pi-web-ui 0.94.0 → 0.94.1

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-B-CMQuzm.js","assets/rolldown-runtime-hePW80VL.js","assets/react-CR5VJ85Q.js","assets/xterm-Cf5xxe4g.js","assets/xterm-B1njb2Cr.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-MVoxpJOA.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,i as o,n as s,o as c,r as l,s as u,t as d}from"./markdown-eUQn_o9D.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 f=e(t(),1),p={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},m=f.createContext&&f.createContext(p),h=[`attr`,`size`,`title`];function g(e,t){if(e==null)return{};var n,r,i=_(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 _(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 v(){return v=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},v.apply(null,arguments)}function y(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 b(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?y(Object(n),!0).forEach(function(t){x(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function x(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e){var t=C(e,`string`);return typeof t==`symbol`?t:t+``}function C(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 w(e){return e&&e.map((e,t)=>f.createElement(e.tag,b({key:t},e.attr),w(e.child)))}function T(e){return t=>f.createElement(E,v({attr:b({},e.attr)},t),w(e.child))}function E(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=g(e,h),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,v({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:b(b({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&f.createElement(`title`,null,i),e.children)};return m===void 0?t(p):f.createElement(m.Consumer,null,e=>t(e))}var D=r(),O=n();function k(e){return T({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 A(e){return T({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 j(e){return T({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 M(e){return T({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 N(e){return T({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 P(e){return T({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 F(e){return T({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 I(e){return T({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 L(e){return T({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 T({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 ee(e){return T({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 te(e){return T({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 ne(e){return T({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 z(e){return T({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 B(e){return T({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 V(e){return T({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 re(e){return T({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 ie(e){return T({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 H(e){return T({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 U(e){return T({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 ae(e){return T({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 oe(e){return T({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 se(e){return T({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 ce(e){return T({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 le(e){return T({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 ue(e){return T({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 de(e){return T({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 fe(e){return T({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 pe(e){return T({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 W(e){return T({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 me(e){return T({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 G(e){return T({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 he(e){return T({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 ge(e){return T({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 _e(e){return T({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 ve(e){return T({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 ye(e){return T({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 K(e){return T({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 be(e){return T({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 xe(e){return T({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 Se(e){return T({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 Ce(e){return T({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 q(e){return T({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 we(e){return T({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 Te(e){return T({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 J(e){return T({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 Ee(e){return T({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 De(e){return T({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 Y(e){return T({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 Oe(e){return T({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 ke(e){return T({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 Ae(e){return T({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 je(e){return T({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 Me(e){return T({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 Ne(e){return T({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 Pe(e){return T({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 Fe(e){return T({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 Ie(e){return T({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 Le(e){return T({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 Re(e){return T({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 ze(e){return T({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 Be(e){return T({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 Ve(e){return T({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 He(e){return T({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 Ue(e){return T({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 We(e){return T({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 Ge(e){return T({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 Ke(e){return T({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 qe(e){return T({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 Je(e){return T({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 Ye(e){return T({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 Xe(e){return T({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 Ze(e){return T({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 Qe(e){return T({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 $e(e){return T({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 et(e){return T({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 tt(e){return T({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 nt(e){return T({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 rt(e){return T({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 it(e){return e.map(e=>e.kind===`package`?`pi update npm:${e.name}`:e.kind===`git-extension`?`pi update ${at(e.source??e.name)}`:`npm i -g ${e.name}@latest`).join(`; `)}function at(e){return e.startsWith(`git:`)?e:`git:${e}`}function ot(){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 st(e,t,n={}){let{enabled:r=!0,ignore:i}=n,a=(0,f.useRef)(t);(0,f.useLayoutEffect)(()=>{a.current=t}),(0,f.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 ct=[],lt=!1;function ut(e){if(e.key===`Escape`&&ct.length!==0)for(let t=ct.length-1;t>=0;t--){let n=ct[t];if(n()!==!1){e.preventDefault(),e.stopPropagation();break}}}function dt(){!lt&&typeof document<`u`&&(document.addEventListener(`keydown`,ut,!0),lt=!0)}function ft(){lt&&ct.length===0&&typeof document<`u`&&(document.removeEventListener(`keydown`,ut,!0),lt=!1)}function pt(e){return ct.push(e),dt(),()=>{let t=ct.lastIndexOf(e);t>=0&&ct.splice(t,1),ft()}}function mt(e,t=!0){let n=(0,f.useRef)(e);(0,f.useLayoutEffect)(()=>{n.current=e}),(0,f.useEffect)(()=>{if(t)return pt(()=>n.current())},[t])}var X=i();function ht({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 gt({trigger:e,open:t,onOpenChange:n,children:r,align:i=`right`,fit:a=!1,direction:o=`down`,tip:s,menuClassName:c,menuRef:l,menuStyle:u}){let d=(0,f.useRef)(null),p=(0,f.useRef)(null),[m,h]=(0,f.useState)(0),g=e=>{p.current=e,typeof l==`function`?l(e):l&&`current`in l&&(l.current=e)},_=()=>{let e=d.current,t=p.current;if(!e||!t)return;if(window.innerWidth<=768){m!==0&&h(0);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.width===0&&r.height===0||n.width===0){m!==0&&h(0);return}let a=n.width,o=ht({align:i,triggerLeft:r.left,triggerRight:r.right,menuWidth:a,viewportWidth:window.innerWidth,margin:8});o!==m&&h(o)};return(0,f.useLayoutEffect)(()=>{t?_():m!==0&&h(0)}),(0,f.useEffect)(()=>{if(t)return window.addEventListener(`resize`,_),()=>window.removeEventListener(`resize`,_)},[t,m]),st(d,()=>n(!1),{enabled:t}),mt(()=>n(!1),t),(0,X.jsxs)(`div`,{className:`dropdown ${i} ${a?`fit`:``} ${o===`up`?`dd-up`:``}`,ref:d,children:[(0,X.jsxs)(`button`,{type:`button`,className:`chip`,onClick:()=>n(!t),"aria-expanded":t,"data-tip":s,children:[e,(0,X.jsx)(Ge,{className:`dd-caret ${t?`up`:``}`})]}),t&&(0,X.jsx)(`div`,{className:`dd-menu ${c??``}`,ref:g,style:m===0?u:{...u,transform:u?.transform?`${u.transform} translateX(${m}px)`:`translateX(${m}px)`},children:r})]})}function _t({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 vt=null;function yt(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 bt(){return vt===null&&(vt=yt()),vt}function xt(e,t){return t===`/`?e:t+e.replace(/^\/+/,``)}function St(e){return xt(e,bt())}var Ct=`pi-web-ui:token`;function wt(){try{let e=new URL(window.location.href),t=e.searchParams.get(`token`);t&&(localStorage.setItem(Ct,t.trim()),e.searchParams.delete(`token`),window.history.replaceState(null,``,e.toString()))}catch{}}function Tt(){try{return localStorage.getItem(Ct)??``}catch{return``}}function Et(e){let t=Tt();return t?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(t)}`:e}var Dt=[`zh`,`en`,`de`,`es`,`fr`,`it`,`ja`,`ko`,`pt`,`ru`];function Ot(e,t,n,r=Dt){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 kt=`pi-web-ui:lang`,At={docTitle:`pi-web-ui — pi 编码智能体`,cancel:`取消`,ok:`确定`,save:`保存`,close:`关闭`,widgetExpand:`点击放大查看完整输出`,collapsePanel:`收起面板`,expandPanel:`展开面板`,dragToResize:`拖拽调整宽度 · 双击复位`,loading:`加载中…`,connected:`已连接`,connecting:`连接中…`,reconnecting:`重连中…`,language:`语言`,langZh:`中文`,langEn:`English`,langIt:`Italiano`,langJa:`日语`,langKo:`韩语`,langFr:`法语`,langDe:`德语`,langEs:`西班牙语`,langRu:`俄语`,langPt:`葡萄牙语`,githubRepo:`GitHub 仓库(xing-shuyin/pi-web-ui)`,copy:`复制`,viewSwitch:`视图切换`,chat:`对话`,terminal:`终端`,selectModel:`选择模型`,availableModels:`可用模型`,allProviders:`全部`,providers:`服务商`,noModels:`暂无可用模型(请先配置 API 密钥)`,reasoning:`推理`,vision:`识图`,refreshModels:`刷新模型列表(保留手填,合并新增)`,manageModels:`⚙ 管理模型(新增 / 修改)`,manageModelsTitle:`管理模型`,setGlobalDefault:`☆ 设为全局默认(新项目自动使用)`,clearGlobalDefault:`★ 取消全局默认`,globalDefaultBadge:`全局默认`,thinkingLevel:`思考强度`,thinking:`思考`,thinkingChip:`思考:{level}`,sound:`声音`,theme:`主题`,themeDefault:`深色(默认)`,themeGroupClassics:`现代经典`,themeGroupBuiltin:`原始预设`,themeLight:`浅色`,themeDark:`深色`,newChat:`新对话`,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)和随机存取内存(RAM)使用率`,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:`刷新`,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 命令`,slashHelpHint:`输入 / 随时打开命令列表`,slashLoading:`命令列表加载中…(连接服务器后可用)`,slashBuiltin:`内置`,slashExtension:`扩展`,slashPrompt:`模板`,slashSkill:`技能`,slashPlugin:`插件`,slashCopied:`已复制上一条助手回复`,slashCopyFailed:`复制失败,请手动复制`,slashCopyEmpty:`还没有可复制的助手回复`,recentProjects:`最近项目`,runningConversations:`运行的对话`,elsewhereBadge:`另一处`,elsewhereTip:`在其他标签页 / 设备上打开的对话(运行中或已结束未关闭,右键可过户到本页查看)`,takeoverConversation:`过户到当前页面`,takeoverHasQuestion:`有问卷等答复,点击直接作答`,waitingQuestionBadge:`有问卷等答复,点击查看`,subagentBadge:`子代理`,convErrorBadge:`子代理运行报错:{error}`,subagentTitle:`子代理 · {title}`,historySessions:`历史对话`,openHistory:`历史对话`,openFiles:`文件列表`,openProject:`打开项目`,streaming:`进行中…`,noHistory:`还没有历史对话`,current:`当前`,messageCount:`{n} 条消息`,tuiTip:`pi 终端(TUI)中的对话`,deleteProject:`从最近项目移出`,deleteProjectConfirm:`确认移出`,deleteSession:`删除该对话记录(不可恢复)`,deleteSessionConfirm:`确认删除`,renameSession:`重命名该对话`,renameSessionPlaceholder:`输入新名称…`,renameSessionConfirm:`重命名`,dismissConversation:`从运行列表移出(历史记录保留)`,dismissConversationConfirm:`确认移出`,dismissFinishedSubagents:`关闭已结束的子代理({n} 个)`,dismissFinishedSubagentsScoped:`关闭该对话下已结束的子代理(含嵌套,{n} 个)`,dismissConversationWithSubagents:`同时关闭已结束的子代理({n} 个)?请确认其结果已不再需要,再点一次确认`,dismissConversationWithSubagentsMixed:`同时关闭已结束的子代理({n} 个)?运行中的 {m} 个不受影响、父对话暂留;请确认已结束的已不再需要,再点一次确认`,dismissStreamingConfirm:`仍在运行,确认强行关闭?(运行将被中止)`,dismissFinishedOnly:`仅关已结束({n})`,dismissForceAll:`强行全关(含子代理 {n})`,forceDismissTitle:`强行关闭本对话及全部 {n} 个子代理(运行中的 {m} 个将被中止)`,forceDismissConversation:`强行关闭对话(含全部子代理)`,persistSubagent:`固化为普通对话`,forceDismissConfirm:`确认强行关闭?未结束的运行将被中止,再点一次`,noFinishedSubagents:`没有可关闭的已结束子代理`,collapseSection:`折叠`,expandSection:`展开`,emptyChat:`空对话`,editReask:`编辑重问`,editReaskTip:`修改此问题,并从这里重新提问(会新建一个分支对话,原对话保留)`,reaskFromHere:`从此处重新提问`,editPlaceholder:`修改问题内容…`,editHint:`⌘/Ctrl+Enter 提交 · Esc 取消`,editAttachmentHint:`原附件已保留,可粘贴/拖入新图片或文件 · ⌘/Ctrl+Enter 提交 · Esc 取消`,expandMsg:`展开`,collapseMsg:`收起`,toolCalls:`工具调用`,bashRuns:`终端运行`,images:`图片`,update:`更新`,updateTip:`检查并更新 pi-web-ui`,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 组件`,updatesAllRefresh:`重新检查全部`,updateCheckFailed:`检查失败`,updateBtn:`更新`,updateAllBtn:`全部更新`,updatePkgTabTitle:`更新 {name}`,updateAllTabTitle:`更新全部组件`,restartService:`重启服务`,restartingService:`重启中…`,restartServiceTip:`重启 pi-web-ui 服务({name}):本实例由系统服务托管(launchd/systemd/Windows watchdog),进程退出后会被自动拉起,本页会自动重连;更新完成后用它生效`,computer:`此电脑`,rootDir:`根目录`,homeDir:`用户目录`,desktopDir:`桌面`,filesHelp:`浏览:点文件夹进入、点文件预览,「..」返回上级;「根目录」回当前项目根,「此电脑」浏览全盘换盘符,「🏠」直达用户目录,「🖥️」直达桌面。
3
3
  文件操作:右键可新建文件/文件夹、重命名、复制/剪切/粘贴、创建副本、删除、上传文件;文件可下载,行尾按钮可复制名称/路径。
4
4
  切换项目:文件夹右键「以项目打开」,或点右下角 📁 路径按钮输入/选择目录。
@@ -323,7 +323,7 @@ Avoid three test anti-patterns: tests coupled to the implementation, tautologica
323
323
 
324
324
  {path}
325
325
 
326
- 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`,dshPresetCurrent:`current`,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)`,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`,schedulerNameLabel:`Task name`,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)`,schedulerPromptLabel:`Prompt`,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 the settings above, then save them as a preset)`,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`,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`,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)`,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`,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.`},Mt=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],Nt={};function Pt(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(Nt[e.code]=e,!0)}function Ft(e){delete Nt[e]}function It(e){return e===`zh`?`中文`:e.toUpperCase()}function Lt(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function Rt(e){let t=await fetch(Et(St(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var zt=(0,f.createContext)(null);function Bt(){try{return localStorage.getItem(kt)}catch{return null}}function Vt(){return Ot(Bt(),typeof navigator<`u`?navigator.languages:[],null)}function Ht({children:e}){let[t,n]=(0,f.useState)(Vt),[r,i]=(0,f.useState)(0),a=(0,f.useRef)(t);a.current=t;let o=(0,f.useCallback)(e=>{n(e);try{localStorage.setItem(kt,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,f.useCallback)(async()=>{let e,t=null;try{let n=await Rt(`/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 Rt(`/api/locales/${e.code}`);return Pt({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,f.useEffect)(()=>{s().then(e=>{if(!Bt()?.trim()){let t=Ot(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!Nt[t]){let t=Ot(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(kt,t)}catch{}}})},[s]);let c=(0,f.useMemo)(()=>[...Mt,...Object.values(Nt).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,f.useCallback)((e,n)=>{let r=Nt[t]?.strings[e]??(t===`zh`?At[e]:jt[e]);if(n)for(let[e,t]of Object.entries(n))r=r.replaceAll(`{${e}}`,String(t));return r},[t,r]);(0,f.useEffect)(()=>{document.documentElement.lang=Lt(t)},[t]);let u=(0,f.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(zt.Provider,{value:u,children:e})}function Ut(){let e=(0,f.useContext)(zt);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return Ut().t}var Wt=[{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`}];function Gt({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)(N,{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})})]}),Wt.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 Kt(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 qt=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),Jt=null,Yt=0;function Xt(){return Jt?.available===!0?Jt.pages??[]:[]}function Zt(){Date.now()-Yt<5e3||Qt().catch(()=>{})}async function Qt(){if(Kt())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=qt();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&&(Jt=r,Yt=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function $t(e){return e.length===1?e[0]:null}function en(e){return{path:e.origin,name:e.title?.trim()||e.origin,mode:`page`,key:`page:${e.origin}`}}async function tn(){let e=qt();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function nn(e=45e3){let[t,n]=(0,f.useState)(null),r=(0,f.useRef)(!0),i=(0,f.useCallback)(async e=>{let t=await Qt();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,f.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 rn=null,an=null,on=null;function sn(e){rn=e}function cn(e){an=e}function ln(e){on=e}function un(){return on?(on(),!0):!1}function Q(){return!!(rn||an)}function dn(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&&!rn||i&&!an?!1:(i&&an?.(n),r&&rn?.(t),!0)}function fn(){let e=Z(),{status:t,refresh:n}=nn(),[r,i]=(0,f.useState)(!1),[a,o]=(0,f.useState)(null),s=(0,f.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=$t(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},p=t=>{let n=dn({attachments:[en(t)]});d(e(n?`browserControlCited`:`browserControlCiteFailed`))},m=()=>{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:()=>p(u),children:[(0,X.jsx)(de,{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:m,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:m,children:[(0,X.jsx)(de,{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)(pn,{status:t,onRefresh:n,onCite:p,onClose:()=>i(!1)})]})}function pn({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,f.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await tn()||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)(de,{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 mn=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],hn=[`subagent_spawn`,`subagent_get_result`,`subagent_steer`,`subagent_list`,`subagent_stop`,`subagent_wait_all`,`subagent_templates`],gn=`edit_soft`,_n=`delegate_task`,vn=`ask_user_question`,yn=`todo_list`,bn=`browser_page`,xn=`conversation_read`,Sn=`skill`,Cn=`schedule_task`,wn=`schedule_list`,Tn=`schedule_cancel`,En=`present_files`,Dn=`claim_files`,On=[...mn.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...hn.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:gn,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:_n,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:vn,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:bn,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:xn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:Dn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:En,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:Sn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:Cn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:wn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:Tn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:yn,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}];new Set(On.map(e=>e.name));var kn=`pi-web-notify`,An={enabled:!1};function jn(){try{let e=localStorage.getItem(kn);if(!e)return{...An};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:An.enabled}}catch{return{...An}}}function Mn(e){try{localStorage.setItem(kn,JSON.stringify(e))}catch{}}function Nn(){return typeof window<`u`&&`Notification`in window}function Pn(){return Nn()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function Fn(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&In(t)||Number.isFinite(n)&&In(n)?!0:r>0&&r<=400&&i>0&&i<=40}function In(e){return e<=-1e4}function Ln(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var Rn=Date.now(),zn=!1;function Bn(){Rn=Date.now()}function Vn(){return Math.max(0,Date.now()-Rn)}function Hn(){if(zn||typeof window>`u`)return;zn=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,Bn,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,Bn,e)}function Un(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function Wn(){return Hn(),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:Fn({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Vn(),windows:Un()}}function Gn(){return Nn()?Notification.permission:`denied`}async function Kn(){if(!Nn())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function qn(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function Jn(e,t=!1){return{body:e,requireInteraction:t,icon:St(`/icons/icon-192.png`),badge:St(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:St(`/`)}}}async function Yn(e,t,n=!1){if(!Nn())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=Jn(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=qn(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${qn(e)}`}}}async function Xn(e,t){Nn()&&(Ln(Wn())||jn().enabled&&await Yn(e,t))}var Zn=!1;function Qn(){let e=Z(),[t,n]=(0,f.useState)(jn),[r,i]=(0,f.useState)(()=>Gn()),[a,o]=(0,f.useState)(null),s=Pn(),c=s!==null,l=Un();(0,f.useEffect)(()=>{let e=()=>i(Gn());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),Mn(r),e){let e=await Kn();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),Mn(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)(Ze,{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`)}),Zn]})}var $n=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),er=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(`.`)),tr=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),nr=new Set([...$n].map(e=>e.toLowerCase())),rr=new Set([...er].map(e=>e.toLowerCase()));function ir(e){return nr.has(e.toLowerCase())}function ar(e){return rr.has(e.toLowerCase())}function or(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[...e.children]){let e=t.tagName.toLowerCase();if(!ir(e)){tr.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of[...t.attributes]){let n=e.name.toLowerCase();(!ar(n)||/^on/i.test(n)||/^(javascript|data|vbscript):/i.test(e.value.trim()))&&t.removeAttribute(e.name)}i(t)}};for(let e of[...r.attributes]){let t=e.name.toLowerCase();(!ar(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function sr({icon:e,iconSvg:t,className:n}){let r=or(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 cr=[`topbar.primary`,`topbar.overflow`,`notice.actions`,`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.file`,`contextmenu.toolcall`,`settings.pages`,`modal.dialog`],lr=[{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: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: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-edit-reask`,slot:`message.actions`,labelKey:`editReask`,icon:`edit`,kind:`action`,order:10},{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: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-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-inline`,slot:`file.preview.toolbar`,labelKey:`attachInlineTip`,icon:`plus`,kind:`action`,order:60},{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-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-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:lp-projects`,slot:`leftpanel.sessions`,labelKey:`recentProjects`,icon:`folder`,kind:`action`,order:10},{id:`host:lp-running`,slot:`leftpanel.sessions`,labelKey:`runningConversations`,icon:`activity`,kind:`action`,order:20},{id:`host:lp-history`,slot:`leftpanel.sessions`,labelKey:`historySessions`,icon:`clock`,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-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-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-inline`,slot:`contextmenu.file`,labelKey:`attachInlineTip`,icon:`plus`,kind:`action`,context:`file`,order:31,group:`chat`},{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:tool-info`,slot:`contextmenu.toolcall`,labelKey:`toolInfoMenuLabel`,icon:`info`,kind:`action`,context:`toolcall`,order:10}],ur=new Set([`host:lp-projects`,`host:lp-running`,`host:lp-history`]),dr=`__view`,fr=new Set([`host:settings`]);function pr(e){return`${e}:${dr}`}function mr(e){return e.source.startsWith(`plugin:`)?e.id===pr(e.source.slice(7)):!1}function hr(e,t,n){let r=pr(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 gr(e,t){let n=t.map(pr),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var _r=`host:brand`,vr=[`host:brand-logo`,`host:brand-name`];function yr(e){if(!((e.hidden??[]).some(e=>vr.includes(e))||(e.shown??[]).some(e=>vr.includes(e))||(e.order??[]).some(e=>vr.includes(e))||vr.some(t=>e.align?.[t]!==void 0)||vr.some(t=>e.groups?.[t]!==void 0)||vr.some(t=>e.labels?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=vr.includes(n)?_r: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))vr.includes(t)||(n[t]=r);if(n[`host:brand`]===void 0){let r=t?e[vr[0]]??e[vr[1]]:e[vr[1]]??e[vr[0]];r!==void 0&&(n[_r]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))vr.includes(n)||(t[n]=r);if(t[`host:brand`]===void 0){let n=e[vr[0]]??e[vr[1]];n!==void 0&&(t[_r]=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)}:{}}}function br(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:dr,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 xr(e){return typeof e==`string`&&cr.includes(e)}function Sr(e,t){return t?e.label:e.labelEn??e.label}function Cr(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function wr(e,t,n,r,i){let a=`${e}#${r.id}`,o=Tr(a,t,n,r.children,i),s=Cr(r,i),c=Er(r.options,i);return{id:a,slot:t,source:n,label:Sr(r,i),...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 Tr(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:wr(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 Er(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 Dr(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function Or(e,t,n,r,i,a){let o=Tr(e,t,n,r.children,i),s=Cr(r,i),c=Dr(r.progress),l=Er(r.options,i);return{id:e,slot:t,source:n,label:Sr(r,i),...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 kr(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 Ar(e){let t=e.filter(e=>mr(e));if(t.length===0)return e;let n=e.filter(e=>!mr(e)),r=[`host:git`,`host:terminal`,`host:chat`].map(e=>n.findIndex(t=>t.id===e)).find(e=>e>=0)??-1,i=n.findIndex(e=>e.id===`host:plugins`),a=r+1;return i>=a&&(a=i),a=Math.max(0,Math.min(a,n.length)),[...n.slice(0,a),...t,...n.slice(a)]}function jr(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=yr(t.layout??{}),a=new Map,o=0;for(let e of lr)a.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:o++});for(let t of e){if(t.error||r.has(t.id))continue;let e=`plugin:${t.id}`;for(let r of t.ui?.items??[]){if(!xr(r.slot))continue;let i=`${t.id}:${r.id}`,s=a.get(i);a.set(i,Or(i,r.slot,e,r,n,s?.seq??o++))}}for(let t of e)if(!(t.error||r.has(t.id)))for(let e of t.ui?.arrange??[])Nr(a,e,t.id);let s=new Map,c=(e,t)=>{let n=s.get(e)??[];n.includes(t)||n.push(t),s.set(e,n)};for(let e of i.hidden??[]){let t=a.get(e);t&&(t.hidden=!0,c(e,`hidden`))}for(let e of i.shown??[]){let t=a.get(e);t&&(t.hidden=!1,c(e,`hidden`))}for(let[e,t]of Object.entries(i.groups??{})){let n=a.get(e);n&&(n.group=t,c(e,`group`))}for(let[e,t]of Object.entries(i.align??{})){let n=a.get(e);!n||t!==`start`&&t!==`center`&&t!==`end`||(n.align=t,c(e,`align`))}for(let[e,t]of Object.entries(i.labels??{})){let n=a.get(e);n&&(n.label=t,c(e,`label`))}for(let e of fr){let t=a.get(e);t&&(t.slot=`topbar.primary`,t.hidden=!1)}let l=new Map;(i.order??[]).forEach((e,t)=>{a.has(e)&&(l.has(e)||l.set(e,t),c(e,`order`))});let u=new Map;for(let e of cr)u.set(e,[]);for(let e of a.values())u.get(e.slot)?.push(e);let d={};for(let e of cr){let t=kr(u.get(e)??[],l);d[e]=(e===`topbar.primary`?Ar(t):t).map(e=>Mr(e,s.get(e.id)??[]))}return d}function Mr(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function Nr(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,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&&xr(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 Pr(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 Fr(e,t){let n=e??{},r={},i=t===`host:brand`?[t,...vr]:[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=Lr(n.groups,t),l=Lr(n.labels,t),u=Lr(n.align,t);if(t===`host:brand`)for(let e of vr)c=Lr(c,e),l=Lr(l,e),u=Lr(u,e);return c&&(r.groups=c),l&&(r.labels=l),u&&(r.align=u),n.topbarText!==void 0&&(r.topbarText=n.topbarText),r}function Ir(){return{}}function Lr(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 Rr=new Set([`host:files`]);function zr(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 Br(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 Vr=null,Hr=new Set;function Ur(){for(let e of Hr)e()}function Wr(e){Vr={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}:{}},Ur()}function Gr(){Vr!==null&&(Vr=null,Ur())}function Kr(e){return Hr.add(e),()=>{Hr.delete(e)}}function qr(){return Vr}function Jr(){return(0,f.useSyncExternalStore)(Kr,qr,qr)}function Yr(e){return Number.isFinite(e)?e:0}function Xr(e,t,n,r,i,a){let o=Math.max(0,Yr(n)),s=Math.max(0,Yr(r)),c=Math.max(8,Yr(i)-o-8),l=Math.max(8,Yr(a)-s-8);return{x:Math.min(Math.max(8,Yr(e)),c),y:Math.min(Math.max(8,Yr(t)),l)}}function Zr(e,t){let n=String(t?.kind??``);if(e===`contextmenu.file`)return{"file.isDir":n===`dir`,"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 Qr(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 $r(e,t){return!e||Qr(e.when,t)}function ei(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 ti(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 ni(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 ri(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!$r(e,t)}function ii(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,ri(e[o],r))return o;return-1}var ai={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:`〜`};function oi(e){let t=(e??``).trim();return t?ai[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var si={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},ci=new Set;function li(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function ui(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&&li(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&li(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function di(e){let t={...si,...e};if(!ui(si,t)){si=t;for(let e of ci)e()}}function fi(e){return ci.add(e),()=>{ci.delete(e)}}function pi(){return si}function mi(){return(0,f.useSyncExternalStore)(fi,pi,pi)}function hi(e){return(0,f.useSyncExternalStore)(fi,()=>si[e],()=>si[e])}function gi(){return hi(`engine`)===`dsh`}function _i(){return hi(`managed`)}function vi(){return hi(`service`)}var yi=null;function bi(e){yi=e}var $=e=>yi?yi(e):!1,xi=`@root`,Si=e=>e.endsWith(`/`)?e:e+`/`;function Ci(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function wi(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var Ti=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)?xi:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function Ei({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z(),[c,l]=(0,f.useState)(``),[u,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(null),[y,b]=(0,f.useState)(-1),x=(0,f.useRef)(null),S=(0,f.useRef)(null),C=n.filter(e=>e.type===`dir`);if((0,f.useEffect)(()=>{if(e){let e=(t||``).replace(/\\/g,`/`);l(e),d(e),m(!1),g(``),v(null),b(-1)}},[e,t]),(0,f.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{x.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,f.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(p?(m(!1),g(``),v(null)):i())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,p,i]),(0,f.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{$({type:`complete_path`,path:Si(c)})},60);return()=>clearTimeout(t)},[c,e]),(0,f.useEffect)(()=>{if(!e||u===c)return;let t=setTimeout(()=>{$({type:`complete_path`,path:u})},150);return()=>clearTimeout(t)},[u,c,e]),!e)return null;let w=e=>{let t=e.trim();t&&t!==`@root`&&(a(t),i())},T=()=>{let e=h.trim();if(!wi(e)){v(s(`invalidProjectName`));return}o(Ci(c,e)),m(!1),g(``),v(null),i()},E=e=>{if(e.key===`Escape`)e.stopPropagation(),p?(m(!1),g(``),v(null)):i();else if(e.key===`Enter`&&!e.nativeEvent.isComposing)w(u);else if(e.key===`Tab`){if(C.length===0)return;e.preventDefault();let t=y>=0?(y+1)%C.length:0;b(t),d(C[t].path),l(C[t].path)}},D=Ti(c),O=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},k=O(c),A=!!c&&c!==`@root`&&k!==O(t)&&!r.some(e=>O(e)===k);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`status-cwd-backdrop project-picker-backdrop`,onClick:i}),(0,X.jsxs)(`div`,{className:`cwd-picker project-picker`,role:`dialog`,"aria-label":s(`projectPickerTitle`),children:[(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:c===`@root`?s(`computer`):c,children:[c===`@root`?`💻`:(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{children:c===`@root`?s(`computer`):c})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:c===xi,title:s(`computer`),onClick:()=>{l(xi),d(xi),b(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!D,title:s(`cwdGoUp`),onClick:()=>{D&&(l(D),d(D),b(-1))},children:[`↑ `,s(`cwdGoUp`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!A,title:s(`addWorkspaceRootHint`),onClick:()=>{A&&$({type:`set_workspace_roots`,roots:[...r,c]})},children:[`+ `,s(`addWorkspaceRoot`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:x,className:`status-cwd-input cwd-picker-input`,value:u,placeholder:s(`enterPath`),spellCheck:!1,onChange:e=>{d(e.target.value),b(-1)},onKeyDown:E}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:s(`cwdPickCurrent`),disabled:c===xi,onClick:()=>w(c),children:s(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[C.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:s(`cwdEmpty`)}),C.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${s(`cwdEnter`)} ${e.path}`,onClick:()=>{l(e.path),d(e.path),b(-1)},children:[(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:s(`cwdChoose`),onClick:()=>w(e.path),children:s(`cwdChoose`)})]},e.path))]}),(0,X.jsxs)(`div`,{className:`cwd-picker-foot`,children:[p?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:S,value:h,autoFocus:!0,spellCheck:!1,placeholder:s(`projectName`),onChange:e=>{g(e.target.value),_&&v(null)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),T()):e.key===`Escape`&&(e.stopPropagation(),m(!1),g(``),v(null))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:T,children:s(`createAndOpenProject`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{m(!1),g(``),v(null)},children:s(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>m(!0),children:[`+ `,s(`newProject`)]}),_&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:_})]})]})]})}function Di(e){return T({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 Oi(e){return T({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 ki(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 Ai(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,f.useRef)(null),[d,p]=(0,f.useState)(null),m=(0,f.useRef)(i);(0,f.useLayoutEffect)(()=>{m.current=i});let h=()=>{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},g=()=>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=g(),i=r&&r.isConnected?r.getBoundingClientRect():h();if(!i)return;let a=ki(i,{width:n.width,height:n.height},{width:window.innerWidth,height:window.innerHeight},{align:o,side:s,gap:c,margin:l});p(e=>e?.x===a.x&&e?.y===a.y?e:a)};return(0,f.useLayoutEffect)(()=>{t?_():p(null)},[t,n,r,o,s,c,l]),mt(()=>{m.current()},t),(0,f.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||g()?.contains(e)||a?.(e)),n=t=>{e(t.target)||m.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 ji({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=Ut(),{panelRef:d,style:p,measure:m}=Ai({anchor:e,anchorEl:t,onClose:l}),[,h]=(0,f.useState)(null),g=(0,f.useRef)(null),[_,v]=(0,f.useState)(null),y=(0,f.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,f.useLayoutEffect)(()=>{m()},[y,m]);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,D.createPortal)((0,X.jsxs)(`div`,{ref:d,className:`pm-panel`,role:`menu`,"aria-label":u(`pluginMenuTitle`),style:p,children:[(0,X.jsxs)(`div`,{className:`pm-head`,"aria-hidden":`true`,children:[(0,X.jsx)(Ye,{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&&g.current&&(n.preventDefault(),v(e.id))},onDrop:t=>{t.preventDefault(),x(t.dataTransfer.getData(`text/plain`)||g.current,e.id),g.current=null,h(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=>{h(e.id),g.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:()=>{g.current=null,h(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)(G,{"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)(sr,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(Ye,{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)(Oi,{"aria-hidden":!0}):(0,X.jsx)(Di,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(re,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function Mi({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=Ut(),[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)(``),[l,u]=(0,f.useState)(``);async function d(){try{let e=await fetch(Et(St(`/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,f.useEffect)(()=>{d()},[]);async function p(e){u(e),c(``);try{let t=await fetch(Et(St(`/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 m(e){u(e),c(``);try{let t=await fetch(Et(St(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);Ft(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)(Te,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(M,{})})]}),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 m(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 p(e.code),children:[(0,X.jsx)(Pe,{}),(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)(oe,{}),(0,X.jsx)(`span`,{children:t(`bgTaskRefresh`)})]})})]})})}var Ni=`xing-shuyin/pi-web-ui`,Pi={state:`idle`,version:null,percent:0,message:null};function Fi(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Ii(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:Fi(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 Li(e){if(!Kt(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 Ri(e){return e instanceof Error?e.message:String(e)}function zi(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${Ni}/releases/tag/v${t}`:`https://github.com/${Ni}/releases/latest`}function Bi(){let[e]=(0,f.useState)(()=>Li()),[t,n]=(0,f.useState)(Pi);(0,f.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>Ii(t,e)))},[e]);let r=(0,f.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:Ri(e)}))))},[e]),i=(0,f.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:Ri(e)}))))},[e]),a=(0,f.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:Ri(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}function Vi({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=Ai({open:t,anchor:e,onClose:n});return(0,f.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,D.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Hi(){let[e,t]=(0,f.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,f.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 Ui({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:p,onOpenGlobalSearch:m,sound:h,onSoundChange:g,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x}){let{locale:S,setLocale:C,t:w,packs:T}=Ut(),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(!1),[A,j]=(0,f.useState)(null),M=hi(`cwd`),P=hi(`workspaceRoots`),F=(0,f.useRef)(null),I=t=>!e.tabs||t===`chat`||e.tabs.includes(t),L=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!mr(e)),R=new Set([...i??[],...a??[]].filter(e=>mr(e)&&!e.hidden).map(e=>e.source.slice(7))),te=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),z=r.map((e,t)=>({id:e.id,index:t})).sort((e,t)=>(te.get(`${e.id}:__view`)??1e6+e.index)-(te.get(`${t.id}:__view`)??1e6+t.index)).map(e=>e.id),B=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:files`].map(e=>({id:e,entry:null})):i.map(e=>({id:e.id,entry:e})),V=(I(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!B.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:[]})),ie=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`}),un(),!0;case`host:open-project`:return k(!0),!0;case`host:search`:return m(),!0;case`host:tasks`:return p(),!0;case`host:settings`:return u(),!0;case`host:plugins`:return j(F.current?{rect:F.current.getBoundingClientRect(),el:F.current}:null),!0;default:return!1}},U=(e,t,n)=>{e.preventDefault(),Wr({x:e.clientX,y:e.clientY,slot:`contextmenu.topbar`,target:{id:t,label:n},entries:o??[]})},{appVersion:ae}=mi(),oe=_i(),ce=vi(),[le,ue]=(0,f.useState)(!1);(0,f.useEffect)(()=>{le&&e.status===`open`&&ue(!1)},[le,e.status]);let[de,fe]=(0,f.useState)(!1),[pe,W]=(0,f.useState)(!1),[he,ge]=(0,f.useState)(!1),[_e,ve]=(0,f.useState)(!1),ye=Kt(),K=Bi(),[xe,Se]=(0,f.useState)(!1),Ce=()=>{if(!e.ready)return;let n=w(`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:ot(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r}),ve(!1),c(`terminal`)},q=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:it(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:ot(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:r,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:i}),ve(!1),c(`terminal`)},we=e.updatesAll??[],Oe=we.filter(e=>!e.upToDate&&!e.error).length,ke=we.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Ae=e=>e.kind===`git-extension`&&e.source?e.source:e.name,je=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,Me=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},Ne=(e,t)=>{if(!t)return Me(e);let n=Me(e),r=Me(t);return n===r?n:`${n} → ${r}`},Fe=()=>(0,X.jsxs)(`div`,{className:`dd-updates-all`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`updatesAllTitle`)}),e.updatesAll===null?(0,X.jsx)(`div`,{className:`dd-note`,children:w(`checkingUpdate`)}):we.length===0?(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updatesAllUpToDate`)}):(0,X.jsx)(`ul`,{className:`dd-all-list`,children:we.map(e=>(0,X.jsxs)(`li`,{className:`dd-all-item${e.error?` err`:e.upToDate?``:` warn`}`,children:[e.kind!==`webui`&&!e.upToDate&&!e.error&&(0,X.jsx)(`button`,{type:`button`,className:`dd-update-btn`,onClick:()=>q([e],w(`updatePkgTabTitle`,{name:e.name})),children:w(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:je(e),children:Ae(e)}),(0,X.jsxs)(`span`,{className:`dd-all-meta`,children:[(0,X.jsx)(`span`,{className:`dd-all-kind`,children:e.kind===`webui`?w(`kindWebUi`):e.kind===`pi-core`?w(`kindPiCore`):e.kind===`git-extension`?w(`kindGitExtension`):w(`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?w(`updateCheckFailed`):e.kind===`git-extension`?e.upToDate?Me(e.current):Ne(e.current,e.latest):e.upToDate?`v${e.current}`:(0,X.jsxs)(X.Fragment,{children:[`v`,e.current,` → v`,e.latest]})})]})]},`${e.kind}:${e.name}`))}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[ke.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>q(ke,w(`updateAllTabTitle`)),children:w(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:ke.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:w(`updatesAllRefresh`)})]})]}),Ie=()=>{let t=zi(e.update?.latest??K.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:w(`updateDesktopManual`)});if(!K.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopNoBridge`)}),n]});switch(K.state){case`checking`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateDesktopChecking`)}),n]});case`available`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopAvailable`,{version:K.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>K.download(),children:w(`updateDesktopDownload`)}),n]});case`downloading`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateDesktopDownloading`,{n:K.percent})}),n]});case`downloaded`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note ok`,children:w(`updateDesktopDownloaded`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>K.quitAndInstall(),children:w(`updateDesktopInstall`)}),n]});case`up-to-date`:return(0,X.jsx)(`div`,{className:`dd-note ok`,children:w(`upToDate`)});case`error`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopError`,{error:K.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>K.check(),children:w(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>K.check(),children:w(`updateDesktopCheck`)}),n]})}},Le=()=>(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:w(`currentVersion`)}),(0,X.jsxs)(`b`,{children:[`v`,e.update?.current??`…`]})]}),(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:w(`latestVersion`)}),(0,X.jsx)(`b`,{children:e.update===null?w(`checkingUpdate`):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:w(`checkingUpdate`)})]}),e.update&&e.update.upToDate&&(0,X.jsx)(`div`,{className:`dd-note ok`,children:w(`upToDate`)}),e.update&&!e.update.upToDate&&e.update.latest&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`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:w(`updateJustPublished`,{version:e.update.latest??``})}),e.update&&!e.update.upToDate&&e.update.latest&&!ye&&(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&ye&&(0,X.jsx)(`div`,{className:`dd-note`,children:w(`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?w(`checkingUpdate`):w(`checkUpdate`)}),e.update&&!e.update.upToDate&&e.update.latest&&!ye&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:Ce,children:w(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&ye&&Ie(),ce&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:le,title:w(`restartServiceTip`,{name:ce.name}),onClick:()=>{le||(ue(!0),$({type:`restart_service`}))},children:w(le?`restartingService`:`restartService`)})]})]}),Re=Hi(),ze={"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":w(`openProject`),onClick:()=>k(!0),children:[(0,X.jsx)(Y,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`openProject`)})]}),"host:history":n===`chat`&&I(`history`)?(0,X.jsx)(`button`,{type:`button`,className:`panel-toggle`,"data-tip":w(`openHistory`),"aria-label":w(`openHistory`),onClick:()=>l(`left`),children:(0,X.jsx)(G,{})}):null,"host:files":n===`chat`&&I(`files`)?(0,X.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label`,"data-tip":w(`openFiles`),"aria-label":w(`openFiles`),onClick:()=>l(`right`),children:[(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{children:w(`openFiles`)})]}):null,"host:new-chat":I(`new-chat`)?(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat`,"data-tip":w(`newChatTip`),onClick:()=>{c(`chat`),$({type:`new_chat`}),un()},children:[(0,X.jsx)(se,{}),(0,X.jsx)(`span`,{children:w(`newChat`)})]}):null,"host:chat":(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`chat`,className:`tb-tab${n===`chat`?` active`:``}`,"data-tip":w(`chat`),onClick:()=>c(`chat`),children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:w(`chat`)})]}),"host:terminal":I(`terminal`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`terminal`,className:`tb-tab${n===`terminal`?` active`:``}`,"data-tip":w(`terminal`),onClick:()=>c(`terminal`),children:[(0,X.jsx)(ee,{}),(0,X.jsx)(`span`,{children:w(`terminal`)})]}):null,"host:git":I(`git`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`git`,className:`tb-tab${n===`git`?` active`:``}`,"data-tip":w(`scmTab`),onClick:()=>c(`git`),children:[(0,X.jsx)(Ee,{}),(0,X.jsx)(`span`,{children:w(`scmTab`)})]}):null,"host:plugins":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":w(`pluginMenuTitle`),"aria-haspopup":`menu`,"aria-expanded":A!==null,onClick:e=>{let t=e.currentTarget;j(e=>e?.el===t?null:{rect:t.getBoundingClientRect(),el:t})},children:[(0,X.jsx)(Ye,{"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`pluginMenuTitle`)})]}),"host:search":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":w(`searchGlobalTip`),onClick:m,children:[(0,X.jsx)(H,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(fn,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":w(`bgTasksTip`),onClick:p,children:[(0,X.jsx)(be,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`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":w(`settingsTitle`),onClick:u,children:[(0,X.jsx)(re,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`settings`)})]}),"host:sound":(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`sound`)})]}),tip:w(`sound`),open:de,onOpenChange:fe,children:[(0,X.jsx)(Gt,{settings:h,onChange:g,onPreview:_}),(0,X.jsx)(Qn,{})]}),"host:language":(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Te,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:It(S)})]}),tip:w(`language`),open:pe,onOpenChange:W,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`language`)}),T.map(e=>(0,X.jsx)(_t,{active:S===e.code,onClick:()=>{C(e.code),W(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(_t,{onClick:()=>{W(!1),Se(!0)},children:[(0,X.jsx)(Pe,{}),` `,w(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`theme`)})]}),tip:w(`theme`),open:he,onOpenChange:e=>{ge(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=S===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?w(`themeLight`):e.scheme===`dark`?w(`themeDark`):``;return n?S===`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:w(`themeGroupClassics`)}),e.map(e=>(0,X.jsx)(_t,{active:y===e.id,onClick:()=>{b(e.id),ge(!1)},children:n(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:e.length>0?w(`themeGroupBuiltin`):w(`theme`)}),(0,X.jsx)(_t,{active:y===null,onClick:()=>{b(null),ge(!1)},children:w(`themeDefault`)}),t.map(e=>(0,X.jsx)(_t,{active:y===e.id,onClick:()=>{b(e.id),ge(!1)},children:n(e)},e.id))]})})()}),"host:update":oe?(0,X.jsxs)(`span`,{className:`chip`,"data-tip":w(`updatesManaged`),children:[(0,X.jsx)(Pe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,ae??e.update?.current??`…`]})]}):(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pe,{}),(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:w(`updateAvailable`,{version:e.update.latest??``})}),Oe>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:w(`updatesAllBadge`,{n:Oe})})]}),tip:w(`update`),open:_e,onOpenChange:e=>{ve(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},fit:!0,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`update`)}),Le(),Fe()]}),"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":w(`githubRepo`),children:(0,X.jsx)(J,{})})},Be=new Set([`host:search`,`host:tasks`,`host:settings`,`host:plugins`]),Ve=new Set([`host:sound`,`host:language`,`host:theme`,`host:update`,`host:browser`]),He=e=>Be.has(e)&&!I(e.slice(5)),Ue=e=>{if(e.kind===`view`){if(!I(`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=>U(t,e.id,e.label),children:[(0,X.jsx)(sr,{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=>U(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=>U(t,e.id,e.label),children:[(0,X.jsx)(sr,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},We=[];for(let e of B){if(e.entry?.hidden||He(e.id))continue;let t=e.id.startsWith(`host:`)?ze[e.id]??null:e.entry?Ue(e.entry):null;t&&We.push({id:e.id,entry:e.entry,node:t})}for(let e of V){let t=Ue(e);t&&We.push({id:e.id,entry:e,node:t})}let Ge=e=>e.entry?.align??`start`,[Ke,qe]=(0,f.useState)(()=>new Set),Je=(0,f.useRef)(null),Xe=(0,f.useRef)(new Map),Ze=We.filter(e=>!Ke.has(e.id)),Qe=Re?Ze.filter(e=>Rr.has(e.id)):[],$e=Re?Ze.filter(e=>!Rr.has(e.id)):Ze,et=Re?We.filter(e=>!Rr.has(e.id)):We,tt=[...et.filter(e=>Ge(e)===`start`),...et.filter(e=>Ge(e)===`center`),...et.filter(e=>Ge(e)===`end`)],nt=tt.filter(e=>!Ke.has(e.id)),rt=()=>{let e=Je.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`));t.length===nt.length&&nt.forEach((e,n)=>Xe.current.set(e.id,t[n].offsetWidth));let n=Number.parseFloat(getComputedStyle(e).columnGap)||0,r=Br(tt.map(e=>({id:e.id,width:e.entry?Xe.current.get(e.id)??0:0})),e.clientWidth,n,0,fr);qe(e=>e.size===r.size&&[...r].every(t=>e.has(t))?e:r)},at=`${Ze.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${Re?`m`:`d`}`;(0,f.useLayoutEffect)(rt,[at]),(0,f.useEffect)(()=>{let e=Je.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>rt());return t.observe(e),()=>t.disconnect()},[at]);let st=$e.filter(e=>Ge(e)===`start`),ct=$e.filter(e=>Ge(e)===`center`),lt=$e.filter(e=>Ge(e)===`end`),ut=We.filter(e=>Ke.has(e.id)&&e.entry).map(e=>e.entry),dt=new Map;[...i??[],...a??[]].forEach((e,t)=>{dt.has(e.id)||dt.set(e.id,t)});let ft=zr([...L,...ut],e=>dt.get(e)??999999),pt=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${pt?` no-labels`:``}`,"data-pi-anchor":`topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-flow`,ref:Je,role:`toolbar`,"aria-label":w(`viewSwitch`),children:[st.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id)),(ct.length>0||lt.length>0)&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),ct.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id)),lt.length>0&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),lt.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id))]}),ft.length>0&&(0,X.jsxs)(`div`,{className:`plugin-topbar-more`,children:[(0,X.jsx)(`button`,{ref:F,type:`button`,className:`plugin-topbar-item`,"aria-haspopup":`menu`,"aria-expanded":E,"data-tip":w(`pluginTopbarMore`),onClick:()=>D(e=>!e),children:`⋯`}),(0,X.jsx)(Vi,{anchorRef:F,open:E,onClose:()=>D(!1),children:ft.map(e=>{let t=e.source===`host`&&Ve.has(e.id)?ze[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(f.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:w(`githubRepo`),onClick:()=>D(!1),children:[(0,X.jsx)(J,{}),(0,X.jsx)(`span`,{children:`GitHub`})]},e.id);if(e.source===`host`){let t=ze[e.id];if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>D(!1),children:t},e.id)}else{let t=Ue(e);if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>D(!1),children:t},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsxs)(`label`,{className:`plugin-topbar-overflow-select`,title:e.hint??e.label,children:[(0,X.jsxs)(`span`,{children:[e.icon&&!/[a-z]/i.test(e.icon)?`${e.icon} `:``,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=>{D(!1),ie(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`,title:e.hint??e.label,onClick:()=>{D(!1),ie(e)||s?.(e)},children:[e.icon&&!/[a-z]/i.test(e.icon)?`${e.icon} `:``,e.label]},e.id)})})]}),Qe.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id)),xe&&(0,X.jsx)(Mi,{onClose:()=>Se(!1)}),A&&(0,X.jsx)(ji,{anchorRect:A.rect,anchorEl:A.el,plugins:r,pinnedIds:R,orderedPluginIds:z,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:hr(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:gr(e.settings?.uiLayout,t)}),onOpenView:e=>{j(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>j(null)}),O&&(0,X.jsx)(Ei,{open:!0,currentCwd:M,pathCompletions:e.pathCompletions??[],workspaceRoots:P,onClose:()=>k(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Wi(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 Gi(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 Ki(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 qi(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 Ji(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 Yi=`pi-web-ui:lp-collapse-projects`,Xi=`pi-web-ui:lp-collapse-convs`,Zi=`pi-web-ui:lp-collapse-sessions`;function Qi(e,t=!1){let[n,r]=(0,f.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,f.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var $i=`pi-web-ui:lp-sizes`,ea={projects:1,convs:1,sessions:1},ta=32,na=72;function ra(){try{return Wi(localStorage.getItem($i),ea)}catch{return{...ea}}}var ia=(0,f.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:p,onUiAction:m,presetNames:h}){let g=Z(),_=e,v=hi(`ready`),y=hi(`status`),b=hi(`cwd`),x=hi(`workspaceRoots`),S=b,[C,w]=(0,f.useState)(!1),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(null),[k,A]=(0,f.useState)(``),[j,N]=Qi(Yi,!1),[P,F]=Qi(Xi,!1),[I,R]=Qi(Zi,!1),ee=(0,f.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]),te=(0,f.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},[]),ne=(0,f.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},[]),z=(0,f.useRef)(null),B=(0,f.useRef)(null),V=(0,f.useRef)(()=>{}),re=ti(d??[]).length>0,ie=(0,f.useCallback)((e,n,r)=>{z.current={x:e,y:n,target:r};let i=r.kind===`running`?r.id:void 0,a=r.kind===`elsewhere`,o=i??(a&&r.id||void 0),s=ee(t,i),c=s===0?g(`noFinishedSubagents`):g(i?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:s}),l=!!i&&B.current===i;Wr({x:e,y:n,slot:`contextmenu.session`,target:r,entries:(d??[]).map(e=>{if(e.source!==`host`)return e;if(e.id===`host:conv-rename`)return r.kind===`running`||r.kind===`history`?e:{...e,hidden:!0};if(e.id===`host:conv-takeover`)return a&&o&&r.owner?e:{...e,hidden:!0};if(a&&(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:c,...s===0?{when:[...e.when??[],`disabled`]}:{}};if(e.id===`host:conv-force-dismiss`)return i?{...e,...l?{label:g(`forceDismissConfirm`)}:{}}:{...e,hidden:!0};if(e.id===`host:conv-persist`){if(!i)return{...e,hidden:!0};let n=t.find(e=>e.id===i);return n&&(n.isSubagent||!n.sessionFile)?e:{...e,hidden:!0}}return e.id===`host:conv-copy-id`?o?e:{...e,hidden:!0}:e.id===`host:conv-copy-path`?r.kind===`history`?e:i?t.some(e=>e.id===i&&e.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}:{...e,hidden:!0}:e.id===`host:conv-quote`?o||r.kind===`history`?e:{...e,hidden:!0}:e}),onHostAction:(e,t)=>V.current(e,t)})},[d,t,ee,g]);V.current=(0,f.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=z.current;if(!i||!e)return;if(B.current!==i)return B.current=i,ie(e.x,e.y,e.target),!0;B.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-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-quote`){n.kind===`history`&&n.id?dn({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&dn({attachments:[{path:``,key:`conv|${a}|`,name:n.label||a,mode:`conversation`,conversationId:a}]});return}if(e.id===`host:conv-rename`){if(E(null),i){let e=t.find(e=>e.id===i);A(e?.title??n.label??``),O(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);A(e?.name??n.label??``),O(n.id)}return}},[o,ie,t,r]);let H=()=>{let e=(p??[]).filter(e=>!ur.has(e.id));return e.length===0?null:(0,X.jsx)(`span`,{className:`lp-slot-sessions`,children:e.map((e,t)=>{let n=`${e.id}#${t}`,r=e.label||e.id,i=e.hint||r;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`lp-slot-divider`,"aria-hidden":`true`},n):e.kind===`badge`?(0,X.jsx)(`span`,{className:`lp-slot-badge`,title:i,children:e.badge??r},n):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`lp-slot-select`,title:i,"aria-label":r,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onClick:e=>e.stopPropagation(),onChange:t=>{t.stopPropagation(),m?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},n):(0,X.jsx)(`button`,{type:`button`,className:`lp-slot-btn`,title:i,"aria-label":r,onClick:t=>{t.stopPropagation(),m?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:r})},n)})})},U=(0,f.useCallback)((e,t)=>{Ji(e.target)||re&&(e.preventDefault(),e.stopPropagation(),B.current=null,ie(e.clientX,e.clientY,t))},[re,ie]),ae=(0,f.useRef)(null),[oe,ce]=(0,f.useState)(()=>ra());(0,f.useEffect)(()=>{try{localStorage.setItem($i,JSON.stringify(oe))}catch{}},[oe]);let le=[...t,...n.map((e,t)=>({id:`elsewhere:${e.cwd}:${e.title}:${t}`,title:e.title,cwd:e.cwd,messageCount:0,isStreaming:e.isStreaming,isSubagent:!1,elsewhere:!0,...e.owner&&e.convId?{owner:e.owner,convId:e.convId}:{},...e.hasQuestion?{hasQuestion:!0}:{}}))],ue=(0,f.useCallback)((e,t)=>n=>{n.preventDefault();let r=n.currentTarget,a=n.clientY,o={...oe},s=ae.current;if(!s)return;let c=[{key:`projects`,visible:i.length>0,collapsed:j},{key:`convs`,visible:le.length>0,collapsed:P},{key:`sessions`,visible:!0,collapsed:I}].filter(e=>e.visible),l=c.filter(e=>e.collapsed).length,u=c.filter(e=>!e.collapsed).map(e=>e.key).reduce((e,t)=>e+(o[t]??1),0)||1,d=Math.max(120,s.clientHeight-l*ta);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let f=n=>{let{above:r,below:i}=Gi({start:{above:o[e]??1,below:o[t]??1},deltaPx:n.clientY-a,availablePx:d,totalWeight:u,minAbovePx:na,minBelowPx:na});ce(n=>({...n,[e]:r,[t]:i}))},p=()=>{window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),r.classList.remove(`dragging`),document.body.classList.remove(`lp-resizing`)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p)},[oe,i.length,le.length,j,P,I]);(0,f.useEffect)(()=>{s&&v&&y===`open`&&b&&(o({type:`list_sessions`}),o({type:`list_projects`}))},[s,v,y,b,o]);let de=e=>{let t=e.name||e.firstMessage.trim();return t.length>0?t:g(`emptyChat`)},fe=e=>e.split(/[\\/]/).pop()||e,pe=(e,t,n,r,i)=>{let a=T===e;return(0,X.jsx)(`button`,{type:`button`,className:`lp-del ${a?`confirm`:``}`,title:a?n:t,onClick:t=>{t.stopPropagation(),a?(E(null),r()):E(e)},children:a?(0,X.jsx)(Ke,{}):i??(0,X.jsx)(L,{})})},W=(e,t,n,r,i)=>(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:g(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)(Ge,{}):(0,X.jsx)(Ue,{})})]}),i?(0,X.jsx)(`div`,{className:`lp-section-actions`,children:i}):null]}),G=[{key:`projects`,visible:i.length>0,collapsed:j},{key:`convs`,visible:le.length>0,collapsed:P},{key:`sessions`,visible:!0,collapsed:I}].filter(e=>e.visible).filter(e=>!e.collapsed),he=G.reduce((e,t)=>e+(oe[t.key]??1),0)||1,ge=e=>G.length<=1?1:(oe[e]??1)/he*G.length;return(0,X.jsxs)(`aside`,{ref:ae,className:`panel panel-left lp-panel`,children:[c&&l&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:g(`collapsePanel`),onClick:l,children:(0,X.jsx)(He,{})}),(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${j||i.length===0?`collapsed`:``}`,style:i.length>0&&!j?{flex:`${ge(`projects`)} 1 0px`}:void 0,children:[W(g(`recentProjects`),j,N,i.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action`,title:g(`manageProjects`),"aria-label":g(`manageProjects`),onClick:()=>w(!0),children:(0,X.jsx)(Y,{})})),i.length>0&&!j&&(0,X.jsx)(`div`,{className:`lp-section-body projects-scroll`,children:i.map(e=>{let t=S===e.path;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>E(t=>t===`proj:${e.path}`?null:t),children:[(0,X.jsxs)(`button`,{type:`button`,className:`project-item ${t?`active`:``}`,title:e.path,onClick:()=>{t||o({type:`set_cwd`,path:e.path})},children:[(0,X.jsx)(De,{className:`project-icon`}),(0,X.jsxs)(`span`,{className:`project-info`,children:[(0,X.jsx)(`span`,{className:`project-name`,children:fe(e.path)}),(0,X.jsx)(`span`,{className:`project-path`,children:e.path})]}),(0,X.jsx)(`span`,{className:`project-time`,children:qi(e.lastUsed)})]}),pe(`proj:${e.path}`,g(`deleteProject`),g(`deleteProjectConfirm`),()=>o({type:`remove_project`,path:e.path}))]},e.path)})})]}),i.length>0&&!j&&(le.length>0?!P:!I)&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:ue(`projects`,le.length>0?`convs`:`sessions`),onDoubleClick:()=>ce({...ea}),title:g(`dragToResize`)}),le.length>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${P?`collapsed`:``}`,style:P?void 0:{flex:`${ge(`convs`)} 1 0px`},onContextMenu:e=>U(e,{id:``,kind:`section`,label:g(`runningConversations`)}),children:[W(g(`runningConversations`),P,F,le.length),!P&&(0,X.jsx)(`div`,{className:`lp-section-body convs-scroll`,children:Ki(le,b,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,children:fe(e.cwd)}),(()=>{let n=new Map(e.convs.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e.convs)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 s=[],c=new Set,l=(e,t)=>{if(!c.has(e.id)){c.add(e.id),s.push({c:e,depth:t});for(let n of r.get(e.id)??[])l(n,t+1)}};for(let e of i)l(e,0);for(let t of e.convs)l(t,0);return s.map(({c:n,depth:r})=>{if(n.elsewhere)return(0,X.jsx)(`div`,{className:`lp-row`,onContextMenu:e=>U(e,{id:n.convId??n.id,kind:`elsewhere`,label:n.title,...n.owner?{owner:n.owner}:{}}),children:(0,X.jsxs)(`div`,{className:`session-item elsewhere-item`,title:`${g(`elsewhereTip`)}\n${n.cwd}`,children:[(0,X.jsx)(me,{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:g(`elsewhereBadge`)}),n.hasQuestion&&n.owner&&n.convId&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:g(`takeoverHasQuestion`),onClick:e=>{e.stopPropagation(),o({type:`peek_elsewhere_question`,owner:n.owner,id:n.convId})},children:`?`}),n.title]}),(0,X.jsx)(`span`,{className:`session-sub`,children:fe(n.cwd)})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:g(`streaming`)})]})},n.id);let i=a===n.id;return(0,X.jsxs)(`div`,{className:`lp-row${r>0?` lp-sub`:``}`,style:r>0?{marginLeft:r*18}:void 0,onMouseLeave:()=>E(e=>e===`conv:${n.id}`?null:e),onContextMenu:e=>U(e,{id:n.id,kind:`running`,label:n.title}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${i?`active`:``}`,title:`${n.title}${e.isCurrent?``:` — ${e.cwd}`}`,onClick:()=>{i||o({type:`switch_conversation`,id:n.id})},children:[(0,X.jsx)(me,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[D===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:k,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>A(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=k.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),O(null)}else e.key===`Escape`&&O(null)},onBlur:()=>O(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:g(`subagentBadge`)}),n.agentPreset&&(0,X.jsx)(`span`,{className:`preset-badge`,title:n.agentPreset,children:h?.[n.agentPreset]??n.agentPreset}),n.title,n.error&&(0,X.jsx)(`span`,{className:`conv-error-badge`,title:g(`convErrorBadge`,{error:n.error})}),n.hasQuestion&&(0,X.jsx)(`span`,{className:`question-badge`,title:g(`waitingQuestionBadge`),children:`?`})]}),D===`conv:${n.id}`?null:(0,X.jsx)(`span`,{className:`session-sub`,children:i?g(`current`):g(`messageCount`,{n:n.messageCount})})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:g(`streaming`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:e=>{e.stopPropagation(),E(null),A(n.title),O(`conv:${n.id}`)},children:(0,X.jsx)(Ne,{})}),(()=>{let e=`conv:${n.id}`,r=T===e,i=ee(t,n.id),a=ne(t,n.id),s=te(t,n.id);return s===0&&!n.isStreaming?pe(e,g(`dismissConversation`),g(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(M,{})):s===0?pe(e,g(`dismissConversation`),g(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(M,{})):r?(0,X.jsxs)(`span`,{className:`lp-del-group`,children:[i>0&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt`,title:g(`dismissFinishedSubagentsScoped`,{n:i}),onClick:e=>{e.stopPropagation(),E(null),o({type:`dismiss_finished_subagents`,parentId:n.id})},children:g(`dismissFinishedOnly`,{n:i})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt danger`,title:g(`forceDismissTitle`,{n:s,m:a}),onClick:e=>{e.stopPropagation(),E(null),o({type:`dismiss_conversation`,id:n.id,force:!0})},children:g(`dismissForceAll`,{n:s})})]}):(0,X.jsx)(`button`,{type:`button`,className:`lp-del`,title:g(`dismissConversation`),onClick:t=>{t.stopPropagation(),E(e)},children:(0,X.jsx)(M,{})})})(),H(),n.isStreaming&&(0,X.jsx)(`span`,{className:`lp-row-stalled`,title:g(`streaming`),style:{position:`absolute`,right:28,top:`50%`,transform:`translateY(-50%)`}})]},n.id)})})()]},e.cwd))})]}),le.length>0&&!P&&!I&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:ue(`convs`,`sessions`),onDoubleClick:()=>ce({...ea}),title:g(`dragToResize`)}),(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${I?`collapsed`:``}`,style:I?void 0:{flex:`${ge(`sessions`)} 1 0px`},children:[W(g(`historySessions`),I,R,r.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-new-chat-action`,title:g(`newChatTip`),"aria-label":g(`newChat`),onClick:()=>{o({type:`new_chat`}),un()},children:(0,X.jsx)(se,{})})),!I&&(0,X.jsxs)(`div`,{className:`lp-section-body sessions-scroll`,children:[r.length===0&&(0,X.jsx)(`div`,{className:`panel-empty`,children:g(`noHistory`)}),r.map(e=>{let t=_===e.path;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>E(t=>t===`sess:${e.path}`?null:t),onContextMenu:t=>U(t,{id:e.path,kind:`history`,label:de(e)}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${t?`active`:``}`,title:e.path,onClick:()=>{D||t||o({type:`switch_session`,path:e.path})},children:[(0,X.jsx)(me,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[D===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:k,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>A(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=k.trim();t&&o({type:`rename_session`,path:e.path,name:t}),O(null)}else t.key===`Escape`&&O(null)},onBlur:()=>O(null)}):(0,X.jsx)(`span`,{className:`session-title`,children:de(e)}),D===e.path?null:(0,X.jsxs)(`span`,{className:`session-sub`,children:[t?g(`current`):g(`messageCount`,{n:e.messageCount}),e.source===`tui`&&(0,X.jsx)(`span`,{className:`session-src`,title:g(`tuiTip`),children:`TUI`})]})]}),(0,X.jsx)(`span`,{className:`session-time`,children:qi(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:t=>{t.stopPropagation(),E(null),A(e.name??``),O(e.path)},children:(0,X.jsx)(Ne,{})}),pe(`sess:${e.path}`,g(`deleteSession`),g(`deleteSessionConfirm`),()=>o({type:`delete_session`,path:e.path})),H()]},e.path)})]})]}),(0,X.jsx)(Ei,{open:C,currentCwd:S,pathCompletions:u??[],workspaceRoots:x,onClose:()=>w(!1),onSelectDirectory:e=>o({type:`set_cwd`,path:e}),onCreateProject:e=>o({type:`make_dir`,path:e,setAsCwd:!0})})]})});function aa(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 oa(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}}function sa(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 ca=null,la=new Set;function ua(){for(let e of la)e()}function da(e){let t=(e??``).trim();t&&(ca={name:t,status:`loading`},ua(),$({type:`get_tool_info`,name:t}))}function fa(){ca!==null&&(ca=null,ua())}function pa(e){ca!==null&&ca.name===e.name&&(ca=sa(e),ua())}function ma(e){return la.add(e),()=>{la.delete(e)}}function ha(){return ca}function ga(){return(0,f.useSyncExternalStore)(ma,ha,ha)}var _a=`__piWebUiHost`,va=e=>new Promise(t=>setTimeout(t,e));async function ya(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 va(100)}}function ba(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 va(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();return r&&!a(r)?!1:(s(n,t??{prompt:n}).catch(()=>{}),!0)},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>Ja(e)},compose(e){return Q()?dn({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=Array.isArray(t?.folders)?t.folders.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],i=Array.isArray(t?.roots)?t.roots.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],s=String(t?.cwd??``).trim(),c=[...new Set([...n,...i])],l=s||c[0]||``;if(!l)return{ok:!1,error:`openSession 需要 cwd / folders / roots(绝对路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let u=c.filter(e=>e!==l).slice(0,7),d=new Set([...e.listProjects?.()??[],...e.grantedPaths?.()??[]]);for(let t of[l,...u])if(!d.has(t)){if(!(e.confirm&&await e.confirm({path:t}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${t}`};e.grantPath?.(t)}if(e.getCwd()!==l&&(e.send({type:`set_cwd`,path:l}),!await r(()=>e.getCwd()===l)))return{ok:!1,error:`切换工作目录失败或超时:${l}`};(u.length>0||e.getWorkspaceRoots().length>0)&&e.send({type:`set_workspace_roots`,roots:u});let f=e.getConversationId()??void 0;if(t?.newChat!==!1){let t=f;e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank()),f=e.getConversationId()??void 0}let p=String(t?.model??``).trim();if(p){if(!a(p))return{ok:!1,error:`未知模型:${p}(先调 models.list() 取可用列表)`};await o(p),f=e.getConversationId()??f}let m=String(t?.prompt??``).trim();return m&&e.send({type:`prompt`,text:m}),{ok:!0,...f?{sessionId:f}:{}}},sessions:{list:()=>e.listSessions(),async open(t){let n=String(t??``).trim();if(!n)return{ok:!1,error:`sessions.open 需要一个会话 id(先调 list)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let i=e.listSessions().find(e=>e.id===n);if(!i)return{ok:!1,error:`找不到会话:${n}`};if(i.cwd&&i.cwd!==e.getCwd()){if(!new Set([...e.listProjects?.()??[],...e.grantedPaths?.()??[]]).has(i.cwd)){if(!(e.confirm&&await e.confirm({path:i.cwd}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${i.cwd}`};e.grantPath?.(i.cwd)}if(e.send({type:`set_cwd`,path:i.cwd}),!await r(()=>e.getCwd()===i.cwd))return{ok:!1,error:`切换工作目录失败或超时:${i.cwd}`}}let a=e.getConversationId();return i.kind===`running`?e.send({type:`switch_conversation`,id:i.id}):e.send({type:`switch_session`,path:i.id}),await r(()=>e.getConversationId()!==a)?{ok:!0,sessionId:e.getConversationId()??void 0}:{ok:!1,error:`切换会话超时:${i.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=ot();return new Promise(t=>{let a=setTimeout(()=>{no.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));no.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 Ta(Ca,String(e??``).trim(),t)},onTopbarAction(e,t){return Ta(Ca,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(Kt())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 ya(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(Da,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>Fa(String(e??``),t)},searchProviders:{register:e=>La(e),list:()=>Ra()},composerProviders:{register:e=>Ba(e),list:()=>Va()},onTheme:e=>Xa(e),onLocale:e=>Za(e),onViewChange:e=>Qa(e)}}function xa(e){try{let t=window;e?t[_a]=e:delete t[_a]}catch{}}var Sa=new Map,Ca=null;async function wa(e,t){let n=Ca;Ca=e;try{return await t()}finally{Ca=n}}function Ta(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=Sa.get(r);i||(i=new Set,Sa.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&Sa.delete(r)}}async function Ea(e,t,n,r){let i=i=>{let a=Sa.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{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 Da=`pi-web-ui:toast`,Oa=new Map,ka=!1;function Aa(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 ja(){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 Ma(e){try{if(ja())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=Oa.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function Na(){if(!ka)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,Ma),ka=!0}catch{}}function Pa(){if(!(Oa.size>0||!ka))try{window.removeEventListener(`keydown`,Ma)}catch{}finally{ka=!1}}function Fa(e,t){if(typeof t!=`function`)return()=>{};let n=Aa(e);if(!n)return()=>{};let r=Oa.get(n.combo);r||(r=new Set,Oa.set(n.combo,r));let i=r;return i.add(t),Na(),()=>{i.delete(t),i.size===0&&Oa.delete(n.combo),Pa()}}var Ia=new Map;function La(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 Ia.set(t,n),()=>{Ia.get(t)===n&&Ia.delete(t)}}function Ra(){return[...Ia.values()].map(e=>({id:e.id,label:e.label}))}var za=new Map;function Ba(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 za.set(t,n),()=>{za.get(t)===n&&za.delete(t)}}function Va(){return[...za.values()].map(e=>({id:e.id,label:e.label}))}function Ha(e){return za.get(String(e??``))}function Ua(e){return Ia.get(String(e??``))}var Wa=new Set,Ga=new Set,Ka=new Set,qa=new Set;function Ja(e){return qa.add(e),()=>{qa.delete(e)}}function Ya(e){for(let t of[...qa])try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function Xa(e){return typeof e==`function`?(Wa.add(e),()=>{Wa.delete(e)}):()=>{}}function Za(e){return typeof e==`function`?(Ga.add(e),()=>{Ga.delete(e)}):()=>{}}function Qa(e){return typeof e==`function`?(Ka.add(e),()=>{Ka.delete(e)}):()=>{}}function $a(e){let t=String(e??``);for(let e of[...Wa])try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function eo(e){let t=String(e??``);for(let e of[...Ga])try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function to(e){let t=String(e??``);for(let e of[...Ka])try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var no=new Map;function ro(e){let t=no.get(e.requestId);if(t){if(no.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 io=`modulepreload`,ao=function(e){return`/`+e},oo={},so=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=ao(t,n),t=s(t),t in oo)return;oo[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`:io,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)})},co=`pi-web-ui:plugin-data`;function lo(e,t){window.dispatchEvent(new CustomEvent(co,{detail:{pluginId:e,payload:t}}))}function uo(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(co,t),()=>window.removeEventListener(co,t)}var fo=new Map,po=new Set,mo=new Set,ho=new Set,go=new Set,_o=-1;function vo(){return[...fo.values()]}function yo(){let e=vo();for(let t of mo)t(e)}function bo(){let e=[...ho];for(let t of go)t(e)}function xo(e){return go.add(e),e([...ho]),()=>go.delete(e)}async function So(e,t){ho.delete(e.id),wo.set(e.id,(wo.get(e.id)??0)+1),bo();let n=await Oo(e,t);return yo(),n}function Co(e){return mo.add(e),e(vo()),()=>mo.delete(e)}var wo=new Map;function To(e,t){let n=wo.get(e)??0;return St(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function Eo(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>wa(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var Do=Eo(e=>so(()=>import(e),[]));async function Oo(e,t){try{let n=(await Do(e.id,To(e.id,t))).default;return n&&typeof n.mount==`function`?(fo.set(e.id,{info:e,module:n}),!0):e.preload?(po.add(e.id),!0):(ho.add(e.id),bo(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return ho.add(e.id),bo(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function ko(e,t){if(fo.has(e.id)||po.has(e.id))return!0;if(ho.has(e.id)||!e.hasClient)return!1;let n=await Oo(e,t);return yo(),n}async function Ao(e,t){t!==_o&&(_o=t,fo.clear(),po.clear(),ho.clear(),wo.clear(),bo());let n=new Set(e.map(e=>e.id));for(let e of[...fo.keys()])n.has(e)||fo.delete(e);for(let e of[...po])n.has(e)||po.delete(e);for(let e of[...ho])n.has(e)||ho.delete(e);bo(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!fo.has(e.id)&&!po.has(e.id)&&!ho.has(e.id)).map(e=>Oo(e,t))),yo()}function jo(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>uo((n,r)=>{n===e&&t(r)})}}var Mo=[`debug`,`info`,`warn`,`error`];function No(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function Po(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function Fo(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`&&Mo.includes(String(e.level)))}var Io=new Map,Lo=new Set;function Ro(){for(let e of[...Lo])try{e()}catch{}}function zo(e){return Lo.add(e),()=>Lo.delete(e)}function Bo(e){return(Io.get(e)??[]).map(e=>({...e}))}function Vo(e,t){return Fo(t)?(Io.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),Ro(),!0):!1}function Ho(){return{flows:[],results:{}}}function Uo(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 Wo(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:Uo(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:Uo(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 Go=`pi-web-ui:lang`;function Ko(){try{return(localStorage.getItem(Go)??``).trim()}catch{return``}}var qo=`pi-web-ui:locale`,Jo=2e5,Yo=2e5,Xo=`LIVE_OMIT`,Zo={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 Qo(){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>Yo?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 $o(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 es(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 ts(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`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!==19};case`snapshot`:return{...e,ready:!0,state:t.state,activeConversationId:t.state.conversationId,liveOutputs:$o(e.liveOutputs,t.state),toolStatuses:es(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,activeConversationId:i.conversationId,liveOutputs:$o(e.liveOutputs,i),toolStatuses:es(e.toolStatuses,i)}}case`tool_delta`:{let n=(e.liveOutputs.get(t.toolCallId)?.text??``)+t.delta,r=n.length>Jo?`…[${Xo}:${n.length-Jo}]…\n`+n.slice(n.length-Jo):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:aa(n,t.msg)}}case`tool_status`:return{...e,toolStatuses:new Map(e.toolStatuses).set(t.status.toolCallId,t.status)};case`notice`:return{...e,notices:[...e.notices,t.notice].slice(-6)};case`dismiss_notice`:return{...e,notices:e.notices.filter(e=>e.id!==t.id)};case`sessions`:return{...e,sessions:t.sessions};case`conversations`:return{...e,conversations:t.conversations,elsewhere:t.elsewhere??[],activeConversationId:t.activeId};case`projects`:return{...e,projects:t.projects};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=Wo({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`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};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`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`settings`:return{...e,settings:t.settings};case`bg_servers`:return{...e,bgServers:t.servers};case`scheduler_tasks`:return{...e,schedulerTasks:t.tasks};case`plugins`:return{...e,plugins:t.plugins,pluginsEpoch:t.epoch};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 n=e.pluginJobs[t.job.jobId],r=t.line?[...n?.lines??[],t.line].slice(-40):n?.lines??[],i={...n,...t.job,lines:r,startedAt:n?.startedAt??Date.now()};return{...e,pluginJobs:{...e.pluginJobs,[t.job.jobId]:i}}}case`plugin_catalog_sync_result`:return{...e,catalogSync:{...t.result,receivedAt:Date.now()}};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};default:return e}}var ns=`pi-web-client-id`,rs=null;function is(){if(rs)return rs;let e=null;try{e=sessionStorage.getItem(ns),e||(e=ot(),sessionStorage.setItem(ns,e))}catch{e??=ot()}return rs=e,e}var as=`pi-web-last-cwd`;function os(){try{return localStorage.getItem(as)}catch{return null}}function ss(e){try{localStorage.setItem(as,e)}catch{}}function cs(){return Et(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${St(`/ws`)}`)}function ls(){let[e,t]=(0,f.useReducer)(ts,{status:`connecting`,ready:!1,state:null,hostMetrics:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:[],conversations:[],elsewhere:[],activeConversationId:``,projects:[],files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},defaultModel:null,providerOAuthFlows:[],providerOAuthResults:Ho().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,widgets:[],statuses:[],dialog:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:Zo,bgServers:[],schedulerTasks:[],settings:null,fetchModelsResult:null,enrichModelsResult:null,enrichModelsProgress:null,refreshProviderResult:null,refreshBuiltinResult:null,appendBuiltinResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginCatalog:[],pluginCatalogEpoch:0,pluginJobs:{},catalogSync:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,dshPresets:null,dshPermission:null,protocolMismatch:!1}),n=(0,f.useRef)(null),r=(0,f.useRef)(Qo()),i=(0,f.useRef)(0),a=(0,f.useRef)(null),o=(0,f.useRef)(!0),s=(0,f.useRef)(0),c=(0,f.useRef)(0),l=(0,f.useRef)(new Map),u=(0,f.useRef)(null),d=(0,f.useRef)(!1),p=(0,f.useRef)(null),m=(0,f.useRef)(new Set),h=(0,f.useRef)(`live`),g=()=>{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)&&g()}n.set(e,t)},v=(0,f.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]),y=(0,f.useCallback)(e=>{let r=n.current;if(r&&r.readyState===WebSocket.OPEN){if(e.type===`check_updates_all`&&e.force===!0&&t({type:`updates_check_started`}),r.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(m.current.add(e.id),m.current.size>64){let e=m.current.values().next().value;e!==void 0&&m.current.delete(e)}h.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,f.useCallback)((e,n)=>{let r=oa({current:O.current.chat.question,source:h.current,snapshot:e,answered:m.current,activeConversationId:n});r.changed&&(h.current=r.source,t({type:`question`,question:r.question}))},[]);bi(y);let x=(0,f.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(cs());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:is(),locale:Ko()})))},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!==`20260921T18154`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}di({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}),m.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;(!e||e.conversationId!==a.conversationId||e.rev!==a.baseRev)&&g(),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`notice`:{let e=++c.current;t({type:`notice`,notice:{id:e,level:a.level,text:a.text,textEn:a.textEn}});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`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`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`:pa(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});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`question_pending`:h.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`question_retracted`:{let e=O.current.chat.question;if(e&&e.id===a.id){if(m.current.add(a.id),m.current.size>64){let e=m.current.values().next().value;e!==void 0&&m.current.delete(e)}h.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`settings_state`:t({type:`settings`,settings:a.settings});break;case`bg_servers`:t({type:`bg_servers`,servers:a.servers});break;case`scheduler_tasks`:t({type:`scheduler_tasks`,tasks:a.tasks});break;case`plugins`:t({type:`plugins`,plugins:a.plugins,epoch:a.epoch});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_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_catalog_sync_result`:ro(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`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`:Vo(a.pluginId,a.payload)||lo(a.pluginId,a.payload)}},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,f.useEffect)(()=>{let e=e=>{let t=e.detail??Ko();t&&y({type:`set_locale`,locale:t})};return window.addEventListener(qo,e),()=>window.removeEventListener(qo,e)},[y]),(0,f.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);return()=>{o.current=!1,clearInterval(e),a.current&&=(clearTimeout(a.current),null),n.current?.close(),n.current=null}},[x]),(0,f.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=os();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}p.current!==t&&(p.current=t,ss(t))}},[e.state?.cwd,y]),(0,f.useEffect)(()=>{di({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,f.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,f.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,f.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,f.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,f.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,f.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,f.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}var us=209715200,ds=/windows/i.test(navigator.userAgent),fs=/[<>:"/\\|?*\u0000-\u001f]/g,ps=/[. ]+$/,ms=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function hs(e){let t=e.replace(fs,`_`).replace(ps,``);return t?ms.test(t)?`_${t}`:t:`_`}function gs(e,t=!0){return Et(St(`/api/file?${new URLSearchParams({clientId:is(),path:e,...t?{download:`1`}:{}})}`))}async function _s(e,t){let n=ds?hs(t):t;try{let t=await fetch(gs(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`)>us)return window.location.assign(gs(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?ys(r,n):bs(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function vs(e,t){let n=ds?hs(t):t;return window.showSaveFilePicker&&window.isSecureContext?ys(e,n):bs(e,n)}async function ys(e,t){let n,r=window.showSaveFilePicker;if(!r)return bs(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:bs(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 bs(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 xs(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 Ss(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function Cs({text:e}){let t=(0,f.useRef)(null),n=(0,f.useRef)(null),[r,i]=(0,f.useState)(!1),[a,o]=(0,f.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,f.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=xs(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,f.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=xs(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,D.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 ws=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function Ts(e,t={}){let n={archive:St(`/api/file-transfer/archive`),upload:St(`/api/file-transfer/upload`)},r=new URL(Et(`${n[e]}?${new URLSearchParams({clientId:is(),...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 Es(e,t,n){let r=await fetch(Ts(`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 vs(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function Ds(){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 Os(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=Ts(`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 ks({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,f.useState)(e.dir),[o,s]=(0,f.useState)(`skip`),[c,l]=(0,f.useState)([]),[u,d]=(0,f.useState)(0),p=(0,f.useRef)(null),[m,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(``),v=(0,f.useRef)(null);(0,f.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 Ds();e?l(e):p.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),h(!0),_(``);try{e.action===`upload`?await Os(e.dir,c,d):await Es(e.action,e.path,{destination:i,policy:o}),n(),t()}catch(e){_(e instanceof Error?e.message:String(e)),n()}finally{h(!1)}}return(0,D.createPortal)((0,X.jsx)(`dialog`,{ref:v,className:`file-transfer-dialog`,"aria-labelledby":`file-transfer-title`,onCancel:e=>{e.preventDefault(),m||t()},children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),x()},children:[(0,X.jsx)(`h3`,{id:`file-transfer-title`,children:y}),(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:m,onChange:e=>a(e.target.value)})]}),(0,X.jsxs)(`label`,{children:[r(`fileConflictPolicy`),(0,X.jsxs)(`select`,{value:o,disabled:m,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:m,onClick:()=>void b(),children:r(`fileChooseFolder`)}),(0,X.jsx)(`input`,{type:`file`,"aria-label":y,multiple:!0,hidden:!0,disabled:m,ref:e=>{p.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]})]}),g&&(0,X.jsx)(`p`,{role:`alert`,children:r(`fileTransferFailed`,{error:g})}),(0,X.jsxs)(`div`,{className:`file-transfer-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:m,onClick:t,children:r(`cancel`)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:m||e.action===`upload`&&c.length===0,children:m?r(`fileTransferBusy`):y})]})]})}),document.body)}function As(e){return e instanceof Error?e.message:String(e)}function js(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 Ms({plugin:e,epoch:t,send:n,className:r}){let i=(0,f.useRef)(null),{locale:a}=Ut(),o=Z(),[s,c]=(0,f.useState)(null),l=(0,f.useRef)(n);(0,f.useEffect)(()=>{l.current=n},[n]),(0,f.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 ko(e,t),r)return;let i=await wa(e.id,()=>so(()=>import(To(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,jo(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:As(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:js(s,e.name,a,o)})]})}function Ns(e){return`pi-web-ui:${e}:tab`}function Ps(e,t){try{let n=localStorage.getItem(Ns(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function Fs(e,t){try{localStorage.setItem(Ns(e),t)}catch{}}function Is(e){return e.length>0&&!/[a-z]/i.test(e)}function Ls(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function Rs({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,f.useId)(),[s,c]=(0,f.useState)(()=>Ps(e,t)??t[0]?.id??``),l=(0,f.useRef)([]),u=(0,f.useRef)(``),d=t.findIndex(e=>e.id===s),p=d>=0?t[d]:t[0],m=p?t.indexOf(p):-1;(0,f.useEffect)(()=>{if(!p)return;s!==p.id&&c(p.id);let t=`${e}:${p.id}`;u.current!==t&&(u.current=t,Fs(e,p.id))},[p,s,e]);let h=t=>{c(t.id),u.current=`${e}:${t.id}`,Fs(e,t.id)},g=(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(),h(a),l.current[i]?.focus())};if(!p)return null;let _=`${o}-panel-${m}`,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===m;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,id:`${o}-tab-${t}`,className:n?`slot-tab active`:`slot-tab`,title:e.hint??Ls(e),"aria-selected":n,"aria-controls":`${o}-panel-${t}`,tabIndex:n?0:-1,ref:e=>{l.current[t]=e},onClick:()=>h(e),onKeyDown:e=>g(e,t),children:[e.iconSvg?(0,X.jsx)(sr,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&Is(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:Ls(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-${m}`,children:p.pluginPage?(0,X.jsx)(Ms,{plugin:p.pluginPage.plugin,epoch:n,send:r}):p.element??null})]})}var zs=`@root`,Bs=`pi-web-ui:rp-sizes`,Vs={files:4,widgets:1},Hs=120,Us=56;function Ws(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var Gs=`files`,Ks=[],qs=()=>{};function Js(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function Ys(e){return e===zs||e===`/`||/^[A-Za-z]:$/.test(e)}function Xs(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var Zs=(0,f.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:p,send:m}){let h=Z(),g=d??Ks,_=hi(`cwd`),v=hi(`workspaceRoots`),y=hi(`homeDir`),b=hi(`desktopDir`),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(!1),D=(0,f.useRef)(null),O=(0,f.useRef)(null),[k,A]=(0,f.useState)(()=>{try{return Wi(localStorage.getItem(Bs),Vs)}catch{return{...Vs}}});(0,f.useEffect)(()=>{try{localStorage.setItem(Bs,JSON.stringify(k))}catch{}},[k]);let j=n.some(e=>e.lines.length>0),N=(0,f.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-Ws(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=Gi({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:Hs,minBelowPx:Us});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]),P=(0,f.useRef)(null),F=(0,f.useRef)(0),I=(0,f.useCallback)(e=>{P.current=e,e&&(e.scrollTop=F.current)},[]),[L,R]=(0,f.useState)(null),ee=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>{ee.current&&clearTimeout(ee.current)},[]);let te=(0,f.useCallback)(e=>{R(e),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>R(null),1200)},[]),ne=e=>{try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}},z=(0,f.useCallback)((e,t)=>{if(!e)return;let n=()=>te(t),r=()=>o(`error`,h(`slashCopyFailed`)),i=navigator;i.clipboard?.writeText?i.clipboard.writeText(e).then(n,()=>{ne(e)?n():r()}):ne(e)?n():r()},[te,o,h]),B=(0,f.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},[_]),V=(0,f.useCallback)(e=>!e||e===zs?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),re=104857600,ie=(0,f.useCallback)((e,t)=>{for(let n of t){if(n.size>re){o(`warning`,h(`fileTooLarge`,{name:n.name,size:re/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,h]),H=(0,f.useRef)(null),[U,ae]=(0,f.useState)(null),oe=(0,f.useRef)(null),ce=(0,f.useCallback)(()=>{let e=H.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),le=(0,f.useCallback)(()=>{oe.current&&(oe.current.value=``),oe.current?.click()},[]),[ue,de]=(0,f.useState)(null),[fe,pe]=(0,f.useState)(null),[W,me]=(0,f.useState)(``),[G,he]=(0,f.useState)(null),[_e,ve]=(0,f.useState)(``),ye=(0,f.useCallback)((e,t)=>{_s(e,t).then(e=>{e.ok||e.cancelled||o(`error`,h(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?h(`fileNotFoundShort`):e.error}))})},[o,h]),be=(0,f.useCallback)(()=>{let e=H.current?.target;e&&e.kind!==`list`&&!Ys(e.id)&&(he(null),me(e.label),pe(e.id))},[]),xe=(0,f.useCallback)(()=>{if(!fe)return;let e=W.trim();pe(null),e&&r({type:`file_rename`,path:fe,newName:e})},[fe,W,r]),Se=(0,f.useCallback)(e=>{let t=H.current?.dir??x;pe(null),ve(``),he({dir:t,kind:e})},[x]),Ce=(0,f.useCallback)(()=>{if(!G)return;let e=_e.trim();he(null),e&&r({type:`file_create`,dir:G.dir,name:e,kind:G.kind})},[G,_e,r]),q=(e,t,n,r)=>(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:e,placeholder:h(`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}),we=(0,f.useCallback)(()=>{let e=H.current?.target;e&&e.kind!==`list`&&!Ys(e.id)&&window.confirm(h(`fileDeleteConfirm`,{name:e.label}))&&(ue?.src===e.id&&de(null),fe===e.id&&pe(null),r({type:`file_delete`,path:e.id}))},[r,h,ue,fe]),Te=(0,f.useCallback)(()=>{let e=H.current?.target;e&&e.kind!==`list`&&!Ys(e.id)&&r({type:`file_copy`,src:e.id,destDir:Js(e.id)})},[r]),J=(0,f.useCallback)(e=>{let t=H.current?.target;t&&t.kind!==`list`&&!Ys(t.id)&&de({src:t.id,cut:e})},[]),Ee=(0,f.useCallback)(()=>{if(!ue)return;let e=H.current?.dir??x;ue.cut?(r({type:`file_copy`,src:ue.src,destDir:e,move:!0}),de(null)):r({type:`file_copy`,src:ue.src,destDir:e})},[ue,r,x]),Y=(0,f.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[ke,Ae]=(0,f.useState)(!1);(0,f.useEffect)(()=>{if(!ke)return;let e=e=>{e.target?.closest(`.root-picker`)||Ae(!1)},t=e=>{e.key===`Escape`&&Ae(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[ke]);let je=(0,f.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),Me=(0,f.useCallback)(()=>{let e=H.current?.target;if(!e||e.kind!==`dir`)return;let t=V(e.id);t&&!v.includes(t)&&je([...v,t])},[v,V,je]),Ne=(0,f.useCallback)(e=>{ie(H.current?.dir??x,Array.from(e.target.files??[]))},[ie,x]),Fe=(0,f.useCallback)(e=>{let t=H.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`;ae({action:n,path:B(t.id),dir:B(n===`upload`?H.current?.dir??x:Js(t.id))});break}case`host:file-open-project`:ce();break;case`host:file-upload`:le();break;case`host:file-add-root`:Me();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&Ze(t.id);break;case`host:file-download`:t?.kind===`file`&&ye(t.id,t.label);break;case`host:file-reveal`:t&&t.kind!==`list`&&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-inline`:t?.kind===`file`&&i(t.id,t.label,`inline`);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`:Se(`file`);break;case`host:file-new-dir`:Se(`dir`);break;case`host:file-paste`:Ee();break;case`host:file-rename`:be();break;case`host:file-duplicate`:Te();break;case`host:file-cut`:J(!0);break;case`host:file-copy`:J(!1);break;case`host:file-copy-name`:t&&t.kind!==`list`&&z(t.label,`name:${t.id}`);break;case`host:file-copy-path`:t&&t.kind!==`list`&&z(B(t.id),`path:${t.id}`);break;case`host:file-copy-rel`:t&&t.kind!==`list`&&z(t.id,`rel:${t.id}`);break;case`host:file-refresh`:Y();break;case`host:file-delete`:we()}},[ce,x,le,Me,a,i,z,B,ye,Se,Ee,be,Te,J,Y,we]),Ie=(0,f.useCallback)((e,t)=>{let n=t.kind===`dir`?V(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&&Ys(t.id),l=!s&&Xs(t.id),d=x===zs,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&&ws(t.label)?e:{...e,hidden:!0};case`host:file-upload`:return d?{...e,hidden:!0}:{...e,label:r.dir===x?h(`uploadToCurrentDir`):h(`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-inline`:case`host:file-attach-ref`:return a?e:{...e,hidden:!0};case`host:file-reveal`:return s?{...e,hidden:!0}:e;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&&ue?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}});ti(f).length!==0&&(e.preventDefault(),e.stopPropagation(),H.current=r,Wr({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:Fe}))},[u,x,V,h,Fe,_,v,ue]),Re=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),ze=(0,f.useCallback)(()=>{P.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),P.current?.classList.remove(`drop-root`)},[]),He=(0,f.useCallback)(e=>{if(ze(),e==null)return;let t=P.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):P.current?.classList.add(`drop-root`)},[ze]),Ue=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Ge=(0,f.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),qe=(0,f.useRef)(0),Je=(0,f.useRef)(void 0),Ye=(0,f.useCallback)((e,t)=>{let n=++qe.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||qe.current===n&&E(!1)},[r]),Xe=(0,f.useCallback)(e=>{let t=v.filter(t=>t!==e);je(t),(x===e||x.startsWith(`${e}/`))&&Ye(``)},[v,je,x,Ye]);(0,f.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,f.useEffect)(()=>{if(_!==Je.current){Je.current=_,Ye(``,{silent:!0});return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&Ye(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,Ye]),(0,f.useEffect)(()=>{t&&t.path===x&&Ye(x,{silent:!0})},[t,x,Ye]);let Ze=e=>Ye(e),Qe=()=>{e?.parent!==null&&e?.parent!==void 0&&Ye(e.parent)},$e=(()=>{if(x===``||x===zs)return[];let e=x.split(`/`).filter(e=>!!e&&e!==zs);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(`/`)}))})(),et=[];for(let e of l??[]){if(e.source===`host`||e.hidden||e.kind===`divider`)continue;let t=g.find(t=>t.id===e.source.slice(7));t&&et.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let tt=(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:h(`collapsePanel`),onClick:c,children:(0,X.jsx)(Ve,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:j?`${k.files} 1 0`:`1 1 0`,minHeight:j?Hs:0},children:(0,X.jsx)(Rs,{storageKey:`rightpanel`,epoch:p??0,send:m??qs,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===Gs?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...tt?[]:[{id:Gs,label:h(`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:()=>Ye(``),children:h(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===zs?`active`:``}`,title:h(`computer`),onClick:()=>Ye(zs),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:h(`homeDir`),onClick:()=>Ye(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:h(`desktopDir`),onClick:()=>Ye(b),children:`🖥️`}),(0,X.jsx)(Cs,{text:h(`filesHelp`)}),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":ke,title:h(`workspaceRoots`),onClick:()=>Ae(e=>!e),children:[(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:h(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),ke&&(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:()=>{Ae(!1),Ye(``)},children:[h(`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:()=>{Ae(!1),Ye(e)},children:(0,X.jsx)(`span`,{className:`root-picker-path`,children:e})}),(0,X.jsx)(`button`,{type:`button`,className:`root-picker-remove`,title:h(`removeWorkspaceRoot`),"aria-label":h(`removeWorkspaceRoot`),onClick:()=>Xe(e),children:(0,X.jsx)(M,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:h(`workspaceRootsHint`)})]})]}),$e.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(We,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>Ye(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:I,className:`panel-body`,onScroll:e=>{F.current=e.currentTarget.scrollTop},onContextMenu:e=>Ie(e,{id:x,kind:`list`,label:x===``?h(`rootDir`):x===zs?h(`computer`):x}),onDragOver:e=>{Re(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Ge(),He(Ue(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||ze()},onDrop:e=>{if(ze(),!Re(e))return;e.preventDefault(),e.stopPropagation(),Ge();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,h(`foldersNotSupported`));return}ie(Ue(e.target),t)},onDragEnd:ze,children:[(0,X.jsx)(`input`,{ref:oe,type:`file`,multiple:!0,hidden:!0,onChange:Ne}),U&&(0,X.jsx)(ks,{request:U,onClose:()=>ae(null),onComplete:Y}),G&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[G.kind===`dir`?(0,X.jsx)(De,{className:`file-icon`}):(0,X.jsx)(Oe,{className:`file-icon`}),q(_e,ve,Ce,()=>he(null))]}),T&&(0,X.jsx)(`div`,{className:`panel-empty`,children:h(`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:Qe,children:[(0,X.jsx)(De,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:`..`})]}),e.entries.map(e=>e.type===`dir`?(0,X.jsxs)(`div`,{className:`file-item dir${ue?.cut&&ue.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Ie(t,{id:e.path,kind:`dir`,label:e.name}),children:[fe===e.path?q(W,me,xe,()=>pe(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>Ze(e.path),children:[(0,X.jsx)(De,{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":h(`linkFolderTip`),"aria-label":h(`linkFolderTip`),onClick:()=>i(e.path,e.name,`reference`,!0),children:(0,X.jsx)(K,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>z(e.name,`name:${e.path}`),children:L===`name:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Le,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>z(B(e.path),`path:${e.path}`),children:L===`path:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Be,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${ue?.cut&&ue.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Ie(t,{id:e.path,kind:`file`,label:e.name}),children:[fe===e.path?q(W,me,xe,()=>pe(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-name`,title:`${e.path} — ${h(`previewFile`)}`,onClick:()=>a(e.path,e.name),children:[(0,X.jsx)(Oe,{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":h(`downloadFile`),onClick:()=>ye(e.path,e.name),children:(0,X.jsx)(Pe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach inline`,"data-tip":h(`attachInlineTip`),onClick:()=>i(e.path,e.name,`inline`),children:(0,X.jsx)(se,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":h(`referenceTip`),"aria-label":h(`referenceTip`),onClick:()=>i(e.path,e.name,`reference`),children:(0,X.jsx)(K,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>z(e.name,`name:${e.path}`),children:L===`name:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Le,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>z(B(e.path),`path:${e.path}`),children:L===`path:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Be,{})})]},e.path)),e.truncated&&(0,X.jsx)(`div`,{className:`panel-empty files-truncated`,children:h(`filesTruncated`)})]}),!T&&!e&&(0,X.jsx)(`div`,{className:`panel-empty`,children:h(`noFiles`)})]})]})}],...et])})}),j&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:N,onDoubleClick:()=>A({...Vs}),title:h(`dragToResize`)}),j&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:Us},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:h(`widgetExpand`),onClick:()=>w(e.key),children:[(0,X.jsx)(`span`,{children:e.key}),(0,X.jsx)(ge,{})]}),(0,X.jsx)(`pre`,{className:`widget-lines`,children:e.lines.join(`
326
+ 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`,dshPresetCurrent:`current`,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)`,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`,schedulerNameLabel:`Task name`,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)`,schedulerPromptLabel:`Prompt`,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 the settings above, then save them as a preset)`,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`,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`,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)`,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`,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.`},Mt=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],Nt={};function Pt(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(Nt[e.code]=e,!0)}function Ft(e){delete Nt[e]}function It(e){return e===`zh`?`中文`:e.toUpperCase()}function Lt(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function Rt(e){let t=await fetch(Et(St(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var zt=(0,f.createContext)(null);function Bt(){try{return localStorage.getItem(kt)}catch{return null}}function Vt(){return Ot(Bt(),typeof navigator<`u`?navigator.languages:[],null)}function Ht({children:e}){let[t,n]=(0,f.useState)(Vt),[r,i]=(0,f.useState)(0),a=(0,f.useRef)(t);a.current=t;let o=(0,f.useCallback)(e=>{n(e);try{localStorage.setItem(kt,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,f.useCallback)(async()=>{let e,t=null;try{let n=await Rt(`/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 Rt(`/api/locales/${e.code}`);return Pt({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,f.useEffect)(()=>{s().then(e=>{if(!Bt()?.trim()){let t=Ot(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!Nt[t]){let t=Ot(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(kt,t)}catch{}}})},[s]);let c=(0,f.useMemo)(()=>[...Mt,...Object.values(Nt).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,f.useCallback)((e,n)=>{let r=Nt[t]?.strings[e]??(t===`zh`?At[e]:jt[e]);if(n)for(let[e,t]of Object.entries(n))r=r.replaceAll(`{${e}}`,String(t));return r},[t,r]);(0,f.useEffect)(()=>{document.documentElement.lang=Lt(t)},[t]);let u=(0,f.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(zt.Provider,{value:u,children:e})}function Ut(){let e=(0,f.useContext)(zt);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return Ut().t}var Wt=[{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`}];function Gt({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)(N,{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})})]}),Wt.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 Kt(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 qt=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),Jt=null,Yt=0;function Xt(){return Jt?.available===!0?Jt.pages??[]:[]}function Zt(){Date.now()-Yt<5e3||Qt().catch(()=>{})}async function Qt(){if(Kt())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=qt();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&&(Jt=r,Yt=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function $t(e){return e.length===1?e[0]:null}function en(e){return{path:e.origin,name:e.title?.trim()||e.origin,mode:`page`,key:`page:${e.origin}`}}async function tn(){let e=qt();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function nn(e=45e3){let[t,n]=(0,f.useState)(null),r=(0,f.useRef)(!0),i=(0,f.useCallback)(async e=>{let t=await Qt();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,f.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 rn=null,an=null,on=null;function sn(e){rn=e}function cn(e){an=e}function ln(e){on=e}function un(){return on?(on(),!0):!1}function Q(){return!!(rn||an)}function dn(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&&!rn||i&&!an?!1:(i&&an?.(n),r&&rn?.(t),!0)}function fn(){let e=Z(),{status:t,refresh:n}=nn(),[r,i]=(0,f.useState)(!1),[a,o]=(0,f.useState)(null),s=(0,f.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=$t(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},p=t=>{let n=dn({attachments:[en(t)]});d(e(n?`browserControlCited`:`browserControlCiteFailed`))},m=()=>{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:()=>p(u),children:[(0,X.jsx)(de,{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:m,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:m,children:[(0,X.jsx)(de,{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)(pn,{status:t,onRefresh:n,onCite:p,onClose:()=>i(!1)})]})}function pn({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,f.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await tn()||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)(de,{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 mn=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],hn=[`subagent_spawn`,`subagent_get_result`,`subagent_steer`,`subagent_list`,`subagent_stop`,`subagent_wait_all`,`subagent_templates`],gn=`edit_soft`,_n=`delegate_task`,vn=`ask_user_question`,yn=`todo_list`,bn=`browser_page`,xn=`conversation_read`,Sn=`skill`,Cn=`schedule_task`,wn=`schedule_list`,Tn=`schedule_cancel`,En=`present_files`,Dn=`claim_files`,On=[...mn.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...hn.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:gn,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:_n,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:vn,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:bn,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:xn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:Dn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:En,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:Sn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:Cn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:wn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:Tn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:yn,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}];new Set(On.map(e=>e.name));var kn=`pi-web-notify`,An={enabled:!1};function jn(){try{let e=localStorage.getItem(kn);if(!e)return{...An};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:An.enabled}}catch{return{...An}}}function Mn(e){try{localStorage.setItem(kn,JSON.stringify(e))}catch{}}function Nn(){return typeof window<`u`&&`Notification`in window}function Pn(){return Nn()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function Fn(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&In(t)||Number.isFinite(n)&&In(n)?!0:r>0&&r<=400&&i>0&&i<=40}function In(e){return e<=-1e4}function Ln(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var Rn=Date.now(),zn=!1;function Bn(){Rn=Date.now()}function Vn(){return Math.max(0,Date.now()-Rn)}function Hn(){if(zn||typeof window>`u`)return;zn=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,Bn,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,Bn,e)}function Un(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function Wn(){return Hn(),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:Fn({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Vn(),windows:Un()}}function Gn(){return Nn()?Notification.permission:`denied`}async function Kn(){if(!Nn())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function qn(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function Jn(e,t=!1){return{body:e,requireInteraction:t,icon:St(`/icons/icon-192.png`),badge:St(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:St(`/`)}}}async function Yn(e,t,n=!1){if(!Nn())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=Jn(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=qn(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${qn(e)}`}}}async function Xn(e,t){Nn()&&(Ln(Wn())||jn().enabled&&await Yn(e,t))}var Zn=!1;function Qn(){let e=Z(),[t,n]=(0,f.useState)(jn),[r,i]=(0,f.useState)(()=>Gn()),[a,o]=(0,f.useState)(null),s=Pn(),c=s!==null,l=Un();(0,f.useEffect)(()=>{let e=()=>i(Gn());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),Mn(r),e){let e=await Kn();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),Mn(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)(Ze,{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`)}),Zn]})}var $n=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),er=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(`.`)),tr=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),nr=new Set([...$n].map(e=>e.toLowerCase())),rr=new Set([...er].map(e=>e.toLowerCase()));function ir(e){return nr.has(e.toLowerCase())}function ar(e){return rr.has(e.toLowerCase())}function or(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[...e.children]){let e=t.tagName.toLowerCase();if(!ir(e)){tr.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of[...t.attributes]){let n=e.name.toLowerCase();(!ar(n)||/^on/i.test(n)||/^(javascript|data|vbscript):/i.test(e.value.trim()))&&t.removeAttribute(e.name)}i(t)}};for(let e of[...r.attributes]){let t=e.name.toLowerCase();(!ar(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function sr({icon:e,iconSvg:t,className:n}){let r=or(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 cr=[`topbar.primary`,`topbar.overflow`,`notice.actions`,`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.file`,`contextmenu.toolcall`,`settings.pages`,`modal.dialog`],lr=[{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: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: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-edit-reask`,slot:`message.actions`,labelKey:`editReask`,icon:`edit`,kind:`action`,order:10},{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: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-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-inline`,slot:`file.preview.toolbar`,labelKey:`attachInlineTip`,icon:`plus`,kind:`action`,order:60},{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-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-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:lp-projects`,slot:`leftpanel.sessions`,labelKey:`recentProjects`,icon:`folder`,kind:`action`,order:10},{id:`host:lp-running`,slot:`leftpanel.sessions`,labelKey:`runningConversations`,icon:`activity`,kind:`action`,order:20},{id:`host:lp-history`,slot:`leftpanel.sessions`,labelKey:`historySessions`,icon:`clock`,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-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-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-inline`,slot:`contextmenu.file`,labelKey:`attachInlineTip`,icon:`plus`,kind:`action`,context:`file`,order:31,group:`chat`},{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:tool-info`,slot:`contextmenu.toolcall`,labelKey:`toolInfoMenuLabel`,icon:`info`,kind:`action`,context:`toolcall`,order:10}],ur=new Set([`host:lp-projects`,`host:lp-running`,`host:lp-history`]),dr=`__view`,fr=new Set([`host:settings`]);function pr(e){return`${e}:${dr}`}function mr(e){return e.source.startsWith(`plugin:`)?e.id===pr(e.source.slice(7)):!1}function hr(e,t,n){let r=pr(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 gr(e,t){let n=t.map(pr),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var _r=`host:brand`,vr=[`host:brand-logo`,`host:brand-name`];function yr(e){if(!((e.hidden??[]).some(e=>vr.includes(e))||(e.shown??[]).some(e=>vr.includes(e))||(e.order??[]).some(e=>vr.includes(e))||vr.some(t=>e.align?.[t]!==void 0)||vr.some(t=>e.groups?.[t]!==void 0)||vr.some(t=>e.labels?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=vr.includes(n)?_r: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))vr.includes(t)||(n[t]=r);if(n[`host:brand`]===void 0){let r=t?e[vr[0]]??e[vr[1]]:e[vr[1]]??e[vr[0]];r!==void 0&&(n[_r]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))vr.includes(n)||(t[n]=r);if(t[`host:brand`]===void 0){let n=e[vr[0]]??e[vr[1]];n!==void 0&&(t[_r]=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)}:{}}}function br(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:dr,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 xr(e){return typeof e==`string`&&cr.includes(e)}function Sr(e,t){return t?e.label:e.labelEn??e.label}function Cr(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function wr(e,t,n,r,i){let a=`${e}#${r.id}`,o=Tr(a,t,n,r.children,i),s=Cr(r,i),c=Er(r.options,i);return{id:a,slot:t,source:n,label:Sr(r,i),...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 Tr(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:wr(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 Er(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 Dr(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function Or(e,t,n,r,i,a){let o=Tr(e,t,n,r.children,i),s=Cr(r,i),c=Dr(r.progress),l=Er(r.options,i);return{id:e,slot:t,source:n,label:Sr(r,i),...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 kr(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 Ar(e){let t=e.filter(e=>mr(e));if(t.length===0)return e;let n=e.filter(e=>!mr(e)),r=[`host:git`,`host:terminal`,`host:chat`].map(e=>n.findIndex(t=>t.id===e)).find(e=>e>=0)??-1,i=n.findIndex(e=>e.id===`host:plugins`),a=r+1;return i>=a&&(a=i),a=Math.max(0,Math.min(a,n.length)),[...n.slice(0,a),...t,...n.slice(a)]}function jr(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=yr(t.layout??{}),a=new Map,o=0;for(let e of lr)a.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:o++});for(let t of e){if(t.error||r.has(t.id))continue;let e=`plugin:${t.id}`;for(let r of t.ui?.items??[]){if(!xr(r.slot))continue;let i=`${t.id}:${r.id}`,s=a.get(i);a.set(i,Or(i,r.slot,e,r,n,s?.seq??o++))}}for(let t of e)if(!(t.error||r.has(t.id)))for(let e of t.ui?.arrange??[])Nr(a,e,t.id);let s=new Map,c=(e,t)=>{let n=s.get(e)??[];n.includes(t)||n.push(t),s.set(e,n)};for(let e of i.hidden??[]){let t=a.get(e);t&&(t.hidden=!0,c(e,`hidden`))}for(let e of i.shown??[]){let t=a.get(e);t&&(t.hidden=!1,c(e,`hidden`))}for(let[e,t]of Object.entries(i.groups??{})){let n=a.get(e);n&&(n.group=t,c(e,`group`))}for(let[e,t]of Object.entries(i.align??{})){let n=a.get(e);!n||t!==`start`&&t!==`center`&&t!==`end`||(n.align=t,c(e,`align`))}for(let[e,t]of Object.entries(i.labels??{})){let n=a.get(e);n&&(n.label=t,c(e,`label`))}for(let e of fr){let t=a.get(e);t&&(t.slot=`topbar.primary`,t.hidden=!1)}let l=new Map;(i.order??[]).forEach((e,t)=>{a.has(e)&&(l.has(e)||l.set(e,t),c(e,`order`))});let u=new Map;for(let e of cr)u.set(e,[]);for(let e of a.values())u.get(e.slot)?.push(e);let d={};for(let e of cr){let t=kr(u.get(e)??[],l);d[e]=(e===`topbar.primary`?Ar(t):t).map(e=>Mr(e,s.get(e.id)??[]))}return d}function Mr(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function Nr(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,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&&xr(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 Pr(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 Fr(e,t){let n=e??{},r={},i=t===`host:brand`?[t,...vr]:[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=Lr(n.groups,t),l=Lr(n.labels,t),u=Lr(n.align,t);if(t===`host:brand`)for(let e of vr)c=Lr(c,e),l=Lr(l,e),u=Lr(u,e);return c&&(r.groups=c),l&&(r.labels=l),u&&(r.align=u),n.topbarText!==void 0&&(r.topbarText=n.topbarText),r}function Ir(){return{}}function Lr(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 Rr=new Set([`host:files`]);function zr(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 Br(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 Vr=null,Hr=new Set;function Ur(){for(let e of Hr)e()}function Wr(e){Vr={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}:{}},Ur()}function Gr(){Vr!==null&&(Vr=null,Ur())}function Kr(e){return Hr.add(e),()=>{Hr.delete(e)}}function qr(){return Vr}function Jr(){return(0,f.useSyncExternalStore)(Kr,qr,qr)}function Yr(e){return Number.isFinite(e)?e:0}function Xr(e,t,n,r,i,a){let o=Math.max(0,Yr(n)),s=Math.max(0,Yr(r)),c=Math.max(8,Yr(i)-o-8),l=Math.max(8,Yr(a)-s-8);return{x:Math.min(Math.max(8,Yr(e)),c),y:Math.min(Math.max(8,Yr(t)),l)}}function Zr(e,t){let n=String(t?.kind??``);if(e===`contextmenu.file`)return{"file.isDir":n===`dir`,"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 Qr(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 $r(e,t){return!e||Qr(e.when,t)}function ei(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 ti(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 ni(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 ri(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!$r(e,t)}function ii(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,ri(e[o],r))return o;return-1}var ai={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:`〜`};function oi(e){let t=(e??``).trim();return t?ai[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var si={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},ci=new Set;function li(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function ui(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&&li(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&li(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function di(e){let t={...si,...e};if(!ui(si,t)){si=t;for(let e of ci)e()}}function fi(e){return ci.add(e),()=>{ci.delete(e)}}function pi(){return si}function mi(){return(0,f.useSyncExternalStore)(fi,pi,pi)}function hi(e){return(0,f.useSyncExternalStore)(fi,()=>si[e],()=>si[e])}function gi(){return hi(`engine`)===`dsh`}function _i(){return hi(`managed`)}function vi(){return hi(`service`)}var yi=null;function bi(e){yi=e}var $=e=>yi?yi(e):!1,xi=`@root`,Si=e=>e.endsWith(`/`)?e:e+`/`;function Ci(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function wi(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var Ti=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)?xi:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function Ei({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z(),[c,l]=(0,f.useState)(``),[u,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(null),[y,b]=(0,f.useState)(-1),x=(0,f.useRef)(null),S=(0,f.useRef)(null),C=n.filter(e=>e.type===`dir`);if((0,f.useEffect)(()=>{if(e){let e=(t||``).replace(/\\/g,`/`);l(e),d(e),m(!1),g(``),v(null),b(-1)}},[e,t]),(0,f.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{x.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,f.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(p?(m(!1),g(``),v(null)):i())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,p,i]),(0,f.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{$({type:`complete_path`,path:Si(c)})},60);return()=>clearTimeout(t)},[c,e]),(0,f.useEffect)(()=>{if(!e||u===c)return;let t=setTimeout(()=>{$({type:`complete_path`,path:u})},150);return()=>clearTimeout(t)},[u,c,e]),!e)return null;let w=e=>{let t=e.trim();t&&t!==`@root`&&(a(t),i())},T=()=>{let e=h.trim();if(!wi(e)){v(s(`invalidProjectName`));return}o(Ci(c,e)),m(!1),g(``),v(null),i()},E=e=>{if(e.key===`Escape`)e.stopPropagation(),p?(m(!1),g(``),v(null)):i();else if(e.key===`Enter`&&!e.nativeEvent.isComposing)w(u);else if(e.key===`Tab`){if(C.length===0)return;e.preventDefault();let t=y>=0?(y+1)%C.length:0;b(t),d(C[t].path),l(C[t].path)}},D=Ti(c),O=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},k=O(c),A=!!c&&c!==`@root`&&k!==O(t)&&!r.some(e=>O(e)===k);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`status-cwd-backdrop project-picker-backdrop`,onClick:i}),(0,X.jsxs)(`div`,{className:`cwd-picker project-picker`,role:`dialog`,"aria-label":s(`projectPickerTitle`),children:[(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:c===`@root`?s(`computer`):c,children:[c===`@root`?`💻`:(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{children:c===`@root`?s(`computer`):c})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:c===xi,title:s(`computer`),onClick:()=>{l(xi),d(xi),b(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!D,title:s(`cwdGoUp`),onClick:()=>{D&&(l(D),d(D),b(-1))},children:[`↑ `,s(`cwdGoUp`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!A,title:s(`addWorkspaceRootHint`),onClick:()=>{A&&$({type:`set_workspace_roots`,roots:[...r,c]})},children:[`+ `,s(`addWorkspaceRoot`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:x,className:`status-cwd-input cwd-picker-input`,value:u,placeholder:s(`enterPath`),spellCheck:!1,onChange:e=>{d(e.target.value),b(-1)},onKeyDown:E}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:s(`cwdPickCurrent`),disabled:c===xi,onClick:()=>w(c),children:s(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[C.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:s(`cwdEmpty`)}),C.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${s(`cwdEnter`)} ${e.path}`,onClick:()=>{l(e.path),d(e.path),b(-1)},children:[(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:s(`cwdChoose`),onClick:()=>w(e.path),children:s(`cwdChoose`)})]},e.path))]}),(0,X.jsxs)(`div`,{className:`cwd-picker-foot`,children:[p?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:S,value:h,autoFocus:!0,spellCheck:!1,placeholder:s(`projectName`),onChange:e=>{g(e.target.value),_&&v(null)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),T()):e.key===`Escape`&&(e.stopPropagation(),m(!1),g(``),v(null))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:T,children:s(`createAndOpenProject`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{m(!1),g(``),v(null)},children:s(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>m(!0),children:[`+ `,s(`newProject`)]}),_&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:_})]})]})]})}function Di(e){return T({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 Oi(e){return T({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 ki(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 Ai(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,f.useRef)(null),[d,p]=(0,f.useState)(null),m=(0,f.useRef)(i);(0,f.useLayoutEffect)(()=>{m.current=i});let h=()=>{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},g=()=>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=g(),i=r&&r.isConnected?r.getBoundingClientRect():h();if(!i)return;let a=ki(i,{width:n.width,height:n.height},{width:window.innerWidth,height:window.innerHeight},{align:o,side:s,gap:c,margin:l});p(e=>e?.x===a.x&&e?.y===a.y?e:a)};return(0,f.useLayoutEffect)(()=>{t?_():p(null)},[t,n,r,o,s,c,l]),mt(()=>{m.current()},t),(0,f.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||g()?.contains(e)||a?.(e)),n=t=>{e(t.target)||m.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 ji({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=Ut(),{panelRef:d,style:p,measure:m}=Ai({anchor:e,anchorEl:t,onClose:l}),[,h]=(0,f.useState)(null),g=(0,f.useRef)(null),[_,v]=(0,f.useState)(null),y=(0,f.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,f.useLayoutEffect)(()=>{m()},[y,m]);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,D.createPortal)((0,X.jsxs)(`div`,{ref:d,className:`pm-panel`,role:`menu`,"aria-label":u(`pluginMenuTitle`),style:p,children:[(0,X.jsxs)(`div`,{className:`pm-head`,"aria-hidden":`true`,children:[(0,X.jsx)(Ye,{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&&g.current&&(n.preventDefault(),v(e.id))},onDrop:t=>{t.preventDefault(),x(t.dataTransfer.getData(`text/plain`)||g.current,e.id),g.current=null,h(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=>{h(e.id),g.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:()=>{g.current=null,h(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)(G,{"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)(sr,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(Ye,{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)(Oi,{"aria-hidden":!0}):(0,X.jsx)(Di,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(re,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function Mi({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=Ut(),[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)(``),[l,u]=(0,f.useState)(``);async function d(){try{let e=await fetch(Et(St(`/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,f.useEffect)(()=>{d()},[]);async function p(e){u(e),c(``);try{let t=await fetch(Et(St(`/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 m(e){u(e),c(``);try{let t=await fetch(Et(St(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);Ft(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)(Te,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(M,{})})]}),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 m(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 p(e.code),children:[(0,X.jsx)(Pe,{}),(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)(oe,{}),(0,X.jsx)(`span`,{children:t(`bgTaskRefresh`)})]})})]})})}var Ni=`xing-shuyin/pi-web-ui`,Pi={state:`idle`,version:null,percent:0,message:null};function Fi(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Ii(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:Fi(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 Li(e){if(!Kt(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 Ri(e){return e instanceof Error?e.message:String(e)}function zi(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${Ni}/releases/tag/v${t}`:`https://github.com/${Ni}/releases/latest`}function Bi(){let[e]=(0,f.useState)(()=>Li()),[t,n]=(0,f.useState)(Pi);(0,f.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>Ii(t,e)))},[e]);let r=(0,f.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:Ri(e)}))))},[e]),i=(0,f.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:Ri(e)}))))},[e]),a=(0,f.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:Ri(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}function Vi({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=Ai({open:t,anchor:e,onClose:n});return(0,f.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,D.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Hi(){let[e,t]=(0,f.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,f.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 Ui({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:p,onOpenGlobalSearch:m,sound:h,onSoundChange:g,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x}){let{locale:S,setLocale:C,t:w,packs:T}=Ut(),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(!1),[A,j]=(0,f.useState)(null),M=hi(`cwd`),P=hi(`workspaceRoots`),F=(0,f.useRef)(null),I=t=>!e.tabs||t===`chat`||e.tabs.includes(t),L=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!mr(e)),R=new Set([...i??[],...a??[]].filter(e=>mr(e)&&!e.hidden).map(e=>e.source.slice(7))),te=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),z=r.map((e,t)=>({id:e.id,index:t})).sort((e,t)=>(te.get(`${e.id}:__view`)??1e6+e.index)-(te.get(`${t.id}:__view`)??1e6+t.index)).map(e=>e.id),B=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:files`].map(e=>({id:e,entry:null})):i.map(e=>({id:e.id,entry:e})),V=(I(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!B.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:[]})),ie=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`}),un(),!0;case`host:open-project`:return k(!0),!0;case`host:search`:return m(),!0;case`host:tasks`:return p(),!0;case`host:settings`:return u(),!0;case`host:plugins`:return j(F.current?{rect:F.current.getBoundingClientRect(),el:F.current}:null),!0;default:return!1}},U=(e,t,n)=>{e.preventDefault(),Wr({x:e.clientX,y:e.clientY,slot:`contextmenu.topbar`,target:{id:t,label:n},entries:o??[]})},{appVersion:ae}=mi(),oe=_i(),ce=vi(),[le,ue]=(0,f.useState)(!1);(0,f.useEffect)(()=>{le&&e.status===`open`&&ue(!1)},[le,e.status]);let[de,fe]=(0,f.useState)(!1),[pe,W]=(0,f.useState)(!1),[he,ge]=(0,f.useState)(!1),[_e,ve]=(0,f.useState)(!1),ye=Kt(),K=Bi(),[xe,Se]=(0,f.useState)(!1),Ce=()=>{if(!e.ready)return;let n=w(`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:ot(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r}),ve(!1),c(`terminal`)},q=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:it(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:ot(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:r,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:i}),ve(!1),c(`terminal`)},we=e.updatesAll??[],Oe=we.filter(e=>!e.upToDate&&!e.error).length,ke=we.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Ae=e=>e.kind===`git-extension`&&e.source?e.source:e.name,je=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,Me=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},Ne=(e,t)=>{if(!t)return Me(e);let n=Me(e),r=Me(t);return n===r?n:`${n} → ${r}`},Fe=()=>(0,X.jsxs)(`div`,{className:`dd-updates-all`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`updatesAllTitle`)}),e.updatesAll===null?(0,X.jsx)(`div`,{className:`dd-note`,children:w(`checkingUpdate`)}):we.length===0?(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updatesAllUpToDate`)}):(0,X.jsx)(`ul`,{className:`dd-all-list`,children:we.map(e=>(0,X.jsxs)(`li`,{className:`dd-all-item${e.error?` err`:e.upToDate?``:` warn`}`,children:[e.kind!==`webui`&&!e.upToDate&&!e.error&&(0,X.jsx)(`button`,{type:`button`,className:`dd-update-btn`,onClick:()=>q([e],w(`updatePkgTabTitle`,{name:e.name})),children:w(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:je(e),children:Ae(e)}),(0,X.jsxs)(`span`,{className:`dd-all-meta`,children:[(0,X.jsx)(`span`,{className:`dd-all-kind`,children:e.kind===`webui`?w(`kindWebUi`):e.kind===`pi-core`?w(`kindPiCore`):e.kind===`git-extension`?w(`kindGitExtension`):w(`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?w(`updateCheckFailed`):e.kind===`git-extension`?e.upToDate?Me(e.current):Ne(e.current,e.latest):e.upToDate?`v${e.current}`:(0,X.jsxs)(X.Fragment,{children:[`v`,e.current,` → v`,e.latest]})})]})]},`${e.kind}:${e.name}`))}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[ke.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>q(ke,w(`updateAllTabTitle`)),children:w(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:ke.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:w(`updatesAllRefresh`)})]})]}),Ie=()=>{let t=zi(e.update?.latest??K.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:w(`updateDesktopManual`)});if(!K.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopNoBridge`)}),n]});switch(K.state){case`checking`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateDesktopChecking`)}),n]});case`available`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopAvailable`,{version:K.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>K.download(),children:w(`updateDesktopDownload`)}),n]});case`downloading`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateDesktopDownloading`,{n:K.percent})}),n]});case`downloaded`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note ok`,children:w(`updateDesktopDownloaded`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>K.quitAndInstall(),children:w(`updateDesktopInstall`)}),n]});case`up-to-date`:return(0,X.jsx)(`div`,{className:`dd-note ok`,children:w(`upToDate`)});case`error`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopError`,{error:K.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>K.check(),children:w(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>K.check(),children:w(`updateDesktopCheck`)}),n]})}},Le=()=>(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:w(`currentVersion`)}),(0,X.jsxs)(`b`,{children:[`v`,e.update?.current??`…`]})]}),(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:w(`latestVersion`)}),(0,X.jsx)(`b`,{children:e.update===null?w(`checkingUpdate`):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:w(`checkingUpdate`)})]}),e.update&&e.update.upToDate&&(0,X.jsx)(`div`,{className:`dd-note ok`,children:w(`upToDate`)}),e.update&&!e.update.upToDate&&e.update.latest&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`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:w(`updateJustPublished`,{version:e.update.latest??``})}),e.update&&!e.update.upToDate&&e.update.latest&&!ye&&(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&ye&&(0,X.jsx)(`div`,{className:`dd-note`,children:w(`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?w(`checkingUpdate`):w(`checkUpdate`)}),e.update&&!e.update.upToDate&&e.update.latest&&!ye&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:Ce,children:w(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&ye&&Ie(),ce&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:le,title:w(`restartServiceTip`,{name:ce.name}),onClick:()=>{le||(ue(!0),$({type:`restart_service`}))},children:w(le?`restartingService`:`restartService`)})]})]}),Re=Hi(),ze={"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":w(`openProject`),onClick:()=>k(!0),children:[(0,X.jsx)(Y,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`openProject`)})]}),"host:history":n===`chat`&&I(`history`)?(0,X.jsx)(`button`,{type:`button`,className:`panel-toggle`,"data-tip":w(`openHistory`),"aria-label":w(`openHistory`),onClick:()=>l(`left`),children:(0,X.jsx)(G,{})}):null,"host:files":n===`chat`&&I(`files`)?(0,X.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label`,"data-tip":w(`openFiles`),"aria-label":w(`openFiles`),onClick:()=>l(`right`),children:[(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{children:w(`openFiles`)})]}):null,"host:new-chat":I(`new-chat`)?(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat`,"data-tip":w(`newChatTip`),onClick:()=>{c(`chat`),$({type:`new_chat`}),un()},children:[(0,X.jsx)(se,{}),(0,X.jsx)(`span`,{children:w(`newChat`)})]}):null,"host:chat":(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`chat`,className:`tb-tab${n===`chat`?` active`:``}`,"data-tip":w(`chat`),onClick:()=>c(`chat`),children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:w(`chat`)})]}),"host:terminal":I(`terminal`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`terminal`,className:`tb-tab${n===`terminal`?` active`:``}`,"data-tip":w(`terminal`),onClick:()=>c(`terminal`),children:[(0,X.jsx)(ee,{}),(0,X.jsx)(`span`,{children:w(`terminal`)})]}):null,"host:git":I(`git`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`git`,className:`tb-tab${n===`git`?` active`:``}`,"data-tip":w(`scmTab`),onClick:()=>c(`git`),children:[(0,X.jsx)(Ee,{}),(0,X.jsx)(`span`,{children:w(`scmTab`)})]}):null,"host:plugins":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":w(`pluginMenuTitle`),"aria-haspopup":`menu`,"aria-expanded":A!==null,onClick:e=>{let t=e.currentTarget;j(e=>e?.el===t?null:{rect:t.getBoundingClientRect(),el:t})},children:[(0,X.jsx)(Ye,{"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`pluginMenuTitle`)})]}),"host:search":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":w(`searchGlobalTip`),onClick:m,children:[(0,X.jsx)(H,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(fn,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":w(`bgTasksTip`),onClick:p,children:[(0,X.jsx)(be,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`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":w(`settingsTitle`),onClick:u,children:[(0,X.jsx)(re,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`settings`)})]}),"host:sound":(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`sound`)})]}),tip:w(`sound`),open:de,onOpenChange:fe,children:[(0,X.jsx)(Gt,{settings:h,onChange:g,onPreview:_}),(0,X.jsx)(Qn,{})]}),"host:language":(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Te,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:It(S)})]}),tip:w(`language`),open:pe,onOpenChange:W,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`language`)}),T.map(e=>(0,X.jsx)(_t,{active:S===e.code,onClick:()=>{C(e.code),W(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(_t,{onClick:()=>{W(!1),Se(!0)},children:[(0,X.jsx)(Pe,{}),` `,w(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`theme`)})]}),tip:w(`theme`),open:he,onOpenChange:e=>{ge(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=S===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?w(`themeLight`):e.scheme===`dark`?w(`themeDark`):``;return n?S===`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:w(`themeGroupClassics`)}),e.map(e=>(0,X.jsx)(_t,{active:y===e.id,onClick:()=>{b(e.id),ge(!1)},children:n(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:e.length>0?w(`themeGroupBuiltin`):w(`theme`)}),(0,X.jsx)(_t,{active:y===null,onClick:()=>{b(null),ge(!1)},children:w(`themeDefault`)}),t.map(e=>(0,X.jsx)(_t,{active:y===e.id,onClick:()=>{b(e.id),ge(!1)},children:n(e)},e.id))]})})()}),"host:update":oe?(0,X.jsxs)(`span`,{className:`chip`,"data-tip":w(`updatesManaged`),children:[(0,X.jsx)(Pe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,ae??e.update?.current??`…`]})]}):(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pe,{}),(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:w(`updateAvailable`,{version:e.update.latest??``})}),Oe>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:w(`updatesAllBadge`,{n:Oe})})]}),tip:w(`update`),open:_e,onOpenChange:e=>{ve(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},fit:!0,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`update`)}),Le(),Fe()]}),"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":w(`githubRepo`),children:(0,X.jsx)(J,{})})},Be=new Set([`host:search`,`host:tasks`,`host:settings`,`host:plugins`]),Ve=new Set([`host:sound`,`host:language`,`host:theme`,`host:update`,`host:browser`]),He=e=>Be.has(e)&&!I(e.slice(5)),Ue=e=>{if(e.kind===`view`){if(!I(`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=>U(t,e.id,e.label),children:[(0,X.jsx)(sr,{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=>U(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=>U(t,e.id,e.label),children:[(0,X.jsx)(sr,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},We=[];for(let e of B){if(e.entry?.hidden||He(e.id))continue;let t=e.id.startsWith(`host:`)?ze[e.id]??null:e.entry?Ue(e.entry):null;t&&We.push({id:e.id,entry:e.entry,node:t})}for(let e of V){let t=Ue(e);t&&We.push({id:e.id,entry:e,node:t})}let Ge=e=>e.entry?.align??`start`,[Ke,qe]=(0,f.useState)(()=>new Set),Je=(0,f.useRef)(null),Xe=(0,f.useRef)(new Map),Ze=We.filter(e=>!Ke.has(e.id)),Qe=Re?Ze.filter(e=>Rr.has(e.id)):[],$e=Re?Ze.filter(e=>!Rr.has(e.id)):Ze,et=Re?We.filter(e=>!Rr.has(e.id)):We,tt=[...et.filter(e=>Ge(e)===`start`),...et.filter(e=>Ge(e)===`center`),...et.filter(e=>Ge(e)===`end`)],nt=tt.filter(e=>!Ke.has(e.id)),rt=()=>{let e=Je.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`));t.length===nt.length&&nt.forEach((e,n)=>Xe.current.set(e.id,t[n].offsetWidth));let n=Number.parseFloat(getComputedStyle(e).columnGap)||0,r=Br(tt.map(e=>({id:e.id,width:e.entry?Xe.current.get(e.id)??0:0})),e.clientWidth,n,0,fr);qe(e=>e.size===r.size&&[...r].every(t=>e.has(t))?e:r)},at=`${Ze.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${Re?`m`:`d`}`;(0,f.useLayoutEffect)(rt,[at]),(0,f.useEffect)(()=>{let e=Je.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>rt());return t.observe(e),()=>t.disconnect()},[at]);let st=$e.filter(e=>Ge(e)===`start`),ct=$e.filter(e=>Ge(e)===`center`),lt=$e.filter(e=>Ge(e)===`end`),ut=We.filter(e=>Ke.has(e.id)&&e.entry).map(e=>e.entry),dt=new Map;[...i??[],...a??[]].forEach((e,t)=>{dt.has(e.id)||dt.set(e.id,t)});let ft=zr([...L,...ut],e=>dt.get(e)??999999),pt=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${pt?` no-labels`:``}`,"data-pi-anchor":`topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-flow`,ref:Je,role:`toolbar`,"aria-label":w(`viewSwitch`),children:[st.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id)),(ct.length>0||lt.length>0)&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),ct.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id)),lt.length>0&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),lt.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id))]}),ft.length>0&&(0,X.jsxs)(`div`,{className:`plugin-topbar-more`,children:[(0,X.jsx)(`button`,{ref:F,type:`button`,className:`plugin-topbar-item`,"aria-haspopup":`menu`,"aria-expanded":E,"data-tip":w(`pluginTopbarMore`),onClick:()=>D(e=>!e),children:`⋯`}),(0,X.jsx)(Vi,{anchorRef:F,open:E,onClose:()=>D(!1),children:ft.map(e=>{let t=e.source===`host`&&Ve.has(e.id)?ze[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(f.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:w(`githubRepo`),onClick:()=>D(!1),children:[(0,X.jsx)(J,{}),(0,X.jsx)(`span`,{children:`GitHub`})]},e.id);if(e.source===`host`){let t=ze[e.id];if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>D(!1),children:t},e.id)}else{let t=Ue(e);if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>D(!1),children:t},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsxs)(`label`,{className:`plugin-topbar-overflow-select`,title:e.hint??e.label,children:[(0,X.jsxs)(`span`,{children:[e.icon&&!/[a-z]/i.test(e.icon)?`${e.icon} `:``,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=>{D(!1),ie(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`,title:e.hint??e.label,onClick:()=>{D(!1),ie(e)||s?.(e)},children:[e.icon&&!/[a-z]/i.test(e.icon)?`${e.icon} `:``,e.label]},e.id)})})]}),Qe.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id)),xe&&(0,X.jsx)(Mi,{onClose:()=>Se(!1)}),A&&(0,X.jsx)(ji,{anchorRect:A.rect,anchorEl:A.el,plugins:r,pinnedIds:R,orderedPluginIds:z,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:hr(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:gr(e.settings?.uiLayout,t)}),onOpenView:e=>{j(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>j(null)}),O&&(0,X.jsx)(Ei,{open:!0,currentCwd:M,pathCompletions:e.pathCompletions??[],workspaceRoots:P,onClose:()=>k(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Wi(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 Gi(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 Ki(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 qi(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 Ji(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 Yi=`pi-web-ui:lp-collapse-projects`,Xi=`pi-web-ui:lp-collapse-convs`,Zi=`pi-web-ui:lp-collapse-sessions`;function Qi(e,t=!1){let[n,r]=(0,f.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,f.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var $i=`pi-web-ui:lp-sizes`,ea={projects:1,convs:1,sessions:1},ta=32,na=72;function ra(){try{return Wi(localStorage.getItem($i),ea)}catch{return{...ea}}}var ia=(0,f.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:p,onUiAction:m,presetNames:h}){let g=Z(),_=e,v=hi(`ready`),y=hi(`status`),b=hi(`cwd`),x=hi(`workspaceRoots`),S=b,[C,w]=(0,f.useState)(!1),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(null),[k,A]=(0,f.useState)(``),[j,N]=Qi(Yi,!1),[P,F]=Qi(Xi,!1),[I,R]=Qi(Zi,!1),ee=(0,f.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]),te=(0,f.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},[]),ne=(0,f.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},[]),z=(0,f.useRef)(null),B=(0,f.useRef)(null),V=(0,f.useRef)(()=>{}),re=ti(d??[]).length>0,ie=(0,f.useCallback)((e,n,r)=>{z.current={x:e,y:n,target:r};let i=r.kind===`running`?r.id:void 0,a=r.kind===`elsewhere`,o=i??(a&&r.id||void 0),s=ee(t,i),c=s===0?g(`noFinishedSubagents`):g(i?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:s}),l=!!i&&B.current===i;Wr({x:e,y:n,slot:`contextmenu.session`,target:r,entries:(d??[]).map(e=>{if(e.source!==`host`)return e;if(e.id===`host:conv-rename`)return r.kind===`running`||r.kind===`history`?e:{...e,hidden:!0};if(e.id===`host:conv-takeover`)return a&&o&&r.owner?e:{...e,hidden:!0};if(a&&(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:c,...s===0?{when:[...e.when??[],`disabled`]}:{}};if(e.id===`host:conv-force-dismiss`)return i?{...e,...l?{label:g(`forceDismissConfirm`)}:{}}:{...e,hidden:!0};if(e.id===`host:conv-persist`){if(!i)return{...e,hidden:!0};let n=t.find(e=>e.id===i);return n&&(n.isSubagent||!n.sessionFile)?e:{...e,hidden:!0}}return e.id===`host:conv-copy-id`?o?e:{...e,hidden:!0}:e.id===`host:conv-copy-path`?r.kind===`history`?e:i?t.some(e=>e.id===i&&e.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}:{...e,hidden:!0}:e.id===`host:conv-quote`?o||r.kind===`history`?e:{...e,hidden:!0}:e}),onHostAction:(e,t)=>V.current(e,t)})},[d,t,ee,g]);V.current=(0,f.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=z.current;if(!i||!e)return;if(B.current!==i)return B.current=i,ie(e.x,e.y,e.target),!0;B.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-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-quote`){n.kind===`history`&&n.id?dn({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&dn({attachments:[{path:``,key:`conv|${a}|`,name:n.label||a,mode:`conversation`,conversationId:a}]});return}if(e.id===`host:conv-rename`){if(E(null),i){let e=t.find(e=>e.id===i);A(e?.title??n.label??``),O(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);A(e?.name??n.label??``),O(n.id)}return}},[o,ie,t,r]);let H=()=>{let e=(p??[]).filter(e=>!ur.has(e.id));return e.length===0?null:(0,X.jsx)(`span`,{className:`lp-slot-sessions`,children:e.map((e,t)=>{let n=`${e.id}#${t}`,r=e.label||e.id,i=e.hint||r;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`lp-slot-divider`,"aria-hidden":`true`},n):e.kind===`badge`?(0,X.jsx)(`span`,{className:`lp-slot-badge`,title:i,children:e.badge??r},n):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`lp-slot-select`,title:i,"aria-label":r,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onClick:e=>e.stopPropagation(),onChange:t=>{t.stopPropagation(),m?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},n):(0,X.jsx)(`button`,{type:`button`,className:`lp-slot-btn`,title:i,"aria-label":r,onClick:t=>{t.stopPropagation(),m?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:r})},n)})})},U=(0,f.useCallback)((e,t)=>{Ji(e.target)||re&&(e.preventDefault(),e.stopPropagation(),B.current=null,ie(e.clientX,e.clientY,t))},[re,ie]),ae=(0,f.useRef)(null),[oe,ce]=(0,f.useState)(()=>ra());(0,f.useEffect)(()=>{try{localStorage.setItem($i,JSON.stringify(oe))}catch{}},[oe]);let le=[...t,...n.map((e,t)=>({id:`elsewhere:${e.cwd}:${e.title}:${t}`,title:e.title,cwd:e.cwd,messageCount:0,isStreaming:e.isStreaming,isSubagent:!1,elsewhere:!0,...e.owner&&e.convId?{owner:e.owner,convId:e.convId}:{},...e.hasQuestion?{hasQuestion:!0}:{}}))],ue=(0,f.useCallback)((e,t)=>n=>{n.preventDefault();let r=n.currentTarget,a=n.clientY,o={...oe},s=ae.current;if(!s)return;let c=[{key:`projects`,visible:i.length>0,collapsed:j},{key:`convs`,visible:le.length>0,collapsed:P},{key:`sessions`,visible:!0,collapsed:I}].filter(e=>e.visible),l=c.filter(e=>e.collapsed).length,u=c.filter(e=>!e.collapsed).map(e=>e.key).reduce((e,t)=>e+(o[t]??1),0)||1,d=Math.max(120,s.clientHeight-l*ta);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let f=n=>{let{above:r,below:i}=Gi({start:{above:o[e]??1,below:o[t]??1},deltaPx:n.clientY-a,availablePx:d,totalWeight:u,minAbovePx:na,minBelowPx:na});ce(n=>({...n,[e]:r,[t]:i}))},p=()=>{window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),r.classList.remove(`dragging`),document.body.classList.remove(`lp-resizing`)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p)},[oe,i.length,le.length,j,P,I]);(0,f.useEffect)(()=>{s&&v&&y===`open`&&b&&(o({type:`list_sessions`}),o({type:`list_projects`}))},[s,v,y,b,o]);let de=e=>{let t=e.name||e.firstMessage.trim();return t.length>0?t:g(`emptyChat`)},fe=e=>e.split(/[\\/]/).pop()||e,pe=(e,t,n,r,i)=>{let a=T===e;return(0,X.jsx)(`button`,{type:`button`,className:`lp-del ${a?`confirm`:``}`,title:a?n:t,onClick:t=>{t.stopPropagation(),a?(E(null),r()):E(e)},children:a?(0,X.jsx)(Ke,{}):i??(0,X.jsx)(L,{})})},W=(e,t,n,r,i)=>(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:g(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)(Ge,{}):(0,X.jsx)(Ue,{})})]}),i?(0,X.jsx)(`div`,{className:`lp-section-actions`,children:i}):null]}),G=[{key:`projects`,visible:i.length>0,collapsed:j},{key:`convs`,visible:le.length>0,collapsed:P},{key:`sessions`,visible:!0,collapsed:I}].filter(e=>e.visible).filter(e=>!e.collapsed),he=G.reduce((e,t)=>e+(oe[t.key]??1),0)||1,ge=e=>G.length<=1?1:(oe[e]??1)/he*G.length;return(0,X.jsxs)(`aside`,{ref:ae,className:`panel panel-left lp-panel`,children:[c&&l&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:g(`collapsePanel`),onClick:l,children:(0,X.jsx)(He,{})}),(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${j||i.length===0?`collapsed`:``}`,style:i.length>0&&!j?{flex:`${ge(`projects`)} 1 0px`}:void 0,children:[W(g(`recentProjects`),j,N,i.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action`,title:g(`manageProjects`),"aria-label":g(`manageProjects`),onClick:()=>w(!0),children:(0,X.jsx)(Y,{})})),i.length>0&&!j&&(0,X.jsx)(`div`,{className:`lp-section-body projects-scroll`,children:i.map(e=>{let t=S===e.path;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>E(t=>t===`proj:${e.path}`?null:t),children:[(0,X.jsxs)(`button`,{type:`button`,className:`project-item ${t?`active`:``}`,title:e.path,onClick:()=>{t||o({type:`set_cwd`,path:e.path})},children:[(0,X.jsx)(De,{className:`project-icon`}),(0,X.jsxs)(`span`,{className:`project-info`,children:[(0,X.jsx)(`span`,{className:`project-name`,children:fe(e.path)}),(0,X.jsx)(`span`,{className:`project-path`,children:e.path})]}),(0,X.jsx)(`span`,{className:`project-time`,children:qi(e.lastUsed)})]}),pe(`proj:${e.path}`,g(`deleteProject`),g(`deleteProjectConfirm`),()=>o({type:`remove_project`,path:e.path}))]},e.path)})})]}),i.length>0&&!j&&(le.length>0?!P:!I)&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:ue(`projects`,le.length>0?`convs`:`sessions`),onDoubleClick:()=>ce({...ea}),title:g(`dragToResize`)}),le.length>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${P?`collapsed`:``}`,style:P?void 0:{flex:`${ge(`convs`)} 1 0px`},onContextMenu:e=>U(e,{id:``,kind:`section`,label:g(`runningConversations`)}),children:[W(g(`runningConversations`),P,F,le.length),!P&&(0,X.jsx)(`div`,{className:`lp-section-body convs-scroll`,children:Ki(le,b,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,children:fe(e.cwd)}),(()=>{let n=new Map(e.convs.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e.convs)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 s=[],c=new Set,l=(e,t)=>{if(!c.has(e.id)){c.add(e.id),s.push({c:e,depth:t});for(let n of r.get(e.id)??[])l(n,t+1)}};for(let e of i)l(e,0);for(let t of e.convs)l(t,0);return s.map(({c:n,depth:r})=>{if(n.elsewhere)return(0,X.jsx)(`div`,{className:`lp-row`,onContextMenu:e=>U(e,{id:n.convId??n.id,kind:`elsewhere`,label:n.title,...n.owner?{owner:n.owner}:{}}),children:(0,X.jsxs)(`div`,{className:`session-item elsewhere-item`,title:`${g(`elsewhereTip`)}\n${n.cwd}`,children:[(0,X.jsx)(me,{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:g(`elsewhereBadge`)}),n.hasQuestion&&n.owner&&n.convId&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:g(`takeoverHasQuestion`),onClick:e=>{e.stopPropagation(),o({type:`peek_elsewhere_question`,owner:n.owner,id:n.convId})},children:`?`}),n.title]}),(0,X.jsx)(`span`,{className:`session-sub`,children:fe(n.cwd)})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:g(`streaming`)})]})},n.id);let i=a===n.id;return(0,X.jsxs)(`div`,{className:`lp-row${r>0?` lp-sub`:``}`,style:r>0?{marginLeft:r*18}:void 0,onMouseLeave:()=>E(e=>e===`conv:${n.id}`?null:e),onContextMenu:e=>U(e,{id:n.id,kind:`running`,label:n.title}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${i?`active`:``}`,title:`${n.title}${e.isCurrent?``:` — ${e.cwd}`}`,onClick:()=>{i||o({type:`switch_conversation`,id:n.id})},children:[(0,X.jsx)(me,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[D===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:k,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>A(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=k.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),O(null)}else e.key===`Escape`&&O(null)},onBlur:()=>O(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:g(`subagentBadge`)}),n.agentPreset&&(0,X.jsx)(`span`,{className:`preset-badge`,title:n.agentPreset,children:h?.[n.agentPreset]??n.agentPreset}),n.title,n.error&&(0,X.jsx)(`span`,{className:`conv-error-badge`,title:g(`convErrorBadge`,{error:n.error})}),n.hasQuestion&&(0,X.jsx)(`span`,{className:`question-badge`,title:g(`waitingQuestionBadge`),children:`?`})]}),D===`conv:${n.id}`?null:(0,X.jsx)(`span`,{className:`session-sub`,children:i?g(`current`):g(`messageCount`,{n:n.messageCount})})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:g(`streaming`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:e=>{e.stopPropagation(),E(null),A(n.title),O(`conv:${n.id}`)},children:(0,X.jsx)(Ne,{})}),(()=>{let e=`conv:${n.id}`,r=T===e,i=ee(t,n.id),a=ne(t,n.id),s=te(t,n.id);return s===0&&!n.isStreaming?pe(e,g(`dismissConversation`),g(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(M,{})):s===0?pe(e,g(`dismissConversation`),g(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(M,{})):r?(0,X.jsxs)(`span`,{className:`lp-del-group`,children:[i>0&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt`,title:g(`dismissFinishedSubagentsScoped`,{n:i}),onClick:e=>{e.stopPropagation(),E(null),o({type:`dismiss_finished_subagents`,parentId:n.id})},children:g(`dismissFinishedOnly`,{n:i})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt danger`,title:g(`forceDismissTitle`,{n:s,m:a}),onClick:e=>{e.stopPropagation(),E(null),o({type:`dismiss_conversation`,id:n.id,force:!0})},children:g(`dismissForceAll`,{n:s})})]}):(0,X.jsx)(`button`,{type:`button`,className:`lp-del`,title:g(`dismissConversation`),onClick:t=>{t.stopPropagation(),E(e)},children:(0,X.jsx)(M,{})})})(),H(),n.isStreaming&&(0,X.jsx)(`span`,{className:`lp-row-stalled`,title:g(`streaming`),style:{position:`absolute`,right:28,top:`50%`,transform:`translateY(-50%)`}})]},n.id)})})()]},e.cwd))})]}),le.length>0&&!P&&!I&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:ue(`convs`,`sessions`),onDoubleClick:()=>ce({...ea}),title:g(`dragToResize`)}),(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${I?`collapsed`:``}`,style:I?void 0:{flex:`${ge(`sessions`)} 1 0px`},children:[W(g(`historySessions`),I,R,r.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-new-chat-action`,title:g(`newChatTip`),"aria-label":g(`newChat`),onClick:()=>{o({type:`new_chat`}),un()},children:(0,X.jsx)(se,{})})),!I&&(0,X.jsxs)(`div`,{className:`lp-section-body sessions-scroll`,children:[r.length===0&&(0,X.jsx)(`div`,{className:`panel-empty`,children:g(`noHistory`)}),r.map(e=>{let t=_===e.path;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>E(t=>t===`sess:${e.path}`?null:t),onContextMenu:t=>U(t,{id:e.path,kind:`history`,label:de(e)}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${t?`active`:``}`,title:e.path,onClick:()=>{D||t||o({type:`switch_session`,path:e.path})},children:[(0,X.jsx)(me,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[D===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:k,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>A(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=k.trim();t&&o({type:`rename_session`,path:e.path,name:t}),O(null)}else t.key===`Escape`&&O(null)},onBlur:()=>O(null)}):(0,X.jsx)(`span`,{className:`session-title`,children:de(e)}),D===e.path?null:(0,X.jsxs)(`span`,{className:`session-sub`,children:[t?g(`current`):g(`messageCount`,{n:e.messageCount}),e.source===`tui`&&(0,X.jsx)(`span`,{className:`session-src`,title:g(`tuiTip`),children:`TUI`})]})]}),(0,X.jsx)(`span`,{className:`session-time`,children:qi(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:t=>{t.stopPropagation(),E(null),A(e.name??``),O(e.path)},children:(0,X.jsx)(Ne,{})}),pe(`sess:${e.path}`,g(`deleteSession`),g(`deleteSessionConfirm`),()=>o({type:`delete_session`,path:e.path})),H()]},e.path)})]})]}),(0,X.jsx)(Ei,{open:C,currentCwd:S,pathCompletions:u??[],workspaceRoots:x,onClose:()=>w(!1),onSelectDirectory:e=>o({type:`set_cwd`,path:e}),onCreateProject:e=>o({type:`make_dir`,path:e,setAsCwd:!0})})]})});function aa(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 oa(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}}function sa(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 ca=null,la=new Set;function ua(){for(let e of la)e()}function da(e){let t=(e??``).trim();t&&(ca={name:t,status:`loading`},ua(),$({type:`get_tool_info`,name:t}))}function fa(){ca!==null&&(ca=null,ua())}function pa(e){ca!==null&&ca.name===e.name&&(ca=sa(e),ua())}function ma(e){return la.add(e),()=>{la.delete(e)}}function ha(){return ca}function ga(){return(0,f.useSyncExternalStore)(ma,ha,ha)}var _a=`__piWebUiHost`,va=e=>new Promise(t=>setTimeout(t,e));async function ya(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 va(100)}}function ba(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 va(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();return r&&!a(r)?!1:(s(n,t??{prompt:n}).catch(()=>{}),!0)},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>Ja(e)},compose(e){return Q()?dn({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=Array.isArray(t?.folders)?t.folders.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],i=Array.isArray(t?.roots)?t.roots.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],s=String(t?.cwd??``).trim(),c=[...new Set([...n,...i])],l=s||c[0]||``;if(!l)return{ok:!1,error:`openSession 需要 cwd / folders / roots(绝对路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let u=c.filter(e=>e!==l).slice(0,7),d=new Set([...e.listProjects?.()??[],...e.grantedPaths?.()??[]]);for(let t of[l,...u])if(!d.has(t)){if(!(e.confirm&&await e.confirm({path:t}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${t}`};e.grantPath?.(t)}if(e.getCwd()!==l&&(e.send({type:`set_cwd`,path:l}),!await r(()=>e.getCwd()===l)))return{ok:!1,error:`切换工作目录失败或超时:${l}`};(u.length>0||e.getWorkspaceRoots().length>0)&&e.send({type:`set_workspace_roots`,roots:u});let f=e.getConversationId()??void 0;if(t?.newChat!==!1){let t=f;e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank()),f=e.getConversationId()??void 0}let p=String(t?.model??``).trim();if(p){if(!a(p))return{ok:!1,error:`未知模型:${p}(先调 models.list() 取可用列表)`};await o(p),f=e.getConversationId()??f}let m=String(t?.prompt??``).trim();return m&&e.send({type:`prompt`,text:m}),{ok:!0,...f?{sessionId:f}:{}}},sessions:{list:()=>e.listSessions(),async open(t){let n=String(t??``).trim();if(!n)return{ok:!1,error:`sessions.open 需要一个会话 id(先调 list)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let i=e.listSessions().find(e=>e.id===n);if(!i)return{ok:!1,error:`找不到会话:${n}`};if(i.cwd&&i.cwd!==e.getCwd()){if(!new Set([...e.listProjects?.()??[],...e.grantedPaths?.()??[]]).has(i.cwd)){if(!(e.confirm&&await e.confirm({path:i.cwd}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${i.cwd}`};e.grantPath?.(i.cwd)}if(e.send({type:`set_cwd`,path:i.cwd}),!await r(()=>e.getCwd()===i.cwd))return{ok:!1,error:`切换工作目录失败或超时:${i.cwd}`}}let a=e.getConversationId();return i.kind===`running`?e.send({type:`switch_conversation`,id:i.id}):e.send({type:`switch_session`,path:i.id}),await r(()=>e.getConversationId()!==a)?{ok:!0,sessionId:e.getConversationId()??void 0}:{ok:!1,error:`切换会话超时:${i.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=ot();return new Promise(t=>{let a=setTimeout(()=>{no.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));no.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 Ta(Ca,String(e??``).trim(),t)},onTopbarAction(e,t){return Ta(Ca,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(Kt())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 ya(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(Da,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>Fa(String(e??``),t)},searchProviders:{register:e=>La(e),list:()=>Ra()},composerProviders:{register:e=>Ba(e),list:()=>Va()},onTheme:e=>Xa(e),onLocale:e=>Za(e),onViewChange:e=>Qa(e)}}function xa(e){try{let t=window;e?t[_a]=e:delete t[_a]}catch{}}var Sa=new Map,Ca=null;async function wa(e,t){let n=Ca;Ca=e;try{return await t()}finally{Ca=n}}function Ta(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=Sa.get(r);i||(i=new Set,Sa.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&Sa.delete(r)}}async function Ea(e,t,n,r){let i=i=>{let a=Sa.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{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 Da=`pi-web-ui:toast`,Oa=new Map,ka=!1;function Aa(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 ja(){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 Ma(e){try{if(ja())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=Oa.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function Na(){if(!ka)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,Ma),ka=!0}catch{}}function Pa(){if(!(Oa.size>0||!ka))try{window.removeEventListener(`keydown`,Ma)}catch{}finally{ka=!1}}function Fa(e,t){if(typeof t!=`function`)return()=>{};let n=Aa(e);if(!n)return()=>{};let r=Oa.get(n.combo);r||(r=new Set,Oa.set(n.combo,r));let i=r;return i.add(t),Na(),()=>{i.delete(t),i.size===0&&Oa.delete(n.combo),Pa()}}var Ia=new Map;function La(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 Ia.set(t,n),()=>{Ia.get(t)===n&&Ia.delete(t)}}function Ra(){return[...Ia.values()].map(e=>({id:e.id,label:e.label}))}var za=new Map;function Ba(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 za.set(t,n),()=>{za.get(t)===n&&za.delete(t)}}function Va(){return[...za.values()].map(e=>({id:e.id,label:e.label}))}function Ha(e){return za.get(String(e??``))}function Ua(e){return Ia.get(String(e??``))}var Wa=new Set,Ga=new Set,Ka=new Set,qa=new Set;function Ja(e){return qa.add(e),()=>{qa.delete(e)}}function Ya(e){for(let t of[...qa])try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function Xa(e){return typeof e==`function`?(Wa.add(e),()=>{Wa.delete(e)}):()=>{}}function Za(e){return typeof e==`function`?(Ga.add(e),()=>{Ga.delete(e)}):()=>{}}function Qa(e){return typeof e==`function`?(Ka.add(e),()=>{Ka.delete(e)}):()=>{}}function $a(e){let t=String(e??``);for(let e of[...Wa])try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function eo(e){let t=String(e??``);for(let e of[...Ga])try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function to(e){let t=String(e??``);for(let e of[...Ka])try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var no=new Map;function ro(e){let t=no.get(e.requestId);if(t){if(no.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 io=`modulepreload`,ao=function(e){return`/`+e},oo={},so=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=ao(t,n),t=s(t),t in oo)return;oo[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`:io,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)})},co=`pi-web-ui:plugin-data`;function lo(e,t){window.dispatchEvent(new CustomEvent(co,{detail:{pluginId:e,payload:t}}))}function uo(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(co,t),()=>window.removeEventListener(co,t)}var fo=new Map,po=new Set,mo=new Set,ho=new Set,go=new Set,_o=-1;function vo(){return[...fo.values()]}function yo(){let e=vo();for(let t of mo)t(e)}function bo(){let e=[...ho];for(let t of go)t(e)}function xo(e){return go.add(e),e([...ho]),()=>go.delete(e)}async function So(e,t){ho.delete(e.id),wo.set(e.id,(wo.get(e.id)??0)+1),bo();let n=await Oo(e,t);return yo(),n}function Co(e){return mo.add(e),e(vo()),()=>mo.delete(e)}var wo=new Map;function To(e,t){let n=wo.get(e)??0;return St(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function Eo(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>wa(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var Do=Eo(e=>so(()=>import(e),[]));async function Oo(e,t){try{let n=(await Do(e.id,To(e.id,t))).default;return n&&typeof n.mount==`function`?(fo.set(e.id,{info:e,module:n}),!0):e.preload?(po.add(e.id),!0):(ho.add(e.id),bo(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return ho.add(e.id),bo(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function ko(e,t){if(fo.has(e.id)||po.has(e.id))return!0;if(ho.has(e.id)||!e.hasClient)return!1;let n=await Oo(e,t);return yo(),n}async function Ao(e,t){t!==_o&&(_o=t,fo.clear(),po.clear(),ho.clear(),wo.clear(),bo());let n=new Set(e.map(e=>e.id));for(let e of[...fo.keys()])n.has(e)||fo.delete(e);for(let e of[...po])n.has(e)||po.delete(e);for(let e of[...ho])n.has(e)||ho.delete(e);bo(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!fo.has(e.id)&&!po.has(e.id)&&!ho.has(e.id)).map(e=>Oo(e,t))),yo()}function jo(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>uo((n,r)=>{n===e&&t(r)})}}var Mo=[`debug`,`info`,`warn`,`error`];function No(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function Po(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function Fo(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`&&Mo.includes(String(e.level)))}var Io=new Map,Lo=new Set;function Ro(){for(let e of[...Lo])try{e()}catch{}}function zo(e){return Lo.add(e),()=>Lo.delete(e)}function Bo(e){return(Io.get(e)??[]).map(e=>({...e}))}function Vo(e,t){return Fo(t)?(Io.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),Ro(),!0):!1}function Ho(){return{flows:[],results:{}}}function Uo(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 Wo(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:Uo(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:Uo(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 Go=`pi-web-ui:lang`;function Ko(){try{return(localStorage.getItem(Go)??``).trim()}catch{return``}}var qo=`pi-web-ui:locale`,Jo=2e5,Yo=2e5,Xo=`LIVE_OMIT`,Zo={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 Qo(){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>Yo?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 $o(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 es(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 ts(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`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!==19};case`snapshot`:return{...e,ready:!0,state:t.state,activeConversationId:t.state.conversationId,liveOutputs:$o(e.liveOutputs,t.state),toolStatuses:es(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,activeConversationId:i.conversationId,liveOutputs:$o(e.liveOutputs,i),toolStatuses:es(e.toolStatuses,i)}}case`tool_delta`:{let n=(e.liveOutputs.get(t.toolCallId)?.text??``)+t.delta,r=n.length>Jo?`…[${Xo}:${n.length-Jo}]…\n`+n.slice(n.length-Jo):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:aa(n,t.msg)}}case`tool_status`:return{...e,toolStatuses:new Map(e.toolStatuses).set(t.status.toolCallId,t.status)};case`notice`:return{...e,notices:[...e.notices,t.notice].slice(-6)};case`dismiss_notice`:return{...e,notices:e.notices.filter(e=>e.id!==t.id)};case`sessions`:return{...e,sessions:t.sessions};case`conversations`:return{...e,conversations:t.conversations,elsewhere:t.elsewhere??[],activeConversationId:t.activeId};case`projects`:return{...e,projects:t.projects};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=Wo({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`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};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`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`settings`:return{...e,settings:t.settings};case`bg_servers`:return{...e,bgServers:t.servers};case`scheduler_tasks`:return{...e,schedulerTasks:t.tasks};case`plugins`:return{...e,plugins:t.plugins,pluginsEpoch:t.epoch};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 n=e.pluginJobs[t.job.jobId],r=t.line?[...n?.lines??[],t.line].slice(-40):n?.lines??[],i={...n,...t.job,lines:r,startedAt:n?.startedAt??Date.now()};return{...e,pluginJobs:{...e.pluginJobs,[t.job.jobId]:i}}}case`plugin_catalog_sync_result`:return{...e,catalogSync:{...t.result,receivedAt:Date.now()}};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};default:return e}}var ns=`pi-web-client-id`,rs=null;function is(){if(rs)return rs;let e=null;try{e=sessionStorage.getItem(ns),e||(e=ot(),sessionStorage.setItem(ns,e))}catch{e??=ot()}return rs=e,e}var as=`pi-web-last-cwd`;function os(){try{return localStorage.getItem(as)}catch{return null}}function ss(e){try{localStorage.setItem(as,e)}catch{}}function cs(){return Et(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${St(`/ws`)}`)}function ls(){let[e,t]=(0,f.useReducer)(ts,{status:`connecting`,ready:!1,state:null,hostMetrics:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:[],conversations:[],elsewhere:[],activeConversationId:``,projects:[],files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},defaultModel:null,providerOAuthFlows:[],providerOAuthResults:Ho().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,widgets:[],statuses:[],dialog:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:Zo,bgServers:[],schedulerTasks:[],settings:null,fetchModelsResult:null,enrichModelsResult:null,enrichModelsProgress:null,refreshProviderResult:null,refreshBuiltinResult:null,appendBuiltinResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginCatalog:[],pluginCatalogEpoch:0,pluginJobs:{},catalogSync:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,dshPresets:null,dshPermission:null,protocolMismatch:!1}),n=(0,f.useRef)(null),r=(0,f.useRef)(Qo()),i=(0,f.useRef)(0),a=(0,f.useRef)(null),o=(0,f.useRef)(!0),s=(0,f.useRef)(0),c=(0,f.useRef)(0),l=(0,f.useRef)(new Map),u=(0,f.useRef)(null),d=(0,f.useRef)(!1),p=(0,f.useRef)(null),m=(0,f.useRef)(new Set),h=(0,f.useRef)(`live`),g=()=>{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)&&g()}n.set(e,t)},v=(0,f.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]),y=(0,f.useCallback)(e=>{let r=n.current;if(r&&r.readyState===WebSocket.OPEN){if(e.type===`check_updates_all`&&e.force===!0&&t({type:`updates_check_started`}),r.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(m.current.add(e.id),m.current.size>64){let e=m.current.values().next().value;e!==void 0&&m.current.delete(e)}h.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,f.useCallback)((e,n)=>{let r=oa({current:O.current.chat.question,source:h.current,snapshot:e,answered:m.current,activeConversationId:n});r.changed&&(h.current=r.source,t({type:`question`,question:r.question}))},[]);bi(y);let x=(0,f.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(cs());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:is(),locale:Ko()})))},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!==`20260922T01193`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}di({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}),m.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;(!e||e.conversationId!==a.conversationId||e.rev!==a.baseRev)&&g(),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`notice`:{let e=++c.current;t({type:`notice`,notice:{id:e,level:a.level,text:a.text,textEn:a.textEn}});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`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`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`:pa(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});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`question_pending`:h.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`question_retracted`:{let e=O.current.chat.question;if(e&&e.id===a.id){if(m.current.add(a.id),m.current.size>64){let e=m.current.values().next().value;e!==void 0&&m.current.delete(e)}h.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`settings_state`:t({type:`settings`,settings:a.settings});break;case`bg_servers`:t({type:`bg_servers`,servers:a.servers});break;case`scheduler_tasks`:t({type:`scheduler_tasks`,tasks:a.tasks});break;case`plugins`:t({type:`plugins`,plugins:a.plugins,epoch:a.epoch});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_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_catalog_sync_result`:ro(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`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`:Vo(a.pluginId,a.payload)||lo(a.pluginId,a.payload)}},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,f.useEffect)(()=>{let e=e=>{let t=e.detail??Ko();t&&y({type:`set_locale`,locale:t})};return window.addEventListener(qo,e),()=>window.removeEventListener(qo,e)},[y]),(0,f.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);return()=>{o.current=!1,clearInterval(e),a.current&&=(clearTimeout(a.current),null),n.current?.close(),n.current=null}},[x]),(0,f.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=os();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}p.current!==t&&(p.current=t,ss(t))}},[e.state?.cwd,y]),(0,f.useEffect)(()=>{di({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,f.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,f.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,f.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,f.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,f.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,f.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,f.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}var us=209715200,ds=/windows/i.test(navigator.userAgent),fs=/[<>:"/\\|?*\u0000-\u001f]/g,ps=/[. ]+$/,ms=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function hs(e){let t=e.replace(fs,`_`).replace(ps,``);return t?ms.test(t)?`_${t}`:t:`_`}function gs(e,t=!0){return Et(St(`/api/file?${new URLSearchParams({clientId:is(),path:e,...t?{download:`1`}:{}})}`))}async function _s(e,t){let n=ds?hs(t):t;try{let t=await fetch(gs(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`)>us)return window.location.assign(gs(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?ys(r,n):bs(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function vs(e,t){let n=ds?hs(t):t;return window.showSaveFilePicker&&window.isSecureContext?ys(e,n):bs(e,n)}async function ys(e,t){let n,r=window.showSaveFilePicker;if(!r)return bs(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:bs(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 bs(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 xs(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 Ss(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function Cs({text:e}){let t=(0,f.useRef)(null),n=(0,f.useRef)(null),[r,i]=(0,f.useState)(!1),[a,o]=(0,f.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,f.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=xs(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,f.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=xs(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,D.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 ws=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function Ts(e,t={}){let n={archive:St(`/api/file-transfer/archive`),upload:St(`/api/file-transfer/upload`)},r=new URL(Et(`${n[e]}?${new URLSearchParams({clientId:is(),...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 Es(e,t,n){let r=await fetch(Ts(`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 vs(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function Ds(){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 Os(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=Ts(`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 ks({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,f.useState)(e.dir),[o,s]=(0,f.useState)(`skip`),[c,l]=(0,f.useState)([]),[u,d]=(0,f.useState)(0),p=(0,f.useRef)(null),[m,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(``),v=(0,f.useRef)(null);(0,f.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 Ds();e?l(e):p.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),h(!0),_(``);try{e.action===`upload`?await Os(e.dir,c,d):await Es(e.action,e.path,{destination:i,policy:o}),n(),t()}catch(e){_(e instanceof Error?e.message:String(e)),n()}finally{h(!1)}}return(0,D.createPortal)((0,X.jsx)(`dialog`,{ref:v,className:`file-transfer-dialog`,"aria-labelledby":`file-transfer-title`,onCancel:e=>{e.preventDefault(),m||t()},children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),x()},children:[(0,X.jsx)(`h3`,{id:`file-transfer-title`,children:y}),(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:m,onChange:e=>a(e.target.value)})]}),(0,X.jsxs)(`label`,{children:[r(`fileConflictPolicy`),(0,X.jsxs)(`select`,{value:o,disabled:m,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:m,onClick:()=>void b(),children:r(`fileChooseFolder`)}),(0,X.jsx)(`input`,{type:`file`,"aria-label":y,multiple:!0,hidden:!0,disabled:m,ref:e=>{p.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]})]}),g&&(0,X.jsx)(`p`,{role:`alert`,children:r(`fileTransferFailed`,{error:g})}),(0,X.jsxs)(`div`,{className:`file-transfer-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:m,onClick:t,children:r(`cancel`)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:m||e.action===`upload`&&c.length===0,children:m?r(`fileTransferBusy`):y})]})]})}),document.body)}function As(e){return e instanceof Error?e.message:String(e)}function js(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 Ms({plugin:e,epoch:t,send:n,className:r}){let i=(0,f.useRef)(null),{locale:a}=Ut(),o=Z(),[s,c]=(0,f.useState)(null),l=(0,f.useRef)(n);(0,f.useEffect)(()=>{l.current=n},[n]),(0,f.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 ko(e,t),r)return;let i=await wa(e.id,()=>so(()=>import(To(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,jo(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:As(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:js(s,e.name,a,o)})]})}function Ns(e){return`pi-web-ui:${e}:tab`}function Ps(e,t){try{let n=localStorage.getItem(Ns(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function Fs(e,t){try{localStorage.setItem(Ns(e),t)}catch{}}function Is(e){return e.length>0&&!/[a-z]/i.test(e)}function Ls(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function Rs({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,f.useId)(),[s,c]=(0,f.useState)(()=>Ps(e,t)??t[0]?.id??``),l=(0,f.useRef)([]),u=(0,f.useRef)(``),d=t.findIndex(e=>e.id===s),p=d>=0?t[d]:t[0],m=p?t.indexOf(p):-1;(0,f.useEffect)(()=>{if(!p)return;s!==p.id&&c(p.id);let t=`${e}:${p.id}`;u.current!==t&&(u.current=t,Fs(e,p.id))},[p,s,e]);let h=t=>{c(t.id),u.current=`${e}:${t.id}`,Fs(e,t.id)},g=(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(),h(a),l.current[i]?.focus())};if(!p)return null;let _=`${o}-panel-${m}`,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===m;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,id:`${o}-tab-${t}`,className:n?`slot-tab active`:`slot-tab`,title:e.hint??Ls(e),"aria-selected":n,"aria-controls":`${o}-panel-${t}`,tabIndex:n?0:-1,ref:e=>{l.current[t]=e},onClick:()=>h(e),onKeyDown:e=>g(e,t),children:[e.iconSvg?(0,X.jsx)(sr,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&Is(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:Ls(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-${m}`,children:p.pluginPage?(0,X.jsx)(Ms,{plugin:p.pluginPage.plugin,epoch:n,send:r}):p.element??null})]})}var zs=`@root`,Bs=`pi-web-ui:rp-sizes`,Vs={files:4,widgets:1},Hs=120,Us=56;function Ws(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var Gs=`files`,Ks=[],qs=()=>{};function Js(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function Ys(e){return e===zs||e===`/`||/^[A-Za-z]:$/.test(e)}function Xs(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var Zs=(0,f.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:p,send:m}){let h=Z(),g=d??Ks,_=hi(`cwd`),v=hi(`workspaceRoots`),y=hi(`homeDir`),b=hi(`desktopDir`),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(!1),D=(0,f.useRef)(null),O=(0,f.useRef)(null),[k,A]=(0,f.useState)(()=>{try{return Wi(localStorage.getItem(Bs),Vs)}catch{return{...Vs}}});(0,f.useEffect)(()=>{try{localStorage.setItem(Bs,JSON.stringify(k))}catch{}},[k]);let j=n.some(e=>e.lines.length>0),N=(0,f.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-Ws(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=Gi({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:Hs,minBelowPx:Us});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]),P=(0,f.useRef)(null),F=(0,f.useRef)(0),I=(0,f.useCallback)(e=>{P.current=e,e&&(e.scrollTop=F.current)},[]),[L,R]=(0,f.useState)(null),ee=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>{ee.current&&clearTimeout(ee.current)},[]);let te=(0,f.useCallback)(e=>{R(e),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>R(null),1200)},[]),ne=e=>{try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}},z=(0,f.useCallback)((e,t)=>{if(!e)return;let n=()=>te(t),r=()=>o(`error`,h(`slashCopyFailed`)),i=navigator;i.clipboard?.writeText?i.clipboard.writeText(e).then(n,()=>{ne(e)?n():r()}):ne(e)?n():r()},[te,o,h]),B=(0,f.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},[_]),V=(0,f.useCallback)(e=>!e||e===zs?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),re=104857600,ie=(0,f.useCallback)((e,t)=>{for(let n of t){if(n.size>re){o(`warning`,h(`fileTooLarge`,{name:n.name,size:re/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,h]),H=(0,f.useRef)(null),[U,ae]=(0,f.useState)(null),oe=(0,f.useRef)(null),ce=(0,f.useCallback)(()=>{let e=H.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),le=(0,f.useCallback)(()=>{oe.current&&(oe.current.value=``),oe.current?.click()},[]),[ue,de]=(0,f.useState)(null),[fe,pe]=(0,f.useState)(null),[W,me]=(0,f.useState)(``),[G,he]=(0,f.useState)(null),[_e,ve]=(0,f.useState)(``),ye=(0,f.useCallback)((e,t)=>{_s(e,t).then(e=>{e.ok||e.cancelled||o(`error`,h(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?h(`fileNotFoundShort`):e.error}))})},[o,h]),be=(0,f.useCallback)(()=>{let e=H.current?.target;e&&e.kind!==`list`&&!Ys(e.id)&&(he(null),me(e.label),pe(e.id))},[]),xe=(0,f.useCallback)(()=>{if(!fe)return;let e=W.trim();pe(null),e&&r({type:`file_rename`,path:fe,newName:e})},[fe,W,r]),Se=(0,f.useCallback)(e=>{let t=H.current?.dir??x;pe(null),ve(``),he({dir:t,kind:e})},[x]),Ce=(0,f.useCallback)(()=>{if(!G)return;let e=_e.trim();he(null),e&&r({type:`file_create`,dir:G.dir,name:e,kind:G.kind})},[G,_e,r]),q=(e,t,n,r)=>(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:e,placeholder:h(`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}),we=(0,f.useCallback)(()=>{let e=H.current?.target;e&&e.kind!==`list`&&!Ys(e.id)&&window.confirm(h(`fileDeleteConfirm`,{name:e.label}))&&(ue?.src===e.id&&de(null),fe===e.id&&pe(null),r({type:`file_delete`,path:e.id}))},[r,h,ue,fe]),Te=(0,f.useCallback)(()=>{let e=H.current?.target;e&&e.kind!==`list`&&!Ys(e.id)&&r({type:`file_copy`,src:e.id,destDir:Js(e.id)})},[r]),J=(0,f.useCallback)(e=>{let t=H.current?.target;t&&t.kind!==`list`&&!Ys(t.id)&&de({src:t.id,cut:e})},[]),Ee=(0,f.useCallback)(()=>{if(!ue)return;let e=H.current?.dir??x;ue.cut?(r({type:`file_copy`,src:ue.src,destDir:e,move:!0}),de(null)):r({type:`file_copy`,src:ue.src,destDir:e})},[ue,r,x]),Y=(0,f.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[ke,Ae]=(0,f.useState)(!1);(0,f.useEffect)(()=>{if(!ke)return;let e=e=>{e.target?.closest(`.root-picker`)||Ae(!1)},t=e=>{e.key===`Escape`&&Ae(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[ke]);let je=(0,f.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),Me=(0,f.useCallback)(()=>{let e=H.current?.target;if(!e||e.kind!==`dir`)return;let t=V(e.id);t&&!v.includes(t)&&je([...v,t])},[v,V,je]),Ne=(0,f.useCallback)(e=>{ie(H.current?.dir??x,Array.from(e.target.files??[]))},[ie,x]),Fe=(0,f.useCallback)(e=>{let t=H.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`;ae({action:n,path:B(t.id),dir:B(n===`upload`?H.current?.dir??x:Js(t.id))});break}case`host:file-open-project`:ce();break;case`host:file-upload`:le();break;case`host:file-add-root`:Me();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&Ze(t.id);break;case`host:file-download`:t?.kind===`file`&&ye(t.id,t.label);break;case`host:file-reveal`:t&&t.kind!==`list`&&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-inline`:t?.kind===`file`&&i(t.id,t.label,`inline`);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`:Se(`file`);break;case`host:file-new-dir`:Se(`dir`);break;case`host:file-paste`:Ee();break;case`host:file-rename`:be();break;case`host:file-duplicate`:Te();break;case`host:file-cut`:J(!0);break;case`host:file-copy`:J(!1);break;case`host:file-copy-name`:t&&t.kind!==`list`&&z(t.label,`name:${t.id}`);break;case`host:file-copy-path`:t&&t.kind!==`list`&&z(B(t.id),`path:${t.id}`);break;case`host:file-copy-rel`:t&&t.kind!==`list`&&z(t.id,`rel:${t.id}`);break;case`host:file-refresh`:Y();break;case`host:file-delete`:we()}},[ce,x,le,Me,a,i,z,B,ye,Se,Ee,be,Te,J,Y,we]),Ie=(0,f.useCallback)((e,t)=>{let n=t.kind===`dir`?V(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&&Ys(t.id),l=!s&&Xs(t.id),d=x===zs,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&&ws(t.label)?e:{...e,hidden:!0};case`host:file-upload`:return d?{...e,hidden:!0}:{...e,label:r.dir===x?h(`uploadToCurrentDir`):h(`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-inline`:case`host:file-attach-ref`:return a?e:{...e,hidden:!0};case`host:file-reveal`:return s?{...e,hidden:!0}:e;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&&ue?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}});ti(f).length!==0&&(e.preventDefault(),e.stopPropagation(),H.current=r,Wr({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:Fe}))},[u,x,V,h,Fe,_,v,ue]),Re=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),ze=(0,f.useCallback)(()=>{P.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),P.current?.classList.remove(`drop-root`)},[]),He=(0,f.useCallback)(e=>{if(ze(),e==null)return;let t=P.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):P.current?.classList.add(`drop-root`)},[ze]),Ue=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Ge=(0,f.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),qe=(0,f.useRef)(0),Je=(0,f.useRef)(void 0),Ye=(0,f.useCallback)((e,t)=>{let n=++qe.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||qe.current===n&&E(!1)},[r]),Xe=(0,f.useCallback)(e=>{let t=v.filter(t=>t!==e);je(t),(x===e||x.startsWith(`${e}/`))&&Ye(``)},[v,je,x,Ye]);(0,f.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,f.useEffect)(()=>{if(_!==Je.current){Je.current=_,Ye(``,{silent:!0});return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&Ye(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,Ye]),(0,f.useEffect)(()=>{t&&t.path===x&&Ye(x,{silent:!0})},[t,x,Ye]);let Ze=e=>Ye(e),Qe=()=>{e?.parent!==null&&e?.parent!==void 0&&Ye(e.parent)},$e=(()=>{if(x===``||x===zs)return[];let e=x.split(`/`).filter(e=>!!e&&e!==zs);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(`/`)}))})(),et=[];for(let e of l??[]){if(e.source===`host`||e.hidden||e.kind===`divider`)continue;let t=g.find(t=>t.id===e.source.slice(7));t&&et.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let tt=(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:h(`collapsePanel`),onClick:c,children:(0,X.jsx)(Ve,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:j?`${k.files} 1 0`:`1 1 0`,minHeight:j?Hs:0},children:(0,X.jsx)(Rs,{storageKey:`rightpanel`,epoch:p??0,send:m??qs,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===Gs?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...tt?[]:[{id:Gs,label:h(`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:()=>Ye(``),children:h(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===zs?`active`:``}`,title:h(`computer`),onClick:()=>Ye(zs),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:h(`homeDir`),onClick:()=>Ye(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:h(`desktopDir`),onClick:()=>Ye(b),children:`🖥️`}),(0,X.jsx)(Cs,{text:h(`filesHelp`)}),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":ke,title:h(`workspaceRoots`),onClick:()=>Ae(e=>!e),children:[(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:h(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),ke&&(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:()=>{Ae(!1),Ye(``)},children:[h(`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:()=>{Ae(!1),Ye(e)},children:(0,X.jsx)(`span`,{className:`root-picker-path`,children:e})}),(0,X.jsx)(`button`,{type:`button`,className:`root-picker-remove`,title:h(`removeWorkspaceRoot`),"aria-label":h(`removeWorkspaceRoot`),onClick:()=>Xe(e),children:(0,X.jsx)(M,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:h(`workspaceRootsHint`)})]})]}),$e.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(We,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>Ye(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:I,className:`panel-body`,onScroll:e=>{F.current=e.currentTarget.scrollTop},onContextMenu:e=>Ie(e,{id:x,kind:`list`,label:x===``?h(`rootDir`):x===zs?h(`computer`):x}),onDragOver:e=>{Re(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Ge(),He(Ue(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||ze()},onDrop:e=>{if(ze(),!Re(e))return;e.preventDefault(),e.stopPropagation(),Ge();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,h(`foldersNotSupported`));return}ie(Ue(e.target),t)},onDragEnd:ze,children:[(0,X.jsx)(`input`,{ref:oe,type:`file`,multiple:!0,hidden:!0,onChange:Ne}),U&&(0,X.jsx)(ks,{request:U,onClose:()=>ae(null),onComplete:Y}),G&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[G.kind===`dir`?(0,X.jsx)(De,{className:`file-icon`}):(0,X.jsx)(Oe,{className:`file-icon`}),q(_e,ve,Ce,()=>he(null))]}),T&&(0,X.jsx)(`div`,{className:`panel-empty`,children:h(`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:Qe,children:[(0,X.jsx)(De,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:`..`})]}),e.entries.map(e=>e.type===`dir`?(0,X.jsxs)(`div`,{className:`file-item dir${ue?.cut&&ue.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Ie(t,{id:e.path,kind:`dir`,label:e.name}),children:[fe===e.path?q(W,me,xe,()=>pe(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>Ze(e.path),children:[(0,X.jsx)(De,{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":h(`linkFolderTip`),"aria-label":h(`linkFolderTip`),onClick:()=>i(e.path,e.name,`reference`,!0),children:(0,X.jsx)(K,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>z(e.name,`name:${e.path}`),children:L===`name:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Le,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>z(B(e.path),`path:${e.path}`),children:L===`path:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Be,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${ue?.cut&&ue.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Ie(t,{id:e.path,kind:`file`,label:e.name}),children:[fe===e.path?q(W,me,xe,()=>pe(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-name`,title:`${e.path} — ${h(`previewFile`)}`,onClick:()=>a(e.path,e.name),children:[(0,X.jsx)(Oe,{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":h(`downloadFile`),onClick:()=>ye(e.path,e.name),children:(0,X.jsx)(Pe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach inline`,"data-tip":h(`attachInlineTip`),onClick:()=>i(e.path,e.name,`inline`),children:(0,X.jsx)(se,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":h(`referenceTip`),"aria-label":h(`referenceTip`),onClick:()=>i(e.path,e.name,`reference`),children:(0,X.jsx)(K,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>z(e.name,`name:${e.path}`),children:L===`name:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Le,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>z(B(e.path),`path:${e.path}`),children:L===`path:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Be,{})})]},e.path)),e.truncated&&(0,X.jsx)(`div`,{className:`panel-empty files-truncated`,children:h(`filesTruncated`)})]}),!T&&!e&&(0,X.jsx)(`div`,{className:`panel-empty`,children:h(`noFiles`)})]})]})}],...et])})}),j&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:N,onDoubleClick:()=>A({...Vs}),title:h(`dragToResize`)}),j&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:Us},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:h(`widgetExpand`),onClick:()=>w(e.key),children:[(0,X.jsx)(`span`,{children:e.key}),(0,X.jsx)(ge,{})]}),(0,X.jsx)(`pre`,{className:`widget-lines`,children:e.lines.join(`
327
327
  `)})]},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:h(`close`),onClick:()=>w(null),children:(0,X.jsx)(M,{})})]}),(0,X.jsx)(`pre`,{className:`widget-expand-lines`,children:e.lines.join(`
328
328
  `)})]})}):null})()]})});function Qs(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}}function $s(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,[i,a]=(0,f.useState)(!1),o=(0,f.useRef)(null),s=(0,f.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,f.useCallback)(()=>{s(),a(!1)},[s]);return(0,f.useEffect)(()=>()=>{s()},[s]),{copied:i,copy:(0,f.useCallback)(async e=>{let i=!1;try{typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`?(await navigator.clipboard.writeText(e),i=!0):i=Qs(e)}catch(t){i=Qs(e),!i&&r&&r(t)}return i&&(a(!0),s(),o.current=setTimeout(()=>{a(!1),o.current=null},t),n?.(e)),i},[t,n,r,s]),reset:c}}var ec=(0,f.memo)(function({text:e}){let t=Z(),{copied:n,copy:r}=$s({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)(Ke,{}):(0,X.jsx)(Le,{})}):null});function tc(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
329
329
  `).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,f.createElement)(n.type,i)]]:a.map(e=>[(0,f.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function nc(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(nc).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return nc(t?.children)}return``}function rc(e){let t=Array.isArray(e)?e[0]:e;return!t||typeof t!=`object`||!(`props`in t)?null:t}function ic(e){let t=rc(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 ac=`pi-web-ui:plugin-data`,oc=new Map,sc=new Map,cc=new Set,lc=-1,uc=0,dc=new Set;function fc(){uc++;for(let e of dc)e()}function pc(e){return dc.add(e),()=>{dc.delete(e)}}function mc(){return uc}var hc=null;function gc(e){hc=e}function _c(e,t){t!==lc&&(lc=t,sc.clear(),cc.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!==oc.size;if(!r){for(let[e,t]of n)if(oc.get(e)!==t){r=!0;break}}if(r){for(let e of sc.keys())n.has(e)||sc.delete(e);for(let e of cc)n.has(e)||cc.delete(e);oc=n,fc()}}async function vc(e,t){let n=oc.get(e);if(!n)return null;let r=sc.get(e);if(!r&&!cc.has(e))try{let t=(await so(()=>import(St(`/plugins/${encodeURIComponent(n)}/client/entry.mjs?e=${lc}`)),[])).default?.renderers?.[e];typeof t==`function`?(r={pluginId:n,renderer:t},sc.set(e,r)):(cc.add(e),console.error(`[plugin:${n}] entry.mjs 未提供 renderers["${e}"]`))}catch(t){cc.add(e),console.error(`[plugin:${n}] renderer 加载失败(${e}):`,t)}if(!r)return null;let i={pluginId:r.pluginId,send:e=>{hc?.({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(ac,t),()=>window.removeEventListener(ac,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 yc(e){return oc.has(e)}var bc=new Map,xc=new Map,Sc=new Set,Cc=-1;function wc(e,t){t!==Cc&&(Cc=t,xc.clear(),Sc.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[...bc.keys()])n.has(e)||bc.delete(e);for(let[e,t]of n)bc.set(e,t);for(let e of xc.keys())n.has(e)||xc.delete(e);for(let e of Sc)n.has(e)||Sc.delete(e)}function Tc(e){return bc.has(e)}async function Ec(e){let t=bc.get(e);if(!t)return null;let n=xc.get(e);if(!n&&!Sc.has(e))try{let r=(await so(()=>import(St(`/plugins/${encodeURIComponent(t)}/client/entry.mjs?e=${Cc}`)),[])).default?.messageWidgets?.[e];typeof r==`function`?(n={pluginId:t,renderer:r},xc.set(e,n)):(Sc.add(e),console.error(`[plugin:${t}] entry.mjs 未提供 messageWidgets["${e}"]`))}catch(n){Sc.add(e),console.error(`[plugin:${t}] messageWidget 加载失败(${e}):`,n)}return n?.renderer??null}var Dc=`pi-web-ui:theme`,Oc=`dark`,kc=`theme-stylesheet`,Ac=`pi-web-ui:theme-change`;function jc(){try{let e=localStorage.getItem(Dc);if(e&&e!==Oc)return e}catch{}return null}function Mc(e){try{e?localStorage.setItem(Dc,e):localStorage.removeItem(Dc)}catch{}}function Nc(e){let t=document.getElementById(kc);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(Ac));return}t||(t=document.createElement(`link`),t.id=kc,t.rel=`stylesheet`,document.head.appendChild(t)),t.href=St(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(Ac))}async function Pc(){try{let e=await fetch(Et(St(`/api/themes`)));if(!e.ok)return[];let t=await e.json();return Array.isArray(t.themes)?t.themes:[]}catch{return[]}}function Fc(){let[e,t]=(0,f.useState)([]),[n,r]=(0,f.useState)(()=>jc());(0,f.useEffect)(()=>{let e=!1;return Pc().then(n=>{e||t(n)}),()=>{e=!0}},[]);let i=(0,f.useCallback)(()=>{Pc().then(t)},[]);return(0,f.useEffect)(()=>{Nc(n),Mc(n)},[n]),{themes:e,theme:n,switchTheme:e=>r(e===Oc?null:e),reloadThemes:i}}function Ic(){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 Lc({lang:e,code:t}){let n=(0,f.useRef)(null),r=(0,f.useRef)(null),i=(0,f.useRef)(0),a=(0,f.useRef)(new WeakMap),[o,s]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let e=()=>{let e=++i.current,t=r.current;t&&(t.dispatchEvent(new CustomEvent(Ac)),a.current.set(t,e))};return window.addEventListener(Ac,e),()=>window.removeEventListener(Ac,e)},[]),(0,f.useEffect)(()=>{let n=!1,r=i.current;return s(null),vc(e,t).then(e=>{n||(e&&a.current.set(e,r),s(e))}),()=>{n=!0}},[e,t]),(0,f.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(Ac)),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)(ec,{text:t}),(0,X.jsx)(`pre`,{children:(0,X.jsx)(`code`,{children:t})})]})}var Rc=[c,o],zc=[c,a,o],Bc=[[s,{strict:!1,throwOnError:!1}],[l,{detect:!0,ignoreMissing:!0}]];function Vc({text:e,rawHtml:t=!1,hardBreaks:n=!1}){let r=t?[d,...Bc]:Bc;return(0,X.jsx)(u,{remarkPlugins:n?zc:Rc,rehypePlugins:r,components:{pre:Wc,a:Uc},children:e})}var Hc=(0,f.memo)(function({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,X.jsx)(`div`,{className:`md`,children:(0,X.jsx)(Vc,{text:e,rawHtml:t,hardBreaks:n})})});function Uc({href:e,children:t,...n}){let r=String(e??``);return/^(https?:|mailto:|tel:)/i.test(r)?(0,X.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer noopener`,...n,children:t}):(0,X.jsx)(`a`,{href:e,...n,children:t})}function Wc({children:e,...t}){(0,f.useSyncExternalStore)(pc,mc,mc);let n=ic(e);return n&&yc(n)?(0,X.jsx)(Lc,{lang:n,code:nc(e)}):(0,X.jsx)(Gc,{children:e,...t})}function Gc({children:e,...t}){let n=tc(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)(ec,{text:Kc(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 Kc(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Kc).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Kc(t?.children)}return``}function qc({type:e,code:t,children:n}){let r=(0,f.useRef)(null),[i,a]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=!1;if(a(null),Tc(e))return Ec(e).then(async r=>{if(!n&&r)try{let i=await r(t,{pluginId:bc.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,f.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 Jc=/^\s{0,3}(`{3,}|~{3,})/,Yc=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Xc(e){return e.trim()===``}function Zc(e){let t=Jc.exec(e);return t?t[1]:null}function Qc(e){let t=e.split(`
@@ -361,4 +361,4 @@ It only opens after you confirm.`,settingsExtensions:`Extensions`,settingsUiPlug
361
361
  `).length)),autoFocus:r,placeholder:a(`promptOverridePlaceholder`),value:t,onFocus:t=>{w.current=e,D(e);let r=t.currentTarget;r.value&&r.value===n&&r.setSelectionRange(r.value.length,r.value.length)},onBlur:()=>{w.current===e&&(w.current=null);let t=x[e]??``;if(t.trim()&&t===n){rr(e);return}nr(e),t.trim()||D(null)},onChange:t=>S(n=>({...n,[e]:t.target.value}))}),(0,X.jsxs)(`div`,{className:`override-edit-foot`,children:[(0,X.jsxs)(`div`,{className:`override-edit-foot-head`,children:[(0,X.jsx)(`span`,{className:`set-muted`,children:a(`promptSourceRefLabel`)}),i&&(0,X.jsx)(`button`,{type:`button`,className:`source-default-toggle`,onClick:()=>ir(e),children:O[e]?a(`promptSourceCollapse`):a(`promptSourceExpand`)})]}),n.trim()?(0,X.jsx)(`pre`,{className:`source-default-text${i?O[e]?` expanded`:` clamped`:``}`,children:n}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:a(`promptSourceDefaultEmpty`)}),!t.trim()&&n.trim()&&(0,X.jsx)(`button`,{type:`button`,className:`override-seed-btn`,title:a(`promptSourceSeedTip`),onClick:()=>ar(e,n),children:a(`promptSourceSeedButton`)})]})]}):(0,X.jsx)(`div`,{className:`source-default`,title:a(`promptSourceDefaultEditHint`),role:`button`,tabIndex:0,onClick:()=>ar(e,n),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),ar(e,n))},children:n.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?O[e]?` expanded`:` clamped`:``}`,children:n}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ir(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ir(e))},children:O[e]?a(`promptSourceCollapse`):a(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:a(`promptSourceDefaultEmpty`)})})]},e)}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-btn`,onClick:or,disabled:!lr,children:a(`promptResetAll`)})})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":ye,onClick:()=>K(e=>!e),children:[a(`settingsViewPrompt`),` `,ye?`▴`:`▾`]}),ye&&(0,X.jsxs)(`div`,{className:`set-prompt-view`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:a(`settingsViewPrompt`)}),(0,X.jsx)(Cs,{text:a(`settingsViewPromptHint`)}),(0,X.jsx)(ec,{text:c.effectiveSystemPrompt})]}),c.effectiveSystemPrompt?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:c.effectiveSystemPrompt}):(0,X.jsx)(`p`,{className:`set-empty`,children:a(`settingsViewPromptEmpty`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":be,onClick:()=>Se(e=>!e),children:[a(`settingsViewToolsSchema`),` `,be?`▴`:`▾`]}),be&&(0,X.jsx)(`div`,{className:`set-prompt-view`,children:(0,X.jsxs)(`div`,{className:`set-prompt-tools`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:a(`settingsViewToolsSchema`)}),(0,X.jsx)(Cs,{text:a(`settingsViewToolsSchemaHint`)}),(0,X.jsx)(ec,{text:c.toolsSchema})]}),c.toolsSchema?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:c.toolsSchema}):(0,X.jsx)(`p`,{className:`set-empty`,children:a(`settingsViewToolsSchemaEmpty`)})]})})]}),p===`prompt`&&!d&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ee,{className:`set-section-icon`}),a(`scmCommitMsgSettingsTitle`),(0,X.jsx)(Cs,{text:a(`scmCommitMsgSettingsDesc`)})]}),(0,X.jsx)(Hh,{label:a(`visionBridgePromptMode`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:H,onChange:e=>{let t=e.target.value;U(t),Q({scmCommitMsgPromptMode:t})},children:[(0,X.jsx)(`option`,{value:`append`,children:a(`promptModeAppend`)}),(0,X.jsx)(`option`,{value:`replace`,children:a(`promptModeReplace`)})]})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:a(`scmCommitMsgPromptPlaceholder`),value:ne,onFocus:()=>ae.current=!0,onBlur:()=>{ae.current=!1;let e=H===`replace`&&c.scmCommitMsgDefaultPrompt&&ne===c.scmCommitMsgDefaultPrompt?``:ne;Q({scmCommitMsgPromptMode:H,scmCommitMsgPrompt:e})},onChange:e=>z(e.target.value)}),(0,X.jsx)(`p`,{className:`set-hint`,children:a(`scmCommitMsgSettingsHint`)})]}),p===`scheduler`&&!d&&(0,X.jsx)(Fm,{tasks:e.schedulerTasks,cwd:e.state?.cwd??``,models:c.subagentModels}),p===`prompt-history`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ze,{className:`set-section-icon`}),a(`settingsPromptHistory`),(0,X.jsx)(Cs,{text:a(`settingsPromptHistoryDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:a(`promptHistoryCount`,{n:String(We)})})]}),We===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`promptHistoryEmpty`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:a(`promptHistoryCount`,{n:String(We)})}),(0,X.jsx)(Hh,{label:a(`promptHistoryMax`),tip:a(`promptHistoryMaxHint`),htmlFor:`ph-max`,children:(0,X.jsx)(`input`,{id:`ph-max`,className:`set-input`,type:`number`,min:1,max:500,step:1,value:String(He.maxEntries),onChange:e=>{let t=Math.floor(Number(e.target.value)||0),n={...He,maxEntries:t};Ue(n)},onBlur:()=>{let e={...He};(!Number.isFinite(e.maxEntries)||e.maxEntries<1)&&(e.maxEntries=1),e.maxEntries>500&&(e.maxEntries=500),e.maxEntries=Math.floor(e.maxEntries),Ue(e),qf(e),Je()}})}),(0,X.jsx)(Rh,{title:a(`promptHistoryCharLimit`),tip:a(`promptHistoryCharLimitHint`),enabled:He.charLimitEnabled,onToggle:()=>{let e={...He,charLimitEnabled:!He.charLimitEnabled};Ue(e),qf(e),Je()}}),He.charLimitEnabled&&(0,X.jsx)(Hh,{label:a(`promptHistoryCharLimit`),htmlFor:`ph-char-limit`,children:(0,X.jsx)(`input`,{id:`ph-char-limit`,className:`set-input`,type:`number`,min:100,max:2e4,step:100,placeholder:a(`promptHistoryCharLimitPlaceholder`),value:String(He.charLimit),onChange:e=>{let t=Math.floor(Number(e.target.value)||0);Ue({...He,charLimit:t})},onBlur:()=>{let e=Math.floor(Number(He.charLimit)||0);(!Number.isFinite(e)||e<100)&&(e=100),e>2e4&&(e=2e4);let t={...He,charLimit:e};Ue(t),qf(t),Je()}})}),(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:12},children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${Ke?` confirm`:``}`,disabled:We===0,title:a(We===0?`promptHistoryEmpty`:`promptHistoryClear`),onClick:()=>{if(!Ke){qe(!0);return}$f(),qe(!1),Je()},children:[(0,X.jsx)(L,{}),` `,a(Ke?`promptHistoryClearConfirm`:`promptHistoryClear`)]}),We>0&&(0,X.jsx)(`span`,{className:`set-hint`,style:{marginLeft:8},children:a(`promptHistoryCount`,{n:String(We)})})]}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[(0,X.jsx)(tt,{style:{verticalAlign:`-2px`,marginRight:4}}),a(`settingsPromptHistoryDesc`)]})]}),p===`tools`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(R,{className:`set-section-icon`}),a(`settingsTools`)]}),(0,X.jsx)(Rh,{title:a(`readDirEnabled`),tip:a(`readDirEnabledDesc`),enabled:c.readDirEnabled!==!1,onToggle:()=>Q({readDirEnabled:c.readDirEnabled===!1})}),(0,X.jsx)(Hh,{label:a(`toolWatchdogTimeout`),tip:a(`toolWatchdogTimeoutDesc`),htmlFor:`tool-watchdog-timeout`,children:(0,X.jsx)(`input`,{id:`tool-watchdog-timeout`,className:`set-input`,type:`number`,min:0,step:1,placeholder:a(`toolWatchdogOff`),value:Gt,onChange:e=>Kt(e.target.value),onBlur:()=>{let e=Gt.trim(),t=e===``?20:Math.max(0,Math.floor(Number(e)||0));Kt(String(t));let n=t*6e4;n!==c.toolWatchdogTimeoutMs&&Q({toolWatchdogTimeoutMs:n})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(`div`,{className:`set-field-label`,children:a(`toolsSectionTerminal`)}),mn.map(e=>(0,X.jsx)(Rh,{title:e,tip:a(`settingsTerminalToolsDesc`),enabled:!an.has(e),onToggle:()=>Sn(e)},e)),(0,X.jsx)(Rh,{title:a(`terminalBashTakeover`),tip:a(`terminalBashTakeoverDesc`),enabled:c.terminalBash,onToggle:()=>Q({terminalBash:!c.terminalBash})}),c.terminalBash&&(0,X.jsx)(Hh,{label:a(`terminalBashIdleMs`),htmlFor:`tb-idle-ms`,children:(0,X.jsx)(`input`,{id:`tb-idle-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:Ht,onChange:e=>Wt(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(Ht)||0));Wt(String(e)),e!==c.terminalBashIdleMs&&Q({terminalBashIdleMs:e})}})}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[a(`toolsSectionSubagent`),` `,(0,X.jsx)(Cs,{text:a(`toolsSubagentDepHint`)})]}),hn.map(e=>(0,X.jsx)(Rh,{title:e,tip:xn[e],enabled:!an.has(e),onToggle:()=>Sn(e)},e)),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[a(`settingsMarkers`),(0,X.jsx)(Cs,{text:`${a(`settingsMarkersDesc`)}\n${a(`markerRenameTip`)}`})]}),(0,X.jsx)(Rh,{title:a(`markersEnabled`),tip:`${a(`markersEnabledDesc`)}\n${a(`markersOffHint`)}`,enabled:En,onToggle:()=>Q({markersEnabled:!En})}),En&&(c.markers?.length??0)===0&&(0,X.jsxs)(`p`,{className:`set-empty`,children:[a(`loading`),`...`]}),En&&c.markers&&c.markers.length>0&&c.markers.map(e=>(0,X.jsx)(Rh,{title:e.name===`todo`?a(`markerGroupTodo`):e.name===`notify`?a(`markerGroupNotify`):e.name===`conv`?a(`markerGroupRename`):e.name,tip:e.guidance.join(`
362
362
  `),enabled:e.enabled,onToggle:()=>On(e.name)},e.name)),(0,X.jsx)(Rh,{title:`todo_list`,tip:`${a(`todoListEnabledDesc`)}\n${a(`todoListOffHint`)}`,enabled:!an.has(`todo_list`),onToggle:()=>Sn(`todo_list`)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:a(`toolsSectionOther`)}),jh.map(e=>(0,X.jsx)(Rh,{title:e.name,tip:`${s(e.descKey??e.name)}\n${s(e.offHintKey??e.name)}`,enabled:!an.has(e.name),onToggle:()=>Sn(e.name)},e.name)),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[a(`toolsSectionPlugin`),(0,X.jsx)(Cs,{text:a(`toolsPluginHint`)})]}),Tn.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:e.plugins.length===0?a(`noUiPlugins`):a(`pluginToolsEmpty`)}):Tn.map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[e.plugin.icon?`${e.plugin.icon} `:``,e.plugin.name,` · `,e.plugin.id]}),e.tools.map(e=>(0,X.jsx)(Rh,{title:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name,tip:e.description?`${e.description}\n${a(`pluginToolOffHint`)}`:a(`pluginToolOffHint`),enabled:!Cn.has(e.name),onToggle:()=>wn(e.name)},e.name))]},e.plugin.id))]}),p===`question`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(q,{className:`set-section-icon`}),a(`settingsQuestionnaire`)]}),(0,X.jsx)(Rh,{title:a(`questionnaireEnabled`),tip:`${a(`questionnaireEnabledDesc`)}\n${a(`questionnaireOffHint`)}`,enabled:c.questionnaireEnabled,onToggle:()=>Q({questionnaireEnabled:!c.questionnaireEnabled})})]}),p===`display`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(me,{className:`set-section-icon`}),a(`settingsMessageDisplay`)]}),(0,X.jsx)(Hh,{label:a(`softCapTokens`),tip:a(`softCapHint`),htmlFor:`soft-cap-max`,children:(0,X.jsx)(`input`,{id:`soft-cap-max`,className:`set-input`,type:`text`,placeholder:a(`softCapOff`),value:Yt,onChange:e=>Xt(e.target.value),onBlur:()=>{let e=Im(Yt);Xt(Lm(e)),e!==(c.softCapTokens??0)&&Q({softCapTokens:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-section-title`,children:[a(`softCapByModel`),(0,X.jsx)(Cs,{text:a(`softCapByModelHint`)})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`softCapModelId`),value:Zt,maxLength:200,onChange:e=>Qt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,placeholder:a(`softCapTokens`),value:$t,onChange:e=>en(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&Zt.trim()&&Im($t)>0){let e=Im($t);Q({softCapByModel:{...c.softCapByModel,[Zt.trim()]:e}}),Qt(``),en(``)}}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!Zt.trim()||Im($t)<=0,onClick:()=>{let e=Zt.trim(),t=Im($t);!e||t<=0||(Q({softCapByModel:{...c.softCapByModel,[e]:t}}),Qt(``),en(``))},children:[(0,X.jsx)(se,{}),` `,a(`softCapAdd`)]})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Object.entries(c.softCapByModel).map(([e,t])=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-row-name`,children:e}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,defaultValue:Lm(t),onBlur:t=>{let n=Im(t.target.value);t.target.value=Lm(n);let r={...c.softCapByModel};n>0?r[e]=n:delete r[e],Q({softCapByModel:r})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}},`${e}:${t}`),(0,X.jsxs)(`button`,{type:`button`,className:`chip`,title:a(`softCapRemove`),onClick:()=>{let t={...c.softCapByModel};delete t[e],Q({softCapByModel:t})},children:[(0,X.jsx)(M,{}),` `,a(`softCapRemove`)]})]},e))}),(0,X.jsx)(Hh,{label:a(`modelRetryAttempts`),tip:a(`modelRetryHint`),htmlFor:`model-retry-max`,children:(0,X.jsx)(`input`,{id:`model-retry-max`,className:`set-input`,type:`number`,min:0,max:100,step:1,value:qt,onChange:e=>Jt(e.target.value),onBlur:()=>{let e=Math.min(100,Math.max(0,Math.floor(Number(qt)||0)));Jt(String(e)),e!==c.retryMaxAttempts&&Q({retryMaxAttempts:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(Rh,{title:a(`thinkingWrap`),tip:a(`thinkingWrapDesc`),enabled:c.thinkingWrap??!0,onToggle:()=>Q({thinkingWrap:!(c.thinkingWrap??!0)})}),(0,X.jsx)(Rh,{title:a(`toolsWrap`),tip:a(`toolsWrapDesc`),enabled:c.toolsWrap??!0,onToggle:()=>Q({toolsWrap:!(c.toolsWrap??!0)})}),(0,X.jsx)(Rh,{title:a(`toolImages`),tip:a(`toolImagesDesc`),enabled:c.toolImagesEnabled??!0,onToggle:()=>Q({toolImagesEnabled:!(c.toolImagesEnabled??!0)})}),(0,X.jsx)(Rh,{title:a(`presentAutoOpen`),tip:a(`presentAutoOpenDesc`),enabled:we,onToggle:()=>Ul(!we)}),(0,X.jsx)(Rh,{title:a(`parallelReminderEnabled`),tip:`${a(`parallelReminderEnabledDesc`)}\n${a(`parallelReminderOffHint`)}`,enabled:c.parallelReminderEnabled??!0,onToggle:()=>Q({parallelReminderEnabled:!(c.parallelReminderEnabled??!0)})}),(0,X.jsx)(Rh,{title:a(`devNoCache`),tip:a(`devNoCacheDesc`),enabled:c.devNoCache??!0,onToggle:()=>Q({devNoCache:!(c.devNoCache??!0)})}),(0,X.jsx)(Rh,{title:a(`autoReload`),tip:a(`autoReloadDesc`),enabled:c.autoReload??!0,onToggle:()=>Q({autoReload:!(c.autoReload??!0)})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(0,X.jsx)(Rh,{title:a(`wideChat`),tip:a(`wideChatDesc`),enabled:Ce,onToggle:()=>Hm({wide:!Ce})}),(0,X.jsx)(Rh,{title:a(`projectTitle`),tip:a(`projectTitleDesc`),enabled:Te,onToggle:()=>$m({projectName:!Te})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(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:[a(`wallpaperTitle`),(0,X.jsx)(Cs,{text:a(`wallpaperDesc`)})]}),(0,X.jsxs)(`div`,{className:`wallpaper-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input wallpaper-url`,placeholder:a(`wallpaperUrlPh`),value:Y,maxLength:2e3,spellCheck:!1,onFocus:()=>{je.current=!0},onChange:e=>Oe(e.target.value),onBlur:()=>{if(je.current=!1,!Y.trim()&&J.url.startsWith(`data:`)){Oe(``);return}let e=uh(Y);Oe(e),e!==J.url&&_h({...J,url:e})},onKeyDown:e=>{e.key===`Enter`?e.target.blur():e.key===`Escape`&&(Oe(J.url.startsWith(`data:`)?``:J.url),e.target.blur())}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:Ie,onClick:()=>Ne.current?.click(),children:[(0,X.jsx)(F,{}),` `,a(`wallpaperUpload`)]}),(0,X.jsx)(`input`,{ref:Ne,type:`file`,accept:`image/*`,hidden:!0,onChange:Ve})]}),Re&&(0,X.jsx)(`p`,{className:`set-hint`,children:a(`wallpaperUploadFailed`)}),(0,X.jsxs)(`div`,{className:`wallpaper-sliders`,children:[(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:a(`wallpaperDim`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:95,step:1,value:J.dim,onChange:e=>_h({...J,dim:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[J.dim,`%`]})]}),(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:a(`wallpaperBlur`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:24,step:1,value:J.blur,onChange:e=>_h({...J,blur:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[J.blur,`px`]})]})]})]}),J.url&&(0,X.jsxs)(`div`,{className:`wallpaper-current`,children:[(0,X.jsx)(`img`,{className:`wallpaper-preview`,src:J.url,alt:``}),(0,X.jsx)(`button`,{type:`button`,className:`wallpaper-clear`,onClick:()=>{Oe(``),_h({...J,url:``})},children:a(`wallpaperClear`)})]})]})]}),p===`quick`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ie,{className:`set-section-icon`}),a(`quickPhrases`),(0,X.jsx)(Cs,{text:a(`quickPhrasesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:c.quickPhrases.length})]}),(0,X.jsx)(Rh,{title:a(`quickPhrasesEnabled`),tip:a(`quickPhrasesDesc`),enabled:c.quickPhrasesEnabled,onToggle:()=>Q({quickPhrasesEnabled:!c.quickPhrasesEnabled})}),!c.quickPhrasesEnabled&&(0,X.jsx)(`p`,{className:`set-hint`,children:a(`quickPhrasesOffHint`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`quickPhrasesPlaceholder`),value:Rt,maxLength:200,onChange:e=>zt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Rt.trim()&&(Q({quickPhrases:[...c.quickPhrases,Rt.trim()]}),zt(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!Rt.trim(),onClick:()=>{Q({quickPhrases:[...c.quickPhrases,Rt.trim()]}),zt(``)},children:[(0,X.jsx)(se,{}),` `,a(`quickPhrasesAdd`)]})]}),c.quickPhrases.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`quickPhrasesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:c.quickPhrases.map((e,t)=>(0,X.jsx)(`div`,{className:`set-row`,children:Bt?.index===t?(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`input`,{className:`set-input`,autoFocus:!0,value:Bt.value,maxLength:200,placeholder:a(`quickPhrasesEditPh`),onChange:e=>Vt({index:t,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?dn():e.key===`Escape`&&Vt(null)},onBlur:dn})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`div`,{className:`set-row-name`,title:e,children:e})}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:a(`quickPhrasesEdit`),onClick:()=>Vt({index:t,value:e}),children:(0,X.jsx)(Me,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:a(`quickPhrasesMoveUp`),disabled:t===0,onClick:()=>{let e=[...c.quickPhrases];[e[t-1],e[t]]=[e[t],e[t-1]],Q({quickPhrases:e})},children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:a(`quickPhrasesMoveDown`),disabled:t===c.quickPhrases.length-1,onClick:()=>{let e=[...c.quickPhrases];[e[t],e[t+1]]=[e[t+1],e[t]],Q({quickPhrases:e})},children:`↓`}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:a(`quickPhrasesDelete`),onClick:()=>Q({quickPhrases:c.quickPhrases.filter((e,n)=>n!==t)}),children:(0,X.jsx)(L,{})})]})]})},`${t}:${e}`))}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>{Vt(null),Q({quickPhrases:Eh[o]??Eh.en})},children:a(`quickPhrasesReset`)})})]}),p===`skills`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Fe,{className:`set-section-icon`}),a(`settingsSkills`),(0,X.jsx)(Cs,{text:`${a(`skillFullTextLabel`)}:${a(`skillFullTextDesc`)}`}),(0,X.jsx)(`span`,{className:`set-count`,children:c.skills.length})]}),c.skills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(d?`dshSkillsNote`:`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:c.skills.map(e=>(0,X.jsx)(Rh,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>fn(e),action:(0,X.jsx)(`button`,{type:`button`,className:`tpl-chip${pn.has(e.name)?` on`:``}`,title:a(`skillFullTextDesc`),onClick:()=>gn(e.name),children:a(`skillFullTextShort`)})},e.name))})]}),p===`extensions`&&(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`}),a(`settingsExtensions`),(0,X.jsx)(`span`,{className:`set-count`,children:c.extensions.length})]}),c.extensions.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(d?`dshExtensionsNote`:`noExtensions`)}):(0,X.jsx)(`div`,{className:`set-list`,children:c.extensions.map(e=>{let t=e.id.startsWith(`npm:`)?e.id.slice(4):null;return(0,X.jsx)(Rh,{title:e.name,subtitle:e.path,enabled:e.enabled,onToggle:()=>bn(e),action:t?Xe===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:a(`uninstallConfirmHint`),onClick:()=>An(t),children:a(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`uninstallHint`),onClick:()=>Ze(e.id),children:[(0,X.jsx)(L,{}),a(`uninstallExt`)]}):void 0},e.id)})})]}),p===`layout`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(B,{className:`set-section-icon`}),a(`uiLayoutTitle`),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:Kn,children:a(`uiLayoutRestoreAll`)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:a(`uiLayoutHint`)}),(0,X.jsx)(`input`,{className:`set-ui-filter`,value:In,placeholder:a(`uiLayoutSearch`),"aria-label":a(`uiLayoutSearch`),onChange:e=>Ln(e.target.value)}),Pn.map(({slot:e,labelKey:t})=>{let n=(tn[e]??[]).filter(e=>d||e.id!==`host:composer-dsh-perm`&&e.id!==`host:composer-dsh-preset`),r=In.trim().toLowerCase(),i=!r&&Fn.includes(e)?[`start`,`center`,`end`].map(e=>({align:e,items:n.filter(t=>t.align===e)})).filter(e=>e.items.length>0):[{align:null,items:r?n.filter(e=>`${e.label} ${e.id} ${e.source}`.toLowerCase().includes(r)):n}],o=i.reduce((e,t)=>e+t.items.length,0);if(r&&o===0)return null;let s=(t,i)=>{let o=i.findIndex(e=>e.id===t.id),s=fr.has(t.id);return(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`label`,{className:`set-toggle`,title:s?a(`uiLayoutRequired`):t.id,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!t.hidden,disabled:s,onChange:()=>Vn(t)}),(0,X.jsxs)(`span`,{children:[t.icon?`${t.icon} `:``,t.label]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[t.arrangedBy.length>0&&(0,X.jsx)(`span`,{className:`set-ui-source`,title:t.arrangedBy.join(`, `),children:a(`uiLayoutArranged`)}),t.movedFrom&&(0,X.jsxs)(`span`,{className:`set-ui-source`,title:t.id,children:[a(`uiLayoutMovedFrom`),`: `,Rn(t.movedFrom)]}),Fn.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:a(`uiLayoutAlign`),children:(0,X.jsxs)(`select`,{value:t.align,onChange:e=>Un(t.id,e.target.value),"aria-label":a(`uiLayoutAlign`),children:[(0,X.jsx)(`option`,{value:`start`,children:`start`}),(0,X.jsx)(`option`,{value:`center`,children:`center`}),(0,X.jsx)(`option`,{value:`end`,children:`end`})]})}),(0,X.jsx)(`input`,{className:`set-ui-label`,defaultValue:zn?.labels?.[t.id]??``,placeholder:a(`uiLayoutRename`),title:a(`uiLayoutRename`),"aria-label":a(`uiLayoutRename`),onBlur:e=>{e.target.value!==(zn?.labels?.[t.id]??``)&&Wn(t.id,e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.target.blur()}},`${t.id}:${zn?.labels?.[t.id]??``}`),t.userOverrides.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Gn(t.id),children:a(`uiLayoutRestore`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||o<=0,onClick:()=>Hn(n,i,t.id,-1),children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||o<0||o>=i.length-1,onClick:()=>Hn(n,i,t.id,1),children:`↓`})]})]},t.id)};return(0,X.jsxs)(`div`,{className:`set-ui-slot`,children:[(0,X.jsx)(`div`,{className:`set-ui-slot-title`,children:a(t)}),e===`topbar.primary`&&(0,X.jsxs)(`label`,{className:`set-toggle`,title:`topbarText`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:zn?.topbarText!==!1,onChange:e=>Bn({topbarText:e.target.checked})}),(0,X.jsx)(`span`,{children:a(`uiLayoutTopbarText`)})]}),n.length===0?(0,X.jsx)(`div`,{className:`set-empty`,children:a(`uiLayoutEmpty`)}):i.map(e=>(0,X.jsxs)(f.Fragment,{children:[e.align&&(0,X.jsx)(`div`,{className:`set-ui-slot-title set-ui-seg`,children:e.align}),e.items.map(t=>s(t,e.items))]},e.align??`all`))]},e)})]}),p===`plugins`&&!u&&(0,X.jsxs)(`div`,{className:`set-subtabs`,role:`tablist`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`market`,className:`set-subtab${h===`market`?` active`:``}`,onClick:()=>{g(`market`),_.current?.scrollTo({top:0})},children:[a(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`installed`,className:`set-subtab${h===`installed`?` active`:``}`,onClick:()=>{g(`installed`),_.current?.scrollTo({top:0})},children:[a(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length})]})]}),p===`plugins`&&h===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(De,{className:`set-section-icon`}),a(`pluginGrantsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginGrants.reduce((e,t)=>e+t.paths.length,0)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:a(`pluginGrantsHint`)}),e.pluginGrants.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`pluginGrantsEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:e.pluginGrants.map(e=>(0,X.jsxs)(`div`,{className:`set-grant-row`,children:[(0,X.jsx)(`div`,{className:`set-catalog-title`,children:(0,X.jsx)(`span`,{children:e.pluginId})}),e.paths.map(t=>(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:t}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_path_revoke`,pluginId:e.pluginId,path:t}),children:a(`pluginGrantsRevoke`)})]},t))]},e.pluginId))})]}),p===`plugins`&&h===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(xe,{className:`set-section-icon`}),a(`pluginPermsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:(e.pluginPermissions??[]).length})]}),(0,X.jsx)(`div`,{className:`set-note`,children:a(`pluginPermsHint`)}),(e.pluginPermissions??[]).length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`pluginPermsEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:(e.pluginPermissions??[]).map((e,t)=>(0,X.jsxs)(`div`,{className:`set-grant-row`,children:[(0,X.jsxs)(`div`,{className:`set-catalog-title`,children:[(0,X.jsx)(`span`,{children:e.pluginId}),(0,X.jsxs)(`span`,{className:`set-catalog-source`,children:[e.family===`net`?a(`pluginPermNet`):a(`pluginPermLlm`),e.session?` · ${a(`pluginPermSession`)}`:``]})]}),(e.hosts??[]).map(t=>(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:t}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:`net`,host:t}),children:a(`pluginGrantsRevoke`)})]},t)),(e.models??[]).map(t=>(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:t}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:`llm`,model:t}),children:a(`pluginGrantsRevoke`)})]},t)),!(e.hosts??[]).length&&!(e.models??[]).length&&(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:e.reason??a(`pluginPermUnscoped`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:e.family}),children:a(`pluginGrantsRevoke`)})]}),e.reason&&((e.hosts??[]).length>0||(e.models??[]).length>0)&&(0,X.jsx)(`div`,{className:`set-note`,children:e.reason})]},`${e.pluginId}|${e.family}|${t}`))})]}),p===`plugins`&&u&&(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-note`,children:a(`updatesManaged`)})}),p===`plugins`&&!u&&h===`market`&&(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`}),a(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`div`,{className:`set-toolbar`,children:[(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:a(`pluginBuildHint`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:St,onChange:e=>Ct(e.target.checked)}),a(`pluginBuildSource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginCatalogSyncHint`),onClick:()=>Tt(e=>!e),children:[(0,X.jsx)(oe,{}),a(`pluginCatalogSync`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginCatalogAddHint`),onClick:()=>xt(e=>!e),children:[(0,X.jsx)(se,{}),a(`pluginCatalogAdd`)]})]}),wt&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`div`,{className:`set-note`,children:a(`pluginCatalogSyncHint`)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`pluginCatalogSyncSource`),value:Et,onChange:e=>Dt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Qn(Et)}}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:a(`pluginCatalogSyncInstall`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Ot,onChange:e=>kt(e.target.checked)}),a(`pluginCatalogSyncInstall`)]}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:a(`pluginCatalogSyncReplace`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:At,onChange:e=>jt(e.target.checked)}),a(`pluginCatalogSyncReplace`)]}),It.length>0&&(0,X.jsxs)(`div`,{className:`set-catalog-recent`,children:[(0,X.jsx)(`span`,{className:`set-catalog-recent-label`,children:a(`pluginCatalogSyncRecent`)}),It.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-catalog-recent-item`,title:e,onClick:()=>{Dt(e),Qn(e)},children:e},e))]}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!Et.trim(),onClick:()=>Qn(Et),children:a(`pluginCatalogSyncSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Tt(!1),children:a(`cancel`)})]}),$n&&($n.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[(0,X.jsxs)(`span`,{children:[`✓ `,a(`pluginCatalogSyncOk`,{n:$n.entryCount??0}),$n.installed?` · ${a(`pluginCatalogSyncInstalled`,{ok:$n.installed.filter(e=>e.ok).length,fail:$n.installed.filter(e=>!e.ok).length})}`:null]}),$n.installed?.some(e=>!e.ok)&&(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:$n.installed.filter(e=>!e.ok).map(e=>`${e.id}:${e.error??`?`}`).join(`
363
363
  `)})]}):(0,X.jsx)(`div`,{className:`set-catalog-job error`,children:(0,X.jsxs)(`span`,{children:[`✗ `,$n.error||a(`pluginJobFailed`)]})}))]}),bt&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`pluginCatalogSource`),value:ut,onChange:e=>dt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`pluginCatalogId`),value:ft,onChange:e=>pt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`pluginCatalogName`),value:mt,onChange:e=>ht(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`pluginCatalogIcon`),value:vt,onChange:e=>yt(e.target.value)}),(0,X.jsx)(`textarea`,{className:`set-input`,rows:2,placeholder:a(`pluginCatalogDesc`),value:gt,onChange:e=>_t(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!ut.trim(),onClick:Zn,children:a(`pluginCatalogAddSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>xt(!1),children:a(`cancel`)})]})]}),e.pluginCatalog.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`noPluginCatalog`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.pluginCatalog.map(e=>{let t=vn.has(e.id);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)(sr,{icon:e.icon,iconSvg:e.iconSvg}),` `,e.name]}),t&&(0,X.jsx)(`span`,{className:`set-catalog-installed`,children:a(`pluginInstalled`)}),!e.builtin&&(0,X.jsx)(`span`,{className:`set-catalog-custom`,children:a(`pluginCatalogCustom`)})]}),e.description&&(0,X.jsx)(`div`,{className:`set-catalog-desc`,children:e.description}),(0,X.jsx)(`div`,{className:`set-catalog-source`,children:e.source}),Nn(e.id)]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginUpdateHint`),onClick:()=>Jn(e.id,e.source),children:[(0,X.jsx)(oe,{}),a(`pluginUpdate`)]}),Qe===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:a(`pluginUninstallHint`),onClick:()=>qn(e.id),children:a(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginUninstallHint`),onClick:()=>$e(e.id),children:[(0,X.jsx)(L,{}),a(`uninstallExt`)]})]}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginInstallHint`),onClick:()=>Yn(e),children:[(0,X.jsx)(Pe,{}),a(`pluginInstall`)]}),!e.builtin&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginCatalogRemoveHint`),onClick:()=>Xn(e.id),children:(0,X.jsx)(M,{})})]})]},e.id)})})]}),p===`plugins`&&h===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ye,{className:`set-section-icon`}),a(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginRescanHint`),onClick:()=>$({type:`plugins_reload`}),children:[(0,X.jsx)(oe,{}),a(`pluginRescan`)]})]}),e.plugins.length>0&&(0,X.jsx)(Vh,{plugins:e.plugins,disabledIds:_n}),e.plugins.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`noUiPlugins`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.plugins.map(e=>(0,X.jsxs)(f.Fragment,{children:[(0,X.jsx)(Rh,{title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Bh,{phase:wh(e,_n.has(e.id)),label:s(zh(wh(e,_n.has(e.id))))}),(0,X.jsx)(sr,{icon:e.icon,iconSvg:e.iconSvg}),` `,e.name]}),subtitle:(e.error?`${e.id} · ${e.error}`:e.source?`${e.id} · ${e.source}`:`${e.id} · ${a(`uiPluginNoSource`)}`)+(e.permissions?.length?` · ${a(`uiPluginPerms`)}: ${e.permissions.join(`, `)}`:``),enabled:!_n.has(e.id)&&!e.error,onToggle:()=>!e.error&&yn(e),action:(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[e.source&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginUpdateHint`),onClick:()=>Jn(e.id,e.source),children:[(0,X.jsx)(oe,{}),a(`pluginUpdate`)]}),Qe===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:a(`pluginUninstallHint`),onClick:()=>qn(e.id),children:a(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginUninstallHint`),onClick:()=>$e(e.id),children:[(0,X.jsx)(L,{}),a(`uninstallExt`)]})]})},e.id),e.agentTools&&e.agentTools.length>0&&!d&&(0,X.jsxs)(`div`,{className:`set-row`,title:a(`pluginToolOffHint`),children:[(0,X.jsxs)(`span`,{className:`set-ui-source`,children:[a(`pluginToolsSection`),` (`,e.agentTools.length,`)`,e.agentTools.some(e=>Cn.has(e.name))?` · ${a(`settingsDisabled`)}`:``]}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>m(`tools`),children:[a(`settingsTools`),` →`]})})]}),(0,X.jsxs)(`div`,{className:`set-row set-log-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>{it===e.id?at(null):(at(e.id),$(No(e.id)))},children:[(0,X.jsx)(ke,{}),a(`pluginLogTitle`),` (`,Bo(e.id).length,`) ·`,` `,it===e.id?a(`pluginLogHide`):a(`pluginLogShow`)]}),it===e.id&&(0,X.jsx)(Uh,{pluginId:e.id})]}),e.diagnostics&&e.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:()=>rt(et===e.id?null:e.id),children:[(0,X.jsx)(nt,{}),a(`pluginDiagTitle`),` (`,e.diagnostics.length,`) ·`,` `,et===e.id?a(`pluginDiagHide`):a(`pluginDiagShow`)]}),et===e.id&&(0,X.jsx)(`ul`,{className:`set-diag-list`,children:e.diagnostics.map((t,n)=>(0,X.jsx)(`li`,{children:t},`${e.id}-${n}`))})]}),e.wantsDom&&(0,X.jsxs)(`div`,{className:`set-row`,title:a(`pluginDomDesc`),children:[(0,X.jsx)(`span`,{className:`set-ui-source`,children:e.domGranted?a(`pluginDomGranted`):a(`pluginDomNeed`)}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall${e.domGranted?``:` confirm`}`,title:a(`pluginDomDesc`),onClick:()=>$({type:`plugin_dom_consent`,pluginId:e.id,granted:!e.domGranted}),children:e.domGranted?a(`pluginDomRevoke`):a(`pluginDomGrant`)})})]}),e.settingsSchema&&e.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:()=>ct(t=>({...t,[e.id]:!t[e.id]})),children:[(0,X.jsx)(B,{}),a(`pluginSettingsTitle`),` (`,e.settingsSchema.length,`) ·`,` `,st[e.id]?a(`pluginSettingsHide`):a(`pluginSettingsShow`)]}),st[e.id]&&(0,X.jsx)(km,{plugin:e,models:c?.subagentModels??[]})]})]},e.id))})]}),p===`plugins`&&d&&h===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ye,{className:`set-section-icon`}),a(`dshPatches`),(0,X.jsx)(Cs,{text:a(`dshPatchesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPatches?.files.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`dshPatchesRescanHint`),onClick:()=>$({type:`dsh_patches_rescan`}),children:[(0,X.jsx)(oe,{}),a(`dshPatchesRescan`)]})]}),(e.dshPatches?.files.length??0)===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`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:[Ih(e.size),` · `,new Date(e.mtimeMs).toLocaleString()]})]})},e.name))}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[a(`dshPatchesPath`),` `,e.dshPatches?.patchDir??``]})]}),p===`review`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(j,{className:`set-section-icon`}),a(`settingsReview`),(0,X.jsx)(Cs,{text:a(`settingsReviewDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:c.reviewSkills.length})]}),(0,X.jsx)(Rh,{title:a(`goalModeEnabled`),tip:`${a(`goalModeEnabledDesc`)}\n${a(`goalModeOffHint`)}`,enabled:c.goalModeEnabled,onToggle:()=>Q({goalModeEnabled:!c.goalModeEnabled})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:5,placeholder:a(`reviewPromptPlaceholder`),value:ce,onFocus:()=>de.current=!0,onBlur:()=>{de.current=!1,Q({reviewPrompt:ce})},onChange:e=>le(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[a(`settingsReviewSkills`),d&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(Cs,{text:a(`dshReviewPromptNote`)})]})]}),c.reviewSkills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:c.reviewSkills.map(e=>(0,X.jsx)(Rh,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>er(e)},`review-${e.name}`))})]}),p===`vision`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ae,{className:`set-section-icon`}),a(`settingsVisionBridge`)]}),(0,X.jsx)(Rh,{title:a(`visionBridgeEnabled`),tip:`${a(`settingsVisionBridgeDesc`)}\n${a(`visionBridgeOffHint`)}`,enabled:c.visionBridgeEnabled,onToggle:()=>Q({visionBridgeEnabled:!c.visionBridgeEnabled})}),c.visionBridgeEnabled&&(0,X.jsx)(Hh,{label:a(`visionBridgeModel`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:c.visionBridgeModel??``,onChange:e=>Q({visionBridgeModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:a(`visionBridgeAuto`)}),c.visionModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),c.visionBridgeEnabled&&(0,X.jsx)(Hh,{label:a(`visionBridgePromptMode`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:I,onChange:e=>{let t=e.target.value;ee(t),Q({visionBridgePromptMode:t})},children:[(0,X.jsx)(`option`,{value:`append`,children:a(`promptModeAppend`)}),(0,X.jsx)(`option`,{value:`replace`,children:a(`promptModeReplace`)})]})}),c.visionBridgeEnabled&&(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:a(`visionBridgePromptPlaceholder`),value:A,onFocus:()=>te.current=!0,onBlur:()=>{te.current=!1;let e=I===`replace`&&c.visionBridgeDefaultPrompt&&A===c.visionBridgeDefaultPrompt?``:A;Q({visionBridgePromptMode:I,visionBridgePrompt:e})},onChange:e=>N(e.target.value)}),c.visionBridgeEnabled&&(c.visionModels.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:a(`visionBridgeNoModels`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:a(`visionBridgeCurrent`,{model:c.visionBridgeModel??a(`visionBridgeAuto`)})}))]}),p===`presets`&&d&&e.dshPresets&&e.dshPresets.presets.length>0&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Fe,{className:`set-section-icon`}),a(`dshPreset`),(0,X.jsx)(Cs,{text:a(`dshDefaultPresetDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPresets.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:a(`dshDefaultPreset`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPresets.defaultPreset,onChange:e=>$({type:`dsh_preset_default`,preset:e.target.value}),children:pp(e.dshPresets.presets).map(e=>(0,X.jsxs)(`option`,{value:e.id,disabled:!!e.broken,children:[e.name??e.id,e.trust===`user`?` · ${a(`dshPresetUser`)}`:``]},e.id))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:pp(e.dshPresets.presets).map(t=>(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[t.name??t.id,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetUser`)}),t.id===e.dshPresets.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:a(`dshPresetBroken`)})]}),t.description&&!t.broken&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:t.description}),t.broken&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:t.broken})]})},t.id))}),(0,X.jsx)(`p`,{className:`set-hint`,children:a(`dshPresetUserNote`)})]}),p===`presets`&&d&&e.dshPermission&&e.dshPermission.options.length>0&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(V,{className:`set-section-icon`}),a(`dshPerm`),(0,X.jsx)(Cs,{text:a(`dshPermDefaultDesc`)})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:a(`dshPermDefault`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:gp.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:a(_p(e))},e))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:gp.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(t=>(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[a(_p(t)),t===e.dshPermission.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)})]}),(0,X.jsx)(`div`,{className:`set-row-desc`,children:a(vp(t))})]})},t))})]}),p===`presets`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(re,{className:`set-section-icon`}),a(`settingsPresets`),(0,X.jsx)(`span`,{className:`set-count`,children:c.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`presetNamePlaceholder`),value:fe,onChange:e=>pe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&fe.trim()&&($({type:`save_preset`,name:fe.trim()}),pe(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!fe.trim(),onClick:()=>{$({type:`save_preset`,name:fe.trim()}),pe(``)},children:[(0,X.jsx)(se,{}),` `,a(`saveAsPreset`)]})]}),c.presets.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`noPresets`)}):(0,X.jsx)(`div`,{className:`set-list`,children:c.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`?a(`promptModeReplace`):a(`promptModeAppend`),e.disabledSkills.length>0&&` · ${a(`settingsSkills`)} ${e.disabledSkills.length}`,e.disabledExtensions.length>0&&` · ${a(`settingsExtensions`)} ${e.disabledExtensions.length}`]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`apply_preset`,name:e.name}),children:a(`applyPreset`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:a(`deletePreset`),onClick:()=>$({type:`delete_preset`,name:e.name}),children:(0,X.jsx)(L,{})})]})]},e.name))})]}),p===`subagent-templates`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(P,{className:`set-section-icon`}),a(`settingsSubagentTemplates`),(0,X.jsx)(Cs,{text:a(`settingsSubagentTemplatesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:c.subagentTemplates.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:a(`subagentTemplateNew`),onClick:()=>{G({name:``,description:``,promptMode:`replace`,systemPrompt:``,enabledSkills:[],enabledExtensions:[],model:``,thinkingLevel:``,enabled:!0}),ge(!0)},children:[(0,X.jsx)(se,{}),` `,a(`subagentTemplateNew`)]})]}),(0,X.jsx)(Hh,{label:a(`subagentDefaultModelLabel`),tip:a(`subagentDefaultModelHint`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:c.subagentDefaultModel??``,onChange:e=>Q({subagentDefaultModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:a(`subagentFollowMain`)}),c.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),c.subagentModels.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:a(`subagentNoModels`)}),W&&(0,X.jsx)(`div`,{className:`modal-backdrop tpl-modal-backdrop`,onClick:()=>G(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":a(`close`),onClick:()=>G(null),children:(0,X.jsx)(M,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(P,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:he?a(`subagentTemplateNew`):`${a(`subagentTemplateEdit`)} · ${W.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:a(`tplNamePlaceholder`),value:W.name,onChange:e=>G({...W,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`tplDescriptionPlaceholder`),value:W.description,onChange:e=>G({...W,description:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`tplDescriptionEnPlaceholder`),value:W.descriptionEn??``,onChange:e=>G({...W,descriptionEn:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:a(`tplPromptModeLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:W.promptMode,onChange:e=>G({...W,promptMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`replace`,children:a(`promptModeReplace`)}),(0,X.jsx)(`option`,{value:`append`,children:a(`promptModeAppend`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:a(`tplModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:W.model??``,onChange:e=>G({...W,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:a(`subagentFollowMain`)}),c.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:[a(`tplThinkingLabel`),` `,(0,X.jsx)(Cs,{text:a(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:W.thinkingLevel??``,onChange:e=>G({...W,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:a(`tplThinkingFollowMain`)}),up.map(e=>(0,X.jsx)(`option`,{value:e,children:a(`thinking.${e}`)},e))]})]}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${a(`tplSystemPromptLabel`)}${o===`zh`?`:`:`: `}${a(`tplSystemPromptPlaceholder`)}`,value:W.systemPrompt,onChange:e=>G({...W,systemPrompt:e.target.value})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${a(`tplSystemPromptLabel`)}: ${a(`tplSystemPromptEnPlaceholder`)}`,value:W.systemPromptEn??``,onChange:e=>G({...W,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:[a(`tplSkillsLabel`),` · `,a(`tplWhitelistHint`)]})}),c.skills.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:a(`noSkills`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:c.skills.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${W.enabledSkills.includes(e.name)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:W.enabledSkills.includes(e.name),onChange:t=>{let n=t.target.checked;G({...W,enabledSkills:n?[...W.enabledSkills,e.name]:W.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:[a(`tplExtensionsLabel`),` · `,a(`tplWhitelistHint`)]})}),c.extensions.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:a(`noExtensions`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:c.extensions.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${W.enabledExtensions.includes(e.id)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:W.enabledExtensions.includes(e.id),onChange:t=>{let n=t.target.checked;G({...W,enabledExtensions:n?[...W.enabledExtensions,e.id]:W.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:!W.name.trim(),onClick:()=>{$({type:`save_subagent_template`,template:{...W,name:W.name.trim()}}),G(null)},children:a(`tplSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>G(null),children:a(`tplCancel`)})]})]})}),c.subagentTemplates.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`noSubagentTemplates`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:c.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,c.subagentDefaultTemplates.includes(e.name)&&(0,X.jsx)(`span`,{className:`tpl-badge default`,children:a(`tplDefaultBadge`)}),!e.enabled&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:a(`subagentTemplateClosed`)})]}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[(o!==`zh`&&e.descriptionEn?e.descriptionEn:e.description)||`${e.promptMode===`replace`?a(`promptModeReplace`):a(`promptModeAppend`)}`,e.model?` · ${a(`tplModelLabel`)} ${e.model}`:` · ${a(`subagentFollowMain`)}`,e.thinkingLevel?` · ${a(`tplThinkingLabel`)} ${s(`thinking.${e.thinkingLevel}`)}`:``,e.enabledSkills.length>0&&` · ${a(`tplSkillsLabel`)} ${e.enabledSkills.length}`,e.enabledExtensions.length>0&&` · ${a(`tplExtensionsLabel`)} ${e.enabledExtensions.length}`,!e.description&&e.enabledSkills.length===0&&e.enabledExtensions.length===0&&` · ${a(`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?a(`subagentTemplateDisable`):a(`subagentTemplateEnable`)} · ${a(`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:a(`subagentTemplateEdit`),onClick:()=>{G({...e}),ge(!1)},children:a(`subagentTemplateEdit`)}),_e===e.name?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:a(`uninstallConfirmHint`),onClick:()=>{$({type:`delete_subagent_template`,name:e.name}),ve(null)},children:a(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:a(`tplDelete`),onClick:()=>ve(e.name),children:(0,X.jsx)(L,{})})]})]},e.name))})]}),cn&&(0,X.jsx)(Ms,{plugin:cn.plugin,epoch:e.pluginsEpoch,send:$,className:`set-plugin-page`})]})]}),(0,X.jsx)(`div`,{className:`modal-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:i,children:a(`close`)})})]})})}var Gh=0,Kh=``;function qh(){typeof document<`u`&&(Gh===0&&(Kh=document.body.style.overflow,document.body.style.overflow=`hidden`),Gh++)}function Jh(){typeof document<`u`&&(Gh=Math.max(0,Gh-1),Gh===0&&(document.body.style.overflow=Kh))}function Yh({open:e=!0,onClose:t,title:n,icon:r,children:i,className:a=``,backdropClassName:o=``,style:s,closeOnBackdropClick:c=!0,closeOnEscape:l=!0,showCloseButton:u=!0,ariaLabel:d,lockScroll:p=!0}){let m=Z(),h=(0,f.useRef)(t);if((0,f.useLayoutEffect)(()=>{h.current=t}),mt(()=>l?(h.current(),!0):!1,e),(0,f.useEffect)(()=>{if(e&&p)return qh(),()=>{Jh()}},[e,p]),!e)return null;let g=e=>{e.target===e.currentTarget&&c&&h.current()},_=d??(typeof n==`string`?n:void 0);return(0,D.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop ${o}`.trim(),onClick:g,role:`presentation`,children:(0,X.jsxs)(`div`,{className:`modal ${a}`.trim(),role:`dialog`,"aria-modal":`true`,"aria-label":_,style:s,onClick:e=>e.stopPropagation(),children:[u&&(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":m(`close`),onClick:()=>h.current(),children:`✕`}),n?(0,X.jsxs)(`div`,{className:`modal-head`,children:[r?(0,X.jsx)(`span`,{className:`modal-head-icon`,"aria-hidden":!0,children:r}):null,(0,X.jsx)(`span`,{children:n})]}):null,i]})}),document.body)}function Xh(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 Zh({servers:e,onClose:t}){let n=Z(),[r,i]=(0,f.useState)(new Set),a=e=>i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,f.useEffect)(()=>{$({type:`list_bg_servers`})},[]),(0,X.jsxs)(Yh,{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)(be,{}),` `,n(`bgTasks`),e.length>0&&(0,X.jsx)(`em`,{className:`bg-task-count`,children:e.length})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:n(`close`),onClick:t,children:(0,X.jsx)(M,{})})]}),e.length===0?(0,X.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,X.jsx)(be,{}),(0,X.jsx)(`span`,{children:n(`bgTasksEmpty`)}),(0,X.jsx)(`small`,{children:n(`bgTasksDesc`)})]}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:e.map(e=>{let t=!!e.taskId,i=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:n(`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:[n(`bgTaskPid`),` `,e.pid]}),(0,X.jsxs)(`span`,{children:[n(`bgTaskSince`),` `,Xh(e.since,n)]}),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 ${r.has(i)?`open`:``}`,title:`${n(`bgTaskCommand`)}: ${e.command}`,onClick:()=>a(i),children:[(0,X.jsx)(ee,{}),(0,X.jsx)(`code`,{children:e.command})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,title:n(`bgTaskStop`),onClick:()=>$(t?{type:`kill_background_server`,taskId:e.taskId}:{type:`kill_background_server`,port:e.port}),children:[(0,X.jsx)(z,{}),(0,X.jsx)(`span`,{children:n(`bgTaskStop`)})]})]},i)})}),(0,X.jsxs)(`div`,{className:`bg-task-foot`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:n(`bgTaskRefresh`),onClick:()=>$({type:`list_bg_servers`}),children:[(0,X.jsx)(oe,{}),(0,X.jsx)(`span`,{children:n(`bgTaskRefresh`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stopall`,disabled:e.length===0,title:n(`bgTaskStopAll`),onClick:()=>$({type:`kill_background_servers`}),children:[(0,X.jsx)(z,{}),(0,X.jsx)(`span`,{children:n(`bgTaskStopAll`)})]})]})]})}var Qh=3,$h=200;function eg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tg(e){return typeof e==`string`&&e.trim()||void 0}function ng(e,t){let n=[];for(let r of e){let e=ig(r,t);if(n.includes(e)||n.push(e),n.length>=4){n.push(`…`);break}}return n.join(` | `)||`any`}function rg(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 ig(e,t=0){if(t>6||!eg(e))return`any`;if(tg(e.$ref))return`ref`;let n=tg(e.type);if(n===`array`){let n=e.items;return`array<${n===void 0?`any`:ig(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 ng(r,t+1)}return eg(e.properties)?`object`:eg(e.additionalProperties)?`record<${ig(e.additionalProperties,t+1)}>`:`any`}function ag(e){let t=[],n=e.enum;if(Array.isArray(n)&&n.length>0){let e=rg(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 og(e,t={}){let n=t.maxDepth??Qh,r=t.maxRows??$h,i=e;if(!eg(i))return[];let a=i.properties;if(!eg(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=eg(l)?l:{},u=t?`${t}.${s}`:s,d={name:u,type:ig(e,i),required:a.has(s),depth:i},f=tg(e.description);f&&(d.description=f);let p=ag(e);if(p&&(d.hint=p),o.push(d),i+1<n&&eg(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 sg(){let e=Z(),t=ga();return(0,f.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&fa()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),t?(0,D.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:fa,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)(Se,{}),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:fa,children:(0,X.jsx)(M,{})})]}),(0,X.jsx)(`div`,{className:`tool-info-body`,children:(0,X.jsx)(cg,{info:t})})]})}),document.body):null}function cg({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?[]:og(e.parameters),r=e.parameters===void 0?``:ug(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)(lg,{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)(ec,{text:r})]}),(0,X.jsx)(`pre`,{children:r})]})]}),(0,X.jsx)(`div`,{className:`tool-info-foot`,children:t(`toolInfoFootnote`)})]})}function lg({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 ug(e){try{return JSON.stringify(e,null,2)??``}catch{return``}}function dg(e,t){return e.toLowerCase().includes(t)}function fg({open:e,projects:t,fileSearch:n,sessionSearch:r,onClose:i,onSwitchSession:a,onSwitchProject:o,onPreviewFile:s}){let c=Z(),{locale:l}=Ut(),u=l===`en`?`Plugins`:`插件`,d=hi(`cwd`),p=(0,f.useRef)(null),[m,h]=(0,f.useState)(``),g=(0,f.useDeferredValue)(m),[_,v]=(0,f.useState)(0),y=(0,f.useRef)(1),b=(0,f.useRef)(0),x=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!e)return;$({type:`list_sessions`}),$({type:`list_projects`});let t=m.trim();if(t){let e=++y.current;b.current=e,C(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}requestAnimationFrame(()=>p.current?.select())},[e]);let[S,C]=(0,f.useState)(!1);(0,f.useEffect)(()=>{x.current&&clearTimeout(x.current);let e=g.trim();if(!e){C(!1);return}return x.current=setTimeout(()=>{let t=++y.current;b.current=t,C(!0),$({type:`search_files`,reqId:t,query:e}),$({type:`search_sessions`,reqId:t,query:e})},300),()=>{x.current&&clearTimeout(x.current)}},[g]);let w=g.trim().toLowerCase(),T=(0,f.useMemo)(()=>!w||!r||r.reqId!==b.current||!r.ok?[]:r.results,[r,w]),E=(0,f.useMemo)(()=>w?t.filter(e=>dg(e.path,w)).slice(0,10):[],[t,w]),D=(0,f.useMemo)(()=>!w||!n||n.reqId!==b.current||!n.ok?[]:n.results,[n,w]);(0,f.useEffect)(()=>{n&&n.reqId===b.current&&r&&r.reqId===b.current&&b.current!==0&&C(!1)},[n,r]);let O=!!n&&n.ok&&n.truncated,[k,A]=(0,f.useState)([]);(0,f.useEffect)(()=>{if(!e)return;let t=g.trim();if(!t){A([]);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 Ra==`function`&&(r=Ra())}catch{r=[]}let i=r.filter(e=>e&&typeof e.id==`string`).map(e=>{if(typeof e.search==`function`)return e;try{let t=Ua(e.id);return t&&typeof t.search==`function`?{...e,search:t.search}:null}catch{return null}}).filter(e=>!!e);if(i.length===0){A([]);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})}A(t.slice(0,20))}),()=>{n=!0}},[e,g]);let j=(0,f.useMemo)(()=>[...T.map(e=>({kind:`session`,path:e.path,anchors:e.anchors})),...E.map(e=>({kind:`project`,path:e.path})),...D.filter(e=>e.type===`file`).map(e=>({kind:`file`,path:e.path,name:e.name})),...k.map(e=>({kind:`plugin`,providerId:e.providerId,providerLabel:e.providerLabel,title:e.title,action:e.action}))],[T,E,D,k]);(0,f.useEffect)(()=>{v(0)},[g]);let N=(0,f.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=g.trim();if(t){let e=++y.current;b.current=e,C(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}}else e.kind===`plugin`?Ea(e.providerId,e.action,e.action).catch(()=>{}):s(e.path,e.name)}},[a,o,s,g]);(0,f.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),i()):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.min(e+1,j.length-1))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),N(j[_]))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[j,_,N,i,e]);let P=T.length+E.length+D.length+k.length,F=(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})]}),I=-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)(H,{}),(0,X.jsx)(`input`,{ref:p,type:`text`,value:m,placeholder:c(`gsPlaceholder`),onChange:e=>h(e.target.value)}),(0,X.jsx)(`button`,{type:`button`,className:`gs-close`,title:c(`close`),onClick:i,children:(0,X.jsx)(M,{})})]}),(0,X.jsxs)(`div`,{className:`gs-results`,children:[!w&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(`gsHint`)}),w&&P===0&&!O&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(S?`gsSearching`:`gsNoResults`)}),T.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[F(c(`gsSessions`),T.length,(0,X.jsx)(me,{})),T.map(e=>{I++;let t=I,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:()=>N({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(),dn({attachments:[{path:``,key:`conv||${e.path}`,name:n,mode:`conversation`,sessionPath:e.path}]})},children:[`💬 `,c(`quoteConversationShort`)]})]},e.path)})]}),E.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[F(c(`gsProjects`),E.length,(0,X.jsx)(De,{})),E.map(e=>{I++;let t=I,n=d&&e.path===d;return(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,onMouseEnter:()=>v(t),onClick:()=>N({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)})]}),(D.length>0||w&&O)&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[F(c(`gsFiles`),D.length,(0,X.jsx)(ke,{})),D.map(e=>{I++;let t=I;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`&&N({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}`)}),O&&(0,X.jsx)(`div`,{className:`gs-truncated`,children:c(`gsTruncated`)})]}),k.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[F(u,k.length,(0,X.jsx)(ue,{})),k.map((e,t)=>{I++;let n=I;return(0,X.jsxs)(`button`,{type:`button`,className:n===_?`gs-item active`:`gs-item`,title:e.providerLabel,onMouseEnter:()=>v(n),onClick:()=>N({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 pg({entry:e,pluginView:t,onUiAction:n,onClose:r}){let i=Z(),a=e.label||e.id,o=e.kind===`view`;return(0,X.jsx)(Yh,{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)(nm,{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 mg=5e3;function hg({file:e,content:t,onAddLines:n,onAttach:r,onClose:i,uiFilePreviewToolbar:a,onUiAction:o}){let s=Z(),[c,l]=(0,f.useState)(null),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)(null),[h,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(!0),[T,E]=(0,f.useState)(!0),[D,O]=(0,f.useState)(!1),j=(0,f.useRef)(!1),[N,P]=(0,f.useState)(!0),[F,I]=(0,f.useState)(!1),[L,R]=(0,f.useState)(100),ee=(0,f.useRef)(0),te=(0,f.useRef)(!1),ne=(0,f.useRef)(null);(0,f.useEffect)(()=>{d(!0),l(null),m(null),b(!1),S(``),w(!0),E(!0),O(!1),j.current=!1,$({type:`read_file`,path:e.path})},[e.path]),(0,f.useEffect)(()=>{t&&t.path===e.path&&(l(t),y||S(t.text),d(!1))},[t,y,e.path]),(0,f.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){ue();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&y){e.preventDefault(),le();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(),ie())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,c,y,x]),(0,f.useEffect)(()=>{let e=()=>{te.current=!1,g(!1)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let z=(0,f.useMemo)(()=>{if(!c)return[];let e=c.text.split(`
364
- `);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,mg)},[c]),B=c?.lines??0,V=B>mg,re=(e,t)=>{if(t){let t=ee.current>0?ee.current:e;m({start:Math.min(t,e),end:Math.max(t,e)})}else ee.current=e,m({start:e,end:e})},ie=()=>{z.length!==0&&(ee.current=1,m({start:1,end:z.length}))},H=()=>{p&&(n(e.path,e.name,p.start,p.end),v(!0),ne.current&&clearTimeout(ne.current),ne.current=setTimeout(()=>v(!1),1400))},ae=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated,oe=()=>{S(c?.text??``),b(!1),j.current&&(gg(e.name)&&w(!0),_g(e.name)&&E(!0))},ce=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;oe();return}ae&&c&&(j.current=gg(e.name)&&C||_g(e.name)&&T,gg(e.name)&&w(!1),_g(e.name)&&E(!1),m(null),S(c.text),b(!0))},le=()=>{y&&c&&ae&&$({type:`write_file`,path:e.path,text:x})&&(b(!1),j.current&&(gg(e.name)&&w(!0),_g(e.name)&&E(!0)),m(null))},ue=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},de=e=>{R(Math.min(200,Math.max(50,e)))},fe=p?p.end-p.start+1:0,W=c?.binary??!1,me=c?.truncated??!1,G=c?.kind??`text`,ge=gg(e.name),_e=_g(e.name),ve=ge&&C&&!y&&G===`text`&&!W,ye=_e&&T&&!y&&G===`text`&&!W,be={"host:fp-md":ge&&G===`text`&&!W&&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)(Ae,{}):(0,X.jsx)(Re,{})}):null,"host:fp-html":_e&&G===`text`&&!W&&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)(Re,{}):(0,X.jsx)(Ae,{})}):null,"host:fp-edit":G===`text`&&!W&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(me?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!ae&&!y,onClick:ce,children:(0,X.jsx)(Me,{})}):null,"host:fp-wrap":G===`text`&&!W&&!ve&&!ye?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${N?`on`:``}`,"data-tip":s(N?`disableWrap`:`enableWrap`),onClick:()=>P(e=>!e),children:(0,X.jsx)(Ie,{})}):null,"host:fp-zoom":G===`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:L<=50,onClick:()=>de(L-10),children:(0,X.jsx)(k,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>R(100),children:[L,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:L>=200,onClick:()=>de(L+10),children:(0,X.jsx)(A,{})})]}):null,"host:fp-inline":G!==`video`&&G!==`none`?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach inline`,"data-tip":s(`attachInlineTip`),onClick:()=>r(e.path,e.name,`inline`),children:(0,X.jsx)(se,{})}):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)(K,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${F?`on`:``}`,"data-tip":s(F?`exitFullscreen`:`fullscreen`),onClick:()=>I(e=>!e),children:F?(0,X.jsx)(pe,{}):(0,X.jsx)(he,{})}),"host:fp-close":(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),onClick:ue,children:(0,X.jsx)(M,{})})},xe=a===void 0?[`host:fp-md`,`host:fp-html`,`host:fp-edit`,`host:fp-wrap`,`host:fp-zoom`,`host:fp-inline`,`host:fp-ref`,`host:fp-full`,`host:fp-close`].map(e=>({id:e,source:`host`})):a.filter(e=>!e.hidden),Se=e=>Et(St(`/api/file?clientId=${encodeURIComponent(is())}&path=${encodeURIComponent(e)}`));return(0,X.jsx)(`div`,{className:`fp-overlay ${F?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&ue()},children:(0,X.jsxs)(`div`,{className:`fp ${F?`fullscreen`:``}`,style:{"--fp-zoom":L/100},children:[(0,X.jsxs)(`div`,{className:`fp-head`,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&&G===`text`&&!W&&s(`fileLines`,{n:B}),c&&` · ${vg(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:Gd(xe,be,o)})]}),me&&G===`text`&&!W&&(0,X.jsx)(`div`,{className:`fp-notice`,children:s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&G===`none`&&!W&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&G===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`img`,{className:`fp-media`,src:Se(e.path),alt:e.name})}),!u&&G===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:Se(e.path),controls:!0,preload:`metadata`})}),!u&&ye&&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.jsx)(`iframe`,{className:`fp-html-frame`,src:(e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return Et(St(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(is())}${D?`&allowJs=1`:``}`))})(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&ve&&c&&(0,X.jsx)(`div`,{className:`fp-markdown msg-text`,children:(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,children:(0,X.jsx)(Hc,{text:c.text})})}),!u&&W&&G!==`image`&&G!==`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&&G===`text`&&!W&&c&&(0,X.jsx)(`textarea`,{className:`fp-editor ${N?``:`no-wrap`}`,value:x,onChange:e=>S(e.target.value),wrap:N?`soft`:`off`,spellCheck:!1,autoFocus:!0}),!u&&!ve&&!ye&&!y&&G===`text`&&!W&&c&&z.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!ve&&!ye&&!y&&G===`text`&&!W&&z.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${h?`dragging`:``} ${N?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[z.map((e,t)=>{let n=t+1,r=p!==null&&n>=p.start&&n<=p.end;return(0,X.jsxs)(`div`,{className:`fp-line ${r?`sel`:``}`,onMouseDown:e=>{e.button===0&&(re(n,e.shiftKey),te.current=!0,g(!0))},onMouseEnter:()=>{te.current&&re(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),V&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:mg})})]}),(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:ce,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:x===(c?.text??``),onClick:le,children:[(0,X.jsx)(U,{}),` `,s(`saveFile`)]})]})]}):!ve&&!ye&&G===`text`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:p?s(`selectedRange`,{n:fe,start:p.start,end:p.end}):s(`selectLinesHint`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:z.length===0,onClick:ie,children:s(`selectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!p,onClick:()=>m(null),children:s(`clearSelection`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!p||W,onClick:H,children:[_?(0,X.jsx)(Ke,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function gg(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function _g(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function vg(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var yg=`pi-web-sounds`,bg={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function xg(){try{let e=localStorage.getItem(yg);if(!e)return{...bg};let t=JSON.parse(e),n={...bg,...t};for(let e of[`enabled`,`question`,`done`,`start`,`error`])typeof n[e]!=`boolean`&&(n[e]=bg[e]);return n.volume=typeof n.volume!=`number`||!Number.isFinite(n.volume)?bg.volume:Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...bg}}}function Sg(e){try{localStorage.setItem(yg,JSON.stringify(e))}catch{}}var Cg=null;function wg(){try{if(!Cg){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Cg=new e}return Cg.state===`suspended`&&Cg.resume(),Cg}catch{return null}}var Tg={question:[{type:`sine`,freq:587.33,start:0,dur:.13,peak:.5},{type:`sine`,freq:880,start:.11,dur:.24,peak:.5}],done:[{type:`sine`,freq:880,start:0,dur:.15,peak:.35},{type:`sine`,freq:587.33,start:.15,dur:.32,peak:.35}],start:[{type:`triangle`,freq:660,start:0,dur:.08,peak:.22}],error:[{type:`square`,freq:220,start:0,dur:.16,peak:.18},{type:`square`,freq:174.61,start:.18,dur:.26,peak:.18}]};function Eg(e,t,n){let r=e.createOscillator(),i=e.createGain();r.type=t.type,r.frequency.value=t.freq;let a=e.currentTime+t.start,o=Math.max(1e-4,t.peak*n);i.gain.setValueAtTime(1e-4,a),i.gain.exponentialRampToValueAtTime(o,a+.012),i.gain.exponentialRampToValueAtTime(1e-4,a+t.dur),r.connect(i),i.connect(e.destination),r.start(a),r.stop(a+t.dur+.05)}function Dg(e,t=xg()){if(!t.enabled||!t[e])return;let n=wg();if(!n)return;let r=Math.max(0,Math.min(1,t.volume/100));for(let t of Tg[e])Eg(n,t,r)}var Og=(0,f.lazy)(()=>so(()=>import(`./TerminalPanel-B-CMQuzm.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function kg({notice:e,onDismiss:t}){let n=Z(),{locale:r}=Ut(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,f.useState)(!1);(0,f.useEffect)(()=>{if(a)return;let n=setTimeout(()=>t(e.id),e.level===`error`?12e3:7e3);return()=>clearTimeout(n)},[a,e.id,e.level,t]);let s=e.level===`error`?rt:e.level===`warning`?nt:Se;return(0,X.jsxs)(`div`,{className:`notice notice-${e.level}${a?` paused`:``}`,role:`status`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),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:()=>t(e.id),children:(0,X.jsx)(M,{})})]})}var Ag=[],jg=180,Mg=520,Ng=240,Pg=e=>`pi-web-ui:${e}-panel-width`;function Fg(e){let t=Number(localStorage.getItem(Pg(e)));return Number.isFinite(t)&&t>=jg&&t<=Mg?t:Ng}var Ig=e=>`pi-web-ui:${e}-panel-collapsed`;function Lg(e){return localStorage.getItem(Ig(e))===`1`}function Rg({side:e,width:t,onResize:n}){let r=Z(),i=(0,f.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(Mg,Math.max(jg,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`),localStorage.setItem(Pg(e),String(o))};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(Ng)})}function zg({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)(Ve,{}):(0,X.jsx)(He,{})})}var Bg=`pi-web-ui:plugin-path-grants`;function Vg(){try{let e=localStorage.getItem(Bg),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Hg(e){try{let t=[...new Set([...Vg(),e])];localStorage.setItem(Bg,JSON.stringify(t))}catch{}}function Ug(){let e=Z(),{locale:t}=Ut(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=ls(),s=(0,f.useRef)(!1);(0,f.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:Eh[t]??Eh.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=ih();(0,f.useEffect)(()=>{let t=l?Zm(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,f.useState)([]);(0,f.useEffect)(()=>(cn(e=>d(t=>Mf(t,e))),()=>cn(null)),[]);let[p,m]=(0,f.useState)(null),h=(0,f.useRef)(!1);(0,f.useEffect)(()=>{h.current=p!==null},[p]),(0,f.useEffect)(()=>(Ll({open:e=>m({path:e.path,name:e.name}),isOpen:()=>h.current}),()=>Ll(null)),[]);let[g,_]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=()=>_(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[v,y]=(0,f.useState)(`chat`),b=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(v.startsWith(`plugin:`)?`plugins`:v)?v:`chat`,x=(0,f.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),S=(0,f.useMemo)(()=>jr(br(n.plugins),{locale:t,t:t=>e(t),disabledPlugins:n.settings?.disabledPlugins??[],layout:n.settings?.uiLayout}),[n.plugins,n.settings?.disabledPlugins,n.settings?.uiLayout,t,e]),C=(0,f.useMemo)(()=>S[`topbar.primary`].filter(e=>!e.hidden),[S]),w=(0,f.useMemo)(()=>[...S[`topbar.primary`].filter(e=>e.hidden),...S[`topbar.overflow`]],[S]),T=(0,f.useMemo)(()=>S[`leftpanel.sessions`].filter(e=>!e.hidden),[S]),E=(0,f.useMemo)(()=>S[`terminal.toolbar`].filter(e=>!e.hidden),[S]),D=(0,f.useMemo)(()=>S[`scm.toolbar`].filter(e=>!e.hidden),[S]),O=(0,f.useMemo)(()=>S[`goalbar.actions`].filter(e=>!e.hidden),[S]),k=(0,f.useMemo)(()=>S[`chat.header`].filter(e=>!e.hidden),[S]),A=(0,f.useMemo)(()=>S[`chat.empty`].filter(e=>!e.hidden),[S]),j=(0,f.useMemo)(()=>S[`file.preview.toolbar`].filter(e=>!e.hidden),[S]),N=(0,f.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(e=>[e.id,e.name??e.id])),[n.dshPresets]),P=(0,f.useMemo)(()=>S[`notice.actions`].filter(e=>!e.hidden),[S]),F=(0,f.useCallback)((t,n,r)=>{let i=(t.action??``).trim();if(t.kind===`view`||(!i||i===`view`)&&t.source!==`host`){y(t.view??`plugin:${t.source.startsWith(`plugin:`)?t.source.slice(7):``}`);return}i&&Ea(t.source.startsWith(`plugin:`)?t.source.slice(7):``,i,t.id,{...n===void 0?{}:{value:n},...r===void 0?{}:{target:r},loadBundle:async e=>{let t=V.current.plugins.find(t=>t.id===e);return t?ko(t,V.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[I,L]=(0,f.useState)([]);(0,f.useEffect)(()=>Co(L),[]);let[R,ee]=(0,f.useState)([]);(0,f.useEffect)(()=>xo(ee),[]);let[te,ne]=(0,f.useState)(null),z=te?S[`modal.dialog`].find(e=>e.id===te&&!e.hidden):void 0,B=(0,f.useMemo)(()=>{if(!z||z.kind!==`view`)return``;let e=z.view??``;return e.startsWith(`plugin:`)?e.slice(7):z.source.startsWith(`plugin:`)?z.source.slice(7):``},[z]);(0,f.useEffect)(()=>{if(!z||!B||I.some(e=>e.info.id===B))return;let e=V.current.plugins.find(e=>e.id===B);e&&ko(e,V.current.pluginsEpoch)},[z,B,I,n.pluginsEpoch]),(0,f.useEffect)(()=>{gc(r),_c(x,n.pluginsEpoch),wc(x,n.pluginsEpoch),Ao(x,n.pluginsEpoch)},[x,n.pluginsEpoch,r]);let V=(0,f.useRef)(n);V.current=n;let re=(0,f.useRef)(y);re.current=y;let ie=(0,f.useRef)(S);ie.current=S,(0,f.useEffect)(()=>(xa(ba({send:r,isReady:()=>!!V.current.state,setView:e=>re.current(e),getCwd:()=>V.current.state?.cwd??``,getWorkspaceRoots:()=>V.current.state?.workspaceRoots??[],listSessions:()=>{let e=V.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:()=>V.current.state?.conversationId??null,isConversationBlank:()=>(V.current.state?.messages.length??0)===0,listModels:()=>V.current.models.map(e=>({id:e.id,provider:e.provider,name:e.name,vision:e.vision,reasoning:e.reasoning})),getCurrentModelId:()=>{let e=V.current.state?.model;return e?`${e.provider}/${e.id}`:null},listProjects:()=>V.current.projects.map(e=>e.path),grantedPaths:Vg,grantPath:Hg,confirm:e=>new Promise(t=>we({path:e.path,resolve:t})),openModal:e=>{let t=String(e??``).trim();if(!t)return!1;let n=ie.current[`modal.dialog`].find(e=>e.id===t);return!n||n.hidden?!1:(ne(t),!0)},closeModal:()=>ne(null),dialogConfirm:e=>new Promise(t=>{if(Ee.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Ee.current=n,J(n)}),select:e=>new Promise(t=>{if(Ee.current){t({ok:!1,error:`busy`});return}let n={kind:`select`,title:e.title,options:e.options,...e.multi?{multi:!0}:{},resolve:t};Ee.current=n,Y([]),J(n)}),input:e=>new Promise(t=>{if(Ee.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};Ee.current=n,ke(e.initial??``),J(n)}),notifyAction:e=>new Promise(t=>{try{let n=Me.current;Me.current=null,je(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Me.current=r,je(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=V.current.plugins.find(t=>t.id===e);return t?ko(t,V.current.pluginsEpoch):Promise.resolve(!1)}})),()=>xa(null)),[r]);let[H,U]=(0,f.useState)(()=>Fg(`left`)),[ae,oe]=(0,f.useState)(()=>Fg(`right`)),se=(0,f.useCallback)(e=>U(e),[]),ce=(0,f.useCallback)(e=>oe(e),[]),[le,ue]=(0,f.useState)(()=>Lg(`left`)),[de,fe]=(0,f.useState)(()=>Lg(`right`)),pe=(0,f.useCallback)(()=>{ue(e=>(localStorage.setItem(Ig(`left`),e?`0`:`1`),!e))},[]),W=(0,f.useCallback)(()=>{fe(e=>(localStorage.setItem(Ig(`right`),e?`0`:`1`),!e))},[]),[me,G]=(0,f.useState)(null),[he,ge]=(0,f.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,f.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>ge(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[_e,ve]=(0,f.useState)(!1),[ye,K]=(0,f.useState)(!1),[be,xe]=(0,f.useState)(!1),[Se,Ce]=(0,f.useState)(),[q,we]=(0,f.useState)(null),[Te,J]=(0,f.useState)(null),Ee=(0,f.useRef)(null),[De,Y]=(0,f.useState)([]),[Oe,ke]=(0,f.useState)(``),[Ae,je]=(0,f.useState)(null),Me=(0,f.useRef)(null),[Ne,Pe]=(0,f.useState)(()=>new Set),Fe=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),Pe(t=>new Set(t).add(e))},Ie=n.pathRequests.find(e=>!Ne.has(e.id))??null,[Le,Re]=(0,f.useState)(()=>new Set),ze=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),Re(t=>new Set(t).add(e))},Be=n.permRequests.find(e=>!Le.has(e.id))??null,Ve=qm(),[He,Ue]=(0,f.useState)(!1),[We,Ge]=(0,f.useState)(!1),[Ke,qe]=(0,f.useState)(null);(0,f.useEffect)(()=>{if(!Ke)return;let e=setTimeout(()=>qe(null),15e3);return()=>clearTimeout(e)},[Ke]),(0,f.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=ot();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})}y(`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,f.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),Ge(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[Je,Ye]=(0,f.useState)(xg),{themes:Xe,theme:Ze,switchTheme:Qe,reloadThemes:$e}=Fc();Ch(),(0,f.useEffect)(()=>{try{typeof $a==`function`&&$a(Ze??``)}catch{}},[Ze]),(0,f.useEffect)(()=>{try{typeof eo==`function`&&eo(t)}catch{}},[t]),(0,f.useEffect)(()=>{try{typeof to==`function`&&to(b)}catch{}},[b]),(0,f.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof Ya==`function`&&Ya(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,f.useEffect)(()=>{if(!Te)return;let e=e=>{if(e.key!==`Escape`)return;let t=Ee.current;Ee.current=null,J(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)},[Te]),(0,f.useEffect)(()=>{if(!Ae)return;let e=setTimeout(()=>{let e=Me.current;Me.current=null,je(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[Ae]);let et=(0,f.useRef)(null),tt=(0,f.useRef)(null),nt=(0,f.useRef)(null),rt=(0,f.useRef)(null),it=(0,f.useRef)(new Set),at=(0,f.useRef)(0),st=(0,f.useRef)(!1),ct=(0,f.useRef)(n.terminals);(0,f.useEffect)(()=>{Sg(Je)},[Je]),(0,f.useEffect)(()=>{let e=ct.current;ct.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,f.useEffect)(()=>{let t=n.state?.isStreaming??!1,r=et.current;et.current=t,r!==null&&(!r&&t?Dg(`start`,Je):r&&!t&&(Dg(`done`,Je),Xn(e(`notifyDoneTitle`),e(`notifyDoneBody`))))},[n.state?.isStreaming,Je]),(0,f.useEffect)(()=>{let t=n.dialog?.id??null;t!==null&&t!==tt.current&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),tt.current=t},[n.dialog,Je]),(0,f.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null;t!==null&&t!==nt.current&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),r!==null&&r!==rt.current&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),nt.current=t,rt.current=r;let i=new Set(n.conversations.filter(e=>e.hasQuestion).map(e=>e.id));[...i].some(e=>!it.current.has(e))&&t===null&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),it.current=i},[n.question,n.remoteQuestion,n.conversations,Je]),(0,f.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==at.current&&(at.current=t.id,Dg(`error`,Je),Xn(e(`notifyErrorTitle`),e(`notifyErrorBody`)))},[n.notices,Je]);let lt=(0,f.useRef)(new Set);(0,f.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||lt.current.has(t.id))continue;lt.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{document.hasFocus()&&(n=window.open(St(e),`_blank`,`noopener`))}catch{n=null}n||a(`info`,e)}},[n.state?.messages,a]);let ut=(e,t,n,r=!1,i)=>{let a=`${e}|${n}|${i?`${i.start}-${i.end}`:``}`;d(o=>o.some(e=>`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`===a)?o:[...o,{path:e,name:t,mode:n,isDir:r,...i?{lines:i}:{}}])},dt=e=>d(t=>t.filter(t=>t.key?t.key!==e:t.mode===`conversation`?`conv|${t.conversationId??``}|${t.sessionPath??``}`!==e:t.path!==e)),ft=(0,f.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&G(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&y(e=>e===`chat`?e:`chat`),r(e)),[r]),pt=(0,f.useRef)(new Set),mt=n.activeConversationId||n.state?.conversationId||``;(0,f.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 pt.current)i.has(e)||pt.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===mt){fm(t);continue}n.questionId&&pt.current.has(n.questionId)||dm({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&&pt.current.add(n.questionId)},onClick:()=>{ft({type:`switch_conversation`,id:n.id}),fm(t),n.questionId&&pt.current.add(n.questionId)}})}pm(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===mt:!1})},[n.conversations,mt,ft,e]);let ht=(0,f.useRef)(0),gt=(0,f.useRef)(0),_t=t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-gt.current>1e4&&(gt.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++ht.current}`;d(e=>[...e,{path:``,key:i,name:t.name,mode:`inline`,imageData:t.data,mimeType:t.mimeType}])},vt=async t=>{for(let n of t){let t=await mu(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}_t(t)}},yt=20971520,bt=(0,f.useRef)(0),xt=async t=>{if(t.size>yt){a(`warning`,e(`fileTooLarge`,{name:t.name,size:yt/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-${++bt.current}`;d(e=>[...e,{path:``,key:r,name:t.name,mode:`inline`,fileData:n,size:t.size,mimeType:t.type||void 0}])},Ct=async e=>{for(let t of e)pu(t.type)?await vt([t]):await xt(t)},wt=(0,f.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),Tt=(0,f.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[Et,Dt]=(0,f.useState)([]),Ot=(0,f.useRef)(0),kt=(0,f.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),Ot.current+=1;let i={text:t,seq:Ot.current};Dt(e=>[...e.slice(-9),i])},[r]),At=(0,f.useCallback)(()=>K(!0),[]),jt=(0,f.useCallback)(()=>d([]),[]),Mt=(0,f.useCallback)(dt,[]),Nt=(0,f.useCallback)(vt,[vt]),Pt=(0,f.useCallback)(Ct,[Ct]),Ft=(0,f.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),It=(0,f.useCallback)(e=>ut(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines),[]),Lt=n.state?.model,Rt=n.state?.thinkingLevel,zt=n.state?.availableThinkingLevels,Bt=(0,f.useMemo)(()=>Lt?{model:Lt,thinkingLevel:Rt??`off`,availableThinkingLevels:zt??[]}:null,[Lt,Rt,zt]),Vt=(0,f.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:ot(),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,f.useEffect)(()=>{if(st.current){if(b!==`terminal`||n.terminals.length!==0){st.current=!1;return}Vt()&&(st.current=!1)}},[n.terminals.length,Vt,b]),(0,X.jsxs)(`div`,{className:`app`,"data-pi-anchor":`app`,onDragOver:e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),_(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||_(!1)},onDrop:t=>{if(_(!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=>pu(e.type)),i=n.filter(e=>!pu(e.type));r.length>0&&vt(r),i.length>0&&Ct(i)},children:[g&&(0,X.jsx)(`div`,{className:`app-drop-overlay`,"aria-hidden":!0,children:(0,X.jsxs)(`span`,{children:[`📎 `,e(`dropHereToAttach`)]})}),(0,X.jsx)(Ui,{chat:n,terminal:o,view:b,plugins:x,uiPrimary:C,uiOverflow:w,uiContextTopbar:S[`contextmenu.topbar`],onUiAction:F,onViewChange:e=>{st.current=e===`terminal`&&n.terminals.length===0,st.current&&Vt()&&(st.current=!1),y(e),G(null)},onOpenPanel:G,onOpenSettings:()=>{Ce(void 0),xe(!0)},onManagePlugins:()=>{Ce(`plugins`),xe(!0)},onOpenBgTasks:()=>Ue(!0),onOpenGlobalSearch:()=>Ge(!0),sound:Je,onSoundChange:Ye,onSoundPreview:e=>Dg(e,Je),themes:Xe,theme:Ze,onThemeChange:Qe,reloadThemes:$e}),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)(kg,{notice:e,onDismiss:i},e.id)),Ae&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:Ae.text}),Ae.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Me.current;Me.current=null,je(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=Me.current;Me.current=null,je(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(M,{})})]}),P.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:P.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=>F(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:()=>F(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)(Rd,{currentModelId:Lt?`${Lt.provider}/${Lt.id}`:null,children:(0,X.jsxs)(`div`,{className:`layout`,style:{"--left-w":`${H}px`,"--right-w":`${ae}px`},children:[me&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>G(null)}),(0,X.jsxs)(`div`,{className:`view-pane ${b===`chat`?``:`hidden`}`,children:[!he&&le&&(0,X.jsx)(zg,{side:`left`,onClick:pe}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${me===`left`?`open`:``}${he?``:le?` hidden`:``}`,children:(0,X.jsx)(ia,{collapsible:!he,onToggleCollapse:pe,panelSend:ft,active:!he||me===`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:S[`contextmenu.session`],uiLeftSessions:T,onUiAction:F,presetNames:N})}),!he&&(0,X.jsx)(Rg,{side:`left`,width:H,onResize:se}),(0,X.jsxs)(`main`,{className:Ve?`main wide-chat`:`main`,children:[k.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:Ud(k,F)}),n.state?(0,X.jsx)(Of,{uiMessageActions:S[`message.actions`],uiContextMessage:S[`contextmenu.message`],uiContextToolCall:S[`contextmenu.toolcall`],uiChatEmpty:A,onUiAction:F,state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:wt,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&Ad(`${e.provider}/${e.id}`)}},onRemoveQueued:Tt,onRecallQueued:kt,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,jumpTarget:Ke,onJumpDone:()=>qe(null)},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)(Ep,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:O,onUiAction:F}),(0,X.jsx)(im,{onAction:(e,t,n)=>F(e,n,t)}),n.dialog&&(0,X.jsx)(Rp,{dialog:n.dialog}),Te&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":Te.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),Te.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:Te.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),Te.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(Te.options??[]).map((e,t)=>{let n=Te.multi?De.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(Te.multi){Y(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Ee.current;Ee.current=null,J(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)}),(Te.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),Te.multi&&(0,X.jsx)(`div`,{className:`dialog-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ee.current,t=(e?.options??[]).filter((e,t)=>De.includes(t)).map(e=>e.label);Ee.current=null,J(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),Te.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=Ee.current;Ee.current=null,J(null);try{e?.resolve(!1)}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),Te.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Oe,placeholder:Te.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>ke(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Ee.current;Ee.current=null,J(null);try{e?.resolve({ok:!0,value:Oe})}catch{}}}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.resolve({ok:!1})}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.resolve({ok:!0,value:Oe})}catch{}},children:e(`ok`)})]})]})]}),Be&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"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:()=>ze(Be.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[Be.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,Be.pluginId).replace(`{hosts}`,(Be.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,Be.pluginId).replace(`{models}`,(Be.models??[]).length>0?` ${(Be.models??[]).join(`, `)}`:``),Be.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Be.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ze(Be.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ze(Be.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>ze(Be.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),Ie&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"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:()=>Fe(Ie.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginGrantRequestBody`).replace(`{plugin}`,Ie.pluginId).replace(`{path}`,Ie.path),Ie.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Ie.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Fe(Ie.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>Fe(Ie.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),q&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"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:()=>{q.resolve(!1),we(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,q.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{q.resolve(!1),we(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{q.resolve(!0),we(null)},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(Vp,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||mt))?.title}),n.remoteQuestion&&(0,X.jsx)(Vp,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(Tp,{composerLeading:S[`composer.leading`],composerActions:S[`composer.actions`],onUiAction:F,streaming:n.state?.isStreaming??!1,messages:n.state?.messages??Ag,slashCommands:n.slashCommands,modelState:Bt,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:Mt,onAddImageFiles:Nt,onAddLocalFiles:Pt,onAddPathAttachment:It,fileSearch:n.fileSearch,onSearchFiles:Ft,onNotice:a,onManageModels:At,onSent:jt,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:Et,dshPermCurrent:n.engine===`dsh`?n.state?.permission??null:void 0,dshPermOptions:n.engine===`dsh`?n.dshPermission?.options??void 0:void 0,dshPermDefault:n.engine===`dsh`?n.dshPermission?.defaultPreset:void 0,dshPreset:n.engine===`dsh`?n.state?.agentPreset??null:void 0,dshPresets:n.engine===`dsh`?n.dshPresets?.presets??void 0:void 0,dshPresetDefault:n.engine===`dsh`?n.dshPresets?.defaultPreset:void 0,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??``})]}),!he&&(0,X.jsx)(Rg,{side:`right`,width:ae,onResize:ce}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${me===`right`?`open`:``}${he?``:de?` hidden`:``}`,children:(0,X.jsx)(Zs,{collapsible:!he,onToggleCollapse:W,panelSend:ft,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{G(null),ut(e,t,n,r)},onPreview:(e,t)=>{G(null),m({path:e,name:t})},onNotice:(e,t)=>a(e,t),uiRightPanelTabs:S[`rightpanel.tabs`],uiContextFile:S[`contextmenu.file`],plugins:x,pluginsEpoch:n.pluginsEpoch,send:r})}),!he&&de&&(0,X.jsx)(zg,{side:`right`,onClick:W})]}),(0,X.jsx)(`div`,{className:`view-pane ${b===`terminal`?``:`hidden`}`,children:(0,X.jsx)(f.Suspense,{fallback:null,children:(0,X.jsx)(Og,{chat:n,terminal:o,uiTerminalToolbar:E,onUiAction:F})})}),(0,X.jsx)(`div`,{className:`view-pane ${b===`git`?``:`hidden`}`,children:(0,X.jsx)(tm,{chat:n,terminal:o,active:b===`git`,onSwitchToTerminal:()=>y(`terminal`),uiScmToolbar:D,onUiAction:F})}),I.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${b===t?``:`hidden`}`,children:(0,X.jsx)(nm,{entry:e})},e.info.id)}),b.startsWith(`plugin:`)&&!I.some(e=>`plugin:${e.info.id}`===b)&&(0,X.jsx)(rm,{pluginId:b.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===b),epoch:n.pluginsEpoch,failed:R.includes(b.slice(7))})]})}),(0,X.jsx)(Fp,{chat:n,bottombarItems:S.bottombar,onUiAction:F}),p&&(0,X.jsx)(hg,{file:p,content:n.fileContent,onAddLines:(e,t,n,r)=>ut(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>ut(e,t,n),onClose:()=>m(null),uiFilePreviewToolbar:j,onUiAction:F}),n.ready&&n.state&&n.state.piConfigured===!1&&!_e&&!ye&&(0,X.jsx)(xm,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>ve(!0)}),ye&&(0,X.jsx)(Dm,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,fetchModelsResult:n.fetchModelsResult,enrichModelsResult:n.enrichModelsResult,enrichModelsProgress:n.enrichModelsProgress,refreshBuiltinResult:n.refreshBuiltinResult,appendBuiltinResult:n.appendBuiltinResult,cloneProviderResult:n.cloneProviderResult,onClose:()=>K(!1)}),be&&(0,X.jsx)(Wh,{chat:n,terminal:o,initialSection:Se,onSwitchToTerminal:()=>y(`terminal`),onClose:()=>xe(!1)}),He&&(0,X.jsx)(Zh,{servers:n.bgServers,onClose:()=>Ue(!1)}),(0,X.jsx)(sg,{}),z&&(0,X.jsx)(pg,{entry:z,pluginView:B?I.find(e=>e.info.id===B):void 0,onUiAction:(e,t)=>{F(e,t),ne(null)},onClose:()=>ne(null)}),(0,X.jsx)(fg,{open:We,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>Ge(!1),onSwitchSession:(e,t)=>{r({type:`switch_session`,path:e});let n=t&&t[0];qe(n?{path:e,role:n.role,timestamp:n.timestamp}:null)},onSwitchProject:e=>{r({type:`set_cwd`,path:e})},onPreviewFile:(e,t)=>{m({path:e,name:t})}}),(0,X.jsx)(ym,{})]})}function Wg(){typeof document<`u`&&(Gg(Kg()),Jg())}function Gg(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function Kg(){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 qg(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 Jg(){let e=()=>{let e=document.querySelector(`.messages`);return e?(Gg(qg(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)}wt(),Nc(jc()),Wg(),(0,O.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(f.StrictMode,{children:(0,X.jsx)(Ht,{children:(0,X.jsx)(Ug,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=bt();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,ot as c,ce as d,se as f,M as g,L as h,Ic as i,Ne as l,ee as m,Ud as n,Ut as o,oe as p,Ac as r,Z as s,Gd as t,G as u};
364
+ `);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,mg)},[c]),B=c?.lines??0,V=B>mg,re=(e,t)=>{if(t){let t=ee.current>0?ee.current:e;m({start:Math.min(t,e),end:Math.max(t,e)})}else ee.current=e,m({start:e,end:e})},ie=()=>{z.length!==0&&(ee.current=1,m({start:1,end:z.length}))},H=()=>{p&&(n(e.path,e.name,p.start,p.end),v(!0),ne.current&&clearTimeout(ne.current),ne.current=setTimeout(()=>v(!1),1400))},ae=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated,oe=()=>{S(c?.text??``),b(!1),j.current&&(gg(e.name)&&w(!0),_g(e.name)&&E(!0))},ce=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;oe();return}ae&&c&&(j.current=gg(e.name)&&C||_g(e.name)&&T,gg(e.name)&&w(!1),_g(e.name)&&E(!1),m(null),S(c.text),b(!0))},le=()=>{y&&c&&ae&&$({type:`write_file`,path:e.path,text:x})&&(b(!1),j.current&&(gg(e.name)&&w(!0),_g(e.name)&&E(!0)),m(null))},ue=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},de=e=>{R(Math.min(200,Math.max(50,e)))},fe=p?p.end-p.start+1:0,W=c?.binary??!1,me=c?.truncated??!1,G=c?.kind??`text`,ge=gg(e.name),_e=_g(e.name),ve=ge&&C&&!y&&G===`text`&&!W,ye=_e&&T&&!y&&G===`text`&&!W,be={"host:fp-md":ge&&G===`text`&&!W&&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)(Ae,{}):(0,X.jsx)(Re,{})}):null,"host:fp-html":_e&&G===`text`&&!W&&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)(Re,{}):(0,X.jsx)(Ae,{})}):null,"host:fp-edit":G===`text`&&!W&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(me?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!ae&&!y,onClick:ce,children:(0,X.jsx)(Me,{})}):null,"host:fp-wrap":G===`text`&&!W&&!ve&&!ye?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${N?`on`:``}`,"data-tip":s(N?`disableWrap`:`enableWrap`),onClick:()=>P(e=>!e),children:(0,X.jsx)(Ie,{})}):null,"host:fp-zoom":G===`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:L<=50,onClick:()=>de(L-10),children:(0,X.jsx)(k,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>R(100),children:[L,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:L>=200,onClick:()=>de(L+10),children:(0,X.jsx)(A,{})})]}):null,"host:fp-inline":G!==`video`&&G!==`none`?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach inline`,"data-tip":s(`attachInlineTip`),onClick:()=>r(e.path,e.name,`inline`),children:(0,X.jsx)(se,{})}):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)(K,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${F?`on`:``}`,"data-tip":s(F?`exitFullscreen`:`fullscreen`),onClick:()=>I(e=>!e),children:F?(0,X.jsx)(pe,{}):(0,X.jsx)(he,{})}),"host:fp-close":(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),onClick:ue,children:(0,X.jsx)(M,{})})},xe=a===void 0?[`host:fp-md`,`host:fp-html`,`host:fp-edit`,`host:fp-wrap`,`host:fp-zoom`,`host:fp-inline`,`host:fp-ref`,`host:fp-full`,`host:fp-close`].map(e=>({id:e,source:`host`})):a.filter(e=>!e.hidden),Se=e=>Et(St(`/api/file?clientId=${encodeURIComponent(is())}&path=${encodeURIComponent(e)}`));return(0,X.jsx)(`div`,{className:`fp-overlay ${F?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&ue()},children:(0,X.jsxs)(`div`,{className:`fp ${F?`fullscreen`:``}`,style:{"--fp-zoom":L/100},children:[(0,X.jsxs)(`div`,{className:`fp-head`,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&&G===`text`&&!W&&s(`fileLines`,{n:B}),c&&` · ${vg(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:Gd(xe,be,o)})]}),me&&G===`text`&&!W&&(0,X.jsx)(`div`,{className:`fp-notice`,children:s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&G===`none`&&!W&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&G===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`img`,{className:`fp-media`,src:Se(e.path),alt:e.name})}),!u&&G===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:Se(e.path),controls:!0,preload:`metadata`})}),!u&&ye&&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.jsx)(`iframe`,{className:`fp-html-frame`,src:(e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return Et(St(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(is())}${D?`&allowJs=1`:``}`))})(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&ve&&c&&(0,X.jsx)(`div`,{className:`fp-markdown msg-text`,children:(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,children:(0,X.jsx)(Hc,{text:c.text})})}),!u&&W&&G!==`image`&&G!==`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&&G===`text`&&!W&&c&&(0,X.jsx)(`textarea`,{className:`fp-editor ${N?``:`no-wrap`}`,value:x,onChange:e=>S(e.target.value),wrap:N?`soft`:`off`,spellCheck:!1,autoFocus:!0}),!u&&!ve&&!ye&&!y&&G===`text`&&!W&&c&&z.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!ve&&!ye&&!y&&G===`text`&&!W&&z.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${h?`dragging`:``} ${N?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[z.map((e,t)=>{let n=t+1,r=p!==null&&n>=p.start&&n<=p.end;return(0,X.jsxs)(`div`,{className:`fp-line ${r?`sel`:``}`,onMouseDown:e=>{e.button===0&&(re(n,e.shiftKey),te.current=!0,g(!0))},onMouseEnter:()=>{te.current&&re(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),V&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:mg})})]}),(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:ce,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:x===(c?.text??``),onClick:le,children:[(0,X.jsx)(U,{}),` `,s(`saveFile`)]})]})]}):!ve&&!ye&&G===`text`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:p?s(`selectedRange`,{n:fe,start:p.start,end:p.end}):s(`selectLinesHint`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:z.length===0,onClick:ie,children:s(`selectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!p,onClick:()=>m(null),children:s(`clearSelection`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!p||W,onClick:H,children:[_?(0,X.jsx)(Ke,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function gg(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function _g(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function vg(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var yg=`pi-web-sounds`,bg={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function xg(){try{let e=localStorage.getItem(yg);if(!e)return{...bg};let t=JSON.parse(e),n={...bg,...t};for(let e of[`enabled`,`question`,`done`,`start`,`error`])typeof n[e]!=`boolean`&&(n[e]=bg[e]);return n.volume=typeof n.volume!=`number`||!Number.isFinite(n.volume)?bg.volume:Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...bg}}}function Sg(e){try{localStorage.setItem(yg,JSON.stringify(e))}catch{}}var Cg=null;function wg(){try{if(!Cg){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Cg=new e}return Cg.state===`suspended`&&Cg.resume(),Cg}catch{return null}}var Tg={question:[{type:`sine`,freq:587.33,start:0,dur:.13,peak:.5},{type:`sine`,freq:880,start:.11,dur:.24,peak:.5}],done:[{type:`sine`,freq:880,start:0,dur:.15,peak:.35},{type:`sine`,freq:587.33,start:.15,dur:.32,peak:.35}],start:[{type:`triangle`,freq:660,start:0,dur:.08,peak:.22}],error:[{type:`square`,freq:220,start:0,dur:.16,peak:.18},{type:`square`,freq:174.61,start:.18,dur:.26,peak:.18}]};function Eg(e,t,n){let r=e.createOscillator(),i=e.createGain();r.type=t.type,r.frequency.value=t.freq;let a=e.currentTime+t.start,o=Math.max(1e-4,t.peak*n);i.gain.setValueAtTime(1e-4,a),i.gain.exponentialRampToValueAtTime(o,a+.012),i.gain.exponentialRampToValueAtTime(1e-4,a+t.dur),r.connect(i),i.connect(e.destination),r.start(a),r.stop(a+t.dur+.05)}function Dg(e,t=xg()){if(!t.enabled||!t[e])return;let n=wg();if(!n)return;let r=Math.max(0,Math.min(1,t.volume/100));for(let t of Tg[e])Eg(n,t,r)}var Og=(0,f.lazy)(()=>so(()=>import(`./TerminalPanel-MVoxpJOA.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function kg({notice:e,onDismiss:t}){let n=Z(),{locale:r}=Ut(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,f.useState)(!1);(0,f.useEffect)(()=>{if(a)return;let n=setTimeout(()=>t(e.id),e.level===`error`?12e3:7e3);return()=>clearTimeout(n)},[a,e.id,e.level,t]);let s=e.level===`error`?rt:e.level===`warning`?nt:Se;return(0,X.jsxs)(`div`,{className:`notice notice-${e.level}${a?` paused`:``}`,role:`status`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),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:()=>t(e.id),children:(0,X.jsx)(M,{})})]})}var Ag=[],jg=180,Mg=520,Ng=240,Pg=e=>`pi-web-ui:${e}-panel-width`;function Fg(e){let t=Number(localStorage.getItem(Pg(e)));return Number.isFinite(t)&&t>=jg&&t<=Mg?t:Ng}var Ig=e=>`pi-web-ui:${e}-panel-collapsed`;function Lg(e){return localStorage.getItem(Ig(e))===`1`}function Rg({side:e,width:t,onResize:n}){let r=Z(),i=(0,f.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(Mg,Math.max(jg,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`),localStorage.setItem(Pg(e),String(o))};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(Ng)})}function zg({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)(Ve,{}):(0,X.jsx)(He,{})})}var Bg=`pi-web-ui:plugin-path-grants`;function Vg(){try{let e=localStorage.getItem(Bg),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Hg(e){try{let t=[...new Set([...Vg(),e])];localStorage.setItem(Bg,JSON.stringify(t))}catch{}}function Ug(){let e=Z(),{locale:t}=Ut(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=ls(),s=(0,f.useRef)(!1);(0,f.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:Eh[t]??Eh.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=ih();(0,f.useEffect)(()=>{let t=l?Zm(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,f.useState)([]);(0,f.useEffect)(()=>(cn(e=>d(t=>Mf(t,e))),()=>cn(null)),[]);let[p,m]=(0,f.useState)(null),h=(0,f.useRef)(!1);(0,f.useEffect)(()=>{h.current=p!==null},[p]),(0,f.useEffect)(()=>(Ll({open:e=>m({path:e.path,name:e.name}),isOpen:()=>h.current}),()=>Ll(null)),[]);let[g,_]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=()=>_(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[v,y]=(0,f.useState)(`chat`),b=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(v.startsWith(`plugin:`)?`plugins`:v)?v:`chat`,x=(0,f.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),S=(0,f.useMemo)(()=>jr(br(n.plugins),{locale:t,t:t=>e(t),disabledPlugins:n.settings?.disabledPlugins??[],layout:n.settings?.uiLayout}),[n.plugins,n.settings?.disabledPlugins,n.settings?.uiLayout,t,e]),C=(0,f.useMemo)(()=>S[`topbar.primary`].filter(e=>!e.hidden),[S]),w=(0,f.useMemo)(()=>[...S[`topbar.primary`].filter(e=>e.hidden),...S[`topbar.overflow`]],[S]),T=(0,f.useMemo)(()=>S[`leftpanel.sessions`].filter(e=>!e.hidden),[S]),E=(0,f.useMemo)(()=>S[`terminal.toolbar`].filter(e=>!e.hidden),[S]),D=(0,f.useMemo)(()=>S[`scm.toolbar`].filter(e=>!e.hidden),[S]),O=(0,f.useMemo)(()=>S[`goalbar.actions`].filter(e=>!e.hidden),[S]),k=(0,f.useMemo)(()=>S[`chat.header`].filter(e=>!e.hidden),[S]),A=(0,f.useMemo)(()=>S[`chat.empty`].filter(e=>!e.hidden),[S]),j=(0,f.useMemo)(()=>S[`file.preview.toolbar`].filter(e=>!e.hidden),[S]),N=(0,f.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(e=>[e.id,e.name??e.id])),[n.dshPresets]),P=(0,f.useMemo)(()=>S[`notice.actions`].filter(e=>!e.hidden),[S]),F=(0,f.useCallback)((t,n,r)=>{let i=(t.action??``).trim();if(t.kind===`view`||(!i||i===`view`)&&t.source!==`host`){y(t.view??`plugin:${t.source.startsWith(`plugin:`)?t.source.slice(7):``}`);return}i&&Ea(t.source.startsWith(`plugin:`)?t.source.slice(7):``,i,t.id,{...n===void 0?{}:{value:n},...r===void 0?{}:{target:r},loadBundle:async e=>{let t=V.current.plugins.find(t=>t.id===e);return t?ko(t,V.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[I,L]=(0,f.useState)([]);(0,f.useEffect)(()=>Co(L),[]);let[R,ee]=(0,f.useState)([]);(0,f.useEffect)(()=>xo(ee),[]);let[te,ne]=(0,f.useState)(null),z=te?S[`modal.dialog`].find(e=>e.id===te&&!e.hidden):void 0,B=(0,f.useMemo)(()=>{if(!z||z.kind!==`view`)return``;let e=z.view??``;return e.startsWith(`plugin:`)?e.slice(7):z.source.startsWith(`plugin:`)?z.source.slice(7):``},[z]);(0,f.useEffect)(()=>{if(!z||!B||I.some(e=>e.info.id===B))return;let e=V.current.plugins.find(e=>e.id===B);e&&ko(e,V.current.pluginsEpoch)},[z,B,I,n.pluginsEpoch]),(0,f.useEffect)(()=>{gc(r),_c(x,n.pluginsEpoch),wc(x,n.pluginsEpoch),Ao(x,n.pluginsEpoch)},[x,n.pluginsEpoch,r]);let V=(0,f.useRef)(n);V.current=n;let re=(0,f.useRef)(y);re.current=y;let ie=(0,f.useRef)(S);ie.current=S,(0,f.useEffect)(()=>(xa(ba({send:r,isReady:()=>!!V.current.state,setView:e=>re.current(e),getCwd:()=>V.current.state?.cwd??``,getWorkspaceRoots:()=>V.current.state?.workspaceRoots??[],listSessions:()=>{let e=V.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:()=>V.current.state?.conversationId??null,isConversationBlank:()=>(V.current.state?.messages.length??0)===0,listModels:()=>V.current.models.map(e=>({id:e.id,provider:e.provider,name:e.name,vision:e.vision,reasoning:e.reasoning})),getCurrentModelId:()=>{let e=V.current.state?.model;return e?`${e.provider}/${e.id}`:null},listProjects:()=>V.current.projects.map(e=>e.path),grantedPaths:Vg,grantPath:Hg,confirm:e=>new Promise(t=>we({path:e.path,resolve:t})),openModal:e=>{let t=String(e??``).trim();if(!t)return!1;let n=ie.current[`modal.dialog`].find(e=>e.id===t);return!n||n.hidden?!1:(ne(t),!0)},closeModal:()=>ne(null),dialogConfirm:e=>new Promise(t=>{if(Ee.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Ee.current=n,J(n)}),select:e=>new Promise(t=>{if(Ee.current){t({ok:!1,error:`busy`});return}let n={kind:`select`,title:e.title,options:e.options,...e.multi?{multi:!0}:{},resolve:t};Ee.current=n,Y([]),J(n)}),input:e=>new Promise(t=>{if(Ee.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};Ee.current=n,ke(e.initial??``),J(n)}),notifyAction:e=>new Promise(t=>{try{let n=Me.current;Me.current=null,je(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Me.current=r,je(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=V.current.plugins.find(t=>t.id===e);return t?ko(t,V.current.pluginsEpoch):Promise.resolve(!1)}})),()=>xa(null)),[r]);let[H,U]=(0,f.useState)(()=>Fg(`left`)),[ae,oe]=(0,f.useState)(()=>Fg(`right`)),se=(0,f.useCallback)(e=>U(e),[]),ce=(0,f.useCallback)(e=>oe(e),[]),[le,ue]=(0,f.useState)(()=>Lg(`left`)),[de,fe]=(0,f.useState)(()=>Lg(`right`)),pe=(0,f.useCallback)(()=>{ue(e=>(localStorage.setItem(Ig(`left`),e?`0`:`1`),!e))},[]),W=(0,f.useCallback)(()=>{fe(e=>(localStorage.setItem(Ig(`right`),e?`0`:`1`),!e))},[]),[me,G]=(0,f.useState)(null),[he,ge]=(0,f.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,f.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>ge(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[_e,ve]=(0,f.useState)(!1),[ye,K]=(0,f.useState)(!1),[be,xe]=(0,f.useState)(!1),[Se,Ce]=(0,f.useState)(),[q,we]=(0,f.useState)(null),[Te,J]=(0,f.useState)(null),Ee=(0,f.useRef)(null),[De,Y]=(0,f.useState)([]),[Oe,ke]=(0,f.useState)(``),[Ae,je]=(0,f.useState)(null),Me=(0,f.useRef)(null),[Ne,Pe]=(0,f.useState)(()=>new Set),Fe=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),Pe(t=>new Set(t).add(e))},Ie=n.pathRequests.find(e=>!Ne.has(e.id))??null,[Le,Re]=(0,f.useState)(()=>new Set),ze=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),Re(t=>new Set(t).add(e))},Be=n.permRequests.find(e=>!Le.has(e.id))??null,Ve=qm(),[He,Ue]=(0,f.useState)(!1),[We,Ge]=(0,f.useState)(!1),[Ke,qe]=(0,f.useState)(null);(0,f.useEffect)(()=>{if(!Ke)return;let e=setTimeout(()=>qe(null),15e3);return()=>clearTimeout(e)},[Ke]),(0,f.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=ot();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})}y(`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,f.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),Ge(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[Je,Ye]=(0,f.useState)(xg),{themes:Xe,theme:Ze,switchTheme:Qe,reloadThemes:$e}=Fc();Ch(),(0,f.useEffect)(()=>{try{typeof $a==`function`&&$a(Ze??``)}catch{}},[Ze]),(0,f.useEffect)(()=>{try{typeof eo==`function`&&eo(t)}catch{}},[t]),(0,f.useEffect)(()=>{try{typeof to==`function`&&to(b)}catch{}},[b]),(0,f.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof Ya==`function`&&Ya(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,f.useEffect)(()=>{if(!Te)return;let e=e=>{if(e.key!==`Escape`)return;let t=Ee.current;Ee.current=null,J(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)},[Te]),(0,f.useEffect)(()=>{if(!Ae)return;let e=setTimeout(()=>{let e=Me.current;Me.current=null,je(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[Ae]);let et=(0,f.useRef)(null),tt=(0,f.useRef)(null),nt=(0,f.useRef)(null),rt=(0,f.useRef)(null),it=(0,f.useRef)(new Set),at=(0,f.useRef)(0),st=(0,f.useRef)(!1),ct=(0,f.useRef)(n.terminals);(0,f.useEffect)(()=>{Sg(Je)},[Je]),(0,f.useEffect)(()=>{let e=ct.current;ct.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,f.useEffect)(()=>{let t=n.state?.isStreaming??!1,r=et.current;et.current=t,r!==null&&(!r&&t?Dg(`start`,Je):r&&!t&&(Dg(`done`,Je),Xn(e(`notifyDoneTitle`),e(`notifyDoneBody`))))},[n.state?.isStreaming,Je]),(0,f.useEffect)(()=>{let t=n.dialog?.id??null;t!==null&&t!==tt.current&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),tt.current=t},[n.dialog,Je]),(0,f.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null;t!==null&&t!==nt.current&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),r!==null&&r!==rt.current&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),nt.current=t,rt.current=r;let i=new Set(n.conversations.filter(e=>e.hasQuestion).map(e=>e.id));[...i].some(e=>!it.current.has(e))&&t===null&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),it.current=i},[n.question,n.remoteQuestion,n.conversations,Je]),(0,f.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==at.current&&(at.current=t.id,Dg(`error`,Je),Xn(e(`notifyErrorTitle`),e(`notifyErrorBody`)))},[n.notices,Je]);let lt=(0,f.useRef)(new Set);(0,f.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||lt.current.has(t.id))continue;lt.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{document.hasFocus()&&(n=window.open(St(e),`_blank`,`noopener`))}catch{n=null}n||a(`info`,e)}},[n.state?.messages,a]);let ut=(e,t,n,r=!1,i)=>{let a=`${e}|${n}|${i?`${i.start}-${i.end}`:``}`;d(o=>o.some(e=>`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`===a)?o:[...o,{path:e,name:t,mode:n,isDir:r,...i?{lines:i}:{}}])},dt=e=>d(t=>t.filter(t=>t.key?t.key!==e:t.mode===`conversation`?`conv|${t.conversationId??``}|${t.sessionPath??``}`!==e:t.path!==e)),ft=(0,f.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&G(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&y(e=>e===`chat`?e:`chat`),r(e)),[r]),pt=(0,f.useRef)(new Set),mt=n.activeConversationId||n.state?.conversationId||``;(0,f.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 pt.current)i.has(e)||pt.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===mt){fm(t);continue}n.questionId&&pt.current.has(n.questionId)||dm({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&&pt.current.add(n.questionId)},onClick:()=>{ft({type:`switch_conversation`,id:n.id}),fm(t),n.questionId&&pt.current.add(n.questionId)}})}pm(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===mt:!1})},[n.conversations,mt,ft,e]);let ht=(0,f.useRef)(0),gt=(0,f.useRef)(0),_t=t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-gt.current>1e4&&(gt.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++ht.current}`;d(e=>[...e,{path:``,key:i,name:t.name,mode:`inline`,imageData:t.data,mimeType:t.mimeType}])},vt=async t=>{for(let n of t){let t=await mu(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}_t(t)}},yt=20971520,bt=(0,f.useRef)(0),xt=async t=>{if(t.size>yt){a(`warning`,e(`fileTooLarge`,{name:t.name,size:yt/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-${++bt.current}`;d(e=>[...e,{path:``,key:r,name:t.name,mode:`inline`,fileData:n,size:t.size,mimeType:t.type||void 0}])},Ct=async e=>{for(let t of e)pu(t.type)?await vt([t]):await xt(t)},wt=(0,f.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),Tt=(0,f.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[Et,Dt]=(0,f.useState)([]),Ot=(0,f.useRef)(0),kt=(0,f.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),Ot.current+=1;let i={text:t,seq:Ot.current};Dt(e=>[...e.slice(-9),i])},[r]),At=(0,f.useCallback)(()=>K(!0),[]),jt=(0,f.useCallback)(()=>d([]),[]),Mt=(0,f.useCallback)(dt,[]),Nt=(0,f.useCallback)(vt,[vt]),Pt=(0,f.useCallback)(Ct,[Ct]),Ft=(0,f.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),It=(0,f.useCallback)(e=>ut(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines),[]),Lt=n.state?.model,Rt=n.state?.thinkingLevel,zt=n.state?.availableThinkingLevels,Bt=(0,f.useMemo)(()=>Lt?{model:Lt,thinkingLevel:Rt??`off`,availableThinkingLevels:zt??[]}:null,[Lt,Rt,zt]),Vt=(0,f.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:ot(),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,f.useEffect)(()=>{if(st.current){if(b!==`terminal`||n.terminals.length!==0){st.current=!1;return}Vt()&&(st.current=!1)}},[n.terminals.length,Vt,b]),(0,X.jsxs)(`div`,{className:`app`,"data-pi-anchor":`app`,onDragOver:e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),_(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||_(!1)},onDrop:t=>{if(_(!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=>pu(e.type)),i=n.filter(e=>!pu(e.type));r.length>0&&vt(r),i.length>0&&Ct(i)},children:[g&&(0,X.jsx)(`div`,{className:`app-drop-overlay`,"aria-hidden":!0,children:(0,X.jsxs)(`span`,{children:[`📎 `,e(`dropHereToAttach`)]})}),(0,X.jsx)(Ui,{chat:n,terminal:o,view:b,plugins:x,uiPrimary:C,uiOverflow:w,uiContextTopbar:S[`contextmenu.topbar`],onUiAction:F,onViewChange:e=>{st.current=e===`terminal`&&n.terminals.length===0,st.current&&Vt()&&(st.current=!1),y(e),G(null)},onOpenPanel:G,onOpenSettings:()=>{Ce(void 0),xe(!0)},onManagePlugins:()=>{Ce(`plugins`),xe(!0)},onOpenBgTasks:()=>Ue(!0),onOpenGlobalSearch:()=>Ge(!0),sound:Je,onSoundChange:Ye,onSoundPreview:e=>Dg(e,Je),themes:Xe,theme:Ze,onThemeChange:Qe,reloadThemes:$e}),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)(kg,{notice:e,onDismiss:i},e.id)),Ae&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:Ae.text}),Ae.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Me.current;Me.current=null,je(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=Me.current;Me.current=null,je(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(M,{})})]}),P.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:P.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=>F(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:()=>F(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)(Rd,{currentModelId:Lt?`${Lt.provider}/${Lt.id}`:null,children:(0,X.jsxs)(`div`,{className:`layout`,style:{"--left-w":`${H}px`,"--right-w":`${ae}px`},children:[me&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>G(null)}),(0,X.jsxs)(`div`,{className:`view-pane ${b===`chat`?``:`hidden`}`,children:[!he&&le&&(0,X.jsx)(zg,{side:`left`,onClick:pe}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${me===`left`?`open`:``}${he?``:le?` hidden`:``}`,children:(0,X.jsx)(ia,{collapsible:!he,onToggleCollapse:pe,panelSend:ft,active:!he||me===`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:S[`contextmenu.session`],uiLeftSessions:T,onUiAction:F,presetNames:N})}),!he&&(0,X.jsx)(Rg,{side:`left`,width:H,onResize:se}),(0,X.jsxs)(`main`,{className:Ve?`main wide-chat`:`main`,children:[k.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:Ud(k,F)}),n.state?(0,X.jsx)(Of,{uiMessageActions:S[`message.actions`],uiContextMessage:S[`contextmenu.message`],uiContextToolCall:S[`contextmenu.toolcall`],uiChatEmpty:A,onUiAction:F,state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:wt,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&Ad(`${e.provider}/${e.id}`)}},onRemoveQueued:Tt,onRecallQueued:kt,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,jumpTarget:Ke,onJumpDone:()=>qe(null)},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)(Ep,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:O,onUiAction:F}),(0,X.jsx)(im,{onAction:(e,t,n)=>F(e,n,t)}),n.dialog&&(0,X.jsx)(Rp,{dialog:n.dialog}),Te&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":Te.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),Te.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:Te.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),Te.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(Te.options??[]).map((e,t)=>{let n=Te.multi?De.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(Te.multi){Y(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Ee.current;Ee.current=null,J(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)}),(Te.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),Te.multi&&(0,X.jsx)(`div`,{className:`dialog-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ee.current,t=(e?.options??[]).filter((e,t)=>De.includes(t)).map(e=>e.label);Ee.current=null,J(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),Te.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=Ee.current;Ee.current=null,J(null);try{e?.resolve(!1)}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),Te.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Oe,placeholder:Te.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>ke(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Ee.current;Ee.current=null,J(null);try{e?.resolve({ok:!0,value:Oe})}catch{}}}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.resolve({ok:!1})}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.resolve({ok:!0,value:Oe})}catch{}},children:e(`ok`)})]})]})]}),Be&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"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:()=>ze(Be.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[Be.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,Be.pluginId).replace(`{hosts}`,(Be.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,Be.pluginId).replace(`{models}`,(Be.models??[]).length>0?` ${(Be.models??[]).join(`, `)}`:``),Be.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Be.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ze(Be.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ze(Be.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>ze(Be.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),Ie&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"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:()=>Fe(Ie.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginGrantRequestBody`).replace(`{plugin}`,Ie.pluginId).replace(`{path}`,Ie.path),Ie.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Ie.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Fe(Ie.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>Fe(Ie.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),q&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"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:()=>{q.resolve(!1),we(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,q.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{q.resolve(!1),we(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{q.resolve(!0),we(null)},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(Vp,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||mt))?.title}),n.remoteQuestion&&(0,X.jsx)(Vp,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(Tp,{composerLeading:S[`composer.leading`],composerActions:S[`composer.actions`],onUiAction:F,streaming:n.state?.isStreaming??!1,messages:n.state?.messages??Ag,slashCommands:n.slashCommands,modelState:Bt,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:Mt,onAddImageFiles:Nt,onAddLocalFiles:Pt,onAddPathAttachment:It,fileSearch:n.fileSearch,onSearchFiles:Ft,onNotice:a,onManageModels:At,onSent:jt,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:Et,dshPermCurrent:n.engine===`dsh`?n.state?.permission??null:void 0,dshPermOptions:n.engine===`dsh`?n.dshPermission?.options??void 0:void 0,dshPermDefault:n.engine===`dsh`?n.dshPermission?.defaultPreset:void 0,dshPreset:n.engine===`dsh`?n.state?.agentPreset??null:void 0,dshPresets:n.engine===`dsh`?n.dshPresets?.presets??void 0:void 0,dshPresetDefault:n.engine===`dsh`?n.dshPresets?.defaultPreset:void 0,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??``})]}),!he&&(0,X.jsx)(Rg,{side:`right`,width:ae,onResize:ce}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${me===`right`?`open`:``}${he?``:de?` hidden`:``}`,children:(0,X.jsx)(Zs,{collapsible:!he,onToggleCollapse:W,panelSend:ft,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{G(null),ut(e,t,n,r)},onPreview:(e,t)=>{G(null),m({path:e,name:t})},onNotice:(e,t)=>a(e,t),uiRightPanelTabs:S[`rightpanel.tabs`],uiContextFile:S[`contextmenu.file`],plugins:x,pluginsEpoch:n.pluginsEpoch,send:r})}),!he&&de&&(0,X.jsx)(zg,{side:`right`,onClick:W})]}),(0,X.jsx)(`div`,{className:`view-pane ${b===`terminal`?``:`hidden`}`,children:(0,X.jsx)(f.Suspense,{fallback:null,children:(0,X.jsx)(Og,{chat:n,terminal:o,uiTerminalToolbar:E,onUiAction:F})})}),(0,X.jsx)(`div`,{className:`view-pane ${b===`git`?``:`hidden`}`,children:(0,X.jsx)(tm,{chat:n,terminal:o,active:b===`git`,onSwitchToTerminal:()=>y(`terminal`),uiScmToolbar:D,onUiAction:F})}),I.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${b===t?``:`hidden`}`,children:(0,X.jsx)(nm,{entry:e})},e.info.id)}),b.startsWith(`plugin:`)&&!I.some(e=>`plugin:${e.info.id}`===b)&&(0,X.jsx)(rm,{pluginId:b.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===b),epoch:n.pluginsEpoch,failed:R.includes(b.slice(7))})]})}),(0,X.jsx)(Fp,{chat:n,bottombarItems:S.bottombar,onUiAction:F}),p&&(0,X.jsx)(hg,{file:p,content:n.fileContent,onAddLines:(e,t,n,r)=>ut(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>ut(e,t,n),onClose:()=>m(null),uiFilePreviewToolbar:j,onUiAction:F}),n.ready&&n.state&&n.state.piConfigured===!1&&!_e&&!ye&&(0,X.jsx)(xm,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>ve(!0)}),ye&&(0,X.jsx)(Dm,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,fetchModelsResult:n.fetchModelsResult,enrichModelsResult:n.enrichModelsResult,enrichModelsProgress:n.enrichModelsProgress,refreshBuiltinResult:n.refreshBuiltinResult,appendBuiltinResult:n.appendBuiltinResult,cloneProviderResult:n.cloneProviderResult,onClose:()=>K(!1)}),be&&(0,X.jsx)(Wh,{chat:n,terminal:o,initialSection:Se,onSwitchToTerminal:()=>y(`terminal`),onClose:()=>xe(!1)}),He&&(0,X.jsx)(Zh,{servers:n.bgServers,onClose:()=>Ue(!1)}),(0,X.jsx)(sg,{}),z&&(0,X.jsx)(pg,{entry:z,pluginView:B?I.find(e=>e.info.id===B):void 0,onUiAction:(e,t)=>{F(e,t),ne(null)},onClose:()=>ne(null)}),(0,X.jsx)(fg,{open:We,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>Ge(!1),onSwitchSession:(e,t)=>{r({type:`switch_session`,path:e});let n=t&&t[0];qe(n?{path:e,role:n.role,timestamp:n.timestamp}:null)},onSwitchProject:e=>{r({type:`set_cwd`,path:e})},onPreviewFile:(e,t)=>{m({path:e,name:t})}}),(0,X.jsx)(ym,{})]})}function Wg(){typeof document<`u`&&(Gg(Kg()),Jg())}function Gg(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function Kg(){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 qg(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 Jg(){let e=()=>{let e=document.querySelector(`.messages`);return e?(Gg(qg(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)}wt(),Nc(jc()),Wg(),(0,O.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(f.StrictMode,{children:(0,X.jsx)(Ht,{children:(0,X.jsx)(Ug,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=bt();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,ot as c,ce as d,se as f,M as g,L as h,Ic as i,Ne as l,ee as m,Ud as n,Ut as o,oe as p,Ac as r,Z as s,Gd as t,G as u};