pi-web-ui 0.104.1 → 0.104.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-LQLL17DU.js","assets/rolldown-runtime-hePW80VL.js","assets/react-CR5VJ85Q.js","assets/xterm-Cf5xxe4g.js","assets/xterm-B1njb2Cr.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from"./react-CR5VJ85Q.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p}from"./markdown-DXwnfD9T.js";import{n as m,t as h}from"./xterm-Cf5xxe4g.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var g=e(t(),1),_={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},v=g.createContext&&g.createContext(_),y=[`attr`,`size`,`title`];function b(e,t){if(e==null)return{};var n,r,i=x(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function x(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S.apply(null,arguments)}function C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?C(Object(n),!0).forEach(function(t){T(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function T(e,t,n){return(t=E(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e){var t=D(e,`string`);return typeof t==`symbol`?t:t+``}function D(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function O(e){return e&&e.map((e,t)=>g.createElement(e.tag,w({key:t},e.attr),O(e.child)))}function k(e){return t=>g.createElement(A,S({attr:w({},e.attr)},t),O(e.child))}function A(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=b(e,y),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),g.createElement(`svg`,S({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:w(w({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&g.createElement(`title`,null,i),e.children)};return v===void 0?t(_):g.createElement(v.Consumer,null,e=>t(e))}var j=r(),ee=n();function M(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function te(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`11`,y1:`8`,x2:`11`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function N(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`13 2 3 14 12 14 11 22 21 10 12 10 13 2`},child:[]}]})(e)}function P(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function ne(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`},child:[]},{tag:`path`,attr:{d:`M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07`},child:[]}]})(e)}function F(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2`},child:[]},{tag:`circle`,attr:{cx:`9`,cy:`7`,r:`4`},child:[]},{tag:`path`,attr:{d:`M23 21v-2a4 4 0 0 0-3-3.87`},child:[]},{tag:`path`,attr:{d:`M16 3.13a4 4 0 0 1 0 7.75`},child:[]}]})(e)}function re(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`17 8 12 3 7 8`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`3`,x2:`12`,y2:`15`},child:[]}]})(e)}function ie(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`16 16 12 12 8 16`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`12`,x2:`12`,y2:`21`},child:[]},{tag:`path`,attr:{d:`M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3`},child:[]},{tag:`polyline`,attr:{points:`16 16 12 12 8 16`},child:[]}]})(e)}function ae(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`11`,width:`18`,height:`11`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M7 11V7a5 5 0 0 1 9.9-1`},child:[]}]})(e)}function I(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 7 4 4 20 4 20 7`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`15`,y2:`20`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`4`,x2:`12`,y2:`20`},child:[]}]})(e)}function L(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`3 6 5 6 21 6`},child:[]},{tag:`path`,attr:{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`11`,x2:`10`,y2:`17`},child:[]},{tag:`line`,attr:{x1:`14`,y1:`11`,x2:`14`,y2:`17`},child:[]}]})(e)}function R(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function z(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 17 10 11 4 5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`20`,y2:`19`},child:[]}]})(e)}function oe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`6`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`2`},child:[]}]})(e)}function B(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`21`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`12`,x2:`3`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`23`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`},child:[]}]})(e)}function V(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function H(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`4`,y1:`21`,x2:`4`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`4`,y1:`10`,x2:`4`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`21`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`21`,x2:`20`,y2:`16`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`12`,x2:`20`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`14`,x2:`7`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`8`,x2:`15`,y2:`8`},child:[]},{tag:`line`,attr:{x1:`17`,y1:`16`,x2:`23`,y2:`16`},child:[]}]})(e)}function se(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`path`,attr:{d:`M16 10a4 4 0 0 1-8 0`},child:[]}]})(e)}function ce(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z`},child:[]}]})(e)}function le(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`18`,cy:`5`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`12`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`18`,cy:`19`,r:`3`},child:[]},{tag:`line`,attr:{x1:`8.59`,y1:`13.51`,x2:`15.42`,y2:`17.49`},child:[]},{tag:`line`,attr:{x1:`15.41`,y1:`6.51`,x2:`8.59`,y2:`10.49`},child:[]}]})(e)}function ue(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`3`},child:[]},{tag:`path`,attr:{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z`},child:[]}]})(e)}function U(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function de(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`22`,y1:`2`,x2:`11`,y2:`13`},child:[]},{tag:`polygon`,attr:{points:`22 2 15 22 11 13 2 9 22 2`},child:[]}]})(e)}function fe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]}]})(e)}function W(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`6`,cy:`6`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`18`,r:`3`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`4`,x2:`8.12`,y2:`15.88`},child:[]},{tag:`line`,attr:{x1:`14.47`,y1:`14.48`,x2:`20`,y2:`20`},child:[]},{tag:`line`,attr:{x1:`8.12`,y1:`8.12`,x2:`12`,y2:`12`},child:[]}]})(e)}function pe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z`},child:[]},{tag:`polyline`,attr:{points:`17 21 17 13 7 13 7 21`},child:[]},{tag:`polyline`,attr:{points:`7 3 7 8 15 8`},child:[]}]})(e)}function G(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`1 4 1 10 7 10`},child:[]},{tag:`path`,attr:{d:`M3.51 15a9 9 0 1 0 2.13-9.36L1 10`},child:[]}]})(e)}function K(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`23 4 23 10 17 10`},child:[]},{tag:`polyline`,attr:{points:`1 20 1 14 7 14`},child:[]},{tag:`path`,attr:{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`},child:[]}]})(e)}function me(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function he(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`5 3 19 12 5 21 5 3`},child:[]}]})(e)}function ge(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48`},child:[]}]})(e)}function q(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`16.5`,y1:`9.4`,x2:`7.5`,y2:`4.21`},child:[]},{tag:`path`,attr:{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`},child:[]},{tag:`polyline`,attr:{points:`3.27 6.96 12 12.01 20.73 6.96`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`22.08`,x2:`12`,y2:`12`},child:[]}]})(e)}function _e(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`5`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`19`,r:`1`},child:[]}]})(e)}function ve(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`21`,x2:`16`,y2:`21`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12`,y2:`21`},child:[]}]})(e)}function ye(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function be(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3`},child:[]}]})(e)}function xe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z`},child:[]},{tag:`path`,attr:{d:`M19 10v2a7 7 0 0 1-14 0v-2`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`23`,x2:`16`,y2:`23`},child:[]}]})(e)}function J(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`},child:[]}]})(e)}function Se(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`21`,y2:`18`},child:[]}]})(e)}function Ce(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3`},child:[]}]})(e)}function we(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 3 21 3 21 9`},child:[]},{tag:`polyline`,attr:{points:`9 21 3 21 3 15`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`3`,x2:`14`,y2:`10`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`21`,x2:`10`,y2:`14`},child:[]}]})(e)}function Te(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`11`,width:`18`,height:`11`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M7 11V7a5 5 0 0 1 10 0v4`},child:[]}]})(e)}function Ee(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`2`,x2:`12`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`18`,x2:`12`,y2:`22`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`4.93`,x2:`7.76`,y2:`7.76`},child:[]},{tag:`line`,attr:{x1:`16.24`,y1:`16.24`,x2:`19.07`,y2:`19.07`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`6`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`18`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`19.07`,x2:`7.76`,y2:`16.24`},child:[]},{tag:`line`,attr:{x1:`16.24`,y1:`7.76`,x2:`19.07`,y2:`4.93`},child:[]}]})(e)}function De(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`8`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`18`,x2:`21`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`},child:[]}]})(e)}function Oe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function ke(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`12 2 2 7 12 12 22 7 12 2`},child:[]},{tag:`polyline`,attr:{points:`2 17 12 22 22 17`},child:[]},{tag:`polyline`,attr:{points:`2 12 12 17 22 12`},child:[]}]})(e)}function Ae(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4`},child:[]}]})(e)}function je(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`},child:[]}]})(e)}function Me(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`8.5`,r:`1.5`},child:[]},{tag:`polyline`,attr:{points:`21 15 16 10 5 21`},child:[]}]})(e)}function Ne(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`path`,attr:{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function Pe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`7`,height:`7`},child:[]},{tag:`rect`,attr:{x:`14`,y:`3`,width:`7`,height:`7`},child:[]},{tag:`rect`,attr:{x:`14`,y:`14`,width:`7`,height:`7`},child:[]},{tag:`rect`,attr:{x:`3`,y:`14`,width:`7`,height:`7`},child:[]}]})(e)}function Fe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`path`,attr:{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`},child:[]}]})(e)}function Ie(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22`},child:[]}]})(e)}function Le(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`6`,y1:`3`,x2:`6`,y2:`15`},child:[]},{tag:`circle`,attr:{cx:`18`,cy:`6`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`18`,r:`3`},child:[]},{tag:`path`,attr:{d:`M18 9a9 9 0 0 1-9 9`},child:[]}]})(e)}function Re(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`},child:[]}]})(e)}function ze(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`11`,x2:`12`,y2:`17`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`14`,x2:`15`,y2:`14`},child:[]}]})(e)}function Be(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`},child:[]},{tag:`polyline`,attr:{points:`13 2 13 9 20 9`},child:[]}]})(e)}function Ve(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},child:[]},{tag:`polyline`,attr:{points:`14 2 14 8 20 8`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`13`,x2:`8`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`17`,x2:`8`,y2:`17`},child:[]},{tag:`polyline`,attr:{points:`10 9 9 9 8 9`},child:[]}]})(e)}function He(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},child:[]},{tag:`polyline`,attr:{points:`14 2 14 8 20 8`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`18`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`15`,x2:`15`,y2:`15`},child:[]}]})(e)}function Ue(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`3`},child:[]}]})(e)}function We(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`1`,x2:`23`,y2:`23`},child:[]}]})(e)}function Ge(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`},child:[]},{tag:`polyline`,attr:{points:`15 3 21 3 21 9`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`14`,x2:`21`,y2:`3`},child:[]}]})(e)}function Y(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 20h9`},child:[]},{tag:`path`,attr:{d:`M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z`},child:[]}]})(e)}function Ke(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},child:[]}]})(e)}function qe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`7 10 12 15 17 10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`15`,x2:`12`,y2:`3`},child:[]}]})(e)}function Je(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`23`},child:[]},{tag:`path`,attr:{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`},child:[]}]})(e)}function Ye(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`ellipse`,attr:{cx:`12`,cy:`5`,rx:`9`,ry:`3`},child:[]},{tag:`path`,attr:{d:`M21 12c0 1.66-4 3-9 3s-9-1.34-9-3`},child:[]},{tag:`path`,attr:{d:`M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5`},child:[]}]})(e)}function Xe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`22`,y1:`12`,x2:`18`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`12`,x2:`2`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`6`,x2:`12`,y2:`2`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`22`,x2:`12`,y2:`18`},child:[]}]})(e)}function Ze(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`9`,y:`9`,width:`6`,height:`6`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`1`,x2:`9`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`1`,x2:`15`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`9`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`20`,x2:`15`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`9`,x2:`23`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`14`,x2:`23`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`9`,x2:`4`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`14`,x2:`4`,y2:`14`},child:[]}]})(e)}function Qe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 14 4 9 9 4`},child:[]},{tag:`path`,attr:{d:`M20 20v-7a4 4 0 0 0-4-4H4`},child:[]}]})(e)}function $e(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},child:[]}]})(e)}function et(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 10 4 15 9 20`},child:[]},{tag:`path`,attr:{d:`M20 4v7a4 4 0 0 1-4 4H4`},child:[]}]})(e)}function tt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`},child:[]}]})(e)}function nt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`16 18 22 12 16 6`},child:[]},{tag:`polyline`,attr:{points:`8 6 2 12 8 18`},child:[]}]})(e)}function rt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function it(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`},child:[]},{tag:`rect`,attr:{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`},child:[]}]})(e)}function at(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]}]})(e)}function ot(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`13 17 18 12 13 7`},child:[]},{tag:`polyline`,attr:{points:`6 17 11 12 6 7`},child:[]}]})(e)}function st(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`11 17 6 12 11 7`},child:[]},{tag:`polyline`,attr:{points:`18 17 13 12 18 7`},child:[]}]})(e)}function ct(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`18 15 12 9 6 15`},child:[]}]})(e)}function lt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function ut(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 18 9 12 15 6`},child:[]}]})(e)}function dt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function ft(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function pt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`},child:[]},{tag:`polyline`,attr:{points:`22 4 12 14.01 9 11.01`},child:[]}]})(e)}function mt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`13`,r:`4`},child:[]}]})(e)}function ht(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`},child:[]},{tag:`polyline`,attr:{points:`3.27 6.96 12 12.01 20.73 6.96`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`22.08`,x2:`12`,y2:`12`},child:[]}]})(e)}function gt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z`},child:[]},{tag:`path`,attr:{d:`M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`},child:[]}]})(e)}function _t(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`},child:[]},{tag:`path`,attr:{d:`M13.73 21a2 2 0 0 1-3.46 0`},child:[]}]})(e)}function vt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},child:[]}]})(e)}function yt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`7`,y1:`17`,x2:`17`,y2:`7`},child:[]},{tag:`polyline`,attr:{points:`7 7 17 7 17 17`},child:[]}]})(e)}function bt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 5 19 12 12 19`},child:[]}]})(e)}function xt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}function St(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`21 8 21 21 3 21 3 8`},child:[]},{tag:`rect`,attr:{x:`1`,y:`3`,width:`22`,height:`5`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`12`,x2:`14`,y2:`12`},child:[]}]})(e)}function Ct(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`5`,r:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`22`,x2:`12`,y2:`8`},child:[]},{tag:`path`,attr:{d:`M5 12H2a10 10 0 0 0 20 0h-3`},child:[]}]})(e)}function wt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`9`,x2:`12`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function Tt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`},child:[]}]})(e)}function Et(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`22 12 18 12 15 21 9 3 6 12 2 12`},child:[]}]})(e)}function Dt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M11.646 15.146 5.854 9.354a.5.5 0 0 1 .353-.854h11.586a.5.5 0 0 1 .353.854l-5.793 5.792a.5.5 0 0 1-.707 0Z`},child:[]}]})(e)}function Ot(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 17H7l-4 4v-7`},child:[]},{tag:`path`,attr:{d:`M14 17h1`},child:[]},{tag:`path`,attr:{d:`M14 3h1`},child:[]},{tag:`path`,attr:{d:`M19 3a2 2 0 0 1 2 2`},child:[]},{tag:`path`,attr:{d:`M21 14v1a2 2 0 0 1-2 2`},child:[]},{tag:`path`,attr:{d:`M21 9v1`},child:[]},{tag:`path`,attr:{d:`M3 9v1`},child:[]},{tag:`path`,attr:{d:`M5 3a2 2 0 0 0-2 2`},child:[]},{tag:`path`,attr:{d:`M9 3h1`},child:[]}]})(e)}function kt(e){return e.map(e=>e.kind===`package`?`pi update npm:${e.name}`:e.kind===`git-extension`?`pi update ${At(e.source??e.name)}`:e.kind===`plugin`?`pi-web-ui install ${e.source??e.name} --name ${e.pluginId??e.name} --force`:`npm i -g ${e.name}@latest`).join(`; `)}function At(e){return e.startsWith(`git:`)?e:`git:${e}`}function jt(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Mt(e,t,n={}){let{enabled:r=!0,ignore:i}=n,a=(0,g.useRef)(t);(0,g.useLayoutEffect)(()=>{a.current=t}),(0,g.useEffect)(()=>{if(!r)return;let t=(e,t)=>{if(!t)return!1;let n=`current`in t?t.current:t;return n?n.contains(e):!1},n=n=>{let r=n.target;r instanceof Node&&(e.current?.contains(r)||i&&(Array.isArray(i)?i:[i]).some(e=>t(r,e))||a.current(n))};return document.addEventListener(`mousedown`,n),document.addEventListener(`touchstart`,n),()=>{document.removeEventListener(`mousedown`,n),document.removeEventListener(`touchstart`,n)}},[r,e,i])}var Nt=[],Pt=!1;function Ft(e){if(e.key===`Escape`&&Nt.length!==0)for(let t=Nt.length-1;t>=0;t--){let n=Nt[t];if(n()!==!1){e.preventDefault(),e.stopPropagation();break}}}function It(){!Pt&&typeof document<`u`&&(document.addEventListener(`keydown`,Ft,!0),Pt=!0)}function Lt(){Pt&&Nt.length===0&&typeof document<`u`&&(document.removeEventListener(`keydown`,Ft,!0),Pt=!1)}function Rt(e){return Nt.push(e),It(),()=>{let t=Nt.lastIndexOf(e);t>=0&&Nt.splice(t,1),Lt()}}function zt(e,t=!0){let n=(0,g.useRef)(e);(0,g.useLayoutEffect)(()=>{n.current=e}),(0,g.useEffect)(()=>{if(t)return Rt(()=>n.current())},[t])}var X=i();function Bt({align:e,triggerLeft:t,triggerRight:n,menuWidth:r,viewportWidth:i,margin:a=8}){if(r<=0||i<=0)return 0;let o=e===`left`?t:n-r,s=Math.max(a,i-a-r);return Math.round(Math.max(a,Math.min(o,s))-o)}function Vt({trigger:e,open:t,onOpenChange:n,children:r,align:i=`right`,fit:a=!1,direction:o=`down`,tip:s,caret:c=!0,menuClassName:l,triggerClassName:u,menuRef:d,menuStyle:f}){let p=(0,g.useRef)(null),m=(0,g.useRef)(null),[h,_]=(0,g.useState)(0),v=e=>{m.current=e,typeof d==`function`?d(e):d&&`current`in d&&(d.current=e)},y=()=>{let e=p.current,t=m.current;if(!e||!t)return;if(window.innerWidth<=768){h!==0&&_(0);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.width===0&&r.height===0||n.width===0){h!==0&&_(0);return}let a=n.width,o=Bt({align:i,triggerLeft:r.left,triggerRight:r.right,menuWidth:a,viewportWidth:window.innerWidth,margin:8});o!==h&&_(o)};return(0,g.useLayoutEffect)(()=>{t?y():h!==0&&_(0)}),(0,g.useEffect)(()=>{if(t)return window.addEventListener(`resize`,y),()=>window.removeEventListener(`resize`,y)},[t,h]),Mt(p,()=>n(!1),{enabled:t}),zt(()=>n(!1),t),(0,X.jsxs)(`div`,{className:`dropdown ${i} ${a?`fit`:``} ${o===`up`?`dd-up`:``}`,ref:p,children:[(0,X.jsxs)(`button`,{type:`button`,className:u??`chip`,onClick:()=>n(!t),"aria-expanded":t,"data-tip":s,children:[e,c&&(0,X.jsx)(dt,{className:`dd-caret ${t?`up`:``}`})]}),t&&(0,X.jsx)(`div`,{className:`dd-menu ${l??``}`,ref:v,style:h===0?f:{...f,transform:f?.transform?`${f.transform} translateX(${h}px)`:`translateX(${h}px)`},children:r})]})}function Ht({active:e,disabled:t=!1,title:n,onClick:r,children:i}){return(0,X.jsx)(`button`,{type:`button`,className:`dd-item ${e?`active`:``}`,disabled:t,title:n,onClick:r,children:i})}var Ut=`pi-web-tts`,Wt={enabled:!1,announce:!0,readReplies:!1,rate:1,voiceURI:``};function Gt(){try{let e=localStorage.getItem(Ut);if(!e)return{...Wt};let t={...Wt,...JSON.parse(e)};for(let e of[`enabled`,`announce`,`readReplies`])typeof t[e]!=`boolean`&&(t[e]=Wt[e]);return t.rate=typeof t.rate!=`number`||!Number.isFinite(t.rate)?Wt.rate:Math.round(Math.max(.5,Math.min(2,t.rate))*10)/10,typeof t.voiceURI!=`string`&&(t.voiceURI=Wt.voiceURI),t}catch{return{...Wt}}}function Kt(e){try{localStorage.setItem(Ut,JSON.stringify(e))}catch{}}function qt(){return typeof window<`u`&&`speechSynthesis`in window}function Jt(e,t,n){if(e){let n=t.find(t=>t.voiceURI===e);if(n)return n}let r=n.split(`-`)[0]?.toLowerCase();return r?t.find(e=>e.lang.toLowerCase().startsWith(r))??null:null}function Yt(e){let t=e??``;return t=t.replace(/```[\s\S]*?(?:```|$)/g,` `),t=t.replace(/`([^`]+)`/g,`$1`),t=t.replace(/!\[[^\]]*\]\([^)]*\)/g,` `),t=t.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`),t=t.replace(/^\s{0,3}#{1,6}\s+/gm,``),t=t.replace(/^\s{0,3}>\s?/gm,``),t=t.replace(/^\s*[-*+]\s+/gm,``),t=t.replace(/^\s*\|?[\s:|-]*\|[\s:|-]*$/gm,``),t=t.replace(/\|/g,` `),t=t.replace(/(\*\*\*|\*\*|__)(.*?)\1/g,`$2`),t=t.replace(/(\*|_)([^*_\n]+)\1/g,`$2`),t=t.replace(/<[^>]+>/g,` `),t=t.replace(/\r/g,``),t=t.replace(/[ \t]+/g,` `),t=t.replace(/\s*\n+\s*/g,` `),t=t.trim(),t.length>600&&(t=`${t.slice(0,600).trimEnd()}…`),t}function Xt(e){if(!Array.isArray(e))return``;for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.role===`assistant`)return Yt((n.content??[]).filter(e=>e?.type===`text`&&typeof e.text==`string`).map(e=>e.text??``).join(`
|
|
3
3
|
`))}return``}var Zt=!1,Qt=null,$t=null,en=new Set;function tn(e,t=null){e?(Zt=!0,Qt=t):(Zt=!1,Qt=null);for(let t of en)try{t(e)}catch{}}function nn(){return Zt}function rn(){return Zt?Qt:null}function an(e){return en.add(e),()=>en.delete(e)}function on(e,t=Gt(),n){if(e&&qt())try{let r=window.speechSynthesis;r.cancel();let i=new SpeechSynthesisUtterance(e);i.rate=t.rate;let a=Jt(t.voiceURI,r.getVoices(),navigator.language);a&&(i.voice=a),i.onend=()=>{$t===i&&tn(!1)},i.onerror=()=>{$t===i&&tn(!1)},$t=i,tn(!0,n??null),r.speak(i)}catch{$t=null,tn(!1)}}function sn(){if(qt()){try{window.speechSynthesis.cancel()}catch{}$t=null,tn(!1)}}var cn=null;function ln(e){if(e===void 0){let t=globalThis.document;if(t&&typeof t.baseURI==`string`&&t.baseURI)try{e=new URL(t.baseURI).pathname}catch{}if(e===void 0)return`/`}if(!e||e===`/`)return`/`;let t=e.replace(/index\.html$/i,``);return t.endsWith(`/`)||(t+=`/`),t}function un(){return cn===null&&(cn=ln()),cn}function dn(e,t){return t===`/`?e:t+e.replace(/^\/+/,``)}function fn(e){return dn(e,un())}var pn=`pi-web-ui:token`;function mn(){try{let e=new URL(window.location.href),t=e.searchParams.get(`token`);t&&(localStorage.setItem(pn,t.trim()),e.searchParams.delete(`token`),window.history.replaceState(null,``,e.toString()))}catch{}}function hn(){try{return localStorage.getItem(pn)??``}catch{return``}}function gn(e){let t=hn();return t?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(t)}`:e}var _n=[`zh`,`en`,`de`,`es`,`fr`,`it`,`ja`,`ko`,`pt`,`ru`];function vn(e,t,n,r=_n){let i=(e??``).trim();if(i)return i;for(let e of t??[]){let t=String(e??``).trim().toLowerCase().replace(/_/g,`-`);if(!t)continue;if(r.includes(t))return t;let n=t.split(`-`)[0];if(n&&r.includes(n))return n}let a=(n??``).trim().toLowerCase();return a&&r.includes(a)?a:`en`}var yn=`pi-web-ui:lang`,bn={docTitle:`pi-web-ui — pi 编码智能体`,cancel:`取消`,ok:`确定`,save:`保存`,close:`关闭`,widgetExpand:`点击放大查看完整输出`,collapsePanel:`收起面板`,expandPanel:`展开面板`,dragToResize:`拖拽调整宽度 · 双击复位`,loading:`加载中…`,connected:`已连接`,connecting:`连接中…`,reconnecting:`重连中…`,language:`语言`,githubRepo:`GitHub 仓库(xing-shuyin/pi-web-ui)`,copy:`复制`,viewSwitch:`视图切换`,chat:`对话`,terminal:`终端`,selectModel:`选择模型`,availableModels:`可用模型`,allProviders:`全部`,providers:`服务商`,noModels:`暂无可用模型(请先配置 API 密钥)`,reasoning:`推理`,vision:`识图`,refreshModels:`刷新模型列表(保留手填,合并新增)`,manageModels:`⚙ 管理模型(新增 / 修改)`,thinkingLevel:`思考强度`,thinking:`思考`,thinkingChip:`{level}`,sound:`声音`,theme:`主题`,themeDefault:`深色(默认)`,themeGroupClassics:`现代经典`,themeGroupBuiltin:`原始预设`,themeLight:`浅色`,themeDark:`深色`,newChat:`新对话`,newChatEphemeral:`临时对话`,newChatEphemeralTip:`临时对话(仅内存,关闭即销毁,不进历史记录)`,ephemeralBadge:`临时`,ephemeralBannerText:`当前为临时对话:消息仅保存在内存中,关闭后自动销毁,不进入历史记录。`,more:`更多`,brand:`品牌`,newChatTip:`新建对话(每个浏览器独立保存会话)`,"thinking.off":`关闭`,"thinking.minimal":`极简`,"thinking.low":`低`,"thinking.medium":`中`,"thinking.high":`高`,"thinking.xhigh":`极高`,"thinking.max":`最大`,thinkingUnsupported:`当前模型不支持该级别,已按模型能力就近生效`,context:`上下文`,contextUsage:`上下文用量`,cumulativeCost:`累计成本`,sessionMessages:`会话消息数`,messages:`消息`,pluginStatus:`插件状态`,engineBadge:`引擎`,working:`工作中`,queued:`排队`,enterPath:`输入路径,Enter 切换`,cwdTip:`工作目录:{path}(点击切换)`,manageProjects:`管理项目和工作目录`,projectPickerTitle:`选择工作目录`,newProject:`新建项目`,projectName:`项目名称`,createAndOpenProject:`创建并打开`,invalidProjectName:`请输入不含路径分隔符的项目名称`,cwdGoUp:`上级目录`,cwdPickCurrent:`选择当前目录`,cwdChoose:`选择`,cwdEnter:`进入`,cwdEmpty:`(空目录)`,cwdNewFolder:`新建文件夹`,cwdNewName:`文件夹名称`,cwdCreate:`创建`,cwdCancel:`取消`,cacheHit:`缓存命中`,cacheHitTip:`缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)`,tps:`t/s`,rateTip:`实时生成速率(估算)`,hostResources:`主机资源`,hostProcessor:`CPU`,hostMemory:`RAM`,hostResourcesTip:`运行 pi-web-ui 服务的主机 · CPU 为约 10 秒平均(2 秒采样),与任务管理器采样时刻不同会有几秒偏差`,folderRef:`文件夹引用:{path}`,refOnly:`仅引用:{path}`,attachContent:`附加内容:{path}`,attachLines:`附加选中行:{path}(第 {start}-{end} 行)`,attachImage:`图片:{name}`,attachFile:`文件:{name}`,removeAttachment:`移除附件`,attachHint:`将随下一条消息发送`,uploadFile:`添加文件(图片/文本/任意文件,也可直接拖入或粘贴截图)`,dropHereToAttach:`松开以添加文件`,imageNotSupported:`当前模型不支持识图:图片将交给视觉桥转写(若未配置视觉模型则可能被忽略)`,imageLoadFailed:`图片读取失败:{name}`,fileLoadFailed:`文件读取失败:{name}`,fileTooLarge:`文件过大已跳过(>{size}MB):{name}`,foldersNotSupported:`不支持直接拖入文件夹,请展开后选择文件`,placeholderStreaming:`智能体正在工作中…回车插队发送,或点「排队」等回答结束后发送`,placeholderStreamingQueued:`智能体正在工作中…回车或点「排队」,回答完全结束后发送(本引擎不支持插队)`,placeholderIdle:`给 pi 发送消息 — Enter 发送,/ 查看命令`,placeholderConnecting:`正在连接服务器…`,stopAgent:`停止智能体`,stop:`停止`,bgTasks:`后台任务`,bgTasksTip:`AI 在后台启动的服务(npm run dev & 等)——可逐个停止或全部关闭,对话结束后仍保留`,bgTasksEmpty:`暂无后台任务`,bgTasksDesc:`AI 运行中启动并仍在监听的进程(按监听端口检测)`,bgTaskPort:`端口`,bgTaskPid:`PID`,bgTaskSince:`启动`,bgTaskStop:`停止`,bgTaskStopAll:`全部关闭`,bgTaskRefresh:`刷新`,bgTaskKeep:`保留(自动清理不碰)`,bgTaskKeepOn:`已保留(自动清理不碰)—— 点一下取消`,bgTaskCleanup:`自动清理遗留`,bgTaskCleanupOff:`关`,bgTaskCleanupMinutes:`闲置 {n} 分钟`,bgTaskCleanupHint:`开启后服务端定期把闲置超阈值的 AI 起后台实例杀掉(📌 钉住的不算);杀完会发一条通知`,bgTaskCleanNow:`立即清理`,bgTaskCleanNowHint:`按当前阈值立刻清一次;阈值为关时按 30 分钟兜底`,bgTaskJustNow:`刚刚`,bgTaskMinutes:`{n} 分钟前`,bgTaskHours:`{n} 小时前`,bgTaskDays:`{n} 天前`,stopBash:`停止`,stopBashTip:`停止正在运行的 bash 命令(对话继续)`,supplement:`排队`,supplementTip:`加入队列:AI 回答完全结束后才发送(不打断)`,steerTip:`插队:立即发送,本回合马上响应(Enter)`,queueSteerTag:`插队`,queueFollowTag:`排队`,queueRemoveTip:`移除此排队消息`,queueRecallTip:`撤回并放回输入框(可编辑后重发)`,sendTip:`发送(Enter)`,composerResize:`拖拽调整输入框高度(双击恢复默认)`,quickPhrases:`快捷短语`,quickPhrasesDesc:`输入框上方的一排常用短语按钮,点击即发送(会带上当前已选的文件附件,不清空输入框草稿)`,quickPhrasesEnabled:`启用快捷短语`,quickPhrasesOffHint:`已关闭:输入框上方不再显示快捷短语按钮(已配置的短语保留,可随时重新启用)`,quickPhrasesPlaceholder:`输入常用短语…(Enter 添加)`,quickPhrasesAdd:`添加`,quickPhrasesEmpty:`还没有快捷短语,在下面添加第一条`,quickPhrasesTip:`点击发送:{text}`,quickPhrasesSendTip:`左键插队发送,右键排队发送`,quickPhrasesMoveUp:`上移`,quickPhrasesMoveDown:`下移`,quickPhrasesDelete:`删除该短语`,quickPhrasesEdit:`编辑该短语`,quickPhrasesEditPh:`修改短语…(Enter 保存,Esc 取消)`,quickPhrasesReset:`恢复默认短语`,slashCommands:`命令`,slashMenuHint:`↑↓ 选择 · Enter/Tab 补全`,atMentions:`提及`,atMenuHint:`↑↓ 选择 · Enter/Tab 插入`,slashHelpTitle:`pi 命令`,slashLoading:`命令列表加载中…(连接服务器后可用)`,slashBuiltin:`内置`,slashExtension:`扩展`,slashPrompt:`模板`,slashSkill:`技能`,slashPlugin:`插件`,slashCopied:`已复制上一条助手回复`,slashCopyFailed:`复制失败,请手动复制`,slashCopyEmpty:`还没有可复制的助手回复`,recentProjects:`最近项目`,runningConversations:`运行的对话`,elsewhereBadge:`另一处`,elsewherePseudoBadge:`无头任务`,elsewhereTip:`在其他标签页 / 设备上打开的对话(运行中或已结束未关闭,右键可过户到本页查看)`,elsewherePseudoTip:`定时任务/插件正在后台会话中执行,报告会自动落回绑定的对话;不支持过户到当前页面`,elsewhereActions:`操作(过户到本页 / 复制 id…)`,takeoverConversation:`过户到当前页面`,takeoverConfirm:`确认过户到当前页面?`,takeoverHasQuestion:`有问卷等答复,点击直接作答`,waitingQuestionBadge:`有问卷等答复,点击查看`,subagentBadge:`子代理`,collapseSubagents:`折叠子代理`,expandSubagents:`展开子代理`,subagentBadgeCount:`{n} 个子代理`,subagentsStreamingTip:`{n} 个子代理(有子代理运行中)`,subagentsQuestionTip:`{n} 个子代理(等待问卷答复)`,subagentsErrorTip:`{n} 个子代理(存在错误)`,subagentsCountTip:`{n} 个子代理`,convErrorBadge:`子代理运行报错:{error}`,subagentTitle:`子代理 · {title}`,historySessions:`历史对话`,openHistory:`历史对话`,openFiles:`文件列表`,openProject:`打开项目`,streaming:`进行中…`,noHistory:`还没有历史对话`,current:`当前`,messageCount:`{n} 条消息`,tuiTip:`pi 终端(TUI)中的对话`,deleteProject:`从最近项目移出`,deleteProjectConfirm:`确认移出`,deleteSession:`删除该对话记录(不可恢复)`,deleteSessionConfirm:`确认删除`,renameSession:`重命名该对话`,renameSessionPlaceholder:`输入新名称…`,dismissConversation:`从运行列表移出(历史记录保留)`,dismissConversationConfirm:`确认移出`,pinConversation:`钉住(切换其他对话也不移出)`,unpinConversation:`取消钉住`,pinnedConversation:`已钉住:切换到其他对话时,本对话会一直留在「运行的对话」里,直到被手动移出`,dismissFinishedSubagents:`关闭已结束的子代理({n} 个)`,dismissFinishedSubagentsScoped:`关闭该对话下已结束的子代理(含嵌套,{n} 个)`,dismissStreamingConfirm:`仍在运行,确认强行关闭?(运行将被中止)`,dismissFinishedOnly:`仅关已结束({n})`,dismissForceAll:`强行全关(含子代理 {n})`,forceDismissTitle:`强行关闭本对话及全部 {n} 个子代理(运行中的 {m} 个将被中止)`,forceDismissConversation:`强行关闭对话(含全部子代理)`,persistSubagent:`固化为普通对话`,saveEphemeral:`保存为正式对话`,forceDismissConfirm:`确认强行关闭?未结束的运行将被中止,再点一次`,noFinishedSubagents:`没有可关闭的已结束子代理`,collapseSection:`折叠`,expandSection:`展开`,emptyChat:`空对话`,reaskDirectly:`直接重问`,reaskDirectlyTip:`直接从这里重新提问(不修改内容,新建分支对话,原对话保留)`,editReask:`编辑重问`,editReaskTip:`修改此问题,并从这里重新提问(会新建一个分支对话,原对话保留)`,forkSession:`派生分支`,forkSessionTip:`从此消息处派生新分支会话(截取该位置之前的转录)`,rollbackSession:`回滚到此`,rollbackSessionTip:`丢弃此消息之后的内容,在当前会话直接继续`,rollbackConfirm:`确定要回滚到此消息吗?该消息之后的所有对话将被丢弃,并在当前会话继续。`,rollbackRestoreWorkspace:`同时还原工作区物理文件(Dual-State Rollback)`,rollbackRestoreWorkspaceTip:`还原物理代码到该消息发起时的检查点版本(通过 Git 影子快照)`,toolApprovalTitle:`工具执行待审批(Human-in-the-Loop)`,toolApprovalApprove:`批准执行`,toolApprovalDeny:`拒绝`,toolApprovalEditAndRun:`修改并放行 (Edit & Run)`,toolApprovalRiskAlert:`检测到高危操作或关键配置修改`,toolApprovalHitsTitle:`高危命中清单`,approvalHitPos:`位置:第 {index} 字符起(长 {length} 字符)`,approvalCommandPreview:`高危命令定位`,toolApprovalParams:`工具调用参数`,toolApprovalEditPlaceholder:`就地修改参数 JSON…`,toolApprovalCategory:`规则档位`,toolApprovalAllowCategory:`本对话允许同类`,toolApprovalAllowCategoryHint:`本对话内这一类高危操作后续不再询问(设置 →「工具」页可撤销)`,toolApprovalAllowConversation:`本对话全部允许`,toolApprovalAllowConversationHint:`本对话内所有高危操作后续都不再询问(设置 →「工具」页可撤销)`,toolApprovalEnabled:`工具执行审批(人机协同)`,toolApprovalEnabledDesc:`开:高危操作(rm -rf / 破坏性 git / 敏感文件 / 工作区外写入 / 插件要求确认)弹窗等你批准、拒绝或改参数;关:一切审批都不弹(内置高危检测直接放行,插件要求确认也按放行处理)。`,toolApprovalPolicyTitle:`已记住的放行(本对话)`,toolApprovalPolicyAllowAll:`本对话全部允许审批`,toolApprovalPolicyRevoke:`撤销`,toolApprovalPolicyHint:`只存在内存里:重启服务或新对话即恢复询问;策略跟对话走(手动过户时一起搬)。`,settingsApprovalRules:`审批规则`,settingsApprovalRulesDesc:`全局自定义人机协同拦截规则,支持基于正则/通配符/路径对工具命令或参数配置「需审批」、「直接拒绝」或「免审放行」。规则自顶向下首条匹配优先。`,manageApprovalRules:`管理审批规则`,approvalRuleNew:`新增规则`,approvalRuleEdit:`编辑规则`,approvalRuleDelete:`删除`,approvalRuleReset:`恢复默认`,approvalRuleActionAsk:`需审批`,approvalRuleActionDeny:`直接拒绝`,approvalRuleActionAllow:`免审放行`,approvalRuleTools:`适用工具`,approvalRuleToolsTip:`输入工具名(如 bash、write、edit),以逗号分隔;输入 * 表示匹配所有工具`,approvalRuleField:`检查字段`,approvalRuleFieldCommand:`命令 (command)`,approvalRuleFieldPath:`文件路径 (path)`,approvalRuleFieldParams:`完整参数 JSON (params)`,approvalRuleMatch:`匹配方式`,approvalRuleMatchRegex:`正则表达式 (regex)`,approvalRuleMatchGlob:`通配符 (glob)`,approvalRuleMatchContains:`包含子串 (contains)`,approvalRuleMatchPrefix:`前缀开头 (prefix)`,approvalRuleMatchOutsideWs:`工作区外路径 (outside_workspace)`,approvalRuleValue:`匹配表达式 / 模式串`,approvalRuleValueTip:`根据匹配方式输入对应规则,例如 rm -rf 或 \\.env$`,approvalRuleLabel:`规则名称 (中文)`,approvalRuleLabelEn:`规则名称 (英文)`,approvalRuleReason:`拦截原因说明 (中文)`,approvalRuleReasonEn:`拦截原因说明 (英文)`,approvalRuleEnabled:`启用该规则`,approvalRuleBuiltin:`内置`,approvalRuleEmpty:`当前没有审批规则。点击右上角「+ 新增规则」添加自定义拦截与放行策略。`,approvalRuleMoveUp:`上移`,approvalRuleMoveDown:`下移`,settingsMcp:`MCP 服务器`,settingsMcpDesc:`Model Context Protocol (MCP) 服务器管理。支持通过 stdio 或 HTTP 将外部工具引入 AI 会话。配置支持 Pi 全局 (~/.pi/agent/mcp.json) 与当前项目 (.pi/mcp.json)。`,mcpReload:`重新加载`,mcpAddServer:`添加服务器`,mcpFilterAll:`全部`,mcpFilterGlobal:`全局设置`,mcpFilterProject:`项目级设置`,mcpGlobalPath:`全局配置`,mcpProjectPath:`项目配置`,mcpEmptyTitle:`未配置 MCP 服务器`,mcpEmptyDesc:`Model Context Protocol 让 AI 可以访问本地文件系统、数据库、GitHub 或自定义工具服务器。点击下方快捷预设或右上角按钮添加。`,mcpQuickAdd:`快捷添加预设`,mcpScopeGlobal:`全局设置`,mcpScopeProject:`项目级设置`,mcpScopeGlobalHint:`保存在 ~/.pi/agent/mcp.json,在所有项目中通用生效`,mcpScopeProjectHint:`保存在当前工作区 .pi/mcp.json,仅在当前项目生效`,mcpStatusRunning:`运行中`,mcpStatusStopped:`已停用`,mcpStatusError:`异常`,mcpEnableHint:`启用该 MCP 服务器`,mcpDisableHint:`停用该 MCP 服务器(保留配置)`,mcpToolsCount:`包含 {count} 个工具`,mcpDeleteConfirmTitle:`删除 MCP 服务器`,mcpDeleteConfirmDesc:`确定要从{scope}中删除 MCP 服务器「{name}」吗?该操作不可撤销。`,mcpAddModalTitle:`添加 MCP 服务器`,mcpEditModalTitle:`编辑 MCP 服务器`,mcpPresetSelect:`预设模板(快捷填充)`,mcpScopeLabel:`配置作用域`,mcpNameLabel:`服务器标识名`,mcpNamePlaceholder:`例如 filesystem, github, fetch`,mcpTransportLabel:`传输协议`,mcpTransportStdio:`命令行进程`,mcpTransportHttp:`远程端点`,mcpCommandLabel:`启动命令`,mcpCommandPlaceholder:`例如 npx, uvx, node, python`,mcpArgsLabel:`命令行参数`,mcpArgsPlaceholder:`以空格分隔的参数列表,例如 -y @modelcontextprotocol/server-filesystem .`,mcpCwdLabel:`运行工作目录 (cwd)`,mcpCwdPlaceholder:`留空默认跟随工作区`,mcpEnvLabel:`环境变量 (env)`,mcpAddEnv:`添加变量`,mcpEnvKeyPlaceholder:`变量名(如 API_KEY)`,mcpEnvValuePlaceholder:`变量值`,mcpUrlLabel:`端点 URL`,mcpUrlPlaceholder:`例如 https://mcp.example.com/mcp`,mcpHeadersLabel:`请求头 (Headers)`,mcpAddHeader:`添加请求头`,mcpHeaderKeyPlaceholder:`请求头名称(如 Authorization)`,mcpHeaderValuePlaceholder:`值(如 Bearer token)`,mcpDescriptionLabel:`功能说明`,mcpDescriptionPlaceholder:`简要说明此服务器提供的工具能力`,mcpEnabledLabel:`启用状态`,mcpEnabledDesc:`停用后保留配置但不启动子进程或连接端点`,mcpPresetCustom:`自定义配置`,mcpPresetCustomDesc:`手动输入完整的命令与参数`,mcpPresetFilesystem:`文件系统 (Filesystem)`,mcpPresetFilesystemDesc:`访问指定目录文件的标准 MCP 服务器`,mcpPresetFetch:`网页抓取 (Fetch)`,mcpPresetFetchDesc:`抓取并读取网页内容的 MCP 服务器`,mcpPresetMemory:`持久记忆 (Memory)`,mcpPresetMemoryDesc:`基于知识图谱的持久化记忆管理`,mcpPresetGithub:`GitHub 代码库`,mcpPresetGithubDesc:`GitHub 仓库、Issue 与 PR 操作工具`,mcpPresetSqlite:`SQLite 数据库`,mcpPresetSqliteDesc:`查询与操作本地 SQLite 数据库`,mcpTabConfigured:`已配置`,mcpTabMarket:`MCP 市场`,mcpBrowseMarket:`浏览 MCP 市场`,mcpMarketSearchPlaceholder:`搜索 MCP 服务器名称、包名或能力描述…`,mcpBadgeOfficial:`官方`,mcpConfigured:`已配置`,mcpAddGlobal:`添加全局`,mcpAddProject:`添加项目`,mcpAddGlobalHint:`添加至 Pi 全局配置 (~/.pi/agent/mcp.json),在所有项目生效`,mcpAddProjectHint:`添加至当前项目配置 (.pi/mcp.json),仅在当前项目生效`,skillTabInstalled:`已安装`,skillTabMarket:`技能市场`,skillEmptyDesc:`暂未安装任何技能,前往技能市场发现并一键安装开箱即用的专业工作流技能。`,skillBrowseMarket:`浏览技能市场`,skillMarketSearchPlaceholder:`搜索技能名称、工作流或能力说明…`,skillCatAll:`全部`,skillCatQuality:`代码质量`,skillCatWorkflow:`规范与流程`,skillCatArchitecture:`架构设计`,skillCatDevops:`运维与数据库`,skillCatStack:`语言专项`,skillInspectPrompt:`查看提示词`,skillInstalled:`已安装`,skillInstallGlobal:`全局安装`,skillInstallProject:`项目安装`,skillInstallGlobalHint:`安装到全局用户技能目录 (~/.pi/agent/skills)`,skillInstallProjectHint:`安装到当前工作区技能目录 (.pi/skills)`,skillInspectModalTitle:`技能详情: {name}`,mcpSourceSelectLabel:`源选择`,mcpSourceSmithery:`Smithery 开放注册中心 (api.smithery.ai)`,mcpSourceGithub:`GitHub 官方仓库 (modelcontextprotocol/servers)`,mcpSourceCustom:`自定义 API / 目录源`,mcpSourceCustomPlaceholder:`输入自定义 MCP 注册中心 API 或 JSON 目录 URL`,mcpMarketLoading:`正在检索远程 MCP 服务器…`,mcpMarketRetry:`重试`,skillRepoSelect:`GitHub 仓库源`,skillRepoDefault:`Anthropic 官方技能库 (anthropics/skills)`,skillRepoCustom:`自定义 GitHub 仓库 (owner/repo)`,skillRepoCustomPlaceholder:`输入 GitHub 仓库,例如 your-org/custom-skills`,skillMarketLoading:`正在从 GitHub 检索技能目录…`,skillContentLoading:`正在拉取 SKILL.md 指令内容…`,skillMarketRetry:`重试`,planBoardTitle:`任务`,planBoardCompleted:`已完成`,planBoardInProgress:`进行中`,planBoardPending:`待执行`,planBoardFailed:`失败`,planImplementBtn:`实施`,planImplementTip:`关掉只规划闸门,按上面的计划开始写代码`,planImplementRequest:`按计划看板上的计划开始实施。`,planBoardExportMarkdown:`复制为 Markdown`,planBoardExportSuccess:`计划已复制为 Markdown`,planCleanHandoffBtn:`✨ 净室`,planCleanHandoffTip:`在新会话中开始实施(带走目标与计划,避免历史探索上下文干扰)`,planCleanHandoffPrompt:`我们已在规划期制定了如下任务计划。这是一个全新的净室执行会话,请专注于按照计划步骤推进实施:`,planBoardAddStep:`添加步骤`,planBoardEditStep:`编辑步骤`,planBoardDeleteStep:`删除步骤`,planBoardStepTitlePlaceholder:`步骤标题…`,planBoardStepDescPlaceholder:`步骤描述/验收要求(可选)…`,placeholderPlanMode:`📋 计划模式:只调研与制定计划,代码写入操作将被拦截…`,planModeBadge:`只读规划中`,clear:`清空`,confirm:`确定`,forkBadge:`分支`,forkBadgeTip:`派生自`,reaskFromHere:`从此处重新提问`,editPlaceholder:`修改问题内容…`,editAttachmentHint:`原附件已保留,可粘贴/拖入新图片或文件 · ⌘/Ctrl+Enter 提交 · Esc 取消`,expandMsg:`展开`,collapseMsg:`收起`,toolCalls:`工具调用`,bashRuns:`终端运行`,images:`图片`,update:`更新`,currentVersion:`当前版本`,latestVersion:`最新版本`,checkingUpdate:`检查中…`,checkUpdate:`检查更新`,upToDate:`已是最新版本`,updateAvailable:`发现新版本 v{version}`,updateJustPublished:`v{version} 刚刚发布,npm 缓存可能尚未同步——若未检测到新版本,请稍后重新检查`,updateNow:`在终端中更新`,updateTabTitle:`更新 pi-web-ui`,updateTerminalHint:`点击后会在可见终端中运行 npm i -g pi-web-ui@latest;完成后重启服务生效(pi-web-ui server restart)。`,updateDesktopNote:`桌面版不走 npm 全局安装:它的服务随应用本身发布,上面的终端命令对它无效。请用下面的应用内更新,或去下载页换包。`,updateDesktopCheck:`检查桌面更新`,updateDesktopChecking:`正在检查桌面更新…`,updateDesktopAvailable:`发现桌面版新版本 v{version}`,updateDesktopDownload:`下载更新`,updateDesktopDownloading:`下载中 {n}%`,updateDesktopDownloaded:`已下载完成,点“安装并重启”生效`,updateDesktopInstall:`安装并重启`,updateDesktopManual:`去下载页手动安装`,updateDesktopError:`桌面更新失败:{error}`,updateDesktopNoBridge:`当前桌面壳太旧,没有内置更新通道,请去下载页换包。`,updatesAllTitle:`全部组件更新`,updatesAllBadge:`{n} 个更新`,updatesAllUpToDate:`全部组件均为最新`,kindWebUi:`Web 界面`,kindPiCore:`核心`,kindPackage:`组件`,kindGitExtension:`Git 组件`,kindPlugin:`插件`,pluginCheckUpdates:`检查插件更新`,pluginCheckUpdatesHint:`检查已安装界面插件是否有新版本(对比远端版本与 commit)`,pluginUpdateAvailableBadge:`可更新`,pluginUpdateAvailableDetail:`可更新:{version}`,updatesAllRefresh:`重新检查全部`,updateCheckFailed:`检查失败`,updateBtn:`更新`,updateAllBtn:`全部更新`,updatePkgTabTitle:`更新 {name}`,updateAllTabTitle:`更新全部组件`,piCoreSplitRun:`服务运行 v{running}`,piSdkSplitNote:`本服务运行的是 pi v{running};机器上装有更新的全局 pi v{installed}。重启服务即可跟上(默认自动选用更新的那份);设了 PI_WEB_SDK=bundled 时会一直用自带副本,升级 pi-web-ui 也可让自带副本跟上。`,piSdkBundledNote:`当前使用随包自带的 pi 引擎 v{running}(随 pi-web-ui 更新)。安装全局引擎后重启服务即可自动切换(服务默认跟随版本更高的那份)。`,installGlobalEngineBtn:`安装全局引擎`,installGlobalEngineTabTitle:`安装全局 pi 引擎`,restartService:`重启服务`,restartingService:`重启中…`,restartServiceTip:`重启 pi-web-ui 服务({name}):本实例由系统服务托管(launchd/systemd/Windows watchdog),进程退出后会被自动拉起,本页会自动重连;更新完成后用它生效`,computer:`此电脑`,workspaceModeLocal:`本地目录`,workspaceModeRemote:`远程 (SSH)`,sshHost:`主机地址`,sshPort:`端口`,sshUser:`用户名`,sshAuthType:`认证方式`,sshPassword:`密码`,sshKeyPath:`私钥路径`,sshAgent:`SSH 代理 (Agent)`,sshSaveProfile:`记住此连接`,sshProfileName:`配置名称 (可选)`,sshConnectAndProbe:`连接并探测环境`,sshConnecting:`正在连接与探测环境…`,sshSavedProfiles:`已保存的远程连接`,sshInstallTool:`一键自动安装`,sshInstalling:`正在安装…`,sshSkipAndBrowse:`跳过并继续浏览`,sshOpenRemoteWorkspace:`打开此远程工作区`,sshDisconnect:`断开连接`,sshDeleteProfileConfirm:`确认删除此连接配置吗?`,rootDir:`根目录`,homeDir:`用户目录`,desktopDir:`桌面`,filesShowHidden:`显示以 . 开头的隐藏文件`,filesHideHidden:`隐藏以 . 开头的文件`,filesHelp:`浏览:点文件夹进入、点文件预览,「..」返回上级;「根目录」回当前项目根,「此电脑」浏览全盘换盘符,「🏠」直达用户目录,「🖥️」直达桌面。
|
|
4
4
|
文件操作:右键可新建文件/文件夹、重命名、复制/剪切/粘贴、创建副本、删除、上传文件;文件可下载,行尾按钮可复制名称/路径。
|
|
@@ -324,7 +324,7 @@ Avoid three test anti-patterns: tests coupled to the implementation, tautologica
|
|
|
324
324
|
|
|
325
325
|
{path}
|
|
326
326
|
|
|
327
|
-
It only opens after you confirm.`,settingsExtensions:`Extensions`,settingsUiPlugins:`UI plugins`,pluginListTab:`Plugin list`,noUiPlugins:`No UI plugins installed (<dataDir>/plugins/)`,pluginPhaseActive:`Active`,pluginPhaseDisabled:`Disabled`,pluginPhaseFailed:`Failed`,pluginPhaseIdle:`Frontend-only`,pluginRescan:`Rescan`,pluginRescanHint:`Re-scan the plugin directory (picks up new/fixed plugins; failure records are cleared and re-evaluated)`,dshPatches:`DSH user patches`,dshPatchesDesc:`Cordis patches loaded at runtime boot, in filename order (<dataDir>/dsh-patches/*.yml). New/edited files take effect after 'Rescan' restarts the runtime; broken files are skipped and logged to runtime stderr.`,dshPatchesRescan:`Rescan`,dshPatchesRescanHint:`Re-scan the patch directory and restart the DSH runtime so new patches take effect`,dshPatchesEmpty:`No patch files yet`,dshPatchesPath:`Patch directory: `,dshPreset:`Agent preset`,dshPresetNewChat:`New chat with this preset`,dshPresetLocked:`Locked`,dshPresetBlankOnly:`Locked after the first message; blank sessions can switch`,dshPresetBroken:` (unavailable)`,dshPresetUser:`custom`,dshPresetDefaultTag:`default`,dshPresetMinimalNote:`Minimal: persistent shell only; host plugin tools and questionnaire unavailable`,dshDefaultPreset:`Default preset`,dshDefaultPresetDesc:`Preset for new chats; blank sessions can switch anytime, locked after the first message`,dshPresetUserNote:`Custom presets come from the user preset directory (trusted like shell access); compositions using bare package names cannot mount here (known limitation)`,"preset.standard":`Full access`,"preset.minimal":`Minimal`,"preset.code":`Code development`,"preset.reader":`Read-only analysis`,"preset.ask":`Chat only`,"preset.standardDesc":`All available tools and extension capabilities (default)`,"preset.minimalDesc":`Keeps only bash and read; plugin tools, skill catalog and terminal guidance are hidden too`,"preset.codeDesc":`Focused on reading, writing and running code (bash, read, edit, write, edit_soft); plugin tools and skill catalog are hidden too`,"preset.readerDesc":`Keeps only read-only tools and forbids writes; plugin tools are hidden too (read/write unknown, handled conservatively)`,"preset.askDesc":`No-tools Q&A: the model never calls a tool; plugin tools and skill catalog are hidden too`,dshPerm:`Permissions`,dshPermReadOnly:`Read Only`,dshPermReadOnlyDesc:`Read files and run read-only commands; writes are always denied, no prompts`,dshPermWorkspaceWrite:`Workspace Write`,dshPermWorkspaceWriteDesc:`Read/write inside the workspace, no prompts; out-of-scope operations are denied directly`,dshPermFullAccess:`Full access`,dshPermFullAccessDesc:`Sandbox off, unrestricted machine access; only for tasks you trust`,dshPermFullAccessTag:`risky`,dshPermCustom:`Custom`,dshPermConfirmFull:`Click again to confirm full access`,dshPermDefault:`Default permission for new chats`,dshPermDefaultDesc:`Initial permission for new chats; the current chat can switch live anytime, no restart`,uiPluginNoSource:`Installed manually — no recorded source, online update unavailable`,uiPluginPerms:`Permissions`,pluginDiagTitle:`Diagnostics`,pluginDiagShow:`Diagnostics`,pluginDiagHide:`Hide`,pluginLogTitle:`Runtime logs`,pluginLogShow:`Logs`,pluginLogHide:`Hide`,pluginLogLevel:`Level`,pluginLogAll:`All`,pluginLogEmpty:`No logs yet`,pluginLogClear:`Clear`,pluginDomNeed:`⚠ Requests full DOM access`,pluginDomDesc:`This plugin can freely read and write the page DOM (bypassing UI layout restrictions). Grant only to plugins from sources you trust; once granted its UI code can touch the topbar, composer and any page element.`,pluginDomGrant:`Grant DOM access`,pluginDomRevoke:`Revoke DOM access`,pluginDomGranted:`Full DOM access granted`,pluginSettingsTitle:`Configuration`,pluginSettingsShow:`Configure`,pluginSettingsHide:`Hide`,pluginSettingsSave:`Save plugin settings`,pluginSettingsSaving:`Saving…`,pluginSettingsReset:`Reset defaults`,pluginSettingsInherit:`Follow global default`,pluginSecretSet:`Set (stored encrypted, leave blank to keep)`,pluginSecretUnset:`Not set (stored encrypted)`,settingsPresets:`Presets`,settingsSubagentTemplates:`Subagent templates`,settingsSubagentTemplatesDesc:`Presets for spawned subagents (role system prompt + skills/extensions whitelist + optional model and thinking level). AI may pick a template (subagent_spawn template param) or spawn without one; disabled templates stay in the panel but are invisible to AI tools.`,noSubagentTemplates:`No subagent templates yet. AI can pick a template when spawning a subagent (role prompt + skills/extensions whitelist + optional model and thinking level), or spawn without a template param for default config.`,subagentTemplateNew:`New template`,subagentTemplateEdit:`Edit`,subagentTemplateClosed:`Disabled`,tplDefaultBadge:`Built-in`,subagentDefaultModelLabel:`Default subagent model`,subagentFollowMain:`Follow the main conversation's current model`,subagentDefaultModelHint:`Fallback model for all subagents (a template's own model and the subagent_spawn model param take priority); does not change the main conversation's model.`,subagentNoModels:`No usable models yet (configure a provider API key first) — subagents will follow the main conversation's model.`,subagentTemplateOffHint:`Disabled templates stay in the panel and can be re-enabled, but AI tools can't see or pick them`,subagentTemplateEnable:`Enable`,subagentTemplateDisable:`Disable`,tplNamePlaceholder:`Template name (referenced by AI via subagent_spawn's template param)…`,tplDescriptionPlaceholder:`Description (AI uses it to judge when to pick this template)…`,tplDescriptionEnPlaceholder:`English description (shown to AI under English UI; falls back to the description above)…`,tplPromptModeLabel:`System prompt mode`,tplModelLabel:`Model (empty = follow main conversation)`,tplThinkingLabel:`Thinking level`,tplThinkingFollowMain:`Follow the main conversation's current thinking level`,tplThinkingHint:`Empty = follow the main conversation's current thinking level (same idea as the model fallback); unsupported levels are clamped to the nearest one the model supports.`,tplSystemPromptLabel:`System prompt`,tplSystemPromptPlaceholder:`Template role system prompt… (may be empty in append mode)`,tplSystemPromptEnPlaceholder:`English system prompt… (used under English UI; falls back to the prompt above)`,tplWhitelistHint:`Whitelist: checked = the subagent only gets these; none checked = follow the main session settings`,tplSkillsLabel:`Skills whitelist`,tplExtensionsLabel:`Extensions whitelist`,tplSave:`Save template`,tplCancel:`Cancel edit`,tplDelete:`Delete template`,settingsScheduler:`Scheduled tasks`,schedulerDesc:`Put the agent on a schedule (dependency audits, test runs, morning briefings…): headless pseudo-client runs, no browser needed; notifies when done, history included.`,schedulerEmpty:`No scheduled tasks yet. Click “New task” above to schedule the first one: a 9 AM daily check or an hourly test run.`,schedulerNew:`New task`,schedulerEdit:`Edit`,schedulerDelete:`Delete`,schedulerRunNow:`Run now`,schedulerRunning:`Running…`,schedulerEnable:`Enable`,schedulerDisable:`Disable`,schedulerEnabled:`Enabled`,schedulerDisabled:`Disabled`,schedulerNamePlaceholder:`E.g. Daily dependency & health check…`,schedulerDescPlaceholder:`Description (optional): what this task does…`,schedulerCwdLabel:`Target project`,schedulerCwdPlaceholder:`/absolute/path/to/project…`,schedulerUseCurrentCwd:`Use current project`,schedulerKindLabel:`Schedule`,schedulerKindCron:`Cron expression`,schedulerKindInterval:`Fixed interval`,schedulerCronPlaceholder:`E.g. 0 9 * * * (daily 9:00 AM)`,schedulerPresetDaily:`Daily 9:00 AM`,schedulerPresetHourly:`Hourly on the hour`,schedulerPresetHalfHour:`Every 30 minutes`,schedulerPresetWorkday:`Weekdays 9:00 AM`,schedulerPresetMonday:`Mondays 9:00 AM`,schedulerPresetCustom:`Custom…`,schedulerIntervalMinutes:`Interval (minutes, min 1)`,schedulerPromptPlaceholder:`The task for the agent, e.g. audit dependencies and report upgrades…`,schedulerModelLabel:`Model (empty = default)`,schedulerThinkingLabel:`Thinking level (empty = default)`,schedulerCatchUp:`Catch up one missed run after restart`,schedulerCatchUpHint:`When checked, a trigger missed during downtime runs once at next startup; otherwise it is skipped.`,schedulerNextFire:`Next`,schedulerLastRun:`Last`,schedulerNeverRun:`Never ran`,schedulerHistory:`History`,schedulerManualBadge:`manual`,schedulerRunOk:`ok`,schedulerRunFail:`failed`,schedulerConfirmDelete:`Delete scheduled task “{name}”? Its history goes with it.`,schedulerSave:`Save task`,schedulerCancelEdit:`Cancel edit`,tplInherit:`Follow main session`,settingsEnabled:`Enabled`,settingsDisabled:`Disabled`,presetNamePlaceholder:`Preset name…`,saveAsPreset:`Save as preset`,applyPreset:`Apply`,deletePreset:`Delete preset`,noSkills:`No skills`,noExtensions:`No extensions`,noPresets:`No presets yet (tune your current settings, then enter a name above to save them as a preset)`,presetShare:`Share presets`,presetShareShareBtn:`Share preset`,presetShareImportBtn:`Import preset`,presetShareBrowseBtn:`Browse shared`,presetShareTabExport:`Export / share`,presetShareTabImport:`Import`,presetShareTabBrowse:`Browse shared`,presetShareSource:`Source`,presetShareSourceCurrent:`Current settings`,presetShareDescription:`Description`,presetShareDescriptionPlaceholder:`What is this preset good for? (optional)`,presetShareTags:`Tags`,presetShareTagsPlaceholder:`Comma separated, e.g. coding, minimal (optional)`,presetShareAuthor:`Author (optional)`,presetExportJson:`Export JSON`,presetExportDownload:`Download file`,presetShareSubmit:`Share to the community repo`,presetShareHint:`Creates a GitHub issue: with the gh CLI or a GitHub token it is submitted for you (the repo bot validates and commits it, and it shows up under "Browse shared" within minutes). With neither, a prefilled new-issue page opens — just hit Submit (for very large presets the JSON is copied to the clipboard instead, so you can paste it).`,presetShareSubmitting:`Submitting…`,presetShareOpenWebTitle:`Submit Issue on GitHub`,presetShareOpenWebBtn:`Open submission page in new window`,presetShareOpenIssueBtn:`View created issue`,presetShareCopyJson:`Copy preset JSON`,presetSharePopupBlocked:`If your browser blocked the popup, click the button below to open:`,presetShareBrowserCopied:`Submission page generated — just hit Submit (for large presets the JSON is on your clipboard, paste it)`,presetImportText:`Paste preset JSON`,presetImportTextPlaceholder:`Paste the exported JSON here (or drop a .json file)…`,presetImportPickFile:`Choose file`,presetImportFromUrl:`Import from URL`,presetImportUrlPlaceholder:`https://raw.githubusercontent.com/…/preset.json`,presetImportPreview:`Preview`,presetImportFields:`{n} fields will be written`,presetImportIgnored:`Unknown fields ignored: {list}`,presetImportRejected:`Dropped (wrong type): {list}`,presetImportReplaces:`A local preset with this name already exists — importing overwrites it`,presetImportApply:`Apply right after importing`,presetImportConfirm:`Import`,presetImportPick:`Import selectively: pick what to write`,presetImportSelectAll:`All`,presetImportSelectNone:`None`,presetImportAllSelected:`All selected`,presetImportNoneSelected:`Select at least one field to import`,presetImportPickHint:`Unchecked fields keep your current values; you can still tweak everything afterwards in Settings.`,presetGroupPrompt:`Prompts`,presetGroupTools:`Tools & switches`,presetGroupTerminal:`Terminal takeover`,presetGroupSkills:`Skills & extensions`,presetGroupAi:`Model behavior & dedicated prompts`,presetGroupUi:`Interface & interaction`,presetGroupEngine:`Engine defaults`,presetGroupOther:`Other`,presetImportImported:`Imported: {name}`,presetBrowseEmpty:`No presets in the shared repo yet`,presetBrowseLoading:`Loading community presets…`,presetBrowseSearch:`Search name / tag / author`,presetBrowseRefresh:`Refresh list`,presetBrowseCached:`List cached at {time} — hit refresh to re-fetch`,presetBrowseImport:`Import`,presetBrowseIssue:`Source issue`,presetBadgeTemplate:`Has template`,presetBadgeReview:`Has review prompt`,loadingSession:`Loading session…`,connectingServer:`Connecting to pi-web-ui server…`,localePacks:`Language packs`,localeGetMore:`Get more languages`,localeInstalled:`Installed`,localeInstall:`Download`,localeRemove:`Remove`,localeDownloading:`Downloading…`,localeRemoving:`Removing…`,localeInstallFailed:`Download failed: {error}`,localeListFailed:`Couldn't load language packs: {error}`,localeRemoveHint:`You can re-download it anytime`,wallpaperTitle:`Chat wallpaper`,wallpaperDesc:`Show a full-window background image (side panels, top and bottom bars included): a theme-provided image applies automatically, a URL here takes precedence; use dim and blur to keep text readable.`,wallpaperUrlPh:`Image URL (https://…, empty = off)`,wallpaperDim:`Dim`,wallpaperBlur:`Blur`,wallpaperClear:`Clear`,wallpaperUpload:`Upload image`,wallpaperUploadFailed:`Couldn't read the image (or it's too big) — try another one`,skillFullTextLabel:`Inject full skill text`,skillFullTextDesc:`Expand skill file contents inline into the system prompt (8KB per file, 32KB total cap); otherwise only a catalog is listed and the model reads files on demand`,skillFullTextShort:`Full`,delegateOpenSubagent:`Open subagent`,delegateSecTask:`Task`,delegateSecExpected:`Expected outcome`,delegateSecTools:`Required tools`,delegateSecMustDo:`Must do`,delegateSecMustNotDo:`Must not do`,delegateSecContext:`Context`,copyConversationId:`Copy conversation ID`,copyConversationPath:`Copy session file path`,copyConversationLink:`Copy link to session`,copyMessageLink:`Copy link to message`,quoteConversation:`Quote into composer (readable by the AI)`,quoteConversationShort:`Quote`,attachConversation:`Conversation reference: {name} (the AI reads it via conversation_read on demand)`,attachConversationShort:`conversation`,quoteSelection:`Quote`,quoteText:`Text quote`,quoteSource:`Source message: {id}`,removeQuote:`Remove quote`,presentOpenLocal:`Open locally`,presentMissing:`File missing or unreadable (moved, deleted, or outside the workspace?)`,presentEmpty:`Nothing to show`,presentAutoOpen:`Auto-open previews the AI presents`,presentAutoOpenDesc:`When the AI presents files with present_files and marks one as 'look at this first', open the file preview dialog automatically. Off (default): the cards stay inline and you open them with one click.`,presentFilesEnabledDesc:`Let the AI push artifacts (screenshots, charts, videos, reports, logs) into the chat as preview cards: images/videos/audio are shown inline, text gets an excerpt plus a one-click preview dialog, and every row carries open-locally / reveal-in-file-manager / download / copy-path actions. The auto-open switch lives on the Chat page.`,presentFilesOffHint:`Disabled: the AI can only tell you the file path — no cards, no open-locally buttons`,skillEnabledDesc:`Load skill bodies by name (the skill catalog stays in the system prompt): the full text is fetched only when a skill is actually needed, instead of making the model guess a path and call read.`,skillOffHint:`Disabled: the AI can no longer load skill bodies by name (the catalog in the prompt is unaffected)`,claimFilesEnabledDesc:`Declare which files you are about to edit so parallel runs in the same project can steer clear (advisory only — it never blocks edits). First-wins; claims expire automatically.`,claimFilesOffHint:`Disabled: the AI can no longer claim files (post-hoc touch reminders still work, only the up-front intent signal is gone)`,planUpdateEnabledDesc:`Structured task plan updates (Plan Mode / Step State Machine): allows the model to break complex tasks into steps and track progress in real time.`,planUpdateOffHint:`Disabled: AI can no longer update the structured plan board`,compactContextEnabledDesc:`Proactively compact context based on the current issue: allows AI to independently specify compression focus, retain core task context, drop irrelevant history, and control retention scope.`,compactContextOffHint:`Disabled: AI cannot proactively invoke context compaction (you can still use /compact or trigger auto-compaction)`,mcpManageEnabledDesc:`MCP server inspection and installation (list / check / install / remove / reload): allows AI to check whether an MCP server is installed and conveniently install/configure npm or remote MCP servers with live hot-reload.`,mcpManageOffHint:`Disabled: AI cannot invoke mcp_manage to check or install MCP servers`,evalEnabledDesc:`Execute Python or JavaScript/TypeScript code in an isolated sandbox with persistent variables; ideal for calculations, data analysis, and algorithm verification (default-off to prevent tool crowding-out).`,evalOffHint:`Disabled: the AI cannot use the persistent code sandbox (can still run scripts via bash)`,patchToolEnabledDesc:`High-reliability structural patch tool (Hashline): line-anchored editing with 4-hex content hashes, syntactic AST block matching, and clipboard registers. Automatically attempts 3-way merge conflict recovery if files diverged.`,patchToolOffHint:`Disabled: AI falls back to basic string replacement via edit`,lspToolEnabledDesc:`Native Language Server Protocol (LSP) tool: IDE-grade semantic code intelligence (definition, references, hover, diagnostics, documentSymbol outline, read_symbol precise slicing, workspaceSymbol search, and cascade impact diagnostics). Multi-agent shared process pool with idle sleep, zero external dependencies.`,lspToolOffHint:`Disabled: AI cannot query LSP semantics and falls back to text search`,codemodeEnabledDesc:`Run JavaScript in a QuickJS WASM sandbox to batch tool calls and filter output: intermediate results never enter LLM context, keeping context concise (default off; requires capable model).`,codemodeOffHint:`Disabled: AI cannot run codemode scripts to batch call tools`,codemodeNestedCalls:`Nested tool calls`,codemodeScript:`JavaScript script`,codemodeFullOutput:`Full output file`,codemodeModeLabel:`Execution Mode`,codemodeModeHint:`In standard mode all tools are directly visible; in strict code mode tools are hidden from the model and must be invoked via sandbox scripts`,codemodeModeOn:`Standard Mode (on)`,codemodeModeOnly:`Strict Code Mode (only)`,codemodeInlineBudgetLabel:`Inline Budget`,codemodeInlineBudgetHint:`Estimated tokens the codemode prompt may spend on tool declarations directly (default: 3000)`,codemodeNestedApprovalBadge:`Nested Call`,codemodeNestedApprovalDesc:`This tool call was triggered by a background codemode sandbox script`,codemodeSavedImages:`Generated Images`,toolSearchEnabledDesc:`BM25-based tool discovery and activation: search and activate tools via natural language queries (ideal for large MCP toolsets to prevent context bloat).`,toolSearchOffHint:`Disabled: AI cannot use tool_search to discover tools`,toolSearchLoaded:`Activated tools`,toolInfoMenuLabel:`Show tool details`,toolInfoTitle:`Tool details`,toolInfoLoading:`Loading tool definition…`,toolInfoUnsupported:`This engine can't show tool definitions`,toolInfoMissing:`No definition found for this tool (it may come from an uninstalled plugin or an older version)`,toolInfoActive:`Enabled`,toolInfoInactive:`Disabled`,toolInfoSource:`Source`,toolInfoDescription:`Description`,toolInfoNoDescription:`This tool has no description`,toolInfoPromptSnippet:`Prompt snippet`,toolInfoGuidelines:`Prompt guidelines`,toolPromptEdit:`Edit description`,toolPromptEdited:`Description customized (click to edit)`,toolPromptHint:`Leave a field empty to use the tool's built-in text. The three fields map to the tool description the model sees, the one-line summary in the system prompt, and the behavioral guidelines.`,toolPromptDescription:`Tool description (how the model understands this tool)`,toolPromptSnippet:`Prompt snippet (the line in the system prompt's Available tools list)`,toolPromptGuidelines:`Behavioral guidelines (Guidelines section, one per line)`,toolPromptDefault:`Built-in text`,toolPromptReset:`Reset to default`,toolPromptSave:`Save`,toolPromptUnavailable:`No definition for this tool (engine unsupported, or the tool is uninstalled) — you can still fill in overrides, but they only apply once the tool exists.`,toolInfoParams:`Parameters`,toolInfoParamsNone:`This tool takes no parameters`,toolInfoSchemaDropped:`The parameter schema is too large and was omitted (see the raw JSON below)`,toolInfoRawSchema:`Raw JSON schema`,toolInfoRequired:`required`,toolInfoFootnote:`This is the tool's definition — not this call's arguments or result.`,elsewhereOfflineBadge:`Offline`,elsewhereOfflineTip:`The page holding this conversation is gone (tab or browser closed) but the run is still on the server — click this row twice to take it over here`,sandboxNewBtn:`Launch Sandbox Project (isolated workspace)`,sandboxModalTitle:`Launch Sandbox Project`,sandboxModalSubtitle:`Experiment freely inside a hard-jailed copy — no changes ever touch your original files.`,sandboxModeLabel:`Initial Content`,sandboxModeBlank:`Blank Sandbox`,sandboxModeBlankDesc:`Clean empty directory for quick prototypes, scripts, or file processing`,sandboxModeImport:`Import Existing Project`,sandboxModeImportDesc:`Clone source project files (auto-skips node_modules/caches); original stays untouched`,sandboxSourceLabel:`Source Project Path`,sandboxSourcePlaceholder:`Enter or select a local project path to import`,sandboxLifecycleLabel:`Lifecycle`,sandboxLifecycleEphemeral:`Temporary (Use & Discard)`,sandboxLifecycleEphemeralDesc:`Ideal for one-off experiments; destroy anytime or convert to permanent`,sandboxLifecyclePermanent:`Permanent Sandbox`,sandboxLifecyclePermanentDesc:`Kept in your projects list for ongoing experimentation`,sandboxNameLabel:`Sandbox Name (optional)`,sandboxNamePlaceholder:`Leave blank to auto-generate`,sandboxCreateSubmit:`Launch Sandbox`,sandboxBadgeEphemeral:`Temp Sandbox`,sandboxBadgePermanent:`Sandbox`,sandboxBannerTitle:`Sandbox Isolation: {name}`,sandboxBannerSourceDesc:`Source: {source} (read-only protected; all edits stay inside this sandbox)`,sandboxBannerBlankDesc:`Isolated workspace (hard jail active; writing outside sandbox is blocked)`,sandboxActionPersist:`Keep Permanently`,sandboxActionPersistTip:`Convert this temporary sandbox into a permanent sandbox project`,sandboxActionApplySource:`Sync to Source`,sandboxActionApplySourceTip:`Sync modified files from this sandbox back to the source project (preserves .git)`,sandboxActionApplyConfirm:`Sync modified files from sandbox "{name}" back to source project ({source})?`,sandboxActionReset:`Reset`,sandboxActionResetTip:`Wipe sandbox and restore initial state (re-clones clean copy from source if imported)`,sandboxActionResetConfirm:`Reset sandbox "{name}"? Unexported changes in the sandbox will be wiped and restored to initial state.`,sandboxActionPromote:`Save as Project`,sandboxActionPromoteTip:`Export this sandbox to a formal project directory outside sandboxes`,sandboxActionDestroy:`Destroy`,sandboxActionDestroyTip:`Permanently delete this sandbox directory and switch back`,sandboxActionDestroyConfirm:`Permanently destroy sandbox "{name}" and delete all its files? This cannot be undone.`,sandboxPromoteTitle:`Save Sandbox as Formal Project`,sandboxPromoteSubtitle:`Export files from sandbox "{name}" to a new directory outside the sandbox jail.`,sandboxPromoteTargetLabel:`Target Directory Path (must be a new or empty directory)`,sandboxPromoteTargetPlaceholder:`e.g. ~/projects/my-new-app`,sandboxPromoteSwitchLabel:`Switch to the exported project immediately`,sandboxPromoteSubmit:`Export Project`,sandboxApplyTitle:`Sync Sandbox Changes to Source Project`,sandboxDiffStats:`+{added} added · ~{modified} modified · -{deleted} deleted in sandbox · {unchanged} unchanged`,sandboxDiffEmpty:`This sandbox is identical to the source project — no modified or added files to sync.`,sandboxDiffDeletedNote:`Note: Syncing only writes added and modified files (preserves source .git and never deletes existing source files).`,sandboxApplySubmit:`Confirm Sync ({count} files)`,sandboxEnabledDesc:`Allow AI to create blank or imported copy-on-write sandbox projects (skipping node_modules/caches), inspect diffs, reset, or destroy; syncing changes back to the source project requires user approval.`,sandboxOffHint:`Disabled: AI cannot invoke the sandbox tool to create or manage isolated sandboxes`},Sn=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],Cn={};function wn(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(Cn[e.code]=e,!0)}function Tn(e){delete Cn[e]}function En(e){return e===`zh`?`中文`:e.toUpperCase()}function Dn(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function On(e){let t=await fetch(gn(fn(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var kn=(0,g.createContext)(null);function An(){try{return localStorage.getItem(yn)}catch{return null}}function jn(){return vn(An(),typeof navigator<`u`?navigator.languages:[],null)}function Mn({children:e}){let[t,n]=(0,g.useState)(jn),[r,i]=(0,g.useState)(0),a=(0,g.useRef)(t);a.current=t;let o=(0,g.useCallback)(e=>{n(e);try{localStorage.setItem(yn,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,g.useCallback)(async()=>{let e,t=null;try{let n=await On(`/api/locales`);e=n.packs??[],t=n.defaultLocale??null}catch{return null}return await Promise.all(e.filter(e=>e.installed).map(async e=>{try{let t=await On(`/api/locales/${e.code}`);return wn({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,g.useEffect)(()=>{s().then(e=>{if(!An()?.trim()){let t=vn(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!Cn[t]){let t=vn(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(yn,t)}catch{}}})},[s]);let c=(0,g.useMemo)(()=>[...Sn,...Object.values(Cn).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,g.useCallback)((e,n)=>{let r=Cn[t]?.strings[e];r&&t!==`zh`&&t!==`ja`&&/[\u4e00-\u9fff]/.test(r)&&(r=void 0);let i=r??(t===`zh`?bn[e]:xn[e]);if(n)for(let[e,t]of Object.entries(n))i=i.replaceAll(`{${e}}`,String(t));return i},[t,r]);(0,g.useEffect)(()=>{document.documentElement.lang=Dn(t)},[t]);let u=(0,g.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(kn.Provider,{value:u,children:e})}function Nn(){let e=(0,g.useContext)(kn);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return Nn().t}var Pn=[{kind:`question`,labelKey:`sound.question`,descKey:`sound.question.desc`},{kind:`done`,labelKey:`sound.done`,descKey:`sound.done.desc`},{kind:`start`,labelKey:`sound.start`,descKey:`sound.start.desc`},{kind:`error`,labelKey:`sound.error`,descKey:`sound.error.desc`},{kind:`approval`,labelKey:`sound.approval`,descKey:`sound.approval.desc`}];function Fn({settings:e,onChange:t,onPreview:n}){let r=Z(),i=n=>t({...e,...n});return(0,X.jsxs)(`div`,{className:`sound-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:r(`soundHeader`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(ne,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:r(`enableSound`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:e=>i({enabled:e.target.checked})})]}),Pn.map(({kind:t,labelKey:a,descKey:o})=>(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(a)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(o)})]}),(0,X.jsxs)(`span`,{className:`sound-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`sound-preview`,title:r(`preview`),disabled:!e.enabled,onClick:e=>{e.preventDefault(),n(t)},children:r(`preview`)}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e[t],disabled:!e.enabled,onChange:e=>i({[t]:e.target.checked})})]})]},t)),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`volume`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:e.volume,disabled:!e.enabled,onChange:e=>i({volume:Number(e.target.value)})}),(0,X.jsxs)(`span`,{className:`sound-vol-num`,children:[e.volume,`%`]})]})]})}function In(){let[e,t]=(0,g.useState)([]);return(0,g.useEffect)(()=>{if(!qt())return;let e=window.speechSynthesis,n=()=>t(e.getVoices().map(e=>({voiceURI:e.voiceURI,lang:e.lang,name:e.name,localService:e.localService})));return n(),e.addEventListener?.(`voiceschanged`,n),()=>e.removeEventListener?.(`voiceschanged`,n)},[]),e}function Ln({settings:e,onChange:t,onPreview:n}){let r=Z(),i=In(),a=qt(),o=n=>t({...e,...n});return(0,X.jsxs)(`div`,{className:`sound-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:r(`ttsHeader`)}),!a&&(0,X.jsx)(`div`,{className:`sound-desc tts-unavailable`,children:r(`ttsUnavailable`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master ${a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(ne,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:r(`ttsEnable`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsEnableDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:!a,onChange:e=>o({enabled:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsAnnounce`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsAnnounceDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.announce,disabled:!e.enabled||!a,onChange:e=>o({announce:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsReadReplies`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsReadRepliesDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.readReplies,disabled:!e.enabled||!a,onChange:e=>o({readReplies:e.target.checked})})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsRate`)}),(0,X.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:e.rate,disabled:!e.enabled||!a,onChange:e=>o({rate:Number(e.target.value)})}),(0,X.jsxs)(`span`,{className:`sound-vol-num`,children:[e.rate.toFixed(1),`×`]})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsVoice`)}),(0,X.jsxs)(`select`,{className:`set-input tts-voice-select`,value:e.voiceURI,disabled:!e.enabled||!a,onChange:e=>o({voiceURI:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`ttsVoiceAuto`)}),i.map(e=>(0,X.jsxs)(`option`,{value:e.voiceURI,children:[e.name,` (`,e.lang,`)`,e.localService?``:` · ${r(`ttsVoiceOnline`)}`]},e.voiceURI))]})]}),(0,X.jsx)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:(0,X.jsx)(`button`,{type:`button`,className:`sound-preview tts-preview`,disabled:!e.enabled||!a,onClick:()=>{if(e.voiceURI&&!Jt(e.voiceURI,i,navigator.language)){t({...Wt,...e,voiceURI:``});return}n()},children:r(`preview`)})})]})}function Rn(e){let t=e??(typeof window>`u`?void 0:window);if(!t)return!1;if(t.piDesktop?.isDesktop===!0)return!0;let n=t.navigator?.userAgent;return typeof n==`string`&&n.includes(`Electron/`)}var zn=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),Bn=null,Vn=0;function Hn(){return Bn?.available===!0?Bn.pages??[]:[]}function Un(){Date.now()-Vn<5e3||Wn().catch(()=>{})}async function Wn(){if(Rn())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=zn();if(!e)return{available:!1,pages:[],error:`宿主页面桥不可用:这个 pi-web-ui 页面还没装上扩展桥(装/启用 page-picker 后刷新本页)`};try{let t=await e({op:`status`,timeoutMs:5e3});if(!t.ok)return{available:!1,pages:[],error:t.error??`扩展没有返回状态`};let n=t.result??{},r={available:n.installed===!0,aiControl:n.aiControl===!0,allowEval:n.allowEval===!0,pages:Array.isArray(n.pages)?n.pages:[]};return r.available&&(Bn=r,Vn=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function Gn(e){return e.length===1?e[0]:null}function Kn(e){return{path:e.origin,name:e.title?.trim()||e.origin,mode:`page`,key:`page:${e.origin}`}}async function qn(){let e=zn();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function Jn(e=45e3){let[t,n]=(0,g.useState)(null),r=(0,g.useRef)(!0),i=(0,g.useCallback)(async e=>{let t=await Wn();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,g.useEffect)(()=>{r.current=!0,i(!0);let t=setInterval(()=>void i(!1),Math.max(5e3,e));return()=>{r.current=!1,clearInterval(t)}},[i,e]),{status:t,refresh:()=>void i(!0)}}var Yn=null,Xn=null,Zn=null,Qn=null,$n=null;function er(e){Qn=e}function tr(e){$n=e}function nr(e){return Qn?(Qn(e),!0):!1}function rr(e){return $n?($n(e),!0):!1}function ir(e){Yn=e}function ar(e){Xn=e}function or(e){Zn=e}function sr(){return Zn?(Zn(),!0):!1}function cr(){return!!(Yn||Xn)}function lr(e){let t=typeof e?.text==`string`?e.text:``,n=Array.isArray(e?.attachments)?e.attachments:[],r=t.trim()!==``,i=n.length>0;return!r&&!i||r&&!Yn||i&&!Xn?!1:(i&&Xn?.(n),r&&Yn?.(t),!0)}function ur(){let e=Z(),{status:t,refresh:n}=Jn(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),s=(0,g.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=Gn(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},f=t=>{let n=lr({attachments:[Kn(t)]});d(e(n?`browserControlCited`:`browserControlCiteFailed`))},p=()=>{i(!0),n()};return(0,X.jsxs)(`span`,{className:`bc-anchor`,children:[u?(0,X.jsxs)(`span`,{className:`browser-control-split`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control single${l?` attention`:``}`,"data-tip":e(`browserControlSingleTip`,{name:u.title||u.origin}),title:e(`browserControlSingleTip`,{name:u.title||u.origin}),onClick:()=>f(u),children:[(0,X.jsx)(ve,{size:14,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`bc-chip-label`,children:u.title||u.origin})]}),(0,X.jsx)(`button`,{type:`button`,className:`chip browser-control caret`,"data-tip":e(`browserControlOpenPanel`),title:e(`browserControlOpenPanel`),"aria-label":e(`browserControlOpenPanel`),onClick:p,children:`▾`})]}):(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control${l?` attention`:``}`,"data-tip":t?.error??e(l?`browserControlEmpty`:`browserControlTip`),title:t?.error??e(l?`browserControlEmpty`:`browserControlTip`),onClick:p,children:[(0,X.jsx)(ve,{size:14,"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[e(`browserControl`),c.length>0?` · ${c.length}`:``]})]}),a&&(0,X.jsx)(`span`,{className:`bc-flash`,children:a}),r&&(0,X.jsx)(dr,{status:t,onRefresh:n,onCite:f,onClose:()=>i(!1)})]})}function dr({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,g.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await qn()||t()}finally{o(!1)}};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:r,children:(0,X.jsxs)(`div`,{className:`modal browser-control-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":i(`close`),onClick:r,children:`✕`}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(ve,{size:16,"aria-hidden":!0}),(0,X.jsx)(`h2`,{children:i(`browserControl`)})]}),(0,X.jsx)(`div`,{className:`modal-desc`,children:i(`browserControlTip`)}),e===null&&(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlChecking`)}),e?.available===!1&&!e.desktop&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlOffline`)}),e?.desktop===!0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlDesktop`)}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlDesktopLead`)}),(0,X.jsx)(`div`,{className:`bc-actions`,style:{marginTop:0},children:(0,X.jsx)(`a`,{className:`btn primary`,href:window.location.href,target:`_blank`,rel:`noreferrer noopener`,children:i(`browserControlOpenInBrowser`)})})]}),e?.available===!1&&!e.desktop&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlInstall`)}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlInstallLead`)}),(0,X.jsx)(`div`,{className:`bc-actions`,style:{marginTop:0},children:(0,X.jsx)(`a`,{className:`btn primary`,href:`https://github.com/xing-shuyin/pi-web-ui/releases/latest/download/page-picker-extension.zip`,target:`_blank`,rel:`noreferrer noopener`,children:i(`browserControlInstallDownload`)})}),(0,X.jsxs)(`ol`,{className:`bc-steps`,children:[(0,X.jsx)(`li`,{children:i(`browserControlInstallStep1`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep2`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep3`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep4`)})]})]}),e?.available===!0&&e.aiControl===!1&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlDisabled`)}),e?.available===!0&&s.length===0&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlEmpty`)}),s.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlPages`)}),(0,X.jsx)(`ul`,{className:`bc-pages`,children:s.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`bc-title`,title:e.title,children:e.title}),(0,X.jsx)(`span`,{className:`bc-origin`,title:e.origin,children:e.origin}),(0,X.jsx)(`span`,{className:`bc-open${e.open?` on`:``}`,children:e.open?i(`browserControlPageOpen`):i(`browserControlPageClosed`)}),(0,X.jsx)(`button`,{type:`button`,className:`bc-cite`,title:i(`browserControlCiteTip`,{name:e.title||e.origin}),onClick:()=>n(e),children:i(`browserControlCite`)})]},e.origin))}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlCiteNote`)})]}),e?.desktop!==!0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlExamples`)}),(0,X.jsxs)(`ul`,{className:`bc-examples`,children:[(0,X.jsx)(`li`,{children:i(`browserControlExample1`)}),(0,X.jsx)(`li`,{children:i(`browserControlExample2`)})]})]}),(0,X.jsxs)(`div`,{className:`bc-actions`,children:[e?.desktop!==!0&&(0,X.jsx)(`button`,{type:`button`,className:`primary`,disabled:a,onClick:()=>void c(),children:i(`browserControlOpenOptions`)}),(0,X.jsx)(`button`,{type:`button`,onClick:t,children:i(`browserControlRefresh`)})]})]})})}var fr=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],pr=[`subagent`],mr=`edit_soft`,hr=`delegate_task`,gr=`ask_user_question`,_r=`todo_list`,vr=`browser_page`,yr=`conversation_read`,br=`skill`,xr=`schedule`,Sr=`eval`,Cr=`present_files`,wr=`claim_files`,Tr=`plan_update`,Er=`compact_context`,Dr=`patch`,Or=`mcp_manage`,kr=`sandbox`,Ar=`codemode`,jr=`tool_search`,Mr=[...fr.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...pr.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:mr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:hr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:gr,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:vr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:yr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:wr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:Tr,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`planUpdateEnabledDesc`,offHintKey:`planUpdateOffHint`},{name:Dr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`patchToolEnabledDesc`,offHintKey:`patchToolOffHint`},{name:`lsp`,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`lspToolEnabledDesc`,offHintKey:`lspToolOffHint`},{name:Cr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:br,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:Sr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`evalEnabledDesc`,offHintKey:`evalOffHint`},{name:Ar,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`codemodeEnabledDesc`,offHintKey:`codemodeOffHint`},{name:jr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`toolSearchEnabledDesc`,offHintKey:`toolSearchOffHint`},{name:xr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:Er,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`compactContextEnabledDesc`,offHintKey:`compactContextOffHint`},{name:Or,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`mcpManageEnabledDesc`,offHintKey:`mcpManageOffHint`},{name:kr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`sandboxEnabledDesc`,offHintKey:`sandboxOffHint`},{name:_r,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}],Nr=[`bash`,`read`,`edit`,`write`,`powershell`,`ls`,`grep`,`find`];new Set(Mr.map(e=>e.name));var Pr=[...Mr.map(e=>e.name),...Nr];function Fr(e){let t=new Set(e);return Pr.filter(e=>!t.has(e))}function Ir(e,t){let n=Array.from(e);if(!t||t===`standard`)return n;if(t===`ask`)return[];if(t===`minimal`)return n.filter(e=>e===`bash`||e===`read`);if(t===`code`){let e=new Set([`bash`,`read`,`edit`,`write`,`edit_soft`]);return n.filter(t=>e.has(t))}if(t===`reader`){let e=new Set([`write`,`edit`,`edit_soft`,`bash`,`powershell`,`terminal_create`,`terminal_input`,`terminal_close`,`terminal_key`,`codemode`]);return n.filter(t=>!e.has(t))}return n}function Lr(e){return Ir([br],e).includes(br)}var Rr=`pi-web-notify`,zr={enabled:!1};function Br(){try{let e=localStorage.getItem(Rr);if(!e)return{...zr};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:zr.enabled}}catch{return{...zr}}}function Vr(e){try{localStorage.setItem(Rr,JSON.stringify(e))}catch{}}function Hr(){return typeof window<`u`&&`Notification`in window}function Ur(){return Hr()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function Wr(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&Gr(t)||Number.isFinite(n)&&Gr(n)?!0:r>0&&r<=400&&i>0&&i<=40}function Gr(e){return e<=-1e4}function Kr(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var qr=Date.now(),Jr=!1;function Yr(){qr=Date.now()}function Xr(){return Math.max(0,Date.now()-qr)}function Zr(){if(Jr||typeof window>`u`)return;Jr=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,Yr,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,Yr,e)}function Qr(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function $r(){return Zr(),typeof window>`u`||typeof document>`u`?{hasFocus:!0,visibility:`visible`,minimized:!1,idleMs:0,windows:!1}:{hasFocus:typeof document.hasFocus!=`function`||document.hasFocus(),visibility:document.visibilityState??``,minimized:Wr({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Xr(),windows:Qr()}}function ei(){return Hr()?Notification.permission:`denied`}async function ti(){if(!Hr())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function ni(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function ri(e,t=!1){return{body:e,requireInteraction:t,icon:fn(`/icons/icon-192.png`),badge:fn(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:fn(`/`)}}}async function ii(e,t,n=!1){if(!Hr())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=ri(t,n),i;try{let t=await navigator.serviceWorker?.getRegistration();if(t?.active&&typeof t.showNotification==`function`)return await t.showNotification(e,r),{path:`sw`};i=t?`service worker not active`:`no service worker registration`}catch(e){i=ni(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${ni(e)}`}}}async function ai(e,t){Hr()&&(Kr($r())||Br().enabled&&await ii(e,t))}var oi=!1;function si(){let e=Z(),[t,n]=(0,g.useState)(Br),[r,i]=(0,g.useState)(()=>ei()),[a,o]=(0,g.useState)(null),s=Ur(),c=s!==null,l=Qr();(0,g.useEffect)(()=>{let e=()=>i(ei());return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]);let u=async e=>{let r={...t,enabled:e};if(n(r),Vr(r),e){let e=await ti();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),Vr(e)}}};return(0,X.jsxs)(`div`,{className:`sound-menu notify-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:e(`notifyHeader`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master${c?` disabled`:``}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(_t,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:e(`notifyEnable`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:t.enabled&&!c,disabled:c,onChange:e=>u(e.target.checked)})]}),(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyEnableDesc`)}),s===`insecure`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyInsecure`)}),s===`unsupported`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyUnsupported`)}),!c&&r===`denied`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyDenied`)}),!c&&l&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyWindowsHint`)}),oi]})}var ci=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),Q=new Set(`viewBox.xmlns.d.fill.stroke.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.opacity.x.y.x1.y1.x2.y2.cx.cy.r.rx.ry.width.height.points.offset.stop-color.stop-opacity.fill-opacity.stroke-opacity.stroke-miterlimit.fill-rule.clip-rule.vector-effect.preserveAspectRatio.transform.clip-path.id.href.xlink:href.xmlns:xlink.gradientUnits.gradientTransform`.split(`.`)),li=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),ui=new Set([...ci].map(e=>e.toLowerCase())),di=new Set([...Q].map(e=>e.toLowerCase()));function fi(e){return ui.has(e.toLowerCase())}function pi(e){return di.has(e.toLowerCase())}function mi(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t||t.length>8192||!/^<svg[\s>]/.test(t.startsWith(`<?xml`)?t.slice(t.indexOf(`?>`)+2).trimStart():t))return null;if(typeof DOMParser>`u`)return/<script[\s>]/i.test(t)||/\son\w+\s*=/i.test(t)||/javascript\s*:/i.test(t)?null:t;let n=new DOMParser().parseFromString(t,`image/svg+xml`);if(n.querySelector(`parsererror`))return null;let r=n.documentElement;if(r.tagName.toLowerCase()!==`svg`)return null;let i=e=>{for(let t of Array.from(e.children)){let e=t.tagName.toLowerCase();if(!fi(e)){li.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of Array.from(t.attributes)){let n=e.name.toLowerCase();(!pi(n)||/^on/i.test(n)||/^(javascript|data|vbscript):/i.test(e.value.trim()))&&t.removeAttribute(e.name)}i(t)}};for(let e of Array.from(r.attributes)){let t=e.name.toLowerCase();(!pi(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function hi({icon:e,iconSvg:t,className:n}){let r=mi(t);return r?(0,X.jsx)(`span`,{className:n??`plugin-icon-svg`,"aria-hidden":!0,dangerouslySetInnerHTML:{__html:r}}):e?(0,X.jsx)(`span`,{className:n?`${n} plugin-icon-glyph`:`plugin-icon-glyph`,"aria-hidden":!0,children:e}):null}var gi=`pi-web-ui:cost-currency`,_i=null,vi=0,yi=new Set;function bi(){vi+=1;for(let e of[...yi])try{e()}catch{}}function xi(e){return yi.add(e),()=>{yi.delete(e)}}function Si(){return vi}function Ci(e){return!Number.isFinite(e)||e<=0?`0`:e<1e-4?`<0.0001`:e.toFixed(4).replace(/\.?0+$/,``)}function wi(){try{if(typeof localStorage<`u`){let e=localStorage.getItem(gi);if(typeof e==`string`&&e.trim().length>0)return e.trim().slice(0,8)}}catch{}return`$`}function Ti(e){try{if(typeof localStorage<`u`){let t=typeof e==`string`?e.trim().slice(0,8):``;!t||t===`$`?localStorage.removeItem(gi):localStorage.setItem(gi,t)}}catch{}bi()}function Ei(e){return typeof e==`function`?(_i=e,bi(),()=>{_i===e&&(_i=null,bi())}):(_i=null,bi(),()=>{})}function Di(e,t){let n=String(e??``).trim();if(!n)return{symbol:t,value:`0`};let r=n.match(/^([^\d<>+-]+)\s*(.+)$/);return r?{symbol:r[1],value:r[2]}:{symbol:``,value:n}}function Oi(e,t){let n=typeof e==`number`&&Number.isFinite(e)?e:0,r=wi(),i=typeof t?.fixedDigits==`number`?n.toFixed(t.fixedDigits):Ci(n);if(_i)try{let e=_i(n,{defaultSymbol:r,defaultValue:i});if(typeof e==`string`)return Di(e,r);if(e&&typeof e==`object`&&typeof e.value==`string`)return{symbol:typeof e.symbol==`string`?e.symbol:r,value:e.value,tooltip:typeof e.tooltip==`string`?e.tooltip:void 0}}catch(e){console.error(`[cost-format] custom cost formatter threw:`,e)}return{symbol:r,value:i}}function ki(e,t){return(0,g.useSyncExternalStore)(xi,Si,Si),Oi(e,t)}var Ai={projects:`host:lp-projects`,convs:`host:lp-running`,sessions:`host:lp-history`},ji=[`projects`,`convs`,`sessions`],Mi=new Map(Object.keys(Ai).map(e=>[Ai[e],e])),Ni=`plugin:`;function Pi(e){return e.startsWith(Ni)&&e.length>7}function Fi(e){let t=[],n=new Set;for(let r of e??[]){let e=null,i,a=Mi.get(r.id);a?e=a:r.source?.startsWith(`plugin:`)&&r.kind===`view`&&(e=`${Ni}${r.id}`,i=r),e&&!n.has(e)&&(n.add(e),t.push({key:e,shown:!r.hidden,...i?{entry:i}:{}}))}for(let e of ji)n.has(e)||t.push({key:e,shown:!0});return t}function Ii(e,t){return e.filter(e=>e.shown&&t(e.key)).map(e=>e.key)}function Li(e,t){let n=[];for(let r=0;r+1<e.length;r++){let i=e[r],a=e[r+1];!t(i)&&!t(a)&&n.push([i,a])}return n}function Ri(e,t){let n={...t};if(!e)return n;try{let r=JSON.parse(e);if(!r||typeof r!=`object`||Array.isArray(r))return n;for(let[e,i]of Object.entries(r))(e in t||Pi(e))&&typeof i==`number`&&Number.isFinite(i)&&i>0&&(n[e]=i)}catch{}return n}var zi=new Set([`view`,`action`,`badge`,`menu`,`page`,`organizer`,`divider`,`toggle`,`input`,`progress`,`select`]),Bi=new Set([`disabled`,`always`,`never`,`file.isDir`,`file.isFile`,`session.isRunning`,`message.hasSelection`]),Vi=`topbar.primary,topbar.overflow,notice.actions,leftpanel.sections,leftpanel.projects.actions,leftpanel.project,leftpanel.running.actions,leftpanel.running,leftpanel.history.actions,leftpanel.history,leftpanel.sessions,chat.header,chat.empty,message.actions,goalbar.actions,composer.leading,composer.actions,rightpanel.tabs,terminal.toolbar,scm.toolbar,bottombar,file.preview.toolbar,contextmenu.topbar,contextmenu.message,contextmenu.session,contextmenu.project,contextmenu.file,contextmenu.toolcall,settings.pages,tasks.panel,modal.dialog,sidebar.left,sidebar.right`.split(`,`),Hi=Vi.map(e=>({slot:e,cardinality:`list`}));function Ui(e){return Hi.find(t=>t.slot===e)?.cardinality??`list`}function Wi(e,t){if(t===`list`)return{entries:[...e],conflicts:[]};let n=e.findIndex(e=>!e.hidden);if(n<0)return{entries:[...e],conflicts:[]};let r=e.filter((e,t)=>t!==n&&!e.hidden);return{entries:e.map((e,t)=>t===n||e.hidden?e:{...e,hidden:!0}),winner:e[n],conflicts:r}}var Gi=[{id:`host:lp-projects`,slot:`leftpanel.sections`,labelKey:`recentProjects`,icon:`folder`,kind:`action`,order:10},{id:`host:lp-running`,slot:`leftpanel.sections`,labelKey:`runningConversations`,icon:`activity`,kind:`action`,order:20},{id:`host:lp-history`,slot:`leftpanel.sections`,labelKey:`historySessions`,icon:`clock`,kind:`action`,order:30},{id:`host:brand`,slot:`topbar.primary`,labelKey:`brand`,kind:`badge`,order:1,group:`brand`},{id:`host:open-project`,slot:`topbar.primary`,labelKey:`openProject`,icon:`folder`,kind:`action`,order:3,group:`primary`},{id:`host:history`,slot:`topbar.primary`,labelKey:`openHistory`,icon:`menu`,kind:`action`,order:0,group:`panels`},{id:`host:files`,slot:`topbar.primary`,labelKey:`openFiles`,icon:`folder`,kind:`action`,order:97,group:`panels`,align:`end`},{id:`host:new-chat`,slot:`topbar.primary`,labelKey:`newChat`,icon:`plus`,kind:`action`,order:96,group:`primary`,align:`end`},{id:`host:new-ephemeral-chat`,slot:`topbar.primary`,labelKey:`newChatEphemeral`,icon:`chat`,kind:`action`,order:96.5,group:`primary`,align:`end`},{id:`host:chat`,slot:`topbar.primary`,labelKey:`chat`,icon:`chat`,kind:`view`,view:`chat`,order:20,group:`views`,align:`end`},{id:`host:terminal`,slot:`topbar.primary`,labelKey:`terminal`,icon:`terminal`,kind:`view`,view:`terminal`,order:21,group:`views`,align:`end`},{id:`host:git`,slot:`topbar.primary`,labelKey:`scmTab`,icon:`git`,kind:`view`,view:`git`,order:22,group:`views`,align:`end`},{id:`host:plugins`,slot:`topbar.primary`,labelKey:`pluginMenuTitle`,icon:`🧩`,kind:`action`,order:24,group:`views`,align:`end`},{id:`host:search`,slot:`topbar.primary`,labelKey:`searchGlobal`,icon:`search`,kind:`action`,order:40,group:`tools`,align:`end`},{id:`host:browser`,slot:`topbar.primary`,labelKey:`browserControl`,icon:`browser`,kind:`action`,order:41,group:`tools`,align:`end`,hidden:!0},{id:`host:tasks`,slot:`topbar.primary`,labelKey:`bgTasks`,icon:`layers`,kind:`action`,order:42,group:`tools`,align:`end`},{id:`host:settings`,slot:`topbar.primary`,labelKey:`settingsTitle`,icon:`settings`,kind:`action`,order:60,group:`system`,align:`end`},{id:`host:sound`,slot:`topbar.primary`,labelKey:`sound`,icon:`sound`,kind:`action`,order:70,group:`system`,hidden:!0,align:`end`},{id:`host:language`,slot:`topbar.primary`,labelKey:`language`,icon:`globe`,kind:`action`,order:80,group:`system`,hidden:!0,align:`end`},{id:`host:theme`,slot:`topbar.primary`,labelKey:`theme`,icon:`sun`,kind:`action`,order:82,group:`system`,hidden:!0,align:`end`},{id:`host:update`,slot:`topbar.primary`,labelKey:`update`,icon:`download`,kind:`action`,order:90,group:`system`,align:`end`,hidden:!0},{id:`host:github`,slot:`topbar.primary`,labelKey:`githubRepo`,icon:`github`,kind:`action`,order:200,group:`system`,align:`end`,hidden:!0},{id:`host:conn`,slot:`bottombar`,labelKey:`connected`,icon:`dot`,kind:`badge`,order:5,group:`status`},{id:`host:engine`,slot:`bottombar`,labelKey:`engineBadge`,icon:`cpu`,kind:`badge`,order:6,group:`status`},{id:`host:ctx`,slot:`bottombar`,labelKey:`context`,icon:`gauge`,kind:`badge`,order:10,group:`usage`},{id:`host:cost`,slot:`bottombar`,labelKey:`cumulativeCost`,icon:`coins`,kind:`badge`,order:11,group:`usage`},{id:`host:cache`,slot:`bottombar`,labelKey:`cacheHit`,icon:`database`,kind:`badge`,order:12,group:`usage`},{id:`host:msg-count`,slot:`bottombar`,labelKey:`messages`,icon:`message`,kind:`badge`,order:13,group:`usage`},{id:`host:plugin-status`,slot:`bottombar`,labelKey:`pluginStatus`,icon:`activity`,kind:`badge`,order:14,group:`status`},{id:`host:working`,slot:`bottombar`,labelKey:`working`,icon:`activity`,kind:`badge`,order:15,group:`status`},{id:`host:status-delegate`,slot:`bottombar`,labelKey:`delegateModeBadge`,icon:`eye`,kind:`badge`,order:16,group:`status`},{id:`host:host-metrics`,slot:`bottombar`,labelKey:`hostResources`,icon:`cpu`,kind:`badge`,order:19,group:`host`,align:`end`},{id:`host:cwd`,slot:`bottombar`,labelKey:`cwdTip`,icon:`folder`,kind:`action`,order:20,group:`context`,align:`end`},{id:`host:msg-reask`,slot:`message.actions`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,order:9},{id:`host:msg-edit-reask`,slot:`message.actions`,labelKey:`editReask`,icon:`edit`,kind:`action`,order:10},{id:`host:msg-fork`,slot:`message.actions`,labelKey:`forkSession`,icon:`branch`,kind:`action`,order:15},{id:`host:msg-rollback`,slot:`message.actions`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,order:16},{id:`host:msg-copy`,slot:`message.actions`,labelKey:`copyMessage`,icon:`copy`,kind:`action`,order:20},{id:`host:msg-copy-text`,slot:`message.actions`,labelKey:`copyText`,icon:`text`,kind:`action`,order:21},{id:`host:msg-copy-markdown`,slot:`message.actions`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,order:22},{id:`host:msg-copy-image`,slot:`message.actions`,labelKey:`copyImage`,icon:`image`,kind:`action`,order:23},{id:`host:msg-speak`,slot:`message.actions`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,order:24},{id:`host:composer-upload`,slot:`composer.actions`,labelKey:`uploadFile`,icon:`upload`,kind:`action`,order:10,align:`start`},{id:`host:composer-templates`,slot:`composer.actions`,labelKey:`tpl.openPicker`,icon:`grid`,kind:`action`,order:110,align:`start`},{id:`host:composer-model`,slot:`composer.actions`,labelKey:`selectModel`,icon:`cpu`,kind:`action`,order:120,align:`start`},{id:`host:composer-thinking`,slot:`composer.actions`,labelKey:`thinkingLevel`,icon:`zap`,kind:`action`,order:130,align:`start`},{id:`host:composer-dsh-perm`,slot:`composer.actions`,labelKey:`dshPerm`,icon:`lock`,kind:`action`,order:140,align:`start`},{id:`host:composer-dsh-preset`,slot:`composer.actions`,labelKey:`dshPreset`,icon:`layers`,kind:`action`,order:150,align:`start`},{id:`host:composer-send`,slot:`composer.actions`,labelKey:`sendTip`,icon:`send`,kind:`action`,order:200,align:`end`},{id:`host:fp-md`,slot:`file.preview.toolbar`,labelKey:`showMarkdownPreview`,icon:`eye`,kind:`action`,order:10},{id:`host:fp-toc`,slot:`file.preview.toolbar`,labelKey:`previewTocLabel`,icon:`list`,kind:`action`,order:15},{id:`host:fp-html`,slot:`file.preview.toolbar`,labelKey:`showHtmlPreview`,icon:`code`,kind:`action`,order:20},{id:`host:fp-edit`,slot:`file.preview.toolbar`,labelKey:`editFile`,icon:`edit`,kind:`action`,order:30},{id:`host:fp-wrap`,slot:`file.preview.toolbar`,labelKey:`enableWrap`,icon:`wrap`,kind:`action`,order:40},{id:`host:fp-zoom`,slot:`file.preview.toolbar`,labelKey:`zoomIn`,icon:`zoom`,kind:`action`,order:50},{id:`host:fp-ref`,slot:`file.preview.toolbar`,labelKey:`referenceTip`,icon:`link`,kind:`action`,order:70},{id:`host:fp-full`,slot:`file.preview.toolbar`,labelKey:`fullscreen`,icon:`maximize`,kind:`action`,order:80},{id:`host:fp-close`,slot:`file.preview.toolbar`,labelKey:`close`,icon:`x`,kind:`action`,order:90},{id:`host:goal-pill`,slot:`goalbar.actions`,labelKey:`goalBarTitle`,icon:`target`,kind:`action`,order:5},{id:`host:goal-set`,slot:`goalbar.actions`,labelKey:`goalBarSet`,icon:`check`,kind:`action`,order:10},{id:`host:goal-wizard`,slot:`goalbar.actions`,labelKey:`goalWizardBtn`,icon:`search`,kind:`action`,order:20},{id:`host:goal-lock`,slot:`goalbar.actions`,labelKey:`goalBarLocked`,icon:`lock`,kind:`action`,order:30},{id:`host:goal-plan`,slot:`goalbar.actions`,labelKey:`planMode`,icon:`list`,kind:`action`,order:25},{id:`host:goal-collapse`,slot:`goalbar.actions`,labelKey:`collapsePanel`,icon:`chevron-up`,kind:`action`,order:40},{id:`host:goal-model`,slot:`goalbar.actions`,labelKey:`goalBarReviewModel`,icon:`cpu`,kind:`action`,order:50},{id:`host:goal-rounds`,slot:`goalbar.actions`,labelKey:`goalBarMaxRounds`,icon:`hash`,kind:`action`,order:60},{id:`host:goal-execmodel`,slot:`goalbar.actions`,labelKey:`goalBarExecModel`,icon:`cpu`,kind:`action`,order:55},{id:`host:goal-openrole`,slot:`goalbar.actions`,labelKey:`goalBarOpenExec`,icon:`search`,kind:`action`,order:65},{id:`host:goal-clear`,slot:`goalbar.actions`,labelKey:`goalBarClear`,icon:`x`,kind:`action`,order:70},{id:`host:scm-changes`,slot:`scm.toolbar`,labelKey:`scmChanges`,icon:`file`,kind:`action`,order:10},{id:`host:scm-history`,slot:`scm.toolbar`,labelKey:`scmHistory`,icon:`clock`,kind:`action`,order:20},{id:`host:scm-refresh`,slot:`scm.toolbar`,labelKey:`scmRefreshTip`,icon:`refresh`,kind:`action`,order:30},{id:`host:scm-branch`,slot:`scm.toolbar`,labelKey:`scmSwitchBranch`,icon:`git`,kind:`action`,order:40},{id:`host:scm-switch`,slot:`scm.toolbar`,labelKey:`scmSwitch`,icon:`git`,kind:`action`,order:50},{id:`host:scm-push`,slot:`scm.toolbar`,labelKey:`scmPush`,icon:`upload`,kind:`action`,order:60},{id:`host:scm-pull`,slot:`scm.toolbar`,labelKey:`scmPull`,icon:`download`,kind:`action`,order:70},{id:`host:scm-input`,slot:`scm.toolbar`,labelKey:`scmCommitPlaceholder`,icon:`edit`,kind:`action`,order:80},{id:`host:scm-genmsg`,slot:`scm.toolbar`,labelKey:`scmGenMsg`,icon:`cpu`,kind:`action`,order:85},{id:`host:scm-commit`,slot:`scm.toolbar`,labelKey:`scmCommit`,icon:`check`,kind:`action`,order:90},{id:`host:scm-commit-all`,slot:`scm.toolbar`,labelKey:`scmCommitAll`,icon:`check`,kind:`action`,order:100},{id:`host:scm-term`,slot:`scm.toolbar`,labelKey:`terminal`,icon:`terminal`,kind:`action`,order:110},{id:`host:term-cmd-refresh`,slot:`terminal.toolbar`,labelKey:`rerun`,icon:`refresh`,kind:`action`,order:10},{id:`host:term-cmd-new`,slot:`terminal.toolbar`,labelKey:`newCommand`,icon:`plus`,kind:`action`,order:20},{id:`host:term-tab-new`,slot:`terminal.toolbar`,labelKey:`newTerminal`,icon:`plus`,kind:`action`,order:30},{id:`host:right-files`,slot:`rightpanel.tabs`,labelKey:`openFiles`,icon:`folder`,kind:`view`,view:`files`,order:10},{id:`host:conv-rename`,slot:`contextmenu.session`,labelKey:`renameSession`,icon:`edit`,kind:`action`,context:`session`,order:1},{id:`host:conv-pin`,slot:`contextmenu.session`,labelKey:`pinConversation`,icon:`pin`,kind:`action`,context:`session`,order:2},{id:`host:conv-takeover`,slot:`contextmenu.session`,labelKey:`takeoverConversation`,icon:`chat`,kind:`action`,context:`session`,order:5},{id:`host:conv-dismiss-subagents`,slot:`contextmenu.session`,labelKey:`dismissFinishedSubagents`,icon:`x`,kind:`action`,context:`session`,order:10},{id:`host:conv-force-dismiss`,slot:`contextmenu.session`,labelKey:`forceDismissConversation`,icon:`x`,kind:`action`,context:`session`,order:20},{id:`host:conv-persist`,slot:`contextmenu.session`,labelKey:`persistSubagent`,icon:`save`,kind:`action`,context:`session`,order:25},{id:`host:conv-copy-id`,slot:`contextmenu.session`,labelKey:`copyConversationId`,icon:`copy`,kind:`action`,context:`session`,order:30},{id:`host:conv-copy-path`,slot:`contextmenu.session`,labelKey:`copyConversationPath`,icon:`copy`,kind:`action`,context:`session`,order:40},{id:`host:conv-copy-link`,slot:`contextmenu.session`,labelKey:`copyConversationLink`,icon:`link`,kind:`action`,context:`session`,order:45},{id:`host:conv-quote`,slot:`contextmenu.session`,labelKey:`quoteConversation`,icon:`chat`,kind:`action`,context:`session`,order:50},{id:`host:file-open`,slot:`contextmenu.file`,labelKey:`fileOpenPreview`,icon:`open`,kind:`action`,context:`file`,order:11,group:`open`},{id:`host:file-enter`,slot:`contextmenu.file`,labelKey:`fileEnterDir`,icon:`folder`,kind:`action`,context:`file`,order:12,group:`open`},{id:`host:file-download`,slot:`contextmenu.file`,labelKey:`downloadFile`,icon:`download`,kind:`action`,context:`file`,order:13,group:`open`},{id:`host:file-compress`,slot:`contextmenu.file`,labelKey:`fileCompress`,icon:`file`,kind:`action`,context:`file`,order:16,group:`archive`},{id:`host:file-extract`,slot:`contextmenu.file`,labelKey:`fileExtract`,icon:`folder`,kind:`action`,context:`file`,order:17,group:`archive`},{id:`host:file-compress-download`,slot:`contextmenu.file`,labelKey:`fileCompressDownload`,icon:`download`,kind:`action`,context:`file`,order:18,group:`archive`},{id:`host:file-upload-folder`,slot:`contextmenu.file`,labelKey:`fileUploadFolder`,icon:`upload`,kind:`action`,context:`file`,order:25,group:`new`},{id:`host:file-open-project`,slot:`contextmenu.file`,labelKey:`openAsProject`,icon:`folder`,kind:`action`,context:`file`,order:14,group:`open`},{id:`host:file-add-root`,slot:`contextmenu.file`,labelKey:`addWorkspaceRoot`,icon:`folder`,kind:`action`,context:`file`,order:15,group:`open`},{id:`host:file-reveal`,slot:`contextmenu.file`,labelKey:`fileReveal`,icon:`folder`,kind:`action`,context:`file`,order:16,group:`open`},{id:`host:file-open-default`,slot:`contextmenu.file`,labelKey:`fileOpenDefault`,icon:`open`,kind:`action`,context:`file`,order:17,group:`open`},{id:`host:file-new-file`,slot:`contextmenu.file`,labelKey:`fileNewFile`,icon:`file`,kind:`action`,context:`file`,order:21,group:`new`},{id:`host:file-new-dir`,slot:`contextmenu.file`,labelKey:`fileNewDir`,icon:`folder`,kind:`action`,context:`file`,order:22,group:`new`},{id:`host:file-upload`,slot:`contextmenu.file`,labelKey:`uploadToFolder`,icon:`upload`,kind:`action`,context:`file`,order:23,group:`new`},{id:`host:file-paste`,slot:`contextmenu.file`,labelKey:`filePaste`,icon:`paste`,kind:`action`,context:`file`,order:24,group:`new`},{id:`host:file-attach-ref`,slot:`contextmenu.file`,labelKey:`referenceTip`,icon:`link`,kind:`action`,context:`file`,order:32,group:`chat`},{id:`host:file-attach-folder`,slot:`contextmenu.file`,labelKey:`linkFolderTip`,icon:`link`,kind:`action`,context:`file`,order:33,group:`chat`},{id:`host:file-rename`,slot:`contextmenu.file`,labelKey:`fileRename`,icon:`edit`,kind:`action`,context:`file`,order:41,group:`edit`},{id:`host:file-duplicate`,slot:`contextmenu.file`,labelKey:`fileDuplicate`,icon:`copy`,kind:`action`,context:`file`,order:42,group:`edit`},{id:`host:file-cut`,slot:`contextmenu.file`,labelKey:`fileCut`,icon:`cut`,kind:`action`,context:`file`,order:43,group:`edit`},{id:`host:file-copy`,slot:`contextmenu.file`,labelKey:`fileCopyEntry`,icon:`copy`,kind:`action`,context:`file`,order:44,group:`edit`},{id:`host:file-copy-name`,slot:`contextmenu.file`,labelKey:`copyName`,icon:`copy`,kind:`action`,context:`file`,order:51,group:`clipboard`},{id:`host:file-copy-path`,slot:`contextmenu.file`,labelKey:`copyPath`,icon:`copy`,kind:`action`,context:`file`,order:52,group:`clipboard`},{id:`host:file-copy-rel`,slot:`contextmenu.file`,labelKey:`fileCopyRelPath`,icon:`copy`,kind:`action`,context:`file`,order:53,group:`clipboard`},{id:`host:file-refresh`,slot:`contextmenu.file`,labelKey:`fileRefresh`,icon:`refresh`,kind:`action`,context:`file`,order:54,group:`clipboard`},{id:`host:file-delete`,slot:`contextmenu.file`,labelKey:`fileDelete`,icon:`trash`,kind:`action`,context:`file`,order:61,group:`danger`},{id:`host:msg-ctx-copy-markdown`,slot:`contextmenu.message`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,context:`message`,order:10,group:`copy`},{id:`host:msg-ctx-copy-text`,slot:`contextmenu.message`,labelKey:`copyText`,icon:`text`,kind:`action`,context:`message`,order:11,group:`copy`},{id:`host:msg-ctx-copy-image`,slot:`contextmenu.message`,labelKey:`copyImage`,icon:`image`,kind:`action`,context:`message`,order:12,group:`copy`},{id:`host:msg-ctx-copy-link`,slot:`contextmenu.message`,labelKey:`copyMessageLink`,icon:`link`,kind:`action`,context:`message`,order:13,group:`copy`},{id:`host:msg-ctx-reask`,slot:`contextmenu.message`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,context:`message`,order:19,group:`action`},{id:`host:msg-ctx-edit-reask`,slot:`contextmenu.message`,labelKey:`editReask`,icon:`edit`,kind:`action`,context:`message`,order:20,group:`action`},{id:`host:msg-ctx-fork`,slot:`contextmenu.message`,labelKey:`forkSession`,icon:`branch`,kind:`action`,context:`message`,order:21,group:`action`},{id:`host:msg-ctx-rollback`,slot:`contextmenu.message`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,context:`message`,order:22,group:`action`},{id:`host:msg-ctx-speak`,slot:`contextmenu.message`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,context:`message`,order:23,group:`action`},{id:`host:tool-info`,slot:`contextmenu.toolcall`,labelKey:`toolInfoMenuLabel`,icon:`info`,kind:`action`,context:`toolcall`,order:10}],Ki=`__view`,qi=new Set([`host:settings`,`host:history`,`host:files`]),Ji=new Set([`host:history`,`host:files`]);function Yi(e){return`${e}:${Ki}`}function Xi(e){return e.source.startsWith(`plugin:`)?e.id===Yi(e.source.slice(7)):!1}function Zi(e,t,n){let r=Yi(t),i=(e?.hidden??[]).filter(e=>e!==r),a=(e?.shown??[]).filter(e=>e!==r);return n?a.push(r):i.push(r),{...e,hidden:i,shown:a}}function Qi(e,t){let n=t.map(Yi),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var $i=`host:brand`,ea=[`host:brand-logo`,`host:brand-name`];function ta(e){if(!((e.hidden??[]).some(e=>ea.includes(e))||(e.shown??[]).some(e=>ea.includes(e))||(e.order??[]).some(e=>ea.includes(e))||ea.some(t=>e.align?.[t]!==void 0)||ea.some(t=>e.groups?.[t]!==void 0)||ea.some(t=>e.labels?.[t]!==void 0)||ea.some(t=>e.slots?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=ea.includes(n)?$i:n;t.includes(e)||t.push(e)}return t},n=(e,t)=>{if(!e)return;let n={};for(let[t,r]of Object.entries(e))ea.includes(t)||(n[t]=r);if(n[$i]===void 0){let r=t?e[ea[0]]??e[ea[1]]:e[ea[1]]??e[ea[0]];r!==void 0&&(n[$i]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))ea.includes(n)||(t[n]=r);if(t[$i]===void 0){let n=e[ea[0]]??e[ea[1]];n!==void 0&&(t[$i]=n)}return t},i=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))ea.includes(n)||(t[n]=r);if(t[$i]===void 0){let n=e[ea[0]]??e[ea[1]];n!==void 0&&(t[$i]=n)}return t};return{...e,...e.hidden?{hidden:t(e.hidden)}:{},...e.shown?{shown:t(e.shown)}:{},...e.order?{order:t(e.order)}:{},...e.groups?{groups:n(e.groups,!0)}:{},...e.labels?{labels:n(e.labels,!1)}:{},...e.align?{align:r(e.align)}:{},...e.slots?{slots:i(e.slots)}:{}}}function na(e){return e.map(e=>{if(e.view===!1)return e;let t=e.ui?.items??[];if(t.some(e=>e.id===`__view`))return e;let n={id:Ki,slot:`topbar.primary`,label:e.name,...e.icon?{icon:e.icon}:{},...e.iconSvg?{iconSvg:e.iconSvg}:{},kind:`view`,view:`plugin:${e.id}`,order:23,align:`end`,hidden:!0};return{...e,ui:{items:[...t,n],arrange:e.ui?.arrange??[]}}})}function ra(e){return typeof e==`string`&&Vi.includes(e)}function ia(e,t){return t?e.label:e.labelEn??e.label}function aa(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function oa(e,t,n,r,i){let a=`${e}#${r.id}`,o=sa(a,t,n,r.children,i),s=aa(r,i),c=ca(r.options,i);return{id:a,slot:t,source:n,label:ia(r,i),labelExplicit:!0,...r.icon?{icon:r.icon}:{},...r.iconSvg?{iconSvg:r.iconSvg}:{},...s?{hint:s}:{},kind:r.kind??`action`,...r.action?{action:r.action}:{},...r.view?{view:r.view}:{},...r.group?{group:r.group}:{},order:r.order??100,align:`start`,hidden:r.hidden??!1,...r.badge?{badge:r.badge}:{},...r.when?{when:r.when}:{},...c?{options:c}:{},...o.length>0?{children:o}:{},userOverrides:[],arrangedBy:[]}}function sa(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:oa(e,t,n,r,i),index:a})).sort((e,t)=>e.entry.order===t.entry.order?e.index-t.index:e.entry.order-t.entry.order).map(e=>e.entry):[]}function ca(e,t){if(e?.length)return e.slice(0,32).map(e=>({value:e.value,label:t?e.label??e.labelEn??e.value:e.labelEn??e.label??e.value}))}function la(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function ua(e,t,n,r,i,a){let o=sa(e,t,n,r.children,i),s=aa(r,i),c=la(r.progress),l=ca(r.options,i);return{id:e,slot:t,source:n,label:ia(r,i),labelExplicit:!0,...r.icon?{icon:r.icon}:{},...r.iconSvg?{iconSvg:r.iconSvg}:{},...s?{hint:s}:{},kind:r.kind??(t===`settings.pages`?`page`:`action`),...r.action?{action:r.action}:{},...r.view?{view:r.view}:{},...r.group?{group:r.group}:{},order:r.order??100,align:r.align??`start`,hidden:r.hidden??!1,...r.badge?{badge:r.badge}:{},...typeof r.checked==`boolean`?{checked:r.checked}:{},...typeof r.value==`string`?{value:r.value}:{},...c===void 0?{}:{progress:c},...l?{options:l}:{},...r.when?{when:r.when}:{},...o.length>0?{children:o}:{},userOverrides:[],arrangedBy:[],seq:a}}function da(e,t){return[...e].sort((e,n)=>{let r=t.get(e.id),i=t.get(n.id);return r!==void 0||i!==void 0?r!==void 0&&i!==void 0?r-i:r===void 0?1:-1:e.order===n.order?e.seq-n.seq:e.order-n.order})}function fa(e,t){let n=e.filter(e=>Xi(e)&&!t.has(e.id));if(n.length===0)return e;let r=e.filter(e=>!Xi(e)||t.has(e.id)),i=[`host:git`,`host:terminal`,`host:chat`].map(e=>r.findIndex(t=>t.id===e)).find(e=>e>=0)??-1,a=r.findIndex(e=>e.id===`host:plugins`),o=i+1;return a>=o&&(o=a),o=Math.max(0,Math.min(o,r.length)),[...r.slice(0,o),...n,...r.slice(o)]}function pa(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=ta(t.layout??{}),a=e=>{t.diagnostics?.push({level:e.level??`warn`,...e})},o=new Map,s=0;for(let e of Gi)o.set(e.id,{id:e.id,slot:e.slot,source:`host`,label:t.t(e.labelKey),labelKey:e.labelKey,...e.icon?{icon:e.icon}:{},kind:e.kind,...e.view?{view:e.view}:{},...e.group?{group:e.group}:{},order:e.order??100,align:e.align??`start`,hidden:e.hidden??!1,userOverrides:[],arrangedBy:[],seq:s++});for(let t of e){if(r.has(t.id)){a({pluginId:t.id,message:`plugin "${t.id}" is disabled by the user — its ${t.ui?.items?.length??0} UI item(s) are not rendered`});continue}if(t.error){a({level:`error`,pluginId:t.id,message:`plugin "${t.id}" failed to activate (${t.error}) — its UI items are not rendered`});continue}let e=`plugin:${t.id}`;for(let r of t.ui?.items??[]){if(!ra(r.slot)){a({pluginId:t.id,entryId:r.id,message:`item "${t.id}:${r.id}" declares unknown slot "${String(r.slot)}" — dropped (valid slots: see docs/architecture-plugins.md)`});continue}if(r.slot===`leftpanel.sections`&&r.kind!==`view`){a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" targets leftpanel.sections: only kind="view" (a plugin section) is accepted — dropped`});continue}if(r.kind&&!zi.has(r.kind)&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares unknown kind "${r.kind}" — the render layer falls back to a plain button`}),Array.isArray(r.when))for(let e of r.when)Bi.has(e)||a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares when:"${e}" which the host does not know — it is ignored (the item still renders)`});else r.when!==void 0&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" has a non-array "when" — ignored`});let i=`${t.id}:${r.id}`,c=o.get(i);c&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item id "${r.id}" is declared more than once — the later declaration wins (order/visibility are inherited from the first)`}),o.set(i,ua(i,r.slot,e,r,n,c?.seq??s++))}}for(let t of e)if(!(t.error||r.has(t.id)))for(let e of t.ui?.arrange??[]){let n=o.get(e.id);ha(o,e,t.id),n||a({pluginId:t.id,entryId:e.id,message:`arrange target "${e.id}" does not exist — op ignored (is the providing plugin installed / not disabled?)`})}let c=new Map,l=(e,t)=>{let n=c.get(e)??[];n.includes(t)||n.push(t),c.set(e,n)};for(let e of i.hidden??[]){let t=o.get(e);t&&(t.hidden=!0,l(e,`hidden`))}for(let e of i.shown??[]){let t=o.get(e);t&&(t.hidden=!1,l(e,`hidden`))}for(let[e,t]of Object.entries(i.groups??{})){let n=o.get(e);n&&(n.group=t,l(e,`group`))}for(let[e,t]of Object.entries(i.align??{})){let n=o.get(e);!n||t!==`start`&&t!==`center`&&t!==`end`||(n.align=t,l(e,`align`))}for(let[e,t]of Object.entries(i.labels??{})){let n=o.get(e);n&&(n.label=t,n.labelExplicit=!0,l(e,`label`))}for(let[e,t]of Object.entries(i.slots??{})){let n=o.get(e);n&&ra(t)&&n.slot!==t&&(n.movedFrom=n.movedFrom??n.slot,n.slot=t,l(e,`slot`))}for(let e of qi){let t=o.get(e);t&&(i.slots?.[e]||(t.slot=`topbar.primary`),t.hidden=!1)}let u=new Map;(i.order??[]).forEach((e,t)=>{o.has(e)&&(u.has(e)||u.set(e,t),l(e,`order`))});for(let e of Object.values(Ai)){let t=o.get(e);t&&t.slot!==`leftpanel.sections`&&(a({entryId:e,slot:t.slot,message:`"${e}" must stay in leftpanel.sections — the move is ignored`}),t.slot=`leftpanel.sections`,delete t.movedFrom)}let d=new Map;for(let e of Vi)d.set(e,[]);for(let e of o.values())d.get(e.slot)?.push(e);let f={};for(let e of Vi){let t=da(d.get(e)??[],u),n=Wi(e===`topbar.primary`?fa(t,u):t,Ui(e));if(n.winner&&n.conflicts.length>0)for(let t of n.conflicts)a({level:`error`,pluginId:t.source.startsWith(`plugin:`)?t.source.slice(7):void 0,entryId:t.id,slot:e,message:`slot "${e}" is single-cardinality; "${n.winner.id}" won and "${t.id}" was hidden`});f[e]=n.entries.map(e=>ma(e,c.get(e.id)??[]))}return f}function ma(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function ha(e,t,n){let r=e.get(t.id);if(!r)return;let i=!1;t.hide!==void 0&&(r.hidden=t.hide,i=!0),t.group!==void 0&&(r.group=t.group,i=!0),t.order!==void 0&&(r.order=t.order,i=!0),t.align!==void 0&&(r.align=t.align,i=!0),t.label!==void 0&&(r.label=t.label,r.labelExplicit=!0,i=!0),t.hint!==void 0&&(r.hint=t.hint,i=!0),t.icon!==void 0&&(r.icon=t.icon,i=!0),t.iconSvg!==void 0&&(r.iconSvg=t.iconSvg||void 0,i=!0),t.slot!==void 0&&ra(t.slot)&&t.slot!==r.slot&&(r.movedFrom=r.movedFrom??r.slot,r.slot=t.slot,i=!0),i&&r.source!==`plugin:${n}`&&!r.arrangedBy.includes(n)&&r.arrangedBy.push(n)}function ga(e){let t=[],n=[],r=[];for(let i of e)i.align===`end`?r.push(i):i.align===`center`?n.push(i):t.push(i);return{start:t,center:n,end:r}}function _a(e,t){let n=e??{},r={},i=t===$i?[t,...ea]:[t],a=(n.hidden??[]).filter(e=>!i.includes(e)),o=(n.shown??[]).filter(e=>!i.includes(e)),s=(n.order??[]).filter(e=>!i.includes(e));a.length>0&&(r.hidden=a),o.length>0&&(r.shown=o),s.length>0&&(r.order=s);let c=ya(n.groups,t),l=ya(n.labels,t),u=ya(n.align,t),d=ya(n.slots,t);if(t===$i)for(let e of ea)c=ya(c,e),l=ya(l,e),u=ya(u,e),d=ya(d,e);return c&&(r.groups=c),l&&(r.labels=l),u&&(r.align=u),d&&(r.slots=d),n.topbarText!==void 0&&(r.topbarText=n.topbarText),n.sideDockFloat!==void 0&&(r.sideDockFloat=n.sideDockFloat),r}function va(){return{}}function ya(e,t){if(!e)return;let n={},r=!1;for(let[i,a]of Object.entries(e))i!==t&&(n[i]=a,r=!0);return r?n:void 0}var ba=new Set([`host:files`]);function xa(e,t){let n=e=>e===`center`?1:e===`end`?2:0;return[...e].sort((e,r)=>n(e.align)-n(r.align)||t(e.id)-t(r.id))}function Sa(e,t,n,r,i=new Set){let a=new Set;if(!Number.isFinite(t)||t<=0)return a;let o=e.filter(e=>i.has(e.id)&&e.width>0).reduce((e,t)=>e+t.width+n,0),s=Math.max(0,t-Math.max(0,r)-o),c=0,l=!1;for(let t of e){if(!(t.width>0)||i.has(t.id))continue;let e=t.width+n;if(l||c+e>s){l=!0,a.add(t.id);continue}c+=e}return a}var Ca=null,wa=new Set;function Ta(){for(let e of wa)e()}function Ea(e){Ca={x:Number.isFinite(e.x)?e.x:0,y:Number.isFinite(e.y)?e.y:0,slot:e.slot,target:e.target??{id:``},entries:Array.isArray(e.entries)?e.entries:[],...typeof e.onHostAction==`function`?{onHostAction:e.onHostAction}:{}},Ta()}function Da(){Ca!==null&&(Ca=null,Ta())}function Oa(e){return wa.add(e),()=>{wa.delete(e)}}function ka(){return Ca}function Aa(){return(0,g.useSyncExternalStore)(Oa,ka,ka)}function ja(e){return Number.isFinite(e)?e:0}function Ma(e,t,n,r,i,a){let o=Math.max(0,ja(n)),s=Math.max(0,ja(r)),c=Math.max(8,ja(i)-o-8),l=Math.max(8,ja(a)-s-8);return{x:Math.min(Math.max(8,ja(e)),c),y:Math.min(Math.max(8,ja(t)),l)}}function Na(e,t){let n=String(t?.kind??``);if(e===`contextmenu.file`)return{"file.isDir":n===`dir`||n===`list`&&t?.id!==`@root`,"file.isFile":n===`file`};if(e===`contextmenu.session`)return{"session.isRunning":n===`running`};if(e===`contextmenu.message`){let e=!1;try{let t=window.getSelection?.();e=!!t&&!t.isCollapsed&&t.toString().trim().length>0}catch{e=!1}return{"message.hasSelection":e}}return{}}function Pa(e,t){if(!Array.isArray(e)||e.length===0)return!1;for(let n of e){if(typeof n!=`string`||!n)continue;let e=n.trim();if(e===`disabled`||e===`never`)return!0;if(e!==`always`){if(e.startsWith(`!`)){let n=e.slice(1).trim();if(!n)continue;if(!t||t[n]!==!0)return!0;continue}if(t&&t[e]===!1)return!0}}return!1}function Fa(e,t){return!e||Pa(e.when,t)}function Ia(e){let t=new Map;return{items:(Array.isArray(e)?e:[]).map(e=>{if(!e||e.kind!==`select`||!e.options?.length||e.children?.length)return e;let n=e.options.map((t,n)=>({id:`${e.id}#${n}`,slot:e.slot,source:e.source,label:t.label,kind:`action`,order:100,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}));return n.forEach((n,r)=>t.set(n.id,{parent:e,value:e.options[r].value})),{...e,kind:`menu`,children:n}}),selectParents:t}}function La(e){if(!Array.isArray(e)||e.length===0)return[];let t=e.filter(e=>e&&e.hidden!==!0),n=t.filter(e=>e.kind!==`divider`),r=new Map,i=new Map;n.forEach((e,t)=>{let n=e.group??``;r.has(n)||r.set(n,t);let a=Number.isFinite(e.order)?e.order:100,o=i.get(n);(o===void 0||a<o)&&i.set(n,a)});let a=[...r.keys()].sort((e,t)=>{let n=i.get(e)??100,a=i.get(t)??100;return n===a?(r.get(e)??0)-(r.get(t)??0):n-a}),o=new Map(a.map((e,t)=>[e,t])),s=new Map;n.forEach((e,t)=>s.set(e,t));let c=[...n].sort((e,t)=>{let n=o.get(e.group??``)??0,r=o.get(t.group??``)??0;if(n!==r)return n-r;let i=Number.isFinite(e.order)?e.order:100,a=Number.isFinite(t.order)?t.order:100;return i===a?(s.get(e)??0)-(s.get(t)??0):i-a}),l=new Map;t.forEach((e,n)=>{if(e.kind!==`divider`)return;let r=t.slice(n+1).find(e=>e.kind!==`divider`);if(!r)return;let i=l.get(r)??[];i.push(e),l.set(r,i)});let u=[];for(let e of c){for(let t of l.get(e)??[])u.push(t);u.push(e)}return u}function Ra(e){let t=[],n=null,r=!1;return e.forEach((e,i)=>{if(!e||e.kind===`divider`){r=!0;return}let a=e.group??``;n!==null&&(r||a!==n)&&t.push({kind:`sep`,key:`sep:${i}`}),t.push({kind:`item`,key:`${e.id}#${i}`,index:i,entry:e}),n=a,r=!1}),t}function za(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!Fa(e,t)}function Ba(e,t,n,r){let i=Array.isArray(e)?e.length:0;if(i===0)return-1;let a=n>=0?1:-1,o=Number.isFinite(t)?Math.trunc(t):-1;(o<0||o>=i)&&(o=a>0?-1:i);for(let t=0;t<i;t++)if(o=(o+a+i)%i,za(e[o],r))return o;return-1}var Va={menu:`☰`,folder:`📁`,plus:`+`,chat:`💬`,terminal:`▙`,git:`⎇`,search:`🔍`,browser:`🌐`,layers:`🗂`,settings:`⚙`,sound:`🔊`,globe:`🌍`,sun:`☀`,download:`⤓`,github:`⌗`,x:`✕`,upload:`⬆`,copy:`⧉`,cut:`✂`,paste:`📋`,trash:`🗑`,file:`📄`,open:`↗`,refresh:`⟳`,link:`🔗`,edit:`✎`,dot:`●`,info:`ⓘ`,cpu:`▣`,gauge:`▤`,coins:`◉`,database:`▥`,message:`✉`,activity:`〜`,markdown:`📄`,text:`≡`,image:`🖼`,branch:`⚚`,undo:`↺`,pin:`📌`,volume:`🔊`};function Ha(e){let t=(e??``).trim();return t?Va[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var Ua={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},Wa=new Set;function Ga(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function Ka(e,t){return e.engine===t.engine&&e.managed===t.managed&&e.appVersion===t.appVersion&&e.serverVersion===t.serverVersion&&e.status===t.status&&e.ready===t.ready&&e.cwd===t.cwd&&Ga(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&Ga(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function qa(e){let t={...Ua,...e};if(!Ka(Ua,t)){Ua=t;for(let e of Wa)e()}}function Ja(e){return Wa.add(e),()=>{Wa.delete(e)}}function Ya(){return Ua}function Xa(){return(0,g.useSyncExternalStore)(Ja,Ya,Ya)}function Za(e){return(0,g.useSyncExternalStore)(Ja,()=>Ua[e],()=>Ua[e])}function Qa(){return Za(`engine`)===`dsh`}function $a(){return Za(`managed`)}function eo(){return Za(`service`)}var to=null;function no(e){to=e}var $=e=>to?to(e):!1,ro=new Set;function io(e){return ro.add(e),()=>{ro.delete(e)}}function ao(e){for(let t of ro)try{t(e)}catch(e){console.error(`[remote-ssh-client] listener error:`,e)}}function oo(e,t,n,r){return`ssh://${e}@${t}:${n}${r.startsWith(`/`)?r:`/${r}`}`}function so(e){return!!(e&&e.startsWith(`ssh://`))}function co(e){if(!so(e))return null;let t=/^ssh:\/\/([^@]+)@([^:]+):(\d+)(\/.*)$/.exec(e);return t?{username:t[1],host:t[2],port:parseInt(t[3],10),remotePath:t[4]}:null}var lo=1;function uo(e){let t=`probe_${Date.now()}_${lo++}`;return new Promise(n=>{let r=io(e=>{e.type===`remote_ssh_probe_result`&&e.reqId===t&&(r(),n({ok:e.ok,connectionId:e.connectionId,error:e.error,system:e.system,tools:e.tools,packageManager:e.packageManager,suggestedInstall:e.suggestedInstall}))});$({type:`remote_ssh_probe`,reqId:t,params:e})||(r(),n({ok:!1,error:`WebSocket 连接不可用,请稍候重试`}))})}function fo(e,t){let n=`listdir_${Date.now()}_${lo++}`;return new Promise(r=>{let i=io(e=>{e.type===`remote_ssh_list_dir_result`&&e.reqId===n&&(i(),r({ok:e.ok,connectionId:e.connectionId,path:e.path,parentPath:e.parentPath,items:e.items,error:e.error}))});$({type:`remote_ssh_list_dir`,reqId:n,connectionId:e,path:t})||(i(),r({ok:!1,connectionId:e,path:t||`/`,items:[],error:`WebSocket 连接不可用`}))})}function po(e,t){let n=`install_${Date.now()}_${lo++}`;return new Promise(r=>{let i=io(e=>{e.type===`remote_ssh_install_result`&&e.reqId===n&&(i(),r({ok:e.ok,connectionId:e.connectionId,tool:e.tool,output:e.output,error:e.error}))});$({type:`remote_ssh_install_tools`,reqId:n,connectionId:e,tools:t})||(i(),r({ok:!1,connectionId:e,tool:t[0]||``,error:`WebSocket 连接不可用`}))})}function mo(){let e=`profiles_${Date.now()}_${lo++}`;return new Promise(t=>{let n=io(r=>{r.type===`remote_ssh_profiles_result`&&r.reqId===e&&(n(),t(r.profiles))});$({type:`remote_ssh_list_profiles`,reqId:e})||(n(),t([]))})}function ho(e){$({type:`remote_ssh_delete_profile`,name:e})}var go=`@root`,_o=e=>e.endsWith(`/`)?e:e+`/`;function vo(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function yo(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var bo=e=>{let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;if(t===`@root`||t===`/`)return null;let n=t.lastIndexOf(`/`);if(n<0)return/^[A-Za-z]:$/.test(t)?go:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function xo({currentCwd:e,pathCompletions:t,workspaceRoots:n,onClose:r,onSelectDirectory:i,mode:a=`folder`,onCreateProject:o,className:s,backdropClassName:c,role:l,ariaLabel:u}){let d=Z(),[f,p]=(0,g.useState)(()=>so(e)?`remote`:`local`),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(-1),D=(0,g.useRef)(null),O=(0,g.useRef)(null),[k,A]=(0,g.useState)([]),[j,ee]=(0,g.useState)(``),[M,te]=(0,g.useState)(`22`),[N,ne]=(0,g.useState)(``),[F,re]=(0,g.useState)(`password`),[ie,ae]=(0,g.useState)(``),[I,R]=(0,g.useState)(`~/.ssh/id_rsa`),[z,oe]=(0,g.useState)(!0),[B,V]=(0,g.useState)(``),[H,se]=(0,g.useState)(!1),[ce,le]=(0,g.useState)(null),[ue,de]=(0,g.useState)(null),[fe,W]=(0,g.useState)(null),[pe,G]=(0,g.useState)(null),[K,me]=(0,g.useState)([]),[he,ge]=(0,g.useState)(!1),[q,_e]=(0,g.useState)(`/`),[ve,ye]=(0,g.useState)(`/`),[be,xe]=(0,g.useState)([]),[J,Se]=(0,g.useState)(!1),Ce=t.filter(e=>e.type===`dir`);(0,g.useEffect)(()=>{if(so(e)){let t=co(e);t&&(ee(t.host),te(String(t.port)),ne(t.username),_e(t.remotePath),ye(t.remotePath))}else{let t=(e||``).replace(/\\/g,`/`);h(t),v(t)}b(!1),S(``),w(null),E(-1)},[e]),(0,g.useEffect)(()=>{f===`remote`&&mo().then(e=>A(e))},[f]),(0,g.useEffect)(()=>{let e=requestAnimationFrame(()=>{D.current?.focus()});return()=>cancelAnimationFrame(e)},[f]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(y?(b(!1),S(``),w(null)):r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y,r]),(0,g.useEffect)(()=>{if(f!==`local`)return;let e=setTimeout(()=>{$({type:`complete_path`,path:_o(m)})},60);return()=>clearTimeout(e)},[m,f]),(0,g.useEffect)(()=>{if(f!==`local`||_===m)return;let e=setTimeout(()=>{$({type:`complete_path`,path:_})},150);return()=>clearTimeout(e)},[_,m,f]);let we=e=>{let t=e.trim();t&&t!==`@root`&&i(t)},Te=()=>{let e=x.trim();if(e){if(a===`project`){if(!yo(e)){w(d(`invalidProjectName`));return}let t=vo(m,e);o?.(t),b(!1),S(``),w(null),r()}else $({type:`make_dir`,path:`${_o(m)}${e}`}),setTimeout(()=>{$({type:`complete_path`,path:_o(m)})},80),S(``),b(!1)}},Ee=e=>{if(e.key===`Escape`)e.stopPropagation(),y?(b(!1),S(``),w(null)):r();else if(e.key===`Enter`&&!e.nativeEvent.isComposing)we(_);else if(e.key===`Tab`){if(Ce.length===0)return;e.preventDefault();let t=T>=0?(T+1)%Ce.length:0;E(t),v(Ce[t].path),h(Ce[t].path)}},De=async e=>{let t=(e?.host??j).trim(),n=e?.port??(parseInt(M,10)||22),r=(e?.username??N).trim();if(!t||!r){le(`请填写主机地址和用户名`);return}se(!0),le(null);let i=await uo({host:t,port:n,username:r,auth:e?.auth??(F===`password`?{type:`password`,password:ie}:F===`key`?{type:`key`,privateKeyPath:I}:{type:`agent`}),saveProfile:z,profileName:e?.profileName||B.trim()||void 0});if(se(!1),!i.ok||!i.connectionId){le(i.error||`连接远程服务器失败`);return}de(i.connectionId),W(i.system??null),G(i.tools??null),me(i.suggestedInstall??[]);let a=i.system?.homeDir||`/`;_e(a),ye(a),Oe(i.connectionId,a),mo().then(e=>A(e))},Oe=async(e,t)=>{Se(!0),le(null);let n=await fo(e,t);Se(!1),n.ok?(_e(n.path),ye(n.path),xe(n.items)):le(n.error||`读取远程目录失败`)},ke=async e=>{if(!ue)return;ge(!0),le(null);let t=await po(ue,[e]);ge(!1),t.ok?(me(t=>t.filter(t=>t!==e)),pe&&e===`git`&&G({...pe,git:{installed:!0,version:`已安装`}})):le(t.error||`安装 ${e} 失败,可能需要远端 sudo 权限`)},Ae=e=>{i(oo(N,j,parseInt(M,10)||22,e)),r()},je=bo(m),Me=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},Ne=Me(m),Pe=!!m&&m!==`@root`&&Ne!==Me(e)&&!n.some(e=>Me(e)===Ne);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`status-cwd-backdrop ${c??``}`.trim(),onClick:r}),(0,X.jsxs)(`div`,{className:`cwd-picker ${s??``}`.trim(),role:l,"aria-label":u,children:[(0,X.jsxs)(`div`,{className:`cwd-mode-tabs`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-mode-tab ${f===`local`?`active`:``}`,onClick:()=>p(`local`),children:[`💻 `,d(`workspaceModeLocal`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-mode-tab ${f===`remote`?`active`:``}`,onClick:()=>p(`remote`),children:[`🌐 `,d(`workspaceModeRemote`)]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-close`,title:d(`close`),"aria-label":d(`close`),onClick:r,children:(0,X.jsx)(P,{})})]}),f===`local`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:m===`@root`?d(`computer`):m,children:[m===`@root`?`💻`:(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{children:m===`@root`?d(`computer`):m})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:m===`@root`,title:d(`computer`),onClick:()=>{h(`@root`),v(`@root`),E(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!je,title:d(`cwdGoUp`),onClick:()=>{je&&(h(je),v(je),E(-1))},children:[`↑ `,d(`cwdGoUp`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!Pe,title:d(`addWorkspaceRootHint`),onClick:()=>{Pe&&$({type:`set_workspace_roots`,roots:[...n,m]})},children:[`+ `,d(`addWorkspaceRoot`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:D,className:`status-cwd-input cwd-picker-input`,value:_,placeholder:d(`enterPath`),spellCheck:!1,onChange:e=>{v(e.target.value),E(-1)},onKeyDown:Ee}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:d(`cwdPickCurrent`),disabled:m===`@root`,onClick:()=>we(m),children:d(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[Ce.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:d(`cwdEmpty`)}),Ce.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${d(`cwdEnter`)} ${e.path}`,onClick:()=>{h(e.path),v(e.path),E(-1)},children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:d(`cwdChoose`),onClick:()=>we(e.path),children:d(`cwdChoose`)})]},e.path))]}),(0,X.jsxs)(`div`,{className:`cwd-picker-foot`,children:[y?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:O,value:x,autoFocus:!0,spellCheck:!1,placeholder:d(a===`project`?`projectName`:`cwdNewName`),onChange:e=>{S(e.target.value),C&&w(null)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),Te()):e.key===`Escape`&&(e.stopPropagation(),b(!1),S(``),w(null))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:Te,children:d(a===`project`?`createAndOpenProject`:`cwdCreate`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{b(!1),S(``),w(null)},children:d(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>b(!0),children:[`+ `,d(a===`project`?`newProject`:`cwdNewFolder`)]}),C&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:C})]})]}),f===`remote`&&(0,X.jsx)(`div`,{className:`cwd-ssh-container`,children:ue?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-probe-box`,children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-probe-header`,children:[(0,X.jsxs)(`span`,{children:[`🌐 `,N,`@`,j,` (`,fe?.os,` `,fe?.arch,`)`]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-ssh-profile-del`,onClick:()=>{de(null),W(null),G(null)},children:d(`sshDisconnect`)})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`6px`,flexWrap:`wrap`,fontSize:`10px`},children:[(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.git.installed?`ok`:`missing`}`,children:[`Git: `,pe?.git.installed?`✓`:`✗`]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.node.installed?`ok`:`missing`}`,children:[`Node: `,pe?.node.installed?`✓`:`✗`]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.bash.installed?`ok`:`missing`}`,children:[`Bash: `,pe?.bash.installed?`✓`:`✗`]})]}),K.length>0&&(0,X.jsxs)(`div`,{className:`cwd-ssh-install-box`,children:[(0,X.jsx)(`div`,{children:`⚠️ 远端环境未检测到 Git / 基础工具,SCM 与执行功能可能受限。`}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`6px`,marginTop:`2px`},children:[(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,disabled:he,onClick:()=>void ke(K[0]),children:he?d(`sshInstalling`):`⚡ ${d(`sshInstallTool`)} ${K[0]}`}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>me([]),children:d(`sshSkipAndBrowse`)})]})]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:q,children:[(0,X.jsx)(Fe,{}),(0,X.jsx)(`span`,{children:q})]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:q===`/`||J,title:d(`cwdGoUp`),onClick:()=>{let e=bo(q)||`/`;ue&&Oe(ue,e)},children:[`↑ `,d(`cwdGoUp`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{className:`status-cwd-input cwd-picker-input`,value:ve,placeholder:d(`enterPath`),spellCheck:!1,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ue&&Oe(ue,ve)}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:()=>Ae(q),children:d(`sshOpenRemoteWorkspace`)})]}),(0,X.jsx)(`div`,{className:`cwd-list`,children:J?(0,X.jsx)(`div`,{className:`cwd-empty`,children:`正在加载远程目录…`}):be.length===0?(0,X.jsx)(`div`,{className:`cwd-empty`,children:d(`cwdEmpty`)}):be.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${e.type===`dir`?d(`cwdEnter`):``} ${e.path}`,onClick:()=>{e.type===`dir`&&ue&&Oe(ue,e.path)},children:[e.type===`dir`?(0,X.jsx)(Re,{}):(0,X.jsx)(`span`,{children:`📄`}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),e.type===`dir`&&(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:d(`cwdChoose`),onClick:()=>Ae(e.path),children:d(`cwdChoose`)})]},e.path))})]}):(0,X.jsxs)(`div`,{className:`cwd-ssh-form`,children:[k.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-profiles-title`,children:[`📋 `,d(`sshSavedProfiles`)]}),k.map(e=>(0,X.jsxs)(`div`,{className:`cwd-ssh-profile-card`,onClick:()=>{ee(e.host),te(String(e.port)),ne(e.username),re(e.authType),e.privateKeyPath&&R(e.privateKeyPath),De({host:e.host,port:e.port,username:e.username,profileName:e.name,auth:e.authType===`password`?{type:`password`,password:``}:e.authType===`key`?{type:`key`,privateKeyPath:e.privateKeyPath}:{type:`agent`}})},children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-profile-meta`,children:[(0,X.jsxs)(`span`,{className:`cwd-ssh-profile-name`,children:[(0,X.jsx)(U,{style:{marginRight:`4px`}}),e.name]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-profile-addr`,children:[e.username,`@`,e.host,`:`,e.port]})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-ssh-profile-del`,title:d(`delete`),onClick:t=>{t.stopPropagation(),confirm(d(`sshDeleteProfileConfirm`))&&(ho(e.name),A(t=>t.filter(t=>t.name!==e.name)))},children:(0,X.jsx)(L,{})})]},e.name))]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,style:{marginTop:`4px`},children:[(0,X.jsxs)(`label`,{children:[d(`sshHost`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:j,placeholder:`192.168.1.100`,onChange:e=>ee(e.target.value)}),(0,X.jsxs)(`label`,{style:{width:`32px`,textAlign:`right`},children:[d(`sshPort`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,style:{width:`45px`,flex:`none`},value:M,onChange:e=>te(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshUser`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:N,placeholder:`root / ubuntu`,onChange:e=>ne(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshAuthType`),`:`]}),(0,X.jsxs)(`select`,{className:`cwd-ssh-select`,value:F,onChange:e=>re(e.target.value),children:[(0,X.jsx)(`option`,{value:`password`,children:d(`sshPassword`)}),(0,X.jsx)(`option`,{value:`key`,children:d(`sshKeyPath`)}),(0,X.jsx)(`option`,{value:`agent`,children:d(`sshAgent`)})]})]}),F===`password`&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshPassword`),`:`]}),(0,X.jsx)(`input`,{type:`password`,className:`cwd-ssh-input`,value:ie,placeholder:`••••••••`,onChange:e=>ae(e.target.value)})]}),F===`key`&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshKeyPath`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:I,placeholder:`~/.ssh/id_rsa`,onChange:e=>R(e.target.value)})]}),(0,X.jsx)(`div`,{className:`cwd-ssh-row`,style:{fontSize:`11px`,color:`var(--text-dim)`},children:(0,X.jsxs)(`label`,{style:{width:`auto`},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:z,onChange:e=>oe(e.target.checked),style:{marginRight:`4px`}}),d(`sshSaveProfile`)]})}),z&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshProfileName`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:B,placeholder:`my-server`,onChange:e=>V(e.target.value)})]}),ce&&(0,X.jsxs)(`div`,{style:{color:`var(--red)`,fontSize:`11px`,padding:`2px 0`},children:[`⚠️ `,ce]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,style:{marginTop:`4px`},disabled:H,onClick:()=>void De(),children:d(H?`sshConnecting`:`sshConnectAndProbe`)})]})})]})]})}function So({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z();return e?(0,X.jsx)(xo,{currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:e=>{a(e),i()},onCreateProject:o,mode:`project`,className:`project-picker`,backdropClassName:`project-picker-backdrop`,role:`dialog`,ariaLabel:s(`projectPickerTitle`)}):null}function Co(e){return k({tag:`svg`,attr:{viewBox:`0 0 256 256`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M53.92,34.62A8,8,0,1,0,42.08,45.38L67.37,73.2A69.82,69.82,0,0,0,38,87.63a16,16,0,0,0-1.29,23.78L85,159.71,42.34,202.34a8,8,0,0,0,11.32,11.32L96.29,171l48.29,48.29A16,16,0,0,0,155.9,224c.38,0,.75,0,1.13,0a15.93,15.93,0,0,0,11.64-6.33,89.75,89.75,0,0,0,11.58-20.27l21.84,24a8,8,0,1,0,11.84-10.76ZM155.9,208,48,100.08C58.23,91.83,69.2,87.72,80.66,87.81l87.16,95.88C165.59,193.56,160.24,202.23,155.9,208Zm79.42-104-44.64,44.79a8,8,0,1,1-11.33-11.3L224,92.7,163.32,32,122.1,73.35a8,8,0,0,1-11.33-11.29L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.32,104Z`},child:[]}]})(e)}function wo(e){return k({tag:`svg`,attr:{viewBox:`0 0 256 256`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M235.33,104l-53.47,53.65c4.56,12.67,6.45,33.89-13.19,60A15.93,15.93,0,0,1,157,224c-.38,0-.75,0-1.13,0a16,16,0,0,1-11.32-4.69L96.29,171,53.66,213.66a8,8,0,0,1-11.32-11.32L85,159.71l-48.3-48.3A16,16,0,0,1,38,87.63c25.42-20.51,49.75-16.48,60.4-13.14L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.33,104Z`},child:[]}]})(e)}function To(e,t,n,r={}){let{align:i=`right`,side:a=`bottom`,gap:o=6,margin:s=8}=r,c=t.width,l=t.height,u=Math.max(0,n.width-c-s),d=Math.max(0,n.height-l-s),f=i===`left`?e.left:e.right-c;f=Math.max(s,Math.min(f,u));let p;return a===`top`?(p=e.top-l-o,p<s&&e.bottom+o+l<=n.height-s&&(p=e.bottom+o)):(p=e.bottom+o,p+l>n.height-s&&e.top-l-o>=s&&(p=e.top-l-o)),p>d&&(p=d),p<s&&(p=s),{x:Math.round(f),y:Math.round(p)}}function Eo(e){let{open:t=!0,anchor:n,anchorEl:r,onClose:i,isInside:a,align:o=`right`,side:s=`bottom`,gap:c=6,margin:l=8}=e,u=(0,g.useRef)(null),[d,f]=(0,g.useState)(null),p=(0,g.useRef)(i);(0,g.useLayoutEffect)(()=>{p.current=i});let m=()=>{if(!n)return null;if(`current`in n)return n.current?.getBoundingClientRect()??null;if(typeof n.getBoundingClientRect==`function`)return n.getBoundingClientRect();let e=n;return typeof e.left==`number`&&typeof e.right==`number`&&typeof e.top==`number`&&typeof e.bottom==`number`?e:null},h=()=>r||(n&&`current`in n?n.current:n&&typeof n.getBoundingClientRect==`function`?n:null),_=()=>{if(!t)return;let e=u.current;if(!e)return;let n=e.getBoundingClientRect();if(n.width===0&&n.height===0)return;let r=h(),i=r&&r.isConnected?r.getBoundingClientRect():m();if(!i)return;let a=To(i,{width:n.width,height:n.height},{width:window.innerWidth,height:window.innerHeight},{align:o,side:s,gap:c,margin:l});f(e=>e?.x===a.x&&e?.y===a.y?e:a)};return(0,g.useLayoutEffect)(()=>{t?_():f(null)},[t,n,r,o,s,c,l]),zt(()=>{p.current()},t),(0,g.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||h()?.contains(e)||a?.(e)),n=t=>{e(t.target)||p.current()};return document.addEventListener(`mousedown`,n,!0),window.addEventListener(`resize`,_,!0),window.addEventListener(`scroll`,_,!0),()=>{document.removeEventListener(`mousedown`,n,!0),window.removeEventListener(`resize`,_,!0),window.removeEventListener(`scroll`,_,!0)}},[t,n,r]),{panelRef:u,pos:d,style:{position:`fixed`,left:d?.x??-9999,top:d?.y??-9999,visibility:d?`visible`:`hidden`},measure:_}}function Do({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=Nn(),{panelRef:d,style:f,measure:p}=Eo({anchor:e,anchorEl:t,onClose:l}),[,m]=(0,g.useState)(null),h=(0,g.useRef)(null),[_,v]=(0,g.useState)(null),y=(0,g.useMemo)(()=>{let e=new Map((i??[]).map((e,t)=>[e,t]));return n.map((e,t)=>({plugin:e,index:t})).sort((t,n)=>(e.get(t.plugin.id)??1e6+t.index)-(e.get(n.plugin.id)??1e6+n.index)).map(({plugin:e})=>e)},[n,i]);(0,g.useLayoutEffect)(()=>{p()},[y,p]);let b=(e,t)=>{let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=r+t;if(r<0||i<0||i>=n.length)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))},x=(e,t)=>{if(!e||e===t)return;let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=n.indexOf(t);if(r<0||i<0)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))};return(0,j.createPortal)((0,X.jsxs)(`div`,{ref:d,className:`pm-panel`,role:`menu`,"aria-label":u(`pluginMenuTitle`),style:f,children:[(0,X.jsxs)(`div`,{className:`pm-head`,"aria-hidden":`true`,children:[(0,X.jsx)(ht,{className:`pm-head-icon`,"aria-hidden":!0}),u(`pluginMenuTitle`)]}),(0,X.jsx)(`div`,{className:`pm-list`,children:n.length===0?(0,X.jsx)(`div`,{className:`pm-empty`,children:u(`pluginMenuEmpty`)}):y.map(e=>{let t=e.view===!1||!!e.error,n=!t&&r.has(e.id),i=e.error??(e.view===!1?u(`pluginMenuNoView`):void 0),o=e.iconSvg?void 0:e.icon&&!/[a-z]/i.test(e.icon)?e.icon:void 0;return(0,X.jsxs)(`div`,{className:`pm-row${_===e.id?` drop-target`:``}`,role:`none`,onDragOver:n=>{!t&&h.current&&(n.preventDefault(),v(e.id))},onDrop:t=>{t.preventDefault(),x(t.dataTransfer.getData(`text/plain`)||h.current,e.id),h.current=null,m(null),v(null)},children:[!t&&(0,X.jsx)(`button`,{type:`button`,className:`pm-drag`,draggable:!0,"aria-label":u(`pluginMenuReorder`),title:u(`pluginMenuReorderHint`),onDragStart:t=>{m(e.id),h.current=e.id,t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id);let n=document.createElement(`div`);n.style.cssText=`position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0`,document.body.appendChild(n),t.dataTransfer.setDragImage(n,0,0),requestAnimationFrame(()=>n.remove())},onDragEnd:()=>{h.current=null,m(null),v(null)},onKeyDown:t=>{(t.key===`ArrowUp`||t.key===`ArrowDown`)&&(t.preventDefault(),b(e.id,t.key===`ArrowUp`?-1:1))},children:(0,X.jsx)(Se,{"aria-hidden":!0})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-row-main`,disabled:t,title:i,onClick:()=>s(e.id),children:[o||e.iconSvg?(0,X.jsx)(hi,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(ht,{className:`pm-icon`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`pm-name`,children:e.name}),i&&(0,X.jsx)(`span`,{className:`pm-sub`,children:i})]}),!t&&(0,X.jsx)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":n,"aria-label":u(n?`pluginMenuUnpin`:`pluginMenuPin`),className:`pm-pin${n?` on`:``}`,onClick:()=>a(e.id,!n),children:n?(0,X.jsx)(wo,{"aria-hidden":!0}):(0,X.jsx)(Co,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(ue,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function Oo({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=Nn(),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``);async function d(){try{let e=await fetch(gn(fn(`/api/locales`)));if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();o(t.packs??[]),c(``)}catch(e){c(t(`localeListFailed`,{error:e instanceof Error?e.message:String(e)}))}}(0,g.useEffect)(()=>{d()},[]);async function f(e){u(e),c(``);try{let t=await fetch(gn(fn(`/api/locales/${e}/install`)),{method:`POST`});if(!t.ok){let e=`HTTP ${t.status}`;try{e=(await t.json()).error??e}catch{}throw Error(e)}await i(),await d()}catch(e){c(t(`localeInstallFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(``)}}async function p(e){u(e),c(``);try{let t=await fetch(gn(fn(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);Tn(e),n===e&&r(`zh`),await i(),await d()}catch(e){c(t(`localeInstallFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(``)}}return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:e,children:(0,X.jsxs)(`div`,{className:`bg-task-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`bg-task-head`,children:[(0,X.jsxs)(`span`,{className:`bg-task-title`,children:[(0,X.jsx)(Fe,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(P,{})})]}),s&&(0,X.jsx)(`div`,{className:`bg-task-empty`,children:s}),a===null&&!s?(0,X.jsx)(`div`,{className:`bg-task-empty`,children:t(`loading`)}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:(a??[]).map(e=>{let n=l===e.code;return(0,X.jsxs)(`li`,{className:`bg-task-item`,children:[(0,X.jsxs)(`div`,{className:`bg-task-info`,children:[(0,X.jsxs)(`div`,{className:`bg-task-line1`,children:[(0,X.jsx)(`span`,{className:`bg-task-port`,children:e.nativeName}),e.installed&&e.version&&(0,X.jsxs)(`span`,{className:`bg-task-name`,children:[`v`,e.version]})]}),(0,X.jsxs)(`div`,{className:`bg-task-line2`,children:[(0,X.jsx)(`span`,{children:e.code}),e.installed?(0,X.jsxs)(`span`,{children:[t(`localeInstalled`),` · `,t(`localeRemoveHint`)]}):(0,X.jsx)(`span`,{children:t(`localeGetMore`)})]})]}),e.installed?(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,disabled:n,title:t(`localeRemove`),onClick:()=>void p(e.code),children:[(0,X.jsx)(L,{}),(0,X.jsx)(`span`,{children:t(n?`localeRemoving`:`localeRemove`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:n,title:t(`localeInstall`),onClick:()=>void f(e.code),children:[(0,X.jsx)(qe,{}),(0,X.jsx)(`span`,{children:t(n?`localeDownloading`:`localeInstall`)})]})]},e.code)})}),(0,X.jsx)(`div`,{className:`bg-task-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`bgTaskRefresh`),onClick:()=>void d(),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:t(`bgTaskRefresh`)})]})})]})})}var ko=`xing-shuyin/pi-web-ui`,Ao={state:`idle`,version:null,percent:0,message:null};function jo(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Mo(e,t){switch(t.state){case`checking`:return{...e,state:`checking`,message:null};case`available`:return{...e,state:`available`,version:t.version??e.version,message:null};case`up-to-date`:return{...e,state:`up-to-date`,version:t.version??e.version,message:null};case`downloading`:return{...e,state:`downloading`,percent:jo(t.percent),message:null};case`downloaded`:return{...e,state:`downloaded`,version:t.version??e.version,percent:100,message:null};case`error`:return{...e,state:`error`,message:t.message??`unknown error`};default:return e}}function No(e){if(!Rn(e))return null;let t=(e??(typeof window>`u`?void 0:window))?.piDesktop?.updater;return!t||typeof t.check!=`function`||typeof t.download!=`function`?null:t}function Po(e){return e instanceof Error?e.message:String(e)}function Fo(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${ko}/releases/tag/v${t}`:`https://github.com/${ko}/releases/latest`}function Io(){let[e]=(0,g.useState)(()=>No()),[t,n]=(0,g.useState)(Ao);(0,g.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>Mo(t,e)))},[e]);let r=(0,g.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:Po(e)}))))},[e]),i=(0,g.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:Po(e)}))))},[e]),a=(0,g.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:Po(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}function Lo(e){let t=Math.max(0,e.input??0),n=Math.max(0,e.cacheRead??0),r=Math.max(0,e.cacheWrite??0),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0,writeRate:i>0?Math.min(r/i,1):0}}var Ro=2e3;function zo(e,t,n=Ro){return e.filter(e=>t-e.t<=n)}function Bo(e,t=Ro){if(e.length<2)return 0;let n=e[e.length-1],r=e.find(e=>e.t>=n.t-t)??e[0],i=(n.t-r.t)/1e3;return i<=0?0:Math.max(0,(n.out-r.out)/i)}function Vo(e){if(!e)return 0;let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r>=12352&&r<=12543||r>=13312&&r<=19903||r>=19968&&r<=40959||r>=63744&&r<=64255||r>=65280&&r<=65519||r===12288)&&t++}let n=e.length-t;return Math.round(t+n/4)}function Ho(e){let t=0;for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text?t+=Vo(n.text):n.type===`thinking`&&typeof n.thinking==`string`&&n.thinking&&(t+=Vo(n.thinking));return t}function Uo(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(e)}function Wo(e){return e.startsWith(`zh`)?`ZH`:e.startsWith(`ja`)?`JA`:e.startsWith(`ko`)?`KO`:e.startsWith(`fr`)?`FR`:e.startsWith(`de`)?`DE`:e.startsWith(`es`)?`ES`:e.startsWith(`ru`)?`RU`:e.startsWith(`pt`)?`PT`:e.startsWith(`it`)?`IT`:`EN`}function Go({entry:e,bar:t,chat:n,view:r,plugins:i,onViewChange:a,onOpenPanel:o,onOpenSettings:s,onOpenGlobalSearch:c,onOpenBgTasks:l,onOpenProjectPicker:u,onOpenPluginMenu:d,isPluginMenuOpen:f,isProjectPickerOpen:p,onUiAction:m,uiContextEntries:h,dropdownProps:_}){let v=Z(),{locale:y,packs:b,setLocale:x}=Nn(),{engine:S}=Xa(),C=S===`dsh`,[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(!1),[A,j]=(0,g.useState)(!1),ee=n.settings?.uiLayout,M=n.state,te=M?.stats,N=M?.isStreaming??!1,P=ki(te?.cost??0),F=(0,g.useRef)([]),re=M?.streamingMessage?Ho(M.streamingMessage.content):0;(0,g.useEffect)(()=>{if(!N){F.current=[];return}let e=Date.now(),t=F.current,n=t[t.length-1];n&&e-n.t<250||(F.current=zo([...t,{t:e,out:re}],e))},[N,re]);let ie=N?Bo(F.current):0,ae=n=>{n.preventDefault(),n.stopPropagation();let r=t=>{let n={...ee?.slots,[e.id]:t};$({type:`set_settings`,uiLayout:{...ee,slots:n}})},i=()=>{let t=new Set(ee?.hidden??[]);t.add(e.id),$({type:`set_settings`,uiLayout:{...ee,hidden:[...t]}})},a=[];t!==`top`&&a.push({id:`host:move-top`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToTop`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`bottom`&&a.push({id:`host:move-bottom`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToBottom`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`left`&&a.push({id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToLeft`),kind:`action`,order:30,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`right`&&a.push({id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToRight`),kind:`action`,order:40,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),a.push({id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:v(`uiLayoutRestore`),kind:`action`,order:50,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),h&&h.length>0&&a.push(...h),Ea({x:n.clientX,y:n.clientY,slot:`contextmenu.topbar`,target:{id:e.id,label:e.label},entries:a,onHostAction:e=>{e.id===`host:move-top`?r(`topbar.primary`):e.id===`host:move-bottom`?r(`bottombar`):e.id===`host:move-left`?r(`sidebar.left`):e.id===`host:move-right`?r(`sidebar.right`):e.id===`host:hide-item`&&i()}})},I=e.id,L=e.labelExplicit?e.label:``,R=e=>L||e,oe=e=>L?`${L} ${e}`:e;if(e.kind===`select`&&e.options?.length){let t=e.options.some(t=>t.value===e.value)?e.value:e.options[0].value;return(0,X.jsx)(`select`,{className:`bar-item bar-item-select`,title:e.hint??e.label,"data-tip":e.hint??e.label,"aria-label":e.label,value:t,onChange:t=>m?.(e,t.target.value),onContextMenu:ae,"data-bar-item":I,children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})}if(I===`host:brand`)return(0,X.jsxs)(`span`,{className:`bar-item brand bar-item-brand`,title:v(`brand`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`brand-logo bar-item-brand-logo`,children:`π`}),(0,X.jsx)(`span`,{className:`brand-name bar-item-text`,children:R(`pi-web-ui`)})]});if(I===`host:conn`){let e=n.ready?`ok`:n.status===`closed`?`error`:`busy`,t=n.ready?v(`connected`):n.status===`closed`?v(`reconnecting`):v(`connecting`);return(0,X.jsxs)(`span`,{className:`bar-item status-item status-conn ${e} bar-item-conn`,title:t,"data-tip":t,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`status-dot ${e}`}),(0,X.jsx)(`span`,{className:`status-conn-label bar-item-text`,children:oe(t)})]})}if(I===`host:engine`)return S===`pi`?null:(0,X.jsx)(`span`,{className:`bar-item status-item engine-badge engine-${S} bar-item-engine`,title:`${v(`engineBadge`)}: ${S}`,"data-tip":`${v(`engineBadge`)}: ${S}`,onContextMenu:ae,"data-bar-item":I,children:oe(S===`dsh`?`DSH`:S)});if(I===`host:ctx`){let e=te?.contextUsage,t=e?.softCap??null,n=t!==null&&t>0&&t<(e?.contextWindow??0),r=n?t:e?.contextWindow??0,i=e?.tokens!==null&&e?.tokens!==void 0&&r>0?Math.min(100,Math.round(e.tokens/r*100)):null,a=e?.tokens!==null&&e?.tokens!==void 0?Uo(e.tokens):null,o=r>0?Uo(r):null,s=a!==null&&o!==null&&i!==null?`${a} / ${o}`:`—`,c=i===null?``:i>=80?`warn`:i>=50?`mid`:`ok`,l=n?`${v(`contextUsage`)}: ${Uo(e?.tokens??0)} / ${Uo(t)} (${v(`softCapMarker`)}, max ${Uo(e?.contextWindow??0)})`:t!==null&&t>0?`${v(`contextUsage`)}: ${s} · ${v(`softCapMarker`)}: ${Uo(t)}`:`${v(`contextUsage`)}: ${s}`,u=i!==null&&i>0?+(31.42*(1-Math.min(i,100)/100)).toFixed(2):31.42;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-ctx bar-item-ctx`,title:l,"data-tip":l,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsxs)(`svg`,{className:`ctx-ring ${c}`,viewBox:`0 0 14 14`,width:`13`,height:`13`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,X.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:31.42,strokeDashoffset:u,"data-percent":i})]}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[L?`${L} `:``,a!==null&&o!==null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`ctx-val`,children:a}),(0,X.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,X.jsx)(`span`,{className:`ctx-max`,children:o})]}):s]})]})}if(I===`host:cache`){let e=Lo(te?.tokens??{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}),t=e.hitRate*100,n=e.totalInput===0?``:e.hitRate>=.7?`ok`:e.hitRate>=.4?`mid`:`warn`,r=e.totalInput>0?`${t.toFixed(1)}%`:`—`,i=v(`cacheHitTip`,{read:Uo(e.read),write:Uo(e.write),miss:Uo(e.miss),input:Uo(e.totalInput)}),a=e.totalInput>0?`${v(`cacheHit`)}: ${r} · ${i}`:v(`cacheHit`),o=e.totalInput===0;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-cache bar-item-cache${o?` is-zero`:``}`,title:a,"data-tip":a,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(Ye,{className:`bar-item-icon`}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[L?`${L} `:``,(0,X.jsx)(`b`,{className:`cache-pct ${n}`,children:r})]})]})}if(I===`host:cost`){let e=te?.cost??0,t=P.tooltip||v(`cumulativeCost`);return(0,X.jsxs)(`span`,{className:`bar-item status-item status-cost bar-item-cost${e<=0?` is-zero`:``}${L?` has-name`:``}`,title:t,"data-tip":t,onContextMenu:ae,"data-bar-item":I,children:[L?(0,X.jsx)(`span`,{className:`bar-item-text`,children:L}):null,P.symbol?(0,X.jsx)(`span`,{className:`bar-item-char`,children:P.symbol}):null,(0,X.jsx)(`span`,{className:`bar-item-text`,children:P.value})]})}if(I===`host:msg-count`){let e=te?.totalMessages??0,t=`${v(`sessionMessages`)}: ${e}`;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-msg-count bar-item-msg-count${e===0?` is-zero`:``}`,title:t,"data-tip":t,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(J,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:oe(String(e))})]})}if(I===`host:working`){if(!N)return null;let e=(M?.queue?.steering?.length??0)+(M?.queue?.followUp?.length??0);return(0,X.jsxs)(`span`,{className:`bar-item status-item working bar-item-working`,title:v(`working`),"data-tip":v(`working`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`working-spin`}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[R(v(`working`)),e>0&&` ⏳ ${e}`]}),(0,X.jsx)(`span`,{className:`status-rate bar-item-rate`,title:v(`rateTip`),children:ie>0?`${Math.round(ie)}${v(`tps`)}`:`…`})]})}if(I===`host:status-delegate`)return M?.delegateMode?(0,X.jsxs)(`span`,{className:`bar-item status-item delegate-badge bar-item-delegate`,title:M.delegateConvId?v(`delegateModeOpenTip`):v(`delegateModeBadgeTip`),"data-tip":M.delegateConvId?v(`delegateModeOpenTip`):v(`delegateModeBadgeTip`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`bar-item-icon`,children:`🔎`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:R(v(`delegateModeBadge`))}),M.delegateConvId?(0,X.jsx)(`button`,{type:`button`,className:`delegate-badge-open`,title:v(`delegateModeOpenTip`),onClick:()=>$({type:`switch_conversation`,id:M.delegateConvId}),children:`↗`}):null]}):null;if(I===`host:host-metrics`){let e=n.hostMetrics;if(!e)return null;let t=e.cpuPercent===null||!Number.isFinite(e.cpuPercent)?`—`:`${Math.round(e.cpuPercent)}%`,r=Number.isFinite(e.memoryPercent)?`${Math.round(e.memoryPercent)}%`:`—`;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-host-metrics bar-item-host-metrics`,title:`${v(`hostResourcesTip`)}\n${v(`hostProcessor`)}: ${t} · ${v(`hostMemory`)}: ${r}`,"data-tip":`${v(`hostResourcesTip`)}\n${v(`hostProcessor`)}: ${t} · ${v(`hostMemory`)}: ${r}`,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(Ze,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:oe(`${t} · ${r}`)})]})}if(I===`host:browser`)return n.settings?.disabledAgentTools?.includes(`browser_page`)?null:(0,X.jsx)(`span`,{className:`bar-item-wrap`,onContextMenu:ae,"data-bar-item":I,children:(0,X.jsx)(ur,{})});if(I===`host:sound`)return(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:w,onOpenChange:T,tip:R(v(`sound`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`sound`)),"data-tip":R(v(`sound`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(ne,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:R(v(`sound`))})]}),children:[_?.sound&&_?.onSoundChange?(0,X.jsx)(Fn,{settings:_.sound,onChange:_.onSoundChange,onPreview:_.onSoundPreview??(()=>{})}):null,(0,X.jsx)(si,{})]});if(I===`host:language`)return(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:E,onOpenChange:D,tip:R(v(`language`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`language`)),"data-tip":R(v(`language`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(Fe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:oe(Wo(y))})]}),children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`language`)}),b.map(e=>(0,X.jsx)(Ht,{active:y===e.code,onClick:()=>{x(e.code),D(!1)},children:e.nativeName},e.code)),_?.onLocaleModalOpen?(0,X.jsxs)(Ht,{onClick:()=>{D(!1),_.onLocaleModalOpen?.()},children:[(0,X.jsx)(qe,{}),` `,v(`localeGetMore`)]}):null]});if(I===`host:theme`){let e=_?.themes??[],n=_?.theme??null;return(0,X.jsx)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:O,onOpenChange:t=>{k(t),t&&e.length===0&&_?.reloadThemes?.()},tip:R(v(`theme`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`theme`)),"data-tip":R(v(`theme`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(B,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:R(v(`theme`))})]}),children:(()=>{let t=e.filter(e=>e.group===`classic`),r=e.filter(e=>e.group!==`classic`),i=e=>{let t=y===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?v(`themeLight`):e.scheme===`dark`?v(`themeDark`):``;return n?y===`zh`?`${t}(${n})`:`${t} (${n})`:t};return(0,X.jsxs)(X.Fragment,{children:[t.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`themeGroupClassics`)}),t.map(e=>(0,X.jsx)(Ht,{active:n===e.id,onClick:()=>{_?.onThemeChange?.(e.id),k(!1)},children:i(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:t.length>0?v(`themeGroupBuiltin`):v(`theme`)}),(0,X.jsx)(Ht,{active:n===null,onClick:()=>{_?.onThemeChange?.(null),k(!1)},children:v(`themeDefault`)}),r.map(e=>(0,X.jsx)(Ht,{active:n===e.id,onClick:()=>{_?.onThemeChange?.(e.id),k(!1)},children:i(e)},e.id))]})})()})}if(I===`host:update`){let e=_?.updatesCount??0;return _?.managed?(0,X.jsxs)(`span`,{className:`bar-item chip`,title:v(`updatesManaged`),"data-tip":v(`updatesManaged`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(qe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:oe(`v${_?.appVersion??n.update?.current??`…`}`)})]}):(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:A,onOpenChange:e=>{j(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},tip:R(v(`update`)),fit:!0,caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`update`)),"data-tip":R(v(`update`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(qe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:oe(`v${n.update?.current??`…`}`)}),n.update&&!n.update.upToDate&&(0,X.jsx)(`span`,{className:`update-dot`}),e>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:e})]}),children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`update`)}),_?.renderUpdateBody?.(),_?.renderAllUpdatesBody?.()]})}let V=null,H=e.label,se=null,ce=!1,le=!1,U=``,de,W;switch(I){case`host:chat`:V=(0,X.jsx)(J,{className:`bar-item-icon`}),H=R(v(`chat`)),ce=r===`chat`,le=!0,W=()=>a?.(`chat`);break;case`host:terminal`:V=(0,X.jsx)(z,{className:`bar-item-icon`}),H=R(v(`terminal`)),ce=r===`terminal`,le=!0,W=()=>a?.(`terminal`);break;case`host:git`:V=(0,X.jsx)(Le,{className:`bar-item-icon`}),H=R(v(`scmTab`)),ce=r===`git`,le=!0,W=()=>a?.(`git`);break;case`host:new-chat`:V=(0,X.jsx)(me,{className:`bar-item-icon`}),H=R(v(`newChat`)),U=`chip newchat`,W=()=>{a?.(`chat`),$({type:`new_chat`}),sr()};break;case`host:new-ephemeral-chat`:if(C)return null;V=(0,X.jsx)(Ot,{className:`bar-item-icon`}),H=R(v(`newChatEphemeral`)),U=`chip newchat ephemeral-chat-btn`,W=()=>{a?.(`chat`),$({type:`new_chat`,ephemeral:!0}),sr()};break;case`host:history`:if(r&&r!==`chat`)return null;V=(0,X.jsx)(Se,{className:`bar-item-icon`}),H=R(v(`openHistory`)),U=`panel-toggle`,W=()=>o?.(`left`);break;case`host:files`:if(r&&r!==`chat`)return null;V=(0,X.jsx)(Re,{className:`bar-item-icon`}),H=R(v(`openFiles`)),U=`panel-toggle has-label`,W=()=>o?.(`right`);break;case`host:open-project`:V=(0,X.jsx)(ze,{className:`bar-item-icon`}),H=R(v(`openProject`)),U=`chip open-project`,ce=!!p,W=()=>u?.();break;case`host:search`:V=(0,X.jsx)(fe,{className:`bar-item-icon`}),H=R(v(`searchGlobal`)),U=`chip`,W=()=>c?.();break;case`host:tasks`:V=(0,X.jsx)(ke,{className:`bar-item-icon`}),H=R(v(`bgTasks`)),U=`chip bg-task-chip`,n.bgServers.length>0&&(se=(0,X.jsx)(`span`,{className:`bg-task-badge bar-item-badge`,children:n.bgServers.length})),W=()=>l?.();break;case`host:settings`:V=(0,X.jsx)(ue,{className:`bar-item-icon`}),H=R(v(`settings`)),U=`chip`,W=()=>s?.();break;case`host:plugins`:V=(0,X.jsx)(ht,{className:`bar-item-icon`}),H=R(v(`pluginMenuTitle`)),U=`chip`,W=e=>{d?d(e.currentTarget):s?.(`plugins`)};break;case`host:github`:V=(0,X.jsx)(Ie,{className:`bar-item-icon`}),H=R(`GitHub`),U=`chip github`,W=()=>window.open(`https://github.com/xing-shuyin/pi-web-ui`,`_blank`,`noreferrer,noopener`);break;case`host:cwd`:V=(0,X.jsx)(Re,{className:`bar-item-icon`}),H=oe(M?.cwd?M.cwd.split(/[/\\]/).pop()||M.cwd:v(`openProject`)),U=`status-item status-cwd`,ce=!!p,W=()=>u?.();break;case`host:plugin-status`:if(n.statuses.length===0)return null;V=(0,X.jsx)(Et,{className:`bar-item-icon`}),H=oe(n.statuses.map(e=>e.text).join(` · `)),U=`status-item ext-status`;break;default:if(e.kind===`view`){let t=e.view??``;ce=r===t,le=!0;let o=(i??n.plugins??[]).find(t=>`plugin:${t.id}`===e.source);U=`plugin-tab${o?.error?` broken`:``}`,o?.error&&(de=`${e.label}: ${o.error}`);let s=e.iconSvg||o?.iconSvg,c=e.icon||o?.icon;V=s?(0,X.jsx)(hi,{icon:c,iconSvg:s,className:`bar-item-icon plugin-icon-svg`}):c?(0,X.jsx)(`span`,{className:`bar-item-icon bar-item-glyph`,children:c}):null,W=()=>a?.(t)}else{let n=e.iconSvg,r=e.icon;U=t===`bottom`?`status-item status-action chip`:`chip`,V=n?(0,X.jsx)(hi,{icon:r,iconSvg:n,className:`bar-item-icon plugin-icon-svg`}):r?(0,X.jsx)(`span`,{className:`bar-item-icon bar-item-glyph`,children:r}):null,e.badge&&(se=(0,X.jsx)(`span`,{className:`bar-item-badge`,children:e.badge})),W=()=>m?.(e)}}let pe=de??e.hint??H,G=[`bar-item`,le?`tb-tab${ce?` active`:``}`:``,U,ce&&!le?`active`:``].filter(Boolean).join(` `);return(0,X.jsxs)(`button`,{type:`button`,role:le?`tab`:void 0,"aria-selected":le?ce:void 0,"aria-haspopup":I===`host:plugins`?`menu`:void 0,"aria-expanded":I===`host:plugins`?!!f:void 0,className:G,title:pe,"data-tip":pe,"aria-label":H,onClick:W,onContextMenu:ae,"data-bar-item":I,children:[V,(0,X.jsx)(`span`,{className:`bar-item-text`,children:H}),se]})}var Ko={name:`@earendil-works/pi-coding-agent`,kind:`pi-core`,current:``,latest:null,upToDate:!1};function qo({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=Eo({open:t,anchor:e,onClose:n});return(0,g.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,j.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Jo(){let[e,t]=(0,g.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,g.useEffect)(()=>{if(typeof window>`u`||window.matchMedia===void 0)return;let e=window.matchMedia(`(max-width: 768px)`),n=e=>t(e.matches);return typeof e.addEventListener==`function`?e.addEventListener(`change`,n):e.addListener(n),()=>{typeof e.removeEventListener==`function`?e.removeEventListener(`change`,n):e.removeListener(n)}},[]),e}function Yo({chat:e,terminal:t,view:n,plugins:r,uiPrimary:i,uiOverflow:a,uiContextTopbar:o,onUiAction:s,onViewChange:c,onOpenPanel:l,onOpenSettings:u,onManagePlugins:d,onOpenBgTasks:f,onOpenGlobalSearch:p,sound:m,onSoundChange:h,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x,onOpenIconEdit:S}){let{locale:C,setLocale:w,t:T,packs:E}=Nn(),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(!1),[j,ee]=(0,g.useState)(null),M=Za(`cwd`),te=Za(`workspaceRoots`),N=Qa(),P=(0,g.useRef)(null),F=t=>!e.tabs||t===`chat`||e.tabs.includes(t),re=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!Xi(e)),ie=new Set([...i??[],...a??[]].filter(e=>Xi(e)&&!e.hidden).map(e=>e.source.slice(7))),ae=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),I=r.map((e,t)=>({id:e.id,index:t})).sort((e,t)=>(ae.get(`${e.id}:__view`)??1e6+e.index)-(ae.get(`${t.id}:__view`)??1e6+t.index)).map(e=>e.id),L=i===void 0?[`host:history`,`host:brand`,`host:open-project`,`host:chat`,`host:terminal`,`host:git`,`host:plugins`,`host:search`,`host:browser`,`host:tasks`,`host:settings`,`host:sound`,`host:language`,`host:theme`,`host:update`,`host:github`,`host:new-chat`,`host:new-ephemeral-chat`,`host:files`].map(e=>({id:e,entry:null})):i.map(e=>({id:e.id,entry:e})),R=(F(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!L.some(t=>t.id===`${e.id}:__view`)).map(e=>({id:`${e.id}:__view`,slot:`topbar.primary`,source:`plugin:${e.id}`,label:e.name,kind:`view`,view:`plugin:${e.id}`,order:23,align:`end`,hidden:!1,userOverrides:[],arrangedBy:[]})),oe=e=>{if(e.source!==`host`)return!1;switch(e.id){case`host:history`:return l(`left`),!0;case`host:files`:return l(`right`),!0;case`host:new-chat`:return c(`chat`),$({type:`new_chat`}),sr(),!0;case`host:new-ephemeral-chat`:return c(`chat`),$({type:`new_chat`,ephemeral:!0}),sr(),!0;case`host:open-project`:return A(!0),!0;case`host:search`:return p(),!0;case`host:tasks`:return f(),!0;case`host:settings`:return u(),!0;case`host:plugins`:return ee(P.current?{rect:P.current.getBoundingClientRect(),el:P.current}:null),!0;default:return!1}},V=(t,n,r)=>{t.preventDefault(),t.stopPropagation();let i=e.settings?.uiLayout,a=e=>{let t={...i?.slots,[n]:e};$({type:`set_settings`,uiLayout:{...i,slots:t}})},s=()=>{let e=new Set(i?.hidden??[]);e.add(n),$({type:`set_settings`,uiLayout:{...i,hidden:[...e]}})},c=[{id:`host:move-bottom`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToBottom`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToLeft`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToRight`),kind:`action`,order:30,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:T(`uiLayoutRestore`),kind:`action`,order:40,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},...o??[]];Ea({x:t.clientX,y:t.clientY,slot:`contextmenu.topbar`,target:{id:n,label:r},entries:c,onHostAction:e=>{e.id===`host:move-bottom`?a(`bottombar`):e.id===`host:move-left`?a(`sidebar.left`):e.id===`host:move-right`?a(`sidebar.right`):e.id===`host:hide-item`&&s()}})},{appVersion:H}=Xa(),se=$a(),ce=eo(),[le,U]=(0,g.useState)(!1);(0,g.useEffect)(()=>{le&&e.status===`open`&&U(!1)},[le,e.status]);let[de,W]=(0,g.useState)(!1),[pe,G]=(0,g.useState)(!1),[K,he]=(0,g.useState)(!1),[ge,q]=(0,g.useState)(!1),_e=Rn(),ve=Io(),[ye,be]=(0,g.useState)(!1),xe=()=>{if(!e.ready)return;let n=T(`updateTabTitle`),r={name:n,command:`npm i -g pi-web-ui@latest`,cwd:"${pwd}"},i=e.terminals.find(e=>e.title===n);i?(t.restart(i.id),$({type:`run_command`,terminalId:i.id,conversationId:i.conversationId,command:r,cols:80,rows:24})):t.create({id:jt(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r}),q(!1),c(`terminal`)},Ce=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:kt(n),cwd:"${pwd}"},a=e.terminals.find(e=>e.title===r);a?(t.restart(a.id),$({type:`run_command`,terminalId:a.id,conversationId:a.conversationId,command:i,cols:80,rows:24})):t.create({id:jt(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:r,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:i}),q(!1),c(`terminal`)},we=e.updatesAll??[],Te=e.updatesSdk,Ee=Te&&Te.newerInstalled?{running:Te.running,installed:Te.newerInstalled}:null,De=Te?.bundledInUse===!0,Oe=we.find(e=>e.kind===`pi-core`&&!e.error),Ae=De&&(!Oe||!Oe.upToDate),je=Ae&&!Oe,Me=we.filter(e=>!e.upToDate&&!e.error).length,Ne=we.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Pe=e=>e.kind===`git-extension`&&e.source?e.source:e.name,Be=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,Ve=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},He=(e,t)=>{if(!t)return Ve(e);let n=Ve(e),r=Ve(t);return n===r?n:`${n} → ${r}`},Ue=()=>(0,X.jsxs)(`div`,{className:`dd-updates-all`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`updatesAllTitle`)}),e.updatesAll===null?(0,X.jsx)(`div`,{className:`dd-note`,children:T(`checkingUpdate`)}):we.length===0?(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updatesAllUpToDate`)}):(0,X.jsx)(`ul`,{className:`dd-all-list`,children:we.map(e=>{let t=Ee!=null&&e.kind===`pi-core`,n=!e.error&&(!e.upToDate||t);return(0,X.jsxs)(`li`,{className:`dd-all-item${e.error?` err`:n?` warn`:``}`,children:[e.kind!==`webui`&&!e.upToDate&&!e.error&&(0,X.jsx)(`button`,{type:`button`,className:`dd-update-btn`,onClick:()=>Ce([e],T(`updatePkgTabTitle`,{name:e.name})),children:T(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:Be(e),children:Pe(e)}),(0,X.jsxs)(`span`,{className:`dd-all-meta`,children:[(0,X.jsx)(`span`,{className:`dd-all-kind`,children:e.kind===`webui`?T(`kindWebUi`):e.kind===`pi-core`?T(`kindPiCore`):e.kind===`git-extension`?T(`kindGitExtension`):e.kind===`plugin`?T(`kindPlugin`):T(`kindPackage`)}),(0,X.jsx)(`span`,{className:`dd-all-vers`,title:e.error?e.error:e.kind===`git-extension`?e.upToDate?e.current:`${e.current} → ${e.latest}`:void 0,children:e.error?T(`updateCheckFailed`):e.kind===`git-extension`?e.upToDate?Ve(e.current):He(e.current,e.latest):e.kind===`plugin`?e.upToDate?e.current.startsWith(`v`)?e.current:Ve(e.current):He(e.current,e.latest):e.upToDate?`v${e.current}`:(0,X.jsxs)(X.Fragment,{children:[`v`,e.current,` → v`,e.latest]})}),t&&!e.error&&(0,X.jsx)(`span`,{className:`dd-split-run`,children:T(`piCoreSplitRun`,{running:Ee.running})})]})]},`${e.kind}:${e.name}`)})}),Ee&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`piSdkSplitNote`,{running:Ee.running,installed:Ee.installed})}),Ae&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`piSdkBundledNote`,{running:Te.running})}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[je&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce([Ko],T(`installGlobalEngineTabTitle`)),children:T(`installGlobalEngineBtn`)}),Ne.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce(Ne,T(`updateAllTabTitle`)),children:T(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:Ne.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:T(`updatesAllRefresh`)})]})]}),We=()=>{let t=Fo(e.update?.latest??ve.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:T(`updateDesktopManual`)});if(!ve.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopNoBridge`)}),n]});switch(ve.state){case`checking`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopChecking`)}),n]});case`available`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopAvailable`,{version:ve.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.download(),children:T(`updateDesktopDownload`)}),n]});case`downloading`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopDownloading`,{n:ve.percent})}),n]});case`downloaded`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`updateDesktopDownloaded`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.quitAndInstall(),children:T(`updateDesktopInstall`)}),n]});case`up-to-date`:return(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`upToDate`)});case`error`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopError`,{error:ve.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>ve.check(),children:T(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.check(),children:T(`updateDesktopCheck`)}),n]})}},Ge=()=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`dd-update`,children:[(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:T(`currentVersion`)}),(0,X.jsxs)(`b`,{children:[`v`,e.update?.current??`…`]})]}),(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:T(`latestVersion`)}),(0,X.jsx)(`b`,{children:e.update===null?T(`checkingUpdate`):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:T(`checkingUpdate`)})]}),e.update&&e.update.upToDate&&(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`upToDate`)}),e.update&&!e.update.upToDate&&e.update.latest&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateAvailable`,{version:e.update.latest})}),e.update?.latestPublishedAt&&Date.now()-new Date(e.update.latestPublishedAt).getTime()<18e5&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateJustPublished`,{version:e.update.latest??``})}),e.update&&!e.update.upToDate&&e.update.latest&&!_e&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&_e&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopNote`)})]}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`check_update`}),children:e.update===null?T(`checkingUpdate`):T(`checkUpdate`)}),e.update&&!e.update.upToDate&&e.update.latest&&!_e&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:xe,children:T(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&_e&&We(),ce&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:le,title:T(`restartServiceTip`,{name:ce.name}),onClick:()=>{le||(U(!0),$({type:`restart_service`}))},children:T(le?`restartingService`:`restartService`)})]})]}),Y=Jo(),Je={"host:brand":(0,X.jsxs)(`span`,{className:`brand`,children:[(0,X.jsx)(`span`,{className:`brand-logo`,children:`π`}),(0,X.jsx)(`span`,{className:`brand-name`,children:`pi-web-ui`})]}),"host:open-project":(0,X.jsxs)(`button`,{type:`button`,className:`chip open-project`,"data-tip":T(`openProject`),onClick:()=>A(!0),children:[(0,X.jsx)(ze,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`openProject`)})]}),"host:history":n===`chat`&&F(`history`)?(0,X.jsx)(`button`,{type:`button`,className:`panel-toggle`,"data-tip":T(`openHistory`),"aria-label":T(`openHistory`),onClick:()=>l(`left`),children:(0,X.jsx)(Se,{})}):null,"host:files":n===`chat`&&F(`files`)?(0,X.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label`,"data-tip":T(`openFiles`),"aria-label":T(`openFiles`),onClick:()=>l(`right`),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{children:T(`openFiles`)})]}):null,"host:new-chat":F(`new-chat`)?(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat`,"data-tip":T(`newChatTip`),onClick:()=>{c(`chat`),$({type:`new_chat`}),sr()},children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:T(`newChat`)})]}):null,"host:new-ephemeral-chat":N?null:(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat ephemeral-chat-btn`,"data-tip":T(`newChatEphemeralTip`),onClick:()=>{c(`chat`),$({type:`new_chat`,ephemeral:!0}),sr()},children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(`span`,{children:T(`newChatEphemeral`)})]}),"host:chat":(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`chat`,className:`tb-tab${n===`chat`?` active`:``}`,"data-tip":T(`chat`),onClick:()=>c(`chat`),children:[(0,X.jsx)(J,{}),(0,X.jsx)(`span`,{children:T(`chat`)})]}),"host:terminal":F(`terminal`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`terminal`,className:`tb-tab${n===`terminal`?` active`:``}`,"data-tip":T(`terminal`),onClick:()=>c(`terminal`),children:[(0,X.jsx)(z,{}),(0,X.jsx)(`span`,{children:T(`terminal`)})]}):null,"host:git":F(`git`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`git`,className:`tb-tab${n===`git`?` active`:``}`,"data-tip":T(`scmTab`),onClick:()=>c(`git`),children:[(0,X.jsx)(Le,{}),(0,X.jsx)(`span`,{children:T(`scmTab`)})]}):null,"host:plugins":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`pluginMenuTitle`),"aria-haspopup":`menu`,"aria-expanded":j!==null,onClick:e=>{let t=e.currentTarget;ee(e=>e?.el===t?null:{rect:t.getBoundingClientRect(),el:t})},children:[(0,X.jsx)(ht,{"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`pluginMenuTitle`)})]}),"host:search":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`searchGlobalTip`),onClick:p,children:[(0,X.jsx)(fe,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(ur,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":T(`bgTasksTip`),onClick:f,children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`bgTasks`)}),e.bgServers.length>0&&(0,X.jsx)(`span`,{className:`bg-task-badge`,children:e.bgServers.length})]}),"host:settings":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`settingsTitle`),onClick:u,children:[(0,X.jsx)(ue,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`settings`)})]}),"host:sound":(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`sound`)})]}),tip:T(`sound`),open:de,onOpenChange:W,caret:!1,children:[(0,X.jsx)(Fn,{settings:m,onChange:h,onPreview:_}),(0,X.jsx)(si,{})]}),"host:language":(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fe,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:En(C)})]}),tip:T(`language`),open:pe,onOpenChange:G,caret:!1,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`language`)}),E.map(e=>(0,X.jsx)(Ht,{active:C===e.code,onClick:()=>{w(e.code),G(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(Ht,{onClick:()=>{G(!1),be(!0)},children:[(0,X.jsx)(qe,{}),` `,T(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(B,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`theme`)})]}),tip:T(`theme`),open:K,caret:!1,onOpenChange:e=>{he(e),e&&v.length===0&&x()},children:(()=>{let e=v.filter(e=>e.group===`classic`),t=v.filter(e=>e.group!==`classic`),n=e=>{let t=C===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?T(`themeLight`):e.scheme===`dark`?T(`themeDark`):``;return n?C===`zh`?`${t}(${n})`:`${t} (${n})`:t};return(0,X.jsxs)(X.Fragment,{children:[e.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`themeGroupClassics`)}),e.map(e=>(0,X.jsx)(Ht,{active:y===e.id,onClick:()=>{b(e.id),he(!1)},children:n(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:e.length>0?T(`themeGroupBuiltin`):T(`theme`)}),(0,X.jsx)(Ht,{active:y===null,onClick:()=>{b(null),he(!1)},children:T(`themeDefault`)}),t.map(e=>(0,X.jsx)(Ht,{active:y===e.id,onClick:()=>{b(e.id),he(!1)},children:n(e)},e.id))]})})()}),"host:update":se?(0,X.jsxs)(`span`,{className:`chip`,"data-tip":T(`updatesManaged`),children:[(0,X.jsx)(qe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,H??e.update?.current??`…`]})]}):(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,e.update?.current??`…`]}),e.update&&!e.update.upToDate&&(0,X.jsx)(`span`,{className:`update-dot`,title:T(`updateAvailable`,{version:e.update.latest??``})}),Me>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:T(`updatesAllBadge`,{n:Me})})]}),tip:T(`update`),open:ge,caret:!1,onOpenChange:e=>{q(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},fit:!0,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`update`)}),Ge(),Ue()]}),"host:github":(0,X.jsx)(`a`,{className:`chip github`,href:`https://github.com/xing-shuyin/pi-web-ui`,target:`_blank`,rel:`noreferrer noopener`,"data-tip":T(`githubRepo`),children:(0,X.jsx)(Ie,{})}),"host:conn":(0,X.jsxs)(`span`,{className:`chip`,"data-tip":e.status,children:[(0,X.jsx)(`span`,{className:`status-dot ${e.status===`open`?`ok`:`busy`}`}),(0,X.jsx)(`span`,{className:`chip-sub`,children:e.status})]}),"host:engine":(0,X.jsx)(`span`,{className:`chip`,"data-tip":`engine`,children:(0,X.jsx)(`span`,{className:`chip-sub`,children:e.engine??`pi`})}),"host:ctx":(0,X.jsx)(`span`,{className:`chip`,"data-tip":T(`contextUsage`),children:(0,X.jsx)(`span`,{className:`chip-sub`,children:(e.state?.stats?.contextUsage?.tokens??0)>0?`${e.state?.stats?.contextUsage?.tokens}`:T(`contextUsage`)})}),"host:cost":(()=>{let t=Oi(e.state?.stats?.cost??0,{fixedDigits:4});return(0,X.jsx)(`span`,{className:`chip`,"data-tip":t.tooltip||T(`cumulativeCost`),children:(0,X.jsxs)(`span`,{className:`chip-sub`,children:[t.symbol,t.value]})})})(),"host:cwd":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":e.state?.cwd??``,onClick:()=>A(!0),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:e.state?.cwd?.split(/[/\\]/).pop()||e.state?.cwd})]})},Ye=new Set([`host:search`,`host:tasks`,`host:settings`,`host:plugins`]),Xe=new Set([`host:sound`,`host:language`,`host:theme`,`host:update`,`host:browser`]),Ze=e=>Ye.has(e)&&!F(e.slice(5)),Qe=e=>{if(e.kind===`view`){if(!F(`plugins`))return null;let t=e.view??``,i=r.find(t=>`plugin:${t.id}`===e.source),a=i?.error?`${e.label}: ${i.error}`:e.hint??e.label;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===t,className:`tb-tab plugin-tab${n===t?` active`:``}${i?.error?` broken`:``}`,"data-tip":a,onClick:()=>c(t),onContextMenu:t=>V(t,e.id,e.label),children:[(0,X.jsx)(hi,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`plugin-topbar-item plugin-topbar-select`,title:e.hint??e.label,"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>s?.(e,t.target.value),onContextMenu:t=>V(t,e.id,e.label),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id):(0,X.jsxs)(`button`,{type:`button`,className:`plugin-topbar-item`,"data-tip":e.hint??e.label,onClick:()=>s?.(e),onContextMenu:t=>V(t,e.id,e.label),children:[(0,X.jsx)(hi,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},$e=[];for(let t of L){if(t.entry?.hidden||Ze(t.id))continue;let i=null;t.entry?i=(0,X.jsx)(Go,{entry:t.entry,bar:`top`,chat:e,view:n,plugins:r,onViewChange:c,onOpenPanel:l,onOpenSettings:u,onOpenGlobalSearch:p,onOpenBgTasks:f,onOpenProjectPicker:()=>A(!0),isProjectPickerOpen:k,onOpenPluginMenu:e=>ee(t=>t?.el===e?null:{rect:e.getBoundingClientRect(),el:e}),isPluginMenuOpen:j!==null,onUiAction:s,uiContextEntries:o,dropdownProps:{sound:m,onSoundChange:h,onSoundPreview:_,theme:y,themes:v,onThemeChange:b,reloadThemes:x,onLocaleModalOpen:()=>be(!0),renderUpdateBody:Ge,renderAllUpdatesBody:Ue,updatesCount:Me,managed:se,appVersion:H}},t.id):t.id.startsWith(`host:`)&&Je[t.id]&&(i=Je[t.id]),i&&$e.push({id:t.id,entry:t.entry,node:i})}for(let t of R){let i=(0,X.jsx)(Go,{entry:t,bar:`top`,chat:e,view:n,plugins:r,onViewChange:c,onUiAction:s,uiContextEntries:o},t.id);i&&$e.push({id:t.id,entry:t,node:i})}let et=e=>e.entry?.align??`start`,[tt,nt]=(0,g.useState)(()=>new Set),rt=(0,g.useRef)(null),it=(0,g.useRef)(new Map),at=$e.filter(e=>!tt.has(e.id)),ot=Y?at.filter(e=>ba.has(e.id)):[],st=Y?at.filter(e=>!ba.has(e.id)):at,ct=Y?$e.filter(e=>!ba.has(e.id)):$e,lt=[...ct.filter(e=>et(e)===`start`),...ct.filter(e=>et(e)===`center`),...ct.filter(e=>et(e)===`end`)],ut=lt.filter(e=>!tt.has(e.id)),dt=(0,g.useRef)(lt),ft=(0,g.useRef)(ut);(0,g.useLayoutEffect)(()=>{dt.current=lt,ft.current=ut});let pt=()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`)),n=ft.current;t.length===n.length&&n.forEach((e,n)=>it.current.set(e.id,t[n].offsetWidth));let r=Number.parseFloat(getComputedStyle(e).columnGap)||0,i=dt.current,a=Sa(i.map(e=>({id:e.id,width:e.entry?it.current.get(e.id)??0:0})),e.clientWidth,r,0,qi);nt(e=>e.size===a.size&&[...a].every(t=>e.has(t))?e:a)},mt=`${at.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${Y?`m`:`d`}`;(0,g.useLayoutEffect)(pt,[mt]),(0,g.useEffect)(()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>pt());return t.observe(e),()=>t.disconnect()},[mt]);let gt=st.filter(e=>et(e)===`start`),_t=st.filter(e=>et(e)===`center`),vt=st.filter(e=>et(e)===`end`),yt=$e.filter(e=>tt.has(e.id)&&e.entry).map(e=>e.entry),bt=new Map;[...i??[],...a??[]].forEach((e,t)=>{bt.has(e.id)||bt.set(e.id,t)});let xt=xa([...re,...yt],e=>bt.get(e)??999999),St=e=>e.icon&&!/[a-z]/i.test(e.icon)?e.icon:null,Ct=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${Ct?` no-labels`:``}`,"data-pi-anchor":`topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-flow`,ref:rt,role:`toolbar`,"aria-label":T(`viewSwitch`),children:[gt.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),(_t.length>0||vt.length>0)&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),_t.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),_t.length>0&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),vt.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id))]}),(xt.length>0||$e.length>0)&&(0,X.jsxs)(`div`,{className:`plugin-topbar-more`,children:[(0,X.jsx)(`button`,{ref:P,type:`button`,className:`plugin-topbar-item`,"aria-haspopup":`menu`,"aria-expanded":D,"aria-label":T(`pluginTopbarMore`),"data-tip":T(`pluginTopbarMore`),onClick:()=>O(e=>!e),children:(0,X.jsx)(Dt,{})}),(0,X.jsxs)(qo,{anchorRef:P,open:D,onClose:()=>O(!1),children:[xt.map(e=>{let t=e.source===`host`&&Xe.has(e.id)?Je[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(g.Fragment,{children:t},e.id);if(e.source===`host`&&e.id===`host:github`)return(0,X.jsxs)(`a`,{role:`menuitem`,className:`chip github`,href:`https://github.com/xing-shuyin/pi-web-ui`,target:`_blank`,rel:`noreferrer noopener`,title:T(`githubRepo`),onClick:()=>O(!1),children:[(0,X.jsx)(Ie,{}),(0,X.jsx)(`span`,{children:`GitHub`})]},e.id);if(e.source===`host`){let t=Je[e.id];if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>O(!1),children:t},e.id)}else{let t=Qe(e);if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>O(!1),children:t},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsxs)(`label`,{className:`plugin-topbar-overflow-select tb-row`,title:e.hint??e.label,children:[St(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:St(e)}):null,(0,X.jsx)(`span`,{className:`tb-row-text`,children:e.label}),(0,X.jsx)(`select`,{"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>{O(!1),oe(e)||s?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})]},e.id):(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`tb-row`,title:e.hint??e.label,onClick:()=>{O(!1),oe(e)||s?.(e)},children:[St(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:St(e)}):null,(0,X.jsx)(`span`,{className:`tb-row-text`,children:e.label})]},e.id)}),(0,X.jsx)(`div`,{className:`tb-menu-divider`,"aria-hidden":`true`}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`tb-row`,onClick:()=>{O(!1),S()},children:[(0,X.jsx)(Ke,{}),(0,X.jsx)(`span`,{className:`tb-row-text`,children:T(`uiIconEdit`)})]})]})]}),ot.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),ye&&(0,X.jsx)(Oo,{onClose:()=>be(!1)}),j&&(0,X.jsx)(Do,{anchorRect:j.rect,anchorEl:j.el,plugins:r,pinnedIds:ie,orderedPluginIds:I,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:Zi(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:Qi(e.settings?.uiLayout,t)}),onOpenView:e=>{ee(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>ee(null)}),k&&(0,X.jsx)(So,{open:!0,currentCwd:M,pathCompletions:e.pathCompletions??[],workspaceRoots:te,onClose:()=>A(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Xo(e,t){let n={...t};if(!e)return n;try{let r=JSON.parse(e);if(r&&typeof r==`object`&&!Array.isArray(r))for(let e of Object.keys(t)){let t=r[e];typeof t==`number`&&Number.isFinite(t)&&t>0&&(n[e]=t)}}catch{}return n}function Zo(e){let t=e.start.above+e.start.below,n=Math.max(1,e.availablePx)/(e.totalWeight>0?e.totalWeight:1),r=e.minAbovePx/n,i=e.minBelowPx/n;if(r+i>=t){let n=e.minAbovePx+e.minBelowPx||1,r=t*e.minAbovePx/n;return{above:r,below:t-r}}let a=Math.min(t-i,Math.max(r,e.start.above+e.deltaPx/n));return{above:a,below:t-a}}function Qo(e,t,n){let r=new Map(e.map(e=>[e.id,e])),i=e=>e.parentId?r.get(e.parentId)?.cwd??e.cwd:e.cwd,a=e.find(e=>e.id===n),o=a?i(a):t,s=new Map;for(let t of e){let e=i(t),n=s.get(e)??[];n.push(t),s.set(e,n)}let c=[...s.entries()].map(([e,t])=>({cwd:e,isCurrent:e===o,convs:t}));return c.sort((e,t)=>e.isCurrent?-1:t.isCurrent?1:e.cwd<t.cwd?-1:+(e.cwd>t.cwd)),c}function $o(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.isStreaming),m=t.some(e=>!!e.error),h=t.some(e=>!!e.hasQuestion),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasStreaming:p,hasError:m,hasQuestion:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}function es(e){if(!e)return null;let t=e.startsWith(`#`)?e.slice(1):e;if(!t.trim())return null;let n=new URLSearchParams(t),r=n.get(`s`)?.trim()??``;if(!r)return null;let i=n.get(`m`)?.trim()||void 0;return i?{sessionId:r,messageId:i}:{sessionId:r}}function ts(e){let t=e?.sessionId?.trim()??``;if(!t)return``;let n=e?.messageId?.trim()??``,r=`#s=${encodeURIComponent(t)}`;return n?`${r}&m=${encodeURIComponent(n)}`:r}function ns(e,t){let n=ts(t);try{let t=new URL(e);return t.searchParams.delete(`token`),t.hash=n,t.toString()}catch{return`${e.split(`#`)[0]??e}${n}`}}function rs(e){if(!e)return null;let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);if(!t)return null;let n=t.split(`/`),r=n[n.length-1]??``;if(!r)return null;if(r===`session.jsonl`)return(n[n.length-2]?.trim()??``)||null;let i=r.endsWith(`.jsonl`)?r.slice(0,-6):r;if(!i)return null;let a=i.lastIndexOf(`_`);return(a>=0?i.slice(a+1).trim():i.trim())||null}function is(e,t){let n=t?.trim()??``;if(!n||e.length===0)return null;let r=e.find(e=>e.id===n);if(r)return r.id;let i=/^([a-z]+-\d+)-\d+$/.exec(n);if(i){let t=`${i[1]}-`,n=e.find(e=>e.id.startsWith(t));if(n)return n.id}return null}function as(e,t){let n=t.assistantMessageEvent,r=e.stats.tokens,i=t.usage===null?r:{...r,...t.usage},a=i===r?e.stats:{...e.stats,tokens:i};if(n.type!==`text_delta`&&n.type!==`thinking_delta`)return a===e.stats?e:{...e,stats:a};let o=n.delta??``;if(!o)return a===e.stats?e:{...e,stats:a};let s=e.streamingMessage??null,c=s&&s.id===t.messageId?s:{id:t.messageId,content:[]},l=[...c.content],u=n.type===`thinking_delta`?`thinking`:`text`,d=n.contentIndex??l.length-1;return d>=0&&d<l.length&&l[d].type===u?l[d]=u===`thinking`?{type:`thinking`,thinking:(l[d].thinking??``)+o}:{type:`text`,text:(l[d].text??``)+o}:l.push(u===`thinking`?{type:`thinking`,thinking:o}:{type:`text`,text:o}),{...e,stats:a,streamingMessage:{...c,id:t.messageId,content:l}}}function os(e){let{current:t,source:n,snapshot:r,answered:i,activeConversationId:a}=e;return r&&r.id&&!i.has(r.id)?t?.id===r.id?{changed:!1,question:t,source:n}:{changed:!0,question:r,source:`snapshot`}:t&&t.conversationId&&a&&t.conversationId!==a||!r&&t&&n===`snapshot`?{changed:!0,question:null,source:`live`}:{changed:!1,question:t,source:n}}var ss=new Set;function cs(e){return ss.add(e),()=>{ss.delete(e)}}function ls(e,t){for(let n of ss)try{n(e,t)}catch(e){console.error(`[tui-overlay-bridge] listener error:`,e)}}function us(e){let t=typeof e.name==`string`?e.name:``;if(e.unsupported===!0)return{name:t,status:`unsupported`};if(e.found!==!0)return{name:t,status:`missing`};let n={name:t,status:`ready`};return e.label&&(n.label=e.label),e.description&&(n.description=e.description),e.promptSnippet&&(n.promptSnippet=e.promptSnippet),Array.isArray(e.promptGuidelines)&&e.promptGuidelines.length>0&&(n.promptGuidelines=e.promptGuidelines),e.parameters!==void 0&&(n.parameters=e.parameters),e.parametersDropped===!0&&(n.parametersDropped=!0),(e.active===!0||e.active===!1)&&(n.active=e.active),e.source&&(n.source=e.source),e.scope&&(n.scope=e.scope),n}var ds=null,fs=new Set;function ps(){for(let e of fs)e()}function ms(e){let t=(e??``).trim();t&&(ds={name:t,status:`loading`},ps(),$({type:`get_tool_info`,name:t}))}function hs(){ds!==null&&(ds=null,ps())}function gs(e){ds!==null&&ds.name===e.name&&(ds=us(e),ps())}function _s(e){return fs.add(e),()=>{fs.delete(e)}}function vs(){return ds}function ys(){return(0,g.useSyncExternalStore)(_s,vs,vs)}function bs(e){let t=typeof e.name==`string`?e.name:``;if(e.unsupported===!0)return{name:t,status:`unsupported`};if(e.found!==!0)return{name:t,status:`missing`};let n={name:t,status:`ready`};return e.defaultDescription&&(n.defaultDescription=e.defaultDescription),e.defaultPromptSnippet&&(n.defaultPromptSnippet=e.defaultPromptSnippet),Array.isArray(e.defaultPromptGuidelines)&&e.defaultPromptGuidelines.length>0&&(n.defaultPromptGuidelines=e.defaultPromptGuidelines),e.override&&(n.override=e.override),n}var xs={},Ss=new Set;function Cs(){for(let e of Ss)e()}function ws(e){let t=(e??``).trim();t&&(xs[t]&&xs[t].status!==`loading`||(xs={...xs,[t]:{name:t,status:`loading`}},Cs(),$({type:`get_tool_prompt`,name:t})))}function Ts(e){let t=typeof e.name==`string`?e.name:``;t&&xs[t]&&(xs={...xs,[t]:bs(e)},Cs())}function Es(e){if(!xs[e])return;let t={...xs};delete t[e],xs=t,Cs()}function Ds(e){return Ss.add(e),()=>Ss.delete(e)}function Os(e){return(0,g.useSyncExternalStore)(Ds,()=>e?xs[e]??null:null)}var ks=Object.freeze({status:`idle`,messages:[]}),As=new Map,js=new Set,Ms=16;function Ns(){for(;As.size>Ms;){let e=As.keys().next().value;if(e===void 0)break;As.delete(e)}}function Ps(){for(let e of js)e()}function Fs(e,t){let n=(e??``).trim();if(!n)return;let r=As.get(n);(!r||r.status!==`loading`&&r.status!==`ready`)&&(As.set(n,{status:`loading`,messages:r?.messages??[]}),Ns(),Ps(),$({type:`get_compacted_messages`,compactionMessageId:n,conversationId:t}))}function Is(e){let t=e.compactionMessageId;t&&(e.error?As.set(t,{status:`error`,messages:[],error:e.error}):As.set(t,{status:`ready`,messages:e.messages??[]}),Ns(),Ps())}function Ls(e){let t=As.get(e);return t?(As.delete(e),As.set(e,t),t):ks}function Rs(e){return js.add(e),()=>{js.delete(e)}}function zs(e){return(0,g.useSyncExternalStore)(Rs,()=>Ls(e),()=>ks)}var Bs=`__piWebUiHost`,Vs=e=>new Promise(t=>setTimeout(t,e));async function Hs(e=3e3){let t=Date.now()+e;for(;;){let e=window.__piBridge;if(e&&typeof e.call==`function`)return e;if(Date.now()>=t)return null;await Vs(100)}}var Us=Promise.resolve(),Ws=0;function Gs(e){let t=Math.max(1,Number(e.pollMs??100)),n=Math.max(t,Number(e.timeoutMs??8e3)),r=async e=>{let r=Date.now()+n;for(;;){if(e())return!0;if(Date.now()>=r)return e();await Vs(t)}},i=()=>{try{let t=e.listModels?.()??[];return Array.isArray(t)?[...t]:[]}catch{return[]}},a=e=>{if(!e)return!0;try{return i().some(t=>t&&t.id===e)}catch{return!1}},o=async t=>{t&&(e.send({type:`set_model`,modelId:t}),typeof e.getCurrentModelId==`function`&&await r(()=>e.getCurrentModelId?.()===t))},s=async(t,n)=>{let i=String(n.cwd??``).trim();if(i&&e.getCwd()!==i&&(e.send({type:`set_cwd`,path:i}),await r(()=>e.getCwd()===i)),n.newChat!==!1){let t=e.getConversationId();e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank())}let a=String(n.model??``).trim();a&&await o(a),e.send({type:`prompt`,text:t})};return{version:11,setView(t){let n=String(t??``).trim();n&&e.setView(n)},startChat(t){let n=String(t?.prompt??``).trim();if(!n||!e.isReady())return!1;let r=String(t?.model??``).trim();if(r&&!a(r))return!1;let i=()=>s(n,t??{prompt:n}),o;return o=Ws>0?Us.then(i):i(),Ws++,Us=o.then(()=>{Ws--},()=>{Ws--}),o.catch(()=>{}),!0},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>xc(e)},compose(e){return cr()?lr({text:typeof e?.text==`string`?e.text:void 0,attachments:Array.isArray(e?.attachments)?e.attachments:void 0}):!1},openModal(t){let n=String(t??``).trim();if(!n||typeof e.openModal!=`function`)return!1;try{return e.openModal(n)}catch{return!1}},closeModal(){if(typeof e.closeModal!=`function`)return!0;try{e.closeModal()}catch{}return!0},async openSession(t){let n=Xs,i=Array.isArray(t?.folders)?t.folders.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],s=Array.isArray(t?.roots)?t.roots.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],c=String(t?.cwd??``).trim(),l=[...new Set([...i,...s])],u=c||l[0]||``;if(!u)return{ok:!1,error:`openSession 需要 cwd / folders / roots(绝对路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let d=l.filter(e=>e!==u).slice(0,7),f=new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]);for(let t of[u,...d])if(!f.has(t)){if(!(e.confirm&&await e.confirm({path:t}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${t}`};e.grantPath?.(t,n)}if(e.getCwd()!==u&&(e.send({type:`set_cwd`,path:u}),!await r(()=>e.getCwd()===u)))return{ok:!1,error:`切换工作目录失败或超时:${u}`};(d.length>0||e.getWorkspaceRoots().length>0)&&e.send({type:`set_workspace_roots`,roots:d});let p=e.getConversationId()??void 0;if(t?.newChat!==!1){let t=p;e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank()),p=e.getConversationId()??void 0}let m=String(t?.model??``).trim();if(m){if(!a(m))return{ok:!1,error:`未知模型:${m}(先调 models.list() 取可用列表)`};await o(m),p=e.getConversationId()??p}let h=String(t?.prompt??``).trim();return h&&e.send({type:`prompt`,text:h}),{ok:!0,...p?{sessionId:p}:{}}},sessions:{list:()=>e.listSessions(),async open(t){let n=Xs,i=String(t??``).trim();if(!i)return{ok:!1,error:`sessions.open 需要一个会话 id(先调 list)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let a=e.listSessions().find(e=>e.id===i);if(!a)return{ok:!1,error:`找不到会话:${i}`};if(a.cwd&&a.cwd!==e.getCwd()){if(!new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]).has(a.cwd)){if(!(e.confirm&&await e.confirm({path:a.cwd}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${a.cwd}`};e.grantPath?.(a.cwd,n)}if(e.send({type:`set_cwd`,path:a.cwd}),!await r(()=>e.getCwd()===a.cwd))return{ok:!1,error:`切换工作目录失败或超时:${a.cwd}`}}let o=e.getConversationId();return a.kind===`running`?e.send({type:`switch_conversation`,id:a.id}):e.send({type:`switch_session`,path:a.id}),await r(()=>e.getConversationId()!==o)?{ok:!0,sessionId:e.getConversationId()??void 0}:{ok:!1,error:`切换会话超时:${a.title}`}}},async reloadCatalog(t,n){let r=String(t??``).trim();if(!r)return{ok:!1,error:`reloadCatalog 需要一个目录来源(http(s) URL 或本地文件路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let i=jt();return new Promise(t=>{let a=setTimeout(()=>{kc.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));kc.set(i,e=>{clearTimeout(a),t(e)}),e.send({type:`plugin_catalog_sync`,requestId:i,source:r,...n?.install?{install:!0}:{},...n?.replace?{replace:!0}:{}})})},onUiAction(e,t){return Qs(Js,String(e??``).trim(),t)},onTopbarAction(e,t){return Qs(Js,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(Rn())return{ok:!1,error:`桌面版(Electron 外壳)不支持 browser_page:窗口里没有 Chrome 扩展运行时。请让用户改用系统浏览器打开同一个 pi-web-ui 地址(网页版)再试。/ The desktop app cannot run browser_page (no Chrome extension runtime); ask the user to open the same pi-web-ui address in a regular browser instead.`};let r=await Hs(e.bridgeWaitMs??3e3);if(!r)return{ok:!1,error:`浏览器扩展的页面桥没就绪:确认已安装并启用 page-picker 扩展、本页地址已绑定,然后刷新本页`};try{let e=await r.call({op:n,...t.args===void 0?{}:{args:t.args},...t.target?{to:t.target}:{},...t.timeoutMs?{timeoutMs:t.timeoutMs}:{}});return e===void 0?{ok:!0}:{ok:!0,result:e}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},dom:{anchors(){let e=e=>{try{return document.querySelector(`[data-pi-anchor="${e}"]`)}catch{return null}};return{app:e(`app`),topbar:e(`topbar`),composer:e(`composer`)}}},dialogs:{async select(t){try{let n=e.select;if(typeof n!=`function`)return{ok:!1};let r=Array.isArray(t?.options)?t.options:[],i=await n({title:String(t?.title??``),options:r.filter(e=>typeof e==`object`&&!!e&&typeof e.label==`string`).map(e=>({label:String(e.label),...typeof e.description==`string`?{description:e.description}:{}})),...t?.multi?{multi:!0}:{}});return!i||typeof i!=`object`||i.ok!==!0?{ok:!1,...i&&typeof i==`object`&&typeof i.error==`string`?{error:i.error}:{}}:{ok:!0,selected:Array.isArray(i.selected)?i.selected.filter(e=>typeof e==`string`):[]}}catch{return{ok:!1}}},async confirm(t){let n=String(t?.title??``),r=typeof t?.detail==`string`?t.detail:``;try{if(typeof e.dialogConfirm==`function`)try{return await e.dialogConfirm({title:n,...r?{detail:r}:{}})===!0}catch{}if(typeof window<`u`&&typeof window.confirm==`function`)try{return window.confirm(r?`${n}\n\n${r}`:n)}catch{return!1}return!1}catch{return!1}},async input(t){try{let n=e.input;if(typeof n!=`function`)return{ok:!1};let r=await n({title:String(t?.title??``),...typeof t?.placeholder==`string`?{placeholder:t.placeholder}:{},...typeof t?.initial==`string`?{initial:t.initial}:{}});return!r||typeof r!=`object`||r.ok!==!0?{ok:!1}:typeof r.value==`string`?{ok:!0,value:r.value}:{ok:!0}}catch{return{ok:!1}}}},async notifyAction(t){let n=String(t?.text??``),r=(Array.isArray(t?.actions)?t.actions:[]).filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.label==`string`);try{if(typeof e.notifyAction==`function`){let t=await e.notifyAction({text:n,actions:r});return typeof t==`string`?t:null}}catch{return null}try{typeof window<`u`&&typeof window.dispatchEvent==`function`&&window.dispatchEvent(new CustomEvent(ec,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>cc(String(e??``),t)},searchProviders:{register:e=>uc(e),list:()=>dc()},composerProviders:{register:e=>pc(e),list:()=>mc()},onTheme:e=>Cc(e),onLocale:e=>wc(e),onViewChange:e=>Tc(e),setCostFormatter:e=>Ei(e),setCostCurrency:e=>Ti(e),getCostCurrency:()=>wi()}}function Ks(e){try{let t=window;e?t[Bs]=e:delete t[Bs]}catch{}}var qs=new Map,Js=null;async function Ys(e,t){let n=Js;Js=e;try{return await t()}finally{Js=n}}var Xs=void 0;function Zs(e,t){let n=Xs;Xs=e;try{return t()}finally{Xs=n}}function Qs(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=qs.get(r);i||(i=new Set,qs.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&qs.delete(r)}}async function $s(e,t,n,r){let i=i=>{let a=qs.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{Zs(e,()=>i(n,r?.value,r?.target))}catch(n){console.error(`[plugin:${e}] 顶栏动作 ${t} 抛错:`,n)}return!0};if(i(`${e}:${t}`)||i(t))return!0;if(r?.loadBundle&&await r.loadBundle(e).catch(()=>!1)){let n=Date.now()+Math.max(100,Number(r.waitMs??1500));for(;;){if(i(`${e}:${t}`)||i(t))return!0;if(Date.now()>=n)break;await new Promise(e=>setTimeout(e,100))}}return!1}var ec=`pi-web-ui:toast`,tc=new Map,nc=!1;function rc(e){let t=e.split(`+`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0);if(t.length===0)return null;let n=!1,r=!1,i=!1,a=!1;for(let e of t.slice(0,-1))if(e===`ctrl`||e===`control`)n=!0;else if(e===`shift`)r=!0;else if(e===`alt`||e===`option`)i=!0;else if(e===`meta`||e===`cmd`||e===`command`||e===`win`||e===`super`)a=!0;else return null;let o=t[t.length-1]??``;return!o||[`ctrl`,`control`,`shift`,`alt`,`option`,`meta`,`cmd`,`command`,`win`,`super`].includes(o)?null:{combo:`${n?`ctrl+`:``}${r?`shift+`:``}${i?`alt+`:``}${a?`meta+`:``}${o}`,key:o,ctrl:n,shift:r,alt:i,meta:a}}function ic(){try{if(typeof document>`u`)return!1;let e=document.activeElement;if(!e)return!1;let t=(e.tagName||``).toUpperCase();return!!(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)}catch{return!1}}function ac(e){try{if(ic())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=tc.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function oc(){if(!nc)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,ac),nc=!0}catch{}}function sc(){if(!(tc.size>0||!nc))try{window.removeEventListener(`keydown`,ac)}catch{}finally{nc=!1}}function cc(e,t){if(typeof t!=`function`)return()=>{};let n=rc(e);if(!n)return()=>{};let r=tc.get(n.combo);r||(r=new Set,tc.set(n.combo,r));let i=r;return i.add(t),oc(),()=>{i.delete(t),i.size===0&&tc.delete(n.combo),sc()}}var lc=new Map;function uc(e){let t=String(e?.id??``).trim();if(!t||typeof e?.search!=`function`)return()=>{};let n={id:t,label:String(e.label??t),search:e.search};return lc.set(t,n),()=>{lc.get(t)===n&&lc.delete(t)}}function dc(){return[...lc.values()].map(e=>({id:e.id,label:e.label}))}var fc=new Map;function pc(e){let t=String(e?.id??``).trim();if(!t||typeof e?.search!=`function`)return()=>{};let n={id:t,label:String(e.label??t),search:e.search};return fc.set(t,n),()=>{fc.get(t)===n&&fc.delete(t)}}function mc(){return[...fc.values()].map(e=>({id:e.id,label:e.label}))}function hc(e){return fc.get(String(e??``))}function gc(e){return lc.get(String(e??``))}var _c=new Set,vc=new Set,yc=new Set,bc=new Set;function xc(e){return bc.add(e),()=>{bc.delete(e)}}function Sc(e){for(let t of bc)try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function Cc(e){return typeof e==`function`?(_c.add(e),()=>{_c.delete(e)}):()=>{}}function wc(e){return typeof e==`function`?(vc.add(e),()=>{vc.delete(e)}):()=>{}}function Tc(e){return typeof e==`function`?(yc.add(e),()=>{yc.delete(e)}):()=>{}}function Ec(e){let t=String(e??``);for(let e of _c)try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function Dc(e){let t=String(e??``);for(let e of vc)try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function Oc(e){let t=String(e??``);for(let e of yc)try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var kc=new Map;function Ac(e){let t=kc.get(e.requestId);if(t){if(kc.delete(e.requestId),!e.ok){t({ok:!1,error:e.error??`目录同步失败`});return}t({ok:!0,...e.entries?{entries:e.entries}:{},...e.installed?{installed:e.installed}:{}})}}var jc=`modulepreload`,Mc=function(e){return`/`+e},Nc={},Pc=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Mc(t,n),t=s(t),t in Nc)return;Nc[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:jc,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Fc=`pi-web-ui:plugin-data`;function Ic(e,t){window.dispatchEvent(new CustomEvent(Fc,{detail:{pluginId:e,payload:t}}))}function Lc(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(Fc,t),()=>window.removeEventListener(Fc,t)}var Rc=new Map,zc=new Set,Bc=new Set,Vc=new Set,Hc=new Set,Uc=-1;function Wc(){return[...Rc.values()]}function Gc(){let e=Wc();for(let t of Bc)t(e)}function Kc(){let e=[...Vc];for(let t of Hc)t(e)}function qc(e){return Hc.add(e),e([...Vc]),()=>Hc.delete(e)}async function Jc(e,t){Vc.delete(e.id),Xc.set(e.id,(Xc.get(e.id)??0)+1),Kc();let n=await tl(e,t);return Gc(),n}function Yc(e){return Bc.add(e),e(Wc()),()=>Bc.delete(e)}var Xc=new Map;function Zc(e,t){let n=Xc.get(e)??0;return fn(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function Qc(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>Ys(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var $c=Qc(e=>Pc(()=>import(e),[]));async function el(e,t){if(!e.hasClient||e.error)return null;try{return(await $c(e.id,Zc(e.id,t))).default??null}catch(t){return console.error(`[plugin:${e.id}] 客户端 bundle 加载失败:`,t),null}}async function tl(e,t){try{let n=(await $c(e.id,Zc(e.id,t))).default;return n&&typeof n.mount==`function`?(Rc.set(e.id,{info:e,module:n}),!0):e.preload?(zc.add(e.id),!0):(Vc.add(e.id),Kc(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return Vc.add(e.id),Kc(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function nl(e,t){if(Rc.has(e.id)||zc.has(e.id))return!0;if(Vc.has(e.id)||!e.hasClient)return!1;let n=await tl(e,t);return Gc(),n}async function rl(e,t){t!==Uc&&(Uc=t,Rc.clear(),zc.clear(),Vc.clear(),Xc.clear(),Kc());let n=new Set(e.map(e=>e.id));for(let e of[...Rc.keys()])n.has(e)||Rc.delete(e);for(let e of[...zc])n.has(e)||zc.delete(e);for(let e of[...Vc])n.has(e)||Vc.delete(e);Kc(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!Rc.has(e.id)&&!zc.has(e.id)&&!Vc.has(e.id)).map(e=>tl(e,t))),Gc()}function il(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>Lc((n,r)=>{n===e&&t(r)})}}var al=[`debug`,`info`,`warn`,`error`];function ol(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function sl(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function cl(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.__host!==`logs`||!Array.isArray(t.logs)?!1:t.logs.every(e=>!!e&&typeof e==`object`&&typeof e.ts==`number`&&typeof e.text==`string`&&al.includes(String(e.level)))}var ll=new Map,ul=new Set;function dl(){for(let e of[...ul])try{e()}catch{}}function fl(e){return ul.add(e),()=>ul.delete(e)}function pl(e){return(ll.get(e)??[]).map(e=>({...e}))}function ml(e,t){return cl(t)?(ll.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),dl(),!0):!1}function hl(e){switch(e){case`error`:return 6500;case`warning`:return 4200;default:return 2400}}var gl=[/^(已在工作目录|正在切换到工作目录|已切换到工作目录)[::]/,/^(Already in directory|Switching to directory|Switched to directory):/i,/该项目最近的对话.*(为你停在了空白新对话|为你停在了新对话)/,/The most recent conversation .* landed on a (blank|new) chat/i,/^分层上下文预算裁剪生效/,/^Tiered context budget pruning/i,/^发现 \d+ 个内置插件有更新可用/,/^\d+ built-in plugin\(s\) have updates available/i,/^已(创建文件|创建文件夹|重命名|删除|移动|复制)[::]/,/^(Created file|Created folder|Renamed|Deleted|Moved|Copied):/i,/^已重命名当前会话为/,/^Renamed current session to/i,/的消息正在投递,已为你保留该对话$/,/is still sending your message — kept in the running list$/i,/^(计划模式已开启|计划模式已关闭|已进入计划模式|已退出计划模式|审查者模式已开启|审查者模式已关闭)/,/^(Plan mode (enabled|disabled)|Entered plan mode|Exited plan mode|Delegate mode (enabled|disabled))/i,/^已切换(智能体预设|权限预设)/,/^Switched (agent|permission) preset/i];function _l(e){if(e.level!==`info`)return!1;let t=(e.text??``).trim(),n=(e.textEn??``).trim();return gl.some(e=>t&&e.test(t)||n&&e.test(n))}function vl(e,t,n=2){if(_l(t))return e;let r=`${t.level}:${(t.text??``).trim()}`,i=[...e.filter(e=>`${e.level}:${(e.text??``).trim()}`!==r),t];for(;i.length>n;){let e=i.findIndex(e=>e.level!==`error`);e>=0?i.splice(e,1):i.shift()}return i}function yl(){return{flows:[],results:{}}}function bl(e,t){let n=e.findIndex(e=>e.flowId===t.flowId);return n<0?[...e,t]:e.map((e,r)=>r===n?t:e)}function xl(e,t){switch(t.type){case`provider_oauth_started`:{let n={...e.results};return delete n[t.provider],{flows:[...e.flows.filter(e=>e.provider!==t.provider),{flowId:t.flowId,provider:t.provider}],results:n}}case`provider_oauth_flows`:return{...e,flows:t.flows.map(e=>({...e}))};case`provider_oauth_prompt`:{let n=e.flows.find(e=>e.flowId===t.flowId);return{...e,flows:bl(e.flows,{...n,flowId:t.flowId,provider:t.provider,promptId:t.promptId,prompt:t.prompt})}}case`provider_oauth_event`:{let n=e.flows.find(e=>e.flowId===t.flowId);return{...e,flows:bl(e.flows,{...n,flowId:t.flowId,provider:t.provider,event:t.event,promptId:void 0,prompt:void 0})}}case`provider_oauth_result`:return{flows:e.flows.filter(e=>e.flowId!==t.flowId),results:{...e.results,[t.provider]:{ok:t.ok,...t.cancelled===void 0?{}:{cancelled:t.cancelled},...t.error===void 0?{}:{error:t.error}}}};case`provider_oauth_logout_result`:return{...e,results:{...e.results,[t.provider]:{ok:t.ok,...t.error===void 0?{}:{error:t.error}}}}}}var Sl=`pi-web-ui:lang`;function Cl(){try{return(localStorage.getItem(Sl)??``).trim()}catch{return``}}var wl=`pi-web-ui:locale`,Tl=2e5,El=2e5,Dl=`LIVE_OMIT`,Ol={conversationId:null,goal:null,reviewModel:null,maxRounds:3,locked:!0,reviewing:!1,round:0,status:``,verdict:`pending`,wizard:{active:!1,draft:``,model:null,step:0,maxSteps:6,status:``}};function kl(){let e=new Map,t=new Map,n=(e,t)=>`${e}:${t}`;return{write(r,i,a){let o=n(r,i),s=e.get(o);if(s&&s.size>0){for(let e of s)try{e.write(a)}catch{}return}let c=t.get(o)??``,l=c.length+a.length>El?a:c+a;t.set(o,l)},register(r,i,a){let o=n(r,i),s=e.get(o);s||(s=new Set,e.set(o,s)),s.add(a);let c=t.get(o);if(c){try{a.write(c)}catch{}t.delete(o)}return()=>{let n=e.get(o);n&&(n.delete(a),n.size===0&&e.delete(o)),t.delete(o)}},clear(){e.clear(),t.clear()}}}function Al(e,t){let n=new Set;for(let e of t.messages)e.role===`toolResult`&&e.toolCallId&&n.add(e.toolCallId),e.role===`bashExecution`&&n.add(`bash-${e.id}`);let r=!1;for(let t of e.keys())n.has(t)&&(e.delete(t),r=!0);return r?new Map(e):e}function jl(e,t){if(e.size===0)return e;let n=new Set;for(let e of t.messages)e.role===`toolResult`&&e.toolCallId&&n.add(e.toolCallId);let r=!1;for(let t of e.keys())n.has(t)&&(e.delete(t),r=!0);return r?new Map(e):e}function Ml(e,t){switch(t.type){case`status`:return{...e,status:t.status,ready:t.status===`open`&&e.ready,terminals:t.status===`closed`?[]:e.terminals,hostMetrics:t.status===`closed`?null:e.hostMetrics};case`sync_cached_sessions`:return{...e,sessions:t.sessions};case`host_metrics`:return{...e,hostMetrics:t.metrics};case`ready`:return{...e,serverVersion:t.serverVersion,engine:t.engine,appVersion:t.appVersion,managed:t.managed===!0,tabs:t.tabs,ready:!0,protocolMismatch:t.protocolVersion!==void 0&&t.protocolVersion!==29};case`snapshot`:{let n=e.state?.cwd,r=e.state?.conversationId,i=t.state.cwd,a=e.sessions;i&&i!==n&&(a=Kl(i));let o=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),s=e.transition;return s&&(s.phase===`done`||s.phase===`error`||s.kind===`cwd`&&o(t.state.cwd)===o(s.target)||s.kind===`session`&&o(t.state.sessionFile)===o(s.target)||s.kind===`conversation`&&t.state.conversationId===s.target||s.kind===`new_chat`&&(!r||t.state.conversationId!==r||t.state.messages.length===0))&&(s=null),{...e,ready:!0,state:t.state,transition:s,sessions:a,approval:t.state.pendingApproval??null,activeConversationId:t.state.conversationId,liveOutputs:Al(e.liveOutputs,t.state),toolStatuses:jl(e.toolStatuses,t.state)}}case`snapshot_delta`:{let n=e.state,r=t.msg;if(!n||n.conversationId!==r.conversationId||n.rev!==r.baseRev)return e;let i={...n,...r.state,messages:r.appended.length>0?[...n.messages,...r.appended]:n.messages};return{...e,ready:!0,state:i,approval:i.pendingApproval===void 0?e.approval:i.pendingApproval??null,activeConversationId:i.conversationId,liveOutputs:Al(e.liveOutputs,i),toolStatuses:jl(e.toolStatuses,i)}}case`tool_approval`:return{...e,approval:t.approval};case`tool_delta`:{let n=(e.liveOutputs.get(t.toolCallId)?.text??``)+t.delta,r=n.length>Tl?`…[${Dl}:${n.length-Tl}]…\n`+n.slice(n.length-Tl):n,i=new Map(e.liveOutputs);return i.set(t.toolCallId,{toolName:t.toolName,text:r}),{...e,liveOutputs:i}}case`message_delta`:{let n=e.state;return!n||n.conversationId!==t.msg.conversationId?e:{...e,state:as(n,t.msg)}}case`tool_status`:return{...e,toolStatuses:new Map(e.toolStatuses).set(t.status.toolCallId,t.status)};case`notice`:{let n=vl(e.notices,t.notice);return n===e.notices?e:{...e,notices:n}}case`dismiss_notice`:return{...e,notices:e.notices.filter(e=>e.id!==t.id)};case`sessions`:return ql(e.state?.cwd,t.sessions),{...e,sessions:t.sessions};case`conversations`:return{...e,conversations:t.conversations,elsewhere:t.elsewhere??[],activeConversationId:t.activeId};case`projects`:return Hl(t.projects),{...e,projects:t.projects};case`sandbox_diff`:return{...e,sandboxDiff:t.diff};case`files`:return{...e,files:t.files};case`file_changed`:return{...e,fileChanged:{path:t.path}};case`file_content`:return{...e,fileContent:t.content};case`models`:return{...e,models:t.models,modelsLoading:t.loading};case`models_config`:return{...e,modelsConfig:t.providers};case`providers_status`:return{...e,providers:t.providers};case`provider_keys`:return{...e,providerKeys:t.keys};case`default_model`:return{...e,defaultModel:t.modelId};case`provider_oauth`:{let n=xl({flows:e.providerOAuthFlows,results:e.providerOAuthResults},t.message);return{...e,providerOAuthFlows:n.flows,providerOAuthResults:n.results}}case`fetch_models_result`:return{...e,fetchModelsResult:t.result};case`test_model_connection_result`:return{...e,testModelConnectionResult:t.result};case`enrich_models_progress`:return{...e,enrichModelsProgress:t.progress};case`enrich_models_result`:return{...e,enrichModelsResult:t.result,enrichModelsProgress:null};case`refresh_provider_result`:return{...e,refreshProviderResult:t.result};case`refresh_builtin_result`:return{...e,refreshBuiltinResult:t.result};case`append_builtin_result`:return{...e,appendBuiltinResult:t.result};case`clone_provider_result`:return{...e,cloneProviderResult:t.result};case`install_result`:return{...e,installResult:t.result};case`scm_data`:return{...e,scmData:t.data};case`file_search_result`:return{...e,fileSearch:t.result};case`session_search_result`:return{...e,sessionSearch:t.result};case`scm_changed`:return{...e,scmDirty:e.scmDirty+1};case`path_completions`:return{...e,pathCompletions:t.completions};case`update_status`:return{...e,update:t.status};case`update_status_all`:return{...e,updatesAll:t.items,updatesSdk:t.piSdk??null};case`updates_check_started`:return{...e,updatesAll:null};case`widgets`:return{...e,widgets:t.widgets};case`statuses`:return{...e,statuses:t.statuses};case`dialog`:return{...e,dialog:t.dialog};case`tui_overlay`:return{...e,tuiOverlay:t.overlay};case`question`:return{...e,question:t.question};case`remote_question`:return{...e,remoteQuestion:t.question};case`commands`:return{...e,commands:t.commands,commandsPath:t.path};case`slash_commands`:return{...e,slashCommands:t.commands};case`goal_status`:return{...e,goal:t.status};case`plan_updated`:{let n=e.state;if(!n)return e;let r=e.activeConversationId||n.conversationId;if(!t.conversationId||t.conversationId!==r)return e;let i={...n,plan:t.plan};return{...e,state:i}}case`settings`:return{...e,settings:t.settings};case`mcp_servers`:return e.settings?{...e,settings:{...e.settings,mcpServers:t.servers,mcpGlobalConfigPath:t.globalConfigPath??e.settings.mcpGlobalConfigPath,mcpProjectConfigPath:t.projectConfigPath??e.settings.mcpProjectConfigPath}}:e;case`mcp_market_result`:return{...e,mcpMarketResult:t.result};case`skill_market_result`:return{...e,skillMarketResult:t.result};case`skill_content_result`:return{...e,skillContentResult:t.result};case`bg_servers`:return{...e,bgServers:t.servers};case`scheduler_tasks`:return{...e,schedulerTasks:t.tasks};case`plugin_panel_items`:return{...e,pluginPanelGroups:t.groups};case`plugins`:return{...e,plugins:t.plugins,pluginsEpoch:t.epoch};case`plugin_updates_check_started`:return{...e,checkingPluginUpdates:!0};case`plugin_updates`:{let n={};for(let e of t.updates)n[e.id]=e;return{...e,pluginUpdates:n,checkingPluginUpdates:!1}}case`plugin_catalog`:return{...e,pluginCatalog:t.entries,pluginCatalogEpoch:t.epoch};case`plugin_grants`:return{...e,pluginGrants:t.grants};case`plugin_permissions`:return{...e,pluginPermissions:t.grants};case`plugin_path_request`:return{...e,pathRequests:[...e.pathRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_path_resolved`:return{...e,pathRequests:e.pathRequests.filter(e=>e.id!==t.id)};case`plugin_permission_request`:return{...e,permRequests:[...e.permRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_permission_resolved`:return{...e,permRequests:e.permRequests.filter(e=>e.id!==t.id)};case`plugin_job`:{let{pluginId:n,phase:r,ok:i,action:a}=t.job,o=e.pluginUpdates;a===`update`&&r===`done`&&i&&e.pluginUpdates?.[n]&&(o={...e.pluginUpdates,[n]:{...e.pluginUpdates[n],updatable:!1}});let s=e.pluginJobs[t.job.jobId],c=t.line?[...s?.lines??[],t.line].slice(-40):s?.lines??[],l={...s,...t.job,lines:c,startedAt:s?.startedAt??Date.now()};return{...e,pluginUpdates:o,pluginJobs:{...e.pluginJobs,[t.job.jobId]:l}}}case`plugin_catalog_sync_result`:return{...e,catalogSync:{...t.result,receivedAt:Date.now()}};case`preset_export_result`:return{...e,presetExport:{...t.result,receivedAt:Date.now()}};case`preset_import_result`:return{...e,presetImport:{...t.result,source:t.source,receivedAt:Date.now()}};case`preset_catalog_result`:return{...e,presetCatalog:{...t.result,receivedAt:Date.now()}};case`preset_share_result`:return{...e,presetShare:{...t.result,receivedAt:Date.now()}};case`plugin_install_inspect_result`:return{...e,installInspect:t.result};case`dsh_patches`:return{...e,dshPatches:{patchDir:t.patchDir,files:t.files}};case`dsh_presets`:return{...e,dshPresets:{presets:t.presets,defaultPreset:t.defaultPreset}};case`dsh_permission`:return{...e,dshPermission:{options:t.options,defaultPreset:t.defaultPreset}};case`terminal_add`:return{...e,terminals:[...e.terminals,t.meta]};case`terminal_remove`:return{...e,terminals:e.terminals.filter(e=>e.id!==t.id)};case`terminal_exit`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!1,exitCode:t.exitCode}:e)};case`terminal_restart`:return{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!0,exitCode:null}:e)};case`terminal_list`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:t.terminals.map(n=>({...n,conversationId:t.conversationId??e.state?.conversationId??``}))};case`terminal_active`:return{...e,terminalActiveId:t.id};case`transition_start`:{let n=t.kind===`cwd`?Kl(t.target):null;return{...e,...n&&n.length>0?{sessions:n}:{},transition:{kind:t.kind,target:t.target,phase:`start`,progress:t.progress,text:t.text,textEn:t.textEn,startedAt:Date.now()}}}case`transition_progress`:{let n=t.msg;if(n.phase===`done`||n.phase===`error`)return{...e,transition:e.transition?{...e.transition,phase:n.phase,progress:100,text:n.text,textEn:n.textEn}:null};let r=e.transition;return{...e,transition:{kind:n.kind,target:n.target,phase:n.phase,progress:Math.max(r?.target===n.target?r.progress:0,n.progress),text:n.text,textEn:n.textEn,totalMessages:n.totalMessages??r?.totalMessages,previewMessages:n.previewMessages??r?.previewMessages,startedAt:r?.startedAt??Date.now()}}}case`transition_tick`:{let t=e.transition;if(!t||t.phase===`done`||t.phase===`error`)return e;let n=t.phase===`start`?26:t.phase===`fs`?56:92;if(t.progress>=n)return e;let r=Math.max(1,Math.round((n-t.progress)*.16));return{...e,transition:{...t,progress:Math.min(n,t.progress+r)}}}case`transition_clear`:return e.transition?{...e,transition:null}:e;default:return e}}var Nl=`pi-web-client-id`,Pl=null;function Fl(){if(Pl)return Pl;let e=null;try{e=sessionStorage.getItem(Nl),e||(e=jt(),sessionStorage.setItem(Nl,e))}catch{e??=jt()}return Pl=e,e}var Il=`pi-web-last-cwd`;function Ll(){try{return localStorage.getItem(Il)}catch{return null}}function Rl(e){try{localStorage.setItem(Il,e)}catch{}}function zl(e){try{let t=localStorage.getItem(Il);if(!t)return;let n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase();(t===e||n(t)===n(e))&&localStorage.removeItem(Il)}catch{}}var Bl=`pi-web-recent-projects`;function Vl(){try{let e=localStorage.getItem(Bl);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Hl(e){try{localStorage.setItem(Bl,JSON.stringify(e.slice(0,20)))}catch{}}function Ul(e){try{let t=Vl(),n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),r=n(e);Hl(t.filter(e=>n(e.path)!==r))}catch{}}var Wl=`pi-web-recent-sessions:`;function Gl(e){return e?`${Wl}${e.trim().replace(/[\\/]+$/,``).toLowerCase()}`:`pi-web-recent-sessions:default`}function Kl(e){try{let t=Gl(e??Ll()),n=localStorage.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function ql(e,t){try{let n=Gl(e??Ll());localStorage.setItem(n,JSON.stringify(t.slice(0,50)))}catch{}}function Jl(e,t){try{let n=Kl(t),r=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),i=r(e);ql(t,n.filter(e=>r(e.path)!==i))}catch{}}function Yl(){return gn(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${fn(`/ws`)}`)}function Xl(){let[e,t]=(0,g.useReducer)(Ml,{status:`connecting`,ready:!1,state:null,hostMetrics:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:Kl(),conversations:[],elsewhere:[],activeConversationId:``,projects:Vl(),files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},defaultModel:null,providerOAuthFlows:[],providerOAuthResults:yl().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,updatesSdk:null,widgets:[],statuses:[],dialog:null,tuiOverlay:null,approval:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:Ol,bgServers:[],schedulerTasks:[],pluginPanelGroups:[],settings:null,fetchModelsResult:null,testModelConnectionResult:null,enrichModelsResult:null,enrichModelsProgress:null,refreshProviderResult:null,refreshBuiltinResult:null,appendBuiltinResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginUpdates:null,checkingPluginUpdates:!1,pluginCatalog:[],pluginCatalogEpoch:0,pluginJobs:{},catalogSync:null,presetExport:null,presetImport:null,presetCatalog:null,presetShare:null,installInspect:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,mcpMarketResult:null,skillMarketResult:null,skillContentResult:null,dshPresets:null,dshPermission:null,protocolMismatch:!1,transition:null,sandboxDiff:null}),n=(0,g.useRef)(null),r=(0,g.useRef)(kl()),i=(0,g.useRef)(0),a=(0,g.useRef)(null),o=(0,g.useRef)(!0),s=(0,g.useRef)(0),c=(0,g.useRef)(0),l=(0,g.useRef)(new Map),u=(0,g.useRef)(null),d=(0,g.useRef)(!1),f=(0,g.useRef)(null),p=(0,g.useRef)(new Set),m=(0,g.useRef)(`live`),h=()=>{u.current||=setTimeout(()=>{u.current=null;let e=n.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:`get_state`}))},300)},_=(e,t)=>{let n=l.current,r=n.get(e);if(r!==void 0&&t!==r+1){let t=O.current.chat;e===(t.activeConversationId||t.state?.conversationId)&&h()}n.set(e,t)},v=(0,g.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]);(0,g.useEffect)(()=>{if(!e.transition)return;if(e.transition.phase===`done`||e.transition.phase===`error`){let e=setTimeout(()=>t({type:`transition_clear`}),180);return()=>clearTimeout(e)}let n=setInterval(()=>{if(Date.now()-(e.transition?.startedAt??0)>2e4){t({type:`transition_clear`});return}t({type:`transition_tick`})},160);return()=>clearInterval(n)},[e.transition]);let y=(0,g.useCallback)(e=>{let r=O.current.chat.state;if(e.type===`set_cwd`&&e.path){let n=(r?.cwd??``).trim().replace(/[\\/]+$/,``).toLowerCase(),i=e.path.trim().replace(/[\\/]+$/,``).toLowerCase();i&&i!==n&&t({type:`transition_start`,kind:`cwd`,target:e.path,progress:14,text:`正在切换到工作目录:${e.path}`,textEn:`Switching to workspace: ${e.path}`})}else if(e.type===`switch_session`&&e.path){let n=(r?.sessionFile??``).trim().replace(/[\\/]+$/,``).toLowerCase(),i=e.path.trim().replace(/[\\/]+$/,``).toLowerCase();i&&i!==n&&t({type:`transition_start`,kind:`session`,target:e.path,progress:14,text:`正在流式载入历史会话…`,textEn:`Streaming session history…`})}else e.type===`new_chat`?r&&(r.messages.length>0||r.isStreaming)&&t({type:`transition_start`,kind:`new_chat`,target:r.cwd,progress:22,text:`正在初始化新对话…`,textEn:`Initializing new chat…`}):e.type===`switch_conversation`&&e.id&&r&&e.id!==r.conversationId&&t({type:`transition_start`,kind:`conversation`,target:e.id,progress:35,text:`正在切换对话…`,textEn:`Switching conversation…`});let i=n.current;if(i&&i.readyState===WebSocket.OPEN){if(e.type===`check_updates_all`&&e.force===!0&&t({type:`updates_check_started`}),e.type===`check_plugin_updates`&&t({type:`plugin_updates_check_started`}),i.send(JSON.stringify(e)),e.type===`question_answer`){if(e.owner){let n=O.current.chat.remoteQuestion;n&&n.id===e.id&&t({type:`remote_question`,question:null})}else{if(p.current.add(e.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}m.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,g.useCallback)((e,n)=>{let r=os({current:O.current.chat.question,source:m.current,snapshot:e,answered:p.current,activeConversationId:n});r.changed&&(m.current=r.source,t({type:`question`,question:r.question}))},[]);no(y);let x=(0,g.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(Yl());n.current=e,e.onopen=()=>{n.current===e&&(t({type:`status`,status:`open`}),i.current=0,s.current=Date.now(),e.send(JSON.stringify({type:`hello`,clientId:Fl(),locale:Cl()})))},e.onmessage=i=>{if(n.current!==e)return;s.current=Date.now();let a;try{a=JSON.parse(i.data)}catch{return}switch(a.type){case`ready`:if((O.current.chat.settings?.autoReload??!0)&&a.buildId&&a.buildId!==`20261011T13070`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}qa({engine:a.engine??`pi`,managed:!!a.managed,tabs:a.tabs,appVersion:a.appVersion,serverVersion:a.serverVersion,service:a.service}),t({type:`ready`,serverVersion:a.serverVersion,protocolVersion:a.protocolVersion,engine:a.engine,appVersion:a.appVersion,managed:a.managed,tabs:a.tabs,service:a.service}),p.current.clear(),t({type:`question`,question:null}),e.send(JSON.stringify({type:`get_state`})),e.send(JSON.stringify({type:`list_files`})),e.send(JSON.stringify({type:`list_models`})),e.send(JSON.stringify({type:`list_commands`})),e.send(JSON.stringify({type:`get_commands`})),a.managed||(e.send(JSON.stringify({type:`check_update`})),e.send(JSON.stringify({type:`check_updates_all`})));break;case`snapshot`:l.current=new Map,t({type:`snapshot`,state:a.state}),b(a.state.pendingQuestion,a.state.conversationId);break;case`snapshot_delta`:{let e=O.current.chat.state;if(e)(e.conversationId!==a.conversationId||e.rev!==a.baseRev)&&h();else{let e=n.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:`get_state`}))}t({type:`snapshot_delta`,msg:a}),b(a.state.pendingQuestion,a.conversationId);break}case`tool_delta`:_(a.conversationId,a.seq),t({type:`tool_delta`,toolCallId:a.toolCallId,toolName:a.toolName,delta:a.delta});break;case`tool_status`:t({type:`tool_status`,status:a});break;case`message_delta`:_(a.conversationId,a.seq),t({type:`message_delta`,msg:a});break;case`subagent_handoff`:break;case`notice`:{let e=++c.current;(a.level===`error`||a.level===`warning`)&&t({type:`transition_clear`}),t({type:`notice`,notice:{id:e,level:a.level,text:a.text,textEn:a.textEn}});break}case`transition_progress`:t({type:`transition_progress`,msg:a});break;case`sessions`:t({type:`sessions`,sessions:a.sessions});break;case`conversations`:t({type:`conversations`,conversations:a.conversations,activeId:a.activeId,elsewhere:a.elsewhere});break;case`projects`:t({type:`projects`,projects:a.projects});break;case`sandbox_diff`:t({type:`sandbox_diff`,diff:a.diff});break;case`files`:t({type:`files`,files:a});break;case`file_changed`:t({type:`file_changed`,path:a.path});break;case`file_content`:t({type:`file_content`,content:a});break;case`models`:t({type:`models`,models:a.models,loading:!1});break;case`models_config`:t({type:`models_config`,providers:a.providers});break;case`providers_status`:t({type:`providers_status`,providers:a.providers});break;case`provider_keys`:t({type:`provider_keys`,keys:a.keys});break;case`default_model`:t({type:`default_model`,modelId:a.modelId});break;case`provider_oauth_started`:case`provider_oauth_flows`:case`provider_oauth_prompt`:case`provider_oauth_event`:case`provider_oauth_result`:case`provider_oauth_logout_result`:t({type:`provider_oauth`,message:a});break;case`fetch_models_result`:t({type:`fetch_models_result`,result:{reqId:a.reqId,ok:a.ok,models:a.models,error:a.error}});break;case`test_model_connection_result`:t({type:`test_model_connection_result`,result:{reqId:a.reqId,ok:a.ok,latencyMs:a.latencyMs,error:a.error}});break;case`enrich_models_progress`:t({type:`enrich_models_progress`,progress:{reqId:a.reqId,phase:a.phase,current:a.current,total:a.total,message:a.message}});break;case`enrich_models_result`:t({type:`enrich_models_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,error:a.error}});break;case`refresh_provider_result`:t({type:`refresh_provider_result`,result:{reqId:a.reqId,ok:a.ok,added:a.added,total:a.total,error:a.error}});break;case`refresh_builtin_result`:t({type:`refresh_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`append_builtin_result`:t({type:`append_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`clone_provider_result`:t({type:`clone_provider_result`,result:{reqId:a.reqId,ok:a.ok,config:a.config,configs:a.configs,error:a.error}});break;case`scm_data`:t({type:`scm_data`,data:a});break;case`search_files_result`:t({type:`file_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,truncated:a.truncated}});break;case`session_search_results`:t({type:`session_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results}});break;case`scm_changed`:t({type:`scm_changed`});break;case`tool_info`:gs(a);break;case`tool_prompt`:Ts(a);break;case`compacted_messages_result`:Is(a);break;case`heartbeat`:a.hostMetrics&&t({type:`host_metrics`,metrics:a.hostMetrics});break;case`install_result`:t({type:`install_result`,result:a});break;case`path_completions`:t({type:`path_completions`,completions:a.completions});break;case`update_status`:t({type:`update_status`,status:a});break;case`update_status_all`:t({type:`update_status_all`,items:a.items,piSdk:a.piSdk});break;case`widgets`:t({type:`widgets`,widgets:a.widgets});break;case`statuses`:t({type:`statuses`,statuses:a.statuses});break;case`dialog`:t({type:`dialog`,dialog:{id:a.id,kind:a.kind,title:a.title,args:a.args}});break;case`dialog_closed`:t({type:`dialog`,dialog:null});break;case`tui_overlay_open`:t({type:`tui_overlay`,overlay:{id:a.id,title:a.title,cols:a.cols,rows:a.rows,initialAnsi:a.initialAnsi}});break;case`tui_overlay_render`:ls(a.id,a.ansi);break;case`tui_overlay_close`:t({type:`tui_overlay`,overlay:null});break;case`question_pending`:m.current=`live`,t({type:`question`,question:{id:a.id,...a.deadline===void 0?{}:{deadline:a.deadline},questions:a.questions,...a.conversationId===void 0?{}:{conversationId:a.conversationId},...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`tool_approval_pending`:t({type:`tool_approval`,approval:{id:a.id,toolCallId:a.toolCallId,toolName:a.toolName,params:a.params,reason:a.reason,reasonEn:a.reasonEn,...a.category?{category:a.category}:{},...a.conversationId===void 0?{}:{conversationId:a.conversationId},...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`tool_approval_resolved`:t({type:`tool_approval`,approval:null});break;case`question_retracted`:{let e=O.current.chat.question;if(e&&e.id===a.id){if(p.current.add(a.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}m.current=`live`,t({type:`question`,question:null})}break}case`elsewhere_question`:t({type:`remote_question`,question:{owner:a.owner,convId:a.convId,id:a.id,questions:a.questions,...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`page_request`:(async()=>{let e=window.__piWebUiHost,t;if(!e?.pageCall)t={ok:!1,error:`宿主页面桥不可用(页面版本过旧?)—— 刷新本页后再试`};else try{t=await e.pageCall({op:a.op,...a.args===void 0?{}:{args:a.args},...a.target?{target:a.target}:{},timeoutMs:a.timeoutMs})}catch(e){t={ok:!1,error:e instanceof Error?e.message:String(e)}}y({type:`page_response`,id:a.id,ok:t.ok===!0,...t.ok===!0?t.result===void 0?{}:{result:t.result}:{error:t.error??`页面操作失败`}})})();break;case`terminal_output`:r.current.write(a.conversationId??O.current.chat.activeConversationId,a.terminalId,a.data);break;case`terminal_exit`:t({type:`terminal_exit`,conversationId:a.conversationId,terminalId:a.terminalId,exitCode:a.exitCode});break;case`terminal_list`:t({type:`terminal_list`,conversationId:a.conversationId,terminals:a.terminals});break;case`commands`:t({type:`commands`,commands:a.commands,path:a.path});break;case`slash_commands`:t({type:`slash_commands`,commands:a.commands});break;case`goal_status`:t({type:`goal_status`,status:a.status});break;case`plan_updated`:t({type:`plan_updated`,conversationId:a.conversationId,plan:a.plan});break;case`settings_state`:t({type:`settings`,settings:a.settings});break;case`mcp_servers`:t({type:`mcp_servers`,servers:a.servers,globalConfigPath:a.globalConfigPath,projectConfigPath:a.projectConfigPath});break;case`mcp_market_result`:t({type:`mcp_market_result`,result:a});break;case`skill_market_result`:t({type:`skill_market_result`,result:a});break;case`skill_content_result`:t({type:`skill_content_result`,result:a});break;case`bg_servers`:t({type:`bg_servers`,servers:a.servers});break;case`scheduler_tasks`:t({type:`scheduler_tasks`,tasks:a.tasks});break;case`plugin_panel_items`:t({type:`plugin_panel_items`,groups:a.groups});break;case`plugins`:t({type:`plugins`,plugins:a.plugins,epoch:a.epoch});break;case`plugin_updates`:t({type:`plugin_updates`,updates:a.updates});break;case`plugin_catalog`:t({type:`plugin_catalog`,entries:a.entries,epoch:a.epoch});break;case`plugin_grants`:t({type:`plugin_grants`,grants:a.grants});break;case`plugin_permissions`:t({type:`plugin_permissions`,grants:a.grants});break;case`plugin_permission_request`:t({type:`plugin_permission_request`,req:{id:a.id,pluginId:a.pluginId,family:a.family,...a.hosts?{hosts:a.hosts}:{},...a.models?{models:a.models}:{},...a.reason?{reason:a.reason}:{}}});break;case`plugin_permission_resolved`:t({type:`plugin_permission_resolved`,id:a.id});break;case`plugin_path_request`:t({type:`plugin_path_request`,req:{id:a.id,pluginId:a.pluginId,path:a.path,...a.reason?{reason:a.reason}:{}}});break;case`plugin_dom_consent_request`:a.from===Fl()&&e.send(JSON.stringify({type:`plugin_dom_consent_response`,id:a.id,ok:!0}));break;case`plugin_job`:t({type:`plugin_job`,job:{jobId:a.jobId,action:a.action,pluginId:a.pluginId,phase:a.phase,...a.ok===void 0?{}:{ok:a.ok},...a.error?{error:a.error}:{},...a.output?{output:a.output}:{}},...a.line?{line:a.line}:{}});break;case`plugin_install_inspect_result`:t({type:`plugin_install_inspect_result`,result:{requestId:String(a.requestId??``),source:String(a.source??``),kind:a.kind,suggestedId:String(a.suggestedId??``),installed:a.installed===!0,...a.problem?{problem:a.problem}:{},...a.detail?{detail:a.detail}:{},...a.manifest?{manifest:a.manifest}:{}}});break;case`plugin_catalog_sync_result`:Ac(a),t({type:`plugin_catalog_sync_result`,result:{requestId:String(a.requestId??``),ok:a.ok===!0,...a.error?{error:a.error}:{},...a.entries?{entryCount:a.entries.length}:{},...a.installed?{installed:a.installed}:{}}});break;case`preset_export_result`:t({type:`preset_export_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,...a.name?{name:a.name}:{},...a.fileName?{fileName:a.fileName}:{},...a.json?{json:a.json}:{},...a.error?{error:a.error}:{}}});break;case`preset_import_result`:{let e=String(a.requestId??``),n=e.startsWith(`url:`)?`url`:e.startsWith(`file:`)?`file`:`paste`;t({type:`preset_import_result`,source:n,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,dryRun:a.dryRun===!0,...a.preview?{preview:a.preview}:{},...a.applied?{applied:!0}:{},...a.error?{error:a.error}:{}}});break}case`preset_catalog_result`:t({type:`preset_catalog_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,entries:a.entries??[],source:a.source??``,cached:a.cached===!0,fetchedAt:a.fetchedAt??0,...a.error?{error:a.error}:{}}});break;case`preset_share_result`:t({type:`preset_share_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,...a.method?{method:a.method}:{},...a.url?{url:a.url}:{},...a.name?{name:a.name}:{},...a.json?{json:a.json}:{},...a.error?{error:a.error}:{}}});break;case`dsh_patches`:t({type:`dsh_patches`,patchDir:a.patchDir,files:a.files});break;case`dsh_presets`:t({type:`dsh_presets`,presets:a.presets,defaultPreset:a.defaultPreset});break;case`dsh_permission`:t({type:`dsh_permission`,options:a.options,defaultPreset:a.defaultPreset});break;case`plugin_data`:ml(a.pluginId,a.payload)||Ic(a.pluginId,a.payload);break;case`remote_ssh_probe_result`:case`remote_ssh_list_dir_result`:case`remote_ssh_install_result`:case`remote_ssh_profiles_result`:ao(a)}},e.onclose=()=>{if(n.current===e&&(n.current=null),r.current.clear(),!o.current||n.current&&n.current!==e)return;t({type:`status`,status:`closed`});let s=Math.min(1e3*2**i.current,1e4);i.current+=1,a.current=setTimeout(()=>{a.current=null,x()},s)},e.onerror=()=>{}},[]);(0,g.useEffect)(()=>{let e=e=>{let t=e.detail??Cl();t&&y({type:`set_locale`,locale:t})};return window.addEventListener(wl,e),()=>window.removeEventListener(wl,e)},[y]),(0,g.useEffect)(()=>{let n=n=>{let r=e.state?.cwd;r&&n.key&&n.key===Gl(r)&&t({type:`sync_cached_sessions`,sessions:Kl(r)})};return window.addEventListener(`storage`,n),()=>window.removeEventListener(`storage`,n)},[e.state?.cwd]),(0,g.useEffect)(()=>{o.current=!0,x();let e=setInterval(()=>{if(!o.current)return;let e=n.current;e&&e.readyState===WebSocket.OPEN&&Date.now()-s.current>3e4&&e.close()},5e3),t=()=>{if(!o.current||typeof document<`u`&&document.visibilityState===`hidden`)return;let e=n.current;if(!e||e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING){a.current&&=(clearTimeout(a.current),null),x();return}e.readyState===WebSocket.OPEN&&(Date.now()-s.current>15e3||!O.current.chat.state)&&e.send(JSON.stringify({type:`get_state`}))};return typeof document<`u`&&document.addEventListener(`visibilitychange`,t),typeof window<`u`&&(window.addEventListener(`pageshow`,t),window.addEventListener(`online`,t)),()=>{o.current=!1,clearInterval(e),a.current&&=(clearTimeout(a.current),null),typeof document<`u`&&document.removeEventListener(`visibilitychange`,t),typeof window<`u`&&(window.removeEventListener(`pageshow`,t),window.removeEventListener(`online`,t)),n.current?.close(),n.current=null}},[x]),(0,g.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=Ll();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}f.current!==t&&(f.current=t,Rl(t))}},[e.state?.cwd,y]),(0,g.useEffect)(()=>{qa({ready:e.ready,status:e.status,cwd:e.state?.cwd??``,workspaceRoots:e.state?.workspaceRoots??[],homeDir:e.state?.homeDir??``,desktopDir:e.state?.desktopDir??``})},[e.ready,e.status,e.state?.cwd,e.state?.workspaceRoots,e.state?.homeDir,e.state?.desktopDir]);let S=(0,g.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,g.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,g.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,g.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,g.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,g.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,g.useRef)({chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}});return O.current={chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}},O.current}function Zl(e){let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`:`${t.getMonth()+1}/${t.getDate()}`}function Ql(e){let t=e instanceof HTMLElement?e:null;if(!t)return!1;let n=t.tagName;return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable}var $l=`pi-web-ui:lp-collapse-projects`,eu=`pi-web-ui:lp-collapse-convs`,tu=`pi-web-ui:lp-collapse-sessions`,nu=`pi-web-ui:lp-collapse-subagents`;function ru(){let[e,t]=(0,g.useState)(()=>{try{let e=localStorage.getItem(nu);if(e)return new Set(JSON.parse(e))}catch{}return new Set});return[e,(0,g.useCallback)(e=>{t(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem(nu,JSON.stringify([...n]))}catch{}return n})},[])]}function iu(e,t=!1){let[n,r]=(0,g.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,g.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var au=`pi-web-ui:lp-collapse-plugin-sections`;function ou(){let[e,t]=(0,g.useState)(()=>{try{let e=localStorage.getItem(au),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`):[])}catch{return new Set}});return[e,(0,g.useCallback)(e=>{t(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem(au,JSON.stringify([...n]))}catch{}return n})},[])]}var su=`pi-web-ui:lp-sizes`,cu={projects:1,convs:1,sessions:1},lu=32,uu={running:`pluginRunStatusRunning`,done:`pluginRunStatusDone`,error:`pluginRunStatusError`},du=72;function fu(){try{return Ri(localStorage.getItem(su),cu)}catch{return{...cu}}}var pu=(0,g.memo)(function({sessionFile:e,conversations:t,elsewhere:n,sessions:r,projects:i,activeConversationId:a,panelSend:o,active:s,collapsible:c,onToggleCollapse:l,pathCompletions:u,uiContextSession:d,uiLeftSessions:f,uiContextProject:p,uiProjectsActions:m,uiLeftProject:h,uiRunningActions:_,uiHistoryActions:v,uiSections:y,renderPluginSectionBody:b,uiPluginRunning:x,onPluginRunningAction:S,uiLeftRunning:C,uiLeftHistory:w,onUiAction:T,presetNames:E,transition:D,onOpenSandboxModal:O}){let k=Z(),A=e,j=Za(`ready`),ee=Za(`status`),M=Za(`cwd`),te=Za(`workspaceRoots`),N=M,[ne,F]=(0,g.useState)(!1),[re,ie]=(0,g.useState)(null),[ae,I]=(0,g.useState)(null),[R,z]=(0,g.useState)(null),[oe,B]=(0,g.useState)(``),[V,H]=iu($l,!1),[se,ce]=iu(eu,!1),[le,ue]=iu(tu,!1),[U,de]=ou(),[fe,W]=ru(),[pe,G]=(0,g.useState)(60);(0,g.useEffect)(()=>{G(60)},[N]);let K=(0,g.useMemo)(()=>{if(r.length<=pe)return r;let e=A?r.findIndex(e=>e.path===A):-1,t=e>=pe?e+10:pe;return r.slice(0,t)},[r,pe,A]),he=(0,g.useCallback)((e,t)=>{if(!t)return e.filter(e=>e.isSubagent&&!e.isStreaming&&e.id!==a).length;let n=new Map(e.map(e=>[e.id,e])),r=e=>{if(e.id===t)return(n.get(t)?.isSubagent??!1)&&!e.isStreaming&&e.id!==a;let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&!e.isStreaming&&e.id!==a&&r(e)).length},[a]),ge=(0,g.useCallback)((e,t)=>{if(!t)return e.filter(e=>e.isSubagent).length;let n=new Map(e.map(e=>[e.id,e])),r=e=>{if(e.id===t)return n.get(t)?.isSubagent??!1;let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&r(e)).length},[]),q=(0,g.useCallback)((e,t)=>{if(!t)return 0;let n=new Map(e.map(e=>[e.id,e])),r=e=>{let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&e.isStreaming&&r(e)).length},[]),ve=(0,g.useRef)(null),ye=(0,g.useRef)(null),be=(0,g.useRef)(()=>{}),xe=La(d??[]).length>0,Se=(0,g.useCallback)((e,n,i)=>{ve.current={x:e,y:n,target:i};let a=i.kind===`running`?i.id:void 0,o=i.kind===`elsewhere`,s=a??(o&&i.id||void 0),c=he(t,a),l=c===0?k(`noFinishedSubagents`):k(a?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:c}),u=!!a&&ye.current===a;Ea({x:e,y:n,slot:`contextmenu.session`,target:i,entries:(d??[]).map(e=>{if(e.source!==`host`)return e;if(e.id===`host:conv-rename`)return i.kind===`running`||i.kind===`history`?e:{...e,hidden:!0};if(e.id===`host:conv-takeover`)return o&&s&&i.owner&&!i.pseudo?e:{...e,hidden:!0};if(o&&(e.id===`host:conv-dismiss-subagents`||e.id===`host:conv-force-dismiss`))return{...e,hidden:!0};if(e.id===`host:conv-dismiss-subagents`)return{...e,label:l,...c===0?{when:[...e.when??[],`disabled`]}:{}};if(e.id===`host:conv-force-dismiss`)return a?{...e,...u?{label:k(`forceDismissConfirm`)}:{}}:{...e,hidden:!0};if(e.id===`host:conv-pin`){if(i.kind===`history`)return r.find(e=>e.path===i.id)?.pinned?{...e,label:k(`unpinConversation`)}:e;if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return!n||n.isSubagent?{...e,hidden:!0}:n.pinned?{...e,label:k(`unpinConversation`)}:e}if(e.id===`host:conv-persist`){if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return!n||!n.isSubagent&&n.sessionFile?{...e,hidden:!0}:n?.isEphemeral?{...e,label:k(`saveEphemeral`)}:e}if(e.id===`host:conv-copy-id`)return s?e:{...e,hidden:!0};if(e.id===`host:conv-copy-path`)return i.kind===`history`?e:a?t.some(e=>e.id===a&&e.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}:{...e,hidden:!0};if(e.id===`host:conv-copy-link`){if(i.kind===`history`)return r.find(e=>e.path===i.id)?.sessionId||rs(i.id)?e:{...e,hidden:!0};if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return n?.sessionId||rs(n?.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}}return e.id===`host:conv-quote`?s||i.kind===`history`?e:{...e,hidden:!0}:e}),onHostAction:(e,t)=>be.current(e,t)})},[d,t,he,k]);be.current=(0,g.useCallback)((e,n)=>{let i=n.kind===`running`?n.id:void 0,a=i??(n.kind===`elsewhere`&&n.id||void 0);if(e.id===`host:conv-takeover`){n.kind===`elsewhere`&&a&&n.owner&&o({type:`take_over_conversation`,owner:n.owner,id:a});return}if(e.id===`host:conv-dismiss-subagents`){o(i?{type:`dismiss_finished_subagents`,parentId:i}:{type:`dismiss_finished_subagents`});return}if(e.id===`host:conv-force-dismiss`){let e=ve.current;if(!i||!e)return;if(ye.current!==i)return ye.current=i,Se(e.x,e.y,e.target),!0;ye.current=null,o({type:`dismiss_conversation`,id:i,force:!0});return}if(e.id===`host:conv-persist`){i&&o({type:`persist_conversation`,id:i});return}if(e.id===`host:conv-pin`){if(n.kind===`history`){let e=r.find(e=>e.path===n.id);o({type:`pin_session`,path:n.id,pinned:!e?.pinned});return}i&&o({type:`pin_conversation`,id:i,pinned:!t.find(e=>e.id===i)?.pinned});return}if(e.id===`host:conv-copy-id`&&a){navigator.clipboard?.writeText(a).catch(()=>{});return}if(e.id===`host:conv-copy-path`){let e=n.kind===`history`?n.id:i&&t.find(e=>e.id===i)?.sessionFile||void 0;e&&navigator.clipboard?.writeText(e).catch(()=>{});return}if(e.id===`host:conv-copy-link`){let e=n.kind===`history`?r.find(e=>e.path===n.id)?.sessionId||rs(n.id):i?t.find(e=>e.id===i)?.sessionId||rs(t.find(e=>e.id===i)?.sessionFile):null;if(e){let t=ns(window.location.href,{sessionId:e});navigator.clipboard?.writeText(t).catch(()=>{})}return}if(e.id===`host:conv-quote`){n.kind===`history`&&n.id?lr({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&lr({attachments:[{path:``,key:`conv|${a}|`,name:n.label||a,mode:`conversation`,conversationId:a}]});return}if(e.id===`host:conv-rename`){if(ie(null),i){let e=t.find(e=>e.id===i);B(e?.title??n.label??``),z(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);B(e?.name??n.label??``),z(n.id)}return}},[o,Se,t,r]);let Ce=(e,t,n)=>!e||e.length===0?null:(0,X.jsx)(`span`,{className:t,children:e.map((e,t)=>{let r=`${e.id}#${t}`,i=e.label||e.id,a=e.hint||i;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`lp-slot-divider`,"aria-hidden":`true`},r):e.kind===`badge`?(0,X.jsx)(`span`,{className:`lp-slot-badge`,title:a,children:e.badge??i},r):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`lp-slot-select`,title:a,"aria-label":i,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onClick:e=>e.stopPropagation(),onChange:t=>{t.stopPropagation(),T?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},r):(0,X.jsx)(`button`,{type:`button`,className:`lp-slot-btn`,title:a,"aria-label":i,onClick:t=>{t.stopPropagation(),n?T?.(e,void 0,n):T?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:i})},r)})}),we=(0,g.useCallback)((e,t)=>{Ql(e.target)||xe&&(e.preventDefault(),e.stopPropagation(),ye.current=null,Se(e.clientX,e.clientY,t))},[xe,Se]),Te=(0,g.useRef)(null),[De,Oe]=(0,g.useState)(()=>fu());(0,g.useEffect)(()=>{try{localStorage.setItem(su,JSON.stringify(De))}catch{}},[De]);let ke=(0,g.useMemo)(()=>{let e=new Set,r=new Set;for(let n of t)n.sessionFile&&e.add(n.sessionFile),r.add(`${n.cwd}\0${n.title}`);let i=[],a=new Set;for(let t of n){if(t.sessionFile&&e.has(t.sessionFile)||r.has(`${t.cwd}\0${t.title}`))continue;let n=t.sessionFile?`file:${t.sessionFile}`:`title:${t.cwd}\0${t.title}`;a.has(n)||(a.add(n),i.push({id:t.sessionFile?`elsewhere:${t.cwd}:${t.sessionFile}`:`elsewhere:${t.cwd}:${t.title}${t.owner?`:${t.owner}`:``}`,title:t.title,cwd:t.cwd,messageCount:0,isStreaming:t.isStreaming,isSubagent:!1,elsewhere:!0,pseudo:!!t.pseudo,ownerOffline:!!t.ownerOffline,sessionFile:t.sessionFile,...t.owner&&t.convId?{owner:t.owner,convId:t.convId}:{},...t.hasQuestion?{hasQuestion:!0}:{}}))}return[...t,...i]},[t,n]),Ae=Fi(y),je=Ae.filter(e=>e.shown),Me=e=>e===`projects`?V:e===`convs`?se:e===`sessions`?le:U.has(e),Ne=(x??[]).reduce((e,t)=>e+t.items.length,0),Pe=ke.length+Ne,Fe=Ii(Ae,e=>e===`projects`?i.length>0:e!==`convs`||Pe>0),Ie=()=>{let e=x??[];return e.length===0?null:e.map(e=>(0,X.jsxs)(`div`,{className:`panel-conv-group lp-plugin-group`,children:[(0,X.jsxs)(`div`,{className:`panel-conv-group-title`,title:e.pluginId,children:[k(`leftPanelPluginGroup`),` · `,e.pluginName]}),e.items.map(t=>(0,X.jsx)(`div`,{className:`lp-row lp-plugin-row`,children:(0,X.jsxs)(`button`,{type:`button`,className:`session-item lp-plugin-item${t.action?``:` is-static`}`,title:t.hint?`${t.title} — ${t.hint}`:t.title,onClick:()=>S?.(e,t),children:[(0,X.jsx)(`span`,{className:`lp-plugin-dot st-${t.status}`,title:k(uu[t.status])}),t.icon?(0,X.jsx)(`span`,{className:`lp-plugin-icon`,"aria-hidden":!0,children:t.icon}):null,(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:t.title}),t.hint?(0,X.jsx)(`span`,{className:`session-sub`,children:t.hint}):null]})]})},t.id))]},`plugin:${e.pluginId}`))},Le=(0,g.useMemo)(()=>[...f??[],...C??[]],[f,C]),Be=(0,g.useMemo)(()=>[...f??[],...w??[]],[f,w]),Ve=(0,g.useCallback)((e,t)=>n=>{n.preventDefault();let r=n.currentTarget,i=n.clientY,a={...De},o=Te.current;if(!o)return;let s=Fe.filter(e=>Me(e)).length,c=Fe.filter(e=>!Me(e)).reduce((e,t)=>e+(a[t]??1),0)||1,l=Math.max(120,o.clientHeight-s*lu);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let u=n=>{let{above:r,below:o}=Zo({start:{above:a[e]??1,below:a[t]??1},deltaPx:n.clientY-i,availablePx:l,totalWeight:c,minAbovePx:du,minBelowPx:du});Oe(n=>({...n,[e]:r,[t]:o}))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),r.classList.remove(`dragging`),document.body.classList.remove(`lp-resizing`)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)},[De,Fe,V,se,le]);(0,g.useEffect)(()=>{s&&j&&ee===`open`&&M&&(o({type:`list_sessions`}),o({type:`list_projects`}))},[s,j,ee,M,o]);let He=e=>{let t=e.name||e.firstMessage.trim();return t.length>0?t:k(`emptyChat`)},Ue=e=>e.split(/[\\/]/).pop()||e,We=La(p??[]).length>0,Ge=(0,g.useCallback)((e,t)=>{Ql(e.target)||We&&(e.preventDefault(),e.stopPropagation(),Ea({x:e.clientX,y:e.clientY,slot:`contextmenu.project`,target:{id:t.path,kind:`project`,label:Ue(t.path)},entries:p??[]}))},[We,p]),Y=(e,t,n,r,i)=>{let a=re===e;return(0,X.jsx)(`button`,{type:`button`,className:`lp-del ${a?`confirm`:``}`,title:a?n:t,onClick:t=>{t.stopPropagation(),a?(ie(null),r()):ie(e)},children:a?(0,X.jsx)(ft,{}):i??(0,X.jsx)(L,{})})},qe=(e,t,n,r,i,a)=>(0,X.jsxs)(`div`,{className:`lp-section-header`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`lp-section-title panel-section-title`,onClick:n,title:k(t?`expandSection`:`collapseSection`),children:[(0,X.jsxs)(`span`,{className:`lp-section-title-text`,children:[e,r===void 0?``:` (${r})`]}),(0,X.jsx)(`span`,{className:`lp-section-chevron`,children:t?(0,X.jsx)(dt,{}):(0,X.jsx)(ct,{})})]}),i||a?(0,X.jsxs)(`div`,{className:`lp-section-actions`,children:[i,a]}):null]}),Je=Fe.filter(e=>!Me(e)),Ye=Je.reduce((e,t)=>e+(De[t]??1),0)||1,Xe=e=>Je.length<=1?1:(De[e]??1)/Ye*Je.length,Ze=new Map(Li(Fe,Me).map(([e,t])=>[e,(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:Ve(e,t),onDoubleClick:()=>Oe({...cu}),title:k(`dragToResize`)},`sash-${e}`)])),Qe={projects:(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${V||i.length===0?`collapsed`:``}`,style:i.length>0&&!V?{flex:`${Xe(`projects`)} 1 0px`}:void 0,children:[qe(k(`recentProjects`),V,H,i.length,(0,X.jsxs)(X.Fragment,{children:[O&&(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action lp-sandbox-action`,title:k(`sandboxNewBtn`),"aria-label":k(`sandboxNewBtn`),onClick:()=>O(),children:(0,X.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:`13px`,lineHeight:1},children:`🧪`})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action`,title:k(`manageProjects`),"aria-label":k(`manageProjects`),onClick:()=>F(!0),children:(0,X.jsx)(ze,{})})]}),Ce(m,`lp-slot-section`)),i.length>0&&!V&&(0,X.jsx)(`div`,{className:`lp-section-body projects-scroll`,children:i.map(e=>{let t=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),n=N===e.path,r=D?.kind===`cwd`&&t(D.target)===t(e.path),i=e.sandbox,a=i?i.name:Ue(e.path);return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>ie(t=>t===`proj:${e.path}`?null:t),onContextMenu:t=>Ge(t,e),children:[(0,X.jsxs)(`button`,{type:`button`,className:`project-item ${n?`active`:``} ${r?`switching`:``}`,title:i?.sourcePath?`${a}\n${k(`sandboxSourceLabel`)}: ${i.sourcePath}\n${e.path}`:e.path,disabled:r,onClick:()=>{!n&&!r&&o({type:`set_cwd`,path:e.path})},children:[r?(0,X.jsx)(Ee,{className:`project-icon spin`}):i?(0,X.jsx)(`span`,{className:`project-icon sandbox-icon`,"aria-hidden":!0,children:`🧪`}):(0,X.jsx)(Re,{className:`project-icon`}),(0,X.jsxs)(`span`,{className:`project-info`,children:[(0,X.jsxs)(`span`,{className:`project-name`,children:[a,i&&(0,X.jsx)(`span`,{className:`lp-sandbox-badge ${i.ephemeral?`ephemeral`:`permanent`}`,children:i.ephemeral?k(`sandboxBadgeEphemeral`):k(`sandboxBadgePermanent`)})]}),(0,X.jsx)(`span`,{className:`project-path`,children:i?.sourcePath?`← ${Ue(i.sourcePath)} · ${e.path}`:e.path})]}),(0,X.jsx)(`span`,{className:`project-time ${r?`switching-pct`:``}`,children:r?`${D.progress}%`:Zl(e.lastUsed)})]}),Y(`proj:${e.path}`,k(i?`sandboxActionDestroyTip`:`deleteProject`),k(i?`sandboxActionDestroy`:`deleteProjectConfirm`),()=>{zl(e.path),Ul(e.path),o(i?{type:`destroy_sandbox`,path:e.path}:{type:`remove_project`,path:e.path})}),Ce(h,`lp-slot-project`,{id:e.path,kind:`project`,label:a})]},e.path)})})]})}),convs:(0,X.jsx)(X.Fragment,{children:Pe>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${se?`collapsed`:``}`,style:se?void 0:{flex:`${Xe(`convs`)} 1 0px`},onContextMenu:e=>we(e,{id:``,kind:`section`,label:k(`runningConversations`)}),children:[qe(k(`runningConversations`),se,ce,Pe,void 0,Ce(_,`lp-slot-section`)),!se&&(0,X.jsxs)(`div`,{className:`lp-section-body convs-scroll`,children:[Qo(ke,M,a).map(e=>(0,X.jsxs)(`div`,{className:`panel-conv-group`,children:[!e.isCurrent&&(0,X.jsx)(`div`,{className:`panel-conv-group-title`,title:e.cwd,onContextMenu:t=>Ge(t,{path:e.cwd,lastUsed:0}),children:Ue(e.cwd)}),$o(e.convs,fe).map(({c:n,depth:r,hasKids:i,isCollapsed:s,descendantCount:c,hasStreaming:l,hasError:u,hasQuestion:d})=>{if(n.elsewhere){let e=n.owner,t=n.convId,r=!!n.pseudo,i=!!n.ownerOffline&&!r,a=!!(e&&t)&&!r,s=ae===n.id,c=s?k(`takeoverConfirm`):r?`${k(`elsewherePseudoTip`)}\n${n.cwd}`:`${k(i?`elsewhereOfflineTip`:`elsewhereTip`)}\n${n.cwd}`;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>I(e=>e===n.id?null:e),onContextMenu:i=>we(i,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{},...r?{pseudo:!0}:{}}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item elsewhere-item${a?``:` elsewhere-static`}${s?` confirm`:``}`,title:c,tabIndex:a?0:-1,onClick:a?()=>{if(!s){I(n.id);return}I(null),o({type:`take_over_conversation`,owner:e,id:t})}:void 0,children:[(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsxs)(`span`,{className:`session-title`,children:[(0,X.jsx)(`span`,{className:`elsewhere-badge`,children:k(r?`elsewherePseudoBadge`:`elsewhereBadge`)}),i&&(0,X.jsx)(`span`,{className:`elsewhere-badge offline`,title:k(`elsewhereOfflineTip`),children:k(`elsewhereOfflineBadge`)}),n.hasQuestion&&e&&t&&!r&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:k(`takeoverHasQuestion`),onClick:n=>{n.stopPropagation(),o({type:`peek_elsewhere_question`,owner:e,id:t})},children:`?`}),s?k(`takeoverConfirm`):n.title]}),(0,X.jsx)(`span`,{className:`session-sub`,children:Ue(n.cwd)})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:k(`streaming`)})]}),xe&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-elsewhere-act`,title:k(`elsewhereActions`),onClick:i=>{i.stopPropagation(),ye.current=null;let a=i.currentTarget.getBoundingClientRect();Se(a.left,a.bottom+4,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{},...r?{pseudo:!0}:{}})},children:(0,X.jsx)(_e,{})})]},n.id)}let f=a===n.id;return(0,X.jsxs)(`div`,{className:`lp-row${r>0?` lp-sub`:``}${i?` lp-has-kids`:``}`,style:r>0?{marginLeft:r*18}:void 0,onMouseLeave:()=>ie(e=>e===`conv:${n.id}`?null:e),onContextMenu:e=>we(e,{id:n.id,kind:`running`,label:n.title}),children:[i&&(0,X.jsx)(`button`,{type:`button`,className:`lp-tree-caret${s?` collapsed`:` expanded`}`,title:k(s?`expandSubagents`:`collapseSubagents`),"aria-label":k(s?`expandSubagents`:`collapseSubagents`),onClick:e=>{e.stopPropagation(),W(n.id)},children:s?(0,X.jsx)(lt,{}):(0,X.jsx)(dt,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${f?`active`:``}`,title:`${n.title}${e.isCurrent?``:` — ${e.cwd}`}`,onClick:()=>{f||o({type:`switch_conversation`,id:n.id})},children:[(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[R===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:oe,placeholder:k(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>B(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=oe.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),z(null)}else e.key===`Escape`&&z(null)},onBlur:()=>z(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:k(`pinnedConversation`),children:`📌`}),n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:k(`subagentBadge`)}),n.isEphemeral&&(0,X.jsx)(`span`,{className:`ephemeral-badge`,children:k(`ephemeralBadge`)}),n.forkFrom&&(0,X.jsxs)(`span`,{className:`preset-badge fork-badge`,title:`${k(`forkBadgeTip`)}: ${n.forkFrom.title??n.forkFrom.conversationId}`,children:[`🌿 `,k(`forkBadge`)]}),n.agentPreset&&(0,X.jsx)(`span`,{className:`preset-badge`,title:n.agentPreset,children:E?.[n.agentPreset]??n.agentPreset}),n.title,n.error&&(0,X.jsx)(`span`,{className:`conv-error-badge`,title:k(`convErrorBadge`,{error:n.error})}),n.hasQuestion&&(0,X.jsx)(`span`,{className:`question-badge`,title:k(`waitingQuestionBadge`),children:`?`}),i&&s&&(0,X.jsxs)(`span`,{className:`subagents-collapsed-badge${l?` has-streaming`:d?` has-question`:u?` has-error`:``}`,title:k(l?`subagentsStreamingTip`:d?`subagentsQuestionTip`:u?`subagentsErrorTip`:`subagentsCountTip`,{n:c}),onClick:e=>{e.stopPropagation(),W(n.id)},children:[l&&(0,X.jsx)(`span`,{className:`subagent-dot streaming`}),d&&(0,X.jsx)(`span`,{className:`subagent-dot question`,children:`?`}),u&&(0,X.jsx)(`span`,{className:`subagent-dot error`}),(0,X.jsx)(`span`,{className:`subagents-count-text`,children:k(`subagentBadgeCount`,{n:c})})]})]}),R===`conv:${n.id}`?null:(0,X.jsx)(`span`,{className:`session-sub`,children:f?k(`current`):k(`messageCount`,{n:n.messageCount})})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:k(`streaming`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:k(`renameSession`),onClick:e=>{e.stopPropagation(),ie(null),B(n.title),z(`conv:${n.id}`)},children:(0,X.jsx)(Ke,{})}),(()=>{let e=`conv:${n.id}`,r=re===e,i=he(t,n.id),a=q(t,n.id),s=ge(t,n.id);return s===0&&!n.isStreaming?Y(e,k(`dismissConversation`),k(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(P,{})):s===0?Y(e,k(`dismissConversation`),k(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(P,{})):r?(0,X.jsxs)(`span`,{className:`lp-del-group`,children:[i>0&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt`,title:k(`dismissFinishedSubagentsScoped`,{n:i}),onClick:e=>{e.stopPropagation(),ie(null),o({type:`dismiss_finished_subagents`,parentId:n.id})},children:k(`dismissFinishedOnly`,{n:i})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt danger`,title:k(`forceDismissTitle`,{n:s,m:a}),onClick:e=>{e.stopPropagation(),ie(null),o({type:`dismiss_conversation`,id:n.id,force:!0})},children:k(`dismissForceAll`,{n:s})})]}):(0,X.jsx)(`button`,{type:`button`,className:`lp-del`,title:k(`dismissConversation`),onClick:t=>{t.stopPropagation(),ie(e)},children:(0,X.jsx)(P,{})})})(),Ce(Le,`lp-slot-sessions`),n.isStreaming&&(0,X.jsx)(`span`,{className:`lp-row-stalled`,title:k(`streaming`),style:{position:`absolute`,right:28,top:`50%`,transform:`translateY(-50%)`}})]},n.id)})]},e.cwd)),Ie()]})]})}),sessions:(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${le?`collapsed`:``}`,style:le?void 0:{flex:`${Xe(`sessions`)} 1 0px`},children:[qe(k(`historySessions`),le,ue,r.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-new-chat-action`,title:k(`newChatTip`),"aria-label":k(`newChat`),onClick:()=>{o({type:`new_chat`}),sr()},children:(0,X.jsx)(me,{})}),Ce(v,`lp-slot-section`)),!le&&(0,X.jsxs)(`div`,{className:`lp-section-body sessions-scroll`,onScroll:e=>{if(K.length>=r.length)return;let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<180&&G(e=>Math.min(r.length,e+60))},children:[r.length===0&&(0,X.jsx)(`div`,{className:`panel-empty`,children:k(`noHistory`)}),K.map(e=>{let t=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),n=A===e.path,r=D?.kind===`session`&&t(D.target)===t(e.path);return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>ie(t=>t===`sess:${e.path}`?null:t),onContextMenu:t=>we(t,{id:e.path,kind:`history`,label:He(e)}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${n?`active`:``} ${r?`switching`:``}`,title:e.path,disabled:r,onClick:()=>{R||r||n||o({type:`switch_session`,path:e.path})},children:[r?(0,X.jsx)(Ee,{className:`session-icon spin`}):(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[R===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:oe,placeholder:k(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>B(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=oe.trim();t&&o({type:`rename_session`,path:e.path,name:t}),z(null)}else t.key===`Escape`&&z(null)},onBlur:()=>z(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[e.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:k(`pinnedConversation`),children:`📌`}),He(e)]}),R===e.path?null:(0,X.jsxs)(`span`,{className:`session-sub`,children:[n?k(`current`):k(`messageCount`,{n:e.messageCount}),e.source===`tui`&&(0,X.jsx)(`span`,{className:`session-src`,title:k(`tuiTip`),children:`TUI`})]})]}),(0,X.jsx)(`span`,{className:`session-time ${r?`switching-pct`:``}`,children:r?`${D.progress}%`:Zl(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:k(`renameSession`),onClick:t=>{t.stopPropagation(),ie(null),B(e.name??``),z(e.path)},children:(0,X.jsx)(Ke,{})}),Y(`sess:${e.path}`,k(`deleteSession`),k(`deleteSessionConfirm`),()=>{Jl(e.path,N),o({type:`delete_session`,path:e.path})}),Ce(Be,`lp-slot-sessions`)]},e.path)})]})]})})},$e=e=>{let t=je.find(t=>t.key===e)?.entry;if(!t)return null;let n=Me(e);return(0,X.jsxs)(`div`,{className:`lp-section lp-section-plugin ${n?`collapsed`:``}`,style:n?void 0:{flex:`${Xe(e)} 1 0px`},children:[qe(t.label,n,()=>de(e)),!n&&(0,X.jsx)(`div`,{className:`lp-section-body lp-plugin-section-body`,children:b?.(t)??null})]})},et=e=>e===`projects`||e===`convs`||e===`sessions`?Qe[e]:$e(e);return(0,X.jsxs)(`aside`,{ref:Te,className:`panel panel-left lp-panel`,children:[c&&l&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:k(`collapsePanel`),onClick:l,children:(0,X.jsx)(st,{})}),je.map(({key:e})=>(0,X.jsxs)(g.Fragment,{children:[et(e),Ze.get(e)??null]},e)),(0,X.jsx)(So,{open:ne,currentCwd:N,pathCompletions:u??[],workspaceRoots:te,onClose:()=>F(!1),onSelectDirectory:e=>o({type:`set_cwd`,path:e}),onCreateProject:e=>o({type:`make_dir`,path:e,setAsCwd:!0})})]})}),mu=209715200,hu=/windows/i.test(navigator.userAgent),gu=/[<>:"/\\|?*\u0000-\u001f]/g,_u=/[. ]+$/,vu=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function yu(e){let t=e.replace(gu,`_`).replace(_u,``);return t?vu.test(t)?`_${t}`:t:`_`}function bu(e,t=!0){return gn(fn(`/api/file?${new URLSearchParams({clientId:Fl(),path:e,...t?{download:`1`}:{}})}`))}async function xu(e,t){let n=hu?yu(t):t;try{let t=await fetch(bu(e));if(!t.ok)return{ok:!1,cancelled:!1,error:await t.text().catch(()=>``)||(t.status===404?`FILE_NOT_FOUND`:`HTTP ${t.status}`)};if(Number(t.headers.get(`content-length`)??`0`)>mu)return window.location.assign(bu(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?Cu(r,n):wu(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function Su(e,t){let n=hu?yu(t):t;return window.showSaveFilePicker&&window.isSecureContext?Cu(e,n):wu(e,n)}async function Cu(e,t){let n,r=window.showSaveFilePicker;if(!r)return wu(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:wu(e,t)}try{let t=await n.createWritable();return await t.write(e),await t.close(),{ok:!0}}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}function wu(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);return r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),{ok:!0}}function Tu(e,t,n){let r=e.left-8,i=e.bottom+8;return r+t.width>n.width-8&&(r=Math.max(8,e.right+8-t.width)),i+t.height>n.height-8&&(i=Math.max(8,e.top-8-t.height)),{left:r,top:i}}function Eu(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function Du({text:e}){let t=(0,g.useRef)(null),n=(0,g.useRef)(null),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)({left:0,top:0}),s=()=>{let e=t.current?.getBoundingClientRect();e&&(o({left:Math.max(8,e.left-8),top:e.bottom+8}),i(!0))},c=()=>i(!1);return(0,g.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=Tu(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,g.useEffect)(()=>{if(!r)return;let e=0,a=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e=t.current,r=n.current;if(!e||!r)return;let a=e.getBoundingClientRect();if(a.bottom<0||a.top>window.innerHeight||a.right<0||a.left>window.innerWidth){i(!1);return}let s=Tu(a,r.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)})};return window.addEventListener(`scroll`,a,!0),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(e),window.removeEventListener(`scroll`,a,!0),window.removeEventListener(`resize`,a)}},[r]),(0,X.jsxs)(`span`,{ref:t,className:`set-tip`,tabIndex:0,"aria-label":e,onMouseEnter:s,onMouseLeave:c,onFocus:s,onBlur:c,onKeyDown:e=>{e.key===`Escape`&&e.target.blur()},children:[`?`,r&&(0,j.createPortal)((0,X.jsx)(`span`,{ref:n,className:`set-tip-bubble open`,role:`tooltip`,style:{position:`fixed`,left:a.left,top:a.top},children:e}),document.body)]})}var Ou=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function ku(e,t={}){let n={archive:fn(`/api/file-transfer/archive`),upload:fn(`/api/file-transfer/upload`)},r=new URL(gn(`${n[e]}?${new URLSearchParams({clientId:Fl(),...t})}`),window.location.href);if(r.origin!==window.location.origin||r.pathname!==new URL(n[e],window.location.href).pathname)throw Error(`File transfers must use an allowlisted same-origin endpoint`);return r}async function Au(e,t,n){let r=await fetch(ku(`archive`),{method:`POST`,headers:{"Content-Type":`application/json`,"X-File-Operation":`1`},body:JSON.stringify({action:e,path:t,...n})});if(!r.ok)throw Error(await r.text());if(e===`download`){let e=r.headers.get(`content-disposition`)??``,t=/filename\*=UTF-8''([^;]+)/i.exec(e)?.[1],n=/filename="([^"]+)"/i.exec(e)?.[1],i=t?decodeURIComponent(t):n??`archive.tar.gz`,a=await Su(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function ju(){let e=window.showDirectoryPicker;if(!e)return null;let t=await e.call(window),n=[];async function r(e,t){if(n.length>=2e4)throw Error(`Folder exceeds 20,000 entries`);if(n.push(e.kind===`file`?{path:t,file:await e.getFile()}:{path:t}),e.kind===`directory`)for await(let n of e.values())await r(n,`${t}/${n.name}`)}return await r(t,t.name),n}async function Mu(e,t,n){if(t.length>2e4)throw Error(`Folder exceeds 20,000 entries`);for(let e of t)if(e.file&&e.file.size>33554432)throw Error(`File exceeds 32 MiB: ${e.path}`);let r=0;for(let i of t){let t=ku(`upload`,{dir:e,name:i.path,kind:i.file?`file`:`directory`}),a=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-File-Operation":`1`},body:i.file??new Blob});if(!a.ok)throw Error(`${i.path}: ${await a.text()}`);n?.(++r)}}function Nu({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,g.useState)(e.dir),[o,s]=(0,g.useState)(`skip`),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(0),f=(0,g.useRef)(null),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(``),v=(0,g.useRef)(null);(0,g.useEffect)(()=>{v.current?.showModal()},[]);let y=r(e.action===`upload`?`fileUploadFolder`:e.action===`extract`?`fileExtract`:e.action===`download`?`fileCompressDownload`:`fileCompress`);async function b(){try{let e=await ju();e?l(e):f.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),m(!0),_(``);try{e.action===`upload`?await Mu(e.dir,c,d):await Au(e.action,e.path,{destination:i,policy:o}),n(),t()}catch(e){_(e instanceof Error?e.message:String(e)),n()}finally{m(!1)}}return(0,j.createPortal)((0,X.jsx)(`dialog`,{ref:v,className:`file-transfer-dialog`,"aria-labelledby":`file-transfer-title`,onCancel:e=>{e.preventDefault(),p||t()},children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),x()},children:[(0,X.jsxs)(`div`,{className:`file-transfer-head`,children:[(0,X.jsx)(`h3`,{id:`file-transfer-title`,children:y}),(0,X.jsx)(`button`,{type:`button`,className:`file-transfer-close`,title:r(`close`),"aria-label":r(`close`),disabled:p,onClick:t,children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`p`,{className:`file-transfer-path`,children:(e.action===`upload`?e.dir:e.path)||`.`}),(0,X.jsx)(`p`,{children:r(`fileArchiveLimits`)}),e.action===`extract`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`label`,{children:[r(`fileExtractDestination`),(0,X.jsx)(`input`,{value:i,disabled:p,onChange:e=>a(e.target.value)})]}),(0,X.jsxs)(`label`,{children:[r(`fileConflictPolicy`),(0,X.jsxs)(`select`,{value:o,disabled:p,onChange:e=>s(e.target.value),children:[(0,X.jsx)(`option`,{value:`skip`,children:r(`fileConflictSkip`)}),(0,X.jsx)(`option`,{value:`overwrite`,children:r(`fileConflictOverwrite`)}),(0,X.jsx)(`option`,{value:`error`,children:r(`fileConflictError`)})]})]})]}),e.action===`upload`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:r(`fileFolderUploadHint`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:p,onClick:()=>void b(),children:r(`fileChooseFolder`)}),(0,X.jsx)(`input`,{type:`file`,"aria-label":y,multiple:!0,hidden:!0,disabled:p,ref:e=>{f.current=e,e?.setAttribute(`webkitdirectory`,``)},onChange:e=>l(Array.from(e.target.files??[],e=>({path:e.webkitRelativePath||e.name,file:e})))}),(0,X.jsxs)(`p`,{"aria-live":`polite`,children:[u,` / `,c.length]})]}),h&&(0,X.jsx)(`p`,{role:`alert`,children:r(`fileTransferFailed`,{error:h})}),(0,X.jsxs)(`div`,{className:`file-transfer-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:p,onClick:t,children:r(`cancel`)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:p||e.action===`upload`&&c.length===0,children:p?r(`fileTransferBusy`):y})]})]})}),document.body)}function Pu(e){return e.startsWith(`.`)&&e!==`..`}function Fu(e,t){return t?e:e.filter(e=>!Pu(e.name))}function Iu(e){return e instanceof Error?e.message:String(e)}function Lu(e,t,n,r){let i=n===`zh`;switch(e.kind){case`no-client`:return i?`插件 ${t} 没有客户端脚本(client/entry.mjs),无法显示这一页。`:`Plugin ${t} ships no client bundle (client/entry.mjs), so this page cannot be shown.`;case`load`:return i?`插件 ${t} 的页面脚本加载失败:${e.detail}`:`Failed to load plugin ${t}'s page bundle: ${e.detail}`;case`mount`:return`${r(`pluginMountFailed`,{name:t})}:${e.detail}`}}function Ru({plugin:e,epoch:t,send:n,className:r}){let i=(0,g.useRef)(null),{locale:a}=Nn(),o=Z(),[s,c]=(0,g.useState)(null),l=(0,g.useRef)(n);(0,g.useEffect)(()=>{l.current=n},[n]),(0,g.useEffect)(()=>{let n=i.current;if(!n)return;let r=!1,a,o=!1;if(c(null),!e.hasClient){c({kind:`no-client`});return}return(async()=>{try{if(await nl(e,t),r)return;let i=await Ys(e.id,()=>Pc(()=>import(Zc(e.id,t)),[]));if(r)return;let s=i.default;if(!s||typeof s.mount!=`function`)throw Error(`client/entry.mjs 没有导出 default.mount()`);o=!0,a=s.mount(n,il(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:Iu(t)})}})(),()=>{if(r=!0,typeof a==`function`)try{a()}catch(t){console.error(`[plugin:${e.id}] cleanup 失败:`,t)}n.textContent=``}},[e.id,e.hasClient,t]);let u=r?`plugin-page ${r}`:`plugin-page`;return(0,X.jsxs)(`div`,{className:u,children:[(0,X.jsx)(`div`,{className:`plugin-page-host`,ref:i}),s&&(0,X.jsx)(`div`,{className:`plugin-page-error`,role:`alert`,children:Lu(s,e.name,a,o)})]})}function zu(e){return`pi-web-ui:${e}:tab`}function Bu(e,t){try{let n=localStorage.getItem(zu(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function Vu(e,t){try{localStorage.setItem(zu(e),t)}catch{}}function Hu(e){return e.length>0&&!/[a-z]/i.test(e)}function Uu(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function Wu({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,g.useId)(),[s,c]=(0,g.useState)(()=>Bu(e,t)??t[0]?.id??``),l=(0,g.useRef)([]),u=(0,g.useRef)(``),d=t.findIndex(e=>e.id===s),f=d>=0?t[d]:t[0],p=f?t.indexOf(f):-1;(0,g.useEffect)(()=>{if(!f)return;s!==f.id&&c(f.id);let t=`${e}:${f.id}`;u.current!==t&&(u.current=t,Vu(e,f.id))},[f,s,e]);let m=t=>{c(t.id),u.current=`${e}:${t.id}`,Vu(e,t.id)},h=(e,n)=>{let r=t.length,i=-1;if(e.key===`ArrowRight`)i=(n+1)%r;else if(e.key===`ArrowLeft`)i=(n-1+r)%r;else if(e.key===`Home`)i=0;else if(e.key===`End`)i=r-1;else return;let a=t[i];a&&(e.preventDefault(),m(a),l.current[i]?.focus())};if(!f)return null;let _=`${o}-panel-${p}`,v=a?`slot-tabs ${a}`:`slot-tabs`;return(0,X.jsxs)(`div`,{className:v,children:[(0,X.jsxs)(`div`,{className:`slot-tabs-bar`,role:`tablist`,children:[t.map((e,t)=>{let n=t===p;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,id:`${o}-tab-${t}`,className:n?`slot-tab active`:`slot-tab`,title:e.hint??Uu(e),"aria-selected":n,"aria-controls":`${o}-panel-${t}`,tabIndex:n?0:-1,ref:e=>{l.current[t]=e},onClick:()=>m(e),onKeyDown:e=>h(e,t),children:[e.iconSvg?(0,X.jsx)(hi,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&Hu(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:Uu(e)})]},e.id)}),i?(0,X.jsx)(`div`,{className:`slot-tabs-extra`,children:i}):null]}),(0,X.jsx)(`div`,{className:`slot-tabs-body`,id:_,role:`tabpanel`,"aria-labelledby":`${o}-tab-${p}`,children:f.pluginPage?(0,X.jsx)(Ru,{plugin:f.pluginPage.plugin,epoch:n,send:r}):f.element??null})]})}function Gu(e){if(typeof document>`u`)return!1;try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.style.top=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}async function Ku(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Gu(e)}return Gu(e)}function qu(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,g.useCallback)(()=>{s(),a(!1)},[s]);return(0,g.useEffect)(()=>()=>{s()},[s]),{copied:i,copy:(0,g.useCallback)(async e=>{let i=!1;try{i=await Ku(e)}catch(e){i=!1,r&&r(e)}return i?(a(!0),s(),o.current=setTimeout(()=>{a(!1),o.current=null},t),n?.(e)):r&&!i&&r(Error(`Copy failed`)),i},[t,n,r,s]),reset:c}}var Ju=`@root`,Yu=`pi-web-ui:rp-sizes`,Xu=`pi-web-ui:files-show-hidden`,Zu={files:4,widgets:1},Qu=120,$u=56;function ed(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var td=`files`,nd=[],rd=()=>{};function id(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function ad(e){return e===Ju||e===`/`||/^[A-Za-z]:$/.test(e)}function od(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var sd=(0,g.memo)(function({files:e,fileChanged:t,widgets:n,panelSend:r,onAttach:i,onPreview:a,onNotice:o,collapsible:s,onToggleCollapse:c,uiRightPanelTabs:l,uiContextFile:u,plugins:d,pluginsEpoch:f,send:p}){let m=Z(),h=d??nd,_=Za(`cwd`),v=Za(`workspaceRoots`),y=Za(`homeDir`),b=Za(`desktopDir`),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(null),[k,A]=(0,g.useState)(()=>{try{return Xo(localStorage.getItem(Yu),Zu)}catch{return{...Zu}}});(0,g.useEffect)(()=>{try{localStorage.setItem(Yu,JSON.stringify(k))}catch{}},[k]);let[j,ee]=(0,g.useState)(()=>{try{return localStorage.getItem(Xu)===`1`}catch{return!1}});(0,g.useEffect)(()=>{try{localStorage.setItem(Xu,j?`1`:`0`)}catch{}},[j]);let M=n.some(e=>e.lines.length>0),te=(0,g.useCallback)(e=>{e.preventDefault();let t=D.current;if(!t)return;let n=e.currentTarget,r=e.clientY,i={above:k.files,below:k.widgets},a=Math.max(120,t.clientHeight-ed(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=Zo({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:Qu,minBelowPx:$u});A({files:t,widgets:n})},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),n.classList.remove(`dragging`),document.body.classList.remove(`rp-resizing`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},[k.files,k.widgets]),N=(0,g.useRef)(null),ne=(0,g.useRef)(0),F=(0,g.useCallback)(e=>{N.current=e,e&&(e.scrollTop=ne.current)},[]),[re,ie]=(0,g.useState)(null),ae=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{ae.current&&clearTimeout(ae.current)},[]);let I=(0,g.useCallback)(e=>{ie(e),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>ie(null),1200)},[]),L=(0,g.useCallback)((e,t)=>{e&&Ku(e).then(e=>{e?I(t):o(`error`,m(`slashCopyFailed`))})},[I,o,m]),R=(0,g.useCallback)(e=>{if(!e)return _;if(/^[A-Za-z]:$/.test(e))return`${e}/`;if(e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e))return e;let t=_.replace(/\\/g,`/`).replace(/\/+$/,``);return t?`${t}/${e}`:e},[_]),z=(0,g.useCallback)(e=>!e||e===Ju?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),oe=104857600,B=(0,g.useCallback)((e,t)=>{for(let n of t){if(n.size>oe){o(`warning`,m(`fileTooLarge`,{name:n.name,size:oe/1024/1024}));continue}let t=new FileReader;t.onload=()=>{let i=t.result,a=i.slice(i.indexOf(`,`)+1);a&&r({type:`upload_file`,dirPath:e,name:n.name,data:a})},t.readAsDataURL(n)}},[r,o,m]),V=(0,g.useRef)(null),[H,se]=(0,g.useState)(null),ce=(0,g.useRef)(null),le=(0,g.useCallback)(()=>{let e=V.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),ue=(0,g.useCallback)(()=>{ce.current&&(ce.current.value=``),ce.current?.click()},[]),[U,de]=(0,g.useState)(null),[fe,W]=(0,g.useState)(null),[pe,G]=(0,g.useState)(``),[K,me]=(0,g.useState)(null),[he,ge]=(0,g.useState)(``),q=(0,g.useCallback)((e,t)=>{xu(e,t).then(e=>{e.ok||e.cancelled||o(`error`,m(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?m(`fileNotFoundShort`):e.error}))})},[o,m]),_e=(0,g.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!ad(e.id)&&(me(null),G(e.label),W(e.id))},[]),ve=(0,g.useCallback)(()=>{if(!fe)return;let e=pe.trim();W(null),e&&r({type:`file_rename`,path:fe,newName:e})},[fe,pe,r]),ye=(0,g.useCallback)(e=>{let t=V.current?.dir??x;W(null),ge(``),me({dir:t,kind:e})},[x]),be=(0,g.useCallback)(()=>{if(!K)return;let e=he.trim();me(null),e&&r({type:`file_create`,dir:K.dir,name:e,kind:K.kind})},[K,he,r]),xe=(e,t,n,r)=>(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:e,placeholder:m(`fileNamePlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>t(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing?n():e.key===`Escape`&&r()},onBlur:r}),J=(0,g.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!ad(e.id)&&window.confirm(m(`fileDeleteConfirm`,{name:e.label}))&&(U?.src===e.id&&de(null),fe===e.id&&W(null),r({type:`file_delete`,path:e.id}))},[r,m,U,fe]),Se=(0,g.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!ad(e.id)&&r({type:`file_copy`,src:e.id,destDir:id(e.id)})},[r]),Ce=(0,g.useCallback)(e=>{let t=V.current?.target;t&&t.kind!==`list`&&!ad(t.id)&&de({src:t.id,cut:e})},[]),Te=(0,g.useCallback)(()=>{if(!U)return;let e=V.current?.dir??x;U.cut?(r({type:`file_copy`,src:U.src,destDir:e,move:!0}),de(null)):r({type:`file_copy`,src:U.src,destDir:e})},[U,r,x]),Ee=(0,g.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[De,ke]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(!De)return;let e=e=>{e.target?.closest(`.root-picker`)||ke(!1)},t=e=>{e.key===`Escape`&&ke(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[De]);let Ae=(0,g.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),je=(0,g.useCallback)(()=>{let e=V.current?.target;if(!e||e.kind!==`dir`)return;let t=z(e.id);t&&!v.includes(t)&&Ae([...v,t])},[v,z,Ae]),Me=(0,g.useCallback)(e=>{B(V.current?.dir??x,Array.from(e.target.files??[]))},[B,x]),Ne=(0,g.useCallback)(e=>{let t=V.current?.target;switch(e.id){case`host:file-compress`:case`host:file-extract`:case`host:file-compress-download`:case`host:file-upload-folder`:{if(!t)break;let n=e.id===`host:file-compress`?`compress`:e.id===`host:file-extract`?`extract`:e.id===`host:file-compress-download`?`download`:`upload`;se({action:n,path:R(t.id),dir:R(n===`upload`?V.current?.dir??x:id(t.id))});break}case`host:file-open-project`:le();break;case`host:file-upload`:ue();break;case`host:file-add-root`:je();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&Je(t.id);break;case`host:file-download`:t?.kind===`file`&&q(t.id,t.label);break;case`host:file-reveal`:t&&r({type:`file_reveal`,path:t.id});break;case`host:file-open-default`:t?.kind===`file`&&r({type:`file_open_default`,path:t.id});break;case`host:file-attach-ref`:t?.kind===`file`&&i(t.id,t.label,`reference`);break;case`host:file-attach-folder`:t?.kind===`dir`&&i(t.id,t.label,`reference`,!0);break;case`host:file-new-file`:ye(`file`);break;case`host:file-new-dir`:ye(`dir`);break;case`host:file-paste`:Te();break;case`host:file-rename`:_e();break;case`host:file-duplicate`:Se();break;case`host:file-cut`:Ce(!0);break;case`host:file-copy`:Ce(!1);break;case`host:file-copy-name`:t&&t.kind!==`list`&&L(t.label,`name:${t.id}`);break;case`host:file-copy-path`:t&&t.kind!==`list`&&L(R(t.id),`path:${t.id}`);break;case`host:file-copy-rel`:t&&t.kind!==`list`&&L(t.id,`rel:${t.id}`);break;case`host:file-refresh`:Ee();break;case`host:file-delete`:J()}},[le,x,ue,je,a,i,L,R,q,ye,Te,_e,Se,Ce,Ee,J]),Pe=(0,g.useCallback)((e,t)=>{let n=t.kind===`dir`?z(t.id):null,r={target:t,dir:t.kind===`dir`?t.id:x,project:n?{path:n,name:t.label}:null},i=t.kind,a=i===`file`,o=i===`dir`,s=i===`list`,c=!s&&ad(t.id),l=!s&&od(t.id),d=x===Ju,f=(u??[]).map(e=>{if(e.source!==`host`)return e;switch(e.id){case`host:file-upload-folder`:return d?{...e,hidden:!0}:e;case`host:file-compress`:case`host:file-compress-download`:return!s&&!c?e:{...e,hidden:!0};case`host:file-extract`:return a&&Ou(t.label)?e:{...e,hidden:!0};case`host:file-upload`:return d?{...e,hidden:!0}:{...e,label:r.dir===x?m(`uploadToCurrentDir`):m(`uploadToFolder`)};case`host:file-open-project`:return n?e:{...e,hidden:!0};case`host:file-add-root`:return n&&n!==_&&!v.includes(n)?e:{...e,hidden:!0};case`host:file-open`:case`host:file-download`:case`host:file-open-default`:case`host:file-attach-ref`:return a?e:{...e,hidden:!0};case`host:file-reveal`:return!d&&t.id!==Ju?e:{...e,hidden:!0};case`host:file-enter`:case`host:file-attach-folder`:return o?e:{...e,hidden:!0};case`host:file-new-file`:case`host:file-new-dir`:return!a&&!d?e:{...e,hidden:!0};case`host:file-paste`:return!a&&!d&&U?e:{...e,hidden:!0};case`host:file-rename`:case`host:file-duplicate`:case`host:file-cut`:case`host:file-copy`:case`host:file-delete`:return!s&&!c?e:{...e,hidden:!0};case`host:file-copy-name`:case`host:file-copy-path`:return s?{...e,hidden:!0}:e;case`host:file-copy-rel`:return!s&&!l?e:{...e,hidden:!0};case`host:file-refresh`:return s?e:{...e,hidden:!0};default:return e}});La(f).length!==0&&(e.preventDefault(),e.stopPropagation(),V.current=r,Ea({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:Ne}))},[u,x,z,m,Ne,_,v,U]),Fe=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),Ie=(0,g.useCallback)(()=>{N.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),N.current?.classList.remove(`drop-root`)},[]),Le=(0,g.useCallback)(e=>{if(Ie(),e==null)return;let t=N.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):N.current?.classList.add(`drop-root`)},[Ie]),ze=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Ve=(0,g.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),He=(0,g.useRef)(0),Ge=(0,g.useRef)(void 0),Y=(0,g.useCallback)((e,t)=>{let n=++He.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||He.current===n&&E(!1)},[r]),Ke=(0,g.useCallback)(e=>{let t=v.filter(t=>t!==e);Ae(t),(x===e||x.startsWith(`${e}/`))&&Y(``)},[v,Ae,x,Y]);(0,g.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,g.useEffect)(()=>{if(_!==Ge.current){let e=Ge.current===void 0;Ge.current=_,e?Y(``,{silent:!0}):S(``);return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&Y(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,Y]),(0,g.useEffect)(()=>{t&&t.path===x&&Y(x,{silent:!0})},[t,x,Y]);let Je=e=>Y(e),Ye=()=>{e?.parent!==null&&e?.parent!==void 0&&Y(e.parent)},Xe=(()=>{if(x===``||x===Ju)return[];let e=x.split(`/`).filter(e=>!!e&&e!==Ju);return x.startsWith(`/`)?[{label:`/`,path:`/`},...e.map((t,n)=>({label:t,path:`/`+e.slice(0,n+1).join(`/`)}))]:e.map((t,n)=>({label:e[n],path:e.slice(0,n+1).join(`/`)}))})(),Ze=[];for(let e of l??[]){if(e.source===`host`||e.hidden||e.kind===`divider`)continue;let t=h.find(t=>t.id===e.source.slice(7));t&&Ze.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let Qe=(l??[]).some(e=>e.id===`host:right-files`&&e.hidden);return(0,X.jsxs)(`aside`,{className:`panel panel-right`,ref:D,children:[s&&c&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:m(`collapsePanel`),onClick:c,children:(0,X.jsx)(ot,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:M?`${k.files} 1 0`:`1 1 0`,minHeight:M?Qu:0},children:(0,X.jsx)(Wu,{storageKey:`rightpanel`,epoch:f??0,send:p??rd,tabs:(e=>{let t=(l??[]).filter(e=>!e.hidden);if(t.length===0)return e;let n=new Map(t.map((e,t)=>[e.id,t])),r=e=>n.get(e===td?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...Qe?[]:[{id:td,label:m(`openFiles`),element:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`panel-crumbs`,children:[(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===``?`active`:``}`,onClick:()=>Y(``),children:m(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===Ju?`active`:``}`,title:m(`computer`),onClick:()=>Y(Ju),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:m(`homeDir`),onClick:()=>Y(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:m(`desktopDir`),onClick:()=>Y(b),children:`🖥️`}),(0,X.jsx)(Du,{text:m(`filesHelp`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${j?`active`:``}`,title:m(j?`filesHideHidden`:`filesShowHidden`),"aria-label":m(j?`filesHideHidden`:`filesShowHidden`),"aria-pressed":j,onClick:()=>ee(e=>!e),children:j?(0,X.jsx)(We,{}):(0,X.jsx)(Ue,{})}),v.length>0&&(0,X.jsxs)(`div`,{className:`root-picker`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`crumb root-picker-trigger`,"aria-haspopup":`menu`,"aria-expanded":De,title:m(`workspaceRoots`),onClick:()=>ke(e=>!e),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:m(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),De&&(0,X.jsxs)(`div`,{className:`root-picker-menu`,role:`menu`,children:[(0,X.jsx)(`div`,{className:`root-picker-row`,children:(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:x===``?`root-picker-item active`:`root-picker-item`,title:_,onClick:()=>{ke(!1),Y(``)},children:[m(`rootDir`),(0,X.jsx)(`span`,{className:`root-picker-path`,children:_})]})}),v.map(e=>(0,X.jsxs)(`div`,{className:`root-picker-row`,children:[(0,X.jsx)(`button`,{type:`button`,role:`menuitem`,className:x===e?`root-picker-item active`:`root-picker-item`,title:e,onClick:()=>{ke(!1),Y(e)},children:(0,X.jsx)(`span`,{className:`root-picker-path`,children:e})}),(0,X.jsx)(`button`,{type:`button`,className:`root-picker-remove`,title:m(`removeWorkspaceRoot`),"aria-label":m(`removeWorkspaceRoot`),onClick:()=>Ke(e),children:(0,X.jsx)(P,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:m(`workspaceRootsHint`)})]})]}),Xe.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(lt,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>Y(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:F,className:`panel-body`,onScroll:e=>{ne.current=e.currentTarget.scrollTop},onContextMenu:e=>Pe(e,{id:x,kind:`list`,label:x===``?m(`rootDir`):x===Ju?m(`computer`):x}),onDragOver:e=>{Fe(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Ve(),Le(ze(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||Ie()},onDrop:e=>{if(Ie(),!Fe(e))return;e.preventDefault(),e.stopPropagation(),Ve();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,m(`foldersNotSupported`));return}B(ze(e.target),t)},onDragEnd:Ie,children:[(0,X.jsx)(`input`,{ref:ce,type:`file`,multiple:!0,hidden:!0,onChange:Me}),H&&(0,X.jsx)(Nu,{request:H,onClose:()=>se(null),onComplete:Ee}),K&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[K.kind===`dir`?(0,X.jsx)(Re,{className:`file-icon`}):(0,X.jsx)(Be,{className:`file-icon`}),xe(he,ge,be,()=>me(null))]}),T&&(0,X.jsx)(`div`,{className:`panel-empty`,children:m(`loading`)}),!T&&e&&e.path===x&&(0,X.jsxs)(X.Fragment,{children:[e.parent!=null&&(0,X.jsxs)(`button`,{type:`button`,className:`file-item dir`,onClick:Ye,children:[(0,X.jsx)(Re,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:`..`})]}),Fu(e.entries,j).map(e=>e.type===`dir`?(0,X.jsxs)(`div`,{className:`file-item dir${U?.cut&&U.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`dir`,label:e.name}),children:[fe===e.path?xe(pe,G,ve,()=>W(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>Je(e.path),children:[(0,X.jsx)(Re,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":m(`linkFolderTip`),"aria-label":m(`linkFolderTip`),onClick:()=>i(e.path,e.name,`reference`,!0),children:(0,X.jsx)(Oe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`name:${e.path}`?` copied`:``}`,"data-tip":m(`copyName`),"aria-label":m(`copyName`),onClick:()=>L(e.name,`name:${e.path}`),children:re===`name:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`path:${e.path}`?` copied`:``}`,"data-tip":m(`copyPath`),"aria-label":m(`copyPath`),onClick:()=>L(R(e.path),`path:${e.path}`),children:re===`path:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(it,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${U?.cut&&U.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`file`,label:e.name}),children:[fe===e.path?xe(pe,G,ve,()=>W(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-name`,title:`${e.path} — ${m(`previewFile`)}`,onClick:()=>a(e.path,e.name),children:[(0,X.jsx)(Be,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name-text`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach download`,"data-tip":m(`downloadFile`),onClick:()=>q(e.path,e.name),children:(0,X.jsx)(qe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":m(`referenceTip`),"aria-label":m(`referenceTip`),onClick:()=>i(e.path,e.name,`reference`),children:(0,X.jsx)(Oe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`name:${e.path}`?` copied`:``}`,"data-tip":m(`copyName`),"aria-label":m(`copyName`),onClick:()=>L(e.name,`name:${e.path}`),children:re===`name:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`path:${e.path}`?` copied`:``}`,"data-tip":m(`copyPath`),"aria-label":m(`copyPath`),onClick:()=>L(R(e.path),`path:${e.path}`),children:re===`path:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(it,{})})]},e.path)),e.truncated&&(0,X.jsx)(`div`,{className:`panel-empty files-truncated`,children:m(`filesTruncated`)})]}),!T&&!e&&(0,X.jsx)(`div`,{className:`panel-empty`,children:m(`noFiles`)})]})]})}],...Ze])})}),M&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:te,onDoubleClick:()=>A({...Zu}),title:m(`dragToResize`)}),M&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:$u},children:n.filter(e=>e.lines.length>0).map(e=>(0,X.jsxs)(`div`,{className:`widget`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`widget-title widget-title-btn`,title:m(`widgetExpand`),onClick:()=>w(e.key),children:[(0,X.jsx)(`span`,{children:e.key}),(0,X.jsx)(we,{})]}),(0,X.jsx)(`pre`,{className:`widget-lines`,children:e.lines.join(`
|
|
327
|
+
It only opens after you confirm.`,settingsExtensions:`Extensions`,settingsUiPlugins:`UI plugins`,pluginListTab:`Plugin list`,noUiPlugins:`No UI plugins installed (<dataDir>/plugins/)`,pluginPhaseActive:`Active`,pluginPhaseDisabled:`Disabled`,pluginPhaseFailed:`Failed`,pluginPhaseIdle:`Frontend-only`,pluginRescan:`Rescan`,pluginRescanHint:`Re-scan the plugin directory (picks up new/fixed plugins; failure records are cleared and re-evaluated)`,dshPatches:`DSH user patches`,dshPatchesDesc:`Cordis patches loaded at runtime boot, in filename order (<dataDir>/dsh-patches/*.yml). New/edited files take effect after 'Rescan' restarts the runtime; broken files are skipped and logged to runtime stderr.`,dshPatchesRescan:`Rescan`,dshPatchesRescanHint:`Re-scan the patch directory and restart the DSH runtime so new patches take effect`,dshPatchesEmpty:`No patch files yet`,dshPatchesPath:`Patch directory: `,dshPreset:`Agent preset`,dshPresetNewChat:`New chat with this preset`,dshPresetLocked:`Locked`,dshPresetBlankOnly:`Locked after the first message; blank sessions can switch`,dshPresetBroken:` (unavailable)`,dshPresetUser:`custom`,dshPresetDefaultTag:`default`,dshPresetMinimalNote:`Minimal: persistent shell only; host plugin tools and questionnaire unavailable`,dshDefaultPreset:`Default preset`,dshDefaultPresetDesc:`Preset for new chats; blank sessions can switch anytime, locked after the first message`,dshPresetUserNote:`Custom presets come from the user preset directory (trusted like shell access); compositions using bare package names cannot mount here (known limitation)`,"preset.standard":`Full access`,"preset.minimal":`Minimal`,"preset.code":`Code development`,"preset.reader":`Read-only analysis`,"preset.ask":`Chat only`,"preset.standardDesc":`All available tools and extension capabilities (default)`,"preset.minimalDesc":`Keeps only bash and read; plugin tools, skill catalog and terminal guidance are hidden too`,"preset.codeDesc":`Focused on reading, writing and running code (bash, read, edit, write, edit_soft); plugin tools and skill catalog are hidden too`,"preset.readerDesc":`Keeps only read-only tools and forbids writes; plugin tools are hidden too (read/write unknown, handled conservatively)`,"preset.askDesc":`No-tools Q&A: the model never calls a tool; plugin tools and skill catalog are hidden too`,dshPerm:`Permissions`,dshPermReadOnly:`Read Only`,dshPermReadOnlyDesc:`Read files and run read-only commands; writes are always denied, no prompts`,dshPermWorkspaceWrite:`Workspace Write`,dshPermWorkspaceWriteDesc:`Read/write inside the workspace, no prompts; out-of-scope operations are denied directly`,dshPermFullAccess:`Full access`,dshPermFullAccessDesc:`Sandbox off, unrestricted machine access; only for tasks you trust`,dshPermFullAccessTag:`risky`,dshPermCustom:`Custom`,dshPermConfirmFull:`Click again to confirm full access`,dshPermDefault:`Default permission for new chats`,dshPermDefaultDesc:`Initial permission for new chats; the current chat can switch live anytime, no restart`,uiPluginNoSource:`Installed manually — no recorded source, online update unavailable`,uiPluginPerms:`Permissions`,pluginDiagTitle:`Diagnostics`,pluginDiagShow:`Diagnostics`,pluginDiagHide:`Hide`,pluginLogTitle:`Runtime logs`,pluginLogShow:`Logs`,pluginLogHide:`Hide`,pluginLogLevel:`Level`,pluginLogAll:`All`,pluginLogEmpty:`No logs yet`,pluginLogClear:`Clear`,pluginDomNeed:`⚠ Requests full DOM access`,pluginDomDesc:`This plugin can freely read and write the page DOM (bypassing UI layout restrictions). Grant only to plugins from sources you trust; once granted its UI code can touch the topbar, composer and any page element.`,pluginDomGrant:`Grant DOM access`,pluginDomRevoke:`Revoke DOM access`,pluginDomGranted:`Full DOM access granted`,pluginSettingsTitle:`Configuration`,pluginSettingsShow:`Configure`,pluginSettingsHide:`Hide`,pluginSettingsSave:`Save plugin settings`,pluginSettingsSaving:`Saving…`,pluginSettingsReset:`Reset defaults`,pluginSettingsInherit:`Follow global default`,pluginSecretSet:`Set (stored encrypted, leave blank to keep)`,pluginSecretUnset:`Not set (stored encrypted)`,settingsPresets:`Presets`,settingsSubagentTemplates:`Subagent templates`,settingsSubagentTemplatesDesc:`Presets for spawned subagents (role system prompt + skills/extensions whitelist + optional model and thinking level). AI may pick a template (subagent_spawn template param) or spawn without one; disabled templates stay in the panel but are invisible to AI tools.`,noSubagentTemplates:`No subagent templates yet. AI can pick a template when spawning a subagent (role prompt + skills/extensions whitelist + optional model and thinking level), or spawn without a template param for default config.`,subagentTemplateNew:`New template`,subagentTemplateEdit:`Edit`,subagentTemplateClosed:`Disabled`,tplDefaultBadge:`Built-in`,subagentDefaultModelLabel:`Default subagent model`,subagentFollowMain:`Follow the main conversation's current model`,subagentDefaultModelHint:`Fallback model for all subagents (a template's own model and the subagent_spawn model param take priority); does not change the main conversation's model.`,subagentNoModels:`No usable models yet (configure a provider API key first) — subagents will follow the main conversation's model.`,subagentTemplateOffHint:`Disabled templates stay in the panel and can be re-enabled, but AI tools can't see or pick them`,subagentTemplateEnable:`Enable`,subagentTemplateDisable:`Disable`,tplNamePlaceholder:`Template name (referenced by AI via subagent_spawn's template param)…`,tplDescriptionPlaceholder:`Description (AI uses it to judge when to pick this template)…`,tplDescriptionEnPlaceholder:`English description (shown to AI under English UI; falls back to the description above)…`,tplPromptModeLabel:`System prompt mode`,tplModelLabel:`Model (empty = follow main conversation)`,tplThinkingLabel:`Thinking level`,tplThinkingFollowMain:`Follow the main conversation's current thinking level`,tplThinkingHint:`Empty = follow the main conversation's current thinking level (same idea as the model fallback); unsupported levels are clamped to the nearest one the model supports.`,tplSystemPromptLabel:`System prompt`,tplSystemPromptPlaceholder:`Template role system prompt… (may be empty in append mode)`,tplSystemPromptEnPlaceholder:`English system prompt… (used under English UI; falls back to the prompt above)`,tplWhitelistHint:`Whitelist: checked = the subagent only gets these; none checked = follow the main session settings`,tplSkillsLabel:`Skills whitelist`,tplExtensionsLabel:`Extensions whitelist`,tplSave:`Save template`,tplCancel:`Cancel edit`,tplDelete:`Delete template`,settingsScheduler:`Scheduled tasks`,schedulerDesc:`Put the agent on a schedule (dependency audits, test runs, morning briefings…): headless pseudo-client runs, no browser needed; notifies when done, history included.`,schedulerEmpty:`No scheduled tasks yet. Click “New task” above to schedule the first one: a 9 AM daily check or an hourly test run.`,schedulerNew:`New task`,schedulerEdit:`Edit`,schedulerDelete:`Delete`,schedulerRunNow:`Run now`,schedulerRunning:`Running…`,schedulerEnable:`Enable`,schedulerDisable:`Disable`,schedulerEnabled:`Enabled`,schedulerDisabled:`Disabled`,schedulerNamePlaceholder:`E.g. Daily dependency & health check…`,schedulerDescPlaceholder:`Description (optional): what this task does…`,schedulerCwdLabel:`Target project`,schedulerCwdPlaceholder:`/absolute/path/to/project…`,schedulerUseCurrentCwd:`Use current project`,schedulerKindLabel:`Schedule`,schedulerKindCron:`Cron expression`,schedulerKindInterval:`Fixed interval`,schedulerCronPlaceholder:`E.g. 0 9 * * * (daily 9:00 AM)`,schedulerPresetDaily:`Daily 9:00 AM`,schedulerPresetHourly:`Hourly on the hour`,schedulerPresetHalfHour:`Every 30 minutes`,schedulerPresetWorkday:`Weekdays 9:00 AM`,schedulerPresetMonday:`Mondays 9:00 AM`,schedulerPresetCustom:`Custom…`,schedulerIntervalMinutes:`Interval (minutes, min 1)`,schedulerPromptPlaceholder:`The task for the agent, e.g. audit dependencies and report upgrades…`,schedulerModelLabel:`Model (empty = default)`,schedulerThinkingLabel:`Thinking level (empty = default)`,schedulerCatchUp:`Catch up one missed run after restart`,schedulerCatchUpHint:`When checked, a trigger missed during downtime runs once at next startup; otherwise it is skipped.`,schedulerNextFire:`Next`,schedulerLastRun:`Last`,schedulerNeverRun:`Never ran`,schedulerHistory:`History`,schedulerManualBadge:`manual`,schedulerRunOk:`ok`,schedulerRunFail:`failed`,schedulerConfirmDelete:`Delete scheduled task “{name}”? Its history goes with it.`,schedulerSave:`Save task`,schedulerCancelEdit:`Cancel edit`,tplInherit:`Follow main session`,settingsEnabled:`Enabled`,settingsDisabled:`Disabled`,presetNamePlaceholder:`Preset name…`,saveAsPreset:`Save as preset`,applyPreset:`Apply`,deletePreset:`Delete preset`,noSkills:`No skills`,noExtensions:`No extensions`,noPresets:`No presets yet (tune your current settings, then enter a name above to save them as a preset)`,presetShare:`Share presets`,presetShareShareBtn:`Share preset`,presetShareImportBtn:`Import preset`,presetShareBrowseBtn:`Browse shared`,presetShareTabExport:`Export / share`,presetShareTabImport:`Import`,presetShareTabBrowse:`Browse shared`,presetShareSource:`Source`,presetShareSourceCurrent:`Current settings`,presetShareDescription:`Description`,presetShareDescriptionPlaceholder:`What is this preset good for? (optional)`,presetShareTags:`Tags`,presetShareTagsPlaceholder:`Comma separated, e.g. coding, minimal (optional)`,presetShareAuthor:`Author (optional)`,presetExportJson:`Export JSON`,presetExportDownload:`Download file`,presetShareSubmit:`Share to the community repo`,presetShareHint:`Creates a GitHub issue: with the gh CLI or a GitHub token it is submitted for you (the repo bot validates and commits it, and it shows up under "Browse shared" within minutes). With neither, a prefilled new-issue page opens — just hit Submit (for very large presets the JSON is copied to the clipboard instead, so you can paste it).`,presetShareSubmitting:`Submitting…`,presetShareOpenWebTitle:`Submit Issue on GitHub`,presetShareOpenWebBtn:`Open submission page in new window`,presetShareOpenIssueBtn:`View created issue`,presetShareCopyJson:`Copy preset JSON`,presetSharePopupBlocked:`If your browser blocked the popup, click the button below to open:`,presetShareBrowserCopied:`Submission page generated — just hit Submit (for large presets the JSON is on your clipboard, paste it)`,presetImportText:`Paste preset JSON`,presetImportTextPlaceholder:`Paste the exported JSON here (or drop a .json file)…`,presetImportPickFile:`Choose file`,presetImportFromUrl:`Import from URL`,presetImportUrlPlaceholder:`https://raw.githubusercontent.com/…/preset.json`,presetImportPreview:`Preview`,presetImportFields:`{n} fields will be written`,presetImportIgnored:`Unknown fields ignored: {list}`,presetImportRejected:`Dropped (wrong type): {list}`,presetImportReplaces:`A local preset with this name already exists — importing overwrites it`,presetImportApply:`Apply right after importing`,presetImportConfirm:`Import`,presetImportPick:`Import selectively: pick what to write`,presetImportSelectAll:`All`,presetImportSelectNone:`None`,presetImportAllSelected:`All selected`,presetImportNoneSelected:`Select at least one field to import`,presetImportPickHint:`Unchecked fields keep your current values; you can still tweak everything afterwards in Settings.`,presetGroupPrompt:`Prompts`,presetGroupTools:`Tools & switches`,presetGroupTerminal:`Terminal takeover`,presetGroupSkills:`Skills & extensions`,presetGroupAi:`Model behavior & dedicated prompts`,presetGroupUi:`Interface & interaction`,presetGroupEngine:`Engine defaults`,presetGroupOther:`Other`,presetImportImported:`Imported: {name}`,presetBrowseEmpty:`No presets in the shared repo yet`,presetBrowseLoading:`Loading community presets…`,presetBrowseSearch:`Search name / tag / author`,presetBrowseRefresh:`Refresh list`,presetBrowseCached:`List cached at {time} — hit refresh to re-fetch`,presetBrowseImport:`Import`,presetBrowseIssue:`Source issue`,presetBadgeTemplate:`Has template`,presetBadgeReview:`Has review prompt`,loadingSession:`Loading session…`,connectingServer:`Connecting to pi-web-ui server…`,localePacks:`Language packs`,localeGetMore:`Get more languages`,localeInstalled:`Installed`,localeInstall:`Download`,localeRemove:`Remove`,localeDownloading:`Downloading…`,localeRemoving:`Removing…`,localeInstallFailed:`Download failed: {error}`,localeListFailed:`Couldn't load language packs: {error}`,localeRemoveHint:`You can re-download it anytime`,wallpaperTitle:`Chat wallpaper`,wallpaperDesc:`Show a full-window background image (side panels, top and bottom bars included): a theme-provided image applies automatically, a URL here takes precedence; use dim and blur to keep text readable.`,wallpaperUrlPh:`Image URL (https://…, empty = off)`,wallpaperDim:`Dim`,wallpaperBlur:`Blur`,wallpaperClear:`Clear`,wallpaperUpload:`Upload image`,wallpaperUploadFailed:`Couldn't read the image (or it's too big) — try another one`,skillFullTextLabel:`Inject full skill text`,skillFullTextDesc:`Expand skill file contents inline into the system prompt (8KB per file, 32KB total cap); otherwise only a catalog is listed and the model reads files on demand`,skillFullTextShort:`Full`,delegateOpenSubagent:`Open subagent`,delegateSecTask:`Task`,delegateSecExpected:`Expected outcome`,delegateSecTools:`Required tools`,delegateSecMustDo:`Must do`,delegateSecMustNotDo:`Must not do`,delegateSecContext:`Context`,copyConversationId:`Copy conversation ID`,copyConversationPath:`Copy session file path`,copyConversationLink:`Copy link to session`,copyMessageLink:`Copy link to message`,quoteConversation:`Quote into composer (readable by the AI)`,quoteConversationShort:`Quote`,attachConversation:`Conversation reference: {name} (the AI reads it via conversation_read on demand)`,attachConversationShort:`conversation`,quoteSelection:`Quote`,quoteText:`Text quote`,quoteSource:`Source message: {id}`,removeQuote:`Remove quote`,presentOpenLocal:`Open locally`,presentMissing:`File missing or unreadable (moved, deleted, or outside the workspace?)`,presentEmpty:`Nothing to show`,presentAutoOpen:`Auto-open previews the AI presents`,presentAutoOpenDesc:`When the AI presents files with present_files and marks one as 'look at this first', open the file preview dialog automatically. Off (default): the cards stay inline and you open them with one click.`,presentFilesEnabledDesc:`Let the AI push artifacts (screenshots, charts, videos, reports, logs) into the chat as preview cards: images/videos/audio are shown inline, text gets an excerpt plus a one-click preview dialog, and every row carries open-locally / reveal-in-file-manager / download / copy-path actions. The auto-open switch lives on the Chat page.`,presentFilesOffHint:`Disabled: the AI can only tell you the file path — no cards, no open-locally buttons`,skillEnabledDesc:`Load skill bodies by name (the skill catalog stays in the system prompt): the full text is fetched only when a skill is actually needed, instead of making the model guess a path and call read.`,skillOffHint:`Disabled: the AI can no longer load skill bodies by name (the catalog in the prompt is unaffected)`,claimFilesEnabledDesc:`Declare which files you are about to edit so parallel runs in the same project can steer clear (advisory only — it never blocks edits). First-wins; claims expire automatically.`,claimFilesOffHint:`Disabled: the AI can no longer claim files (post-hoc touch reminders still work, only the up-front intent signal is gone)`,planUpdateEnabledDesc:`Structured task plan updates (Plan Mode / Step State Machine): allows the model to break complex tasks into steps and track progress in real time.`,planUpdateOffHint:`Disabled: AI can no longer update the structured plan board`,compactContextEnabledDesc:`Proactively compact context based on the current issue: allows AI to independently specify compression focus, retain core task context, drop irrelevant history, and control retention scope.`,compactContextOffHint:`Disabled: AI cannot proactively invoke context compaction (you can still use /compact or trigger auto-compaction)`,mcpManageEnabledDesc:`MCP server inspection and installation (list / check / install / remove / reload): allows AI to check whether an MCP server is installed and conveniently install/configure npm or remote MCP servers with live hot-reload.`,mcpManageOffHint:`Disabled: AI cannot invoke mcp_manage to check or install MCP servers`,evalEnabledDesc:`Execute Python or JavaScript/TypeScript code in an isolated sandbox with persistent variables; ideal for calculations, data analysis, and algorithm verification (default-off to prevent tool crowding-out).`,evalOffHint:`Disabled: the AI cannot use the persistent code sandbox (can still run scripts via bash)`,patchToolEnabledDesc:`High-reliability structural patch tool (Hashline): line-anchored editing with 4-hex content hashes, syntactic AST block matching, and clipboard registers. Automatically attempts 3-way merge conflict recovery if files diverged.`,patchToolOffHint:`Disabled: AI falls back to basic string replacement via edit`,lspToolEnabledDesc:`Native Language Server Protocol (LSP) tool: IDE-grade semantic code intelligence (definition, references, hover, diagnostics, documentSymbol outline, read_symbol precise slicing, workspaceSymbol search, and cascade impact diagnostics). Multi-agent shared process pool with idle sleep, zero external dependencies.`,lspToolOffHint:`Disabled: AI cannot query LSP semantics and falls back to text search`,codemodeEnabledDesc:`Run JavaScript in a QuickJS WASM sandbox to batch tool calls and filter output: intermediate results never enter LLM context, keeping context concise (default off; requires capable model).`,codemodeOffHint:`Disabled: AI cannot run codemode scripts to batch call tools`,codemodeNestedCalls:`Nested tool calls`,codemodeScript:`JavaScript script`,codemodeFullOutput:`Full output file`,codemodeModeLabel:`Execution Mode`,codemodeModeHint:`In standard mode all tools are directly visible; in strict code mode tools are hidden from the model and must be invoked via sandbox scripts`,codemodeModeOn:`Standard Mode (on)`,codemodeModeOnly:`Strict Code Mode (only)`,codemodeInlineBudgetLabel:`Inline Budget`,codemodeInlineBudgetHint:`Estimated tokens the codemode prompt may spend on tool declarations directly (default: 3000)`,codemodeNestedApprovalBadge:`Nested Call`,codemodeNestedApprovalDesc:`This tool call was triggered by a background codemode sandbox script`,codemodeSavedImages:`Generated Images`,toolSearchEnabledDesc:`BM25-based tool discovery and activation: search and activate tools via natural language queries (ideal for large MCP toolsets to prevent context bloat).`,toolSearchOffHint:`Disabled: AI cannot use tool_search to discover tools`,toolSearchLoaded:`Activated tools`,toolInfoMenuLabel:`Show tool details`,toolInfoTitle:`Tool details`,toolInfoLoading:`Loading tool definition…`,toolInfoUnsupported:`This engine can't show tool definitions`,toolInfoMissing:`No definition found for this tool (it may come from an uninstalled plugin or an older version)`,toolInfoActive:`Enabled`,toolInfoInactive:`Disabled`,toolInfoSource:`Source`,toolInfoDescription:`Description`,toolInfoNoDescription:`This tool has no description`,toolInfoPromptSnippet:`Prompt snippet`,toolInfoGuidelines:`Prompt guidelines`,toolPromptEdit:`Edit description`,toolPromptEdited:`Description customized (click to edit)`,toolPromptHint:`Leave a field empty to use the tool's built-in text. The three fields map to the tool description the model sees, the one-line summary in the system prompt, and the behavioral guidelines.`,toolPromptDescription:`Tool description (how the model understands this tool)`,toolPromptSnippet:`Prompt snippet (the line in the system prompt's Available tools list)`,toolPromptGuidelines:`Behavioral guidelines (Guidelines section, one per line)`,toolPromptDefault:`Built-in text`,toolPromptReset:`Reset to default`,toolPromptSave:`Save`,toolPromptUnavailable:`No definition for this tool (engine unsupported, or the tool is uninstalled) — you can still fill in overrides, but they only apply once the tool exists.`,toolInfoParams:`Parameters`,toolInfoParamsNone:`This tool takes no parameters`,toolInfoSchemaDropped:`The parameter schema is too large and was omitted (see the raw JSON below)`,toolInfoRawSchema:`Raw JSON schema`,toolInfoRequired:`required`,toolInfoFootnote:`This is the tool's definition — not this call's arguments or result.`,elsewhereOfflineBadge:`Offline`,elsewhereOfflineTip:`The page holding this conversation is gone (tab or browser closed) but the run is still on the server — click this row twice to take it over here`,sandboxNewBtn:`Launch Sandbox Project (isolated workspace)`,sandboxModalTitle:`Launch Sandbox Project`,sandboxModalSubtitle:`Experiment freely inside a hard-jailed copy — no changes ever touch your original files.`,sandboxModeLabel:`Initial Content`,sandboxModeBlank:`Blank Sandbox`,sandboxModeBlankDesc:`Clean empty directory for quick prototypes, scripts, or file processing`,sandboxModeImport:`Import Existing Project`,sandboxModeImportDesc:`Clone source project files (auto-skips node_modules/caches); original stays untouched`,sandboxSourceLabel:`Source Project Path`,sandboxSourcePlaceholder:`Enter or select a local project path to import`,sandboxLifecycleLabel:`Lifecycle`,sandboxLifecycleEphemeral:`Temporary (Use & Discard)`,sandboxLifecycleEphemeralDesc:`Ideal for one-off experiments; destroy anytime or convert to permanent`,sandboxLifecyclePermanent:`Permanent Sandbox`,sandboxLifecyclePermanentDesc:`Kept in your projects list for ongoing experimentation`,sandboxNameLabel:`Sandbox Name (optional)`,sandboxNamePlaceholder:`Leave blank to auto-generate`,sandboxCreateSubmit:`Launch Sandbox`,sandboxBadgeEphemeral:`Temp Sandbox`,sandboxBadgePermanent:`Sandbox`,sandboxBannerTitle:`Sandbox Isolation: {name}`,sandboxBannerSourceDesc:`Source: {source} (read-only protected; all edits stay inside this sandbox)`,sandboxBannerBlankDesc:`Isolated workspace (hard jail active; writing outside sandbox is blocked)`,sandboxActionPersist:`Keep Permanently`,sandboxActionPersistTip:`Convert this temporary sandbox into a permanent sandbox project`,sandboxActionApplySource:`Sync to Source`,sandboxActionApplySourceTip:`Sync modified files from this sandbox back to the source project (preserves .git)`,sandboxActionApplyConfirm:`Sync modified files from sandbox "{name}" back to source project ({source})?`,sandboxActionReset:`Reset`,sandboxActionResetTip:`Wipe sandbox and restore initial state (re-clones clean copy from source if imported)`,sandboxActionResetConfirm:`Reset sandbox "{name}"? Unexported changes in the sandbox will be wiped and restored to initial state.`,sandboxActionPromote:`Save as Project`,sandboxActionPromoteTip:`Export this sandbox to a formal project directory outside sandboxes`,sandboxActionDestroy:`Destroy`,sandboxActionDestroyTip:`Permanently delete this sandbox directory and switch back`,sandboxActionDestroyConfirm:`Permanently destroy sandbox "{name}" and delete all its files? This cannot be undone.`,sandboxPromoteTitle:`Save Sandbox as Formal Project`,sandboxPromoteSubtitle:`Export files from sandbox "{name}" to a new directory outside the sandbox jail.`,sandboxPromoteTargetLabel:`Target Directory Path (must be a new or empty directory)`,sandboxPromoteTargetPlaceholder:`e.g. ~/projects/my-new-app`,sandboxPromoteSwitchLabel:`Switch to the exported project immediately`,sandboxPromoteSubmit:`Export Project`,sandboxApplyTitle:`Sync Sandbox Changes to Source Project`,sandboxDiffStats:`+{added} added · ~{modified} modified · -{deleted} deleted in sandbox · {unchanged} unchanged`,sandboxDiffEmpty:`This sandbox is identical to the source project — no modified or added files to sync.`,sandboxDiffDeletedNote:`Note: Syncing only writes added and modified files (preserves source .git and never deletes existing source files).`,sandboxApplySubmit:`Confirm Sync ({count} files)`,sandboxEnabledDesc:`Allow AI to create blank or imported copy-on-write sandbox projects (skipping node_modules/caches), inspect diffs, reset, or destroy; syncing changes back to the source project requires user approval.`,sandboxOffHint:`Disabled: AI cannot invoke the sandbox tool to create or manage isolated sandboxes`},Sn=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],Cn={};function wn(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(Cn[e.code]=e,!0)}function Tn(e){delete Cn[e]}function En(e){return e===`zh`?`中文`:e.toUpperCase()}function Dn(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function On(e){let t=await fetch(gn(fn(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var kn=(0,g.createContext)(null);function An(){try{return localStorage.getItem(yn)}catch{return null}}function jn(){return vn(An(),typeof navigator<`u`?navigator.languages:[],null)}function Mn({children:e}){let[t,n]=(0,g.useState)(jn),[r,i]=(0,g.useState)(0),a=(0,g.useRef)(t);a.current=t;let o=(0,g.useCallback)(e=>{n(e);try{localStorage.setItem(yn,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,g.useCallback)(async()=>{let e,t=null;try{let n=await On(`/api/locales`);e=n.packs??[],t=n.defaultLocale??null}catch{return null}return await Promise.all(e.filter(e=>e.installed).map(async e=>{try{let t=await On(`/api/locales/${e.code}`);return wn({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,g.useEffect)(()=>{s().then(e=>{if(!An()?.trim()){let t=vn(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!Cn[t]){let t=vn(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(yn,t)}catch{}}})},[s]);let c=(0,g.useMemo)(()=>[...Sn,...Object.values(Cn).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,g.useCallback)((e,n)=>{let r=Cn[t]?.strings[e];r&&t!==`zh`&&t!==`ja`&&/[\u4e00-\u9fff]/.test(r)&&(r=void 0);let i=r??(t===`zh`?bn[e]:xn[e]);if(n)for(let[e,t]of Object.entries(n))i=i.replaceAll(`{${e}}`,String(t));return i},[t,r]);(0,g.useEffect)(()=>{document.documentElement.lang=Dn(t)},[t]);let u=(0,g.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(kn.Provider,{value:u,children:e})}function Nn(){let e=(0,g.useContext)(kn);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return Nn().t}var Pn=[{kind:`question`,labelKey:`sound.question`,descKey:`sound.question.desc`},{kind:`done`,labelKey:`sound.done`,descKey:`sound.done.desc`},{kind:`start`,labelKey:`sound.start`,descKey:`sound.start.desc`},{kind:`error`,labelKey:`sound.error`,descKey:`sound.error.desc`},{kind:`approval`,labelKey:`sound.approval`,descKey:`sound.approval.desc`}];function Fn({settings:e,onChange:t,onPreview:n}){let r=Z(),i=n=>t({...e,...n});return(0,X.jsxs)(`div`,{className:`sound-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:r(`soundHeader`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(ne,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:r(`enableSound`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:e=>i({enabled:e.target.checked})})]}),Pn.map(({kind:t,labelKey:a,descKey:o})=>(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(a)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(o)})]}),(0,X.jsxs)(`span`,{className:`sound-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`sound-preview`,title:r(`preview`),disabled:!e.enabled,onClick:e=>{e.preventDefault(),n(t)},children:r(`preview`)}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e[t],disabled:!e.enabled,onChange:e=>i({[t]:e.target.checked})})]})]},t)),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`volume`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:e.volume,disabled:!e.enabled,onChange:e=>i({volume:Number(e.target.value)})}),(0,X.jsxs)(`span`,{className:`sound-vol-num`,children:[e.volume,`%`]})]})]})}function In(){let[e,t]=(0,g.useState)([]);return(0,g.useEffect)(()=>{if(!qt())return;let e=window.speechSynthesis,n=()=>t(e.getVoices().map(e=>({voiceURI:e.voiceURI,lang:e.lang,name:e.name,localService:e.localService})));return n(),e.addEventListener?.(`voiceschanged`,n),()=>e.removeEventListener?.(`voiceschanged`,n)},[]),e}function Ln({settings:e,onChange:t,onPreview:n}){let r=Z(),i=In(),a=qt(),o=n=>t({...e,...n});return(0,X.jsxs)(`div`,{className:`sound-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:r(`ttsHeader`)}),!a&&(0,X.jsx)(`div`,{className:`sound-desc tts-unavailable`,children:r(`ttsUnavailable`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master ${a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(ne,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:r(`ttsEnable`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsEnableDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:!a,onChange:e=>o({enabled:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsAnnounce`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsAnnounceDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.announce,disabled:!e.enabled||!a,onChange:e=>o({announce:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsReadReplies`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsReadRepliesDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.readReplies,disabled:!e.enabled||!a,onChange:e=>o({readReplies:e.target.checked})})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsRate`)}),(0,X.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:e.rate,disabled:!e.enabled||!a,onChange:e=>o({rate:Number(e.target.value)})}),(0,X.jsxs)(`span`,{className:`sound-vol-num`,children:[e.rate.toFixed(1),`×`]})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsVoice`)}),(0,X.jsxs)(`select`,{className:`set-input tts-voice-select`,value:e.voiceURI,disabled:!e.enabled||!a,onChange:e=>o({voiceURI:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`ttsVoiceAuto`)}),i.map(e=>(0,X.jsxs)(`option`,{value:e.voiceURI,children:[e.name,` (`,e.lang,`)`,e.localService?``:` · ${r(`ttsVoiceOnline`)}`]},e.voiceURI))]})]}),(0,X.jsx)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:(0,X.jsx)(`button`,{type:`button`,className:`sound-preview tts-preview`,disabled:!e.enabled||!a,onClick:()=>{if(e.voiceURI&&!Jt(e.voiceURI,i,navigator.language)){t({...Wt,...e,voiceURI:``});return}n()},children:r(`preview`)})})]})}function Rn(e){let t=e??(typeof window>`u`?void 0:window);if(!t)return!1;if(t.piDesktop?.isDesktop===!0)return!0;let n=t.navigator?.userAgent;return typeof n==`string`&&n.includes(`Electron/`)}var zn=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),Bn=null,Vn=0;function Hn(){return Bn?.available===!0?Bn.pages??[]:[]}function Un(){Date.now()-Vn<5e3||Wn().catch(()=>{})}async function Wn(){if(Rn())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=zn();if(!e)return{available:!1,pages:[],error:`宿主页面桥不可用:这个 pi-web-ui 页面还没装上扩展桥(装/启用 page-picker 后刷新本页)`};try{let t=await e({op:`status`,timeoutMs:5e3});if(!t.ok)return{available:!1,pages:[],error:t.error??`扩展没有返回状态`};let n=t.result??{},r={available:n.installed===!0,aiControl:n.aiControl===!0,allowEval:n.allowEval===!0,pages:Array.isArray(n.pages)?n.pages:[]};return r.available&&(Bn=r,Vn=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function Gn(e){return e.length===1?e[0]:null}function Kn(e){return{path:e.origin,name:e.title?.trim()||e.origin,mode:`page`,key:`page:${e.origin}`}}async function qn(){let e=zn();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function Jn(e=45e3){let[t,n]=(0,g.useState)(null),r=(0,g.useRef)(!0),i=(0,g.useCallback)(async e=>{let t=await Wn();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,g.useEffect)(()=>{r.current=!0,i(!0);let t=setInterval(()=>void i(!1),Math.max(5e3,e));return()=>{r.current=!1,clearInterval(t)}},[i,e]),{status:t,refresh:()=>void i(!0)}}var Yn=null,Xn=null,Zn=null,Qn=null,$n=null;function er(e){Qn=e}function tr(e){$n=e}function nr(e){return Qn?(Qn(e),!0):!1}function rr(e){return $n?($n(e),!0):!1}function ir(e){Yn=e}function ar(e){Xn=e}function or(e){Zn=e}function sr(){return Zn?(Zn(),!0):!1}function cr(){return!!(Yn||Xn)}function lr(e){let t=typeof e?.text==`string`?e.text:``,n=Array.isArray(e?.attachments)?e.attachments:[],r=t.trim()!==``,i=n.length>0;return!r&&!i||r&&!Yn||i&&!Xn?!1:(i&&Xn?.(n),r&&Yn?.(t),!0)}function ur(){let e=Z(),{status:t,refresh:n}=Jn(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),s=(0,g.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=Gn(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},f=t=>{let n=lr({attachments:[Kn(t)]});d(e(n?`browserControlCited`:`browserControlCiteFailed`))},p=()=>{i(!0),n()};return(0,X.jsxs)(`span`,{className:`bc-anchor`,children:[u?(0,X.jsxs)(`span`,{className:`browser-control-split`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control single${l?` attention`:``}`,"data-tip":e(`browserControlSingleTip`,{name:u.title||u.origin}),title:e(`browserControlSingleTip`,{name:u.title||u.origin}),onClick:()=>f(u),children:[(0,X.jsx)(ve,{size:14,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`bc-chip-label`,children:u.title||u.origin})]}),(0,X.jsx)(`button`,{type:`button`,className:`chip browser-control caret`,"data-tip":e(`browserControlOpenPanel`),title:e(`browserControlOpenPanel`),"aria-label":e(`browserControlOpenPanel`),onClick:p,children:`▾`})]}):(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control${l?` attention`:``}`,"data-tip":t?.error??e(l?`browserControlEmpty`:`browserControlTip`),title:t?.error??e(l?`browserControlEmpty`:`browserControlTip`),onClick:p,children:[(0,X.jsx)(ve,{size:14,"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[e(`browserControl`),c.length>0?` · ${c.length}`:``]})]}),a&&(0,X.jsx)(`span`,{className:`bc-flash`,children:a}),r&&(0,X.jsx)(dr,{status:t,onRefresh:n,onCite:f,onClose:()=>i(!1)})]})}function dr({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,g.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await qn()||t()}finally{o(!1)}};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:r,children:(0,X.jsxs)(`div`,{className:`modal browser-control-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":i(`close`),onClick:r,children:`✕`}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(ve,{size:16,"aria-hidden":!0}),(0,X.jsx)(`h2`,{children:i(`browserControl`)})]}),(0,X.jsx)(`div`,{className:`modal-desc`,children:i(`browserControlTip`)}),e===null&&(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlChecking`)}),e?.available===!1&&!e.desktop&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlOffline`)}),e?.desktop===!0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlDesktop`)}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlDesktopLead`)}),(0,X.jsx)(`div`,{className:`bc-actions`,style:{marginTop:0},children:(0,X.jsx)(`a`,{className:`btn primary`,href:window.location.href,target:`_blank`,rel:`noreferrer noopener`,children:i(`browserControlOpenInBrowser`)})})]}),e?.available===!1&&!e.desktop&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlInstall`)}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlInstallLead`)}),(0,X.jsx)(`div`,{className:`bc-actions`,style:{marginTop:0},children:(0,X.jsx)(`a`,{className:`btn primary`,href:`https://github.com/xing-shuyin/pi-web-ui/releases/latest/download/page-picker-extension.zip`,target:`_blank`,rel:`noreferrer noopener`,children:i(`browserControlInstallDownload`)})}),(0,X.jsxs)(`ol`,{className:`bc-steps`,children:[(0,X.jsx)(`li`,{children:i(`browserControlInstallStep1`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep2`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep3`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep4`)})]})]}),e?.available===!0&&e.aiControl===!1&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlDisabled`)}),e?.available===!0&&s.length===0&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlEmpty`)}),s.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlPages`)}),(0,X.jsx)(`ul`,{className:`bc-pages`,children:s.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`bc-title`,title:e.title,children:e.title}),(0,X.jsx)(`span`,{className:`bc-origin`,title:e.origin,children:e.origin}),(0,X.jsx)(`span`,{className:`bc-open${e.open?` on`:``}`,children:e.open?i(`browserControlPageOpen`):i(`browserControlPageClosed`)}),(0,X.jsx)(`button`,{type:`button`,className:`bc-cite`,title:i(`browserControlCiteTip`,{name:e.title||e.origin}),onClick:()=>n(e),children:i(`browserControlCite`)})]},e.origin))}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlCiteNote`)})]}),e?.desktop!==!0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlExamples`)}),(0,X.jsxs)(`ul`,{className:`bc-examples`,children:[(0,X.jsx)(`li`,{children:i(`browserControlExample1`)}),(0,X.jsx)(`li`,{children:i(`browserControlExample2`)})]})]}),(0,X.jsxs)(`div`,{className:`bc-actions`,children:[e?.desktop!==!0&&(0,X.jsx)(`button`,{type:`button`,className:`primary`,disabled:a,onClick:()=>void c(),children:i(`browserControlOpenOptions`)}),(0,X.jsx)(`button`,{type:`button`,onClick:t,children:i(`browserControlRefresh`)})]})]})})}var fr=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],pr=[`subagent`],mr=`edit_soft`,hr=`delegate_task`,gr=`ask_user_question`,_r=`todo_list`,vr=`browser_page`,yr=`conversation_read`,br=`skill`,xr=`schedule`,Sr=`eval`,Cr=`present_files`,wr=`claim_files`,Tr=`plan_update`,Er=`compact_context`,Dr=`patch`,Or=`mcp_manage`,kr=`sandbox`,Ar=`codemode`,jr=`tool_search`,Mr=[...fr.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...pr.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:mr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:hr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:gr,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:vr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:yr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:wr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:Tr,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`planUpdateEnabledDesc`,offHintKey:`planUpdateOffHint`},{name:Dr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`patchToolEnabledDesc`,offHintKey:`patchToolOffHint`},{name:`lsp`,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`lspToolEnabledDesc`,offHintKey:`lspToolOffHint`},{name:Cr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:br,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:Sr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`evalEnabledDesc`,offHintKey:`evalOffHint`},{name:Ar,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`codemodeEnabledDesc`,offHintKey:`codemodeOffHint`},{name:jr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`toolSearchEnabledDesc`,offHintKey:`toolSearchOffHint`},{name:xr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:Er,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`compactContextEnabledDesc`,offHintKey:`compactContextOffHint`},{name:Or,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`mcpManageEnabledDesc`,offHintKey:`mcpManageOffHint`},{name:kr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`sandboxEnabledDesc`,offHintKey:`sandboxOffHint`},{name:_r,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}],Nr=[`bash`,`read`,`edit`,`write`,`powershell`,`ls`,`grep`,`find`];new Set(Mr.map(e=>e.name));var Pr=[...Mr.map(e=>e.name),...Nr];function Fr(e){let t=new Set(e);return Pr.filter(e=>!t.has(e))}function Ir(e,t){let n=Array.from(e);if(!t||t===`standard`)return n;if(t===`ask`)return[];if(t===`minimal`)return n.filter(e=>e===`bash`||e===`read`);if(t===`code`){let e=new Set([`bash`,`read`,`edit`,`write`,`edit_soft`]);return n.filter(t=>e.has(t))}if(t===`reader`){let e=new Set([`write`,`edit`,`edit_soft`,`bash`,`powershell`,`terminal_create`,`terminal_input`,`terminal_close`,`terminal_key`,`codemode`]);return n.filter(t=>!e.has(t))}return n}function Lr(e){return Ir([br],e).includes(br)}var Rr=`pi-web-notify`,zr={enabled:!1};function Br(){try{let e=localStorage.getItem(Rr);if(!e)return{...zr};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:zr.enabled}}catch{return{...zr}}}function Vr(e){try{localStorage.setItem(Rr,JSON.stringify(e))}catch{}}function Hr(){return typeof window<`u`&&`Notification`in window}function Ur(){return Hr()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function Wr(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&Gr(t)||Number.isFinite(n)&&Gr(n)?!0:r>0&&r<=400&&i>0&&i<=40}function Gr(e){return e<=-1e4}function Kr(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var qr=Date.now(),Jr=!1;function Yr(){qr=Date.now()}function Xr(){return Math.max(0,Date.now()-qr)}function Zr(){if(Jr||typeof window>`u`)return;Jr=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,Yr,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,Yr,e)}function Qr(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function $r(){return Zr(),typeof window>`u`||typeof document>`u`?{hasFocus:!0,visibility:`visible`,minimized:!1,idleMs:0,windows:!1}:{hasFocus:typeof document.hasFocus!=`function`||document.hasFocus(),visibility:document.visibilityState??``,minimized:Wr({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Xr(),windows:Qr()}}function ei(){return Hr()?Notification.permission:`denied`}async function ti(){if(!Hr())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function ni(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function ri(e,t=!1){return{body:e,requireInteraction:t,icon:fn(`/icons/icon-192.png`),badge:fn(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:fn(`/`)}}}async function ii(e,t,n=!1){if(!Hr())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=ri(t,n),i;try{let t=await navigator.serviceWorker?.getRegistration();if(t?.active&&typeof t.showNotification==`function`)return await t.showNotification(e,r),{path:`sw`};i=t?`service worker not active`:`no service worker registration`}catch(e){i=ni(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${ni(e)}`}}}async function ai(e,t){Hr()&&(Kr($r())||Br().enabled&&await ii(e,t))}var oi=!1;function si(){let e=Z(),[t,n]=(0,g.useState)(Br),[r,i]=(0,g.useState)(()=>ei()),[a,o]=(0,g.useState)(null),s=Ur(),c=s!==null,l=Qr();(0,g.useEffect)(()=>{let e=()=>i(ei());return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]);let u=async e=>{let r={...t,enabled:e};if(n(r),Vr(r),e){let e=await ti();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),Vr(e)}}};return(0,X.jsxs)(`div`,{className:`sound-menu notify-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:e(`notifyHeader`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master${c?` disabled`:``}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(_t,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:e(`notifyEnable`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:t.enabled&&!c,disabled:c,onChange:e=>u(e.target.checked)})]}),(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyEnableDesc`)}),s===`insecure`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyInsecure`)}),s===`unsupported`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyUnsupported`)}),!c&&r===`denied`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyDenied`)}),!c&&l&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyWindowsHint`)}),oi]})}var ci=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),Q=new Set(`viewBox.xmlns.d.fill.stroke.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.opacity.x.y.x1.y1.x2.y2.cx.cy.r.rx.ry.width.height.points.offset.stop-color.stop-opacity.fill-opacity.stroke-opacity.stroke-miterlimit.fill-rule.clip-rule.vector-effect.preserveAspectRatio.transform.clip-path.id.href.xlink:href.xmlns:xlink.gradientUnits.gradientTransform`.split(`.`)),li=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),ui=new Set([...ci].map(e=>e.toLowerCase())),di=new Set([...Q].map(e=>e.toLowerCase()));function fi(e){return ui.has(e.toLowerCase())}function pi(e){return di.has(e.toLowerCase())}function mi(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t||t.length>8192||!/^<svg[\s>]/.test(t.startsWith(`<?xml`)?t.slice(t.indexOf(`?>`)+2).trimStart():t))return null;if(typeof DOMParser>`u`)return/<script[\s>]/i.test(t)||/\son\w+\s*=/i.test(t)||/javascript\s*:/i.test(t)?null:t;let n=new DOMParser().parseFromString(t,`image/svg+xml`);if(n.querySelector(`parsererror`))return null;let r=n.documentElement;if(r.tagName.toLowerCase()!==`svg`)return null;let i=e=>{for(let t of Array.from(e.children)){let e=t.tagName.toLowerCase();if(!fi(e)){li.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of Array.from(t.attributes)){let n=e.name.toLowerCase();(!pi(n)||/^on/i.test(n)||/^(javascript|data|vbscript):/i.test(e.value.trim()))&&t.removeAttribute(e.name)}i(t)}};for(let e of Array.from(r.attributes)){let t=e.name.toLowerCase();(!pi(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function hi({icon:e,iconSvg:t,className:n}){let r=mi(t);return r?(0,X.jsx)(`span`,{className:n??`plugin-icon-svg`,"aria-hidden":!0,dangerouslySetInnerHTML:{__html:r}}):e?(0,X.jsx)(`span`,{className:n?`${n} plugin-icon-glyph`:`plugin-icon-glyph`,"aria-hidden":!0,children:e}):null}var gi=`pi-web-ui:cost-currency`,_i=null,vi=0,yi=new Set;function bi(){vi+=1;for(let e of[...yi])try{e()}catch{}}function xi(e){return yi.add(e),()=>{yi.delete(e)}}function Si(){return vi}function Ci(e){return!Number.isFinite(e)||e<=0?`0`:e<1e-4?`<0.0001`:e.toFixed(4).replace(/\.?0+$/,``)}function wi(){try{if(typeof localStorage<`u`){let e=localStorage.getItem(gi);if(typeof e==`string`&&e.trim().length>0)return e.trim().slice(0,8)}}catch{}return`$`}function Ti(e){try{if(typeof localStorage<`u`){let t=typeof e==`string`?e.trim().slice(0,8):``;!t||t===`$`?localStorage.removeItem(gi):localStorage.setItem(gi,t)}}catch{}bi()}function Ei(e){return typeof e==`function`?(_i=e,bi(),()=>{_i===e&&(_i=null,bi())}):(_i=null,bi(),()=>{})}function Di(e,t){let n=String(e??``).trim();if(!n)return{symbol:t,value:`0`};let r=n.match(/^([^\d<>+-]+)\s*(.+)$/);return r?{symbol:r[1],value:r[2]}:{symbol:``,value:n}}function Oi(e,t){let n=typeof e==`number`&&Number.isFinite(e)?e:0,r=wi(),i=typeof t?.fixedDigits==`number`?n.toFixed(t.fixedDigits):Ci(n);if(_i)try{let e=_i(n,{defaultSymbol:r,defaultValue:i});if(typeof e==`string`)return Di(e,r);if(e&&typeof e==`object`&&typeof e.value==`string`)return{symbol:typeof e.symbol==`string`?e.symbol:r,value:e.value,tooltip:typeof e.tooltip==`string`?e.tooltip:void 0}}catch(e){console.error(`[cost-format] custom cost formatter threw:`,e)}return{symbol:r,value:i}}function ki(e,t){return(0,g.useSyncExternalStore)(xi,Si,Si),Oi(e,t)}var Ai={projects:`host:lp-projects`,convs:`host:lp-running`,sessions:`host:lp-history`},ji=[`projects`,`convs`,`sessions`],Mi=new Map(Object.keys(Ai).map(e=>[Ai[e],e])),Ni=`plugin:`;function Pi(e){return e.startsWith(Ni)&&e.length>7}function Fi(e){let t=[],n=new Set;for(let r of e??[]){let e=null,i,a=Mi.get(r.id);a?e=a:r.source?.startsWith(`plugin:`)&&r.kind===`view`&&(e=`${Ni}${r.id}`,i=r),e&&!n.has(e)&&(n.add(e),t.push({key:e,shown:!r.hidden,...i?{entry:i}:{}}))}for(let e of ji)n.has(e)||t.push({key:e,shown:!0});return t}function Ii(e,t){return e.filter(e=>e.shown&&t(e.key)).map(e=>e.key)}function Li(e,t){let n=[];for(let r=0;r+1<e.length;r++){let i=e[r],a=e[r+1];!t(i)&&!t(a)&&n.push([i,a])}return n}function Ri(e,t){let n={...t};if(!e)return n;try{let r=JSON.parse(e);if(!r||typeof r!=`object`||Array.isArray(r))return n;for(let[e,i]of Object.entries(r))(e in t||Pi(e))&&typeof i==`number`&&Number.isFinite(i)&&i>0&&(n[e]=i)}catch{}return n}var zi=new Set([`view`,`action`,`badge`,`menu`,`page`,`organizer`,`divider`,`toggle`,`input`,`progress`,`select`]),Bi=new Set([`disabled`,`always`,`never`,`file.isDir`,`file.isFile`,`session.isRunning`,`message.hasSelection`]),Vi=`topbar.primary,topbar.overflow,notice.actions,leftpanel.sections,leftpanel.projects.actions,leftpanel.project,leftpanel.running.actions,leftpanel.running,leftpanel.history.actions,leftpanel.history,leftpanel.sessions,chat.header,chat.empty,message.actions,goalbar.actions,composer.leading,composer.actions,rightpanel.tabs,terminal.toolbar,scm.toolbar,bottombar,file.preview.toolbar,contextmenu.topbar,contextmenu.message,contextmenu.session,contextmenu.project,contextmenu.file,contextmenu.toolcall,settings.pages,tasks.panel,modal.dialog,sidebar.left,sidebar.right`.split(`,`),Hi=Vi.map(e=>({slot:e,cardinality:`list`}));function Ui(e){return Hi.find(t=>t.slot===e)?.cardinality??`list`}function Wi(e,t){if(t===`list`)return{entries:[...e],conflicts:[]};let n=e.findIndex(e=>!e.hidden);if(n<0)return{entries:[...e],conflicts:[]};let r=e.filter((e,t)=>t!==n&&!e.hidden);return{entries:e.map((e,t)=>t===n||e.hidden?e:{...e,hidden:!0}),winner:e[n],conflicts:r}}var Gi=[{id:`host:lp-projects`,slot:`leftpanel.sections`,labelKey:`recentProjects`,icon:`folder`,kind:`action`,order:10},{id:`host:lp-running`,slot:`leftpanel.sections`,labelKey:`runningConversations`,icon:`activity`,kind:`action`,order:20},{id:`host:lp-history`,slot:`leftpanel.sections`,labelKey:`historySessions`,icon:`clock`,kind:`action`,order:30},{id:`host:brand`,slot:`topbar.primary`,labelKey:`brand`,kind:`badge`,order:1,group:`brand`},{id:`host:open-project`,slot:`topbar.primary`,labelKey:`openProject`,icon:`folder`,kind:`action`,order:3,group:`primary`},{id:`host:history`,slot:`topbar.primary`,labelKey:`openHistory`,icon:`menu`,kind:`action`,order:0,group:`panels`},{id:`host:files`,slot:`topbar.primary`,labelKey:`openFiles`,icon:`folder`,kind:`action`,order:97,group:`panels`,align:`end`},{id:`host:new-chat`,slot:`topbar.primary`,labelKey:`newChat`,icon:`plus`,kind:`action`,order:96,group:`primary`,align:`end`},{id:`host:new-ephemeral-chat`,slot:`topbar.primary`,labelKey:`newChatEphemeral`,icon:`chat`,kind:`action`,order:96.5,group:`primary`,align:`end`},{id:`host:chat`,slot:`topbar.primary`,labelKey:`chat`,icon:`chat`,kind:`view`,view:`chat`,order:20,group:`views`,align:`end`},{id:`host:terminal`,slot:`topbar.primary`,labelKey:`terminal`,icon:`terminal`,kind:`view`,view:`terminal`,order:21,group:`views`,align:`end`},{id:`host:git`,slot:`topbar.primary`,labelKey:`scmTab`,icon:`git`,kind:`view`,view:`git`,order:22,group:`views`,align:`end`},{id:`host:plugins`,slot:`topbar.primary`,labelKey:`pluginMenuTitle`,icon:`🧩`,kind:`action`,order:24,group:`views`,align:`end`},{id:`host:search`,slot:`topbar.primary`,labelKey:`searchGlobal`,icon:`search`,kind:`action`,order:40,group:`tools`,align:`end`},{id:`host:browser`,slot:`topbar.primary`,labelKey:`browserControl`,icon:`browser`,kind:`action`,order:41,group:`tools`,align:`end`,hidden:!0},{id:`host:tasks`,slot:`topbar.primary`,labelKey:`bgTasks`,icon:`layers`,kind:`action`,order:42,group:`tools`,align:`end`},{id:`host:settings`,slot:`topbar.primary`,labelKey:`settingsTitle`,icon:`settings`,kind:`action`,order:60,group:`system`,align:`end`},{id:`host:sound`,slot:`topbar.primary`,labelKey:`sound`,icon:`sound`,kind:`action`,order:70,group:`system`,hidden:!0,align:`end`},{id:`host:language`,slot:`topbar.primary`,labelKey:`language`,icon:`globe`,kind:`action`,order:80,group:`system`,hidden:!0,align:`end`},{id:`host:theme`,slot:`topbar.primary`,labelKey:`theme`,icon:`sun`,kind:`action`,order:82,group:`system`,hidden:!0,align:`end`},{id:`host:update`,slot:`topbar.primary`,labelKey:`update`,icon:`download`,kind:`action`,order:90,group:`system`,align:`end`,hidden:!0},{id:`host:github`,slot:`topbar.primary`,labelKey:`githubRepo`,icon:`github`,kind:`action`,order:200,group:`system`,align:`end`,hidden:!0},{id:`host:conn`,slot:`bottombar`,labelKey:`connected`,icon:`dot`,kind:`badge`,order:5,group:`status`},{id:`host:engine`,slot:`bottombar`,labelKey:`engineBadge`,icon:`cpu`,kind:`badge`,order:6,group:`status`},{id:`host:ctx`,slot:`bottombar`,labelKey:`context`,icon:`gauge`,kind:`badge`,order:10,group:`usage`},{id:`host:cost`,slot:`bottombar`,labelKey:`cumulativeCost`,icon:`coins`,kind:`badge`,order:11,group:`usage`},{id:`host:cache`,slot:`bottombar`,labelKey:`cacheHit`,icon:`database`,kind:`badge`,order:12,group:`usage`},{id:`host:msg-count`,slot:`bottombar`,labelKey:`messages`,icon:`message`,kind:`badge`,order:13,group:`usage`},{id:`host:plugin-status`,slot:`bottombar`,labelKey:`pluginStatus`,icon:`activity`,kind:`badge`,order:14,group:`status`},{id:`host:working`,slot:`bottombar`,labelKey:`working`,icon:`activity`,kind:`badge`,order:15,group:`status`},{id:`host:status-delegate`,slot:`bottombar`,labelKey:`delegateModeBadge`,icon:`eye`,kind:`badge`,order:16,group:`status`},{id:`host:host-metrics`,slot:`bottombar`,labelKey:`hostResources`,icon:`cpu`,kind:`badge`,order:19,group:`host`,align:`end`},{id:`host:cwd`,slot:`bottombar`,labelKey:`cwdTip`,icon:`folder`,kind:`action`,order:20,group:`context`,align:`end`},{id:`host:msg-reask`,slot:`message.actions`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,order:9},{id:`host:msg-edit-reask`,slot:`message.actions`,labelKey:`editReask`,icon:`edit`,kind:`action`,order:10},{id:`host:msg-fork`,slot:`message.actions`,labelKey:`forkSession`,icon:`branch`,kind:`action`,order:15},{id:`host:msg-rollback`,slot:`message.actions`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,order:16},{id:`host:msg-copy`,slot:`message.actions`,labelKey:`copyMessage`,icon:`copy`,kind:`action`,order:20},{id:`host:msg-copy-text`,slot:`message.actions`,labelKey:`copyText`,icon:`text`,kind:`action`,order:21},{id:`host:msg-copy-markdown`,slot:`message.actions`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,order:22},{id:`host:msg-copy-image`,slot:`message.actions`,labelKey:`copyImage`,icon:`image`,kind:`action`,order:23},{id:`host:msg-speak`,slot:`message.actions`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,order:24},{id:`host:composer-upload`,slot:`composer.actions`,labelKey:`uploadFile`,icon:`upload`,kind:`action`,order:10,align:`start`},{id:`host:composer-templates`,slot:`composer.actions`,labelKey:`tpl.openPicker`,icon:`grid`,kind:`action`,order:110,align:`start`},{id:`host:composer-model`,slot:`composer.actions`,labelKey:`selectModel`,icon:`cpu`,kind:`action`,order:120,align:`start`},{id:`host:composer-thinking`,slot:`composer.actions`,labelKey:`thinkingLevel`,icon:`zap`,kind:`action`,order:130,align:`start`},{id:`host:composer-dsh-perm`,slot:`composer.actions`,labelKey:`dshPerm`,icon:`lock`,kind:`action`,order:140,align:`start`},{id:`host:composer-dsh-preset`,slot:`composer.actions`,labelKey:`dshPreset`,icon:`layers`,kind:`action`,order:150,align:`start`},{id:`host:composer-send`,slot:`composer.actions`,labelKey:`sendTip`,icon:`send`,kind:`action`,order:200,align:`end`},{id:`host:fp-md`,slot:`file.preview.toolbar`,labelKey:`showMarkdownPreview`,icon:`eye`,kind:`action`,order:10},{id:`host:fp-toc`,slot:`file.preview.toolbar`,labelKey:`previewTocLabel`,icon:`list`,kind:`action`,order:15},{id:`host:fp-html`,slot:`file.preview.toolbar`,labelKey:`showHtmlPreview`,icon:`code`,kind:`action`,order:20},{id:`host:fp-edit`,slot:`file.preview.toolbar`,labelKey:`editFile`,icon:`edit`,kind:`action`,order:30},{id:`host:fp-wrap`,slot:`file.preview.toolbar`,labelKey:`enableWrap`,icon:`wrap`,kind:`action`,order:40},{id:`host:fp-zoom`,slot:`file.preview.toolbar`,labelKey:`zoomIn`,icon:`zoom`,kind:`action`,order:50},{id:`host:fp-ref`,slot:`file.preview.toolbar`,labelKey:`referenceTip`,icon:`link`,kind:`action`,order:70},{id:`host:fp-full`,slot:`file.preview.toolbar`,labelKey:`fullscreen`,icon:`maximize`,kind:`action`,order:80},{id:`host:fp-close`,slot:`file.preview.toolbar`,labelKey:`close`,icon:`x`,kind:`action`,order:90},{id:`host:goal-pill`,slot:`goalbar.actions`,labelKey:`goalBarTitle`,icon:`target`,kind:`action`,order:5},{id:`host:goal-set`,slot:`goalbar.actions`,labelKey:`goalBarSet`,icon:`check`,kind:`action`,order:10},{id:`host:goal-wizard`,slot:`goalbar.actions`,labelKey:`goalWizardBtn`,icon:`search`,kind:`action`,order:20},{id:`host:goal-lock`,slot:`goalbar.actions`,labelKey:`goalBarLocked`,icon:`lock`,kind:`action`,order:30},{id:`host:goal-plan`,slot:`goalbar.actions`,labelKey:`planMode`,icon:`list`,kind:`action`,order:25},{id:`host:goal-collapse`,slot:`goalbar.actions`,labelKey:`collapsePanel`,icon:`chevron-up`,kind:`action`,order:40},{id:`host:goal-model`,slot:`goalbar.actions`,labelKey:`goalBarReviewModel`,icon:`cpu`,kind:`action`,order:50},{id:`host:goal-rounds`,slot:`goalbar.actions`,labelKey:`goalBarMaxRounds`,icon:`hash`,kind:`action`,order:60},{id:`host:goal-execmodel`,slot:`goalbar.actions`,labelKey:`goalBarExecModel`,icon:`cpu`,kind:`action`,order:55},{id:`host:goal-openrole`,slot:`goalbar.actions`,labelKey:`goalBarOpenExec`,icon:`search`,kind:`action`,order:65},{id:`host:goal-clear`,slot:`goalbar.actions`,labelKey:`goalBarClear`,icon:`x`,kind:`action`,order:70},{id:`host:scm-changes`,slot:`scm.toolbar`,labelKey:`scmChanges`,icon:`file`,kind:`action`,order:10},{id:`host:scm-history`,slot:`scm.toolbar`,labelKey:`scmHistory`,icon:`clock`,kind:`action`,order:20},{id:`host:scm-refresh`,slot:`scm.toolbar`,labelKey:`scmRefreshTip`,icon:`refresh`,kind:`action`,order:30},{id:`host:scm-branch`,slot:`scm.toolbar`,labelKey:`scmSwitchBranch`,icon:`git`,kind:`action`,order:40},{id:`host:scm-switch`,slot:`scm.toolbar`,labelKey:`scmSwitch`,icon:`git`,kind:`action`,order:50},{id:`host:scm-push`,slot:`scm.toolbar`,labelKey:`scmPush`,icon:`upload`,kind:`action`,order:60},{id:`host:scm-pull`,slot:`scm.toolbar`,labelKey:`scmPull`,icon:`download`,kind:`action`,order:70},{id:`host:scm-input`,slot:`scm.toolbar`,labelKey:`scmCommitPlaceholder`,icon:`edit`,kind:`action`,order:80},{id:`host:scm-genmsg`,slot:`scm.toolbar`,labelKey:`scmGenMsg`,icon:`cpu`,kind:`action`,order:85},{id:`host:scm-commit`,slot:`scm.toolbar`,labelKey:`scmCommit`,icon:`check`,kind:`action`,order:90},{id:`host:scm-commit-all`,slot:`scm.toolbar`,labelKey:`scmCommitAll`,icon:`check`,kind:`action`,order:100},{id:`host:scm-term`,slot:`scm.toolbar`,labelKey:`terminal`,icon:`terminal`,kind:`action`,order:110},{id:`host:term-cmd-refresh`,slot:`terminal.toolbar`,labelKey:`rerun`,icon:`refresh`,kind:`action`,order:10},{id:`host:term-cmd-new`,slot:`terminal.toolbar`,labelKey:`newCommand`,icon:`plus`,kind:`action`,order:20},{id:`host:term-tab-new`,slot:`terminal.toolbar`,labelKey:`newTerminal`,icon:`plus`,kind:`action`,order:30},{id:`host:right-files`,slot:`rightpanel.tabs`,labelKey:`openFiles`,icon:`folder`,kind:`view`,view:`files`,order:10},{id:`host:conv-rename`,slot:`contextmenu.session`,labelKey:`renameSession`,icon:`edit`,kind:`action`,context:`session`,order:1},{id:`host:conv-pin`,slot:`contextmenu.session`,labelKey:`pinConversation`,icon:`pin`,kind:`action`,context:`session`,order:2},{id:`host:conv-takeover`,slot:`contextmenu.session`,labelKey:`takeoverConversation`,icon:`chat`,kind:`action`,context:`session`,order:5},{id:`host:conv-dismiss-subagents`,slot:`contextmenu.session`,labelKey:`dismissFinishedSubagents`,icon:`x`,kind:`action`,context:`session`,order:10},{id:`host:conv-force-dismiss`,slot:`contextmenu.session`,labelKey:`forceDismissConversation`,icon:`x`,kind:`action`,context:`session`,order:20},{id:`host:conv-persist`,slot:`contextmenu.session`,labelKey:`persistSubagent`,icon:`save`,kind:`action`,context:`session`,order:25},{id:`host:conv-copy-id`,slot:`contextmenu.session`,labelKey:`copyConversationId`,icon:`copy`,kind:`action`,context:`session`,order:30},{id:`host:conv-copy-path`,slot:`contextmenu.session`,labelKey:`copyConversationPath`,icon:`copy`,kind:`action`,context:`session`,order:40},{id:`host:conv-copy-link`,slot:`contextmenu.session`,labelKey:`copyConversationLink`,icon:`link`,kind:`action`,context:`session`,order:45},{id:`host:conv-quote`,slot:`contextmenu.session`,labelKey:`quoteConversation`,icon:`chat`,kind:`action`,context:`session`,order:50},{id:`host:file-open`,slot:`contextmenu.file`,labelKey:`fileOpenPreview`,icon:`open`,kind:`action`,context:`file`,order:11,group:`open`},{id:`host:file-enter`,slot:`contextmenu.file`,labelKey:`fileEnterDir`,icon:`folder`,kind:`action`,context:`file`,order:12,group:`open`},{id:`host:file-download`,slot:`contextmenu.file`,labelKey:`downloadFile`,icon:`download`,kind:`action`,context:`file`,order:13,group:`open`},{id:`host:file-compress`,slot:`contextmenu.file`,labelKey:`fileCompress`,icon:`file`,kind:`action`,context:`file`,order:16,group:`archive`},{id:`host:file-extract`,slot:`contextmenu.file`,labelKey:`fileExtract`,icon:`folder`,kind:`action`,context:`file`,order:17,group:`archive`},{id:`host:file-compress-download`,slot:`contextmenu.file`,labelKey:`fileCompressDownload`,icon:`download`,kind:`action`,context:`file`,order:18,group:`archive`},{id:`host:file-upload-folder`,slot:`contextmenu.file`,labelKey:`fileUploadFolder`,icon:`upload`,kind:`action`,context:`file`,order:25,group:`new`},{id:`host:file-open-project`,slot:`contextmenu.file`,labelKey:`openAsProject`,icon:`folder`,kind:`action`,context:`file`,order:14,group:`open`},{id:`host:file-add-root`,slot:`contextmenu.file`,labelKey:`addWorkspaceRoot`,icon:`folder`,kind:`action`,context:`file`,order:15,group:`open`},{id:`host:file-reveal`,slot:`contextmenu.file`,labelKey:`fileReveal`,icon:`folder`,kind:`action`,context:`file`,order:16,group:`open`},{id:`host:file-open-default`,slot:`contextmenu.file`,labelKey:`fileOpenDefault`,icon:`open`,kind:`action`,context:`file`,order:17,group:`open`},{id:`host:file-new-file`,slot:`contextmenu.file`,labelKey:`fileNewFile`,icon:`file`,kind:`action`,context:`file`,order:21,group:`new`},{id:`host:file-new-dir`,slot:`contextmenu.file`,labelKey:`fileNewDir`,icon:`folder`,kind:`action`,context:`file`,order:22,group:`new`},{id:`host:file-upload`,slot:`contextmenu.file`,labelKey:`uploadToFolder`,icon:`upload`,kind:`action`,context:`file`,order:23,group:`new`},{id:`host:file-paste`,slot:`contextmenu.file`,labelKey:`filePaste`,icon:`paste`,kind:`action`,context:`file`,order:24,group:`new`},{id:`host:file-attach-ref`,slot:`contextmenu.file`,labelKey:`referenceTip`,icon:`link`,kind:`action`,context:`file`,order:32,group:`chat`},{id:`host:file-attach-folder`,slot:`contextmenu.file`,labelKey:`linkFolderTip`,icon:`link`,kind:`action`,context:`file`,order:33,group:`chat`},{id:`host:file-rename`,slot:`contextmenu.file`,labelKey:`fileRename`,icon:`edit`,kind:`action`,context:`file`,order:41,group:`edit`},{id:`host:file-duplicate`,slot:`contextmenu.file`,labelKey:`fileDuplicate`,icon:`copy`,kind:`action`,context:`file`,order:42,group:`edit`},{id:`host:file-cut`,slot:`contextmenu.file`,labelKey:`fileCut`,icon:`cut`,kind:`action`,context:`file`,order:43,group:`edit`},{id:`host:file-copy`,slot:`contextmenu.file`,labelKey:`fileCopyEntry`,icon:`copy`,kind:`action`,context:`file`,order:44,group:`edit`},{id:`host:file-copy-name`,slot:`contextmenu.file`,labelKey:`copyName`,icon:`copy`,kind:`action`,context:`file`,order:51,group:`clipboard`},{id:`host:file-copy-path`,slot:`contextmenu.file`,labelKey:`copyPath`,icon:`copy`,kind:`action`,context:`file`,order:52,group:`clipboard`},{id:`host:file-copy-rel`,slot:`contextmenu.file`,labelKey:`fileCopyRelPath`,icon:`copy`,kind:`action`,context:`file`,order:53,group:`clipboard`},{id:`host:file-refresh`,slot:`contextmenu.file`,labelKey:`fileRefresh`,icon:`refresh`,kind:`action`,context:`file`,order:54,group:`clipboard`},{id:`host:file-delete`,slot:`contextmenu.file`,labelKey:`fileDelete`,icon:`trash`,kind:`action`,context:`file`,order:61,group:`danger`},{id:`host:msg-ctx-copy-markdown`,slot:`contextmenu.message`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,context:`message`,order:10,group:`copy`},{id:`host:msg-ctx-copy-text`,slot:`contextmenu.message`,labelKey:`copyText`,icon:`text`,kind:`action`,context:`message`,order:11,group:`copy`},{id:`host:msg-ctx-copy-image`,slot:`contextmenu.message`,labelKey:`copyImage`,icon:`image`,kind:`action`,context:`message`,order:12,group:`copy`},{id:`host:msg-ctx-copy-link`,slot:`contextmenu.message`,labelKey:`copyMessageLink`,icon:`link`,kind:`action`,context:`message`,order:13,group:`copy`},{id:`host:msg-ctx-reask`,slot:`contextmenu.message`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,context:`message`,order:19,group:`action`},{id:`host:msg-ctx-edit-reask`,slot:`contextmenu.message`,labelKey:`editReask`,icon:`edit`,kind:`action`,context:`message`,order:20,group:`action`},{id:`host:msg-ctx-fork`,slot:`contextmenu.message`,labelKey:`forkSession`,icon:`branch`,kind:`action`,context:`message`,order:21,group:`action`},{id:`host:msg-ctx-rollback`,slot:`contextmenu.message`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,context:`message`,order:22,group:`action`},{id:`host:msg-ctx-speak`,slot:`contextmenu.message`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,context:`message`,order:23,group:`action`},{id:`host:tool-info`,slot:`contextmenu.toolcall`,labelKey:`toolInfoMenuLabel`,icon:`info`,kind:`action`,context:`toolcall`,order:10}],Ki=`__view`,qi=new Set([`host:settings`,`host:history`,`host:files`]),Ji=new Set([`host:history`,`host:files`]);function Yi(e){return`${e}:${Ki}`}function Xi(e){return e.source.startsWith(`plugin:`)?e.id===Yi(e.source.slice(7)):!1}function Zi(e,t,n){let r=Yi(t),i=(e?.hidden??[]).filter(e=>e!==r),a=(e?.shown??[]).filter(e=>e!==r);return n?a.push(r):i.push(r),{...e,hidden:i,shown:a}}function Qi(e,t){let n=t.map(Yi),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var $i=`host:brand`,ea=[`host:brand-logo`,`host:brand-name`];function ta(e){if(!((e.hidden??[]).some(e=>ea.includes(e))||(e.shown??[]).some(e=>ea.includes(e))||(e.order??[]).some(e=>ea.includes(e))||ea.some(t=>e.align?.[t]!==void 0)||ea.some(t=>e.groups?.[t]!==void 0)||ea.some(t=>e.labels?.[t]!==void 0)||ea.some(t=>e.slots?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=ea.includes(n)?$i:n;t.includes(e)||t.push(e)}return t},n=(e,t)=>{if(!e)return;let n={};for(let[t,r]of Object.entries(e))ea.includes(t)||(n[t]=r);if(n[$i]===void 0){let r=t?e[ea[0]]??e[ea[1]]:e[ea[1]]??e[ea[0]];r!==void 0&&(n[$i]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))ea.includes(n)||(t[n]=r);if(t[$i]===void 0){let n=e[ea[0]]??e[ea[1]];n!==void 0&&(t[$i]=n)}return t},i=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))ea.includes(n)||(t[n]=r);if(t[$i]===void 0){let n=e[ea[0]]??e[ea[1]];n!==void 0&&(t[$i]=n)}return t};return{...e,...e.hidden?{hidden:t(e.hidden)}:{},...e.shown?{shown:t(e.shown)}:{},...e.order?{order:t(e.order)}:{},...e.groups?{groups:n(e.groups,!0)}:{},...e.labels?{labels:n(e.labels,!1)}:{},...e.align?{align:r(e.align)}:{},...e.slots?{slots:i(e.slots)}:{}}}function na(e){return e.map(e=>{if(e.view===!1)return e;let t=e.ui?.items??[];if(t.some(e=>e.id===`__view`))return e;let n={id:Ki,slot:`topbar.primary`,label:e.name,...e.icon?{icon:e.icon}:{},...e.iconSvg?{iconSvg:e.iconSvg}:{},kind:`view`,view:`plugin:${e.id}`,order:23,align:`end`,hidden:!0};return{...e,ui:{items:[...t,n],arrange:e.ui?.arrange??[]}}})}function ra(e){return typeof e==`string`&&Vi.includes(e)}function ia(e,t){return t?e.label:e.labelEn??e.label}function aa(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function oa(e,t,n,r,i){let a=`${e}#${r.id}`,o=sa(a,t,n,r.children,i),s=aa(r,i),c=ca(r.options,i);return{id:a,slot:t,source:n,label:ia(r,i),labelExplicit:!0,...r.icon?{icon:r.icon}:{},...r.iconSvg?{iconSvg:r.iconSvg}:{},...s?{hint:s}:{},kind:r.kind??`action`,...r.action?{action:r.action}:{},...r.view?{view:r.view}:{},...r.group?{group:r.group}:{},order:r.order??100,align:`start`,hidden:r.hidden??!1,...r.badge?{badge:r.badge}:{},...r.when?{when:r.when}:{},...c?{options:c}:{},...o.length>0?{children:o}:{},userOverrides:[],arrangedBy:[]}}function sa(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:oa(e,t,n,r,i),index:a})).sort((e,t)=>e.entry.order===t.entry.order?e.index-t.index:e.entry.order-t.entry.order).map(e=>e.entry):[]}function ca(e,t){if(e?.length)return e.slice(0,32).map(e=>({value:e.value,label:t?e.label??e.labelEn??e.value:e.labelEn??e.label??e.value}))}function la(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function ua(e,t,n,r,i,a){let o=sa(e,t,n,r.children,i),s=aa(r,i),c=la(r.progress),l=ca(r.options,i);return{id:e,slot:t,source:n,label:ia(r,i),labelExplicit:!0,...r.icon?{icon:r.icon}:{},...r.iconSvg?{iconSvg:r.iconSvg}:{},...s?{hint:s}:{},kind:r.kind??(t===`settings.pages`?`page`:`action`),...r.action?{action:r.action}:{},...r.view?{view:r.view}:{},...r.group?{group:r.group}:{},order:r.order??100,align:r.align??`start`,hidden:r.hidden??!1,...r.badge?{badge:r.badge}:{},...typeof r.checked==`boolean`?{checked:r.checked}:{},...typeof r.value==`string`?{value:r.value}:{},...c===void 0?{}:{progress:c},...l?{options:l}:{},...r.when?{when:r.when}:{},...o.length>0?{children:o}:{},userOverrides:[],arrangedBy:[],seq:a}}function da(e,t){return[...e].sort((e,n)=>{let r=t.get(e.id),i=t.get(n.id);return r!==void 0||i!==void 0?r!==void 0&&i!==void 0?r-i:r===void 0?1:-1:e.order===n.order?e.seq-n.seq:e.order-n.order})}function fa(e,t){let n=e.filter(e=>Xi(e)&&!t.has(e.id));if(n.length===0)return e;let r=e.filter(e=>!Xi(e)||t.has(e.id)),i=[`host:git`,`host:terminal`,`host:chat`].map(e=>r.findIndex(t=>t.id===e)).find(e=>e>=0)??-1,a=r.findIndex(e=>e.id===`host:plugins`),o=i+1;return a>=o&&(o=a),o=Math.max(0,Math.min(o,r.length)),[...r.slice(0,o),...n,...r.slice(o)]}function pa(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=ta(t.layout??{}),a=e=>{t.diagnostics?.push({level:e.level??`warn`,...e})},o=new Map,s=0;for(let e of Gi)o.set(e.id,{id:e.id,slot:e.slot,source:`host`,label:t.t(e.labelKey),labelKey:e.labelKey,...e.icon?{icon:e.icon}:{},kind:e.kind,...e.view?{view:e.view}:{},...e.group?{group:e.group}:{},order:e.order??100,align:e.align??`start`,hidden:e.hidden??!1,userOverrides:[],arrangedBy:[],seq:s++});for(let t of e){if(r.has(t.id)){a({pluginId:t.id,message:`plugin "${t.id}" is disabled by the user — its ${t.ui?.items?.length??0} UI item(s) are not rendered`});continue}if(t.error){a({level:`error`,pluginId:t.id,message:`plugin "${t.id}" failed to activate (${t.error}) — its UI items are not rendered`});continue}let e=`plugin:${t.id}`;for(let r of t.ui?.items??[]){if(!ra(r.slot)){a({pluginId:t.id,entryId:r.id,message:`item "${t.id}:${r.id}" declares unknown slot "${String(r.slot)}" — dropped (valid slots: see docs/architecture-plugins.md)`});continue}if(r.slot===`leftpanel.sections`&&r.kind!==`view`){a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" targets leftpanel.sections: only kind="view" (a plugin section) is accepted — dropped`});continue}if(r.kind&&!zi.has(r.kind)&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares unknown kind "${r.kind}" — the render layer falls back to a plain button`}),Array.isArray(r.when))for(let e of r.when)Bi.has(e)||a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares when:"${e}" which the host does not know — it is ignored (the item still renders)`});else r.when!==void 0&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" has a non-array "when" — ignored`});let i=`${t.id}:${r.id}`,c=o.get(i);c&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item id "${r.id}" is declared more than once — the later declaration wins (order/visibility are inherited from the first)`}),o.set(i,ua(i,r.slot,e,r,n,c?.seq??s++))}}for(let t of e)if(!(t.error||r.has(t.id)))for(let e of t.ui?.arrange??[]){let n=o.get(e.id);ha(o,e,t.id),n||a({pluginId:t.id,entryId:e.id,message:`arrange target "${e.id}" does not exist — op ignored (is the providing plugin installed / not disabled?)`})}let c=new Map,l=(e,t)=>{let n=c.get(e)??[];n.includes(t)||n.push(t),c.set(e,n)};for(let e of i.hidden??[]){let t=o.get(e);t&&(t.hidden=!0,l(e,`hidden`))}for(let e of i.shown??[]){let t=o.get(e);t&&(t.hidden=!1,l(e,`hidden`))}for(let[e,t]of Object.entries(i.groups??{})){let n=o.get(e);n&&(n.group=t,l(e,`group`))}for(let[e,t]of Object.entries(i.align??{})){let n=o.get(e);!n||t!==`start`&&t!==`center`&&t!==`end`||(n.align=t,l(e,`align`))}for(let[e,t]of Object.entries(i.labels??{})){let n=o.get(e);n&&(n.label=t,n.labelExplicit=!0,l(e,`label`))}for(let[e,t]of Object.entries(i.slots??{})){let n=o.get(e);n&&ra(t)&&n.slot!==t&&(n.movedFrom=n.movedFrom??n.slot,n.slot=t,l(e,`slot`))}for(let e of qi){let t=o.get(e);t&&(i.slots?.[e]||(t.slot=`topbar.primary`),t.hidden=!1)}let u=new Map;(i.order??[]).forEach((e,t)=>{o.has(e)&&(u.has(e)||u.set(e,t),l(e,`order`))});for(let e of Object.values(Ai)){let t=o.get(e);t&&t.slot!==`leftpanel.sections`&&(a({entryId:e,slot:t.slot,message:`"${e}" must stay in leftpanel.sections — the move is ignored`}),t.slot=`leftpanel.sections`,delete t.movedFrom)}let d=new Map;for(let e of Vi)d.set(e,[]);for(let e of o.values())d.get(e.slot)?.push(e);let f={};for(let e of Vi){let t=da(d.get(e)??[],u),n=Wi(e===`topbar.primary`?fa(t,u):t,Ui(e));if(n.winner&&n.conflicts.length>0)for(let t of n.conflicts)a({level:`error`,pluginId:t.source.startsWith(`plugin:`)?t.source.slice(7):void 0,entryId:t.id,slot:e,message:`slot "${e}" is single-cardinality; "${n.winner.id}" won and "${t.id}" was hidden`});f[e]=n.entries.map(e=>ma(e,c.get(e.id)??[]))}return f}function ma(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function ha(e,t,n){let r=e.get(t.id);if(!r)return;let i=!1;t.hide!==void 0&&(r.hidden=t.hide,i=!0),t.group!==void 0&&(r.group=t.group,i=!0),t.order!==void 0&&(r.order=t.order,i=!0),t.align!==void 0&&(r.align=t.align,i=!0),t.label!==void 0&&(r.label=t.label,r.labelExplicit=!0,i=!0),t.hint!==void 0&&(r.hint=t.hint,i=!0),t.icon!==void 0&&(r.icon=t.icon,i=!0),t.iconSvg!==void 0&&(r.iconSvg=t.iconSvg||void 0,i=!0),t.slot!==void 0&&ra(t.slot)&&t.slot!==r.slot&&(r.movedFrom=r.movedFrom??r.slot,r.slot=t.slot,i=!0),i&&r.source!==`plugin:${n}`&&!r.arrangedBy.includes(n)&&r.arrangedBy.push(n)}function ga(e){let t=[],n=[],r=[];for(let i of e)i.align===`end`?r.push(i):i.align===`center`?n.push(i):t.push(i);return{start:t,center:n,end:r}}function _a(e,t){let n=e??{},r={},i=t===$i?[t,...ea]:[t],a=(n.hidden??[]).filter(e=>!i.includes(e)),o=(n.shown??[]).filter(e=>!i.includes(e)),s=(n.order??[]).filter(e=>!i.includes(e));a.length>0&&(r.hidden=a),o.length>0&&(r.shown=o),s.length>0&&(r.order=s);let c=ya(n.groups,t),l=ya(n.labels,t),u=ya(n.align,t),d=ya(n.slots,t);if(t===$i)for(let e of ea)c=ya(c,e),l=ya(l,e),u=ya(u,e),d=ya(d,e);return c&&(r.groups=c),l&&(r.labels=l),u&&(r.align=u),d&&(r.slots=d),n.topbarText!==void 0&&(r.topbarText=n.topbarText),n.sideDockFloat!==void 0&&(r.sideDockFloat=n.sideDockFloat),r}function va(){return{}}function ya(e,t){if(!e)return;let n={},r=!1;for(let[i,a]of Object.entries(e))i!==t&&(n[i]=a,r=!0);return r?n:void 0}var ba=new Set([`host:files`]);function xa(e,t){let n=e=>e===`center`?1:e===`end`?2:0;return[...e].sort((e,r)=>n(e.align)-n(r.align)||t(e.id)-t(r.id))}function Sa(e,t,n,r,i=new Set){let a=new Set;if(!Number.isFinite(t)||t<=0)return a;let o=e.filter(e=>i.has(e.id)&&e.width>0).reduce((e,t)=>e+t.width+n,0),s=Math.max(0,t-Math.max(0,r)-o),c=0,l=!1;for(let t of e){if(!(t.width>0)||i.has(t.id))continue;let e=t.width+n;if(l||c+e>s){l=!0,a.add(t.id);continue}c+=e}return a}var Ca=null,wa=new Set;function Ta(){for(let e of wa)e()}function Ea(e){Ca={x:Number.isFinite(e.x)?e.x:0,y:Number.isFinite(e.y)?e.y:0,slot:e.slot,target:e.target??{id:``},entries:Array.isArray(e.entries)?e.entries:[],...typeof e.onHostAction==`function`?{onHostAction:e.onHostAction}:{}},Ta()}function Da(){Ca!==null&&(Ca=null,Ta())}function Oa(e){return wa.add(e),()=>{wa.delete(e)}}function ka(){return Ca}function Aa(){return(0,g.useSyncExternalStore)(Oa,ka,ka)}function ja(e){return Number.isFinite(e)?e:0}function Ma(e,t,n,r,i,a){let o=Math.max(0,ja(n)),s=Math.max(0,ja(r)),c=Math.max(8,ja(i)-o-8),l=Math.max(8,ja(a)-s-8);return{x:Math.min(Math.max(8,ja(e)),c),y:Math.min(Math.max(8,ja(t)),l)}}function Na(e,t){let n=String(t?.kind??``);if(e===`contextmenu.file`)return{"file.isDir":n===`dir`||n===`list`&&t?.id!==`@root`,"file.isFile":n===`file`};if(e===`contextmenu.session`)return{"session.isRunning":n===`running`};if(e===`contextmenu.message`){let e=!1;try{let t=window.getSelection?.();e=!!t&&!t.isCollapsed&&t.toString().trim().length>0}catch{e=!1}return{"message.hasSelection":e}}return{}}function Pa(e,t){if(!Array.isArray(e)||e.length===0)return!1;for(let n of e){if(typeof n!=`string`||!n)continue;let e=n.trim();if(e===`disabled`||e===`never`)return!0;if(e!==`always`){if(e.startsWith(`!`)){let n=e.slice(1).trim();if(!n)continue;if(!t||t[n]!==!0)return!0;continue}if(t&&t[e]===!1)return!0}}return!1}function Fa(e,t){return!e||Pa(e.when,t)}function Ia(e){let t=new Map;return{items:(Array.isArray(e)?e:[]).map(e=>{if(!e||e.kind!==`select`||!e.options?.length||e.children?.length)return e;let n=e.options.map((t,n)=>({id:`${e.id}#${n}`,slot:e.slot,source:e.source,label:t.label,kind:`action`,order:100,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}));return n.forEach((n,r)=>t.set(n.id,{parent:e,value:e.options[r].value})),{...e,kind:`menu`,children:n}}),selectParents:t}}function La(e){if(!Array.isArray(e)||e.length===0)return[];let t=e.filter(e=>e&&e.hidden!==!0),n=t.filter(e=>e.kind!==`divider`),r=new Map,i=new Map;n.forEach((e,t)=>{let n=e.group??``;r.has(n)||r.set(n,t);let a=Number.isFinite(e.order)?e.order:100,o=i.get(n);(o===void 0||a<o)&&i.set(n,a)});let a=[...r.keys()].sort((e,t)=>{let n=i.get(e)??100,a=i.get(t)??100;return n===a?(r.get(e)??0)-(r.get(t)??0):n-a}),o=new Map(a.map((e,t)=>[e,t])),s=new Map;n.forEach((e,t)=>s.set(e,t));let c=[...n].sort((e,t)=>{let n=o.get(e.group??``)??0,r=o.get(t.group??``)??0;if(n!==r)return n-r;let i=Number.isFinite(e.order)?e.order:100,a=Number.isFinite(t.order)?t.order:100;return i===a?(s.get(e)??0)-(s.get(t)??0):i-a}),l=new Map;t.forEach((e,n)=>{if(e.kind!==`divider`)return;let r=t.slice(n+1).find(e=>e.kind!==`divider`);if(!r)return;let i=l.get(r)??[];i.push(e),l.set(r,i)});let u=[];for(let e of c){for(let t of l.get(e)??[])u.push(t);u.push(e)}return u}function Ra(e){let t=[],n=null,r=!1;return e.forEach((e,i)=>{if(!e||e.kind===`divider`){r=!0;return}let a=e.group??``;n!==null&&(r||a!==n)&&t.push({kind:`sep`,key:`sep:${i}`}),t.push({kind:`item`,key:`${e.id}#${i}`,index:i,entry:e}),n=a,r=!1}),t}function za(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!Fa(e,t)}function Ba(e,t,n,r){let i=Array.isArray(e)?e.length:0;if(i===0)return-1;let a=n>=0?1:-1,o=Number.isFinite(t)?Math.trunc(t):-1;(o<0||o>=i)&&(o=a>0?-1:i);for(let t=0;t<i;t++)if(o=(o+a+i)%i,za(e[o],r))return o;return-1}var Va={menu:`☰`,folder:`📁`,plus:`+`,chat:`💬`,terminal:`▙`,git:`⎇`,search:`🔍`,browser:`🌐`,layers:`🗂`,settings:`⚙`,sound:`🔊`,globe:`🌍`,sun:`☀`,download:`⤓`,github:`⌗`,x:`✕`,upload:`⬆`,copy:`⧉`,cut:`✂`,paste:`📋`,trash:`🗑`,file:`📄`,open:`↗`,refresh:`⟳`,link:`🔗`,edit:`✎`,dot:`●`,info:`ⓘ`,cpu:`▣`,gauge:`▤`,coins:`◉`,database:`▥`,message:`✉`,activity:`〜`,markdown:`📄`,text:`≡`,image:`🖼`,branch:`⚚`,undo:`↺`,pin:`📌`,volume:`🔊`};function Ha(e){let t=(e??``).trim();return t?Va[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var Ua={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},Wa=new Set;function Ga(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function Ka(e,t){return e.engine===t.engine&&e.managed===t.managed&&e.appVersion===t.appVersion&&e.serverVersion===t.serverVersion&&e.status===t.status&&e.ready===t.ready&&e.cwd===t.cwd&&Ga(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&Ga(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function qa(e){let t={...Ua,...e};if(!Ka(Ua,t)){Ua=t;for(let e of Wa)e()}}function Ja(e){return Wa.add(e),()=>{Wa.delete(e)}}function Ya(){return Ua}function Xa(){return(0,g.useSyncExternalStore)(Ja,Ya,Ya)}function Za(e){return(0,g.useSyncExternalStore)(Ja,()=>Ua[e],()=>Ua[e])}function Qa(){return Za(`engine`)===`dsh`}function $a(){return Za(`managed`)}function eo(){return Za(`service`)}var to=null;function no(e){to=e}var $=e=>to?to(e):!1,ro=new Set;function io(e){return ro.add(e),()=>{ro.delete(e)}}function ao(e){for(let t of ro)try{t(e)}catch(e){console.error(`[remote-ssh-client] listener error:`,e)}}function oo(e,t,n,r){return`ssh://${e}@${t}:${n}${r.startsWith(`/`)?r:`/${r}`}`}function so(e){return!!(e&&e.startsWith(`ssh://`))}function co(e){if(!so(e))return null;let t=/^ssh:\/\/([^@]+)@([^:]+):(\d+)(\/.*)$/.exec(e);return t?{username:t[1],host:t[2],port:parseInt(t[3],10),remotePath:t[4]}:null}var lo=1;function uo(e){let t=`probe_${Date.now()}_${lo++}`;return new Promise(n=>{let r=io(e=>{e.type===`remote_ssh_probe_result`&&e.reqId===t&&(r(),n({ok:e.ok,connectionId:e.connectionId,error:e.error,system:e.system,tools:e.tools,packageManager:e.packageManager,suggestedInstall:e.suggestedInstall}))});$({type:`remote_ssh_probe`,reqId:t,params:e})||(r(),n({ok:!1,error:`WebSocket 连接不可用,请稍候重试`}))})}function fo(e,t){let n=`listdir_${Date.now()}_${lo++}`;return new Promise(r=>{let i=io(e=>{e.type===`remote_ssh_list_dir_result`&&e.reqId===n&&(i(),r({ok:e.ok,connectionId:e.connectionId,path:e.path,parentPath:e.parentPath,items:e.items,error:e.error}))});$({type:`remote_ssh_list_dir`,reqId:n,connectionId:e,path:t})||(i(),r({ok:!1,connectionId:e,path:t||`/`,items:[],error:`WebSocket 连接不可用`}))})}function po(e,t){let n=`install_${Date.now()}_${lo++}`;return new Promise(r=>{let i=io(e=>{e.type===`remote_ssh_install_result`&&e.reqId===n&&(i(),r({ok:e.ok,connectionId:e.connectionId,tool:e.tool,output:e.output,error:e.error}))});$({type:`remote_ssh_install_tools`,reqId:n,connectionId:e,tools:t})||(i(),r({ok:!1,connectionId:e,tool:t[0]||``,error:`WebSocket 连接不可用`}))})}function mo(){let e=`profiles_${Date.now()}_${lo++}`;return new Promise(t=>{let n=io(r=>{r.type===`remote_ssh_profiles_result`&&r.reqId===e&&(n(),t(r.profiles))});$({type:`remote_ssh_list_profiles`,reqId:e})||(n(),t([]))})}function ho(e){$({type:`remote_ssh_delete_profile`,name:e})}var go=`@root`,_o=e=>e.endsWith(`/`)?e:e+`/`;function vo(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function yo(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var bo=e=>{let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;if(t===`@root`||t===`/`)return null;let n=t.lastIndexOf(`/`);if(n<0)return/^[A-Za-z]:$/.test(t)?go:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function xo({currentCwd:e,pathCompletions:t,workspaceRoots:n,onClose:r,onSelectDirectory:i,mode:a=`folder`,onCreateProject:o,className:s,backdropClassName:c,role:l,ariaLabel:u}){let d=Z(),[f,p]=(0,g.useState)(()=>so(e)?`remote`:`local`),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(-1),D=(0,g.useRef)(null),O=(0,g.useRef)(null),[k,A]=(0,g.useState)([]),[j,ee]=(0,g.useState)(``),[M,te]=(0,g.useState)(`22`),[N,ne]=(0,g.useState)(``),[F,re]=(0,g.useState)(`password`),[ie,ae]=(0,g.useState)(``),[I,R]=(0,g.useState)(`~/.ssh/id_rsa`),[z,oe]=(0,g.useState)(!0),[B,V]=(0,g.useState)(``),[H,se]=(0,g.useState)(!1),[ce,le]=(0,g.useState)(null),[ue,de]=(0,g.useState)(null),[fe,W]=(0,g.useState)(null),[pe,G]=(0,g.useState)(null),[K,me]=(0,g.useState)([]),[he,ge]=(0,g.useState)(!1),[q,_e]=(0,g.useState)(`/`),[ve,ye]=(0,g.useState)(`/`),[be,xe]=(0,g.useState)([]),[J,Se]=(0,g.useState)(!1),Ce=t.filter(e=>e.type===`dir`);(0,g.useEffect)(()=>{if(so(e)){let t=co(e);t&&(ee(t.host),te(String(t.port)),ne(t.username),_e(t.remotePath),ye(t.remotePath))}else{let t=(e||``).replace(/\\/g,`/`);h(t),v(t)}b(!1),S(``),w(null),E(-1)},[e]),(0,g.useEffect)(()=>{f===`remote`&&mo().then(e=>A(e))},[f]),(0,g.useEffect)(()=>{let e=requestAnimationFrame(()=>{D.current?.focus()});return()=>cancelAnimationFrame(e)},[f]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(y?(b(!1),S(``),w(null)):r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y,r]),(0,g.useEffect)(()=>{if(f!==`local`)return;let e=setTimeout(()=>{$({type:`complete_path`,path:_o(m)})},60);return()=>clearTimeout(e)},[m,f]),(0,g.useEffect)(()=>{if(f!==`local`||_===m)return;let e=setTimeout(()=>{$({type:`complete_path`,path:_})},150);return()=>clearTimeout(e)},[_,m,f]);let we=e=>{let t=e.trim();t&&t!==`@root`&&i(t)},Te=()=>{let e=x.trim();if(e){if(a===`project`){if(!yo(e)){w(d(`invalidProjectName`));return}let t=vo(m,e);o?.(t),b(!1),S(``),w(null),r()}else $({type:`make_dir`,path:`${_o(m)}${e}`}),setTimeout(()=>{$({type:`complete_path`,path:_o(m)})},80),S(``),b(!1)}},Ee=e=>{if(e.key===`Escape`)e.stopPropagation(),y?(b(!1),S(``),w(null)):r();else if(e.key===`Enter`&&!e.nativeEvent.isComposing)we(_);else if(e.key===`Tab`){if(Ce.length===0)return;e.preventDefault();let t=T>=0?(T+1)%Ce.length:0;E(t),v(Ce[t].path),h(Ce[t].path)}},De=async e=>{let t=(e?.host??j).trim(),n=e?.port??(parseInt(M,10)||22),r=(e?.username??N).trim();if(!t||!r){le(`请填写主机地址和用户名`);return}se(!0),le(null);let i=await uo({host:t,port:n,username:r,auth:e?.auth??(F===`password`?{type:`password`,password:ie}:F===`key`?{type:`key`,privateKeyPath:I}:{type:`agent`}),saveProfile:z,profileName:e?.profileName||B.trim()||void 0});if(se(!1),!i.ok||!i.connectionId){le(i.error||`连接远程服务器失败`);return}de(i.connectionId),W(i.system??null),G(i.tools??null),me(i.suggestedInstall??[]);let a=i.system?.homeDir||`/`;_e(a),ye(a),Oe(i.connectionId,a),mo().then(e=>A(e))},Oe=async(e,t)=>{Se(!0),le(null);let n=await fo(e,t);Se(!1),n.ok?(_e(n.path),ye(n.path),xe(n.items)):le(n.error||`读取远程目录失败`)},ke=async e=>{if(!ue)return;ge(!0),le(null);let t=await po(ue,[e]);ge(!1),t.ok?(me(t=>t.filter(t=>t!==e)),pe&&e===`git`&&G({...pe,git:{installed:!0,version:`已安装`}})):le(t.error||`安装 ${e} 失败,可能需要远端 sudo 权限`)},Ae=e=>{i(oo(N,j,parseInt(M,10)||22,e)),r()},je=bo(m),Me=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},Ne=Me(m),Pe=!!m&&m!==`@root`&&Ne!==Me(e)&&!n.some(e=>Me(e)===Ne);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`status-cwd-backdrop ${c??``}`.trim(),onClick:r}),(0,X.jsxs)(`div`,{className:`cwd-picker ${s??``}`.trim(),role:l,"aria-label":u,children:[(0,X.jsxs)(`div`,{className:`cwd-mode-tabs`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-mode-tab ${f===`local`?`active`:``}`,onClick:()=>p(`local`),children:[`💻 `,d(`workspaceModeLocal`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-mode-tab ${f===`remote`?`active`:``}`,onClick:()=>p(`remote`),children:[`🌐 `,d(`workspaceModeRemote`)]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-close`,title:d(`close`),"aria-label":d(`close`),onClick:r,children:(0,X.jsx)(P,{})})]}),f===`local`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:m===`@root`?d(`computer`):m,children:[m===`@root`?`💻`:(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{children:m===`@root`?d(`computer`):m})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:m===`@root`,title:d(`computer`),onClick:()=>{h(`@root`),v(`@root`),E(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!je,title:d(`cwdGoUp`),onClick:()=>{je&&(h(je),v(je),E(-1))},children:[`↑ `,d(`cwdGoUp`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!Pe,title:d(`addWorkspaceRootHint`),onClick:()=>{Pe&&$({type:`set_workspace_roots`,roots:[...n,m]})},children:[`+ `,d(`addWorkspaceRoot`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:D,className:`status-cwd-input cwd-picker-input`,value:_,placeholder:d(`enterPath`),spellCheck:!1,onChange:e=>{v(e.target.value),E(-1)},onKeyDown:Ee}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:d(`cwdPickCurrent`),disabled:m===`@root`,onClick:()=>we(m),children:d(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[Ce.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:d(`cwdEmpty`)}),Ce.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${d(`cwdEnter`)} ${e.path}`,onClick:()=>{h(e.path),v(e.path),E(-1)},children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:d(`cwdChoose`),onClick:()=>we(e.path),children:d(`cwdChoose`)})]},e.path))]}),(0,X.jsxs)(`div`,{className:`cwd-picker-foot`,children:[y?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:O,value:x,autoFocus:!0,spellCheck:!1,placeholder:d(a===`project`?`projectName`:`cwdNewName`),onChange:e=>{S(e.target.value),C&&w(null)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),Te()):e.key===`Escape`&&(e.stopPropagation(),b(!1),S(``),w(null))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:Te,children:d(a===`project`?`createAndOpenProject`:`cwdCreate`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{b(!1),S(``),w(null)},children:d(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>b(!0),children:[`+ `,d(a===`project`?`newProject`:`cwdNewFolder`)]}),C&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:C})]})]}),f===`remote`&&(0,X.jsx)(`div`,{className:`cwd-ssh-container`,children:ue?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-probe-box`,children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-probe-header`,children:[(0,X.jsxs)(`span`,{children:[`🌐 `,N,`@`,j,` (`,fe?.os,` `,fe?.arch,`)`]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-ssh-profile-del`,onClick:()=>{de(null),W(null),G(null)},children:d(`sshDisconnect`)})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`6px`,flexWrap:`wrap`,fontSize:`10px`},children:[(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.git.installed?`ok`:`missing`}`,children:[`Git: `,pe?.git.installed?`✓`:`✗`]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.node.installed?`ok`:`missing`}`,children:[`Node: `,pe?.node.installed?`✓`:`✗`]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.bash.installed?`ok`:`missing`}`,children:[`Bash: `,pe?.bash.installed?`✓`:`✗`]})]}),K.length>0&&(0,X.jsxs)(`div`,{className:`cwd-ssh-install-box`,children:[(0,X.jsx)(`div`,{children:`⚠️ 远端环境未检测到 Git / 基础工具,SCM 与执行功能可能受限。`}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`6px`,marginTop:`2px`},children:[(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,disabled:he,onClick:()=>void ke(K[0]),children:he?d(`sshInstalling`):`⚡ ${d(`sshInstallTool`)} ${K[0]}`}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>me([]),children:d(`sshSkipAndBrowse`)})]})]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:q,children:[(0,X.jsx)(Fe,{}),(0,X.jsx)(`span`,{children:q})]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:q===`/`||J,title:d(`cwdGoUp`),onClick:()=>{let e=bo(q)||`/`;ue&&Oe(ue,e)},children:[`↑ `,d(`cwdGoUp`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{className:`status-cwd-input cwd-picker-input`,value:ve,placeholder:d(`enterPath`),spellCheck:!1,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ue&&Oe(ue,ve)}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:()=>Ae(q),children:d(`sshOpenRemoteWorkspace`)})]}),(0,X.jsx)(`div`,{className:`cwd-list`,children:J?(0,X.jsx)(`div`,{className:`cwd-empty`,children:`正在加载远程目录…`}):be.length===0?(0,X.jsx)(`div`,{className:`cwd-empty`,children:d(`cwdEmpty`)}):be.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${e.type===`dir`?d(`cwdEnter`):``} ${e.path}`,onClick:()=>{e.type===`dir`&&ue&&Oe(ue,e.path)},children:[e.type===`dir`?(0,X.jsx)(Re,{}):(0,X.jsx)(`span`,{children:`📄`}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),e.type===`dir`&&(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:d(`cwdChoose`),onClick:()=>Ae(e.path),children:d(`cwdChoose`)})]},e.path))})]}):(0,X.jsxs)(`div`,{className:`cwd-ssh-form`,children:[k.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-profiles-title`,children:[`📋 `,d(`sshSavedProfiles`)]}),k.map(e=>(0,X.jsxs)(`div`,{className:`cwd-ssh-profile-card`,onClick:()=>{ee(e.host),te(String(e.port)),ne(e.username),re(e.authType),e.privateKeyPath&&R(e.privateKeyPath),De({host:e.host,port:e.port,username:e.username,profileName:e.name,auth:e.authType===`password`?{type:`password`,password:``}:e.authType===`key`?{type:`key`,privateKeyPath:e.privateKeyPath}:{type:`agent`}})},children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-profile-meta`,children:[(0,X.jsxs)(`span`,{className:`cwd-ssh-profile-name`,children:[(0,X.jsx)(U,{style:{marginRight:`4px`}}),e.name]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-profile-addr`,children:[e.username,`@`,e.host,`:`,e.port]})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-ssh-profile-del`,title:d(`delete`),onClick:t=>{t.stopPropagation(),confirm(d(`sshDeleteProfileConfirm`))&&(ho(e.name),A(t=>t.filter(t=>t.name!==e.name)))},children:(0,X.jsx)(L,{})})]},e.name))]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,style:{marginTop:`4px`},children:[(0,X.jsxs)(`label`,{children:[d(`sshHost`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:j,placeholder:`192.168.1.100`,onChange:e=>ee(e.target.value)}),(0,X.jsxs)(`label`,{style:{width:`32px`,textAlign:`right`},children:[d(`sshPort`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,style:{width:`45px`,flex:`none`},value:M,onChange:e=>te(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshUser`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:N,placeholder:`root / ubuntu`,onChange:e=>ne(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshAuthType`),`:`]}),(0,X.jsxs)(`select`,{className:`cwd-ssh-select`,value:F,onChange:e=>re(e.target.value),children:[(0,X.jsx)(`option`,{value:`password`,children:d(`sshPassword`)}),(0,X.jsx)(`option`,{value:`key`,children:d(`sshKeyPath`)}),(0,X.jsx)(`option`,{value:`agent`,children:d(`sshAgent`)})]})]}),F===`password`&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshPassword`),`:`]}),(0,X.jsx)(`input`,{type:`password`,className:`cwd-ssh-input`,value:ie,placeholder:`••••••••`,onChange:e=>ae(e.target.value)})]}),F===`key`&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshKeyPath`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:I,placeholder:`~/.ssh/id_rsa`,onChange:e=>R(e.target.value)})]}),(0,X.jsx)(`div`,{className:`cwd-ssh-row`,style:{fontSize:`11px`,color:`var(--text-dim)`},children:(0,X.jsxs)(`label`,{style:{width:`auto`},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:z,onChange:e=>oe(e.target.checked),style:{marginRight:`4px`}}),d(`sshSaveProfile`)]})}),z&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshProfileName`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:B,placeholder:`my-server`,onChange:e=>V(e.target.value)})]}),ce&&(0,X.jsxs)(`div`,{style:{color:`var(--red)`,fontSize:`11px`,padding:`2px 0`},children:[`⚠️ `,ce]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,style:{marginTop:`4px`},disabled:H,onClick:()=>void De(),children:d(H?`sshConnecting`:`sshConnectAndProbe`)})]})})]})]})}function So({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z();return e?(0,X.jsx)(xo,{currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:e=>{a(e),i()},onCreateProject:o,mode:`project`,className:`project-picker`,backdropClassName:`project-picker-backdrop`,role:`dialog`,ariaLabel:s(`projectPickerTitle`)}):null}function Co(e){return k({tag:`svg`,attr:{viewBox:`0 0 256 256`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M53.92,34.62A8,8,0,1,0,42.08,45.38L67.37,73.2A69.82,69.82,0,0,0,38,87.63a16,16,0,0,0-1.29,23.78L85,159.71,42.34,202.34a8,8,0,0,0,11.32,11.32L96.29,171l48.29,48.29A16,16,0,0,0,155.9,224c.38,0,.75,0,1.13,0a15.93,15.93,0,0,0,11.64-6.33,89.75,89.75,0,0,0,11.58-20.27l21.84,24a8,8,0,1,0,11.84-10.76ZM155.9,208,48,100.08C58.23,91.83,69.2,87.72,80.66,87.81l87.16,95.88C165.59,193.56,160.24,202.23,155.9,208Zm79.42-104-44.64,44.79a8,8,0,1,1-11.33-11.3L224,92.7,163.32,32,122.1,73.35a8,8,0,0,1-11.33-11.29L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.32,104Z`},child:[]}]})(e)}function wo(e){return k({tag:`svg`,attr:{viewBox:`0 0 256 256`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M235.33,104l-53.47,53.65c4.56,12.67,6.45,33.89-13.19,60A15.93,15.93,0,0,1,157,224c-.38,0-.75,0-1.13,0a16,16,0,0,1-11.32-4.69L96.29,171,53.66,213.66a8,8,0,0,1-11.32-11.32L85,159.71l-48.3-48.3A16,16,0,0,1,38,87.63c25.42-20.51,49.75-16.48,60.4-13.14L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.33,104Z`},child:[]}]})(e)}function To(e,t,n,r={}){let{align:i=`right`,side:a=`bottom`,gap:o=6,margin:s=8}=r,c=t.width,l=t.height,u=Math.max(0,n.width-c-s),d=Math.max(0,n.height-l-s),f=i===`left`?e.left:e.right-c;f=Math.max(s,Math.min(f,u));let p;return a===`top`?(p=e.top-l-o,p<s&&e.bottom+o+l<=n.height-s&&(p=e.bottom+o)):(p=e.bottom+o,p+l>n.height-s&&e.top-l-o>=s&&(p=e.top-l-o)),p>d&&(p=d),p<s&&(p=s),{x:Math.round(f),y:Math.round(p)}}function Eo(e){let{open:t=!0,anchor:n,anchorEl:r,onClose:i,isInside:a,align:o=`right`,side:s=`bottom`,gap:c=6,margin:l=8}=e,u=(0,g.useRef)(null),[d,f]=(0,g.useState)(null),p=(0,g.useRef)(i);(0,g.useLayoutEffect)(()=>{p.current=i});let m=()=>{if(!n)return null;if(`current`in n)return n.current?.getBoundingClientRect()??null;if(typeof n.getBoundingClientRect==`function`)return n.getBoundingClientRect();let e=n;return typeof e.left==`number`&&typeof e.right==`number`&&typeof e.top==`number`&&typeof e.bottom==`number`?e:null},h=()=>r||(n&&`current`in n?n.current:n&&typeof n.getBoundingClientRect==`function`?n:null),_=()=>{if(!t)return;let e=u.current;if(!e)return;let n=e.getBoundingClientRect();if(n.width===0&&n.height===0)return;let r=h(),i=r&&r.isConnected?r.getBoundingClientRect():m();if(!i)return;let a=To(i,{width:n.width,height:n.height},{width:window.innerWidth,height:window.innerHeight},{align:o,side:s,gap:c,margin:l});f(e=>e?.x===a.x&&e?.y===a.y?e:a)};return(0,g.useLayoutEffect)(()=>{t?_():f(null)},[t,n,r,o,s,c,l]),zt(()=>{p.current()},t),(0,g.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||h()?.contains(e)||a?.(e)),n=t=>{e(t.target)||p.current()};return document.addEventListener(`mousedown`,n,!0),window.addEventListener(`resize`,_,!0),window.addEventListener(`scroll`,_,!0),()=>{document.removeEventListener(`mousedown`,n,!0),window.removeEventListener(`resize`,_,!0),window.removeEventListener(`scroll`,_,!0)}},[t,n,r]),{panelRef:u,pos:d,style:{position:`fixed`,left:d?.x??-9999,top:d?.y??-9999,visibility:d?`visible`:`hidden`},measure:_}}function Do({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=Nn(),{panelRef:d,style:f,measure:p}=Eo({anchor:e,anchorEl:t,onClose:l}),[,m]=(0,g.useState)(null),h=(0,g.useRef)(null),[_,v]=(0,g.useState)(null),y=(0,g.useMemo)(()=>{let e=new Map((i??[]).map((e,t)=>[e,t]));return n.map((e,t)=>({plugin:e,index:t})).sort((t,n)=>(e.get(t.plugin.id)??1e6+t.index)-(e.get(n.plugin.id)??1e6+n.index)).map(({plugin:e})=>e)},[n,i]);(0,g.useLayoutEffect)(()=>{p()},[y,p]);let b=(e,t)=>{let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=r+t;if(r<0||i<0||i>=n.length)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))},x=(e,t)=>{if(!e||e===t)return;let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=n.indexOf(t);if(r<0||i<0)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))};return(0,j.createPortal)((0,X.jsxs)(`div`,{ref:d,className:`pm-panel`,role:`menu`,"aria-label":u(`pluginMenuTitle`),style:f,children:[(0,X.jsxs)(`div`,{className:`pm-head`,"aria-hidden":`true`,children:[(0,X.jsx)(ht,{className:`pm-head-icon`,"aria-hidden":!0}),u(`pluginMenuTitle`)]}),(0,X.jsx)(`div`,{className:`pm-list`,children:n.length===0?(0,X.jsx)(`div`,{className:`pm-empty`,children:u(`pluginMenuEmpty`)}):y.map(e=>{let t=e.view===!1||!!e.error,n=!t&&r.has(e.id),i=e.error??(e.view===!1?u(`pluginMenuNoView`):void 0),o=e.iconSvg?void 0:e.icon&&!/[a-z]/i.test(e.icon)?e.icon:void 0;return(0,X.jsxs)(`div`,{className:`pm-row${_===e.id?` drop-target`:``}`,role:`none`,onDragOver:n=>{!t&&h.current&&(n.preventDefault(),v(e.id))},onDrop:t=>{t.preventDefault(),x(t.dataTransfer.getData(`text/plain`)||h.current,e.id),h.current=null,m(null),v(null)},children:[!t&&(0,X.jsx)(`button`,{type:`button`,className:`pm-drag`,draggable:!0,"aria-label":u(`pluginMenuReorder`),title:u(`pluginMenuReorderHint`),onDragStart:t=>{m(e.id),h.current=e.id,t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id);let n=document.createElement(`div`);n.style.cssText=`position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0`,document.body.appendChild(n),t.dataTransfer.setDragImage(n,0,0),requestAnimationFrame(()=>n.remove())},onDragEnd:()=>{h.current=null,m(null),v(null)},onKeyDown:t=>{(t.key===`ArrowUp`||t.key===`ArrowDown`)&&(t.preventDefault(),b(e.id,t.key===`ArrowUp`?-1:1))},children:(0,X.jsx)(Se,{"aria-hidden":!0})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-row-main`,disabled:t,title:i,onClick:()=>s(e.id),children:[o||e.iconSvg?(0,X.jsx)(hi,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(ht,{className:`pm-icon`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`pm-name`,children:e.name}),i&&(0,X.jsx)(`span`,{className:`pm-sub`,children:i})]}),!t&&(0,X.jsx)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":n,"aria-label":u(n?`pluginMenuUnpin`:`pluginMenuPin`),className:`pm-pin${n?` on`:``}`,onClick:()=>a(e.id,!n),children:n?(0,X.jsx)(wo,{"aria-hidden":!0}):(0,X.jsx)(Co,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(ue,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function Oo({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=Nn(),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``);async function d(){try{let e=await fetch(gn(fn(`/api/locales`)));if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();o(t.packs??[]),c(``)}catch(e){c(t(`localeListFailed`,{error:e instanceof Error?e.message:String(e)}))}}(0,g.useEffect)(()=>{d()},[]);async function f(e){u(e),c(``);try{let t=await fetch(gn(fn(`/api/locales/${e}/install`)),{method:`POST`});if(!t.ok){let e=`HTTP ${t.status}`;try{e=(await t.json()).error??e}catch{}throw Error(e)}await i(),await d()}catch(e){c(t(`localeInstallFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(``)}}async function p(e){u(e),c(``);try{let t=await fetch(gn(fn(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);Tn(e),n===e&&r(`zh`),await i(),await d()}catch(e){c(t(`localeInstallFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(``)}}return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:e,children:(0,X.jsxs)(`div`,{className:`bg-task-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`bg-task-head`,children:[(0,X.jsxs)(`span`,{className:`bg-task-title`,children:[(0,X.jsx)(Fe,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(P,{})})]}),s&&(0,X.jsx)(`div`,{className:`bg-task-empty`,children:s}),a===null&&!s?(0,X.jsx)(`div`,{className:`bg-task-empty`,children:t(`loading`)}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:(a??[]).map(e=>{let n=l===e.code;return(0,X.jsxs)(`li`,{className:`bg-task-item`,children:[(0,X.jsxs)(`div`,{className:`bg-task-info`,children:[(0,X.jsxs)(`div`,{className:`bg-task-line1`,children:[(0,X.jsx)(`span`,{className:`bg-task-port`,children:e.nativeName}),e.installed&&e.version&&(0,X.jsxs)(`span`,{className:`bg-task-name`,children:[`v`,e.version]})]}),(0,X.jsxs)(`div`,{className:`bg-task-line2`,children:[(0,X.jsx)(`span`,{children:e.code}),e.installed?(0,X.jsxs)(`span`,{children:[t(`localeInstalled`),` · `,t(`localeRemoveHint`)]}):(0,X.jsx)(`span`,{children:t(`localeGetMore`)})]})]}),e.installed?(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,disabled:n,title:t(`localeRemove`),onClick:()=>void p(e.code),children:[(0,X.jsx)(L,{}),(0,X.jsx)(`span`,{children:t(n?`localeRemoving`:`localeRemove`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:n,title:t(`localeInstall`),onClick:()=>void f(e.code),children:[(0,X.jsx)(qe,{}),(0,X.jsx)(`span`,{children:t(n?`localeDownloading`:`localeInstall`)})]})]},e.code)})}),(0,X.jsx)(`div`,{className:`bg-task-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`bgTaskRefresh`),onClick:()=>void d(),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:t(`bgTaskRefresh`)})]})})]})})}var ko=`xing-shuyin/pi-web-ui`,Ao={state:`idle`,version:null,percent:0,message:null};function jo(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Mo(e,t){switch(t.state){case`checking`:return{...e,state:`checking`,message:null};case`available`:return{...e,state:`available`,version:t.version??e.version,message:null};case`up-to-date`:return{...e,state:`up-to-date`,version:t.version??e.version,message:null};case`downloading`:return{...e,state:`downloading`,percent:jo(t.percent),message:null};case`downloaded`:return{...e,state:`downloaded`,version:t.version??e.version,percent:100,message:null};case`error`:return{...e,state:`error`,message:t.message??`unknown error`};default:return e}}function No(e){if(!Rn(e))return null;let t=(e??(typeof window>`u`?void 0:window))?.piDesktop?.updater;return!t||typeof t.check!=`function`||typeof t.download!=`function`?null:t}function Po(e){return e instanceof Error?e.message:String(e)}function Fo(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${ko}/releases/tag/v${t}`:`https://github.com/${ko}/releases/latest`}function Io(){let[e]=(0,g.useState)(()=>No()),[t,n]=(0,g.useState)(Ao);(0,g.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>Mo(t,e)))},[e]);let r=(0,g.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:Po(e)}))))},[e]),i=(0,g.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:Po(e)}))))},[e]),a=(0,g.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:Po(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}function Lo(e){let t=Math.max(0,e.input??0),n=Math.max(0,e.cacheRead??0),r=Math.max(0,e.cacheWrite??0),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0,writeRate:i>0?Math.min(r/i,1):0}}var Ro=2e3;function zo(e,t,n=Ro){return e.filter(e=>t-e.t<=n)}function Bo(e,t=Ro){if(e.length<2)return 0;let n=e[e.length-1],r=e.find(e=>e.t>=n.t-t)??e[0],i=(n.t-r.t)/1e3;return i<=0?0:Math.max(0,(n.out-r.out)/i)}function Vo(e){if(!e)return 0;let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r>=12352&&r<=12543||r>=13312&&r<=19903||r>=19968&&r<=40959||r>=63744&&r<=64255||r>=65280&&r<=65519||r===12288)&&t++}let n=e.length-t;return Math.round(t+n/4)}function Ho(e){let t=0;for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text?t+=Vo(n.text):n.type===`thinking`&&typeof n.thinking==`string`&&n.thinking&&(t+=Vo(n.thinking));return t}function Uo(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(e)}function Wo(e){return e.startsWith(`zh`)?`ZH`:e.startsWith(`ja`)?`JA`:e.startsWith(`ko`)?`KO`:e.startsWith(`fr`)?`FR`:e.startsWith(`de`)?`DE`:e.startsWith(`es`)?`ES`:e.startsWith(`ru`)?`RU`:e.startsWith(`pt`)?`PT`:e.startsWith(`it`)?`IT`:`EN`}function Go({entry:e,bar:t,chat:n,view:r,plugins:i,onViewChange:a,onOpenPanel:o,onOpenSettings:s,onOpenGlobalSearch:c,onOpenBgTasks:l,onOpenProjectPicker:u,onOpenPluginMenu:d,isPluginMenuOpen:f,isProjectPickerOpen:p,onUiAction:m,uiContextEntries:h,dropdownProps:_}){let v=Z(),{locale:y,packs:b,setLocale:x}=Nn(),{engine:S}=Xa(),C=S===`dsh`,[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(!1),[A,j]=(0,g.useState)(!1),ee=n.settings?.uiLayout,M=n.state,te=M?.stats,N=M?.isStreaming??!1,P=ki(te?.cost??0),F=(0,g.useRef)([]),re=M?.streamingMessage?Ho(M.streamingMessage.content):0;(0,g.useEffect)(()=>{if(!N){F.current=[];return}let e=Date.now(),t=F.current,n=t[t.length-1];n&&e-n.t<250||(F.current=zo([...t,{t:e,out:re}],e))},[N,re]);let ie=N?Bo(F.current):0,ae=n=>{n.preventDefault(),n.stopPropagation();let r=t=>{let n={...ee?.slots,[e.id]:t};$({type:`set_settings`,uiLayout:{...ee,slots:n}})},i=()=>{let t=new Set(ee?.hidden??[]);t.add(e.id),$({type:`set_settings`,uiLayout:{...ee,hidden:[...t]}})},a=[];t!==`top`&&a.push({id:`host:move-top`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToTop`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`bottom`&&a.push({id:`host:move-bottom`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToBottom`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`left`&&a.push({id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToLeft`),kind:`action`,order:30,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`right`&&a.push({id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToRight`),kind:`action`,order:40,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),a.push({id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:v(`uiLayoutRestore`),kind:`action`,order:50,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),h&&h.length>0&&a.push(...h),Ea({x:n.clientX,y:n.clientY,slot:`contextmenu.topbar`,target:{id:e.id,label:e.label},entries:a,onHostAction:e=>{e.id===`host:move-top`?r(`topbar.primary`):e.id===`host:move-bottom`?r(`bottombar`):e.id===`host:move-left`?r(`sidebar.left`):e.id===`host:move-right`?r(`sidebar.right`):e.id===`host:hide-item`&&i()}})},I=e.id,L=e.labelExplicit?e.label:``,R=e=>L||e,oe=e=>L?`${L} ${e}`:e;if(e.kind===`select`&&e.options?.length){let t=e.options.some(t=>t.value===e.value)?e.value:e.options[0].value;return(0,X.jsx)(`select`,{className:`bar-item bar-item-select`,title:e.hint??e.label,"data-tip":e.hint??e.label,"aria-label":e.label,value:t,onChange:t=>m?.(e,t.target.value),onContextMenu:ae,"data-bar-item":I,children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})}if(I===`host:brand`)return(0,X.jsxs)(`span`,{className:`bar-item brand bar-item-brand`,title:v(`brand`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`brand-logo bar-item-brand-logo`,children:`π`}),(0,X.jsx)(`span`,{className:`brand-name bar-item-text`,children:R(`pi-web-ui`)})]});if(I===`host:conn`){let e=n.ready?`ok`:n.status===`closed`?`error`:`busy`,t=n.ready?v(`connected`):n.status===`closed`?v(`reconnecting`):v(`connecting`);return(0,X.jsxs)(`span`,{className:`bar-item status-item status-conn ${e} bar-item-conn`,title:t,"data-tip":t,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`status-dot ${e}`}),(0,X.jsx)(`span`,{className:`status-conn-label bar-item-text`,children:oe(t)})]})}if(I===`host:engine`)return S===`pi`?null:(0,X.jsx)(`span`,{className:`bar-item status-item engine-badge engine-${S} bar-item-engine`,title:`${v(`engineBadge`)}: ${S}`,"data-tip":`${v(`engineBadge`)}: ${S}`,onContextMenu:ae,"data-bar-item":I,children:oe(S===`dsh`?`DSH`:S)});if(I===`host:ctx`){let e=te?.contextUsage,t=e?.softCap??null,n=t!==null&&t>0&&t<(e?.contextWindow??0),r=n?t:e?.contextWindow??0,i=e?.tokens!==null&&e?.tokens!==void 0&&r>0?Math.min(100,Math.round(e.tokens/r*100)):null,a=e?.tokens!==null&&e?.tokens!==void 0?Uo(e.tokens):null,o=r>0?Uo(r):null,s=a!==null&&o!==null&&i!==null?`${a} / ${o}`:`—`,c=i===null?``:i>=80?`warn`:i>=50?`mid`:`ok`,l=n?`${v(`contextUsage`)}: ${Uo(e?.tokens??0)} / ${Uo(t)} (${v(`softCapMarker`)}, max ${Uo(e?.contextWindow??0)})`:t!==null&&t>0?`${v(`contextUsage`)}: ${s} · ${v(`softCapMarker`)}: ${Uo(t)}`:`${v(`contextUsage`)}: ${s}`,u=i!==null&&i>0?+(31.42*(1-Math.min(i,100)/100)).toFixed(2):31.42;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-ctx bar-item-ctx`,title:l,"data-tip":l,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsxs)(`svg`,{className:`ctx-ring ${c}`,viewBox:`0 0 14 14`,width:`13`,height:`13`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,X.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:31.42,strokeDashoffset:u,"data-percent":i})]}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[L?`${L} `:``,a!==null&&o!==null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`ctx-val`,children:a}),(0,X.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,X.jsx)(`span`,{className:`ctx-max`,children:o})]}):s]})]})}if(I===`host:cache`){let e=Lo(te?.tokens??{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}),t=e.hitRate*100,n=e.totalInput===0?``:e.hitRate>=.7?`ok`:e.hitRate>=.4?`mid`:`warn`,r=e.totalInput>0?`${t.toFixed(1)}%`:`—`,i=v(`cacheHitTip`,{read:Uo(e.read),write:Uo(e.write),miss:Uo(e.miss),input:Uo(e.totalInput)}),a=e.totalInput>0?`${v(`cacheHit`)}: ${r} · ${i}`:v(`cacheHit`),o=e.totalInput===0;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-cache bar-item-cache${o?` is-zero`:``}`,title:a,"data-tip":a,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(Ye,{className:`bar-item-icon`}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[L?`${L} `:``,(0,X.jsx)(`b`,{className:`cache-pct ${n}`,children:r})]})]})}if(I===`host:cost`){let e=te?.cost??0,t=P.tooltip||v(`cumulativeCost`);return(0,X.jsxs)(`span`,{className:`bar-item status-item status-cost bar-item-cost${e<=0?` is-zero`:``}${L?` has-name`:``}`,title:t,"data-tip":t,onContextMenu:ae,"data-bar-item":I,children:[L?(0,X.jsx)(`span`,{className:`bar-item-text`,children:L}):null,P.symbol?(0,X.jsx)(`span`,{className:`bar-item-char`,children:P.symbol}):null,(0,X.jsx)(`span`,{className:`bar-item-text`,children:P.value})]})}if(I===`host:msg-count`){let e=te?.totalMessages??0,t=`${v(`sessionMessages`)}: ${e}`;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-msg-count bar-item-msg-count${e===0?` is-zero`:``}`,title:t,"data-tip":t,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(J,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:oe(String(e))})]})}if(I===`host:working`){if(!N)return null;let e=(M?.queue?.steering?.length??0)+(M?.queue?.followUp?.length??0);return(0,X.jsxs)(`span`,{className:`bar-item status-item working bar-item-working`,title:v(`working`),"data-tip":v(`working`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`working-spin`}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[R(v(`working`)),e>0&&` ⏳ ${e}`]}),(0,X.jsx)(`span`,{className:`status-rate bar-item-rate`,title:v(`rateTip`),children:ie>0?`${Math.round(ie)}${v(`tps`)}`:`…`})]})}if(I===`host:status-delegate`)return M?.delegateMode?(0,X.jsxs)(`span`,{className:`bar-item status-item delegate-badge bar-item-delegate`,title:M.delegateConvId?v(`delegateModeOpenTip`):v(`delegateModeBadgeTip`),"data-tip":M.delegateConvId?v(`delegateModeOpenTip`):v(`delegateModeBadgeTip`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`bar-item-icon`,children:`🔎`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:R(v(`delegateModeBadge`))}),M.delegateConvId?(0,X.jsx)(`button`,{type:`button`,className:`delegate-badge-open`,title:v(`delegateModeOpenTip`),onClick:()=>$({type:`switch_conversation`,id:M.delegateConvId}),children:`↗`}):null]}):null;if(I===`host:host-metrics`){let e=n.hostMetrics;if(!e)return null;let t=e.cpuPercent===null||!Number.isFinite(e.cpuPercent)?`—`:`${Math.round(e.cpuPercent)}%`,r=Number.isFinite(e.memoryPercent)?`${Math.round(e.memoryPercent)}%`:`—`;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-host-metrics bar-item-host-metrics`,title:`${v(`hostResourcesTip`)}\n${v(`hostProcessor`)}: ${t} · ${v(`hostMemory`)}: ${r}`,"data-tip":`${v(`hostResourcesTip`)}\n${v(`hostProcessor`)}: ${t} · ${v(`hostMemory`)}: ${r}`,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(Ze,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:oe(`${t} · ${r}`)})]})}if(I===`host:browser`)return n.settings?.disabledAgentTools?.includes(`browser_page`)?null:(0,X.jsx)(`span`,{className:`bar-item-wrap`,onContextMenu:ae,"data-bar-item":I,children:(0,X.jsx)(ur,{})});if(I===`host:sound`)return(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:w,onOpenChange:T,tip:R(v(`sound`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`sound`)),"data-tip":R(v(`sound`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(ne,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:R(v(`sound`))})]}),children:[_?.sound&&_?.onSoundChange?(0,X.jsx)(Fn,{settings:_.sound,onChange:_.onSoundChange,onPreview:_.onSoundPreview??(()=>{})}):null,(0,X.jsx)(si,{})]});if(I===`host:language`)return(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:E,onOpenChange:D,tip:R(v(`language`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`language`)),"data-tip":R(v(`language`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(Fe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:oe(Wo(y))})]}),children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`language`)}),b.map(e=>(0,X.jsx)(Ht,{active:y===e.code,onClick:()=>{x(e.code),D(!1)},children:e.nativeName},e.code)),_?.onLocaleModalOpen?(0,X.jsxs)(Ht,{onClick:()=>{D(!1),_.onLocaleModalOpen?.()},children:[(0,X.jsx)(qe,{}),` `,v(`localeGetMore`)]}):null]});if(I===`host:theme`){let e=_?.themes??[],n=_?.theme??null;return(0,X.jsx)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:O,onOpenChange:t=>{k(t),t&&e.length===0&&_?.reloadThemes?.()},tip:R(v(`theme`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`theme`)),"data-tip":R(v(`theme`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(B,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:R(v(`theme`))})]}),children:(()=>{let t=e.filter(e=>e.group===`classic`),r=e.filter(e=>e.group!==`classic`),i=e=>{let t=y===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?v(`themeLight`):e.scheme===`dark`?v(`themeDark`):``;return n?y===`zh`?`${t}(${n})`:`${t} (${n})`:t};return(0,X.jsxs)(X.Fragment,{children:[t.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`themeGroupClassics`)}),t.map(e=>(0,X.jsx)(Ht,{active:n===e.id,onClick:()=>{_?.onThemeChange?.(e.id),k(!1)},children:i(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:t.length>0?v(`themeGroupBuiltin`):v(`theme`)}),(0,X.jsx)(Ht,{active:n===null,onClick:()=>{_?.onThemeChange?.(null),k(!1)},children:v(`themeDefault`)}),r.map(e=>(0,X.jsx)(Ht,{active:n===e.id,onClick:()=>{_?.onThemeChange?.(e.id),k(!1)},children:i(e)},e.id))]})})()})}if(I===`host:update`){let e=_?.updatesCount??0;return _?.managed?(0,X.jsxs)(`span`,{className:`bar-item chip`,title:v(`updatesManaged`),"data-tip":v(`updatesManaged`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(qe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:oe(`v${_?.appVersion??n.update?.current??`…`}`)})]}):(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:A,onOpenChange:e=>{j(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},tip:R(v(`update`)),fit:!0,caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`update`)),"data-tip":R(v(`update`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(qe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:oe(`v${n.update?.current??`…`}`)}),n.update&&!n.update.upToDate&&(0,X.jsx)(`span`,{className:`update-dot`}),e>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:e})]}),children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`update`)}),_?.renderUpdateBody?.(),_?.renderAllUpdatesBody?.()]})}let V=null,H=e.label,se=null,ce=!1,le=!1,U=``,de,W;switch(I){case`host:chat`:V=(0,X.jsx)(J,{className:`bar-item-icon`}),H=R(v(`chat`)),ce=r===`chat`,le=!0,W=()=>a?.(`chat`);break;case`host:terminal`:V=(0,X.jsx)(z,{className:`bar-item-icon`}),H=R(v(`terminal`)),ce=r===`terminal`,le=!0,W=()=>a?.(`terminal`);break;case`host:git`:V=(0,X.jsx)(Le,{className:`bar-item-icon`}),H=R(v(`scmTab`)),ce=r===`git`,le=!0,W=()=>a?.(`git`);break;case`host:new-chat`:V=(0,X.jsx)(me,{className:`bar-item-icon`}),H=R(v(`newChat`)),U=`chip newchat`,W=()=>{a?.(`chat`),$({type:`new_chat`}),sr()};break;case`host:new-ephemeral-chat`:if(C)return null;V=(0,X.jsx)(Ot,{className:`bar-item-icon`}),H=R(v(`newChatEphemeral`)),U=`chip newchat ephemeral-chat-btn`,W=()=>{a?.(`chat`),$({type:`new_chat`,ephemeral:!0}),sr()};break;case`host:history`:if(r&&r!==`chat`)return null;V=(0,X.jsx)(Se,{className:`bar-item-icon`}),H=R(v(`openHistory`)),U=`panel-toggle`,W=()=>o?.(`left`);break;case`host:files`:if(r&&r!==`chat`)return null;V=(0,X.jsx)(Re,{className:`bar-item-icon`}),H=R(v(`openFiles`)),U=`panel-toggle has-label`,W=()=>o?.(`right`);break;case`host:open-project`:V=(0,X.jsx)(ze,{className:`bar-item-icon`}),H=R(v(`openProject`)),U=`chip open-project`,ce=!!p,W=()=>u?.();break;case`host:search`:V=(0,X.jsx)(fe,{className:`bar-item-icon`}),H=R(v(`searchGlobal`)),U=`chip`,W=()=>c?.();break;case`host:tasks`:V=(0,X.jsx)(ke,{className:`bar-item-icon`}),H=R(v(`bgTasks`)),U=`chip bg-task-chip`,n.bgServers.length>0&&(se=(0,X.jsx)(`span`,{className:`bg-task-badge bar-item-badge`,children:n.bgServers.length})),W=()=>l?.();break;case`host:settings`:V=(0,X.jsx)(ue,{className:`bar-item-icon`}),H=R(v(`settings`)),U=`chip`,W=()=>s?.();break;case`host:plugins`:V=(0,X.jsx)(ht,{className:`bar-item-icon`}),H=R(v(`pluginMenuTitle`)),U=`chip`,W=e=>{d?d(e.currentTarget):s?.(`plugins`)};break;case`host:github`:V=(0,X.jsx)(Ie,{className:`bar-item-icon`}),H=R(`GitHub`),U=`chip github`,W=()=>window.open(`https://github.com/xing-shuyin/pi-web-ui`,`_blank`,`noreferrer,noopener`);break;case`host:cwd`:V=(0,X.jsx)(Re,{className:`bar-item-icon`}),H=oe(M?.cwd?M.cwd.split(/[/\\]/).pop()||M.cwd:v(`openProject`)),U=`status-item status-cwd`,ce=!!p,W=()=>u?.();break;case`host:plugin-status`:if(n.statuses.length===0)return null;V=(0,X.jsx)(Et,{className:`bar-item-icon`}),H=oe(n.statuses.map(e=>e.text).join(` · `)),U=`status-item ext-status`;break;default:if(e.kind===`view`){let t=e.view??``;ce=r===t,le=!0;let o=(i??n.plugins??[]).find(t=>`plugin:${t.id}`===e.source);U=`plugin-tab${o?.error?` broken`:``}`,o?.error&&(de=`${e.label}: ${o.error}`);let s=e.iconSvg||o?.iconSvg,c=e.icon||o?.icon;V=s?(0,X.jsx)(hi,{icon:c,iconSvg:s,className:`bar-item-icon plugin-icon-svg`}):c?(0,X.jsx)(`span`,{className:`bar-item-icon bar-item-glyph`,children:c}):null,W=()=>a?.(t)}else{let n=e.iconSvg,r=e.icon;U=t===`bottom`?`status-item status-action chip`:`chip`,V=n?(0,X.jsx)(hi,{icon:r,iconSvg:n,className:`bar-item-icon plugin-icon-svg`}):r?(0,X.jsx)(`span`,{className:`bar-item-icon bar-item-glyph`,children:r}):null,e.badge&&(se=(0,X.jsx)(`span`,{className:`bar-item-badge`,children:e.badge})),W=()=>m?.(e)}}let pe=de??e.hint??H,G=[`bar-item`,le?`tb-tab${ce?` active`:``}`:``,U,ce&&!le?`active`:``].filter(Boolean).join(` `);return(0,X.jsxs)(`button`,{type:`button`,role:le?`tab`:void 0,"aria-selected":le?ce:void 0,"aria-haspopup":I===`host:plugins`?`menu`:void 0,"aria-expanded":I===`host:plugins`?!!f:void 0,className:G,title:pe,"data-tip":pe,"aria-label":H,onClick:W,onContextMenu:ae,"data-bar-item":I,children:[V,(0,X.jsx)(`span`,{className:`bar-item-text`,children:H}),se]})}var Ko={name:`@earendil-works/pi-coding-agent`,kind:`pi-core`,current:``,latest:null,upToDate:!1};function qo({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=Eo({open:t,anchor:e,onClose:n});return(0,g.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,j.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Jo(){let[e,t]=(0,g.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,g.useEffect)(()=>{if(typeof window>`u`||window.matchMedia===void 0)return;let e=window.matchMedia(`(max-width: 768px)`),n=e=>t(e.matches);return typeof e.addEventListener==`function`?e.addEventListener(`change`,n):e.addListener(n),()=>{typeof e.removeEventListener==`function`?e.removeEventListener(`change`,n):e.removeListener(n)}},[]),e}function Yo({chat:e,terminal:t,view:n,plugins:r,uiPrimary:i,uiOverflow:a,uiContextTopbar:o,onUiAction:s,onViewChange:c,onOpenPanel:l,onOpenSettings:u,onManagePlugins:d,onOpenBgTasks:f,onOpenGlobalSearch:p,sound:m,onSoundChange:h,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x,onOpenIconEdit:S}){let{locale:C,setLocale:w,t:T,packs:E}=Nn(),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(!1),[j,ee]=(0,g.useState)(null),M=Za(`cwd`),te=Za(`workspaceRoots`),N=Qa(),P=(0,g.useRef)(null),F=t=>!e.tabs||t===`chat`||e.tabs.includes(t),re=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!Xi(e)),ie=new Set([...i??[],...a??[]].filter(e=>Xi(e)&&!e.hidden).map(e=>e.source.slice(7))),ae=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),I=r.map((e,t)=>({id:e.id,index:t})).sort((e,t)=>(ae.get(`${e.id}:__view`)??1e6+e.index)-(ae.get(`${t.id}:__view`)??1e6+t.index)).map(e=>e.id),L=i===void 0?[`host:history`,`host:brand`,`host:open-project`,`host:chat`,`host:terminal`,`host:git`,`host:plugins`,`host:search`,`host:browser`,`host:tasks`,`host:settings`,`host:sound`,`host:language`,`host:theme`,`host:update`,`host:github`,`host:new-chat`,`host:new-ephemeral-chat`,`host:files`].map(e=>({id:e,entry:null})):i.map(e=>({id:e.id,entry:e})),R=(F(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!L.some(t=>t.id===`${e.id}:__view`)).map(e=>({id:`${e.id}:__view`,slot:`topbar.primary`,source:`plugin:${e.id}`,label:e.name,kind:`view`,view:`plugin:${e.id}`,order:23,align:`end`,hidden:!1,userOverrides:[],arrangedBy:[]})),oe=e=>{if(e.source!==`host`)return!1;switch(e.id){case`host:history`:return l(`left`),!0;case`host:files`:return l(`right`),!0;case`host:new-chat`:return c(`chat`),$({type:`new_chat`}),sr(),!0;case`host:new-ephemeral-chat`:return c(`chat`),$({type:`new_chat`,ephemeral:!0}),sr(),!0;case`host:open-project`:return A(!0),!0;case`host:search`:return p(),!0;case`host:tasks`:return f(),!0;case`host:settings`:return u(),!0;case`host:plugins`:return ee(P.current?{rect:P.current.getBoundingClientRect(),el:P.current}:null),!0;default:return!1}},V=(t,n,r)=>{t.preventDefault(),t.stopPropagation();let i=e.settings?.uiLayout,a=e=>{let t={...i?.slots,[n]:e};$({type:`set_settings`,uiLayout:{...i,slots:t}})},s=()=>{let e=new Set(i?.hidden??[]);e.add(n),$({type:`set_settings`,uiLayout:{...i,hidden:[...e]}})},c=[{id:`host:move-bottom`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToBottom`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToLeft`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToRight`),kind:`action`,order:30,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:T(`uiLayoutRestore`),kind:`action`,order:40,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},...o??[]];Ea({x:t.clientX,y:t.clientY,slot:`contextmenu.topbar`,target:{id:n,label:r},entries:c,onHostAction:e=>{e.id===`host:move-bottom`?a(`bottombar`):e.id===`host:move-left`?a(`sidebar.left`):e.id===`host:move-right`?a(`sidebar.right`):e.id===`host:hide-item`&&s()}})},{appVersion:H}=Xa(),se=$a(),ce=eo(),[le,U]=(0,g.useState)(!1);(0,g.useEffect)(()=>{le&&e.status===`open`&&U(!1)},[le,e.status]);let[de,W]=(0,g.useState)(!1),[pe,G]=(0,g.useState)(!1),[K,he]=(0,g.useState)(!1),[ge,q]=(0,g.useState)(!1),_e=Rn(),ve=Io(),[ye,be]=(0,g.useState)(!1),xe=()=>{if(!e.ready)return;let n=T(`updateTabTitle`),r={name:n,command:`npm i -g pi-web-ui@latest`,cwd:"${pwd}"},i=e.terminals.find(e=>e.title===n);i?(t.restart(i.id),$({type:`run_command`,terminalId:i.id,conversationId:i.conversationId,command:r,cols:80,rows:24})):t.create({id:jt(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r}),q(!1),c(`terminal`)},Ce=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:kt(n),cwd:"${pwd}"},a=e.terminals.find(e=>e.title===r);a?(t.restart(a.id),$({type:`run_command`,terminalId:a.id,conversationId:a.conversationId,command:i,cols:80,rows:24})):t.create({id:jt(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:r,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:i}),q(!1),c(`terminal`)},we=e.updatesAll??[],Te=e.updatesSdk,Ee=Te&&Te.newerInstalled?{running:Te.running,installed:Te.newerInstalled}:null,De=Te?.bundledInUse===!0,Oe=we.find(e=>e.kind===`pi-core`&&!e.error),Ae=De&&(!Oe||!Oe.upToDate),je=Ae&&!Oe,Me=we.filter(e=>!e.upToDate&&!e.error).length,Ne=we.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Pe=e=>e.kind===`git-extension`&&e.source?e.source:e.name,Be=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,Ve=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},He=(e,t)=>{if(!t)return Ve(e);let n=Ve(e),r=Ve(t);return n===r?n:`${n} → ${r}`},Ue=()=>(0,X.jsxs)(`div`,{className:`dd-updates-all`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`updatesAllTitle`)}),e.updatesAll===null?(0,X.jsx)(`div`,{className:`dd-note`,children:T(`checkingUpdate`)}):we.length===0?(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updatesAllUpToDate`)}):(0,X.jsx)(`ul`,{className:`dd-all-list`,children:we.map(e=>{let t=Ee!=null&&e.kind===`pi-core`,n=!e.error&&(!e.upToDate||t);return(0,X.jsxs)(`li`,{className:`dd-all-item${e.error?` err`:n?` warn`:``}`,children:[e.kind!==`webui`&&!e.upToDate&&!e.error&&(0,X.jsx)(`button`,{type:`button`,className:`dd-update-btn`,onClick:()=>Ce([e],T(`updatePkgTabTitle`,{name:e.name})),children:T(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:Be(e),children:Pe(e)}),(0,X.jsxs)(`span`,{className:`dd-all-meta`,children:[(0,X.jsx)(`span`,{className:`dd-all-kind`,children:e.kind===`webui`?T(`kindWebUi`):e.kind===`pi-core`?T(`kindPiCore`):e.kind===`git-extension`?T(`kindGitExtension`):e.kind===`plugin`?T(`kindPlugin`):T(`kindPackage`)}),(0,X.jsx)(`span`,{className:`dd-all-vers`,title:e.error?e.error:e.kind===`git-extension`?e.upToDate?e.current:`${e.current} → ${e.latest}`:void 0,children:e.error?T(`updateCheckFailed`):e.kind===`git-extension`?e.upToDate?Ve(e.current):He(e.current,e.latest):e.kind===`plugin`?e.upToDate?e.current.startsWith(`v`)?e.current:Ve(e.current):He(e.current,e.latest):e.upToDate?`v${e.current}`:(0,X.jsxs)(X.Fragment,{children:[`v`,e.current,` → v`,e.latest]})}),t&&!e.error&&(0,X.jsx)(`span`,{className:`dd-split-run`,children:T(`piCoreSplitRun`,{running:Ee.running})})]})]},`${e.kind}:${e.name}`)})}),Ee&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`piSdkSplitNote`,{running:Ee.running,installed:Ee.installed})}),Ae&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`piSdkBundledNote`,{running:Te.running})}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[je&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce([Ko],T(`installGlobalEngineTabTitle`)),children:T(`installGlobalEngineBtn`)}),Ne.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce(Ne,T(`updateAllTabTitle`)),children:T(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:Ne.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:T(`updatesAllRefresh`)})]})]}),We=()=>{let t=Fo(e.update?.latest??ve.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:T(`updateDesktopManual`)});if(!ve.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopNoBridge`)}),n]});switch(ve.state){case`checking`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopChecking`)}),n]});case`available`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopAvailable`,{version:ve.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.download(),children:T(`updateDesktopDownload`)}),n]});case`downloading`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopDownloading`,{n:ve.percent})}),n]});case`downloaded`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`updateDesktopDownloaded`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.quitAndInstall(),children:T(`updateDesktopInstall`)}),n]});case`up-to-date`:return(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`upToDate`)});case`error`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopError`,{error:ve.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>ve.check(),children:T(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.check(),children:T(`updateDesktopCheck`)}),n]})}},Ge=()=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`dd-update`,children:[(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:T(`currentVersion`)}),(0,X.jsxs)(`b`,{children:[`v`,e.update?.current??`…`]})]}),(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:T(`latestVersion`)}),(0,X.jsx)(`b`,{children:e.update===null?T(`checkingUpdate`):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:T(`checkingUpdate`)})]}),e.update&&e.update.upToDate&&(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`upToDate`)}),e.update&&!e.update.upToDate&&e.update.latest&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateAvailable`,{version:e.update.latest})}),e.update?.latestPublishedAt&&Date.now()-new Date(e.update.latestPublishedAt).getTime()<18e5&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateJustPublished`,{version:e.update.latest??``})}),e.update&&!e.update.upToDate&&e.update.latest&&!_e&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&_e&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopNote`)})]}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`check_update`}),children:e.update===null?T(`checkingUpdate`):T(`checkUpdate`)}),e.update&&!e.update.upToDate&&e.update.latest&&!_e&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:xe,children:T(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&_e&&We(),ce&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:le,title:T(`restartServiceTip`,{name:ce.name}),onClick:()=>{le||(U(!0),$({type:`restart_service`}))},children:T(le?`restartingService`:`restartService`)})]})]}),Y=Jo(),Je={"host:brand":(0,X.jsxs)(`span`,{className:`brand`,children:[(0,X.jsx)(`span`,{className:`brand-logo`,children:`π`}),(0,X.jsx)(`span`,{className:`brand-name`,children:`pi-web-ui`})]}),"host:open-project":(0,X.jsxs)(`button`,{type:`button`,className:`chip open-project`,"data-tip":T(`openProject`),onClick:()=>A(!0),children:[(0,X.jsx)(ze,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`openProject`)})]}),"host:history":n===`chat`&&F(`history`)?(0,X.jsx)(`button`,{type:`button`,className:`panel-toggle`,"data-tip":T(`openHistory`),"aria-label":T(`openHistory`),onClick:()=>l(`left`),children:(0,X.jsx)(Se,{})}):null,"host:files":n===`chat`&&F(`files`)?(0,X.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label`,"data-tip":T(`openFiles`),"aria-label":T(`openFiles`),onClick:()=>l(`right`),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{children:T(`openFiles`)})]}):null,"host:new-chat":F(`new-chat`)?(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat`,"data-tip":T(`newChatTip`),onClick:()=>{c(`chat`),$({type:`new_chat`}),sr()},children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:T(`newChat`)})]}):null,"host:new-ephemeral-chat":N?null:(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat ephemeral-chat-btn`,"data-tip":T(`newChatEphemeralTip`),onClick:()=>{c(`chat`),$({type:`new_chat`,ephemeral:!0}),sr()},children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(`span`,{children:T(`newChatEphemeral`)})]}),"host:chat":(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`chat`,className:`tb-tab${n===`chat`?` active`:``}`,"data-tip":T(`chat`),onClick:()=>c(`chat`),children:[(0,X.jsx)(J,{}),(0,X.jsx)(`span`,{children:T(`chat`)})]}),"host:terminal":F(`terminal`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`terminal`,className:`tb-tab${n===`terminal`?` active`:``}`,"data-tip":T(`terminal`),onClick:()=>c(`terminal`),children:[(0,X.jsx)(z,{}),(0,X.jsx)(`span`,{children:T(`terminal`)})]}):null,"host:git":F(`git`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`git`,className:`tb-tab${n===`git`?` active`:``}`,"data-tip":T(`scmTab`),onClick:()=>c(`git`),children:[(0,X.jsx)(Le,{}),(0,X.jsx)(`span`,{children:T(`scmTab`)})]}):null,"host:plugins":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`pluginMenuTitle`),"aria-haspopup":`menu`,"aria-expanded":j!==null,onClick:e=>{let t=e.currentTarget;ee(e=>e?.el===t?null:{rect:t.getBoundingClientRect(),el:t})},children:[(0,X.jsx)(ht,{"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`pluginMenuTitle`)})]}),"host:search":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`searchGlobalTip`),onClick:p,children:[(0,X.jsx)(fe,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(ur,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":T(`bgTasksTip`),onClick:f,children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`bgTasks`)}),e.bgServers.length>0&&(0,X.jsx)(`span`,{className:`bg-task-badge`,children:e.bgServers.length})]}),"host:settings":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`settingsTitle`),onClick:u,children:[(0,X.jsx)(ue,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`settings`)})]}),"host:sound":(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`sound`)})]}),tip:T(`sound`),open:de,onOpenChange:W,caret:!1,children:[(0,X.jsx)(Fn,{settings:m,onChange:h,onPreview:_}),(0,X.jsx)(si,{})]}),"host:language":(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fe,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:En(C)})]}),tip:T(`language`),open:pe,onOpenChange:G,caret:!1,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`language`)}),E.map(e=>(0,X.jsx)(Ht,{active:C===e.code,onClick:()=>{w(e.code),G(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(Ht,{onClick:()=>{G(!1),be(!0)},children:[(0,X.jsx)(qe,{}),` `,T(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(B,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`theme`)})]}),tip:T(`theme`),open:K,caret:!1,onOpenChange:e=>{he(e),e&&v.length===0&&x()},children:(()=>{let e=v.filter(e=>e.group===`classic`),t=v.filter(e=>e.group!==`classic`),n=e=>{let t=C===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?T(`themeLight`):e.scheme===`dark`?T(`themeDark`):``;return n?C===`zh`?`${t}(${n})`:`${t} (${n})`:t};return(0,X.jsxs)(X.Fragment,{children:[e.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`themeGroupClassics`)}),e.map(e=>(0,X.jsx)(Ht,{active:y===e.id,onClick:()=>{b(e.id),he(!1)},children:n(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:e.length>0?T(`themeGroupBuiltin`):T(`theme`)}),(0,X.jsx)(Ht,{active:y===null,onClick:()=>{b(null),he(!1)},children:T(`themeDefault`)}),t.map(e=>(0,X.jsx)(Ht,{active:y===e.id,onClick:()=>{b(e.id),he(!1)},children:n(e)},e.id))]})})()}),"host:update":se?(0,X.jsxs)(`span`,{className:`chip`,"data-tip":T(`updatesManaged`),children:[(0,X.jsx)(qe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,H??e.update?.current??`…`]})]}):(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,e.update?.current??`…`]}),e.update&&!e.update.upToDate&&(0,X.jsx)(`span`,{className:`update-dot`,title:T(`updateAvailable`,{version:e.update.latest??``})}),Me>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:T(`updatesAllBadge`,{n:Me})})]}),tip:T(`update`),open:ge,caret:!1,onOpenChange:e=>{q(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},fit:!0,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`update`)}),Ge(),Ue()]}),"host:github":(0,X.jsx)(`a`,{className:`chip github`,href:`https://github.com/xing-shuyin/pi-web-ui`,target:`_blank`,rel:`noreferrer noopener`,"data-tip":T(`githubRepo`),children:(0,X.jsx)(Ie,{})}),"host:conn":(0,X.jsxs)(`span`,{className:`chip`,"data-tip":e.status,children:[(0,X.jsx)(`span`,{className:`status-dot ${e.status===`open`?`ok`:`busy`}`}),(0,X.jsx)(`span`,{className:`chip-sub`,children:e.status})]}),"host:engine":(0,X.jsx)(`span`,{className:`chip`,"data-tip":`engine`,children:(0,X.jsx)(`span`,{className:`chip-sub`,children:e.engine??`pi`})}),"host:ctx":(0,X.jsx)(`span`,{className:`chip`,"data-tip":T(`contextUsage`),children:(0,X.jsx)(`span`,{className:`chip-sub`,children:(e.state?.stats?.contextUsage?.tokens??0)>0?`${e.state?.stats?.contextUsage?.tokens}`:T(`contextUsage`)})}),"host:cost":(()=>{let t=Oi(e.state?.stats?.cost??0,{fixedDigits:4});return(0,X.jsx)(`span`,{className:`chip`,"data-tip":t.tooltip||T(`cumulativeCost`),children:(0,X.jsxs)(`span`,{className:`chip-sub`,children:[t.symbol,t.value]})})})(),"host:cwd":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":e.state?.cwd??``,onClick:()=>A(!0),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:e.state?.cwd?.split(/[/\\]/).pop()||e.state?.cwd})]})},Ye=new Set([`host:search`,`host:tasks`,`host:settings`,`host:plugins`]),Xe=new Set([`host:sound`,`host:language`,`host:theme`,`host:update`,`host:browser`]),Ze=e=>Ye.has(e)&&!F(e.slice(5)),Qe=e=>{if(e.kind===`view`){if(!F(`plugins`))return null;let t=e.view??``,i=r.find(t=>`plugin:${t.id}`===e.source),a=i?.error?`${e.label}: ${i.error}`:e.hint??e.label;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===t,className:`tb-tab plugin-tab${n===t?` active`:``}${i?.error?` broken`:``}`,"data-tip":a,onClick:()=>c(t),onContextMenu:t=>V(t,e.id,e.label),children:[(0,X.jsx)(hi,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`plugin-topbar-item plugin-topbar-select`,title:e.hint??e.label,"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>s?.(e,t.target.value),onContextMenu:t=>V(t,e.id,e.label),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id):(0,X.jsxs)(`button`,{type:`button`,className:`plugin-topbar-item`,"data-tip":e.hint??e.label,onClick:()=>s?.(e),onContextMenu:t=>V(t,e.id,e.label),children:[(0,X.jsx)(hi,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},$e=[];for(let t of L){if(t.entry?.hidden||Ze(t.id))continue;let i=null;t.entry?i=(0,X.jsx)(Go,{entry:t.entry,bar:`top`,chat:e,view:n,plugins:r,onViewChange:c,onOpenPanel:l,onOpenSettings:u,onOpenGlobalSearch:p,onOpenBgTasks:f,onOpenProjectPicker:()=>A(!0),isProjectPickerOpen:k,onOpenPluginMenu:e=>ee(t=>t?.el===e?null:{rect:e.getBoundingClientRect(),el:e}),isPluginMenuOpen:j!==null,onUiAction:s,uiContextEntries:o,dropdownProps:{sound:m,onSoundChange:h,onSoundPreview:_,theme:y,themes:v,onThemeChange:b,reloadThemes:x,onLocaleModalOpen:()=>be(!0),renderUpdateBody:Ge,renderAllUpdatesBody:Ue,updatesCount:Me,managed:se,appVersion:H}},t.id):t.id.startsWith(`host:`)&&Je[t.id]&&(i=Je[t.id]),i&&$e.push({id:t.id,entry:t.entry,node:i})}for(let t of R){let i=(0,X.jsx)(Go,{entry:t,bar:`top`,chat:e,view:n,plugins:r,onViewChange:c,onUiAction:s,uiContextEntries:o},t.id);i&&$e.push({id:t.id,entry:t,node:i})}let et=e=>e.entry?.align??`start`,[tt,nt]=(0,g.useState)(()=>new Set),rt=(0,g.useRef)(null),it=(0,g.useRef)(new Map),at=$e.filter(e=>!tt.has(e.id)),ot=Y?at.filter(e=>ba.has(e.id)):[],st=Y?at.filter(e=>!ba.has(e.id)):at,ct=Y?$e.filter(e=>!ba.has(e.id)):$e,lt=[...ct.filter(e=>et(e)===`start`),...ct.filter(e=>et(e)===`center`),...ct.filter(e=>et(e)===`end`)],ut=lt.filter(e=>!tt.has(e.id)),dt=(0,g.useRef)(lt),ft=(0,g.useRef)(ut);(0,g.useLayoutEffect)(()=>{dt.current=lt,ft.current=ut});let pt=()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`)),n=ft.current;t.length===n.length&&n.forEach((e,n)=>it.current.set(e.id,t[n].offsetWidth));let r=Number.parseFloat(getComputedStyle(e).columnGap)||0,i=dt.current,a=Sa(i.map(e=>({id:e.id,width:e.entry?it.current.get(e.id)??0:0})),e.clientWidth,r,0,qi);nt(e=>e.size===a.size&&[...a].every(t=>e.has(t))?e:a)},mt=`${at.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${Y?`m`:`d`}`;(0,g.useLayoutEffect)(pt,[mt]),(0,g.useEffect)(()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>pt());return t.observe(e),()=>t.disconnect()},[mt]);let gt=st.filter(e=>et(e)===`start`),_t=st.filter(e=>et(e)===`center`),vt=st.filter(e=>et(e)===`end`),yt=$e.filter(e=>tt.has(e.id)&&e.entry).map(e=>e.entry),bt=new Map;[...i??[],...a??[]].forEach((e,t)=>{bt.has(e.id)||bt.set(e.id,t)});let xt=xa([...re,...yt],e=>bt.get(e)??999999),St=e=>e.icon&&!/[a-z]/i.test(e.icon)?e.icon:null,Ct=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${Ct?` no-labels`:``}`,"data-pi-anchor":`topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-flow`,ref:rt,role:`toolbar`,"aria-label":T(`viewSwitch`),children:[gt.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),(_t.length>0||vt.length>0)&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),_t.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),_t.length>0&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),vt.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id))]}),(xt.length>0||$e.length>0)&&(0,X.jsxs)(`div`,{className:`plugin-topbar-more`,children:[(0,X.jsx)(`button`,{ref:P,type:`button`,className:`plugin-topbar-item`,"aria-haspopup":`menu`,"aria-expanded":D,"aria-label":T(`pluginTopbarMore`),"data-tip":T(`pluginTopbarMore`),onClick:()=>O(e=>!e),children:(0,X.jsx)(Dt,{})}),(0,X.jsxs)(qo,{anchorRef:P,open:D,onClose:()=>O(!1),children:[xt.map(e=>{let t=e.source===`host`&&Xe.has(e.id)?Je[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(g.Fragment,{children:t},e.id);if(e.source===`host`&&e.id===`host:github`)return(0,X.jsxs)(`a`,{role:`menuitem`,className:`chip github`,href:`https://github.com/xing-shuyin/pi-web-ui`,target:`_blank`,rel:`noreferrer noopener`,title:T(`githubRepo`),onClick:()=>O(!1),children:[(0,X.jsx)(Ie,{}),(0,X.jsx)(`span`,{children:`GitHub`})]},e.id);if(e.source===`host`){let t=Je[e.id];if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>O(!1),children:t},e.id)}else{let t=Qe(e);if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>O(!1),children:t},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsxs)(`label`,{className:`plugin-topbar-overflow-select tb-row`,title:e.hint??e.label,children:[St(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:St(e)}):null,(0,X.jsx)(`span`,{className:`tb-row-text`,children:e.label}),(0,X.jsx)(`select`,{"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>{O(!1),oe(e)||s?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})]},e.id):(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`tb-row`,title:e.hint??e.label,onClick:()=>{O(!1),oe(e)||s?.(e)},children:[St(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:St(e)}):null,(0,X.jsx)(`span`,{className:`tb-row-text`,children:e.label})]},e.id)}),(0,X.jsx)(`div`,{className:`tb-menu-divider`,"aria-hidden":`true`}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`tb-row`,onClick:()=>{O(!1),S()},children:[(0,X.jsx)(Ke,{}),(0,X.jsx)(`span`,{className:`tb-row-text`,children:T(`uiIconEdit`)})]})]})]}),ot.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),ye&&(0,X.jsx)(Oo,{onClose:()=>be(!1)}),j&&(0,X.jsx)(Do,{anchorRect:j.rect,anchorEl:j.el,plugins:r,pinnedIds:ie,orderedPluginIds:I,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:Zi(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:Qi(e.settings?.uiLayout,t)}),onOpenView:e=>{ee(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>ee(null)}),k&&(0,X.jsx)(So,{open:!0,currentCwd:M,pathCompletions:e.pathCompletions??[],workspaceRoots:te,onClose:()=>A(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Xo(e,t){let n={...t};if(!e)return n;try{let r=JSON.parse(e);if(r&&typeof r==`object`&&!Array.isArray(r))for(let e of Object.keys(t)){let t=r[e];typeof t==`number`&&Number.isFinite(t)&&t>0&&(n[e]=t)}}catch{}return n}function Zo(e){let t=e.start.above+e.start.below,n=Math.max(1,e.availablePx)/(e.totalWeight>0?e.totalWeight:1),r=e.minAbovePx/n,i=e.minBelowPx/n;if(r+i>=t){let n=e.minAbovePx+e.minBelowPx||1,r=t*e.minAbovePx/n;return{above:r,below:t-r}}let a=Math.min(t-i,Math.max(r,e.start.above+e.deltaPx/n));return{above:a,below:t-a}}function Qo(e,t,n){let r=new Map(e.map(e=>[e.id,e])),i=e=>e.parentId?r.get(e.parentId)?.cwd??e.cwd:e.cwd,a=e.find(e=>e.id===n),o=a?i(a):t,s=new Map;for(let t of e){let e=i(t),n=s.get(e)??[];n.push(t),s.set(e,n)}let c=[...s.entries()].map(([e,t])=>({cwd:e,isCurrent:e===o,convs:t}));return c.sort((e,t)=>e.isCurrent?-1:t.isCurrent?1:e.cwd<t.cwd?-1:+(e.cwd>t.cwd)),c}function $o(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.isStreaming),m=t.some(e=>!!e.error),h=t.some(e=>!!e.hasQuestion),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasStreaming:p,hasError:m,hasQuestion:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}function es(e){if(!e)return null;let t=e.startsWith(`#`)?e.slice(1):e;if(!t.trim())return null;let n=new URLSearchParams(t),r=n.get(`s`)?.trim()??``;if(!r)return null;let i=n.get(`m`)?.trim()||void 0;return i?{sessionId:r,messageId:i}:{sessionId:r}}function ts(e){let t=e?.sessionId?.trim()??``;if(!t)return``;let n=e?.messageId?.trim()??``,r=`#s=${encodeURIComponent(t)}`;return n?`${r}&m=${encodeURIComponent(n)}`:r}function ns(e,t){let n=ts(t);try{let t=new URL(e);return t.searchParams.delete(`token`),t.hash=n,t.toString()}catch{return`${e.split(`#`)[0]??e}${n}`}}function rs(e){if(!e)return null;let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);if(!t)return null;let n=t.split(`/`),r=n[n.length-1]??``;if(!r)return null;if(r===`session.jsonl`)return(n[n.length-2]?.trim()??``)||null;let i=r.endsWith(`.jsonl`)?r.slice(0,-6):r;if(!i)return null;let a=i.lastIndexOf(`_`);return(a>=0?i.slice(a+1).trim():i.trim())||null}function is(e,t){let n=t?.trim()??``;if(!n||e.length===0)return null;let r=e.find(e=>e.id===n);if(r)return r.id;let i=/^([a-z]+-\d+)-\d+$/.exec(n);if(i){let t=`${i[1]}-`,n=e.find(e=>e.id.startsWith(t));if(n)return n.id}return null}function as(e,t){let n=t.assistantMessageEvent,r=e.stats.tokens,i=t.usage===null?r:{...r,...t.usage},a=i===r?e.stats:{...e.stats,tokens:i};if(n.type!==`text_delta`&&n.type!==`thinking_delta`)return a===e.stats?e:{...e,stats:a};let o=n.delta??``;if(!o)return a===e.stats?e:{...e,stats:a};let s=e.streamingMessage??null,c=s&&s.id===t.messageId?s:{id:t.messageId,content:[]},l=[...c.content],u=n.type===`thinking_delta`?`thinking`:`text`,d=n.contentIndex??l.length-1;return d>=0&&d<l.length&&l[d].type===u?l[d]=u===`thinking`?{type:`thinking`,thinking:(l[d].thinking??``)+o}:{type:`text`,text:(l[d].text??``)+o}:l.push(u===`thinking`?{type:`thinking`,thinking:o}:{type:`text`,text:o}),{...e,stats:a,streamingMessage:{...c,id:t.messageId,content:l}}}function os(e){let{current:t,source:n,snapshot:r,answered:i,activeConversationId:a}=e;return r&&r.id&&!i.has(r.id)?t?.id===r.id?{changed:!1,question:t,source:n}:{changed:!0,question:r,source:`snapshot`}:t&&t.conversationId&&a&&t.conversationId!==a||!r&&t&&n===`snapshot`?{changed:!0,question:null,source:`live`}:{changed:!1,question:t,source:n}}var ss=new Set;function cs(e){return ss.add(e),()=>{ss.delete(e)}}function ls(e,t){for(let n of ss)try{n(e,t)}catch(e){console.error(`[tui-overlay-bridge] listener error:`,e)}}function us(e){let t=typeof e.name==`string`?e.name:``;if(e.unsupported===!0)return{name:t,status:`unsupported`};if(e.found!==!0)return{name:t,status:`missing`};let n={name:t,status:`ready`};return e.label&&(n.label=e.label),e.description&&(n.description=e.description),e.promptSnippet&&(n.promptSnippet=e.promptSnippet),Array.isArray(e.promptGuidelines)&&e.promptGuidelines.length>0&&(n.promptGuidelines=e.promptGuidelines),e.parameters!==void 0&&(n.parameters=e.parameters),e.parametersDropped===!0&&(n.parametersDropped=!0),(e.active===!0||e.active===!1)&&(n.active=e.active),e.source&&(n.source=e.source),e.scope&&(n.scope=e.scope),n}var ds=null,fs=new Set;function ps(){for(let e of fs)e()}function ms(e){let t=(e??``).trim();t&&(ds={name:t,status:`loading`},ps(),$({type:`get_tool_info`,name:t}))}function hs(){ds!==null&&(ds=null,ps())}function gs(e){ds!==null&&ds.name===e.name&&(ds=us(e),ps())}function _s(e){return fs.add(e),()=>{fs.delete(e)}}function vs(){return ds}function ys(){return(0,g.useSyncExternalStore)(_s,vs,vs)}function bs(e){let t=typeof e.name==`string`?e.name:``;if(e.unsupported===!0)return{name:t,status:`unsupported`};if(e.found!==!0)return{name:t,status:`missing`};let n={name:t,status:`ready`};return e.defaultDescription&&(n.defaultDescription=e.defaultDescription),e.defaultPromptSnippet&&(n.defaultPromptSnippet=e.defaultPromptSnippet),Array.isArray(e.defaultPromptGuidelines)&&e.defaultPromptGuidelines.length>0&&(n.defaultPromptGuidelines=e.defaultPromptGuidelines),e.override&&(n.override=e.override),n}var xs={},Ss=new Set;function Cs(){for(let e of Ss)e()}function ws(e){let t=(e??``).trim();t&&(xs[t]&&xs[t].status!==`loading`||(xs={...xs,[t]:{name:t,status:`loading`}},Cs(),$({type:`get_tool_prompt`,name:t})))}function Ts(e){let t=typeof e.name==`string`?e.name:``;t&&xs[t]&&(xs={...xs,[t]:bs(e)},Cs())}function Es(e){if(!xs[e])return;let t={...xs};delete t[e],xs=t,Cs()}function Ds(e){return Ss.add(e),()=>Ss.delete(e)}function Os(e){return(0,g.useSyncExternalStore)(Ds,()=>e?xs[e]??null:null)}var ks=Object.freeze({status:`idle`,messages:[]}),As=new Map,js=new Set,Ms=16;function Ns(){for(;As.size>Ms;){let e=As.keys().next().value;if(e===void 0)break;As.delete(e)}}function Ps(){for(let e of js)e()}function Fs(e,t){let n=(e??``).trim();if(!n)return;let r=As.get(n);(!r||r.status!==`loading`&&r.status!==`ready`)&&(As.set(n,{status:`loading`,messages:r?.messages??[]}),Ns(),Ps(),$({type:`get_compacted_messages`,compactionMessageId:n,conversationId:t}))}function Is(e){let t=e.compactionMessageId;t&&(e.error?As.set(t,{status:`error`,messages:[],error:e.error}):As.set(t,{status:`ready`,messages:e.messages??[]}),Ns(),Ps())}function Ls(e){let t=As.get(e);return t?(As.delete(e),As.set(e,t),t):ks}function Rs(e){return js.add(e),()=>{js.delete(e)}}function zs(e){return(0,g.useSyncExternalStore)(Rs,()=>Ls(e),()=>ks)}var Bs=`__piWebUiHost`,Vs=e=>new Promise(t=>setTimeout(t,e));async function Hs(e=3e3){let t=Date.now()+e;for(;;){let e=window.__piBridge;if(e&&typeof e.call==`function`)return e;if(Date.now()>=t)return null;await Vs(100)}}var Us=Promise.resolve(),Ws=0;function Gs(e){let t=Math.max(1,Number(e.pollMs??100)),n=Math.max(t,Number(e.timeoutMs??8e3)),r=async e=>{let r=Date.now()+n;for(;;){if(e())return!0;if(Date.now()>=r)return e();await Vs(t)}},i=()=>{try{let t=e.listModels?.()??[];return Array.isArray(t)?[...t]:[]}catch{return[]}},a=e=>{if(!e)return!0;try{return i().some(t=>t&&t.id===e)}catch{return!1}},o=async t=>{t&&(e.send({type:`set_model`,modelId:t}),typeof e.getCurrentModelId==`function`&&await r(()=>e.getCurrentModelId?.()===t))},s=async(t,n)=>{let i=String(n.cwd??``).trim();if(i&&e.getCwd()!==i&&(e.send({type:`set_cwd`,path:i}),await r(()=>e.getCwd()===i)),n.newChat!==!1){let t=e.getConversationId();e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank())}let a=String(n.model??``).trim();a&&await o(a),e.send({type:`prompt`,text:t})};return{version:11,setView(t){let n=String(t??``).trim();n&&e.setView(n)},startChat(t){let n=String(t?.prompt??``).trim();if(!n||!e.isReady())return!1;let r=String(t?.model??``).trim();if(r&&!a(r))return!1;let i=()=>s(n,t??{prompt:n}),o;return o=Ws>0?Us.then(i):i(),Ws++,Us=o.then(()=>{Ws--},()=>{Ws--}),o.catch(()=>{}),!0},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>xc(e)},compose(e){return cr()?lr({text:typeof e?.text==`string`?e.text:void 0,attachments:Array.isArray(e?.attachments)?e.attachments:void 0}):!1},openModal(t){let n=String(t??``).trim();if(!n||typeof e.openModal!=`function`)return!1;try{return e.openModal(n)}catch{return!1}},closeModal(){if(typeof e.closeModal!=`function`)return!0;try{e.closeModal()}catch{}return!0},async openSession(t){let n=Xs,i=Array.isArray(t?.folders)?t.folders.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],s=Array.isArray(t?.roots)?t.roots.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],c=String(t?.cwd??``).trim(),l=[...new Set([...i,...s])],u=c||l[0]||``;if(!u)return{ok:!1,error:`openSession 需要 cwd / folders / roots(绝对路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let d=l.filter(e=>e!==u).slice(0,7),f=new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]);for(let t of[u,...d])if(!f.has(t)){if(!(e.confirm&&await e.confirm({path:t}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${t}`};e.grantPath?.(t,n)}if(e.getCwd()!==u&&(e.send({type:`set_cwd`,path:u}),!await r(()=>e.getCwd()===u)))return{ok:!1,error:`切换工作目录失败或超时:${u}`};(d.length>0||e.getWorkspaceRoots().length>0)&&e.send({type:`set_workspace_roots`,roots:d});let p=e.getConversationId()??void 0;if(t?.newChat!==!1){let t=p;e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank()),p=e.getConversationId()??void 0}let m=String(t?.model??``).trim();if(m){if(!a(m))return{ok:!1,error:`未知模型:${m}(先调 models.list() 取可用列表)`};await o(m),p=e.getConversationId()??p}let h=String(t?.prompt??``).trim();return h&&e.send({type:`prompt`,text:h}),{ok:!0,...p?{sessionId:p}:{}}},sessions:{list:()=>e.listSessions(),async open(t){let n=Xs,i=String(t??``).trim();if(!i)return{ok:!1,error:`sessions.open 需要一个会话 id(先调 list)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let a=e.listSessions().find(e=>e.id===i);if(!a)return{ok:!1,error:`找不到会话:${i}`};if(a.cwd&&a.cwd!==e.getCwd()){if(!new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]).has(a.cwd)){if(!(e.confirm&&await e.confirm({path:a.cwd}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${a.cwd}`};e.grantPath?.(a.cwd,n)}if(e.send({type:`set_cwd`,path:a.cwd}),!await r(()=>e.getCwd()===a.cwd))return{ok:!1,error:`切换工作目录失败或超时:${a.cwd}`}}let o=e.getConversationId();return a.kind===`running`?e.send({type:`switch_conversation`,id:a.id}):e.send({type:`switch_session`,path:a.id}),await r(()=>e.getConversationId()!==o)?{ok:!0,sessionId:e.getConversationId()??void 0}:{ok:!1,error:`切换会话超时:${a.title}`}}},async reloadCatalog(t,n){let r=String(t??``).trim();if(!r)return{ok:!1,error:`reloadCatalog 需要一个目录来源(http(s) URL 或本地文件路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let i=jt();return new Promise(t=>{let a=setTimeout(()=>{kc.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));kc.set(i,e=>{clearTimeout(a),t(e)}),e.send({type:`plugin_catalog_sync`,requestId:i,source:r,...n?.install?{install:!0}:{},...n?.replace?{replace:!0}:{}})})},onUiAction(e,t){return Qs(Js,String(e??``).trim(),t)},onTopbarAction(e,t){return Qs(Js,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(Rn())return{ok:!1,error:`桌面版(Electron 外壳)不支持 browser_page:窗口里没有 Chrome 扩展运行时。请让用户改用系统浏览器打开同一个 pi-web-ui 地址(网页版)再试。/ The desktop app cannot run browser_page (no Chrome extension runtime); ask the user to open the same pi-web-ui address in a regular browser instead.`};let r=await Hs(e.bridgeWaitMs??3e3);if(!r)return{ok:!1,error:`浏览器扩展的页面桥没就绪:确认已安装并启用 page-picker 扩展、本页地址已绑定,然后刷新本页`};try{let e=await r.call({op:n,...t.args===void 0?{}:{args:t.args},...t.target?{to:t.target}:{},...t.timeoutMs?{timeoutMs:t.timeoutMs}:{}});return e===void 0?{ok:!0}:{ok:!0,result:e}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},dom:{anchors(){let e=e=>{try{return document.querySelector(`[data-pi-anchor="${e}"]`)}catch{return null}};return{app:e(`app`),topbar:e(`topbar`),composer:e(`composer`)}}},dialogs:{async select(t){try{let n=e.select;if(typeof n!=`function`)return{ok:!1};let r=Array.isArray(t?.options)?t.options:[],i=await n({title:String(t?.title??``),options:r.filter(e=>typeof e==`object`&&!!e&&typeof e.label==`string`).map(e=>({label:String(e.label),...typeof e.description==`string`?{description:e.description}:{}})),...t?.multi?{multi:!0}:{}});return!i||typeof i!=`object`||i.ok!==!0?{ok:!1,...i&&typeof i==`object`&&typeof i.error==`string`?{error:i.error}:{}}:{ok:!0,selected:Array.isArray(i.selected)?i.selected.filter(e=>typeof e==`string`):[]}}catch{return{ok:!1}}},async confirm(t){let n=String(t?.title??``),r=typeof t?.detail==`string`?t.detail:``;try{if(typeof e.dialogConfirm==`function`)try{return await e.dialogConfirm({title:n,...r?{detail:r}:{}})===!0}catch{}if(typeof window<`u`&&typeof window.confirm==`function`)try{return window.confirm(r?`${n}\n\n${r}`:n)}catch{return!1}return!1}catch{return!1}},async input(t){try{let n=e.input;if(typeof n!=`function`)return{ok:!1};let r=await n({title:String(t?.title??``),...typeof t?.placeholder==`string`?{placeholder:t.placeholder}:{},...typeof t?.initial==`string`?{initial:t.initial}:{}});return!r||typeof r!=`object`||r.ok!==!0?{ok:!1}:typeof r.value==`string`?{ok:!0,value:r.value}:{ok:!0}}catch{return{ok:!1}}}},async notifyAction(t){let n=String(t?.text??``),r=(Array.isArray(t?.actions)?t.actions:[]).filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.label==`string`);try{if(typeof e.notifyAction==`function`){let t=await e.notifyAction({text:n,actions:r});return typeof t==`string`?t:null}}catch{return null}try{typeof window<`u`&&typeof window.dispatchEvent==`function`&&window.dispatchEvent(new CustomEvent(ec,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>cc(String(e??``),t)},searchProviders:{register:e=>uc(e),list:()=>dc()},composerProviders:{register:e=>pc(e),list:()=>mc()},onTheme:e=>Cc(e),onLocale:e=>wc(e),onViewChange:e=>Tc(e),setCostFormatter:e=>Ei(e),setCostCurrency:e=>Ti(e),getCostCurrency:()=>wi()}}function Ks(e){try{let t=window;e?t[Bs]=e:delete t[Bs]}catch{}}var qs=new Map,Js=null;async function Ys(e,t){let n=Js;Js=e;try{return await t()}finally{Js=n}}var Xs=void 0;function Zs(e,t){let n=Xs;Xs=e;try{return t()}finally{Xs=n}}function Qs(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=qs.get(r);i||(i=new Set,qs.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&qs.delete(r)}}async function $s(e,t,n,r){let i=i=>{let a=qs.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{Zs(e,()=>i(n,r?.value,r?.target))}catch(n){console.error(`[plugin:${e}] 顶栏动作 ${t} 抛错:`,n)}return!0};if(i(`${e}:${t}`)||i(t))return!0;if(r?.loadBundle&&await r.loadBundle(e).catch(()=>!1)){let n=Date.now()+Math.max(100,Number(r.waitMs??1500));for(;;){if(i(`${e}:${t}`)||i(t))return!0;if(Date.now()>=n)break;await new Promise(e=>setTimeout(e,100))}}return!1}var ec=`pi-web-ui:toast`,tc=new Map,nc=!1;function rc(e){let t=e.split(`+`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0);if(t.length===0)return null;let n=!1,r=!1,i=!1,a=!1;for(let e of t.slice(0,-1))if(e===`ctrl`||e===`control`)n=!0;else if(e===`shift`)r=!0;else if(e===`alt`||e===`option`)i=!0;else if(e===`meta`||e===`cmd`||e===`command`||e===`win`||e===`super`)a=!0;else return null;let o=t[t.length-1]??``;return!o||[`ctrl`,`control`,`shift`,`alt`,`option`,`meta`,`cmd`,`command`,`win`,`super`].includes(o)?null:{combo:`${n?`ctrl+`:``}${r?`shift+`:``}${i?`alt+`:``}${a?`meta+`:``}${o}`,key:o,ctrl:n,shift:r,alt:i,meta:a}}function ic(){try{if(typeof document>`u`)return!1;let e=document.activeElement;if(!e)return!1;let t=(e.tagName||``).toUpperCase();return!!(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)}catch{return!1}}function ac(e){try{if(ic())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=tc.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function oc(){if(!nc)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,ac),nc=!0}catch{}}function sc(){if(!(tc.size>0||!nc))try{window.removeEventListener(`keydown`,ac)}catch{}finally{nc=!1}}function cc(e,t){if(typeof t!=`function`)return()=>{};let n=rc(e);if(!n)return()=>{};let r=tc.get(n.combo);r||(r=new Set,tc.set(n.combo,r));let i=r;return i.add(t),oc(),()=>{i.delete(t),i.size===0&&tc.delete(n.combo),sc()}}var lc=new Map;function uc(e){let t=String(e?.id??``).trim();if(!t||typeof e?.search!=`function`)return()=>{};let n={id:t,label:String(e.label??t),search:e.search};return lc.set(t,n),()=>{lc.get(t)===n&&lc.delete(t)}}function dc(){return[...lc.values()].map(e=>({id:e.id,label:e.label}))}var fc=new Map;function pc(e){let t=String(e?.id??``).trim();if(!t||typeof e?.search!=`function`)return()=>{};let n={id:t,label:String(e.label??t),search:e.search};return fc.set(t,n),()=>{fc.get(t)===n&&fc.delete(t)}}function mc(){return[...fc.values()].map(e=>({id:e.id,label:e.label}))}function hc(e){return fc.get(String(e??``))}function gc(e){return lc.get(String(e??``))}var _c=new Set,vc=new Set,yc=new Set,bc=new Set;function xc(e){return bc.add(e),()=>{bc.delete(e)}}function Sc(e){for(let t of bc)try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function Cc(e){return typeof e==`function`?(_c.add(e),()=>{_c.delete(e)}):()=>{}}function wc(e){return typeof e==`function`?(vc.add(e),()=>{vc.delete(e)}):()=>{}}function Tc(e){return typeof e==`function`?(yc.add(e),()=>{yc.delete(e)}):()=>{}}function Ec(e){let t=String(e??``);for(let e of _c)try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function Dc(e){let t=String(e??``);for(let e of vc)try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function Oc(e){let t=String(e??``);for(let e of yc)try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var kc=new Map;function Ac(e){let t=kc.get(e.requestId);if(t){if(kc.delete(e.requestId),!e.ok){t({ok:!1,error:e.error??`目录同步失败`});return}t({ok:!0,...e.entries?{entries:e.entries}:{},...e.installed?{installed:e.installed}:{}})}}var jc=`modulepreload`,Mc=function(e){return`/`+e},Nc={},Pc=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Mc(t,n),t=s(t),t in Nc)return;Nc[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:jc,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Fc=`pi-web-ui:plugin-data`;function Ic(e,t){window.dispatchEvent(new CustomEvent(Fc,{detail:{pluginId:e,payload:t}}))}function Lc(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(Fc,t),()=>window.removeEventListener(Fc,t)}var Rc=new Map,zc=new Set,Bc=new Set,Vc=new Set,Hc=new Set,Uc=-1;function Wc(){return[...Rc.values()]}function Gc(){let e=Wc();for(let t of Bc)t(e)}function Kc(){let e=[...Vc];for(let t of Hc)t(e)}function qc(e){return Hc.add(e),e([...Vc]),()=>Hc.delete(e)}async function Jc(e,t){Vc.delete(e.id),Xc.set(e.id,(Xc.get(e.id)??0)+1),Kc();let n=await tl(e,t);return Gc(),n}function Yc(e){return Bc.add(e),e(Wc()),()=>Bc.delete(e)}var Xc=new Map;function Zc(e,t){let n=Xc.get(e)??0;return fn(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function Qc(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>Ys(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var $c=Qc(e=>Pc(()=>import(e),[]));async function el(e,t){if(!e.hasClient||e.error)return null;try{return(await $c(e.id,Zc(e.id,t))).default??null}catch(t){return console.error(`[plugin:${e.id}] 客户端 bundle 加载失败:`,t),null}}async function tl(e,t){try{let n=(await $c(e.id,Zc(e.id,t))).default;return n&&typeof n.mount==`function`?(Rc.set(e.id,{info:e,module:n}),!0):e.preload?(zc.add(e.id),!0):(Vc.add(e.id),Kc(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return Vc.add(e.id),Kc(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function nl(e,t){if(Rc.has(e.id)||zc.has(e.id))return!0;if(Vc.has(e.id)||!e.hasClient)return!1;let n=await tl(e,t);return Gc(),n}async function rl(e,t){t!==Uc&&(Uc=t,Rc.clear(),zc.clear(),Vc.clear(),Xc.clear(),Kc());let n=new Set(e.map(e=>e.id));for(let e of[...Rc.keys()])n.has(e)||Rc.delete(e);for(let e of[...zc])n.has(e)||zc.delete(e);for(let e of[...Vc])n.has(e)||Vc.delete(e);Kc(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!Rc.has(e.id)&&!zc.has(e.id)&&!Vc.has(e.id)).map(e=>tl(e,t))),Gc()}function il(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>Lc((n,r)=>{n===e&&t(r)})}}var al=[`debug`,`info`,`warn`,`error`];function ol(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function sl(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function cl(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.__host!==`logs`||!Array.isArray(t.logs)?!1:t.logs.every(e=>!!e&&typeof e==`object`&&typeof e.ts==`number`&&typeof e.text==`string`&&al.includes(String(e.level)))}var ll=new Map,ul=new Set;function dl(){for(let e of[...ul])try{e()}catch{}}function fl(e){return ul.add(e),()=>ul.delete(e)}function pl(e){return(ll.get(e)??[]).map(e=>({...e}))}function ml(e,t){return cl(t)?(ll.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),dl(),!0):!1}function hl(e){switch(e){case`error`:return 6500;case`warning`:return 4200;default:return 2400}}var gl=[/^(已在工作目录|正在切换到工作目录|已切换到工作目录)[::]/,/^(Already in directory|Switching to directory|Switched to directory):/i,/该项目最近的对话.*(为你停在了空白新对话|为你停在了新对话)/,/The most recent conversation .* landed on a (blank|new) chat/i,/^分层上下文预算裁剪生效/,/^Tiered context budget pruning/i,/^发现 \d+ 个内置插件有更新可用/,/^\d+ built-in plugin\(s\) have updates available/i,/^已(创建文件|创建文件夹|重命名|删除|移动|复制)[::]/,/^(Created file|Created folder|Renamed|Deleted|Moved|Copied):/i,/^已重命名当前会话为/,/^Renamed current session to/i,/的消息正在投递,已为你保留该对话$/,/is still sending your message — kept in the running list$/i,/^(计划模式已开启|计划模式已关闭|已进入计划模式|已退出计划模式|审查者模式已开启|审查者模式已关闭)/,/^(Plan mode (enabled|disabled)|Entered plan mode|Exited plan mode|Delegate mode (enabled|disabled))/i,/^已切换(智能体预设|权限预设)/,/^Switched (agent|permission) preset/i];function _l(e){if(e.level!==`info`)return!1;let t=(e.text??``).trim(),n=(e.textEn??``).trim();return gl.some(e=>t&&e.test(t)||n&&e.test(n))}function vl(e,t,n=2){if(_l(t))return e;let r=`${t.level}:${(t.text??``).trim()}`,i=[...e.filter(e=>`${e.level}:${(e.text??``).trim()}`!==r),t];for(;i.length>n;){let e=i.findIndex(e=>e.level!==`error`);e>=0?i.splice(e,1):i.shift()}return i}function yl(){return{flows:[],results:{}}}function bl(e,t){let n=e.findIndex(e=>e.flowId===t.flowId);return n<0?[...e,t]:e.map((e,r)=>r===n?t:e)}function xl(e,t){switch(t.type){case`provider_oauth_started`:{let n={...e.results};return delete n[t.provider],{flows:[...e.flows.filter(e=>e.provider!==t.provider),{flowId:t.flowId,provider:t.provider}],results:n}}case`provider_oauth_flows`:return{...e,flows:t.flows.map(e=>({...e}))};case`provider_oauth_prompt`:{let n=e.flows.find(e=>e.flowId===t.flowId);return{...e,flows:bl(e.flows,{...n,flowId:t.flowId,provider:t.provider,promptId:t.promptId,prompt:t.prompt})}}case`provider_oauth_event`:{let n=e.flows.find(e=>e.flowId===t.flowId);return{...e,flows:bl(e.flows,{...n,flowId:t.flowId,provider:t.provider,event:t.event,promptId:void 0,prompt:void 0})}}case`provider_oauth_result`:return{flows:e.flows.filter(e=>e.flowId!==t.flowId),results:{...e.results,[t.provider]:{ok:t.ok,...t.cancelled===void 0?{}:{cancelled:t.cancelled},...t.error===void 0?{}:{error:t.error}}}};case`provider_oauth_logout_result`:return{...e,results:{...e.results,[t.provider]:{ok:t.ok,...t.error===void 0?{}:{error:t.error}}}}}}var Sl=`pi-web-ui:lang`;function Cl(){try{return(localStorage.getItem(Sl)??``).trim()}catch{return``}}var wl=`pi-web-ui:locale`,Tl=2e5,El=2e5,Dl=`LIVE_OMIT`,Ol={conversationId:null,goal:null,reviewModel:null,maxRounds:3,locked:!0,reviewing:!1,round:0,status:``,verdict:`pending`,wizard:{active:!1,draft:``,model:null,step:0,maxSteps:6,status:``}};function kl(){let e=new Map,t=new Map,n=(e,t)=>`${e}:${t}`;return{write(r,i,a){let o=n(r,i),s=e.get(o);if(s&&s.size>0){for(let e of s)try{e.write(a)}catch{}return}let c=t.get(o)??``,l=c.length+a.length>El?a:c+a;t.set(o,l)},register(r,i,a){let o=n(r,i),s=e.get(o);s||(s=new Set,e.set(o,s)),s.add(a);let c=t.get(o);if(c){try{a.write(c)}catch{}t.delete(o)}return()=>{let n=e.get(o);n&&(n.delete(a),n.size===0&&e.delete(o)),t.delete(o)}},clear(){e.clear(),t.clear()}}}function Al(e,t){let n=new Set;for(let e of t.messages)e.role===`toolResult`&&e.toolCallId&&n.add(e.toolCallId),e.role===`bashExecution`&&n.add(`bash-${e.id}`);let r=!1;for(let t of e.keys())n.has(t)&&(e.delete(t),r=!0);return r?new Map(e):e}function jl(e,t){if(e.size===0)return e;let n=new Set;for(let e of t.messages)e.role===`toolResult`&&e.toolCallId&&n.add(e.toolCallId);let r=!1;for(let t of e.keys())n.has(t)&&(e.delete(t),r=!0);return r?new Map(e):e}function Ml(e,t){switch(t.type){case`status`:return{...e,status:t.status,ready:t.status===`open`&&e.ready,terminals:t.status===`closed`?[]:e.terminals,hostMetrics:t.status===`closed`?null:e.hostMetrics};case`sync_cached_sessions`:return{...e,sessions:t.sessions};case`host_metrics`:return{...e,hostMetrics:t.metrics};case`ready`:return{...e,serverVersion:t.serverVersion,engine:t.engine,appVersion:t.appVersion,managed:t.managed===!0,tabs:t.tabs,ready:!0,protocolMismatch:t.protocolVersion!==void 0&&t.protocolVersion!==29};case`snapshot`:{let n=e.state?.cwd,r=e.state?.conversationId,i=t.state.cwd,a=e.sessions;i&&i!==n&&(a=Kl(i));let o=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),s=e.transition;return s&&(s.phase===`done`||s.phase===`error`||s.kind===`cwd`&&o(t.state.cwd)===o(s.target)||s.kind===`session`&&o(t.state.sessionFile)===o(s.target)||s.kind===`conversation`&&t.state.conversationId===s.target||s.kind===`new_chat`&&(!r||t.state.conversationId!==r||t.state.messages.length===0))&&(s=null),{...e,ready:!0,state:t.state,transition:s,sessions:a,approval:t.state.pendingApproval??null,activeConversationId:t.state.conversationId,liveOutputs:Al(e.liveOutputs,t.state),toolStatuses:jl(e.toolStatuses,t.state)}}case`snapshot_delta`:{let n=e.state,r=t.msg;if(!n||n.conversationId!==r.conversationId||n.rev!==r.baseRev)return e;let i={...n,...r.state,messages:r.appended.length>0?[...n.messages,...r.appended]:n.messages};return{...e,ready:!0,state:i,approval:i.pendingApproval===void 0?e.approval:i.pendingApproval??null,activeConversationId:i.conversationId,liveOutputs:Al(e.liveOutputs,i),toolStatuses:jl(e.toolStatuses,i)}}case`tool_approval`:return{...e,approval:t.approval};case`tool_delta`:{let n=(e.liveOutputs.get(t.toolCallId)?.text??``)+t.delta,r=n.length>Tl?`…[${Dl}:${n.length-Tl}]…\n`+n.slice(n.length-Tl):n,i=new Map(e.liveOutputs);return i.set(t.toolCallId,{toolName:t.toolName,text:r}),{...e,liveOutputs:i}}case`message_delta`:{let n=e.state;return!n||n.conversationId!==t.msg.conversationId?e:{...e,state:as(n,t.msg)}}case`tool_status`:return{...e,toolStatuses:new Map(e.toolStatuses).set(t.status.toolCallId,t.status)};case`notice`:{let n=vl(e.notices,t.notice);return n===e.notices?e:{...e,notices:n}}case`dismiss_notice`:return{...e,notices:e.notices.filter(e=>e.id!==t.id)};case`sessions`:return ql(e.state?.cwd,t.sessions),{...e,sessions:t.sessions};case`conversations`:return{...e,conversations:t.conversations,elsewhere:t.elsewhere??[],activeConversationId:t.activeId};case`projects`:return Hl(t.projects),{...e,projects:t.projects};case`sandbox_diff`:return{...e,sandboxDiff:t.diff};case`files`:return{...e,files:t.files};case`file_changed`:return{...e,fileChanged:{path:t.path}};case`file_content`:return{...e,fileContent:t.content};case`models`:return{...e,models:t.models,modelsLoading:t.loading};case`models_config`:return{...e,modelsConfig:t.providers};case`providers_status`:return{...e,providers:t.providers};case`provider_keys`:return{...e,providerKeys:t.keys};case`default_model`:return{...e,defaultModel:t.modelId};case`provider_oauth`:{let n=xl({flows:e.providerOAuthFlows,results:e.providerOAuthResults},t.message);return{...e,providerOAuthFlows:n.flows,providerOAuthResults:n.results}}case`fetch_models_result`:return{...e,fetchModelsResult:t.result};case`test_model_connection_result`:return{...e,testModelConnectionResult:t.result};case`enrich_models_progress`:return{...e,enrichModelsProgress:t.progress};case`enrich_models_result`:return{...e,enrichModelsResult:t.result,enrichModelsProgress:null};case`refresh_provider_result`:return{...e,refreshProviderResult:t.result};case`refresh_builtin_result`:return{...e,refreshBuiltinResult:t.result};case`append_builtin_result`:return{...e,appendBuiltinResult:t.result};case`clone_provider_result`:return{...e,cloneProviderResult:t.result};case`install_result`:return{...e,installResult:t.result};case`scm_data`:return{...e,scmData:t.data};case`file_search_result`:return{...e,fileSearch:t.result};case`session_search_result`:return{...e,sessionSearch:t.result};case`scm_changed`:return{...e,scmDirty:e.scmDirty+1};case`path_completions`:return{...e,pathCompletions:t.completions};case`update_status`:return{...e,update:t.status};case`update_status_all`:return{...e,updatesAll:t.items,updatesSdk:t.piSdk??null};case`updates_check_started`:return{...e,updatesAll:null};case`widgets`:return{...e,widgets:t.widgets};case`statuses`:return{...e,statuses:t.statuses};case`dialog`:return{...e,dialog:t.dialog};case`tui_overlay`:return{...e,tuiOverlay:t.overlay};case`question`:return{...e,question:t.question};case`remote_question`:return{...e,remoteQuestion:t.question};case`commands`:return{...e,commands:t.commands,commandsPath:t.path};case`slash_commands`:return{...e,slashCommands:t.commands};case`goal_status`:return{...e,goal:t.status};case`plan_updated`:{let n=e.state;if(!n)return e;let r=e.activeConversationId||n.conversationId;if(!t.conversationId||t.conversationId!==r)return e;let i={...n,plan:t.plan};return{...e,state:i}}case`settings`:return{...e,settings:t.settings};case`mcp_servers`:return e.settings?{...e,settings:{...e.settings,mcpServers:t.servers,mcpGlobalConfigPath:t.globalConfigPath??e.settings.mcpGlobalConfigPath,mcpProjectConfigPath:t.projectConfigPath??e.settings.mcpProjectConfigPath}}:e;case`mcp_market_result`:return{...e,mcpMarketResult:t.result};case`skill_market_result`:return{...e,skillMarketResult:t.result};case`skill_content_result`:return{...e,skillContentResult:t.result};case`bg_servers`:return{...e,bgServers:t.servers};case`scheduler_tasks`:return{...e,schedulerTasks:t.tasks};case`plugin_panel_items`:return{...e,pluginPanelGroups:t.groups};case`plugins`:return{...e,plugins:t.plugins,pluginsEpoch:t.epoch};case`plugin_updates_check_started`:return{...e,checkingPluginUpdates:!0};case`plugin_updates`:{let n={};for(let e of t.updates)n[e.id]=e;return{...e,pluginUpdates:n,checkingPluginUpdates:!1}}case`plugin_catalog`:return{...e,pluginCatalog:t.entries,pluginCatalogEpoch:t.epoch};case`plugin_grants`:return{...e,pluginGrants:t.grants};case`plugin_permissions`:return{...e,pluginPermissions:t.grants};case`plugin_path_request`:return{...e,pathRequests:[...e.pathRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_path_resolved`:return{...e,pathRequests:e.pathRequests.filter(e=>e.id!==t.id)};case`plugin_permission_request`:return{...e,permRequests:[...e.permRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_permission_resolved`:return{...e,permRequests:e.permRequests.filter(e=>e.id!==t.id)};case`plugin_job`:{let{pluginId:n,phase:r,ok:i,action:a}=t.job,o=e.pluginUpdates;a===`update`&&r===`done`&&i&&e.pluginUpdates?.[n]&&(o={...e.pluginUpdates,[n]:{...e.pluginUpdates[n],updatable:!1}});let s=e.pluginJobs[t.job.jobId],c=t.line?[...s?.lines??[],t.line].slice(-40):s?.lines??[],l={...s,...t.job,lines:c,startedAt:s?.startedAt??Date.now()};return{...e,pluginUpdates:o,pluginJobs:{...e.pluginJobs,[t.job.jobId]:l}}}case`plugin_catalog_sync_result`:return{...e,catalogSync:{...t.result,receivedAt:Date.now()}};case`preset_export_result`:return{...e,presetExport:{...t.result,receivedAt:Date.now()}};case`preset_import_result`:return{...e,presetImport:{...t.result,source:t.source,receivedAt:Date.now()}};case`preset_catalog_result`:return{...e,presetCatalog:{...t.result,receivedAt:Date.now()}};case`preset_share_result`:return{...e,presetShare:{...t.result,receivedAt:Date.now()}};case`plugin_install_inspect_result`:return{...e,installInspect:t.result};case`dsh_patches`:return{...e,dshPatches:{patchDir:t.patchDir,files:t.files}};case`dsh_presets`:return{...e,dshPresets:{presets:t.presets,defaultPreset:t.defaultPreset}};case`dsh_permission`:return{...e,dshPermission:{options:t.options,defaultPreset:t.defaultPreset}};case`terminal_add`:return{...e,terminals:[...e.terminals,t.meta]};case`terminal_remove`:return{...e,terminals:e.terminals.filter(e=>e.id!==t.id)};case`terminal_exit`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!1,exitCode:t.exitCode}:e)};case`terminal_restart`:return{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!0,exitCode:null}:e)};case`terminal_list`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:t.terminals.map(n=>({...n,conversationId:t.conversationId??e.state?.conversationId??``}))};case`terminal_active`:return{...e,terminalActiveId:t.id};case`transition_start`:{let n=t.kind===`cwd`?Kl(t.target):null;return{...e,...n&&n.length>0?{sessions:n}:{},transition:{kind:t.kind,target:t.target,phase:`start`,progress:t.progress,text:t.text,textEn:t.textEn,startedAt:Date.now()}}}case`transition_progress`:{let n=t.msg;if(n.phase===`done`||n.phase===`error`)return{...e,transition:e.transition?{...e.transition,phase:n.phase,progress:100,text:n.text,textEn:n.textEn}:null};let r=e.transition;return{...e,transition:{kind:n.kind,target:n.target,phase:n.phase,progress:Math.max(r?.target===n.target?r.progress:0,n.progress),text:n.text,textEn:n.textEn,totalMessages:n.totalMessages??r?.totalMessages,previewMessages:n.previewMessages??r?.previewMessages,startedAt:r?.startedAt??Date.now()}}}case`transition_tick`:{let t=e.transition;if(!t||t.phase===`done`||t.phase===`error`)return e;let n=t.phase===`start`?26:t.phase===`fs`?56:92;if(t.progress>=n)return e;let r=Math.max(1,Math.round((n-t.progress)*.16));return{...e,transition:{...t,progress:Math.min(n,t.progress+r)}}}case`transition_clear`:return e.transition?{...e,transition:null}:e;default:return e}}var Nl=`pi-web-client-id`,Pl=null;function Fl(){if(Pl)return Pl;let e=null;try{e=sessionStorage.getItem(Nl),e||(e=jt(),sessionStorage.setItem(Nl,e))}catch{e??=jt()}return Pl=e,e}var Il=`pi-web-last-cwd`;function Ll(){try{return localStorage.getItem(Il)}catch{return null}}function Rl(e){try{localStorage.setItem(Il,e)}catch{}}function zl(e){try{let t=localStorage.getItem(Il);if(!t)return;let n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase();(t===e||n(t)===n(e))&&localStorage.removeItem(Il)}catch{}}var Bl=`pi-web-recent-projects`;function Vl(){try{let e=localStorage.getItem(Bl);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Hl(e){try{localStorage.setItem(Bl,JSON.stringify(e.slice(0,20)))}catch{}}function Ul(e){try{let t=Vl(),n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),r=n(e);Hl(t.filter(e=>n(e.path)!==r))}catch{}}var Wl=`pi-web-recent-sessions:`;function Gl(e){return e?`${Wl}${e.trim().replace(/[\\/]+$/,``).toLowerCase()}`:`pi-web-recent-sessions:default`}function Kl(e){try{let t=Gl(e??Ll()),n=localStorage.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function ql(e,t){try{let n=Gl(e??Ll());localStorage.setItem(n,JSON.stringify(t.slice(0,50)))}catch{}}function Jl(e,t){try{let n=Kl(t),r=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),i=r(e);ql(t,n.filter(e=>r(e.path)!==i))}catch{}}function Yl(){return gn(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${fn(`/ws`)}`)}function Xl(){let[e,t]=(0,g.useReducer)(Ml,{status:`connecting`,ready:!1,state:null,hostMetrics:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:Kl(),conversations:[],elsewhere:[],activeConversationId:``,projects:Vl(),files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},defaultModel:null,providerOAuthFlows:[],providerOAuthResults:yl().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,updatesSdk:null,widgets:[],statuses:[],dialog:null,tuiOverlay:null,approval:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:Ol,bgServers:[],schedulerTasks:[],pluginPanelGroups:[],settings:null,fetchModelsResult:null,testModelConnectionResult:null,enrichModelsResult:null,enrichModelsProgress:null,refreshProviderResult:null,refreshBuiltinResult:null,appendBuiltinResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginUpdates:null,checkingPluginUpdates:!1,pluginCatalog:[],pluginCatalogEpoch:0,pluginJobs:{},catalogSync:null,presetExport:null,presetImport:null,presetCatalog:null,presetShare:null,installInspect:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,mcpMarketResult:null,skillMarketResult:null,skillContentResult:null,dshPresets:null,dshPermission:null,protocolMismatch:!1,transition:null,sandboxDiff:null}),n=(0,g.useRef)(null),r=(0,g.useRef)(kl()),i=(0,g.useRef)(0),a=(0,g.useRef)(null),o=(0,g.useRef)(!0),s=(0,g.useRef)(0),c=(0,g.useRef)(0),l=(0,g.useRef)(new Map),u=(0,g.useRef)(null),d=(0,g.useRef)(!1),f=(0,g.useRef)(null),p=(0,g.useRef)(new Set),m=(0,g.useRef)(`live`),h=()=>{u.current||=setTimeout(()=>{u.current=null;let e=n.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:`get_state`}))},300)},_=(e,t)=>{let n=l.current,r=n.get(e);if(r!==void 0&&t!==r+1){let t=O.current.chat;e===(t.activeConversationId||t.state?.conversationId)&&h()}n.set(e,t)},v=(0,g.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]);(0,g.useEffect)(()=>{if(!e.transition)return;if(e.transition.phase===`done`||e.transition.phase===`error`){let e=setTimeout(()=>t({type:`transition_clear`}),180);return()=>clearTimeout(e)}let n=setInterval(()=>{if(Date.now()-(e.transition?.startedAt??0)>2e4){t({type:`transition_clear`});return}t({type:`transition_tick`})},160);return()=>clearInterval(n)},[e.transition]);let y=(0,g.useCallback)(e=>{let r=O.current.chat.state;if(e.type===`set_cwd`&&e.path){let n=(r?.cwd??``).trim().replace(/[\\/]+$/,``).toLowerCase(),i=e.path.trim().replace(/[\\/]+$/,``).toLowerCase();i&&i!==n&&t({type:`transition_start`,kind:`cwd`,target:e.path,progress:14,text:`正在切换到工作目录:${e.path}`,textEn:`Switching to workspace: ${e.path}`})}else if(e.type===`switch_session`&&e.path){let n=(r?.sessionFile??``).trim().replace(/[\\/]+$/,``).toLowerCase(),i=e.path.trim().replace(/[\\/]+$/,``).toLowerCase();i&&i!==n&&t({type:`transition_start`,kind:`session`,target:e.path,progress:14,text:`正在流式载入历史会话…`,textEn:`Streaming session history…`})}else e.type===`new_chat`?r&&(r.messages.length>0||r.isStreaming)&&t({type:`transition_start`,kind:`new_chat`,target:r.cwd,progress:22,text:`正在初始化新对话…`,textEn:`Initializing new chat…`}):e.type===`switch_conversation`&&e.id&&r&&e.id!==r.conversationId&&t({type:`transition_start`,kind:`conversation`,target:e.id,progress:35,text:`正在切换对话…`,textEn:`Switching conversation…`});let i=n.current;if(i&&i.readyState===WebSocket.OPEN){if(e.type===`check_updates_all`&&e.force===!0&&t({type:`updates_check_started`}),e.type===`check_plugin_updates`&&t({type:`plugin_updates_check_started`}),i.send(JSON.stringify(e)),e.type===`question_answer`){if(e.owner){let n=O.current.chat.remoteQuestion;n&&n.id===e.id&&t({type:`remote_question`,question:null})}else{if(p.current.add(e.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}m.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,g.useCallback)((e,n)=>{let r=os({current:O.current.chat.question,source:m.current,snapshot:e,answered:p.current,activeConversationId:n});r.changed&&(m.current=r.source,t({type:`question`,question:r.question}))},[]);no(y);let x=(0,g.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(Yl());n.current=e,e.onopen=()=>{n.current===e&&(t({type:`status`,status:`open`}),i.current=0,s.current=Date.now(),e.send(JSON.stringify({type:`hello`,clientId:Fl(),locale:Cl()})))},e.onmessage=i=>{if(n.current!==e)return;s.current=Date.now();let a;try{a=JSON.parse(i.data)}catch{return}switch(a.type){case`ready`:if((O.current.chat.settings?.autoReload??!0)&&a.buildId&&a.buildId!==`20261011T13264`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}qa({engine:a.engine??`pi`,managed:!!a.managed,tabs:a.tabs,appVersion:a.appVersion,serverVersion:a.serverVersion,service:a.service}),t({type:`ready`,serverVersion:a.serverVersion,protocolVersion:a.protocolVersion,engine:a.engine,appVersion:a.appVersion,managed:a.managed,tabs:a.tabs,service:a.service}),p.current.clear(),t({type:`question`,question:null}),e.send(JSON.stringify({type:`get_state`})),e.send(JSON.stringify({type:`list_files`})),e.send(JSON.stringify({type:`list_models`})),e.send(JSON.stringify({type:`list_commands`})),e.send(JSON.stringify({type:`get_commands`})),a.managed||(e.send(JSON.stringify({type:`check_update`})),e.send(JSON.stringify({type:`check_updates_all`})));break;case`snapshot`:l.current=new Map,t({type:`snapshot`,state:a.state}),b(a.state.pendingQuestion,a.state.conversationId);break;case`snapshot_delta`:{let e=O.current.chat.state;if(e)(e.conversationId!==a.conversationId||e.rev!==a.baseRev)&&h();else{let e=n.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:`get_state`}))}t({type:`snapshot_delta`,msg:a}),b(a.state.pendingQuestion,a.conversationId);break}case`tool_delta`:_(a.conversationId,a.seq),t({type:`tool_delta`,toolCallId:a.toolCallId,toolName:a.toolName,delta:a.delta});break;case`tool_status`:t({type:`tool_status`,status:a});break;case`message_delta`:_(a.conversationId,a.seq),t({type:`message_delta`,msg:a});break;case`subagent_handoff`:break;case`notice`:{let e=++c.current;(a.level===`error`||a.level===`warning`)&&t({type:`transition_clear`}),t({type:`notice`,notice:{id:e,level:a.level,text:a.text,textEn:a.textEn}});break}case`transition_progress`:t({type:`transition_progress`,msg:a});break;case`sessions`:t({type:`sessions`,sessions:a.sessions});break;case`conversations`:t({type:`conversations`,conversations:a.conversations,activeId:a.activeId,elsewhere:a.elsewhere});break;case`projects`:t({type:`projects`,projects:a.projects});break;case`sandbox_diff`:t({type:`sandbox_diff`,diff:a.diff});break;case`files`:t({type:`files`,files:a});break;case`file_changed`:t({type:`file_changed`,path:a.path});break;case`file_content`:t({type:`file_content`,content:a});break;case`models`:t({type:`models`,models:a.models,loading:!1});break;case`models_config`:t({type:`models_config`,providers:a.providers});break;case`providers_status`:t({type:`providers_status`,providers:a.providers});break;case`provider_keys`:t({type:`provider_keys`,keys:a.keys});break;case`default_model`:t({type:`default_model`,modelId:a.modelId});break;case`provider_oauth_started`:case`provider_oauth_flows`:case`provider_oauth_prompt`:case`provider_oauth_event`:case`provider_oauth_result`:case`provider_oauth_logout_result`:t({type:`provider_oauth`,message:a});break;case`fetch_models_result`:t({type:`fetch_models_result`,result:{reqId:a.reqId,ok:a.ok,models:a.models,error:a.error}});break;case`test_model_connection_result`:t({type:`test_model_connection_result`,result:{reqId:a.reqId,ok:a.ok,latencyMs:a.latencyMs,error:a.error}});break;case`enrich_models_progress`:t({type:`enrich_models_progress`,progress:{reqId:a.reqId,phase:a.phase,current:a.current,total:a.total,message:a.message}});break;case`enrich_models_result`:t({type:`enrich_models_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,error:a.error}});break;case`refresh_provider_result`:t({type:`refresh_provider_result`,result:{reqId:a.reqId,ok:a.ok,added:a.added,total:a.total,error:a.error}});break;case`refresh_builtin_result`:t({type:`refresh_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`append_builtin_result`:t({type:`append_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`clone_provider_result`:t({type:`clone_provider_result`,result:{reqId:a.reqId,ok:a.ok,config:a.config,configs:a.configs,error:a.error}});break;case`scm_data`:t({type:`scm_data`,data:a});break;case`search_files_result`:t({type:`file_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,truncated:a.truncated}});break;case`session_search_results`:t({type:`session_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results}});break;case`scm_changed`:t({type:`scm_changed`});break;case`tool_info`:gs(a);break;case`tool_prompt`:Ts(a);break;case`compacted_messages_result`:Is(a);break;case`heartbeat`:a.hostMetrics&&t({type:`host_metrics`,metrics:a.hostMetrics});break;case`install_result`:t({type:`install_result`,result:a});break;case`path_completions`:t({type:`path_completions`,completions:a.completions});break;case`update_status`:t({type:`update_status`,status:a});break;case`update_status_all`:t({type:`update_status_all`,items:a.items,piSdk:a.piSdk});break;case`widgets`:t({type:`widgets`,widgets:a.widgets});break;case`statuses`:t({type:`statuses`,statuses:a.statuses});break;case`dialog`:t({type:`dialog`,dialog:{id:a.id,kind:a.kind,title:a.title,args:a.args}});break;case`dialog_closed`:t({type:`dialog`,dialog:null});break;case`tui_overlay_open`:t({type:`tui_overlay`,overlay:{id:a.id,title:a.title,cols:a.cols,rows:a.rows,initialAnsi:a.initialAnsi}});break;case`tui_overlay_render`:ls(a.id,a.ansi);break;case`tui_overlay_close`:t({type:`tui_overlay`,overlay:null});break;case`question_pending`:m.current=`live`,t({type:`question`,question:{id:a.id,...a.deadline===void 0?{}:{deadline:a.deadline},questions:a.questions,...a.conversationId===void 0?{}:{conversationId:a.conversationId},...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`tool_approval_pending`:t({type:`tool_approval`,approval:{id:a.id,toolCallId:a.toolCallId,toolName:a.toolName,params:a.params,reason:a.reason,reasonEn:a.reasonEn,...a.category?{category:a.category}:{},...a.conversationId===void 0?{}:{conversationId:a.conversationId},...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`tool_approval_resolved`:t({type:`tool_approval`,approval:null});break;case`question_retracted`:{let e=O.current.chat.question;if(e&&e.id===a.id){if(p.current.add(a.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}m.current=`live`,t({type:`question`,question:null})}break}case`elsewhere_question`:t({type:`remote_question`,question:{owner:a.owner,convId:a.convId,id:a.id,questions:a.questions,...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`page_request`:(async()=>{let e=window.__piWebUiHost,t;if(!e?.pageCall)t={ok:!1,error:`宿主页面桥不可用(页面版本过旧?)—— 刷新本页后再试`};else try{t=await e.pageCall({op:a.op,...a.args===void 0?{}:{args:a.args},...a.target?{target:a.target}:{},timeoutMs:a.timeoutMs})}catch(e){t={ok:!1,error:e instanceof Error?e.message:String(e)}}y({type:`page_response`,id:a.id,ok:t.ok===!0,...t.ok===!0?t.result===void 0?{}:{result:t.result}:{error:t.error??`页面操作失败`}})})();break;case`terminal_output`:r.current.write(a.conversationId??O.current.chat.activeConversationId,a.terminalId,a.data);break;case`terminal_exit`:t({type:`terminal_exit`,conversationId:a.conversationId,terminalId:a.terminalId,exitCode:a.exitCode});break;case`terminal_list`:t({type:`terminal_list`,conversationId:a.conversationId,terminals:a.terminals});break;case`commands`:t({type:`commands`,commands:a.commands,path:a.path});break;case`slash_commands`:t({type:`slash_commands`,commands:a.commands});break;case`goal_status`:t({type:`goal_status`,status:a.status});break;case`plan_updated`:t({type:`plan_updated`,conversationId:a.conversationId,plan:a.plan});break;case`settings_state`:t({type:`settings`,settings:a.settings});break;case`mcp_servers`:t({type:`mcp_servers`,servers:a.servers,globalConfigPath:a.globalConfigPath,projectConfigPath:a.projectConfigPath});break;case`mcp_market_result`:t({type:`mcp_market_result`,result:a});break;case`skill_market_result`:t({type:`skill_market_result`,result:a});break;case`skill_content_result`:t({type:`skill_content_result`,result:a});break;case`bg_servers`:t({type:`bg_servers`,servers:a.servers});break;case`scheduler_tasks`:t({type:`scheduler_tasks`,tasks:a.tasks});break;case`plugin_panel_items`:t({type:`plugin_panel_items`,groups:a.groups});break;case`plugins`:t({type:`plugins`,plugins:a.plugins,epoch:a.epoch});break;case`plugin_updates`:t({type:`plugin_updates`,updates:a.updates});break;case`plugin_catalog`:t({type:`plugin_catalog`,entries:a.entries,epoch:a.epoch});break;case`plugin_grants`:t({type:`plugin_grants`,grants:a.grants});break;case`plugin_permissions`:t({type:`plugin_permissions`,grants:a.grants});break;case`plugin_permission_request`:t({type:`plugin_permission_request`,req:{id:a.id,pluginId:a.pluginId,family:a.family,...a.hosts?{hosts:a.hosts}:{},...a.models?{models:a.models}:{},...a.reason?{reason:a.reason}:{}}});break;case`plugin_permission_resolved`:t({type:`plugin_permission_resolved`,id:a.id});break;case`plugin_path_request`:t({type:`plugin_path_request`,req:{id:a.id,pluginId:a.pluginId,path:a.path,...a.reason?{reason:a.reason}:{}}});break;case`plugin_dom_consent_request`:a.from===Fl()&&e.send(JSON.stringify({type:`plugin_dom_consent_response`,id:a.id,ok:!0}));break;case`plugin_job`:t({type:`plugin_job`,job:{jobId:a.jobId,action:a.action,pluginId:a.pluginId,phase:a.phase,...a.ok===void 0?{}:{ok:a.ok},...a.error?{error:a.error}:{},...a.output?{output:a.output}:{}},...a.line?{line:a.line}:{}});break;case`plugin_install_inspect_result`:t({type:`plugin_install_inspect_result`,result:{requestId:String(a.requestId??``),source:String(a.source??``),kind:a.kind,suggestedId:String(a.suggestedId??``),installed:a.installed===!0,...a.problem?{problem:a.problem}:{},...a.detail?{detail:a.detail}:{},...a.manifest?{manifest:a.manifest}:{}}});break;case`plugin_catalog_sync_result`:Ac(a),t({type:`plugin_catalog_sync_result`,result:{requestId:String(a.requestId??``),ok:a.ok===!0,...a.error?{error:a.error}:{},...a.entries?{entryCount:a.entries.length}:{},...a.installed?{installed:a.installed}:{}}});break;case`preset_export_result`:t({type:`preset_export_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,...a.name?{name:a.name}:{},...a.fileName?{fileName:a.fileName}:{},...a.json?{json:a.json}:{},...a.error?{error:a.error}:{}}});break;case`preset_import_result`:{let e=String(a.requestId??``),n=e.startsWith(`url:`)?`url`:e.startsWith(`file:`)?`file`:`paste`;t({type:`preset_import_result`,source:n,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,dryRun:a.dryRun===!0,...a.preview?{preview:a.preview}:{},...a.applied?{applied:!0}:{},...a.error?{error:a.error}:{}}});break}case`preset_catalog_result`:t({type:`preset_catalog_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,entries:a.entries??[],source:a.source??``,cached:a.cached===!0,fetchedAt:a.fetchedAt??0,...a.error?{error:a.error}:{}}});break;case`preset_share_result`:t({type:`preset_share_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,...a.method?{method:a.method}:{},...a.url?{url:a.url}:{},...a.name?{name:a.name}:{},...a.json?{json:a.json}:{},...a.error?{error:a.error}:{}}});break;case`dsh_patches`:t({type:`dsh_patches`,patchDir:a.patchDir,files:a.files});break;case`dsh_presets`:t({type:`dsh_presets`,presets:a.presets,defaultPreset:a.defaultPreset});break;case`dsh_permission`:t({type:`dsh_permission`,options:a.options,defaultPreset:a.defaultPreset});break;case`plugin_data`:ml(a.pluginId,a.payload)||Ic(a.pluginId,a.payload);break;case`remote_ssh_probe_result`:case`remote_ssh_list_dir_result`:case`remote_ssh_install_result`:case`remote_ssh_profiles_result`:ao(a)}},e.onclose=()=>{if(n.current===e&&(n.current=null),r.current.clear(),!o.current||n.current&&n.current!==e)return;t({type:`status`,status:`closed`});let s=Math.min(1e3*2**i.current,1e4);i.current+=1,a.current=setTimeout(()=>{a.current=null,x()},s)},e.onerror=()=>{}},[]);(0,g.useEffect)(()=>{let e=e=>{let t=e.detail??Cl();t&&y({type:`set_locale`,locale:t})};return window.addEventListener(wl,e),()=>window.removeEventListener(wl,e)},[y]),(0,g.useEffect)(()=>{let n=n=>{let r=e.state?.cwd;r&&n.key&&n.key===Gl(r)&&t({type:`sync_cached_sessions`,sessions:Kl(r)})};return window.addEventListener(`storage`,n),()=>window.removeEventListener(`storage`,n)},[e.state?.cwd]),(0,g.useEffect)(()=>{o.current=!0,x();let e=setInterval(()=>{if(!o.current)return;let e=n.current;e&&e.readyState===WebSocket.OPEN&&Date.now()-s.current>3e4&&e.close()},5e3),t=()=>{if(!o.current||typeof document<`u`&&document.visibilityState===`hidden`)return;let e=n.current;if(!e||e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING){a.current&&=(clearTimeout(a.current),null),x();return}e.readyState===WebSocket.OPEN&&(Date.now()-s.current>15e3||!O.current.chat.state)&&e.send(JSON.stringify({type:`get_state`}))};return typeof document<`u`&&document.addEventListener(`visibilitychange`,t),typeof window<`u`&&(window.addEventListener(`pageshow`,t),window.addEventListener(`online`,t)),()=>{o.current=!1,clearInterval(e),a.current&&=(clearTimeout(a.current),null),typeof document<`u`&&document.removeEventListener(`visibilitychange`,t),typeof window<`u`&&(window.removeEventListener(`pageshow`,t),window.removeEventListener(`online`,t)),n.current?.close(),n.current=null}},[x]),(0,g.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=Ll();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}f.current!==t&&(f.current=t,Rl(t))}},[e.state?.cwd,y]),(0,g.useEffect)(()=>{qa({ready:e.ready,status:e.status,cwd:e.state?.cwd??``,workspaceRoots:e.state?.workspaceRoots??[],homeDir:e.state?.homeDir??``,desktopDir:e.state?.desktopDir??``})},[e.ready,e.status,e.state?.cwd,e.state?.workspaceRoots,e.state?.homeDir,e.state?.desktopDir]);let S=(0,g.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,g.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,g.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,g.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,g.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,g.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,g.useRef)({chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}});return O.current={chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}},O.current}function Zl(e){let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`:`${t.getMonth()+1}/${t.getDate()}`}function Ql(e){let t=e instanceof HTMLElement?e:null;if(!t)return!1;let n=t.tagName;return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable}var $l=`pi-web-ui:lp-collapse-projects`,eu=`pi-web-ui:lp-collapse-convs`,tu=`pi-web-ui:lp-collapse-sessions`,nu=`pi-web-ui:lp-collapse-subagents`;function ru(){let[e,t]=(0,g.useState)(()=>{try{let e=localStorage.getItem(nu);if(e)return new Set(JSON.parse(e))}catch{}return new Set});return[e,(0,g.useCallback)(e=>{t(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem(nu,JSON.stringify([...n]))}catch{}return n})},[])]}function iu(e,t=!1){let[n,r]=(0,g.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,g.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var au=`pi-web-ui:lp-collapse-plugin-sections`;function ou(){let[e,t]=(0,g.useState)(()=>{try{let e=localStorage.getItem(au),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`):[])}catch{return new Set}});return[e,(0,g.useCallback)(e=>{t(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem(au,JSON.stringify([...n]))}catch{}return n})},[])]}var su=`pi-web-ui:lp-sizes`,cu={projects:1,convs:1,sessions:1},lu=32,uu={running:`pluginRunStatusRunning`,done:`pluginRunStatusDone`,error:`pluginRunStatusError`},du=72;function fu(){try{return Ri(localStorage.getItem(su),cu)}catch{return{...cu}}}var pu=(0,g.memo)(function({sessionFile:e,conversations:t,elsewhere:n,sessions:r,projects:i,activeConversationId:a,panelSend:o,active:s,collapsible:c,onToggleCollapse:l,pathCompletions:u,uiContextSession:d,uiLeftSessions:f,uiContextProject:p,uiProjectsActions:m,uiLeftProject:h,uiRunningActions:_,uiHistoryActions:v,uiSections:y,renderPluginSectionBody:b,uiPluginRunning:x,onPluginRunningAction:S,uiLeftRunning:C,uiLeftHistory:w,onUiAction:T,presetNames:E,transition:D,onOpenSandboxModal:O}){let k=Z(),A=e,j=Za(`ready`),ee=Za(`status`),M=Za(`cwd`),te=Za(`workspaceRoots`),N=M,[ne,F]=(0,g.useState)(!1),[re,ie]=(0,g.useState)(null),[ae,I]=(0,g.useState)(null),[R,z]=(0,g.useState)(null),[oe,B]=(0,g.useState)(``),[V,H]=iu($l,!1),[se,ce]=iu(eu,!1),[le,ue]=iu(tu,!1),[U,de]=ou(),[fe,W]=ru(),[pe,G]=(0,g.useState)(60);(0,g.useEffect)(()=>{G(60)},[N]);let K=(0,g.useMemo)(()=>{if(r.length<=pe)return r;let e=A?r.findIndex(e=>e.path===A):-1,t=e>=pe?e+10:pe;return r.slice(0,t)},[r,pe,A]),he=(0,g.useCallback)((e,t)=>{if(!t)return e.filter(e=>e.isSubagent&&!e.isStreaming&&e.id!==a).length;let n=new Map(e.map(e=>[e.id,e])),r=e=>{if(e.id===t)return(n.get(t)?.isSubagent??!1)&&!e.isStreaming&&e.id!==a;let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&!e.isStreaming&&e.id!==a&&r(e)).length},[a]),ge=(0,g.useCallback)((e,t)=>{if(!t)return e.filter(e=>e.isSubagent).length;let n=new Map(e.map(e=>[e.id,e])),r=e=>{if(e.id===t)return n.get(t)?.isSubagent??!1;let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&r(e)).length},[]),q=(0,g.useCallback)((e,t)=>{if(!t)return 0;let n=new Map(e.map(e=>[e.id,e])),r=e=>{let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&e.isStreaming&&r(e)).length},[]),ve=(0,g.useRef)(null),ye=(0,g.useRef)(null),be=(0,g.useRef)(()=>{}),xe=La(d??[]).length>0,Se=(0,g.useCallback)((e,n,i)=>{ve.current={x:e,y:n,target:i};let a=i.kind===`running`?i.id:void 0,o=i.kind===`elsewhere`,s=a??(o&&i.id||void 0),c=he(t,a),l=c===0?k(`noFinishedSubagents`):k(a?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:c}),u=!!a&&ye.current===a;Ea({x:e,y:n,slot:`contextmenu.session`,target:i,entries:(d??[]).map(e=>{if(e.source!==`host`)return e;if(e.id===`host:conv-rename`)return i.kind===`running`||i.kind===`history`?e:{...e,hidden:!0};if(e.id===`host:conv-takeover`)return o&&s&&i.owner&&!i.pseudo?e:{...e,hidden:!0};if(o&&(e.id===`host:conv-dismiss-subagents`||e.id===`host:conv-force-dismiss`))return{...e,hidden:!0};if(e.id===`host:conv-dismiss-subagents`)return{...e,label:l,...c===0?{when:[...e.when??[],`disabled`]}:{}};if(e.id===`host:conv-force-dismiss`)return a?{...e,...u?{label:k(`forceDismissConfirm`)}:{}}:{...e,hidden:!0};if(e.id===`host:conv-pin`){if(i.kind===`history`)return r.find(e=>e.path===i.id)?.pinned?{...e,label:k(`unpinConversation`)}:e;if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return!n||n.isSubagent?{...e,hidden:!0}:n.pinned?{...e,label:k(`unpinConversation`)}:e}if(e.id===`host:conv-persist`){if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return!n||!n.isSubagent&&n.sessionFile?{...e,hidden:!0}:n?.isEphemeral?{...e,label:k(`saveEphemeral`)}:e}if(e.id===`host:conv-copy-id`)return s?e:{...e,hidden:!0};if(e.id===`host:conv-copy-path`)return i.kind===`history`?e:a?t.some(e=>e.id===a&&e.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}:{...e,hidden:!0};if(e.id===`host:conv-copy-link`){if(i.kind===`history`)return r.find(e=>e.path===i.id)?.sessionId||rs(i.id)?e:{...e,hidden:!0};if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return n?.sessionId||rs(n?.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}}return e.id===`host:conv-quote`?s||i.kind===`history`?e:{...e,hidden:!0}:e}),onHostAction:(e,t)=>be.current(e,t)})},[d,t,he,k]);be.current=(0,g.useCallback)((e,n)=>{let i=n.kind===`running`?n.id:void 0,a=i??(n.kind===`elsewhere`&&n.id||void 0);if(e.id===`host:conv-takeover`){n.kind===`elsewhere`&&a&&n.owner&&o({type:`take_over_conversation`,owner:n.owner,id:a});return}if(e.id===`host:conv-dismiss-subagents`){o(i?{type:`dismiss_finished_subagents`,parentId:i}:{type:`dismiss_finished_subagents`});return}if(e.id===`host:conv-force-dismiss`){let e=ve.current;if(!i||!e)return;if(ye.current!==i)return ye.current=i,Se(e.x,e.y,e.target),!0;ye.current=null,o({type:`dismiss_conversation`,id:i,force:!0});return}if(e.id===`host:conv-persist`){i&&o({type:`persist_conversation`,id:i});return}if(e.id===`host:conv-pin`){if(n.kind===`history`){let e=r.find(e=>e.path===n.id);o({type:`pin_session`,path:n.id,pinned:!e?.pinned});return}i&&o({type:`pin_conversation`,id:i,pinned:!t.find(e=>e.id===i)?.pinned});return}if(e.id===`host:conv-copy-id`&&a){navigator.clipboard?.writeText(a).catch(()=>{});return}if(e.id===`host:conv-copy-path`){let e=n.kind===`history`?n.id:i&&t.find(e=>e.id===i)?.sessionFile||void 0;e&&navigator.clipboard?.writeText(e).catch(()=>{});return}if(e.id===`host:conv-copy-link`){let e=n.kind===`history`?r.find(e=>e.path===n.id)?.sessionId||rs(n.id):i?t.find(e=>e.id===i)?.sessionId||rs(t.find(e=>e.id===i)?.sessionFile):null;if(e){let t=ns(window.location.href,{sessionId:e});navigator.clipboard?.writeText(t).catch(()=>{})}return}if(e.id===`host:conv-quote`){n.kind===`history`&&n.id?lr({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&lr({attachments:[{path:``,key:`conv|${a}|`,name:n.label||a,mode:`conversation`,conversationId:a}]});return}if(e.id===`host:conv-rename`){if(ie(null),i){let e=t.find(e=>e.id===i);B(e?.title??n.label??``),z(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);B(e?.name??n.label??``),z(n.id)}return}},[o,Se,t,r]);let Ce=(e,t,n)=>!e||e.length===0?null:(0,X.jsx)(`span`,{className:t,children:e.map((e,t)=>{let r=`${e.id}#${t}`,i=e.label||e.id,a=e.hint||i;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`lp-slot-divider`,"aria-hidden":`true`},r):e.kind===`badge`?(0,X.jsx)(`span`,{className:`lp-slot-badge`,title:a,children:e.badge??i},r):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`lp-slot-select`,title:a,"aria-label":i,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onClick:e=>e.stopPropagation(),onChange:t=>{t.stopPropagation(),T?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},r):(0,X.jsx)(`button`,{type:`button`,className:`lp-slot-btn`,title:a,"aria-label":i,onClick:t=>{t.stopPropagation(),n?T?.(e,void 0,n):T?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:i})},r)})}),we=(0,g.useCallback)((e,t)=>{Ql(e.target)||xe&&(e.preventDefault(),e.stopPropagation(),ye.current=null,Se(e.clientX,e.clientY,t))},[xe,Se]),Te=(0,g.useRef)(null),[De,Oe]=(0,g.useState)(()=>fu());(0,g.useEffect)(()=>{try{localStorage.setItem(su,JSON.stringify(De))}catch{}},[De]);let ke=(0,g.useMemo)(()=>{let e=new Set,r=new Set;for(let n of t)n.sessionFile&&e.add(n.sessionFile),r.add(`${n.cwd}\0${n.title}`);let i=[],a=new Set;for(let t of n){if(t.sessionFile&&e.has(t.sessionFile)||r.has(`${t.cwd}\0${t.title}`))continue;let n=t.sessionFile?`file:${t.sessionFile}`:`title:${t.cwd}\0${t.title}`;a.has(n)||(a.add(n),i.push({id:t.sessionFile?`elsewhere:${t.cwd}:${t.sessionFile}`:`elsewhere:${t.cwd}:${t.title}${t.owner?`:${t.owner}`:``}`,title:t.title,cwd:t.cwd,messageCount:0,isStreaming:t.isStreaming,isSubagent:!1,elsewhere:!0,pseudo:!!t.pseudo,ownerOffline:!!t.ownerOffline,sessionFile:t.sessionFile,...t.owner&&t.convId?{owner:t.owner,convId:t.convId}:{},...t.hasQuestion?{hasQuestion:!0}:{}}))}return[...t,...i]},[t,n]),Ae=Fi(y),je=Ae.filter(e=>e.shown),Me=e=>e===`projects`?V:e===`convs`?se:e===`sessions`?le:U.has(e),Ne=(x??[]).reduce((e,t)=>e+t.items.length,0),Pe=ke.length+Ne,Fe=Ii(Ae,e=>e===`projects`?i.length>0:e!==`convs`||Pe>0),Ie=()=>{let e=x??[];return e.length===0?null:e.map(e=>(0,X.jsxs)(`div`,{className:`panel-conv-group lp-plugin-group`,children:[(0,X.jsxs)(`div`,{className:`panel-conv-group-title`,title:e.pluginId,children:[k(`leftPanelPluginGroup`),` · `,e.pluginName]}),e.items.map(t=>(0,X.jsx)(`div`,{className:`lp-row lp-plugin-row`,children:(0,X.jsxs)(`button`,{type:`button`,className:`session-item lp-plugin-item${t.action?``:` is-static`}`,title:t.hint?`${t.title} — ${t.hint}`:t.title,onClick:()=>S?.(e,t),children:[(0,X.jsx)(`span`,{className:`lp-plugin-dot st-${t.status}`,title:k(uu[t.status])}),t.icon?(0,X.jsx)(`span`,{className:`lp-plugin-icon`,"aria-hidden":!0,children:t.icon}):null,(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:t.title}),t.hint?(0,X.jsx)(`span`,{className:`session-sub`,children:t.hint}):null]})]})},t.id))]},`plugin:${e.pluginId}`))},Le=(0,g.useMemo)(()=>[...f??[],...C??[]],[f,C]),Be=(0,g.useMemo)(()=>[...f??[],...w??[]],[f,w]),Ve=(0,g.useCallback)((e,t)=>n=>{n.preventDefault();let r=n.currentTarget,i=n.clientY,a={...De},o=Te.current;if(!o)return;let s=Fe.filter(e=>Me(e)).length,c=Fe.filter(e=>!Me(e)).reduce((e,t)=>e+(a[t]??1),0)||1,l=Math.max(120,o.clientHeight-s*lu);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let u=n=>{let{above:r,below:o}=Zo({start:{above:a[e]??1,below:a[t]??1},deltaPx:n.clientY-i,availablePx:l,totalWeight:c,minAbovePx:du,minBelowPx:du});Oe(n=>({...n,[e]:r,[t]:o}))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),r.classList.remove(`dragging`),document.body.classList.remove(`lp-resizing`)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)},[De,Fe,V,se,le]);(0,g.useEffect)(()=>{s&&j&&ee===`open`&&M&&(o({type:`list_sessions`}),o({type:`list_projects`}))},[s,j,ee,M,o]);let He=e=>{let t=e.name||e.firstMessage.trim();return t.length>0?t:k(`emptyChat`)},Ue=e=>e.split(/[\\/]/).pop()||e,We=La(p??[]).length>0,Ge=(0,g.useCallback)((e,t)=>{Ql(e.target)||We&&(e.preventDefault(),e.stopPropagation(),Ea({x:e.clientX,y:e.clientY,slot:`contextmenu.project`,target:{id:t.path,kind:`project`,label:Ue(t.path)},entries:p??[]}))},[We,p]),Y=(e,t,n,r,i)=>{let a=re===e;return(0,X.jsx)(`button`,{type:`button`,className:`lp-del ${a?`confirm`:``}`,title:a?n:t,onClick:t=>{t.stopPropagation(),a?(ie(null),r()):ie(e)},children:a?(0,X.jsx)(ft,{}):i??(0,X.jsx)(L,{})})},qe=(e,t,n,r,i,a)=>(0,X.jsxs)(`div`,{className:`lp-section-header`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`lp-section-title panel-section-title`,onClick:n,title:k(t?`expandSection`:`collapseSection`),children:[(0,X.jsxs)(`span`,{className:`lp-section-title-text`,children:[e,r===void 0?``:` (${r})`]}),(0,X.jsx)(`span`,{className:`lp-section-chevron`,children:t?(0,X.jsx)(dt,{}):(0,X.jsx)(ct,{})})]}),i||a?(0,X.jsxs)(`div`,{className:`lp-section-actions`,children:[i,a]}):null]}),Je=Fe.filter(e=>!Me(e)),Ye=Je.reduce((e,t)=>e+(De[t]??1),0)||1,Xe=e=>Je.length<=1?1:(De[e]??1)/Ye*Je.length,Ze=new Map(Li(Fe,Me).map(([e,t])=>[e,(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:Ve(e,t),onDoubleClick:()=>Oe({...cu}),title:k(`dragToResize`)},`sash-${e}`)])),Qe={projects:(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${V||i.length===0?`collapsed`:``}`,style:i.length>0&&!V?{flex:`${Xe(`projects`)} 1 0px`}:void 0,children:[qe(k(`recentProjects`),V,H,i.length,(0,X.jsxs)(X.Fragment,{children:[O&&(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action lp-sandbox-action`,title:k(`sandboxNewBtn`),"aria-label":k(`sandboxNewBtn`),onClick:()=>O(),children:(0,X.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:`13px`,lineHeight:1},children:`🧪`})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action`,title:k(`manageProjects`),"aria-label":k(`manageProjects`),onClick:()=>F(!0),children:(0,X.jsx)(ze,{})})]}),Ce(m,`lp-slot-section`)),i.length>0&&!V&&(0,X.jsx)(`div`,{className:`lp-section-body projects-scroll`,children:i.map(e=>{let t=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),n=N===e.path,r=D?.kind===`cwd`&&t(D.target)===t(e.path),i=e.sandbox,a=i?i.name:Ue(e.path);return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>ie(t=>t===`proj:${e.path}`?null:t),onContextMenu:t=>Ge(t,e),children:[(0,X.jsxs)(`button`,{type:`button`,className:`project-item ${n?`active`:``} ${r?`switching`:``}`,title:i?.sourcePath?`${a}\n${k(`sandboxSourceLabel`)}: ${i.sourcePath}\n${e.path}`:e.path,disabled:r,onClick:()=>{!n&&!r&&o({type:`set_cwd`,path:e.path})},children:[r?(0,X.jsx)(Ee,{className:`project-icon spin`}):i?(0,X.jsx)(`span`,{className:`project-icon sandbox-icon`,"aria-hidden":!0,children:`🧪`}):(0,X.jsx)(Re,{className:`project-icon`}),(0,X.jsxs)(`span`,{className:`project-info`,children:[(0,X.jsxs)(`span`,{className:`project-name`,children:[a,i&&(0,X.jsx)(`span`,{className:`lp-sandbox-badge ${i.ephemeral?`ephemeral`:`permanent`}`,children:i.ephemeral?k(`sandboxBadgeEphemeral`):k(`sandboxBadgePermanent`)})]}),(0,X.jsx)(`span`,{className:`project-path`,children:i?.sourcePath?`← ${Ue(i.sourcePath)} · ${e.path}`:e.path})]}),(0,X.jsx)(`span`,{className:`project-time ${r?`switching-pct`:``}`,children:r?`${D.progress}%`:Zl(e.lastUsed)})]}),Y(`proj:${e.path}`,k(i?`sandboxActionDestroyTip`:`deleteProject`),k(i?`sandboxActionDestroy`:`deleteProjectConfirm`),()=>{zl(e.path),Ul(e.path),o(i?{type:`destroy_sandbox`,path:e.path}:{type:`remove_project`,path:e.path})}),Ce(h,`lp-slot-project`,{id:e.path,kind:`project`,label:a})]},e.path)})})]})}),convs:(0,X.jsx)(X.Fragment,{children:Pe>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${se?`collapsed`:``}`,style:se?void 0:{flex:`${Xe(`convs`)} 1 0px`},onContextMenu:e=>we(e,{id:``,kind:`section`,label:k(`runningConversations`)}),children:[qe(k(`runningConversations`),se,ce,Pe,void 0,Ce(_,`lp-slot-section`)),!se&&(0,X.jsxs)(`div`,{className:`lp-section-body convs-scroll`,children:[Qo(ke,M,a).map(e=>(0,X.jsxs)(`div`,{className:`panel-conv-group`,children:[!e.isCurrent&&(0,X.jsx)(`div`,{className:`panel-conv-group-title`,title:e.cwd,onContextMenu:t=>Ge(t,{path:e.cwd,lastUsed:0}),children:Ue(e.cwd)}),$o(e.convs,fe).map(({c:n,depth:r,hasKids:i,isCollapsed:s,descendantCount:c,hasStreaming:l,hasError:u,hasQuestion:d})=>{if(n.elsewhere){let e=n.owner,t=n.convId,r=!!n.pseudo,i=!!n.ownerOffline&&!r,a=!!(e&&t)&&!r,s=ae===n.id,c=s?k(`takeoverConfirm`):r?`${k(`elsewherePseudoTip`)}\n${n.cwd}`:`${k(i?`elsewhereOfflineTip`:`elsewhereTip`)}\n${n.cwd}`;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>I(e=>e===n.id?null:e),onContextMenu:i=>we(i,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{},...r?{pseudo:!0}:{}}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item elsewhere-item${a?``:` elsewhere-static`}${s?` confirm`:``}`,title:c,tabIndex:a?0:-1,onClick:a?()=>{if(!s){I(n.id);return}I(null),o({type:`take_over_conversation`,owner:e,id:t})}:void 0,children:[(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsxs)(`span`,{className:`session-title`,children:[(0,X.jsx)(`span`,{className:`elsewhere-badge`,children:k(r?`elsewherePseudoBadge`:`elsewhereBadge`)}),i&&(0,X.jsx)(`span`,{className:`elsewhere-badge offline`,title:k(`elsewhereOfflineTip`),children:k(`elsewhereOfflineBadge`)}),n.hasQuestion&&e&&t&&!r&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:k(`takeoverHasQuestion`),onClick:n=>{n.stopPropagation(),o({type:`peek_elsewhere_question`,owner:e,id:t})},children:`?`}),s?k(`takeoverConfirm`):n.title]}),(0,X.jsx)(`span`,{className:`session-sub`,children:Ue(n.cwd)})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:k(`streaming`)})]}),xe&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-elsewhere-act`,title:k(`elsewhereActions`),onClick:i=>{i.stopPropagation(),ye.current=null;let a=i.currentTarget.getBoundingClientRect();Se(a.left,a.bottom+4,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{},...r?{pseudo:!0}:{}})},children:(0,X.jsx)(_e,{})})]},n.id)}let f=a===n.id;return(0,X.jsxs)(`div`,{className:`lp-row${r>0?` lp-sub`:``}${i?` lp-has-kids`:``}`,style:r>0?{marginLeft:r*18}:void 0,onMouseLeave:()=>ie(e=>e===`conv:${n.id}`?null:e),onContextMenu:e=>we(e,{id:n.id,kind:`running`,label:n.title}),children:[i&&(0,X.jsx)(`button`,{type:`button`,className:`lp-tree-caret${s?` collapsed`:` expanded`}`,title:k(s?`expandSubagents`:`collapseSubagents`),"aria-label":k(s?`expandSubagents`:`collapseSubagents`),onClick:e=>{e.stopPropagation(),W(n.id)},children:s?(0,X.jsx)(lt,{}):(0,X.jsx)(dt,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${f?`active`:``}`,title:`${n.title}${e.isCurrent?``:` — ${e.cwd}`}`,onClick:()=>{f||o({type:`switch_conversation`,id:n.id})},children:[(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[R===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:oe,placeholder:k(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>B(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=oe.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),z(null)}else e.key===`Escape`&&z(null)},onBlur:()=>z(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:k(`pinnedConversation`),children:`📌`}),n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:k(`subagentBadge`)}),n.isEphemeral&&(0,X.jsx)(`span`,{className:`ephemeral-badge`,children:k(`ephemeralBadge`)}),n.forkFrom&&(0,X.jsxs)(`span`,{className:`preset-badge fork-badge`,title:`${k(`forkBadgeTip`)}: ${n.forkFrom.title??n.forkFrom.conversationId}`,children:[`🌿 `,k(`forkBadge`)]}),n.agentPreset&&(0,X.jsx)(`span`,{className:`preset-badge`,title:n.agentPreset,children:E?.[n.agentPreset]??n.agentPreset}),n.title,n.error&&(0,X.jsx)(`span`,{className:`conv-error-badge`,title:k(`convErrorBadge`,{error:n.error})}),n.hasQuestion&&(0,X.jsx)(`span`,{className:`question-badge`,title:k(`waitingQuestionBadge`),children:`?`}),i&&s&&(0,X.jsxs)(`span`,{className:`subagents-collapsed-badge${l?` has-streaming`:d?` has-question`:u?` has-error`:``}`,title:k(l?`subagentsStreamingTip`:d?`subagentsQuestionTip`:u?`subagentsErrorTip`:`subagentsCountTip`,{n:c}),onClick:e=>{e.stopPropagation(),W(n.id)},children:[l&&(0,X.jsx)(`span`,{className:`subagent-dot streaming`}),d&&(0,X.jsx)(`span`,{className:`subagent-dot question`,children:`?`}),u&&(0,X.jsx)(`span`,{className:`subagent-dot error`}),(0,X.jsx)(`span`,{className:`subagents-count-text`,children:k(`subagentBadgeCount`,{n:c})})]})]}),R===`conv:${n.id}`?null:(0,X.jsx)(`span`,{className:`session-sub`,children:f?k(`current`):k(`messageCount`,{n:n.messageCount})})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:k(`streaming`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:k(`renameSession`),onClick:e=>{e.stopPropagation(),ie(null),B(n.title),z(`conv:${n.id}`)},children:(0,X.jsx)(Ke,{})}),(()=>{let e=`conv:${n.id}`,r=re===e,i=he(t,n.id),a=q(t,n.id),s=ge(t,n.id);return s===0&&!n.isStreaming?Y(e,k(`dismissConversation`),k(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(P,{})):s===0?Y(e,k(`dismissConversation`),k(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(P,{})):r?(0,X.jsxs)(`span`,{className:`lp-del-group`,children:[i>0&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt`,title:k(`dismissFinishedSubagentsScoped`,{n:i}),onClick:e=>{e.stopPropagation(),ie(null),o({type:`dismiss_finished_subagents`,parentId:n.id})},children:k(`dismissFinishedOnly`,{n:i})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt danger`,title:k(`forceDismissTitle`,{n:s,m:a}),onClick:e=>{e.stopPropagation(),ie(null),o({type:`dismiss_conversation`,id:n.id,force:!0})},children:k(`dismissForceAll`,{n:s})})]}):(0,X.jsx)(`button`,{type:`button`,className:`lp-del`,title:k(`dismissConversation`),onClick:t=>{t.stopPropagation(),ie(e)},children:(0,X.jsx)(P,{})})})(),Ce(Le,`lp-slot-sessions`),n.isStreaming&&(0,X.jsx)(`span`,{className:`lp-row-stalled`,title:k(`streaming`),style:{position:`absolute`,right:28,top:`50%`,transform:`translateY(-50%)`}})]},n.id)})]},e.cwd)),Ie()]})]})}),sessions:(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${le?`collapsed`:``}`,style:le?void 0:{flex:`${Xe(`sessions`)} 1 0px`},children:[qe(k(`historySessions`),le,ue,r.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-new-chat-action`,title:k(`newChatTip`),"aria-label":k(`newChat`),onClick:()=>{o({type:`new_chat`}),sr()},children:(0,X.jsx)(me,{})}),Ce(v,`lp-slot-section`)),!le&&(0,X.jsxs)(`div`,{className:`lp-section-body sessions-scroll`,onScroll:e=>{if(K.length>=r.length)return;let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<180&&G(e=>Math.min(r.length,e+60))},children:[r.length===0&&(0,X.jsx)(`div`,{className:`panel-empty`,children:k(`noHistory`)}),K.map(e=>{let t=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),n=A===e.path,r=D?.kind===`session`&&t(D.target)===t(e.path);return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>ie(t=>t===`sess:${e.path}`?null:t),onContextMenu:t=>we(t,{id:e.path,kind:`history`,label:He(e)}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${n?`active`:``} ${r?`switching`:``}`,title:e.path,disabled:r,onClick:()=>{R||r||n||o({type:`switch_session`,path:e.path})},children:[r?(0,X.jsx)(Ee,{className:`session-icon spin`}):(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[R===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:oe,placeholder:k(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>B(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=oe.trim();t&&o({type:`rename_session`,path:e.path,name:t}),z(null)}else t.key===`Escape`&&z(null)},onBlur:()=>z(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[e.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:k(`pinnedConversation`),children:`📌`}),He(e)]}),R===e.path?null:(0,X.jsxs)(`span`,{className:`session-sub`,children:[n?k(`current`):k(`messageCount`,{n:e.messageCount}),e.source===`tui`&&(0,X.jsx)(`span`,{className:`session-src`,title:k(`tuiTip`),children:`TUI`})]})]}),(0,X.jsx)(`span`,{className:`session-time ${r?`switching-pct`:``}`,children:r?`${D.progress}%`:Zl(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:k(`renameSession`),onClick:t=>{t.stopPropagation(),ie(null),B(e.name??``),z(e.path)},children:(0,X.jsx)(Ke,{})}),Y(`sess:${e.path}`,k(`deleteSession`),k(`deleteSessionConfirm`),()=>{Jl(e.path,N),o({type:`delete_session`,path:e.path})}),Ce(Be,`lp-slot-sessions`)]},e.path)})]})]})})},$e=e=>{let t=je.find(t=>t.key===e)?.entry;if(!t)return null;let n=Me(e);return(0,X.jsxs)(`div`,{className:`lp-section lp-section-plugin ${n?`collapsed`:``}`,style:n?void 0:{flex:`${Xe(e)} 1 0px`},children:[qe(t.label,n,()=>de(e)),!n&&(0,X.jsx)(`div`,{className:`lp-section-body lp-plugin-section-body`,children:b?.(t)??null})]})},et=e=>e===`projects`||e===`convs`||e===`sessions`?Qe[e]:$e(e);return(0,X.jsxs)(`aside`,{ref:Te,className:`panel panel-left lp-panel`,children:[c&&l&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:k(`collapsePanel`),onClick:l,children:(0,X.jsx)(st,{})}),je.map(({key:e})=>(0,X.jsxs)(g.Fragment,{children:[et(e),Ze.get(e)??null]},e)),(0,X.jsx)(So,{open:ne,currentCwd:N,pathCompletions:u??[],workspaceRoots:te,onClose:()=>F(!1),onSelectDirectory:e=>o({type:`set_cwd`,path:e}),onCreateProject:e=>o({type:`make_dir`,path:e,setAsCwd:!0})})]})}),mu=209715200,hu=/windows/i.test(navigator.userAgent),gu=/[<>:"/\\|?*\u0000-\u001f]/g,_u=/[. ]+$/,vu=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function yu(e){let t=e.replace(gu,`_`).replace(_u,``);return t?vu.test(t)?`_${t}`:t:`_`}function bu(e,t=!0){return gn(fn(`/api/file?${new URLSearchParams({clientId:Fl(),path:e,...t?{download:`1`}:{}})}`))}async function xu(e,t){let n=hu?yu(t):t;try{let t=await fetch(bu(e));if(!t.ok)return{ok:!1,cancelled:!1,error:await t.text().catch(()=>``)||(t.status===404?`FILE_NOT_FOUND`:`HTTP ${t.status}`)};if(Number(t.headers.get(`content-length`)??`0`)>mu)return window.location.assign(bu(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?Cu(r,n):wu(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function Su(e,t){let n=hu?yu(t):t;return window.showSaveFilePicker&&window.isSecureContext?Cu(e,n):wu(e,n)}async function Cu(e,t){let n,r=window.showSaveFilePicker;if(!r)return wu(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:wu(e,t)}try{let t=await n.createWritable();return await t.write(e),await t.close(),{ok:!0}}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}function wu(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);return r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),{ok:!0}}function Tu(e,t,n){let r=e.left-8,i=e.bottom+8;return r+t.width>n.width-8&&(r=Math.max(8,e.right+8-t.width)),i+t.height>n.height-8&&(i=Math.max(8,e.top-8-t.height)),{left:r,top:i}}function Eu(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function Du({text:e}){let t=(0,g.useRef)(null),n=(0,g.useRef)(null),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)({left:0,top:0}),s=()=>{let e=t.current?.getBoundingClientRect();e&&(o({left:Math.max(8,e.left-8),top:e.bottom+8}),i(!0))},c=()=>i(!1);return(0,g.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=Tu(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,g.useEffect)(()=>{if(!r)return;let e=0,a=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e=t.current,r=n.current;if(!e||!r)return;let a=e.getBoundingClientRect();if(a.bottom<0||a.top>window.innerHeight||a.right<0||a.left>window.innerWidth){i(!1);return}let s=Tu(a,r.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)})};return window.addEventListener(`scroll`,a,!0),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(e),window.removeEventListener(`scroll`,a,!0),window.removeEventListener(`resize`,a)}},[r]),(0,X.jsxs)(`span`,{ref:t,className:`set-tip`,tabIndex:0,"aria-label":e,onMouseEnter:s,onMouseLeave:c,onFocus:s,onBlur:c,onKeyDown:e=>{e.key===`Escape`&&e.target.blur()},children:[`?`,r&&(0,j.createPortal)((0,X.jsx)(`span`,{ref:n,className:`set-tip-bubble open`,role:`tooltip`,style:{position:`fixed`,left:a.left,top:a.top},children:e}),document.body)]})}var Ou=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function ku(e,t={}){let n={archive:fn(`/api/file-transfer/archive`),upload:fn(`/api/file-transfer/upload`)},r=new URL(gn(`${n[e]}?${new URLSearchParams({clientId:Fl(),...t})}`),window.location.href);if(r.origin!==window.location.origin||r.pathname!==new URL(n[e],window.location.href).pathname)throw Error(`File transfers must use an allowlisted same-origin endpoint`);return r}async function Au(e,t,n){let r=await fetch(ku(`archive`),{method:`POST`,headers:{"Content-Type":`application/json`,"X-File-Operation":`1`},body:JSON.stringify({action:e,path:t,...n})});if(!r.ok)throw Error(await r.text());if(e===`download`){let e=r.headers.get(`content-disposition`)??``,t=/filename\*=UTF-8''([^;]+)/i.exec(e)?.[1],n=/filename="([^"]+)"/i.exec(e)?.[1],i=t?decodeURIComponent(t):n??`archive.tar.gz`,a=await Su(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function ju(){let e=window.showDirectoryPicker;if(!e)return null;let t=await e.call(window),n=[];async function r(e,t){if(n.length>=2e4)throw Error(`Folder exceeds 20,000 entries`);if(n.push(e.kind===`file`?{path:t,file:await e.getFile()}:{path:t}),e.kind===`directory`)for await(let n of e.values())await r(n,`${t}/${n.name}`)}return await r(t,t.name),n}async function Mu(e,t,n){if(t.length>2e4)throw Error(`Folder exceeds 20,000 entries`);for(let e of t)if(e.file&&e.file.size>33554432)throw Error(`File exceeds 32 MiB: ${e.path}`);let r=0;for(let i of t){let t=ku(`upload`,{dir:e,name:i.path,kind:i.file?`file`:`directory`}),a=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-File-Operation":`1`},body:i.file??new Blob});if(!a.ok)throw Error(`${i.path}: ${await a.text()}`);n?.(++r)}}function Nu({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,g.useState)(e.dir),[o,s]=(0,g.useState)(`skip`),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(0),f=(0,g.useRef)(null),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(``),v=(0,g.useRef)(null);(0,g.useEffect)(()=>{v.current?.showModal()},[]);let y=r(e.action===`upload`?`fileUploadFolder`:e.action===`extract`?`fileExtract`:e.action===`download`?`fileCompressDownload`:`fileCompress`);async function b(){try{let e=await ju();e?l(e):f.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),m(!0),_(``);try{e.action===`upload`?await Mu(e.dir,c,d):await Au(e.action,e.path,{destination:i,policy:o}),n(),t()}catch(e){_(e instanceof Error?e.message:String(e)),n()}finally{m(!1)}}return(0,j.createPortal)((0,X.jsx)(`dialog`,{ref:v,className:`file-transfer-dialog`,"aria-labelledby":`file-transfer-title`,onCancel:e=>{e.preventDefault(),p||t()},children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),x()},children:[(0,X.jsxs)(`div`,{className:`file-transfer-head`,children:[(0,X.jsx)(`h3`,{id:`file-transfer-title`,children:y}),(0,X.jsx)(`button`,{type:`button`,className:`file-transfer-close`,title:r(`close`),"aria-label":r(`close`),disabled:p,onClick:t,children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`p`,{className:`file-transfer-path`,children:(e.action===`upload`?e.dir:e.path)||`.`}),(0,X.jsx)(`p`,{children:r(`fileArchiveLimits`)}),e.action===`extract`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`label`,{children:[r(`fileExtractDestination`),(0,X.jsx)(`input`,{value:i,disabled:p,onChange:e=>a(e.target.value)})]}),(0,X.jsxs)(`label`,{children:[r(`fileConflictPolicy`),(0,X.jsxs)(`select`,{value:o,disabled:p,onChange:e=>s(e.target.value),children:[(0,X.jsx)(`option`,{value:`skip`,children:r(`fileConflictSkip`)}),(0,X.jsx)(`option`,{value:`overwrite`,children:r(`fileConflictOverwrite`)}),(0,X.jsx)(`option`,{value:`error`,children:r(`fileConflictError`)})]})]})]}),e.action===`upload`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:r(`fileFolderUploadHint`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:p,onClick:()=>void b(),children:r(`fileChooseFolder`)}),(0,X.jsx)(`input`,{type:`file`,"aria-label":y,multiple:!0,hidden:!0,disabled:p,ref:e=>{f.current=e,e?.setAttribute(`webkitdirectory`,``)},onChange:e=>l(Array.from(e.target.files??[],e=>({path:e.webkitRelativePath||e.name,file:e})))}),(0,X.jsxs)(`p`,{"aria-live":`polite`,children:[u,` / `,c.length]})]}),h&&(0,X.jsx)(`p`,{role:`alert`,children:r(`fileTransferFailed`,{error:h})}),(0,X.jsxs)(`div`,{className:`file-transfer-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:p,onClick:t,children:r(`cancel`)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:p||e.action===`upload`&&c.length===0,children:p?r(`fileTransferBusy`):y})]})]})}),document.body)}function Pu(e){return e.startsWith(`.`)&&e!==`..`}function Fu(e,t){return t?e:e.filter(e=>!Pu(e.name))}function Iu(e){return e instanceof Error?e.message:String(e)}function Lu(e,t,n,r){let i=n===`zh`;switch(e.kind){case`no-client`:return i?`插件 ${t} 没有客户端脚本(client/entry.mjs),无法显示这一页。`:`Plugin ${t} ships no client bundle (client/entry.mjs), so this page cannot be shown.`;case`load`:return i?`插件 ${t} 的页面脚本加载失败:${e.detail}`:`Failed to load plugin ${t}'s page bundle: ${e.detail}`;case`mount`:return`${r(`pluginMountFailed`,{name:t})}:${e.detail}`}}function Ru({plugin:e,epoch:t,send:n,className:r}){let i=(0,g.useRef)(null),{locale:a}=Nn(),o=Z(),[s,c]=(0,g.useState)(null),l=(0,g.useRef)(n);(0,g.useEffect)(()=>{l.current=n},[n]),(0,g.useEffect)(()=>{let n=i.current;if(!n)return;let r=!1,a,o=!1;if(c(null),!e.hasClient){c({kind:`no-client`});return}return(async()=>{try{if(await nl(e,t),r)return;let i=await Ys(e.id,()=>Pc(()=>import(Zc(e.id,t)),[]));if(r)return;let s=i.default;if(!s||typeof s.mount!=`function`)throw Error(`client/entry.mjs 没有导出 default.mount()`);o=!0,a=s.mount(n,il(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:Iu(t)})}})(),()=>{if(r=!0,typeof a==`function`)try{a()}catch(t){console.error(`[plugin:${e.id}] cleanup 失败:`,t)}n.textContent=``}},[e.id,e.hasClient,t]);let u=r?`plugin-page ${r}`:`plugin-page`;return(0,X.jsxs)(`div`,{className:u,children:[(0,X.jsx)(`div`,{className:`plugin-page-host`,ref:i}),s&&(0,X.jsx)(`div`,{className:`plugin-page-error`,role:`alert`,children:Lu(s,e.name,a,o)})]})}function zu(e){return`pi-web-ui:${e}:tab`}function Bu(e,t){try{let n=localStorage.getItem(zu(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function Vu(e,t){try{localStorage.setItem(zu(e),t)}catch{}}function Hu(e){return e.length>0&&!/[a-z]/i.test(e)}function Uu(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function Wu({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,g.useId)(),[s,c]=(0,g.useState)(()=>Bu(e,t)??t[0]?.id??``),l=(0,g.useRef)([]),u=(0,g.useRef)(``),d=t.findIndex(e=>e.id===s),f=d>=0?t[d]:t[0],p=f?t.indexOf(f):-1;(0,g.useEffect)(()=>{if(!f)return;s!==f.id&&c(f.id);let t=`${e}:${f.id}`;u.current!==t&&(u.current=t,Vu(e,f.id))},[f,s,e]);let m=t=>{c(t.id),u.current=`${e}:${t.id}`,Vu(e,t.id)},h=(e,n)=>{let r=t.length,i=-1;if(e.key===`ArrowRight`)i=(n+1)%r;else if(e.key===`ArrowLeft`)i=(n-1+r)%r;else if(e.key===`Home`)i=0;else if(e.key===`End`)i=r-1;else return;let a=t[i];a&&(e.preventDefault(),m(a),l.current[i]?.focus())};if(!f)return null;let _=`${o}-panel-${p}`,v=a?`slot-tabs ${a}`:`slot-tabs`;return(0,X.jsxs)(`div`,{className:v,children:[(0,X.jsxs)(`div`,{className:`slot-tabs-bar`,role:`tablist`,children:[t.map((e,t)=>{let n=t===p;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,id:`${o}-tab-${t}`,className:n?`slot-tab active`:`slot-tab`,title:e.hint??Uu(e),"aria-selected":n,"aria-controls":`${o}-panel-${t}`,tabIndex:n?0:-1,ref:e=>{l.current[t]=e},onClick:()=>m(e),onKeyDown:e=>h(e,t),children:[e.iconSvg?(0,X.jsx)(hi,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&Hu(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:Uu(e)})]},e.id)}),i?(0,X.jsx)(`div`,{className:`slot-tabs-extra`,children:i}):null]}),(0,X.jsx)(`div`,{className:`slot-tabs-body`,id:_,role:`tabpanel`,"aria-labelledby":`${o}-tab-${p}`,children:f.pluginPage?(0,X.jsx)(Ru,{plugin:f.pluginPage.plugin,epoch:n,send:r}):f.element??null})]})}function Gu(e){if(typeof document>`u`)return!1;try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.style.top=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}async function Ku(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Gu(e)}return Gu(e)}function qu(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,g.useCallback)(()=>{s(),a(!1)},[s]);return(0,g.useEffect)(()=>()=>{s()},[s]),{copied:i,copy:(0,g.useCallback)(async e=>{let i=!1;try{i=await Ku(e)}catch(e){i=!1,r&&r(e)}return i?(a(!0),s(),o.current=setTimeout(()=>{a(!1),o.current=null},t),n?.(e)):r&&!i&&r(Error(`Copy failed`)),i},[t,n,r,s]),reset:c}}var Ju=`@root`,Yu=`pi-web-ui:rp-sizes`,Xu=`pi-web-ui:files-show-hidden`,Zu={files:4,widgets:1},Qu=120,$u=56;function ed(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var td=`files`,nd=[],rd=()=>{};function id(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function ad(e){return e===Ju||e===`/`||/^[A-Za-z]:$/.test(e)}function od(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var sd=(0,g.memo)(function({files:e,fileChanged:t,widgets:n,panelSend:r,onAttach:i,onPreview:a,onNotice:o,collapsible:s,onToggleCollapse:c,uiRightPanelTabs:l,uiContextFile:u,plugins:d,pluginsEpoch:f,send:p}){let m=Z(),h=d??nd,_=Za(`cwd`),v=Za(`workspaceRoots`),y=Za(`homeDir`),b=Za(`desktopDir`),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(null),[k,A]=(0,g.useState)(()=>{try{return Xo(localStorage.getItem(Yu),Zu)}catch{return{...Zu}}});(0,g.useEffect)(()=>{try{localStorage.setItem(Yu,JSON.stringify(k))}catch{}},[k]);let[j,ee]=(0,g.useState)(()=>{try{return localStorage.getItem(Xu)===`1`}catch{return!1}});(0,g.useEffect)(()=>{try{localStorage.setItem(Xu,j?`1`:`0`)}catch{}},[j]);let M=n.some(e=>e.lines.length>0),te=(0,g.useCallback)(e=>{e.preventDefault();let t=D.current;if(!t)return;let n=e.currentTarget,r=e.clientY,i={above:k.files,below:k.widgets},a=Math.max(120,t.clientHeight-ed(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=Zo({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:Qu,minBelowPx:$u});A({files:t,widgets:n})},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),n.classList.remove(`dragging`),document.body.classList.remove(`rp-resizing`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},[k.files,k.widgets]),N=(0,g.useRef)(null),ne=(0,g.useRef)(0),F=(0,g.useCallback)(e=>{N.current=e,e&&(e.scrollTop=ne.current)},[]),[re,ie]=(0,g.useState)(null),ae=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{ae.current&&clearTimeout(ae.current)},[]);let I=(0,g.useCallback)(e=>{ie(e),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>ie(null),1200)},[]),L=(0,g.useCallback)((e,t)=>{e&&Ku(e).then(e=>{e?I(t):o(`error`,m(`slashCopyFailed`))})},[I,o,m]),R=(0,g.useCallback)(e=>{if(!e)return _;if(/^[A-Za-z]:$/.test(e))return`${e}/`;if(e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e))return e;let t=_.replace(/\\/g,`/`).replace(/\/+$/,``);return t?`${t}/${e}`:e},[_]),z=(0,g.useCallback)(e=>!e||e===Ju?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),oe=104857600,B=(0,g.useCallback)((e,t)=>{for(let n of t){if(n.size>oe){o(`warning`,m(`fileTooLarge`,{name:n.name,size:oe/1024/1024}));continue}let t=new FileReader;t.onload=()=>{let i=t.result,a=i.slice(i.indexOf(`,`)+1);a&&r({type:`upload_file`,dirPath:e,name:n.name,data:a})},t.readAsDataURL(n)}},[r,o,m]),V=(0,g.useRef)(null),[H,se]=(0,g.useState)(null),ce=(0,g.useRef)(null),le=(0,g.useCallback)(()=>{let e=V.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),ue=(0,g.useCallback)(()=>{ce.current&&(ce.current.value=``),ce.current?.click()},[]),[U,de]=(0,g.useState)(null),[fe,W]=(0,g.useState)(null),[pe,G]=(0,g.useState)(``),[K,me]=(0,g.useState)(null),[he,ge]=(0,g.useState)(``),q=(0,g.useCallback)((e,t)=>{xu(e,t).then(e=>{e.ok||e.cancelled||o(`error`,m(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?m(`fileNotFoundShort`):e.error}))})},[o,m]),_e=(0,g.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!ad(e.id)&&(me(null),G(e.label),W(e.id))},[]),ve=(0,g.useCallback)(()=>{if(!fe)return;let e=pe.trim();W(null),e&&r({type:`file_rename`,path:fe,newName:e})},[fe,pe,r]),ye=(0,g.useCallback)(e=>{let t=V.current?.dir??x;W(null),ge(``),me({dir:t,kind:e})},[x]),be=(0,g.useCallback)(()=>{if(!K)return;let e=he.trim();me(null),e&&r({type:`file_create`,dir:K.dir,name:e,kind:K.kind})},[K,he,r]),xe=(e,t,n,r)=>(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:e,placeholder:m(`fileNamePlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>t(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing?n():e.key===`Escape`&&r()},onBlur:r}),J=(0,g.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!ad(e.id)&&window.confirm(m(`fileDeleteConfirm`,{name:e.label}))&&(U?.src===e.id&&de(null),fe===e.id&&W(null),r({type:`file_delete`,path:e.id}))},[r,m,U,fe]),Se=(0,g.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!ad(e.id)&&r({type:`file_copy`,src:e.id,destDir:id(e.id)})},[r]),Ce=(0,g.useCallback)(e=>{let t=V.current?.target;t&&t.kind!==`list`&&!ad(t.id)&&de({src:t.id,cut:e})},[]),Te=(0,g.useCallback)(()=>{if(!U)return;let e=V.current?.dir??x;U.cut?(r({type:`file_copy`,src:U.src,destDir:e,move:!0}),de(null)):r({type:`file_copy`,src:U.src,destDir:e})},[U,r,x]),Ee=(0,g.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[De,ke]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(!De)return;let e=e=>{e.target?.closest(`.root-picker`)||ke(!1)},t=e=>{e.key===`Escape`&&ke(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[De]);let Ae=(0,g.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),je=(0,g.useCallback)(()=>{let e=V.current?.target;if(!e||e.kind!==`dir`)return;let t=z(e.id);t&&!v.includes(t)&&Ae([...v,t])},[v,z,Ae]),Me=(0,g.useCallback)(e=>{B(V.current?.dir??x,Array.from(e.target.files??[]))},[B,x]),Ne=(0,g.useCallback)(e=>{let t=V.current?.target;switch(e.id){case`host:file-compress`:case`host:file-extract`:case`host:file-compress-download`:case`host:file-upload-folder`:{if(!t)break;let n=e.id===`host:file-compress`?`compress`:e.id===`host:file-extract`?`extract`:e.id===`host:file-compress-download`?`download`:`upload`;se({action:n,path:R(t.id),dir:R(n===`upload`?V.current?.dir??x:id(t.id))});break}case`host:file-open-project`:le();break;case`host:file-upload`:ue();break;case`host:file-add-root`:je();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&Je(t.id);break;case`host:file-download`:t?.kind===`file`&&q(t.id,t.label);break;case`host:file-reveal`:t&&r({type:`file_reveal`,path:t.id});break;case`host:file-open-default`:t?.kind===`file`&&r({type:`file_open_default`,path:t.id});break;case`host:file-attach-ref`:t?.kind===`file`&&i(t.id,t.label,`reference`);break;case`host:file-attach-folder`:t?.kind===`dir`&&i(t.id,t.label,`reference`,!0);break;case`host:file-new-file`:ye(`file`);break;case`host:file-new-dir`:ye(`dir`);break;case`host:file-paste`:Te();break;case`host:file-rename`:_e();break;case`host:file-duplicate`:Se();break;case`host:file-cut`:Ce(!0);break;case`host:file-copy`:Ce(!1);break;case`host:file-copy-name`:t&&t.kind!==`list`&&L(t.label,`name:${t.id}`);break;case`host:file-copy-path`:t&&t.kind!==`list`&&L(R(t.id),`path:${t.id}`);break;case`host:file-copy-rel`:t&&t.kind!==`list`&&L(t.id,`rel:${t.id}`);break;case`host:file-refresh`:Ee();break;case`host:file-delete`:J()}},[le,x,ue,je,a,i,L,R,q,ye,Te,_e,Se,Ce,Ee,J]),Pe=(0,g.useCallback)((e,t)=>{let n=t.kind===`dir`?z(t.id):null,r={target:t,dir:t.kind===`dir`?t.id:x,project:n?{path:n,name:t.label}:null},i=t.kind,a=i===`file`,o=i===`dir`,s=i===`list`,c=!s&&ad(t.id),l=!s&&od(t.id),d=x===Ju,f=(u??[]).map(e=>{if(e.source!==`host`)return e;switch(e.id){case`host:file-upload-folder`:return d?{...e,hidden:!0}:e;case`host:file-compress`:case`host:file-compress-download`:return!s&&!c?e:{...e,hidden:!0};case`host:file-extract`:return a&&Ou(t.label)?e:{...e,hidden:!0};case`host:file-upload`:return d?{...e,hidden:!0}:{...e,label:r.dir===x?m(`uploadToCurrentDir`):m(`uploadToFolder`)};case`host:file-open-project`:return n?e:{...e,hidden:!0};case`host:file-add-root`:return n&&n!==_&&!v.includes(n)?e:{...e,hidden:!0};case`host:file-open`:case`host:file-download`:case`host:file-open-default`:case`host:file-attach-ref`:return a?e:{...e,hidden:!0};case`host:file-reveal`:return!d&&t.id!==Ju?e:{...e,hidden:!0};case`host:file-enter`:case`host:file-attach-folder`:return o?e:{...e,hidden:!0};case`host:file-new-file`:case`host:file-new-dir`:return!a&&!d?e:{...e,hidden:!0};case`host:file-paste`:return!a&&!d&&U?e:{...e,hidden:!0};case`host:file-rename`:case`host:file-duplicate`:case`host:file-cut`:case`host:file-copy`:case`host:file-delete`:return!s&&!c?e:{...e,hidden:!0};case`host:file-copy-name`:case`host:file-copy-path`:return s?{...e,hidden:!0}:e;case`host:file-copy-rel`:return!s&&!l?e:{...e,hidden:!0};case`host:file-refresh`:return s?e:{...e,hidden:!0};default:return e}});La(f).length!==0&&(e.preventDefault(),e.stopPropagation(),V.current=r,Ea({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:Ne}))},[u,x,z,m,Ne,_,v,U]),Fe=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),Ie=(0,g.useCallback)(()=>{N.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),N.current?.classList.remove(`drop-root`)},[]),Le=(0,g.useCallback)(e=>{if(Ie(),e==null)return;let t=N.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):N.current?.classList.add(`drop-root`)},[Ie]),ze=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Ve=(0,g.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),He=(0,g.useRef)(0),Ge=(0,g.useRef)(void 0),Y=(0,g.useCallback)((e,t)=>{let n=++He.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||He.current===n&&E(!1)},[r]),Ke=(0,g.useCallback)(e=>{let t=v.filter(t=>t!==e);Ae(t),(x===e||x.startsWith(`${e}/`))&&Y(``)},[v,Ae,x,Y]);(0,g.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,g.useEffect)(()=>{if(_!==Ge.current){let e=Ge.current===void 0;Ge.current=_,e?Y(``,{silent:!0}):S(``);return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&Y(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,Y]),(0,g.useEffect)(()=>{t&&t.path===x&&Y(x,{silent:!0})},[t,x,Y]);let Je=e=>Y(e),Ye=()=>{e?.parent!==null&&e?.parent!==void 0&&Y(e.parent)},Xe=(()=>{if(x===``||x===Ju)return[];let e=x.split(`/`).filter(e=>!!e&&e!==Ju);return x.startsWith(`/`)?[{label:`/`,path:`/`},...e.map((t,n)=>({label:t,path:`/`+e.slice(0,n+1).join(`/`)}))]:e.map((t,n)=>({label:e[n],path:e.slice(0,n+1).join(`/`)}))})(),Ze=[];for(let e of l??[]){if(e.source===`host`||e.hidden||e.kind===`divider`)continue;let t=h.find(t=>t.id===e.source.slice(7));t&&Ze.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let Qe=(l??[]).some(e=>e.id===`host:right-files`&&e.hidden);return(0,X.jsxs)(`aside`,{className:`panel panel-right`,ref:D,children:[s&&c&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:m(`collapsePanel`),onClick:c,children:(0,X.jsx)(ot,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:M?`${k.files} 1 0`:`1 1 0`,minHeight:M?Qu:0},children:(0,X.jsx)(Wu,{storageKey:`rightpanel`,epoch:f??0,send:p??rd,tabs:(e=>{let t=(l??[]).filter(e=>!e.hidden);if(t.length===0)return e;let n=new Map(t.map((e,t)=>[e.id,t])),r=e=>n.get(e===td?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...Qe?[]:[{id:td,label:m(`openFiles`),element:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`panel-crumbs`,children:[(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===``?`active`:``}`,onClick:()=>Y(``),children:m(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===Ju?`active`:``}`,title:m(`computer`),onClick:()=>Y(Ju),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:m(`homeDir`),onClick:()=>Y(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:m(`desktopDir`),onClick:()=>Y(b),children:`🖥️`}),(0,X.jsx)(Du,{text:m(`filesHelp`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${j?`active`:``}`,title:m(j?`filesHideHidden`:`filesShowHidden`),"aria-label":m(j?`filesHideHidden`:`filesShowHidden`),"aria-pressed":j,onClick:()=>ee(e=>!e),children:j?(0,X.jsx)(We,{}):(0,X.jsx)(Ue,{})}),v.length>0&&(0,X.jsxs)(`div`,{className:`root-picker`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`crumb root-picker-trigger`,"aria-haspopup":`menu`,"aria-expanded":De,title:m(`workspaceRoots`),onClick:()=>ke(e=>!e),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:m(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),De&&(0,X.jsxs)(`div`,{className:`root-picker-menu`,role:`menu`,children:[(0,X.jsx)(`div`,{className:`root-picker-row`,children:(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:x===``?`root-picker-item active`:`root-picker-item`,title:_,onClick:()=>{ke(!1),Y(``)},children:[m(`rootDir`),(0,X.jsx)(`span`,{className:`root-picker-path`,children:_})]})}),v.map(e=>(0,X.jsxs)(`div`,{className:`root-picker-row`,children:[(0,X.jsx)(`button`,{type:`button`,role:`menuitem`,className:x===e?`root-picker-item active`:`root-picker-item`,title:e,onClick:()=>{ke(!1),Y(e)},children:(0,X.jsx)(`span`,{className:`root-picker-path`,children:e})}),(0,X.jsx)(`button`,{type:`button`,className:`root-picker-remove`,title:m(`removeWorkspaceRoot`),"aria-label":m(`removeWorkspaceRoot`),onClick:()=>Ke(e),children:(0,X.jsx)(P,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:m(`workspaceRootsHint`)})]})]}),Xe.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(lt,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>Y(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:F,className:`panel-body`,onScroll:e=>{ne.current=e.currentTarget.scrollTop},onContextMenu:e=>Pe(e,{id:x,kind:`list`,label:x===``?m(`rootDir`):x===Ju?m(`computer`):x}),onDragOver:e=>{Fe(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Ve(),Le(ze(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||Ie()},onDrop:e=>{if(Ie(),!Fe(e))return;e.preventDefault(),e.stopPropagation(),Ve();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,m(`foldersNotSupported`));return}B(ze(e.target),t)},onDragEnd:Ie,children:[(0,X.jsx)(`input`,{ref:ce,type:`file`,multiple:!0,hidden:!0,onChange:Me}),H&&(0,X.jsx)(Nu,{request:H,onClose:()=>se(null),onComplete:Ee}),K&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[K.kind===`dir`?(0,X.jsx)(Re,{className:`file-icon`}):(0,X.jsx)(Be,{className:`file-icon`}),xe(he,ge,be,()=>me(null))]}),T&&(0,X.jsx)(`div`,{className:`panel-empty`,children:m(`loading`)}),!T&&e&&e.path===x&&(0,X.jsxs)(X.Fragment,{children:[e.parent!=null&&(0,X.jsxs)(`button`,{type:`button`,className:`file-item dir`,onClick:Ye,children:[(0,X.jsx)(Re,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:`..`})]}),Fu(e.entries,j).map(e=>e.type===`dir`?(0,X.jsxs)(`div`,{className:`file-item dir${U?.cut&&U.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`dir`,label:e.name}),children:[fe===e.path?xe(pe,G,ve,()=>W(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>Je(e.path),children:[(0,X.jsx)(Re,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":m(`linkFolderTip`),"aria-label":m(`linkFolderTip`),onClick:()=>i(e.path,e.name,`reference`,!0),children:(0,X.jsx)(Oe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`name:${e.path}`?` copied`:``}`,"data-tip":m(`copyName`),"aria-label":m(`copyName`),onClick:()=>L(e.name,`name:${e.path}`),children:re===`name:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`path:${e.path}`?` copied`:``}`,"data-tip":m(`copyPath`),"aria-label":m(`copyPath`),onClick:()=>L(R(e.path),`path:${e.path}`),children:re===`path:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(it,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${U?.cut&&U.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`file`,label:e.name}),children:[fe===e.path?xe(pe,G,ve,()=>W(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-name`,title:`${e.path} — ${m(`previewFile`)}`,onClick:()=>a(e.path,e.name),children:[(0,X.jsx)(Be,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name-text`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach download`,"data-tip":m(`downloadFile`),onClick:()=>q(e.path,e.name),children:(0,X.jsx)(qe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":m(`referenceTip`),"aria-label":m(`referenceTip`),onClick:()=>i(e.path,e.name,`reference`),children:(0,X.jsx)(Oe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`name:${e.path}`?` copied`:``}`,"data-tip":m(`copyName`),"aria-label":m(`copyName`),onClick:()=>L(e.name,`name:${e.path}`),children:re===`name:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`path:${e.path}`?` copied`:``}`,"data-tip":m(`copyPath`),"aria-label":m(`copyPath`),onClick:()=>L(R(e.path),`path:${e.path}`),children:re===`path:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(it,{})})]},e.path)),e.truncated&&(0,X.jsx)(`div`,{className:`panel-empty files-truncated`,children:m(`filesTruncated`)})]}),!T&&!e&&(0,X.jsx)(`div`,{className:`panel-empty`,children:m(`noFiles`)})]})]})}],...Ze])})}),M&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:te,onDoubleClick:()=>A({...Zu}),title:m(`dragToResize`)}),M&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:$u},children:n.filter(e=>e.lines.length>0).map(e=>(0,X.jsxs)(`div`,{className:`widget`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`widget-title widget-title-btn`,title:m(`widgetExpand`),onClick:()=>w(e.key),children:[(0,X.jsx)(`span`,{children:e.key}),(0,X.jsx)(we,{})]}),(0,X.jsx)(`pre`,{className:`widget-lines`,children:e.lines.join(`
|
|
328
328
|
`)})]},e.key))}),C&&(()=>{let e=n.find(e=>e.key===C);return e?(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>w(null),children:(0,X.jsxs)(`div`,{className:`widget-expand`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`widget-expand-head`,children:[(0,X.jsx)(`span`,{className:`widget-expand-title`,children:e.key}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:m(`close`),onClick:()=>w(null),children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`pre`,{className:`widget-expand-lines`,children:e.lines.join(`
|
|
329
329
|
`)})]})}):null})()]})});function cd(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.text!=`string`||!t.text.trim()||typeof t.messageId!=`string`||!t.messageId||typeof t.role!=`string`||!t.role?null:{text:t.text,messageId:t.messageId,role:t.role,...typeof t.sessionId==`string`&&t.sessionId?{sessionId:t.sessionId}:{}}}function ld(e){let t=/^<quoted-text>\n([^\n]*)\n<\/quoted-text>$/.exec(e);if(!t)return null;try{return cd(JSON.parse(t[1]))}catch{return null}}function ud(e){let t=e,n=[];for(;;){let e=/(?:^|\n\n)(<quoted-text>\n[^\n]*\n<\/quoted-text>)$/.exec(t),r=e?ld(e[1]):null;if(!e||!r)break;n.unshift(r),t=t.slice(0,e.index)}return{text:t,quotes:n}}var dd=[{id:`builtin.bash.rm-rf`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\brm\\s+((-[a-zA-Z0-9]*[rf][a-zA-Z0-9]*|--recursive|--force)\\s+)+(((\\/)|(~)|(\\.\\.)|(\\*)|(\\.\\/))|[a-zA-Z]:[\\\\/])`,action:`ask`,label:`递归/强制删除 (rm -rf)`,labelEn:`Recursive/force delete (rm -rf)`,reason:`检测到高风险的递归/强制删除大范围路径命令 (rm -rf)`,reasonEn:`Detected high-risk recursive/force deletion of wide paths (rm -rf)`,categoryId:`bash.rm-rf`,builtin:!0},{id:`builtin.bash.win-del`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\b(del|rmdir|rd)\\s+[/\\-][fsq]`,action:`ask`,label:`Windows 强制删除 (del/rmdir/rd)`,labelEn:`Windows force delete (del/rmdir/rd)`,reason:`检测到高风险的 Windows 强制/递归删除目录命令 (del/rmdir/rd /s /q)`,reasonEn:`Detected high-risk Windows force/recursive deletion command (del/rmdir/rd /s /q)`,categoryId:`bash.win-del`,builtin:!0},{id:`builtin.bash.disk`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\b(mkfs|format\\s+[a-zA-Z]:|dd\\s+if=)`,action:`ask`,label:`磁盘格式化/底层写入`,labelEn:`Disk format / raw block write`,reason:`检测到磁盘格式化或底层块写入危险命令 (format/mkfs/dd)`,reasonEn:`Detected dangerous disk formatting or raw block write command (format/mkfs/dd)`,categoryId:`bash.disk`,builtin:!0},{id:`builtin.bash.git-destructive`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\bgit(?:\\.exe)?(?:\\s+(?:-[cC]\\s+\\S+|--[a-zA-Z-]+=\\S+))*\\s+(?:push\\s+(?:[^;&|\\n]*?\\s)?(?:--force|-[a-zA-Z0-9]*f)\\b|push\\s+(?:[^;&|\\n]*?\\s)?(?:\\+\\S+|:[^\\s/]\\S*)|reset\\s+--hard|clean\\s+(?:-[a-zA-Z]+\\s+)*-[a-zA-Z0-9]*f[a-zA-Z0-9]*|branch\\s+-[dD]\\b|checkout\\s+(?:--\\s+)?\\.(?=\\s|$|[;&|])|restore\\s+(?:--(?!staged\\b)\\S+\\s+)*\\.(?=\\s|$|[;&|])|stash\\s+(?:drop|clear)\\b)`,action:`ask`,label:`破坏性 Git 操作`,labelEn:`Destructive git operation`,reason:`检测到不可逆的破坏性 Git 操作 (force push / reset --hard / clean -f / checkout . / stash drop|clear / branch -D)`,reasonEn:`Detected irreversible destructive Git operation (force push / reset --hard / clean -f / checkout . / stash drop|clear / branch -D)`,categoryId:`bash.git-destructive`,builtin:!0},{id:`builtin.bash.chmod`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\bchmod\\s+(-R\\s+)?(777|000)\\b`,action:`ask`,label:`危险权限修改 (chmod)`,labelEn:`Dangerous permission change (chmod)`,reason:`检测到过度开放或全局破坏性的文件权限修改 (chmod 777/000)`,reasonEn:`Detected overly permissive or globally destructive file permission change (chmod 777/000)`,categoryId:`bash.chmod`,builtin:!0},{id:`builtin.bash.system-redirect`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`>\\s*(\\/etc\\/|\\/boot\\/|C:\\\\Windows)`,action:`ask`,label:`写入系统关键目录`,labelEn:`Write into system directories`,reason:`检测到重定向写入系统关键目录的危险操作`,reasonEn:`Detected dangerous redirection writing into critical system directories`,categoryId:`bash.system-redirect`,builtin:!0},{id:`builtin.file.sensitive.env`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`regex`,value:`(^|[\\/\\\\])\\.env(\\.[a-zA-Z0-9_-]+)?$`,action:`ask`,label:`敏感配置 (.env)`,labelEn:`Sensitive config (.env)`,reason:`尝试修改敏感环境变量/密钥配置文件 (.env)`,reasonEn:`Attempting to modify sensitive environment/secret configuration (.env)`,categoryId:`file.sensitive.env`,builtin:!0},{id:`builtin.file.sensitive.ssh`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`regex`,value:`(^|[\\/\\\\])(id_rsa|id_ed25519|authorized_keys|known_hosts)$`,action:`ask`,label:`SSH 密钥/凭据`,labelEn:`SSH keys / credentials`,reason:`尝试修改 SSH 密钥或认证凭据文件`,reasonEn:`Attempting to modify SSH keys or authentication credentials`,categoryId:`file.sensitive.ssh`,builtin:!0},{id:`builtin.file.sensitive.shell`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`regex`,value:`(^|[\\/\\\\])(\\.bashrc|\\.zshrc|\\.profile|\\.bash_profile)$`,action:`ask`,label:`Shell 启动配置`,labelEn:`Shell profile`,reason:`尝试修改用户全局 Shell 启动配置文件`,reasonEn:`Attempting to modify user global Shell profile configuration`,categoryId:`file.sensitive.shell`,builtin:!0},{id:`builtin.file.outside-workspace`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`outside_workspace`,value:``,action:`ask`,label:`工作区外写入`,labelEn:`Write outside workspace`,reason:`尝试在工作区外部写入/修改文件`,reasonEn:`Attempting to write/modify file outside the workspace`,categoryId:`file.outside-workspace`,builtin:!0}].filter(e=>e.enabled&&e.field===`command`&&e.match===`regex`&&e.tools.some(e=>e.trim().toLowerCase()===`bash`));function fd(e){if(e.length<=1)return e;let t=[...e].sort((e,t)=>e.start-t.start),n=[t[0]];for(let e=1;e<t.length;e++){let r=t[e],i=n[n.length-1];r.start<=i.end?(i.end=Math.max(i.end,r.end),r.label&&(!i.label||!i.label.includes(r.label))&&(i.label=i.label?`${i.label} / ${r.label}`:r.label)):n.push(r)}return n}function pd(e,t){if(!e||typeof e!=`string`)return[];if(t&&t.length>0){let n=[];for(let r of t)if(r.field===`command`&&r.length>0){let t=Math.max(0,r.index),i=Math.min(e.length,t+r.length);i>t&&n.push({start:t,end:i,label:r.label})}if(n.length>0)return fd(n)}let n=[];for(let t of dd){let r;try{r=new RegExp(t.value,`gi`)}catch{continue}for(let i of e.matchAll(r)){let e=i.index??0;i[0].length>0&&n.push({start:e,end:e+i[0].length,label:t.label})}}return fd(n)}function md(e,t){let n=pd(e,t);if(n.length===0)return e;let r=[],i=0;return n.forEach((t,n)=>{t.start>i&&r.push(e.slice(i,t.start));let a=e.slice(t.start,t.end);r.push((0,X.jsx)(`mark`,{className:`bash-danger-hit`,title:t.label??`高危命令片段`,children:a},n)),i=t.end}),i<e.length&&r.push(e.slice(i)),(0,X.jsx)(X.Fragment,{children:r})}function hd({quote:e,onRemove:t,forceOpen:n=!1}){let r=Z(),[i,a]=(0,g.useState)(!1),o=e.role===`user`?`role.user`:e.role===`assistant`?`role.assistant`:e.role===`toolResult`?`role.tool`:e.role===`bashExecution`?`role.bash`:`attachment`;return(0,X.jsxs)(`div`,{className:`quote-card`,children:[(0,X.jsxs)(`details`,{open:i||n,onToggle:e=>a(e.currentTarget.open),children:[(0,X.jsxs)(`summary`,{title:r(`quoteSource`,{id:e.messageId}),children:[(0,X.jsxs)(`span`,{className:`quote-source`,children:[`↪ `,r(`quoteText`),` · `,r(o)]}),(0,X.jsx)(`span`,{className:`quote-preview`,children:e.text.replace(/\s+/g,` `).slice(0,80)})]}),(0,X.jsx)(`pre`,{className:`quote-content`,children:e.text})]}),t&&(0,X.jsx)(`button`,{type:`button`,className:`quote-remove`,"aria-label":r(`removeQuote`),title:r(`removeQuote`),onClick:t,children:`×`})]})}var gd=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],_d={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...gd,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...gd],h2:[[`className`,`sr-only`]],img:[...gd,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...gd,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...gd],table:[...gd],ul:[...gd,[`className`,`contains-task-list`]],"*":`abbr.accept.acceptCharset.accessKey.action.align.alt.axis.border.cellPadding.cellSpacing.char.charOff.charSet.checked.clear.colSpan.color.cols.compact.coords.dateTime.dir.encType.frame.hSpace.headers.height.hrefLang.htmlFor.id.isMap.itemProp.label.lang.maxLength.media.method.multiple.name.noHref.noShade.noWrap.open.prompt.readOnly.rev.rowSpan.rows.rules.scope.selected.shape.size.span.start.summary.tabIndex.title.useMap.vAlign.value.width`.split(`.`)},clobber:[`ariaDescribedBy`,`ariaLabelledBy`,`id`,`name`],clobberPrefix:`user-content-`,protocols:{cite:[`http`,`https`],href:[`http`,`https`,`irc`,`ircs`,`mailto`,`xmpp`],longDesc:[`http`,`https`],src:[`http`,`https`]},required:{input:{disabled:!0,type:`checkbox`}},strip:[`script`],tagNames:`a.b.blockquote.br.code.dd.del.details.div.dl.dt.em.h1.h2.h3.h4.h5.h6.hr.i.img.input.ins.kbd.li.ol.p.picture.pre.q.rp.rt.ruby.s.samp.section.source.span.strike.strong.sub.summary.sup.table.tbody.td.tfoot.th.thead.tr.tt.ul.var`.split(`.`)},vd={}.hasOwnProperty;function yd(e,t){let n={type:`root`,children:[]},r=bd({schema:t?{..._d,...t}:_d,stack:[]},e);return r&&(Array.isArray(r)?r.length===1?n=r[0]:n.children=r:n=r),n}function bd(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return xd(e,n);case`doctype`:return Sd(e,n);case`element`:return Cd(e,n);case`root`:return wd(e,n);case`text`:return Td(e,n)}}}function xd(e,t){if(e.schema.allowComments){let e=typeof t.value==`string`?t.value:``,n=e.indexOf(`-->`),r={type:`comment`,value:n<0?e:e.slice(0,n)};return Md(r,t),r}}function Sd(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return Md(e,t),e}}function Cd(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=Ed(e,t.children),i=Dd(e,t.properties);e.stack.pop();let a=!1;if(n&&n!==`*`&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(a=!0,e.schema.ancestors&&vd.call(e.schema.ancestors,n))){let t=e.schema.ancestors[n],r=-1;for(a=!1;++r<t.length;)e.stack.includes(t[r])&&(a=!0)}if(!a)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;let o={type:`element`,tagName:n,properties:i,children:r};return Md(o,t),o}function wd(e,t){let n={type:`root`,children:Ed(e,t.children)};return Md(n,t),n}function Td(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return Md(n,t),n}function Ed(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=bd(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function Dd(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,a=r&&vd.call(r,n)?r[n]:void 0,o=r&&vd.call(r,`*`)?r[`*`]:void 0,s=t&&typeof t==`object`?t:{},c={},l;for(l in s)if(vd.call(s,l)){let t=s[l],n=Od(e,Nd(a,l),l,t);n??=Od(e,Nd(o,l),l,t),n!=null&&(c[l]=n)}if(i&&vd.call(i,n)){let e=i[n];for(l in e)vd.call(e,l)&&!vd.call(c,l)&&(c[l]=e[l])}return c}function Od(e,t,n,r){return t?Array.isArray(r)?kd(e,t,n,r):Ad(e,t,n,r):void 0}function kd(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=Ad(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function Ad(e,t,n,r){if((typeof r==`boolean`||typeof r==`number`||typeof r==`string`)&&jd(e,n,r)){if(typeof t==`object`&&t.length>1){let e=!1,n=0;for(;++n<t.length;){let i=t[n];if(i&&typeof i==`object`&&`flags`in i){if(i.test(String(r))){e=!0;break}}else if(i===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function jd(e,t,n){let r=e.schema.protocols&&vd.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;let i=String(n),a=i.indexOf(`:`),o=i.indexOf(`?`),s=i.indexOf(`#`),c=i.indexOf(`/`);if(a<0||c>-1&&a>c||o>-1&&a>o||s>-1&&a>s)return!0;let l=-1;for(;++l<r.length;){let e=r[l];if(a===e.length&&i.slice(0,e.length)===e)return!0}return!1}function Md(e,t){let n=c(t);t.data&&(e.data=o(t.data)),n&&(e.position=n)}function Nd(e,t){let n,r=-1;if(e)for(;++r<e.length;){let i=e[r],a=typeof i==`string`?i:i[0];if(a===t)return i;a===`data*`&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()===`data`)return n}function Pd(e){return function(t){return yd(t,e)}}var Fd=(0,g.memo)(function({text:e}){let t=Z(),{copied:n,copy:r}=qu({duration:1200});return e?(0,X.jsx)(`button`,{type:`button`,className:`copy-btn`,title:t(`copy`),onClick:()=>void r(e),children:n?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}):null});function Id(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
330
330
|
`).map(e=>e===``?[]:[e])}if(Array.isArray(e)){let n=[];for(let r of e){let e=t(r);if(n.length===0)n=e;else{let t=e[0]??[];n[n.length-1].push(...t),n.push(...e.slice(1))}}return n}if(e&&typeof e==`object`&&`props`in e){let n=e,r=n.props?.children,i={...n.props,children:void 0},a=r==null?[]:t(r);return a.length===0?[[(0,g.createElement)(n.type,i)]]:a.map(e=>[(0,g.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function Ld(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Ld).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Ld(t?.children)}return``}function Rd(e){let t=Array.isArray(e)?e[0]:e;return!t||typeof t!=`object`||!(`props`in t)?null:t}function zd(e){let t=Rd(e)?.props?.className;if(typeof t!=`string`)return null;let n=t.match(/(?:^|\s)language-([A-Za-z0-9_+-]+)(?:\s|$)/);return n?n[1]:null}var Bd=`pi-web-ui:plugin-data`,Vd=new Map,Hd=new Map,Ud=new Set,Wd=-1,Gd=0,Kd=new Set;function qd(){Gd++;for(let e of Kd)e()}function Jd(e){return Kd.add(e),()=>{Kd.delete(e)}}function Yd(){return Gd}var Xd=null;function Zd(e){Xd=e}function Qd(e,t){t!==Wd&&(Wd=t,Hd.clear(),Ud.clear());let n=new Map;for(let t of e)if(!t.error&&t.renderers)for(let e of t.renderers)n.has(e)||n.set(e,t.id);let r=n.size!==Vd.size;if(!r){for(let[e,t]of n)if(Vd.get(e)!==t){r=!0;break}}if(r){for(let e of Hd.keys())n.has(e)||Hd.delete(e);for(let e of Ud)n.has(e)||Ud.delete(e);Vd=n,qd()}}async function $d(e,t){let n=Vd.get(e);if(!n)return null;let r=Hd.get(e);if(!r&&!Ud.has(e))try{let t=(await Pc(()=>import(fn(`/plugins/${encodeURIComponent(n)}/client/entry.mjs?e=${Wd}`)),[])).default?.renderers?.[e];typeof t==`function`?(r={pluginId:n,renderer:t},Hd.set(e,r)):(Ud.add(e),console.error(`[plugin:${n}] entry.mjs 未提供 renderers["${e}"]`))}catch(t){Ud.add(e),console.error(`[plugin:${n}] renderer 加载失败(${e}):`,t)}if(!r)return null;let i={pluginId:r.pluginId,send:e=>{Xd?.({type:`plugin_message`,pluginId:r.pluginId,payload:e})},onData:e=>{let t=t=>{let n=t.detail;n.pluginId===r.pluginId&&e(n.payload)};return window.addEventListener(Bd,t),()=>window.removeEventListener(Bd,t)}};try{let e=await r.renderer(t,i);return e instanceof HTMLElement?e:null}catch(t){return console.error(`[plugin:${r.pluginId}] renderer("${e}") 执行失败:`,t),null}}function ef(e){return Vd.has(e)}var tf=new Map,nf=new Map,rf=new Set,af=-1;function of(e,t){t!==af&&(af=t,nf.clear(),rf.clear());let n=new Map;for(let t of e){if(t.error)continue;let e=t.messageWidgets;if(Array.isArray(e))for(let r of e)typeof r==`string`&&r&&(n.has(r)||n.set(r,t.id))}for(let e of Array.from(tf.keys()))n.has(e)||tf.delete(e);for(let[e,t]of n)tf.set(e,t);for(let e of nf.keys())n.has(e)||nf.delete(e);for(let e of rf)n.has(e)||rf.delete(e)}function sf(e){return tf.has(e)}async function cf(e){let t=tf.get(e);if(!t)return null;let n=nf.get(e);if(!n&&!rf.has(e))try{let r=(await Pc(()=>import(fn(`/plugins/${encodeURIComponent(t)}/client/entry.mjs?e=${af}`)),[])).default?.messageWidgets?.[e];typeof r==`function`?(n={pluginId:t,renderer:r},nf.set(e,n)):(rf.add(e),console.error(`[plugin:${t}] entry.mjs 未提供 messageWidgets["${e}"]`))}catch(n){rf.add(e),console.error(`[plugin:${t}] messageWidget 加载失败(${e}):`,n)}return n?.renderer??null}var lf=`pi-web-ui:theme`,uf=`dark`,df=`theme-stylesheet`,ff=`pi-web-ui:theme-change`;function pf(){try{let e=localStorage.getItem(lf);if(e&&e!==uf)return e}catch{}return null}function mf(e){try{e?localStorage.setItem(lf,e):localStorage.removeItem(lf)}catch{}}function hf(e){let t=document.getElementById(df);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(ff));return}t||(t=document.createElement(`link`),t.id=df,t.rel=`stylesheet`,document.head.appendChild(t)),t.href=fn(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(ff))}async function gf(){try{let e=await fetch(gn(fn(`/api/themes`)));if(!e.ok)return[];let t=await e.json();return Array.isArray(t.themes)?t.themes:[]}catch{return[]}}function _f(){let[e,t]=(0,g.useState)([]),[n,r]=(0,g.useState)(()=>pf());(0,g.useEffect)(()=>{let e=!1;return gf().then(n=>{e||t(n)}),()=>{e=!0}},[]);let i=(0,g.useCallback)(()=>{gf().then(t)},[]);return(0,g.useEffect)(()=>{hf(n),mf(n)},[n]),{themes:e,theme:n,switchTheme:e=>r(e===uf?null:e),reloadThemes:i}}function vf(){let e=getComputedStyle(document.documentElement),t=(t,n)=>e.getPropertyValue(t).trim()||n;return{background:t(`--term-bg`,`#0b0d12`),foreground:t(`--term-fg`,`#e6e8ef`),cursor:t(`--term-cursor`,`#8b5cf6`),cursorAccent:t(`--term-cursor-accent`,`#0b0d12`),selectionBackground:t(`--term-selection`,`rgba(139, 92, 246, 0.35)`),black:t(`--term-black`,`#1a1d26`),red:t(`--term-red`,`#f87171`),green:t(`--term-green`,`#34d399`),yellow:t(`--term-yellow`,`#fbbf24`),blue:t(`--term-blue`,`#60a5fa`),magenta:t(`--term-magenta`,`#c084fc`),cyan:t(`--term-cyan`,`#22d3ee`),white:t(`--term-white`,`#e6e8ef`),brightBlack:t(`--term-bright-black`,`#6b7284`),brightRed:t(`--term-bright-red`,`#f87171`),brightGreen:t(`--term-bright-green`,`#34d399`),brightYellow:t(`--term-bright-yellow`,`#fbbf24`),brightBlue:t(`--term-bright-blue`,`#60a5fa`),brightMagenta:t(`--term-bright-magenta`,`#c084fc`),brightCyan:t(`--term-bright-cyan`,`#22d3ee`),brightWhite:t(`--term-bright-white`,`#ffffff`)}}function yf({lang:e,code:t}){let n=(0,g.useRef)(null),r=(0,g.useRef)(null),i=(0,g.useRef)(0),a=(0,g.useRef)(new WeakMap),[o,s]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let e=()=>{let e=++i.current,t=r.current;t&&(t.dispatchEvent(new CustomEvent(ff)),a.current.set(t,e))};return window.addEventListener(ff,e),()=>window.removeEventListener(ff,e)},[]),(0,g.useEffect)(()=>{let n=!1,r=i.current;return s(null),$d(e,t).then(e=>{n||(e&&a.current.set(e,r),s(e))}),()=>{n=!0}},[e,t]),(0,g.useEffect)(()=>{r.current=o;let e=n.current;return e&&(e.replaceChildren(),o&&(e.appendChild(o),(a.current.get(o)??i.current)<i.current&&(o.dispatchEvent(new CustomEvent(ff)),a.current.set(o,i.current)))),()=>{r.current===o&&(r.current=null)}},[o]),o?(0,X.jsx)(`div`,{className:`plugin-fence`,ref:n}):(0,X.jsxs)(`div`,{className:`codeblock`,children:[(0,X.jsx)(Fd,{text:t}),(0,X.jsx)(`pre`,{children:(0,X.jsx)(`code`,{children:t})})]})}var bf=null,xf=null;function Sf(e){bf=e?.open??null,xf=e?.isOpen??null}function Cf(){return xf?xf():!1}function wf(e){return!bf||!e?.path?!1:(bf(e),!0)}var Tf=[u,s],Ef=[u,a,s],Df=[[l,{strict:!1,throwOnError:!1}],[d,{detect:!0,ignoreMissing:!0}]];function Of(e){if(!e||!e.includes(`@`))return e;let t=e.split(RegExp("(```[\\s\\S]*?```|`[^`\\r\\n]+`)",`g`)),n=/(^|[\s((“"'[])@((?:[\w.-]+\/)*[\w.-]+\.(?:[a-zA-Z0-9]{1,10}))(?=[)\s\],.;:!?,。!?’”"']|$)/g;for(let e=0;e<t.length;e+=2)t[e]&&(t[e]=t[e].replace(n,(e,t,n)=>t+`[@`+n+`](pi-file://`+encodeURIComponent(n)+`)`));return t.join(``)}function kf({text:e,rawHtml:t=!1,hardBreaks:n=!1}){let r=t?[p,Pd,...Df]:Df,i=(0,g.useMemo)(()=>Of(e),[e]);return(0,X.jsx)(f,{remarkPlugins:n?Ef:Tf,rehypePlugins:r,components:{pre:Mf,a:jf},children:i})}var Af=(0,g.memo)(function({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,X.jsx)(`div`,{className:`md`,children:(0,X.jsx)(kf,{text:e,rawHtml:t,hardBreaks:n})})});function jf({node:e,href:t,children:n,...r}){let i=String(t??``);if(i.startsWith(`pi-file://`)){let e=i.slice(10),t=e;try{t=decodeURIComponent(e)}catch{t=e}let r=typeof n==`string`&&n.trim()?n.trim():t.split(`/`).pop()??t;return(0,X.jsxs)(`button`,{type:`button`,className:`file-pill`,title:`点击预览文件: `+t,onClick:e=>{e.preventDefault(),e.stopPropagation(),wf({path:t,name:r.replace(/^@/,``)})},children:[(0,X.jsx)(`span`,{className:`file-pill-icon`,"aria-hidden":`true`,children:`📄`}),(0,X.jsx)(`span`,{className:`file-pill-name`,children:r})]})}return/^(https?:|mailto:|tel:)/i.test(i)?(0,X.jsx)(`a`,{...r,href:t,target:`_blank`,rel:`noreferrer noopener`,children:n}):(0,X.jsx)(`a`,{href:t,...r,children:n})}function Mf({children:e,...t}){(0,g.useSyncExternalStore)(Jd,Yd,Yd);let n=zd(e);return n&&ef(n)?(0,X.jsx)(yf,{lang:n,code:Ld(e)}):(0,X.jsx)(Nf,{children:e,...t})}function Nf({children:e,...t}){let n=Id(e&&typeof e==`object`&&`props`in e?e.props?.children:e),r=n.length>1,i=r?`${String(n.length).length+1}ch`:void 0;return(0,X.jsxs)(`div`,{className:`codeblock`,children:[(0,X.jsx)(Fd,{text:Pf(e)}),(0,X.jsx)(`pre`,{...t,children:n.map((e,t)=>(0,X.jsxs)(`div`,{className:`code-line`,children:[r&&(0,X.jsx)(`span`,{className:`code-num`,style:i?{width:i}:void 0,children:t+1}),(0,X.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function Pf(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Pf).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Pf(t?.children)}return``}function Ff({type:e,code:t,children:n}){let r=(0,g.useRef)(null),[i,a]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!1;if(a(null),sf(e))return cf(e).then(async r=>{if(!n&&r)try{let i=await r(t,{pluginId:tf.get(e)??e,send:()=>void 0,onData:()=>()=>void 0});!n&&i instanceof HTMLElement&&a(i)}catch(t){console.error(`[plugin-widget:${e}] 渲染失败:`,t)}}),()=>{n=!0}},[e,t]),(0,g.useEffect)(()=>{let e=r.current;e&&(e.replaceChildren(),i&&e.appendChild(i))},[i]),i?(0,X.jsx)(`div`,{className:`plugin-widget`,ref:r}):(0,X.jsx)(X.Fragment,{children:n})}var If=/^\s{0,3}(`{3,}|~{3,})/,Lf=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Rf(e){return e.trim()===``}function zf(e){let t=If.exec(e);return t?t[1]:null}function Bf(e){let t=e.split(`
|
|
@@ -677,4 +677,4 @@ Systematic steps for investigating and resolving software defects:
|
|
|
677
677
|
`)})]}):(0,X.jsx)(`div`,{className:`set-catalog-job error`,children:(0,X.jsxs)(`span`,{children:[`✗ `,ca.error||u(`pluginJobFailed`)]})}))]}),Yn&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogSource`),value:zn,onChange:e=>Bn(e.target.value)}),ji(sa),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogId`),value:Vn,onChange:e=>Hn(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogName`),value:Un,onChange:e=>Wn(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogIcon`),value:qn,onChange:e=>Jn(e.target.value)}),(0,X.jsx)(`textarea`,{className:`set-input`,rows:2,placeholder:u(`pluginCatalogDesc`),value:Gn,onChange:e=>Kn(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!zn.trim(),onClick:ta,children:u(`pluginCatalogAddSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Xn(!1),children:u(`cancel`)})]})]}),e.pluginCatalog.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noPluginCatalog`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.pluginCatalog.map(t=>{let n=mi.has(t.id),r=e.pluginUpdates?.[t.id],i=n&&r?.updatable===!0,a=!!(Ai(t.id)&&Ai(t.id)?.phase!==`done`),o=d!==`zh`&&t.nameEn?t.nameEn:t.name,s=d!==`zh`&&t.descriptionEn?t.descriptionEn:t.description;return(0,X.jsxs)(`div`,{className:`set-catalog-row`,children:[(0,X.jsxs)(`div`,{className:`set-catalog-main`,children:[(0,X.jsxs)(`div`,{className:`set-catalog-title`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(hi,{icon:t.icon,iconSvg:t.iconSvg}),` `,o]}),n&&(0,X.jsx)(`span`,{className:`set-catalog-installed`,children:u(`pluginInstalled`)}),!t.builtin&&(0,X.jsx)(`span`,{className:`set-catalog-custom`,children:u(`pluginCatalogCustom`)}),i&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:r?.latestVersion?`${r?.version??``} → v${r.latestVersion}`:r?.remoteSha??``,children:[u(`pluginUpdateAvailableBadge`),r?.latestVersion?` v${r.latestVersion}`:``]})]}),s&&(0,X.jsx)(`div`,{className:`set-catalog-desc`,children:s}),(0,X.jsx)(`div`,{className:`set-catalog-source`,children:t.source}),Mi(t.id)]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[jx(t)&&(0,X.jsxs)(`a`,{href:jx(t),target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialLinkHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialLink`)]}),n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${i?` accent`:``}`,disabled:a,title:i&&r?.latestVersion?u(`pluginUpdateAvailableDetail`,{version:`v${r.latestVersion}`}):u(`pluginUpdateHint`),onClick:()=>Qi(t.id,t.source),children:[(0,X.jsx)(K,{className:a?`set-job-spin`:``}),u(a?`pluginJobRunning`:`pluginUpdate`)]}),Dn===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:a,title:u(`pluginUninstallHint`),onClick:()=>Zi(t.id),children:u(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:a,title:u(`pluginUninstallHint`),onClick:()=>On(t.id),children:[(0,X.jsx)(L,{}),u(`uninstallExt`)]})]}):(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginInstallHint`),disabled:a,onClick:()=>$i(t),children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{className:`set-job-spin`}),u(`pluginJobRunning`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qe,{}),u(`pluginInstall`)]})}),!t.builtin&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginCatalogRemoveHint`),onClick:()=>ea(t.id),children:(0,X.jsx)(P,{})})]})]},t.id)})})]}),S===`plugins`&&w===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ht,{className:`set-section-icon`}),u(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(0,X.jsxs)(`a`,{href:`https://github.com/xing-shuyin/pi-web-ui-plugins`,target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialMarketHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialMarket`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginCheckUpdatesHint`),disabled:e.checkingPluginUpdates,onClick:()=>$({type:`check_plugin_updates`}),children:[(0,X.jsx)(K,{className:e.checkingPluginUpdates?`spin`:``}),e.checkingPluginUpdates?u(`checkingUpdate`):u(`pluginCheckUpdates`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginRescanHint`),onClick:()=>$({type:`plugins_reload`}),children:[(0,X.jsx)(K,{}),u(`pluginRescan`)]})]}),e.plugins.length>0&&(0,X.jsx)(Mx,{plugins:e.plugins,disabledIds:pi}),e.plugins.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noUiPlugins`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.plugins.map(t=>{let n=e.pluginUpdates?.[t.id],r=n?.updatable===!0,i=!!(Ai(t.id)&&Ai(t.id)?.phase!==`done`);return(0,X.jsxs)(g.Fragment,{children:[(0,X.jsx)(Dx,{title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ax,{phase:fx(t,pi.has(t.id)),label:f(kx(fx(t,pi.has(t.id))))}),(0,X.jsx)(hi,{icon:t.icon,iconSvg:t.iconSvg}),` `,t.name,r&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:n?.latestVersion?`v${t.version??`0.0.0`} → v${n.latestVersion}`:n?.remoteSha??``,children:[u(`pluginUpdateAvailableBadge`),n?.latestVersion?` v${n.latestVersion}`:``]})]}),subtitle:(t.error?`${t.id} · ${t.error}`:t.source?`${t.id} · ${t.source}`:`${t.id} · ${u(`uiPluginNoSource`)}`)+(t.permissions?.length?` · ${u(`uiPluginPerms`)}: ${t.permissions.join(`, `)}`:``),enabled:!pi.has(t.id)&&!t.error,onToggle:()=>!t.error&&gi(t),action:(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(()=>{let n=jx(e.pluginCatalog.find(e=>e.id===t.id))||jx(t);return n?(0,X.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialLinkHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialLink`)]}):null})(),t.source&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${r?` accent`:``}`,disabled:i,title:r&&n?.latestVersion?u(`pluginUpdateAvailableDetail`,{version:`v${n.latestVersion}`}):u(`pluginUpdateHint`),onClick:()=>Qi(t.id,t.source),children:[(0,X.jsx)(K,{className:i?`set-job-spin`:``}),u(i?`pluginJobRunning`:`pluginUpdate`)]}),Dn===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:i,title:u(`pluginUninstallHint`),onClick:()=>Zi(t.id),children:u(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:i,title:u(`pluginUninstallHint`),onClick:()=>On(t.id),children:[(0,X.jsx)(L,{}),u(`uninstallExt`)]})]})},t.id),Mi(t.id),t.agentTools&&t.agentTools.length>0&&!x&&(0,X.jsxs)(`div`,{className:`set-row`,title:u(`pluginToolOffHint`),children:[(0,X.jsxs)(`span`,{className:`set-ui-source`,children:[u(`pluginToolsSection`),` (`,t.agentTools.length,`)`,t.agentTools.some(e=>xi.has(e.name))?` · ${u(`settingsDisabled`)}`:``]}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>C(`tools`),children:[u(`settingsTools`),` →`]})})]}),(0,X.jsxs)(`div`,{className:`set-row set-log-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>{jn===t.id?Mn(null):(Mn(t.id),$(ol(t.id)))},children:[(0,X.jsx)(Ve,{}),u(`pluginLogTitle`),` (`,pl(t.id).length,`) ·`,` `,jn===t.id?u(`pluginLogHide`):u(`pluginLogShow`)]}),jn===t.id&&(0,X.jsx)(Fx,{pluginId:t.id})]}),t.diagnostics&&t.diagnostics.length>0&&(0,X.jsxs)(`div`,{className:`set-row set-diag-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>An(kn===t.id?null:t.id),children:[(0,X.jsx)(wt,{}),u(`pluginDiagTitle`),` (`,t.diagnostics.length,`) ·`,` `,kn===t.id?u(`pluginDiagHide`):u(`pluginDiagShow`)]}),kn===t.id&&(0,X.jsx)(`ul`,{className:`set-diag-list`,children:t.diagnostics.map((e,n)=>(0,X.jsx)(`li`,{children:e},`${t.id}-${n}`))})]}),t.wantsDom&&(0,X.jsxs)(`div`,{className:`set-row`,title:u(`pluginDomDesc`),children:[(0,X.jsx)(`span`,{className:`set-ui-source`,children:t.domGranted?u(`pluginDomGranted`):u(`pluginDomNeed`)}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall${t.domGranted?``:` confirm`}`,title:u(`pluginDomDesc`),onClick:()=>$({type:`plugin_dom_consent`,pluginId:t.id,granted:!t.domGranted}),children:t.domGranted?u(`pluginDomRevoke`):u(`pluginDomGrant`)})})]}),t.settingsSchema&&t.settingsSchema.length>0&&(0,X.jsxs)(`div`,{className:`set-row set-settings-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>In(e=>({...e,[t.id]:!e[t.id]})),children:[(0,X.jsx)(H,{}),u(`pluginSettingsTitle`),` (`,t.settingsSchema.length,`) ·`,` `,Pn[t.id]?u(`pluginSettingsHide`):u(`pluginSettingsShow`)]}),Pn[t.id]&&(0,X.jsx)(Vy,{plugin:t,models:_?.subagentModels??[]})]})]},t.id)})})]}),S===`plugins`&&x&&w===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ht,{className:`set-section-icon`}),u(`dshPatches`),(0,X.jsx)(Du,{text:u(`dshPatchesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPatches?.files.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`dshPatchesRescanHint`),onClick:()=>$({type:`dsh_patches_rescan`}),children:[(0,X.jsx)(K,{}),u(`dshPatchesRescan`)]})]}),(e.dshPatches?.files.length??0)===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`dshPatchesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:e.dshPatches.files.map(e=>(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsx)(`div`,{className:`set-row-name`,children:e.name}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[gm(e.size),` · `,new Date(e.mtimeMs).toLocaleString()]})]})},e.name))}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[u(`dshPatchesPath`),` `,e.dshPatches?.patchDir??``]})]}),S===`review`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(N,{className:`set-section-icon`}),u(`settingsReview`),(0,X.jsx)(Du,{text:u(`settingsReviewDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.reviewSkills.length})]}),(0,X.jsx)(Dx,{title:u(`goalModeEnabled`),tip:`${u(`goalModeEnabledDesc`)}\n${u(`goalModeOffHint`)}`,enabled:_.goalModeEnabled,onToggle:()=>Q({goalModeEnabled:!_.goalModeEnabled})}),(0,X.jsx)(Dx,{title:u(`delegateMode`),tip:`${u(`delegateModeDesc`)}\n${u(`delegateModeOffHint`)}`,enabled:e.state?.delegateMode===!0,onToggle:()=>$({type:`set_delegate_mode`,enabled:e.state?.delegateMode!==!0})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:5,placeholder:u(`reviewPromptPlaceholder`),value:mt,onFocus:()=>_t.current=!0,onBlur:()=>{_t.current=!1,Q({reviewPrompt:mt})},onChange:e=>gt(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`settingsReviewSkills`),x&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(Du,{text:u(`dshReviewPromptNote`)})]})]}),_.reviewSkills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:_.reviewSkills.map(e=>(0,X.jsx)(Dx,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>la(e)},`review-${e.name}`))})]}),S===`vision`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ue,{className:`set-section-icon`}),u(`settingsVisionBridge`)]}),(0,X.jsx)(Dx,{title:u(`visionBridgeEnabled`),tip:`${u(`settingsVisionBridgeDesc`)}\n${u(`visionBridgeOffHint`)}`,enabled:_.visionBridgeEnabled,onToggle:()=>Q({visionBridgeEnabled:!_.visionBridgeEnabled})}),_.visionBridgeEnabled&&(0,X.jsx)(Nx,{label:u(`visionBridgeModel`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:_.visionBridgeModel??``,onChange:e=>Q({visionBridgeModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:u(`visionBridgeAuto`)}),_.visionModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),_.visionBridgeEnabled&&(0,X.jsx)(Px,{mode:Xe,onModeChange:Qe,draft:Je,onDraftChange:Ye,defaultPrompt:_.visionBridgeDefaultPrompt,placeholder:u(`visionBridgePromptPlaceholder`),rows:4,onCommit:(e,t)=>{Q({visionBridgePromptMode:e,visionBridgePrompt:t})},hint:_.visionModels.length===0?u(`visionBridgeNoModels`):u(`visionBridgeCurrent`,{model:_.visionBridgeModel??u(`visionBridgeAuto`)}),focusRef:$e})]}),S===`presets`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(H,{className:`set-section-icon`}),u(`settingsPresets`),(0,X.jsx)(Du,{text:u(`dshPresetUserNote`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-preset-share-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-preset-share-btn primary`,title:u(`presetShareShareBtn`),onClick:()=>xt({name:_.presets[0]?.name??``,tab:`export`}),children:[(0,X.jsx)(le,{}),u(`presetShareShareBtn`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-preset-share-btn`,title:u(`presetShareImportBtn`),onClick:()=>xt({name:``,tab:`import`}),children:[(0,X.jsx)(re,{}),u(`presetShareImportBtn`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-preset-share-btn`,title:u(`presetShareBrowseBtn`),onClick:()=>xt({name:``,tab:`browse`}),children:[(0,X.jsx)(Fe,{}),u(`presetShareBrowseBtn`)]})]}),ti&&(0,X.jsxs)(`div`,{className:`set-preset-config`,children:[e.dshPresets&&e.dshPresets.presets.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`dshDefaultPreset`),(0,X.jsx)(Du,{text:u(`dshDefaultPresetDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPresets.defaultPreset,onChange:e=>$({type:`dsh_preset_default`,preset:e.target.value}),children:Q_(e.dshPresets.presets).map(e=>(0,X.jsxs)(`option`,{value:e.id,disabled:!!e.broken,children:[Z_(e,d,u).name,e.trust===`user`?` · ${u(`dshPresetUser`)}`:``,e.broken?` · ${u(`dshPresetBroken`)}`:``]},e.id))})]}),$r&&(0,X.jsx)(`p`,{className:`set-preset-config-desc`,children:$r})]}),e.dshPermission&&e.dshPermission.options.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`dshPermDefault`),(0,X.jsx)(Du,{text:u(`dshPermDefaultDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:tv.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:u(nv(e))},e))})]}),(0,X.jsx)(`p`,{className:`set-preset-config-desc`,children:u(rv(e.dshPermission.defaultPreset))})]})]}),ei&&(0,X.jsx)(`p`,{className:`set-hint`,children:u(`dshPresetUserNote`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`presetNamePlaceholder`),value:vt,onChange:e=>yt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&vt.trim()&&($({type:`save_preset`,name:vt.trim()}),yt(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!vt.trim(),onClick:()=>{$({type:`save_preset`,name:vt.trim()}),yt(``)},children:[(0,X.jsx)(me,{}),` `,u(`saveAsPreset`)]})]}),_.presets.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noPresets`)}):(0,X.jsx)(`div`,{className:`set-list`,children:_.presets.map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsx)(`div`,{className:`set-row-name`,children:e.name}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[e.promptMode===`replace`?u(`promptModeReplace`):u(`promptModeAppend`),e.disabledSkills.length>0&&` · ${u(`settingsSkills`)} ${e.disabledSkills.length}`,e.disabledExtensions.length>0&&` · ${u(`settingsExtensions`)} ${e.disabledExtensions.length}`]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`presetShare`),onClick:()=>xt({name:e.name,tab:`export`}),children:(0,X.jsx)(le,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`apply_preset`,name:e.name}),children:u(`applyPreset`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`deletePreset`),onClick:()=>$({type:`delete_preset`,name:e.name}),children:(0,X.jsx)(L,{})})]})]},e.name))})]}),S===`mcp`&&(0,X.jsx)(Xy,{settings:_,chat:e}),S===`subagent-templates`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(F,{className:`set-section-icon`}),u(`settingsSubagentTemplates`),(0,X.jsx)(Du,{text:u(`settingsSubagentTemplatesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.subagentTemplates.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:u(`subagentTemplateNew`),onClick:()=>{Tt({name:``,description:``,promptMode:`replace`,systemPrompt:``,enabledSkills:[],enabledExtensions:[],model:``,thinkingLevel:``,enabled:!0}),Dt(!0)},children:[(0,X.jsx)(me,{}),` `,u(`subagentTemplateNew`)]})]}),(0,X.jsx)(Nx,{label:u(`subagentDefaultModelLabel`),tip:u(`subagentDefaultModelHint`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:_.subagentDefaultModel??``,onChange:e=>Q({subagentDefaultModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:u(`subagentFollowMain`)}),_.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),_.subagentModels.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:u(`subagentNoModels`)}),Ct&&(0,X.jsx)(`div`,{className:`modal-backdrop tpl-modal-backdrop`,onClick:()=>Tt(null),children:(0,X.jsxs)(`div`,{className:`modal tpl-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":u(`close`),onClick:()=>Tt(null),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(F,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:Et?u(`subagentTemplateNew`):`${u(`subagentTemplateEdit`)} · ${Ct.name}`})]}),(0,X.jsxs)(`div`,{className:`modal-body`,children:[(0,X.jsxs)(`div`,{className:`tpl-fields`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`tplNamePlaceholder`),value:Ct.name,onChange:e=>Tt({...Ct,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`tplDescriptionPlaceholder`),value:Ct.description,onChange:e=>Tt({...Ct,description:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`tplDescriptionEnPlaceholder`),value:Ct.descriptionEn??``,onChange:e=>Tt({...Ct,descriptionEn:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:u(`tplPromptModeLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:Ct.promptMode,onChange:e=>Tt({...Ct,promptMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`replace`,children:u(`promptModeReplace`)}),(0,X.jsx)(`option`,{value:`append`,children:u(`promptModeAppend`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:u(`tplModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:Ct.model??``,onChange:e=>Tt({...Ct,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:u(`subagentFollowMain`)}),_.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`tplThinkingLabel`),` `,(0,X.jsx)(Du,{text:u(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:Ct.thinkingLevel??``,onChange:e=>Tt({...Ct,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:u(`tplThinkingFollowMain`)}),W_.map(e=>(0,X.jsx)(`option`,{value:e,children:u(`thinking.${e}`)},e))]})]}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${u(`tplSystemPromptLabel`)}${d===`zh`?`:`:`: `}${u(`tplSystemPromptPlaceholder`)}`,value:Ct.systemPrompt,onChange:e=>Tt({...Ct,systemPrompt:e.target.value})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${u(`tplSystemPromptLabel`)}: ${u(`tplSystemPromptEnPlaceholder`)}`,value:Ct.systemPromptEn??``,onChange:e=>Tt({...Ct,systemPromptEn:e.target.value})}),(0,X.jsxs)(`div`,{className:`tpl-pick-block`,children:[(0,X.jsx)(`div`,{className:`tpl-pick-head`,children:(0,X.jsxs)(`span`,{children:[u(`tplSkillsLabel`),` · `,u(`tplWhitelistHint`)]})}),_.skills.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:u(`noSkills`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:_.skills.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${Ct.enabledSkills.includes(e.name)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Ct.enabledSkills.includes(e.name),onChange:t=>{let n=t.target.checked;Tt({...Ct,enabledSkills:n?[...Ct.enabledSkills,e.name]:Ct.enabledSkills.filter(t=>t!==e.name)})}}),e.name]},e.name))})]}),(0,X.jsxs)(`div`,{className:`tpl-pick-block`,children:[(0,X.jsx)(`div`,{className:`tpl-pick-head`,children:(0,X.jsxs)(`span`,{children:[u(`tplExtensionsLabel`),` · `,u(`tplWhitelistHint`)]})}),_.extensions.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:u(`noExtensions`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:_.extensions.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${Ct.enabledExtensions.includes(e.id)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Ct.enabledExtensions.includes(e.id),onChange:t=>{let n=t.target.checked;Tt({...Ct,enabledExtensions:n?[...Ct.enabledExtensions,e.id]:Ct.enabledExtensions.filter(t=>t!==e.id)})}}),e.name]},e.id))})]})]}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-save-btn`,disabled:!Ct.name.trim(),onClick:()=>{$({type:`save_subagent_template`,template:{...Ct,name:Ct.name.trim()}}),Tt(null)},children:u(`tplSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>Tt(null),children:u(`tplCancel`)})]})]})}),_.subagentTemplates.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noSubagentTemplates`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:_.subagentTemplates.map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[e.name,_.subagentDefaultTemplates.includes(e.name)&&(0,X.jsx)(`span`,{className:`tpl-badge default`,children:u(`tplDefaultBadge`)}),!e.enabled&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:u(`subagentTemplateClosed`)})]}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[(d!==`zh`&&e.descriptionEn?e.descriptionEn:e.description)||`${e.promptMode===`replace`?u(`promptModeReplace`):u(`promptModeAppend`)}`,e.model?` · ${u(`tplModelLabel`)} ${e.model}`:` · ${u(`subagentFollowMain`)}`,e.thinkingLevel?` · ${u(`tplThinkingLabel`)} ${f(`thinking.${e.thinkingLevel}`)}`:``,e.enabledSkills.length>0&&` · ${u(`tplSkillsLabel`)} ${e.enabledSkills.length}`,e.enabledExtensions.length>0&&` · ${u(`tplExtensionsLabel`)} ${e.enabledExtensions.length}`,!e.description&&e.enabledSkills.length===0&&e.enabledExtensions.length===0&&` · ${u(`tplInherit`)}`]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-switch${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,title:`${e.enabled?u(`subagentTemplateDisable`):u(`subagentTemplateEnable`)} · ${u(`subagentTemplateOffHint`)}`,onClick:()=>$({type:`save_subagent_template`,template:{...e,enabled:!e.enabled}}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:u(`subagentTemplateEdit`),onClick:()=>{Tt({...e}),Dt(!1)},children:u(`subagentTemplateEdit`)}),Ot===e.name?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:u(`uninstallConfirmHint`),onClick:()=>{$({type:`delete_subagent_template`,name:e.name}),kt(null)},children:u(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`tplDelete`),onClick:()=>kt(e.name),children:(0,X.jsx)(L,{})})]})]},e.name))})]}),S===`approval-rules`&&!x&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ce,{className:`set-section-icon`}),u(`settingsApprovalRules`),(0,X.jsx)(Du,{text:u(`settingsApprovalRulesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.approvalRules?.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:u(`approvalRuleNew`),onClick:()=>{Mt({id:`custom.${jt().slice(0,8)}`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:``,action:`ask`,label:``,labelEn:``,reason:``,reasonEn:``}),It(`bash`),Pt(!0),Rt(null)},children:[(0,X.jsx)(me,{}),` `,u(`approvalRuleNew`)]})]}),At&&(0,X.jsxs)(`div`,{className:`rule-editor`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,style:{fontSize:13,marginBottom:4},children:Nt?u(`approvalRuleNew`):`${u(`approvalRuleEdit`)} · ${At.label}`}),(0,X.jsx)(Nx,{label:u(`approvalRuleLabel`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.label,placeholder:`例如:拦截 Docker 危险操作`,onChange:e=>Mt({...At,label:e.target.value})})}),(0,X.jsx)(Nx,{label:u(`approvalRuleLabelEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.labelEn??``,placeholder:`e.g. Block dangerous Docker commands`,onChange:e=>Mt({...At,labelEn:e.target.value})})}),(0,X.jsx)(Nx,{label:u(`approvalRuleTools`),tip:u(`approvalRuleToolsTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Ft,placeholder:`bash, write, edit (或 * 通配)`,onChange:e=>{It(e.target.value);let t=e.target.value.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);Mt({...At,tools:t.length>0?t:[`*`]})}})}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:10,flexWrap:`wrap`},children:[(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(Nx,{label:u(`approvalRuleField`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:At.field,onChange:e=>Mt({...At,field:e.target.value}),children:[(0,X.jsx)(`option`,{value:`command`,children:u(`approvalRuleFieldCommand`)}),(0,X.jsx)(`option`,{value:`path`,children:u(`approvalRuleFieldPath`)}),(0,X.jsx)(`option`,{value:`params`,children:u(`approvalRuleFieldParams`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(Nx,{label:u(`approvalRuleMatch`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:At.match,onChange:e=>Mt({...At,match:e.target.value}),children:[(0,X.jsx)(`option`,{value:`regex`,children:u(`approvalRuleMatchRegex`)}),(0,X.jsx)(`option`,{value:`glob`,children:u(`approvalRuleMatchGlob`)}),(0,X.jsx)(`option`,{value:`contains`,children:u(`approvalRuleMatchContains`)}),(0,X.jsx)(`option`,{value:`prefix`,children:u(`approvalRuleMatchPrefix`)}),(0,X.jsx)(`option`,{value:`outside_workspace`,children:u(`approvalRuleMatchOutsideWs`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(Nx,{label:`命中动作`,children:(0,X.jsxs)(`select`,{className:`set-select`,value:At.action,onChange:e=>Mt({...At,action:e.target.value}),children:[(0,X.jsx)(`option`,{value:`ask`,children:u(`approvalRuleActionAsk`)}),(0,X.jsx)(`option`,{value:`deny`,children:u(`approvalRuleActionDeny`)}),(0,X.jsx)(`option`,{value:`allow`,children:u(`approvalRuleActionAllow`)})]})})})]}),At.match!==`outside_workspace`&&(0,X.jsx)(Nx,{label:u(`approvalRuleValue`),tip:u(`approvalRuleValueTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.value,placeholder:`匹配表达式或关键字…`,onChange:e=>Mt({...At,value:e.target.value})})}),(0,X.jsx)(Nx,{label:u(`approvalRuleReason`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.reason??``,placeholder:`例如:检测到删除镜像或容器操作`,onChange:e=>Mt({...At,reason:e.target.value})})}),(0,X.jsx)(Nx,{label:u(`approvalRuleReasonEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.reasonEn??``,placeholder:`e.g. Detected docker image/container removal`,onChange:e=>Mt({...At,reasonEn:e.target.value})})}),(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`label`,{className:`set-checkbox-label`,style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:At.enabled,onChange:e=>Mt({...At,enabled:e.target.checked})}),u(`approvalRuleEnabled`)]})}),Lt&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12},children:Lt}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:4},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Mt(null),Rt(null)},children:u(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{if(!At.label.trim()){Rt(`请填写规则名称`);return}if(At.match===`regex`)try{new RegExp(At.value)}catch(e){Rt(`正则表达式非法:${e.message}`);return}$({type:`save_approval_rule`,rule:At}),Mt(null),Rt(null)},children:u(`save`)})]})]}),(_.approvalRules??[]).length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:u(`approvalRuleEmpty`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:(_.approvalRules??[]).map((e,t)=>{let n=e.builtin===!0;return(0,X.jsxs)(`div`,{className:`set-row${e.enabled?``:` rule-row-disabled`}`,style:{alignItems:`flex-start`,padding:`12px 0`},children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,style:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:6},children:[(0,X.jsx)(`span`,{className:`rule-badge ${e.action}`,children:e.action===`deny`?u(`approvalRuleActionDeny`):e.action===`allow`?u(`approvalRuleActionAllow`):u(`approvalRuleActionAsk`)}),(0,X.jsx)(`strong`,{style:{fontSize:13},children:d===`zh`?e.label:e.labelEn||e.label}),n&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:u(`approvalRuleBuiltin`)}),(0,X.jsx)(`span`,{className:`rule-meta-code`,children:e.tools.join(`, `)})]}),(0,X.jsxs)(`div`,{className:`set-hint`,style:{marginTop:6,display:`flex`,flexDirection:`column`,gap:3},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:6,flexWrap:`wrap`},children:[(0,X.jsxs)(`span`,{style:{opacity:.85,fontSize:11,fontFamily:`var(--mono)`},children:[`[`,e.field,` · `,e.match,`]`]}),e.match!==`outside_workspace`&&(0,X.jsx)(`code`,{className:`rule-pattern-code`,children:e.value})]}),(e.reason||e.reasonEn)&&(0,X.jsx)(`div`,{style:{opacity:.75,fontSize:11},children:d===`zh`?e.reason:e.reasonEn||e.reason})]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,style:{marginLeft:12,flexShrink:0},children:[(0,X.jsx)(`button`,{type:`button`,className:`set-switch${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,title:e.enabled?u(`settingsEnabled`):u(`settingsDisabled`),onClick:()=>$({type:`save_approval_rule`,rule:{...e,enabled:!e.enabled}}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})}),!n&&t>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleMoveUp`),onClick:()=>{let e=[..._.approvalRules??[]],n=e[t-1];e[t-1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(ct,{})}),!n&&t<(_.approvalRules?.length??0)-1&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleMoveDown`),onClick:()=>{let e=[..._.approvalRules??[]],n=e[t+1];e[t+1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(dt,{})}),n&&(Ht===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`reset_builtin_approval_rule`,id:e.id}),Ut(null)},children:u(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleReset`),onClick:()=>Ut(e.id),children:(0,X.jsx)(K,{})})),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleEdit`),onClick:()=>{Mt({...e}),It(e.tools.join(`, `)),Pt(!1),Rt(null)},children:(0,X.jsx)(Y,{})}),!n&&(Bt===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`delete_approval_rule`,id:e.id}),Vt(null)},children:u(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`approvalRuleDelete`),onClick:()=>Vt(e.id),children:(0,X.jsx)(L,{})}))]})]},e.id)})})]}),oi&&(0,X.jsx)(Ru,{plugin:oi.plugin,epoch:e.pluginsEpoch,send:$,className:`set-plugin-page`}),Jt&&(0,X.jsx)(qy,{name:Jt,override:Xt[Jt]??null,onApply:$t,onClose:()=>Yt(null)})]})]}),(0,X.jsx)(`div`,{className:`modal-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:xa,children:u(`close`)})})]}),bt!==null&&(0,X.jsx)(dx,{presets:_.presets.map(e=>e.name),presetExport:e.presetExport,presetImport:e.presetImport,presetCatalog:e.presetCatalog,presetShare:e.presetShare,initialPreset:bt.name,initialTab:bt.tab,onClose:()=>xt(null)})]})}function zx(e,t){let n=Math.max(0,Date.now()-e),r=Math.floor(n/6e4);if(r<1)return t(`bgTaskJustNow`);if(r<60)return t(`bgTaskMinutes`,{n:r});let i=Math.floor(r/60);return i<24?t(`bgTaskHours`,{n:i}):t(`bgTaskDays`,{n:Math.floor(i/24)})}function Bx({servers:e,onClose:t,plugins:n=[],epoch:r=0,send:i,onUiAction:a,autoCleanupMin:o=0}){let s=Z(),{locale:c}=Nn(),[l,u]=(0,g.useState)(new Set),d=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});(0,g.useEffect)(()=>{$({type:`list_bg_servers`})},[]);let f=(0,g.useMemo)(()=>(pa(na(n),{locale:c,t:e=>s(e)})[`tasks.panel`]??[]).filter(e=>!e.hidden&&e.source!==`host`&&e.kind!==`divider`),[n,c,s]);return(0,X.jsxs)(Ky,{className:`bg-task-modal`,onClose:t,showCloseButton:!1,children:[(0,X.jsxs)(`div`,{className:`bg-task-head`,children:[(0,X.jsxs)(`span`,{className:`bg-task-title`,children:[(0,X.jsx)(ke,{}),` `,s(`bgTasks`),e.length>0&&(0,X.jsx)(`em`,{className:`bg-task-count`,children:e.length})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:s(`close`),onClick:t,children:(0,X.jsx)(P,{})})]}),e.length===0?(0,X.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{children:s(`bgTasksEmpty`)}),(0,X.jsx)(`small`,{children:s(`bgTasksDesc`)})]}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:e.map(e=>{let t=!!e.taskId,n=e.taskId??String(e.port);return(0,X.jsxs)(`li`,{className:`bg-task-item`,children:[(0,X.jsx)(`span`,{className:`bg-task-icon`,title:t?e.plugin:s(`bgTaskPort`)}),(0,X.jsxs)(`div`,{className:`bg-task-info`,children:[(0,X.jsxs)(`div`,{className:`bg-task-line1`,children:[t?(0,X.jsxs)(`span`,{className:`bg-task-port`,title:e.taskId,children:[`🧩 `,e.plugin]}):(0,X.jsxs)(`span`,{className:`bg-task-port`,children:[`:`,e.port]}),e.name&&(0,X.jsx)(`span`,{className:`bg-task-name`,children:e.name})]}),(0,X.jsxs)(`div`,{className:`bg-task-line2`,children:[!t&&(0,X.jsxs)(`span`,{children:[s(`bgTaskPid`),` `,e.pid]}),(0,X.jsxs)(`span`,{children:[s(`bgTaskSince`),` `,zx(e.since,s)]}),t&&e.status&&(0,X.jsx)(`span`,{className:`bg-task-status`,children:e.status})]}),e.command&&(0,X.jsxs)(`button`,{type:`button`,className:`bg-task-cmd ${l.has(n)?`open`:``}`,title:`${s(`bgTaskCommand`)}: ${e.command}`,onClick:()=>d(n),children:[(0,X.jsx)(z,{}),(0,X.jsx)(`code`,{children:e.command})]})]}),!t&&(0,X.jsx)(`button`,{type:`button`,className:`btn bg-task-keep`,title:e.keep?s(`bgTaskKeepOn`):s(`bgTaskKeep`),"aria-pressed":!!e.keep,onClick:()=>$({type:`set_bg_keep`,port:e.port??0,keep:!e.keep}),children:e.keep?`📌`:`📍`}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,title:s(`bgTaskStop`),onClick:()=>$(t?{type:`kill_background_server`,taskId:e.taskId}:{type:`kill_background_server`,port:e.port}),children:[(0,X.jsx)(V,{}),(0,X.jsx)(`span`,{children:s(`bgTaskStop`)})]})]},n)})}),f.map(e=>{let t=n.find(t=>t.id===e.source.slice(7));return e.kind===`view`?t?(0,X.jsx)(`div`,{children:(0,X.jsx)(Ru,{plugin:t,epoch:r,send:i??(()=>{})})},e.id):null:(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e.hint??e.label,onClick:()=>a?.(e),children:e.label},e.id)}),(0,X.jsxs)(`div`,{className:`bg-task-foot`,children:[(0,X.jsxs)(`label`,{className:`bg-task-cleanup`,title:s(`bgTaskCleanupHint`),children:[(0,X.jsx)(`span`,{children:s(`bgTaskCleanup`)}),(0,X.jsxs)(`select`,{className:`btn`,value:String(o),onChange:e=>$({type:`set_settings`,bgAutoCleanupMin:Number(e.target.value)}),children:[(0,X.jsx)(`option`,{value:`0`,children:s(`bgTaskCleanupOff`)}),[15,30,60,120].map(e=>(0,X.jsx)(`option`,{value:String(e),children:s(`bgTaskCleanupMinutes`,{n:e})},e))]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:s(`bgTaskCleanNowHint`),onClick:()=>$({type:`clean_bg_leftovers`}),children:[(0,X.jsx)(L,{}),(0,X.jsx)(`span`,{children:s(`bgTaskCleanNow`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:s(`bgTaskRefresh`),onClick:()=>$({type:`list_bg_servers`}),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:s(`bgTaskRefresh`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stopall`,disabled:e.length===0,title:s(`bgTaskStopAll`),onClick:()=>$({type:`kill_background_servers`}),children:[(0,X.jsx)(V,{}),(0,X.jsx)(`span`,{children:s(`bgTaskStopAll`)})]})]})]})}function Vx(){let e=Z(),t=zm(),[n,r]=(0,g.useState)(!0),i=(0,g.useRef)(null);return(0,g.useEffect)(()=>{t&&r(!0)},[t]),zt(()=>{t&&Lm()},!!t),(0,g.useEffect)(()=>{if(!t)return;let e=e=>{if(e.key!==`Enter`||e.shiftKey||e.ctrlKey||e.metaKey)return;let t=e.target;(!t||t===document.body||i.current?.contains(t))&&(e.preventDefault(),Rm(n))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,n]),t?(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:Lm,children:(0,X.jsxs)(`div`,{ref:i,className:`tool-info-modal rollback-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`rollbackSession`),onClick:e=>e.stopPropagation(),style:{maxWidth:520},children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,style:{color:`var(--amber, #f59e0b)`},children:[(0,X.jsx)(wt,{}),e(`rollbackSession`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`cancel`),onClick:Lm,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[(0,X.jsx)(`p`,{style:{margin:`0 0 16px 0`,fontSize:14,lineHeight:1.6},children:e(`rollbackConfirm`)}),(0,X.jsxs)(`label`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`12px 14px`,borderRadius:8,backgroundColor:`var(--bg-elev, rgba(255, 255, 255, 0.04))`,border:`1px solid var(--border-subtle, rgba(255, 255, 255, 0.1))`,cursor:`pointer`,marginBottom:20},title:e(`rollbackRestoreWorkspaceTip`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),style:{marginTop:3,cursor:`pointer`}}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{style:{fontWeight:600,fontSize:13,color:`var(--text, #e2e8f0)`},children:e(`rollbackRestoreWorkspace`)}),(0,X.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginTop:2},children:e(`rollbackRestoreWorkspaceTip`)})]})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:Lm,children:e(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{display:`inline-flex`,alignItems:`center`,gap:6,backgroundColor:`var(--amber, #f59e0b)`,borderColor:`var(--amber, #f59e0b)`,color:`#000`,fontWeight:600},onClick:()=>Rm(n),children:[(0,X.jsx)(ft,{}),e(`confirm`)]})]})]})]})}),document.body):null}function Hx({approval:e}){let t=Z(),{locale:n}=Nn(),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(null);if((0,g.useEffect)(()=>{if(e){let t=e.params;i(typeof t==`object`&&t?JSON.stringify(t,null,2):t==null?`{}`:String(t)),o(null)}},[e]),!e)return null;let s=t=>{$({type:`tool_approval_response`,id:e.id,decision:`approve`,...t&&t!==`once`?{scope:t}:{}})},c=()=>{$({type:`tool_approval_response`,id:e.id,decision:`deny`,reason:`Operation rejected by user`})};return(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,children:(0,X.jsxs)(`div`,{className:`tool-info-modal approval-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`toolApprovalTitle`),style:{maxWidth:640,borderTop:`4px solid var(--amber, #f59e0b)`},onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,style:{color:`var(--amber, #f59e0b)`},children:[(0,X.jsx)(wt,{}),t(`toolApprovalTitle`)]}),(0,X.jsx)(`code`,{className:`tool-info-name`,style:{fontWeight:700},children:e.toolName}),e.parentTool===`codemode`&&(0,X.jsxs)(`span`,{className:`tool-info-label`,style:{backgroundColor:`rgba(245, 158, 11, 0.15)`,color:`var(--amber, #f59e0b)`,border:`1px solid rgba(245, 158, 11, 0.35)`,fontWeight:600},children:[`⚡ `,t(`codemodeNestedApprovalBadge`)]}),e.conversationTitle&&(0,X.jsx)(`span`,{className:`tool-info-label`,children:e.conversationTitle}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalDeny`),onClick:c,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[e.parentTool===`codemode`&&(0,X.jsxs)(`div`,{style:{padding:`8px 12px`,borderRadius:6,backgroundColor:`rgba(99, 102, 241, 0.12)`,border:`1px solid rgba(99, 102, 241, 0.25)`,marginBottom:12,color:`var(--text, #e2e8f0)`,fontSize:12.5,display:`flex`,alignItems:`center`,gap:6},children:[(0,X.jsx)(`span`,{style:{fontSize:14},children:`⚡`}),(0,X.jsx)(`span`,{children:t(`codemodeNestedApprovalDesc`)})]}),(e.reason||e.reasonEn)&&(0,X.jsxs)(`div`,{style:{padding:`10px 14px`,borderRadius:6,backgroundColor:`rgba(245, 158, 11, 0.12)`,border:`1px solid rgba(245, 158, 11, 0.3)`,marginBottom:16,color:`var(--amber, #f59e0b)`,fontSize:13,lineHeight:1.5,fontWeight:500},children:[(0,X.jsxs)(`div`,{style:{fontWeight:600,marginBottom:2},children:[t(`toolApprovalRiskAlert`),`:`]}),(0,X.jsx)(`div`,{children:n===`zh`?e.reason||e.reasonEn:e.reasonEn||e.reason}),e.category&&(0,X.jsxs)(`div`,{style:{marginTop:6,fontSize:12,opacity:.85},children:[t(`toolApprovalCategory`),`:`,n===`zh`?e.category.label:e.category.labelEn]}),e.hits&&e.hits.length>0&&(0,X.jsxs)(`div`,{className:`approval-hits-panel`,children:[(0,X.jsxs)(`div`,{className:`approval-hits-title`,children:[t(`toolApprovalHitsTitle`),` (`,e.hits.length,`)`]}),(0,X.jsx)(`div`,{className:`approval-hits-list`,children:e.hits.map((e,r)=>(0,X.jsxs)(`div`,{className:`approval-hit-item`,children:[(0,X.jsxs)(`div`,{className:`approval-hit-header`,children:[(0,X.jsx)(`span`,{className:`approval-hit-badge`,children:n===`zh`?e.label:e.labelEn||e.label}),(0,X.jsx)(`span`,{className:`approval-hit-field`,children:e.field}),(0,X.jsx)(`span`,{className:`approval-hit-pos`,children:t(`approvalHitPos`,{index:e.index+1,length:e.length})})]}),(0,X.jsx)(`div`,{className:`approval-hit-text`,children:(0,X.jsx)(`mark`,{className:`approval-danger-hit`,children:e.text})})]},r))})]})]}),e.toolName===`bash`&&typeof e.params?.command==`string`&&(0,X.jsxs)(`div`,{className:`approval-cmd-preview`,children:[(0,X.jsxs)(`div`,{className:`approval-cmd-preview-label`,children:[t(`approvalCommandPreview`),`:`]}),(0,X.jsxs)(`div`,{className:`approval-cmd-preview-box`,children:[(0,X.jsx)(`span`,{className:`bashblock-prompt`,children:`$`}),(0,X.jsx)(`code`,{children:md(e.params.command,e.hits)})]})]}),(0,X.jsxs)(`div`,{style:{marginBottom:16},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:6},children:[(0,X.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`var(--text, #e2e8f0)`},children:t(`toolApprovalParams`)}),(0,X.jsx)(`span`,{style:{fontSize:11,color:`var(--text-dim, #9aa1b4)`},children:t(`toolApprovalEditPlaceholder`)})]}),(0,X.jsx)(`textarea`,{rows:8,value:r,onChange:e=>{i(e.target.value),a&&o(null)},style:{width:`100%`,fontFamily:`var(--mono, monospace)`,fontSize:12,lineHeight:1.5,padding:10,borderRadius:6,backgroundColor:`var(--bg-elev, #111827)`,color:`var(--text, #f8fafc)`,border:a?`1px solid var(--red, #ef4444)`:`1px solid var(--border-subtle, rgba(255,255,255,0.1))`,boxSizing:`border-box`,resize:`vertical`}}),a&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12,marginTop:4},children:a})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,justifyContent:`flex-end`,gap:10},children:[e.category&&(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowCategoryHint`),onClick:()=>s(`category`),children:[(0,X.jsx)(ke,{}),t(`toolApprovalAllowCategory`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowConversationHint`),onClick:()=>s(`all`),children:[(0,X.jsx)(pt,{}),t(`toolApprovalAllowConversation`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,style:{color:`var(--red, #ef4444)`},onClick:c,children:[(0,X.jsx)(P,{}),t(`toolApprovalDeny`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>s(),style:{fontWeight:500},children:[(0,X.jsx)(ft,{}),t(`toolApprovalApprove`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{display:`inline-flex`,alignItems:`center`,gap:6,backgroundColor:`var(--amber, #f59e0b)`,borderColor:`var(--amber, #f59e0b)`,color:`#000`,fontWeight:600},onClick:()=>{try{let t=e.params,n;n=typeof t==`object`&&t||t==null?JSON.parse(r):r,o(null),$({type:`tool_approval_response`,id:e.id,decision:`edit`,editedParams:n})}catch(e){o(`JSON 格式错误:${e.message}`)}},children:[(0,X.jsx)(Y,{}),t(`toolApprovalEditAndRun`)]})]})]})]})}),document.body)}function Ux({overlay:e}){let t=Z(),n=(0,g.useRef)(null),r=(0,g.useRef)(null),i=(0,g.useCallback)(()=>{$({type:`tui_overlay_cancel`,id:e.id})},[e.id]);(0,g.useEffect)(()=>{let t=n.current;if(!t)return;let i=new m({theme:vf(),fontFamily:`"SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace`,fontSize:13,cursorBlink:!0,scrollback:1e3,cols:e.cols||80,rows:e.rows||24}),a=new h;i.loadAddon(a),i.open(t),r.current={term:i,fit:a},e.initialAnsi&&i.write(e.initialAnsi);let o=i.onData(t=>{$({type:`tui_overlay_input`,id:e.id,data:t})}),s=cs((t,n)=>{t===e.id&&i.write(n)});try{a.fit(),(i.cols!==e.cols||i.rows!==e.rows)&&$({type:`tui_overlay_resize`,id:e.id,cols:i.cols,rows:i.rows})}catch{}let c=new ResizeObserver(()=>{try{a.fit(),i.cols&&i.rows&&$({type:`tui_overlay_resize`,id:e.id,cols:i.cols,rows:i.rows})}catch{}});c.observe(t);let l=setTimeout(()=>{i.focus()},50);return()=>{clearTimeout(l),c.disconnect(),o.dispose(),s(),i.dispose(),r.current=null}},[e.id,e.cols,e.rows,e.initialAnsi]);let a=e.title||t(`tuiOverlayTitle`);return(0,X.jsx)(Ky,{open:!0,onClose:i,title:a,icon:(0,X.jsx)(z,{}),className:`tui-overlay-modal`,closeOnBackdropClick:!1,closeOnEscape:!0,children:(0,X.jsx)(`div`,{className:`tui-overlay-body`,children:(0,X.jsx)(`div`,{className:`tui-overlay-xterm`,ref:n})})})}var Wx={pending:`in_progress`,in_progress:`done`,done:`failed`,failed:`pending`};function Gx({plan:e}){let t=Z(),[n,r]=(0,g.useState)(!1),{copied:i,copy:a}=qu({duration:2e3}),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(``);if(!e||!e.steps||e.steps.length===0)return null;let f=e.steps,p=f.filter(e=>e.status===`done`).length,m=f.length,h=Math.round(p/m*100),_=f.find(t=>t.id===e.activeStepId)??f.find(e=>e.status===`in_progress`),v=()=>{window.confirm(`确定要清空当前任务计划看板吗?`)&&$({type:`plan_update`,steps:[]})},y=()=>{$({type:`set_plan_mode`,enabled:!1}),$({type:`prompt`,text:t(`planImplementRequest`)})},b=()=>{let e=f.map((e,t)=>`${t+1}. ${e.title}${e.description?` (${e.description})`:``}`).join(`
|
|
678
678
|
`);$({type:`plan_clean_handoff`,steps:f,prompt:`${t(`planCleanHandoffPrompt`)}\n\n${e}`})},x=async()=>{let e=[`# ${t(`planBoardTitle`)} (${p}/${m})`,``,...f.map((e,t)=>{let n=`${e.status===`done`?`[x]`:e.status===`in_progress`?`[>]`:e.status===`failed`?`[!]`:`[ ]`} ${t+1}. ${e.title}`;return e.description&&(n+=`\n ${e.description}`),n})];await a(e.join(`
|
|
679
679
|
`))},S=e=>{s(e.id),l(e.title),d(e.description||``)},C=()=>{s(null),l(``),d(``)},w=e=>{let t=c.trim();if(!t)return;let n={title:t};n.description=u.trim()?u.trim():void 0,$({type:`plan_step_update`,stepId:e,patch:n}),s(null)},T=e=>{$({type:`plan_step_delete`,stepId:e})},E=e=>{let t=f.find(t=>t.id===e);t&&$({type:`plan_step_update`,stepId:e,patch:{status:Wx[t.status]}})},D=()=>{let e={id:`step-${Date.now()}`,title:t(`planBoardAddStep`),status:`pending`};$({type:`plan_step_add`,step:e}),S(e)},O=(e,n)=>{let r=(()=>{switch(e){case`done`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(pt,{}),t(`planBoardCompleted`)]});case`in_progress`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(rt,{}),t(`planBoardInProgress`)]});case`failed`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Tt,{}),t(`planBoardFailed`)]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(at,{}),t(`planBoardPending`)]})}})();return(0,X.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),E(n)},title:`点击切换状态 (pending / in_progress / done / failed)`,style:{display:`inline-flex`,alignItems:`center`,gap:4,color:e===`done`?`var(--green, #22c55e)`:e===`in_progress`?`var(--accent, #38bdf8)`:e===`failed`?`var(--red, #ef4444)`:`var(--text-dim, #9aa1b4)`,fontSize:12,fontWeight:e===`pending`?400:600,background:`none`,border:`none`,cursor:`pointer`,padding:`2px 4px`,borderRadius:4},children:r})};return(0,X.jsxs)(`div`,{className:`plan-board ${n?``:`plan-board-collapsed`}`.trim(),children:[(0,X.jsxs)(`div`,{className:`plan-board-head`,onClick:()=>r(!n),children:[(0,X.jsxs)(`div`,{className:`plan-board-head-main`,children:[(0,X.jsx)(De,{className:`plan-board-icon`}),(0,X.jsx)(`span`,{className:`plan-board-title`,children:t(`planBoardTitle`)}),(0,X.jsxs)(`span`,{className:`plan-board-count ${h===100?`plan-board-count-done`:``}`.trim(),children:[p,`/`,m]}),!n&&_&&(0,X.jsx)(`span`,{className:`plan-board-active`,title:_.title,children:_.title})]}),(0,X.jsxs)(`div`,{className:`plan-board-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`plan-board-implement`,title:t(`planImplementTip`),onClick:e=>{e.stopPropagation(),y()},children:t(`planImplementBtn`)}),n&&(0,X.jsx)(`button`,{type:`button`,className:`plan-board-clean-handoff`,title:t(`planCleanHandoffTip`),onClick:e=>{e.stopPropagation(),b()},children:t(`planCleanHandoffBtn`)}),n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(i?`planBoardExportSuccess`:`planBoardExportMarkdown`),onClick:e=>{e.stopPropagation(),x()},children:i?(0,X.jsx)(ft,{style:{color:`var(--green, #22c55e)`}}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(`clear`),onClick:e=>{e.stopPropagation(),v()},children:(0,X.jsx)(L,{})})]}),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(n?`collapseSection`:`expandSection`),children:n?(0,X.jsx)(ct,{}):(0,X.jsx)(dt,{})})]}),n&&(0,X.jsx)(`div`,{className:`plan-board-head-divider`,children:(0,X.jsx)(`div`,{className:`plan-board-head-divider-fill`,style:{width:`${h}%`,backgroundColor:h===100?`var(--green, #22c55e)`:`var(--accent, #38bdf8)`}})})]}),!n&&(0,X.jsx)(`div`,{className:`plan-board-progress-line`,children:(0,X.jsx)(`div`,{className:`plan-board-progress-line-fill`,style:{width:`${h}%`,backgroundColor:h===100?`var(--green, #22c55e)`:`var(--accent, #38bdf8)`}})}),n&&(0,X.jsxs)(`div`,{className:`plan-board-steps`,style:{marginTop:8,display:`flex`,flexDirection:`column`,gap:8},children:[f.map((n,r)=>{let i=n.id===e.activeStepId||n.status===`in_progress`;return o===n.id?(0,X.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,padding:`8px 10px`,borderRadius:6,backgroundColor:`var(--bg-elev2, rgba(0, 0, 0, 0.2))`,border:`1px solid var(--accent, #38bdf8)`},children:[(0,X.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:t(`planBoardStepTitlePlaceholder`),style:{width:`100%`,padding:`4px 8px`,borderRadius:4,border:`1px solid var(--border-subtle)`,background:`var(--bg, #0b0f17)`,color:`var(--text, #f1f5f9)`,fontSize:13},autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),w(n.id)):e.key===`Escape`&&C()}}),(0,X.jsx)(`textarea`,{rows:2,value:u,onChange:e=>d(e.target.value),placeholder:t(`planBoardStepDescPlaceholder`),style:{width:`100%`,padding:`4px 8px`,borderRadius:4,border:`1px solid var(--border-subtle)`,background:`var(--bg, #0b0f17)`,color:`var(--text-dim, #9aa1b4)`,fontSize:12,resize:`vertical`},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),w(n.id)):e.key===`Escape`&&C()}}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:6,marginTop:2},children:[(0,X.jsxs)(`button`,{type:`button`,className:`plan-board-iconbtn`,onClick:C,title:t(`cancel`),style:{padding:`3px 8px`,fontSize:12},children:[(0,X.jsx)(P,{}),` `,t(`cancel`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`plan-board-implement`,onClick:()=>w(n.id),title:t(`confirm`),style:{padding:`3px 10px`,fontSize:12},children:[(0,X.jsx)(ft,{}),` `,t(`confirm`)]})]})]},n.id||r):(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,flexWrap:`wrap`,rowGap:4,minWidth:0,padding:`6px 10px`,borderRadius:6,backgroundColor:i?`rgba(56, 189, 248, 0.08)`:`var(--bg-elev2, rgba(0, 0, 0, 0.2))`,border:i?`1px solid rgba(56, 189, 248, 0.25)`:`1px solid transparent`},children:[(0,X.jsxs)(`div`,{style:{flex:`1 1 180px`,minWidth:0,paddingRight:10},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:6,minWidth:0},children:[(0,X.jsxs)(`span`,{style:{fontSize:11,fontWeight:700,color:i?`var(--accent, #38bdf8)`:`var(--text-dim, #9aa1b4)`,minWidth:16},children:[r+1,`.`]}),(0,X.jsx)(`span`,{style:{fontWeight:i?600:500,color:n.status===`done`?`var(--text-dim, #9aa1b4)`:`var(--text, #f1f5f9)`,textDecoration:n.status===`done`?`line-through`:`none`,minWidth:0,overflowWrap:`anywhere`,wordBreak:`break-word`},children:n.title})]}),n.description&&(0,X.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginTop:2,paddingLeft:22,lineHeight:1.4,overflowWrap:`anywhere`,wordBreak:`break-word`},children:n.description})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:4,flexShrink:0,marginTop:2},children:[O(n.status,n.id),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(`planBoardEditStep`),onClick:()=>S(n),children:(0,X.jsx)(Ke,{size:12})}),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(`planBoardDeleteStep`),onClick:()=>T(n.id),children:(0,X.jsx)(L,{size:12})})]})]},n.id||r)}),(0,X.jsxs)(`button`,{type:`button`,className:`plan-board-add-btn`,onClick:D,children:[(0,X.jsx)(me,{}),` `,t(`planBoardAddStep`)]})]})]})}var Kx=3,qx=200;function Jx(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Yx(e){return typeof e==`string`&&e.trim()||void 0}function Xx(e,t){let n=[];for(let r of e){let e=Qx(r,t);if(n.includes(e)||n.push(e),n.length>=4){n.push(`…`);break}}return n.join(` | `)||`any`}function Zx(e){let t=e.slice(0,6).map(e=>typeof e==`string`?e:JSON.stringify(e)??String(e));if(t.length!==0)return`enum: ${t.join(` | `)}${e.length>t.length?` | …`:``}`}function Qx(e,t=0){if(t>6||!Jx(e))return`any`;if(Yx(e.$ref))return`ref`;let n=Yx(e.type);if(n===`array`){let n=e.items;return`array<${n===void 0?`any`:Qx(n,t+1)}>`}if(n)return n;for(let n of[`anyOf`,`oneOf`,`allOf`]){let r=e[n];if(Array.isArray(r)&&r.length>0)return Xx(r,t+1)}return Jx(e.properties)?`object`:Jx(e.additionalProperties)?`record<${Qx(e.additionalProperties,t+1)}>`:`any`}function $x(e){let t=[],n=e.enum;if(Array.isArray(n)&&n.length>0){let e=Zx(n);e&&t.push(e)}return e.const!==void 0&&t.push(`const: ${JSON.stringify(e.const)}`),e.default!==void 0&&t.push(`default: ${JSON.stringify(e.default)}`),t.length>0?t.join(` · `):void 0}function eS(e,t={}){let n=t.maxDepth??Kx,r=t.maxRows??qx,i=e;if(!Jx(i))return[];let a=i.properties;if(!Jx(a))return[];let o=[],s=new Set((Array.isArray(i.required)?i.required:[]).filter(e=>typeof e==`string`)),c=(e,t,i,a)=>{if(!(o.length>=r))for(let[s,l]of Object.entries(e)){if(o.length>=r)return;let e=Jx(l)?l:{},u=t?`${t}.${s}`:s,d={name:u,type:Qx(e,i),required:a.has(s),depth:i},f=Yx(e.description);f&&(d.description=f);let p=$x(e);if(p&&(d.hint=p),o.push(d),i+1<n&&Jx(e.properties)){let t=new Set((Array.isArray(e.required)?e.required:[]).filter(e=>typeof e==`string`));c(e.properties,u,i+1,t)}}};return c(a,``,0,s),o}function tS(){let e=Z(),t=ys();return zt(()=>{hs()},!!t),t?(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:hs,children:(0,X.jsxs)(`div`,{className:`tool-info-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`toolInfoTitle`),onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,children:[(0,X.jsx)(je,{}),e(`toolInfoTitle`)]}),(0,X.jsx)(`code`,{className:`tool-info-name`,children:t.name}),t.label&&t.label!==t.name&&(0,X.jsx)(`span`,{className:`tool-info-label`,children:t.label}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`close`),onClick:hs,children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`div`,{className:`tool-info-body`,children:(0,X.jsx)(nS,{info:t})})]})}),document.body):null}function nS({info:e}){let t=Z();if(e.status===`loading`)return(0,X.jsxs)(`div`,{className:`tool-info-state`,role:`status`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,t(`toolInfoLoading`)]});if(e.status===`unsupported`)return(0,X.jsx)(`div`,{className:`tool-info-state`,children:t(`toolInfoUnsupported`)});if(e.status===`missing`)return(0,X.jsx)(`div`,{className:`tool-info-state`,children:t(`toolInfoMissing`)});let n=e.parameters===void 0?[]:eS(e.parameters),r=e.parameters===void 0?``:iS(e.parameters);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`tool-info-badges`,children:[e.active!==void 0&&(0,X.jsx)(`span`,{className:`tool-info-badge ${e.active?`on`:`off`}`,children:e.active?t(`toolInfoActive`):t(`toolInfoInactive`)}),e.source&&(0,X.jsxs)(`span`,{className:`tool-info-badge`,children:[t(`toolInfoSource`),`: `,e.source,e.scope?` · ${e.scope}`:``]})]}),(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoDescription`)}),(0,X.jsx)(`div`,{className:`tool-info-text`,children:e.description||t(`toolInfoNoDescription`)})]}),e.promptSnippet&&(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoPromptSnippet`)}),(0,X.jsx)(`div`,{className:`tool-info-text dim`,children:e.promptSnippet})]}),e.promptGuidelines&&e.promptGuidelines.length>0&&(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoGuidelines`)}),(0,X.jsx)(`ul`,{className:`tool-info-list`,children:e.promptGuidelines.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoParams`)}),n.length>0?(0,X.jsx)(rS,{rows:n}):(0,X.jsx)(`div`,{className:`tool-info-text dim`,children:t(`toolInfoParamsNone`)}),e.parametersDropped&&(0,X.jsx)(`div`,{className:`tool-info-text warn`,children:t(`toolInfoSchemaDropped`)}),r&&(0,X.jsxs)(`details`,{className:`tool-info-raw`,children:[(0,X.jsxs)(`summary`,{children:[t(`toolInfoRawSchema`),(0,X.jsx)(Fd,{text:r})]}),(0,X.jsx)(`pre`,{children:r})]})]}),(0,X.jsx)(`div`,{className:`tool-info-foot`,children:t(`toolInfoFootnote`)})]})}function rS({rows:e}){let t=Z();return(0,X.jsx)(`div`,{className:`tool-schema-table`,role:`table`,children:e.map(e=>(0,X.jsxs)(`div`,{className:`tool-schema-row`,role:`row`,style:{paddingLeft:8+e.depth*14},children:[(0,X.jsxs)(`div`,{className:`tool-schema-name`,children:[(0,X.jsx)(`code`,{children:e.name}),e.required&&(0,X.jsx)(`span`,{className:`tool-schema-req`,children:t(`toolInfoRequired`)})]}),(0,X.jsxs)(`div`,{className:`tool-schema-type`,children:[e.type,e.hint&&(0,X.jsx)(`span`,{className:`tool-schema-hint`,children:e.hint})]}),e.description&&(0,X.jsx)(`div`,{className:`tool-schema-desc`,children:e.description})]},e.name))})}function iS(e){try{return JSON.stringify(e,null,2)??``}catch{return``}}function aS(e,t){return e.toLowerCase().includes(t)}function oS({open:e,projects:t,fileSearch:n,sessionSearch:r,onClose:i,onSwitchSession:a,onSwitchProject:o,onPreviewFile:s}){let c=Z(),{locale:l}=Nn(),u=l===`en`?`Plugins`:`插件`,d=Za(`cwd`),f=(0,g.useRef)(null),[p,m]=(0,g.useState)(``),h=(0,g.useDeferredValue)(p),[_,v]=(0,g.useState)(0),y=(0,g.useRef)(0),b=(0,g.useRef)(null),[x,S]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!e)return;$({type:`list_sessions`}),$({type:`list_projects`});let t=p.trim();if(t){let e=U_();y.current=e,w(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}requestAnimationFrame(()=>f.current?.select())},[e]);let[C,w]=(0,g.useState)(!1);(0,g.useEffect)(()=>{b.current&&clearTimeout(b.current);let e=h.trim();if(!e){w(!1),S(null);return}return b.current=setTimeout(()=>{let t=U_();y.current=t,w(!0),$({type:`search_files`,reqId:t,query:e}),$({type:`search_sessions`,reqId:t,query:e})},300),()=>{b.current&&clearTimeout(b.current)}},[h]),(0,g.useEffect)(()=>{n&&n.reqId===y.current&&S(n)},[n]);let T=h.trim().toLowerCase(),E=(0,g.useMemo)(()=>!T||!r||r.reqId!==y.current||!r.ok?[]:r.results,[r,T]),D=(0,g.useMemo)(()=>T?t.filter(e=>aS(e.path,T)).slice(0,10):[],[t,T]),O=(0,g.useMemo)(()=>!T||!x||!x.ok?[]:x.results,[x,T]);(0,g.useEffect)(()=>{x&&x.reqId===y.current&&r&&r.reqId===y.current&&y.current!==0&&w(!1)},[x,r]);let k=!!x&&x.ok&&x.truncated,[A,j]=(0,g.useState)([]);(0,g.useEffect)(()=>{if(!e)return;let t=h.trim();if(!t){j([]);return}let n=!1,r=[];try{let e=window,t=e.__piWebUiHost?.searchProviders?.list;if(typeof t==`function`){let n=t.call(e.__piWebUiHost);Array.isArray(n)&&(r=n)}else typeof dc==`function`&&(r=dc())}catch{r=[]}let i=r.filter(e=>e&&typeof e.id==`string`).map(e=>{if(typeof e.search==`function`)return e;try{let t=gc(e.id);return t&&typeof t.search==`function`?{...e,search:t.search}:null}catch{return null}}).filter(e=>!!e);if(i.length===0){j([]);return}return Promise.allSettled(i.map(e=>Promise.race([e.search(t),new Promise((e,t)=>setTimeout(()=>t(Error(`timeout`)),3e3))]).then(t=>({provider:e,items:Array.isArray(t)?t:[]}),()=>({provider:e,items:[]})))).then(e=>{if(n)return;let t=[];for(let n of e)if(n.status===`fulfilled`)for(let e of n.value.items){if(!e||typeof e!=`object`)continue;let r=e;typeof r.title==`string`&&typeof r.action==`string`&&t.push({providerId:n.value.provider.id,providerLabel:n.value.provider.label,title:r.title,...typeof r.hint==`string`?{hint:r.hint}:{},action:r.action})}j(t.slice(0,20))}),()=>{n=!0}},[e,h]);let ee=(0,g.useMemo)(()=>[...E.map(e=>({kind:`session`,path:e.path,anchors:e.anchors})),...D.map(e=>({kind:`project`,path:e.path})),...O.filter(e=>e.type===`file`).map(e=>({kind:`file`,path:e.path,name:e.name})),...A.map(e=>({kind:`plugin`,providerId:e.providerId,providerLabel:e.providerLabel,title:e.title,action:e.action}))],[E,D,O,A]);(0,g.useEffect)(()=>{v(0)},[h]);let M=(0,g.useCallback)(e=>{if(e){if(e.kind===`session`)a(e.path,e.anchors),i();else if(e.kind===`project`){o(e.path),$({type:`list_sessions`}),$({type:`list_projects`});let t=h.trim();if(t){let e=U_();y.current=e,w(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}}else e.kind===`plugin`?$s(e.providerId,e.action,e.action).catch(()=>{}):s(e.path,e.name)}},[a,o,s,h]);(0,g.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),i()):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.max(0,Math.min(e+1,ee.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),M(ee[_]))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[ee,_,M,i,e]);let te=E.length+D.length+O.length+A.length,N=(e,t,n)=>(0,X.jsxs)(`div`,{className:`gs-section-head`,children:[n,(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`em`,{children:t})]}),ne=-1;return e?(0,X.jsx)(`div`,{className:`modal-backdrop gs-backdrop`,onClick:i,children:(0,X.jsxs)(`div`,{className:`gs-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`gs-input-row`,children:[(0,X.jsx)(fe,{}),(0,X.jsx)(`input`,{ref:f,type:`text`,value:p,placeholder:c(`gsPlaceholder`),onChange:e=>m(e.target.value)}),(0,X.jsx)(`button`,{type:`button`,className:`gs-close`,title:c(`close`),onClick:i,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`gs-results`,children:[!T&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(`gsHint`)}),T&&te===0&&!k&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(C?`gsSearching`:`gsNoResults`)}),E.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(c(`gsSessions`),E.length,(0,X.jsx)(J,{})),E.map(e=>{ne++;let t=ne,n=e.name||e.path.split(/[\\/]/).pop()||e.path;return(0,X.jsxs)(`div`,{className:`gs-item-wrap`,children:[(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,onMouseEnter:()=>v(t),onClick:()=>M({kind:`session`,path:e.path,anchors:e.anchors}),children:[(0,X.jsxs)(`span`,{className:`gs-item-title`,children:[n,(0,X.jsx)(`em`,{className:`gs-item-meta`,children:e.messageCount})]}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.firstMessage})]}),(0,X.jsxs)(`button`,{type:`button`,className:`gs-quote`,title:c(`quoteConversation`),onClick:t=>{t.stopPropagation(),lr({attachments:[{path:``,key:`conv||${e.path}`,name:n,mode:`conversation`,sessionPath:e.path}]})},children:[`💬 `,c(`quoteConversationShort`)]})]},e.path)})]}),D.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(c(`gsProjects`),D.length,(0,X.jsx)(Re,{})),D.map(e=>{ne++;let t=ne,n=d&&e.path===d;return(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,onMouseEnter:()=>v(t),onClick:()=>M({kind:`project`,path:e.path}),children:[(0,X.jsxs)(`span`,{className:`gs-item-title`,children:[e.path.split(/[\\/]/).pop(),n&&(0,X.jsx)(`em`,{className:`gs-item-meta`,children:c(`gsCurrentProject`)})]}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.path})]},e.path)})]}),(O.length>0||T&&k)&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(c(`gsFiles`),O.length,(0,X.jsx)(Ve,{})),O.map(e=>{ne++;let t=ne;return(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,disabled:e.type===`dir`,title:e.type===`dir`?void 0:c(`gsOpenPreview`),onMouseEnter:()=>v(t),onClick:()=>{e.type===`file`&&M({kind:`file`,path:e.path,name:e.name})},children:[(0,X.jsx)(`span`,{className:`gs-item-title`,children:e.name}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.path})]},`${e.type}:${e.path}`)}),k&&(0,X.jsx)(`div`,{className:`gs-truncated`,children:c(`gsTruncated`)})]}),A.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(u,A.length,(0,X.jsx)(q,{})),A.map((e,t)=>{ne++;let n=ne;return(0,X.jsxs)(`button`,{type:`button`,className:n===_?`gs-item active`:`gs-item`,title:e.providerLabel,onMouseEnter:()=>v(n),onClick:()=>M({kind:`plugin`,providerId:e.providerId,providerLabel:e.providerLabel,title:e.title,action:e.action}),children:[(0,X.jsx)(`span`,{className:`gs-item-title`,children:e.title}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.hint??e.providerLabel})]},`${e.providerId}:${e.action}:${t}`)})]})]}),(0,X.jsxs)(`div`,{className:`gs-foot`,children:[(0,X.jsxs)(`span`,{children:[`↑↓ `,c(`gsNavigate`)]}),(0,X.jsxs)(`span`,{children:[`Enter `,c(`gsOpen`)]}),(0,X.jsxs)(`span`,{children:[`Esc `,c(`gsCloseHint`)]})]})]})}):null}function sS({entry:e,pluginView:t,onUiAction:n,onClose:r}){let i=Z(),a=e.label||e.id,o=e.kind===`view`;return(0,X.jsx)(Ky,{className:`plugin-modal`,title:a,icon:e.icon,onClose:r,children:(0,X.jsx)(`div`,{className:`modal-body plugin-modal-body`,children:o?t?(0,X.jsx)($v,{entry:t}):(0,X.jsx)(`div`,{className:`plugin-modal-loading`,children:i(`loading`)}):e.kind===`divider`?(0,X.jsx)(`hr`,{className:`plugin-modal-divider`}):(0,X.jsx)(`button`,{type:`button`,className:`btn primary plugin-modal-action`,onClick:()=>n?.(e),children:e.badge??a})})})}var cS=`未命名章节`;function lS(e){return String(e??``).trim().replace(/[\s\u3000]+/g,`-`).replace(/[^\p{L}\p{N}_-]+/gu,`-`).replace(/-{2,}/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`section`}function uS(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=lS(r||cS),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||cS}})}function dS(e){return e.length>=2}var fS=5e3,pS=`pi-web-ui:preview-toc`;function mS({file:e,content:t,onAddLines:n,onAttach:r,onClose:i,uiFilePreviewToolbar:a,onUiAction:o}){let s=Z(),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(!0),[T,E]=(0,g.useState)(!0),[D,O]=(0,g.useState)(!1),k=(0,g.useRef)(!1),[A,j]=(0,g.useState)(!0),[ee,N]=(0,g.useState)(!1),[ne,F]=(0,g.useState)(100),re=(0,g.useRef)(0),ie=(0,g.useRef)(!1),ae=(0,g.useRef)(null),[I,L]=(0,g.useState)(!1),[R,z]=(0,g.useState)(!1),oe=(0,g.useRef)(!1),B=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{ae.current&&clearTimeout(ae.current),B.current&&clearTimeout(B.current)},[]),(0,g.useEffect)(()=>{d(!0),l(null),p(null),b(!1),S(``),w(!0),E(!0),O(!1),k.current=!1,oe.current=!1,L(!1),z(!1),B.current&&clearTimeout(B.current),$({type:`read_file`,path:e.path})},[e.path]),(0,g.useEffect)(()=>{t&&t.path===e.path&&(l(t),y||S(t.text),d(!1),oe.current&&(oe.current=!1,B.current&&clearTimeout(B.current),L(!1),z(!1),b(!1),S(t.text),k.current&&(hS(e.name)&&w(!0),_S(e.name)&&E(!0)),p(null)))},[t,y,e.path]),(0,g.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){G();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&y){e.preventDefault(),W();return}let t=e.target,n=t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable);(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`&&!n&&(e.preventDefault(),le())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,c,y,x]),(0,g.useEffect)(()=>{let e=()=>{ie.current=!1,h(!1)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let V=(0,g.useMemo)(()=>{if(!c)return[];let e=c.text.split(`
|
|
680
|
-
`);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,fS)},[c]),H=c?.lines??0,se=H>fS,ce=(e,t)=>{if(t){let t=re.current>0?re.current:e;p({start:Math.min(t,e),end:Math.max(t,e)})}else re.current=e,p({start:e,end:e})},le=()=>{V.length!==0&&(re.current=1,p({start:1,end:V.length}))},ue=()=>{f&&(n(e.path,e.name,f.start,f.end),v(!0),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>v(!1),1400))},U=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated&&!gS(e.name),de=()=>{oe.current=!1,B.current&&clearTimeout(B.current),L(!1),z(!1),S(c?.text??``),b(!1),k.current&&(hS(e.name)&&w(!0),_S(e.name)&&E(!0))},fe=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;de();return}U&&c&&(k.current=hS(e.name)&&C||_S(e.name)&&T,hS(e.name)&&w(!1),_S(e.name)&&E(!1),p(null),S(c.text),b(!0))},W=()=>{y&&c&&U&&$({type:`write_file`,path:e.path,text:x})&&(oe.current=!0,z(!1),L(!0),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{oe.current=!1,L(!1),z(!0)},5e3))},G=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},K=e=>{F(Math.min(200,Math.max(50,e)))},me=f?f.end-f.start+1:0,he=c?.binary??!1,ge=c?.truncated??!1,q=c?.kind??`text`,_e=hS(e.name)||gS(e.name),ve=_S(e.name),ye=_e&&C&&!y&&q===`text`&&!he,xe=ve&&T&&!y&&q===`text`&&!he,[J,Se]=(0,g.useState)(()=>{try{return localStorage.getItem(pS)===`1`}catch{return!1}});(0,g.useEffect)(()=>{try{localStorage.setItem(pS,J?`1`:`0`)}catch{}},[J]);let[we,Te]=(0,g.useState)([]),[Ee,ke]=(0,g.useState)(``),Ae=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=Ae.current;if(!e||!ye){Te([]);return}let t=[...e.querySelectorAll(`h1, h2, h3, h4, h5, h6`)],n=uS(t.map(e=>({level:Number(e.tagName.slice(1)),label:e.textContent??``})));t.forEach((e,t)=>{e.id||=n[t].id}),Te(n)},[ye,c?.text,e.path]),(0,g.useEffect)(()=>{let e=Ae.current;if(!e||!J||!dS(we))return;let t=we.map(t=>e.querySelector(`#${CSS.escape(t.id)}`)).filter(e=>e!==null);if(t.length===0)return;let n=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0];t?.target.id&&ke(t.target.id)},{rootMargin:`0px 0px -70% 0px`});for(let e of t)n.observe(e);return()=>n.disconnect()},[we,J]);let je={"host:fp-md":_e&&q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach markdown ${C?`on`:``}`,"data-tip":s(C?`showMarkdownSource`:`showMarkdownPreview`),disabled:y,onClick:()=>w(e=>!e),children:C?(0,X.jsx)(Ue,{}):(0,X.jsx)(nt,{})}):null,"host:fp-toc":ye&&dS(we)?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach toc ${J?`on`:``}`,"data-tip":s(J?`previewTocHide`:`previewTocShow`),onClick:()=>Se(e=>!e),children:(0,X.jsx)(De,{})}):null,"host:fp-html":ve&&q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach html ${T?`on`:``}`,"data-tip":s(T?`showHtmlSource`:`showHtmlPreview`),disabled:y,onClick:()=>E(e=>!e),children:T?(0,X.jsx)(nt,{}):(0,X.jsx)(Ue,{})}):null,"host:fp-edit":q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(ge?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!U&&!y,onClick:fe,children:(0,X.jsx)(Y,{})}):null,"host:fp-wrap":q===`text`&&!he&&!ye&&!xe?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${A?`on`:``}`,"data-tip":s(A?`disableWrap`:`enableWrap`),onClick:()=>j(e=>!e),children:(0,X.jsx)(et,{})}):null,"host:fp-zoom":q===`text`&&c?(0,X.jsxs)(`span`,{className:`fp-zoom`,children:[(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-out`,"data-tip":s(`zoomOut`),disabled:ne<=50,onClick:()=>K(ne-10),children:(0,X.jsx)(M,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>F(100),children:[ne,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:ne>=200,onClick:()=>K(ne+10),children:(0,X.jsx)(te,{})})]}):null,"host:fp-ref":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach ref`,"data-tip":s(`referenceTip`),onClick:()=>r(e.path,e.name,`reference`),children:(0,X.jsx)(Oe,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${ee?`on`:``}`,"data-tip":s(ee?`exitFullscreen`:`fullscreen`),onClick:()=>N(e=>!e),children:ee?(0,X.jsx)(be,{}):(0,X.jsx)(Ce,{})}),"host:fp-close":null},Me=a===void 0?[`host:fp-md`,`host:fp-toc`,`host:fp-html`,`host:fp-edit`,`host:fp-wrap`,`host:fp-zoom`,`host:fp-ref`,`host:fp-full`].map(e=>({id:e,source:`host`})):a.filter(e=>!e.hidden&&e.id!==`host:fp-close`),Ne=e=>gn(fn(`/api/file?clientId=${encodeURIComponent(Fl())}&path=${encodeURIComponent(e)}`)),Pe=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return gn(fn(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(Fl())}${D?`&allowJs=1`:``}`))};return(0,X.jsx)(`div`,{className:`fp-overlay ${ee?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&G()},children:(0,X.jsxs)(`div`,{className:`fp ${ee?`fullscreen`:``}`,style:{"--fp-zoom":ne/100},children:[(0,X.jsxs)(`div`,{className:`fp-head`,onDoubleClick:e=>{let t=e.target;t&&!t.closest(`button, a, input`)&&N(e=>!e)},children:[(0,X.jsx)(`span`,{className:`fp-name`,title:e.path,children:e.name}),(0,X.jsx)(`span`,{className:`fp-path`,children:e.path}),(0,X.jsxs)(`span`,{className:`fp-meta`,children:[c&&q===`text`&&!he&&s(`fileLines`,{n:H}),c&&` · ${_m(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:ag(Me,je,o)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),"aria-label":s(`close`),onClick:G,children:(0,X.jsx)(P,{})})]}),ge&&q===`text`&&!he&&(0,X.jsx)(`div`,{className:`fp-notice`,children:gS(e.name)?s(`previewLinesTruncated`,{n:V.length}):s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&q===`none`&&!he&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&q===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap clickable`,onClick:G,title:s(`clickToCloseImage`),children:(0,X.jsx)(`img`,{className:`fp-media fp-media-clickable`,src:Ne(e.path),alt:e.name,onClick:G,title:s(`clickToCloseImage`)})}),!u&&q===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:Ne(e.path),controls:!0,preload:`metadata`})}),!u&&xe&&c&&(0,X.jsxs)(`div`,{className:`fp-html`,children:[(0,X.jsxs)(`div`,{className:`fp-html-bar`,children:[(0,X.jsx)(`span`,{className:`fp-html-hint`,title:s(D?`htmlJsOnTip`:`htmlJsOffTip`),children:s(D?`htmlJsOn`:`htmlJsOff`)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-html-js ${D?`on`:``}`,"data-tip":s(D?`htmlDisableJs`:`htmlEnableJs`),onClick:()=>O(e=>!e),children:s(D?`htmlDisableJs`:`htmlEnableJs`)}),(0,X.jsxs)(`a`,{className:`fp-html-btn fp-html-external`,href:Pe(e.path),target:`_blank`,rel:`noopener noreferrer`,title:s(`openInNewTab`),children:[(0,X.jsx)(Ge,{}),(0,X.jsx)(`span`,{children:s(`openInNewTab`)})]})]}),(0,X.jsx)(`iframe`,{className:`fp-html-frame`,src:Pe(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&ye&&c&&(0,X.jsx)(`div`,{className:gS(e.name)?`fp-markdown msg-text fp-office`:`fp-markdown msg-text`,children:(0,X.jsxs)(`div`,{className:J&&dS(we)?`fp-toc-layout`:void 0,children:[J&&dS(we)&&(0,X.jsx)(`nav`,{className:`fp-toc`,"aria-label":s(`previewTocLabel`),children:we.map(e=>(0,X.jsx)(`a`,{className:`l${Math.min(e.level,6)}${e.id===Ee?` on`:``}`,href:`#${e.id}`,title:e.label,onClick:t=>{t.preventDefault(),Ae.current?.querySelector(`#${CSS.escape(e.id)}`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:e.label},e.id))}),(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,ref:Ae,children:(0,X.jsx)(Af,{text:c.text})})]})}),!u&&he&&q!==`image`&&q!==`video`&&c&&(0,X.jsxs)(`div`,{className:`fp-hex-wrap`,children:[(0,X.jsxs)(`div`,{className:`fp-notice`,children:[s(`binaryFile`),c.truncated&&s(`binaryHexTruncated`)]}),(0,X.jsx)(`pre`,{className:`fp-hex`,children:c.text})]}),!u&&y&&q===`text`&&!he&&c&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{className:`fp-editor ${A?``:`no-wrap`}`,value:x,onChange:e=>S(e.target.value),wrap:A?`soft`:`off`,spellCheck:!1,autoFocus:!0}),R&&(0,X.jsx)(`div`,{className:`fp-notice`,role:`alert`,children:s(`saveResultUnknown`)})]}),!u&&!ye&&!xe&&!y&&q===`text`&&!he&&c&&V.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!ye&&!xe&&!y&&q===`text`&&!he&&V.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${m?`dragging`:``} ${A?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[V.map((e,t)=>{let n=t+1,r=f!==null&&n>=f.start&&n<=f.end;return(0,X.jsxs)(`div`,{className:`fp-line ${r?`sel`:``}`,onMouseDown:e=>{e.button===0&&(ce(n,e.shiftKey),ie.current=!0,h(!0))},onMouseEnter:()=>{ie.current&&ce(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),se&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:fS})})]}),(y||!ye&&!xe&&q===`text`)&&(0,X.jsx)(`div`,{className:`fp-foot`,children:y?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:s(`editFile`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:fe,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:I||x===(c?.text??``),onClick:W,children:[(0,X.jsx)(pe,{}),` `,s(`saveFile`)]})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:f?s(`selectedRange`,{n:me,start:f.start,end:f.end}):s(`selectLinesHint`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:V.length===0,onClick:le,children:s(`selectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!f,onClick:()=>p(null),children:s(`clearSelection`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!f||he,onClick:ue,children:[_?(0,X.jsx)(ft,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function hS(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function gS(e){let t=e.toLowerCase();return t.endsWith(`.docx`)||t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`)}function _S(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function vS({file:e,plugin:t,declaration:n,epoch:r,send:i,onClose:a,onFallback:o}){let s=Z(),c=(0,g.useRef)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(!1),p=(0,g.useRef)(o);p.current=o;let m=n.label??t.name;return(0,g.useEffect)(()=>{let r=c.current;if(!r)return;let a=!1,o;return u(null),f(!1),(async()=>{try{let s=await Dy({plugin:t,declaration:n});if(a)return;if(!s)throw Error(`插件没有提供可用的文件查看器`);let c=`/plugins-api/${encodeURIComponent(t.id)}`,l={...il(t.id,i),file:e,apiUrl:(e,t)=>{let n=String(e??``).startsWith(`/`)?String(e):`/${String(e??``)}`,r=new URLSearchParams;for(let[e,n]of Object.entries(t??{}))n!==void 0&&r.set(e,String(n));let i=r.toString();return gn(fn(`${c}${n}${i?`?${i}`:``}`))}};o=s.handler.mount(r,e,l),a||f(!0)}catch(e){a||(console.error(`[plugin:${t.id}] file handler failed:`,e),p.current())}})(),()=>{if(a=!0,typeof o==`function`)try{o()}catch(e){console.error(`[plugin:${t.id}] file handler cleanup failed:`,e)}r.textContent=``}},[e,t,n,r,i]),(0,X.jsx)(Ky,{className:`plugin-file-preview`,title:m,icon:t.icon,onClose:a,children:(0,X.jsxs)(`div`,{className:`modal-body plugin-file-preview-body`,children:[(0,X.jsx)(`div`,{className:`plugin-file-preview-file`,title:e.path,children:e.name}),l?(0,X.jsx)(`div`,{className:`plugin-file-preview-error`,children:l}):null,!l&&!d?(0,X.jsx)(`div`,{children:s(`loading`)}):null,(0,X.jsx)(`div`,{ref:c,className:`plugin-file-preview-host`})]})})}var yS=.4,bS=1.05;function xS(e){return Math.min(300,e*.86)}function SS(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function CS(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function wS(e,t){return e===`left`?t:-t}function TS(e,t){return Math.max(-e,Math.min(0,-e+t))}function ES(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function DS(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:ES(r*bS,n,t)>=yS}var OS=new Set([`auto`,`scroll`,`overlay`]);function kS(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&OS.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function AS(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function jS(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,g.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0],i=SS(r.clientX,window.innerWidth,n);i&&!kS(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0],d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=CS(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=xS(window.innerWidth),h=m*bS;let i=e.querySelector(a?a(r):`.panel-drawer.drawer-${r}`);if(!i){s=null;return}g=i,_=o===null?null:e.querySelector(o??`.drawer-backdrop`),i.classList.add(`drawer-dragging`)}let y=g;if(!y)return;f=wS(r,d);let b=TS(h,f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(ES(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?DS({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(AS(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}function MS(e,t,n,r,i){let a=new Map;for(let e of r)a.set(e.id,!!e.isStreaming);if(t&&a.set(t,n),e===null)return{startCue:!1,finishedConvs:[],nextMap:a};let o=!1;if(t&&(i===void 0||i===t)){let n=e.get(t),r=a.get(t)??!1;n===!1&&r===!0&&(o=!0)}let s=[];for(let[n,i]of e.entries())if(i&&a.has(n)&&!a.get(n)){let e=r.find(e=>e.id===n);s.push({id:n,title:e?.title,isActive:n===t})}return{startCue:o,finishedConvs:s,nextMap:a}}var NS=(0,g.lazy)(()=>Pc(()=>import(`./TerminalPanel-CpfPFx32.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function PS({notice:e,onDismiss:t}){let n=Z(),{locale:r}=Nn(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(a)return;let n=setTimeout(()=>t(e.id),hl(e.level));return()=>clearTimeout(n)},[a,e.id,e.level,t]);let s=e.level===`error`?Tt:e.level===`warning`?wt:je;return(0,X.jsxs)(`div`,{className:`notice notice-${e.level}${a?` paused`:``}`,role:`status`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onClick:()=>{window.getSelection?.()?.toString()||t(e.id)},children:[(0,X.jsx)(s,{className:`notice-icon`}),(0,X.jsx)(`span`,{className:`notice-text`,children:i}),(0,X.jsx)(`button`,{type:`button`,className:`notice-close`,title:n(`close`),onClick:n=>{n.stopPropagation(),t(e.id)},children:(0,X.jsx)(P,{})})]})}var FS=[],IS=180,LS=520,RS=240,zS=e=>`pi-web-ui:${e}-panel-width`;function BS(e){try{let t=Number(localStorage.getItem(zS(e)));return Number.isFinite(t)&&t>=IS&&t<=LS?t:RS}catch{return RS}}var VS=e=>`pi-web-ui:${e}-panel-collapsed`;function HS(e){try{return localStorage.getItem(VS(e))===`1`}catch{return!1}}function US({side:e,width:t,onResize:n}){let r=Z(),i=(0,g.useCallback)(r=>{r.preventDefault();let i=r.clientX,a=t,o=a,s=t=>{let r=e===`left`?t.clientX-i:i-t.clientX;o=Math.min(LS,Math.max(IS,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`);try{localStorage.setItem(zS(e),String(o))}catch{}};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),document.body.classList.add(`panel-resizing`)},[e,t,n]);return(0,X.jsx)(`div`,{className:`resize-handle resize-${e}`,title:r(`dragToResize`),onPointerDown:i,onDoubleClick:()=>n(RS)})}function WS({side:e,onClick:t}){let n=Z();return(0,X.jsx)(`button`,{type:`button`,className:`panel-rail panel-rail-${e}`,title:n(`expandPanel`),onClick:t,children:e===`left`?(0,X.jsx)(ot,{}):(0,X.jsx)(st,{})})}var GS=`pi-web-ui:plugin-path-grants`,KS=e=>e?`${GS}:${e}`:GS;function qS(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function JS(e){try{let t=KS(e);if(localStorage.getItem(t)!==null)return qS(localStorage.getItem(t));if(!e)return[];let n=qS(localStorage.getItem(GS));return localStorage.setItem(t,JSON.stringify(n)),n}catch{return[]}}function YS(e,t){try{let n=[...new Set([...JS(t),e])];localStorage.setItem(KS(t),JSON.stringify(n))}catch{}}function XS(){let e=Z(),{locale:t}=Nn(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=Xl(),s=(0,g.useRef)(!1);(0,g.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:mx[t]??mx.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=Fb();(0,g.useEffect)(()=>{let t=l?Ob(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,g.useState)([]);(0,g.useEffect)(()=>(ar(e=>d(t=>e_(t,e))),()=>ar(null)),[]);let[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(null),_=(0,g.useRef)(!1),v=(0,g.useRef)(null);(0,g.useEffect)(()=>{_.current=f!==null,v.current=m},[f,m]);let y=(0,g.useCallback)((e,t)=>{let n=Ey(t);if(n){p(null),h({file:{path:e,name:t},plugin:n.plugin,declaration:n.declaration});return}h(null),p({path:e,name:t})},[]);(0,g.useEffect)(()=>(Sf({open:e=>y(e.path,e.name),isOpen:()=>_.current||v.current!==null}),()=>Sf(null)),[y]);let[b,x]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let e=()=>x(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[S,C]=(0,g.useState)(`chat`),w=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(S.startsWith(`plugin:`)?`plugins`:S)?S:`chat`,T=(0,g.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),E=(0,g.useMemo)(()=>{let r=[],i=pa(na(n.plugins),{locale:t,t:t=>e(t),disabledPlugins:n.settings?.disabledPlugins??[],layout:n.settings?.uiLayout,diagnostics:r});for(let e of r)console.warn(`[ui-slot] ${e.pluginId?`[${e.pluginId}] `:``}${e.message}`);return i},[n.plugins,n.settings?.disabledPlugins,n.settings?.uiLayout,t,e]),D=(0,g.useMemo)(()=>E[`topbar.primary`].filter(e=>!e.hidden),[E]),O=(0,g.useMemo)(()=>[...E[`topbar.primary`].filter(e=>e.hidden),...E[`topbar.overflow`]],[E]),k=(0,g.useMemo)(()=>E[`leftpanel.sessions`].filter(e=>!e.hidden),[E]),A=(0,g.useMemo)(()=>E[`leftpanel.projects.actions`].filter(e=>!e.hidden),[E]),j=(0,g.useMemo)(()=>E[`leftpanel.project`].filter(e=>!e.hidden),[E]),ee=(0,g.useMemo)(()=>E[`leftpanel.running.actions`].filter(e=>!e.hidden),[E]),M=(0,g.useMemo)(()=>E[`leftpanel.history.actions`].filter(e=>!e.hidden),[E]),te=E[`leftpanel.sections`],N=(0,g.useMemo)(()=>E[`leftpanel.running`].filter(e=>!e.hidden),[E]),ne=(0,g.useMemo)(()=>E[`leftpanel.history`].filter(e=>!e.hidden),[E]),F=(0,g.useMemo)(()=>E[`terminal.toolbar`].filter(e=>!e.hidden),[E]),re=(0,g.useMemo)(()=>E[`scm.toolbar`].filter(e=>!e.hidden),[E]),ie=(0,g.useMemo)(()=>E[`goalbar.actions`].filter(e=>!e.hidden),[E]),ae=(0,g.useMemo)(()=>E[`chat.header`].filter(e=>!e.hidden),[E]),I=(0,g.useMemo)(()=>E[`chat.empty`].filter(e=>!e.hidden),[E]),L=(0,g.useMemo)(()=>E[`file.preview.toolbar`].filter(e=>!e.hidden),[E]),R=(0,g.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(n=>[n.id,Z_(n,t,e).name])),[n.dshPresets,t]),z=(0,g.useMemo)(()=>E[`notice.actions`].filter(e=>!e.hidden),[E]),oe=(0,g.useMemo)(()=>E[`sidebar.left`]??[],[E]),B=(0,g.useMemo)(()=>E[`sidebar.right`]??[],[E]),V=(0,g.useCallback)((t,n,i)=>{if(t.id===`host:msg-fork`){i?.id&&r({type:`fork_session`,messageId:i.id,position:`before`});return}if(t.id===`host:msg-rollback`){i?.id&&Im({messageId:i.id});return}let o=(t.action??``).trim();if(t.kind===`view`||(!o||o===`view`)&&t.source!==`host`){C(t.view??`plugin:${t.source.startsWith(`plugin:`)?t.source.slice(7):``}`);return}o&&$s(t.source.startsWith(`plugin:`)?t.source.slice(7):``,o,t.id,{...n===void 0?{}:{value:n},...i===void 0?{}:{target:i},loadBundle:async e=>{let t=G.current.plugins.find(t=>t.id===e);return t?nl(t,G.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),H=(0,g.useCallback)(e=>{let t=n.plugins.find(t=>t.id===e.source.slice(7));return t?(0,X.jsx)(Ru,{plugin:t,epoch:n.pluginsEpoch,send:r,className:`lp-plugin-page`}):null},[n.plugins,n.pluginsEpoch,r]),se=(0,g.useCallback)((t,n)=>{n.action&&$s(t.pluginId,n.action,n.id,{target:{id:n.id,kind:`plugin-running`,label:n.title},loadBundle:async e=>{let t=G.current.plugins.find(t=>t.id===e);return t?nl(t,G.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[ce,le]=(0,g.useState)([]);(0,g.useEffect)(()=>Yc(le),[]);let[ue,U]=(0,g.useState)([]);(0,g.useEffect)(()=>qc(U),[]);let[de,fe]=(0,g.useState)(null),W=de?E[`modal.dialog`].find(e=>e.id===de&&!e.hidden):void 0,pe=(0,g.useMemo)(()=>{if(!W||W.kind!==`view`)return``;let e=W.view??``;return e.startsWith(`plugin:`)?e.slice(7):W.source.startsWith(`plugin:`)?W.source.slice(7):``},[W]);(0,g.useEffect)(()=>{if(!W||!pe||ce.some(e=>e.info.id===pe))return;let e=G.current.plugins.find(e=>e.id===pe);e&&nl(e,G.current.pluginsEpoch)},[W,pe,ce,n.pluginsEpoch]),(0,g.useEffect)(()=>{Zd(r),Qd(T,n.pluginsEpoch),of(T,n.pluginsEpoch),Ty(T,n.pluginsEpoch),rl(T,n.pluginsEpoch)},[T,n.pluginsEpoch,r]);let G=(0,g.useRef)(n);G.current=n;let me=(0,g.useRef)(C);me.current=C;let he=(0,g.useRef)(E);he.current=E,(0,g.useEffect)(()=>(Ks(Gs({send:r,isReady:()=>!!G.current.state,setView:e=>me.current(e),getCwd:()=>G.current.state?.cwd??``,getWorkspaceRoots:()=>G.current.state?.workspaceRoots??[],listSessions:()=>{let e=G.current,t=e.state?.cwd??``;return[...e.conversations.map(e=>({id:e.id,title:e.title,cwd:e.cwd||t,kind:`running`,isStreaming:e.isStreaming})),...e.sessions.map(e=>({id:e.path,title:e.name||e.firstMessage||e.path,cwd:t,kind:`history`}))]},getConversationId:()=>G.current.state?.conversationId??null,isConversationBlank:()=>(G.current.state?.messages.length??0)===0,listModels:()=>G.current.models.map(e=>({id:e.id,provider:e.provider,name:e.name,vision:e.vision,reasoning:e.reasoning})),getCurrentModelId:()=>{let e=G.current.state?.model;return e?`${e.provider}/${e.id}`:null},listProjects:()=>G.current.projects.map(e=>e.path),grantedPaths:JS,grantPath:YS,confirm:e=>new Promise(t=>{if(Ue.current){t(!1);return}let n={path:e.path,resolve:t};Ue.current=n,He(n)}),openModal:e=>{let t=String(e??``).trim();if(!t)return!1;let n=he.current[`modal.dialog`].find(e=>e.id===t);return!n||n.hidden?!1:(fe(t),!0)},closeModal:()=>fe(null),dialogConfirm:e=>new Promise(t=>{if(Y.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Y.current=n,Ge(n)}),select:e=>new Promise(t=>{if(Y.current){t({ok:!1,error:`busy`});return}let n={kind:`select`,title:e.title,options:e.options,...e.multi?{multi:!0}:{},resolve:t};Y.current=n,qe([]),Ge(n)}),input:e=>new Promise(t=>{if(Y.current){t({ok:!1,error:`busy`});return}let n={kind:`input`,title:e.title,...typeof e.placeholder==`string`?{placeholder:e.placeholder}:{},...typeof e.initial==`string`?{initial:e.initial}:{},resolve:t};Y.current=n,Ye(e.initial??``),Ge(n)}),notifyAction:e=>new Promise(t=>{try{let n=Qe.current;Qe.current=null,Ze(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Qe.current=r,Ze(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=G.current.plugins.find(t=>t.id===e);return t?nl(t,G.current.pluginsEpoch):Promise.resolve(!1)}})),()=>Ks(null)),[r]);let[ge,q]=(0,g.useState)(()=>BS(`left`)),[_e,ve]=(0,g.useState)(()=>BS(`right`)),ye=(0,g.useCallback)(e=>q(e),[]),be=(0,g.useCallback)(e=>ve(e),[]),[xe,J]=(0,g.useState)(()=>HS(`left`)),[Se,Ce]=(0,g.useState)(()=>HS(`right`)),we=(0,g.useCallback)(()=>{J(e=>{try{localStorage.setItem(VS(`left`),e?`0`:`1`)}catch{}return!e})},[]),Te=(0,g.useCallback)(()=>{Ce(e=>{try{localStorage.setItem(VS(`right`),e?`0`:`1`)}catch{}return!e})},[]),[Ee,De]=(0,g.useState)(null),Oe=(0,g.useRef)(null),[ke,Ae]=(0,g.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,g.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>Ae(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),jS({enabled:ke&&w===`chat`,open:Ee,onOpenChange:De,container:Oe,backdropSelector:`.drawer-backdrop.persistent`});let[je,Me]=(0,g.useState)(!1),[Ne,Pe]=(0,g.useState)(!1),[Fe,Ie]=(0,g.useState)(!1),[Le,Re]=(0,g.useState)(),[ze,Be]=(0,g.useState)(null),[Ve,He]=(0,g.useState)(null),Ue=(0,g.useRef)(null),[We,Ge]=(0,g.useState)(null),Y=(0,g.useRef)(null),[Ke,qe]=(0,g.useState)([]),[Je,Ye]=(0,g.useState)(``),[Xe,Ze]=(0,g.useState)(null),Qe=(0,g.useRef)(null),[$e,et]=(0,g.useState)(()=>new Set),tt=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),et(t=>new Set(t).add(e))},nt=n.pathRequests.find(e=>!$e.has(e.id))??null,[rt,it]=(0,g.useState)(()=>new Set),at=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),it(t=>new Set(t).add(e))},ot=n.permRequests.find(e=>!rt.has(e.id))??null,st=wb(),[ct,lt]=(0,g.useState)(!1),[ut,dt]=(0,g.useState)(!1),[ft,pt]=(0,g.useState)(!1),[mt,ht]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!mt)return;let e=setTimeout(()=>ht(null),15e3);return()=>clearTimeout(e)},[mt]);let[gt,_t]=(0,g.useState)(null),vt=(0,g.useRef)(null),yt=(0,g.useRef)(null),bt=n.state?.sessionId??``,xt=(0,g.useRef)(bt);xt.current=bt;let St=(0,g.useRef)(n.ready);St.current=n.ready,(0,g.useEffect)(()=>{let e=()=>{let e=es(window.location.hash);if(e){if(e.messageId?_t({sessionId:e.sessionId,messageId:e.messageId}):_t(null),!St.current||!xt.current){vt.current=e.sessionId;return}xt.current!==e.sessionId&&(yt.current=e.sessionId,C(`chat`),r({type:`switch_session`,path:``,sessionId:e.sessionId}))}};return e(),window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[r]),(0,g.useEffect)(()=>{let e=yt.current;if(e&&n.notices.some(t=>t.text.includes(e)&&(t.text.includes(`未找到会话`)||t.text.includes(`Session not found`)))&&(yt.current=null,_t(null),bt)){let e=ts({sessionId:bt});window.location.hash!==e&&window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${e}`)}},[n.notices,bt]),(0,g.useEffect)(()=>{if(!n.ready||!bt)return;if(vt.current){let e=vt.current;if(vt.current=null,e!==bt){yt.current=e,C(`chat`),r({type:`switch_session`,path:``,sessionId:e});return}}if(yt.current){if(bt===yt.current)yt.current=null;else return}let e=es(window.location.hash),t=e?.sessionId===bt?e.messageId:void 0,i=ts({sessionId:bt,...t?{messageId:t}:{}});window.location.hash!==i&&window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${i}`)},[n.ready,bt,r]),(0,g.useEffect)(()=>{let t=t=>{let i=t.detail,a=i?.title||e(`pluginCommandFallback`),s=i?.command;if(!s||!n.ready)return;let c={name:a,command:s,cwd:"${pwd}"},l=n.terminals.find(e=>e.title===a);if(l)o.restart(l.id),r({type:`run_command`,terminalId:l.id,conversationId:l.conversationId,command:c,cols:80,rows:24});else{let e=jt();o.create({id:e,conversationId:n.activeConversationId||n.state?.conversationId||``,title:a,cwd:n.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:c})}C(`terminal`)};window.addEventListener(`pi-web-ui:plugin-run-command`,t);let i=e=>{let t=e.detail;typeof t==`string`&&t&&r({type:`switch_conversation`,id:t})};return window.addEventListener(`pi-web-ui:switch-conversation`,i),()=>{window.removeEventListener(`pi-web-ui:plugin-run-command`,t),window.removeEventListener(`pi-web-ui:switch-conversation`,i)}},[n,o,r]),(0,g.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),dt(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[Ct,wt]=(0,g.useState)(ob),[Tt,Et]=(0,g.useState)(Gt),{themes:Dt,theme:Ot,switchTheme:kt,reloadThemes:At}=_f();ex(),(0,g.useEffect)(()=>{try{typeof Ec==`function`&&Ec(Ot??``)}catch{}},[Ot]),(0,g.useEffect)(()=>{try{typeof Dc==`function`&&Dc(t)}catch{}},[t]),(0,g.useEffect)(()=>{try{typeof Oc==`function`&&Oc(w)}catch{}},[w]),(0,g.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof Sc==`function`&&Sc(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,g.useEffect)(()=>{if(!We)return;let e=e=>{if(e.key!==`Escape`)return;let t=Y.current;Y.current=null,Ge(null);try{if(!t)return;t.kind===`confirm`?t.resolve(!1):t.resolve({ok:!1})}catch{}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[We]),(0,g.useEffect)(()=>{if(!Xe)return;let e=setTimeout(()=>{let e=Qe.current;Qe.current=null,Ze(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[Xe]);let Mt=(0,g.useRef)(null),Nt=(0,g.useRef)(null),Pt=(0,g.useRef)(n.state?.messages);Pt.current=n.state?.messages;let Ft=(0,g.useRef)(new Set),It=(0,g.useRef)(new Set),Lt=(0,g.useRef)(new Set),Rt=(0,g.useRef)(0),zt=(0,g.useRef)(!1),Bt=(0,g.useRef)(n.terminals);(0,g.useEffect)(()=>{sb(Ct)},[Ct]),(0,g.useEffect)(()=>{Kt(Tt)},[Tt]),(0,g.useEffect)(()=>{let e=Bt.current;Bt.current=n.terminals;for(let t of n.terminals){let n=t.command?.command??``;e.find(e=>e.id===t.id)?.running&&!t.running&&(n.startsWith(`pi remove `)?r({type:`extensions_reload`}):n.startsWith(`pi-web-ui install `)||n.startsWith(`pi-web-ui uninstall `)?r({type:`plugins_reload`}):n.startsWith(`npm i -g `)&&(r({type:`extensions_reload`}),r({type:`plugins_reload`}),r({type:`check_updates_all`,force:!0})))}},[n.terminals,r]),(0,g.useEffect)(()=>{let t=n.state?.conversationId??null,r=MS(Mt.current,t,n.state?.isStreaming??!1,n.conversations,Nt.current);if(Mt.current=r.nextMap,Nt.current=t,r.startCue&&fb(`start`,Ct),r.finishedConvs.length>0){fb(`done`,Ct);let t=r.finishedConvs.find(e=>e.isActive);if(t&&(ai(e(`notifyDoneTitle`),e(`notifyDoneBody`)),Tt.enabled&&!Kr($r()))){if(Tt.readReplies){let t=Xt(Pt.current);t?on(t,Tt):Tt.announce&&on(e(`ttsAnnounceDone`),Tt)}else Tt.announce&&on(e(`ttsAnnounceDone`),Tt)}for(let t of r.finishedConvs.filter(e=>!e.isActive)){let n=t.title?`${t.title}:${e(`notifyDoneBody`)}`:e(`notifyDoneBody`);ai(e(`notifyDoneTitle`),n)}!t&&Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceDone`),Tt)}},[n.state?.conversationId,n.state?.isStreaming,n.conversations,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.dialog?.id??null;if(t!==null&&!Ft.current.has(t)){if(Ft.current.add(t),Ft.current.size>64){let e=Ft.current.values().next().value;e!==void 0&&Ft.current.delete(e)}fb(`question`,Ct),ai(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceQuestion`),Tt)}},[n.dialog,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null,i=!1;t!==null&&!It.current.has(t)&&(It.current.add(t),i=!0),r!==null&&!It.current.has(r)&&(It.current.add(r),i=!0);for(let e of n.conversations){if(!e.hasQuestion)continue;let n=e.questionId?`q:${e.questionId}`:`conv-q:${e.id}`;It.current.has(n)||(It.current.add(n),e.questionId&&It.current.add(e.questionId),t!==e.questionId&&(i=!0))}if(It.current.size>64){let e=It.current.values().next().value;e!==void 0&&It.current.delete(e)}i&&(fb(`question`,Ct),ai(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceQuestion`),Tt))},[n.question,n.remoteQuestion,n.conversations,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.approval,r=t?.id??null;if(r!==null&&!Lt.current.has(r)){if(Lt.current.add(r),Lt.current.size>64){let e=Lt.current.values().next().value;e!==void 0&&Lt.current.delete(e)}fb(`approval`,Ct);let n=typeof t?.toolName==`string`?t.toolName:``;ai(e(`notifyApprovalTitle`),n?e(`notifyApprovalBodyTool`,{tool:n}):e(`notifyApprovalBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceApproval`),Tt)}},[n.approval,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==Rt.current&&(Rt.current=t.id,fb(`error`,Ct),ai(e(`notifyErrorTitle`),e(`notifyErrorBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceError`),Tt))},[n.notices,Ct,Tt,e]);let Vt=(0,g.useRef)(new Set);(0,g.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||Vt.current.has(t.id))continue;Vt.current.add(t.id);let e=``;for(let n of t.content??[]){if(n.type!==`text`)continue;let t=/🔗 已自动在浏览器打开\]\((\/(?!\/)[^)\s]+)\)/.exec(n.text??``);if(t?.[1]){e=t[1];break}}if(!e)continue;let n=null;try{let t=new URL(fn(e),window.location.href);t.origin===window.location.origin&&document.hasFocus()&&(n=window.open(t.href,`_blank`,`noopener`))}catch{n=null}n||a(`info`,e)}},[n.state?.messages,a]);let Ht=(e,t,n,r=!1,i,a=!1)=>{let o=`${e}|${n}|${i?`${i.start}-${i.end}`:``}`;d(a=>a.some(e=>`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`===o)?a:[...a,{path:e,name:t,mode:n,isDir:r,...i?{lines:i}:{}}]);let s=n===`page`?t:e;!a&&s&&nr(`@${s} `)},Ut=e=>{let t=``;d(n=>n.filter(n=>{let r=n.key?n.key===e:n.mode===`conversation`?`conv|${n.conversationId??``}|${n.sessionPath??``}`===e:n.path===e;return r&&!t&&(t=n.mode===`page`||n.mode===`conversation`?n.name:n.path),!r})),t&&rr(`@${t}`)},Wt=(0,g.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&De(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&C(e=>e===`chat`?e:`chat`),r(e)),[r]),qt=(0,g.useRef)(new Set),Jt=n.activeConversationId||n.state?.conversationId||``;(0,g.useEffect)(()=>{let t=n.conversations.filter(e=>e.hasQuestion),r=new Set(t.map(e=>e.id)),i=new Set(t.map(e=>e.questionId).filter(Boolean));for(let e of qt.current)i.has(e)||qt.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===Jt){ly(t,{silent:!0});continue}n.questionId&&qt.current.has(n.questionId)||cy({id:t,type:`question`,title:n.title||e(`chat`),message:n.questionTitle||e(`waitingQuestionBadge`),persistent:!0,dismissible:!0,data:{conversationId:n.id,questionId:n.questionId},onClose:()=>{n.questionId&&qt.current.add(n.questionId)},onClick:()=>{Wt({type:`switch_conversation`,id:n.id}),ly(t,{silent:!0})}})}uy(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===Jt:!1},{silent:!0})},[n.conversations,Jt,Wt,e]);let Yt=(0,g.useRef)(0),Zt=(0,g.useRef)(0),Qt=(0,g.useCallback)(t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-Zt.current>1e4&&(Zt.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++Yt.current}`;d(e=>[...e,{path:``,key:i,name:t.name,imageData:t.data,mimeType:t.mimeType}])},[n.state?.model,a,e]),$t=(0,g.useCallback)(async t=>{for(let n of t){let t=await dm(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}Qt(t)}},[Qt,a,e]),en=20971520,tn=(0,g.useRef)(0),nn=(0,g.useCallback)(async t=>{if(t.size>en){a(`warning`,e(`fileTooLarge`,{name:t.name,size:en/1024/1024}));return}let n;try{n=(await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(t)})).replace(/^data:[^;]*;base64,/,``)}catch{a(`error`,e(`fileLoadFailed`,{name:t.name}));return}let r=`upload-${++tn.current}`;d(e=>[...e,{path:``,key:r,name:t.name,fileData:n,size:t.size,mimeType:t.type||void 0}])},[en,a,e]),rn=(0,g.useCallback)(async e=>{for(let t of e)um(t.type)?await $t([t]):await nn(t)},[$t,nn]),an=(0,g.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),sn=(0,g.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[cn,ln]=(0,g.useState)([]),un=(0,g.useRef)(0),dn=(0,g.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),un.current+=1;let i=ud(t),a={text:i.text,seq:un.current};i.quotes.length&&d(e=>e_(e,i.quotes.map(e=>({path:``,name:``,mode:`quote`,quote:e,key:jt()})))),ln(e=>[...e.slice(-9),a])},[r]),pn=(0,g.useCallback)(()=>Pe(!0),[]),mn=(0,g.useCallback)(()=>d([]),[]);by(n.state?.sessionId??``,mn);let hn=(0,g.useCallback)(Ut,[]),gn=$t,_n=rn,vn=(0,g.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),yn=(0,g.useCallback)(e=>Ht(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines,e.silent??!1),[]),bn=n.state?.model,xn=n.state?.thinkingLevel,Sn=n.state?.availableThinkingLevels,Cn=(0,g.useMemo)(()=>bn?{model:bn,thinkingLevel:xn??`off`,availableThinkingLevels:Sn??[]}:null,[bn,xn,Sn]),wn=(0,g.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:jt(),conversationId:n.activeConversationId||n.state?.conversationId||``,title:e(`terminalTitle`,{n:1}),cwd:n.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null}),!0),[n.ready,n.state?.cwd,n.terminals.length,e,o]);return(0,g.useEffect)(()=>{if(zt.current){if(w!==`terminal`||n.terminals.length!==0){zt.current=!1;return}wn()&&(zt.current=!1)}},[n.terminals.length,wn,w]),(0,X.jsxs)(`div`,{className:`app`,"data-pi-anchor":`app`,onDragOver:e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),x(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||x(!1)},onDrop:t=>{if(x(!1),!Array.from(t.dataTransfer?.types??[]).includes(`Files`))return;t.preventDefault();let n=Array.from(t.dataTransfer?.files??[]);if(n.length===0){a(`warning`,e(`foldersNotSupported`));return}let r=n.filter(e=>um(e.type)),i=n.filter(e=>!um(e.type));r.length>0&&$t(r),i.length>0&&rn(i)},children:[b&&(0,X.jsx)(`div`,{className:`app-drop-overlay`,"aria-hidden":!0,children:(0,X.jsxs)(`span`,{children:[`📎 `,e(`dropHereToAttach`)]})}),(0,X.jsx)(Yo,{chat:n,terminal:o,view:w,plugins:T,uiPrimary:D,uiOverflow:O,uiContextTopbar:E[`contextmenu.topbar`],onUiAction:V,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:()=>{Re(void 0),Ie(!0)},onManagePlugins:()=>{Re(`plugins`),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onOpenIconEdit:()=>pt(!0),sound:Ct,onSoundChange:wt,onSoundPreview:e=>fb(e,Ct),themes:Dt,theme:Ot,onThemeChange:kt,reloadThemes:At}),ft&&(0,X.jsx)(yy,{slots:E,layout:n.settings?.uiLayout,exclude:Ji,onClose:()=>pt(!1)}),n.protocolMismatch&&(0,X.jsxs)(`div`,{className:`protocol-banner`,children:[`⚠ `,e(`protocolMismatch`)]}),(0,X.jsxs)(`div`,{className:`notices`,children:[n.notices.map(e=>(0,X.jsx)(PS,{notice:e,onDismiss:i},e.id)),Xe&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:Xe.text}),Xe.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Qe.current;Qe.current=null,Ze(null);try{t?.resolve(e.id)}catch{}},children:e.label},e.id)),(0,X.jsx)(`button`,{type:`button`,className:`notice-close`,title:e(`close`),onClick:()=>{let e=Qe.current;Qe.current=null,Ze(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(P,{})})]}),z.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:z.map(e=>e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`btn btn-slot notice-select`,title:e.hint??e.label,"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>V(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id):(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-slot`,title:e.hint??e.label,onClick:()=>V(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)(Zh,{currentModelId:bn?`${bn.provider}/${bn.id}`:null,children:(0,X.jsxs)(`div`,{ref:Oe,className:`layout`,style:{"--left-w":`${ge}px`,"--right-w":`${_e}px`},children:[ke?(0,X.jsx)(`div`,{className:`drawer-backdrop persistent${Ee?` on`:``}`,onClick:()=>De(null)}):Ee&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>De(null)}),(0,X.jsx)(Dv,{side:`left`,items:oe,chat:n,view:w,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:e=>{Re(e),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onUiAction:V,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>kt(Ot===`light`?null:`light`),onSoundToggle:()=>wt({...Ct,enabled:!Ct.enabled})}),(0,X.jsxs)(`div`,{className:`view-pane ${w===`chat`?``:`hidden`}`,children:[!ke&&xe&&(0,X.jsx)(WS,{side:`left`,onClick:we}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${Ee===`left`?`open`:``}${ke?``:xe?` hidden`:``}`,children:(0,X.jsx)(pu,{collapsible:!ke,onToggleCollapse:we,panelSend:Wt,active:!ke||Ee===`left`,sessionFile:n.state?.sessionFile??null,conversations:n.conversations,elsewhere:n.elsewhere,sessions:n.sessions,projects:n.projects,pathCompletions:n.pathCompletions,activeConversationId:n.activeConversationId,uiContextSession:E[`contextmenu.session`],uiLeftSessions:k,uiContextProject:E[`contextmenu.project`],uiProjectsActions:A,uiLeftProject:j,uiRunningActions:ee,uiHistoryActions:M,uiSections:te,renderPluginSectionBody:H,uiLeftRunning:N,uiLeftHistory:ne,uiPluginRunning:n.pluginPanelGroups,onPluginRunningAction:se,onUiAction:V,presetNames:R,transition:n.transition,onOpenSandboxModal:()=>Be(`create`)})}),!ke&&(0,X.jsx)(US,{side:`left`,width:ge,onResize:ye}),(0,X.jsxs)(`main`,{className:`${st?`main wide-chat`:`main`}${n.transition&&!n.transition.previewMessages?.length?` main-transitioning`:``}`,children:[n.transition&&(0,X.jsxs)(`div`,{className:`workspace-transition-bar phase-${n.transition.phase}`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(`div`,{className:`workspace-transition-track`,children:(0,X.jsx)(`div`,{className:`workspace-transition-fill`,style:{width:`${Math.min(100,Math.max(8,n.transition.progress))}%`}})}),(0,X.jsxs)(`div`,{className:`workspace-transition-pill`,children:[(0,X.jsx)(`span`,{className:`workspace-transition-spinner`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`workspace-transition-text`,children:t!==`zh`&&n.transition.textEn?n.transition.textEn:n.transition.text}),(0,X.jsxs)(`span`,{className:`workspace-transition-pct`,children:[n.transition.progress,`%`]})]})]}),ae.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:rg(ae,V)}),n.state?(0,X.jsxs)(X.Fragment,{children:[n.state.sandbox&&(0,X.jsxs)(`div`,{className:`sandbox-banner`,role:`region`,"aria-label":n.state.sandbox.name,children:[(0,X.jsxs)(`div`,{className:`sandbox-banner-info`,children:[(0,X.jsxs)(`span`,{className:`sandbox-banner-title`,children:[`🧪 `,e(`sandboxBannerTitle`,{name:n.state.sandbox.name}),(0,X.jsx)(`span`,{className:`lp-sandbox-badge ${n.state.sandbox.ephemeral?`ephemeral`:`permanent`}`,children:n.state.sandbox.ephemeral?e(`sandboxBadgeEphemeral`):e(`sandboxBadgePermanent`)})]}),(0,X.jsx)(`span`,{className:`sandbox-banner-desc`,children:n.state.sandbox.sourcePath?e(`sandboxBannerSourceDesc`,{source:n.state.sandbox.sourcePath}):e(`sandboxBannerBlankDesc`)})]}),(0,X.jsxs)(`div`,{className:`sandbox-banner-actions`,children:[n.state.sandbox.ephemeral&&(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionPersistTip`),onClick:()=>r({type:`persist_sandbox`,path:n.state?.sandbox?.path}),children:[`📌 `,e(`sandboxActionPersist`)]}),n.state.sandbox.sourcePath&&(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn primary`,title:e(`sandboxActionApplySourceTip`),onClick:()=>Be(`apply`),children:[`✅ `,e(`sandboxActionApplySource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionPromoteTip`),onClick:()=>Be(`promote`),children:[`📤 `,e(`sandboxActionPromote`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionResetTip`),onClick:()=>{let t=n.state?.sandbox;t&&window.confirm(e(`sandboxActionResetConfirm`,{name:t.name}))&&r({type:`reset_sandbox`,path:t.path})},children:[`🔄 `,e(`sandboxActionReset`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn danger`,title:e(`sandboxActionDestroyTip`),onClick:()=>{let t=n.state?.sandbox;t&&window.confirm(e(`sandboxActionDestroyConfirm`,{name:t.name}))&&r({type:`destroy_sandbox`,path:t.path})},children:[`🗑️ `,e(`sandboxActionDestroy`)]})]})]}),n.state.isEphemeral&&(0,X.jsxs)(`div`,{className:`ephemeral-banner`,children:[(0,X.jsxs)(`span`,{children:[`🎭 `,e(`ephemeralBannerText`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`ephemeral-save`,onClick:()=>r({type:`persist_conversation`,id:Jt}),children:[`💾 `,e(`saveEphemeral`)]})]}),(0,X.jsx)(Yg,{uiMessageActions:E[`message.actions`],uiContextMessage:E[`contextmenu.message`],uiContextToolCall:E[`contextmenu.toolcall`],uiChatEmpty:I,onUiAction:V,state:n.transition?.previewMessages?.length?{...n.state,messages:n.transition.previewMessages,streamingMessage:null,isStreaming:!1}:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:an,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&Uh(`${e.provider}/${e.id}`)}},onRemoveQueued:sn,onRecallQueued:dn,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,keepRecent:n.settings?.keepRecentMessages,jumpTarget:mt,onJumpDone:()=>ht(null),urlJumpMessageId:gt&>.sessionId===n.state.sessionId?gt.messageId:null,onUrlJumpDone:()=>_t(null)},n.transition?.previewMessages?.length?`preview:${n.transition.target}`:n.state.conversationId??`boot`)]}):(0,X.jsx)(`div`,{className:`boot-wait`,children:n.ready?e(`loadingSession`):e(`connectingServer`)}),n.settings?.goalModeEnabled!==!1&&(0,X.jsx)(`div`,{className:`goalbar-slot`,children:(0,X.jsx)(dv,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:ie,onUiAction:V})}),(0,X.jsx)(ty,{onAction:(e,t,n)=>V(e,n,t)}),n.dialog&&(0,X.jsx)(Ov,{dialog:n.dialog}),We&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":We.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),We.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:We.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),We.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(We.options??[]).map((e,t)=>{let n=We.multi?Ke.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(We.multi){qe(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Y.current;Y.current=null,Ge(null);try{n?.resolve({ok:!0,selected:[e.label]})}catch{}},children:[e.label,e.description&&(0,X.jsx)(`span`,{className:`dialog-hint`,children:e.description})]},t)}),(We.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),We.multi&&(0,X.jsx)(`div`,{className:`dialog-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current,t=(e?.options??[]).filter((e,t)=>Ke.includes(t)).map(e=>e.label);Y.current=null,Ge(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),We.kind===`confirm`&&(0,X.jsx)(`div`,{className:`dialog-body`,children:(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve(!1)}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),We.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Je,placeholder:We.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>Ye(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!0,value:Je})}catch{}}}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!1})}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!0,value:Je})}catch{}},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(Rv,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||Jt))?.title}),n.remoteQuestion&&(0,X.jsx)(Rv,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(Gx,{plan:n.activeConversationId&&n.state?.conversationId!==n.activeConversationId?null:n.state?.plan}),(0,X.jsx)(uv,{composerLeading:E[`composer.leading`],composerActions:E[`composer.actions`],onUiAction:V,streaming:n.state?.isStreaming??!1,planMode:n.state?.planMode??!1,messages:n.state?.messages??FS,slashCommands:n.slashCommands,modelState:Cn,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:hn,onAddImageFiles:gn,onAddLocalFiles:_n,onAddPathAttachment:yn,fileSearch:n.fileSearch,onSearchFiles:vn,onNotice:a,onManageModels:pn,onSent:mn,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:cn,dshPermCurrent:n.state?.permission??null,dshPermOptions:n.dshPermission?.options??void 0,dshPermDefault:n.dshPermission?.defaultPreset,dshPreset:n.state?.agentPreset??null,dshPresets:n.dshPresets?.presets??void 0,dshPresetDefault:n.dshPresets?.defaultPreset,dshBlank:(n.state?.messages?.length??0)===0,conversationId:n.activeConversationId||n.state?.conversationId||``,sessionDraft:n.engine===`pi`?n.state?.draft??null:null,sessionId:n.state?.sessionId??``})]}),!ke&&(0,X.jsx)(US,{side:`right`,width:_e,onResize:be}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${Ee===`right`?`open`:``}${ke?``:Se?` hidden`:``}`,children:(0,X.jsx)(sd,{collapsible:!ke,onToggleCollapse:Te,panelSend:Wt,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{De(null),Ht(e,t,n,r)},onPreview:(e,t)=>{De(null),y(e,t)},onNotice:(e,t)=>a(e,t),uiRightPanelTabs:E[`rightpanel.tabs`],uiContextFile:E[`contextmenu.file`],plugins:T,pluginsEpoch:n.pluginsEpoch,send:r})}),!ke&&Se&&(0,X.jsx)(WS,{side:`right`,onClick:Te})]}),(0,X.jsx)(`div`,{className:`view-pane ${w===`terminal`?``:`hidden`}`,children:(0,X.jsx)(g.Suspense,{fallback:null,children:(0,X.jsx)(NS,{chat:n,terminal:o,uiTerminalToolbar:F,onUiAction:V})})}),(0,X.jsx)(`div`,{className:`view-pane ${w===`git`?``:`hidden`}`,children:(0,X.jsx)(Qv,{chat:n,terminal:o,active:w===`git`,onSwitchToTerminal:()=>C(`terminal`),uiScmToolbar:re,onUiAction:V})}),ce.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${w===t?``:`hidden`}`,children:(0,X.jsx)($v,{entry:e})},e.info.id)}),w.startsWith(`plugin:`)&&!ce.some(e=>`plugin:${e.info.id}`===w)&&(0,X.jsx)(ey,{pluginId:w.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===w),epoch:n.pluginsEpoch,failed:ue.includes(w.slice(7))}),(0,X.jsx)(Dv,{side:`right`,items:B,chat:n,view:w,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:e=>{Re(e),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onUiAction:V,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>kt(Ot===`light`?null:`light`),onSoundToggle:()=>wt({...Ct,enabled:!Ct.enabled})})]})}),(0,X.jsx)(hv,{chat:n,bottombarItems:E.bottombar,onUiAction:V,onOpenSettings:()=>{Re(void 0),Ie(!0)},onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenGlobalSearch:()=>dt(!0),onOpenBgTasks:()=>lt(!0)}),f&&(0,X.jsx)(mS,{file:f,content:n.fileContent,onAddLines:(e,t,n,r)=>Ht(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>Ht(e,t,n),onClose:()=>p(null),uiFilePreviewToolbar:L,onUiAction:V}),m&&(0,X.jsx)(vS,{file:m.file,plugin:m.plugin,declaration:m.declaration,epoch:n.pluginsEpoch,send:r,onClose:()=>h(null),onFallback:()=>{h(null),p(m.file)}}),n.ready&&n.state&&n.state.piConfigured===!1&&!je&&!Ne&&(0,X.jsx)(ky,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>Me(!0)}),Ne&&(0,X.jsx)(zy,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,fetchModelsResult:n.fetchModelsResult,testModelConnectionResult:n.testModelConnectionResult,enrichModelsResult:n.enrichModelsResult,enrichModelsProgress:n.enrichModelsProgress,refreshBuiltinResult:n.refreshBuiltinResult,refreshProviderResult:n.refreshProviderResult,appendBuiltinResult:n.appendBuiltinResult,cloneProviderResult:n.cloneProviderResult,defaultModel:n.defaultModel,onClose:()=>Pe(!1)}),Fe&&(0,X.jsx)(Rx,{chat:n,terminal:o,initialSection:Le,onSwitchToTerminal:()=>C(`terminal`),onClose:()=>Ie(!1),onOpenIconEdit:()=>pt(!0),sound:Ct,onSoundChange:wt,tts:Tt,onTtsChange:Et}),ct&&(0,X.jsx)(Bx,{servers:n.bgServers,plugins:n.plugins,epoch:n.pluginsEpoch,send:r,onUiAction:V,autoCleanupMin:n.settings?.bgAutoCleanupMin??0,onClose:()=>lt(!1)}),(0,X.jsx)(tS,{}),(0,X.jsx)(Vx,{}),(0,X.jsx)(Hx,{approval:n.approval}),n.tuiOverlay&&(0,X.jsx)(Ux,{overlay:n.tuiOverlay}),W&&(0,X.jsx)(sS,{entry:W,pluginView:pe?ce.find(e=>e.info.id===pe):void 0,onUiAction:(e,t)=>{V(e,t),fe(null)},onClose:()=>fe(null)}),(0,X.jsx)(oS,{open:ut,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>dt(!1),onSwitchSession:(e,t)=>{r({type:`switch_session`,path:e});let n=t&&t[0];ht(n?{path:e,role:n.role,timestamp:n.timestamp}:null)},onSwitchProject:e=>{r({type:`set_cwd`,path:e})},onPreviewFile:(e,t)=>{y(e,t)}}),(ot||nt||Ve)&&(0,X.jsxs)(`div`,{className:`modal-backdrop perm-modal-backdrop`,children:[ot&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginPermTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>at(ot.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[ot.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,ot.pluginId).replace(`{hosts}`,(ot.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,ot.pluginId).replace(`{models}`,(ot.models??[]).length>0?` ${(ot.models??[]).join(`, `)}`:``),ot.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:ot.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>at(ot.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>at(ot.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>at(ot.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),nt&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginGrantRequestTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>tt(nt.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginGrantRequestBody`).replace(`{plugin}`,nt.pluginId).replace(`{path}`,nt.path),nt.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:nt.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>tt(nt.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>tt(nt.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),Ve&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginSessionGrantTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{Ue.current=null,Ve.resolve(!1),He(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,Ve.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Ue.current=null,Ve.resolve(!1),He(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{Ue.current=null,Ve.resolve(!0),He(null)},children:e(`ok`)})]})]})]})]}),!Fe&&Object.values(n.pluginJobs??{}).some(e=>e.phase!==`done`)&&(0,X.jsxs)(`div`,{className:`active-plugin-jobs-bar`,onClick:()=>{Re(`plugins`),Ie(!0)},title:e(`pluginJobRunning`),children:[(0,X.jsx)(K,{className:`spin`}),(0,X.jsxs)(`span`,{className:`active-plugin-jobs-title`,children:[e(`pluginJobRunning`),`:`,` `,Object.values(n.pluginJobs??{}).filter(e=>e.phase!==`done`).map(e=>e.pluginId).join(`, `)]}),(()=>{let e=Object.values(n.pluginJobs??{}).find(e=>e.phase!==`done`),t=e?.lines[e.lines.length-1];return t?(0,X.jsx)(`span`,{className:`active-plugin-jobs-line`,children:t}):null})()]}),ze&&(0,X.jsx)(pv,{mode:ze,currentCwd:n.state?.cwd,currentSandbox:n.state?.sandbox,sandboxDiff:n.sandboxDiff,projects:n.projects,send:r,onClose:()=>Be(null)}),(0,X.jsx)(gy,{})]})}function ZS(){typeof document<`u`&&(QS($S()),tC())}function QS(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function $S(){let e=document.createElement(`div`);e.style.cssText=`position:fixed;top:-9999px;left:0;width:100px;height:100px;overflow-y:auto;scrollbar-gutter:stable both-edges;visibility:hidden;pointer-events:none;`,document.body.appendChild(e);let t=(e.offsetWidth-e.clientWidth)/2;return e.remove(),t}function eC(e){let t=document.createElement(`div`);t.style.cssText=`width:0;height:0;pointer-events:none;`,e.appendChild(t);let n=getComputedStyle(e),r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=Number.parseFloat(n.borderLeftWidth)||0,o=Number.parseFloat(n.paddingLeft)||0,s=i.left-(r.left+a+o);return t.remove(),s}function tC(){let e=()=>{let e=document.querySelector(`.messages`);return e?(QS(eC(e)),!0):!1},t=0;if(window.addEventListener(`resize`,()=>{t||=window.requestAnimationFrame(()=>{t=0,e()})}),e())return;let n=new MutationObserver(()=>{e()&&n.disconnect()});n.observe(document.documentElement,{childList:!0,subtree:!0}),window.setTimeout(()=>n.disconnect(),6e4)}mn(),hf(pf()),ZS(),(0,ee.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(g.StrictMode,{children:(0,X.jsx)(Mn,{children:(0,X.jsx)(XS,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=un();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,jt as c,he as d,me as f,P as g,L as h,vf as i,Ke as l,z as m,rg as n,Nn as o,K as p,ff as r,Z as s,ag as t,Se as u};
|
|
680
|
+
`);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,fS)},[c]),H=c?.lines??0,se=H>fS,ce=(e,t)=>{if(t){let t=re.current>0?re.current:e;p({start:Math.min(t,e),end:Math.max(t,e)})}else re.current=e,p({start:e,end:e})},le=()=>{V.length!==0&&(re.current=1,p({start:1,end:V.length}))},ue=()=>{f&&(n(e.path,e.name,f.start,f.end),v(!0),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>v(!1),1400))},U=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated&&!gS(e.name),de=()=>{oe.current=!1,B.current&&clearTimeout(B.current),L(!1),z(!1),S(c?.text??``),b(!1),k.current&&(hS(e.name)&&w(!0),_S(e.name)&&E(!0))},fe=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;de();return}U&&c&&(k.current=hS(e.name)&&C||_S(e.name)&&T,hS(e.name)&&w(!1),_S(e.name)&&E(!1),p(null),S(c.text),b(!0))},W=()=>{y&&c&&U&&$({type:`write_file`,path:e.path,text:x})&&(oe.current=!0,z(!1),L(!0),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{oe.current=!1,L(!1),z(!0)},5e3))},G=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},K=e=>{F(Math.min(200,Math.max(50,e)))},me=f?f.end-f.start+1:0,he=c?.binary??!1,ge=c?.truncated??!1,q=c?.kind??`text`,_e=hS(e.name)||gS(e.name),ve=_S(e.name),ye=_e&&C&&!y&&q===`text`&&!he,xe=ve&&T&&!y&&q===`text`&&!he,[J,Se]=(0,g.useState)(()=>{try{return localStorage.getItem(pS)===`1`}catch{return!1}});(0,g.useEffect)(()=>{try{localStorage.setItem(pS,J?`1`:`0`)}catch{}},[J]);let[we,Te]=(0,g.useState)([]),[Ee,ke]=(0,g.useState)(``),Ae=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=Ae.current;if(!e||!ye){Te([]);return}let t=[...e.querySelectorAll(`h1, h2, h3, h4, h5, h6`)],n=uS(t.map(e=>({level:Number(e.tagName.slice(1)),label:e.textContent??``})));t.forEach((e,t)=>{e.id||=n[t].id}),Te(n)},[ye,c?.text,e.path]),(0,g.useEffect)(()=>{let e=Ae.current;if(!e||!J||!dS(we))return;let t=we.map(t=>e.querySelector(`#${CSS.escape(t.id)}`)).filter(e=>e!==null);if(t.length===0)return;let n=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0];t?.target.id&&ke(t.target.id)},{rootMargin:`0px 0px -70% 0px`});for(let e of t)n.observe(e);return()=>n.disconnect()},[we,J]);let je={"host:fp-md":_e&&q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach markdown ${C?`on`:``}`,"data-tip":s(C?`showMarkdownSource`:`showMarkdownPreview`),disabled:y,onClick:()=>w(e=>!e),children:C?(0,X.jsx)(Ue,{}):(0,X.jsx)(nt,{})}):null,"host:fp-toc":ye&&dS(we)?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach toc ${J?`on`:``}`,"data-tip":s(J?`previewTocHide`:`previewTocShow`),onClick:()=>Se(e=>!e),children:(0,X.jsx)(De,{})}):null,"host:fp-html":ve&&q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach html ${T?`on`:``}`,"data-tip":s(T?`showHtmlSource`:`showHtmlPreview`),disabled:y,onClick:()=>E(e=>!e),children:T?(0,X.jsx)(nt,{}):(0,X.jsx)(Ue,{})}):null,"host:fp-edit":q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(ge?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!U&&!y,onClick:fe,children:(0,X.jsx)(Y,{})}):null,"host:fp-wrap":q===`text`&&!he&&!ye&&!xe?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${A?`on`:``}`,"data-tip":s(A?`disableWrap`:`enableWrap`),onClick:()=>j(e=>!e),children:(0,X.jsx)(et,{})}):null,"host:fp-zoom":q===`text`&&c?(0,X.jsxs)(`span`,{className:`fp-zoom`,children:[(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-out`,"data-tip":s(`zoomOut`),disabled:ne<=50,onClick:()=>K(ne-10),children:(0,X.jsx)(M,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>F(100),children:[ne,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:ne>=200,onClick:()=>K(ne+10),children:(0,X.jsx)(te,{})})]}):null,"host:fp-ref":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach ref`,"data-tip":s(`referenceTip`),onClick:()=>r(e.path,e.name,`reference`),children:(0,X.jsx)(Oe,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${ee?`on`:``}`,"data-tip":s(ee?`exitFullscreen`:`fullscreen`),onClick:()=>N(e=>!e),children:ee?(0,X.jsx)(be,{}):(0,X.jsx)(Ce,{})}),"host:fp-close":null},Me=a===void 0?[`host:fp-md`,`host:fp-toc`,`host:fp-html`,`host:fp-edit`,`host:fp-wrap`,`host:fp-zoom`,`host:fp-ref`,`host:fp-full`].map(e=>({id:e,source:`host`})):a.filter(e=>!e.hidden&&e.id!==`host:fp-close`),Ne=e=>gn(fn(`/api/file?clientId=${encodeURIComponent(Fl())}&path=${encodeURIComponent(e)}`)),Pe=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return gn(fn(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(Fl())}${D?`&allowJs=1`:``}`))};return(0,X.jsx)(`div`,{className:`fp-overlay ${ee?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&G()},children:(0,X.jsxs)(`div`,{className:`fp ${ee?`fullscreen`:``}`,style:{"--fp-zoom":ne/100},children:[(0,X.jsxs)(`div`,{className:`fp-head`,onDoubleClick:e=>{let t=e.target;t&&!t.closest(`button, a, input`)&&N(e=>!e)},children:[(0,X.jsx)(`span`,{className:`fp-name`,title:e.path,children:e.name}),(0,X.jsx)(`span`,{className:`fp-path`,children:e.path}),(0,X.jsxs)(`span`,{className:`fp-meta`,children:[c&&q===`text`&&!he&&s(`fileLines`,{n:H}),c&&` · ${_m(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:ag(Me,je,o)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),"aria-label":s(`close`),onClick:G,children:(0,X.jsx)(P,{})})]}),ge&&q===`text`&&!he&&(0,X.jsx)(`div`,{className:`fp-notice`,children:gS(e.name)?s(`previewLinesTruncated`,{n:V.length}):s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&q===`none`&&!he&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&q===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap clickable`,onClick:G,title:s(`clickToCloseImage`),children:(0,X.jsx)(`img`,{className:`fp-media fp-media-clickable`,src:Ne(e.path),alt:e.name,onClick:G,title:s(`clickToCloseImage`)})}),!u&&q===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:Ne(e.path),controls:!0,preload:`metadata`})}),!u&&xe&&c&&(0,X.jsxs)(`div`,{className:`fp-html`,children:[(0,X.jsxs)(`div`,{className:`fp-html-bar`,children:[(0,X.jsx)(`span`,{className:`fp-html-hint`,title:s(D?`htmlJsOnTip`:`htmlJsOffTip`),children:s(D?`htmlJsOn`:`htmlJsOff`)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-html-js ${D?`on`:``}`,"data-tip":s(D?`htmlDisableJs`:`htmlEnableJs`),onClick:()=>O(e=>!e),children:s(D?`htmlDisableJs`:`htmlEnableJs`)}),(0,X.jsxs)(`a`,{className:`fp-html-btn fp-html-external`,href:Pe(e.path),target:`_blank`,rel:`noopener noreferrer`,title:s(`openInNewTab`),children:[(0,X.jsx)(Ge,{}),(0,X.jsx)(`span`,{children:s(`openInNewTab`)})]})]}),(0,X.jsx)(`iframe`,{className:`fp-html-frame`,src:Pe(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&ye&&c&&(0,X.jsx)(`div`,{className:gS(e.name)?`fp-markdown msg-text fp-office`:`fp-markdown msg-text`,children:(0,X.jsxs)(`div`,{className:J&&dS(we)?`fp-toc-layout`:void 0,children:[J&&dS(we)&&(0,X.jsx)(`nav`,{className:`fp-toc`,"aria-label":s(`previewTocLabel`),children:we.map(e=>(0,X.jsx)(`a`,{className:`l${Math.min(e.level,6)}${e.id===Ee?` on`:``}`,href:`#${e.id}`,title:e.label,onClick:t=>{t.preventDefault(),Ae.current?.querySelector(`#${CSS.escape(e.id)}`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:e.label},e.id))}),(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,ref:Ae,children:(0,X.jsx)(Af,{text:c.text})})]})}),!u&&he&&q!==`image`&&q!==`video`&&c&&(0,X.jsxs)(`div`,{className:`fp-hex-wrap`,children:[(0,X.jsxs)(`div`,{className:`fp-notice`,children:[s(`binaryFile`),c.truncated&&s(`binaryHexTruncated`)]}),(0,X.jsx)(`pre`,{className:`fp-hex`,children:c.text})]}),!u&&y&&q===`text`&&!he&&c&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{className:`fp-editor ${A?``:`no-wrap`}`,value:x,onChange:e=>S(e.target.value),wrap:A?`soft`:`off`,spellCheck:!1,autoFocus:!0}),R&&(0,X.jsx)(`div`,{className:`fp-notice`,role:`alert`,children:s(`saveResultUnknown`)})]}),!u&&!ye&&!xe&&!y&&q===`text`&&!he&&c&&V.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!ye&&!xe&&!y&&q===`text`&&!he&&V.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${m?`dragging`:``} ${A?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[V.map((e,t)=>{let n=t+1,r=f!==null&&n>=f.start&&n<=f.end;return(0,X.jsxs)(`div`,{className:`fp-line ${r?`sel`:``}`,onMouseDown:e=>{e.button===0&&(ce(n,e.shiftKey),ie.current=!0,h(!0))},onMouseEnter:()=>{ie.current&&ce(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),se&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:fS})})]}),(y||!ye&&!xe&&q===`text`)&&(0,X.jsx)(`div`,{className:`fp-foot`,children:y?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:s(`editFile`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:fe,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:I||x===(c?.text??``),onClick:W,children:[(0,X.jsx)(pe,{}),` `,s(`saveFile`)]})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:f?s(`selectedRange`,{n:me,start:f.start,end:f.end}):s(`selectLinesHint`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:V.length===0,onClick:le,children:s(`selectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!f,onClick:()=>p(null),children:s(`clearSelection`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!f||he,onClick:ue,children:[_?(0,X.jsx)(ft,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function hS(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function gS(e){let t=e.toLowerCase();return t.endsWith(`.docx`)||t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`)}function _S(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function vS({file:e,plugin:t,declaration:n,epoch:r,send:i,onClose:a,onFallback:o}){let s=Z(),c=(0,g.useRef)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(!1),p=(0,g.useRef)(o);p.current=o;let m=n.label??t.name;return(0,g.useEffect)(()=>{let r=c.current;if(!r)return;let a=!1,o;return u(null),f(!1),(async()=>{try{let s=await Dy({plugin:t,declaration:n});if(a)return;if(!s)throw Error(`插件没有提供可用的文件查看器`);let c=`/plugins-api/${encodeURIComponent(t.id)}`,l={...il(t.id,i),file:e,apiUrl:(e,t)=>{let n=String(e??``).startsWith(`/`)?String(e):`/${String(e??``)}`,r=new URLSearchParams;for(let[e,n]of Object.entries(t??{}))n!==void 0&&r.set(e,String(n));let i=r.toString();return gn(fn(`${c}${n}${i?`?${i}`:``}`))}};o=s.handler.mount(r,e,l),a||f(!0)}catch(e){a||(console.error(`[plugin:${t.id}] file handler failed:`,e),p.current())}})(),()=>{if(a=!0,typeof o==`function`)try{o()}catch(e){console.error(`[plugin:${t.id}] file handler cleanup failed:`,e)}r.textContent=``}},[e,t,n,r,i]),(0,X.jsx)(Ky,{className:`plugin-file-preview`,title:m,icon:t.icon,onClose:a,children:(0,X.jsxs)(`div`,{className:`modal-body plugin-file-preview-body`,children:[(0,X.jsx)(`div`,{className:`plugin-file-preview-file`,title:e.path,children:e.name}),l?(0,X.jsx)(`div`,{className:`plugin-file-preview-error`,children:l}):null,!l&&!d?(0,X.jsx)(`div`,{children:s(`loading`)}):null,(0,X.jsx)(`div`,{ref:c,className:`plugin-file-preview-host`})]})})}var yS=.4,bS=1.05;function xS(e){return Math.min(300,e*.86)}function SS(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function CS(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function wS(e,t){return e===`left`?t:-t}function TS(e,t){return Math.max(-e,Math.min(0,-e+t))}function ES(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function DS(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:ES(r*bS,n,t)>=yS}var OS=new Set([`auto`,`scroll`,`overlay`]);function kS(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&OS.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function AS(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function jS(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,g.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0],i=SS(r.clientX,window.innerWidth,n);i&&!kS(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0],d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=CS(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=xS(window.innerWidth),h=m*bS;let i=e.querySelector(a?a(r):`.panel-drawer.drawer-${r}`);if(!i){s=null;return}g=i,_=o===null?null:e.querySelector(o??`.drawer-backdrop`),i.classList.add(`drawer-dragging`)}let y=g;if(!y)return;f=wS(r,d);let b=TS(h,f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(ES(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?DS({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(AS(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}function MS(e,t,n,r,i){let a=new Map;for(let e of r)a.set(e.id,!!e.isStreaming);if(t&&a.set(t,n),e===null)return{startCue:!1,finishedConvs:[],nextMap:a};let o=!1;if(t&&(i===void 0||i===t)){let n=e.get(t),r=a.get(t)??!1;n===!1&&r===!0&&(o=!0)}let s=[];for(let[n,i]of e.entries())if(i&&a.has(n)&&!a.get(n)){let e=r.find(e=>e.id===n);s.push({id:n,title:e?.title,isActive:n===t})}return{startCue:o,finishedConvs:s,nextMap:a}}var NS=(0,g.lazy)(()=>Pc(()=>import(`./TerminalPanel-LQLL17DU.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function PS({notice:e,onDismiss:t}){let n=Z(),{locale:r}=Nn(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(a)return;let n=setTimeout(()=>t(e.id),hl(e.level));return()=>clearTimeout(n)},[a,e.id,e.level,t]);let s=e.level===`error`?Tt:e.level===`warning`?wt:je;return(0,X.jsxs)(`div`,{className:`notice notice-${e.level}${a?` paused`:``}`,role:`status`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onClick:()=>{window.getSelection?.()?.toString()||t(e.id)},children:[(0,X.jsx)(s,{className:`notice-icon`}),(0,X.jsx)(`span`,{className:`notice-text`,children:i}),(0,X.jsx)(`button`,{type:`button`,className:`notice-close`,title:n(`close`),onClick:n=>{n.stopPropagation(),t(e.id)},children:(0,X.jsx)(P,{})})]})}var FS=[],IS=180,LS=520,RS=240,zS=e=>`pi-web-ui:${e}-panel-width`;function BS(e){try{let t=Number(localStorage.getItem(zS(e)));return Number.isFinite(t)&&t>=IS&&t<=LS?t:RS}catch{return RS}}var VS=e=>`pi-web-ui:${e}-panel-collapsed`;function HS(e){try{return localStorage.getItem(VS(e))===`1`}catch{return!1}}function US({side:e,width:t,onResize:n}){let r=Z(),i=(0,g.useCallback)(r=>{r.preventDefault();let i=r.clientX,a=t,o=a,s=t=>{let r=e===`left`?t.clientX-i:i-t.clientX;o=Math.min(LS,Math.max(IS,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`);try{localStorage.setItem(zS(e),String(o))}catch{}};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),document.body.classList.add(`panel-resizing`)},[e,t,n]);return(0,X.jsx)(`div`,{className:`resize-handle resize-${e}`,title:r(`dragToResize`),onPointerDown:i,onDoubleClick:()=>n(RS)})}function WS({side:e,onClick:t}){let n=Z();return(0,X.jsx)(`button`,{type:`button`,className:`panel-rail panel-rail-${e}`,title:n(`expandPanel`),onClick:t,children:e===`left`?(0,X.jsx)(ot,{}):(0,X.jsx)(st,{})})}var GS=`pi-web-ui:plugin-path-grants`,KS=e=>e?`${GS}:${e}`:GS;function qS(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function JS(e){try{let t=KS(e);if(localStorage.getItem(t)!==null)return qS(localStorage.getItem(t));if(!e)return[];let n=qS(localStorage.getItem(GS));return localStorage.setItem(t,JSON.stringify(n)),n}catch{return[]}}function YS(e,t){try{let n=[...new Set([...JS(t),e])];localStorage.setItem(KS(t),JSON.stringify(n))}catch{}}function XS(){let e=Z(),{locale:t}=Nn(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=Xl(),s=(0,g.useRef)(!1);(0,g.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:mx[t]??mx.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=Fb();(0,g.useEffect)(()=>{let t=l?Ob(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,g.useState)([]);(0,g.useEffect)(()=>(ar(e=>d(t=>e_(t,e))),()=>ar(null)),[]);let[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(null),_=(0,g.useRef)(!1),v=(0,g.useRef)(null);(0,g.useEffect)(()=>{_.current=f!==null,v.current=m},[f,m]);let y=(0,g.useCallback)((e,t)=>{let n=Ey(t);if(n){p(null),h({file:{path:e,name:t},plugin:n.plugin,declaration:n.declaration});return}h(null),p({path:e,name:t})},[]);(0,g.useEffect)(()=>(Sf({open:e=>y(e.path,e.name),isOpen:()=>_.current||v.current!==null}),()=>Sf(null)),[y]);let[b,x]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let e=()=>x(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[S,C]=(0,g.useState)(`chat`),w=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(S.startsWith(`plugin:`)?`plugins`:S)?S:`chat`,T=(0,g.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),E=(0,g.useMemo)(()=>{let r=[],i=pa(na(n.plugins),{locale:t,t:t=>e(t),disabledPlugins:n.settings?.disabledPlugins??[],layout:n.settings?.uiLayout,diagnostics:r});for(let e of r)console.warn(`[ui-slot] ${e.pluginId?`[${e.pluginId}] `:``}${e.message}`);return i},[n.plugins,n.settings?.disabledPlugins,n.settings?.uiLayout,t,e]),D=(0,g.useMemo)(()=>E[`topbar.primary`].filter(e=>!e.hidden),[E]),O=(0,g.useMemo)(()=>[...E[`topbar.primary`].filter(e=>e.hidden),...E[`topbar.overflow`]],[E]),k=(0,g.useMemo)(()=>E[`leftpanel.sessions`].filter(e=>!e.hidden),[E]),A=(0,g.useMemo)(()=>E[`leftpanel.projects.actions`].filter(e=>!e.hidden),[E]),j=(0,g.useMemo)(()=>E[`leftpanel.project`].filter(e=>!e.hidden),[E]),ee=(0,g.useMemo)(()=>E[`leftpanel.running.actions`].filter(e=>!e.hidden),[E]),M=(0,g.useMemo)(()=>E[`leftpanel.history.actions`].filter(e=>!e.hidden),[E]),te=E[`leftpanel.sections`],N=(0,g.useMemo)(()=>E[`leftpanel.running`].filter(e=>!e.hidden),[E]),ne=(0,g.useMemo)(()=>E[`leftpanel.history`].filter(e=>!e.hidden),[E]),F=(0,g.useMemo)(()=>E[`terminal.toolbar`].filter(e=>!e.hidden),[E]),re=(0,g.useMemo)(()=>E[`scm.toolbar`].filter(e=>!e.hidden),[E]),ie=(0,g.useMemo)(()=>E[`goalbar.actions`].filter(e=>!e.hidden),[E]),ae=(0,g.useMemo)(()=>E[`chat.header`].filter(e=>!e.hidden),[E]),I=(0,g.useMemo)(()=>E[`chat.empty`].filter(e=>!e.hidden),[E]),L=(0,g.useMemo)(()=>E[`file.preview.toolbar`].filter(e=>!e.hidden),[E]),R=(0,g.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(n=>[n.id,Z_(n,t,e).name])),[n.dshPresets,t]),z=(0,g.useMemo)(()=>E[`notice.actions`].filter(e=>!e.hidden),[E]),oe=(0,g.useMemo)(()=>E[`sidebar.left`]??[],[E]),B=(0,g.useMemo)(()=>E[`sidebar.right`]??[],[E]),V=(0,g.useCallback)((t,n,i)=>{if(t.id===`host:msg-fork`){i?.id&&r({type:`fork_session`,messageId:i.id,position:`before`});return}if(t.id===`host:msg-rollback`){i?.id&&Im({messageId:i.id});return}let o=(t.action??``).trim();if(t.kind===`view`||(!o||o===`view`)&&t.source!==`host`){C(t.view??`plugin:${t.source.startsWith(`plugin:`)?t.source.slice(7):``}`);return}o&&$s(t.source.startsWith(`plugin:`)?t.source.slice(7):``,o,t.id,{...n===void 0?{}:{value:n},...i===void 0?{}:{target:i},loadBundle:async e=>{let t=G.current.plugins.find(t=>t.id===e);return t?nl(t,G.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),H=(0,g.useCallback)(e=>{let t=n.plugins.find(t=>t.id===e.source.slice(7));return t?(0,X.jsx)(Ru,{plugin:t,epoch:n.pluginsEpoch,send:r,className:`lp-plugin-page`}):null},[n.plugins,n.pluginsEpoch,r]),se=(0,g.useCallback)((t,n)=>{n.action&&$s(t.pluginId,n.action,n.id,{target:{id:n.id,kind:`plugin-running`,label:n.title},loadBundle:async e=>{let t=G.current.plugins.find(t=>t.id===e);return t?nl(t,G.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[ce,le]=(0,g.useState)([]);(0,g.useEffect)(()=>Yc(le),[]);let[ue,U]=(0,g.useState)([]);(0,g.useEffect)(()=>qc(U),[]);let[de,fe]=(0,g.useState)(null),W=de?E[`modal.dialog`].find(e=>e.id===de&&!e.hidden):void 0,pe=(0,g.useMemo)(()=>{if(!W||W.kind!==`view`)return``;let e=W.view??``;return e.startsWith(`plugin:`)?e.slice(7):W.source.startsWith(`plugin:`)?W.source.slice(7):``},[W]);(0,g.useEffect)(()=>{if(!W||!pe||ce.some(e=>e.info.id===pe))return;let e=G.current.plugins.find(e=>e.id===pe);e&&nl(e,G.current.pluginsEpoch)},[W,pe,ce,n.pluginsEpoch]),(0,g.useEffect)(()=>{Zd(r),Qd(T,n.pluginsEpoch),of(T,n.pluginsEpoch),Ty(T,n.pluginsEpoch),rl(T,n.pluginsEpoch)},[T,n.pluginsEpoch,r]);let G=(0,g.useRef)(n);G.current=n;let me=(0,g.useRef)(C);me.current=C;let he=(0,g.useRef)(E);he.current=E,(0,g.useEffect)(()=>(Ks(Gs({send:r,isReady:()=>!!G.current.state,setView:e=>me.current(e),getCwd:()=>G.current.state?.cwd??``,getWorkspaceRoots:()=>G.current.state?.workspaceRoots??[],listSessions:()=>{let e=G.current,t=e.state?.cwd??``;return[...e.conversations.map(e=>({id:e.id,title:e.title,cwd:e.cwd||t,kind:`running`,isStreaming:e.isStreaming})),...e.sessions.map(e=>({id:e.path,title:e.name||e.firstMessage||e.path,cwd:t,kind:`history`}))]},getConversationId:()=>G.current.state?.conversationId??null,isConversationBlank:()=>(G.current.state?.messages.length??0)===0,listModels:()=>G.current.models.map(e=>({id:e.id,provider:e.provider,name:e.name,vision:e.vision,reasoning:e.reasoning})),getCurrentModelId:()=>{let e=G.current.state?.model;return e?`${e.provider}/${e.id}`:null},listProjects:()=>G.current.projects.map(e=>e.path),grantedPaths:JS,grantPath:YS,confirm:e=>new Promise(t=>{if(Ue.current){t(!1);return}let n={path:e.path,resolve:t};Ue.current=n,He(n)}),openModal:e=>{let t=String(e??``).trim();if(!t)return!1;let n=he.current[`modal.dialog`].find(e=>e.id===t);return!n||n.hidden?!1:(fe(t),!0)},closeModal:()=>fe(null),dialogConfirm:e=>new Promise(t=>{if(Y.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Y.current=n,Ge(n)}),select:e=>new Promise(t=>{if(Y.current){t({ok:!1,error:`busy`});return}let n={kind:`select`,title:e.title,options:e.options,...e.multi?{multi:!0}:{},resolve:t};Y.current=n,qe([]),Ge(n)}),input:e=>new Promise(t=>{if(Y.current){t({ok:!1,error:`busy`});return}let n={kind:`input`,title:e.title,...typeof e.placeholder==`string`?{placeholder:e.placeholder}:{},...typeof e.initial==`string`?{initial:e.initial}:{},resolve:t};Y.current=n,Ye(e.initial??``),Ge(n)}),notifyAction:e=>new Promise(t=>{try{let n=Qe.current;Qe.current=null,Ze(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Qe.current=r,Ze(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=G.current.plugins.find(t=>t.id===e);return t?nl(t,G.current.pluginsEpoch):Promise.resolve(!1)}})),()=>Ks(null)),[r]);let[ge,q]=(0,g.useState)(()=>BS(`left`)),[_e,ve]=(0,g.useState)(()=>BS(`right`)),ye=(0,g.useCallback)(e=>q(e),[]),be=(0,g.useCallback)(e=>ve(e),[]),[xe,J]=(0,g.useState)(()=>HS(`left`)),[Se,Ce]=(0,g.useState)(()=>HS(`right`)),we=(0,g.useCallback)(()=>{J(e=>{try{localStorage.setItem(VS(`left`),e?`0`:`1`)}catch{}return!e})},[]),Te=(0,g.useCallback)(()=>{Ce(e=>{try{localStorage.setItem(VS(`right`),e?`0`:`1`)}catch{}return!e})},[]),[Ee,De]=(0,g.useState)(null),Oe=(0,g.useRef)(null),[ke,Ae]=(0,g.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,g.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>Ae(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),jS({enabled:ke&&w===`chat`,open:Ee,onOpenChange:De,container:Oe,backdropSelector:`.drawer-backdrop.persistent`});let[je,Me]=(0,g.useState)(!1),[Ne,Pe]=(0,g.useState)(!1),[Fe,Ie]=(0,g.useState)(!1),[Le,Re]=(0,g.useState)(),[ze,Be]=(0,g.useState)(null),[Ve,He]=(0,g.useState)(null),Ue=(0,g.useRef)(null),[We,Ge]=(0,g.useState)(null),Y=(0,g.useRef)(null),[Ke,qe]=(0,g.useState)([]),[Je,Ye]=(0,g.useState)(``),[Xe,Ze]=(0,g.useState)(null),Qe=(0,g.useRef)(null),[$e,et]=(0,g.useState)(()=>new Set),tt=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),et(t=>new Set(t).add(e))},nt=n.pathRequests.find(e=>!$e.has(e.id))??null,[rt,it]=(0,g.useState)(()=>new Set),at=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),it(t=>new Set(t).add(e))},ot=n.permRequests.find(e=>!rt.has(e.id))??null,st=wb(),[ct,lt]=(0,g.useState)(!1),[ut,dt]=(0,g.useState)(!1),[ft,pt]=(0,g.useState)(!1),[mt,ht]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!mt)return;let e=setTimeout(()=>ht(null),15e3);return()=>clearTimeout(e)},[mt]);let[gt,_t]=(0,g.useState)(null),vt=(0,g.useRef)(null),yt=(0,g.useRef)(null),bt=n.state?.sessionId??``,xt=(0,g.useRef)(bt);xt.current=bt;let St=(0,g.useRef)(n.ready);St.current=n.ready,(0,g.useEffect)(()=>{let e=()=>{let e=es(window.location.hash);if(e){if(e.messageId?_t({sessionId:e.sessionId,messageId:e.messageId}):_t(null),!St.current||!xt.current){vt.current=e.sessionId;return}xt.current!==e.sessionId&&(yt.current=e.sessionId,C(`chat`),r({type:`switch_session`,path:``,sessionId:e.sessionId}))}};return e(),window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[r]),(0,g.useEffect)(()=>{let e=yt.current;if(e&&n.notices.some(t=>t.text.includes(e)&&(t.text.includes(`未找到会话`)||t.text.includes(`Session not found`)))&&(yt.current=null,_t(null),bt)){let e=ts({sessionId:bt});window.location.hash!==e&&window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${e}`)}},[n.notices,bt]),(0,g.useEffect)(()=>{if(!n.ready||!bt)return;if(vt.current){let e=vt.current;if(vt.current=null,e!==bt){yt.current=e,C(`chat`),r({type:`switch_session`,path:``,sessionId:e});return}}if(yt.current){if(bt===yt.current)yt.current=null;else return}let e=es(window.location.hash),t=e?.sessionId===bt?e.messageId:void 0,i=ts({sessionId:bt,...t?{messageId:t}:{}});window.location.hash!==i&&window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${i}`)},[n.ready,bt,r]),(0,g.useEffect)(()=>{let t=t=>{let i=t.detail,a=i?.title||e(`pluginCommandFallback`),s=i?.command;if(!s||!n.ready)return;let c={name:a,command:s,cwd:"${pwd}"},l=n.terminals.find(e=>e.title===a);if(l)o.restart(l.id),r({type:`run_command`,terminalId:l.id,conversationId:l.conversationId,command:c,cols:80,rows:24});else{let e=jt();o.create({id:e,conversationId:n.activeConversationId||n.state?.conversationId||``,title:a,cwd:n.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:c})}C(`terminal`)};window.addEventListener(`pi-web-ui:plugin-run-command`,t);let i=e=>{let t=e.detail;typeof t==`string`&&t&&r({type:`switch_conversation`,id:t})};return window.addEventListener(`pi-web-ui:switch-conversation`,i),()=>{window.removeEventListener(`pi-web-ui:plugin-run-command`,t),window.removeEventListener(`pi-web-ui:switch-conversation`,i)}},[n,o,r]),(0,g.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),dt(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[Ct,wt]=(0,g.useState)(ob),[Tt,Et]=(0,g.useState)(Gt),{themes:Dt,theme:Ot,switchTheme:kt,reloadThemes:At}=_f();ex(),(0,g.useEffect)(()=>{try{typeof Ec==`function`&&Ec(Ot??``)}catch{}},[Ot]),(0,g.useEffect)(()=>{try{typeof Dc==`function`&&Dc(t)}catch{}},[t]),(0,g.useEffect)(()=>{try{typeof Oc==`function`&&Oc(w)}catch{}},[w]),(0,g.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof Sc==`function`&&Sc(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,g.useEffect)(()=>{if(!We)return;let e=e=>{if(e.key!==`Escape`)return;let t=Y.current;Y.current=null,Ge(null);try{if(!t)return;t.kind===`confirm`?t.resolve(!1):t.resolve({ok:!1})}catch{}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[We]),(0,g.useEffect)(()=>{if(!Xe)return;let e=setTimeout(()=>{let e=Qe.current;Qe.current=null,Ze(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[Xe]);let Mt=(0,g.useRef)(null),Nt=(0,g.useRef)(null),Pt=(0,g.useRef)(n.state?.messages);Pt.current=n.state?.messages;let Ft=(0,g.useRef)(new Set),It=(0,g.useRef)(new Set),Lt=(0,g.useRef)(new Set),Rt=(0,g.useRef)(0),zt=(0,g.useRef)(!1),Bt=(0,g.useRef)(n.terminals);(0,g.useEffect)(()=>{sb(Ct)},[Ct]),(0,g.useEffect)(()=>{Kt(Tt)},[Tt]),(0,g.useEffect)(()=>{let e=Bt.current;Bt.current=n.terminals;for(let t of n.terminals){let n=t.command?.command??``;e.find(e=>e.id===t.id)?.running&&!t.running&&(n.startsWith(`pi remove `)?r({type:`extensions_reload`}):n.startsWith(`pi-web-ui install `)||n.startsWith(`pi-web-ui uninstall `)?r({type:`plugins_reload`}):n.startsWith(`npm i -g `)&&(r({type:`extensions_reload`}),r({type:`plugins_reload`}),r({type:`check_updates_all`,force:!0})))}},[n.terminals,r]),(0,g.useEffect)(()=>{let t=n.state?.conversationId??null,r=MS(Mt.current,t,n.state?.isStreaming??!1,n.conversations,Nt.current);if(Mt.current=r.nextMap,Nt.current=t,r.startCue&&fb(`start`,Ct),r.finishedConvs.length>0){fb(`done`,Ct);let t=r.finishedConvs.find(e=>e.isActive);if(t&&(ai(e(`notifyDoneTitle`),e(`notifyDoneBody`)),Tt.enabled&&!Kr($r()))){if(Tt.readReplies){let t=Xt(Pt.current);t?on(t,Tt):Tt.announce&&on(e(`ttsAnnounceDone`),Tt)}else Tt.announce&&on(e(`ttsAnnounceDone`),Tt)}for(let t of r.finishedConvs.filter(e=>!e.isActive)){let n=t.title?`${t.title}:${e(`notifyDoneBody`)}`:e(`notifyDoneBody`);ai(e(`notifyDoneTitle`),n)}!t&&Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceDone`),Tt)}},[n.state?.conversationId,n.state?.isStreaming,n.conversations,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.dialog?.id??null;if(t!==null&&!Ft.current.has(t)){if(Ft.current.add(t),Ft.current.size>64){let e=Ft.current.values().next().value;e!==void 0&&Ft.current.delete(e)}fb(`question`,Ct),ai(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceQuestion`),Tt)}},[n.dialog,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null,i=!1;t!==null&&!It.current.has(t)&&(It.current.add(t),i=!0),r!==null&&!It.current.has(r)&&(It.current.add(r),i=!0);for(let e of n.conversations){if(!e.hasQuestion)continue;let n=e.questionId?`q:${e.questionId}`:`conv-q:${e.id}`;It.current.has(n)||(It.current.add(n),e.questionId&&It.current.add(e.questionId),t!==e.questionId&&(i=!0))}if(It.current.size>64){let e=It.current.values().next().value;e!==void 0&&It.current.delete(e)}i&&(fb(`question`,Ct),ai(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceQuestion`),Tt))},[n.question,n.remoteQuestion,n.conversations,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.approval,r=t?.id??null;if(r!==null&&!Lt.current.has(r)){if(Lt.current.add(r),Lt.current.size>64){let e=Lt.current.values().next().value;e!==void 0&&Lt.current.delete(e)}fb(`approval`,Ct);let n=typeof t?.toolName==`string`?t.toolName:``;ai(e(`notifyApprovalTitle`),n?e(`notifyApprovalBodyTool`,{tool:n}):e(`notifyApprovalBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceApproval`),Tt)}},[n.approval,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==Rt.current&&(Rt.current=t.id,fb(`error`,Ct),ai(e(`notifyErrorTitle`),e(`notifyErrorBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceError`),Tt))},[n.notices,Ct,Tt,e]);let Vt=(0,g.useRef)(new Set);(0,g.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||Vt.current.has(t.id))continue;Vt.current.add(t.id);let e=``;for(let n of t.content??[]){if(n.type!==`text`)continue;let t=/🔗 已自动在浏览器打开\]\((\/(?!\/)[^)\s]+)\)/.exec(n.text??``);if(t?.[1]){e=t[1];break}}if(!e)continue;let n=null;try{let t=new URL(fn(e),window.location.href);t.origin===window.location.origin&&document.hasFocus()&&(n=window.open(t.href,`_blank`,`noopener`))}catch{n=null}n||a(`info`,e)}},[n.state?.messages,a]);let Ht=(e,t,n,r=!1,i,a=!1)=>{let o=`${e}|${n}|${i?`${i.start}-${i.end}`:``}`;d(a=>a.some(e=>`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`===o)?a:[...a,{path:e,name:t,mode:n,isDir:r,...i?{lines:i}:{}}]);let s=n===`page`?t:e;!a&&s&&nr(`@${s} `)},Ut=e=>{let t=``;d(n=>n.filter(n=>{let r=n.key?n.key===e:n.mode===`conversation`?`conv|${n.conversationId??``}|${n.sessionPath??``}`===e:n.path===e;return r&&!t&&(t=n.mode===`page`||n.mode===`conversation`?n.name:n.path),!r})),t&&rr(`@${t}`)},Wt=(0,g.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&De(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&C(e=>e===`chat`?e:`chat`),r(e)),[r]),qt=(0,g.useRef)(new Set),Jt=n.activeConversationId||n.state?.conversationId||``;(0,g.useEffect)(()=>{let t=n.conversations.filter(e=>e.hasQuestion),r=new Set(t.map(e=>e.id)),i=new Set(t.map(e=>e.questionId).filter(Boolean));for(let e of qt.current)i.has(e)||qt.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===Jt){ly(t,{silent:!0});continue}n.questionId&&qt.current.has(n.questionId)||cy({id:t,type:`question`,title:n.title||e(`chat`),message:n.questionTitle||e(`waitingQuestionBadge`),persistent:!0,dismissible:!0,data:{conversationId:n.id,questionId:n.questionId},onClose:()=>{n.questionId&&qt.current.add(n.questionId)},onClick:()=>{Wt({type:`switch_conversation`,id:n.id}),ly(t,{silent:!0})}})}uy(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===Jt:!1},{silent:!0})},[n.conversations,Jt,Wt,e]);let Yt=(0,g.useRef)(0),Zt=(0,g.useRef)(0),Qt=(0,g.useCallback)(t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-Zt.current>1e4&&(Zt.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++Yt.current}`;d(e=>[...e,{path:``,key:i,name:t.name,imageData:t.data,mimeType:t.mimeType}])},[n.state?.model,a,e]),$t=(0,g.useCallback)(async t=>{for(let n of t){let t=await dm(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}Qt(t)}},[Qt,a,e]),en=20971520,tn=(0,g.useRef)(0),nn=(0,g.useCallback)(async t=>{if(t.size>en){a(`warning`,e(`fileTooLarge`,{name:t.name,size:en/1024/1024}));return}let n;try{n=(await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(t)})).replace(/^data:[^;]*;base64,/,``)}catch{a(`error`,e(`fileLoadFailed`,{name:t.name}));return}let r=`upload-${++tn.current}`;d(e=>[...e,{path:``,key:r,name:t.name,fileData:n,size:t.size,mimeType:t.type||void 0}])},[en,a,e]),rn=(0,g.useCallback)(async e=>{for(let t of e)um(t.type)?await $t([t]):await nn(t)},[$t,nn]),an=(0,g.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),sn=(0,g.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[cn,ln]=(0,g.useState)([]),un=(0,g.useRef)(0),dn=(0,g.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),un.current+=1;let i=ud(t),a={text:i.text,seq:un.current};i.quotes.length&&d(e=>e_(e,i.quotes.map(e=>({path:``,name:``,mode:`quote`,quote:e,key:jt()})))),ln(e=>[...e.slice(-9),a])},[r]),pn=(0,g.useCallback)(()=>Pe(!0),[]),mn=(0,g.useCallback)(()=>d([]),[]);by(n.state?.sessionId??``,mn);let hn=(0,g.useCallback)(Ut,[]),gn=$t,_n=rn,vn=(0,g.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),yn=(0,g.useCallback)(e=>Ht(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines,e.silent??!1),[]),bn=n.state?.model,xn=n.state?.thinkingLevel,Sn=n.state?.availableThinkingLevels,Cn=(0,g.useMemo)(()=>bn?{model:bn,thinkingLevel:xn??`off`,availableThinkingLevels:Sn??[]}:null,[bn,xn,Sn]),wn=(0,g.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:jt(),conversationId:n.activeConversationId||n.state?.conversationId||``,title:e(`terminalTitle`,{n:1}),cwd:n.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null}),!0),[n.ready,n.state?.cwd,n.terminals.length,e,o]);return(0,g.useEffect)(()=>{if(zt.current){if(w!==`terminal`||n.terminals.length!==0){zt.current=!1;return}wn()&&(zt.current=!1)}},[n.terminals.length,wn,w]),(0,X.jsxs)(`div`,{className:`app`,"data-pi-anchor":`app`,onDragOver:e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),x(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||x(!1)},onDrop:t=>{if(x(!1),!Array.from(t.dataTransfer?.types??[]).includes(`Files`))return;t.preventDefault();let n=Array.from(t.dataTransfer?.files??[]);if(n.length===0){a(`warning`,e(`foldersNotSupported`));return}let r=n.filter(e=>um(e.type)),i=n.filter(e=>!um(e.type));r.length>0&&$t(r),i.length>0&&rn(i)},children:[b&&(0,X.jsx)(`div`,{className:`app-drop-overlay`,"aria-hidden":!0,children:(0,X.jsxs)(`span`,{children:[`📎 `,e(`dropHereToAttach`)]})}),(0,X.jsx)(Yo,{chat:n,terminal:o,view:w,plugins:T,uiPrimary:D,uiOverflow:O,uiContextTopbar:E[`contextmenu.topbar`],onUiAction:V,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:()=>{Re(void 0),Ie(!0)},onManagePlugins:()=>{Re(`plugins`),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onOpenIconEdit:()=>pt(!0),sound:Ct,onSoundChange:wt,onSoundPreview:e=>fb(e,Ct),themes:Dt,theme:Ot,onThemeChange:kt,reloadThemes:At}),ft&&(0,X.jsx)(yy,{slots:E,layout:n.settings?.uiLayout,exclude:Ji,onClose:()=>pt(!1)}),n.protocolMismatch&&(0,X.jsxs)(`div`,{className:`protocol-banner`,children:[`⚠ `,e(`protocolMismatch`)]}),(0,X.jsxs)(`div`,{className:`notices`,children:[n.notices.map(e=>(0,X.jsx)(PS,{notice:e,onDismiss:i},e.id)),Xe&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:Xe.text}),Xe.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Qe.current;Qe.current=null,Ze(null);try{t?.resolve(e.id)}catch{}},children:e.label},e.id)),(0,X.jsx)(`button`,{type:`button`,className:`notice-close`,title:e(`close`),onClick:()=>{let e=Qe.current;Qe.current=null,Ze(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(P,{})})]}),z.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:z.map(e=>e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`btn btn-slot notice-select`,title:e.hint??e.label,"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>V(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id):(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-slot`,title:e.hint??e.label,onClick:()=>V(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)(Zh,{currentModelId:bn?`${bn.provider}/${bn.id}`:null,children:(0,X.jsxs)(`div`,{ref:Oe,className:`layout`,style:{"--left-w":`${ge}px`,"--right-w":`${_e}px`},children:[ke?(0,X.jsx)(`div`,{className:`drawer-backdrop persistent${Ee?` on`:``}`,onClick:()=>De(null)}):Ee&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>De(null)}),(0,X.jsx)(Dv,{side:`left`,items:oe,chat:n,view:w,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:e=>{Re(e),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onUiAction:V,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>kt(Ot===`light`?null:`light`),onSoundToggle:()=>wt({...Ct,enabled:!Ct.enabled})}),(0,X.jsxs)(`div`,{className:`view-pane ${w===`chat`?``:`hidden`}`,children:[!ke&&xe&&(0,X.jsx)(WS,{side:`left`,onClick:we}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${Ee===`left`?`open`:``}${ke?``:xe?` hidden`:``}`,children:(0,X.jsx)(pu,{collapsible:!ke,onToggleCollapse:we,panelSend:Wt,active:!ke||Ee===`left`,sessionFile:n.state?.sessionFile??null,conversations:n.conversations,elsewhere:n.elsewhere,sessions:n.sessions,projects:n.projects,pathCompletions:n.pathCompletions,activeConversationId:n.activeConversationId,uiContextSession:E[`contextmenu.session`],uiLeftSessions:k,uiContextProject:E[`contextmenu.project`],uiProjectsActions:A,uiLeftProject:j,uiRunningActions:ee,uiHistoryActions:M,uiSections:te,renderPluginSectionBody:H,uiLeftRunning:N,uiLeftHistory:ne,uiPluginRunning:n.pluginPanelGroups,onPluginRunningAction:se,onUiAction:V,presetNames:R,transition:n.transition,onOpenSandboxModal:()=>Be(`create`)})}),!ke&&(0,X.jsx)(US,{side:`left`,width:ge,onResize:ye}),(0,X.jsxs)(`main`,{className:`${st?`main wide-chat`:`main`}${n.transition&&!n.transition.previewMessages?.length?` main-transitioning`:``}`,children:[n.transition&&(0,X.jsxs)(`div`,{className:`workspace-transition-bar phase-${n.transition.phase}`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(`div`,{className:`workspace-transition-track`,children:(0,X.jsx)(`div`,{className:`workspace-transition-fill`,style:{width:`${Math.min(100,Math.max(8,n.transition.progress))}%`}})}),(0,X.jsxs)(`div`,{className:`workspace-transition-pill`,children:[(0,X.jsx)(`span`,{className:`workspace-transition-spinner`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`workspace-transition-text`,children:t!==`zh`&&n.transition.textEn?n.transition.textEn:n.transition.text}),(0,X.jsxs)(`span`,{className:`workspace-transition-pct`,children:[n.transition.progress,`%`]})]})]}),ae.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:rg(ae,V)}),n.state?(0,X.jsxs)(X.Fragment,{children:[n.state.sandbox&&(0,X.jsxs)(`div`,{className:`sandbox-banner`,role:`region`,"aria-label":n.state.sandbox.name,children:[(0,X.jsxs)(`div`,{className:`sandbox-banner-info`,children:[(0,X.jsxs)(`span`,{className:`sandbox-banner-title`,children:[`🧪 `,e(`sandboxBannerTitle`,{name:n.state.sandbox.name}),(0,X.jsx)(`span`,{className:`lp-sandbox-badge ${n.state.sandbox.ephemeral?`ephemeral`:`permanent`}`,children:n.state.sandbox.ephemeral?e(`sandboxBadgeEphemeral`):e(`sandboxBadgePermanent`)})]}),(0,X.jsx)(`span`,{className:`sandbox-banner-desc`,children:n.state.sandbox.sourcePath?e(`sandboxBannerSourceDesc`,{source:n.state.sandbox.sourcePath}):e(`sandboxBannerBlankDesc`)})]}),(0,X.jsxs)(`div`,{className:`sandbox-banner-actions`,children:[n.state.sandbox.ephemeral&&(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionPersistTip`),onClick:()=>r({type:`persist_sandbox`,path:n.state?.sandbox?.path}),children:[`📌 `,e(`sandboxActionPersist`)]}),n.state.sandbox.sourcePath&&(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn primary`,title:e(`sandboxActionApplySourceTip`),onClick:()=>Be(`apply`),children:[`✅ `,e(`sandboxActionApplySource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionPromoteTip`),onClick:()=>Be(`promote`),children:[`📤 `,e(`sandboxActionPromote`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionResetTip`),onClick:()=>{let t=n.state?.sandbox;t&&window.confirm(e(`sandboxActionResetConfirm`,{name:t.name}))&&r({type:`reset_sandbox`,path:t.path})},children:[`🔄 `,e(`sandboxActionReset`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn danger`,title:e(`sandboxActionDestroyTip`),onClick:()=>{let t=n.state?.sandbox;t&&window.confirm(e(`sandboxActionDestroyConfirm`,{name:t.name}))&&r({type:`destroy_sandbox`,path:t.path})},children:[`🗑️ `,e(`sandboxActionDestroy`)]})]})]}),n.state.isEphemeral&&(0,X.jsxs)(`div`,{className:`ephemeral-banner`,children:[(0,X.jsxs)(`span`,{children:[`🎭 `,e(`ephemeralBannerText`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`ephemeral-save`,onClick:()=>r({type:`persist_conversation`,id:Jt}),children:[`💾 `,e(`saveEphemeral`)]})]}),(0,X.jsx)(Yg,{uiMessageActions:E[`message.actions`],uiContextMessage:E[`contextmenu.message`],uiContextToolCall:E[`contextmenu.toolcall`],uiChatEmpty:I,onUiAction:V,state:n.transition?.previewMessages?.length?{...n.state,messages:n.transition.previewMessages,streamingMessage:null,isStreaming:!1}:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:an,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&Uh(`${e.provider}/${e.id}`)}},onRemoveQueued:sn,onRecallQueued:dn,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,keepRecent:n.settings?.keepRecentMessages,jumpTarget:mt,onJumpDone:()=>ht(null),urlJumpMessageId:gt&>.sessionId===n.state.sessionId?gt.messageId:null,onUrlJumpDone:()=>_t(null)},n.transition?.previewMessages?.length?`preview:${n.transition.target}`:n.state.conversationId??`boot`)]}):(0,X.jsx)(`div`,{className:`boot-wait`,children:n.ready?e(`loadingSession`):e(`connectingServer`)}),n.settings?.goalModeEnabled!==!1&&(0,X.jsx)(`div`,{className:`goalbar-slot`,children:(0,X.jsx)(dv,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:ie,onUiAction:V})}),(0,X.jsx)(ty,{onAction:(e,t,n)=>V(e,n,t)}),n.dialog&&(0,X.jsx)(Ov,{dialog:n.dialog}),We&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":We.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),We.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:We.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),We.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(We.options??[]).map((e,t)=>{let n=We.multi?Ke.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(We.multi){qe(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Y.current;Y.current=null,Ge(null);try{n?.resolve({ok:!0,selected:[e.label]})}catch{}},children:[e.label,e.description&&(0,X.jsx)(`span`,{className:`dialog-hint`,children:e.description})]},t)}),(We.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),We.multi&&(0,X.jsx)(`div`,{className:`dialog-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current,t=(e?.options??[]).filter((e,t)=>Ke.includes(t)).map(e=>e.label);Y.current=null,Ge(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),We.kind===`confirm`&&(0,X.jsx)(`div`,{className:`dialog-body`,children:(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve(!1)}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),We.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Je,placeholder:We.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>Ye(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!0,value:Je})}catch{}}}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!1})}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!0,value:Je})}catch{}},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(Rv,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||Jt))?.title}),n.remoteQuestion&&(0,X.jsx)(Rv,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(Gx,{plan:n.activeConversationId&&n.state?.conversationId!==n.activeConversationId?null:n.state?.plan}),(0,X.jsx)(uv,{composerLeading:E[`composer.leading`],composerActions:E[`composer.actions`],onUiAction:V,streaming:n.state?.isStreaming??!1,planMode:n.state?.planMode??!1,messages:n.state?.messages??FS,slashCommands:n.slashCommands,modelState:Cn,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:hn,onAddImageFiles:gn,onAddLocalFiles:_n,onAddPathAttachment:yn,fileSearch:n.fileSearch,onSearchFiles:vn,onNotice:a,onManageModels:pn,onSent:mn,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:cn,dshPermCurrent:n.state?.permission??null,dshPermOptions:n.dshPermission?.options??void 0,dshPermDefault:n.dshPermission?.defaultPreset,dshPreset:n.state?.agentPreset??null,dshPresets:n.dshPresets?.presets??void 0,dshPresetDefault:n.dshPresets?.defaultPreset,dshBlank:(n.state?.messages?.length??0)===0,conversationId:n.activeConversationId||n.state?.conversationId||``,sessionDraft:n.engine===`pi`?n.state?.draft??null:null,sessionId:n.state?.sessionId??``})]}),!ke&&(0,X.jsx)(US,{side:`right`,width:_e,onResize:be}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${Ee===`right`?`open`:``}${ke?``:Se?` hidden`:``}`,children:(0,X.jsx)(sd,{collapsible:!ke,onToggleCollapse:Te,panelSend:Wt,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{De(null),Ht(e,t,n,r)},onPreview:(e,t)=>{De(null),y(e,t)},onNotice:(e,t)=>a(e,t),uiRightPanelTabs:E[`rightpanel.tabs`],uiContextFile:E[`contextmenu.file`],plugins:T,pluginsEpoch:n.pluginsEpoch,send:r})}),!ke&&Se&&(0,X.jsx)(WS,{side:`right`,onClick:Te})]}),(0,X.jsx)(`div`,{className:`view-pane ${w===`terminal`?``:`hidden`}`,children:(0,X.jsx)(g.Suspense,{fallback:null,children:(0,X.jsx)(NS,{chat:n,terminal:o,uiTerminalToolbar:F,onUiAction:V})})}),(0,X.jsx)(`div`,{className:`view-pane ${w===`git`?``:`hidden`}`,children:(0,X.jsx)(Qv,{chat:n,terminal:o,active:w===`git`,onSwitchToTerminal:()=>C(`terminal`),uiScmToolbar:re,onUiAction:V})}),ce.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${w===t?``:`hidden`}`,children:(0,X.jsx)($v,{entry:e})},e.info.id)}),w.startsWith(`plugin:`)&&!ce.some(e=>`plugin:${e.info.id}`===w)&&(0,X.jsx)(ey,{pluginId:w.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===w),epoch:n.pluginsEpoch,failed:ue.includes(w.slice(7))}),(0,X.jsx)(Dv,{side:`right`,items:B,chat:n,view:w,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:e=>{Re(e),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onUiAction:V,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>kt(Ot===`light`?null:`light`),onSoundToggle:()=>wt({...Ct,enabled:!Ct.enabled})})]})}),(0,X.jsx)(hv,{chat:n,bottombarItems:E.bottombar,onUiAction:V,onOpenSettings:()=>{Re(void 0),Ie(!0)},onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenGlobalSearch:()=>dt(!0),onOpenBgTasks:()=>lt(!0)}),f&&(0,X.jsx)(mS,{file:f,content:n.fileContent,onAddLines:(e,t,n,r)=>Ht(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>Ht(e,t,n),onClose:()=>p(null),uiFilePreviewToolbar:L,onUiAction:V}),m&&(0,X.jsx)(vS,{file:m.file,plugin:m.plugin,declaration:m.declaration,epoch:n.pluginsEpoch,send:r,onClose:()=>h(null),onFallback:()=>{h(null),p(m.file)}}),n.ready&&n.state&&n.state.piConfigured===!1&&!je&&!Ne&&(0,X.jsx)(ky,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>Me(!0)}),Ne&&(0,X.jsx)(zy,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,fetchModelsResult:n.fetchModelsResult,testModelConnectionResult:n.testModelConnectionResult,enrichModelsResult:n.enrichModelsResult,enrichModelsProgress:n.enrichModelsProgress,refreshBuiltinResult:n.refreshBuiltinResult,refreshProviderResult:n.refreshProviderResult,appendBuiltinResult:n.appendBuiltinResult,cloneProviderResult:n.cloneProviderResult,defaultModel:n.defaultModel,onClose:()=>Pe(!1)}),Fe&&(0,X.jsx)(Rx,{chat:n,terminal:o,initialSection:Le,onSwitchToTerminal:()=>C(`terminal`),onClose:()=>Ie(!1),onOpenIconEdit:()=>pt(!0),sound:Ct,onSoundChange:wt,tts:Tt,onTtsChange:Et}),ct&&(0,X.jsx)(Bx,{servers:n.bgServers,plugins:n.plugins,epoch:n.pluginsEpoch,send:r,onUiAction:V,autoCleanupMin:n.settings?.bgAutoCleanupMin??0,onClose:()=>lt(!1)}),(0,X.jsx)(tS,{}),(0,X.jsx)(Vx,{}),(0,X.jsx)(Hx,{approval:n.approval}),n.tuiOverlay&&(0,X.jsx)(Ux,{overlay:n.tuiOverlay}),W&&(0,X.jsx)(sS,{entry:W,pluginView:pe?ce.find(e=>e.info.id===pe):void 0,onUiAction:(e,t)=>{V(e,t),fe(null)},onClose:()=>fe(null)}),(0,X.jsx)(oS,{open:ut,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>dt(!1),onSwitchSession:(e,t)=>{r({type:`switch_session`,path:e});let n=t&&t[0];ht(n?{path:e,role:n.role,timestamp:n.timestamp}:null)},onSwitchProject:e=>{r({type:`set_cwd`,path:e})},onPreviewFile:(e,t)=>{y(e,t)}}),(ot||nt||Ve)&&(0,X.jsxs)(`div`,{className:`modal-backdrop perm-modal-backdrop`,children:[ot&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginPermTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>at(ot.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[ot.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,ot.pluginId).replace(`{hosts}`,(ot.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,ot.pluginId).replace(`{models}`,(ot.models??[]).length>0?` ${(ot.models??[]).join(`, `)}`:``),ot.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:ot.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>at(ot.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>at(ot.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>at(ot.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),nt&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginGrantRequestTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>tt(nt.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginGrantRequestBody`).replace(`{plugin}`,nt.pluginId).replace(`{path}`,nt.path),nt.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:nt.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>tt(nt.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>tt(nt.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),Ve&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginSessionGrantTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{Ue.current=null,Ve.resolve(!1),He(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,Ve.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Ue.current=null,Ve.resolve(!1),He(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{Ue.current=null,Ve.resolve(!0),He(null)},children:e(`ok`)})]})]})]})]}),!Fe&&Object.values(n.pluginJobs??{}).some(e=>e.phase!==`done`)&&(0,X.jsxs)(`div`,{className:`active-plugin-jobs-bar`,onClick:()=>{Re(`plugins`),Ie(!0)},title:e(`pluginJobRunning`),children:[(0,X.jsx)(K,{className:`spin`}),(0,X.jsxs)(`span`,{className:`active-plugin-jobs-title`,children:[e(`pluginJobRunning`),`:`,` `,Object.values(n.pluginJobs??{}).filter(e=>e.phase!==`done`).map(e=>e.pluginId).join(`, `)]}),(()=>{let e=Object.values(n.pluginJobs??{}).find(e=>e.phase!==`done`),t=e?.lines[e.lines.length-1];return t?(0,X.jsx)(`span`,{className:`active-plugin-jobs-line`,children:t}):null})()]}),ze&&(0,X.jsx)(pv,{mode:ze,currentCwd:n.state?.cwd,currentSandbox:n.state?.sandbox,sandboxDiff:n.sandboxDiff,projects:n.projects,send:r,onClose:()=>Be(null)}),(0,X.jsx)(gy,{})]})}function ZS(){typeof document<`u`&&(QS($S()),tC())}function QS(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function $S(){let e=document.createElement(`div`);e.style.cssText=`position:fixed;top:-9999px;left:0;width:100px;height:100px;overflow-y:auto;scrollbar-gutter:stable both-edges;visibility:hidden;pointer-events:none;`,document.body.appendChild(e);let t=(e.offsetWidth-e.clientWidth)/2;return e.remove(),t}function eC(e){let t=document.createElement(`div`);t.style.cssText=`width:0;height:0;pointer-events:none;`,e.appendChild(t);let n=getComputedStyle(e),r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=Number.parseFloat(n.borderLeftWidth)||0,o=Number.parseFloat(n.paddingLeft)||0,s=i.left-(r.left+a+o);return t.remove(),s}function tC(){let e=()=>{let e=document.querySelector(`.messages`);return e?(QS(eC(e)),!0):!1},t=0;if(window.addEventListener(`resize`,()=>{t||=window.requestAnimationFrame(()=>{t=0,e()})}),e())return;let n=new MutationObserver(()=>{e()&&n.disconnect()});n.observe(document.documentElement,{childList:!0,subtree:!0}),window.setTimeout(()=>n.disconnect(),6e4)}mn(),hf(pf()),ZS(),(0,ee.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(g.StrictMode,{children:(0,X.jsx)(Mn,{children:(0,X.jsx)(XS,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=un();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,jt as c,he as d,me as f,P as g,L as h,vf as i,Ke as l,z as m,rg as n,Nn as o,K as p,ff as r,Z as s,ag as t,Se as u};
|