@evandu/super-pi 0.1.290 → 0.1.292
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/dist/.super-pi-check-inputs.json +4 -0
- package/dist/client/.super-pi-client-sources.json +5 -4
- package/dist/client/assets/{CodeMirrorEditor-CC6Mf3yd.js → CodeMirrorEditor-BItIClMY.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-AhSKDGru.js → GitDiffEditor-CgWWgUsi.js} +1 -1
- package/dist/client/assets/index-C3aSjjM8.css +1 -0
- package/dist/client/assets/{index-D-sud3i3.js → index-Cwt3-oUx.js} +6 -6
- package/dist/client/index.html +2 -2
- package/dist/server/managed-http.js +1 -1
- package/dist/server/managed-recovery.d.ts +10 -0
- package/dist/server/managed-recovery.js +113 -0
- package/dist/server/managed-servers.d.ts +10 -2
- package/dist/server/managed-servers.js +134 -9
- package/dist/server/remote-bootstrap.d.ts +3 -0
- package/dist/server/remote-bootstrap.js +11 -1
- package/dist/shared/managed-servers.d.ts +16 -0
- package/package.json +3 -1
- package/dist/client/assets/index-dkbN-Swt.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-J6XWqRpB.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-D978o95T.js","assets/dist-B3-a6uF0.js","assets/dist-Cus6_oaF.js","assets/dist-Dc1MBGAG.js","assets/dist-BXAOrsjq.js","assets/dist-Cx00EZKR.js","assets/dist-moiMRpw_.js","assets/dist-Dds-qLxY.js","assets/dist-AW5lyI3I.js","assets/dist-BGxkyh6e.js","assets/dist-CKF2Jksy.js","assets/dist-BV64A9Ji.js","assets/dist-Dvb0SqcK.js","assets/dist-D71y2EI1.js","assets/dist-DeD9copn.js","assets/dist-QzbOCAU6.js","assets/dist-DuvGReu-.js","assets/dist-BRVQKlcp.js","assets/dist-BJxfd7yb.js","assets/CodeMirrorEditor-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-J6XWqRpB.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-D978o95T.js","assets/dist-B3-a6uF0.js","assets/dist-Cus6_oaF.js","assets/dist-Dc1MBGAG.js","assets/dist-BXAOrsjq.js","assets/dist-Cx00EZKR.js","assets/dist-moiMRpw_.js","assets/dist-Dds-qLxY.js","assets/dist-AW5lyI3I.js","assets/dist-BGxkyh6e.js","assets/dist-CKF2Jksy.js","assets/dist-BV64A9Ji.js","assets/dist-Dvb0SqcK.js","assets/dist-D71y2EI1.js","assets/dist-DeD9copn.js","assets/dist-QzbOCAU6.js","assets/dist-DuvGReu-.js","assets/dist-BRVQKlcp.js","assets/dist-BJxfd7yb.js","assets/CodeMirrorEditor-BItIClMY.js","assets/CodeMirrorEditor-O7UpftQ-.css","assets/GitDiffEditor-CgWWgUsi.js","assets/GitDiffEditor-DP0DQ9Y5.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e,t}from"./rolldown-runtime-XKyaHtl9.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 n=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function P(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=P(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=P(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return P(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function F(e,t,n){if(e==null)return e;var r=[],i=0;return P(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ee(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var te=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function ne(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,te)}catch(e){te(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function re(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else ne(re.bind(null,e))}var ie={map:F,forEach:function(e,t,n){F(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return F(e,function(){t++}),t},toArray:function(e){return F(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ie,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=re,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ee}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=ne,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),r=t(((e,t)=>{t.exports=n()})),i=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),a=t(((e,t)=>{t.exports=i()})),o=t((e=>{var t=r();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(){}var a={d:{f:i,r:function(){throw Error(n(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},o=Symbol.for(`react.portal`),s=Symbol.for(`react.recoverable`),c=Symbol.for(`react.optimistic_key`);function l(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:r===c?c:``+r,children:e,containerInfo:t,implementation:n}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,e.browser=function(e){return{$$typeof:s,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return l(e,t,null,r)},e.flushSync=function(e){var t=u.T,n=a.p;try{if(u.T=null,a.p=2,e)return e()}finally{u.T=t,a.p=n,a.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,a.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&a.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin),i=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?a.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n===`script`&&a.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=d(t.as,t.crossOrigin);a.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??a.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=d(n,t.crossOrigin);a.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=d(t.as,t.crossOrigin);a.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else a.d.m(e)}},e.requestFormReset=function(e){a.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return u.H.useFormState(e,t,n)},e.useFormStatus=function(){return u.H.useHostTransitionStatus()},e.version=`19.3.1`})),s=t(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=t((e=>{var t=a(),n=r(),i=s();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(o(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return f(i),e;if(a===r)return f(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=a;break}if(c===r){s=!0,r=i,n=a;break}c=c.sibling}if(!s){for(c=a.child;c;){if(c===n){s=!0,n=a,r=i;break}if(c===r){s=!0,r=a,n=i;break}c=c.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}function h(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&h(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function g(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function _(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function v(e){var t=[null,null],n=g(e);return n===null||y(t,e,n.child,{foundSelf:!1}),t}function y(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&y(e,t,n.child,r))return!0;n=n.sibling}return!1}function b(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(o(559))}}var x=null,S=null;function C(e,t,n){return e===n||e===t&&(x=e,!0)}function w(e,t,n){return e===n?(S=e,!1):e===t&&(S!==null&&(x=e),!0)}function T(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function E(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var D=Object.assign,O=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),P=Symbol.for(`react.consumer`),F=Symbol.for(`react.context`),ee=Symbol.for(`react.forward_ref`),te=Symbol.for(`react.suspense`),ne=Symbol.for(`react.suspense_list`),re=Symbol.for(`react.memo`),ie=Symbol.for(`react.lazy`),ae=Symbol.for(`react.activity`),oe=Symbol.for(`react.legacy_hidden`),se=Symbol.for(`react.memo_cache_sentinel`),ce=Symbol.for(`react.view_transition`),le=Symbol.for(`react.recoverable`),ue=Symbol.iterator;function de(e){return typeof e!=`object`||!e?null:(e=ue&&e[ue]||e[`@@iterator`],typeof e==`function`?e:null)}var fe=Symbol.for(`react.client.reference`);function pe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case te:return`Suspense`;case ne:return`SuspenseList`;case ae:return`Activity`;case ce:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case F:return e.displayName||`Context`;case P:return(e._context.displayName||`Context`)+`.Consumer`;case ee:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case re:return t=e.displayName||null,t===null?pe(e.type)||`Memo`:t;case ie:t=e._payload,e=e._init;try{return pe(e(t))}catch{}}return null}var me=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge={pending:!1,data:null,method:null,action:null},_e=[],ve=-1;function ye(e){return{current:e}}function be(e){0>ve||(e.current=_e[ve],_e[ve]=null,ve--)}function xe(e,t){ve++,_e[ve]=e.current,e.current=t}var Se=ye(null),Ce=ye(null),we=ye(null),Te=ye(null);function Ee(e,t){switch(xe(we,t),xe(Ce,e),xe(Se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?dp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=dp(t),e=fp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}be(Se),xe(Se,e)}function De(){be(Se),be(Ce),be(we)}function Oe(e){var t=e.memoizedState;t!==null&&(ch._currentValue=t.memoizedState,xe(Te,e)),t=Se.current;var n=fp(t,e.type);t!==n&&(xe(Ce,e),xe(Se,n))}function ke(e){Ce.current===e&&(be(Se),be(Ce)),Te.current===e&&(be(Te),ch._currentValue=ge)}var Ae,je;function Me(e){if(Ae===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ae=t&&t[1]||``,je=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Ae+e+je}var Ne=!1;function Pe(e,t){if(!e||Ne)return``;Ne=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -17,9 +17,9 @@ Error generating stack: `+e.message+`
|
|
|
17
17
|
`);r.push(a[3]?.toLowerCase()===`math`&&o&&s.trim()?{type:`math-block`,source:s}:{type:`code-block`,lang:a[3]??``,value:s});continue}let o=jt(n,i);if(o){r.push(o.node),i=o.next;continue}if(Tt.test(e)){r.push({type:`rule`}),i+=1;continue}let s=wt.exec(e);if(s){r.push({type:`heading`,level:s[1].length,children:St(s[2]??``,t)}),i+=1;continue}if(Ot.test(e)){let e=[];for(;i<n.length;){let t=Ot.exec(n[i]);if(t)e.push(t[1]),i+=1;else{if(e.length===0||!n[i].trim()||Ft(n,i))break;e.push(n[i].trim()),i+=1}}r.push({type:`blockquote`,children:Nt(e.join(`
|
|
18
18
|
`),t)});continue}let c=Pt(n,i);if(c){c.prefix&&r.push({type:`paragraph`,children:St(c.prefix,t)});let e=Lt(c.header),a=Lt(n[i+1]).map(Rt),o=[];for(i+=2;i<n.length&&n[i].trim()&&n[i].includes(`|`);)o.push(zt(Lt(n[i]),e.length).map(e=>St(e,t))),i+=1;r.push({type:`table`,head:e.map(e=>St(e,t)),align:a,rows:o});continue}if(Et.test(e)||Dt.test(e)){let e=It(n,i,t);r.push(e.node),i=e.next;continue}let l=[];for(;i<n.length&&n[i].trim()&&!Ft(n,i);)l.push(n[i]),i+=1;l.length||(l.push(n[i]),i+=1),r.push({type:`paragraph`,children:St(l.join(`
|
|
19
19
|
`),t)})}return r}function Pt(e,t){let n=e[t],r=e[t+1];if(!n?.includes(`|`)||!r||!kt.test(r)||!r.includes(`-`))return;if(Lt(n).length===Lt(r).length)return{header:n};let i=n.indexOf(`|`);if(i<=0)return{header:n};let a=n.slice(0,i).trim(),o=n.slice(i);if(a&&Lt(o).length===Lt(r).length)return{header:o,prefix:a}}function Ft(e,t){let n=e[t];return Ct.test(n)||wt.test(n)||Tt.test(n)||Ot.test(n)||!!Pt(e,t)||Et.test(n)||Dt.test(n)||At.test(n)}function It(e,t,n){let r=Dt.test(e[t]),i=r?Dt.exec(e[t]):Et.exec(e[t]),a=i[1].length,o=[],s=t;for(;s<e.length;){let t=Et.exec(e[s]),i=Dt.exec(e[s]),c=r?i:t;if(!c)break;let l=c[1].length;if(l<a)break;let u=[c[c.length-1]];for(s+=1;s<e.length;){let n=e[s];if(!n.trim()){let t=e[s+1]??``;if(!t.trim()||t.search(/\S/)<=l)break;u.push(``),s+=1;continue}let r=n.search(/\S/);if(r===0&&t||r===0&&i)break;if(r>l)u.push(n.slice(Math.min(r,l+2))),s+=1;else if(r===l){if(Ft(e,s))break;u.push(n),s+=1}else break}o.push(Nt(u.join(`
|
|
20
|
-
`),n))}return{node:{type:`list`,ordered:r,start:r?Number(i[2]):1,items:o},next:s}}function Lt(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1));let n=[],r=``;for(let e=0;e<t.length;e+=1){let i=xt(t,e);if(i)r+=t.slice(e,i.next),e=i.next-1;else if(t[e]==="`"){let n=dt(t,e,"`"),i=pt(t,e+n,n),a=i===-1?e+n:i+n;r+=t.slice(e,a),e=a-1}else t[e]===`\\`&&t[e+1]===`|`?(r+=`|`,e+=1):t[e]===`|`?(n.push(r.trim()),r=``):r+=t[e]}return n.push(r.trim()),n}function Rt(e){let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`center`:n?`right`:t?`left`:null}function zt(e,t){let n=e.slice(0,t);for(;n.length<t;)n.push(``);return n}var Bt=[{kind:`calculator`,name:`计算器`,glyph:`∑`,blurb:`算术表达式,四则运算与乘方。除零会明确报错。`},{kind:`timestamp`,name:`时间戳`,glyph:`◷`,blurb:`Unix 时间戳与日期互转,本地计算,不联网。`}],Vt=[{id:`preset_calculator`,kind:`calculator`,name:`计算器`,glyph:`∑`}],Ht=40,Ut=2048,Wt=`super-pi:tools:v1`;function Gt(e){return typeof e==`string`?e.replace(/\s+/g,` `).trim().slice(0,Ht):``}function Kt(e){let t=e.trim();if(!t)return{ok:!1,reason:`请填写网址。`};if(t.length>Ut)return{ok:!1,reason:`网址太长了,请控制在 ${Ut} 个字符以内。`};let n=ct(t);return n?{ok:!0,url:n}:{ok:!1,reason:`这个网址不是允许的协议。只支持 http / https / mailto 开头的网址。`}}function qt(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];let n=[],r=new Set;for(let e of t){if(n.length>=32)break;if(typeof e!=`object`||!e)continue;let t=e,i=t.kind;if(typeof i!=`string`||i!==`calculator`&&i!==`timestamp`&&i!==`link`)continue;let a=Gt(t.name);if(!a)continue;let o=typeof t.glyph==`string`&&t.glyph.trim()?t.glyph.trim().slice(0,4):``;if(!o)continue;let s=typeof t.id==`string`&&t.id.trim()?t.id.trim().slice(0,64):``;if(s&&!r.has(s)){if(i===`link`){let e=ct(typeof t.url==`string`?t.url:``);if(!e)continue;r.add(s),n.push({id:s,kind:`link`,name:a,glyph:o,url:e})}else r.add(s),n.push({id:s,kind:i,name:a,glyph:o})}}return n}function Jt(e){return JSON.stringify(e.map(e=>e.kind===`link`?{...e}:{id:e.id,kind:e.kind,name:e.name,glyph:e.glyph}))}function Yt(){let e=typeof globalThis<`u`?globalThis.crypto:void 0;return typeof e?.randomUUID==`function`?e.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function Xt(e,t){let n=e===`link`?`link`:`preset_${e}`,r=Yt().replace(/-/g,``).slice(0,8),i=`${n}_${r}`,a=1;for(;t.includes(i);)i=`${n}_${r}_${a}`,a+=1;return i}function Zt(e,t){if(e.some(e=>e.kind===t))return e.slice();let n=Bt.find(e=>e.kind===t);return n?[...e,{id:Xt(t,e.map(e=>e.id)),kind:t,name:n.name,glyph:n.glyph}]:e.slice()}function Qt(e,t){return e.filter(e=>e.id!==t)}var $t=e=>({ok:!1,reason:e}),en=`除数不能为 0:除以零没有结果,请换一个非零的除数。`,tn=new Set([`/`,`%`]),nn=e=>e!==void 0&&e>=`0`&&e<=`9`,rn=e=>e!==void 0&&/\s/.test(e);function an(e){for(;rn(e.source[e.at]);)e.at+=1}function on(e){let t=e.at,n=0;for(;nn(e.source[e.at]);)e.at+=1,n+=1;if(e.source[e.at]===`.`)for(e.at+=1;nn(e.source[e.at]);)e.at+=1,n+=1;if(!n)return e.at=t,$t(`「${e.source[t]}」不是有效的数字。`);let r=Number(e.source.slice(t,e.at));return Number.isFinite(r)?{ok:!0,value:r}:$t(`数字太长了,无法表示。`)}function sn(e){an(e);let t=e.source[e.at];if(t===void 0)return $t(`算式不完整:末尾还缺一个数字或右括号。`);if(t===`(`){e.at+=1;let t=dn(e);return t.ok?(an(e),e.source[e.at]===`)`?(e.at+=1,t):$t(`括号不匹配:少了一个右括号「)」。`)):t}return nn(t)||t===`.`?on(e):$t(`无法识别的字符「${t}」。`)}function cn(e){let t=sn(e);if(!t.ok||(an(e),e.source[e.at]!==`^`))return t;e.at+=1;let n=ln(e);if(!n.ok)return n;let r=t.value**n.value;return Number.isFinite(r)?{ok:!0,value:r}:$t(`结果超出了可计算的数值范围。`)}function ln(e){an(e);let t=e.source[e.at];if(t!==`+`&&t!==`-`)return cn(e);e.at+=1;let n=ln(e);if(!n.ok)return n;let r=t===`-`?-n.value:n.value;return Number.isFinite(r)?{ok:!0,value:r}:$t(`结果超出了可计算的数值范围。`)}function un(e){let t=ln(e);if(!t.ok)return t;for(;;){an(e);let n=e.source[e.at];if(n!==`*`&&!tn.has(n))return t;e.at+=1;let r=ln(e);if(!r.ok)return r;if(tn.has(n)&&r.value===0)return $t(en);let i=n===`*`?t.value*r.value:n===`%`?t.value%r.value:t.value/r.value;if(!Number.isFinite(i))return $t(`结果超出了可计算的数值范围。`);t={ok:!0,value:i}}}function dn(e){let t=un(e);if(!t.ok)return t;for(;;){an(e);let n=e.source[e.at];if(n!==`+`&&n!==`-`)return t;e.at+=1;let r=un(e);if(!r.ok)return r;let i=n===`+`?t.value+r.value:t.value-r.value;if(!Number.isFinite(i))return $t(`结果超出了可计算的数值范围。`);t={ok:!0,value:i}}}function fn(e){let t=e.trim();if(!t)return $t(`请输入算式。`);if(t.length>200)return $t(`算式太长了,请控制在 200 个字符以内。`);let n={source:t,at:0},r=dn(n);return r.ok?(an(n),n.at===t.length?Number.isFinite(r.value)?r:$t(`结果不是有限数字。`):$t(`「${t[n.at]}」后面的内容无法识别,请检查是否漏了运算符。`)):r}function pn(e){return String(!Number.isFinite(e)||Number.isInteger(e)&&Math.abs(e)<1e21?e:Number(e.toPrecision(12)))}function mn(e){let t=e.trim();if(!t)return{ok:!1,reason:`请输入时间戳或日期。`};if(/^-?\d+$/.test(t)){let e=Number(t);if(!Number.isFinite(e))return{ok:!1,reason:`这个数字太大,无法表示。`};let n=t.replace(`-`,``).length<=11?e*1e3:e;return!Number.isFinite(n)||Math.abs(n)>864e13?{ok:!1,reason:`这个时间戳超出了日期能表示的范围。`}:{ok:!0,ms:n}}let n=Date.parse(t);return Number.isNaN(n)?{ok:!1,reason:`看不懂这个日期。试试 1757000000、2026-10-08 或 2026-10-08T09:00:00。`}:{ok:!0,ms:n}}var hn=e=>String(Math.abs(e)).padStart(2,`0`);function gn(e){let t=new Date(e);return Number.isNaN(t.getTime())?null:{local:`${t.getFullYear()}-${hn(t.getMonth()+1)}-${hn(t.getDate())} ${hn(t.getHours())}:${hn(t.getMinutes())}:${hn(t.getSeconds())}`,iso:t.toISOString(),seconds:String(Math.floor(e/1e3)),milliseconds:String(e)}}function _n({workspaceId:e,onEnter:t,onBranches:n,onClose:r,summaries:i,anchor:a}){let[o,s]=(0,u.useState)([]),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(!1),[p,g]=(0,u.useState)({}),_=(0,u.useRef)(new Set),v=async t=>{if(!_.current.has(t)){_.current.add(t);try{let n=await je(`/api/git?`+new URLSearchParams({workspaceId:e,op:`worktree-inspect`,worktreeId:t}),{signal:AbortSignal.timeout(1e4)}),r=await n.json();if(!n.ok)throw Error();let i=r.status,a=new Set([...i.staged,...i.unstaged,...i.untracked].map(e=>e.path)).size;g(e=>({...e,[t]:a?`${a} 个改动`:`工作树干净`}))}catch{g(e=>({...e,[t]:`改动状态暂不可用`}))}}};(0,u.useEffect)(()=>{let t=new AbortController;return je(`/api/git?`+new URLSearchParams({workspaceId:e,op:`worktrees`}),{signal:t.signal}).then(async e=>{let n=await e.json();if(!e.ok)throw Error(n.error??`无法读取工作树`);t.signal.aborted||s(n.worktrees)}).catch(e=>{t.signal.aborted||l(e.message)}),()=>t.abort()},[e]);let y=async n=>{if(!d){f(!0),l(``);try{let r=await je(`/api/git?`+new URLSearchParams({workspaceId:e,op:`worktree-manage`}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`enter`,worktreeId:n,requestId:Yt()})}),i=await r.json();if(!r.ok)throw Error(i.error??`无法进入工作树`);t(m(h(e).server,i.workspaceId))}catch(e){l(e instanceof Error?e.message:`无法进入工作树`)}finally{f(!1)}}};return(0,L.jsxs)(Ye,{anchor:a,title:`进入仓库工作树`,onClose:r,onHighlight:e=>void v(e),choices:o.map(e=>({id:e.id,label:(e.branch??e.head.slice(0,8))+(e.current?` · 当前`:``),detail:[e.path,p[e.id],...i.filter(t=>t.path.replaceAll(`\\`,`/`)===e.path.replaceAll(`\\`,`/`)&&t.running>0).map(e=>`${e.running} 个会话正在运行`)].filter(Boolean).join(` · `),group:e.primary?`主检出`:`关联工作树`,disabled:e.missing||d})),onChoose:e=>void y(e),children:[c&&(0,L.jsx)(`p`,{role:`alert`,children:c}),!o.length&&!c&&(0,L.jsx)(`p`,{role:`status`,children:`正在读取工作树…`}),(0,L.jsx)(`button`,{type:`button`,"data-status-branches":!0,disabled:d,onClick:n,children:`查看分支与切换分支`})]})}var vn=`modulepreload`,yn=function(e){return`/`+e},bn={},xn=function(e){return e.pathname.endsWith(`.css`)},Sn=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Cn=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,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?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=yn(t,n);let r=s(t),i=xn(r);return Sn(bn,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:vn,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).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)})};async function wn(e,t){let[{StreamLanguage:n},r]=await Promise.all([Cn(()=>import(`./dist-J6XWqRpB.js`).then(e=>e.d),__vite__mapDeps([0,1,2,3,4])),e()]),i=r[t]??r.default??r;return n.define(i)}var Tn={cpp:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),cc:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),cxx:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),hpp:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),hh:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),hxx:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),c:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),h:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),cu:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),cuh:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),js:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,2,3,4,0,6,8])),jsx:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([7,1,2,3,4,0,6,8])),mjs:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,2,3,4,0,6,8])),cjs:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,2,3,4,0,6,8])),ts:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,2,3,4,0,6,8])),tsx:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([7,1,2,3,4,0,6,8])),mts:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,2,3,4,0,6,8])),cts:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,2,3,4,0,6,8])),py:()=>Cn(()=>import(`./dist-Dds-qLxY.js`).then(e=>e.python()),__vite__mapDeps([9,4,1,0,2,3,6,8])),pyi:()=>Cn(()=>import(`./dist-Dds-qLxY.js`).then(e=>e.python()),__vite__mapDeps([9,4,1,0,2,3,6,8])),java:()=>Cn(()=>import(`./dist-AW5lyI3I.js`).then(e=>e.java()),__vite__mapDeps([10,4,1,0,2,3,6])),php:()=>Cn(()=>import(`./dist-BGxkyh6e.js`).then(e=>e.php()),__vite__mapDeps([11,4,1,0,2,3,6,12,13,7,8])),sql:()=>Cn(()=>import(`./dist-Dvb0SqcK.js`).then(e=>e.sql()),__vite__mapDeps([14,4,1,0,2,3,6,8])),yaml:()=>Cn(()=>import(`./dist-D71y2EI1.js`).then(e=>e.yaml()),__vite__mapDeps([15,4,1,0,2,3,6])),yml:()=>Cn(()=>import(`./dist-D71y2EI1.js`).then(e=>e.yaml()),__vite__mapDeps([15,4,1,0,2,3,6])),xml:()=>Cn(()=>import(`./dist-DeD9copn.js`).then(e=>e.xml()),__vite__mapDeps([16,2,1,3,4,0,6])),json:()=>Cn(()=>import(`./dist-QzbOCAU6.js`).then(e=>e.json()),__vite__mapDeps([17,4,1,0,2,3,6])),jsonc:()=>Cn(()=>import(`./dist-QzbOCAU6.js`).then(e=>e.json()),__vite__mapDeps([17,4,1,0,2,3,6])),json5:()=>Cn(()=>import(`./dist-QzbOCAU6.js`).then(e=>e.json()),__vite__mapDeps([17,4,1,0,2,3,6])),html:()=>Cn(()=>import(`./dist-CKF2Jksy.js`).then(e=>e.html()),__vite__mapDeps([12,2,1,3,4,0,6,13,7,8])),htm:()=>Cn(()=>import(`./dist-CKF2Jksy.js`).then(e=>e.html()),__vite__mapDeps([12,2,1,3,4,0,6,13,7,8])),vue:()=>Cn(()=>import(`./dist-CKF2Jksy.js`).then(e=>e.html()),__vite__mapDeps([12,2,1,3,4,0,6,13,7,8])),svelte:()=>Cn(()=>import(`./dist-CKF2Jksy.js`).then(e=>e.html()),__vite__mapDeps([12,2,1,3,4,0,6,13,7,8])),css:()=>Cn(()=>import(`./dist-BV64A9Ji.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([13,1,4,0,2,3,6])),md:()=>Cn(()=>import(`./dist-DuvGReu-.js`).then(e=>e.markdown()),__vite__mapDeps([18,2,1,3,4,0,8,12,6,13,7])),markdown:()=>Cn(()=>import(`./dist-DuvGReu-.js`).then(e=>e.markdown()),__vite__mapDeps([18,2,1,3,4,0,8,12,6,13,7])),mdx:()=>Cn(()=>import(`./dist-DuvGReu-.js`).then(e=>e.markdown()),__vite__mapDeps([18,2,1,3,4,0,8,12,6,13,7])),rs:()=>Cn(()=>import(`./dist-BRVQKlcp.js`).then(e=>e.rust()),__vite__mapDeps([19,4,1,0,2,3,6])),go:()=>Cn(()=>import(`./dist-BJxfd7yb.js`).then(e=>e.go()),__vite__mapDeps([20,4,1,0,2,3,6,8])),sh:()=>wn(()=>Cn(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>wn(()=>Cn(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>wn(()=>Cn(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>wn(()=>Cn(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>wn(()=>Cn(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>wn(()=>Cn(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>wn(()=>Cn(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>wn(()=>Cn(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>wn(()=>Cn(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>wn(()=>Cn(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>wn(()=>Cn(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>wn(()=>Cn(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>wn(()=>Cn(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>wn(()=>Cn(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>wn(()=>Cn(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>wn(()=>Cn(()=>import(`./diff-ChtP43wD.js`),[]),`diff`)},En={cpp:`C++`,cc:`C++`,cxx:`C++`,hpp:`C++`,hh:`C++`,hxx:`C++`,cu:`CUDA C++`,cuh:`CUDA C++`,c:`C`,h:`C/C++ Header`,js:`JavaScript`,jsx:`JSX`,mjs:`JavaScript`,cjs:`JavaScript`,ts:`TypeScript`,tsx:`TSX`,mts:`TypeScript`,cts:`TypeScript`,py:`Python`,pyi:`Python Stub`,java:`Java`,php:`PHP`,sql:`SQL`,yaml:`YAML`,yml:`YAML`,xml:`XML`,json:`JSON`,jsonc:`JSON with Comments`,json5:`JSON5`,css:`CSS`,md:`Markdown`,markdown:`Markdown`,mdx:`MDX`,rs:`Rust`,go:`Go`,html:`HTML`,htm:`HTML`,vue:`Vue`,svelte:`Svelte`,sh:`Shell`,bash:`Bash`,zsh:`Zsh`,fish:`Fish`,ps1:`PowerShell`,psm1:`PowerShell`,rb:`Ruby`,swift:`Swift`,toml:`TOML`,ini:`INI`,cfg:`Config`,conf:`Config`,properties:`Properties`,dockerfile:`Dockerfile`,diff:`Diff`,patch:`Patch`};function Dn(e){return Tn[e.toLowerCase()]}function On(e){return En[e.toLowerCase()]}function kn(e,t){return new URL(`http://${e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}:${t}`).origin}var An=()=>({name:``,host:``,sshPort:`22`,username:``,servicePort:`3080`,serviceHost:`0.0.0.0`,authentication:`password`}),jn={offline:`未连接`,connecting:`连接中`,online:`已连接`,needsTrust:`等待确认指纹`,awaitingVerification:`等待交互验证`};function Mn(){let[e,t]=(0,u.useState)([]),[n,r]=(0,u.useState)(),[i,a]=(0,u.useState)(An),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``),[d,p]=(0,u.useState)({}),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(new Set),v=(0,u.useRef)(new Set),y=async()=>{let e=await je(`/api/managed-servers`,{signal:AbortSignal.timeout(8e3)},f),n=await e.json();return r(e.ok&&n.available===!0),Array.isArray(n.profiles)&&t(n.profiles),n};(0,u.useEffect)(()=>{let e=!1,t=()=>{e||y().catch(()=>{e||r(!1)})};t();let n=setInterval(t,2e3);return()=>{e=!0,clearInterval(n)}},[]);let b=async e=>{let n=await je(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),signal:AbortSignal.timeout(3e4)},f),r=await n.json();if(Array.isArray(r.profiles)&&t(r.profiles),Ee(),!n.ok)throw Error(r.error??`操作失败`);return r};(0,u.useEffect)(()=>{for(let t of e)g.has(t.id)&&!v.current.has(t.id)&&t.ssh===`online`&&[`idle`,`ready`].includes(t.phase)&&t.fingerprint&&(v.current.add(t.id),_(e=>new Set([...e].filter(e=>e!==t.id))),b({action:`deploy`,id:t.id}).catch(e=>l(e instanceof Error?e.message:`部署未开始`)).finally(()=>v.current.delete(t.id)))},[e,g]);let x=async(e,t,n={})=>{s(!0),l(``);try{await b({id:e,action:t,...n})}catch(e){l(e instanceof Error?e.message:`操作失败`)}finally{s(!1)}},S=e=>{a({id:e.id,name:e.name,host:e.host,username:e.username,sshPort:String(e.sshPort),servicePort:String(e.servicePort),serviceHost:e.serviceHost??`127.0.0.1`,authentication:e.authentication,identityFile:e.identityFile,serviceUrl:e.serviceUrl===kn(e.host,e.servicePort)?``:e.serviceUrl}),h(!0),l(``)},C=async(e,t=e.id??`draft`)=>{s(!0),l(``);try{let n=await b({action:`probeService`,profile:{...e,servicePort:Number(e.servicePort),...e.sshPort===void 0?{}:{sshPort:Number(e.sshPort)}}});n.probe&&p(e=>({...e,[t]:n.probe}))}catch(e){l(e instanceof Error?e.message:`无法检测服务端口`)}finally{s(!1)}};return(0,u.useEffect)(()=>{p(e=>{let t={...e};return delete t.draft,t})},[i.host,i.servicePort,i.serviceUrl,i.serviceAccessToken]),n===!1?(0,L.jsxs)(`div`,{className:`server-managed-unavailable`,children:[(0,L.jsx)(`h4`,{children:`请使用本地完整安装开启 SSH 托管`}),(0,L.jsxs)(`p`,{children:[`运行 `,(0,L.jsx)(`code`,{children:`super_pi desktop`}),` 打开桌面端,或在自己的电脑启动完整包,再通过本机网页访问。纯服务包只负责远端执行,不保存其他服务器的 SSH 资料。`]})]}):(0,L.jsxs)(`div`,{className:`managed-servers-panel`,"data-managed-servers":`1`,children:[(0,L.jsx)(`p`,{className:`server-description`,children:`预览功能:SSH 自动部署仍在完善跨平台兼容性。部署失败时可查看下方日志并重试;已有服务也可以使用“已有服务直接连接”。`}),(0,L.jsxs)(`div`,{className:`managed-overview`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{children:`本地配置,统一接入`}),(0,L.jsx)(`p`,{children:`默认通过 Super Pi 的 IP 和端口直连。SSH 用于安装与维护,访问隧道可按服务器手动开启。`}),(0,L.jsx)(`small`,{children:`SSH 资料保存在当前入口服务所在的电脑。新托管服务调用模型时本地入口需在线;已有服务继续使用它原来的模型配置。`})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{fe(f),window.dispatchEvent(new Event(`super-pi-open-local-model-settings`))},children:`配置本地模型`})]}),(0,L.jsxs)(`div`,{className:`managed-toolbar`,children:[(0,L.jsxs)(`span`,{children:[e.length,` 台服务器`]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void x(``,`syncAll`),children:`同步全部模型目录`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{a(An()),h(!0)},children:`+ 添加 SSH 服务器`})]})]}),n===void 0&&(0,L.jsx)(`p`,{role:`status`,children:`正在读取本地托管配置…`}),e.length===0&&!m&&(0,L.jsxs)(`div`,{className:`managed-empty`,children:[(0,L.jsx)(`strong`,{children:`尚未添加服务器`}),(0,L.jsx)(`p`,{children:`只需要提供 SSH 访问方式和希望使用的服务端口。通过 SSH 隧道访问时,无需向外网开放这个端口。`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(!0),children:`添加并部署第一台服务器`})]}),(0,L.jsx)(`div`,{className:`managed-server-list`,children:e.map(e=>(0,L.jsxs)(`section`,{className:`managed-server-card`,"data-managed-server":e.id,children:[(0,L.jsxs)(`header`,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{children:e.name}),(0,L.jsxs)(`small`,{children:[e.username,`@`,e.host,`:`,e.sshPort,` · Super Pi `,e.servicePort]})]}),(0,L.jsx)(`span`,{className:`managed-phase`,"data-phase":e.phase,children:e.enabled?e.phase===`deploying`?`部署中`:e.phase===`ready`?`可使用`:e.phase===`awaitingVerification`?`等待验证`:e.phase===`connecting`?`连接中`:e.phase===`needsTrust`?`待确认`:e.phase===`failed`?`需要处理`:e.ssh===`online`?`SSH 已连接`:e.enabled?`待连接`:`已停用`:`已停用`})]}),(0,L.jsxs)(`dl`,{className:`managed-connectivity`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`服务访问`}),(0,L.jsx)(`dd`,{children:e.enabled?e.service===`online`?e.transport===`direct`?`直连在线`:`SSH 隧道在线`:e.service===`offline`?`当前不可达`:`正在确认`:`已停用`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`SSH 管理`}),(0,L.jsxs)(`dd`,{children:[jn[e.ssh],e.sshError&&(0,L.jsx)(`small`,{className:`server-connection-error`,children:e.sshError})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:e.existingService?.attached?`模型配置`:`本地模型通道`}),(0,L.jsxs)(`dd`,{children:[e.existingService?.attached?`沿用远端配置`:e.modelTransport===`direct`?e.modelChannel===`online`?`已连接 · 服务端口`:`服务端口通道未就绪`:e.modelChannel===`online`?`已连接 · SSH`:e.modelChannelPaused?`已暂停`:e.ssh===`awaitingVerification`?`等待 SSH 验证`:e.ssh===`connecting`?`正在恢复`:`未连接`,e.modelError&&(0,L.jsxs)(`small`,{className:`server-connection-error`,children:[`模型同步未完成 · `,e.modelError]}),e.modelChannelPaused&&e.enabled&&(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void x(e.id,`connectSsh`),children:`恢复本地模型通道`})]})]})]}),e.serviceUrl&&(0,L.jsxs)(`section`,{className:`managed-existing-service`,children:[e.enabled&&e.service===`offline`&&e.serviceError&&(0,L.jsx)(`p`,{className:`server-connection-error`,role:`status`,children:e.serviceError}),d[e.id]&&(0,L.jsxs)(`p`,{role:`status`,"data-service-probe-result":d[e.id].authorized?`online`:d[e.id].reachable?`reachable`:`offline`,children:[`上次手动测试 · `,d[e.id].message,` · `,d[e.id].latencyMs,` ms`]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void C({id:e.id}),children:`测试服务端口`}),e.ssh===`online`?(0,L.jsx)(`button`,{type:`button`,"data-managed-ssh":`disconnect`,disabled:o,onClick:()=>void x(e.id,`disconnectSsh`),children:`断开 SSH 管理`}):(0,L.jsx)(`button`,{type:`button`,"data-managed-ssh":`connect`,disabled:o||e.ssh===`connecting`||e.ssh===`awaitingVerification`,onClick:()=>void x(e.id,`connectSsh`),children:`连接 SSH 管理`}),e.enabled&&(e.allowServiceTunnel||e.service===`offline`)&&(0,L.jsx)(`button`,{type:`button`,"data-service-tunnel-toggle":!0,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,e.allowServiceTunnel?`disableServiceTunnel`:`enableServiceTunnel`),children:e.allowServiceTunnel?`关闭 SSH 隧道访问`:`启用 SSH 隧道访问`})]})]}),e.existingService&&(0,L.jsxs)(`section`,{className:`managed-existing-service`,children:[(0,L.jsxs)(`h4`,{children:[e.existingService.attached?`已接入已有服务`:e.existingService.running?`发现正在运行的 Super Pi`:`发现已有 Super Pi 安装`,e.existingService.version?` · v${e.existingService.version}`:``]}),(0,L.jsx)(`p`,{children:e.existingService.attached?`保留原端口、工作区、会话和模型配置。未重装或重启原服务。`:e.existingService.running?`原服务仍在运行,补充访问授权后即可接入。`:`原有数据保持原样,不会自动创建空实例。`}),e.existingService.dataDirectory&&(0,L.jsxs)(`small`,{children:[`原数据目录:`,(0,L.jsx)(`code`,{children:e.existingService.dataDirectory})]}),!e.existingService.running&&e.existingService.canStart&&(0,L.jsx)(`button`,{type:`button`,disabled:o||e.ssh!==`online`,onClick:()=>void x(e.id,`startExisting`),children:`启动并接入原服务`})]}),(0,L.jsx)(Nn,{profile:e,busy:o,onApply:t=>void x(e.id,`applyListener`,{serviceHost:t})}),e.phase===`deploying`&&(0,L.jsxs)(`div`,{className:`managed-progress`,role:`status`,children:[(0,L.jsx)(`progress`,{"aria-label":`远端部署进度`}),(0,L.jsx)(`span`,{children:e.step})]}),e.error&&(0,L.jsxs)(`p`,{className:`server-connection-error`,role:`status`,children:[`上次操作未完成 · `,e.error]}),e.verification&&(0,L.jsx)(Be,{verification:e.verification,onAnswer:t=>b({action:`answerVerification`,id:e.id,verificationId:e.verification.id,answers:t}).then(()=>{}),onCancel:()=>(_(t=>new Set([...t].filter(t=>t!==e.id))),b({action:`cancelVerification`,id:e.id,verificationId:e.verification.id}).then(()=>{}))},e.verification.id),e.observedFingerprint&&(0,L.jsxs)(`div`,{className:`managed-host-trust`,children:[(0,L.jsx)(`strong`,{children:e.fingerprint?`主机指纹已变化`:`首次连接:确认 SSH 主机指纹`}),(0,L.jsx)(`code`,{children:e.observedFingerprint}),(0,L.jsx)(`small`,{children:`请与服务器管理员或已有 SSH 记录核对;确认后才会安装或执行远端命令。`}),(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:async()=>{s(!0),l(``);try{await b({action:`trust`,id:e.id,fingerprint:e.observedFingerprint})}catch(e){l(e instanceof Error?e.message:`连接失败`)}finally{s(!1)}},children:g.has(e.id)?`确认指纹并继续部署`:`信任此主机并连接`})]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:o||!!e.existingService||e.phase===`deploying`||!e.fingerprint,title:e.existingService?`已识别原安装,保留原服务及数据`:void 0,onClick:()=>void x(e.id,`deploy`),children:e.existingService?.attached?`已保留原服务`:e.deployedAt?`重新部署/升级`:`一键安装并接入`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,e.enabled?`disconnect`:`connect`),children:e.enabled?`停用连接`:`启用连接`}),!e.serviceUrl&&(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,`connectSsh`),children:`检测/连接 SSH`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.service!==`online`||e.existingService?.attached,title:e.existingService?.attached?`原服务沿用远端模型配置`:void 0,onClick:()=>void x(e.id,`sync`),children:`同步模型`}),(0,L.jsx)(`button`,{type:`button`,disabled:e.phase===`deploying`,onClick:()=>S(e),children:`编辑`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,`remove`),children:`移除连接`})]}),(e.log?.length||e.remoteRoot)&&(0,L.jsxs)(`details`,{className:`managed-diagnostics`,children:[(0,L.jsx)(`summary`,{children:`部署记录与日志位置`}),e.remoteRoot&&(0,L.jsxs)(`p`,{children:[`远端目录:`,(0,L.jsx)(`code`,{children:e.remoteRoot}),(0,L.jsx)(`br`,{}),`服务日志:`,(0,L.jsxs)(`code`,{children:[e.remoteRoot,`/service.log`]})]}),e.log?.length?(0,L.jsx)(`pre`,{children:e.log.join(`
|
|
21
|
-
`)}):null]})]},e.id))}),m&&(0,L.jsxs)(`form`,{className:`managed-server-form`,onSubmit:async e=>{e.preventDefault(),s(!0),l(``);try{let t=(await b({action:`save`,profile:{...i,sshPort:Number(i.sshPort),servicePort:Number(i.servicePort)}})).profiles.find(e=>e.name===i.name.trim()),n=e.nativeEvent.submitter,r=n instanceof HTMLButtonElement&&n.value===`deploy`;r&&_(e=>new Set(e).add(t.id)),h(!1),a(An()),await b({action:r?`connectSsh`:`test`,id:t.id})}catch(e){l(e instanceof Error?e.message:`无法保存连接`)}finally{s(!1)}},children:[(0,L.jsx)(`h4`,{children:i.id?`编辑 SSH 连接`:`添加 SSH 服务器`}),(0,L.jsxs)(`div`,{className:`managed-form-grid`,children:[(0,L.jsxs)(`label`,{children:[`显示名称`,(0,L.jsx)(`input`,{required:!0,value:i.name,onChange:e=>a({...i,name:e.target.value}),placeholder:`例如:开发服务器`})]}),(0,L.jsxs)(`label`,{children:[`SSH 地址`,(0,L.jsx)(`input`,{required:!0,value:i.host,onChange:e=>a({...i,host:e.target.value}),placeholder:`IP 或主机名`})]}),(0,L.jsxs)(`label`,{children:[`SSH 端口`,(0,L.jsx)(`input`,{type:`number`,min:1,max:65535,required:!0,value:i.sshPort,onChange:e=>a({...i,sshPort:e.target.value})})]}),(0,L.jsxs)(`label`,{children:[`SSH 用户名`,(0,L.jsx)(`input`,{required:!0,value:i.username,onChange:e=>a({...i,username:e.target.value}),autoComplete:`off`})]}),(0,L.jsxs)(`label`,{children:[`Super Pi 端口`,(0,L.jsx)(`input`,{type:`number`,min:1,max:65535,required:!0,value:i.servicePort,onChange:e=>a({...i,servicePort:e.target.value})}),(0,L.jsx)(`small`,{children:`直连需使用已放行的端口;平台不修改防火墙。`})]}),(0,L.jsxs)(`label`,{children:[`服务监听方式`,(0,L.jsxs)(`select`,{"data-service-listener-mode":!0,value:i.serviceHost??`0.0.0.0`,onChange:e=>a({...i,serviceHost:e.target.value}),children:[(0,L.jsx)(`option`,{value:`0.0.0.0`,children:`可直连 · IPv4 所有网卡`}),(0,L.jsx)(`option`,{value:`::`,children:`可直连 · IPv4 / IPv6`}),(0,L.jsx)(`option`,{value:`127.0.0.1`,children:`仅本机回环`})]}),(0,L.jsx)(`small`,{children:`可直连模式强制访问鉴权。更改后需部署以应用,不会仅凭填写地址改变已运行的服务。`})]}),(0,L.jsxs)(`label`,{children:[`Super Pi 直连地址(可选)`,(0,L.jsx)(`input`,{type:`url`,value:i.serviceUrl??``,onChange:e=>a({...i,serviceUrl:e.target.value}),placeholder:`https://server.example:8088`}),(0,L.jsx)(`small`,{children:`留空自动使用上面的服务器地址和 Super Pi 端口;HTTPS 或不同地址可在这里指定。不自动开放远端端口。`})]}),(0,L.jsxs)(`label`,{children:[`认证方式`,(0,L.jsxs)(`select`,{"data-ssh-authentication":!0,value:i.authentication,onChange:e=>a({...i,authentication:e.target.value}),children:[(0,L.jsx)(`option`,{value:`password`,children:`SSH 密码`}),(0,L.jsx)(`option`,{value:`privateKey`,children:`SSH 私钥`}),(0,L.jsx)(`option`,{value:`agent`,children:`本地 SSH Agent`})]})]})]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,"data-service-port-probe":!0,disabled:o||!i.host.trim()||!i.servicePort,onClick:()=>void C(i,`draft`),children:o?`正在检测…`:`测试服务端口`}),(0,L.jsx)(`small`,{children:`只检测 Super Pi 的 IP 和端口,不进行 SSH 登录,也不安装或重启服务。`})]}),d.draft&&(0,L.jsxs)(`p`,{role:`status`,"data-service-probe-result":d.draft.authorized?`online`:d.draft.reachable?`reachable`:`offline`,children:[d.draft.message,(0,L.jsx)(`br`,{}),(0,L.jsxs)(`small`,{children:[d.draft.address,` · `,d.draft.latencyMs,` ms`]})]}),i.authentication===`password`&&(0,L.jsxs)(`label`,{children:[`SSH 密码`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.password??``,placeholder:i.id?`留空保留已有密码`:``,required:!i.id,onChange:e=>a({...i,password:e.target.value})})]}),i.authentication===`privateKey`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`label`,{children:[`本地私钥文件路径`,(0,L.jsx)(`input`,{value:i.identityFile??``,placeholder:`管理电脑上的私钥绝对路径`,onChange:e=>a({...i,identityFile:e.target.value})})]}),(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{children:`或者粘贴私钥`}),(0,L.jsx)(`textarea`,{rows:4,value:i.privateKey??``,onChange:e=>a({...i,privateKey:e.target.value}),spellCheck:!1})]}),(0,L.jsxs)(`label`,{children:[`私钥口令(如有)`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.passphrase??``,onChange:e=>a({...i,passphrase:e.target.value})})]})]}),i.authentication===`agent`&&(0,L.jsx)(`small`,{children:`使用管理电脑当前用户的 SSH Agent;需提前将对应密钥加入 Agent。`}),(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{children:`已有 Super Pi 服务的访问授权(可选)`}),(0,L.jsxs)(`label`,{children:[`原服务访问密钥`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.serviceAccessToken??``,placeholder:`仅在原服务设置过访问密钥时填写;编辑时留空保留`,onChange:e=>a({...i,serviceAccessToken:e.target.value})})]}),(0,L.jsx)(`small`,{children:`用于访问原服务,单独加密保存,不修改原服务的授权设置。`})]}),(0,L.jsx)(`small`,{children:`认证资料在本地管理服务加密保存,不返回浏览器。端口测试不连接 SSH、不安装或重启;安装与维护使用 SSH,部署使用用户目录,无需 sudo。`}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`submit`,value:`connect`,disabled:o,children:o?`正在保存和检测…`:`保存并检测`}),(0,L.jsx)(`button`,{type:`submit`,value:`deploy`,disabled:o,children:`保存并部署`}),(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{a(An()),h(!1)},children:`取消`})]})]}),c&&(0,L.jsx)(`p`,{role:`alert`,className:`server-connection-error`,children:c})]})}function Nn({profile:e,busy:t,onApply:n}){if(!e.remoteRoot)return null;let r=e.deployedServiceHost??`127.0.0.1`,i=e.serviceHost??`127.0.0.1`,a=i!==r,o=a?i:`0.0.0.0`;return(0,L.jsxs)(`section`,{className:`managed-existing-service`,"data-service-listener":r,children:[(0,L.jsx)(`h4`,{children:`已部署的服务监听`}),(0,L.jsxs)(`p`,{children:[(0,L.jsxs)(`code`,{children:[r,`:`,e.servicePort]}),r===`127.0.0.1`?` · 仅本机及 SSH 隧道可达`:` · 可通过已放行的服务端口直连`]}),(a||r===`127.0.0.1`)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,"data-service-listener-apply":!0,disabled:t||e.phase===`deploying`||!e.fingerprint,onClick:()=>n(o),children:a?`应用监听配置并重新部署`:`启用直连并重新部署`}),(0,L.jsx)(`small`,{children:`保留原数据和会话;会重启远端服务,部署前需结束运行中的任务。`})]})]})}function Pn({workspaces:e}){let{connections:t}=ce();return(0,L.jsx)(L.Fragment,{children:t.map(t=>{let n=e.filter(e=>h(e.id).server===t.id);return n.length?(0,L.jsx)(`optgroup`,{label:t.name,children:n.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.name},e.id))},t.id):null})})}function Fn(){let{connections:e,settingsServer:t,statuses:n}=ce();return(0,L.jsxs)(`div`,{className:`server-settings-scope`,children:[(0,L.jsxs)(`label`,{children:[`设置目标服务器 `,(0,L.jsx)(`select`,{"aria-label":`设置目标服务器`,value:t,onChange:e=>fe(e.target.value),children:e.filter(e=>e.enabled).map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,L.jsxs)(`small`,{children:[`工作区和会话设置属于所选服务器。外观和通知属于当前客户端。`,n.get(t)?.state===`offline`?` 当前服务器离线。`:``]})]})}function In(){let{connections:e,statuses:t,settingsServer:n}=ce(),r=e.find(e=>e.id===n)?.managed,[i,a]=(0,u.useState)(),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(``),[y,b]=(0,u.useState)(!1);(0,u.useEffect)(()=>{v(``),g(``),Me(`/api/browser-access`).then(e=>e.json()).then(e=>b(e.enabled)).catch(()=>g(`无法读取服务器授权设置`))},[n]);let x=async e=>{m(!0),g(``);try{let t=await Me(`/api/browser-access`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:e})}),n=await t.json();if(!t.ok)throw Error(n.error);b(n.enabled),v(n.key??``)}catch(e){g(e instanceof Error?e.message:`授权设置失败`)}finally{m(!1)}};return(0,L.jsxs)(`div`,{className:`server-connections-panel`,children:[(0,L.jsx)(`p`,{className:`server-description`,children:`当前浏览器直接连接每台服务器。关闭一个连接不会停止那台服务器上的任务。连接配置仅保存在当前浏览器。`}),(0,L.jsx)(`div`,{className:`server-connection-list`,children:e.filter(e=>!e.managed).map(e=>(0,L.jsxs)(`section`,{className:`server-connection-card`,children:[(0,L.jsxs)(`div`,{className:`server-connection-heading`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`span`,{"data-server-status":t.get(e.id)?.state??`disabled`,children:e.enabled?{online:`已连接`,connecting:`连接中`,offline:`离线`,disabled:`已停用`}[t.get(e.id)?.state??`connecting`]:`已停用`})]}),(0,L.jsxs)(`small`,{children:[e.url,e.id===`entry`?` · 网页入口`:``]}),t.get(e.id)?.error&&e.enabled&&(0,L.jsx)(`p`,{role:`status`,children:t.get(e.id)?.error}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>fe(e.id),disabled:!e.enabled||n===e.id,children:n===e.id?`当前设置目标`:`管理此服务器`}),(0,L.jsxs)(`label`,{children:[`名称 `,(0,L.jsx)(`input`,{"aria-label":`${e.name}的服务器名称`,defaultValue:e.name,onBlur:t=>{try{ve(e.id,t.target.value),g(``)}catch(n){g(n instanceof Error?n.message:`名称修改失败`),t.target.value=e.name}}})]}),e.id!==`entry`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>be(e.id,!e.enabled),children:e.enabled?`断开`:`连接`}),(0,L.jsx)(`button`,{type:`button`,disabled:!e.enabled,onClick:()=>{a(e.id),s(e.name),l(e.url),f(``)},children:`编辑连接`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>ye(e.id),children:`移除连接`})]})]})]},e.id))}),(0,L.jsxs)(`form`,{className:`server-connect-form`,onSubmit:async e=>{e.preventDefault(),m(!0),g(``);try{i?await Ce(i,o,c,d):await xe(o,c,d),a(void 0),s(``),l(``),f(``)}catch(e){g(e instanceof Error?e.message:`连接失败`)}finally{m(!1)}},children:[(0,L.jsx)(`h4`,{children:i?`编辑服务器连接`:`添加服务器`}),(0,L.jsxs)(`label`,{children:[`显示名称`,(0,L.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`例如:开发服务器`,required:!0})]}),(0,L.jsxs)(`label`,{children:[`服务地址`,(0,L.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`http://主机:端口`,required:!0})]}),(0,L.jsxs)(`label`,{children:[`连接密钥`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`off`,value:d,onChange:e=>f(e.target.value),required:!i,placeholder:i?`留空保留已保存的密钥`:void 0})]}),(0,L.jsx)(`small`,{children:`先在目标服务器的“服务器连接”设置中生成连接密钥,再粘贴到这里。密钥具有该服务器的操作权限。`}),(0,L.jsx)(`button`,{type:`submit`,disabled:p,children:p?`正在连接…`:i?`验证并保存`:`验证并添加`}),i&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{a(void 0),s(``),l(``),f(``)},children:`取消编辑`})]}),r?(0,L.jsx)(`p`,{children:`SSH 托管连接由本地入口管理,无需手动生成或更换连接密钥。`}):(0,L.jsxs)(`section`,{className:`server-access-settings`,children:[(0,L.jsxs)(`h4`,{children:[`允许其他浏览器连接 · `,I(n)]}),(0,L.jsx)(`p`,{children:y?`已开启。重新生成会使原连接密钥失效。`:`尚未开启远程浏览器授权。`}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void x(`rotate`),children:y?`重新生成连接密钥`:`生成连接密钥`}),y&&(0,L.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void x(`revoke`),children:`撤销授权`})]}),_&&(0,L.jsxs)(`label`,{children:[`连接密钥(仅本次显示,请妥善保存)`,(0,L.jsx)(`textarea`,{readOnly:!0,rows:3,value:_,onFocus:e=>e.target.select()})]})]}),h&&(0,L.jsx)(`p`,{className:`server-connection-error`,role:`alert`,children:h})]})}function Ln(){let[e,t]=(0,u.useState)(`managed`);return(0,L.jsxs)(`div`,{className:`server-connections-panel`,children:[(0,L.jsxs)(`div`,{className:`server-connection-modes`,role:`tablist`,"aria-label":`服务器接入方式`,children:[(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===`managed`,"data-server-mode":`managed`,onClick:()=>t(`managed`),children:`SSH 托管`}),(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===`direct`,"data-server-mode":`direct`,onClick:()=>t(`direct`),children:`已有服务直接连接`})]}),e===`managed`?(0,L.jsx)(Mn,{}):(0,L.jsx)(In,{})]})}function Rn(e,t,n){let r=new Set,i=new Set,a=!1,o=o=>{let s=o.data;if(o.source!==e()?.contentWindow||o.origin!==`null`||s?.type!==`super-pi-tool-request`||s.owner!==n||typeof s.id!=`string`||i.has(s.id)||i.size>=64)return;let c=t=>{a||e()?.contentWindow?.postMessage({type:`super-pi-tool-response`,id:s.id,...t},`*`)};if(typeof s.path!=`string`||s.path.length>2048||!/^api\/(run|runs(?:\/[a-z0-9_-]+)?|llm(?:\/[a-z0-9_-]+)?)(?:\?[^#\r\n]*)?$/i.test(s.path)||![`GET`,`POST`,`DELETE`].includes(s.method)||s.body!==void 0&&(typeof s.body!=`string`||s.body.length>1048576)){c({error:`工具请求超出当前挂载范围`});return}i.add(s.id);let l=new AbortController;r.add(l),(async()=>{try{let e=await je(Ae(`/tools/${encodeURIComponent(t)}/${s.path}`),{method:s.method,headers:{"content-type":`application/json`,"x-super-pi-tool-owner":n},body:s.body,signal:AbortSignal.any([l.signal,AbortSignal.timeout(25e3)])},le(t));c({status:e.status,headers:{"content-type":e.headers.get(`content-type`)??`application/json`},body:await e.text()})}catch{c({error:`工具所属服务器暂不可达,请检查该服务器连接后重试`})}finally{r.delete(l),i.delete(s.id)}})()};return window.addEventListener(`message`,o),()=>{a=!0,window.removeEventListener(`message`,o);for(let e of r)e.abort()}}function zn(e){return window.superPiDesktop?window.localStorage.getItem(e)??window.sessionStorage.getItem(e):window.sessionStorage.getItem(e)}function Bn(e,t){(window.superPiDesktop?window.localStorage:window.sessionStorage).setItem(e,t)}function Vn(){try{let e=JSON.parse(zn(`super-pi.sidebar-scope.v1`)??`null`);if(e&&[`all`,`workspace`,`repo`,`recent`,`running`].includes(e.kind))return{kind:e.kind,...typeof e.workspaceId==`string`?{workspaceId:e.workspaceId}:{},...typeof e.repoId==`string`?{repoId:e.repoId}:{},...typeof e.serverId==`string`?{serverId:e.serverId}:{}}}catch{}return{kind:`workspace`}}function Hn(){let e={groups:[],gitDiffs:[],diffs:{paths:[]}};try{let t=JSON.parse(zn(`super-pi.workbench-scene.v1`)??`null`);return!t||typeof t!=`object`?e:{groups:Array.isArray(t.groups)?t.groups.filter(e=>e&&typeof e.workspaceId==`string`&&typeof e.roomId==`string`).slice(0,200):[],gitDiffs:Array.isArray(t.gitDiffs)?t.gitDiffs.filter(e=>e?.target&&typeof e.target.url==`string`&&e.target.url.startsWith(`/api/git?`)&&[e.target.path,e.target.label,e.target.comparison].every(e=>typeof e==`string`)).slice(0,200).map(e=>({target:e.target,workspaceId:e.workspaceId,revision:0,preview:e.preview===!0,reading:{}})):[],diffs:{paths:Array.isArray(t.diffs?.paths)?t.diffs.paths.filter(e=>typeof e==`string`).slice(0,200):[],...typeof t.diffs?.previewPath==`string`?{previewPath:t.diffs.previewPath}:{}},...[`session`,`file`,`diff`,`gitDiff`,`group`].includes(t.view)?{view:t.view}:{},...typeof t.gitDiffUrl==`string`?{gitDiffUrl:t.gitDiffUrl}:{}}}catch{return e}}function Un(e){Bn(`super-pi.workbench-scene.v1`,JSON.stringify({...e,gitDiffs:e.gitDiffs.map(e=>({target:e.target,workspaceId:e.workspaceId,preview:e.preview}))}))}var Wn=`汇报线只允许逐级上升,子会话默认不能直接对话;确有特殊情况可解锁。`;function Gn(e,t){return e?!(!t||t.id!==e||t.archivedAt):!1}function Kn(e){let{conversation:t,parent:n,directChildren:r,isTopLevelUnread:i=!1}=e;return t.hasOpenEscalation?`awaiting_decision`:r.some(e=>{if(e.archivedAt)return!1;let t=e.status===`running`||e.status===`waiting`||e.status===`awaiting_background`,n=!!e.hasOpenEscalation;return t||n})?`awaiting_subordinates`:Gn(t.parentConversationId,n)?t.hasPendingResult?`pending_report`:null:i?`unread`:null}function qn(e){let{conversation:t,directChildren:n}=e,r=t.hasOpenEscalation&&!t.parentConversationId&&t.escalationAudience===`boss`;return Kn({...e,conversation:{...t,hasOpenEscalation:r},directChildren:n.map(e=>e.hasOpenEscalation?{...e,hasOpenEscalation:!1}:e)})}function Jn(e){let{status:t,reportingState:n,awaitingQuestion:r,quietWhenRead:i=!1}=e;return r?`question`:t===`failed`?`failed`:n===`awaiting_decision`?`awaiting_decision`:t===`waiting`?`waiting`:t===`running`?`running`:t===`awaiting_background`?`awaiting_background`:n===`pending_report`?`pending_report`:n===`awaiting_subordinates`?`awaiting_subordinates`:n===`unread`?t===`completed`?`completed`:`unread`:i?`idle`:t===`completed`?`completed`:`idle`}var Yn=[`solution-designer`,`code-designer`,`code-auditor`,`document-organizer`];function Xn(e){return e.role===`assistant`?e.settledAt??e.createdAt:e.createdAt}function Zn(e){return e.filter(e=>e.role===`user`||![`queued`,`running`].includes(e.status)).slice().sort((e,t)=>Xn(e).localeCompare(Xn(t)))}function Qn(e,t){return Jn({status:e.status,quietWhenRead:!0,reportingState:e.lastReplyAt&&e.lastReplyAt>(t??``)?`unread`:null})}var $n=`super-pi-active-group-workspace`,er=e=>`super-pi-group-room:${e}`;function tr(){try{let e=localStorage.getItem($n),t=e&&localStorage.getItem(er(e));if(e&&t)return{workspaceId:e,roomId:t}}catch{}}function nr(e){try{e?.roomId?(localStorage.setItem(er(e.workspaceId),e.roomId),localStorage.setItem($n,e.workspaceId)):localStorage.removeItem($n)}catch{}}var rr=({workspaceId:e,roomId:t})=>`group:${JSON.stringify([e,t])}`;function ir(e){if(e.startsWith(`group:`))try{let t=JSON.parse(e.slice(6));if(Array.isArray(t)&&typeof t[0]==`string`&&typeof t[1]==`string`)return{workspaceId:t[0],roomId:t[1]}}catch{}}function ar(e,t,n,r){let i=new URLSearchParams({workspaceId:e});return t&&i.set(`id`,t),n&&i.set(`revision`,n),r&&i.set(`execution`,r),`/api/group-chats?${i}`}var or=class extends Error{status;constructor(e,t){super(e),this.status=t}};async function sr(e,t){let n=await je(e,t);if(n.status===204)return;let r=await n.json().catch(()=>void 0);if(!n.ok)throw new or(r?.error||`群聊请求失败(${n.status})。`,n.status);return r}function cr(e,t){return sr(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})}function lr(e,t){return e.archivedAt?`idle`:t&&t.revision>=e.activity.revision?t.status:e.activity.status}function ur(e,t,n){return e.archivedAt?`idle`:Qn(t&&t.revision>=e.activity.revision?t:e.activity,n)}function dr(e,t){let n=JSON.stringify(e.filter(e=>!e.closedAt&&!e.id.startsWith(`pending:`)).map(e=>e.id)),[r,i]=(0,u.useState)({}),[a,o]=(0,u.useState)({}),[s,c]=(0,u.useState)(0),l=(0,u.useRef)(new Map),d=(0,u.useRef)(new Set),f=(0,u.useRef)(0),p=(0,u.useCallback)(()=>{f.current+=1,c(e=>e+1)},[]);(0,u.useEffect)(()=>{if(!t)return;let e=JSON.parse(n),r=new AbortController,a=f.current,o=()=>!r.signal.aborted&&a===f.current;for(let t of e)sr(ar(t),{signal:r.signal}).then(e=>{if(!o()||!e)return;for(let t of e)l.current.delete(t.id);let n=[...l.current.values()].filter(e=>e.workspaceId===t);i(r=>({...r,[t]:{rooms:[...n.reverse(),...e],loaded:!0}}))}).catch(()=>{o()&&i(e=>({...e,[t]:{...e[t],rooms:e[t]?.rooms??[],failed:!0}}))});return window.addEventListener(`focus`,p),()=>{window.removeEventListener(`focus`,p),r.abort()}},[n,t,s,p]);let m=(0,u.useCallback)(({id:e,workspaceId:t,activity:n,cloneRequests:r})=>{d.current.has(e)||(r&&i(i=>{let a=i[t];return a?{...i,[t]:{...a,rooms:a.rooms.map(t=>t.id===e&&t.activity.revision<=n.revision?{...t,activity:n,cloneRequests:r}:t)}}:i}),o(t=>t[e]&&t[e].revision>=n.revision?t:{...t,[e]:n}))},[]);return{index:r,reload:p,remember:(0,u.useCallback)((e,t=!1)=>{if(d.current.has(e.id))return;let{id:n,workspaceId:r,title:a,updatedAt:o,archivedAt:s,activity:c}=e,u={id:n,workspaceId:r,title:a,updatedAt:o,archivedAt:s,activity:c};m(u),t&&l.current.set(u.id,u),i(t=>{let n=t[e.workspaceId],r=n?.rooms??[],i=r.find(t=>t.id===e.id);return i&&(i.updatedAt>u.updatedAt||i.title===u.title&&i.archivedAt===u.archivedAt)?t:{...t,[e.workspaceId]:{...n,rooms:i?r.map(t=>t.id===e.id?u:t):[u,...r]}}})},[m]),forget:(0,u.useCallback)(({workspaceId:e,roomId:t})=>{d.current.add(t),l.current.delete(t),o(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),i(n=>{let r=n[e];return r?{...n,[e]:{...r,rooms:r.rooms.filter(e=>e.id!==t)}}:n})},[]),activities:a,recordActivity:m}}function fr(e){return JSON.stringify([e.workspaceId,e.conversationId?`session`:`group`,e.conversationId??e.roomId])}function pr(e,t,n){let{connections:r}=ce(),i=(0,u.useRef)({conversations:t,onMerge:n});i.current={conversations:t,onMerge:n};let a=JSON.stringify(r.filter(e=>e.enabled).map(e=>e.id));(0,u.useEffect)(()=>{let t=!1,n=new Set,r=new Set,o=new Set,s=async a=>{if(r.has(a))return;r.add(a);let s=new AbortController;n.add(s);let c=window.setTimeout(()=>s.abort(),12e3),l=!1;try{let n=await je(`/api/read-receipts`,{signal:s.signal},a);if(!n.ok||!n.headers.get(`content-type`)?.includes(`application/json`))return;let r=(await n.json()).receipts;if(t||!Array.isArray(r))return;let c=new Map(r.map(e=>[fr(e),e.at])),u=t=>{for(let n of t){let t=n.conversationId??rr({workspaceId:n.workspaceId,roomId:n.roomId});n.at>(e.current[t]??``)&&(e.current[t]=n.at,l=!0)}};u(r),l&&!t&&(i.current.onMerge(),l=!1);let d=[];for(let[t,n]of Object.entries(e.current)){let e;if(t.startsWith(`group:`))try{let[r,i]=JSON.parse(t.slice(6));e={workspaceId:r,roomId:i,at:n}}catch{continue}else{let r=i.current.conversations.find(e=>e.id===t);r&&(e={workspaceId:r.workspaceId,conversationId:t,at:n})}e&&!o.has(fr(e))&&h(e.workspaceId).server===a&&n>(c.get(fr(e))??``)&&d.push(e)}for(let e=0;e<d.length&&!t;e+=500){let t=d.slice(e,e+500),n=e=>je(`/api/read-receipts`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({receipts:e}),signal:s.signal},a),r=await n(t);if(r.ok)u((await r.json()).receipts??[]);else if(r.status===400)for(let e of t){let t=await n([e]);t.ok?u((await t.json()).receipts??[]):t.status===400&&o.add(fr(e))}}}catch{}finally{l&&!t&&i.current.onMerge(),window.clearTimeout(c),n.delete(s),r.delete(a)}},c=()=>{for(let e of JSON.parse(a))s(e)};c();let l=window.setInterval(c,3e3);return window.addEventListener(`focus`,c),()=>{t=!0,window.clearInterval(l),window.removeEventListener(`focus`,c);for(let e of n)e.abort()}},[a,e])}function mr(e,t){let n=e.trim();if(!n||n===t)return{path:t,prefix:``};let r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`));return r<0?n===`~`?{path:`~`,prefix:``}:{path:t,prefix:n}:{path:n.slice(0,r+1),prefix:n.slice(r+1)}}var hr=`操作没有完成。`,gr=`操作没有完成,没有拿到失败原因。可以重试,或查看服务端日志。`,_r=160,vr=/[\u3400-\u9fff]/,yr=/^(?:bad request|\{\s*"detail"\s*:\s*"bad request"\s*\})$/i,br=/failed to fetch|fetch failed|network\s*error|econnrefused|econnreset|enotfound|eai_again|socket hang up|connection refused|connection reset|broken pipe|load failed/i,xr=/timeout|timed out|etimedout/i,Sr=/aborterror|aborted|the user aborted a request|operation was aborted/i,Cr=/node-pty|pty unavailable|terminal unavailable/i,wr=/could not find[^\n]*\bpi\b|pi command not found|pi (?:is )?not (?:installed|found)|not recognized as an internal or external command/i,Tr=/\b401\b|\b403\b|unauthorized|forbidden|invalid api key|incorrect api key|authentication failed|insufficient permission/i,Er=/\b5(?:00|01|02|03|04)\b|internal server error|bad gateway|service unavailable|gateway timeout/i,Dr=/\bhttp\s*(?:status\s*)?[:=]?\s*(\d{3})\b|\bstatus(?:\s*code)?\s*[:=]\s*(\d{3})\b/i,Or=/\b(ENOENT|EACCES|EPERM|EBUSY|EISDIR|ENOTDIR|EMFILE|ENOSPC)\b/;function kr(e){let t=``;if(e==null)t=``;else if(typeof e==`string`)t=e;else if(e instanceof Error)t=e.message;else if(typeof e==`object`&&typeof e.message==`string`)t=e.message;else try{t=String(e)}catch{t=``}return t.trim().replace(/^error:\s*/i,``).replace(/^\[object object\]$/i,``).trim()}var Ar=/^\{[\s{}]*\}$|^\[[\s[\]]*\]$|^(undefined|null|NaN)$|^\[object [\w\s]+\]$/i;function jr(e){let t=e.replace(/\s+/g,` `).trim().replace(/\bsk-[A-Za-z0-9_-]{6,}/g,`sk-***`).replace(/([?&](?:api[_-]?key|access[_-]?token|token)=)[^&\s]+/gi,`$1***`);return t.length>_r?`${t.slice(0,_r)}…`:t}function Mr(e,t){return e.toLowerCase().includes(t.toLowerCase())?e:`${e}(${jr(t)})`}function Nr(e,t){let n=kr(e);if(!n||Ar.test(n))return t??gr;if(vr.test(n))return n;if(yr.test(n))return`请求被拒绝(Bad Request)。返回方没有提供具体原因。`;if(br.test(n))return Mr(`连接不上 Super Pi 服务,请稍后再试。`,n);if(xr.test(n))return Mr(`等待服务响应超时,请稍后再试。`,n);if(Sr.test(n))return Mr(`请求被中断,请重试。`,n);if(Cr.test(n))return Mr(`终端组件没有加载,请重启 Super Pi 后再试。`,n);if(wr.test(n))return Mr(`找不到 Pi 命令,请确认 Pi 已安装并且在命令行里可用。`,n);let r=Number(Dr.exec(n)?.[1]??Dr.exec(n)?.[2]??0);if(r===401||r===403)return Mr(`没有权限完成这个操作,请检查鉴权配置。`,n);if(r>=500)return Mr(`服务端没有完成这次请求(HTTP ${r}),请稍后再试。`,n);if(r>=400)return Mr(`请求被拒绝(HTTP ${r})。`,n);if(Tr.test(n))return Mr(`鉴权失败,请检查对应的 key 或权限配置。`,n);if(Er.test(n))return Mr(`服务端出错了,请稍后再试。`,n);let i=Or.exec(n)?.[1];return Mr(i===`ENOENT`?`找不到对应的文件或目录。`:i===`EACCES`||i===`EPERM`?`没有访问这个文件的权限。`:i===`EBUSY`?`文件正被其他程序占用,请稍后再试。`:i===`ENOSPC`?`磁盘空间不足,这个操作没有完成。`:i?`文件操作没有完成,请检查路径后重试。`:t??hr,n)}function Pr(e){let t=kr(e);if(t&&!Ar.test(t))return Nr(e).includes(t)?void 0:t}function Fr(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?``:t.slice(n+1).toLowerCase()}var Ir={ts:`code`,tsx:`code`,js:`code`,jsx:`code`,mjs:`code`,cjs:`code`,mts:`code`,cts:`code`,py:`code`,rb:`code`,go:`code`,rs:`code`,java:`code`,kt:`code`,kts:`code`,scala:`code`,c:`code`,h:`code`,cc:`code`,cpp:`code`,hpp:`code`,cs:`code`,swift:`code`,m:`code`,mm:`code`,php:`code`,pl:`code`,pm:`code`,lua:`code`,r:`code`,jl:`code`,ex:`code`,exs:`code`,erl:`code`,hs:`code`,dart:`code`,nim:`code`,zig:`code`,vue:`code`,svelte:`code`,astro:`code`,sh:`code`,bash:`code`,zsh:`code`,fish:`code`,ps1:`code`,bat:`code`,cmd:`code`,sql:`code`,graphql:`code`,gql:`code`,proto:`code`,tf:`code`,tfvars:`code`,hcl:`code`,sol:`code`,md:`markup`,mdx:`markup`,markdown:`markup`,txt:`markup`,text:`markup`,rst:`markup`,adoc:`markup`,org:`markup`,yaml:`config`,yml:`config`,toml:`config`,ini:`config`,cfg:`config`,conf:`config`,xml:`config`,env:`config`,properties:`config`,gitignore:`config`,editorconfig:`config`,eslintrc:`config`,prettierrc:`config`,css:`style`,scss:`style`,sass:`style`,less:`style`,stylus:`style`,pcss:`style`,postcss:`style`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,bmp:`image`,webp:`image`,avif:`image`,ico:`image`,svg:`image`,tif:`image`,tiff:`image`,heic:`image`,psd:`image`,ai:`image`,json:`data`,jsonc:`data`,json5:`data`,csv:`data`,tsv:`data`,parquet:`data`,db:`data`,sqlite:`data`,sqlite3:`data`,ndjson:`data`,zip:`archive`,tar:`archive`,gz:`archive`,tgz:`archive`,bz2:`archive`,xz:`archive`,"7z":`archive`,rar:`archive`,zst:`archive`,jar:`archive`,war:`archive`,whl:`archive`,woff:`font`,woff2:`font`,ttf:`font`,otf:`font`,eot:`font`,exe:`binary`,dll:`binary`,so:`binary`,dylib:`binary`,bin:`binary`,o:`binary`,obj:`binary`,a:`binary`,lib:`binary`,class:`binary`,node:`binary`,pyc:`binary`,pyo:`binary`,pack:`binary`,idx:`binary`,iso:`binary`,dmg:`binary`,msi:`binary`,apk:`binary`,deb:`binary`,rpm:`binary`,pdf:`binary`,doc:`binary`,docx:`binary`,xls:`binary`,xlsx:`binary`,ppt:`binary`,pptx:`binary`,odt:`binary`,ods:`binary`,odp:`binary`,wasm:`binary`},Lr={dockerfile:`config`,containerfile:`config`,makefile:`code`,cmakelists:`code`,rakefile:`code`,gemfile:`config`,procfile:`config`,license:`markup`,licence:`markup`,notice:`markup`,readme:`markup`,changelog:`markup`,authors:`markup`,contributing:`markup`,".gitignore":`config`,".gitattributes":`config`,".gitmodules":`config`,".npmrc":`config`,".nvmrc":`config`,".env":`config`};function Rr(e){let t=Lr[e.slice(e.lastIndexOf(`/`)+1).toLowerCase()];if(t)return t;let n=Fr(e);return n?Ir[n]??`generic`:`generic`}var zr={code:[`M6 4.5 2.5 8 6 11.5`,`M10 4.5 13.5 8 10 11.5`,`M9.2 3.5 6.8 12.5`],markup:[`M4 2.5h5l3 3v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1z`,`M9 2.5v3h3`,`M5.5 8.5h5`,`M5.5 11h3.5`],config:[`M8 10.2a2.2 2.2 0 1 0 0-4.4 2.2 2.2 0 0 0 0 4.4z`,`M8 1.8v1.6`,`M8 12.6v1.6`,`M1.8 8h1.6`,`M12.6 8h1.6`,`M3.6 3.6l1.1 1.1`,`M11.3 11.3l1.1 1.1`,`M12.4 3.6l-1.1 1.1`,`M4.7 11.3l-1.1 1.1`],style:[`M8 13.5a5.5 5.5 0 1 1 0-11c3 0 5.5 2 5.5 4.5 0 1.4-1.1 2.2-2.3 2.2h-1c-.9 0-1.6.7-1.6 1.5 0 .4.2.7.4 1 .2.3.4.6.4 1a1.3 1.3 0 0 1-1.4.8z`,`M5.6 6.8h.01`,`M8.4 5.2h.01`,`M11 6.9h.01`],image:[`M2.5 4.5a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-7z`,`M2.5 10.5 6 7.5l2.5 2 2-1.5 3 2.5`,`M5.8 6.4h.01`],data:[`M2.5 3.5h11v9h-11z`,`M2.5 8h11`,`M8 3.5v9`],archive:[`M2.5 5.5h11v8h-11z`,`M1.5 2.5h13v3h-13z`,`M6.8 8.5h2.4`],font:[`M3.5 13 8 3l4.5 10`,`M5.4 9.6h5.2`],binary:[`M2.5 4.5h11v7h-11z`,`M5 7h.01`,`M8 7h.01`,`M11 7h.01`,`M5 9.5h.01`,`M8 9.5h.01`],generic:[`M4 2.5h5l3 3v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1z`,`M9 2.5v3h3`],folder:[`M2.5 4.5a1 1 0 0 1 1-1h3l1.5 2h4.5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-8z`],"folder-open":[`M2.5 12.5v-8a1 1 0 0 1 1-1h3l1.5 2h4.5a1 1 0 0 1 1 1v1`,`M2.5 12.5 4.6 6.8a1 1 0 0 1 .95-.7h8.1a.6.6 0 0 1 .55.85L12.9 12.5a1 1 0 0 1-.95.7H3.5a1 1 0 0 1-1-1z`]};function Br({path:e,category:t,size:n=14}){let r=t??Rr(e??``),i=zr[r]??zr.generic;return(0,L.jsx)(`svg`,{className:`file-icon file-icon-${r}`,"data-file-icon":r,width:n,height:n,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:i.map((e,t)=>(0,L.jsx)(`path`,{d:e},t))})}var Vr={sessions:`会话`,files:`资源管理器`,terminal:`终端`,git:`Git`,main:`任务`,projects:`项目`,tools:`工具`,rsi:`RSI · 观察与改进`},Hr={sessions:`left`,files:`left`,terminal:`right`,git:`right`,main:`right`,projects:`right`,tools:`right`,rsi:`right`},Ur=[`sessions`,`files`,`main`,`terminal`,`git`,`rsi`,`projects`,`tools`],Wr=`super-pi.workbench.layout.v1`,Gr=e=>typeof e==`string`&&Ur.includes(e);function Kr(){return{sides:{...Hr},order:[...Ur],unpinned:[],leftView:`sessions`,leftClosed:!1,rightClosed:!1}}function qr(){let e=Kr();try{let t=JSON.parse(window.localStorage.getItem(Wr)??`null`);if(!t)return e;let n={...Hr};for(let e of Ur)e!==`sessions`&&(t.sides?.[e]===`left`||t.sides?.[e]===`right`)&&(n[e]=t.sides[e]);let r=Array.isArray(t.order)?t.order.filter(Gr):[];return{sides:n,order:[...new Set([...r,...Ur])],unpinned:Array.isArray(t.unpinned)?t.unpinned.filter(Gr).filter(e=>e!==`sessions`):[],leftView:Gr(t.leftView)?t.leftView:`sessions`,leftClosed:t.leftClosed===!0,rightClosed:t.rightClosed===!0}}catch{return e}}function Jr(e){try{window.localStorage.setItem(Wr,JSON.stringify(e))}catch{}}var Yr={rsi:`M5 4h14v12H9l-4 4V4zM8 8h8m-8 4h4m3 0 2 2 3-3`,sessions:`M4 4h16v12H9l-5 4V4zM8 8h8m-8 4h5`,group:`M3 4h14v10H8l-5 4V4zM8 9h4m7 0h2v10h-7l-3 2v-4`,"group-add":`M3 4h14v10H8l-5 4V4zM8 9h4m6 7v6m-3-3h6`,archive:`M4 4h16v5H4zM6 9v11h12V9M10 13h4`,delete:`M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 10v7m4-7v7`,files:`M3 6h7l2 2h9v11H3zM3 9h18`,terminal:`M3 4h18v16H3zM7 8l4 4-4 4m7 0h4`,git:`M7 7v10m10-10v3a4 4 0 0 1-4 4H7M7 3a2 2 0 1 0 0 4 2 2 0 1 0 0-4zm0 14a2 2 0 1 0 0 4 2 2 0 1 0 0-4zM17 3a2 2 0 1 0 0 4 2 2 0 1 0 0-4z`,history:`M3 10a9 9 0 1 1 2 8M3 3v7h7M12 7v5l3 2`,graph:`M6 6v4m0 4v4M8 4h4a6 6 0 0 1 6 6m0 4a6 6 0 0 1-6 6H8M6 2a2 2 0 1 0 0 4 2 2 0 0 0 0-4m0 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4m0 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4M18 10a2 2 0 1 0 0 4 2 2 0 0 0 0-4`,stash:`M6 14V3h8l4 4v7M14 3v4h4M3 14h18v7H3zM9 17h6`,main:`m4 6 2 2 3-4m3 3h8m-16 6 2 2 3-4m3 3h8m-16 6 2 2 3-4m3 3h8`,projects:`M3 4h18v16H3zM3 8h18M9 8v12M15 8v12`,worktree:`M9 2h6v5H9zM12 7v4M6 11h12M6 11v3m12-3v3M2 14h3l2 2h3v6H2zM14 14h3l2 2h3v6h-8z`,tools:`M4 4h6v6H4zm10 0h6v6h-6zM4 14h6v6H4zm10 0h6v6h-6z`,search:`M11 3a7 7 0 1 0 0 14 7 7 0 1 0 0-14zm5 12 5 5`,settings:`M10 3h4l.6 2.5 2 .9L19 5l2 3.5-1.9 1.7v2.4l1.9 1.8-2 3.4-2.4-.9-2 .9L14 21h-4l-.6-2.6-2-.9-2.4.9-2-3.4 1.9-1.8v-2.4L3 8.5 5 5l2.4 1.4 2-.9zM12 9a3 3 0 1 0 0 6 3 3 0 1 0 0-6z`,help:`M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zm-2.8 6.3a2.8 2.8 0 0 1 5.6 0c0 2-2.8 2.3-2.8 4M12 17h.01`,update:`M12 3v12m-4-4 4 4 4-4M4 15v5h16v-5`,restart:`M12 3v9M6 6a8 8 0 1 0 12 0`,more:`M5 12h.01M12 12h.01M19 12h.01`,close:`M6 6l12 12M18 6 6 18`,back:`M19 12H5m7-7-7 7 7 7`,forward:`M5 12h14m-7-7 7 7-7 7`,split:`M3 4h18v16H3zM12 4v16`,pin:`m14 3 7 7-3 1-3 4-1 3-8-8 3-1 4-3zm-4 11-6 6`};function Xr({name:e}){return(0,L.jsx)(`svg`,{className:`workbench-icon`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.55`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:Yr[e]})})}function Zr({side:e,views:t,unpinned:n,active:r,previous:i,onSelect:a,onSearch:o,onArrange:s,onReorder:c,children:l,searchActive:d}){let f=t.filter(e=>n.includes(e)),p=t.filter(e=>!n.includes(e)),[m,h]=(0,u.useState)(),g=m&&p.includes(m)?m:r&&p.includes(r)?r:p[0],_=(0,u.useRef)(new Map),v=(0,u.useRef)(null),[y,b]=(0,u.useState)(),x=(0,u.useRef)(null),S=(0,u.useRef)(void 0),[C,w]=(0,u.useState)();return(0,u.useEffect)(()=>{if(!y)return;let e=()=>b(void 0),t=t=>{t.target instanceof Node&&!x.current?.contains(t.target)&&e()},n=t=>{t.key!==`Escape`||t.defaultPrevented||(t.preventDefault(),e(),_.current.get(y.view)?.focus())};return x.current?.querySelector(`button`)?.focus(),window.addEventListener(`pointerdown`,t),window.addEventListener(`keydown`,n),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`pointerdown`,t),window.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,e)}},[y]),(0,u.useEffect)(()=>{let e=e=>{let t=v.current;t?.open&&e.target instanceof Node&&!t.contains(e.target)&&(t.open=!1)};return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[]),(0,L.jsxs)(`div`,{className:`workbench-activity workbench-activity-${e}`,"data-workbench-activity":e,children:[(0,L.jsx)(`div`,{className:`workbench-activity-views`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":e===`left`?`左侧视图`:`右侧视图`,children:p.map((t,n)=>(0,L.jsx)(`button`,{type:`button`,role:`tab`,id:t===`sessions`?`workbench-sessions-tab`:`right-tab-${t}`,className:`right-tab workbench-activity-button${r===t?` right-tab-active`:``}`,"data-workbench-view":t,"data-right-tab":t===`sessions`?void 0:t,"data-right-rail-open":e===`right`&&!r&&i===t?`1`:void 0,"aria-controls":t===`sessions`?`workbench-sessions`:`right-panel-${t}`,"aria-selected":r===t,tabIndex:t===g?0:-1,draggable:t!==`sessions`,"data-workbench-drop":C===t?`1`:void 0,onContextMenu:n=>{if(t===`sessions`)return;n.preventDefault();let r=n.currentTarget.getBoundingClientRect();b({view:t,x:Math.max(4,Math.min(window.innerWidth-200,n.clientX||(e===`left`?r.right:r.left-196))),y:Math.max(4,Math.min(window.innerHeight-146,n.clientY||r.top))})},onDragStart:e=>{t!==`sessions`&&(S.current=t,e.dataTransfer.setData(`text/plain`,t),e.dataTransfer.effectAllowed=`move`)},onDragOver:e=>{S.current&&t!==`sessions`&&S.current!==t&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,w(t))},onDragLeave:()=>w(e=>e===t?void 0:e),onDrop:e=>{let n=S.current;n&&t!==`sessions`&&(e.preventDefault(),c(n,t),S.current=void 0,w(void 0))},onDragEnd:()=>{S.current=void 0,w(void 0)},ref:e=>{e?_.current.set(t,e):_.current.delete(t)},title:Vr[t],"aria-label":Vr[t],onFocus:()=>h(t),onClick:()=>a(t),onKeyDown:r=>{if(t!==`sessions`&&(r.key===`ContextMenu`||r.shiftKey&&r.key===`F10`)){r.preventDefault();let n=r.currentTarget.getBoundingClientRect();b({view:t,x:Math.max(4,e===`left`?n.right:n.left-196),y:Math.max(4,Math.min(window.innerHeight-146,n.top))});return}let i=r.key===`Home`?p[0]:r.key===`End`?p.at(-1):r.key===`ArrowDown`?p[(n+1)%p.length]:r.key===`ArrowUp`?p[(n+p.length-1)%p.length]:void 0;i&&(r.preventDefault(),_.current.get(i)?.focus())},children:(0,L.jsx)(Xr,{name:t})},t))}),o&&(0,L.jsx)(`button`,{type:`button`,className:`workbench-activity-button${d?` right-tab-active`:``}`,"data-workbench-search":`1`,title:`搜索`,"aria-label":`搜索`,"aria-pressed":!!d,onClick:o,children:(0,L.jsx)(Xr,{name:`search`})}),f.length>0&&(0,L.jsxs)(`details`,{className:`workbench-menu workbench-more`,ref:v,onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.open&&(e.preventDefault(),e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,L.jsx)(`summary`,{className:`workbench-activity-button`,title:`更多视图`,"aria-label":`更多视图`,children:(0,L.jsx)(Xr,{name:`more`})}),(0,L.jsx)(`div`,{className:`workbench-menu-items`,children:f.map(e=>(0,L.jsxs)(`button`,{type:`button`,"data-workbench-extra":e,"aria-pressed":r===e,onClick:t=>{t.currentTarget.closest(`details`)?.removeAttribute(`open`),r===e?v.current?.querySelector(`summary`)?.focus():a(e)},children:[(0,L.jsx)(Xr,{name:e}),Vr[e]]},e))})]}),y&&(0,Ie.createPortal)((0,L.jsx)(`div`,{ref:x,className:`workbench-menu-items workbench-context-menu`,style:{left:y.x,top:y.y},"aria-label":`${Vr[y.view]}布局`,children:Qr(e,!0).map(([e,t])=>(0,L.jsx)(`button`,{type:`button`,"data-workbench-context-action":e,onClick:()=>{b(void 0),s(y.view,e),e!==`move`&&e!==`pin`&&_.current.get(y.view)?.focus()},children:t},e))}),document.body),l&&(0,L.jsx)(`div`,{className:`workbench-activity-utilities`,children:l})]})}var Qr=(e,t)=>[[`move`,e===`left`?`移到右侧`:`移到左侧`],[`pin`,t?`从活动栏取消固定`:`固定到活动栏`],[`up`,`在活动栏上移`],[`down`,`在活动栏下移`]];function $r({view:e,side:t,pinned:n,onArrange:r}){let i=Qr(t,n);return(0,L.jsxs)(`details`,{className:`workbench-menu workbench-panel-menu`,children:[(0,L.jsx)(`summary`,{title:`视图布局`,"aria-label":`${Vr[e]}布局`,"data-workbench-panel-menu":e,children:(0,L.jsx)(Xr,{name:`more`})}),(0,L.jsx)(`div`,{className:`workbench-menu-items`,children:i.map(([t,n])=>(0,L.jsx)(`button`,{type:`button`,"data-workbench-arrange":t,onClick:n=>{n.currentTarget.closest(`details`)?.removeAttribute(`open`),r(e,t)},children:n},t))})]})}var ei={file:`M8 3h6l4 4v13H6V3h2m6 0v5h4M9 13h6m-3-3v6`,folder:`M3 7V5h7l2 2h9v12H3V7m6 6h6m-3-3v6`,refresh:`M19 9a7 7 0 0 0-12-3L4 9m0-5v5h5m-4 6a7 7 0 0 0 12 3l3-3m0 5v-5h-5`,collapse:`M8 5h12v12M4 9h12v12H4zm3 6h6`,locate:`M12 2v4m0 12v4M2 12h4m12 0h4M7 12a5 5 0 1 0 10 0 5 5 0 1 0-10 0`,upload:`M12 15V4m-4 4 4-4 4 4M4 14v5h16v-5`,download:`M12 4v11m-4-4 4 4 4-4M4 15v5h16v-5`,more:`M5 12h.01M12 12h.01M19 12h.01`,search:`M11 5a6 6 0 1 0 0 12 6 6 0 1 0 0-12m4.5 10.5L20 20`,right:`m9 6 6 6-6 6`,down:`m6 9 6 6 6-6`,close:`m6 6 12 12M18 6 6 18`,trash:`M4 6h16M9 6V3h6v3m3 0-1 14H7L6 6m4 4v6m4-6v6`,copy:`M8 8h12v12H8zm8-4H4v12`,reference:`M15 12a3 3 0 1 0-6 0 3 3 0 0 0 6 0m0-3v5c0 2 5 3 5-2a8 8 0 1 0-3 6`,rename:`M4 7h6m4 0h6v10h-6m-4 0H4zm8-11v12m-2-12h4m-4 12h4`,move:`M3 7V5h7l2 2h9v12H3zm6 6h6m-3-3 3 3-3 3`,changes:`M7 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 0v10m0 4a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm10-12a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 0c0 5-5 5-10 5`,save:`M4 4h13l3 3v13H4zm4 0v6h8V4M8 20v-6h8v6`};function ti({name:e}){return(0,L.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:e===`more`?3.3:1.65,strokeLinecap:`round`,strokeLinejoin:`round`,className:`explorer-glyph`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:ei[e]})})}function ni(e){let t=e.getBoundingClientRect();return{x:t.right,y:t.bottom+4,origin:e,alignEnd:!0,initialFocus:!0}}function ri({label:e,anchor:t,close:n,children:r}){let i=(0,u.useRef)(null),a=(0,u.useRef)(n);a.current=n;let[o,s]=(0,u.useState)({left:t.x,top:t.y});return(0,u.useLayoutEffect)(()=>{let e=i.current;if(!e)return;let n=e.getBoundingClientRect();s({left:Math.max(6,Math.min(t.alignEnd?t.x-n.width:t.x,window.innerWidth-n.width-6)),top:Math.max(6,Math.min(t.y,window.innerHeight-n.height-6))}),t.initialFocus?e.querySelector(`[role="menuitem"]`)?.focus({preventScroll:!0}):e.focus({preventScroll:!0});let r=n=>{let r=n.target;!e.contains(r)&&!t.origin.contains(r)&&a.current(!1)},o=()=>a.current(!1),c=n=>{let r=n.target;r instanceof Element&&!e.contains(r)&&r.contains(t.origin)&&a.current(!1)};return window.addEventListener(`pointerdown`,r,!0),window.addEventListener(`resize`,o),window.addEventListener(`scroll`,c,!0),()=>{window.removeEventListener(`pointerdown`,r,!0),window.removeEventListener(`resize`,o),window.removeEventListener(`scroll`,c,!0)}},[t]),(0,Ie.createPortal)((0,L.jsx)(`div`,{className:`file-context-menu`,"data-file-context-menu":`1`,ref:i,style:o,role:`menu`,"aria-label":e,tabIndex:-1,onContextMenu:e=>e.preventDefault(),onKeyDown:e=>{if(e.key===`Escape`||e.key===`Tab`){e.preventDefault(),e.stopPropagation(),n(!0);return}let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]`)],r=t.indexOf(document.activeElement),i=t.length;i&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)&&(e.preventDefault(),t[e.key===`Home`?0:e.key===`End`?i-1:e.key===`ArrowDown`?(r+1)%i:r<=0?i-1:r-1]?.focus())},children:r}),document.body)}function ii({root:e,path:t,reveal:n}){let r=t.split(`/`),i=r.at(-1)??t,a=r.slice(0,-1);return(0,L.jsxs)(`nav`,{className:`file-breadcrumbs`,"aria-label":`文件路径`,title:t,children:[(0,L.jsxs)(`button`,{className:`file-crumb file-crumb-root`,type:`button`,onClick:()=>n(``,!0),title:`定位 ${e}`,children:[(0,L.jsx)(Br,{category:`folder`}),(0,L.jsx)(`span`,{children:e})]}),a.map((e,t)=>{let r=a.slice(0,t+1).join(`/`);return(0,L.jsxs)(`span`,{className:`file-crumb-step`,children:[(0,L.jsx)(ti,{name:`right`}),(0,L.jsx)(`button`,{className:`file-crumb`,type:`button`,title:`定位 ${r}`,"data-file-crumb":r,onClick:()=>n(r,!0),children:e})]},r)}),(0,L.jsxs)(`span`,{className:`file-crumb-step file-crumb-leaf`,children:[(0,L.jsx)(ti,{name:`right`}),(0,L.jsxs)(`button`,{className:`file-crumb`,type:`button`,"aria-current":`location`,"data-file-crumb":t,onClick:()=>n(t,!1),title:`定位 ${t}`,children:[(0,L.jsx)(Br,{path:t}),(0,L.jsx)(`span`,{children:i})]})]})]})}async function ai(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}let t=document.activeElement,n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.cssText=`position:fixed;top:0;left:0;width:1px;height:1px;padding:0;border:0;opacity:0;pointer-events:none`,document.body.appendChild(n);try{return n.focus({preventScroll:!0}),n.select(),n.setSelectionRange(0,n.value.length),document.execCommand(`copy`)}catch{return!1}finally{n.remove(),t?.isConnected&&t.focus({preventScroll:!0})}}function oi(e){let t=new Map,n=[],r=0,i=1,a=(e,t)=>{let r=t??n.indexOf(!1),a=r<0?n.length:r;return n[a]=!0,i=Math.max(i,a+1),{index:a,color:e}},o=e.map(({hash:e,parents:i})=>{let o=t.get(e),s=o??a(r++);t.delete(e),n[s.index]=!1;let c=[...t.values()],l=[...new Set(i)].map((e,n)=>{let i=t.get(e);return i||(i=n===0?a(s.color,s.index):a(r++),t.set(e,i)),{hash:e,lane:i}});return{node:s,incoming:o!==void 0,through:c,parents:l}});return{columns:i,rows:o}}function si(e,t){if(t===`untracked`||e.startsWith(`?`))return{label:`U`,kind:`untracked`,slot:`worktree`};let n=(t===`staged`?e[0]:e[1])||e[0]||`M`;return n===`A`?{label:`A`,kind:`added`,slot:t===`staged`?`index`:`worktree`}:n===`D`?{label:`D`,kind:`deleted`,slot:t===`staged`?`index`:`worktree`}:n===`R`?{label:`R`,kind:`renamed`,slot:t===`staged`?`index`:`worktree`}:{label:`M`,kind:`modified`,slot:t===`staged`?`index`:`worktree`}}var ci={untracked:`未跟踪(U):尚未加入 Git,暂存后会加入版本管理`,added:`新增(A)`,modified:`已修改(M)`,deleted:`已删除(D)`,renamed:`已重命名(R)`},li=e=>e.path.endsWith(`/`),ui=[{id:`changes`,title:`工作区改动`,search:`搜索文件名或路径`,icon:`main`},{id:`log`,title:`提交历史`,search:`搜索提交说明或哈希`,icon:`history`},{id:`graph`,title:`提交图`,search:``,icon:`graph`},{id:`branches`,title:`分支`,search:`搜索本地或远程分支`,icon:`git`},{id:`stash`,title:`Stash`,search:`搜索贮藏记录`,icon:`stash`},{id:`worktrees`,title:`工作树`,search:``,icon:`worktree`}],di={graph:`提交图:查看提交历史及分叉、汇合关系`,branches:`分支:查看和管理本地、远程分支`,stash:`Stash:临时收起未提交改动,稍后恢复`,worktrees:`工作树:同一仓库的多个独立工作目录`},fi=`请选择具体工作区或 session 以确定工作目录`,pi=e=>e===`changes`||e===`log`||e===`stash`,mi=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},hi=15e3,z=(e,t)=>new mi(408,{error:`请求超时:${t/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function gi(e,t,n=hi){let r=new AbortController,i=setTimeout(()=>r.abort(),n);try{let n=t?.signal?AbortSignal.any([t.signal,r.signal]):r.signal,i=await je(e,{...t,signal:n}),a;try{a=await i.json()}catch(e){if(i.ok)throw e}if(!i.ok)throw new mi(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw r.signal.aborted?z(e,n):t}finally{clearTimeout(i)}}var _i=e=>e instanceof mi?e:new mi(0,{error:e instanceof Error?e.message:`读取失败`}),vi=e=>encodeURIComponent(e),yi=e=>e?`&cwd=${vi(e)}`:``,bi=(e,t)=>`/api/git?workspaceId=${vi(e)}&op=status${yi(t)}`,xi=(e,t,n,r)=>`/api/git?workspaceId=${vi(e)}&op=diff&path=${vi(t)}${n?`&staged=1`:``}${yi(r)}`;async function Si(e,t,n={},r){let i=t===`draft`?35e3:[`fetch`,`pull`,`push`].includes(t)?65e3:hi;return gi(`/api/git?workspaceId=${vi(e)}&op=${vi(t)}${yi(r)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)},i)}var Ci=20,wi=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`})},Ti=e=>e.detached||e.branch===null?`(未在任何分支上)`:e.unborn?`${e.branch}(起始提交)`:e.branch,Ei=e=>{let t=[];return e.ahead!==null&&t.push(`↑${e.ahead}`),e.behind!==null&&t.push(`↓${e.behind}`),t.length===0?null:t.join(` `)},Di=[{key:`staged`,title:`已暂存`},{key:`unstaged`,title:`未暂存`},{key:`untracked`,title:`未跟踪`}];function Oi({path:e,untracked:t=!1,onCancel:n,onConfirm:r}){let i=(0,u.useRef)(null),a=(0,u.useRef)(null);(0,u.useEffect)(()=>{a.current?.focus();let e=e=>{e.key===`Escape`&&(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let o=(0,L.jsx)(`div`,{className:`overlay git-confirm-overlay`,"data-git-confirm-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&n()},children:(0,L.jsxs)(`div`,{className:`picker git-confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`git-confirm-title`,tabIndex:-1,ref:i,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.key!==`Tab`)return;let t=i.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), [tabindex]:not([tabindex='-1'])`));if(n.length===0)return;let r=n[0],a=n[n.length-1];e.shiftKey?document.activeElement===r&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),r.focus())},"data-git-confirm-dialog":`1`,children:[(0,L.jsx)(`h2`,{id:`git-confirm-title`,className:`git-confirm-title`,children:`确认丢弃更改?`}),(0,L.jsx)(`p`,{className:`git-confirm-desc`,children:t?`将以下未跟踪文件或目录移到资源管理器回收站:`:`即将丢弃以下文件的所有未暂存修改,恢复暂存区版本;已暂存内容不受影响:`}),(0,L.jsx)(`div`,{className:`git-confirm-path`,"data-git-confirm-path":e,title:e,children:e}),(0,L.jsx)(`p`,{className:`git-confirm-warning`,"data-git-confirm-warning":`1`,children:t?`可在资源管理器的回收站中恢复。`:`⚠ 丢弃后不可撤销,此文件的本地未暂存修改将永久丢失(无法找回)。`}),(0,L.jsxs)(`div`,{className:`git-confirm-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`picker-cancel git-confirm-cancel`,"data-git-confirm-cancel":`1`,ref:a,onClick:n,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,className:`git-confirm-danger`,"data-git-confirm-ok":`1`,onClick:r,children:t?`移到回收站`:`确认丢弃`})]})]})});return typeof document>`u`?o:(0,Ie.createPortal)(o,document.body)}function ki(e,t,n){let r=e?bi(e,t):``,[i,a]=(0,u.useState)(),o=(0,u.useRef)({scope:r,ticket:0,busy:!1});o.current.scope!==r&&(o.current={scope:r,ticket:0,busy:!1});let s=(0,u.useCallback)((e=!1)=>{let t=o.current;if(!r||t.scope!==r||!n||t.busy&&!e)return;t.busy=!0;let i=++t.ticket,s=()=>o.current===t&&t.ticket===i;gi(r).then(e=>{s()&&(Ii(Mi,r,e,16),a({scope:r,status:e,error:null}))}).catch(e=>{s()&&a({scope:r,status:null,error:_i(e)})}).finally(()=>{s()&&(t.busy=!1)})},[r,n]);(0,u.useEffect)(()=>{let e=o.current;s(!0);let t=()=>{document.visibilityState===`visible`&&s()},n=window.setInterval(t,15e3);return window.addEventListener(`focus`,t),()=>{window.clearInterval(n),window.removeEventListener(`focus`,t),e.ticket++,e.busy=!1}},[s]);let c=(0,u.useCallback)(e=>{r&&o.current.scope===r&&(o.current.ticket++,o.current.busy=!1,Ii(Mi,r,e,16),a({scope:r,status:e,error:null}))},[r]),l=i?.scope===r?i:void 0;return{status:l?l.status:Mi.get(r)??null,error:l?.error??null,refresh:s,publish:c}}function Ai(e,t,n={}){return`/api/git?${new URLSearchParams({workspaceId:e,op:t,...n})}`}function ji(e,t,n,r,i){return Ai(e,i===void 0?`commit-detail`:`commit-diff`,{hash:n,...t?{cwd:t}:{},...r?{worktreeId:r}:{},...i===void 0?{}:{path:i}})}var Mi=new Map,Ni=new Map,Pi=new Map,Fi=new Map;function Ii(e,t,n,r){if(e.delete(t),e.set(t,n),e.size>r){let t=e.keys().next().value;t!==void 0&&e.delete(t)}}function Li(e){return e.length?`${e.length>1?`第一父提交`:`父提交`} ${e[0].slice(0,8)}`:`空树`}var Ri={A:`新增`,M:`修改`,D:`删除`,R:`重命名`,C:`复制`,T:`类型更改`};function zi({commits:e,workspaceId:t,cwd:n,worktreeId:r,onDiff:i,graph:a}){let[o,s]=(0,u.useState)(),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(0),p=o&&e.some(e=>e.hash===o)?ji(t,n,o,r):``;(0,u.useEffect)(()=>{if(!p||Pi.has(p))return;let e=new AbortController;return gi(p,{signal:e.signal}).then(t=>{e.signal.aborted||(Ii(Pi,p,t,40),l({url:p,detail:t}))}).catch(t=>{e.signal.aborted||l({url:p,error:_i(t).message})}),()=>e.abort()},[p,d]);let m=Pi.get(p),h=c?.url===p?c:m?{detail:m}:void 0;return(0,L.jsx)(L.Fragment,{children:e.map((e,t)=>{let n=o===e.hash,c=n?h?.detail:void 0,u=c?Li(c.parents):``,d=a?.rows[t],p=`refs`in e?e.refs:[],m=`parents`in e&&e.parents.length>1;return(0,L.jsxs)(`div`,{className:d?`git-history-item git-graph-item`:`git-history-item`,style:d&&a?{minWidth:a.columns*Bi+142}:void 0,children:[d&&a&&(0,L.jsx)(Ui,{row:d,columns:a.columns,merge:m}),(0,L.jsxs)(`button`,{type:`button`,className:`git-log-row`,"data-git-commit":e.hash,"aria-expanded":n,onClick:()=>{s(n?void 0:e.hash),l(void 0)},children:[(0,L.jsx)(`span`,{className:`git-log-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,L.jsx)(`span`,{className:`git-log-subject`,title:e.subject,children:e.subject||`(无提交说明)`}),(0,L.jsxs)(`span`,{className:`git-log-meta`,children:[(0,L.jsx)(`span`,{className:`git-log-hash`,title:e.hash,children:e.short}),(0,L.jsx)(`span`,{className:`git-log-author`,title:e.author,children:e.author}),(0,L.jsx)(`time`,{className:`git-log-date`,dateTime:e.date,title:e.date,children:wi(e.date)})]}),(m||p.length>0)&&(0,L.jsxs)(`span`,{className:`git-graph-refs`,children:[m&&(0,L.jsx)(`span`,{className:`git-graph-ref`,children:`合并`}),p.slice(0,3).map(e=>(0,L.jsx)(Hi,{refItem:e},e.checkoutId??`${e.kind}:${e.name}`)),p.length>3&&(0,L.jsxs)(`span`,{className:`git-graph-ref`,title:`展开提交查看全部引用`,children:[`+`,p.length-3]})]})]}),n&&(0,L.jsxs)(`div`,{className:`git-commit-changes`,"data-git-commit-changes":e.hash,children:[!h&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取提交中的文件…`}),h?.error&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,children:Nr(h.error,`读取提交失败。`)}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,onClick:()=>{l(void 0),f(e=>e+1)},children:`重试`})]}),c&&(0,L.jsxs)(L.Fragment,{children:[p.length>3&&(0,L.jsxs)(`details`,{className:`git-commit-extra`,children:[(0,L.jsxs)(`summary`,{children:[p.length,` 个引用`]}),(0,L.jsx)(`div`,{className:`git-graph-refs`,children:p.map(e=>(0,L.jsx)(Hi,{refItem:e},e.checkoutId??`${e.kind}:${e.name}`))})]}),c.message.includes(`
|
|
22
|
-
`)&&(0,L.jsxs)(`details`,{className:`git-commit-extra`,children:[(0,L.jsx)(`summary`,{children:`完整提交说明`}),(0,L.jsx)(`pre`,{children:c.message})]}),(0,L.jsxs)(`p`,{className:`git-scope-note`,title:c.parents[0],children:[c.files.length,` 个文件 · 对比`,u]}),!c.files.length&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`当前目录内没有文件改动。`}),c.files.map(t=>{let n=t.path.split(`/`).at(-1)??t.path,a=t.previousPath===void 0?t.path:`${t.previousPath} → ${t.path}`,o=Ri[t.status[0]]??t.status;return(0,L.jsxs)(`button`,{type:`button`,className:`git-worktree-file git-commit-file`,"data-git-commit-file":t.path,title:`${o} · ${a}`,onClick:()=>i({hash:e.hash,base:u,file:t,worktreeId:r}),children:[(0,L.jsx)(Br,{path:t.path,size:15}),(0,L.jsxs)(`span`,{className:`git-commit-file-label`,children:[(0,L.jsx)(`span`,{children:n}),a!==n&&(0,L.jsx)(`small`,{children:a})]}),(0,L.jsx)(`span`,{className:`git-commit-file-status`,"aria-label":o,children:t.status[0]})]},t.path)})]})]})]},e.hash)})})}var Bi=14,Vi={head:`当前检出`,worktree:`工作树`,branch:`本地分支`,remote:`远程跟踪分支`,tag:`标签`,stash:`贮藏`};function Hi({refItem:e}){let{kind:t,name:n}=e;return(0,L.jsxs)(`span`,{className:`git-graph-ref`,"data-git-graph-ref":t,title:`${Vi[t]} · ${n}`,children:[t===`tag`||t===`worktree`?`${Vi[t]} `:``,n]})}function Ui({row:e,columns:t,merge:n}){let r=e=>e*Bi+Bi/2,i=r(e.node.index),a=t*Bi;return(0,L.jsxs)(`div`,{className:`git-graph-lines`,"aria-hidden":`true`,"data-git-graph-lane":e.node.index,"data-git-graph-incoming":e.incoming||void 0,children:[(0,L.jsxs)(`svg`,{className:`git-graph-top`,width:a,height:`32`,viewBox:`0 0 ${a} 32`,children:[e.through.map(e=>(0,L.jsx)(`path`,{"data-color":e.color%5,d:`M ${r(e.index)} 0 V 32`},e.index)),e.incoming&&(0,L.jsx)(`path`,{"data-color":e.node.color%5,d:`M ${i} 0 V 16`}),e.parents.map(({hash:e,lane:t},n)=>(0,L.jsx)(`path`,{"data-git-graph-parent":e,"data-color":t.color%5,d:`M ${i} 16 C ${i} 24 ${r(t.index)} 22 ${r(t.index)} 32`},n)),n?(0,L.jsx)(`rect`,{"data-color":e.node.color%5,x:i-3.5,y:`12.5`,width:`7`,height:`7`,rx:`1`}):(0,L.jsx)(`circle`,{"data-color":e.node.color%5,cx:i,cy:`16`,r:`3.5`})]}),(0,L.jsx)(`svg`,{className:`git-graph-tail`,width:a,viewBox:`0 0 ${a} 1`,preserveAspectRatio:`none`,children:[...e.through,...e.parents.map(e=>e.lane).filter(t=>!e.through.some(e=>e.index===t.index))].map(e=>(0,L.jsx)(`path`,{"data-color":e.color%5,d:`M ${r(e.index)} 0 V 1`},e.index))})]})}function Wi({workspaceId:e,cwd:t,revision:n,onDiff:r}){let i=Ai(e,`graph`,t?{cwd:t}:{}),[a,o]=(0,u.useState)(()=>({page:Ni.get(i),loading:!0})),s=(0,u.useRef)(void 0),c=(0,u.useCallback)(e=>{s.current?.abort();let t=new AbortController;s.current=t;let n=Ni.get(i);o(t=>({page:e??n??t.page,loading:!0}));let r=new URLSearchParams(e?{offset:String(e.commits.length),snapshot:e.snapshot,after:e.commits.at(-1)?.hash??``}:n?{knownSnapshot:n.snapshot}:{});gi(`${i}&${r}`,{signal:t.signal}).then(r=>{if(t.signal.aborted)return;let a=`unchanged`in r?Ni.get(i)??n:e?{...r,commits:[...e.commits,...r.commits]}:r;a&&Ii(Ni,i,a,8),o({page:a,loading:!1})}).catch(n=>{t.signal.aborted||o(t=>({page:t.page,error:_i(n),loading:!1,append:!!e}))})},[i]);(0,u.useEffect)(()=>(c(),()=>s.current?.abort()),[c,n]);let l=a.page,d=(0,u.useMemo)(()=>l&&oi(l.commits),[l]),f=a.error?.body.code===`graph_changed`;return(0,L.jsxs)(`section`,{className:`git-graph`,"data-git-graph":!0,"aria-label":`提交图`,"aria-busy":a.loading,children:[(0,L.jsx)(`p`,{className:`git-scope-note`,children:`仓库历史 · 文件差异按当前会话目录`}),l&&d&&l.commits.length>0&&(0,L.jsx)(`div`,{className:`git-graph-list`,tabIndex:0,role:`region`,"aria-label":`提交关系`,children:(0,L.jsx)(zi,{commits:l.commits,workspaceId:e,cwd:t,onDiff:r,graph:d})}),l&&!l.commits.length&&(0,L.jsx)(`p`,{className:`rail-empty`,children:`暂无提交记录。`}),a.error&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,children:Nr(a.error,`读取提交图失败。`)}),a.loading&&!l&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取提交图…`}),(a.error||l?.hasMore)&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action git-graph-more`,"data-git-graph-more":!0,disabled:a.loading,onClick:()=>c(f||a.error&&!a.append?void 0:l),children:a.loading?`读取中…`:f?`重新加载提交图`:a.error?`重试`:`加载更早的提交`})]})}function Gi({workspaceId:e,value:t,disabled:n,onChoose:r}){let[i,a]=(0,u.useState)(),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(0),[d,f]=(0,u.useState)(),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(!1),[_,v]=(0,u.useState)(0);return(0,u.useEffect)(()=>{if(!i)return;let t=new AbortController;g(!0),m(``);let n=window.setTimeout(()=>{gi(Ai(e,`branches`,{local:`1`,q:o,offset:String(c)}),{signal:t.signal}).then(e=>{t.signal.aborted||f(t=>c&&t?{...e,branches:[...t.branches,...e.branches]}:e)}).catch(e=>{t.signal.aborted||m(_i(e).message)}).finally(()=>{t.signal.aborted||g(!1)})},o?180:0);return()=>{window.clearTimeout(n),t.abort()}},[i,e,o,c,_]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-view-search git-base-trigger`,"aria-label":`工作树起点分支`,"aria-haspopup":`dialog`,"aria-expanded":!!i,title:n?fi:t||`当前工作区提交(HEAD)`,disabled:n,onClick:e=>{s(``),l(0),f(void 0),a(e.currentTarget)},children:[(0,L.jsx)(`span`,{children:t||`当前工作区提交(HEAD)`}),(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`⌄`})]}),i&&(0,L.jsxs)(Ye,{title:`选择工作树起点分支`,anchor:i,onClose:()=>a(void 0),hideEmpty:h||!!p,onSearch:e=>{s(e),l(0),f(void 0),g(!0)},choices:[{id:``,label:`当前工作区提交(HEAD)`},...(d?.branches??[]).map(e=>({id:e.name,label:e.name,detail:e.current?`本地分支 · 当前分支`:`本地分支`}))],onChoose:e=>{r(e),a(void 0),i.focus()},children:[h&&(0,L.jsx)(`p`,{role:`status`,children:`读取本地分支…`}),p&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,children:p}),(p||d&&d.branches.length<d.matches)&&(0,L.jsx)(`button`,{type:`button`,disabled:h,"data-worktree-branches-more":!0,onClick:()=>p?v(e=>e+1):l(d.branches.length),children:p?`重试`:`加载更多分支`})]})]})}function Ki({workspaceId:e,conversationId:t,followedWorktreeId:n,revision:r,onDiff:i,onCommitDiff:a,onOpenConversation:o,repositoryOnly:s=!1}){let[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(``),p=`super-pi.git-worktree:${JSON.stringify([e,t])}`,[m,h]=(0,u.useState)(()=>{try{return window.sessionStorage.getItem(p)??n??``}catch{return n??``}}),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(0),O=(0,u.useRef)(n),k=c?.find(e=>e.current),A=m?c?.find(e=>e.id===m):k??c?.[0],j=e=>{h(e);try{window.sessionStorage.setItem(p,e)}catch{}};(0,u.useEffect)(()=>{n&&n!==O.current&&j(n),O.current=n},[n,p]);let M=async(n,r)=>{if(!(S||s&&n!==`open`)){C(n),T(``);try{let i={action:n,requestId:Yt(),worktreeId:r,...t&&!t.startsWith(`pending:`)?{conversationId:t}:{},...n===`create`?{branch:v.trim(),base:b.trim()}:{}},a=await gi(Ai(e,`worktree-manage`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)},65e3);j(a.worktree.id),D(e=>e+1),n===`create`&&(y(``),x(``)),a.conversationId&&o?.(a.conversationId,a.workspaceId)}catch(e){T(_i(e).message)}finally{C(``)}}};(0,u.useEffect)(()=>{let t=!0,n=!1,r=async()=>{if(!n){n=!0;try{let n=await gi(Ai(e,`worktrees`));t&&(l(n.worktrees),f(``))}catch(e){t&&f(_i(e).message)}finally{n=!1}}};r();let i=window.setInterval(()=>{document.visibilityState===`visible`&&r()},1e4);return()=>{t=!1,window.clearInterval(i)}},[e,r,E]),(0,u.useEffect)(()=>{if(s||!A||A.missing)return;let t=A.id,n=!0,r=!1,i=async()=>{if(!r){r=!0;try{let r=await gi(Ai(e,`worktree-inspect`,{worktreeId:t}));n&&_({id:t,value:r})}catch(e){n&&_({id:t,error:_i(e).message})}finally{r=!1}}};i();let a=window.setInterval(()=>{document.visibilityState===`visible`&&i()},5e3);return()=>{n=!1,window.clearInterval(a)}},[e,A?.id,A?.missing,r,E,s]);let N=!s&&g?.id===A?.id?g:void 0,P=N?.value?.comparison,F=N?.value?.status,ee=F?Di.map(e=>({...e,files:F[e.key]})):[],te=(e,t)=>{let n=si(e.xy,`unstaged`).kind===`untracked`;return(0,L.jsxs)(`button`,{type:`button`,className:`git-worktree-file`,title:e.path,"data-git-worktree-file":e.path,onClick:()=>i({...t,label:A?.branch??A?.name??`关联工作树`}),children:[(0,L.jsx)(Br,{path:e.path,size:15}),` `,(0,L.jsx)(`span`,{children:e.path}),(0,L.jsx)(`small`,{title:n?ci.untracked:e.xy.trim(),children:n?`U`:e.xy.trim()})]},e.path)};return(0,L.jsxs)(`section`,{className:`git-worktrees`,"data-git-worktrees":!0,"aria-label":`仓库工作树`,children:[d&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:d}),!c&&!d&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取工作树…`}),c&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`select`,{className:`git-view-search`,"aria-label":`选择要查看的工作树`,value:A?.id??``,onChange:e=>j(e.target.value),children:[!A&&(0,L.jsx)(`option`,{value:``,children:`选择工作树`}),c.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.branch??(e.head.slice(0,8)||e.name),` · `,e.name,e.primary?` · 主检出`:``,e.current?` · 当前`:``,e.missing?` · 已丢失`:``,e.locked?` · 已锁定`:``]},e.id))]}),A&&(0,L.jsx)(`p`,{className:`git-worktree-path`,title:A.path,"data-git-worktree-path":!0,children:A.path}),(0,L.jsxs)(`div`,{className:`git-worktree-actions`,children:[A&&!A.missing&&o&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-worktree-open":!0,disabled:!!S,onClick:()=>void M(`open`,A.id),children:`在此新建会话`}),A&&!A.missing&&t&&!t.startsWith(`pending:`)&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-worktree-follow":!0,disabled:!!S||A.id===n,onClick:()=>void M(`follow`,A.id),children:A.id===n?`会话已跟随`:`会话跟随`})]}),(0,L.jsxs)(`details`,{className:`git-worktree-create`,children:[(0,L.jsx)(`summary`,{title:s?fi:void 0,children:`新建工作树`}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),M(`create`)},children:[(0,L.jsx)(Gi,{workspaceId:e,value:b,disabled:s||!!S,onChoose:x}),(0,L.jsx)(`input`,{disabled:s,title:s?fi:void 0,className:`git-view-search`,"aria-label":`工作树的新分支`,placeholder:`新分支(可选)`,value:v,onChange:e=>y(e.target.value),maxLength:180}),(0,L.jsx)(`button`,{type:`submit`,className:`git-group-action`,"data-git-worktree-create":!0,title:s?fi:void 0,disabled:s||!!S,children:S===`create`?`创建中…`:`创建工作树`})]})]}),w&&(0,L.jsx)(`p`,{className:`tool-error`,"data-git-worktree-error":!0,role:`alert`,children:w}),A?.missing&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`此工作树目录已丢失。`}),!s&&A&&!A.missing&&!N&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取工作树状态…`}),N?.error&&!A?.missing&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`alert`,children:N.error}),A&&!A.missing&&N?.value&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`git-worktree-summary`,"data-git-worktree-status":!0,children:[N.value.status.branch??`分离 HEAD`,A.current?` · 当前会话检出`:` · 仅查看`]}),ee.every(e=>!e.files.length)&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`无未提交改动。`}),ee.filter(e=>e.files.length).map(e=>(0,L.jsxs)(`div`,{className:`git-worktree-group`,children:[(0,L.jsxs)(`strong`,{children:[e.title,` · `,e.files.length]}),e.files.map(t=>te(t,{worktreeId:A.id,path:t.path,staged:e.key===`staged`}))]},e.key)),P&&!A.primary&&(0,L.jsxs)(`div`,{className:`git-worktree-group`,"data-git-worktree-comparison":!0,children:[(0,L.jsxs)(`strong`,{children:[`相对 `,P.base,` · ↑`,P.ahead,` ↓`,P.behind]}),P.files.map(e=>te(e,{worktreeId:A.id,path:e.path,staged:!1,comparison:`committed`})),(0,L.jsx)(zi,{commits:P.commits,workspaceId:e,cwd:``,worktreeId:A.id,onDiff:e=>a({...e,worktreeLabel:A.branch??A.name})},A.id),P.truncated&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`显示最近 20 条独有提交。`})]})]})]})]})}function qi({workspaceId:e,conversationId:t,cwd:n=``,followedWorktreeId:r,onOpenDiff:i,activeDiffUrl:a,onOpenConversation:o,sharedGit:s,repositoryOnly:c=!1}){let[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(null),m=s?s.status:l,h=s?s.error:f,g=s?.refresh,_=s?.publish,[v,y]=(0,u.useState)(()=>c||r?`worktrees`:`log`),b=(0,u.useRef)(null),[x,S]=(0,u.useState)(``),[C,w]=(0,u.useState)(()=>{try{let e=localStorage.getItem(`super-pi.git-panel.split.v1`),t=e===null?55:Number(e);return Number.isFinite(t)?Math.min(80,Math.max(20,t)):55}catch{return 55}}),T=e=>{let t=Math.round(Math.min(80,Math.max(20,e)));w(t);try{localStorage.setItem(`super-pi.git-panel.split.v1`,String(t))}catch{}},[E,D]=(0,u.useState)(),[O,k]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!O)return;let e=setTimeout(()=>k(``),2500);return()=>clearTimeout(e)},[O]);let A=e=>{e&&E?.anchor.origin.isConnected&&E.anchor.origin.focus({preventScroll:!0}),D(void 0)};(0,u.useEffect)(()=>{let t=t=>{let n=t.detail;n?.workspaceId===e&&[`branches`,`changes`,`worktrees`].includes(n.view)&&(n.view===`changes`?b.current?.focus({preventScroll:!0}):y(n.view))};return window.addEventListener(`super-pi-status-git-view`,t),()=>window.removeEventListener(`super-pi-status-git-view`,t)},[e]);let j=c&&pi(v)?`worktrees`:v,M=j===`changes`?`log`:j;(0,u.useEffect)(()=>{r&&y(`worktrees`)},[r]);let[N,P]=(0,u.useState)(``),[F,ee]=(0,u.useState)(0),[te,ne]=(0,u.useState)(0),[re,ie]=(0,u.useState)(),[ae,oe]=(0,u.useState)({}),[se,ce]=(0,u.useState)(``),[le,ue]=(0,u.useState)(null),[de,fe]=(0,u.useState)(``),[pe,me]=(0,u.useState)(``),[I,he]=(0,u.useState)(null),[ge,_e]=(0,u.useState)(null),ve=(0,u.useRef)(0),ye=(0,u.useCallback)(e=>{let t=++ve.current;p(null),me(``),ne(e=>e+1),g?g(!0):gi(bi(e,n)).then(e=>{t===ve.current&&d(e)}).catch(e=>{t===ve.current&&(d(null),p(_i(e)))})},[n,g]);(0,u.useEffect)(()=>{if(e)return ye(e),()=>{ve.current++}},[e,n,ye]);let be=e=>{c&&pi(e)||(e===`changes`?b.current?.focus({preventScroll:!0}):e!==M&&(y(e),P(``),ee(0)))},xe=ui.find(e=>e.id===M)??ui[0],Se=M===`log`||M===`branches`||M===`stash`,Ce=e&&m&&Se?`/api/git?workspaceId=${vi(e)}&op=${M}&limit=${Ci}${yi(n)}&q=${vi(N.trim())}&offset=${F}`:``;(0,u.useEffect)(()=>{if(!Ce)return;let e=!0;ie({url:Ce,result:Fi.get(Ce)});let t=window.setTimeout(()=>{gi(Ce).then(t=>{e&&(Ii(Fi,Ce,t,32),ie({url:Ce,result:t}),`branches`in t&&oe(e=>({...e,branches:t.total})),`stashes`in t&&oe(e=>({...e,stash:t.total})))}).catch(t=>{e&&ie({url:Ce,result:Fi.get(Ce),error:_i(t).message})})},N.trim()?180:0);return()=>{e=!1,window.clearTimeout(t)}},[Ce,N,te]);let we=(t,r,a,o=!1)=>{if(!e||c)return;let s=a?.comparison?`共同祖先 → 工作树 HEAD`:o?`未跟踪文件`:r?`HEAD → 暂存区`:`暂存区 → 工作区`,l=a?.comparison?`已提交`:o?`未跟踪`:r?`已暂存`:`未暂存`;i({url:a?Ai(e,`worktree-diff`,{worktreeId:a.worktreeId,path:t,staged:r?`1`:`0`,...a.comparison?{comparison:a.comparison}:{}}):xi(e,t,r,n),path:t,label:a?`${a.label} · ${l}`:l,comparison:a?`${a.label} · ${s}`:s})},Te=t=>{if(!e)return;let r=t.file.path,a=t.hash.slice(0,8);i({url:ji(e,t.worktreeId?``:n,t.hash,t.worktreeId,r),path:r,label:t.worktreeLabel?`${t.worktreeLabel} · ${a}`:a,comparison:`提交 ${a} · 对比${t.base}`,previousPath:t.file.previousPath,commitHash:t.hash})},Ee=(0,u.useCallback)(async(t,r={})=>{if(!e||I||c&&t!==`fetch`)return!1;he(t),me(``);try{if(t===`draft`)return ue(await Si(e,t,r,n)),!0;if(t===`discard-untracked`)return await gi(`/api/files/tree?workspaceId=${vi(e)}${yi(n)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`trash`,path:r.path.replace(/\/$/,``)})}),ye(e),!0;let i=await Si(e,t,r,n);return _?_(i):d(i),t!==`fetch`&&t!==`push`&&ue(null),(t===`stash-save`||t===`switch`)&&ee(0),ne(e=>e+1),!0}catch(n){let r=_i(n);return t===`stash-apply`&&ye(e),me(r.body?.error||r.message||`操作失败`),!1}finally{he(null)}},[e,n,_,I,ye,c]),De=(0,u.useCallback)(()=>{if(!ge)return;let e=ge;_e(null),Ee(e.untracked?`discard-untracked`:`discard`,{path:e.path})},[ge,Ee]),Oe=(0,u.useCallback)(()=>{_e(null)},[]),ke=m===null?null:Ei(m),Ae=x.trim().toLowerCase(),je=m===null?[]:Di.map(e=>({...e,entries:m[e.key].filter(e=>e.path.toLowerCase().includes(Ae))})),Me=m?new Set(Di.flatMap(e=>m[e.key].map(e=>e.path))).size:0,Ne=re?.url===Ce?re.result:void 0,Pe=re?.url===Ce?re.error:void 0,Fe=Ne&&`commits`in Ne?Ne:null,Ie=Ne&&`branches`in Ne?Ne:null,Le=Ne&&`stashes`in Ne?Ne:null,Re=M===`log`?Ci:50,ze=Ie??Le,Be=Fe?Fe.truncated:ze?F+Re<ze.matches:!1;return e?(0,L.jsxs)(`div`,{className:`git-panel`,"data-git-panel":`1`,"data-git-scope":c?`repository`:`checkout`,children:[c&&(0,L.jsxs)(`p`,{className:`git-scope-note`,role:`status`,children:[`仓库浏览 · `,fi]}),m===null&&h===null&&(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-loading":`1`,children:`读取 Git 状态…`}),h!==null&&(0,L.jsxs)(`div`,{className:`git-state-card${h.body.code===`not_a_repo`?` git-state-card-empty`:` git-error`}`,"data-git-error":`1`,role:`status`,"data-git-error-code":h.body.code??``,children:[(0,L.jsx)(`span`,{className:`git-state-icon`,"aria-hidden":`true`,children:h.body.code===`not_a_repo`?`⌁`:`!`}),(0,L.jsx)(`strong`,{children:h.body.code===`not_a_repo`?`此工作区不是 git 仓库`:`Git 状态暂时不可用`}),(0,L.jsx)(`p`,{children:h.body.code===`not_a_repo`?`当前工作区没有 Git 仓库,因此没有分支、变更或提交记录可显示。文件和对话功能仍可正常使用。`:`读取仓库状态时遇到问题,请稍后重试。`}),(0,L.jsx)(`button`,{type:`button`,className:`git-state-action`,onClick:()=>ye(e),children:`重新检查`})]}),m!==null&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`git-head`,"data-git-head":`1`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-branch`,"data-git-branch":`1`,title:c?`查看仓库分支`:Ti(m),"aria-label":c?`查看仓库分支`:`当前分支 ${Ti(m)},查看分支`,onClick:()=>be(`branches`),children:[(0,L.jsx)(Xr,{name:`git`}),(0,L.jsx)(`span`,{children:c?`仓库分支`:Ti(m)})]}),!c&&ke!==null&&(0,L.jsx)(`span`,{className:`git-ahead-behind`,"data-git-ahead-behind":`1`,children:ke}),(0,L.jsx)(`button`,{type:`button`,className:`git-refresh`,"data-git-refresh":`1`,title:`刷新 Git 状态`,"aria-label":`刷新 Git 状态`,onClick:()=>ye(e),children:(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`})})]}),pe&&(0,L.jsx)(`p`,{className:`tool-error`,"data-git-action-error":`1`,role:`alert`,children:pe}),O&&(0,L.jsx)(`p`,{className:`git-copy-notice`,role:`status`,children:O}),(0,L.jsxs)(`div`,{className:`git-sync-actions`,"aria-label":`远程操作`,children:[(0,L.jsx)(`button`,{type:`button`,"data-git-action":`fetch`,onClick:()=>void Ee(`fetch`),disabled:I!==null,title:`从上游获取远程引用`,children:I===`fetch`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`获取中…`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),` Fetch`]})}),(0,L.jsx)(`button`,{type:`button`,"data-git-action":`pull`,onClick:()=>void Ee(`pull`),disabled:c||I!==null,title:c?fi:void 0,children:I===`pull`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`拉取中…`]}):`拉取`}),(0,L.jsx)(`button`,{type:`button`,"data-git-action":`push`,onClick:()=>void Ee(`push`),disabled:c||I!==null,title:c?fi:void 0,children:I===`push`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`推送中…`]}):`推送`})]}),(0,L.jsxs)(`div`,{className:`git-pane-stack`,"data-git-pane-stack":!0,style:{gridTemplateRows:`minmax(0, ${C}fr) 6px minmax(0, ${100-C}fr)`},children:[(0,L.jsxs)(`section`,{className:`git-changes-pane`,"data-git-changes-pane":!0,ref:b,tabIndex:-1,"aria-label":`工作区改动`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-pane-title`,"data-git-view":`changes`,"aria-pressed":!c,disabled:c,title:c?fi:void 0,onClick:()=>be(`changes`),children:[(0,L.jsx)(Xr,{name:`main`}),(0,L.jsx)(`span`,{children:`工作区改动`}),!c&&(0,L.jsx)(`span`,{className:`git-view-count`,children:Me})]}),c?(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:fi}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`section`,{className:`git-scm-actions`,"data-git-actions":`1`,"aria-label":`提交已暂存的更改`,children:[(0,L.jsxs)(`form`,{className:`git-commit-input`,onSubmit:async e=>{e.preventDefault(),await Ee(`commit`,{message:se})&&ce(``)},children:[(0,L.jsx)(`input`,{value:se,onChange:e=>ce(e.target.value),placeholder:`提交说明…`,"aria-label":`提交消息`,disabled:I!==null}),(0,L.jsx)(`button`,{type:`submit`,className:`git-commit-submit`,"data-git-action":`commit`,disabled:!m.staged.length||!se.trim()||I!==null,children:I===`commit`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`提交中…`]}):`提交`})]}),(0,L.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,L.jsx)(`span`,{children:`仅提交已暂存内容`}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`draft`,"aria-label":`用 AI 根据当前目录的暂存差异生成提交信息`,title:`用 AI 根据当前目录的暂存差异生成提交信息`,disabled:!m.staged.length||I!==null,onClick:()=>void Ee(`draft`),children:I===`draft`?`生成中…`:`✧ AI 生成`})]}),le&&(0,L.jsxs)(`div`,{className:`git-draft`,"data-git-draft":!0,children:[(0,L.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,L.jsx)(`strong`,{children:le.truncated?`提交说明建议 · 差异已截断`:`提交说明建议`}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"aria-label":`关闭提交说明建议`,onClick:()=>ue(null),children:`×`})]}),(0,L.jsx)(`p`,{children:le.message}),(0,L.jsx)(`button`,{type:`button`,"data-git-draft-apply":!0,onClick:()=>{ce(le.message.replace(/\s*\n\s*/g,` `)),ue(null)},children:`替换输入`})]})]}),(0,L.jsx)(`input`,{className:`git-view-search`,type:`search`,"aria-label":`搜索文件名或路径`,placeholder:`搜索文件名或路径`,value:x,onChange:e=>S(e.target.value),maxLength:160}),je.map(t=>(0,L.jsxs)(`div`,{className:`git-group`,"data-git-group":t.key,children:[(0,L.jsxs)(`div`,{className:`git-group-head`,"data-git-group-head":t.key,children:[(0,L.jsx)(`span`,{className:`git-group-title`,children:t.title}),(0,L.jsx)(`span`,{className:`git-group-count`,"data-git-count":t.key,children:t.entries.length}),!Ae&&t.key===`staged`&&t.entries.length>0&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`unstage-all`,disabled:I!==null,onClick:()=>void Ee(`unstage-all`),children:`全部取消暂存`}),!Ae&&t.key===`unstaged`&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`stage-all`,disabled:I!==null||!m.unstaged.length&&!m.untracked.length,onClick:()=>void Ee(`stage-all`),children:`全部暂存`})]}),(0,L.jsx)(`div`,{className:`git-group-body`,children:t.entries.length===0?(0,L.jsx)(`p`,{className:`git-group-empty`,"data-git-empty":t.key,children:Ae?`无匹配文件。`:`无${t.title}变更。`}):t.entries.map(r=>{let i=si(r.xy,t.key),o=li(r),s=a===xi(e,r.path,t.key===`staged`,n);return(0,L.jsxs)(`div`,{className:`git-file-row${s?` is-active`:``}`,onContextMenu:e=>{e.preventDefault();let n=e.currentTarget.querySelector(`[data-git-file]`);D({entry:r,group:t.key,anchor:{x:e.clientX,y:e.clientY,origin:n,initialFocus:!0}})},onKeyDown:e=>{(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`)&&(e.preventDefault(),D({entry:r,group:t.key,anchor:ni(e.currentTarget.querySelector(`[data-git-file]`))}))},children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-file-open`,"data-git-file":r.path,"data-git-kind":o?`dir`:`file`,title:r.path,onClick:()=>we(r.path,t.key===`staged`,void 0,t.key===`untracked`),children:[(0,L.jsx)(Br,{path:r.path,category:o?`folder`:void 0,size:15}),(0,L.jsx)(`span`,{className:`git-path`,children:o?`${r.name}/`:r.name}),r.path.includes(`/`)&&!o&&(0,L.jsx)(`span`,{className:`git-parent-path`,children:r.path.slice(0,r.path.lastIndexOf(`/`))})]}),(0,L.jsxs)(`span`,{className:`git-file-actions`,children:[t.key===`staged`?(0,L.jsx)(`button`,{type:`button`,title:`取消暂存`,disabled:I!==null,onClick:e=>{e.stopPropagation(),Ee(`unstage`,{path:r.path})},children:`−`}):(0,L.jsx)(`button`,{type:`button`,title:`暂存`,disabled:I!==null,onClick:e=>{e.stopPropagation(),Ee(`stage`,{path:r.path})},children:`+`}),t.key!==`staged`&&(0,L.jsx)(`button`,{type:`button`,className:`git-file-action`,"data-git-action":`discard`,title:`丢弃 ${r.path} 的更改`,"aria-label":`丢弃更改 ${r.path}`,disabled:ge!==null||I!==null,onClick:e=>{e.stopPropagation(),_e({path:r.path,untracked:t.key===`untracked`})},children:`↶`}),(0,L.jsx)(`button`,{type:`button`,title:`更多文件操作`,"aria-label":`更多文件操作 ${r.path}`,"data-git-file-menu":r.path,"aria-haspopup":`menu`,onClick:e=>D({entry:r,group:t.key,anchor:ni(e.currentTarget)}),children:(0,L.jsx)(ti,{name:`more`})})]}),(0,L.jsx)(`span`,{className:`git-badge git-badge-${i.kind} git-badge-slot-${i.slot}`,role:`img`,title:ci[i.kind],"aria-label":ci[i.kind],"data-git-badge":i.kind,"data-git-badge-slot":i.slot,children:i.label})]},r.path)})})]},t.key))]})]}),(0,L.jsx)(`div`,{className:`git-pane-divider`,"data-git-pane-divider":!0,role:`separator`,"aria-label":`调整 Git 上下区域高度`,"aria-orientation":`horizontal`,"aria-valuenow":C,"aria-valuemin":20,"aria-valuemax":80,tabIndex:0,onPointerDown:e=>{e.button===0&&(e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{if(!e.currentTarget.hasPointerCapture(e.pointerId))return;let t=e.currentTarget.parentElement.getBoundingClientRect();T((e.clientY-t.top)/t.height*100)},onPointerUp:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onDoubleClick:()=>T(55),onKeyDown:e=>{if(e.key===`ArrowUp`)T(C-5);else if(e.key===`ArrowDown`)T(C+5);else if(e.key===`Home`)T(20);else if(e.key===`End`)T(80);else return;e.preventDefault()}}),(0,L.jsxs)(`section`,{className:`git-secondary-pane`,"data-git-secondary-pane":!0,"aria-label":`Git 仓库功能`,children:[(0,L.jsxs)(`nav`,{className:`git-view-nav`,"aria-label":`源代码管理视图`,children:[(0,L.jsxs)(`span`,{className:`git-secondary-title`,children:[xe.title,(M===`branches`||M===`stash`)&&ae[M]!==void 0&&(0,L.jsx)(`small`,{children:ae[M]})]}),ui.filter(e=>e.id!==`changes`).map(e=>{let t=c&&pi(e.id),n=t?void 0:e.id===`branches`||e.id===`stash`?ae[e.id]:void 0;return(0,L.jsxs)(`button`,{type:`button`,disabled:t,title:t?fi:di[e.id]??e.title,"aria-label":e.title,"data-git-view":e.id,"aria-pressed":e.id===M,onClick:()=>be(e.id),children:[(0,L.jsx)(Xr,{name:e.icon}),(0,L.jsx)(`span`,{className:`git-view-label`,children:e.title}),n!==void 0&&(0,L.jsx)(`span`,{className:`git-view-count`,children:n})]},e.id)})]}),xe.search&&(0,L.jsx)(`input`,{className:`git-view-search`,type:`search`,"aria-label":xe.search,placeholder:xe.search,value:N,maxLength:160,onChange:e=>{P(e.target.value),ee(0)}}),M===`worktrees`&&(0,L.jsx)(Ki,{repositoryOnly:c,workspaceId:e,conversationId:t,followedWorktreeId:r,revision:te,onOpenConversation:o,onDiff:e=>we(e.path,e.staged,e),onCommitDiff:Te}),M===`graph`&&m&&(0,L.jsx)(Wi,{workspaceId:e,cwd:n,revision:te,onDiff:Te}),Se&&!Ne&&!Pe&&(0,L.jsxs)(`p`,{className:`rail-empty`,"data-git-log-loading":M===`log`?`1`:void 0,role:`status`,children:[`读取`,xe.title,`…`]}),Se&&Pe&&(0,L.jsxs)(`div`,{className:`git-page-error`,"data-git-log-error":M===`log`?`1`:void 0,children:[(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,title:Pr(Pe),children:Nr(Pe,`读取 Git 列表失败。`)}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,onClick:()=>ne(e=>e+1),children:`重试`})]}),M===`log`&&Fe&&(0,L.jsx)(`div`,{className:`git-log`,"data-git-log":`1`,children:Fe.commits.length===0?(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-log-empty":`1`,children:N.trim()?`没有匹配的提交。`:`暂无提交记录。`}):(0,L.jsx)(zi,{commits:Fe.commits,workspaceId:e,cwd:n,onDiff:Te})}),M===`branches`&&Ie&&(0,L.jsxs)(`div`,{className:`git-index-list`,"data-git-branches":!0,children:[!Ie.canWrite&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`切换分支会改变整个工作树,请在仓库根目录操作。`}),Ie.branches.length===0&&(0,L.jsx)(`p`,{className:`rail-empty`,children:N.trim()?`没有匹配的分支。`:`暂无分支。`}),Ie.branches.map(e=>(0,L.jsxs)(`div`,{className:`git-index-row`,"data-git-ref":e.name,children:[(0,L.jsx)(`span`,{className:`git-index-name`,title:e.name,children:e.name}),e.current?!c&&(0,L.jsx)(`span`,{className:`git-index-current`,children:`当前`}):e.local?Ie.canWrite&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`switch`,"aria-label":`切换到 ${e.name}`,disabled:c||I!==null,title:c?fi:void 0,onClick:()=>void Ee(`switch`,{target:e.name}),children:`切换`}):(0,L.jsx)(`span`,{className:`git-index-meta`,children:`远程`})]},`${e.local}:${e.name}`))]}),M===`stash`&&Le&&(0,L.jsxs)(`div`,{className:`git-index-list`,"data-git-stashes":!0,children:[Le.canWrite?(0,L.jsxs)(`form`,{className:`git-stash-form`,onSubmit:async e=>{e.preventDefault(),await Ee(`stash-save`,{message:de})&&fe(``)},children:[(0,L.jsxs)(`div`,{className:`git-commit-input`,children:[(0,L.jsx)(`input`,{className:`git-view-search`,value:de,onChange:e=>fe(e.target.value),maxLength:200,"aria-label":`贮藏说明`,placeholder:`贮藏说明(可选)`}),(0,L.jsx)(`button`,{type:`submit`,className:`git-group-action`,"data-git-action":`stash-save`,disabled:!Me||I!==null,children:`贮藏改动`})]}),(0,L.jsx)(`p`,{className:`git-scope-note`,children:`保存整个工作树的改动,包括未跟踪文件。`})]}):(0,L.jsx)(`p`,{className:`git-scope-note`,children:`贮藏影响整个工作树,请在仓库根目录操作。`}),Le.stashes.length===0&&(0,L.jsx)(`p`,{className:`rail-empty`,children:N.trim()?`没有匹配的贮藏。`:`暂无贮藏记录。`}),Le.stashes.map(e=>(0,L.jsxs)(`div`,{className:`git-index-row`,"data-git-stash":e.hash,children:[(0,L.jsxs)(`div`,{className:`git-index-name`,title:e.subject,children:[e.subject,(0,L.jsxs)(`small`,{className:`git-index-meta`,children:[e.ref,` · `,wi(e.date)]})]}),Le.canWrite&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`stash-apply`,"aria-label":`恢复 ${e.ref}`,title:`恢复改动并保留贮藏记录`,disabled:I!==null,onClick:()=>void Ee(`stash-apply`,{target:e.hash}),children:`恢复`})]},`${e.ref}:${e.hash}`))]}),Ne&&(F>0||Be)&&(0,L.jsxs)(`div`,{className:`git-pages`,children:[(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,disabled:!F,onClick:()=>ee(Math.max(0,F-Re)),children:`上一页`}),(0,L.jsxs)(`span`,{children:[`第 `,F/Re+1,` 页`,ze?` · ${ze.matches} 项`:``]}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-log-truncated":Fe?.truncated?`1`:void 0,disabled:!Be,onClick:()=>ee(F+Re),children:`下一页`})]})]})]}),ge!==null&&(0,L.jsx)(Oi,{path:ge.path,untracked:ge.untracked,onCancel:Oe,onConfirm:De}),E&&(0,L.jsxs)(ri,{label:E.entry.path,anchor:E.anchor,close:A,children:[(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`file-context-item`,"data-git-menu-action":`diff`,disabled:li(E.entry),onClick:()=>{we(E.entry.path,E.group===`staged`,void 0,E.group===`untracked`),A(!0)},children:[(0,L.jsx)(ti,{name:`file`}),(0,L.jsx)(`span`,{children:`查看差异`})]}),(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`file-context-item`,"data-git-menu-action":`stage`,disabled:I!==null,onClick:()=>{Ee(E.group===`staged`?`unstage`:`stage`,{path:E.entry.path}),A(!0)},children:[(0,L.jsx)(ti,{name:`reference`}),(0,L.jsx)(`span`,{children:E.group===`staged`?`取消暂存`:`暂存更改`})]}),E.group!==`staged`&&(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`file-context-item`,"data-git-menu-action":`discard`,disabled:I!==null,onClick:()=>{_e({path:E.entry.path,untracked:E.group===`untracked`}),A(!1)},children:[(0,L.jsx)(ti,{name:`trash`}),(0,L.jsx)(`span`,{children:E.group===`untracked`?`放弃更改(移到回收站)`:`放弃未暂存更改`})]}),(0,L.jsx)(`div`,{role:`separator`}),[[`relative`,`复制相对路径`,[n,E.entry.path].filter(Boolean).join(`/`)],[`name`,`复制文件名`,E.entry.name]].map(([e,t,n])=>(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`file-context-item`,"data-git-menu-action":e,onClick:()=>{A(!0),ai(n).then(e=>{e?k(`已${t}`):me(`复制失败,请重试。`)})},children:[(0,L.jsx)(ti,{name:`copy`}),(0,L.jsx)(`span`,{children:t})]},e))]})]})]}):(0,L.jsx)(`div`,{className:`git-panel`,"data-git-panel":`1`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-empty":`noworkspace`,children:`请选择一个工作区查看 Git 状态。`})})}var Ji=e=>e?.phase===`waiting`||e?.phase===`installing`||e?.phase===`restarting`;async function Yi(e,t={},n=f){let r=await je(e,{...t,cache:`no-store`,signal:t.signal??AbortSignal.timeout(12e3)},n),i=await r.json().catch(()=>null);if(!i||!r.ok&&!(r.status===409&&i.operation))throw Error(i?.error??`更新服务未返回有效状态(HTTP ${r.status})`);return i}async function Xi(e,t){let n;for(let r=0;r<2;r++)try{let n=AbortSignal.any([e,AbortSignal.timeout(8e3)]),r=await je(`/api/update-status`,{cache:`no-store`,signal:n},t);if(r.status===404||r.ok&&r.headers.get(`content-type`)?.includes(`text/html`))return{...await Yi(`/api/health`,{signal:n},t),operation:null};let i=await r.json();if(!r.ok)throw Error(i?.error??`无法读取更新状态(HTTP ${r.status})`);return i}catch(t){if(n=t,e.aborted||r===1)break;await new Promise(e=>setTimeout(e,400))}throw n}var Zi=e=>e===`entry`?`super-pi.update-legacy-receipt`:`super-pi.update-legacy-receipt:${e}`;function Qi(e,t){try{if(t!==void 0)return t?sessionStorage.setItem(Zi(e),JSON.stringify(t)):sessionStorage.removeItem(Zi(e)),t;let n=JSON.parse(sessionStorage.getItem(Zi(e))??`null`);return n?.id&&Date.now()-Date.parse(n.startedAt)<18e5?n:null}catch{return t??null}}var $i=e=>e?`v${e}`:`—`,ea=`super-pi.update-check-hours`,ta=`super-pi.update-check-times`;function na(){try{let e=Number(localStorage.getItem(ea)??6);return[1,3,6,12,24].includes(e)?e:6}catch{return 6}}var ra=e=>!(!e.managed||e.legacy),ia=(e,t)=>ra(e)&&!!t&&!t.serviceSelfUpdate;function aa(e,t){let n=e.split(/[+-]/)[0].split(`.`).map(Number),r=t.split(/[+-]/)[0].split(`.`).map(Number);if(n.length!==3||r.length!==3||[...n,...r].some(e=>!Number.isFinite(e)))return!1;for(let e=0;e<3;e++)if(n[e]!==r[e])return n[e]>r[e];return t.includes(`-`)&&!e.includes(`-`)}var oa=e=>e?.status?.needsRestart?`restart`:e?.latest&&e.status&&aa(e.latest,e.status.diskVersion)?`update`:void 0;function sa(e){return e?.submitting?`starting`:e?.checking?`checking`:Ji(e?.status?.operation)?e.status.operation.phase:e?.status?.needsRestart?`needs-restart`:e?.status?.operation?.phase===`failed`||e?.error?`failed`:e?.status?.operation?.phase===`completed`&&e.observedOperationId===e.status.operation.id&&!oa(e)?`completed`:`idle`}function ca(e,t=!1){if(e?.backgroundChecking&&!e.latest)return`正在检查可用版本`;let n=sa(e);return n===`starting`?`正在提交更新`:n===`checking`?`正在检查可用版本`:n===`waiting`?`等待选中的托管服务更新结束,再更新本地入口`:n===`installing`?`正在下载并安装更新`:n===`restarting`?t?`正在自动退出并重新启动 Super Pi 桌面和本地服务`:e?.connectionLost?`等待服务重新上线`:`正在重启服务`:n===`needs-restart`?`${$i(e?.status?.diskVersion)} 已安装,等待重启`:n===`failed`?e?.error??e?.status?.operation?.failure?.message??`更新失败`:n===`completed`?`更新完成`:oa(e)?`有新版本可安装`:e?.latest?`当前已是最新版本`:`等待检查更新`}function la(e){let{connections:t,activeServer:n}=ce(),[r,i]=(0,u.useState)({}),a=(0,u.useRef)(r);a.current=r;let[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(()=>new Set),[d,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(!1),b=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>clearTimeout(b.current),[]),(0,u.useEffect)(()=>{let e=window.superPiDesktop;if(!e)return;let t=!1,n=()=>{e.status().then(e=>{t||h(e)}).catch(()=>{})};n();let r=setInterval(n,2e3);return()=>{t=!0,clearInterval(r)}},[]);let x=async()=>{if(!v&&window.superPiDesktop?.restart){y(!0),_(``),b.current=window.setTimeout(()=>{y(!1),_(`桌面端尚未退出,可以重试。当前窗口与本地服务状态分别保留。`)},12e3);try{await window.superPiDesktop.restart()}catch(e){clearTimeout(b.current),y(!1),_(e instanceof Error?e.message:`无法接管桌面重启,请重试。`)}}},[S,C]=(0,u.useState)(na),w=(0,u.useRef)({}),T=(0,u.useRef)({}),E=(0,u.useRef)({});(0,u.useEffect)(()=>{try{w.current=JSON.parse(localStorage.getItem(ta)??`{}`),T.current=JSON.parse(localStorage.getItem(`super-pi.update-known-versions`)??`{}`)}catch{w.current={},T.current={}}},[]);let D=(0,u.useRef)(null),O=(0,u.useId)(),k=(0,u.useRef)(new Map),A=(0,u.useRef)(new Set),j=(0,u.useRef)(!1),M=(0,u.useRef)(new Map),N=(e,t)=>{let n=a.current[e],r={...n??{},...t};r.status?.operation&&(Ji(r.status.operation)||n?.submitting&&t.status)&&(r.observedOperationId=r.status.operation.id),a.current={...a.current,[e]:r},i(t=>JSON.stringify(t[e])===JSON.stringify(r)?t:{...t,[e]:r})},P=e=>{let t=(k.current.get(e)??0)+1;return k.current.set(e,t),t},F=JSON.stringify(t.map(({id:e,url:t,enabled:n,revision:r})=>[e,t,n,r]));(0,u.useEffect)(()=>{let e=new AbortController,n,r=async()=>{if(t.some(ra))try{let t=await Yi(`/api/managed-servers`,{signal:e.signal});M.current=new Map((t.profiles??[]).map(e=>[e.id,e]))}catch{}await Promise.allSettled(t.filter(e=>e.enabled).map(async t=>{if(A.current.has(t.id))return;let n=k.current.get(t.id);try{let r=await Xi(e.signal,t.id);if(e.signal.aborted||n!==k.current.get(t.id))return;let i=t.managedId&&M.current.get(t.managedId);if(ia(t,r)&&i&&i.updateOperation&&(r.operation=i.updateOperation),r.operation)Qi(t.id,null);else{let e=Qi(t.id);e&&(N(t.id,{observedOperationId:e.id}),r.operation=e.targetVersion===r.runningVersion&&!r.needsRestart?Qi(t.id,{...e,phase:`completed`,changedAt:new Date().toISOString()}):Date.now()-Date.parse(e.changedAt)>15e4&&e.phase===`restarting`?Qi(t.id,{...e,phase:`failed`,changedAt:new Date().toISOString(),failure:{step:`restarting`,message:`服务尚未恢复,请检查所选服务的运行状态后重试。`}}):e)}N(t.id,{status:r,latest:a.current[t.id]?.latest??T.current[t.url],connectionLost:!1})}catch{!e.signal.aborted&&n===k.current.get(t.id)&&N(t.id,{connectionLost:!0})}})),e.signal.aborted||(n=window.setTimeout(r,o||Object.values(a.current).some(e=>Ji(e.status?.operation))?1600:5e3))};return r(),()=>{e.abort(),clearTimeout(n)}},[F,o]);async function ee(e,t=!1){if(A.current.has(e.id)||Ji(a.current[e.id]?.status?.operation))return;if(!e.enabled){N(e.id,{error:`连接已停用,请先连接此服务端再更新。`,latest:void 0});return}A.current.add(e.id);let n=P(e.id);t?N(e.id,{backgroundChecking:!0}):N(e.id,{checking:!0,error:void 0,observedOperationId:void 0});try{let t=await Yi(`/api/update-check`,{signal:AbortSignal.timeout(7e4)},e.id);if(k.current.get(e.id)!==n)return;let r=e.managedId&&M.current.get(e.managedId);ia(e,t)&&r&&r.updateOperation&&(t.operation=r.updateOperation),N(e.id,{status:t,latest:t.latestVersion,connectionLost:!1,error:void 0}),w.current[e.url]=Date.now(),t.latestVersion&&(T.current[e.url]=t.latestVersion);try{localStorage.setItem(ta,JSON.stringify(w.current)),localStorage.setItem(`super-pi.update-known-versions`,JSON.stringify(T.current))}catch{}}catch(r){!t&&k.current.get(e.id)===n&&N(e.id,{error:r instanceof Error?r.message:`检查更新失败。`,latest:void 0})}finally{A.current.delete(e.id),N(e.id,{checking:!1,backgroundChecking:!1})}}let te=(0,u.useRef)(ee);te.current=ee,(0,u.useEffect)(()=>{let e=!1,n=async()=>{for(let n of t){if(e||!n.enabled)continue;let t=Number(w.current[n.url]??0);Date.now()-t<S*36e5||Date.now()-(E.current[n.id]??0)<3e5||(E.current[n.id]=Date.now(),await te.current(n,!0))}};n();let r=window.setInterval(()=>void n(),6e4),i=()=>{document.visibilityState===`visible`&&n()};return document.addEventListener(`visibilitychange`,i),()=>{e=!0,clearInterval(r),document.removeEventListener(`visibilitychange`,i)}},[F,S]);async function ne(){await Promise.allSettled(t.filter(e=>!c.has(e.id)).map(e=>ee(e)))}function re(e,t){for(let n of t){let t=e.profiles?.find(e=>e.id===n.managedId),r=a.current[n.id]?.status;N(n.id,{error:e.errors?.[n.managedId],status:t?.updateOperation&&r?{...r,operation:t.updateOperation}:r,submitting:!1})}}async function ie(e,t){let n=a.current[e.id],r=oa(n);if(r&&n.status&&!A.current.has(e.id)&&!Ji(n.status.operation)){A.current.add(e.id),P(e.id),N(e.id,{submitting:!0,error:void 0});try{let i=r===`restart`?{restartOnly:!0}:{version:n.latest},a=await Yi(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...i,...t?.length?{managedUpdates:t}:{}})},e.id),o={...n.status,...a,operation:a.operation??null};if(!o.operation){let t=new Date().toISOString();o.operation=Qi(e.id,{id:t,action:r,phase:r===`restart`?`restarting`:`installing`,fromVersion:n.status.runningVersion,targetVersion:r===`restart`?n.status.diskVersion:n.latest,startedAt:t,changedAt:t})}return N(e.id,{status:o,connectionLost:!1}),o.managedResult}catch(t){N(e.id,{error:t instanceof Error?t.message:`无法确认更新请求是否送达,请检查状态。`})}finally{A.current.delete(e.id),N(e.id,{submitting:!1})}}}async function ae(){if(j.current)return;j.current=!0,p(!0);let e=t.filter(e=>!c.has(e.id));try{await Promise.allSettled(e.filter(e=>!a.current[e.id]?.latest&&!a.current[e.id]?.status?.needsRestart).map(e=>ee(e)));let t=e.filter(e=>e.enabled&&!a.current[e.id]?.error&&oa(a.current[e.id])),n=t.filter(e=>ia(e,a.current[e.id]?.status)),r=t.find(e=>e.id===f),i=n.map(e=>({id:e.managedId,version:a.current[e.id].status?.needsRestart?a.current[e.id].status.diskVersion:a.current[e.id].latest}));if(await Promise.allSettled(t.filter(e=>e.id!==`entry`&&!n.includes(e)).map(e=>ie(e))),r){for(let e of n)N(e.id,{submitting:!0,error:void 0});if(re({errors:(await ie(r,i))?.errors},n),a.current[r.id]?.error)for(let e of n)N(e.id,{error:`本地入口未受理托管更新,请检查本地状态后重试。`})}else if(i.length){for(let e of n)N(e.id,{submitting:!0,error:void 0});try{re(await Yi(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`updateSelected`,updates:i})}),n)}catch(e){for(let t of n)N(t.id,{error:e instanceof Error?e.message:`无法启动托管更新`,submitting:!1})}}}finally{j.current=!1,p(!1)}}let oe=t.map(e=>sa(r[e.id])),se=t.filter(e=>e.enabled&&oa(r[e.id])),le=d||oe.some(e=>[`starting`,`waiting`,`installing`,`restarting`,`checking`].includes(e)),ue=d?`starting`:oe.find(e=>[`waiting`,`installing`,`restarting`,`checking`].includes(e))??(oe.includes(`needs-restart`)?`needs-restart`:oe.includes(`failed`)?`failed`:oe.includes(`completed`)?`completed`:`idle`),de=t.filter(e=>!c.has(e.id)),fe=de.some(e=>oa(r[e.id])),pe=de.some(e=>oa(r[e.id])===`restart`)&&!de.some(e=>oa(r[e.id])===`update`);return{entry:e=>(0,L.jsxs)(`button`,{type:`button`,className:`software-update-entry ${e}`,"data-software-update-entry":ue,"aria-haspopup":`dialog`,"aria-expanded":o,title:`软件更新`,"aria-label":`软件更新`,onClick:e=>{D.current=e.currentTarget,s(e=>!e),ne()},children:[(0,L.jsx)(Xr,{name:`update`}),(0,L.jsx)(`span`,{children:!le&&se.length?`有可用更新`:`软件更新`}),!le&&se.length>0&&(0,L.jsx)(`small`,{"data-update-available":!0,children:se.length===1?$i(r[se[0].id]?.latest??r[se[0].id]?.status?.diskVersion):`${se.length} 个服务`}),le&&(0,L.jsx)(`small`,{children:`进行中`}),!le&&ue===`needs-restart`&&(0,L.jsx)(`small`,{children:`待重启`})]}),panel:o?(0,L.jsx)(ze,{anchor:D.current,label:`软件更新`,className:`software-update-dialog software-update-multi`,onClose:()=>s(!1),children:(0,L.jsxs)(`div`,{className:`software-update-content`,children:[(0,L.jsxs)(`div`,{className:`software-update-header`,children:[(0,L.jsxs)(`h2`,{id:O,children:[(0,L.jsx)(Xr,{name:`update`}),`软件更新`]}),(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"aria-label":`关闭软件更新`,onClick:()=>s(!1),children:(0,L.jsx)(Xr,{name:`close`})})]}),(0,L.jsxs)(`label`,{className:`software-update-note`,children:[`自动检查更新 `,(0,L.jsx)(`select`,{"data-update-check-hours":!0,"aria-label":`自动检查更新间隔`,value:S,onChange:e=>{let t=Number(e.target.value);C(t),localStorage.setItem(ea,String(t))},children:[1,3,6,12,24].map(e=>(0,L.jsxs)(`option`,{value:e,children:[`每 `,e,` 小时`]},e))})]}),(0,L.jsxs)(`div`,{className:`software-update-selection`,children:[(0,L.jsxs)(`span`,{children:[`已选择 `,de.length,` / `,t.length,` 个服务端`]}),(0,L.jsx)(`button`,{type:`button`,disabled:le,onClick:()=>l(new Set),children:`全选`}),(0,L.jsx)(`button`,{type:`button`,disabled:le,onClick:()=>l(new Set(t.map(e=>e.id))),children:`全不选`})]}),(0,L.jsx)(`div`,{className:`software-update-targets`,children:t.map(e=>{let t=r[e.id],n=sa(t),i=t?.status?.operation;return(0,L.jsxs)(`section`,{className:`software-update-target`,"data-update-target":e.id,children:[(0,L.jsxs)(`label`,{className:`software-update-target-label`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:!c.has(e.id),disabled:le,onChange:t=>{let n=t.target.checked;l(t=>{let r=new Set(t);return n?r.delete(e.id):r.add(e.id),r})}}),(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`small`,{children:e.id===`entry`?`本地入口`:ra(e)?`SSH 托管服务`:e.managed?`SSH 原有服务`:`远端服务`})]}),ra(e)&&t?.status&&(0,L.jsx)(`p`,{className:`software-update-note`,children:ia(e,t.status)?`此旧版需要通过已配置的 SSH 连接迁移一次,之后可通过服务端口更新。`:`通过服务端口更新,由该服务器下载并安装纯服务包。`}),(0,L.jsxs)(`dl`,{className:`software-update-versions`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`运行版本`}),(0,L.jsx)(`dd`,{"data-update-version":`running`,children:$i(t?.status?.runningVersion)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`已安装`}),(0,L.jsx)(`dd`,{"data-update-version":`disk`,children:$i(t?.status?.diskVersion)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`目标版本`}),(0,L.jsx)(`dd`,{"data-update-version":`target`,children:$i(Ji(i)?i?.targetVersion:t?.latest??t?.status?.diskVersion)})]})]}),(0,L.jsxs)(`div`,{className:`software-update-progress`,"data-update-progress":n,children:[(0,L.jsx)(`div`,{className:`software-update-summary`,role:`status`,children:ca(t,e.id===`entry`&&!!m)}),[`starting`,`checking`,`waiting`,`installing`,`restarting`].includes(n)&&(0,L.jsx)(`progress`,{"aria-label":ca(t,e.id===`entry`&&!!m)}),t?.connectionLost&&(0,L.jsx)(`small`,{children:`服务连接暂时中断,正在自动重试。`}),!e.enabled&&(0,L.jsx)(`small`,{children:`此连接已停用,需连接后才能更新。`}),t?.error&&(0,L.jsx)(`p`,{role:`alert`,children:t.error}),i?.phase===`failed`&&(0,L.jsx)(`p`,{role:`alert`,children:i.failure?.message})]}),e.id===`entry`&&m&&(0,L.jsxs)(`p`,{className:`software-update-note`,children:[`桌面运行版本:`,$i(m.desktopVersion),m.needsDesktopRestart?` · 桌面端待重启`:m.desktopVersion?` · 服务更新完成后会自动重新打开桌面端`:` · 旧桌面外壳,本次更新后请从托盘退出并重新打开一次,之后支持自动重启`]})]},e.id)})}),(0,L.jsx)(`p`,{className:`software-update-note`,children:`远端先更新,本地入口最后重启。重启可能中断对应服务正在运行的任务和终端。`}),(g||m?.restartError)&&(0,L.jsx)(`p`,{role:`alert`,children:g||m?.restartError}),(0,L.jsxs)(`div`,{className:`software-update-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`software-update-secondary`,"data-update-check":!0,disabled:le||!de.length,onClick:()=>void ne(),children:`检查更新`}),window.superPiDesktop?.restart&&(m?.needsDesktopRestart||m?.restartError||sa(r.entry)===`restarting`)&&(0,L.jsx)(`button`,{type:`button`,"data-update-desktop-restart":!0,disabled:v,onClick:()=>void x(),children:v?`正在重启桌面端…`:`重新启动桌面端`}),(0,L.jsxs)(`button`,{type:`button`,className:`software-update-primary`,"data-update-install":pe?void 0:`1`,"data-update-restart":pe?`1`:void 0,disabled:le||!de.length||!fe,onClick:()=>void ae(),children:[(0,L.jsx)(Xr,{name:pe?`restart`:`update`}),pe?`重启所选服务`:`更新并重启所选服务`]})]})]})}):null,status:r[n]?.status,open:e=>{D.current=e?.currentTarget??null,s(!0),ne()}}}function ua(e){let t=0;return e.map(e=>e.key.startsWith(`m:`)?(t=Math.max(t,Number.isFinite(e.at)?e.at:0),{...e,at:t}):e).sort((e,t)=>e.at-t.at||e.seq-t.seq).map(e=>e.key)}var da=new Set,fa=new Map,pa=new Map,ma=!1;function ha(){return typeof window<`u`&&window.superPiDesktop?.notifications?`native`:typeof window>`u`||!(`Notification`in window)?`unsupported`:window.isSecureContext?Notification.permission:`insecure`}async function ga(){return window.superPiDesktop?.notifications?(await window.superPiDesktop.notifications.status()).supported?`native`:`unsupported`:`Notification`in window?Notification.requestPermission():`denied`}function _a(e,t){let n=window.superPiDesktop?.notifications;if(!n)return new Notification(e,{...t,icon:new URL(`/favicon.png`,location.origin).href});ma||(ma=!0,n.onClick(e=>pa.get(e)?.onclick?.()));let r={close:()=>{pa.delete(t.tag),n.close(t.tag),r.onclose?.()}};return pa.get(t.tag)?.close(),pa.set(t.tag,r),pa.size>64&&pa.values().next().value?.close(),r.ready=n.show({id:t.tag,title:e.slice(0,160),body:t.body.slice(0,1e3)}),r.ready.catch(()=>{pa.get(t.tag)===r&&pa.delete(t.tag)}),r}function va(e,t,n,r,i){if(!da.has(e)){da.add(e);try{let t=`super-pi.notification.${e}`;if(localStorage.getItem(t))return;localStorage.setItem(t,`shown`)}catch{}if(!r&&[`granted`,`native`].includes(ha()))try{let r=_a(t,{body:n,tag:e});fa.set(e,r),r.onclick=()=>{window.focus(),i(),r.close(),fa.delete(e)}}catch{}}}function ya(e){for(let[t,n]of fa)e.has(t)||(n.close(),fa.delete(t))}var B=class e extends Error{constructor(t,n){var r=`KaTeX parse error: `+t,i,a,o=n&&n.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start,a=o.end,i===s.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;var c=s.slice(i,a).replace(/[^]/g,`$&̲`),l=i>15?`…`+s.slice(i-15,i):s.slice(0,i),u=a+15<s.length?s.slice(a,a+15)+`…`:s.slice(a);r+=l+c+u}super(r),this.name=`ParseError`,this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,e.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=t}},ba=/([A-Z])/g,xa=e=>e.replace(ba,`-$1`).toLowerCase(),Sa={"&":`&`,">":`>`,"<":`<`,'"':`"`,"'":`'`},Ca=/[&><"']/g,wa=e=>String(e).replace(Ca,e=>Sa[e]),Ta=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?Ta(e.body[0]):e:e.type===`font`?Ta(e.body):e,Ea=new Set([`mathord`,`textord`,`atom`]),Da=e=>Ea.has(Ta(e).type),Oa=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},ka={displayMode:{type:`boolean`,description:`Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.`,cli:`-d, --display-mode`},output:{type:{enum:[`htmlAndMathml`,`html`,`mathml`]},description:`Determines the markup language of the output.`,cli:`-F, --format <type>`},leqno:{type:`boolean`,description:`Render display math in leqno style (left-justified tags).`},fleqn:{type:`boolean`,description:`Render display math flush left.`},throwOnError:{type:`boolean`,default:!0,cli:`-t, --no-throw-on-error`,cliDescription:`Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.`},errorColor:{type:`string`,default:`#cc0000`,cli:`-c, --error-color <color>`,cliDescription:`A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.`,cliProcessor:e=>`#`+e},macros:{type:`object`,cli:`-m, --macro <def>`,cliDescription:`Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).`,cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:`number`,description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:`--min-rule-thickness <size>`,cliProcessor:parseFloat},colorIsTextColor:{type:`boolean`,description:`Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.`,cli:`-b, --color-is-text-color`},strict:{type:[{enum:[`warn`,`ignore`,`error`]},`boolean`,`function`],description:`Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.`,cli:`-S, --strict`,cliDefault:!1},trust:{type:[`boolean`,`function`],description:`Trust the input, enabling all HTML features such as \\url.`,cli:`-T, --trust`},maxSize:{type:`number`,default:1/0,description:`If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large`,processor:e=>Math.max(0,e),cli:`-s, --max-size <n>`,cliProcessor:parseInt},maxExpand:{type:`number`,default:1e3,description:`Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.`,processor:e=>Math.max(0,e),cli:`-e, --max-expand <n>`,cliProcessor:e=>e===`Infinity`?1/0:parseInt(e)},globalGroup:{type:`boolean`,cli:!1}};function Aa(e){if(typeof e!=`string`)return e.enum[0];switch(e){case`boolean`:return!1;case`string`:return``;case`number`:return 0;case`object`:return{};default:throw Error(`Unexpected schema type; settings must declare an explicit default.`)}}function ja(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:Aa(Array.isArray(e.type)?e.type[0]:e.type)}function Ma(e,t,n,r){var i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,a=Object.prototype.hasOwnProperty.call(r,`processor`)?r.processor:void 0;e[t]=i===void 0?ja(r):a?a(i):i}var Na=class{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e||={};for(var t of Object.keys(ka)){var n=ka[t];n&&Ma(this,t,e,n)}}isTrusted(e){if(`url`in e&&e.url&&!e.protocol){var t=Oa(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},Pa=class{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return Ua[Wa[this.id]]}sub(){return Ua[Ga[this.id]]}fracNum(){return Ua[Ka[this.id]]}fracDen(){return Ua[qa[this.id]]}cramp(){return Ua[Ja[this.id]]}text(){return Ua[Ya[this.id]]}isTight(){return this.size>=2}},Fa=0,Ia=1,La=2,Ra=3,za=4,Ba=5,Va=6,Ha=7,Ua=[new Pa(Fa,0,!1),new Pa(Ia,0,!0),new Pa(La,1,!1),new Pa(Ra,1,!0),new Pa(za,2,!1),new Pa(Ba,2,!0),new Pa(Va,3,!1),new Pa(Ha,3,!0)],Wa=[za,Ba,za,Ba,Va,Ha,Va,Ha],Ga=[Ba,Ba,Ba,Ba,Ha,Ha,Ha,Ha],Ka=[La,Ra,za,Ba,Va,Ha,Va,Ha],qa=[Ra,Ra,Ba,Ba,Ha,Ha,Ha,Ha],Ja=[Ia,Ia,Ra,Ra,Ba,Ba,Ha,Ha],Ya=[Fa,Ia,La,Ra,La,Ra,La,Ra],Xa={DISPLAY:Ua[Fa],TEXT:Ua[La],SCRIPT:Ua[za],SCRIPTSCRIPT:Ua[Va]},Za=[{name:`latin`,blocks:[[256,591],[768,879]]},{name:`cyrillic`,blocks:[[1024,1279]]},{name:`armenian`,blocks:[[1328,1423]]},{name:`brahmic`,blocks:[[2304,4255]]},{name:`georgian`,blocks:[[4256,4351]]},{name:`cjk`,blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:`hangul`,blocks:[[44032,55215]]}];function Qa(e){for(var t=0;t<Za.length;t++)for(var n=Za[t],r=0;r<n.blocks.length;r++){var i=n.blocks[r];if(e>=i[0]&&e<=i[1])return n.name}return null}var $a=[];Za.forEach(e=>e.blocks.forEach(e=>$a.push(...e)));function eo(e){for(var t=0;t<$a.length;t+=2)if(e>=$a[t]&&e<=$a[t+1])return!0;return!1}var to=e=>e+` `+e,no=80,ro=function(e,t){return`M95,`+(622+e+t)+`
|
|
20
|
+
`),n))}return{node:{type:`list`,ordered:r,start:r?Number(i[2]):1,items:o},next:s}}function Lt(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1));let n=[],r=``;for(let e=0;e<t.length;e+=1){let i=xt(t,e);if(i)r+=t.slice(e,i.next),e=i.next-1;else if(t[e]==="`"){let n=dt(t,e,"`"),i=pt(t,e+n,n),a=i===-1?e+n:i+n;r+=t.slice(e,a),e=a-1}else t[e]===`\\`&&t[e+1]===`|`?(r+=`|`,e+=1):t[e]===`|`?(n.push(r.trim()),r=``):r+=t[e]}return n.push(r.trim()),n}function Rt(e){let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`center`:n?`right`:t?`left`:null}function zt(e,t){let n=e.slice(0,t);for(;n.length<t;)n.push(``);return n}var Bt=[{kind:`calculator`,name:`计算器`,glyph:`∑`,blurb:`算术表达式,四则运算与乘方。除零会明确报错。`},{kind:`timestamp`,name:`时间戳`,glyph:`◷`,blurb:`Unix 时间戳与日期互转,本地计算,不联网。`}],Vt=[{id:`preset_calculator`,kind:`calculator`,name:`计算器`,glyph:`∑`}],Ht=40,Ut=2048,Wt=`super-pi:tools:v1`;function Gt(e){return typeof e==`string`?e.replace(/\s+/g,` `).trim().slice(0,Ht):``}function Kt(e){let t=e.trim();if(!t)return{ok:!1,reason:`请填写网址。`};if(t.length>Ut)return{ok:!1,reason:`网址太长了,请控制在 ${Ut} 个字符以内。`};let n=ct(t);return n?{ok:!0,url:n}:{ok:!1,reason:`这个网址不是允许的协议。只支持 http / https / mailto 开头的网址。`}}function qt(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];let n=[],r=new Set;for(let e of t){if(n.length>=32)break;if(typeof e!=`object`||!e)continue;let t=e,i=t.kind;if(typeof i!=`string`||i!==`calculator`&&i!==`timestamp`&&i!==`link`)continue;let a=Gt(t.name);if(!a)continue;let o=typeof t.glyph==`string`&&t.glyph.trim()?t.glyph.trim().slice(0,4):``;if(!o)continue;let s=typeof t.id==`string`&&t.id.trim()?t.id.trim().slice(0,64):``;if(s&&!r.has(s)){if(i===`link`){let e=ct(typeof t.url==`string`?t.url:``);if(!e)continue;r.add(s),n.push({id:s,kind:`link`,name:a,glyph:o,url:e})}else r.add(s),n.push({id:s,kind:i,name:a,glyph:o})}}return n}function Jt(e){return JSON.stringify(e.map(e=>e.kind===`link`?{...e}:{id:e.id,kind:e.kind,name:e.name,glyph:e.glyph}))}function Yt(){let e=typeof globalThis<`u`?globalThis.crypto:void 0;return typeof e?.randomUUID==`function`?e.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function Xt(e,t){let n=e===`link`?`link`:`preset_${e}`,r=Yt().replace(/-/g,``).slice(0,8),i=`${n}_${r}`,a=1;for(;t.includes(i);)i=`${n}_${r}_${a}`,a+=1;return i}function Zt(e,t){if(e.some(e=>e.kind===t))return e.slice();let n=Bt.find(e=>e.kind===t);return n?[...e,{id:Xt(t,e.map(e=>e.id)),kind:t,name:n.name,glyph:n.glyph}]:e.slice()}function Qt(e,t){return e.filter(e=>e.id!==t)}var $t=e=>({ok:!1,reason:e}),en=`除数不能为 0:除以零没有结果,请换一个非零的除数。`,tn=new Set([`/`,`%`]),nn=e=>e!==void 0&&e>=`0`&&e<=`9`,rn=e=>e!==void 0&&/\s/.test(e);function an(e){for(;rn(e.source[e.at]);)e.at+=1}function on(e){let t=e.at,n=0;for(;nn(e.source[e.at]);)e.at+=1,n+=1;if(e.source[e.at]===`.`)for(e.at+=1;nn(e.source[e.at]);)e.at+=1,n+=1;if(!n)return e.at=t,$t(`「${e.source[t]}」不是有效的数字。`);let r=Number(e.source.slice(t,e.at));return Number.isFinite(r)?{ok:!0,value:r}:$t(`数字太长了,无法表示。`)}function sn(e){an(e);let t=e.source[e.at];if(t===void 0)return $t(`算式不完整:末尾还缺一个数字或右括号。`);if(t===`(`){e.at+=1;let t=dn(e);return t.ok?(an(e),e.source[e.at]===`)`?(e.at+=1,t):$t(`括号不匹配:少了一个右括号「)」。`)):t}return nn(t)||t===`.`?on(e):$t(`无法识别的字符「${t}」。`)}function cn(e){let t=sn(e);if(!t.ok||(an(e),e.source[e.at]!==`^`))return t;e.at+=1;let n=ln(e);if(!n.ok)return n;let r=t.value**n.value;return Number.isFinite(r)?{ok:!0,value:r}:$t(`结果超出了可计算的数值范围。`)}function ln(e){an(e);let t=e.source[e.at];if(t!==`+`&&t!==`-`)return cn(e);e.at+=1;let n=ln(e);if(!n.ok)return n;let r=t===`-`?-n.value:n.value;return Number.isFinite(r)?{ok:!0,value:r}:$t(`结果超出了可计算的数值范围。`)}function un(e){let t=ln(e);if(!t.ok)return t;for(;;){an(e);let n=e.source[e.at];if(n!==`*`&&!tn.has(n))return t;e.at+=1;let r=ln(e);if(!r.ok)return r;if(tn.has(n)&&r.value===0)return $t(en);let i=n===`*`?t.value*r.value:n===`%`?t.value%r.value:t.value/r.value;if(!Number.isFinite(i))return $t(`结果超出了可计算的数值范围。`);t={ok:!0,value:i}}}function dn(e){let t=un(e);if(!t.ok)return t;for(;;){an(e);let n=e.source[e.at];if(n!==`+`&&n!==`-`)return t;e.at+=1;let r=un(e);if(!r.ok)return r;let i=n===`+`?t.value+r.value:t.value-r.value;if(!Number.isFinite(i))return $t(`结果超出了可计算的数值范围。`);t={ok:!0,value:i}}}function fn(e){let t=e.trim();if(!t)return $t(`请输入算式。`);if(t.length>200)return $t(`算式太长了,请控制在 200 个字符以内。`);let n={source:t,at:0},r=dn(n);return r.ok?(an(n),n.at===t.length?Number.isFinite(r.value)?r:$t(`结果不是有限数字。`):$t(`「${t[n.at]}」后面的内容无法识别,请检查是否漏了运算符。`)):r}function pn(e){return String(!Number.isFinite(e)||Number.isInteger(e)&&Math.abs(e)<1e21?e:Number(e.toPrecision(12)))}function mn(e){let t=e.trim();if(!t)return{ok:!1,reason:`请输入时间戳或日期。`};if(/^-?\d+$/.test(t)){let e=Number(t);if(!Number.isFinite(e))return{ok:!1,reason:`这个数字太大,无法表示。`};let n=t.replace(`-`,``).length<=11?e*1e3:e;return!Number.isFinite(n)||Math.abs(n)>864e13?{ok:!1,reason:`这个时间戳超出了日期能表示的范围。`}:{ok:!0,ms:n}}let n=Date.parse(t);return Number.isNaN(n)?{ok:!1,reason:`看不懂这个日期。试试 1757000000、2026-10-08 或 2026-10-08T09:00:00。`}:{ok:!0,ms:n}}var hn=e=>String(Math.abs(e)).padStart(2,`0`);function gn(e){let t=new Date(e);return Number.isNaN(t.getTime())?null:{local:`${t.getFullYear()}-${hn(t.getMonth()+1)}-${hn(t.getDate())} ${hn(t.getHours())}:${hn(t.getMinutes())}:${hn(t.getSeconds())}`,iso:t.toISOString(),seconds:String(Math.floor(e/1e3)),milliseconds:String(e)}}function _n({workspaceId:e,onEnter:t,onBranches:n,onClose:r,summaries:i,anchor:a}){let[o,s]=(0,u.useState)([]),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(!1),[p,g]=(0,u.useState)({}),_=(0,u.useRef)(new Set),v=async t=>{if(!_.current.has(t)){_.current.add(t);try{let n=await je(`/api/git?`+new URLSearchParams({workspaceId:e,op:`worktree-inspect`,worktreeId:t}),{signal:AbortSignal.timeout(1e4)}),r=await n.json();if(!n.ok)throw Error();let i=r.status,a=new Set([...i.staged,...i.unstaged,...i.untracked].map(e=>e.path)).size;g(e=>({...e,[t]:a?`${a} 个改动`:`工作树干净`}))}catch{g(e=>({...e,[t]:`改动状态暂不可用`}))}}};(0,u.useEffect)(()=>{let t=new AbortController;return je(`/api/git?`+new URLSearchParams({workspaceId:e,op:`worktrees`}),{signal:t.signal}).then(async e=>{let n=await e.json();if(!e.ok)throw Error(n.error??`无法读取工作树`);t.signal.aborted||s(n.worktrees)}).catch(e=>{t.signal.aborted||l(e.message)}),()=>t.abort()},[e]);let y=async n=>{if(!d){f(!0),l(``);try{let r=await je(`/api/git?`+new URLSearchParams({workspaceId:e,op:`worktree-manage`}),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`enter`,worktreeId:n,requestId:Yt()})}),i=await r.json();if(!r.ok)throw Error(i.error??`无法进入工作树`);t(m(h(e).server,i.workspaceId))}catch(e){l(e instanceof Error?e.message:`无法进入工作树`)}finally{f(!1)}}};return(0,L.jsxs)(Ye,{anchor:a,title:`进入仓库工作树`,onClose:r,onHighlight:e=>void v(e),choices:o.map(e=>({id:e.id,label:(e.branch??e.head.slice(0,8))+(e.current?` · 当前`:``),detail:[e.path,p[e.id],...i.filter(t=>t.path.replaceAll(`\\`,`/`)===e.path.replaceAll(`\\`,`/`)&&t.running>0).map(e=>`${e.running} 个会话正在运行`)].filter(Boolean).join(` · `),group:e.primary?`主检出`:`关联工作树`,disabled:e.missing||d})),onChoose:e=>void y(e),children:[c&&(0,L.jsx)(`p`,{role:`alert`,children:c}),!o.length&&!c&&(0,L.jsx)(`p`,{role:`status`,children:`正在读取工作树…`}),(0,L.jsx)(`button`,{type:`button`,"data-status-branches":!0,disabled:d,onClick:n,children:`查看分支与切换分支`})]})}var vn=`modulepreload`,yn=function(e){return`/`+e},bn={},xn=function(e){return e.pathname.endsWith(`.css`)},Sn=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Cn=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,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?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=yn(t,n);let r=s(t),i=xn(r);return Sn(bn,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:vn,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).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)})};async function wn(e,t){let[{StreamLanguage:n},r]=await Promise.all([Cn(()=>import(`./dist-J6XWqRpB.js`).then(e=>e.d),__vite__mapDeps([0,1,2,3,4])),e()]),i=r[t]??r.default??r;return n.define(i)}var Tn={cpp:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),cc:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),cxx:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),hpp:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),hh:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),hxx:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),c:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),h:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),cu:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),cuh:()=>Cn(()=>import(`./dist-Dc1MBGAG.js`).then(e=>e.cpp()),__vite__mapDeps([5,4,1,0,2,3,6])),js:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,2,3,4,0,6,8])),jsx:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([7,1,2,3,4,0,6,8])),mjs:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,2,3,4,0,6,8])),cjs:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([7,1,2,3,4,0,6,8])),ts:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,2,3,4,0,6,8])),tsx:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([7,1,2,3,4,0,6,8])),mts:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,2,3,4,0,6,8])),cts:()=>Cn(()=>import(`./dist-Cx00EZKR.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([7,1,2,3,4,0,6,8])),py:()=>Cn(()=>import(`./dist-Dds-qLxY.js`).then(e=>e.python()),__vite__mapDeps([9,4,1,0,2,3,6,8])),pyi:()=>Cn(()=>import(`./dist-Dds-qLxY.js`).then(e=>e.python()),__vite__mapDeps([9,4,1,0,2,3,6,8])),java:()=>Cn(()=>import(`./dist-AW5lyI3I.js`).then(e=>e.java()),__vite__mapDeps([10,4,1,0,2,3,6])),php:()=>Cn(()=>import(`./dist-BGxkyh6e.js`).then(e=>e.php()),__vite__mapDeps([11,4,1,0,2,3,6,12,13,7,8])),sql:()=>Cn(()=>import(`./dist-Dvb0SqcK.js`).then(e=>e.sql()),__vite__mapDeps([14,4,1,0,2,3,6,8])),yaml:()=>Cn(()=>import(`./dist-D71y2EI1.js`).then(e=>e.yaml()),__vite__mapDeps([15,4,1,0,2,3,6])),yml:()=>Cn(()=>import(`./dist-D71y2EI1.js`).then(e=>e.yaml()),__vite__mapDeps([15,4,1,0,2,3,6])),xml:()=>Cn(()=>import(`./dist-DeD9copn.js`).then(e=>e.xml()),__vite__mapDeps([16,2,1,3,4,0,6])),json:()=>Cn(()=>import(`./dist-QzbOCAU6.js`).then(e=>e.json()),__vite__mapDeps([17,4,1,0,2,3,6])),jsonc:()=>Cn(()=>import(`./dist-QzbOCAU6.js`).then(e=>e.json()),__vite__mapDeps([17,4,1,0,2,3,6])),json5:()=>Cn(()=>import(`./dist-QzbOCAU6.js`).then(e=>e.json()),__vite__mapDeps([17,4,1,0,2,3,6])),html:()=>Cn(()=>import(`./dist-CKF2Jksy.js`).then(e=>e.html()),__vite__mapDeps([12,2,1,3,4,0,6,13,7,8])),htm:()=>Cn(()=>import(`./dist-CKF2Jksy.js`).then(e=>e.html()),__vite__mapDeps([12,2,1,3,4,0,6,13,7,8])),vue:()=>Cn(()=>import(`./dist-CKF2Jksy.js`).then(e=>e.html()),__vite__mapDeps([12,2,1,3,4,0,6,13,7,8])),svelte:()=>Cn(()=>import(`./dist-CKF2Jksy.js`).then(e=>e.html()),__vite__mapDeps([12,2,1,3,4,0,6,13,7,8])),css:()=>Cn(()=>import(`./dist-BV64A9Ji.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([13,1,4,0,2,3,6])),md:()=>Cn(()=>import(`./dist-DuvGReu-.js`).then(e=>e.markdown()),__vite__mapDeps([18,2,1,3,4,0,8,12,6,13,7])),markdown:()=>Cn(()=>import(`./dist-DuvGReu-.js`).then(e=>e.markdown()),__vite__mapDeps([18,2,1,3,4,0,8,12,6,13,7])),mdx:()=>Cn(()=>import(`./dist-DuvGReu-.js`).then(e=>e.markdown()),__vite__mapDeps([18,2,1,3,4,0,8,12,6,13,7])),rs:()=>Cn(()=>import(`./dist-BRVQKlcp.js`).then(e=>e.rust()),__vite__mapDeps([19,4,1,0,2,3,6])),go:()=>Cn(()=>import(`./dist-BJxfd7yb.js`).then(e=>e.go()),__vite__mapDeps([20,4,1,0,2,3,6,8])),sh:()=>wn(()=>Cn(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>wn(()=>Cn(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>wn(()=>Cn(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>wn(()=>Cn(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>wn(()=>Cn(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>wn(()=>Cn(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>wn(()=>Cn(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>wn(()=>Cn(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>wn(()=>Cn(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>wn(()=>Cn(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>wn(()=>Cn(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>wn(()=>Cn(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>wn(()=>Cn(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>wn(()=>Cn(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>wn(()=>Cn(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>wn(()=>Cn(()=>import(`./diff-ChtP43wD.js`),[]),`diff`)},En={cpp:`C++`,cc:`C++`,cxx:`C++`,hpp:`C++`,hh:`C++`,hxx:`C++`,cu:`CUDA C++`,cuh:`CUDA C++`,c:`C`,h:`C/C++ Header`,js:`JavaScript`,jsx:`JSX`,mjs:`JavaScript`,cjs:`JavaScript`,ts:`TypeScript`,tsx:`TSX`,mts:`TypeScript`,cts:`TypeScript`,py:`Python`,pyi:`Python Stub`,java:`Java`,php:`PHP`,sql:`SQL`,yaml:`YAML`,yml:`YAML`,xml:`XML`,json:`JSON`,jsonc:`JSON with Comments`,json5:`JSON5`,css:`CSS`,md:`Markdown`,markdown:`Markdown`,mdx:`MDX`,rs:`Rust`,go:`Go`,html:`HTML`,htm:`HTML`,vue:`Vue`,svelte:`Svelte`,sh:`Shell`,bash:`Bash`,zsh:`Zsh`,fish:`Fish`,ps1:`PowerShell`,psm1:`PowerShell`,rb:`Ruby`,swift:`Swift`,toml:`TOML`,ini:`INI`,cfg:`Config`,conf:`Config`,properties:`Properties`,dockerfile:`Dockerfile`,diff:`Diff`,patch:`Patch`};function Dn(e){return Tn[e.toLowerCase()]}function On(e){return En[e.toLowerCase()]}function kn(e,t){return new URL(`http://${e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}:${t}`).origin}var An=()=>({name:``,host:``,sshPort:`22`,username:``,servicePort:`3080`,serviceHost:`0.0.0.0`,authentication:`password`}),jn={offline:`未连接`,connecting:`连接中`,online:`已连接`,needsTrust:`等待确认指纹`,awaitingVerification:`等待交互验证`};function Mn(){let[e,t]=(0,u.useState)([]),[n,r]=(0,u.useState)(),[i,a]=(0,u.useState)(An),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``),[d,p]=(0,u.useState)({}),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(new Set),v=(0,u.useRef)(new Set),y=async()=>{let e=await je(`/api/managed-servers`,{signal:AbortSignal.timeout(8e3)},f),n=await e.json();return r(e.ok&&n.available===!0),Array.isArray(n.profiles)&&t(n.profiles),n};(0,u.useEffect)(()=>{let e=!1,t=()=>{e||y().catch(()=>{e||r(!1)})};t();let n=setInterval(t,2e3);return()=>{e=!0,clearInterval(n)}},[]);let b=async e=>{let n=await je(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),signal:AbortSignal.timeout(3e4)},f),r=await n.json();if(Array.isArray(r.profiles)&&t(r.profiles),Ee(),!n.ok)throw Error(r.error??`操作失败`);return r};(0,u.useEffect)(()=>{for(let t of e)g.has(t.id)&&!v.current.has(t.id)&&t.ssh===`online`&&[`idle`,`ready`].includes(t.phase)&&t.fingerprint&&(v.current.add(t.id),_(e=>new Set([...e].filter(e=>e!==t.id))),b({action:`deploy`,id:t.id}).catch(e=>l(e instanceof Error?e.message:`部署未开始`)).finally(()=>v.current.delete(t.id)))},[e,g]);let x=async(e,t,n={})=>{s(!0),l(``);try{await b({id:e,action:t,...n})}catch(e){l(e instanceof Error?e.message:`操作失败`)}finally{s(!1)}},S=e=>{a({id:e.id,name:e.name,host:e.host,username:e.username,sshPort:String(e.sshPort),servicePort:String(e.servicePort),serviceHost:e.serviceHost??`127.0.0.1`,authentication:e.authentication,identityFile:e.identityFile,serviceUrl:e.serviceUrl===kn(e.host,e.servicePort)?``:e.serviceUrl}),h(!0),l(``)},C=e=>o||e.phase===`deploying`||!!e.maintenance,w=async(e,t=e.id??`draft`)=>{s(!0),l(``);try{let n=await b({action:`probeService`,profile:{...e,servicePort:Number(e.servicePort),...e.sshPort===void 0?{}:{sshPort:Number(e.sshPort)}}});n.probe&&p(e=>({...e,[t]:n.probe}))}catch(e){l(e instanceof Error?e.message:`无法检测服务端口`)}finally{s(!1)}};return(0,u.useEffect)(()=>{p(e=>{let t={...e};return delete t.draft,t})},[i.host,i.servicePort,i.serviceUrl,i.serviceAccessToken]),n===!1?(0,L.jsxs)(`div`,{className:`server-managed-unavailable`,children:[(0,L.jsx)(`h4`,{children:`请使用本地完整安装开启 SSH 托管`}),(0,L.jsxs)(`p`,{children:[`运行 `,(0,L.jsx)(`code`,{children:`super_pi desktop`}),` 打开桌面端,或在自己的电脑启动完整包,再通过本机网页访问。纯服务包只负责远端执行,不保存其他服务器的 SSH 资料。`]})]}):(0,L.jsxs)(`div`,{className:`managed-servers-panel`,"data-managed-servers":`1`,children:[(0,L.jsx)(`p`,{className:`server-description`,children:`预览功能:SSH 自动部署仍在完善跨平台兼容性。部署失败时可查看下方日志并重试;已有服务也可以使用“已有服务直接连接”。`}),(0,L.jsxs)(`div`,{className:`managed-overview`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{children:`本地配置,统一接入`}),(0,L.jsx)(`p`,{children:`默认通过 Super Pi 的 IP 和端口直连。SSH 用于安装与维护,访问隧道可按服务器手动开启。`}),(0,L.jsx)(`small`,{children:`SSH 资料保存在当前入口服务所在的电脑。新托管服务调用模型时本地入口需在线;已有服务继续使用它原来的模型配置。`})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{fe(f),window.dispatchEvent(new Event(`super-pi-open-local-model-settings`))},children:`配置本地模型`})]}),(0,L.jsxs)(`div`,{className:`managed-toolbar`,children:[(0,L.jsxs)(`span`,{children:[e.length,` 台服务器`]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void x(``,`syncAll`),children:`同步全部模型目录`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>{a(An()),h(!0)},children:`+ 添加 SSH 服务器`})]})]}),n===void 0&&(0,L.jsx)(`p`,{role:`status`,children:`正在读取本地托管配置…`}),e.length===0&&!m&&(0,L.jsxs)(`div`,{className:`managed-empty`,children:[(0,L.jsx)(`strong`,{children:`尚未添加服务器`}),(0,L.jsx)(`p`,{children:`只需要提供 SSH 访问方式和希望使用的服务端口。通过 SSH 隧道访问时,无需向外网开放这个端口。`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(!0),children:`添加并部署第一台服务器`})]}),(0,L.jsx)(`div`,{className:`managed-server-list`,children:e.map(e=>(0,L.jsxs)(`section`,{className:`managed-server-card`,"data-managed-server":e.id,children:[(0,L.jsxs)(`header`,{children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{children:e.name}),(0,L.jsxs)(`small`,{children:[e.username,`@`,e.host,`:`,e.sshPort,` · Super Pi `,e.servicePort]})]}),(0,L.jsx)(`span`,{className:`managed-phase`,"data-phase":e.phase,children:e.enabled?e.phase===`deploying`?e.maintenance?`维护中`:`部署中`:e.phase===`ready`?`可使用`:e.phase===`awaitingVerification`?`等待验证`:e.phase===`connecting`?`连接中`:e.phase===`needsTrust`?`待确认`:e.phase===`failed`?`需要处理`:e.ssh===`online`?`SSH 已连接`:e.enabled?`待连接`:`已停用`:`已停用`})]}),(0,L.jsxs)(`dl`,{className:`managed-connectivity`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`服务访问`}),(0,L.jsx)(`dd`,{children:e.enabled?e.service===`online`?e.transport===`direct`?`直连在线`:`SSH 隧道在线`:e.service===`offline`?`当前不可达`:`正在确认`:`已停用`})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`SSH 管理`}),(0,L.jsxs)(`dd`,{children:[jn[e.ssh],e.sshError&&(0,L.jsx)(`small`,{className:`server-connection-error`,children:e.sshError})]})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:e.existingService?.attached?`模型配置`:`本地模型通道`}),(0,L.jsxs)(`dd`,{children:[e.existingService?.attached?`沿用远端配置`:e.modelTransport===`direct`?e.modelChannel===`online`?`已连接 · 服务端口`:`服务端口通道未就绪`:e.modelChannel===`online`?`已连接 · SSH`:e.modelChannelPaused?`已暂停`:e.ssh===`awaitingVerification`?`等待 SSH 验证`:e.ssh===`connecting`?`正在恢复`:`未连接`,e.modelError&&(0,L.jsxs)(`small`,{className:`server-connection-error`,children:[`模型同步未完成 · `,e.modelError]}),e.modelChannelPaused&&e.enabled&&(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void x(e.id,`connectSsh`),children:`恢复本地模型通道`})]})]})]}),e.serviceUrl&&(0,L.jsxs)(`section`,{className:`managed-existing-service`,children:[e.enabled&&e.service===`offline`&&e.serviceError&&(0,L.jsx)(`p`,{className:`server-connection-error`,role:`status`,children:e.serviceError}),d[e.id]&&(0,L.jsxs)(`p`,{role:`status`,"data-service-probe-result":d[e.id].authorized?`online`:d[e.id].reachable?`reachable`:`offline`,children:[`上次手动测试 · `,d[e.id].message,` · `,d[e.id].latencyMs,` ms`]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>void w({id:e.id}),children:`测试服务端口`}),e.ssh===`online`?(0,L.jsx)(`button`,{type:`button`,"data-managed-ssh":`disconnect`,disabled:o,onClick:()=>void x(e.id,`disconnectSsh`),children:`断开 SSH 管理`}):(0,L.jsx)(`button`,{type:`button`,"data-managed-ssh":`connect`,disabled:o||e.ssh===`connecting`||e.ssh===`awaitingVerification`,onClick:()=>void x(e.id,`connectSsh`),children:`连接 SSH 管理`}),e.enabled&&(e.allowServiceTunnel||e.service===`offline`)&&(0,L.jsx)(`button`,{type:`button`,"data-service-tunnel-toggle":!0,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,e.allowServiceTunnel?`disableServiceTunnel`:`enableServiceTunnel`),children:e.allowServiceTunnel?`关闭 SSH 隧道访问`:`启用 SSH 隧道访问`})]})]}),e.existingService&&(0,L.jsxs)(`section`,{className:`managed-existing-service`,children:[(0,L.jsxs)(`h4`,{children:[e.existingService.attached?`已接入已有服务`:e.existingService.running?`发现正在运行的 Super Pi`:`发现已有 Super Pi 安装`,e.existingService.version?` · v${e.existingService.version}`:``]}),(0,L.jsx)(`p`,{children:e.existingService.attached?`保留原端口、工作区、会话和模型配置。未重装或重启原服务。`:e.existingService.running?`原服务仍在运行,补充访问授权后即可接入。`:`原有数据保持原样,不会自动创建空实例。`}),e.existingService.dataDirectory&&(0,L.jsxs)(`small`,{children:[`原数据目录:`,(0,L.jsx)(`code`,{children:e.existingService.dataDirectory})]}),!e.existingService.running&&e.existingService.canStart&&(0,L.jsx)(`button`,{type:`button`,disabled:o||e.ssh!==`online`,onClick:()=>void x(e.id,`startExisting`),children:`启动并接入原服务`})]}),(0,L.jsx)(Nn,{profile:e,busy:o,onApply:t=>void x(e.id,`applyListener`,{serviceHost:t})}),(0,L.jsxs)(`section`,{className:`managed-recovery`,"data-managed-recovery":e.id,children:[(0,L.jsx)(`h4`,{children:`实例维护与恢复`}),(0,L.jsx)(`p`,{children:`通过本地入口和 SSH 执行,服务端口离线时也可使用。重启或修复保留原数据目录和会话。`}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[e.remoteRoot&&!e.existingService?.attached&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,"data-managed-restart":!0,disabled:C(e)||!e.fingerprint||e.canRestart===!1,title:e.canRestart===!1?`原运行程序尚未恢复,请先修复部署`:`通过 SSH 重启,会中断原实例的当前任务,不删除数据`,onClick:()=>void x(e.id,`restart`),children:`重启原实例`}),(0,L.jsx)(`button`,{type:`button`,"data-managed-repair":!0,disabled:C(e)||!e.fingerprint,title:`重新安装服务程序,沿用原 data 和 agent 目录`,onClick:()=>void x(e.id,`repair`),children:`修复部署`})]}),(0,L.jsx)(`button`,{type:`button`,"data-managed-scan":!0,disabled:C(e)||!e.fingerprint,title:e.fingerprint?`只读探测当前 SSH 用户的历史托管目录`:`先连接 SSH 并确认主机指纹`,onClick:()=>void x(e.id,`scanInstances`),children:`查找旧实例`})]}),!!e.recoverableInstances?.length&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{children:`发现其他托管目录。接管会重启所选实例并重新绑定入口授权,原目录和历史会话保留。`}),(0,L.jsx)(`ul`,{className:`managed-recovery-list`,children:e.recoverableInstances.map(t=>(0,L.jsxs)(`li`,{"data-recoverable-instance":t.id,children:[(0,L.jsxs)(`strong`,{children:[t.port?`端口 ${t.port}`:`原端口未记录`,t.version?` · v${t.version}`:` · 运行程序需要修复`]}),(0,L.jsxs)(`span`,{children:[t.conversationCount===void 0?t.hasData?`有历史数据`:`未发现历史数据`:`${t.conversationCount} 个会话`,t.workspaceCount===void 0?``:` · ${t.workspaceCount} 个工作区`]}),(0,L.jsx)(`code`,{children:t.dataDirectory}),(0,L.jsx)(`div`,{className:`server-connection-actions`,children:(0,L.jsx)(`button`,{type:`button`,"data-managed-recover":t.id,disabled:C(e)||!t.hasData||!e.fingerprint,onClick:()=>void x(e.id,`recover`,{instanceId:t.id}),children:`重新接管并恢复会话`})})]},t.id))}),!e.remoteRoot&&(0,L.jsx)(`button`,{type:`button`,"data-managed-deploy-new":!0,disabled:C(e)||!e.fingerprint,title:`明确另建空实例,不修改上面列出的旧数据目录`,onClick:()=>void x(e.id,`deployNew`),children:`仍新建独立空实例`})]})]}),e.phase===`deploying`&&(0,L.jsxs)(`div`,{className:`managed-progress`,role:`status`,children:[(0,L.jsx)(`progress`,{"aria-label":`远端部署进度`}),(0,L.jsx)(`span`,{children:e.step})]}),e.error&&(0,L.jsxs)(`p`,{className:`server-connection-error`,role:`status`,children:[`上次操作未完成 · `,e.error]}),e.verification&&(0,L.jsx)(Be,{verification:e.verification,onAnswer:t=>b({action:`answerVerification`,id:e.id,verificationId:e.verification.id,answers:t}).then(()=>{}),onCancel:()=>(_(t=>new Set([...t].filter(t=>t!==e.id))),b({action:`cancelVerification`,id:e.id,verificationId:e.verification.id}).then(()=>{}))},e.verification.id),e.observedFingerprint&&(0,L.jsxs)(`div`,{className:`managed-host-trust`,children:[(0,L.jsx)(`strong`,{children:e.fingerprint?`主机指纹已变化`:`首次连接:确认 SSH 主机指纹`}),(0,L.jsx)(`code`,{children:e.observedFingerprint}),(0,L.jsx)(`small`,{children:`请与服务器管理员或已有 SSH 记录核对;确认后才会安装或执行远端命令。`}),(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:async()=>{s(!0),l(``);try{await b({action:`trust`,id:e.id,fingerprint:e.observedFingerprint})}catch(e){l(e instanceof Error?e.message:`连接失败`)}finally{s(!1)}},children:g.has(e.id)?`确认指纹并继续部署`:`信任此主机并连接`})]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[!e.remoteRoot&&(0,L.jsx)(`button`,{type:`button`,disabled:o||!!e.existingService||e.phase===`deploying`||!e.fingerprint,title:e.existingService?`已识别原安装,保留原服务及数据`:void 0,onClick:()=>void x(e.id,`deploy`),children:e.existingService?.attached?`已保留原服务`:`一键安装并接入`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,e.enabled?`disconnect`:`connect`),children:e.enabled?`停用连接`:`启用连接`}),!e.serviceUrl&&(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,onClick:()=>void x(e.id,`connectSsh`),children:`检测/连接 SSH`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.service!==`online`||e.existingService?.attached,title:e.existingService?.attached?`原服务沿用远端模型配置`:void 0,onClick:()=>void x(e.id,`sync`),children:`同步模型`}),(0,L.jsx)(`button`,{type:`button`,disabled:e.phase===`deploying`,onClick:()=>S(e),children:`编辑`}),(0,L.jsx)(`button`,{type:`button`,disabled:o||e.phase===`deploying`,title:`只移除本地连接,远端实例和历史数据保持原样`,onClick:()=>void x(e.id,`remove`),children:`移除连接`})]}),(0,L.jsx)(`small`,{className:`managed-data-note`,children:`移除连接只删除本地配置,不删除远端会话;重新添加后可使用“查找旧实例”恢复接管。`}),(e.log?.length||e.remoteRoot)&&(0,L.jsxs)(`details`,{className:`managed-diagnostics`,children:[(0,L.jsx)(`summary`,{children:`部署记录与日志位置`}),e.remoteRoot&&(0,L.jsxs)(`p`,{children:[`远端目录:`,(0,L.jsx)(`code`,{children:e.remoteRoot}),(0,L.jsx)(`br`,{}),`服务日志:`,(0,L.jsxs)(`code`,{children:[e.remoteRoot,`/service.log`]})]}),e.log?.length?(0,L.jsx)(`pre`,{children:e.log.join(`
|
|
21
|
+
`)}):null]})]},e.id))}),m&&(0,L.jsxs)(`form`,{className:`managed-server-form`,onSubmit:async e=>{e.preventDefault(),s(!0),l(``);try{let t=(await b({action:`save`,profile:{...i,sshPort:Number(i.sshPort),servicePort:Number(i.servicePort)}})).profiles.find(e=>e.name===i.name.trim()),n=e.nativeEvent.submitter,r=n instanceof HTMLButtonElement&&n.value===`deploy`;r&&_(e=>new Set(e).add(t.id)),h(!1),a(An()),await b({action:r?`connectSsh`:`test`,id:t.id})}catch(e){l(e instanceof Error?e.message:`无法保存连接`)}finally{s(!1)}},children:[(0,L.jsx)(`h4`,{children:i.id?`编辑 SSH 连接`:`添加 SSH 服务器`}),(0,L.jsxs)(`div`,{className:`managed-form-grid`,children:[(0,L.jsxs)(`label`,{children:[`显示名称`,(0,L.jsx)(`input`,{required:!0,value:i.name,onChange:e=>a({...i,name:e.target.value}),placeholder:`例如:开发服务器`})]}),(0,L.jsxs)(`label`,{children:[`SSH 地址`,(0,L.jsx)(`input`,{required:!0,value:i.host,onChange:e=>a({...i,host:e.target.value}),placeholder:`IP 或主机名`})]}),(0,L.jsxs)(`label`,{children:[`SSH 端口`,(0,L.jsx)(`input`,{type:`number`,min:1,max:65535,required:!0,value:i.sshPort,onChange:e=>a({...i,sshPort:e.target.value})})]}),(0,L.jsxs)(`label`,{children:[`SSH 用户名`,(0,L.jsx)(`input`,{required:!0,value:i.username,onChange:e=>a({...i,username:e.target.value}),autoComplete:`off`})]}),(0,L.jsxs)(`label`,{children:[`Super Pi 端口`,(0,L.jsx)(`input`,{type:`number`,min:1,max:65535,required:!0,value:i.servicePort,onChange:e=>a({...i,servicePort:e.target.value})}),(0,L.jsx)(`small`,{children:`直连需使用已放行的端口;平台不修改防火墙。`})]}),(0,L.jsxs)(`label`,{children:[`服务监听方式`,(0,L.jsxs)(`select`,{"data-service-listener-mode":!0,value:i.serviceHost??`0.0.0.0`,onChange:e=>a({...i,serviceHost:e.target.value}),children:[(0,L.jsx)(`option`,{value:`0.0.0.0`,children:`可直连 · IPv4 所有网卡`}),(0,L.jsx)(`option`,{value:`::`,children:`可直连 · IPv4 / IPv6`}),(0,L.jsx)(`option`,{value:`127.0.0.1`,children:`仅本机回环`})]}),(0,L.jsx)(`small`,{children:`可直连模式强制访问鉴权。更改后需部署以应用,不会仅凭填写地址改变已运行的服务。`})]}),(0,L.jsxs)(`label`,{children:[`Super Pi 直连地址(可选)`,(0,L.jsx)(`input`,{type:`url`,value:i.serviceUrl??``,onChange:e=>a({...i,serviceUrl:e.target.value}),placeholder:`https://server.example:8088`}),(0,L.jsx)(`small`,{children:`留空自动使用上面的服务器地址和 Super Pi 端口;HTTPS 或不同地址可在这里指定。不自动开放远端端口。`})]}),(0,L.jsxs)(`label`,{children:[`认证方式`,(0,L.jsxs)(`select`,{"data-ssh-authentication":!0,value:i.authentication,onChange:e=>a({...i,authentication:e.target.value}),children:[(0,L.jsx)(`option`,{value:`password`,children:`SSH 密码`}),(0,L.jsx)(`option`,{value:`privateKey`,children:`SSH 私钥`}),(0,L.jsx)(`option`,{value:`agent`,children:`本地 SSH Agent`})]})]})]}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,"data-service-port-probe":!0,disabled:o||!i.host.trim()||!i.servicePort,onClick:()=>void w(i,`draft`),children:o?`正在检测…`:`测试服务端口`}),(0,L.jsx)(`small`,{children:`只检测 Super Pi 的 IP 和端口,不进行 SSH 登录,也不安装或重启服务。`})]}),d.draft&&(0,L.jsxs)(`p`,{role:`status`,"data-service-probe-result":d.draft.authorized?`online`:d.draft.reachable?`reachable`:`offline`,children:[d.draft.message,(0,L.jsx)(`br`,{}),(0,L.jsxs)(`small`,{children:[d.draft.address,` · `,d.draft.latencyMs,` ms`]})]}),i.authentication===`password`&&(0,L.jsxs)(`label`,{children:[`SSH 密码`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.password??``,placeholder:i.id?`留空保留已有密码`:``,required:!i.id,onChange:e=>a({...i,password:e.target.value})})]}),i.authentication===`privateKey`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`label`,{children:[`本地私钥文件路径`,(0,L.jsx)(`input`,{value:i.identityFile??``,placeholder:`管理电脑上的私钥绝对路径`,onChange:e=>a({...i,identityFile:e.target.value})})]}),(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{children:`或者粘贴私钥`}),(0,L.jsx)(`textarea`,{rows:4,value:i.privateKey??``,onChange:e=>a({...i,privateKey:e.target.value}),spellCheck:!1})]}),(0,L.jsxs)(`label`,{children:[`私钥口令(如有)`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.passphrase??``,onChange:e=>a({...i,passphrase:e.target.value})})]})]}),i.authentication===`agent`&&(0,L.jsx)(`small`,{children:`使用管理电脑当前用户的 SSH Agent;需提前将对应密钥加入 Agent。`}),(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{children:`已有 Super Pi 服务的访问授权(可选)`}),(0,L.jsxs)(`label`,{children:[`原服务访问密钥`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`new-password`,value:i.serviceAccessToken??``,placeholder:`仅在原服务设置过访问密钥时填写;编辑时留空保留`,onChange:e=>a({...i,serviceAccessToken:e.target.value})})]}),(0,L.jsx)(`small`,{children:`用于访问原服务,单独加密保存,不修改原服务的授权设置。`})]}),(0,L.jsx)(`small`,{children:`认证资料在本地管理服务加密保存,不返回浏览器。端口测试不连接 SSH、不安装或重启;安装与维护使用 SSH,部署使用用户目录,无需 sudo。`}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`submit`,value:`connect`,disabled:o,children:o?`正在保存和检测…`:`保存并检测`}),(0,L.jsx)(`button`,{type:`submit`,value:`deploy`,disabled:o,children:`保存并部署`}),(0,L.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{a(An()),h(!1)},children:`取消`})]})]}),c&&(0,L.jsx)(`p`,{role:`alert`,className:`server-connection-error`,children:c})]})}function Nn({profile:e,busy:t,onApply:n}){if(!e.remoteRoot)return null;let r=e.deployedServiceHost??`127.0.0.1`,i=e.serviceHost??`127.0.0.1`,a=i!==r,o=a?i:`0.0.0.0`;return(0,L.jsxs)(`section`,{className:`managed-existing-service`,"data-service-listener":r,children:[(0,L.jsx)(`h4`,{children:`已部署的服务监听`}),(0,L.jsxs)(`p`,{children:[(0,L.jsxs)(`code`,{children:[r,`:`,e.servicePort]}),r===`127.0.0.1`?` · 仅本机及 SSH 隧道可达`:` · 可通过已放行的服务端口直连`]}),(a||r===`127.0.0.1`)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,"data-service-listener-apply":!0,disabled:t||e.phase===`deploying`||!e.fingerprint,onClick:()=>n(o),children:a?`应用监听配置并重新部署`:`启用直连并重新部署`}),(0,L.jsx)(`small`,{children:`保留原数据和会话;会重启远端服务,部署前需结束运行中的任务。`})]})]})}function Pn({workspaces:e}){let{connections:t}=ce();return(0,L.jsx)(L.Fragment,{children:t.map(t=>{let n=e.filter(e=>h(e.id).server===t.id);return n.length?(0,L.jsx)(`optgroup`,{label:t.name,children:n.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.name},e.id))},t.id):null})})}function Fn(){let{connections:e,settingsServer:t,statuses:n}=ce();return(0,L.jsxs)(`div`,{className:`server-settings-scope`,children:[(0,L.jsxs)(`label`,{children:[`设置目标服务器 `,(0,L.jsx)(`select`,{"aria-label":`设置目标服务器`,value:t,onChange:e=>fe(e.target.value),children:e.filter(e=>e.enabled).map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,L.jsxs)(`small`,{children:[`工作区和会话设置属于所选服务器。外观和通知属于当前客户端。`,n.get(t)?.state===`offline`?` 当前服务器离线。`:``]})]})}function In(){let{connections:e,statuses:t,settingsServer:n}=ce(),r=e.find(e=>e.id===n)?.managed,[i,a]=(0,u.useState)(),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(``),[y,b]=(0,u.useState)(!1);(0,u.useEffect)(()=>{v(``),g(``),Me(`/api/browser-access`).then(e=>e.json()).then(e=>b(e.enabled)).catch(()=>g(`无法读取服务器授权设置`))},[n]);let x=async e=>{m(!0),g(``);try{let t=await Me(`/api/browser-access`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:e})}),n=await t.json();if(!t.ok)throw Error(n.error);b(n.enabled),v(n.key??``)}catch(e){g(e instanceof Error?e.message:`授权设置失败`)}finally{m(!1)}};return(0,L.jsxs)(`div`,{className:`server-connections-panel`,children:[(0,L.jsx)(`p`,{className:`server-description`,children:`当前浏览器直接连接每台服务器。关闭一个连接不会停止那台服务器上的任务。连接配置仅保存在当前浏览器。`}),(0,L.jsx)(`div`,{className:`server-connection-list`,children:e.filter(e=>!e.managed).map(e=>(0,L.jsxs)(`section`,{className:`server-connection-card`,children:[(0,L.jsxs)(`div`,{className:`server-connection-heading`,children:[(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`span`,{"data-server-status":t.get(e.id)?.state??`disabled`,children:e.enabled?{online:`已连接`,connecting:`连接中`,offline:`离线`,disabled:`已停用`}[t.get(e.id)?.state??`connecting`]:`已停用`})]}),(0,L.jsxs)(`small`,{children:[e.url,e.id===`entry`?` · 网页入口`:``]}),t.get(e.id)?.error&&e.enabled&&(0,L.jsx)(`p`,{role:`status`,children:t.get(e.id)?.error}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>fe(e.id),disabled:!e.enabled||n===e.id,children:n===e.id?`当前设置目标`:`管理此服务器`}),(0,L.jsxs)(`label`,{children:[`名称 `,(0,L.jsx)(`input`,{"aria-label":`${e.name}的服务器名称`,defaultValue:e.name,onBlur:t=>{try{ve(e.id,t.target.value),g(``)}catch(n){g(n instanceof Error?n.message:`名称修改失败`),t.target.value=e.name}}})]}),e.id!==`entry`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>be(e.id,!e.enabled),children:e.enabled?`断开`:`连接`}),(0,L.jsx)(`button`,{type:`button`,disabled:!e.enabled,onClick:()=>{a(e.id),s(e.name),l(e.url),f(``)},children:`编辑连接`}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>ye(e.id),children:`移除连接`})]})]})]},e.id))}),(0,L.jsxs)(`form`,{className:`server-connect-form`,onSubmit:async e=>{e.preventDefault(),m(!0),g(``);try{i?await Ce(i,o,c,d):await xe(o,c,d),a(void 0),s(``),l(``),f(``)}catch(e){g(e instanceof Error?e.message:`连接失败`)}finally{m(!1)}},children:[(0,L.jsx)(`h4`,{children:i?`编辑服务器连接`:`添加服务器`}),(0,L.jsxs)(`label`,{children:[`显示名称`,(0,L.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`例如:开发服务器`,required:!0})]}),(0,L.jsxs)(`label`,{children:[`服务地址`,(0,L.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`http://主机:端口`,required:!0})]}),(0,L.jsxs)(`label`,{children:[`连接密钥`,(0,L.jsx)(`input`,{type:`password`,autoComplete:`off`,value:d,onChange:e=>f(e.target.value),required:!i,placeholder:i?`留空保留已保存的密钥`:void 0})]}),(0,L.jsx)(`small`,{children:`先在目标服务器的“服务器连接”设置中生成连接密钥,再粘贴到这里。密钥具有该服务器的操作权限。`}),(0,L.jsx)(`button`,{type:`submit`,disabled:p,children:p?`正在连接…`:i?`验证并保存`:`验证并添加`}),i&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{a(void 0),s(``),l(``),f(``)},children:`取消编辑`})]}),r?(0,L.jsx)(`p`,{children:`SSH 托管连接由本地入口管理,无需手动生成或更换连接密钥。`}):(0,L.jsxs)(`section`,{className:`server-access-settings`,children:[(0,L.jsxs)(`h4`,{children:[`允许其他浏览器连接 · `,I(n)]}),(0,L.jsx)(`p`,{children:y?`已开启。重新生成会使原连接密钥失效。`:`尚未开启远程浏览器授权。`}),(0,L.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void x(`rotate`),children:y?`重新生成连接密钥`:`生成连接密钥`}),y&&(0,L.jsx)(`button`,{type:`button`,disabled:p,onClick:()=>void x(`revoke`),children:`撤销授权`})]}),_&&(0,L.jsxs)(`label`,{children:[`连接密钥(仅本次显示,请妥善保存)`,(0,L.jsx)(`textarea`,{readOnly:!0,rows:3,value:_,onFocus:e=>e.target.select()})]})]}),h&&(0,L.jsx)(`p`,{className:`server-connection-error`,role:`alert`,children:h})]})}function Ln(){let[e,t]=(0,u.useState)(`managed`);return(0,L.jsxs)(`div`,{className:`server-connections-panel`,children:[(0,L.jsxs)(`div`,{className:`server-connection-modes`,role:`tablist`,"aria-label":`服务器接入方式`,children:[(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===`managed`,"data-server-mode":`managed`,onClick:()=>t(`managed`),children:`SSH 托管`}),(0,L.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":e===`direct`,"data-server-mode":`direct`,onClick:()=>t(`direct`),children:`已有服务直接连接`})]}),e===`managed`?(0,L.jsx)(Mn,{}):(0,L.jsx)(In,{})]})}function Rn(e,t,n){let r=new Set,i=new Set,a=!1,o=o=>{let s=o.data;if(o.source!==e()?.contentWindow||o.origin!==`null`||s?.type!==`super-pi-tool-request`||s.owner!==n||typeof s.id!=`string`||i.has(s.id)||i.size>=64)return;let c=t=>{a||e()?.contentWindow?.postMessage({type:`super-pi-tool-response`,id:s.id,...t},`*`)};if(typeof s.path!=`string`||s.path.length>2048||!/^api\/(run|runs(?:\/[a-z0-9_-]+)?|llm(?:\/[a-z0-9_-]+)?)(?:\?[^#\r\n]*)?$/i.test(s.path)||![`GET`,`POST`,`DELETE`].includes(s.method)||s.body!==void 0&&(typeof s.body!=`string`||s.body.length>1048576)){c({error:`工具请求超出当前挂载范围`});return}i.add(s.id);let l=new AbortController;r.add(l),(async()=>{try{let e=await je(Ae(`/tools/${encodeURIComponent(t)}/${s.path}`),{method:s.method,headers:{"content-type":`application/json`,"x-super-pi-tool-owner":n},body:s.body,signal:AbortSignal.any([l.signal,AbortSignal.timeout(25e3)])},le(t));c({status:e.status,headers:{"content-type":e.headers.get(`content-type`)??`application/json`},body:await e.text()})}catch{c({error:`工具所属服务器暂不可达,请检查该服务器连接后重试`})}finally{r.delete(l),i.delete(s.id)}})()};return window.addEventListener(`message`,o),()=>{a=!0,window.removeEventListener(`message`,o);for(let e of r)e.abort()}}function zn(e){return window.superPiDesktop?window.localStorage.getItem(e)??window.sessionStorage.getItem(e):window.sessionStorage.getItem(e)}function Bn(e,t){(window.superPiDesktop?window.localStorage:window.sessionStorage).setItem(e,t)}function Vn(){try{let e=JSON.parse(zn(`super-pi.sidebar-scope.v1`)??`null`);if(e&&[`all`,`workspace`,`repo`,`recent`,`running`].includes(e.kind))return{kind:e.kind,...typeof e.workspaceId==`string`?{workspaceId:e.workspaceId}:{},...typeof e.repoId==`string`?{repoId:e.repoId}:{},...typeof e.serverId==`string`?{serverId:e.serverId}:{}}}catch{}return{kind:`workspace`}}function Hn(){let e={groups:[],gitDiffs:[],diffs:{paths:[]}};try{let t=JSON.parse(zn(`super-pi.workbench-scene.v1`)??`null`);return!t||typeof t!=`object`?e:{groups:Array.isArray(t.groups)?t.groups.filter(e=>e&&typeof e.workspaceId==`string`&&typeof e.roomId==`string`).slice(0,200):[],gitDiffs:Array.isArray(t.gitDiffs)?t.gitDiffs.filter(e=>e?.target&&typeof e.target.url==`string`&&e.target.url.startsWith(`/api/git?`)&&[e.target.path,e.target.label,e.target.comparison].every(e=>typeof e==`string`)).slice(0,200).map(e=>({target:e.target,workspaceId:e.workspaceId,revision:0,preview:e.preview===!0,reading:{}})):[],diffs:{paths:Array.isArray(t.diffs?.paths)?t.diffs.paths.filter(e=>typeof e==`string`).slice(0,200):[],...typeof t.diffs?.previewPath==`string`?{previewPath:t.diffs.previewPath}:{}},...[`session`,`file`,`diff`,`gitDiff`,`group`].includes(t.view)?{view:t.view}:{},...typeof t.gitDiffUrl==`string`?{gitDiffUrl:t.gitDiffUrl}:{}}}catch{return e}}function Un(e){Bn(`super-pi.workbench-scene.v1`,JSON.stringify({...e,gitDiffs:e.gitDiffs.map(e=>({target:e.target,workspaceId:e.workspaceId,preview:e.preview}))}))}var Wn=`汇报线只允许逐级上升,子会话默认不能直接对话;确有特殊情况可解锁。`;function Gn(e,t){return e?!(!t||t.id!==e||t.archivedAt):!1}function Kn(e){let{conversation:t,parent:n,directChildren:r,isTopLevelUnread:i=!1}=e;return t.hasOpenEscalation?`awaiting_decision`:r.some(e=>{if(e.archivedAt)return!1;let t=e.status===`running`||e.status===`waiting`||e.status===`awaiting_background`,n=!!e.hasOpenEscalation;return t||n})?`awaiting_subordinates`:Gn(t.parentConversationId,n)?t.hasPendingResult?`pending_report`:null:i?`unread`:null}function qn(e){let{conversation:t,directChildren:n}=e,r=t.hasOpenEscalation&&!t.parentConversationId&&t.escalationAudience===`boss`;return Kn({...e,conversation:{...t,hasOpenEscalation:r},directChildren:n.map(e=>e.hasOpenEscalation?{...e,hasOpenEscalation:!1}:e)})}function Jn(e){let{status:t,reportingState:n,awaitingQuestion:r,quietWhenRead:i=!1}=e;return r?`question`:t===`failed`?`failed`:n===`awaiting_decision`?`awaiting_decision`:t===`waiting`?`waiting`:t===`running`?`running`:t===`awaiting_background`?`awaiting_background`:n===`pending_report`?`pending_report`:n===`awaiting_subordinates`?`awaiting_subordinates`:n===`unread`?t===`completed`?`completed`:`unread`:i?`idle`:t===`completed`?`completed`:`idle`}var Yn=[`solution-designer`,`code-designer`,`code-auditor`,`document-organizer`];function Xn(e){return e.role===`assistant`?e.settledAt??e.createdAt:e.createdAt}function Zn(e){return e.filter(e=>e.role===`user`||![`queued`,`running`].includes(e.status)).slice().sort((e,t)=>Xn(e).localeCompare(Xn(t)))}function Qn(e,t){return Jn({status:e.status,quietWhenRead:!0,reportingState:e.lastReplyAt&&e.lastReplyAt>(t??``)?`unread`:null})}var $n=`super-pi-active-group-workspace`,er=e=>`super-pi-group-room:${e}`;function tr(){try{let e=localStorage.getItem($n),t=e&&localStorage.getItem(er(e));if(e&&t)return{workspaceId:e,roomId:t}}catch{}}function nr(e){try{e?.roomId?(localStorage.setItem(er(e.workspaceId),e.roomId),localStorage.setItem($n,e.workspaceId)):localStorage.removeItem($n)}catch{}}var rr=({workspaceId:e,roomId:t})=>`group:${JSON.stringify([e,t])}`;function ir(e){if(e.startsWith(`group:`))try{let t=JSON.parse(e.slice(6));if(Array.isArray(t)&&typeof t[0]==`string`&&typeof t[1]==`string`)return{workspaceId:t[0],roomId:t[1]}}catch{}}function ar(e,t,n,r){let i=new URLSearchParams({workspaceId:e});return t&&i.set(`id`,t),n&&i.set(`revision`,n),r&&i.set(`execution`,r),`/api/group-chats?${i}`}var or=class extends Error{status;constructor(e,t){super(e),this.status=t}};async function sr(e,t){let n=await je(e,t);if(n.status===204)return;let r=await n.json().catch(()=>void 0);if(!n.ok)throw new or(r?.error||`群聊请求失败(${n.status})。`,n.status);return r}function cr(e,t){return sr(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)})}function lr(e,t){return e.archivedAt?`idle`:t&&t.revision>=e.activity.revision?t.status:e.activity.status}function ur(e,t,n){return e.archivedAt?`idle`:Qn(t&&t.revision>=e.activity.revision?t:e.activity,n)}function dr(e,t){let n=JSON.stringify(e.filter(e=>!e.closedAt&&!e.id.startsWith(`pending:`)).map(e=>e.id)),[r,i]=(0,u.useState)({}),[a,o]=(0,u.useState)({}),[s,c]=(0,u.useState)(0),l=(0,u.useRef)(new Map),d=(0,u.useRef)(new Set),f=(0,u.useRef)(0),p=(0,u.useCallback)(()=>{f.current+=1,c(e=>e+1)},[]);(0,u.useEffect)(()=>{if(!t)return;let e=JSON.parse(n),r=new AbortController,a=f.current,o=()=>!r.signal.aborted&&a===f.current;for(let t of e)sr(ar(t),{signal:r.signal}).then(e=>{if(!o()||!e)return;for(let t of e)l.current.delete(t.id);let n=[...l.current.values()].filter(e=>e.workspaceId===t);i(r=>({...r,[t]:{rooms:[...n.reverse(),...e],loaded:!0}}))}).catch(()=>{o()&&i(e=>({...e,[t]:{...e[t],rooms:e[t]?.rooms??[],failed:!0}}))});return window.addEventListener(`focus`,p),()=>{window.removeEventListener(`focus`,p),r.abort()}},[n,t,s,p]);let m=(0,u.useCallback)(({id:e,workspaceId:t,activity:n,cloneRequests:r})=>{d.current.has(e)||(r&&i(i=>{let a=i[t];return a?{...i,[t]:{...a,rooms:a.rooms.map(t=>t.id===e&&t.activity.revision<=n.revision?{...t,activity:n,cloneRequests:r}:t)}}:i}),o(t=>t[e]&&t[e].revision>=n.revision?t:{...t,[e]:n}))},[]);return{index:r,reload:p,remember:(0,u.useCallback)((e,t=!1)=>{if(d.current.has(e.id))return;let{id:n,workspaceId:r,title:a,updatedAt:o,archivedAt:s,activity:c}=e,u={id:n,workspaceId:r,title:a,updatedAt:o,archivedAt:s,activity:c};m(u),t&&l.current.set(u.id,u),i(t=>{let n=t[e.workspaceId],r=n?.rooms??[],i=r.find(t=>t.id===e.id);return i&&(i.updatedAt>u.updatedAt||i.title===u.title&&i.archivedAt===u.archivedAt)?t:{...t,[e.workspaceId]:{...n,rooms:i?r.map(t=>t.id===e.id?u:t):[u,...r]}}})},[m]),forget:(0,u.useCallback)(({workspaceId:e,roomId:t})=>{d.current.add(t),l.current.delete(t),o(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),i(n=>{let r=n[e];return r?{...n,[e]:{...r,rooms:r.rooms.filter(e=>e.id!==t)}}:n})},[]),activities:a,recordActivity:m}}function fr(e){return JSON.stringify([e.workspaceId,e.conversationId?`session`:`group`,e.conversationId??e.roomId])}function pr(e,t,n){let{connections:r}=ce(),i=(0,u.useRef)({conversations:t,onMerge:n});i.current={conversations:t,onMerge:n};let a=JSON.stringify(r.filter(e=>e.enabled).map(e=>e.id));(0,u.useEffect)(()=>{let t=!1,n=new Set,r=new Set,o=new Set,s=async a=>{if(r.has(a))return;r.add(a);let s=new AbortController;n.add(s);let c=window.setTimeout(()=>s.abort(),12e3),l=!1;try{let n=await je(`/api/read-receipts`,{signal:s.signal},a);if(!n.ok||!n.headers.get(`content-type`)?.includes(`application/json`))return;let r=(await n.json()).receipts;if(t||!Array.isArray(r))return;let c=new Map(r.map(e=>[fr(e),e.at])),u=t=>{for(let n of t){let t=n.conversationId??rr({workspaceId:n.workspaceId,roomId:n.roomId});n.at>(e.current[t]??``)&&(e.current[t]=n.at,l=!0)}};u(r),l&&!t&&(i.current.onMerge(),l=!1);let d=[];for(let[t,n]of Object.entries(e.current)){let e;if(t.startsWith(`group:`))try{let[r,i]=JSON.parse(t.slice(6));e={workspaceId:r,roomId:i,at:n}}catch{continue}else{let r=i.current.conversations.find(e=>e.id===t);r&&(e={workspaceId:r.workspaceId,conversationId:t,at:n})}e&&!o.has(fr(e))&&h(e.workspaceId).server===a&&n>(c.get(fr(e))??``)&&d.push(e)}for(let e=0;e<d.length&&!t;e+=500){let t=d.slice(e,e+500),n=e=>je(`/api/read-receipts`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({receipts:e}),signal:s.signal},a),r=await n(t);if(r.ok)u((await r.json()).receipts??[]);else if(r.status===400)for(let e of t){let t=await n([e]);t.ok?u((await t.json()).receipts??[]):t.status===400&&o.add(fr(e))}}}catch{}finally{l&&!t&&i.current.onMerge(),window.clearTimeout(c),n.delete(s),r.delete(a)}},c=()=>{for(let e of JSON.parse(a))s(e)};c();let l=window.setInterval(c,3e3);return window.addEventListener(`focus`,c),()=>{t=!0,window.clearInterval(l),window.removeEventListener(`focus`,c);for(let e of n)e.abort()}},[a,e])}function mr(e,t){let n=e.trim();if(!n||n===t)return{path:t,prefix:``};let r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`));return r<0?n===`~`?{path:`~`,prefix:``}:{path:t,prefix:n}:{path:n.slice(0,r+1),prefix:n.slice(r+1)}}var hr=`操作没有完成。`,gr=`操作没有完成,没有拿到失败原因。可以重试,或查看服务端日志。`,_r=160,vr=/[\u3400-\u9fff]/,yr=/^(?:bad request|\{\s*"detail"\s*:\s*"bad request"\s*\})$/i,br=/failed to fetch|fetch failed|network\s*error|econnrefused|econnreset|enotfound|eai_again|socket hang up|connection refused|connection reset|broken pipe|load failed/i,xr=/timeout|timed out|etimedout/i,Sr=/aborterror|aborted|the user aborted a request|operation was aborted/i,Cr=/node-pty|pty unavailable|terminal unavailable/i,wr=/could not find[^\n]*\bpi\b|pi command not found|pi (?:is )?not (?:installed|found)|not recognized as an internal or external command/i,Tr=/\b401\b|\b403\b|unauthorized|forbidden|invalid api key|incorrect api key|authentication failed|insufficient permission/i,Er=/\b5(?:00|01|02|03|04)\b|internal server error|bad gateway|service unavailable|gateway timeout/i,Dr=/\bhttp\s*(?:status\s*)?[:=]?\s*(\d{3})\b|\bstatus(?:\s*code)?\s*[:=]\s*(\d{3})\b/i,Or=/\b(ENOENT|EACCES|EPERM|EBUSY|EISDIR|ENOTDIR|EMFILE|ENOSPC)\b/;function kr(e){let t=``;if(e==null)t=``;else if(typeof e==`string`)t=e;else if(e instanceof Error)t=e.message;else if(typeof e==`object`&&typeof e.message==`string`)t=e.message;else try{t=String(e)}catch{t=``}return t.trim().replace(/^error:\s*/i,``).replace(/^\[object object\]$/i,``).trim()}var Ar=/^\{[\s{}]*\}$|^\[[\s[\]]*\]$|^(undefined|null|NaN)$|^\[object [\w\s]+\]$/i;function jr(e){let t=e.replace(/\s+/g,` `).trim().replace(/\bsk-[A-Za-z0-9_-]{6,}/g,`sk-***`).replace(/([?&](?:api[_-]?key|access[_-]?token|token)=)[^&\s]+/gi,`$1***`);return t.length>_r?`${t.slice(0,_r)}…`:t}function Mr(e,t){return e.toLowerCase().includes(t.toLowerCase())?e:`${e}(${jr(t)})`}function Nr(e,t){let n=kr(e);if(!n||Ar.test(n))return t??gr;if(vr.test(n))return n;if(yr.test(n))return`请求被拒绝(Bad Request)。返回方没有提供具体原因。`;if(br.test(n))return Mr(`连接不上 Super Pi 服务,请稍后再试。`,n);if(xr.test(n))return Mr(`等待服务响应超时,请稍后再试。`,n);if(Sr.test(n))return Mr(`请求被中断,请重试。`,n);if(Cr.test(n))return Mr(`终端组件没有加载,请重启 Super Pi 后再试。`,n);if(wr.test(n))return Mr(`找不到 Pi 命令,请确认 Pi 已安装并且在命令行里可用。`,n);let r=Number(Dr.exec(n)?.[1]??Dr.exec(n)?.[2]??0);if(r===401||r===403)return Mr(`没有权限完成这个操作,请检查鉴权配置。`,n);if(r>=500)return Mr(`服务端没有完成这次请求(HTTP ${r}),请稍后再试。`,n);if(r>=400)return Mr(`请求被拒绝(HTTP ${r})。`,n);if(Tr.test(n))return Mr(`鉴权失败,请检查对应的 key 或权限配置。`,n);if(Er.test(n))return Mr(`服务端出错了,请稍后再试。`,n);let i=Or.exec(n)?.[1];return Mr(i===`ENOENT`?`找不到对应的文件或目录。`:i===`EACCES`||i===`EPERM`?`没有访问这个文件的权限。`:i===`EBUSY`?`文件正被其他程序占用,请稍后再试。`:i===`ENOSPC`?`磁盘空间不足,这个操作没有完成。`:i?`文件操作没有完成,请检查路径后重试。`:t??hr,n)}function Pr(e){let t=kr(e);if(t&&!Ar.test(t))return Nr(e).includes(t)?void 0:t}function Fr(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?``:t.slice(n+1).toLowerCase()}var Ir={ts:`code`,tsx:`code`,js:`code`,jsx:`code`,mjs:`code`,cjs:`code`,mts:`code`,cts:`code`,py:`code`,rb:`code`,go:`code`,rs:`code`,java:`code`,kt:`code`,kts:`code`,scala:`code`,c:`code`,h:`code`,cc:`code`,cpp:`code`,hpp:`code`,cs:`code`,swift:`code`,m:`code`,mm:`code`,php:`code`,pl:`code`,pm:`code`,lua:`code`,r:`code`,jl:`code`,ex:`code`,exs:`code`,erl:`code`,hs:`code`,dart:`code`,nim:`code`,zig:`code`,vue:`code`,svelte:`code`,astro:`code`,sh:`code`,bash:`code`,zsh:`code`,fish:`code`,ps1:`code`,bat:`code`,cmd:`code`,sql:`code`,graphql:`code`,gql:`code`,proto:`code`,tf:`code`,tfvars:`code`,hcl:`code`,sol:`code`,md:`markup`,mdx:`markup`,markdown:`markup`,txt:`markup`,text:`markup`,rst:`markup`,adoc:`markup`,org:`markup`,yaml:`config`,yml:`config`,toml:`config`,ini:`config`,cfg:`config`,conf:`config`,xml:`config`,env:`config`,properties:`config`,gitignore:`config`,editorconfig:`config`,eslintrc:`config`,prettierrc:`config`,css:`style`,scss:`style`,sass:`style`,less:`style`,stylus:`style`,pcss:`style`,postcss:`style`,png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,bmp:`image`,webp:`image`,avif:`image`,ico:`image`,svg:`image`,tif:`image`,tiff:`image`,heic:`image`,psd:`image`,ai:`image`,json:`data`,jsonc:`data`,json5:`data`,csv:`data`,tsv:`data`,parquet:`data`,db:`data`,sqlite:`data`,sqlite3:`data`,ndjson:`data`,zip:`archive`,tar:`archive`,gz:`archive`,tgz:`archive`,bz2:`archive`,xz:`archive`,"7z":`archive`,rar:`archive`,zst:`archive`,jar:`archive`,war:`archive`,whl:`archive`,woff:`font`,woff2:`font`,ttf:`font`,otf:`font`,eot:`font`,exe:`binary`,dll:`binary`,so:`binary`,dylib:`binary`,bin:`binary`,o:`binary`,obj:`binary`,a:`binary`,lib:`binary`,class:`binary`,node:`binary`,pyc:`binary`,pyo:`binary`,pack:`binary`,idx:`binary`,iso:`binary`,dmg:`binary`,msi:`binary`,apk:`binary`,deb:`binary`,rpm:`binary`,pdf:`binary`,doc:`binary`,docx:`binary`,xls:`binary`,xlsx:`binary`,ppt:`binary`,pptx:`binary`,odt:`binary`,ods:`binary`,odp:`binary`,wasm:`binary`},Lr={dockerfile:`config`,containerfile:`config`,makefile:`code`,cmakelists:`code`,rakefile:`code`,gemfile:`config`,procfile:`config`,license:`markup`,licence:`markup`,notice:`markup`,readme:`markup`,changelog:`markup`,authors:`markup`,contributing:`markup`,".gitignore":`config`,".gitattributes":`config`,".gitmodules":`config`,".npmrc":`config`,".nvmrc":`config`,".env":`config`};function Rr(e){let t=Lr[e.slice(e.lastIndexOf(`/`)+1).toLowerCase()];if(t)return t;let n=Fr(e);return n?Ir[n]??`generic`:`generic`}var zr={code:[`M6 4.5 2.5 8 6 11.5`,`M10 4.5 13.5 8 10 11.5`,`M9.2 3.5 6.8 12.5`],markup:[`M4 2.5h5l3 3v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1z`,`M9 2.5v3h3`,`M5.5 8.5h5`,`M5.5 11h3.5`],config:[`M8 10.2a2.2 2.2 0 1 0 0-4.4 2.2 2.2 0 0 0 0 4.4z`,`M8 1.8v1.6`,`M8 12.6v1.6`,`M1.8 8h1.6`,`M12.6 8h1.6`,`M3.6 3.6l1.1 1.1`,`M11.3 11.3l1.1 1.1`,`M12.4 3.6l-1.1 1.1`,`M4.7 11.3l-1.1 1.1`],style:[`M8 13.5a5.5 5.5 0 1 1 0-11c3 0 5.5 2 5.5 4.5 0 1.4-1.1 2.2-2.3 2.2h-1c-.9 0-1.6.7-1.6 1.5 0 .4.2.7.4 1 .2.3.4.6.4 1a1.3 1.3 0 0 1-1.4.8z`,`M5.6 6.8h.01`,`M8.4 5.2h.01`,`M11 6.9h.01`],image:[`M2.5 4.5a1 1 0 0 1 1-1h9a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-7z`,`M2.5 10.5 6 7.5l2.5 2 2-1.5 3 2.5`,`M5.8 6.4h.01`],data:[`M2.5 3.5h11v9h-11z`,`M2.5 8h11`,`M8 3.5v9`],archive:[`M2.5 5.5h11v8h-11z`,`M1.5 2.5h13v3h-13z`,`M6.8 8.5h2.4`],font:[`M3.5 13 8 3l4.5 10`,`M5.4 9.6h5.2`],binary:[`M2.5 4.5h11v7h-11z`,`M5 7h.01`,`M8 7h.01`,`M11 7h.01`,`M5 9.5h.01`,`M8 9.5h.01`],generic:[`M4 2.5h5l3 3v8a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-10a1 1 0 0 1 1-1z`,`M9 2.5v3h3`],folder:[`M2.5 4.5a1 1 0 0 1 1-1h3l1.5 2h4.5a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-8z`],"folder-open":[`M2.5 12.5v-8a1 1 0 0 1 1-1h3l1.5 2h4.5a1 1 0 0 1 1 1v1`,`M2.5 12.5 4.6 6.8a1 1 0 0 1 .95-.7h8.1a.6.6 0 0 1 .55.85L12.9 12.5a1 1 0 0 1-.95.7H3.5a1 1 0 0 1-1-1z`]};function Br({path:e,category:t,size:n=14}){let r=t??Rr(e??``),i=zr[r]??zr.generic;return(0,L.jsx)(`svg`,{className:`file-icon file-icon-${r}`,"data-file-icon":r,width:n,height:n,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:i.map((e,t)=>(0,L.jsx)(`path`,{d:e},t))})}var Vr={sessions:`会话`,files:`资源管理器`,terminal:`终端`,git:`Git`,main:`任务`,projects:`项目`,tools:`工具`,rsi:`RSI · 观察与改进`},Hr={sessions:`left`,files:`left`,terminal:`right`,git:`right`,main:`right`,projects:`right`,tools:`right`,rsi:`right`},Ur=[`sessions`,`files`,`main`,`terminal`,`git`,`rsi`,`projects`,`tools`],Wr=`super-pi.workbench.layout.v1`,Gr=e=>typeof e==`string`&&Ur.includes(e);function Kr(){return{sides:{...Hr},order:[...Ur],unpinned:[],leftView:`sessions`,leftClosed:!1,rightClosed:!1}}function qr(){let e=Kr();try{let t=JSON.parse(window.localStorage.getItem(Wr)??`null`);if(!t)return e;let n={...Hr};for(let e of Ur)e!==`sessions`&&(t.sides?.[e]===`left`||t.sides?.[e]===`right`)&&(n[e]=t.sides[e]);let r=Array.isArray(t.order)?t.order.filter(Gr):[];return{sides:n,order:[...new Set([...r,...Ur])],unpinned:Array.isArray(t.unpinned)?t.unpinned.filter(Gr).filter(e=>e!==`sessions`):[],leftView:Gr(t.leftView)?t.leftView:`sessions`,leftClosed:t.leftClosed===!0,rightClosed:t.rightClosed===!0}}catch{return e}}function Jr(e){try{window.localStorage.setItem(Wr,JSON.stringify(e))}catch{}}var Yr={rsi:`M5 4h14v12H9l-4 4V4zM8 8h8m-8 4h4m3 0 2 2 3-3`,sessions:`M4 4h16v12H9l-5 4V4zM8 8h8m-8 4h5`,group:`M3 4h14v10H8l-5 4V4zM8 9h4m7 0h2v10h-7l-3 2v-4`,"group-add":`M3 4h14v10H8l-5 4V4zM8 9h4m6 7v6m-3-3h6`,archive:`M4 4h16v5H4zM6 9v11h12V9M10 13h4`,delete:`M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 10v7m4-7v7`,files:`M3 6h7l2 2h9v11H3zM3 9h18`,terminal:`M3 4h18v16H3zM7 8l4 4-4 4m7 0h4`,git:`M7 7v10m10-10v3a4 4 0 0 1-4 4H7M7 3a2 2 0 1 0 0 4 2 2 0 1 0 0-4zm0 14a2 2 0 1 0 0 4 2 2 0 1 0 0-4zM17 3a2 2 0 1 0 0 4 2 2 0 1 0 0-4z`,history:`M3 10a9 9 0 1 1 2 8M3 3v7h7M12 7v5l3 2`,graph:`M6 6v4m0 4v4M8 4h4a6 6 0 0 1 6 6m0 4a6 6 0 0 1-6 6H8M6 2a2 2 0 1 0 0 4 2 2 0 0 0 0-4m0 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4m0 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4M18 10a2 2 0 1 0 0 4 2 2 0 0 0 0-4`,stash:`M6 14V3h8l4 4v7M14 3v4h4M3 14h18v7H3zM9 17h6`,main:`m4 6 2 2 3-4m3 3h8m-16 6 2 2 3-4m3 3h8m-16 6 2 2 3-4m3 3h8`,projects:`M3 4h18v16H3zM3 8h18M9 8v12M15 8v12`,worktree:`M9 2h6v5H9zM12 7v4M6 11h12M6 11v3m12-3v3M2 14h3l2 2h3v6H2zM14 14h3l2 2h3v6h-8z`,tools:`M4 4h6v6H4zm10 0h6v6h-6zM4 14h6v6H4zm10 0h6v6h-6z`,search:`M11 3a7 7 0 1 0 0 14 7 7 0 1 0 0-14zm5 12 5 5`,settings:`M10 3h4l.6 2.5 2 .9L19 5l2 3.5-1.9 1.7v2.4l1.9 1.8-2 3.4-2.4-.9-2 .9L14 21h-4l-.6-2.6-2-.9-2.4.9-2-3.4 1.9-1.8v-2.4L3 8.5 5 5l2.4 1.4 2-.9zM12 9a3 3 0 1 0 0 6 3 3 0 1 0 0-6z`,help:`M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zm-2.8 6.3a2.8 2.8 0 0 1 5.6 0c0 2-2.8 2.3-2.8 4M12 17h.01`,update:`M12 3v12m-4-4 4 4 4-4M4 15v5h16v-5`,restart:`M12 3v9M6 6a8 8 0 1 0 12 0`,more:`M5 12h.01M12 12h.01M19 12h.01`,close:`M6 6l12 12M18 6 6 18`,back:`M19 12H5m7-7-7 7 7 7`,forward:`M5 12h14m-7-7 7 7-7 7`,split:`M3 4h18v16H3zM12 4v16`,pin:`m14 3 7 7-3 1-3 4-1 3-8-8 3-1 4-3zm-4 11-6 6`};function Xr({name:e}){return(0,L.jsx)(`svg`,{className:`workbench-icon`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.55`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:Yr[e]})})}function Zr({side:e,views:t,unpinned:n,active:r,previous:i,onSelect:a,onSearch:o,onArrange:s,onReorder:c,children:l,searchActive:d}){let f=t.filter(e=>n.includes(e)),p=t.filter(e=>!n.includes(e)),[m,h]=(0,u.useState)(),g=m&&p.includes(m)?m:r&&p.includes(r)?r:p[0],_=(0,u.useRef)(new Map),v=(0,u.useRef)(null),[y,b]=(0,u.useState)(),x=(0,u.useRef)(null),S=(0,u.useRef)(void 0),[C,w]=(0,u.useState)();return(0,u.useEffect)(()=>{if(!y)return;let e=()=>b(void 0),t=t=>{t.target instanceof Node&&!x.current?.contains(t.target)&&e()},n=t=>{t.key!==`Escape`||t.defaultPrevented||(t.preventDefault(),e(),_.current.get(y.view)?.focus())};return x.current?.querySelector(`button`)?.focus(),window.addEventListener(`pointerdown`,t),window.addEventListener(`keydown`,n),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`pointerdown`,t),window.removeEventListener(`keydown`,n),window.removeEventListener(`resize`,e)}},[y]),(0,u.useEffect)(()=>{let e=e=>{let t=v.current;t?.open&&e.target instanceof Node&&!t.contains(e.target)&&(t.open=!1)};return window.addEventListener(`pointerdown`,e),()=>window.removeEventListener(`pointerdown`,e)},[]),(0,L.jsxs)(`div`,{className:`workbench-activity workbench-activity-${e}`,"data-workbench-activity":e,children:[(0,L.jsx)(`div`,{className:`workbench-activity-views`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":e===`left`?`左侧视图`:`右侧视图`,children:p.map((t,n)=>(0,L.jsx)(`button`,{type:`button`,role:`tab`,id:t===`sessions`?`workbench-sessions-tab`:`right-tab-${t}`,className:`right-tab workbench-activity-button${r===t?` right-tab-active`:``}`,"data-workbench-view":t,"data-right-tab":t===`sessions`?void 0:t,"data-right-rail-open":e===`right`&&!r&&i===t?`1`:void 0,"aria-controls":t===`sessions`?`workbench-sessions`:`right-panel-${t}`,"aria-selected":r===t,tabIndex:t===g?0:-1,draggable:t!==`sessions`,"data-workbench-drop":C===t?`1`:void 0,onContextMenu:n=>{if(t===`sessions`)return;n.preventDefault();let r=n.currentTarget.getBoundingClientRect();b({view:t,x:Math.max(4,Math.min(window.innerWidth-200,n.clientX||(e===`left`?r.right:r.left-196))),y:Math.max(4,Math.min(window.innerHeight-146,n.clientY||r.top))})},onDragStart:e=>{t!==`sessions`&&(S.current=t,e.dataTransfer.setData(`text/plain`,t),e.dataTransfer.effectAllowed=`move`)},onDragOver:e=>{S.current&&t!==`sessions`&&S.current!==t&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,w(t))},onDragLeave:()=>w(e=>e===t?void 0:e),onDrop:e=>{let n=S.current;n&&t!==`sessions`&&(e.preventDefault(),c(n,t),S.current=void 0,w(void 0))},onDragEnd:()=>{S.current=void 0,w(void 0)},ref:e=>{e?_.current.set(t,e):_.current.delete(t)},title:Vr[t],"aria-label":Vr[t],onFocus:()=>h(t),onClick:()=>a(t),onKeyDown:r=>{if(t!==`sessions`&&(r.key===`ContextMenu`||r.shiftKey&&r.key===`F10`)){r.preventDefault();let n=r.currentTarget.getBoundingClientRect();b({view:t,x:Math.max(4,e===`left`?n.right:n.left-196),y:Math.max(4,Math.min(window.innerHeight-146,n.top))});return}let i=r.key===`Home`?p[0]:r.key===`End`?p.at(-1):r.key===`ArrowDown`?p[(n+1)%p.length]:r.key===`ArrowUp`?p[(n+p.length-1)%p.length]:void 0;i&&(r.preventDefault(),_.current.get(i)?.focus())},children:(0,L.jsx)(Xr,{name:t})},t))}),o&&(0,L.jsx)(`button`,{type:`button`,className:`workbench-activity-button${d?` right-tab-active`:``}`,"data-workbench-search":`1`,title:`搜索`,"aria-label":`搜索`,"aria-pressed":!!d,onClick:o,children:(0,L.jsx)(Xr,{name:`search`})}),f.length>0&&(0,L.jsxs)(`details`,{className:`workbench-menu workbench-more`,ref:v,onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.open&&(e.preventDefault(),e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},children:[(0,L.jsx)(`summary`,{className:`workbench-activity-button`,title:`更多视图`,"aria-label":`更多视图`,children:(0,L.jsx)(Xr,{name:`more`})}),(0,L.jsx)(`div`,{className:`workbench-menu-items`,children:f.map(e=>(0,L.jsxs)(`button`,{type:`button`,"data-workbench-extra":e,"aria-pressed":r===e,onClick:t=>{t.currentTarget.closest(`details`)?.removeAttribute(`open`),r===e?v.current?.querySelector(`summary`)?.focus():a(e)},children:[(0,L.jsx)(Xr,{name:e}),Vr[e]]},e))})]}),y&&(0,Ie.createPortal)((0,L.jsx)(`div`,{ref:x,className:`workbench-menu-items workbench-context-menu`,style:{left:y.x,top:y.y},"aria-label":`${Vr[y.view]}布局`,children:Qr(e,!0).map(([e,t])=>(0,L.jsx)(`button`,{type:`button`,"data-workbench-context-action":e,onClick:()=>{b(void 0),s(y.view,e),e!==`move`&&e!==`pin`&&_.current.get(y.view)?.focus()},children:t},e))}),document.body),l&&(0,L.jsx)(`div`,{className:`workbench-activity-utilities`,children:l})]})}var Qr=(e,t)=>[[`move`,e===`left`?`移到右侧`:`移到左侧`],[`pin`,t?`从活动栏取消固定`:`固定到活动栏`],[`up`,`在活动栏上移`],[`down`,`在活动栏下移`]];function $r({view:e,side:t,pinned:n,onArrange:r}){let i=Qr(t,n);return(0,L.jsxs)(`details`,{className:`workbench-menu workbench-panel-menu`,children:[(0,L.jsx)(`summary`,{title:`视图布局`,"aria-label":`${Vr[e]}布局`,"data-workbench-panel-menu":e,children:(0,L.jsx)(Xr,{name:`more`})}),(0,L.jsx)(`div`,{className:`workbench-menu-items`,children:i.map(([t,n])=>(0,L.jsx)(`button`,{type:`button`,"data-workbench-arrange":t,onClick:n=>{n.currentTarget.closest(`details`)?.removeAttribute(`open`),r(e,t)},children:n},t))})]})}var ei={file:`M8 3h6l4 4v13H6V3h2m6 0v5h4M9 13h6m-3-3v6`,folder:`M3 7V5h7l2 2h9v12H3V7m6 6h6m-3-3v6`,refresh:`M19 9a7 7 0 0 0-12-3L4 9m0-5v5h5m-4 6a7 7 0 0 0 12 3l3-3m0 5v-5h-5`,collapse:`M8 5h12v12M4 9h12v12H4zm3 6h6`,locate:`M12 2v4m0 12v4M2 12h4m12 0h4M7 12a5 5 0 1 0 10 0 5 5 0 1 0-10 0`,upload:`M12 15V4m-4 4 4-4 4 4M4 14v5h16v-5`,download:`M12 4v11m-4-4 4 4 4-4M4 15v5h16v-5`,more:`M5 12h.01M12 12h.01M19 12h.01`,search:`M11 5a6 6 0 1 0 0 12 6 6 0 1 0 0-12m4.5 10.5L20 20`,right:`m9 6 6 6-6 6`,down:`m6 9 6 6 6-6`,close:`m6 6 12 12M18 6 6 18`,trash:`M4 6h16M9 6V3h6v3m3 0-1 14H7L6 6m4 4v6m4-6v6`,copy:`M8 8h12v12H8zm8-4H4v12`,reference:`M15 12a3 3 0 1 0-6 0 3 3 0 0 0 6 0m0-3v5c0 2 5 3 5-2a8 8 0 1 0-3 6`,rename:`M4 7h6m4 0h6v10h-6m-4 0H4zm8-11v12m-2-12h4m-4 12h4`,move:`M3 7V5h7l2 2h9v12H3zm6 6h6m-3-3 3 3-3 3`,changes:`M7 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 0v10m0 4a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm10-12a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm0 0c0 5-5 5-10 5`,save:`M4 4h13l3 3v13H4zm4 0v6h8V4M8 20v-6h8v6`};function ti({name:e}){return(0,L.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:e===`more`?3.3:1.65,strokeLinecap:`round`,strokeLinejoin:`round`,className:`explorer-glyph`,"aria-hidden":`true`,children:(0,L.jsx)(`path`,{d:ei[e]})})}function ni(e){let t=e.getBoundingClientRect();return{x:t.right,y:t.bottom+4,origin:e,alignEnd:!0,initialFocus:!0}}function ri({label:e,anchor:t,close:n,children:r}){let i=(0,u.useRef)(null),a=(0,u.useRef)(n);a.current=n;let[o,s]=(0,u.useState)({left:t.x,top:t.y});return(0,u.useLayoutEffect)(()=>{let e=i.current;if(!e)return;let n=e.getBoundingClientRect();s({left:Math.max(6,Math.min(t.alignEnd?t.x-n.width:t.x,window.innerWidth-n.width-6)),top:Math.max(6,Math.min(t.y,window.innerHeight-n.height-6))}),t.initialFocus?e.querySelector(`[role="menuitem"]`)?.focus({preventScroll:!0}):e.focus({preventScroll:!0});let r=n=>{let r=n.target;!e.contains(r)&&!t.origin.contains(r)&&a.current(!1)},o=()=>a.current(!1),c=n=>{let r=n.target;r instanceof Element&&!e.contains(r)&&r.contains(t.origin)&&a.current(!1)};return window.addEventListener(`pointerdown`,r,!0),window.addEventListener(`resize`,o),window.addEventListener(`scroll`,c,!0),()=>{window.removeEventListener(`pointerdown`,r,!0),window.removeEventListener(`resize`,o),window.removeEventListener(`scroll`,c,!0)}},[t]),(0,Ie.createPortal)((0,L.jsx)(`div`,{className:`file-context-menu`,"data-file-context-menu":`1`,ref:i,style:o,role:`menu`,"aria-label":e,tabIndex:-1,onContextMenu:e=>e.preventDefault(),onKeyDown:e=>{if(e.key===`Escape`||e.key===`Tab`){e.preventDefault(),e.stopPropagation(),n(!0);return}let t=[...e.currentTarget.querySelectorAll(`[role="menuitem"]`)],r=t.indexOf(document.activeElement),i=t.length;i&&[`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key)&&(e.preventDefault(),t[e.key===`Home`?0:e.key===`End`?i-1:e.key===`ArrowDown`?(r+1)%i:r<=0?i-1:r-1]?.focus())},children:r}),document.body)}function ii({root:e,path:t,reveal:n}){let r=t.split(`/`),i=r.at(-1)??t,a=r.slice(0,-1);return(0,L.jsxs)(`nav`,{className:`file-breadcrumbs`,"aria-label":`文件路径`,title:t,children:[(0,L.jsxs)(`button`,{className:`file-crumb file-crumb-root`,type:`button`,onClick:()=>n(``,!0),title:`定位 ${e}`,children:[(0,L.jsx)(Br,{category:`folder`}),(0,L.jsx)(`span`,{children:e})]}),a.map((e,t)=>{let r=a.slice(0,t+1).join(`/`);return(0,L.jsxs)(`span`,{className:`file-crumb-step`,children:[(0,L.jsx)(ti,{name:`right`}),(0,L.jsx)(`button`,{className:`file-crumb`,type:`button`,title:`定位 ${r}`,"data-file-crumb":r,onClick:()=>n(r,!0),children:e})]},r)}),(0,L.jsxs)(`span`,{className:`file-crumb-step file-crumb-leaf`,children:[(0,L.jsx)(ti,{name:`right`}),(0,L.jsxs)(`button`,{className:`file-crumb`,type:`button`,"aria-current":`location`,"data-file-crumb":t,onClick:()=>n(t,!1),title:`定位 ${t}`,children:[(0,L.jsx)(Br,{path:t}),(0,L.jsx)(`span`,{children:i})]})]})]})}async function ai(e){try{if(navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}let t=document.activeElement,n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.cssText=`position:fixed;top:0;left:0;width:1px;height:1px;padding:0;border:0;opacity:0;pointer-events:none`,document.body.appendChild(n);try{return n.focus({preventScroll:!0}),n.select(),n.setSelectionRange(0,n.value.length),document.execCommand(`copy`)}catch{return!1}finally{n.remove(),t?.isConnected&&t.focus({preventScroll:!0})}}function oi(e){let t=new Map,n=[],r=0,i=1,a=(e,t)=>{let r=t??n.indexOf(!1),a=r<0?n.length:r;return n[a]=!0,i=Math.max(i,a+1),{index:a,color:e}},o=e.map(({hash:e,parents:i})=>{let o=t.get(e),s=o??a(r++);t.delete(e),n[s.index]=!1;let c=[...t.values()],l=[...new Set(i)].map((e,n)=>{let i=t.get(e);return i||(i=n===0?a(s.color,s.index):a(r++),t.set(e,i)),{hash:e,lane:i}});return{node:s,incoming:o!==void 0,through:c,parents:l}});return{columns:i,rows:o}}function si(e,t){if(t===`untracked`||e.startsWith(`?`))return{label:`U`,kind:`untracked`,slot:`worktree`};let n=(t===`staged`?e[0]:e[1])||e[0]||`M`;return n===`A`?{label:`A`,kind:`added`,slot:t===`staged`?`index`:`worktree`}:n===`D`?{label:`D`,kind:`deleted`,slot:t===`staged`?`index`:`worktree`}:n===`R`?{label:`R`,kind:`renamed`,slot:t===`staged`?`index`:`worktree`}:{label:`M`,kind:`modified`,slot:t===`staged`?`index`:`worktree`}}var ci={untracked:`未跟踪(U):尚未加入 Git,暂存后会加入版本管理`,added:`新增(A)`,modified:`已修改(M)`,deleted:`已删除(D)`,renamed:`已重命名(R)`},li=e=>e.path.endsWith(`/`),ui=[{id:`changes`,title:`工作区改动`,search:`搜索文件名或路径`,icon:`main`},{id:`log`,title:`提交历史`,search:`搜索提交说明或哈希`,icon:`history`},{id:`graph`,title:`提交图`,search:``,icon:`graph`},{id:`branches`,title:`分支`,search:`搜索本地或远程分支`,icon:`git`},{id:`stash`,title:`Stash`,search:`搜索贮藏记录`,icon:`stash`},{id:`worktrees`,title:`工作树`,search:``,icon:`worktree`}],di={graph:`提交图:查看提交历史及分叉、汇合关系`,branches:`分支:查看和管理本地、远程分支`,stash:`Stash:临时收起未提交改动,稍后恢复`,worktrees:`工作树:同一仓库的多个独立工作目录`},fi=`请选择具体工作区或 session 以确定工作目录`,pi=e=>e===`changes`||e===`log`||e===`stash`,mi=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},hi=15e3,z=(e,t)=>new mi(408,{error:`请求超时:${t/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function gi(e,t,n=hi){let r=new AbortController,i=setTimeout(()=>r.abort(),n);try{let n=t?.signal?AbortSignal.any([t.signal,r.signal]):r.signal,i=await je(e,{...t,signal:n}),a;try{a=await i.json()}catch(e){if(i.ok)throw e}if(!i.ok)throw new mi(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw r.signal.aborted?z(e,n):t}finally{clearTimeout(i)}}var _i=e=>e instanceof mi?e:new mi(0,{error:e instanceof Error?e.message:`读取失败`}),vi=e=>encodeURIComponent(e),yi=e=>e?`&cwd=${vi(e)}`:``,bi=(e,t)=>`/api/git?workspaceId=${vi(e)}&op=status${yi(t)}`,xi=(e,t,n,r)=>`/api/git?workspaceId=${vi(e)}&op=diff&path=${vi(t)}${n?`&staged=1`:``}${yi(r)}`;async function Si(e,t,n={},r){let i=t===`draft`?35e3:[`fetch`,`pull`,`push`].includes(t)?65e3:hi;return gi(`/api/git?workspaceId=${vi(e)}&op=${vi(t)}${yi(r)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)},i)}var Ci=20,wi=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`})},Ti=e=>e.detached||e.branch===null?`(未在任何分支上)`:e.unborn?`${e.branch}(起始提交)`:e.branch,Ei=e=>{let t=[];return e.ahead!==null&&t.push(`↑${e.ahead}`),e.behind!==null&&t.push(`↓${e.behind}`),t.length===0?null:t.join(` `)},Di=[{key:`staged`,title:`已暂存`},{key:`unstaged`,title:`未暂存`},{key:`untracked`,title:`未跟踪`}];function Oi({path:e,untracked:t=!1,onCancel:n,onConfirm:r}){let i=(0,u.useRef)(null),a=(0,u.useRef)(null);(0,u.useEffect)(()=>{a.current?.focus();let e=e=>{e.key===`Escape`&&(e.preventDefault(),n())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let o=(0,L.jsx)(`div`,{className:`overlay git-confirm-overlay`,"data-git-confirm-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&n()},children:(0,L.jsxs)(`div`,{className:`picker git-confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`git-confirm-title`,tabIndex:-1,ref:i,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.key!==`Tab`)return;let t=i.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), [tabindex]:not([tabindex='-1'])`));if(n.length===0)return;let r=n[0],a=n[n.length-1];e.shiftKey?document.activeElement===r&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),r.focus())},"data-git-confirm-dialog":`1`,children:[(0,L.jsx)(`h2`,{id:`git-confirm-title`,className:`git-confirm-title`,children:`确认丢弃更改?`}),(0,L.jsx)(`p`,{className:`git-confirm-desc`,children:t?`将以下未跟踪文件或目录移到资源管理器回收站:`:`即将丢弃以下文件的所有未暂存修改,恢复暂存区版本;已暂存内容不受影响:`}),(0,L.jsx)(`div`,{className:`git-confirm-path`,"data-git-confirm-path":e,title:e,children:e}),(0,L.jsx)(`p`,{className:`git-confirm-warning`,"data-git-confirm-warning":`1`,children:t?`可在资源管理器的回收站中恢复。`:`⚠ 丢弃后不可撤销,此文件的本地未暂存修改将永久丢失(无法找回)。`}),(0,L.jsxs)(`div`,{className:`git-confirm-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`picker-cancel git-confirm-cancel`,"data-git-confirm-cancel":`1`,ref:a,onClick:n,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,className:`git-confirm-danger`,"data-git-confirm-ok":`1`,onClick:r,children:t?`移到回收站`:`确认丢弃`})]})]})});return typeof document>`u`?o:(0,Ie.createPortal)(o,document.body)}function ki(e,t,n){let r=e?bi(e,t):``,[i,a]=(0,u.useState)(),o=(0,u.useRef)({scope:r,ticket:0,busy:!1});o.current.scope!==r&&(o.current={scope:r,ticket:0,busy:!1});let s=(0,u.useCallback)((e=!1)=>{let t=o.current;if(!r||t.scope!==r||!n||t.busy&&!e)return;t.busy=!0;let i=++t.ticket,s=()=>o.current===t&&t.ticket===i;gi(r).then(e=>{s()&&(Ii(Mi,r,e,16),a({scope:r,status:e,error:null}))}).catch(e=>{s()&&a({scope:r,status:null,error:_i(e)})}).finally(()=>{s()&&(t.busy=!1)})},[r,n]);(0,u.useEffect)(()=>{let e=o.current;s(!0);let t=()=>{document.visibilityState===`visible`&&s()},n=window.setInterval(t,15e3);return window.addEventListener(`focus`,t),()=>{window.clearInterval(n),window.removeEventListener(`focus`,t),e.ticket++,e.busy=!1}},[s]);let c=(0,u.useCallback)(e=>{r&&o.current.scope===r&&(o.current.ticket++,o.current.busy=!1,Ii(Mi,r,e,16),a({scope:r,status:e,error:null}))},[r]),l=i?.scope===r?i:void 0;return{status:l?l.status:Mi.get(r)??null,error:l?.error??null,refresh:s,publish:c}}function Ai(e,t,n={}){return`/api/git?${new URLSearchParams({workspaceId:e,op:t,...n})}`}function ji(e,t,n,r,i){return Ai(e,i===void 0?`commit-detail`:`commit-diff`,{hash:n,...t?{cwd:t}:{},...r?{worktreeId:r}:{},...i===void 0?{}:{path:i}})}var Mi=new Map,Ni=new Map,Pi=new Map,Fi=new Map;function Ii(e,t,n,r){if(e.delete(t),e.set(t,n),e.size>r){let t=e.keys().next().value;t!==void 0&&e.delete(t)}}function Li(e){return e.length?`${e.length>1?`第一父提交`:`父提交`} ${e[0].slice(0,8)}`:`空树`}var Ri={A:`新增`,M:`修改`,D:`删除`,R:`重命名`,C:`复制`,T:`类型更改`};function zi({commits:e,workspaceId:t,cwd:n,worktreeId:r,onDiff:i,graph:a}){let[o,s]=(0,u.useState)(),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(0),p=o&&e.some(e=>e.hash===o)?ji(t,n,o,r):``;(0,u.useEffect)(()=>{if(!p||Pi.has(p))return;let e=new AbortController;return gi(p,{signal:e.signal}).then(t=>{e.signal.aborted||(Ii(Pi,p,t,40),l({url:p,detail:t}))}).catch(t=>{e.signal.aborted||l({url:p,error:_i(t).message})}),()=>e.abort()},[p,d]);let m=Pi.get(p),h=c?.url===p?c:m?{detail:m}:void 0;return(0,L.jsx)(L.Fragment,{children:e.map((e,t)=>{let n=o===e.hash,c=n?h?.detail:void 0,u=c?Li(c.parents):``,d=a?.rows[t],p=`refs`in e?e.refs:[],m=`parents`in e&&e.parents.length>1;return(0,L.jsxs)(`div`,{className:d?`git-history-item git-graph-item`:`git-history-item`,style:d&&a?{minWidth:a.columns*Bi+142}:void 0,children:[d&&a&&(0,L.jsx)(Ui,{row:d,columns:a.columns,merge:m}),(0,L.jsxs)(`button`,{type:`button`,className:`git-log-row`,"data-git-commit":e.hash,"aria-expanded":n,onClick:()=>{s(n?void 0:e.hash),l(void 0)},children:[(0,L.jsx)(`span`,{className:`git-log-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,L.jsx)(`span`,{className:`git-log-subject`,title:e.subject,children:e.subject||`(无提交说明)`}),(0,L.jsxs)(`span`,{className:`git-log-meta`,children:[(0,L.jsx)(`span`,{className:`git-log-hash`,title:e.hash,children:e.short}),(0,L.jsx)(`span`,{className:`git-log-author`,title:e.author,children:e.author}),(0,L.jsx)(`time`,{className:`git-log-date`,dateTime:e.date,title:e.date,children:wi(e.date)})]}),(m||p.length>0)&&(0,L.jsxs)(`span`,{className:`git-graph-refs`,children:[m&&(0,L.jsx)(`span`,{className:`git-graph-ref`,children:`合并`}),p.slice(0,3).map(e=>(0,L.jsx)(Hi,{refItem:e},e.checkoutId??`${e.kind}:${e.name}`)),p.length>3&&(0,L.jsxs)(`span`,{className:`git-graph-ref`,title:`展开提交查看全部引用`,children:[`+`,p.length-3]})]})]}),n&&(0,L.jsxs)(`div`,{className:`git-commit-changes`,"data-git-commit-changes":e.hash,children:[!h&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取提交中的文件…`}),h?.error&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,children:Nr(h.error,`读取提交失败。`)}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,onClick:()=>{l(void 0),f(e=>e+1)},children:`重试`})]}),c&&(0,L.jsxs)(L.Fragment,{children:[p.length>3&&(0,L.jsxs)(`details`,{className:`git-commit-extra`,children:[(0,L.jsxs)(`summary`,{children:[p.length,` 个引用`]}),(0,L.jsx)(`div`,{className:`git-graph-refs`,children:p.map(e=>(0,L.jsx)(Hi,{refItem:e},e.checkoutId??`${e.kind}:${e.name}`))})]}),c.message.includes(`
|
|
22
|
+
`)&&(0,L.jsxs)(`details`,{className:`git-commit-extra`,children:[(0,L.jsx)(`summary`,{children:`完整提交说明`}),(0,L.jsx)(`pre`,{children:c.message})]}),(0,L.jsxs)(`p`,{className:`git-scope-note`,title:c.parents[0],children:[c.files.length,` 个文件 · 对比`,u]}),!c.files.length&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`当前目录内没有文件改动。`}),c.files.map(t=>{let n=t.path.split(`/`).at(-1)??t.path,a=t.previousPath===void 0?t.path:`${t.previousPath} → ${t.path}`,o=Ri[t.status[0]]??t.status;return(0,L.jsxs)(`button`,{type:`button`,className:`git-worktree-file git-commit-file`,"data-git-commit-file":t.path,title:`${o} · ${a}`,onClick:()=>i({hash:e.hash,base:u,file:t,worktreeId:r}),children:[(0,L.jsx)(Br,{path:t.path,size:15}),(0,L.jsxs)(`span`,{className:`git-commit-file-label`,children:[(0,L.jsx)(`span`,{children:n}),a!==n&&(0,L.jsx)(`small`,{children:a})]}),(0,L.jsx)(`span`,{className:`git-commit-file-status`,"aria-label":o,children:t.status[0]})]},t.path)})]})]})]},e.hash)})})}var Bi=14,Vi={head:`当前检出`,worktree:`工作树`,branch:`本地分支`,remote:`远程跟踪分支`,tag:`标签`,stash:`贮藏`};function Hi({refItem:e}){let{kind:t,name:n}=e;return(0,L.jsxs)(`span`,{className:`git-graph-ref`,"data-git-graph-ref":t,title:`${Vi[t]} · ${n}`,children:[t===`tag`||t===`worktree`?`${Vi[t]} `:``,n]})}function Ui({row:e,columns:t,merge:n}){let r=e=>e*Bi+Bi/2,i=r(e.node.index),a=t*Bi;return(0,L.jsxs)(`div`,{className:`git-graph-lines`,"aria-hidden":`true`,"data-git-graph-lane":e.node.index,"data-git-graph-incoming":e.incoming||void 0,children:[(0,L.jsxs)(`svg`,{className:`git-graph-top`,width:a,height:`32`,viewBox:`0 0 ${a} 32`,children:[e.through.map(e=>(0,L.jsx)(`path`,{"data-color":e.color%5,d:`M ${r(e.index)} 0 V 32`},e.index)),e.incoming&&(0,L.jsx)(`path`,{"data-color":e.node.color%5,d:`M ${i} 0 V 16`}),e.parents.map(({hash:e,lane:t},n)=>(0,L.jsx)(`path`,{"data-git-graph-parent":e,"data-color":t.color%5,d:`M ${i} 16 C ${i} 24 ${r(t.index)} 22 ${r(t.index)} 32`},n)),n?(0,L.jsx)(`rect`,{"data-color":e.node.color%5,x:i-3.5,y:`12.5`,width:`7`,height:`7`,rx:`1`}):(0,L.jsx)(`circle`,{"data-color":e.node.color%5,cx:i,cy:`16`,r:`3.5`})]}),(0,L.jsx)(`svg`,{className:`git-graph-tail`,width:a,viewBox:`0 0 ${a} 1`,preserveAspectRatio:`none`,children:[...e.through,...e.parents.map(e=>e.lane).filter(t=>!e.through.some(e=>e.index===t.index))].map(e=>(0,L.jsx)(`path`,{"data-color":e.color%5,d:`M ${r(e.index)} 0 V 1`},e.index))})]})}function Wi({workspaceId:e,cwd:t,revision:n,onDiff:r}){let i=Ai(e,`graph`,t?{cwd:t}:{}),[a,o]=(0,u.useState)(()=>({page:Ni.get(i),loading:!0})),s=(0,u.useRef)(void 0),c=(0,u.useCallback)(e=>{s.current?.abort();let t=new AbortController;s.current=t;let n=Ni.get(i);o(t=>({page:e??n??t.page,loading:!0}));let r=new URLSearchParams(e?{offset:String(e.commits.length),snapshot:e.snapshot,after:e.commits.at(-1)?.hash??``}:n?{knownSnapshot:n.snapshot}:{});gi(`${i}&${r}`,{signal:t.signal}).then(r=>{if(t.signal.aborted)return;let a=`unchanged`in r?Ni.get(i)??n:e?{...r,commits:[...e.commits,...r.commits]}:r;a&&Ii(Ni,i,a,8),o({page:a,loading:!1})}).catch(n=>{t.signal.aborted||o(t=>({page:t.page,error:_i(n),loading:!1,append:!!e}))})},[i]);(0,u.useEffect)(()=>(c(),()=>s.current?.abort()),[c,n]);let l=a.page,d=(0,u.useMemo)(()=>l&&oi(l.commits),[l]),f=a.error?.body.code===`graph_changed`;return(0,L.jsxs)(`section`,{className:`git-graph`,"data-git-graph":!0,"aria-label":`提交图`,"aria-busy":a.loading,children:[(0,L.jsx)(`p`,{className:`git-scope-note`,children:`仓库历史 · 文件差异按当前会话目录`}),l&&d&&l.commits.length>0&&(0,L.jsx)(`div`,{className:`git-graph-list`,tabIndex:0,role:`region`,"aria-label":`提交关系`,children:(0,L.jsx)(zi,{commits:l.commits,workspaceId:e,cwd:t,onDiff:r,graph:d})}),l&&!l.commits.length&&(0,L.jsx)(`p`,{className:`rail-empty`,children:`暂无提交记录。`}),a.error&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,children:Nr(a.error,`读取提交图失败。`)}),a.loading&&!l&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取提交图…`}),(a.error||l?.hasMore)&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action git-graph-more`,"data-git-graph-more":!0,disabled:a.loading,onClick:()=>c(f||a.error&&!a.append?void 0:l),children:a.loading?`读取中…`:f?`重新加载提交图`:a.error?`重试`:`加载更早的提交`})]})}function Gi({workspaceId:e,value:t,disabled:n,onChoose:r}){let[i,a]=(0,u.useState)(),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(0),[d,f]=(0,u.useState)(),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(!1),[_,v]=(0,u.useState)(0);return(0,u.useEffect)(()=>{if(!i)return;let t=new AbortController;g(!0),m(``);let n=window.setTimeout(()=>{gi(Ai(e,`branches`,{local:`1`,q:o,offset:String(c)}),{signal:t.signal}).then(e=>{t.signal.aborted||f(t=>c&&t?{...e,branches:[...t.branches,...e.branches]}:e)}).catch(e=>{t.signal.aborted||m(_i(e).message)}).finally(()=>{t.signal.aborted||g(!1)})},o?180:0);return()=>{window.clearTimeout(n),t.abort()}},[i,e,o,c,_]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-view-search git-base-trigger`,"aria-label":`工作树起点分支`,"aria-haspopup":`dialog`,"aria-expanded":!!i,title:n?fi:t||`当前工作区提交(HEAD)`,disabled:n,onClick:e=>{s(``),l(0),f(void 0),a(e.currentTarget)},children:[(0,L.jsx)(`span`,{children:t||`当前工作区提交(HEAD)`}),(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`⌄`})]}),i&&(0,L.jsxs)(Ye,{title:`选择工作树起点分支`,anchor:i,onClose:()=>a(void 0),hideEmpty:h||!!p,onSearch:e=>{s(e),l(0),f(void 0),g(!0)},choices:[{id:``,label:`当前工作区提交(HEAD)`},...(d?.branches??[]).map(e=>({id:e.name,label:e.name,detail:e.current?`本地分支 · 当前分支`:`本地分支`}))],onChoose:e=>{r(e),a(void 0),i.focus()},children:[h&&(0,L.jsx)(`p`,{role:`status`,children:`读取本地分支…`}),p&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,children:p}),(p||d&&d.branches.length<d.matches)&&(0,L.jsx)(`button`,{type:`button`,disabled:h,"data-worktree-branches-more":!0,onClick:()=>p?v(e=>e+1):l(d.branches.length),children:p?`重试`:`加载更多分支`})]})]})}function Ki({workspaceId:e,conversationId:t,followedWorktreeId:n,revision:r,onDiff:i,onCommitDiff:a,onOpenConversation:o,repositoryOnly:s=!1}){let[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(``),p=`super-pi.git-worktree:${JSON.stringify([e,t])}`,[m,h]=(0,u.useState)(()=>{try{return window.sessionStorage.getItem(p)??n??``}catch{return n??``}}),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(0),O=(0,u.useRef)(n),k=c?.find(e=>e.current),A=m?c?.find(e=>e.id===m):k??c?.[0],j=e=>{h(e);try{window.sessionStorage.setItem(p,e)}catch{}};(0,u.useEffect)(()=>{n&&n!==O.current&&j(n),O.current=n},[n,p]);let M=async(n,r)=>{if(!(S||s&&n!==`open`)){C(n),T(``);try{let i={action:n,requestId:Yt(),worktreeId:r,...t&&!t.startsWith(`pending:`)?{conversationId:t}:{},...n===`create`?{branch:v.trim(),base:b.trim()}:{}},a=await gi(Ai(e,`worktree-manage`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)},65e3);j(a.worktree.id),D(e=>e+1),n===`create`&&(y(``),x(``)),a.conversationId&&o?.(a.conversationId,a.workspaceId)}catch(e){T(_i(e).message)}finally{C(``)}}};(0,u.useEffect)(()=>{let t=!0,n=!1,r=async()=>{if(!n){n=!0;try{let n=await gi(Ai(e,`worktrees`));t&&(l(n.worktrees),f(``))}catch(e){t&&f(_i(e).message)}finally{n=!1}}};r();let i=window.setInterval(()=>{document.visibilityState===`visible`&&r()},1e4);return()=>{t=!1,window.clearInterval(i)}},[e,r,E]),(0,u.useEffect)(()=>{if(s||!A||A.missing)return;let t=A.id,n=!0,r=!1,i=async()=>{if(!r){r=!0;try{let r=await gi(Ai(e,`worktree-inspect`,{worktreeId:t}));n&&_({id:t,value:r})}catch(e){n&&_({id:t,error:_i(e).message})}finally{r=!1}}};i();let a=window.setInterval(()=>{document.visibilityState===`visible`&&i()},5e3);return()=>{n=!1,window.clearInterval(a)}},[e,A?.id,A?.missing,r,E,s]);let N=!s&&g?.id===A?.id?g:void 0,P=N?.value?.comparison,F=N?.value?.status,ee=F?Di.map(e=>({...e,files:F[e.key]})):[],te=(e,t)=>{let n=si(e.xy,`unstaged`).kind===`untracked`;return(0,L.jsxs)(`button`,{type:`button`,className:`git-worktree-file`,title:e.path,"data-git-worktree-file":e.path,onClick:()=>i({...t,label:A?.branch??A?.name??`关联工作树`}),children:[(0,L.jsx)(Br,{path:e.path,size:15}),` `,(0,L.jsx)(`span`,{children:e.path}),(0,L.jsx)(`small`,{title:n?ci.untracked:e.xy.trim(),children:n?`U`:e.xy.trim()})]},e.path)};return(0,L.jsxs)(`section`,{className:`git-worktrees`,"data-git-worktrees":!0,"aria-label":`仓库工作树`,children:[d&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:d}),!c&&!d&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取工作树…`}),c&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`select`,{className:`git-view-search`,"aria-label":`选择要查看的工作树`,value:A?.id??``,onChange:e=>j(e.target.value),children:[!A&&(0,L.jsx)(`option`,{value:``,children:`选择工作树`}),c.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.branch??(e.head.slice(0,8)||e.name),` · `,e.name,e.primary?` · 主检出`:``,e.current?` · 当前`:``,e.missing?` · 已丢失`:``,e.locked?` · 已锁定`:``]},e.id))]}),A&&(0,L.jsx)(`p`,{className:`git-worktree-path`,title:A.path,"data-git-worktree-path":!0,children:A.path}),(0,L.jsxs)(`div`,{className:`git-worktree-actions`,children:[A&&!A.missing&&o&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-worktree-open":!0,disabled:!!S,onClick:()=>void M(`open`,A.id),children:`在此新建会话`}),A&&!A.missing&&t&&!t.startsWith(`pending:`)&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-worktree-follow":!0,disabled:!!S||A.id===n,onClick:()=>void M(`follow`,A.id),children:A.id===n?`会话已跟随`:`会话跟随`})]}),(0,L.jsxs)(`details`,{className:`git-worktree-create`,children:[(0,L.jsx)(`summary`,{title:s?fi:void 0,children:`新建工作树`}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),M(`create`)},children:[(0,L.jsx)(Gi,{workspaceId:e,value:b,disabled:s||!!S,onChoose:x}),(0,L.jsx)(`input`,{disabled:s,title:s?fi:void 0,className:`git-view-search`,"aria-label":`工作树的新分支`,placeholder:`新分支(可选)`,value:v,onChange:e=>y(e.target.value),maxLength:180}),(0,L.jsx)(`button`,{type:`submit`,className:`git-group-action`,"data-git-worktree-create":!0,title:s?fi:void 0,disabled:s||!!S,children:S===`create`?`创建中…`:`创建工作树`})]})]}),w&&(0,L.jsx)(`p`,{className:`tool-error`,"data-git-worktree-error":!0,role:`alert`,children:w}),A?.missing&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`此工作树目录已丢失。`}),!s&&A&&!A.missing&&!N&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取工作树状态…`}),N?.error&&!A?.missing&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`alert`,children:N.error}),A&&!A.missing&&N?.value&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`git-worktree-summary`,"data-git-worktree-status":!0,children:[N.value.status.branch??`分离 HEAD`,A.current?` · 当前会话检出`:` · 仅查看`]}),ee.every(e=>!e.files.length)&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`无未提交改动。`}),ee.filter(e=>e.files.length).map(e=>(0,L.jsxs)(`div`,{className:`git-worktree-group`,children:[(0,L.jsxs)(`strong`,{children:[e.title,` · `,e.files.length]}),e.files.map(t=>te(t,{worktreeId:A.id,path:t.path,staged:e.key===`staged`}))]},e.key)),P&&!A.primary&&(0,L.jsxs)(`div`,{className:`git-worktree-group`,"data-git-worktree-comparison":!0,children:[(0,L.jsxs)(`strong`,{children:[`相对 `,P.base,` · ↑`,P.ahead,` ↓`,P.behind]}),P.files.map(e=>te(e,{worktreeId:A.id,path:e.path,staged:!1,comparison:`committed`})),(0,L.jsx)(zi,{commits:P.commits,workspaceId:e,cwd:``,worktreeId:A.id,onDiff:e=>a({...e,worktreeLabel:A.branch??A.name})},A.id),P.truncated&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`显示最近 20 条独有提交。`})]})]})]})]})}function qi({workspaceId:e,conversationId:t,cwd:n=``,followedWorktreeId:r,onOpenDiff:i,activeDiffUrl:a,onOpenConversation:o,sharedGit:s,repositoryOnly:c=!1}){let[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(null),m=s?s.status:l,h=s?s.error:f,g=s?.refresh,_=s?.publish,[v,y]=(0,u.useState)(()=>c||r?`worktrees`:`log`),b=(0,u.useRef)(null),[x,S]=(0,u.useState)(``),[C,w]=(0,u.useState)(()=>{try{let e=localStorage.getItem(`super-pi.git-panel.split.v1`),t=e===null?55:Number(e);return Number.isFinite(t)?Math.min(80,Math.max(20,t)):55}catch{return 55}}),T=e=>{let t=Math.round(Math.min(80,Math.max(20,e)));w(t);try{localStorage.setItem(`super-pi.git-panel.split.v1`,String(t))}catch{}},[E,D]=(0,u.useState)(),[O,k]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!O)return;let e=setTimeout(()=>k(``),2500);return()=>clearTimeout(e)},[O]);let A=e=>{e&&E?.anchor.origin.isConnected&&E.anchor.origin.focus({preventScroll:!0}),D(void 0)};(0,u.useEffect)(()=>{let t=t=>{let n=t.detail;n?.workspaceId===e&&[`branches`,`changes`,`worktrees`].includes(n.view)&&(n.view===`changes`?b.current?.focus({preventScroll:!0}):y(n.view))};return window.addEventListener(`super-pi-status-git-view`,t),()=>window.removeEventListener(`super-pi-status-git-view`,t)},[e]);let j=c&&pi(v)?`worktrees`:v,M=j===`changes`?`log`:j;(0,u.useEffect)(()=>{r&&y(`worktrees`)},[r]);let[N,P]=(0,u.useState)(``),[F,ee]=(0,u.useState)(0),[te,ne]=(0,u.useState)(0),[re,ie]=(0,u.useState)(),[ae,oe]=(0,u.useState)({}),[se,ce]=(0,u.useState)(``),[le,ue]=(0,u.useState)(null),[de,fe]=(0,u.useState)(``),[pe,me]=(0,u.useState)(``),[I,he]=(0,u.useState)(null),[ge,_e]=(0,u.useState)(null),ve=(0,u.useRef)(0),ye=(0,u.useCallback)(e=>{let t=++ve.current;p(null),me(``),ne(e=>e+1),g?g(!0):gi(bi(e,n)).then(e=>{t===ve.current&&d(e)}).catch(e=>{t===ve.current&&(d(null),p(_i(e)))})},[n,g]);(0,u.useEffect)(()=>{if(e)return ye(e),()=>{ve.current++}},[e,n,ye]);let be=e=>{c&&pi(e)||(e===`changes`?b.current?.focus({preventScroll:!0}):e!==M&&(y(e),P(``),ee(0)))},xe=ui.find(e=>e.id===M)??ui[0],Se=M===`log`||M===`branches`||M===`stash`,Ce=e&&m&&Se?`/api/git?workspaceId=${vi(e)}&op=${M}&limit=${Ci}${yi(n)}&q=${vi(N.trim())}&offset=${F}`:``;(0,u.useEffect)(()=>{if(!Ce)return;let e=!0;ie({url:Ce,result:Fi.get(Ce)});let t=window.setTimeout(()=>{gi(Ce).then(t=>{e&&(Ii(Fi,Ce,t,32),ie({url:Ce,result:t}),`branches`in t&&oe(e=>({...e,branches:t.total})),`stashes`in t&&oe(e=>({...e,stash:t.total})))}).catch(t=>{e&&ie({url:Ce,result:Fi.get(Ce),error:_i(t).message})})},N.trim()?180:0);return()=>{e=!1,window.clearTimeout(t)}},[Ce,N,te]);let we=(t,r,a,o=!1)=>{if(!e||c)return;let s=a?.comparison?`共同祖先 → 工作树 HEAD`:o?`未跟踪文件`:r?`HEAD → 暂存区`:`暂存区 → 工作区`,l=a?.comparison?`已提交`:o?`未跟踪`:r?`已暂存`:`未暂存`;i({url:a?Ai(e,`worktree-diff`,{worktreeId:a.worktreeId,path:t,staged:r?`1`:`0`,...a.comparison?{comparison:a.comparison}:{}}):xi(e,t,r,n),path:t,label:a?`${a.label} · ${l}`:l,comparison:a?`${a.label} · ${s}`:s})},Te=t=>{if(!e)return;let r=t.file.path,a=t.hash.slice(0,8);i({url:ji(e,t.worktreeId?``:n,t.hash,t.worktreeId,r),path:r,label:t.worktreeLabel?`${t.worktreeLabel} · ${a}`:a,comparison:`提交 ${a} · 对比${t.base}`,previousPath:t.file.previousPath,commitHash:t.hash})},Ee=(0,u.useCallback)(async(t,r={})=>{if(!e||I||c&&t!==`fetch`)return!1;he(t),me(``);try{if(t===`draft`)return ue(await Si(e,t,r,n)),!0;if(t===`discard-untracked`)return await gi(`/api/files/tree?workspaceId=${vi(e)}${yi(n)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`trash`,path:r.path.replace(/\/$/,``)})}),ye(e),!0;let i=await Si(e,t,r,n);return _?_(i):d(i),t!==`fetch`&&t!==`push`&&ue(null),(t===`stash-save`||t===`switch`)&&ee(0),ne(e=>e+1),!0}catch(n){let r=_i(n);return t===`stash-apply`&&ye(e),me(r.body?.error||r.message||`操作失败`),!1}finally{he(null)}},[e,n,_,I,ye,c]),De=(0,u.useCallback)(()=>{if(!ge)return;let e=ge;_e(null),Ee(e.untracked?`discard-untracked`:`discard`,{path:e.path})},[ge,Ee]),Oe=(0,u.useCallback)(()=>{_e(null)},[]),ke=m===null?null:Ei(m),Ae=x.trim().toLowerCase(),je=m===null?[]:Di.map(e=>({...e,entries:m[e.key].filter(e=>e.path.toLowerCase().includes(Ae))})),Me=m?new Set(Di.flatMap(e=>m[e.key].map(e=>e.path))).size:0,Ne=re?.url===Ce?re.result:void 0,Pe=re?.url===Ce?re.error:void 0,Fe=Ne&&`commits`in Ne?Ne:null,Ie=Ne&&`branches`in Ne?Ne:null,Le=Ne&&`stashes`in Ne?Ne:null,Re=M===`log`?Ci:50,ze=Ie??Le,Be=Fe?Fe.truncated:ze?F+Re<ze.matches:!1;return e?(0,L.jsxs)(`div`,{className:`git-panel`,"data-git-panel":`1`,"data-git-scope":c?`repository`:`checkout`,children:[c&&(0,L.jsxs)(`p`,{className:`git-scope-note`,role:`status`,children:[`仓库浏览 · `,fi]}),m===null&&h===null&&(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-loading":`1`,children:`读取 Git 状态…`}),h!==null&&(0,L.jsxs)(`div`,{className:`git-state-card${h.body.code===`not_a_repo`?` git-state-card-empty`:` git-error`}`,"data-git-error":`1`,role:`status`,"data-git-error-code":h.body.code??``,children:[(0,L.jsx)(`span`,{className:`git-state-icon`,"aria-hidden":`true`,children:h.body.code===`not_a_repo`?`⌁`:`!`}),(0,L.jsx)(`strong`,{children:h.body.code===`not_a_repo`?`此工作区不是 git 仓库`:`Git 状态暂时不可用`}),(0,L.jsx)(`p`,{children:h.body.code===`not_a_repo`?`当前工作区没有 Git 仓库,因此没有分支、变更或提交记录可显示。文件和对话功能仍可正常使用。`:`读取仓库状态时遇到问题,请稍后重试。`}),(0,L.jsx)(`button`,{type:`button`,className:`git-state-action`,onClick:()=>ye(e),children:`重新检查`})]}),m!==null&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`git-head`,"data-git-head":`1`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-branch`,"data-git-branch":`1`,title:c?`查看仓库分支`:Ti(m),"aria-label":c?`查看仓库分支`:`当前分支 ${Ti(m)},查看分支`,onClick:()=>be(`branches`),children:[(0,L.jsx)(Xr,{name:`git`}),(0,L.jsx)(`span`,{children:c?`仓库分支`:Ti(m)})]}),!c&&ke!==null&&(0,L.jsx)(`span`,{className:`git-ahead-behind`,"data-git-ahead-behind":`1`,children:ke}),(0,L.jsx)(`button`,{type:`button`,className:`git-refresh`,"data-git-refresh":`1`,title:`刷新 Git 状态`,"aria-label":`刷新 Git 状态`,onClick:()=>ye(e),children:(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`})})]}),pe&&(0,L.jsx)(`p`,{className:`tool-error`,"data-git-action-error":`1`,role:`alert`,children:pe}),O&&(0,L.jsx)(`p`,{className:`git-copy-notice`,role:`status`,children:O}),(0,L.jsxs)(`div`,{className:`git-sync-actions`,"aria-label":`远程操作`,children:[(0,L.jsx)(`button`,{type:`button`,"data-git-action":`fetch`,onClick:()=>void Ee(`fetch`),disabled:I!==null,title:`从上游获取远程引用`,children:I===`fetch`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`获取中…`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),` Fetch`]})}),(0,L.jsx)(`button`,{type:`button`,"data-git-action":`pull`,onClick:()=>void Ee(`pull`),disabled:c||I!==null,title:c?fi:void 0,children:I===`pull`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`拉取中…`]}):`拉取`}),(0,L.jsx)(`button`,{type:`button`,"data-git-action":`push`,onClick:()=>void Ee(`push`),disabled:c||I!==null,title:c?fi:void 0,children:I===`push`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`推送中…`]}):`推送`})]}),(0,L.jsxs)(`div`,{className:`git-pane-stack`,"data-git-pane-stack":!0,style:{gridTemplateRows:`minmax(0, ${C}fr) 6px minmax(0, ${100-C}fr)`},children:[(0,L.jsxs)(`section`,{className:`git-changes-pane`,"data-git-changes-pane":!0,ref:b,tabIndex:-1,"aria-label":`工作区改动`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-pane-title`,"data-git-view":`changes`,"aria-pressed":!c,disabled:c,title:c?fi:void 0,onClick:()=>be(`changes`),children:[(0,L.jsx)(Xr,{name:`main`}),(0,L.jsx)(`span`,{children:`工作区改动`}),!c&&(0,L.jsx)(`span`,{className:`git-view-count`,children:Me})]}),c?(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:fi}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`section`,{className:`git-scm-actions`,"data-git-actions":`1`,"aria-label":`提交已暂存的更改`,children:[(0,L.jsxs)(`form`,{className:`git-commit-input`,onSubmit:async e=>{e.preventDefault(),await Ee(`commit`,{message:se})&&ce(``)},children:[(0,L.jsx)(`input`,{value:se,onChange:e=>ce(e.target.value),placeholder:`提交说明…`,"aria-label":`提交消息`,disabled:I!==null}),(0,L.jsx)(`button`,{type:`submit`,className:`git-commit-submit`,"data-git-action":`commit`,disabled:!m.staged.length||!se.trim()||I!==null,children:I===`commit`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`提交中…`]}):`提交`})]}),(0,L.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,L.jsx)(`span`,{children:`仅提交已暂存内容`}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`draft`,"aria-label":`用 AI 根据当前目录的暂存差异生成提交信息`,title:`用 AI 根据当前目录的暂存差异生成提交信息`,disabled:!m.staged.length||I!==null,onClick:()=>void Ee(`draft`),children:I===`draft`?`生成中…`:`✧ AI 生成`})]}),le&&(0,L.jsxs)(`div`,{className:`git-draft`,"data-git-draft":!0,children:[(0,L.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,L.jsx)(`strong`,{children:le.truncated?`提交说明建议 · 差异已截断`:`提交说明建议`}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"aria-label":`关闭提交说明建议`,onClick:()=>ue(null),children:`×`})]}),(0,L.jsx)(`p`,{children:le.message}),(0,L.jsx)(`button`,{type:`button`,"data-git-draft-apply":!0,onClick:()=>{ce(le.message.replace(/\s*\n\s*/g,` `)),ue(null)},children:`替换输入`})]})]}),(0,L.jsx)(`input`,{className:`git-view-search`,type:`search`,"aria-label":`搜索文件名或路径`,placeholder:`搜索文件名或路径`,value:x,onChange:e=>S(e.target.value),maxLength:160}),je.map(t=>(0,L.jsxs)(`div`,{className:`git-group`,"data-git-group":t.key,children:[(0,L.jsxs)(`div`,{className:`git-group-head`,"data-git-group-head":t.key,children:[(0,L.jsx)(`span`,{className:`git-group-title`,children:t.title}),(0,L.jsx)(`span`,{className:`git-group-count`,"data-git-count":t.key,children:t.entries.length}),!Ae&&t.key===`staged`&&t.entries.length>0&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`unstage-all`,disabled:I!==null,onClick:()=>void Ee(`unstage-all`),children:`全部取消暂存`}),!Ae&&t.key===`unstaged`&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`stage-all`,disabled:I!==null||!m.unstaged.length&&!m.untracked.length,onClick:()=>void Ee(`stage-all`),children:`全部暂存`})]}),(0,L.jsx)(`div`,{className:`git-group-body`,children:t.entries.length===0?(0,L.jsx)(`p`,{className:`git-group-empty`,"data-git-empty":t.key,children:Ae?`无匹配文件。`:`无${t.title}变更。`}):t.entries.map(r=>{let i=si(r.xy,t.key),o=li(r),s=a===xi(e,r.path,t.key===`staged`,n);return(0,L.jsxs)(`div`,{className:`git-file-row${s?` is-active`:``}`,onContextMenu:e=>{e.preventDefault();let n=e.currentTarget.querySelector(`[data-git-file]`);D({entry:r,group:t.key,anchor:{x:e.clientX,y:e.clientY,origin:n,initialFocus:!0}})},onKeyDown:e=>{(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`)&&(e.preventDefault(),D({entry:r,group:t.key,anchor:ni(e.currentTarget.querySelector(`[data-git-file]`))}))},children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-file-open`,"data-git-file":r.path,"data-git-kind":o?`dir`:`file`,title:r.path,onClick:()=>we(r.path,t.key===`staged`,void 0,t.key===`untracked`),children:[(0,L.jsx)(Br,{path:r.path,category:o?`folder`:void 0,size:15}),(0,L.jsx)(`span`,{className:`git-path`,children:o?`${r.name}/`:r.name}),r.path.includes(`/`)&&!o&&(0,L.jsx)(`span`,{className:`git-parent-path`,children:r.path.slice(0,r.path.lastIndexOf(`/`))})]}),(0,L.jsxs)(`span`,{className:`git-file-actions`,children:[t.key===`staged`?(0,L.jsx)(`button`,{type:`button`,title:`取消暂存`,disabled:I!==null,onClick:e=>{e.stopPropagation(),Ee(`unstage`,{path:r.path})},children:`−`}):(0,L.jsx)(`button`,{type:`button`,title:`暂存`,disabled:I!==null,onClick:e=>{e.stopPropagation(),Ee(`stage`,{path:r.path})},children:`+`}),t.key!==`staged`&&(0,L.jsx)(`button`,{type:`button`,className:`git-file-action`,"data-git-action":`discard`,title:`丢弃 ${r.path} 的更改`,"aria-label":`丢弃更改 ${r.path}`,disabled:ge!==null||I!==null,onClick:e=>{e.stopPropagation(),_e({path:r.path,untracked:t.key===`untracked`})},children:`↶`}),(0,L.jsx)(`button`,{type:`button`,title:`更多文件操作`,"aria-label":`更多文件操作 ${r.path}`,"data-git-file-menu":r.path,"aria-haspopup":`menu`,onClick:e=>D({entry:r,group:t.key,anchor:ni(e.currentTarget)}),children:(0,L.jsx)(ti,{name:`more`})})]}),(0,L.jsx)(`span`,{className:`git-badge git-badge-${i.kind} git-badge-slot-${i.slot}`,role:`img`,title:ci[i.kind],"aria-label":ci[i.kind],"data-git-badge":i.kind,"data-git-badge-slot":i.slot,children:i.label})]},r.path)})})]},t.key))]})]}),(0,L.jsx)(`div`,{className:`git-pane-divider`,"data-git-pane-divider":!0,role:`separator`,"aria-label":`调整 Git 上下区域高度`,"aria-orientation":`horizontal`,"aria-valuenow":C,"aria-valuemin":20,"aria-valuemax":80,tabIndex:0,onPointerDown:e=>{e.button===0&&(e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{if(!e.currentTarget.hasPointerCapture(e.pointerId))return;let t=e.currentTarget.parentElement.getBoundingClientRect();T((e.clientY-t.top)/t.height*100)},onPointerUp:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)},onDoubleClick:()=>T(55),onKeyDown:e=>{if(e.key===`ArrowUp`)T(C-5);else if(e.key===`ArrowDown`)T(C+5);else if(e.key===`Home`)T(20);else if(e.key===`End`)T(80);else return;e.preventDefault()}}),(0,L.jsxs)(`section`,{className:`git-secondary-pane`,"data-git-secondary-pane":!0,"aria-label":`Git 仓库功能`,children:[(0,L.jsxs)(`nav`,{className:`git-view-nav`,"aria-label":`源代码管理视图`,children:[(0,L.jsxs)(`span`,{className:`git-secondary-title`,children:[xe.title,(M===`branches`||M===`stash`)&&ae[M]!==void 0&&(0,L.jsx)(`small`,{children:ae[M]})]}),ui.filter(e=>e.id!==`changes`).map(e=>{let t=c&&pi(e.id),n=t?void 0:e.id===`branches`||e.id===`stash`?ae[e.id]:void 0;return(0,L.jsxs)(`button`,{type:`button`,disabled:t,title:t?fi:di[e.id]??e.title,"aria-label":e.title,"data-git-view":e.id,"aria-pressed":e.id===M,onClick:()=>be(e.id),children:[(0,L.jsx)(Xr,{name:e.icon}),(0,L.jsx)(`span`,{className:`git-view-label`,children:e.title}),n!==void 0&&(0,L.jsx)(`span`,{className:`git-view-count`,children:n})]},e.id)})]}),xe.search&&(0,L.jsx)(`input`,{className:`git-view-search`,type:`search`,"aria-label":xe.search,placeholder:xe.search,value:N,maxLength:160,onChange:e=>{P(e.target.value),ee(0)}}),M===`worktrees`&&(0,L.jsx)(Ki,{repositoryOnly:c,workspaceId:e,conversationId:t,followedWorktreeId:r,revision:te,onOpenConversation:o,onDiff:e=>we(e.path,e.staged,e),onCommitDiff:Te}),M===`graph`&&m&&(0,L.jsx)(Wi,{workspaceId:e,cwd:n,revision:te,onDiff:Te}),Se&&!Ne&&!Pe&&(0,L.jsxs)(`p`,{className:`rail-empty`,"data-git-log-loading":M===`log`?`1`:void 0,role:`status`,children:[`读取`,xe.title,`…`]}),Se&&Pe&&(0,L.jsxs)(`div`,{className:`git-page-error`,"data-git-log-error":M===`log`?`1`:void 0,children:[(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,title:Pr(Pe),children:Nr(Pe,`读取 Git 列表失败。`)}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,onClick:()=>ne(e=>e+1),children:`重试`})]}),M===`log`&&Fe&&(0,L.jsx)(`div`,{className:`git-log`,"data-git-log":`1`,children:Fe.commits.length===0?(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-log-empty":`1`,children:N.trim()?`没有匹配的提交。`:`暂无提交记录。`}):(0,L.jsx)(zi,{commits:Fe.commits,workspaceId:e,cwd:n,onDiff:Te})}),M===`branches`&&Ie&&(0,L.jsxs)(`div`,{className:`git-index-list`,"data-git-branches":!0,children:[!Ie.canWrite&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`切换分支会改变整个工作树,请在仓库根目录操作。`}),Ie.branches.length===0&&(0,L.jsx)(`p`,{className:`rail-empty`,children:N.trim()?`没有匹配的分支。`:`暂无分支。`}),Ie.branches.map(e=>(0,L.jsxs)(`div`,{className:`git-index-row`,"data-git-ref":e.name,children:[(0,L.jsx)(`span`,{className:`git-index-name`,title:e.name,children:e.name}),e.current?!c&&(0,L.jsx)(`span`,{className:`git-index-current`,children:`当前`}):e.local?Ie.canWrite&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`switch`,"aria-label":`切换到 ${e.name}`,disabled:c||I!==null,title:c?fi:void 0,onClick:()=>void Ee(`switch`,{target:e.name}),children:`切换`}):(0,L.jsx)(`span`,{className:`git-index-meta`,children:`远程`})]},`${e.local}:${e.name}`))]}),M===`stash`&&Le&&(0,L.jsxs)(`div`,{className:`git-index-list`,"data-git-stashes":!0,children:[Le.canWrite?(0,L.jsxs)(`form`,{className:`git-stash-form`,onSubmit:async e=>{e.preventDefault(),await Ee(`stash-save`,{message:de})&&fe(``)},children:[(0,L.jsxs)(`div`,{className:`git-commit-input`,children:[(0,L.jsx)(`input`,{className:`git-view-search`,value:de,onChange:e=>fe(e.target.value),maxLength:200,"aria-label":`贮藏说明`,placeholder:`贮藏说明(可选)`}),(0,L.jsx)(`button`,{type:`submit`,className:`git-group-action`,"data-git-action":`stash-save`,disabled:!Me||I!==null,children:`贮藏改动`})]}),(0,L.jsx)(`p`,{className:`git-scope-note`,children:`保存整个工作树的改动,包括未跟踪文件。`})]}):(0,L.jsx)(`p`,{className:`git-scope-note`,children:`贮藏影响整个工作树,请在仓库根目录操作。`}),Le.stashes.length===0&&(0,L.jsx)(`p`,{className:`rail-empty`,children:N.trim()?`没有匹配的贮藏。`:`暂无贮藏记录。`}),Le.stashes.map(e=>(0,L.jsxs)(`div`,{className:`git-index-row`,"data-git-stash":e.hash,children:[(0,L.jsxs)(`div`,{className:`git-index-name`,title:e.subject,children:[e.subject,(0,L.jsxs)(`small`,{className:`git-index-meta`,children:[e.ref,` · `,wi(e.date)]})]}),Le.canWrite&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`stash-apply`,"aria-label":`恢复 ${e.ref}`,title:`恢复改动并保留贮藏记录`,disabled:I!==null,onClick:()=>void Ee(`stash-apply`,{target:e.hash}),children:`恢复`})]},`${e.ref}:${e.hash}`))]}),Ne&&(F>0||Be)&&(0,L.jsxs)(`div`,{className:`git-pages`,children:[(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,disabled:!F,onClick:()=>ee(Math.max(0,F-Re)),children:`上一页`}),(0,L.jsxs)(`span`,{children:[`第 `,F/Re+1,` 页`,ze?` · ${ze.matches} 项`:``]}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-log-truncated":Fe?.truncated?`1`:void 0,disabled:!Be,onClick:()=>ee(F+Re),children:`下一页`})]})]})]}),ge!==null&&(0,L.jsx)(Oi,{path:ge.path,untracked:ge.untracked,onCancel:Oe,onConfirm:De}),E&&(0,L.jsxs)(ri,{label:E.entry.path,anchor:E.anchor,close:A,children:[(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`file-context-item`,"data-git-menu-action":`diff`,disabled:li(E.entry),onClick:()=>{we(E.entry.path,E.group===`staged`,void 0,E.group===`untracked`),A(!0)},children:[(0,L.jsx)(ti,{name:`file`}),(0,L.jsx)(`span`,{children:`查看差异`})]}),(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`file-context-item`,"data-git-menu-action":`stage`,disabled:I!==null,onClick:()=>{Ee(E.group===`staged`?`unstage`:`stage`,{path:E.entry.path}),A(!0)},children:[(0,L.jsx)(ti,{name:`reference`}),(0,L.jsx)(`span`,{children:E.group===`staged`?`取消暂存`:`暂存更改`})]}),E.group!==`staged`&&(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`file-context-item`,"data-git-menu-action":`discard`,disabled:I!==null,onClick:()=>{_e({path:E.entry.path,untracked:E.group===`untracked`}),A(!1)},children:[(0,L.jsx)(ti,{name:`trash`}),(0,L.jsx)(`span`,{children:E.group===`untracked`?`放弃更改(移到回收站)`:`放弃未暂存更改`})]}),(0,L.jsx)(`div`,{role:`separator`}),[[`relative`,`复制相对路径`,[n,E.entry.path].filter(Boolean).join(`/`)],[`name`,`复制文件名`,E.entry.name]].map(([e,t,n])=>(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`file-context-item`,"data-git-menu-action":e,onClick:()=>{A(!0),ai(n).then(e=>{e?k(`已${t}`):me(`复制失败,请重试。`)})},children:[(0,L.jsx)(ti,{name:`copy`}),(0,L.jsx)(`span`,{children:t})]},e))]})]})]}):(0,L.jsx)(`div`,{className:`git-panel`,"data-git-panel":`1`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-empty":`noworkspace`,children:`请选择一个工作区查看 Git 状态。`})})}var Ji=e=>e?.phase===`waiting`||e?.phase===`installing`||e?.phase===`restarting`;async function Yi(e,t={},n=f){let r=await je(e,{...t,cache:`no-store`,signal:t.signal??AbortSignal.timeout(12e3)},n),i=await r.json().catch(()=>null);if(!i||!r.ok&&!(r.status===409&&i.operation))throw Error(i?.error??`更新服务未返回有效状态(HTTP ${r.status})`);return i}async function Xi(e,t){let n;for(let r=0;r<2;r++)try{let n=AbortSignal.any([e,AbortSignal.timeout(8e3)]),r=await je(`/api/update-status`,{cache:`no-store`,signal:n},t);if(r.status===404||r.ok&&r.headers.get(`content-type`)?.includes(`text/html`))return{...await Yi(`/api/health`,{signal:n},t),operation:null};let i=await r.json();if(!r.ok)throw Error(i?.error??`无法读取更新状态(HTTP ${r.status})`);return i}catch(t){if(n=t,e.aborted||r===1)break;await new Promise(e=>setTimeout(e,400))}throw n}var Zi=e=>e===`entry`?`super-pi.update-legacy-receipt`:`super-pi.update-legacy-receipt:${e}`;function Qi(e,t){try{if(t!==void 0)return t?sessionStorage.setItem(Zi(e),JSON.stringify(t)):sessionStorage.removeItem(Zi(e)),t;let n=JSON.parse(sessionStorage.getItem(Zi(e))??`null`);return n?.id&&Date.now()-Date.parse(n.startedAt)<18e5?n:null}catch{return t??null}}var $i=e=>e?`v${e}`:`—`,ea=`super-pi.update-check-hours`,ta=`super-pi.update-check-times`;function na(){try{let e=Number(localStorage.getItem(ea)??6);return[1,3,6,12,24].includes(e)?e:6}catch{return 6}}var ra=e=>!(!e.managed||e.legacy),ia=(e,t)=>ra(e)&&!!t&&!t.serviceSelfUpdate;function aa(e,t){let n=e.split(/[+-]/)[0].split(`.`).map(Number),r=t.split(/[+-]/)[0].split(`.`).map(Number);if(n.length!==3||r.length!==3||[...n,...r].some(e=>!Number.isFinite(e)))return!1;for(let e=0;e<3;e++)if(n[e]!==r[e])return n[e]>r[e];return t.includes(`-`)&&!e.includes(`-`)}var oa=e=>e?.status?.needsRestart?`restart`:e?.latest&&e.status&&aa(e.latest,e.status.diskVersion)?`update`:void 0;function sa(e){return e?.submitting?`starting`:e?.checking?`checking`:Ji(e?.status?.operation)?e.status.operation.phase:e?.status?.needsRestart?`needs-restart`:e?.status?.operation?.phase===`failed`||e?.error?`failed`:e?.status?.operation?.phase===`completed`&&e.observedOperationId===e.status.operation.id&&!oa(e)?`completed`:`idle`}function ca(e,t=!1){if(e?.backgroundChecking&&!e.latest)return`正在检查可用版本`;let n=sa(e);return n===`starting`?`正在提交更新`:n===`checking`?`正在检查可用版本`:n===`waiting`?`等待选中的托管服务更新结束,再更新本地入口`:n===`installing`?`正在下载并安装更新`:n===`restarting`?t?`正在自动退出并重新启动 Super Pi 桌面和本地服务`:e?.connectionLost?`等待服务重新上线`:`正在重启服务`:n===`needs-restart`?`${$i(e?.status?.diskVersion)} 已安装,等待重启`:n===`failed`?e?.error??e?.status?.operation?.failure?.message??`更新失败`:n===`completed`?`更新完成`:oa(e)?`有新版本可安装`:e?.latest?`当前已是最新版本`:`等待检查更新`}function la(e){let{connections:t,activeServer:n}=ce(),[r,i]=(0,u.useState)({}),a=(0,u.useRef)(r);a.current=r;let[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(()=>new Set),[d,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(!1),b=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>clearTimeout(b.current),[]),(0,u.useEffect)(()=>{let e=window.superPiDesktop;if(!e)return;let t=!1,n=()=>{e.status().then(e=>{t||h(e)}).catch(()=>{})};n();let r=setInterval(n,2e3);return()=>{t=!0,clearInterval(r)}},[]);let x=async()=>{if(!v&&window.superPiDesktop?.restart){y(!0),_(``),b.current=window.setTimeout(()=>{y(!1),_(`桌面端尚未退出,可以重试。当前窗口与本地服务状态分别保留。`)},12e3);try{await window.superPiDesktop.restart()}catch(e){clearTimeout(b.current),y(!1),_(e instanceof Error?e.message:`无法接管桌面重启,请重试。`)}}},[S,C]=(0,u.useState)(na),w=(0,u.useRef)({}),T=(0,u.useRef)({}),E=(0,u.useRef)({});(0,u.useEffect)(()=>{try{w.current=JSON.parse(localStorage.getItem(ta)??`{}`),T.current=JSON.parse(localStorage.getItem(`super-pi.update-known-versions`)??`{}`)}catch{w.current={},T.current={}}},[]);let D=(0,u.useRef)(null),O=(0,u.useId)(),k=(0,u.useRef)(new Map),A=(0,u.useRef)(new Set),j=(0,u.useRef)(!1),M=(0,u.useRef)(new Map),N=(e,t)=>{let n=a.current[e],r={...n??{},...t};r.status?.operation&&(Ji(r.status.operation)||n?.submitting&&t.status)&&(r.observedOperationId=r.status.operation.id),a.current={...a.current,[e]:r},i(t=>JSON.stringify(t[e])===JSON.stringify(r)?t:{...t,[e]:r})},P=e=>{let t=(k.current.get(e)??0)+1;return k.current.set(e,t),t},F=JSON.stringify(t.map(({id:e,url:t,enabled:n,revision:r})=>[e,t,n,r]));(0,u.useEffect)(()=>{let e=new AbortController,n,r=async()=>{if(t.some(ra))try{let t=await Yi(`/api/managed-servers`,{signal:e.signal});M.current=new Map((t.profiles??[]).map(e=>[e.id,e]))}catch{}await Promise.allSettled(t.filter(e=>e.enabled).map(async t=>{if(A.current.has(t.id))return;let n=k.current.get(t.id);try{let r=await Xi(e.signal,t.id);if(e.signal.aborted||n!==k.current.get(t.id))return;let i=t.managedId&&M.current.get(t.managedId);if(ia(t,r)&&i&&i.updateOperation&&(r.operation=i.updateOperation),r.operation)Qi(t.id,null);else{let e=Qi(t.id);e&&(N(t.id,{observedOperationId:e.id}),r.operation=e.targetVersion===r.runningVersion&&!r.needsRestart?Qi(t.id,{...e,phase:`completed`,changedAt:new Date().toISOString()}):Date.now()-Date.parse(e.changedAt)>15e4&&e.phase===`restarting`?Qi(t.id,{...e,phase:`failed`,changedAt:new Date().toISOString(),failure:{step:`restarting`,message:`服务尚未恢复,请检查所选服务的运行状态后重试。`}}):e)}N(t.id,{status:r,latest:a.current[t.id]?.latest??T.current[t.url],connectionLost:!1})}catch{!e.signal.aborted&&n===k.current.get(t.id)&&N(t.id,{connectionLost:!0})}})),e.signal.aborted||(n=window.setTimeout(r,o||Object.values(a.current).some(e=>Ji(e.status?.operation))?1600:5e3))};return r(),()=>{e.abort(),clearTimeout(n)}},[F,o]);async function ee(e,t=!1){if(A.current.has(e.id)||Ji(a.current[e.id]?.status?.operation))return;if(!e.enabled){N(e.id,{error:`连接已停用,请先连接此服务端再更新。`,latest:void 0});return}A.current.add(e.id);let n=P(e.id);t?N(e.id,{backgroundChecking:!0}):N(e.id,{checking:!0,error:void 0,observedOperationId:void 0});try{let t=await Yi(`/api/update-check`,{signal:AbortSignal.timeout(7e4)},e.id);if(k.current.get(e.id)!==n)return;let r=e.managedId&&M.current.get(e.managedId);ia(e,t)&&r&&r.updateOperation&&(t.operation=r.updateOperation),N(e.id,{status:t,latest:t.latestVersion,connectionLost:!1,error:void 0}),w.current[e.url]=Date.now(),t.latestVersion&&(T.current[e.url]=t.latestVersion);try{localStorage.setItem(ta,JSON.stringify(w.current)),localStorage.setItem(`super-pi.update-known-versions`,JSON.stringify(T.current))}catch{}}catch(r){!t&&k.current.get(e.id)===n&&N(e.id,{error:r instanceof Error?r.message:`检查更新失败。`,latest:void 0})}finally{A.current.delete(e.id),N(e.id,{checking:!1,backgroundChecking:!1})}}let te=(0,u.useRef)(ee);te.current=ee,(0,u.useEffect)(()=>{let e=!1,n=async()=>{for(let n of t){if(e||!n.enabled)continue;let t=Number(w.current[n.url]??0);Date.now()-t<S*36e5||Date.now()-(E.current[n.id]??0)<3e5||(E.current[n.id]=Date.now(),await te.current(n,!0))}};n();let r=window.setInterval(()=>void n(),6e4),i=()=>{document.visibilityState===`visible`&&n()};return document.addEventListener(`visibilitychange`,i),()=>{e=!0,clearInterval(r),document.removeEventListener(`visibilitychange`,i)}},[F,S]);async function ne(){await Promise.allSettled(t.filter(e=>!c.has(e.id)).map(e=>ee(e)))}function re(e,t){for(let n of t){let t=e.profiles?.find(e=>e.id===n.managedId),r=a.current[n.id]?.status;N(n.id,{error:e.errors?.[n.managedId],status:t?.updateOperation&&r?{...r,operation:t.updateOperation}:r,submitting:!1})}}async function ie(e,t){let n=a.current[e.id],r=oa(n);if(r&&n.status&&!A.current.has(e.id)&&!Ji(n.status.operation)){A.current.add(e.id),P(e.id),N(e.id,{submitting:!0,error:void 0});try{let i=r===`restart`?{restartOnly:!0}:{version:n.latest},a=await Yi(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...i,...t?.length?{managedUpdates:t}:{}})},e.id),o={...n.status,...a,operation:a.operation??null};if(!o.operation){let t=new Date().toISOString();o.operation=Qi(e.id,{id:t,action:r,phase:r===`restart`?`restarting`:`installing`,fromVersion:n.status.runningVersion,targetVersion:r===`restart`?n.status.diskVersion:n.latest,startedAt:t,changedAt:t})}return N(e.id,{status:o,connectionLost:!1}),o.managedResult}catch(t){N(e.id,{error:t instanceof Error?t.message:`无法确认更新请求是否送达,请检查状态。`})}finally{A.current.delete(e.id),N(e.id,{submitting:!1})}}}async function ae(){if(j.current)return;j.current=!0,p(!0);let e=t.filter(e=>!c.has(e.id));try{await Promise.allSettled(e.filter(e=>!a.current[e.id]?.latest&&!a.current[e.id]?.status?.needsRestart).map(e=>ee(e)));let t=e.filter(e=>e.enabled&&!a.current[e.id]?.error&&oa(a.current[e.id])),n=t.filter(e=>ia(e,a.current[e.id]?.status)),r=t.find(e=>e.id===f),i=n.map(e=>({id:e.managedId,version:a.current[e.id].status?.needsRestart?a.current[e.id].status.diskVersion:a.current[e.id].latest}));if(await Promise.allSettled(t.filter(e=>e.id!==`entry`&&!n.includes(e)).map(e=>ie(e))),r){for(let e of n)N(e.id,{submitting:!0,error:void 0});if(re({errors:(await ie(r,i))?.errors},n),a.current[r.id]?.error)for(let e of n)N(e.id,{error:`本地入口未受理托管更新,请检查本地状态后重试。`})}else if(i.length){for(let e of n)N(e.id,{submitting:!0,error:void 0});try{re(await Yi(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`updateSelected`,updates:i})}),n)}catch(e){for(let t of n)N(t.id,{error:e instanceof Error?e.message:`无法启动托管更新`,submitting:!1})}}}finally{j.current=!1,p(!1)}}let oe=t.map(e=>sa(r[e.id])),se=t.filter(e=>e.enabled&&oa(r[e.id])),le=d||oe.some(e=>[`starting`,`waiting`,`installing`,`restarting`,`checking`].includes(e)),ue=d?`starting`:oe.find(e=>[`waiting`,`installing`,`restarting`,`checking`].includes(e))??(oe.includes(`needs-restart`)?`needs-restart`:oe.includes(`failed`)?`failed`:oe.includes(`completed`)?`completed`:`idle`),de=t.filter(e=>!c.has(e.id)),fe=de.some(e=>oa(r[e.id])),pe=de.some(e=>oa(r[e.id])===`restart`)&&!de.some(e=>oa(r[e.id])===`update`);return{entry:e=>(0,L.jsxs)(`button`,{type:`button`,className:`software-update-entry ${e}`,"data-software-update-entry":ue,"aria-haspopup":`dialog`,"aria-expanded":o,title:`软件更新`,"aria-label":`软件更新`,onClick:e=>{D.current=e.currentTarget,s(e=>!e),ne()},children:[(0,L.jsx)(Xr,{name:`update`}),(0,L.jsx)(`span`,{children:!le&&se.length?`有可用更新`:`软件更新`}),!le&&se.length>0&&(0,L.jsx)(`small`,{"data-update-available":!0,children:se.length===1?$i(r[se[0].id]?.latest??r[se[0].id]?.status?.diskVersion):`${se.length} 个服务`}),le&&(0,L.jsx)(`small`,{children:`进行中`}),!le&&ue===`needs-restart`&&(0,L.jsx)(`small`,{children:`待重启`})]}),panel:o?(0,L.jsx)(ze,{anchor:D.current,label:`软件更新`,className:`software-update-dialog software-update-multi`,onClose:()=>s(!1),children:(0,L.jsxs)(`div`,{className:`software-update-content`,children:[(0,L.jsxs)(`div`,{className:`software-update-header`,children:[(0,L.jsxs)(`h2`,{id:O,children:[(0,L.jsx)(Xr,{name:`update`}),`软件更新`]}),(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"aria-label":`关闭软件更新`,onClick:()=>s(!1),children:(0,L.jsx)(Xr,{name:`close`})})]}),(0,L.jsxs)(`label`,{className:`software-update-note`,children:[`自动检查更新 `,(0,L.jsx)(`select`,{"data-update-check-hours":!0,"aria-label":`自动检查更新间隔`,value:S,onChange:e=>{let t=Number(e.target.value);C(t),localStorage.setItem(ea,String(t))},children:[1,3,6,12,24].map(e=>(0,L.jsxs)(`option`,{value:e,children:[`每 `,e,` 小时`]},e))})]}),(0,L.jsxs)(`div`,{className:`software-update-selection`,children:[(0,L.jsxs)(`span`,{children:[`已选择 `,de.length,` / `,t.length,` 个服务端`]}),(0,L.jsx)(`button`,{type:`button`,disabled:le,onClick:()=>l(new Set),children:`全选`}),(0,L.jsx)(`button`,{type:`button`,disabled:le,onClick:()=>l(new Set(t.map(e=>e.id))),children:`全不选`})]}),(0,L.jsx)(`div`,{className:`software-update-targets`,children:t.map(e=>{let t=r[e.id],n=sa(t),i=t?.status?.operation;return(0,L.jsxs)(`section`,{className:`software-update-target`,"data-update-target":e.id,children:[(0,L.jsxs)(`label`,{className:`software-update-target-label`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:!c.has(e.id),disabled:le,onChange:t=>{let n=t.target.checked;l(t=>{let r=new Set(t);return n?r.delete(e.id):r.add(e.id),r})}}),(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`small`,{children:e.id===`entry`?`本地入口`:ra(e)?`SSH 托管服务`:e.managed?`SSH 原有服务`:`远端服务`})]}),ra(e)&&t?.status&&(0,L.jsx)(`p`,{className:`software-update-note`,children:ia(e,t.status)?`此旧版需要通过已配置的 SSH 连接迁移一次,之后可通过服务端口更新。`:`通过服务端口更新,由该服务器下载并安装纯服务包。`}),(0,L.jsxs)(`dl`,{className:`software-update-versions`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`运行版本`}),(0,L.jsx)(`dd`,{"data-update-version":`running`,children:$i(t?.status?.runningVersion)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`已安装`}),(0,L.jsx)(`dd`,{"data-update-version":`disk`,children:$i(t?.status?.diskVersion)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`目标版本`}),(0,L.jsx)(`dd`,{"data-update-version":`target`,children:$i(Ji(i)?i?.targetVersion:t?.latest??t?.status?.diskVersion)})]})]}),(0,L.jsxs)(`div`,{className:`software-update-progress`,"data-update-progress":n,children:[(0,L.jsx)(`div`,{className:`software-update-summary`,role:`status`,children:ca(t,e.id===`entry`&&!!m)}),[`starting`,`checking`,`waiting`,`installing`,`restarting`].includes(n)&&(0,L.jsx)(`progress`,{"aria-label":ca(t,e.id===`entry`&&!!m)}),t?.connectionLost&&(0,L.jsx)(`small`,{children:`服务连接暂时中断,正在自动重试。`}),!e.enabled&&(0,L.jsx)(`small`,{children:`此连接已停用,需连接后才能更新。`}),t?.error&&(0,L.jsx)(`p`,{role:`alert`,children:t.error}),t?.error&&e.managed&&(0,L.jsx)(`button`,{type:`button`,className:`software-update-secondary`,"data-update-ssh-recovery":!0,onClick:()=>{s(!1),window.dispatchEvent(new Event(`super-pi-open-server-management`))},children:`通过 SSH 恢复离线实例`}),i?.phase===`failed`&&(0,L.jsx)(`p`,{role:`alert`,children:i.failure?.message})]}),e.id===`entry`&&m&&(0,L.jsxs)(`p`,{className:`software-update-note`,children:[`桌面运行版本:`,$i(m.desktopVersion),m.needsDesktopRestart?` · 桌面端待重启`:m.desktopVersion?` · 服务更新完成后会自动重新打开桌面端`:` · 旧桌面外壳,本次更新后请从托盘退出并重新打开一次,之后支持自动重启`]})]},e.id)})}),(0,L.jsx)(`p`,{className:`software-update-note`,children:`远端先更新,本地入口最后重启。重启可能中断对应服务正在运行的任务和终端。`}),(g||m?.restartError)&&(0,L.jsx)(`p`,{role:`alert`,children:g||m?.restartError}),(0,L.jsxs)(`div`,{className:`software-update-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`software-update-secondary`,"data-update-check":!0,disabled:le||!de.length,onClick:()=>void ne(),children:`检查更新`}),window.superPiDesktop?.restart&&(m?.needsDesktopRestart||m?.restartError||sa(r.entry)===`restarting`)&&(0,L.jsx)(`button`,{type:`button`,"data-update-desktop-restart":!0,disabled:v,onClick:()=>void x(),children:v?`正在重启桌面端…`:`重新启动桌面端`}),(0,L.jsxs)(`button`,{type:`button`,className:`software-update-primary`,"data-update-install":pe?void 0:`1`,"data-update-restart":pe?`1`:void 0,disabled:le||!de.length||!fe,onClick:()=>void ae(),children:[(0,L.jsx)(Xr,{name:pe?`restart`:`update`}),pe?`重启所选服务`:`更新并重启所选服务`]})]})]})}):null,status:r[n]?.status,open:e=>{D.current=e?.currentTarget??null,s(!0),ne()}}}function ua(e){let t=0;return e.map(e=>e.key.startsWith(`m:`)?(t=Math.max(t,Number.isFinite(e.at)?e.at:0),{...e,at:t}):e).sort((e,t)=>e.at-t.at||e.seq-t.seq).map(e=>e.key)}var da=new Set,fa=new Map,pa=new Map,ma=!1;function ha(){return typeof window<`u`&&window.superPiDesktop?.notifications?`native`:typeof window>`u`||!(`Notification`in window)?`unsupported`:window.isSecureContext?Notification.permission:`insecure`}async function ga(){return window.superPiDesktop?.notifications?(await window.superPiDesktop.notifications.status()).supported?`native`:`unsupported`:`Notification`in window?Notification.requestPermission():`denied`}function _a(e,t){let n=window.superPiDesktop?.notifications;if(!n)return new Notification(e,{...t,icon:new URL(`/favicon.png`,location.origin).href});ma||(ma=!0,n.onClick(e=>pa.get(e)?.onclick?.()));let r={close:()=>{pa.delete(t.tag),n.close(t.tag),r.onclose?.()}};return pa.get(t.tag)?.close(),pa.set(t.tag,r),pa.size>64&&pa.values().next().value?.close(),r.ready=n.show({id:t.tag,title:e.slice(0,160),body:t.body.slice(0,1e3)}),r.ready.catch(()=>{pa.get(t.tag)===r&&pa.delete(t.tag)}),r}function va(e,t,n,r,i){if(!da.has(e)){da.add(e);try{let t=`super-pi.notification.${e}`;if(localStorage.getItem(t))return;localStorage.setItem(t,`shown`)}catch{}if(!r&&[`granted`,`native`].includes(ha()))try{let r=_a(t,{body:n,tag:e});fa.set(e,r),r.onclick=()=>{window.focus(),i(),r.close(),fa.delete(e)}}catch{}}}function ya(e){for(let[t,n]of fa)e.has(t)||(n.close(),fa.delete(t))}var B=class e extends Error{constructor(t,n){var r=`KaTeX parse error: `+t,i,a,o=n&&n.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start,a=o.end,i===s.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;var c=s.slice(i,a).replace(/[^]/g,`$&̲`),l=i>15?`…`+s.slice(i-15,i):s.slice(0,i),u=a+15<s.length?s.slice(a,a+15)+`…`:s.slice(a);r+=l+c+u}super(r),this.name=`ParseError`,this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,e.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=t}},ba=/([A-Z])/g,xa=e=>e.replace(ba,`-$1`).toLowerCase(),Sa={"&":`&`,">":`>`,"<":`<`,'"':`"`,"'":`'`},Ca=/[&><"']/g,wa=e=>String(e).replace(Ca,e=>Sa[e]),Ta=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?Ta(e.body[0]):e:e.type===`font`?Ta(e.body):e,Ea=new Set([`mathord`,`textord`,`atom`]),Da=e=>Ea.has(Ta(e).type),Oa=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},ka={displayMode:{type:`boolean`,description:`Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.`,cli:`-d, --display-mode`},output:{type:{enum:[`htmlAndMathml`,`html`,`mathml`]},description:`Determines the markup language of the output.`,cli:`-F, --format <type>`},leqno:{type:`boolean`,description:`Render display math in leqno style (left-justified tags).`},fleqn:{type:`boolean`,description:`Render display math flush left.`},throwOnError:{type:`boolean`,default:!0,cli:`-t, --no-throw-on-error`,cliDescription:`Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.`},errorColor:{type:`string`,default:`#cc0000`,cli:`-c, --error-color <color>`,cliDescription:`A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.`,cliProcessor:e=>`#`+e},macros:{type:`object`,cli:`-m, --macro <def>`,cliDescription:`Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).`,cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:`number`,description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:`--min-rule-thickness <size>`,cliProcessor:parseFloat},colorIsTextColor:{type:`boolean`,description:`Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.`,cli:`-b, --color-is-text-color`},strict:{type:[{enum:[`warn`,`ignore`,`error`]},`boolean`,`function`],description:`Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.`,cli:`-S, --strict`,cliDefault:!1},trust:{type:[`boolean`,`function`],description:`Trust the input, enabling all HTML features such as \\url.`,cli:`-T, --trust`},maxSize:{type:`number`,default:1/0,description:`If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large`,processor:e=>Math.max(0,e),cli:`-s, --max-size <n>`,cliProcessor:parseInt},maxExpand:{type:`number`,default:1e3,description:`Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.`,processor:e=>Math.max(0,e),cli:`-e, --max-expand <n>`,cliProcessor:e=>e===`Infinity`?1/0:parseInt(e)},globalGroup:{type:`boolean`,cli:!1}};function Aa(e){if(typeof e!=`string`)return e.enum[0];switch(e){case`boolean`:return!1;case`string`:return``;case`number`:return 0;case`object`:return{};default:throw Error(`Unexpected schema type; settings must declare an explicit default.`)}}function ja(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:Aa(Array.isArray(e.type)?e.type[0]:e.type)}function Ma(e,t,n,r){var i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,a=Object.prototype.hasOwnProperty.call(r,`processor`)?r.processor:void 0;e[t]=i===void 0?ja(r):a?a(i):i}var Na=class{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e||={};for(var t of Object.keys(ka)){var n=ka[t];n&&Ma(this,t,e,n)}}isTrusted(e){if(`url`in e&&e.url&&!e.protocol){var t=Oa(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},Pa=class{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return Ua[Wa[this.id]]}sub(){return Ua[Ga[this.id]]}fracNum(){return Ua[Ka[this.id]]}fracDen(){return Ua[qa[this.id]]}cramp(){return Ua[Ja[this.id]]}text(){return Ua[Ya[this.id]]}isTight(){return this.size>=2}},Fa=0,Ia=1,La=2,Ra=3,za=4,Ba=5,Va=6,Ha=7,Ua=[new Pa(Fa,0,!1),new Pa(Ia,0,!0),new Pa(La,1,!1),new Pa(Ra,1,!0),new Pa(za,2,!1),new Pa(Ba,2,!0),new Pa(Va,3,!1),new Pa(Ha,3,!0)],Wa=[za,Ba,za,Ba,Va,Ha,Va,Ha],Ga=[Ba,Ba,Ba,Ba,Ha,Ha,Ha,Ha],Ka=[La,Ra,za,Ba,Va,Ha,Va,Ha],qa=[Ra,Ra,Ba,Ba,Ha,Ha,Ha,Ha],Ja=[Ia,Ia,Ra,Ra,Ba,Ba,Ha,Ha],Ya=[Fa,Ia,La,Ra,La,Ra,La,Ra],Xa={DISPLAY:Ua[Fa],TEXT:Ua[La],SCRIPT:Ua[za],SCRIPTSCRIPT:Ua[Va]},Za=[{name:`latin`,blocks:[[256,591],[768,879]]},{name:`cyrillic`,blocks:[[1024,1279]]},{name:`armenian`,blocks:[[1328,1423]]},{name:`brahmic`,blocks:[[2304,4255]]},{name:`georgian`,blocks:[[4256,4351]]},{name:`cjk`,blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:`hangul`,blocks:[[44032,55215]]}];function Qa(e){for(var t=0;t<Za.length;t++)for(var n=Za[t],r=0;r<n.blocks.length;r++){var i=n.blocks[r];if(e>=i[0]&&e<=i[1])return n.name}return null}var $a=[];Za.forEach(e=>e.blocks.forEach(e=>$a.push(...e)));function eo(e){for(var t=0;t<$a.length;t+=2)if(e>=$a[t]&&e<=$a[t+1])return!0;return!1}var to=e=>e+` `+e,no=80,ro=function(e,t){return`M95,`+(622+e+t)+`
|
|
23
23
|
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
|
|
24
24
|
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
|
|
25
25
|
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
|
|
@@ -284,7 +284,7 @@ ${h}.`);break;case m:switch(t){case`xml`:break;case``:e.fail(`the default namesp
|
|
|
284
284
|
`&&(s+=1),n.length===500&&s<e.length-1))return{rows:n,clipped:!0}}else i+=c}return(i||r.length)&&(r.length<50?r.push(i):o=!0,n.push(r)),{rows:n,clipped:o}}function Rf({workspaceId:e,cwd:t,path:n,name:r,kind:i,content:a,source:o,version:s,sourceRequest:c,external:l,navigation:d,assetTicket:f,onReload:p}){let[m,h]=(0,u.useState)(c!==void 0),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(!1),b=(r,i)=>f?If(r,e,t,f,i):Ff(r,e,t,n,i),x=b(`asset`,{v:s}),S=b(`asset`,{download:`1`}),C=b(`document`);(0,u.useEffect)(()=>{c!==void 0&&h(!0)},[c]),(0,u.useEffect)(()=>{y(!1)},[x]),(0,u.useEffect)(()=>{if(i!==`document`)return;let e=new AbortController;return je(C,{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error??`无法读取文档。`);_(t)}).catch(t=>{e.signal.aborted||_({error:String(t.message??t)})}),()=>e.abort()},[C,i,s]);let w=(0,u.useMemo)(()=>i===`table`&&!m?Lf(a,/\.tsv$/i.test(n)?` `:`,`):void 0,[i,a,n,m]);return(0,L.jsxs)(`section`,{className:`workspace-file-preview`,"aria-label":`预览 ${r}`,"data-workspace-file-preview":i,"data-file-readonly":f?`1`:void 0,children:[(0,L.jsxs)(`div`,{className:`workspace-file-preview-head`,children:[d,(0,L.jsxs)(`div`,{className:`workspace-file-preview-actions`,children:[f&&(0,L.jsx)(`span`,{children:`外部文件 · 只读`}),f&&p&&(0,L.jsx)(`button`,{type:`button`,onClick:p,children:`重新读取`}),o&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),children:m?`查看表格`:f?`查看原文`:`编辑原文`}),(0,L.jsxs)(`a`,{href:S,download:r,children:[(0,L.jsx)(ti,{name:`download`}),`下载`]})]})]}),l&&!m&&(0,L.jsx)(`p`,{role:`status`,children:o?`磁盘上的文件已变化,请打开原文查看。`:`磁盘上的文件已移走或无法读取。`}),m?o:v?(0,L.jsx)(`p`,{role:`status`,children:`预览无法打开,可以下载文件。`}):(0,L.jsxs)(L.Fragment,{children:[i===`download`&&(0,L.jsx)(`p`,{children:`此文件可以下载。`}),i===`presentation`&&(f?(0,L.jsx)(`p`,{children:`外部演示稿可通过上方按钮下载。`}):(0,L.jsx)(Pf,{workspaceId:e,cwd:t,path:n,version:s})),i===`image`&&(0,L.jsx)(`img`,{src:x,alt:r,onError:()=>y(!0)}),i===`pdf`&&(0,L.jsx)(`iframe`,{src:x,title:r}),i===`audio`&&(0,L.jsx)(`audio`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`video`&&(0,L.jsx)(`video`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`document`&&(g?.error?(0,L.jsx)(`p`,{role:`alert`,children:g.error}):g?(0,L.jsxs)(L.Fragment,{children:[g.warnings?.map(e=>(0,L.jsx)(`p`,{children:e},e)),(0,L.jsx)(`pre`,{children:g.text||`此文档没有可显示的文字。`})]}):(0,L.jsx)(`p`,{children:`正在读取文档…`})),w&&(w.rows.length?(0,L.jsx)(`div`,{className:`workspace-file-table`,children:(0,L.jsx)(`table`,{children:(0,L.jsx)(`tbody`,{children:w.rows.map((e,t)=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`row`,children:t+1}),e.map((e,t)=>(0,L.jsx)(`td`,{children:e},t))]},t))})})}):(0,L.jsx)(`p`,{children:`文件为空。`})),w?.clipped&&(0,L.jsx)(`p`,{className:`workspace-file-preview-limit`,children:`表格超出预览范围。完整内容可在原文中查看。`})]})]})}var zf={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,avif:`image/avif`,pdf:`application/pdf`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`,m4a:`audio/mp4`,mp4:`video/mp4`,webm:`video/webm`,ogv:`video/ogg`};function Bf(e){return/\.([^./]+)$/.exec(e)?.[1].toLowerCase()??``}function Vf(e){let t=Bf(e);return Object.hasOwn(zf,t)?zf[t]:void 0}function Hf(e){let t=Vf(e);if(t===`application/pdf`)return`pdf`;if(t?.startsWith(`image/`))return`image`;if(t?.startsWith(`audio/`))return`audio`;if(t?.startsWith(`video/`))return`video`;if(/\.(csv|tsv)$/i.test(e))return`table`;if(/\.docx$/i.test(e))return`document`;if(/\.pptx$/i.test(e))return`presentation`}var Uf=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`))),Wf=(e,t)=>!t||e===t||e.startsWith(`${t}/`),Gf=e=>e.split(`/`).at(-1)??e;function Kf(e){if(!(e instanceof Element))return;let t=e.closest(`[data-file-dir], [data-file-entry], [data-file-hit]`);if(!t)return;let n=t.dataset.fileDir??t.dataset.fileEntry??t.dataset.fileHit;if(n!==void 0)return{path:n,directory:t.dataset.fileDir!==void 0,linked:t.dataset.linked===`true`||t.dataset.fileOutside!==void 0}}function qf({title:e,cancel:t,children:n}){let r=(0,u.useRef)(null);return(0,u.useEffect)(()=>{let e=r.current,t=document.activeElement;return e?.showModal(),()=>{e?.close(),t?.isConnected&&t.focus()}},[]),(0,L.jsx)(`dialog`,{ref:r,className:`file-explorer-dialog`,"aria-label":e,onCancel:e=>{e.preventDefault(),t()},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{className:`file-explorer-dialog-body`,children:[(0,L.jsx)(`h2`,{children:e}),n]})})}function Jf({target:e,label:t,initial:n,busy:r,error:i,depth:a,submit:o,close:s}){let c=(0,u.useRef)(null);return(0,u.useLayoutEffect)(()=>{let t=c.current;if(!t)return;t.focus();let r=n.lastIndexOf(`.`);t.setSelectionRange(0,!e.directory&&r>0?r:n.length)},[n,e.directory]),(0,L.jsxs)(`form`,{className:`file-inline-edit`,"data-file-inline-edit":e.path,"aria-label":t,style:{paddingInlineStart:23+a*15},onSubmit:o,onKeyDown:e=>{e.key===`Escape`&&!r&&(e.preventDefault(),e.stopPropagation(),s())},children:[(0,L.jsxs)(`div`,{className:`file-inline-row`,children:[(0,L.jsx)(Br,{path:e.path,category:e.directory?`folder`:void 0}),(0,L.jsx)(`input`,{ref:c,name:`name`,required:!0,defaultValue:n,placeholder:t,"aria-label":t,"aria-invalid":!!i,readOnly:r,autoComplete:`off`,spellCheck:!1}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`submit`,title:t,"aria-label":t,disabled:r,children:(0,L.jsx)(ti,{name:`right`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,onClick:s,disabled:r,title:`取消`,"aria-label":`取消`,children:(0,L.jsx)(ti,{name:`close`})})]}),i&&(0,L.jsx)(`p`,{className:`file-inline-error`,role:`alert`,children:i})]})}function Yf({files:e,source:t,scopeName:n}){let[r,i]=(0,u.useState)(Uf(t.path)),a=e.listings[r],o=e.loadDirectory;(0,u.useEffect)(()=>{a||o(r)},[r,a,o]);let s=a&&`entries`in a?a.entries.filter(e=>e.kind===`directory`&&!e.symlink&&!(t.directory&&Wf(e.path,t.path))):[];return(0,L.jsxs)(`div`,{className:`file-move-picker`,children:[(0,L.jsx)(`input`,{type:`hidden`,name:`parent`,value:r}),(0,L.jsxs)(`div`,{className:`file-move-location`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:!r,"aria-label":`上一级`,onClick:()=>i(Uf(r)),children:`↑`}),(0,L.jsx)(`span`,{title:r||n,children:r||n})]}),(0,L.jsx)(`ul`,{"aria-label":`目标文件夹`,children:s.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),children:[(0,L.jsx)(Br,{category:`folder`}),(0,L.jsx)(`span`,{children:e.name}),(0,L.jsx)(ti,{name:`right`})]})},e.path))}),!s.length&&(0,L.jsx)(`p`,{children:a?`error`in a?a.error.message:`此处没有子文件夹。`:`正在读取文件夹…`})]})}function Xf({workspaceId:e,scopeName:t,cwd:n,files:r,onOpen:i,onReference:a,onMoved:o,onSearchFolder:s}){let[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(),[p,m]=(0,u.useState)(),[h,g]=(0,u.useState)(!1),[_,v]=(0,u.useState)(``),[y,b]=(0,u.useState)(),x=(0,u.useRef)(null),S=(0,u.useRef)(``),C=(0,u.useRef)(void 0),w=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{let e={controller:new AbortController};return w.current=e,l(void 0),f(void 0),m(void 0),b(void 0),g(!1),v(``),()=>{e.controller.abort(),w.current===e&&(w.current=void 0)}},[e,n]);let T=(t,r=``,i)=>Ff(t,e??``,n,r,i);async function E(e,t){let n=await je(e,{...t,signal:w.current?.controller.signal}),r=await n.json();if(!n.ok)throw Error(r.error??`操作失败(${n.status})`);return r}function D(e,t){c?.anchor.origin===t.origin&&c.target.path===e.path?l(void 0):l({target:e,anchor:t})}function O(e){l(void 0),e&&c?.anchor.origin.isConnected&&c.anchor.origin.focus({preventScroll:!0})}function k(e,t,n,i){C.current=i??c?.anchor.origin??(document.activeElement instanceof HTMLElement?document.activeElement:void 0),l(void 0),v(``),f({action:e,target:t,move:n}),e===`create-file`||e===`create-directory`?t.path?r.revealPath(`${t.path}/`):r.setQuery(``):e===`move`&&!n&&r.revealPath(t.path)}function A(){f(void 0);let e=C.current;requestAnimationFrame(()=>{e?.isConnected&&e.offsetParent?e.focus({preventScroll:!0}):d?.target.path&&r.locatePath(d.target.path,d.target.directory)})}async function j(t){let a=w.current;g(!0),v(``);try{let s=await E(T(`tree`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(w.current!==a)return;if(s.previousPath&&s.previousPath!==s.path?(r.movePath(s.previousPath,s.path,s.text),o?.(s.previousPath,s.path)):s.removed||r.revealPath(s.path),r.invalidateTree(e??``,[s.path,...s.previousPath?[s.previousPath]:[]].map(e=>n?`${n}/${e}`:e)),s.removed){for(let e of r.open)Wf(e.path,s.path)&&!e.dirty&&r.closeFile(e.path);r.locatePath(Uf(s.path),!0)}f(void 0),t.action===`restore`&&m(e=>e?.filter(e=>e.id!==t.id)),t.action===`create-file`&&s.text!==!1&&i({path:s.path,name:Gf(s.path),text:!0},!0),t.action!==`restore`&&!s.removed&&r.locatePath(s.path,!!s.directory),r.setNotice(s.removed?`已移到回收站:${s.path}`:t.action===`restore`?`已恢复:${s.path}`:``)}catch(e){if(w.current===a){let t=e instanceof Error?e.message:String(e);v(t),d||r.setNotice(t)}}finally{w.current===a&&g(!1)}}function M(e){if(e.preventDefault(),!d||h)return;let{action:t,target:n}=d;if((t===`move`||t===`trash`)&&Object.entries(r.saves).some(([e,t])=>Wf(e,n.path)&&t.state===`saving`)){v(`文件正在保存,等保存结束后再操作。`);return}if(t===`trash`&&r.open.some(e=>e.dirty&&Wf(e.path,n.path))){v(`这里有未保存的草稿,请先保存。`);return}let i=new FormData(e.currentTarget),a=String(i.get(`name`)??Gf(n.path));if(t===`move`&&!n.directory&&Bf(n.path)!==Bf(a)&&r.open.some(e=>e.path===n.path&&e.dirty)){v(`更换文件扩展名之前,请先保存草稿。`);return}let o=String(i.get(`parent`)??(t===`move`?Uf(n.path):n.path));d.move&&o===Uf(n.path)?v(`请选择另一个文件夹。`):j({action:t,path:n.path,parent:o,name:a})}async function N(){let e=w.current;l(void 0),v(``);try{let t=await E(T(`tree`));w.current===e&&m(t.entries)}catch(t){w.current===e&&r.setNotice(String(t.message))}}function P(e){S.current=e,O(!0),x.current?.click()}async function F(t,i,a){let o=w.current;if(!e||!o||!i.length||h)return;g(!0),v(``),b(void 0);let s=[],c=[],l=[];try{for(let e of i){if(o!==w.current)return;try{let n=a?.find(t=>t.file===e)?.etag;if(!a){let n=await E(T(`upload-check`,t,{name:e.name}));if(n.exists){!n.replaceable||!n.meta?c.push(`${e.name}:同名目录或链接`):s.push({file:e,etag:n.meta.etag});continue}}let r=await E(T(`upload`,t,{name:e.name}),{method:`POST`,headers:{"content-type":`application/octet-stream`,...n?{"if-match":n}:{}},body:e});l.push(r.path)}catch(t){c.push(`${e.name}:${t.message}`)}}if(w.current!==o)return;l[0]&&r.revealPath(l[0]),l.length&&r.invalidateTree(e,l.map(e=>n?`${n}/${e}`:e)),s.length&&b({parent:t,items:s}),r.setNotice([l.length?`已上传 ${l.length} 个文件`:``,...c].filter(Boolean).join(`。`))}finally{w.current===o&&g(!1)}}function ee(e,t){l(void 0),a?.(e||`.`,t)}function te(e){O(!0),ai(e||`.`).then(t=>r.setNotice(t?`已复制相对路径。`:`相对路径:${e||`.`}`))}let ne=d?.action===`create-file`?`新建文件`:d?.action===`create-directory`?`新建文件夹`:d?.action===`trash`?`移到回收站`:d?.move?`移动到文件夹`:`重命名`,re={path:``,directory:!0},ie=d?.action===`create-file`||d?.action===`create-directory`,ae=d?.action===`move`&&!d.move,oe=(e,t,n)=>!d||d.target.path!==e||(t===`child`?!ie:!ae)?null:(0,L.jsx)(Jf,{target:{...d.target,directory:ie?d.action===`create-directory`:d.target.directory},label:ne,initial:ae?Gf(e):``,busy:h,error:_,depth:n,submit:M,close:A},`${d.action}:${e}`),se=(e,t)=>{h||e.linked||e.directory&&Wf(t,e.path)||t===Uf(e.path)||(Object.entries(r.saves).some(([t,n])=>Wf(t,e.path)&&n.state===`saving`)?r.setNotice(`文件正在保存,等保存结束后再移动。`):j({action:`move`,path:e.path,parent:t,name:Gf(e.path)}))},ce=(0,L.jsxs)(`div`,{className:`file-explorer-toolbar`,role:`group`,"aria-label":`文件操作`,children:[(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-file`,title:`新建文件`,"aria-label":`新建文件`,onClick:e=>k(`create-file`,re,!1,e.currentTarget),disabled:!e||h,children:(0,L.jsx)(ti,{name:`file`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-directory`,title:`新建文件夹`,"aria-label":`新建文件夹`,onClick:e=>k(`create-directory`,re,!1,e.currentTarget),disabled:!e||h,children:(0,L.jsx)(ti,{name:`folder`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-refresh":`1`,title:`刷新目录`,"aria-label":`刷新目录`,onClick:r.refreshTree,disabled:!e,children:(0,L.jsx)(ti,{name:`refresh`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-collapse-all":`1`,title:`折叠所有文件夹`,"aria-label":`折叠所有文件夹`,onClick:r.collapseDirectories,disabled:!r.expanded.size,children:(0,L.jsx)(ti,{name:`collapse`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`root-menu`,"aria-haspopup":`menu`,"aria-expanded":c?.target.path===``,onClick:e=>D(re,ni(e.currentTarget)),title:`更多文件操作`,"aria-label":`更多文件操作`,disabled:!e||h,children:(0,L.jsx)(ti,{name:`more`})})]}),le=(e,t,n,r,i)=>(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`file-context-item`,"data-explorer-command":r,onClick:n,children:[(0,L.jsx)(ti,{name:t}),(0,L.jsx)(`span`,{children:e}),i&&(0,L.jsx)(`kbd`,{children:i})]});return{controls:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{ref:x,type:`file`,multiple:!0,hidden:!0,"aria-label":`上传工作区文件`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,F(S.current,t)}}),c&&(0,L.jsxs)(ri,{label:c.target.path||t,anchor:c.anchor,close:O,children:[c.target.directory&&!c.target.linked&&(0,L.jsxs)(L.Fragment,{children:[s&&le(`在此文件夹中搜索`,`search`,()=>{let e=c.target.path;O(!1),s(e)},`search-folder`),le(`新建文件`,`file`,()=>k(`create-file`,c.target),`new-file`),le(`新建文件夹`,`folder`,()=>k(`create-directory`,c.target),`new-directory`),le(`上传到此处`,`upload`,()=>P(c.target.path),`upload`),(0,L.jsx)(`div`,{role:`separator`})]}),c.target.path&&!c.target.linked&&(0,L.jsxs)(L.Fragment,{children:[le(`重命名`,`rename`,()=>k(`move`,c.target),`rename`,`F2`),le(`移动到文件夹`,`move`,()=>k(`move`,c.target,!0),`move`),(0,L.jsx)(`div`,{role:`separator`})]}),!c.target.linked&&a&&le(`引用到会话`,`reference`,()=>ee(c.target.path,c.target.directory),`reference`),le(`复制相对路径`,`copy`,()=>te(c.target.path)),!c.target.directory&&!c.target.linked&&(0,L.jsxs)(`a`,{role:`menuitem`,tabIndex:-1,className:`file-context-item`,href:T(`asset`,c.target.path,{download:`1`}),download:Gf(c.target.path),onClick:()=>O(!0),children:[(0,L.jsx)(ti,{name:`download`}),(0,L.jsx)(`span`,{children:`下载`})]}),!c.target.path&&le(`打开回收站`,`trash`,()=>void N(),`trash-list`),!!c.target.path&&!c.target.linked&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{role:`separator`}),le(`移到回收站`,`trash`,()=>k(`trash`,c.target),`trash`,`Delete`)]})]}),d&&!ie&&!ae&&(0,L.jsx)(qf,{title:ne,cancel:()=>{h||A()},children:(0,L.jsxs)(`form`,{onSubmit:M,className:`file-explorer-form`,children:[d.action===`trash`?(0,L.jsxs)(`p`,{children:[`将「`,d.target.path,`」移到回收站?`]}):(0,L.jsx)(Yf,{files:r,source:d.target,scopeName:t}),_&&(0,L.jsx)(`p`,{role:`alert`,children:_}),(0,L.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:h,onClick:A,children:`取消`}),(0,L.jsx)(`button`,{type:`submit`,disabled:h,children:d.move?`移动到此处`:ne})]})]})}),p&&(0,L.jsxs)(qf,{title:`回收站`,cancel:()=>{h||m(void 0)},children:[_&&(0,L.jsx)(`p`,{role:`alert`,children:_}),p.length?(0,L.jsx)(`ul`,{className:`file-explorer-trash`,children:p.map(e=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`span`,{children:e.path}),(0,L.jsx)(`button`,{type:`button`,"data-explorer-restore":e.path,disabled:h,onClick:()=>void j({action:`restore`,id:e.id}),children:`还原`})]},e.id))}):(0,L.jsx)(`p`,{children:`回收站为空。`}),(0,L.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>m(void 0),children:`关闭`})]}),y&&(0,L.jsxs)(qf,{title:`同名文件`,cancel:()=>b(void 0),children:[(0,L.jsx)(`p`,{children:`以下文件已经存在。替换前会再次检查磁盘版本。`}),(0,L.jsx)(`ul`,{children:y.items.map(e=>(0,L.jsx)(`li`,{children:e.file.name},e.file.name))}),(0,L.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{r.setNotice(`已跳过 ${y.items.length} 个同名文件。`),b(void 0)},children:`跳过`}),(0,L.jsx)(`button`,{type:`button`,"data-file-replace-upload":`1`,onClick:()=>void F(y.parent,y.items.map(e=>e.file),y.items),children:`替换`})]})]})]}),toolbar:ce,inline:oe,editing:ie||ae,busy:h,openMenu:D,showAction:k,upload:F,moveTo:se}}var Zf=[{id:`path`,label:`文件名 / 路径`,shortcut:`Ctrl+P`},{id:`content`,label:`文件内容`,shortcut:`Ctrl+Shift+F`},{id:`session`,label:`会话消息`}];function Qf({mode:e,query:t,onClose:n,onMode:r,children:i,presentation:a}){let o=e===`path`?{"data-quick-open":`1`}:e===`content`?{"data-content-search":`1`}:{"data-session-search":`1`},s=(0,L.jsx)(`div`,{className:`workbench-search-modes`,role:`group`,"aria-label":`搜索范围`,children:Zf.map(n=>(0,L.jsx)(`button`,{type:`button`,"data-workbench-search-mode":n.id,"aria-pressed":n.id===e,title:n.shortcut,onClick:()=>{n.id!==e&&r(n.id,t)},children:n.label},n.id))});return a===`sidebar`?(0,L.jsxs)(`div`,{className:`workbench-search-embedded`,...o,children:[s,i]}):(0,L.jsx)(`div`,{className:`quick-open-backdrop`,...o,role:`presentation`,onMouseDown:n,children:(0,L.jsxs)(`div`,{className:e===`path`?`quick-open`:`quick-open content-search`,role:`dialog`,"aria-modal":`true`,"aria-label":Zf.find(t=>t.id===e)?.label,onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&(e.preventDefault(),n())},children:[s,i]})})}function $f({workspaceId:e,initialQuery:t=``,onClose:n,onMode:r,onOpen:i,presentation:a}){let[o,s]=(0,u.useState)(t),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(0),[h,g]=(0,u.useState)(!1),_=(0,u.useRef)(null),v=(0,u.useRef)(null);return(0,u.useEffect)(()=>{_.current?.focus()},[]),(0,u.useEffect)(()=>{v.current?.scrollIntoView({block:`nearest`})},[p]),(0,u.useEffect)(()=>{let t=o.trim();if(l(void 0),m(0),f(``),g(!1),!e||!t)return;if(t.length>256){f(`搜索词不能超过 256 个字符。`);return}let n=new AbortController;g(!0);let r=setTimeout(()=>{je(`/api/session-search?${new URLSearchParams({workspaceId:e,q:t})}`,{signal:n.signal}).then(async e=>{if(!e.ok)throw Error(`会话搜索没有完成。`);return await e.json()}).then(e=>{n.signal.aborted||l(e)}).catch(e=>{n.signal.aborted||f(Nr(e,`会话搜索没有完成。`))}).finally(()=>{n.signal.aborted||g(!1)})},180);return()=>{clearTimeout(r),n.abort()}},[o,e]),(0,L.jsxs)(Qf,{mode:`session`,query:o,onMode:r,onClose:n,presentation:a,children:[(0,L.jsx)(`input`,{ref:_,className:`quick-open-input`,"data-session-search-input":!0,value:o,"aria-label":`搜索会话消息`,placeholder:`输入要在会话消息中查找的文字`,onChange:e=>s(e.target.value),onKeyDown:e=>{if(!e.nativeEvent.isComposing&&(e.key===`ArrowDown`&&(e.preventDefault(),m(e=>Math.min(e+1,Math.max(0,(c?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),m(e=>Math.max(0,e-1))),e.key===`Enter`)){e.preventDefault();let t=c?.hits[p];t&&i(t)}}}),(0,L.jsx)(`p`,{className:`quick-open-status`,role:`status`,"data-session-search-status":!0,children:d||(h?`搜索中…`:e?c?c.truncated?`显示前 60 条命中`:`${c.hits.length} 条命中`:`当前工作区的未归档会话 · 用户和 Agent 消息`:`请选择工作区`)}),(0,L.jsx)(`ul`,{className:`quick-open-results content-search-results`,"aria-label":`会话搜索结果`,children:c?.hits.map((e,t)=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{ref:t===p?v:void 0,type:`button`,"data-session-search-result":e.messageId,className:`quick-open-result content-search-result${p===t?` quick-open-result-active`:``}`,onMouseEnter:()=>m(t),onClick:()=>i(e),children:[(0,L.jsxs)(`span`,{children:[e.title,` · `,e.role===`user`?`用户`:`Agent`]}),(0,L.jsxs)(`small`,{children:[e.before,(0,L.jsx)(`mark`,{children:e.match}),e.after]})]})},`${e.conversationId}:${e.messageId}`))})]})}var ep=class extends u.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[SuperPi ErrorBoundary captured error]:`,e,t)}reset=()=>{this.setState({error:null})};render(){let{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,this.reset):(0,L.jsxs)(`div`,{className:`error-boundary-card`,"data-error-boundary":`1`,children:[(0,L.jsxs)(`div`,{className:`error-boundary-head`,children:[(0,L.jsx)(`span`,{className:`error-boundary-icon`,"aria-hidden":`true`,children:`⚠️`}),(0,L.jsx)(`strong`,{children:`视图渲染遇到异常`})]}),(0,L.jsx)(`p`,{className:`error-boundary-msg`,children:e.message||`未知组件错误`}),(0,L.jsx)(`button`,{type:`button`,className:`error-boundary-retry`,onClick:this.reset,children:`重试`})]}):this.props.children}};function tp(){}tp.prototype={diff:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.callback;typeof n==`function`&&(r=n,n={}),this.options=n;var i=this;function a(e){return r?(setTimeout(function(){r(void 0,e)},0),!0):e}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var o=t.length,s=e.length,c=1,l=o+s;n.maxEditLength&&(l=Math.min(l,n.maxEditLength));var u=n.timeout??1/0,d=Date.now()+u,f=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(f[0],t,e,0);if(f[0].oldPos+1>=s&&p+1>=o)return a([{value:this.join(t),count:t.length}]);var m=-1/0,h=1/0;function g(){for(var n=Math.max(m,-c);n<=Math.min(h,c);n+=2){var r=void 0,l=f[n-1],u=f[n+1];l&&(f[n-1]=void 0);var d=!1;if(u){var g=u.oldPos-n;d=u&&0<=g&&g<o}var _=l&&l.oldPos+1<s;if(!d&&!_)f[n]=void 0;else{if(r=!_||d&&l.oldPos+1<u.oldPos?i.addToPath(u,!0,void 0,0):i.addToPath(l,void 0,!0,1),p=i.extractCommon(r,t,e,n),r.oldPos+1>=s&&p+1>=o)return a(np(i,r.lastComponent,t,e,i.useLongestToken));f[n]=r,r.oldPos+1>=s&&(h=Math.min(h,n-1)),p+1>=o&&(m=Math.max(m,n+1))}}c++}if(r)(function e(){setTimeout(function(){if(c>l||Date.now()>d)return r();g()||e()},0)})();else for(;c<=l&&Date.now()<=d;){var _=g();if(_)return _}},addToPath:function(e,t,n,r){var i=e.lastComponent;return i&&i.added===t&&i.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:i.count+1,added:t,removed:n,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:i}}},extractCommon:function(e,t,n,r){for(var i=t.length,a=n.length,o=e.oldPos,s=o-r,c=0;s+1<i&&o+1<a&&this.equals(t[s+1],n[o+1]);)s++,o++,c++;return c&&(e.lastComponent={count:c,previousComponent:e.lastComponent}),e.oldPos=o,s},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t},castInput:function(e){return e},tokenize:function(e){return e.split(``)},join:function(e){return e.join(``)}};function np(e,t,n,r,i){for(var a=[],o;t;)a.push(t),o=t.previousComponent,delete t.previousComponent,t=o;a.reverse();for(var s=0,c=a.length,l=0,u=0;s<c;s++){var d=a[s];if(!d.removed){if(!d.added&&i){var f=n.slice(l,l+d.count);f=f.map(function(e,t){var n=r[u+t];return n.length>e.length?n:e}),d.value=e.join(f)}else d.value=e.join(n.slice(l,l+d.count));l+=d.count,d.added||(u+=d.count)}else if(d.value=e.join(r.slice(u,u+d.count)),u+=d.count,s&&a[s-1].added){var p=a[s-1];a[s-1]=a[s],a[s]=p}}var m=a[c-1];return c>1&&typeof m.value==`string`&&(m.added||m.removed)&&e.equals(``,m.value)&&(a[c-2].value+=m.value,a.pop()),a}new tp;var rp=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,ip=/\S/,ap=new tp;ap.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!ip.test(e)&&!ip.test(t)},ap.tokenize=function(e){for(var t=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),n=0;n<t.length-1;n++)!t[n+1]&&t[n+2]&&rp.test(t[n])&&rp.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var op=new tp;op.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
285
285
|
`));var t=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var r=0;r<n.length;r++){var i=n[r];r%2&&!this.options.newlineIsToken?t[t.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),t.push(i))}return t};function sp(e,t,n){return op.diff(e,t,n)}var cp=new tp;cp.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var lp=new tp;lp.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function up(e){"@babel/helpers - typeof";return up=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},up(e)}var dp=Object.prototype.toString,fp=new tp;fp.useLongestToken=!0,fp.tokenize=op.tokenize,fp.castInput=function(e){var t=this.options,n=t.undefinedReplacement,r=t.stringifyReplacer,i=r===void 0?function(e,t){return t===void 0?n:t}:r;return typeof e==`string`?e:JSON.stringify(pp(e,null,null,i),i,` `)},fp.equals=function(e,t){return tp.prototype.equals.call(fp,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function pp(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i,e));for(var a=0;a<t.length;a+=1)if(t[a]===e)return n[a];var o;if(dp.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=pp(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),up(e)===`object`&&e!==null){t.push(e),o={},n.push(o);var s=[],c;for(c in e)e.hasOwnProperty(c)&&s.push(c);for(s.sort(),a=0;a<s.length;a+=1)c=s[a],o[c]=pp(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var mp=new tp;mp.tokenize=function(e){return e.slice()},mp.join=mp.removeEmpty=function(e){return e};function hp(e,t){let n=sp(e??``,t??``),r=[],i=0,a=0,o=1,s=1;for(let e of n){let t=e.value.split(`
|
|
286
286
|
`),n=t.length>0&&t[t.length-1]===``;n&&t.pop();for(let c=0;c<t.length;c+=1){let l=t[c],u=c===t.length-1&&!n;e.added?(r.push({kind:`added`,text:l,newLine:s,noNewline:u}),s+=1,i+=1):e.removed?(r.push({kind:`removed`,text:l,oldLine:o,noNewline:u}),o+=1,a+=1):(r.push({kind:`same`,text:l,oldLine:o,newLine:s,noNewline:u}),o+=1,s+=1)}}return{lines:r,added:i,removed:a,identical:i===0&&a===0}}function gp(e,t=3){let n=new Set;e.lines.forEach((r,i)=>{if(r.kind!==`same`)for(let r=-t;r<=t;r+=1){let t=i+r;t>=0&&t<e.lines.length&&n.add(t)}});let r=[],i=0,a=!1;return e.lines.forEach((e,t)=>{n.has(t)?(a&&=(r.push({kind:`fold`,text:`⋯ 省略未改动的行`}),!1),r.push(e)):a||(a=!0,i+=1)}),a&&r.push({kind:`fold`,text:`⋯ 省略未改动的行`}),{lines:r,folded:i}}var _p=`super-pi.outbox.v1.`,vp=e=>_p+JSON.stringify([e.conversationId,e.clientId]);function yp(){try{let e=[];for(let t of Object.keys(window.localStorage).filter(e=>e.startsWith(_p)))try{let n=JSON.parse(window.localStorage.getItem(t)??`null`),r=n?.send;r?.type===`message.send`&&typeof r.conversationId==`string`&&/^message_[0-9a-f-]{36}$/.test(r.clientId)&&typeof r.content==`string`&&t===vp(r)&&e.push(n)}catch{}return e.sort((e,t)=>e.queuedAt-t.queuedAt).map(e=>e.send)}catch{return[]}}function bp(e){try{return window.localStorage.setItem(vp(e),JSON.stringify({queuedAt:Date.now(),send:e})),!0}catch{return!1}}function xp(e,t){try{window.localStorage.removeItem(vp({conversationId:e,clientId:t}))}catch{}}function Sp(e){return m(h(e.conversationId).server,e.clientId)}function Cp(e,t,n){let r=e.conversations.find(e=>e.id===t.conversationId),i=Sp(t);if(!r||r.messages.some(e=>e.id===i))return e;let a=r.status===`running`||r.status===`waiting`;return{...e,conversations:e.conversations.map(e=>e===r?{...e,...a?{}:{status:`waiting`,updatedAt:n},messages:[...e.messages,{id:i,role:`user`,content:t.content,createdAt:n,...t.images?.length?{images:t.images}:{},...t.attachments?.length?{attachments:t.attachments}:{},...a?{delivery:`waiting`}:{}}]}:e)}}function wp(e,t){try{return JSON.parse(zn(e)??`null`)??t}catch{return t}}function Tp(e,t){try{return Bn(e,JSON.stringify(t)),!0}catch{return!1}}var Ep=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.name=`BlameApiError`,this.status=e,this.body=t}},Dp=class extends Error{constructor(){super(`Blame 请求已取消`),this.name=`BlameCancelledError`}},Op=(e,t,n=``)=>`/api/git?workspaceId=${encodeURIComponent(e)}&op=blame&path=${encodeURIComponent(t)}${n?`&cwd=${encodeURIComponent(n)}`:``}`;async function kp(e,t,n={}){if(n.signal?.aborted)throw new Dp;let r=n.timeoutMs??15e3,i=new AbortController,a=!1,o=setTimeout(()=>{a=!0,i.abort()},r),s=()=>i.abort();n.signal?.addEventListener(`abort`,s,{once:!0});try{let r=await je(Op(e,t,n.cwd),{signal:i.signal}),a;try{a=await r.json()}catch{a=void 0}if(!r.ok){let e=a??{};throw new Ep(r.status,{error:e.error||`HTTP ${r.status}`,...e.code?{code:e.code}:{}})}return a}catch(e){throw n.signal?.aborted?new Dp:a?new Ep(408,{error:`请求超时:${Math.round(r/1e3)} 秒内服务端没有响应`,code:`timeout`}):e}finally{clearTimeout(o),n.signal?.removeEventListener(`abort`,s)}}var Ap=`\0`,jp=(e,t,n)=>[e,t,n??``].join(Ap),Mp=24,Np=new Map;function Pp(e){let t=Np.get(e);if(t)return Np.delete(e),Np.set(e,t),t}function Fp(e,t){for(Np.delete(e),Np.set(e,t);Np.size>Mp;){let e=Np.keys().next();if(e.done)break;Np.delete(e.value)}}var Ip={untracked:`这个文件尚未被 Git 跟踪`,binary:`二进制文件不支持 Blame`,too_large:`文件过大,未显示 Blame`,no_head:`仓库还没有提交`,not_in_revision:`这个版本里没有这个文件`},Lp=`此工作区不是 Git 仓库`;function Rp(e){return e&&Ip[e]?{code:e,text:Ip[e]}:{code:`unsupported`,text:`这个文件暂时不能显示 Blame`}}function zp(e){return e instanceof Ep&&e.body.code===`not_a_repo`?{state:`unsupported`,note:{code:`not_a_repo`,text:Lp}}:{state:`error`,note:{code:`error`,text:`读取 Blame 失败:${e instanceof Error&&e.message?e.message:`未知错误`}`}}}var Bp=`${Ap}uncommitted`;function Vp(e){let t=new Map,n=0;for(let r of e.lines)t.has(r.line)||t.set(r.line,r),r.line>n&&(n=r.line);let r=[],i=null,a=0;for(let e=1;e<=n;e+=1){let n=t.get(e);if(!n){r.push({line:e,kind:`missing`,data:null}),i=null,a=e;continue}let o=n.isUncommitted?Bp:n.commit??`${Ap}none`,s=o===i&&e===a+1?`continuation`:n.isUncommitted?`uncommitted`:`commit`;r.push({line:e,kind:s,data:n}),i=o,a=e}if(e.truncated)for(let t=n+1;t<=e.totalLines;t+=1)r.push({line:t,kind:`truncated`,data:null});return r}function Hp(e){let t=0;for(let n of e.lines)n.line>t&&(t=n.line);return t}function Up(e){switch(e.kind){case`commit`:{let t=e.data,n=t?.shortCommit??t?.commit?.slice(0,8)??`?`,r=t?.author?.trim();return r?`${n} · ${r}`:n}case`continuation`:return`│`;case`uncommitted`:return`● 未提交`;case`missing`:return`?`;case`truncated`:return`…`;default:return``}}function Wp(e){if(e.kind===`uncommitted`||e.data?.isUncommitted)return[`未提交`,`这行尚不属于任何 Git 提交`];if(e.kind===`missing`)return[`没有 Blame 信息`,`这一行没有对应的提交记录`];if(e.kind===`truncated`)return[`Blame 数据已截断`,`文件太长,只显示了前面一部分的提交信息`];let t=e.data;if(!t)return[`没有 Blame 信息`];let n=t.shortCommit??t.commit?.slice(0,8)??`未知提交`,r=t.author?.trim()||`未知作者`;return[n,t.authorEmail?`${r} <${t.authorEmail}>`:r,Gp(t.date),t.summary?.trim()||`(没有提交摘要)`]}function Gp(e){if(!e)return`不详`;let t=new Date(e);if(!Number.isFinite(t.getTime()))return e;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function Kp(e){if(e.length===0)return 0;let t=1;for(let n=0;n<e.length;n+=1)e.charCodeAt(n)===10&&(t+=1);return e.charCodeAt(e.length-1)===10&&--t,t}function qp(e,t,n=!1){return!t||!t.supported?!1:n||Kp(e)!==t.totalLines}var Jp=new WeakMap;function Yp(e){let t=Jp.get(e);if(t)return t;let n={response:e,models:Vp(e),covered:Hp(e)};return Jp.set(e,n),n}function Xp(e,t){if(!e||t<1)return null;let n=e.models[t-1];return n&&n.line===t?n:null}var Zp=`a1b2c3d · Author`;async function Qp(){let[e,t]=await Promise.all([Cn(()=>import(`./dist-D978o95T.js`).then(e=>e.S),__vite__mapDeps([2,1])),Cn(()=>import(`./dist-B3-a6uF0.js`).then(e=>e.s),__vite__mapDeps([3,1,2]))]),n=e.StateEffect.define(),r=e.StateField.define({create:()=>null,update:(e,t)=>{for(let e of t.effects)if(e.is(n))return e.value;return e}}),i=e.StateEffect.define(),a=e.StateField.define({create:()=>null,update:(e,t)=>{for(let e of t.effects)if(e.is(i))return e.value;return e}}),o=t.GutterMarker;class s extends o{model;constructor(e){super(),this.model=e}eq(e){let t=e.model;return t?t.line===this.model.line&&t.kind===this.model.kind&&t.data?.commit===this.model.data?.commit&&t.data?.summary===this.model.data?.summary&&t.data?.author===this.model.data?.author:!1}toDOM(){let e=document.createElement(`span`);e.className=`cm-blame-marker cm-blame-${this.model.kind}`,e.setAttribute(`data-file-blame-line`,String(this.model.line)),e.setAttribute(`data-file-blame-kind`,this.model.kind),this.model.data?.commit&&e.setAttribute(`data-file-blame-commit`,this.model.data.commit);let t=Wp(this.model);return e.setAttribute(`title`,t.join(`
|
|
287
|
-
`)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=Up(this.model),e}}class c extends o{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-blame-marker cm-blame-spacer`,e.textContent=Zp,e}}let l=t.gutter({class:`cm-blame-gutter`,initialSpacer:()=>new c,lineMarker:(e,t)=>{let n=e.state.field(r);if(!n)return null;let i=e.state.doc.lineAt(t.from).number,a=Xp(n,i);return new s(a??{line:i,kind:`missing`,data:null})},lineMarkerChange:e=>e.startState.field(r)!==e.state.field(r)}),u=t.ViewPlugin.fromClass(class{line=null;editorView;constructor(e){this.editorView=e,this.editorView.dom.addEventListener(`mousemove`,this.onMove),this.editorView.dom.addEventListener(`mouseleave`,this.onLeave)}destroy(){this.editorView.dom.removeEventListener(`mousemove`,this.onMove),this.editorView.dom.removeEventListener(`mouseleave`,this.onLeave)}update(e){e.startState.field(r)!==e.state.field(r)&&this.line!==null&&(this.line=null,this.editorView.dispatch({effects:i.of(null)}))}onMove=e=>{let t=this.lineAt(e);if(t===this.line)return;if(this.line=t,t===null){this.editorView.dispatch({effects:i.of(null)});return}let n=Xp(this.editorView.state.field(r),t);if(!n){this.editorView.dispatch({effects:i.of(null)});return}let a=this.editorView.state.doc,o=a.line(Math.min(t,a.lines));this.editorView.dispatch({effects:i.of({pos:o.from,above:!0,create:()=>({dom:$p(n)})})})};onLeave=()=>{this.line=null,this.editorView.dispatch({effects:i.of(null)})};lineAt(e){let t=e.target,n=t?.closest?.(`[data-file-blame-line]`);if(n){let e=Number(n.getAttribute(`data-file-blame-line`));return Number.isInteger(e)&&e>0?e:null}if(t?.closest?.(`.cm-blame-gutter`))return null;let r=this.editorView.posAtCoords({x:e.clientX,y:e.clientY});return r==null?null:this.editorView.state.doc.lineAt(r).number}});return{field:r,setBlame:n,base:[r,a,t.showTooltip.from(a),u],gutter:l}}function $p(e){let t=document.createElement(`div`);t.className=`cm-blame-tooltip`,t.setAttribute(`data-file-blame-tooltip`,`1`),t.setAttribute(`data-file-blame-kind`,e.kind),e.data?.commit&&t.setAttribute(`data-file-blame-commit`,e.data.commit);for(let n of Wp(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function em(e,t){let n=(0,u.useRef)(null),r=(0,u.useRef)(void 0);return(0,u.useLayoutEffect)(()=>{let e=r.current;r.current=void 0;let i=n.current;if(!i||!e)return;let a=i.querySelectorAll(t)[e.index];a&&(i.scrollTop+=a.getBoundingClientRect().top-i.getBoundingClientRect().top-e.offset)},[e,t]),{scrollBox:n,capture:()=>{let e=n.current;if(!e)return;let i=e.getBoundingClientRect().top,a;e.querySelectorAll(t).forEach((e,t)=>{let n=e.getBoundingClientRect().top-i;(!a||Math.abs(n)<Math.abs(a.offset))&&(a={index:t,offset:n})}),r.current=a}}}var tm=`super-pi.diff-layout.v1`,nm=`super-pi-diff-layout`;function rm(){try{return localStorage.getItem(tm)===`split`}catch{return!1}}function im(e){let t=t=>{(t.key===tm||t.key===null)&&e()};return window.addEventListener(nm,e),window.addEventListener(`storage`,t),()=>{window.removeEventListener(nm,e),window.removeEventListener(`storage`,t)}}var am;function om(){return am??rm()}function sm(){return[(0,u.useSyncExternalStore)(im,om,()=>!1),e=>{am=e;try{localStorage.setItem(tm,e?`split`:`inline`),am=void 0}catch{}window.dispatchEvent(new Event(nm))}]}var cm=4e3,lm=(0,u.lazy)(()=>Cn(()=>import(`./CodeMirrorEditor-CC6Mf3yd.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([21,1,22]))),um=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},dm=15e3,fm=e=>new um(408,{error:`请求超时:${dm/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function pm(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),dm);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await je(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new um(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?fm(e):t}finally{clearTimeout(r)}}var mm=e=>e instanceof um?e:new um(0,{error:e instanceof Error?e.message:`读取失败`}),hm=e=>encodeURIComponent(e),gm=e=>e?`&cwd=${hm(e)}`:``,_m=(e,t,n)=>`/api/files?workspaceId=${hm(e)}&path=${hm(t)}${gm(n)}`,vm=`//workspace/`,ym=e=>e.startsWith(vm)?e.slice(12):void 0,bm=(e,t,n)=>{let r=ym(t);return`/api/file?workspaceId=${hm(e)}&path=${hm(r??t)}${gm(r?``:n)}`},xm=(e,t,n)=>bm(e,t,n)+`&meta=1`,Sm=(e,t,n)=>`/api/files?workspaceId=${hm(e)}&q=${hm(t)}${gm(n)}`;async function Cm(e,t,n){let r=t.current;if(!r)return t.current=pm(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return pm(e,{cache:`no-store`})}function wm(e){let t=e.trim();if(/^(["']).*\1$/u.test(t)&&(t=t.slice(1,-1)),!/^file:\/\//iu.test(t))return t;try{let e=new URL(t);return e.hostname||e.search||e.hash?t:decodeURIComponent(e.pathname).replace(/^\/(?=[a-z]:[\\/])/iu,``)}catch{return t}}function Tm(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function Em(e){let t=wm(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return Tm(t)}function Dm(e){return wm(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function Om(e,t,n){let r=ym(n.path),i=await pm(`/api/files/open?workspaceId=${hm(e)}${gm(r===void 0?t:``)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:r??n.path})}),{path:a,name:o,text:s,ticket:c,content:l,meta:u}=i,d=Hf(i.targetName??a),f=s===!1&&d===`table`?`download`:d??(s===!1?`download`:void 0);return{path:r===void 0?a:n.path,name:o,content:l??``,etag:u.etag,dirty:!1,view:f,assetTicket:c}}var km=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function Am({workspaceId:e,entryPath:t,name:n,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f,linked:p,presentation:m}){let h=r[t],g=i.has(t);(0,u.useEffect)(()=>{g&&h===void 0&&o(t)},[g,t,h,o]);let _=m.inline(t,`entry`,f),v=m.inline(t,`child`,f+1);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-dir`,"data-file-dir-toggle":t,"aria-expanded":g,tabIndex:-1,draggable:!p,title:c.has(t)?`${t} 里有 agent 改过的文件`:t,onClick:()=>a(t),children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,L.jsx)(ti,{name:g?`down`:`right`})}),(0,L.jsx)(Br,{category:g?`folder-open`:`folder`}),(0,L.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${n} 的文件操作`,children:(0,L.jsx)(ti,{name:`more`})})]}),_,g&&(0,L.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,L.jsx)(`li`,{children:v}),h===void 0?(0,L.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,L.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:Pr(h.error.message),children:Nr(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,L.jsxs)(L.Fragment,{children:[h.truncated&&(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,L.jsx)(Am,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f+1,presentation:m},t.path):(0,L.jsx)(jm,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function jm({entry:e,depth:t,openPaths:n,changedPaths:r,onOpen:i,presentation:a}){let o={"--file-depth":t};if(e.kind===`symlink`&&!e.openLink)return(0,L.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=Hf(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-entry":e.path,"data-linked":e.symlink,"data-file-outside":e.outside?e.path:void 0,"data-file-row-open":s?`1`:`0`,"data-file-row-changed":c?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-open":e.path,"aria-disabled":!u||void 0,title:u?e.path:`${e.name} 可以通过文件操作菜单下载`,tabIndex:-1,"aria-current":d?`true`:void 0,draggable:!e.symlink,onClick:t=>{u&&i(e.openLink&&!e.outside?{...e,openLink:void 0}:e,t.detail>1)},children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(Br,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,L.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,"aria-haspopup":`menu`,tabIndex:-1,"aria-label":`${e.name} 的文件操作`,children:(0,L.jsx)(ti,{name:`more`})})]}),f]})}function Mm({file:e,state:t,message:n,external:r,jumpToLine:i,onChange:a,onSave:o,onReload:s,onOverwrite:c,workspaceId:l,cwd:d=``,navigation:f,embedded:p=!1,onPosition:m,languageOverride:h}){let[g,_]=(0,u.useState)(!0),v=(0,u.useRef)(null),[y,b]=(0,u.useState)({}),[x,S]=(0,u.useState)(null),C=(0,u.useRef)(0),w=!!e.assetTicket,T=!w&&y[e.path]===!0&&!!l,E=l?d?`${l}:${d}`:l:``;(0,u.useEffect)(()=>{let t=++C.current;if(!T||!l){S(null);return}let n=new AbortController,i=jp(E,e.path,e.etag),a=r?void 0:Pp(i);if(a){S({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:E,note:a.supported?null:Rp(a.reason)});return}S({state:`loading`,response:null,path:e.path,workspaceId:E,note:null});let o=ym(e.path);return kp(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===C.current&&(r||Fp(i,n),S({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:E,note:n.supported?null:Rp(n.reason)}))}).catch(n=>{if(t!==C.current||n instanceof Dp)return;let r=zp(n);S({state:r.state,response:null,path:e.path,workspaceId:E,note:r.note})}),()=>{n.abort()}},[T,l,d,E,e.path,e.etag,r]);let D=x&&x.path===e.path&&x.workspaceId===E?x:null,O=T?D?.state??`loading`:`off`,k=O===`ready`&&qp(e.content,D?.response??null,e.dirty||r),A=[];D?.note&&A.push(D.note),O===`ready`&&D?.response?.truncated&&A.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${D.response.totalLines} 行)`}),k&&A.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let j=O===`loading`?`⌛ Blame`:O===`ready`?`✓ Blame`:O===`off`?`Blame`:`! Blame`;(0,u.useEffect)(()=>{i&&_(!1)},[e.path,i]),(0,u.useEffect)(()=>{let e=v.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
|
|
287
|
+
`)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=Up(this.model),e}}class c extends o{eq(){return!0}toDOM(){let e=document.createElement(`span`);return e.className=`cm-blame-marker cm-blame-spacer`,e.textContent=Zp,e}}let l=t.gutter({class:`cm-blame-gutter`,initialSpacer:()=>new c,lineMarker:(e,t)=>{let n=e.state.field(r);if(!n)return null;let i=e.state.doc.lineAt(t.from).number,a=Xp(n,i);return new s(a??{line:i,kind:`missing`,data:null})},lineMarkerChange:e=>e.startState.field(r)!==e.state.field(r)}),u=t.ViewPlugin.fromClass(class{line=null;editorView;constructor(e){this.editorView=e,this.editorView.dom.addEventListener(`mousemove`,this.onMove),this.editorView.dom.addEventListener(`mouseleave`,this.onLeave)}destroy(){this.editorView.dom.removeEventListener(`mousemove`,this.onMove),this.editorView.dom.removeEventListener(`mouseleave`,this.onLeave)}update(e){e.startState.field(r)!==e.state.field(r)&&this.line!==null&&(this.line=null,this.editorView.dispatch({effects:i.of(null)}))}onMove=e=>{let t=this.lineAt(e);if(t===this.line)return;if(this.line=t,t===null){this.editorView.dispatch({effects:i.of(null)});return}let n=Xp(this.editorView.state.field(r),t);if(!n){this.editorView.dispatch({effects:i.of(null)});return}let a=this.editorView.state.doc,o=a.line(Math.min(t,a.lines));this.editorView.dispatch({effects:i.of({pos:o.from,above:!0,create:()=>({dom:$p(n)})})})};onLeave=()=>{this.line=null,this.editorView.dispatch({effects:i.of(null)})};lineAt(e){let t=e.target,n=t?.closest?.(`[data-file-blame-line]`);if(n){let e=Number(n.getAttribute(`data-file-blame-line`));return Number.isInteger(e)&&e>0?e:null}if(t?.closest?.(`.cm-blame-gutter`))return null;let r=this.editorView.posAtCoords({x:e.clientX,y:e.clientY});return r==null?null:this.editorView.state.doc.lineAt(r).number}});return{field:r,setBlame:n,base:[r,a,t.showTooltip.from(a),u],gutter:l}}function $p(e){let t=document.createElement(`div`);t.className=`cm-blame-tooltip`,t.setAttribute(`data-file-blame-tooltip`,`1`),t.setAttribute(`data-file-blame-kind`,e.kind),e.data?.commit&&t.setAttribute(`data-file-blame-commit`,e.data.commit);for(let n of Wp(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function em(e,t){let n=(0,u.useRef)(null),r=(0,u.useRef)(void 0);return(0,u.useLayoutEffect)(()=>{let e=r.current;r.current=void 0;let i=n.current;if(!i||!e)return;let a=i.querySelectorAll(t)[e.index];a&&(i.scrollTop+=a.getBoundingClientRect().top-i.getBoundingClientRect().top-e.offset)},[e,t]),{scrollBox:n,capture:()=>{let e=n.current;if(!e)return;let i=e.getBoundingClientRect().top,a;e.querySelectorAll(t).forEach((e,t)=>{let n=e.getBoundingClientRect().top-i;(!a||Math.abs(n)<Math.abs(a.offset))&&(a={index:t,offset:n})}),r.current=a}}}var tm=`super-pi.diff-layout.v1`,nm=`super-pi-diff-layout`;function rm(){try{return localStorage.getItem(tm)===`split`}catch{return!1}}function im(e){let t=t=>{(t.key===tm||t.key===null)&&e()};return window.addEventListener(nm,e),window.addEventListener(`storage`,t),()=>{window.removeEventListener(nm,e),window.removeEventListener(`storage`,t)}}var am;function om(){return am??rm()}function sm(){return[(0,u.useSyncExternalStore)(im,om,()=>!1),e=>{am=e;try{localStorage.setItem(tm,e?`split`:`inline`),am=void 0}catch{}window.dispatchEvent(new Event(nm))}]}var cm=4e3,lm=(0,u.lazy)(()=>Cn(()=>import(`./CodeMirrorEditor-BItIClMY.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([21,1,22]))),um=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},dm=15e3,fm=e=>new um(408,{error:`请求超时:${dm/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function pm(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),dm);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await je(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new um(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?fm(e):t}finally{clearTimeout(r)}}var mm=e=>e instanceof um?e:new um(0,{error:e instanceof Error?e.message:`读取失败`}),hm=e=>encodeURIComponent(e),gm=e=>e?`&cwd=${hm(e)}`:``,_m=(e,t,n)=>`/api/files?workspaceId=${hm(e)}&path=${hm(t)}${gm(n)}`,vm=`//workspace/`,ym=e=>e.startsWith(vm)?e.slice(12):void 0,bm=(e,t,n)=>{let r=ym(t);return`/api/file?workspaceId=${hm(e)}&path=${hm(r??t)}${gm(r?``:n)}`},xm=(e,t,n)=>bm(e,t,n)+`&meta=1`,Sm=(e,t,n)=>`/api/files?workspaceId=${hm(e)}&q=${hm(t)}${gm(n)}`;async function Cm(e,t,n){let r=t.current;if(!r)return t.current=pm(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return pm(e,{cache:`no-store`})}function wm(e){let t=e.trim();if(/^(["']).*\1$/u.test(t)&&(t=t.slice(1,-1)),!/^file:\/\//iu.test(t))return t;try{let e=new URL(t);return e.hostname||e.search||e.hash?t:decodeURIComponent(e.pathname).replace(/^\/(?=[a-z]:[\\/])/iu,``)}catch{return t}}function Tm(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function Em(e){let t=wm(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return Tm(t)}function Dm(e){return wm(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function Om(e,t,n){let r=ym(n.path),i=await pm(`/api/files/open?workspaceId=${hm(e)}${gm(r===void 0?t:``)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:r??n.path})}),{path:a,name:o,text:s,ticket:c,content:l,meta:u}=i,d=Hf(i.targetName??a),f=s===!1&&d===`table`?`download`:d??(s===!1?`download`:void 0);return{path:r===void 0?a:n.path,name:o,content:l??``,etag:u.etag,dirty:!1,view:f,assetTicket:c}}var km=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function Am({workspaceId:e,entryPath:t,name:n,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f,linked:p,presentation:m}){let h=r[t],g=i.has(t);(0,u.useEffect)(()=>{g&&h===void 0&&o(t)},[g,t,h,o]);let _=m.inline(t,`entry`,f),v=m.inline(t,`child`,f+1);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-dir`,"data-file-dir-toggle":t,"aria-expanded":g,tabIndex:-1,draggable:!p,title:c.has(t)?`${t} 里有 agent 改过的文件`:t,onClick:()=>a(t),children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,L.jsx)(ti,{name:g?`down`:`right`})}),(0,L.jsx)(Br,{category:g?`folder-open`:`folder`}),(0,L.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${n} 的文件操作`,children:(0,L.jsx)(ti,{name:`more`})})]}),_,g&&(0,L.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,L.jsx)(`li`,{children:v}),h===void 0?(0,L.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,L.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:Pr(h.error.message),children:Nr(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,L.jsxs)(L.Fragment,{children:[h.truncated&&(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,L.jsx)(Am,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f+1,presentation:m},t.path):(0,L.jsx)(jm,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function jm({entry:e,depth:t,openPaths:n,changedPaths:r,onOpen:i,presentation:a}){let o={"--file-depth":t};if(e.kind===`symlink`&&!e.openLink)return(0,L.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=Hf(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-entry":e.path,"data-linked":e.symlink,"data-file-outside":e.outside?e.path:void 0,"data-file-row-open":s?`1`:`0`,"data-file-row-changed":c?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-open":e.path,"aria-disabled":!u||void 0,title:u?e.path:`${e.name} 可以通过文件操作菜单下载`,tabIndex:-1,"aria-current":d?`true`:void 0,draggable:!e.symlink,onClick:t=>{u&&i(e.openLink&&!e.outside?{...e,openLink:void 0}:e,t.detail>1)},children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(Br,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,L.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,"aria-haspopup":`menu`,tabIndex:-1,"aria-label":`${e.name} 的文件操作`,children:(0,L.jsx)(ti,{name:`more`})})]}),f]})}function Mm({file:e,state:t,message:n,external:r,jumpToLine:i,onChange:a,onSave:o,onReload:s,onOverwrite:c,workspaceId:l,cwd:d=``,navigation:f,embedded:p=!1,onPosition:m,languageOverride:h}){let[g,_]=(0,u.useState)(!0),v=(0,u.useRef)(null),[y,b]=(0,u.useState)({}),[x,S]=(0,u.useState)(null),C=(0,u.useRef)(0),w=!!e.assetTicket,T=!w&&y[e.path]===!0&&!!l,E=l?d?`${l}:${d}`:l:``;(0,u.useEffect)(()=>{let t=++C.current;if(!T||!l){S(null);return}let n=new AbortController,i=jp(E,e.path,e.etag),a=r?void 0:Pp(i);if(a){S({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:E,note:a.supported?null:Rp(a.reason)});return}S({state:`loading`,response:null,path:e.path,workspaceId:E,note:null});let o=ym(e.path);return kp(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===C.current&&(r||Fp(i,n),S({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:E,note:n.supported?null:Rp(n.reason)}))}).catch(n=>{if(t!==C.current||n instanceof Dp)return;let r=zp(n);S({state:r.state,response:null,path:e.path,workspaceId:E,note:r.note})}),()=>{n.abort()}},[T,l,d,E,e.path,e.etag,r]);let D=x&&x.path===e.path&&x.workspaceId===E?x:null,O=T?D?.state??`loading`:`off`,k=O===`ready`&&qp(e.content,D?.response??null,e.dirty||r),A=[];D?.note&&A.push(D.note),O===`ready`&&D?.response?.truncated&&A.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${D.response.totalLines} 行)`}),k&&A.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let j=O===`loading`?`⌛ Blame`:O===`ready`?`✓ Blame`:O===`off`?`Blame`:`! Blame`;(0,u.useEffect)(()=>{i&&_(!1)},[e.path,i]),(0,u.useEffect)(()=>{let e=v.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
|
|
288
288
|
`).length),n=e.value.split(`
|
|
289
289
|
`),r=n.slice(0,t-1).reduce((e,t)=>e+t.length+1,0),a=n[t-1].length;e.focus(),e.setSelectionRange(r+Math.min(a,(i.column??1)-1),r+a);let o=parseFloat(getComputedStyle(e).lineHeight);e.scrollTop=Math.max(0,(t-1)*o-e.clientHeight/2),e.scrollLeft=0;let s=e.previousElementSibling;s instanceof HTMLElement&&(s.scrollTop=e.scrollTop,s.scrollLeft=0)},[e.path,i,g]);let M=/\.md$/i.test(e.path);return(0,L.jsxs)(`div`,{className:`file-editor`,"data-file-editor":e.path,"data-save-state":t,"data-file-readonly":w?`1`:void 0,children:[(0,L.jsxs)(`div`,{className:`file-editor-head`,children:[f??(!p&&(0,L.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path})),(0,L.jsxs)(`span`,{className:`file-editor-flags`,children:[M&&(0,L.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:()=>_(e=>!e),children:g?`原文`:`预览`}),e.assetTicket&&l&&!p&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{children:`外部文件 · 只读`}),(0,L.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:s,children:`重新读取`}),(0,L.jsx)(`a`,{className:`file-preview-toggle`,href:If(`asset`,l,ym(e.path)===void 0?d:``,e.assetTicket,{download:`1`}),download:e.name,children:`下载`})]}),!w&&(0,L.jsx)(`button`,{type:`button`,className:`file-blame-toggle`,"data-file-blame-toggle":e.path,"data-file-blame-state":O,"aria-pressed":T,"aria-label":T?`关闭 Git Blame`:`显示 Git Blame`,onClick:()=>b(t=>({...t,[e.path]:t[e.path]!==!0})),children:j}),e.dirty&&(0,L.jsx)(`span`,{className:`file-dirty`,"data-file-dirty":`1`,children:`未保存`}),!w&&(0,L.jsxs)(`button`,{type:`button`,className:`file-save`,"data-file-save":e.path,onClick:o,title:`保存文件 (Ctrl+S)`,disabled:t===`saving`,children:[(0,L.jsx)(ti,{name:`save`}),t===`saving`?`保存中…`:`保存`]})]})]}),A.length>0&&(0,L.jsx)(`p`,{className:`file-blame-note`,"data-file-blame-reason":A.map(e=>e.code).join(` `),role:`status`,children:A.map(e=>e.text).join(`;`)}),r&&t!==`conflict`&&(0,L.jsxs)(`div`,{className:`file-conflict`,"data-file-external":e.path,role:`alert`,children:[(0,L.jsx)(`p`,{children:`这个文件在磁盘上已经被改过了,你的修改还没有覆盖它。`}),(0,L.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,L.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,L.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),t===`conflict`&&(0,L.jsxs)(`div`,{className:`file-conflict`,"data-file-conflict":e.path,role:`alert`,children:[(0,L.jsx)(`p`,{children:`保存被拒绝:这个文件在磁盘上已经被改过了,覆盖会丢掉对方的改动。`}),(0,L.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,L.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,L.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),n&&t!==`conflict`&&!r&&(0,L.jsx)(`p`,{className:`file-editor-message file-message-${t}`,"data-file-message":t,role:`status`,children:n}),M&&g?(0,L.jsx)(`div`,{className:`file-markdown-preview`,"data-file-preview":`markdown`,children:(0,L.jsx)(hf,{source:e.content})}):(0,L.jsx)(ep,{fallback:(t,n)=>(0,L.jsxs)(`div`,{className:`file-editor-fallback`,"data-file-editor-fallback":`1`,children:[(0,L.jsxs)(`div`,{className:`file-editor-fallback-bar`,children:[(0,L.jsxs)(`span`,{children:[`⚠️ 高级编辑器加载异常(`,t.message||`未知错误`,`),已自动降级为安全模式`]}),(0,L.jsx)(`button`,{type:`button`,onClick:n,children:`重新加载`})]}),(0,L.jsx)(`textarea`,{className:`file-textarea`,readOnly:w,value:e.content,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),o())}})]}),children:(0,L.jsx)(u.Suspense,{fallback:(0,L.jsx)(`div`,{className:`file-cm-wrap`,"data-file-text":e.path,"data-file-content":e.content,"data-file-selection":`0,0`,"data-file-editor-ready":`0`,children:(0,L.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`})}),children:(0,L.jsx)(lm,{path:e.path,languageOverride:h,value:e.content,onChange:a,jumpToLine:i,onSave:o,readOnly:w,workspaceId:l,onPosition:m,blame:T&&D&&!k?{state:D.state,response:D.response,path:D.path,workspaceId:l??``}:void 0})})})]})}function Nm({line:e}){if(e.kind===`fold`)return(0,L.jsx)(`div`,{className:`file-diff-line file-diff-fold`,"data-diff-kind":`fold`,children:e.text});let t=e.kind===`added`?`+`:e.kind===`removed`?`-`:` `;return(0,L.jsxs)(`div`,{className:`file-diff-line file-diff-${e.kind}`,"data-diff-kind":e.kind,"data-diff-no-newline":e.noNewline?`1`:void 0,children:[(0,L.jsx)(`span`,{className:`file-diff-mark`,"aria-hidden":`true`,children:t}),(0,L.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.oldLine??``}),(0,L.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.newLine??``}),(0,L.jsx)(`span`,{className:`file-diff-text`,children:e.text}),e.noNewline&&(0,L.jsx)(`span`,{className:`file-diff-no-newline`,title:`这个版本的末尾没有换行`,children:`(末尾无换行)`})]})}function Pm(e){let t=[];for(let n=0;n<e.length;){let r=e[n];if(r.kind===`same`||r.kind===`fold`){t.push({before:r,after:r}),n++;continue}let i=[],a=[];for(;n<e.length&&[`removed`,`added`].includes(e[n].kind);){let t=e[n++];(t.kind===`removed`?i:a).push(t)}for(let e=0;e<Math.max(i.length,a.length);e++)t.push({before:i[e],after:a[e]})}return t}function Fm({diff:e,loading:t,error:n,bufferContent:r,mode:i,onMode:a}){let[o,s]=(0,u.useState)(),[c,l]=sm(),d=JSON.stringify([e?.path,i]),f=o===d,{scrollBox:p,capture:m}=em(f,`.file-diff-added, .file-diff-removed`);if(t)return(0,L.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`loading`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-diff-loading":`1`,children:`正在读取差异…`})});if(n)return(0,L.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`error`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-diff-error":`1`,title:Pr(n),children:Nr(n,`这个文件的差异读取失败。`)})});if(!e)return(0,L.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`empty`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-diff-empty":`1`,children:`没有选中的差异。`})});let h=typeof r==`string`,g=i===`buffer`&&h,_=g?e.after:e.before,v=g?r:e.after,y=g?`我未保存的修改`:e.label,b=g?`buffer`:e.baseline,x=h&&e.baseline!==`none`?(0,L.jsxs)(`span`,{className:`file-diff-switch`,"data-file-diff-switch":`1`,children:[(0,L.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${g?``:` file-diff-switch-active`}`,"data-file-diff-base":`server`,"aria-pressed":!g,onClick:()=>a(`server`),children:`agent 的改动`}),(0,L.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${g?` file-diff-switch-active`:``}`,"data-file-diff-base":`buffer`,"aria-pressed":g,onClick:()=>a(`buffer`),children:`我的修改`})]}):null;if(b===`none`)return(0,L.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`none`,"data-file-diff-baseline":b,children:[(0,L.jsxs)(`div`,{className:`file-editor-head`,children:[(0,L.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,L.jsx)(`span`,{className:`file-editor-flags`,children:x})]}),(0,L.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-nobaseline":`1`,children:y})]});let S=hp(_,v),C=gp(S),w=f?S.lines:C.lines,T=c?Pm(w):[];return(0,L.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`ready`,"data-file-diff-baseline":b,"data-file-diff-added":S.added,"data-file-diff-removed":S.removed,"data-file-diff-layout":c?`split`:`inline`,children:[(0,L.jsxs)(`div`,{className:`file-editor-head`,children:[(0,L.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,L.jsxs)(`span`,{className:`file-editor-flags`,children:[x,(0,L.jsx)(`span`,{className:`file-diff-baseline`,"data-file-diff-label":`1`,children:y}),(0,L.jsxs)(`span`,{className:`file-diff-count`,"data-file-diff-count":`1`,children:[`+`,S.added,` / -`,S.removed]}),(0,L.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,"data-file-diff-layout-button":!0,onClick:()=>l(!c),title:c?`切换为全局内联视图`:`切换为全局分栏视图`,children:c?`内联`:`分栏`}),!S.identical&&C.folded>0&&(0,L.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,"data-file-diff-context":!0,"aria-pressed":f,onClick:()=>{m(),s(f?void 0:d)},children:f?`折叠未改动行`:`显示全文`})]})]}),e.beforeUnknown&&!g&&(0,L.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-before-unknown":`1`,role:`status`,children:`读不到改动前的版本(文件太大或无法读取),这里只显示现在的内容。`}),e.before===null&&!e.beforeUnknown&&!g&&(0,L.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-is-new":`1`,role:`status`,children:`这个文件是新建的,下面是它的全部内容。`}),S.identical?(0,L.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-identical":`1`,children:`两个版本没有区别。`}):(0,L.jsx)(`div`,{ref:p,className:`file-diff-body`,"data-file-diff-body":`1`,"data-file-diff-context-mode":f?`full`:`compact`,children:c?(0,L.jsx)(`div`,{className:`file-diff-split-grid`,children:[`before`,`after`].map(e=>(0,L.jsx)(`div`,{"data-diff-side":e,"aria-label":e===`before`?`修改前`:`修改后`,children:T.map((t,n)=>t[e]?(0,L.jsx)(Nm,{line:t[e]},n):(0,L.jsx)(`div`,{className:`file-diff-line`,"aria-hidden":`true`,children:`\xA0`},n))},e))}):w.map((e,t)=>(0,L.jsx)(Nm,{line:e},t))})]})}function Im({error:e}){let t=e.body.code,n=typeof e.body.details?.path==`string`?e.body.details.path:``,r=t===`workspace_missing`?`missing`:t===`timeout`?`timeout`:`failed`;return(0,L.jsxs)(`div`,{className:`rail-empty file-problem`,"data-file-root-error":`1`,"data-file-error-kind":r,role:`alert`,children:[r===`missing`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`工作区路径不存在,无法读取文件。`}),(0,L.jsx)(`p`,{className:`file-problem-hint`,children:`请确认这个路径是写错了,还是目录被移动或删除了:`}),(0,L.jsx)(`code`,{className:`file-problem-path`,"data-file-error-path":`1`,children:n||Nr(e.message,`路径未知`)})]}),r===`timeout`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取超时,服务端没有回应。`}),(0,L.jsxs)(`p`,{className:`file-problem-hint`,children:[`已经等了 `,dm/1e3,` 秒。如果这个工作区在网络盘上,请检查它是否已连接,然后点上面的 ↻ 重试。`]})]}),r===`failed`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取失败。`}),(0,L.jsx)(`p`,{className:`file-problem-hint`,title:Pr(e.message),children:Nr(e.message,`读取失败,请稍后重试。`)})]})]})}function Lm(e,t=``,{navigation:n,showingFile:r=!1,splitFilePath:i}={}){let a=t.trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``),o=e?a?`${e}:${a}`:e:void 0,s=(0,u.useRef)(o);s.current=o;let[c,l]=(0,u.useState)([]),[d,f]=(0,u.useState)(e),p=(0,u.useRef)(c);p.current=c;let[m,h]=(0,u.useState)(),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)({}),[S,C]=(0,u.useState)({}),[w,T]=(0,u.useState)(()=>new Set),[E,D]=(0,u.useState)(),O=(0,u.useRef)(w);O.current=w;let k=(0,u.useRef)(new Map),A=(0,u.useRef)(new Map),[j,M]=(0,u.useState)(0),[N,P]=(0,u.useState)(``),[F,ee]=(0,u.useState)(null),[te,ne]=(0,u.useState)(null),[re,ie]=(0,u.useState)(!1),[ae,oe]=(0,u.useState)({});(0,u.useEffect)(()=>{if(f(e),k.current=new Map,l([]),h(void 0),_(``),y({}),x({}),C({}),T(new Set),D(void 0),ee(null),ne(null),P(``),ie(!1),!e)return;let t=!0;return pm(_m(e,``,a)).then(e=>{t&&C({"":e})}).catch(e=>{t&&C({"":{error:mm(e)}})}),()=>{if(t=!1,o&&s.current!==o){let e=p.current.filter(e=>e.dirty);e.length?A.current.set(o,e):A.current.delete(o),Tp(`super-pi.file-drafts.v1.`+o,e),Vm(o)}}},[e,a,o]);let[se,ce]=(0,u.useState)(),[le,ue]=(0,u.useState)(void 0);(0,u.useEffect)(()=>{if(!e||!o)return;let t=!0;ue(void 0),ce(void 0);let r=zm()[o]??{expanded:[],open:[]},i=e=>({path:e,name:e.split(/[\\/]/).at(-1)||e,text:!0,openLink:r.explicit?.includes(e)?!0:void 0}),a=wp(`super-pi.file-drafts.v1.`+o,[]),c=new Map((A.current.get(o)??a).map(e=>[e.path,e]));r.expanded.length&&T(new Set(r.expanded)),typeof r.listHeight==`number`&&ee(r.listHeight);let u=new Set([...r.open,...c.keys()]);if(!u.size){ce(o);return}let d=r.active??[...c.keys()].at(-1),f=n?.current,p=()=>t&&n?.current===f;return(async()=>{let e,n=r.preview&&!c.has(r.preview)?r.preview:void 0;for(let r of u){if(r===n)continue;let a=c.get(r);a&&l(e=>e.some(e=>e.path===r)?e:[...e,a]);let u=a?.path??await Se(i(r),{activate:!1,isCurrent:()=>t});if(!t||s.current!==o)return;r===d&&(e=u)}if(n&&p()&&(e=await Se(i(n),{activate:!1,isCurrent:p})),e&&s.current===o&&p()){let t=e;r.preview===r.active&&l(e=>e.map(e=>e.path===t&&!e.dirty?{...e,preview:!0}:e)),h(t),ue(t)}})().finally(()=>{t&&s.current===o&&ce(o)}),()=>{t=!1}},[e,a,o,n]),(0,u.useEffect)(()=>{if(!e||!o)return;let t=setTimeout(()=>{let e=zm();e[o]={open:c.map(e=>e.path),explicit:c.filter(e=>e.assetTicket).map(e=>e.path),expanded:[...w],...r&&m?{active:m}:{},...r&&m&&c.some(e=>e.path===m&&e.preview)?{preview:m}:{},...F===null?{}:{listHeight:F}},Bm(e)},400);return()=>{clearTimeout(t)}},[e,o,c,w,m,F,r]),(0,u.useEffect)(()=>{if(!o||se!==o)return;let e=()=>{if(s.current!==o)return;let e=p.current.filter(e=>e.dirty);return Tp(`super-pi.file-drafts.v1.`+o,e)||e.length===0},t=window.setTimeout(()=>{e()===!1&&_(`浏览器无法保存文件草稿,刷新前请先保存修改。`)},250);return window.addEventListener(`pagehide`,e),()=>{window.clearTimeout(t),window.removeEventListener(`pagehide`,e)}},[o,se,c]);let de=(0,u.useCallback)(async(t,n=!1)=>{if(!e)return;let r={},i=k.current;i.set(t,r);let c=()=>s.current===o&&k.current===i&&i.get(t)===r;await pm(_m(e,t,a)+(n?`&revalidate=1`:``)).then(e=>{c()&&C(n=>({...n,[t]:e}))}).catch(e=>{c()&&C(n=>({...n,[t]:{error:mm(e)}}))}).finally(()=>{c()&&i.delete(t)})},[e,a,o]),fe=(0,u.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),pe=(0,u.useCallback)(t=>{if(!e)return;let n=new Set([``,...O.current]),r=t&&new Set(t.map(Uf)),i=e=>!r||r.has(e)||t.some(t=>Wf(e,t));C(e=>Object.fromEntries(Object.entries(e).filter(([e])=>n.has(e)||!i(e))));for(let e of k.current.keys())!n.has(e)&&i(e)&&k.current.delete(e);Promise.all([...n].filter(i).map(e=>de(e,!t&&!e))).then(()=>{s.current===o&&M(e=>e+1)})},[e,o,de]),me=(0,u.useCallback)(()=>pe(),[pe]),I=(0,u.useRef)(void 0),he=(0,u.useRef)(new Set);(0,u.useEffect)(()=>()=>{clearTimeout(I.current),I.current=void 0,he.current=new Set},[o]);let ge=(0,u.useCallback)((t,n)=>{if(t!==e)return;let r=a?`${a}/`:``,i=n?.flatMap(e=>e.startsWith(r)?[e.slice(r.length)]:[]);if(i?.length===0){if(!n?.some(e=>Wf(a,e)))return;he.current=null}else if(!i)he.current=null;else for(let e of i)he.current?.add(e);I.current||=setTimeout(()=>{I.current=void 0;let e=he.current;he.current=new Set,pe(e?[...e]:void 0)},100)},[e,a,pe]),_e=(0,u.useCallback)(e=>{let t=new Set;for(let n=Uf(e);n;n=Uf(n))t.add(n);P(``),T(e=>new Set([...e,...t]))},[]),ve=(0,u.useCallback)((e,t)=>{_e(t&&e?`${e}/`:e),D({path:e,directory:t})},[_e]),ye=(0,u.useCallback)(()=>T(new Set),[]),be=(0,u.useCallback)((e,t,n)=>{let r=n=>Wf(n,e)?t+n.slice(e.length):n,i=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[r(e),t]));l(t=>t.map(t=>{let i=r(t.path);if(i===t.path)return t;let a=Hf(i),o=t.view&&t.view!==`table`&&(!a||a===`table`)||t.path===e&&n===!1&&!a?`download`:a;return{...t,path:i,view:o,name:i.split(`/`).at(-1)??t.name}})),h(e=>e&&r(e)),T(e=>new Set([...e].map(r))),y(i),x(i);for(let t of k.current.keys())Wf(t,e)&&k.current.delete(t);C(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!Wf(t,e)))),_e(t)},[_e]),xe=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{xe.current=void 0},[e,a]),(0,u.useEffect)(()=>{let t=Dm(N);if(!e||!t||Em(N)){xe.current=void 0,ne(null),ie(!1);return}let n=!0,r,i=async()=>{try{let o=await Cm(Sm(e,t,a),xe,()=>n);if(!n||!o)return;ne(o),ie(!1),o.indexed||(r=setTimeout(()=>void i(),400))}catch(e){if(!n)return;ne(null),ie(!1),_(Nr(e,`文件查找没有完成`))}};return ie(!0),r=setTimeout(()=>void i(),80),()=>{n=!1,clearTimeout(r)}},[N,e,a,j]);let Se=(0,u.useCallback)(async(t,{preview:n=!1,activate:r=!0,isCurrent:i,throwOnError:c,requireText:u}={})=>{if(!(!e||i&&!i())){_(``);try{let c=p.current.find(e=>e.path===t.path),d=c??await Om(e,a,t);if(s.current!==o||i&&!i())return;if(u&&d.view&&d.view!==`table`)throw Error(`已找到匹配行,但此文件无法在文本编辑器中定位。可以在搜索结果中查看这一行。`);return c?(r&&h(t.path),t.path):(l(e=>e.some(e=>e.path===d.path)?e:[...e,{...d,...n?{preview:n}:{}}]),r&&h(d.path),x(e=>({...e,[d.path]:!1})),d.path)}catch(e){if(s.current!==o||i&&!i())return;if(c)throw e;_(`打不开「${t.name}」:${e instanceof Error?e.message:`未知错误`}`)}}},[e,a,o]),Ce=(0,u.useCallback)(e=>{o&&p.current.some(t=>t.path===e&&t.preview&&!t.dirty)&&Vm(o,e),l(t=>{let n=t.find(t=>t.path===e);if(n?.dirty&&!window.confirm(`「${n.name}」有未保存的修改,关掉就丢了。仍然关闭?`))return t;let r=t.findIndex(t=>t.path===e),i=t.filter(t=>t.path!==e);return e===m&&h(i.length===0?void 0:i[Math.min(r,i.length-1)]?.path),i})},[m,o]),we=(0,u.useCallback)(e=>{l(t=>t.map(t=>t.path===e&&t.preview?{...t,preview:!1}:t))},[]),Te=(0,u.useCallback)(e=>{l(t=>t.filter(t=>t.path!==e||!t.preview||t.dirty)),h(t=>t===e?void 0:t),o&&Vm(o,e)},[o]),Ee=(0,u.useCallback)((e,t)=>{l(n=>n.map(n=>n.path===e&&!n.assetTicket&&n.content!==t?{...n,content:t,dirty:!0,preview:!1}:n))},[]);(0,u.useEffect)(()=>{if(!e||c.length===0)return;let t=!0,n=setInterval(()=>{for(let{path:n,assetTicket:r}of p.current)r||pm(xm(e,n,a)).then(e=>{if(!t)return;let r=p.current.find(e=>e.path===n);r?.view&&r.view!==`table`&&e.etag!==r.etag?l(t=>t.map(t=>t.path===n&&t.etag===r.etag?{...t,etag:e.etag}:t)):r&&e.etag!==r.etag&&x(e=>({...e,[n]:!0}))}).catch(e=>{t&&mm(e).status===404&&x(e=>({...e,[n]:!0}))})},cm);return()=>{t=!1,clearInterval(n)}},[e,a,c.length]);let De=(0,u.useCallback)(async(t,n)=>{if(!e)return;let r=c.find(e=>e.path===t);if(!r||r.assetTicket)return;y(e=>({...e,[t]:{state:`saving`,message:``}}));let i=r.etag;if(n)try{i=(await pm(xm(e,t,a))).etag}catch(e){s.current===o&&y(n=>({...n,[t]:{state:`error`,message:`无法读取磁盘上的最新版本:${e instanceof Error?e.message:`未知错误`}`}}));return}let u=r.content;try{let n=await pm(bm(e,t,a),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:ym(t)??t,content:u,baseEtag:i})});if(s.current!==o)return;let r=p.current.find(e=>e.path===t),c=r!==void 0&&r.content!==u;l(e=>e.map(e=>e.path===t?{...e,etag:n.meta.etag,dirty:e.content!==u}:e)),x(e=>({...e,[t]:!1})),y(e=>({...e,[t]:{state:`saved`,message:c?`已保存,但你又改了;最新修改仍未保存`:`已保存 ${km(n.meta.modifiedAt)}`}}))}catch(e){if(s.current!==o)return;let n=e instanceof um&&e.body.code===`stale`;y(r=>({...r,[t]:{state:n?`conflict`:`error`,message:e instanceof Error?e.message:`保存失败`}})),n&&x(e=>({...e,[t]:!0}))}},[e,a,o,c]),Oe=(0,u.useCallback)(async t=>{if(!e)return;let n=p.current.find(e=>e.path===t),r=n?.content;try{if(n?.assetTicket){let r=await Om(e,a,{path:t,name:n.name,text:null,openLink:!0});if(!r.assetTicket||r.path!==t)throw Error(`链接目标已变化,请关闭后重新打开。`);s.current===o&&(l(e=>e.map(e=>e.path===t?{...r,preview:e.preview}:e)),y(e=>({...e,[t]:{state:`idle`,message:``}})));return}let i=await pm(bm(e,t,a));if(s.current!==o)return;let c=p.current.find(e=>e.path===t),u=c!==void 0&&c.content!==r;l(e=>e.map(e=>e.path===t?{...e,content:u?e.content:i.content,etag:i.meta.etag,dirty:u}:e)),x(e=>({...e,[t]:!1})),y(e=>({...e,[t]:{state:`saved`,message:u?`已读取磁盘版本;你后来输入的修改仍未保存`:`已重新载入磁盘版本`}}))}catch(e){s.current===o&&y(n=>({...n,[t]:{state:`error`,message:e instanceof Error?e.message:`重新载入失败`}}))}},[e,a,o]),ke=c.find(e=>e.path===m),Ae=(0,u.useMemo)(()=>c.map(e=>({id:e.path,label:e.name,title:ym(e.path)??e.path,closable:!0,badge:e.dirty?(0,L.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[c]),je=(0,u.useMemo)(()=>new Set(c.map(e=>e.path)),[c]),Me=(0,u.useCallback)((e,t,n)=>{oe(r=>({...r,[e]:{changes:t,dropped:n}}))},[]),Ne=e?ae[e]:void 0,Pe=(0,u.useMemo)(()=>{let e=Ne?.changes??[];if(!a)return e;let t=`${a}/`;return e.flatMap(e=>e.path.startsWith(t)?[{...e,path:e.path.slice(t.length)}]:[])},[Ne,a]),Fe=Ne?.dropped??0,Ie=(0,u.useMemo)(()=>new Set(Pe.map(e=>e.path)),[Pe]),Le=(0,u.useMemo)(()=>{let e=new Set;for(let t of Pe){let n=t.path.split(`/`);for(let t=1;t<n.length;t++)e.add(n.slice(0,t).join(`/`))}return e},[Pe]);return{ownerWorkspaceId:d,open:c,activePath:m,visiblePath:r?m:i,location:E,active:ke,tabItems:Ae,openPaths:je,notice:g,setNotice:_,saves:v,external:b,restoringWorkbench:!!(o&&se!==o),openFile:Se,setActivePath:h,closeFile:Ce,pinFile:we,discardPreview:Te,updateBuffer:Ee,save:De,reload:Oe,listings:S,expanded:w,toggleDirectory:fe,loadDirectory:de,refreshTree:me,invalidateTree:ge,revealPath:_e,locatePath:ve,collapseDirectories:ye,movePath:be,listHeight:F,setListHeight:ee,query:N,setQuery:P,hits:te,searching:re,changed:Pe,changedPaths:Ie,changedDirs:Le,changedDropped:Fe,setChangedFor:Me,restoredActive:le}}var Rm=`super-pi.file-workbench.v1`;function zm(){try{if(typeof window>`u`)return{};let e=JSON.parse(window.localStorage.getItem(`super-pi.file-workbench.v1`)??`null`);if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){if(!r||typeof r!=`object`)continue;let e=r,i=Array.isArray(e.open)?e.open.filter(e=>typeof e==`string`):[],a=typeof e.preview==`string`?e.preview:void 0;a&&a!==e.active&&(i=i.filter(e=>e!==a));let o=Array.isArray(e.expanded)?e.expanded.filter(e=>typeof e==`string`):[],s=typeof e.listHeight==`number`&&Number.isFinite(e.listHeight)&&e.listHeight>0?Math.round(e.listHeight):void 0,c=Array.isArray(e.explicit)?e.explicit.filter(e=>typeof e==`string`):[];t[n]={open:i,expanded:o,explicit:c,...typeof e.active==`string`?{active:e.active}:{},...a&&a===e.active?{preview:a}:{},...s?{listHeight:s}:{}}}return t}catch{return{}}}function Bm(e){try{typeof window<`u`&&window.localStorage.setItem(Rm,JSON.stringify(e))}catch{}}function Vm(e,t){let n=zm(),r=n[e];!r?.preview||t&&r.preview!==t||(n[e]={...r,open:r.open.filter(e=>e!==r.preview),active:void 0,preview:void 0},Bm(n))}function Hm({height:e,onHeight:t,panelRef:n,min:r=120}){let[i,a]=(0,u.useState)(!1),o=()=>{let e=n.current?.querySelector(`.files-tree`)??null;return{list:e,height:e?.getBoundingClientRect().height??0}},s=e=>{e.preventDefault(),e.currentTarget.focus();let n=e.clientY,{height:i}=o();a(!0);let s=document.body,c=s.style.cursor,l=s.style.userSelect;s.style.cursor=`row-resize`,s.style.userSelect=`none`;let u=e=>{let a=Math.round(i+(e.clientY-n));t(Math.max(r,a))},d=()=>{s.style.cursor=c,s.style.userSelect=l,a(!1),window.removeEventListener(`mousemove`,u),window.removeEventListener(`mouseup`,d)};window.addEventListener(`mousemove`,u),window.addEventListener(`mouseup`,d)},c=e=>e.shiftKey?96:24;return(0,L.jsx)(`div`,{className:`files-splitter${i?` files-splitter-dragging`:``}`,"data-file-splitter":`1`,"data-file-splitter-dragging":i?`true`:`false`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整文件列表高度`,"aria-valuenow":e??void 0,"aria-valuemin":r,tabIndex:0,onMouseDown:s,onKeyDown:e=>{let i=c(e);if(e.key===`ArrowDown`){e.preventDefault();let{height:n}=o();t(Math.max(r,Math.round(n)+i))}else if(e.key===`ArrowUp`){e.preventDefault();let{height:n}=o(),a=Math.round(n)-i;t(a<=r?null:a)}else if(e.key===`Home`)e.preventDefault(),t(null);else if(e.key===`End`){e.preventDefault();let i=n.current?.querySelector(`.files-tree`)?.parentElement?.clientHeight??0;t(Math.max(r,i))}}})}var Um=()=>null,Wm=`application/x-super-pi-workspace-file`;function Gm({workspaceId:e,workspaceName:t,cwd:n=``,files:r,onOpenFile:i,onOpenChanged:a,onReference:o,onMoved:s,onSearchFolder:c}){let{open:l,openPaths:d,notice:f,setNotice:p,openFile:m,listings:h,expanded:g,toggleDirectory:_,loadDirectory:v,refreshTree:y,listHeight:b,setListHeight:x,query:S,setQuery:C,hits:w,searching:T,changed:E,changedPaths:D,changedDirs:O,changedDropped:k}=r,A=(0,u.useCallback)((e,t)=>{i?i(e,t):m(e)},[i,m]),j=n.split(`/`).at(-1)||t||`工作目录`,M=Xf({workspaceId:e,cwd:n,scopeName:j,files:r,onOpen:A,onReference:o,onMoved:s,onSearchFolder:c}),[N,P]=(0,u.useState)(),F=(0,u.useRef)(void 0),[ee,te]=(0,u.useState)(!1),ne=M.editing?M.inline:Um,re=(0,u.useMemo)(()=>({currentPath:r.visiblePath,dropPath:N,inline:ne}),[r.visiblePath,N,ne]);(0,u.useEffect)(()=>{y();function e(){y()}return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[y]),(0,u.useEffect)(()=>{P(void 0),F.current=void 0,te(!1)},[e,n]);let ie=h[``],ae=S.trim(),oe=e?Em(S):void 0,se=(0,u.useRef)(null),ce=(0,u.useRef)(null),le=(0,u.useRef)(void 0);function ue(e){let t=ce.current;t&&(le.current&&le.current!==e&&(le.current.tabIndex=-1),le.current=e,t.tabIndex=e?-1:0,e&&(e.tabIndex=0))}let de=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{let{location:e}=r;if(!e||de.current===e)return;let t=se.current?.querySelector(e.path?`[${e.directory?`data-file-dir-toggle`:`data-file-open`}="${CSS.escape(e.path)}"]`:`[data-explorer-root]`);t&&(de.current=e,t.focus({preventScroll:!0}),t.scrollIntoView({block:`nearest`}))},[r.location,h,g,S]),(0,u.useEffect)(()=>{if(!N||g.has(N))return;let e=window.setTimeout(()=>_(N),650);return()=>window.clearTimeout(e)},[N,g,_]);let fe=(0,u.useCallback)(e=>{let t=se.current;if(!t)return;let n=e.target?.closest(`.file-row`);if(!n)return;let r=Kf(n);if(r&&!M.busy){if(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`){e.preventDefault(),M.openMenu(r,ni(n));return}if(!r.linked&&e.key===`F2`){e.preventDefault(),M.showAction(`move`,r,!1,n);return}if(!r.linked&&e.key===`Delete`){e.preventDefault(),M.showAction(`trash`,r,!1,n);return}}let i=[...(n.closest(`.files-tree, .files-changed`)??t).querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),a=i.indexOf(n);if(a<0)return;let o=e=>{let t=Math.max(0,Math.min(i.length-1,e));i[t]?.focus()};if(e.key===`ArrowDown`)e.preventDefault(),o(a+1);else if(e.key===`ArrowUp`)e.preventDefault(),o(a-1);else if(e.key===`Home`)e.preventDefault(),o(0);else if(e.key===`End`)e.preventDefault(),o(i.length-1);else if(e.key===`ArrowRight`){let t=n.getAttribute(`data-file-dir-toggle`);if(t&&n.getAttribute(`aria-expanded`)===`false`)e.preventDefault(),_(t);else if(t){let t=n.closest(`.file-node`)?.querySelector(`.file-children .file-row:not(:disabled)`);t&&(e.preventDefault(),t.focus())}}else if(e.key===`ArrowLeft`){let r=n.getAttribute(`data-file-dir-toggle`);if(r&&n.getAttribute(`aria-expanded`)===`true`){e.preventDefault(),_(r);return}let i=n.getAttribute(`data-file-open`)??n.getAttribute(`data-file-hit`)??r;if(i){e.preventDefault();let n=i.lastIndexOf(`/`),r=n<0?``:i.slice(0,n);(r?t.querySelector(`[data-file-dir-toggle="${CSS.escape(r)}"]`):null)?.focus()}}},[_,M]),[pe,me]=(0,u.useState)(200);(0,u.useEffect)(()=>{me(200)},[ae,e]);let I=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(ae===``)return;let e=I.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&me(e=>e>=(w?.hits.length??0)?e:e+200)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[ae,w]);let he=(0,u.useMemo)(()=>{if(oe)return(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-exact-path":oe.path,title:oe.path,onClick:()=>A(oe),children:[(0,L.jsx)(Br,{path:oe.path}),(0,L.jsxs)(`span`,{className:`file-name`,children:[`打开 `,oe.name]})]});if(ae){if(T)return(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-searching":`1`,children:`搜索中…`});if(!w)return null;if(w.hits.length===0)return(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-search-empty":`1`,children:w.indexed?`没有匹配「${ae}」的文件。`:`正在建立索引…`});let e=w.hits.slice(0,pe),t=[],n=new Map;for(let r of e){let e=n.get(r.directory);if(e)e.push(r);else{let e=[r];n.set(r.directory,e),t.push({directory:r.directory,hits:e})}}return(0,L.jsxs)(L.Fragment,{children:[t.map(e=>(0,L.jsxs)(`section`,{className:`file-group`,"data-file-search-group":e.directory,children:[(0,L.jsxs)(`h3`,{className:`file-group-head`,"data-file-search-group-head":e.directory,children:[(0,L.jsx)(`span`,{className:`file-group-name`,children:e.directory||`/`}),(0,L.jsx)(`span`,{className:`file-group-count`,children:e.hits.length})]}),(0,L.jsx)(`ul`,{className:`file-list`,children:e.hits.map(e=>(0,L.jsxs)(`li`,{className:`file-explorer-row`,"data-file-entry":e.path,"data-linked":e.openLink,"data-file-current":r.visiblePath===e.path?`1`:void 0,children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-hit":e.path,tabIndex:-1,"aria-current":r.visiblePath===e.path?`true`:void 0,"data-file-hit-open":d.has(e.path)?`1`:`0`,onClick:()=>A({...e,text:!0}),children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(Br,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),d.has(e.path)&&(0,L.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`})]}),!e.openLink&&(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${e.name} 的文件操作`,children:(0,L.jsx)(ti,{name:`more`})})]},e.path))})]},e.directory||`/`)),e.length<w.hits.length&&(0,L.jsx)(`div`,{ref:I,className:`file-sentinel`,"data-file-search-more":`1`,children:`正在载入更多…`})]})}return e?ie===void 0?(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-root-loading":`1`,children:`读取工作区…`}):`error`in ie?(0,L.jsx)(Im,{error:ie.error}):(0,L.jsxs)(L.Fragment,{children:[ie.truncated&&(0,L.jsx)(`p`,{className:`file-search-note`,"data-file-truncated-root":`1`,children:`条目过多,只显示前一部分。`}),ie.entries.length===0?(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-root-empty":`1`,children:`这个工作区是空的,没有文件也没有子目录。`}):(0,L.jsx)(`ul`,{className:`file-list`,children:ie.entries.map(t=>t.kind===`directory`?(0,L.jsx)(Am,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:h,expanded:g,toggle:_,loadDirectory:v,openPaths:d,changedDirs:O,changedPaths:D,onOpen:A,depth:0,presentation:re},t.path):(0,L.jsx)(jm,{entry:t,depth:0,openPaths:d,changedPaths:D,onOpen:A,presentation:re},t.path))})]}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-no-workspace":`1`,children:`先在左侧选一个工作区,这里会显示它的文件。`})},[oe,ae,T,w,pe,e,ie,h,g,_,v,A,d,O,D,re,r.visiblePath]),ge=e=>{let t=Kf(e);if(!t?.linked)return t?t.directory?t.path:Uf(t.path):``},_e=(e,t)=>e!==Uf(t.path)&&!(t.directory&&Wf(e,t.path));return(0,u.useLayoutEffect)(()=>{let e=ce.current;if(!e)return;let t=[...e.querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),n=le.current;ue(n&&t.includes(n)?n:t.find(e=>e.hasAttribute(`aria-current`))??t[0])},[he,M.editing]),(0,L.jsxs)(`div`,{className:`files-panel`,"data-files-panel":`1`,"data-files-open-count":l.length,"data-files-changed-count":E.length,ref:se,onKeyDown:fe,onClick:e=>{let t=e.target instanceof Element?e.target.closest(`[data-explorer-action]`):void 0,n=Kf(t??null);t&&n&&!M.busy&&M.openMenu(n,ni(t))},onContextMenu:e=>{let t=Kf(e.target),n=e.target instanceof Element?e.target.closest(`.file-row, [data-explorer-action]`):void 0;t&&n&&!M.busy&&(e.preventDefault(),M.openMenu(t,{x:e.clientX,y:e.clientY,origin:n}))},onDragStart:e=>{let t=Kf(e.target instanceof Element?e.target.closest(`.file-row[draggable=true]`):null);!t||t.linked||M.busy||ae||(F.current=t,e.dataTransfer.setData(Wm,t.path),e.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{F.current=void 0,P(void 0)},onDragLeave:e=>{(!(e.relatedTarget instanceof Node)||!e.currentTarget.contains(e.relatedTarget))&&P(void 0)},onDragOver:t=>{let n=t.dataTransfer.types.includes(`Files`),r=F.current&&t.dataTransfer.types.includes(Wm)?F.current:void 0;if(!e||M.busy||!n&&!r)return;t.preventDefault();let i=ge(t.target),a=i!==void 0&&(!r||_e(i,r));t.dataTransfer.dropEffect=a?r?`move`:`copy`:`none`,P(a?i:void 0)},onDrop:t=>{P(void 0);let n=t.dataTransfer.types.includes(Wm)?F.current:void 0;if(F.current=void 0,!e||M.busy||!n&&!t.dataTransfer.types.includes(`Files`))return;t.preventDefault();let r=ge(t.target);if(r===void 0){p(`请选择工作区里的普通文件夹。`);return}if(n){_e(r,n)&&M.moveTo(n,r);return}let i=Array.from(t.dataTransfer.items).filter(e=>!e.webkitGetAsEntry?.()?.isDirectory).map(e=>e.getAsFile()).filter(e=>e!==null);i.length?M.upload(r,i):t.dataTransfer.files.length&&!t.dataTransfer.items.length?M.upload(r,Array.from(t.dataTransfer.files)):p(`请选择要上传的文件。`)},children:[(0,L.jsxs)(`header`,{className:`file-explorer-header`,"data-file-drop-target":N===``?`1`:void 0,children:[(0,L.jsxs)(`div`,{className:`file-explorer-scope`,"data-explorer-root":`1`,tabIndex:-1,title:n?`${t??`工作区`}/${n}`:j,children:[(0,L.jsx)(Br,{category:`folder-open`}),(0,L.jsx)(`span`,{children:j})]}),M.toolbar]}),(0,L.jsxs)(`div`,{className:`files-search`,children:[(0,L.jsx)(`span`,{className:`files-search-icon`,"aria-hidden":`true`,children:(0,L.jsx)(ti,{name:`search`})}),(0,L.jsx)(`input`,{type:`search`,className:`files-search-input`,"data-file-search-input":`1`,value:S,placeholder:`筛选文件或输入绝对路径`,"aria-label":`按文件名搜索`,onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),C(``)):e.key===`Enter`&&oe&&(e.preventDefault(),A(oe))},onChange:e=>C(e.target.value)}),(0,L.jsx)(`button`,{type:`button`,className:`explorer-icon-button`,disabled:!r.activePath||!!ym(r.activePath)||!!(r.active?.assetTicket&&Em(r.activePath)),onClick:()=>{r.activePath&&r.locatePath(r.activePath,!1)},title:`定位打开的文件`,"aria-label":`在文件树中定位当前文件`,children:(0,L.jsx)(ti,{name:`locate`})})]}),M.controls,!oe&&ae&&w&&!T&&(0,L.jsxs)(`p`,{className:`files-count`,"data-file-search-count":`1`,role:`status`,children:[(0,L.jsx)(`b`,{children:w.total.toLocaleString(`zh-CN`)}),` 个结果`,w.indexed===!1&&(0,L.jsx)(`span`,{className:`files-count-note`,"data-file-search-indexing":`1`,children:`正在建立索引…`}),w.indexed&&w.incomplete&&(0,L.jsx)(`span`,{className:`files-count-note`,children:`索引不完整`})]}),f&&(0,L.jsx)(`p`,{className:`rail-empty file-explorer-notice`,"data-file-notice":`1`,role:`status`,children:f}),M.busy&&(0,L.jsx)(`p`,{className:`file-explorer-notice`,role:`status`,children:`正在处理文件…`}),(0,L.jsx)(`div`,{className:`files-tree`,ref:ce,"data-file-tree":ae?`search`:`browse`,tabIndex:0,"aria-label":`文件树`,onFocus:e=>{e.target instanceof HTMLElement&&e.target.matches(`.file-row:not(:disabled)`)&&ue(e.target)},style:b===null?void 0:{height:`${b}px`,flex:`0 0 auto`},children:(0,L.jsxs)(`div`,{className:`files-tree-body`,children:[M.inline(``,`child`,0),he]})}),(0,L.jsx)(Hm,{height:b,onHeight:x,panelRef:se}),(0,L.jsxs)(`div`,{className:`files-changed`,"data-file-changed-list":`1`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`files-changed-head`,"data-file-changed-head":`1`,"aria-expanded":ee,onClick:()=>te(e=>!e),children:[(0,L.jsx)(ti,{name:ee?`down`:`right`}),(0,L.jsx)(ti,{name:`changes`}),(0,L.jsx)(`span`,{children:`改动`}),(0,L.jsx)(`span`,{className:`files-change-count`,children:E.length})]}),ee&&(0,L.jsxs)(`div`,{className:`files-change-list`,children:[k>0&&(0,L.jsxs)(`p`,{className:`file-search-note`,"data-file-changed-dropped":`1`,children:[`还有 `,k,` 个改动没有记录(超过保留上限)。`]}),!E.length&&(0,L.jsx)(`p`,{className:`file-row-empty`,children:`没有 agent 改动。`}),(0,L.jsx)(`ul`,{className:`file-list`,children:E.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-changed-open":e.path,title:`${e.path}(点击查看改动)`,onClick:()=>a?.(e.path),children:[(0,L.jsx)(Br,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.path.split(`/`).pop()}),(0,L.jsx)(`span`,{className:`file-badge-path`,children:e.path.split(`/`).slice(0,-1).join(`/`)||`/`}),(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed-kind":e.path,children:e.baseline===null&&!e.baselineUnknown?`新建`:`已改`})]})},e.path))})]})]})]})}function Km(e,t){let[n,r]=(0,u.useState)(!1),[i,a]=(0,u.useState)(``);return{choose:async(i,o,s)=>{if(i&&!n){r(!0),a(``);try{await e(i,o,s)&&t()}catch(e){a(Nr(e,`文件无法打开`))}finally{r(!1)}}},openError:i,opening:n,setOpenError:a}}var qm=200;async function Jm(e,t,n){let r=await je(e,{signal:t,cache:`no-store`});if(!r.ok)throw new um(r.status,await r.json());if(!r.body)throw Error(`服务端没有返回搜索结果。`);let i=r.body.pipeThrough(new TextDecoderStream).getReader(),a=``,o=!1;try{for(;;){let e=await i.read();if(e.done)break;let t=(a+e.value).split(`
|
|
290
290
|
`);a=t.pop();for(let e of t){if(!e)continue;let t=JSON.parse(e);if(t.type===`error`)throw Error(t.error);n(t),t.type===`done`&&(o=!0)}}if(!o)throw Error(`搜索连接提前断开,结果可能不完整。`)}finally{await i.cancel().catch(()=>void 0),i.releaseLock()}}function Ym(e,t){return{path:t?e.startsWith(t+`/`)?e.slice(t.length+1):vm+e:e,name:e.split(`/`).at(-1)??e,text:!0}}function Xm(e,t,n){return{...Ym(t?t+`/`+e.path:e.path,n),name:e.name}}function Zm({workspaceId:e,cwd:t=``,directory:n,initialQuery:r=``,onOpen:i,onClose:a,onMode:o,presentation:s}){let[c,l]=(0,u.useState)(r),[d,f]=(0,u.useState)(n??``),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(!0),[y,b]=(0,u.useState)([]),[x,S]=(0,u.useState)(),[C,w]=(0,u.useState)(qm),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(!1),[k,A]=(0,u.useState)(!1),[j,M]=(0,u.useState)(0),{choose:N,openError:P,opening:F,setOpenError:ee}=Km(i,a),te=!!Em(c),ne=(0,u.useRef)(null),re=(0,u.useRef)(null),ie=(0,u.useRef)(void 0),ae=(0,u.useId)();(0,u.useEffect)(()=>{ne.current?.focus()},[]),(0,u.useEffect)(()=>{re.current?.scrollIntoView({block:`nearest`})},[j]),(0,u.useEffect)(()=>{let t=c.trim(),n=new AbortController;if(ie.current=n,b([]),S(void 0),E(``),A(!1),w(qm),M(0),!e||!t){O(!1);return}if(t.length>256){E(`搜索词不能超过 256 个字符。`),O(!1);return}let r=new URLSearchParams({workspaceId:e,q:t,stream:`1`,ignore:_?`1`:`0`});d&&r.set(`cwd`,d),p.trim()&&r.set(`include`,p.trim()),h.trim()&&r.set(`exclude`,h.trim()),O(!0);let i=setTimeout(()=>{n.signal.aborted||Jm(`/api/files/search?`+r,n.signal,e=>{n.signal.aborted||(e.type===`matches`?b(t=>[...t,...e.hits]):e.type===`done`&&S(e.summary))}).catch(e=>{n.signal.aborted||E(Nr(e,`搜索没有完成`))}).finally(()=>{n.signal.aborted||O(!1)})},220);return()=>{n.abort(),clearTimeout(i)}},[c,e,d,p,h,_]);let oe=(0,u.useMemo)(()=>{let e=new Map;return y.slice(0,C).forEach((t,n)=>{let r=e.get(t.path);r?r.push({hit:t,row:n}):e.set(t.path,[{hit:t,row:n}])}),[...e]},[y,C]),se=e=>{e&&N(Xm(e,d,t),e.line,e.column)},ce=x?.complete===!1,le={time:`搜索超时`,results:`达到全局结果上限`,line:`部分行太长`,encoding:`部分文件的编码无法读取`,unreadable:`部分文件无法读取`};return(0,L.jsxs)(Qf,{mode:`content`,query:c,onMode:o,onClose:a,presentation:s,children:[(0,L.jsx)(`input`,{ref:ne,className:`quick-open-input`,"data-content-search-input":`1`,value:c,readOnly:F,placeholder:`内容搜索(区分大小写,按字面匹配)`,role:`combobox`,"aria-label":`内容搜索`,"aria-autocomplete":`list`,"aria-controls":ae,"aria-expanded":y.length>0,"aria-activedescendant":y[j]?`${ae}-${j}`:void 0,onChange:e=>{l(e.target.value),ee(``)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),M(e=>Math.min(e+1,Math.max(0,Math.min(C,y.length)-1)))):e.key===`ArrowUp`?(e.preventDefault(),M(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),se(y[j])))}}),(0,L.jsxs)(`div`,{className:`content-search-controls`,children:[(0,L.jsxs)(`label`,{children:[`范围 `,(0,L.jsxs)(`select`,{value:d,"aria-label":`搜索范围`,onChange:e=>f(e.target.value),children:[(0,L.jsx)(`option`,{value:``,children:`整个工作区`}),t&&(0,L.jsxs)(`option`,{value:t,children:[`当前目录 · `,t]}),n&&n!==t&&(0,L.jsxs)(`option`,{value:n,children:[`文件夹 · `,n]})]})]}),D&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ie.current?.abort(),ne.current?.focus(),O(!1),A(!0)},children:`取消搜索`})]}),(0,L.jsxs)(`details`,{className:`content-search-filters`,children:[(0,L.jsx)(`summary`,{children:`文件筛选`}),(0,L.jsxs)(`label`,{children:[`包含 `,(0,L.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`例如 **/*.cpp`})]}),(0,L.jsxs)(`label`,{children:[`排除 `,(0,L.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`例如 **/generated/**`})]}),(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),` 遵循忽略文件和默认排除`]})]}),(0,L.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"data-content-search-status":T?`error`:D?`searching`:k?`cancelled`:ce?`partial`:`complete`,children:[T?`搜索失败:`+T:D?`搜索中…`:k?`已取消`:e?ce?`结果不完整`:x?`搜索完成`:`输入要搜索的内容`:`请先选择工作区`,(y.length>0||x)&&` · ${y.length} 条命中`]}),te&&(0,L.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>o(`path`,c),children:`按文件路径打开`}),ce&&(0,L.jsx)(`p`,{className:`quick-open-status`,"data-content-search-partial":`1`,children:x.reasons.map(e=>le[e]??e).join(`;`)}),x?.complete&&!y.length&&(0,L.jsx)(`p`,{className:`quick-open-status`,"data-content-search-empty":`1`,children:`没有匹配的行`}),P&&(0,L.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:P}),(0,L.jsx)(`ul`,{id:ae,className:`quick-open-results content-search-results`,role:`listbox`,"aria-label":`正文搜索结果`,children:oe.map(([e,t])=>(0,L.jsxs)(`li`,{className:`content-search-group`,role:`presentation`,children:[(0,L.jsx)(`div`,{className:`content-search-file`,title:e,children:e}),t.map(({hit:e,row:t})=>(0,L.jsxs)(`button`,{id:`${ae}-${t}`,ref:t===j?re:void 0,type:`button`,role:`option`,tabIndex:-1,"data-content-search-result":`${e.path}:${e.line}`,className:`quick-open-result content-search-result${j===t?` quick-open-result-active`:``}`,"aria-selected":j===t,"aria-label":`${e.path}:${e.line}:${e.column} ${e.text}`,onMouseEnter:()=>M(t),onClick:()=>se(e),children:[(0,L.jsxs)(`span`,{title:`${e.path}:${e.line}:${e.column}`,className:`content-search-result-position`,children:[e.line,`:`,e.column]}),(0,L.jsx)(`small`,{title:e.text,children:e.text})]},e.line))]},e))}),y.length>C&&(0,L.jsxs)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-content-search-more":`1`,onClick:()=>{C+qm>=y.length&&ne.current?.focus(),w(e=>e+qm)},children:[`显示更多结果(已显示 `,C,` / `,y.length,`)`]})]})}function Qm({workspaceId:e,cwd:t=``,connected:n,initialQuery:r=``,onOpen:i,onClose:a,onMode:o,presentation:s}){let[c,l]=(0,u.useState)(r),[d,f]=(0,u.useState)(0),[p,m]=(0,u.useState)(0),[h,g]=(0,u.useState)(),_=(0,u.useRef)(void 0),v=(0,u.useRef)(void 0),{choose:y,openError:b,opening:x,setOpenError:S}=Km(i,a),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=Dm(c),E=e?Em(c):void 0,D=!!E;(0,u.useEffect)(()=>{if(!n||!e)return;let r=new AbortController,i=Sm(e,``,t)+`&quick=1&refresh=1`;return _.current=pm(i,{cache:`no-store`,signal:r.signal}).catch(()=>void 0),()=>{r.abort(),_.current=void 0}},[n,e,t]),(0,u.useEffect)(()=>{if(!n||!e||D)return;let r=new AbortController,i=r.signal,a=Sm(e,T,t)+`&quick=1&page=${p}`,o,s=async e=>{try{let t=e?await _.current:void 0;if(i.aborted)return;let n=e&&!T&&t?t:await pm(a,{cache:`no-store`,signal:i});if(i.aborted)return;g({query:T,page:p,response:n}),n.indexed||(o=setTimeout(()=>void s(!1),350))}catch(e){i.aborted||g({query:T,page:p,error:Nr(e,`文件查找没有完成`)})}};return o=setTimeout(()=>void s(!0),T?120:0),()=>{r.abort(),clearTimeout(o)}},[n,e,t,T,D,p]);let O=h?.query===T&&h.page===p?h:void 0,k=O?.response,A=(0,u.useMemo)(()=>{if(E)return[E];let t=k?.hits.map(e=>({...e,text:null}))??[];return p>0||e&&T.includes(`/`)&&!T.endsWith(`/`)&&!T.split(`/`).includes(`..`)&&!t.some(e=>e.path.toLowerCase()===T.toLowerCase())&&(k?.total?t.push(Tm(T)):t.unshift(Tm(T))),t},[E,T,k,p,e]),j=e=>{v.current=void 0,m(e),g(void 0),f(0),S(``),C.current?.focus()},M=!D&&!(!e||O?.error||k?.indexed);return(0,u.useEffect)(()=>{let e=v.current;e===void 0||M||(v.current=void 0,y(A[Math.min(e,A.length-1)]))},[M,A,y]),(0,u.useEffect)(()=>{C.current?.focus()},[]),(0,u.useEffect)(()=>{w.current?.scrollIntoView({block:`nearest`})},[d]),(0,L.jsxs)(Qf,{mode:`path`,query:c,onMode:o,onClose:a,presentation:s,children:[(0,L.jsx)(`input`,{ref:C,className:`quick-open-input`,"data-quick-open-input":`1`,value:c,readOnly:x,placeholder:`快速打开:输入文件名或路径`,"aria-label":`快速打开文件路径`,onChange:e=>{let t=e.target.value;v.current=void 0,(Dm(t)!==T||p!==0)&&g(void 0),l(t),m(0),f(0),S(``)},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`ArrowDown`)e.preventDefault(),f(e=>Math.min(e+1,Math.max(0,A.length-1)));else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=A[Math.min(d,A.length-1)],n=k?.hits.some(e=>e.path===t?.path&&[e.name,e.path].some(e=>e.toLowerCase()===T.toLowerCase()));M&&!n?v.current=d:y(t)}}}}),(0,L.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"aria-live":`polite`,"data-quick-open-status":D||k?.indexed&&!k.incomplete?`complete`:`partial`,children:[D?`按 Enter 打开指定文件`:e?n?O?.error||(M?`正在检查文件索引…`:T?k?.incomplete?`索引不完整 · ${k.total} 条命中`:k?.total?`${k.total} 条命中${p?` · 第 ${p+1} 页`:``}`:A.length?`近似路径`:`没有匹配的文件名或路径`:`输入文件名或路径以查找当前目录中的文件`):`等待连接…`:`请先选择工作区`,` · Esc 关闭`]}),b&&(0,L.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:b}),(0,L.jsx)(`ul`,{className:`quick-open-results`,role:`listbox`,children:A.map((e,t)=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{ref:t===d?w:void 0,type:`button`,"data-quick-open-result":e.path,className:t===d?`quick-open-result quick-open-result-active`:`quick-open-result`,"aria-selected":t===d,onMouseMove:()=>f(t),onClick:()=>{v.current=void 0,y(e)},children:[(0,L.jsx)(`span`,{title:e.name,children:e.name}),(0,L.jsx)(`small`,{title:e.path,children:e.path})]})},e.path))}),T&&k?.indexed&&(p>0||k.truncated)&&(0,L.jsxs)(`div`,{className:`quick-open-pages`,"aria-label":`文件搜索翻页`,children:[p>0&&(0,L.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>j(p-1),children:`上一页`}),k.truncated&&(0,L.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-quick-open-next-page":!0,onClick:()=>j(p+1),children:`下一页`})]})]})}function $m({workspaceId:e,workspaceName:t,cwd:n,connected:r,onOpen:i,onSession:a,active:o=!0}){let[s,c]=(0,u.useState)(`content`),[l,d]=(0,u.useState)(``),f=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!o)return;let e=requestAnimationFrame(()=>f.current?.parentElement?.querySelector(`[data-content-search-input], [data-quick-open-input], [data-session-search-input]`)?.focus());return()=>cancelAnimationFrame(e)},[o,s]);let p={workspaceId:e,cwd:n,initialQuery:l,presentation:`sidebar`,onClose:()=>{},onMode:(e,t)=>{d(t),c(e)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{ref:f,className:`workbench-search-heading`,children:[(0,L.jsx)(`strong`,{children:`搜索`}),(0,L.jsx)(`span`,{title:t,children:t??`请选择工作区`})]}),s===`content`?(0,L.jsx)(Zm,{...p,onOpen:i}):s===`path`?(0,L.jsx)(Qm,{...p,connected:r,onOpen:i}):(0,L.jsx)($f,{...p,onOpen:a})]})}function eh(e,t,n){if(!t)return[];let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=new RegExp(r,n?`gu`:`giu`),a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=[];for(;a.nextNode();){let e=a.currentNode,t=e.parentElement;if(!t||!e.data||t.closest(`script,style,textarea,input,select,[hidden],[aria-hidden="true"],.katex-mathml,button:not([data-message-source-link])`))continue;let n=t.closest(`details:not([open])`);if(n&&!n.querySelector(`summary`)?.contains(t))continue;let r=t.closest(`p,pre,li,td,th,h1,h2,h3,h4,h5,h6,summary,[data-transcript-key]`);if(!r)continue;let i=o.at(-1);(!i||i.block!==r)&&(i={block:r,nodes:[],text:``},o.push(i)),i.nodes.push(e),i.text+=e.data}let s=[];for(let e of o){let t=0,n=0;for(let r of e.text.matchAll(i)){let i=r.index,a=i+r[0].length;for(;t<e.nodes.length-1&&i>=n+e.nodes[t].length;)n+=e.nodes[t++].length;let o=document.createRange();o.setStart(e.nodes[t],i-n);let c=t,l=n;for(;c<e.nodes.length-1&&a>l+e.nodes[c].length;)l+=e.nodes[c++].length;o.setEnd(e.nodes[c],a-l),o.getClientRects().length&&s.push(o)}}return s}function th(e,t,n){if(!n||!t.length)return 0;let r=new Map,i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),a=0;for(;i.nextNode();)r.set(i.currentNode,a),a+=i.currentNode.textContent?.length??0;let o=(t,n)=>{let i=r.get(t);if(i!==void 0)return i+n;let a=document.createRange();return a.selectNodeContents(e),a.setEnd(t,n),a.toString().length},s=n.range,c=s&&e.contains(s.startContainer)?o(s.startContainer,s.startOffset):void 0,l=e.getBoundingClientRect(),u=0,d=1/0;return t.forEach((t,r)=>{let i=c===void 0?0:o(t.startContainer,t.startOffset),a=c===void 0?0:o(t.endContainer,t.endOffset),s=c===void 0?Math.abs(t.getBoundingClientRect().top-l.top+e.scrollTop-n.top):c>=a?c-a+1:Math.max(i-c,0);s<d&&(u=r,d=s)}),u}function nh({container:e,onNavigate:t}){let[n,r]=(0,u.useState)(!1),[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)([]),[d,f]=(0,u.useState)(0),[p,m]=(0,u.useState)({top:0,right:0,width:0}),h=(0,u.useRef)(null),g=(0,u.useRef)(null),_=(0,u.useRef)(void 0),v=(0,u.useRef)(void 0),[y,b]=(0,u.useState)(0),x=(0,u.useRef)(t);x.current=t;let S=(0,u.useCallback)(()=>{r(!1),g.current?.isConnected&&g.current.focus({preventScroll:!0})},[]);(0,u.useEffect)(()=>{let t=t=>{if(!(t.defaultPrevented||t.isComposing||t.altKey)){if((t.ctrlKey||t.metaKey)&&!t.shiftKey&&t.key.toLowerCase()===`f`){if(t.target?.closest(`.cm-editor,.xterm,[role="dialog"],.modal`))return;t.preventDefault();let i=window.getSelection(),o=e.current;if(!o)return;let s=i&&i.rangeCount>0&&o.contains(i.anchorNode)&&o.contains(i.focusNode);(s||!n)&&(v.current={range:s?i.getRangeAt(0).cloneRange():void 0,top:o.scrollTop+o.clientHeight/3},l([]),_.current=void 0,b(e=>e+1)),s&&!i.isCollapsed&&a(i.toString()),n||(g.current=document.activeElement),r(!0),requestAnimationFrame(()=>{h.current?.focus(),h.current?.select()})}else n&&t.key===`Escape`&&(t.preventDefault(),S())}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[S,n]),(0,u.useLayoutEffect)(()=>{let t=e.current;if(!n||!t)return;let r=()=>{let e=t.getBoundingClientRect();m({top:e.top+8,right:window.innerWidth-e.right+12,width:Math.max(0,e.width-24)})};r();let i=new ResizeObserver(r);return i.observe(t),window.addEventListener(`resize`,r),()=>{i.disconnect(),window.removeEventListener(`resize`,r)}},[e,n]),(0,u.useEffect)(()=>{let t=e.current;if(!n||!t){l([]);return}let r,a=()=>{let e=eh(t,i,o);l(e),f(th(t,e,v.current))};a();let s=new MutationObserver(()=>{clearTimeout(r),r=setTimeout(a,100)});return s.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`open`,`hidden`]}),()=>{clearTimeout(r),s.disconnect()}},[e,n,i,o,y]);let C=c.length?Math.min(d,c.length-1):0;if((0,u.useEffect)(()=>{if(CSS.highlights?.delete(`transcript-find`),CSS.highlights?.delete(`transcript-find-current`),n&&typeof Highlight<`u`)return CSS.highlights.set(`transcript-find`,new Highlight(...c)),c[C]&&CSS.highlights.set(`transcript-find-current`,new Highlight(c[C])),()=>{CSS.highlights.delete(`transcript-find`),CSS.highlights.delete(`transcript-find-current`)}},[n,c,C]),(0,u.useEffect)(()=>{let t=e.current,r=c[C];if(!n||!t||!r){_.current=void 0;return}let i=_.current;if(i?.node===r.startContainer&&i.offset===r.startOffset&&i.end===r.endOffset)return;_.current={node:r.startContainer,offset:r.startOffset,end:r.endOffset},v.current={range:r.cloneRange(),top:t.scrollTop+t.clientHeight/3};let a=r.getBoundingClientRect(),o=t.getBoundingClientRect();t.scrollTop+=a.top-o.top-o.height/3,x.current(t)},[e,n,c,C]),!n)return null;let w=e=>f((C+e+c.length)%(c.length||1));return(0,L.jsxs)(`div`,{className:`transcript-find`,role:`search`,"aria-label":`当前会话页内查找`,style:{top:p.top,right:p.right,maxWidth:p.width},children:[(0,L.jsx)(`input`,{ref:h,"aria-label":`查找当前会话`,placeholder:`查找当前会话…`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),w(e.shiftKey?-1:1))}}),(0,L.jsx)(`button`,{type:`button`,className:`transcript-find-case`,title:`区分大小写`,"aria-label":`区分大小写`,"aria-pressed":o,onClick:()=>s(e=>!e),children:`Aa`}),(0,L.jsx)(`output`,{"aria-live":`polite`,"data-transcript-find-count":!0,children:i?c.length?`${C+1} / ${c.length}`:`无结果`:`0 / 0`}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`上一个匹配`,title:`上一个匹配(Shift+Enter)`,disabled:!c.length,onClick:()=>w(-1),children:`↑`}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`下一个匹配`,title:`下一个匹配(Enter)`,disabled:!c.length,onClick:()=>w(1),children:`↓`}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`关闭页内查找`,title:`关闭(Esc)`,onClick:S,children:`×`})]})}function rh(e,t,n,r,i){let a=Number.isFinite(t)&&t>0?t:n,o=e.map(e=>({id:e.id,width:Math.min(a,Math.max(Math.min(n,a),Number.isFinite(e.width)?e.width:n))}));if(o.every(e=>e.width<=i.width)){let t=[];for(let n=0;n<e.length;n+=Math.max(1,i.perRow))t.push({ids:e.slice(n,n+Math.max(1,i.perRow)).map(e=>e.id),width:Math.min(a,i.width)});return t}let s=[],c=[],l=0,u=()=>{c.length&&(s.push({ids:c.map(e=>e.id),width:Math.min(a/c.length,Math.max(r,l))}),c=[],l=0)};for(let e of o)c.length&&Math.max(l,e.width)*(c.length+1)>a+.1&&u(),c.push(e),l=Math.max(l,e.width);return u(),s}function ih(e,t,n=88,r=200){let i=Math.max(0,Math.floor(e));if(!Number.isFinite(t)||t<=0)return{perRow:Math.max(1,i),width:n};if(i===0)return{perRow:1,width:n};if(i===1)return{perRow:1,width:Math.min(r,t)};let a=t/i;if(a>=n)return{perRow:i,width:Math.min(a,r)};for(let e=2;e<=i;e+=1){let a=Math.ceil(i/e),o=t/a;if(o>=n)return{perRow:a,width:Math.min(o,r)}}return{perRow:1,width:n}}function ah(e,t,n=88,r=200){let[i,a]=(0,u.useState)(()=>ih(e,0,n,r)),[o,s]=(0,u.useState)(null),c=(0,u.useCallback)(()=>{let i=ih(e,t,n,r);s({count:e,containerWidth:t}),a(e=>e.perRow===i.perRow&&e.width===i.width?e:i)},[e,t,n,r]),l=(0,u.useRef)(t);(0,u.useLayoutEffect)(()=>{t<=0||l.current!==t&&(l.current=t,c())},[t,c]);let d=(0,u.useRef)(null);return(0,u.useLayoutEffect)(()=>{let t=d.current;d.current=e,t!==null&&e>t&&c()},[e,c]),{layout:i,frozen:o!==null&&o.count!==e,recompute:c}}function oh({tabs:e,activeId:t,onSelect:n,onClose:r,onActivate:i,ariaLabel:a,minWidth:o=88,maxWidth:s=200,prefix:c=`workspace-tab`,idPrefix:l=c,className:d}){let f=(0,u.useRef)(null),[p,m]=(0,u.useState)(0),{layout:h,frozen:g,recompute:_}=ah(e.length,p,o,s);(0,u.useLayoutEffect)(()=>{let e=f.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>{let t=e.clientWidth;t>0&&m(t)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)([]),S=JSON.stringify(e.map(e=>[e.id,e.label]));(0,u.useLayoutEffect)(()=>{let e=f.current;if(!e)return;let t=()=>{let t={};for(let n of e.querySelectorAll(`[role=tab]`)){let e=n.querySelector(`.workspace-tab-label`),r=n.id.slice(l.length+1);if(!e||!r)continue;let i=document.createRange();i.selectNodeContents(e);let a=n.getBoundingClientRect().width-e.getBoundingClientRect().width;t[r]=Math.ceil(i.getBoundingClientRect().width+a+2)}y(e=>JSON.stringify(e)===JSON.stringify(t)?e:t)};return t(),document.fonts?.addEventListener(`loadingdone`,t),()=>document.fonts?.removeEventListener(`loadingdone`,t)},[S,p,l]);let C=rh(e.map(e=>({id:e.id,width:v[e.id]??o})),p,o,s,h),w=JSON.stringify(C);(0,u.useLayoutEffect)(()=>{g||x(e=>JSON.stringify(e)===w?e:C)},[g,w]);let T=b.length&&e.every(e=>b.some(t=>t.ids.includes(e.id)))?b:C,E=0,D=T.map(t=>{let n=g?e.slice(E,E+=t.ids.length):t.ids.flatMap(t=>{let n=e.find(e=>e.id===t);return n?[n]:[]});return{...t,tabs:n}}).filter(e=>e.tabs.length),O=D.map(e=>e.tabs),k=D.map(e=>e.width),A=(e,t)=>t===void 0?{}:{[`data-${c}-${e}`]:t},j=e.filter(e=>e.kind===`file`).length,M=e.filter(e=>e.kind===`session`||!e.kind).length,N=t=>({[`data-${t}-strip`]:`1`,...g?{[`data-${t}-frozen`]:`1`}:{},[`data-${t}-count`]:t===`file-tab`?j:t===`session-tab`?M:e.length,[`data-${t}-min`]:o,[`data-${t}-max`]:s,[`data-${t}-per-row`]:O[0]?.length??h.perRow,[`data-${t}-width`]:Math.round((k[0]??h.width)*100)/100}),P=e=>{let t=e.relatedTarget;(!t||t.isConnected)&&_()},F=e=>{let t=e.relatedTarget;(!t||t.isConnected)&&_()};(0,u.useEffect)(()=>{if(!g)return;let e=f.current;if(!e)return;let t=t=>{let n=e.getBoundingClientRect();t.clientX>=n.left&&t.clientX<=n.right&&t.clientY>=n.top&&t.clientY<=n.bottom||_()};return document.addEventListener(`mousemove`,t,!0),()=>document.removeEventListener(`mousemove`,t,!0)},[g,_]);let ee=[`${c}-strip`,`workspace-tab-strip`,`session-tab-strip`,`file-tab-strip`,d].filter(Boolean).join(` `);return(0,L.jsx)(`div`,{ref:f,className:ee,role:`tablist`,"aria-label":a??`工作区标签页`,...A(`strip`,`1`),...N(`workspace-tab`),...N(`session-tab`),...N(`file-tab`),style:{"--tab-w":`${h.width}px`},onMouseEnter:P,onMouseLeave:F,children:O.map((a,o)=>(0,L.jsx)(`div`,{className:`${c}-row workspace-tab-row session-tab-row file-tab-row`,role:`presentation`,...A(`row`,o),"data-tab-row-width":k[o],children:a.map(a=>{let s={width:k[o]},u=a.id===t||a.rawId!==void 0&&a.rawId===t,d=a.title?a.title.includes(a.label)?a.title:`${a.label}\n${a.title}`:a.label,f=a.kind,p=a.rawId??a.id,m=e.findIndex(e=>e.id===a.id),h=[c,u?`${c}-active`:``,`workspace-tab`,u?`workspace-tab-active`:``,f?`${f}-tab`:``,f&&u?`${f}-tab-active`:``,a.preview?`${c}-preview`:``,a.preview?`workspace-tab-preview`:``,a.preview&&f?`${f}-tab-preview`:``].filter(Boolean).join(` `);return(0,L.jsxs)(`div`,{role:`tab`,id:`${l}-${a.id}`,"aria-selected":u,"aria-controls":`${l}-panel-${a.id}`,tabIndex:u?0:-1,className:h,...A(`id`,p),...A(`index`,m),...u?A(`active`,`1`):{},...A(`closable`,a.closable===!1?`0`:`1`),...f?{"data-tab-kind":f}:{},...a.preview?{"data-tab-preview":`1`}:{},...f===`session`||!f?{"data-session-tab-id":p,"data-session-tab-index":m,...u?{"data-session-tab-active":`1`}:{},"data-session-tab-closable":a.closable===!1?`0`:`1`,...a.preview?{"data-session-tab-preview":`1`}:{}}:{},...f===`file`?{"data-file-tab-id":p,"data-file-tab-index":m,...u?{"data-file-tab-active":`1`}:{},"data-file-tab-closable":a.closable===!1?`0`:`1`}:{},...f===`diff`?{"data-diff-tab-id":p,"data-diff-tab-index":m,...u?{"data-diff-tab-active":`1`}:{},"data-diff-tab-closable":a.closable===!1?`0`:`1`}:{},title:d,style:{width:s.width,boxSizing:`border-box`},onClick:()=>n?.(a.id),onDoubleClick:i?()=>i(a.id):void 0,onAuxClick:e=>{e.button===1&&(e.preventDefault(),e.stopPropagation(),a.closable!==!1&&r&&r(a.id))},onMouseDown:e=>{e.button===1&&e.preventDefault()},onKeyDown:t=>{if(t.key!==`ArrowLeft`&&t.key!==`ArrowRight`)return;t.preventDefault();let r=t.key===`ArrowRight`?1:-1,i=e[(e.findIndex(e=>e.id===a.id)+r+e.length)%e.length];i&&(document.getElementById(`${l}-${i.id}`)?.focus(),n?.(i.id))},children:[a.icon&&(0,L.jsx)(`span`,{className:`${c}-icon workspace-tab-icon`,children:a.icon}),a.badge,(0,L.jsx)(`span`,{className:`${c}-label workspace-tab-label ${f?`${f}-tab-label`:``}`,title:d,...A(`label`,p),...f===`session`||!f?{"data-session-tab-label":p}:{},...f===`file`?{"data-file-tab-label":p}:{},...f===`diff`?{"data-diff-tab-label":p}:{},children:a.label}),a.closable!==!1&&r&&(0,L.jsx)(`button`,{type:`button`,className:`${c}-close workspace-tab-close ${f?`${f}-tab-close`:``}`,...A(`close`,p),...f===`session`||!f?{"data-session-tab-close":p}:{},...f===`file`?{"data-file-tab-close":p}:{},...f===`diff`?{"data-diff-tab-close":p}:{},onClick:e=>{e.stopPropagation(),r(a.id)},onDoubleClick:e=>{e.stopPropagation()},title:`关闭 ${d}`,"aria-label":`关闭 ${d}`,children:`×`})]},a.id)})},`row_${o}`))})}var sh=25,ch=75;function lh({share:e,onShare:t}){let n=(0,u.useRef)(null),[r,i]=(0,u.useState)(!1),a=e=>t(Math.round(Math.min(ch,Math.max(sh,e))));return(0,u.useLayoutEffect)(()=>{let e=n.current?.parentElement;if(!e)return;let t=()=>i(getComputedStyle(e).flexDirection===`column`);t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]),(0,L.jsx)(`div`,{ref:n,className:`workbench-split-divider`,"data-workbench-split-divider":!0,role:`separator`,"aria-label":`调整拆分大小`,"aria-orientation":r?`horizontal`:`vertical`,"aria-valuenow":e,"aria-valuemin":sh,"aria-valuemax":ch,tabIndex:0,onPointerDown:e=>{e.button===0&&(e.currentTarget.focus(),e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{if(!e.currentTarget.hasPointerCapture(e.pointerId))return;let t=e.currentTarget.parentElement?.getBoundingClientRect();t&&a(r?(e.clientY-t.top)/t.height*100:(e.clientX-t.left)/t.width*100)},onKeyDown:t=>{let n=t.key===(r?`ArrowDown`:`ArrowRight`),i=t.key===(r?`ArrowUp`:`ArrowLeft`);if(n||i)a(e+(n?5:-5));else if(t.key===`Home`)a(sh);else if(t.key===`End`)a(ch);else return;t.preventDefault()}})}function uh({tabs:e,selected:t,onSelect:n,onPin:r,onCloseTab:i,onClose:a,children:o}){let s=e.find(e=>e.id===t);return(0,L.jsxs)(`section`,{className:`workbench-split-pane`,"data-workbench-split-pane":!0,"aria-label":`拆分区`,children:[(0,L.jsxs)(`div`,{className:`workbench-split-bar`,children:[(0,L.jsxs)(`select`,{"aria-label":`拆分区标签页`,"data-workbench-split-tabs":!0,value:t??``,onChange:e=>n(e.target.value),title:s?.title,"data-workbench-split-preview":s?.preview||void 0,children:[(0,L.jsx)(`option`,{value:``,disabled:!0,children:`选择文件或差异`}),e.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),t&&s?.preview&&(0,L.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`固定标签页`,"aria-label":`固定拆分区标签页`,onClick:()=>r(t),children:(0,L.jsx)(Xr,{name:`pin`})}),t&&(0,L.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`关闭此标签页`,"aria-label":`关闭拆分区标签页`,onClick:()=>i(t),children:(0,L.jsx)(Xr,{name:`close`})}),(0,L.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,"data-close-workbench-split":!0,title:`合并主区`,"aria-label":`合并主区`,onClick:a,children:(0,L.jsx)(Xr,{name:`split`})})]}),o??(0,L.jsx)(`p`,{className:`rail-empty`,children:`从文件或 Git 面板打开一个文件或差异。`})]})}function dh(e,t){if(e.entries[e.index]?.key===t.key)return e;let n=[...e.entries.slice(0,e.index+1),t].slice(-100);return{entries:n,index:n.length-1}}function fh(e,t,n,r){for(let i=t+n;i>=0&&i<e.entries.length;i+=n)if(r(e.entries[i]))return i;return-1}var ph={pending:`未开始`,running:`运行中`,completed:`已完成`,failed:`失败`,skipped:`已跳过`,stopped:`已停止`},mh={running:`运行中`,completed:`全部完成`,failed:`中途失败`,stopped:`已停止`},hh={pending:`○`,running:`◐`,completed:`✓`,failed:`✕`,skipped:`→`,stopped:`■`},gh={stop:`失败即停`,skip:`失败跳过`,"retry:1":`失败重试 1 次`,"retry:2":`失败重试 2 次`,"retry:3":`失败重试 3 次`};function _h(e){let t=Math.max(0,Math.round(e/1e3)),n=t%60,r=Math.floor(t/60)%60,i=Math.floor(t/3600),a=e=>String(e).padStart(2,`0`);return i>0?`${i}h ${a(r)}:${a(n)}`:`${r}:${a(n)}`}function vh(e){let t=e.status===`running`,[n,r]=(0,u.useState)(0);(0,u.useEffect)(()=>{if(!t)return;r(Date.now());let e=window.setInterval(()=>r(Date.now()),200);return()=>window.clearInterval(e)},[t,e.startedAt]);let i=Date.parse(e.startedAt);if(Number.isFinite(i)){if(!t){let t=Date.parse(e.finishedAt??``);return Number.isFinite(t)?t-i:void 0}return n>0?n-i:void 0}}function yh({step:e,names:t}){let n=e.attempts.length,r=e.attempts[n-1],i=t.get(e.agentId)||e.agentId,a=e.label?.trim()||i;return(0,L.jsxs)(`li`,{className:`workflow-step workflow-step-${e.status}`,"data-workflow-step":e.index+1,"data-workflow-step-status":e.status,"data-workflow-step-agent":e.agentId,"data-workflow-step-attempts":n,children:[(0,L.jsx)(`span`,{className:`workflow-step-mark`,"aria-hidden":`true`,children:hh[e.status]}),(0,L.jsxs)(`span`,{className:`workflow-step-n`,"data-workflow-step-n":e.index+1,children:[`第 `,e.index+1,` 步`]}),(0,L.jsx)(`strong`,{className:`workflow-step-name`,"data-workflow-step-name":e.index+1,children:a}),(0,L.jsx)(`span`,{className:`workflow-step-agent`,"data-workflow-step-agent-name":e.index+1,children:i}),n>1&&(0,L.jsxs)(`span`,{className:`workflow-step-tries`,"data-workflow-step-retried":e.index+1,children:[`尝试 `,n,` 次`]}),(0,L.jsx)(`span`,{className:`workflow-step-status`,"data-workflow-step-status-text":e.index+1,children:ph[e.status]}),e.status===`failed`&&r?.error&&(0,L.jsx)(`span`,{className:`workflow-step-why`,"data-workflow-step-error":e.index+1,title:Pr(r.error),children:Nr(r.error,`这一步没有完成。`)})]})}function bh({nodes:e,steps:t,names:n}){return(0,L.jsx)(`ol`,{className:`workflow-steps`,children:e.map((e,r)=>{if(e.kind===`step`){let r=t[e.stepIndex];return r?(0,L.jsx)(yh,{step:r,names:n},`step-${e.stepIndex}`):null}return e.kind===`loop`?(0,L.jsxs)(`li`,{className:`workflow-node workflow-loop`,"data-workflow-loop":!0,"data-workflow-loop-rounds":e.rounds.length,"data-workflow-loop-max":e.max,"data-workflow-until":e.until,children:[(0,L.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),(0,L.jsx)(`strong`,{children:`循环`}),(0,L.jsxs)(`span`,{children:[`直到「`,e.until,`」`]}),(0,L.jsxs)(`span`,{"data-workflow-loop-progress":!0,children:[`已跑 `,e.rounds.length,`/`,e.max,` 轮`]})]}),e.rounds.map(e=>(0,L.jsxs)(`section`,{className:`workflow-round`,"data-workflow-round":e.n,"data-workflow-round-met":e.untilMet?`true`:`false`,children:[(0,L.jsxs)(`div`,{className:`workflow-round-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:e.untilMet?`✓`:`○`}),`第 `,e.n,` 轮 · `,e.untilMet?`条件满足`:`条件未满足`]}),(0,L.jsx)(bh,{nodes:e.nodes,steps:t,names:n})]},e.n))]},`loop-${r}`):(0,L.jsxs)(`li`,{className:`workflow-node workflow-foreach`,"data-workflow-foreach":!0,"data-workflow-foreach-count":e.items.length,children:[(0,L.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`≡`}),(0,L.jsx)(`strong`,{children:`逐项执行`}),(0,L.jsxs)(`span`,{children:[e.items.length,` 个由 primary 给出的项目`]})]}),e.iterations.map((e,r)=>(0,L.jsxs)(`section`,{className:`workflow-item`,"data-workflow-item":r+1,"data-workflow-item-value":e.item,children:[(0,L.jsxs)(`div`,{className:`workflow-item-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),`第 `,r+1,` 项 · `,e.item]}),(0,L.jsx)(bh,{nodes:e.nodes,steps:t,names:n})]},`${r}-${e.item}`))]},`foreach-${r}`)})})}function xh({workflow:e,names:t,onStop:n,stopping:r}){let i=e.status===`running`,a=vh(e),o=e.steps.filter(e=>e.status===`completed`||e.status===`skipped`).length;return(0,L.jsxs)(`article`,{className:`workflow-card workflow-${e.status}`,"data-workflow-card":e.id,"data-workflow-status":e.status,"data-workflow-steps":e.steps.length,"data-workflow-current":e.currentIndex+1,children:[(0,L.jsxs)(`div`,{className:`workflow-head`,children:[(0,L.jsx)(`span`,{className:`workflow-badge`,children:`编排`}),(0,L.jsx)(`strong`,{className:`workflow-summary`,"data-workflow-summary":e.id,children:e.summary}),(0,L.jsxs)(`span`,{className:`workflow-progress`,"data-workflow-progress":e.id,children:[o,`/`,e.steps.length]}),(0,L.jsx)(`span`,{className:`workflow-status`,"data-workflow-status-text":e.id,children:mh[e.status]??`未知状态`}),(0,L.jsx)(`span`,{className:`workflow-policy`,"data-workflow-policy":e.onFailure,children:gh[e.onFailure]??e.onFailure}),a!==void 0&&(0,L.jsxs)(`span`,{className:`workflow-clock`,"data-workflow-elapsed":e.id,children:[i?`已运行 `:`用时 `,_h(a)]}),i&&(0,L.jsx)(`button`,{type:`button`,className:`workflow-stop`,"data-workflow-stop":e.id,disabled:r,onClick:n,children:`停止`})]}),e.nodes?(0,L.jsx)(bh,{nodes:e.nodes,steps:e.steps,names:t}):(0,L.jsx)(`ol`,{className:`workflow-steps`,"data-workflow-step-count":e.steps.length,children:e.steps.map(e=>(0,L.jsx)(yh,{step:e,names:t},e.index))})]})}var Sh=[{id:`agents`,label:`智能体与创建`,icon:`🤖`,title:`Agent 智能体系统与创建指南`,description:`了解 Super Pi 的角色设定机制,以及如何一步步创建你自己的自定义 Agent。`},{id:`workspace`,label:`工作区与会话`,icon:`🗂️`,title:`工作区与多会话管理`,description:`高效管理本地代码仓库、独立会话标签页与多模态图文输入。`},{id:`subagents`,label:`子任务与编排`,icon:`⚡`,title:`子智能体委托与顺序编排使用指南`,description:`让主 Agent 安排分工、交接结果,并查看进度、处理失败与停止任务。`},{id:`model-policy`,label:`模型使用规则`,icon:`🔒`,title:`模型过滤规则(按工作区限制可用模型)`,description:`用正则规则限定哪些工作区只能用哪些模型,防止敏感代码被发到不该用的模型上。`},{id:`memory`,label:`主动记忆`,icon:`🧠`,title:`主动记忆与技能经验`,description:`让 Super Pi 在得到明确证据后保存长期事实、用户偏好和可复用工作方法。`},{id:`knowledge`,label:`知识库`,icon:`📚`,title:`工作区知识库`,description:`导入规范与设计文档,让 Agent 检索原文作答,而不是凭记忆编造。`},{id:`feishu`,label:`飞书`,icon:`📄`,title:`飞书云文档的读写`,description:`让 Agent 读一篇飞书文档、写回结论。接入方式、连接步骤与常见问题。`},{id:`tools`,label:`侧边栏工具`,icon:`🧩`,title:`全局工具:开发、导出与导入`,description:`让 Agent 写一个工具,用一个文件分享给别人,导入前先看清它会做什么。`},{id:`cli`,label:`指令与快捷键`,icon:`⌨️`,title:`Pi 终端命令与键盘快捷操作`,description:`利用 Pi 终端斜杠指令控制服务生命周期,掌握常用快捷键提升效率。`},{id:`themes`,label:`外观与主题`,icon:`🎨`,title:`界面主题与个性化显示`,description:`内置 4 款专业高对比度主题,针对不同环境提供舒适体验。`}];function Ch({onClose:e}){let[t,n]=(0,u.useState)(`agents`);(0,u.useEffect)(()=>{let t=t=>{t.key===`Escape`&&!t.defaultPrevented&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let r=Sh.find(e=>e.id===t)??Sh[0];return(0,L.jsx)(`div`,{className:`overlay`,onClick:e,children:(0,L.jsxs)(`div`,{className:`picker settings-window help-window`,"data-help-window":`1`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-window-title`,children:[(0,L.jsxs)(`div`,{className:`settings-window-head help-window-head`,children:[(0,L.jsxs)(`div`,{className:`help-head-title`,children:[(0,L.jsx)(`h2`,{id:`help-window-title`,children:`使用指南与帮助`}),(0,L.jsx)(`span`,{className:`help-badge`,children:`v0.1.x`})]}),(0,L.jsx)(`button`,{type:`button`,className:`help-close-button`,"aria-label":`关闭指南`,onClick:e,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`settings-window-body help-window-body`,children:[(0,L.jsxs)(`nav`,{className:`settings-nav help-nav`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":`使用指南分类`,children:[(0,L.jsx)(`div`,{className:`settings-nav-label`,children:`目录`}),Sh.map(e=>(0,L.jsxs)(`button`,{type:`button`,id:`help-tab-${e.id}`,className:`settings-category help-category`,role:`tab`,"aria-selected":e.id===r.id,"aria-controls":`help-panel`,tabIndex:e.id===r.id?0:-1,onClick:()=>n(e.id),children:[(0,L.jsx)(`span`,{className:`help-tab-icon`,"aria-hidden":`true`,children:e.icon}),(0,L.jsx)(`span`,{children:e.label})]},e.id))]}),(0,L.jsxs)(`div`,{id:`help-panel`,className:`settings-panel help-panel`,role:`tabpanel`,"aria-labelledby":`help-tab-${r.id}`,children:[(0,L.jsxs)(`div`,{className:`help-panel-header`,children:[(0,L.jsx)(`h3`,{className:`help-panel-title`,children:r.title}),(0,L.jsx)(`p`,{className:`help-panel-desc`,children:r.description})]}),(0,L.jsxs)(`div`,{className:`help-panel-content`,children:[r.id===`agents`&&(0,L.jsx)(Eh,{}),r.id===`workspace`&&(0,L.jsx)(Dh,{}),r.id===`subagents`&&(0,L.jsx)(kh,{}),r.id===`model-policy`&&(0,L.jsx)(Oh,{}),r.id===`memory`&&(0,L.jsx)(wh,{}),r.id===`knowledge`&&(0,L.jsx)(Th,{}),r.id===`feishu`&&(0,L.jsx)(Ah,{}),r.id===`tools`&&(0,L.jsx)(jh,{}),r.id===`cli`&&(0,L.jsx)(Mh,{}),r.id===`themes`&&(0,L.jsx)(Nh,{})]}),(0,L.jsx)(`div`,{className:`picker-actions help-actions`,children:(0,L.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e,children:`关闭`})})]})]})]})})}function wh(){return(0,L.jsxs)(`div`,{className:`help-section-group`,children:[(0,L.jsxs)(`div`,{className:`help-card highlight`,children:[(0,L.jsx)(`h4`,{children:`🧠 它会记住什么?`}),(0,L.jsx)(`p`,{children:`用户档案保存跨工作区的长期偏好;工作区事实保存环境与项目约定;技能保存已经验证过的步骤、命令和坑。临时结果、秘密和未验证的失败不会保存。`})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`主动保存与后台复盘`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[`主 Agent 可以使用 `,(0,L.jsx)(`code`,{children:`memory`}),` 和 `,(0,L.jsx)(`code`,{children:`skill_manage`}),` 工具主动保存;说“记住了”本身不会写入。`]}),(0,L.jsx)(`li`,{children:`每隔若干回合,系统会在独立会话中复盘最近证据。复盘不能读写工作区文件、执行命令或派发任务。`}),(0,L.jsx)(`li`,{children:`读取记忆和历史只返回带来源的参考数据,不能把记忆中的文字当作新的指令。`})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`权限与审批`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsx)(`li`,{children:`子 Agent 可以读取相关记忆,但没有写入权限。`}),(0,L.jsx)(`li`,{children:`后台复盘新增记忆可以直接保存;修改或删除旧条目会进入设置中的待审批列表。`}),(0,L.jsx)(`li`,{children:`在“设置 → 主动记忆”可以开关功能、调整复盘间隔、编辑条目和批准提案。`})]})]})]})}function Th(){return(0,L.jsxs)(`div`,{className:`help-section-group`,children:[(0,L.jsxs)(`div`,{className:`help-card highlight`,children:[(0,L.jsx)(`h4`,{children:`📚 它解决什么问题?`}),(0,L.jsx)(`p`,{children:`Agent 默认靠训练时的记忆回答项目里的问题。知识库让你把规范、设计稿、会议纪要导入工作区,Agent 在回答前检索这些文档的原文片段,而不是凭印象编造。它与“主动记忆”不同:记忆是 Agent 自己沉淀的事实和技能,知识库的内容来自工作区里真实存在的文档。`})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`怎么用`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[`在“设置 → 知识库”里点“浏览工作区文件…”,在弹出的浏览器里挑一个 Markdown 或文本文件,挑完即导入。也可以直接粘贴正文、手动填写相对路径,或者直接对 Agent 说“把某某文件加入知识库”——它会用 `,(0,L.jsx)(`code`,{children:`knowledge_import`}),` 导入,走的是同一条服务端校验。`]}),(0,L.jsx)(`li`,{children:`同一个文件内容改了再导入就是更新,不会留下旧版本;同样的内容换个标题再导入也不会变成两篇。`}),(0,L.jsx)(`li`,{children:`面板里的“试检索”会用和 Agent 相同的检索器回答,方便你在交给 Agent 之前先确认它找得到。`}),(0,L.jsxs)(`li`,{children:[`从下一条消息开始生效。Agent 使用 `,(0,L.jsx)(`code`,{children:`knowledge_search`}),` 检索,只拿得到片段和来源,拿不到整篇文档。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`语义检索是内置的`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[`关键词检索始终可用。语义检索让“撤销购买”也能找到写着“取消订单”的段落,它靠一个`,(0,L.jsx)(`strong`,{children:`随安装包一起分发`}),`的中文模型在本机运行,不需要额外下载、不需要联网、也不会把文档发到任何服务。`]}),(0,L.jsxs)(`li`,{children:[`第一次检索时加载模型(约一秒),之后一直可用。设 `,(0,L.jsx)(`code`,{children:`SUPER_PI_KNOWLEDGE_EMBEDDINGS=0`}),` 可以彻底关闭语义检索,只保留关键词检索。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`它不知道的事`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsx)(`li`,{children:`知识库只会检索它有的东西。文档里没写的,它检索出来也不会有——所以导入什么,直接决定它能回答什么。`}),(0,L.jsx)(`li`,{children:`语义检索总会返回“最接近的那一段”,即使这一段其实并不回答问题。检索结果带一个分数,低分意味着这可能只是最像的一条,Agent 会被要求先核对再使用。`}),(0,L.jsxs)(`li`,{children:[`Agent 可以按你的要求把工作区文件导入知识库(`,(0,L.jsx)(`code`,{children:`knowledge_import`}),`,只接受文本类文件),但`,(0,L.jsx)(`strong`,{children:`不能删除`}),`——删除文档只有你能在“设置 → 知识库”里做。`]})]})]})]})}function Eh(){return(0,L.jsxs)(`div`,{className:`help-section-group`,children:[(0,L.jsxs)(`div`,{className:`help-card highlight`,children:[(0,L.jsx)(`h4`,{children:`💡 Agent 是什么?`}),(0,L.jsxs)(`p`,{children:[`在 Super Pi 中,`,(0,L.jsx)(`strong`,{children:`Agent(智能体)`}),` 是一套独立的「角色提示词设定与能力配置」。 通过切换 Agent,模型将扮演专精工程师、系统架构师、代码审查员或规划专家等不同角色,遵循指定的原则来协助你完成任务。`]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`📁 Agent 文件存放在哪里?`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`内置 Agent 目录:`}),`项目根目录下的 `,(0,L.jsx)(`code`,{children:`agents/`}),` 文件夹,例如 `,(0,L.jsx)(`code`,{children:`agents/coder.md`}),`、`,(0,L.jsx)(`code`,{children:`agents/planner.md`}),`、`,(0,L.jsx)(`code`,{children:`agents/reviewer.md`}),` 等。`]}),(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`用户自定义持久化目录:`}),`用户主目录下的 `,(0,L.jsx)(`code`,{children:`~/.super-pi/agents/`}),`,放入此目录的文件在所有项目和更新中均持久有效。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`🚀 如何创建一个全新的自定义 Agent?`}),(0,L.jsxs)(`div`,{className:`help-steps`,children:[(0,L.jsxs)(`div`,{className:`help-step`,children:[(0,L.jsx)(`span`,{className:`step-num`,children:`1`}),(0,L.jsxs)(`div`,{className:`step-body`,children:[(0,L.jsx)(`strong`,{children:`创建 Markdown 文件`}),(0,L.jsxs)(`p`,{children:[`在 `,(0,L.jsx)(`code`,{children:`agents/`}),` 或 `,(0,L.jsx)(`code`,{children:`~/.super-pi/agents/`}),` 目录下新建文件,例如 `,(0,L.jsx)(`code`,{children:`architect.md`}),`。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-step`,children:[(0,L.jsx)(`span`,{className:`step-num`,children:`2`}),(0,L.jsxs)(`div`,{className:`step-body`,children:[(0,L.jsx)(`strong`,{children:`编写元数据与系统提示词`}),(0,L.jsx)(`p`,{children:`文件开头使用 YAML Frontmatter 声明名称和描述,正文编写设定提示词:`}),(0,L.jsx)(`pre`,{className:`help-code-block`,children:(0,L.jsx)(`code`,{children:`---
|
|
@@ -338,7 +338,7 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
338
338
|
`).find(e=>e.trim().length>0)??``).trim().slice(0,60)||`任务指令`,state:`running`};let t=(()=>{let t=/<summary>([\s\S]*?)<\/summary>/.exec(e.content);return t?t[1].trim():`后台回传`})(),n=/<task id="[^"]+" state="([^"]+)"/.exec(e.content);return{label:t,state:n?n[1]:`completed`}}function QO({message:e,order:t,total:n,running:r,interrupting:i=!1,selectable:a=!1,selected:o=!1,onToggleSelect:s,onSteer:c,onInterrupt:l,onSend:d,onCancel:f,onEdit:p}){let[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(e.content),v=e.delivery===`sending`,y=e.source===`session-reminder`,b=e.role===`tool`&&!y,{label:x,state:S}=b?ZO(e):{label:XO(e),state:`user`},C=()=>{let t=g.trim();t&&t!==e.content&&p(e.id,t),h(!1)};return(0,L.jsxs)(`li`,{className:`queue-row ${v?`queue-row-sending`:`queue-row-queued`} ${b?`queue-row-bg-result`:``}`,"data-queue-id":e.id,"data-message-delivery":e.delivery,"data-message-role":e.role,"data-bg-result-state":b?S:void 0,"data-waiting-order":t,"data-waiting-total":n,children:[a&&(0,L.jsx)(`input`,{type:`checkbox`,className:`queue-select`,"data-waiting-select":e.id,checked:o,"aria-label":`选择「${x}」`,onChange:()=>s?.(e.id)}),(0,L.jsx)(`span`,{className:`queue-index`,"aria-hidden":`true`,children:t}),y?(0,L.jsxs)(`span`,{className:`queue-reminder`,"data-queue-reminder":!0,children:[(0,L.jsxs)(`span`,{className:`reminder-label`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,L.jsx)(`span`,{className:`queue-text`,title:x,children:x})]}):b?(0,L.jsxs)(`span`,{className:`queue-bg-result`,title:x,children:[(0,L.jsx)(`span`,{className:`bg-result-glyph`,"aria-hidden":`true`,children:S===`error`?`✕`:`↩`}),(0,L.jsx)(`span`,{className:`bg-result-label`,children:`后台回传`}),(0,L.jsx)(`span`,{className:`bg-result-summary`,children:x})]}):m?(0,L.jsxs)(`div`,{className:`queue-row-edit`,children:[(0,L.jsx)(`textarea`,{value:g,autoFocus:!0,rows:2,"aria-label":`修改这条等待中的消息`,onChange:e=>_(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),_(e.content),h(!1)),t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),C())}}),(0,L.jsx)(`button`,{type:`button`,className:`queue-edit-save`,"data-waiting-save":e.id,onClick:C,children:`保存`}),(0,L.jsx)(`button`,{type:`button`,className:`queue-edit-cancel`,"data-waiting-cancel-edit":e.id,onClick:()=>{_(e.content),h(!1)},children:`取消`})]}):(0,L.jsx)(`span`,{className:`queue-text`,title:x,children:x}),(0,L.jsx)(`span`,{className:`queue-state`,"data-waiting-state":v?`sending`:`queued`,children:v?`已交给 Agent`:t===1?`下一条回答这条`:`等待回答 · 第 ${t} 条`}),v?(0,L.jsx)(`span`,{className:`queue-locked`,"data-waiting-locked":e.id,children:`暂时改不了`}):(0,L.jsxs)(L.Fragment,{children:[r?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,className:`queue-interrupt`,"data-waiting-interrupt":e.id,disabled:i,title:`停止当前任务,立即回答这条消息`,"aria-label":`停止当前任务并回答「${x}」`,onClick:()=>l(e.id),children:i?`◌ 打断中…`:`打断并回答`}),(0,L.jsx)(`button`,{type:`button`,className:`queue-steer`,"data-waiting-steer":e.id,title:t===1?`当前工具完成后回答这条消息`:`插到最前:让它成为下一条被回答的消息`,"aria-label":t===1?`当前工具完成后回答「${x}」`:`让「${x}」插到最前`,onClick:()=>c(e.id),children:t===1?`当前工具完成后回答`:`插到最前`})]}):(0,L.jsx)(`button`,{type:`button`,className:`queue-steer`,"data-waiting-send":e.id,title:`现在就回答这条消息`,"aria-label":`现在就回答「${x}」`,onClick:()=>d(e.id),children:`现在就回答`}),e.role===`user`&&(0,L.jsx)(`button`,{type:`button`,className:`queue-edit`,"data-waiting-edit":e.id,title:`回答这条之前改字`,"aria-label":`修改「${x}」`,onClick:()=>{_(e.content),h(!0)},children:`改字`}),(0,L.jsx)(`button`,{type:`button`,className:`queue-cancel`,"data-waiting-cancel":e.id,title:`撤回这条消息,它不会被回答`,"aria-label":`撤回「${x}」`,onClick:()=>f(e.id),children:`撤回`})]})]})}function $O(e,t,n){return`${e}:${t}:${n}`}function ek(e){return{picked:Object.fromEntries((e.answers??[]).map(e=>[e.id,e.selected])),note:e.answers?.map(e=>e.note??``).join(`
|
|
339
339
|
`)??``}}function tk({question:e,index:t,expanded:n,draft:r,onDraftChange:i,onToggle:a,onAnswer:o}){return(0,L.jsxs)(`div`,{className:`call-block question-block-${e.status}`,"data-call-block":t,"data-call-tool":`question`,"data-call-detail":`提问`,"data-call-status":e.status===`answered`?`ok`:e.status===`cancelled`?`error`:`running`,"data-call-expanded":n?`true`:`false`,"data-question-block":t,children:[(0,L.jsx)(`button`,{type:`button`,className:`call-fold-edge`,"data-question-fold-edge":t,"aria-expanded":n,"aria-label":`${n?`折叠`:`展开`}提问`,title:n?`折叠这段提问`:`展开这段提问`,onClick:a}),(0,L.jsxs)(`div`,{className:`call-head-row`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`call-head`,"data-call-head":t,"aria-expanded":n,onClick:a,children:[(0,L.jsx)(`span`,{className:`call-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,L.jsx)(`span`,{className:`call-glyph`,"aria-hidden":`true`,children:e.status===`answered`?`✓`:e.status===`cancelled`?`✕`:`?`}),(0,L.jsx)(`span`,{className:`call-label`,children:`提问`}),(0,L.jsxs)(`span`,{className:`call-detail`,children:[e.items.length,` 个问题`]})]}),n&&(0,L.jsx)(`button`,{type:`button`,className:`call-fold-top`,"data-call-fold-top":t,onClick:a,children:`收起`})]}),n&&(0,L.jsx)(`div`,{className:`question-body`,"data-question-body":t,children:(0,L.jsx)(nk,{question:e,draft:r,onDraftChange:i,instanceId:`inline`,onAnswer:o})})]})}function nk({question:e,draft:t,onDraftChange:n,instanceId:r,onAnswer:i}){let{picked:a,note:o}=t,s=(e,r,i)=>{let o=(()=>{let t=a,n=t[e]??[];return i?{...t,[e]:n.includes(r)?n.filter(e=>e!==r):[...n,r]}:{...t,[e]:[r]}})();n({...t,picked:o})},c=()=>{i(e.items.map(e=>({id:e.id,selected:a[e.id]??[],...e.extraNote&&o.trim()?{note:o.trim()}:{}})),!1)},l=e.items.some(e=>(a[e.id]??[]).length>0);return(0,L.jsxs)(`div`,{className:`question-block question-${e.status}`,"data-question-status":e.status,children:[e.items.map(i=>(0,L.jsxs)(`div`,{className:`question-item`,children:[(0,L.jsx)(`div`,{className:`question-text`,children:i.header?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`question-header`,children:i.header}),(0,L.jsx)(`span`,{className:`question-sep`,children:` · `}),(0,L.jsx)(hf,{source:i.question})]}):(0,L.jsx)(hf,{source:i.question})}),(0,L.jsx)(`div`,{className:`question-options`,"data-question-options":i.id,children:i.options.map(t=>{let n=e.status!==`pending`,o=(n?e.answers?.find(e=>e.id===i.id)?.selected:a[i.id])?.includes(t)??!1;return(0,L.jsxs)(`label`,{className:o?`is-chosen`:``,"data-chosen":n&&o?`1`:void 0,children:[(0,L.jsx)(`input`,{type:i.multiple?`checkbox`:`radio`,name:`q-${r}-${i.id}`,checked:o,disabled:n,onChange:()=>s(i.id,t,i.multiple)}),(0,L.jsx)(gf,{source:t}),n&&o?(0,L.jsx)(`span`,{className:`question-mark`,"aria-label":`已选择`,children:`✓`}):null]},t)})}),e.status===`pending`&&i.extraNote?(0,L.jsx)(`textarea`,{value:o,placeholder:`补充说明(可选)`,onChange:e=>n({...t,note:e.target.value})}):e.status===`answered`&&(e.answers??[]).some(e=>e.note)?(0,L.jsxs)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:[`补充:`,(e.answers??[]).map(e=>e.note).filter(Boolean).join(`;`)]}):null,e.status===`cancelled`&&(0,L.jsx)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:`已取消,没有作答。`})]},i.id)),e.status===`pending`&&(0,L.jsxs)(`div`,{className:`question-actions`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:c,disabled:!l,children:`提交`}),(0,L.jsx)(`button`,{type:`button`,className:`question-skip`,onClick:()=>i([],!0),children:`跳过`})]})]})}function rk({question:e,pendingCount:t,minimized:n,floatingRight:r,onMinimize:i,onExpand:a,onLocate:o,draft:s,onDraftChange:c,onAnswer:l}){return n?(0,Ie.createPortal)((0,L.jsxs)(`button`,{type:`button`,className:`question-floating-ball`,style:{"--question-floating-right":r},"data-question-floating-ball":e.key,onClick:a,"aria-label":`展开待回答的问题${t>1?`,还有 ${t-1} 个待处理`:``}`,title:`展开待回答的问题`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`?`}),t>1&&(0,L.jsx)(`small`,{children:t})]}),document.body):(0,Ie.createPortal)((0,L.jsxs)(`section`,{className:`question-floating-panel`,style:{"--question-floating-right":r},"data-question-floating-panel":e.key,role:`dialog`,"aria-labelledby":`question-floating-title`,children:[(0,L.jsxs)(`header`,{className:`question-floating-head`,children:[(0,L.jsx)(`span`,{className:`question-floating-mark`,"aria-hidden":`true`,children:`?`}),(0,L.jsxs)(`h2`,{id:`question-floating-title`,children:[`需要你回答`,t>1?` · 还有 ${t-1} 个`:``]}),(0,L.jsx)(`button`,{type:`button`,className:`question-floating-minimize`,onClick:o,title:`定位到消息上下文并最小化`,children:`查看上下文`}),(0,L.jsx)(`button`,{type:`button`,className:`question-floating-minimize-icon`,onClick:i,title:`最小化为悬浮球`,"aria-label":`最小化问题`,children:`−`})]}),(0,L.jsx)(`div`,{className:`question-floating-body`,children:(0,L.jsx)(nk,{question:e.value,draft:s,onDraftChange:c,instanceId:`floating`,onAnswer:l})})]}),document.body)}function ik({request:e,onAnswer:t,pending:n}){let[r,i]=(0,u.useState)(e.prefill??``),a=e.method===`input`||e.method===`editor`,o=(0,L.jsx)(`button`,{type:`button`,className:`extui-cancel`,onClick:()=>t({cancelled:!0}),children:`取消提问`});return(0,L.jsxs)(`article`,{className:`extui-card extui-${e.method}`,"data-request-id":e.requestId,"data-method":e.method,children:[(0,L.jsxs)(`div`,{className:`extui-head`,children:[(0,L.jsx)(`span`,{className:`extui-badge`,children:`扩展提问`}),e.timeoutMs!==void 0&&(0,L.jsxs)(`span`,{className:`extui-deadline`,children:[Math.ceil(Math.max(0,e.deadlineAt===void 0?e.timeoutMs:e.deadlineAt-Date.now())/1e3),`s 超时`]})]}),n&&(0,L.jsx)(`p`,{className:`extui-pending`,role:`status`,children:`提交中…`}),(0,L.jsxs)(`fieldset`,{disabled:n,style:{border:0,padding:0,margin:0},children:[(0,L.jsx)(`h3`,{className:`extui-title`,children:e.title||vk[e.method]}),e.method===`confirm`&&(0,L.jsx)(`p`,{className:`extui-body`,children:e.message}),e.method===`select`&&(0,L.jsxs)(`div`,{className:`extui-options`,children:[(e.options??[]).map(e=>(0,L.jsx)(`button`,{type:`button`,className:`extui-option`,onClick:()=>t({value:e}),children:e},e)),(e.options??[]).length===0&&(0,L.jsx)(`p`,{className:`extui-body`,children:`扩展没有提供任何选项`})]}),a&&(0,L.jsxs)(`form`,{className:`extui-form`,onSubmit:e=>{e.preventDefault(),!n&&r.trim()&&t({value:r})},children:[e.method===`input`?(0,L.jsx)(`input`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&nO(e)&&e.preventDefault()},placeholder:e.placeholder??``}):(0,L.jsx)(`textarea`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&nO(e)&&e.preventDefault()}}),(0,L.jsxs)(`div`,{className:`extui-actions`,children:[(0,L.jsx)(`button`,{type:`submit`,className:`extui-primary`,disabled:!r.trim(),children:`提交`}),o]})]}),!a&&(0,L.jsxs)(`div`,{className:`extui-actions`,children:[e.method===`confirm`&&(0,L.jsx)(`button`,{type:`button`,className:`extui-primary`,onClick:()=>t({confirmed:!0}),children:`确认`}),e.method===`confirm`&&(0,L.jsx)(`button`,{type:`button`,className:`extui-no`,onClick:()=>t({confirmed:!1}),children:`拒绝`}),o]})]})]})}function ak({initial:e,label:t,onCommit:n,onClose:r}){let[i,a]=(0,u.useState)(e),o=(0,u.useRef)(null),s=(0,u.useRef)(!1);(0,u.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]);let c=!i.trim(),l=()=>{s.current=!0,r()},d=()=>{if(c)return;let t=i.trim();(t===e||n(t))&&l()};return(0,L.jsxs)(`div`,{className:`inline-edit`,"data-editing":`1`,children:[(0,L.jsx)(`input`,{ref:o,className:`inline-edit-input`,value:i,"aria-label":t,onChange:e=>a(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){if(nO(e))return;e.preventDefault(),d()}else e.key===`Escape`&&(e.preventDefault(),l())},onBlur:()=>{s.current||r()}}),(0,L.jsx)(`button`,{type:`button`,className:`inline-edit-ok`,title:`确认重命名`,"aria-label":`确认重命名`,disabled:c,onMouseDown:e=>e.preventDefault(),onClick:d,children:`✓`}),(0,L.jsx)(`button`,{type:`button`,className:`inline-edit-cancel`,title:`取消重命名`,"aria-label":`取消重命名`,onMouseDown:e=>e.preventDefault(),onClick:l,children:`✗`})]})}function ok({kind:e,label:t,value:n,detail:r,options:i,disabled:a,note:o,onChoose:s,scope:c,providerOptions:l}){let[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(0),[_,v]=(0,u.useState)(`*`),y=(0,u.useRef)(null),b=(0,u.useRef)(null),x=(0,u.useRef)(null),S=(0,u.useRef)(null),C=(0,u.useRef)([]),w=i.find(e=>e.selected),T=OO(l?i.filter(e=>_===`*`||e.key!==sk&&e.key.split(`/`)[0]===_):i,p),E=T.length===0?-1:Math.min(Math.max(h,0),T.length-1),D=E<0?void 0:T[E],O=(e=!1)=>{f(!1),e&&b.current?.focus()},k=()=>{m(``),v(`*`),g(Math.max(i.findIndex(e=>e.selected),0)),f(!0)},A=e=>g(t=>T.length?Math.min(Math.max(t+e,0),T.length-1):0);(0,u.useEffect)(()=>{if(!d)return;let e=e=>{y.current?.contains(e.target)||O()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[d]),(0,u.useEffect)(()=>{if(!d)return;let e=y.current,t=t=>{e?.contains(t.relatedTarget)||O()};return e?.addEventListener(`focusout`,t),()=>e?.removeEventListener(`focusout`,t)},[d]),(0,u.useEffect)(()=>{d&&S.current?.focus()},[d]),(0,u.useEffect)(()=>{d&&E>=0&&C.current[E]?.scrollIntoView({block:`nearest`})},[d,E]),(0,u.useLayoutEffect)(()=>{if(!d)return;let e=x.current;if(!e)return;e.style.setProperty(`--picker-nudge`,`0px`),e.style.setProperty(`--picker-drop`,`0px`);let t=e.getBoundingClientRect(),n=Math.min(window.innerWidth-8-t.right,Math.max(8-t.left,0)),r=Math.min(window.innerHeight-8-t.bottom,Math.max(8-t.top,0));e.style.setProperty(`--picker-nudge`,`${n}px`),e.style.setProperty(`--picker-drop`,`${r}px`)},[d,T.length,i.length]);let j=e=>{if(d){if(e.key===`Escape`)e.preventDefault(),O(!0);else if(e.key===`ArrowDown`)e.preventDefault(),A(1);else if(e.key===`ArrowUp`)e.preventDefault(),A(-1);else if(e.key===`Home`)e.preventDefault(),g(0);else if(e.key===`End`)e.preventDefault(),g(Math.max(T.length-1,0));else if(e.key===`Enter`){if(nO(e))return;e.preventDefault(),D&&(s(D.key),O(!0))}}},M=`picker-list-${c??e}`,N=t=>`picker-option-${c??e}-${t}`;return(0,L.jsxs)(`div`,{className:`session-picker-item session-picker-${e}`,ref:y,onKeyDown:d?j:void 0,children:[(0,L.jsxs)(`button`,{ref:b,type:`button`,className:`session-picker-trigger`,disabled:a,"aria-haspopup":`listbox`,"aria-expanded":d,title:o??`${bO[e]}:${r?`${t} · ${r}`:t}`,"data-picker-trigger":e,"data-picker-value":n??t,"data-picker-selected":i.some(e=>e.selected),onClick:()=>d?O():k(),children:[(0,L.jsx)(`span`,{className:`session-picker-kind`,children:bO[e]}),(0,L.jsx)(`span`,{className:`session-picker-name`,children:t}),r&&(0,L.jsx)(`span`,{className:`session-picker-detail`,children:r}),(0,L.jsx)(`span`,{className:`session-picker-caret`,"aria-hidden":`true`,children:`▾`})]}),d&&(0,L.jsxs)(`div`,{className:`picker-menu`,ref:x,"data-picker-menu":e,"data-picker-highlight":E,children:[l&&(0,L.jsxs)(`label`,{className:`picker-provider-filter`,children:[(0,L.jsx)(`span`,{children:`Provider`}),(0,L.jsxs)(`select`,{"data-picker-provider":e,"aria-label":`筛选模型 Provider`,value:_,onKeyDown:e=>e.stopPropagation(),onChange:e=>{v(e.target.value),g(0)},children:[(0,L.jsx)(`option`,{value:`*`,children:`全部 Provider`}),l.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))]})]}),(0,L.jsxs)(`div`,{className:`picker-filter`,children:[(0,L.jsx)(`span`,{className:`picker-filter-icon`,"aria-hidden":`true`,children:`🔍`}),(0,L.jsx)(`input`,{ref:S,className:`picker-filter-input`,"data-picker-filter":e,role:`combobox`,"aria-label":`筛选${SO[e]}选项`,"aria-expanded":`true`,"aria-controls":M,"aria-autocomplete":`list`,"aria-activedescendant":D?N(E):void 0,value:p,placeholder:`输入以筛选…`,autoComplete:`off`,spellCheck:!1,onChange:e=>{m(e.target.value),g(0)}}),p&&(0,L.jsx)(`button`,{type:`button`,className:`picker-filter-clear`,"data-picker-filter-clear":e,title:`清空筛选`,"aria-label":`清空筛选`,onMouseDown:e=>e.preventDefault(),onClick:()=>{m(``),g(0),S.current?.focus()},children:`✕`})]}),w&&!T.some(e=>e.key===w.key)&&(0,L.jsxs)(`div`,{className:`picker-current`,"data-picker-current":e,"data-picker-current-value":w.key,children:[(0,L.jsx)(`span`,{className:`picker-current-label`,children:`当前`}),(0,L.jsx)(`span`,{className:`picker-current-value`,children:w.label})]}),(0,L.jsxs)(`div`,{className:`picker-list`,role:`listbox`,id:M,"aria-label":wO[e],children:[T.map((e,t)=>(0,L.jsxs)(`button`,{id:N(t),type:`button`,role:`option`,"aria-selected":e.selected,ref:e=>{C.current[t]=e},className:`picker-option${e.selected?` selected`:``}${t===E&&!e.selected?` preview`:``}`,"data-picker-option":e.key,"data-picker-option-selected":e.selected,"data-picker-highlight":t===E,onClick:()=>{s(e.key),O(!0)},children:[e.color&&(0,L.jsx)(`span`,{className:`picker-option-swatch`,style:{background:e.color},"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`picker-option-name`,children:e.label}),e.badge&&(0,L.jsx)(`span`,{className:`picker-option-badge`,"data-picker-option-badge":e.badge,children:e.badge}),e.detail&&(0,L.jsx)(`span`,{className:`picker-option-detail`,children:e.detail}),e.selected&&(0,L.jsx)(`span`,{className:`picker-option-mark`,"aria-hidden":`true`,children:`✓`})]},e.key)),T.length===0&&(0,L.jsx)(`div`,{className:`picker-empty`,"data-picker-empty":e,children:i.length===0?CO[e]:`没有匹配「${p.trim()}」的${SO[e]}`})]})]})]})}var sk=`__pi_default__`;function ck({workspace:e,catalog:t,agents:n,onSave:r,onRename:i,onRemove:a,onClose:o}){let[s,c]=(0,u.useState)(e.defaultAgentId),[l,d]=(0,u.useState)(e.defaultModel),[f,p]=(0,u.useState)(e.defaultThinkingLevel);(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.defaultPrevented&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let m=t?.source===`pi`,h=[{key:sk,label:`跟随 Pi 默认`,detail:`不为新会话指定模型`,selected:l===void 0},...(t?.models??[]).map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,FD(e.contextWindow)?`${FD(e.contextWindow)} 上下文`:``,ID(e.maxTokens)?`${ID(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:EO(e),selected:l?.provider===e.provider&&l.modelId===e.modelId}))],g=t?.models.find(e=>e.provider===l?.provider&&e.modelId===l?.modelId),_=g?.thinkingLevels??t?.levels??[],v=[{key:sk,label:`跟随 Pi 默认`,detail:`不为新会话指定思考等级`,selected:f===void 0},..._.map(e=>({key:e,label:e,selected:e===f}))],y=e=>{if(e===sk){d(void 0),p(void 0);return}let n=(t?.models??[]).find(t=>t.provider===e.split(`/`)[0]&&t.modelId===e.split(`/`)[1]);if(n){let e=l?.provider!==n.provider||l.modelId!==n.modelId;d({provider:n.provider,modelId:n.modelId,label:n.label}),e&&p(void 0)}},b=e=>p(e===sk?void 0:e),x=[{key:sk,label:`跟随 Pi 默认`,detail:`新会话不使用任何 agent 角色`,selected:s===void 0},...(n?.agents??[]).map(e=>({key:e.id,label:e.name,detail:e.toolSummary,color:e.color,selected:s===e.id}))];return(0,L.jsx)(`div`,{className:`overlay`,onClick:o,children:(0,L.jsxs)(`div`,{className:`picker settings-dialog`,"data-settings-dialog":`1`,onClick:e=>e.stopPropagation(),children:[(0,L.jsx)(`h2`,{children:`工作区设置`}),(0,L.jsxs)(`div`,{className:`settings-scope`,children:[e.name,` · 默认值只影响之后新建的会话,已有会话不变`]}),(0,L.jsx)(`div`,{className:`workspace-settings-path`,children:e.path}),(0,L.jsxs)(`div`,{className:`settings-row`,children:[(0,L.jsx)(`span`,{className:`settings-label`,children:`默认智能体`}),(0,L.jsx)(ok,{kind:`agent`,scope:`settings-agent`,label:n?.agents.find(e=>e.id===s)?.name??`跟随 Pi 默认`,value:s??sk,detail:s?`${n?.agents.find(e=>e.id===s)?.toolSummary??``}`:void 0,options:x,disabled:!n||n.source===`unavailable`,note:FO(n),onChoose:e=>c(e===sk?void 0:e)})]}),(0,L.jsxs)(`div`,{className:`settings-row`,children:[(0,L.jsx)(`span`,{className:`settings-label`,children:`默认模型`}),(0,L.jsx)(ok,{kind:`model`,scope:`settings-model`,label:l?.label??`跟随 Pi 默认`,value:l?`${l.provider}/${l.modelId}`:sk,detail:l?`${l.provider}/${l.modelId}`:void 0,options:h,providerOptions:[...new Set((t?.models??[]).map(e=>e.provider))],disabled:!m,note:PO(`模型`,t),onChoose:y})]}),(0,L.jsxs)(`div`,{className:`settings-row`,children:[(0,L.jsx)(`span`,{className:`settings-label`,children:`思考强度`}),(0,L.jsx)(ok,{kind:`thinking`,scope:`settings-thinking`,label:f??`跟随 Pi 默认`,value:f??sk,options:v,disabled:!m,note:PO(`思考等级`,t),onChoose:b})]}),l&&g&&_.length===0&&(0,L.jsx)(`div`,{className:`settings-scope`,children:`Pi 未提供此模型的可选等级,使用模型默认值。`}),(0,L.jsxs)(`div`,{className:`picker-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`settings-rename`,"data-settings-rename":`1`,onClick:i,children:`重命名工作区`}),(0,L.jsx)(`button`,{type:`button`,className:`picker-cancel`,"data-settings-cancel":`1`,onClick:o,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,className:`picker-ok`,"data-settings-save":`1`,onClick:()=>r(s,l,f),children:`保存`})]}),(0,L.jsx)(`button`,{type:`button`,className:`workspace-delete`,onClick:a,children:`从列表移除工作区`})]})})}var lk=[{id:`main`,label:`任务`,name:`任务与后台任务`},{id:`projects`,label:`项目`,name:`项目控制面`},{id:`tools`,label:`工具`,name:`工具 tab`},{id:`files`,label:`文件`,name:`文件 tab`},{id:`git`,label:`Git`,name:`Git tab`},{id:`rsi`,label:`RSI`,name:`RSI 观察与改进`},{id:`terminal`,label:`终端`,name:`终端 tab`}],uk=`super-pi.right-tabs.v1`;function dk(){let e=e=>lk.some(t=>t.id===e),t={tab:lk[0].id,byConversation:{}};try{let n=JSON.parse(zn(uk)??`null`);return!n||!e(n.tab)?t:{tab:n.tab,byConversation:Object.fromEntries(Object.entries(n.byConversation??{}).filter(t=>e(t[1])))}}catch{return t}}var fk={waiting:`⋯`,running:``,failed:``,question:`?`,completed:``,unread:`•`,idle:``,awaiting_background:`⚙`,pending_report:`↑`,awaiting_subordinates:`↓`,awaiting_decision:`▲`},pk={idle:`空闲`,running:`讨论中`,awaiting_background:`后台任务进行中`,completed:`讨论已完成`,failed:`讨论未完成`},mk={waiting:`等待 LLM`,running:`进行中`,failed:`出错`,question:`等你回答`,completed:`已完成`,unread:`有未读`,idle:`空闲`,awaiting_background:`等待后台任务`,pending_report:`待汇报`,awaiting_subordinates:`等待下级`,awaiting_decision:`等上面拍板`},hk={idle:`就绪`,waiting:`等待 LLM`,running:`正在生成`,completed:`已完成`,stopped:`已停止`,failed:`运行失败`,awaiting_background:`等待后台任务`},gk=e=>e?.status===`running`||e?.status===`waiting`||e?.compaction?.status===`running`,_k={running:`运行中`,completed:`已完成`,failed:`失败`,stopped:`已停止`,cancelled:`已取消`,interrupted:`已中断`},vk={select:`请选择一项`,confirm:`请确认`,input:`请输入内容`,editor:`请输入内容`,notify:`扩展通知`,setStatus:`扩展状态`,setWidget:`扩展内容`,setTitle:`扩展标题`,set_editor_text:`扩展输入`};function yk(e,t){return t.some(t=>t.conversationId===e.id)?!0:e.messagesLoaded===!1?e.hasPendingQuestion===!0:e.messages.some(e=>(e.toolCalls??[]).some(e=>e.question?.status===`pending`))}function bk(e,t,n){let r=(t||[]).filter(t=>t.parentConversationId===e.id),i=(t||[]).find(t=>t.id===e.parentConversationId),a=n??``;return qn({conversation:e,parent:i,directChildren:r,isTopLevelUnread:e.updatedAt>a})}function xk(e,t,n,r){let i=bk(e,r,n);return Jn({status:e.status,reportingState:i,awaitingQuestion:t,quietWhenRead:!0})}function Sk(e,t){return t===`awaiting_decision`||e===`awaiting_decision`?(0,L.jsx)(`span`,{className:`conversation-status-badge badge--warning project-status-awaiting_decision`,"data-session-status":`awaiting_decision`,"data-reporting-badge":`awaiting_decision`,title:mk.awaiting_decision,children:mk.awaiting_decision}):t===`awaiting_subordinates`||e===`awaiting_subordinates`?(0,L.jsx)(`span`,{className:`conversation-status-badge project-status-awaiting_subordinates`,"data-session-status":`awaiting_subordinates`,"data-reporting-badge":`awaiting_subordinates`,title:mk.awaiting_subordinates,children:mk.awaiting_subordinates}):t===`pending_report`||e===`pending_report`?(0,L.jsx)(`span`,{className:`conversation-status-badge project-status-pending_report`,"data-session-status":`pending_report`,"data-reporting-badge":`pending_report`,title:mk.pending_report,children:mk.pending_report}):null}function Ck({state:e,label:t=mk[e]}){let n=fk[e];if(e===`idle`)return null;let r=e.replace(/_/g,`-`);return(0,L.jsx)(`i`,{className:`session-state session-state-${e} session-state-${r}`,"data-session-state":e,title:t,"aria-label":t,...e===`awaiting_background`?{style:{color:`var(--accent)`}}:{},children:(0,L.jsx)(`i`,{className:`session-state-mark`,"aria-hidden":`true`,children:n})})}function wk(e,t){return(0,L.jsxs)(L.Fragment,{children:[e.origin===`orchestrator`&&(0,L.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`orchestrator`,title:`编排会话:由上级智能体创建`,"aria-label":`编排会话:由上级智能体创建`,children:`编排`}),t&&(0,L.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`scheduled`,title:`定时任务会话:${t.name}`,"aria-label":`定时任务会话:${t.name}`,children:`定时`})]})}function Tk(e,t){let n=[];return e.origin===`orchestrator`&&n.push(`编排会话`),t&&n.push(`定时任务会话:${t.name}`),n.length?`(${n.join(`;`)})`:``}var Ek={pending:`未开始`,in_progress:`运行中`,completed:`已完成`},Dk={pending:`○`,in_progress:`◐`,completed:`✓`},Ok={high:`高`,medium:`中`,low:`低`};function kk(e){let t=e.filter(e=>e.status!==`completed`).length;return e.length?t?`${t} 个未完成 / 共 ${e.length} 个`:`全部完成:${e.length} 个`:`0 个待办任务`}function Ak({todo:e,index:t}){let n=e.id??`todo_${t}`;return(0,L.jsxs)(`li`,{className:`todo-item todo-${e.status}`,"data-todo-item":n,"data-todo-status":e.status,title:`状态:${Ek[e.status]}`,children:[(0,L.jsx)(`span`,{className:`todo-mark`,"aria-hidden":`true`,children:Dk[e.status]}),(0,L.jsx)(`span`,{className:`todo-text`,children:e.content}),(0,L.jsx)(`span`,{className:`todo-status`,"data-todo-status-text":`1`,children:Ek[e.status]}),e.priority&&(0,L.jsx)(`span`,{className:`todo-priority`,"data-todo-priority":e.priority,children:Ok[e.priority]})]})}function jk(e,t){if(!e)return[];let n=t.filter(t=>t.conversationId===e.id&&t.status===`running`),r=new Set(n.map(e=>e.id));for(let t of e.messages)t.toolCalls?.forEach((i,a)=>{let o=i.backgroundTask;o&&o.status===`running`&&!r.has(o.id)&&(r.add(o.id),n.push({id:o.id,conversationId:e.id,title:i.detail?.trim()||i.label?.trim()||o.id,status:o.status,originMessageId:t.id,originCallRow:a}))});return n}function Mk({tasks:e,runs:t,execOutputs:n,onStop:r}){return(0,L.jsx)(`ul`,{className:`bg-list`,"data-bg-task-count":e.length,children:e.map((e,i)=>{let a=e.id||`bg_${i}`,o=e.status?.trim()||``,s=o?_k[o]??(/[\u3400-\u9fff]/.test(o)?o:`未知状态`):`未知状态`;return(0,L.jsx)(Nk,{task:e,status:s,run:t?.get(e.id),execOutputs:n,onStop:r},a)})})}function Nk({task:e,status:t,run:n,execOutputs:r,onStop:i}){let[a,o]=(0,u.useState)(!1),s=BO(e.id,r),c=n?BD(n):s?.text||e.output,l=c&&zD(c),d=n?n.outputTruncated||n.toolCalls?.some(e=>e.outputTruncated):s?.truncated??e.outputTruncated;return(0,L.jsxs)(`li`,{className:`bg-item${a?` bg-item-expanded`:``}`,"data-bg-task":e.id,"data-bg-task-status":e.status??`unknown`,title:`状态:${t}`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`bg-item-toggle`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-label":`展开后台任务详情`,children:[(0,L.jsx)(`span`,{className:`bg-title`,children:e.title?.trim()||e.id||`未命名任务`}),(0,L.jsxs)(`span`,{className:`bg-meta`,children:[e.agentId?.trim()&&(0,L.jsx)(`span`,{className:`bg-agent`,"data-bg-agent":e.agentId,children:e.agentId}),(0,L.jsx)(`span`,{className:`bg-status`,children:t})]})]}),i&&(0,L.jsx)(`button`,{type:`button`,className:`bg-stop-btn`,"data-bg-task-stop":e.id,title:`终止后台任务`,onClick:()=>i(e.id),children:`终止`}),a&&(0,L.jsx)(`pre`,{className:`bg-output`,"data-bg-output":e.id,children:[d?`日志仅保留最近一段。`:``,l].filter(Boolean).join(`
|
|
340
340
|
|
|
341
|
-
`)||`运行中,暂无输出`})]})}var Pk=(0,u.lazy)(()=>Cn(()=>import(`./GitDiffEditor-
|
|
341
|
+
`)||`运行中,暂无输出`})]})}var Pk=(0,u.lazy)(()=>Cn(()=>import(`./GitDiffEditor-CgWWgUsi.js`),__vite__mapDeps([23,1,2,3,4,0,21,22,24])));function Fk({todos:e,tasks:t,backgroundRuns:n,execOutputs:r,scheduledTasks:i,scheduledCatalog:a,scheduledAgents:o,collapsed:s,onToggle:c,workspaceId:l,gitWorkspaceId:u=l,gitRepositoryOnly:d=!1,workspaceLabel:f,workspaceName:p,gitWorkspaceName:m=p,cwd:h=``,conversationId:g,followedWorktreeId:_,connected:v,files:y,onOpenFile:b,onOpenChanged:x,onOpenGitDiff:S,activeGitDiffUrl:C,onFileReference:w,onFilesMoved:T,onSearchFolder:E,activeTab:D,onSelectTab:O,sendCommand:k,registerTerminalSink:A,terminalShell:j,terminalFocusRequest:M,notify:N,serverTimeZone:P,onOpenSession:F,side:ee,onArrange:te,pinned:ne=!0,sharedGit:re,rsiContext:ie,rsiCatalog:ae}){let oe=lk,se=ee===`left`;return(0,L.jsx)(`div`,{className:`right-rail${ee?` workbench-panel workbench-panel-`+ee:``}${s?` right-rail-collapsed`:``}`,role:`complementary`,"aria-label":se?`左侧栏`:`右侧栏`,"data-right-rail":se?void 0:`1`,"data-right-rail-collapsed":s,"data-workbench-panel":ee,hidden:ee&&s?!0:void 0,children:s?!ee&&(0,L.jsx)(`button`,{type:`button`,className:`right-rail-open`,"data-right-rail-open":`1`,title:`展开右侧栏`,"aria-label":`展开右侧栏`,onClick:c,children:`‹`}):(0,L.jsxs)(L.Fragment,{children:[ee?(0,L.jsxs)(`div`,{className:`workbench-panel-heading`,children:[(0,L.jsx)(`h2`,{children:Vr[D]}),te&&(0,L.jsx)($r,{view:D,side:ee,pinned:ne,onArrange:te}),(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-right-rail-collapse":se?void 0:`1`,title:se?`收起左侧栏`:`收起右侧栏`,"aria-label":D===`rsi`?`关闭 RSI 面板`:se?`收起左侧栏`:`收起右侧栏`,onClick:c,children:(0,L.jsx)(Xr,{name:`close`})})]}):(0,L.jsxs)(`div`,{className:`right-rail-head`,children:[(0,L.jsx)(`div`,{className:`right-tabs`,role:`tablist`,"aria-label":`右侧栏 tab`,"data-right-tab-count":oe.length,children:oe.map(e=>(0,L.jsx)(`button`,{type:`button`,role:`tab`,id:`right-tab-${e.id}`,className:`right-tab${e.id===D?` right-tab-active`:``}`,"data-right-tab":e.id,"aria-selected":e.id===D,"aria-controls":`right-panel-${e.id}`,title:e.name,"aria-label":e.name,onClick:()=>O(e.id),children:e.label},e.id))}),(0,L.jsx)(`button`,{type:`button`,className:`right-rail-collapse`,"data-right-rail-collapse":`1`,title:`收起右侧栏(聊天区会变宽)`,"aria-label":D===`rsi`?`关闭 RSI 面板`:`收起右侧栏`,onClick:c,children:`›`})]}),lk.filter(e=>e.id===D).map(s=>(0,L.jsxs)(`div`,{className:`right-rail-body`,role:`tabpanel`,id:`right-panel-${s.id}`,"aria-label":ee?Vr[s.id]:void 0,"aria-labelledby":ee?void 0:`right-tab-${s.id}`,"data-right-panel":s.id,children:[s.id===`main`&&(0,L.jsxs)(L.Fragment,{children:[(e.length>0||t.length>0)&&(0,L.jsxs)(`p`,{className:`rail-legend`,"data-rail-legend":`1`,children:[(0,L.jsx)(`span`,{className:`rail-legend-label`,children:`左侧竖条=状态`}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-pending`,"aria-hidden":`true`}),`未开始`]}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-running`,"aria-hidden":`true`}),`运行中`]}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-done`,"aria-hidden":`true`}),`已完成`]})]}),(0,L.jsxs)(`div`,{className:`rail-task-sections`,children:[(0,L.jsx)(Gw,{id:`todos`,title:`待办任务`,icon:`tasks`,count:(0,L.jsx)(`span`,{"data-todo-summary":`1`,children:kk(e)}),children:e.length>0?(0,L.jsx)(`ol`,{className:`todo-list`,"data-todo-count":e.length,children:e.map((e,t)=>(0,L.jsx)(Ak,{todo:e,index:t},e.id??`todo_${t}`))}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-todo-empty":`1`,children:`暂无待办任务。开始多步骤任务后会自动显示。`})}),(0,L.jsx)(Gw,{id:`background`,title:`后台任务`,icon:`activity`,count:(0,L.jsx)(`span`,{"data-bg-summary":`1`,children:t.length?`${t.filter(e=>e.status===`running`).length} 个运行中 / 共 ${t.length} 个`:`0 个`}),children:t.length>0?(0,L.jsx)(Mk,{tasks:t,runs:n,execOutputs:r,onStop:e=>k({type:`backgroundTask.stop`,taskId:e})}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-bg-empty":`1`,children:`当前没有正在运行的后台任务。`})}),(0,L.jsx)(aT,{tasks:i,workspaceId:l,catalog:a,agents:o,sendCommand:k,notify:N,serverTimeZone:P})]})]}),s.id===`projects`&&(0,L.jsx)(WT,{workspaceId:l,notify:N,onOpenSession:F,onOpenFile:b,cwd:h},l),s.id===`rsi`&&(0,L.jsx)(QD,{context:ie,models:ae?.models??[],onClose:c}),s.id===`tools`&&(0,L.jsx)(Ik,{workspaceId:l},l),s.id===`files`&&(0,L.jsx)(Gm,{workspaceId:l,workspaceName:p,cwd:h,files:y,onOpenFile:b,onOpenChanged:x,onReference:w,onMoved:T,onSearchFolder:E}),s.id===`git`&&(0,L.jsx)(qi,{repositoryOnly:d,workspaceId:u??null,conversationId:g,cwd:u===l?h:``,followedWorktreeId:_,onOpenDiff:e=>S({...e,comparison:m?`${m} · ${e.comparison}`:e.comparison}),activeDiffUrl:C,onOpenConversation:F,sharedGit:re},JSON.stringify([u,h,g,d])),s.id===`terminal`&&(0,L.jsx)(Ww,{workspaceId:l,workspaceLabel:f,cwd:h,conversationId:g,connected:v,sendCommand:k,registerSink:A,terminalShell:j,focusRequest:M},JSON.stringify([l,g]))]},s.id))]})})}function Ik({workspaceId:e}){let{tools:t,mountedTools:n,openToolId:r,shortcuts:i}=hD(),[a,o]=(0,u.useState)(),s=async e=>{o(void 0);let t=await vD(e);t&&o(`移除工具失败:${Nr(t)}`)},c=(e,t)=>t?`打开${e}(快捷键 ${HE(t)})`:`打开${e}`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`rail-section-head`,children:[(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`工具`}),(0,L.jsxs)(`span`,{className:`rail-section-count`,"data-tool-summary":`1`,children:[t.length+n.length,` 个`]})]}),t.length+n.length>0?(0,L.jsxs)(`ul`,{className:`tool-grid`,"data-tool-count":t.length+n.length,children:[t.map(e=>(0,L.jsxs)(`li`,{className:`tool-slot`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`tool-icon`,"data-tool-icon":e.id,"data-tool-kind":e.kind,"data-tool-state":r===e.id?`open`:`idle`,title:c(e.name,i[e.id]),"aria-label":c(e.name,i[e.id]),"aria-current":r===e.id?`true`:void 0,onClick:()=>gD.toggleTool(e.id),children:[(0,L.jsx)(bE,{className:`tool-icon-glyph`,glyph:e.glyph}),(0,L.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,L.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${HE(i[e.id])}`,children:UE(i[e.id])}),e.kind===`link`&&(0,L.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>gD.removeTool(e.id),children:`✕`})]},e.id)),n.map(e=>(0,L.jsxs)(`li`,{className:`tool-slot`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`tool-icon`,"data-mounted-tool-icon":e.id,"data-tool-state":r===e.id?`open`:`idle`,title:c(e.name,i[e.id]),"aria-label":c(e.name,i[e.id]),onClick:()=>gD.toggleTool(e.id),children:[(0,L.jsx)(bE,{className:`tool-icon-glyph`,glyph:SE(e)}),(0,L.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,L.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${HE(i[e.id])}`,children:UE(i[e.id])}),(0,L.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>void s(e.id),children:`✕`})]},e.id))]}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-tool-empty":`1`,children:`还没有工具。点下面的「工具设置」添加。`}),(0,L.jsx)(`button`,{type:`button`,className:`tools-settings-btn`,"data-tool-settings-trigger":`1`,title:`添加预置工具、网址工具、快捷键与说明`,"aria-label":`打开工具设置`,onClick:()=>gD.openSettings(),children:`⚙ 工具设置`}),a&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-error":`1`,children:a})]})}function Lk({onClose:e}){let{tools:t,mountedTools:n,shortcuts:r}=hD(),[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(),[h,g]=(0,u.useState)(),[_,v]=(0,u.useState)(),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(),[C,w]=(0,u.useState)(),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(),[k,A]=(0,u.useState)(),j=(0,u.useRef)(null),M=(0,u.useRef)(null),[N,P]=(0,u.useState)(),[F,ee]=(0,u.useState)(),te=(0,u.useRef)(null),[ne,re]=(0,u.useState)(()=>{let e=oD();return!e||typeof window>`u`?e:cD(e,window.innerWidth,window.innerHeight)}),ie=async()=>{let e=await ai(`请为 Super Pi 开发一个全局右侧栏工具。不要启动独立 HTTP 服务器,也不要监听端口。
|
|
342
342
|
|
|
343
343
|
工具不属于当前 workspace;通过内置 tool_register 一次性提交完整文件(index.html、JS/CSS,必要时 .py),并用 glyph 提供一个易辨识的短图标(1 至 4 个字符,例如 {}、∑、◷),Super Pi 会保存为全局工具并自动出现在每个 workspace 的工具 Tab。
|
|
344
344
|
|