pi-web-ui 0.96.0 → 0.96.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.
- package/CHANGELOG.md +22 -1
- package/dist/server/index.js +44 -19
- package/dist/server/plugin-installer.js +30 -0
- package/dist/server/settings-service.js +2 -2
- package/package.json +1 -1
- package/themes/zhupi-dark.css +74 -14
- package/themes/zhupi.css +74 -14
- package/web/dist/assets/{TerminalPanel-DDChcYOh.js → TerminalPanel-O3GyFIGG.js} +1 -1
- package/web/dist/assets/index-B7Zp23Vc.css +1 -0
- package/web/dist/assets/{index-Do9RgJC3.js → index-ByfoaDwp.js} +21 -21
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-DryOsILO.css +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from"./react-CR5VJ85Q.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p}from"./markdown-DXwnfD9T.js";(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 m=e(t(),1),h={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},g=m.createContext&&m.createContext(h),_=[`attr`,`size`,`title`];function v(e,t){if(e==null)return{};var n,r,i=y(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 y(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 b(){return b=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},b.apply(null,arguments)}function x(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 S(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?x(Object(n),!0).forEach(function(t){C(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function C(e,t,n){return(t=w(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){var t=T(e,`string`);return typeof t==`symbol`?t:t+``}function T(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 E(e){return e&&e.map((e,t)=>m.createElement(e.tag,S({key:t},e.attr),E(e.child)))}function D(e){return t=>m.createElement(O,b({attr:S({},e.attr)},t),E(e.child))}function O(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=v(e,_),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),m.createElement(`svg`,b({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:S(S({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&m.createElement(`title`,null,i),e.children)};return g===void 0?t(h):m.createElement(g.Consumer,null,e=>t(e))}var k=r(),A=n();function ee(e){return D({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 j(e){return D({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 M(e){return D({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 N(e){return D({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 P(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`},child:[]},{tag:`path`,attr:{d:`M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07`},child:[]}]})(e)}function F(e){return D({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 I(e){return D({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 L(e){return D({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 R(e){return D({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 te(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function z(e){return D({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 B(e){return D({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 V(e){return D({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 ne(e){return D({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 re(e){return D({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 H(e){return D({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 U(e){return D({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 W(e){return D({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 ie(e){return D({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 ae(e){return D({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 oe(e){return D({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 se(e){return D({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 ce(e){return D({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 le(e){return D({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 ue(e){return D({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 de(e){return D({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 fe(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`5`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`19`,r:`1`},child:[]}]})(e)}function pe(e){return D({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 me(e){return D({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 he(e){return D({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 ge(e){return D({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 G(e){return D({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 _e(e){return D({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 ve(e){return D({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 K(e){return D({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 q(e){return D({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 ye(e){return D({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 J(e){return D({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 be(e){return D({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 xe(e){return D({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 Se(e){return D({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 Ce(e){return D({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 we(e){return D({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 Te(e){return D({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 Ee(e){return D({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 De(e){return D({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 Oe(e){return D({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 ke(e){return D({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 D({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 Ae(e){return D({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 je(e){return D({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 Me(e){return D({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 Ne(e){return D({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 Pe(e){return D({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 Fe(e){return D({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 Ie(e){return D({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 Le(e){return D({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 Re(e){return D({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 ze(e){return D({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 Be(e){return D({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 Ve(e){return D({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 He(e){return D({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 Ue(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]}]})(e)}function We(e){return D({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 Ge(e){return D({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 Ke(e){return D({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 qe(e){return D({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 Je(e){return D({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 Ye(e){return D({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 Xe(e){return D({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 Ze(e){return D({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 Qe(e){return D({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 $e(e){return D({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 et(e){return D({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 tt(e){return D({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 nt(e){return D({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 rt(e){return D({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 it(e){return D({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 at(e){return D({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 ot(e){return D({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 st(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`22 12 18 12 15 21 9 3 6 12 2 12`},child:[]}]})(e)}function ct(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 17H7l-4 4v-7`},child:[]},{tag:`path`,attr:{d:`M14 17h1`},child:[]},{tag:`path`,attr:{d:`M14 3h1`},child:[]},{tag:`path`,attr:{d:`M19 3a2 2 0 0 1 2 2`},child:[]},{tag:`path`,attr:{d:`M21 14v1a2 2 0 0 1-2 2`},child:[]},{tag:`path`,attr:{d:`M21 9v1`},child:[]},{tag:`path`,attr:{d:`M3 9v1`},child:[]},{tag:`path`,attr:{d:`M5 3a2 2 0 0 0-2 2`},child:[]},{tag:`path`,attr:{d:`M9 3h1`},child:[]}]})(e)}function lt(e){return e.map(e=>e.kind===`package`?`pi update npm:${e.name}`:e.kind===`git-extension`?`pi update ${ut(e.source??e.name)}`:e.kind===`plugin`?`pi-web-ui install ${e.source??e.name} --name ${e.pluginId??e.name} --force`:`npm i -g ${e.name}@latest`).join(`; `)}function ut(e){return e.startsWith(`git:`)?e:`git:${e}`}function dt(){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 ft(e,t,n={}){let{enabled:r=!0,ignore:i}=n,a=(0,m.useRef)(t);(0,m.useLayoutEffect)(()=>{a.current=t}),(0,m.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 pt=[],mt=!1;function ht(e){if(e.key===`Escape`&&pt.length!==0)for(let t=pt.length-1;t>=0;t--){let n=pt[t];if(n()!==!1){e.preventDefault(),e.stopPropagation();break}}}function gt(){!mt&&typeof document<`u`&&(document.addEventListener(`keydown`,ht,!0),mt=!0)}function _t(){mt&&pt.length===0&&typeof document<`u`&&(document.removeEventListener(`keydown`,ht,!0),mt=!1)}function vt(e){return pt.push(e),gt(),()=>{let t=pt.lastIndexOf(e);t>=0&&pt.splice(t,1),_t()}}function yt(e,t=!0){let n=(0,m.useRef)(e);(0,m.useLayoutEffect)(()=>{n.current=e}),(0,m.useEffect)(()=>{if(t)return vt(()=>n.current())},[t])}var X=i();function bt({align:e,triggerLeft:t,triggerRight:n,menuWidth:r,viewportWidth:i,margin:a=8}){if(r<=0||i<=0)return 0;let o=e===`left`?t:n-r,s=Math.max(a,i-a-r);return Math.round(Math.max(a,Math.min(o,s))-o)}function xt({trigger:e,open:t,onOpenChange:n,children:r,align:i=`right`,fit:a=!1,direction:o=`down`,tip:s,menuClassName:c,triggerClassName:l,menuRef:u,menuStyle:d}){let f=(0,m.useRef)(null),p=(0,m.useRef)(null),[h,g]=(0,m.useState)(0),_=e=>{p.current=e,typeof u==`function`?u(e):u&&`current`in u&&(u.current=e)},v=()=>{let e=f.current,t=p.current;if(!e||!t)return;if(window.innerWidth<=768){h!==0&&g(0);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.width===0&&r.height===0||n.width===0){h!==0&&g(0);return}let a=n.width,o=bt({align:i,triggerLeft:r.left,triggerRight:r.right,menuWidth:a,viewportWidth:window.innerWidth,margin:8});o!==h&&g(o)};return(0,m.useLayoutEffect)(()=>{t?v():h!==0&&g(0)}),(0,m.useEffect)(()=>{if(t)return window.addEventListener(`resize`,v),()=>window.removeEventListener(`resize`,v)},[t,h]),ft(f,()=>n(!1),{enabled:t}),yt(()=>n(!1),t),(0,X.jsxs)(`div`,{className:`dropdown ${i} ${a?`fit`:``} ${o===`up`?`dd-up`:``}`,ref:f,children:[(0,X.jsxs)(`button`,{type:`button`,className:l??`chip`,onClick:()=>n(!t),"aria-expanded":t,"data-tip":s,children:[e,(0,X.jsx)(Je,{className:`dd-caret ${t?`up`:``}`})]}),t&&(0,X.jsx)(`div`,{className:`dd-menu ${c??``}`,ref:_,style:h===0?d:{...d,transform:d?.transform?`${d.transform} translateX(${h}px)`:`translateX(${h}px)`},children:r})]})}function St({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 Ct=`pi-web-tts`,wt={enabled:!1,announce:!0,readReplies:!1,rate:1,voiceURI:``};function Tt(){try{let e=localStorage.getItem(Ct);if(!e)return{...wt};let t={...wt,...JSON.parse(e)};for(let e of[`enabled`,`announce`,`readReplies`])typeof t[e]!=`boolean`&&(t[e]=wt[e]);return t.rate=typeof t.rate!=`number`||!Number.isFinite(t.rate)?wt.rate:Math.round(Math.max(.5,Math.min(2,t.rate))*10)/10,typeof t.voiceURI!=`string`&&(t.voiceURI=wt.voiceURI),t}catch{return{...wt}}}function Et(e){try{localStorage.setItem(Ct,JSON.stringify(e))}catch{}}function Dt(){return typeof window<`u`&&`speechSynthesis`in window}function Ot(e,t,n){if(e){let n=t.find(t=>t.voiceURI===e);if(n)return n}let r=n.split(`-`)[0]?.toLowerCase();return r?t.find(e=>e.lang.toLowerCase().startsWith(r))??null:null}function kt(e){let t=e??``;return t=t.replace(/```[\s\S]*?(?:```|$)/g,` `),t=t.replace(/`([^`]+)`/g,`$1`),t=t.replace(/!\[[^\]]*\]\([^)]*\)/g,` `),t=t.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`),t=t.replace(/^\s{0,3}#{1,6}\s+/gm,``),t=t.replace(/^\s{0,3}>\s?/gm,``),t=t.replace(/^\s*[-*+]\s+/gm,``),t=t.replace(/^\s*\|?[\s:|-]*\|[\s:|-]*$/gm,``),t=t.replace(/\|/g,` `),t=t.replace(/(\*\*\*|\*\*|__)(.*?)\1/g,`$2`),t=t.replace(/(\*|_)([^*_\n]+)\1/g,`$2`),t=t.replace(/<[^>]+>/g,` `),t=t.replace(/\r/g,``),t=t.replace(/[ \t]+/g,` `),t=t.replace(/\s*\n+\s*/g,` `),t=t.trim(),t.length>600&&(t=`${t.slice(0,600).trimEnd()}…`),t}function At(e){if(!Array.isArray(e))return``;for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.role===`assistant`)return kt((n.content??[]).filter(e=>e?.type===`text`&&typeof e.text==`string`).map(e=>e.text??``).join(`
|
|
3
|
-
`))}return``}var jt=!1,Mt=null,Nt=null,Pt=new Set;function Ft(e,t=null){e?(jt=!0,Mt=t):(jt=!1,Mt=null);for(let t of Pt)try{t(e)}catch{}}function It(){return jt}function Lt(){return jt?Mt:null}function Rt(e){return Pt.add(e),()=>Pt.delete(e)}function zt(e,t=Tt(),n){if(e&&Dt())try{let r=window.speechSynthesis;r.cancel();let i=new SpeechSynthesisUtterance(e);i.rate=t.rate;let a=Ot(t.voiceURI,r.getVoices(),navigator.language);a&&(i.voice=a),i.onend=()=>{Nt===i&&Ft(!1)},i.onerror=()=>{Nt===i&&Ft(!1)},Nt=i,Ft(!0,n??null),r.speak(i)}catch{Nt=null,Ft(!1)}}function Bt(){if(Dt()){try{window.speechSynthesis.cancel()}catch{}Nt=null,Ft(!1)}}var Vt=null;function Ht(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 Ut(){return Vt===null&&(Vt=Ht()),Vt}function Wt(e,t){return t===`/`?e:t+e.replace(/^\/+/,``)}function Gt(e){return Wt(e,Ut())}var Kt=`pi-web-ui:token`;function qt(){try{let e=new URL(window.location.href),t=e.searchParams.get(`token`);t&&(localStorage.setItem(Kt,t.trim()),e.searchParams.delete(`token`),window.history.replaceState(null,``,e.toString()))}catch{}}function Jt(){try{return localStorage.getItem(Kt)??``}catch{return``}}function Yt(e){let t=Jt();return t?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(t)}`:e}var Xt=[`zh`,`en`,`de`,`es`,`fr`,`it`,`ja`,`ko`,`pt`,`ru`];function Zt(e,t,n,r=Xt){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 Qt=`pi-web-ui:lang`,$t={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:`新对话`,newChatEphemeral:`临时对话`,newChatEphemeralTip:`临时对话(仅内存,关闭即销毁,不进历史记录)`,ephemeralBadge:`临时`,ephemeralBannerText:`当前为临时对话:消息仅保存在内存中,关闭后自动销毁,不进入历史记录。`,more:`更多`,brand:`品牌`,newChatTip:`新建对话(每个浏览器独立保存会话)`,"thinking.off":`关闭`,"thinking.minimal":`极简`,"thinking.low":`低`,"thinking.medium":`中`,"thinking.high":`高`,"thinking.xhigh":`极高`,"thinking.max":`最大`,thinkingUnsupported:`当前模型不支持该级别,已按模型能力就近生效`,context:`上下文`,contextUsage:`上下文用量`,cumulativeCost:`累计成本`,sessionMessages:`会话消息数`,messages:`消息`,pluginStatus:`插件状态`,engineBadge:`引擎`,working:`工作中`,queued:`排队`,enterPath:`输入路径,Enter 切换`,cwdTip:`工作目录:{path}(点击切换)`,manageProjects:`管理项目和工作目录`,projectPickerTitle:`选择工作目录`,newProject:`新建项目`,projectName:`项目名称`,createAndOpenProject:`创建并打开`,invalidProjectName:`请输入不含路径分隔符的项目名称`,cwdGoUp:`上级目录`,cwdPickCurrent:`选择当前目录`,cwdChoose:`选择`,cwdEnter:`进入`,cwdEmpty:`(空目录)`,cwdNewFolder:`新建文件夹`,cwdNewName:`文件夹名称`,cwdCreate:`创建`,cwdCancel:`取消`,cacheHit:`缓存命中`,cacheHitTip:`缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)`,tps:`t/s`,rateTip:`实时生成速率(估算)`,hostResources:`主机资源`,hostProcessor:`CPU`,hostMemory:`RAM`,hostResourcesTip:`运行 pi-web-ui 服务的主机 · CPU 为约 10 秒平均(2 秒采样),与任务管理器采样时刻不同会有几秒偏差`,folderRef:`文件夹引用:{path}`,refOnly:`仅引用:{path}`,attachContent:`附加内容:{path}`,attachLines:`附加选中行:{path}(第 {start}-{end} 行)`,attachImage:`图片:{name}`,attachFile:`文件:{name}`,removeAttachment:`移除附件`,attachHint:`将随下一条消息发送`,uploadFile:`添加文件(图片/文本/任意文件,也可直接拖入或粘贴截图)`,dropHereToAttach:`松开以添加文件`,imageNotSupported:`当前模型不支持识图:图片将交给视觉桥转写(若未配置视觉模型则可能被忽略)`,imageLoadFailed:`图片读取失败:{name}`,fileLoadFailed:`文件读取失败:{name}`,fileTooLarge:`文件过大已跳过(>{size}MB):{name}`,foldersNotSupported:`不支持直接拖入文件夹,请展开后选择文件`,placeholderStreaming:`智能体正在工作中…回车插队发送,或点「排队」等回答结束后发送`,placeholderStreamingQueued:`智能体正在工作中…回车或点「排队」,回答完全结束后发送(本引擎不支持插队)`,placeholderIdle:`给 pi 发送消息 — Enter 发送,/ 查看命令`,placeholderConnecting:`正在连接服务器…`,stopAgent:`停止智能体`,stop:`停止`,bgTasks:`后台任务`,bgTasksTip:`AI 在后台启动的服务(npm run dev & 等)——可逐个停止或全部关闭,对话结束后仍保留`,bgTasksEmpty:`暂无后台任务`,bgTasksDesc:`AI 运行中启动并仍在监听的进程(按监听端口检测)`,bgTaskPort:`端口`,bgTaskPid:`PID`,bgTaskSince:`启动`,bgTaskStop:`停止`,bgTaskStopAll:`全部关闭`,bgTaskRefresh:`刷新`,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:`在其他标签页 / 设备上打开的对话(运行中或已结束未关闭,右键可过户到本页查看)`,elsewhereActions:`操作(过户到本页 / 复制 id…)`,takeoverConversation:`过户到当前页面`,takeoverConfirm:`确认过户到当前页面?`,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:`固化为普通对话`,saveEphemeral:`保存为正式对话`,forceDismissConfirm:`确认强行关闭?未结束的运行将被中止,再点一次`,noFinishedSubagents:`没有可关闭的已结束子代理`,collapseSection:`折叠`,expandSection:`展开`,emptyChat:`空对话`,reaskDirectly:`直接重问`,reaskDirectlyTip:`直接从这里重新提问(不修改内容,新建分支对话,原对话保留)`,editReask:`编辑重问`,editReaskTip:`修改此问题,并从这里重新提问(会新建一个分支对话,原对话保留)`,forkSession:`派生分支`,forkSessionTip:`从此消息处派生新分支会话(截取该位置之前的转录)`,rollbackSession:`回滚到此`,rollbackSessionTip:`丢弃此消息之后的内容,在当前会话直接继续`,rollbackConfirm:`确定要回滚到此消息吗?该消息之后的所有对话将被丢弃,并在当前会话继续。`,rollbackRestoreWorkspace:`同时还原工作区物理文件(Dual-State Rollback)`,rollbackRestoreWorkspaceTip:`还原物理代码到该消息发起时的检查点版本(通过 Git 影子快照)`,toolApprovalTitle:`工具执行待审批(Human-in-the-Loop)`,toolApprovalApprove:`批准执行`,toolApprovalDeny:`拒绝`,toolApprovalEditAndRun:`修改并放行 (Edit & Run)`,toolApprovalRiskAlert:`检测到高危操作或关键配置修改`,toolApprovalCommand:`命令内容`,toolApprovalParams:`工具调用参数`,toolApprovalEditPlaceholder:`就地修改参数 JSON…`,toolApprovalReason:`拦截原因`,toolApprovalCategory:`规则档位`,toolApprovalAllowCategory:`本对话允许同类`,toolApprovalAllowCategoryHint:`本对话内这一类高危操作后续不再询问(设置 →「工具」页可撤销)`,toolApprovalAllowConversation:`本对话全部允许`,toolApprovalAllowConversationHint:`本对话内所有高危操作后续都不再询问(设置 →「工具」页可撤销)`,toolApprovalEnabled:`工具执行审批(人机协同)`,toolApprovalEnabledDesc:`开:高危操作(rm -rf / 破坏性 git / 敏感文件 / 工作区外写入 / 插件要求确认)弹窗等你批准、拒绝或改参数;关:一切审批都不弹(内置高危检测直接放行,插件要求确认也按放行处理)。`,toolApprovalPolicyTitle:`已记住的放行(本对话)`,toolApprovalPolicyAllowAll:`本对话全部允许审批`,toolApprovalPolicyRevoke:`撤销`,toolApprovalPolicyHint:`只存在内存里:重启服务或新对话即恢复询问;策略跟对话走(手动过户时一起搬)。`,settingsApprovalRules:`审批规则`,settingsApprovalRulesDesc:`全局自定义人机协同拦截规则,支持基于正则/通配符/路径对工具命令或参数配置「需审批」、「直接拒绝」或「免审放行」。规则自顶向下首条匹配优先。`,manageApprovalRules:`管理审批规则`,approvalRuleNew:`新增规则`,approvalRuleEdit:`编辑规则`,approvalRuleDelete:`删除`,approvalRuleReset:`恢复默认`,approvalRuleResetConfirm:`确认将该内置规则恢复为系统默认设定吗?`,approvalRuleDeleteConfirm:`确认删除该自定义审批规则吗?`,approvalRuleActionAsk:`需审批`,approvalRuleActionDeny:`直接拒绝`,approvalRuleActionAllow:`免审放行`,approvalRuleTools:`适用工具`,approvalRuleToolsTip:`输入工具名(如 bash、write、edit),以逗号分隔;输入 * 表示匹配所有工具`,approvalRuleField:`检查字段`,approvalRuleFieldCommand:`命令 (command)`,approvalRuleFieldPath:`文件路径 (path)`,approvalRuleFieldParams:`完整参数 JSON (params)`,approvalRuleMatch:`匹配方式`,approvalRuleMatchRegex:`正则表达式 (regex)`,approvalRuleMatchGlob:`通配符 (glob)`,approvalRuleMatchContains:`包含子串 (contains)`,approvalRuleMatchPrefix:`前缀开头 (prefix)`,approvalRuleMatchOutsideWs:`工作区外路径 (outside_workspace)`,approvalRuleValue:`匹配表达式 / 模式串`,approvalRuleValueTip:`根据匹配方式输入对应规则,例如 rm -rf 或 \\.env$`,approvalRuleLabel:`规则名称 (中文)`,approvalRuleLabelEn:`规则名称 (英文)`,approvalRuleReason:`拦截原因说明 (中文)`,approvalRuleReasonEn:`拦截原因说明 (英文)`,approvalRuleEnabled:`启用该规则`,approvalRuleBuiltin:`内置`,approvalRuleEmpty:`当前没有审批规则。点击右上角「+ 新增规则」添加自定义拦截与放行策略。`,approvalRuleMoveUp:`上移`,approvalRuleMoveDown:`下移`,planBoardTitle:`任务执行看板 (Plan Mode)`,planBoardSteps:`步骤清单`,planBoardProgress:`总体进度`,planBoardNoPlan:`暂无任务计划`,planBoardCompleted:`已完成`,planBoardInProgress:`进行中`,planBoardPending:`待执行`,planBoardFailed:`失败`,clear:`清空`,confirm:`确定`,forkBadge:`分支`,forkBadgeTip:`派生自`,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 组件`,kindPlugin:`插件`,pluginCheckUpdates:`检查插件更新`,pluginCheckUpdatesHint:`检查已安装界面插件是否有新版本(对比远端版本与 commit)`,pluginUpdateAvailableBadge:`可更新`,pluginUpdateAvailableDetail:`可更新:{version}`,pluginAllUpToDate:`所有插件均为最新版本`,updatesAllRefresh:`重新检查全部`,updateCheckFailed:`检查失败`,updateBtn:`更新`,updateAllBtn:`全部更新`,updatePkgTabTitle:`更新 {name}`,updateAllTabTitle:`更新全部组件`,piCoreSplitRun:`服务运行 v{running}`,piSdkSplitNote:`本服务运行的是 pi v{running};机器上装有更新的全局 pi v{installed}。重启服务即可跟上(默认自动选用更新的那份);设了 PI_WEB_SDK=bundled 时会一直用自带副本,升级 pi-web-ui 也可让自带副本跟上。`,piSdkBundledNote:`当前使用随包自带的 pi 引擎 v{running}(随 pi-web-ui 更新)。安装全局引擎后重启服务即可自动切换(服务默认跟随版本更高的那份)。`,installGlobalEngineBtn:`安装全局引擎`,installGlobalEngineTabTitle:`安装全局 pi 引擎`,restartService:`重启服务`,restartingService:`重启中…`,restartServiceTip:`重启 pi-web-ui 服务({name}):本实例由系统服务托管(launchd/systemd/Windows watchdog),进程退出后会被自动拉起,本页会自动重连;更新完成后用它生效`,computer:`此电脑`,rootDir:`根目录`,homeDir:`用户目录`,desktopDir:`桌面`,filesHelp:`浏览:点文件夹进入、点文件预览,「..」返回上级;「根目录」回当前项目根,「此电脑」浏览全盘换盘符,「🏠」直达用户目录,「🖥️」直达桌面。
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-O3GyFIGG.js","assets/rolldown-runtime-hePW80VL.js","assets/react-CR5VJ85Q.js","assets/xterm-Cf5xxe4g.js","assets/xterm-B1njb2Cr.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from"./react-CR5VJ85Q.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p}from"./markdown-DXwnfD9T.js";(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 m=e(t(),1),h={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},g=m.createContext&&m.createContext(h),_=[`attr`,`size`,`title`];function v(e,t){if(e==null)return{};var n,r,i=y(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 y(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 b(){return b=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},b.apply(null,arguments)}function x(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 S(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?x(Object(n),!0).forEach(function(t){C(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function C(e,t,n){return(t=w(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){var t=T(e,`string`);return typeof t==`symbol`?t:t+``}function T(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 E(e){return e&&e.map((e,t)=>m.createElement(e.tag,S({key:t},e.attr),E(e.child)))}function D(e){return t=>m.createElement(O,b({attr:S({},e.attr)},t),E(e.child))}function O(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=v(e,_),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),m.createElement(`svg`,b({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:S(S({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&m.createElement(`title`,null,i),e.children)};return g===void 0?t(h):m.createElement(g.Consumer,null,e=>t(e))}var k=r(),A=n();function ee(e){return D({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 j(e){return D({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 M(e){return D({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 N(e){return D({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 P(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`},child:[]},{tag:`path`,attr:{d:`M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07`},child:[]}]})(e)}function F(e){return D({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 I(e){return D({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 L(e){return D({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 R(e){return D({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 te(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function z(e){return D({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 B(e){return D({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 V(e){return D({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 ne(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function H(e){return D({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 U(e){return D({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 W(e){return D({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 G(e){return D({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 re(e){return D({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 ie(e){return D({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 D({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 D({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 D({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 D({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 D({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 D({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 D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`5`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`19`,r:`1`},child:[]}]})(e)}function fe(e){return D({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 pe(e){return D({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 me(e){return D({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 he(e){return D({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 K(e){return D({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 ge(e){return D({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 _e(e){return D({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 ve(e){return D({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 q(e){return D({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 ye(e){return D({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 J(e){return D({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 be(e){return D({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 xe(e){return D({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 Se(e){return D({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 Ce(e){return D({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 we(e){return D({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 Te(e){return D({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 Ee(e){return D({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 Y(e){return D({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 De(e){return D({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 Oe(e){return D({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 ke(e){return D({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 Ae(e){return D({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 je(e){return D({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 Me(e){return D({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 Ne(e){return D({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 Pe(e){return D({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 Fe(e){return D({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 Ie(e){return D({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 Le(e){return D({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 Re(e){return D({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 ze(e){return D({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 Be(e){return D({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 Ve(e){return D({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 He(e){return D({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 Ue(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]}]})(e)}function We(e){return D({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 Ge(e){return D({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 Ke(e){return D({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 qe(e){return D({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 Je(e){return D({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 Ye(e){return D({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 Xe(e){return D({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 Ze(e){return D({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 Qe(e){return D({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 $e(e){return D({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 et(e){return D({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 tt(e){return D({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 nt(e){return D({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 rt(e){return D({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 it(e){return D({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 at(e){return D({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 ot(e){return D({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 st(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`22 12 18 12 15 21 9 3 6 12 2 12`},child:[]}]})(e)}function ct(e){return D({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 17H7l-4 4v-7`},child:[]},{tag:`path`,attr:{d:`M14 17h1`},child:[]},{tag:`path`,attr:{d:`M14 3h1`},child:[]},{tag:`path`,attr:{d:`M19 3a2 2 0 0 1 2 2`},child:[]},{tag:`path`,attr:{d:`M21 14v1a2 2 0 0 1-2 2`},child:[]},{tag:`path`,attr:{d:`M21 9v1`},child:[]},{tag:`path`,attr:{d:`M3 9v1`},child:[]},{tag:`path`,attr:{d:`M5 3a2 2 0 0 0-2 2`},child:[]},{tag:`path`,attr:{d:`M9 3h1`},child:[]}]})(e)}function lt(e){return e.map(e=>e.kind===`package`?`pi update npm:${e.name}`:e.kind===`git-extension`?`pi update ${ut(e.source??e.name)}`:e.kind===`plugin`?`pi-web-ui install ${e.source??e.name} --name ${e.pluginId??e.name} --force`:`npm i -g ${e.name}@latest`).join(`; `)}function ut(e){return e.startsWith(`git:`)?e:`git:${e}`}function dt(){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 ft(e,t,n={}){let{enabled:r=!0,ignore:i}=n,a=(0,m.useRef)(t);(0,m.useLayoutEffect)(()=>{a.current=t}),(0,m.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 pt=[],mt=!1;function ht(e){if(e.key===`Escape`&&pt.length!==0)for(let t=pt.length-1;t>=0;t--){let n=pt[t];if(n()!==!1){e.preventDefault(),e.stopPropagation();break}}}function gt(){!mt&&typeof document<`u`&&(document.addEventListener(`keydown`,ht,!0),mt=!0)}function _t(){mt&&pt.length===0&&typeof document<`u`&&(document.removeEventListener(`keydown`,ht,!0),mt=!1)}function vt(e){return pt.push(e),gt(),()=>{let t=pt.lastIndexOf(e);t>=0&&pt.splice(t,1),_t()}}function yt(e,t=!0){let n=(0,m.useRef)(e);(0,m.useLayoutEffect)(()=>{n.current=e}),(0,m.useEffect)(()=>{if(t)return vt(()=>n.current())},[t])}var X=i();function bt({align:e,triggerLeft:t,triggerRight:n,menuWidth:r,viewportWidth:i,margin:a=8}){if(r<=0||i<=0)return 0;let o=e===`left`?t:n-r,s=Math.max(a,i-a-r);return Math.round(Math.max(a,Math.min(o,s))-o)}function xt({trigger:e,open:t,onOpenChange:n,children:r,align:i=`right`,fit:a=!1,direction:o=`down`,tip:s,menuClassName:c,triggerClassName:l,menuRef:u,menuStyle:d}){let f=(0,m.useRef)(null),p=(0,m.useRef)(null),[h,g]=(0,m.useState)(0),_=e=>{p.current=e,typeof u==`function`?u(e):u&&`current`in u&&(u.current=e)},v=()=>{let e=f.current,t=p.current;if(!e||!t)return;if(window.innerWidth<=768){h!==0&&g(0);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.width===0&&r.height===0||n.width===0){h!==0&&g(0);return}let a=n.width,o=bt({align:i,triggerLeft:r.left,triggerRight:r.right,menuWidth:a,viewportWidth:window.innerWidth,margin:8});o!==h&&g(o)};return(0,m.useLayoutEffect)(()=>{t?v():h!==0&&g(0)}),(0,m.useEffect)(()=>{if(t)return window.addEventListener(`resize`,v),()=>window.removeEventListener(`resize`,v)},[t,h]),ft(f,()=>n(!1),{enabled:t}),yt(()=>n(!1),t),(0,X.jsxs)(`div`,{className:`dropdown ${i} ${a?`fit`:``} ${o===`up`?`dd-up`:``}`,ref:f,children:[(0,X.jsxs)(`button`,{type:`button`,className:l??`chip`,onClick:()=>n(!t),"aria-expanded":t,"data-tip":s,children:[e,(0,X.jsx)(Je,{className:`dd-caret ${t?`up`:``}`})]}),t&&(0,X.jsx)(`div`,{className:`dd-menu ${c??``}`,ref:_,style:h===0?d:{...d,transform:d?.transform?`${d.transform} translateX(${h}px)`:`translateX(${h}px)`},children:r})]})}function St({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 Ct=`pi-web-tts`,wt={enabled:!1,announce:!0,readReplies:!1,rate:1,voiceURI:``};function Tt(){try{let e=localStorage.getItem(Ct);if(!e)return{...wt};let t={...wt,...JSON.parse(e)};for(let e of[`enabled`,`announce`,`readReplies`])typeof t[e]!=`boolean`&&(t[e]=wt[e]);return t.rate=typeof t.rate!=`number`||!Number.isFinite(t.rate)?wt.rate:Math.round(Math.max(.5,Math.min(2,t.rate))*10)/10,typeof t.voiceURI!=`string`&&(t.voiceURI=wt.voiceURI),t}catch{return{...wt}}}function Et(e){try{localStorage.setItem(Ct,JSON.stringify(e))}catch{}}function Dt(){return typeof window<`u`&&`speechSynthesis`in window}function Ot(e,t,n){if(e){let n=t.find(t=>t.voiceURI===e);if(n)return n}let r=n.split(`-`)[0]?.toLowerCase();return r?t.find(e=>e.lang.toLowerCase().startsWith(r))??null:null}function kt(e){let t=e??``;return t=t.replace(/```[\s\S]*?(?:```|$)/g,` `),t=t.replace(/`([^`]+)`/g,`$1`),t=t.replace(/!\[[^\]]*\]\([^)]*\)/g,` `),t=t.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`),t=t.replace(/^\s{0,3}#{1,6}\s+/gm,``),t=t.replace(/^\s{0,3}>\s?/gm,``),t=t.replace(/^\s*[-*+]\s+/gm,``),t=t.replace(/^\s*\|?[\s:|-]*\|[\s:|-]*$/gm,``),t=t.replace(/\|/g,` `),t=t.replace(/(\*\*\*|\*\*|__)(.*?)\1/g,`$2`),t=t.replace(/(\*|_)([^*_\n]+)\1/g,`$2`),t=t.replace(/<[^>]+>/g,` `),t=t.replace(/\r/g,``),t=t.replace(/[ \t]+/g,` `),t=t.replace(/\s*\n+\s*/g,` `),t=t.trim(),t.length>600&&(t=`${t.slice(0,600).trimEnd()}…`),t}function At(e){if(!Array.isArray(e))return``;for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.role===`assistant`)return kt((n.content??[]).filter(e=>e?.type===`text`&&typeof e.text==`string`).map(e=>e.text??``).join(`
|
|
3
|
+
`))}return``}var jt=!1,Mt=null,Nt=null,Pt=new Set;function Ft(e,t=null){e?(jt=!0,Mt=t):(jt=!1,Mt=null);for(let t of Pt)try{t(e)}catch{}}function It(){return jt}function Lt(){return jt?Mt:null}function Rt(e){return Pt.add(e),()=>Pt.delete(e)}function zt(e,t=Tt(),n){if(e&&Dt())try{let r=window.speechSynthesis;r.cancel();let i=new SpeechSynthesisUtterance(e);i.rate=t.rate;let a=Ot(t.voiceURI,r.getVoices(),navigator.language);a&&(i.voice=a),i.onend=()=>{Nt===i&&Ft(!1)},i.onerror=()=>{Nt===i&&Ft(!1)},Nt=i,Ft(!0,n??null),r.speak(i)}catch{Nt=null,Ft(!1)}}function Bt(){if(Dt()){try{window.speechSynthesis.cancel()}catch{}Nt=null,Ft(!1)}}var Vt=null;function Ht(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 Ut(){return Vt===null&&(Vt=Ht()),Vt}function Wt(e,t){return t===`/`?e:t+e.replace(/^\/+/,``)}function Gt(e){return Wt(e,Ut())}var Kt=`pi-web-ui:token`;function qt(){try{let e=new URL(window.location.href),t=e.searchParams.get(`token`);t&&(localStorage.setItem(Kt,t.trim()),e.searchParams.delete(`token`),window.history.replaceState(null,``,e.toString()))}catch{}}function Jt(){try{return localStorage.getItem(Kt)??``}catch{return``}}function Yt(e){let t=Jt();return t?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(t)}`:e}var Xt=[`zh`,`en`,`de`,`es`,`fr`,`it`,`ja`,`ko`,`pt`,`ru`];function Zt(e,t,n,r=Xt){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 Qt=`pi-web-ui:lang`,$t={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:`新对话`,newChatEphemeral:`临时对话`,newChatEphemeralTip:`临时对话(仅内存,关闭即销毁,不进历史记录)`,ephemeralBadge:`临时`,ephemeralBannerText:`当前为临时对话:消息仅保存在内存中,关闭后自动销毁,不进入历史记录。`,more:`更多`,brand:`品牌`,newChatTip:`新建对话(每个浏览器独立保存会话)`,"thinking.off":`关闭`,"thinking.minimal":`极简`,"thinking.low":`低`,"thinking.medium":`中`,"thinking.high":`高`,"thinking.xhigh":`极高`,"thinking.max":`最大`,thinkingUnsupported:`当前模型不支持该级别,已按模型能力就近生效`,context:`上下文`,contextUsage:`上下文用量`,cumulativeCost:`累计成本`,sessionMessages:`会话消息数`,messages:`消息`,pluginStatus:`插件状态`,engineBadge:`引擎`,working:`工作中`,queued:`排队`,enterPath:`输入路径,Enter 切换`,cwdTip:`工作目录:{path}(点击切换)`,manageProjects:`管理项目和工作目录`,projectPickerTitle:`选择工作目录`,newProject:`新建项目`,projectName:`项目名称`,createAndOpenProject:`创建并打开`,invalidProjectName:`请输入不含路径分隔符的项目名称`,cwdGoUp:`上级目录`,cwdPickCurrent:`选择当前目录`,cwdChoose:`选择`,cwdEnter:`进入`,cwdEmpty:`(空目录)`,cwdNewFolder:`新建文件夹`,cwdNewName:`文件夹名称`,cwdCreate:`创建`,cwdCancel:`取消`,cacheHit:`缓存命中`,cacheHitTip:`缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)`,tps:`t/s`,rateTip:`实时生成速率(估算)`,hostResources:`主机资源`,hostProcessor:`CPU`,hostMemory:`RAM`,hostResourcesTip:`运行 pi-web-ui 服务的主机 · CPU 为约 10 秒平均(2 秒采样),与任务管理器采样时刻不同会有几秒偏差`,folderRef:`文件夹引用:{path}`,refOnly:`仅引用:{path}`,attachContent:`附加内容:{path}`,attachLines:`附加选中行:{path}(第 {start}-{end} 行)`,attachImage:`图片:{name}`,attachFile:`文件:{name}`,removeAttachment:`移除附件`,attachHint:`将随下一条消息发送`,uploadFile:`添加文件(图片/文本/任意文件,也可直接拖入或粘贴截图)`,dropHereToAttach:`松开以添加文件`,imageNotSupported:`当前模型不支持识图:图片将交给视觉桥转写(若未配置视觉模型则可能被忽略)`,imageLoadFailed:`图片读取失败:{name}`,fileLoadFailed:`文件读取失败:{name}`,fileTooLarge:`文件过大已跳过(>{size}MB):{name}`,foldersNotSupported:`不支持直接拖入文件夹,请展开后选择文件`,placeholderStreaming:`智能体正在工作中…回车插队发送,或点「排队」等回答结束后发送`,placeholderStreamingQueued:`智能体正在工作中…回车或点「排队」,回答完全结束后发送(本引擎不支持插队)`,placeholderIdle:`给 pi 发送消息 — Enter 发送,/ 查看命令`,placeholderConnecting:`正在连接服务器…`,stopAgent:`停止智能体`,stop:`停止`,bgTasks:`后台任务`,bgTasksTip:`AI 在后台启动的服务(npm run dev & 等)——可逐个停止或全部关闭,对话结束后仍保留`,bgTasksEmpty:`暂无后台任务`,bgTasksDesc:`AI 运行中启动并仍在监听的进程(按监听端口检测)`,bgTaskPort:`端口`,bgTaskPid:`PID`,bgTaskSince:`启动`,bgTaskStop:`停止`,bgTaskStopAll:`全部关闭`,bgTaskRefresh:`刷新`,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:`在其他标签页 / 设备上打开的对话(运行中或已结束未关闭,右键可过户到本页查看)`,elsewhereActions:`操作(过户到本页 / 复制 id…)`,takeoverConversation:`过户到当前页面`,takeoverConfirm:`确认过户到当前页面?`,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:`固化为普通对话`,saveEphemeral:`保存为正式对话`,forceDismissConfirm:`确认强行关闭?未结束的运行将被中止,再点一次`,noFinishedSubagents:`没有可关闭的已结束子代理`,collapseSection:`折叠`,expandSection:`展开`,emptyChat:`空对话`,reaskDirectly:`直接重问`,reaskDirectlyTip:`直接从这里重新提问(不修改内容,新建分支对话,原对话保留)`,editReask:`编辑重问`,editReaskTip:`修改此问题,并从这里重新提问(会新建一个分支对话,原对话保留)`,forkSession:`派生分支`,forkSessionTip:`从此消息处派生新分支会话(截取该位置之前的转录)`,rollbackSession:`回滚到此`,rollbackSessionTip:`丢弃此消息之后的内容,在当前会话直接继续`,rollbackConfirm:`确定要回滚到此消息吗?该消息之后的所有对话将被丢弃,并在当前会话继续。`,rollbackRestoreWorkspace:`同时还原工作区物理文件(Dual-State Rollback)`,rollbackRestoreWorkspaceTip:`还原物理代码到该消息发起时的检查点版本(通过 Git 影子快照)`,toolApprovalTitle:`工具执行待审批(Human-in-the-Loop)`,toolApprovalApprove:`批准执行`,toolApprovalDeny:`拒绝`,toolApprovalEditAndRun:`修改并放行 (Edit & Run)`,toolApprovalRiskAlert:`检测到高危操作或关键配置修改`,toolApprovalCommand:`命令内容`,toolApprovalParams:`工具调用参数`,toolApprovalEditPlaceholder:`就地修改参数 JSON…`,toolApprovalReason:`拦截原因`,toolApprovalCategory:`规则档位`,toolApprovalAllowCategory:`本对话允许同类`,toolApprovalAllowCategoryHint:`本对话内这一类高危操作后续不再询问(设置 →「工具」页可撤销)`,toolApprovalAllowConversation:`本对话全部允许`,toolApprovalAllowConversationHint:`本对话内所有高危操作后续都不再询问(设置 →「工具」页可撤销)`,toolApprovalEnabled:`工具执行审批(人机协同)`,toolApprovalEnabledDesc:`开:高危操作(rm -rf / 破坏性 git / 敏感文件 / 工作区外写入 / 插件要求确认)弹窗等你批准、拒绝或改参数;关:一切审批都不弹(内置高危检测直接放行,插件要求确认也按放行处理)。`,toolApprovalPolicyTitle:`已记住的放行(本对话)`,toolApprovalPolicyAllowAll:`本对话全部允许审批`,toolApprovalPolicyRevoke:`撤销`,toolApprovalPolicyHint:`只存在内存里:重启服务或新对话即恢复询问;策略跟对话走(手动过户时一起搬)。`,settingsApprovalRules:`审批规则`,settingsApprovalRulesDesc:`全局自定义人机协同拦截规则,支持基于正则/通配符/路径对工具命令或参数配置「需审批」、「直接拒绝」或「免审放行」。规则自顶向下首条匹配优先。`,manageApprovalRules:`管理审批规则`,approvalRuleNew:`新增规则`,approvalRuleEdit:`编辑规则`,approvalRuleDelete:`删除`,approvalRuleReset:`恢复默认`,approvalRuleResetConfirm:`确认将该内置规则恢复为系统默认设定吗?`,approvalRuleDeleteConfirm:`确认删除该自定义审批规则吗?`,approvalRuleActionAsk:`需审批`,approvalRuleActionDeny:`直接拒绝`,approvalRuleActionAllow:`免审放行`,approvalRuleTools:`适用工具`,approvalRuleToolsTip:`输入工具名(如 bash、write、edit),以逗号分隔;输入 * 表示匹配所有工具`,approvalRuleField:`检查字段`,approvalRuleFieldCommand:`命令 (command)`,approvalRuleFieldPath:`文件路径 (path)`,approvalRuleFieldParams:`完整参数 JSON (params)`,approvalRuleMatch:`匹配方式`,approvalRuleMatchRegex:`正则表达式 (regex)`,approvalRuleMatchGlob:`通配符 (glob)`,approvalRuleMatchContains:`包含子串 (contains)`,approvalRuleMatchPrefix:`前缀开头 (prefix)`,approvalRuleMatchOutsideWs:`工作区外路径 (outside_workspace)`,approvalRuleValue:`匹配表达式 / 模式串`,approvalRuleValueTip:`根据匹配方式输入对应规则,例如 rm -rf 或 \\.env$`,approvalRuleLabel:`规则名称 (中文)`,approvalRuleLabelEn:`规则名称 (英文)`,approvalRuleReason:`拦截原因说明 (中文)`,approvalRuleReasonEn:`拦截原因说明 (英文)`,approvalRuleEnabled:`启用该规则`,approvalRuleBuiltin:`内置`,approvalRuleEmpty:`当前没有审批规则。点击右上角「+ 新增规则」添加自定义拦截与放行策略。`,approvalRuleMoveUp:`上移`,approvalRuleMoveDown:`下移`,planBoardTitle:`任务执行看板 (Plan Mode)`,planBoardSteps:`步骤清单`,planBoardProgress:`总体进度`,planBoardNoPlan:`暂无任务计划`,planBoardCompleted:`已完成`,planBoardInProgress:`进行中`,planBoardPending:`待执行`,planBoardFailed:`失败`,clear:`清空`,confirm:`确定`,forkBadge:`分支`,forkBadgeTip:`派生自`,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 组件`,kindPlugin:`插件`,pluginCheckUpdates:`检查插件更新`,pluginCheckUpdatesHint:`检查已安装界面插件是否有新版本(对比远端版本与 commit)`,pluginUpdateAvailableBadge:`可更新`,pluginUpdateAvailableDetail:`可更新:{version}`,pluginAllUpToDate:`所有插件均为最新版本`,updatesAllRefresh:`重新检查全部`,updateCheckFailed:`检查失败`,updateBtn:`更新`,updateAllBtn:`全部更新`,updatePkgTabTitle:`更新 {name}`,updateAllTabTitle:`更新全部组件`,piCoreSplitRun:`服务运行 v{running}`,piSdkSplitNote:`本服务运行的是 pi v{running};机器上装有更新的全局 pi v{installed}。重启服务即可跟上(默认自动选用更新的那份);设了 PI_WEB_SDK=bundled 时会一直用自带副本,升级 pi-web-ui 也可让自带副本跟上。`,piSdkBundledNote:`当前使用随包自带的 pi 引擎 v{running}(随 pi-web-ui 更新)。安装全局引擎后重启服务即可自动切换(服务默认跟随版本更高的那份)。`,installGlobalEngineBtn:`安装全局引擎`,installGlobalEngineTabTitle:`安装全局 pi 引擎`,restartService:`重启服务`,restartingService:`重启中…`,restartServiceTip:`重启 pi-web-ui 服务({name}):本实例由系统服务托管(launchd/systemd/Windows watchdog),进程退出后会被自动拉起,本页会自动重连;更新完成后用它生效`,computer:`此电脑`,rootDir:`根目录`,homeDir:`用户目录`,desktopDir:`桌面`,filesHelp:`浏览:点文件夹进入、点文件预览,「..」返回上级;「根目录」回当前项目根,「此电脑」浏览全盘换盘符,「🏠」直达用户目录,「🖥️」直达桌面。
|
|
4
4
|
文件操作:右键可新建文件/文件夹、重命名、复制/剪切/粘贴、创建副本、删除、上传文件;文件可下载,行尾按钮可复制名称/路径。
|
|
5
5
|
切换项目:文件夹右键「以项目打开」,或点右下角 📁 路径按钮输入/选择目录。
|
|
6
6
|
发给 AI:行尾按钮附加内容或仅引用路径,也可把文件拖进输入框。`,workspaceRoots:`工作区根`,workspaceRootsHint:`文件树可切换到这些根;插件读写这些目录不必再单独授权。`,addWorkspaceRoot:`添加为工作区根`,addWorkspaceRootHint:`把当前目录加成工作区根(右栏文件树可切换浏览;插件读写该目录不再单独授权)`,removeWorkspaceRoot:`移除工作区根`,noFiles:`暂无文件`,filesTruncated:`目录过大,列表已截断,仅显示前 2000 项`,linkFolderTip:`链接文件夹路径到对话`,referenceTip:`仅引用路径(AI 按需读取)`,previewFile:`预览`,downloadFile:`下载文件`,copyName:`复制名称`,copyPath:`复制路径`,downloadFailed:`下载失败:{error}`,fileNotFoundShort:`文件不存在`,pluginMountFailed:`插件 {name} 挂载失败`,pluginViewLoading:`插件视图加载中…`,pluginViewLoadFailed:`插件视图加载失败`,pluginViewLoadFailedHint:`按 F12 打开 console 查看 plugin 开头的报错,或检查服务端日志;也可以在设置 → 插件里重装该插件。`,pluginViewRetry:`重试加载`,liveOutputOmitted:`…[前 {n} 字符已省略]…
|
|
@@ -162,7 +162,7 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from
|
|
|
162
162
|
|
|
163
163
|
{path}
|
|
164
164
|
|
|
165
|
-
只在你确认后打开。`,settingsExtensions:`插件`,settingsUiPlugins:`界面插件`,pluginListTab:`插件列表`,noUiPlugins:`未安装界面组件(<dataDir>/plugins/)`,pluginPhaseActive:`运行中`,pluginPhaseDisabled:`已禁用`,pluginPhaseFailed:`失败`,pluginPhaseIdle:`纯前端`,pluginRescan:`重新扫描`,pluginRescanHint:`重新扫描插件目录(新增/修复后生效;失败记录清空重记)`,dshPatches:`DSH 用户补丁`,dshPatchesDesc:`启动时按文件名序加载的 Cordis patch(<dataDir>/dsh-patches/*.yml)。新增/修改后点「重扫」重启运行时生效;失败的文件会被跳过并打印到运行时 stderr。`,dshPatchesRescan:`重扫`,dshPatchesRescanHint:`重新扫描补丁目录并重启 DSH 运行时使新补丁生效`,dshPatchesEmpty:`未放置补丁文件`,dshPatchesPath:`补丁目录:`,dshPreset:`Agent 预设`,dshPresetNewChat:`以此预设开新对话`,dshPresetLocked:`已锁定`,dshPresetBlankOnly:`首轮发言后锁定,空白会话可切换`,dshPresetBroken:`(不可用)`,dshPresetUser:`自建`,dshPresetDefaultTag:`默认`,dshPresetCurrent:`当前`,dshPresetMinimalNote:`极简模式:仅持久 shell;宿主插件工具与问卷不可用`,dshDefaultPreset:`默认预设`,dshDefaultPresetDesc:`新对话使用的预设;空白会话可随时切换,首轮发言后锁定`,dshPresetUserNote:`自建预设来自用户预设目录(与 shell 同等信任);用裸包名的自建组合在此无法挂载(已知限制)`,dshPerm:`权限`,dshPermReadOnly:`仅可查看`,dshPermReadOnlyDesc:`只能读文件、跑只读命令;写操作一律拒绝,不弹确认`,dshPermWorkspaceWrite:`工作区内修改`,dshPermWorkspaceWriteDesc:`工作区内读写,不弹确认;超出范围的操作直接拒绝`,dshPermFullAccess:`完全权限`,dshPermFullAccessDesc:`关闭沙箱,整机任意读写;只给信任的任务`,dshPermFullAccessTag:`高危`,dshPermCustom:`自定义`,dshPermConfirmFull:`再点一次确认开启完全权限`,dshPermDefault:`新会话默认权限`,dshPermDefaultDesc:`新对话的初始权限;当前对话可随时热切换,无需重启`,uiPluginNoSource:`手工安装,无来源信息,无法在线更新`,uiPluginPerms:`能力声明`,pluginDiagTitle:`诊断信息`,pluginDiagShow:`诊断`,pluginDiagHide:`收起`,pluginLogTitle:`运行日志`,pluginLogShow:`日志`,pluginLogHide:`收起`,pluginLogLevel:`级别`,pluginLogAll:`全部`,pluginLogEmpty:`暂无日志`,pluginLogClear:`清空`,pluginDomNeed:`⚠ 请求完全 DOM 访问`,pluginDomDesc:`该插件可直接读写页面 DOM(绕过界面布局限制)。只给可信来源的插件授权;授权后其界面代码可碰顶栏/输入框/任意页面元素。`,pluginDomGrant:`授权 DOM 访问`,pluginDomRevoke:`撤销 DOM 访问`,pluginDomGranted:`已授权完全 DOM 访问`,pluginSettingsTitle:`插件配置`,pluginSettingsShow:`配置`,pluginSettingsHide:`收起`,pluginSettingsSave:`保存插件设置`,pluginSettingsSaving:`保存中…`,pluginSettingsReset:`恢复默认`,pluginSettingsInherit:`跟随全局默认`,pluginSecretSet:`已设置(加密保存,留空不改)`,pluginSecretUnset:`未设置(加密保存)`,settingsPresets:`预设`,settingsSubagentTemplates:`子代理模板`,settingsSubagentTemplatesDesc:`配置子代理预设(角色系统提示词 + 技能/扩展白名单 + 可选模型与思考强度)。AI 派生子代理时可选用模板(subagent_spawn 的 template 参数),也可不传按默认运行;停用的模板保留在面板但对 AI 不可见。`,noSubagentTemplates:`还没有子代理模板。AI 派生子代理时可选用模板(角色提示词 + 技能/扩展白名单 + 可选模型与思考强度),也可以不传 template 按默认配置运行。`,subagentTemplateNew:`新建模板`,subagentTemplateEdit:`编辑`,subagentTemplateClosed:`已停用`,tplDefaultBadge:`默认`,subagentTemplateOffHint:`关闭的模板保留在面板、可随时重新启用,但 AI 工具查询不到、不能选择`,subagentTemplateEnable:`启用`,subagentTemplateDisable:`停用`,subagentDefaultModelLabel:`子代理默认模型`,subagentFollowMain:`跟随主对话当前模型`,subagentDefaultModelHint:`所有子代理的兜底模型(模板里指定的模型和 subagent_spawn 的 model 参数优先级更高);不改主对话模型。`,subagentNoModels:`暂无可用的模型(需要先配置服务商 API Key)——子代理将跟随主对话模型。`,tplNamePlaceholder:`模板名(AI 用 subagent_spawn 的 template 参数引用)…`,tplDescriptionPlaceholder:`简介(AI 据此判断适用场景)…`,tplDescriptionEnPlaceholder:`英文简介(英文 UI 时 AI 看这个,留空则用中文简介)…`,tplPromptModeLabel:`系统提示词模式`,tplModelLabel:`模型(空 = 跟随主对话)`,tplThinkingLabel:`思考强度`,tplThinkingFollowMain:`跟随主对话当前思考强度`,tplThinkingHint:`空 = 跟随主对话当前思考强度(与不指定模型时的「跟随主对话」同语义);模型不支持所选档位时自动收敛到最接近的可用档位。`,tplSystemPromptLabel:`系统提示词`,tplSystemPromptPlaceholder:`模板角色系统提示词…(append 模式可留空)`,tplSystemPromptEnPlaceholder:`英文系统提示词…(英文 UI 时生效,留空则用中文)`,tplWhitelistHint:`白名单:勾选 = 子代理只启用这些;全部不勾 = 跟随主会话设置`,tplSkillsLabel:`技能白名单`,tplExtensionsLabel:`扩展白名单`,tplSave:`保存模板`,tplCancel:`取消编辑`,tplDelete:`删除模板`,settingsScheduler:`定时任务`,schedulerDesc:`到点自动让 Agent 干活(依赖巡检、跑测试、生成早报……):无头伪客户端执行,无浏览器也能跑;跑完推送通知,历史可查。`,schedulerEmpty:`还没有定时任务。点右上角「新建任务」安排第一个:每天 9 点巡检、每小时跑一次测试都可以。`,schedulerNew:`新建任务`,schedulerEdit:`编辑`,schedulerDelete:`删除`,schedulerRunNow:`立即运行`,schedulerRunning:`执行中…`,schedulerEnable:`启用`,schedulerDisable:`停用`,schedulerEnabled:`已启用`,schedulerDisabled:`已停用`,schedulerNameLabel:`任务名称`,schedulerNamePlaceholder:`如:每日依赖与代码健康检查…`,schedulerDescPlaceholder:`说明(可选):这个任务是干什么的…`,schedulerCwdLabel:`执行目标项目`,schedulerCwdPlaceholder:`/绝对/路径/到/项目…`,schedulerUseCurrentCwd:`用当前项目`,schedulerKindLabel:`调度周期`,schedulerKindCron:`Cron 表达式`,schedulerKindInterval:`固定间隔`,schedulerCronPlaceholder:`如 0 9 * * *(每天 9:00)`,schedulerPresetDaily:`每天 9:00`,schedulerPresetHourly:`每小时整点`,schedulerPresetHalfHour:`每 30 分钟`,schedulerPresetWorkday:`工作日 9:00`,schedulerPresetMonday:`每周一 9:00`,schedulerPresetCustom:`自定义…`,schedulerIntervalMinutes:`间隔(分钟,最少 1 分钟)`,schedulerPromptLabel:`触发指令`,schedulerPromptPlaceholder:`给 Agent 的具体任务,如:审计依赖并报告可升级项…`,schedulerModelLabel:`模型(空 = 跟随默认)`,schedulerThinkingLabel:`思考强度(空 = 跟随默认)`,schedulerCatchUp:`服务重启后补跑漏掉的一次`,schedulerCatchUpHint:`勾选后,服务停机期间错过的触发会在下次启动时补跑一次;不勾选则跳过。`,schedulerNextFire:`下次`,schedulerLastRun:`上次`,schedulerNeverRun:`从未运行`,schedulerHistory:`历史`,schedulerManualBadge:`手动`,schedulerRunOk:`成功`,schedulerRunFail:`失败`,schedulerConfirmDelete:`确定删除定时任务「{name}」吗?历史记录一并清除。`,schedulerSave:`保存任务`,schedulerCancelEdit:`取消编辑`,tplInherit:`跟随主会话`,settingsEnabled:`已启用`,settingsDisabled:`已禁用`,presetNamePlaceholder:`预设名称…`,saveAsPreset:`保存为预设`,applyPreset:`应用`,deletePreset:`删除预设`,noSkills:`暂无技能`,noExtensions:`暂无插件`,noPresets:`暂无预设(调整好当前设置后,在上方输入名称保存为预设)`,loadingSession:`正在加载会话…`,connectingServer:`正在连接 pi-web-ui 服务器…`,localePacks:`语言包`,localeGetMore:`获取更多语言`,localeInstalled:`已安装`,localeInstall:`下载`,localeRemove:`移除`,localeDownloading:`下载中…`,localeRemoving:`移除中…`,localeInstallFailed:`下载失败:{error}`,localeListFailed:`获取语言包列表失败:{error}`,localeRemoveHint:`移除后随时可重新下载`,wallpaperTitle:`聊天背景图`,wallpaperDesc:`给整个窗口加一张背景图(左右面板、顶栏、底栏也会透出):主题自带的图会自动生效,在此填地址则优先用你的;用压暗与模糊保证文字清晰。`,wallpaperUrlPh:`图片地址(https://…,留空关闭)`,wallpaperDim:`压暗`,wallpaperBlur:`模糊`,wallpaperClear:`清除`,wallpaperUpload:`上传图片`,wallpaperUploadFailed:`图片读取失败或过大,请换一张试试`,skillFullTextLabel:`技能全文注入`,skillFullTextDesc:`把技能文件正文直接展开进系统提示词(单文件 8KB、总量 32KB 封顶),否则只列名录由模型按需读取`,skillFullTextShort:`全文`,delegateOpenSubagent:`查看子代理`,delegateSecTask:`任务`,delegateSecExpected:`期望产出`,delegateSecTools:`可用工具`,delegateSecMustDo:`必须做`,delegateSecMustNotDo:`禁止做`,delegateSecContext:`上下文`,copyConversationId:`复制对话 ID`,copyConversationPath:`复制会话文件路径`,quoteConversation:`引用到输入框(AI 可读)`,quoteConversationShort:`引用`,attachConversation:`对话引用:{name}(AI 经 conversation_read 按需读取)`,attachConversationShort:`对话`,presentOpenLocal:`本地打开`,presentMissing:`文件不存在或不可读(可能已被移动、删除或超出工作区)`,presentEmpty:`没有可展示的文件`,presentAutoOpen:`自动打开 AI 展示的预览`,presentAutoOpenDesc:`AI 用 present_files 展示文件、并标了「先看这个」时,自动弹出文件预览窗口;关闭(默认)则只在卡片里显示,点一下再看。`,presentFilesEnabledDesc:`让 AI 把产物(截图 / 图表 / 视频 / 报告 / 日志)作为预览卡片推到对话里:图片、视频、音频直接在消息里显示/播放,文本给开头摘录 + 一键开预览弹窗,每条都带「本地打开 / 在文件夹中显示 / 下载 / 复制路径」。自动弹预览窗的开关在「对话」页。`,presentFilesOffHint:`已关闭:AI 只能用文字告诉你文件路径,没有卡片,也没有本地打开按钮`,skillEnabledDesc:`技能正文按名加载(技能名录仍注入系统提示词):真要用到某个技能时才取全文,不再让模型拼路径去 read。`,skillOffHint:`已关闭:AI 不能按名取技能全文(提示词里的技能名录不受影响)`,claimFilesEnabledDesc:`声明你要改哪些文件,让同项目的并行对话绕行(纯建议,不拦编辑):开着 AI 才知道能认领,先到先得,过期自动释放。`,claimFilesOffHint:`已关闭:AI 不能再认领文件(并行触碰提醒照常工作,只是少了事前意图这一路)`,planUpdateEnabledDesc:`结构化任务计划更新(Plan Mode / Step State Machine):让模型将复杂任务拆解为步骤并实时更新推进状态。`,planUpdateOffHint:`已关闭:AI 不能再更新结构化计划看板`,compactContextEnabledDesc:`根据当前问题主动压缩上下文:允许 AI 自主指定压缩重点、保留与当前任务相关的核心上下文并去除无关历史细节,自主控制保留范围并在回合后生效。`,compactContextOffHint:`已关闭:AI 不能主动调用上下文压缩工具(仍可用 /compact 命令或触发软上限自动压缩)`,evalEnabledDesc:`在隔离的代码求值沙箱中执行 Python 或 JavaScript/TypeScript 代码,变量状态跨调用保持;适用于即时数学计算、数据处理与算法验证(默认关闭,防工具挤占)。`,evalOffHint:`已关闭:AI 不能使用持久代码求值沙箱(可使用 bash 工具运行临时脚本)`,patchToolEnabledDesc:`高可靠结构化行补丁工具(Hashline):基于内容哈希锚点与语法块(AST Block)替换代码,支持剪切/粘贴寄存器;文件被外部改动时自动执行三方合并(3-Way Merge)冲突自愈,避免大文件编辑幻觉与行号漂移。`,patchToolOffHint:`已关闭:AI 只能使用基础 edit 工具进行纯文本精确字符串替换`,lspToolEnabledDesc:`原生语言服务器协议(LSP)工具:为 AI 提供 IDE 级的代码语义智能(支持定义跳转、引用查询、类型悬停、编译诊断、符号大纲 documentSymbol、精确符号代码切片 read_symbol、工作区全局符号搜索 workspaceSymbol、编辑影响级联诊断 cascade),多子代理共享进程池与闲置休眠,免外部插件开箱即用。`,lspToolOffHint:`已关闭:AI 将无法主动调用 LSP 语义工具,依赖全局搜索或文本匹配定位符号`,toolInfoMenuLabel:`显示工具详细信息`,toolInfoTitle:`工具详细信息`,toolInfoLoading:`正在读取工具定义…`,toolInfoUnsupported:`当前引擎不支持查看工具定义`,toolInfoMissing:`未找到这个工具的定义(可能来自已卸载的插件或旧版本)`,toolInfoActive:`已启用`,toolInfoInactive:`已停用`,toolInfoSource:`来源`,toolInfoDescription:`说明`,toolInfoNoDescription:`这个工具没有提供说明`,toolInfoPromptSnippet:`提示词摘要`,toolInfoGuidelines:`提示词要点`,toolInfoParams:`参数`,toolInfoParamsNone:`这个工具没有参数`,toolInfoSchemaDropped:`参数 schema 太大,已省略(见下方原始 JSON)`,toolInfoRawSchema:`原始 JSON Schema`,toolInfoRequired:`必填`,toolInfoFootnote:`这是工具的定义说明,不含本次调用的参数与结果。`},en={docTitle:`pi-web-ui — pi coding agent`,cancel:`Cancel`,ok:`OK`,save:`Save`,close:`Close`,widgetExpand:`Click to view full output`,collapsePanel:`Collapse panel`,expandPanel:`Expand panel`,dragToResize:`Drag to resize · double-click to reset`,loading:`Loading…`,connected:`Connected`,connecting:`Connecting…`,reconnecting:`Reconnecting…`,language:`Language`,langZh:`中文`,langEn:`English`,langIt:`Italiano`,langJa:`日本語`,langKo:`한국어`,langFr:`Français`,langDe:`Deutsch`,langEs:`Español`,langRu:`Русский`,langPt:`Português`,githubRepo:`GitHub repository (xing-shuyin/pi-web-ui)`,copy:`Copy`,viewSwitch:`Switch view`,chat:`Chat`,terminal:`Terminal`,selectModel:`Select model`,availableModels:`Available models`,allProviders:`All`,providers:`Providers`,noModels:`No models available (configure an API key first)`,reasoning:`reasoning`,vision:`vision`,refreshModels:`Refresh model list (keeps manual rows, merges new ones)`,manageModels:`⚙ Manage models (add / edit)`,manageModelsTitle:`Manage models`,setGlobalDefault:`☆ Set as global default (new projects follow it)`,clearGlobalDefault:`★ Clear global default`,globalDefaultBadge:`Global default`,thinkingLevel:`Thinking level`,thinking:`Thinking`,thinkingChip:`Thinking: {level}`,sound:`Sound`,theme:`Theme`,themeDefault:`Dark (default)`,themeGroupClassics:`Classics`,themeGroupBuiltin:`Original`,themeLight:`Light`,themeDark:`Dark`,newChat:`New chat`,newChatEphemeral:`Ephemeral chat`,newChatEphemeralTip:`Ephemeral chat (in-memory only, auto-discarded on close, not saved to history)`,ephemeralBadge:`Ephemeral`,ephemeralBannerText:`Ephemeral session: messages are in-memory only, discarded on close, not saved to history.`,more:`More`,brand:`Brand`,newChatTip:`New chat (sessions are saved per browser)`,"thinking.off":`Off`,"thinking.minimal":`Minimal`,"thinking.low":`Low`,"thinking.medium":`Medium`,"thinking.high":`High`,"thinking.xhigh":`Extra high`,"thinking.max":`Max`,thinkingUnsupported:`Not supported by this model — snapped to the nearest supported level`,context:`Context`,contextUsage:`Context usage`,cumulativeCost:`Cumulative cost`,sessionMessages:`Session messages`,messages:`messages`,pluginStatus:`Plugin status`,engineBadge:`Engine`,working:`Working`,queued:`queued`,enterPath:`Type a path, Enter to switch`,cwdTip:`Working directory: {path} (click to switch)`,manageProjects:`Manage projects and working directories`,projectPickerTitle:`Choose a working directory`,newProject:`New project`,projectName:`Project name`,createAndOpenProject:`Create and open`,invalidProjectName:`Enter a project name without path separators`,cwdGoUp:`Up one level`,cwdPickCurrent:`Select this folder`,cwdChoose:`Select`,cwdEnter:`Enter`,cwdEmpty:`(empty)`,cwdNewFolder:`New folder`,cwdNewName:`Folder name`,cwdCreate:`Create`,cwdCancel:`Cancel`,cacheHit:`Cache hit`,cacheHitTip:`read {read} · write {write} · miss {miss} (of {input} input tokens)`,tps:`t/s`,rateTip:`Live generation rate (estimated)`,hostResources:`Host resources`,hostProcessor:`CPU`,hostMemory:`RAM`,hostResourcesTip:`Host running pi-web-ui · CPU is a ~10s average (2s samples); a few seconds of skew vs Task Manager is normal`,folderRef:`Folder reference: {path}`,refOnly:`Reference only: {path}`,attachContent:`Attached content: {path}`,attachLines:`Attached selected lines: {path} (lines {start}-{end})`,attachImage:`Image: {name}`,attachFile:`File: {name}`,removeAttachment:`Remove attachment`,attachHint:`Will be sent with the next message`,uploadFile:`Add files (images / text / any file — or drag in / paste a screenshot)`,dropHereToAttach:`Release to attach file`,imageNotSupported:`The current model doesn't support vision — images will be transcribed by the vision bridge (may be ignored if no vision model is configured)`,imageLoadFailed:`Couldn't read image: {name}`,fileLoadFailed:`Couldn't read file: {name}`,fileTooLarge:`File too large, skipped (> {size}MB): {name}`,foldersNotSupported:`Folders can't be dropped directly — expand and pick files instead`,placeholderStreaming:`The agent is working… press Enter to steer, or click Queue to send after the reply finishes`,placeholderStreamingQueued:`The agent is working… press Enter or click Queue — delivered after the reply finishes (this engine cannot steer)`,placeholderIdle:`Message pi — Enter to send, / for commands`,placeholderConnecting:`Connecting to server…`,stopAgent:`Stop agent`,stop:`Stop`,bgTasks:`Background tasks`,bgTasksTip:`Servers the AI started in the background (npm run dev & etc.) — stop them individually or all at once; they survive the conversation`,bgTasksEmpty:`No background tasks`,bgTasksDesc:`Processes the AI started that are still listening (detected by port)`,bgTaskPort:`Port`,bgTaskPid:`PID`,bgTaskSince:`Started`,bgTaskStop:`Stop`,bgTaskStopAll:`Stop all`,bgTaskRefresh:`Refresh`,bgTaskJustNow:`just now`,bgTaskMinutes:`{n} min ago`,bgTaskHours:`{n} hr ago`,bgTaskDays:`{n} days ago`,stopBash:`Stop`,stopBashTip:`Stop the running bash command (conversation continues)`,supplement:`Queue`,supplementTip:`Add to queue: sent only after the whole run finishes (no interruption)`,steerTip:`Steer: send right away — the current turn responds immediately (Enter)`,queueSteerTag:`Steer`,queueFollowTag:`Queued`,queueRemoveTip:`Remove this queued message`,queueRecallTip:`Recall into the input box for editing`,sendTip:`Send (Enter)`,composerResize:`Drag to resize the input height (double-click to reset)`,quickPhrases:`Quick phrases`,quickPhrasesDesc:`A row of frequently-used phrase buttons above the input box — click to send (current file attachments are included, the input draft is kept)`,quickPhrasesEnabled:`Enable quick phrases`,quickPhrasesOffHint:`Off: the phrase buttons above the input box are hidden (saved phrases are kept and can be re-enabled anytime)`,quickPhrasesPlaceholder:`Type a frequently-used phrase… (Enter to add)`,quickPhrasesAdd:`Add`,quickPhrasesEmpty:`No quick phrases yet — add your first one below`,quickPhrasesTip:`Click to send: {text}`,quickPhrasesSendTip:`Left-click to steer, right-click to queue`,quickPhrasesMoveUp:`Move up`,quickPhrasesMoveDown:`Move down`,quickPhrasesDelete:`Delete this phrase`,quickPhrasesEdit:`Edit this phrase`,quickPhrasesEditPh:`Edit phrase… (Enter to save, Esc to cancel)`,quickPhrasesReset:`Reset to defaults`,slashCommands:`Commands`,slashMenuHint:`↑↓ select · Enter/Tab complete`,atMentions:`Mentions`,atMenuHint:`↑↓ select · Enter/Tab insert`,slashHelpTitle:`pi commands`,slashHelpHint:`Type / anytime to open the command list`,slashLoading:`Loading commands… (available once connected)`,slashBuiltin:`Builtin`,slashExtension:`Extension`,slashPrompt:`Template`,slashSkill:`Skill`,slashPlugin:`Plugin`,slashCopied:`Copied the last assistant reply`,slashCopyFailed:`Copy failed — please copy manually`,slashCopyEmpty:`No assistant reply to copy yet`,recentProjects:`Recent projects`,runningConversations:`Running chats`,elsewhereBadge:`Elsewhere`,elsewhereTip:`Conversation open in another tab / device (running, or finished but still held there; right-click to take over and view it here)`,elsewhereActions:`Actions (take over here, copy id…)`,takeoverConversation:`Take over to this page`,takeoverConfirm:`Confirm take over to this page?`,takeoverHasQuestion:`Has a pending question — click to answer it here`,waitingQuestionBadge:`Waiting on your answer — click to view`,subagentBadge:`Subagent`,convErrorBadge:`Subagent failed: {error}`,subagentTitle:`Subagent · {title}`,historySessions:`History`,openHistory:`History`,openFiles:`Files`,openProject:`Open project`,streaming:`Streaming…`,noHistory:`No previous chats`,current:`Current`,messageCount:`{n} messages`,tuiTip:`Chat in the pi terminal (TUI)`,deleteProject:`Remove from recent projects`,deleteProjectConfirm:`Confirm remove`,deleteSession:`Delete this chat transcript permanently`,deleteSessionConfirm:`Confirm delete`,renameSession:`Rename this chat`,renameSessionPlaceholder:`Type a new name…`,renameSessionConfirm:`Rename`,dismissConversation:`Dismiss from running (keep in history)`,dismissConversationConfirm:`Confirm dismiss`,dismissFinishedSubagents:`Dismiss finished subagents ({n})`,dismissFinishedSubagentsScoped:`Dismiss finished subagents under this chat, incl. nested ({n})`,dismissConversationWithSubagents:`Also dismiss finished subagents ({n})? Make sure their results are no longer needed — click again to confirm`,dismissConversationWithSubagentsMixed:`Also dismiss finished subagents ({n})? {m} running one(s) stay, parent stays; make sure the finished ones are no longer needed — click again to confirm`,dismissStreamingConfirm:`Still running — confirm force-dismiss? (The run will be aborted)`,dismissFinishedOnly:`Dismiss finished only ({n})`,dismissForceAll:`Force-dismiss all (incl. {n} subagent(s))`,forceDismissTitle:`Force-dismiss this conversation and all {n} subagent(s) ({m} running will be aborted)`,forceDismissConversation:`Force-dismiss conversation (incl. all subagents)`,persistSubagent:`Convert to Regular Conversation`,saveEphemeral:`Save as regular conversation`,forceDismissConfirm:`Confirm force-dismiss? Unfinished runs will be aborted — click again`,noFinishedSubagents:`No finished subagents to dismiss`,collapseSection:`Collapse`,expandSection:`Expand`,emptyChat:`Empty chat`,reaskDirectly:`Re-ask`,reaskDirectlyTip:`Re-ask from here directly without editing (forks a new conversation; original kept)`,editReask:`Edit & re-ask`,editReaskTip:`Edit this question and re-ask from here (forks a new conversation; the original is kept)`,forkSession:`Fork branch`,forkSessionTip:`Fork a new branch session from this message (truncates prior transcript)`,rollbackSession:`Rollback to here`,rollbackSessionTip:`Discard all content after this message and continue here`,rollbackConfirm:`Are you sure you want to rollback to this message? All subsequent messages will be discarded.`,rollbackRestoreWorkspace:`Restore workspace files to this checkpoint (Dual-State Rollback)`,rollbackRestoreWorkspaceTip:`Revert physical files to the checkpoint state when this message was sent (via Git shadow snapshot)`,toolApprovalTitle:`Tool Execution Approval (Human-in-the-Loop)`,toolApprovalApprove:`Approve`,toolApprovalDeny:`Deny`,toolApprovalEditAndRun:`Edit & Run`,toolApprovalRiskAlert:`High-risk operation or critical config modification detected`,toolApprovalCommand:`Command`,toolApprovalParams:`Tool Parameters`,toolApprovalEditPlaceholder:`Modify parameter JSON in place…`,toolApprovalReason:`Reason for Interception`,toolApprovalCategory:`Category`,toolApprovalAllowCategory:`Allow this kind here`,toolApprovalAllowCategoryHint:`Stop asking for this category of high-risk operations in this conversation (revocable under Settings → Tools)`,toolApprovalAllowConversation:`Allow all here`,toolApprovalAllowConversationHint:`Stop asking for any high-risk operation in this conversation (revocable under Settings → Tools)`,toolApprovalEnabled:`Tool execution approval (human-in-the-loop)`,toolApprovalEnabledDesc:`On: high-risk operations (rm -rf / destructive git / sensitive files / writes outside the workspace / plugin confirmation requests) pop a dialog for you to approve, deny or edit the parameters. Off: no approvals at all (built-in detection passes silently, plugin confirmation requests are treated as allowed).`,toolApprovalPolicyTitle:`Remembered allowances (this conversation)`,toolApprovalPolicyAllowAll:`All approvals allowed in this conversation`,toolApprovalPolicyRevoke:`Revoke`,toolApprovalPolicyHint:`In-memory only: restarting the service or opening a new conversation restores prompting. The policy travels with the conversation (e.g. on manual takeover).`,settingsApprovalRules:`Approval Rules`,settingsApprovalRulesDesc:`Global human-in-the-loop approval rules. Configure ask, deny, or allow actions for tool calls based on regex/glob/path matching. Evaluated top-to-bottom on first match.`,manageApprovalRules:`Manage Approval Rules`,approvalRuleNew:`Add Rule`,approvalRuleEdit:`Edit Rule`,approvalRuleDelete:`Delete`,approvalRuleReset:`Reset to Default`,approvalRuleResetConfirm:`Reset this built-in rule to system defaults?`,approvalRuleDeleteConfirm:`Are you sure you want to delete this custom approval rule?`,approvalRuleActionAsk:`Ask`,approvalRuleActionDeny:`Deny`,approvalRuleActionAllow:`Allow`,approvalRuleTools:`Target Tools`,approvalRuleToolsTip:`Comma-separated tool names (e.g. bash, write, edit); use * to match all tools`,approvalRuleField:`Target Field`,approvalRuleFieldCommand:`Command (command)`,approvalRuleFieldPath:`File Path (path)`,approvalRuleFieldParams:`Full Params JSON (params)`,approvalRuleMatch:`Match Mode`,approvalRuleMatchRegex:`Regular Expression (regex)`,approvalRuleMatchGlob:`Glob Pattern (glob)`,approvalRuleMatchContains:`Contains Substring (contains)`,approvalRuleMatchPrefix:`Prefix (prefix)`,approvalRuleMatchOutsideWs:`Outside Workspace Path (outside_workspace)`,approvalRuleValue:`Pattern / Value`,approvalRuleValueTip:`Pattern according to match mode, e.g. rm -rf or \\.env$`,approvalRuleLabel:`Rule Label (Chinese)`,approvalRuleLabelEn:`Rule Label (English)`,approvalRuleReason:`Reason (Chinese)`,approvalRuleReasonEn:`Reason (English)`,approvalRuleEnabled:`Enable this rule`,approvalRuleBuiltin:`Built-in`,approvalRuleEmpty:`No approval rules configured. Click '+ Add Rule' to add custom policies.`,approvalRuleMoveUp:`Move Up`,approvalRuleMoveDown:`Move Down`,planBoardTitle:`Task Plan Board (Plan Mode)`,planBoardSteps:`Step List`,planBoardProgress:`Overall Progress`,planBoardNoPlan:`No active plan`,planBoardCompleted:`Completed`,planBoardInProgress:`In Progress`,planBoardPending:`Pending`,planBoardFailed:`Failed`,clear:`Clear`,confirm:`Confirm`,forkBadge:`Branch`,forkBadgeTip:`Forked from`,reaskFromHere:`Re-ask from here`,editPlaceholder:`Edit the question…`,editHint:`⌘/Ctrl+Enter to submit · Esc to cancel`,editAttachmentHint:`Original attachments kept — paste/drop images or files · ⌘/Ctrl+Enter to submit · Esc to cancel`,expandMsg:`Expand`,collapseMsg:`Collapse`,toolCalls:`tool calls`,bashRuns:`bash runs`,images:`images`,update:`Update`,updateTip:`Check & update pi-web-ui`,currentVersion:`Current version`,latestVersion:`Latest version`,checkingUpdate:`Checking…`,checkUpdate:`Check for updates`,upToDate:`You're up to date`,updateAvailable:`New version v{version} available`,updateJustPublished:`v{version} was just published — npm cache may lag; if the new version isn't detected yet, re-check in a moment`,updateNow:`Update in terminal`,updateTabTitle:`Update pi-web-ui`,updateTerminalHint:`Clicking runs npm i -g pi-web-ui@latest in a visible terminal; restart the service afterwards to take effect (pi-web-ui server restart).`,updateDesktopNote:`The desktop app doesn't use the global npm install: its server ships inside the app bundle, so the terminal command above does nothing for it. Use the in-app update below, or grab a new installer from the downloads page.`,updateDesktopCheck:`Check for desktop updates`,updateDesktopChecking:`Checking for desktop updates…`,updateDesktopAvailable:`New desktop release v{version} available`,updateDesktopDownload:`Download update`,updateDesktopDownloading:`Downloading {n}%`,updateDesktopDownloaded:`Download ready — install & restart to apply`,updateDesktopInstall:`Install & restart`,updateDesktopManual:`Manual install from downloads page`,updateDesktopError:`Desktop update failed: {error}`,updateDesktopNoBridge:`This desktop shell predates the built-in updater — grab a new installer from the downloads page.`,updatesAllTitle:`Component updates`,updatesAllBadge:`{n} updates`,updatesAllUpToDate:`All components up to date`,kindWebUi:`Web UI`,kindPiCore:`Core`,kindPackage:`Package`,kindGitExtension:`Git package`,kindPlugin:`Plugin`,pluginCheckUpdates:`Check plugin updates`,pluginCheckUpdatesHint:`Check if installed UI plugins have updates (compares remote versions and commits)`,pluginUpdateAvailableBadge:`Updatable`,pluginUpdateAvailableDetail:`Update available: {version}`,pluginAllUpToDate:`All plugins are up to date`,updatesAllRefresh:`Re-check all`,updateCheckFailed:`Check failed`,updateBtn:`Update`,updateAllBtn:`Update all`,updatePkgTabTitle:`Update {name}`,updateAllTabTitle:`Update all components`,piCoreSplitRun:`service runs v{running}`,piSdkSplitNote:`This service runs pi v{running}; a newer global pi v{installed} is installed. Restart the service to catch up (the newest copy is followed by default); PI_WEB_SDK=bundled pins the bundled copy — upgrading pi-web-ui refreshes it too.`,piSdkBundledNote:`Currently using the bundled pi engine v{running} (updated with pi-web-ui). Install the global engine and restart the service to switch to it (the newest copy is followed by default).`,installGlobalEngineBtn:`Install global engine`,installGlobalEngineTabTitle:`Install global pi engine`,restartService:`Restart service`,restartingService:`Restarting…`,restartServiceTip:`Restart the pi-web-ui service ({name}): this instance is supervised (launchd/systemd/Windows watchdog), so it comes back automatically and the page reconnects — run it after an update`,computer:`This PC`,rootDir:`Root`,homeDir:`Home directory`,desktopDir:`Desktop`,filesHelp:`Navigate: click a folder to enter, a file to preview, '..' to go up; Root returns to the current project, This PC browses all drives, 🏠 jumps to your home directory, 🖥️ to the desktop.
|
|
165
|
+
只在你确认后打开。`,settingsExtensions:`插件`,settingsUiPlugins:`界面插件`,pluginListTab:`插件列表`,noUiPlugins:`未安装界面组件(<dataDir>/plugins/)`,pluginPhaseActive:`运行中`,pluginPhaseDisabled:`已禁用`,pluginPhaseFailed:`失败`,pluginPhaseIdle:`纯前端`,pluginRescan:`重新扫描`,pluginRescanHint:`重新扫描插件目录(新增/修复后生效;失败记录清空重记)`,dshPatches:`DSH 用户补丁`,dshPatchesDesc:`启动时按文件名序加载的 Cordis patch(<dataDir>/dsh-patches/*.yml)。新增/修改后点「重扫」重启运行时生效;失败的文件会被跳过并打印到运行时 stderr。`,dshPatchesRescan:`重扫`,dshPatchesRescanHint:`重新扫描补丁目录并重启 DSH 运行时使新补丁生效`,dshPatchesEmpty:`未放置补丁文件`,dshPatchesPath:`补丁目录:`,dshPreset:`Agent 预设`,dshPresetNewChat:`以此预设开新对话`,dshPresetLocked:`已锁定`,dshPresetBlankOnly:`首轮发言后锁定,空白会话可切换`,dshPresetBroken:`(不可用)`,dshPresetUser:`自建`,dshPresetDefaultTag:`默认`,dshPresetCurrent:`当前`,dshPresetMinimalNote:`极简模式:仅持久 shell;宿主插件工具与问卷不可用`,dshDefaultPreset:`默认预设`,dshDefaultPresetDesc:`新对话使用的预设;空白会话可随时切换,首轮发言后锁定`,dshPresetUserNote:`自建预设来自用户预设目录(与 shell 同等信任);用裸包名的自建组合在此无法挂载(已知限制)`,dshPerm:`权限`,dshPermReadOnly:`仅可查看`,dshPermReadOnlyDesc:`只能读文件、跑只读命令;写操作一律拒绝,不弹确认`,dshPermWorkspaceWrite:`工作区内修改`,dshPermWorkspaceWriteDesc:`工作区内读写,不弹确认;超出范围的操作直接拒绝`,dshPermFullAccess:`完全权限`,dshPermFullAccessDesc:`关闭沙箱,整机任意读写;只给信任的任务`,dshPermFullAccessTag:`高危`,dshPermCustom:`自定义`,dshPermConfirmFull:`再点一次确认开启完全权限`,dshPermDefault:`新会话默认权限`,dshPermDefaultDesc:`新对话的初始权限;当前对话可随时热切换,无需重启`,uiPluginNoSource:`手工安装,无来源信息,无法在线更新`,uiPluginPerms:`能力声明`,pluginDiagTitle:`诊断信息`,pluginDiagShow:`诊断`,pluginDiagHide:`收起`,pluginLogTitle:`运行日志`,pluginLogShow:`日志`,pluginLogHide:`收起`,pluginLogLevel:`级别`,pluginLogAll:`全部`,pluginLogEmpty:`暂无日志`,pluginLogClear:`清空`,pluginDomNeed:`⚠ 请求完全 DOM 访问`,pluginDomDesc:`该插件可直接读写页面 DOM(绕过界面布局限制)。只给可信来源的插件授权;授权后其界面代码可碰顶栏/输入框/任意页面元素。`,pluginDomGrant:`授权 DOM 访问`,pluginDomRevoke:`撤销 DOM 访问`,pluginDomGranted:`已授权完全 DOM 访问`,pluginSettingsTitle:`插件配置`,pluginSettingsShow:`配置`,pluginSettingsHide:`收起`,pluginSettingsSave:`保存插件设置`,pluginSettingsSaving:`保存中…`,pluginSettingsReset:`恢复默认`,pluginSettingsInherit:`跟随全局默认`,pluginSecretSet:`已设置(加密保存,留空不改)`,pluginSecretUnset:`未设置(加密保存)`,settingsPresets:`预设`,settingsSubagentTemplates:`子代理模板`,settingsSubagentTemplatesDesc:`配置子代理预设(角色系统提示词 + 技能/扩展白名单 + 可选模型与思考强度)。AI 派生子代理时可选用模板(subagent_spawn 的 template 参数),也可不传按默认运行;停用的模板保留在面板但对 AI 不可见。`,noSubagentTemplates:`还没有子代理模板。AI 派生子代理时可选用模板(角色提示词 + 技能/扩展白名单 + 可选模型与思考强度),也可以不传 template 按默认配置运行。`,subagentTemplateNew:`新建模板`,subagentTemplateEdit:`编辑`,subagentTemplateClosed:`已停用`,tplDefaultBadge:`默认`,subagentTemplateOffHint:`关闭的模板保留在面板、可随时重新启用,但 AI 工具查询不到、不能选择`,subagentTemplateEnable:`启用`,subagentTemplateDisable:`停用`,subagentDefaultModelLabel:`子代理默认模型`,subagentFollowMain:`跟随主对话当前模型`,subagentDefaultModelHint:`所有子代理的兜底模型(模板里指定的模型和 subagent_spawn 的 model 参数优先级更高);不改主对话模型。`,subagentNoModels:`暂无可用的模型(需要先配置服务商 API Key)——子代理将跟随主对话模型。`,tplNamePlaceholder:`模板名(AI 用 subagent_spawn 的 template 参数引用)…`,tplDescriptionPlaceholder:`简介(AI 据此判断适用场景)…`,tplDescriptionEnPlaceholder:`英文简介(英文 UI 时 AI 看这个,留空则用中文简介)…`,tplPromptModeLabel:`系统提示词模式`,tplModelLabel:`模型(空 = 跟随主对话)`,tplThinkingLabel:`思考强度`,tplThinkingFollowMain:`跟随主对话当前思考强度`,tplThinkingHint:`空 = 跟随主对话当前思考强度(与不指定模型时的「跟随主对话」同语义);模型不支持所选档位时自动收敛到最接近的可用档位。`,tplSystemPromptLabel:`系统提示词`,tplSystemPromptPlaceholder:`模板角色系统提示词…(append 模式可留空)`,tplSystemPromptEnPlaceholder:`英文系统提示词…(英文 UI 时生效,留空则用中文)`,tplWhitelistHint:`白名单:勾选 = 子代理只启用这些;全部不勾 = 跟随主会话设置`,tplSkillsLabel:`技能白名单`,tplExtensionsLabel:`扩展白名单`,tplSave:`保存模板`,tplCancel:`取消编辑`,tplDelete:`删除模板`,settingsScheduler:`定时任务`,schedulerDesc:`到点自动让 Agent 干活(依赖巡检、跑测试、生成早报……):无头伪客户端执行,无浏览器也能跑;跑完推送通知,历史可查。`,schedulerEmpty:`还没有定时任务。点右上角「新建任务」安排第一个:每天 9 点巡检、每小时跑一次测试都可以。`,schedulerNew:`新建任务`,schedulerEdit:`编辑`,schedulerDelete:`删除`,schedulerRunNow:`立即运行`,schedulerRunning:`执行中…`,schedulerEnable:`启用`,schedulerDisable:`停用`,schedulerEnabled:`已启用`,schedulerDisabled:`已停用`,schedulerNameLabel:`任务名称`,schedulerNamePlaceholder:`如:每日依赖与代码健康检查…`,schedulerDescPlaceholder:`说明(可选):这个任务是干什么的…`,schedulerCwdLabel:`执行目标项目`,schedulerCwdPlaceholder:`/绝对/路径/到/项目…`,schedulerUseCurrentCwd:`用当前项目`,schedulerKindLabel:`调度周期`,schedulerKindCron:`Cron 表达式`,schedulerKindInterval:`固定间隔`,schedulerCronPlaceholder:`如 0 9 * * *(每天 9:00)`,schedulerPresetDaily:`每天 9:00`,schedulerPresetHourly:`每小时整点`,schedulerPresetHalfHour:`每 30 分钟`,schedulerPresetWorkday:`工作日 9:00`,schedulerPresetMonday:`每周一 9:00`,schedulerPresetCustom:`自定义…`,schedulerIntervalMinutes:`间隔(分钟,最少 1 分钟)`,schedulerPromptLabel:`触发指令`,schedulerPromptPlaceholder:`给 Agent 的具体任务,如:审计依赖并报告可升级项…`,schedulerModelLabel:`模型(空 = 跟随默认)`,schedulerThinkingLabel:`思考强度(空 = 跟随默认)`,schedulerCatchUp:`服务重启后补跑漏掉的一次`,schedulerCatchUpHint:`勾选后,服务停机期间错过的触发会在下次启动时补跑一次;不勾选则跳过。`,schedulerNextFire:`下次`,schedulerLastRun:`上次`,schedulerNeverRun:`从未运行`,schedulerHistory:`历史`,schedulerManualBadge:`手动`,schedulerRunOk:`成功`,schedulerRunFail:`失败`,schedulerConfirmDelete:`确定删除定时任务「{name}」吗?历史记录一并清除。`,schedulerSave:`保存任务`,schedulerCancelEdit:`取消编辑`,tplInherit:`跟随主会话`,settingsEnabled:`已启用`,settingsDisabled:`已禁用`,presetNamePlaceholder:`预设名称…`,saveAsPreset:`保存为预设`,applyPreset:`应用`,deletePreset:`删除预设`,noSkills:`暂无技能`,noExtensions:`暂无插件`,noPresets:`暂无预设(调整好当前设置后,在上方输入名称保存为预设)`,loadingSession:`正在加载会话…`,connectingServer:`正在连接 pi-web-ui 服务器…`,localePacks:`语言包`,localeGetMore:`获取更多语言`,localeInstalled:`已安装`,localeInstall:`下载`,localeRemove:`移除`,localeDownloading:`下载中…`,localeRemoving:`移除中…`,localeInstallFailed:`下载失败:{error}`,localeListFailed:`获取语言包列表失败:{error}`,localeRemoveHint:`移除后随时可重新下载`,wallpaperTitle:`聊天背景图`,wallpaperDesc:`给整个窗口加一张背景图(左右面板、顶栏、底栏也会透出):主题自带的图会自动生效,在此填地址则优先用你的;用压暗与模糊保证文字清晰。`,wallpaperUrlPh:`图片地址(https://…,留空关闭)`,wallpaperDim:`压暗`,wallpaperBlur:`模糊`,wallpaperClear:`清除`,wallpaperUpload:`上传图片`,wallpaperUploadFailed:`图片读取失败或过大,请换一张试试`,skillFullTextLabel:`技能全文注入`,skillFullTextDesc:`把技能文件正文直接展开进系统提示词(单文件 8KB、总量 32KB 封顶),否则只列名录由模型按需读取`,skillFullTextShort:`全文`,delegateOpenSubagent:`查看子代理`,delegateSecTask:`任务`,delegateSecExpected:`期望产出`,delegateSecTools:`可用工具`,delegateSecMustDo:`必须做`,delegateSecMustNotDo:`禁止做`,delegateSecContext:`上下文`,copyConversationId:`复制对话 ID`,copyConversationPath:`复制会话文件路径`,quoteConversation:`引用到输入框(AI 可读)`,quoteConversationShort:`引用`,attachConversation:`对话引用:{name}(AI 经 conversation_read 按需读取)`,attachConversationShort:`对话`,presentOpenLocal:`本地打开`,presentMissing:`文件不存在或不可读(可能已被移动、删除或超出工作区)`,presentEmpty:`没有可展示的文件`,presentAutoOpen:`自动打开 AI 展示的预览`,presentAutoOpenDesc:`AI 用 present_files 展示文件、并标了「先看这个」时,自动弹出文件预览窗口;关闭(默认)则只在卡片里显示,点一下再看。`,presentFilesEnabledDesc:`让 AI 把产物(截图 / 图表 / 视频 / 报告 / 日志)作为预览卡片推到对话里:图片、视频、音频直接在消息里显示/播放,文本给开头摘录 + 一键开预览弹窗,每条都带「本地打开 / 在文件夹中显示 / 下载 / 复制路径」。自动弹预览窗的开关在「对话」页。`,presentFilesOffHint:`已关闭:AI 只能用文字告诉你文件路径,没有卡片,也没有本地打开按钮`,skillEnabledDesc:`技能正文按名加载(技能名录仍注入系统提示词):真要用到某个技能时才取全文,不再让模型拼路径去 read。`,skillOffHint:`已关闭:AI 不能按名取技能全文(提示词里的技能名录不受影响)`,claimFilesEnabledDesc:`声明你要改哪些文件,让同项目的并行对话绕行(纯建议,不拦编辑):开着 AI 才知道能认领,先到先得,过期自动释放。`,claimFilesOffHint:`已关闭:AI 不能再认领文件(并行触碰提醒照常工作,只是少了事前意图这一路)`,planUpdateEnabledDesc:`结构化任务计划更新(Plan Mode / Step State Machine):让模型将复杂任务拆解为步骤并实时更新推进状态。`,planUpdateOffHint:`已关闭:AI 不能再更新结构化计划看板`,compactContextEnabledDesc:`根据当前问题主动压缩上下文:允许 AI 自主指定压缩重点、保留与当前任务相关的核心上下文并去除无关历史细节,自主控制保留范围并在回合后生效。`,compactContextOffHint:`已关闭:AI 不能主动调用上下文压缩工具(仍可用 /compact 命令或触发软上限自动压缩)`,evalEnabledDesc:`在隔离的代码求值沙箱中执行 Python 或 JavaScript/TypeScript 代码,变量状态跨调用保持;适用于即时数学计算、数据处理与算法验证(默认关闭,防工具挤占)。`,evalOffHint:`已关闭:AI 不能使用持久代码求值沙箱(可使用 bash 工具运行临时脚本)`,patchToolEnabledDesc:`高可靠结构化行补丁工具(Hashline):基于内容哈希锚点与语法块(AST Block)替换代码,支持剪切/粘贴寄存器;文件被外部改动时自动执行三方合并(3-Way Merge)冲突自愈,避免大文件编辑幻觉与行号漂移。`,patchToolOffHint:`已关闭:AI 只能使用基础 edit 工具进行纯文本精确字符串替换`,lspToolEnabledDesc:`原生语言服务器协议(LSP)工具:为 AI 提供 IDE 级的代码语义智能(支持定义跳转、引用查询、类型悬停、编译诊断、符号大纲 documentSymbol、精确符号代码切片 read_symbol、工作区全局符号搜索 workspaceSymbol、编辑影响级联诊断 cascade),多子代理共享进程池与闲置休眠,免外部插件开箱即用。`,lspToolOffHint:`已关闭:AI 将无法主动调用 LSP 语义工具,依赖全局搜索或文本匹配定位符号`,toolInfoMenuLabel:`显示工具详细信息`,toolInfoTitle:`工具详细信息`,toolInfoLoading:`正在读取工具定义…`,toolInfoUnsupported:`当前引擎不支持查看工具定义`,toolInfoMissing:`未找到这个工具的定义(可能来自已卸载的插件或旧版本)`,toolInfoActive:`已启用`,toolInfoInactive:`已停用`,toolInfoSource:`来源`,toolInfoDescription:`说明`,toolInfoNoDescription:`这个工具没有提供说明`,toolInfoPromptSnippet:`提示词摘要`,toolInfoGuidelines:`提示词要点`,toolInfoParams:`参数`,toolInfoParamsNone:`这个工具没有参数`,toolInfoSchemaDropped:`参数 schema 太大,已省略(见下方原始 JSON)`,toolInfoRawSchema:`原始 JSON Schema`,toolInfoRequired:`必填`,toolInfoFootnote:`这是工具的定义说明,不含本次调用的参数与结果。`},en={docTitle:`pi-web-ui — pi coding agent`,cancel:`Cancel`,ok:`OK`,save:`Save`,close:`Close`,widgetExpand:`Click to view full output`,collapsePanel:`Collapse panel`,expandPanel:`Expand panel`,dragToResize:`Drag to resize · double-click to reset`,loading:`Loading…`,connected:`Connected`,connecting:`Connecting…`,reconnecting:`Reconnecting…`,language:`Language`,langZh:`中文`,langEn:`English`,langIt:`Italiano`,langJa:`日本語`,langKo:`한국어`,langFr:`Français`,langDe:`Deutsch`,langEs:`Español`,langRu:`Русский`,langPt:`Português`,githubRepo:`GitHub repository (xing-shuyin/pi-web-ui)`,copy:`Copy`,viewSwitch:`Switch view`,chat:`Chat`,terminal:`Terminal`,selectModel:`Select model`,availableModels:`Available models`,allProviders:`All`,providers:`Providers`,noModels:`No models available (configure an API key first)`,reasoning:`reasoning`,vision:`vision`,refreshModels:`Refresh model list (keeps manual rows, merges new ones)`,manageModels:`⚙ Manage models (add / edit)`,manageModelsTitle:`Manage models`,setGlobalDefault:`☆ Set as global default (new projects follow it)`,clearGlobalDefault:`★ Clear global default`,globalDefaultBadge:`Global default`,thinkingLevel:`Thinking level`,thinking:`Thinking`,thinkingChip:`{level}`,sound:`Sound`,theme:`Theme`,themeDefault:`Dark (default)`,themeGroupClassics:`Classics`,themeGroupBuiltin:`Original`,themeLight:`Light`,themeDark:`Dark`,newChat:`New chat`,newChatEphemeral:`Ephemeral chat`,newChatEphemeralTip:`Ephemeral chat (in-memory only, auto-discarded on close, not saved to history)`,ephemeralBadge:`Ephemeral`,ephemeralBannerText:`Ephemeral session: messages are in-memory only, discarded on close, not saved to history.`,more:`More`,brand:`Brand`,newChatTip:`New chat (sessions are saved per browser)`,"thinking.off":`Off`,"thinking.minimal":`Minimal`,"thinking.low":`Low`,"thinking.medium":`Medium`,"thinking.high":`High`,"thinking.xhigh":`Extra high`,"thinking.max":`Max`,thinkingUnsupported:`Not supported by this model — snapped to the nearest supported level`,context:`Context`,contextUsage:`Context usage`,cumulativeCost:`Cumulative cost`,sessionMessages:`Session messages`,messages:`messages`,pluginStatus:`Plugin status`,engineBadge:`Engine`,working:`Working`,queued:`queued`,enterPath:`Type a path, Enter to switch`,cwdTip:`Working directory: {path} (click to switch)`,manageProjects:`Manage projects and working directories`,projectPickerTitle:`Choose a working directory`,newProject:`New project`,projectName:`Project name`,createAndOpenProject:`Create and open`,invalidProjectName:`Enter a project name without path separators`,cwdGoUp:`Up one level`,cwdPickCurrent:`Select this folder`,cwdChoose:`Select`,cwdEnter:`Enter`,cwdEmpty:`(empty)`,cwdNewFolder:`New folder`,cwdNewName:`Folder name`,cwdCreate:`Create`,cwdCancel:`Cancel`,cacheHit:`Cache hit`,cacheHitTip:`read {read} · write {write} · miss {miss} (of {input} input tokens)`,tps:`t/s`,rateTip:`Live generation rate (estimated)`,hostResources:`Host resources`,hostProcessor:`CPU`,hostMemory:`RAM`,hostResourcesTip:`Host running pi-web-ui · CPU is a ~10s average (2s samples); a few seconds of skew vs Task Manager is normal`,folderRef:`Folder reference: {path}`,refOnly:`Reference only: {path}`,attachContent:`Attached content: {path}`,attachLines:`Attached selected lines: {path} (lines {start}-{end})`,attachImage:`Image: {name}`,attachFile:`File: {name}`,removeAttachment:`Remove attachment`,attachHint:`Will be sent with the next message`,uploadFile:`Add files (images / text / any file — or drag in / paste a screenshot)`,dropHereToAttach:`Release to attach file`,imageNotSupported:`The current model doesn't support vision — images will be transcribed by the vision bridge (may be ignored if no vision model is configured)`,imageLoadFailed:`Couldn't read image: {name}`,fileLoadFailed:`Couldn't read file: {name}`,fileTooLarge:`File too large, skipped (> {size}MB): {name}`,foldersNotSupported:`Folders can't be dropped directly — expand and pick files instead`,placeholderStreaming:`The agent is working… press Enter to steer, or click Queue to send after the reply finishes`,placeholderStreamingQueued:`The agent is working… press Enter or click Queue — delivered after the reply finishes (this engine cannot steer)`,placeholderIdle:`Message pi — Enter to send, / for commands`,placeholderConnecting:`Connecting to server…`,stopAgent:`Stop agent`,stop:`Stop`,bgTasks:`Background tasks`,bgTasksTip:`Servers the AI started in the background (npm run dev & etc.) — stop them individually or all at once; they survive the conversation`,bgTasksEmpty:`No background tasks`,bgTasksDesc:`Processes the AI started that are still listening (detected by port)`,bgTaskPort:`Port`,bgTaskPid:`PID`,bgTaskSince:`Started`,bgTaskStop:`Stop`,bgTaskStopAll:`Stop all`,bgTaskRefresh:`Refresh`,bgTaskJustNow:`just now`,bgTaskMinutes:`{n} min ago`,bgTaskHours:`{n} hr ago`,bgTaskDays:`{n} days ago`,stopBash:`Stop`,stopBashTip:`Stop the running bash command (conversation continues)`,supplement:`Queue`,supplementTip:`Add to queue: sent only after the whole run finishes (no interruption)`,steerTip:`Steer: send right away — the current turn responds immediately (Enter)`,queueSteerTag:`Steer`,queueFollowTag:`Queued`,queueRemoveTip:`Remove this queued message`,queueRecallTip:`Recall into the input box for editing`,sendTip:`Send (Enter)`,composerResize:`Drag to resize the input height (double-click to reset)`,quickPhrases:`Quick phrases`,quickPhrasesDesc:`A row of frequently-used phrase buttons above the input box — click to send (current file attachments are included, the input draft is kept)`,quickPhrasesEnabled:`Enable quick phrases`,quickPhrasesOffHint:`Off: the phrase buttons above the input box are hidden (saved phrases are kept and can be re-enabled anytime)`,quickPhrasesPlaceholder:`Type a frequently-used phrase… (Enter to add)`,quickPhrasesAdd:`Add`,quickPhrasesEmpty:`No quick phrases yet — add your first one below`,quickPhrasesTip:`Click to send: {text}`,quickPhrasesSendTip:`Left-click to steer, right-click to queue`,quickPhrasesMoveUp:`Move up`,quickPhrasesMoveDown:`Move down`,quickPhrasesDelete:`Delete this phrase`,quickPhrasesEdit:`Edit this phrase`,quickPhrasesEditPh:`Edit phrase… (Enter to save, Esc to cancel)`,quickPhrasesReset:`Reset to defaults`,slashCommands:`Commands`,slashMenuHint:`↑↓ select · Enter/Tab complete`,atMentions:`Mentions`,atMenuHint:`↑↓ select · Enter/Tab insert`,slashHelpTitle:`pi commands`,slashHelpHint:`Type / anytime to open the command list`,slashLoading:`Loading commands… (available once connected)`,slashBuiltin:`Builtin`,slashExtension:`Extension`,slashPrompt:`Template`,slashSkill:`Skill`,slashPlugin:`Plugin`,slashCopied:`Copied the last assistant reply`,slashCopyFailed:`Copy failed — please copy manually`,slashCopyEmpty:`No assistant reply to copy yet`,recentProjects:`Recent projects`,runningConversations:`Running chats`,elsewhereBadge:`Elsewhere`,elsewhereTip:`Conversation open in another tab / device (running, or finished but still held there; right-click to take over and view it here)`,elsewhereActions:`Actions (take over here, copy id…)`,takeoverConversation:`Take over to this page`,takeoverConfirm:`Confirm take over to this page?`,takeoverHasQuestion:`Has a pending question — click to answer it here`,waitingQuestionBadge:`Waiting on your answer — click to view`,subagentBadge:`Subagent`,convErrorBadge:`Subagent failed: {error}`,subagentTitle:`Subagent · {title}`,historySessions:`History`,openHistory:`History`,openFiles:`Files`,openProject:`Open project`,streaming:`Streaming…`,noHistory:`No previous chats`,current:`Current`,messageCount:`{n} messages`,tuiTip:`Chat in the pi terminal (TUI)`,deleteProject:`Remove from recent projects`,deleteProjectConfirm:`Confirm remove`,deleteSession:`Delete this chat transcript permanently`,deleteSessionConfirm:`Confirm delete`,renameSession:`Rename this chat`,renameSessionPlaceholder:`Type a new name…`,renameSessionConfirm:`Rename`,dismissConversation:`Dismiss from running (keep in history)`,dismissConversationConfirm:`Confirm dismiss`,dismissFinishedSubagents:`Dismiss finished subagents ({n})`,dismissFinishedSubagentsScoped:`Dismiss finished subagents under this chat, incl. nested ({n})`,dismissConversationWithSubagents:`Also dismiss finished subagents ({n})? Make sure their results are no longer needed — click again to confirm`,dismissConversationWithSubagentsMixed:`Also dismiss finished subagents ({n})? {m} running one(s) stay, parent stays; make sure the finished ones are no longer needed — click again to confirm`,dismissStreamingConfirm:`Still running — confirm force-dismiss? (The run will be aborted)`,dismissFinishedOnly:`Dismiss finished only ({n})`,dismissForceAll:`Force-dismiss all (incl. {n} subagent(s))`,forceDismissTitle:`Force-dismiss this conversation and all {n} subagent(s) ({m} running will be aborted)`,forceDismissConversation:`Force-dismiss conversation (incl. all subagents)`,persistSubagent:`Convert to Regular Conversation`,saveEphemeral:`Save as regular conversation`,forceDismissConfirm:`Confirm force-dismiss? Unfinished runs will be aborted — click again`,noFinishedSubagents:`No finished subagents to dismiss`,collapseSection:`Collapse`,expandSection:`Expand`,emptyChat:`Empty chat`,reaskDirectly:`Re-ask`,reaskDirectlyTip:`Re-ask from here directly without editing (forks a new conversation; original kept)`,editReask:`Edit & re-ask`,editReaskTip:`Edit this question and re-ask from here (forks a new conversation; the original is kept)`,forkSession:`Fork branch`,forkSessionTip:`Fork a new branch session from this message (truncates prior transcript)`,rollbackSession:`Rollback to here`,rollbackSessionTip:`Discard all content after this message and continue here`,rollbackConfirm:`Are you sure you want to rollback to this message? All subsequent messages will be discarded.`,rollbackRestoreWorkspace:`Restore workspace files to this checkpoint (Dual-State Rollback)`,rollbackRestoreWorkspaceTip:`Revert physical files to the checkpoint state when this message was sent (via Git shadow snapshot)`,toolApprovalTitle:`Tool Execution Approval (Human-in-the-Loop)`,toolApprovalApprove:`Approve`,toolApprovalDeny:`Deny`,toolApprovalEditAndRun:`Edit & Run`,toolApprovalRiskAlert:`High-risk operation or critical config modification detected`,toolApprovalCommand:`Command`,toolApprovalParams:`Tool Parameters`,toolApprovalEditPlaceholder:`Modify parameter JSON in place…`,toolApprovalReason:`Reason for Interception`,toolApprovalCategory:`Category`,toolApprovalAllowCategory:`Allow this kind here`,toolApprovalAllowCategoryHint:`Stop asking for this category of high-risk operations in this conversation (revocable under Settings → Tools)`,toolApprovalAllowConversation:`Allow all here`,toolApprovalAllowConversationHint:`Stop asking for any high-risk operation in this conversation (revocable under Settings → Tools)`,toolApprovalEnabled:`Tool execution approval (human-in-the-loop)`,toolApprovalEnabledDesc:`On: high-risk operations (rm -rf / destructive git / sensitive files / writes outside the workspace / plugin confirmation requests) pop a dialog for you to approve, deny or edit the parameters. Off: no approvals at all (built-in detection passes silently, plugin confirmation requests are treated as allowed).`,toolApprovalPolicyTitle:`Remembered allowances (this conversation)`,toolApprovalPolicyAllowAll:`All approvals allowed in this conversation`,toolApprovalPolicyRevoke:`Revoke`,toolApprovalPolicyHint:`In-memory only: restarting the service or opening a new conversation restores prompting. The policy travels with the conversation (e.g. on manual takeover).`,settingsApprovalRules:`Approval Rules`,settingsApprovalRulesDesc:`Global human-in-the-loop approval rules. Configure ask, deny, or allow actions for tool calls based on regex/glob/path matching. Evaluated top-to-bottom on first match.`,manageApprovalRules:`Manage Approval Rules`,approvalRuleNew:`Add Rule`,approvalRuleEdit:`Edit Rule`,approvalRuleDelete:`Delete`,approvalRuleReset:`Reset to Default`,approvalRuleResetConfirm:`Reset this built-in rule to system defaults?`,approvalRuleDeleteConfirm:`Are you sure you want to delete this custom approval rule?`,approvalRuleActionAsk:`Ask`,approvalRuleActionDeny:`Deny`,approvalRuleActionAllow:`Allow`,approvalRuleTools:`Target Tools`,approvalRuleToolsTip:`Comma-separated tool names (e.g. bash, write, edit); use * to match all tools`,approvalRuleField:`Target Field`,approvalRuleFieldCommand:`Command (command)`,approvalRuleFieldPath:`File Path (path)`,approvalRuleFieldParams:`Full Params JSON (params)`,approvalRuleMatch:`Match Mode`,approvalRuleMatchRegex:`Regular Expression (regex)`,approvalRuleMatchGlob:`Glob Pattern (glob)`,approvalRuleMatchContains:`Contains Substring (contains)`,approvalRuleMatchPrefix:`Prefix (prefix)`,approvalRuleMatchOutsideWs:`Outside Workspace Path (outside_workspace)`,approvalRuleValue:`Pattern / Value`,approvalRuleValueTip:`Pattern according to match mode, e.g. rm -rf or \\.env$`,approvalRuleLabel:`Rule Label (Chinese)`,approvalRuleLabelEn:`Rule Label (English)`,approvalRuleReason:`Reason (Chinese)`,approvalRuleReasonEn:`Reason (English)`,approvalRuleEnabled:`Enable this rule`,approvalRuleBuiltin:`Built-in`,approvalRuleEmpty:`No approval rules configured. Click '+ Add Rule' to add custom policies.`,approvalRuleMoveUp:`Move Up`,approvalRuleMoveDown:`Move Down`,planBoardTitle:`Task Plan Board (Plan Mode)`,planBoardSteps:`Step List`,planBoardProgress:`Overall Progress`,planBoardNoPlan:`No active plan`,planBoardCompleted:`Completed`,planBoardInProgress:`In Progress`,planBoardPending:`Pending`,planBoardFailed:`Failed`,clear:`Clear`,confirm:`Confirm`,forkBadge:`Branch`,forkBadgeTip:`Forked from`,reaskFromHere:`Re-ask from here`,editPlaceholder:`Edit the question…`,editHint:`⌘/Ctrl+Enter to submit · Esc to cancel`,editAttachmentHint:`Original attachments kept — paste/drop images or files · ⌘/Ctrl+Enter to submit · Esc to cancel`,expandMsg:`Expand`,collapseMsg:`Collapse`,toolCalls:`tool calls`,bashRuns:`bash runs`,images:`images`,update:`Update`,updateTip:`Check & update pi-web-ui`,currentVersion:`Current version`,latestVersion:`Latest version`,checkingUpdate:`Checking…`,checkUpdate:`Check for updates`,upToDate:`You're up to date`,updateAvailable:`New version v{version} available`,updateJustPublished:`v{version} was just published — npm cache may lag; if the new version isn't detected yet, re-check in a moment`,updateNow:`Update in terminal`,updateTabTitle:`Update pi-web-ui`,updateTerminalHint:`Clicking runs npm i -g pi-web-ui@latest in a visible terminal; restart the service afterwards to take effect (pi-web-ui server restart).`,updateDesktopNote:`The desktop app doesn't use the global npm install: its server ships inside the app bundle, so the terminal command above does nothing for it. Use the in-app update below, or grab a new installer from the downloads page.`,updateDesktopCheck:`Check for desktop updates`,updateDesktopChecking:`Checking for desktop updates…`,updateDesktopAvailable:`New desktop release v{version} available`,updateDesktopDownload:`Download update`,updateDesktopDownloading:`Downloading {n}%`,updateDesktopDownloaded:`Download ready — install & restart to apply`,updateDesktopInstall:`Install & restart`,updateDesktopManual:`Manual install from downloads page`,updateDesktopError:`Desktop update failed: {error}`,updateDesktopNoBridge:`This desktop shell predates the built-in updater — grab a new installer from the downloads page.`,updatesAllTitle:`Component updates`,updatesAllBadge:`{n} updates`,updatesAllUpToDate:`All components up to date`,kindWebUi:`Web UI`,kindPiCore:`Core`,kindPackage:`Package`,kindGitExtension:`Git package`,kindPlugin:`Plugin`,pluginCheckUpdates:`Check plugin updates`,pluginCheckUpdatesHint:`Check if installed UI plugins have updates (compares remote versions and commits)`,pluginUpdateAvailableBadge:`Updatable`,pluginUpdateAvailableDetail:`Update available: {version}`,pluginAllUpToDate:`All plugins are up to date`,updatesAllRefresh:`Re-check all`,updateCheckFailed:`Check failed`,updateBtn:`Update`,updateAllBtn:`Update all`,updatePkgTabTitle:`Update {name}`,updateAllTabTitle:`Update all components`,piCoreSplitRun:`service runs v{running}`,piSdkSplitNote:`This service runs pi v{running}; a newer global pi v{installed} is installed. Restart the service to catch up (the newest copy is followed by default); PI_WEB_SDK=bundled pins the bundled copy — upgrading pi-web-ui refreshes it too.`,piSdkBundledNote:`Currently using the bundled pi engine v{running} (updated with pi-web-ui). Install the global engine and restart the service to switch to it (the newest copy is followed by default).`,installGlobalEngineBtn:`Install global engine`,installGlobalEngineTabTitle:`Install global pi engine`,restartService:`Restart service`,restartingService:`Restarting…`,restartServiceTip:`Restart the pi-web-ui service ({name}): this instance is supervised (launchd/systemd/Windows watchdog), so it comes back automatically and the page reconnects — run it after an update`,computer:`This PC`,rootDir:`Root`,homeDir:`Home directory`,desktopDir:`Desktop`,filesHelp:`Navigate: click a folder to enter, a file to preview, '..' to go up; Root returns to the current project, This PC browses all drives, 🏠 jumps to your home directory, 🖥️ to the desktop.
|
|
166
166
|
Manage: right-click for new file/folder, rename, copy/cut/paste, duplicate, delete, upload; files can be downloaded, row buttons copy name/path.
|
|
167
167
|
Switch projects: right-click a folder → Open as project, or click the bottom-right 📁 path button to type/pick a directory.
|
|
168
168
|
Send to AI: row buttons attach content or reference a path, or drag files into the input.`,workspaceRoots:`Workspace roots`,workspaceRootsHint:`Roots the file tree can switch to; plugins may read and write them without a separate prompt.`,addWorkspaceRoot:`Add as workspace root`,addWorkspaceRootHint:`Add the current directory as a workspace root (switchable in the file tree; plugins may read/write it without a separate prompt)`,removeWorkspaceRoot:`Remove workspace root`,noFiles:`No files`,filesTruncated:`Directory too large — list truncated (first 2000 shown)`,linkFolderTip:`Link folder path to chat`,referenceTip:`Reference path only (AI reads on demand)`,previewFile:`Preview`,downloadFile:`Download file`,copyName:`Copy name`,copyPath:`Copy path`,downloadFailed:`Download failed: {error}`,fileNotFoundShort:`File not found`,pluginMountFailed:`Plugin {name} failed to mount`,pluginViewLoading:`Loading plugin view…`,pluginViewLoadFailed:`Plugin view failed to load`,pluginViewLoadFailedHint:`Open console (F12) for the plugin error, or check the server log; you can also reinstall the plugin in Settings → Plugins.`,pluginViewRetry:`Retry`,liveOutputOmitted:`…[{n} chars omitted above]…
|
|
@@ -324,14 +324,14 @@ Avoid three test anti-patterns: tests coupled to the implementation, tautologica
|
|
|
324
324
|
|
|
325
325
|
{path}
|
|
326
326
|
|
|
327
|
-
It only opens after you confirm.`,settingsExtensions:`Extensions`,settingsUiPlugins:`UI plugins`,pluginListTab:`Plugin list`,noUiPlugins:`No UI plugins installed (<dataDir>/plugins/)`,pluginPhaseActive:`Active`,pluginPhaseDisabled:`Disabled`,pluginPhaseFailed:`Failed`,pluginPhaseIdle:`Frontend-only`,pluginRescan:`Rescan`,pluginRescanHint:`Re-scan the plugin directory (picks up new/fixed plugins; failure records are cleared and re-evaluated)`,dshPatches:`DSH user patches`,dshPatchesDesc:`Cordis patches loaded at runtime boot, in filename order (<dataDir>/dsh-patches/*.yml). New/edited files take effect after 'Rescan' restarts the runtime; broken files are skipped and logged to runtime stderr.`,dshPatchesRescan:`Rescan`,dshPatchesRescanHint:`Re-scan the patch directory and restart the DSH runtime so new patches take effect`,dshPatchesEmpty:`No patch files yet`,dshPatchesPath:`Patch directory: `,dshPreset:`Agent preset`,dshPresetNewChat:`New chat with this preset`,dshPresetLocked:`Locked`,dshPresetBlankOnly:`Locked after the first message; blank sessions can switch`,dshPresetBroken:` (unavailable)`,dshPresetUser:`custom`,dshPresetDefaultTag:`default`,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 your current settings, then enter a name above to 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)`,planUpdateEnabledDesc:`Structured task plan updates (Plan Mode / Step State Machine): allows the model to break complex tasks into steps and track progress in real time.`,planUpdateOffHint:`Disabled: AI can no longer update the structured plan board`,compactContextEnabledDesc:`Proactively compact context based on the current issue: allows AI to independently specify compression focus, retain core task context, drop irrelevant history, and control retention scope.`,compactContextOffHint:`Disabled: AI cannot proactively invoke context compaction (you can still use /compact or trigger auto-compaction)`,evalEnabledDesc:`Execute Python or JavaScript/TypeScript code in an isolated sandbox with persistent variables; ideal for calculations, data analysis, and algorithm verification (default-off to prevent tool crowding-out).`,evalOffHint:`Disabled: the AI cannot use the persistent code sandbox (can still run scripts via bash)`,patchToolEnabledDesc:`High-reliability structural patch tool (Hashline): line-anchored editing with 4-hex content hashes, syntactic AST block matching, and clipboard registers. Automatically attempts 3-way merge conflict recovery if files diverged.`,patchToolOffHint:`Disabled: AI falls back to basic string replacement via edit`,lspToolEnabledDesc:`Native Language Server Protocol (LSP) tool: IDE-grade semantic code intelligence (definition, references, hover, diagnostics, documentSymbol outline, read_symbol precise slicing, workspaceSymbol search, and cascade impact diagnostics). Multi-agent shared process pool with idle sleep, zero external dependencies.`,lspToolOffHint:`Disabled: AI cannot query LSP semantics and falls back to text search`,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.`},tn=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],nn={};function rn(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(nn[e.code]=e,!0)}function an(e){delete nn[e]}function on(e){return e===`zh`?`中文`:e.toUpperCase()}function sn(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function cn(e){let t=await fetch(Yt(Gt(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var ln=(0,m.createContext)(null);function un(){try{return localStorage.getItem(Qt)}catch{return null}}function dn(){return Zt(un(),typeof navigator<`u`?navigator.languages:[],null)}function fn({children:e}){let[t,n]=(0,m.useState)(dn),[r,i]=(0,m.useState)(0),a=(0,m.useRef)(t);a.current=t;let o=(0,m.useCallback)(e=>{n(e);try{localStorage.setItem(Qt,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,m.useCallback)(async()=>{let e,t=null;try{let n=await cn(`/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 cn(`/api/locales/${e.code}`);return rn({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,m.useEffect)(()=>{s().then(e=>{if(!un()?.trim()){let t=Zt(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!nn[t]){let t=Zt(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(Qt,t)}catch{}}})},[s]);let c=(0,m.useMemo)(()=>[...tn,...Object.values(nn).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,m.useCallback)((e,n)=>{let r=nn[t]?.strings[e]??(t===`zh`?$t[e]:en[e]);if(n)for(let[e,t]of Object.entries(n))r=r.replaceAll(`{${e}}`,String(t));return r},[t,r]);(0,m.useEffect)(()=>{document.documentElement.lang=sn(t)},[t]);let u=(0,m.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(ln.Provider,{value:u,children:e})}function pn(){let e=(0,m.useContext)(ln);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return pn().t}var mn=[{kind:`question`,labelKey:`sound.question`,descKey:`sound.question.desc`},{kind:`done`,labelKey:`sound.done`,descKey:`sound.done.desc`},{kind:`start`,labelKey:`sound.start`,descKey:`sound.start.desc`},{kind:`error`,labelKey:`sound.error`,descKey:`sound.error.desc`},{kind:`approval`,labelKey:`sound.approval`,descKey:`sound.approval.desc`}];function hn({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)(P,{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})})]}),mn.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 gn(){let[e,t]=(0,m.useState)([]);return(0,m.useEffect)(()=>{if(!Dt())return;let e=window.speechSynthesis,n=()=>t(e.getVoices().map(e=>({voiceURI:e.voiceURI,lang:e.lang,name:e.name,localService:e.localService})));return n(),e.addEventListener?.(`voiceschanged`,n),()=>e.removeEventListener?.(`voiceschanged`,n)},[]),e}function _n({settings:e,onChange:t,onPreview:n}){let r=Z(),i=gn(),a=Dt(),o=n=>t({...e,...n});return(0,X.jsxs)(`div`,{className:`sound-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:r(`ttsHeader`)}),!a&&(0,X.jsx)(`div`,{className:`sound-desc tts-unavailable`,children:r(`ttsUnavailable`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master ${a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(P,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:r(`ttsEnable`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsEnableDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:!a,onChange:e=>o({enabled:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsAnnounce`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsAnnounceDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.announce,disabled:!e.enabled||!a,onChange:e=>o({announce:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsReadReplies`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsReadRepliesDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.readReplies,disabled:!e.enabled||!a,onChange:e=>o({readReplies:e.target.checked})})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsRate`)}),(0,X.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:e.rate,disabled:!e.enabled||!a,onChange:e=>o({rate:Number(e.target.value)})}),(0,X.jsxs)(`span`,{className:`sound-vol-num`,children:[e.rate.toFixed(1),`×`]})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsVoice`)}),(0,X.jsxs)(`select`,{className:`set-input tts-voice-select`,value:e.voiceURI,disabled:!e.enabled||!a,onChange:e=>o({voiceURI:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`ttsVoiceAuto`)}),i.map(e=>(0,X.jsxs)(`option`,{value:e.voiceURI,children:[e.name,` (`,e.lang,`)`,e.localService?``:` · ${r(`ttsVoiceOnline`)}`]},e.voiceURI))]})]}),(0,X.jsx)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:(0,X.jsx)(`button`,{type:`button`,className:`sound-preview tts-preview`,disabled:!e.enabled||!a,onClick:()=>{if(e.voiceURI&&!Ot(e.voiceURI,i,navigator.language)){t({...wt,...e,voiceURI:``});return}n()},children:r(`preview`)})})]})}function vn(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 yn=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),bn=null,xn=0;function Sn(){return bn?.available===!0?bn.pages??[]:[]}function Cn(){Date.now()-xn<5e3||wn().catch(()=>{})}async function wn(){if(vn())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=yn();if(!e)return{available:!1,pages:[],error:`宿主页面桥不可用:这个 pi-web-ui 页面还没装上扩展桥(装/启用 page-picker 后刷新本页)`};try{let t=await e({op:`status`,timeoutMs:5e3});if(!t.ok)return{available:!1,pages:[],error:t.error??`扩展没有返回状态`};let n=t.result??{},r={available:n.installed===!0,aiControl:n.aiControl===!0,allowEval:n.allowEval===!0,pages:Array.isArray(n.pages)?n.pages:[]};return r.available&&(bn=r,xn=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function Tn(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 Dn(){let e=yn();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function On(e=45e3){let[t,n]=(0,m.useState)(null),r=(0,m.useRef)(!0),i=(0,m.useCallback)(async e=>{let t=await wn();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,m.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 kn=null,An=null,jn=null,Mn=null,Nn=null;function Pn(e){Mn=e}function Fn(e){Nn=e}function In(e){return Mn?(Mn(e),!0):!1}function Ln(e){return Nn?(Nn(e),!0):!1}function Rn(e){kn=e}function zn(e){An=e}function Bn(e){jn=e}function Vn(){return jn?(jn(),!0):!1}function Hn(){return!!(kn||An)}function Un(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&&!kn||i&&!An?!1:(i&&An?.(n),r&&kn?.(t),!0)}function Wn(){let e=Z(),{status:t,refresh:n}=On(),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(null),s=(0,m.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=Tn(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},f=t=>{let n=Un({attachments:[En(t)]});d(e(n?`browserControlCited`:`browserControlCiteFailed`))},p=()=>{i(!0),n()};return(0,X.jsxs)(`span`,{className:`bc-anchor`,children:[u?(0,X.jsxs)(`span`,{className:`browser-control-split`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control single${l?` attention`:``}`,"data-tip":e(`browserControlSingleTip`,{name:u.title||u.origin}),title:e(`browserControlSingleTip`,{name:u.title||u.origin}),onClick:()=>f(u),children:[(0,X.jsx)(pe,{size:14,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`bc-chip-label`,children:u.title||u.origin})]}),(0,X.jsx)(`button`,{type:`button`,className:`chip browser-control caret`,"data-tip":e(`browserControlOpenPanel`),title:e(`browserControlOpenPanel`),"aria-label":e(`browserControlOpenPanel`),onClick:p,children:`▾`})]}):(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control${l?` attention`:``}`,"data-tip":t?.error??e(l?`browserControlEmpty`:`browserControlTip`),title:t?.error??e(l?`browserControlEmpty`:`browserControlTip`),onClick:p,children:[(0,X.jsx)(pe,{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)(Gn,{status:t,onRefresh:n,onCite:f,onClose:()=>i(!1)})]})}function Gn({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,m.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await Dn()||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)(pe,{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 Kn=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],qn=[`subagent_spawn`,`subagent_get_result`,`subagent_steer`,`subagent_list`,`subagent_stop`,`subagent_wait_all`,`subagent_templates`,`subagent_handoff`],Jn=`edit_soft`,Yn=`delegate_task`,Xn=`ask_user_question`,Zn=`todo_list`,Qn=`browser_page`,$n=`conversation_read`,er=`skill`,Q=`schedule_task`,tr=`schedule_list`,nr=`schedule_cancel`,rr=`eval`,ir=`present_files`,ar=`claim_files`,or=`plan_update`,sr=`compact_context`,cr=`patch`,lr=[...Kn.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...qn.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:Jn,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:Yn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:Xn,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:Qn,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:$n,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:ar,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:or,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`planUpdateEnabledDesc`,offHintKey:`planUpdateOffHint`},{name:cr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`patchToolEnabledDesc`,offHintKey:`patchToolOffHint`},{name:`lsp`,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`lspToolEnabledDesc`,offHintKey:`lspToolOffHint`},{name:ir,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:er,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:rr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`evalEnabledDesc`,offHintKey:`evalOffHint`},{name:Q,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:tr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:nr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:sr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`compactContextEnabledDesc`,offHintKey:`compactContextOffHint`},{name:Zn,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}],ur=[`bash`,`read`,`edit`,`write`];new Set(lr.map(e=>e.name));function dr(e,t){let n=Array.from(e);if(!t||t===`standard`)return n;if(t===`ask`)return[];if(t===`minimal`)return n.filter(e=>e===`bash`||e===`read`);if(t===`code`){let e=new Set([`bash`,`read`,`edit`,`write`,`edit_soft`]);return n.filter(t=>e.has(t))}if(t===`reader`){let e=new Set([`write`,`edit`,`edit_soft`,`bash`,`terminal_create`,`terminal_input`,`terminal_close`,`terminal_key`]);return n.filter(t=>!e.has(t))}return n}function fr(e){return dr([er],e).includes(er)}var pr=`pi-web-notify`,mr={enabled:!1};function hr(){try{let e=localStorage.getItem(pr);if(!e)return{...mr};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:mr.enabled}}catch{return{...mr}}}function gr(e){try{localStorage.setItem(pr,JSON.stringify(e))}catch{}}function _r(){return typeof window<`u`&&`Notification`in window}function vr(){return _r()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function yr(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&br(t)||Number.isFinite(n)&&br(n)?!0:r>0&&r<=400&&i>0&&i<=40}function br(e){return e<=-1e4}function xr(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var Sr=Date.now(),Cr=!1;function wr(){Sr=Date.now()}function Tr(){return Math.max(0,Date.now()-Sr)}function Er(){if(Cr||typeof window>`u`)return;Cr=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,wr,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,wr,e)}function Dr(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function Or(){return Er(),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:yr({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Tr(),windows:Dr()}}function kr(){return _r()?Notification.permission:`denied`}async function Ar(){if(!_r())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function jr(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function Mr(e,t=!1){return{body:e,requireInteraction:t,icon:Gt(`/icons/icon-192.png`),badge:Gt(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:Gt(`/`)}}}async function Nr(e,t,n=!1){if(!_r())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=Mr(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=jr(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${jr(e)}`}}}async function Pr(e,t){_r()&&(xr(Or())||hr().enabled&&await Nr(e,t))}var Fr=!1;function Ir(){let e=Z(),[t,n]=(0,m.useState)(hr),[r,i]=(0,m.useState)(()=>kr()),[a,o]=(0,m.useState)(null),s=vr(),c=s!==null,l=Dr();(0,m.useEffect)(()=>{let e=()=>i(kr());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),gr(r),e){let e=await Ar();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),gr(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)(et,{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`)}),Fr]})}var Lr=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),Rr=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(`.`)),zr=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),Br=new Set([...Lr].map(e=>e.toLowerCase())),Vr=new Set([...Rr].map(e=>e.toLowerCase()));function Hr(e){return Br.has(e.toLowerCase())}function Ur(e){return Vr.has(e.toLowerCase())}function Wr(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(!Hr(e)){zr.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of[...t.attributes]){let n=e.name.toLowerCase();(!Ur(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();(!Ur(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function Gr({icon:e,iconSvg:t,className:n}){let r=Wr(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 Kr=new Set([`view`,`action`,`badge`,`menu`,`page`,`organizer`,`divider`,`toggle`,`input`,`progress`,`select`]),qr=new Set([`disabled`,`always`,`never`,`file.isDir`,`file.isFile`,`session.isRunning`,`message.hasSelection`]),Jr=[`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`],Yr=Jr.map(e=>({slot:e,cardinality:`list`}));function Xr(e){return Yr.find(t=>t.slot===e)?.cardinality??`list`}function Zr(e,t){if(t===`list`)return{entries:[...e],conflicts:[]};let n=e.findIndex(e=>!e.hidden);if(n<0)return{entries:[...e],conflicts:[]};let r=e.filter((e,t)=>t!==n&&!e.hidden);return{entries:e.map((e,t)=>t===n||e.hidden?e:{...e,hidden:!0}),winner:e[n],conflicts:r}}var Qr=[{id:`host:brand`,slot:`topbar.primary`,labelKey:`brand`,kind:`badge`,order:1,group:`brand`},{id:`host:open-project`,slot:`topbar.primary`,labelKey:`openProject`,icon:`folder`,kind:`action`,order:3,group:`primary`},{id:`host:history`,slot:`topbar.primary`,labelKey:`openHistory`,icon:`menu`,kind:`action`,order:0,group:`panels`},{id:`host:files`,slot:`topbar.primary`,labelKey:`openFiles`,icon:`folder`,kind:`action`,order:97,group:`panels`,align:`end`},{id:`host:new-chat`,slot:`topbar.primary`,labelKey:`newChat`,icon:`plus`,kind:`action`,order:96,group:`primary`,align:`end`},{id:`host:new-ephemeral-chat`,slot:`topbar.primary`,labelKey:`newChatEphemeral`,icon:`chat`,kind:`action`,order:96.5,group:`primary`,align:`end`},{id:`host:chat`,slot:`topbar.primary`,labelKey:`chat`,icon:`chat`,kind:`view`,view:`chat`,order:20,group:`views`,align:`end`},{id:`host:terminal`,slot:`topbar.primary`,labelKey:`terminal`,icon:`terminal`,kind:`view`,view:`terminal`,order:21,group:`views`,align:`end`},{id:`host:git`,slot:`topbar.primary`,labelKey:`scmTab`,icon:`git`,kind:`view`,view:`git`,order:22,group:`views`,align:`end`},{id:`host:plugins`,slot:`topbar.primary`,labelKey:`pluginMenuTitle`,icon:`🧩`,kind:`action`,order:24,group:`views`,align:`end`},{id:`host:search`,slot:`topbar.primary`,labelKey:`searchGlobal`,icon:`search`,kind:`action`,order:40,group:`tools`,align:`end`},{id:`host:browser`,slot:`topbar.primary`,labelKey:`browserControl`,icon:`browser`,kind:`action`,order:41,group:`tools`,align:`end`,hidden:!0},{id:`host:tasks`,slot:`topbar.primary`,labelKey:`bgTasks`,icon:`layers`,kind:`action`,order:42,group:`tools`,align:`end`},{id:`host:settings`,slot:`topbar.primary`,labelKey:`settingsTitle`,icon:`settings`,kind:`action`,order:60,group:`system`,align:`end`},{id:`host:sound`,slot:`topbar.primary`,labelKey:`sound`,icon:`sound`,kind:`action`,order:70,group:`system`,hidden:!0,align:`end`},{id:`host:language`,slot:`topbar.primary`,labelKey:`language`,icon:`globe`,kind:`action`,order:80,group:`system`,hidden:!0,align:`end`},{id:`host:theme`,slot:`topbar.primary`,labelKey:`theme`,icon:`sun`,kind:`action`,order:82,group:`system`,hidden:!0,align:`end`},{id:`host:update`,slot:`topbar.primary`,labelKey:`update`,icon:`download`,kind:`action`,order:90,group:`system`,align:`end`,hidden:!0},{id:`host:github`,slot:`topbar.primary`,labelKey:`githubRepo`,icon:`github`,kind:`action`,order:200,group:`system`,align:`end`,hidden:!0},{id:`host:conn`,slot:`bottombar`,labelKey:`connected`,icon:`dot`,kind:`badge`,order:5,group:`status`},{id:`host:engine`,slot:`bottombar`,labelKey:`engineBadge`,icon:`cpu`,kind:`badge`,order:6,group:`status`},{id:`host:ctx`,slot:`bottombar`,labelKey:`context`,icon:`gauge`,kind:`badge`,order:10,group:`usage`},{id:`host:cost`,slot:`bottombar`,labelKey:`cumulativeCost`,icon:`coins`,kind:`badge`,order:11,group:`usage`},{id:`host:cache`,slot:`bottombar`,labelKey:`cacheHit`,icon:`database`,kind:`badge`,order:12,group:`usage`},{id:`host:msg-count`,slot:`bottombar`,labelKey:`messages`,icon:`message`,kind:`badge`,order:13,group:`usage`},{id:`host:plugin-status`,slot:`bottombar`,labelKey:`pluginStatus`,icon:`activity`,kind:`badge`,order:14,group:`status`},{id:`host:working`,slot:`bottombar`,labelKey:`working`,icon:`activity`,kind:`badge`,order:15,group:`status`},{id:`host:host-metrics`,slot:`bottombar`,labelKey:`hostResources`,icon:`cpu`,kind:`badge`,order:19,group:`host`,align:`end`},{id:`host:cwd`,slot:`bottombar`,labelKey:`cwdTip`,icon:`folder`,kind:`action`,order:20,group:`context`,align:`end`},{id:`host:msg-reask`,slot:`message.actions`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,order:9},{id:`host:msg-edit-reask`,slot:`message.actions`,labelKey:`editReask`,icon:`edit`,kind:`action`,order:10},{id:`host:msg-fork`,slot:`message.actions`,labelKey:`forkSession`,icon:`branch`,kind:`action`,order:15},{id:`host:msg-rollback`,slot:`message.actions`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,order:16},{id:`host:msg-copy`,slot:`message.actions`,labelKey:`copyMessage`,icon:`copy`,kind:`action`,order:20},{id:`host:msg-copy-text`,slot:`message.actions`,labelKey:`copyText`,icon:`text`,kind:`action`,order:21},{id:`host:msg-copy-markdown`,slot:`message.actions`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,order:22},{id:`host:msg-copy-image`,slot:`message.actions`,labelKey:`copyImage`,icon:`image`,kind:`action`,order:23},{id:`host:msg-speak`,slot:`message.actions`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,order:24},{id:`host:composer-upload`,slot:`composer.actions`,labelKey:`uploadFile`,icon:`upload`,kind:`action`,order:10,align:`start`},{id:`host:composer-templates`,slot:`composer.actions`,labelKey:`tpl.openPicker`,icon:`grid`,kind:`action`,order:110,align:`start`},{id:`host:composer-model`,slot:`composer.actions`,labelKey:`selectModel`,icon:`cpu`,kind:`action`,order:120,align:`start`},{id:`host:composer-thinking`,slot:`composer.actions`,labelKey:`thinkingLevel`,icon:`zap`,kind:`action`,order:130,align:`start`},{id:`host:composer-dsh-perm`,slot:`composer.actions`,labelKey:`dshPerm`,icon:`lock`,kind:`action`,order:140,align:`start`},{id:`host:composer-dsh-preset`,slot:`composer.actions`,labelKey:`dshPreset`,icon:`layers`,kind:`action`,order:150,align:`start`},{id:`host:composer-send`,slot:`composer.actions`,labelKey:`sendTip`,icon:`send`,kind:`action`,order:200,align:`end`},{id:`host:fp-md`,slot:`file.preview.toolbar`,labelKey:`showMarkdownPreview`,icon:`eye`,kind:`action`,order:10},{id:`host:fp-html`,slot:`file.preview.toolbar`,labelKey:`showHtmlPreview`,icon:`code`,kind:`action`,order:20},{id:`host:fp-edit`,slot:`file.preview.toolbar`,labelKey:`editFile`,icon:`edit`,kind:`action`,order:30},{id:`host:fp-wrap`,slot:`file.preview.toolbar`,labelKey:`enableWrap`,icon:`wrap`,kind:`action`,order:40},{id:`host:fp-zoom`,slot:`file.preview.toolbar`,labelKey:`zoomIn`,icon:`zoom`,kind:`action`,order:50},{id:`host:fp-ref`,slot:`file.preview.toolbar`,labelKey:`referenceTip`,icon:`link`,kind:`action`,order:70},{id:`host:fp-full`,slot:`file.preview.toolbar`,labelKey:`fullscreen`,icon:`maximize`,kind:`action`,order:80},{id:`host:fp-close`,slot:`file.preview.toolbar`,labelKey:`close`,icon:`x`,kind:`action`,order:90},{id:`host:goal-pill`,slot:`goalbar.actions`,labelKey:`goalBarTitle`,icon:`target`,kind:`action`,order:5},{id:`host:goal-set`,slot:`goalbar.actions`,labelKey:`goalBarSet`,icon:`check`,kind:`action`,order:10},{id:`host:goal-wizard`,slot:`goalbar.actions`,labelKey:`goalWizardBtn`,icon:`search`,kind:`action`,order:20},{id:`host:goal-lock`,slot:`goalbar.actions`,labelKey:`goalBarLocked`,icon:`lock`,kind:`action`,order:30},{id:`host:goal-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-ref`,slot:`contextmenu.file`,labelKey:`referenceTip`,icon:`link`,kind:`action`,context:`file`,order:32,group:`chat`},{id:`host:file-attach-folder`,slot:`contextmenu.file`,labelKey:`linkFolderTip`,icon:`link`,kind:`action`,context:`file`,order:33,group:`chat`},{id:`host:file-rename`,slot:`contextmenu.file`,labelKey:`fileRename`,icon:`edit`,kind:`action`,context:`file`,order:41,group:`edit`},{id:`host:file-duplicate`,slot:`contextmenu.file`,labelKey:`fileDuplicate`,icon:`copy`,kind:`action`,context:`file`,order:42,group:`edit`},{id:`host:file-cut`,slot:`contextmenu.file`,labelKey:`fileCut`,icon:`cut`,kind:`action`,context:`file`,order:43,group:`edit`},{id:`host:file-copy`,slot:`contextmenu.file`,labelKey:`fileCopyEntry`,icon:`copy`,kind:`action`,context:`file`,order:44,group:`edit`},{id:`host:file-copy-name`,slot:`contextmenu.file`,labelKey:`copyName`,icon:`copy`,kind:`action`,context:`file`,order:51,group:`clipboard`},{id:`host:file-copy-path`,slot:`contextmenu.file`,labelKey:`copyPath`,icon:`copy`,kind:`action`,context:`file`,order:52,group:`clipboard`},{id:`host:file-copy-rel`,slot:`contextmenu.file`,labelKey:`fileCopyRelPath`,icon:`copy`,kind:`action`,context:`file`,order:53,group:`clipboard`},{id:`host:file-refresh`,slot:`contextmenu.file`,labelKey:`fileRefresh`,icon:`refresh`,kind:`action`,context:`file`,order:54,group:`clipboard`},{id:`host:file-delete`,slot:`contextmenu.file`,labelKey:`fileDelete`,icon:`trash`,kind:`action`,context:`file`,order:61,group:`danger`},{id:`host:msg-ctx-copy-markdown`,slot:`contextmenu.message`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,context:`message`,order:10,group:`copy`},{id:`host:msg-ctx-copy-text`,slot:`contextmenu.message`,labelKey:`copyText`,icon:`text`,kind:`action`,context:`message`,order:11,group:`copy`},{id:`host:msg-ctx-copy-image`,slot:`contextmenu.message`,labelKey:`copyImage`,icon:`image`,kind:`action`,context:`message`,order:12,group:`copy`},{id:`host:msg-ctx-reask`,slot:`contextmenu.message`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,context:`message`,order:19,group:`action`},{id:`host:msg-ctx-edit-reask`,slot:`contextmenu.message`,labelKey:`editReask`,icon:`edit`,kind:`action`,context:`message`,order:20,group:`action`},{id:`host:msg-ctx-fork`,slot:`contextmenu.message`,labelKey:`forkSession`,icon:`branch`,kind:`action`,context:`message`,order:21,group:`action`},{id:`host:msg-ctx-rollback`,slot:`contextmenu.message`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,context:`message`,order:22,group:`action`},{id:`host:msg-ctx-speak`,slot:`contextmenu.message`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,context:`message`,order:23,group:`action`},{id:`host:tool-info`,slot:`contextmenu.toolcall`,labelKey:`toolInfoMenuLabel`,icon:`info`,kind:`action`,context:`toolcall`,order:10}],$r=new Set([`host:lp-projects`,`host:lp-running`,`host:lp-history`]),ei=`__view`,ti=new Set([`host:settings`,`host:history`,`host:files`]),ni=new Set([`host:history`,`host:files`]);function ri(e){return`${e}:${ei}`}function ii(e){return e.source.startsWith(`plugin:`)?e.id===ri(e.source.slice(7)):!1}function ai(e,t,n){let r=ri(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 oi(e,t){let n=t.map(ri),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var si=`host:brand`,ci=[`host:brand-logo`,`host:brand-name`];function li(e){if(!((e.hidden??[]).some(e=>ci.includes(e))||(e.shown??[]).some(e=>ci.includes(e))||(e.order??[]).some(e=>ci.includes(e))||ci.some(t=>e.align?.[t]!==void 0)||ci.some(t=>e.groups?.[t]!==void 0)||ci.some(t=>e.labels?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=ci.includes(n)?si: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))ci.includes(t)||(n[t]=r);if(n[`host:brand`]===void 0){let r=t?e[ci[0]]??e[ci[1]]:e[ci[1]]??e[ci[0]];r!==void 0&&(n[si]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))ci.includes(n)||(t[n]=r);if(t[`host:brand`]===void 0){let n=e[ci[0]]??e[ci[1]];n!==void 0&&(t[si]=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 ui(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:ei,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 di(e){return typeof e==`string`&&Jr.includes(e)}function fi(e,t){return t?e.label:e.labelEn??e.label}function pi(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function mi(e,t,n,r,i){let a=`${e}#${r.id}`,o=hi(a,t,n,r.children,i),s=pi(r,i),c=gi(r.options,i);return{id:a,slot:t,source:n,label:fi(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 hi(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:mi(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 gi(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 _i(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function vi(e,t,n,r,i,a){let o=hi(e,t,n,r.children,i),s=pi(r,i),c=_i(r.progress),l=gi(r.options,i);return{id:e,slot:t,source:n,label:fi(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 yi(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 bi(e){let t=e.filter(e=>ii(e));if(t.length===0)return e;let n=e.filter(e=>!ii(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 xi(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=li(t.layout??{}),a=e=>{t.diagnostics?.push({level:e.level??`warn`,...e})},o=new Map,s=0;for(let e of Qr)o.set(e.id,{id:e.id,slot:e.slot,source:`host`,label:t.t(e.labelKey),labelKey:e.labelKey,...e.icon?{icon:e.icon}:{},kind:e.kind,...e.view?{view:e.view}:{},...e.group?{group:e.group}:{},order:e.order??100,align:e.align??`start`,hidden:e.hidden??!1,userOverrides:[],arrangedBy:[],seq:s++});for(let t of e){if(r.has(t.id)){a({pluginId:t.id,message:`plugin "${t.id}" is disabled by the user — its ${t.ui?.items?.length??0} UI item(s) are not rendered`});continue}if(t.error){a({level:`error`,pluginId:t.id,message:`plugin "${t.id}" failed to activate (${t.error}) — its UI items are not rendered`});continue}let e=`plugin:${t.id}`;for(let r of t.ui?.items??[]){if(!di(r.slot)){a({pluginId:t.id,entryId:r.id,message:`item "${t.id}:${r.id}" declares unknown slot "${String(r.slot)}" — dropped (valid slots: see docs/architecture-plugins.md)`});continue}if(r.kind&&!Kr.has(r.kind)&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares unknown kind "${r.kind}" — the render layer falls back to a plain button`}),Array.isArray(r.when))for(let e of r.when)qr.has(e)||a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares when:"${e}" which the host does not know — it is ignored (the item still renders)`});else r.when!==void 0&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" has a non-array "when" — ignored`});let i=`${t.id}:${r.id}`,c=o.get(i);c&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item id "${r.id}" is declared more than once — the later declaration wins (order/visibility are inherited from the first)`}),o.set(i,vi(i,r.slot,e,r,n,c?.seq??s++))}}for(let t of e)if(!(t.error||r.has(t.id)))for(let e of t.ui?.arrange??[]){let n=o.get(e.id);Ci(o,e,t.id),n||a({pluginId:t.id,entryId:e.id,message:`arrange target "${e.id}" does not exist — op ignored (is the providing plugin installed / not disabled?)`})}let c=new Map,l=(e,t)=>{let n=c.get(e)??[];n.includes(t)||n.push(t),c.set(e,n)};for(let e of i.hidden??[]){let t=o.get(e);t&&(t.hidden=!0,l(e,`hidden`))}for(let e of i.shown??[]){let t=o.get(e);t&&(t.hidden=!1,l(e,`hidden`))}for(let[e,t]of Object.entries(i.groups??{})){let n=o.get(e);n&&(n.group=t,l(e,`group`))}for(let[e,t]of Object.entries(i.align??{})){let n=o.get(e);!n||t!==`start`&&t!==`center`&&t!==`end`||(n.align=t,l(e,`align`))}for(let[e,t]of Object.entries(i.labels??{})){let n=o.get(e);n&&(n.label=t,l(e,`label`))}for(let e of ti){let t=o.get(e);t&&(t.slot=`topbar.primary`,t.hidden=!1)}let u=new Map;(i.order??[]).forEach((e,t)=>{o.has(e)&&(u.has(e)||u.set(e,t),l(e,`order`))});let d=new Map;for(let e of Jr)d.set(e,[]);for(let e of o.values())d.get(e.slot)?.push(e);let f={};for(let e of Jr){let t=yi(d.get(e)??[],u),n=Zr(e===`topbar.primary`?bi(t):t,Xr(e));if(n.winner&&n.conflicts.length>0)for(let t of n.conflicts)a({level:`error`,pluginId:t.source.startsWith(`plugin:`)?t.source.slice(7):void 0,entryId:t.id,slot:e,message:`slot "${e}" is single-cardinality; "${n.winner.id}" won and "${t.id}" was hidden`});f[e]=n.entries.map(e=>Si(e,c.get(e.id)??[]))}return f}function Si(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function Ci(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&&di(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 wi(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 Ti(e,t){let n=e??{},r={},i=t===`host:brand`?[t,...ci]:[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=Di(n.groups,t),l=Di(n.labels,t),u=Di(n.align,t);if(t===`host:brand`)for(let e of ci)c=Di(c,e),l=Di(l,e),u=Di(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 Ei(){return{}}function Di(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 Oi=new Set([`host:files`]);function ki(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 Ai(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 ji=null,Mi=new Set;function Ni(){for(let e of Mi)e()}function Pi(e){ji={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}:{}},Ni()}function Fi(){ji!==null&&(ji=null,Ni())}function Ii(e){return Mi.add(e),()=>{Mi.delete(e)}}function Li(){return ji}function Ri(){return(0,m.useSyncExternalStore)(Ii,Li,Li)}function zi(e){return Number.isFinite(e)?e:0}function Bi(e,t,n,r,i,a){let o=Math.max(0,zi(n)),s=Math.max(0,zi(r)),c=Math.max(8,zi(i)-o-8),l=Math.max(8,zi(a)-s-8);return{x:Math.min(Math.max(8,zi(e)),c),y:Math.min(Math.max(8,zi(t)),l)}}function Vi(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 Hi(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 Ui(e,t){return!e||Hi(e.when,t)}function Wi(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 Gi(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 Ki(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 qi(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!Ui(e,t)}function Ji(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,qi(e[o],r))return o;return-1}var Yi={menu:`☰`,folder:`📁`,plus:`+`,chat:`💬`,terminal:`▙`,git:`⎇`,search:`🔍`,browser:`🌐`,layers:`🗂`,settings:`⚙`,sound:`🔊`,globe:`🌍`,sun:`☀`,download:`⤓`,github:`⌗`,x:`✕`,upload:`⬆`,copy:`⧉`,cut:`✂`,paste:`📋`,trash:`🗑`,file:`📄`,open:`↗`,refresh:`⟳`,link:`🔗`,edit:`✎`,dot:`●`,info:`ⓘ`,cpu:`▣`,gauge:`▤`,coins:`◉`,database:`▥`,message:`✉`,activity:`〜`,markdown:`📄`,text:`≡`,image:`🖼`,branch:`⚚`,undo:`↺`,volume:`🔊`};function Xi(e){let t=(e??``).trim();return t?Yi[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var Zi={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},Qi=new Set;function $i(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function ea(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&&$i(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&$i(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function ta(e){let t={...Zi,...e};if(!ea(Zi,t)){Zi=t;for(let e of Qi)e()}}function na(e){return Qi.add(e),()=>{Qi.delete(e)}}function ra(){return Zi}function ia(){return(0,m.useSyncExternalStore)(na,ra,ra)}function aa(e){return(0,m.useSyncExternalStore)(na,()=>Zi[e],()=>Zi[e])}function oa(){return aa(`engine`)===`dsh`}function sa(){return aa(`managed`)}function ca(){return aa(`service`)}var la=null;function ua(e){la=e}var $=e=>la?la(e):!1,da=`@root`,fa=e=>e.endsWith(`/`)?e:e+`/`;function pa(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function ma(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var ha=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)?da:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function ga({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z(),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(``),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(-1),x=(0,m.useRef)(null),S=(0,m.useRef)(null),C=n.filter(e=>e.type===`dir`);if((0,m.useEffect)(()=>{if(e){let e=(t||``).replace(/\\/g,`/`);l(e),d(e),p(!1),g(``),v(null),b(-1)}},[e,t]),(0,m.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{x.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,m.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(f?(p(!1),g(``),v(null)):i())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,f,i]),(0,m.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{$({type:`complete_path`,path:fa(c)})},60);return()=>clearTimeout(t)},[c,e]),(0,m.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(!ma(e)){v(s(`invalidProjectName`));return}o(pa(c,e)),p(!1),g(``),v(null),i()},E=e=>{if(e.key===`Escape`)e.stopPropagation(),f?(p(!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=ha(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)(ke,{}),(0,X.jsx)(`span`,{children:c===`@root`?s(`computer`):c})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:c===da,title:s(`computer`),onClick:()=>{l(da),d(da),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.jsx)(`button`,{type:`button`,className:`cwd-close`,title:s(`close`),"aria-label":s(`close`),onClick:i,children:(0,X.jsx)(N,{})})]}),(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===da,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)(ke,{}),(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:[f?(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(),p(!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:()=>{p(!1),g(``),v(null)},children:s(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>p(!0),children:[`+ `,s(`newProject`)]}),_&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:_})]})]})]})}function _a(e){return D({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 va(e){return D({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 ya(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 ba(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,m.useRef)(null),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(i);(0,m.useLayoutEffect)(()=>{p.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=ya(i,{width:n.width,height:n.height},{width:window.innerWidth,height:window.innerHeight},{align:o,side:s,gap:c,margin:l});f(e=>e?.x===a.x&&e?.y===a.y?e:a)};return(0,m.useLayoutEffect)(()=>{t?_():f(null)},[t,n,r,o,s,c,l]),yt(()=>{p.current()},t),(0,m.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||g()?.contains(e)||a?.(e)),n=t=>{e(t.target)||p.current()};return document.addEventListener(`mousedown`,n,!0),window.addEventListener(`resize`,_,!0),window.addEventListener(`scroll`,_,!0),()=>{document.removeEventListener(`mousedown`,n,!0),window.removeEventListener(`resize`,_,!0),window.removeEventListener(`scroll`,_,!0)}},[t,n,r]),{panelRef:u,pos:d,style:{position:`fixed`,left:d?.x??-9999,top:d?.y??-9999,visibility:d?`visible`:`hidden`},measure:_}}function xa({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=pn(),{panelRef:d,style:f,measure:p}=ba({anchor:e,anchorEl:t,onClose:l}),[,h]=(0,m.useState)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null),y=(0,m.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,m.useLayoutEffect)(()=>{p()},[y,p]);let b=(e,t)=>{let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=r+t;if(r<0||i<0||i>=n.length)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))},x=(e,t)=>{if(!e||e===t)return;let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=n.indexOf(t);if(r<0||i<0)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))};return(0,k.createPortal)((0,X.jsxs)(`div`,{ref:d,className:`pm-panel`,role:`menu`,"aria-label":u(`pluginMenuTitle`),style:f,children:[(0,X.jsxs)(`div`,{className:`pm-head`,"aria-hidden":`true`,children:[(0,X.jsx)(Qe,{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)(_e,{"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)(Gr,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(Qe,{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)(va,{"aria-hidden":!0}):(0,X.jsx)(_a,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(U,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function Sa({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=pn(),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(``);async function d(){try{let e=await fetch(Yt(Gt(`/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,m.useEffect)(()=>{d()},[]);async function f(e){u(e),c(``);try{let t=await fetch(Yt(Gt(`/api/locales/${e}/install`)),{method:`POST`});if(!t.ok){let e=`HTTP ${t.status}`;try{e=(await t.json()).error??e}catch{}throw Error(e)}await i(),await d()}catch(e){c(t(`localeInstallFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(``)}}async function p(e){u(e),c(``);try{let t=await fetch(Yt(Gt(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);an(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)(Ee,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(N,{})})]}),s&&(0,X.jsx)(`div`,{className:`bg-task-empty`,children:s}),a===null&&!s?(0,X.jsx)(`div`,{className:`bg-task-empty`,children:t(`loading`)}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:(a??[]).map(e=>{let n=l===e.code;return(0,X.jsxs)(`li`,{className:`bg-task-item`,children:[(0,X.jsxs)(`div`,{className:`bg-task-info`,children:[(0,X.jsxs)(`div`,{className:`bg-task-line1`,children:[(0,X.jsx)(`span`,{className:`bg-task-port`,children:e.nativeName}),e.installed&&e.version&&(0,X.jsxs)(`span`,{className:`bg-task-name`,children:[`v`,e.version]})]}),(0,X.jsxs)(`div`,{className:`bg-task-line2`,children:[(0,X.jsx)(`span`,{children:e.code}),e.installed?(0,X.jsxs)(`span`,{children:[t(`localeInstalled`),` · `,t(`localeRemoveHint`)]}):(0,X.jsx)(`span`,{children:t(`localeGetMore`)})]})]}),e.installed?(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,disabled:n,title:t(`localeRemove`),onClick:()=>void p(e.code),children:[(0,X.jsx)(R,{}),(0,X.jsx)(`span`,{children:t(n?`localeRemoving`:`localeRemove`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:n,title:t(`localeInstall`),onClick:()=>void f(e.code),children:[(0,X.jsx)(Ie,{}),(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)(se,{}),(0,X.jsx)(`span`,{children:t(`bgTaskRefresh`)})]})})]})})}var Ca=`xing-shuyin/pi-web-ui`,wa={state:`idle`,version:null,percent:0,message:null};function Ta(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Ea(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:Ta(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 Da(e){if(!vn(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 Oa(e){return e instanceof Error?e.message:String(e)}function ka(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${Ca}/releases/tag/v${t}`:`https://github.com/${Ca}/releases/latest`}function Aa(){let[e]=(0,m.useState)(()=>Da()),[t,n]=(0,m.useState)(wa);(0,m.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>Ea(t,e)))},[e]);let r=(0,m.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:Oa(e)}))))},[e]),i=(0,m.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:Oa(e)}))))},[e]),a=(0,m.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:Oa(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}var ja={name:`@earendil-works/pi-coding-agent`,kind:`pi-core`,current:``,latest:null,upToDate:!1};function Ma({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=ba({open:t,anchor:e,onClose:n});return(0,m.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,k.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Na(){let[e,t]=(0,m.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,m.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 Pa({chat:e,terminal:t,view:n,plugins:r,uiPrimary:i,uiOverflow:a,uiContextTopbar:o,onUiAction:s,onViewChange:c,onOpenPanel:l,onOpenSettings:u,onManagePlugins:d,onOpenBgTasks:f,onOpenGlobalSearch:p,sound:h,onSoundChange:g,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x}){let{locale:S,setLocale:C,t:w,packs:T}=pn(),[E,D]=(0,m.useState)(!1),[O,k]=(0,m.useState)(!1),[A,ee]=(0,m.useState)(null),j=aa(`cwd`),M=aa(`workspaceRoots`),N=oa(),F=(0,m.useRef)(null),I=t=>!e.tabs||t===`chat`||e.tabs.includes(t),L=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!ii(e)),R=new Set([...i??[],...a??[]].filter(e=>ii(e)&&!e.hidden).map(e=>e.source.slice(7))),te=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),B=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),ne=i===void 0?[`host:history`,`host:brand`,`host:open-project`,`host:chat`,`host:terminal`,`host:git`,`host:plugins`,`host:search`,`host:browser`,`host:tasks`,`host:settings`,`host:sound`,`host:language`,`host:theme`,`host:update`,`host:github`,`host:new-chat`,`host:new-ephemeral-chat`,`host:files`].map(e=>({id:e,entry:null})):i.map(e=>({id:e.id,entry:e})),re=(I(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!ne.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:[]})),H=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`}),Vn(),!0;case`host:new-ephemeral-chat`:return c(`chat`),$({type:`new_chat`,ephemeral:!0}),Vn(),!0;case`host:open-project`:return k(!0),!0;case`host:search`:return p(),!0;case`host:tasks`:return f(),!0;case`host:settings`:return u(),!0;case`host:plugins`:return ee(F.current?{rect:F.current.getBoundingClientRect(),el:F.current}:null),!0;default:return!1}},W=(e,t,n)=>{e.preventDefault(),Pi({x:e.clientX,y:e.clientY,slot:`contextmenu.topbar`,target:{id:t,label:n},entries:o??[]})},{appVersion:ae}=ia(),oe=sa(),se=ca(),[le,ue]=(0,m.useState)(!1);(0,m.useEffect)(()=>{le&&e.status===`open`&&ue(!1)},[le,e.status]);let[de,fe]=(0,m.useState)(!1),[pe,me]=(0,m.useState)(!1),[he,ge]=(0,m.useState)(!1),[ve,K]=(0,m.useState)(!1),q=vn(),ye=Aa(),[J,be]=(0,m.useState)(!1),Se=()=>{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:dt(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r}),K(!1),c(`terminal`)},Ce=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:lt(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:dt(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:r,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:i}),K(!1),c(`terminal`)},we=e.updatesAll??[],Te=e.updatesSdk,Ae=Te&&Te.newerInstalled?{running:Te.running,installed:Te.newerInstalled}:null,je=Te?.bundledInUse===!0,Me=we.find(e=>e.kind===`pi-core`&&!e.error),Ne=je&&(!Me||!Me.upToDate),Pe=Ne&&!Me,Fe=we.filter(e=>!e.upToDate&&!e.error).length,Le=we.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Re=e=>e.kind===`git-extension`&&e.source?e.source:e.name,ze=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,Be=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},Ve=(e,t)=>{if(!t)return Be(e);let n=Be(e),r=Be(t);return n===r?n:`${n} → ${r}`},He=()=>(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=>{let t=Ae!=null&&e.kind===`pi-core`,n=!e.error&&(!e.upToDate||t);return(0,X.jsxs)(`li`,{className:`dd-all-item${e.error?` err`:n?` warn`:``}`,children:[e.kind!==`webui`&&!e.upToDate&&!e.error&&(0,X.jsx)(`button`,{type:`button`,className:`dd-update-btn`,onClick:()=>Ce([e],w(`updatePkgTabTitle`,{name:e.name})),children:w(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:ze(e),children:Re(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`):e.kind===`plugin`?w(`kindPlugin`):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?Be(e.current):Ve(e.current,e.latest):e.kind===`plugin`?e.upToDate?e.current.startsWith(`v`)?e.current:Be(e.current):Ve(e.current,e.latest):e.upToDate?`v${e.current}`:(0,X.jsxs)(X.Fragment,{children:[`v`,e.current,` → v`,e.latest]})}),t&&!e.error&&(0,X.jsx)(`span`,{className:`dd-split-run`,children:w(`piCoreSplitRun`,{running:Ae.running})})]})]},`${e.kind}:${e.name}`)})}),Ae&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`piSdkSplitNote`,{running:Ae.running,installed:Ae.installed})}),Ne&&(0,X.jsx)(`div`,{className:`dd-note`,children:w(`piSdkBundledNote`,{running:Te.running})}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[Pe&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce([ja],w(`installGlobalEngineTabTitle`)),children:w(`installGlobalEngineBtn`)}),Le.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce(Le,w(`updateAllTabTitle`)),children:w(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:Le.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:w(`updatesAllRefresh`)})]})]}),Ue=()=>{let t=ka(e.update?.latest??ye.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:w(`updateDesktopManual`)});if(!ye.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopNoBridge`)}),n]});switch(ye.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:ye.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ye.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:ye.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:()=>ye.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:ye.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>ye.check(),children:w(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ye.check(),children:w(`updateDesktopCheck`)}),n]})}},We=()=>(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&&!q&&(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&q&&(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&&!q&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:Se,children:w(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&q&&Ue(),se&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:le,title:w(`restartServiceTip`,{name:se.name}),onClick:()=>{le||(ue(!0),$({type:`restart_service`}))},children:w(le?`restartingService`:`restartService`)})]})]}),Ge=Na(),Ke={"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)(_e,{})}):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)(ke,{}),(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`}),Vn()},children:[(0,X.jsx)(ce,{}),(0,X.jsx)(`span`,{children:w(`newChat`)})]}):null,"host:new-ephemeral-chat":N?null:(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat ephemeral-chat-btn`,"data-tip":w(`newChatEphemeralTip`),onClick:()=>{c(`chat`),$({type:`new_chat`,ephemeral:!0}),Vn()},children:[(0,X.jsx)(ct,{}),(0,X.jsx)(`span`,{children:w(`newChatEphemeral`)})]}),"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)(G,{}),(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)(z,{}),(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)(Oe,{}),(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;ee(e=>e?.el===t?null:{rect:t.getBoundingClientRect(),el:t})},children:[(0,X.jsx)(Qe,{"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:p,children:[(0,X.jsx)(ie,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(Wn,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":w(`bgTasksTip`),onClick:f,children:[(0,X.jsx)(xe,{}),(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)(U,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`settings`)})]}),"host:sound":(0,X.jsxs)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(P,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`sound`)})]}),tip:w(`sound`),open:de,onOpenChange:fe,children:[(0,X.jsx)(hn,{settings:h,onChange:g,onPreview:_}),(0,X.jsx)(Ir,{})]}),"host:language":(0,X.jsxs)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ee,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:on(S)})]}),tip:w(`language`),open:pe,onOpenChange:me,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`language`)}),T.map(e=>(0,X.jsx)(St,{active:S===e.code,onClick:()=>{C(e.code),me(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(St,{onClick:()=>{me(!1),be(!0)},children:[(0,X.jsx)(Ie,{}),` `,w(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{}),(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)(St,{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)(St,{active:y===null,onClick:()=>{b(null),ge(!1)},children:w(`themeDefault`)}),t.map(e=>(0,X.jsx)(St,{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)(Ie,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,ae??e.update?.current??`…`]})]}):(0,X.jsxs)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ie,{}),(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??``})}),Fe>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:w(`updatesAllBadge`,{n:Fe})})]}),tip:w(`update`),open:ve,onOpenChange:e=>{K(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},fit:!0,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`update`)}),We(),He()]}),"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)(De,{})})},qe=new Set([`host:search`,`host:tasks`,`host:settings`,`host:plugins`]),Je=new Set([`host:sound`,`host:language`,`host:theme`,`host:update`,`host:browser`]),Ye=e=>qe.has(e)&&!I(e.slice(5)),Xe=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=>W(t,e.id,e.label),children:[(0,X.jsx)(Gr,{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=>W(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=>W(t,e.id,e.label),children:[(0,X.jsx)(Gr,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},Ze=[];for(let e of ne){if(e.entry?.hidden||Ye(e.id))continue;let t=e.id.startsWith(`host:`)?Ke[e.id]??null:e.entry?Xe(e.entry):null;t&&Ze.push({id:e.id,entry:e.entry,node:t})}for(let e of re){let t=Xe(e);t&&Ze.push({id:e.id,entry:e,node:t})}let $e=e=>e.entry?.align??`start`,[et,tt]=(0,m.useState)(()=>new Set),nt=(0,m.useRef)(null),rt=(0,m.useRef)(new Map),it=Ze.filter(e=>!et.has(e.id)),at=Ge?it.filter(e=>Oi.has(e.id)):[],ot=Ge?it.filter(e=>!Oi.has(e.id)):it,st=Ge?Ze.filter(e=>!Oi.has(e.id)):Ze,ut=[...st.filter(e=>$e(e)===`start`),...st.filter(e=>$e(e)===`center`),...st.filter(e=>$e(e)===`end`)],ft=ut.filter(e=>!et.has(e.id)),pt=(0,m.useRef)(ut),mt=(0,m.useRef)(ft);(0,m.useLayoutEffect)(()=>{pt.current=ut,mt.current=ft});let ht=()=>{let e=nt.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`)),n=mt.current;t.length===n.length&&n.forEach((e,n)=>rt.current.set(e.id,t[n].offsetWidth));let r=Number.parseFloat(getComputedStyle(e).columnGap)||0,i=pt.current,a=Ai(i.map(e=>({id:e.id,width:e.entry?rt.current.get(e.id)??0:0})),e.clientWidth,r,0,ti);tt(e=>e.size===a.size&&[...a].every(t=>e.has(t))?e:a)},gt=`${it.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${Ge?`m`:`d`}`;(0,m.useLayoutEffect)(ht,[gt]),(0,m.useEffect)(()=>{let e=nt.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>ht());return t.observe(e),()=>t.disconnect()},[gt]);let _t=ot.filter(e=>$e(e)===`start`),vt=ot.filter(e=>$e(e)===`center`),yt=ot.filter(e=>$e(e)===`end`),bt=Ze.filter(e=>et.has(e.id)&&e.entry).map(e=>e.entry),Ct=new Map;[...i??[],...a??[]].forEach((e,t)=>{Ct.has(e.id)||Ct.set(e.id,t)});let wt=ki([...L,...bt],e=>Ct.get(e)??999999),Tt=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${Tt?` no-labels`:``}`,"data-pi-anchor":`topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-flow`,ref:nt,role:`toolbar`,"aria-label":w(`viewSwitch`),children:[_t.map(e=>(0,X.jsx)(m.Fragment,{children:e.node},e.id)),(vt.length>0||yt.length>0)&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),vt.map(e=>(0,X.jsx)(m.Fragment,{children:e.node},e.id)),yt.length>0&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),yt.map(e=>(0,X.jsx)(m.Fragment,{children:e.node},e.id))]}),wt.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)(Ma,{anchorRef:F,open:E,onClose:()=>D(!1),children:wt.map(e=>{let t=e.source===`host`&&Je.has(e.id)?Ke[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(m.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)(De,{}),(0,X.jsx)(`span`,{children:`GitHub`})]},e.id);if(e.source===`host`){let t=Ke[e.id];if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>D(!1),children:t},e.id)}else{let t=Xe(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),H(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),H(e)||s?.(e)},children:[e.icon&&!/[a-z]/i.test(e.icon)?`${e.icon} `:``,e.label]},e.id)})})]}),at.map(e=>(0,X.jsx)(m.Fragment,{children:e.node},e.id)),J&&(0,X.jsx)(Sa,{onClose:()=>be(!1)}),A&&(0,X.jsx)(xa,{anchorRect:A.rect,anchorEl:A.el,plugins:r,pinnedIds:R,orderedPluginIds:B,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:ai(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:oi(e.settings?.uiLayout,t)}),onOpenView:e=>{ee(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>ee(null)}),O&&(0,X.jsx)(ga,{open:!0,currentCwd:j,pathCompletions:e.pathCompletions??[],workspaceRoots:M,onClose:()=>k(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Fa(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 Ia(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 La(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 Ra(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 za(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 Ba(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 Va=null,Ha=new Set;function Ua(){for(let e of Ha)e()}function Wa(e){let t=(e??``).trim();t&&(Va={name:t,status:`loading`},Ua(),$({type:`get_tool_info`,name:t}))}function Ga(){Va!==null&&(Va=null,Ua())}function Ka(e){Va!==null&&Va.name===e.name&&(Va=Ba(e),Ua())}function qa(e){return Ha.add(e),()=>{Ha.delete(e)}}function Ja(){return Va}function Ya(){return(0,m.useSyncExternalStore)(qa,Ja,Ja)}var Xa=`__piWebUiHost`,Za=e=>new Promise(t=>setTimeout(t,e));async function Qa(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 Za(100)}}var $a=Promise.resolve(),eo=0;function to(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 Za(t)}},i=()=>{try{let t=e.listModels?.()??[];return Array.isArray(t)?[...t]:[]}catch{return[]}},a=e=>{if(!e)return!0;try{return i().some(t=>t&&t.id===e)}catch{return!1}},o=async t=>{t&&(e.send({type:`set_model`,modelId:t}),typeof e.getCurrentModelId==`function`&&await r(()=>e.getCurrentModelId?.()===t))},s=async(t,n)=>{let i=String(n.cwd??``).trim();if(i&&e.getCwd()!==i&&(e.send({type:`set_cwd`,path:i}),await r(()=>e.getCwd()===i)),n.newChat!==!1){let t=e.getConversationId();e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank())}let a=String(n.model??``).trim();a&&await o(a),e.send({type:`prompt`,text:t})};return{version:11,setView(t){let n=String(t??``).trim();n&&e.setView(n)},startChat(t){let n=String(t?.prompt??``).trim();if(!n||!e.isReady())return!1;let r=String(t?.model??``).trim();if(r&&!a(r))return!1;let i=()=>s(n,t??{prompt:n}),o;return o=eo>0?$a.then(i):i(),eo++,$a=o.then(()=>{eo--},()=>{eo--}),o.catch(()=>{}),!0},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>Mo(e)},compose(e){return Hn()?Un({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=oo,i=Array.isArray(t?.folders)?t.folders.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],s=Array.isArray(t?.roots)?t.roots.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],c=String(t?.cwd??``).trim(),l=[...new Set([...i,...s])],u=c||l[0]||``;if(!u)return{ok:!1,error:`openSession 需要 cwd / folders / roots(绝对路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let d=l.filter(e=>e!==u).slice(0,7),f=new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]);for(let t of[u,...d])if(!f.has(t)){if(!(e.confirm&&await e.confirm({path:t}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${t}`};e.grantPath?.(t,n)}if(e.getCwd()!==u&&(e.send({type:`set_cwd`,path:u}),!await r(()=>e.getCwd()===u)))return{ok:!1,error:`切换工作目录失败或超时:${u}`};(d.length>0||e.getWorkspaceRoots().length>0)&&e.send({type:`set_workspace_roots`,roots:d});let p=e.getConversationId()??void 0;if(t?.newChat!==!1){let t=p;e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank()),p=e.getConversationId()??void 0}let m=String(t?.model??``).trim();if(m){if(!a(m))return{ok:!1,error:`未知模型:${m}(先调 models.list() 取可用列表)`};await o(m),p=e.getConversationId()??p}let h=String(t?.prompt??``).trim();return h&&e.send({type:`prompt`,text:h}),{ok:!0,...p?{sessionId:p}:{}}},sessions:{list:()=>e.listSessions(),async open(t){let n=oo,i=String(t??``).trim();if(!i)return{ok:!1,error:`sessions.open 需要一个会话 id(先调 list)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let a=e.listSessions().find(e=>e.id===i);if(!a)return{ok:!1,error:`找不到会话:${i}`};if(a.cwd&&a.cwd!==e.getCwd()){if(!new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]).has(a.cwd)){if(!(e.confirm&&await e.confirm({path:a.cwd}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${a.cwd}`};e.grantPath?.(a.cwd,n)}if(e.send({type:`set_cwd`,path:a.cwd}),!await r(()=>e.getCwd()===a.cwd))return{ok:!1,error:`切换工作目录失败或超时:${a.cwd}`}}let o=e.getConversationId();return a.kind===`running`?e.send({type:`switch_conversation`,id:a.id}):e.send({type:`switch_session`,path:a.id}),await r(()=>e.getConversationId()!==o)?{ok:!0,sessionId:e.getConversationId()??void 0}:{ok:!1,error:`切换会话超时:${a.title}`}}},async reloadCatalog(t,n){let r=String(t??``).trim();if(!r)return{ok:!1,error:`reloadCatalog 需要一个目录来源(http(s) URL 或本地文件路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let i=dt();return new Promise(t=>{let a=setTimeout(()=>{Bo.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));Bo.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 co(io,String(e??``).trim(),t)},onTopbarAction(e,t){return co(io,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(vn())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 Qa(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(uo,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>yo(String(e??``),t)},searchProviders:{register:e=>xo(e),list:()=>So()},composerProviders:{register:e=>wo(e),list:()=>To()},onTheme:e=>Po(e),onLocale:e=>Fo(e),onViewChange:e=>Io(e)}}function no(e){try{let t=window;e?t[Xa]=e:delete t[Xa]}catch{}}var ro=new Map,io=null;async function ao(e,t){let n=io;io=e;try{return await t()}finally{io=n}}var oo=void 0;function so(e,t){let n=oo;oo=e;try{return t()}finally{oo=n}}function co(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=ro.get(r);i||(i=new Set,ro.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&ro.delete(r)}}async function lo(e,t,n,r){let i=i=>{let a=ro.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{so(e,()=>i(n,r?.value,r?.target))}catch(n){console.error(`[plugin:${e}] 顶栏动作 ${t} 抛错:`,n)}return!0};if(i(`${e}:${t}`)||i(t))return!0;if(r?.loadBundle&&await r.loadBundle(e).catch(()=>!1)){let n=Date.now()+Math.max(100,Number(r.waitMs??1500));for(;;){if(i(`${e}:${t}`)||i(t))return!0;if(Date.now()>=n)break;await new Promise(e=>setTimeout(e,100))}}return!1}var uo=`pi-web-ui:toast`,fo=new Map,po=!1;function mo(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 ho(){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 go(e){try{if(ho())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=fo.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function _o(){if(!po)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,go),po=!0}catch{}}function vo(){if(!(fo.size>0||!po))try{window.removeEventListener(`keydown`,go)}catch{}finally{po=!1}}function yo(e,t){if(typeof t!=`function`)return()=>{};let n=mo(e);if(!n)return()=>{};let r=fo.get(n.combo);r||(r=new Set,fo.set(n.combo,r));let i=r;return i.add(t),_o(),()=>{i.delete(t),i.size===0&&fo.delete(n.combo),vo()}}var bo=new Map;function xo(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 bo.set(t,n),()=>{bo.get(t)===n&&bo.delete(t)}}function So(){return[...bo.values()].map(e=>({id:e.id,label:e.label}))}var Co=new Map;function wo(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 Co.set(t,n),()=>{Co.get(t)===n&&Co.delete(t)}}function To(){return[...Co.values()].map(e=>({id:e.id,label:e.label}))}function Eo(e){return Co.get(String(e??``))}function Do(e){return bo.get(String(e??``))}var Oo=new Set,ko=new Set,Ao=new Set,jo=new Set;function Mo(e){return jo.add(e),()=>{jo.delete(e)}}function No(e){for(let t of[...jo])try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function Po(e){return typeof e==`function`?(Oo.add(e),()=>{Oo.delete(e)}):()=>{}}function Fo(e){return typeof e==`function`?(ko.add(e),()=>{ko.delete(e)}):()=>{}}function Io(e){return typeof e==`function`?(Ao.add(e),()=>{Ao.delete(e)}):()=>{}}function Lo(e){let t=String(e??``);for(let e of[...Oo])try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function Ro(e){let t=String(e??``);for(let e of[...ko])try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function zo(e){let t=String(e??``);for(let e of[...Ao])try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var Bo=new Map;function Vo(e){let t=Bo.get(e.requestId);if(t){if(Bo.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 Ho=`modulepreload`,Uo=function(e){return`/`+e},Wo={},Go=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=Uo(t,n),t=s(t),t in Wo)return;Wo[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`:Ho,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)})},Ko=`pi-web-ui:plugin-data`;function qo(e,t){window.dispatchEvent(new CustomEvent(Ko,{detail:{pluginId:e,payload:t}}))}function Jo(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(Ko,t),()=>window.removeEventListener(Ko,t)}var Yo=new Map,Xo=new Set,Zo=new Set,Qo=new Set,$o=new Set,es=-1;function ts(){return[...Yo.values()]}function ns(){let e=ts();for(let t of Zo)t(e)}function rs(){let e=[...Qo];for(let t of $o)t(e)}function is(e){return $o.add(e),e([...Qo]),()=>$o.delete(e)}async function as(e,t){Qo.delete(e.id),ss.set(e.id,(ss.get(e.id)??0)+1),rs();let n=await fs(e,t);return ns(),n}function os(e){return Zo.add(e),e(ts()),()=>Zo.delete(e)}var ss=new Map;function cs(e,t){let n=ss.get(e)??0;return Gt(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function ls(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>ao(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var us=ls(e=>Go(()=>import(e),[]));async function ds(e,t){if(!e.hasClient||e.error)return null;try{return(await us(e.id,cs(e.id,t))).default??null}catch(t){return console.error(`[plugin:${e.id}] 客户端 bundle 加载失败:`,t),null}}async function fs(e,t){try{let n=(await us(e.id,cs(e.id,t))).default;return n&&typeof n.mount==`function`?(Yo.set(e.id,{info:e,module:n}),!0):e.preload?(Xo.add(e.id),!0):(Qo.add(e.id),rs(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return Qo.add(e.id),rs(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function ps(e,t){if(Yo.has(e.id)||Xo.has(e.id))return!0;if(Qo.has(e.id)||!e.hasClient)return!1;let n=await fs(e,t);return ns(),n}async function ms(e,t){t!==es&&(es=t,Yo.clear(),Xo.clear(),Qo.clear(),ss.clear(),rs());let n=new Set(e.map(e=>e.id));for(let e of[...Yo.keys()])n.has(e)||Yo.delete(e);for(let e of[...Xo])n.has(e)||Xo.delete(e);for(let e of[...Qo])n.has(e)||Qo.delete(e);rs(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!Yo.has(e.id)&&!Xo.has(e.id)&&!Qo.has(e.id)).map(e=>fs(e,t))),ns()}function hs(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>Jo((n,r)=>{n===e&&t(r)})}}var gs=[`debug`,`info`,`warn`,`error`];function _s(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function vs(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function ys(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`&&gs.includes(String(e.level)))}var bs=new Map,xs=new Set;function Ss(){for(let e of[...xs])try{e()}catch{}}function Cs(e){return xs.add(e),()=>xs.delete(e)}function ws(e){return(bs.get(e)??[]).map(e=>({...e}))}function Ts(e,t){return ys(t)?(bs.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),Ss(),!0):!1}function Es(){return{flows:[],results:{}}}function Ds(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 Os(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:Ds(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:Ds(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 ks=`pi-web-ui:lang`;function As(){try{return(localStorage.getItem(ks)??``).trim()}catch{return``}}var js=`pi-web-ui:locale`,Ms=2e5,Ns=2e5,Ps=`LIVE_OMIT`,Fs={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 Is(){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>Ns?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 Ls(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 Rs(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 zs(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!==20};case`snapshot`:return{...e,ready:!0,state:t.state,approval:t.state.pendingApproval??null,activeConversationId:t.state.conversationId,liveOutputs:Ls(e.liveOutputs,t.state),toolStatuses:Rs(e.toolStatuses,t.state)};case`snapshot_delta`:{let n=e.state,r=t.msg;if(!n||n.conversationId!==r.conversationId||n.rev!==r.baseRev)return e;let i={...n,...r.state,messages:r.appended.length>0?[...n.messages,...r.appended]:n.messages};return{...e,ready:!0,state:i,approval:i.pendingApproval===void 0?e.approval:i.pendingApproval??null,activeConversationId:i.conversationId,liveOutputs:Ls(e.liveOutputs,i),toolStatuses:Rs(e.toolStatuses,i)}}case`tool_approval`:return{...e,approval:t.approval};case`tool_delta`:{let n=(e.liveOutputs.get(t.toolCallId)?.text??``)+t.delta,r=n.length>Ms?`…[${Ps}:${n.length-Ms}]…\n`+n.slice(n.length-Ms):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:Ra(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=Os({flows:e.providerOAuthFlows,results:e.providerOAuthResults},t.message);return{...e,providerOAuthFlows:n.flows,providerOAuthResults:n.results}}case`fetch_models_result`:return{...e,fetchModelsResult:t.result};case`test_model_connection_result`:return{...e,testModelConnectionResult:t.result};case`enrich_models_progress`:return{...e,enrichModelsProgress:t.progress};case`enrich_models_result`:return{...e,enrichModelsResult:t.result,enrichModelsProgress:null};case`refresh_provider_result`:return{...e,refreshProviderResult:t.result};case`refresh_builtin_result`:return{...e,refreshBuiltinResult:t.result};case`append_builtin_result`:return{...e,appendBuiltinResult:t.result};case`clone_provider_result`:return{...e,cloneProviderResult:t.result};case`install_result`:return{...e,installResult:t.result};case`scm_data`:return{...e,scmData:t.data};case`file_search_result`:return{...e,fileSearch:t.result};case`session_search_result`:return{...e,sessionSearch:t.result};case`scm_changed`:return{...e,scmDirty:e.scmDirty+1};case`path_completions`:return{...e,pathCompletions:t.completions};case`update_status`:return{...e,update:t.status};case`update_status_all`:return{...e,updatesAll:t.items,updatesSdk:t.piSdk??null};case`updates_check_started`:return{...e,updatesAll:null};case`widgets`:return{...e,widgets:t.widgets};case`statuses`:return{...e,statuses:t.statuses};case`dialog`:return{...e,dialog:t.dialog};case`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_updates_check_started`:return{...e,checkingPluginUpdates:!0};case`plugin_updates`:{let n={};for(let e of t.updates)n[e.id]=e;return{...e,pluginUpdates:n,checkingPluginUpdates:!1}}case`plugin_catalog`:return{...e,pluginCatalog:t.entries,pluginCatalogEpoch:t.epoch};case`plugin_grants`:return{...e,pluginGrants:t.grants};case`plugin_permissions`:return{...e,pluginPermissions:t.grants};case`plugin_path_request`:return{...e,pathRequests:[...e.pathRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_path_resolved`:return{...e,pathRequests:e.pathRequests.filter(e=>e.id!==t.id)};case`plugin_permission_request`:return{...e,permRequests:[...e.permRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_permission_resolved`:return{...e,permRequests:e.permRequests.filter(e=>e.id!==t.id)};case`plugin_job`:{let{pluginId:n,phase:r,ok:i,action:a}=t.job,o=e.pluginUpdates;a===`update`&&r===`done`&&i&&e.pluginUpdates?.[n]&&(o={...e.pluginUpdates,[n]:{...e.pluginUpdates[n],updatable:!1}});let s=e.pluginJobs[t.job.jobId],c=t.line?[...s?.lines??[],t.line].slice(-40):s?.lines??[],l={...s,...t.job,lines:c,startedAt:s?.startedAt??Date.now()};return{...e,pluginUpdates:o,pluginJobs:{...e.pluginJobs,[t.job.jobId]:l}}}case`plugin_catalog_sync_result`:return{...e,catalogSync:{...t.result,receivedAt:Date.now()}};case`plugin_install_inspect_result`:return{...e,installInspect:t.result};case`dsh_patches`:return{...e,dshPatches:{patchDir:t.patchDir,files:t.files}};case`dsh_presets`:return{...e,dshPresets:{presets:t.presets,defaultPreset:t.defaultPreset}};case`dsh_permission`:return{...e,dshPermission:{options:t.options,defaultPreset:t.defaultPreset}};case`terminal_add`:return{...e,terminals:[...e.terminals,t.meta]};case`terminal_remove`:return{...e,terminals:e.terminals.filter(e=>e.id!==t.id)};case`terminal_exit`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!1,exitCode:t.exitCode}:e)};case`terminal_restart`:return{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!0,exitCode:null}:e)};case`terminal_list`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:t.terminals.map(n=>({...n,conversationId:t.conversationId??e.state?.conversationId??``}))};case`terminal_active`:return{...e,terminalActiveId:t.id};default:return e}}var Bs=`pi-web-client-id`,Vs=null;function Hs(){if(Vs)return Vs;let e=null;try{e=sessionStorage.getItem(Bs),e||(e=dt(),sessionStorage.setItem(Bs,e))}catch{e??=dt()}return Vs=e,e}var Us=`pi-web-last-cwd`;function Ws(){try{return localStorage.getItem(Us)}catch{return null}}function Gs(e){try{localStorage.setItem(Us,e)}catch{}}function Ks(e){try{let t=localStorage.getItem(Us);if(!t)return;let n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase();(t===e||n(t)===n(e))&&localStorage.removeItem(Us)}catch{}}function qs(){return Yt(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${Gt(`/ws`)}`)}function Js(){let[e,t]=(0,m.useReducer)(zs,{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:Es().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,updatesSdk:null,widgets:[],statuses:[],dialog:null,approval:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:Fs,bgServers:[],schedulerTasks:[],settings:null,fetchModelsResult:null,testModelConnectionResult:null,enrichModelsResult:null,enrichModelsProgress:null,refreshProviderResult:null,refreshBuiltinResult:null,appendBuiltinResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginUpdates:null,checkingPluginUpdates:!1,pluginCatalog:[],pluginCatalogEpoch:0,pluginJobs:{},catalogSync:null,installInspect:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,dshPresets:null,dshPermission:null,protocolMismatch:!1}),n=(0,m.useRef)(null),r=(0,m.useRef)(Is()),i=(0,m.useRef)(0),a=(0,m.useRef)(null),o=(0,m.useRef)(!0),s=(0,m.useRef)(0),c=(0,m.useRef)(0),l=(0,m.useRef)(new Map),u=(0,m.useRef)(null),d=(0,m.useRef)(!1),f=(0,m.useRef)(null),p=(0,m.useRef)(new Set),h=(0,m.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,m.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]),y=(0,m.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`}),e.type===`check_plugin_updates`&&t({type:`plugin_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(p.current.add(e.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}h.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,m.useCallback)((e,n)=>{let r=za({current:O.current.chat.question,source:h.current,snapshot:e,answered:p.current,activeConversationId:n});r.changed&&(h.current=r.source,t({type:`question`,question:r.question}))},[]);ua(y);let x=(0,m.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(qs());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:Hs(),locale:As()})))},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!==`20260926T06540`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}ta({engine:a.engine??`pi`,managed:!!a.managed,tabs:a.tabs,appVersion:a.appVersion,serverVersion:a.serverVersion,service:a.service}),t({type:`ready`,serverVersion:a.serverVersion,protocolVersion:a.protocolVersion,engine:a.engine,appVersion:a.appVersion,managed:a.managed,tabs:a.tabs,service:a.service}),p.current.clear(),t({type:`question`,question:null}),e.send(JSON.stringify({type:`get_state`})),e.send(JSON.stringify({type:`list_files`})),e.send(JSON.stringify({type:`list_models`})),e.send(JSON.stringify({type:`list_commands`})),e.send(JSON.stringify({type:`get_commands`})),a.managed||(e.send(JSON.stringify({type:`check_update`})),e.send(JSON.stringify({type:`check_updates_all`})));break;case`snapshot`:l.current=new Map,t({type:`snapshot`,state:a.state}),b(a.state.pendingQuestion,a.state.conversationId);break;case`snapshot_delta`:{let e=O.current.chat.state;(!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`subagent_handoff`: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`test_model_connection_result`:t({type:`test_model_connection_result`,result:{reqId:a.reqId,ok:a.ok,latencyMs:a.latencyMs,error:a.error}});break;case`enrich_models_progress`:t({type:`enrich_models_progress`,progress:{reqId:a.reqId,phase:a.phase,current:a.current,total:a.total,message:a.message}});break;case`enrich_models_result`:t({type:`enrich_models_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,error:a.error}});break;case`refresh_provider_result`:t({type:`refresh_provider_result`,result:{reqId:a.reqId,ok:a.ok,added:a.added,total:a.total,error:a.error}});break;case`refresh_builtin_result`:t({type:`refresh_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`append_builtin_result`:t({type:`append_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`clone_provider_result`:t({type:`clone_provider_result`,result:{reqId:a.reqId,ok:a.ok,config:a.config,configs:a.configs,error:a.error}});break;case`scm_data`:t({type:`scm_data`,data:a});break;case`search_files_result`:t({type:`file_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,truncated:a.truncated}});break;case`session_search_results`:t({type:`session_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results}});break;case`scm_changed`:t({type:`scm_changed`});break;case`tool_info`:Ka(a);break;case`heartbeat`:a.hostMetrics&&t({type:`host_metrics`,metrics:a.hostMetrics});break;case`install_result`:t({type:`install_result`,result:a});break;case`path_completions`:t({type:`path_completions`,completions:a.completions});break;case`update_status`:t({type:`update_status`,status:a});break;case`update_status_all`:t({type:`update_status_all`,items:a.items,piSdk:a.piSdk});break;case`widgets`:t({type:`widgets`,widgets:a.widgets});break;case`statuses`:t({type:`statuses`,statuses:a.statuses});break;case`dialog`:t({type:`dialog`,dialog:{id:a.id,kind:a.kind,title:a.title,args:a.args}});break;case`dialog_closed`:t({type:`dialog`,dialog:null});break;case`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`tool_approval_pending`:t({type:`tool_approval`,approval:{id:a.id,toolCallId:a.toolCallId,toolName:a.toolName,params:a.params,reason:a.reason,reasonEn:a.reasonEn,...a.category?{category:a.category}:{},...a.conversationId===void 0?{}:{conversationId:a.conversationId},...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`tool_approval_resolved`:t({type:`tool_approval`,approval:null});break;case`question_retracted`:{let e=O.current.chat.question;if(e&&e.id===a.id){if(p.current.add(a.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}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_updates`:t({type:`plugin_updates`,updates:a.updates});break;case`plugin_catalog`:t({type:`plugin_catalog`,entries:a.entries,epoch:a.epoch});break;case`plugin_grants`:t({type:`plugin_grants`,grants:a.grants});break;case`plugin_permissions`:t({type:`plugin_permissions`,grants:a.grants});break;case`plugin_permission_request`:t({type:`plugin_permission_request`,req:{id:a.id,pluginId:a.pluginId,family:a.family,...a.hosts?{hosts:a.hosts}:{},...a.models?{models:a.models}:{},...a.reason?{reason:a.reason}:{}}});break;case`plugin_permission_resolved`:t({type:`plugin_permission_resolved`,id:a.id});break;case`plugin_path_request`:t({type:`plugin_path_request`,req:{id:a.id,pluginId:a.pluginId,path:a.path,...a.reason?{reason:a.reason}:{}}});break;case`plugin_dom_consent_request`:a.from===Hs()&&e.send(JSON.stringify({type:`plugin_dom_consent_response`,id:a.id,ok:!0}));break;case`plugin_job`:t({type:`plugin_job`,job:{jobId:a.jobId,action:a.action,pluginId:a.pluginId,phase:a.phase,...a.ok===void 0?{}:{ok:a.ok},...a.error?{error:a.error}:{},...a.output?{output:a.output}:{}},...a.line?{line:a.line}:{}});break;case`plugin_install_inspect_result`:t({type:`plugin_install_inspect_result`,result:{requestId:String(a.requestId??``),source:String(a.source??``),kind:a.kind,suggestedId:String(a.suggestedId??``),installed:a.installed===!0,...a.problem?{problem:a.problem}:{},...a.detail?{detail:a.detail}:{},...a.manifest?{manifest:a.manifest}:{}}});break;case`plugin_catalog_sync_result`:Vo(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`:Ts(a.pluginId,a.payload)||qo(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,m.useEffect)(()=>{let e=e=>{let t=e.detail??As();t&&y({type:`set_locale`,locale:t})};return window.addEventListener(js,e),()=>window.removeEventListener(js,e)},[y]),(0,m.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,m.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=Ws();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}f.current!==t&&(f.current=t,Gs(t))}},[e.state?.cwd,y]),(0,m.useEffect)(()=>{ta({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,m.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,m.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,m.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,m.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,m.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,m.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,m.useRef)({chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}});return O.current={chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}},O.current}function Ys(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 Xs(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 Zs=`pi-web-ui:lp-collapse-projects`,Qs=`pi-web-ui:lp-collapse-convs`,$s=`pi-web-ui:lp-collapse-sessions`;function ec(e,t=!1){let[n,r]=(0,m.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,m.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var tc=`pi-web-ui:lp-sizes`,nc={projects:1,convs:1,sessions:1},rc=32,ic=72;function ac(){try{return Fa(localStorage.getItem(tc),nc)}catch{return{...nc}}}var oc=(0,m.memo)(function({sessionFile:e,conversations:t,elsewhere:n,sessions:r,projects:i,activeConversationId:a,panelSend:o,active:s,collapsible:c,onToggleCollapse:l,pathCompletions:u,uiContextSession:d,uiLeftSessions:f,onUiAction:p,presetNames:h}){let g=Z(),_=e,v=aa(`ready`),y=aa(`status`),b=aa(`cwd`),x=aa(`workspaceRoots`),S=b,[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(null),[D,O]=(0,m.useState)(null),[k,A]=(0,m.useState)(null),[ee,j]=(0,m.useState)(``),[M,P]=ec(Zs,!1),[F,I]=ec(Qs,!1),[L,te]=ec($s,!1),z=(0,m.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]),B=(0,m.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},[]),V=(0,m.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},[]),ne=(0,m.useRef)(null),re=(0,m.useRef)(null),H=(0,m.useRef)(()=>{}),U=Gi(d??[]).length>0,W=(0,m.useCallback)((e,n,r)=>{ne.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=z(t,i),c=s===0?g(`noFinishedSubagents`):g(i?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:s}),l=!!i&&re.current===i;Pi({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,hidden:!0}:n?.isEphemeral?{...e,label:g(`saveEphemeral`)}:e}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)=>H.current(e,t)})},[d,t,z,g]);H.current=(0,m.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=ne.current;if(!i||!e)return;if(re.current!==i)return re.current=i,W(e.x,e.y,e.target),!0;re.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?Un({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&Un({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);j(e?.title??n.label??``),A(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);j(e?.name??n.label??``),A(n.id)}return}},[o,W,t,r]);let ie=()=>{let e=(f??[]).filter(e=>!$r.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(),p?.(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(),p?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:r})},n)})})},ae=(0,m.useCallback)((e,t)=>{Xs(e.target)||U&&(e.preventDefault(),e.stopPropagation(),re.current=null,W(e.clientX,e.clientY,t))},[U,W]),oe=(0,m.useRef)(null),[se,le]=(0,m.useState)(()=>ac());(0,m.useEffect)(()=>{try{localStorage.setItem(tc,JSON.stringify(se))}catch{}},[se]);let ue=[...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}:{}}))],de=(0,m.useCallback)((e,t)=>n=>{n.preventDefault();let r=n.currentTarget,a=n.clientY,o={...se},s=oe.current;if(!s)return;let c=[{key:`projects`,visible:i.length>0,collapsed:M},{key:`convs`,visible:ue.length>0,collapsed:F},{key:`sessions`,visible:!0,collapsed:L}].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*rc);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let f=n=>{let{above:r,below:i}=Ia({start:{above:o[e]??1,below:o[t]??1},deltaPx:n.clientY-a,availablePx:d,totalWeight:u,minAbovePx:ic,minBelowPx:ic});le(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)},[se,i.length,ue.length,M,F,L]);(0,m.useEffect)(()=>{s&&v&&y===`open`&&b&&(o({type:`list_sessions`}),o({type:`list_projects`}))},[s,v,y,b,o]);let pe=e=>{let t=e.name||e.firstMessage.trim();return t.length>0?t:g(`emptyChat`)},me=e=>e.split(/[\\/]/).pop()||e,he=(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)(Ye,{}):i??(0,X.jsx)(R,{})})},ge=(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)(Je,{}):(0,X.jsx)(Ke,{})})]}),i?(0,X.jsx)(`div`,{className:`lp-section-actions`,children:i}):null]}),_e=[{key:`projects`,visible:i.length>0,collapsed:M},{key:`convs`,visible:ue.length>0,collapsed:F},{key:`sessions`,visible:!0,collapsed:L}].filter(e=>e.visible).filter(e=>!e.collapsed),ve=_e.reduce((e,t)=>e+(se[t.key]??1),0)||1,K=e=>_e.length<=1?1:(se[e]??1)/ve*_e.length;return(0,X.jsxs)(`aside`,{ref:oe,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)(Ge,{})}),(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${M||i.length===0?`collapsed`:``}`,style:i.length>0&&!M?{flex:`${K(`projects`)} 1 0px`}:void 0,children:[ge(g(`recentProjects`),M,P,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&&!M&&(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)(ke,{className:`project-icon`}),(0,X.jsxs)(`span`,{className:`project-info`,children:[(0,X.jsx)(`span`,{className:`project-name`,children:me(e.path)}),(0,X.jsx)(`span`,{className:`project-path`,children:e.path})]}),(0,X.jsx)(`span`,{className:`project-time`,children:Ys(e.lastUsed)})]}),he(`proj:${e.path}`,g(`deleteProject`),g(`deleteProjectConfirm`),()=>{Ks(e.path),o({type:`remove_project`,path:e.path})})]},e.path)})})]}),i.length>0&&!M&&(ue.length>0?!F:!L)&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:de(`projects`,ue.length>0?`convs`:`sessions`),onDoubleClick:()=>le({...nc}),title:g(`dragToResize`)}),ue.length>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${F?`collapsed`:``}`,style:F?void 0:{flex:`${K(`convs`)} 1 0px`},onContextMenu:e=>ae(e,{id:``,kind:`section`,label:g(`runningConversations`)}),children:[ge(g(`runningConversations`),F,I,ue.length),!F&&(0,X.jsx)(`div`,{className:`lp-section-body convs-scroll`,children:La(ue,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:me(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){let e=n.owner,t=n.convId,r=!!(e&&t),i=D===n.id;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>O(e=>e===n.id?null:e),onContextMenu:r=>ae(r,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{}}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item elsewhere-item${r?``:` elsewhere-static`}${i?` confirm`:``}`,title:i?g(`takeoverConfirm`):`${g(`elsewhereTip`)}\n${n.cwd}`,tabIndex:r?0:-1,onClick:r?()=>{if(!i){O(n.id);return}O(null),o({type:`take_over_conversation`,owner:e,id:t})}:void 0,children:[(0,X.jsx)(G,{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&&e&&t&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:g(`takeoverHasQuestion`),onClick:n=>{n.stopPropagation(),o({type:`peek_elsewhere_question`,owner:e,id:t})},children:`?`}),i?g(`takeoverConfirm`):n.title]}),(0,X.jsx)(`span`,{className:`session-sub`,children:me(n.cwd)})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:g(`streaming`)})]}),U&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-elsewhere-act`,title:g(`elsewhereActions`),onClick:r=>{r.stopPropagation(),re.current=null;let i=r.currentTarget.getBoundingClientRect();W(i.left,i.bottom+4,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{}})},children:(0,X.jsx)(fe,{})})]},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=>ae(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)(G,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[k===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:ee,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>j(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=ee.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),A(null)}else e.key===`Escape`&&A(null)},onBlur:()=>A(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:g(`subagentBadge`)}),n.isEphemeral&&(0,X.jsx)(`span`,{className:`ephemeral-badge`,children:g(`ephemeralBadge`)}),n.forkFrom&&(0,X.jsxs)(`span`,{className:`preset-badge fork-badge`,title:`${g(`forkBadgeTip`)}: ${n.forkFrom.title??n.forkFrom.conversationId}`,children:[`🌿 `,g(`forkBadge`)]}),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:`?`})]}),k===`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),j(n.title),A(`conv:${n.id}`)},children:(0,X.jsx)(Fe,{})}),(()=>{let e=`conv:${n.id}`,r=T===e,i=z(t,n.id),a=V(t,n.id),s=B(t,n.id);return s===0&&!n.isStreaming?he(e,g(`dismissConversation`),g(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(N,{})):s===0?he(e,g(`dismissConversation`),g(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(N,{})):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)(N,{})})})(),ie(),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))})]}),ue.length>0&&!F&&!L&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:de(`convs`,`sessions`),onDoubleClick:()=>le({...nc}),title:g(`dragToResize`)}),(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${L?`collapsed`:``}`,style:L?void 0:{flex:`${K(`sessions`)} 1 0px`},children:[ge(g(`historySessions`),L,te,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`}),Vn()},children:(0,X.jsx)(ce,{})})),!L&&(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=>ae(t,{id:e.path,kind:`history`,label:pe(e)}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${t?`active`:``}`,title:e.path,onClick:()=>{k||t||o({type:`switch_session`,path:e.path})},children:[(0,X.jsx)(G,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[k===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:ee,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>j(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=ee.trim();t&&o({type:`rename_session`,path:e.path,name:t}),A(null)}else t.key===`Escape`&&A(null)},onBlur:()=>A(null)}):(0,X.jsx)(`span`,{className:`session-title`,children:pe(e)}),k===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:Ys(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:t=>{t.stopPropagation(),E(null),j(e.name??``),A(e.path)},children:(0,X.jsx)(Fe,{})}),he(`sess:${e.path}`,g(`deleteSession`),g(`deleteSessionConfirm`),()=>o({type:`delete_session`,path:e.path})),ie()]},e.path)})]})]}),(0,X.jsx)(ga,{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})})]})}),sc=209715200,cc=/windows/i.test(navigator.userAgent),lc=/[<>:"/\\|?*\u0000-\u001f]/g,uc=/[. ]+$/,dc=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function fc(e){let t=e.replace(lc,`_`).replace(uc,``);return t?dc.test(t)?`_${t}`:t:`_`}function pc(e,t=!0){return Yt(Gt(`/api/file?${new URLSearchParams({clientId:Hs(),path:e,...t?{download:`1`}:{}})}`))}async function mc(e,t){let n=cc?fc(t):t;try{let t=await fetch(pc(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`)>sc)return window.location.assign(pc(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?gc(r,n):_c(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function hc(e,t){let n=cc?fc(t):t;return window.showSaveFilePicker&&window.isSecureContext?gc(e,n):_c(e,n)}async function gc(e,t){let n,r=window.showSaveFilePicker;if(!r)return _c(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:_c(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 _c(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 vc(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 yc(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function bc({text:e}){let t=(0,m.useRef)(null),n=(0,m.useRef)(null),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.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,m.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=vc(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,m.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=vc(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,k.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 xc=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function Sc(e,t={}){let n={archive:Gt(`/api/file-transfer/archive`),upload:Gt(`/api/file-transfer/upload`)},r=new URL(Yt(`${n[e]}?${new URLSearchParams({clientId:Hs(),...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 Cc(e,t,n){let r=await fetch(Sc(`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 hc(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function wc(){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 Tc(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=Sc(`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 Ec({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,m.useState)(e.dir),[o,s]=(0,m.useState)(`skip`),[c,l]=(0,m.useState)([]),[u,d]=(0,m.useState)(0),f=(0,m.useRef)(null),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(``),v=(0,m.useRef)(null);(0,m.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 wc();e?l(e):f.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),h(!0),_(``);try{e.action===`upload`?await Tc(e.dir,c,d):await Cc(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,k.createPortal)((0,X.jsx)(`dialog`,{ref:v,className:`file-transfer-dialog`,"aria-labelledby":`file-transfer-title`,onCancel:e=>{e.preventDefault(),p||t()},children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),x()},children:[(0,X.jsxs)(`div`,{className:`file-transfer-head`,children:[(0,X.jsx)(`h3`,{id:`file-transfer-title`,children:y}),(0,X.jsx)(`button`,{type:`button`,className:`file-transfer-close`,title:r(`close`),"aria-label":r(`close`),disabled:p,onClick:t,children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`p`,{className:`file-transfer-path`,children:(e.action===`upload`?e.dir:e.path)||`.`}),(0,X.jsx)(`p`,{children:r(`fileArchiveLimits`)}),e.action===`extract`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`label`,{children:[r(`fileExtractDestination`),(0,X.jsx)(`input`,{value:i,disabled:p,onChange:e=>a(e.target.value)})]}),(0,X.jsxs)(`label`,{children:[r(`fileConflictPolicy`),(0,X.jsxs)(`select`,{value:o,disabled:p,onChange:e=>s(e.target.value),children:[(0,X.jsx)(`option`,{value:`skip`,children:r(`fileConflictSkip`)}),(0,X.jsx)(`option`,{value:`overwrite`,children:r(`fileConflictOverwrite`)}),(0,X.jsx)(`option`,{value:`error`,children:r(`fileConflictError`)})]})]})]}),e.action===`upload`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:r(`fileFolderUploadHint`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:p,onClick:()=>void b(),children:r(`fileChooseFolder`)}),(0,X.jsx)(`input`,{type:`file`,"aria-label":y,multiple:!0,hidden:!0,disabled:p,ref:e=>{f.current=e,e?.setAttribute(`webkitdirectory`,``)},onChange:e=>l(Array.from(e.target.files??[],e=>({path:e.webkitRelativePath||e.name,file:e})))}),(0,X.jsxs)(`p`,{"aria-live":`polite`,children:[u,` / `,c.length]})]}),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:p,onClick:t,children:r(`cancel`)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:p||e.action===`upload`&&c.length===0,children:p?r(`fileTransferBusy`):y})]})]})}),document.body)}function Dc(e){return e instanceof Error?e.message:String(e)}function Oc(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 kc({plugin:e,epoch:t,send:n,className:r}){let i=(0,m.useRef)(null),{locale:a}=pn(),o=Z(),[s,c]=(0,m.useState)(null),l=(0,m.useRef)(n);(0,m.useEffect)(()=>{l.current=n},[n]),(0,m.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 ps(e,t),r)return;let i=await ao(e.id,()=>Go(()=>import(cs(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,hs(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:Dc(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:Oc(s,e.name,a,o)})]})}function Ac(e){return`pi-web-ui:${e}:tab`}function jc(e,t){try{let n=localStorage.getItem(Ac(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function Mc(e,t){try{localStorage.setItem(Ac(e),t)}catch{}}function Nc(e){return e.length>0&&!/[a-z]/i.test(e)}function Pc(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function Fc({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,m.useId)(),[s,c]=(0,m.useState)(()=>jc(e,t)??t[0]?.id??``),l=(0,m.useRef)([]),u=(0,m.useRef)(``),d=t.findIndex(e=>e.id===s),f=d>=0?t[d]:t[0],p=f?t.indexOf(f):-1;(0,m.useEffect)(()=>{if(!f)return;s!==f.id&&c(f.id);let t=`${e}:${f.id}`;u.current!==t&&(u.current=t,Mc(e,f.id))},[f,s,e]);let h=t=>{c(t.id),u.current=`${e}:${t.id}`,Mc(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(!f)return null;let _=`${o}-panel-${p}`,v=a?`slot-tabs ${a}`:`slot-tabs`;return(0,X.jsxs)(`div`,{className:v,children:[(0,X.jsxs)(`div`,{className:`slot-tabs-bar`,role:`tablist`,children:[t.map((e,t)=>{let n=t===p;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,id:`${o}-tab-${t}`,className:n?`slot-tab active`:`slot-tab`,title:e.hint??Pc(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)(Gr,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&Nc(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:Pc(e)})]},e.id)}),i?(0,X.jsx)(`div`,{className:`slot-tabs-extra`,children:i}):null]}),(0,X.jsx)(`div`,{className:`slot-tabs-body`,id:_,role:`tabpanel`,"aria-labelledby":`${o}-tab-${p}`,children:f.pluginPage?(0,X.jsx)(kc,{plugin:f.pluginPage.plugin,epoch:n,send:r}):f.element??null})]})}var Ic=`@root`,Lc=`pi-web-ui:rp-sizes`,Rc={files:4,widgets:1},zc=120,Bc=56;function Vc(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var Hc=`files`,Uc=[],Wc=()=>{};function Gc(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function Kc(e){return e===Ic||e===`/`||/^[A-Za-z]:$/.test(e)}function qc(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var Jc=(0,m.memo)(function({files:e,fileChanged:t,widgets:n,panelSend:r,onAttach:i,onPreview:a,onNotice:o,collapsible:s,onToggleCollapse:c,uiRightPanelTabs:l,uiContextFile:u,plugins:d,pluginsEpoch:f,send:p}){let h=Z(),g=d??Uc,_=aa(`cwd`),v=aa(`workspaceRoots`),y=aa(`homeDir`),b=aa(`desktopDir`),[x,S]=(0,m.useState)(``),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(!1),D=(0,m.useRef)(null),O=(0,m.useRef)(null),[k,A]=(0,m.useState)(()=>{try{return Fa(localStorage.getItem(Lc),Rc)}catch{return{...Rc}}});(0,m.useEffect)(()=>{try{localStorage.setItem(Lc,JSON.stringify(k))}catch{}},[k]);let ee=n.some(e=>e.lines.length>0),j=(0,m.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-Vc(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=Ia({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:zc,minBelowPx:Bc});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]),M=(0,m.useRef)(null),P=(0,m.useRef)(0),F=(0,m.useCallback)(e=>{M.current=e,e&&(e.scrollTop=P.current)},[]),[I,L]=(0,m.useState)(null),R=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{R.current&&clearTimeout(R.current)},[]);let te=(0,m.useCallback)(e=>{L(e),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>L(null),1200)},[]),z=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}},B=(0,m.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,()=>{z(e)?n():r()}):z(e)?n():r()},[te,o,h]),V=(0,m.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},[_]),ne=(0,m.useCallback)(e=>!e||e===Ic?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),re=104857600,H=(0,m.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]),U=(0,m.useRef)(null),[W,ie]=(0,m.useState)(null),ae=(0,m.useRef)(null),oe=(0,m.useCallback)(()=>{let e=U.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),se=(0,m.useCallback)(()=>{ae.current&&(ae.current.value=``),ae.current?.click()},[]),[ce,le]=(0,m.useState)(null),[ue,de]=(0,m.useState)(null),[fe,pe]=(0,m.useState)(``),[me,he]=(0,m.useState)(null),[ge,G]=(0,m.useState)(``),_e=(0,m.useCallback)((e,t)=>{mc(e,t).then(e=>{e.ok||e.cancelled||o(`error`,h(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?h(`fileNotFoundShort`):e.error}))})},[o,h]),ve=(0,m.useCallback)(()=>{let e=U.current?.target;e&&e.kind!==`list`&&!Kc(e.id)&&(he(null),pe(e.label),de(e.id))},[]),q=(0,m.useCallback)(()=>{if(!ue)return;let e=fe.trim();de(null),e&&r({type:`file_rename`,path:ue,newName:e})},[ue,fe,r]),ye=(0,m.useCallback)(e=>{let t=U.current?.dir??x;de(null),G(``),he({dir:t,kind:e})},[x]),J=(0,m.useCallback)(()=>{if(!me)return;let e=ge.trim();he(null),e&&r({type:`file_create`,dir:me.dir,name:e,kind:me.kind})},[me,ge,r]),xe=(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}),Se=(0,m.useCallback)(()=>{let e=U.current?.target;e&&e.kind!==`list`&&!Kc(e.id)&&window.confirm(h(`fileDeleteConfirm`,{name:e.label}))&&(ce?.src===e.id&&le(null),ue===e.id&&de(null),r({type:`file_delete`,path:e.id}))},[r,h,ce,ue]),Ce=(0,m.useCallback)(()=>{let e=U.current?.target;e&&e.kind!==`list`&&!Kc(e.id)&&r({type:`file_copy`,src:e.id,destDir:Gc(e.id)})},[r]),we=(0,m.useCallback)(e=>{let t=U.current?.target;t&&t.kind!==`list`&&!Kc(t.id)&&le({src:t.id,cut:e})},[]),Te=(0,m.useCallback)(()=>{if(!ce)return;let e=U.current?.dir??x;ce.cut?(r({type:`file_copy`,src:ce.src,destDir:e,move:!0}),le(null)):r({type:`file_copy`,src:ce.src,destDir:e})},[ce,r,x]),Ee=(0,m.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[De,Oe]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(!De)return;let e=e=>{e.target?.closest(`.root-picker`)||Oe(!1)},t=e=>{e.key===`Escape`&&Oe(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[De]);let Y=(0,m.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),je=(0,m.useCallback)(()=>{let e=U.current?.target;if(!e||e.kind!==`dir`)return;let t=ne(e.id);t&&!v.includes(t)&&Y([...v,t])},[v,ne,Y]),Me=(0,m.useCallback)(e=>{H(U.current?.dir??x,Array.from(e.target.files??[]))},[H,x]),Ne=(0,m.useCallback)(e=>{let t=U.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`;ie({action:n,path:V(t.id),dir:V(n===`upload`?U.current?.dir??x:Gc(t.id))});break}case`host:file-open-project`:oe();break;case`host:file-upload`:se();break;case`host:file-add-root`:je();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&Xe(t.id);break;case`host:file-download`:t?.kind===`file`&&_e(t.id,t.label);break;case`host:file-reveal`:t&&r({type:`file_reveal`,path:t.id});break;case`host:file-open-default`:t?.kind===`file`&&r({type:`file_open_default`,path:t.id});break;case`host:file-attach-ref`:t?.kind===`file`&&i(t.id,t.label,`reference`);break;case`host:file-attach-folder`:t?.kind===`dir`&&i(t.id,t.label,`reference`,!0);break;case`host:file-new-file`:ye(`file`);break;case`host:file-new-dir`:ye(`dir`);break;case`host:file-paste`:Te();break;case`host:file-rename`:ve();break;case`host:file-duplicate`:Ce();break;case`host:file-cut`:we(!0);break;case`host:file-copy`:we(!1);break;case`host:file-copy-name`:t&&t.kind!==`list`&&B(t.label,`name:${t.id}`);break;case`host:file-copy-path`:t&&t.kind!==`list`&&B(V(t.id),`path:${t.id}`);break;case`host:file-copy-rel`:t&&t.kind!==`list`&&B(t.id,`rel:${t.id}`);break;case`host:file-refresh`:Ee();break;case`host:file-delete`:Se()}},[oe,x,se,je,a,i,B,V,_e,ye,Te,ve,Ce,we,Ee,Se]),Pe=(0,m.useCallback)((e,t)=>{let n=t.kind===`dir`?ne(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&&Kc(t.id),l=!s&&qc(t.id),d=x===Ic,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&&xc(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-ref`:return a?e:{...e,hidden:!0};case`host:file-reveal`:return!d&&t.id!==Ic?e:{...e,hidden:!0};case`host:file-enter`:case`host:file-attach-folder`:return o?e:{...e,hidden:!0};case`host:file-new-file`:case`host:file-new-dir`:return!a&&!d?e:{...e,hidden:!0};case`host:file-paste`:return!a&&!d&&ce?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}});Gi(f).length!==0&&(e.preventDefault(),e.stopPropagation(),U.current=r,Pi({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:Ne}))},[u,x,ne,h,Ne,_,v,ce]),Fe=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),Le=(0,m.useCallback)(()=>{M.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),M.current?.classList.remove(`drop-root`)},[]),Re=(0,m.useCallback)(e=>{if(Le(),e==null)return;let t=M.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):M.current?.classList.add(`drop-root`)},[Le]),Be=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Ve=(0,m.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),Ue=(0,m.useRef)(0),Ge=(0,m.useRef)(void 0),Ke=(0,m.useCallback)((e,t)=>{let n=++Ue.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||Ue.current===n&&E(!1)},[r]),Je=(0,m.useCallback)(e=>{let t=v.filter(t=>t!==e);Y(t),(x===e||x.startsWith(`${e}/`))&&Ke(``)},[v,Y,x,Ke]);(0,m.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,m.useEffect)(()=>{if(_!==Ge.current){Ge.current=_,Ke(``,{silent:!0});return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&Ke(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,Ke]),(0,m.useEffect)(()=>{t&&t.path===x&&Ke(x,{silent:!0})},[t,x,Ke]);let Xe=e=>Ke(e),Ze=()=>{e?.parent!==null&&e?.parent!==void 0&&Ke(e.parent)},Qe=(()=>{if(x===``||x===Ic)return[];let e=x.split(`/`).filter(e=>!!e&&e!==Ic);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(`/`)}))})(),$e=[];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&&$e.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let et=(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)(We,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:ee?`${k.files} 1 0`:`1 1 0`,minHeight:ee?zc:0},children:(0,X.jsx)(Fc,{storageKey:`rightpanel`,epoch:f??0,send:p??Wc,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===Hc?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...et?[]:[{id:Hc,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:()=>Ke(``),children:h(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===Ic?`active`:``}`,title:h(`computer`),onClick:()=>Ke(Ic),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:h(`homeDir`),onClick:()=>Ke(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:h(`desktopDir`),onClick:()=>Ke(b),children:`🖥️`}),(0,X.jsx)(bc,{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":De,title:h(`workspaceRoots`),onClick:()=>Oe(e=>!e),children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:h(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),De&&(0,X.jsxs)(`div`,{className:`root-picker-menu`,role:`menu`,children:[(0,X.jsx)(`div`,{className:`root-picker-row`,children:(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:x===``?`root-picker-item active`:`root-picker-item`,title:_,onClick:()=>{Oe(!1),Ke(``)},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:()=>{Oe(!1),Ke(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:()=>Je(e),children:(0,X.jsx)(N,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:h(`workspaceRootsHint`)})]})]}),Qe.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(qe,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>Ke(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:F,className:`panel-body`,onScroll:e=>{P.current=e.currentTarget.scrollTop},onContextMenu:e=>Pe(e,{id:x,kind:`list`,label:x===``?h(`rootDir`):x===Ic?h(`computer`):x}),onDragOver:e=>{Fe(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Ve(),Re(Be(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||Le()},onDrop:e=>{if(Le(),!Fe(e))return;e.preventDefault(),e.stopPropagation(),Ve();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,h(`foldersNotSupported`));return}H(Be(e.target),t)},onDragEnd:Le,children:[(0,X.jsx)(`input`,{ref:ae,type:`file`,multiple:!0,hidden:!0,onChange:Me}),W&&(0,X.jsx)(Ec,{request:W,onClose:()=>ie(null),onComplete:Ee}),me&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[me.kind===`dir`?(0,X.jsx)(ke,{className:`file-icon`}):(0,X.jsx)(Ae,{className:`file-icon`}),xe(ge,G,J,()=>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:Ze,children:[(0,X.jsx)(ke,{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${ce?.cut&&ce.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`dir`,label:e.name}),children:[ue===e.path?xe(fe,pe,q,()=>de(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>Xe(e.path),children:[(0,X.jsx)(ke,{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)(be,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>B(e.name,`name:${e.path}`),children:I===`name:${e.path}`?(0,X.jsx)(Ye,{}):(0,X.jsx)(ze,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>B(V(e.path),`path:${e.path}`),children:I===`path:${e.path}`?(0,X.jsx)(Ye,{}):(0,X.jsx)(He,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${ce?.cut&&ce.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`file`,label:e.name}),children:[ue===e.path?xe(fe,pe,q,()=>de(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)(Ae,{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:()=>_e(e.path,e.name),children:(0,X.jsx)(Ie,{})}),(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)(be,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>B(e.name,`name:${e.path}`),children:I===`name:${e.path}`?(0,X.jsx)(Ye,{}):(0,X.jsx)(ze,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>B(V(e.path),`path:${e.path}`),children:I===`path:${e.path}`?(0,X.jsx)(Ye,{}):(0,X.jsx)(He,{})})]},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`)})]})]})}],...$e])})}),ee&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:j,onDoubleClick:()=>A({...Rc}),title:h(`dragToResize`)}),ee&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:Bc},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)(K,{})]}),(0,X.jsx)(`pre`,{className:`widget-lines`,children:e.lines.join(`
|
|
327
|
+
It only opens after you confirm.`,settingsExtensions:`Extensions`,settingsUiPlugins:`UI plugins`,pluginListTab:`Plugin list`,noUiPlugins:`No UI plugins installed (<dataDir>/plugins/)`,pluginPhaseActive:`Active`,pluginPhaseDisabled:`Disabled`,pluginPhaseFailed:`Failed`,pluginPhaseIdle:`Frontend-only`,pluginRescan:`Rescan`,pluginRescanHint:`Re-scan the plugin directory (picks up new/fixed plugins; failure records are cleared and re-evaluated)`,dshPatches:`DSH user patches`,dshPatchesDesc:`Cordis patches loaded at runtime boot, in filename order (<dataDir>/dsh-patches/*.yml). New/edited files take effect after 'Rescan' restarts the runtime; broken files are skipped and logged to runtime stderr.`,dshPatchesRescan:`Rescan`,dshPatchesRescanHint:`Re-scan the patch directory and restart the DSH runtime so new patches take effect`,dshPatchesEmpty:`No patch files yet`,dshPatchesPath:`Patch directory: `,dshPreset:`Agent preset`,dshPresetNewChat:`New chat with this preset`,dshPresetLocked:`Locked`,dshPresetBlankOnly:`Locked after the first message; blank sessions can switch`,dshPresetBroken:` (unavailable)`,dshPresetUser:`custom`,dshPresetDefaultTag:`default`,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 your current settings, then enter a name above to 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)`,planUpdateEnabledDesc:`Structured task plan updates (Plan Mode / Step State Machine): allows the model to break complex tasks into steps and track progress in real time.`,planUpdateOffHint:`Disabled: AI can no longer update the structured plan board`,compactContextEnabledDesc:`Proactively compact context based on the current issue: allows AI to independently specify compression focus, retain core task context, drop irrelevant history, and control retention scope.`,compactContextOffHint:`Disabled: AI cannot proactively invoke context compaction (you can still use /compact or trigger auto-compaction)`,evalEnabledDesc:`Execute Python or JavaScript/TypeScript code in an isolated sandbox with persistent variables; ideal for calculations, data analysis, and algorithm verification (default-off to prevent tool crowding-out).`,evalOffHint:`Disabled: the AI cannot use the persistent code sandbox (can still run scripts via bash)`,patchToolEnabledDesc:`High-reliability structural patch tool (Hashline): line-anchored editing with 4-hex content hashes, syntactic AST block matching, and clipboard registers. Automatically attempts 3-way merge conflict recovery if files diverged.`,patchToolOffHint:`Disabled: AI falls back to basic string replacement via edit`,lspToolEnabledDesc:`Native Language Server Protocol (LSP) tool: IDE-grade semantic code intelligence (definition, references, hover, diagnostics, documentSymbol outline, read_symbol precise slicing, workspaceSymbol search, and cascade impact diagnostics). Multi-agent shared process pool with idle sleep, zero external dependencies.`,lspToolOffHint:`Disabled: AI cannot query LSP semantics and falls back to text search`,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.`},tn=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],nn={};function rn(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(nn[e.code]=e,!0)}function an(e){delete nn[e]}function on(e){return e===`zh`?`中文`:e.toUpperCase()}function sn(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function cn(e){let t=await fetch(Yt(Gt(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var ln=(0,m.createContext)(null);function un(){try{return localStorage.getItem(Qt)}catch{return null}}function dn(){return Zt(un(),typeof navigator<`u`?navigator.languages:[],null)}function fn({children:e}){let[t,n]=(0,m.useState)(dn),[r,i]=(0,m.useState)(0),a=(0,m.useRef)(t);a.current=t;let o=(0,m.useCallback)(e=>{n(e);try{localStorage.setItem(Qt,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,m.useCallback)(async()=>{let e,t=null;try{let n=await cn(`/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 cn(`/api/locales/${e.code}`);return rn({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,m.useEffect)(()=>{s().then(e=>{if(!un()?.trim()){let t=Zt(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!nn[t]){let t=Zt(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(Qt,t)}catch{}}})},[s]);let c=(0,m.useMemo)(()=>[...tn,...Object.values(nn).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,m.useCallback)((e,n)=>{let r=nn[t]?.strings[e]??(t===`zh`?$t[e]:en[e]);if(n)for(let[e,t]of Object.entries(n))r=r.replaceAll(`{${e}}`,String(t));return r},[t,r]);(0,m.useEffect)(()=>{document.documentElement.lang=sn(t)},[t]);let u=(0,m.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(ln.Provider,{value:u,children:e})}function pn(){let e=(0,m.useContext)(ln);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return pn().t}var mn=[{kind:`question`,labelKey:`sound.question`,descKey:`sound.question.desc`},{kind:`done`,labelKey:`sound.done`,descKey:`sound.done.desc`},{kind:`start`,labelKey:`sound.start`,descKey:`sound.start.desc`},{kind:`error`,labelKey:`sound.error`,descKey:`sound.error.desc`},{kind:`approval`,labelKey:`sound.approval`,descKey:`sound.approval.desc`}];function hn({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)(P,{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})})]}),mn.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 gn(){let[e,t]=(0,m.useState)([]);return(0,m.useEffect)(()=>{if(!Dt())return;let e=window.speechSynthesis,n=()=>t(e.getVoices().map(e=>({voiceURI:e.voiceURI,lang:e.lang,name:e.name,localService:e.localService})));return n(),e.addEventListener?.(`voiceschanged`,n),()=>e.removeEventListener?.(`voiceschanged`,n)},[]),e}function _n({settings:e,onChange:t,onPreview:n}){let r=Z(),i=gn(),a=Dt(),o=n=>t({...e,...n});return(0,X.jsxs)(`div`,{className:`sound-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:r(`ttsHeader`)}),!a&&(0,X.jsx)(`div`,{className:`sound-desc tts-unavailable`,children:r(`ttsUnavailable`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master ${a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(P,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:r(`ttsEnable`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsEnableDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:!a,onChange:e=>o({enabled:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsAnnounce`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsAnnounceDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.announce,disabled:!e.enabled||!a,onChange:e=>o({announce:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsReadReplies`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsReadRepliesDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.readReplies,disabled:!e.enabled||!a,onChange:e=>o({readReplies:e.target.checked})})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsRate`)}),(0,X.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:e.rate,disabled:!e.enabled||!a,onChange:e=>o({rate:Number(e.target.value)})}),(0,X.jsxs)(`span`,{className:`sound-vol-num`,children:[e.rate.toFixed(1),`×`]})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsVoice`)}),(0,X.jsxs)(`select`,{className:`set-input tts-voice-select`,value:e.voiceURI,disabled:!e.enabled||!a,onChange:e=>o({voiceURI:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`ttsVoiceAuto`)}),i.map(e=>(0,X.jsxs)(`option`,{value:e.voiceURI,children:[e.name,` (`,e.lang,`)`,e.localService?``:` · ${r(`ttsVoiceOnline`)}`]},e.voiceURI))]})]}),(0,X.jsx)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:(0,X.jsx)(`button`,{type:`button`,className:`sound-preview tts-preview`,disabled:!e.enabled||!a,onClick:()=>{if(e.voiceURI&&!Ot(e.voiceURI,i,navigator.language)){t({...wt,...e,voiceURI:``});return}n()},children:r(`preview`)})})]})}function vn(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 yn=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),bn=null,xn=0;function Sn(){return bn?.available===!0?bn.pages??[]:[]}function Cn(){Date.now()-xn<5e3||wn().catch(()=>{})}async function wn(){if(vn())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=yn();if(!e)return{available:!1,pages:[],error:`宿主页面桥不可用:这个 pi-web-ui 页面还没装上扩展桥(装/启用 page-picker 后刷新本页)`};try{let t=await e({op:`status`,timeoutMs:5e3});if(!t.ok)return{available:!1,pages:[],error:t.error??`扩展没有返回状态`};let n=t.result??{},r={available:n.installed===!0,aiControl:n.aiControl===!0,allowEval:n.allowEval===!0,pages:Array.isArray(n.pages)?n.pages:[]};return r.available&&(bn=r,xn=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function Tn(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 Dn(){let e=yn();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function On(e=45e3){let[t,n]=(0,m.useState)(null),r=(0,m.useRef)(!0),i=(0,m.useCallback)(async e=>{let t=await wn();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,m.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 kn=null,An=null,jn=null,Mn=null,Nn=null;function Pn(e){Mn=e}function Fn(e){Nn=e}function In(e){return Mn?(Mn(e),!0):!1}function Ln(e){return Nn?(Nn(e),!0):!1}function Rn(e){kn=e}function zn(e){An=e}function Bn(e){jn=e}function Vn(){return jn?(jn(),!0):!1}function Hn(){return!!(kn||An)}function Un(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&&!kn||i&&!An?!1:(i&&An?.(n),r&&kn?.(t),!0)}function Wn(){let e=Z(),{status:t,refresh:n}=On(),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(null),s=(0,m.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=Tn(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},f=t=>{let n=Un({attachments:[En(t)]});d(e(n?`browserControlCited`:`browserControlCiteFailed`))},p=()=>{i(!0),n()};return(0,X.jsxs)(`span`,{className:`bc-anchor`,children:[u?(0,X.jsxs)(`span`,{className:`browser-control-split`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control single${l?` attention`:``}`,"data-tip":e(`browserControlSingleTip`,{name:u.title||u.origin}),title:e(`browserControlSingleTip`,{name:u.title||u.origin}),onClick:()=>f(u),children:[(0,X.jsx)(fe,{size:14,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`bc-chip-label`,children:u.title||u.origin})]}),(0,X.jsx)(`button`,{type:`button`,className:`chip browser-control caret`,"data-tip":e(`browserControlOpenPanel`),title:e(`browserControlOpenPanel`),"aria-label":e(`browserControlOpenPanel`),onClick:p,children:`▾`})]}):(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control${l?` attention`:``}`,"data-tip":t?.error??e(l?`browserControlEmpty`:`browserControlTip`),title:t?.error??e(l?`browserControlEmpty`:`browserControlTip`),onClick:p,children:[(0,X.jsx)(fe,{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)(Gn,{status:t,onRefresh:n,onCite:f,onClose:()=>i(!1)})]})}function Gn({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,m.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await Dn()||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)(fe,{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 Kn=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],qn=[`subagent_spawn`,`subagent_get_result`,`subagent_steer`,`subagent_list`,`subagent_stop`,`subagent_wait_all`,`subagent_templates`,`subagent_handoff`],Jn=`edit_soft`,Yn=`delegate_task`,Xn=`ask_user_question`,Zn=`todo_list`,Qn=`browser_page`,$n=`conversation_read`,er=`skill`,Q=`schedule_task`,tr=`schedule_list`,nr=`schedule_cancel`,rr=`eval`,ir=`present_files`,ar=`claim_files`,or=`plan_update`,sr=`compact_context`,cr=`patch`,lr=[...Kn.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...qn.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:Jn,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:Yn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:Xn,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:Qn,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:$n,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:ar,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:or,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`planUpdateEnabledDesc`,offHintKey:`planUpdateOffHint`},{name:cr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`patchToolEnabledDesc`,offHintKey:`patchToolOffHint`},{name:`lsp`,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`lspToolEnabledDesc`,offHintKey:`lspToolOffHint`},{name:ir,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:er,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:rr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`evalEnabledDesc`,offHintKey:`evalOffHint`},{name:Q,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:tr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:nr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:sr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`compactContextEnabledDesc`,offHintKey:`compactContextOffHint`},{name:Zn,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}],ur=[`bash`,`read`,`edit`,`write`];new Set(lr.map(e=>e.name));function dr(e,t){let n=Array.from(e);if(!t||t===`standard`)return n;if(t===`ask`)return[];if(t===`minimal`)return n.filter(e=>e===`bash`||e===`read`);if(t===`code`){let e=new Set([`bash`,`read`,`edit`,`write`,`edit_soft`]);return n.filter(t=>e.has(t))}if(t===`reader`){let e=new Set([`write`,`edit`,`edit_soft`,`bash`,`terminal_create`,`terminal_input`,`terminal_close`,`terminal_key`]);return n.filter(t=>!e.has(t))}return n}function fr(e){return dr([er],e).includes(er)}var pr=`pi-web-notify`,mr={enabled:!1};function hr(){try{let e=localStorage.getItem(pr);if(!e)return{...mr};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:mr.enabled}}catch{return{...mr}}}function gr(e){try{localStorage.setItem(pr,JSON.stringify(e))}catch{}}function _r(){return typeof window<`u`&&`Notification`in window}function vr(){return _r()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function yr(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&br(t)||Number.isFinite(n)&&br(n)?!0:r>0&&r<=400&&i>0&&i<=40}function br(e){return e<=-1e4}function xr(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var Sr=Date.now(),Cr=!1;function wr(){Sr=Date.now()}function Tr(){return Math.max(0,Date.now()-Sr)}function Er(){if(Cr||typeof window>`u`)return;Cr=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,wr,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,wr,e)}function Dr(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function Or(){return Er(),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:yr({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Tr(),windows:Dr()}}function kr(){return _r()?Notification.permission:`denied`}async function Ar(){if(!_r())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function jr(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function Mr(e,t=!1){return{body:e,requireInteraction:t,icon:Gt(`/icons/icon-192.png`),badge:Gt(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:Gt(`/`)}}}async function Nr(e,t,n=!1){if(!_r())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=Mr(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=jr(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${jr(e)}`}}}async function Pr(e,t){_r()&&(xr(Or())||hr().enabled&&await Nr(e,t))}var Fr=!1;function Ir(){let e=Z(),[t,n]=(0,m.useState)(hr),[r,i]=(0,m.useState)(()=>kr()),[a,o]=(0,m.useState)(null),s=vr(),c=s!==null,l=Dr();(0,m.useEffect)(()=>{let e=()=>i(kr());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),gr(r),e){let e=await Ar();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),gr(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)(et,{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`)}),Fr]})}var Lr=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),Rr=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(`.`)),zr=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),Br=new Set([...Lr].map(e=>e.toLowerCase())),Vr=new Set([...Rr].map(e=>e.toLowerCase()));function Hr(e){return Br.has(e.toLowerCase())}function Ur(e){return Vr.has(e.toLowerCase())}function Wr(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(!Hr(e)){zr.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of[...t.attributes]){let n=e.name.toLowerCase();(!Ur(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();(!Ur(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function Gr({icon:e,iconSvg:t,className:n}){let r=Wr(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 Kr=new Set([`view`,`action`,`badge`,`menu`,`page`,`organizer`,`divider`,`toggle`,`input`,`progress`,`select`]),qr=new Set([`disabled`,`always`,`never`,`file.isDir`,`file.isFile`,`session.isRunning`,`message.hasSelection`]),Jr=[`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`],Yr=Jr.map(e=>({slot:e,cardinality:`list`}));function Xr(e){return Yr.find(t=>t.slot===e)?.cardinality??`list`}function Zr(e,t){if(t===`list`)return{entries:[...e],conflicts:[]};let n=e.findIndex(e=>!e.hidden);if(n<0)return{entries:[...e],conflicts:[]};let r=e.filter((e,t)=>t!==n&&!e.hidden);return{entries:e.map((e,t)=>t===n||e.hidden?e:{...e,hidden:!0}),winner:e[n],conflicts:r}}var Qr=[{id:`host:brand`,slot:`topbar.primary`,labelKey:`brand`,kind:`badge`,order:1,group:`brand`},{id:`host:open-project`,slot:`topbar.primary`,labelKey:`openProject`,icon:`folder`,kind:`action`,order:3,group:`primary`},{id:`host:history`,slot:`topbar.primary`,labelKey:`openHistory`,icon:`menu`,kind:`action`,order:0,group:`panels`},{id:`host:files`,slot:`topbar.primary`,labelKey:`openFiles`,icon:`folder`,kind:`action`,order:97,group:`panels`,align:`end`},{id:`host:new-chat`,slot:`topbar.primary`,labelKey:`newChat`,icon:`plus`,kind:`action`,order:96,group:`primary`,align:`end`},{id:`host:new-ephemeral-chat`,slot:`topbar.primary`,labelKey:`newChatEphemeral`,icon:`chat`,kind:`action`,order:96.5,group:`primary`,align:`end`},{id:`host:chat`,slot:`topbar.primary`,labelKey:`chat`,icon:`chat`,kind:`view`,view:`chat`,order:20,group:`views`,align:`end`},{id:`host:terminal`,slot:`topbar.primary`,labelKey:`terminal`,icon:`terminal`,kind:`view`,view:`terminal`,order:21,group:`views`,align:`end`},{id:`host:git`,slot:`topbar.primary`,labelKey:`scmTab`,icon:`git`,kind:`view`,view:`git`,order:22,group:`views`,align:`end`},{id:`host:plugins`,slot:`topbar.primary`,labelKey:`pluginMenuTitle`,icon:`🧩`,kind:`action`,order:24,group:`views`,align:`end`},{id:`host:search`,slot:`topbar.primary`,labelKey:`searchGlobal`,icon:`search`,kind:`action`,order:40,group:`tools`,align:`end`},{id:`host:browser`,slot:`topbar.primary`,labelKey:`browserControl`,icon:`browser`,kind:`action`,order:41,group:`tools`,align:`end`,hidden:!0},{id:`host:tasks`,slot:`topbar.primary`,labelKey:`bgTasks`,icon:`layers`,kind:`action`,order:42,group:`tools`,align:`end`},{id:`host:settings`,slot:`topbar.primary`,labelKey:`settingsTitle`,icon:`settings`,kind:`action`,order:60,group:`system`,align:`end`},{id:`host:sound`,slot:`topbar.primary`,labelKey:`sound`,icon:`sound`,kind:`action`,order:70,group:`system`,hidden:!0,align:`end`},{id:`host:language`,slot:`topbar.primary`,labelKey:`language`,icon:`globe`,kind:`action`,order:80,group:`system`,hidden:!0,align:`end`},{id:`host:theme`,slot:`topbar.primary`,labelKey:`theme`,icon:`sun`,kind:`action`,order:82,group:`system`,hidden:!0,align:`end`},{id:`host:update`,slot:`topbar.primary`,labelKey:`update`,icon:`download`,kind:`action`,order:90,group:`system`,align:`end`,hidden:!0},{id:`host:github`,slot:`topbar.primary`,labelKey:`githubRepo`,icon:`github`,kind:`action`,order:200,group:`system`,align:`end`,hidden:!0},{id:`host:conn`,slot:`bottombar`,labelKey:`connected`,icon:`dot`,kind:`badge`,order:5,group:`status`},{id:`host:engine`,slot:`bottombar`,labelKey:`engineBadge`,icon:`cpu`,kind:`badge`,order:6,group:`status`},{id:`host:ctx`,slot:`bottombar`,labelKey:`context`,icon:`gauge`,kind:`badge`,order:10,group:`usage`},{id:`host:cost`,slot:`bottombar`,labelKey:`cumulativeCost`,icon:`coins`,kind:`badge`,order:11,group:`usage`},{id:`host:cache`,slot:`bottombar`,labelKey:`cacheHit`,icon:`database`,kind:`badge`,order:12,group:`usage`},{id:`host:msg-count`,slot:`bottombar`,labelKey:`messages`,icon:`message`,kind:`badge`,order:13,group:`usage`},{id:`host:plugin-status`,slot:`bottombar`,labelKey:`pluginStatus`,icon:`activity`,kind:`badge`,order:14,group:`status`},{id:`host:working`,slot:`bottombar`,labelKey:`working`,icon:`activity`,kind:`badge`,order:15,group:`status`},{id:`host:host-metrics`,slot:`bottombar`,labelKey:`hostResources`,icon:`cpu`,kind:`badge`,order:19,group:`host`,align:`end`},{id:`host:cwd`,slot:`bottombar`,labelKey:`cwdTip`,icon:`folder`,kind:`action`,order:20,group:`context`,align:`end`},{id:`host:msg-reask`,slot:`message.actions`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,order:9},{id:`host:msg-edit-reask`,slot:`message.actions`,labelKey:`editReask`,icon:`edit`,kind:`action`,order:10},{id:`host:msg-fork`,slot:`message.actions`,labelKey:`forkSession`,icon:`branch`,kind:`action`,order:15},{id:`host:msg-rollback`,slot:`message.actions`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,order:16},{id:`host:msg-copy`,slot:`message.actions`,labelKey:`copyMessage`,icon:`copy`,kind:`action`,order:20},{id:`host:msg-copy-text`,slot:`message.actions`,labelKey:`copyText`,icon:`text`,kind:`action`,order:21},{id:`host:msg-copy-markdown`,slot:`message.actions`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,order:22},{id:`host:msg-copy-image`,slot:`message.actions`,labelKey:`copyImage`,icon:`image`,kind:`action`,order:23},{id:`host:msg-speak`,slot:`message.actions`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,order:24},{id:`host:composer-upload`,slot:`composer.actions`,labelKey:`uploadFile`,icon:`upload`,kind:`action`,order:10,align:`start`},{id:`host:composer-templates`,slot:`composer.actions`,labelKey:`tpl.openPicker`,icon:`grid`,kind:`action`,order:110,align:`start`},{id:`host:composer-model`,slot:`composer.actions`,labelKey:`selectModel`,icon:`cpu`,kind:`action`,order:120,align:`start`},{id:`host:composer-thinking`,slot:`composer.actions`,labelKey:`thinkingLevel`,icon:`zap`,kind:`action`,order:130,align:`start`},{id:`host:composer-dsh-perm`,slot:`composer.actions`,labelKey:`dshPerm`,icon:`lock`,kind:`action`,order:140,align:`start`},{id:`host:composer-dsh-preset`,slot:`composer.actions`,labelKey:`dshPreset`,icon:`layers`,kind:`action`,order:150,align:`start`},{id:`host:composer-send`,slot:`composer.actions`,labelKey:`sendTip`,icon:`send`,kind:`action`,order:200,align:`end`},{id:`host:fp-md`,slot:`file.preview.toolbar`,labelKey:`showMarkdownPreview`,icon:`eye`,kind:`action`,order:10},{id:`host:fp-html`,slot:`file.preview.toolbar`,labelKey:`showHtmlPreview`,icon:`code`,kind:`action`,order:20},{id:`host:fp-edit`,slot:`file.preview.toolbar`,labelKey:`editFile`,icon:`edit`,kind:`action`,order:30},{id:`host:fp-wrap`,slot:`file.preview.toolbar`,labelKey:`enableWrap`,icon:`wrap`,kind:`action`,order:40},{id:`host:fp-zoom`,slot:`file.preview.toolbar`,labelKey:`zoomIn`,icon:`zoom`,kind:`action`,order:50},{id:`host:fp-ref`,slot:`file.preview.toolbar`,labelKey:`referenceTip`,icon:`link`,kind:`action`,order:70},{id:`host:fp-full`,slot:`file.preview.toolbar`,labelKey:`fullscreen`,icon:`maximize`,kind:`action`,order:80},{id:`host:fp-close`,slot:`file.preview.toolbar`,labelKey:`close`,icon:`x`,kind:`action`,order:90},{id:`host:goal-pill`,slot:`goalbar.actions`,labelKey:`goalBarTitle`,icon:`target`,kind:`action`,order:5},{id:`host:goal-set`,slot:`goalbar.actions`,labelKey:`goalBarSet`,icon:`check`,kind:`action`,order:10},{id:`host:goal-wizard`,slot:`goalbar.actions`,labelKey:`goalWizardBtn`,icon:`search`,kind:`action`,order:20},{id:`host:goal-lock`,slot:`goalbar.actions`,labelKey:`goalBarLocked`,icon:`lock`,kind:`action`,order:30},{id:`host:goal-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-ref`,slot:`contextmenu.file`,labelKey:`referenceTip`,icon:`link`,kind:`action`,context:`file`,order:32,group:`chat`},{id:`host:file-attach-folder`,slot:`contextmenu.file`,labelKey:`linkFolderTip`,icon:`link`,kind:`action`,context:`file`,order:33,group:`chat`},{id:`host:file-rename`,slot:`contextmenu.file`,labelKey:`fileRename`,icon:`edit`,kind:`action`,context:`file`,order:41,group:`edit`},{id:`host:file-duplicate`,slot:`contextmenu.file`,labelKey:`fileDuplicate`,icon:`copy`,kind:`action`,context:`file`,order:42,group:`edit`},{id:`host:file-cut`,slot:`contextmenu.file`,labelKey:`fileCut`,icon:`cut`,kind:`action`,context:`file`,order:43,group:`edit`},{id:`host:file-copy`,slot:`contextmenu.file`,labelKey:`fileCopyEntry`,icon:`copy`,kind:`action`,context:`file`,order:44,group:`edit`},{id:`host:file-copy-name`,slot:`contextmenu.file`,labelKey:`copyName`,icon:`copy`,kind:`action`,context:`file`,order:51,group:`clipboard`},{id:`host:file-copy-path`,slot:`contextmenu.file`,labelKey:`copyPath`,icon:`copy`,kind:`action`,context:`file`,order:52,group:`clipboard`},{id:`host:file-copy-rel`,slot:`contextmenu.file`,labelKey:`fileCopyRelPath`,icon:`copy`,kind:`action`,context:`file`,order:53,group:`clipboard`},{id:`host:file-refresh`,slot:`contextmenu.file`,labelKey:`fileRefresh`,icon:`refresh`,kind:`action`,context:`file`,order:54,group:`clipboard`},{id:`host:file-delete`,slot:`contextmenu.file`,labelKey:`fileDelete`,icon:`trash`,kind:`action`,context:`file`,order:61,group:`danger`},{id:`host:msg-ctx-copy-markdown`,slot:`contextmenu.message`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,context:`message`,order:10,group:`copy`},{id:`host:msg-ctx-copy-text`,slot:`contextmenu.message`,labelKey:`copyText`,icon:`text`,kind:`action`,context:`message`,order:11,group:`copy`},{id:`host:msg-ctx-copy-image`,slot:`contextmenu.message`,labelKey:`copyImage`,icon:`image`,kind:`action`,context:`message`,order:12,group:`copy`},{id:`host:msg-ctx-reask`,slot:`contextmenu.message`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,context:`message`,order:19,group:`action`},{id:`host:msg-ctx-edit-reask`,slot:`contextmenu.message`,labelKey:`editReask`,icon:`edit`,kind:`action`,context:`message`,order:20,group:`action`},{id:`host:msg-ctx-fork`,slot:`contextmenu.message`,labelKey:`forkSession`,icon:`branch`,kind:`action`,context:`message`,order:21,group:`action`},{id:`host:msg-ctx-rollback`,slot:`contextmenu.message`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,context:`message`,order:22,group:`action`},{id:`host:msg-ctx-speak`,slot:`contextmenu.message`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,context:`message`,order:23,group:`action`},{id:`host:tool-info`,slot:`contextmenu.toolcall`,labelKey:`toolInfoMenuLabel`,icon:`info`,kind:`action`,context:`toolcall`,order:10}],$r=new Set([`host:lp-projects`,`host:lp-running`,`host:lp-history`]),ei=`__view`,ti=new Set([`host:settings`,`host:history`,`host:files`]),ni=new Set([`host:history`,`host:files`]);function ri(e){return`${e}:${ei}`}function ii(e){return e.source.startsWith(`plugin:`)?e.id===ri(e.source.slice(7)):!1}function ai(e,t,n){let r=ri(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 oi(e,t){let n=t.map(ri),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var si=`host:brand`,ci=[`host:brand-logo`,`host:brand-name`];function li(e){if(!((e.hidden??[]).some(e=>ci.includes(e))||(e.shown??[]).some(e=>ci.includes(e))||(e.order??[]).some(e=>ci.includes(e))||ci.some(t=>e.align?.[t]!==void 0)||ci.some(t=>e.groups?.[t]!==void 0)||ci.some(t=>e.labels?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=ci.includes(n)?si: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))ci.includes(t)||(n[t]=r);if(n[`host:brand`]===void 0){let r=t?e[ci[0]]??e[ci[1]]:e[ci[1]]??e[ci[0]];r!==void 0&&(n[si]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))ci.includes(n)||(t[n]=r);if(t[`host:brand`]===void 0){let n=e[ci[0]]??e[ci[1]];n!==void 0&&(t[si]=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 ui(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:ei,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 di(e){return typeof e==`string`&&Jr.includes(e)}function fi(e,t){return t?e.label:e.labelEn??e.label}function pi(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function mi(e,t,n,r,i){let a=`${e}#${r.id}`,o=hi(a,t,n,r.children,i),s=pi(r,i),c=gi(r.options,i);return{id:a,slot:t,source:n,label:fi(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 hi(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:mi(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 gi(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 _i(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function vi(e,t,n,r,i,a){let o=hi(e,t,n,r.children,i),s=pi(r,i),c=_i(r.progress),l=gi(r.options,i);return{id:e,slot:t,source:n,label:fi(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 yi(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 bi(e){let t=e.filter(e=>ii(e));if(t.length===0)return e;let n=e.filter(e=>!ii(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 xi(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=li(t.layout??{}),a=e=>{t.diagnostics?.push({level:e.level??`warn`,...e})},o=new Map,s=0;for(let e of Qr)o.set(e.id,{id:e.id,slot:e.slot,source:`host`,label:t.t(e.labelKey),labelKey:e.labelKey,...e.icon?{icon:e.icon}:{},kind:e.kind,...e.view?{view:e.view}:{},...e.group?{group:e.group}:{},order:e.order??100,align:e.align??`start`,hidden:e.hidden??!1,userOverrides:[],arrangedBy:[],seq:s++});for(let t of e){if(r.has(t.id)){a({pluginId:t.id,message:`plugin "${t.id}" is disabled by the user — its ${t.ui?.items?.length??0} UI item(s) are not rendered`});continue}if(t.error){a({level:`error`,pluginId:t.id,message:`plugin "${t.id}" failed to activate (${t.error}) — its UI items are not rendered`});continue}let e=`plugin:${t.id}`;for(let r of t.ui?.items??[]){if(!di(r.slot)){a({pluginId:t.id,entryId:r.id,message:`item "${t.id}:${r.id}" declares unknown slot "${String(r.slot)}" — dropped (valid slots: see docs/architecture-plugins.md)`});continue}if(r.kind&&!Kr.has(r.kind)&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares unknown kind "${r.kind}" — the render layer falls back to a plain button`}),Array.isArray(r.when))for(let e of r.when)qr.has(e)||a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares when:"${e}" which the host does not know — it is ignored (the item still renders)`});else r.when!==void 0&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" has a non-array "when" — ignored`});let i=`${t.id}:${r.id}`,c=o.get(i);c&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item id "${r.id}" is declared more than once — the later declaration wins (order/visibility are inherited from the first)`}),o.set(i,vi(i,r.slot,e,r,n,c?.seq??s++))}}for(let t of e)if(!(t.error||r.has(t.id)))for(let e of t.ui?.arrange??[]){let n=o.get(e.id);Ci(o,e,t.id),n||a({pluginId:t.id,entryId:e.id,message:`arrange target "${e.id}" does not exist — op ignored (is the providing plugin installed / not disabled?)`})}let c=new Map,l=(e,t)=>{let n=c.get(e)??[];n.includes(t)||n.push(t),c.set(e,n)};for(let e of i.hidden??[]){let t=o.get(e);t&&(t.hidden=!0,l(e,`hidden`))}for(let e of i.shown??[]){let t=o.get(e);t&&(t.hidden=!1,l(e,`hidden`))}for(let[e,t]of Object.entries(i.groups??{})){let n=o.get(e);n&&(n.group=t,l(e,`group`))}for(let[e,t]of Object.entries(i.align??{})){let n=o.get(e);!n||t!==`start`&&t!==`center`&&t!==`end`||(n.align=t,l(e,`align`))}for(let[e,t]of Object.entries(i.labels??{})){let n=o.get(e);n&&(n.label=t,l(e,`label`))}for(let e of ti){let t=o.get(e);t&&(t.slot=`topbar.primary`,t.hidden=!1)}let u=new Map;(i.order??[]).forEach((e,t)=>{o.has(e)&&(u.has(e)||u.set(e,t),l(e,`order`))});let d=new Map;for(let e of Jr)d.set(e,[]);for(let e of o.values())d.get(e.slot)?.push(e);let f={};for(let e of Jr){let t=yi(d.get(e)??[],u),n=Zr(e===`topbar.primary`?bi(t):t,Xr(e));if(n.winner&&n.conflicts.length>0)for(let t of n.conflicts)a({level:`error`,pluginId:t.source.startsWith(`plugin:`)?t.source.slice(7):void 0,entryId:t.id,slot:e,message:`slot "${e}" is single-cardinality; "${n.winner.id}" won and "${t.id}" was hidden`});f[e]=n.entries.map(e=>Si(e,c.get(e.id)??[]))}return f}function Si(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function Ci(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&&di(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 wi(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 Ti(e,t){let n=e??{},r={},i=t===`host:brand`?[t,...ci]:[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=Di(n.groups,t),l=Di(n.labels,t),u=Di(n.align,t);if(t===`host:brand`)for(let e of ci)c=Di(c,e),l=Di(l,e),u=Di(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 Ei(){return{}}function Di(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 Oi=new Set([`host:files`]);function ki(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 Ai(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 ji=null,Mi=new Set;function Ni(){for(let e of Mi)e()}function Pi(e){ji={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}:{}},Ni()}function Fi(){ji!==null&&(ji=null,Ni())}function Ii(e){return Mi.add(e),()=>{Mi.delete(e)}}function Li(){return ji}function Ri(){return(0,m.useSyncExternalStore)(Ii,Li,Li)}function zi(e){return Number.isFinite(e)?e:0}function Bi(e,t,n,r,i,a){let o=Math.max(0,zi(n)),s=Math.max(0,zi(r)),c=Math.max(8,zi(i)-o-8),l=Math.max(8,zi(a)-s-8);return{x:Math.min(Math.max(8,zi(e)),c),y:Math.min(Math.max(8,zi(t)),l)}}function Vi(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 Hi(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 Ui(e,t){return!e||Hi(e.when,t)}function Wi(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 Gi(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 Ki(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 qi(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!Ui(e,t)}function Ji(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,qi(e[o],r))return o;return-1}var Yi={menu:`☰`,folder:`📁`,plus:`+`,chat:`💬`,terminal:`▙`,git:`⎇`,search:`🔍`,browser:`🌐`,layers:`🗂`,settings:`⚙`,sound:`🔊`,globe:`🌍`,sun:`☀`,download:`⤓`,github:`⌗`,x:`✕`,upload:`⬆`,copy:`⧉`,cut:`✂`,paste:`📋`,trash:`🗑`,file:`📄`,open:`↗`,refresh:`⟳`,link:`🔗`,edit:`✎`,dot:`●`,info:`ⓘ`,cpu:`▣`,gauge:`▤`,coins:`◉`,database:`▥`,message:`✉`,activity:`〜`,markdown:`📄`,text:`≡`,image:`🖼`,branch:`⚚`,undo:`↺`,volume:`🔊`};function Xi(e){let t=(e??``).trim();return t?Yi[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var Zi={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},Qi=new Set;function $i(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function ea(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&&$i(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&$i(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function ta(e){let t={...Zi,...e};if(!ea(Zi,t)){Zi=t;for(let e of Qi)e()}}function na(e){return Qi.add(e),()=>{Qi.delete(e)}}function ra(){return Zi}function ia(){return(0,m.useSyncExternalStore)(na,ra,ra)}function aa(e){return(0,m.useSyncExternalStore)(na,()=>Zi[e],()=>Zi[e])}function oa(){return aa(`engine`)===`dsh`}function sa(){return aa(`managed`)}function ca(){return aa(`service`)}var la=null;function ua(e){la=e}var $=e=>la?la(e):!1,da=`@root`,fa=e=>e.endsWith(`/`)?e:e+`/`;function pa(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function ma(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var ha=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)?da:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function ga({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z(),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(``),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(-1),x=(0,m.useRef)(null),S=(0,m.useRef)(null),C=n.filter(e=>e.type===`dir`);if((0,m.useEffect)(()=>{if(e){let e=(t||``).replace(/\\/g,`/`);l(e),d(e),p(!1),g(``),v(null),b(-1)}},[e,t]),(0,m.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{x.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,m.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(f?(p(!1),g(``),v(null)):i())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,f,i]),(0,m.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{$({type:`complete_path`,path:fa(c)})},60);return()=>clearTimeout(t)},[c,e]),(0,m.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(!ma(e)){v(s(`invalidProjectName`));return}o(pa(c,e)),p(!1),g(``),v(null),i()},E=e=>{if(e.key===`Escape`)e.stopPropagation(),f?(p(!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=ha(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)(Oe,{}),(0,X.jsx)(`span`,{children:c===`@root`?s(`computer`):c})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:c===da,title:s(`computer`),onClick:()=>{l(da),d(da),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.jsx)(`button`,{type:`button`,className:`cwd-close`,title:s(`close`),"aria-label":s(`close`),onClick:i,children:(0,X.jsx)(N,{})})]}),(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===da,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)(Oe,{}),(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:[f?(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(),p(!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:()=>{p(!1),g(``),v(null)},children:s(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>p(!0),children:[`+ `,s(`newProject`)]}),_&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:_})]})]})]})}function _a(e){return D({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 va(e){return D({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 ya(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 ba(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,m.useRef)(null),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(i);(0,m.useLayoutEffect)(()=>{p.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=ya(i,{width:n.width,height:n.height},{width:window.innerWidth,height:window.innerHeight},{align:o,side:s,gap:c,margin:l});f(e=>e?.x===a.x&&e?.y===a.y?e:a)};return(0,m.useLayoutEffect)(()=>{t?_():f(null)},[t,n,r,o,s,c,l]),yt(()=>{p.current()},t),(0,m.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||g()?.contains(e)||a?.(e)),n=t=>{e(t.target)||p.current()};return document.addEventListener(`mousedown`,n,!0),window.addEventListener(`resize`,_,!0),window.addEventListener(`scroll`,_,!0),()=>{document.removeEventListener(`mousedown`,n,!0),window.removeEventListener(`resize`,_,!0),window.removeEventListener(`scroll`,_,!0)}},[t,n,r]),{panelRef:u,pos:d,style:{position:`fixed`,left:d?.x??-9999,top:d?.y??-9999,visibility:d?`visible`:`hidden`},measure:_}}function xa({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=pn(),{panelRef:d,style:f,measure:p}=ba({anchor:e,anchorEl:t,onClose:l}),[,h]=(0,m.useState)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null),y=(0,m.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,m.useLayoutEffect)(()=>{p()},[y,p]);let b=(e,t)=>{let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=r+t;if(r<0||i<0||i>=n.length)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))},x=(e,t)=>{if(!e||e===t)return;let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=n.indexOf(t);if(r<0||i<0)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))};return(0,k.createPortal)((0,X.jsxs)(`div`,{ref:d,className:`pm-panel`,role:`menu`,"aria-label":u(`pluginMenuTitle`),style:f,children:[(0,X.jsxs)(`div`,{className:`pm-head`,"aria-hidden":`true`,children:[(0,X.jsx)(Qe,{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)(ge,{"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)(Gr,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(Qe,{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)(va,{"aria-hidden":!0}):(0,X.jsx)(_a,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(W,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function Sa({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=pn(),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(``);async function d(){try{let e=await fetch(Yt(Gt(`/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,m.useEffect)(()=>{d()},[]);async function f(e){u(e),c(``);try{let t=await fetch(Yt(Gt(`/api/locales/${e}/install`)),{method:`POST`});if(!t.ok){let e=`HTTP ${t.status}`;try{e=(await t.json()).error??e}catch{}throw Error(e)}await i(),await d()}catch(e){c(t(`localeInstallFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(``)}}async function p(e){u(e),c(``);try{let t=await fetch(Yt(Gt(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);an(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)(Ee,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(N,{})})]}),s&&(0,X.jsx)(`div`,{className:`bg-task-empty`,children:s}),a===null&&!s?(0,X.jsx)(`div`,{className:`bg-task-empty`,children:t(`loading`)}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:(a??[]).map(e=>{let n=l===e.code;return(0,X.jsxs)(`li`,{className:`bg-task-item`,children:[(0,X.jsxs)(`div`,{className:`bg-task-info`,children:[(0,X.jsxs)(`div`,{className:`bg-task-line1`,children:[(0,X.jsx)(`span`,{className:`bg-task-port`,children:e.nativeName}),e.installed&&e.version&&(0,X.jsxs)(`span`,{className:`bg-task-name`,children:[`v`,e.version]})]}),(0,X.jsxs)(`div`,{className:`bg-task-line2`,children:[(0,X.jsx)(`span`,{children:e.code}),e.installed?(0,X.jsxs)(`span`,{children:[t(`localeInstalled`),` · `,t(`localeRemoveHint`)]}):(0,X.jsx)(`span`,{children:t(`localeGetMore`)})]})]}),e.installed?(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,disabled:n,title:t(`localeRemove`),onClick:()=>void p(e.code),children:[(0,X.jsx)(R,{}),(0,X.jsx)(`span`,{children:t(n?`localeRemoving`:`localeRemove`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:n,title:t(`localeInstall`),onClick:()=>void f(e.code),children:[(0,X.jsx)(Ie,{}),(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 Ca=`xing-shuyin/pi-web-ui`,wa={state:`idle`,version:null,percent:0,message:null};function Ta(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Ea(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:Ta(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 Da(e){if(!vn(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 Oa(e){return e instanceof Error?e.message:String(e)}function ka(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${Ca}/releases/tag/v${t}`:`https://github.com/${Ca}/releases/latest`}function Aa(){let[e]=(0,m.useState)(()=>Da()),[t,n]=(0,m.useState)(wa);(0,m.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>Ea(t,e)))},[e]);let r=(0,m.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:Oa(e)}))))},[e]),i=(0,m.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:Oa(e)}))))},[e]),a=(0,m.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:Oa(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}var ja={name:`@earendil-works/pi-coding-agent`,kind:`pi-core`,current:``,latest:null,upToDate:!1};function Ma({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=ba({open:t,anchor:e,onClose:n});return(0,m.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,k.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Na(){let[e,t]=(0,m.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,m.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 Pa({chat:e,terminal:t,view:n,plugins:r,uiPrimary:i,uiOverflow:a,uiContextTopbar:o,onUiAction:s,onViewChange:c,onOpenPanel:l,onOpenSettings:u,onManagePlugins:d,onOpenBgTasks:f,onOpenGlobalSearch:p,sound:h,onSoundChange:g,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x}){let{locale:S,setLocale:C,t:w,packs:T}=pn(),[E,D]=(0,m.useState)(!1),[O,k]=(0,m.useState)(!1),[A,ee]=(0,m.useState)(null),j=aa(`cwd`),M=aa(`workspaceRoots`),N=oa(),F=(0,m.useRef)(null),I=t=>!e.tabs||t===`chat`||e.tabs.includes(t),L=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!ii(e)),R=new Set([...i??[],...a??[]].filter(e=>ii(e)&&!e.hidden).map(e=>e.source.slice(7))),te=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),B=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),ne=i===void 0?[`host:history`,`host:brand`,`host:open-project`,`host:chat`,`host:terminal`,`host:git`,`host:plugins`,`host:search`,`host:browser`,`host:tasks`,`host:settings`,`host:sound`,`host:language`,`host:theme`,`host:update`,`host:github`,`host:new-chat`,`host:new-ephemeral-chat`,`host:files`].map(e=>({id:e,entry:null})):i.map(e=>({id:e.id,entry:e})),H=(I(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!ne.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:[]})),U=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`}),Vn(),!0;case`host:new-ephemeral-chat`:return c(`chat`),$({type:`new_chat`,ephemeral:!0}),Vn(),!0;case`host:open-project`:return k(!0),!0;case`host:search`:return p(),!0;case`host:tasks`:return f(),!0;case`host:settings`:return u(),!0;case`host:plugins`:return ee(F.current?{rect:F.current.getBoundingClientRect(),el:F.current}:null),!0;default:return!1}},G=(e,t,n)=>{e.preventDefault(),Pi({x:e.clientX,y:e.clientY,slot:`contextmenu.topbar`,target:{id:t,label:n},entries:o??[]})},{appVersion:ie}=ia(),ae=sa(),oe=ca(),[ce,le]=(0,m.useState)(!1);(0,m.useEffect)(()=>{ce&&e.status===`open`&&le(!1)},[ce,e.status]);let[ue,de]=(0,m.useState)(!1),[fe,pe]=(0,m.useState)(!1),[me,he]=(0,m.useState)(!1),[_e,ve]=(0,m.useState)(!1),q=vn(),ye=Aa(),[J,be]=(0,m.useState)(!1),Se=()=>{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:dt(),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`)},Ce=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:lt(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:dt(),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??[],Te=e.updatesSdk,Ae=Te&&Te.newerInstalled?{running:Te.running,installed:Te.newerInstalled}:null,je=Te?.bundledInUse===!0,Me=we.find(e=>e.kind===`pi-core`&&!e.error),Ne=je&&(!Me||!Me.upToDate),Pe=Ne&&!Me,Fe=we.filter(e=>!e.upToDate&&!e.error).length,Le=we.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Re=e=>e.kind===`git-extension`&&e.source?e.source:e.name,ze=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,Be=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},Ve=(e,t)=>{if(!t)return Be(e);let n=Be(e),r=Be(t);return n===r?n:`${n} → ${r}`},He=()=>(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=>{let t=Ae!=null&&e.kind===`pi-core`,n=!e.error&&(!e.upToDate||t);return(0,X.jsxs)(`li`,{className:`dd-all-item${e.error?` err`:n?` warn`:``}`,children:[e.kind!==`webui`&&!e.upToDate&&!e.error&&(0,X.jsx)(`button`,{type:`button`,className:`dd-update-btn`,onClick:()=>Ce([e],w(`updatePkgTabTitle`,{name:e.name})),children:w(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:ze(e),children:Re(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`):e.kind===`plugin`?w(`kindPlugin`):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?Be(e.current):Ve(e.current,e.latest):e.kind===`plugin`?e.upToDate?e.current.startsWith(`v`)?e.current:Be(e.current):Ve(e.current,e.latest):e.upToDate?`v${e.current}`:(0,X.jsxs)(X.Fragment,{children:[`v`,e.current,` → v`,e.latest]})}),t&&!e.error&&(0,X.jsx)(`span`,{className:`dd-split-run`,children:w(`piCoreSplitRun`,{running:Ae.running})})]})]},`${e.kind}:${e.name}`)})}),Ae&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`piSdkSplitNote`,{running:Ae.running,installed:Ae.installed})}),Ne&&(0,X.jsx)(`div`,{className:`dd-note`,children:w(`piSdkBundledNote`,{running:Te.running})}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[Pe&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce([ja],w(`installGlobalEngineTabTitle`)),children:w(`installGlobalEngineBtn`)}),Le.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce(Le,w(`updateAllTabTitle`)),children:w(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:Le.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:w(`updatesAllRefresh`)})]})]}),Ue=()=>{let t=ka(e.update?.latest??ye.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:w(`updateDesktopManual`)});if(!ye.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopNoBridge`)}),n]});switch(ye.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:ye.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ye.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:ye.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:()=>ye.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:ye.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>ye.check(),children:w(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ye.check(),children:w(`updateDesktopCheck`)}),n]})}},We=()=>(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&&!q&&(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&q&&(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&&!q&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:Se,children:w(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&q&&Ue(),oe&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:ce,title:w(`restartServiceTip`,{name:oe.name}),onClick:()=>{ce||(le(!0),$({type:`restart_service`}))},children:w(ce?`restartingService`:`restartService`)})]})]}),Ge=Na(),Ke={"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)(ke,{}),(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)(ge,{})}):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)(Oe,{}),(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`}),Vn()},children:[(0,X.jsx)(se,{}),(0,X.jsx)(`span`,{children:w(`newChat`)})]}):null,"host:new-ephemeral-chat":N?null:(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat ephemeral-chat-btn`,"data-tip":w(`newChatEphemeralTip`),onClick:()=>{c(`chat`),$({type:`new_chat`,ephemeral:!0}),Vn()},children:[(0,X.jsx)(ct,{}),(0,X.jsx)(`span`,{children:w(`newChatEphemeral`)})]}),"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)(K,{}),(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)(z,{}),(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)(De,{}),(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;ee(e=>e?.el===t?null:{rect:t.getBoundingClientRect(),el:t})},children:[(0,X.jsx)(Qe,{"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:p,children:[(0,X.jsx)(re,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(Wn,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":w(`bgTasksTip`),onClick:f,children:[(0,X.jsx)(xe,{}),(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)(W,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`settings`)})]}),"host:sound":(0,X.jsxs)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(P,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`sound`)})]}),tip:w(`sound`),open:ue,onOpenChange:de,children:[(0,X.jsx)(hn,{settings:h,onChange:g,onPreview:_}),(0,X.jsx)(Ir,{})]}),"host:language":(0,X.jsxs)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ee,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:on(S)})]}),tip:w(`language`),open:fe,onOpenChange:pe,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`language`)}),T.map(e=>(0,X.jsx)(St,{active:S===e.code,onClick:()=>{C(e.code),pe(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(St,{onClick:()=>{pe(!1),be(!0)},children:[(0,X.jsx)(Ie,{}),` `,w(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`theme`)})]}),tip:w(`theme`),open:me,onOpenChange:e=>{he(e),e&&v.length===0&&x()},children:(()=>{let e=v.filter(e=>e.group===`classic`),t=v.filter(e=>e.group!==`classic`),n=e=>{let t=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)(St,{active:y===e.id,onClick:()=>{b(e.id),he(!1)},children:n(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:e.length>0?w(`themeGroupBuiltin`):w(`theme`)}),(0,X.jsx)(St,{active:y===null,onClick:()=>{b(null),he(!1)},children:w(`themeDefault`)}),t.map(e=>(0,X.jsx)(St,{active:y===e.id,onClick:()=>{b(e.id),he(!1)},children:n(e)},e.id))]})})()}),"host:update":ae?(0,X.jsxs)(`span`,{className:`chip`,"data-tip":w(`updatesManaged`),children:[(0,X.jsx)(Ie,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,ie??e.update?.current??`…`]})]}):(0,X.jsxs)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ie,{}),(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??``})}),Fe>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:w(`updatesAllBadge`,{n:Fe})})]}),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`)}),We(),He()]}),"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)(Y,{})})},qe=new Set([`host:search`,`host:tasks`,`host:settings`,`host:plugins`]),Je=new Set([`host:sound`,`host:language`,`host:theme`,`host:update`,`host:browser`]),Ye=e=>qe.has(e)&&!I(e.slice(5)),Xe=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=>G(t,e.id,e.label),children:[(0,X.jsx)(Gr,{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=>G(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=>G(t,e.id,e.label),children:[(0,X.jsx)(Gr,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},Ze=[];for(let e of ne){if(e.entry?.hidden||Ye(e.id))continue;let t=e.id.startsWith(`host:`)?Ke[e.id]??null:e.entry?Xe(e.entry):null;t&&Ze.push({id:e.id,entry:e.entry,node:t})}for(let e of H){let t=Xe(e);t&&Ze.push({id:e.id,entry:e,node:t})}let $e=e=>e.entry?.align??`start`,[et,tt]=(0,m.useState)(()=>new Set),nt=(0,m.useRef)(null),rt=(0,m.useRef)(new Map),it=Ze.filter(e=>!et.has(e.id)),at=Ge?it.filter(e=>Oi.has(e.id)):[],ot=Ge?it.filter(e=>!Oi.has(e.id)):it,st=Ge?Ze.filter(e=>!Oi.has(e.id)):Ze,ut=[...st.filter(e=>$e(e)===`start`),...st.filter(e=>$e(e)===`center`),...st.filter(e=>$e(e)===`end`)],ft=ut.filter(e=>!et.has(e.id)),pt=(0,m.useRef)(ut),mt=(0,m.useRef)(ft);(0,m.useLayoutEffect)(()=>{pt.current=ut,mt.current=ft});let ht=()=>{let e=nt.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`)),n=mt.current;t.length===n.length&&n.forEach((e,n)=>rt.current.set(e.id,t[n].offsetWidth));let r=Number.parseFloat(getComputedStyle(e).columnGap)||0,i=pt.current,a=Ai(i.map(e=>({id:e.id,width:e.entry?rt.current.get(e.id)??0:0})),e.clientWidth,r,0,ti);tt(e=>e.size===a.size&&[...a].every(t=>e.has(t))?e:a)},gt=`${it.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${Ge?`m`:`d`}`;(0,m.useLayoutEffect)(ht,[gt]),(0,m.useEffect)(()=>{let e=nt.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>ht());return t.observe(e),()=>t.disconnect()},[gt]);let _t=ot.filter(e=>$e(e)===`start`),vt=ot.filter(e=>$e(e)===`center`),yt=ot.filter(e=>$e(e)===`end`),bt=Ze.filter(e=>et.has(e.id)&&e.entry).map(e=>e.entry),Ct=new Map;[...i??[],...a??[]].forEach((e,t)=>{Ct.has(e.id)||Ct.set(e.id,t)});let wt=ki([...L,...bt],e=>Ct.get(e)??999999),Tt=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${Tt?` no-labels`:``}`,"data-pi-anchor":`topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-flow`,ref:nt,role:`toolbar`,"aria-label":w(`viewSwitch`),children:[_t.map(e=>(0,X.jsx)(m.Fragment,{children:e.node},e.id)),(vt.length>0||yt.length>0)&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),vt.map(e=>(0,X.jsx)(m.Fragment,{children:e.node},e.id)),vt.length>0&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),yt.map(e=>(0,X.jsx)(m.Fragment,{children:e.node},e.id))]}),wt.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)(Ma,{anchorRef:F,open:E,onClose:()=>D(!1),children:wt.map(e=>{let t=e.source===`host`&&Je.has(e.id)?Ke[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(m.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)(Y,{}),(0,X.jsx)(`span`,{children:`GitHub`})]},e.id);if(e.source===`host`){let t=Ke[e.id];if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>D(!1),children:t},e.id)}else{let t=Xe(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),U(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),U(e)||s?.(e)},children:[e.icon&&!/[a-z]/i.test(e.icon)?`${e.icon} `:``,e.label]},e.id)})})]}),at.map(e=>(0,X.jsx)(m.Fragment,{children:e.node},e.id)),J&&(0,X.jsx)(Sa,{onClose:()=>be(!1)}),A&&(0,X.jsx)(xa,{anchorRect:A.rect,anchorEl:A.el,plugins:r,pinnedIds:R,orderedPluginIds:B,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:ai(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:oi(e.settings?.uiLayout,t)}),onOpenView:e=>{ee(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>ee(null)}),O&&(0,X.jsx)(ga,{open:!0,currentCwd:j,pathCompletions:e.pathCompletions??[],workspaceRoots:M,onClose:()=>k(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Fa(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 Ia(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 La(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 Ra(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 za(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 Ba(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 Va=null,Ha=new Set;function Ua(){for(let e of Ha)e()}function Wa(e){let t=(e??``).trim();t&&(Va={name:t,status:`loading`},Ua(),$({type:`get_tool_info`,name:t}))}function Ga(){Va!==null&&(Va=null,Ua())}function Ka(e){Va!==null&&Va.name===e.name&&(Va=Ba(e),Ua())}function qa(e){return Ha.add(e),()=>{Ha.delete(e)}}function Ja(){return Va}function Ya(){return(0,m.useSyncExternalStore)(qa,Ja,Ja)}var Xa=`__piWebUiHost`,Za=e=>new Promise(t=>setTimeout(t,e));async function Qa(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 Za(100)}}var $a=Promise.resolve(),eo=0;function to(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 Za(t)}},i=()=>{try{let t=e.listModels?.()??[];return Array.isArray(t)?[...t]:[]}catch{return[]}},a=e=>{if(!e)return!0;try{return i().some(t=>t&&t.id===e)}catch{return!1}},o=async t=>{t&&(e.send({type:`set_model`,modelId:t}),typeof e.getCurrentModelId==`function`&&await r(()=>e.getCurrentModelId?.()===t))},s=async(t,n)=>{let i=String(n.cwd??``).trim();if(i&&e.getCwd()!==i&&(e.send({type:`set_cwd`,path:i}),await r(()=>e.getCwd()===i)),n.newChat!==!1){let t=e.getConversationId();e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank())}let a=String(n.model??``).trim();a&&await o(a),e.send({type:`prompt`,text:t})};return{version:11,setView(t){let n=String(t??``).trim();n&&e.setView(n)},startChat(t){let n=String(t?.prompt??``).trim();if(!n||!e.isReady())return!1;let r=String(t?.model??``).trim();if(r&&!a(r))return!1;let i=()=>s(n,t??{prompt:n}),o;return o=eo>0?$a.then(i):i(),eo++,$a=o.then(()=>{eo--},()=>{eo--}),o.catch(()=>{}),!0},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>Mo(e)},compose(e){return Hn()?Un({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=oo,i=Array.isArray(t?.folders)?t.folders.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],s=Array.isArray(t?.roots)?t.roots.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],c=String(t?.cwd??``).trim(),l=[...new Set([...i,...s])],u=c||l[0]||``;if(!u)return{ok:!1,error:`openSession 需要 cwd / folders / roots(绝对路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let d=l.filter(e=>e!==u).slice(0,7),f=new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]);for(let t of[u,...d])if(!f.has(t)){if(!(e.confirm&&await e.confirm({path:t}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${t}`};e.grantPath?.(t,n)}if(e.getCwd()!==u&&(e.send({type:`set_cwd`,path:u}),!await r(()=>e.getCwd()===u)))return{ok:!1,error:`切换工作目录失败或超时:${u}`};(d.length>0||e.getWorkspaceRoots().length>0)&&e.send({type:`set_workspace_roots`,roots:d});let p=e.getConversationId()??void 0;if(t?.newChat!==!1){let t=p;e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank()),p=e.getConversationId()??void 0}let m=String(t?.model??``).trim();if(m){if(!a(m))return{ok:!1,error:`未知模型:${m}(先调 models.list() 取可用列表)`};await o(m),p=e.getConversationId()??p}let h=String(t?.prompt??``).trim();return h&&e.send({type:`prompt`,text:h}),{ok:!0,...p?{sessionId:p}:{}}},sessions:{list:()=>e.listSessions(),async open(t){let n=oo,i=String(t??``).trim();if(!i)return{ok:!1,error:`sessions.open 需要一个会话 id(先调 list)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let a=e.listSessions().find(e=>e.id===i);if(!a)return{ok:!1,error:`找不到会话:${i}`};if(a.cwd&&a.cwd!==e.getCwd()){if(!new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]).has(a.cwd)){if(!(e.confirm&&await e.confirm({path:a.cwd}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${a.cwd}`};e.grantPath?.(a.cwd,n)}if(e.send({type:`set_cwd`,path:a.cwd}),!await r(()=>e.getCwd()===a.cwd))return{ok:!1,error:`切换工作目录失败或超时:${a.cwd}`}}let o=e.getConversationId();return a.kind===`running`?e.send({type:`switch_conversation`,id:a.id}):e.send({type:`switch_session`,path:a.id}),await r(()=>e.getConversationId()!==o)?{ok:!0,sessionId:e.getConversationId()??void 0}:{ok:!1,error:`切换会话超时:${a.title}`}}},async reloadCatalog(t,n){let r=String(t??``).trim();if(!r)return{ok:!1,error:`reloadCatalog 需要一个目录来源(http(s) URL 或本地文件路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let i=dt();return new Promise(t=>{let a=setTimeout(()=>{Bo.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));Bo.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 co(io,String(e??``).trim(),t)},onTopbarAction(e,t){return co(io,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(vn())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 Qa(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(uo,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>yo(String(e??``),t)},searchProviders:{register:e=>xo(e),list:()=>So()},composerProviders:{register:e=>wo(e),list:()=>To()},onTheme:e=>Po(e),onLocale:e=>Fo(e),onViewChange:e=>Io(e)}}function no(e){try{let t=window;e?t[Xa]=e:delete t[Xa]}catch{}}var ro=new Map,io=null;async function ao(e,t){let n=io;io=e;try{return await t()}finally{io=n}}var oo=void 0;function so(e,t){let n=oo;oo=e;try{return t()}finally{oo=n}}function co(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=ro.get(r);i||(i=new Set,ro.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&ro.delete(r)}}async function lo(e,t,n,r){let i=i=>{let a=ro.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{so(e,()=>i(n,r?.value,r?.target))}catch(n){console.error(`[plugin:${e}] 顶栏动作 ${t} 抛错:`,n)}return!0};if(i(`${e}:${t}`)||i(t))return!0;if(r?.loadBundle&&await r.loadBundle(e).catch(()=>!1)){let n=Date.now()+Math.max(100,Number(r.waitMs??1500));for(;;){if(i(`${e}:${t}`)||i(t))return!0;if(Date.now()>=n)break;await new Promise(e=>setTimeout(e,100))}}return!1}var uo=`pi-web-ui:toast`,fo=new Map,po=!1;function mo(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 ho(){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 go(e){try{if(ho())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=fo.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function _o(){if(!po)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,go),po=!0}catch{}}function vo(){if(!(fo.size>0||!po))try{window.removeEventListener(`keydown`,go)}catch{}finally{po=!1}}function yo(e,t){if(typeof t!=`function`)return()=>{};let n=mo(e);if(!n)return()=>{};let r=fo.get(n.combo);r||(r=new Set,fo.set(n.combo,r));let i=r;return i.add(t),_o(),()=>{i.delete(t),i.size===0&&fo.delete(n.combo),vo()}}var bo=new Map;function xo(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 bo.set(t,n),()=>{bo.get(t)===n&&bo.delete(t)}}function So(){return[...bo.values()].map(e=>({id:e.id,label:e.label}))}var Co=new Map;function wo(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 Co.set(t,n),()=>{Co.get(t)===n&&Co.delete(t)}}function To(){return[...Co.values()].map(e=>({id:e.id,label:e.label}))}function Eo(e){return Co.get(String(e??``))}function Do(e){return bo.get(String(e??``))}var Oo=new Set,ko=new Set,Ao=new Set,jo=new Set;function Mo(e){return jo.add(e),()=>{jo.delete(e)}}function No(e){for(let t of[...jo])try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function Po(e){return typeof e==`function`?(Oo.add(e),()=>{Oo.delete(e)}):()=>{}}function Fo(e){return typeof e==`function`?(ko.add(e),()=>{ko.delete(e)}):()=>{}}function Io(e){return typeof e==`function`?(Ao.add(e),()=>{Ao.delete(e)}):()=>{}}function Lo(e){let t=String(e??``);for(let e of[...Oo])try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function Ro(e){let t=String(e??``);for(let e of[...ko])try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function zo(e){let t=String(e??``);for(let e of[...Ao])try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var Bo=new Map;function Vo(e){let t=Bo.get(e.requestId);if(t){if(Bo.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 Ho=`modulepreload`,Uo=function(e){return`/`+e},Wo={},Go=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=Uo(t,n),t=s(t),t in Wo)return;Wo[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`:Ho,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)})},Ko=`pi-web-ui:plugin-data`;function qo(e,t){window.dispatchEvent(new CustomEvent(Ko,{detail:{pluginId:e,payload:t}}))}function Jo(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(Ko,t),()=>window.removeEventListener(Ko,t)}var Yo=new Map,Xo=new Set,Zo=new Set,Qo=new Set,$o=new Set,es=-1;function ts(){return[...Yo.values()]}function ns(){let e=ts();for(let t of Zo)t(e)}function rs(){let e=[...Qo];for(let t of $o)t(e)}function is(e){return $o.add(e),e([...Qo]),()=>$o.delete(e)}async function as(e,t){Qo.delete(e.id),ss.set(e.id,(ss.get(e.id)??0)+1),rs();let n=await fs(e,t);return ns(),n}function os(e){return Zo.add(e),e(ts()),()=>Zo.delete(e)}var ss=new Map;function cs(e,t){let n=ss.get(e)??0;return Gt(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function ls(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>ao(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var us=ls(e=>Go(()=>import(e),[]));async function ds(e,t){if(!e.hasClient||e.error)return null;try{return(await us(e.id,cs(e.id,t))).default??null}catch(t){return console.error(`[plugin:${e.id}] 客户端 bundle 加载失败:`,t),null}}async function fs(e,t){try{let n=(await us(e.id,cs(e.id,t))).default;return n&&typeof n.mount==`function`?(Yo.set(e.id,{info:e,module:n}),!0):e.preload?(Xo.add(e.id),!0):(Qo.add(e.id),rs(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return Qo.add(e.id),rs(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function ps(e,t){if(Yo.has(e.id)||Xo.has(e.id))return!0;if(Qo.has(e.id)||!e.hasClient)return!1;let n=await fs(e,t);return ns(),n}async function ms(e,t){t!==es&&(es=t,Yo.clear(),Xo.clear(),Qo.clear(),ss.clear(),rs());let n=new Set(e.map(e=>e.id));for(let e of[...Yo.keys()])n.has(e)||Yo.delete(e);for(let e of[...Xo])n.has(e)||Xo.delete(e);for(let e of[...Qo])n.has(e)||Qo.delete(e);rs(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!Yo.has(e.id)&&!Xo.has(e.id)&&!Qo.has(e.id)).map(e=>fs(e,t))),ns()}function hs(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>Jo((n,r)=>{n===e&&t(r)})}}var gs=[`debug`,`info`,`warn`,`error`];function _s(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function vs(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function ys(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`&&gs.includes(String(e.level)))}var bs=new Map,xs=new Set;function Ss(){for(let e of[...xs])try{e()}catch{}}function Cs(e){return xs.add(e),()=>xs.delete(e)}function ws(e){return(bs.get(e)??[]).map(e=>({...e}))}function Ts(e,t){return ys(t)?(bs.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),Ss(),!0):!1}function Es(){return{flows:[],results:{}}}function Ds(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 Os(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:Ds(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:Ds(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 ks=`pi-web-ui:lang`;function As(){try{return(localStorage.getItem(ks)??``).trim()}catch{return``}}var js=`pi-web-ui:locale`,Ms=2e5,Ns=2e5,Ps=`LIVE_OMIT`,Fs={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 Is(){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>Ns?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 Ls(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 Rs(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 zs(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!==20};case`snapshot`:return{...e,ready:!0,state:t.state,approval:t.state.pendingApproval??null,activeConversationId:t.state.conversationId,liveOutputs:Ls(e.liveOutputs,t.state),toolStatuses:Rs(e.toolStatuses,t.state)};case`snapshot_delta`:{let n=e.state,r=t.msg;if(!n||n.conversationId!==r.conversationId||n.rev!==r.baseRev)return e;let i={...n,...r.state,messages:r.appended.length>0?[...n.messages,...r.appended]:n.messages};return{...e,ready:!0,state:i,approval:i.pendingApproval===void 0?e.approval:i.pendingApproval??null,activeConversationId:i.conversationId,liveOutputs:Ls(e.liveOutputs,i),toolStatuses:Rs(e.toolStatuses,i)}}case`tool_approval`:return{...e,approval:t.approval};case`tool_delta`:{let n=(e.liveOutputs.get(t.toolCallId)?.text??``)+t.delta,r=n.length>Ms?`…[${Ps}:${n.length-Ms}]…\n`+n.slice(n.length-Ms):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:Ra(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=Os({flows:e.providerOAuthFlows,results:e.providerOAuthResults},t.message);return{...e,providerOAuthFlows:n.flows,providerOAuthResults:n.results}}case`fetch_models_result`:return{...e,fetchModelsResult:t.result};case`test_model_connection_result`:return{...e,testModelConnectionResult:t.result};case`enrich_models_progress`:return{...e,enrichModelsProgress:t.progress};case`enrich_models_result`:return{...e,enrichModelsResult:t.result,enrichModelsProgress:null};case`refresh_provider_result`:return{...e,refreshProviderResult:t.result};case`refresh_builtin_result`:return{...e,refreshBuiltinResult:t.result};case`append_builtin_result`:return{...e,appendBuiltinResult:t.result};case`clone_provider_result`:return{...e,cloneProviderResult:t.result};case`install_result`:return{...e,installResult:t.result};case`scm_data`:return{...e,scmData:t.data};case`file_search_result`:return{...e,fileSearch:t.result};case`session_search_result`:return{...e,sessionSearch:t.result};case`scm_changed`:return{...e,scmDirty:e.scmDirty+1};case`path_completions`:return{...e,pathCompletions:t.completions};case`update_status`:return{...e,update:t.status};case`update_status_all`:return{...e,updatesAll:t.items,updatesSdk:t.piSdk??null};case`updates_check_started`:return{...e,updatesAll:null};case`widgets`:return{...e,widgets:t.widgets};case`statuses`:return{...e,statuses:t.statuses};case`dialog`:return{...e,dialog:t.dialog};case`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_updates_check_started`:return{...e,checkingPluginUpdates:!0};case`plugin_updates`:{let n={};for(let e of t.updates)n[e.id]=e;return{...e,pluginUpdates:n,checkingPluginUpdates:!1}}case`plugin_catalog`:return{...e,pluginCatalog:t.entries,pluginCatalogEpoch:t.epoch};case`plugin_grants`:return{...e,pluginGrants:t.grants};case`plugin_permissions`:return{...e,pluginPermissions:t.grants};case`plugin_path_request`:return{...e,pathRequests:[...e.pathRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_path_resolved`:return{...e,pathRequests:e.pathRequests.filter(e=>e.id!==t.id)};case`plugin_permission_request`:return{...e,permRequests:[...e.permRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_permission_resolved`:return{...e,permRequests:e.permRequests.filter(e=>e.id!==t.id)};case`plugin_job`:{let{pluginId:n,phase:r,ok:i,action:a}=t.job,o=e.pluginUpdates;a===`update`&&r===`done`&&i&&e.pluginUpdates?.[n]&&(o={...e.pluginUpdates,[n]:{...e.pluginUpdates[n],updatable:!1}});let s=e.pluginJobs[t.job.jobId],c=t.line?[...s?.lines??[],t.line].slice(-40):s?.lines??[],l={...s,...t.job,lines:c,startedAt:s?.startedAt??Date.now()};return{...e,pluginUpdates:o,pluginJobs:{...e.pluginJobs,[t.job.jobId]:l}}}case`plugin_catalog_sync_result`:return{...e,catalogSync:{...t.result,receivedAt:Date.now()}};case`plugin_install_inspect_result`:return{...e,installInspect:t.result};case`dsh_patches`:return{...e,dshPatches:{patchDir:t.patchDir,files:t.files}};case`dsh_presets`:return{...e,dshPresets:{presets:t.presets,defaultPreset:t.defaultPreset}};case`dsh_permission`:return{...e,dshPermission:{options:t.options,defaultPreset:t.defaultPreset}};case`terminal_add`:return{...e,terminals:[...e.terminals,t.meta]};case`terminal_remove`:return{...e,terminals:e.terminals.filter(e=>e.id!==t.id)};case`terminal_exit`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!1,exitCode:t.exitCode}:e)};case`terminal_restart`:return{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!0,exitCode:null}:e)};case`terminal_list`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:t.terminals.map(n=>({...n,conversationId:t.conversationId??e.state?.conversationId??``}))};case`terminal_active`:return{...e,terminalActiveId:t.id};default:return e}}var Bs=`pi-web-client-id`,Vs=null;function Hs(){if(Vs)return Vs;let e=null;try{e=sessionStorage.getItem(Bs),e||(e=dt(),sessionStorage.setItem(Bs,e))}catch{e??=dt()}return Vs=e,e}var Us=`pi-web-last-cwd`;function Ws(){try{return localStorage.getItem(Us)}catch{return null}}function Gs(e){try{localStorage.setItem(Us,e)}catch{}}function Ks(e){try{let t=localStorage.getItem(Us);if(!t)return;let n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase();(t===e||n(t)===n(e))&&localStorage.removeItem(Us)}catch{}}function qs(){return Yt(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${Gt(`/ws`)}`)}function Js(){let[e,t]=(0,m.useReducer)(zs,{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:Es().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,updatesSdk:null,widgets:[],statuses:[],dialog:null,approval:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:Fs,bgServers:[],schedulerTasks:[],settings:null,fetchModelsResult:null,testModelConnectionResult:null,enrichModelsResult:null,enrichModelsProgress:null,refreshProviderResult:null,refreshBuiltinResult:null,appendBuiltinResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginUpdates:null,checkingPluginUpdates:!1,pluginCatalog:[],pluginCatalogEpoch:0,pluginJobs:{},catalogSync:null,installInspect:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,dshPresets:null,dshPermission:null,protocolMismatch:!1}),n=(0,m.useRef)(null),r=(0,m.useRef)(Is()),i=(0,m.useRef)(0),a=(0,m.useRef)(null),o=(0,m.useRef)(!0),s=(0,m.useRef)(0),c=(0,m.useRef)(0),l=(0,m.useRef)(new Map),u=(0,m.useRef)(null),d=(0,m.useRef)(!1),f=(0,m.useRef)(null),p=(0,m.useRef)(new Set),h=(0,m.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,m.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]),y=(0,m.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`}),e.type===`check_plugin_updates`&&t({type:`plugin_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(p.current.add(e.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}h.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,m.useCallback)((e,n)=>{let r=za({current:O.current.chat.question,source:h.current,snapshot:e,answered:p.current,activeConversationId:n});r.changed&&(h.current=r.source,t({type:`question`,question:r.question}))},[]);ua(y);let x=(0,m.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(qs());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:Hs(),locale:As()})))},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!==`20260926T09494`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}ta({engine:a.engine??`pi`,managed:!!a.managed,tabs:a.tabs,appVersion:a.appVersion,serverVersion:a.serverVersion,service:a.service}),t({type:`ready`,serverVersion:a.serverVersion,protocolVersion:a.protocolVersion,engine:a.engine,appVersion:a.appVersion,managed:a.managed,tabs:a.tabs,service:a.service}),p.current.clear(),t({type:`question`,question:null}),e.send(JSON.stringify({type:`get_state`})),e.send(JSON.stringify({type:`list_files`})),e.send(JSON.stringify({type:`list_models`})),e.send(JSON.stringify({type:`list_commands`})),e.send(JSON.stringify({type:`get_commands`})),a.managed||(e.send(JSON.stringify({type:`check_update`})),e.send(JSON.stringify({type:`check_updates_all`})));break;case`snapshot`:l.current=new Map,t({type:`snapshot`,state:a.state}),b(a.state.pendingQuestion,a.state.conversationId);break;case`snapshot_delta`:{let e=O.current.chat.state;(!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`subagent_handoff`: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`test_model_connection_result`:t({type:`test_model_connection_result`,result:{reqId:a.reqId,ok:a.ok,latencyMs:a.latencyMs,error:a.error}});break;case`enrich_models_progress`:t({type:`enrich_models_progress`,progress:{reqId:a.reqId,phase:a.phase,current:a.current,total:a.total,message:a.message}});break;case`enrich_models_result`:t({type:`enrich_models_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,error:a.error}});break;case`refresh_provider_result`:t({type:`refresh_provider_result`,result:{reqId:a.reqId,ok:a.ok,added:a.added,total:a.total,error:a.error}});break;case`refresh_builtin_result`:t({type:`refresh_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`append_builtin_result`:t({type:`append_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`clone_provider_result`:t({type:`clone_provider_result`,result:{reqId:a.reqId,ok:a.ok,config:a.config,configs:a.configs,error:a.error}});break;case`scm_data`:t({type:`scm_data`,data:a});break;case`search_files_result`:t({type:`file_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,truncated:a.truncated}});break;case`session_search_results`:t({type:`session_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results}});break;case`scm_changed`:t({type:`scm_changed`});break;case`tool_info`:Ka(a);break;case`heartbeat`:a.hostMetrics&&t({type:`host_metrics`,metrics:a.hostMetrics});break;case`install_result`:t({type:`install_result`,result:a});break;case`path_completions`:t({type:`path_completions`,completions:a.completions});break;case`update_status`:t({type:`update_status`,status:a});break;case`update_status_all`:t({type:`update_status_all`,items:a.items,piSdk:a.piSdk});break;case`widgets`:t({type:`widgets`,widgets:a.widgets});break;case`statuses`:t({type:`statuses`,statuses:a.statuses});break;case`dialog`:t({type:`dialog`,dialog:{id:a.id,kind:a.kind,title:a.title,args:a.args}});break;case`dialog_closed`:t({type:`dialog`,dialog:null});break;case`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`tool_approval_pending`:t({type:`tool_approval`,approval:{id:a.id,toolCallId:a.toolCallId,toolName:a.toolName,params:a.params,reason:a.reason,reasonEn:a.reasonEn,...a.category?{category:a.category}:{},...a.conversationId===void 0?{}:{conversationId:a.conversationId},...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`tool_approval_resolved`:t({type:`tool_approval`,approval:null});break;case`question_retracted`:{let e=O.current.chat.question;if(e&&e.id===a.id){if(p.current.add(a.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}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_updates`:t({type:`plugin_updates`,updates:a.updates});break;case`plugin_catalog`:t({type:`plugin_catalog`,entries:a.entries,epoch:a.epoch});break;case`plugin_grants`:t({type:`plugin_grants`,grants:a.grants});break;case`plugin_permissions`:t({type:`plugin_permissions`,grants:a.grants});break;case`plugin_permission_request`:t({type:`plugin_permission_request`,req:{id:a.id,pluginId:a.pluginId,family:a.family,...a.hosts?{hosts:a.hosts}:{},...a.models?{models:a.models}:{},...a.reason?{reason:a.reason}:{}}});break;case`plugin_permission_resolved`:t({type:`plugin_permission_resolved`,id:a.id});break;case`plugin_path_request`:t({type:`plugin_path_request`,req:{id:a.id,pluginId:a.pluginId,path:a.path,...a.reason?{reason:a.reason}:{}}});break;case`plugin_dom_consent_request`:a.from===Hs()&&e.send(JSON.stringify({type:`plugin_dom_consent_response`,id:a.id,ok:!0}));break;case`plugin_job`:t({type:`plugin_job`,job:{jobId:a.jobId,action:a.action,pluginId:a.pluginId,phase:a.phase,...a.ok===void 0?{}:{ok:a.ok},...a.error?{error:a.error}:{},...a.output?{output:a.output}:{}},...a.line?{line:a.line}:{}});break;case`plugin_install_inspect_result`:t({type:`plugin_install_inspect_result`,result:{requestId:String(a.requestId??``),source:String(a.source??``),kind:a.kind,suggestedId:String(a.suggestedId??``),installed:a.installed===!0,...a.problem?{problem:a.problem}:{},...a.detail?{detail:a.detail}:{},...a.manifest?{manifest:a.manifest}:{}}});break;case`plugin_catalog_sync_result`:Vo(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`:Ts(a.pluginId,a.payload)||qo(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,m.useEffect)(()=>{let e=e=>{let t=e.detail??As();t&&y({type:`set_locale`,locale:t})};return window.addEventListener(js,e),()=>window.removeEventListener(js,e)},[y]),(0,m.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,m.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=Ws();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}f.current!==t&&(f.current=t,Gs(t))}},[e.state?.cwd,y]),(0,m.useEffect)(()=>{ta({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,m.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,m.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,m.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,m.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,m.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,m.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,m.useRef)({chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}});return O.current={chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}},O.current}function Ys(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 Xs(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 Zs=`pi-web-ui:lp-collapse-projects`,Qs=`pi-web-ui:lp-collapse-convs`,$s=`pi-web-ui:lp-collapse-sessions`;function ec(e,t=!1){let[n,r]=(0,m.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,m.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var tc=`pi-web-ui:lp-sizes`,nc={projects:1,convs:1,sessions:1},rc=32,ic=72;function ac(){try{return Fa(localStorage.getItem(tc),nc)}catch{return{...nc}}}var oc=(0,m.memo)(function({sessionFile:e,conversations:t,elsewhere:n,sessions:r,projects:i,activeConversationId:a,panelSend:o,active:s,collapsible:c,onToggleCollapse:l,pathCompletions:u,uiContextSession:d,uiLeftSessions:f,onUiAction:p,presetNames:h}){let g=Z(),_=e,v=aa(`ready`),y=aa(`status`),b=aa(`cwd`),x=aa(`workspaceRoots`),S=b,[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(null),[D,O]=(0,m.useState)(null),[k,A]=(0,m.useState)(null),[ee,j]=(0,m.useState)(``),[M,P]=ec(Zs,!1),[F,I]=ec(Qs,!1),[L,te]=ec($s,!1),z=(0,m.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]),B=(0,m.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},[]),V=(0,m.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},[]),ne=(0,m.useRef)(null),H=(0,m.useRef)(null),U=(0,m.useRef)(()=>{}),W=Gi(d??[]).length>0,G=(0,m.useCallback)((e,n,r)=>{ne.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=z(t,i),c=s===0?g(`noFinishedSubagents`):g(i?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:s}),l=!!i&&H.current===i;Pi({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,hidden:!0}:n?.isEphemeral?{...e,label:g(`saveEphemeral`)}:e}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)=>U.current(e,t)})},[d,t,z,g]);U.current=(0,m.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=ne.current;if(!i||!e)return;if(H.current!==i)return H.current=i,G(e.x,e.y,e.target),!0;H.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?Un({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&Un({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);j(e?.title??n.label??``),A(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);j(e?.name??n.label??``),A(n.id)}return}},[o,G,t,r]);let re=()=>{let e=(f??[]).filter(e=>!$r.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(),p?.(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(),p?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:r})},n)})})},ie=(0,m.useCallback)((e,t)=>{Xs(e.target)||W&&(e.preventDefault(),e.stopPropagation(),H.current=null,G(e.clientX,e.clientY,t))},[W,G]),ae=(0,m.useRef)(null),[oe,ce]=(0,m.useState)(()=>ac());(0,m.useEffect)(()=>{try{localStorage.setItem(tc,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,m.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:M},{key:`convs`,visible:le.length>0,collapsed:F},{key:`sessions`,visible:!0,collapsed:L}].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*rc);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let f=n=>{let{above:r,below:i}=Ia({start:{above:o[e]??1,below:o[t]??1},deltaPx:n.clientY-a,availablePx:d,totalWeight:u,minAbovePx:ic,minBelowPx:ic});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,M,F,L]);(0,m.useEffect)(()=>{s&&v&&y===`open`&&b&&(o({type:`list_sessions`}),o({type:`list_projects`}))},[s,v,y,b,o]);let fe=e=>{let t=e.name||e.firstMessage.trim();return t.length>0?t:g(`emptyChat`)},pe=e=>e.split(/[\\/]/).pop()||e,me=(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)(Ye,{}):i??(0,X.jsx)(R,{})})},he=(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)(Je,{}):(0,X.jsx)(Ke,{})})]}),i?(0,X.jsx)(`div`,{className:`lp-section-actions`,children:i}):null]}),ge=[{key:`projects`,visible:i.length>0,collapsed:M},{key:`convs`,visible:le.length>0,collapsed:F},{key:`sessions`,visible:!0,collapsed:L}].filter(e=>e.visible).filter(e=>!e.collapsed),_e=ge.reduce((e,t)=>e+(oe[t.key]??1),0)||1,ve=e=>ge.length<=1?1:(oe[e]??1)/_e*ge.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)(Ge,{})}),(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${M||i.length===0?`collapsed`:``}`,style:i.length>0&&!M?{flex:`${ve(`projects`)} 1 0px`}:void 0,children:[he(g(`recentProjects`),M,P,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)(ke,{})})),i.length>0&&!M&&(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)(Oe,{className:`project-icon`}),(0,X.jsxs)(`span`,{className:`project-info`,children:[(0,X.jsx)(`span`,{className:`project-name`,children:pe(e.path)}),(0,X.jsx)(`span`,{className:`project-path`,children:e.path})]}),(0,X.jsx)(`span`,{className:`project-time`,children:Ys(e.lastUsed)})]}),me(`proj:${e.path}`,g(`deleteProject`),g(`deleteProjectConfirm`),()=>{Ks(e.path),o({type:`remove_project`,path:e.path})})]},e.path)})})]}),i.length>0&&!M&&(le.length>0?!F:!L)&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:ue(`projects`,le.length>0?`convs`:`sessions`),onDoubleClick:()=>ce({...nc}),title:g(`dragToResize`)}),le.length>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${F?`collapsed`:``}`,style:F?void 0:{flex:`${ve(`convs`)} 1 0px`},onContextMenu:e=>ie(e,{id:``,kind:`section`,label:g(`runningConversations`)}),children:[he(g(`runningConversations`),F,I,le.length),!F&&(0,X.jsx)(`div`,{className:`lp-section-body convs-scroll`,children:La(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:pe(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){let e=n.owner,t=n.convId,r=!!(e&&t),i=D===n.id;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>O(e=>e===n.id?null:e),onContextMenu:r=>ie(r,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{}}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item elsewhere-item${r?``:` elsewhere-static`}${i?` confirm`:``}`,title:i?g(`takeoverConfirm`):`${g(`elsewhereTip`)}\n${n.cwd}`,tabIndex:r?0:-1,onClick:r?()=>{if(!i){O(n.id);return}O(null),o({type:`take_over_conversation`,owner:e,id:t})}:void 0,children:[(0,X.jsx)(K,{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&&e&&t&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:g(`takeoverHasQuestion`),onClick:n=>{n.stopPropagation(),o({type:`peek_elsewhere_question`,owner:e,id:t})},children:`?`}),i?g(`takeoverConfirm`):n.title]}),(0,X.jsx)(`span`,{className:`session-sub`,children:pe(n.cwd)})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:g(`streaming`)})]}),W&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-elsewhere-act`,title:g(`elsewhereActions`),onClick:r=>{r.stopPropagation(),H.current=null;let i=r.currentTarget.getBoundingClientRect();G(i.left,i.bottom+4,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{}})},children:(0,X.jsx)(de,{})})]},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=>ie(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)(K,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[k===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:ee,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>j(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=ee.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),A(null)}else e.key===`Escape`&&A(null)},onBlur:()=>A(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:g(`subagentBadge`)}),n.isEphemeral&&(0,X.jsx)(`span`,{className:`ephemeral-badge`,children:g(`ephemeralBadge`)}),n.forkFrom&&(0,X.jsxs)(`span`,{className:`preset-badge fork-badge`,title:`${g(`forkBadgeTip`)}: ${n.forkFrom.title??n.forkFrom.conversationId}`,children:[`🌿 `,g(`forkBadge`)]}),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:`?`})]}),k===`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),j(n.title),A(`conv:${n.id}`)},children:(0,X.jsx)(Fe,{})}),(()=>{let e=`conv:${n.id}`,r=T===e,i=z(t,n.id),a=V(t,n.id),s=B(t,n.id);return s===0&&!n.isStreaming?me(e,g(`dismissConversation`),g(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(N,{})):s===0?me(e,g(`dismissConversation`),g(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(N,{})):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)(N,{})})})(),re(),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&&!F&&!L&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:ue(`convs`,`sessions`),onDoubleClick:()=>ce({...nc}),title:g(`dragToResize`)}),(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${L?`collapsed`:``}`,style:L?void 0:{flex:`${ve(`sessions`)} 1 0px`},children:[he(g(`historySessions`),L,te,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`}),Vn()},children:(0,X.jsx)(se,{})})),!L&&(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=>ie(t,{id:e.path,kind:`history`,label:fe(e)}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${t?`active`:``}`,title:e.path,onClick:()=>{k||t||o({type:`switch_session`,path:e.path})},children:[(0,X.jsx)(K,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[k===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:ee,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>j(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=ee.trim();t&&o({type:`rename_session`,path:e.path,name:t}),A(null)}else t.key===`Escape`&&A(null)},onBlur:()=>A(null)}):(0,X.jsx)(`span`,{className:`session-title`,children:fe(e)}),k===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:Ys(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:t=>{t.stopPropagation(),E(null),j(e.name??``),A(e.path)},children:(0,X.jsx)(Fe,{})}),me(`sess:${e.path}`,g(`deleteSession`),g(`deleteSessionConfirm`),()=>o({type:`delete_session`,path:e.path})),re()]},e.path)})]})]}),(0,X.jsx)(ga,{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})})]})}),sc=209715200,cc=/windows/i.test(navigator.userAgent),lc=/[<>:"/\\|?*\u0000-\u001f]/g,uc=/[. ]+$/,dc=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function fc(e){let t=e.replace(lc,`_`).replace(uc,``);return t?dc.test(t)?`_${t}`:t:`_`}function pc(e,t=!0){return Yt(Gt(`/api/file?${new URLSearchParams({clientId:Hs(),path:e,...t?{download:`1`}:{}})}`))}async function mc(e,t){let n=cc?fc(t):t;try{let t=await fetch(pc(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`)>sc)return window.location.assign(pc(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?gc(r,n):_c(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function hc(e,t){let n=cc?fc(t):t;return window.showSaveFilePicker&&window.isSecureContext?gc(e,n):_c(e,n)}async function gc(e,t){let n,r=window.showSaveFilePicker;if(!r)return _c(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:_c(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 _c(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 vc(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 yc(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function bc({text:e}){let t=(0,m.useRef)(null),n=(0,m.useRef)(null),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.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,m.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=vc(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,m.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=vc(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,k.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 xc=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function Sc(e,t={}){let n={archive:Gt(`/api/file-transfer/archive`),upload:Gt(`/api/file-transfer/upload`)},r=new URL(Yt(`${n[e]}?${new URLSearchParams({clientId:Hs(),...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 Cc(e,t,n){let r=await fetch(Sc(`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 hc(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function wc(){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 Tc(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=Sc(`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 Ec({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,m.useState)(e.dir),[o,s]=(0,m.useState)(`skip`),[c,l]=(0,m.useState)([]),[u,d]=(0,m.useState)(0),f=(0,m.useRef)(null),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(``),v=(0,m.useRef)(null);(0,m.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 wc();e?l(e):f.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),h(!0),_(``);try{e.action===`upload`?await Tc(e.dir,c,d):await Cc(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,k.createPortal)((0,X.jsx)(`dialog`,{ref:v,className:`file-transfer-dialog`,"aria-labelledby":`file-transfer-title`,onCancel:e=>{e.preventDefault(),p||t()},children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),x()},children:[(0,X.jsxs)(`div`,{className:`file-transfer-head`,children:[(0,X.jsx)(`h3`,{id:`file-transfer-title`,children:y}),(0,X.jsx)(`button`,{type:`button`,className:`file-transfer-close`,title:r(`close`),"aria-label":r(`close`),disabled:p,onClick:t,children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`p`,{className:`file-transfer-path`,children:(e.action===`upload`?e.dir:e.path)||`.`}),(0,X.jsx)(`p`,{children:r(`fileArchiveLimits`)}),e.action===`extract`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`label`,{children:[r(`fileExtractDestination`),(0,X.jsx)(`input`,{value:i,disabled:p,onChange:e=>a(e.target.value)})]}),(0,X.jsxs)(`label`,{children:[r(`fileConflictPolicy`),(0,X.jsxs)(`select`,{value:o,disabled:p,onChange:e=>s(e.target.value),children:[(0,X.jsx)(`option`,{value:`skip`,children:r(`fileConflictSkip`)}),(0,X.jsx)(`option`,{value:`overwrite`,children:r(`fileConflictOverwrite`)}),(0,X.jsx)(`option`,{value:`error`,children:r(`fileConflictError`)})]})]})]}),e.action===`upload`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:r(`fileFolderUploadHint`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:p,onClick:()=>void b(),children:r(`fileChooseFolder`)}),(0,X.jsx)(`input`,{type:`file`,"aria-label":y,multiple:!0,hidden:!0,disabled:p,ref:e=>{f.current=e,e?.setAttribute(`webkitdirectory`,``)},onChange:e=>l(Array.from(e.target.files??[],e=>({path:e.webkitRelativePath||e.name,file:e})))}),(0,X.jsxs)(`p`,{"aria-live":`polite`,children:[u,` / `,c.length]})]}),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:p,onClick:t,children:r(`cancel`)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:p||e.action===`upload`&&c.length===0,children:p?r(`fileTransferBusy`):y})]})]})}),document.body)}function Dc(e){return e instanceof Error?e.message:String(e)}function Oc(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 kc({plugin:e,epoch:t,send:n,className:r}){let i=(0,m.useRef)(null),{locale:a}=pn(),o=Z(),[s,c]=(0,m.useState)(null),l=(0,m.useRef)(n);(0,m.useEffect)(()=>{l.current=n},[n]),(0,m.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 ps(e,t),r)return;let i=await ao(e.id,()=>Go(()=>import(cs(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,hs(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:Dc(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:Oc(s,e.name,a,o)})]})}function Ac(e){return`pi-web-ui:${e}:tab`}function jc(e,t){try{let n=localStorage.getItem(Ac(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function Mc(e,t){try{localStorage.setItem(Ac(e),t)}catch{}}function Nc(e){return e.length>0&&!/[a-z]/i.test(e)}function Pc(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function Fc({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,m.useId)(),[s,c]=(0,m.useState)(()=>jc(e,t)??t[0]?.id??``),l=(0,m.useRef)([]),u=(0,m.useRef)(``),d=t.findIndex(e=>e.id===s),f=d>=0?t[d]:t[0],p=f?t.indexOf(f):-1;(0,m.useEffect)(()=>{if(!f)return;s!==f.id&&c(f.id);let t=`${e}:${f.id}`;u.current!==t&&(u.current=t,Mc(e,f.id))},[f,s,e]);let h=t=>{c(t.id),u.current=`${e}:${t.id}`,Mc(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(!f)return null;let _=`${o}-panel-${p}`,v=a?`slot-tabs ${a}`:`slot-tabs`;return(0,X.jsxs)(`div`,{className:v,children:[(0,X.jsxs)(`div`,{className:`slot-tabs-bar`,role:`tablist`,children:[t.map((e,t)=>{let n=t===p;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,id:`${o}-tab-${t}`,className:n?`slot-tab active`:`slot-tab`,title:e.hint??Pc(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)(Gr,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&Nc(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:Pc(e)})]},e.id)}),i?(0,X.jsx)(`div`,{className:`slot-tabs-extra`,children:i}):null]}),(0,X.jsx)(`div`,{className:`slot-tabs-body`,id:_,role:`tabpanel`,"aria-labelledby":`${o}-tab-${p}`,children:f.pluginPage?(0,X.jsx)(kc,{plugin:f.pluginPage.plugin,epoch:n,send:r}):f.element??null})]})}var Ic=`@root`,Lc=`pi-web-ui:rp-sizes`,Rc={files:4,widgets:1},zc=120,Bc=56;function Vc(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var Hc=`files`,Uc=[],Wc=()=>{};function Gc(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function Kc(e){return e===Ic||e===`/`||/^[A-Za-z]:$/.test(e)}function qc(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var Jc=(0,m.memo)(function({files:e,fileChanged:t,widgets:n,panelSend:r,onAttach:i,onPreview:a,onNotice:o,collapsible:s,onToggleCollapse:c,uiRightPanelTabs:l,uiContextFile:u,plugins:d,pluginsEpoch:f,send:p}){let h=Z(),g=d??Uc,_=aa(`cwd`),v=aa(`workspaceRoots`),y=aa(`homeDir`),b=aa(`desktopDir`),[x,S]=(0,m.useState)(``),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(!1),D=(0,m.useRef)(null),O=(0,m.useRef)(null),[k,A]=(0,m.useState)(()=>{try{return Fa(localStorage.getItem(Lc),Rc)}catch{return{...Rc}}});(0,m.useEffect)(()=>{try{localStorage.setItem(Lc,JSON.stringify(k))}catch{}},[k]);let ee=n.some(e=>e.lines.length>0),j=(0,m.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-Vc(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=Ia({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:zc,minBelowPx:Bc});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]),M=(0,m.useRef)(null),P=(0,m.useRef)(0),F=(0,m.useCallback)(e=>{M.current=e,e&&(e.scrollTop=P.current)},[]),[I,L]=(0,m.useState)(null),R=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{R.current&&clearTimeout(R.current)},[]);let te=(0,m.useCallback)(e=>{L(e),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>L(null),1200)},[]),z=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}},B=(0,m.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,()=>{z(e)?n():r()}):z(e)?n():r()},[te,o,h]),V=(0,m.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},[_]),ne=(0,m.useCallback)(e=>!e||e===Ic?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),H=104857600,U=(0,m.useCallback)((e,t)=>{for(let n of t){if(n.size>H){o(`warning`,h(`fileTooLarge`,{name:n.name,size:H/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]),W=(0,m.useRef)(null),[G,re]=(0,m.useState)(null),ie=(0,m.useRef)(null),ae=(0,m.useCallback)(()=>{let e=W.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),oe=(0,m.useCallback)(()=>{ie.current&&(ie.current.value=``),ie.current?.click()},[]),[se,ce]=(0,m.useState)(null),[le,ue]=(0,m.useState)(null),[de,fe]=(0,m.useState)(``),[pe,me]=(0,m.useState)(null),[he,K]=(0,m.useState)(``),ge=(0,m.useCallback)((e,t)=>{mc(e,t).then(e=>{e.ok||e.cancelled||o(`error`,h(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?h(`fileNotFoundShort`):e.error}))})},[o,h]),_e=(0,m.useCallback)(()=>{let e=W.current?.target;e&&e.kind!==`list`&&!Kc(e.id)&&(me(null),fe(e.label),ue(e.id))},[]),q=(0,m.useCallback)(()=>{if(!le)return;let e=de.trim();ue(null),e&&r({type:`file_rename`,path:le,newName:e})},[le,de,r]),ye=(0,m.useCallback)(e=>{let t=W.current?.dir??x;ue(null),K(``),me({dir:t,kind:e})},[x]),J=(0,m.useCallback)(()=>{if(!pe)return;let e=he.trim();me(null),e&&r({type:`file_create`,dir:pe.dir,name:e,kind:pe.kind})},[pe,he,r]),xe=(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}),Se=(0,m.useCallback)(()=>{let e=W.current?.target;e&&e.kind!==`list`&&!Kc(e.id)&&window.confirm(h(`fileDeleteConfirm`,{name:e.label}))&&(se?.src===e.id&&ce(null),le===e.id&&ue(null),r({type:`file_delete`,path:e.id}))},[r,h,se,le]),Ce=(0,m.useCallback)(()=>{let e=W.current?.target;e&&e.kind!==`list`&&!Kc(e.id)&&r({type:`file_copy`,src:e.id,destDir:Gc(e.id)})},[r]),we=(0,m.useCallback)(e=>{let t=W.current?.target;t&&t.kind!==`list`&&!Kc(t.id)&&ce({src:t.id,cut:e})},[]),Te=(0,m.useCallback)(()=>{if(!se)return;let e=W.current?.dir??x;se.cut?(r({type:`file_copy`,src:se.src,destDir:e,move:!0}),ce(null)):r({type:`file_copy`,src:se.src,destDir:e})},[se,r,x]),Ee=(0,m.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[Y,De]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(!Y)return;let e=e=>{e.target?.closest(`.root-picker`)||De(!1)},t=e=>{e.key===`Escape`&&De(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[Y]);let ke=(0,m.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),je=(0,m.useCallback)(()=>{let e=W.current?.target;if(!e||e.kind!==`dir`)return;let t=ne(e.id);t&&!v.includes(t)&&ke([...v,t])},[v,ne,ke]),Me=(0,m.useCallback)(e=>{U(W.current?.dir??x,Array.from(e.target.files??[]))},[U,x]),Ne=(0,m.useCallback)(e=>{let t=W.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`;re({action:n,path:V(t.id),dir:V(n===`upload`?W.current?.dir??x:Gc(t.id))});break}case`host:file-open-project`:ae();break;case`host:file-upload`:oe();break;case`host:file-add-root`:je();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&Xe(t.id);break;case`host:file-download`:t?.kind===`file`&&ge(t.id,t.label);break;case`host:file-reveal`:t&&r({type:`file_reveal`,path:t.id});break;case`host:file-open-default`:t?.kind===`file`&&r({type:`file_open_default`,path:t.id});break;case`host:file-attach-ref`:t?.kind===`file`&&i(t.id,t.label,`reference`);break;case`host:file-attach-folder`:t?.kind===`dir`&&i(t.id,t.label,`reference`,!0);break;case`host:file-new-file`:ye(`file`);break;case`host:file-new-dir`:ye(`dir`);break;case`host:file-paste`:Te();break;case`host:file-rename`:_e();break;case`host:file-duplicate`:Ce();break;case`host:file-cut`:we(!0);break;case`host:file-copy`:we(!1);break;case`host:file-copy-name`:t&&t.kind!==`list`&&B(t.label,`name:${t.id}`);break;case`host:file-copy-path`:t&&t.kind!==`list`&&B(V(t.id),`path:${t.id}`);break;case`host:file-copy-rel`:t&&t.kind!==`list`&&B(t.id,`rel:${t.id}`);break;case`host:file-refresh`:Ee();break;case`host:file-delete`:Se()}},[ae,x,oe,je,a,i,B,V,ge,ye,Te,_e,Ce,we,Ee,Se]),Pe=(0,m.useCallback)((e,t)=>{let n=t.kind===`dir`?ne(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&&Kc(t.id),l=!s&&qc(t.id),d=x===Ic,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&&xc(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-ref`:return a?e:{...e,hidden:!0};case`host:file-reveal`:return!d&&t.id!==Ic?e:{...e,hidden:!0};case`host:file-enter`:case`host:file-attach-folder`:return o?e:{...e,hidden:!0};case`host:file-new-file`:case`host:file-new-dir`:return!a&&!d?e:{...e,hidden:!0};case`host:file-paste`:return!a&&!d&&se?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}});Gi(f).length!==0&&(e.preventDefault(),e.stopPropagation(),W.current=r,Pi({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:Ne}))},[u,x,ne,h,Ne,_,v,se]),Fe=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),Le=(0,m.useCallback)(()=>{M.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),M.current?.classList.remove(`drop-root`)},[]),Re=(0,m.useCallback)(e=>{if(Le(),e==null)return;let t=M.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):M.current?.classList.add(`drop-root`)},[Le]),Be=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Ve=(0,m.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),Ue=(0,m.useRef)(0),Ge=(0,m.useRef)(void 0),Ke=(0,m.useCallback)((e,t)=>{let n=++Ue.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||Ue.current===n&&E(!1)},[r]),Je=(0,m.useCallback)(e=>{let t=v.filter(t=>t!==e);ke(t),(x===e||x.startsWith(`${e}/`))&&Ke(``)},[v,ke,x,Ke]);(0,m.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,m.useEffect)(()=>{if(_!==Ge.current){Ge.current=_,Ke(``,{silent:!0});return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&Ke(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,Ke]),(0,m.useEffect)(()=>{t&&t.path===x&&Ke(x,{silent:!0})},[t,x,Ke]);let Xe=e=>Ke(e),Ze=()=>{e?.parent!==null&&e?.parent!==void 0&&Ke(e.parent)},Qe=(()=>{if(x===``||x===Ic)return[];let e=x.split(`/`).filter(e=>!!e&&e!==Ic);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(`/`)}))})(),$e=[];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&&$e.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let et=(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)(We,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:ee?`${k.files} 1 0`:`1 1 0`,minHeight:ee?zc:0},children:(0,X.jsx)(Fc,{storageKey:`rightpanel`,epoch:f??0,send:p??Wc,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===Hc?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...et?[]:[{id:Hc,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:()=>Ke(``),children:h(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===Ic?`active`:``}`,title:h(`computer`),onClick:()=>Ke(Ic),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:h(`homeDir`),onClick:()=>Ke(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:h(`desktopDir`),onClick:()=>Ke(b),children:`🖥️`}),(0,X.jsx)(bc,{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":Y,title:h(`workspaceRoots`),onClick:()=>De(e=>!e),children:[(0,X.jsx)(Oe,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:h(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),Y&&(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:()=>{De(!1),Ke(``)},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:()=>{De(!1),Ke(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:()=>Je(e),children:(0,X.jsx)(N,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:h(`workspaceRootsHint`)})]})]}),Qe.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(qe,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>Ke(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:F,className:`panel-body`,onScroll:e=>{P.current=e.currentTarget.scrollTop},onContextMenu:e=>Pe(e,{id:x,kind:`list`,label:x===``?h(`rootDir`):x===Ic?h(`computer`):x}),onDragOver:e=>{Fe(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Ve(),Re(Be(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||Le()},onDrop:e=>{if(Le(),!Fe(e))return;e.preventDefault(),e.stopPropagation(),Ve();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,h(`foldersNotSupported`));return}U(Be(e.target),t)},onDragEnd:Le,children:[(0,X.jsx)(`input`,{ref:ie,type:`file`,multiple:!0,hidden:!0,onChange:Me}),G&&(0,X.jsx)(Ec,{request:G,onClose:()=>re(null),onComplete:Ee}),pe&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[pe.kind===`dir`?(0,X.jsx)(Oe,{className:`file-icon`}):(0,X.jsx)(Ae,{className:`file-icon`}),xe(he,K,J,()=>me(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:Ze,children:[(0,X.jsx)(Oe,{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${se?.cut&&se.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`dir`,label:e.name}),children:[le===e.path?xe(de,fe,q,()=>ue(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>Xe(e.path),children:[(0,X.jsx)(Oe,{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)(be,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>B(e.name,`name:${e.path}`),children:I===`name:${e.path}`?(0,X.jsx)(Ye,{}):(0,X.jsx)(ze,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>B(V(e.path),`path:${e.path}`),children:I===`path:${e.path}`?(0,X.jsx)(Ye,{}):(0,X.jsx)(He,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${se?.cut&&se.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`file`,label:e.name}),children:[le===e.path?xe(de,fe,q,()=>ue(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)(Ae,{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:()=>ge(e.path,e.name),children:(0,X.jsx)(Ie,{})}),(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)(be,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>B(e.name,`name:${e.path}`),children:I===`name:${e.path}`?(0,X.jsx)(Ye,{}):(0,X.jsx)(ze,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>B(V(e.path),`path:${e.path}`),children:I===`path:${e.path}`?(0,X.jsx)(Ye,{}):(0,X.jsx)(He,{})})]},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`)})]})]})}],...$e])})}),ee&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:j,onDoubleClick:()=>A({...Rc}),title:h(`dragToResize`)}),ee&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:Bc},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)(ve,{})]}),(0,X.jsx)(`pre`,{className:`widget-lines`,children:e.lines.join(`
|
|
328
328
|
`)})]},e.key))}),C&&(()=>{let e=n.find(e=>e.key===C);return e?(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>w(null),children:(0,X.jsxs)(`div`,{className:`widget-expand`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`widget-expand-head`,children:[(0,X.jsx)(`span`,{className:`widget-expand-title`,children:e.key}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:h(`close`),onClick:()=>w(null),children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`pre`,{className:`widget-expand-lines`,children:e.lines.join(`
|
|
329
329
|
`)})]})}):null})()]})}),Yc=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],Xc={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...Yc,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...Yc],h2:[[`className`,`sr-only`]],img:[...Yc,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...Yc,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...Yc],table:[...Yc],ul:[...Yc,[`className`,`contains-task-list`]],"*":`abbr.accept.acceptCharset.accessKey.action.align.alt.axis.border.cellPadding.cellSpacing.char.charOff.charSet.checked.clear.colSpan.color.cols.compact.coords.dateTime.dir.encType.frame.hSpace.headers.height.hrefLang.htmlFor.id.isMap.itemProp.label.lang.maxLength.media.method.multiple.name.noHref.noShade.noWrap.open.prompt.readOnly.rev.rowSpan.rows.rules.scope.selected.shape.size.span.start.summary.tabIndex.title.useMap.vAlign.value.width`.split(`.`)},clobber:[`ariaDescribedBy`,`ariaLabelledBy`,`id`,`name`],clobberPrefix:`user-content-`,protocols:{cite:[`http`,`https`],href:[`http`,`https`,`irc`,`ircs`,`mailto`,`xmpp`],longDesc:[`http`,`https`],src:[`http`,`https`]},required:{input:{disabled:!0,type:`checkbox`}},strip:[`script`],tagNames:`a.b.blockquote.br.code.dd.del.details.div.dl.dt.em.h1.h2.h3.h4.h5.h6.hr.i.img.input.ins.kbd.li.ol.p.picture.pre.q.rp.rt.ruby.s.samp.section.source.span.strike.strong.sub.summary.sup.table.tbody.td.tfoot.th.thead.tr.tt.ul.var`.split(`.`)},Zc={}.hasOwnProperty;function Qc(e,t){let n={type:`root`,children:[]},r=$c({schema:t?{...Xc,...t}:Xc,stack:[]},e);return r&&(Array.isArray(r)?r.length===1?n=r[0]:n.children=r:n=r),n}function $c(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return el(e,n);case`doctype`:return tl(e,n);case`element`:return nl(e,n);case`root`:return rl(e,n);case`text`:return il(e,n)}}}function el(e,t){if(e.schema.allowComments){let e=typeof t.value==`string`?t.value:``,n=e.indexOf(`-->`),r={type:`comment`,value:n<0?e:e.slice(0,n)};return dl(r,t),r}}function tl(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return dl(e,t),e}}function nl(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=al(e,t.children),i=ol(e,t.properties);e.stack.pop();let a=!1;if(n&&n!==`*`&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(a=!0,e.schema.ancestors&&Zc.call(e.schema.ancestors,n))){let t=e.schema.ancestors[n],r=-1;for(a=!1;++r<t.length;)e.stack.includes(t[r])&&(a=!0)}if(!a)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;let o={type:`element`,tagName:n,properties:i,children:r};return dl(o,t),o}function rl(e,t){let n={type:`root`,children:al(e,t.children)};return dl(n,t),n}function il(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return dl(n,t),n}function al(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=$c(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function ol(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,a=r&&Zc.call(r,n)?r[n]:void 0,o=r&&Zc.call(r,`*`)?r[`*`]:void 0,s=t&&typeof t==`object`?t:{},c={},l;for(l in s)if(Zc.call(s,l)){let t=s[l],n=sl(e,fl(a,l),l,t);n??=sl(e,fl(o,l),l,t),n!=null&&(c[l]=n)}if(i&&Zc.call(i,n)){let e=i[n];for(l in e)Zc.call(e,l)&&!Zc.call(c,l)&&(c[l]=e[l])}return c}function sl(e,t,n,r){return t?Array.isArray(r)?cl(e,t,n,r):ll(e,t,n,r):void 0}function cl(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=ll(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function ll(e,t,n,r){if((typeof r==`boolean`||typeof r==`number`||typeof r==`string`)&&ul(e,n,r)){if(typeof t==`object`&&t.length>1){let e=!1,n=0;for(;++n<t.length;){let i=t[n];if(i&&typeof i==`object`&&`flags`in i){if(i.test(String(r))){e=!0;break}}else if(i===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function ul(e,t,n){let r=e.schema.protocols&&Zc.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;let i=String(n),a=i.indexOf(`:`),o=i.indexOf(`?`),s=i.indexOf(`#`),c=i.indexOf(`/`);if(a<0||c>-1&&a>c||o>-1&&a>o||s>-1&&a>s)return!0;let l=-1;for(;++l<r.length;){let e=r[l];if(a===e.length&&i.slice(0,e.length)===e)return!0}return!1}function dl(e,t){let n=c(t);t.data&&(e.data=o(t.data)),n&&(e.position=n)}function fl(e,t){let n,r=-1;if(e)for(;++r<e.length;){let i=e[r],a=typeof i==`string`?i:i[0];if(a===t)return i;a===`data*`&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()===`data`)return n}function pl(e){return function(t){return Qc(t,e)}}function ml(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 hl(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,m.useCallback)(()=>{s(),a(!1)},[s]);return(0,m.useEffect)(()=>()=>{s()},[s]),{copied:i,copy:(0,m.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=ml(e)}catch(t){i=ml(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 gl=(0,m.memo)(function({text:e}){let t=Z(),{copied:n,copy:r}=hl({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)(Ye,{}):(0,X.jsx)(ze,{})}):null});function _l(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
330
330
|
`).map(e=>e===``?[]:[e])}if(Array.isArray(e)){let n=[];for(let r of e){let e=t(r);if(n.length===0)n=e;else{let t=e[0]??[];n[n.length-1].push(...t),n.push(...e.slice(1))}}return n}if(e&&typeof e==`object`&&`props`in e){let n=e,r=n.props?.children,i={...n.props,children:void 0},a=r==null?[]:t(r);return a.length===0?[[(0,m.createElement)(n.type,i)]]:a.map(e=>[(0,m.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function vl(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(vl).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return vl(t?.children)}return``}function yl(e){let t=Array.isArray(e)?e[0]:e;return!t||typeof t!=`object`||!(`props`in t)?null:t}function bl(e){let t=yl(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 xl=`pi-web-ui:plugin-data`,Sl=new Map,Cl=new Map,wl=new Set,Tl=-1,El=0,Dl=new Set;function Ol(){El++;for(let e of Dl)e()}function kl(e){return Dl.add(e),()=>{Dl.delete(e)}}function Al(){return El}var jl=null;function Ml(e){jl=e}function Nl(e,t){t!==Tl&&(Tl=t,Cl.clear(),wl.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!==Sl.size;if(!r){for(let[e,t]of n)if(Sl.get(e)!==t){r=!0;break}}if(r){for(let e of Cl.keys())n.has(e)||Cl.delete(e);for(let e of wl)n.has(e)||wl.delete(e);Sl=n,Ol()}}async function Pl(e,t){let n=Sl.get(e);if(!n)return null;let r=Cl.get(e);if(!r&&!wl.has(e))try{let t=(await Go(()=>import(Gt(`/plugins/${encodeURIComponent(n)}/client/entry.mjs?e=${Tl}`)),[])).default?.renderers?.[e];typeof t==`function`?(r={pluginId:n,renderer:t},Cl.set(e,r)):(wl.add(e),console.error(`[plugin:${n}] entry.mjs 未提供 renderers["${e}"]`))}catch(t){wl.add(e),console.error(`[plugin:${n}] renderer 加载失败(${e}):`,t)}if(!r)return null;let i={pluginId:r.pluginId,send:e=>{jl?.({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(xl,t),()=>window.removeEventListener(xl,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 Fl(e){return Sl.has(e)}var Il=new Map,Ll=new Map,Rl=new Set,zl=-1;function Bl(e,t){t!==zl&&(zl=t,Ll.clear(),Rl.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[...Il.keys()])n.has(e)||Il.delete(e);for(let[e,t]of n)Il.set(e,t);for(let e of Ll.keys())n.has(e)||Ll.delete(e);for(let e of Rl)n.has(e)||Rl.delete(e)}function Vl(e){return Il.has(e)}async function Hl(e){let t=Il.get(e);if(!t)return null;let n=Ll.get(e);if(!n&&!Rl.has(e))try{let r=(await Go(()=>import(Gt(`/plugins/${encodeURIComponent(t)}/client/entry.mjs?e=${zl}`)),[])).default?.messageWidgets?.[e];typeof r==`function`?(n={pluginId:t,renderer:r},Ll.set(e,n)):(Rl.add(e),console.error(`[plugin:${t}] entry.mjs 未提供 messageWidgets["${e}"]`))}catch(n){Rl.add(e),console.error(`[plugin:${t}] messageWidget 加载失败(${e}):`,n)}return n?.renderer??null}var Ul=`pi-web-ui:theme`,Wl=`dark`,Gl=`theme-stylesheet`,Kl=`pi-web-ui:theme-change`;function ql(){try{let e=localStorage.getItem(Ul);if(e&&e!==Wl)return e}catch{}return null}function Jl(e){try{e?localStorage.setItem(Ul,e):localStorage.removeItem(Ul)}catch{}}function Yl(e){let t=document.getElementById(Gl);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(Kl));return}t||(t=document.createElement(`link`),t.id=Gl,t.rel=`stylesheet`,document.head.appendChild(t)),t.href=Gt(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(Kl))}async function Xl(){try{let e=await fetch(Yt(Gt(`/api/themes`)));if(!e.ok)return[];let t=await e.json();return Array.isArray(t.themes)?t.themes:[]}catch{return[]}}function Zl(){let[e,t]=(0,m.useState)([]),[n,r]=(0,m.useState)(()=>ql());(0,m.useEffect)(()=>{let e=!1;return Xl().then(n=>{e||t(n)}),()=>{e=!0}},[]);let i=(0,m.useCallback)(()=>{Xl().then(t)},[]);return(0,m.useEffect)(()=>{Yl(n),Jl(n)},[n]),{themes:e,theme:n,switchTheme:e=>r(e===Wl?null:e),reloadThemes:i}}function Ql(){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 $l({lang:e,code:t}){let n=(0,m.useRef)(null),r=(0,m.useRef)(null),i=(0,m.useRef)(0),a=(0,m.useRef)(new WeakMap),[o,s]=(0,m.useState)(null);return(0,m.useEffect)(()=>{let e=()=>{let e=++i.current,t=r.current;t&&(t.dispatchEvent(new CustomEvent(Kl)),a.current.set(t,e))};return window.addEventListener(Kl,e),()=>window.removeEventListener(Kl,e)},[]),(0,m.useEffect)(()=>{let n=!1,r=i.current;return s(null),Pl(e,t).then(e=>{n||(e&&a.current.set(e,r),s(e))}),()=>{n=!0}},[e,t]),(0,m.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(Kl)),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)(gl,{text:t}),(0,X.jsx)(`pre`,{children:(0,X.jsx)(`code`,{children:t})})]})}var eu=null,tu=null;function nu(e){eu=e?.open??null,tu=e?.isOpen??null}function ru(){return tu?tu():!1}function iu(e){return!eu||!e?.path?!1:(eu(e),!0)}var au=[u,s],ou=[u,a,s],su=[[l,{strict:!1,throwOnError:!1}],[d,{detect:!0,ignoreMissing:!0}]];function cu(e){if(!e||!e.includes(`@`))return e;let t=e.split(RegExp("(```[\\s\\S]*?```|`[^`\\r\\n]+`)",`g`)),n=/(^|[\s((“"'[])@((?:[\w.-]+\/)*[\w.-]+\.(?:[a-zA-Z0-9]{1,10}))(?=[)\s\],.;:!?,。!?’”"']|$)/g;for(let e=0;e<t.length;e+=2)t[e]&&(t[e]=t[e].replace(n,(e,t,n)=>t+`[@`+n+`](pi-file://`+encodeURIComponent(n)+`)`));return t.join(``)}function lu({text:e,rawHtml:t=!1,hardBreaks:n=!1}){let r=t?[p,pl,...su]:su,i=(0,m.useMemo)(()=>cu(e),[e]);return(0,X.jsx)(f,{remarkPlugins:n?ou:au,rehypePlugins:r,components:{pre:fu,a:du},children:i})}var uu=(0,m.memo)(function({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,X.jsx)(`div`,{className:`md`,children:(0,X.jsx)(lu,{text:e,rawHtml:t,hardBreaks:n})})});function du({node:e,href:t,children:n,...r}){let i=String(t??``);if(i.startsWith(`pi-file://`)){let e=i.slice(10),t=e;try{t=decodeURIComponent(e)}catch{t=e}let r=typeof n==`string`&&n.trim()?n.trim():t.split(`/`).pop()??t;return(0,X.jsxs)(`button`,{type:`button`,className:`file-pill`,title:`点击预览文件: `+t,onClick:e=>{e.preventDefault(),e.stopPropagation(),iu({path:t,name:r.replace(/^@/,``)})},children:[(0,X.jsx)(`span`,{className:`file-pill-icon`,"aria-hidden":`true`,children:`📄`}),(0,X.jsx)(`span`,{className:`file-pill-name`,children:r})]})}return/^(https?:|mailto:|tel:)/i.test(i)?(0,X.jsx)(`a`,{...r,href:t,target:`_blank`,rel:`noreferrer noopener`,children:n}):(0,X.jsx)(`a`,{href:t,...r,children:n})}function fu({children:e,...t}){(0,m.useSyncExternalStore)(kl,Al,Al);let n=bl(e);return n&&Fl(n)?(0,X.jsx)($l,{lang:n,code:vl(e)}):(0,X.jsx)(pu,{children:e,...t})}function pu({children:e,...t}){let n=_l(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)(gl,{text:mu(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 mu(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(mu).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return mu(t?.children)}return``}function hu({type:e,code:t,children:n}){let r=(0,m.useRef)(null),[i,a]=(0,m.useState)(null);return(0,m.useEffect)(()=>{let n=!1;if(a(null),Vl(e))return Hl(e).then(async r=>{if(!n&&r)try{let i=await r(t,{pluginId:Il.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,m.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 gu=/^\s{0,3}(`{3,}|~{3,})/,_u=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function vu(e){return e.trim()===``}function yu(e){let t=gu.exec(e);return t?t[1]:null}function bu(e){let t=e.split(`
|
|
331
331
|
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=yu(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=yu(a);if(o&&!vu(a)){i=o,r.push(a);continue}if(vu(a)){let i=e;for(;i<t.length&&vu(t[i]);)i++;if(!(i<t.length&&_u.test(t[i]))&&r.length>0){n.push(r.join(`
|
|
332
332
|
`)),r=[];continue}r.push(a);continue}r.push(a)}return{frozen:n,active:r.join(`
|
|
333
333
|
`),inFence:i!==null}}var xu=(0,m.memo)(function({text:e}){return(0,X.jsx)(lu,{text:e})}),Su=200;function Cu({text:e,inFence:t}){let[n,r]=(0,m.useState)(e),i=(0,m.useRef)(0),a=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(t)return;let n=Date.now()-i.current,o=()=>{i.current=Date.now(),r(e)};if(n>=Su){o();return}return a.current=setTimeout(o,Su-n),()=>{a.current&&clearTimeout(a.current)}},[e,t]),t?(0,X.jsx)(`div`,{className:`codeblock`,children:(0,X.jsx)(`pre`,{children:(0,X.jsx)(`code`,{children:e})})}):(0,X.jsx)(lu,{text:n})}var wu=(0,m.memo)(function({text:e}){let{frozen:t,active:n,inFence:r}=(0,m.useMemo)(()=>bu(e),[e]);return(0,X.jsxs)(`div`,{className:`md`,children:[t.map((e,t)=>(0,X.jsx)(xu,{text:e},t)),n.length>0&&(0,X.jsx)(Cu,{text:n,inFence:r},t.length)]})});function Tu(e,t){return t?e.trimEnd().slice(-80):e.split(`
|
|
334
|
-
`)[0].slice(0,80)}function Eu({thinking:e,streaming:t,wrap:n=!0,forceOpen:r=!1,headExtra:i}){let a=Z(),[o,s]=(0,m.useState)(null),c=o??n,l=c||r,u=Tu(e,t),[d,f]=(0,m.useState)(!1),p=()=>{navigator.clipboard.writeText(e),f(!0),window.setTimeout(()=>f(!1),1200)};return(0,X.jsxs)(`div`,{className:`thinking ${l?`open`:``} ${t?`live`:``}`,children:[(0,X.jsxs)(`div`,{className:`chead thinking-head`,role:`button`,tabIndex:0,"aria-expanded":l,title:a(l?`collapseMsg`:`expandMsg`),onClick:()=>s(!c),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(!c))},children:[(0,X.jsx)(`button`,{type:`button`,className:`chead-toggle thinking-toggle`,title:a(l?`collapseMsg`:`expandMsg`),"aria-label":a(l?`collapseMsg`:`expandMsg`),"aria-expanded":l,onClick:e=>{e.stopPropagation(),s(!c)},children:l?(0,X.jsx)(Je,{}):(0,X.jsx)(qe,{})}),(0,X.jsx)(`span`,{className:`chead-icon thinking-icon`,children:(0,X.jsx)(Le,{})}),(0,X.jsx)(`span`,{className:`chead-title thinking-label`,children:t&&l?(0,X.jsxs)(`span`,{className:`thinking-live-label`,children:[a(`thinkingNow`),(0,X.jsx)(`span`,{className:`dots`})]}):l?a(`thinking`):a(`thinkingPreview`,{preview:u})}),i==null&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy thinking-copy${d?` copied`:``}`,title:a(d?`copied`:`copyMessage`),"aria-label":a(`copyMessage`),onClick:e=>{e.stopPropagation(),p()},children:d?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{})}),i!=null&&(0,X.jsx)(`span`,{className:`chead-actions`,onClick:e=>e.stopPropagation(),children:i})]}),l&&(0,X.jsx)(`div`,{className:`thinking-body`,children:e})]})}var Du=262144,Ou=300,ku=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,Au=/"agent"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/,ju=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,Mu=1e9;function Nu(e){if(!e)return{};let t=e.length>Du?e.slice(0,Du):e;return{path:Ru(t),timeout:zu(t),command:Bu(e),agent:Pu(t)}}function Pu(e){let t=Au.exec(e);if(!t)return;let n=t[1].replace(/[\u0000-\u001f\u007f]/g,``).trim();if(n)return n.length>Ou?`${n.slice(0,Ou)}…`:n}var Fu=[`task`,`expected_outcome`,`required_tools`,`must_do`,`must_not_do`,`context`];function Iu(e){if(!e||e.length>Du)return{};try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n=t,r={};for(let e of[...Fu,`agent`,`model`])typeof n[e]==`string`&&n[e].trim()&&(r[e]=n[e]);return r}catch{return{}}}function Lu(e,t=56){if(e.length<=t)return e;let n=e.split(/[\\/]+/).filter(Boolean),r=n[n.length-1];if(!r||n.length<=1)return`…${e.slice(-(t-1))}`;let i=r;for(let e=n.length-2;e>=0;e--){let r=`${n[e]}/${i}`;if(r.length+2>t)break;i=r}return`…/${i}`}function Ru(e){let t=ku.exec(e);if(!t)return;let n=Vu(t[2]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>Ou?`${n.slice(0,299)}…`:n}function zu(e){let t=ju.exec(e);if(!t)return;let n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>Mu)return;let r=t[1].toLowerCase();return!r.endsWith(`ms`)&&!r.endsWith(`milliseconds`)?`${n}s`:n<1e3?`${n}ms`:`${Math.round(n/100)/10}s`}function Bu(e){if(!(e.length>Du))try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?void 0:typeof t.command==`string`&&t.command.trim()?t.command:void 0}catch{return}}function Vu(e){try{let t=JSON.parse(`"${e}"`);return typeof t==`string`?t:e}catch{return e}}var Hu=new Set([`image`,`video`,`audio`,`markdown`,`html`,`pdf`,`text`,`binary`,`dir`,`missing`]);function Uu(e){let t=String(e??``).trim().replace(/\\/g,`/`);return t.length>1?t.replace(/\/+$/,``):t}function Wu(e){let t=Uu(e).split(`/`);return(t[t.length-1]??``)||String(e??``)}function Gu(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Ku(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function qu(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Gu(t);if(!n)return null;let r=Array.isArray(n.items)?n.items:[],i=[];for(let e of r){if(typeof e==`string`){let t=e.trim();t&&i.push({path:t});continue}let t=Gu(e),n=t?Ku(t.path):void 0;if(!n)continue;let r={path:n},a=Ku(t?.caption);a&&(r.caption=a),t?.focus===!0&&(r.focus=!0),i.push(r)}if(i.length===0)return null;let a={items:i},o=Ku(n.title);o&&(a.title=o);let s=Ku(n.note);return s&&(a.note=s),a}function Ju(e,t){let n=Gu(t),r=Array.isArray(n?.items)?n.items.map(Gu):[],i=new Map;for(let e of r){if(!e)continue;let t=Uu(String(e.path??e.abs??``));t&&!i.has(t)&&i.set(t,e)}return e.items.map((e,t)=>{let n=i.get(Uu(e.path))??r[t]??null,a=Ku(n?.kind),o={path:e.path,target:Ku(n?.abs)??e.path,name:Wu(Ku(n?.name)??e.path),kind:a&&Hu.has(a)?a:`unknown`,focus:e.focus===!0};e.caption&&(o.caption=e.caption),typeof n?.size==`number`&&Number.isFinite(n.size)&&(o.size=n.size),typeof n?.mtime==`number`&&Number.isFinite(n.mtime)&&(o.mtime=n.mtime);let s=Ku(n?.excerpt);return s&&(o.excerpt=s),n?.excerptTruncated===!0&&(o.excerptTruncated=!0),o})}function Yu(e,t){return Ku(Gu(t)?.title)??e.title}function Xu(e,t){return Ku(Gu(t)?.note)??e.note}function Zu(e){return e===`image`||e===`video`||e===`audio`?e:null}function Qu(e){return e!==`dir`&&e!==`missing`}function $u(e){switch(e){case`image`:return`🖼`;case`video`:return`🎬`;case`audio`:return`🎵`;case`markdown`:return`📝`;case`html`:return`🌐`;case`pdf`:return`📕`;case`text`:return`📄`;case`dir`:return`📁`;case`missing`:return`⚠`;default:return`📦`}}function ed(e){if(!(e===void 0||!Number.isFinite(e)||e<0))return e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(+(e<10240))} KB`:e<1073741824?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function td(e){return e.find(e=>e.focus&&Qu(e.kind))}function nd(e){if(!e.enabled||e.seen||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp))return!1;let t=e.now-e.timestamp;return t>=0&&t<=e.maxAgeMs}var rd=`pi-web-ui:present-auto-open`,id=`pi-web-ui:present-auto-opened`;function ad(){try{return localStorage.getItem(rd)===`1`}catch{return!1}}function od(e){try{localStorage.setItem(rd,e?`1`:`0`)}catch{}ud=e,cd()}var sd=new Set;function cd(){for(let e of sd)e()}function ld(e){return sd.add(e),()=>{sd.delete(e)}}var ud=null;function dd(){return ud===null&&(ud=ad()),ud}function fd(){return(0,m.useSyncExternalStore)(ld,dd)}function pd(){try{let e=sessionStorage.getItem(id);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function md(e){if(!e)return!1;let t=pd();if(t.includes(e))return!1;let n=[...t,e].slice(-200);try{sessionStorage.setItem(id,JSON.stringify(n))}catch{}return!0}function hd(e,t,n=Date.now()){return nd({enabled:ad(),seen:!1,timestamp:t,now:n,maxAgeMs:3e4})?md(e):!1}var gd=(0,m.memo)(function({args:e,details:t,toolCallId:n,resultTimestamp:r}){let i=Z(),a=fd(),o=(0,m.useMemo)(()=>Ju(e,t),[e,t]),s=Yu(e,t),c=Xu(e,t),l=(0,m.useMemo)(()=>td(o),[o]);return(0,m.useEffect)(()=>{a&&l&&n&&(ru()||hd(n,r)&&iu({path:l.target,name:l.name}))},[a,l,n,r]),o.length===0?(0,X.jsx)(`div`,{className:`present-empty`,children:i(`presentEmpty`)}):(0,X.jsxs)(`div`,{className:`present-card`,children:[s&&(0,X.jsx)(`div`,{className:`present-title`,children:s}),c&&(0,X.jsx)(`div`,{className:`present-note`,children:(0,X.jsx)(uu,{text:c,rawHtml:!0})}),(0,X.jsx)(`div`,{className:`present-items`,children:o.map(e=>(0,X.jsx)(vd,{item:e},`${e.target}\u0000${e.path}`))})]})});function _d(e){return typeof e.mtime==`number`?`${e.path}\n${new Date(e.mtime).toLocaleString()}`:e.path}function vd({item:e}){let t=Z(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=i?null:Zu(e.kind),l=ed(e.size),u=e.kind===`missing`,d={path:e.target,name:e.name};return(0,X.jsxs)(`div`,{className:`present-item${u?` missing`:``}`,children:[(0,X.jsxs)(`div`,{className:`present-item-head`,children:[(0,X.jsx)(`span`,{className:`present-item-icon`,"aria-hidden":`true`,children:$u(e.kind)}),(0,X.jsx)(`span`,{className:`present-item-name`,title:_d(e),children:e.name}),e.caption&&(0,X.jsx)(`span`,{className:`present-item-caption`,children:e.caption}),l&&!u&&(0,X.jsx)(`span`,{className:`present-item-meta`,children:l}),(0,X.jsx)(`span`,{className:`present-item-spacer`}),!u&&(0,X.jsxs)(X.Fragment,{children:[Qu(e.kind)&&(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`previewFile`),"aria-label":t(`previewFile`),onClick:()=>iu(d),children:(0,X.jsx)(Me,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`present-btn labeled`,title:t(`fileOpenDefault`),onClick:()=>$({type:`file_open_default`,path:e.target}),children:[(0,X.jsx)(Ne,{}),(0,X.jsx)(`span`,{children:t(`presentOpenLocal`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`fileReveal`),"aria-label":t(`fileReveal`),onClick:()=>$({type:`file_reveal`,path:e.target}),children:(0,X.jsx)(ke,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`downloadFile`),"aria-label":t(`downloadFile`),onClick:()=>{s(``),mc(e.target,e.name).then(e=>{e.ok||e.cancelled||s(e.error===`FILE_NOT_FOUND`?t(`fileNotFoundShort`):e.error)})},children:(0,X.jsx)(Ie,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn${n?` on`:``}`,title:t(`copyPath`),"aria-label":t(`copyPath`),onClick:()=>{navigator.clipboard.writeText(e.path),r(!0),window.setTimeout(()=>r(!1),1200)},children:(0,X.jsx)(ze,{})})]})]}),u&&(0,X.jsx)(`div`,{className:`present-item-warn`,children:t(`presentMissing`)}),o&&(0,X.jsx)(`div`,{className:`present-item-warn`,children:t(`downloadFailed`,{error:o})}),c===`image`&&(0,X.jsx)(`button`,{type:`button`,className:`present-media`,title:t(`previewFile`),onClick:()=>iu(d),children:(0,X.jsx)(`img`,{src:pc(e.target,!1),alt:e.name,loading:`lazy`,onError:()=>a(!0)})}),c===`video`&&(0,X.jsx)(`video`,{className:`present-media-video`,src:pc(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),c===`audio`&&(0,X.jsx)(`audio`,{className:`present-media-audio`,src:pc(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),e.excerpt&&(0,X.jsxs)(`pre`,{className:`present-excerpt`,children:[e.excerpt,e.excerptTruncated?`…`:``]})]})}var yd={bash:`$`,delegate_task:`◈`,read:`📄`,write:`✍️`,edit:`✏️`,edit_soft:`✏️`,grep:`🔍`,find:`🧭`,ls:`📂`,[ir]:`🖼`};function bd(e){return yd[e]??`🛠`}var xd=(0,m.memo)(function({block:e,view:t,onKillBash:n,wrap:r=!0,showImages:i=!0,forceOpen:a=!1,uiContextToolCall:o,onUiAction:s,headExtra:c}){let l=Z(),[u,d]=(0,m.useState)(null),f=e.name===ir,p=u??(f?!0:r),h=p||a,[g,_]=(0,m.useState)(!1),v=!t.result&&t.streaming&&!t.status,y=e.name===`bash`&&v,b=t.result!==void 0,x=!t.result&&!!t.status,S=t.result?.isError??t.status?.isError??!1,C=t.result?t.result.content.map(e=>e.type===`text`?e.text:``).join(``):t.liveOutput??``,w=C.replace(/…\[LIVE_OMIT:(\d+)\]…\n/,(e,t)=>l(`liveOutputOmitted`,{n:t})),T=(0,m.useMemo)(()=>i?(t.result?.content??[]).filter(e=>e.type===`image`&&typeof e.dataUrl==`string`&&e.dataUrl.startsWith(`data:`)):[],[i,t.result]),[E,D]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!E)return;let e=e=>{e.key===`Escape`&&D(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E]);let O=e.name===`delegate_task`,A=O?Iu(e.argumentsText):{},ee=(0,m.useMemo)(()=>f?qu(e.argumentsText):null,[f,e.argumentsText]),j=O&&t.result&&typeof t.result.details==`object`&&t.result.details!==null?t.result.details.convId:void 0,M=typeof j==`string`&&j?j:/sa-[0-9a-f]{8}/.exec(C)?.[0],P=(0,m.useRef)(void 0),F=t.status?.durationMs,I=t.result?.durationMs;(0,m.useEffect)(()=>{F!==void 0&&(P.current=F),typeof I==`number`&&(P.current=I)},[F,I]);let L=typeof I==`number`?I:F??P.current,R=S?`err`:b?`ok`:v||x?`run`:`idle`,te=l(S?`error`:b?`done`:v?`running`:x?`toolDoneWaitingModel`:`toolQueued`),z=(x||b)&&L!==void 0?Td(L):``;(x||b)&&z&&(te=`${te} · ${z}`);let B=x&&t.status?.exitCode!==void 0?`exit ${t.status.exitCode}`:``,V=Nu(e.argumentsText),re=e.name===`bash`?V.command:void 0,H=!h&&re?wd(re):void 0,U=()=>{e.argumentsText&&(navigator.clipboard.writeText(e.argumentsText),_(!0),setTimeout(()=>_(!1),1200))},W=(o??[]).some(e=>e&&e.hidden!==!0&&e.kind!==`divider`);return(0,X.jsxs)(`div`,{className:`toolcall ${R}`,children:[(0,X.jsxs)(`div`,{className:`chead toolcall-head`,role:`button`,tabIndex:0,"aria-expanded":h,title:l(h?`collapseMsg`:`expandMsg`),onClick:()=>d(!p),onContextMenu:t=>{if(!W)return;let n=t.target;if(n instanceof Element&&n.closest(`pre, code, a, input, textarea, [contenteditable='true']`))return;let r=window.getSelection?.();r&&!r.isCollapsed&&r.toString().trim().length>0||(t.preventDefault(),t.stopPropagation(),Pi({x:t.clientX,y:t.clientY,slot:`contextmenu.toolcall`,target:{id:e.id,kind:`toolcall`,label:e.name},entries:o??[],onHostAction:t=>{if(t.id===`host:tool-info`){Wa(e.name);return}s?.(t)}}))},onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d(!p))},children:[(0,X.jsx)(`button`,{type:`button`,className:`chead-toggle toolcall-toggle`,title:l(h?`collapseMsg`:`expandMsg`),"aria-label":l(h?`collapseMsg`:`expandMsg`),"aria-expanded":h,onClick:e=>{e.stopPropagation(),d(!p)},children:h?(0,X.jsx)(Je,{}):(0,X.jsx)(qe,{})}),(0,X.jsx)(`span`,{className:`chead-icon toolcall-icon`,children:bd(e.name)}),(0,X.jsx)(`span`,{className:`chead-title toolcall-name`,children:e.name}),(0,X.jsx)(`span`,{className:`toolcall-status`,title:B?`${te} · ${B}`:te,"aria-label":B?`${te} · ${B}`:te,children:S?(0,X.jsx)(N,{}):b?(0,X.jsx)(Ye,{}):v?(0,X.jsx)(ye,{}):x?(0,X.jsx)(Ve,{}):(0,X.jsx)(me,{})}),z&&(0,X.jsx)(`span`,{className:`toolcall-duration toolcall-timeout`,style:{marginLeft:-2,fontFamily:`var(--mono)`},title:B?`${te} · ${B}`:te,children:z}),H&&(0,X.jsxs)(`span`,{className:`toolcall-cmd`,title:re,children:[`$ `,H]}),V.path&&(0,X.jsx)(`span`,{className:`toolcall-path`,title:V.path,children:Lu(V.path)}),V.timeout&&(0,X.jsxs)(`span`,{className:`toolcall-timeout`,children:[`⏱ `,V.timeout]}),O&&V.agent&&(0,X.jsxs)(`span`,{className:`toolcall-agent`,title:V.agent,children:[`◈ `,V.agent]}),(0,X.jsx)(`span`,{className:`toolcall-spacer`}),y&&n&&(0,X.jsxs)(`button`,{type:`button`,className:`toolcall-kill`,title:l(`stopBashTip`),onClick:e=>{e.stopPropagation(),n?.()},children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`span`,{children:l(`stopBash`)})]}),O&&b&&M&&(0,X.jsxs)(`button`,{type:`button`,className:`toolcall-open`,title:l(`delegateOpenSubagent`),onClick:e=>{e.stopPropagation(),window.dispatchEvent(new CustomEvent(`pi-web-ui:switch-conversation`,{detail:M}))},children:[(0,X.jsx)(nt,{}),(0,X.jsx)(`span`,{children:l(`delegateOpenSubagent`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy${g?` copied`:``}`,title:l(`copyArgs`),onClick:e=>{e.stopPropagation(),U()},children:g?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{})}),c!=null&&(0,X.jsx)(`span`,{className:`chead-actions`,onClick:e=>e.stopPropagation(),children:c})]}),T.length>0&&(0,X.jsx)(`div`,{className:`toolcall-images`,children:T.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`toolcall-image`,title:l(`toolImageZoom`),"aria-label":l(`toolImageZoom`),onClick:t=>{t.stopPropagation(),D(e.dataUrl)},children:(0,X.jsx)(`img`,{src:e.dataUrl,alt:`tool result image ${t+1}`})},t))}),E&&(0,k.createPortal)((0,X.jsxs)(`div`,{className:`img-lightbox`,role:`dialog`,"aria-label":l(`toolImageZoom`),onClick:()=>D(null),children:[(0,X.jsx)(`button`,{type:`button`,className:`img-lightbox-close`,title:l(`close`),"aria-label":l(`close`),onClick:e=>{e.stopPropagation(),D(null)},children:(0,X.jsx)(N,{})}),(0,X.jsx)(`img`,{src:E,alt:`tool result preview`})]}),document.body),h&&(0,X.jsxs)(`div`,{className:`toolcall-body`,children:[f&&ee?(0,X.jsx)(gd,{args:ee,details:t.result?.details,toolCallId:t.result?.toolCallId??e.id,resultTimestamp:t.result?.timestamp}):O?(0,X.jsx)(Cd,{args:A}):e.argumentsText&&(0,X.jsx)(`div`,{className:`toolcall-args`,children:re?(0,X.jsx)(Sd,{command:re}):(0,X.jsx)(`pre`,{children:e.argumentsText})}),w.length>0&&(0,X.jsxs)(`div`,{className:`toolcall-output`,children:[(0,X.jsxs)(`div`,{className:`toolcall-output-label`,children:[l(S?`errorOutput`:`output`),(v||x)&&(0,X.jsx)(`span`,{className:`cursor`})]}),(0,X.jsx)(`pre`,{children:w})]}),v&&w.length===0&&(0,X.jsxs)(`div`,{className:`toolcall-waiting`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,l(`waitingOutput`)]}),x&&w.length===0&&(0,X.jsxs)(`div`,{className:`toolcall-waiting`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,l(`waitingModel`)]})]})]})});function Sd({command:e}){return(0,X.jsxs)(`div`,{className:`termline`,children:[(0,X.jsx)(z,{className:`termline-icon`}),(0,X.jsx)(`code`,{children:e})]})}function Cd({args:e}){let t=Z(),n=[{field:`task`,label:t(`delegateSecTask`)},{field:`expected_outcome`,label:t(`delegateSecExpected`)},{field:`required_tools`,label:t(`delegateSecTools`)},{field:`must_do`,label:t(`delegateSecMustDo`)},{field:`must_not_do`,label:t(`delegateSecMustNotDo`)},{field:`context`,label:t(`delegateSecContext`)}].filter(({field:t})=>e[t]?.trim());return n.length===0?null:(0,X.jsx)(`div`,{className:`delegate-brief`,children:n.map(({field:t,label:n})=>(0,X.jsxs)(`div`,{className:`delegate-sec`,children:[(0,X.jsx)(`div`,{className:`delegate-sec-label`,children:n}),(0,X.jsx)(`div`,{className:`delegate-sec-text`,children:e[t]})]},t))})}function wd(e){let t=e.split(`
|
|
334
|
+
`)[0].slice(0,80)}function Eu({thinking:e,streaming:t,wrap:n=!0,forceOpen:r=!1,headExtra:i}){let a=Z(),[o,s]=(0,m.useState)(null),c=o??n,l=c||r,u=Tu(e,t),[d,f]=(0,m.useState)(!1),p=()=>{navigator.clipboard.writeText(e),f(!0),window.setTimeout(()=>f(!1),1200)};return(0,X.jsxs)(`div`,{className:`thinking ${l?`open`:``} ${t?`live`:``}`,children:[(0,X.jsxs)(`div`,{className:`chead thinking-head`,role:`button`,tabIndex:0,"aria-expanded":l,title:a(l?`collapseMsg`:`expandMsg`),onClick:()=>s(!c),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(!c))},children:[(0,X.jsx)(`button`,{type:`button`,className:`chead-toggle thinking-toggle`,title:a(l?`collapseMsg`:`expandMsg`),"aria-label":a(l?`collapseMsg`:`expandMsg`),"aria-expanded":l,onClick:e=>{e.stopPropagation(),s(!c)},children:l?(0,X.jsx)(Je,{}):(0,X.jsx)(qe,{})}),(0,X.jsx)(`span`,{className:`chead-icon thinking-icon`,children:(0,X.jsx)(Le,{})}),(0,X.jsx)(`span`,{className:`chead-title thinking-label`,children:t&&l?(0,X.jsxs)(`span`,{className:`thinking-live-label`,children:[a(`thinkingNow`),(0,X.jsx)(`span`,{className:`dots`})]}):l?a(`thinking`):a(`thinkingPreview`,{preview:u})}),i==null&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy thinking-copy${d?` copied`:``}`,title:a(d?`copied`:`copyMessage`),"aria-label":a(`copyMessage`),onClick:e=>{e.stopPropagation(),p()},children:d?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{})}),i!=null&&(0,X.jsx)(`span`,{className:`chead-actions`,onClick:e=>e.stopPropagation(),children:i})]}),l&&(0,X.jsx)(`div`,{className:`thinking-body`,children:e})]})}var Du=262144,Ou=300,ku=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,Au=/"agent"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/,ju=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,Mu=1e9;function Nu(e){if(!e)return{};let t=e.length>Du?e.slice(0,Du):e;return{path:Ru(t),timeout:zu(t),command:Bu(e),agent:Pu(t)}}function Pu(e){let t=Au.exec(e);if(!t)return;let n=t[1].replace(/[\u0000-\u001f\u007f]/g,``).trim();if(n)return n.length>Ou?`${n.slice(0,Ou)}…`:n}var Fu=[`task`,`expected_outcome`,`required_tools`,`must_do`,`must_not_do`,`context`];function Iu(e){if(!e||e.length>Du)return{};try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n=t,r={};for(let e of[...Fu,`agent`,`model`])typeof n[e]==`string`&&n[e].trim()&&(r[e]=n[e]);return r}catch{return{}}}function Lu(e,t=56){if(e.length<=t)return e;let n=e.split(/[\\/]+/).filter(Boolean),r=n[n.length-1];if(!r||n.length<=1)return`…${e.slice(-(t-1))}`;let i=r;for(let e=n.length-2;e>=0;e--){let r=`${n[e]}/${i}`;if(r.length+2>t)break;i=r}return`…/${i}`}function Ru(e){let t=ku.exec(e);if(!t)return;let n=Vu(t[2]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>Ou?`${n.slice(0,299)}…`:n}function zu(e){let t=ju.exec(e);if(!t)return;let n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>Mu)return;let r=t[1].toLowerCase();return!r.endsWith(`ms`)&&!r.endsWith(`milliseconds`)?`${n}s`:n<1e3?`${n}ms`:`${Math.round(n/100)/10}s`}function Bu(e){if(!(e.length>Du))try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?void 0:typeof t.command==`string`&&t.command.trim()?t.command:void 0}catch{return}}function Vu(e){try{let t=JSON.parse(`"${e}"`);return typeof t==`string`?t:e}catch{return e}}var Hu=new Set([`image`,`video`,`audio`,`markdown`,`html`,`pdf`,`text`,`binary`,`dir`,`missing`]);function Uu(e){let t=String(e??``).trim().replace(/\\/g,`/`);return t.length>1?t.replace(/\/+$/,``):t}function Wu(e){let t=Uu(e).split(`/`);return(t[t.length-1]??``)||String(e??``)}function Gu(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Ku(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function qu(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Gu(t);if(!n)return null;let r=Array.isArray(n.items)?n.items:[],i=[];for(let e of r){if(typeof e==`string`){let t=e.trim();t&&i.push({path:t});continue}let t=Gu(e),n=t?Ku(t.path):void 0;if(!n)continue;let r={path:n},a=Ku(t?.caption);a&&(r.caption=a),t?.focus===!0&&(r.focus=!0),i.push(r)}if(i.length===0)return null;let a={items:i},o=Ku(n.title);o&&(a.title=o);let s=Ku(n.note);return s&&(a.note=s),a}function Ju(e,t){let n=Gu(t),r=Array.isArray(n?.items)?n.items.map(Gu):[],i=new Map;for(let e of r){if(!e)continue;let t=Uu(String(e.path??e.abs??``));t&&!i.has(t)&&i.set(t,e)}return e.items.map((e,t)=>{let n=i.get(Uu(e.path))??r[t]??null,a=Ku(n?.kind),o={path:e.path,target:Ku(n?.abs)??e.path,name:Wu(Ku(n?.name)??e.path),kind:a&&Hu.has(a)?a:`unknown`,focus:e.focus===!0};e.caption&&(o.caption=e.caption),typeof n?.size==`number`&&Number.isFinite(n.size)&&(o.size=n.size),typeof n?.mtime==`number`&&Number.isFinite(n.mtime)&&(o.mtime=n.mtime);let s=Ku(n?.excerpt);return s&&(o.excerpt=s),n?.excerptTruncated===!0&&(o.excerptTruncated=!0),o})}function Yu(e,t){return Ku(Gu(t)?.title)??e.title}function Xu(e,t){return Ku(Gu(t)?.note)??e.note}function Zu(e){return e===`image`||e===`video`||e===`audio`?e:null}function Qu(e){return e!==`dir`&&e!==`missing`}function $u(e){switch(e){case`image`:return`🖼`;case`video`:return`🎬`;case`audio`:return`🎵`;case`markdown`:return`📝`;case`html`:return`🌐`;case`pdf`:return`📕`;case`text`:return`📄`;case`dir`:return`📁`;case`missing`:return`⚠`;default:return`📦`}}function ed(e){if(!(e===void 0||!Number.isFinite(e)||e<0))return e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(+(e<10240))} KB`:e<1073741824?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function td(e){return e.find(e=>e.focus&&Qu(e.kind))}function nd(e){if(!e.enabled||e.seen||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp))return!1;let t=e.now-e.timestamp;return t>=0&&t<=e.maxAgeMs}var rd=`pi-web-ui:present-auto-open`,id=`pi-web-ui:present-auto-opened`;function ad(){try{return localStorage.getItem(rd)===`1`}catch{return!1}}function od(e){try{localStorage.setItem(rd,e?`1`:`0`)}catch{}ud=e,cd()}var sd=new Set;function cd(){for(let e of sd)e()}function ld(e){return sd.add(e),()=>{sd.delete(e)}}var ud=null;function dd(){return ud===null&&(ud=ad()),ud}function fd(){return(0,m.useSyncExternalStore)(ld,dd)}function pd(){try{let e=sessionStorage.getItem(id);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function md(e){if(!e)return!1;let t=pd();if(t.includes(e))return!1;let n=[...t,e].slice(-200);try{sessionStorage.setItem(id,JSON.stringify(n))}catch{}return!0}function hd(e,t,n=Date.now()){return nd({enabled:ad(),seen:!1,timestamp:t,now:n,maxAgeMs:3e4})?md(e):!1}var gd=(0,m.memo)(function({args:e,details:t,toolCallId:n,resultTimestamp:r}){let i=Z(),a=fd(),o=(0,m.useMemo)(()=>Ju(e,t),[e,t]),s=Yu(e,t),c=Xu(e,t),l=(0,m.useMemo)(()=>td(o),[o]);return(0,m.useEffect)(()=>{a&&l&&n&&(ru()||hd(n,r)&&iu({path:l.target,name:l.name}))},[a,l,n,r]),o.length===0?(0,X.jsx)(`div`,{className:`present-empty`,children:i(`presentEmpty`)}):(0,X.jsxs)(`div`,{className:`present-card`,children:[s&&(0,X.jsx)(`div`,{className:`present-title`,children:s}),c&&(0,X.jsx)(`div`,{className:`present-note`,children:(0,X.jsx)(uu,{text:c,rawHtml:!0})}),(0,X.jsx)(`div`,{className:`present-items`,children:o.map(e=>(0,X.jsx)(vd,{item:e},`${e.target}\u0000${e.path}`))})]})});function _d(e){return typeof e.mtime==`number`?`${e.path}\n${new Date(e.mtime).toLocaleString()}`:e.path}function vd({item:e}){let t=Z(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=i?null:Zu(e.kind),l=ed(e.size),u=e.kind===`missing`,d={path:e.target,name:e.name};return(0,X.jsxs)(`div`,{className:`present-item${u?` missing`:``}`,children:[(0,X.jsxs)(`div`,{className:`present-item-head`,children:[(0,X.jsx)(`span`,{className:`present-item-icon`,"aria-hidden":`true`,children:$u(e.kind)}),(0,X.jsx)(`span`,{className:`present-item-name`,title:_d(e),children:e.name}),e.caption&&(0,X.jsx)(`span`,{className:`present-item-caption`,children:e.caption}),l&&!u&&(0,X.jsx)(`span`,{className:`present-item-meta`,children:l}),(0,X.jsx)(`span`,{className:`present-item-spacer`}),!u&&(0,X.jsxs)(X.Fragment,{children:[Qu(e.kind)&&(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`previewFile`),"aria-label":t(`previewFile`),onClick:()=>iu(d),children:(0,X.jsx)(Me,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`present-btn labeled`,title:t(`fileOpenDefault`),onClick:()=>$({type:`file_open_default`,path:e.target}),children:[(0,X.jsx)(Ne,{}),(0,X.jsx)(`span`,{children:t(`presentOpenLocal`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`fileReveal`),"aria-label":t(`fileReveal`),onClick:()=>$({type:`file_reveal`,path:e.target}),children:(0,X.jsx)(Oe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`downloadFile`),"aria-label":t(`downloadFile`),onClick:()=>{s(``),mc(e.target,e.name).then(e=>{e.ok||e.cancelled||s(e.error===`FILE_NOT_FOUND`?t(`fileNotFoundShort`):e.error)})},children:(0,X.jsx)(Ie,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn${n?` on`:``}`,title:t(`copyPath`),"aria-label":t(`copyPath`),onClick:()=>{navigator.clipboard.writeText(e.path),r(!0),window.setTimeout(()=>r(!1),1200)},children:(0,X.jsx)(ze,{})})]})]}),u&&(0,X.jsx)(`div`,{className:`present-item-warn`,children:t(`presentMissing`)}),o&&(0,X.jsx)(`div`,{className:`present-item-warn`,children:t(`downloadFailed`,{error:o})}),c===`image`&&(0,X.jsx)(`button`,{type:`button`,className:`present-media`,title:t(`previewFile`),onClick:()=>iu(d),children:(0,X.jsx)(`img`,{src:pc(e.target,!1),alt:e.name,loading:`lazy`,onError:()=>a(!0)})}),c===`video`&&(0,X.jsx)(`video`,{className:`present-media-video`,src:pc(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),c===`audio`&&(0,X.jsx)(`audio`,{className:`present-media-audio`,src:pc(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),e.excerpt&&(0,X.jsxs)(`pre`,{className:`present-excerpt`,children:[e.excerpt,e.excerptTruncated?`…`:``]})]})}var yd={bash:`$`,delegate_task:`◈`,read:`📄`,write:`✍️`,edit:`✏️`,edit_soft:`✏️`,grep:`🔍`,find:`🧭`,ls:`📂`,[ir]:`🖼`};function bd(e){return yd[e]??`🛠`}var xd=(0,m.memo)(function({block:e,view:t,onKillBash:n,wrap:r=!0,showImages:i=!0,forceOpen:a=!1,uiContextToolCall:o,onUiAction:s,headExtra:c}){let l=Z(),[u,d]=(0,m.useState)(null),f=e.name===ir,p=u??(f?!0:r),h=p||a,[g,_]=(0,m.useState)(!1),v=!t.result&&t.streaming&&!t.status,y=e.name===`bash`&&v,b=t.result!==void 0,x=!t.result&&!!t.status,S=t.result?.isError??t.status?.isError??!1,C=t.result?t.result.content.map(e=>e.type===`text`?e.text:``).join(``):t.liveOutput??``,w=C.replace(/…\[LIVE_OMIT:(\d+)\]…\n/,(e,t)=>l(`liveOutputOmitted`,{n:t})),T=(0,m.useMemo)(()=>i?(t.result?.content??[]).filter(e=>e.type===`image`&&typeof e.dataUrl==`string`&&e.dataUrl.startsWith(`data:`)):[],[i,t.result]),[E,D]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!E)return;let e=e=>{e.key===`Escape`&&D(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[E]);let O=e.name===`delegate_task`,A=O?Iu(e.argumentsText):{},ee=(0,m.useMemo)(()=>f?qu(e.argumentsText):null,[f,e.argumentsText]),j=O&&t.result&&typeof t.result.details==`object`&&t.result.details!==null?t.result.details.convId:void 0,M=typeof j==`string`&&j?j:/sa-[0-9a-f]{8}/.exec(C)?.[0],P=(0,m.useRef)(void 0),F=t.status?.durationMs,I=t.result?.durationMs;(0,m.useEffect)(()=>{F!==void 0&&(P.current=F),typeof I==`number`&&(P.current=I)},[F,I]);let L=typeof I==`number`?I:F??P.current,R=S?`err`:b?`ok`:v||x?`run`:`idle`,te=l(S?`error`:b?`done`:v?`running`:x?`toolDoneWaitingModel`:`toolQueued`),z=(x||b)&&L!==void 0?Td(L):``;(x||b)&&z&&(te=`${te} · ${z}`);let B=x&&t.status?.exitCode!==void 0?`exit ${t.status.exitCode}`:``,V=Nu(e.argumentsText),H=e.name===`bash`?V.command:void 0,U=!h&&H?wd(H):void 0,W=()=>{e.argumentsText&&(navigator.clipboard.writeText(e.argumentsText),_(!0),setTimeout(()=>_(!1),1200))},G=(o??[]).some(e=>e&&e.hidden!==!0&&e.kind!==`divider`);return(0,X.jsxs)(`div`,{className:`toolcall ${R}`,children:[(0,X.jsxs)(`div`,{className:`chead toolcall-head`,role:`button`,tabIndex:0,"aria-expanded":h,title:l(h?`collapseMsg`:`expandMsg`),onClick:()=>d(!p),onContextMenu:t=>{if(!G)return;let n=t.target;if(n instanceof Element&&n.closest(`pre, code, a, input, textarea, [contenteditable='true']`))return;let r=window.getSelection?.();r&&!r.isCollapsed&&r.toString().trim().length>0||(t.preventDefault(),t.stopPropagation(),Pi({x:t.clientX,y:t.clientY,slot:`contextmenu.toolcall`,target:{id:e.id,kind:`toolcall`,label:e.name},entries:o??[],onHostAction:t=>{if(t.id===`host:tool-info`){Wa(e.name);return}s?.(t)}}))},onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d(!p))},children:[(0,X.jsx)(`button`,{type:`button`,className:`chead-toggle toolcall-toggle`,title:l(h?`collapseMsg`:`expandMsg`),"aria-label":l(h?`collapseMsg`:`expandMsg`),"aria-expanded":h,onClick:e=>{e.stopPropagation(),d(!p)},children:h?(0,X.jsx)(Je,{}):(0,X.jsx)(qe,{})}),(0,X.jsx)(`span`,{className:`chead-icon toolcall-icon`,children:bd(e.name)}),(0,X.jsx)(`span`,{className:`chead-title toolcall-name`,children:e.name}),(0,X.jsx)(`span`,{className:`toolcall-status`,title:B?`${te} · ${B}`:te,"aria-label":B?`${te} · ${B}`:te,children:S?(0,X.jsx)(N,{}):b?(0,X.jsx)(Ye,{}):v?(0,X.jsx)(ye,{}):x?(0,X.jsx)(Ve,{}):(0,X.jsx)(pe,{})}),z&&(0,X.jsx)(`span`,{className:`toolcall-duration toolcall-timeout`,style:{marginLeft:-2,fontFamily:`var(--mono)`},title:B?`${te} · ${B}`:te,children:z}),U&&(0,X.jsxs)(`span`,{className:`toolcall-cmd`,title:H,children:[`$ `,U]}),V.path&&(0,X.jsx)(`span`,{className:`toolcall-path`,title:V.path,children:Lu(V.path)}),V.timeout&&(0,X.jsxs)(`span`,{className:`toolcall-timeout`,children:[`⏱ `,V.timeout]}),O&&V.agent&&(0,X.jsxs)(`span`,{className:`toolcall-agent`,title:V.agent,children:[`◈ `,V.agent]}),(0,X.jsx)(`span`,{className:`toolcall-spacer`}),y&&n&&(0,X.jsxs)(`button`,{type:`button`,className:`toolcall-kill`,title:l(`stopBashTip`),onClick:e=>{e.stopPropagation(),n?.()},children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`span`,{children:l(`stopBash`)})]}),O&&b&&M&&(0,X.jsxs)(`button`,{type:`button`,className:`toolcall-open`,title:l(`delegateOpenSubagent`),onClick:e=>{e.stopPropagation(),window.dispatchEvent(new CustomEvent(`pi-web-ui:switch-conversation`,{detail:M}))},children:[(0,X.jsx)(nt,{}),(0,X.jsx)(`span`,{children:l(`delegateOpenSubagent`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy${g?` copied`:``}`,title:l(`copyArgs`),onClick:e=>{e.stopPropagation(),W()},children:g?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{})}),c!=null&&(0,X.jsx)(`span`,{className:`chead-actions`,onClick:e=>e.stopPropagation(),children:c})]}),T.length>0&&(0,X.jsx)(`div`,{className:`toolcall-images`,children:T.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`toolcall-image`,title:l(`toolImageZoom`),"aria-label":l(`toolImageZoom`),onClick:t=>{t.stopPropagation(),D(e.dataUrl)},children:(0,X.jsx)(`img`,{src:e.dataUrl,alt:`tool result image ${t+1}`})},t))}),E&&(0,k.createPortal)((0,X.jsxs)(`div`,{className:`img-lightbox`,role:`dialog`,"aria-label":l(`toolImageZoom`),onClick:()=>D(null),children:[(0,X.jsx)(`button`,{type:`button`,className:`img-lightbox-close`,title:l(`close`),"aria-label":l(`close`),onClick:e=>{e.stopPropagation(),D(null)},children:(0,X.jsx)(N,{})}),(0,X.jsx)(`img`,{src:E,alt:`tool result preview`})]}),document.body),h&&(0,X.jsxs)(`div`,{className:`toolcall-body`,children:[f&&ee?(0,X.jsx)(gd,{args:ee,details:t.result?.details,toolCallId:t.result?.toolCallId??e.id,resultTimestamp:t.result?.timestamp}):O?(0,X.jsx)(Cd,{args:A}):e.argumentsText&&(0,X.jsx)(`div`,{className:`toolcall-args`,children:H?(0,X.jsx)(Sd,{command:H}):(0,X.jsx)(`pre`,{children:e.argumentsText})}),w.length>0&&(0,X.jsxs)(`div`,{className:`toolcall-output`,children:[(0,X.jsxs)(`div`,{className:`toolcall-output-label`,children:[l(S?`errorOutput`:`output`),(v||x)&&(0,X.jsx)(`span`,{className:`cursor`})]}),(0,X.jsx)(`pre`,{children:w})]}),v&&w.length===0&&(0,X.jsxs)(`div`,{className:`toolcall-waiting`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,l(`waitingOutput`)]}),x&&w.length===0&&(0,X.jsxs)(`div`,{className:`toolcall-waiting`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,l(`waitingModel`)]})]})]})});function Sd({command:e}){return(0,X.jsxs)(`div`,{className:`termline`,children:[(0,X.jsx)(z,{className:`termline-icon`}),(0,X.jsx)(`code`,{children:e})]})}function Cd({args:e}){let t=Z(),n=[{field:`task`,label:t(`delegateSecTask`)},{field:`expected_outcome`,label:t(`delegateSecExpected`)},{field:`required_tools`,label:t(`delegateSecTools`)},{field:`must_do`,label:t(`delegateSecMustDo`)},{field:`must_not_do`,label:t(`delegateSecMustNotDo`)},{field:`context`,label:t(`delegateSecContext`)}].filter(({field:t})=>e[t]?.trim());return n.length===0?null:(0,X.jsx)(`div`,{className:`delegate-brief`,children:n.map(({field:t,label:n})=>(0,X.jsxs)(`div`,{className:`delegate-sec`,children:[(0,X.jsx)(`div`,{className:`delegate-sec-label`,children:n}),(0,X.jsx)(`div`,{className:`delegate-sec-text`,children:e[t]})]},t))})}function wd(e){let t=e.split(`
|
|
335
335
|
`),n=t[0].replace(/\s+/g,` `).trim();if(!n)return;let r=t.length-1,i=n.length>80?`${n.slice(0,80)}…`:n;return r>0?`${i} +${r}`:i}function Td(e){if(e===void 0||e<0||!Number.isFinite(e))return``;if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return`${n}m ${String(r).padStart(2,`0`)}s`}var Ed=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function Dd(e){let t=e.match(Ed);return t?{name:t[1],location:t[2],content:t[3],userMessage:t[4]?.trim()||void 0}:null}var Od=1568,kd=2097152;function Ad(e){return e.startsWith(`image/`)&&e!==`image/svg+xml`&&e!==`image/svg`}async function jd(e){if(!e.type.startsWith(`image/`))return null;let t;try{t=await createImageBitmap(e,{imageOrientation:`from-image`})}catch{return null}try{let n=Math.min(1,Od/Math.max(t.width,t.height)),r=Math.max(1,Math.round(t.width*n)),i=Math.max(1,Math.round(t.height*n)),a=e.type===`image/jpeg`||e.type===`image/jpg`?[[`image/jpeg`,.85],[`image/jpeg`,.6],[`image/webp`,.8]]:[[`image/png`,1],[`image/jpeg`,.85],[`image/jpeg`,.6]],o=null;for(let[n,s]of a){let a=document.createElement(`canvas`);a.width=r,a.height=i;let c=a.getContext(`2d`);if(!c)continue;n!==`image/png`&&(c.fillStyle=`#ffffff`,c.fillRect(0,0,r,i)),c.drawImage(t,0,0,r,i);let l=a.toDataURL(n,s),u=l.match(/^data:([^;]+);base64,/),d=u?u[1]:n,f=l.replace(/^data:[^;]*;base64,/,``),p=Math.floor(f.length*3/4);if(o={data:f,mimeType:d,name:e.name,size:p},p<=kd)return o}return o}finally{t.close()}}function Md(e){let t=[];for(let n of e)n?.type===`text`&&typeof n.text==`string`&&n.text.length>0&&t.push(n.text);return t}function Nd(e){return Md(e).join(`
|
|
336
336
|
|
|
337
337
|
`)}function Pd(e){return Fd(Nd(e))}function Fd(e){let t=e.split(`
|
|
@@ -340,27 +340,27 @@ It only opens after you confirm.`,settingsExtensions:`Extensions`,settingsUiPlug
|
|
|
340
340
|
`).map(e=>e.replace(/[ \t]+/g,` `).replace(/^\s+|\s+$/g,``)).join(`
|
|
341
341
|
`).replace(/\n{3,}/g,`
|
|
342
342
|
|
|
343
|
-
`).trim()}var Id={open:!1,triggerId:``,selectedIds:[],includeTools:!1,includeThinking:!1},Ld=Id,Rd=[],zd=new Set;function Bd(){for(let e of zd)e()}function Vd(e){return(e.role===`user`||e.role===`assistant`)&&Nd(e.content).length>0}function Hd(e,t=Rd){let n=new Map(t.map((e,t)=>[e.id,t]));return[...new Set(e)].filter(e=>n.has(e)).sort((e,t)=>(n.get(e)??0)-(n.get(t)??0))}function Ud(e){if(Rd=e,Ld.open){let e=Hd(Ld.selectedIds,Rd);e.join(`\0`)!==Ld.selectedIds.join(`\0`)&&(Ld={...Ld,selectedIds:e},Bd())}}function Wd(){return Ld}function Gd(e){return zd.add(e),()=>{zd.delete(e)}}function Kd(){return(0,m.useSyncExternalStore)(Gd,Wd,Wd)}function qd(){Ld.open&&(Ld=Id,Bd())}function Jd(e){let t=Rd.find(t=>t.id===e);if(t&&Vd(t)){if(Ld.open){Ld={...Ld,selectedIds:Hd([...Ld.selectedIds,e])},Bd();return}Ld={open:!0,triggerId:e,selectedIds:[e],includeTools:!1,includeThinking:!1},Bd()}}function Yd(e){Ld.open&&(Ld={...Ld,includeTools:e.includeTools??Ld.includeTools,includeThinking:e.includeThinking??Ld.includeThinking},Bd())}function Xd(e){if(!Ld.open||!Rd.filter(Vd).map(e=>e.id).includes(e))return;let t=Ld.selectedIds.includes(e)?Ld.selectedIds.filter(t=>t!==e):Hd([...Ld.selectedIds,e]);Ld={...Ld,selectedIds:t},Bd()}var Zd=null,Qd=new Set;function $d(){for(let e of Qd)e()}function ef(e){Zd=e,$d()}function tf(){Zd=null,$d()}function nf(e){Zd&&($({type:`rollback_session`,messageId:Zd.messageId,conversationId:Zd.conversationId,restoreWorkspace:e}),Zd=null,$d())}function rf(){return(0,m.useSyncExternalStore)(e=>(Qd.add(e),()=>Qd.delete(e)),()=>Zd)}var af=20971520;function of(e){return e.type===`text`&&typeof e.text==`string`?e:null}function sf(e){return e.type===`thinking`&&typeof e.thinking==`string`?e:null}function cf(e){return e.type===`toolCall`&&typeof e.id==`string`&&typeof e.name==`string`?e:null}function lf(e){return e.type===`image`&&typeof e.dataUrl==`string`?e:null}function uf(e){return e.type===`bash`&&typeof e.command==`string`?e:null}function df(e){return e.imageData?`image`:e.uploadPath?`upload`:e.fileData?`file`:`path`}function ff(e,t){if(e.imageData)return t(`attachImage`,{name:e.name??`image`});if(e.uploadPath)return t(`attachFile`,{name:e.name??e.uploadPath});if(e.fileData)return t(`attachFile`,{name:e.name??`file`});let n=e.path.split(`/`).pop()??e.path;return e.mode===`lines`&&e.lines?t(`attachLines`,{path:n,start:e.lines.start,end:e.lines.end}):e.mode===`page`?t(`attachPage`,{name:e.name??e.path}):e.mode===`conversation`?t(`attachConversation`,{name:e.name??e.path}):e.mode===`reference`?t(`refOnly`,{path:n}):t(`attachContent`,{path:n})}var pf={edit:(0,X.jsx)(Pe,{}),copy:(0,X.jsx)(ze,{}),branch:(0,X.jsx)(
|
|
343
|
+
`).trim()}var Id={open:!1,triggerId:``,selectedIds:[],includeTools:!1,includeThinking:!1},Ld=Id,Rd=[],zd=new Set;function Bd(){for(let e of zd)e()}function Vd(e){return(e.role===`user`||e.role===`assistant`)&&Nd(e.content).length>0}function Hd(e,t=Rd){let n=new Map(t.map((e,t)=>[e.id,t]));return[...new Set(e)].filter(e=>n.has(e)).sort((e,t)=>(n.get(e)??0)-(n.get(t)??0))}function Ud(e){if(Rd=e,Ld.open){let e=Hd(Ld.selectedIds,Rd);e.join(`\0`)!==Ld.selectedIds.join(`\0`)&&(Ld={...Ld,selectedIds:e},Bd())}}function Wd(){return Ld}function Gd(e){return zd.add(e),()=>{zd.delete(e)}}function Kd(){return(0,m.useSyncExternalStore)(Gd,Wd,Wd)}function qd(){Ld.open&&(Ld=Id,Bd())}function Jd(e){let t=Rd.find(t=>t.id===e);if(t&&Vd(t)){if(Ld.open){Ld={...Ld,selectedIds:Hd([...Ld.selectedIds,e])},Bd();return}Ld={open:!0,triggerId:e,selectedIds:[e],includeTools:!1,includeThinking:!1},Bd()}}function Yd(e){Ld.open&&(Ld={...Ld,includeTools:e.includeTools??Ld.includeTools,includeThinking:e.includeThinking??Ld.includeThinking},Bd())}function Xd(e){if(!Ld.open||!Rd.filter(Vd).map(e=>e.id).includes(e))return;let t=Ld.selectedIds.includes(e)?Ld.selectedIds.filter(t=>t!==e):Hd([...Ld.selectedIds,e]);Ld={...Ld,selectedIds:t},Bd()}var Zd=null,Qd=new Set;function $d(){for(let e of Qd)e()}function ef(e){Zd=e,$d()}function tf(){Zd=null,$d()}function nf(e){Zd&&($({type:`rollback_session`,messageId:Zd.messageId,conversationId:Zd.conversationId,restoreWorkspace:e}),Zd=null,$d())}function rf(){return(0,m.useSyncExternalStore)(e=>(Qd.add(e),()=>Qd.delete(e)),()=>Zd)}var af=20971520;function of(e){return e.type===`text`&&typeof e.text==`string`?e:null}function sf(e){return e.type===`thinking`&&typeof e.thinking==`string`?e:null}function cf(e){return e.type===`toolCall`&&typeof e.id==`string`&&typeof e.name==`string`?e:null}function lf(e){return e.type===`image`&&typeof e.dataUrl==`string`?e:null}function uf(e){return e.type===`bash`&&typeof e.command==`string`?e:null}function df(e){return e.imageData?`image`:e.uploadPath?`upload`:e.fileData?`file`:`path`}function ff(e,t){if(e.imageData)return t(`attachImage`,{name:e.name??`image`});if(e.uploadPath)return t(`attachFile`,{name:e.name??e.uploadPath});if(e.fileData)return t(`attachFile`,{name:e.name??`file`});let n=e.path.split(`/`).pop()??e.path;return e.mode===`lines`&&e.lines?t(`attachLines`,{path:n,start:e.lines.start,end:e.lines.end}):e.mode===`page`?t(`attachPage`,{name:e.name??e.path}):e.mode===`conversation`?t(`attachConversation`,{name:e.name??e.path}):e.mode===`reference`?t(`refOnly`,{path:n}):t(`attachContent`,{path:n})}var pf={edit:(0,X.jsx)(Pe,{}),copy:(0,X.jsx)(ze,{}),branch:(0,X.jsx)(De,{}),text:(0,X.jsx)(je,{}),markdown:(0,X.jsx)(Be,{}),image:(0,X.jsx)(we,{}),undo:(0,X.jsx)(ae,{}),volume:(0,X.jsx)(P,{}),refresh:(0,X.jsx)(oe,{}),x:(0,X.jsx)(N,{})};function mf(e){let t=(e??``).trim();return t?pf[t.toLowerCase()]||(!/[\p{L}\p{N}]/u.test(t)&&t.length<=4?(0,X.jsx)(`span`,{className:`msg-action-glyph`,children:t}):(0,X.jsx)(M,{})):(0,X.jsx)(M,{})}function hf(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}var gf=(0,m.memo)(function({message:e,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onEdit:o,onKillBash:s,onRetry:c,onCollapse:l,questionAttachments:u,qnIndex:d,qnActive:f,onJump:p,thinkingWrap:h,toolsWrap:g,toolImages:_,searchActive:v,autoExpand:y,uiMessageActions:b,uiContextMessage:x,uiContextToolCall:S,onUiAction:C}){let w=Z(),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(``),[k,A]=(0,m.useState)([]),[ee,j]=(0,m.useState)(!1),[M,F]=(0,m.useState)(null),I=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{I.current&&clearTimeout(I.current)},[]);let L=e=>{F(e),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>F(t=>t===e?null:t),4e3)};if(e.role===`toolResult`||e.role===`system`)return null;if(e.role===`compactionSummary`)return(0,X.jsx)(bf,{message:e,forceOpen:v,autoExpand:y});let R=e.role===`custom`&&e.customType===`file`,te=e.content.map(e=>of(e)?.text??``).filter(Boolean).join(`
|
|
344
344
|
`),z=e.role===`user`?Dd(te):null,B=z?z.userMessage??`skill:${z.name}`:te.split(`
|
|
345
|
-
`).join(` `).trim(),V=i&&a&&e.content.length===0,
|
|
346
|
-
`)).trim();t&&o?.(e.id,t,u&&u.length>0?u:void 0)},
|
|
347
|
-
`)),A(u??[]),E(!0)},oe=()=>{let t=D.trim();t&&(o?.(e.id,t,k.length>0?k:void 0),E(!1))},ce=!b||b.some(e=>e?.id===`host:msg-copy`&&e.hidden!==!0),le=(0,m.useRef)(null),[ue,de]=(0,m.useState)(null),fe=Kd(),pe=(0,m.useRef)(0),me=Nd(e.content),he=(e.role===`assistant`||e.role===`user`)&&me.length>0&&!i,ge=async t=>{try{if(t===`host:msg-copy-text`)await navigator.clipboard.writeText(Pd(e.content));else if(t===`host:msg-copy-markdown`)await navigator.clipboard.writeText(me);else{Jd(e.id);return}window.clearTimeout(pe.current),de({id:t,ok:!0}),pe.current=window.setTimeout(()=>de(null),1600)}catch{window.clearTimeout(pe.current),de({id:t,ok:!1}),pe.current=window.setTimeout(()=>de(null),1600)}},G=hf(Pd(e.content),40)||Cf(e.role,w),[_e,ve]=(0,m.useState)(It());(0,m.useEffect)(()=>Rt(ve),[]);let K=e.role===`assistant`&&Pd(e.content).trim().length>0&&!i&&Dt(),q=K&&Lt()===e.id,ye=()=>{if(q){Bt();return}zt(kt(Pd(e.content)),{...Tt(),enabled:!0},e.id)},[J,be]=(0,m.useState)(!1),xe=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!J)return;let e=e=>{xe.current&&!xe.current.contains(e.target)&&be(!1)},t=e=>{e.key===`Escape`&&be(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[J]);let Se=e=>K?(0,X.jsxs)(`button`,{type:`button`,className:`msg-action${q?` msg-action-speaking`:``}`,title:w(q?`stopSpeakingMsg`:`speakMsg`),"aria-label":w(q?`stopSpeakingMsg`:`speakMsg`),onClick:ye,children:[q?(0,X.jsx)(ne,{}):(0,X.jsx)(P,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:w(q?`stopSpeakingMsg`:`speakMsg`)})]},e):null,Ce=()=>Qr.filter(e=>e.slot===`contextmenu.message`).map(e=>({id:e.id,slot:e.slot,source:`host`,label:w(e.labelKey),labelKey:e.labelKey,icon:e.icon,kind:e.kind,group:e.group,order:e.order??100,align:e.align??`start`,hidden:e.hidden??!1,userOverrides:[],arrangedBy:[]})),Te=t=>{let n=t.target;if(n instanceof Element&&n.closest(`a, input, textarea, [contenteditable='true']`))return;let r=window.getSelection?.();if(r&&!r.isCollapsed&&r.toString().trim().length>0)return;let a=(x&&x.length>0?x:Ce()).map(e=>{if(e.source!==`host`)return e;switch(e.id){case`host:msg-ctx-copy-markdown`:case`host:msg-ctx-copy-text`:case`host:msg-ctx-copy-image`:return he?e:{...e,hidden:!0};case`host:msg-ctx-reask`:case`host:msg-ctx-edit-reask`:return re?e:{...e,hidden:!0};case`host:msg-ctx-fork`:case`host:msg-ctx-rollback`:return!i&&!T?e:{...e,hidden:!0};case`host:msg-ctx-speak`:return K?q?{...e,label:w(`stopSpeakingMsg`),icon:`square`}:e:{...e,hidden:!0};default:return e}});Gi(a).length!==0&&(t.preventDefault(),Pi({x:t.clientX,y:t.clientY,slot:`contextmenu.message`,target:{id:e.id,kind:`message`,label:G},entries:a,onHostAction:t=>{switch(t.id){case`host:msg-ctx-copy-markdown`:ge(`host:msg-copy-markdown`);return;case`host:msg-ctx-copy-text`:ge(`host:msg-copy-text`);return;case`host:msg-ctx-copy-image`:ge(`host:msg-copy-image`);return;case`host:msg-ctx-reask`:ie();return;case`host:msg-ctx-edit-reask`:ae();return;case`host:msg-ctx-fork`:$({type:`fork_session`,messageId:e.id,position:`before`});return;case`host:msg-ctx-rollback`:ef({messageId:e.id});return;case`host:msg-ctx-speak`:ye();return;default:C?.(t);return}}}))},Ee=(e,t)=>{if(!he)return null;let n=[{id:`host:msg-copy-markdown`,label:w(`copyMarkdown`),icon:(0,X.jsx)(Be,{})},{id:`host:msg-copy-text`,label:w(`copyText`),icon:(0,X.jsx)(je,{})},{id:`host:msg-copy-image`,label:w(`copyImage`),icon:(0,X.jsx)(we,{})}].filter(e=>{if(!t)return!0;let n=t.find(t=>t.id===e.id);return!n||n.hidden!==!0});if(n.length===0)return null;let r=ue!==null,i=ue?.ok;return(0,X.jsxs)(`div`,{ref:xe,className:`msg-copy-group${J?` has-open-dropdown`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`msg-action msg-copy-main-btn${i?` msg-copy-success`:``}`,title:w(i?`copied`:r&&!i?`copyFailed`:`copyMarkdown`),"aria-label":w(`copyMarkdown`),onClick:()=>void ge(`host:msg-copy-markdown`),children:[i?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{}),(0,X.jsx)(`span`,{className:`msg-action-label`,children:w(i?`copied`:`copy`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`msg-action msg-copy-caret-btn${J?` active`:``}`,title:w(`copyMessage`),"aria-label":w(`copyMessage`),"aria-expanded":J,onClick:e=>{e.stopPropagation(),be(e=>!e)},children:(0,X.jsx)(Je,{className:`msg-copy-caret-icon${J?` open`:``}`})}),J&&(0,X.jsx)(`div`,{className:`msg-copy-dropdown`,role:`menu`,children:n.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`msg-copy-menu-item`,role:`menuitem`,onClick:()=>{be(!1),ge(e.id)},children:[e.icon,(0,X.jsx)(`span`,{children:e.label})]},e.id))})]},e)},De=()=>{if(!b){let e=Ee(`fb-copy`),t=Se(`fb-speak`);if(!re&&!e&&!t)return null;let n=[];return re&&n.push((0,X.jsxs)(m.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`reaskDirectlyTip`),"aria-label":w(`reaskDirectly`),onClick:ie,children:[(0,X.jsx)(se,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:w(`reaskDirectly`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`editReaskTip`),"aria-label":w(`editReask`),onClick:ae,children:[(0,X.jsx)(Pe,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:w(`editReask`)})]})]},`fb-reask`)),e&&n.push(e),t&&n.push(t),n}let t=[],n=!1;return b.forEach((r,a)=>{if(!r||r.hidden===!0||r.id===`host:msg-copy`)return;let o=`${r.id}#${a}`,s=r.label||r.id;if(r.id===`host:msg-copy-text`||r.id===`host:msg-copy-markdown`||r.id===`host:msg-copy-image`){if(!n){n=!0;let e=Ee(`copy-dropdown`,b);e&&t.push(e)}return}if(r.id===`host:msg-speak`){let e=Se(o);e&&t.push(e);return}if(r.id===`host:msg-reask`){if(!re)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`reaskDirectlyTip`),"aria-label":s,onClick:ie,children:[mf(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-edit-reask`){if(!re)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`editReaskTip`),onClick:ae,children:[mf(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-fork`){if(i||T)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`forkSessionTip`),"aria-label":s,onClick:()=>$({type:`fork_session`,messageId:e.id,position:`before`}),children:[mf(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-rollback`){if(i||T)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`rollbackSessionTip`),"aria-label":s,onClick:()=>{ef({messageId:e.id})},children:[mf(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.kind===`divider`){t.push((0,X.jsx)(`span`,{className:`msg-action-divider`,"aria-hidden":`true`},o));return}if(r.kind===`badge`){t.push((0,X.jsx)(`span`,{className:`msg-action-badge`,title:s,children:r.badge??s},o));return}if(r.kind===`select`&&r.options?.length){t.push((0,X.jsx)(`select`,{className:`msg-action msg-action-select`,title:s,"aria-label":s,value:r.options.some(e=>e.value===r.value)?r.value:r.options[0].value,onChange:e=>C?.(r,e.target.value),children:r.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},o));return}t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:s,"aria-label":s,onClick:()=>C?.(r),children:[mf(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s}),r.badge?(0,X.jsx)(`span`,{className:`msg-action-count`,children:r.badge}):null]},o))}),t.length===0?null:t},Oe=()=>{let e=De();return e?(0,X.jsx)(`div`,{className:`msg-actions${J?` has-open-dropdown`:``}`,children:e}):null},ke=e.role===`custom`&&(e.customType===`goal-review`||e.customType===`goal-wizard`),Y=e.role===`custom`&&e.customType===`goal-wizard`,Ae=e.role===`custom`&&!!e.customType&&e.customType!==`file`&&!ke&&Vl(e.customType),Me=Ae?JSON.stringify({customType:e.customType,details:e.details??{}}):``,Ne=fe.open&&fe.selectedIds.includes(e.id),Fe=fe.open&&he,Ie=Ne&&fe.includeThinking,Le=Ne&&fe.includeTools,Re=T?null:De(),Ve=Re&&!T?e.content.findIndex(e=>sf(e)||cf(e)):-1,He=Ve>=0?Re:null;return(0,X.jsxs)(`div`,{ref:le,className:`msg msg-${e.role}${ke?` msg-goal-review`:``}${He?` msg-head-actions`:``}${Ne?` msg-export-selected`:``}`,"data-role":e.role,"data-msg-id":e.id,onContextMenu:Te,children:[Fe&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:Ne,title:w(`copyImage`),"aria-label":w(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>Xd(e.id)}),(0,X.jsxs)(`div`,{className:`msg-meta`,children:[l&&(0,X.jsxs)(`button`,{type:`button`,className:`msg-collapse-btn`,title:w(`collapseMsg`),onClick:()=>l(e.id),children:[(0,X.jsx)(Ke,{}),` `,w(`collapseMsg`)]}),(0,X.jsx)(`span`,{className:`msg-role`,children:e.role===`custom`?Y?w(`goalWizardCard`):ke?w(`goalBarTitle`):e.customType===`file`?w(`attachment`):`${w(`plugin`)} · ${e.customType??w(`unknown`)}`:Cf(e.role,w)}),e.model&&(0,X.jsx)(`span`,{className:`msg-model`,children:e.model}),e.timestamp&&(0,X.jsx)(`span`,{className:`msg-time`,children:wf(e.timestamp)}),d!==void 0&&p&&(0,X.jsxs)(`button`,{type:`button`,className:`qn-tag ${f?`active`:``}`,title:`${d+1}. ${B}`,"aria-label":`${d+1}. ${B}`,onClick:()=>p(e.id),children:[(0,X.jsx)(`span`,{className:`qn-tag-bar`}),(0,X.jsx)(`span`,{className:`qn-tag-idx`,children:d+1})]})]}),(0,X.jsx)(`div`,{className:`msg-body`,children:T?(0,X.jsxs)(`div`,{className:`msg-editor${ee?` drag-over`:``}`,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),j(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||j(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),j(!1),W(Array.from(e.dataTransfer?.files??[]))},children:[k.length>0&&(0,X.jsx)(`div`,{className:`msg-editor-images`,children:k.map((e,t)=>{let n=df(e);return(0,X.jsxs)(`span`,{className:`msg-editor-img ${n===`image`?``:`file-chip`}`,title:ff(e,w),children:[n===`image`?(0,X.jsx)(`img`,{src:`data:${e.mimeType??`image/png`};base64,${e.imageData}`,alt:e.name}):(0,X.jsxs)(`span`,{className:`msg-editor-file`,children:[(0,X.jsx)(`span`,{className:`msg-editor-file-icon`,children:n===`path`?e.mode===`page`?`🌐`:e.mode===`reference`?`🔗`:`📎`:`📄`}),(0,X.jsx)(`span`,{className:`msg-editor-file-name`,children:e.name??e.path?.split(`/`).pop()})]}),(0,X.jsx)(`button`,{type:`button`,className:`msg-editor-img-remove`,title:w(`removeAttachment`),onClick:()=>A(e=>e.filter((e,n)=>n!==t)),children:(0,X.jsx)(N,{})})]},`${e.name??e.path??`att`}-${t}`)})}),M&&(0,X.jsx)(`div`,{className:`msg-editor-notice`,children:M}),(0,X.jsx)(`textarea`,{className:`msg-editor-input`,value:D,autoFocus:!0,placeholder:w(`editPlaceholder`),rows:Math.max(2,Math.min(10,D.split(`
|
|
348
|
-
`).length+1)),onChange:e=>O(e.target.value),onPaste:e=>{let t=[];for(let n of e.clipboardData?.items??[])if(n.kind===`file`&&Ad(n.type)){let e=n.getAsFile();e&&t.push(e)}t.length!==0&&(e.preventDefault(),
|
|
345
|
+
`).join(` `).trim(),V=i&&a&&e.content.length===0,H=e.role===`user`&&!i&&!V&&!!o,U=async e=>{let t=[];for(let n of e){if(!Ad(n.type))continue;let e=await jd(n);e&&t.push({path:``,imageData:e.data,mimeType:e.mimeType,name:e.name})}t.length>0&&A(e=>[...e,...t])},W=async e=>{if(e.size>af){L(w(`fileTooLarge`,{name:e.name,size:20}));return}let t;try{t=(await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(e)})).replace(/^data:[^;]*;base64,/,``)}catch{L(w(`fileLoadFailed`,{name:e.name}));return}A(n=>[...n,{path:``,fileData:t,name:e.name,size:e.size,mimeType:e.type||void 0}])},G=async e=>{let t=[];for(let n of e)Ad(n.type)?t.push(n):W(n);t.length>0&&await U(t)},re=()=>{let t=(z?`/skill:`+z.name+(z.userMessage?` `+z.userMessage:``):e.content.map(e=>of(e)?.text??``).filter(Boolean).join(`
|
|
346
|
+
`)).trim();t&&o?.(e.id,t,u&&u.length>0?u:void 0)},ie=()=>{O(z?`/skill:${z.name}${z.userMessage?` ${z.userMessage}`:``}`:e.content.map(e=>of(e)?.text??``).filter(Boolean).join(`
|
|
347
|
+
`)),A(u??[]),E(!0)},ae=()=>{let t=D.trim();t&&(o?.(e.id,t,k.length>0?k:void 0),E(!1))},se=!b||b.some(e=>e?.id===`host:msg-copy`&&e.hidden!==!0),ce=(0,m.useRef)(null),[le,ue]=(0,m.useState)(null),de=Kd(),fe=(0,m.useRef)(0),pe=Nd(e.content),me=(e.role===`assistant`||e.role===`user`)&&pe.length>0&&!i,he=async t=>{try{if(t===`host:msg-copy-text`)await navigator.clipboard.writeText(Pd(e.content));else if(t===`host:msg-copy-markdown`)await navigator.clipboard.writeText(pe);else{Jd(e.id);return}window.clearTimeout(fe.current),ue({id:t,ok:!0}),fe.current=window.setTimeout(()=>ue(null),1600)}catch{window.clearTimeout(fe.current),ue({id:t,ok:!1}),fe.current=window.setTimeout(()=>ue(null),1600)}},K=hf(Pd(e.content),40)||Cf(e.role,w),[ge,_e]=(0,m.useState)(It());(0,m.useEffect)(()=>Rt(_e),[]);let ve=e.role===`assistant`&&Pd(e.content).trim().length>0&&!i&&Dt(),q=ve&&Lt()===e.id,ye=()=>{if(q){Bt();return}zt(kt(Pd(e.content)),{...Tt(),enabled:!0},e.id)},[J,be]=(0,m.useState)(!1),xe=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!J)return;let e=e=>{xe.current&&!xe.current.contains(e.target)&&be(!1)},t=e=>{e.key===`Escape`&&be(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[J]);let Se=e=>ve?(0,X.jsxs)(`button`,{type:`button`,className:`msg-action${q?` msg-action-speaking`:``}`,title:w(q?`stopSpeakingMsg`:`speakMsg`),"aria-label":w(q?`stopSpeakingMsg`:`speakMsg`),onClick:ye,children:[q?(0,X.jsx)(ne,{}):(0,X.jsx)(P,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:w(q?`stopSpeakingMsg`:`speakMsg`)})]},e):null,Ce=()=>Qr.filter(e=>e.slot===`contextmenu.message`).map(e=>({id:e.id,slot:e.slot,source:`host`,label:w(e.labelKey),labelKey:e.labelKey,icon:e.icon,kind:e.kind,group:e.group,order:e.order??100,align:e.align??`start`,hidden:e.hidden??!1,userOverrides:[],arrangedBy:[]})),Te=t=>{let n=t.target;if(n instanceof Element&&n.closest(`a, input, textarea, [contenteditable='true']`))return;let r=window.getSelection?.();if(r&&!r.isCollapsed&&r.toString().trim().length>0)return;let a=(x&&x.length>0?x:Ce()).map(e=>{if(e.source!==`host`)return e;switch(e.id){case`host:msg-ctx-copy-markdown`:case`host:msg-ctx-copy-text`:case`host:msg-ctx-copy-image`:return me?e:{...e,hidden:!0};case`host:msg-ctx-reask`:case`host:msg-ctx-edit-reask`:return H?e:{...e,hidden:!0};case`host:msg-ctx-fork`:case`host:msg-ctx-rollback`:return!i&&!T?e:{...e,hidden:!0};case`host:msg-ctx-speak`:return ve?q?{...e,label:w(`stopSpeakingMsg`),icon:`square`}:e:{...e,hidden:!0};default:return e}});Gi(a).length!==0&&(t.preventDefault(),Pi({x:t.clientX,y:t.clientY,slot:`contextmenu.message`,target:{id:e.id,kind:`message`,label:K},entries:a,onHostAction:t=>{switch(t.id){case`host:msg-ctx-copy-markdown`:he(`host:msg-copy-markdown`);return;case`host:msg-ctx-copy-text`:he(`host:msg-copy-text`);return;case`host:msg-ctx-copy-image`:he(`host:msg-copy-image`);return;case`host:msg-ctx-reask`:re();return;case`host:msg-ctx-edit-reask`:ie();return;case`host:msg-ctx-fork`:$({type:`fork_session`,messageId:e.id,position:`before`});return;case`host:msg-ctx-rollback`:ef({messageId:e.id});return;case`host:msg-ctx-speak`:ye();return;default:C?.(t);return}}}))},Ee=(e,t)=>{if(!me)return null;let n=[{id:`host:msg-copy-markdown`,label:w(`copyMarkdown`),icon:(0,X.jsx)(Be,{})},{id:`host:msg-copy-text`,label:w(`copyText`),icon:(0,X.jsx)(je,{})},{id:`host:msg-copy-image`,label:w(`copyImage`),icon:(0,X.jsx)(we,{})}].filter(e=>{if(!t)return!0;let n=t.find(t=>t.id===e.id);return!n||n.hidden!==!0});if(n.length===0)return null;let r=le!==null,i=le?.ok;return(0,X.jsxs)(`div`,{ref:xe,className:`msg-copy-group${J?` has-open-dropdown`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`msg-action msg-copy-main-btn${i?` msg-copy-success`:``}`,title:w(i?`copied`:r&&!i?`copyFailed`:`copyMarkdown`),"aria-label":w(`copyMarkdown`),onClick:()=>void he(`host:msg-copy-markdown`),children:[i?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{}),(0,X.jsx)(`span`,{className:`msg-action-label`,children:w(i?`copied`:`copy`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`msg-action msg-copy-caret-btn${J?` active`:``}`,title:w(`copyMessage`),"aria-label":w(`copyMessage`),"aria-expanded":J,onClick:e=>{e.stopPropagation(),be(e=>!e)},children:(0,X.jsx)(Je,{className:`msg-copy-caret-icon${J?` open`:``}`})}),J&&(0,X.jsx)(`div`,{className:`msg-copy-dropdown`,role:`menu`,children:n.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`msg-copy-menu-item`,role:`menuitem`,onClick:()=>{be(!1),he(e.id)},children:[e.icon,(0,X.jsx)(`span`,{children:e.label})]},e.id))})]},e)},Y=()=>{if(!b){let e=Ee(`fb-copy`),t=Se(`fb-speak`);if(!H&&!e&&!t)return null;let n=[];return H&&n.push((0,X.jsxs)(m.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`reaskDirectlyTip`),"aria-label":w(`reaskDirectly`),onClick:re,children:[(0,X.jsx)(oe,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:w(`reaskDirectly`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`editReaskTip`),"aria-label":w(`editReask`),onClick:ie,children:[(0,X.jsx)(Pe,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:w(`editReask`)})]})]},`fb-reask`)),e&&n.push(e),t&&n.push(t),n}let t=[],n=!1;return b.forEach((r,a)=>{if(!r||r.hidden===!0||r.id===`host:msg-copy`)return;let o=`${r.id}#${a}`,s=r.label||r.id;if(r.id===`host:msg-copy-text`||r.id===`host:msg-copy-markdown`||r.id===`host:msg-copy-image`){if(!n){n=!0;let e=Ee(`copy-dropdown`,b);e&&t.push(e)}return}if(r.id===`host:msg-speak`){let e=Se(o);e&&t.push(e);return}if(r.id===`host:msg-reask`){if(!H)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`reaskDirectlyTip`),"aria-label":s,onClick:re,children:[mf(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-edit-reask`){if(!H)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`editReaskTip`),onClick:ie,children:[mf(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-fork`){if(i||T)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`forkSessionTip`),"aria-label":s,onClick:()=>$({type:`fork_session`,messageId:e.id,position:`before`}),children:[mf(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-rollback`){if(i||T)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`rollbackSessionTip`),"aria-label":s,onClick:()=>{ef({messageId:e.id})},children:[mf(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.kind===`divider`){t.push((0,X.jsx)(`span`,{className:`msg-action-divider`,"aria-hidden":`true`},o));return}if(r.kind===`badge`){t.push((0,X.jsx)(`span`,{className:`msg-action-badge`,title:s,children:r.badge??s},o));return}if(r.kind===`select`&&r.options?.length){t.push((0,X.jsx)(`select`,{className:`msg-action msg-action-select`,title:s,"aria-label":s,value:r.options.some(e=>e.value===r.value)?r.value:r.options[0].value,onChange:e=>C?.(r,e.target.value),children:r.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},o));return}t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:s,"aria-label":s,onClick:()=>C?.(r),children:[mf(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s}),r.badge?(0,X.jsx)(`span`,{className:`msg-action-count`,children:r.badge}):null]},o))}),t.length===0?null:t},De=()=>{let e=Y();return e?(0,X.jsx)(`div`,{className:`msg-actions${J?` has-open-dropdown`:``}`,children:e}):null},Oe=e.role===`custom`&&(e.customType===`goal-review`||e.customType===`goal-wizard`),ke=e.role===`custom`&&e.customType===`goal-wizard`,Ae=e.role===`custom`&&!!e.customType&&e.customType!==`file`&&!Oe&&Vl(e.customType),Me=Ae?JSON.stringify({customType:e.customType,details:e.details??{}}):``,Ne=de.open&&de.selectedIds.includes(e.id),Fe=de.open&&me,Ie=Ne&&de.includeThinking,Le=Ne&&de.includeTools,Re=T?null:Y(),Ve=Re&&!T?e.content.findIndex(e=>sf(e)||cf(e)):-1,He=Ve>=0?Re:null;return(0,X.jsxs)(`div`,{ref:ce,className:`msg msg-${e.role}${Oe?` msg-goal-review`:``}${He?` msg-head-actions`:``}${Ne?` msg-export-selected`:``}`,"data-role":e.role,"data-msg-id":e.id,onContextMenu:Te,children:[Fe&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:Ne,title:w(`copyImage`),"aria-label":w(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>Xd(e.id)}),(0,X.jsxs)(`div`,{className:`msg-meta`,children:[l&&(0,X.jsxs)(`button`,{type:`button`,className:`msg-collapse-btn`,title:w(`collapseMsg`),onClick:()=>l(e.id),children:[(0,X.jsx)(Ke,{}),` `,w(`collapseMsg`)]}),(0,X.jsx)(`span`,{className:`msg-role`,children:e.role===`custom`?ke?w(`goalWizardCard`):Oe?w(`goalBarTitle`):e.customType===`file`?w(`attachment`):`${w(`plugin`)} · ${e.customType??w(`unknown`)}`:Cf(e.role,w)}),e.model&&(0,X.jsx)(`span`,{className:`msg-model`,children:e.model}),e.timestamp&&(0,X.jsx)(`span`,{className:`msg-time`,children:wf(e.timestamp)}),d!==void 0&&p&&(0,X.jsxs)(`button`,{type:`button`,className:`qn-tag ${f?`active`:``}`,title:`${d+1}. ${B}`,"aria-label":`${d+1}. ${B}`,onClick:()=>p(e.id),children:[(0,X.jsx)(`span`,{className:`qn-tag-bar`}),(0,X.jsx)(`span`,{className:`qn-tag-idx`,children:d+1})]})]}),(0,X.jsx)(`div`,{className:`msg-body`,children:T?(0,X.jsxs)(`div`,{className:`msg-editor${ee?` drag-over`:``}`,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),j(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||j(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),j(!1),G(Array.from(e.dataTransfer?.files??[]))},children:[k.length>0&&(0,X.jsx)(`div`,{className:`msg-editor-images`,children:k.map((e,t)=>{let n=df(e);return(0,X.jsxs)(`span`,{className:`msg-editor-img ${n===`image`?``:`file-chip`}`,title:ff(e,w),children:[n===`image`?(0,X.jsx)(`img`,{src:`data:${e.mimeType??`image/png`};base64,${e.imageData}`,alt:e.name}):(0,X.jsxs)(`span`,{className:`msg-editor-file`,children:[(0,X.jsx)(`span`,{className:`msg-editor-file-icon`,children:n===`path`?e.mode===`page`?`🌐`:e.mode===`reference`?`🔗`:`📎`:`📄`}),(0,X.jsx)(`span`,{className:`msg-editor-file-name`,children:e.name??e.path?.split(`/`).pop()})]}),(0,X.jsx)(`button`,{type:`button`,className:`msg-editor-img-remove`,title:w(`removeAttachment`),onClick:()=>A(e=>e.filter((e,n)=>n!==t)),children:(0,X.jsx)(N,{})})]},`${e.name??e.path??`att`}-${t}`)})}),M&&(0,X.jsx)(`div`,{className:`msg-editor-notice`,children:M}),(0,X.jsx)(`textarea`,{className:`msg-editor-input`,value:D,autoFocus:!0,placeholder:w(`editPlaceholder`),rows:Math.max(2,Math.min(10,D.split(`
|
|
348
|
+
`).length+1)),onChange:e=>O(e.target.value),onPaste:e=>{let t=[];for(let n of e.clipboardData?.items??[])if(n.kind===`file`&&Ad(n.type)){let e=n.getAsFile();e&&t.push(e)}t.length!==0&&(e.preventDefault(),U(t))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),ae()):e.key===`Escape`&&E(!1)}}),(0,X.jsxs)(`div`,{className:`msg-editor-actions`,children:[(0,X.jsxs)(`span`,{className:`msg-editor-hint`,children:[(0,X.jsx)(we,{}),` `,w(`editAttachmentHint`)]}),(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>E(!1),children:w(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`chip primary`,disabled:!D.trim(),title:w(`reaskFromHere`),onClick:ae,children:[(0,X.jsx)(Pe,{}),` `,w(`reaskFromHere`)]})]})]}):(0,X.jsxs)(X.Fragment,{children:[e.errorMessage&&(0,X.jsxs)(`div`,{className:`msg-error`,children:[(0,X.jsx)(`span`,{className:`msg-error-text`,children:e.errorMessage}),a&&!i&&c&&(0,X.jsxs)(`button`,{type:`button`,className:`msg-retry-btn`,title:w(`retryLastTip`),onClick:c,children:[(0,X.jsx)(oe,{}),` `,w(`retryNow`)]})]}),R?(0,X.jsx)(_f,{message:e,forceOpen:v}):z?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(xf,{block:z,forceOpen:v}),z.userMessage&&(0,X.jsx)(`div`,{className:`msg-text`,children:(0,X.jsx)(uu,{text:z.userMessage,hardBreaks:!0})}),e.content.map((o,c)=>o.type===`text`?null:(0,X.jsx)(Sf,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:g,toolImages:_,thinkingWrap:h,searchActive:v,forceThinking:Ie,forceTools:Le,role:e.role,showCopy:se,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`))]}):Ae?(0,X.jsx)(hu,{type:e.customType??``,code:Me,children:e.content.map((o,c)=>(0,X.jsx)(Sf,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:g,toolImages:_,thinkingWrap:h,searchActive:v,forceThinking:Ie,forceTools:Le,role:e.role,showCopy:se,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`))}):e.content.map((o,c)=>(0,X.jsx)(Sf,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:g,toolImages:_,thinkingWrap:h,searchActive:v,forceThinking:Ie,forceTools:Le,role:e.role,showCopy:se,uiContextToolCall:S,onUiAction:C,headActions:c===Ve?He:void 0},`${e.id}-${c}`)),V&&(0,X.jsxs)(`div`,{className:`thinking-wait`,children:[w(`thinkingWait`),(0,X.jsx)(`span`,{className:`dot`})]}),i&&a&&!V&&(0,X.jsx)(`span`,{className:`stream-cursor`})]})}),!T&&!He&&De()]})});function _f({message:e,forceOpen:t=!1}){let n=Z(),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(!1),s=r||t,c=e.details??{},l=c.name??c.path??n(`attachment`),u=c.type===`folder`,d=c.mode===`reference`,f=c.mode===`bridged`,p=c.mode===`page`,h=c.mode===`conversation`,g=c.path&&/^https?:\/\//i.test(c.path.trim())?c.path.trim():null,_=yf(e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
349
349
|
`)),v=e.content.find(e=>e.type===`image`),y=_.split(`
|
|
350
350
|
`).length,b=!d&&!p&&!h&&_.length>0;return(0,X.jsxs)(`div`,{className:`attachcard ${d?`reference`:``}${p?` page`:``}${h?` conversation`:``}`,children:[(0,X.jsxs)(`div`,{className:`chead attachcard-head`,role:`button`,tabIndex:0,"aria-expanded":s,title:n(s?`collapseMsg`:`expandMsg`),onClick:()=>i(e=>t?!0:!e),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i(e=>t?!0:!e))},children:[!d&&!p&&!h&&(0,X.jsx)(`span`,{className:`chead-toggle`,children:s?(0,X.jsx)(Je,{}):(0,X.jsx)(qe,{})}),(0,X.jsx)(`span`,{className:`chead-icon attachcard-icon`,children:u?`📁`:p?`🌐`:h?`💬`:`📎`}),(0,X.jsx)(`span`,{className:`chead-title attachcard-name`,children:l}),c.path&&(p&&g?(0,X.jsx)(`a`,{className:`attachcard-path attachcard-link`,href:g,target:`_blank`,rel:`noreferrer`,children:c.path}):(0,X.jsx)(`span`,{className:`attachcard-path`,children:c.path})),(0,X.jsx)(`span`,{className:`attachcard-mode ${c.mode===`lines`?`lines`:d?`ref`:p?`page`:h?`conversation`:f?`bridged`:`inline`}`,children:p?n(`attachPageShort`):h?n(`attachConversationShort`):d?u?n(`folderRefShort`):`${n(`refOnlyShort`)} · ${vf(c.size)}`:f?n(`bridgedVision`):v?n(`image`):c.mode===`lines`?n(`inlineLinesRange`,{start:c.startLine??1,end:c.endLine??c.lines??1}):n(`inlineLines`,{n:c.lines??y})}),b&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:n(a?`copied`:`copyMessage`),"aria-label":n(`copyMessage`),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(_),o(!0),window.setTimeout(()=>o(!1),1200)},children:a?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{})})]}),!d&&s&&(f?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`attachcard-bridgenote`,children:n(`bridgedVisionDetail`)}),v?.dataUrl&&(0,X.jsx)(`div`,{className:`attachcard-image`,children:(0,X.jsx)(`img`,{src:v.dataUrl,alt:l})}),_&&(0,X.jsx)(`pre`,{className:`attachcard-content`,children:_})]}):v?.dataUrl?(0,X.jsx)(`div`,{className:`attachcard-image`,children:(0,X.jsx)(`img`,{src:v.dataUrl,alt:l})}):(0,X.jsx)(`pre`,{className:`attachcard-content`,children:_})),d&&(0,X.jsx)(`div`,{className:`attachcard-refnote`,children:u?n(`folderNotExpanded`):n(`fileNotExpanded`,{size:vf(c.size)})})]})}function vf(e){return e===void 0?``:e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function yf(e){let t=e.match(/^\s*<file path="[^"]*"(?:\s+lines="[^"]*")?>\s*```\s*\n?([\s\S]*?)\n?```\s*<\/file>\s*$/);if(t)return t[1].trim();let n=e.match(/^\s*<vision-bridge>\s*([\s\S]*?)\s*<\/vision-bridge>\s*$/);return n?n[1].trim():e.trim()}function bf({message:e,forceOpen:t=!1,autoExpand:n=!1}){let r=Z(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(n);n!==c&&(l(n),n&&a(!0));let u=i||t,d=e.content.map(e=>of(e)?.text??``).filter(Boolean).join(`
|
|
351
351
|
`),f=typeof e.tokensBefore==`number`?e.tokensBefore.toLocaleString():null;return(0,X.jsxs)(`div`,{className:`msg msg-compactionSummary`,"data-role":e.role,"data-msg-id":e.id,children:[(0,X.jsxs)(`div`,{className:`msg-meta`,children:[(0,X.jsx)(`span`,{className:`msg-role`,children:r(`role.compaction`)}),e.timestamp&&(0,X.jsx)(`span`,{className:`msg-time`,children:wf(e.timestamp)})]}),(0,X.jsxs)(`div`,{className:`compaction-card${i?` expanded`:``}`,children:[(0,X.jsxs)(`div`,{className:`chead compaction-head`,role:`button`,tabIndex:0,"aria-expanded":u,title:r(u?`collapseMsg`:`expandMsg`),onClick:()=>a(e=>t?!0:!e),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a(e=>t?!0:!e))},children:[(0,X.jsx)(`span`,{className:`chead-toggle`,children:u?(0,X.jsx)(Je,{}):(0,X.jsx)(qe,{})}),(0,X.jsx)(`span`,{className:`chead-icon compaction-icon`,children:(0,X.jsx)(it,{})}),(0,X.jsx)(`span`,{className:`chead-title compaction-title`,children:f?r(`compactionFrom`,{tokens:f}):r(`role.compaction`)}),d&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:r(o?`copied`:`copyMessage`),"aria-label":r(`copyMessage`),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(d),s(!0),window.setTimeout(()=>s(!1),1200)},children:o?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{})})]}),u&&(0,X.jsxs)(`div`,{className:`compaction-body`,children:[(0,X.jsx)(uu,{text:d}),(0,X.jsx)(`div`,{className:`compaction-hint`,children:r(`compactionKeptHint`)})]})]})]})}function xf({block:e,forceOpen:t=!1}){let n=Z(),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(!1),s=r||t;return(0,X.jsxs)(`div`,{className:`skillcard${r?` expanded`:``}`,children:[(0,X.jsxs)(`div`,{className:`chead skillcard-head`,role:`button`,tabIndex:0,"aria-expanded":s,title:e.location,onClick:()=>i(e=>t?!0:!e),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i(e=>t?!0:!e))},children:[(0,X.jsx)(`span`,{className:`chead-toggle`,children:s?(0,X.jsx)(Je,{}):(0,X.jsx)(qe,{})}),(0,X.jsx)(`span`,{className:`chead-icon skillcard-icon`,children:(0,X.jsx)($e,{})}),(0,X.jsx)(`span`,{className:`chead-title skillcard-name`,children:e.name}),(0,X.jsx)(`span`,{className:`skillcard-path`,children:e.location}),(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:n(a?`copied`:`copyMessage`),"aria-label":n(`copyMessage`),onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.content),o(!0),window.setTimeout(()=>o(!1),1200)},children:a?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{})})]}),s&&(0,X.jsx)(`div`,{className:`skillcard-body`,children:(0,X.jsx)(uu,{text:e.content})})]})}function Sf({block:e,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:o,thinkingWrap:s,toolsWrap:c,toolImages:l,searchActive:u,forceThinking:d,forceTools:f,role:p,showCopy:h,uiContextToolCall:g,onUiAction:_,headActions:v}){let y=Z(),[b,x]=(0,m.useState)(!1),S=of(e);if(S){let e=i&&a,t=(p===`assistant`||p===`user`)&&h!==!1,n=t&&!S.text.includes(`
|
|
352
352
|
`)&&!S.truncated,r=p===`user`?(0,X.jsx)(uu,{text:S.text,hardBreaks:!0}):e?(0,X.jsx)(wu,{text:S.text}):(0,X.jsx)(uu,{text:S.text});return(0,X.jsxs)(`div`,{className:`msg-text${n?` single`:``}`,children:[n?(0,X.jsx)(`div`,{className:`msg-text-main`,children:r}):(0,X.jsxs)(X.Fragment,{children:[r,S.truncated&&(0,X.jsx)(`div`,{className:`trunc-note`,children:y(`truncated`)})]}),t?(0,X.jsx)(`button`,{type:`button`,className:`msg-text-copy${b?` copied`:``}`,title:y(b?`copied`:`copyMessage`),"aria-label":y(`copyMessage`),onClick:()=>{navigator.clipboard.writeText(S.text),x(!0),window.setTimeout(()=>x(!1),1200)},children:b?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{})}):null]})}let C=sf(e);if(C)return(0,X.jsx)(Eu,{thinking:C.thinking,streaming:i&&a,wrap:s,forceOpen:u||d,headExtra:v});let w=cf(e);if(w){let e={result:t.get(w.id),liveOutput:n.get(w.id)?.text,streaming:i,status:r.get(w.id)};return(0,X.jsx)(xd,{block:w,view:e,onKillBash:o,wrap:c,showImages:l??!0,forceOpen:u||f,uiContextToolCall:g,onUiAction:_,headExtra:v})}let T=lf(e);if(T&&T.dataUrl)return(0,X.jsx)(`div`,{className:`msg-image`,children:(0,X.jsx)(`img`,{src:T.dataUrl,alt:`attachment`})});let E=uf(e);return E?(0,X.jsxs)(`div`,{className:`bashblock`,children:[(0,X.jsxs)(`div`,{className:`bashblock-command`,children:[(0,X.jsx)(`span`,{className:`bashblock-prompt`,children:`$`}),(0,X.jsx)(`code`,{children:E.command}),E.exitCode!==void 0&&(0,X.jsx)(`span`,{className:`bashblock-exit ${E.exitCode===0?`ok`:`err`}`,children:y(`exitCode`,{code:E.exitCode})}),E.cancelled&&(0,X.jsx)(`span`,{className:`bashblock-exit err`,children:y(`cancelled`)})]}),E.output&&(0,X.jsx)(`pre`,{className:`bashblock-output`,children:E.output}),E.truncated&&(0,X.jsx)(`div`,{className:`trunc-note`,children:y(`outputTruncated`)})]}):null}function Cf(e,t){switch(e){case`user`:return t(`role.user`);case`assistant`:return t(`role.assistant`);case`toolResult`:return t(`role.tool`);case`bashExecution`:return t(`role.bash`);case`branchSummary`:return t(`role.branch`);case`compactionSummary`:return t(`role.compaction`);default:return e}}function wf(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Tf(e,t,n){let r=!1;for(let i of t){let t=i;if(t.type!==`image`||typeof t.dataUrl!=`string`||!t.dataUrl.startsWith(`data:`))continue;let a=t.dataUrl.match(/^data:([^;]*);base64,(.+)$/);a&&(r=!0,e.push({path:``,imageData:a[2],mimeType:a[1]||`image/png`,name:n??`image.${(a[1]||`image/png`).split(`/`)[1]??`png`}`}))}return r}function Ef(e){let t=new Map;for(let n=0;n<e.length;n++){let r=e[n];if(r.role!==`user`||!r.id)continue;let i=[];Tf(i,r.content);for(let t=n+1;t<e.length&&e[t].role===`custom`&&e[t].customType===`file`;t++){let n=e[t].details??{};if(!Tf(i,e[t].content,n.name)){if(n.upload&&n.path){i.push({path:``,uploadPath:n.path,name:n.name??n.path,size:n.size});continue}if(n.mode===`page`&&n.path){i.push({path:n.path,mode:`page`,name:n.name??n.path});continue}if(n.mode===`conversation`){let e=n,t=typeof e.conversationId==`string`&&e.conversationId?e.conversationId:void 0,r=typeof e.sessionPath==`string`&&e.sessionPath?e.sessionPath:void 0;(t||r)&&i.push({path:``,mode:`conversation`,name:n.name??t??r,...t?{conversationId:t}:{},...r?{sessionPath:r}:{}});continue}if(n.path&&n.mode){let e=n.mode===`lines`?`lines`:`reference`,t={path:n.path,mode:e};n.mode===`lines`&&typeof n.startLine==`number`&&typeof n.endLine==`number`&&(t.lines={start:n.startLine,end:n.endLine}),i.push(t)}}}i.length>0&&t.set(r.id,i)}return t}var Df=(0,m.memo)(function({message:e,onExpand:t}){let n=Z(),r=Kd(),i=Vd(e),a=r.open&&r.selectedIds.includes(e.id),o=r.open&&i,s=``;for(let t of e.content){let e=of(t);if(e&&e.text.trim()){let t=Dd(e.text);s=t?`skill:${t.name}`+(t.userMessage?` · ${t.userMessage.replace(/\s+/g,` `).trim()}`:``):e.text.replace(/\s+/g,` `).trim();break}}if(!s&&e.role===`custom`&&e.customType===`file`){let t=e.details??{};s=t.name??t.path??``}s.length>90&&(s=`${s.slice(0,90)}…`);let c=0,l=0,u=0,d=0;for(let t of e.content)sf(t)?c++:cf(t)?l++:uf(t)?u++:lf(t)&&d++;let f=[];return c&&f.push(`${n(`thinking`)} ${c}`),l&&f.push(`${n(`toolCalls`)} ${l}`),u&&f.push(`${n(`bashRuns`)} ${u}`),d&&f.push(`${n(`images`)} ${d}`),(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,className:`msg-collapsed${a?` msg-export-selected`:``}`,"data-msg-id":e.id,title:`${n(`expandMsg`)} · ${s||f.join(` · `)||e.role}`,onClick:()=>t(e.id),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.id))},children:[o&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:a,title:n(`copyImage`),"aria-label":n(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>Xd(e.id)}),(0,X.jsx)(`span`,{className:`msg-collapsed-role role-${e.role}`,children:e.role===`custom`&&e.customType===`file`?n(`attachment`):Cf(e.role,n)}),(0,X.jsxs)(`span`,{className:`msg-collapsed-body`,children:[s&&(0,X.jsx)(`span`,{className:`msg-collapsed-preview`,children:s}),f.length>0&&(0,X.jsx)(`span`,{className:`msg-collapsed-chips`,children:f.map((e,t)=>(0,X.jsx)(`span`,{className:`msg-collapsed-chip`,children:e},t))})]}),e.timestamp?(0,X.jsx)(`span`,{className:`msg-collapsed-time`,children:Of(e.timestamp)}):null,(0,X.jsx)(`span`,{className:`msg-collapsed-action`,children:n(`expandMsg`)})]})});function Of(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}var kf=(0,m.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,m.useRef)(null),c=(0,m.useRef)(null);return(0,m.useLayoutEffect)(()=>{let a=c.current;if(c.current=t,!t||a!==!1)return;let o=s.current,l=r.current;if(!o||!l)return;let u=o.offsetHeight;i?.(e,u);let d=u-n;if(d!==0){let e=o.parentElement;e&&e.getBoundingClientRect().bottom<=l.getBoundingClientRect().top&&(l.scrollTop+=d)}},[t]),t?(0,X.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,X.jsx)(`div`,{ref:s,children:o})}):(0,X.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})});function Af(e,t,n,r){let i=[],a=[],o=0;for(let s of e)n.has(s.id)||(s.top<t.bottom&&s.bottom>t.top?r.has(s.id)&&i.push(s.id):r.has(s.id)||(a.push(s.id),s.bottom<=t.top&&(o+=s.bottom-s.top)));return{show:i,hide:a,shrinkAbove:o}}function jf(e,t){if(t.show.length===0&&t.hide.length===0)return e;let n=new Set(e);for(let e of t.show)n.delete(e);for(let e of t.hide)n.add(e);return n}function Mf(e,t,n){let r=new Set,i=0;for(let a=e.length-1;a>=0&&!(a<e.length-1&&i>=n);a--){let n=e[a];r.add(n.id),i+=t.get(n.id)??Nf(n.role,n.customType)}return r}function Nf(e,t){switch(e){case`user`:return 72;case`assistant`:return 280;case`toolResult`:return 8;case`custom`:return t===`file`?96:72;default:return 60}}var Pf=[`text`,`thinking`,`argumentsText`,`output`,`command`];function Ff(e){let t=0;for(let n of e.content){n.type===`image`&&(t+=1);for(let e of Pf){let r=n[e];typeof r==`string`&&(t+=r.length)}}return t}function If(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function Lf(e){let t=[];for(let n of e.content)n.type===`text`&&typeof n.text==`string`&&t.push(n.text);return t.join(`
|
|
353
353
|
`)}function Rf(e,t){let n=[];for(let r of e.content)if(r.type===`text`&&typeof r.text==`string`)n.push(r.text);else if(r.type===`thinking`&&typeof r.thinking==`string`)n.push(r.thinking);else if(r.type===`toolCall`){if(typeof r.name==`string`&&n.push(r.name),typeof r.argumentsText==`string`&&n.push(r.argumentsText),typeof r.id==`string`){let e=t.get(r.id);if(e){let t=Lf(e);t&&n.push(t)}}}else r.type===`bash`&&(typeof r.command==`string`&&n.push(r.command),typeof r.output==`string`&&n.push(r.output));return n.join(`
|
|
354
|
-
`)}function zf(e,t){let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}function Bf(e,t,n,r){let i=new Map,a=n.toLowerCase();if(!a)return i;for(let n of e){if(!t.has(n.id))continue;let e=zf(Rf(n,r).toLowerCase(),a);e>0&&i.set(n.id,e)}return i}function Vf(e,t){let n=[],r=t.toLowerCase();if(!r)return n;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!t||t.closest(`.search-bar`)||t.closest(`.msg-collapsed`)?NodeFilter.FILTER_REJECT:(e.textContent??``).toLowerCase().includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let e=i.nextNode();e;e=i.nextNode()){let t=(e.textContent??``).toLowerCase();if(!e.parentElement?.closest(`[data-msg-id]`))continue;let i=t.indexOf(r);for(;i!==-1;){let a=document.createRange();a.setStart(e,i),a.setEnd(e,i+r.length),n.push(a),i=t.indexOf(r,i+r.length)}}return n}function Hf(e,t,n,r,i){let a=Bf(n,r,t,i),o=new Map;for(let n of Vf(e,t)){let e=n.startContainer.parentElement?.closest(`[data-msg-id]`);if(!e?.dataset.msgId)continue;let t=o.get(e.dataset.msgId);t?t.push(n):o.set(e.dataset.msgId,[n])}let s=[];for(let e of n){let t=o.get(e.id);if(t)for(let n=0;n<t.length;n++)s.push({kind:`dom`,range:t[n],msgId:e.id,k:n});let n=a.get(e.id);if(n)for(let t=0;t<n;t++)s.push({kind:`folded`,msgId:e.id,k:t})}return s}function Uf(e,t){return e.findIndex(e=>e.msgId===t.msgId&&e.k===t.k)}function Wf(e,t){let n=CSS;if(!n.highlights)return;if(t.length===0){n.highlights.delete(e);return}let r=window.Highlight;r&&n.highlights.set(e,new r(...t))}function Gf(e,t){let n=[],r=e;for(;r&&r!==t;){let e=getComputedStyle(r);/(auto|scroll|hidden)/.test(e.overflowY+e.overflowX)&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)&&n.push(r),r=r.parentElement}return n}function Kf(e,t){let n=t.startContainer.parentElement;for(let r of Gf(n,e)){let e=t.getBoundingClientRect(),n=r.getBoundingClientRect();if(e.height<=0||e.width<=0)return;e.top>=n.top+4&&e.bottom<=n.bottom-4||(r.scrollTop+=e.top-n.top-(r.clientHeight-e.height)/2),e.left>=n.left+4&&e.right<=n.right-4||(r.scrollLeft+=e.left-n.left-(r.clientWidth-e.width)/2)}let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();if(r.height<=0||r.width<=0)return;let a=r.top>=i.top+6&&r.bottom<=i.bottom-6,o=r.left>=i.left+6&&r.right<=i.right-6;a&&o||(a||(e.scrollTop+=r.top-i.top-(i.height-r.height)/2),o||(e.scrollLeft+=r.left-i.left-(i.width-r.width)/2))}function qf({containerRef:e,messages:t,collapsedIds:n,toolResults:r,onExpand:i,onProgrammaticScroll:a,open:o,onClose:s}){let c=Z(),l=(0,m.useRef)(null),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(0),[,_]=(0,m.useState)(0),v=(0,m.useDeferredValue)(u),y=o?v.trim():``,b=(0,m.useRef)(null);b.current=f;let x=(0,m.useRef)([]),S=(0,m.useRef)({key:null}),C=(0,m.useRef)(``);(0,m.useEffect)(()=>{o&&(p(null),requestAnimationFrame(()=>l.current?.select()))},[o]),(0,m.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),s())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o,s]),(0,m.useEffect)(()=>(o||(Wf(`msg-search`,[]),Wf(`msg-search-active`,[])),()=>{Wf(`msg-search`,[]),Wf(`msg-search-active`,[])}),[o]),(0,m.useLayoutEffect)(()=>{let s=()=>{g(0),p(null),_(0),x.current=[],Wf(`msg-search`,[]),Wf(`msg-search-active`,[]),S.current={key:null},C.current=``};if(!o||!y){s();return}let c=e.current;if(!c)return;let l=!1,u=0;return u=requestAnimationFrame(()=>{if(l)return;let e=Hf(c,y,t,n,r);x.current=e;let o=e.length;if(g(o),o===0){p(null),_(0),Wf(`msg-search`,[]),Wf(`msg-search-active`,[]),S.current={key:null},C.current=y;return}let s=b.current,u;if(s){if(u=Uf(e,s),u===-1){let t=[];for(let n=0;n<e.length;n++)e[n].msgId===s.msgId&&t.push(n);u=t.length>0?t[Math.min(s.k,t.length-1)]:0}}else u=0;u<0&&(u=0),u>=o&&(u=o-1),(!s||s.msgId!==e[u].msgId||s.k!==e[u].k)&&p({msgId:e[u].msgId,k:e[u].k}),_(u);let d=e[u],f=S.current,m=f.key?.msgId!==d.msgId||f.key?.k!==d.k||f.kind===`folded`&&d.kind===`dom`||y!==C.current;if(S.current={key:{msgId:d.msgId,k:d.k},kind:d.kind},C.current=y,Wf(`msg-search`,e.filter(e=>e.kind===`dom`).map(e=>e.range)),d.kind===`folded`){Wf(`msg-search-active`,[]),m&&i(d.msgId);return}Wf(`msg-search-active`,[d.range]),m&&(a?.(),Kf(c,d.range))}),()=>{l=!0,cancelAnimationFrame(u)}},[o,y,t,e,f,n,r,i,a]);let w=(0,m.useCallback)(e=>{let t=x.current,n=t.length;if(n===0)return;let r=b.current,i=t[((r?Uf(t,r):0)+e+n)%n];p(i.kind===`dom`||i.kind===`folded`?{msgId:i.msgId,k:i.k}:null)},[]);if(!o)return null;let T=f?(()=>{let e=Uf(x.current,f);return e===-1?0:e})():0;return(0,X.jsxs)(`div`,{className:`search-bar`,role:`search`,children:[(0,X.jsx)(`input`,{ref:l,className:`search-input`,type:`text`,value:u,placeholder:c(`searchPlaceholder`),onChange:e=>{d(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w(e.shiftKey?-1:1))}}),(0,X.jsx)(`span`,{className:`search-count ${h===0?`empty`:``}`,children:h===0?c(`searchNoResults`):`${Math.min(T+1,h)}/${h}`}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchPrev`),disabled:h===0,onClick:()=>w(-1),children:(0,X.jsx)(Ke,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchNext`),disabled:h===0,onClick:()=>w(1),children:(0,X.jsx)(Je,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchClose`),onClick:s,children:(0,X.jsx)(N,{})})]})}function Jf(e){let{dSt:t,dSh:n,escaped:r,graceActive:i,stuck:a}=e;return i||t>=-4||t<=-500?{flipEscape:!1,reassert:!1}:n<0?{flipEscape:!1,reassert:a&&!r}:{flipEscape:!0,reassert:!1}}var Yf=`pi-web-model-usage`;function Xf(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){let e=typeof r==`number`?Math.floor(r):0;Number.isFinite(e)&&e>0&&(t[n]=e)}return t}function Zf(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function Qf(e,t){let n=t;return e.map((e,t)=>({m:e,i:t,count:n[e.id]??0})).sort((e,t)=>t.count-e.count||e.i-t.i).map(e=>e.m)}function $f(){try{let e=localStorage.getItem(Yf);return e?Xf(JSON.parse(e)):{}}catch{return{}}}function ep(e){try{localStorage.setItem(Yf,JSON.stringify(e))}catch{}}function tp(e){let t=Zf($f(),e);return ep(t),t}var np=[{id:`setup-matt-pocock-skills`,icon:`🛠`,titleKey:`tpl.sk.setup`,descKey:`tpl.sk.setup.desc`,promptKey:`tpl.sk.setup.prompt`},{id:`ask-matt`,icon:`🧭`,titleKey:`tpl.sk.ask`,descKey:`tpl.sk.ask.desc`,promptKey:`tpl.sk.ask.prompt`},{id:`grill-with-docs`,icon:`🗣`,titleKey:`tpl.sk.grilldocs`,descKey:`tpl.sk.grilldocs.desc`,promptKey:`tpl.sk.grilldocs.prompt`},{id:`to-spec`,icon:`📝`,titleKey:`tpl.sk.tospec`,descKey:`tpl.sk.tospec.desc`,promptKey:`tpl.sk.tospec.prompt`},{id:`to-tickets`,icon:`🎫`,titleKey:`tpl.sk.totickets`,descKey:`tpl.sk.totickets.desc`,promptKey:`tpl.sk.totickets.prompt`},{id:`implement`,icon:`🏗`,titleKey:`tpl.sk.implement`,descKey:`tpl.sk.implement.desc`,promptKey:`tpl.sk.implement.prompt`},{id:`code-review`,icon:`🧹`,titleKey:`tpl.sk.codeview`,descKey:`tpl.sk.codeview.desc`,promptKey:`tpl.sk.codeview.prompt`},{id:`wayfinder`,icon:`🗺`,titleKey:`tpl.sk.wayfinder`,descKey:`tpl.sk.wayfinder.desc`,promptKey:`tpl.sk.wayfinder.prompt`},{id:`prototype`,icon:`🔬`,titleKey:`tpl.sk.prototype`,descKey:`tpl.sk.prototype.desc`,promptKey:`tpl.sk.prototype.prompt`},{id:`research`,icon:`📚`,titleKey:`tpl.sk.research`,descKey:`tpl.sk.research.desc`,promptKey:`tpl.sk.research.prompt`},{id:`improve-codebase-architecture`,icon:`🏛`,titleKey:`tpl.sk.arch`,descKey:`tpl.sk.arch.desc`,promptKey:`tpl.sk.arch.prompt`},{id:`diagnosing-bugs`,icon:`🐛`,titleKey:`tpl.sk.debug`,descKey:`tpl.sk.debug.desc`,promptKey:`tpl.sk.debug.prompt`},{id:`resolving-merge-conflicts`,icon:`🔀`,titleKey:`tpl.sk.merge`,descKey:`tpl.sk.merge.desc`,promptKey:`tpl.sk.merge.prompt`},{id:`triage`,icon:`🗂`,titleKey:`tpl.sk.triage`,descKey:`tpl.sk.triage.desc`,promptKey:`tpl.sk.triage.prompt`},{id:`wizard`,icon:`✨`,titleKey:`tpl.sk.wizard`,descKey:`tpl.sk.wizard.desc`,promptKey:`tpl.sk.wizard.prompt`},{id:`grill-me`,icon:`🔍`,titleKey:`tpl.sk.grillme`,descKey:`tpl.sk.grillme.desc`,promptKey:`tpl.sk.grillme.prompt`},{id:`handoff`,icon:`🤝`,titleKey:`tpl.sk.handoff`,descKey:`tpl.sk.handoff.desc`,promptKey:`tpl.sk.handoff.prompt`},{id:`to-questionnaire`,icon:`📋`,titleKey:`tpl.sk.questionnaire`,descKey:`tpl.sk.questionnaire.desc`,promptKey:`tpl.sk.questionnaire.prompt`},{id:`teach`,icon:`🎓`,titleKey:`tpl.sk.teach`,descKey:`tpl.sk.teach.desc`,promptKey:`tpl.sk.teach.prompt`},{id:`wait-what`,icon:`💬`,titleKey:`tpl.sk.ww`,descKey:`tpl.sk.ww.desc`,promptKey:`tpl.sk.ww.prompt`},{id:`writing-for-agents`,icon:`📄`,titleKey:`tpl.sk.wfa`,descKey:`tpl.sk.wfa.desc`,promptKey:`tpl.sk.wfa.prompt`},{id:`codebase-design`,icon:`🧱`,titleKey:`tpl.sk.codesign`,descKey:`tpl.sk.codesign.desc`,promptKey:`tpl.sk.codesign.prompt`},{id:`domain-modeling`,icon:`🏷`,titleKey:`tpl.sk.domain`,descKey:`tpl.sk.domain.desc`,promptKey:`tpl.sk.domain.prompt`},{id:`grilling`,icon:`🔥`,titleKey:`tpl.sk.grilling`,descKey:`tpl.sk.grilling.desc`,promptKey:`tpl.sk.grilling.prompt`},{id:`tdd`,icon:`🧪`,titleKey:`tpl.sk.tdd`,descKey:`tpl.sk.tdd.desc`,promptKey:`tpl.sk.tdd.prompt`}],rp=`pi-web-ui:prompt-templates`;function ip(){try{let e=localStorage.getItem(rp);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`):[]}catch{return[]}}function ap(e){return np.some(t=>t.id===e)}function op(e){return typeof e.title==`string`}var sp=(0,m.createContext)(null);function cp(){let e=(0,m.useContext)(sp);if(!e)throw Error(`useTemplates must be used within TemplateProvider`);return e}function lp({children:e,currentModelId:t}){let n=Z(),[r,i]=(0,m.useState)(ip),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(!1);(0,m.useEffect)(()=>{try{localStorage.setItem(rp,JSON.stringify(r))}catch{}},[r]);let g=(0,m.useMemo)(()=>{let e=new Map,t=new Set;for(let n of r)n.hidden?t.add(n.id):(op(n)&&!ap(n.id)||op(n))&&e.set(n.id,n);let i=np.filter(e=>!t.has(e.id)).map(t=>{let r=e.get(t.id);return{id:t.id,icon:r?.icon??t.icon,title:r?.title??n(t.titleKey),desc:r?.desc??n(t.descKey),prompt:r?.prompt??n(t.promptKey),builtin:!0}}),a=r.filter(e=>op(e)&&!ap(e.id)).map(e=>({id:e.id,icon:e.icon??`📌`,title:e.title??``,desc:e.desc??``,prompt:e.prompt??``}));return[...i,...a]},[r,n]),_=(0,m.useCallback)(()=>o(!0),[]),v=(0,m.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:e}))},[]),y=(0,m.useCallback)((e,t=!1)=>{h(t),e?(u(!1),c({...e})):(u(!0),c({id:dt(),icon:`📌`,title:``,desc:``,prompt:``}))},[]),b=(0,m.useCallback)(()=>{o(!1),c(null),h(!1)},[]),x=(0,m.useCallback)(()=>{d?(i([]),f(!1)):f(!0)},[d]);(0,m.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),5e3);return()=>clearTimeout(e)},[d]);let S=(0,m.useCallback)(e=>{o(!1),v(e.prompt)},[v]),C=(0,m.useCallback)(e=>{o(!1),y(e,!0)},[y]),w=(0,m.useCallback)(()=>{o(!1),y(void 0,!0)},[y]),T=(0,m.useCallback)(e=>{i(t=>{let n=t.findIndex(t=>t.id===e.id);if(n>=0){let r=[...t];return r[n]=e,r}return[...t,e]}),c(null),p&&(o(!0),h(!1))},[p]),E=(0,m.useCallback)(e=>{i(t=>e.builtin?[...t.filter(t=>t.id!==e.id),{id:e.id,hidden:!0}]:t.filter(t=>t.id!==e.id)),c(null),p&&(o(!0),h(!1))},[p]),D=(0,m.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e.id||t.hidden)),c(null),p&&(o(!0),h(!1))},[p]),O=(0,m.useMemo)(()=>({templates:g,fill:v,openPicker:_,openEdit:y,resetConfirm:d,toggleReset:x}),[g,v,_,y,d,x]),k=s?r.some(e=>e.id===s.id&&!e.hidden&&op(e)):!1;return(0,X.jsxs)(sp.Provider,{value:O,children:[e,a&&(0,X.jsx)(fp,{templates:g,resetConfirm:d,onFill:S,onEditTpl:C,onNew:w,onResetToggle:x,onClose:b}),s&&(0,X.jsx)(pp,{editing:s,isNew:l,hasOverride:k,onDraft:c,onSave:T,onRestore:()=>D(s),onRemove:()=>E(s),onFill:()=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:s.prompt})),b()},onSend:()=>{let e=s.prompt.trim();e&&$({type:`prompt`,text:e,queue:!1})&&(t&&tp(t),b())},onClose:b})]})}function up(){let e=Z(),{templates:t,fill:n,openEdit:r,toggleReset:i,resetConfirm:a}=cp();return(0,X.jsxs)(`div`,{className:`empty-templates`,children:[(0,X.jsxs)(`div`,{className:`empty-templates-head`,children:[(0,X.jsx)(`span`,{className:`empty-templates-title`,children:e(`tpl.title`)}),(0,X.jsx)(`span`,{className:`empty-templates-hint`,children:e(`tpl.hint`)})]}),(0,X.jsxs)(`div`,{className:`empty-templates-grid`,children:[t.map(t=>(0,X.jsx)(dp,{tpl:t,title:e(`tpl.clickCard`),onFill:()=>n(t.prompt),onEdit:()=>r(t),editTitle:e(`tpl.editTpl`)},t.id)),(0,X.jsxs)(`button`,{type:`button`,className:`empty-template add`,onClick:()=>r(),title:e(`tpl.add`),children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:(0,X.jsx)(ce,{})}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:e(`tpl.add`)}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:e(`tpl.addDesc`)})]})]})]}),(0,X.jsx)(`div`,{className:`empty-templates-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`empty-templates-reset`,onClick:i,children:[(0,X.jsx)(oe,{}),e(a?`tpl.resetConfirm`:`tpl.reset`)]})})]})}function dp({tpl:e,title:t,onFill:n,onEdit:r,editTitle:i}){let a=Z();return(0,X.jsxs)(`button`,{type:`button`,className:`empty-template`,title:t,onClick:n,children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:e.icon}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:e.title}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:e.desc})]}),(0,X.jsx)(`span`,{className:`template-card-ops`,role:`button`,title:i??a(`tpl.editTpl`),onClick:e=>{e.stopPropagation(),r()},children:(0,X.jsx)(Fe,{})})]})}function fp({templates:e,resetConfirm:t,onFill:n,onEditTpl:r,onNew:i,onResetToggle:a,onClose:o}){let s=Z();return(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]),(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:o,children:(0,X.jsxs)(`div`,{className:`modal template-picker`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`template-picker-top`,children:[(0,X.jsxs)(`div`,{className:`template-picker-head`,children:[(0,X.jsx)(`span`,{className:`template-picker-title`,children:s(`tpl.pickerTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-modal-close`,title:s(`close`),onClick:o,children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`div`,{className:`template-picker-hint`,children:s(`tpl.pickerHint`)})]}),(0,X.jsx)(`div`,{className:`template-picker-scroll`,children:(0,X.jsxs)(`div`,{className:`template-picker-grid`,children:[e.map(e=>(0,X.jsx)(dp,{tpl:e,title:s(`tpl.clickCard`),onFill:()=>n(e),onEdit:()=>r(e),editTitle:s(`tpl.editTpl`)},e.id)),(0,X.jsxs)(`button`,{type:`button`,className:`empty-template add`,onClick:i,title:s(`tpl.add`),children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:(0,X.jsx)(ce,{})}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:s(`tpl.add`)}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:s(`tpl.addDesc`)})]})]})]})}),(0,X.jsx)(`div`,{className:`template-picker-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`empty-templates-reset`,onClick:a,children:[(0,X.jsx)(oe,{}),s(t?`tpl.resetConfirm`:`tpl.reset`)]})})]})})}function pp({editing:e,isNew:t,hasOverride:n,onDraft:r,onSave:i,onRestore:a,onRemove:o,onFill:s,onSend:c,onClose:l}){let u=Z(),d=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&l()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]),(0,m.useEffect)(()=>{let e=d.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight>300;e.style.height=`${Math.min(e.scrollHeight,300)}px`,e.style.overflowY=t?`auto`:`hidden`},[e.prompt]);let f=()=>{let t=e.title.trim(),n=e.prompt.trim();if(!t||!n){r({...e,error:u(`tpl.required`)});return}i({id:e.id,icon:e.icon.trim()||`📌`,title:t,desc:e.desc.trim(),prompt:n})},p=!!e.builtin&&!t;return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:l,children:(0,X.jsxs)(`div`,{className:`modal template-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`template-modal-head`,children:[(0,X.jsx)(`span`,{className:`template-modal-icon`,children:e.icon}),(0,X.jsx)(`span`,{className:`template-modal-badge`,children:u(p?`tpl.builtin`:`tpl.custom`)}),(0,X.jsx)(`span`,{className:`template-modal-title`,children:u(t?`tpl.newTitle`:`tpl.editTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-modal-close`,title:u(`close`),onClick:l,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`template-modal-body`,children:[(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldIcon`)}),(0,X.jsx)(`input`,{className:`template-field-input icon`,value:e.icon,maxLength:4,onChange:t=>r({...e,icon:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldTitle`)}),(0,X.jsx)(`input`,{className:`template-field-input`,value:e.title,placeholder:u(`tpl.fieldTitlePh`),onChange:t=>r({...e,title:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldDesc`)}),(0,X.jsx)(`input`,{className:`template-field-input`,value:e.desc,placeholder:u(`tpl.fieldDescPh`),onChange:t=>r({...e,desc:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldPrompt`)}),(0,X.jsx)(`textarea`,{ref:d,className:`template-field-prompt`,value:e.prompt,placeholder:u(`tpl.fieldPromptPh`),onChange:t=>r({...e,prompt:t.target.value})})]})]}),e.error&&(0,X.jsx)(`div`,{className:`template-error`,children:e.error}),(0,X.jsxs)(`div`,{className:`template-modal-actions`,children:[(0,X.jsxs)(`div`,{className:`template-modal-actions-left`,children:[!t&&p&&n&&(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn ghost`,title:u(`tpl.restoreTip`),onClick:a,children:u(`tpl.restore`)}),!t&&p&&(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn ghost danger`,title:u(`tpl.removeTip`),onClick:o,children:[(0,X.jsx)(R,{}),` `,u(`tpl.remove`)]}),!t&&!p&&(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn ghost danger`,title:u(`tpl.deleteTip`),onClick:o,children:[(0,X.jsx)(R,{}),` `,u(`tpl.delete`)]})]}),(0,X.jsxs)(`div`,{className:`template-modal-actions-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn`,onClick:f,children:u(`tpl.save`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn fill`,onClick:s,title:u(`tpl.fillTip`),children:u(`tpl.fill`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn send`,onClick:c,title:u(`tpl.sendTip`),children:[(0,X.jsx)(W,{}),` `,u(`tpl.sendNow`)]})]})]})]})})}var mp=class extends m.Component{state={message:null};static getDerivedStateFromError(e){return{message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`[ui-slot] entry "${this.props.entryId??this.props.label}" in slot "${this.props.slot??`?`}" crashed:`,e,t.componentStack)}render(){if(this.state.message===null)return this.props.children;let e=`slot=${this.props.slot??`?`} entry=${this.props.entryId??this.props.label}: ${this.state.message}`;return(0,X.jsxs)(`button`,{type:`button`,className:`slot-error`,title:e,"aria-label":this.props.label,onClick:()=>console.error(`[ui-slot] ${e}`),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`⚠`}),(0,X.jsx)(`span`,{children:this.props.label})]})}};function hp(e,t){return!e||e.length===0?null:(0,X.jsx)(`span`,{className:`slot-toolbar`,children:e.map((e,n)=>(0,X.jsx)(mp,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:gp(e,n,t)},`${e.id}#${n}`))})}function gp(e,t,n){let r=`${e.id}#${t}`,i=e.label||e.id,a=e.hint||i;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`slot-divider`,"aria-hidden":`true`},r):e.kind===`badge`?(0,X.jsx)(`span`,{className:`slot-badge`,title:a,children:e.badge??i},r):e.kind===`toggle`?(0,X.jsxs)(`button`,{type:`button`,className:`slot-btn${e.checked?` on`:``}`,title:a,"aria-label":i,"aria-pressed":!!e.checked,onClick:()=>n?.(e),children:[e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):null,(0,X.jsx)(`span`,{children:i})]},r):e.kind===`progress`?(0,X.jsx)(`span`,{className:`slot-progress`,title:`${a} ${e.progress??0}%`,children:(0,X.jsx)(`progress`,{value:e.progress??0,max:100})},r):e.kind===`input`?(0,X.jsx)(`input`,{className:`slot-input`,defaultValue:e.value??``,placeholder:i,title:a,"aria-label":i,onKeyDown:t=>{t.key===`Enter`&&!t.nativeEvent.isComposing&&n?.(e,t.target.value)}},`${r}:${e.value??``}`):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`slot-select`,title:a,"aria-label":i,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>n?.(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},r):(0,X.jsxs)(`button`,{type:`button`,className:`slot-btn`,title:a,"aria-label":i,onClick:()=>n?.(e),children:[e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):null,(0,X.jsx)(`span`,{children:i})]},r)}function _p(e,t,n){let r=[],i=[],a=!1,o=e=>{i.length!==0&&(a=!0,r.push((0,X.jsx)(`span`,{className:`slot-toolbar`,children:i.map((e,t)=>(0,X.jsx)(mp,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:gp(e,t,n)},`${e.id}#${t}`))},e)),i=[])};return e.forEach((e,n)=>{if(e.source===`host`){o(`gap${n}`);let i=t[e.id]??null;i&&(a=!0),r.push((0,X.jsx)(m.Fragment,{children:i},e.id))}else i.push(e)}),o(`tail`),a?(0,X.jsx)(X.Fragment,{children:r}):null}var vp=`#ffffff`,yp=`#1e1e1e`,bp=`.msg-actions, .msg-text-copy, .chead-copy, .stream-cursor, .msg-editor, .msg-collapse-btn, .msg-export-check, .toolcall-kill, .toolcall-open`;function xp(e,t=800,n=2){let r=Math.max(e,t,1);return r*n<=16384?n:+(r<=16384)}function Sp(e){let t=e.trim().toLowerCase();if(!t)return null;if(t===`transparent`)return{r:0,g:0,b:0,a:0};if(t.startsWith(`#`)){let e=t.slice(1);if(e.length===3||e.length===4){let t=Number.parseInt(e[0]+e[0],16),n=Number.parseInt(e[1]+e[1],16),r=Number.parseInt(e[2]+e[2],16),i=e.length===4?Number.parseInt(e[3]+e[3],16)/255:1;return[t,n,r,i].some(e=>Number.isNaN(e))?null:{r:t,g:n,b:r,a:i}}if(e.length===6||e.length===8){let t=Number.parseInt(e.slice(0,2),16),n=Number.parseInt(e.slice(2,4),16),r=Number.parseInt(e.slice(4,6),16),i=e.length===8?Number.parseInt(e.slice(6,8),16)/255:1;return[t,n,r,i].some(e=>Number.isNaN(e))?null:{r:t,g:n,b:r,a:i}}return null}let n=t.match(/^rgba?\(\s*([\s\S]+)\)$/);if(!n)return null;let r=n[1].trim(),i,a=1;if(r.includes(`/`)){let[e,t]=r.split(`/`);i=e.trim().split(/[\s,]+/).filter(Boolean),a=wp(t.trim())}else if(r.includes(`,`)){let e=r.split(`,`).map(e=>e.trim());e.length===4&&(a=wp(e.pop())),i=e}else i=r.split(/\s+/).filter(Boolean),i.length===4&&(a=wp(i.pop()));if(i.length!==3)return null;let o=Cp(i[0]),s=Cp(i[1]),c=Cp(i[2]);return[o,s,c,a].some(e=>Number.isNaN(e))?null:{r:o,g:s,b:c,a}}function Cp(e){return e.endsWith(`%`)?Math.round(Tp(Number.parseFloat(e),0,100)*2.55):Math.round(Tp(Number.parseFloat(e),0,255))}function wp(e){return e.endsWith(`%`)?Tp(Number.parseFloat(e)/100,0,1):Tp(Number.parseFloat(e),0,1)}function Tp(e,t,n){return Math.min(n,Math.max(t,e))}function Ep(e){let t=Tp(Math.round(e.r),0,255),n=Tp(Math.round(e.g),0,255),r=Tp(Math.round(e.b),0,255);return e.a<.996?`rgba(${t}, ${n}, ${r}, ${Math.round(Tp(e.a,0,1)*1e3)/1e3})`:`rgb(${t}, ${n}, ${r})`}function Dp(e,t){let n=Tp(e.a,0,1);return n<=0?{r:t.r,g:t.g,b:t.b,a:t.a}:n>=1?{r:e.r,g:e.g,b:e.b,a:1}:{r:e.r*n+t.r*(1-n),g:e.g*n+t.g*(1-n),b:e.b*n+t.b*(1-n),a:1}}function Op(e,t){let n=Sp(t)??{r:255,g:255,b:255,a:1},r=Sp(e);return!r||r.a<=.004?Ep({...n,a:1}):Ep(Dp(r,{...n,a:1}))}function kp(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function Ap(e){return kp(e)>.45}function jp(e){let t=document.createElement(`div`);t.style.cssText=`position:fixed;left:-99999px;top:0;width:8px;height:8px;pointer-events:none;background:${e}`,document.body.appendChild(t);let n=getComputedStyle(t).backgroundColor;return t.remove(),n}function Mp(){return getComputedStyle(document.documentElement).colorScheme.split(/\s+/).includes(`light`)?vp:yp}function Np(e){let t=Mp(),n=t;try{n=Op(jp(`var(--bg)`),t)}catch{n=t}try{let e=Op(jp(`var(--card-bg, var(--msgs-bg, var(--bg)))`),n),t=Sp(e);if(t&&kp(t)+t.a>0)return e}catch{}let r=e??null;for(;r;){let e=getComputedStyle(r).backgroundColor;if(e&&e!==`transparent`&&e!==`rgba(0, 0, 0, 0)`){let t=Op(e,n),r=Sp(e);if(r&&r.a>.04)return t}r=r.parentElement}return n}function Pp(e){return e instanceof HTMLElement||e instanceof SVGElement?e.style:null}function Fp(e,t){let n=Sp(e);return n?n.a<=.004?`transparent`:n.a>=.996?Ep({...n,a:1}):Ep(Dp(n,{...Sp(t)??{r:255,g:255,b:255,a:1},a:1})):null}function Ip(e,t,n){let r=getComputedStyle(e),i=Pp(t),a=n;if(i){let e=Fp(r.backgroundColor,n);e===`transparent`?i.backgroundColor=`transparent`:e&&(i.backgroundColor=e,a=e);let t=Fp(r.color,a);t&&t!==`transparent`&&(i.color=t);for(let[e]of[[`borderTopColor`,`border-top-color`],[`borderRightColor`,`border-right-color`],[`borderBottomColor`,`border-bottom-color`],[`borderLeftColor`,`border-left-color`],[`outlineColor`,`outline-color`],[`textDecorationColor`,`text-decoration-color`]]){let t=Fp(r[e],a);t&&t!==`transparent`&&(i[e]=t)}let o=Fp(r.fill,a);o&&o!==`transparent`&&r.fill!==`none`&&(i.fill=o);let s=Fp(r.stroke,a);s&&s!==`transparent`&&r.stroke!==`none`&&(i.stroke=s),i.backdropFilter=`none`,i.setProperty(`-webkit-backdrop-filter`,`none`),r.mixBlendMode&&r.mixBlendMode!==`normal`&&(i.mixBlendMode=`normal`),i.caretColor=`transparent`}let o=Array.from(e.children),s=Array.from(t.children),c=Math.min(o.length,s.length);for(let e=0;e<c;e++)Ip(o[e],s[e],a)}function Lp(e){e.querySelectorAll(bp).forEach(e=>e.remove())}function Rp(e,t={}){t.includeThinking||e.querySelectorAll(`.thinking`).forEach(e=>e.remove()),t.includeTools||e.querySelectorAll(`.toolcall`).forEach(e=>e.remove())}function zp(e,t,n={}){let r=e.cloneNode(!0);return Ip(e,r,t),Rp(r,n),Lp(r),r.classList.remove(`msg-export-selected`),r.style.margin=`0`,r.style.paddingLeft=``,r.removeAttribute(`id`),r.querySelectorAll(`[id]`).forEach(e=>e.removeAttribute(`id`)),r}async function Bp(e,t={}){let{toBlob:n}=await Go(async()=>{let{toBlob:e}=await import(`./es-DIDZppIF.js`);return{toBlob:e}},[]),r=t.backgroundColor??Np(e),i=Sp(r),a=await n(e,{pixelRatio:t.pixelRatio??2,backgroundColor:r,cacheBust:!1,style:{colorScheme:i&&!Ap(i)?`dark`:`light`}});if(!a)throw Error(`toBlob returned null`);return a}function Vp(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function Hp(e){return document.querySelector(`.msg[data-msg-id="${Vp(e)}"]`)??document.querySelector(`[data-msg-id="${Vp(e)}"]`)}function Up(){let e=Z(),t=Kd(),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(`pi-web-ui`),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(``),y=(0,m.useRef)(null),b=(0,m.useRef)(null),x=(0,m.useRef)(`#ffffff`);if((0,m.useEffect)(()=>{t.open&&(d(!1),g(!1),v(``))},[t.open]),yt(()=>{qd()},t.open),(0,m.useLayoutEffect)(()=>{if(!t.open)return;let e=!1,n=0;p(!0);let r=()=>{if(e||!b.current)return;let i=[],a=!1;for(let e of t.selectedIds){let t=Hp(e);t?i.push(t):a=!0}let o=t.includeThinking&&i.some(e=>e.querySelector(`.thinking`)&&!e.querySelector(`.thinking-body`))||t.includeTools&&i.some(e=>e.querySelector(`.toolcall`)&&!e.querySelector(`.toolcall-body`));if((a||o)&&n<12){n+=1,requestAnimationFrame(r);return}let s=i[0],c=Np(s??void 0);x.current=c;let l=document.createDocumentFragment();for(let e of i)l.appendChild(zp(e,c,{includeThinking:t.includeThinking,includeTools:t.includeTools}));b.current.replaceChildren(l);let u=y.current;if(u){u.style.backgroundColor=c;let e=Sp(c);if(u.style.colorScheme=e&&!Ap(e)?`dark`:`light`,s){let e=getComputedStyle(s).color;e&&(u.style.color=e)}}p(!1)},i=requestAnimationFrame(()=>requestAnimationFrame(r));return()=>{e=!0,cancelAnimationFrame(i),b.current?.replaceChildren()}},[t.open,t.selectedIds,t.includeThinking,t.includeTools]),!t.open)return null;let S=async()=>{let n=y.current;if(n&&!u&&t.selectedIds.length!==0){d(!0),v(``);try{let t=xp(n.scrollHeight,n.scrollWidth);if(t===0){v(e(`exportTooLong`));return}let r=await Bp(n,{backgroundColor:x.current,pixelRatio:t});await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),g(!0),window.setTimeout(()=>g(!1),1500)}catch(t){let n=t instanceof Error?t.message:String(t);v(`${e(`copyFailed`)}: ${n}`)}finally{d(!1)}}};return(0,X.jsxs)(`aside`,{className:`saveimg-dock`,role:`dialog`,"aria-label":e(`saveAsImage`),children:[(0,X.jsxs)(`div`,{className:`saveimg-head`,children:[(0,X.jsx)(`span`,{className:`saveimg-title`,children:e(`saveAsImage`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`close`),"aria-label":e(`close`),onClick:()=>qd(),children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`p`,{className:`saveimg-hint`,children:e(`exportSelectHint`)}),(0,X.jsxs)(`div`,{className:`saveimg-body`,children:[(0,X.jsx)(`div`,{className:`saveimg-preview`,children:(0,X.jsxs)(`div`,{ref:y,className:`saveimg-card${i?` saveimg-card--border`:``}`,children:[n.trim()?(0,X.jsx)(`div`,{className:`saveimg-card-title`,children:n.trim()}):null,(0,X.jsx)(`div`,{ref:b,className:`saveimg-card-md`}),o&&c.trim()?(0,X.jsx)(`div`,{className:`saveimg-card-wm`,children:c.trim()}):null]})}),(0,X.jsxs)(`div`,{className:`saveimg-options`,children:[(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t.includeTools,onChange:e=>Yd({includeTools:e.target.checked})}),(0,X.jsx)(`span`,{children:e(`exportIncludeTools`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t.includeThinking,onChange:e=>Yd({includeThinking:e.target.checked})}),(0,X.jsx)(`span`,{children:e(`exportIncludeThinking`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt`,children:[(0,X.jsx)(`span`,{children:e(`imageTitle`)}),(0,X.jsx)(`input`,{type:`text`,className:`dialog-input saveimg-input`,value:n,onChange:e=>r(e.target.value),placeholder:e(`imageTitlePlaceholder`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),(0,X.jsx)(`span`,{children:e(`imageBorder`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),(0,X.jsx)(`span`,{children:e(`imageWatermark`)})]}),(0,X.jsx)(`input`,{type:`text`,className:`dialog-input saveimg-input`,value:c,disabled:!o,onChange:e=>l(e.target.value),placeholder:e(`imageWatermarkPlaceholder`)}),(0,X.jsxs)(`div`,{className:`saveimg-copy-row`,children:[(0,X.jsx)(`span`,{className:`saveimg-count`,children:e(`exportSelectedCount`,{n:t.selectedIds.length})}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary saveimg-copy`,onClick:()=>void S(),disabled:u||f||t.selectedIds.length===0,title:e(`copyImageBtn`),children:[u||f?(0,X.jsx)(ye,{className:`saveimg-spin`}):h?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{}),(0,X.jsx)(`span`,{children:e(u||f?`savingImage`:h?`copied`:`copyImageBtn`)})]})]})]}),_?(0,X.jsx)(`div`,{className:`saveimg-error`,children:_}):null]})]})}var Wp=new Map,Gp=15,Kp=30,qp=250,Jp=1200,Yp=1600;function Xp({kind:e,text:t,index:n,onRemoveQueued:r,onRecallQueued:i}){let a=Z();return(0,X.jsxs)(`div`,{className:`msg msg-user msg-queued`,"data-role":`user`,children:[(0,X.jsxs)(`div`,{className:`msg-meta`,children:[(0,X.jsx)(`span`,{className:`msg-role`,children:a(`role.user`)}),(0,X.jsx)(`span`,{className:`queued-tag ${e===`steer`?`steer`:`follow`}`,children:a(e===`steer`?`queueSteerTag`:`queueFollowTag`)}),(0,X.jsxs)(`div`,{className:`msg-queued-actions`,children:[i&&(0,X.jsx)(`button`,{type:`button`,className:`msg-queued-recall`,title:a(`queueRecallTip`),"aria-label":a(`queueRecallTip`),onClick:()=>i(e,t,n),children:`↩`}),r&&(0,X.jsx)(`button`,{type:`button`,className:`msg-queued-remove`,title:a(`queueRemoveTip`),"aria-label":a(`queueRemoveTip`),onClick:()=>r(e,t,n),children:`✕`})]})]}),(0,X.jsx)(`div`,{className:`msg-body`,children:(0,X.jsx)(`div`,{className:`msg-text`,children:(0,X.jsx)(uu,{text:t,hardBreaks:!0})})})]})}function Zp({compaction:e}){let t=Z(),[,n]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3)),i=e.reason===`manual`?t(`compactingReasonManual`):e.reason===`overflow`?t(`compactingReasonOverflow`):t(`compactingReasonThreshold`);return(0,X.jsxs)(`div`,{className:`compact-notice`,role:`status`,children:[(0,X.jsx)(`span`,{className:`compact-pulse`}),(0,X.jsxs)(`span`,{className:`compact-text`,children:[t(`compactingContext`),` · `,r,`s`]}),(0,X.jsx)(`span`,{className:`compact-reason`,children:i})]})}function Qp(e){return e.content.some(e=>e.type===`toolCall`)}function $p({state:e,liveOutputs:t,toolStatuses:n,onEdit:r,onKillBash:i,onRetry:a,onRemoveQueued:o,onRecallQueued:s,thinkingWrap:c,toolsWrap:l,toolImages:u,jumpTarget:d,onJumpDone:f,uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,uiChatEmpty:_,onUiAction:v}){let y=Z(),b=Kd(),x=(0,m.useRef)(null),[S,C]=(0,m.useState)(!0),w=(0,m.useRef)(!0),T=(0,m.useRef)(0),E=(0,m.useRef)(0),D=(0,m.useRef)(!1),O=(0,m.useRef)(0),[A,ee]=(0,m.useState)(()=>new Set),[j,M]=(0,m.useState)(!1),N=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,P=(0,m.useMemo)(()=>{let t=new Map;for(let n of e.messages)n.role===`toolResult`&&n.toolCallId&&t.set(n.toolCallId,n);return t},[e.messages]),F=(0,m.useMemo)(()=>Ef(e.messages),[e.messages]),I=[...N].reverse().find(e=>e.role!==`system`),L=I?I.id:null,R=e.messages.length>Kp?Math.max(0,e.messages.length-Gp):0,te=(0,m.useMemo)(()=>{let t=new Set;for(let n=0;n<R;n++){let r=e.messages[n];r.role!==`toolResult`&&(A.has(r.id)||t.add(r.id))}return t},[e.messages,R,A]),[z,B]=(0,m.useState)(()=>new Set),[V,ne]=(0,m.useState)(()=>new Set),re=(0,m.useRef)(new Map),H=(0,m.useRef)(new Map),U=(0,m.useRef)(new Map),W=(0,m.useRef)(0),ie=(0,m.useMemo)(()=>{let t=new Map;for(let n of e.messages)t.set(n.id,Ff(n));return t},[e.messages]),ae=(0,m.useRef)(ie);ae.current=ie;let oe=(0,m.useRef)(z);oe.current=z;let se=e.messages.length>Kp&&!j,ce=(0,m.useRef)(se);ce.current=se;let le=Mf(e.messages,re.current,Yp),ue=(0,m.useRef)(le);ue.current=le;let de=(0,m.useCallback)(()=>{let e=x.current;if(!e)return;if(!ce.current){B(e=>e.size?new Set:e);return}let t=e.getBoundingClientRect(),n={top:t.top-Jp,bottom:t.bottom+Jp},r=[];for(let[e,t]of U.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),oe.current.has(e)||me(e,n.bottom-n.top,ae.current.get(e))}let i=Af(r,n,ue.current,oe.current);for(let e of i.hide){let t=U.current.get(e);t&&me(e,t.offsetHeight,ae.current.get(e))}B(e=>jf(e,i))},[]),fe=(0,m.useCallback)(()=>{W.current||=requestAnimationFrame(()=>{W.current=0,de()})},[de]);(0,m.useLayoutEffect)(()=>{de()},[de]);let pe=(0,m.useRef)(j);(0,m.useLayoutEffect)(()=>{pe.current&&!j&&de(),pe.current=j},[j,de]);let me=(0,m.useCallback)((e,t,n)=>{n!==void 0&&(H.current.set(e,{h:t,len:n}),re.current.set(e,t))},[]),he=(0,m.useCallback)((e,t)=>{me(e,t,ae.current.get(e))},[me]),ge=(0,m.useCallback)(e=>{e&&U.current.set(e.dataset.lazyId??``,e)},[]);(0,m.useEffect)(()=>{let t=new Set(e.messages.map(e=>e.id));for(let e of U.current.keys())t.has(e)||(U.current.delete(e),re.current.delete(e),H.current.delete(e));B(e=>{let n=!1,r=new Set;for(let i of e)t.has(i)?r.add(i):n=!0;return n?r:e})},[e.messages,A]),(0,m.useEffect)(()=>()=>cancelAnimationFrame(W.current),[]);let G=(0,m.useMemo)(()=>{let t=[];for(let n of e.messages){if(n.role!==`user`)continue;let e=n.content.map(e=>of(e)?.text??``).filter(Boolean).join(` `),r=Dd(e),i=r?r.userMessage??`skill:${r.name}`:e.trim();i&&t.push({id:n.id,text:i})}return t},[e.messages]),_e=(0,m.useMemo)(()=>{let e=new Map;return G.forEach((t,n)=>e.set(t.id,n)),e},[G]),[ve,K]=(0,m.useState)(-1),q=(0,m.useRef)(-1),ye=(0,m.useRef)(G);(0,m.useEffect)(()=>{ye.current=G},[G]);let J=(0,m.useCallback)(()=>{let e=x.current,t=ye.current;if(!e||t.length===0)return;let n=e.getBoundingClientRect().top,r=-1;for(let i=0;i<t.length;i++){let a=e.querySelector(`[data-msg-id="${t[i].id}"]`);if(a){if(a.getBoundingClientRect().top<=n+140)r=i;else break}}r!==q.current&&(q.current=r,K(r))},[]);(0,m.useEffect)(()=>{J()},[G,J]);let be=(0,m.useCallback)(e=>{ee(t=>t.has(e)?t:new Set(t).add(e))},[]);(0,m.useLayoutEffect)(()=>{Ud(e.messages.filter(Vd).map(e=>({id:e.id,role:e.role,content:e.content})))},[e.messages]),(0,m.useEffect)(()=>{if(b.open){for(let e of b.selectedIds)be(e);ne(e=>{let t=!1,n=new Set(e);for(let e of b.selectedIds)n.has(e)||(n.add(e),t=!0);return t?n:e})}},[b.open,b.selectedIds,be]),(0,m.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey)||e.key.toLowerCase()!==`f`)return;let t=e.target;(!t||t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable)&&(e.preventDefault(),M(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let xe=(0,m.useCallback)(e=>{ee(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),Se=(0,m.useCallback)(t=>{let n=e.messages.findIndex(e=>e.id===t);(0,k.flushSync)(()=>{n>=0&&n<R&&!A.has(t)&&be(t),ne(e=>e.has(t)?e:new Set(e).add(t))});let r=ye.current.findIndex(e=>e.id===t);q.current=r,K(r),requestAnimationFrame(()=>{let e=x.current?.querySelector(`[data-msg-id="${t}"]`);e&&(x.current?.querySelectorAll(`.msg-flash`).forEach(e=>e.classList.remove(`msg-flash`)),e.scrollIntoView({block:`start`}),e.classList.remove(`msg-flash`),e.offsetWidth,e.classList.add(`msg-flash`),e!==x.current?.lastElementChild&&(D.current=!0))})},[e.messages,R,A,be]),[Ce,we]=(0,m.useState)(null),Te=(0,m.useRef)(null),Ee=(0,m.useRef)(null);(0,m.useEffect)(()=>{let t=Te.current;if(!t||t.convId!==e.conversationId){Te.current={convId:e.conversationId,ids:new Set(e.messages.filter(e=>e.role===`compactionSummary`).map(e=>e.id))},Ee.current=null,we(null);return}for(let n of e.messages)if(n.role===`compactionSummary`&&!t.ids.has(n.id)){t.ids.add(n.id),we(n.id);break}},[e.messages,e.conversationId]),(0,m.useEffect)(()=>{Ce&&Ee.current!==Ce&&(Ee.current=Ce,Se(Ce))},[Ce,Se]);let De=(0,m.useMemo)(()=>d?e.messages.find(e=>e.role===d.role&&e.timestamp===d.timestamp)?.id??null:null,[e.messages,d]);(0,m.useEffect)(()=>{if(d){if(De){Se(De),f?.();return}e.sessionFile===d.path&&e.messages.length>0&&f?.()}},[De,Se,f,d,e.sessionFile,e.messages.length]);let Oe=(0,m.useCallback)(()=>{let e=x.current;if(!e)return;let t=e.scrollTop-T.current,n=e.scrollHeight-E.current;T.current=e.scrollTop,E.current=e.scrollHeight;let r=e.scrollHeight-e.scrollTop-e.clientHeight<80,i=Date.now()<O.current,a=Jf({dSt:t,dSh:n,escaped:D.current,graceActive:i,stuck:w.current});a.reassert&&(O.current=Date.now()+qp,e.scrollTop=e.scrollHeight),a.flipEscape&&(D.current=!0),r&&t>=0&&(D.current=!1),i||(t<0?w.current=r&&!D.current:r&&(w.current=!0)),C(w.current),J(),fe()},[J,fe]),ke=(0,m.useRef)(!1);(0,m.useEffect)(()=>{let t=ke.current;if(ke.current=!!e.isStreaming,t&&!e.isStreaming&&!D.current){let e=()=>{let e=x.current;e&&!D.current&&(e.scrollTop=e.scrollHeight,w.current=!0,C(!0))};requestAnimationFrame(()=>requestAnimationFrame(e));let t=setTimeout(e,180);return()=>clearTimeout(t)}},[e.isStreaming]),(0,m.useEffect)(()=>{let e=x.current;e&&w.current&&(e.scrollTop=e.scrollHeight)},[N,e.isStreaming,t]);let Y=e.queue.steering.join(`\0`)+``+e.queue.followUp.join(`\0`);(0,m.useEffect)(()=>{let e=x.current;e&&w.current&&(e.scrollTop=e.scrollHeight)},[Y]),(0,m.useEffect)(()=>{let e=x.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.clientHeight,n=new ResizeObserver(()=>{let n=e.clientHeight,r=n-t;t=n,r>0&&(e.scrollTop=Math.min(e.scrollTop,e.scrollHeight-e.clientHeight))});return n.observe(e),()=>n.disconnect()},[]),(0,m.useEffect)(()=>{let e=x.current;if(!e||typeof MutationObserver>`u`)return;let t=!1,n=new MutationObserver(()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let e=x.current;e&&w.current&&!D.current&&(e.scrollTop=e.scrollHeight,C(!0))}))});return n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[]);let Ae=(0,m.useCallback)(()=>{if(!x.current)return;w.current=!0,D.current=!1,C(!0),O.current=Date.now()+qp;let e=()=>{let e=x.current;e&&w.current&&!D.current&&(O.current=Date.now()+qp,e.scrollTop=e.scrollHeight)};e(),requestAnimationFrame(()=>requestAnimationFrame(e)),setTimeout(e,120),setTimeout(e,300),setTimeout(e,600)},[]),je=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=je.current,t=x.current;if(!e||!t)return;let n=n=>{n.preventDefault();let r=e.querySelector(`.qn-list`);if(r&&r.contains(n.target)&&r.scrollHeight>r.clientHeight){r.scrollTop+=n.deltaY;return}t.scrollTop+=n.deltaY};return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)},[]);let[Me,Ne]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=()=>{Ne(x.current?.clientHeight??0),fe()};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[fe]);let Pe=G.length,Fe=(0,m.useMemo)(()=>Pe===0?27:Math.max(4,Math.min(27,Math.floor(((Me||600)-16)/Pe)-3)),[Pe,Me]),Ie=Fe<20;return(0,X.jsxs)(`div`,{className:`messages-wrap${b.open?` messages-exporting`:``}`,children:[(0,X.jsxs)(`div`,{className:`messages${j||S?``:` anchor-live`}`,ref:x,onScroll:Oe,children:[e.messages.length===0&&!e.streamingMessage&&(0,X.jsxs)(`div`,{className:`empty-state`,children:[(0,X.jsx)(up,{}),_&&_.length>0&&(0,X.jsx)(`div`,{className:`chat-empty-slots`,children:hp(_,v)})]}),e.messages.map((o,s)=>{if(o.role===`system`)return null;let d=s<R,f=d&&A.has(o.id);if(d&&!f)return o.role===`toolResult`?null:(0,X.jsx)(Df,{message:o,onExpand:be},o.id);let m=o.role===`user`?_e.get(o.id):void 0,_=!se||le.has(o.id)||V.has(o.id)||!z.has(o.id);return(0,X.jsx)(kf,{id:o.id,show:_,height:If(o.id,ie.get(o.id)??-1,H.current,Nf(o.role,o.customType)),containerRef:x,onMeasured:he,lazyRef:ge,children:(0,X.jsx)(gf,{uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,onUiAction:v,message:o,qnIndex:m,qnActive:m===void 0?void 0:m===ve,onJump:Se,toolResults:P,liveOutputs:Qp(o)?t:Wp,toolStatuses:n,streaming:e.isStreaming,onKillBash:i,onRetry:o.id===L?a:void 0,toolsWrap:l,toolImages:u,thinkingWrap:c,isLast:o.id===L,onEdit:r,questionAttachments:F.get(o.id),onCollapse:f?xe:void 0,searchActive:j,autoExpand:o.id===Ce},o.id)},o.id)}),e.streamingMessage&&(0,X.jsx)(gf,{uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,onUiAction:v,message:e.streamingMessage,toolResults:P,liveOutputs:Qp(e.streamingMessage)?t:Wp,toolStatuses:n,streaming:!0,isLast:!0,onEdit:r,onKillBash:i,toolsWrap:l,toolImages:u,thinkingWrap:c,searchActive:j},e.streamingMessage.id),e.retry&&e.isStreaming&&(0,X.jsxs)(`div`,{className:`retry-notice`,role:`status`,title:e.retry.errorMessage||void 0,children:[(0,X.jsx)(`span`,{className:`retry-pulse`}),(0,X.jsx)(`span`,{className:`retry-text`,children:e.retry.maxAttempts>0?y(`retryingApi`,{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):y(`retryingApiSoon`,{error:e.retry.errorMessage})})]}),e.compaction&&(0,X.jsx)(Zp,{compaction:e.compaction}),e.isStreaming&&N.length===0&&(0,X.jsx)(`div`,{className:`streaming-wait`,children:y(`waitingResponse`)}),e.queue.steering.map((e,t)=>(0,X.jsx)(Xp,{kind:`steer`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-steer-${t}`)),e.queue.followUp.map((e,t)=>(0,X.jsx)(Xp,{kind:`followUp`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-fu-${t}`))]}),!S&&(0,X.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:Ae,children:[(0,X.jsx)(rt,{}),` `,y(`backToBottom`)]}),(0,X.jsx)(qf,{containerRef:x,messages:N,collapsedIds:te,toolResults:P,onExpand:be,onProgrammaticScroll:()=>{D.current=!0,w.current=!1,C(!1)},open:j,onClose:()=>M(!1)}),G.length>0&&(0,X.jsxs)(`div`,{className:`qn-rail ${Ie?`many`:``}`,ref:je,"aria-label":y(`questionNavTitle`),style:{"--rail-gap":`${Fe}px`},children:[G.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`qn-bar ${t===ve?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Se(e.id),children:(0,X.jsxs)(`span`,{className:`qn-bar-text`,children:[t+1,`. `,e.text]})},e.id)),Ie&&(0,X.jsx)(`div`,{className:`qn-list`,children:G.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`qn-list-item ${t===ve?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Se(e.id),children:[(0,X.jsx)(`span`,{className:`qn-list-idx`,children:t+1}),(0,X.jsx)(`span`,{className:`qn-list-text`,children:e.text})]},e.id))})]}),(0,X.jsx)(Up,{})]})}function em(e,t){return t?e.trim()?`${e.replace(/\s+$/,``)}\n${t}`:t:e}function tm(e,t,n){let r=null;return e&&e.text&&e.ts>0&&(r={text:e.text,ts:e.ts}),t&&t.text&&t.ts>(r?.ts??0)&&(r=t),!r||r.ts<=n?null:r}function nm(e){return e.key?`key:${e.key}`:e.mode===`conversation`?e.conversationId?`conv:id:${e.conversationId}`:e.sessionPath?`conv:path:${e.sessionPath}`:null:e.path?`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`:null}function rm(e,t){return t?e?{key:t,clear:e!==t}:{key:t,clear:!1}:{key:e,clear:!1}}function im(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=new Set(e.map(nm).filter(e=>e!==null)),r=[...e];for(let e of t){let t=nm(e);if(t!==null){if(n.has(t))continue;n.add(t)}r.push(e)}return r}function am(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var om=``;function sm(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function cm(e,t){return{first:!e.slice(0,t).includes(`
|
|
354
|
+
`)}function zf(e,t){let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}function Bf(e,t,n,r){let i=new Map,a=n.toLowerCase();if(!a)return i;for(let n of e){if(!t.has(n.id))continue;let e=zf(Rf(n,r).toLowerCase(),a);e>0&&i.set(n.id,e)}return i}function Vf(e,t){let n=[],r=t.toLowerCase();if(!r)return n;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!t||t.closest(`.search-bar`)||t.closest(`.msg-collapsed`)?NodeFilter.FILTER_REJECT:(e.textContent??``).toLowerCase().includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let e=i.nextNode();e;e=i.nextNode()){let t=(e.textContent??``).toLowerCase();if(!e.parentElement?.closest(`[data-msg-id]`))continue;let i=t.indexOf(r);for(;i!==-1;){let a=document.createRange();a.setStart(e,i),a.setEnd(e,i+r.length),n.push(a),i=t.indexOf(r,i+r.length)}}return n}function Hf(e,t,n,r,i){let a=Bf(n,r,t,i),o=new Map;for(let n of Vf(e,t)){let e=n.startContainer.parentElement?.closest(`[data-msg-id]`);if(!e?.dataset.msgId)continue;let t=o.get(e.dataset.msgId);t?t.push(n):o.set(e.dataset.msgId,[n])}let s=[];for(let e of n){let t=o.get(e.id);if(t)for(let n=0;n<t.length;n++)s.push({kind:`dom`,range:t[n],msgId:e.id,k:n});let n=a.get(e.id);if(n)for(let t=0;t<n;t++)s.push({kind:`folded`,msgId:e.id,k:t})}return s}function Uf(e,t){return e.findIndex(e=>e.msgId===t.msgId&&e.k===t.k)}function Wf(e,t){let n=CSS;if(!n.highlights)return;if(t.length===0){n.highlights.delete(e);return}let r=window.Highlight;r&&n.highlights.set(e,new r(...t))}function Gf(e,t){let n=[],r=e;for(;r&&r!==t;){let e=getComputedStyle(r);/(auto|scroll|hidden)/.test(e.overflowY+e.overflowX)&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)&&n.push(r),r=r.parentElement}return n}function Kf(e,t){let n=t.startContainer.parentElement;for(let r of Gf(n,e)){let e=t.getBoundingClientRect(),n=r.getBoundingClientRect();if(e.height<=0||e.width<=0)return;e.top>=n.top+4&&e.bottom<=n.bottom-4||(r.scrollTop+=e.top-n.top-(r.clientHeight-e.height)/2),e.left>=n.left+4&&e.right<=n.right-4||(r.scrollLeft+=e.left-n.left-(r.clientWidth-e.width)/2)}let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();if(r.height<=0||r.width<=0)return;let a=r.top>=i.top+6&&r.bottom<=i.bottom-6,o=r.left>=i.left+6&&r.right<=i.right-6;a&&o||(a||(e.scrollTop+=r.top-i.top-(i.height-r.height)/2),o||(e.scrollLeft+=r.left-i.left-(i.width-r.width)/2))}function qf({containerRef:e,messages:t,collapsedIds:n,toolResults:r,onExpand:i,onProgrammaticScroll:a,open:o,onClose:s}){let c=Z(),l=(0,m.useRef)(null),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(0),[,_]=(0,m.useState)(0),v=(0,m.useDeferredValue)(u),y=o?v.trim():``,b=(0,m.useRef)(null);b.current=f;let x=(0,m.useRef)([]),S=(0,m.useRef)({key:null}),C=(0,m.useRef)(``);(0,m.useEffect)(()=>{o&&(p(null),requestAnimationFrame(()=>l.current?.select()))},[o]),(0,m.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),s())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o,s]),(0,m.useEffect)(()=>(o||(Wf(`msg-search`,[]),Wf(`msg-search-active`,[])),()=>{Wf(`msg-search`,[]),Wf(`msg-search-active`,[])}),[o]),(0,m.useLayoutEffect)(()=>{let s=()=>{g(0),p(null),_(0),x.current=[],Wf(`msg-search`,[]),Wf(`msg-search-active`,[]),S.current={key:null},C.current=``};if(!o||!y){s();return}let c=e.current;if(!c)return;let l=!1,u=0;return u=requestAnimationFrame(()=>{if(l)return;let e=Hf(c,y,t,n,r);x.current=e;let o=e.length;if(g(o),o===0){p(null),_(0),Wf(`msg-search`,[]),Wf(`msg-search-active`,[]),S.current={key:null},C.current=y;return}let s=b.current,u;if(s){if(u=Uf(e,s),u===-1){let t=[];for(let n=0;n<e.length;n++)e[n].msgId===s.msgId&&t.push(n);u=t.length>0?t[Math.min(s.k,t.length-1)]:0}}else u=0;u<0&&(u=0),u>=o&&(u=o-1),(!s||s.msgId!==e[u].msgId||s.k!==e[u].k)&&p({msgId:e[u].msgId,k:e[u].k}),_(u);let d=e[u],f=S.current,m=f.key?.msgId!==d.msgId||f.key?.k!==d.k||f.kind===`folded`&&d.kind===`dom`||y!==C.current;if(S.current={key:{msgId:d.msgId,k:d.k},kind:d.kind},C.current=y,Wf(`msg-search`,e.filter(e=>e.kind===`dom`).map(e=>e.range)),d.kind===`folded`){Wf(`msg-search-active`,[]),m&&i(d.msgId);return}Wf(`msg-search-active`,[d.range]),m&&(a?.(),Kf(c,d.range))}),()=>{l=!0,cancelAnimationFrame(u)}},[o,y,t,e,f,n,r,i,a]);let w=(0,m.useCallback)(e=>{let t=x.current,n=t.length;if(n===0)return;let r=b.current,i=t[((r?Uf(t,r):0)+e+n)%n];p(i.kind===`dom`||i.kind===`folded`?{msgId:i.msgId,k:i.k}:null)},[]);if(!o)return null;let T=f?(()=>{let e=Uf(x.current,f);return e===-1?0:e})():0;return(0,X.jsxs)(`div`,{className:`search-bar`,role:`search`,children:[(0,X.jsx)(`input`,{ref:l,className:`search-input`,type:`text`,value:u,placeholder:c(`searchPlaceholder`),onChange:e=>{d(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w(e.shiftKey?-1:1))}}),(0,X.jsx)(`span`,{className:`search-count ${h===0?`empty`:``}`,children:h===0?c(`searchNoResults`):`${Math.min(T+1,h)}/${h}`}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchPrev`),disabled:h===0,onClick:()=>w(-1),children:(0,X.jsx)(Ke,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchNext`),disabled:h===0,onClick:()=>w(1),children:(0,X.jsx)(Je,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchClose`),onClick:s,children:(0,X.jsx)(N,{})})]})}function Jf(e){let{dSt:t,dSh:n,escaped:r,graceActive:i,stuck:a}=e;return i||t>=-4||t<=-500?{flipEscape:!1,reassert:!1}:n<0?{flipEscape:!1,reassert:a&&!r}:{flipEscape:!0,reassert:!1}}var Yf=`pi-web-model-usage`;function Xf(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){let e=typeof r==`number`?Math.floor(r):0;Number.isFinite(e)&&e>0&&(t[n]=e)}return t}function Zf(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function Qf(e,t){let n=t;return e.map((e,t)=>({m:e,i:t,count:n[e.id]??0})).sort((e,t)=>t.count-e.count||e.i-t.i).map(e=>e.m)}function $f(){try{let e=localStorage.getItem(Yf);return e?Xf(JSON.parse(e)):{}}catch{return{}}}function ep(e){try{localStorage.setItem(Yf,JSON.stringify(e))}catch{}}function tp(e){let t=Zf($f(),e);return ep(t),t}var np=[{id:`setup-matt-pocock-skills`,icon:`🛠`,titleKey:`tpl.sk.setup`,descKey:`tpl.sk.setup.desc`,promptKey:`tpl.sk.setup.prompt`},{id:`ask-matt`,icon:`🧭`,titleKey:`tpl.sk.ask`,descKey:`tpl.sk.ask.desc`,promptKey:`tpl.sk.ask.prompt`},{id:`grill-with-docs`,icon:`🗣`,titleKey:`tpl.sk.grilldocs`,descKey:`tpl.sk.grilldocs.desc`,promptKey:`tpl.sk.grilldocs.prompt`},{id:`to-spec`,icon:`📝`,titleKey:`tpl.sk.tospec`,descKey:`tpl.sk.tospec.desc`,promptKey:`tpl.sk.tospec.prompt`},{id:`to-tickets`,icon:`🎫`,titleKey:`tpl.sk.totickets`,descKey:`tpl.sk.totickets.desc`,promptKey:`tpl.sk.totickets.prompt`},{id:`implement`,icon:`🏗`,titleKey:`tpl.sk.implement`,descKey:`tpl.sk.implement.desc`,promptKey:`tpl.sk.implement.prompt`},{id:`code-review`,icon:`🧹`,titleKey:`tpl.sk.codeview`,descKey:`tpl.sk.codeview.desc`,promptKey:`tpl.sk.codeview.prompt`},{id:`wayfinder`,icon:`🗺`,titleKey:`tpl.sk.wayfinder`,descKey:`tpl.sk.wayfinder.desc`,promptKey:`tpl.sk.wayfinder.prompt`},{id:`prototype`,icon:`🔬`,titleKey:`tpl.sk.prototype`,descKey:`tpl.sk.prototype.desc`,promptKey:`tpl.sk.prototype.prompt`},{id:`research`,icon:`📚`,titleKey:`tpl.sk.research`,descKey:`tpl.sk.research.desc`,promptKey:`tpl.sk.research.prompt`},{id:`improve-codebase-architecture`,icon:`🏛`,titleKey:`tpl.sk.arch`,descKey:`tpl.sk.arch.desc`,promptKey:`tpl.sk.arch.prompt`},{id:`diagnosing-bugs`,icon:`🐛`,titleKey:`tpl.sk.debug`,descKey:`tpl.sk.debug.desc`,promptKey:`tpl.sk.debug.prompt`},{id:`resolving-merge-conflicts`,icon:`🔀`,titleKey:`tpl.sk.merge`,descKey:`tpl.sk.merge.desc`,promptKey:`tpl.sk.merge.prompt`},{id:`triage`,icon:`🗂`,titleKey:`tpl.sk.triage`,descKey:`tpl.sk.triage.desc`,promptKey:`tpl.sk.triage.prompt`},{id:`wizard`,icon:`✨`,titleKey:`tpl.sk.wizard`,descKey:`tpl.sk.wizard.desc`,promptKey:`tpl.sk.wizard.prompt`},{id:`grill-me`,icon:`🔍`,titleKey:`tpl.sk.grillme`,descKey:`tpl.sk.grillme.desc`,promptKey:`tpl.sk.grillme.prompt`},{id:`handoff`,icon:`🤝`,titleKey:`tpl.sk.handoff`,descKey:`tpl.sk.handoff.desc`,promptKey:`tpl.sk.handoff.prompt`},{id:`to-questionnaire`,icon:`📋`,titleKey:`tpl.sk.questionnaire`,descKey:`tpl.sk.questionnaire.desc`,promptKey:`tpl.sk.questionnaire.prompt`},{id:`teach`,icon:`🎓`,titleKey:`tpl.sk.teach`,descKey:`tpl.sk.teach.desc`,promptKey:`tpl.sk.teach.prompt`},{id:`wait-what`,icon:`💬`,titleKey:`tpl.sk.ww`,descKey:`tpl.sk.ww.desc`,promptKey:`tpl.sk.ww.prompt`},{id:`writing-for-agents`,icon:`📄`,titleKey:`tpl.sk.wfa`,descKey:`tpl.sk.wfa.desc`,promptKey:`tpl.sk.wfa.prompt`},{id:`codebase-design`,icon:`🧱`,titleKey:`tpl.sk.codesign`,descKey:`tpl.sk.codesign.desc`,promptKey:`tpl.sk.codesign.prompt`},{id:`domain-modeling`,icon:`🏷`,titleKey:`tpl.sk.domain`,descKey:`tpl.sk.domain.desc`,promptKey:`tpl.sk.domain.prompt`},{id:`grilling`,icon:`🔥`,titleKey:`tpl.sk.grilling`,descKey:`tpl.sk.grilling.desc`,promptKey:`tpl.sk.grilling.prompt`},{id:`tdd`,icon:`🧪`,titleKey:`tpl.sk.tdd`,descKey:`tpl.sk.tdd.desc`,promptKey:`tpl.sk.tdd.prompt`}],rp=`pi-web-ui:prompt-templates`;function ip(){try{let e=localStorage.getItem(rp);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`):[]}catch{return[]}}function ap(e){return np.some(t=>t.id===e)}function op(e){return typeof e.title==`string`}var sp=(0,m.createContext)(null);function cp(){let e=(0,m.useContext)(sp);if(!e)throw Error(`useTemplates must be used within TemplateProvider`);return e}function lp({children:e,currentModelId:t}){let n=Z(),[r,i]=(0,m.useState)(ip),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(!1);(0,m.useEffect)(()=>{try{localStorage.setItem(rp,JSON.stringify(r))}catch{}},[r]);let g=(0,m.useMemo)(()=>{let e=new Map,t=new Set;for(let n of r)n.hidden?t.add(n.id):(op(n)&&!ap(n.id)||op(n))&&e.set(n.id,n);let i=np.filter(e=>!t.has(e.id)).map(t=>{let r=e.get(t.id);return{id:t.id,icon:r?.icon??t.icon,title:r?.title??n(t.titleKey),desc:r?.desc??n(t.descKey),prompt:r?.prompt??n(t.promptKey),builtin:!0}}),a=r.filter(e=>op(e)&&!ap(e.id)).map(e=>({id:e.id,icon:e.icon??`📌`,title:e.title??``,desc:e.desc??``,prompt:e.prompt??``}));return[...i,...a]},[r,n]),_=(0,m.useCallback)(()=>o(!0),[]),v=(0,m.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:e}))},[]),y=(0,m.useCallback)((e,t=!1)=>{h(t),e?(u(!1),c({...e})):(u(!0),c({id:dt(),icon:`📌`,title:``,desc:``,prompt:``}))},[]),b=(0,m.useCallback)(()=>{o(!1),c(null),h(!1)},[]),x=(0,m.useCallback)(()=>{d?(i([]),f(!1)):f(!0)},[d]);(0,m.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),5e3);return()=>clearTimeout(e)},[d]);let S=(0,m.useCallback)(e=>{o(!1),v(e.prompt)},[v]),C=(0,m.useCallback)(e=>{o(!1),y(e,!0)},[y]),w=(0,m.useCallback)(()=>{o(!1),y(void 0,!0)},[y]),T=(0,m.useCallback)(e=>{i(t=>{let n=t.findIndex(t=>t.id===e.id);if(n>=0){let r=[...t];return r[n]=e,r}return[...t,e]}),c(null),p&&(o(!0),h(!1))},[p]),E=(0,m.useCallback)(e=>{i(t=>e.builtin?[...t.filter(t=>t.id!==e.id),{id:e.id,hidden:!0}]:t.filter(t=>t.id!==e.id)),c(null),p&&(o(!0),h(!1))},[p]),D=(0,m.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e.id||t.hidden)),c(null),p&&(o(!0),h(!1))},[p]),O=(0,m.useMemo)(()=>({templates:g,fill:v,openPicker:_,openEdit:y,resetConfirm:d,toggleReset:x}),[g,v,_,y,d,x]),k=s?r.some(e=>e.id===s.id&&!e.hidden&&op(e)):!1;return(0,X.jsxs)(sp.Provider,{value:O,children:[e,a&&(0,X.jsx)(fp,{templates:g,resetConfirm:d,onFill:S,onEditTpl:C,onNew:w,onResetToggle:x,onClose:b}),s&&(0,X.jsx)(pp,{editing:s,isNew:l,hasOverride:k,onDraft:c,onSave:T,onRestore:()=>D(s),onRemove:()=>E(s),onFill:()=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:s.prompt})),b()},onSend:()=>{let e=s.prompt.trim();e&&$({type:`prompt`,text:e,queue:!1})&&(t&&tp(t),b())},onClose:b})]})}function up(){let e=Z(),{templates:t,fill:n,openEdit:r,toggleReset:i,resetConfirm:a}=cp();return(0,X.jsxs)(`div`,{className:`empty-templates`,children:[(0,X.jsxs)(`div`,{className:`empty-templates-head`,children:[(0,X.jsx)(`span`,{className:`empty-templates-title`,children:e(`tpl.title`)}),(0,X.jsx)(`span`,{className:`empty-templates-hint`,children:e(`tpl.hint`)})]}),(0,X.jsxs)(`div`,{className:`empty-templates-grid`,children:[t.map(t=>(0,X.jsx)(dp,{tpl:t,title:e(`tpl.clickCard`),onFill:()=>n(t.prompt),onEdit:()=>r(t),editTitle:e(`tpl.editTpl`)},t.id)),(0,X.jsxs)(`button`,{type:`button`,className:`empty-template add`,onClick:()=>r(),title:e(`tpl.add`),children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:(0,X.jsx)(se,{})}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:e(`tpl.add`)}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:e(`tpl.addDesc`)})]})]})]}),(0,X.jsx)(`div`,{className:`empty-templates-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`empty-templates-reset`,onClick:i,children:[(0,X.jsx)(ae,{}),e(a?`tpl.resetConfirm`:`tpl.reset`)]})})]})}function dp({tpl:e,title:t,onFill:n,onEdit:r,editTitle:i}){let a=Z();return(0,X.jsxs)(`button`,{type:`button`,className:`empty-template`,title:t,onClick:n,children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:e.icon}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:e.title}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:e.desc})]}),(0,X.jsx)(`span`,{className:`template-card-ops`,role:`button`,title:i??a(`tpl.editTpl`),onClick:e=>{e.stopPropagation(),r()},children:(0,X.jsx)(Fe,{})})]})}function fp({templates:e,resetConfirm:t,onFill:n,onEditTpl:r,onNew:i,onResetToggle:a,onClose:o}){let s=Z();return(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]),(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:o,children:(0,X.jsxs)(`div`,{className:`modal template-picker`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`template-picker-top`,children:[(0,X.jsxs)(`div`,{className:`template-picker-head`,children:[(0,X.jsx)(`span`,{className:`template-picker-title`,children:s(`tpl.pickerTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-modal-close`,title:s(`close`),onClick:o,children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`div`,{className:`template-picker-hint`,children:s(`tpl.pickerHint`)})]}),(0,X.jsx)(`div`,{className:`template-picker-scroll`,children:(0,X.jsxs)(`div`,{className:`template-picker-grid`,children:[e.map(e=>(0,X.jsx)(dp,{tpl:e,title:s(`tpl.clickCard`),onFill:()=>n(e),onEdit:()=>r(e),editTitle:s(`tpl.editTpl`)},e.id)),(0,X.jsxs)(`button`,{type:`button`,className:`empty-template add`,onClick:i,title:s(`tpl.add`),children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:(0,X.jsx)(se,{})}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:s(`tpl.add`)}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:s(`tpl.addDesc`)})]})]})]})}),(0,X.jsx)(`div`,{className:`template-picker-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`empty-templates-reset`,onClick:a,children:[(0,X.jsx)(ae,{}),s(t?`tpl.resetConfirm`:`tpl.reset`)]})})]})})}function pp({editing:e,isNew:t,hasOverride:n,onDraft:r,onSave:i,onRestore:a,onRemove:o,onFill:s,onSend:c,onClose:l}){let u=Z(),d=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&l()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]),(0,m.useEffect)(()=>{let e=d.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight>300;e.style.height=`${Math.min(e.scrollHeight,300)}px`,e.style.overflowY=t?`auto`:`hidden`},[e.prompt]);let f=()=>{let t=e.title.trim(),n=e.prompt.trim();if(!t||!n){r({...e,error:u(`tpl.required`)});return}i({id:e.id,icon:e.icon.trim()||`📌`,title:t,desc:e.desc.trim(),prompt:n})},p=!!e.builtin&&!t;return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:l,children:(0,X.jsxs)(`div`,{className:`modal template-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`template-modal-head`,children:[(0,X.jsx)(`span`,{className:`template-modal-icon`,children:e.icon}),(0,X.jsx)(`span`,{className:`template-modal-badge`,children:u(p?`tpl.builtin`:`tpl.custom`)}),(0,X.jsx)(`span`,{className:`template-modal-title`,children:u(t?`tpl.newTitle`:`tpl.editTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-modal-close`,title:u(`close`),onClick:l,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`template-modal-body`,children:[(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldIcon`)}),(0,X.jsx)(`input`,{className:`template-field-input icon`,value:e.icon,maxLength:4,onChange:t=>r({...e,icon:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldTitle`)}),(0,X.jsx)(`input`,{className:`template-field-input`,value:e.title,placeholder:u(`tpl.fieldTitlePh`),onChange:t=>r({...e,title:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldDesc`)}),(0,X.jsx)(`input`,{className:`template-field-input`,value:e.desc,placeholder:u(`tpl.fieldDescPh`),onChange:t=>r({...e,desc:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldPrompt`)}),(0,X.jsx)(`textarea`,{ref:d,className:`template-field-prompt`,value:e.prompt,placeholder:u(`tpl.fieldPromptPh`),onChange:t=>r({...e,prompt:t.target.value})})]})]}),e.error&&(0,X.jsx)(`div`,{className:`template-error`,children:e.error}),(0,X.jsxs)(`div`,{className:`template-modal-actions`,children:[(0,X.jsxs)(`div`,{className:`template-modal-actions-left`,children:[!t&&p&&n&&(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn ghost`,title:u(`tpl.restoreTip`),onClick:a,children:u(`tpl.restore`)}),!t&&p&&(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn ghost danger`,title:u(`tpl.removeTip`),onClick:o,children:[(0,X.jsx)(R,{}),` `,u(`tpl.remove`)]}),!t&&!p&&(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn ghost danger`,title:u(`tpl.deleteTip`),onClick:o,children:[(0,X.jsx)(R,{}),` `,u(`tpl.delete`)]})]}),(0,X.jsxs)(`div`,{className:`template-modal-actions-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn`,onClick:f,children:u(`tpl.save`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn fill`,onClick:s,title:u(`tpl.fillTip`),children:u(`tpl.fill`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn send`,onClick:c,title:u(`tpl.sendTip`),children:[(0,X.jsx)(G,{}),` `,u(`tpl.sendNow`)]})]})]})]})})}var mp=class extends m.Component{state={message:null};static getDerivedStateFromError(e){return{message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`[ui-slot] entry "${this.props.entryId??this.props.label}" in slot "${this.props.slot??`?`}" crashed:`,e,t.componentStack)}render(){if(this.state.message===null)return this.props.children;let e=`slot=${this.props.slot??`?`} entry=${this.props.entryId??this.props.label}: ${this.state.message}`;return(0,X.jsxs)(`button`,{type:`button`,className:`slot-error`,title:e,"aria-label":this.props.label,onClick:()=>console.error(`[ui-slot] ${e}`),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`⚠`}),(0,X.jsx)(`span`,{children:this.props.label})]})}};function hp(e,t){return!e||e.length===0?null:(0,X.jsx)(`span`,{className:`slot-toolbar`,children:e.map((e,n)=>(0,X.jsx)(mp,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:gp(e,n,t)},`${e.id}#${n}`))})}function gp(e,t,n){let r=`${e.id}#${t}`,i=e.label||e.id,a=e.hint||i;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`slot-divider`,"aria-hidden":`true`},r):e.kind===`badge`?(0,X.jsx)(`span`,{className:`slot-badge`,title:a,children:e.badge??i},r):e.kind===`toggle`?(0,X.jsxs)(`button`,{type:`button`,className:`slot-btn${e.checked?` on`:``}`,title:a,"aria-label":i,"aria-pressed":!!e.checked,onClick:()=>n?.(e),children:[e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):null,(0,X.jsx)(`span`,{children:i})]},r):e.kind===`progress`?(0,X.jsx)(`span`,{className:`slot-progress`,title:`${a} ${e.progress??0}%`,children:(0,X.jsx)(`progress`,{value:e.progress??0,max:100})},r):e.kind===`input`?(0,X.jsx)(`input`,{className:`slot-input`,defaultValue:e.value??``,placeholder:i,title:a,"aria-label":i,onKeyDown:t=>{t.key===`Enter`&&!t.nativeEvent.isComposing&&n?.(e,t.target.value)}},`${r}:${e.value??``}`):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`slot-select`,title:a,"aria-label":i,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>n?.(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},r):(0,X.jsxs)(`button`,{type:`button`,className:`slot-btn`,title:a,"aria-label":i,onClick:()=>n?.(e),children:[e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):null,(0,X.jsx)(`span`,{children:i})]},r)}function _p(e,t,n){let r=[],i=[],a=!1,o=e=>{i.length!==0&&(a=!0,r.push((0,X.jsx)(`span`,{className:`slot-toolbar`,children:i.map((e,t)=>(0,X.jsx)(mp,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:gp(e,t,n)},`${e.id}#${t}`))},e)),i=[])};return e.forEach((e,n)=>{if(e.source===`host`){o(`gap${n}`);let i=t[e.id]??null;i&&(a=!0),r.push((0,X.jsx)(m.Fragment,{children:i},e.id))}else i.push(e)}),o(`tail`),a?(0,X.jsx)(X.Fragment,{children:r}):null}var vp=`#ffffff`,yp=`#1e1e1e`,bp=`.msg-actions, .msg-text-copy, .chead-copy, .stream-cursor, .msg-editor, .msg-collapse-btn, .msg-export-check, .toolcall-kill, .toolcall-open`;function xp(e,t=800,n=2){let r=Math.max(e,t,1);return r*n<=16384?n:+(r<=16384)}function Sp(e){let t=e.trim().toLowerCase();if(!t)return null;if(t===`transparent`)return{r:0,g:0,b:0,a:0};if(t.startsWith(`#`)){let e=t.slice(1);if(e.length===3||e.length===4){let t=Number.parseInt(e[0]+e[0],16),n=Number.parseInt(e[1]+e[1],16),r=Number.parseInt(e[2]+e[2],16),i=e.length===4?Number.parseInt(e[3]+e[3],16)/255:1;return[t,n,r,i].some(e=>Number.isNaN(e))?null:{r:t,g:n,b:r,a:i}}if(e.length===6||e.length===8){let t=Number.parseInt(e.slice(0,2),16),n=Number.parseInt(e.slice(2,4),16),r=Number.parseInt(e.slice(4,6),16),i=e.length===8?Number.parseInt(e.slice(6,8),16)/255:1;return[t,n,r,i].some(e=>Number.isNaN(e))?null:{r:t,g:n,b:r,a:i}}return null}let n=t.match(/^rgba?\(\s*([\s\S]+)\)$/);if(!n)return null;let r=n[1].trim(),i,a=1;if(r.includes(`/`)){let[e,t]=r.split(`/`);i=e.trim().split(/[\s,]+/).filter(Boolean),a=wp(t.trim())}else if(r.includes(`,`)){let e=r.split(`,`).map(e=>e.trim());e.length===4&&(a=wp(e.pop())),i=e}else i=r.split(/\s+/).filter(Boolean),i.length===4&&(a=wp(i.pop()));if(i.length!==3)return null;let o=Cp(i[0]),s=Cp(i[1]),c=Cp(i[2]);return[o,s,c,a].some(e=>Number.isNaN(e))?null:{r:o,g:s,b:c,a}}function Cp(e){return e.endsWith(`%`)?Math.round(Tp(Number.parseFloat(e),0,100)*2.55):Math.round(Tp(Number.parseFloat(e),0,255))}function wp(e){return e.endsWith(`%`)?Tp(Number.parseFloat(e)/100,0,1):Tp(Number.parseFloat(e),0,1)}function Tp(e,t,n){return Math.min(n,Math.max(t,e))}function Ep(e){let t=Tp(Math.round(e.r),0,255),n=Tp(Math.round(e.g),0,255),r=Tp(Math.round(e.b),0,255);return e.a<.996?`rgba(${t}, ${n}, ${r}, ${Math.round(Tp(e.a,0,1)*1e3)/1e3})`:`rgb(${t}, ${n}, ${r})`}function Dp(e,t){let n=Tp(e.a,0,1);return n<=0?{r:t.r,g:t.g,b:t.b,a:t.a}:n>=1?{r:e.r,g:e.g,b:e.b,a:1}:{r:e.r*n+t.r*(1-n),g:e.g*n+t.g*(1-n),b:e.b*n+t.b*(1-n),a:1}}function Op(e,t){let n=Sp(t)??{r:255,g:255,b:255,a:1},r=Sp(e);return!r||r.a<=.004?Ep({...n,a:1}):Ep(Dp(r,{...n,a:1}))}function kp(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function Ap(e){return kp(e)>.45}function jp(e){let t=document.createElement(`div`);t.style.cssText=`position:fixed;left:-99999px;top:0;width:8px;height:8px;pointer-events:none;background:${e}`,document.body.appendChild(t);let n=getComputedStyle(t).backgroundColor;return t.remove(),n}function Mp(){return getComputedStyle(document.documentElement).colorScheme.split(/\s+/).includes(`light`)?vp:yp}function Np(e){let t=Mp(),n=t;try{n=Op(jp(`var(--bg)`),t)}catch{n=t}try{let e=Op(jp(`var(--card-bg, var(--msgs-bg, var(--bg)))`),n),t=Sp(e);if(t&&kp(t)+t.a>0)return e}catch{}let r=e??null;for(;r;){let e=getComputedStyle(r).backgroundColor;if(e&&e!==`transparent`&&e!==`rgba(0, 0, 0, 0)`){let t=Op(e,n),r=Sp(e);if(r&&r.a>.04)return t}r=r.parentElement}return n}function Pp(e){return e instanceof HTMLElement||e instanceof SVGElement?e.style:null}function Fp(e,t){let n=Sp(e);return n?n.a<=.004?`transparent`:n.a>=.996?Ep({...n,a:1}):Ep(Dp(n,{...Sp(t)??{r:255,g:255,b:255,a:1},a:1})):null}function Ip(e,t,n){let r=getComputedStyle(e),i=Pp(t),a=n;if(i){let e=Fp(r.backgroundColor,n);e===`transparent`?i.backgroundColor=`transparent`:e&&(i.backgroundColor=e,a=e);let t=Fp(r.color,a);t&&t!==`transparent`&&(i.color=t);for(let[e]of[[`borderTopColor`,`border-top-color`],[`borderRightColor`,`border-right-color`],[`borderBottomColor`,`border-bottom-color`],[`borderLeftColor`,`border-left-color`],[`outlineColor`,`outline-color`],[`textDecorationColor`,`text-decoration-color`]]){let t=Fp(r[e],a);t&&t!==`transparent`&&(i[e]=t)}let o=Fp(r.fill,a);o&&o!==`transparent`&&r.fill!==`none`&&(i.fill=o);let s=Fp(r.stroke,a);s&&s!==`transparent`&&r.stroke!==`none`&&(i.stroke=s),i.backdropFilter=`none`,i.setProperty(`-webkit-backdrop-filter`,`none`),r.mixBlendMode&&r.mixBlendMode!==`normal`&&(i.mixBlendMode=`normal`),i.caretColor=`transparent`}let o=Array.from(e.children),s=Array.from(t.children),c=Math.min(o.length,s.length);for(let e=0;e<c;e++)Ip(o[e],s[e],a)}function Lp(e){e.querySelectorAll(bp).forEach(e=>e.remove())}function Rp(e,t={}){t.includeThinking||e.querySelectorAll(`.thinking`).forEach(e=>e.remove()),t.includeTools||e.querySelectorAll(`.toolcall`).forEach(e=>e.remove())}function zp(e,t,n={}){let r=e.cloneNode(!0);return Ip(e,r,t),Rp(r,n),Lp(r),r.classList.remove(`msg-export-selected`),r.style.margin=`0`,r.style.paddingLeft=``,r.removeAttribute(`id`),r.querySelectorAll(`[id]`).forEach(e=>e.removeAttribute(`id`)),r}async function Bp(e,t={}){let{toBlob:n}=await Go(async()=>{let{toBlob:e}=await import(`./es-DIDZppIF.js`);return{toBlob:e}},[]),r=t.backgroundColor??Np(e),i=Sp(r),a=await n(e,{pixelRatio:t.pixelRatio??2,backgroundColor:r,cacheBust:!1,style:{colorScheme:i&&!Ap(i)?`dark`:`light`}});if(!a)throw Error(`toBlob returned null`);return a}function Vp(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function Hp(e){return document.querySelector(`.msg[data-msg-id="${Vp(e)}"]`)??document.querySelector(`[data-msg-id="${Vp(e)}"]`)}function Up(){let e=Z(),t=Kd(),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(`pi-web-ui`),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(``),y=(0,m.useRef)(null),b=(0,m.useRef)(null),x=(0,m.useRef)(`#ffffff`);if((0,m.useEffect)(()=>{t.open&&(d(!1),g(!1),v(``))},[t.open]),yt(()=>{qd()},t.open),(0,m.useLayoutEffect)(()=>{if(!t.open)return;let e=!1,n=0;p(!0);let r=()=>{if(e||!b.current)return;let i=[],a=!1;for(let e of t.selectedIds){let t=Hp(e);t?i.push(t):a=!0}let o=t.includeThinking&&i.some(e=>e.querySelector(`.thinking`)&&!e.querySelector(`.thinking-body`))||t.includeTools&&i.some(e=>e.querySelector(`.toolcall`)&&!e.querySelector(`.toolcall-body`));if((a||o)&&n<12){n+=1,requestAnimationFrame(r);return}let s=i[0],c=Np(s??void 0);x.current=c;let l=document.createDocumentFragment();for(let e of i)l.appendChild(zp(e,c,{includeThinking:t.includeThinking,includeTools:t.includeTools}));b.current.replaceChildren(l);let u=y.current;if(u){u.style.backgroundColor=c;let e=Sp(c);if(u.style.colorScheme=e&&!Ap(e)?`dark`:`light`,s){let e=getComputedStyle(s).color;e&&(u.style.color=e)}}p(!1)},i=requestAnimationFrame(()=>requestAnimationFrame(r));return()=>{e=!0,cancelAnimationFrame(i),b.current?.replaceChildren()}},[t.open,t.selectedIds,t.includeThinking,t.includeTools]),!t.open)return null;let S=async()=>{let n=y.current;if(n&&!u&&t.selectedIds.length!==0){d(!0),v(``);try{let t=xp(n.scrollHeight,n.scrollWidth);if(t===0){v(e(`exportTooLong`));return}let r=await Bp(n,{backgroundColor:x.current,pixelRatio:t});await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),g(!0),window.setTimeout(()=>g(!1),1500)}catch(t){let n=t instanceof Error?t.message:String(t);v(`${e(`copyFailed`)}: ${n}`)}finally{d(!1)}}};return(0,X.jsxs)(`aside`,{className:`saveimg-dock`,role:`dialog`,"aria-label":e(`saveAsImage`),children:[(0,X.jsxs)(`div`,{className:`saveimg-head`,children:[(0,X.jsx)(`span`,{className:`saveimg-title`,children:e(`saveAsImage`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`close`),"aria-label":e(`close`),onClick:()=>qd(),children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`p`,{className:`saveimg-hint`,children:e(`exportSelectHint`)}),(0,X.jsxs)(`div`,{className:`saveimg-body`,children:[(0,X.jsx)(`div`,{className:`saveimg-preview`,children:(0,X.jsxs)(`div`,{ref:y,className:`saveimg-card${i?` saveimg-card--border`:``}`,children:[n.trim()?(0,X.jsx)(`div`,{className:`saveimg-card-title`,children:n.trim()}):null,(0,X.jsx)(`div`,{ref:b,className:`saveimg-card-md`}),o&&c.trim()?(0,X.jsx)(`div`,{className:`saveimg-card-wm`,children:c.trim()}):null]})}),(0,X.jsxs)(`div`,{className:`saveimg-options`,children:[(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t.includeTools,onChange:e=>Yd({includeTools:e.target.checked})}),(0,X.jsx)(`span`,{children:e(`exportIncludeTools`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t.includeThinking,onChange:e=>Yd({includeThinking:e.target.checked})}),(0,X.jsx)(`span`,{children:e(`exportIncludeThinking`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt`,children:[(0,X.jsx)(`span`,{children:e(`imageTitle`)}),(0,X.jsx)(`input`,{type:`text`,className:`dialog-input saveimg-input`,value:n,onChange:e=>r(e.target.value),placeholder:e(`imageTitlePlaceholder`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),(0,X.jsx)(`span`,{children:e(`imageBorder`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),(0,X.jsx)(`span`,{children:e(`imageWatermark`)})]}),(0,X.jsx)(`input`,{type:`text`,className:`dialog-input saveimg-input`,value:c,disabled:!o,onChange:e=>l(e.target.value),placeholder:e(`imageWatermarkPlaceholder`)}),(0,X.jsxs)(`div`,{className:`saveimg-copy-row`,children:[(0,X.jsx)(`span`,{className:`saveimg-count`,children:e(`exportSelectedCount`,{n:t.selectedIds.length})}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary saveimg-copy`,onClick:()=>void S(),disabled:u||f||t.selectedIds.length===0,title:e(`copyImageBtn`),children:[u||f?(0,X.jsx)(ye,{className:`saveimg-spin`}):h?(0,X.jsx)(Xe,{}):(0,X.jsx)(ze,{}),(0,X.jsx)(`span`,{children:e(u||f?`savingImage`:h?`copied`:`copyImageBtn`)})]})]})]}),_?(0,X.jsx)(`div`,{className:`saveimg-error`,children:_}):null]})]})}var Wp=new Map,Gp=15,Kp=30,qp=250,Jp=1200,Yp=1600;function Xp({kind:e,text:t,index:n,onRemoveQueued:r,onRecallQueued:i}){let a=Z();return(0,X.jsxs)(`div`,{className:`msg msg-user msg-queued`,"data-role":`user`,children:[(0,X.jsxs)(`div`,{className:`msg-meta`,children:[(0,X.jsx)(`span`,{className:`msg-role`,children:a(`role.user`)}),(0,X.jsx)(`span`,{className:`queued-tag ${e===`steer`?`steer`:`follow`}`,children:a(e===`steer`?`queueSteerTag`:`queueFollowTag`)}),(0,X.jsxs)(`div`,{className:`msg-queued-actions`,children:[i&&(0,X.jsx)(`button`,{type:`button`,className:`msg-queued-recall`,title:a(`queueRecallTip`),"aria-label":a(`queueRecallTip`),onClick:()=>i(e,t,n),children:`↩`}),r&&(0,X.jsx)(`button`,{type:`button`,className:`msg-queued-remove`,title:a(`queueRemoveTip`),"aria-label":a(`queueRemoveTip`),onClick:()=>r(e,t,n),children:`✕`})]})]}),(0,X.jsx)(`div`,{className:`msg-body`,children:(0,X.jsx)(`div`,{className:`msg-text`,children:(0,X.jsx)(uu,{text:t,hardBreaks:!0})})})]})}function Zp({compaction:e}){let t=Z(),[,n]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3)),i=e.reason===`manual`?t(`compactingReasonManual`):e.reason===`overflow`?t(`compactingReasonOverflow`):t(`compactingReasonThreshold`);return(0,X.jsxs)(`div`,{className:`compact-notice`,role:`status`,children:[(0,X.jsx)(`span`,{className:`compact-pulse`}),(0,X.jsxs)(`span`,{className:`compact-text`,children:[t(`compactingContext`),` · `,r,`s`]}),(0,X.jsx)(`span`,{className:`compact-reason`,children:i})]})}function Qp(e){return e.content.some(e=>e.type===`toolCall`)}function $p({state:e,liveOutputs:t,toolStatuses:n,onEdit:r,onKillBash:i,onRetry:a,onRemoveQueued:o,onRecallQueued:s,thinkingWrap:c,toolsWrap:l,toolImages:u,jumpTarget:d,onJumpDone:f,uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,uiChatEmpty:_,onUiAction:v}){let y=Z(),b=Kd(),x=(0,m.useRef)(null),[S,C]=(0,m.useState)(!0),w=(0,m.useRef)(!0),T=(0,m.useRef)(0),E=(0,m.useRef)(0),D=(0,m.useRef)(!1),O=(0,m.useRef)(0),[A,ee]=(0,m.useState)(()=>new Set),[j,M]=(0,m.useState)(!1),N=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,P=(0,m.useMemo)(()=>{let t=new Map;for(let n of e.messages)n.role===`toolResult`&&n.toolCallId&&t.set(n.toolCallId,n);return t},[e.messages]),F=(0,m.useMemo)(()=>Ef(e.messages),[e.messages]),I=[...N].reverse().find(e=>e.role!==`system`),L=I?I.id:null,R=e.messages.length>Kp?Math.max(0,e.messages.length-Gp):0,te=(0,m.useMemo)(()=>{let t=new Set;for(let n=0;n<R;n++){let r=e.messages[n];r.role!==`toolResult`&&(A.has(r.id)||t.add(r.id))}return t},[e.messages,R,A]),[z,B]=(0,m.useState)(()=>new Set),[V,ne]=(0,m.useState)(()=>new Set),H=(0,m.useRef)(new Map),U=(0,m.useRef)(new Map),W=(0,m.useRef)(new Map),G=(0,m.useRef)(0),re=(0,m.useMemo)(()=>{let t=new Map;for(let n of e.messages)t.set(n.id,Ff(n));return t},[e.messages]),ie=(0,m.useRef)(re);ie.current=re;let ae=(0,m.useRef)(z);ae.current=z;let oe=e.messages.length>Kp&&!j,se=(0,m.useRef)(oe);se.current=oe;let ce=Mf(e.messages,H.current,Yp),le=(0,m.useRef)(ce);le.current=ce;let ue=(0,m.useCallback)(()=>{let e=x.current;if(!e)return;if(!se.current){B(e=>e.size?new Set:e);return}let t=e.getBoundingClientRect(),n={top:t.top-Jp,bottom:t.bottom+Jp},r=[];for(let[e,t]of W.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),ae.current.has(e)||pe(e,n.bottom-n.top,ie.current.get(e))}let i=Af(r,n,le.current,ae.current);for(let e of i.hide){let t=W.current.get(e);t&&pe(e,t.offsetHeight,ie.current.get(e))}B(e=>jf(e,i))},[]),de=(0,m.useCallback)(()=>{G.current||=requestAnimationFrame(()=>{G.current=0,ue()})},[ue]);(0,m.useLayoutEffect)(()=>{ue()},[ue]);let fe=(0,m.useRef)(j);(0,m.useLayoutEffect)(()=>{fe.current&&!j&&ue(),fe.current=j},[j,ue]);let pe=(0,m.useCallback)((e,t,n)=>{n!==void 0&&(U.current.set(e,{h:t,len:n}),H.current.set(e,t))},[]),me=(0,m.useCallback)((e,t)=>{pe(e,t,ie.current.get(e))},[pe]),he=(0,m.useCallback)(e=>{e&&W.current.set(e.dataset.lazyId??``,e)},[]);(0,m.useEffect)(()=>{let t=new Set(e.messages.map(e=>e.id));for(let e of W.current.keys())t.has(e)||(W.current.delete(e),H.current.delete(e),U.current.delete(e));B(e=>{let n=!1,r=new Set;for(let i of e)t.has(i)?r.add(i):n=!0;return n?r:e})},[e.messages,A]),(0,m.useEffect)(()=>()=>cancelAnimationFrame(G.current),[]);let K=(0,m.useMemo)(()=>{let t=[];for(let n of e.messages){if(n.role!==`user`)continue;let e=n.content.map(e=>of(e)?.text??``).filter(Boolean).join(` `),r=Dd(e),i=r?r.userMessage??`skill:${r.name}`:e.trim();i&&t.push({id:n.id,text:i})}return t},[e.messages]),ge=(0,m.useMemo)(()=>{let e=new Map;return K.forEach((t,n)=>e.set(t.id,n)),e},[K]),[_e,ve]=(0,m.useState)(-1),q=(0,m.useRef)(-1),ye=(0,m.useRef)(K);(0,m.useEffect)(()=>{ye.current=K},[K]);let J=(0,m.useCallback)(()=>{let e=x.current,t=ye.current;if(!e||t.length===0)return;let n=e.getBoundingClientRect().top,r=-1;for(let i=0;i<t.length;i++){let a=e.querySelector(`[data-msg-id="${t[i].id}"]`);if(a){if(a.getBoundingClientRect().top<=n+140)r=i;else break}}r!==q.current&&(q.current=r,ve(r))},[]);(0,m.useEffect)(()=>{J()},[K,J]);let be=(0,m.useCallback)(e=>{ee(t=>t.has(e)?t:new Set(t).add(e))},[]);(0,m.useLayoutEffect)(()=>{Ud(e.messages.filter(Vd).map(e=>({id:e.id,role:e.role,content:e.content})))},[e.messages]),(0,m.useEffect)(()=>{if(b.open){for(let e of b.selectedIds)be(e);ne(e=>{let t=!1,n=new Set(e);for(let e of b.selectedIds)n.has(e)||(n.add(e),t=!0);return t?n:e})}},[b.open,b.selectedIds,be]),(0,m.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey)||e.key.toLowerCase()!==`f`)return;let t=e.target;(!t||t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable)&&(e.preventDefault(),M(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let xe=(0,m.useCallback)(e=>{ee(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),Se=(0,m.useCallback)(t=>{let n=e.messages.findIndex(e=>e.id===t);(0,k.flushSync)(()=>{n>=0&&n<R&&!A.has(t)&&be(t),ne(e=>e.has(t)?e:new Set(e).add(t))});let r=ye.current.findIndex(e=>e.id===t);q.current=r,ve(r),requestAnimationFrame(()=>{let e=x.current?.querySelector(`[data-msg-id="${t}"]`);e&&(x.current?.querySelectorAll(`.msg-flash`).forEach(e=>e.classList.remove(`msg-flash`)),e.scrollIntoView({block:`start`}),e.classList.remove(`msg-flash`),e.offsetWidth,e.classList.add(`msg-flash`),e!==x.current?.lastElementChild&&(D.current=!0))})},[e.messages,R,A,be]),[Ce,we]=(0,m.useState)(null),Te=(0,m.useRef)(null),Ee=(0,m.useRef)(null);(0,m.useEffect)(()=>{let t=Te.current;if(!t||t.convId!==e.conversationId){Te.current={convId:e.conversationId,ids:new Set(e.messages.filter(e=>e.role===`compactionSummary`).map(e=>e.id))},Ee.current=null,we(null);return}for(let n of e.messages)if(n.role===`compactionSummary`&&!t.ids.has(n.id)){t.ids.add(n.id),we(n.id);break}},[e.messages,e.conversationId]),(0,m.useEffect)(()=>{Ce&&Ee.current!==Ce&&(Ee.current=Ce,Se(Ce))},[Ce,Se]);let Y=(0,m.useMemo)(()=>d?e.messages.find(e=>e.role===d.role&&e.timestamp===d.timestamp)?.id??null:null,[e.messages,d]);(0,m.useEffect)(()=>{if(d){if(Y){Se(Y),f?.();return}e.sessionFile===d.path&&e.messages.length>0&&f?.()}},[Y,Se,f,d,e.sessionFile,e.messages.length]);let De=(0,m.useCallback)(()=>{let e=x.current;if(!e)return;let t=e.scrollTop-T.current,n=e.scrollHeight-E.current;T.current=e.scrollTop,E.current=e.scrollHeight;let r=e.scrollHeight-e.scrollTop-e.clientHeight<80,i=Date.now()<O.current,a=Jf({dSt:t,dSh:n,escaped:D.current,graceActive:i,stuck:w.current});a.reassert&&(O.current=Date.now()+qp,e.scrollTop=e.scrollHeight),a.flipEscape&&(D.current=!0),r&&t>=0&&(D.current=!1),i||(t<0?w.current=r&&!D.current:r&&(w.current=!0)),C(w.current),J(),de()},[J,de]),Oe=(0,m.useRef)(!1);(0,m.useEffect)(()=>{let t=Oe.current;if(Oe.current=!!e.isStreaming,t&&!e.isStreaming&&!D.current){let e=()=>{let e=x.current;e&&!D.current&&(e.scrollTop=e.scrollHeight,w.current=!0,C(!0))};requestAnimationFrame(()=>requestAnimationFrame(e));let t=setTimeout(e,180);return()=>clearTimeout(t)}},[e.isStreaming]),(0,m.useEffect)(()=>{let e=x.current;e&&w.current&&(e.scrollTop=e.scrollHeight)},[N,e.isStreaming,t]);let ke=e.queue.steering.join(`\0`)+``+e.queue.followUp.join(`\0`);(0,m.useEffect)(()=>{let e=x.current;e&&w.current&&(e.scrollTop=e.scrollHeight)},[ke]),(0,m.useEffect)(()=>{let e=x.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.clientHeight,n=new ResizeObserver(()=>{let n=e.clientHeight,r=n-t;t=n,r>0&&(e.scrollTop=Math.min(e.scrollTop,e.scrollHeight-e.clientHeight))});return n.observe(e),()=>n.disconnect()},[]),(0,m.useEffect)(()=>{let e=x.current;if(!e||typeof MutationObserver>`u`)return;let t=!1,n=new MutationObserver(()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let e=x.current;e&&w.current&&!D.current&&(e.scrollTop=e.scrollHeight,C(!0))}))});return n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[]);let Ae=(0,m.useCallback)(()=>{if(!x.current)return;w.current=!0,D.current=!1,C(!0),O.current=Date.now()+qp;let e=()=>{let e=x.current;e&&w.current&&!D.current&&(O.current=Date.now()+qp,e.scrollTop=e.scrollHeight)};e(),requestAnimationFrame(()=>requestAnimationFrame(e)),setTimeout(e,120),setTimeout(e,300),setTimeout(e,600)},[]),je=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=je.current,t=x.current;if(!e||!t)return;let n=n=>{n.preventDefault();let r=e.querySelector(`.qn-list`);if(r&&r.contains(n.target)&&r.scrollHeight>r.clientHeight){r.scrollTop+=n.deltaY;return}t.scrollTop+=n.deltaY};return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)},[]);let[Me,Ne]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=()=>{Ne(x.current?.clientHeight??0),de()};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[de]);let Pe=K.length,Fe=(0,m.useMemo)(()=>Pe===0?27:Math.max(4,Math.min(27,Math.floor(((Me||600)-16)/Pe)-3)),[Pe,Me]),Ie=Fe<20;return(0,X.jsxs)(`div`,{className:`messages-wrap${b.open?` messages-exporting`:``}`,children:[(0,X.jsxs)(`div`,{className:`messages${j||S?``:` anchor-live`}`,ref:x,onScroll:De,children:[e.messages.length===0&&!e.streamingMessage&&(0,X.jsxs)(`div`,{className:`empty-state`,children:[(0,X.jsx)(up,{}),_&&_.length>0&&(0,X.jsx)(`div`,{className:`chat-empty-slots`,children:hp(_,v)})]}),e.messages.map((o,s)=>{if(o.role===`system`)return null;let d=s<R,f=d&&A.has(o.id);if(d&&!f)return o.role===`toolResult`?null:(0,X.jsx)(Df,{message:o,onExpand:be},o.id);let m=o.role===`user`?ge.get(o.id):void 0,_=!oe||ce.has(o.id)||V.has(o.id)||!z.has(o.id);return(0,X.jsx)(kf,{id:o.id,show:_,height:If(o.id,re.get(o.id)??-1,U.current,Nf(o.role,o.customType)),containerRef:x,onMeasured:me,lazyRef:he,children:(0,X.jsx)(gf,{uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,onUiAction:v,message:o,qnIndex:m,qnActive:m===void 0?void 0:m===_e,onJump:Se,toolResults:P,liveOutputs:Qp(o)?t:Wp,toolStatuses:n,streaming:e.isStreaming,onKillBash:i,onRetry:o.id===L?a:void 0,toolsWrap:l,toolImages:u,thinkingWrap:c,isLast:o.id===L,onEdit:r,questionAttachments:F.get(o.id),onCollapse:f?xe:void 0,searchActive:j,autoExpand:o.id===Ce},o.id)},o.id)}),e.streamingMessage&&(0,X.jsx)(gf,{uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,onUiAction:v,message:e.streamingMessage,toolResults:P,liveOutputs:Qp(e.streamingMessage)?t:Wp,toolStatuses:n,streaming:!0,isLast:!0,onEdit:r,onKillBash:i,toolsWrap:l,toolImages:u,thinkingWrap:c,searchActive:j},e.streamingMessage.id),e.retry&&e.isStreaming&&(0,X.jsxs)(`div`,{className:`retry-notice`,role:`status`,title:e.retry.errorMessage||void 0,children:[(0,X.jsx)(`span`,{className:`retry-pulse`}),(0,X.jsx)(`span`,{className:`retry-text`,children:e.retry.maxAttempts>0?y(`retryingApi`,{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):y(`retryingApiSoon`,{error:e.retry.errorMessage})})]}),e.compaction&&(0,X.jsx)(Zp,{compaction:e.compaction}),e.isStreaming&&N.length===0&&(0,X.jsx)(`div`,{className:`streaming-wait`,children:y(`waitingResponse`)}),e.queue.steering.map((e,t)=>(0,X.jsx)(Xp,{kind:`steer`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-steer-${t}`)),e.queue.followUp.map((e,t)=>(0,X.jsx)(Xp,{kind:`followUp`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-fu-${t}`))]}),!S&&(0,X.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:Ae,children:[(0,X.jsx)(rt,{}),` `,y(`backToBottom`)]}),(0,X.jsx)(qf,{containerRef:x,messages:N,collapsedIds:te,toolResults:P,onExpand:be,onProgrammaticScroll:()=>{D.current=!0,w.current=!1,C(!1)},open:j,onClose:()=>M(!1)}),K.length>0&&(0,X.jsxs)(`div`,{className:`qn-rail ${Ie?`many`:``}`,ref:je,"aria-label":y(`questionNavTitle`),style:{"--rail-gap":`${Fe}px`},children:[K.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`qn-bar ${t===_e?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Se(e.id),children:(0,X.jsxs)(`span`,{className:`qn-bar-text`,children:[t+1,`. `,e.text]})},e.id)),Ie&&(0,X.jsx)(`div`,{className:`qn-list`,children:K.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`qn-list-item ${t===_e?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Se(e.id),children:[(0,X.jsx)(`span`,{className:`qn-list-idx`,children:t+1}),(0,X.jsx)(`span`,{className:`qn-list-text`,children:e.text})]},e.id))})]}),(0,X.jsx)(Up,{})]})}function em(e,t){return t?e.trim()?`${e.replace(/\s+$/,``)}\n${t}`:t:e}function tm(e,t,n){let r=null;return e&&e.text&&e.ts>0&&(r={text:e.text,ts:e.ts}),t&&t.text&&t.ts>(r?.ts??0)&&(r=t),!r||r.ts<=n?null:r}function nm(e){return e.key?`key:${e.key}`:e.mode===`conversation`?e.conversationId?`conv:id:${e.conversationId}`:e.sessionPath?`conv:path:${e.sessionPath}`:null:e.path?`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`:null}function rm(e,t){return t?e?{key:t,clear:e!==t}:{key:t,clear:!1}:{key:e,clear:!1}}function im(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=new Set(e.map(nm).filter(e=>e!==null)),r=[...e];for(let e of t){let t=nm(e);if(t!==null){if(n.has(t))continue;n.add(t)}r.push(e)}return r}function am(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var om=``;function sm(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function cm(e,t){return{first:!e.slice(0,t).includes(`
|
|
355
355
|
`),last:!e.slice(t).includes(`
|
|
356
|
-
`)}}var lm=null;function um(){if(lm?.isConnected)return lm;let e=document.createElement(`div`);e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-caret-mirror`,``);let t=e.style;return t.position=`fixed`,t.top=`0`,t.left=`-99999px`,t.visibility=`hidden`,t.pointerEvents=`none`,t.margin=`0`,t.padding=`0`,t.border=`0`,t.boxSizing=`border-box`,t.overflow=`visible`,document.body.appendChild(e),lm=e,e}function dm(e,t){let n=getComputedStyle(e),r=t.style;r.fontFamily=n.fontFamily,r.fontSize=n.fontSize,r.fontStyle=n.fontStyle,r.fontWeight=n.fontWeight,r.fontVariant=n.fontVariant,r.fontStretch=n.fontStretch,r.lineHeight=n.lineHeight,r.letterSpacing=n.letterSpacing,r.wordSpacing=n.wordSpacing,r.textTransform=n.textTransform,r.textIndent=n.textIndent,r.tabSize=n.tabSize,r.whiteSpace=n.whiteSpace||`pre-wrap`,r.overflowWrap=n.overflowWrap||`break-word`,r.wordBreak=n.wordBreak||`normal`,r.direction=n.direction,r.writingMode=n.writingMode,r.paddingLeft=n.paddingLeft,r.paddingRight=n.paddingRight;let i=e.clientWidth;return i>0?(r.width=`${i}px`,i):0}function fm(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=om,e.appendChild(n),n.offsetTop}function pm(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=cm(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=um();if(dm(e,i)<=0)return r;let a=fm(i,t.slice(0,n)),o=fm(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:sm(a,o,am(e))}var mm=`pi-web-ui:prompt-history`,hm=`pi-web-ui:prompt-history-settings`,gm={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function _m(e){let t=gm;if(!e||typeof e!=`object`)return{...t};let n=e,r=typeof n.maxEntries==`number`?Math.floor(n.maxEntries):t.maxEntries;(!Number.isFinite(r)||r<1)&&(r=1),r>500&&(r=500);let i=typeof n.charLimit==`number`?Math.floor(n.charLimit):t.charLimit;(!Number.isFinite(i)||i<100)&&(i=100),i>2e4&&(i=2e4);let a=typeof n.charLimitEnabled==`boolean`?n.charLimitEnabled:t.charLimitEnabled;return{maxEntries:r,charLimitEnabled:a,charLimit:i}}function vm(){try{let e=localStorage.getItem(hm);return e?_m(JSON.parse(e)):{...gm}}catch{return{...gm}}}function ym(e){let t=_m(e);try{localStorage.setItem(hm,JSON.stringify(t))}catch{}try{let e=Sm();t.charLimitEnabled&&(e=e.map(e=>e.length>t.charLimit?e.slice(0,t.charLimit):e)),e.length>t.maxEntries&&(e=e.slice(e.length-t.maxEntries)),Cm(e)}catch{}}function bm(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}return t}function xm(e,t,n=100){let r=t.trim();if(!r||e.length>0&&e[e.length-1]===r)return e;let i=[...e,r];return i.length>n?i.slice(i.length-n):i}function Sm(){try{let e=localStorage.getItem(mm);return e?bm(JSON.parse(e)):[]}catch{return[]}}function Cm(e){let t=e;for(;t;)try{localStorage.setItem(mm,JSON.stringify(t));return}catch(e){if(!(e instanceof DOMException&&(e.name===`QuotaExceededError`||e.code===22))||t.length<=1)return;t=t.slice(Math.ceil(t.length/2))}}function wm(e){let t=e.trim();if(!t)return;let n=vm();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));let r=Sm(),i=xm(r,t,n.maxEntries);i!==r&&Cm(i)}function Tm(){try{localStorage.removeItem(mm)}catch{}}var Em=`skill:`;function Dm(e,t){let n=e.toLowerCase();return t===`skill`&&n.startsWith(`skill:`)?[n,n.slice(6)]:[n]}function Om(e,t){let n=t.toLowerCase();return n?e.filter(e=>Dm(e.name,e.source).some(e=>e.startsWith(n))):[...e]}var km=new Set([`p`,`page`,`pages`,`web`,`网页`,`页面`]);function Am(e,t,n,r=10){if(!Array.isArray(t))return[];let i=String(n??``).toLowerCase(),a=i===``||km.has(i),o=[];for(let n of t){if(!n||typeof n.origin!=`string`||!n.origin||n.open!==!0)continue;let t=typeof n.title==`string`&&n.title.trim()?n.title.trim():n.origin;if(!a&&!t.toLowerCase().includes(i)&&!n.origin.toLowerCase().includes(i))continue;let s=t.indexOf(` · `),c=s===-1?`page · ${t}`:`page · ${t.slice(s+3)}`;if(o.push({providerId:`host:pages`,providerLabel:e,title:c,hint:n.origin,text:t,attachments:[{path:n.origin,name:t,mode:`page`}]}),o.length>=Math.max(0,r))break}return o}function jm(e,t,n=10){if(!Array.isArray(t))return[];let r=[];for(let i of t.slice(0,Math.max(0,n))){if(!i||typeof i!=`object`)continue;let t=i;typeof t.path==`string`&&t.path&&typeof t.name==`string`&&t.name&&r.push({providerId:`host:files`,providerLabel:e,title:t.name,hint:t.path,text:`@${t.name}`,attachments:[{path:t.path,name:t.name,mode:`reference`,...t.type===`dir`?{isDir:!0}:{}}]})}return r}function Mm(e,t,n,r=10){if(!Array.isArray(n))return[];let i=[];for(let a of n.slice(0,Math.max(0,r))){if(!a||typeof a!=`object`)continue;let n=a;if(typeof n.title!=`string`||!n.title.trim())continue;let r=Array.isArray(n.attachments)?n.attachments.filter(e=>!!e&&typeof e==`object`&&typeof e.path==`string`).slice(0,4).map(e=>{let t=e.mode;return{path:e.path,...typeof e.name==`string`?{name:e.name}:{},...t===`inline`||t===`reference`||t===`lines`||t===`page`?{mode:t}:{},...typeof e.isDir==`boolean`?{isDir:e.isDir}:{}}}):void 0;i.push({providerId:e,providerLabel:t,title:n.title.trim(),...typeof n.hint==`string`&&n.hint?{hint:n.hint}:{},...typeof n.text==`string`&&n.text?{text:n.text}:{},...r?.length?{attachments:r}:{}})}return i}function Nm(e,t,n,r=15,i){if(!Array.isArray(t)||r<=0)return[];let a=String(n??``).toLowerCase(),o=a.startsWith(Em),s=o?a.slice(Em.length):a,c=[],l=[],u=o||s.length>=3;for(let n of t){if(n.source!==`skill`)continue;let t=n.name.startsWith(`skill:`)?n.name.slice(Em.length):n.name,r=t.toLowerCase(),a=i?i(n):n.description??``,o=a.toLowerCase(),d=(n.descriptionEn??``).toLowerCase(),f={providerId:`host:skills`,providerLabel:e,title:t,hint:a||`Skill ${t}`,text:`@skill:${t}`};s?r.includes(s)?c.push(f):u&&(o.includes(s)||d.includes(s))&&l.push(f):c.push(f)}return[...c,...l].slice(0,Math.max(0,r))}function Pm(e,t,n=30){let r=String(t??``).toLowerCase(),i=e.pages??[],a=e.skills??[],o=e.files??[],s=e.plugins??[],c;return c=r.startsWith(`skill:`)?[...a,...i,...o,...s]:[...i,...a,...o,...s],c.slice(0,Math.max(0,n))}function Fm(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function Im(e,t){let n=typeof e==`string`?e:``,r=Math.max(0,Math.min(typeof t==`number`&&Number.isFinite(t)?Math.floor(t):0,n.length)),i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a===-1||!Fm(a>0?i[a-1]:void 0))return null;let o=i.slice(a+1);return/[\s@]/.test(o)?null:{start:a,query:o}}function Lm(e){let t=e.query;if(!t||!t(`(pointer: coarse)`)||!t(`(hover: none)`))return!1;let n=e.userAgent??``;return!(/Windows|CrOS/i.test(n)||/Linux/i.test(n)&&!/Android/i.test(n)||/Macintosh/i.test(n)&&(e.maxTouchPoints??0)<=1)}function Rm(){return typeof window>`u`||typeof navigator>`u`||typeof window.matchMedia!=`function`?!1:Lm({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}var zm=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Bm=(0,m.memo)(function({state:e,models:t,modelsLoading:n,onManageModels:r,providerKeys:i,defaultModel:a,compact:o=!1,only:s}){let c=Z(),l=e?.model,u=l?`${l.provider}/${l.id}`:null,[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(``),[v,y]=(0,m.useState)(null),[b,x]=(0,m.useState)({}),S=(0,m.useRef)(null),C=(0,m.useRef)(null),[w,T]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!d){T(null);return}if(t.length===0)return;let e=requestAnimationFrame(()=>{let e=C.current;e&&T(e.offsetWidth)});return()=>cancelAnimationFrame(e)},[d,t.length]),(0,m.useEffect)(()=>{d&&x($f())},[d]),(0,m.useEffect)(()=>{d||(_(``),y(null))},[d]);let E=(0,m.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.provider,(e.get(n.provider)??0)+1);let n=[];for(let[t,r]of[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))){let e=i[t];if(e&&e.length>1)for(let i of e)n.push({provider:t,keyName:i.name,count:r});else n.push({provider:t,keyName:null,count:r})}return n},[t,i]),D=(0,m.useMemo)(()=>Qf(t,b),[t,b]),O=(0,m.useMemo)(()=>{let e=D;v&&(e=e.filter(e=>e.provider===v.provider));let t=g.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.provider.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)):e},[D,g,v]),k=(0,m.useMemo)(()=>{let e=[];for(let t of O){let n=i[t.provider];if(!n||n.length<=1){e.push({model:t,key:null});continue}let r=n.find(e=>e.active)??n[0];if(v?.provider===t.provider&&v.keyName){let e=n.find(e=>e.name===v.keyName);e&&(r=e)}e.push({model:t,key:r})}return e},[O,i,v]),[A,ee]=(0,m.useState)(!1),j=e?.availableThinkingLevels&&e.availableThinkingLevels.length>0?new Set(e.availableThinkingLevels):null,N=zm.map(e=>({value:e,label:c(`thinking.${e}`),supported:!j||j.has(e)})),P=e=>N.find(t=>t.value===e)?.label??e,F=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!d){F.current=!1;return}F.current||t.length>0||n||(F.current=!0,ee(!0),$({type:`list_models`})||ee(!1))},[d,t.length,n]),(0,m.useEffect)(()=>{ee(!1)},[t]),(0,m.useEffect)(()=>{d&&(S.current?.querySelector(`.dd-item.active`))?.scrollIntoView({block:`nearest`})},[d,u,t.length]);let I=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`availableModels`)}),(0,X.jsxs)(`div`,{className:`dd-search-row`,children:[(0,X.jsx)(ie,{}),(0,X.jsx)(`input`,{className:`dd-search`,type:`text`,placeholder:c(`searchModels`),value:g,onChange:e=>_(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`dd-model-body`,children:[E.length>1&&(0,X.jsxs)(`div`,{className:`dd-provider-col`,children:[(0,X.jsx)(`div`,{className:`dd-provider-head`,children:c(`providers`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-provider-item ${v===null?`active`:``}`,onClick:()=>y(null),children:(0,X.jsx)(`span`,{children:c(`allProviders`)})}),E.map(e=>{let t=v?.provider===e.provider&&v?.keyName===e.keyName;return(0,X.jsxs)(`button`,{type:`button`,className:`dd-provider-item ${t?`active`:``}`,onClick:()=>y(t?null:{provider:e.provider,keyName:e.keyName}),title:e.keyName?`${e.provider} · ${e.keyName}`:`${e.provider} · ${e.count}`,children:[(0,X.jsxs)(`span`,{className:`dd-provider-txt`,children:[(0,X.jsx)(`span`,{className:`dd-provider-name`,children:e.provider}),e.keyName&&(0,X.jsx)(`span`,{className:`dd-provider-key`,children:e.keyName})]}),(0,X.jsx)(`span`,{className:`dd-provider-count`,children:e.count})]},e.keyName?`${e.provider}::${e.keyName}`:e.provider)})]}),(0,X.jsxs)(`div`,{className:`dd-model-scroll`,ref:S,children:[(A||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`loading`)}),t.length===0&&!A&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`noModels`)}),O.length===0&&t.length>0&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`noModelMatches`)}),k.map(e=>{let t=e.model,n=u===t.id&&(!e.key||e.key.active),r=a!==void 0&&a===t.id;return(0,X.jsxs)(St,{active:n,onClick:()=>{e.key&&!e.key.active&&$({type:`activate_provider_key`,provider:t.provider,keyName:e.key.name}),u!==t.id&&$({type:`set_model`,modelId:t.id}),f(!1)},children:[(0,X.jsxs)(`span`,{className:`dd-model-cell`,children:[(0,X.jsx)(`span`,{className:`dd-model-name`,children:t.name}),(0,X.jsxs)(`span`,{className:`dd-model-meta`,children:[(0,X.jsx)(`span`,{className:`dd-model-provider`,children:t.provider}),(0,X.jsx)(`span`,{className:`dd-model-id`,children:t.id.split(`/`).slice(1).join(`/`)}),e.key&&(0,X.jsxs)(`span`,{className:`dd-model-key ${e.key.active?`active`:``}`,children:[e.key.active?`●`:`○`,` `,e.key.name]}),(b[t.id]??0)>0&&(0,X.jsx)(`span`,{className:`dd-model-usage`,children:c(`modelUsedCount`,{n:b[t.id]})}),(t.reasoning||t.vision)&&(0,X.jsxs)(`span`,{className:`dd-model-badges`,children:[t.reasoning&&(0,X.jsx)(`span`,{className:`dd-model-badge`,children:c(`reasoning`)}),t.vision&&(0,X.jsx)(`span`,{className:`dd-model-badge`,children:c(`vision`)})]})]})]}),a!==void 0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-star-btn ${r?`active`:``}`,title:r?`当前全局默认模型(点击取消默认)`:`设为全局默认模型`,onClick:e=>{e.stopPropagation(),$(r?{type:`clear_default_model`}:{type:`set_default_model`,modelId:t.id})},children:r?`★`:`☆`})]},e.key?`${t.id}::${e.key.name}`:t.id)})]})]}),(0,X.jsxs)(`div`,{className:`dd-footer`,children:[a!==void 0&&a&&(0,X.jsxs)(`div`,{className:`dd-default-banner`,children:[(0,X.jsxs)(`div`,{className:`dd-default-banner-left`,children:[(0,X.jsx)(`span`,{className:`dd-default-banner-star`,children:`★`}),(0,X.jsx)(`span`,{className:`dd-default-banner-label`,children:`默认模型`}),(0,X.jsx)(`span`,{className:`dd-default-banner-name`,title:`默认模型: ${a}`,children:a.split(`/`).slice(1).join(`/`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`dd-default-banner-clear`,title:`清除全局默认模型`,onClick:()=>$({type:`clear_default_model`}),children:`✕ 清除`})]}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`list_models`}),children:c(`refreshModels`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>{f(!1),r()},children:c(`manageModels`)})]})]}),L=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`thinkingLevel`)}),N.map(t=>(0,X.jsx)(St,{active:e?.thinkingLevel===t.value,disabled:!t.supported,title:t.supported?void 0:c(`thinkingUnsupported`),onClick:()=>{e?.thinkingLevel!==t.value&&$({type:`set_thinking`,level:t.value}),h(!1)},children:t.label},t.value))]}),R=(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Le,{}),(0,X.jsx)(`span`,{className:`chip-model`,children:l?l.name:c(`selectModel`)}),!o&&l?.vision&&(0,X.jsx)(`span`,{className:`chip-vision`,title:c(`vision`),children:`🖼`}),!o&&l&&(0,X.jsx)(`span`,{className:`chip-sub`,children:l.provider})]}),open:d,onOpenChange:f,align:`left`,menuClassName:`dd-menu-model`,menuRef:C,menuStyle:w==null?void 0:{width:w},direction:`up`,children:I}),te=(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:c(`thinkingChip`,{level:e?P(e.thinkingLevel):`—`})})]}),open:p,onOpenChange:h,align:`left`,direction:`up`,children:L});if(s===`model`)return R;if(s===`thinking`)return te;let z=e?.thinkingLevel&&e.thinkingLevel!==`off`;return(0,X.jsxs)(`div`,{className:`model-thinking-capsule`,children:[(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Le,{}),(0,X.jsx)(`span`,{className:`capsule-model-name`,children:l?l.name:c(`selectModel`)}),!o&&l?.vision&&(0,X.jsx)(`span`,{className:`chip-vision`,title:c(`vision`),children:`🖼`})]}),triggerClassName:`capsule-segment capsule-model`,open:d,onOpenChange:f,align:`left`,menuClassName:`dd-menu-model`,menuRef:C,menuStyle:w==null?void 0:{width:w},direction:`up`,children:I}),(0,X.jsx)(`div`,{className:`capsule-divider`}),(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`thinking-pulse-dot ${z?`on`:``}`}),(0,X.jsx)(`span`,{className:`capsule-thinking-text`,children:e?P(e.thinkingLevel):`—`})]}),triggerClassName:`capsule-segment capsule-thinking`,open:p,onOpenChange:h,align:`left`,direction:`up`,children:L})]})}),Vm=[`standard`,`ptc`,`minimal`,`cordis`];function Hm(e){return[...e].sort((e,t)=>{let n=Number.isSafeInteger(e.order)?e.order:Vm.indexOf(e.id),r=Number.isSafeInteger(t.order)?t.order:Vm.indexOf(t.id),i=n>=0?n:1e3,a=r>=0?r:1e3;return i===a?e.id.localeCompare(t.id):i-a})}var Um=(0,m.memo)(function({preset:e,presets:t,defaultPreset:n,blank:r,conversationId:i,compact:a=!1}){let o=Z(),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(e?.id??n);if((0,m.useEffect)(()=>{u(e?.id??n)},[i,e?.id,n]),t.length===0)return null;let d=e?.locked||!r,f=Hm(t),p=f.find(t=>t.id===e?.id),h=f.find(e=>e.id===l)??p,g=t=>{u(t),c(!1),r&&t!==e?.id&&$({type:`dsh_preset_select`,preset:t})};if(a){let t=p?.description??p?.id??o(`dshPreset`);return(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Le,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:d?`${t}(${o(`dshPresetLocked`)})`:t,children:[p?.name??p?.id??e?.name??o(`dshPreset`),d&&(0,X.jsx)(q,{style:{marginLeft:3}})]})]}),open:s&&!d,onOpenChange:c,direction:`up`,align:`left`,children:f.map(t=>(0,X.jsxs)(St,{active:t.id===e?.id,disabled:!!t.broken,title:t.broken??t.description??t.id,onClick:()=>g(t.id),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[t.name??t.id,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetUser`)}),t.id===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:o(`dshPresetBroken`)})]}),t.description&&!t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:t.description})]},t.id))})}return(0,X.jsxs)(`div`,{className:`dsh-presetbar`,"data-testid":`dsh-presetbar`,children:[(0,X.jsxs)(`span`,{className:`dsh-preset-label`,children:[(0,X.jsx)(Le,{}),o(`dshPreset`)]}),(0,X.jsx)(xt,{trigger:(0,X.jsxs)(`span`,{title:p?.description??p?.id??``,children:[p?.name??p?.id??e?.name??`…`,d&&(0,X.jsxs)(`span`,{className:`dsh-preset-lock`,title:o(`dshPresetBlankOnly`),children:[(0,X.jsx)(q,{}),` `,o(`dshPresetLocked`)]})]}),open:s&&!d,onOpenChange:c,children:f.map(t=>(0,X.jsxs)(St,{active:t.id===e?.id,disabled:!!t.broken,title:t.broken??t.description??t.id,onClick:()=>g(t.id),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[t.name??t.id,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetUser`)}),t.id===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:o(`dshPresetBroken`)})]}),t.description&&!t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:t.description})]},t.id))}),!d&&(0,X.jsx)(`span`,{className:`dsh-preset-hint`,title:o(`dshPresetBlankOnly`),children:o(`dshPresetBlankOnly`)}),h?.id===`minimal`&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:o(`dshPresetMinimalNote`)}),(0,X.jsxs)(`button`,{type:`button`,className:`chip`,title:o(`dshPresetNewChat`),onClick:()=>{$({type:`new_chat`,preset:h?.id??l}),Vn()},children:[(0,X.jsx)(ce,{}),` `,o(`dshPresetNewChat`)]})]})}),Wm=[`read-only`,`workspace-write-never`,`danger-full-access`],Gm=[`read-only`,`workspace-write-never`,`danger-full-access`];function Km(e){return e===`read-only`?`dshPermReadOnly`:e===`danger-full-access`?`dshPermFullAccess`:`dshPermWorkspaceWrite`}function qm(e){return e===`read-only`?`dshPermReadOnlyDesc`:e===`danger-full-access`?`dshPermFullAccessDesc`:`dshPermWorkspaceWriteDesc`}var Jm=(0,m.memo)(function({current:e,options:t,defaultPreset:n,conversationId:r,compact:i=!1}){let a=Z(),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1);(0,m.useEffect)(()=>{l(!1),s(!1)},[r]);let u=Wm.filter(e=>t.some(t=>t.value===e));if(u.length===0)return null;let d=e??n,f=!!e&&!u.includes(e),p=e=>{if(e===`danger-full-access`&&e!==d&&!c){l(!0);return}l(!1),s(!1),e!==d&&$({type:`dsh_permission_set`,preset:e})};if(i){let r=a(f?`dshPermCustom`:Km(d)),i=f?e??r:a(qm(d));return(0,X.jsxs)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(H,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:i,children:[r,d===`danger-full-access`&&(0,X.jsx)(at,{style:{marginLeft:3}})]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},direction:`up`,align:`left`,children:[u.map(e=>{let r=t.find(t=>t.value===e);return(0,X.jsxs)(St,{active:e===d,title:r?.description??a(qm(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(Km(e)),e===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)}),e===`danger-full-access`&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:a(`dshPermFullAccessTag`)})]}),(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:a(qm(e))})]},e)}),c&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:a(`dshPermConfirmFull`)})]})}return(0,X.jsxs)(`div`,{className:`dsh-presetbar`,"data-testid":`dsh-permissionbar`,children:[(0,X.jsxs)(`span`,{className:`dsh-preset-label`,children:[(0,X.jsx)(H,{}),a(`dshPerm`)]}),(0,X.jsx)(xt,{trigger:(0,X.jsxs)(`span`,{title:f?e:a(qm(d)),children:[a(f?`dshPermCustom`:Km(d)),d===`danger-full-access`&&(0,X.jsxs)(`span`,{className:`dd-preset-tag warn`,children:[(0,X.jsx)(at,{}),` `,a(`dshPermFullAccessTag`)]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},children:u.map(e=>{let r=t.find(t=>t.value===e);return(0,X.jsxs)(St,{active:e===d,title:r?.description??a(qm(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(Km(e)),e===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)}),e===`danger-full-access`&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:a(`dshPermFullAccessTag`)})]}),(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:a(qm(e))})]},e)})}),c&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:a(`dshPermConfirmFull`)})]})}),Ym=Rm(),Xm=40,Zm=220,Qm=720,$m=`pi-web-ui:composer-height`,eh=(0,m.memo)(function({streaming:e,messages:t,slashCommands:n,modelState:r,models:i,modelsLoading:a,attachments:o,onRemoveAttachment:s,onAddImageFiles:c,onAddLocalFiles:l,onAddPathAttachment:u,fileSearch:d,onSearchFiles:f,onNotice:p,onSent:h,onManageModels:g,providerKeys:_,defaultModel:v,quickPhrases:y,quickPhrasesEnabled:b,recallDrafts:x,composerLeading:S,composerActions:C,onUiAction:w,dshPermCurrent:T,dshPermOptions:E,dshPermDefault:D,dshPreset:O,dshPresets:k,dshPresetDefault:A,dshBlank:ee,conversationId:j,sessionDraft:M,sessionId:N}){let P=Z(),F=aa(`ready`),I=oa(),{locale:L}=pn(),{openPicker:R}=cp(),te=e=>L!==`zh`&&e.descriptionEn?e.descriptionEn:e.description??``,z=e=>L!==`zh`&&e.argumentHintEn?e.argumentHintEn:e.argumentHint??``,[B,V]=(0,m.useState)(``),[re,H]=(0,m.useState)(()=>{try{let e=Number(localStorage.getItem($m));if(Number.isFinite(e)&&e>=Xm&&e<=Qm)return e}catch{}return null}),U=(0,m.useRef)(null),[W,ie]=(0,m.useState)(null),[ae,oe]=(0,m.useState)(0),se=(0,m.useRef)(0),ce=(0,m.useRef)(0),le=(0,m.useRef)(new Map),de=(0,m.useRef)(``),[fe,pe]=(0,m.useState)(!1),[me,he]=(0,m.useState)(void 0),G=(0,m.useRef)(null),_e=(0,m.useRef)(null),ve=(0,m.useRef)(null),K=(0,m.useRef)(-1),q=(0,m.useRef)(``),ye=(0,m.useRef)(0);(0,m.useEffect)(()=>{if(!x||x.length===0)return;let e=x.filter(e=>e.text&&e.seq>ye.current);e.length!==0&&(ye.current=e[e.length-1].seq,V(t=>e.reduce((e,t)=>em(e,t.text),t)),K.current=-1,q.current=``,requestAnimationFrame(()=>{let e=G.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)}))},[x]),(0,m.useEffect)(()=>(Rn(e=>{V(t=>em(t,e)),K.current=-1,q.current=``,requestAnimationFrame(()=>{let e=G.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)})}),()=>Rn(null)),[]),(0,m.useEffect)(()=>(Bn(()=>{Ym||requestAnimationFrame(()=>{G.current?.focus()})}),()=>Bn(null)),[]);let be=(0,m.useRef)(``);be.current=B,(0,m.useEffect)(()=>(Pn(e=>{{let t=e.trim(),n=new Set([`.`,`*`,`+`,`?`,`^`,`$`,`{`,`}`,`(`,`)`,`|`,`[`,`]`,`\\`]),r=t.split(``).map(e=>n.has(e)?`\\`+e:e).join(``),i=RegExp(`(^|[\\s(("'“‘[【])`+r+`(?=[\\s,.;:!?,。!?)\\]】」]|$)`);if(t&&i.test(be.current))return}let t=G.current;if(!t){V(t=>{let n=t+(t&&!t.endsWith(` `)?` `:``)+e;return de.current=n,n});return}let n=t.selectionStart??be.current.length,r=t.selectionEnd??be.current.length,i=be.current,a=(n>0&&!/[\s([{]$/.test(i.slice(0,n))?` `:``)+e,o=i.slice(0,n)+a+i.slice(r);de.current=o,V(o);let s=n+a.length;requestAnimationFrame(()=>{t.focus(),t.selectionStart=t.selectionEnd=s})}),()=>Pn(null)),[]),(0,m.useEffect)(()=>(Fn(e=>{V(t=>{let n=new Set([`.`,`*`,`+`,`?`,`^`,`$`,`{`,`}`,`(`,`)`,`|`,`[`,`]`,`\\`]),r=e.split(``).map(e=>n.has(e)?`\\`+e:e).join(``),i=RegExp(`(^|\\s)`+r+`(?:\\s|$)`,`g`),a=t.replace(i,(e,t)=>t===` `?` `:``);return a=a.replace(/ {2,}/g,` `).trim(),de.current=a,a})}),()=>Fn(null)),[]);let xe=2e4,Se=!I&&N?`${j??``}${N}`:null,Ce=Se&&N?`pi-web-ui:composer-draft:${N}`:null,we=(0,m.useRef)(``),Te=(0,m.useRef)(0),Ee=(0,m.useRef)(!1),De=(0,m.useRef)(0),Oe=(0,m.useRef)(null),ke=(0,m.useRef)(null),Y=(0,m.useRef)(0),Ae=e=>{try{let t=localStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return typeof n.text!=`string`||!n.text||typeof n.ts!=`number`?null:{text:n.text.slice(0,xe),ts:n.ts}}catch{return null}},je=(e,t,n,r)=>{let i=n.slice(0,xe);try{i.trim()?localStorage.setItem(t,JSON.stringify({text:i,ts:r})):localStorage.removeItem(t)}catch{}$({type:`draft_update`,sessionId:e,text:i,ts:r})},Me=()=>{Oe.current&&=(clearTimeout(Oe.current),null),Ee.current&&Se&&Ce&&N&&Ye&&je(N,Ce,we.current,Te.current)},Ne=e=>{if(we.current=e,Ee.current=!0,Te.current=Date.now(),Ce){let t=e.slice(0,xe);try{t.trim()?localStorage.setItem(Ce,JSON.stringify({text:t,ts:Te.current})):localStorage.removeItem(Ce)}catch{}}if(Se&&N&&Ye){Oe.current&&clearTimeout(Oe.current);let e=N,t=Ce,n=Te.current,r=Se;Oe.current=setTimeout(()=>{Oe.current=null,r===ke.current&&t&&je(e,t,we.current,n)},2e3)}},Pe=(e,t)=>{K.current=-1,V(e),Le(e,t),Ne(e)};(0,m.useEffect)(()=>{let e=Se,t=N,n=Ce;return()=>{Oe.current&&=(clearTimeout(Oe.current),null),Ee.current&&e&&t&&n&&we.current.trim()&&je(t,n,we.current,Te.current)}},[Se]),(0,m.useEffect)(()=>{ke.current=Se,Ee.current=!1,De.current=0,we.current=``,Te.current=0,V(``),ie(null),K.current=-1},[Se]);let Fe=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=t.length===0,n=Fe.current!==Se;Fe.current=Se,F&&e&&(!Ym||n)&&requestAnimationFrame(()=>{G.current?.focus()})},[Se,t.length,F]),(0,m.useEffect)(()=>{if(!Se||!Ce||Ee.current||we.current!==``)return;let e=tm(M&&M.text?{text:M.text.slice(0,xe),ts:M.ts}:null,Ae(Ce),De.current);e&&(De.current=e.ts,we.current=e.text,Te.current=e.ts,V(e.text),Le(e.text,null))});let Ie={builtin:P(`slashBuiltin`),extension:P(`slashExtension`),prompt:P(`slashPrompt`),skill:P(`slashSkill`),plugin:P(`slashPlugin`)},Le=(e,t)=>{de.current=e;let r=e.match(/^\/([^\s]*)$/);if(r&&F){let e=Om(n,r[1].toLowerCase());ie(e.length>0?{kind:`slash`,items:e}:null),oe(0);return}if(t===null||!F){ie(null);return}let i=Im(e,t);if(!i){ie(null);return}let a=[];try{a=To()}catch{a=[]}let o=++se.current,s=e,c=i.start,l=i.query,u=a.map(e=>({id:e.id,label:e.label,run:()=>{let t;try{t=Eo(e.id)?.search}catch{t=void 0}return typeof t==`function`?t(l):Promise.resolve([])}}));l&&typeof f==`function`&&u.push({id:`host:files`,label:P(`openFiles`),run:()=>Re(l)}),Cn();let d=Am(P(`browserControl`),Sn(),l);if(u.push({id:`host:pages`,label:P(`browserControl`),run:()=>Promise.resolve(d)}),u.length===0){ie(null);return}let p=Nm(P(`slashSkill`),n,l,15,te),m=Pm({pages:d,skills:p},l,30),h=!1;m.length>0&&(h=!0,ie({kind:`at`,start:c,items:m}),oe(0)),Promise.allSettled(u.map(e=>Promise.race([e.run(),new Promise((e,t)=>setTimeout(()=>t(Error(`at-mention timeout`)),2e3))]))).then(e=>{if(se.current!==o||de.current!==s)return;let t=[],n=[],r=[];e.forEach((e,i)=>{e.status===`fulfilled`&&(u[i].id===`host:pages`&&Array.isArray(e.value)?t.push(...e.value):u[i].id===`host:files`?n.push(...jm(u[i].label,e.value)):r.push(...Mm(u[i].id,u[i].label,e.value)))});let i=Pm({pages:t,skills:p,files:n,plugins:r},l,30);ie(i.length>0?{kind:`at`,start:c,items:i}:null),!h&&i.length>0&&oe(0)})},Re=e=>{if(typeof f!=`function`)return Promise.resolve([]);let t=++ce.current;return new Promise(n=>{le.current.set(t,n);try{f(t,e)}catch{le.current.delete(t),n([]);return}setTimeout(()=>{le.current.get(t)===n&&(le.current.delete(t),n([]))},3e3)})};(0,m.useEffect)(()=>{if(!d||!d.ok)return;let e=le.current.get(d.reqId);e&&(le.current.delete(d.reqId),e(d.results??[]))},[d]);let ze=e=>Le(e,null);(0,m.useEffect)(()=>{(ve.current?.querySelector(`.slash-item.active`))?.scrollIntoView({block:`nearest`})},[ae,W]);let Be=e=>{let t=W?.kind===`slash`?W.items:[],n=e??t[ae%Math.max(t.length,1)];if(!n){ie(null);return}let r=B.match(/^\/([^\s]*)([\s\S]*)$/),i=r?r[2]:``,a=`/${n.name} ${i}`;de.current=a,V(a),ie(null),G.current?.focus()},Ve=(e,t)=>{let n=W?.kind===`at`?W:null,r=n?.items??[],i=e??r[ae%Math.max(r.length,1)],a=t??n?.start;if(!i||a===void 0){ie(null);return}let o=G.current,s=o?o.selectionStart??B.length:B.length,c=i.attachments??[],l=i.text??i.title,d=c.length>0&&!l.startsWith(`@`)?`@${l} `:`${l} `,f=`${B.slice(0,a)}${d}${B.slice(s)}`;de.current=f,V(f),ie(null);for(let e of c)try{u?.({path:e.path,name:e.name??e.path.split(`/`).pop()??e.path,...e.mode?{mode:e.mode}:{mode:`reference`},...typeof e.isDir==`boolean`?{isDir:e.isDir}:{},...e.lines?{lines:e.lines}:{},silent:!0})}catch{}requestAnimationFrame(()=>{let e=G.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=a+d.length)})},He=()=>W?.kind===`slash`?W.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===ae?` active`:``}`,onMouseEnter:()=>oe(t),onClick:()=>We(e),children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Ie[e.source]}),(0,X.jsxs)(`span`,{className:`slash-desc`,children:[te(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:z(e)})]})]},e.name)):null,Ue=()=>W?.kind===`at`?W.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===ae?` active`:``}`,onMouseEnter:()=>oe(t),onClick:()=>We(e),title:e.hint??e.title,children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`@`,e.title]}),(0,X.jsx)(`span`,{className:`slash-source ${e.providerId===`host:skills`?`skill`:`plugin`}`,children:e.providerLabel}),e.hint&&(0,X.jsx)(`span`,{className:`slash-desc`,children:e.hint})]},`${e.providerId}:${e.title}:${t}`)):null,We=e=>{W&&(W.kind===`slash`?Be(e):Ve(e,W.start))},Ge=async()=>{let e=[...t].reverse().find(e=>e.role===`assistant`&&e.content.some(e=>e.type===`text`&&e.text))?.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
357
|
-
`);if(!e){p(`warning`,P(`slashCopyEmpty`));return}try{await navigator.clipboard.writeText(e),p(`info`,P(`slashCopied`))}catch{p(`error`,P(`slashCopyFailed`))}},Ke=e=>{if(!e||e.length===0){p(`warning`,P(`foldersNotSupported`));return}let t=Array.from(e).filter(e=>Ad(e.type)),n=Array.from(e).filter(e=>!Ad(e.type)),r=Je();t.length>0&&r?p(`warning`,r):t.length>0&&c(t),n.length>0&&l(n)},qe=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`&&Ad(e.type)){let t=e.getAsFile();t&&n.push(t)}if(n.length===0)return;e.preventDefault();let r=Je();if(r){p(`warning`,r);return}c(n)},Je=()=>{let e=r?.model;if(!e?.id)return null;let t=i.find(t=>t.id===e.id);return t&&t.vision===!1?P(`modelNoVision`,{name:t.name}):null},Ye=F,Xe=(0,m.useRef)(B);(0,m.useEffect)(()=>{Xe.current=B},[B]),(0,m.useEffect)(()=>{ze(Xe.current)},[n]),(0,m.useEffect)(()=>{let e=e=>{let t=e.detail;V(t),G.current?.focus()};return window.addEventListener(`pi-web:fill`,e),()=>window.removeEventListener(`pi-web:fill`,e)},[]),(0,m.useEffect)(()=>{if(!fe)return;let e=e=>{e.key===`Escape`&&pe(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[fe]);let Qe=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=G.current,t=Qe.current;if(!e||!t)return;let n=e.closest(`main`)?.querySelector(`.messages`),r=t.getBoundingClientRect().height,i=n?.scrollTop??0;e.style.height=`auto`;let a=re==null?Zm:Qm;e.style.maxHeight=`${a}px`;let o=Math.min(Math.max(e.scrollHeight,re??0),a);e.style.height=`${o}px`,e.style.overflowY=e.scrollHeight>o?`auto`:`hidden`,n&&(n.scrollTop=i+(t.getBoundingClientRect().height-r))},[B,re]);let et=()=>o.map(e=>e.imageData?{path:``,imageData:e.imageData,mimeType:e.mimeType,name:e.name}:e.fileData?{path:``,fileData:e.fileData,mimeType:e.mimeType,name:e.name,size:e.size}:{path:e.path,mode:e.mode,...e.lines?{lines:e.lines}:{},...e.mode===`page`?{name:e.name}:{},...e.mode===`conversation`?{name:e.name,...e.conversationId?{conversationId:e.conversationId}:{},...e.sessionPath?{sessionPath:e.sessionPath}:{}}:{}}),nt=(e=!1)=>{let t=B.trim(),n=o.some(e=>e.imageData||e.fileData||e.mode===`conversation`);if(t||n){if(!Ye){p(`error`,P(`netDisconnected`));return}if(t===`/help`){let e=G.current?.closest(`.inputbox`)?.getBoundingClientRect();he(e?.width),pe(!0),V(``),G.current?.focus();return}if(t===`/copy`){V(``),G.current?.focus(),Ge();return}if($({type:`prompt`,text:t,queue:e,attachments:et()})){if(t&&wm(t),K.current=-1,q.current=``,V(``),Ce)try{localStorage.removeItem(Ce)}catch{}Oe.current&&=(clearTimeout(Oe.current),null),Ee.current=!1,De.current=Date.now(),we.current=``,Te.current=0,h();let e=r?.model;e&&tp(`${e.provider}/${e.id}`),G.current?.focus()}else p(`error`,P(`netDisconnected`))}},rt=(e,t=!1)=>{let n=e.trim();if(n){if(!Ye){p(`error`,P(`netDisconnected`));return}if($({type:`prompt`,text:n,queue:t,attachments:et()})){n&&wm(n),K.current=-1,q.current=``,Me(),h();let e=r?.model;e&&tp(`${e.provider}/${e.id}`),Ym||G.current?.focus()}else p(`error`,P(`netDisconnected`))}},it=e=>{if(!(e.nativeEvent.isComposing||e.keyCode===229||Date.now()-Y.current<50)){if(W&&W.items.length>0){let t=W.items.length;switch(e.key){case`ArrowDown`:e.preventDefault(),oe(e=>(e+1)%t);return;case`ArrowUp`:e.preventDefault(),oe(e=>(e-1+t)%t);return;case`Tab`:case`Enter`:e.preventDefault(),We();return;case`Escape`:e.preventDefault(),ie(null);return}}if(e.key===`Backspace`&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=G.current;if(t&&t.selectionStart===t.selectionEnd&&t.selectionStart>0){let n=t.selectionStart,r=B.slice(0,n),i=o.find(e=>e.name&&(r.endsWith(`@`+e.name+` `)||r.endsWith(`@`+e.name))),a=-1;if(i&&i.name){let e=`@`+i.name,t=n-(r.endsWith(e+` `)?e.length+1:e.length);a=t>0&&/[\w.\-/]/.test(r[t-1])?-1:t}if(a<0){let e=/(^|[\s(("'"“‘[【])(@[^\s@,.;:!?,。!?)\]】」]+)(\s?)$/.exec(r);e&&(a=n-e[2].length-e[3].length)}if(a>=0&&a<n){e.preventDefault();let t=B.slice(0,a)+B.slice(n);de.current=t,V(t),requestAnimationFrame(()=>{G.current&&(G.current.selectionStart=G.current.selectionEnd=a)});let r=B.slice(a,n).trim().replace(/^@/,``),c=r.split(`/`).pop()??r,l=i??o.find(e=>e.name===r||e.name===c||e.path===r);l&&s(l.key??(l.mode===`conversation`?`conv|${l.conversationId??``}|${l.sessionPath??``}`:l.path));return}}}if(e.key===`ArrowUp`||e.key===`ArrowDown`){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=G.current;if(!t)return;let n=e.key===`ArrowUp`,r=pm(t);if(n&&!r.first||!n&&!r.last||!n&&K.current===-1)return;let i=Sm();if(i.length===0)return;if(e.preventDefault(),n){if(K.current===-1){q.current=B;let e=i.length-1;K.current=e;let t=i[e];V(t),ze(t),requestAnimationFrame(()=>{let e=G.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else if(K.current>0){let e=K.current-1;K.current=e;let t=i[e];V(t),ze(t),requestAnimationFrame(()=>{let e=G.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}}else{let e=K.current+1;if(e<i.length){K.current=e;let t=i[e];V(t),ze(t),requestAnimationFrame(()=>{let e=G.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else{K.current=-1;let e=q.current;V(e),ze(e),requestAnimationFrame(()=>{let t=G.current;t&&(t.selectionStart=t.selectionEnd=e.length)})}}return}if(e.key===`Escape`&&K.current!==-1){e.preventDefault();let t=q.current;K.current=-1,V(t),ze(t),requestAnimationFrame(()=>{let e=G.current;e&&(e.selectionStart=e.selectionEnd=t.length)});return}if(e.key===`Enter`){if(Ym&&!e.shiftKey&&!(e.ctrlKey||e.metaKey))return;e.shiftKey||(e.preventDefault(),nt())}}},at=Ye&&(B.trim()!==``||o.some(e=>e.imageData||e.fileData||e.mode===`conversation`)),ot=(0,m.useMemo)(()=>wi((C??[]).filter(e=>e.source!==`host`&&!e.hidden)),[C]),st=(0,m.useMemo)(()=>(S??[]).filter(e=>e.source!==`host`&&!e.hidden),[S]),ct=C!==void 0,lt=(0,m.useMemo)(()=>wi((C??[]).filter(e=>!e.hidden)),[C]),ut=e=>{if(e.kind===`select`&&e.options?.length){let t=e.options.some(t=>t.value===e.value)?e.value:e.options[0].value;return(0,X.jsx)(`select`,{className:`composer-plugin-select`,title:e.hint||e.label,"aria-label":e.label,value:t,onChange:t=>w?.(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id)}let t=e.icon===`mic`?(0,X.jsx)(ge,{}):e.icon===`camera`?(0,X.jsx)(Ze,{}):e.icon||e.label;return(0,X.jsx)(`button`,{type:`button`,className:`btn composer-plugin-action`,title:e.hint||e.label,"aria-label":e.label,onClick:()=>w?.(e),children:t},e.id)},dt=()=>(0,X.jsx)(`div`,{className:`inputbox-actions`,children:e?at?(0,X.jsxs)(`div`,{className:`split-send${I?` single`:``}`,children:[(0,X.jsx)(`button`,{type:`button`,className:`split-queue`,title:P(`supplementTip`),"aria-label":P(`queueFollowTag`),onClick:()=>nt(!0),children:(0,X.jsx)(J,{})}),!I&&(0,X.jsx)(`button`,{type:`button`,className:`split-steer`,title:P(`steerTip`),"aria-label":P(`queueSteerTag`),onClick:()=>nt(),children:(0,X.jsx)(tt,{})})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn stop`,title:P(`stopAgent`),onClick:()=>$({type:`abort`}),children:(0,X.jsx)(ne,{})}):(0,X.jsx)(`button`,{type:`button`,className:`btn send`,title:P(`sendTip`),disabled:!at,onClick:()=>nt(),children:(0,X.jsx)(tt,{})})}),ft={"host:composer-upload":(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:P(`uploadFile`),disabled:!Ye,onClick:()=>_e.current?.click(),children:(0,X.jsx)(ue,{})}),"host:composer-templates":(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:P(`tpl.openPicker`),onClick:R,children:(0,X.jsx)($e,{})}),"host:composer-model":(0,X.jsx)(Bm,{only:`model`,state:r,models:i,modelsLoading:a,onManageModels:g,providerKeys:_,defaultModel:v,compact:!0}),"host:composer-thinking":(0,X.jsx)(Bm,{only:`thinking`,state:r,models:i,modelsLoading:a,onManageModels:g,providerKeys:_,compact:!0}),"host:composer-dsh-perm":E&&E.length>0&&D!==void 0?(0,X.jsx)(Jm,{compact:!0,current:T??null,options:E,defaultPreset:D,conversationId:j??``}):null,"host:composer-dsh-preset":k&&k.length>0&&A!==void 0?(0,X.jsx)(Um,{compact:!0,preset:O??null,presets:k,defaultPreset:A,blank:ee??!1,conversationId:j??``}):null,"host:composer-send":dt()},pt=e=>e.source===`host`?(0,X.jsx)(m.Fragment,{children:ft[e.id]??null},e.id):ut(e);return(0,X.jsxs)(`div`,{ref:Qe,className:`inputbar`,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),Ke(e.dataTransfer?.files??null)},children:[o.length>0&&(0,X.jsxs)(`div`,{className:`attach-row`,children:[o.map(e=>(0,X.jsxs)(`span`,{className:`attach-chip ${e.imageData?`image`:e.fileData?`file`:e.mode}`,title:e.imageData?P(`attachImage`,{name:e.name}):e.fileData?P(`attachFile`,{name:e.name}):e.isDir?P(`folderRef`,{path:e.path}):e.mode===`page`?P(`attachPage`,{name:e.name}):e.mode===`conversation`?P(`attachConversation`,{name:e.name}):e.mode===`reference`?P(`refOnly`,{path:e.path}):e.mode===`lines`&&e.lines?P(`attachLines`,{path:e.path,start:e.lines.start,end:e.lines.end}):P(`attachContent`,{path:e.path}),children:[e.imageData?`🖼`:e.fileData?`📄`:e.isDir?`📁`:e.mode===`page`?`🌐`:e.mode===`conversation`?`💬`:e.mode===`reference`?`🔗`:`📎`,e.name,e.mode===`lines`&&e.lines&&(0,X.jsxs)(`span`,{className:`attach-range`,children:[`L`,e.lines.start,`-`,e.lines.end]}),(0,X.jsx)(`button`,{type:`button`,className:`attach-remove`,title:P(`removeAttachment`),onClick:()=>s(e.key??(e.mode===`conversation`?`conv|${e.conversationId??``}|${e.sessionPath??``}`:e.path)),children:`×`})]},e.key??(e.mode===`conversation`?`conv|${e.conversationId??``}|${e.sessionPath??``}`:`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`))),(0,X.jsx)(`span`,{className:`attach-hint`,children:P(`attachHint`)})]}),W&&W.items.length>0&&(0,X.jsxs)(`div`,{className:`slash-menu`,role:`listbox`,ref:ve,"aria-label":W.kind===`slash`?P(`slashCommands`):P(`atMentions`),"data-menu-kind":W.kind,children:[(0,X.jsxs)(`div`,{className:`slash-menu-hint`,children:[(0,X.jsx)(`span`,{children:W.kind===`slash`?P(`slashMenuHint`):P(`atMenuHint`)}),(0,X.jsx)(`span`,{className:`slash-menu-close`,onClick:()=>ie(null),children:`Esc`})]}),W.kind===`slash`?He():Ue()]}),fe&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>pe(!1),children:(0,X.jsxs)(`div`,{className:`slash-help`,style:me?{width:me}:void 0,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`slash-help-head`,children:[(0,X.jsxs)(`span`,{children:[`⚡ `,P(`slashHelpTitle`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>pe(!1),children:P(`close`)})]}),(0,X.jsx)(`div`,{className:`slash-help-body`,children:n.length===0?(0,X.jsx)(`div`,{className:`slash-help-empty`,children:P(`slashLoading`)}):n.map(e=>(0,X.jsxs)(`div`,{className:`slash-help-row`,children:[(0,X.jsxs)(`span`,{className:`slash-help-cmd`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Ie[e.source]}),(0,X.jsxs)(`span`,{className:`slash-help-desc`,children:[te(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:z(e)})]})]},e.name))})]})}),b&&y.length>0&&(0,X.jsx)(`div`,{className:`quick-row`,"aria-label":P(`quickPhrases`),children:y.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`quick-chip`,title:`${P(`quickPhrasesTip`,{text:e})}(${P(`quickPhrasesSendTip`)})`,disabled:!Ye,onClick:()=>rt(e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),rt(e,!0)},children:e},e))}),(0,X.jsxs)(`div`,{className:`inputbox`,"data-pi-anchor":`composer`,children:[(0,X.jsx)(`div`,{className:`composer-resize`,title:P(`composerResize`),"aria-label":P(`composerResize`),role:`separator`,"aria-orientation":`horizontal`,"aria-valuenow":Math.round(re??Zm),"aria-valuemin":Xm,"aria-valuemax":Qm,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId);let t=G.current?.getBoundingClientRect().height;U.current={startY:e.clientY,startH:typeof t==`number`&&Number.isFinite(t)?t:re??Zm,next:null}},onPointerMove:e=>{let t=U.current;if(!t)return;let n=Math.min(Qm,Math.max(Xm,t.startH+(t.startY-e.clientY)));t.next=n,H(n)},onPointerUp:()=>{let e=U.current?.next;if(U.current=null,e!=null)try{localStorage.setItem($m,String(Math.round(e)))}catch{}},onPointerCancel:()=>{U.current=null},onDoubleClick:()=>{H(null);try{localStorage.removeItem($m)}catch{}}}),(0,X.jsx)(`input`,{ref:_e,type:`file`,multiple:!0,hidden:!0,onChange:e=>{Ke(e.target.files),e.target.value=``}}),(0,X.jsx)(`textarea`,{ref:G,value:B,rows:1,placeholder:P(Ye?e?I?`placeholderStreamingQueued`:`placeholderStreaming`:`placeholderIdle`:`placeholderConnecting`),disabled:!Ye,onChange:e=>{Pe(e.target.value,e.target.selectionStart??e.target.value.length)},onCompositionEnd:()=>{Y.current=Date.now()},onBlur:Me,onKeyDown:it,onPaste:qe}),(0,X.jsx)(`div`,{className:`composer-tools`,children:ct?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[st.map(ut),lt.start.map(pt)]}),lt.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:lt.center.map(pt)}),(0,X.jsx)(`div`,{className:`composer-tools-right`,children:lt.end.map(pt)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[st.map(ut),(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:P(`uploadFile`),disabled:!Ye,onClick:()=>_e.current?.click(),children:(0,X.jsx)(ue,{})}),ot.start.map(ut),(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:P(`tpl.openPicker`),onClick:R,children:(0,X.jsx)($e,{})}),(0,X.jsx)(Bm,{state:r,models:i,modelsLoading:a,onManageModels:g,providerKeys:_,defaultModel:v,compact:!0}),E&&E.length>0&&D!==void 0&&(0,X.jsx)(Jm,{compact:!0,current:T??null,options:E,defaultPreset:D,conversationId:j??``}),k&&k.length>0&&A!==void 0&&(0,X.jsx)(Um,{compact:!0,preset:O??null,presets:k,defaultPreset:A,blank:ee??!1,conversationId:j??``})]}),ot.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:ot.center.map(ut)}),(0,X.jsxs)(`div`,{className:`composer-tools-right`,children:[ot.end.map(ut),dt()]})]})})]})]})}),th=(0,m.memo)(function({goal:e,models:t,modelsLoading:n,activeConversationId:r,uiGoalbarActions:i,onUiAction:a}){let o=Z(),{locale:s}=pn(),c=s!==`zh`&&e.statusEn?e.statusEn:e.status||``,l=s!==`zh`&&e.wizard?.statusEn?e.wizard.statusEn:e.wizard?.status||``,u=oa(),d=!e.conversationId||e.conversationId===r,f=e.goal!==null&&d,[p,h]=(0,m.useState)(``),[g,_]=(0,m.useState)(e.reviewModel??``),[v,y]=(0,m.useState)(e.maxRounds),[b,x]=(0,m.useState)(e.locked),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(!0);(0,m.useEffect)(()=>{_(e.reviewModel??``),y(e.maxRounds||0),x(e.locked)},[e.goal,e.reviewModel,e.maxRounds,e.locked]),(0,m.useEffect)(()=>{S&&t.length===0&&!w&&!n&&(T(!0),$({type:`list_models`}))},[S,t.length,w,n]),(0,m.useEffect)(()=>{t.length>0&&T(!1)},[t.length]);let O=()=>g?t.find(e=>e.id===g)?.name??g:o(`goalBarUseMainModel`),k=()=>{let e=p.trim();e&&($({type:`set_goal`,goal:e,...g?{reviewModel:g}:{},maxRounds:v,locked:b}),h(``),D(!1))},A=()=>{let e=p.trim();e&&($({type:`start_goal_wizard`,text:e,...g?{wizardModel:g}:{},maxRounds:v,locked:b}),h(``),D(!1))},ee=i===void 0?[`host:goal-pill`,`host:goal-set`,`host:goal-wizard`,`host:goal-lock`,`host:goal-collapse`,`host:goal-model`,`host:goal-rounds`,`host:goal-clear`].map(e=>({id:e,source:`host`})):i.filter(e=>!e.hidden),j=e=>{let t=new Set(e);return ee.filter(e=>t.has(e.id)||e.source!==`host`)},M={"host:goal-pill":(0,X.jsxs)(`button`,{type:`button`,className:`goalbar-hint`,title:o(`goalBarPlaceholder`),onClick:()=>D(!1),children:[(0,X.jsx)(B,{}),` `,(0,X.jsx)(`span`,{children:o(`goalBarTitle`)})]}),"host:goal-set":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn`,disabled:!p.trim(),onClick:k,children:o(`goalBarSet`)}),"host:goal-wizard":(0,X.jsxs)(`button`,{type:`button`,className:`goalbar-btn wizard`,disabled:!p.trim(),title:o(`goalWizardTip`),onClick:A,children:[`🔍 `,o(`goalWizardBtn`)]}),"host:goal-lock":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(b?`goalBarLocked`:`goalBarUnlocked`),onClick:()=>x(e=>($({type:`set_goal_prefs`,locked:!e}),!e)),children:b?(0,X.jsx)(q,{}):(0,X.jsx)(L,{})}),"host:goal-collapse":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarClear`),onClick:()=>D(!0),children:(0,X.jsx)(Ke,{})}),"host:goal-model":u?(0,X.jsx)(`p`,{className:`goalbar-dsh-note`,children:o(`dshNoReviewModel`)}):(0,X.jsxs)(xt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,children:[o(`goalBarReviewModel`),`: `,(0,X.jsx)(`b`,{children:O()})]}),open:S,onOpenChange:C,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarReviewModel`)}),(w||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!w&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(St,{active:g===``,onClick:()=>{_(``),C(!1),$({type:`set_goal_prefs`,reviewModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(St,{active:g===e.id,onClick:()=>{_(e.id),C(!1),$({type:`set_goal_prefs`,reviewModel:e.id})},children:(0,X.jsxs)(`span`,{className:`dd-model-cell`,children:[(0,X.jsx)(`span`,{className:`dd-model-name`,children:e.name}),(0,X.jsxs)(`span`,{className:`dd-model-meta`,children:[(0,X.jsx)(`span`,{className:`dd-model-provider`,children:e.provider}),(0,X.jsx)(`span`,{className:`dd-model-id`,children:e.id.split(`/`).slice(1).join(`/`)})]})]})},e.id)),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`list_models`}),children:o(`refreshModels`)})]}),"host:goal-rounds":(0,X.jsxs)(`label`,{className:`goalbar-round`,title:o(`goalBarMaxRoundsTip`),children:[(0,X.jsx)(`span`,{children:o(`goalBarMaxRounds`)}),(0,X.jsx)(`input`,{type:`number`,min:0,step:1,value:v,placeholder:o(`goalBarUnlimitedShort`),onChange:e=>{let t=parseInt(e.target.value,10);if(Number.isNaN(t)||t<0){y(0);return}y(t)},onBlur:()=>$({type:`set_goal_prefs`,maxRounds:v}),onKeyDown:e=>{e.key===`Enter`&&($({type:`set_goal_prefs`,maxRounds:v}),e.target.blur())}})]})},P=(e.wizard?.active??!1)&&d;if(P)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${P?`wizard`:``}`,children:(0,X.jsxs)(`div`,{className:`goalbar-active-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:(0,X.jsx)(`span`,{className:`goalbar-spin`,children:`🔍`})}),(0,X.jsxs)(`span`,{className:`goalbar-text`,title:e.wizard?.draft??``,children:[o(`goalWizardRunning`),`: `,e.wizard?.draft]}),(0,X.jsxs)(`span`,{className:`goalbar-chip reviewing`,children:[o(`goalBarRound`,{n:(e.wizard?.step??0)+1}),` / `,e.wizard?.maxSteps??6]}),(0,X.jsx)(`span`,{className:`goalbar-detail`,children:l||o(`goalBarReviewing`)}),_p(j([`host:goal-clear`]),{...M,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x`,title:o(`goalBarClear`),onClick:()=>{$({type:`clear_goal`}),D(!0)},children:(0,X.jsx)(N,{})})},a)]})});if(f)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${e.reviewing?`reviewing`:``}`,children:(0,X.jsxs)(`div`,{className:`goalbar-active-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:e.reviewing?(0,X.jsx)(`span`,{className:`goalbar-spin`,children:`◌`}):`🎯`}),(0,X.jsx)(`span`,{className:`goalbar-text`,title:e.goal??``,children:e.goal}),e.reviewing?(0,X.jsxs)(`span`,{className:`goalbar-chip reviewing`,children:[o(`goalBarReviewing`),` `,o(`goalBarRound`,{n:e.round})]}):(0,X.jsx)(`span`,{className:`goalbar-chip ${e.verdict===`pass`?`pass`:e.verdict===`fail`?`fail`:e.verdict===`blocked`?`blocked`:``}`,children:e.verdict===`pass`?o(`goalBarPassed`):e.verdict===`fail`?o(`goalBarFailed`):e.verdict===`blocked`?o(`goalBarBlocked`):`${o(`goalBarRound`,{n:e.round||1})} · ${e.locked?o(`goalBarLocked`):o(`goalBarUnlocked`)}`}),(0,X.jsx)(`span`,{className:`goalbar-detail`,children:c}),_p(j([`host:goal-clear`]),{...M,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x`,title:o(`goalBarClear`),disabled:e.reviewing,onClick:()=>{e.goal&&h(e.goal),$({type:`clear_goal`}),D(!1)},children:(0,X.jsx)(N,{})})},a)]})});if(E){let e=_p(j([`host:goal-pill`]),M,a);return e?(0,X.jsx)(`div`,{className:`goalbar goalbar-collapsed`,children:e}):null}return(0,X.jsxs)(`div`,{className:`goalbar`,children:[(0,X.jsxs)(`div`,{className:`goalbar-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:(0,X.jsx)(B,{})}),(0,X.jsx)(`input`,{className:`goalbar-input`,value:p,placeholder:o(`goalBarPlaceholder`),onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k()}}),_p(j([`host:goal-set`,`host:goal-wizard`,`host:goal-lock`,`host:goal-collapse`]),M,a)]}),(0,X.jsxs)(`div`,{className:`goalbar-opts`,children:[j([`host:goal-model`,`host:goal-rounds`]).filter(e=>e.source===`host`).map(e=>(0,X.jsx)(m.Fragment,{children:M[e.id]},e.id)),(0,X.jsx)(`span`,{className:`goalbar-lock-hint`,children:o(b?`goalBarLocked`:`goalBarUnlocked`)})]})]})});function nh(e){let t=Math.max(0,e.input??0),n=Math.max(0,e.cacheRead??0),r=Math.max(0,e.cacheWrite??0),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0,writeRate:i>0?Math.min(r/i,1):0}}var rh=2e3;function ih(e,t,n=rh){return e.filter(e=>t-e.t<=n)}function ah(e,t=rh){if(e.length<2)return 0;let n=e[e.length-1],r=e.find(e=>e.t>=n.t-t)??e[0],i=(n.t-r.t)/1e3;return i<=0?0:Math.max(0,(n.out-r.out)/i)}function oh(e){if(!e)return 0;let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r>=12352&&r<=12543||r>=13312&&r<=19903||r>=19968&&r<=40959||r>=63744&&r<=64255||r>=65280&&r<=65519||r===12288)&&t++}let n=e.length-t;return Math.round(t+n/4)}function sh(e){let t=0;for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text?t+=oh(n.text):n.type===`thinking`&&typeof n.thinking==`string`&&n.thinking&&(t+=oh(n.thinking));return t}var ch=`@root`,lh=[{id:`host:conn`,align:`start`},{id:`host:engine`,align:`start`},{id:`host:ctx`,align:`start`},{id:`host:cost`,align:`start`},{id:`host:cache`,align:`start`},{id:`host:msg-count`,align:`start`},{id:`host:plugin-status`,align:`start`},{id:`host:working`,align:`start`},{id:`host:host-metrics`,align:`end`},{id:`host:cwd`,align:`end`}];function uh({chat:e,bottombarItems:t,onUiAction:n}){let r=Z(),{engine:i}=ia(),a=aa(`workspaceRoots`),o=e.state,[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(``),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(``),[v,y]=(0,m.useState)(-1),b=(0,m.useRef)(null),x=(0,m.useRef)(null),S=e.pathCompletions.filter(e=>e.type===`dir`),C=e=>e.endsWith(`/`)?e:e+`/`,w=e=>{let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;if(t===ch||t===`/`)return null;let n=t.lastIndexOf(`/`);if(n<0)return/^[A-Za-z]:$/.test(t)?ch:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};(0,m.useEffect)(()=>{if(!s)return;let e=setTimeout(()=>{$({type:`complete_path`,path:C(l)})},60);return()=>clearTimeout(e)},[l,s]),(0,m.useEffect)(()=>{if(!s||d===l)return;let e=setTimeout(()=>{$({type:`complete_path`,path:d})},150);return()=>clearTimeout(e)},[d,l,s]);let T=(0,m.useRef)([]),E=o?.isStreaming??!1,D=o?.streamingMessage?sh(o.streamingMessage.content):0;if((0,m.useEffect)(()=>{if(!E){T.current=[];return}let e=Date.now(),t=T.current,n=t[t.length-1];n&&e-n.t<250||(T.current=ih([...t,{t:e,out:D}],e))},[E,D]),!o)return null;let O=o.stats,k=nh(O.tokens),A=k.hitRate*100,ee=k.totalInput===0?``:k.hitRate>=.7?`ok`:k.hitRate>=.4?`mid`:`warn`,j=k.totalInput>0?`${A.toFixed(1)}%`:`—`,M=E?ah(T.current):0,P=e.ready?`ok`:e.status===`closed`?`error`:`busy`,F=e.ready?r(`connected`):e.status===`closed`?r(`reconnecting`):r(`connecting`),I=O.contextUsage,L=I.softCap??null,R=L!==null&&L>0&&L<I.contextWindow,te=R?L:I.contextWindow,z=I.tokens!==null&&te>0?Math.min(100,Math.round(I.tokens/te*100)):null,B=I.tokens!==null&&z!==null?`${dh(I.tokens)} / ${dh(te)}`:`—`,V=z===null?``:z>=80?`warn`:z>=50?`mid`:`ok`,ne=o.queue.steering.length+o.queue.followUp.length,re=()=>{let e=o.cwd.replace(/\\/g,`/`);f(e),u(e),h(!1),_(``),c(!0)},H=e=>{let t=e.trim();t!==ch&&(t&&t!==o.cwd&&$({type:`set_cwd`,path:t}),c(!1))},U=()=>{let e=g.trim();e&&($({type:`make_dir`,path:`${C(l)}${e}`}),setTimeout(()=>{$({type:`complete_path`,path:C(l)})},80),_(``),h(!1))},W=e=>{if(e.key===`Escape`)e.stopPropagation(),c(!1);else if(e.key===`Enter`&&!e.nativeEvent.isComposing)H(d);else if(e.key===`Tab`){if(S.length===0)return;e.preventDefault();let t=v>=0?(v+1)%S.length:0;y(t),f(S[t].path),u(S[t].path)}},ie=w(l),ae={"host:conn":(0,X.jsxs)(`span`,{className:`status-item status-conn ${P}`,title:F,children:[(0,X.jsx)(`span`,{className:`status-dot ${P}`}),(0,X.jsx)(`span`,{className:`status-conn-label`,children:F})]}),"host:engine":i===`pi`?null:(0,X.jsx)(`span`,{className:`status-item engine-badge engine-${i}`,title:`${r(`engineBadge`)}: ${i}`,children:i===`dsh`?`DSH`:i}),"host:ctx":(()=>{let e=R?`${r(`contextUsage`)}: ${dh(I.tokens??0)} / ${dh(L)} (${r(`softCapMarker`)}, max ${dh(I.contextWindow)})`:L!==null&&L>0?`${r(`contextUsage`)} · ${r(`softCapMarker`)}: ${dh(L)}`:r(`contextUsage`);return(0,X.jsxs)(`span`,{className:`status-item status-ctx`,title:e,children:[(0,X.jsx)(`span`,{className:`ctx-label`,children:r(`context`)}),(0,X.jsx)(`span`,{className:`ctx-bar ${V}`,children:z!==null&&(0,X.jsx)(`span`,{className:`ctx-bar-fill`,style:{width:`${Math.min(z,100)}%`}})}),B]})})(),"host:cost":(0,X.jsxs)(`span`,{className:`status-item status-cost`,title:r(`cumulativeCost`),children:[`$`,fh(O.cost)]}),"host:cache":(0,X.jsxs)(`span`,{className:`status-item status-cache`,title:r(`cacheHitTip`,{read:dh(k.read),write:dh(k.write),miss:dh(k.miss),input:dh(k.totalInput)}),children:[r(`cacheHit`),(0,X.jsx)(`b`,{className:`cache-pct ${ee}`,children:j})]}),"host:msg-count":(0,X.jsxs)(`span`,{className:`status-item`,title:r(`sessionMessages`),children:[r(`messages`),` `,O.totalMessages]}),"host:plugin-status":e.statuses.length>0?(0,X.jsx)(`span`,{className:`status-item ext-status`,title:r(`pluginStatus`),children:e.statuses.map(e=>e.text).join(` · `)}):null,"host:working":o.isStreaming?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`status-item working`,children:[(0,X.jsx)(`span`,{className:`working-spin`}),r(`working`),ne>0&&(0,X.jsxs)(`span`,{className:`status-queue`,children:[`⏳ `,ne,` `,r(`queued`)]})]}),(0,X.jsxs)(`span`,{className:`status-item status-rate`,title:r(`rateTip`),children:[(0,X.jsx)(`span`,{className:`working-spin rate-spin`}),M>0?`${Math.round(M)}${r(`tps`)}`:`…`]})]}):null,"host:host-metrics":(()=>{let t=e.hostMetrics;if(!t)return null;let n=t.cpuPercent===null||!Number.isFinite(t.cpuPercent)?`—`:`${Math.round(t.cpuPercent)}%`,i=Number.isFinite(t.memoryPercent)?`${Math.round(t.memoryPercent)}%`:`—`;return(0,X.jsxs)(`span`,{className:`status-item status-host-metrics`,title:`${r(`hostResourcesTip`)}\n${r(`hostProcessor`)}: ${n} · ${r(`hostMemory`)}: ${i}`,children:[r(`hostProcessor`),` `,n,` · `,r(`hostMemory`),` `,i]})})(),"host:cwd":s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`status-cwd-backdrop`,onClick:()=>c(!1)}),(0,X.jsxs)(`div`,{className:`cwd-picker`,children:[(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:l===ch?r(`computer`):l,children:[l===ch?`💻`:(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{children:l===ch?r(`computer`):l})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:l===ch,title:r(`computer`),onClick:()=>{u(ch),f(ch),y(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!ie,title:r(`cwdGoUp`),onClick:()=>{ie&&(u(ie),f(ie),y(-1))},children:[`↑ `,r(`cwdGoUp`)]}),(()=>{let e=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},t=e(l),n=!!l&&l!==ch&&t!==e(o.cwd)&&!a.some(n=>e(n)===t);return(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!n,title:r(`addWorkspaceRootHint`),onClick:()=>{n&&$({type:`set_workspace_roots`,roots:[...a,l]})},children:[`+ `,r(`addWorkspaceRoot`)]})})(),(0,X.jsx)(`button`,{type:`button`,className:`cwd-close`,title:r(`close`),"aria-label":r(`close`),onClick:()=>c(!1),children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:b,className:`status-cwd-input cwd-picker-input`,value:d,placeholder:r(`enterPath`),spellCheck:!1,onChange:e=>{f(e.target.value),y(-1)},onKeyDown:W}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:r(`cwdPickCurrent`),disabled:l===ch,onClick:()=>H(l),children:r(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[S.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:r(`cwdEmpty`)}),S.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${r(`cwdEnter`)} ${e.path}`,onClick:()=>{u(e.path),f(e.path),y(-1)},children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:r(`cwdChoose`),onClick:()=>H(e.path),children:r(`cwdChoose`)})]},e.path))]}),(0,X.jsx)(`div`,{className:`cwd-picker-foot`,children:p?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:x,value:g,autoFocus:!0,spellCheck:!1,placeholder:r(`cwdNewName`),onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),U()):e.key===`Escape`&&(e.stopPropagation(),h(!1),_(``))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:U,children:r(`cwdCreate`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{h(!1),_(``)},children:r(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>h(!0),children:[`+ `,r(`cwdNewFolder`)]})})]})]}):(0,X.jsxs)(`button`,{type:`button`,className:`status-item status-cwd`,title:r(`cwdTip`,{path:o.cwd}),onClick:re,children:[`📁 `,o.cwd]})},oe=t?t.map(e=>({id:e.id,entry:e,fallbackAlign:`start`})):lh.map(({id:e,align:t})=>({id:e,entry:null,fallbackAlign:t})),se=[],ce=[],le=[];for(let{id:e,entry:t,fallbackAlign:r}of oe){if(t?.hidden)continue;let i=null;if(e.startsWith(`host:`)?i=ae[e]:t&&(i=t.kind===`select`&&t.options?.length?(0,X.jsx)(`select`,{className:`status-select`,title:t.hint??t.label,"aria-label":t.label,value:t.options.some(e=>e.value===t.value)?t.value:t.options[0].value,onChange:e=>n?.(t,e.target.value),children:t.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:t.hint??t.label,onClick:()=>n?.(t),children:[t.icon?`${t.icon} `:``,t.label,t.badge?(0,X.jsx)(`span`,{className:`status-badge`,children:t.badge}):null]})),!i)continue;let a=t?.align??r;a===`end`?le.push({key:e,node:i}):a===`center`?ce.push({key:e,node:i}):se.push({key:e,node:i})}let ue=e=>e.map((e,t)=>(0,X.jsxs)(m.Fragment,{children:[t>0&&(0,X.jsx)(`span`,{className:`status-sep`,children:`·`}),e.node]},e.key));return(0,X.jsxs)(`footer`,{className:`statusbar`,children:[(0,X.jsx)(`div`,{className:`statusbar-left`,children:ue(se)}),ce.length>0&&(0,X.jsx)(`div`,{className:`statusbar-center`,children:ue(ce)}),(0,X.jsx)(`div`,{className:`statusbar-right`,children:ue(le)})]})}function dh(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(e)}function fh(e){return e<=0?`0`:e<1e-4?`<0.0001`:e.toFixed(4).replace(/\.?0+$/,``)}function ph({dialog:e}){let t=Z(),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(0),o=t=>{$({type:`dialog_response`,id:e.id,value:t})};(0,m.useEffect)(()=>{r(``),a(0)},[e.id]),yt(()=>o(null));let s=Array.isArray(e.args[0])?e.args[0]:[],c=typeof e.args[0]==`string`?e.args[0]:``;return(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":e.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:t(`pluginRequest`)}),e.title&&e.title!==t(`pluginRequest`)&&(0,X.jsx)(`span`,{className:`dialog-title`,children:e.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:t(`cancel`),onClick:()=>o(null),children:`✕`})]}),e.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[s.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`dialog-option ${t===i?`sel`:``}`,onMouseEnter:()=>a(t),onClick:()=>o(e),children:(0,X.jsx)(uu,{text:e,rawHtml:!0})},t)),s.length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:t(`noOptions`)}),(0,X.jsxs)(`div`,{className:`dialog-custom-row`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:n,placeholder:t(`modelQuestionCustom`),onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&n.trim()&&o(n.trim())}}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!n.trim(),onClick:()=>{n.trim()&&o(n.trim())},children:t(`ok`)})]})]}),e.kind===`confirm`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(uu,{text:c,rawHtml:!0}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>o(!1),children:t(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>o(!0),children:t(`ok`)})]})]}),e.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:n,placeholder:c||t(`inputPlaceholder`),autoFocus:!0,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&o(n)}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>o(null),children:t(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>o(n),children:t(`ok`)})]})]})]})}var mh=150;function hh({anchorRef:e,enabled:t=!0,className:n,children:r}){let i=(0,m.useRef)(null),a=(0,m.useRef)(null),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)({left:0,top:0}),u=(0,m.useCallback)(()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},[]),d=(0,m.useCallback)(()=>{u(),a.current=setTimeout(()=>s(!1),mh)},[u]);return(0,m.useEffect)(()=>{let n=e.current;if(!n)return;let r=()=>{u(),s(!0)};n.addEventListener(`mouseenter`,r);let a=e=>{let t=e.relatedTarget;t&&i.current?.contains(t)||d()};return n.addEventListener(`mouseleave`,a),t&&(n.addEventListener(`focus`,r),n.addEventListener(`blur`,d)),()=>{u(),n.removeEventListener(`mouseenter`,r),n.removeEventListener(`mouseleave`,a),n.removeEventListener(`focus`,r),n.removeEventListener(`blur`,d)}},[e,t,u,d]),(0,m.useLayoutEffect)(()=>{if(!o)return;let t=e.current?.getBoundingClientRect();if(!t)return;let n={left:Math.max(8,t.left-8),top:t.bottom+8};l(e=>e.left===n.left&&e.top===n.top?e:n)},[o,e]),(0,m.useLayoutEffect)(()=>{if(!o)return;let t=i.current,n=e.current;if(!t||!n)return;let r=vc(n.getBoundingClientRect(),t.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight});l(e=>e.left===r.left&&e.top===r.top?e:r)},[o,e,r]),(0,m.useEffect)(()=>{if(!o)return;let e=()=>s(!1);return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[o]),o?(0,k.createPortal)((0,X.jsx)(`div`,{ref:i,className:`set-tip-bubble open${n?` ${n}`:``}`,role:`tooltip`,style:{position:`fixed`,left:c.left,top:c.top},onMouseEnter:u,onMouseLeave:d,children:r}),document.body):null}function gh({question:e,owner:t,conversationTitle:n}){let r=Z(),i=e.conversationTitle||n,[a,o]=(0,m.useState)({}),[s,c]=(0,m.useState)({}),[l,u]=(0,m.useState)(0),[d,f]=(0,m.useState)(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1);(0,m.useEffect)(()=>{o({}),c({}),u(0);let n=e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1;f(n),e.deadline&&n<=0&&$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})},[e.id,e.deadline,t]),(0,m.useEffect)(()=>{if(!e.deadline)return;let n=setInterval(()=>{f(n=>{let r=Math.max(0,Math.ceil((e.deadline-Date.now())/1e3));return r<=0&&n>0&&$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}}),r})},1e3);return()=>clearInterval(n)},[e.id,e.deadline]);let p=()=>{$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})};yt(()=>{p()});let h=(e,t)=>{if(!e.dependsOn)return!0;let n=t[e.dependsOn.questionId]??[];if(e.dependsOn.value===void 0)return n.length>0;let r=Array.isArray(e.dependsOn.value)?e.dependsOn.value:[e.dependsOn.value];return n.some(e=>r.includes(e))},g=e.questions.filter(e=>h(e,a)),_=g.length;(0,m.useEffect)(()=>{if(e.questions.length===0||_>0)return;let n=setTimeout(()=>{$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})},1500);return()=>clearTimeout(n)},[e.id,e.questions.length,_,t]);let v=Math.min(l,Math.max(0,_-1)),y=g[v];if(!y)return(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":`select`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:r(`modelQuestion`)}),i&&(0,X.jsx)(`span`,{className:`question-conv-title`,title:i,children:i}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(`cancel`),onClick:p,children:`✕`})]}),(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-hint`,children:r(`questionNoneAvailable`)})})]});let b=(()=>{if(!y)return[];if(y.optionsMap&&y.dependsOn){let e=a[y.dependsOn.questionId]??[];for(let t of e)if(y.optionsMap[t])return y.optionsMap[t]}return y.options??[]})(),x=n=>{let r=e.questions.map(e=>{let t=n[e.id]??[],r=(s[e.id]??``).trim();return{id:e.id,selected:t,...r?{custom:r}:{}}});$({type:`question_answer`,id:e.id,answers:r,...t?{owner:t}:{}})},S=(e,t)=>{o(n=>{let r=n[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},C=(t,n,r)=>{if(r){S(t,n);return}let i={...a,[t]:[n]};o(i);let s=e.questions.filter(e=>h(e,i));v>=s.length-1?x(i):u(v+1)},w=()=>{v>=_-1?x(a):u(v+1)},T=t=>{let n=e.questions.find(e=>e.id===t);return b.length===0&&(n?.options?.length??0)===0||(a[t]?.length??0)>0||(s[t]??``).trim()!==``},E=b.filter(e=>(a[y.id]??[]).includes(e.label)&&e.preview).map(e=>e.preview);return(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":`select`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:r(`modelQuestion`)}),i&&(0,X.jsx)(`span`,{className:`question-conv-title`,title:i,children:i}),_>1&&(0,X.jsx)(`span`,{className:`question-progress`,children:r(`questionStep`,{cur:v+1,total:_})}),d>=0&&(0,X.jsx)(`span`,{className:`question-timer`,children:d>0?r(`questionTimeout`,{s:d}):r(`questionTimeoutExpired`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(`cancel`),onClick:p,children:`✕`})]}),(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,children:y.header??`${r(`modelQuestion`)} ${v+1}`}),(0,X.jsx)(`div`,{className:`question-head`,children:(0,X.jsx)(uu,{text:y.question,rawHtml:!0})}),y.detail&&(0,X.jsx)(`div`,{className:`set-hint`,children:(0,X.jsx)(uu,{text:y.detail,rawHtml:!0})}),b.length>0&&(0,X.jsx)(`div`,{className:`set-list`,children:b.map(e=>{let t=(a[y.id]??[]).includes(e.label);return(0,X.jsx)(_h,{label:e.label,description:e.description,mark:y.multiSelect?t?`☑ `:`☐ `:t?`● `:`○ `,active:t,onPick:()=>C(y.id,e.label,!!y.multiSelect)},e.label)})}),E.length>0&&(0,X.jsxs)(`div`,{className:`question-preview`,children:[(0,X.jsx)(`div`,{className:`question-preview-label`,children:r(`optionPreview`)}),E.map((e,t)=>(0,X.jsx)(`div`,{className:`question-preview-body`,children:(0,X.jsx)(uu,{text:e,rawHtml:!0})},t))]}),(0,X.jsx)(`input`,{className:`set-prompt-input question-custom`,placeholder:r(`modelQuestionCustom`),value:s[y.id]??``,onChange:e=>c(t=>({...t,[y.id]:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T(y.id)&&w())}})]},y.id),(0,X.jsxs)(`div`,{className:`dialog-nav`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss-inline`,onClick:p,children:r(`cancel`)}),(0,X.jsxs)(`div`,{className:`dialog-nav-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-prev`,disabled:v===0,onClick:()=>u(v-1),children:r(`previous`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-submit`,disabled:!T(y.id),onClick:w,children:v===_-1?r(`modelQuestionSubmit`):r(`next`)})]})]})]})}function _h({label:e,description:t,mark:n,active:r,onPick:i}){let a=(0,m.useRef)(null);return(0,X.jsxs)(`button`,{type:`button`,ref:a,className:`set-row question-option${r?` active`:``}`,onClick:i,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[(0,X.jsx)(`span`,{className:`question-mark`,children:n}),(0,X.jsx)(uu,{text:e,rawHtml:!0})]}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`set-row-desc`,children:(0,X.jsx)(uu,{text:t,rawHtml:!0})}),(0,X.jsx)(hh,{anchorRef:a,enabled:yc(),className:`question-desc-tip`,children:(0,X.jsx)(uu,{text:t,rawHtml:!0})})]})]})}var vh=e=>`'${e.replace(/'/g,`'\\''`)}'`,yh=`pi-web-ui:scm-sidebar-width`;function bh(e,t=0){if(!Number.isFinite(e))return 300;let n=Math.max(200,Math.min(720,t>0?t-220:720));return Math.min(n,Math.max(200,Math.round(e)))}function xh(e){return e===null||e.trim()===``?300:bh(Number(e))}function Sh(e,t){let n=t.toLowerCase();return e.subject.toLowerCase().includes(n)||e.author.toLowerCase().includes(n)||e.shortHash.toLowerCase().includes(n)||e.hash.toLowerCase().includes(n)||e.decorations!==void 0&&e.decorations.toLowerCase().includes(n)}function Ch(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>Sh(e,t)))}var wh=`scm-commit-history`;function Th(e=localStorage){try{let t=e.getItem(wh);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Eh(e,t=localStorage){let n=e.trim();if(!n)return Th(t);let r=[n,...Th(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(wh,JSON.stringify(r))}catch{}return r}var Dh={idx:-1,draft:``};function Oh(e,t,n,r){return e.length===0?null:r===`up`?t.idx>=e.length-1?null:t.idx===-1?{state:{idx:0,draft:n},text:e[0]}:{state:{idx:t.idx+1,draft:t.draft},text:e[t.idx+1]}:t.idx===-1?null:t.idx===0?{state:Dh,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}function kh(e){if(e.x===`?`&&e.y===`?`)return`untracked`;let t=e.x!==` `&&e.x!==`?`,n=e.y!==` `&&e.y!==`?`;return t&&n?`both`:t?`staged`:`unstaged`}function Ah({chat:e,terminal:t,active:n,onSwitchToTerminal:r,uiScmToolbar:i,onUiAction:a}){let o=Z(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)([]),[d,f]=(0,m.useState)(``),[p,h]=(0,m.useState)(new Map),[g,_]=(0,m.useState)(`changes`),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[A,ee]=(0,m.useState)(!1),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(!1),[F,I]=(0,m.useState)(null),[L,R]=(0,m.useState)(!1),[te,B]=(0,m.useState)(!1),[V,ne]=(0,m.useState)(null),[re,H]=(0,m.useState)(()=>xh(localStorage.getItem(yh))),[U,W]=(0,m.useState)(``),[ie,ae]=(0,m.useState)(``),[oe,ce]=(0,m.useState)(()=>Th()),le=(0,m.useRef)(Dh),ue=(0,m.useRef)(0),de=(0,m.useRef)(-1),fe=(0,m.useRef)(-1),pe=(0,m.useRef)(-1),me=(0,m.useRef)(-1),he=(0,m.useRef)(-1),ge=(0,m.useRef)(void 0),G=(0,m.useRef)(null),_e=(0,m.useRef)([]),ve=(0,m.useRef)(re);ve.current=re;let K=(0,m.useRef)(null),q=(0,m.useCallback)(e=>{try{localStorage.setItem(yh,String(e))}catch{}},[]),ye=(0,m.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=ve.current,r=K.current?.getBoundingClientRect().width??0,i=n,a=e=>{i=bh(n+(e.clientX-t),r),H(i)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.classList.remove(`panel-resizing`),q(i)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),document.body.classList.add(`panel-resizing`)},[q]),J=(0,m.useCallback)(()=>{H(300),q(300)},[q]),be=(0,m.useCallback)(e=>{if(e.reqId===de.current){if(de.current=-1,M(!1),I(null),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}if(e.notRepo){R(!0),c(null),u([]),h(new Map),y([]),x(null),C(``),k(null);return}R(!1);let t={branch:e.branch??``,detached:!!e.detached,upstream:e.upstream??null,ahead:e.ahead??0,behind:e.behind??0,upstreamGone:!!e.upstreamGone,files:(e.files??[]).map(e=>({...e}))},n=(e.branches??[]).map(e=>({...e})),r=new Map;for(let[t,n]of Object.entries(e.stats??{}))r.set(t,{add:n[0],del:n[1]});c(t),u(n),h(r),f(e=>t.detached?e||``:t.branch&&n.some(e=>e.name===t.branch)?t.branch:e&&n.some(t=>t.name===e)?e:n[0]?.name??``),k(e=>e&&!t.files.some(t=>t.path===e.file.path)?null:e)}else if(e.reqId===fe.current){if(fe.current=-1,ee(!1),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}let t=G.current;if(!t)return;k({file:t,staged:e.stagedText??``,worktree:e.worktreeText??``,untracked:!1})}else if(e.reqId===me.current){if(me.current=-1,P(!1),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}y((e.history??[]).map(e=>({...e})))}else if(e.reqId===pe.current){if(pe.current=-1,T(!1),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}C(e.text??``)}else if(e.reqId===he.current){if(he.current=-1,B(!1),!e.ok){ne(e.error??o(`scmGenMsgFail`));return}ne(null),W(e.text??``)}},[]);(0,m.useEffect)(()=>{let t=e.scmData;t&&t.type===`scm_data`&&be(t)},[e.scmData,be]);let xe=(0,m.useCallback)((t,n)=>{if(!e.ready||e.status!==`open`)return!1;let r=++ue.current;return $({...t,reqId:r})?(n.current=r,!0):(--ue.current,!1)},[e.ready,e.status]),Se=(0,m.useCallback)((t=!1,n=!1)=>{e.ready&&e.status===`open`&&e.state?.cwd&&(ge.current!==void 0&&ge.current!==e.state.cwd&&(c(null),u([]),h(new Map),y([]),ae(``),P(!1),me.current=-1,x(null),C(``),k(null),D(null),ne(null),B(!1),he.current=-1),ge.current=e.state.cwd,I(null),xe({type:`scm_status`},de)&&(n||M(!0)))},[e.ready,e.state?.cwd,e.status,xe]),Ce=(0,m.useCallback)(e=>{if(D(e),x(null),G.current=e,e.x===`?`&&e.y===`?`){k({file:e,staged:``,worktree:``,untracked:!0});return}ee(!0),I(null),xe({type:`scm_filediff`,path:e.path},fe)||ee(!1)},[xe]),we=(0,m.useCallback)(e=>{x(e),D(null),k(null),C(``),T(!0),I(null),xe({type:`scm_commit`,hash:e.hash},pe)||T(!1)},[xe]),Te=(0,m.useCallback)((n,i)=>{if(!e.ready)return;let a={name:n,command:i,cwd:"${pwd}"},o,s=e.terminals.find(e=>e.title===n);s?(t.restart(s.id),$({type:`run_command`,terminalId:s.id,conversationId:s.conversationId,command:a,cols:80,rows:24}),o=s.id):(o=dt(),t.create({id:o,conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:a})),t.select(o),r()},[e.ready,e.state?.cwd,e.terminals,r,t]),Ee=(0,m.useCallback)(()=>{let e=U.trim();if(!e||L)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);Te(`git commit`,`git commit -m "${t}"`),ce(Eh(e)),W(``),le.current=Dh},[U,L,Te]),De=(0,m.useCallback)(()=>{let e=U.trim();if(!e||L)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);Te(`git commit`,`git add -A && git commit -m "${t}"`),ce(Eh(e)),W(``),le.current=Dh},[U,L,Te]),ke=(0,m.useCallback)(e=>{L||Te(`git add`,`git add -- ${vh(e.path)}`)},[L,Te]),Y=(0,m.useCallback)(e=>{L||Te(`git reset`,`git reset HEAD -- ${vh(e.path)}`)},[L,Te]),Ae=(0,m.useCallback)(()=>{if(!d||L)return;let e=l.find(e=>e.name===d);if(e?.remote&&typeof e.remote==`string`){let t=d.slice(e.remote.length+1);Te(`git checkout`,`git checkout -b ${t} ${d} || git checkout ${d}`)}else Te(`git checkout`,`git checkout ${d}`)},[d,l,L,Te]),je=(0,m.useCallback)(()=>Te(`git push`,`git push`),[Te]),Me=(0,m.useCallback)(()=>Te(`git pull`,`git pull`),[Te]),Ne=(0,m.useCallback)(()=>{te||L||!e.ready||e.status!==`open`||(ne(null),xe({type:`scm_commitmsg`},he)?B(!0):ne(o(`scmGenMsgFail`)))},[te,L,e.ready,e.status,xe,o]),Pe=(0,m.useCallback)(()=>{xe({type:`scm_history`},me)||(me.current=-1)},[xe]);(0,m.useEffect)(()=>{n&&Se()},[n,Se]),(0,m.useEffect)(()=>{g===`history`&&s&&Pe()},[g,s,Pe]),(0,m.useEffect)(()=>{e.scmDirty>0&&n&&Se(!1,!0)},[e.scmDirty]),(0,m.useEffect)(()=>{if(!n||!e.ready||e.status!==`open`)return;let t=setInterval(()=>{document.visibilityState!==`hidden`&&Se(!1,!0)},3e4);return()=>clearInterval(t)},[n,e.ready,e.status,Se]),(0,m.useEffect)(()=>{let t=_e.current;_e.current=e.terminals,n&&e.terminals.some(e=>e.running===!1&&t.find(t=>t.id===e.id)?.running===!0&&e.title.startsWith(`git `))&&e.ready&&e.status===`open`&&(Se(!1,!0),g===`history`&&s&&Pe())},[e.terminals,n,e.ready,e.status,Se,g,s,Pe]);let Fe={staged:o(`scmStaged`),unstaged:o(`scmUnstaged`),untracked:o(`scmUntracked`),both:o(`scmStagedUnstaged`)},Ie=Ch(v,ie),Re=e=>{let t=e.split(`
|
|
358
|
-
`);return(0,X.jsx)(`pre`,{className:`scm-diff-pre`,children:t.map((e,t)=>{let n=``;return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)?n=`hdr`:e.startsWith(`@@`)?n=`hunk`:e.startsWith(`+`)?n=`add`:e.startsWith(`-`)&&(n=`del`),(0,X.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})},ze=i===void 0?[`host:scm-changes`,`host:scm-history`,`host:scm-refresh`,`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`,`host:scm-term`].map(e=>({id:e,source:`host`})):i.filter(e=>!e.hidden),Be=[`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`],Ve=(e,t)=>{let n=new Set(e);return ze.filter(e=>n.has(e.id)||t&&e.source!==`host`)},He=e=>i===void 0||!i.some(t=>t.id===e&&t.hidden),Ue={"host:scm-changes":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`changes`,className:g===`changes`?`active`:``,onClick:()=>{_(`changes`),I(null)},children:o(`scmChanges`)}),"host:scm-history":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`history`,className:g===`history`?`active`:``,onClick:()=>{_(`history`),I(null)},children:o(`scmHistory`)}),"host:scm-refresh":(0,X.jsx)(`button`,{type:`button`,className:`panel-refresh`,title:o(`scmRefreshTip`),disabled:j,onClick:()=>Se(!0),children:(0,X.jsx)(se,{className:j?`scm-spin`:``})}),"host:scm-branch":(0,X.jsxs)(`select`,{className:`scm-select`,value:d,disabled:L||l.length===0,title:o(`scmSwitchBranch`),onChange:e=>f(e.target.value),children:[(0,X.jsx)(`option`,{value:``,disabled:!0,children:o(`scmSelectBranch`)}),l.filter(e=>!e.remote).map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.current?`* ${e.name}`:e.name},e.name)),l.some(e=>e.remote)&&(0,X.jsx)(`optgroup`,{label:o(`scmRemoteBranches`),children:l.filter(e=>e.remote).map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),"host:scm-switch":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!d||d===s?.branch||L,title:o(`scmSwitchBranchTip`,{branch:d}),onClick:Ae,children:[(0,X.jsx)(Oe,{}),o(`scmSwitch`)]}),"host:scm-push":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||L,title:o(`scmPushTip`),onClick:je,children:[(0,X.jsx)(tt,{}),o(`scmPush`)]}),"host:scm-pull":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||L,title:o(`scmPullTip`),onClick:Me,children:[(0,X.jsx)(rt,{}),o(`scmPull`)]}),"host:scm-input":(0,X.jsx)(`input`,{className:`scm-commit-input`,value:U,placeholder:o(`scmCommitPlaceholder`),disabled:L,title:oe.length>0?o(`scmCommitHistoryTip`):void 0,onChange:e=>{W(e.target.value),le.current=Dh},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`){Ee();return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=Oh(oe,le.current,U,e.key===`ArrowUp`?`up`:`down`);t&&(e.preventDefault(),le.current=t.state,W(t.text))}}}}),"host:scm-genmsg":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:te||L||!s||s.files.length===0,title:o(`scmGenMsgTip`),onClick:Ne,children:[(0,X.jsx)(Le,{className:te?`scm-spin`:``}),o(te?`scmGenMsgRunning`:`scmGenMsg`)]}),"host:scm-commit":(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!U.trim()||L,title:o(`scmCommitTip`),onClick:Ee,children:[(0,X.jsx)(Ye,{}),o(`scmCommit`)]}),"host:scm-commit-all":(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!U.trim()||L,title:o(`scmCommitAllTip`),onClick:De,children:o(`scmCommitAll`)})};return(0,X.jsxs)(`div`,{className:`scm-view`,children:[(0,X.jsxs)(`div`,{className:`scm-header`,children:[(0,X.jsxs)(`div`,{className:`scm-title-row`,children:[(0,X.jsxs)(`span`,{className:`scm-title`,children:[(0,X.jsx)(Oe,{}),o(`scmTitle`)]}),(0,X.jsx)(`div`,{className:`scm-view-tabs`,role:`tablist`,children:_p(Ve([`host:scm-changes`,`host:scm-history`],!1),Ue,a)}),_p(Ve([`host:scm-refresh`],!0),Ue,a)]}),(0,X.jsxs)(`div`,{className:`scm-row`,children:[(0,X.jsxs)(`span`,{className:`scm-branch-current`,title:o(`scmCurrentBranch`),children:[(0,X.jsx)(Oe,{}),s?s.detached?o(`scmDetached`):s.branch:`…`,s?.upstream&&(0,X.jsx)(`span`,{className:`scm-upstream`,children:s.upstreamGone?o(`scmUpstreamGone`):s.ahead>0||s.behind>0?o(`scmAheadBehind`,{ahead:s.ahead,behind:s.behind}):s.upstream})]}),_p(Ve(Be,!1),Ue,a)]}),V&&(0,X.jsx)(`div`,{className:`scm-gen-error`,role:`alert`,title:o(`close`),onClick:()=>ne(null),children:V})]}),(0,X.jsxs)(`div`,{className:`scm-body`,ref:K,style:{"--scm-sidebar-w":`${re}px`},children:[g===`history`?(0,X.jsxs)(`div`,{className:`scm-history`,children:[(0,X.jsxs)(`div`,{className:`scm-files-header`,children:[(0,X.jsx)(`span`,{children:o(`scmHistory`)}),v.length>0&&(0,X.jsx)(`span`,{className:`scm-files-count`,children:ie.trim()?`${Ie.length}/${v.length}`:v.length})]}),v.length>0&&!L&&(0,X.jsx)(`input`,{className:`scm-history-filter`,value:ie,placeholder:o(`scmHistoryFilterPlaceholder`),title:o(`scmHistoryFilterTip`),onChange:e=>ae(e.target.value)}),(0,X.jsx)(`div`,{className:`scm-history-list`,children:L?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):!s||N?(0,X.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?o(`scmLoading`):o(`scmConnecting`)}):v.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoHistory`)}):Ie.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmHistoryFilterEmpty`)}):Ie.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`scm-commit ${b?.hash===e.hash?`active`:``}`,onClick:()=>we(e),title:e.hash,children:[(0,X.jsx)(`span`,{className:`scm-commit-graph`,"aria-hidden":`true`,children:e.graph||`* `}),(0,X.jsxs)(`span`,{className:`scm-commit-info`,children:[(0,X.jsx)(`span`,{className:`scm-commit-subject`,children:e.subject}),(0,X.jsxs)(`span`,{className:`scm-commit-meta`,children:[e.shortHash,` · `,e.author,` · `,e.date]}),e.decorations&&(0,X.jsx)(`span`,{className:`scm-commit-refs`,children:e.decorations})]})]},e.hash))})]}):(0,X.jsxs)(`div`,{className:`scm-files`,children:[(0,X.jsxs)(`div`,{className:`scm-files-header`,children:[(0,X.jsx)(`span`,{children:o(`scmChanges`)}),s&&s.files.length>0&&(0,X.jsx)(`span`,{className:`scm-files-count`,children:s.files.length})]}),(0,X.jsx)(`div`,{className:`scm-files-list`,children:L?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):s?s.files.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoChanges`)}):s.files.map(e=>{let t=kh(e),n=p.get(e.path);return(0,X.jsxs)(`div`,{className:`scm-file ${E?.path===e.path?`active`:``}`,title:Fe[t],onClick:()=>Ce(e),children:[(0,X.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`x`}`,children:e.x===` `?`\xA0`:e.x}),(0,X.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`y`}`,children:e.y===` `?`\xA0`:e.y}),(0,X.jsx)(`span`,{className:`scm-file-path`,children:e.path}),n&&(n.add>0||n.del>0)&&(0,X.jsxs)(`span`,{className:`scm-file-stat`,children:[n.add>0&&(0,X.jsxs)(`span`,{className:`add`,children:[`+`,n.add]}),n.del>0&&(0,X.jsxs)(`span`,{className:`del`,children:[`-`,n.del]})]}),(0,X.jsxs)(`span`,{className:`scm-file-actions`,children:[(e.y!==` `||t===`untracked`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-act`,title:o(`scmStageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),ke(e)},children:`+`}),t===`staged`||t===`both`?(0,X.jsx)(`button`,{type:`button`,className:`scm-act`,title:o(`scmUnstageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),Y(e)},children:`−`}):null]})]},e.path)}):(0,X.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?o(`scmLoading`):o(`scmConnecting`)})})]}),(0,X.jsx)(`div`,{className:`scm-divider`,role:`separator`,"aria-orientation":`vertical`,title:o(`dragToResize`),onPointerDown:ye,onDoubleClick:J}),(0,X.jsxs)(`div`,{className:`scm-diff`,children:[(0,X.jsxs)(`div`,{className:`scm-diff-header`,children:[(0,X.jsx)(`span`,{children:g===`history`?b?`${b.shortHash} ${b.subject}`:o(`scmCommitDetail`):E?E.path:o(`scmDiff`)}),(g===`history`?w:A)&&(0,X.jsx)(`span`,{className:`scm-diff-loading`,children:o(`scmLoading`)})]}),(0,X.jsx)(`div`,{className:`scm-diff-body`,children:g===`history`?(0,X.jsxs)(X.Fragment,{children:[F&&(0,X.jsx)(`div`,{className:`scm-error`,children:F}),!b&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectCommitHint`)}),b&&w&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),b&&!w&&!F&&S?Re(S):null]}):(0,X.jsxs)(X.Fragment,{children:[F&&(0,X.jsx)(`div`,{className:`scm-error`,children:F}),!E&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectFileHint`)}),E&&!O&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),E&&O&&O.untracked&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmUntrackedNote`)}),E&&O&&!O.untracked&&(0,X.jsxs)(X.Fragment,{children:[O.staged&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmStaged`)}),Re(O.staged)]}),O.worktree&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmUnstaged`)}),Re(O.worktree)]}),!O.staged&&!O.worktree&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoDiff`)})]})]})})]})]}),(0,X.jsxs)(`div`,{className:`scm-hint`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(`span`,{children:o(`scmRunsInTerminal`)}),He(`host:scm-term`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-goto-term`,onClick:r,children:o(`scmViewTerminal`)})]})]})}function jh({entry:e}){let t=(0,m.useRef)(null),n=Z();return(0,m.useEffect)(()=>{let r=t.current;if(!r)return;let i;try{i=e.module.mount(r,hs(e.info.id,e=>$(e)))}catch(t){console.error(`[plugin:${e.info.id}] mount failed:`,t),r.textContent=n(`pluginMountFailed`,{name:e.info.name})}return()=>{if(typeof i==`function`)try{i()}catch(t){console.error(`[plugin:${e.info.id}] cleanup failed:`,t)}r.textContent=``}},[e]),(0,X.jsx)(`div`,{className:`plugin-view`,ref:t})}function Mh({pluginId:e,info:t,epoch:n,failed:r}){let i=Z(),[a,o]=(0,m.useState)(!1),s=t?.name||e;return r?(0,X.jsx)(`div`,{className:`view-pane`,children:(0,X.jsxs)(`div`,{className:`plugin-view-fallback`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`plugin-view-fallback-title`,children:[i(`pluginViewLoadFailed`),`:`,s]}),(0,X.jsx)(`div`,{className:`plugin-view-fallback-hint`,children:i(`pluginViewLoadFailedHint`)}),t&&(0,X.jsx)(`button`,{type:`button`,className:`plugin-view-fallback-retry`,onClick:()=>{t&&!a&&(o(!0),as(t,n).finally(()=>o(!1)))},disabled:a,children:i(a?`pluginViewLoading`:`pluginViewRetry`)})]})}):(0,X.jsx)(`div`,{className:`view-pane`,children:(0,X.jsx)(`div`,{className:`plugin-view-fallback`,role:`status`,children:i(`pluginViewLoading`)})})}function Nh({onAction:e}){let t=Ri(),n=(0,m.useMemo)(()=>t?Gi(t.entries):[],[t]),{items:r,selectParents:i}=(0,m.useMemo)(()=>Wi(n),[n]),a=(0,m.useMemo)(()=>Ki(r),[r]),o=(0,m.useMemo)(()=>t?Vi(t.slot,t.target):void 0,[t,t?.slot,t?.target.kind]),s=(0,m.useRef)(null),c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(-1),[p,h]=(0,m.useState)(-1),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(0),b=(0,m.useRef)(-1),x=e=>{b.current=e,f(e)},S=(0,m.useMemo)(()=>p>=0?Gi(r[p]?.children??[]):[],[r,p]),C=(0,m.useMemo)(()=>Ki(S),[S]),w=e=>{let n=r[e];if(t&&n&&!Ui(n,o)){if(n.children?.length){h(e);return}T(n,t)||Fi()}},T=(t,n,r)=>t.source===`host`&&n.onHostAction?n.onHostAction(t,n.target)===!0:(e(t,n.target,r),!1),E=(0,m.useRef)(w);if((0,m.useLayoutEffect)(()=>{E.current=w}),(0,m.useEffect)(()=>{if(!t){b.current=-1,f(-1),h(-1);return}let e=Ji(r,-1,1,o);b.current=e,f(e),h(-1),s.current?.focus()},[t,r,o]),(0,m.useLayoutEffect)(()=>{if(!t){u(null);return}let e=s.current;if(!e)return;let n=e.getBoundingClientRect();u(Bi(t.x,t.y,n.width,n.height,window.innerWidth,window.innerHeight))},[t,r]),(0,m.useLayoutEffect)(()=>{let e=c.current,t=s.current;if(p<0||!e||!t){_(!1),y(0);return}let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth-r.right,a=r.left;_(i<n.width+8&&a>i);let o=n.bottom-(window.innerHeight-8);y(o>0?-Math.min(o,Math.max(0,n.top-8)):0)},[p,r]),(0,m.useEffect)(()=>{if(!t)return;let e=e=>s.current&&e instanceof Node&&s.current.contains(e),n=t=>{e(t.target)||Fi()},r=t=>{e(t.target)||Fi()},i=()=>Fi();return document.addEventListener(`mousedown`,n,!0),window.addEventListener(`wheel`,r,!0),window.addEventListener(`resize`,i),()=>{document.removeEventListener(`mousedown`,n,!0),window.removeEventListener(`wheel`,r,!0),window.removeEventListener(`resize`,i)}},[t]),(0,m.useEffect)(()=>{if(!t)return;let e=e=>{let t=Ji(r,b.current,e,o);b.current=t,f(t)},n=t=>{switch(t.key){case`Escape`:t.preventDefault(),Fi();return;case`Tab`:Fi();return;case`ArrowDown`:t.preventDefault(),e(1);return;case`ArrowUp`:t.preventDefault(),e(-1);return;case`ArrowRight`:r[b.current]?.children?.length&&(t.preventDefault(),h(b.current));return;case`ArrowLeft`:p>=0&&(t.preventDefault(),h(-1));return;case`Enter`:case` `:t.preventDefault(),E.current(b.current);return;default:return}};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[t,r,p,o]),(0,m.useEffect)(()=>{d<0||s.current?.querySelector(`[data-ctx-active="true"]`)?.scrollIntoView?.({block:`nearest`})},[d]),!t)return null;let D=e=>{let n=i.get(e.id);if(n){if(Ui(n.parent,o))return;t&&!T(n.parent,t,n.value)&&Fi();return}Ui(e,o)||T(e,t)||Fi()},O=(e,t,n)=>{let r=Ui(e,o),i=!!e.children?.length,a=Xi(e.icon),s=n&&d===t;return(0,X.jsxs)(`div`,{className:`ctx-menu-itemwrap`,role:`none`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item${r?` disabled`:``}${s?` active`:``}${i?` has-sub`:``}`,"aria-label":e.label,title:e.hint,"aria-disabled":r||void 0,"aria-haspopup":i?`menu`:void 0,"aria-expanded":i?p===t:void 0,"data-ctx-active":s?`true`:void 0,onMouseEnter:n?()=>{x(t),i&&!r&&h(t)}:void 0,onClick:()=>n?w(t):D(e),children:[a?(0,X.jsx)(`span`,{className:`ctx-menu-icon`,"aria-hidden":`true`,children:a}):null,(0,X.jsx)(`span`,{className:`ctx-menu-label`,children:e.label}),e.badge?(0,X.jsx)(`span`,{className:`ctx-menu-badge`,children:e.badge}):null,i?(0,X.jsx)(`span`,{className:`ctx-menu-caret`,"aria-hidden":`true`,children:`▸`}):null]}),n&&i&&p===t?(0,X.jsx)(`div`,{ref:c,className:`ctx-menu-sub${g?` left`:``}`,role:`menu`,"aria-label":e.label,style:v?{marginTop:v}:void 0,children:C.map(e=>e.kind===`sep`?(0,X.jsx)(`div`,{className:`ctx-menu-sep`,role:`separator`},e.key):O(e.entry,e.index,!1))}):null]},`${e.id}#${t}`)};return(0,k.createPortal)((0,X.jsx)(`div`,{ref:s,className:`ctx-menu`,role:`menu`,"aria-label":t.target.label?`${t.slot}: ${t.target.label}`:t.slot,tabIndex:-1,style:{left:l?.x??t.x,top:l?.y??t.y,visibility:l?`visible`:`hidden`},onContextMenu:e=>{e.preventDefault(),e.stopPropagation()},children:a.map(e=>e.kind===`sep`?(0,X.jsx)(`div`,{className:`ctx-menu-sep`,role:`separator`},e.key):O(e.entry,e.index,!0))}),document.body)}var Ph=0,Fh=[],Ih=new Map,Lh=new Set;function Rh(){for(let e of Lh)try{e()}catch{}}function zh(e){let t=Ih.get(e);t!==void 0&&(clearTimeout(t),Ih.delete(e))}function Bh(e){let t=e.id||`banner-${Date.now()}-${++Ph}`,n={...e,id:t,type:e.type||`info`,persistent:!!e.persistent,timeoutMs:e.timeoutMs??5e3,dismissible:e.dismissible!==!1};if(zh(t),!n.persistent&&n.timeoutMs&&n.timeoutMs>0){let e=setTimeout(()=>{Vh(t)},n.timeoutMs);Ih.set(t,e)}let r=Fh.findIndex(e=>e.id===t);if(r>=0){let e=[...Fh];e[r]=n,Fh=e}else Fh=[...Fh,n];return Rh(),t}function Vh(e){zh(e);let t=Fh.find(t=>t.id===e);if(t){Fh=Fh.filter(t=>t.id!==e);try{t.onClose?.()}catch{}Rh()}}function Hh(e){let t=Fh.filter(e);if(t.length!==0){for(let e of t){zh(e.id);try{e.onClose?.()}catch{}}Fh=Fh.filter(t=>!e(t)),Rh()}}function Uh(){return Fh}function Wh(e){return Lh.add(e),()=>{Lh.delete(e)}}function Gh(){return(0,m.useSyncExternalStore)(Wh,Uh,Uh)}function Kh({type:e}){switch(e){case`question`:return(0,X.jsx)(Te,{className:`banner-icon banner-icon-question`});case`warning`:return(0,X.jsx)(at,{className:`banner-icon banner-icon-warning`});case`error`:return(0,X.jsx)(ot,{className:`banner-icon banner-icon-error`});case`success`:return(0,X.jsx)(Xe,{className:`banner-icon banner-icon-success`});default:return(0,X.jsx)(Ce,{className:`banner-icon banner-icon-info`})}}var qh=(0,m.memo)(function({banner:e}){let t=typeof e.onClick==`function`;return(0,X.jsxs)(`div`,{className:`banner-card banner-type-${e.type||`info`} ${t?`banner-clickable`:``}`,onClick:t?e.onClick:void 0,role:t?`button`:`status`,tabIndex:t?0:void 0,onKeyDown:t?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onClick?.())}:void 0,children:[(0,X.jsx)(`div`,{className:`banner-icon-col`,children:(0,X.jsx)(Kh,{type:e.type})}),(0,X.jsxs)(`div`,{className:`banner-content-col`,children:[e.title&&(0,X.jsx)(`div`,{className:`banner-title`,title:e.title,children:e.title}),(0,X.jsx)(`div`,{className:`banner-message`,title:e.message,children:e.message})]}),e.dismissible&&(0,X.jsx)(`button`,{type:`button`,className:`banner-close`,onClick:t=>{t.stopPropagation(),Vh(e.id)},"aria-label":`Close banner`,title:`关闭通知`,children:(0,X.jsx)(N,{})})]})}),Jh=(0,m.memo)(function(){let e=Gh();return e.length===0?null:(0,X.jsx)(`aside`,{className:`banner-container`,"aria-label":`Notifications`,children:e.map(e=>(0,X.jsx)(qh,{banner:e},e.id))})});function Yh(e,t){let n=(0,m.useRef)(``);(0,m.useEffect)(()=>{let r=rm(n.current,e);n.current=r.key,r.clear&&t()},[e,t])}var Xh=new Map,Zh=-1;function Qh(e){let t=e.trim().toLowerCase();return t.startsWith(`.`)?t:`.${t}`}function $h(e){let t=e.replace(/\\/g,`/`).split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n).toLowerCase():``}function eg(e,t){Zh!==t&&(Zh=t);let n=new Map;for(let t of e){let e=t;if(!e.error&&e.hasClient&&Array.isArray(e.fileHandlers)){for(let t of e.fileHandlers)if(t&&t.id&&Array.isArray(t.extensions))for(let r of t.extensions){if(typeof r!=`string`)continue;let i=Qh(r);if(!/^\.[a-z0-9][a-z0-9._-]*$/.test(i))continue;let a=n.get(i)??[];a.push({plugin:e,declaration:t}),n.set(i,a)}}}for(let e of n.values())e.sort((e,t)=>t.declaration.priority-e.declaration.priority||e.plugin.id.localeCompare(t.plugin.id));Xh=n}function tg(e){return Xh.get($h(e))?.[0]??null}async function ng(e){let t=await ds(e.plugin,Zh);if(!t)return null;let n=t.fileHandlers,r;if(Array.isArray(n))r=n.find(t=>t&&t.id===e.declaration.id),!r&&n.length===1&&typeof n[0]?.mount==`function`&&(r=n[0]);else if(n&&typeof n==`object`){r=n[e.declaration.id];let t=Object.values(n);!r&&t.length===1&&typeof t[0]?.mount==`function`&&(r=t[0])}return!r||typeof r.mount!=`function`?null:{handler:r,pluginId:e.plugin.id}}function rg({provider:e,flow:t,result:n}){let r=Z(),i=t?.event,a=e.oauthName??e.name,[o,s]=(0,m.useState)(``);return(0,m.useEffect)(()=>s(``),[t?.promptId]),e.usingOAuth?(0,X.jsxs)(`div`,{className:`provider-oauth`,children:[(0,X.jsx)(`span`,{className:`provider-oauth-status`,children:r(`oauthConnected`,{name:a})}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-provider-oauth-logout":e.id,onClick:()=>$({type:`provider_oauth_logout`,provider:e.id}),children:r(`oauthLogout`)}),n?.error&&(0,X.jsx)(`div`,{className:`provider-oauth-error`,children:n.error})]}):(0,X.jsxs)(`div`,{className:`provider-oauth`,children:[t?(0,X.jsxs)(X.Fragment,{children:[i?.type===`device_code`&&(0,X.jsxs)(`div`,{className:`provider-oauth-device`,children:[(0,X.jsx)(`div`,{children:r(`oauthDeviceCode`)}),(0,X.jsx)(`code`,{"data-oauth-device-code":!0,children:i.userCode}),(0,X.jsx)(`a`,{"data-oauth-verification-url":!0,href:i.verificationUri,target:`_blank`,rel:`noreferrer`,children:r(`oauthOpenVerification`)})]}),i?.type===`auth_url`&&(0,X.jsxs)(`div`,{className:`provider-oauth-event`,children:[i.instructions&&(0,X.jsx)(`div`,{children:i.instructions}),(0,X.jsx)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,children:r(`oauthOpenVerification`)})]}),i?.type===`progress`&&(0,X.jsx)(`div`,{className:`provider-oauth-message`,children:i.message}),i?.type===`info`&&(0,X.jsxs)(`div`,{className:`provider-oauth-event`,children:[(0,X.jsx)(`div`,{children:i.message}),i.links?.map(e=>(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.label??e.url},e.url))]}),t.prompt&&(0,X.jsx)(`div`,{className:`provider-oauth-message`,children:t.prompt.message}),t.prompt?.type===`select`&&t.promptId&&(0,X.jsx)(`div`,{className:`provider-oauth-options`,children:t.prompt.options.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,"data-oauth-option":e.id,onClick:()=>$({type:`provider_oauth_reply`,flowId:t.flowId,promptId:t.promptId,value:e.id}),children:e.label},e.id))}),t.prompt&&t.prompt.type!==`select`&&t.promptId&&(0,X.jsxs)(`form`,{className:`provider-oauth-prompt`,onSubmit:e=>{e.preventDefault(),o.trim()&&$({type:`provider_oauth_reply`,flowId:t.flowId,promptId:t.promptId,value:o.trim()})},children:[(0,X.jsx)(`input`,{"data-oauth-prompt-input":!0,type:t.prompt.type===`secret`?`password`:`text`,className:`key-input`,placeholder:t.prompt.placeholder,value:o,onChange:e=>s(e.target.value)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary sm`,"data-oauth-prompt-submit":!0,disabled:!o.trim(),children:r(`oauthContinue`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-oauth-cancel":t.flowId,onClick:()=>$({type:`provider_oauth_cancel`,flowId:t.flowId}),children:r(`cancel`)})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn primary sm`,"data-provider-oauth-login":e.id,onClick:()=>$({type:`provider_oauth_start`,provider:e.id}),children:r(`oauthLogin`,{name:a})}),n?.error&&(0,X.jsx)(`div`,{className:`provider-oauth-error`,children:n.error})]})}function ig({piConfigured:e,piAgentInstalled:t,providers:n,providerOAuthFlows:r,providerOAuthResults:i,installResult:a,onClose:o}){let s=Z(),c=sa(),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(``),[p,h]=(0,m.useState)(``),[g,_]=(0,m.useState)(!1);(0,m.useEffect)(()=>{$({type:`list_providers`}),$({type:`list_provider_oauth_flows`})},[]),(0,m.useEffect)(()=>{e&&o()},[e,o]),(0,m.useEffect)(()=>{a&&u(!1)},[a]),(0,m.useEffect)(()=>{!d&&n.length>0&&f(n.find(e=>!e.configured)?.id??n[0].id)},[n,d]);let v=()=>{l||(u(!0),$({type:`install_pi_agent`}))},y=()=>{p.trim()&&!g&&(_(!0),$({type:`set_provider_api_key`,provider:d.trim(),apiKey:p.trim()}),setTimeout(()=>_(!1),3e3))},b=()=>{$({type:`get_state`}),$({type:`list_providers`})},x=n.find(e=>e.id===d),S=a!==null&&!a.ok;return(0,X.jsx)(`div`,{className:`modal-backdrop`,children:(0,X.jsxs)(`div`,{className:`modal setup-modal`,children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":s(`close`),onClick:o,children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Le,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:s(`setupTitle`)})]}),(0,X.jsx)(`p`,{className:`modal-desc`,children:s(`setupDesc`)}),S?(0,X.jsxs)(`div`,{className:`setup-failed`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:s(`installFailed`)}),(0,X.jsx)(`pre`,{className:`setup-detail`,children:a.detail}),(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:l,onClick:v,children:s(`retryInstall`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]})]}):t||a?.ok?(0,X.jsxs)(`div`,{className:`setup-key-form`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:a?.ok?s(`installDone`):s(`cliReadyHint`)}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:s(`provider`)}),(0,X.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),children:[n.length===0&&(0,X.jsx)(`option`,{value:``,children:s(`loading`)}),n.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name,`(`,e.id,`)`,e.configured?` · ${s(`configured`)}`:``]},e.id))]}),x?.configured&&(0,X.jsx)(`div`,{className:`field-hint`,children:s(`providerKeyReady`)})]}),x?.supportsOAuth&&(0,X.jsx)(rg,{provider:x,flow:r.find(e=>e.provider===x.id),result:i[x.id]}),x?.supportsApiKey&&(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:s(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:p,onChange:e=>h(e.target.value),placeholder:`sk-…`})]}),(0,X.jsxs)(`div`,{className:`setup-actions`,children:[x?.supportsApiKey&&(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!p.trim()||g||!d,onClick:y,children:s(g?`saving`:`saveAndStart`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:b,children:[(0,X.jsx)(se,{}),` `,s(`recheck`)]})]})]}):c?(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:s(`updatesManaged`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]}):(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:l,onClick:v,children:s(l?`installing`:`autoInstall`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]})]})})}var ag=[`openai-completions`,`openai-responses`,`anthropic-messages`,`google-generative-ai`],og=[{id:`deepseek`,name:`DeepSeek`,api:`openai-completions`,baseUrl:`https://api.deepseek.com/v1`,authHeader:!0,tag:`官方`},{id:`openrouter`,name:`OpenRouter`,api:`openai-completions`,baseUrl:`https://openrouter.ai/api/v1`,authHeader:!0,tag:`聚合`},{id:`moonshot`,name:`Moonshot (Kimi)`,api:`openai-completions`,baseUrl:`https://api.moonshot.cn/v1`,authHeader:!0,tag:`官方`},{id:`zhipu`,name:`智谱 GLM`,api:`openai-completions`,baseUrl:`https://open.bigmodel.cn/api/paas/v4`,authHeader:!0,tag:`官方`},{id:`siliconflow`,name:`硅基流动`,api:`openai-completions`,baseUrl:`https://api.siliconflow.cn/v1`,authHeader:!0,tag:`云端`},{id:`ollama`,name:`Ollama`,api:`openai-completions`,baseUrl:`http://127.0.0.1:11434/v1`,authHeader:!0,tag:`本地`},{id:`vllm`,name:`vLLM / LM Studio`,api:`openai-completions`,baseUrl:`http://127.0.0.1:8000/v1`,authHeader:!0,tag:`本地`},{id:`antigravity`,name:`Antigravity (OpenAI)`,api:`openai-completions`,baseUrl:`http://127.0.0.1:8045/v1`,authHeader:!0,tag:`反代`},{id:`antigravity-anthropic`,name:`Antigravity (Anthropic)`,api:`anthropic-messages`,baseUrl:`http://127.0.0.1:8045`,authHeader:!0,tag:`反代`}],sg=[{label:`8K`,value:`8192`},{label:`16K`,value:`16384`},{label:`32K`,value:`32768`},{label:`64K`,value:`65536`},{label:`128K`,value:`131072`},{label:`200K`,value:`200000`},{label:`1M`,value:`1000000`}],cg=[{label:`2K`,value:`2048`},{label:`4K`,value:`4096`},{label:`8K`,value:`8192`},{label:`16K`,value:`16384`},{label:`32K`,value:`32768`},{label:`64K`,value:`65536`}],lg=()=>({id:``,name:``,reasoning:!1,input:`text`,contextWindow:``,maxTokens:``}),ug=()=>({providerId:``,name:``,api:`openai-completions`,baseUrl:``,apiKey:``,hasApiKey:!1,authHeader:!0,models:[lg()]});function dg(e){return{providerId:e.providerId,name:e.name??``,api:e.api??`openai-completions`,baseUrl:e.baseUrl??``,apiKey:``,hasApiKey:e.hasApiKey??!1,authHeader:e.authHeader??!1,models:(e.models.length?e.models:[lg()]).map(e=>({id:e.id,name:e.name??``,reasoning:e.reasoning??!1,input:e.input?.includes(`image`)?`text-image`:`text`,contextWindow:e.contextWindow?String(e.contextWindow):``,maxTokens:e.maxTokens?String(e.maxTokens):``}))}}function fg(e){let t={};for(let n of e.split(`
|
|
359
|
-
`)){let e=n.indexOf(`=`);if(e<=0)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}return t}function pg({candidates:e,onAdopt:t,onClose:n}){let r=Z(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(()=>{let t=new Set;for(let n of e){let e=n.id.toLowerCase();!e.includes(`embed`)&&!e.includes(`audio`)&&!e.includes(`tts`)&&!e.includes(`whisper`)&&t.add(n.id)}if(t.size===0)for(let n of e)t.add(n.id);return t}),c=(0,m.useMemo)(()=>{let t=i.trim().toLowerCase();return t?e.filter(e=>e.id.toLowerCase().includes(t)||e.name&&e.name.toLowerCase().includes(t)):e},[e,i]),l=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,X.jsx)(`div`,{className:`candidate-picker-backdrop`,onClick:n,children:(0,X.jsxs)(`div`,{className:`candidate-picker-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`candidate-header`,children:[(0,X.jsxs)(`div`,{className:`candidate-title-group`,children:[(0,X.jsx)(`span`,{className:`candidate-title`,children:`候选模型采纳器 (Candidate Picker)`}),(0,X.jsxs)(`span`,{className:`candidate-subtitle`,children:[`已探测到 `,e.length,` 个模型,请勾选需要采纳的模型`]})]}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,onClick:n,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`candidate-filter-bar`,children:[(0,X.jsx)(ie,{style:{color:`var(--text-faint)`,flexShrink:0}}),(0,X.jsx)(`input`,{type:`text`,className:`candidate-search-input`,placeholder:`搜索模型 ID 或名称…`,value:i,onChange:e=>a(e.target.value),autoFocus:!0}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:6,flexShrink:0},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{s(new Set(c.map(e=>e.id)))},children:`全选`}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{s(new Set)},children:`全不选`})]})]}),(0,X.jsxs)(`div`,{className:`candidate-list-scroll`,children:[c.length===0&&(0,X.jsx)(`div`,{style:{padding:`32px 0`,textAlign:`center`,color:`var(--text-faint)`,fontSize:13},children:`未匹配到模型`}),c.map(e=>{let t=o.has(e.id);return(0,X.jsxs)(`div`,{className:`candidate-item-card ${t?`selected`:``}`,onClick:()=>l(e.id),children:[(0,X.jsxs)(`div`,{className:`candidate-item-left`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`candidate-checkbox`,checked:t,onChange:()=>{},onClick:e=>e.stopPropagation()}),(0,X.jsxs)(`div`,{className:`candidate-id-info`,children:[(0,X.jsx)(`span`,{className:`candidate-id-name`,children:e.id}),e.name&&e.name!==e.id&&(0,X.jsx)(`span`,{style:{fontSize:11.5,color:`var(--text-dim)`},children:e.name})]})]}),(0,X.jsxs)(`div`,{className:`candidate-item-meta`,children:[e.contextWindow&&(0,X.jsx)(`span`,{className:`spec-badge ctx`,title:`上下文窗口`,children:e.contextWindow>=1e6?`${Math.round(e.contextWindow/1e6)}M`:`${Math.round(e.contextWindow/1024)}K`}),e.reasoning&&(0,X.jsxs)(`span`,{className:`spec-badge reasoning`,title:`支持深度思考 / 推理`,children:[(0,X.jsx)(M,{}),` 推理`]}),e.input?.includes(`image`)&&(0,X.jsx)(`span`,{className:`spec-badge vision`,title:`支持图像视觉`,children:`视觉`})]})]},e.id)})]}),(0,X.jsxs)(`div`,{className:`candidate-actions-footer`,children:[(0,X.jsxs)(`span`,{className:`candidate-select-summary`,children:[`已勾选 `,o.size,` / `,e.length,` 个模型`]}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:n,children:r(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:o.size===0,onClick:()=>{t(e.filter(e=>o.has(e.id)))},children:[`采纳所选模型 (`,o.size,`)`]})]})]})]})})}function mg({providers:e,providerStatus:t,providerKeys:n,providerOAuthFlows:r,providerOAuthResults:i,fetchModelsResult:a,testModelConnectionResult:o,enrichModelsResult:s,enrichModelsProgress:c,cloneProviderResult:l,refreshBuiltinResult:u,appendBuiltinResult:d,defaultModel:f,onClose:p}){let h=Z(),[g,_]=(0,m.useState)(()=>e.length>0?{type:`custom`,id:e[0].providerId}:t.length>0?{type:`builtin`,id:t[0].id}:{type:`custom`,id:``}),[v,y]=(0,m.useState)(()=>e.length>0?dg(e[0]):t.length>0?null:ug()),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(0),[E,D]=(0,m.useState)(null),O=(0,m.useRef)(0),[k,A]=(0,m.useState)({}),[ee,j]=(0,m.useState)({}),[M,P]=(0,m.useState)(null),F=(0,m.useRef)(n),I=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=M;e&&n[e]!==F.current[e]&&(P(null),A(t=>({...t,[e]:``})),j(t=>({...t,[e]:``})),I.current&&clearTimeout(I.current)),F.current=n},[n,M]),(0,m.useEffect)(()=>()=>{I.current&&clearTimeout(I.current)},[]);let[L,te]=(0,m.useState)(!1),[z,B]=(0,m.useState)(0),[V,ne]=(0,m.useState)(null),re=(0,m.useRef)(0),[H,U]=(0,m.useState)(!1),[W,ie]=(0,m.useState)(!1),[ae,oe]=(0,m.useState)(0),[le,ue]=(0,m.useState)(null),[de,fe]=(0,m.useState)([]),[pe]=(0,m.useState)(``),me=(0,m.useRef)(0),[he,ge]=(0,m.useState)(!1),[G,_e]=(0,m.useState)(0),[ve,K]=(0,m.useState)(null),q=(0,m.useRef)(0),[ye,J]=(0,m.useState)(null),[be,xe]=(0,m.useState)(``),[Se,Ce]=(0,m.useState)(``),[we,Te]=(0,m.useState)(``),[Ee,De]=(0,m.useState)(``),[Oe,ke]=(0,m.useState)(!1),[Y,Ae]=(0,m.useState)(0),[je,Me]=(0,m.useState)(null),Ne=(0,m.useRef)(0),[Pe,Fe]=(0,m.useState)(null),[Re,ze]=(0,m.useState)(``),[Be,Ve]=(0,m.useState)(null);(0,m.useEffect)(()=>{$({type:`list_models_config`}),$({type:`list_providers`}),$({type:`list_provider_keys`}),$({type:`list_provider_oauth_flows`})},[]),(0,m.useEffect)(()=>{o&&o.reqId!==O.current&&(O.current=o.reqId,C(!1),D({ok:o.ok,latencyMs:o.latencyMs,error:o.error}))},[o]),(0,m.useEffect)(()=>{a&&a.reqId!==re.current&&(re.current=a.reqId,te(!1),a.ok&&a.models?.length?(x(a.models),ne({ok:!0,text:h(`fetchModelsOk`,{n:a.models.length})})):ne({ok:!1,text:a.error||h(`fetchModelsEmpty`)}))},[a,h]),(0,m.useEffect)(()=>{if(s&&s.reqId!==me.current){if(me.current=s.reqId,U(!1),ie(!1),s.ok&&s.results?.length){let e=s.results,t=new Map(e.map(e=>[e.id.trim(),e]));y(e=>e&&{...e,models:e.models.map(e=>{let n=t.get(e.id.trim());return!n||n.status!==`matched`?e:{...e,name:e.name||n.name||``,contextWindow:e.contextWindow||(n.contextWindow?String(n.contextWindow):``),maxTokens:e.maxTokens||(n.maxTokens?String(n.maxTokens):``),input:e.input===`text`&&n.input?.includes(`image`)?`text-image`:e.input,reasoning:e.reasoning||(n.reasoning??!1),src:n.source}})});let n=e.filter(e=>e.status===`matched`).length,r=e.length-n;ue({ok:!0,text:h(`enrichModelsOk`,{n,m:r})});let i=e.filter(e=>e.status!==`matched`&&(e.suggestions?.length||e.note)).map(e=>({id:e.id,suggestions:e.suggestions??[],note:e.note}));fe(i)}else ue({ok:!1,text:s.error||h(`enrichModelsErr`,{msg:``})})}},[s,h]),(0,m.useEffect)(()=>{u&&u.reqId!==q.current&&(q.current=u.reqId,ge(!1),u.ok?K({ok:!0,text:h(`refreshBuiltinOk`)}):K({ok:!1,text:u.error||h(`refreshBuiltinFail`)}))},[u,h]),(0,m.useEffect)(()=>{d&&d.reqId!==Ne.current&&(Ne.current=d.reqId,ke(!1),d.ok?(Me({ok:!0,text:h(`appendModelOk`)}),xe(``),Ce(``),Te(``),De(``),J(null),$({type:`list_models_config`})):Me({ok:!1,text:d.error||h(`appendModelFail`)}))},[d,h]),(0,m.useEffect)(()=>{if(l&&l.ok){let e=l.configs;if(e&&e.length>1){Fe(e.map(e=>dg(e))),ze(``);return}l.config&&Ve(dg(l.config))}},[l]);let He=()=>{if(!v)return;let e=v.baseUrl.trim();if(!e){D({ok:!1,error:h(`fetchModelsNeedBaseUrl`)});return}C(!0),D(null);let t=w+1;T(t),$({type:`test_model_connection`,reqId:t,baseUrl:e,apiKey:v.apiKey.trim()||void 0,...v.apiKey.trim()?{}:v.hasApiKey?{providerId:v.providerId.trim()}:{},authHeader:v.authHeader,api:v.api})},Ue=()=>{if(!v)return;let e=v.baseUrl.trim();if(!e){ne({ok:!1,text:h(`fetchModelsNeedBaseUrl`)});return}if(L)return;te(!0),ne(null);let t=z+1;B(t),$({type:`fetch_models`,reqId:t,baseUrl:e,apiKey:v.apiKey.trim()||void 0,...v.apiKey.trim()?{}:v.hasApiKey?{providerId:v.providerId.trim()}:{},authHeader:v.authHeader,api:v.api})},We=e=>{v&&(y(t=>{if(!t)return t;let n=t.models.filter(e=>e.id.trim()),r=new Set(n.map(e=>e.id.trim())),i=e.filter(e=>!r.has(e.id)).map(e=>({id:e.id,name:e.name??``,reasoning:e.reasoning??!1,input:e.input?.includes(`image`)?`text-image`:`text`,contextWindow:e.contextWindow?String(e.contextWindow):``,maxTokens:e.maxTokens?String(e.maxTokens):``}));return{...t,models:n.length===0?i:[...n,...i]}}),x(null))},Ge=()=>{if(!v||H)return;let e=v.models.map(e=>e.id.trim()).filter(Boolean);if(e.length===0){ue({ok:!1,text:h(`enrichModelsNeedIds`)});return}U(!0),ie(!1),ue(null),fe([]);let t=ae+1;oe(t),$({type:`enrich_models`,reqId:t,ids:e,hints:fg(pe)})},Ke=()=>{H&&!W&&(ie(!0),$({type:`abort_enrich_models`,reqId:ae}))},qe=e=>{y(t=>({providerId:t?.providerId.trim()||e.id,name:t?.name.trim()||e.name,api:e.api,baseUrl:e.baseUrl,apiKey:t?.apiKey||``,hasApiKey:t?.hasApiKey??!1,authHeader:e.authHeader,models:t?.models.length?t.models:[lg()]})),D(null),ne(null)},Je=()=>{if(!v)return;let e=v.providerId.trim();if(!e)return;let t=v.models.filter(e=>e.id.trim()).map(e=>({id:e.id.trim(),name:e.name.trim()||void 0,reasoning:e.reasoning||void 0,input:e.input===`text-image`?[`text`,`image`]:void 0,contextWindow:e.contextWindow?Number(e.contextWindow):void 0,maxTokens:e.maxTokens?Number(e.maxTokens):void 0}));$({type:`save_model_config`,providerId:e,config:{providerId:e,name:v.name.trim()||void 0,api:v.api.trim()||void 0,baseUrl:v.baseUrl.trim()||void 0,...v.apiKey.trim()?{apiKey:v.apiKey.trim()}:{},authHeader:v.authHeader||void 0,models:t}}),p()},Xe=(e,t)=>{v&&y({...v,models:v.models.map((n,r)=>r===e?{...n,...t}:n)})},Ze=()=>{v&&y({...v,models:[...v.models,lg()]})},Qe=e=>{v&&y({...v,models:v.models.filter((t,n)=>n!==e)})},$e=e=>{let t=(k[e.id]??``).trim();t&&!M&&(P(e.id),$({type:`add_provider_key`,provider:e.id,apiKey:t,name:(ee[e.id]??``).trim()||void 0}),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{P(t=>t===e.id?null:t)},1e4))},et=(e,t)=>{$({type:`activate_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`})},tt=(e,t)=>{window.confirm(h(`removeKeyConfirm`))&&($({type:`remove_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`}))},nt=e=>{window.confirm(h(`clearKeyConfirm`,{id:e}))&&$({type:`clear_provider_api_key`,provider:e})},rt=t=>{if(window.confirm(h(`deleteProviderConfirm`,{id:t.providerId,n:t.models.length}))&&($({type:`delete_model_config`,providerId:t.providerId}),g.type===`custom`&&g.id===t.providerId)){let n=e.filter(e=>e.providerId!==t.providerId);n.length>0?(_({type:`custom`,id:n[0].providerId}),y(dg(n[0]))):(_({type:`custom`,id:``}),y(ug()))}},it=e=>{let t=be.trim();if(!t||Oe)return;ke(!0),Me(null);let n=Y+1;Ae(n),$({type:`append_builtin_model`,providerId:e,model:{id:t,...Se.trim()?{name:Se.trim()}:{},...we?{api:we}:{},...Ee.trim()?{baseUrl:Ee.trim()}:{}},reqId:n})};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:p,children:(0,X.jsxs)(`div`,{className:`modal model-studio-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`studio-header`,children:[(0,X.jsxs)(`div`,{className:`studio-header-left`,children:[(0,X.jsx)(`div`,{className:`studio-header-icon-box`,children:(0,X.jsx)(Le,{})}),(0,X.jsxs)(`div`,{className:`studio-header-title-wrap`,children:[(0,X.jsx)(`h2`,{className:`studio-header-title`,children:`模型管理`}),(0,X.jsx)(`span`,{className:`studio-header-badge`,children:`Studio`})]})]}),(0,X.jsxs)(`div`,{className:`studio-header-actions`,children:[f!==void 0&&f&&(0,X.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:5,padding:`3px 8px`,borderRadius:6,background:`rgba(251, 191, 36, 0.08)`,border:`1px solid rgba(251, 191, 36, 0.3)`,fontSize:11.5,color:`var(--amber)`},title:`全局默认模型: ${f}`,children:[(0,X.jsx)(`span`,{children:`★`}),(0,X.jsx)(`span`,{style:{maxWidth:120,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`var(--mono)`},children:f.split(`/`).slice(1).join(`/`)}),(0,X.jsx)(`button`,{type:`button`,style:{background:`transparent`,border:`none`,color:`var(--amber)`,cursor:`pointer`,fontSize:10,padding:`0 2px`,opacity:.7},title:`清除全局默认模型`,onClick:()=>$({type:`clear_default_model`}),children:`✕`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`studio-header-btn`,title:h(`refreshBuiltinHint`),disabled:he,onClick:()=>{if(he)return;ge(!0),K(null);let e=G+1;_e(e),$({type:`refresh_builtin_models`,reqId:e})},children:[(0,X.jsx)(Ie,{}),(0,X.jsx)(`span`,{children:he?h(`refreshBuiltinBusy`):`刷新官方目录`})]}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn`,title:h(`reloadModelsHint`),onClick:()=>$({type:`reload_models_config`}),children:(0,X.jsx)(se,{})}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn close-btn`,"aria-label":h(`close`),onClick:p,children:(0,X.jsx)(N,{})})]})]}),ve&&(0,X.jsx)(`div`,{style:{padding:`6px 20px`,background:`var(--bg-elev2)`,fontSize:12,borderBottom:`1px solid var(--border-soft)`},children:(0,X.jsx)(`span`,{className:`fetch-msg ${ve.ok?`ok`:`err`}`,children:ve.text})}),(0,X.jsxs)(`div`,{className:`model-studio-body`,children:[(0,X.jsxs)(`div`,{className:`model-studio-sidebar`,children:[(0,X.jsx)(`div`,{style:{padding:`12px 10px 6px`},children:(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,style:{width:`100%`,justifyContent:`center`},onClick:()=>{_({type:`custom`,id:``}),y(ug()),D(null),ne(null)},children:[(0,X.jsx)(ce,{}),` 添加自定义服务商`]})}),(0,X.jsxs)(`div`,{className:`studio-sidebar-section`,children:[(0,X.jsxs)(`span`,{className:`studio-sidebar-title`,children:[`自定义服务商 (`,e.length,`)`]}),e.length===0&&(0,X.jsx)(`div`,{style:{fontSize:11.5,color:`var(--text-faint)`,padding:`6px 8px`},children:`暂无配置`}),e.map(e=>{let t=g.type===`custom`&&g.id===e.providerId;return(0,X.jsxs)(`div`,{className:`studio-nav-item ${t?`active`:``}`,onClick:()=>{_({type:`custom`,id:e.providerId}),y(dg(e)),D(null),ne(null)},children:[(0,X.jsxs)(`span`,{className:`studio-nav-label`,children:[(0,X.jsx)(`span`,{className:`studio-nav-dot configured`}),(0,X.jsx)(`span`,{children:e.name||e.providerId})]}),(0,X.jsxs)(`span`,{style:{fontSize:10.5,color:`var(--text-faint)`,fontFamily:`var(--mono)`},children:[e.models.length,`m`]})]},e.providerId)})]}),(0,X.jsxs)(`div`,{className:`studio-sidebar-section`,children:[(0,X.jsxs)(`span`,{className:`studio-sidebar-title`,children:[`官方内置服务商 (`,t.length,`)`]}),t.map(e=>{let t=g.type===`builtin`&&g.id===e.id,r=n[e.id]??[];return(0,X.jsxs)(`div`,{className:`studio-nav-item ${t?`active`:``}`,onClick:()=>{_({type:`builtin`,id:e.id}),y(null)},children:[(0,X.jsxs)(`span`,{className:`studio-nav-label`,children:[(0,X.jsx)(`span`,{className:`studio-nav-dot ${e.configured?`configured`:``}`}),(0,X.jsx)(`span`,{children:e.name})]}),r.length>0&&(0,X.jsxs)(`span`,{style:{fontSize:10.5,color:`var(--text-faint)`,fontFamily:`var(--mono)`},children:[r.length,`k`]})]},e.id)})]})]}),(0,X.jsxs)(`div`,{className:`model-studio-main`,children:[v&&(0,X.jsxs)(`div`,{className:`studio-card`,children:[(0,X.jsxs)(`div`,{className:`studio-card-head`,children:[(0,X.jsxs)(`div`,{className:`studio-card-title`,children:[(0,X.jsx)(`span`,{children:v.providerId?`编辑服务商:${v.providerId}`:`新建自定义服务商`}),v.providerId&&e.some(e=>e.providerId===v.providerId)&&(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger sm`,title:`删除此服务商`,onClick:()=>{let t=e.find(e=>e.providerId===v.providerId);t&&rt(t)},children:(0,X.jsx)(R,{})})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,X.jsxs)(`div`,{className:`conn-test-box`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`conn-test-btn`,disabled:S||!v.baseUrl.trim(),onClick:He,children:[(0,X.jsx)(st,{}),` `,S?`测试中…`:`测试连接`]}),E&&(0,X.jsxs)(`span`,{className:`ping-indicator ${E.ok?`ok`:`err`}`,children:[(0,X.jsx)(`span`,{className:`ping-dot`}),(0,X.jsx)(`span`,{children:E.ok?`${E.latencyMs??0}ms 连通正常`:`连接失败`})]})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary sm`,onClick:Je,children:h(`save`)})]})]}),(0,X.jsxs)(`div`,{className:`quick-chips-wrapper`,children:[(0,X.jsx)(`span`,{className:`quick-chips-label`,children:`快捷预设模板 (Quick Presets)`}),(0,X.jsx)(`div`,{className:`quick-chips-grid`,children:og.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`quick-chip`,onClick:()=>qe(e),children:[(0,X.jsx)(`span`,{className:`quick-chip-name`,children:e.name}),e.tag&&(0,X.jsx)(`span`,{className:`quick-chip-tag`,children:e.tag})]},e.id))})]}),(0,X.jsxs)(`div`,{className:`form-grid`,children:[(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[h(`providerId`),` `,(0,X.jsx)(`em`,{children:h(`providerIdHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:v.providerId,disabled:e.some(e=>e.providerId===v.providerId),onChange:e=>y({...v,providerId:e.target.value}),placeholder:`例如 deepseek`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`displayName`)}),(0,X.jsx)(`input`,{type:`text`,value:v.name,onChange:e=>y({...v,name:e.target.value}),placeholder:h(`displayNamePh`)})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`apiType`)}),(0,X.jsx)(`select`,{value:v.api,onChange:e=>y({...v,api:e.target.value}),children:ag.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[`baseUrl `,(0,X.jsx)(`em`,{children:h(`baseUrlHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:v.baseUrl,onChange:e=>y({...v,baseUrl:e.target.value}),placeholder:`https://api.deepseek.com/v1`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:v.apiKey,onChange:e=>y({...v,apiKey:e.target.value}),placeholder:v.hasApiKey?h(`apiKeySavedHint`):h(`apiKeyHint`)})]}),(0,X.jsxs)(`label`,{className:`field check`,style:{alignSelf:`center`,paddingTop:16},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:v.authHeader,onChange:e=>y({...v,authHeader:e.target.checked})}),(0,X.jsx)(`span`,{children:h(`authHeader`)})]})]}),(0,X.jsxs)(`div`,{style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`model-section-head`,children:[(0,X.jsxs)(`span`,{className:`form-section-title`,style:{fontSize:13,fontWeight:600},children:[`模型矩阵 (`,v.models.filter(e=>e.id.trim()).length,`)`]}),(0,X.jsxs)(`div`,{className:`model-section-actions`,children:[V&&(0,X.jsx)(`span`,{className:`fetch-msg ${V.ok?`ok`:`err`}`,title:V.text,children:V.text}),le&&(0,X.jsx)(`span`,{className:`fetch-msg ${le.ok?`ok`:`err`}`,title:le.text,children:le.text}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:L||!v.baseUrl.trim(),title:h(`fetchModelsHint`),onClick:Ue,children:[(0,X.jsx)(Ie,{}),` `,L?h(`fetchingModels`):`自动获取并采纳模型`]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:H,title:h(`enrichModelsHint`),onClick:Ge,children:[(0,X.jsx)(Ie,{}),` `,h(H?`enrichingModels`:`enrichModels`)]}),H&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:W,title:h(`enrichModelsAbort`),onClick:Ke,style:{color:`var(--red)`},children:[(0,X.jsx)(N,{}),` `,h(W?`enrichCancelling`:`enrichModelsCancel`)]})]})]}),(0,X.jsxs)(`div`,{className:`model-matrix-list`,children:[v.models.map((e,t)=>(0,X.jsxs)(`div`,{className:`model-matrix-card`,children:[(0,X.jsxs)(`div`,{className:`matrix-main-row`,children:[(0,X.jsxs)(`div`,{className:`matrix-input-group id-group`,children:[(0,X.jsxs)(`span`,{className:`matrix-input-prefix`,children:[(0,X.jsx)(Le,{}),` ID`]}),(0,X.jsx)(`input`,{type:`text`,className:`matrix-input-field mono`,value:e.id,onChange:e=>Xe(t,{id:e.target.value}),placeholder:`例如 deepseek-chat`})]}),(0,X.jsxs)(`div`,{className:`matrix-input-group name-group`,children:[(0,X.jsx)(`span`,{className:`matrix-input-prefix`,children:`别名`}),(0,X.jsx)(`input`,{type:`text`,className:`matrix-input-field`,value:e.name,onChange:e=>Xe(t,{name:e.target.value}),placeholder:`显示名称 (选填)`})]}),(0,X.jsxs)(`div`,{className:`matrix-toggles`,children:[(0,X.jsx)(`button`,{type:`button`,className:`matrix-toggle-tag ${e.input===`text-image`?`active vision`:``}`,onClick:()=>Xe(t,{input:e.input===`text-image`?`text`:`text-image`}),title:`是否支持图像识图输入`,children:`🖼 视觉`}),(0,X.jsx)(`button`,{type:`button`,className:`matrix-toggle-tag ${e.reasoning?`active reasoning`:``}`,onClick:()=>Xe(t,{reasoning:!e.reasoning}),title:`是否支持深度思考推理`,children:`⚡ 推理`}),f!==void 0&&e.id.trim()&&(()=>{let t=`${v.providerId}/${e.id.trim()}`,n=f===t||f===e.id.trim();return(0,X.jsxs)(`button`,{type:`button`,className:`matrix-star-btn ${n?`active`:``}`,title:n?`当前全局默认模型(点击取消默认)`:`设为全局默认模型`,onClick:()=>{$(n?{type:`clear_default_model`}:{type:`set_default_model`,modelId:t})},children:[(0,X.jsx)(`span`,{className:`matrix-star-icon`,children:n?`★`:`☆`}),(0,X.jsx)(`span`,{children:n?`默认`:`设为默认`})]})})(),(0,X.jsx)(`button`,{type:`button`,className:`matrix-delete-btn`,title:h(`delete`),onClick:()=>Qe(t),children:(0,X.jsx)(R,{})})]})]}),(0,X.jsxs)(`div`,{className:`matrix-spec-bar`,children:[(0,X.jsxs)(`div`,{className:`spec-combobox`,children:[(0,X.jsx)(`span`,{className:`spec-combobox-label`,children:`上下文`}),(0,X.jsxs)(`select`,{className:`spec-combobox-select`,value:sg.some(t=>t.value===e.contextWindow)?e.contextWindow:`custom`,onChange:e=>{e.target.value!==`custom`&&Xe(t,{contextWindow:e.target.value})},children:[sg.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[e.label,` (`,Math.round(Number(e.value)/1024),`K)`]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:`自定义…`})]}),(!sg.some(t=>t.value===e.contextWindow)||e.contextWindow===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.contextWindow,onChange:e=>Xe(t,{contextWindow:e.target.value}),placeholder:`如 131072`})]}),(0,X.jsxs)(`div`,{className:`spec-combobox`,children:[(0,X.jsx)(`span`,{className:`spec-combobox-label`,children:`最大输出`}),(0,X.jsxs)(`select`,{className:`spec-combobox-select`,value:cg.some(t=>t.value===e.maxTokens)?e.maxTokens:`custom`,onChange:e=>{e.target.value!==`custom`&&Xe(t,{maxTokens:e.target.value})},children:[cg.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[e.label,` (`,Math.round(Number(e.value)/1024),`K)`]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:`自定义…`})]}),(!cg.some(t=>t.value===e.maxTokens)||e.maxTokens===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.maxTokens,onChange:e=>Xe(t,{maxTokens:e.target.value}),placeholder:`如 8192`})]}),(0,X.jsx)(`div`,{className:`matrix-spec-quick-pills`,children:[`32K`,`128K`,`200K`].map(n=>{let r=sg.find(e=>e.label===n);return r?(0,X.jsx)(`button`,{type:`button`,className:`param-pill ${e.contextWindow===r.value?`active`:``}`,onClick:()=>Xe(t,{contextWindow:r.value}),title:`快捷设为 ${n} 上下文`,children:n},n):null})})]})]},t)),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,style:{alignSelf:`flex-start`,marginTop:4},onClick:Ze,children:[(0,X.jsx)(ce,{}),` 添加模型行`]})]})]})]}),g.type===`builtin`&&(()=>{let e=t.find(e=>e.id===g.id);if(!e)return null;let a=n[e.id]??[];return(0,X.jsxs)(`div`,{className:`studio-card`,children:[(0,X.jsxs)(`div`,{className:`studio-card-head`,children:[(0,X.jsxs)(`div`,{className:`studio-card-title`,children:[(0,X.jsxs)(`span`,{children:[`官方内置服务商:`,e.name]}),e.configured&&(0,X.jsx)(`span`,{className:`auth-badge`,children:h(`configuredBadge`)}),e.source&&!e.configured&&(0,X.jsx)(`span`,{className:`auth-badge dim`,children:e.source})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{J(ye===e.id?null:e.id),Me(null)},children:[(0,X.jsx)(ce,{}),` `,h(`appendModel`)]}),e.supportsApiKey&&e.source===`stored`&&!e.usingOAuth&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm danger`,title:h(`clearKeyTitle`),onClick:()=>nt(e.id),children:[(0,X.jsx)(R,{}),` `,h(`clearKey`)]})]})]}),e.supportsOAuth&&(0,X.jsx)(rg,{provider:e,flow:r.find(t=>t.provider===e.id),result:i[e.id]}),e.supportsApiKey&&(0,X.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,X.jsx)(`span`,{style:{fontSize:12.5,fontWeight:600},children:`API 密钥管理`}),(0,X.jsxs)(`div`,{className:`provider-keys`,children:[a.length===0&&(0,X.jsx)(`div`,{className:`provider-key-empty`,children:h(`noKeyYet`)}),a.map(t=>(0,X.jsxs)(`div`,{className:`provider-key-item ${t.active?`active`:``}`,children:[(0,X.jsx)(`span`,{className:`provider-key-dot`,children:t.active?`●`:`○`}),(0,X.jsx)(`span`,{className:`provider-key-label`,children:t.name}),!t.active&&(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:h(`activateKey`),onClick:()=>et(e.id,t.name),children:(0,X.jsx)(Ye,{})}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger`,title:h(`removeKey`),onClick:()=>tt(e.id,t.name),children:(0,X.jsx)(R,{})})]},t.name))]}),(0,X.jsxs)(`div`,{className:`provider-add-key`,style:{marginTop:6},children:[(0,X.jsx)(`input`,{type:`text`,className:`key-input key-input-name`,placeholder:h(`keyNamePh`),value:ee[e.id]??``,onChange:t=>j(n=>({...n,[e.id]:t.target.value}))}),(0,X.jsx)(`input`,{type:`password`,className:`key-input key-input-value`,placeholder:h(`addKeyPlaceholder`),value:k[e.id]??``,onChange:t=>A(n=>({...n,[e.id]:t.target.value}))}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!(k[e.id]??``).trim()||M===e.id,onClick:()=>$e(e),children:[(0,X.jsx)(ce,{}),` `,M===e.id?h(`savingKey`):h(`addKey`)]})]})]}),ye===e.id&&(0,X.jsxs)(`div`,{style:{marginTop:12,padding:12,background:`var(--bg)`,borderRadius:8,border:`1px dashed var(--border-soft)`},children:[(0,X.jsx)(`span`,{style:{fontSize:12,fontWeight:600,display:`block`,marginBottom:8},children:`追加官方模型覆盖 (Overlay)`}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:`模型 ID (必填)`,value:be,onChange:e=>xe(e.target.value)}),(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:`显示名称 (选填)`,value:Se,onChange:e=>Ce(e.target.value)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!be.trim()||Oe,onClick:()=>it(e.id),children:[(0,X.jsx)(ce,{}),` 提交追加`]})]}),je&&(0,X.jsx)(`span`,{style:{fontSize:12,color:je.ok?`var(--green)`:`var(--red)`,marginTop:6},children:je.text})]})]})})()]})]}),b&&(0,X.jsx)(pg,{candidates:b,onAdopt:We,onClose:()=>x(null)})]})})}function hg(e,t=[],n){let r=[],i=e=>{r.includes(e)||r.push(e)};e.optionsFrom&&i(``);for(let t of e.options??[])i(t);if(e.optionsFrom===`models`)for(let e of t)i(`${e.provider}/${e.id}`);else if(e.optionsFrom===`thinkingLevels`)for(let e of zm)i(e);let a=typeof n==`string`?n:n==null?``:String(n);return a&&i(a),r}function gg({plugin:e,models:t=[]}){let n=Z(),r=e.settingsSchema??[],[i,a]=(0,m.useState)(()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);return t}),[o,s]=(0,m.useState)(!1);if(r.length===0)return null;let c=(e,t)=>a(n=>({...n,[e]:t})),l=e=>hg(e,t,i[e.key]).map(r=>{if(r===``)return{value:``,label:n(`pluginSettingsInherit`)};if(e.optionsFrom===`thinkingLevels`&&zm.includes(r))return{value:r,label:n(`thinking.${r}`)};if(e.optionsFrom===`models`){let e=t.find(e=>`${e.provider}/${e.id}`===r);if(e)return{value:r,label:e.label}}return{value:r,label:r}}),u=r.some(t=>t.type===`secret`?String(i[t.key]??``)!==``:i[t.key]!==e.settingsValues?.[t.key]);return(0,X.jsxs)(`div`,{className:`plugin-settings-form`,children:[(0,X.jsx)(`div`,{className:`plugin-settings-fields`,children:r.map(t=>(0,X.jsxs)(`label`,{className:`plugin-settings-field`,"data-key":t.key,title:t.hint,children:[(0,X.jsxs)(`span`,{className:`plugin-settings-label`,children:[(0,X.jsx)(`span`,{className:`plugin-settings-label-text`,title:t.label,children:t.label}),t.hint&&(0,X.jsx)(`span`,{className:`plugin-settings-hint`,children:t.hint})]}),(0,X.jsx)(`span`,{className:`plugin-settings-control`,children:t.type===`boolean`?(0,X.jsx)(`input`,{type:`checkbox`,checked:!!i[t.key],onChange:e=>c(t.key,e.target.checked)}):t.type===`secret`?(0,X.jsx)(`input`,{type:`password`,value:String(i[t.key]??``),placeholder:n(e.settingsValues?.[t.key]?`pluginSecretSet`:`pluginSecretUnset`),autoComplete:`new-password`,onChange:e=>c(t.key,e.target.value)}):t.type===`select`?(0,X.jsx)(`select`,{value:String(i[t.key]??``),onChange:e=>c(t.key,e.target.value),children:l(t).map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,X.jsx)(`input`,{type:t.type===`password`?`password`:t.type===`number`?`number`:`text`,value:String(i[t.key]??``),min:t.min,max:t.max,onChange:e=>c(t.key,t.type===`number`?Number(e.target.value):e.target.value)})})]},t.key))}),(0,X.jsxs)(`div`,{className:`plugin-settings-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn plugin-settings-save`,disabled:!u||o,onClick:()=>{s(!0),$({type:`plugin_settings`,pluginId:e.id,values:i}),setTimeout(()=>s(!1),800)},children:n(o?`pluginSettingsSaving`:`pluginSettingsSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn plugin-settings-reset`,onClick:()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);a(t)},children:n(`pluginSettingsReset`)})]})]})}var _g=[{value:`0 9 * * *`,key:`schedulerPresetDaily`},{value:`0 * * * *`,key:`schedulerPresetHourly`},{value:`*/30 * * * *`,key:`schedulerPresetHalfHour`},{value:`0 9 * * 1-5`,key:`schedulerPresetWorkday`},{value:`0 9 * * 1`,key:`schedulerPresetMonday`}];function vg(e){return{id:``,name:``,description:``,cwd:e,kind:`cron`,cron:`0 9 * * *`,preset:`0 9 * * *`,intervalMinutes:`60`,prompt:``,model:``,thinkingLevel:``,catchUp:!1}}function yg(e){let t=e.kind===`cron`&&_g.some(t=>t.value===e.spec);return{id:e.id,name:e.name,description:e.description,cwd:e.cwd,kind:e.kind,cron:e.kind===`cron`?e.spec:`0 9 * * *`,preset:t?e.spec:`custom`,intervalMinutes:e.kind===`interval`?String(Math.max(1,Math.round(Number(e.spec)/6e4))):`60`,prompt:e.prompt,model:e.model,thinkingLevel:e.thinkingLevel,catchUp:e.catchUp===`once`}}function bg(e,t){if(e.kind===`interval`){let n=Math.round(Number(e.spec)/6e4);return n<60?`${t(`schedulerKindInterval`)} · ${n} min`:n%60==0?`${t(`schedulerKindInterval`)} · ${n/60} h`:`${t(`schedulerKindInterval`)} · ${n} min`}let n=_g.find(t=>t.value===e.spec);return n?t(n.key):e.spec}function xg(e){if(!e)return``;try{return new Date(e).toLocaleString()}catch{return String(e)}}function Sg({tasks:e,cwd:t,models:n}){let r=Z(),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(new Set);(0,m.useEffect)(()=>{$({type:`schedule_list`})},[]);let u=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ve,{className:`set-section-icon`}),r(`settingsScheduler`),(0,X.jsx)(bc,{text:r(`schedulerDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:r(`schedulerNew`),onClick:()=>{a(vg(t)),s(!0)},children:[(0,X.jsx)(ce,{}),` `,r(`schedulerNew`)]})]}),e.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:r(`schedulerEmpty`)}):(0,X.jsx)(`ul`,{className:`scheduler-list`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`scheduler-item ${e.enabled?``:`off`}`,children:[(0,X.jsxs)(`div`,{className:`scheduler-line1`,children:[(0,X.jsxs)(`span`,{className:`scheduler-name`,title:e.description||e.name,children:[e.running?`${r(`schedulerRunning`)} `:``,e.name]}),(0,X.jsx)(`span`,{className:`scheduler-badge ${e.enabled?`on`:``}`,children:e.enabled?r(`schedulerEnabled`):r(`schedulerDisabled`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-switch ${e.enabled?`on`:``}`,title:e.enabled?r(`schedulerDisable`):r(`schedulerEnable`),onClick:()=>$({type:`schedule_toggle`,id:e.id,enabled:!e.enabled}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsx)(`span`,{title:e.cwd,children:e.cwd}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsx)(`span`,{title:e.kind===`cron`?e.spec:`${e.spec} ms`,children:bg(e,r)})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsxs)(`span`,{children:[r(`schedulerNextFire`),`: `,e.nextFire?xg(e.nextFire):`—`]}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsxs)(`span`,{children:[r(`schedulerLastRun`),`:`,` `,e.lastRun?(0,X.jsxs)(X.Fragment,{children:[xg(e.lastRun.at),` ·`,` `,(0,X.jsx)(`span`,{className:e.lastRun.ok?`scheduler-ok`:`scheduler-fail`,children:e.lastRun.ok?r(`schedulerRunOk`):r(`schedulerRunFail`)}),e.lastRun.manual?` · ${r(`schedulerManualBadge`)}`:``,e.lastRun.error?` · ${e.lastRun.error}`:``]}):r(`schedulerNeverRun`)]}),e.history.length>1&&(0,X.jsxs)(`button`,{type:`button`,className:`scheduler-link`,onClick:()=>u(e.id),children:[r(`schedulerHistory`),` (`,e.history.length,`)`]})]}),c.has(e.id)&&e.history.length>0&&(0,X.jsx)(`ul`,{className:`scheduler-history`,children:e.history.map((e,t)=>(0,X.jsxs)(`li`,{children:[xg(e.at),` ·`,` `,(0,X.jsx)(`span`,{className:e.ok?`scheduler-ok`:`scheduler-fail`,children:e.ok?r(`schedulerRunOk`):r(`schedulerRunFail`)}),` · ${(e.durationMs/1e3).toFixed(0)}s`,e.manual?` · ${r(`schedulerManualBadge`)}`:``,e.error?` · ${e.error}`:``]},`${e.at}-${t}`))}),(0,X.jsxs)(`div`,{className:`scheduler-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:e.running,title:r(`schedulerRunNow`),onClick:()=>$({type:`schedule_run`,id:e.id}),children:[(0,X.jsx)(le,{}),` `,r(`schedulerRunNow`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerEdit`),onClick:()=>{a(yg(e)),s(!1)},children:[(0,X.jsx)(Pe,{}),` `,r(`schedulerEdit`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerDelete`),onClick:()=>{window.confirm(r(`schedulerConfirmDelete`,{name:e.name}))&&$({type:`schedule_delete`,id:e.id})},children:[(0,X.jsx)(R,{}),` `,r(`schedulerDelete`)]})]})]},e.id))}),i&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>a(null),children:(0,X.jsxs)(`div`,{className:`modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":r(`close`),onClick:()=>a(null),children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Ve,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:o?r(`schedulerNew`):`${r(`schedulerEdit`)} · ${i.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:r(`schedulerNamePlaceholder`),value:i.name,onChange:e=>a({...i,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerDescPlaceholder`),value:i.description,onChange:e=>a({...i,description:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerCwdLabel`)}),(0,X.jsxs)(`div`,{className:`scheduler-cwd-row`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerCwdPlaceholder`),value:i.cwd,onChange:e=>a({...i,cwd:e.target.value})}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>a({...i,cwd:t}),children:r(`schedulerUseCurrentCwd`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.kind,onChange:e=>a({...i,kind:e.target.value}),children:[(0,X.jsx)(`option`,{value:`cron`,children:r(`schedulerKindCron`)}),(0,X.jsx)(`option`,{value:`interval`,children:r(`schedulerKindInterval`)})]})]}),i.kind===`cron`?(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindCron`)}),(0,X.jsxs)(`div`,{className:`scheduler-cwd-row`,children:[(0,X.jsxs)(`select`,{className:`set-select`,value:i.preset,onChange:e=>{let t=e.target.value;a({...i,preset:t,...t===`custom`?{}:{cron:t}})},children:[_g.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[r(e.key),` · `,e.value]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:r(`schedulerPresetCustom`)})]}),i.preset===`custom`&&(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerCronPlaceholder`),value:i.cron,onChange:e=>a({...i,cron:e.target.value})})]})]}):(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindInterval`)}),(0,X.jsx)(`input`,{className:`set-input`,type:`number`,min:1,placeholder:r(`schedulerIntervalMinutes`),value:i.intervalMinutes,onChange:e=>a({...i,intervalMinutes:e.target.value})})]}),(0,X.jsx)(`div`,{className:`tpl-fields`,children:(0,X.jsx)(`textarea`,{className:`set-input`,rows:4,placeholder:r(`schedulerPromptPlaceholder`),value:i.prompt,onChange:e=>a({...i,prompt:e.target.value})})}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.model,onChange:e=>a({...i,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`subagentFollowMain`)}),n.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})]}),n.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:r(`subagentNoModels`)}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[r(`schedulerThinkingLabel`),` `,(0,X.jsx)(bc,{text:r(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.thinkingLevel,onChange:e=>a({...i,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`tplThinkingFollowMain`)}),zm.map(e=>(0,X.jsx)(`option`,{value:e,children:r(`thinking.${e}`)},e))]})]}),(0,X.jsxs)(`label`,{className:`scheduler-check`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i.catchUp,onChange:e=>a({...i,catchUp:e.target.checked})}),(0,X.jsxs)(`span`,{children:[r(`schedulerCatchUp`),` `,(0,X.jsx)(bc,{text:r(`schedulerCatchUpHint`)})]})]}),(0,X.jsxs)(`div`,{className:`scheduler-foot`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>a(null),children:r(`schedulerCancelEdit`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!i.name.trim()||!i.cwd.trim()||!i.prompt.trim(),onClick:()=>{if(!i)return;let e=i.kind;$({type:`schedule_save`,task:{...i.id?{id:i.id}:{},name:i.name.trim(),description:i.description.trim(),cwd:i.cwd.trim(),kind:e,spec:e===`cron`?i.cron.trim():String(Math.max(1,Math.floor(Number(i.intervalMinutes)||0))*6e4),prompt:i.prompt.trim(),...i.model.trim()?{model:i.model.trim()}:{},...i.thinkingLevel.trim()?{thinkingLevel:i.thinkingLevel.trim()}:{},catchUp:i.catchUp?`once`:`skip`}}),a(null)},children:r(`schedulerSave`)})]})]})]})})]})}var Cg=`pi-web-sounds`,wg={enabled:!0,question:!0,done:!0,start:!1,error:!0,approval:!0,volume:100};function Tg(){try{let e=localStorage.getItem(Cg);if(!e)return{...wg};let t=JSON.parse(e),n={...wg,...t};for(let e of[`enabled`,`question`,`done`,`start`,`error`,`approval`])typeof n[e]!=`boolean`&&(n[e]=wg[e]);return n.volume=typeof n.volume!=`number`||!Number.isFinite(n.volume)?wg.volume:Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...wg}}}function Eg(e){try{localStorage.setItem(Cg,JSON.stringify(e))}catch{}}var Dg=null;function Og(){try{if(!Dg){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Dg=new e}return Dg.state===`suspended`&&Dg.resume(),Dg}catch{return null}}var kg={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}],approval:[{type:`sine`,freq:659.25,start:0,dur:.11,peak:.45},{type:`sine`,freq:659.25,start:.14,dur:.11,peak:.45},{type:`sine`,freq:880,start:.28,dur:.26,peak:.5}]};function Ag(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 jg(e,t=Tg()){if(!t.enabled||!t[e])return;let n=Og();if(!n)return;let r=Math.max(0,Math.min(1,t.volume/100));for(let t of kg[e])Ag(n,t,r)}function Mg(e){if(e==null)return 0;if(typeof e==`number`){if(!Number.isFinite(e)||e<=0)return 0;let t=Math.floor(e);return t<=1e3?t*1e3:Math.min(1e7,t)}let t=String(e).trim().toLowerCase().replace(/[,_\s]/g,``);if(!t)return 0;let n=t.match(/^(\d+(?:\.\d+)?)([km])?$/);if(!n)return 0;let r=parseFloat(n[1]);if(!Number.isFinite(r)||r<=0)return 0;let i=n[2],a;return i===`k`?a=Math.floor(r*1e3):i===`m`?a=Math.floor(r*1e6):(a=Math.floor(r),a<=1e3&&(a*=1e3)),Math.min(1e7,Math.max(0,a))}function Ng(e){return!e||e<=0||!Number.isFinite(e)?``:e>=1e6&&e%1e5==0?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3&&e%1e3==0?`${e/1e3}k`:String(e)}var Pg=`pi-web-ui:wide-chat`,Fg={wide:!1};function Ig(e){if(!e||typeof e!=`object`)return{...Fg};let t=e;return{wide:typeof t.wide==`boolean`?t.wide:Fg.wide}}function Lg(){try{let e=localStorage.getItem(Pg);return e?Ig(JSON.parse(e)):{...Fg}}catch{return{...Fg}}}function Rg(e){let t=Ig(e);try{localStorage.setItem(Pg,JSON.stringify(t))}catch{}zg=t;for(let e of Bg)e()}var zg=null,Bg=new Set;function Vg(e){return Bg.add(e),()=>{Bg.delete(e)}}function Hg(){return zg||=Lg(),zg.wide}function Ug(){return(0,m.useSyncExternalStore)(Vg,Hg)}var Wg=`pi-web-ui:project-title`,Gg={projectName:!0};function Kg(e){if(!e||typeof e!=`object`)return{...Gg};let t=e;return{projectName:typeof t.projectName==`boolean`?t.projectName:Gg.projectName}}function qg(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()??``:``}function Jg(){try{let e=localStorage.getItem(Wg);return e?Kg(JSON.parse(e)):{...Gg}}catch{return{...Gg}}}function Yg(e){let t=Kg(e);try{localStorage.setItem(Wg,JSON.stringify(t))}catch{}Xg=t;for(let e of Zg)e()}var Xg=null,Zg=new Set;function Qg(e){return Zg.add(e),()=>{Zg.delete(e)}}function $g(){return Xg||=Jg(),Xg.projectName}function e_(){return(0,m.useSyncExternalStore)(Qg,$g)}var t_=`pi-web-ui:wallpaper`,n_=`has-wallpaper`,r_={url:``,dim:78,blur:0},i_=2e3,a_=28e5;function o_(e){if(typeof e!=`string`)return``;let t=e.trim();if(!t)return``;let n=t.toLowerCase().startsWith(`data:image/`)?a_:i_;return t.length>n?``:/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith(`/`)&&!t.startsWith(`//`)?t:``}var s_=(e,t,n,r)=>typeof e!=`number`||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)));function c_(e){if(!e||typeof e!=`object`)return{...r_};let t=e;return{url:o_(t.url),dim:s_(t.dim,0,95,r_.dim),blur:s_(t.blur,0,24,r_.blur)}}function l_(){try{let e=localStorage.getItem(t_);return e?c_(JSON.parse(e)):{...r_}}catch{return{...r_}}}function u_(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/[\r\n]/g,``)}async function d_(e){let t=await jd(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function f_(){let e=m_??l_(),t=document.documentElement;e.url?(t.style.setProperty(`--bg-image`,`url("${u_(e.url)}")`),t.style.setProperty(`--bg-image-dim`,String(e.dim/100)),t.style.setProperty(`--bg-image-blur`,`${e.blur}px`)):(t.style.removeProperty(`--bg-image`),t.style.removeProperty(`--bg-image-dim`),t.style.removeProperty(`--bg-image-blur`));let n=getComputedStyle(t).getPropertyValue(`--bg-image`).trim();document.body.classList.toggle(n_,e.url!==``||n!==``&&n!==`none`)}function p_(e){let t=c_(e);m_=t;try{localStorage.setItem(t_,JSON.stringify(t))}catch{}for(let e of h_)e();f_()}var m_=null,h_=new Set;function g_(e){return h_.add(e),()=>{h_.delete(e)}}function __(){return m_||=l_(),m_}function v_(){return(0,m.useSyncExternalStore)(g_,__)}function y_(){let e=v_();(0,m.useEffect)(()=>{f_()},[e]),(0,m.useEffect)(()=>{let e=()=>f_();return window.addEventListener(Kl,e),f_(),()=>window.removeEventListener(Kl,e)},[])}function b_(e,t){return e.error?`failed`:t?`disabled`:e.active===!0?`active`:`idle`}function x_(e,t){let n={active:0,disabled:0,failed:0,idle:0};for(let r of e)n[b_(r,t.has(r.id))]+=1;return n}var S_={zh:[`继续`,`总结一下`,`详细解释一下`,`检查并修复问题`,`补充测试覆盖`,`发布上传`],en:[`Continue`,`Summarize`,`Explain in detail`,`Check and fix issues`,`Add test coverage`,`Publish release`],it:[`Continua`,`Riassumi`,`Spiega in dettaglio`,`Verifica e correggi i problemi`,`Aggiungi copertura dei test`,`Pubblica la release`],ja:[`続ける`,`要約して`,`詳しく説明して`,`問題を確認して修正`,`テストカバレッジを追加`,`公開・リリース`],ko:[`계속`,`요약해줘`,`자세히 설명해줘`,`문제를 확인하고 수정`,`테스트 커버리지 추가`,`게시/릴리스`],fr:[`Continuer`,`Résumer`,`Expliquer en détail`,`Vérifier et corriger les problèmes`,`Ajouter des tests`,`Publier`],de:[`Weiter`,`Zusammenfassen`,`Ausführlich erklären`,`Probleme prüfen und beheben`,`Testabdeckung ergänzen`,`Veröffentlichen`],es:[`Continuar`,`Resumir`,`Explicar en detalle`,`Revisar y corregir problemas`,`Añadir cobertura de pruebas`,`Publicar`],ru:[`Продолжить`,`Подведи итог`,`Объясни подробно`,`Проверь и исправь проблемы`,`Добавь покрытие тестами`,`Опубликовать`],pt:[`Continuar`,`Resumir`,`Explique em detalhes`,`Verifique e corrija os problemas`,`Adicione cobertura de testes`,`Publique a release`]},C_=[`soul`,`tools`,`guidelines`,`pi_docs`,`append`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`],w_=[`tools`,`pi_docs`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`];function T_(e){return w_.includes(e)}var E_=C_.map(e=>`{{${e}}}`).join(`
|
|
356
|
+
`)}}var lm=null;function um(){if(lm?.isConnected)return lm;let e=document.createElement(`div`);e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-caret-mirror`,``);let t=e.style;return t.position=`fixed`,t.top=`0`,t.left=`-99999px`,t.visibility=`hidden`,t.pointerEvents=`none`,t.margin=`0`,t.padding=`0`,t.border=`0`,t.boxSizing=`border-box`,t.overflow=`visible`,document.body.appendChild(e),lm=e,e}function dm(e,t){let n=getComputedStyle(e),r=t.style;r.fontFamily=n.fontFamily,r.fontSize=n.fontSize,r.fontStyle=n.fontStyle,r.fontWeight=n.fontWeight,r.fontVariant=n.fontVariant,r.fontStretch=n.fontStretch,r.lineHeight=n.lineHeight,r.letterSpacing=n.letterSpacing,r.wordSpacing=n.wordSpacing,r.textTransform=n.textTransform,r.textIndent=n.textIndent,r.tabSize=n.tabSize,r.whiteSpace=n.whiteSpace||`pre-wrap`,r.overflowWrap=n.overflowWrap||`break-word`,r.wordBreak=n.wordBreak||`normal`,r.direction=n.direction,r.writingMode=n.writingMode,r.paddingLeft=n.paddingLeft,r.paddingRight=n.paddingRight;let i=e.clientWidth;return i>0?(r.width=`${i}px`,i):0}function fm(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=om,e.appendChild(n),n.offsetTop}function pm(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=cm(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=um();if(dm(e,i)<=0)return r;let a=fm(i,t.slice(0,n)),o=fm(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:sm(a,o,am(e))}var mm=`pi-web-ui:prompt-history`,hm=`pi-web-ui:prompt-history-settings`,gm={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function _m(e){let t=gm;if(!e||typeof e!=`object`)return{...t};let n=e,r=typeof n.maxEntries==`number`?Math.floor(n.maxEntries):t.maxEntries;(!Number.isFinite(r)||r<1)&&(r=1),r>500&&(r=500);let i=typeof n.charLimit==`number`?Math.floor(n.charLimit):t.charLimit;(!Number.isFinite(i)||i<100)&&(i=100),i>2e4&&(i=2e4);let a=typeof n.charLimitEnabled==`boolean`?n.charLimitEnabled:t.charLimitEnabled;return{maxEntries:r,charLimitEnabled:a,charLimit:i}}function vm(){try{let e=localStorage.getItem(hm);return e?_m(JSON.parse(e)):{...gm}}catch{return{...gm}}}function ym(e){let t=_m(e);try{localStorage.setItem(hm,JSON.stringify(t))}catch{}try{let e=Sm();t.charLimitEnabled&&(e=e.map(e=>e.length>t.charLimit?e.slice(0,t.charLimit):e)),e.length>t.maxEntries&&(e=e.slice(e.length-t.maxEntries)),Cm(e)}catch{}}function bm(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}return t}function xm(e,t,n=100){let r=t.trim();if(!r||e.length>0&&e[e.length-1]===r)return e;let i=[...e,r];return i.length>n?i.slice(i.length-n):i}function Sm(){try{let e=localStorage.getItem(mm);return e?bm(JSON.parse(e)):[]}catch{return[]}}function Cm(e){let t=e;for(;t;)try{localStorage.setItem(mm,JSON.stringify(t));return}catch(e){if(!(e instanceof DOMException&&(e.name===`QuotaExceededError`||e.code===22))||t.length<=1)return;t=t.slice(Math.ceil(t.length/2))}}function wm(e){let t=e.trim();if(!t)return;let n=vm();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));let r=Sm(),i=xm(r,t,n.maxEntries);i!==r&&Cm(i)}function Tm(){try{localStorage.removeItem(mm)}catch{}}var Em=`skill:`;function Dm(e,t){let n=e.toLowerCase();return t===`skill`&&n.startsWith(`skill:`)?[n,n.slice(6)]:[n]}function Om(e,t){let n=t.toLowerCase();return n?e.filter(e=>Dm(e.name,e.source).some(e=>e.startsWith(n))):[...e]}var km=new Set([`p`,`page`,`pages`,`web`,`网页`,`页面`]);function Am(e,t,n,r=10){if(!Array.isArray(t))return[];let i=String(n??``).toLowerCase(),a=i===``||km.has(i),o=[];for(let n of t){if(!n||typeof n.origin!=`string`||!n.origin||n.open!==!0)continue;let t=typeof n.title==`string`&&n.title.trim()?n.title.trim():n.origin;if(!a&&!t.toLowerCase().includes(i)&&!n.origin.toLowerCase().includes(i))continue;let s=t.indexOf(` · `),c=s===-1?`page · ${t}`:`page · ${t.slice(s+3)}`;if(o.push({providerId:`host:pages`,providerLabel:e,title:c,hint:n.origin,text:t,attachments:[{path:n.origin,name:t,mode:`page`}]}),o.length>=Math.max(0,r))break}return o}function jm(e,t,n=10){if(!Array.isArray(t))return[];let r=[];for(let i of t.slice(0,Math.max(0,n))){if(!i||typeof i!=`object`)continue;let t=i;typeof t.path==`string`&&t.path&&typeof t.name==`string`&&t.name&&r.push({providerId:`host:files`,providerLabel:e,title:t.name,hint:t.path,text:`@${t.name}`,attachments:[{path:t.path,name:t.name,mode:`reference`,...t.type===`dir`?{isDir:!0}:{}}]})}return r}function Mm(e,t,n,r=10){if(!Array.isArray(n))return[];let i=[];for(let a of n.slice(0,Math.max(0,r))){if(!a||typeof a!=`object`)continue;let n=a;if(typeof n.title!=`string`||!n.title.trim())continue;let r=Array.isArray(n.attachments)?n.attachments.filter(e=>!!e&&typeof e==`object`&&typeof e.path==`string`).slice(0,4).map(e=>{let t=e.mode;return{path:e.path,...typeof e.name==`string`?{name:e.name}:{},...t===`inline`||t===`reference`||t===`lines`||t===`page`?{mode:t}:{},...typeof e.isDir==`boolean`?{isDir:e.isDir}:{}}}):void 0;i.push({providerId:e,providerLabel:t,title:n.title.trim(),...typeof n.hint==`string`&&n.hint?{hint:n.hint}:{},...typeof n.text==`string`&&n.text?{text:n.text}:{},...r?.length?{attachments:r}:{}})}return i}function Nm(e,t,n,r=15,i){if(!Array.isArray(t)||r<=0)return[];let a=String(n??``).toLowerCase(),o=a.startsWith(Em),s=o?a.slice(Em.length):a,c=[],l=[],u=o||s.length>=3;for(let n of t){if(n.source!==`skill`)continue;let t=n.name.startsWith(`skill:`)?n.name.slice(Em.length):n.name,r=t.toLowerCase(),a=i?i(n):n.description??``,o=a.toLowerCase(),d=(n.descriptionEn??``).toLowerCase(),f={providerId:`host:skills`,providerLabel:e,title:t,hint:a||`Skill ${t}`,text:`@skill:${t}`};s?r.includes(s)?c.push(f):u&&(o.includes(s)||d.includes(s))&&l.push(f):c.push(f)}return[...c,...l].slice(0,Math.max(0,r))}function Pm(e,t,n=30){let r=String(t??``).toLowerCase(),i=e.pages??[],a=e.skills??[],o=e.files??[],s=e.plugins??[],c;return c=r.startsWith(`skill:`)?[...a,...i,...o,...s]:[...i,...a,...o,...s],c.slice(0,Math.max(0,n))}function Fm(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function Im(e,t){let n=typeof e==`string`?e:``,r=Math.max(0,Math.min(typeof t==`number`&&Number.isFinite(t)?Math.floor(t):0,n.length)),i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a===-1||!Fm(a>0?i[a-1]:void 0))return null;let o=i.slice(a+1);return/[\s@]/.test(o)?null:{start:a,query:o}}function Lm(e){let t=e.query;if(!t||!t(`(pointer: coarse)`)||!t(`(hover: none)`))return!1;let n=e.userAgent??``;return!(/Windows|CrOS/i.test(n)||/Linux/i.test(n)&&!/Android/i.test(n)||/Macintosh/i.test(n)&&(e.maxTouchPoints??0)<=1)}function Rm(){return typeof window>`u`||typeof navigator>`u`||typeof window.matchMedia!=`function`?!1:Lm({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}var zm=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Bm=(0,m.memo)(function({state:e,models:t,modelsLoading:n,onManageModels:r,providerKeys:i,defaultModel:a,compact:o=!1,only:s}){let c=Z(),l=e?.model,u=l?`${l.provider}/${l.id}`:null,[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(``),[v,y]=(0,m.useState)(null),[b,x]=(0,m.useState)({}),S=(0,m.useRef)(null),C=(0,m.useRef)(null),[w,T]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!d){T(null);return}if(t.length===0)return;let e=requestAnimationFrame(()=>{let e=C.current;e&&T(e.offsetWidth)});return()=>cancelAnimationFrame(e)},[d,t.length]),(0,m.useEffect)(()=>{d&&x($f())},[d]),(0,m.useEffect)(()=>{d||(_(``),y(null))},[d]);let E=(0,m.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.provider,(e.get(n.provider)??0)+1);let n=[];for(let[t,r]of[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))){let e=i[t];if(e&&e.length>1)for(let i of e)n.push({provider:t,keyName:i.name,count:r});else n.push({provider:t,keyName:null,count:r})}return n},[t,i]),D=(0,m.useMemo)(()=>Qf(t,b),[t,b]),O=(0,m.useMemo)(()=>{let e=D;v&&(e=e.filter(e=>e.provider===v.provider));let t=g.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.provider.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)):e},[D,g,v]),k=(0,m.useMemo)(()=>{let e=[];for(let t of O){let n=i[t.provider];if(!n||n.length<=1){e.push({model:t,key:null});continue}let r=n.find(e=>e.active)??n[0];if(v?.provider===t.provider&&v.keyName){let e=n.find(e=>e.name===v.keyName);e&&(r=e)}e.push({model:t,key:r})}return e},[O,i,v]),[A,ee]=(0,m.useState)(!1),j=e?.availableThinkingLevels&&e.availableThinkingLevels.length>0?new Set(e.availableThinkingLevels):null,N=zm.map(e=>({value:e,label:c(`thinking.${e}`),supported:!j||j.has(e)})),P=e=>N.find(t=>t.value===e)?.label??e,F=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!d){F.current=!1;return}F.current||t.length>0||n||(F.current=!0,ee(!0),$({type:`list_models`})||ee(!1))},[d,t.length,n]),(0,m.useEffect)(()=>{ee(!1)},[t]),(0,m.useEffect)(()=>{d&&(S.current?.querySelector(`.dd-item.active`))?.scrollIntoView({block:`nearest`})},[d,u,t.length]);let I=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`availableModels`)}),(0,X.jsxs)(`div`,{className:`dd-search-row`,children:[(0,X.jsx)(re,{}),(0,X.jsx)(`input`,{className:`dd-search`,type:`text`,placeholder:c(`searchModels`),value:g,onChange:e=>_(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`dd-model-body`,children:[E.length>1&&(0,X.jsxs)(`div`,{className:`dd-provider-col`,children:[(0,X.jsx)(`div`,{className:`dd-provider-head`,children:c(`providers`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-provider-item ${v===null?`active`:``}`,onClick:()=>y(null),children:(0,X.jsx)(`span`,{children:c(`allProviders`)})}),E.map(e=>{let t=v?.provider===e.provider&&v?.keyName===e.keyName;return(0,X.jsxs)(`button`,{type:`button`,className:`dd-provider-item ${t?`active`:``}`,onClick:()=>y(t?null:{provider:e.provider,keyName:e.keyName}),title:e.keyName?`${e.provider} · ${e.keyName}`:`${e.provider} · ${e.count}`,children:[(0,X.jsxs)(`span`,{className:`dd-provider-txt`,children:[(0,X.jsx)(`span`,{className:`dd-provider-name`,children:e.provider}),e.keyName&&(0,X.jsx)(`span`,{className:`dd-provider-key`,children:e.keyName})]}),(0,X.jsx)(`span`,{className:`dd-provider-count`,children:e.count})]},e.keyName?`${e.provider}::${e.keyName}`:e.provider)})]}),(0,X.jsxs)(`div`,{className:`dd-model-scroll`,ref:S,children:[(A||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`loading`)}),t.length===0&&!A&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`noModels`)}),O.length===0&&t.length>0&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`noModelMatches`)}),k.map(e=>{let t=e.model,n=u===t.id&&(!e.key||e.key.active),r=a!==void 0&&a===t.id;return(0,X.jsxs)(St,{active:n,onClick:()=>{e.key&&!e.key.active&&$({type:`activate_provider_key`,provider:t.provider,keyName:e.key.name}),u!==t.id&&$({type:`set_model`,modelId:t.id}),f(!1)},children:[(0,X.jsxs)(`span`,{className:`dd-model-cell`,children:[(0,X.jsx)(`span`,{className:`dd-model-name`,children:t.name}),(0,X.jsxs)(`span`,{className:`dd-model-meta`,children:[(0,X.jsx)(`span`,{className:`dd-model-provider`,children:t.provider}),(0,X.jsx)(`span`,{className:`dd-model-id`,children:t.id.split(`/`).slice(1).join(`/`)}),e.key&&(0,X.jsxs)(`span`,{className:`dd-model-key ${e.key.active?`active`:``}`,children:[e.key.active?`●`:`○`,` `,e.key.name]}),(b[t.id]??0)>0&&(0,X.jsx)(`span`,{className:`dd-model-usage`,children:c(`modelUsedCount`,{n:b[t.id]})}),(t.reasoning||t.vision)&&(0,X.jsxs)(`span`,{className:`dd-model-badges`,children:[t.reasoning&&(0,X.jsx)(`span`,{className:`dd-model-badge`,children:c(`reasoning`)}),t.vision&&(0,X.jsx)(`span`,{className:`dd-model-badge`,children:c(`vision`)})]})]})]}),a!==void 0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-star-btn ${r?`active`:``}`,title:r?`当前全局默认模型(点击取消默认)`:`设为全局默认模型`,onClick:e=>{e.stopPropagation(),$(r?{type:`clear_default_model`}:{type:`set_default_model`,modelId:t.id})},children:r?`★`:`☆`})]},e.key?`${t.id}::${e.key.name}`:t.id)})]})]}),(0,X.jsxs)(`div`,{className:`dd-footer`,children:[a!==void 0&&a&&(0,X.jsxs)(`div`,{className:`dd-default-banner`,children:[(0,X.jsxs)(`div`,{className:`dd-default-banner-left`,children:[(0,X.jsx)(`span`,{className:`dd-default-banner-star`,children:`★`}),(0,X.jsx)(`span`,{className:`dd-default-banner-label`,children:`默认模型`}),(0,X.jsx)(`span`,{className:`dd-default-banner-name`,title:`默认模型: ${a}`,children:a.split(`/`).slice(1).join(`/`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`dd-default-banner-clear`,title:`清除全局默认模型`,onClick:()=>$({type:`clear_default_model`}),children:`✕ 清除`})]}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`list_models`}),children:c(`refreshModels`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>{f(!1),r()},children:c(`manageModels`)})]})]}),L=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`thinkingLevel`)}),N.map(t=>(0,X.jsx)(St,{active:e?.thinkingLevel===t.value,disabled:!t.supported,title:t.supported?void 0:c(`thinkingUnsupported`),onClick:()=>{e?.thinkingLevel!==t.value&&$({type:`set_thinking`,level:t.value}),h(!1)},children:t.label},t.value))]}),R=(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Le,{}),(0,X.jsx)(`span`,{className:`chip-model`,children:l?l.name:c(`selectModel`)}),!o&&l?.vision&&(0,X.jsx)(`span`,{className:`chip-vision`,title:c(`vision`),children:`🖼`}),!o&&l&&(0,X.jsx)(`span`,{className:`chip-sub`,children:l.provider})]}),open:d,onOpenChange:f,align:`left`,menuClassName:`dd-menu-model`,menuRef:C,menuStyle:w==null?void 0:{width:w},direction:`up`,children:I}),te=(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:c(`thinkingChip`,{level:e?P(e.thinkingLevel):`—`})})]}),tip:c(`thinkingLevel`),open:p,onOpenChange:h,align:`left`,direction:`up`,children:L});if(s===`model`)return R;if(s===`thinking`)return te;let z=e?.thinkingLevel&&e.thinkingLevel!==`off`;return(0,X.jsxs)(`div`,{className:`model-thinking-capsule`,children:[(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Le,{}),(0,X.jsx)(`span`,{className:`capsule-model-name`,children:l?l.name:c(`selectModel`)}),!o&&l?.vision&&(0,X.jsx)(`span`,{className:`chip-vision`,title:c(`vision`),children:`🖼`})]}),triggerClassName:`capsule-segment capsule-model`,open:d,onOpenChange:f,align:`left`,menuClassName:`dd-menu-model`,menuRef:C,menuStyle:w==null?void 0:{width:w},direction:`up`,children:I}),(0,X.jsx)(`div`,{className:`capsule-divider`}),(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`thinking-pulse-dot ${z?`on`:``}`}),(0,X.jsx)(`span`,{className:`capsule-thinking-text`,children:e?P(e.thinkingLevel):`—`})]}),triggerClassName:`capsule-segment capsule-thinking`,open:p,onOpenChange:h,align:`left`,direction:`up`,children:L})]})}),Vm=[`standard`,`ptc`,`minimal`,`cordis`];function Hm(e){return[...e].sort((e,t)=>{let n=Number.isSafeInteger(e.order)?e.order:Vm.indexOf(e.id),r=Number.isSafeInteger(t.order)?t.order:Vm.indexOf(t.id),i=n>=0?n:1e3,a=r>=0?r:1e3;return i===a?e.id.localeCompare(t.id):i-a})}var Um=(0,m.memo)(function({preset:e,presets:t,defaultPreset:n,blank:r,conversationId:i,compact:a=!1}){let o=Z(),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(e?.id??n);if((0,m.useEffect)(()=>{u(e?.id??n)},[i,e?.id,n]),t.length===0)return null;let d=e?.locked||!r,f=Hm(t),p=f.find(t=>t.id===e?.id),h=f.find(e=>e.id===l)??p,g=t=>{u(t),c(!1),r&&t!==e?.id&&$({type:`dsh_preset_select`,preset:t})};if(a){let t=p?.description??p?.id??o(`dshPreset`);return(0,X.jsx)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(H,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:d?`${t}(${o(`dshPresetLocked`)})`:t,children:[p?.name??p?.id??e?.name??o(`dshPreset`),d&&(0,X.jsx)(q,{style:{marginLeft:3}})]})]}),open:s&&!d,onOpenChange:c,direction:`up`,align:`left`,children:f.map(t=>(0,X.jsxs)(St,{active:t.id===e?.id,disabled:!!t.broken,title:t.broken??t.description??t.id,onClick:()=>g(t.id),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[t.name??t.id,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetUser`)}),t.id===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:o(`dshPresetBroken`)})]}),t.description&&!t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:t.description})]},t.id))})}return(0,X.jsxs)(`div`,{className:`dsh-presetbar`,"data-testid":`dsh-presetbar`,children:[(0,X.jsxs)(`span`,{className:`dsh-preset-label`,children:[(0,X.jsx)(H,{}),o(`dshPreset`)]}),(0,X.jsx)(xt,{trigger:(0,X.jsxs)(`span`,{title:p?.description??p?.id??``,children:[p?.name??p?.id??e?.name??`…`,d&&(0,X.jsxs)(`span`,{className:`dsh-preset-lock`,title:o(`dshPresetBlankOnly`),children:[(0,X.jsx)(q,{}),` `,o(`dshPresetLocked`)]})]}),open:s&&!d,onOpenChange:c,children:f.map(t=>(0,X.jsxs)(St,{active:t.id===e?.id,disabled:!!t.broken,title:t.broken??t.description??t.id,onClick:()=>g(t.id),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[t.name??t.id,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetUser`)}),t.id===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:o(`dshPresetBroken`)})]}),t.description&&!t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:t.description})]},t.id))}),!d&&(0,X.jsx)(`span`,{className:`dsh-preset-hint`,title:o(`dshPresetBlankOnly`),children:o(`dshPresetBlankOnly`)}),h?.id===`minimal`&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:o(`dshPresetMinimalNote`)}),(0,X.jsxs)(`button`,{type:`button`,className:`chip`,title:o(`dshPresetNewChat`),onClick:()=>{$({type:`new_chat`,preset:h?.id??l}),Vn()},children:[(0,X.jsx)(se,{}),` `,o(`dshPresetNewChat`)]})]})}),Wm=[`read-only`,`workspace-write-never`,`danger-full-access`],Gm=[`read-only`,`workspace-write-never`,`danger-full-access`];function Km(e){return e===`read-only`?`dshPermReadOnly`:e===`danger-full-access`?`dshPermFullAccess`:`dshPermWorkspaceWrite`}function qm(e){return e===`read-only`?`dshPermReadOnlyDesc`:e===`danger-full-access`?`dshPermFullAccessDesc`:`dshPermWorkspaceWriteDesc`}var Jm=(0,m.memo)(function({current:e,options:t,defaultPreset:n,conversationId:r,compact:i=!1}){let a=Z(),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1);(0,m.useEffect)(()=>{l(!1),s(!1)},[r]);let u=Wm.filter(e=>t.some(t=>t.value===e));if(u.length===0)return null;let d=e??n,f=!!e&&!u.includes(e),p=e=>{if(e===`danger-full-access`&&e!==d&&!c){l(!0);return}l(!1),s(!1),e!==d&&$({type:`dsh_permission_set`,preset:e})};if(i){let r=a(f?`dshPermCustom`:Km(d)),i=f?e??r:a(qm(d));return(0,X.jsxs)(xt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:i,children:[r,d===`danger-full-access`&&(0,X.jsx)(at,{style:{marginLeft:3}})]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},direction:`up`,align:`left`,children:[u.map(e=>{let r=t.find(t=>t.value===e);return(0,X.jsxs)(St,{active:e===d,title:r?.description??a(qm(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(Km(e)),e===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)}),e===`danger-full-access`&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:a(`dshPermFullAccessTag`)})]}),(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:a(qm(e))})]},e)}),c&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:a(`dshPermConfirmFull`)})]})}return(0,X.jsxs)(`div`,{className:`dsh-presetbar`,"data-testid":`dsh-permissionbar`,children:[(0,X.jsxs)(`span`,{className:`dsh-preset-label`,children:[(0,X.jsx)(U,{}),a(`dshPerm`)]}),(0,X.jsx)(xt,{trigger:(0,X.jsxs)(`span`,{title:f?e:a(qm(d)),children:[a(f?`dshPermCustom`:Km(d)),d===`danger-full-access`&&(0,X.jsxs)(`span`,{className:`dd-preset-tag warn`,children:[(0,X.jsx)(at,{}),` `,a(`dshPermFullAccessTag`)]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},children:u.map(e=>{let r=t.find(t=>t.value===e);return(0,X.jsxs)(St,{active:e===d,title:r?.description??a(qm(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(Km(e)),e===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)}),e===`danger-full-access`&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:a(`dshPermFullAccessTag`)})]}),(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:a(qm(e))})]},e)})}),c&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:a(`dshPermConfirmFull`)})]})}),Ym=Rm(),Xm=40,Zm=220,Qm=720,$m=`pi-web-ui:composer-height`,eh=(0,m.memo)(function({streaming:e,messages:t,slashCommands:n,modelState:r,models:i,modelsLoading:a,attachments:o,onRemoveAttachment:s,onAddImageFiles:c,onAddLocalFiles:l,onAddPathAttachment:u,fileSearch:d,onSearchFiles:f,onNotice:p,onSent:h,onManageModels:g,providerKeys:_,defaultModel:v,quickPhrases:y,quickPhrasesEnabled:b,recallDrafts:x,composerLeading:S,composerActions:C,onUiAction:w,dshPermCurrent:T,dshPermOptions:E,dshPermDefault:D,dshPreset:O,dshPresets:k,dshPresetDefault:A,dshBlank:ee,conversationId:j,sessionDraft:M,sessionId:N}){let P=Z(),F=aa(`ready`),I=oa(),{locale:L}=pn(),{openPicker:R}=cp(),te=e=>L!==`zh`&&e.descriptionEn?e.descriptionEn:e.description??``,z=e=>L!==`zh`&&e.argumentHintEn?e.argumentHintEn:e.argumentHint??``,[B,V]=(0,m.useState)(``),[H,U]=(0,m.useState)(()=>{try{let e=Number(localStorage.getItem($m));if(Number.isFinite(e)&&e>=Xm&&e<=Qm)return e}catch{}return null}),W=(0,m.useRef)(null),[G,re]=(0,m.useState)(null),[ie,ae]=(0,m.useState)(0),oe=(0,m.useRef)(0),se=(0,m.useRef)(0),ce=(0,m.useRef)(new Map),ue=(0,m.useRef)(``),[de,fe]=(0,m.useState)(!1),[pe,me]=(0,m.useState)(void 0),K=(0,m.useRef)(null),ge=(0,m.useRef)(null),_e=(0,m.useRef)(null),ve=(0,m.useRef)(-1),q=(0,m.useRef)(``),ye=(0,m.useRef)(0);(0,m.useEffect)(()=>{if(!x||x.length===0)return;let e=x.filter(e=>e.text&&e.seq>ye.current);e.length!==0&&(ye.current=e[e.length-1].seq,V(t=>e.reduce((e,t)=>em(e,t.text),t)),ve.current=-1,q.current=``,requestAnimationFrame(()=>{let e=K.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)}))},[x]),(0,m.useEffect)(()=>(Rn(e=>{V(t=>em(t,e)),ve.current=-1,q.current=``,requestAnimationFrame(()=>{let e=K.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)})}),()=>Rn(null)),[]),(0,m.useEffect)(()=>(Bn(()=>{Ym||requestAnimationFrame(()=>{K.current?.focus()})}),()=>Bn(null)),[]);let be=(0,m.useRef)(``);be.current=B,(0,m.useEffect)(()=>(Pn(e=>{{let t=e.trim(),n=new Set([`.`,`*`,`+`,`?`,`^`,`$`,`{`,`}`,`(`,`)`,`|`,`[`,`]`,`\\`]),r=t.split(``).map(e=>n.has(e)?`\\`+e:e).join(``),i=RegExp(`(^|[\\s(("'“‘[【])`+r+`(?=[\\s,.;:!?,。!?)\\]】」]|$)`);if(t&&i.test(be.current))return}let t=K.current;if(!t){V(t=>{let n=t+(t&&!t.endsWith(` `)?` `:``)+e;return ue.current=n,n});return}let n=t.selectionStart??be.current.length,r=t.selectionEnd??be.current.length,i=be.current,a=(n>0&&!/[\s([{]$/.test(i.slice(0,n))?` `:``)+e,o=i.slice(0,n)+a+i.slice(r);ue.current=o,V(o);let s=n+a.length;requestAnimationFrame(()=>{t.focus(),t.selectionStart=t.selectionEnd=s})}),()=>Pn(null)),[]),(0,m.useEffect)(()=>(Fn(e=>{V(t=>{let n=new Set([`.`,`*`,`+`,`?`,`^`,`$`,`{`,`}`,`(`,`)`,`|`,`[`,`]`,`\\`]),r=e.split(``).map(e=>n.has(e)?`\\`+e:e).join(``),i=RegExp(`(^|\\s)`+r+`(?:\\s|$)`,`g`),a=t.replace(i,(e,t)=>t===` `?` `:``);return a=a.replace(/ {2,}/g,` `).trim(),ue.current=a,a})}),()=>Fn(null)),[]);let xe=2e4,Se=!I&&N?`${j??``}${N}`:null,Ce=Se&&N?`pi-web-ui:composer-draft:${N}`:null,we=(0,m.useRef)(``),Te=(0,m.useRef)(0),Ee=(0,m.useRef)(!1),Y=(0,m.useRef)(0),De=(0,m.useRef)(null),Oe=(0,m.useRef)(null),ke=(0,m.useRef)(0),Ae=e=>{try{let t=localStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return typeof n.text!=`string`||!n.text||typeof n.ts!=`number`?null:{text:n.text.slice(0,xe),ts:n.ts}}catch{return null}},je=(e,t,n,r)=>{let i=n.slice(0,xe);try{i.trim()?localStorage.setItem(t,JSON.stringify({text:i,ts:r})):localStorage.removeItem(t)}catch{}$({type:`draft_update`,sessionId:e,text:i,ts:r})},Me=()=>{De.current&&=(clearTimeout(De.current),null),Ee.current&&Se&&Ce&&N&&Ye&&je(N,Ce,we.current,Te.current)},Ne=e=>{if(we.current=e,Ee.current=!0,Te.current=Date.now(),Ce){let t=e.slice(0,xe);try{t.trim()?localStorage.setItem(Ce,JSON.stringify({text:t,ts:Te.current})):localStorage.removeItem(Ce)}catch{}}if(Se&&N&&Ye){De.current&&clearTimeout(De.current);let e=N,t=Ce,n=Te.current,r=Se;De.current=setTimeout(()=>{De.current=null,r===Oe.current&&t&&je(e,t,we.current,n)},2e3)}},Pe=(e,t)=>{ve.current=-1,V(e),Le(e,t),Ne(e)};(0,m.useEffect)(()=>{let e=Se,t=N,n=Ce;return()=>{De.current&&=(clearTimeout(De.current),null),Ee.current&&e&&t&&n&&we.current.trim()&&je(t,n,we.current,Te.current)}},[Se]),(0,m.useEffect)(()=>{Oe.current=Se,Ee.current=!1,Y.current=0,we.current=``,Te.current=0,V(``),re(null),ve.current=-1},[Se]);let Fe=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=t.length===0,n=Fe.current!==Se;Fe.current=Se,F&&e&&(!Ym||n)&&requestAnimationFrame(()=>{K.current?.focus()})},[Se,t.length,F]),(0,m.useEffect)(()=>{if(!Se||!Ce||Ee.current||we.current!==``)return;let e=tm(M&&M.text?{text:M.text.slice(0,xe),ts:M.ts}:null,Ae(Ce),Y.current);e&&(Y.current=e.ts,we.current=e.text,Te.current=e.ts,V(e.text),Le(e.text,null))});let Ie={builtin:P(`slashBuiltin`),extension:P(`slashExtension`),prompt:P(`slashPrompt`),skill:P(`slashSkill`),plugin:P(`slashPlugin`)},Le=(e,t)=>{ue.current=e;let r=e.match(/^\/([^\s]*)$/);if(r&&F){let e=Om(n,r[1].toLowerCase());re(e.length>0?{kind:`slash`,items:e}:null),ae(0);return}if(t===null||!F){re(null);return}let i=Im(e,t);if(!i){re(null);return}let a=[];try{a=To()}catch{a=[]}let o=++oe.current,s=e,c=i.start,l=i.query,u=a.map(e=>({id:e.id,label:e.label,run:()=>{let t;try{t=Eo(e.id)?.search}catch{t=void 0}return typeof t==`function`?t(l):Promise.resolve([])}}));l&&typeof f==`function`&&u.push({id:`host:files`,label:P(`openFiles`),run:()=>Re(l)}),Cn();let d=Am(P(`browserControl`),Sn(),l);if(u.push({id:`host:pages`,label:P(`browserControl`),run:()=>Promise.resolve(d)}),u.length===0){re(null);return}let p=Nm(P(`slashSkill`),n,l,15,te),m=Pm({pages:d,skills:p},l,30),h=!1;m.length>0&&(h=!0,re({kind:`at`,start:c,items:m}),ae(0)),Promise.allSettled(u.map(e=>Promise.race([e.run(),new Promise((e,t)=>setTimeout(()=>t(Error(`at-mention timeout`)),2e3))]))).then(e=>{if(oe.current!==o||ue.current!==s)return;let t=[],n=[],r=[];e.forEach((e,i)=>{e.status===`fulfilled`&&(u[i].id===`host:pages`&&Array.isArray(e.value)?t.push(...e.value):u[i].id===`host:files`?n.push(...jm(u[i].label,e.value)):r.push(...Mm(u[i].id,u[i].label,e.value)))});let i=Pm({pages:t,skills:p,files:n,plugins:r},l,30);re(i.length>0?{kind:`at`,start:c,items:i}:null),!h&&i.length>0&&ae(0)})},Re=e=>{if(typeof f!=`function`)return Promise.resolve([]);let t=++se.current;return new Promise(n=>{ce.current.set(t,n);try{f(t,e)}catch{ce.current.delete(t),n([]);return}setTimeout(()=>{ce.current.get(t)===n&&(ce.current.delete(t),n([]))},3e3)})};(0,m.useEffect)(()=>{if(!d||!d.ok)return;let e=ce.current.get(d.reqId);e&&(ce.current.delete(d.reqId),e(d.results??[]))},[d]);let ze=e=>Le(e,null);(0,m.useEffect)(()=>{(_e.current?.querySelector(`.slash-item.active`))?.scrollIntoView({block:`nearest`})},[ie,G]);let Be=e=>{let t=G?.kind===`slash`?G.items:[],n=e??t[ie%Math.max(t.length,1)];if(!n){re(null);return}let r=B.match(/^\/([^\s]*)([\s\S]*)$/),i=r?r[2]:``,a=`/${n.name} ${i}`;ue.current=a,V(a),re(null),K.current?.focus()},Ve=(e,t)=>{let n=G?.kind===`at`?G:null,r=n?.items??[],i=e??r[ie%Math.max(r.length,1)],a=t??n?.start;if(!i||a===void 0){re(null);return}let o=K.current,s=o?o.selectionStart??B.length:B.length,c=i.attachments??[],l=i.text??i.title,d=c.length>0&&!l.startsWith(`@`)?`@${l} `:`${l} `,f=`${B.slice(0,a)}${d}${B.slice(s)}`;ue.current=f,V(f),re(null);for(let e of c)try{u?.({path:e.path,name:e.name??e.path.split(`/`).pop()??e.path,...e.mode?{mode:e.mode}:{mode:`reference`},...typeof e.isDir==`boolean`?{isDir:e.isDir}:{},...e.lines?{lines:e.lines}:{},silent:!0})}catch{}requestAnimationFrame(()=>{let e=K.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=a+d.length)})},He=()=>G?.kind===`slash`?G.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===ie?` active`:``}`,onMouseEnter:()=>ae(t),onClick:()=>We(e),children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Ie[e.source]}),(0,X.jsxs)(`span`,{className:`slash-desc`,children:[te(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:z(e)})]})]},e.name)):null,Ue=()=>G?.kind===`at`?G.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===ie?` active`:``}`,onMouseEnter:()=>ae(t),onClick:()=>We(e),title:e.hint??e.title,children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`@`,e.title]}),(0,X.jsx)(`span`,{className:`slash-source ${e.providerId===`host:skills`?`skill`:`plugin`}`,children:e.providerLabel}),e.hint&&(0,X.jsx)(`span`,{className:`slash-desc`,children:e.hint})]},`${e.providerId}:${e.title}:${t}`)):null,We=e=>{G&&(G.kind===`slash`?Be(e):Ve(e,G.start))},Ge=async()=>{let e=[...t].reverse().find(e=>e.role===`assistant`&&e.content.some(e=>e.type===`text`&&e.text))?.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
357
|
+
`);if(!e){p(`warning`,P(`slashCopyEmpty`));return}try{await navigator.clipboard.writeText(e),p(`info`,P(`slashCopied`))}catch{p(`error`,P(`slashCopyFailed`))}},Ke=e=>{if(!e||e.length===0){p(`warning`,P(`foldersNotSupported`));return}let t=Array.from(e).filter(e=>Ad(e.type)),n=Array.from(e).filter(e=>!Ad(e.type)),r=Je();t.length>0&&r?p(`warning`,r):t.length>0&&c(t),n.length>0&&l(n)},qe=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`&&Ad(e.type)){let t=e.getAsFile();t&&n.push(t)}if(n.length===0)return;e.preventDefault();let r=Je();if(r){p(`warning`,r);return}c(n)},Je=()=>{let e=r?.model;if(!e?.id)return null;let t=i.find(t=>t.id===e.id);return t&&t.vision===!1?P(`modelNoVision`,{name:t.name}):null},Ye=F,Xe=(0,m.useRef)(B);(0,m.useEffect)(()=>{Xe.current=B},[B]),(0,m.useEffect)(()=>{ze(Xe.current)},[n]),(0,m.useEffect)(()=>{let e=e=>{let t=e.detail;V(t),K.current?.focus()};return window.addEventListener(`pi-web:fill`,e),()=>window.removeEventListener(`pi-web:fill`,e)},[]),(0,m.useEffect)(()=>{if(!de)return;let e=e=>{e.key===`Escape`&&fe(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[de]);let Qe=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=K.current,t=Qe.current;if(!e||!t)return;let n=e.closest(`main`)?.querySelector(`.messages`),r=t.getBoundingClientRect().height,i=n?.scrollTop??0;e.style.height=`auto`;let a=H==null?Zm:Qm;e.style.maxHeight=`${a}px`;let o=Math.min(Math.max(e.scrollHeight,H??0),a);e.style.height=`${o}px`,e.style.overflowY=e.scrollHeight>o?`auto`:`hidden`,n&&(n.scrollTop=i+(t.getBoundingClientRect().height-r))},[B,H]);let et=()=>o.map(e=>e.imageData?{path:``,imageData:e.imageData,mimeType:e.mimeType,name:e.name}:e.fileData?{path:``,fileData:e.fileData,mimeType:e.mimeType,name:e.name,size:e.size}:{path:e.path,mode:e.mode,...e.lines?{lines:e.lines}:{},...e.mode===`page`?{name:e.name}:{},...e.mode===`conversation`?{name:e.name,...e.conversationId?{conversationId:e.conversationId}:{},...e.sessionPath?{sessionPath:e.sessionPath}:{}}:{}}),nt=(e=!1)=>{let t=B.trim(),n=o.some(e=>e.imageData||e.fileData||e.mode===`conversation`);if(t||n){if(!Ye){p(`error`,P(`netDisconnected`));return}if(t===`/help`){let e=K.current?.closest(`.inputbox`)?.getBoundingClientRect();me(e?.width),fe(!0),V(``),K.current?.focus();return}if(t===`/copy`){V(``),K.current?.focus(),Ge();return}if($({type:`prompt`,text:t,queue:e,attachments:et()})){if(t&&wm(t),ve.current=-1,q.current=``,V(``),Ce)try{localStorage.removeItem(Ce)}catch{}De.current&&=(clearTimeout(De.current),null),Ee.current=!1,Y.current=Date.now(),we.current=``,Te.current=0,h();let e=r?.model;e&&tp(`${e.provider}/${e.id}`),K.current?.focus()}else p(`error`,P(`netDisconnected`))}},rt=(e,t=!1)=>{let n=e.trim();if(n){if(!Ye){p(`error`,P(`netDisconnected`));return}if($({type:`prompt`,text:n,queue:t,attachments:et()})){n&&wm(n),ve.current=-1,q.current=``,Me(),h();let e=r?.model;e&&tp(`${e.provider}/${e.id}`),Ym||K.current?.focus()}else p(`error`,P(`netDisconnected`))}},it=e=>{if(!(e.nativeEvent.isComposing||e.keyCode===229||Date.now()-ke.current<50)){if(G&&G.items.length>0){let t=G.items.length;switch(e.key){case`ArrowDown`:e.preventDefault(),ae(e=>(e+1)%t);return;case`ArrowUp`:e.preventDefault(),ae(e=>(e-1+t)%t);return;case`Tab`:case`Enter`:e.preventDefault(),We();return;case`Escape`:e.preventDefault(),re(null);return}}if(e.key===`Backspace`&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=K.current;if(t&&t.selectionStart===t.selectionEnd&&t.selectionStart>0){let n=t.selectionStart,r=B.slice(0,n),i=o.find(e=>e.name&&(r.endsWith(`@`+e.name+` `)||r.endsWith(`@`+e.name))),a=-1;if(i&&i.name){let e=`@`+i.name,t=n-(r.endsWith(e+` `)?e.length+1:e.length);a=t>0&&/[\w.\-/]/.test(r[t-1])?-1:t}if(a<0){let e=/(^|[\s(("'"“‘[【])(@[^\s@,.;:!?,。!?)\]】」]+)(\s?)$/.exec(r);e&&(a=n-e[2].length-e[3].length)}if(a>=0&&a<n){e.preventDefault();let t=B.slice(0,a)+B.slice(n);ue.current=t,V(t),requestAnimationFrame(()=>{K.current&&(K.current.selectionStart=K.current.selectionEnd=a)});let r=B.slice(a,n).trim().replace(/^@/,``),c=r.split(`/`).pop()??r,l=i??o.find(e=>e.name===r||e.name===c||e.path===r);l&&s(l.key??(l.mode===`conversation`?`conv|${l.conversationId??``}|${l.sessionPath??``}`:l.path));return}}}if(e.key===`ArrowUp`||e.key===`ArrowDown`){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=K.current;if(!t)return;let n=e.key===`ArrowUp`,r=pm(t);if(n&&!r.first||!n&&!r.last||!n&&ve.current===-1)return;let i=Sm();if(i.length===0)return;if(e.preventDefault(),n){if(ve.current===-1){q.current=B;let e=i.length-1;ve.current=e;let t=i[e];V(t),ze(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else if(ve.current>0){let e=ve.current-1;ve.current=e;let t=i[e];V(t),ze(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}}else{let e=ve.current+1;if(e<i.length){ve.current=e;let t=i[e];V(t),ze(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else{ve.current=-1;let e=q.current;V(e),ze(e),requestAnimationFrame(()=>{let t=K.current;t&&(t.selectionStart=t.selectionEnd=e.length)})}}return}if(e.key===`Escape`&&ve.current!==-1){e.preventDefault();let t=q.current;ve.current=-1,V(t),ze(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)});return}if(e.key===`Enter`){if(Ym&&!e.shiftKey&&!(e.ctrlKey||e.metaKey))return;e.shiftKey||(e.preventDefault(),nt())}}},at=Ye&&(B.trim()!==``||o.some(e=>e.imageData||e.fileData||e.mode===`conversation`)),ot=(0,m.useMemo)(()=>wi((C??[]).filter(e=>e.source!==`host`&&!e.hidden)),[C]),st=(0,m.useMemo)(()=>(S??[]).filter(e=>e.source!==`host`&&!e.hidden),[S]),ct=C!==void 0,lt=(0,m.useMemo)(()=>wi((C??[]).filter(e=>!e.hidden)),[C]),ut=e=>{if(e.kind===`select`&&e.options?.length){let t=e.options.some(t=>t.value===e.value)?e.value:e.options[0].value;return(0,X.jsx)(`select`,{className:`composer-plugin-select`,title:e.hint||e.label,"aria-label":e.label,value:t,onChange:t=>w?.(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id)}let t=e.icon===`mic`?(0,X.jsx)(he,{}):e.icon===`camera`?(0,X.jsx)(Ze,{}):e.icon||e.label;return(0,X.jsx)(`button`,{type:`button`,className:`btn composer-plugin-action`,title:e.hint||e.label,"aria-label":e.label,onClick:()=>w?.(e),children:t},e.id)},dt=()=>(0,X.jsx)(`div`,{className:`inputbox-actions`,children:e?at?(0,X.jsxs)(`div`,{className:`split-send${I?` single`:``}`,children:[(0,X.jsx)(`button`,{type:`button`,className:`split-queue`,title:P(`supplementTip`),"aria-label":P(`queueFollowTag`),onClick:()=>nt(!0),children:(0,X.jsx)(J,{})}),!I&&(0,X.jsx)(`button`,{type:`button`,className:`split-steer`,title:P(`steerTip`),"aria-label":P(`queueSteerTag`),onClick:()=>nt(),children:(0,X.jsx)(tt,{})})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn stop`,title:P(`stopAgent`),onClick:()=>$({type:`abort`}),children:(0,X.jsx)(ne,{})}):(0,X.jsx)(`button`,{type:`button`,className:`btn send`,title:P(`sendTip`),disabled:!at,onClick:()=>nt(),children:(0,X.jsx)(tt,{})})}),ft={"host:composer-upload":(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:P(`uploadFile`),disabled:!Ye,onClick:()=>ge.current?.click(),children:(0,X.jsx)(le,{})}),"host:composer-templates":(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:P(`tpl.openPicker`),onClick:R,children:(0,X.jsx)($e,{})}),"host:composer-model":(0,X.jsx)(Bm,{only:`model`,state:r,models:i,modelsLoading:a,onManageModels:g,providerKeys:_,defaultModel:v,compact:!0}),"host:composer-thinking":(0,X.jsx)(Bm,{only:`thinking`,state:r,models:i,modelsLoading:a,onManageModels:g,providerKeys:_,compact:!0}),"host:composer-dsh-perm":E&&E.length>0&&D!==void 0?(0,X.jsx)(Jm,{compact:!0,current:T??null,options:E,defaultPreset:D,conversationId:j??``}):null,"host:composer-dsh-preset":k&&k.length>0&&A!==void 0?(0,X.jsx)(Um,{compact:!0,preset:O??null,presets:k,defaultPreset:A,blank:ee??!1,conversationId:j??``}):null,"host:composer-send":dt()},pt=e=>e.source===`host`?(0,X.jsx)(m.Fragment,{children:ft[e.id]??null},e.id):ut(e);return(0,X.jsxs)(`div`,{ref:Qe,className:`inputbar`,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),Ke(e.dataTransfer?.files??null)},children:[o.length>0&&(0,X.jsxs)(`div`,{className:`attach-row`,children:[o.map(e=>(0,X.jsxs)(`span`,{className:`attach-chip ${e.imageData?`image`:e.fileData?`file`:e.mode}`,title:e.imageData?P(`attachImage`,{name:e.name}):e.fileData?P(`attachFile`,{name:e.name}):e.isDir?P(`folderRef`,{path:e.path}):e.mode===`page`?P(`attachPage`,{name:e.name}):e.mode===`conversation`?P(`attachConversation`,{name:e.name}):e.mode===`reference`?P(`refOnly`,{path:e.path}):e.mode===`lines`&&e.lines?P(`attachLines`,{path:e.path,start:e.lines.start,end:e.lines.end}):P(`attachContent`,{path:e.path}),children:[e.imageData?`🖼`:e.fileData?`📄`:e.isDir?`📁`:e.mode===`page`?`🌐`:e.mode===`conversation`?`💬`:e.mode===`reference`?`🔗`:`📎`,e.name,e.mode===`lines`&&e.lines&&(0,X.jsxs)(`span`,{className:`attach-range`,children:[`L`,e.lines.start,`-`,e.lines.end]}),(0,X.jsx)(`button`,{type:`button`,className:`attach-remove`,title:P(`removeAttachment`),onClick:()=>s(e.key??(e.mode===`conversation`?`conv|${e.conversationId??``}|${e.sessionPath??``}`:e.path)),children:`×`})]},e.key??(e.mode===`conversation`?`conv|${e.conversationId??``}|${e.sessionPath??``}`:`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`))),(0,X.jsx)(`span`,{className:`attach-hint`,children:P(`attachHint`)})]}),G&&G.items.length>0&&(0,X.jsxs)(`div`,{className:`slash-menu`,role:`listbox`,ref:_e,"aria-label":G.kind===`slash`?P(`slashCommands`):P(`atMentions`),"data-menu-kind":G.kind,children:[(0,X.jsxs)(`div`,{className:`slash-menu-hint`,children:[(0,X.jsx)(`span`,{children:G.kind===`slash`?P(`slashMenuHint`):P(`atMenuHint`)}),(0,X.jsx)(`span`,{className:`slash-menu-close`,onClick:()=>re(null),children:`Esc`})]}),G.kind===`slash`?He():Ue()]}),de&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>fe(!1),children:(0,X.jsxs)(`div`,{className:`slash-help`,style:pe?{width:pe}:void 0,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`slash-help-head`,children:[(0,X.jsxs)(`span`,{children:[`⚡ `,P(`slashHelpTitle`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>fe(!1),children:P(`close`)})]}),(0,X.jsx)(`div`,{className:`slash-help-body`,children:n.length===0?(0,X.jsx)(`div`,{className:`slash-help-empty`,children:P(`slashLoading`)}):n.map(e=>(0,X.jsxs)(`div`,{className:`slash-help-row`,children:[(0,X.jsxs)(`span`,{className:`slash-help-cmd`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Ie[e.source]}),(0,X.jsxs)(`span`,{className:`slash-help-desc`,children:[te(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:z(e)})]})]},e.name))})]})}),b&&y.length>0&&(0,X.jsx)(`div`,{className:`quick-row`,"aria-label":P(`quickPhrases`),children:y.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`quick-chip`,title:`${P(`quickPhrasesTip`,{text:e})}(${P(`quickPhrasesSendTip`)})`,disabled:!Ye,onClick:()=>rt(e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),rt(e,!0)},children:e},e))}),(0,X.jsxs)(`div`,{className:`inputbox`,"data-pi-anchor":`composer`,children:[(0,X.jsx)(`div`,{className:`composer-resize`,title:P(`composerResize`),"aria-label":P(`composerResize`),role:`separator`,"aria-orientation":`horizontal`,"aria-valuenow":Math.round(H??Zm),"aria-valuemin":Xm,"aria-valuemax":Qm,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId);let t=K.current?.getBoundingClientRect().height;W.current={startY:e.clientY,startH:typeof t==`number`&&Number.isFinite(t)?t:H??Zm,next:null}},onPointerMove:e=>{let t=W.current;if(!t)return;let n=Math.min(Qm,Math.max(Xm,t.startH+(t.startY-e.clientY)));t.next=n,U(n)},onPointerUp:()=>{let e=W.current?.next;if(W.current=null,e!=null)try{localStorage.setItem($m,String(Math.round(e)))}catch{}},onPointerCancel:()=>{W.current=null},onDoubleClick:()=>{U(null);try{localStorage.removeItem($m)}catch{}}}),(0,X.jsx)(`input`,{ref:ge,type:`file`,multiple:!0,hidden:!0,onChange:e=>{Ke(e.target.files),e.target.value=``}}),(0,X.jsx)(`textarea`,{ref:K,value:B,rows:1,placeholder:P(Ye?e?I?`placeholderStreamingQueued`:`placeholderStreaming`:`placeholderIdle`:`placeholderConnecting`),disabled:!Ye,onChange:e=>{Pe(e.target.value,e.target.selectionStart??e.target.value.length)},onCompositionEnd:()=>{ke.current=Date.now()},onBlur:Me,onKeyDown:it,onPaste:qe}),(0,X.jsx)(`div`,{className:`composer-tools`,children:ct?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[st.map(ut),lt.start.map(pt)]}),lt.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:lt.center.map(pt)}),(0,X.jsx)(`div`,{className:`composer-tools-right`,children:lt.end.map(pt)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[st.map(ut),(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:P(`uploadFile`),disabled:!Ye,onClick:()=>ge.current?.click(),children:(0,X.jsx)(le,{})}),ot.start.map(ut),(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:P(`tpl.openPicker`),onClick:R,children:(0,X.jsx)($e,{})}),(0,X.jsx)(Bm,{state:r,models:i,modelsLoading:a,onManageModels:g,providerKeys:_,defaultModel:v,compact:!0}),E&&E.length>0&&D!==void 0&&(0,X.jsx)(Jm,{compact:!0,current:T??null,options:E,defaultPreset:D,conversationId:j??``}),k&&k.length>0&&A!==void 0&&(0,X.jsx)(Um,{compact:!0,preset:O??null,presets:k,defaultPreset:A,blank:ee??!1,conversationId:j??``})]}),ot.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:ot.center.map(ut)}),(0,X.jsxs)(`div`,{className:`composer-tools-right`,children:[ot.end.map(ut),dt()]})]})})]})]})}),th=(0,m.memo)(function({goal:e,models:t,modelsLoading:n,activeConversationId:r,uiGoalbarActions:i,onUiAction:a}){let o=Z(),{locale:s}=pn(),c=s!==`zh`&&e.statusEn?e.statusEn:e.status||``,l=s!==`zh`&&e.wizard?.statusEn?e.wizard.statusEn:e.wizard?.status||``,u=oa(),d=!e.conversationId||e.conversationId===r,f=e.goal!==null&&d,[p,h]=(0,m.useState)(``),[g,_]=(0,m.useState)(e.reviewModel??``),[v,y]=(0,m.useState)(e.maxRounds),[b,x]=(0,m.useState)(e.locked),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(!0);(0,m.useEffect)(()=>{_(e.reviewModel??``),y(e.maxRounds||0),x(e.locked)},[e.goal,e.reviewModel,e.maxRounds,e.locked]),(0,m.useEffect)(()=>{S&&t.length===0&&!w&&!n&&(T(!0),$({type:`list_models`}))},[S,t.length,w,n]),(0,m.useEffect)(()=>{t.length>0&&T(!1)},[t.length]);let O=()=>g?t.find(e=>e.id===g)?.name??g:o(`goalBarUseMainModel`),k=()=>{let e=p.trim();e&&($({type:`set_goal`,goal:e,...g?{reviewModel:g}:{},maxRounds:v,locked:b}),h(``),D(!1))},A=()=>{let e=p.trim();e&&($({type:`start_goal_wizard`,text:e,...g?{wizardModel:g}:{},maxRounds:v,locked:b}),h(``),D(!1))},ee=i===void 0?[`host:goal-pill`,`host:goal-set`,`host:goal-wizard`,`host:goal-lock`,`host:goal-collapse`,`host:goal-model`,`host:goal-rounds`,`host:goal-clear`].map(e=>({id:e,source:`host`})):i.filter(e=>!e.hidden),j=e=>{let t=new Set(e);return ee.filter(e=>t.has(e.id)||e.source!==`host`)},M={"host:goal-pill":(0,X.jsxs)(`button`,{type:`button`,className:`goalbar-hint`,title:o(`goalBarPlaceholder`),onClick:()=>D(!1),children:[(0,X.jsx)(B,{}),` `,(0,X.jsx)(`span`,{children:o(`goalBarTitle`)})]}),"host:goal-set":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn`,disabled:!p.trim(),onClick:k,children:o(`goalBarSet`)}),"host:goal-wizard":(0,X.jsxs)(`button`,{type:`button`,className:`goalbar-btn wizard`,disabled:!p.trim(),title:o(`goalWizardTip`),onClick:A,children:[`🔍 `,o(`goalWizardBtn`)]}),"host:goal-lock":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(b?`goalBarLocked`:`goalBarUnlocked`),onClick:()=>x(e=>($({type:`set_goal_prefs`,locked:!e}),!e)),children:b?(0,X.jsx)(q,{}):(0,X.jsx)(L,{})}),"host:goal-collapse":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarClear`),onClick:()=>D(!0),children:(0,X.jsx)(Ke,{})}),"host:goal-model":u?(0,X.jsx)(`p`,{className:`goalbar-dsh-note`,children:o(`dshNoReviewModel`)}):(0,X.jsxs)(xt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,children:[o(`goalBarReviewModel`),`: `,(0,X.jsx)(`b`,{children:O()})]}),open:S,onOpenChange:C,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarReviewModel`)}),(w||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!w&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(St,{active:g===``,onClick:()=>{_(``),C(!1),$({type:`set_goal_prefs`,reviewModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(St,{active:g===e.id,onClick:()=>{_(e.id),C(!1),$({type:`set_goal_prefs`,reviewModel:e.id})},children:(0,X.jsxs)(`span`,{className:`dd-model-cell`,children:[(0,X.jsx)(`span`,{className:`dd-model-name`,children:e.name}),(0,X.jsxs)(`span`,{className:`dd-model-meta`,children:[(0,X.jsx)(`span`,{className:`dd-model-provider`,children:e.provider}),(0,X.jsx)(`span`,{className:`dd-model-id`,children:e.id.split(`/`).slice(1).join(`/`)})]})]})},e.id)),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`list_models`}),children:o(`refreshModels`)})]}),"host:goal-rounds":(0,X.jsxs)(`label`,{className:`goalbar-round`,title:o(`goalBarMaxRoundsTip`),children:[(0,X.jsx)(`span`,{children:o(`goalBarMaxRounds`)}),(0,X.jsx)(`input`,{type:`number`,min:0,step:1,value:v,placeholder:o(`goalBarUnlimitedShort`),onChange:e=>{let t=parseInt(e.target.value,10);if(Number.isNaN(t)||t<0){y(0);return}y(t)},onBlur:()=>$({type:`set_goal_prefs`,maxRounds:v}),onKeyDown:e=>{e.key===`Enter`&&($({type:`set_goal_prefs`,maxRounds:v}),e.target.blur())}})]})},P=(e.wizard?.active??!1)&&d;if(P)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${P?`wizard`:``}`,children:(0,X.jsxs)(`div`,{className:`goalbar-active-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:(0,X.jsx)(`span`,{className:`goalbar-spin`,children:`🔍`})}),(0,X.jsxs)(`span`,{className:`goalbar-text`,title:e.wizard?.draft??``,children:[o(`goalWizardRunning`),`: `,e.wizard?.draft]}),(0,X.jsxs)(`span`,{className:`goalbar-chip reviewing`,children:[o(`goalBarRound`,{n:(e.wizard?.step??0)+1}),` / `,e.wizard?.maxSteps??6]}),(0,X.jsx)(`span`,{className:`goalbar-detail`,children:l||o(`goalBarReviewing`)}),_p(j([`host:goal-clear`]),{...M,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x`,title:o(`goalBarClear`),onClick:()=>{$({type:`clear_goal`}),D(!0)},children:(0,X.jsx)(N,{})})},a)]})});if(f)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${e.reviewing?`reviewing`:``}`,children:(0,X.jsxs)(`div`,{className:`goalbar-active-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:e.reviewing?(0,X.jsx)(`span`,{className:`goalbar-spin`,children:`◌`}):`🎯`}),(0,X.jsx)(`span`,{className:`goalbar-text`,title:e.goal??``,children:e.goal}),e.reviewing?(0,X.jsxs)(`span`,{className:`goalbar-chip reviewing`,children:[o(`goalBarReviewing`),` `,o(`goalBarRound`,{n:e.round})]}):(0,X.jsx)(`span`,{className:`goalbar-chip ${e.verdict===`pass`?`pass`:e.verdict===`fail`?`fail`:e.verdict===`blocked`?`blocked`:``}`,children:e.verdict===`pass`?o(`goalBarPassed`):e.verdict===`fail`?o(`goalBarFailed`):e.verdict===`blocked`?o(`goalBarBlocked`):`${o(`goalBarRound`,{n:e.round||1})} · ${e.locked?o(`goalBarLocked`):o(`goalBarUnlocked`)}`}),(0,X.jsx)(`span`,{className:`goalbar-detail`,children:c}),_p(j([`host:goal-clear`]),{...M,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x`,title:o(`goalBarClear`),disabled:e.reviewing,onClick:()=>{e.goal&&h(e.goal),$({type:`clear_goal`}),D(!1)},children:(0,X.jsx)(N,{})})},a)]})});if(E){let e=_p(j([`host:goal-pill`]),M,a);return e?(0,X.jsx)(`div`,{className:`goalbar goalbar-collapsed`,children:e}):null}return(0,X.jsxs)(`div`,{className:`goalbar`,children:[(0,X.jsxs)(`div`,{className:`goalbar-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:(0,X.jsx)(B,{})}),(0,X.jsx)(`input`,{className:`goalbar-input`,value:p,placeholder:o(`goalBarPlaceholder`),onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k()}}),_p(j([`host:goal-set`,`host:goal-wizard`,`host:goal-lock`,`host:goal-collapse`]),M,a)]}),(0,X.jsxs)(`div`,{className:`goalbar-opts`,children:[j([`host:goal-model`,`host:goal-rounds`]).filter(e=>e.source===`host`).map(e=>(0,X.jsx)(m.Fragment,{children:M[e.id]},e.id)),(0,X.jsx)(`span`,{className:`goalbar-lock-hint`,children:o(b?`goalBarLocked`:`goalBarUnlocked`)})]})]})});function nh(e){let t=Math.max(0,e.input??0),n=Math.max(0,e.cacheRead??0),r=Math.max(0,e.cacheWrite??0),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0,writeRate:i>0?Math.min(r/i,1):0}}var rh=2e3;function ih(e,t,n=rh){return e.filter(e=>t-e.t<=n)}function ah(e,t=rh){if(e.length<2)return 0;let n=e[e.length-1],r=e.find(e=>e.t>=n.t-t)??e[0],i=(n.t-r.t)/1e3;return i<=0?0:Math.max(0,(n.out-r.out)/i)}function oh(e){if(!e)return 0;let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r>=12352&&r<=12543||r>=13312&&r<=19903||r>=19968&&r<=40959||r>=63744&&r<=64255||r>=65280&&r<=65519||r===12288)&&t++}let n=e.length-t;return Math.round(t+n/4)}function sh(e){let t=0;for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text?t+=oh(n.text):n.type===`thinking`&&typeof n.thinking==`string`&&n.thinking&&(t+=oh(n.thinking));return t}var ch=`@root`,lh=[{id:`host:conn`,align:`start`},{id:`host:engine`,align:`start`},{id:`host:ctx`,align:`start`},{id:`host:cost`,align:`start`},{id:`host:cache`,align:`start`},{id:`host:msg-count`,align:`start`},{id:`host:plugin-status`,align:`start`},{id:`host:working`,align:`start`},{id:`host:host-metrics`,align:`end`},{id:`host:cwd`,align:`end`}];function uh({chat:e,bottombarItems:t,onUiAction:n}){let r=Z(),{engine:i}=ia(),a=aa(`workspaceRoots`),o=e.state,[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(``),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(``),[v,y]=(0,m.useState)(-1),b=(0,m.useRef)(null),x=(0,m.useRef)(null),S=e.pathCompletions.filter(e=>e.type===`dir`),C=e=>e.endsWith(`/`)?e:e+`/`,w=e=>{let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;if(t===ch||t===`/`)return null;let n=t.lastIndexOf(`/`);if(n<0)return/^[A-Za-z]:$/.test(t)?ch:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};(0,m.useEffect)(()=>{if(!s)return;let e=setTimeout(()=>{$({type:`complete_path`,path:C(l)})},60);return()=>clearTimeout(e)},[l,s]),(0,m.useEffect)(()=>{if(!s||d===l)return;let e=setTimeout(()=>{$({type:`complete_path`,path:d})},150);return()=>clearTimeout(e)},[d,l,s]);let T=(0,m.useRef)([]),E=o?.isStreaming??!1,D=o?.streamingMessage?sh(o.streamingMessage.content):0;if((0,m.useEffect)(()=>{if(!E){T.current=[];return}let e=Date.now(),t=T.current,n=t[t.length-1];n&&e-n.t<250||(T.current=ih([...t,{t:e,out:D}],e))},[E,D]),!o)return null;let O=o.stats,k=nh(O.tokens),A=k.hitRate*100,ee=k.totalInput===0?``:k.hitRate>=.7?`ok`:k.hitRate>=.4?`mid`:`warn`,j=k.totalInput>0?`${A.toFixed(1)}%`:`—`,M=E?ah(T.current):0,P=e.ready?`ok`:e.status===`closed`?`error`:`busy`,F=e.ready?r(`connected`):e.status===`closed`?r(`reconnecting`):r(`connecting`),I=O.contextUsage,L=I.softCap??null,R=L!==null&&L>0&&L<I.contextWindow,te=R?L:I.contextWindow,z=I.tokens!==null&&te>0?Math.min(100,Math.round(I.tokens/te*100)):null,B=I.tokens!==null&&z!==null?`${dh(I.tokens)} / ${dh(te)}`:`—`,V=z===null?``:z>=80?`warn`:z>=50?`mid`:`ok`,ne=o.queue.steering.length+o.queue.followUp.length,H=()=>{let e=o.cwd.replace(/\\/g,`/`);f(e),u(e),h(!1),_(``),c(!0)},U=e=>{let t=e.trim();t!==ch&&(t&&t!==o.cwd&&$({type:`set_cwd`,path:t}),c(!1))},W=()=>{let e=g.trim();e&&($({type:`make_dir`,path:`${C(l)}${e}`}),setTimeout(()=>{$({type:`complete_path`,path:C(l)})},80),_(``),h(!1))},G=e=>{if(e.key===`Escape`)e.stopPropagation(),c(!1);else if(e.key===`Enter`&&!e.nativeEvent.isComposing)U(d);else if(e.key===`Tab`){if(S.length===0)return;e.preventDefault();let t=v>=0?(v+1)%S.length:0;y(t),f(S[t].path),u(S[t].path)}},re=w(l),ie={"host:conn":(0,X.jsxs)(`span`,{className:`status-item status-conn ${P}`,title:F,children:[(0,X.jsx)(`span`,{className:`status-dot ${P}`}),(0,X.jsx)(`span`,{className:`status-conn-label`,children:F})]}),"host:engine":i===`pi`?null:(0,X.jsx)(`span`,{className:`status-item engine-badge engine-${i}`,title:`${r(`engineBadge`)}: ${i}`,children:i===`dsh`?`DSH`:i}),"host:ctx":(()=>{let e=R?`${r(`contextUsage`)}: ${dh(I.tokens??0)} / ${dh(L)} (${r(`softCapMarker`)}, max ${dh(I.contextWindow)})`:L!==null&&L>0?`${r(`contextUsage`)} · ${r(`softCapMarker`)}: ${dh(L)}`:r(`contextUsage`);return(0,X.jsxs)(`span`,{className:`status-item status-ctx`,title:e,children:[(0,X.jsx)(`span`,{className:`ctx-label`,children:r(`context`)}),(0,X.jsx)(`span`,{className:`ctx-bar ${V}`,children:z!==null&&(0,X.jsx)(`span`,{className:`ctx-bar-fill`,style:{width:`${Math.min(z,100)}%`}})}),B]})})(),"host:cost":(0,X.jsxs)(`span`,{className:`status-item status-cost`,title:r(`cumulativeCost`),children:[`$`,fh(O.cost)]}),"host:cache":(0,X.jsxs)(`span`,{className:`status-item status-cache`,title:r(`cacheHitTip`,{read:dh(k.read),write:dh(k.write),miss:dh(k.miss),input:dh(k.totalInput)}),children:[r(`cacheHit`),(0,X.jsx)(`b`,{className:`cache-pct ${ee}`,children:j})]}),"host:msg-count":(0,X.jsxs)(`span`,{className:`status-item`,title:r(`sessionMessages`),children:[r(`messages`),` `,O.totalMessages]}),"host:plugin-status":e.statuses.length>0?(0,X.jsx)(`span`,{className:`status-item ext-status`,title:r(`pluginStatus`),children:e.statuses.map(e=>e.text).join(` · `)}):null,"host:working":o.isStreaming?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`status-item working`,children:[(0,X.jsx)(`span`,{className:`working-spin`}),r(`working`),ne>0&&(0,X.jsxs)(`span`,{className:`status-queue`,children:[`⏳ `,ne,` `,r(`queued`)]})]}),(0,X.jsxs)(`span`,{className:`status-item status-rate`,title:r(`rateTip`),children:[(0,X.jsx)(`span`,{className:`working-spin rate-spin`}),M>0?`${Math.round(M)}${r(`tps`)}`:`…`]})]}):null,"host:host-metrics":(()=>{let t=e.hostMetrics;if(!t)return null;let n=t.cpuPercent===null||!Number.isFinite(t.cpuPercent)?`—`:`${Math.round(t.cpuPercent)}%`,i=Number.isFinite(t.memoryPercent)?`${Math.round(t.memoryPercent)}%`:`—`;return(0,X.jsxs)(`span`,{className:`status-item status-host-metrics`,title:`${r(`hostResourcesTip`)}\n${r(`hostProcessor`)}: ${n} · ${r(`hostMemory`)}: ${i}`,children:[r(`hostProcessor`),` `,n,` · `,r(`hostMemory`),` `,i]})})(),"host:cwd":s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`status-cwd-backdrop`,onClick:()=>c(!1)}),(0,X.jsxs)(`div`,{className:`cwd-picker`,children:[(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:l===ch?r(`computer`):l,children:[l===ch?`💻`:(0,X.jsx)(Oe,{}),(0,X.jsx)(`span`,{children:l===ch?r(`computer`):l})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:l===ch,title:r(`computer`),onClick:()=>{u(ch),f(ch),y(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!re,title:r(`cwdGoUp`),onClick:()=>{re&&(u(re),f(re),y(-1))},children:[`↑ `,r(`cwdGoUp`)]}),(()=>{let e=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},t=e(l),n=!!l&&l!==ch&&t!==e(o.cwd)&&!a.some(n=>e(n)===t);return(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!n,title:r(`addWorkspaceRootHint`),onClick:()=>{n&&$({type:`set_workspace_roots`,roots:[...a,l]})},children:[`+ `,r(`addWorkspaceRoot`)]})})(),(0,X.jsx)(`button`,{type:`button`,className:`cwd-close`,title:r(`close`),"aria-label":r(`close`),onClick:()=>c(!1),children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:b,className:`status-cwd-input cwd-picker-input`,value:d,placeholder:r(`enterPath`),spellCheck:!1,onChange:e=>{f(e.target.value),y(-1)},onKeyDown:G}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:r(`cwdPickCurrent`),disabled:l===ch,onClick:()=>U(l),children:r(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[S.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:r(`cwdEmpty`)}),S.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${r(`cwdEnter`)} ${e.path}`,onClick:()=>{u(e.path),f(e.path),y(-1)},children:[(0,X.jsx)(Oe,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:r(`cwdChoose`),onClick:()=>U(e.path),children:r(`cwdChoose`)})]},e.path))]}),(0,X.jsx)(`div`,{className:`cwd-picker-foot`,children:p?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:x,value:g,autoFocus:!0,spellCheck:!1,placeholder:r(`cwdNewName`),onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),W()):e.key===`Escape`&&(e.stopPropagation(),h(!1),_(``))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:W,children:r(`cwdCreate`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{h(!1),_(``)},children:r(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>h(!0),children:[`+ `,r(`cwdNewFolder`)]})})]})]}):(0,X.jsxs)(`button`,{type:`button`,className:`status-item status-cwd`,title:r(`cwdTip`,{path:o.cwd}),onClick:H,children:[`📁 `,o.cwd]})},ae=t?t.map(e=>({id:e.id,entry:e,fallbackAlign:`start`})):lh.map(({id:e,align:t})=>({id:e,entry:null,fallbackAlign:t})),oe=[],se=[],ce=[];for(let{id:e,entry:t,fallbackAlign:r}of ae){if(t?.hidden)continue;let i=null;if(e.startsWith(`host:`)?i=ie[e]:t&&(i=t.kind===`select`&&t.options?.length?(0,X.jsx)(`select`,{className:`status-select`,title:t.hint??t.label,"aria-label":t.label,value:t.options.some(e=>e.value===t.value)?t.value:t.options[0].value,onChange:e=>n?.(t,e.target.value),children:t.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:t.hint??t.label,onClick:()=>n?.(t),children:[t.icon?`${t.icon} `:``,t.label,t.badge?(0,X.jsx)(`span`,{className:`status-badge`,children:t.badge}):null]})),!i)continue;let a=t?.align??r;a===`end`?ce.push({key:e,node:i}):a===`center`?se.push({key:e,node:i}):oe.push({key:e,node:i})}let le=e=>e.map((e,t)=>(0,X.jsxs)(m.Fragment,{children:[t>0&&(0,X.jsx)(`span`,{className:`status-sep`,children:`·`}),e.node]},e.key));return(0,X.jsxs)(`footer`,{className:`statusbar`,children:[(0,X.jsx)(`div`,{className:`statusbar-left`,children:le(oe)}),se.length>0&&(0,X.jsx)(`div`,{className:`statusbar-center`,children:le(se)}),(0,X.jsx)(`div`,{className:`statusbar-right`,children:le(ce)})]})}function dh(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(e)}function fh(e){return e<=0?`0`:e<1e-4?`<0.0001`:e.toFixed(4).replace(/\.?0+$/,``)}function ph({dialog:e}){let t=Z(),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(0),o=t=>{$({type:`dialog_response`,id:e.id,value:t})};(0,m.useEffect)(()=>{r(``),a(0)},[e.id]),yt(()=>o(null));let s=Array.isArray(e.args[0])?e.args[0]:[],c=typeof e.args[0]==`string`?e.args[0]:``;return(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":e.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:t(`pluginRequest`)}),e.title&&e.title!==t(`pluginRequest`)&&(0,X.jsx)(`span`,{className:`dialog-title`,children:e.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:t(`cancel`),onClick:()=>o(null),children:`✕`})]}),e.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[s.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`dialog-option ${t===i?`sel`:``}`,onMouseEnter:()=>a(t),onClick:()=>o(e),children:(0,X.jsx)(uu,{text:e,rawHtml:!0})},t)),s.length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:t(`noOptions`)}),(0,X.jsxs)(`div`,{className:`dialog-custom-row`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:n,placeholder:t(`modelQuestionCustom`),onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&n.trim()&&o(n.trim())}}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!n.trim(),onClick:()=>{n.trim()&&o(n.trim())},children:t(`ok`)})]})]}),e.kind===`confirm`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(uu,{text:c,rawHtml:!0}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>o(!1),children:t(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>o(!0),children:t(`ok`)})]})]}),e.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:n,placeholder:c||t(`inputPlaceholder`),autoFocus:!0,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&o(n)}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>o(null),children:t(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>o(n),children:t(`ok`)})]})]})]})}var mh=150;function hh({anchorRef:e,enabled:t=!0,className:n,children:r}){let i=(0,m.useRef)(null),a=(0,m.useRef)(null),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)({left:0,top:0}),u=(0,m.useCallback)(()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},[]),d=(0,m.useCallback)(()=>{u(),a.current=setTimeout(()=>s(!1),mh)},[u]);return(0,m.useEffect)(()=>{let n=e.current;if(!n)return;let r=()=>{u(),s(!0)};n.addEventListener(`mouseenter`,r);let a=e=>{let t=e.relatedTarget;t&&i.current?.contains(t)||d()};return n.addEventListener(`mouseleave`,a),t&&(n.addEventListener(`focus`,r),n.addEventListener(`blur`,d)),()=>{u(),n.removeEventListener(`mouseenter`,r),n.removeEventListener(`mouseleave`,a),n.removeEventListener(`focus`,r),n.removeEventListener(`blur`,d)}},[e,t,u,d]),(0,m.useLayoutEffect)(()=>{if(!o)return;let t=e.current?.getBoundingClientRect();if(!t)return;let n={left:Math.max(8,t.left-8),top:t.bottom+8};l(e=>e.left===n.left&&e.top===n.top?e:n)},[o,e]),(0,m.useLayoutEffect)(()=>{if(!o)return;let t=i.current,n=e.current;if(!t||!n)return;let r=vc(n.getBoundingClientRect(),t.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight});l(e=>e.left===r.left&&e.top===r.top?e:r)},[o,e,r]),(0,m.useEffect)(()=>{if(!o)return;let e=()=>s(!1);return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[o]),o?(0,k.createPortal)((0,X.jsx)(`div`,{ref:i,className:`set-tip-bubble open${n?` ${n}`:``}`,role:`tooltip`,style:{position:`fixed`,left:c.left,top:c.top},onMouseEnter:u,onMouseLeave:d,children:r}),document.body):null}function gh({question:e,owner:t,conversationTitle:n}){let r=Z(),i=e.conversationTitle||n,[a,o]=(0,m.useState)({}),[s,c]=(0,m.useState)({}),[l,u]=(0,m.useState)(0),[d,f]=(0,m.useState)(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1);(0,m.useEffect)(()=>{o({}),c({}),u(0);let n=e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1;f(n),e.deadline&&n<=0&&$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})},[e.id,e.deadline,t]),(0,m.useEffect)(()=>{if(!e.deadline)return;let n=setInterval(()=>{f(n=>{let r=Math.max(0,Math.ceil((e.deadline-Date.now())/1e3));return r<=0&&n>0&&$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}}),r})},1e3);return()=>clearInterval(n)},[e.id,e.deadline]);let p=()=>{$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})};yt(()=>{p()});let h=(e,t)=>{if(!e.dependsOn)return!0;let n=t[e.dependsOn.questionId]??[];if(e.dependsOn.value===void 0)return n.length>0;let r=Array.isArray(e.dependsOn.value)?e.dependsOn.value:[e.dependsOn.value];return n.some(e=>r.includes(e))},g=e.questions.filter(e=>h(e,a)),_=g.length;(0,m.useEffect)(()=>{if(e.questions.length===0||_>0)return;let n=setTimeout(()=>{$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})},1500);return()=>clearTimeout(n)},[e.id,e.questions.length,_,t]);let v=Math.min(l,Math.max(0,_-1)),y=g[v];if(!y)return(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":`select`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:r(`modelQuestion`)}),i&&(0,X.jsx)(`span`,{className:`question-conv-title`,title:i,children:i}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(`cancel`),onClick:p,children:`✕`})]}),(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-hint`,children:r(`questionNoneAvailable`)})})]});let b=(()=>{if(!y)return[];if(y.optionsMap&&y.dependsOn){let e=a[y.dependsOn.questionId]??[];for(let t of e)if(y.optionsMap[t])return y.optionsMap[t]}return y.options??[]})(),x=n=>{let r=e.questions.map(e=>{let t=n[e.id]??[],r=(s[e.id]??``).trim();return{id:e.id,selected:t,...r?{custom:r}:{}}});$({type:`question_answer`,id:e.id,answers:r,...t?{owner:t}:{}})},S=(e,t)=>{o(n=>{let r=n[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},C=(t,n,r)=>{if(r){S(t,n);return}let i={...a,[t]:[n]};o(i);let s=e.questions.filter(e=>h(e,i));v>=s.length-1?x(i):u(v+1)},w=()=>{v>=_-1?x(a):u(v+1)},T=t=>{let n=e.questions.find(e=>e.id===t);return b.length===0&&(n?.options?.length??0)===0||(a[t]?.length??0)>0||(s[t]??``).trim()!==``},E=b.filter(e=>(a[y.id]??[]).includes(e.label)&&e.preview).map(e=>e.preview);return(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":`select`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:r(`modelQuestion`)}),i&&(0,X.jsx)(`span`,{className:`question-conv-title`,title:i,children:i}),_>1&&(0,X.jsx)(`span`,{className:`question-progress`,children:r(`questionStep`,{cur:v+1,total:_})}),d>=0&&(0,X.jsx)(`span`,{className:`question-timer`,children:d>0?r(`questionTimeout`,{s:d}):r(`questionTimeoutExpired`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(`cancel`),onClick:p,children:`✕`})]}),(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,children:y.header??`${r(`modelQuestion`)} ${v+1}`}),(0,X.jsx)(`div`,{className:`question-head`,children:(0,X.jsx)(uu,{text:y.question,rawHtml:!0})}),y.detail&&(0,X.jsx)(`div`,{className:`set-hint`,children:(0,X.jsx)(uu,{text:y.detail,rawHtml:!0})}),b.length>0&&(0,X.jsx)(`div`,{className:`set-list`,children:b.map(e=>{let t=(a[y.id]??[]).includes(e.label);return(0,X.jsx)(_h,{label:e.label,description:e.description,mark:y.multiSelect?t?`☑ `:`☐ `:t?`● `:`○ `,active:t,onPick:()=>C(y.id,e.label,!!y.multiSelect)},e.label)})}),E.length>0&&(0,X.jsxs)(`div`,{className:`question-preview`,children:[(0,X.jsx)(`div`,{className:`question-preview-label`,children:r(`optionPreview`)}),E.map((e,t)=>(0,X.jsx)(`div`,{className:`question-preview-body`,children:(0,X.jsx)(uu,{text:e,rawHtml:!0})},t))]}),(0,X.jsx)(`input`,{className:`set-prompt-input question-custom`,placeholder:r(`modelQuestionCustom`),value:s[y.id]??``,onChange:e=>c(t=>({...t,[y.id]:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T(y.id)&&w())}})]},y.id),(0,X.jsxs)(`div`,{className:`dialog-nav`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss-inline`,onClick:p,children:r(`cancel`)}),(0,X.jsxs)(`div`,{className:`dialog-nav-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-prev`,disabled:v===0,onClick:()=>u(v-1),children:r(`previous`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-submit`,disabled:!T(y.id),onClick:w,children:v===_-1?r(`modelQuestionSubmit`):r(`next`)})]})]})]})}function _h({label:e,description:t,mark:n,active:r,onPick:i}){let a=(0,m.useRef)(null);return(0,X.jsxs)(`button`,{type:`button`,ref:a,className:`set-row question-option${r?` active`:``}`,onClick:i,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[(0,X.jsx)(`span`,{className:`question-mark`,children:n}),(0,X.jsx)(uu,{text:e,rawHtml:!0})]}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`set-row-desc`,children:(0,X.jsx)(uu,{text:t,rawHtml:!0})}),(0,X.jsx)(hh,{anchorRef:a,enabled:yc(),className:`question-desc-tip`,children:(0,X.jsx)(uu,{text:t,rawHtml:!0})})]})]})}var vh=e=>`'${e.replace(/'/g,`'\\''`)}'`,yh=`pi-web-ui:scm-sidebar-width`;function bh(e,t=0){if(!Number.isFinite(e))return 300;let n=Math.max(200,Math.min(720,t>0?t-220:720));return Math.min(n,Math.max(200,Math.round(e)))}function xh(e){return e===null||e.trim()===``?300:bh(Number(e))}function Sh(e,t){let n=t.toLowerCase();return e.subject.toLowerCase().includes(n)||e.author.toLowerCase().includes(n)||e.shortHash.toLowerCase().includes(n)||e.hash.toLowerCase().includes(n)||e.decorations!==void 0&&e.decorations.toLowerCase().includes(n)}function Ch(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>Sh(e,t)))}var wh=`scm-commit-history`;function Th(e=localStorage){try{let t=e.getItem(wh);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Eh(e,t=localStorage){let n=e.trim();if(!n)return Th(t);let r=[n,...Th(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(wh,JSON.stringify(r))}catch{}return r}var Dh={idx:-1,draft:``};function Oh(e,t,n,r){return e.length===0?null:r===`up`?t.idx>=e.length-1?null:t.idx===-1?{state:{idx:0,draft:n},text:e[0]}:{state:{idx:t.idx+1,draft:t.draft},text:e[t.idx+1]}:t.idx===-1?null:t.idx===0?{state:Dh,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}function kh(e){if(e.x===`?`&&e.y===`?`)return`untracked`;let t=e.x!==` `&&e.x!==`?`,n=e.y!==` `&&e.y!==`?`;return t&&n?`both`:t?`staged`:`unstaged`}function Ah({chat:e,terminal:t,active:n,onSwitchToTerminal:r,uiScmToolbar:i,onUiAction:a}){let o=Z(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)([]),[d,f]=(0,m.useState)(``),[p,h]=(0,m.useState)(new Map),[g,_]=(0,m.useState)(`changes`),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[A,ee]=(0,m.useState)(!1),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(!1),[F,I]=(0,m.useState)(null),[L,R]=(0,m.useState)(!1),[te,B]=(0,m.useState)(!1),[V,ne]=(0,m.useState)(null),[H,U]=(0,m.useState)(()=>xh(localStorage.getItem(yh))),[W,G]=(0,m.useState)(``),[re,ie]=(0,m.useState)(``),[ae,se]=(0,m.useState)(()=>Th()),ce=(0,m.useRef)(Dh),le=(0,m.useRef)(0),ue=(0,m.useRef)(-1),de=(0,m.useRef)(-1),fe=(0,m.useRef)(-1),pe=(0,m.useRef)(-1),me=(0,m.useRef)(-1),he=(0,m.useRef)(void 0),K=(0,m.useRef)(null),ge=(0,m.useRef)([]),_e=(0,m.useRef)(H);_e.current=H;let ve=(0,m.useRef)(null),q=(0,m.useCallback)(e=>{try{localStorage.setItem(yh,String(e))}catch{}},[]),ye=(0,m.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=_e.current,r=ve.current?.getBoundingClientRect().width??0,i=n,a=e=>{i=bh(n+(e.clientX-t),r),U(i)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.classList.remove(`panel-resizing`),q(i)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),document.body.classList.add(`panel-resizing`)},[q]),J=(0,m.useCallback)(()=>{U(300),q(300)},[q]),be=(0,m.useCallback)(e=>{if(e.reqId===ue.current){if(ue.current=-1,M(!1),I(null),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}if(e.notRepo){R(!0),c(null),u([]),h(new Map),y([]),x(null),C(``),k(null);return}R(!1);let t={branch:e.branch??``,detached:!!e.detached,upstream:e.upstream??null,ahead:e.ahead??0,behind:e.behind??0,upstreamGone:!!e.upstreamGone,files:(e.files??[]).map(e=>({...e}))},n=(e.branches??[]).map(e=>({...e})),r=new Map;for(let[t,n]of Object.entries(e.stats??{}))r.set(t,{add:n[0],del:n[1]});c(t),u(n),h(r),f(e=>t.detached?e||``:t.branch&&n.some(e=>e.name===t.branch)?t.branch:e&&n.some(t=>t.name===e)?e:n[0]?.name??``),k(e=>e&&!t.files.some(t=>t.path===e.file.path)?null:e)}else if(e.reqId===de.current){if(de.current=-1,ee(!1),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}let t=K.current;if(!t)return;k({file:t,staged:e.stagedText??``,worktree:e.worktreeText??``,untracked:!1})}else if(e.reqId===pe.current){if(pe.current=-1,P(!1),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}y((e.history??[]).map(e=>({...e})))}else if(e.reqId===fe.current){if(fe.current=-1,T(!1),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}C(e.text??``)}else if(e.reqId===me.current){if(me.current=-1,B(!1),!e.ok){ne(e.error??o(`scmGenMsgFail`));return}ne(null),G(e.text??``)}},[]);(0,m.useEffect)(()=>{let t=e.scmData;t&&t.type===`scm_data`&&be(t)},[e.scmData,be]);let xe=(0,m.useCallback)((t,n)=>{if(!e.ready||e.status!==`open`)return!1;let r=++le.current;return $({...t,reqId:r})?(n.current=r,!0):(--le.current,!1)},[e.ready,e.status]),Se=(0,m.useCallback)((t=!1,n=!1)=>{e.ready&&e.status===`open`&&e.state?.cwd&&(he.current!==void 0&&he.current!==e.state.cwd&&(c(null),u([]),h(new Map),y([]),ie(``),P(!1),pe.current=-1,x(null),C(``),k(null),D(null),ne(null),B(!1),me.current=-1),he.current=e.state.cwd,I(null),xe({type:`scm_status`},ue)&&(n||M(!0)))},[e.ready,e.state?.cwd,e.status,xe]),Ce=(0,m.useCallback)(e=>{if(D(e),x(null),K.current=e,e.x===`?`&&e.y===`?`){k({file:e,staged:``,worktree:``,untracked:!0});return}ee(!0),I(null),xe({type:`scm_filediff`,path:e.path},de)||ee(!1)},[xe]),we=(0,m.useCallback)(e=>{x(e),D(null),k(null),C(``),T(!0),I(null),xe({type:`scm_commit`,hash:e.hash},fe)||T(!1)},[xe]),Te=(0,m.useCallback)((n,i)=>{if(!e.ready)return;let a={name:n,command:i,cwd:"${pwd}"},o,s=e.terminals.find(e=>e.title===n);s?(t.restart(s.id),$({type:`run_command`,terminalId:s.id,conversationId:s.conversationId,command:a,cols:80,rows:24}),o=s.id):(o=dt(),t.create({id:o,conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:a})),t.select(o),r()},[e.ready,e.state?.cwd,e.terminals,r,t]),Ee=(0,m.useCallback)(()=>{let e=W.trim();if(!e||L)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);Te(`git commit`,`git commit -m "${t}"`),se(Eh(e)),G(``),ce.current=Dh},[W,L,Te]),Y=(0,m.useCallback)(()=>{let e=W.trim();if(!e||L)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);Te(`git commit`,`git add -A && git commit -m "${t}"`),se(Eh(e)),G(``),ce.current=Dh},[W,L,Te]),Oe=(0,m.useCallback)(e=>{L||Te(`git add`,`git add -- ${vh(e.path)}`)},[L,Te]),ke=(0,m.useCallback)(e=>{L||Te(`git reset`,`git reset HEAD -- ${vh(e.path)}`)},[L,Te]),Ae=(0,m.useCallback)(()=>{if(!d||L)return;let e=l.find(e=>e.name===d);if(e?.remote&&typeof e.remote==`string`){let t=d.slice(e.remote.length+1);Te(`git checkout`,`git checkout -b ${t} ${d} || git checkout ${d}`)}else Te(`git checkout`,`git checkout ${d}`)},[d,l,L,Te]),je=(0,m.useCallback)(()=>Te(`git push`,`git push`),[Te]),Me=(0,m.useCallback)(()=>Te(`git pull`,`git pull`),[Te]),Ne=(0,m.useCallback)(()=>{te||L||!e.ready||e.status!==`open`||(ne(null),xe({type:`scm_commitmsg`},me)?B(!0):ne(o(`scmGenMsgFail`)))},[te,L,e.ready,e.status,xe,o]),Pe=(0,m.useCallback)(()=>{xe({type:`scm_history`},pe)||(pe.current=-1)},[xe]);(0,m.useEffect)(()=>{n&&Se()},[n,Se]),(0,m.useEffect)(()=>{g===`history`&&s&&Pe()},[g,s,Pe]),(0,m.useEffect)(()=>{e.scmDirty>0&&n&&Se(!1,!0)},[e.scmDirty]),(0,m.useEffect)(()=>{if(!n||!e.ready||e.status!==`open`)return;let t=setInterval(()=>{document.visibilityState!==`hidden`&&Se(!1,!0)},3e4);return()=>clearInterval(t)},[n,e.ready,e.status,Se]),(0,m.useEffect)(()=>{let t=ge.current;ge.current=e.terminals,n&&e.terminals.some(e=>e.running===!1&&t.find(t=>t.id===e.id)?.running===!0&&e.title.startsWith(`git `))&&e.ready&&e.status===`open`&&(Se(!1,!0),g===`history`&&s&&Pe())},[e.terminals,n,e.ready,e.status,Se,g,s,Pe]);let Fe={staged:o(`scmStaged`),unstaged:o(`scmUnstaged`),untracked:o(`scmUntracked`),both:o(`scmStagedUnstaged`)},Ie=Ch(v,re),Re=e=>{let t=e.split(`
|
|
358
|
+
`);return(0,X.jsx)(`pre`,{className:`scm-diff-pre`,children:t.map((e,t)=>{let n=``;return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)?n=`hdr`:e.startsWith(`@@`)?n=`hunk`:e.startsWith(`+`)?n=`add`:e.startsWith(`-`)&&(n=`del`),(0,X.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})},ze=i===void 0?[`host:scm-changes`,`host:scm-history`,`host:scm-refresh`,`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`,`host:scm-term`].map(e=>({id:e,source:`host`})):i.filter(e=>!e.hidden),Be=[`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`],Ve=(e,t)=>{let n=new Set(e);return ze.filter(e=>n.has(e.id)||t&&e.source!==`host`)},He=e=>i===void 0||!i.some(t=>t.id===e&&t.hidden),Ue={"host:scm-changes":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`changes`,className:g===`changes`?`active`:``,onClick:()=>{_(`changes`),I(null)},children:o(`scmChanges`)}),"host:scm-history":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`history`,className:g===`history`?`active`:``,onClick:()=>{_(`history`),I(null)},children:o(`scmHistory`)}),"host:scm-refresh":(0,X.jsx)(`button`,{type:`button`,className:`panel-refresh`,title:o(`scmRefreshTip`),disabled:j,onClick:()=>Se(!0),children:(0,X.jsx)(oe,{className:j?`scm-spin`:``})}),"host:scm-branch":(0,X.jsxs)(`select`,{className:`scm-select`,value:d,disabled:L||l.length===0,title:o(`scmSwitchBranch`),onChange:e=>f(e.target.value),children:[(0,X.jsx)(`option`,{value:``,disabled:!0,children:o(`scmSelectBranch`)}),l.filter(e=>!e.remote).map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.current?`* ${e.name}`:e.name},e.name)),l.some(e=>e.remote)&&(0,X.jsx)(`optgroup`,{label:o(`scmRemoteBranches`),children:l.filter(e=>e.remote).map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),"host:scm-switch":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!d||d===s?.branch||L,title:o(`scmSwitchBranchTip`,{branch:d}),onClick:Ae,children:[(0,X.jsx)(De,{}),o(`scmSwitch`)]}),"host:scm-push":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||L,title:o(`scmPushTip`),onClick:je,children:[(0,X.jsx)(tt,{}),o(`scmPush`)]}),"host:scm-pull":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||L,title:o(`scmPullTip`),onClick:Me,children:[(0,X.jsx)(rt,{}),o(`scmPull`)]}),"host:scm-input":(0,X.jsx)(`input`,{className:`scm-commit-input`,value:W,placeholder:o(`scmCommitPlaceholder`),disabled:L,title:ae.length>0?o(`scmCommitHistoryTip`):void 0,onChange:e=>{G(e.target.value),ce.current=Dh},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`){Ee();return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=Oh(ae,ce.current,W,e.key===`ArrowUp`?`up`:`down`);t&&(e.preventDefault(),ce.current=t.state,G(t.text))}}}}),"host:scm-genmsg":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:te||L||!s||s.files.length===0,title:o(`scmGenMsgTip`),onClick:Ne,children:[(0,X.jsx)(Le,{className:te?`scm-spin`:``}),o(te?`scmGenMsgRunning`:`scmGenMsg`)]}),"host:scm-commit":(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!W.trim()||L,title:o(`scmCommitTip`),onClick:Ee,children:[(0,X.jsx)(Ye,{}),o(`scmCommit`)]}),"host:scm-commit-all":(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!W.trim()||L,title:o(`scmCommitAllTip`),onClick:Y,children:o(`scmCommitAll`)})};return(0,X.jsxs)(`div`,{className:`scm-view`,children:[(0,X.jsxs)(`div`,{className:`scm-header`,children:[(0,X.jsxs)(`div`,{className:`scm-title-row`,children:[(0,X.jsxs)(`span`,{className:`scm-title`,children:[(0,X.jsx)(De,{}),o(`scmTitle`)]}),(0,X.jsx)(`div`,{className:`scm-view-tabs`,role:`tablist`,children:_p(Ve([`host:scm-changes`,`host:scm-history`],!1),Ue,a)}),_p(Ve([`host:scm-refresh`],!0),Ue,a)]}),(0,X.jsxs)(`div`,{className:`scm-row`,children:[(0,X.jsxs)(`span`,{className:`scm-branch-current`,title:o(`scmCurrentBranch`),children:[(0,X.jsx)(De,{}),s?s.detached?o(`scmDetached`):s.branch:`…`,s?.upstream&&(0,X.jsx)(`span`,{className:`scm-upstream`,children:s.upstreamGone?o(`scmUpstreamGone`):s.ahead>0||s.behind>0?o(`scmAheadBehind`,{ahead:s.ahead,behind:s.behind}):s.upstream})]}),_p(Ve(Be,!1),Ue,a)]}),V&&(0,X.jsx)(`div`,{className:`scm-gen-error`,role:`alert`,title:o(`close`),onClick:()=>ne(null),children:V})]}),(0,X.jsxs)(`div`,{className:`scm-body`,ref:ve,style:{"--scm-sidebar-w":`${H}px`},children:[g===`history`?(0,X.jsxs)(`div`,{className:`scm-history`,children:[(0,X.jsxs)(`div`,{className:`scm-files-header`,children:[(0,X.jsx)(`span`,{children:o(`scmHistory`)}),v.length>0&&(0,X.jsx)(`span`,{className:`scm-files-count`,children:re.trim()?`${Ie.length}/${v.length}`:v.length})]}),v.length>0&&!L&&(0,X.jsx)(`input`,{className:`scm-history-filter`,value:re,placeholder:o(`scmHistoryFilterPlaceholder`),title:o(`scmHistoryFilterTip`),onChange:e=>ie(e.target.value)}),(0,X.jsx)(`div`,{className:`scm-history-list`,children:L?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):!s||N?(0,X.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?o(`scmLoading`):o(`scmConnecting`)}):v.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoHistory`)}):Ie.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmHistoryFilterEmpty`)}):Ie.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`scm-commit ${b?.hash===e.hash?`active`:``}`,onClick:()=>we(e),title:e.hash,children:[(0,X.jsx)(`span`,{className:`scm-commit-graph`,"aria-hidden":`true`,children:e.graph||`* `}),(0,X.jsxs)(`span`,{className:`scm-commit-info`,children:[(0,X.jsx)(`span`,{className:`scm-commit-subject`,children:e.subject}),(0,X.jsxs)(`span`,{className:`scm-commit-meta`,children:[e.shortHash,` · `,e.author,` · `,e.date]}),e.decorations&&(0,X.jsx)(`span`,{className:`scm-commit-refs`,children:e.decorations})]})]},e.hash))})]}):(0,X.jsxs)(`div`,{className:`scm-files`,children:[(0,X.jsxs)(`div`,{className:`scm-files-header`,children:[(0,X.jsx)(`span`,{children:o(`scmChanges`)}),s&&s.files.length>0&&(0,X.jsx)(`span`,{className:`scm-files-count`,children:s.files.length})]}),(0,X.jsx)(`div`,{className:`scm-files-list`,children:L?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):s?s.files.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoChanges`)}):s.files.map(e=>{let t=kh(e),n=p.get(e.path);return(0,X.jsxs)(`div`,{className:`scm-file ${E?.path===e.path?`active`:``}`,title:Fe[t],onClick:()=>Ce(e),children:[(0,X.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`x`}`,children:e.x===` `?`\xA0`:e.x}),(0,X.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`y`}`,children:e.y===` `?`\xA0`:e.y}),(0,X.jsx)(`span`,{className:`scm-file-path`,children:e.path}),n&&(n.add>0||n.del>0)&&(0,X.jsxs)(`span`,{className:`scm-file-stat`,children:[n.add>0&&(0,X.jsxs)(`span`,{className:`add`,children:[`+`,n.add]}),n.del>0&&(0,X.jsxs)(`span`,{className:`del`,children:[`-`,n.del]})]}),(0,X.jsxs)(`span`,{className:`scm-file-actions`,children:[(e.y!==` `||t===`untracked`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-act`,title:o(`scmStageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),Oe(e)},children:`+`}),t===`staged`||t===`both`?(0,X.jsx)(`button`,{type:`button`,className:`scm-act`,title:o(`scmUnstageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),ke(e)},children:`−`}):null]})]},e.path)}):(0,X.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?o(`scmLoading`):o(`scmConnecting`)})})]}),(0,X.jsx)(`div`,{className:`scm-divider`,role:`separator`,"aria-orientation":`vertical`,title:o(`dragToResize`),onPointerDown:ye,onDoubleClick:J}),(0,X.jsxs)(`div`,{className:`scm-diff`,children:[(0,X.jsxs)(`div`,{className:`scm-diff-header`,children:[(0,X.jsx)(`span`,{children:g===`history`?b?`${b.shortHash} ${b.subject}`:o(`scmCommitDetail`):E?E.path:o(`scmDiff`)}),(g===`history`?w:A)&&(0,X.jsx)(`span`,{className:`scm-diff-loading`,children:o(`scmLoading`)})]}),(0,X.jsx)(`div`,{className:`scm-diff-body`,children:g===`history`?(0,X.jsxs)(X.Fragment,{children:[F&&(0,X.jsx)(`div`,{className:`scm-error`,children:F}),!b&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectCommitHint`)}),b&&w&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),b&&!w&&!F&&S?Re(S):null]}):(0,X.jsxs)(X.Fragment,{children:[F&&(0,X.jsx)(`div`,{className:`scm-error`,children:F}),!E&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectFileHint`)}),E&&!O&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),E&&O&&O.untracked&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmUntrackedNote`)}),E&&O&&!O.untracked&&(0,X.jsxs)(X.Fragment,{children:[O.staged&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmStaged`)}),Re(O.staged)]}),O.worktree&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmUnstaged`)}),Re(O.worktree)]}),!O.staged&&!O.worktree&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoDiff`)})]})]})})]})]}),(0,X.jsxs)(`div`,{className:`scm-hint`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(`span`,{children:o(`scmRunsInTerminal`)}),He(`host:scm-term`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-goto-term`,onClick:r,children:o(`scmViewTerminal`)})]})]})}function jh({entry:e}){let t=(0,m.useRef)(null),n=Z();return(0,m.useEffect)(()=>{let r=t.current;if(!r)return;let i;try{i=e.module.mount(r,hs(e.info.id,e=>$(e)))}catch(t){console.error(`[plugin:${e.info.id}] mount failed:`,t),r.textContent=n(`pluginMountFailed`,{name:e.info.name})}return()=>{if(typeof i==`function`)try{i()}catch(t){console.error(`[plugin:${e.info.id}] cleanup failed:`,t)}r.textContent=``}},[e]),(0,X.jsx)(`div`,{className:`plugin-view`,ref:t})}function Mh({pluginId:e,info:t,epoch:n,failed:r}){let i=Z(),[a,o]=(0,m.useState)(!1),s=t?.name||e;return r?(0,X.jsx)(`div`,{className:`view-pane`,children:(0,X.jsxs)(`div`,{className:`plugin-view-fallback`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`plugin-view-fallback-title`,children:[i(`pluginViewLoadFailed`),`:`,s]}),(0,X.jsx)(`div`,{className:`plugin-view-fallback-hint`,children:i(`pluginViewLoadFailedHint`)}),t&&(0,X.jsx)(`button`,{type:`button`,className:`plugin-view-fallback-retry`,onClick:()=>{t&&!a&&(o(!0),as(t,n).finally(()=>o(!1)))},disabled:a,children:i(a?`pluginViewLoading`:`pluginViewRetry`)})]})}):(0,X.jsx)(`div`,{className:`view-pane`,children:(0,X.jsx)(`div`,{className:`plugin-view-fallback`,role:`status`,children:i(`pluginViewLoading`)})})}function Nh({onAction:e}){let t=Ri(),n=(0,m.useMemo)(()=>t?Gi(t.entries):[],[t]),{items:r,selectParents:i}=(0,m.useMemo)(()=>Wi(n),[n]),a=(0,m.useMemo)(()=>Ki(r),[r]),o=(0,m.useMemo)(()=>t?Vi(t.slot,t.target):void 0,[t,t?.slot,t?.target.kind]),s=(0,m.useRef)(null),c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(-1),[p,h]=(0,m.useState)(-1),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(0),b=(0,m.useRef)(-1),x=e=>{b.current=e,f(e)},S=(0,m.useMemo)(()=>p>=0?Gi(r[p]?.children??[]):[],[r,p]),C=(0,m.useMemo)(()=>Ki(S),[S]),w=e=>{let n=r[e];if(t&&n&&!Ui(n,o)){if(n.children?.length){h(e);return}T(n,t)||Fi()}},T=(t,n,r)=>t.source===`host`&&n.onHostAction?n.onHostAction(t,n.target)===!0:(e(t,n.target,r),!1),E=(0,m.useRef)(w);if((0,m.useLayoutEffect)(()=>{E.current=w}),(0,m.useEffect)(()=>{if(!t){b.current=-1,f(-1),h(-1);return}let e=Ji(r,-1,1,o);b.current=e,f(e),h(-1),s.current?.focus()},[t,r,o]),(0,m.useLayoutEffect)(()=>{if(!t){u(null);return}let e=s.current;if(!e)return;let n=e.getBoundingClientRect();u(Bi(t.x,t.y,n.width,n.height,window.innerWidth,window.innerHeight))},[t,r]),(0,m.useLayoutEffect)(()=>{let e=c.current,t=s.current;if(p<0||!e||!t){_(!1),y(0);return}let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth-r.right,a=r.left;_(i<n.width+8&&a>i);let o=n.bottom-(window.innerHeight-8);y(o>0?-Math.min(o,Math.max(0,n.top-8)):0)},[p,r]),(0,m.useEffect)(()=>{if(!t)return;let e=e=>s.current&&e instanceof Node&&s.current.contains(e),n=t=>{e(t.target)||Fi()},r=t=>{e(t.target)||Fi()},i=()=>Fi();return document.addEventListener(`mousedown`,n,!0),window.addEventListener(`wheel`,r,!0),window.addEventListener(`resize`,i),()=>{document.removeEventListener(`mousedown`,n,!0),window.removeEventListener(`wheel`,r,!0),window.removeEventListener(`resize`,i)}},[t]),(0,m.useEffect)(()=>{if(!t)return;let e=e=>{let t=Ji(r,b.current,e,o);b.current=t,f(t)},n=t=>{switch(t.key){case`Escape`:t.preventDefault(),Fi();return;case`Tab`:Fi();return;case`ArrowDown`:t.preventDefault(),e(1);return;case`ArrowUp`:t.preventDefault(),e(-1);return;case`ArrowRight`:r[b.current]?.children?.length&&(t.preventDefault(),h(b.current));return;case`ArrowLeft`:p>=0&&(t.preventDefault(),h(-1));return;case`Enter`:case` `:t.preventDefault(),E.current(b.current);return;default:return}};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[t,r,p,o]),(0,m.useEffect)(()=>{d<0||s.current?.querySelector(`[data-ctx-active="true"]`)?.scrollIntoView?.({block:`nearest`})},[d]),!t)return null;let D=e=>{let n=i.get(e.id);if(n){if(Ui(n.parent,o))return;t&&!T(n.parent,t,n.value)&&Fi();return}Ui(e,o)||T(e,t)||Fi()},O=(e,t,n)=>{let r=Ui(e,o),i=!!e.children?.length,a=Xi(e.icon),s=n&&d===t;return(0,X.jsxs)(`div`,{className:`ctx-menu-itemwrap`,role:`none`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item${r?` disabled`:``}${s?` active`:``}${i?` has-sub`:``}`,"aria-label":e.label,title:e.hint,"aria-disabled":r||void 0,"aria-haspopup":i?`menu`:void 0,"aria-expanded":i?p===t:void 0,"data-ctx-active":s?`true`:void 0,onMouseEnter:n?()=>{x(t),i&&!r&&h(t)}:void 0,onClick:()=>n?w(t):D(e),children:[a?(0,X.jsx)(`span`,{className:`ctx-menu-icon`,"aria-hidden":`true`,children:a}):null,(0,X.jsx)(`span`,{className:`ctx-menu-label`,children:e.label}),e.badge?(0,X.jsx)(`span`,{className:`ctx-menu-badge`,children:e.badge}):null,i?(0,X.jsx)(`span`,{className:`ctx-menu-caret`,"aria-hidden":`true`,children:`▸`}):null]}),n&&i&&p===t?(0,X.jsx)(`div`,{ref:c,className:`ctx-menu-sub${g?` left`:``}`,role:`menu`,"aria-label":e.label,style:v?{marginTop:v}:void 0,children:C.map(e=>e.kind===`sep`?(0,X.jsx)(`div`,{className:`ctx-menu-sep`,role:`separator`},e.key):O(e.entry,e.index,!1))}):null]},`${e.id}#${t}`)};return(0,k.createPortal)((0,X.jsx)(`div`,{ref:s,className:`ctx-menu`,role:`menu`,"aria-label":t.target.label?`${t.slot}: ${t.target.label}`:t.slot,tabIndex:-1,style:{left:l?.x??t.x,top:l?.y??t.y,visibility:l?`visible`:`hidden`},onContextMenu:e=>{e.preventDefault(),e.stopPropagation()},children:a.map(e=>e.kind===`sep`?(0,X.jsx)(`div`,{className:`ctx-menu-sep`,role:`separator`},e.key):O(e.entry,e.index,!0))}),document.body)}var Ph=0,Fh=[],Ih=new Map,Lh=new Set;function Rh(){for(let e of Lh)try{e()}catch{}}function zh(e){let t=Ih.get(e);t!==void 0&&(clearTimeout(t),Ih.delete(e))}function Bh(e){let t=e.id||`banner-${Date.now()}-${++Ph}`,n={...e,id:t,type:e.type||`info`,persistent:!!e.persistent,timeoutMs:e.timeoutMs??5e3,dismissible:e.dismissible!==!1};if(zh(t),!n.persistent&&n.timeoutMs&&n.timeoutMs>0){let e=setTimeout(()=>{Vh(t)},n.timeoutMs);Ih.set(t,e)}let r=Fh.findIndex(e=>e.id===t);if(r>=0){let e=[...Fh];e[r]=n,Fh=e}else Fh=[...Fh,n];return Rh(),t}function Vh(e){zh(e);let t=Fh.find(t=>t.id===e);if(t){Fh=Fh.filter(t=>t.id!==e);try{t.onClose?.()}catch{}Rh()}}function Hh(e){let t=Fh.filter(e);if(t.length!==0){for(let e of t){zh(e.id);try{e.onClose?.()}catch{}}Fh=Fh.filter(t=>!e(t)),Rh()}}function Uh(){return Fh}function Wh(e){return Lh.add(e),()=>{Lh.delete(e)}}function Gh(){return(0,m.useSyncExternalStore)(Wh,Uh,Uh)}function Kh({type:e}){switch(e){case`question`:return(0,X.jsx)(Te,{className:`banner-icon banner-icon-question`});case`warning`:return(0,X.jsx)(at,{className:`banner-icon banner-icon-warning`});case`error`:return(0,X.jsx)(ot,{className:`banner-icon banner-icon-error`});case`success`:return(0,X.jsx)(Xe,{className:`banner-icon banner-icon-success`});default:return(0,X.jsx)(Ce,{className:`banner-icon banner-icon-info`})}}var qh=(0,m.memo)(function({banner:e}){let t=typeof e.onClick==`function`;return(0,X.jsxs)(`div`,{className:`banner-card banner-type-${e.type||`info`} ${t?`banner-clickable`:``}`,onClick:t?e.onClick:void 0,role:t?`button`:`status`,tabIndex:t?0:void 0,onKeyDown:t?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onClick?.())}:void 0,children:[(0,X.jsx)(`div`,{className:`banner-icon-col`,children:(0,X.jsx)(Kh,{type:e.type})}),(0,X.jsxs)(`div`,{className:`banner-content-col`,children:[e.title&&(0,X.jsx)(`div`,{className:`banner-title`,title:e.title,children:e.title}),(0,X.jsx)(`div`,{className:`banner-message`,title:e.message,children:e.message})]}),e.dismissible&&(0,X.jsx)(`button`,{type:`button`,className:`banner-close`,onClick:t=>{t.stopPropagation(),Vh(e.id)},"aria-label":`Close banner`,title:`关闭通知`,children:(0,X.jsx)(N,{})})]})}),Jh=(0,m.memo)(function(){let e=Gh();return e.length===0?null:(0,X.jsx)(`aside`,{className:`banner-container`,"aria-label":`Notifications`,children:e.map(e=>(0,X.jsx)(qh,{banner:e},e.id))})});function Yh(e,t){let n=(0,m.useRef)(``);(0,m.useEffect)(()=>{let r=rm(n.current,e);n.current=r.key,r.clear&&t()},[e,t])}var Xh=new Map,Zh=-1;function Qh(e){let t=e.trim().toLowerCase();return t.startsWith(`.`)?t:`.${t}`}function $h(e){let t=e.replace(/\\/g,`/`).split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n).toLowerCase():``}function eg(e,t){Zh!==t&&(Zh=t);let n=new Map;for(let t of e){let e=t;if(!e.error&&e.hasClient&&Array.isArray(e.fileHandlers)){for(let t of e.fileHandlers)if(t&&t.id&&Array.isArray(t.extensions))for(let r of t.extensions){if(typeof r!=`string`)continue;let i=Qh(r);if(!/^\.[a-z0-9][a-z0-9._-]*$/.test(i))continue;let a=n.get(i)??[];a.push({plugin:e,declaration:t}),n.set(i,a)}}}for(let e of n.values())e.sort((e,t)=>t.declaration.priority-e.declaration.priority||e.plugin.id.localeCompare(t.plugin.id));Xh=n}function tg(e){return Xh.get($h(e))?.[0]??null}async function ng(e){let t=await ds(e.plugin,Zh);if(!t)return null;let n=t.fileHandlers,r;if(Array.isArray(n))r=n.find(t=>t&&t.id===e.declaration.id),!r&&n.length===1&&typeof n[0]?.mount==`function`&&(r=n[0]);else if(n&&typeof n==`object`){r=n[e.declaration.id];let t=Object.values(n);!r&&t.length===1&&typeof t[0]?.mount==`function`&&(r=t[0])}return!r||typeof r.mount!=`function`?null:{handler:r,pluginId:e.plugin.id}}function rg({provider:e,flow:t,result:n}){let r=Z(),i=t?.event,a=e.oauthName??e.name,[o,s]=(0,m.useState)(``);return(0,m.useEffect)(()=>s(``),[t?.promptId]),e.usingOAuth?(0,X.jsxs)(`div`,{className:`provider-oauth`,children:[(0,X.jsx)(`span`,{className:`provider-oauth-status`,children:r(`oauthConnected`,{name:a})}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-provider-oauth-logout":e.id,onClick:()=>$({type:`provider_oauth_logout`,provider:e.id}),children:r(`oauthLogout`)}),n?.error&&(0,X.jsx)(`div`,{className:`provider-oauth-error`,children:n.error})]}):(0,X.jsxs)(`div`,{className:`provider-oauth`,children:[t?(0,X.jsxs)(X.Fragment,{children:[i?.type===`device_code`&&(0,X.jsxs)(`div`,{className:`provider-oauth-device`,children:[(0,X.jsx)(`div`,{children:r(`oauthDeviceCode`)}),(0,X.jsx)(`code`,{"data-oauth-device-code":!0,children:i.userCode}),(0,X.jsx)(`a`,{"data-oauth-verification-url":!0,href:i.verificationUri,target:`_blank`,rel:`noreferrer`,children:r(`oauthOpenVerification`)})]}),i?.type===`auth_url`&&(0,X.jsxs)(`div`,{className:`provider-oauth-event`,children:[i.instructions&&(0,X.jsx)(`div`,{children:i.instructions}),(0,X.jsx)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,children:r(`oauthOpenVerification`)})]}),i?.type===`progress`&&(0,X.jsx)(`div`,{className:`provider-oauth-message`,children:i.message}),i?.type===`info`&&(0,X.jsxs)(`div`,{className:`provider-oauth-event`,children:[(0,X.jsx)(`div`,{children:i.message}),i.links?.map(e=>(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.label??e.url},e.url))]}),t.prompt&&(0,X.jsx)(`div`,{className:`provider-oauth-message`,children:t.prompt.message}),t.prompt?.type===`select`&&t.promptId&&(0,X.jsx)(`div`,{className:`provider-oauth-options`,children:t.prompt.options.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,"data-oauth-option":e.id,onClick:()=>$({type:`provider_oauth_reply`,flowId:t.flowId,promptId:t.promptId,value:e.id}),children:e.label},e.id))}),t.prompt&&t.prompt.type!==`select`&&t.promptId&&(0,X.jsxs)(`form`,{className:`provider-oauth-prompt`,onSubmit:e=>{e.preventDefault(),o.trim()&&$({type:`provider_oauth_reply`,flowId:t.flowId,promptId:t.promptId,value:o.trim()})},children:[(0,X.jsx)(`input`,{"data-oauth-prompt-input":!0,type:t.prompt.type===`secret`?`password`:`text`,className:`key-input`,placeholder:t.prompt.placeholder,value:o,onChange:e=>s(e.target.value)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary sm`,"data-oauth-prompt-submit":!0,disabled:!o.trim(),children:r(`oauthContinue`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-oauth-cancel":t.flowId,onClick:()=>$({type:`provider_oauth_cancel`,flowId:t.flowId}),children:r(`cancel`)})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn primary sm`,"data-provider-oauth-login":e.id,onClick:()=>$({type:`provider_oauth_start`,provider:e.id}),children:r(`oauthLogin`,{name:a})}),n?.error&&(0,X.jsx)(`div`,{className:`provider-oauth-error`,children:n.error})]})}function ig({piConfigured:e,piAgentInstalled:t,providers:n,providerOAuthFlows:r,providerOAuthResults:i,installResult:a,onClose:o}){let s=Z(),c=sa(),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(``),[p,h]=(0,m.useState)(``),[g,_]=(0,m.useState)(!1);(0,m.useEffect)(()=>{$({type:`list_providers`}),$({type:`list_provider_oauth_flows`})},[]),(0,m.useEffect)(()=>{e&&o()},[e,o]),(0,m.useEffect)(()=>{a&&u(!1)},[a]),(0,m.useEffect)(()=>{!d&&n.length>0&&f(n.find(e=>!e.configured)?.id??n[0].id)},[n,d]);let v=()=>{l||(u(!0),$({type:`install_pi_agent`}))},y=()=>{p.trim()&&!g&&(_(!0),$({type:`set_provider_api_key`,provider:d.trim(),apiKey:p.trim()}),setTimeout(()=>_(!1),3e3))},b=()=>{$({type:`get_state`}),$({type:`list_providers`})},x=n.find(e=>e.id===d),S=a!==null&&!a.ok;return(0,X.jsx)(`div`,{className:`modal-backdrop`,children:(0,X.jsxs)(`div`,{className:`modal setup-modal`,children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":s(`close`),onClick:o,children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Le,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:s(`setupTitle`)})]}),(0,X.jsx)(`p`,{className:`modal-desc`,children:s(`setupDesc`)}),S?(0,X.jsxs)(`div`,{className:`setup-failed`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:s(`installFailed`)}),(0,X.jsx)(`pre`,{className:`setup-detail`,children:a.detail}),(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:l,onClick:v,children:s(`retryInstall`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]})]}):t||a?.ok?(0,X.jsxs)(`div`,{className:`setup-key-form`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:a?.ok?s(`installDone`):s(`cliReadyHint`)}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:s(`provider`)}),(0,X.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),children:[n.length===0&&(0,X.jsx)(`option`,{value:``,children:s(`loading`)}),n.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name,`(`,e.id,`)`,e.configured?` · ${s(`configured`)}`:``]},e.id))]}),x?.configured&&(0,X.jsx)(`div`,{className:`field-hint`,children:s(`providerKeyReady`)})]}),x?.supportsOAuth&&(0,X.jsx)(rg,{provider:x,flow:r.find(e=>e.provider===x.id),result:i[x.id]}),x?.supportsApiKey&&(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:s(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:p,onChange:e=>h(e.target.value),placeholder:`sk-…`})]}),(0,X.jsxs)(`div`,{className:`setup-actions`,children:[x?.supportsApiKey&&(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!p.trim()||g||!d,onClick:y,children:s(g?`saving`:`saveAndStart`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:b,children:[(0,X.jsx)(oe,{}),` `,s(`recheck`)]})]})]}):c?(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:s(`updatesManaged`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]}):(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:l,onClick:v,children:s(l?`installing`:`autoInstall`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]})]})})}var ag=[`openai-completions`,`openai-responses`,`anthropic-messages`,`google-generative-ai`],og=[{id:`deepseek`,name:`DeepSeek`,api:`openai-completions`,baseUrl:`https://api.deepseek.com/v1`,authHeader:!0,tag:`官方`},{id:`openrouter`,name:`OpenRouter`,api:`openai-completions`,baseUrl:`https://openrouter.ai/api/v1`,authHeader:!0,tag:`聚合`},{id:`moonshot`,name:`Moonshot (Kimi)`,api:`openai-completions`,baseUrl:`https://api.moonshot.cn/v1`,authHeader:!0,tag:`官方`},{id:`zhipu`,name:`智谱 GLM`,api:`openai-completions`,baseUrl:`https://open.bigmodel.cn/api/paas/v4`,authHeader:!0,tag:`官方`},{id:`siliconflow`,name:`硅基流动`,api:`openai-completions`,baseUrl:`https://api.siliconflow.cn/v1`,authHeader:!0,tag:`云端`},{id:`ollama`,name:`Ollama`,api:`openai-completions`,baseUrl:`http://127.0.0.1:11434/v1`,authHeader:!0,tag:`本地`},{id:`vllm`,name:`vLLM / LM Studio`,api:`openai-completions`,baseUrl:`http://127.0.0.1:8000/v1`,authHeader:!0,tag:`本地`},{id:`antigravity`,name:`Antigravity (OpenAI)`,api:`openai-completions`,baseUrl:`http://127.0.0.1:8045/v1`,authHeader:!0,tag:`反代`},{id:`antigravity-anthropic`,name:`Antigravity (Anthropic)`,api:`anthropic-messages`,baseUrl:`http://127.0.0.1:8045`,authHeader:!0,tag:`反代`}],sg=[{label:`8K`,value:`8192`},{label:`16K`,value:`16384`},{label:`32K`,value:`32768`},{label:`64K`,value:`65536`},{label:`128K`,value:`131072`},{label:`200K`,value:`200000`},{label:`1M`,value:`1000000`}],cg=[{label:`2K`,value:`2048`},{label:`4K`,value:`4096`},{label:`8K`,value:`8192`},{label:`16K`,value:`16384`},{label:`32K`,value:`32768`},{label:`64K`,value:`65536`}],lg=()=>({id:``,name:``,reasoning:!1,input:`text`,contextWindow:``,maxTokens:``}),ug=()=>({providerId:``,name:``,api:`openai-completions`,baseUrl:``,apiKey:``,hasApiKey:!1,authHeader:!0,models:[lg()]});function dg(e){return{providerId:e.providerId,name:e.name??``,api:e.api??`openai-completions`,baseUrl:e.baseUrl??``,apiKey:``,hasApiKey:e.hasApiKey??!1,authHeader:e.authHeader??!1,models:(e.models.length?e.models:[lg()]).map(e=>({id:e.id,name:e.name??``,reasoning:e.reasoning??!1,input:e.input?.includes(`image`)?`text-image`:`text`,contextWindow:e.contextWindow?String(e.contextWindow):``,maxTokens:e.maxTokens?String(e.maxTokens):``}))}}function fg(e){let t={};for(let n of e.split(`
|
|
359
|
+
`)){let e=n.indexOf(`=`);if(e<=0)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}return t}function pg({candidates:e,onAdopt:t,onClose:n}){let r=Z(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(()=>{let t=new Set;for(let n of e){let e=n.id.toLowerCase();!e.includes(`embed`)&&!e.includes(`audio`)&&!e.includes(`tts`)&&!e.includes(`whisper`)&&t.add(n.id)}if(t.size===0)for(let n of e)t.add(n.id);return t}),c=(0,m.useMemo)(()=>{let t=i.trim().toLowerCase();return t?e.filter(e=>e.id.toLowerCase().includes(t)||e.name&&e.name.toLowerCase().includes(t)):e},[e,i]),l=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,X.jsx)(`div`,{className:`candidate-picker-backdrop`,onClick:n,children:(0,X.jsxs)(`div`,{className:`candidate-picker-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`candidate-header`,children:[(0,X.jsxs)(`div`,{className:`candidate-title-group`,children:[(0,X.jsx)(`span`,{className:`candidate-title`,children:`候选模型采纳器 (Candidate Picker)`}),(0,X.jsxs)(`span`,{className:`candidate-subtitle`,children:[`已探测到 `,e.length,` 个模型,请勾选需要采纳的模型`]})]}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,onClick:n,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`candidate-filter-bar`,children:[(0,X.jsx)(re,{style:{color:`var(--text-faint)`,flexShrink:0}}),(0,X.jsx)(`input`,{type:`text`,className:`candidate-search-input`,placeholder:`搜索模型 ID 或名称…`,value:i,onChange:e=>a(e.target.value),autoFocus:!0}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:6,flexShrink:0},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{s(new Set(c.map(e=>e.id)))},children:`全选`}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{s(new Set)},children:`全不选`})]})]}),(0,X.jsxs)(`div`,{className:`candidate-list-scroll`,children:[c.length===0&&(0,X.jsx)(`div`,{style:{padding:`32px 0`,textAlign:`center`,color:`var(--text-faint)`,fontSize:13},children:`未匹配到模型`}),c.map(e=>{let t=o.has(e.id);return(0,X.jsxs)(`div`,{className:`candidate-item-card ${t?`selected`:``}`,onClick:()=>l(e.id),children:[(0,X.jsxs)(`div`,{className:`candidate-item-left`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`candidate-checkbox`,checked:t,onChange:()=>{},onClick:e=>e.stopPropagation()}),(0,X.jsxs)(`div`,{className:`candidate-id-info`,children:[(0,X.jsx)(`span`,{className:`candidate-id-name`,children:e.id}),e.name&&e.name!==e.id&&(0,X.jsx)(`span`,{style:{fontSize:11.5,color:`var(--text-dim)`},children:e.name})]})]}),(0,X.jsxs)(`div`,{className:`candidate-item-meta`,children:[e.contextWindow&&(0,X.jsx)(`span`,{className:`spec-badge ctx`,title:`上下文窗口`,children:e.contextWindow>=1e6?`${Math.round(e.contextWindow/1e6)}M`:`${Math.round(e.contextWindow/1024)}K`}),e.reasoning&&(0,X.jsxs)(`span`,{className:`spec-badge reasoning`,title:`支持深度思考 / 推理`,children:[(0,X.jsx)(M,{}),` 推理`]}),e.input?.includes(`image`)&&(0,X.jsx)(`span`,{className:`spec-badge vision`,title:`支持图像视觉`,children:`视觉`})]})]},e.id)})]}),(0,X.jsxs)(`div`,{className:`candidate-actions-footer`,children:[(0,X.jsxs)(`span`,{className:`candidate-select-summary`,children:[`已勾选 `,o.size,` / `,e.length,` 个模型`]}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:n,children:r(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:o.size===0,onClick:()=>{t(e.filter(e=>o.has(e.id)))},children:[`采纳所选模型 (`,o.size,`)`]})]})]})]})})}function mg({providers:e,providerStatus:t,providerKeys:n,providerOAuthFlows:r,providerOAuthResults:i,fetchModelsResult:a,testModelConnectionResult:o,enrichModelsResult:s,enrichModelsProgress:c,cloneProviderResult:l,refreshBuiltinResult:u,appendBuiltinResult:d,defaultModel:f,onClose:p}){let h=Z(),[g,_]=(0,m.useState)(()=>e.length>0?{type:`custom`,id:e[0].providerId}:t.length>0?{type:`builtin`,id:t[0].id}:{type:`custom`,id:``}),[v,y]=(0,m.useState)(()=>e.length>0?dg(e[0]):t.length>0?null:ug()),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(0),[E,D]=(0,m.useState)(null),O=(0,m.useRef)(0),[k,A]=(0,m.useState)({}),[ee,j]=(0,m.useState)({}),[M,P]=(0,m.useState)(null),F=(0,m.useRef)(n),I=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=M;e&&n[e]!==F.current[e]&&(P(null),A(t=>({...t,[e]:``})),j(t=>({...t,[e]:``})),I.current&&clearTimeout(I.current)),F.current=n},[n,M]),(0,m.useEffect)(()=>()=>{I.current&&clearTimeout(I.current)},[]);let[L,te]=(0,m.useState)(!1),[z,B]=(0,m.useState)(0),[V,ne]=(0,m.useState)(null),H=(0,m.useRef)(0),[U,W]=(0,m.useState)(!1),[G,re]=(0,m.useState)(!1),[ie,ae]=(0,m.useState)(0),[ce,le]=(0,m.useState)(null),[ue,de]=(0,m.useState)([]),[fe]=(0,m.useState)(``),pe=(0,m.useRef)(0),[me,he]=(0,m.useState)(!1),[K,ge]=(0,m.useState)(0),[_e,ve]=(0,m.useState)(null),q=(0,m.useRef)(0),[ye,J]=(0,m.useState)(null),[be,xe]=(0,m.useState)(``),[Se,Ce]=(0,m.useState)(``),[we,Te]=(0,m.useState)(``),[Ee,Y]=(0,m.useState)(``),[De,Oe]=(0,m.useState)(!1),[ke,Ae]=(0,m.useState)(0),[je,Me]=(0,m.useState)(null),Ne=(0,m.useRef)(0),[Pe,Fe]=(0,m.useState)(null),[Re,ze]=(0,m.useState)(``),[Be,Ve]=(0,m.useState)(null);(0,m.useEffect)(()=>{$({type:`list_models_config`}),$({type:`list_providers`}),$({type:`list_provider_keys`}),$({type:`list_provider_oauth_flows`})},[]),(0,m.useEffect)(()=>{o&&o.reqId!==O.current&&(O.current=o.reqId,C(!1),D({ok:o.ok,latencyMs:o.latencyMs,error:o.error}))},[o]),(0,m.useEffect)(()=>{a&&a.reqId!==H.current&&(H.current=a.reqId,te(!1),a.ok&&a.models?.length?(x(a.models),ne({ok:!0,text:h(`fetchModelsOk`,{n:a.models.length})})):ne({ok:!1,text:a.error||h(`fetchModelsEmpty`)}))},[a,h]),(0,m.useEffect)(()=>{if(s&&s.reqId!==pe.current){if(pe.current=s.reqId,W(!1),re(!1),s.ok&&s.results?.length){let e=s.results,t=new Map(e.map(e=>[e.id.trim(),e]));y(e=>e&&{...e,models:e.models.map(e=>{let n=t.get(e.id.trim());return!n||n.status!==`matched`?e:{...e,name:e.name||n.name||``,contextWindow:e.contextWindow||(n.contextWindow?String(n.contextWindow):``),maxTokens:e.maxTokens||(n.maxTokens?String(n.maxTokens):``),input:e.input===`text`&&n.input?.includes(`image`)?`text-image`:e.input,reasoning:e.reasoning||(n.reasoning??!1),src:n.source}})});let n=e.filter(e=>e.status===`matched`).length,r=e.length-n;le({ok:!0,text:h(`enrichModelsOk`,{n,m:r})});let i=e.filter(e=>e.status!==`matched`&&(e.suggestions?.length||e.note)).map(e=>({id:e.id,suggestions:e.suggestions??[],note:e.note}));de(i)}else le({ok:!1,text:s.error||h(`enrichModelsErr`,{msg:``})})}},[s,h]),(0,m.useEffect)(()=>{u&&u.reqId!==q.current&&(q.current=u.reqId,he(!1),u.ok?ve({ok:!0,text:h(`refreshBuiltinOk`)}):ve({ok:!1,text:u.error||h(`refreshBuiltinFail`)}))},[u,h]),(0,m.useEffect)(()=>{d&&d.reqId!==Ne.current&&(Ne.current=d.reqId,Oe(!1),d.ok?(Me({ok:!0,text:h(`appendModelOk`)}),xe(``),Ce(``),Te(``),Y(``),J(null),$({type:`list_models_config`})):Me({ok:!1,text:d.error||h(`appendModelFail`)}))},[d,h]),(0,m.useEffect)(()=>{if(l&&l.ok){let e=l.configs;if(e&&e.length>1){Fe(e.map(e=>dg(e))),ze(``);return}l.config&&Ve(dg(l.config))}},[l]);let He=()=>{if(!v)return;let e=v.baseUrl.trim();if(!e){D({ok:!1,error:h(`fetchModelsNeedBaseUrl`)});return}C(!0),D(null);let t=w+1;T(t),$({type:`test_model_connection`,reqId:t,baseUrl:e,apiKey:v.apiKey.trim()||void 0,...v.apiKey.trim()?{}:v.hasApiKey?{providerId:v.providerId.trim()}:{},authHeader:v.authHeader,api:v.api})},Ue=()=>{if(!v)return;let e=v.baseUrl.trim();if(!e){ne({ok:!1,text:h(`fetchModelsNeedBaseUrl`)});return}if(L)return;te(!0),ne(null);let t=z+1;B(t),$({type:`fetch_models`,reqId:t,baseUrl:e,apiKey:v.apiKey.trim()||void 0,...v.apiKey.trim()?{}:v.hasApiKey?{providerId:v.providerId.trim()}:{},authHeader:v.authHeader,api:v.api})},We=e=>{v&&(y(t=>{if(!t)return t;let n=t.models.filter(e=>e.id.trim()),r=new Set(n.map(e=>e.id.trim())),i=e.filter(e=>!r.has(e.id)).map(e=>({id:e.id,name:e.name??``,reasoning:e.reasoning??!1,input:e.input?.includes(`image`)?`text-image`:`text`,contextWindow:e.contextWindow?String(e.contextWindow):``,maxTokens:e.maxTokens?String(e.maxTokens):``}));return{...t,models:n.length===0?i:[...n,...i]}}),x(null))},Ge=()=>{if(!v||U)return;let e=v.models.map(e=>e.id.trim()).filter(Boolean);if(e.length===0){le({ok:!1,text:h(`enrichModelsNeedIds`)});return}W(!0),re(!1),le(null),de([]);let t=ie+1;ae(t),$({type:`enrich_models`,reqId:t,ids:e,hints:fg(fe)})},Ke=()=>{U&&!G&&(re(!0),$({type:`abort_enrich_models`,reqId:ie}))},qe=e=>{y(t=>({providerId:t?.providerId.trim()||e.id,name:t?.name.trim()||e.name,api:e.api,baseUrl:e.baseUrl,apiKey:t?.apiKey||``,hasApiKey:t?.hasApiKey??!1,authHeader:e.authHeader,models:t?.models.length?t.models:[lg()]})),D(null),ne(null)},Je=()=>{if(!v)return;let e=v.providerId.trim();if(!e)return;let t=v.models.filter(e=>e.id.trim()).map(e=>({id:e.id.trim(),name:e.name.trim()||void 0,reasoning:e.reasoning||void 0,input:e.input===`text-image`?[`text`,`image`]:void 0,contextWindow:e.contextWindow?Number(e.contextWindow):void 0,maxTokens:e.maxTokens?Number(e.maxTokens):void 0}));$({type:`save_model_config`,providerId:e,config:{providerId:e,name:v.name.trim()||void 0,api:v.api.trim()||void 0,baseUrl:v.baseUrl.trim()||void 0,...v.apiKey.trim()?{apiKey:v.apiKey.trim()}:{},authHeader:v.authHeader||void 0,models:t}}),p()},Xe=(e,t)=>{v&&y({...v,models:v.models.map((n,r)=>r===e?{...n,...t}:n)})},Ze=()=>{v&&y({...v,models:[...v.models,lg()]})},Qe=e=>{v&&y({...v,models:v.models.filter((t,n)=>n!==e)})},$e=e=>{let t=(k[e.id]??``).trim();t&&!M&&(P(e.id),$({type:`add_provider_key`,provider:e.id,apiKey:t,name:(ee[e.id]??``).trim()||void 0}),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{P(t=>t===e.id?null:t)},1e4))},et=(e,t)=>{$({type:`activate_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`})},tt=(e,t)=>{window.confirm(h(`removeKeyConfirm`))&&($({type:`remove_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`}))},nt=e=>{window.confirm(h(`clearKeyConfirm`,{id:e}))&&$({type:`clear_provider_api_key`,provider:e})},rt=t=>{if(window.confirm(h(`deleteProviderConfirm`,{id:t.providerId,n:t.models.length}))&&($({type:`delete_model_config`,providerId:t.providerId}),g.type===`custom`&&g.id===t.providerId)){let n=e.filter(e=>e.providerId!==t.providerId);n.length>0?(_({type:`custom`,id:n[0].providerId}),y(dg(n[0]))):(_({type:`custom`,id:``}),y(ug()))}},it=e=>{let t=be.trim();if(!t||De)return;Oe(!0),Me(null);let n=ke+1;Ae(n),$({type:`append_builtin_model`,providerId:e,model:{id:t,...Se.trim()?{name:Se.trim()}:{},...we?{api:we}:{},...Ee.trim()?{baseUrl:Ee.trim()}:{}},reqId:n})};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:p,children:(0,X.jsxs)(`div`,{className:`modal model-studio-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`studio-header`,children:[(0,X.jsxs)(`div`,{className:`studio-header-left`,children:[(0,X.jsx)(`div`,{className:`studio-header-icon-box`,children:(0,X.jsx)(Le,{})}),(0,X.jsxs)(`div`,{className:`studio-header-title-wrap`,children:[(0,X.jsx)(`h2`,{className:`studio-header-title`,children:`模型管理`}),(0,X.jsx)(`span`,{className:`studio-header-badge`,children:`Studio`})]})]}),(0,X.jsxs)(`div`,{className:`studio-header-actions`,children:[f!==void 0&&f&&(0,X.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:5,padding:`3px 8px`,borderRadius:6,background:`rgba(251, 191, 36, 0.08)`,border:`1px solid rgba(251, 191, 36, 0.3)`,fontSize:11.5,color:`var(--amber)`},title:`全局默认模型: ${f}`,children:[(0,X.jsx)(`span`,{children:`★`}),(0,X.jsx)(`span`,{style:{maxWidth:120,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`var(--mono)`},children:f.split(`/`).slice(1).join(`/`)}),(0,X.jsx)(`button`,{type:`button`,style:{background:`transparent`,border:`none`,color:`var(--amber)`,cursor:`pointer`,fontSize:10,padding:`0 2px`,opacity:.7},title:`清除全局默认模型`,onClick:()=>$({type:`clear_default_model`}),children:`✕`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`studio-header-btn`,title:h(`refreshBuiltinHint`),disabled:me,onClick:()=>{if(me)return;he(!0),ve(null);let e=K+1;ge(e),$({type:`refresh_builtin_models`,reqId:e})},children:[(0,X.jsx)(Ie,{}),(0,X.jsx)(`span`,{children:me?h(`refreshBuiltinBusy`):`刷新官方目录`})]}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn`,title:h(`reloadModelsHint`),onClick:()=>$({type:`reload_models_config`}),children:(0,X.jsx)(oe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn close-btn`,"aria-label":h(`close`),onClick:p,children:(0,X.jsx)(N,{})})]})]}),_e&&(0,X.jsx)(`div`,{style:{padding:`6px 20px`,background:`var(--bg-elev2)`,fontSize:12,borderBottom:`1px solid var(--border-soft)`},children:(0,X.jsx)(`span`,{className:`fetch-msg ${_e.ok?`ok`:`err`}`,children:_e.text})}),(0,X.jsxs)(`div`,{className:`model-studio-body`,children:[(0,X.jsxs)(`div`,{className:`model-studio-sidebar`,children:[(0,X.jsx)(`div`,{style:{padding:`12px 10px 6px`},children:(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,style:{width:`100%`,justifyContent:`center`},onClick:()=>{_({type:`custom`,id:``}),y(ug()),D(null),ne(null)},children:[(0,X.jsx)(se,{}),` 添加自定义服务商`]})}),(0,X.jsxs)(`div`,{className:`studio-sidebar-section`,children:[(0,X.jsxs)(`span`,{className:`studio-sidebar-title`,children:[`自定义服务商 (`,e.length,`)`]}),e.length===0&&(0,X.jsx)(`div`,{style:{fontSize:11.5,color:`var(--text-faint)`,padding:`6px 8px`},children:`暂无配置`}),e.map(e=>{let t=g.type===`custom`&&g.id===e.providerId;return(0,X.jsxs)(`div`,{className:`studio-nav-item ${t?`active`:``}`,onClick:()=>{_({type:`custom`,id:e.providerId}),y(dg(e)),D(null),ne(null)},children:[(0,X.jsxs)(`span`,{className:`studio-nav-label`,children:[(0,X.jsx)(`span`,{className:`studio-nav-dot configured`}),(0,X.jsx)(`span`,{children:e.name||e.providerId})]}),(0,X.jsxs)(`span`,{style:{fontSize:10.5,color:`var(--text-faint)`,fontFamily:`var(--mono)`},children:[e.models.length,`m`]})]},e.providerId)})]}),(0,X.jsxs)(`div`,{className:`studio-sidebar-section`,children:[(0,X.jsxs)(`span`,{className:`studio-sidebar-title`,children:[`官方内置服务商 (`,t.length,`)`]}),t.map(e=>{let t=g.type===`builtin`&&g.id===e.id,r=n[e.id]??[];return(0,X.jsxs)(`div`,{className:`studio-nav-item ${t?`active`:``}`,onClick:()=>{_({type:`builtin`,id:e.id}),y(null)},children:[(0,X.jsxs)(`span`,{className:`studio-nav-label`,children:[(0,X.jsx)(`span`,{className:`studio-nav-dot ${e.configured?`configured`:``}`}),(0,X.jsx)(`span`,{children:e.name})]}),r.length>0&&(0,X.jsxs)(`span`,{style:{fontSize:10.5,color:`var(--text-faint)`,fontFamily:`var(--mono)`},children:[r.length,`k`]})]},e.id)})]})]}),(0,X.jsxs)(`div`,{className:`model-studio-main`,children:[v&&(0,X.jsxs)(`div`,{className:`studio-card`,children:[(0,X.jsxs)(`div`,{className:`studio-card-head`,children:[(0,X.jsxs)(`div`,{className:`studio-card-title`,children:[(0,X.jsx)(`span`,{children:v.providerId?`编辑服务商:${v.providerId}`:`新建自定义服务商`}),v.providerId&&e.some(e=>e.providerId===v.providerId)&&(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger sm`,title:`删除此服务商`,onClick:()=>{let t=e.find(e=>e.providerId===v.providerId);t&&rt(t)},children:(0,X.jsx)(R,{})})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,X.jsxs)(`div`,{className:`conn-test-box`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`conn-test-btn`,disabled:S||!v.baseUrl.trim(),onClick:He,children:[(0,X.jsx)(st,{}),` `,S?`测试中…`:`测试连接`]}),E&&(0,X.jsxs)(`span`,{className:`ping-indicator ${E.ok?`ok`:`err`}`,children:[(0,X.jsx)(`span`,{className:`ping-dot`}),(0,X.jsx)(`span`,{children:E.ok?`${E.latencyMs??0}ms 连通正常`:`连接失败`})]})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary sm`,onClick:Je,children:h(`save`)})]})]}),(0,X.jsxs)(`div`,{className:`quick-chips-wrapper`,children:[(0,X.jsx)(`span`,{className:`quick-chips-label`,children:`快捷预设模板 (Quick Presets)`}),(0,X.jsx)(`div`,{className:`quick-chips-grid`,children:og.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`quick-chip`,onClick:()=>qe(e),children:[(0,X.jsx)(`span`,{className:`quick-chip-name`,children:e.name}),e.tag&&(0,X.jsx)(`span`,{className:`quick-chip-tag`,children:e.tag})]},e.id))})]}),(0,X.jsxs)(`div`,{className:`form-grid`,children:[(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[h(`providerId`),` `,(0,X.jsx)(`em`,{children:h(`providerIdHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:v.providerId,disabled:e.some(e=>e.providerId===v.providerId),onChange:e=>y({...v,providerId:e.target.value}),placeholder:`例如 deepseek`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`displayName`)}),(0,X.jsx)(`input`,{type:`text`,value:v.name,onChange:e=>y({...v,name:e.target.value}),placeholder:h(`displayNamePh`)})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`apiType`)}),(0,X.jsx)(`select`,{value:v.api,onChange:e=>y({...v,api:e.target.value}),children:ag.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[`baseUrl `,(0,X.jsx)(`em`,{children:h(`baseUrlHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:v.baseUrl,onChange:e=>y({...v,baseUrl:e.target.value}),placeholder:`https://api.deepseek.com/v1`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:v.apiKey,onChange:e=>y({...v,apiKey:e.target.value}),placeholder:v.hasApiKey?h(`apiKeySavedHint`):h(`apiKeyHint`)})]}),(0,X.jsxs)(`label`,{className:`field check`,style:{alignSelf:`center`,paddingTop:16},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:v.authHeader,onChange:e=>y({...v,authHeader:e.target.checked})}),(0,X.jsx)(`span`,{children:h(`authHeader`)})]})]}),(0,X.jsxs)(`div`,{style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`model-section-head`,children:[(0,X.jsxs)(`span`,{className:`form-section-title`,style:{fontSize:13,fontWeight:600},children:[`模型矩阵 (`,v.models.filter(e=>e.id.trim()).length,`)`]}),(0,X.jsxs)(`div`,{className:`model-section-actions`,children:[V&&(0,X.jsx)(`span`,{className:`fetch-msg ${V.ok?`ok`:`err`}`,title:V.text,children:V.text}),ce&&(0,X.jsx)(`span`,{className:`fetch-msg ${ce.ok?`ok`:`err`}`,title:ce.text,children:ce.text}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:L||!v.baseUrl.trim(),title:h(`fetchModelsHint`),onClick:Ue,children:[(0,X.jsx)(Ie,{}),` `,L?h(`fetchingModels`):`自动获取并采纳模型`]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:U,title:h(`enrichModelsHint`),onClick:Ge,children:[(0,X.jsx)(Ie,{}),` `,h(U?`enrichingModels`:`enrichModels`)]}),U&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:G,title:h(`enrichModelsAbort`),onClick:Ke,style:{color:`var(--red)`},children:[(0,X.jsx)(N,{}),` `,h(G?`enrichCancelling`:`enrichModelsCancel`)]})]})]}),(0,X.jsxs)(`div`,{className:`model-matrix-list`,children:[v.models.map((e,t)=>(0,X.jsxs)(`div`,{className:`model-matrix-card`,children:[(0,X.jsxs)(`div`,{className:`matrix-main-row`,children:[(0,X.jsxs)(`div`,{className:`matrix-input-group id-group`,children:[(0,X.jsxs)(`span`,{className:`matrix-input-prefix`,children:[(0,X.jsx)(Le,{}),` ID`]}),(0,X.jsx)(`input`,{type:`text`,className:`matrix-input-field mono`,value:e.id,onChange:e=>Xe(t,{id:e.target.value}),placeholder:`例如 deepseek-chat`})]}),(0,X.jsxs)(`div`,{className:`matrix-input-group name-group`,children:[(0,X.jsx)(`span`,{className:`matrix-input-prefix`,children:`别名`}),(0,X.jsx)(`input`,{type:`text`,className:`matrix-input-field`,value:e.name,onChange:e=>Xe(t,{name:e.target.value}),placeholder:`显示名称 (选填)`})]}),(0,X.jsxs)(`div`,{className:`matrix-toggles`,children:[(0,X.jsx)(`button`,{type:`button`,className:`matrix-toggle-tag ${e.input===`text-image`?`active vision`:``}`,onClick:()=>Xe(t,{input:e.input===`text-image`?`text`:`text-image`}),title:`是否支持图像识图输入`,children:`🖼 视觉`}),(0,X.jsx)(`button`,{type:`button`,className:`matrix-toggle-tag ${e.reasoning?`active reasoning`:``}`,onClick:()=>Xe(t,{reasoning:!e.reasoning}),title:`是否支持深度思考推理`,children:`⚡ 推理`}),f!==void 0&&e.id.trim()&&(()=>{let t=`${v.providerId}/${e.id.trim()}`,n=f===t||f===e.id.trim();return(0,X.jsxs)(`button`,{type:`button`,className:`matrix-star-btn ${n?`active`:``}`,title:n?`当前全局默认模型(点击取消默认)`:`设为全局默认模型`,onClick:()=>{$(n?{type:`clear_default_model`}:{type:`set_default_model`,modelId:t})},children:[(0,X.jsx)(`span`,{className:`matrix-star-icon`,children:n?`★`:`☆`}),(0,X.jsx)(`span`,{children:n?`默认`:`设为默认`})]})})(),(0,X.jsx)(`button`,{type:`button`,className:`matrix-delete-btn`,title:h(`delete`),onClick:()=>Qe(t),children:(0,X.jsx)(R,{})})]})]}),(0,X.jsxs)(`div`,{className:`matrix-spec-bar`,children:[(0,X.jsxs)(`div`,{className:`spec-combobox`,children:[(0,X.jsx)(`span`,{className:`spec-combobox-label`,children:`上下文`}),(0,X.jsxs)(`select`,{className:`spec-combobox-select`,value:sg.some(t=>t.value===e.contextWindow)?e.contextWindow:`custom`,onChange:e=>{e.target.value!==`custom`&&Xe(t,{contextWindow:e.target.value})},children:[sg.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[e.label,` (`,Math.round(Number(e.value)/1024),`K)`]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:`自定义…`})]}),(!sg.some(t=>t.value===e.contextWindow)||e.contextWindow===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.contextWindow,onChange:e=>Xe(t,{contextWindow:e.target.value}),placeholder:`如 131072`})]}),(0,X.jsxs)(`div`,{className:`spec-combobox`,children:[(0,X.jsx)(`span`,{className:`spec-combobox-label`,children:`最大输出`}),(0,X.jsxs)(`select`,{className:`spec-combobox-select`,value:cg.some(t=>t.value===e.maxTokens)?e.maxTokens:`custom`,onChange:e=>{e.target.value!==`custom`&&Xe(t,{maxTokens:e.target.value})},children:[cg.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[e.label,` (`,Math.round(Number(e.value)/1024),`K)`]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:`自定义…`})]}),(!cg.some(t=>t.value===e.maxTokens)||e.maxTokens===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.maxTokens,onChange:e=>Xe(t,{maxTokens:e.target.value}),placeholder:`如 8192`})]}),(0,X.jsx)(`div`,{className:`matrix-spec-quick-pills`,children:[`32K`,`128K`,`200K`].map(n=>{let r=sg.find(e=>e.label===n);return r?(0,X.jsx)(`button`,{type:`button`,className:`param-pill ${e.contextWindow===r.value?`active`:``}`,onClick:()=>Xe(t,{contextWindow:r.value}),title:`快捷设为 ${n} 上下文`,children:n},n):null})})]})]},t)),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,style:{alignSelf:`flex-start`,marginTop:4},onClick:Ze,children:[(0,X.jsx)(se,{}),` 添加模型行`]})]})]})]}),g.type===`builtin`&&(()=>{let e=t.find(e=>e.id===g.id);if(!e)return null;let a=n[e.id]??[];return(0,X.jsxs)(`div`,{className:`studio-card`,children:[(0,X.jsxs)(`div`,{className:`studio-card-head`,children:[(0,X.jsxs)(`div`,{className:`studio-card-title`,children:[(0,X.jsxs)(`span`,{children:[`官方内置服务商:`,e.name]}),e.configured&&(0,X.jsx)(`span`,{className:`auth-badge`,children:h(`configuredBadge`)}),e.source&&!e.configured&&(0,X.jsx)(`span`,{className:`auth-badge dim`,children:e.source})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{J(ye===e.id?null:e.id),Me(null)},children:[(0,X.jsx)(se,{}),` `,h(`appendModel`)]}),e.supportsApiKey&&e.source===`stored`&&!e.usingOAuth&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm danger`,title:h(`clearKeyTitle`),onClick:()=>nt(e.id),children:[(0,X.jsx)(R,{}),` `,h(`clearKey`)]})]})]}),e.supportsOAuth&&(0,X.jsx)(rg,{provider:e,flow:r.find(t=>t.provider===e.id),result:i[e.id]}),e.supportsApiKey&&(0,X.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,X.jsx)(`span`,{style:{fontSize:12.5,fontWeight:600},children:`API 密钥管理`}),(0,X.jsxs)(`div`,{className:`provider-keys`,children:[a.length===0&&(0,X.jsx)(`div`,{className:`provider-key-empty`,children:h(`noKeyYet`)}),a.map(t=>(0,X.jsxs)(`div`,{className:`provider-key-item ${t.active?`active`:``}`,children:[(0,X.jsx)(`span`,{className:`provider-key-dot`,children:t.active?`●`:`○`}),(0,X.jsx)(`span`,{className:`provider-key-label`,children:t.name}),!t.active&&(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:h(`activateKey`),onClick:()=>et(e.id,t.name),children:(0,X.jsx)(Ye,{})}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger`,title:h(`removeKey`),onClick:()=>tt(e.id,t.name),children:(0,X.jsx)(R,{})})]},t.name))]}),(0,X.jsxs)(`div`,{className:`provider-add-key`,style:{marginTop:6},children:[(0,X.jsx)(`input`,{type:`text`,className:`key-input key-input-name`,placeholder:h(`keyNamePh`),value:ee[e.id]??``,onChange:t=>j(n=>({...n,[e.id]:t.target.value}))}),(0,X.jsx)(`input`,{type:`password`,className:`key-input key-input-value`,placeholder:h(`addKeyPlaceholder`),value:k[e.id]??``,onChange:t=>A(n=>({...n,[e.id]:t.target.value}))}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!(k[e.id]??``).trim()||M===e.id,onClick:()=>$e(e),children:[(0,X.jsx)(se,{}),` `,M===e.id?h(`savingKey`):h(`addKey`)]})]})]}),ye===e.id&&(0,X.jsxs)(`div`,{style:{marginTop:12,padding:12,background:`var(--bg)`,borderRadius:8,border:`1px dashed var(--border-soft)`},children:[(0,X.jsx)(`span`,{style:{fontSize:12,fontWeight:600,display:`block`,marginBottom:8},children:`追加官方模型覆盖 (Overlay)`}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:`模型 ID (必填)`,value:be,onChange:e=>xe(e.target.value)}),(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:`显示名称 (选填)`,value:Se,onChange:e=>Ce(e.target.value)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!be.trim()||De,onClick:()=>it(e.id),children:[(0,X.jsx)(se,{}),` 提交追加`]})]}),je&&(0,X.jsx)(`span`,{style:{fontSize:12,color:je.ok?`var(--green)`:`var(--red)`,marginTop:6},children:je.text})]})]})})()]})]}),b&&(0,X.jsx)(pg,{candidates:b,onAdopt:We,onClose:()=>x(null)})]})})}function hg(e,t=[],n){let r=[],i=e=>{r.includes(e)||r.push(e)};e.optionsFrom&&i(``);for(let t of e.options??[])i(t);if(e.optionsFrom===`models`)for(let e of t)i(`${e.provider}/${e.id}`);else if(e.optionsFrom===`thinkingLevels`)for(let e of zm)i(e);let a=typeof n==`string`?n:n==null?``:String(n);return a&&i(a),r}function gg({plugin:e,models:t=[]}){let n=Z(),r=e.settingsSchema??[],[i,a]=(0,m.useState)(()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);return t}),[o,s]=(0,m.useState)(!1);if(r.length===0)return null;let c=(e,t)=>a(n=>({...n,[e]:t})),l=e=>hg(e,t,i[e.key]).map(r=>{if(r===``)return{value:``,label:n(`pluginSettingsInherit`)};if(e.optionsFrom===`thinkingLevels`&&zm.includes(r))return{value:r,label:n(`thinking.${r}`)};if(e.optionsFrom===`models`){let e=t.find(e=>`${e.provider}/${e.id}`===r);if(e)return{value:r,label:e.label}}return{value:r,label:r}}),u=r.some(t=>t.type===`secret`?String(i[t.key]??``)!==``:i[t.key]!==e.settingsValues?.[t.key]);return(0,X.jsxs)(`div`,{className:`plugin-settings-form`,children:[(0,X.jsx)(`div`,{className:`plugin-settings-fields`,children:r.map(t=>(0,X.jsxs)(`label`,{className:`plugin-settings-field`,"data-key":t.key,title:t.hint,children:[(0,X.jsxs)(`span`,{className:`plugin-settings-label`,children:[(0,X.jsx)(`span`,{className:`plugin-settings-label-text`,title:t.label,children:t.label}),t.hint&&(0,X.jsx)(`span`,{className:`plugin-settings-hint`,children:t.hint})]}),(0,X.jsx)(`span`,{className:`plugin-settings-control`,children:t.type===`boolean`?(0,X.jsx)(`input`,{type:`checkbox`,checked:!!i[t.key],onChange:e=>c(t.key,e.target.checked)}):t.type===`secret`?(0,X.jsx)(`input`,{type:`password`,value:String(i[t.key]??``),placeholder:n(e.settingsValues?.[t.key]?`pluginSecretSet`:`pluginSecretUnset`),autoComplete:`new-password`,onChange:e=>c(t.key,e.target.value)}):t.type===`select`?(0,X.jsx)(`select`,{value:String(i[t.key]??``),onChange:e=>c(t.key,e.target.value),children:l(t).map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,X.jsx)(`input`,{type:t.type===`password`?`password`:t.type===`number`?`number`:`text`,value:String(i[t.key]??``),min:t.min,max:t.max,onChange:e=>c(t.key,t.type===`number`?Number(e.target.value):e.target.value)})})]},t.key))}),(0,X.jsxs)(`div`,{className:`plugin-settings-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn plugin-settings-save`,disabled:!u||o,onClick:()=>{s(!0),$({type:`plugin_settings`,pluginId:e.id,values:i}),setTimeout(()=>s(!1),800)},children:n(o?`pluginSettingsSaving`:`pluginSettingsSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn plugin-settings-reset`,onClick:()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);a(t)},children:n(`pluginSettingsReset`)})]})]})}var _g=[{value:`0 9 * * *`,key:`schedulerPresetDaily`},{value:`0 * * * *`,key:`schedulerPresetHourly`},{value:`*/30 * * * *`,key:`schedulerPresetHalfHour`},{value:`0 9 * * 1-5`,key:`schedulerPresetWorkday`},{value:`0 9 * * 1`,key:`schedulerPresetMonday`}];function vg(e){return{id:``,name:``,description:``,cwd:e,kind:`cron`,cron:`0 9 * * *`,preset:`0 9 * * *`,intervalMinutes:`60`,prompt:``,model:``,thinkingLevel:``,catchUp:!1}}function yg(e){let t=e.kind===`cron`&&_g.some(t=>t.value===e.spec);return{id:e.id,name:e.name,description:e.description,cwd:e.cwd,kind:e.kind,cron:e.kind===`cron`?e.spec:`0 9 * * *`,preset:t?e.spec:`custom`,intervalMinutes:e.kind===`interval`?String(Math.max(1,Math.round(Number(e.spec)/6e4))):`60`,prompt:e.prompt,model:e.model,thinkingLevel:e.thinkingLevel,catchUp:e.catchUp===`once`}}function bg(e,t){if(e.kind===`interval`){let n=Math.round(Number(e.spec)/6e4);return n<60?`${t(`schedulerKindInterval`)} · ${n} min`:n%60==0?`${t(`schedulerKindInterval`)} · ${n/60} h`:`${t(`schedulerKindInterval`)} · ${n} min`}let n=_g.find(t=>t.value===e.spec);return n?t(n.key):e.spec}function xg(e){if(!e)return``;try{return new Date(e).toLocaleString()}catch{return String(e)}}function Sg({tasks:e,cwd:t,models:n}){let r=Z(),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(new Set);(0,m.useEffect)(()=>{$({type:`schedule_list`})},[]);let u=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ve,{className:`set-section-icon`}),r(`settingsScheduler`),(0,X.jsx)(bc,{text:r(`schedulerDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:r(`schedulerNew`),onClick:()=>{a(vg(t)),s(!0)},children:[(0,X.jsx)(se,{}),` `,r(`schedulerNew`)]})]}),e.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:r(`schedulerEmpty`)}):(0,X.jsx)(`ul`,{className:`scheduler-list`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`scheduler-item ${e.enabled?``:`off`}`,children:[(0,X.jsxs)(`div`,{className:`scheduler-line1`,children:[(0,X.jsxs)(`span`,{className:`scheduler-name`,title:e.description||e.name,children:[e.running?`${r(`schedulerRunning`)} `:``,e.name]}),(0,X.jsx)(`span`,{className:`scheduler-badge ${e.enabled?`on`:``}`,children:e.enabled?r(`schedulerEnabled`):r(`schedulerDisabled`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-switch ${e.enabled?`on`:``}`,title:e.enabled?r(`schedulerDisable`):r(`schedulerEnable`),onClick:()=>$({type:`schedule_toggle`,id:e.id,enabled:!e.enabled}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsx)(`span`,{title:e.cwd,children:e.cwd}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsx)(`span`,{title:e.kind===`cron`?e.spec:`${e.spec} ms`,children:bg(e,r)})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsxs)(`span`,{children:[r(`schedulerNextFire`),`: `,e.nextFire?xg(e.nextFire):`—`]}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsxs)(`span`,{children:[r(`schedulerLastRun`),`:`,` `,e.lastRun?(0,X.jsxs)(X.Fragment,{children:[xg(e.lastRun.at),` ·`,` `,(0,X.jsx)(`span`,{className:e.lastRun.ok?`scheduler-ok`:`scheduler-fail`,children:e.lastRun.ok?r(`schedulerRunOk`):r(`schedulerRunFail`)}),e.lastRun.manual?` · ${r(`schedulerManualBadge`)}`:``,e.lastRun.error?` · ${e.lastRun.error}`:``]}):r(`schedulerNeverRun`)]}),e.history.length>1&&(0,X.jsxs)(`button`,{type:`button`,className:`scheduler-link`,onClick:()=>u(e.id),children:[r(`schedulerHistory`),` (`,e.history.length,`)`]})]}),c.has(e.id)&&e.history.length>0&&(0,X.jsx)(`ul`,{className:`scheduler-history`,children:e.history.map((e,t)=>(0,X.jsxs)(`li`,{children:[xg(e.at),` ·`,` `,(0,X.jsx)(`span`,{className:e.ok?`scheduler-ok`:`scheduler-fail`,children:e.ok?r(`schedulerRunOk`):r(`schedulerRunFail`)}),` · ${(e.durationMs/1e3).toFixed(0)}s`,e.manual?` · ${r(`schedulerManualBadge`)}`:``,e.error?` · ${e.error}`:``]},`${e.at}-${t}`))}),(0,X.jsxs)(`div`,{className:`scheduler-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:e.running,title:r(`schedulerRunNow`),onClick:()=>$({type:`schedule_run`,id:e.id}),children:[(0,X.jsx)(ce,{}),` `,r(`schedulerRunNow`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerEdit`),onClick:()=>{a(yg(e)),s(!1)},children:[(0,X.jsx)(Pe,{}),` `,r(`schedulerEdit`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerDelete`),onClick:()=>{window.confirm(r(`schedulerConfirmDelete`,{name:e.name}))&&$({type:`schedule_delete`,id:e.id})},children:[(0,X.jsx)(R,{}),` `,r(`schedulerDelete`)]})]})]},e.id))}),i&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>a(null),children:(0,X.jsxs)(`div`,{className:`modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":r(`close`),onClick:()=>a(null),children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Ve,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:o?r(`schedulerNew`):`${r(`schedulerEdit`)} · ${i.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:r(`schedulerNamePlaceholder`),value:i.name,onChange:e=>a({...i,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerDescPlaceholder`),value:i.description,onChange:e=>a({...i,description:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerCwdLabel`)}),(0,X.jsxs)(`div`,{className:`scheduler-cwd-row`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerCwdPlaceholder`),value:i.cwd,onChange:e=>a({...i,cwd:e.target.value})}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>a({...i,cwd:t}),children:r(`schedulerUseCurrentCwd`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.kind,onChange:e=>a({...i,kind:e.target.value}),children:[(0,X.jsx)(`option`,{value:`cron`,children:r(`schedulerKindCron`)}),(0,X.jsx)(`option`,{value:`interval`,children:r(`schedulerKindInterval`)})]})]}),i.kind===`cron`?(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindCron`)}),(0,X.jsxs)(`div`,{className:`scheduler-cwd-row`,children:[(0,X.jsxs)(`select`,{className:`set-select`,value:i.preset,onChange:e=>{let t=e.target.value;a({...i,preset:t,...t===`custom`?{}:{cron:t}})},children:[_g.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[r(e.key),` · `,e.value]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:r(`schedulerPresetCustom`)})]}),i.preset===`custom`&&(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerCronPlaceholder`),value:i.cron,onChange:e=>a({...i,cron:e.target.value})})]})]}):(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindInterval`)}),(0,X.jsx)(`input`,{className:`set-input`,type:`number`,min:1,placeholder:r(`schedulerIntervalMinutes`),value:i.intervalMinutes,onChange:e=>a({...i,intervalMinutes:e.target.value})})]}),(0,X.jsx)(`div`,{className:`tpl-fields`,children:(0,X.jsx)(`textarea`,{className:`set-input`,rows:4,placeholder:r(`schedulerPromptPlaceholder`),value:i.prompt,onChange:e=>a({...i,prompt:e.target.value})})}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.model,onChange:e=>a({...i,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`subagentFollowMain`)}),n.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})]}),n.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:r(`subagentNoModels`)}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[r(`schedulerThinkingLabel`),` `,(0,X.jsx)(bc,{text:r(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.thinkingLevel,onChange:e=>a({...i,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`tplThinkingFollowMain`)}),zm.map(e=>(0,X.jsx)(`option`,{value:e,children:r(`thinking.${e}`)},e))]})]}),(0,X.jsxs)(`label`,{className:`scheduler-check`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i.catchUp,onChange:e=>a({...i,catchUp:e.target.checked})}),(0,X.jsxs)(`span`,{children:[r(`schedulerCatchUp`),` `,(0,X.jsx)(bc,{text:r(`schedulerCatchUpHint`)})]})]}),(0,X.jsxs)(`div`,{className:`scheduler-foot`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>a(null),children:r(`schedulerCancelEdit`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!i.name.trim()||!i.cwd.trim()||!i.prompt.trim(),onClick:()=>{if(!i)return;let e=i.kind;$({type:`schedule_save`,task:{...i.id?{id:i.id}:{},name:i.name.trim(),description:i.description.trim(),cwd:i.cwd.trim(),kind:e,spec:e===`cron`?i.cron.trim():String(Math.max(1,Math.floor(Number(i.intervalMinutes)||0))*6e4),prompt:i.prompt.trim(),...i.model.trim()?{model:i.model.trim()}:{},...i.thinkingLevel.trim()?{thinkingLevel:i.thinkingLevel.trim()}:{},catchUp:i.catchUp?`once`:`skip`}}),a(null)},children:r(`schedulerSave`)})]})]})]})})]})}var Cg=`pi-web-sounds`,wg={enabled:!0,question:!0,done:!0,start:!1,error:!0,approval:!0,volume:100};function Tg(){try{let e=localStorage.getItem(Cg);if(!e)return{...wg};let t=JSON.parse(e),n={...wg,...t};for(let e of[`enabled`,`question`,`done`,`start`,`error`,`approval`])typeof n[e]!=`boolean`&&(n[e]=wg[e]);return n.volume=typeof n.volume!=`number`||!Number.isFinite(n.volume)?wg.volume:Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...wg}}}function Eg(e){try{localStorage.setItem(Cg,JSON.stringify(e))}catch{}}var Dg=null;function Og(){try{if(!Dg){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Dg=new e}return Dg.state===`suspended`&&Dg.resume(),Dg}catch{return null}}var kg={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}],approval:[{type:`sine`,freq:659.25,start:0,dur:.11,peak:.45},{type:`sine`,freq:659.25,start:.14,dur:.11,peak:.45},{type:`sine`,freq:880,start:.28,dur:.26,peak:.5}]};function Ag(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 jg(e,t=Tg()){if(!t.enabled||!t[e])return;let n=Og();if(!n)return;let r=Math.max(0,Math.min(1,t.volume/100));for(let t of kg[e])Ag(n,t,r)}function Mg(e){if(e==null)return 0;if(typeof e==`number`){if(!Number.isFinite(e)||e<=0)return 0;let t=Math.floor(e);return t<=1e3?t*1e3:Math.min(1e7,t)}let t=String(e).trim().toLowerCase().replace(/[,_\s]/g,``);if(!t)return 0;let n=t.match(/^(\d+(?:\.\d+)?)([km])?$/);if(!n)return 0;let r=parseFloat(n[1]);if(!Number.isFinite(r)||r<=0)return 0;let i=n[2],a;return i===`k`?a=Math.floor(r*1e3):i===`m`?a=Math.floor(r*1e6):(a=Math.floor(r),a<=1e3&&(a*=1e3)),Math.min(1e7,Math.max(0,a))}function Ng(e){return!e||e<=0||!Number.isFinite(e)?``:e>=1e6&&e%1e5==0?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3&&e%1e3==0?`${e/1e3}k`:String(e)}var Pg=`pi-web-ui:wide-chat`,Fg={wide:!1};function Ig(e){if(!e||typeof e!=`object`)return{...Fg};let t=e;return{wide:typeof t.wide==`boolean`?t.wide:Fg.wide}}function Lg(){try{let e=localStorage.getItem(Pg);return e?Ig(JSON.parse(e)):{...Fg}}catch{return{...Fg}}}function Rg(e){let t=Ig(e);try{localStorage.setItem(Pg,JSON.stringify(t))}catch{}zg=t;for(let e of Bg)e()}var zg=null,Bg=new Set;function Vg(e){return Bg.add(e),()=>{Bg.delete(e)}}function Hg(){return zg||=Lg(),zg.wide}function Ug(){return(0,m.useSyncExternalStore)(Vg,Hg)}var Wg=`pi-web-ui:project-title`,Gg={projectName:!0};function Kg(e){if(!e||typeof e!=`object`)return{...Gg};let t=e;return{projectName:typeof t.projectName==`boolean`?t.projectName:Gg.projectName}}function qg(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()??``:``}function Jg(){try{let e=localStorage.getItem(Wg);return e?Kg(JSON.parse(e)):{...Gg}}catch{return{...Gg}}}function Yg(e){let t=Kg(e);try{localStorage.setItem(Wg,JSON.stringify(t))}catch{}Xg=t;for(let e of Zg)e()}var Xg=null,Zg=new Set;function Qg(e){return Zg.add(e),()=>{Zg.delete(e)}}function $g(){return Xg||=Jg(),Xg.projectName}function e_(){return(0,m.useSyncExternalStore)(Qg,$g)}var t_=`pi-web-ui:wallpaper`,n_=`has-wallpaper`,r_={url:``,dim:78,blur:0},i_=2e3,a_=28e5;function o_(e){if(typeof e!=`string`)return``;let t=e.trim();if(!t)return``;let n=t.toLowerCase().startsWith(`data:image/`)?a_:i_;return t.length>n?``:/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith(`/`)&&!t.startsWith(`//`)?t:``}var s_=(e,t,n,r)=>typeof e!=`number`||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)));function c_(e){if(!e||typeof e!=`object`)return{...r_};let t=e;return{url:o_(t.url),dim:s_(t.dim,0,95,r_.dim),blur:s_(t.blur,0,24,r_.blur)}}function l_(){try{let e=localStorage.getItem(t_);return e?c_(JSON.parse(e)):{...r_}}catch{return{...r_}}}function u_(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/[\r\n]/g,``)}async function d_(e){let t=await jd(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function f_(){let e=m_??l_(),t=document.documentElement;e.url?(t.style.setProperty(`--bg-image`,`url("${u_(e.url)}")`),t.style.setProperty(`--bg-image-dim`,String(e.dim/100)),t.style.setProperty(`--bg-image-blur`,`${e.blur}px`)):(t.style.removeProperty(`--bg-image`),t.style.removeProperty(`--bg-image-dim`),t.style.removeProperty(`--bg-image-blur`));let n=getComputedStyle(t).getPropertyValue(`--bg-image`).trim();document.body.classList.toggle(n_,e.url!==``||n!==``&&n!==`none`)}function p_(e){let t=c_(e);m_=t;try{localStorage.setItem(t_,JSON.stringify(t))}catch{}for(let e of h_)e();f_()}var m_=null,h_=new Set;function g_(e){return h_.add(e),()=>{h_.delete(e)}}function __(){return m_||=l_(),m_}function v_(){return(0,m.useSyncExternalStore)(g_,__)}function y_(){let e=v_();(0,m.useEffect)(()=>{f_()},[e]),(0,m.useEffect)(()=>{let e=()=>f_();return window.addEventListener(Kl,e),f_(),()=>window.removeEventListener(Kl,e)},[])}function b_(e,t){return e.error?`failed`:t?`disabled`:e.active===!0?`active`:`idle`}function x_(e,t){let n={active:0,disabled:0,failed:0,idle:0};for(let r of e)n[b_(r,t.has(r.id))]+=1;return n}var S_={zh:[`继续`,`总结一下`,`详细解释一下`,`检查并修复问题`,`补充测试覆盖`,`发布上传`],en:[`Continue`,`Summarize`,`Explain in detail`,`Check and fix issues`,`Add test coverage`,`Publish release`],it:[`Continua`,`Riassumi`,`Spiega in dettaglio`,`Verifica e correggi i problemi`,`Aggiungi copertura dei test`,`Pubblica la release`],ja:[`続ける`,`要約して`,`詳しく説明して`,`問題を確認して修正`,`テストカバレッジを追加`,`公開・リリース`],ko:[`계속`,`요약해줘`,`자세히 설명해줘`,`문제를 확인하고 수정`,`테스트 커버리지 추가`,`게시/릴리스`],fr:[`Continuer`,`Résumer`,`Expliquer en détail`,`Vérifier et corriger les problèmes`,`Ajouter des tests`,`Publier`],de:[`Weiter`,`Zusammenfassen`,`Ausführlich erklären`,`Probleme prüfen und beheben`,`Testabdeckung ergänzen`,`Veröffentlichen`],es:[`Continuar`,`Resumir`,`Explicar en detalle`,`Revisar y corregir problemas`,`Añadir cobertura de pruebas`,`Publicar`],ru:[`Продолжить`,`Подведи итог`,`Объясни подробно`,`Проверь и исправь проблемы`,`Добавь покрытие тестами`,`Опубликовать`],pt:[`Continuar`,`Resumir`,`Explique em detalhes`,`Verifique e corrija os problemas`,`Adicione cobertura de testes`,`Publique a release`]},C_=[`soul`,`tools`,`guidelines`,`pi_docs`,`append`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`],w_=[`tools`,`pi_docs`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`];function T_(e){return w_.includes(e)}var E_=C_.map(e=>`{{${e}}}`).join(`
|
|
360
360
|
|
|
361
|
-
`),D_=/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uac00-\ud7af]/gu;function O_(e){if(!e)return 0;let t=e.match(D_)?.length??0;return Math.ceil(t+(e.length-t)/4)}var k_=lr.filter(e=>e.group===`other`&&e.name!==`todo_list`),A_=`pi-web-ui:catalog-sync-urls`,j_=8;function M_(){try{let e=localStorage.getItem(A_);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim()!==``).slice(0,j_):[]}catch{return[]}}function N_(e){let t=e.trim();if(!t)return M_();let n=[t,...M_().filter(e=>e!==t)].slice(0,j_);try{localStorage.setItem(A_,JSON.stringify(n))}catch{}return n}function P_(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function F_(e){return e===`append`?0:T_(e)?2:1}function I_({title:e,subtitle:t,tip:n,enabled:r,onToggle:i,action:a,disabled:o}){let s=Z();return(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,n&&(0,X.jsx)(bc,{text:n})]}),t&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:t})]}),a,(0,X.jsx)(`button`,{type:`button`,className:`set-switch ${r?`on`:``}`,role:`switch`,"aria-checked":r,disabled:o,title:s(r?`settingsEnabled`:`settingsDisabled`),onClick:o?void 0:i,children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})}function L_(e){return e===`active`?`pluginPhaseActive`:e===`disabled`?`pluginPhaseDisabled`:e===`failed`?`pluginPhaseFailed`:`pluginPhaseIdle`}function R_({phase:e,label:t}){return(0,X.jsx)(`span`,{className:`inv-dot inv-dot-${e}`,title:t,"aria-label":t})}function z_({plugins:e,disabledIds:t}){let n=Z(),r=x_(e,t),i={active:n(`pluginPhaseActive`),disabled:n(`pluginPhaseDisabled`),failed:n(`pluginPhaseFailed`),idle:n(`pluginPhaseIdle`)};return(0,X.jsx)(`div`,{className:`set-note inv-strip`,children:[`active`,`disabled`,`failed`,`idle`].map(e=>(0,X.jsxs)(`span`,{className:`inv-item`,title:i[e],children:[(0,X.jsx)(R_,{phase:e,label:i[e]}),r[e]]},e))})}function B_({label:e,tip:t,htmlFor:n,children:r}){return(0,X.jsxs)(`div`,{className:`set-row set-field-row`,children:[(0,X.jsxs)(`label`,{className:`set-row-name`,htmlFor:n,children:[e,t&&(0,X.jsx)(bc,{text:t})]}),r]})}function V_({pluginId:e}){let t=Z(),[n,r]=(0,m.useState)(`all`),i=ws(e),a=n===`all`?i:i.filter(e=>e.level===n);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-log-filter`,children:[(0,X.jsx)(`span`,{className:`set-log-filter-label`,children:t(`pluginLogLevel`)}),[`all`,...gs].map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-log-filter-btn${n===e?` on`:``}`,onClick:()=>r(e),children:e===`all`?t(`pluginLogAll`):e.toUpperCase()},e)),(0,X.jsxs)(`button`,{type:`button`,className:`set-log-clear`,title:t(`pluginLogClear`),onClick:()=>$(vs(e)),children:[(0,X.jsx)(R,{}),t(`pluginLogClear`)]})]}),a.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:t(`pluginLogEmpty`)}):(0,X.jsx)(`ul`,{className:`set-diag-list set-log-list`,children:a.map((t,n)=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`set-log-time`,children:new Date(t.ts).toLocaleTimeString()}),` `,(0,X.jsx)(`span`,{className:`set-log-level lv-${t.level}`,children:t.level.toUpperCase()}),` `,(0,X.jsx)(`span`,{className:`set-log-text`,children:t.text})]},`${e}-${t.ts}-${n}`))})]})}function H_(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}var U_=1e4;function W_({chat:e,terminal:t,initialSection:n,onSwitchToTerminal:r,onClose:i,sound:a,onSoundChange:o,tts:s,onTtsChange:c}){let l=Z(),{locale:u}=pn(),d=e=>l(e),f=e.settings,[p,h]=(0,m.useState)({}),g=(0,m.useMemo)(()=>{if(!f)return null;if(Object.keys(p).length===0)return f;let e={...f};for(let[t,{value:n}]of Object.entries(p))e[t]=n;return e},[f,p]);(0,m.useEffect)(()=>{f&&h(e=>{if(Object.keys(e).length===0)return e;let t={},n=Date.now();for(let[r,{value:i,at:a}]of Object.entries(e))!H_(f[r],i)&&n-a<U_&&(t[r]={value:i,at:a});return Object.keys(t).length===Object.keys(e).length?e:t})},[f]);let _=g?.approvalPolicy,{engine:v,managed:y}=ia(),b=v===`dsh`,[x,S]=(0,m.useState)(n??`prompt`),[C,w]=(0,m.useState)(`market`),T=(0,m.useRef)(null);(0,m.useEffect)(()=>{T.current?.scrollTo({top:0})},[x]);let E=(0,m.useRef)(null);(0,m.useEffect)(()=>{E.current?.querySelector(`.settings-tab.active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[x]),(0,m.useEffect)(()=>{x===`plugins`&&b&&$({type:`dsh_patches_list`})},[x,b]),(0,m.useEffect)(()=>{$({type:`get_settings`})},[e.state?.cwd,e.activeConversationId]);let[D,O]=(0,m.useState)(``),[k,A]=(0,m.useState)({}),ee=(0,m.useRef)(!1),j=(0,m.useRef)(null),L=[...C_].sort((e,t)=>F_(e)-F_(t)),[z,B]=(0,m.useState)(null),[V,ne]=(0,m.useState)({}),[ie,ae]=(0,m.useState)(``),[oe,le]=(0,m.useState)(`append`),ue=(0,m.useRef)(!1),[fe,pe]=(0,m.useState)(``),[me,he]=(0,m.useState)(`append`),ge=(0,m.useRef)(!1),[_e,ve]=(0,m.useState)(``),K=(0,m.useRef)(!1),[q,ye]=(0,m.useState)(``),[J,be]=(0,m.useState)(null),[xe,Ce]=(0,m.useState)(!1),[we,Ee]=(0,m.useState)(null),[De,Y]=(0,m.useState)(null),[Ae,Ne]=(0,m.useState)(!1),[Fe,Re]=(0,m.useState)(``),[ze,Be]=(0,m.useState)(null),[He,Ue]=(0,m.useState)(null),[We,Ge]=(0,m.useState)(null),[qe,Ye]=(0,m.useState)(!1),[Xe,Ze]=(0,m.useState)(!1),$e=(0,m.useMemo)(()=>O_(g?.effectiveSystemPrompt??``),[g?.effectiveSystemPrompt]),et=(0,m.useMemo)(()=>O_(g?.toolsSchema??``),[g?.toolsSchema]),tt=$e+et,nt=Ug(),rt=fd(),ot=e_(),st=v_(),[ct,lt]=(0,m.useState)(st.url),ut=(0,m.useRef)(!1),ft=(0,m.useRef)(null),[pt,mt]=(0,m.useState)(!1),[ht,gt]=(0,m.useState)(!1);(0,m.useEffect)(()=>{ut.current||lt(st.url.startsWith(`data:`)?``:st.url)},[st.url]);let _t=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){mt(!0),gt(!1);try{let e=await d_(t),n=e?o_(e):``;if(!n){gt(!0);return}lt(``),p_({...st,url:n})}finally{mt(!1)}}},[vt,yt]=(0,m.useState)(()=>vm()),[bt,xt]=(0,m.useState)(()=>{try{return Sm().length}catch{return 0}}),[St,Ct]=(0,m.useState)(!1),wt=()=>{try{xt(Sm().length)}catch{xt(0)}};(0,m.useEffect)(()=>{x===`prompt-history`&&wt()},[x]),(0,m.useEffect)(()=>{if(!St)return;let e=window.setTimeout(()=>Ct(!1),3e3);return()=>window.clearTimeout(e)},[St]);let[Tt,Et]=(0,m.useState)(null),[Dt,Ot]=(0,m.useState)(null),[kt,At]=(0,m.useState)(null),[jt,Mt]=(0,m.useState)(null),[Nt,Pt]=(0,m.useState)({}),[,Ft]=(0,m.useState)(0);(0,m.useEffect)(()=>Cs(()=>Ft(e=>e+1)),[]);let[It,Lt]=(0,m.useState)(``),[Rt,Bt]=(0,m.useState)(``),[Vt,Ht]=(0,m.useState)(``),[Ut,Wt]=(0,m.useState)(``),[Gt,Kt]=(0,m.useState)(``),[qt,Jt]=(0,m.useState)(!1),[Yt,Xt]=(0,m.useState)(!1),[Zt,Qt]=(0,m.useState)(!1),[$t,en]=(0,m.useState)(``),[tn,nn]=(0,m.useState)(!1),[rn,an]=(0,m.useState)(!1),[on,sn]=(0,m.useState)(null),[cn,ln]=(0,m.useState)(``),[un,dn]=(0,m.useState)(()=>M_()),[fn,mn]=(0,m.useState)(``),[gn,vn]=(0,m.useState)(null);(0,m.useEffect)(()=>{g&&(ee.current||O(g.promptTemplate??``),A(e=>{let t={};for(let[e,n]of Object.entries(g.promptOverrides??{}))t[e]=n??``;return j.current&&(t[j.current]=e[j.current]??``),t}),le(g.visionBridgePromptMode),!ue.current&&(ae(oe===`append`||g.visionBridgePrompt?g.visionBridgePrompt:g.visionBridgeDefaultPrompt||``),he(g.scmCommitMsgPromptMode),ge.current||pe(g.scmCommitMsgPromptMode===`append`||g.scmCommitMsgPrompt?g.scmCommitMsgPrompt:g.scmCommitMsgDefaultPrompt||``),K.current||ve(g.reviewPrompt)))},[g,oe,me]);let[yn,bn]=(0,m.useState)(String(g?.terminalBashIdleMs??15e3));(0,m.useEffect)(()=>{bn(String(g?.terminalBashIdleMs??15e3))},[g?.terminalBashIdleMs]);let[xn,Sn]=(0,m.useState)(String(g?.terminalBashMaxForegroundMs??6e4));(0,m.useEffect)(()=>{Sn(String(g?.terminalBashMaxForegroundMs??6e4))},[g?.terminalBashMaxForegroundMs]);let[Cn,wn]=(0,m.useState)(String(Math.round((g?.toolWatchdogTimeoutMs??12e5)/6e4)));(0,m.useEffect)(()=>{wn(String(Math.round((g?.toolWatchdogTimeoutMs??12e5)/6e4)))},[g?.toolWatchdogTimeoutMs]);let[Tn,En]=(0,m.useState)(String(g?.retryMaxAttempts??6));(0,m.useEffect)(()=>{En(String(g?.retryMaxAttempts??6))},[g?.retryMaxAttempts]);let[Dn,On]=(0,m.useState)(g?.softCapTokens&&g.softCapTokens>0?Ng(g.softCapTokens):``);(0,m.useEffect)(()=>{On(g?.softCapTokens&&g.softCapTokens>0?Ng(g.softCapTokens):``)},[g?.softCapTokens]);let[kn,An]=(0,m.useState)(``),[jn,Mn]=(0,m.useState)(``),Nn=[],Pn=xi(ui(e.plugins),{locale:u,t:e=>l(e),disabledPlugins:e.settings?.disabledPlugins??[],layout:e.settings?.uiLayout,diagnostics:Nn}),Fn=[];for(let t of Pn[`settings.pages`]){if(t.source===`host`||t.hidden||t.kind===`divider`)continue;let n=e.plugins.find(e=>e.id===t.source.slice(7));n&&Fn.push({entry:t,plugin:n})}let In=e=>`plugin-page:${e}`;if((0,m.useEffect)(()=>{x.startsWith(`plugin-page:`)&&(Fn.some(e=>In(e.entry.id)===x)||S(`prompt`))},[x,Fn]),!g)return null;let Ln=new Set(g.disabledAgentTools??[]),Rn=Ln.size,zn=b?null:e.dshPresets?.defaultPreset??null,Bn=!!zn&&zn!==`standard`,Vn=Bn?new Set(dr([...lr.map(e=>e.name),`bash`,`read`,`edit`,`write`],zn??void 0)):new Set(lr.map(e=>e.name)),Hn=e.dshPresets?.presets.find(e=>e.id===zn)?.name??zn??``,Un=e=>Bn&&!Vn.has(e),Wn=Bn?lr.filter(e=>!Vn.has(e.name)).length:0,Gn=Bn?e.plugins.flatMap(e=>e.agentTools??[]).filter(e=>!(g.disabledPluginTools??[]).includes(e.name)).length:0,Jn=e.pluginUpdates,Yn=Object.values(Jn??{}).some(e=>e.updatable&&(e.builtin??!1)),Xn=Object.values(Jn??{}).some(e=>e.updatable),Zn=[{id:`prompt`,icon:(0,X.jsx)(je,{}),label:l(`settingsSystemPrompt`)},{id:`prompt-history`,icon:(0,X.jsx)(Ve,{}),label:l(`settingsPromptHistory`),count:bt},...b?[]:[{id:`scheduler`,icon:(0,X.jsx)(Ve,{}),label:l(`settingsScheduler`),count:e.schedulerTasks.length||void 0}],...b?[{id:`question`,icon:(0,X.jsx)(Te,{}),label:l(`settingsQuestionnaire`)}]:[{id:`tools`,icon:(0,X.jsx)(te,{}),label:l(`settingsTools`),count:Rn+(g.disabledMarkers?.length??0)||void 0},{id:`approval-rules`,icon:(0,X.jsx)(H,{}),label:l(`settingsApprovalRules`),count:(g.approvalRules??[]).length||void 0}],{id:`display`,icon:(0,X.jsx)(G,{}),label:l(`settingsMessageDisplay`)},{id:`sound`,icon:(0,X.jsx)(P,{}),label:l(`settingsSoundVoice`)},{id:`quick`,icon:(0,X.jsx)(W,{}),label:l(`quickPhrases`),count:g.quickPhrases.length},{id:`skills`,icon:(0,X.jsx)(Le,{}),label:l(`settingsSkills`),count:g.skills.length},{id:`extensions`,icon:(0,X.jsx)(de,{}),label:l(`settingsExtensions`),count:g.extensions.length},{id:`plugins`,icon:(0,X.jsx)(Qe,{}),label:l(`settingsUiPlugins`),count:e.plugins.length,dot:Yn||Xn},{id:`layout`,icon:(0,X.jsx)(re,{}),label:l(`uiLayoutTitle`)},{id:`review`,icon:(0,X.jsx)(M,{}),label:l(`settingsReview`),count:g.reviewSkills.length},...b?[]:[{id:`vision`,icon:(0,X.jsx)(Me,{}),label:l(`settingsVisionBridge`)}],{id:`presets`,icon:(0,X.jsx)(re,{}),label:l(`settingsPresets`),count:g.presets.length},...b?[]:[{id:`subagent-templates`,icon:(0,X.jsx)(F,{}),label:l(`settingsSubagentTemplates`),count:g.subagentTemplates.length}],...Fn.map(e=>({id:In(e.entry.id),icon:e.entry.iconSvg?(0,X.jsx)(Gr,{iconSvg:e.entry.iconSvg}):e.entry.icon&&!/[a-z]/i.test(e.entry.icon)?(0,X.jsx)(`span`,{children:e.entry.icon}):(0,X.jsx)(Qe,{}),label:e.entry.label,pluginPage:{plugin:e.plugin,entry:e.entry}}))],Qn=x.startsWith(`plugin-page:`)?Fn.find(e=>In(e.entry.id)===x)??null:null,$n=new Set(g.disabledSkills),er=new Set(g.disabledExtensions),Q=e=>{let t=Date.now();h(n=>{let r={...n};for(let[n,i]of Object.entries(e))r[n]={value:i,at:t};return r}),$({type:`set_settings`,...e})},tr=()=>{if(!gn||!g)return;let e=gn.value.trim(),t=gn.index;if(vn(null),!e||e===g.quickPhrases[t])return;let n=[...g.quickPhrases];n[t]=e,Q({quickPhrases:n})},nr=e=>{let t=new Set($n);t.has(e.name)?t.delete(e.name):t.add(e.name),Q({disabledSkills:[...t]})},rr=new Set(g.skillsFullText??[]),ir=e=>{let t=new Set(rr);t.has(e)?t.delete(e):t.add(e),Q({skillsFullText:[...t]})},ar=new Set(g.disabledPlugins??[]),or=new Set(e.plugins.map(e=>e.id)),sr=e=>{let t=new Set(ar);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledPlugins:[...t]})},cr=e=>{let t=new Set(er);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledExtensions:[...t]})},pr={subagent_spawn:l(`toolDescSubagentSpawn`),subagent_get_result:l(`toolDescSubagentGetResult`),subagent_steer:l(`toolDescSubagentSteer`),subagent_list:l(`toolDescSubagentList`),subagent_stop:l(`toolDescSubagentStop`),subagent_wait_all:l(`toolDescSubagentWaitAll`),subagent_templates:l(`toolDescSubagentTemplates`)},mr={bash:l(`toolCoreBashDesc`),read:l(`toolCoreReadDesc`),edit:l(`toolCoreEditDesc`),write:l(`toolCoreWriteDesc`)},hr=e=>{let t=new Set(Ln);t.has(e)?t.delete(e):t.add(e),Q({disabledAgentTools:[...t]})},gr=new Set(g.disabledPluginTools??[]),_r=e=>{let t=new Set(gr);t.has(e)?t.delete(e):t.add(e),Q({disabledPluginTools:[...t]})},vr=e.plugins.map(e=>({plugin:e,tools:[...e.agentTools??[]].sort((e,t)=>e.name.localeCompare(t.name))})).filter(e=>e.tools.length>0),yr=g.markersEnabled??!0,br=new Set(g.disabledMarkers??[]),xr=e=>{let t=new Set(br);t.has(e)?t.delete(e):t.add(e),Q({disabledMarkers:[...t]})},Sr=(n,a)=>{let o={name:n,command:a,cwd:"${pwd}"},s,c=e.terminals.find(e=>e.title===n);c?(t.restart(c.id),$({type:`run_command`,terminalId:c.id,conversationId:c.conversationId,command:o,cols:80,rows:24}),s=c.id):(s=dt(),t.create({id:s,conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:o})),t.select(s),r(),i()},Cr=e=>{Et(null),Sr(`${l(`uninstallTitle`)} ${e}`,`pi remove npm:${e}`)},wr=(e,t,n)=>{$({type:`plugin_job`,jobId:dt(),action:e,id:t,...n?{source:n}:{},...e!==`uninstall`&&Yt?{build:!0}:{}})},Tr=t=>{let n=null;for(let r of Object.values(e.pluginJobs??{}))r.pluginId===t&&(!n||r.startedAt>=n.startedAt)&&(n=r);return n},Er=e=>e?e.problem===`already-installed`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:l(`pluginInspectAlreadyInstalled`,{id:e.suggestedId})}):e.problem===`network`?(0,X.jsx)(`div`,{className:`set-catalog-hint`,"data-problem":e.problem,children:l(`pluginInspectNetwork`)}):e.problem===`invalid-spec`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:l(`pluginInspectInvalid`)}):e.problem===`not-found`||e.problem===`not-a-package`||e.problem===`not-a-bundle`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:l(`pluginInspectNotPlugin`)}):e.problem?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,children:e.detail}):e.manifest?(0,X.jsxs)(`div`,{className:`set-catalog-hint ok`,"data-problem":`ok`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`✓ `}),e.manifest.name??e.manifest.id??e.suggestedId,e.manifest.version?` v${e.manifest.version}`:``,e.manifest.description?` · ${e.manifest.description}`:``]}):null:null,Dr=e=>{let t=Tr(e);if(!t)return null;if(t.phase!==`done`){let e=t.lines[t.lines.length-1]??``;return(0,X.jsxs)(`div`,{className:`set-catalog-job running`,title:e,children:[(0,X.jsx)(se,{className:`set-job-spin`}),l(`pluginJobRunning`),(0,X.jsx)(`span`,{className:`set-catalog-job-line`,children:e})]})}return t.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[`✓ `,l(`pluginJobDone`)]}):(0,X.jsxs)(`div`,{className:`set-catalog-job error`,children:[(0,X.jsxs)(`span`,{children:[`✗ `,t.error||l(`pluginJobFailed`)]}),t.output?(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:t.output}):null]})},Or=[{slot:`topbar.primary`,labelKey:`uiLayoutTopbar`},{slot:`topbar.overflow`,labelKey:`uiLayoutTopbarOverflow`},{slot:`notice.actions`,labelKey:`uiLayoutNotice`},{slot:`leftpanel.sessions`,labelKey:`uiLayoutLeftSessions`},{slot:`chat.header`,labelKey:`uiLayoutChatHeader`},{slot:`chat.empty`,labelKey:`uiLayoutChatEmpty`},{slot:`message.actions`,labelKey:`uiLayoutMessage`},{slot:`goalbar.actions`,labelKey:`uiLayoutGoalbar`},{slot:`composer.leading`,labelKey:`uiLayoutComposerLeading`},{slot:`composer.actions`,labelKey:`uiLayoutComposer`},{slot:`rightpanel.tabs`,labelKey:`uiLayoutRightPanel`},{slot:`terminal.toolbar`,labelKey:`uiLayoutTerminal`},{slot:`scm.toolbar`,labelKey:`uiLayoutScm`},{slot:`bottombar`,labelKey:`uiLayoutBottombar`},{slot:`file.preview.toolbar`,labelKey:`uiLayoutFilePreview`},{slot:`contextmenu.topbar`,labelKey:`uiLayoutContextTopbar`},{slot:`contextmenu.message`,labelKey:`uiLayoutContextMessage`},{slot:`contextmenu.session`,labelKey:`uiLayoutContextSession`},{slot:`contextmenu.file`,labelKey:`uiLayoutContextFile`},{slot:`contextmenu.toolcall`,labelKey:`uiLayoutContextToolcall`},{slot:`settings.pages`,labelKey:`uiLayoutSettingsPages`},{slot:`modal.dialog`,labelKey:`uiLayoutModal`}],kr=[`bottombar`,`composer.actions`,`topbar.primary`],[Ar,jr]=(0,m.useState)(``),Mr=e=>{let t=Or.find(t=>t.slot===e);return t?l(t.labelKey):e},Nr=e.settings?.uiLayout,Pr=e=>Q({uiLayout:{...Nr,...e}}),Fr=e=>{let t=new Set(Nr?.hidden??[]),n=new Set(Nr?.shown??[]);e.hidden?(t.delete(e.id),n.add(e.id)):(t.add(e.id),n.delete(e.id)),Pr({hidden:[...t],shown:[...n]})},Ir=(e,t,n,r)=>{let i=t.map(e=>e.id),a=i.indexOf(n),o=a+r;if(a<0||o<0||o>=i.length)return;let s=[...i],[c]=s.splice(a,1);if(c===void 0)return;s.splice(o,0,c);let l=new Set(i),u=[...s],d=e.map(e=>l.has(e.id)?u.shift():e.id),f=new Set(e.map(e=>e.id)),p=(Nr?.order??[]).filter(e=>!f.has(e));Pr({order:[...p,...d]})},Lr=(e,t)=>{(t===`start`||t===`center`||t===`end`)&&Pr({align:{...Nr?.align,[e]:t}})},Rr=(e,t)=>{let n={...Nr?.labels},r=t.trim().slice(0,60);r?n[e]=r:delete n[e],Pr({labels:n})},zr=e=>Q({uiLayout:Ti(Nr,e)}),Br=()=>Q({uiLayout:Ei()}),Vr=e=>{Ot(null),wr(`uninstall`,e)},Hr=(e,t)=>{wr(`update`,e,t)},Ur=e=>{wr(`install`,e.id,e.source)},Wr=e=>{$({type:`plugin_catalog_remove`,id:e})},Kr=()=>{let e=It.trim();e&&($({type:`plugin_catalog_add`,entry:{source:e,...Rt.trim()?{id:Rt.trim()}:{},...Vt.trim()?{name:Vt.trim()}:{},...Ut.trim()?{description:Ut.trim()}:{},...Gt.trim()?{icon:Gt.trim()}:{}}}),Lt(``),Bt(``),Ht(``),Wt(``),Kt(``),Jt(!1))},qr=e=>{let t=e.trim();if(!t)return;let n=dt();sn(n),ln(t),$({type:`plugin_catalog_sync`,requestId:n,source:t,...tn?{install:!0}:{},...rn?{replace:!0}:{}})},[Jr,Yr]=(0,m.useState)(``);(0,m.useEffect)(()=>{let e=It.trim();if(!e){Yr(``);return}let t=setTimeout(()=>{let t=dt();Yr(t),$({type:`plugin_install_inspect`,requestId:t,source:e,...Rt.trim()?{explicitId:Rt.trim()}:{}})},500);return()=>clearTimeout(t)},[It,Rt]);let Xr=e.installInspect,Zr=Xr&&Xr.requestId===Jr&&Xr.source===It.trim()?Xr:null,Qr=e.catalogSync&&e.catalogSync.requestId===on?e.catalogSync:null;(0,m.useEffect)(()=>{Qr?.ok&&cn&&dn(N_(cn))},[Qr?.requestId,Qr?.ok]);let $r=e=>{let t=new Set(g.reviewSkills.filter(e=>!e.enabled).map(e=>e.name));t.has(e.name)?t.delete(e.name):t.add(e.name),Q({reviewDisabledSkills:[...t]})},ei=()=>Q({promptTemplate:D}),ri=e=>{Q({promptOverrides:{[e]:k[e]??``}})},ii=e=>{j.current===e&&(j.current=null),B(null),A(t=>{let n={...t};return delete n[e],n}),Q({promptOverrides:{[e]:``}})},ai=e=>ne(t=>({...t,[e]:!t[e]})),oi=(e,t)=>{A(n=>({...n,[e]:t})),B(e)},si=()=>{ee.current=!1,j.current=null,O(E_),A({}),Q({promptTemplate:E_,promptOverrides:{}})},ci=e=>{O(t=>t.trim()?`${t}\n\n{{${e}}}`:`{{${e}}}`)},li=D.trim()&&D.trim()!==E_||Object.values(k).some(e=>e.trim());return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:i,children:(0,X.jsxs)(`div`,{className:`modal settings-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":l(`close`),onClick:i,children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(U,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:l(`settingsTitle`)}),(0,X.jsx)(bc,{text:l(`settingsDesc`)})]}),(0,X.jsxs)(`div`,{className:`settings-layout`,children:[(0,X.jsx)(`nav`,{className:`settings-rail`,"aria-label":l(`settingsTitle`),ref:E,children:Zn.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-tab":e.id,className:`settings-tab${x===e.id?` active`:``}`,"aria-current":x===e.id?`true`:void 0,title:e.hint??e.label,onClick:()=>S(e.id),children:[(0,X.jsx)(`span`,{className:`settings-tab-icon`,children:e.icon}),(0,X.jsx)(`span`,{className:`settings-tab-label`,children:e.label}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`set-count`,children:e.count}),e.dot&&(0,X.jsx)(`span`,{className:`update-dot`,style:{marginLeft:4}})]},e.id))}),(0,X.jsxs)(`div`,{className:`modal-body`,ref:T,children:[x===`prompt`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(M,{className:`set-section-icon`}),l(`settingsSystemPrompt`),(0,X.jsx)(bc,{text:`${l(`promptComposeHint`)}\n${l(`promptComposeDesc`)}`})]}),(0,X.jsxs)(`div`,{className:`set-prompt-view-triggers`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":qe,onClick:()=>Ye(e=>!e),children:[(0,X.jsx)(`span`,{children:l(`settingsViewPrompt`)}),$e>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:l(`settingsViewPromptTokens`,{n:$e.toLocaleString()})}),(0,X.jsx)(`span`,{children:qe?`▴`:`▾`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":Xe,onClick:()=>Ze(e=>!e),children:[(0,X.jsx)(`span`,{children:l(`settingsViewToolsSchema`)}),et>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:l(`settingsViewPromptTokens`,{n:et.toLocaleString()})}),(0,X.jsx)(`span`,{children:Xe?`▴`:`▾`})]}),tt>0&&(0,X.jsx)(`span`,{className:`set-prompt-total-est`,children:l(`settingsPromptContextTotal`,{n:tt.toLocaleString()})})]}),qe&&(0,X.jsxs)(`div`,{className:`set-prompt-view`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:l(`settingsViewPrompt`)}),(0,X.jsx)(bc,{text:l(`settingsViewPromptHint`)}),(0,X.jsx)(gl,{text:g.effectiveSystemPrompt})]}),g.effectiveSystemPrompt?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:g.effectiveSystemPrompt}):(0,X.jsx)(`p`,{className:`set-empty`,children:l(`settingsViewPromptEmpty`)})]}),Xe&&(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:l(`settingsViewToolsSchema`)}),(0,X.jsx)(bc,{text:l(`settingsViewToolsSchemaHint`)}),(0,X.jsx)(gl,{text:g.toolsSchema})]}),g.toolsSchema?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:g.toolsSchema}):(0,X.jsx)(`p`,{className:`set-empty`,children:l(`settingsViewToolsSchemaEmpty`)})]})}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`promptTemplateLabel`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:6,spellCheck:!1,placeholder:E_,value:D,onFocus:()=>ee.current=!0,onBlur:()=>{ee.current=!1,ei()},onChange:e=>O(e.target.value)}),(0,X.jsxs)(`div`,{className:`compose-toolbar`,children:[(0,X.jsx)(`span`,{className:`set-field-label set-muted`,children:l(`promptInsertTokens`)}),L.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`token-chip`,title:d(`promptTok_${e}_desc`),onClick:()=>ci(e),children:`{{${e}}}`},e))]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`promptSourcesLabel`)}),L.map(e=>{let t=k[e]??``,n=g.promptSourceDefaults?.[e]??``,r=z===e,i=n.split(`
|
|
361
|
+
`),D_=/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uac00-\ud7af]/gu;function O_(e){if(!e)return 0;let t=e.match(D_)?.length??0;return Math.ceil(t+(e.length-t)/4)}var k_=lr.filter(e=>e.group===`other`&&e.name!==`todo_list`),A_=`pi-web-ui:catalog-sync-urls`,j_=8;function M_(){try{let e=localStorage.getItem(A_);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim()!==``).slice(0,j_):[]}catch{return[]}}function N_(e){let t=e.trim();if(!t)return M_();let n=[t,...M_().filter(e=>e!==t)].slice(0,j_);try{localStorage.setItem(A_,JSON.stringify(n))}catch{}return n}function P_(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function F_(e){return e===`append`?0:T_(e)?2:1}function I_({title:e,subtitle:t,tip:n,enabled:r,onToggle:i,action:a,disabled:o}){let s=Z();return(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,n&&(0,X.jsx)(bc,{text:n})]}),t&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:t})]}),a,(0,X.jsx)(`button`,{type:`button`,className:`set-switch ${r?`on`:``}`,role:`switch`,"aria-checked":r,disabled:o,title:s(r?`settingsEnabled`:`settingsDisabled`),onClick:o?void 0:i,children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})}function L_(e){return e===`active`?`pluginPhaseActive`:e===`disabled`?`pluginPhaseDisabled`:e===`failed`?`pluginPhaseFailed`:`pluginPhaseIdle`}function R_({phase:e,label:t}){return(0,X.jsx)(`span`,{className:`inv-dot inv-dot-${e}`,title:t,"aria-label":t})}function z_({plugins:e,disabledIds:t}){let n=Z(),r=x_(e,t),i={active:n(`pluginPhaseActive`),disabled:n(`pluginPhaseDisabled`),failed:n(`pluginPhaseFailed`),idle:n(`pluginPhaseIdle`)};return(0,X.jsx)(`div`,{className:`set-note inv-strip`,children:[`active`,`disabled`,`failed`,`idle`].map(e=>(0,X.jsxs)(`span`,{className:`inv-item`,title:i[e],children:[(0,X.jsx)(R_,{phase:e,label:i[e]}),r[e]]},e))})}function B_({label:e,tip:t,htmlFor:n,children:r}){return(0,X.jsxs)(`div`,{className:`set-row set-field-row`,children:[(0,X.jsxs)(`label`,{className:`set-row-name`,htmlFor:n,children:[e,t&&(0,X.jsx)(bc,{text:t})]}),r]})}function V_({pluginId:e}){let t=Z(),[n,r]=(0,m.useState)(`all`),i=ws(e),a=n===`all`?i:i.filter(e=>e.level===n);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-log-filter`,children:[(0,X.jsx)(`span`,{className:`set-log-filter-label`,children:t(`pluginLogLevel`)}),[`all`,...gs].map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-log-filter-btn${n===e?` on`:``}`,onClick:()=>r(e),children:e===`all`?t(`pluginLogAll`):e.toUpperCase()},e)),(0,X.jsxs)(`button`,{type:`button`,className:`set-log-clear`,title:t(`pluginLogClear`),onClick:()=>$(vs(e)),children:[(0,X.jsx)(R,{}),t(`pluginLogClear`)]})]}),a.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:t(`pluginLogEmpty`)}):(0,X.jsx)(`ul`,{className:`set-diag-list set-log-list`,children:a.map((t,n)=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`set-log-time`,children:new Date(t.ts).toLocaleTimeString()}),` `,(0,X.jsx)(`span`,{className:`set-log-level lv-${t.level}`,children:t.level.toUpperCase()}),` `,(0,X.jsx)(`span`,{className:`set-log-text`,children:t.text})]},`${e}-${t.ts}-${n}`))})]})}function H_(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}var U_=1e4;function W_({chat:e,terminal:t,initialSection:n,onSwitchToTerminal:r,onClose:i,sound:a,onSoundChange:o,tts:s,onTtsChange:c}){let l=Z(),{locale:u}=pn(),d=e=>l(e),f=e.settings,[p,h]=(0,m.useState)({}),g=(0,m.useMemo)(()=>{if(!f)return null;if(Object.keys(p).length===0)return f;let e={...f};for(let[t,{value:n}]of Object.entries(p))e[t]=n;return e},[f,p]);(0,m.useEffect)(()=>{f&&h(e=>{if(Object.keys(e).length===0)return e;let t={},n=Date.now();for(let[r,{value:i,at:a}]of Object.entries(e))!H_(f[r],i)&&n-a<U_&&(t[r]={value:i,at:a});return Object.keys(t).length===Object.keys(e).length?e:t})},[f]);let _=g?.approvalPolicy,{engine:v,managed:y}=ia(),b=v===`dsh`,[x,S]=(0,m.useState)(n??`prompt`),[C,w]=(0,m.useState)(`market`),T=(0,m.useRef)(null);(0,m.useEffect)(()=>{T.current?.scrollTo({top:0})},[x]);let E=(0,m.useRef)(null);(0,m.useEffect)(()=>{E.current?.querySelector(`.settings-tab.active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[x]),(0,m.useEffect)(()=>{x===`plugins`&&b&&$({type:`dsh_patches_list`})},[x,b]),(0,m.useEffect)(()=>{$({type:`get_settings`})},[e.state?.cwd,e.activeConversationId]);let[D,O]=(0,m.useState)(``),[k,A]=(0,m.useState)({}),ee=(0,m.useRef)(!1),j=(0,m.useRef)(null),L=[...C_].sort((e,t)=>F_(e)-F_(t)),[z,B]=(0,m.useState)(null),[V,ne]=(0,m.useState)({}),[re,ie]=(0,m.useState)(``),[ae,ce]=(0,m.useState)(`append`),le=(0,m.useRef)(!1),[de,fe]=(0,m.useState)(``),[pe,me]=(0,m.useState)(`append`),he=(0,m.useRef)(!1),[ge,_e]=(0,m.useState)(``),ve=(0,m.useRef)(!1),[q,ye]=(0,m.useState)(``),[J,be]=(0,m.useState)(null),[xe,Ce]=(0,m.useState)(!1),[we,Ee]=(0,m.useState)(null),[Y,ke]=(0,m.useState)(null),[Ae,Ne]=(0,m.useState)(!1),[Fe,Re]=(0,m.useState)(``),[ze,Be]=(0,m.useState)(null),[He,Ue]=(0,m.useState)(null),[We,Ge]=(0,m.useState)(null),[qe,Ye]=(0,m.useState)(!1),[Xe,Ze]=(0,m.useState)(!1),$e=(0,m.useMemo)(()=>O_(g?.effectiveSystemPrompt??``),[g?.effectiveSystemPrompt]),et=(0,m.useMemo)(()=>O_(g?.toolsSchema??``),[g?.toolsSchema]),tt=$e+et,nt=Ug(),rt=fd(),ot=e_(),st=v_(),[ct,lt]=(0,m.useState)(st.url),ut=(0,m.useRef)(!1),ft=(0,m.useRef)(null),[pt,mt]=(0,m.useState)(!1),[ht,gt]=(0,m.useState)(!1);(0,m.useEffect)(()=>{ut.current||lt(st.url.startsWith(`data:`)?``:st.url)},[st.url]);let _t=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){mt(!0),gt(!1);try{let e=await d_(t),n=e?o_(e):``;if(!n){gt(!0);return}lt(``),p_({...st,url:n})}finally{mt(!1)}}},[vt,yt]=(0,m.useState)(()=>vm()),[bt,xt]=(0,m.useState)(()=>{try{return Sm().length}catch{return 0}}),[St,Ct]=(0,m.useState)(!1),wt=()=>{try{xt(Sm().length)}catch{xt(0)}};(0,m.useEffect)(()=>{x===`prompt-history`&&wt()},[x]),(0,m.useEffect)(()=>{if(!St)return;let e=window.setTimeout(()=>Ct(!1),3e3);return()=>window.clearTimeout(e)},[St]);let[Tt,Et]=(0,m.useState)(null),[Dt,Ot]=(0,m.useState)(null),[kt,At]=(0,m.useState)(null),[jt,Mt]=(0,m.useState)(null),[Nt,Pt]=(0,m.useState)({}),[,Ft]=(0,m.useState)(0);(0,m.useEffect)(()=>Cs(()=>Ft(e=>e+1)),[]);let[It,Lt]=(0,m.useState)(``),[Rt,Bt]=(0,m.useState)(``),[Vt,Ht]=(0,m.useState)(``),[Ut,Wt]=(0,m.useState)(``),[Gt,Kt]=(0,m.useState)(``),[qt,Jt]=(0,m.useState)(!1),[Yt,Xt]=(0,m.useState)(!1),[Zt,Qt]=(0,m.useState)(!1),[$t,en]=(0,m.useState)(``),[tn,nn]=(0,m.useState)(!1),[rn,an]=(0,m.useState)(!1),[on,sn]=(0,m.useState)(null),[cn,ln]=(0,m.useState)(``),[un,dn]=(0,m.useState)(()=>M_()),[fn,mn]=(0,m.useState)(``),[gn,vn]=(0,m.useState)(null);(0,m.useEffect)(()=>{g&&(ee.current||O(g.promptTemplate??``),A(e=>{let t={};for(let[e,n]of Object.entries(g.promptOverrides??{}))t[e]=n??``;return j.current&&(t[j.current]=e[j.current]??``),t}),ce(g.visionBridgePromptMode),!le.current&&(ie(ae===`append`||g.visionBridgePrompt?g.visionBridgePrompt:g.visionBridgeDefaultPrompt||``),me(g.scmCommitMsgPromptMode),he.current||fe(g.scmCommitMsgPromptMode===`append`||g.scmCommitMsgPrompt?g.scmCommitMsgPrompt:g.scmCommitMsgDefaultPrompt||``),ve.current||_e(g.reviewPrompt)))},[g,ae,pe]);let[yn,bn]=(0,m.useState)(String(g?.terminalBashIdleMs??15e3));(0,m.useEffect)(()=>{bn(String(g?.terminalBashIdleMs??15e3))},[g?.terminalBashIdleMs]);let[xn,Sn]=(0,m.useState)(String(g?.terminalBashMaxForegroundMs??6e4));(0,m.useEffect)(()=>{Sn(String(g?.terminalBashMaxForegroundMs??6e4))},[g?.terminalBashMaxForegroundMs]);let[Cn,wn]=(0,m.useState)(String(Math.round((g?.toolWatchdogTimeoutMs??12e5)/6e4)));(0,m.useEffect)(()=>{wn(String(Math.round((g?.toolWatchdogTimeoutMs??12e5)/6e4)))},[g?.toolWatchdogTimeoutMs]);let[Tn,En]=(0,m.useState)(String(g?.retryMaxAttempts??6));(0,m.useEffect)(()=>{En(String(g?.retryMaxAttempts??6))},[g?.retryMaxAttempts]);let[Dn,On]=(0,m.useState)(g?.softCapTokens&&g.softCapTokens>0?Ng(g.softCapTokens):``);(0,m.useEffect)(()=>{On(g?.softCapTokens&&g.softCapTokens>0?Ng(g.softCapTokens):``)},[g?.softCapTokens]);let[kn,An]=(0,m.useState)(``),[jn,Mn]=(0,m.useState)(``),Nn=[],Pn=xi(ui(e.plugins),{locale:u,t:e=>l(e),disabledPlugins:e.settings?.disabledPlugins??[],layout:e.settings?.uiLayout,diagnostics:Nn}),Fn=[];for(let t of Pn[`settings.pages`]){if(t.source===`host`||t.hidden||t.kind===`divider`)continue;let n=e.plugins.find(e=>e.id===t.source.slice(7));n&&Fn.push({entry:t,plugin:n})}let In=e=>`plugin-page:${e}`;if((0,m.useEffect)(()=>{x.startsWith(`plugin-page:`)&&(Fn.some(e=>In(e.entry.id)===x)||S(`prompt`))},[x,Fn]),!g)return null;let Ln=new Set(g.disabledAgentTools??[]),Rn=Ln.size,zn=b?null:e.dshPresets?.defaultPreset??null,Bn=!!zn&&zn!==`standard`,Vn=Bn?new Set(dr([...lr.map(e=>e.name),`bash`,`read`,`edit`,`write`],zn??void 0)):new Set(lr.map(e=>e.name)),Hn=e.dshPresets?.presets.find(e=>e.id===zn)?.name??zn??``,Un=e=>Bn&&!Vn.has(e),Wn=Bn?lr.filter(e=>!Vn.has(e.name)).length:0,Gn=Bn?e.plugins.flatMap(e=>e.agentTools??[]).filter(e=>!(g.disabledPluginTools??[]).includes(e.name)).length:0,Jn=e.pluginUpdates,Yn=Object.values(Jn??{}).some(e=>e.updatable&&(e.builtin??!1)),Xn=Object.values(Jn??{}).some(e=>e.updatable),Zn=[{id:`prompt`,icon:(0,X.jsx)(je,{}),label:l(`settingsSystemPrompt`)},{id:`prompt-history`,icon:(0,X.jsx)(Ve,{}),label:l(`settingsPromptHistory`),count:bt},...b?[]:[{id:`scheduler`,icon:(0,X.jsx)(Ve,{}),label:l(`settingsScheduler`),count:e.schedulerTasks.length||void 0}],...b?[{id:`question`,icon:(0,X.jsx)(Te,{}),label:l(`settingsQuestionnaire`)}]:[{id:`tools`,icon:(0,X.jsx)(te,{}),label:l(`settingsTools`),count:Rn+(g.disabledMarkers?.length??0)||void 0},{id:`approval-rules`,icon:(0,X.jsx)(U,{}),label:l(`settingsApprovalRules`),count:(g.approvalRules??[]).length||void 0}],{id:`display`,icon:(0,X.jsx)(K,{}),label:l(`settingsMessageDisplay`)},{id:`sound`,icon:(0,X.jsx)(P,{}),label:l(`settingsSoundVoice`)},{id:`quick`,icon:(0,X.jsx)(G,{}),label:l(`quickPhrases`),count:g.quickPhrases.length},{id:`skills`,icon:(0,X.jsx)(Le,{}),label:l(`settingsSkills`),count:g.skills.length},{id:`extensions`,icon:(0,X.jsx)(ue,{}),label:l(`settingsExtensions`),count:g.extensions.length},{id:`plugins`,icon:(0,X.jsx)(Qe,{}),label:l(`settingsUiPlugins`),count:e.plugins.length,dot:Yn||Xn},{id:`layout`,icon:(0,X.jsx)(H,{}),label:l(`uiLayoutTitle`)},{id:`review`,icon:(0,X.jsx)(M,{}),label:l(`settingsReview`),count:g.reviewSkills.length},...b?[]:[{id:`vision`,icon:(0,X.jsx)(Me,{}),label:l(`settingsVisionBridge`)}],{id:`presets`,icon:(0,X.jsx)(H,{}),label:l(`settingsPresets`),count:g.presets.length},...b?[]:[{id:`subagent-templates`,icon:(0,X.jsx)(F,{}),label:l(`settingsSubagentTemplates`),count:g.subagentTemplates.length}],...Fn.map(e=>({id:In(e.entry.id),icon:e.entry.iconSvg?(0,X.jsx)(Gr,{iconSvg:e.entry.iconSvg}):e.entry.icon&&!/[a-z]/i.test(e.entry.icon)?(0,X.jsx)(`span`,{children:e.entry.icon}):(0,X.jsx)(Qe,{}),label:e.entry.label,pluginPage:{plugin:e.plugin,entry:e.entry}}))],Qn=x.startsWith(`plugin-page:`)?Fn.find(e=>In(e.entry.id)===x)??null:null,$n=new Set(g.disabledSkills),er=new Set(g.disabledExtensions),Q=e=>{let t=Date.now();h(n=>{let r={...n};for(let[n,i]of Object.entries(e))r[n]={value:i,at:t};return r}),$({type:`set_settings`,...e})},tr=()=>{if(!gn||!g)return;let e=gn.value.trim(),t=gn.index;if(vn(null),!e||e===g.quickPhrases[t])return;let n=[...g.quickPhrases];n[t]=e,Q({quickPhrases:n})},nr=e=>{let t=new Set($n);t.has(e.name)?t.delete(e.name):t.add(e.name),Q({disabledSkills:[...t]})},rr=new Set(g.skillsFullText??[]),ir=e=>{let t=new Set(rr);t.has(e)?t.delete(e):t.add(e),Q({skillsFullText:[...t]})},ar=new Set(g.disabledPlugins??[]),or=new Set(e.plugins.map(e=>e.id)),sr=e=>{let t=new Set(ar);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledPlugins:[...t]})},cr=e=>{let t=new Set(er);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledExtensions:[...t]})},pr={subagent_spawn:l(`toolDescSubagentSpawn`),subagent_get_result:l(`toolDescSubagentGetResult`),subagent_steer:l(`toolDescSubagentSteer`),subagent_list:l(`toolDescSubagentList`),subagent_stop:l(`toolDescSubagentStop`),subagent_wait_all:l(`toolDescSubagentWaitAll`),subagent_templates:l(`toolDescSubagentTemplates`)},mr={bash:l(`toolCoreBashDesc`),read:l(`toolCoreReadDesc`),edit:l(`toolCoreEditDesc`),write:l(`toolCoreWriteDesc`)},hr=e=>{let t=new Set(Ln);t.has(e)?t.delete(e):t.add(e),Q({disabledAgentTools:[...t]})},gr=new Set(g.disabledPluginTools??[]),_r=e=>{let t=new Set(gr);t.has(e)?t.delete(e):t.add(e),Q({disabledPluginTools:[...t]})},vr=e.plugins.map(e=>({plugin:e,tools:[...e.agentTools??[]].sort((e,t)=>e.name.localeCompare(t.name))})).filter(e=>e.tools.length>0),yr=g.markersEnabled??!0,br=new Set(g.disabledMarkers??[]),xr=e=>{let t=new Set(br);t.has(e)?t.delete(e):t.add(e),Q({disabledMarkers:[...t]})},Sr=(n,a)=>{let o={name:n,command:a,cwd:"${pwd}"},s,c=e.terminals.find(e=>e.title===n);c?(t.restart(c.id),$({type:`run_command`,terminalId:c.id,conversationId:c.conversationId,command:o,cols:80,rows:24}),s=c.id):(s=dt(),t.create({id:s,conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:o})),t.select(s),r(),i()},Cr=e=>{Et(null),Sr(`${l(`uninstallTitle`)} ${e}`,`pi remove npm:${e}`)},wr=(e,t,n)=>{$({type:`plugin_job`,jobId:dt(),action:e,id:t,...n?{source:n}:{},...e!==`uninstall`&&Yt?{build:!0}:{}})},Tr=t=>{let n=null;for(let r of Object.values(e.pluginJobs??{}))r.pluginId===t&&(!n||r.startedAt>=n.startedAt)&&(n=r);return n},Er=e=>e?e.problem===`already-installed`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:l(`pluginInspectAlreadyInstalled`,{id:e.suggestedId})}):e.problem===`network`?(0,X.jsx)(`div`,{className:`set-catalog-hint`,"data-problem":e.problem,children:l(`pluginInspectNetwork`)}):e.problem===`invalid-spec`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:l(`pluginInspectInvalid`)}):e.problem===`not-found`||e.problem===`not-a-package`||e.problem===`not-a-bundle`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:l(`pluginInspectNotPlugin`)}):e.problem?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,children:e.detail}):e.manifest?(0,X.jsxs)(`div`,{className:`set-catalog-hint ok`,"data-problem":`ok`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`✓ `}),e.manifest.name??e.manifest.id??e.suggestedId,e.manifest.version?` v${e.manifest.version}`:``,e.manifest.description?` · ${e.manifest.description}`:``]}):null:null,Dr=e=>{let t=Tr(e);if(!t)return null;if(t.phase!==`done`){let e=t.lines[t.lines.length-1]??``;return(0,X.jsxs)(`div`,{className:`set-catalog-job running`,title:e,children:[(0,X.jsx)(oe,{className:`set-job-spin`}),l(`pluginJobRunning`),(0,X.jsx)(`span`,{className:`set-catalog-job-line`,children:e})]})}return t.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[`✓ `,l(`pluginJobDone`)]}):(0,X.jsxs)(`div`,{className:`set-catalog-job error`,children:[(0,X.jsxs)(`span`,{children:[`✗ `,t.error||l(`pluginJobFailed`)]}),t.output?(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:t.output}):null]})},Or=[{slot:`topbar.primary`,labelKey:`uiLayoutTopbar`},{slot:`topbar.overflow`,labelKey:`uiLayoutTopbarOverflow`},{slot:`notice.actions`,labelKey:`uiLayoutNotice`},{slot:`leftpanel.sessions`,labelKey:`uiLayoutLeftSessions`},{slot:`chat.header`,labelKey:`uiLayoutChatHeader`},{slot:`chat.empty`,labelKey:`uiLayoutChatEmpty`},{slot:`message.actions`,labelKey:`uiLayoutMessage`},{slot:`goalbar.actions`,labelKey:`uiLayoutGoalbar`},{slot:`composer.leading`,labelKey:`uiLayoutComposerLeading`},{slot:`composer.actions`,labelKey:`uiLayoutComposer`},{slot:`rightpanel.tabs`,labelKey:`uiLayoutRightPanel`},{slot:`terminal.toolbar`,labelKey:`uiLayoutTerminal`},{slot:`scm.toolbar`,labelKey:`uiLayoutScm`},{slot:`bottombar`,labelKey:`uiLayoutBottombar`},{slot:`file.preview.toolbar`,labelKey:`uiLayoutFilePreview`},{slot:`contextmenu.topbar`,labelKey:`uiLayoutContextTopbar`},{slot:`contextmenu.message`,labelKey:`uiLayoutContextMessage`},{slot:`contextmenu.session`,labelKey:`uiLayoutContextSession`},{slot:`contextmenu.file`,labelKey:`uiLayoutContextFile`},{slot:`contextmenu.toolcall`,labelKey:`uiLayoutContextToolcall`},{slot:`settings.pages`,labelKey:`uiLayoutSettingsPages`},{slot:`modal.dialog`,labelKey:`uiLayoutModal`}],kr=[`bottombar`,`composer.actions`,`topbar.primary`],[Ar,jr]=(0,m.useState)(``),Mr=e=>{let t=Or.find(t=>t.slot===e);return t?l(t.labelKey):e},Nr=e.settings?.uiLayout,Pr=e=>Q({uiLayout:{...Nr,...e}}),Fr=e=>{let t=new Set(Nr?.hidden??[]),n=new Set(Nr?.shown??[]);e.hidden?(t.delete(e.id),n.add(e.id)):(t.add(e.id),n.delete(e.id)),Pr({hidden:[...t],shown:[...n]})},Ir=(e,t,n,r)=>{let i=t.map(e=>e.id),a=i.indexOf(n),o=a+r;if(a<0||o<0||o>=i.length)return;let s=[...i],[c]=s.splice(a,1);if(c===void 0)return;s.splice(o,0,c);let l=new Set(i),u=[...s],d=e.map(e=>l.has(e.id)?u.shift():e.id),f=new Set(e.map(e=>e.id)),p=(Nr?.order??[]).filter(e=>!f.has(e));Pr({order:[...p,...d]})},Lr=(e,t)=>{(t===`start`||t===`center`||t===`end`)&&Pr({align:{...Nr?.align,[e]:t}})},Rr=(e,t)=>{let n={...Nr?.labels},r=t.trim().slice(0,60);r?n[e]=r:delete n[e],Pr({labels:n})},zr=e=>Q({uiLayout:Ti(Nr,e)}),Br=()=>Q({uiLayout:Ei()}),Vr=e=>{Ot(null),wr(`uninstall`,e)},Hr=(e,t)=>{wr(`update`,e,t)},Ur=e=>{wr(`install`,e.id,e.source)},Wr=e=>{$({type:`plugin_catalog_remove`,id:e})},Kr=()=>{let e=It.trim();e&&($({type:`plugin_catalog_add`,entry:{source:e,...Rt.trim()?{id:Rt.trim()}:{},...Vt.trim()?{name:Vt.trim()}:{},...Ut.trim()?{description:Ut.trim()}:{},...Gt.trim()?{icon:Gt.trim()}:{}}}),Lt(``),Bt(``),Ht(``),Wt(``),Kt(``),Jt(!1))},qr=e=>{let t=e.trim();if(!t)return;let n=dt();sn(n),ln(t),$({type:`plugin_catalog_sync`,requestId:n,source:t,...tn?{install:!0}:{},...rn?{replace:!0}:{}})},[Jr,Yr]=(0,m.useState)(``);(0,m.useEffect)(()=>{let e=It.trim();if(!e){Yr(``);return}let t=setTimeout(()=>{let t=dt();Yr(t),$({type:`plugin_install_inspect`,requestId:t,source:e,...Rt.trim()?{explicitId:Rt.trim()}:{}})},500);return()=>clearTimeout(t)},[It,Rt]);let Xr=e.installInspect,Zr=Xr&&Xr.requestId===Jr&&Xr.source===It.trim()?Xr:null,Qr=e.catalogSync&&e.catalogSync.requestId===on?e.catalogSync:null;(0,m.useEffect)(()=>{Qr?.ok&&cn&&dn(N_(cn))},[Qr?.requestId,Qr?.ok]);let $r=e=>{let t=new Set(g.reviewSkills.filter(e=>!e.enabled).map(e=>e.name));t.has(e.name)?t.delete(e.name):t.add(e.name),Q({reviewDisabledSkills:[...t]})},ei=()=>Q({promptTemplate:D}),ri=e=>{Q({promptOverrides:{[e]:k[e]??``}})},ii=e=>{j.current===e&&(j.current=null),B(null),A(t=>{let n={...t};return delete n[e],n}),Q({promptOverrides:{[e]:``}})},ai=e=>ne(t=>({...t,[e]:!t[e]})),oi=(e,t)=>{A(n=>({...n,[e]:t})),B(e)},si=()=>{ee.current=!1,j.current=null,O(E_),A({}),Q({promptTemplate:E_,promptOverrides:{}})},ci=e=>{O(t=>t.trim()?`${t}\n\n{{${e}}}`:`{{${e}}}`)},li=D.trim()&&D.trim()!==E_||Object.values(k).some(e=>e.trim());return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:i,children:(0,X.jsxs)(`div`,{className:`modal settings-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":l(`close`),onClick:i,children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(W,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:l(`settingsTitle`)}),(0,X.jsx)(bc,{text:l(`settingsDesc`)})]}),(0,X.jsxs)(`div`,{className:`settings-layout`,children:[(0,X.jsx)(`nav`,{className:`settings-rail`,"aria-label":l(`settingsTitle`),ref:E,children:Zn.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-tab":e.id,className:`settings-tab${x===e.id?` active`:``}`,"aria-current":x===e.id?`true`:void 0,title:e.hint??e.label,onClick:()=>S(e.id),children:[(0,X.jsx)(`span`,{className:`settings-tab-icon`,children:e.icon}),(0,X.jsx)(`span`,{className:`settings-tab-label`,children:e.label}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`set-count`,children:e.count}),e.dot&&(0,X.jsx)(`span`,{className:`update-dot`,style:{marginLeft:4}})]},e.id))}),(0,X.jsxs)(`div`,{className:`modal-body`,ref:T,children:[x===`prompt`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(M,{className:`set-section-icon`}),l(`settingsSystemPrompt`),(0,X.jsx)(bc,{text:`${l(`promptComposeHint`)}\n${l(`promptComposeDesc`)}`})]}),(0,X.jsxs)(`div`,{className:`set-prompt-view-triggers`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":qe,onClick:()=>Ye(e=>!e),children:[(0,X.jsx)(`span`,{children:l(`settingsViewPrompt`)}),$e>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:l(`settingsViewPromptTokens`,{n:$e.toLocaleString()})}),(0,X.jsx)(`span`,{children:qe?`▴`:`▾`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":Xe,onClick:()=>Ze(e=>!e),children:[(0,X.jsx)(`span`,{children:l(`settingsViewToolsSchema`)}),et>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:l(`settingsViewPromptTokens`,{n:et.toLocaleString()})}),(0,X.jsx)(`span`,{children:Xe?`▴`:`▾`})]}),tt>0&&(0,X.jsx)(`span`,{className:`set-prompt-total-est`,children:l(`settingsPromptContextTotal`,{n:tt.toLocaleString()})})]}),qe&&(0,X.jsxs)(`div`,{className:`set-prompt-view`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:l(`settingsViewPrompt`)}),(0,X.jsx)(bc,{text:l(`settingsViewPromptHint`)}),(0,X.jsx)(gl,{text:g.effectiveSystemPrompt})]}),g.effectiveSystemPrompt?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:g.effectiveSystemPrompt}):(0,X.jsx)(`p`,{className:`set-empty`,children:l(`settingsViewPromptEmpty`)})]}),Xe&&(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:l(`settingsViewToolsSchema`)}),(0,X.jsx)(bc,{text:l(`settingsViewToolsSchemaHint`)}),(0,X.jsx)(gl,{text:g.toolsSchema})]}),g.toolsSchema?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:g.toolsSchema}):(0,X.jsx)(`p`,{className:`set-empty`,children:l(`settingsViewToolsSchemaEmpty`)})]})}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`promptTemplateLabel`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:6,spellCheck:!1,placeholder:E_,value:D,onFocus:()=>ee.current=!0,onBlur:()=>{ee.current=!1,ei()},onChange:e=>O(e.target.value)}),(0,X.jsxs)(`div`,{className:`compose-toolbar`,children:[(0,X.jsx)(`span`,{className:`set-field-label set-muted`,children:l(`promptInsertTokens`)}),L.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`token-chip`,title:d(`promptTok_${e}_desc`),onClick:()=>ci(e),children:`{{${e}}}`},e))]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`promptSourcesLabel`)}),L.map(e=>{let t=k[e]??``,n=g.promptSourceDefaults?.[e]??``,r=z===e,i=n.split(`
|
|
362
362
|
`).length>6||n.length>480;if(T_(e)){let r=t.trim()?t:n;return(0,X.jsxs)(`div`,{className:`override-row readonly`,children:[(0,X.jsxs)(`div`,{className:`override-row-head`,children:[`{{${e}}}`,(0,X.jsxs)(`span`,{className:`set-muted`,children:[d(`promptTok_${e}`),` `,(0,X.jsx)(bc,{text:d(`promptTok_${e}_desc`)})]}),t.trim()?(0,X.jsx)(`button`,{type:`button`,className:`set-btn-mini`,title:l(`promptReadonlyLockedHint`),onClick:()=>ii(e),children:l(`promptResetSource`)}):(0,X.jsx)(`span`,{className:`set-muted`,children:l(`promptReadonlyBadge`)})]}),(0,X.jsx)(`div`,{className:`source-default readonly${r.trim()?``:` empty`}`,title:l(`promptReadonlyTitle`),children:r.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?V[e]?` expanded`:` clamped`:``}`,children:r}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ai(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ai(e))},children:V[e]?l(`promptSourceCollapse`):l(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:l(`promptSourceDefaultEmpty`)})})]},e)}return(0,X.jsxs)(`div`,{className:`override-row`,children:[(0,X.jsxs)(`div`,{className:`override-row-head`,children:[`{{${e}}}`,(0,X.jsxs)(`span`,{className:`set-muted`,children:[d(`promptTok_${e}`),` `,(0,X.jsx)(bc,{text:d(`promptTok_${e}_desc`)})]}),t.trim()?(0,X.jsx)(`button`,{type:`button`,className:`set-btn-mini`,onClick:()=>ii(e),children:l(`promptResetSource`)}):(0,X.jsx)(`span`,{className:`set-muted`,children:l(`promptAutoBadge`)})]}),t.trim()||r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{className:`set-prompt-input override-input`,rows:Math.min(10,Math.max(1,t.split(`
|
|
363
|
-
`).length)),autoFocus:r,placeholder:l(`promptOverridePlaceholder`),value:t,onFocus:t=>{j.current=e,B(e);let r=t.currentTarget;r.value&&r.value===n&&r.setSelectionRange(r.value.length,r.value.length)},onBlur:()=>{j.current===e&&(j.current=null);let t=k[e]??``;if(t.trim()&&t===n){ii(e);return}ri(e),t.trim()||B(null)},onChange:t=>A(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:l(`promptSourceRefLabel`)}),i&&(0,X.jsx)(`button`,{type:`button`,className:`source-default-toggle`,onClick:()=>ai(e),children:V[e]?l(`promptSourceCollapse`):l(`promptSourceExpand`)})]}),n.trim()?(0,X.jsx)(`pre`,{className:`source-default-text${i?V[e]?` expanded`:` clamped`:``}`,children:n}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:l(`promptSourceDefaultEmpty`)}),!t.trim()&&n.trim()&&(0,X.jsx)(`button`,{type:`button`,className:`override-seed-btn`,title:l(`promptSourceSeedTip`),onClick:()=>oi(e,n),children:l(`promptSourceSeedButton`)})]})]}):(0,X.jsx)(`div`,{className:`source-default`,title:l(`promptSourceDefaultEditHint`),role:`button`,tabIndex:0,onClick:()=>oi(e,n),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),oi(e,n))},children:n.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?V[e]?` expanded`:` clamped`:``}`,children:n}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ai(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ai(e))},children:V[e]?l(`promptSourceCollapse`):l(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:l(`promptSourceDefaultEmpty`)})})]},e)}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-btn`,onClick:si,disabled:!li,children:l(`promptResetAll`)})})]})]}),x===`prompt`&&!b&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Oe,{className:`set-section-icon`}),l(`scmCommitMsgSettingsTitle`),(0,X.jsx)(bc,{text:l(`scmCommitMsgSettingsDesc`)})]}),(0,X.jsx)(B_,{label:l(`visionBridgePromptMode`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:me,onChange:e=>{let t=e.target.value;he(t),Q({scmCommitMsgPromptMode:t})},children:[(0,X.jsx)(`option`,{value:`append`,children:l(`promptModeAppend`)}),(0,X.jsx)(`option`,{value:`replace`,children:l(`promptModeReplace`)})]})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:l(`scmCommitMsgPromptPlaceholder`),value:fe,onFocus:()=>ge.current=!0,onBlur:()=>{ge.current=!1;let e=me===`replace`&&g.scmCommitMsgDefaultPrompt&&fe===g.scmCommitMsgDefaultPrompt?``:fe;Q({scmCommitMsgPromptMode:me,scmCommitMsgPrompt:e})},onChange:e=>pe(e.target.value)}),(0,X.jsx)(`p`,{className:`set-hint`,children:l(`scmCommitMsgSettingsHint`)})]}),x===`scheduler`&&!b&&(0,X.jsx)(Sg,{tasks:e.schedulerTasks,cwd:e.state?.cwd??``,models:g.subagentModels}),x===`prompt-history`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ve,{className:`set-section-icon`}),l(`settingsPromptHistory`),(0,X.jsx)(bc,{text:l(`settingsPromptHistoryDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:l(`promptHistoryCount`,{n:String(bt)})})]}),bt===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`promptHistoryEmpty`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:l(`promptHistoryCount`,{n:String(bt)})}),(0,X.jsx)(B_,{label:l(`promptHistoryMax`),tip:l(`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(vt.maxEntries),onChange:e=>{let t=Math.floor(Number(e.target.value)||0),n={...vt,maxEntries:t};yt(n)},onBlur:()=>{let e={...vt};(!Number.isFinite(e.maxEntries)||e.maxEntries<1)&&(e.maxEntries=1),e.maxEntries>500&&(e.maxEntries=500),e.maxEntries=Math.floor(e.maxEntries),yt(e),ym(e),wt()}})}),(0,X.jsx)(I_,{title:l(`promptHistoryCharLimit`),tip:l(`promptHistoryCharLimitHint`),enabled:vt.charLimitEnabled,onToggle:()=>{let e={...vt,charLimitEnabled:!vt.charLimitEnabled};yt(e),ym(e),wt()}}),vt.charLimitEnabled&&(0,X.jsx)(B_,{label:l(`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:l(`promptHistoryCharLimitPlaceholder`),value:String(vt.charLimit),onChange:e=>{let t=Math.floor(Number(e.target.value)||0);yt({...vt,charLimit:t})},onBlur:()=>{let e=Math.floor(Number(vt.charLimit)||0);(!Number.isFinite(e)||e<100)&&(e=100),e>2e4&&(e=2e4);let t={...vt,charLimit:e};yt(t),ym(t),wt()}})}),(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:12},children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${St?` confirm`:``}`,disabled:bt===0,title:l(bt===0?`promptHistoryEmpty`:`promptHistoryClear`),onClick:()=>{if(!St){Ct(!0);return}Tm(),Ct(!1),wt()},children:[(0,X.jsx)(R,{}),` `,l(St?`promptHistoryClearConfirm`:`promptHistoryClear`)]}),bt>0&&(0,X.jsx)(`span`,{className:`set-hint`,style:{marginLeft:8},children:l(`promptHistoryCount`,{n:String(bt)})})]}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[(0,X.jsx)(it,{style:{verticalAlign:`-2px`,marginRight:4}}),l(`settingsPromptHistoryDesc`)]})]}),x===`tools`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(te,{className:`set-section-icon`}),l(`settingsTools`)]}),Bn&&(0,X.jsxs)(`p`,{className:`set-catalog-hint warn`,children:[l(`toolsPresetBanner`,{name:Hn,count:Wn+Gn}),` `,(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>$({type:`dsh_preset_default`,preset:`standard`}),children:l(`toolsBackToStandard`)})]}),(0,X.jsx)(I_,{title:l(`readDirEnabled`),tip:l(`readDirEnabledDesc`),enabled:g.readDirEnabled!==!1,onToggle:()=>Q({readDirEnabled:g.readDirEnabled===!1})}),(0,X.jsx)(I_,{title:l(`toolApprovalEnabled`),tip:l(`toolApprovalEnabledDesc`),enabled:g.toolApprovalEnabled!==!1,onToggle:()=>Q({toolApprovalEnabled:g.toolApprovalEnabled===!1}),action:b?void 0:(0,X.jsxs)(`button`,{type:`button`,className:`tpl-chip`,onClick:()=>S(`approval-rules`),title:l(`settingsApprovalRulesDesc`),children:[(0,X.jsx)(H,{}),` `,l(`manageApprovalRules`)]})}),e.dshPermission&&e.dshPermission.options.length>0&&(0,X.jsxs)(`div`,{className:`set-mode-row`,style:{marginTop:8,marginBottom:8},children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[l(`dshPermDefault`),(0,X.jsx)(bc,{text:l(`dshPermDefaultDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:Gm.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:l(Km(e))},e))})]}),_?.allowAll||(_?.categories.length??0)>0?(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolApprovalPolicyTitle`),(0,X.jsx)(bc,{text:l(`toolApprovalPolicyHint`)})]}),_?.allowAll&&(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:l(`toolApprovalPolicyAllowAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,allowAll:!1}),children:l(`toolApprovalPolicyRevoke`)})]}),(_?.categories??[]).map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:u===`zh`?e.label:e.labelEn}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,categories:(_?.categories??[]).filter(t=>t.id!==e.id).map(e=>e.id)}),children:l(`toolApprovalPolicyRevoke`)})]},e.id))]}):null,(0,X.jsx)(B_,{label:l(`toolWatchdogTimeout`),tip:l(`toolWatchdogTimeoutDesc`),htmlFor:`tool-watchdog-timeout`,children:(0,X.jsx)(`input`,{id:`tool-watchdog-timeout`,className:`set-input`,type:`number`,min:0,step:1,placeholder:l(`toolWatchdogOff`),value:Cn,onChange:e=>wn(e.target.value),onBlur:()=>{let e=Cn.trim(),t=e===``?20:Math.max(0,Math.floor(Number(e)||0));wn(String(t));let n=t*6e4;n!==g.toolWatchdogTimeoutMs&&Q({toolWatchdogTimeoutMs:n})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionCore`),(0,X.jsx)(bc,{text:l(`toolsCoreHint`)})]}),ur.map(e=>{let t=Un(e);return(0,X.jsx)(I_,{title:e,tip:mr[e],subtitle:t?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!t&&!Ln.has(e),disabled:t,onToggle:()=>hr(e)},e)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:l(`toolsSectionTerminal`)}),Kn.map(e=>{let t=Un(e);return(0,X.jsx)(I_,{title:e,tip:l(`settingsTerminalToolsDesc`),subtitle:t?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!t&&!Ln.has(e),disabled:t,onToggle:()=>hr(e)},e)}),(0,X.jsx)(I_,{title:l(`terminalBashTakeover`),tip:l(`terminalBashTakeoverDesc`),enabled:g.terminalBash,onToggle:()=>Q({terminalBash:!g.terminalBash})}),g.terminalBash&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(B_,{label:l(`terminalBashIdleMs`),tip:l(`terminalBashIdleMsDesc`),htmlFor:`tb-idle-ms`,children:(0,X.jsx)(`input`,{id:`tb-idle-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:yn,onChange:e=>bn(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(yn)||0));bn(String(e)),e!==g.terminalBashIdleMs&&Q({terminalBashIdleMs:e})}})}),(0,X.jsx)(B_,{label:l(`terminalBashMaxForegroundMs`),tip:l(`terminalBashMaxForegroundMsDesc`),htmlFor:`tb-max-ms`,children:(0,X.jsx)(`input`,{id:`tb-max-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:xn,onChange:e=>Sn(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(xn)||0));Sn(String(e)),e!==g.terminalBashMaxForegroundMs&&Q({terminalBashMaxForegroundMs:e})}})})]}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionSubagent`),` `,(0,X.jsx)(bc,{text:l(`toolsSubagentDepHint`)})]}),qn.map(e=>{let t=Un(e);return(0,X.jsx)(I_,{title:e,tip:pr[e],subtitle:t?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!t&&!Ln.has(e),disabled:t,onToggle:()=>hr(e)},e)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`settingsMarkers`),(0,X.jsx)(bc,{text:`${l(`settingsMarkersDesc`)}\n${l(`markerRenameTip`)}`})]}),(0,X.jsx)(I_,{title:l(`markersEnabled`),tip:`${l(`markersEnabledDesc`)}\n${l(`markersOffHint`)}`,enabled:yr,onToggle:()=>Q({markersEnabled:!yr})}),yr&&(g.markers?.length??0)===0&&(0,X.jsxs)(`p`,{className:`set-empty`,children:[l(`loading`),`...`]}),yr&&g.markers&&g.markers.length>0&&g.markers.map(e=>(0,X.jsx)(I_,{title:e.name===`todo`?l(`markerGroupTodo`):e.name===`notify`?l(`markerGroupNotify`):e.name===`conv`?l(`markerGroupRename`):e.name,tip:e.guidance.join(`
|
|
364
|
-
`),enabled:e.enabled,onToggle:()=>xr(e.name)},e.name)),(0,X.jsx)(I_,{title:`todo_list`,tip:`${l(`todoListEnabledDesc`)}\n${l(`todoListOffHint`)}`,subtitle:Un(`todo_list`)?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!Un(`todo_list`)&&!Ln.has(`todo_list`),disabled:Un(`todo_list`),onToggle:()=>hr(`todo_list`)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:l(`toolsSectionOther`)}),k_.map(e=>{let t=Un(e.name);return(0,X.jsx)(I_,{title:e.name,tip:`${d(e.descKey??e.name)}\n${d(e.offHintKey??e.name)}`,subtitle:t?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!t&&!Ln.has(e.name),disabled:t,onToggle:()=>hr(e.name)},e.name)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionPlugin`),(0,X.jsx)(bc,{text:l(`toolsPluginHint`)})]}),vr.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:e.plugins.length===0?l(`noUiPlugins`):l(`pluginToolsEmpty`)}):vr.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)(I_,{title:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name,tip:e.description?`${e.description}\n${l(`pluginToolOffHint`)}`:l(`pluginToolOffHint`),subtitle:Bn?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!Bn&&!gr.has(e.name),disabled:Bn,onToggle:()=>_r(e.name)},e.name))]},e.plugin.id))]}),x===`question`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Te,{className:`set-section-icon`}),l(`settingsQuestionnaire`)]}),(0,X.jsx)(I_,{title:l(`questionnaireEnabled`),tip:`${l(`questionnaireEnabledDesc`)}\n${l(`questionnaireOffHint`)}`,enabled:g.questionnaireEnabled,onToggle:()=>Q({questionnaireEnabled:!g.questionnaireEnabled})})]}),x===`display`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(G,{className:`set-section-icon`}),l(`settingsMessageDisplay`)]}),(0,X.jsx)(B_,{label:l(`softCapTokens`),tip:l(`softCapHint`),htmlFor:`soft-cap-max`,children:(0,X.jsx)(`input`,{id:`soft-cap-max`,className:`set-input`,type:`text`,placeholder:l(`softCapOff`),value:Dn,onChange:e=>On(e.target.value),onBlur:()=>{let e=Mg(Dn);On(Ng(e)),e!==(g.softCapTokens??0)&&Q({softCapTokens:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-section-title`,children:[l(`softCapByModel`),(0,X.jsx)(bc,{text:l(`softCapByModelHint`)})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`softCapModelId`),value:kn,maxLength:200,onChange:e=>An(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,placeholder:l(`softCapTokens`),value:jn,onChange:e=>Mn(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&kn.trim()&&Mg(jn)>0){let e=Mg(jn);Q({softCapByModel:{...g.softCapByModel,[kn.trim()]:e}}),An(``),Mn(``)}}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!kn.trim()||Mg(jn)<=0,onClick:()=>{let e=kn.trim(),t=Mg(jn);!e||t<=0||(Q({softCapByModel:{...g.softCapByModel,[e]:t}}),An(``),Mn(``))},children:[(0,X.jsx)(ce,{}),` `,l(`softCapAdd`)]})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Object.entries(g.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:Ng(t),onBlur:t=>{let n=Mg(t.target.value);t.target.value=Ng(n);let r={...g.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:l(`softCapRemove`),onClick:()=>{let t={...g.softCapByModel};delete t[e],Q({softCapByModel:t})},children:[(0,X.jsx)(N,{}),` `,l(`softCapRemove`)]})]},e))}),(0,X.jsx)(B_,{label:l(`modelRetryAttempts`),tip:l(`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:Tn,onChange:e=>En(e.target.value),onBlur:()=>{let e=Math.min(100,Math.max(0,Math.floor(Number(Tn)||0)));En(String(e)),e!==g.retryMaxAttempts&&Q({retryMaxAttempts:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(I_,{title:l(`thinkingWrap`),tip:l(`thinkingWrapDesc`),enabled:g.thinkingWrap??!0,onToggle:()=>Q({thinkingWrap:!(g.thinkingWrap??!0)})}),(0,X.jsx)(I_,{title:l(`toolsWrap`),tip:l(`toolsWrapDesc`),enabled:g.toolsWrap??!0,onToggle:()=>Q({toolsWrap:!(g.toolsWrap??!0)})}),(0,X.jsx)(I_,{title:l(`toolImages`),tip:l(`toolImagesDesc`),enabled:g.toolImagesEnabled??!0,onToggle:()=>Q({toolImagesEnabled:!(g.toolImagesEnabled??!0)})}),(0,X.jsx)(I_,{title:l(`presentAutoOpen`),tip:l(`presentAutoOpenDesc`),enabled:rt,onToggle:()=>od(!rt)}),(0,X.jsx)(I_,{title:l(`parallelReminderEnabled`),tip:`${l(`parallelReminderEnabledDesc`)}\n${l(`parallelReminderOffHint`)}`,enabled:g.parallelReminderEnabled??!0,onToggle:()=>Q({parallelReminderEnabled:!(g.parallelReminderEnabled??!0)})}),(0,X.jsx)(I_,{title:l(`devNoCache`),tip:l(`devNoCacheDesc`),enabled:g.devNoCache??!0,onToggle:()=>Q({devNoCache:!(g.devNoCache??!0)})}),(0,X.jsx)(I_,{title:l(`autoReload`),tip:l(`autoReloadDesc`),enabled:g.autoReload??!0,onToggle:()=>Q({autoReload:!(g.autoReload??!0)})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(0,X.jsx)(I_,{title:l(`wideChat`),tip:l(`wideChatDesc`),enabled:nt,onToggle:()=>Rg({wide:!nt})}),(0,X.jsx)(I_,{title:l(`projectTitle`),tip:l(`projectTitleDesc`),enabled:ot,onToggle:()=>Yg({projectName:!ot})}),(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:[l(`wallpaperTitle`),(0,X.jsx)(bc,{text:l(`wallpaperDesc`)})]}),(0,X.jsxs)(`div`,{className:`wallpaper-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input wallpaper-url`,placeholder:l(`wallpaperUrlPh`),value:ct,maxLength:2e3,spellCheck:!1,onFocus:()=>{ut.current=!0},onChange:e=>lt(e.target.value),onBlur:()=>{if(ut.current=!1,!ct.trim()&&st.url.startsWith(`data:`)){lt(``);return}let e=o_(ct);lt(e),e!==st.url&&p_({...st,url:e})},onKeyDown:e=>{e.key===`Enter`?e.target.blur():e.key===`Escape`&&(lt(st.url.startsWith(`data:`)?``:st.url),e.target.blur())}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:pt,onClick:()=>ft.current?.click(),children:[(0,X.jsx)(I,{}),` `,l(`wallpaperUpload`)]}),(0,X.jsx)(`input`,{ref:ft,type:`file`,accept:`image/*`,hidden:!0,onChange:_t})]}),ht&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`wallpaperUploadFailed`)}),(0,X.jsxs)(`div`,{className:`wallpaper-sliders`,children:[(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:l(`wallpaperDim`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:95,step:1,value:st.dim,onChange:e=>p_({...st,dim:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[st.dim,`%`]})]}),(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:l(`wallpaperBlur`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:24,step:1,value:st.blur,onChange:e=>p_({...st,blur:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[st.blur,`px`]})]})]})]}),st.url&&(0,X.jsxs)(`div`,{className:`wallpaper-current`,children:[(0,X.jsx)(`img`,{className:`wallpaper-preview`,src:st.url,alt:``}),(0,X.jsx)(`button`,{type:`button`,className:`wallpaper-clear`,onClick:()=>{lt(``),p_({...st,url:``})},children:l(`wallpaperClear`)})]})]})]}),x===`sound`&&(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`}),l(`settingsSoundVoice`)]}),(0,X.jsx)(hn,{settings:a,onChange:o,onPreview:e=>jg(e,a)}),(0,X.jsx)(_n,{settings:s,onChange:c,onPreview:()=>zt(l(`ttsPreviewLine`),{...s,enabled:!0})})]}),x===`quick`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(W,{className:`set-section-icon`}),l(`quickPhrases`),(0,X.jsx)(bc,{text:l(`quickPhrasesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.quickPhrases.length})]}),(0,X.jsx)(I_,{title:l(`quickPhrasesEnabled`),tip:l(`quickPhrasesDesc`),enabled:g.quickPhrasesEnabled,onToggle:()=>Q({quickPhrasesEnabled:!g.quickPhrasesEnabled})}),!g.quickPhrasesEnabled&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`quickPhrasesOffHint`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`quickPhrasesPlaceholder`),value:fn,maxLength:200,onChange:e=>mn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&fn.trim()&&(Q({quickPhrases:[...g.quickPhrases,fn.trim()]}),mn(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!fn.trim(),onClick:()=>{Q({quickPhrases:[...g.quickPhrases,fn.trim()]}),mn(``)},children:[(0,X.jsx)(ce,{}),` `,l(`quickPhrasesAdd`)]})]}),g.quickPhrases.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`quickPhrasesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.quickPhrases.map((e,t)=>(0,X.jsx)(`div`,{className:`set-row`,children:gn?.index===t?(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`input`,{className:`set-input`,autoFocus:!0,value:gn.value,maxLength:200,placeholder:l(`quickPhrasesEditPh`),onChange:e=>vn({index:t,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?tr():e.key===`Escape`&&vn(null)},onBlur:tr})}):(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:l(`quickPhrasesEdit`),onClick:()=>vn({index:t,value:e}),children:(0,X.jsx)(Pe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`quickPhrasesMoveUp`),disabled:t===0,onClick:()=>{let e=[...g.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:l(`quickPhrasesMoveDown`),disabled:t===g.quickPhrases.length-1,onClick:()=>{let e=[...g.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:l(`quickPhrasesDelete`),onClick:()=>Q({quickPhrases:g.quickPhrases.filter((e,n)=>n!==t)}),children:(0,X.jsx)(R,{})})]})]})},`${t}:${e}`))}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>{vn(null),Q({quickPhrases:S_[u]??S_.en})},children:l(`quickPhrasesReset`)})})]}),x===`skills`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Le,{className:`set-section-icon`}),l(`settingsSkills`),(0,X.jsx)(bc,{text:`${l(`skillFullTextLabel`)}:${l(`skillFullTextDesc`)}`}),(0,X.jsx)(`span`,{className:`set-count`,children:g.skills.length})]}),!b&&Bn&&!fr(zn??void 0)&&(0,X.jsx)(`p`,{className:`set-catalog-hint warn`,children:l(`skillsHiddenByPreset`,{name:Hn})}),g.skills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(b?`dshSkillsNote`:`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.skills.map(e=>(0,X.jsx)(I_,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>nr(e),action:(0,X.jsx)(`button`,{type:`button`,className:`tpl-chip${rr.has(e.name)?` on`:``}`,title:l(`skillFullTextDesc`),onClick:()=>ir(e.name),children:l(`skillFullTextShort`)})},e.name))})]}),x===`extensions`&&(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`}),l(`settingsExtensions`),(0,X.jsx)(`span`,{className:`set-count`,children:g.extensions.length})]}),g.extensions.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(b?`dshExtensionsNote`:`noExtensions`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.extensions.map(e=>{let t=e.id.startsWith(`npm:`)?e.id.slice(4):null;return(0,X.jsx)(I_,{title:e.name,subtitle:e.path,enabled:e.enabled,onToggle:()=>cr(e),action:t?Tt===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:l(`uninstallConfirmHint`),onClick:()=>Cr(t),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`uninstallHint`),onClick:()=>Et(e.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]}):void 0},e.id)})})]}),x===`layout`&&(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`}),l(`uiLayoutTitle`),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:Br,children:l(`uiLayoutRestoreAll`)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:l(`uiLayoutHint`)}),Nn.length>0&&(0,X.jsxs)(`details`,{className:`set-ui-diag`,open:Nn.some(e=>e.level===`error`),children:[(0,X.jsxs)(`summary`,{children:[`⚠ `,l(`uiLayoutDiagTitle`,{n:Nn.length})]}),(0,X.jsx)(`ul`,{className:`set-ui-diag-list`,children:Nn.map((e,t)=>(0,X.jsxs)(`li`,{className:`set-ui-diag-item ${e.level}`,children:[e.pluginId?(0,X.jsx)(`code`,{children:e.pluginId}):null,e.entryId?(0,X.jsx)(`code`,{children:e.entryId}):null,(0,X.jsx)(`span`,{children:e.message})]},`${e.pluginId??`host`}:${e.entryId??t}`))}),(0,X.jsx)(`div`,{className:`set-ui-diag-hint`,children:l(`uiLayoutDiagHint`)})]}),(0,X.jsx)(`input`,{className:`set-ui-filter`,value:Ar,placeholder:l(`uiLayoutSearch`),"aria-label":l(`uiLayoutSearch`),onChange:e=>jr(e.target.value)}),Or.map(({slot:e,labelKey:t})=>{let n=(Pn[e]??[]).filter(e=>(b||e.id!==`host:composer-dsh-perm`&&e.id!==`host:composer-dsh-preset`)&&!ni.has(e.id)),r=Ar.trim().toLowerCase(),i=!r&&kr.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}],a=i.reduce((e,t)=>e+t.items.length,0);if(r&&a===0)return null;let o=(t,i)=>{let a=i.findIndex(e=>e.id===t.id),o=ti.has(t.id);return(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`label`,{className:`set-toggle`,title:o?l(`uiLayoutRequired`):t.id,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!t.hidden,disabled:o,onChange:()=>Fr(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:l(`uiLayoutArranged`)}),t.movedFrom&&(0,X.jsxs)(`span`,{className:`set-ui-source`,title:t.id,children:[l(`uiLayoutMovedFrom`),`: `,Mr(t.movedFrom)]}),kr.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:l(`uiLayoutAlign`),children:(0,X.jsxs)(`select`,{value:t.align,onChange:e=>Lr(t.id,e.target.value),"aria-label":l(`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:Nr?.labels?.[t.id]??``,placeholder:l(`uiLayoutRename`),title:l(`uiLayoutRename`),"aria-label":l(`uiLayoutRename`),onBlur:e=>{e.target.value!==(Nr?.labels?.[t.id]??``)&&Rr(t.id,e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.target.blur()}},`${t.id}:${Nr?.labels?.[t.id]??``}`),t.userOverrides.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>zr(t.id),children:l(`uiLayoutRestore`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<=0,onClick:()=>Ir(n,i,t.id,-1),children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<0||a>=i.length-1,onClick:()=>Ir(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:l(t)}),e===`topbar.primary`&&(0,X.jsxs)(`label`,{className:`set-toggle`,title:`topbarText`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Nr?.topbarText!==!1,onChange:e=>Pr({topbarText:e.target.checked})}),(0,X.jsx)(`span`,{children:l(`uiLayoutTopbarText`)})]}),n.length===0?(0,X.jsx)(`div`,{className:`set-empty`,children:l(`uiLayoutEmpty`)}):i.map(e=>(0,X.jsxs)(m.Fragment,{children:[e.align&&(0,X.jsx)(`div`,{className:`set-ui-slot-title set-ui-seg`,children:e.align}),e.items.map(t=>o(t,e.items))]},e.align??`all`))]},e)})]}),x===`plugins`&&!y&&(0,X.jsxs)(`div`,{className:`set-subtabs`,role:`tablist`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":C===`market`,className:`set-subtab${C===`market`?` active`:``}`,onClick:()=>{w(`market`),T.current?.scrollTo({top:0})},children:[l(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":C===`installed`,className:`set-subtab${C===`installed`?` active`:``}`,onClick:()=>{w(`installed`),T.current?.scrollTo({top:0})},children:[(0,X.jsx)(Qe,{}),l(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(Yn||Xn)&&(0,X.jsx)(`span`,{className:`update-dot`,style:{marginLeft:4}})]})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ke,{className:`set-section-icon`}),l(`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:l(`pluginGrantsHint`)}),e.pluginGrants.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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:l(`pluginGrantsRevoke`)})]},t))]},e.pluginId))})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Se,{className:`set-section-icon`}),l(`pluginPermsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:(e.pluginPermissions??[]).length})]}),(0,X.jsx)(`div`,{className:`set-note`,children:l(`pluginPermsHint`)}),(e.pluginPermissions??[]).length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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`?l(`pluginPermNet`):l(`pluginPermLlm`),e.session?` · ${l(`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:l(`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:l(`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??l(`pluginPermUnscoped`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:e.family}),children:l(`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}`))})]}),x===`plugins`&&y&&(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-note`,children:l(`updatesManaged`)})}),x===`plugins`&&!y&&C===`market`&&(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`}),l(`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:l(`pluginBuildHint`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Yt,onChange:e=>Xt(e.target.checked)}),l(`pluginBuildSource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogSyncHint`),onClick:()=>Qt(e=>!e),children:[(0,X.jsx)(se,{}),l(`pluginCatalogSync`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogAddHint`),onClick:()=>Jt(e=>!e),children:[(0,X.jsx)(ce,{}),l(`pluginCatalogAdd`)]})]}),Zt&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`div`,{className:`set-note`,children:l(`pluginCatalogSyncHint`)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogSyncSource`),value:$t,onChange:e=>en(e.target.value),onKeyDown:e=>{e.key===`Enter`&&qr($t)}}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:l(`pluginCatalogSyncInstall`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:tn,onChange:e=>nn(e.target.checked)}),l(`pluginCatalogSyncInstall`)]}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:l(`pluginCatalogSyncReplace`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:rn,onChange:e=>an(e.target.checked)}),l(`pluginCatalogSyncReplace`)]}),un.length>0&&(0,X.jsxs)(`div`,{className:`set-catalog-recent`,children:[(0,X.jsx)(`span`,{className:`set-catalog-recent-label`,children:l(`pluginCatalogSyncRecent`)}),un.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-catalog-recent-item`,title:e,onClick:()=>{en(e),qr(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:!$t.trim(),onClick:()=>qr($t),children:l(`pluginCatalogSyncSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Qt(!1),children:l(`cancel`)})]}),Qr&&(Qr.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[(0,X.jsxs)(`span`,{children:[`✓ `,l(`pluginCatalogSyncOk`,{n:Qr.entryCount??0}),Qr.installed?` · ${l(`pluginCatalogSyncInstalled`,{ok:Qr.installed.filter(e=>e.ok).length,fail:Qr.installed.filter(e=>!e.ok).length})}`:null]}),Qr.installed?.some(e=>!e.ok)&&(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:Qr.installed.filter(e=>!e.ok).map(e=>`${e.id}:${e.error??`?`}`).join(`
|
|
365
|
-
`)})]}):(0,X.jsx)(`div`,{className:`set-catalog-job error`,children:(0,X.jsxs)(`span`,{children:[`✗ `,Qr.error||l(`pluginJobFailed`)]})}))]}),qt&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogSource`),value:It,onChange:e=>Lt(e.target.value)}),Er(Zr),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogId`),value:Rt,onChange:e=>Bt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogName`),value:Vt,onChange:e=>Ht(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogIcon`),value:Gt,onChange:e=>Kt(e.target.value)}),(0,X.jsx)(`textarea`,{className:`set-input`,rows:2,placeholder:l(`pluginCatalogDesc`),value:Ut,onChange:e=>Wt(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!It.trim(),onClick:Kr,children:l(`pluginCatalogAddSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Jt(!1),children:l(`cancel`)})]})]}),e.pluginCatalog.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noPluginCatalog`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.pluginCatalog.map(t=>{let n=or.has(t.id),r=e.pluginUpdates?.[t.id],i=n&&r?.updatable===!0;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)(Gr,{icon:t.icon,iconSvg:t.iconSvg}),` `,t.name]}),n&&(0,X.jsx)(`span`,{className:`set-catalog-installed`,children:l(`pluginInstalled`)}),!t.builtin&&(0,X.jsx)(`span`,{className:`set-catalog-custom`,children:l(`pluginCatalogCustom`)}),i&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:r?.latestVersion?`${r?.version??``} → v${r.latestVersion}`:r?.remoteSha??``,children:[l(`pluginUpdateAvailableBadge`),r?.latestVersion?` v${r.latestVersion}`:``]})]}),t.description&&(0,X.jsx)(`div`,{className:`set-catalog-desc`,children:t.description}),(0,X.jsx)(`div`,{className:`set-catalog-source`,children:t.source}),Dr(t.id)]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${i?` accent`:``}`,title:i&&r?.latestVersion?l(`pluginUpdateAvailableDetail`,{version:`v${r.latestVersion}`}):l(`pluginUpdateHint`),onClick:()=>Hr(t.id,t.source),children:[(0,X.jsx)(se,{}),l(`pluginUpdate`)]}),Dt===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:l(`pluginUninstallHint`),onClick:()=>Vr(t.id),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginUninstallHint`),onClick:()=>Ot(t.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]})]}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginInstallHint`),onClick:()=>Ur(t),children:[(0,X.jsx)(Ie,{}),l(`pluginInstall`)]}),!t.builtin&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogRemoveHint`),onClick:()=>Wr(t.id),children:(0,X.jsx)(N,{})})]})]},t.id)})})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Qe,{className:`set-section-icon`}),l(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCheckUpdatesHint`),disabled:e.checkingPluginUpdates,onClick:()=>$({type:`check_plugin_updates`}),children:[(0,X.jsx)(se,{className:e.checkingPluginUpdates?`spin`:``}),e.checkingPluginUpdates?l(`checkingUpdate`):l(`pluginCheckUpdates`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginRescanHint`),onClick:()=>$({type:`plugins_reload`}),children:[(0,X.jsx)(se,{}),l(`pluginRescan`)]})]}),e.plugins.length>0&&(0,X.jsx)(z_,{plugins:e.plugins,disabledIds:ar}),e.plugins.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noUiPlugins`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.plugins.map(t=>{let n=e.pluginUpdates?.[t.id],r=n?.updatable===!0;return(0,X.jsxs)(m.Fragment,{children:[(0,X.jsx)(I_,{title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R_,{phase:b_(t,ar.has(t.id)),label:d(L_(b_(t,ar.has(t.id))))}),(0,X.jsx)(Gr,{icon:t.icon,iconSvg:t.iconSvg}),` `,t.name,r&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:n?.latestVersion?`v${t.version??`0.0.0`} → v${n.latestVersion}`:n?.remoteSha??``,children:[l(`pluginUpdateAvailableBadge`),n?.latestVersion?` v${n.latestVersion}`:``]})]}),subtitle:(t.error?`${t.id} · ${t.error}`:t.source?`${t.id} · ${t.source}`:`${t.id} · ${l(`uiPluginNoSource`)}`)+(t.permissions?.length?` · ${l(`uiPluginPerms`)}: ${t.permissions.join(`, `)}`:``),enabled:!ar.has(t.id)&&!t.error,onToggle:()=>!t.error&&sr(t),action:(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[t.source&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${r?` accent`:``}`,title:r&&n?.latestVersion?l(`pluginUpdateAvailableDetail`,{version:`v${n.latestVersion}`}):l(`pluginUpdateHint`),onClick:()=>Hr(t.id,t.source),children:[(0,X.jsx)(se,{}),l(`pluginUpdate`)]}),Dt===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:l(`pluginUninstallHint`),onClick:()=>Vr(t.id),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginUninstallHint`),onClick:()=>Ot(t.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]})]})},t.id),t.agentTools&&t.agentTools.length>0&&!b&&(0,X.jsxs)(`div`,{className:`set-row`,title:l(`pluginToolOffHint`),children:[(0,X.jsxs)(`span`,{className:`set-ui-source`,children:[l(`pluginToolsSection`),` (`,t.agentTools.length,`)`,t.agentTools.some(e=>gr.has(e.name))?` · ${l(`settingsDisabled`)}`:``]}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>S(`tools`),children:[l(`settingsTools`),` →`]})})]}),(0,X.jsxs)(`div`,{className:`set-row set-log-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>{jt===t.id?Mt(null):(Mt(t.id),$(_s(t.id)))},children:[(0,X.jsx)(je,{}),l(`pluginLogTitle`),` (`,ws(t.id).length,`) ·`,` `,jt===t.id?l(`pluginLogHide`):l(`pluginLogShow`)]}),jt===t.id&&(0,X.jsx)(V_,{pluginId:t.id})]}),t.diagnostics&&t.diagnostics.length>0&&(0,X.jsxs)(`div`,{className:`set-row set-diag-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>At(kt===t.id?null:t.id),children:[(0,X.jsx)(at,{}),l(`pluginDiagTitle`),` (`,t.diagnostics.length,`) ·`,` `,kt===t.id?l(`pluginDiagHide`):l(`pluginDiagShow`)]}),kt===t.id&&(0,X.jsx)(`ul`,{className:`set-diag-list`,children:t.diagnostics.map((e,n)=>(0,X.jsx)(`li`,{children:e},`${t.id}-${n}`))})]}),t.wantsDom&&(0,X.jsxs)(`div`,{className:`set-row`,title:l(`pluginDomDesc`),children:[(0,X.jsx)(`span`,{className:`set-ui-source`,children:t.domGranted?l(`pluginDomGranted`):l(`pluginDomNeed`)}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall${t.domGranted?``:` confirm`}`,title:l(`pluginDomDesc`),onClick:()=>$({type:`plugin_dom_consent`,pluginId:t.id,granted:!t.domGranted}),children:t.domGranted?l(`pluginDomRevoke`):l(`pluginDomGrant`)})})]}),t.settingsSchema&&t.settingsSchema.length>0&&(0,X.jsxs)(`div`,{className:`set-row set-settings-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>Pt(e=>({...e,[t.id]:!e[t.id]})),children:[(0,X.jsx)(re,{}),l(`pluginSettingsTitle`),` (`,t.settingsSchema.length,`) ·`,` `,Nt[t.id]?l(`pluginSettingsHide`):l(`pluginSettingsShow`)]}),Nt[t.id]&&(0,X.jsx)(gg,{plugin:t,models:g?.subagentModels??[]})]})]},t.id)})})]}),x===`plugins`&&b&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Qe,{className:`set-section-icon`}),l(`dshPatches`),(0,X.jsx)(bc,{text:l(`dshPatchesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPatches?.files.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`dshPatchesRescanHint`),onClick:()=>$({type:`dsh_patches_rescan`}),children:[(0,X.jsx)(se,{}),l(`dshPatchesRescan`)]})]}),(e.dshPatches?.files.length??0)===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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:[P_(e.size),` · `,new Date(e.mtimeMs).toLocaleString()]})]})},e.name))}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[l(`dshPatchesPath`),` `,e.dshPatches?.patchDir??``]})]}),x===`review`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(M,{className:`set-section-icon`}),l(`settingsReview`),(0,X.jsx)(bc,{text:l(`settingsReviewDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.reviewSkills.length})]}),(0,X.jsx)(I_,{title:l(`goalModeEnabled`),tip:`${l(`goalModeEnabledDesc`)}\n${l(`goalModeOffHint`)}`,enabled:g.goalModeEnabled,onToggle:()=>Q({goalModeEnabled:!g.goalModeEnabled})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:5,placeholder:l(`reviewPromptPlaceholder`),value:_e,onFocus:()=>K.current=!0,onBlur:()=>{K.current=!1,Q({reviewPrompt:_e})},onChange:e=>ve(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`settingsReviewSkills`),b&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(bc,{text:l(`dshReviewPromptNote`)})]})]}),g.reviewSkills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.reviewSkills.map(e=>(0,X.jsx)(I_,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>$r(e)},`review-${e.name}`))})]}),x===`vision`&&(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`}),l(`settingsVisionBridge`)]}),(0,X.jsx)(I_,{title:l(`visionBridgeEnabled`),tip:`${l(`settingsVisionBridgeDesc`)}\n${l(`visionBridgeOffHint`)}`,enabled:g.visionBridgeEnabled,onToggle:()=>Q({visionBridgeEnabled:!g.visionBridgeEnabled})}),g.visionBridgeEnabled&&(0,X.jsx)(B_,{label:l(`visionBridgeModel`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:g.visionBridgeModel??``,onChange:e=>Q({visionBridgeModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:l(`visionBridgeAuto`)}),g.visionModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),g.visionBridgeEnabled&&(0,X.jsx)(B_,{label:l(`visionBridgePromptMode`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:oe,onChange:e=>{let t=e.target.value;le(t),Q({visionBridgePromptMode:t})},children:[(0,X.jsx)(`option`,{value:`append`,children:l(`promptModeAppend`)}),(0,X.jsx)(`option`,{value:`replace`,children:l(`promptModeReplace`)})]})}),g.visionBridgeEnabled&&(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:l(`visionBridgePromptPlaceholder`),value:ie,onFocus:()=>ue.current=!0,onBlur:()=>{ue.current=!1;let e=oe===`replace`&&g.visionBridgeDefaultPrompt&&ie===g.visionBridgeDefaultPrompt?``:ie;Q({visionBridgePromptMode:oe,visionBridgePrompt:e})},onChange:e=>ae(e.target.value)}),g.visionBridgeEnabled&&(g.visionModels.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`visionBridgeNoModels`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:l(`visionBridgeCurrent`,{model:g.visionBridgeModel??l(`visionBridgeAuto`)})}))]}),x===`presets`&&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)(Le,{className:`set-section-icon`}),l(`dshPreset`),(0,X.jsx)(bc,{text:l(`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:l(`dshDefaultPreset`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPresets.defaultPreset,onChange:e=>$({type:`dsh_preset_default`,preset:e.target.value}),children:Hm(e.dshPresets.presets).map(e=>(0,X.jsxs)(`option`,{value:e.id,disabled:!!e.broken,children:[e.name??e.id,e.trust===`user`?` · ${l(`dshPresetUser`)}`:``]},e.id))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Hm(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:l(`dshPresetUser`)}),t.id===e.dshPresets.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:l(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:l(`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:l(`dshPresetUserNote`)})]}),x===`presets`&&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)(H,{className:`set-section-icon`}),l(`dshPerm`),(0,X.jsx)(bc,{text:l(`dshPermDefaultDesc`)})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`dshPermDefault`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:Gm.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:l(Km(e))},e))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Gm.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:[l(Km(t)),t===e.dshPermission.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:l(`dshPresetDefaultTag`)})]}),(0,X.jsx)(`div`,{className:`set-row-desc`,children:l(qm(t))})]})},t))})]}),x===`presets`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(U,{className:`set-section-icon`}),l(`settingsPresets`),(0,X.jsx)(`span`,{className:`set-count`,children:g.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`presetNamePlaceholder`),value:q,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&q.trim()&&($({type:`save_preset`,name:q.trim()}),ye(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!q.trim(),onClick:()=>{$({type:`save_preset`,name:q.trim()}),ye(``)},children:[(0,X.jsx)(ce,{}),` `,l(`saveAsPreset`)]})]}),g.presets.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noPresets`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.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`?l(`promptModeReplace`):l(`promptModeAppend`),e.disabledSkills.length>0&&` · ${l(`settingsSkills`)} ${e.disabledSkills.length}`,e.disabledExtensions.length>0&&` · ${l(`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:l(`applyPreset`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`deletePreset`),onClick:()=>$({type:`delete_preset`,name:e.name}),children:(0,X.jsx)(R,{})})]})]},e.name))})]}),x===`subagent-templates`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(F,{className:`set-section-icon`}),l(`settingsSubagentTemplates`),(0,X.jsx)(bc,{text:l(`settingsSubagentTemplatesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.subagentTemplates.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:l(`subagentTemplateNew`),onClick:()=>{be({name:``,description:``,promptMode:`replace`,systemPrompt:``,enabledSkills:[],enabledExtensions:[],model:``,thinkingLevel:``,enabled:!0}),Ce(!0)},children:[(0,X.jsx)(ce,{}),` `,l(`subagentTemplateNew`)]})]}),(0,X.jsx)(B_,{label:l(`subagentDefaultModelLabel`),tip:l(`subagentDefaultModelHint`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:g.subagentDefaultModel??``,onChange:e=>Q({subagentDefaultModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:l(`subagentFollowMain`)}),g.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),g.subagentModels.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`subagentNoModels`)}),J&&(0,X.jsx)(`div`,{className:`modal-backdrop tpl-modal-backdrop`,onClick:()=>be(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":l(`close`),onClick:()=>be(null),children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(F,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:xe?l(`subagentTemplateNew`):`${l(`subagentTemplateEdit`)} · ${J.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:l(`tplNamePlaceholder`),value:J.name,onChange:e=>be({...J,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`tplDescriptionPlaceholder`),value:J.description,onChange:e=>be({...J,description:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`tplDescriptionEnPlaceholder`),value:J.descriptionEn??``,onChange:e=>be({...J,descriptionEn:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`tplPromptModeLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:J.promptMode,onChange:e=>be({...J,promptMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`replace`,children:l(`promptModeReplace`)}),(0,X.jsx)(`option`,{value:`append`,children:l(`promptModeAppend`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`tplModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:J.model??``,onChange:e=>be({...J,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:l(`subagentFollowMain`)}),g.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:[l(`tplThinkingLabel`),` `,(0,X.jsx)(bc,{text:l(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:J.thinkingLevel??``,onChange:e=>be({...J,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:l(`tplThinkingFollowMain`)}),zm.map(e=>(0,X.jsx)(`option`,{value:e,children:l(`thinking.${e}`)},e))]})]}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${l(`tplSystemPromptLabel`)}${u===`zh`?`:`:`: `}${l(`tplSystemPromptPlaceholder`)}`,value:J.systemPrompt,onChange:e=>be({...J,systemPrompt:e.target.value})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${l(`tplSystemPromptLabel`)}: ${l(`tplSystemPromptEnPlaceholder`)}`,value:J.systemPromptEn??``,onChange:e=>be({...J,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:[l(`tplSkillsLabel`),` · `,l(`tplWhitelistHint`)]})}),g.skills.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`noSkills`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:g.skills.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${J.enabledSkills.includes(e.name)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:J.enabledSkills.includes(e.name),onChange:t=>{let n=t.target.checked;be({...J,enabledSkills:n?[...J.enabledSkills,e.name]:J.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:[l(`tplExtensionsLabel`),` · `,l(`tplWhitelistHint`)]})}),g.extensions.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`noExtensions`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:g.extensions.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${J.enabledExtensions.includes(e.id)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:J.enabledExtensions.includes(e.id),onChange:t=>{let n=t.target.checked;be({...J,enabledExtensions:n?[...J.enabledExtensions,e.id]:J.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:!J.name.trim(),onClick:()=>{$({type:`save_subagent_template`,template:{...J,name:J.name.trim()}}),be(null)},children:l(`tplSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>be(null),children:l(`tplCancel`)})]})]})}),g.subagentTemplates.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noSubagentTemplates`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:g.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,g.subagentDefaultTemplates.includes(e.name)&&(0,X.jsx)(`span`,{className:`tpl-badge default`,children:l(`tplDefaultBadge`)}),!e.enabled&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:l(`subagentTemplateClosed`)})]}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[(u!==`zh`&&e.descriptionEn?e.descriptionEn:e.description)||`${e.promptMode===`replace`?l(`promptModeReplace`):l(`promptModeAppend`)}`,e.model?` · ${l(`tplModelLabel`)} ${e.model}`:` · ${l(`subagentFollowMain`)}`,e.thinkingLevel?` · ${l(`tplThinkingLabel`)} ${d(`thinking.${e.thinkingLevel}`)}`:``,e.enabledSkills.length>0&&` · ${l(`tplSkillsLabel`)} ${e.enabledSkills.length}`,e.enabledExtensions.length>0&&` · ${l(`tplExtensionsLabel`)} ${e.enabledExtensions.length}`,!e.description&&e.enabledSkills.length===0&&e.enabledExtensions.length===0&&` · ${l(`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?l(`subagentTemplateDisable`):l(`subagentTemplateEnable`)} · ${l(`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:l(`subagentTemplateEdit`),onClick:()=>{be({...e}),Ce(!1)},children:l(`subagentTemplateEdit`)}),we===e.name?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:l(`uninstallConfirmHint`),onClick:()=>{$({type:`delete_subagent_template`,name:e.name}),Ee(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`tplDelete`),onClick:()=>Ee(e.name),children:(0,X.jsx)(R,{})})]})]},e.name))})]}),x===`approval-rules`&&!b&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(H,{className:`set-section-icon`}),l(`settingsApprovalRules`),(0,X.jsx)(bc,{text:l(`settingsApprovalRulesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.approvalRules?.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:l(`approvalRuleNew`),onClick:()=>{Y({id:`custom.${dt().slice(0,8)}`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:``,action:`ask`,label:``,labelEn:``,reason:``,reasonEn:``}),Re(`bash`),Ne(!0),Be(null)},children:[(0,X.jsx)(ce,{}),` `,l(`approvalRuleNew`)]})]}),De&&(0,X.jsxs)(`div`,{className:`rule-editor`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,style:{fontSize:13,marginBottom:4},children:Ae?l(`approvalRuleNew`):`${l(`approvalRuleEdit`)} · ${De.label}`}),(0,X.jsx)(B_,{label:l(`approvalRuleLabel`),children:(0,X.jsx)(`input`,{className:`set-input`,value:De.label,placeholder:`例如:拦截 Docker 危险操作`,onChange:e=>Y({...De,label:e.target.value})})}),(0,X.jsx)(B_,{label:l(`approvalRuleLabelEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:De.labelEn??``,placeholder:`e.g. Block dangerous Docker commands`,onChange:e=>Y({...De,labelEn:e.target.value})})}),(0,X.jsx)(B_,{label:l(`approvalRuleTools`),tip:l(`approvalRuleToolsTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Fe,placeholder:`bash, write, edit (或 * 通配)`,onChange:e=>{Re(e.target.value);let t=e.target.value.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);Y({...De,tools:t.length>0?t:[`*`]})}})}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:10,flexWrap:`wrap`},children:[(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(B_,{label:l(`approvalRuleField`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:De.field,onChange:e=>Y({...De,field:e.target.value}),children:[(0,X.jsx)(`option`,{value:`command`,children:l(`approvalRuleFieldCommand`)}),(0,X.jsx)(`option`,{value:`path`,children:l(`approvalRuleFieldPath`)}),(0,X.jsx)(`option`,{value:`params`,children:l(`approvalRuleFieldParams`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(B_,{label:l(`approvalRuleMatch`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:De.match,onChange:e=>Y({...De,match:e.target.value}),children:[(0,X.jsx)(`option`,{value:`regex`,children:l(`approvalRuleMatchRegex`)}),(0,X.jsx)(`option`,{value:`glob`,children:l(`approvalRuleMatchGlob`)}),(0,X.jsx)(`option`,{value:`contains`,children:l(`approvalRuleMatchContains`)}),(0,X.jsx)(`option`,{value:`prefix`,children:l(`approvalRuleMatchPrefix`)}),(0,X.jsx)(`option`,{value:`outside_workspace`,children:l(`approvalRuleMatchOutsideWs`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(B_,{label:`命中动作`,children:(0,X.jsxs)(`select`,{className:`set-select`,value:De.action,onChange:e=>Y({...De,action:e.target.value}),children:[(0,X.jsx)(`option`,{value:`ask`,children:l(`approvalRuleActionAsk`)}),(0,X.jsx)(`option`,{value:`deny`,children:l(`approvalRuleActionDeny`)}),(0,X.jsx)(`option`,{value:`allow`,children:l(`approvalRuleActionAllow`)})]})})})]}),De.match!==`outside_workspace`&&(0,X.jsx)(B_,{label:l(`approvalRuleValue`),tip:l(`approvalRuleValueTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:De.value,placeholder:`匹配表达式或关键字…`,onChange:e=>Y({...De,value:e.target.value})})}),(0,X.jsx)(B_,{label:l(`approvalRuleReason`),children:(0,X.jsx)(`input`,{className:`set-input`,value:De.reason??``,placeholder:`例如:检测到删除镜像或容器操作`,onChange:e=>Y({...De,reason:e.target.value})})}),(0,X.jsx)(B_,{label:l(`approvalRuleReasonEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:De.reasonEn??``,placeholder:`e.g. Detected docker image/container removal`,onChange:e=>Y({...De,reasonEn:e.target.value})})}),(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`label`,{className:`set-checkbox-label`,style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:De.enabled,onChange:e=>Y({...De,enabled:e.target.checked})}),l(`approvalRuleEnabled`)]})}),ze&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12},children:ze}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:4},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Y(null),Be(null)},children:l(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{if(!De.label.trim()){Be(`请填写规则名称`);return}if(De.match===`regex`)try{new RegExp(De.value)}catch(e){Be(`正则表达式非法:${e.message}`);return}$({type:`save_approval_rule`,rule:De}),Y(null),Be(null)},children:l(`save`)})]})]}),(g.approvalRules??[]).length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`approvalRuleEmpty`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:(g.approvalRules??[]).map((e,t)=>{let n=e.builtin===!0;return(0,X.jsxs)(`div`,{className:`set-row${e.enabled?``:` rule-row-disabled`}`,style:{alignItems:`flex-start`,padding:`12px 0`},children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,style:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:6},children:[(0,X.jsx)(`span`,{className:`rule-badge ${e.action}`,children:e.action===`deny`?l(`approvalRuleActionDeny`):e.action===`allow`?l(`approvalRuleActionAllow`):l(`approvalRuleActionAsk`)}),(0,X.jsx)(`strong`,{style:{fontSize:13},children:u===`zh`?e.label:e.labelEn||e.label}),n&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:l(`approvalRuleBuiltin`)}),(0,X.jsx)(`span`,{className:`rule-meta-code`,children:e.tools.join(`, `)})]}),(0,X.jsxs)(`div`,{className:`set-hint`,style:{marginTop:6,display:`flex`,flexDirection:`column`,gap:3},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:6,flexWrap:`wrap`},children:[(0,X.jsxs)(`span`,{style:{opacity:.85,fontSize:11,fontFamily:`var(--mono)`},children:[`[`,e.field,` · `,e.match,`]`]}),e.match!==`outside_workspace`&&(0,X.jsx)(`code`,{className:`rule-pattern-code`,children:e.value})]}),(e.reason||e.reasonEn)&&(0,X.jsx)(`div`,{style:{opacity:.75,fontSize:11},children:u===`zh`?e.reason:e.reasonEn||e.reason})]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,style:{marginLeft:12,flexShrink:0},children:[(0,X.jsx)(`button`,{type:`button`,className:`set-switch${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,title:e.enabled?l(`settingsEnabled`):l(`settingsDisabled`),onClick:()=>$({type:`save_approval_rule`,rule:{...e,enabled:!e.enabled}}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})}),!n&&t>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleMoveUp`),onClick:()=>{let e=[...g.approvalRules??[]],n=e[t-1];e[t-1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(Ke,{})}),!n&&t<(g.approvalRules?.length??0)-1&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleMoveDown`),onClick:()=>{let e=[...g.approvalRules??[]],n=e[t+1];e[t+1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(Je,{})}),n&&(We===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`reset_builtin_approval_rule`,id:e.id}),Ge(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleReset`),onClick:()=>Ge(e.id),children:(0,X.jsx)(se,{})})),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleEdit`),onClick:()=>{Y({...e}),Re(e.tools.join(`, `)),Ne(!1),Be(null)},children:(0,X.jsx)(Pe,{})}),!n&&(He===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`delete_approval_rule`,id:e.id}),Ue(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`approvalRuleDelete`),onClick:()=>Ue(e.id),children:(0,X.jsx)(R,{})}))]})]},e.id)})})]}),Qn&&(0,X.jsx)(kc,{plugin:Qn.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:l(`close`)})})]})})}var G_=0,K_=``;function q_(){typeof document<`u`&&(G_===0&&(K_=document.body.style.overflow,document.body.style.overflow=`hidden`),G_++)}function J_(){typeof document<`u`&&(G_=Math.max(0,G_-1),G_===0&&(document.body.style.overflow=K_))}function Y_({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:f=!0}){let p=Z(),h=(0,m.useRef)(t);if((0,m.useLayoutEffect)(()=>{h.current=t}),yt(()=>l?(h.current(),!0):!1,e),(0,m.useEffect)(()=>{if(e&&f)return q_(),()=>{J_()}},[e,f]),!e)return null;let g=e=>{e.target===e.currentTarget&&c&&h.current()},_=d??(typeof n==`string`?n:void 0);return(0,k.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":p(`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 X_(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 Z_({servers:e,onClose:t}){let n=Z(),[r,i]=(0,m.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,m.useEffect)(()=>{$({type:`list_bg_servers`})},[]),(0,X.jsxs)(Y_,{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)(xe,{}),` `,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)(N,{})})]}),e.length===0?(0,X.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,X.jsx)(xe,{}),(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`),` `,X_(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)(z,{}),(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)(ne,{}),(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)(se,{}),(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)(ne,{}),(0,X.jsx)(`span`,{children:n(`bgTaskStopAll`)})]})]})]})}function Q_(){let e=Z(),t=rf(),[n,r]=(0,m.useState)(!0),i=(0,m.useRef)(null);return(0,m.useEffect)(()=>{t&&r(!0)},[t]),yt(()=>{t&&tf()},!!t),(0,m.useEffect)(()=>{if(!t)return;let e=e=>{if(e.key!==`Enter`||e.shiftKey||e.ctrlKey||e.metaKey)return;let t=e.target;(!t||t===document.body||i.current?.contains(t))&&(e.preventDefault(),nf(n))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,n]),t?(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:tf,children:(0,X.jsxs)(`div`,{ref:i,className:`tool-info-modal rollback-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`rollbackSession`),onClick:e=>e.stopPropagation(),style:{maxWidth:520},children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,style:{color:`var(--amber, #f59e0b)`},children:[(0,X.jsx)(at,{}),e(`rollbackSession`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`cancel`),onClick:tf,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[(0,X.jsx)(`p`,{style:{margin:`0 0 16px 0`,fontSize:14,lineHeight:1.6},children:e(`rollbackConfirm`)}),(0,X.jsxs)(`label`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`12px 14px`,borderRadius:8,backgroundColor:`var(--bg-elev, rgba(255, 255, 255, 0.04))`,border:`1px solid var(--border-subtle, rgba(255, 255, 255, 0.1))`,cursor:`pointer`,marginBottom:20},title:e(`rollbackRestoreWorkspaceTip`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),style:{marginTop:3,cursor:`pointer`}}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{style:{fontWeight:600,fontSize:13,color:`var(--text, #e2e8f0)`},children:e(`rollbackRestoreWorkspace`)}),(0,X.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginTop:2},children:e(`rollbackRestoreWorkspaceTip`)})]})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:tf,children:e(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{display:`inline-flex`,alignItems:`center`,gap:6,backgroundColor:`var(--amber, #f59e0b)`,borderColor:`var(--amber, #f59e0b)`,color:`#000`,fontWeight:600},onClick:()=>nf(n),children:[(0,X.jsx)(Ye,{}),e(`confirm`)]})]})]})]})}),document.body):null}function $_({approval:e}){let t=Z(),{locale:n}=pn(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(null);if((0,m.useEffect)(()=>{if(e){let t=e.params;i(typeof t==`object`&&t?JSON.stringify(t,null,2):t==null?`{}`:String(t)),o(null)}},[e]),!e)return null;let s=t=>{$({type:`tool_approval_response`,id:e.id,decision:`approve`,...t&&t!==`once`?{scope:t}:{}})},c=()=>{$({type:`tool_approval_response`,id:e.id,decision:`deny`,reason:`Operation rejected by user`})};return(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,children:(0,X.jsxs)(`div`,{className:`tool-info-modal approval-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`toolApprovalTitle`),style:{maxWidth:640,borderTop:`4px solid var(--amber, #f59e0b)`},onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,style:{color:`var(--amber, #f59e0b)`},children:[(0,X.jsx)(at,{}),t(`toolApprovalTitle`)]}),(0,X.jsx)(`code`,{className:`tool-info-name`,style:{fontWeight:700},children:e.toolName}),e.conversationTitle&&(0,X.jsx)(`span`,{className:`tool-info-label`,children:e.conversationTitle}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalDeny`),onClick:c,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[(e.reason||e.reasonEn)&&(0,X.jsxs)(`div`,{style:{padding:`10px 14px`,borderRadius:6,backgroundColor:`rgba(245, 158, 11, 0.12)`,border:`1px solid rgba(245, 158, 11, 0.3)`,marginBottom:16,color:`var(--amber, #f59e0b)`,fontSize:13,lineHeight:1.5,fontWeight:500},children:[(0,X.jsxs)(`div`,{style:{fontWeight:600,marginBottom:2},children:[t(`toolApprovalRiskAlert`),`:`]}),(0,X.jsx)(`div`,{children:e.reason||e.reasonEn}),e.category&&(0,X.jsxs)(`div`,{style:{marginTop:6,fontSize:12,opacity:.85},children:[t(`toolApprovalCategory`),`:`,n===`zh`?e.category.label:e.category.labelEn]})]}),(0,X.jsxs)(`div`,{style:{marginBottom:16},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:6},children:[(0,X.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`var(--text, #e2e8f0)`},children:t(`toolApprovalParams`)}),(0,X.jsx)(`span`,{style:{fontSize:11,color:`var(--text-dim, #9aa1b4)`},children:t(`toolApprovalEditPlaceholder`)})]}),(0,X.jsx)(`textarea`,{rows:8,value:r,onChange:e=>{i(e.target.value),a&&o(null)},style:{width:`100%`,fontFamily:`var(--mono, monospace)`,fontSize:12,lineHeight:1.5,padding:10,borderRadius:6,backgroundColor:`var(--bg-elev, #111827)`,color:`var(--text, #f8fafc)`,border:a?`1px solid var(--red, #ef4444)`:`1px solid var(--border-subtle, rgba(255,255,255,0.1))`,boxSizing:`border-box`,resize:`vertical`}}),a&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12,marginTop:4},children:a})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,justifyContent:`flex-end`,gap:10},children:[e.category&&(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowCategoryHint`),onClick:()=>s(`category`),children:[(0,X.jsx)(xe,{}),t(`toolApprovalAllowCategory`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowConversationHint`),onClick:()=>s(`all`),children:[(0,X.jsx)(Xe,{}),t(`toolApprovalAllowConversation`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,style:{color:`var(--red, #ef4444)`},onClick:c,children:[(0,X.jsx)(N,{}),t(`toolApprovalDeny`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>s(),style:{fontWeight:500},children:[(0,X.jsx)(Ye,{}),t(`toolApprovalApprove`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{display:`inline-flex`,alignItems:`center`,gap:6,backgroundColor:`var(--amber, #f59e0b)`,borderColor:`var(--amber, #f59e0b)`,color:`#000`,fontWeight:600},onClick:()=>{try{let t=e.params,n;n=typeof t==`object`&&t||t==null?JSON.parse(r):r,o(null),$({type:`tool_approval_response`,id:e.id,decision:`edit`,editedParams:n})}catch(e){o(`JSON 格式错误:${e.message}`)}},children:[(0,X.jsx)(Pe,{}),t(`toolApprovalEditAndRun`)]})]})]})]})}),document.body)}function ev({plan:e}){let t=Z(),[n,r]=(0,m.useState)(!1);if(!e||!e.steps||e.steps.length===0)return null;let i=e.steps,a=i.filter(e=>e.status===`done`).length,o=i.length,s=Math.round(a/o*100),c=i.find(t=>t.id===e.activeStepId)??i.find(e=>e.status===`in_progress`),l=()=>{window.confirm(`确定要清空当前任务计划看板吗?`)&&$({type:`plan_update`,steps:[]})},u=e=>{switch(e){case`done`:return(0,X.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,color:`var(--green, #22c55e)`,fontSize:12,fontWeight:600},children:[(0,X.jsx)(Xe,{}),t(`planBoardCompleted`)]});case`in_progress`:return(0,X.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,color:`var(--accent, #38bdf8)`,fontSize:12,fontWeight:600},children:[(0,X.jsx)(Ve,{}),t(`planBoardInProgress`)]});case`failed`:return(0,X.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,color:`var(--red, #ef4444)`,fontSize:12,fontWeight:600},children:[(0,X.jsx)(ot,{}),t(`planBoardFailed`)]});default:return(0,X.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,color:`var(--text-dim, #9aa1b4)`,fontSize:12},children:[(0,X.jsx)(Ue,{}),t(`planBoardPending`)]})}};return(0,X.jsxs)(`div`,{className:`plan-board`,style:{padding:`10px 14px`,borderRadius:8,backgroundColor:`var(--bg-elev, #18202f)`,border:`1px solid var(--border-subtle, rgba(255, 255, 255, 0.1))`,boxShadow:`0 2px 8px rgba(0, 0, 0, 0.15)`,fontSize:13},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,cursor:`pointer`,userSelect:`none`},onClick:()=>r(!n),children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flex:1,minWidth:0},children:[(0,X.jsx)(J,{style:{color:`var(--accent, #38bdf8)`,flexShrink:0}}),(0,X.jsx)(`span`,{style:{fontWeight:600,color:`var(--text, #f1f5f9)`},children:t(`planBoardTitle`)}),(0,X.jsxs)(`span`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginLeft:4},children:[a,`/`,o,` (`,s,`%)`]}),!n&&c&&(0,X.jsx)(`span`,{style:{marginLeft:8,fontSize:12,padding:`2px 8px`,borderRadius:4,backgroundColor:`rgba(56, 189, 248, 0.12)`,color:`var(--accent, #38bdf8)`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:260},children:c.title})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn-icon`,title:t(`clear`),style:{background:`none`,border:`none`,color:`var(--text-dim, #9aa1b4)`,cursor:`pointer`,padding:4,display:`inline-flex`},onClick:e=>{e.stopPropagation(),l()},children:(0,X.jsx)(R,{})}),(0,X.jsx)(`button`,{type:`button`,className:`btn-icon`,style:{background:`none`,border:`none`,color:`var(--text-dim, #9aa1b4)`,cursor:`pointer`,padding:4,display:`inline-flex`},children:n?(0,X.jsx)(Ke,{}):(0,X.jsx)(Je,{})})]})]}),(0,X.jsx)(`div`,{style:{height:4,backgroundColor:`rgba(255, 255, 255, 0.08)`,borderRadius:2,margin:`8px 0`,overflow:`hidden`},children:(0,X.jsx)(`div`,{style:{height:`100%`,width:`${s}%`,backgroundColor:s===100?`var(--green, #22c55e)`:`var(--accent, #38bdf8)`,transition:`width 0.3s ease`}})}),n&&(0,X.jsx)(`div`,{style:{marginTop:10,display:`flex`,flexDirection:`column`,gap:8},children:i.map((t,n)=>{let r=t.id===e.activeStepId||t.status===`in_progress`;return(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,padding:`6px 10px`,borderRadius:6,backgroundColor:r?`rgba(56, 189, 248, 0.08)`:`var(--bg-elev2, rgba(0, 0, 0, 0.2))`,border:r?`1px solid rgba(56, 189, 248, 0.25)`:`1px solid transparent`},children:[(0,X.jsxs)(`div`,{style:{flex:1,minWidth:0,paddingRight:10},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,X.jsxs)(`span`,{style:{fontSize:11,fontWeight:700,color:r?`var(--accent, #38bdf8)`:`var(--text-dim, #9aa1b4)`,minWidth:16},children:[n+1,`.`]}),(0,X.jsx)(`span`,{style:{fontWeight:r?600:500,color:t.status===`done`?`var(--text-dim, #9aa1b4)`:`var(--text, #f1f5f9)`,textDecoration:t.status===`done`?`line-through`:`none`},children:t.title})]}),t.description&&(0,X.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginTop:2,paddingLeft:22,lineHeight:1.4},children:t.description})]}),(0,X.jsx)(`div`,{style:{flexShrink:0,marginTop:2},children:u(t.status)})]},t.id||n)})})]})}var tv=3,nv=200;function rv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function iv(e){return typeof e==`string`&&e.trim()||void 0}function av(e,t){let n=[];for(let r of e){let e=sv(r,t);if(n.includes(e)||n.push(e),n.length>=4){n.push(`…`);break}}return n.join(` | `)||`any`}function ov(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 sv(e,t=0){if(t>6||!rv(e))return`any`;if(iv(e.$ref))return`ref`;let n=iv(e.type);if(n===`array`){let n=e.items;return`array<${n===void 0?`any`:sv(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 av(r,t+1)}return rv(e.properties)?`object`:rv(e.additionalProperties)?`record<${sv(e.additionalProperties,t+1)}>`:`any`}function cv(e){let t=[],n=e.enum;if(Array.isArray(n)&&n.length>0){let e=ov(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 lv(e,t={}){let n=t.maxDepth??tv,r=t.maxRows??nv,i=e;if(!rv(i))return[];let a=i.properties;if(!rv(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=rv(l)?l:{},u=t?`${t}.${s}`:s,d={name:u,type:sv(e,i),required:a.has(s),depth:i},f=iv(e.description);f&&(d.description=f);let p=cv(e);if(p&&(d.hint=p),o.push(d),i+1<n&&rv(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 uv(){let e=Z(),t=Ya();return yt(()=>{Ga()},!!t),t?(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:Ga,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)(Ce,{}),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:Ga,children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`div`,{className:`tool-info-body`,children:(0,X.jsx)(dv,{info:t})})]})}),document.body):null}function dv({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?[]:lv(e.parameters),r=e.parameters===void 0?``:pv(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)(fv,{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)(gl,{text:r})]}),(0,X.jsx)(`pre`,{children:r})]})]}),(0,X.jsx)(`div`,{className:`tool-info-foot`,children:t(`toolInfoFootnote`)})]})}function fv({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 pv(e){try{return JSON.stringify(e,null,2)??``}catch{return``}}function mv(e,t){return e.toLowerCase().includes(t)}function hv({open:e,projects:t,fileSearch:n,sessionSearch:r,onClose:i,onSwitchSession:a,onSwitchProject:o,onPreviewFile:s}){let c=Z(),{locale:l}=pn(),u=l===`en`?`Plugins`:`插件`,d=aa(`cwd`),f=(0,m.useRef)(null),[p,h]=(0,m.useState)(``),g=(0,m.useDeferredValue)(p),[_,v]=(0,m.useState)(0),y=(0,m.useRef)(1),b=(0,m.useRef)(0),x=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!e)return;$({type:`list_sessions`}),$({type:`list_projects`});let t=p.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(()=>f.current?.select())},[e]);let[S,C]=(0,m.useState)(!1);(0,m.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,m.useMemo)(()=>!w||!r||r.reqId!==b.current||!r.ok?[]:r.results,[r,w]),E=(0,m.useMemo)(()=>w?t.filter(e=>mv(e.path,w)).slice(0,10):[],[t,w]),D=(0,m.useMemo)(()=>!w||!n||n.reqId!==b.current||!n.ok?[]:n.results,[n,w]);(0,m.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,m.useState)([]);(0,m.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 So==`function`&&(r=So())}catch{r=[]}let i=r.filter(e=>e&&typeof e.id==`string`).map(e=>{if(typeof e.search==`function`)return e;try{let t=Do(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 ee=(0,m.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,m.useEffect)(()=>{v(0)},[g]);let j=(0,m.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`?lo(e.providerId,e.action,e.action).catch(()=>{}):s(e.path,e.name)}},[a,o,s,g]);(0,m.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),i()):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.max(0,Math.min(e+1,ee.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),j(ee[_]))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[ee,_,j,i,e]);let M=T.length+E.length+D.length+k.length,P=(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})]}),F=-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)(ie,{}),(0,X.jsx)(`input`,{ref:f,type:`text`,value:p,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)(N,{})})]}),(0,X.jsxs)(`div`,{className:`gs-results`,children:[!w&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(`gsHint`)}),w&&M===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:[P(c(`gsSessions`),T.length,(0,X.jsx)(G,{})),T.map(e=>{F++;let t=F,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:()=>j({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(),Un({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:[P(c(`gsProjects`),E.length,(0,X.jsx)(ke,{})),E.map(e=>{F++;let t=F,n=d&&e.path===d;return(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,onMouseEnter:()=>v(t),onClick:()=>j({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:[P(c(`gsFiles`),D.length,(0,X.jsx)(je,{})),D.map(e=>{F++;let t=F;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`&&j({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:[P(u,k.length,(0,X.jsx)(de,{})),k.map((e,t)=>{F++;let n=F;return(0,X.jsxs)(`button`,{type:`button`,className:n===_?`gs-item active`:`gs-item`,title:e.providerLabel,onMouseEnter:()=>v(n),onClick:()=>j({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 gv({entry:e,pluginView:t,onUiAction:n,onClose:r}){let i=Z(),a=e.label||e.id,o=e.kind===`view`;return(0,X.jsx)(Y_,{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)(jh,{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 _v=5e3;function vv({file:e,content:t,onAddLines:n,onAttach:r,onClose:i,uiFilePreviewToolbar:a,onUiAction:o}){let s=Z(),[c,l]=(0,m.useState)(null),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(``),[C,w]=(0,m.useState)(!0),[T,E]=(0,m.useState)(!0),[D,O]=(0,m.useState)(!1),k=(0,m.useRef)(!1),[A,M]=(0,m.useState)(!0),[P,F]=(0,m.useState)(!1),[I,L]=(0,m.useState)(100),R=(0,m.useRef)(0),te=(0,m.useRef)(!1),z=(0,m.useRef)(null),[B,V]=(0,m.useState)(!1),[ne,re]=(0,m.useState)(!1),H=(0,m.useRef)(!1),U=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{z.current&&clearTimeout(z.current),U.current&&clearTimeout(U.current)},[]),(0,m.useEffect)(()=>{d(!0),l(null),p(null),b(!1),S(``),w(!0),E(!0),O(!1),k.current=!1,H.current=!1,V(!1),re(!1),U.current&&clearTimeout(U.current),$({type:`read_file`,path:e.path})},[e.path]),(0,m.useEffect)(()=>{t&&t.path===e.path&&(l(t),y||S(t.text),d(!1),H.current&&(H.current=!1,U.current&&clearTimeout(U.current),V(!1),re(!1),b(!1),S(t.text),k.current&&(yv(e.name)&&w(!0),xv(e.name)&&E(!0)),p(null)))},[t,y,e.path]),(0,m.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){me();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&y){e.preventDefault(),pe();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(),ce())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,c,y,x]),(0,m.useEffect)(()=>{let e=()=>{te.current=!1,g(!1)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let W=(0,m.useMemo)(()=>{if(!c)return[];let e=c.text.split(`
|
|
366
|
-
`);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,_v)},[c]),ie=c?.lines??0,oe=ie>_v,se=(e,t)=>{if(t){let t=R.current>0?R.current:e;p({start:Math.min(t,e),end:Math.max(t,e)})}else R.current=e,p({start:e,end:e})},ce=()=>{W.length!==0&&(R.current=1,p({start:1,end:W.length}))},le=()=>{f&&(n(e.path,e.name,f.start,f.end),v(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>v(!1),1400))},ue=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated&&!bv(e.name),de=()=>{H.current=!1,U.current&&clearTimeout(U.current),V(!1),re(!1),S(c?.text??``),b(!1),k.current&&(yv(e.name)&&w(!0),xv(e.name)&&E(!0))},fe=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;de();return}ue&&c&&(k.current=yv(e.name)&&C||xv(e.name)&&T,yv(e.name)&&w(!1),xv(e.name)&&E(!1),p(null),S(c.text),b(!0))},pe=()=>{y&&c&&ue&&$({type:`write_file`,path:e.path,text:x})&&(H.current=!0,re(!1),V(!0),U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{H.current=!1,V(!1),re(!0)},5e3))},me=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},ge=e=>{L(Math.min(200,Math.max(50,e)))},G=f?f.end-f.start+1:0,_e=c?.binary??!1,K=c?.truncated??!1,q=c?.kind??`text`,ye=yv(e.name)||bv(e.name),J=xv(e.name),xe=ye&&C&&!y&&q===`text`&&!_e,Se=J&&T&&!y&&q===`text`&&!_e,Ce={"host:fp-md":ye&&q===`text`&&!_e&&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)(Me,{}):(0,X.jsx)(Be,{})}):null,"host:fp-html":J&&q===`text`&&!_e&&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)(Be,{}):(0,X.jsx)(Me,{})}):null,"host:fp-edit":q===`text`&&!_e&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(K?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!ue&&!y,onClick:fe,children:(0,X.jsx)(Pe,{})}):null,"host:fp-wrap":q===`text`&&!_e&&!xe&&!Se?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${A?`on`:``}`,"data-tip":s(A?`disableWrap`:`enableWrap`),onClick:()=>M(e=>!e),children:(0,X.jsx)(Re,{})}):null,"host:fp-zoom":q===`text`&&c?(0,X.jsxs)(`span`,{className:`fp-zoom`,children:[(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-out`,"data-tip":s(`zoomOut`),disabled:I<=50,onClick:()=>ge(I-10),children:(0,X.jsx)(ee,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>L(100),children:[I,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:I>=200,onClick:()=>ge(I+10),children:(0,X.jsx)(j,{})})]}):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)(be,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${P?`on`:``}`,"data-tip":s(P?`exitFullscreen`:`fullscreen`),onClick:()=>F(e=>!e),children:P?(0,X.jsx)(he,{}):(0,X.jsx)(ve,{})}),"host:fp-close":null},we=a===void 0?[`host:fp-md`,`host:fp-html`,`host:fp-edit`,`host:fp-wrap`,`host:fp-zoom`,`host:fp-ref`,`host:fp-full`].map(e=>({id:e,source:`host`})):a.filter(e=>!e.hidden&&e.id!==`host:fp-close`),Te=e=>Yt(Gt(`/api/file?clientId=${encodeURIComponent(Hs())}&path=${encodeURIComponent(e)}`));return(0,X.jsx)(`div`,{className:`fp-overlay ${P?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&me()},children:(0,X.jsxs)(`div`,{className:`fp ${P?`fullscreen`:``}`,style:{"--fp-zoom":I/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&&q===`text`&&!_e&&s(`fileLines`,{n:ie}),c&&` · ${Sv(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:_p(we,Ce,o)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),"aria-label":s(`close`),onClick:me,children:(0,X.jsx)(N,{})})]}),K&&q===`text`&&!_e&&(0,X.jsx)(`div`,{className:`fp-notice`,children:bv(e.name)?s(`previewLinesTruncated`,{n:W.length}):s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&q===`none`&&!_e&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&q===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`img`,{className:`fp-media`,src:Te(e.path),alt:e.name})}),!u&&q===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:Te(e.path),controls:!0,preload:`metadata`})}),!u&&Se&&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 Yt(Gt(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(Hs())}${D?`&allowJs=1`:``}`))})(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&xe&&c&&(0,X.jsx)(`div`,{className:bv(e.name)?`fp-markdown msg-text fp-office`:`fp-markdown msg-text`,children:(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,children:(0,X.jsx)(uu,{text:c.text})})}),!u&&_e&&q!==`image`&&q!==`video`&&c&&(0,X.jsxs)(`div`,{className:`fp-hex-wrap`,children:[(0,X.jsxs)(`div`,{className:`fp-notice`,children:[s(`binaryFile`),c.truncated&&s(`binaryHexTruncated`)]}),(0,X.jsx)(`pre`,{className:`fp-hex`,children:c.text})]}),!u&&y&&q===`text`&&!_e&&c&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{className:`fp-editor ${A?``:`no-wrap`}`,value:x,onChange:e=>S(e.target.value),wrap:A?`soft`:`off`,spellCheck:!1,autoFocus:!0}),ne&&(0,X.jsx)(`div`,{className:`fp-notice`,role:`alert`,children:s(`saveResultUnknown`)})]}),!u&&!xe&&!Se&&!y&&q===`text`&&!_e&&c&&W.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!xe&&!Se&&!y&&q===`text`&&!_e&&W.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${h?`dragging`:``} ${A?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[W.map((e,t)=>{let n=t+1,r=f!==null&&n>=f.start&&n<=f.end;return(0,X.jsxs)(`div`,{className:`fp-line ${r?`sel`:``}`,onMouseDown:e=>{e.button===0&&(se(n,e.shiftKey),te.current=!0,g(!0))},onMouseEnter:()=>{te.current&&se(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),oe&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:_v})})]}),(0,X.jsx)(`div`,{className:`fp-foot`,children:y?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:s(`editFile`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:fe,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:B||x===(c?.text??``),onClick:pe,children:[(0,X.jsx)(ae,{}),` `,s(`saveFile`)]})]})]}):!xe&&!Se&&q===`text`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:f?s(`selectedRange`,{n:G,start:f.start,end:f.end}):s(`selectLinesHint`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:W.length===0,onClick:ce,children:s(`selectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!f,onClick:()=>p(null),children:s(`clearSelection`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!f||_e,onClick:le,children:[_?(0,X.jsx)(Ye,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function yv(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function bv(e){let t=e.toLowerCase();return t.endsWith(`.docx`)||t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`)}function xv(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function Sv(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function Cv({file:e,plugin:t,declaration:n,epoch:r,send:i,onClose:a,onFallback:o}){let s=Z(),c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(!1),p=(0,m.useRef)(o);p.current=o;let h=n.label??t.name;return(0,m.useEffect)(()=>{let r=c.current;if(!r)return;let a=!1,o;return u(null),f(!1),(async()=>{try{let s=await ng({plugin:t,declaration:n});if(a)return;if(!s)throw Error(`插件没有提供可用的文件查看器`);let c=`/plugins-api/${encodeURIComponent(t.id)}`,l={...hs(t.id,i),file:e,apiUrl:(e,t)=>{let n=String(e??``).startsWith(`/`)?String(e):`/${String(e??``)}`,r=new URLSearchParams;for(let[e,n]of Object.entries(t??{}))n!==void 0&&r.set(e,String(n));let i=r.toString();return Yt(Gt(`${c}${n}${i?`?${i}`:``}`))}};o=s.handler.mount(r,e,l),a||f(!0)}catch(e){a||(console.error(`[plugin:${t.id}] file handler failed:`,e),p.current())}})(),()=>{if(a=!0,typeof o==`function`)try{o()}catch(e){console.error(`[plugin:${t.id}] file handler cleanup failed:`,e)}r.textContent=``}},[e,t,n,r,i]),(0,X.jsx)(Y_,{className:`plugin-file-preview`,title:h,icon:t.icon,onClose:a,children:(0,X.jsxs)(`div`,{className:`modal-body plugin-file-preview-body`,children:[(0,X.jsx)(`div`,{className:`plugin-file-preview-file`,title:e.path,children:e.name}),l?(0,X.jsx)(`div`,{className:`plugin-file-preview-error`,children:l}):null,!l&&!d?(0,X.jsx)(`div`,{children:s(`loading`)}):null,(0,X.jsx)(`div`,{ref:c,className:`plugin-file-preview-host`})]})})}function wv(e,t,n,r,i){let a=new Map;for(let e of r)a.set(e.id,!!e.isStreaming);if(t&&a.set(t,n),e===null)return{startCue:!1,finishedConvs:[],nextMap:a};let o=!1;if(t&&(i===void 0||i===t)){let n=e.get(t),r=a.get(t)??!1;n===!1&&r===!0&&(o=!0)}let s=[];for(let[n,i]of e.entries())if(i&&a.has(n)&&!a.get(n)){let e=r.find(e=>e.id===n);s.push({id:n,title:e?.title,isActive:n===t})}return{startCue:o,finishedConvs:s,nextMap:a}}var Tv=(0,m.lazy)(()=>Go(()=>import(`./TerminalPanel-DDChcYOh.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function Ev({notice:e,onDismiss:t}){let n=Z(),{locale:r}=pn(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,m.useState)(!1);(0,m.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`?ot:e.level===`warning`?at:Ce;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)(N,{})})]})}var Dv=[],Ov=180,kv=520,Av=240,jv=e=>`pi-web-ui:${e}-panel-width`;function Mv(e){try{let t=Number(localStorage.getItem(jv(e)));return Number.isFinite(t)&&t>=Ov&&t<=kv?t:Av}catch{return Av}}var Nv=e=>`pi-web-ui:${e}-panel-collapsed`;function Pv(e){try{return localStorage.getItem(Nv(e))===`1`}catch{return!1}}function Fv({side:e,width:t,onResize:n}){let r=Z(),i=(0,m.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(kv,Math.max(Ov,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`);try{localStorage.setItem(jv(e),String(o))}catch{}};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),document.body.classList.add(`panel-resizing`)},[e,t,n]);return(0,X.jsx)(`div`,{className:`resize-handle resize-${e}`,title:r(`dragToResize`),onPointerDown:i,onDoubleClick:()=>n(Av)})}function Iv({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)(We,{}):(0,X.jsx)(Ge,{})})}var Lv=`pi-web-ui:plugin-path-grants`,Rv=e=>e?`${Lv}:${e}`:Lv;function zv(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Bv(e){try{let t=Rv(e);if(localStorage.getItem(t)!==null)return zv(localStorage.getItem(t));if(!e)return[];let n=zv(localStorage.getItem(Lv));return localStorage.setItem(t,JSON.stringify(n)),n}catch{return[]}}function Vv(e,t){try{let n=[...new Set([...Bv(t),e])];localStorage.setItem(Rv(t),JSON.stringify(n))}catch{}}function Hv(){let e=Z(),{locale:t}=pn(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=Js(),s=(0,m.useRef)(!1);(0,m.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:S_[t]??S_.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=e_();(0,m.useEffect)(()=>{let t=l?qg(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,m.useState)([]);(0,m.useEffect)(()=>(zn(e=>d(t=>im(t,e))),()=>zn(null)),[]);let[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(null),_=(0,m.useRef)(!1),v=(0,m.useRef)(null);(0,m.useEffect)(()=>{_.current=f!==null,v.current=h},[f,h]);let y=(0,m.useCallback)((e,t)=>{let n=tg(t);if(n){p(null),g({file:{path:e,name:t},plugin:n.plugin,declaration:n.declaration});return}g(null),p({path:e,name:t})},[]);(0,m.useEffect)(()=>(nu({open:e=>y(e.path,e.name),isOpen:()=>_.current||v.current!==null}),()=>nu(null)),[y]);let[b,x]=(0,m.useState)(!1);(0,m.useEffect)(()=>{let e=()=>x(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[S,C]=(0,m.useState)(`chat`),w=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(S.startsWith(`plugin:`)?`plugins`:S)?S:`chat`,T=(0,m.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),E=(0,m.useMemo)(()=>{let r=[],i=xi(ui(n.plugins),{locale:t,t:t=>e(t),disabledPlugins:n.settings?.disabledPlugins??[],layout:n.settings?.uiLayout,diagnostics:r});for(let e of r)console.warn(`[ui-slot] ${e.pluginId?`[${e.pluginId}] `:``}${e.message}`);return i},[n.plugins,n.settings?.disabledPlugins,n.settings?.uiLayout,t,e]),D=(0,m.useMemo)(()=>E[`topbar.primary`].filter(e=>!e.hidden),[E]),O=(0,m.useMemo)(()=>[...E[`topbar.primary`].filter(e=>e.hidden),...E[`topbar.overflow`]],[E]),k=(0,m.useMemo)(()=>E[`leftpanel.sessions`].filter(e=>!e.hidden),[E]),A=(0,m.useMemo)(()=>E[`terminal.toolbar`].filter(e=>!e.hidden),[E]),ee=(0,m.useMemo)(()=>E[`scm.toolbar`].filter(e=>!e.hidden),[E]),j=(0,m.useMemo)(()=>E[`goalbar.actions`].filter(e=>!e.hidden),[E]),M=(0,m.useMemo)(()=>E[`chat.header`].filter(e=>!e.hidden),[E]),P=(0,m.useMemo)(()=>E[`chat.empty`].filter(e=>!e.hidden),[E]),F=(0,m.useMemo)(()=>E[`file.preview.toolbar`].filter(e=>!e.hidden),[E]),I=(0,m.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(e=>[e.id,e.name??e.id])),[n.dshPresets]),L=(0,m.useMemo)(()=>E[`notice.actions`].filter(e=>!e.hidden),[E]),R=(0,m.useCallback)((t,n,i)=>{if(t.id===`host:msg-fork`){i?.id&&r({type:`fork_session`,messageId:i.id,position:`before`});return}if(t.id===`host:msg-rollback`){i?.id&&ef({messageId:i.id});return}let o=(t.action??``).trim();if(t.kind===`view`||(!o||o===`view`)&&t.source!==`host`){C(t.view??`plugin:${t.source.startsWith(`plugin:`)?t.source.slice(7):``}`);return}o&&lo(t.source.startsWith(`plugin:`)?t.source.slice(7):``,o,t.id,{...n===void 0?{}:{value:n},...i===void 0?{}:{target:i},loadBundle:async e=>{let t=W.current.plugins.find(t=>t.id===e);return t?ps(t,W.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[te,z]=(0,m.useState)([]);(0,m.useEffect)(()=>os(z),[]);let[B,V]=(0,m.useState)([]);(0,m.useEffect)(()=>is(V),[]);let[ne,re]=(0,m.useState)(null),H=ne?E[`modal.dialog`].find(e=>e.id===ne&&!e.hidden):void 0,U=(0,m.useMemo)(()=>{if(!H||H.kind!==`view`)return``;let e=H.view??``;return e.startsWith(`plugin:`)?e.slice(7):H.source.startsWith(`plugin:`)?H.source.slice(7):``},[H]);(0,m.useEffect)(()=>{if(!H||!U||te.some(e=>e.info.id===U))return;let e=W.current.plugins.find(e=>e.id===U);e&&ps(e,W.current.pluginsEpoch)},[H,U,te,n.pluginsEpoch]),(0,m.useEffect)(()=>{Ml(r),Nl(T,n.pluginsEpoch),Bl(T,n.pluginsEpoch),eg(T,n.pluginsEpoch),ms(T,n.pluginsEpoch)},[T,n.pluginsEpoch,r]);let W=(0,m.useRef)(n);W.current=n;let ie=(0,m.useRef)(C);ie.current=C;let ae=(0,m.useRef)(E);ae.current=E,(0,m.useEffect)(()=>(no(to({send:r,isReady:()=>!!W.current.state,setView:e=>ie.current(e),getCwd:()=>W.current.state?.cwd??``,getWorkspaceRoots:()=>W.current.state?.workspaceRoots??[],listSessions:()=>{let e=W.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:()=>W.current.state?.conversationId??null,isConversationBlank:()=>(W.current.state?.messages.length??0)===0,listModels:()=>W.current.models.map(e=>({id:e.id,provider:e.provider,name:e.name,vision:e.vision,reasoning:e.reasoning})),getCurrentModelId:()=>{let e=W.current.state?.model;return e?`${e.provider}/${e.id}`:null},listProjects:()=>W.current.projects.map(e=>e.path),grantedPaths:Bv,grantPath:Vv,confirm:e=>new Promise(t=>De({path:e.path,resolve:t})),openModal:e=>{let t=String(e??``).trim();if(!t)return!1;let n=ae.current[`modal.dialog`].find(e=>e.id===t);return!n||n.hidden?!1:(re(t),!0)},closeModal:()=>re(null),dialogConfirm:e=>new Promise(t=>{if(Y.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Y.current=n,ke(n)}),select:e=>new Promise(t=>{if(Y.current){t({ok:!1,error:`busy`});return}let n={kind:`select`,title:e.title,options:e.options,...e.multi?{multi:!0}:{},resolve:t};Y.current=n,je([]),ke(n)}),input:e=>new Promise(t=>{if(Y.current){t({ok:!1,error:`busy`});return}let n={kind:`input`,title:e.title,...typeof e.placeholder==`string`?{placeholder:e.placeholder}:{},...typeof e.initial==`string`?{initial:e.initial}:{},resolve:t};Y.current=n,Ne(e.initial??``),ke(n)}),notifyAction:e=>new Promise(t=>{try{let n=Ie.current;Ie.current=null,Fe(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Ie.current=r,Fe(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=W.current.plugins.find(t=>t.id===e);return t?ps(t,W.current.pluginsEpoch):Promise.resolve(!1)}})),()=>no(null)),[r]);let[oe,se]=(0,m.useState)(()=>Mv(`left`)),[ce,le]=(0,m.useState)(()=>Mv(`right`)),ue=(0,m.useCallback)(e=>se(e),[]),de=(0,m.useCallback)(e=>le(e),[]),[fe,pe]=(0,m.useState)(()=>Pv(`left`)),[me,he]=(0,m.useState)(()=>Pv(`right`)),ge=(0,m.useCallback)(()=>{pe(e=>{try{localStorage.setItem(Nv(`left`),e?`0`:`1`)}catch{}return!e})},[]),G=(0,m.useCallback)(()=>{he(e=>{try{localStorage.setItem(Nv(`right`),e?`0`:`1`)}catch{}return!e})},[]),[_e,ve]=(0,m.useState)(null),[K,q]=(0,m.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,m.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>q(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[ye,J]=(0,m.useState)(!1),[be,xe]=(0,m.useState)(!1),[Se,Ce]=(0,m.useState)(!1),[we,Te]=(0,m.useState)(),[Ee,De]=(0,m.useState)(null),[Oe,ke]=(0,m.useState)(null),Y=(0,m.useRef)(null),[Ae,je]=(0,m.useState)([]),[Me,Ne]=(0,m.useState)(``),[Pe,Fe]=(0,m.useState)(null),Ie=(0,m.useRef)(null),[Le,Re]=(0,m.useState)(()=>new Set),ze=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),Re(t=>new Set(t).add(e))},Be=n.pathRequests.find(e=>!Le.has(e.id))??null,[Ve,He]=(0,m.useState)(()=>new Set),Ue=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),He(t=>new Set(t).add(e))},We=n.permRequests.find(e=>!Ve.has(e.id))??null,Ge=Ug(),[Ke,qe]=(0,m.useState)(!1),[Je,Ye]=(0,m.useState)(!1),[Xe,Ze]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!Xe)return;let e=setTimeout(()=>Ze(null),15e3);return()=>clearTimeout(e)},[Xe]),(0,m.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=dt();o.create({id:e,conversationId:n.activeConversationId||n.state?.conversationId||``,title:a,cwd:n.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:c})}C(`terminal`)};window.addEventListener(`pi-web-ui:plugin-run-command`,t);let i=e=>{let t=e.detail;typeof t==`string`&&t&&r({type:`switch_conversation`,id:t})};return window.addEventListener(`pi-web-ui:switch-conversation`,i),()=>{window.removeEventListener(`pi-web-ui:plugin-run-command`,t),window.removeEventListener(`pi-web-ui:switch-conversation`,i)}},[n,o,r]),(0,m.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),Ye(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[Qe,$e]=(0,m.useState)(Tg),[et,tt]=(0,m.useState)(Tt),{themes:nt,theme:rt,switchTheme:it,reloadThemes:at}=Zl();y_(),(0,m.useEffect)(()=>{try{typeof Lo==`function`&&Lo(rt??``)}catch{}},[rt]),(0,m.useEffect)(()=>{try{typeof Ro==`function`&&Ro(t)}catch{}},[t]),(0,m.useEffect)(()=>{try{typeof zo==`function`&&zo(w)}catch{}},[w]),(0,m.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof No==`function`&&No(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,m.useEffect)(()=>{if(!Oe)return;let e=e=>{if(e.key!==`Escape`)return;let t=Y.current;Y.current=null,ke(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)},[Oe]),(0,m.useEffect)(()=>{if(!Pe)return;let e=setTimeout(()=>{let e=Ie.current;Ie.current=null,Fe(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[Pe]);let ot=(0,m.useRef)(null),st=(0,m.useRef)(null),ct=(0,m.useRef)(n.state?.messages);ct.current=n.state?.messages;let lt=(0,m.useRef)(new Set),ut=(0,m.useRef)(new Set),ft=(0,m.useRef)(new Set),pt=(0,m.useRef)(0),mt=(0,m.useRef)(!1),ht=(0,m.useRef)(n.terminals);(0,m.useEffect)(()=>{Eg(Qe)},[Qe]),(0,m.useEffect)(()=>{Et(et)},[et]),(0,m.useEffect)(()=>{let e=ht.current;ht.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,m.useEffect)(()=>{let t=n.state?.conversationId??null,r=wv(ot.current,t,n.state?.isStreaming??!1,n.conversations,st.current);if(ot.current=r.nextMap,st.current=t,r.startCue&&jg(`start`,Qe),r.finishedConvs.length>0){jg(`done`,Qe);let t=r.finishedConvs.find(e=>e.isActive);if(t&&(Pr(e(`notifyDoneTitle`),e(`notifyDoneBody`)),et.enabled&&!xr(Or()))){if(et.readReplies){let t=At(ct.current);t?zt(t,et):et.announce&&zt(e(`ttsAnnounceDone`),et)}else et.announce&&zt(e(`ttsAnnounceDone`),et)}for(let t of r.finishedConvs.filter(e=>!e.isActive)){let n=t.title?`${t.title}:${e(`notifyDoneBody`)}`:e(`notifyDoneBody`);Pr(e(`notifyDoneTitle`),n)}!t&&et.enabled&&et.announce&&!xr(Or())&&zt(e(`ttsAnnounceDone`),et)}},[n.state?.conversationId,n.state?.isStreaming,n.conversations,Qe,et,e]),(0,m.useEffect)(()=>{let t=n.dialog?.id??null;if(t!==null&&!lt.current.has(t)){if(lt.current.add(t),lt.current.size>64){let e=lt.current.values().next().value;e!==void 0&<.current.delete(e)}jg(`question`,Qe),Pr(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),et.enabled&&et.announce&&!xr(Or())&&zt(e(`ttsAnnounceQuestion`),et)}},[n.dialog,Qe,et,e]),(0,m.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null,i=!1;t!==null&&!ut.current.has(t)&&(ut.current.add(t),i=!0),r!==null&&!ut.current.has(r)&&(ut.current.add(r),i=!0);for(let e of n.conversations){if(!e.hasQuestion)continue;let n=e.questionId?`q:${e.questionId}`:`conv-q:${e.id}`;ut.current.has(n)||(ut.current.add(n),e.questionId&&ut.current.add(e.questionId),t!==e.questionId&&(i=!0))}if(ut.current.size>64){let e=ut.current.values().next().value;e!==void 0&&ut.current.delete(e)}i&&(jg(`question`,Qe),Pr(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),et.enabled&&et.announce&&!xr(Or())&&zt(e(`ttsAnnounceQuestion`),et))},[n.question,n.remoteQuestion,n.conversations,Qe,et,e]),(0,m.useEffect)(()=>{let t=n.approval,r=t?.id??null;if(r!==null&&!ft.current.has(r)){if(ft.current.add(r),ft.current.size>64){let e=ft.current.values().next().value;e!==void 0&&ft.current.delete(e)}jg(`approval`,Qe);let n=typeof t?.toolName==`string`?t.toolName:``;Pr(e(`notifyApprovalTitle`),n?e(`notifyApprovalBodyTool`,{tool:n}):e(`notifyApprovalBody`)),et.enabled&&et.announce&&!xr(Or())&&zt(e(`ttsAnnounceApproval`),et)}},[n.approval,Qe,et,e]),(0,m.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==pt.current&&(pt.current=t.id,jg(`error`,Qe),Pr(e(`notifyErrorTitle`),e(`notifyErrorBody`)),et.enabled&&et.announce&&!xr(Or())&&zt(e(`ttsAnnounceError`),et))},[n.notices,Qe,et,e]);let gt=(0,m.useRef)(new Set);(0,m.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||gt.current.has(t.id))continue;gt.current.add(t.id);let e=``;for(let n of t.content??[]){if(n.type!==`text`)continue;let t=/🔗 已自动在浏览器打开\]\((\/(?!\/)[^)\s]+)\)/.exec(n.text??``);if(t?.[1]){e=t[1];break}}if(!e)continue;let n=null;try{let t=new URL(Gt(e),window.location.href);t.origin===window.location.origin&&document.hasFocus()&&(n=window.open(t.href,`_blank`,`noopener`))}catch{n=null}n||a(`info`,e)}},[n.state?.messages,a]);let _t=(e,t,n,r=!1,i,a=!1)=>{let o=`${e}|${n}|${i?`${i.start}-${i.end}`:``}`;d(a=>a.some(e=>`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`===o)?a:[...a,{path:e,name:t,mode:n,isDir:r,...i?{lines:i}:{}}]),!a&&t&&In(`@${t} `)},vt=e=>{let t=``;d(n=>n.filter(n=>{let r=n.key?n.key===e:n.mode===`conversation`?`conv|${n.conversationId??``}|${n.sessionPath??``}`===e:n.path===e;return r&&!t&&(t=n.name),!r})),t&&Ln(`@${t}`)},yt=(0,m.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&ve(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&C(e=>e===`chat`?e:`chat`),r(e)),[r]),bt=(0,m.useRef)(new Set),xt=n.activeConversationId||n.state?.conversationId||``;(0,m.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 bt.current)i.has(e)||bt.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===xt){Vh(t);continue}n.questionId&&bt.current.has(n.questionId)||Bh({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&&bt.current.add(n.questionId)},onClick:()=>{yt({type:`switch_conversation`,id:n.id}),Vh(t),n.questionId&&bt.current.add(n.questionId)}})}Hh(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===xt:!1})},[n.conversations,xt,yt,e]);let St=(0,m.useRef)(0),Ct=(0,m.useRef)(0),wt=(0,m.useCallback)(t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-Ct.current>1e4&&(Ct.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++St.current}`;d(e=>[...e,{path:``,key:i,name:t.name,imageData:t.data,mimeType:t.mimeType}])},[n.state?.model,a,e]),Dt=(0,m.useCallback)(async t=>{for(let n of t){let t=await jd(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}wt(t)}},[wt,a,e]),Ot=20971520,kt=(0,m.useRef)(0),jt=(0,m.useCallback)(async t=>{if(t.size>Ot){a(`warning`,e(`fileTooLarge`,{name:t.name,size:Ot/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-${++kt.current}`;d(e=>[...e,{path:``,key:r,name:t.name,fileData:n,size:t.size,mimeType:t.type||void 0}])},[Ot,a,e]),Mt=(0,m.useCallback)(async e=>{for(let t of e)Ad(t.type)?await Dt([t]):await jt(t)},[Dt,jt]),Nt=(0,m.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),Pt=(0,m.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[Ft,It]=(0,m.useState)([]),Lt=(0,m.useRef)(0),Rt=(0,m.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),Lt.current+=1;let i={text:t,seq:Lt.current};It(e=>[...e.slice(-9),i])},[r]),Bt=(0,m.useCallback)(()=>xe(!0),[]),Vt=(0,m.useCallback)(()=>d([]),[]);Yh(n.state?.sessionId??``,Vt);let Ht=(0,m.useCallback)(vt,[]),Ut=Dt,Wt=Mt,Kt=(0,m.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),qt=(0,m.useCallback)(e=>_t(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines,e.silent??!1),[]),Jt=n.state?.model,Yt=n.state?.thinkingLevel,Xt=n.state?.availableThinkingLevels,Zt=(0,m.useMemo)(()=>Jt?{model:Jt,thinkingLevel:Yt??`off`,availableThinkingLevels:Xt??[]}:null,[Jt,Yt,Xt]),Qt=(0,m.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:dt(),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,m.useEffect)(()=>{if(mt.current){if(w!==`terminal`||n.terminals.length!==0){mt.current=!1;return}Qt()&&(mt.current=!1)}},[n.terminals.length,Qt,w]),(0,X.jsxs)(`div`,{className:`app`,"data-pi-anchor":`app`,onDragOver:e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),x(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||x(!1)},onDrop:t=>{if(x(!1),!Array.from(t.dataTransfer?.types??[]).includes(`Files`))return;t.preventDefault();let n=Array.from(t.dataTransfer?.files??[]);if(n.length===0){a(`warning`,e(`foldersNotSupported`));return}let r=n.filter(e=>Ad(e.type)),i=n.filter(e=>!Ad(e.type));r.length>0&&Dt(r),i.length>0&&Mt(i)},children:[b&&(0,X.jsx)(`div`,{className:`app-drop-overlay`,"aria-hidden":!0,children:(0,X.jsxs)(`span`,{children:[`📎 `,e(`dropHereToAttach`)]})}),(0,X.jsx)(Pa,{chat:n,terminal:o,view:w,plugins:T,uiPrimary:D,uiOverflow:O,uiContextTopbar:E[`contextmenu.topbar`],onUiAction:R,onViewChange:e=>{mt.current=e===`terminal`&&n.terminals.length===0,mt.current&&Qt()&&(mt.current=!1),C(e),ve(null)},onOpenPanel:ve,onOpenSettings:()=>{Te(void 0),Ce(!0)},onManagePlugins:()=>{Te(`plugins`),Ce(!0)},onOpenBgTasks:()=>qe(!0),onOpenGlobalSearch:()=>Ye(!0),sound:Qe,onSoundChange:$e,onSoundPreview:e=>jg(e,Qe),themes:nt,theme:rt,onThemeChange:it,reloadThemes:at}),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)(Ev,{notice:e,onDismiss:i},e.id)),Pe&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:Pe.text}),Pe.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Ie.current;Ie.current=null,Fe(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=Ie.current;Ie.current=null,Fe(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(N,{})})]}),L.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:L.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=>R(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:()=>R(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)(lp,{currentModelId:Jt?`${Jt.provider}/${Jt.id}`:null,children:(0,X.jsxs)(`div`,{className:`layout`,style:{"--left-w":`${oe}px`,"--right-w":`${ce}px`},children:[_e&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>ve(null)}),(0,X.jsxs)(`div`,{className:`view-pane ${w===`chat`?``:`hidden`}`,children:[!K&&fe&&(0,X.jsx)(Iv,{side:`left`,onClick:ge}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${_e===`left`?`open`:``}${K?``:fe?` hidden`:``}`,children:(0,X.jsx)(oc,{collapsible:!K,onToggleCollapse:ge,panelSend:yt,active:!K||_e===`left`,sessionFile:n.state?.sessionFile??null,conversations:n.conversations,elsewhere:n.elsewhere,sessions:n.sessions,projects:n.projects,pathCompletions:n.pathCompletions,activeConversationId:n.activeConversationId,uiContextSession:E[`contextmenu.session`],uiLeftSessions:k,onUiAction:R,presetNames:I})}),!K&&(0,X.jsx)(Fv,{side:`left`,width:oe,onResize:ue}),(0,X.jsxs)(`main`,{className:Ge?`main wide-chat`:`main`,children:[M.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:hp(M,R)}),n.state?(0,X.jsxs)(X.Fragment,{children:[n.state.isEphemeral&&(0,X.jsxs)(`div`,{className:`ephemeral-banner`,children:[(0,X.jsxs)(`span`,{children:[`🎭 `,e(`ephemeralBannerText`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`ephemeral-save`,onClick:()=>r({type:`persist_conversation`,id:xt}),children:[`💾 `,e(`saveEphemeral`)]})]}),(0,X.jsx)($p,{uiMessageActions:E[`message.actions`],uiContextMessage:E[`contextmenu.message`],uiContextToolCall:E[`contextmenu.toolcall`],uiChatEmpty:P,onUiAction:R,state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:Nt,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&tp(`${e.provider}/${e.id}`)}},onRemoveQueued:Pt,onRecallQueued:Rt,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,jumpTarget:Xe,onJumpDone:()=>Ze(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)(th,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:j,onUiAction:R}),(0,X.jsx)(Nh,{onAction:(e,t,n)=>R(e,n,t)}),n.dialog&&(0,X.jsx)(ph,{dialog:n.dialog}),Oe&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":Oe.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),Oe.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:Oe.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Y.current;Y.current=null,ke(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),Oe.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(Oe.options??[]).map((e,t)=>{let n=Oe.multi?Ae.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(Oe.multi){je(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Y.current;Y.current=null,ke(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)}),(Oe.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),Oe.multi&&(0,X.jsx)(`div`,{className:`dialog-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current,t=(e?.options??[]).filter((e,t)=>Ae.includes(t)).map(e=>e.label);Y.current=null,ke(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),Oe.kind===`confirm`&&(0,X.jsx)(`div`,{className:`dialog-body`,children:(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y.current;Y.current=null,ke(null);try{e?.resolve(!1)}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current;Y.current=null,ke(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),Oe.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Me,placeholder:Oe.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>Ne(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Y.current;Y.current=null,ke(null);try{e?.resolve({ok:!0,value:Me})}catch{}}}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y.current;Y.current=null,ke(null);try{e?.resolve({ok:!1})}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current;Y.current=null,ke(null);try{e?.resolve({ok:!0,value:Me})}catch{}},children:e(`ok`)})]})]})]}),We&&(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:()=>Ue(We.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[We.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,We.pluginId).replace(`{hosts}`,(We.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,We.pluginId).replace(`{models}`,(We.models??[]).length>0?` ${(We.models??[]).join(`, `)}`:``),We.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:We.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Ue(We.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Ue(We.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>Ue(We.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),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(`pluginGrantRequestTitle`)}),(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:[e(`pluginGrantRequestBody`).replace(`{plugin}`,Be.pluginId).replace(`{path}`,Be.path),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 primary`,onClick:()=>ze(Be.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),Ee&&(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:()=>{Ee.resolve(!1),De(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,Ee.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Ee.resolve(!1),De(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{Ee.resolve(!0),De(null)},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(gh,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||xt))?.title}),n.remoteQuestion&&(0,X.jsx)(gh,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(ev,{plan:n.state?.plan}),(0,X.jsx)(eh,{composerLeading:E[`composer.leading`],composerActions:E[`composer.actions`],onUiAction:R,streaming:n.state?.isStreaming??!1,messages:n.state?.messages??Dv,slashCommands:n.slashCommands,modelState:Zt,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:Ht,onAddImageFiles:Ut,onAddLocalFiles:Wt,onAddPathAttachment:qt,fileSearch:n.fileSearch,onSearchFiles:Kt,onNotice:a,onManageModels:Bt,onSent:Vt,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:Ft,dshPermCurrent:n.state?.permission??null,dshPermOptions:n.dshPermission?.options??void 0,dshPermDefault:n.dshPermission?.defaultPreset,dshPreset:n.state?.agentPreset??null,dshPresets:n.dshPresets?.presets??void 0,dshPresetDefault:n.dshPresets?.defaultPreset,dshBlank:(n.state?.messages?.length??0)===0,conversationId:n.activeConversationId||n.state?.conversationId||``,sessionDraft:n.engine===`pi`?n.state?.draft??null:null,sessionId:n.state?.sessionId??``})]}),!K&&(0,X.jsx)(Fv,{side:`right`,width:ce,onResize:de}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${_e===`right`?`open`:``}${K?``:me?` hidden`:``}`,children:(0,X.jsx)(Jc,{collapsible:!K,onToggleCollapse:G,panelSend:yt,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{ve(null),_t(e,t,n,r)},onPreview:(e,t)=>{ve(null),y(e,t)},onNotice:(e,t)=>a(e,t),uiRightPanelTabs:E[`rightpanel.tabs`],uiContextFile:E[`contextmenu.file`],plugins:T,pluginsEpoch:n.pluginsEpoch,send:r})}),!K&&me&&(0,X.jsx)(Iv,{side:`right`,onClick:G})]}),(0,X.jsx)(`div`,{className:`view-pane ${w===`terminal`?``:`hidden`}`,children:(0,X.jsx)(m.Suspense,{fallback:null,children:(0,X.jsx)(Tv,{chat:n,terminal:o,uiTerminalToolbar:A,onUiAction:R})})}),(0,X.jsx)(`div`,{className:`view-pane ${w===`git`?``:`hidden`}`,children:(0,X.jsx)(Ah,{chat:n,terminal:o,active:w===`git`,onSwitchToTerminal:()=>C(`terminal`),uiScmToolbar:ee,onUiAction:R})}),te.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${w===t?``:`hidden`}`,children:(0,X.jsx)(jh,{entry:e})},e.info.id)}),w.startsWith(`plugin:`)&&!te.some(e=>`plugin:${e.info.id}`===w)&&(0,X.jsx)(Mh,{pluginId:w.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===w),epoch:n.pluginsEpoch,failed:B.includes(w.slice(7))})]})}),(0,X.jsx)(uh,{chat:n,bottombarItems:E.bottombar,onUiAction:R}),f&&(0,X.jsx)(vv,{file:f,content:n.fileContent,onAddLines:(e,t,n,r)=>_t(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>_t(e,t,n),onClose:()=>p(null),uiFilePreviewToolbar:F,onUiAction:R}),h&&(0,X.jsx)(Cv,{file:h.file,plugin:h.plugin,declaration:h.declaration,epoch:n.pluginsEpoch,send:r,onClose:()=>g(null),onFallback:()=>{g(null),p(h.file)}}),n.ready&&n.state&&n.state.piConfigured===!1&&!ye&&!be&&(0,X.jsx)(ig,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>J(!0)}),be&&(0,X.jsx)(mg,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,fetchModelsResult:n.fetchModelsResult,testModelConnectionResult:n.testModelConnectionResult,enrichModelsResult:n.enrichModelsResult,enrichModelsProgress:n.enrichModelsProgress,refreshBuiltinResult:n.refreshBuiltinResult,appendBuiltinResult:n.appendBuiltinResult,cloneProviderResult:n.cloneProviderResult,defaultModel:n.defaultModel,onClose:()=>xe(!1)}),Se&&(0,X.jsx)(W_,{chat:n,terminal:o,initialSection:we,onSwitchToTerminal:()=>C(`terminal`),onClose:()=>Ce(!1),sound:Qe,onSoundChange:$e,tts:et,onTtsChange:tt}),Ke&&(0,X.jsx)(Z_,{servers:n.bgServers,onClose:()=>qe(!1)}),(0,X.jsx)(uv,{}),(0,X.jsx)(Q_,{}),(0,X.jsx)($_,{approval:n.approval}),H&&(0,X.jsx)(gv,{entry:H,pluginView:U?te.find(e=>e.info.id===U):void 0,onUiAction:(e,t)=>{R(e,t),re(null)},onClose:()=>re(null)}),(0,X.jsx)(hv,{open:Je,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>Ye(!1),onSwitchSession:(e,t)=>{r({type:`switch_session`,path:e});let n=t&&t[0];Ze(n?{path:e,role:n.role,timestamp:n.timestamp}:null)},onSwitchProject:e=>{r({type:`set_cwd`,path:e})},onPreviewFile:(e,t)=>{y(e,t)}}),(0,X.jsx)(Jh,{})]})}function Uv(){typeof document<`u`&&(Wv(Gv()),qv())}function Wv(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function Gv(){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 Kv(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 qv(){let e=()=>{let e=document.querySelector(`.messages`);return e?(Wv(Kv(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)}qt(),Yl(ql()),Uv(),(0,A.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(m.StrictMode,{children:(0,X.jsx)(fn,{children:(0,X.jsx)(Hv,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=Ut();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,dt as c,le as d,ce as f,N as g,R as h,Ql as i,Fe as l,z as m,hp as n,pn as o,se as p,Kl as r,Z as s,_p as t,_e as u};
|
|
363
|
+
`).length)),autoFocus:r,placeholder:l(`promptOverridePlaceholder`),value:t,onFocus:t=>{j.current=e,B(e);let r=t.currentTarget;r.value&&r.value===n&&r.setSelectionRange(r.value.length,r.value.length)},onBlur:()=>{j.current===e&&(j.current=null);let t=k[e]??``;if(t.trim()&&t===n){ii(e);return}ri(e),t.trim()||B(null)},onChange:t=>A(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:l(`promptSourceRefLabel`)}),i&&(0,X.jsx)(`button`,{type:`button`,className:`source-default-toggle`,onClick:()=>ai(e),children:V[e]?l(`promptSourceCollapse`):l(`promptSourceExpand`)})]}),n.trim()?(0,X.jsx)(`pre`,{className:`source-default-text${i?V[e]?` expanded`:` clamped`:``}`,children:n}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:l(`promptSourceDefaultEmpty`)}),!t.trim()&&n.trim()&&(0,X.jsx)(`button`,{type:`button`,className:`override-seed-btn`,title:l(`promptSourceSeedTip`),onClick:()=>oi(e,n),children:l(`promptSourceSeedButton`)})]})]}):(0,X.jsx)(`div`,{className:`source-default`,title:l(`promptSourceDefaultEditHint`),role:`button`,tabIndex:0,onClick:()=>oi(e,n),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),oi(e,n))},children:n.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?V[e]?` expanded`:` clamped`:``}`,children:n}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ai(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ai(e))},children:V[e]?l(`promptSourceCollapse`):l(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:l(`promptSourceDefaultEmpty`)})})]},e)}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-btn`,onClick:si,disabled:!li,children:l(`promptResetAll`)})})]})]}),x===`prompt`&&!b&&(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`}),l(`scmCommitMsgSettingsTitle`),(0,X.jsx)(bc,{text:l(`scmCommitMsgSettingsDesc`)})]}),(0,X.jsx)(B_,{label:l(`visionBridgePromptMode`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:pe,onChange:e=>{let t=e.target.value;me(t),Q({scmCommitMsgPromptMode:t})},children:[(0,X.jsx)(`option`,{value:`append`,children:l(`promptModeAppend`)}),(0,X.jsx)(`option`,{value:`replace`,children:l(`promptModeReplace`)})]})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:l(`scmCommitMsgPromptPlaceholder`),value:de,onFocus:()=>he.current=!0,onBlur:()=>{he.current=!1;let e=pe===`replace`&&g.scmCommitMsgDefaultPrompt&&de===g.scmCommitMsgDefaultPrompt?``:de;Q({scmCommitMsgPromptMode:pe,scmCommitMsgPrompt:e})},onChange:e=>fe(e.target.value)}),(0,X.jsx)(`p`,{className:`set-hint`,children:l(`scmCommitMsgSettingsHint`)})]}),x===`scheduler`&&!b&&(0,X.jsx)(Sg,{tasks:e.schedulerTasks,cwd:e.state?.cwd??``,models:g.subagentModels}),x===`prompt-history`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ve,{className:`set-section-icon`}),l(`settingsPromptHistory`),(0,X.jsx)(bc,{text:l(`settingsPromptHistoryDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:l(`promptHistoryCount`,{n:String(bt)})})]}),bt===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`promptHistoryEmpty`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:l(`promptHistoryCount`,{n:String(bt)})}),(0,X.jsx)(B_,{label:l(`promptHistoryMax`),tip:l(`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(vt.maxEntries),onChange:e=>{let t=Math.floor(Number(e.target.value)||0),n={...vt,maxEntries:t};yt(n)},onBlur:()=>{let e={...vt};(!Number.isFinite(e.maxEntries)||e.maxEntries<1)&&(e.maxEntries=1),e.maxEntries>500&&(e.maxEntries=500),e.maxEntries=Math.floor(e.maxEntries),yt(e),ym(e),wt()}})}),(0,X.jsx)(I_,{title:l(`promptHistoryCharLimit`),tip:l(`promptHistoryCharLimitHint`),enabled:vt.charLimitEnabled,onToggle:()=>{let e={...vt,charLimitEnabled:!vt.charLimitEnabled};yt(e),ym(e),wt()}}),vt.charLimitEnabled&&(0,X.jsx)(B_,{label:l(`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:l(`promptHistoryCharLimitPlaceholder`),value:String(vt.charLimit),onChange:e=>{let t=Math.floor(Number(e.target.value)||0);yt({...vt,charLimit:t})},onBlur:()=>{let e=Math.floor(Number(vt.charLimit)||0);(!Number.isFinite(e)||e<100)&&(e=100),e>2e4&&(e=2e4);let t={...vt,charLimit:e};yt(t),ym(t),wt()}})}),(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:12},children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${St?` confirm`:``}`,disabled:bt===0,title:l(bt===0?`promptHistoryEmpty`:`promptHistoryClear`),onClick:()=>{if(!St){Ct(!0);return}Tm(),Ct(!1),wt()},children:[(0,X.jsx)(R,{}),` `,l(St?`promptHistoryClearConfirm`:`promptHistoryClear`)]}),bt>0&&(0,X.jsx)(`span`,{className:`set-hint`,style:{marginLeft:8},children:l(`promptHistoryCount`,{n:String(bt)})})]}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[(0,X.jsx)(it,{style:{verticalAlign:`-2px`,marginRight:4}}),l(`settingsPromptHistoryDesc`)]})]}),x===`tools`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(te,{className:`set-section-icon`}),l(`settingsTools`)]}),Bn&&(0,X.jsxs)(`p`,{className:`set-catalog-hint warn`,children:[l(`toolsPresetBanner`,{name:Hn,count:Wn+Gn}),` `,(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>$({type:`dsh_preset_default`,preset:`standard`}),children:l(`toolsBackToStandard`)})]}),(0,X.jsx)(I_,{title:l(`readDirEnabled`),tip:l(`readDirEnabledDesc`),enabled:g.readDirEnabled!==!1,onToggle:()=>Q({readDirEnabled:g.readDirEnabled===!1})}),(0,X.jsx)(I_,{title:l(`toolApprovalEnabled`),tip:l(`toolApprovalEnabledDesc`),enabled:g.toolApprovalEnabled!==!1,onToggle:()=>Q({toolApprovalEnabled:g.toolApprovalEnabled===!1}),action:b?void 0:(0,X.jsxs)(`button`,{type:`button`,className:`tpl-chip`,onClick:()=>S(`approval-rules`),title:l(`settingsApprovalRulesDesc`),children:[(0,X.jsx)(U,{}),` `,l(`manageApprovalRules`)]})}),e.dshPermission&&e.dshPermission.options.length>0&&(0,X.jsxs)(`div`,{className:`set-mode-row`,style:{marginTop:8,marginBottom:8},children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[l(`dshPermDefault`),(0,X.jsx)(bc,{text:l(`dshPermDefaultDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:Gm.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:l(Km(e))},e))})]}),_?.allowAll||(_?.categories.length??0)>0?(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolApprovalPolicyTitle`),(0,X.jsx)(bc,{text:l(`toolApprovalPolicyHint`)})]}),_?.allowAll&&(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:l(`toolApprovalPolicyAllowAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,allowAll:!1}),children:l(`toolApprovalPolicyRevoke`)})]}),(_?.categories??[]).map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:u===`zh`?e.label:e.labelEn}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,categories:(_?.categories??[]).filter(t=>t.id!==e.id).map(e=>e.id)}),children:l(`toolApprovalPolicyRevoke`)})]},e.id))]}):null,(0,X.jsx)(B_,{label:l(`toolWatchdogTimeout`),tip:l(`toolWatchdogTimeoutDesc`),htmlFor:`tool-watchdog-timeout`,children:(0,X.jsx)(`input`,{id:`tool-watchdog-timeout`,className:`set-input`,type:`number`,min:0,step:1,placeholder:l(`toolWatchdogOff`),value:Cn,onChange:e=>wn(e.target.value),onBlur:()=>{let e=Cn.trim(),t=e===``?20:Math.max(0,Math.floor(Number(e)||0));wn(String(t));let n=t*6e4;n!==g.toolWatchdogTimeoutMs&&Q({toolWatchdogTimeoutMs:n})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionCore`),(0,X.jsx)(bc,{text:l(`toolsCoreHint`)})]}),ur.map(e=>{let t=Un(e);return(0,X.jsx)(I_,{title:e,tip:mr[e],subtitle:t?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!t&&!Ln.has(e),disabled:t,onToggle:()=>hr(e)},e)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:l(`toolsSectionTerminal`)}),Kn.map(e=>{let t=Un(e);return(0,X.jsx)(I_,{title:e,tip:l(`settingsTerminalToolsDesc`),subtitle:t?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!t&&!Ln.has(e),disabled:t,onToggle:()=>hr(e)},e)}),(0,X.jsx)(I_,{title:l(`terminalBashTakeover`),tip:l(`terminalBashTakeoverDesc`),enabled:g.terminalBash,onToggle:()=>Q({terminalBash:!g.terminalBash})}),g.terminalBash&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(B_,{label:l(`terminalBashIdleMs`),tip:l(`terminalBashIdleMsDesc`),htmlFor:`tb-idle-ms`,children:(0,X.jsx)(`input`,{id:`tb-idle-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:yn,onChange:e=>bn(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(yn)||0));bn(String(e)),e!==g.terminalBashIdleMs&&Q({terminalBashIdleMs:e})}})}),(0,X.jsx)(B_,{label:l(`terminalBashMaxForegroundMs`),tip:l(`terminalBashMaxForegroundMsDesc`),htmlFor:`tb-max-ms`,children:(0,X.jsx)(`input`,{id:`tb-max-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:xn,onChange:e=>Sn(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(xn)||0));Sn(String(e)),e!==g.terminalBashMaxForegroundMs&&Q({terminalBashMaxForegroundMs:e})}})})]}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionSubagent`),` `,(0,X.jsx)(bc,{text:l(`toolsSubagentDepHint`)})]}),qn.map(e=>{let t=Un(e);return(0,X.jsx)(I_,{title:e,tip:pr[e],subtitle:t?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!t&&!Ln.has(e),disabled:t,onToggle:()=>hr(e)},e)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`settingsMarkers`),(0,X.jsx)(bc,{text:`${l(`settingsMarkersDesc`)}\n${l(`markerRenameTip`)}`})]}),(0,X.jsx)(I_,{title:l(`markersEnabled`),tip:`${l(`markersEnabledDesc`)}\n${l(`markersOffHint`)}`,enabled:yr,onToggle:()=>Q({markersEnabled:!yr})}),yr&&(g.markers?.length??0)===0&&(0,X.jsxs)(`p`,{className:`set-empty`,children:[l(`loading`),`...`]}),yr&&g.markers&&g.markers.length>0&&g.markers.map(e=>(0,X.jsx)(I_,{title:e.name===`todo`?l(`markerGroupTodo`):e.name===`notify`?l(`markerGroupNotify`):e.name===`conv`?l(`markerGroupRename`):e.name,tip:e.guidance.join(`
|
|
364
|
+
`),enabled:e.enabled,onToggle:()=>xr(e.name)},e.name)),(0,X.jsx)(I_,{title:`todo_list`,tip:`${l(`todoListEnabledDesc`)}\n${l(`todoListOffHint`)}`,subtitle:Un(`todo_list`)?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!Un(`todo_list`)&&!Ln.has(`todo_list`),disabled:Un(`todo_list`),onToggle:()=>hr(`todo_list`)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:l(`toolsSectionOther`)}),k_.map(e=>{let t=Un(e.name);return(0,X.jsx)(I_,{title:e.name,tip:`${d(e.descKey??e.name)}\n${d(e.offHintKey??e.name)}`,subtitle:t?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!t&&!Ln.has(e.name),disabled:t,onToggle:()=>hr(e.name)},e.name)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionPlugin`),(0,X.jsx)(bc,{text:l(`toolsPluginHint`)})]}),vr.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:e.plugins.length===0?l(`noUiPlugins`):l(`pluginToolsEmpty`)}):vr.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)(I_,{title:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name,tip:e.description?`${e.description}\n${l(`pluginToolOffHint`)}`:l(`pluginToolOffHint`),subtitle:Bn?l(`toolsBlockedByPreset`,{name:Hn}):void 0,enabled:!Bn&&!gr.has(e.name),disabled:Bn,onToggle:()=>_r(e.name)},e.name))]},e.plugin.id))]}),x===`question`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Te,{className:`set-section-icon`}),l(`settingsQuestionnaire`)]}),(0,X.jsx)(I_,{title:l(`questionnaireEnabled`),tip:`${l(`questionnaireEnabledDesc`)}\n${l(`questionnaireOffHint`)}`,enabled:g.questionnaireEnabled,onToggle:()=>Q({questionnaireEnabled:!g.questionnaireEnabled})})]}),x===`display`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(K,{className:`set-section-icon`}),l(`settingsMessageDisplay`)]}),(0,X.jsx)(B_,{label:l(`softCapTokens`),tip:l(`softCapHint`),htmlFor:`soft-cap-max`,children:(0,X.jsx)(`input`,{id:`soft-cap-max`,className:`set-input`,type:`text`,placeholder:l(`softCapOff`),value:Dn,onChange:e=>On(e.target.value),onBlur:()=>{let e=Mg(Dn);On(Ng(e)),e!==(g.softCapTokens??0)&&Q({softCapTokens:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-section-title`,children:[l(`softCapByModel`),(0,X.jsx)(bc,{text:l(`softCapByModelHint`)})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`softCapModelId`),value:kn,maxLength:200,onChange:e=>An(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,placeholder:l(`softCapTokens`),value:jn,onChange:e=>Mn(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&kn.trim()&&Mg(jn)>0){let e=Mg(jn);Q({softCapByModel:{...g.softCapByModel,[kn.trim()]:e}}),An(``),Mn(``)}}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!kn.trim()||Mg(jn)<=0,onClick:()=>{let e=kn.trim(),t=Mg(jn);!e||t<=0||(Q({softCapByModel:{...g.softCapByModel,[e]:t}}),An(``),Mn(``))},children:[(0,X.jsx)(se,{}),` `,l(`softCapAdd`)]})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Object.entries(g.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:Ng(t),onBlur:t=>{let n=Mg(t.target.value);t.target.value=Ng(n);let r={...g.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:l(`softCapRemove`),onClick:()=>{let t={...g.softCapByModel};delete t[e],Q({softCapByModel:t})},children:[(0,X.jsx)(N,{}),` `,l(`softCapRemove`)]})]},e))}),(0,X.jsx)(B_,{label:l(`modelRetryAttempts`),tip:l(`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:Tn,onChange:e=>En(e.target.value),onBlur:()=>{let e=Math.min(100,Math.max(0,Math.floor(Number(Tn)||0)));En(String(e)),e!==g.retryMaxAttempts&&Q({retryMaxAttempts:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(I_,{title:l(`thinkingWrap`),tip:l(`thinkingWrapDesc`),enabled:g.thinkingWrap??!0,onToggle:()=>Q({thinkingWrap:!(g.thinkingWrap??!0)})}),(0,X.jsx)(I_,{title:l(`toolsWrap`),tip:l(`toolsWrapDesc`),enabled:g.toolsWrap??!0,onToggle:()=>Q({toolsWrap:!(g.toolsWrap??!0)})}),(0,X.jsx)(I_,{title:l(`toolImages`),tip:l(`toolImagesDesc`),enabled:g.toolImagesEnabled??!0,onToggle:()=>Q({toolImagesEnabled:!(g.toolImagesEnabled??!0)})}),(0,X.jsx)(I_,{title:l(`presentAutoOpen`),tip:l(`presentAutoOpenDesc`),enabled:rt,onToggle:()=>od(!rt)}),(0,X.jsx)(I_,{title:l(`parallelReminderEnabled`),tip:`${l(`parallelReminderEnabledDesc`)}\n${l(`parallelReminderOffHint`)}`,enabled:g.parallelReminderEnabled??!0,onToggle:()=>Q({parallelReminderEnabled:!(g.parallelReminderEnabled??!0)})}),(0,X.jsx)(I_,{title:l(`devNoCache`),tip:l(`devNoCacheDesc`),enabled:g.devNoCache??!0,onToggle:()=>Q({devNoCache:!(g.devNoCache??!0)})}),(0,X.jsx)(I_,{title:l(`autoReload`),tip:l(`autoReloadDesc`),enabled:g.autoReload??!0,onToggle:()=>Q({autoReload:!(g.autoReload??!0)})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(0,X.jsx)(I_,{title:l(`wideChat`),tip:l(`wideChatDesc`),enabled:nt,onToggle:()=>Rg({wide:!nt})}),(0,X.jsx)(I_,{title:l(`projectTitle`),tip:l(`projectTitleDesc`),enabled:ot,onToggle:()=>Yg({projectName:!ot})}),(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:[l(`wallpaperTitle`),(0,X.jsx)(bc,{text:l(`wallpaperDesc`)})]}),(0,X.jsxs)(`div`,{className:`wallpaper-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input wallpaper-url`,placeholder:l(`wallpaperUrlPh`),value:ct,maxLength:2e3,spellCheck:!1,onFocus:()=>{ut.current=!0},onChange:e=>lt(e.target.value),onBlur:()=>{if(ut.current=!1,!ct.trim()&&st.url.startsWith(`data:`)){lt(``);return}let e=o_(ct);lt(e),e!==st.url&&p_({...st,url:e})},onKeyDown:e=>{e.key===`Enter`?e.target.blur():e.key===`Escape`&&(lt(st.url.startsWith(`data:`)?``:st.url),e.target.blur())}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:pt,onClick:()=>ft.current?.click(),children:[(0,X.jsx)(I,{}),` `,l(`wallpaperUpload`)]}),(0,X.jsx)(`input`,{ref:ft,type:`file`,accept:`image/*`,hidden:!0,onChange:_t})]}),ht&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`wallpaperUploadFailed`)}),(0,X.jsxs)(`div`,{className:`wallpaper-sliders`,children:[(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:l(`wallpaperDim`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:95,step:1,value:st.dim,onChange:e=>p_({...st,dim:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[st.dim,`%`]})]}),(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:l(`wallpaperBlur`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:24,step:1,value:st.blur,onChange:e=>p_({...st,blur:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[st.blur,`px`]})]})]})]}),st.url&&(0,X.jsxs)(`div`,{className:`wallpaper-current`,children:[(0,X.jsx)(`img`,{className:`wallpaper-preview`,src:st.url,alt:``}),(0,X.jsx)(`button`,{type:`button`,className:`wallpaper-clear`,onClick:()=>{lt(``),p_({...st,url:``})},children:l(`wallpaperClear`)})]})]})]}),x===`sound`&&(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`}),l(`settingsSoundVoice`)]}),(0,X.jsx)(hn,{settings:a,onChange:o,onPreview:e=>jg(e,a)}),(0,X.jsx)(_n,{settings:s,onChange:c,onPreview:()=>zt(l(`ttsPreviewLine`),{...s,enabled:!0})})]}),x===`quick`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(G,{className:`set-section-icon`}),l(`quickPhrases`),(0,X.jsx)(bc,{text:l(`quickPhrasesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.quickPhrases.length})]}),(0,X.jsx)(I_,{title:l(`quickPhrasesEnabled`),tip:l(`quickPhrasesDesc`),enabled:g.quickPhrasesEnabled,onToggle:()=>Q({quickPhrasesEnabled:!g.quickPhrasesEnabled})}),!g.quickPhrasesEnabled&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`quickPhrasesOffHint`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`quickPhrasesPlaceholder`),value:fn,maxLength:200,onChange:e=>mn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&fn.trim()&&(Q({quickPhrases:[...g.quickPhrases,fn.trim()]}),mn(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!fn.trim(),onClick:()=>{Q({quickPhrases:[...g.quickPhrases,fn.trim()]}),mn(``)},children:[(0,X.jsx)(se,{}),` `,l(`quickPhrasesAdd`)]})]}),g.quickPhrases.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`quickPhrasesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.quickPhrases.map((e,t)=>(0,X.jsx)(`div`,{className:`set-row`,children:gn?.index===t?(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`input`,{className:`set-input`,autoFocus:!0,value:gn.value,maxLength:200,placeholder:l(`quickPhrasesEditPh`),onChange:e=>vn({index:t,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?tr():e.key===`Escape`&&vn(null)},onBlur:tr})}):(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:l(`quickPhrasesEdit`),onClick:()=>vn({index:t,value:e}),children:(0,X.jsx)(Pe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`quickPhrasesMoveUp`),disabled:t===0,onClick:()=>{let e=[...g.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:l(`quickPhrasesMoveDown`),disabled:t===g.quickPhrases.length-1,onClick:()=>{let e=[...g.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:l(`quickPhrasesDelete`),onClick:()=>Q({quickPhrases:g.quickPhrases.filter((e,n)=>n!==t)}),children:(0,X.jsx)(R,{})})]})]})},`${t}:${e}`))}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>{vn(null),Q({quickPhrases:S_[u]??S_.en})},children:l(`quickPhrasesReset`)})})]}),x===`skills`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Le,{className:`set-section-icon`}),l(`settingsSkills`),(0,X.jsx)(bc,{text:`${l(`skillFullTextLabel`)}:${l(`skillFullTextDesc`)}`}),(0,X.jsx)(`span`,{className:`set-count`,children:g.skills.length})]}),!b&&Bn&&!fr(zn??void 0)&&(0,X.jsx)(`p`,{className:`set-catalog-hint warn`,children:l(`skillsHiddenByPreset`,{name:Hn})}),g.skills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(b?`dshSkillsNote`:`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.skills.map(e=>(0,X.jsx)(I_,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>nr(e),action:(0,X.jsx)(`button`,{type:`button`,className:`tpl-chip${rr.has(e.name)?` on`:``}`,title:l(`skillFullTextDesc`),onClick:()=>ir(e.name),children:l(`skillFullTextShort`)})},e.name))})]}),x===`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`}),l(`settingsExtensions`),(0,X.jsx)(`span`,{className:`set-count`,children:g.extensions.length})]}),g.extensions.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(b?`dshExtensionsNote`:`noExtensions`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.extensions.map(e=>{let t=e.id.startsWith(`npm:`)?e.id.slice(4):null;return(0,X.jsx)(I_,{title:e.name,subtitle:e.path,enabled:e.enabled,onToggle:()=>cr(e),action:t?Tt===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:l(`uninstallConfirmHint`),onClick:()=>Cr(t),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`uninstallHint`),onClick:()=>Et(e.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]}):void 0},e.id)})})]}),x===`layout`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(H,{className:`set-section-icon`}),l(`uiLayoutTitle`),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:Br,children:l(`uiLayoutRestoreAll`)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:l(`uiLayoutHint`)}),Nn.length>0&&(0,X.jsxs)(`details`,{className:`set-ui-diag`,open:Nn.some(e=>e.level===`error`),children:[(0,X.jsxs)(`summary`,{children:[`⚠ `,l(`uiLayoutDiagTitle`,{n:Nn.length})]}),(0,X.jsx)(`ul`,{className:`set-ui-diag-list`,children:Nn.map((e,t)=>(0,X.jsxs)(`li`,{className:`set-ui-diag-item ${e.level}`,children:[e.pluginId?(0,X.jsx)(`code`,{children:e.pluginId}):null,e.entryId?(0,X.jsx)(`code`,{children:e.entryId}):null,(0,X.jsx)(`span`,{children:e.message})]},`${e.pluginId??`host`}:${e.entryId??t}`))}),(0,X.jsx)(`div`,{className:`set-ui-diag-hint`,children:l(`uiLayoutDiagHint`)})]}),(0,X.jsx)(`input`,{className:`set-ui-filter`,value:Ar,placeholder:l(`uiLayoutSearch`),"aria-label":l(`uiLayoutSearch`),onChange:e=>jr(e.target.value)}),Or.map(({slot:e,labelKey:t})=>{let n=(Pn[e]??[]).filter(e=>(b||e.id!==`host:composer-dsh-perm`&&e.id!==`host:composer-dsh-preset`)&&!ni.has(e.id)),r=Ar.trim().toLowerCase(),i=!r&&kr.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}],a=i.reduce((e,t)=>e+t.items.length,0);if(r&&a===0)return null;let o=(t,i)=>{let a=i.findIndex(e=>e.id===t.id),o=ti.has(t.id);return(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`label`,{className:`set-toggle`,title:o?l(`uiLayoutRequired`):t.id,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!t.hidden,disabled:o,onChange:()=>Fr(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:l(`uiLayoutArranged`)}),t.movedFrom&&(0,X.jsxs)(`span`,{className:`set-ui-source`,title:t.id,children:[l(`uiLayoutMovedFrom`),`: `,Mr(t.movedFrom)]}),kr.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:l(`uiLayoutAlign`),children:(0,X.jsxs)(`select`,{value:t.align,onChange:e=>Lr(t.id,e.target.value),"aria-label":l(`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:Nr?.labels?.[t.id]??``,placeholder:l(`uiLayoutRename`),title:l(`uiLayoutRename`),"aria-label":l(`uiLayoutRename`),onBlur:e=>{e.target.value!==(Nr?.labels?.[t.id]??``)&&Rr(t.id,e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.target.blur()}},`${t.id}:${Nr?.labels?.[t.id]??``}`),t.userOverrides.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>zr(t.id),children:l(`uiLayoutRestore`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<=0,onClick:()=>Ir(n,i,t.id,-1),children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<0||a>=i.length-1,onClick:()=>Ir(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:l(t)}),e===`topbar.primary`&&(0,X.jsxs)(`label`,{className:`set-toggle`,title:`topbarText`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Nr?.topbarText!==!1,onChange:e=>Pr({topbarText:e.target.checked})}),(0,X.jsx)(`span`,{children:l(`uiLayoutTopbarText`)})]}),n.length===0?(0,X.jsx)(`div`,{className:`set-empty`,children:l(`uiLayoutEmpty`)}):i.map(e=>(0,X.jsxs)(m.Fragment,{children:[e.align&&(0,X.jsx)(`div`,{className:`set-ui-slot-title set-ui-seg`,children:e.align}),e.items.map(t=>o(t,e.items))]},e.align??`all`))]},e)})]}),x===`plugins`&&!y&&(0,X.jsxs)(`div`,{className:`set-subtabs`,role:`tablist`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":C===`market`,className:`set-subtab${C===`market`?` active`:``}`,onClick:()=>{w(`market`),T.current?.scrollTo({top:0})},children:[l(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":C===`installed`,className:`set-subtab${C===`installed`?` active`:``}`,onClick:()=>{w(`installed`),T.current?.scrollTo({top:0})},children:[(0,X.jsx)(Qe,{}),l(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(Yn||Xn)&&(0,X.jsx)(`span`,{className:`update-dot`,style:{marginLeft:4}})]})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Oe,{className:`set-section-icon`}),l(`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:l(`pluginGrantsHint`)}),e.pluginGrants.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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:l(`pluginGrantsRevoke`)})]},t))]},e.pluginId))})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Se,{className:`set-section-icon`}),l(`pluginPermsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:(e.pluginPermissions??[]).length})]}),(0,X.jsx)(`div`,{className:`set-note`,children:l(`pluginPermsHint`)}),(e.pluginPermissions??[]).length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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`?l(`pluginPermNet`):l(`pluginPermLlm`),e.session?` · ${l(`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:l(`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:l(`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??l(`pluginPermUnscoped`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:e.family}),children:l(`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}`))})]}),x===`plugins`&&y&&(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-note`,children:l(`updatesManaged`)})}),x===`plugins`&&!y&&C===`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`}),l(`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:l(`pluginBuildHint`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Yt,onChange:e=>Xt(e.target.checked)}),l(`pluginBuildSource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogSyncHint`),onClick:()=>Qt(e=>!e),children:[(0,X.jsx)(oe,{}),l(`pluginCatalogSync`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogAddHint`),onClick:()=>Jt(e=>!e),children:[(0,X.jsx)(se,{}),l(`pluginCatalogAdd`)]})]}),Zt&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`div`,{className:`set-note`,children:l(`pluginCatalogSyncHint`)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogSyncSource`),value:$t,onChange:e=>en(e.target.value),onKeyDown:e=>{e.key===`Enter`&&qr($t)}}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:l(`pluginCatalogSyncInstall`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:tn,onChange:e=>nn(e.target.checked)}),l(`pluginCatalogSyncInstall`)]}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:l(`pluginCatalogSyncReplace`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:rn,onChange:e=>an(e.target.checked)}),l(`pluginCatalogSyncReplace`)]}),un.length>0&&(0,X.jsxs)(`div`,{className:`set-catalog-recent`,children:[(0,X.jsx)(`span`,{className:`set-catalog-recent-label`,children:l(`pluginCatalogSyncRecent`)}),un.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-catalog-recent-item`,title:e,onClick:()=>{en(e),qr(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:!$t.trim(),onClick:()=>qr($t),children:l(`pluginCatalogSyncSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Qt(!1),children:l(`cancel`)})]}),Qr&&(Qr.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[(0,X.jsxs)(`span`,{children:[`✓ `,l(`pluginCatalogSyncOk`,{n:Qr.entryCount??0}),Qr.installed?` · ${l(`pluginCatalogSyncInstalled`,{ok:Qr.installed.filter(e=>e.ok).length,fail:Qr.installed.filter(e=>!e.ok).length})}`:null]}),Qr.installed?.some(e=>!e.ok)&&(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:Qr.installed.filter(e=>!e.ok).map(e=>`${e.id}:${e.error??`?`}`).join(`
|
|
365
|
+
`)})]}):(0,X.jsx)(`div`,{className:`set-catalog-job error`,children:(0,X.jsxs)(`span`,{children:[`✗ `,Qr.error||l(`pluginJobFailed`)]})}))]}),qt&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogSource`),value:It,onChange:e=>Lt(e.target.value)}),Er(Zr),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogId`),value:Rt,onChange:e=>Bt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogName`),value:Vt,onChange:e=>Ht(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogIcon`),value:Gt,onChange:e=>Kt(e.target.value)}),(0,X.jsx)(`textarea`,{className:`set-input`,rows:2,placeholder:l(`pluginCatalogDesc`),value:Ut,onChange:e=>Wt(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!It.trim(),onClick:Kr,children:l(`pluginCatalogAddSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Jt(!1),children:l(`cancel`)})]})]}),e.pluginCatalog.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noPluginCatalog`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.pluginCatalog.map(t=>{let n=or.has(t.id),r=e.pluginUpdates?.[t.id],i=n&&r?.updatable===!0,a=!!(Tr(t.id)&&Tr(t.id)?.phase!==`done`);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)(Gr,{icon:t.icon,iconSvg:t.iconSvg}),` `,t.name]}),n&&(0,X.jsx)(`span`,{className:`set-catalog-installed`,children:l(`pluginInstalled`)}),!t.builtin&&(0,X.jsx)(`span`,{className:`set-catalog-custom`,children:l(`pluginCatalogCustom`)}),i&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:r?.latestVersion?`${r?.version??``} → v${r.latestVersion}`:r?.remoteSha??``,children:[l(`pluginUpdateAvailableBadge`),r?.latestVersion?` v${r.latestVersion}`:``]})]}),t.description&&(0,X.jsx)(`div`,{className:`set-catalog-desc`,children:t.description}),(0,X.jsx)(`div`,{className:`set-catalog-source`,children:t.source}),Dr(t.id)]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${i?` accent`:``}`,disabled:a,title:i&&r?.latestVersion?l(`pluginUpdateAvailableDetail`,{version:`v${r.latestVersion}`}):l(`pluginUpdateHint`),onClick:()=>Hr(t.id,t.source),children:[(0,X.jsx)(oe,{className:a?`set-job-spin`:``}),l(a?`pluginJobRunning`:`pluginUpdate`)]}),Dt===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:a,title:l(`pluginUninstallHint`),onClick:()=>Vr(t.id),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:a,title:l(`pluginUninstallHint`),onClick:()=>Ot(t.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]})]}):(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginInstallHint`),disabled:a,onClick:()=>Ur(t),children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{className:`set-job-spin`}),l(`pluginJobRunning`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ie,{}),l(`pluginInstall`)]})}),!t.builtin&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogRemoveHint`),onClick:()=>Wr(t.id),children:(0,X.jsx)(N,{})})]})]},t.id)})})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Qe,{className:`set-section-icon`}),l(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCheckUpdatesHint`),disabled:e.checkingPluginUpdates,onClick:()=>$({type:`check_plugin_updates`}),children:[(0,X.jsx)(oe,{className:e.checkingPluginUpdates?`spin`:``}),e.checkingPluginUpdates?l(`checkingUpdate`):l(`pluginCheckUpdates`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginRescanHint`),onClick:()=>$({type:`plugins_reload`}),children:[(0,X.jsx)(oe,{}),l(`pluginRescan`)]})]}),e.plugins.length>0&&(0,X.jsx)(z_,{plugins:e.plugins,disabledIds:ar}),e.plugins.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noUiPlugins`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.plugins.map(t=>{let n=e.pluginUpdates?.[t.id],r=n?.updatable===!0,i=!!(Tr(t.id)&&Tr(t.id)?.phase!==`done`);return(0,X.jsxs)(m.Fragment,{children:[(0,X.jsx)(I_,{title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R_,{phase:b_(t,ar.has(t.id)),label:d(L_(b_(t,ar.has(t.id))))}),(0,X.jsx)(Gr,{icon:t.icon,iconSvg:t.iconSvg}),` `,t.name,r&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:n?.latestVersion?`v${t.version??`0.0.0`} → v${n.latestVersion}`:n?.remoteSha??``,children:[l(`pluginUpdateAvailableBadge`),n?.latestVersion?` v${n.latestVersion}`:``]})]}),subtitle:(t.error?`${t.id} · ${t.error}`:t.source?`${t.id} · ${t.source}`:`${t.id} · ${l(`uiPluginNoSource`)}`)+(t.permissions?.length?` · ${l(`uiPluginPerms`)}: ${t.permissions.join(`, `)}`:``),enabled:!ar.has(t.id)&&!t.error,onToggle:()=>!t.error&&sr(t),action:(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[t.source&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${r?` accent`:``}`,disabled:i,title:r&&n?.latestVersion?l(`pluginUpdateAvailableDetail`,{version:`v${n.latestVersion}`}):l(`pluginUpdateHint`),onClick:()=>Hr(t.id,t.source),children:[(0,X.jsx)(oe,{className:i?`set-job-spin`:``}),l(i?`pluginJobRunning`:`pluginUpdate`)]}),Dt===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:i,title:l(`pluginUninstallHint`),onClick:()=>Vr(t.id),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:i,title:l(`pluginUninstallHint`),onClick:()=>Ot(t.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]})]})},t.id),Dr(t.id),t.agentTools&&t.agentTools.length>0&&!b&&(0,X.jsxs)(`div`,{className:`set-row`,title:l(`pluginToolOffHint`),children:[(0,X.jsxs)(`span`,{className:`set-ui-source`,children:[l(`pluginToolsSection`),` (`,t.agentTools.length,`)`,t.agentTools.some(e=>gr.has(e.name))?` · ${l(`settingsDisabled`)}`:``]}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>S(`tools`),children:[l(`settingsTools`),` →`]})})]}),(0,X.jsxs)(`div`,{className:`set-row set-log-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>{jt===t.id?Mt(null):(Mt(t.id),$(_s(t.id)))},children:[(0,X.jsx)(je,{}),l(`pluginLogTitle`),` (`,ws(t.id).length,`) ·`,` `,jt===t.id?l(`pluginLogHide`):l(`pluginLogShow`)]}),jt===t.id&&(0,X.jsx)(V_,{pluginId:t.id})]}),t.diagnostics&&t.diagnostics.length>0&&(0,X.jsxs)(`div`,{className:`set-row set-diag-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>At(kt===t.id?null:t.id),children:[(0,X.jsx)(at,{}),l(`pluginDiagTitle`),` (`,t.diagnostics.length,`) ·`,` `,kt===t.id?l(`pluginDiagHide`):l(`pluginDiagShow`)]}),kt===t.id&&(0,X.jsx)(`ul`,{className:`set-diag-list`,children:t.diagnostics.map((e,n)=>(0,X.jsx)(`li`,{children:e},`${t.id}-${n}`))})]}),t.wantsDom&&(0,X.jsxs)(`div`,{className:`set-row`,title:l(`pluginDomDesc`),children:[(0,X.jsx)(`span`,{className:`set-ui-source`,children:t.domGranted?l(`pluginDomGranted`):l(`pluginDomNeed`)}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall${t.domGranted?``:` confirm`}`,title:l(`pluginDomDesc`),onClick:()=>$({type:`plugin_dom_consent`,pluginId:t.id,granted:!t.domGranted}),children:t.domGranted?l(`pluginDomRevoke`):l(`pluginDomGrant`)})})]}),t.settingsSchema&&t.settingsSchema.length>0&&(0,X.jsxs)(`div`,{className:`set-row set-settings-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>Pt(e=>({...e,[t.id]:!e[t.id]})),children:[(0,X.jsx)(H,{}),l(`pluginSettingsTitle`),` (`,t.settingsSchema.length,`) ·`,` `,Nt[t.id]?l(`pluginSettingsHide`):l(`pluginSettingsShow`)]}),Nt[t.id]&&(0,X.jsx)(gg,{plugin:t,models:g?.subagentModels??[]})]})]},t.id)})})]}),x===`plugins`&&b&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Qe,{className:`set-section-icon`}),l(`dshPatches`),(0,X.jsx)(bc,{text:l(`dshPatchesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPatches?.files.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`dshPatchesRescanHint`),onClick:()=>$({type:`dsh_patches_rescan`}),children:[(0,X.jsx)(oe,{}),l(`dshPatchesRescan`)]})]}),(e.dshPatches?.files.length??0)===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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:[P_(e.size),` · `,new Date(e.mtimeMs).toLocaleString()]})]})},e.name))}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[l(`dshPatchesPath`),` `,e.dshPatches?.patchDir??``]})]}),x===`review`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(M,{className:`set-section-icon`}),l(`settingsReview`),(0,X.jsx)(bc,{text:l(`settingsReviewDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.reviewSkills.length})]}),(0,X.jsx)(I_,{title:l(`goalModeEnabled`),tip:`${l(`goalModeEnabledDesc`)}\n${l(`goalModeOffHint`)}`,enabled:g.goalModeEnabled,onToggle:()=>Q({goalModeEnabled:!g.goalModeEnabled})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:5,placeholder:l(`reviewPromptPlaceholder`),value:ge,onFocus:()=>ve.current=!0,onBlur:()=>{ve.current=!1,Q({reviewPrompt:ge})},onChange:e=>_e(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`settingsReviewSkills`),b&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(bc,{text:l(`dshReviewPromptNote`)})]})]}),g.reviewSkills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.reviewSkills.map(e=>(0,X.jsx)(I_,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>$r(e)},`review-${e.name}`))})]}),x===`vision`&&(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`}),l(`settingsVisionBridge`)]}),(0,X.jsx)(I_,{title:l(`visionBridgeEnabled`),tip:`${l(`settingsVisionBridgeDesc`)}\n${l(`visionBridgeOffHint`)}`,enabled:g.visionBridgeEnabled,onToggle:()=>Q({visionBridgeEnabled:!g.visionBridgeEnabled})}),g.visionBridgeEnabled&&(0,X.jsx)(B_,{label:l(`visionBridgeModel`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:g.visionBridgeModel??``,onChange:e=>Q({visionBridgeModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:l(`visionBridgeAuto`)}),g.visionModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),g.visionBridgeEnabled&&(0,X.jsx)(B_,{label:l(`visionBridgePromptMode`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:ae,onChange:e=>{let t=e.target.value;ce(t),Q({visionBridgePromptMode:t})},children:[(0,X.jsx)(`option`,{value:`append`,children:l(`promptModeAppend`)}),(0,X.jsx)(`option`,{value:`replace`,children:l(`promptModeReplace`)})]})}),g.visionBridgeEnabled&&(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:l(`visionBridgePromptPlaceholder`),value:re,onFocus:()=>le.current=!0,onBlur:()=>{le.current=!1;let e=ae===`replace`&&g.visionBridgeDefaultPrompt&&re===g.visionBridgeDefaultPrompt?``:re;Q({visionBridgePromptMode:ae,visionBridgePrompt:e})},onChange:e=>ie(e.target.value)}),g.visionBridgeEnabled&&(g.visionModels.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`visionBridgeNoModels`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:l(`visionBridgeCurrent`,{model:g.visionBridgeModel??l(`visionBridgeAuto`)})}))]}),x===`presets`&&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)(Le,{className:`set-section-icon`}),l(`dshPreset`),(0,X.jsx)(bc,{text:l(`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:l(`dshDefaultPreset`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPresets.defaultPreset,onChange:e=>$({type:`dsh_preset_default`,preset:e.target.value}),children:Hm(e.dshPresets.presets).map(e=>(0,X.jsxs)(`option`,{value:e.id,disabled:!!e.broken,children:[e.name??e.id,e.trust===`user`?` · ${l(`dshPresetUser`)}`:``]},e.id))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Hm(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:l(`dshPresetUser`)}),t.id===e.dshPresets.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:l(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:l(`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:l(`dshPresetUserNote`)})]}),x===`presets`&&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)(U,{className:`set-section-icon`}),l(`dshPerm`),(0,X.jsx)(bc,{text:l(`dshPermDefaultDesc`)})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`dshPermDefault`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:Gm.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:l(Km(e))},e))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Gm.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:[l(Km(t)),t===e.dshPermission.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:l(`dshPresetDefaultTag`)})]}),(0,X.jsx)(`div`,{className:`set-row-desc`,children:l(qm(t))})]})},t))})]}),x===`presets`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(W,{className:`set-section-icon`}),l(`settingsPresets`),(0,X.jsx)(`span`,{className:`set-count`,children:g.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`presetNamePlaceholder`),value:q,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&q.trim()&&($({type:`save_preset`,name:q.trim()}),ye(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!q.trim(),onClick:()=>{$({type:`save_preset`,name:q.trim()}),ye(``)},children:[(0,X.jsx)(se,{}),` `,l(`saveAsPreset`)]})]}),g.presets.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noPresets`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.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`?l(`promptModeReplace`):l(`promptModeAppend`),e.disabledSkills.length>0&&` · ${l(`settingsSkills`)} ${e.disabledSkills.length}`,e.disabledExtensions.length>0&&` · ${l(`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:l(`applyPreset`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`deletePreset`),onClick:()=>$({type:`delete_preset`,name:e.name}),children:(0,X.jsx)(R,{})})]})]},e.name))})]}),x===`subagent-templates`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(F,{className:`set-section-icon`}),l(`settingsSubagentTemplates`),(0,X.jsx)(bc,{text:l(`settingsSubagentTemplatesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.subagentTemplates.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:l(`subagentTemplateNew`),onClick:()=>{be({name:``,description:``,promptMode:`replace`,systemPrompt:``,enabledSkills:[],enabledExtensions:[],model:``,thinkingLevel:``,enabled:!0}),Ce(!0)},children:[(0,X.jsx)(se,{}),` `,l(`subagentTemplateNew`)]})]}),(0,X.jsx)(B_,{label:l(`subagentDefaultModelLabel`),tip:l(`subagentDefaultModelHint`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:g.subagentDefaultModel??``,onChange:e=>Q({subagentDefaultModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:l(`subagentFollowMain`)}),g.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),g.subagentModels.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`subagentNoModels`)}),J&&(0,X.jsx)(`div`,{className:`modal-backdrop tpl-modal-backdrop`,onClick:()=>be(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":l(`close`),onClick:()=>be(null),children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(F,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:xe?l(`subagentTemplateNew`):`${l(`subagentTemplateEdit`)} · ${J.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:l(`tplNamePlaceholder`),value:J.name,onChange:e=>be({...J,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`tplDescriptionPlaceholder`),value:J.description,onChange:e=>be({...J,description:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`tplDescriptionEnPlaceholder`),value:J.descriptionEn??``,onChange:e=>be({...J,descriptionEn:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`tplPromptModeLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:J.promptMode,onChange:e=>be({...J,promptMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`replace`,children:l(`promptModeReplace`)}),(0,X.jsx)(`option`,{value:`append`,children:l(`promptModeAppend`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`tplModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:J.model??``,onChange:e=>be({...J,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:l(`subagentFollowMain`)}),g.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:[l(`tplThinkingLabel`),` `,(0,X.jsx)(bc,{text:l(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:J.thinkingLevel??``,onChange:e=>be({...J,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:l(`tplThinkingFollowMain`)}),zm.map(e=>(0,X.jsx)(`option`,{value:e,children:l(`thinking.${e}`)},e))]})]}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${l(`tplSystemPromptLabel`)}${u===`zh`?`:`:`: `}${l(`tplSystemPromptPlaceholder`)}`,value:J.systemPrompt,onChange:e=>be({...J,systemPrompt:e.target.value})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${l(`tplSystemPromptLabel`)}: ${l(`tplSystemPromptEnPlaceholder`)}`,value:J.systemPromptEn??``,onChange:e=>be({...J,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:[l(`tplSkillsLabel`),` · `,l(`tplWhitelistHint`)]})}),g.skills.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`noSkills`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:g.skills.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${J.enabledSkills.includes(e.name)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:J.enabledSkills.includes(e.name),onChange:t=>{let n=t.target.checked;be({...J,enabledSkills:n?[...J.enabledSkills,e.name]:J.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:[l(`tplExtensionsLabel`),` · `,l(`tplWhitelistHint`)]})}),g.extensions.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`noExtensions`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:g.extensions.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${J.enabledExtensions.includes(e.id)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:J.enabledExtensions.includes(e.id),onChange:t=>{let n=t.target.checked;be({...J,enabledExtensions:n?[...J.enabledExtensions,e.id]:J.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:!J.name.trim(),onClick:()=>{$({type:`save_subagent_template`,template:{...J,name:J.name.trim()}}),be(null)},children:l(`tplSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>be(null),children:l(`tplCancel`)})]})]})}),g.subagentTemplates.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noSubagentTemplates`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:g.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,g.subagentDefaultTemplates.includes(e.name)&&(0,X.jsx)(`span`,{className:`tpl-badge default`,children:l(`tplDefaultBadge`)}),!e.enabled&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:l(`subagentTemplateClosed`)})]}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[(u!==`zh`&&e.descriptionEn?e.descriptionEn:e.description)||`${e.promptMode===`replace`?l(`promptModeReplace`):l(`promptModeAppend`)}`,e.model?` · ${l(`tplModelLabel`)} ${e.model}`:` · ${l(`subagentFollowMain`)}`,e.thinkingLevel?` · ${l(`tplThinkingLabel`)} ${d(`thinking.${e.thinkingLevel}`)}`:``,e.enabledSkills.length>0&&` · ${l(`tplSkillsLabel`)} ${e.enabledSkills.length}`,e.enabledExtensions.length>0&&` · ${l(`tplExtensionsLabel`)} ${e.enabledExtensions.length}`,!e.description&&e.enabledSkills.length===0&&e.enabledExtensions.length===0&&` · ${l(`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?l(`subagentTemplateDisable`):l(`subagentTemplateEnable`)} · ${l(`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:l(`subagentTemplateEdit`),onClick:()=>{be({...e}),Ce(!1)},children:l(`subagentTemplateEdit`)}),we===e.name?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:l(`uninstallConfirmHint`),onClick:()=>{$({type:`delete_subagent_template`,name:e.name}),Ee(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`tplDelete`),onClick:()=>Ee(e.name),children:(0,X.jsx)(R,{})})]})]},e.name))})]}),x===`approval-rules`&&!b&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(U,{className:`set-section-icon`}),l(`settingsApprovalRules`),(0,X.jsx)(bc,{text:l(`settingsApprovalRulesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.approvalRules?.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:l(`approvalRuleNew`),onClick:()=>{ke({id:`custom.${dt().slice(0,8)}`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:``,action:`ask`,label:``,labelEn:``,reason:``,reasonEn:``}),Re(`bash`),Ne(!0),Be(null)},children:[(0,X.jsx)(se,{}),` `,l(`approvalRuleNew`)]})]}),Y&&(0,X.jsxs)(`div`,{className:`rule-editor`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,style:{fontSize:13,marginBottom:4},children:Ae?l(`approvalRuleNew`):`${l(`approvalRuleEdit`)} · ${Y.label}`}),(0,X.jsx)(B_,{label:l(`approvalRuleLabel`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.label,placeholder:`例如:拦截 Docker 危险操作`,onChange:e=>ke({...Y,label:e.target.value})})}),(0,X.jsx)(B_,{label:l(`approvalRuleLabelEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.labelEn??``,placeholder:`e.g. Block dangerous Docker commands`,onChange:e=>ke({...Y,labelEn:e.target.value})})}),(0,X.jsx)(B_,{label:l(`approvalRuleTools`),tip:l(`approvalRuleToolsTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Fe,placeholder:`bash, write, edit (或 * 通配)`,onChange:e=>{Re(e.target.value);let t=e.target.value.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);ke({...Y,tools:t.length>0?t:[`*`]})}})}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:10,flexWrap:`wrap`},children:[(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(B_,{label:l(`approvalRuleField`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:Y.field,onChange:e=>ke({...Y,field:e.target.value}),children:[(0,X.jsx)(`option`,{value:`command`,children:l(`approvalRuleFieldCommand`)}),(0,X.jsx)(`option`,{value:`path`,children:l(`approvalRuleFieldPath`)}),(0,X.jsx)(`option`,{value:`params`,children:l(`approvalRuleFieldParams`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(B_,{label:l(`approvalRuleMatch`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:Y.match,onChange:e=>ke({...Y,match:e.target.value}),children:[(0,X.jsx)(`option`,{value:`regex`,children:l(`approvalRuleMatchRegex`)}),(0,X.jsx)(`option`,{value:`glob`,children:l(`approvalRuleMatchGlob`)}),(0,X.jsx)(`option`,{value:`contains`,children:l(`approvalRuleMatchContains`)}),(0,X.jsx)(`option`,{value:`prefix`,children:l(`approvalRuleMatchPrefix`)}),(0,X.jsx)(`option`,{value:`outside_workspace`,children:l(`approvalRuleMatchOutsideWs`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(B_,{label:`命中动作`,children:(0,X.jsxs)(`select`,{className:`set-select`,value:Y.action,onChange:e=>ke({...Y,action:e.target.value}),children:[(0,X.jsx)(`option`,{value:`ask`,children:l(`approvalRuleActionAsk`)}),(0,X.jsx)(`option`,{value:`deny`,children:l(`approvalRuleActionDeny`)}),(0,X.jsx)(`option`,{value:`allow`,children:l(`approvalRuleActionAllow`)})]})})})]}),Y.match!==`outside_workspace`&&(0,X.jsx)(B_,{label:l(`approvalRuleValue`),tip:l(`approvalRuleValueTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.value,placeholder:`匹配表达式或关键字…`,onChange:e=>ke({...Y,value:e.target.value})})}),(0,X.jsx)(B_,{label:l(`approvalRuleReason`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.reason??``,placeholder:`例如:检测到删除镜像或容器操作`,onChange:e=>ke({...Y,reason:e.target.value})})}),(0,X.jsx)(B_,{label:l(`approvalRuleReasonEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.reasonEn??``,placeholder:`e.g. Detected docker image/container removal`,onChange:e=>ke({...Y,reasonEn:e.target.value})})}),(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`label`,{className:`set-checkbox-label`,style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Y.enabled,onChange:e=>ke({...Y,enabled:e.target.checked})}),l(`approvalRuleEnabled`)]})}),ze&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12},children:ze}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:4},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{ke(null),Be(null)},children:l(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{if(!Y.label.trim()){Be(`请填写规则名称`);return}if(Y.match===`regex`)try{new RegExp(Y.value)}catch(e){Be(`正则表达式非法:${e.message}`);return}$({type:`save_approval_rule`,rule:Y}),ke(null),Be(null)},children:l(`save`)})]})]}),(g.approvalRules??[]).length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`approvalRuleEmpty`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:(g.approvalRules??[]).map((e,t)=>{let n=e.builtin===!0;return(0,X.jsxs)(`div`,{className:`set-row${e.enabled?``:` rule-row-disabled`}`,style:{alignItems:`flex-start`,padding:`12px 0`},children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,style:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:6},children:[(0,X.jsx)(`span`,{className:`rule-badge ${e.action}`,children:e.action===`deny`?l(`approvalRuleActionDeny`):e.action===`allow`?l(`approvalRuleActionAllow`):l(`approvalRuleActionAsk`)}),(0,X.jsx)(`strong`,{style:{fontSize:13},children:u===`zh`?e.label:e.labelEn||e.label}),n&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:l(`approvalRuleBuiltin`)}),(0,X.jsx)(`span`,{className:`rule-meta-code`,children:e.tools.join(`, `)})]}),(0,X.jsxs)(`div`,{className:`set-hint`,style:{marginTop:6,display:`flex`,flexDirection:`column`,gap:3},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:6,flexWrap:`wrap`},children:[(0,X.jsxs)(`span`,{style:{opacity:.85,fontSize:11,fontFamily:`var(--mono)`},children:[`[`,e.field,` · `,e.match,`]`]}),e.match!==`outside_workspace`&&(0,X.jsx)(`code`,{className:`rule-pattern-code`,children:e.value})]}),(e.reason||e.reasonEn)&&(0,X.jsx)(`div`,{style:{opacity:.75,fontSize:11},children:u===`zh`?e.reason:e.reasonEn||e.reason})]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,style:{marginLeft:12,flexShrink:0},children:[(0,X.jsx)(`button`,{type:`button`,className:`set-switch${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,title:e.enabled?l(`settingsEnabled`):l(`settingsDisabled`),onClick:()=>$({type:`save_approval_rule`,rule:{...e,enabled:!e.enabled}}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})}),!n&&t>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleMoveUp`),onClick:()=>{let e=[...g.approvalRules??[]],n=e[t-1];e[t-1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(Ke,{})}),!n&&t<(g.approvalRules?.length??0)-1&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleMoveDown`),onClick:()=>{let e=[...g.approvalRules??[]],n=e[t+1];e[t+1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(Je,{})}),n&&(We===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`reset_builtin_approval_rule`,id:e.id}),Ge(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleReset`),onClick:()=>Ge(e.id),children:(0,X.jsx)(oe,{})})),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleEdit`),onClick:()=>{ke({...e}),Re(e.tools.join(`, `)),Ne(!1),Be(null)},children:(0,X.jsx)(Pe,{})}),!n&&(He===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`delete_approval_rule`,id:e.id}),Ue(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`approvalRuleDelete`),onClick:()=>Ue(e.id),children:(0,X.jsx)(R,{})}))]})]},e.id)})})]}),Qn&&(0,X.jsx)(kc,{plugin:Qn.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:l(`close`)})})]})})}var G_=0,K_=``;function q_(){typeof document<`u`&&(G_===0&&(K_=document.body.style.overflow,document.body.style.overflow=`hidden`),G_++)}function J_(){typeof document<`u`&&(G_=Math.max(0,G_-1),G_===0&&(document.body.style.overflow=K_))}function Y_({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:f=!0}){let p=Z(),h=(0,m.useRef)(t);if((0,m.useLayoutEffect)(()=>{h.current=t}),yt(()=>l?(h.current(),!0):!1,e),(0,m.useEffect)(()=>{if(e&&f)return q_(),()=>{J_()}},[e,f]),!e)return null;let g=e=>{e.target===e.currentTarget&&c&&h.current()},_=d??(typeof n==`string`?n:void 0);return(0,k.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":p(`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 X_(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 Z_({servers:e,onClose:t}){let n=Z(),[r,i]=(0,m.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,m.useEffect)(()=>{$({type:`list_bg_servers`})},[]),(0,X.jsxs)(Y_,{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)(xe,{}),` `,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)(N,{})})]}),e.length===0?(0,X.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,X.jsx)(xe,{}),(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`),` `,X_(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)(z,{}),(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)(ne,{}),(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)(ne,{}),(0,X.jsx)(`span`,{children:n(`bgTaskStopAll`)})]})]})]})}function Q_(){let e=Z(),t=rf(),[n,r]=(0,m.useState)(!0),i=(0,m.useRef)(null);return(0,m.useEffect)(()=>{t&&r(!0)},[t]),yt(()=>{t&&tf()},!!t),(0,m.useEffect)(()=>{if(!t)return;let e=e=>{if(e.key!==`Enter`||e.shiftKey||e.ctrlKey||e.metaKey)return;let t=e.target;(!t||t===document.body||i.current?.contains(t))&&(e.preventDefault(),nf(n))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,n]),t?(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:tf,children:(0,X.jsxs)(`div`,{ref:i,className:`tool-info-modal rollback-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`rollbackSession`),onClick:e=>e.stopPropagation(),style:{maxWidth:520},children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,style:{color:`var(--amber, #f59e0b)`},children:[(0,X.jsx)(at,{}),e(`rollbackSession`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`cancel`),onClick:tf,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[(0,X.jsx)(`p`,{style:{margin:`0 0 16px 0`,fontSize:14,lineHeight:1.6},children:e(`rollbackConfirm`)}),(0,X.jsxs)(`label`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`12px 14px`,borderRadius:8,backgroundColor:`var(--bg-elev, rgba(255, 255, 255, 0.04))`,border:`1px solid var(--border-subtle, rgba(255, 255, 255, 0.1))`,cursor:`pointer`,marginBottom:20},title:e(`rollbackRestoreWorkspaceTip`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),style:{marginTop:3,cursor:`pointer`}}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{style:{fontWeight:600,fontSize:13,color:`var(--text, #e2e8f0)`},children:e(`rollbackRestoreWorkspace`)}),(0,X.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginTop:2},children:e(`rollbackRestoreWorkspaceTip`)})]})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:tf,children:e(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{display:`inline-flex`,alignItems:`center`,gap:6,backgroundColor:`var(--amber, #f59e0b)`,borderColor:`var(--amber, #f59e0b)`,color:`#000`,fontWeight:600},onClick:()=>nf(n),children:[(0,X.jsx)(Ye,{}),e(`confirm`)]})]})]})]})}),document.body):null}function $_({approval:e}){let t=Z(),{locale:n}=pn(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(null);if((0,m.useEffect)(()=>{if(e){let t=e.params;i(typeof t==`object`&&t?JSON.stringify(t,null,2):t==null?`{}`:String(t)),o(null)}},[e]),!e)return null;let s=t=>{$({type:`tool_approval_response`,id:e.id,decision:`approve`,...t&&t!==`once`?{scope:t}:{}})},c=()=>{$({type:`tool_approval_response`,id:e.id,decision:`deny`,reason:`Operation rejected by user`})};return(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,children:(0,X.jsxs)(`div`,{className:`tool-info-modal approval-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`toolApprovalTitle`),style:{maxWidth:640,borderTop:`4px solid var(--amber, #f59e0b)`},onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,style:{color:`var(--amber, #f59e0b)`},children:[(0,X.jsx)(at,{}),t(`toolApprovalTitle`)]}),(0,X.jsx)(`code`,{className:`tool-info-name`,style:{fontWeight:700},children:e.toolName}),e.conversationTitle&&(0,X.jsx)(`span`,{className:`tool-info-label`,children:e.conversationTitle}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalDeny`),onClick:c,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[(e.reason||e.reasonEn)&&(0,X.jsxs)(`div`,{style:{padding:`10px 14px`,borderRadius:6,backgroundColor:`rgba(245, 158, 11, 0.12)`,border:`1px solid rgba(245, 158, 11, 0.3)`,marginBottom:16,color:`var(--amber, #f59e0b)`,fontSize:13,lineHeight:1.5,fontWeight:500},children:[(0,X.jsxs)(`div`,{style:{fontWeight:600,marginBottom:2},children:[t(`toolApprovalRiskAlert`),`:`]}),(0,X.jsx)(`div`,{children:e.reason||e.reasonEn}),e.category&&(0,X.jsxs)(`div`,{style:{marginTop:6,fontSize:12,opacity:.85},children:[t(`toolApprovalCategory`),`:`,n===`zh`?e.category.label:e.category.labelEn]})]}),(0,X.jsxs)(`div`,{style:{marginBottom:16},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:6},children:[(0,X.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`var(--text, #e2e8f0)`},children:t(`toolApprovalParams`)}),(0,X.jsx)(`span`,{style:{fontSize:11,color:`var(--text-dim, #9aa1b4)`},children:t(`toolApprovalEditPlaceholder`)})]}),(0,X.jsx)(`textarea`,{rows:8,value:r,onChange:e=>{i(e.target.value),a&&o(null)},style:{width:`100%`,fontFamily:`var(--mono, monospace)`,fontSize:12,lineHeight:1.5,padding:10,borderRadius:6,backgroundColor:`var(--bg-elev, #111827)`,color:`var(--text, #f8fafc)`,border:a?`1px solid var(--red, #ef4444)`:`1px solid var(--border-subtle, rgba(255,255,255,0.1))`,boxSizing:`border-box`,resize:`vertical`}}),a&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12,marginTop:4},children:a})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,justifyContent:`flex-end`,gap:10},children:[e.category&&(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowCategoryHint`),onClick:()=>s(`category`),children:[(0,X.jsx)(xe,{}),t(`toolApprovalAllowCategory`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowConversationHint`),onClick:()=>s(`all`),children:[(0,X.jsx)(Xe,{}),t(`toolApprovalAllowConversation`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,style:{color:`var(--red, #ef4444)`},onClick:c,children:[(0,X.jsx)(N,{}),t(`toolApprovalDeny`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>s(),style:{fontWeight:500},children:[(0,X.jsx)(Ye,{}),t(`toolApprovalApprove`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{display:`inline-flex`,alignItems:`center`,gap:6,backgroundColor:`var(--amber, #f59e0b)`,borderColor:`var(--amber, #f59e0b)`,color:`#000`,fontWeight:600},onClick:()=>{try{let t=e.params,n;n=typeof t==`object`&&t||t==null?JSON.parse(r):r,o(null),$({type:`tool_approval_response`,id:e.id,decision:`edit`,editedParams:n})}catch(e){o(`JSON 格式错误:${e.message}`)}},children:[(0,X.jsx)(Pe,{}),t(`toolApprovalEditAndRun`)]})]})]})]})}),document.body)}function ev({plan:e}){let t=Z(),[n,r]=(0,m.useState)(!1);if(!e||!e.steps||e.steps.length===0)return null;let i=e.steps,a=i.filter(e=>e.status===`done`).length,o=i.length,s=Math.round(a/o*100),c=i.find(t=>t.id===e.activeStepId)??i.find(e=>e.status===`in_progress`),l=()=>{window.confirm(`确定要清空当前任务计划看板吗?`)&&$({type:`plan_update`,steps:[]})},u=e=>{switch(e){case`done`:return(0,X.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,color:`var(--green, #22c55e)`,fontSize:12,fontWeight:600},children:[(0,X.jsx)(Xe,{}),t(`planBoardCompleted`)]});case`in_progress`:return(0,X.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,color:`var(--accent, #38bdf8)`,fontSize:12,fontWeight:600},children:[(0,X.jsx)(Ve,{}),t(`planBoardInProgress`)]});case`failed`:return(0,X.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,color:`var(--red, #ef4444)`,fontSize:12,fontWeight:600},children:[(0,X.jsx)(ot,{}),t(`planBoardFailed`)]});default:return(0,X.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:4,color:`var(--text-dim, #9aa1b4)`,fontSize:12},children:[(0,X.jsx)(Ue,{}),t(`planBoardPending`)]})}};return(0,X.jsxs)(`div`,{className:`plan-board`,style:{padding:`10px 14px`,borderRadius:8,backgroundColor:`var(--bg-elev, #18202f)`,border:`1px solid var(--border-subtle, rgba(255, 255, 255, 0.1))`,boxShadow:`0 2px 8px rgba(0, 0, 0, 0.15)`,fontSize:13},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,cursor:`pointer`,userSelect:`none`},onClick:()=>r(!n),children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flex:1,minWidth:0},children:[(0,X.jsx)(J,{style:{color:`var(--accent, #38bdf8)`,flexShrink:0}}),(0,X.jsx)(`span`,{style:{fontWeight:600,color:`var(--text, #f1f5f9)`},children:t(`planBoardTitle`)}),(0,X.jsxs)(`span`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginLeft:4},children:[a,`/`,o,` (`,s,`%)`]}),!n&&c&&(0,X.jsx)(`span`,{style:{marginLeft:8,fontSize:12,padding:`2px 8px`,borderRadius:4,backgroundColor:`rgba(56, 189, 248, 0.12)`,color:`var(--accent, #38bdf8)`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:260},children:c.title})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn-icon`,title:t(`clear`),style:{background:`none`,border:`none`,color:`var(--text-dim, #9aa1b4)`,cursor:`pointer`,padding:4,display:`inline-flex`},onClick:e=>{e.stopPropagation(),l()},children:(0,X.jsx)(R,{})}),(0,X.jsx)(`button`,{type:`button`,className:`btn-icon`,style:{background:`none`,border:`none`,color:`var(--text-dim, #9aa1b4)`,cursor:`pointer`,padding:4,display:`inline-flex`},children:n?(0,X.jsx)(Ke,{}):(0,X.jsx)(Je,{})})]})]}),(0,X.jsx)(`div`,{style:{height:4,backgroundColor:`rgba(255, 255, 255, 0.08)`,borderRadius:2,margin:`8px 0`,overflow:`hidden`},children:(0,X.jsx)(`div`,{style:{height:`100%`,width:`${s}%`,backgroundColor:s===100?`var(--green, #22c55e)`:`var(--accent, #38bdf8)`,transition:`width 0.3s ease`}})}),n&&(0,X.jsx)(`div`,{style:{marginTop:10,display:`flex`,flexDirection:`column`,gap:8},children:i.map((t,n)=>{let r=t.id===e.activeStepId||t.status===`in_progress`;return(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,padding:`6px 10px`,borderRadius:6,backgroundColor:r?`rgba(56, 189, 248, 0.08)`:`var(--bg-elev2, rgba(0, 0, 0, 0.2))`,border:r?`1px solid rgba(56, 189, 248, 0.25)`:`1px solid transparent`},children:[(0,X.jsxs)(`div`,{style:{flex:1,minWidth:0,paddingRight:10},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,X.jsxs)(`span`,{style:{fontSize:11,fontWeight:700,color:r?`var(--accent, #38bdf8)`:`var(--text-dim, #9aa1b4)`,minWidth:16},children:[n+1,`.`]}),(0,X.jsx)(`span`,{style:{fontWeight:r?600:500,color:t.status===`done`?`var(--text-dim, #9aa1b4)`:`var(--text, #f1f5f9)`,textDecoration:t.status===`done`?`line-through`:`none`},children:t.title})]}),t.description&&(0,X.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginTop:2,paddingLeft:22,lineHeight:1.4},children:t.description})]}),(0,X.jsx)(`div`,{style:{flexShrink:0,marginTop:2},children:u(t.status)})]},t.id||n)})})]})}var tv=3,nv=200;function rv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function iv(e){return typeof e==`string`&&e.trim()||void 0}function av(e,t){let n=[];for(let r of e){let e=sv(r,t);if(n.includes(e)||n.push(e),n.length>=4){n.push(`…`);break}}return n.join(` | `)||`any`}function ov(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 sv(e,t=0){if(t>6||!rv(e))return`any`;if(iv(e.$ref))return`ref`;let n=iv(e.type);if(n===`array`){let n=e.items;return`array<${n===void 0?`any`:sv(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 av(r,t+1)}return rv(e.properties)?`object`:rv(e.additionalProperties)?`record<${sv(e.additionalProperties,t+1)}>`:`any`}function cv(e){let t=[],n=e.enum;if(Array.isArray(n)&&n.length>0){let e=ov(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 lv(e,t={}){let n=t.maxDepth??tv,r=t.maxRows??nv,i=e;if(!rv(i))return[];let a=i.properties;if(!rv(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=rv(l)?l:{},u=t?`${t}.${s}`:s,d={name:u,type:sv(e,i),required:a.has(s),depth:i},f=iv(e.description);f&&(d.description=f);let p=cv(e);if(p&&(d.hint=p),o.push(d),i+1<n&&rv(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 uv(){let e=Z(),t=Ya();return yt(()=>{Ga()},!!t),t?(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:Ga,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)(Ce,{}),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:Ga,children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`div`,{className:`tool-info-body`,children:(0,X.jsx)(dv,{info:t})})]})}),document.body):null}function dv({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?[]:lv(e.parameters),r=e.parameters===void 0?``:pv(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)(fv,{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)(gl,{text:r})]}),(0,X.jsx)(`pre`,{children:r})]})]}),(0,X.jsx)(`div`,{className:`tool-info-foot`,children:t(`toolInfoFootnote`)})]})}function fv({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 pv(e){try{return JSON.stringify(e,null,2)??``}catch{return``}}function mv(e,t){return e.toLowerCase().includes(t)}function hv({open:e,projects:t,fileSearch:n,sessionSearch:r,onClose:i,onSwitchSession:a,onSwitchProject:o,onPreviewFile:s}){let c=Z(),{locale:l}=pn(),u=l===`en`?`Plugins`:`插件`,d=aa(`cwd`),f=(0,m.useRef)(null),[p,h]=(0,m.useState)(``),g=(0,m.useDeferredValue)(p),[_,v]=(0,m.useState)(0),y=(0,m.useRef)(1),b=(0,m.useRef)(0),x=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!e)return;$({type:`list_sessions`}),$({type:`list_projects`});let t=p.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(()=>f.current?.select())},[e]);let[S,C]=(0,m.useState)(!1);(0,m.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,m.useMemo)(()=>!w||!r||r.reqId!==b.current||!r.ok?[]:r.results,[r,w]),E=(0,m.useMemo)(()=>w?t.filter(e=>mv(e.path,w)).slice(0,10):[],[t,w]),D=(0,m.useMemo)(()=>!w||!n||n.reqId!==b.current||!n.ok?[]:n.results,[n,w]);(0,m.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,m.useState)([]);(0,m.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 So==`function`&&(r=So())}catch{r=[]}let i=r.filter(e=>e&&typeof e.id==`string`).map(e=>{if(typeof e.search==`function`)return e;try{let t=Do(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 ee=(0,m.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,m.useEffect)(()=>{v(0)},[g]);let j=(0,m.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`?lo(e.providerId,e.action,e.action).catch(()=>{}):s(e.path,e.name)}},[a,o,s,g]);(0,m.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),i()):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.max(0,Math.min(e+1,ee.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),j(ee[_]))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[ee,_,j,i,e]);let M=T.length+E.length+D.length+k.length,P=(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})]}),F=-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)(re,{}),(0,X.jsx)(`input`,{ref:f,type:`text`,value:p,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)(N,{})})]}),(0,X.jsxs)(`div`,{className:`gs-results`,children:[!w&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(`gsHint`)}),w&&M===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:[P(c(`gsSessions`),T.length,(0,X.jsx)(K,{})),T.map(e=>{F++;let t=F,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:()=>j({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(),Un({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:[P(c(`gsProjects`),E.length,(0,X.jsx)(Oe,{})),E.map(e=>{F++;let t=F,n=d&&e.path===d;return(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,onMouseEnter:()=>v(t),onClick:()=>j({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:[P(c(`gsFiles`),D.length,(0,X.jsx)(je,{})),D.map(e=>{F++;let t=F;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`&&j({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:[P(u,k.length,(0,X.jsx)(ue,{})),k.map((e,t)=>{F++;let n=F;return(0,X.jsxs)(`button`,{type:`button`,className:n===_?`gs-item active`:`gs-item`,title:e.providerLabel,onMouseEnter:()=>v(n),onClick:()=>j({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 gv({entry:e,pluginView:t,onUiAction:n,onClose:r}){let i=Z(),a=e.label||e.id,o=e.kind===`view`;return(0,X.jsx)(Y_,{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)(jh,{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 _v=5e3;function vv({file:e,content:t,onAddLines:n,onAttach:r,onClose:i,uiFilePreviewToolbar:a,onUiAction:o}){let s=Z(),[c,l]=(0,m.useState)(null),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(``),[C,w]=(0,m.useState)(!0),[T,E]=(0,m.useState)(!0),[D,O]=(0,m.useState)(!1),k=(0,m.useRef)(!1),[A,M]=(0,m.useState)(!0),[P,F]=(0,m.useState)(!1),[I,L]=(0,m.useState)(100),R=(0,m.useRef)(0),te=(0,m.useRef)(!1),z=(0,m.useRef)(null),[B,V]=(0,m.useState)(!1),[ne,H]=(0,m.useState)(!1),U=(0,m.useRef)(!1),W=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{z.current&&clearTimeout(z.current),W.current&&clearTimeout(W.current)},[]),(0,m.useEffect)(()=>{d(!0),l(null),p(null),b(!1),S(``),w(!0),E(!0),O(!1),k.current=!1,U.current=!1,V(!1),H(!1),W.current&&clearTimeout(W.current),$({type:`read_file`,path:e.path})},[e.path]),(0,m.useEffect)(()=>{t&&t.path===e.path&&(l(t),y||S(t.text),d(!1),U.current&&(U.current=!1,W.current&&clearTimeout(W.current),V(!1),H(!1),b(!1),S(t.text),k.current&&(yv(e.name)&&w(!0),xv(e.name)&&E(!0)),p(null)))},[t,y,e.path]),(0,m.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){pe();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&y){e.preventDefault(),fe();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(),se())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,c,y,x]),(0,m.useEffect)(()=>{let e=()=>{te.current=!1,g(!1)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let G=(0,m.useMemo)(()=>{if(!c)return[];let e=c.text.split(`
|
|
366
|
+
`);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,_v)},[c]),re=c?.lines??0,ae=re>_v,oe=(e,t)=>{if(t){let t=R.current>0?R.current:e;p({start:Math.min(t,e),end:Math.max(t,e)})}else R.current=e,p({start:e,end:e})},se=()=>{G.length!==0&&(R.current=1,p({start:1,end:G.length}))},ce=()=>{f&&(n(e.path,e.name,f.start,f.end),v(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>v(!1),1400))},le=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated&&!bv(e.name),ue=()=>{U.current=!1,W.current&&clearTimeout(W.current),V(!1),H(!1),S(c?.text??``),b(!1),k.current&&(yv(e.name)&&w(!0),xv(e.name)&&E(!0))},de=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;ue();return}le&&c&&(k.current=yv(e.name)&&C||xv(e.name)&&T,yv(e.name)&&w(!1),xv(e.name)&&E(!1),p(null),S(c.text),b(!0))},fe=()=>{y&&c&&le&&$({type:`write_file`,path:e.path,text:x})&&(U.current=!0,H(!1),V(!0),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{U.current=!1,V(!1),H(!0)},5e3))},pe=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},he=e=>{L(Math.min(200,Math.max(50,e)))},K=f?f.end-f.start+1:0,ge=c?.binary??!1,ve=c?.truncated??!1,q=c?.kind??`text`,ye=yv(e.name)||bv(e.name),J=xv(e.name),xe=ye&&C&&!y&&q===`text`&&!ge,Se=J&&T&&!y&&q===`text`&&!ge,Ce={"host:fp-md":ye&&q===`text`&&!ge&&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)(Me,{}):(0,X.jsx)(Be,{})}):null,"host:fp-html":J&&q===`text`&&!ge&&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)(Be,{}):(0,X.jsx)(Me,{})}):null,"host:fp-edit":q===`text`&&!ge&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(ve?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!le&&!y,onClick:de,children:(0,X.jsx)(Pe,{})}):null,"host:fp-wrap":q===`text`&&!ge&&!xe&&!Se?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${A?`on`:``}`,"data-tip":s(A?`disableWrap`:`enableWrap`),onClick:()=>M(e=>!e),children:(0,X.jsx)(Re,{})}):null,"host:fp-zoom":q===`text`&&c?(0,X.jsxs)(`span`,{className:`fp-zoom`,children:[(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-out`,"data-tip":s(`zoomOut`),disabled:I<=50,onClick:()=>he(I-10),children:(0,X.jsx)(ee,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>L(100),children:[I,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:I>=200,onClick:()=>he(I+10),children:(0,X.jsx)(j,{})})]}):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)(be,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${P?`on`:``}`,"data-tip":s(P?`exitFullscreen`:`fullscreen`),onClick:()=>F(e=>!e),children:P?(0,X.jsx)(me,{}):(0,X.jsx)(_e,{})}),"host:fp-close":null},we=a===void 0?[`host:fp-md`,`host:fp-html`,`host:fp-edit`,`host:fp-wrap`,`host:fp-zoom`,`host:fp-ref`,`host:fp-full`].map(e=>({id:e,source:`host`})):a.filter(e=>!e.hidden&&e.id!==`host:fp-close`),Te=e=>Yt(Gt(`/api/file?clientId=${encodeURIComponent(Hs())}&path=${encodeURIComponent(e)}`));return(0,X.jsx)(`div`,{className:`fp-overlay ${P?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&pe()},children:(0,X.jsxs)(`div`,{className:`fp ${P?`fullscreen`:``}`,style:{"--fp-zoom":I/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&&q===`text`&&!ge&&s(`fileLines`,{n:re}),c&&` · ${Sv(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:_p(we,Ce,o)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),"aria-label":s(`close`),onClick:pe,children:(0,X.jsx)(N,{})})]}),ve&&q===`text`&&!ge&&(0,X.jsx)(`div`,{className:`fp-notice`,children:bv(e.name)?s(`previewLinesTruncated`,{n:G.length}):s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&q===`none`&&!ge&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&q===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`img`,{className:`fp-media`,src:Te(e.path),alt:e.name})}),!u&&q===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:Te(e.path),controls:!0,preload:`metadata`})}),!u&&Se&&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 Yt(Gt(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(Hs())}${D?`&allowJs=1`:``}`))})(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&xe&&c&&(0,X.jsx)(`div`,{className:bv(e.name)?`fp-markdown msg-text fp-office`:`fp-markdown msg-text`,children:(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,children:(0,X.jsx)(uu,{text:c.text})})}),!u&&ge&&q!==`image`&&q!==`video`&&c&&(0,X.jsxs)(`div`,{className:`fp-hex-wrap`,children:[(0,X.jsxs)(`div`,{className:`fp-notice`,children:[s(`binaryFile`),c.truncated&&s(`binaryHexTruncated`)]}),(0,X.jsx)(`pre`,{className:`fp-hex`,children:c.text})]}),!u&&y&&q===`text`&&!ge&&c&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{className:`fp-editor ${A?``:`no-wrap`}`,value:x,onChange:e=>S(e.target.value),wrap:A?`soft`:`off`,spellCheck:!1,autoFocus:!0}),ne&&(0,X.jsx)(`div`,{className:`fp-notice`,role:`alert`,children:s(`saveResultUnknown`)})]}),!u&&!xe&&!Se&&!y&&q===`text`&&!ge&&c&&G.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!xe&&!Se&&!y&&q===`text`&&!ge&&G.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${h?`dragging`:``} ${A?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[G.map((e,t)=>{let n=t+1,r=f!==null&&n>=f.start&&n<=f.end;return(0,X.jsxs)(`div`,{className:`fp-line ${r?`sel`:``}`,onMouseDown:e=>{e.button===0&&(oe(n,e.shiftKey),te.current=!0,g(!0))},onMouseEnter:()=>{te.current&&oe(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),ae&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:_v})})]}),(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:de,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:B||x===(c?.text??``),onClick:fe,children:[(0,X.jsx)(ie,{}),` `,s(`saveFile`)]})]})]}):!xe&&!Se&&q===`text`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:f?s(`selectedRange`,{n:K,start:f.start,end:f.end}):s(`selectLinesHint`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:G.length===0,onClick:se,children:s(`selectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!f,onClick:()=>p(null),children:s(`clearSelection`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!f||ge,onClick:ce,children:[_?(0,X.jsx)(Ye,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function yv(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function bv(e){let t=e.toLowerCase();return t.endsWith(`.docx`)||t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`)}function xv(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function Sv(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function Cv({file:e,plugin:t,declaration:n,epoch:r,send:i,onClose:a,onFallback:o}){let s=Z(),c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(!1),p=(0,m.useRef)(o);p.current=o;let h=n.label??t.name;return(0,m.useEffect)(()=>{let r=c.current;if(!r)return;let a=!1,o;return u(null),f(!1),(async()=>{try{let s=await ng({plugin:t,declaration:n});if(a)return;if(!s)throw Error(`插件没有提供可用的文件查看器`);let c=`/plugins-api/${encodeURIComponent(t.id)}`,l={...hs(t.id,i),file:e,apiUrl:(e,t)=>{let n=String(e??``).startsWith(`/`)?String(e):`/${String(e??``)}`,r=new URLSearchParams;for(let[e,n]of Object.entries(t??{}))n!==void 0&&r.set(e,String(n));let i=r.toString();return Yt(Gt(`${c}${n}${i?`?${i}`:``}`))}};o=s.handler.mount(r,e,l),a||f(!0)}catch(e){a||(console.error(`[plugin:${t.id}] file handler failed:`,e),p.current())}})(),()=>{if(a=!0,typeof o==`function`)try{o()}catch(e){console.error(`[plugin:${t.id}] file handler cleanup failed:`,e)}r.textContent=``}},[e,t,n,r,i]),(0,X.jsx)(Y_,{className:`plugin-file-preview`,title:h,icon:t.icon,onClose:a,children:(0,X.jsxs)(`div`,{className:`modal-body plugin-file-preview-body`,children:[(0,X.jsx)(`div`,{className:`plugin-file-preview-file`,title:e.path,children:e.name}),l?(0,X.jsx)(`div`,{className:`plugin-file-preview-error`,children:l}):null,!l&&!d?(0,X.jsx)(`div`,{children:s(`loading`)}):null,(0,X.jsx)(`div`,{ref:c,className:`plugin-file-preview-host`})]})})}function wv(e,t,n,r,i){let a=new Map;for(let e of r)a.set(e.id,!!e.isStreaming);if(t&&a.set(t,n),e===null)return{startCue:!1,finishedConvs:[],nextMap:a};let o=!1;if(t&&(i===void 0||i===t)){let n=e.get(t),r=a.get(t)??!1;n===!1&&r===!0&&(o=!0)}let s=[];for(let[n,i]of e.entries())if(i&&a.has(n)&&!a.get(n)){let e=r.find(e=>e.id===n);s.push({id:n,title:e?.title,isActive:n===t})}return{startCue:o,finishedConvs:s,nextMap:a}}var Tv=(0,m.lazy)(()=>Go(()=>import(`./TerminalPanel-O3GyFIGG.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function Ev({notice:e,onDismiss:t}){let n=Z(),{locale:r}=pn(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,m.useState)(!1);(0,m.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`?ot:e.level===`warning`?at:Ce;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)(N,{})})]})}var Dv=[],Ov=180,kv=520,Av=240,jv=e=>`pi-web-ui:${e}-panel-width`;function Mv(e){try{let t=Number(localStorage.getItem(jv(e)));return Number.isFinite(t)&&t>=Ov&&t<=kv?t:Av}catch{return Av}}var Nv=e=>`pi-web-ui:${e}-panel-collapsed`;function Pv(e){try{return localStorage.getItem(Nv(e))===`1`}catch{return!1}}function Fv({side:e,width:t,onResize:n}){let r=Z(),i=(0,m.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(kv,Math.max(Ov,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`);try{localStorage.setItem(jv(e),String(o))}catch{}};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),document.body.classList.add(`panel-resizing`)},[e,t,n]);return(0,X.jsx)(`div`,{className:`resize-handle resize-${e}`,title:r(`dragToResize`),onPointerDown:i,onDoubleClick:()=>n(Av)})}function Iv({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)(We,{}):(0,X.jsx)(Ge,{})})}var Lv=`pi-web-ui:plugin-path-grants`,Rv=e=>e?`${Lv}:${e}`:Lv;function zv(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Bv(e){try{let t=Rv(e);if(localStorage.getItem(t)!==null)return zv(localStorage.getItem(t));if(!e)return[];let n=zv(localStorage.getItem(Lv));return localStorage.setItem(t,JSON.stringify(n)),n}catch{return[]}}function Vv(e,t){try{let n=[...new Set([...Bv(t),e])];localStorage.setItem(Rv(t),JSON.stringify(n))}catch{}}function Hv(){let e=Z(),{locale:t}=pn(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=Js(),s=(0,m.useRef)(!1);(0,m.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:S_[t]??S_.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=e_();(0,m.useEffect)(()=>{let t=l?qg(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,m.useState)([]);(0,m.useEffect)(()=>(zn(e=>d(t=>im(t,e))),()=>zn(null)),[]);let[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(null),_=(0,m.useRef)(!1),v=(0,m.useRef)(null);(0,m.useEffect)(()=>{_.current=f!==null,v.current=h},[f,h]);let y=(0,m.useCallback)((e,t)=>{let n=tg(t);if(n){p(null),g({file:{path:e,name:t},plugin:n.plugin,declaration:n.declaration});return}g(null),p({path:e,name:t})},[]);(0,m.useEffect)(()=>(nu({open:e=>y(e.path,e.name),isOpen:()=>_.current||v.current!==null}),()=>nu(null)),[y]);let[b,x]=(0,m.useState)(!1);(0,m.useEffect)(()=>{let e=()=>x(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[S,C]=(0,m.useState)(`chat`),w=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(S.startsWith(`plugin:`)?`plugins`:S)?S:`chat`,T=(0,m.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),E=(0,m.useMemo)(()=>{let r=[],i=xi(ui(n.plugins),{locale:t,t:t=>e(t),disabledPlugins:n.settings?.disabledPlugins??[],layout:n.settings?.uiLayout,diagnostics:r});for(let e of r)console.warn(`[ui-slot] ${e.pluginId?`[${e.pluginId}] `:``}${e.message}`);return i},[n.plugins,n.settings?.disabledPlugins,n.settings?.uiLayout,t,e]),D=(0,m.useMemo)(()=>E[`topbar.primary`].filter(e=>!e.hidden),[E]),O=(0,m.useMemo)(()=>[...E[`topbar.primary`].filter(e=>e.hidden),...E[`topbar.overflow`]],[E]),k=(0,m.useMemo)(()=>E[`leftpanel.sessions`].filter(e=>!e.hidden),[E]),A=(0,m.useMemo)(()=>E[`terminal.toolbar`].filter(e=>!e.hidden),[E]),ee=(0,m.useMemo)(()=>E[`scm.toolbar`].filter(e=>!e.hidden),[E]),j=(0,m.useMemo)(()=>E[`goalbar.actions`].filter(e=>!e.hidden),[E]),M=(0,m.useMemo)(()=>E[`chat.header`].filter(e=>!e.hidden),[E]),P=(0,m.useMemo)(()=>E[`chat.empty`].filter(e=>!e.hidden),[E]),F=(0,m.useMemo)(()=>E[`file.preview.toolbar`].filter(e=>!e.hidden),[E]),I=(0,m.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(e=>[e.id,e.name??e.id])),[n.dshPresets]),L=(0,m.useMemo)(()=>E[`notice.actions`].filter(e=>!e.hidden),[E]),R=(0,m.useCallback)((t,n,i)=>{if(t.id===`host:msg-fork`){i?.id&&r({type:`fork_session`,messageId:i.id,position:`before`});return}if(t.id===`host:msg-rollback`){i?.id&&ef({messageId:i.id});return}let o=(t.action??``).trim();if(t.kind===`view`||(!o||o===`view`)&&t.source!==`host`){C(t.view??`plugin:${t.source.startsWith(`plugin:`)?t.source.slice(7):``}`);return}o&&lo(t.source.startsWith(`plugin:`)?t.source.slice(7):``,o,t.id,{...n===void 0?{}:{value:n},...i===void 0?{}:{target:i},loadBundle:async e=>{let t=G.current.plugins.find(t=>t.id===e);return t?ps(t,G.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[te,z]=(0,m.useState)([]);(0,m.useEffect)(()=>os(z),[]);let[B,V]=(0,m.useState)([]);(0,m.useEffect)(()=>is(V),[]);let[ne,H]=(0,m.useState)(null),U=ne?E[`modal.dialog`].find(e=>e.id===ne&&!e.hidden):void 0,W=(0,m.useMemo)(()=>{if(!U||U.kind!==`view`)return``;let e=U.view??``;return e.startsWith(`plugin:`)?e.slice(7):U.source.startsWith(`plugin:`)?U.source.slice(7):``},[U]);(0,m.useEffect)(()=>{if(!U||!W||te.some(e=>e.info.id===W))return;let e=G.current.plugins.find(e=>e.id===W);e&&ps(e,G.current.pluginsEpoch)},[U,W,te,n.pluginsEpoch]),(0,m.useEffect)(()=>{Ml(r),Nl(T,n.pluginsEpoch),Bl(T,n.pluginsEpoch),eg(T,n.pluginsEpoch),ms(T,n.pluginsEpoch)},[T,n.pluginsEpoch,r]);let G=(0,m.useRef)(n);G.current=n;let re=(0,m.useRef)(C);re.current=C;let ie=(0,m.useRef)(E);ie.current=E,(0,m.useEffect)(()=>(no(to({send:r,isReady:()=>!!G.current.state,setView:e=>re.current(e),getCwd:()=>G.current.state?.cwd??``,getWorkspaceRoots:()=>G.current.state?.workspaceRoots??[],listSessions:()=>{let e=G.current,t=e.state?.cwd??``;return[...e.conversations.map(e=>({id:e.id,title:e.title,cwd:e.cwd||t,kind:`running`,isStreaming:e.isStreaming})),...e.sessions.map(e=>({id:e.path,title:e.name||e.firstMessage||e.path,cwd:t,kind:`history`}))]},getConversationId:()=>G.current.state?.conversationId??null,isConversationBlank:()=>(G.current.state?.messages.length??0)===0,listModels:()=>G.current.models.map(e=>({id:e.id,provider:e.provider,name:e.name,vision:e.vision,reasoning:e.reasoning})),getCurrentModelId:()=>{let e=G.current.state?.model;return e?`${e.provider}/${e.id}`:null},listProjects:()=>G.current.projects.map(e=>e.path),grantedPaths:Bv,grantPath:Vv,confirm:e=>new Promise(t=>De({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:(H(t),!0)},closeModal:()=>H(null),dialogConfirm:e=>new Promise(t=>{if(Ae.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Ae.current=n,ke(n)}),select:e=>new Promise(t=>{if(Ae.current){t({ok:!1,error:`busy`});return}let n={kind:`select`,title:e.title,options:e.options,...e.multi?{multi:!0}:{},resolve:t};Ae.current=n,Me([]),ke(n)}),input:e=>new Promise(t=>{if(Ae.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};Ae.current=n,Pe(e.initial??``),ke(n)}),notifyAction:e=>new Promise(t=>{try{let n=Le.current;Le.current=null,Ie(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Le.current=r,Ie(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=G.current.plugins.find(t=>t.id===e);return t?ps(t,G.current.pluginsEpoch):Promise.resolve(!1)}})),()=>no(null)),[r]);let[ae,se]=(0,m.useState)(()=>Mv(`left`)),[ce,le]=(0,m.useState)(()=>Mv(`right`)),ue=(0,m.useCallback)(e=>se(e),[]),de=(0,m.useCallback)(e=>le(e),[]),[fe,pe]=(0,m.useState)(()=>Pv(`left`)),[me,he]=(0,m.useState)(()=>Pv(`right`)),K=(0,m.useCallback)(()=>{pe(e=>{try{localStorage.setItem(Nv(`left`),e?`0`:`1`)}catch{}return!e})},[]),ge=(0,m.useCallback)(()=>{he(e=>{try{localStorage.setItem(Nv(`right`),e?`0`:`1`)}catch{}return!e})},[]),[_e,ve]=(0,m.useState)(null),[q,ye]=(0,m.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,m.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>ye(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[J,be]=(0,m.useState)(!1),[xe,Se]=(0,m.useState)(!1),[Ce,we]=(0,m.useState)(!1),[Te,Ee]=(0,m.useState)(),[Y,De]=(0,m.useState)(null),[Oe,ke]=(0,m.useState)(null),Ae=(0,m.useRef)(null),[je,Me]=(0,m.useState)([]),[Ne,Pe]=(0,m.useState)(``),[Fe,Ie]=(0,m.useState)(null),Le=(0,m.useRef)(null),[Re,ze]=(0,m.useState)(()=>new Set),Be=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),ze(t=>new Set(t).add(e))},Ve=n.pathRequests.find(e=>!Re.has(e.id))??null,[He,Ue]=(0,m.useState)(()=>new Set),We=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),Ue(t=>new Set(t).add(e))},Ge=n.permRequests.find(e=>!He.has(e.id))??null,Ke=Ug(),[qe,Je]=(0,m.useState)(!1),[Ye,Xe]=(0,m.useState)(!1),[Ze,Qe]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!Ze)return;let e=setTimeout(()=>Qe(null),15e3);return()=>clearTimeout(e)},[Ze]),(0,m.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=dt();o.create({id:e,conversationId:n.activeConversationId||n.state?.conversationId||``,title:a,cwd:n.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:c})}C(`terminal`)};window.addEventListener(`pi-web-ui:plugin-run-command`,t);let i=e=>{let t=e.detail;typeof t==`string`&&t&&r({type:`switch_conversation`,id:t})};return window.addEventListener(`pi-web-ui:switch-conversation`,i),()=>{window.removeEventListener(`pi-web-ui:plugin-run-command`,t),window.removeEventListener(`pi-web-ui:switch-conversation`,i)}},[n,o,r]),(0,m.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),Xe(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[$e,et]=(0,m.useState)(Tg),[tt,nt]=(0,m.useState)(Tt),{themes:rt,theme:it,switchTheme:at,reloadThemes:ot}=Zl();y_(),(0,m.useEffect)(()=>{try{typeof Lo==`function`&&Lo(it??``)}catch{}},[it]),(0,m.useEffect)(()=>{try{typeof Ro==`function`&&Ro(t)}catch{}},[t]),(0,m.useEffect)(()=>{try{typeof zo==`function`&&zo(w)}catch{}},[w]),(0,m.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof No==`function`&&No(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,m.useEffect)(()=>{if(!Oe)return;let e=e=>{if(e.key!==`Escape`)return;let t=Ae.current;Ae.current=null,ke(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)},[Oe]),(0,m.useEffect)(()=>{if(!Fe)return;let e=setTimeout(()=>{let e=Le.current;Le.current=null,Ie(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[Fe]);let st=(0,m.useRef)(null),ct=(0,m.useRef)(null),lt=(0,m.useRef)(n.state?.messages);lt.current=n.state?.messages;let ut=(0,m.useRef)(new Set),ft=(0,m.useRef)(new Set),pt=(0,m.useRef)(new Set),mt=(0,m.useRef)(0),ht=(0,m.useRef)(!1),gt=(0,m.useRef)(n.terminals);(0,m.useEffect)(()=>{Eg($e)},[$e]),(0,m.useEffect)(()=>{Et(tt)},[tt]),(0,m.useEffect)(()=>{let e=gt.current;gt.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,m.useEffect)(()=>{let t=n.state?.conversationId??null,r=wv(st.current,t,n.state?.isStreaming??!1,n.conversations,ct.current);if(st.current=r.nextMap,ct.current=t,r.startCue&&jg(`start`,$e),r.finishedConvs.length>0){jg(`done`,$e);let t=r.finishedConvs.find(e=>e.isActive);if(t&&(Pr(e(`notifyDoneTitle`),e(`notifyDoneBody`)),tt.enabled&&!xr(Or()))){if(tt.readReplies){let t=At(lt.current);t?zt(t,tt):tt.announce&&zt(e(`ttsAnnounceDone`),tt)}else tt.announce&&zt(e(`ttsAnnounceDone`),tt)}for(let t of r.finishedConvs.filter(e=>!e.isActive)){let n=t.title?`${t.title}:${e(`notifyDoneBody`)}`:e(`notifyDoneBody`);Pr(e(`notifyDoneTitle`),n)}!t&&tt.enabled&&tt.announce&&!xr(Or())&&zt(e(`ttsAnnounceDone`),tt)}},[n.state?.conversationId,n.state?.isStreaming,n.conversations,$e,tt,e]),(0,m.useEffect)(()=>{let t=n.dialog?.id??null;if(t!==null&&!ut.current.has(t)){if(ut.current.add(t),ut.current.size>64){let e=ut.current.values().next().value;e!==void 0&&ut.current.delete(e)}jg(`question`,$e),Pr(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),tt.enabled&&tt.announce&&!xr(Or())&&zt(e(`ttsAnnounceQuestion`),tt)}},[n.dialog,$e,tt,e]),(0,m.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null,i=!1;t!==null&&!ft.current.has(t)&&(ft.current.add(t),i=!0),r!==null&&!ft.current.has(r)&&(ft.current.add(r),i=!0);for(let e of n.conversations){if(!e.hasQuestion)continue;let n=e.questionId?`q:${e.questionId}`:`conv-q:${e.id}`;ft.current.has(n)||(ft.current.add(n),e.questionId&&ft.current.add(e.questionId),t!==e.questionId&&(i=!0))}if(ft.current.size>64){let e=ft.current.values().next().value;e!==void 0&&ft.current.delete(e)}i&&(jg(`question`,$e),Pr(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),tt.enabled&&tt.announce&&!xr(Or())&&zt(e(`ttsAnnounceQuestion`),tt))},[n.question,n.remoteQuestion,n.conversations,$e,tt,e]),(0,m.useEffect)(()=>{let t=n.approval,r=t?.id??null;if(r!==null&&!pt.current.has(r)){if(pt.current.add(r),pt.current.size>64){let e=pt.current.values().next().value;e!==void 0&&pt.current.delete(e)}jg(`approval`,$e);let n=typeof t?.toolName==`string`?t.toolName:``;Pr(e(`notifyApprovalTitle`),n?e(`notifyApprovalBodyTool`,{tool:n}):e(`notifyApprovalBody`)),tt.enabled&&tt.announce&&!xr(Or())&&zt(e(`ttsAnnounceApproval`),tt)}},[n.approval,$e,tt,e]),(0,m.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==mt.current&&(mt.current=t.id,jg(`error`,$e),Pr(e(`notifyErrorTitle`),e(`notifyErrorBody`)),tt.enabled&&tt.announce&&!xr(Or())&&zt(e(`ttsAnnounceError`),tt))},[n.notices,$e,tt,e]);let _t=(0,m.useRef)(new Set);(0,m.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||_t.current.has(t.id))continue;_t.current.add(t.id);let e=``;for(let n of t.content??[]){if(n.type!==`text`)continue;let t=/🔗 已自动在浏览器打开\]\((\/(?!\/)[^)\s]+)\)/.exec(n.text??``);if(t?.[1]){e=t[1];break}}if(!e)continue;let n=null;try{let t=new URL(Gt(e),window.location.href);t.origin===window.location.origin&&document.hasFocus()&&(n=window.open(t.href,`_blank`,`noopener`))}catch{n=null}n||a(`info`,e)}},[n.state?.messages,a]);let vt=(e,t,n,r=!1,i,a=!1)=>{let o=`${e}|${n}|${i?`${i.start}-${i.end}`:``}`;d(a=>a.some(e=>`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`===o)?a:[...a,{path:e,name:t,mode:n,isDir:r,...i?{lines:i}:{}}]),!a&&t&&In(`@${t} `)},yt=e=>{let t=``;d(n=>n.filter(n=>{let r=n.key?n.key===e:n.mode===`conversation`?`conv|${n.conversationId??``}|${n.sessionPath??``}`===e:n.path===e;return r&&!t&&(t=n.name),!r})),t&&Ln(`@${t}`)},bt=(0,m.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&ve(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&C(e=>e===`chat`?e:`chat`),r(e)),[r]),xt=(0,m.useRef)(new Set),St=n.activeConversationId||n.state?.conversationId||``;(0,m.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 xt.current)i.has(e)||xt.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===St){Vh(t);continue}n.questionId&&xt.current.has(n.questionId)||Bh({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&&xt.current.add(n.questionId)},onClick:()=>{bt({type:`switch_conversation`,id:n.id}),Vh(t),n.questionId&&xt.current.add(n.questionId)}})}Hh(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===St:!1})},[n.conversations,St,bt,e]);let Ct=(0,m.useRef)(0),wt=(0,m.useRef)(0),Dt=(0,m.useCallback)(t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-wt.current>1e4&&(wt.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++Ct.current}`;d(e=>[...e,{path:``,key:i,name:t.name,imageData:t.data,mimeType:t.mimeType}])},[n.state?.model,a,e]),Ot=(0,m.useCallback)(async t=>{for(let n of t){let t=await jd(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}Dt(t)}},[Dt,a,e]),kt=20971520,jt=(0,m.useRef)(0),Mt=(0,m.useCallback)(async t=>{if(t.size>kt){a(`warning`,e(`fileTooLarge`,{name:t.name,size:kt/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-${++jt.current}`;d(e=>[...e,{path:``,key:r,name:t.name,fileData:n,size:t.size,mimeType:t.type||void 0}])},[kt,a,e]),Nt=(0,m.useCallback)(async e=>{for(let t of e)Ad(t.type)?await Ot([t]):await Mt(t)},[Ot,Mt]),Pt=(0,m.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),Ft=(0,m.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[It,Lt]=(0,m.useState)([]),Rt=(0,m.useRef)(0),Bt=(0,m.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),Rt.current+=1;let i={text:t,seq:Rt.current};Lt(e=>[...e.slice(-9),i])},[r]),Vt=(0,m.useCallback)(()=>Se(!0),[]),Ht=(0,m.useCallback)(()=>d([]),[]);Yh(n.state?.sessionId??``,Ht);let Ut=(0,m.useCallback)(yt,[]),Wt=Ot,Kt=Nt,qt=(0,m.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),Jt=(0,m.useCallback)(e=>vt(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines,e.silent??!1),[]),Yt=n.state?.model,Xt=n.state?.thinkingLevel,Zt=n.state?.availableThinkingLevels,Qt=(0,m.useMemo)(()=>Yt?{model:Yt,thinkingLevel:Xt??`off`,availableThinkingLevels:Zt??[]}:null,[Yt,Xt,Zt]),$t=(0,m.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:dt(),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,m.useEffect)(()=>{if(ht.current){if(w!==`terminal`||n.terminals.length!==0){ht.current=!1;return}$t()&&(ht.current=!1)}},[n.terminals.length,$t,w]),(0,X.jsxs)(`div`,{className:`app`,"data-pi-anchor":`app`,onDragOver:e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),x(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||x(!1)},onDrop:t=>{if(x(!1),!Array.from(t.dataTransfer?.types??[]).includes(`Files`))return;t.preventDefault();let n=Array.from(t.dataTransfer?.files??[]);if(n.length===0){a(`warning`,e(`foldersNotSupported`));return}let r=n.filter(e=>Ad(e.type)),i=n.filter(e=>!Ad(e.type));r.length>0&&Ot(r),i.length>0&&Nt(i)},children:[b&&(0,X.jsx)(`div`,{className:`app-drop-overlay`,"aria-hidden":!0,children:(0,X.jsxs)(`span`,{children:[`📎 `,e(`dropHereToAttach`)]})}),(0,X.jsx)(Pa,{chat:n,terminal:o,view:w,plugins:T,uiPrimary:D,uiOverflow:O,uiContextTopbar:E[`contextmenu.topbar`],onUiAction:R,onViewChange:e=>{ht.current=e===`terminal`&&n.terminals.length===0,ht.current&&$t()&&(ht.current=!1),C(e),ve(null)},onOpenPanel:ve,onOpenSettings:()=>{Ee(void 0),we(!0)},onManagePlugins:()=>{Ee(`plugins`),we(!0)},onOpenBgTasks:()=>Je(!0),onOpenGlobalSearch:()=>Xe(!0),sound:$e,onSoundChange:et,onSoundPreview:e=>jg(e,$e),themes:rt,theme:it,onThemeChange:at,reloadThemes:ot}),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)(Ev,{notice:e,onDismiss:i},e.id)),Fe&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:Fe.text}),Fe.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Le.current;Le.current=null,Ie(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=Le.current;Le.current=null,Ie(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(N,{})})]}),L.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:L.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=>R(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:()=>R(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)(lp,{currentModelId:Yt?`${Yt.provider}/${Yt.id}`:null,children:(0,X.jsxs)(`div`,{className:`layout`,style:{"--left-w":`${ae}px`,"--right-w":`${ce}px`},children:[_e&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>ve(null)}),(0,X.jsxs)(`div`,{className:`view-pane ${w===`chat`?``:`hidden`}`,children:[!q&&fe&&(0,X.jsx)(Iv,{side:`left`,onClick:K}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${_e===`left`?`open`:``}${q?``:fe?` hidden`:``}`,children:(0,X.jsx)(oc,{collapsible:!q,onToggleCollapse:K,panelSend:bt,active:!q||_e===`left`,sessionFile:n.state?.sessionFile??null,conversations:n.conversations,elsewhere:n.elsewhere,sessions:n.sessions,projects:n.projects,pathCompletions:n.pathCompletions,activeConversationId:n.activeConversationId,uiContextSession:E[`contextmenu.session`],uiLeftSessions:k,onUiAction:R,presetNames:I})}),!q&&(0,X.jsx)(Fv,{side:`left`,width:ae,onResize:ue}),(0,X.jsxs)(`main`,{className:Ke?`main wide-chat`:`main`,children:[M.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:hp(M,R)}),n.state?(0,X.jsxs)(X.Fragment,{children:[n.state.isEphemeral&&(0,X.jsxs)(`div`,{className:`ephemeral-banner`,children:[(0,X.jsxs)(`span`,{children:[`🎭 `,e(`ephemeralBannerText`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`ephemeral-save`,onClick:()=>r({type:`persist_conversation`,id:St}),children:[`💾 `,e(`saveEphemeral`)]})]}),(0,X.jsx)($p,{uiMessageActions:E[`message.actions`],uiContextMessage:E[`contextmenu.message`],uiContextToolCall:E[`contextmenu.toolcall`],uiChatEmpty:P,onUiAction:R,state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:Pt,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&tp(`${e.provider}/${e.id}`)}},onRemoveQueued:Ft,onRecallQueued:Bt,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,jumpTarget:Ze,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)(th,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:j,onUiAction:R}),(0,X.jsx)(Nh,{onAction:(e,t,n)=>R(e,n,t)}),n.dialog&&(0,X.jsx)(ph,{dialog:n.dialog}),Oe&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":Oe.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),Oe.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:Oe.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Ae.current;Ae.current=null,ke(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),Oe.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(Oe.options??[]).map((e,t)=>{let n=Oe.multi?je.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(Oe.multi){Me(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Ae.current;Ae.current=null,ke(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)}),(Oe.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),Oe.multi&&(0,X.jsx)(`div`,{className:`dialog-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ae.current,t=(e?.options??[]).filter((e,t)=>je.includes(t)).map(e=>e.label);Ae.current=null,ke(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),Oe.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=Ae.current;Ae.current=null,ke(null);try{e?.resolve(!1)}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ae.current;Ae.current=null,ke(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),Oe.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Ne,placeholder:Oe.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>Pe(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Ae.current;Ae.current=null,ke(null);try{e?.resolve({ok:!0,value:Ne})}catch{}}}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Ae.current;Ae.current=null,ke(null);try{e?.resolve({ok:!1})}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ae.current;Ae.current=null,ke(null);try{e?.resolve({ok:!0,value:Ne})}catch{}},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(gh,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||St))?.title}),n.remoteQuestion&&(0,X.jsx)(gh,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(ev,{plan:n.state?.plan}),(0,X.jsx)(eh,{composerLeading:E[`composer.leading`],composerActions:E[`composer.actions`],onUiAction:R,streaming:n.state?.isStreaming??!1,messages:n.state?.messages??Dv,slashCommands:n.slashCommands,modelState:Qt,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:Ut,onAddImageFiles:Wt,onAddLocalFiles:Kt,onAddPathAttachment:Jt,fileSearch:n.fileSearch,onSearchFiles:qt,onNotice:a,onManageModels:Vt,onSent:Ht,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:It,dshPermCurrent:n.state?.permission??null,dshPermOptions:n.dshPermission?.options??void 0,dshPermDefault:n.dshPermission?.defaultPreset,dshPreset:n.state?.agentPreset??null,dshPresets:n.dshPresets?.presets??void 0,dshPresetDefault:n.dshPresets?.defaultPreset,dshBlank:(n.state?.messages?.length??0)===0,conversationId:n.activeConversationId||n.state?.conversationId||``,sessionDraft:n.engine===`pi`?n.state?.draft??null:null,sessionId:n.state?.sessionId??``})]}),!q&&(0,X.jsx)(Fv,{side:`right`,width:ce,onResize:de}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${_e===`right`?`open`:``}${q?``:me?` hidden`:``}`,children:(0,X.jsx)(Jc,{collapsible:!q,onToggleCollapse:ge,panelSend:bt,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{ve(null),vt(e,t,n,r)},onPreview:(e,t)=>{ve(null),y(e,t)},onNotice:(e,t)=>a(e,t),uiRightPanelTabs:E[`rightpanel.tabs`],uiContextFile:E[`contextmenu.file`],plugins:T,pluginsEpoch:n.pluginsEpoch,send:r})}),!q&&me&&(0,X.jsx)(Iv,{side:`right`,onClick:ge})]}),(0,X.jsx)(`div`,{className:`view-pane ${w===`terminal`?``:`hidden`}`,children:(0,X.jsx)(m.Suspense,{fallback:null,children:(0,X.jsx)(Tv,{chat:n,terminal:o,uiTerminalToolbar:A,onUiAction:R})})}),(0,X.jsx)(`div`,{className:`view-pane ${w===`git`?``:`hidden`}`,children:(0,X.jsx)(Ah,{chat:n,terminal:o,active:w===`git`,onSwitchToTerminal:()=>C(`terminal`),uiScmToolbar:ee,onUiAction:R})}),te.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${w===t?``:`hidden`}`,children:(0,X.jsx)(jh,{entry:e})},e.info.id)}),w.startsWith(`plugin:`)&&!te.some(e=>`plugin:${e.info.id}`===w)&&(0,X.jsx)(Mh,{pluginId:w.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===w),epoch:n.pluginsEpoch,failed:B.includes(w.slice(7))})]})}),(0,X.jsx)(uh,{chat:n,bottombarItems:E.bottombar,onUiAction:R}),f&&(0,X.jsx)(vv,{file:f,content:n.fileContent,onAddLines:(e,t,n,r)=>vt(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>vt(e,t,n),onClose:()=>p(null),uiFilePreviewToolbar:F,onUiAction:R}),h&&(0,X.jsx)(Cv,{file:h.file,plugin:h.plugin,declaration:h.declaration,epoch:n.pluginsEpoch,send:r,onClose:()=>g(null),onFallback:()=>{g(null),p(h.file)}}),n.ready&&n.state&&n.state.piConfigured===!1&&!J&&!xe&&(0,X.jsx)(ig,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>be(!0)}),xe&&(0,X.jsx)(mg,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,fetchModelsResult:n.fetchModelsResult,testModelConnectionResult:n.testModelConnectionResult,enrichModelsResult:n.enrichModelsResult,enrichModelsProgress:n.enrichModelsProgress,refreshBuiltinResult:n.refreshBuiltinResult,appendBuiltinResult:n.appendBuiltinResult,cloneProviderResult:n.cloneProviderResult,defaultModel:n.defaultModel,onClose:()=>Se(!1)}),Ce&&(0,X.jsx)(W_,{chat:n,terminal:o,initialSection:Te,onSwitchToTerminal:()=>C(`terminal`),onClose:()=>we(!1),sound:$e,onSoundChange:et,tts:tt,onTtsChange:nt}),qe&&(0,X.jsx)(Z_,{servers:n.bgServers,onClose:()=>Je(!1)}),(0,X.jsx)(uv,{}),(0,X.jsx)(Q_,{}),(0,X.jsx)($_,{approval:n.approval}),U&&(0,X.jsx)(gv,{entry:U,pluginView:W?te.find(e=>e.info.id===W):void 0,onUiAction:(e,t)=>{R(e,t),H(null)},onClose:()=>H(null)}),(0,X.jsx)(hv,{open:Ye,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>Xe(!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)=>{y(e,t)}}),(Ge||Ve||Y)&&(0,X.jsxs)(`div`,{className:`modal-backdrop perm-modal-backdrop`,children:[Ge&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginPermTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>We(Ge.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[Ge.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,Ge.pluginId).replace(`{hosts}`,(Ge.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,Ge.pluginId).replace(`{models}`,(Ge.models??[]).length>0?` ${(Ge.models??[]).join(`, `)}`:``),Ge.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Ge.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>We(Ge.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>We(Ge.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>We(Ge.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),Ve&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginGrantRequestTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>Be(Ve.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginGrantRequestBody`).replace(`{plugin}`,Ve.pluginId).replace(`{path}`,Ve.path),Ve.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Ve.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Be(Ve.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>Be(Ve.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),Y&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginSessionGrantTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{Y.resolve(!1),De(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,Y.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Y.resolve(!1),De(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{Y.resolve(!0),De(null)},children:e(`ok`)})]})]})]})]}),!Ce&&Object.values(n.pluginJobs??{}).some(e=>e.phase!==`done`)&&(0,X.jsxs)(`div`,{className:`active-plugin-jobs-bar`,onClick:()=>{Ee(`plugins`),we(!0)},title:e(`pluginJobRunning`),children:[(0,X.jsx)(oe,{className:`spin`}),(0,X.jsxs)(`span`,{className:`active-plugin-jobs-title`,children:[e(`pluginJobRunning`),`:`,` `,Object.values(n.pluginJobs??{}).filter(e=>e.phase!==`done`).map(e=>e.pluginId).join(`, `)]}),(()=>{let e=Object.values(n.pluginJobs??{}).find(e=>e.phase!==`done`),t=e?.lines[e.lines.length-1];return t?(0,X.jsx)(`span`,{className:`active-plugin-jobs-line`,children:t}):null})()]}),(0,X.jsx)(Jh,{})]})}function Uv(){typeof document<`u`&&(Wv(Gv()),qv())}function Wv(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function Gv(){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 Kv(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 qv(){let e=()=>{let e=document.querySelector(`.messages`);return e?(Wv(Kv(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)}qt(),Yl(ql()),Uv(),(0,A.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(m.StrictMode,{children:(0,X.jsx)(fn,{children:(0,X.jsx)(Hv,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=Ut();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,dt as c,ce as d,se as f,N as g,R as h,Ql as i,Fe as l,z as m,hp as n,pn as o,oe as p,Kl as r,Z as s,_p as t,ge as u};
|