@evandu/super-pi 0.1.253 → 0.1.254
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/client/.super-pi-client-sources.json +3 -3
- package/dist/client/assets/{CodeMirrorEditor-DnjDYGwz.js → CodeMirrorEditor-DdxPcLjw.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-O0JZcWkA.js → GitDiffEditor-CNCMPKVv.js} +3 -3
- package/dist/client/assets/{index-Cxt9aePy.js → index-WcUajwk6.js} +3 -3
- package/dist/client/index.html +1 -1
- package/dist/server/http-server.js +36 -5
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D978o95T.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-B3-a6uF0.js","assets/CodeMirrorEditor-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D978o95T.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-B3-a6uF0.js","assets/CodeMirrorEditor-DdxPcLjw.js","assets/GitDiffEditor-CNCMPKVv.js","assets/dist-Cus6_oaF.js","assets/GitDiffEditor-CpoDDQrA.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 ee(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,ee(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,`$&/`)+`/`),ee(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+=ee(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+=ee(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ee(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 P(e,t,n){if(e==null)return e;var r=[],i=0;return ee(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function te(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 ne=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 re(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,ne)}catch(e){ne(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ie(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 re(ie.bind(null,e))}var F={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(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=F,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=ie,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:te}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=re,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`),ee=Symbol.for(`react.consumer`),P=Symbol.for(`react.context`),te=Symbol.for(`react.forward_ref`),ne=Symbol.for(`react.suspense`),re=Symbol.for(`react.suspense_list`),ie=Symbol.for(`react.memo`),F=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 ne:return`Suspense`;case re:return`SuspenseList`;case ae:return`Activity`;case ce:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case P:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case te:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ie:return t=e.displayName||null,t===null?pe(e.type)||`Memo`:t;case F: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),L=ye(null),we=ye(null);function Te(e,t){switch(xe(L,t),xe(Ce,e),xe(Se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?fp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=fp(t),e=pp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}be(Se),xe(Se,e)}function Ee(){be(Se),be(Ce),be(L)}function De(e){var t=e.memoizedState;t!==null&&(lh._currentValue=t.memoizedState,xe(we,e)),t=Se.current;var n=pp(t,e.type);t!==n&&(xe(Ce,e),xe(Se,n))}function Oe(e){Ce.current===e&&(be(Se),be(Ce)),we.current===e&&(be(we),lh._currentValue=ge)}var ke,Ae;function je(e){if(ke===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ke=t&&t[1]||``,Ae=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ke+e+Ae}var Me=!1;function Ne(e,t){if(!e||Me)return``;Me=!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(`
|
|
@@ -283,7 +283,7 @@ ${h}.`);break;case m:switch(t){case`xml`:break;case``:e.fail(`the default namesp
|
|
|
283
283
|
`&&(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 Jl({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?Kl(r,e,t,f,i):Gl(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 fetch(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?ql(a,/\.tsv$/i.test(n)?` `:`,`):void 0,[i,a,n,m]);return(0,P.jsxs)(`section`,{className:`workspace-file-preview`,"aria-label":`预览 ${r}`,"data-workspace-file-preview":i,"data-file-readonly":f?`1`:void 0,children:[(0,P.jsxs)(`div`,{className:`workspace-file-preview-head`,children:[d,(0,P.jsxs)(`div`,{className:`workspace-file-preview-actions`,children:[f&&(0,P.jsx)(`span`,{children:`外部文件 · 只读`}),f&&p&&(0,P.jsx)(`button`,{type:`button`,onClick:p,children:`重新读取`}),o&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),children:m?`查看表格`:f?`查看原文`:`编辑原文`}),(0,P.jsxs)(`a`,{href:S,download:r,children:[(0,P.jsx)(Vl,{name:`download`}),`下载`]})]})]}),l&&!m&&(0,P.jsx)(`p`,{role:`status`,children:o?`磁盘上的文件已变化,请打开原文查看。`:`磁盘上的文件已移走或无法读取。`}),m?o:v?(0,P.jsx)(`p`,{role:`status`,children:`预览无法打开,可以下载文件。`}):(0,P.jsxs)(P.Fragment,{children:[i===`download`&&(0,P.jsx)(`p`,{children:`此文件可以下载。`}),i===`image`&&(0,P.jsx)(`img`,{src:x,alt:r,onError:()=>y(!0)}),i===`pdf`&&(0,P.jsx)(`iframe`,{src:x,title:r}),i===`audio`&&(0,P.jsx)(`audio`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`video`&&(0,P.jsx)(`video`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`document`&&(g?.error?(0,P.jsx)(`p`,{role:`alert`,children:g.error}):g?(0,P.jsxs)(P.Fragment,{children:[g.warnings?.map(e=>(0,P.jsx)(`p`,{children:e},e)),(0,P.jsx)(`pre`,{children:g.text||`此文档没有可显示的文字。`})]}):(0,P.jsx)(`p`,{children:`正在读取文档…`})),w&&(w.rows.length?(0,P.jsx)(`div`,{className:`workspace-file-table`,children:(0,P.jsx)(`table`,{children:(0,P.jsx)(`tbody`,{children:w.rows.map((e,t)=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{scope:`row`,children:t+1}),e.map((e,t)=>(0,P.jsx)(`td`,{children:e},t))]},t))})})}):(0,P.jsx)(`p`,{children:`文件为空。`})),w?.clipped&&(0,P.jsx)(`p`,{className:`workspace-file-preview-limit`,children:`表格超出预览范围。完整内容可在原文中查看。`})]})]})}var Yl={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 Xl(e){return/\.([^./]+)$/.exec(e)?.[1].toLowerCase()??``}function Zl(e){let t=Xl(e);return Object.hasOwn(Yl,t)?Yl[t]:void 0}function Ql(e){let t=Zl(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`}var $l=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`))),eu=(e,t)=>!t||e===t||e.startsWith(`${t}/`),tu=e=>e.split(`/`).at(-1)??e;function nu(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 ru({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,P.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,P.jsxs)(`div`,{className:`file-explorer-dialog-body`,children:[(0,P.jsx)(`h2`,{children:e}),n]})})}function iu({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,P.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,P.jsxs)(`div`,{className:`file-inline-row`,children:[(0,P.jsx)(ae,{path:e.path,category:e.directory?`folder`:void 0}),(0,P.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,P.jsx)(`button`,{className:`explorer-icon-button`,type:`submit`,title:t,"aria-label":t,disabled:r,children:(0,P.jsx)(Vl,{name:`right`})}),(0,P.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,onClick:s,disabled:r,title:`取消`,"aria-label":`取消`,children:(0,P.jsx)(Vl,{name:`close`})})]}),i&&(0,P.jsx)(`p`,{className:`file-inline-error`,role:`alert`,children:i})]})}function au({files:e,source:t,scopeName:n}){let[r,i]=(0,u.useState)($l(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&&eu(e.path,t.path))):[];return(0,P.jsxs)(`div`,{className:`file-move-picker`,children:[(0,P.jsx)(`input`,{type:`hidden`,name:`parent`,value:r}),(0,P.jsxs)(`div`,{className:`file-move-location`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:!r,"aria-label":`上一级`,onClick:()=>i($l(r)),children:`↑`}),(0,P.jsx)(`span`,{title:r||n,children:r||n})]}),(0,P.jsx)(`ul`,{"aria-label":`目标文件夹`,children:s.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),children:[(0,P.jsx)(ae,{category:`folder`}),(0,P.jsx)(`span`,{children:e.name}),(0,P.jsx)(Vl,{name:`right`})]})},e.path))}),!s.length&&(0,P.jsx)(`p`,{children:a?`error`in a?a.error.message:`此处没有子文件夹。`:`正在读取文件夹…`})]})}function ou({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)=>Gl(t,e??``,n,r,i);async function E(e,t){let n=await fetch(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)eu(e.path,s.path)&&!e.dirty&&r.closeFile(e.path);r.locatePath($l(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:tu(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])=>eu(e,n.path)&&t.state===`saving`)){v(`文件正在保存,等保存结束后再操作。`);return}if(t===`trash`&&r.open.some(e=>e.dirty&&eu(e.path,n.path))){v(`这里有未保存的草稿,请先保存。`);return}let i=new FormData(e.currentTarget),a=String(i.get(`name`)??tu(n.path));if(t===`move`&&!n.directory&&Xl(n.path)!==Xl(a)&&r.open.some(e=>e.path===n.path&&e.dirty)){v(`更换文件扩展名之前,请先保存草稿。`);return}let o=String(i.get(`parent`)??(t===`move`?$l(n.path):n.path));d.move&&o===$l(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 ee(e){S.current=e,O(!0),x.current?.click()}async function te(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 ne(e,t){l(void 0),a?.(e||`.`,t)}function re(e){O(!0),dl(e||`.`).then(t=>r.setNotice(t?`已复制相对路径。`:`相对路径:${e||`.`}`))}let ie=d?.action===`create-file`?`新建文件`:d?.action===`create-directory`?`新建文件夹`:d?.action===`trash`?`移到回收站`:d?.move?`移动到文件夹`:`重命名`,F={path:``,directory:!0},ae=d?.action===`create-file`||d?.action===`create-directory`,oe=d?.action===`move`&&!d.move,se=(e,t,n)=>!d||d.target.path!==e||(t===`child`?!ae:!oe)?null:(0,P.jsx)(iu,{target:{...d.target,directory:ae?d.action===`create-directory`:d.target.directory},label:ie,initial:oe?tu(e):``,busy:h,error:_,depth:n,submit:M,close:A},`${d.action}:${e}`),ce=(e,t)=>{h||e.linked||e.directory&&eu(t,e.path)||t===$l(e.path)||(Object.entries(r.saves).some(([t,n])=>eu(t,e.path)&&n.state===`saving`)?r.setNotice(`文件正在保存,等保存结束后再移动。`):j({action:`move`,path:e.path,parent:t,name:tu(e.path)}))},le=(0,P.jsxs)(`div`,{className:`file-explorer-toolbar`,role:`group`,"aria-label":`文件操作`,children:[(0,P.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-file`,title:`新建文件`,"aria-label":`新建文件`,onClick:e=>k(`create-file`,F,!1,e.currentTarget),disabled:!e||h,children:(0,P.jsx)(Vl,{name:`file`})}),(0,P.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-directory`,title:`新建文件夹`,"aria-label":`新建文件夹`,onClick:e=>k(`create-directory`,F,!1,e.currentTarget),disabled:!e||h,children:(0,P.jsx)(Vl,{name:`folder`})}),(0,P.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-refresh":`1`,title:`刷新目录`,"aria-label":`刷新目录`,onClick:r.refreshTree,disabled:!e,children:(0,P.jsx)(Vl,{name:`refresh`})}),(0,P.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,P.jsx)(Vl,{name:`collapse`})}),(0,P.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`root-menu`,"aria-haspopup":`menu`,"aria-expanded":c?.target.path===``,onClick:e=>D(F,Hl(e.currentTarget)),title:`更多文件操作`,"aria-label":`更多文件操作`,disabled:!e||h,children:(0,P.jsx)(Vl,{name:`more`})})]}),ue=(e,t,n,r,i)=>(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`file-context-item`,"data-explorer-command":r,onClick:n,children:[(0,P.jsx)(Vl,{name:t}),(0,P.jsx)(`span`,{children:e}),i&&(0,P.jsx)(`kbd`,{children:i})]});return{controls:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`input`,{ref:x,type:`file`,multiple:!0,hidden:!0,"aria-label":`上传工作区文件`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,te(S.current,t)}}),c&&(0,P.jsxs)(Ul,{label:c.target.path||t,anchor:c.anchor,close:O,children:[c.target.directory&&!c.target.linked&&(0,P.jsxs)(P.Fragment,{children:[s&&ue(`在此文件夹中搜索`,`search`,()=>{let e=c.target.path;O(!1),s(e)},`search-folder`),ue(`新建文件`,`file`,()=>k(`create-file`,c.target),`new-file`),ue(`新建文件夹`,`folder`,()=>k(`create-directory`,c.target),`new-directory`),ue(`上传到此处`,`upload`,()=>ee(c.target.path),`upload`),(0,P.jsx)(`div`,{role:`separator`})]}),c.target.path&&!c.target.linked&&(0,P.jsxs)(P.Fragment,{children:[ue(`重命名`,`rename`,()=>k(`move`,c.target),`rename`,`F2`),ue(`移动到文件夹`,`move`,()=>k(`move`,c.target,!0),`move`),(0,P.jsx)(`div`,{role:`separator`})]}),!c.target.linked&&a&&ue(`引用到会话`,`reference`,()=>ne(c.target.path,c.target.directory),`reference`),ue(`复制相对路径`,`copy`,()=>re(c.target.path)),!c.target.directory&&!c.target.linked&&(0,P.jsxs)(`a`,{role:`menuitem`,tabIndex:-1,className:`file-context-item`,href:T(`asset`,c.target.path,{download:`1`}),download:tu(c.target.path),onClick:()=>O(!0),children:[(0,P.jsx)(Vl,{name:`download`}),(0,P.jsx)(`span`,{children:`下载`})]}),!c.target.path&&ue(`打开回收站`,`trash`,()=>void N(),`trash-list`),!!c.target.path&&!c.target.linked&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{role:`separator`}),ue(`移到回收站`,`trash`,()=>k(`trash`,c.target),`trash`,`Delete`)]})]}),d&&!ae&&!oe&&(0,P.jsx)(ru,{title:ie,cancel:()=>{h||A()},children:(0,P.jsxs)(`form`,{onSubmit:M,className:`file-explorer-form`,children:[d.action===`trash`?(0,P.jsxs)(`p`,{children:[`将「`,d.target.path,`」移到回收站?`]}):(0,P.jsx)(au,{files:r,source:d.target,scopeName:t}),_&&(0,P.jsx)(`p`,{role:`alert`,children:_}),(0,P.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,P.jsx)(`button`,{type:`button`,disabled:h,onClick:A,children:`取消`}),(0,P.jsx)(`button`,{type:`submit`,disabled:h,children:d.move?`移动到此处`:ie})]})]})}),p&&(0,P.jsxs)(ru,{title:`回收站`,cancel:()=>{h||m(void 0)},children:[_&&(0,P.jsx)(`p`,{role:`alert`,children:_}),p.length?(0,P.jsx)(`ul`,{className:`file-explorer-trash`,children:p.map(e=>(0,P.jsxs)(`li`,{children:[(0,P.jsx)(`span`,{children:e.path}),(0,P.jsx)(`button`,{type:`button`,"data-explorer-restore":e.path,disabled:h,onClick:()=>void j({action:`restore`,id:e.id}),children:`还原`})]},e.id))}):(0,P.jsx)(`p`,{children:`回收站为空。`}),(0,P.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>m(void 0),children:`关闭`})]}),y&&(0,P.jsxs)(ru,{title:`同名文件`,cancel:()=>b(void 0),children:[(0,P.jsx)(`p`,{children:`以下文件已经存在。替换前会再次检查磁盘版本。`}),(0,P.jsx)(`ul`,{children:y.items.map(e=>(0,P.jsx)(`li`,{children:e.file.name},e.file.name))}),(0,P.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>{r.setNotice(`已跳过 ${y.items.length} 个同名文件。`),b(void 0)},children:`跳过`}),(0,P.jsx)(`button`,{type:`button`,"data-file-replace-upload":`1`,onClick:()=>void te(y.parent,y.items.map(e=>e.file),y.items),children:`替换`})]})]})]}),toolbar:le,inline:se,editing:ae||oe,busy:h,openMenu:D,showAction:k,upload:te,moveTo:ce}}var su=[{id:`path`,label:`文件名 / 路径`,shortcut:`Ctrl+P`},{id:`content`,label:`文件内容`,shortcut:`Ctrl+Shift+F`},{id:`session`,label:`会话消息`}];function cu({mode:e,query:t,onClose:n,onMode:r,children:i}){return(0,P.jsx)(`div`,{className:`quick-open-backdrop`,...e===`path`?{"data-quick-open":`1`}:e===`content`?{"data-content-search":`1`}:{"data-session-search":`1`},role:`presentation`,onMouseDown:n,children:(0,P.jsxs)(`div`,{className:e===`path`?`quick-open`:`quick-open content-search`,role:`dialog`,"aria-modal":`true`,"aria-label":su.find(t=>t.id===e)?.label,onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&(e.preventDefault(),n())},children:[(0,P.jsx)(`div`,{className:`workbench-search-modes`,role:`group`,"aria-label":`搜索范围`,children:su.map(n=>(0,P.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))}),i]})})}function lu({workspaceId:e,initialQuery:t=``,onClose:n,onMode:r,onOpen:i}){let[a,o]=(0,u.useState)(t),[s,c]=(0,u.useState)(),[l,d]=(0,u.useState)(``),[f,p]=(0,u.useState)(0),[m,h]=(0,u.useState)(!1),g=(0,u.useRef)(null),_=(0,u.useRef)(null);return(0,u.useEffect)(()=>{g.current?.focus()},[]),(0,u.useEffect)(()=>{_.current?.scrollIntoView({block:`nearest`})},[f]),(0,u.useEffect)(()=>{let t=a.trim();if(c(void 0),p(0),d(``),h(!1),!e||!t)return;if(t.length>256){d(`搜索词不能超过 256 个字符。`);return}let n=new AbortController;h(!0);let r=setTimeout(()=>{let r=new URLSearchParams({workspaceId:e,q:t});fetch(`/api/session-search?${r}`,{signal:n.signal}).then(async e=>{if(!e.ok)throw Error(`会话搜索没有完成。`);return await e.json()}).then(e=>{n.signal.aborted||c(e)}).catch(e=>{n.signal.aborted||d(j(e,`会话搜索没有完成。`))}).finally(()=>{n.signal.aborted||h(!1)})},180);return()=>{clearTimeout(r),n.abort()}},[a,e]),(0,P.jsxs)(cu,{mode:`session`,query:a,onMode:r,onClose:n,children:[(0,P.jsx)(`input`,{ref:g,className:`quick-open-input`,"data-session-search-input":!0,value:a,"aria-label":`搜索会话消息`,placeholder:`输入要在会话消息中查找的文字`,onChange:e=>o(e.target.value),onKeyDown:e=>{if(!e.nativeEvent.isComposing&&(e.key===`ArrowDown`&&(e.preventDefault(),p(e=>Math.min(e+1,Math.max(0,(s?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),p(e=>Math.max(0,e-1))),e.key===`Enter`)){e.preventDefault();let t=s?.hits[f];t&&i(t)}}}),(0,P.jsx)(`p`,{className:`quick-open-status`,role:`status`,"data-session-search-status":!0,children:l||(m?`搜索中…`:e?s?s.truncated?`显示前 60 条命中`:`${s.hits.length} 条命中`:`当前工作区的未归档会话 · 用户和 Agent 消息`:`请选择工作区`)}),(0,P.jsx)(`ul`,{className:`quick-open-results content-search-results`,"aria-label":`会话搜索结果`,children:s?.hits.map((e,t)=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{ref:t===f?_:void 0,type:`button`,"data-session-search-result":e.messageId,className:`quick-open-result content-search-result${f===t?` quick-open-result-active`:``}`,onMouseEnter:()=>p(t),onClick:()=>i(e),children:[(0,P.jsxs)(`span`,{children:[e.title,` · `,e.role===`user`?`用户`:`Agent`]}),(0,P.jsxs)(`small`,{children:[e.before,(0,P.jsx)(`mark`,{children:e.match}),e.after]})]})},`${e.conversationId}:${e.messageId}`))})]})}var uu=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,P.jsxs)(`div`,{className:`error-boundary-card`,"data-error-boundary":`1`,children:[(0,P.jsxs)(`div`,{className:`error-boundary-head`,children:[(0,P.jsx)(`span`,{className:`error-boundary-icon`,"aria-hidden":`true`,children:`⚠️`}),(0,P.jsx)(`strong`,{children:`视图渲染遇到异常`})]}),(0,P.jsx)(`p`,{className:`error-boundary-msg`,children:e.message||`未知组件错误`}),(0,P.jsx)(`button`,{type:`button`,className:`error-boundary-retry`,onClick:this.reset,children:`重试`})]}):this.props.children}};function du(){}du.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(fu(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 fu(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 du;var pu=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,mu=/\S/,hu=new du;hu.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!mu.test(e)&&!mu.test(t)},hu.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]&&pu.test(t[n])&&pu.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var gu=new du;gu.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
284
284
|
`));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 _u(e,t,n){return gu.diff(e,t,n)}var vu=new du;vu.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var yu=new du;yu.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function bu(e){"@babel/helpers - typeof";return bu=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},bu(e)}var xu=Object.prototype.toString,Su=new du;Su.useLongestToken=!0,Su.tokenize=gu.tokenize,Su.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(Cu(e,null,null,i),i,` `)},Su.equals=function(e,t){return du.prototype.equals.call(Su,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function Cu(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(xu.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Cu(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),bu(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]=Cu(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var wu=new du;wu.tokenize=function(e){return e.slice()},wu.join=wu.removeEmpty=function(e){return e};function Tu(e,t){let n=_u(e??``,t??``),r=[],i=0,a=0,o=1,s=1;for(let e of n){let t=e.value.split(`
|
|
285
285
|
`),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 Eu(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 Du=`super-pi.outbox.v1.`,Ou=e=>Du+JSON.stringify([e.conversationId,e.clientId]);function ku(){try{let e=[];for(let t of Object.keys(window.localStorage).filter(e=>e.startsWith(Du)))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===Ou(r)&&e.push(n)}catch{}return e.sort((e,t)=>e.queuedAt-t.queuedAt).map(e=>e.send)}catch{return[]}}function Au(e){try{return window.localStorage.setItem(Ou(e),JSON.stringify({queuedAt:Date.now(),send:e})),!0}catch{return!1}}function ju(e,t){try{window.localStorage.removeItem(Ou({conversationId:e,clientId:t}))}catch{}}function Mu(e,t,n){let r=e.conversations.find(e=>e.id===t.conversationId);if(!r||r.messages.some(e=>e.id===t.clientId))return e;let i=r.status===`running`||r.status===`waiting`;return{...e,conversations:e.conversations.map(e=>e===r?{...e,...i?{}:{status:`waiting`,updatedAt:n},messages:[...e.messages,{id:t.clientId,role:`user`,content:t.content,createdAt:n,...t.images?.length?{images:t.images}:{},...t.attachments?.length?{attachments:t.attachments}:{},...i?{delivery:`waiting`}:{}}]}:e)}}function Nu(e,t){try{return JSON.parse(window.sessionStorage.getItem(e)??`null`)??t}catch{return t}}function Pu(e,t){try{return window.sessionStorage.setItem(e,JSON.stringify(t)),!0}catch{return!1}}var Fu=`modulepreload`,Iu=function(e){return`/`+e},Lu={},Ru=function(e){return e.pathname.endsWith(`.css`)},zu=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},Bu=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=Iu(t,n);let r=s(t),i=Ru(r);return zu(Lu,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`:Fu,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)})},Vu=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.name=`BlameApiError`,this.status=e,this.body=t}},Hu=class extends Error{constructor(){super(`Blame 请求已取消`),this.name=`BlameCancelledError`}},Uu=(e,t,n=``)=>`/api/git?workspaceId=${encodeURIComponent(e)}&op=blame&path=${encodeURIComponent(t)}${n?`&cwd=${encodeURIComponent(n)}`:``}`;async function Wu(e,t,n={}){if(n.signal?.aborted)throw new Hu;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 fetch(Uu(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 Vu(r.status,{error:e.error||`HTTP ${r.status}`,...e.code?{code:e.code}:{}})}return a}catch(e){throw n.signal?.aborted?new Hu:a?new Vu(408,{error:`请求超时:${Math.round(r/1e3)} 秒内服务端没有响应`,code:`timeout`}):e}finally{clearTimeout(o),n.signal?.removeEventListener(`abort`,s)}}var Gu=`\0`,Ku=(e,t,n)=>[e,t,n??``].join(Gu),qu=24,Ju=new Map;function Yu(e){let t=Ju.get(e);if(t)return Ju.delete(e),Ju.set(e,t),t}function Xu(e,t){for(Ju.delete(e),Ju.set(e,t);Ju.size>qu;){let e=Ju.keys().next();if(e.done)break;Ju.delete(e.value)}}var Zu={untracked:`这个文件尚未被 Git 跟踪`,binary:`二进制文件不支持 Blame`,too_large:`文件过大,未显示 Blame`,no_head:`仓库还没有提交`,not_in_revision:`这个版本里没有这个文件`},Qu=`此工作区不是 Git 仓库`;function $u(e){return e&&Zu[e]?{code:e,text:Zu[e]}:{code:`unsupported`,text:`这个文件暂时不能显示 Blame`}}function ed(e){return e instanceof Vu&&e.body.code===`not_a_repo`?{state:`unsupported`,note:{code:`not_a_repo`,text:Qu}}:{state:`error`,note:{code:`error`,text:`读取 Blame 失败:${e instanceof Error&&e.message?e.message:`未知错误`}`}}}var td=`${Gu}uncommitted`;function nd(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?td:n.commit??`${Gu}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 rd(e){let t=0;for(let n of e.lines)n.line>t&&(t=n.line);return t}function id(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 ad(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,od(t.date),t.summary?.trim()||`(没有提交摘要)`]}function od(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 sd(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 cd(e,t,n=!1){return!t||!t.supported?!1:n||sd(e)!==t.totalLines}var ld=new WeakMap;function ud(e){let t=ld.get(e);if(t)return t;let n={response:e,models:nd(e),covered:rd(e)};return ld.set(e,n),n}function dd(e,t){if(!e||t<1)return null;let n=e.models[t-1];return n&&n.line===t?n:null}var fd=`a1b2c3d · Author`;async function pd(){let[e,t]=await Promise.all([Bu(()=>import(`./dist-D978o95T.js`).then(e=>e.S),__vite__mapDeps([0,1])),Bu(()=>import(`./dist-B3-a6uF0.js`).then(e=>e.s),__vite__mapDeps([2,1,0]))]),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=ad(this.model);return e.setAttribute(`title`,t.join(`
|
|
286
|
-
`)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=id(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=fd,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=dd(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=dd(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:md(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 md(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 ad(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function hd(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 gd=4e3,_d=(0,u.lazy)(()=>Bu(()=>import(`./CodeMirrorEditor-DnjDYGwz.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([3,1]))),vd=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},yd=15e3,bd=e=>new vd(408,{error:`请求超时:${yd/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function xd(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),yd);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await fetch(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new vd(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?bd(e):t}finally{clearTimeout(r)}}var Sd=e=>e instanceof vd?e:new vd(0,{error:e instanceof Error?e.message:`读取失败`}),Cd=e=>encodeURIComponent(e),wd=e=>e?`&cwd=${Cd(e)}`:``,Td=(e,t,n)=>`/api/files?workspaceId=${Cd(e)}&path=${Cd(t)}${wd(n)}`,Ed=`//workspace/`,Dd=e=>e.startsWith(Ed)?e.slice(12):void 0,Od=(e,t,n)=>{let r=Dd(t);return`/api/file?workspaceId=${Cd(e)}&path=${Cd(r??t)}${wd(r?``:n)}`},kd=(e,t,n)=>Od(e,t,n)+`&meta=1`,Ad=(e,t,n)=>`/api/files?workspaceId=${Cd(e)}&q=${Cd(t)}${wd(n)}`;async function jd(e,t,n){let r=t.current;if(!r)return t.current=xd(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return xd(e,{cache:`no-store`})}function Md(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 Nd(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function Pd(e){let t=Md(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return Nd(t)}function Fd(e){return Md(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function Id(e,t,n){if(n.openLink){let r=await xd(`/api/files/open?workspaceId=${Cd(e)}${wd(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n.path})}),{path:i,name:a,text:o,ticket:s,content:c,meta:l}=r,u=Ql(r.targetName??i),d=o===!1&&u===`table`?`download`:u??(o===!1?`download`:void 0);return{path:i,name:a,content:c??``,etag:l.etag,dirty:!1,view:d,assetTicket:s}}let{path:r,name:i,text:a}=n,o=Ql(r);if(a===!1&&!o)throw Error(`此文件可通过文件操作菜单下载。`);if(o&&o!==`table`)return{path:r,name:i,content:``,etag:(await xd(kd(e,r,t))).etag,dirty:!1,view:o};try{let n=await xd(Od(e,r,t));return{path:Dd(r)?r:n.path,name:i,content:n.content,etag:n.meta.etag,dirty:!1,view:o}}catch(n){if(!(n instanceof vd)||![413,415].includes(n.status))throw n;return{path:r,name:i,content:``,etag:(await xd(kd(e,r,t))).etag,dirty:!1,view:`download`}}}var Ld=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function Rd({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,P.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,P.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,P.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,P.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,P.jsx)(Vl,{name:g?`down`:`right`})}),(0,P.jsx)(ae,{category:g?`folder-open`:`folder`}),(0,P.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,P.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,P.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,P.jsx)(Vl,{name:`more`})})]}),_,g&&(0,P.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,P.jsx)(`li`,{children:v}),h===void 0?(0,P.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,P.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:M(h.error.message),children:j(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,P.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,P.jsxs)(P.Fragment,{children:[h.truncated&&(0,P.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,P.jsx)(Rd,{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,P.jsx)(zd,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function zd({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,P.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,P.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,P.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`file-name`,children:e.name}),(0,P.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=Ql(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,P.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,P.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,P.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,P.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,P.jsx)(ae,{path:e.path}),(0,P.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,P.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,P.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,P.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,P.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,P.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,P.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,P.jsx)(Vl,{name:`more`})})]}),f]})}function Bd({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}){let[h,g]=(0,u.useState)(!0),_=(0,u.useRef)(null),[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)(null),S=(0,u.useRef)(0),C=!!e.assetTicket,w=!C&&v[e.path]===!0&&!!l,T=l?d?`${l}:${d}`:l:``;(0,u.useEffect)(()=>{let t=++S.current;if(!w||!l){x(null);return}let n=new AbortController,i=Ku(T,e.path,e.etag),a=r?void 0:Yu(i);if(a){x({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:T,note:a.supported?null:$u(a.reason)});return}x({state:`loading`,response:null,path:e.path,workspaceId:T,note:null});let o=Dd(e.path);return Wu(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===S.current&&(r||Xu(i,n),x({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:T,note:n.supported?null:$u(n.reason)}))}).catch(n=>{if(t!==S.current||n instanceof Hu)return;let r=ed(n);x({state:r.state,response:null,path:e.path,workspaceId:T,note:r.note})}),()=>{n.abort()}},[w,l,d,T,e.path,e.etag,r]);let E=b&&b.path===e.path&&b.workspaceId===T?b:null,D=w?E?.state??`loading`:`off`,O=D===`ready`&&cd(e.content,E?.response??null,e.dirty||r),k=[];E?.note&&k.push(E.note),D===`ready`&&E?.response?.truncated&&k.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${E.response.totalLines} 行)`}),O&&k.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let A=D===`loading`?`⌛ Blame`:D===`ready`?`✓ Blame`:D===`off`?`Blame`:`! Blame`;(0,u.useEffect)(()=>{i&&g(!1)},[e.path,i]),(0,u.useEffect)(()=>{let e=_.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
|
|
286
|
+
`)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=id(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=fd,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=dd(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=dd(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:md(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 md(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 ad(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function hd(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 gd=4e3,_d=(0,u.lazy)(()=>Bu(()=>import(`./CodeMirrorEditor-DdxPcLjw.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([3,1]))),vd=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},yd=15e3,bd=e=>new vd(408,{error:`请求超时:${yd/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function xd(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),yd);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await fetch(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new vd(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?bd(e):t}finally{clearTimeout(r)}}var Sd=e=>e instanceof vd?e:new vd(0,{error:e instanceof Error?e.message:`读取失败`}),Cd=e=>encodeURIComponent(e),wd=e=>e?`&cwd=${Cd(e)}`:``,Td=(e,t,n)=>`/api/files?workspaceId=${Cd(e)}&path=${Cd(t)}${wd(n)}`,Ed=`//workspace/`,Dd=e=>e.startsWith(Ed)?e.slice(12):void 0,Od=(e,t,n)=>{let r=Dd(t);return`/api/file?workspaceId=${Cd(e)}&path=${Cd(r??t)}${wd(r?``:n)}`},kd=(e,t,n)=>Od(e,t,n)+`&meta=1`,Ad=(e,t,n)=>`/api/files?workspaceId=${Cd(e)}&q=${Cd(t)}${wd(n)}`;async function jd(e,t,n){let r=t.current;if(!r)return t.current=xd(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return xd(e,{cache:`no-store`})}function Md(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 Nd(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function Pd(e){let t=Md(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return Nd(t)}function Fd(e){return Md(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function Id(e,t,n){if(n.openLink){let r=await xd(`/api/files/open?workspaceId=${Cd(e)}${wd(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n.path})}),{path:i,name:a,text:o,ticket:s,content:c,meta:l}=r,u=Ql(r.targetName??i),d=o===!1&&u===`table`?`download`:u??(o===!1?`download`:void 0);return{path:i,name:a,content:c??``,etag:l.etag,dirty:!1,view:d,assetTicket:s}}let{path:r,name:i,text:a}=n,o=Ql(r);if(a===!1&&!o)throw Error(`此文件可通过文件操作菜单下载。`);if(o&&o!==`table`)return{path:r,name:i,content:``,etag:(await xd(kd(e,r,t))).etag,dirty:!1,view:o};try{let n=await xd(Od(e,r,t));return{path:Dd(r)?r:n.path,name:i,content:n.content,etag:n.meta.etag,dirty:!1,view:o}}catch(n){if(!(n instanceof vd)||![413,415].includes(n.status))throw n;return{path:r,name:i,content:``,etag:(await xd(kd(e,r,t))).etag,dirty:!1,view:`download`}}}var Ld=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function Rd({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,P.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,P.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,P.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,P.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,P.jsx)(Vl,{name:g?`down`:`right`})}),(0,P.jsx)(ae,{category:g?`folder-open`:`folder`}),(0,P.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,P.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,P.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,P.jsx)(Vl,{name:`more`})})]}),_,g&&(0,P.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,P.jsx)(`li`,{children:v}),h===void 0?(0,P.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,P.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:M(h.error.message),children:j(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,P.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,P.jsxs)(P.Fragment,{children:[h.truncated&&(0,P.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,P.jsx)(Rd,{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,P.jsx)(zd,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function zd({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,P.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,P.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,P.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`file-name`,children:e.name}),(0,P.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=Ql(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,P.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,P.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,P.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,P.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,P.jsx)(ae,{path:e.path}),(0,P.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,P.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,P.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,P.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,P.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,P.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,P.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,P.jsx)(Vl,{name:`more`})})]}),f]})}function Bd({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}){let[h,g]=(0,u.useState)(!0),_=(0,u.useRef)(null),[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)(null),S=(0,u.useRef)(0),C=!!e.assetTicket,w=!C&&v[e.path]===!0&&!!l,T=l?d?`${l}:${d}`:l:``;(0,u.useEffect)(()=>{let t=++S.current;if(!w||!l){x(null);return}let n=new AbortController,i=Ku(T,e.path,e.etag),a=r?void 0:Yu(i);if(a){x({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:T,note:a.supported?null:$u(a.reason)});return}x({state:`loading`,response:null,path:e.path,workspaceId:T,note:null});let o=Dd(e.path);return Wu(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===S.current&&(r||Xu(i,n),x({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:T,note:n.supported?null:$u(n.reason)}))}).catch(n=>{if(t!==S.current||n instanceof Hu)return;let r=ed(n);x({state:r.state,response:null,path:e.path,workspaceId:T,note:r.note})}),()=>{n.abort()}},[w,l,d,T,e.path,e.etag,r]);let E=b&&b.path===e.path&&b.workspaceId===T?b:null,D=w?E?.state??`loading`:`off`,O=D===`ready`&&cd(e.content,E?.response??null,e.dirty||r),k=[];E?.note&&k.push(E.note),D===`ready`&&E?.response?.truncated&&k.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${E.response.totalLines} 行)`}),O&&k.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let A=D===`loading`?`⌛ Blame`:D===`ready`?`✓ Blame`:D===`off`?`Blame`:`! Blame`;(0,u.useEffect)(()=>{i&&g(!1)},[e.path,i]),(0,u.useEffect)(()=>{let e=_.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
|
|
287
287
|
`).length),n=e.value.split(`
|
|
288
288
|
`),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,h]);let j=/\.md$/i.test(e.path);return(0,P.jsxs)(`div`,{className:`file-editor`,"data-file-editor":e.path,"data-save-state":t,"data-file-readonly":C?`1`:void 0,children:[(0,P.jsxs)(`div`,{className:`file-editor-head`,children:[f??(!p&&(0,P.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path})),(0,P.jsxs)(`span`,{className:`file-editor-flags`,children:[j&&(0,P.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:()=>g(e=>!e),children:h?`原文`:`预览`}),e.assetTicket&&l&&!p&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{children:`外部文件 · 只读`}),(0,P.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:s,children:`重新读取`}),(0,P.jsx)(`a`,{className:`file-preview-toggle`,href:Kl(`asset`,l,d,e.assetTicket,{download:`1`}),download:e.name,children:`下载`})]}),!C&&(0,P.jsx)(`button`,{type:`button`,className:`file-blame-toggle`,"data-file-blame-toggle":e.path,"data-file-blame-state":D,"aria-pressed":w,"aria-label":w?`关闭 Git Blame`:`显示 Git Blame`,onClick:()=>y(t=>({...t,[e.path]:t[e.path]!==!0})),children:A}),e.dirty&&(0,P.jsx)(`span`,{className:`file-dirty`,"data-file-dirty":`1`,children:`未保存`}),!C&&(0,P.jsxs)(`button`,{type:`button`,className:`file-save`,"data-file-save":e.path,onClick:o,title:`保存文件 (Ctrl+S)`,disabled:t===`saving`,children:[(0,P.jsx)(Vl,{name:`save`}),t===`saving`?`保存中…`:`保存`]})]})]}),k.length>0&&(0,P.jsx)(`p`,{className:`file-blame-note`,"data-file-blame-reason":k.map(e=>e.code).join(` `),role:`status`,children:k.map(e=>e.text).join(`;`)}),r&&t!==`conflict`&&(0,P.jsxs)(`div`,{className:`file-conflict`,"data-file-external":e.path,role:`alert`,children:[(0,P.jsx)(`p`,{children:`这个文件在磁盘上已经被改过了,你的修改还没有覆盖它。`}),(0,P.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,P.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,P.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),t===`conflict`&&(0,P.jsxs)(`div`,{className:`file-conflict`,"data-file-conflict":e.path,role:`alert`,children:[(0,P.jsx)(`p`,{children:`保存被拒绝:这个文件在磁盘上已经被改过了,覆盖会丢掉对方的改动。`}),(0,P.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,P.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,P.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),n&&t!==`conflict`&&!r&&(0,P.jsx)(`p`,{className:`file-editor-message file-message-${t}`,"data-file-message":t,role:`status`,children:n}),j&&h?(0,P.jsx)(`div`,{className:`file-markdown-preview`,"data-file-preview":`markdown`,children:(0,P.jsx)(wl,{source:e.content})}):(0,P.jsx)(uu,{fallback:(t,n)=>(0,P.jsxs)(`div`,{className:`file-editor-fallback`,"data-file-editor-fallback":`1`,children:[(0,P.jsxs)(`div`,{className:`file-editor-fallback-bar`,children:[(0,P.jsxs)(`span`,{children:[`⚠️ 高级编辑器加载异常(`,t.message||`未知错误`,`),已自动降级为安全模式`]}),(0,P.jsx)(`button`,{type:`button`,onClick:n,children:`重新加载`})]}),(0,P.jsx)(`textarea`,{className:`file-textarea`,readOnly:C,value:e.content,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),o())}})]}),children:(0,P.jsx)(u.Suspense,{fallback:(0,P.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,P.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`})}),children:(0,P.jsx)(_d,{path:e.path,value:e.content,onChange:a,jumpToLine:i,onSave:o,readOnly:C,workspaceId:l,onPosition:m,blame:w&&E&&!O?{state:E.state,response:E.response,path:E.path,workspaceId:l??``}:void 0})})})]})}function Vd({line:e}){if(e.kind===`fold`)return(0,P.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,P.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,P.jsx)(`span`,{className:`file-diff-mark`,"aria-hidden":`true`,children:t}),(0,P.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.oldLine??``}),(0,P.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.newLine??``}),(0,P.jsx)(`span`,{className:`file-diff-text`,children:e.text}),e.noNewline&&(0,P.jsx)(`span`,{className:`file-diff-no-newline`,title:`这个版本的末尾没有换行`,children:`(末尾无换行)`})]})}function Hd({diff:e,loading:t,error:n,bufferContent:r,mode:i,onMode:a}){let[o,s]=(0,u.useState)(),c=JSON.stringify([e?.path,i]),l=o===c,{scrollBox:d,capture:f}=hd(l,`.file-diff-added, .file-diff-removed`);if(t)return(0,P.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`loading`,children:(0,P.jsx)(`p`,{className:`rail-empty`,"data-file-diff-loading":`1`,children:`正在读取差异…`})});if(n)return(0,P.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`error`,children:(0,P.jsx)(`p`,{className:`rail-empty`,"data-file-diff-error":`1`,title:M(n),children:j(n,`这个文件的差异读取失败。`)})});if(!e)return(0,P.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`empty`,children:(0,P.jsx)(`p`,{className:`rail-empty`,"data-file-diff-empty":`1`,children:`没有选中的差异。`})});let p=typeof r==`string`,m=i===`buffer`&&p,h=m?e.after:e.before,g=m?r:e.after,_=m?`我未保存的修改`:e.label,v=m?`buffer`:e.baseline,y=p&&e.baseline!==`none`?(0,P.jsxs)(`span`,{className:`file-diff-switch`,"data-file-diff-switch":`1`,children:[(0,P.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${m?``:` file-diff-switch-active`}`,"data-file-diff-base":`server`,"aria-pressed":!m,onClick:()=>a(`server`),children:`agent 的改动`}),(0,P.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${m?` file-diff-switch-active`:``}`,"data-file-diff-base":`buffer`,"aria-pressed":m,onClick:()=>a(`buffer`),children:`我的修改`})]}):null;if(v===`none`)return(0,P.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`none`,"data-file-diff-baseline":v,children:[(0,P.jsxs)(`div`,{className:`file-editor-head`,children:[(0,P.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,P.jsx)(`span`,{className:`file-editor-flags`,children:y})]}),(0,P.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-nobaseline":`1`,children:_})]});let b=Tu(h,g),x=Eu(b);return(0,P.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`ready`,"data-file-diff-baseline":v,"data-file-diff-added":b.added,"data-file-diff-removed":b.removed,children:[(0,P.jsxs)(`div`,{className:`file-editor-head`,children:[(0,P.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,P.jsxs)(`span`,{className:`file-editor-flags`,children:[y,(0,P.jsx)(`span`,{className:`file-diff-baseline`,"data-file-diff-label":`1`,children:_}),(0,P.jsxs)(`span`,{className:`file-diff-count`,"data-file-diff-count":`1`,children:[`+`,b.added,` / -`,b.removed]}),!b.identical&&x.folded>0&&(0,P.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,"data-file-diff-context":!0,"aria-pressed":l,onClick:()=>{f(),s(l?void 0:c)},children:l?`折叠未改动行`:`显示全文`})]})]}),e.beforeUnknown&&!m&&(0,P.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-before-unknown":`1`,role:`status`,children:`读不到改动前的版本(文件太大或无法读取),这里只显示现在的内容。`}),e.before===null&&!e.beforeUnknown&&!m&&(0,P.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-is-new":`1`,role:`status`,children:`这个文件是新建的,下面是它的全部内容。`}),b.identical?(0,P.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-identical":`1`,children:`两个版本没有区别。`}):(0,P.jsx)(`div`,{ref:d,className:`file-diff-body`,"data-file-diff-body":`1`,"data-file-diff-context-mode":l?`full`:`compact`,children:(l?b.lines:x.lines).map((e,t)=>(0,P.jsx)(Vd,{line:e},t))})]})}function Ud({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,P.jsxs)(`div`,{className:`rail-empty file-problem`,"data-file-root-error":`1`,"data-file-error-kind":r,role:`alert`,children:[r===`missing`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`工作区路径不存在,无法读取文件。`}),(0,P.jsx)(`p`,{className:`file-problem-hint`,children:`请确认这个路径是写错了,还是目录被移动或删除了:`}),(0,P.jsx)(`code`,{className:`file-problem-path`,"data-file-error-path":`1`,children:n||j(e.message,`路径未知`)})]}),r===`timeout`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取超时,服务端没有回应。`}),(0,P.jsxs)(`p`,{className:`file-problem-hint`,children:[`已经等了 `,yd/1e3,` 秒。如果这个工作区在网络盘上,请检查它是否已连接,然后点上面的 ↻ 重试。`]})]}),r===`failed`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取失败。`}),(0,P.jsx)(`p`,{className:`file-problem-hint`,title:M(e.message),children:j(e.message,`读取失败,请稍后重试。`)})]})]})}function Wd(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=(0,u.useRef)(c);d.current=c;let[f,p]=(0,u.useState)(),[m,h]=(0,u.useState)(``),[g,_]=(0,u.useState)({}),[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)({}),[S,C]=(0,u.useState)(()=>new Set),[w,T]=(0,u.useState)(),E=(0,u.useRef)(S);E.current=S;let D=(0,u.useRef)(new Map),O=(0,u.useRef)(new Map),[k,A]=(0,u.useState)(0),[M,N]=(0,u.useState)(``),[ee,te]=(0,u.useState)(null),[ne,re]=(0,u.useState)(null),[ie,F]=(0,u.useState)(!1),[ae,oe]=(0,u.useState)({});(0,u.useEffect)(()=>{if(D.current=new Map,l([]),p(void 0),h(``),_({}),y({}),x({}),C(new Set),T(void 0),te(null),re(null),N(``),F(!1),!e)return;let t=!0;return xd(Td(e,``,a)).then(e=>{t&&x({"":e})}).catch(e=>{t&&x({"":{error:Sd(e)}})}),()=>{if(t=!1,o&&s.current!==o){let e=d.current.filter(e=>e.dirty);e.length?O.current.set(o,e):O.current.delete(o),Pu(`super-pi.file-drafts.v1.`+o,e),Jd(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=Kd()[o]??{expanded:[],open:[]},i=e=>({path:e,name:e.split(/[\\/]/).at(-1)||e,text:!0,openLink:r.explicit?.includes(e)?!0:void 0}),a=Nu(`super-pi.file-drafts.v1.`+o,[]),c=new Map((O.current.get(o)??a).map(e=>[e.path,e]));r.expanded.length&&C(new Set(r.expanded)),typeof r.listHeight==`number`&&te(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,m=()=>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&&m()&&(e=await Se(i(n),{activate:!1,isCurrent:m})),e&&s.current===o&&m()){let t=e;r.preview===r.active&&l(e=>e.map(e=>e.path===t&&!e.dirty?{...e,preview:!0}:e)),p(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=Kd();e[o]={open:c.map(e=>e.path),explicit:c.filter(e=>e.assetTicket).map(e=>e.path),expanded:[...S],...r&&f?{active:f}:{},...r&&f&&c.some(e=>e.path===f&&e.preview)?{preview:f}:{},...ee===null?{}:{listHeight:ee}},qd(e)},400);return()=>{clearTimeout(t)}},[e,o,c,S,f,ee,r]),(0,u.useEffect)(()=>{if(!o||se!==o)return;let e=()=>{if(s.current!==o)return;let e=d.current.filter(e=>e.dirty);return Pu(`super-pi.file-drafts.v1.`+o,e)||e.length===0},t=window.setTimeout(()=>{e()===!1&&h(`浏览器无法保存文件草稿,刷新前请先保存修改。`)},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=D.current;i.set(t,r);let c=()=>s.current===o&&D.current===i&&i.get(t)===r;await xd(Td(e,t,a)+(n?`&revalidate=1`:``)).then(e=>{c()&&x(n=>({...n,[t]:e}))}).catch(e=>{c()&&x(n=>({...n,[t]:{error:Sd(e)}}))}).finally(()=>{c()&&i.delete(t)})},[e,a,o]),fe=(0,u.useCallback)(e=>{C(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([``,...E.current]),r=t&&new Set(t.map($l)),i=e=>!r||r.has(e)||t.some(t=>eu(e,t));x(e=>Object.fromEntries(Object.entries(e).filter(([e])=>n.has(e)||!i(e))));for(let e of D.current.keys())!n.has(e)&&i(e)&&D.current.delete(e);Promise.all([...n].filter(i).map(e=>de(e,!t&&!e))).then(()=>{s.current===o&&A(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=>eu(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=$l(e);n;n=$l(n))t.add(n);N(``),C(e=>new Set([...e,...t]))},[]),ve=(0,u.useCallback)((e,t)=>{_e(t&&e?`${e}/`:e),T({path:e,directory:t})},[_e]),ye=(0,u.useCallback)(()=>C(new Set),[]),be=(0,u.useCallback)((e,t,n)=>{let r=n=>eu(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=Ql(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}})),p(e=>e&&r(e)),C(e=>new Set([...e].map(r))),_(i),y(i);for(let t of D.current.keys())eu(t,e)&&D.current.delete(t);x(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!eu(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=Fd(M);if(!e||!t||Pd(M)){xe.current=void 0,re(null),F(!1);return}let n=!0,r,i=async()=>{try{let o=await jd(Ad(e,t,a),xe,()=>n);if(!n||!o)return;re(o),F(!1),o.indexed||(r=setTimeout(()=>void i(),400))}catch(e){if(!n)return;re(null),F(!1),h(j(e,`文件查找没有完成`))}};return F(!0),r=setTimeout(()=>void i(),80),()=>{n=!1,clearTimeout(r)}},[M,e,a,k]);let Se=(0,u.useCallback)(async(t,{preview:n=!1,activate:r=!0,isCurrent:i,throwOnError:c,requireText:u}={})=>{if(!(!e||i&&!i())){h(``);try{let c=d.current.find(e=>e.path===t.path),f=c??await Id(e,a,t);if(s.current!==o||i&&!i())return;if(u&&f.view&&f.view!==`table`)throw Error(`已找到匹配行,但此文件无法在文本编辑器中定位。可以在搜索结果中查看这一行。`);return c?(r&&p(t.path),t.path):(l(e=>e.some(e=>e.path===f.path)?e:[...e,{...f,...n?{preview:n}:{}}]),r&&p(f.path),y(e=>({...e,[f.path]:!1})),f.path)}catch(e){if(s.current!==o||i&&!i())return;if(c)throw e;h(`打不开「${t.name}」:${e instanceof Error?e.message:`未知错误`}`)}}},[e,a,o]),Ce=(0,u.useCallback)(e=>{o&&d.current.some(t=>t.path===e&&t.preview&&!t.dirty)&&Jd(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===f&&p(i.length===0?void 0:i[Math.min(r,i.length-1)]?.path),i})},[f,o]),L=(0,u.useCallback)(e=>{l(t=>t.map(t=>t.path===e&&t.preview?{...t,preview:!1}:t))},[]),we=(0,u.useCallback)(e=>{l(t=>t.filter(t=>t.path!==e||!t.preview||t.dirty)),p(t=>t===e?void 0:t),o&&Jd(o,e)},[o]),Te=(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 d.current)r||xd(kd(e,n,a)).then(e=>{if(!t)return;let r=d.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&&y(e=>({...e,[n]:!0}))}).catch(e=>{t&&Sd(e).status===404&&y(e=>({...e,[n]:!0}))})},gd);return()=>{t=!1,clearInterval(n)}},[e,a,c.length]);let Ee=(0,u.useCallback)(async(t,n)=>{if(!e)return;let r=c.find(e=>e.path===t);if(!r||r.assetTicket)return;_(e=>({...e,[t]:{state:`saving`,message:``}}));let i=r.etag;if(n)try{i=(await xd(kd(e,t,a))).etag}catch(e){s.current===o&&_(n=>({...n,[t]:{state:`error`,message:`无法读取磁盘上的最新版本:${e instanceof Error?e.message:`未知错误`}`}}));return}let u=r.content;try{let n=await xd(Od(e,t,a),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:Dd(t)??t,content:u,baseEtag:i})});if(s.current!==o)return;let r=d.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)),y(e=>({...e,[t]:!1})),_(e=>({...e,[t]:{state:`saved`,message:c?`已保存,但你又改了;最新修改仍未保存`:`已保存 ${Ld(n.meta.modifiedAt)}`}}))}catch(e){if(s.current!==o)return;let n=e instanceof vd&&e.body.code===`stale`;_(r=>({...r,[t]:{state:n?`conflict`:`error`,message:e instanceof Error?e.message:`保存失败`}})),n&&y(e=>({...e,[t]:!0}))}},[e,a,o,c]),De=(0,u.useCallback)(async t=>{if(!e)return;let n=d.current.find(e=>e.path===t),r=n?.content;try{if(n?.assetTicket){let r=await Id(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)),_(e=>({...e,[t]:{state:`idle`,message:``}})));return}let i=await xd(Od(e,t,a));if(s.current!==o)return;let c=d.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)),y(e=>({...e,[t]:!1})),_(e=>({...e,[t]:{state:`saved`,message:u?`已读取磁盘版本;你后来输入的修改仍未保存`:`已重新载入磁盘版本`}}))}catch(e){s.current===o&&_(n=>({...n,[t]:{state:`error`,message:e instanceof Error?e.message:`重新载入失败`}}))}},[e,a,o]),Oe=c.find(e=>e.path===f),ke=(0,u.useMemo)(()=>c.map(e=>({id:e.path,label:e.name,title:Dd(e.path)??e.path,closable:!0,badge:e.dirty?(0,P.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[c]),Ae=(0,u.useMemo)(()=>new Set(c.map(e=>e.path)),[c]),je=(0,u.useCallback)((e,t,n)=>{oe(r=>({...r,[e]:{changes:t,dropped:n}}))},[]),Me=e?ae[e]:void 0,Ne=(0,u.useMemo)(()=>{let e=Me?.changes??[];if(!a)return e;let t=`${a}/`;return e.flatMap(e=>e.path.startsWith(t)?[{...e,path:e.path.slice(t.length)}]:[])},[Me,a]),Pe=Me?.dropped??0,Fe=(0,u.useMemo)(()=>new Set(Ne.map(e=>e.path)),[Ne]),Ie=(0,u.useMemo)(()=>{let e=new Set;for(let t of Ne){let n=t.path.split(`/`);for(let t=1;t<n.length;t++)e.add(n.slice(0,t).join(`/`))}return e},[Ne]);return{open:c,activePath:f,visiblePath:r?f:i,location:w,active:Oe,tabItems:ke,openPaths:Ae,notice:m,setNotice:h,saves:g,external:v,restoringWorkbench:!!(o&&se!==o),openFile:Se,setActivePath:p,closeFile:Ce,pinFile:L,discardPreview:we,updateBuffer:Te,save:Ee,reload:De,listings:b,expanded:S,toggleDirectory:fe,loadDirectory:de,refreshTree:me,invalidateTree:ge,revealPath:_e,locatePath:ve,collapseDirectories:ye,movePath:be,listHeight:ee,setListHeight:te,query:M,setQuery:N,hits:ne,searching:ie,changed:Ne,changedPaths:Fe,changedDirs:Ie,changedDropped:Pe,setChangedFor:je,restoredActive:le}}var Gd=`super-pi.file-workbench.v1`;function Kd(){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 qd(e){try{typeof window<`u`&&window.localStorage.setItem(Gd,JSON.stringify(e))}catch{}}function Jd(e,t){let n=Kd(),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},qd(n))}function Yd({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,P.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 Xd=()=>null,Zd=`application/x-super-pi-workspace-file`;function Qd({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=ou({workspaceId:e,cwd:n,scopeName:j,files:r,onOpen:A,onReference:o,onMoved:s,onSearchFolder:c}),[N,ee]=(0,u.useState)(),te=(0,u.useRef)(void 0),[ne,re]=(0,u.useState)(!1),ie=M.editing?M.inline:Xd,F=(0,u.useMemo)(()=>({currentPath:r.visiblePath,dropPath:N,inline:ie}),[r.visiblePath,N,ie]);(0,u.useEffect)(()=>{y();function e(){y()}return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[y]),(0,u.useEffect)(()=>{ee(void 0),te.current=void 0,re(!1)},[e,n]);let oe=h[``],se=S.trim(),ce=e?Pd(S):void 0,le=(0,u.useRef)(null),ue=(0,u.useRef)(null),de=(0,u.useRef)(void 0);function fe(e){let t=ue.current;t&&(de.current&&de.current!==e&&(de.current.tabIndex=-1),de.current=e,t.tabIndex=e?-1:0,e&&(e.tabIndex=0))}let pe=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{let{location:e}=r;if(!e||pe.current===e)return;let t=le.current?.querySelector(e.path?`[${e.directory?`data-file-dir-toggle`:`data-file-open`}="${CSS.escape(e.path)}"]`:`[data-explorer-root]`);t&&(pe.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 me=(0,u.useCallback)(e=>{let t=le.current;if(!t)return;let n=e.target?.closest(`.file-row`);if(!n)return;let r=nu(n);if(r&&!M.busy){if(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`){e.preventDefault(),M.openMenu(r,Hl(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]),[I,he]=(0,u.useState)(200);(0,u.useEffect)(()=>{he(200)},[se,e]);let ge=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(se===``)return;let e=ge.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&he(e=>e>=(w?.hits.length??0)?e:e+200)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[se,w]);let _e=(0,u.useMemo)(()=>{if(ce)return(0,P.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-exact-path":ce.path,title:ce.path,onClick:()=>A(ce),children:[(0,P.jsx)(ae,{path:ce.path}),(0,P.jsxs)(`span`,{className:`file-name`,children:[`打开 `,ce.name]})]});if(se){if(T)return(0,P.jsx)(`p`,{className:`rail-empty`,"data-file-searching":`1`,children:`搜索中…`});if(!w)return null;if(w.hits.length===0)return(0,P.jsx)(`p`,{className:`rail-empty`,"data-file-search-empty":`1`,children:w.indexed?`没有匹配「${se}」的文件。`:`正在建立索引…`});let e=w.hits.slice(0,I),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,P.jsxs)(P.Fragment,{children:[t.map(e=>(0,P.jsxs)(`section`,{className:`file-group`,"data-file-search-group":e.directory,children:[(0,P.jsxs)(`h3`,{className:`file-group-head`,"data-file-search-group-head":e.directory,children:[(0,P.jsx)(`span`,{className:`file-group-name`,children:e.directory||`/`}),(0,P.jsx)(`span`,{className:`file-group-count`,children:e.hits.length})]}),(0,P.jsx)(`ul`,{className:`file-list`,children:e.hits.map(e=>(0,P.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,P.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,P.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,P.jsx)(ae,{path:e.path}),(0,P.jsx)(`span`,{className:`file-name`,children:e.name}),d.has(e.path)&&(0,P.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`})]}),!e.openLink&&(0,P.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,P.jsx)(Vl,{name:`more`})})]},e.path))})]},e.directory||`/`)),e.length<w.hits.length&&(0,P.jsx)(`div`,{ref:ge,className:`file-sentinel`,"data-file-search-more":`1`,children:`正在载入更多…`})]})}return e?oe===void 0?(0,P.jsx)(`p`,{className:`rail-empty`,"data-file-root-loading":`1`,children:`读取工作区…`}):`error`in oe?(0,P.jsx)(Ud,{error:oe.error}):(0,P.jsxs)(P.Fragment,{children:[oe.truncated&&(0,P.jsx)(`p`,{className:`file-search-note`,"data-file-truncated-root":`1`,children:`条目过多,只显示前一部分。`}),oe.entries.length===0?(0,P.jsx)(`p`,{className:`rail-empty`,"data-file-root-empty":`1`,children:`这个工作区是空的,没有文件也没有子目录。`}):(0,P.jsx)(`ul`,{className:`file-list`,children:oe.entries.map(t=>t.kind===`directory`?(0,P.jsx)(Rd,{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:F},t.path):(0,P.jsx)(zd,{entry:t,depth:0,openPaths:d,changedPaths:D,onOpen:A,presentation:F},t.path))})]}):(0,P.jsx)(`p`,{className:`rail-empty`,"data-file-no-workspace":`1`,children:`先在左侧选一个工作区,这里会显示它的文件。`})},[ce,se,T,w,I,e,oe,h,g,_,v,A,d,O,D,F,r.visiblePath]),ve=e=>{let t=nu(e);if(!t?.linked)return t?t.directory?t.path:$l(t.path):``},ye=(e,t)=>e!==$l(t.path)&&!(t.directory&&eu(e,t.path));return(0,u.useLayoutEffect)(()=>{let e=ue.current;if(!e)return;let t=[...e.querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),n=de.current;fe(n&&t.includes(n)?n:t.find(e=>e.hasAttribute(`aria-current`))??t[0])},[_e,M.editing]),(0,P.jsxs)(`div`,{className:`files-panel`,"data-files-panel":`1`,"data-files-open-count":l.length,"data-files-changed-count":E.length,ref:le,onKeyDown:me,onClick:e=>{let t=e.target instanceof Element?e.target.closest(`[data-explorer-action]`):void 0,n=nu(t??null);t&&n&&!M.busy&&M.openMenu(n,Hl(t))},onContextMenu:e=>{let t=nu(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=nu(e.target instanceof Element?e.target.closest(`.file-row[draggable=true]`):null);!t||t.linked||M.busy||se||(te.current=t,e.dataTransfer.setData(Zd,t.path),e.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{te.current=void 0,ee(void 0)},onDragLeave:e=>{(!(e.relatedTarget instanceof Node)||!e.currentTarget.contains(e.relatedTarget))&&ee(void 0)},onDragOver:t=>{let n=t.dataTransfer.types.includes(`Files`),r=te.current&&t.dataTransfer.types.includes(Zd)?te.current:void 0;if(!e||M.busy||!n&&!r)return;t.preventDefault();let i=ve(t.target),a=i!==void 0&&(!r||ye(i,r));t.dataTransfer.dropEffect=a?r?`move`:`copy`:`none`,ee(a?i:void 0)},onDrop:t=>{ee(void 0);let n=t.dataTransfer.types.includes(Zd)?te.current:void 0;if(te.current=void 0,!e||M.busy||!n&&!t.dataTransfer.types.includes(`Files`))return;t.preventDefault();let r=ve(t.target);if(r===void 0){p(`请选择工作区里的普通文件夹。`);return}if(n){ye(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,P.jsxs)(`header`,{className:`file-explorer-header`,"data-file-drop-target":N===``?`1`:void 0,children:[(0,P.jsxs)(`div`,{className:`file-explorer-scope`,"data-explorer-root":`1`,tabIndex:-1,title:n?`${t??`工作区`}/${n}`:j,children:[(0,P.jsx)(ae,{category:`folder-open`}),(0,P.jsx)(`span`,{children:j})]}),M.toolbar]}),(0,P.jsxs)(`div`,{className:`files-search`,children:[(0,P.jsx)(`span`,{className:`files-search-icon`,"aria-hidden":`true`,children:(0,P.jsx)(Vl,{name:`search`})}),(0,P.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`&&ce&&(e.preventDefault(),A(ce))},onChange:e=>C(e.target.value)}),(0,P.jsx)(`button`,{type:`button`,className:`explorer-icon-button`,disabled:!r.activePath||!!Dd(r.activePath)||!!(r.active?.assetTicket&&Pd(r.activePath)),onClick:()=>{r.activePath&&r.locatePath(r.activePath,!1)},title:`定位打开的文件`,"aria-label":`在文件树中定位当前文件`,children:(0,P.jsx)(Vl,{name:`locate`})})]}),M.controls,!ce&&se&&w&&!T&&(0,P.jsxs)(`p`,{className:`files-count`,"data-file-search-count":`1`,role:`status`,children:[(0,P.jsx)(`b`,{children:w.total.toLocaleString(`zh-CN`)}),` 个结果`,w.indexed===!1&&(0,P.jsx)(`span`,{className:`files-count-note`,"data-file-search-indexing":`1`,children:`正在建立索引…`}),w.indexed&&w.incomplete&&(0,P.jsx)(`span`,{className:`files-count-note`,children:`索引不完整`})]}),f&&(0,P.jsx)(`p`,{className:`rail-empty file-explorer-notice`,"data-file-notice":`1`,role:`status`,children:f}),M.busy&&(0,P.jsx)(`p`,{className:`file-explorer-notice`,role:`status`,children:`正在处理文件…`}),(0,P.jsx)(`div`,{className:`files-tree`,ref:ue,"data-file-tree":se?`search`:`browse`,tabIndex:0,"aria-label":`文件树`,onFocus:e=>{e.target instanceof HTMLElement&&e.target.matches(`.file-row:not(:disabled)`)&&fe(e.target)},style:b===null?void 0:{height:`${b}px`,flex:`0 0 auto`},children:(0,P.jsxs)(`div`,{className:`files-tree-body`,children:[M.inline(``,`child`,0),_e]})}),(0,P.jsx)(Yd,{height:b,onHeight:x,panelRef:le}),(0,P.jsxs)(`div`,{className:`files-changed`,"data-file-changed-list":`1`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`files-changed-head`,"data-file-changed-head":`1`,"aria-expanded":ne,onClick:()=>re(e=>!e),children:[(0,P.jsx)(Vl,{name:ne?`down`:`right`}),(0,P.jsx)(Vl,{name:`changes`}),(0,P.jsx)(`span`,{children:`改动`}),(0,P.jsx)(`span`,{className:`files-change-count`,children:E.length})]}),ne&&(0,P.jsxs)(`div`,{className:`files-change-list`,children:[k>0&&(0,P.jsxs)(`p`,{className:`file-search-note`,"data-file-changed-dropped":`1`,children:[`还有 `,k,` 个改动没有记录(超过保留上限)。`]}),!E.length&&(0,P.jsx)(`p`,{className:`file-row-empty`,children:`没有 agent 改动。`}),(0,P.jsx)(`ul`,{className:`file-list`,children:E.map(e=>(0,P.jsx)(`li`,{children:(0,P.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,P.jsx)(ae,{path:e.path}),(0,P.jsx)(`span`,{className:`file-name`,children:e.path.split(`/`).pop()}),(0,P.jsx)(`span`,{className:`file-badge-path`,children:e.path.split(`/`).slice(0,-1).join(`/`)||`/`}),(0,P.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed-kind":e.path,children:e.baseline===null&&!e.baselineUnknown?`新建`:`已改`})]})},e.path))})]})]})]})}function $d(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(j(e,`文件无法打开`))}finally{r(!1)}}},openError:i,opening:n,setOpenError:a}}var ef=200;async function tf(e,t,n){let r=await fetch(e,{signal:t,cache:`no-store`});if(!r.ok)throw new vd(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(`
|
|
289
289
|
`);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 nf(e,t,n){let r=t?t+`/`+e.path:e.path;return{path:n?r.startsWith(n+`/`)?r.slice(n.length+1):Ed+r:r,name:e.name,text:!0}}function rf({workspaceId:e,cwd:t=``,directory:n,initialQuery:r=``,onOpen:i,onClose:a,onMode:o}){let[s,c]=(0,u.useState)(r),[l,d]=(0,u.useState)(n??``),[f,p]=(0,u.useState)(``),[m,h]=(0,u.useState)(``),[g,_]=(0,u.useState)(!0),[v,y]=(0,u.useState)([]),[b,x]=(0,u.useState)(),[S,C]=(0,u.useState)(ef),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(!1),[O,k]=(0,u.useState)(!1),[A,M]=(0,u.useState)(0),{choose:N,openError:ee,opening:te,setOpenError:ne}=$d(i,a),re=!!Pd(s),ie=(0,u.useRef)(null),F=(0,u.useRef)(null),ae=(0,u.useRef)(void 0),oe=(0,u.useId)();(0,u.useEffect)(()=>{ie.current?.focus()},[]),(0,u.useEffect)(()=>{F.current?.scrollIntoView({block:`nearest`})},[A]),(0,u.useEffect)(()=>{let t=s.trim(),n=new AbortController;if(ae.current=n,y([]),x(void 0),T(``),k(!1),C(ef),M(0),!e||!t){D(!1);return}if(t.length>256){T(`搜索词不能超过 256 个字符。`),D(!1);return}let r=new URLSearchParams({workspaceId:e,q:t,stream:`1`,ignore:g?`1`:`0`});l&&r.set(`cwd`,l),f.trim()&&r.set(`include`,f.trim()),m.trim()&&r.set(`exclude`,m.trim()),D(!0);let i=setTimeout(()=>{n.signal.aborted||tf(`/api/files/search?`+r,n.signal,e=>{n.signal.aborted||(e.type===`matches`?y(t=>[...t,...e.hits]):e.type===`done`&&x(e.summary))}).catch(e=>{n.signal.aborted||T(j(e,`搜索没有完成`))}).finally(()=>{n.signal.aborted||D(!1)})},220);return()=>{n.abort(),clearTimeout(i)}},[s,e,l,f,m,g]);let se=(0,u.useMemo)(()=>{let e=new Map;return v.slice(0,S).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]},[v,S]),ce=e=>{e&&N(nf(e,l,t),e.line,e.column)},le=b?.complete===!1,ue={time:`搜索超时`,results:`达到全局结果上限`,line:`部分行太长`,encoding:`部分文件的编码无法读取`,unreadable:`部分文件无法读取`};return(0,P.jsxs)(cu,{mode:`content`,query:s,onMode:o,onClose:a,children:[(0,P.jsx)(`input`,{ref:ie,className:`quick-open-input`,"data-content-search-input":`1`,value:s,readOnly:te,placeholder:`内容搜索(区分大小写,按字面匹配)`,role:`combobox`,"aria-label":`内容搜索`,"aria-autocomplete":`list`,"aria-controls":oe,"aria-expanded":v.length>0,"aria-activedescendant":v[A]?`${oe}-${A}`:void 0,onChange:e=>{c(e.target.value),ne(``)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),M(e=>Math.min(e+1,Math.max(0,Math.min(S,v.length)-1)))):e.key===`ArrowUp`?(e.preventDefault(),M(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),ce(v[A])))}}),(0,P.jsxs)(`div`,{className:`content-search-controls`,children:[(0,P.jsxs)(`label`,{children:[`范围 `,(0,P.jsxs)(`select`,{value:l,"aria-label":`搜索范围`,onChange:e=>d(e.target.value),children:[(0,P.jsx)(`option`,{value:``,children:`整个工作区`}),t&&(0,P.jsxs)(`option`,{value:t,children:[`当前目录 · `,t]}),n&&n!==t&&(0,P.jsxs)(`option`,{value:n,children:[`文件夹 · `,n]})]})]}),E&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>{ae.current?.abort(),ie.current?.focus(),D(!1),k(!0)},children:`取消搜索`})]}),(0,P.jsxs)(`details`,{className:`content-search-filters`,children:[(0,P.jsx)(`summary`,{children:`文件筛选`}),(0,P.jsxs)(`label`,{children:[`包含 `,(0,P.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`例如 **/*.cpp`})]}),(0,P.jsxs)(`label`,{children:[`排除 `,(0,P.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`例如 **/generated/**`})]}),(0,P.jsxs)(`label`,{children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked)}),` 遵循忽略文件和默认排除`]})]}),(0,P.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"data-content-search-status":w?`error`:E?`searching`:O?`cancelled`:le?`partial`:`complete`,children:[w?`搜索失败:`+w:E?`搜索中…`:O?`已取消`:e?le?`结果不完整`:b?`搜索完成`:`输入要搜索的内容`:`请先选择工作区`,(v.length>0||b)&&` · ${v.length} 条命中`]}),re&&(0,P.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>o(`path`,s),children:`按文件路径打开`}),le&&(0,P.jsx)(`p`,{className:`quick-open-status`,"data-content-search-partial":`1`,children:b.reasons.map(e=>ue[e]??e).join(`;`)}),b?.complete&&!v.length&&(0,P.jsx)(`p`,{className:`quick-open-status`,"data-content-search-empty":`1`,children:`没有匹配的行`}),ee&&(0,P.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:ee}),(0,P.jsx)(`ul`,{id:oe,className:`quick-open-results content-search-results`,role:`listbox`,"aria-label":`正文搜索结果`,children:se.map(([e,t])=>(0,P.jsxs)(`li`,{className:`content-search-group`,role:`presentation`,children:[(0,P.jsx)(`div`,{className:`content-search-file`,title:e,children:e}),t.map(({hit:e,row:t})=>(0,P.jsxs)(`button`,{id:`${oe}-${t}`,ref:t===A?F:void 0,type:`button`,role:`option`,tabIndex:-1,"data-content-search-result":`${e.path}:${e.line}`,className:`quick-open-result content-search-result${A===t?` quick-open-result-active`:``}`,"aria-selected":A===t,"aria-label":`${e.path}:${e.line}:${e.column} ${e.text}`,onMouseEnter:()=>M(t),onClick:()=>ce(e),children:[(0,P.jsxs)(`span`,{title:`${e.path}:${e.line}:${e.column}`,className:`content-search-result-position`,children:[e.line,`:`,e.column]}),(0,P.jsx)(`small`,{title:e.text,children:e.text})]},e.line))]},e))}),v.length>S&&(0,P.jsxs)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-content-search-more":`1`,onClick:()=>{S+ef>=v.length&&ie.current?.focus(),C(e=>e+ef)},children:[`显示更多结果(已显示 `,S,` / `,v.length,`)`]})]})}function af({workspaceId:e,cwd:t=``,connected:n,initialQuery:r=``,onOpen:i,onClose:a,onMode:o}){let[s,c]=(0,u.useState)(r),[l,d]=(0,u.useState)(0),[f,p]=(0,u.useState)(0),[m,h]=(0,u.useState)(),g=(0,u.useRef)(void 0),_=(0,u.useRef)(void 0),{choose:v,openError:y,opening:b,setOpenError:x}=$d(i,a),S=(0,u.useRef)(null),C=(0,u.useRef)(null),w=Fd(s),T=e?Pd(s):void 0,E=!!T;(0,u.useEffect)(()=>{if(!n||!e)return;let r=new AbortController,i=Ad(e,``,t)+`&quick=1&refresh=1`;return g.current=xd(i,{cache:`no-store`,signal:r.signal}).catch(()=>void 0),()=>{r.abort(),g.current=void 0}},[n,e,t]),(0,u.useEffect)(()=>{if(!n||!e||E)return;let r=new AbortController,i=r.signal,a=Ad(e,w,t)+`&quick=1&page=${f}`,o,s=async e=>{try{let t=e?await g.current:void 0;if(i.aborted)return;let n=e&&!w&&t?t:await xd(a,{cache:`no-store`,signal:i});if(i.aborted)return;h({query:w,page:f,response:n}),n.indexed||(o=setTimeout(()=>void s(!1),350))}catch(e){i.aborted||h({query:w,page:f,error:j(e,`文件查找没有完成`)})}};return o=setTimeout(()=>void s(!0),w?120:0),()=>{r.abort(),clearTimeout(o)}},[n,e,t,w,E,f]);let D=m?.query===w&&m.page===f?m:void 0,O=D?.response,k=(0,u.useMemo)(()=>{if(T)return[T];let t=O?.hits.map(e=>({...e,text:null}))??[];return f>0||e&&w.includes(`/`)&&!w.endsWith(`/`)&&!w.split(`/`).includes(`..`)&&!t.some(e=>e.path.toLowerCase()===w.toLowerCase())&&(O?.total?t.push(Nd(w)):t.unshift(Nd(w))),t},[T,w,O,f,e]),A=e=>{_.current=void 0,p(e),h(void 0),d(0),x(``),S.current?.focus()},M=!E&&!(!e||D?.error||O?.indexed);return(0,u.useEffect)(()=>{let e=_.current;e===void 0||M||(_.current=void 0,v(k[Math.min(e,k.length-1)]))},[M,k,v]),(0,u.useEffect)(()=>{S.current?.focus()},[]),(0,u.useEffect)(()=>{C.current?.scrollIntoView({block:`nearest`})},[l]),(0,P.jsxs)(cu,{mode:`path`,query:s,onMode:o,onClose:a,children:[(0,P.jsx)(`input`,{ref:S,className:`quick-open-input`,"data-quick-open-input":`1`,value:s,readOnly:b,placeholder:`快速打开:输入文件名或路径`,"aria-label":`快速打开文件路径`,onChange:e=>{let t=e.target.value;_.current=void 0,(Fd(t)!==w||f!==0)&&h(void 0),c(t),p(0),d(0),x(``)},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`ArrowDown`)e.preventDefault(),d(e=>Math.min(e+1,Math.max(0,k.length-1)));else if(e.key===`ArrowUp`)e.preventDefault(),d(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=k[Math.min(l,k.length-1)],n=O?.hits.some(e=>e.path===t?.path&&[e.name,e.path].some(e=>e.toLowerCase()===w.toLowerCase()));M&&!n?_.current=l:v(t)}}}}),(0,P.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"aria-live":`polite`,"data-quick-open-status":E||O?.indexed&&!O.incomplete?`complete`:`partial`,children:[E?`按 Enter 打开指定文件`:e?n?D?.error||(M?`正在检查文件索引…`:w?O?.incomplete?`索引不完整 · ${O.total} 条命中`:O?.total?`${O.total} 条命中${f?` · 第 ${f+1} 页`:``}`:k.length?`近似路径`:`没有匹配的文件名或路径`:`输入文件名或路径以查找当前目录中的文件`):`等待连接…`:`请先选择工作区`,` · Esc 关闭`]}),y&&(0,P.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:y}),(0,P.jsx)(`ul`,{className:`quick-open-results`,role:`listbox`,children:k.map((e,t)=>(0,P.jsx)(`li`,{children:(0,P.jsxs)(`button`,{ref:t===l?C:void 0,type:`button`,"data-quick-open-result":e.path,className:t===l?`quick-open-result quick-open-result-active`:`quick-open-result`,"aria-selected":t===l,onMouseMove:()=>d(t),onClick:()=>{_.current=void 0,v(e)},children:[(0,P.jsx)(`span`,{title:e.name,children:e.name}),(0,P.jsx)(`small`,{title:e.path,children:e.path})]})},e.path))}),w&&O?.indexed&&(f>0||O.truncated)&&(0,P.jsxs)(`div`,{className:`quick-open-pages`,"aria-label":`文件搜索翻页`,children:[f>0&&(0,P.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>A(f-1),children:`上一页`}),O.truncated&&(0,P.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-quick-open-next-page":!0,onClick:()=>A(f+1),children:`下一页`})]})]})}function of(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 sf(e,t){let n=Math.max(1,Math.floor(t)),r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}function cf(e,t,n=88,r=200){let[i,a]=(0,u.useState)(()=>of(e,0,n,r)),[o,s]=(0,u.useState)(null),c=(0,u.useCallback)(()=>{let i=of(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 lf({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:_}=cf(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=sf(e,h.perRow),y=(e,t)=>t===void 0?{}:{[`data-${c}-${e}`]:t},b=e.filter(e=>e.kind===`file`).length,x=e.filter(e=>e.kind===`session`||!e.kind).length,S=t=>({[`data-${t}-strip`]:`1`,...g?{[`data-${t}-frozen`]:`1`}:{},[`data-${t}-count`]:t===`file-tab`?b:t===`session-tab`?x:e.length,[`data-${t}-min`]:o,[`data-${t}-max`]:s,[`data-${t}-per-row`]:h.perRow,[`data-${t}-width`]:Math.round(h.width*100)/100}),C=e=>{let t=e.relatedTarget;(!t||t.isConnected)&&_()},w=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 T=[`${c}-strip`,`workspace-tab-strip`,`session-tab-strip`,`file-tab-strip`,d].filter(Boolean).join(` `);return(0,P.jsx)(`div`,{ref:f,className:T,role:`tablist`,"aria-label":a??`工作区标签页`,...y(`strip`,`1`),...S(`workspace-tab`),...S(`session-tab`),...S(`file-tab`),style:{"--tab-w":`${h.width}px`},onMouseEnter:C,onMouseLeave:w,children:v.map((a,o)=>(0,P.jsx)(`div`,{className:`${c}-row workspace-tab-row session-tab-row file-tab-row`,role:`presentation`,...y(`row`,o),children:a.map(a=>{let o=a.id===t||a.rawId!==void 0&&a.rawId===t,s=a.title??a.label,u=a.kind,d=a.rawId??a.id,f=e.findIndex(e=>e.id===a.id),p=[c,o?`${c}-active`:``,`workspace-tab`,o?`workspace-tab-active`:``,u?`${u}-tab`:``,u&&o?`${u}-tab-active`:``,a.preview?`${c}-preview`:``,a.preview?`workspace-tab-preview`:``,a.preview&&u?`${u}-tab-preview`:``].filter(Boolean).join(` `);return(0,P.jsxs)(`div`,{role:`tab`,id:`${l}-${a.id}`,"aria-selected":o,"aria-controls":`${l}-panel-${a.id}`,tabIndex:o?0:-1,className:p,...y(`id`,d),...y(`index`,f),...o?y(`active`,`1`):{},...y(`closable`,a.closable===!1?`0`:`1`),...u?{"data-tab-kind":u}:{},...a.preview?{"data-tab-preview":`1`}:{},...u===`session`||!u?{"data-session-tab-id":d,"data-session-tab-index":f,...o?{"data-session-tab-active":`1`}:{},"data-session-tab-closable":a.closable===!1?`0`:`1`,...a.preview?{"data-session-tab-preview":`1`}:{}}:{},...u===`file`?{"data-file-tab-id":d,"data-file-tab-index":f,...o?{"data-file-tab-active":`1`}:{},"data-file-tab-closable":a.closable===!1?`0`:`1`}:{},...u===`diff`?{"data-diff-tab-id":d,"data-diff-tab-index":f,...o?{"data-diff-tab-active":`1`}:{},"data-diff-tab-closable":a.closable===!1?`0`:`1`}:{},title:s,style:{width:h.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,P.jsx)(`span`,{className:`${c}-icon workspace-tab-icon`,children:a.icon}),a.badge,(0,P.jsx)(`span`,{className:`${c}-label workspace-tab-label ${u?`${u}-tab-label`:``}`,...y(`label`,d),...u===`session`||!u?{"data-session-tab-label":d}:{},...u===`file`?{"data-file-tab-label":d}:{},...u===`diff`?{"data-diff-tab-label":d}:{},children:a.label}),a.closable!==!1&&r&&(0,P.jsx)(`button`,{type:`button`,className:`${c}-close workspace-tab-close ${u?`${u}-tab-close`:``}`,...y(`close`,d),...u===`session`||!u?{"data-session-tab-close":d}:{},...u===`file`?{"data-file-tab-close":d}:{},...u===`diff`?{"data-diff-tab-close":d}:{},onClick:e=>{e.stopPropagation(),r(a.id)},onDoubleClick:e=>{e.stopPropagation()},title:`关闭 ${s}`,"aria-label":`关闭 ${s}`,children:`×`})]},a.id)})},`row_${o}`))})}var uf=25,df=75;function ff({share:e,onShare:t}){let n=(0,u.useRef)(null),[r,i]=(0,u.useState)(!1),a=e=>t(Math.round(Math.min(df,Math.max(uf,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,P.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":uf,"aria-valuemax":df,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(uf);else if(t.key===`End`)a(df);else return;t.preventDefault()}})}function pf({tabs:e,selected:t,onSelect:n,onPin:r,onCloseTab:i,onClose:a,children:o}){let s=e.find(e=>e.id===t);return(0,P.jsxs)(`section`,{className:`workbench-split-pane`,"data-workbench-split-pane":!0,"aria-label":`拆分区`,children:[(0,P.jsxs)(`div`,{className:`workbench-split-bar`,children:[(0,P.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,P.jsx)(`option`,{value:``,disabled:!0,children:`选择文件或差异`}),e.map(e=>(0,P.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),t&&s?.preview&&(0,P.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`固定标签页`,"aria-label":`固定拆分区标签页`,onClick:()=>r(t),children:(0,P.jsx)(I,{name:`pin`})}),t&&(0,P.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`关闭此标签页`,"aria-label":`关闭拆分区标签页`,onClick:()=>i(t),children:(0,P.jsx)(I,{name:`close`})}),(0,P.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,"data-close-workbench-split":!0,title:`合并主区`,"aria-label":`合并主区`,onClick:a,children:(0,P.jsx)(I,{name:`split`})})]}),o??(0,P.jsx)(`p`,{className:`rail-empty`,children:`从文件或 Git 面板打开一个文件或差异。`})]})}function mf(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 hf(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 gf={pending:`未开始`,running:`运行中`,completed:`已完成`,failed:`失败`,skipped:`已跳过`,stopped:`已停止`},_f={running:`运行中`,completed:`全部完成`,failed:`中途失败`,stopped:`已停止`},vf={pending:`○`,running:`◐`,completed:`✓`,failed:`✕`,skipped:`→`,stopped:`■`},yf={stop:`失败即停`,skip:`失败跳过`,"retry:1":`失败重试 1 次`,"retry:2":`失败重试 2 次`,"retry:3":`失败重试 3 次`};function bf(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 xf(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 Sf({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,P.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,P.jsx)(`span`,{className:`workflow-step-mark`,"aria-hidden":`true`,children:vf[e.status]}),(0,P.jsxs)(`span`,{className:`workflow-step-n`,"data-workflow-step-n":e.index+1,children:[`第 `,e.index+1,` 步`]}),(0,P.jsx)(`strong`,{className:`workflow-step-name`,"data-workflow-step-name":e.index+1,children:a}),(0,P.jsx)(`span`,{className:`workflow-step-agent`,"data-workflow-step-agent-name":e.index+1,children:i}),n>1&&(0,P.jsxs)(`span`,{className:`workflow-step-tries`,"data-workflow-step-retried":e.index+1,children:[`尝试 `,n,` 次`]}),(0,P.jsx)(`span`,{className:`workflow-step-status`,"data-workflow-step-status-text":e.index+1,children:gf[e.status]}),e.status===`failed`&&r?.error&&(0,P.jsx)(`span`,{className:`workflow-step-why`,"data-workflow-step-error":e.index+1,title:M(r.error),children:j(r.error,`这一步没有完成。`)})]})}function Cf({nodes:e,steps:t,names:n}){return(0,P.jsx)(`ol`,{className:`workflow-steps`,children:e.map((e,r)=>{if(e.kind===`step`){let r=t[e.stepIndex];return r?(0,P.jsx)(Sf,{step:r,names:n},`step-${e.stepIndex}`):null}return e.kind===`loop`?(0,P.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,P.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),(0,P.jsx)(`strong`,{children:`循环`}),(0,P.jsxs)(`span`,{children:[`直到「`,e.until,`」`]}),(0,P.jsxs)(`span`,{"data-workflow-loop-progress":!0,children:[`已跑 `,e.rounds.length,`/`,e.max,` 轮`]})]}),e.rounds.map(e=>(0,P.jsxs)(`section`,{className:`workflow-round`,"data-workflow-round":e.n,"data-workflow-round-met":e.untilMet?`true`:`false`,children:[(0,P.jsxs)(`div`,{className:`workflow-round-head`,children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:e.untilMet?`✓`:`○`}),`第 `,e.n,` 轮 · `,e.untilMet?`条件满足`:`条件未满足`]}),(0,P.jsx)(Cf,{nodes:e.nodes,steps:t,names:n})]},e.n))]},`loop-${r}`):(0,P.jsxs)(`li`,{className:`workflow-node workflow-foreach`,"data-workflow-foreach":!0,"data-workflow-foreach-count":e.items.length,children:[(0,P.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:`≡`}),(0,P.jsx)(`strong`,{children:`逐项执行`}),(0,P.jsxs)(`span`,{children:[e.items.length,` 个由 primary 给出的项目`]})]}),e.iterations.map((e,r)=>(0,P.jsxs)(`section`,{className:`workflow-item`,"data-workflow-item":r+1,"data-workflow-item-value":e.item,children:[(0,P.jsxs)(`div`,{className:`workflow-item-head`,children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),`第 `,r+1,` 项 · `,e.item]}),(0,P.jsx)(Cf,{nodes:e.nodes,steps:t,names:n})]},`${r}-${e.item}`))]},`foreach-${r}`)})})}function wf({workflow:e,names:t,onStop:n,stopping:r}){let i=e.status===`running`,a=xf(e),o=e.steps.filter(e=>e.status===`completed`||e.status===`skipped`).length;return(0,P.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,P.jsxs)(`div`,{className:`workflow-head`,children:[(0,P.jsx)(`span`,{className:`workflow-badge`,children:`编排`}),(0,P.jsx)(`strong`,{className:`workflow-summary`,"data-workflow-summary":e.id,children:e.summary}),(0,P.jsxs)(`span`,{className:`workflow-progress`,"data-workflow-progress":e.id,children:[o,`/`,e.steps.length]}),(0,P.jsx)(`span`,{className:`workflow-status`,"data-workflow-status-text":e.id,children:_f[e.status]??`未知状态`}),(0,P.jsx)(`span`,{className:`workflow-policy`,"data-workflow-policy":e.onFailure,children:yf[e.onFailure]??e.onFailure}),a!==void 0&&(0,P.jsxs)(`span`,{className:`workflow-clock`,"data-workflow-elapsed":e.id,children:[i?`已运行 `:`用时 `,bf(a)]}),i&&(0,P.jsx)(`button`,{type:`button`,className:`workflow-stop`,"data-workflow-stop":e.id,disabled:r,onClick:n,children:`停止`})]}),e.nodes?(0,P.jsx)(Cf,{nodes:e.nodes,steps:e.steps,names:t}):(0,P.jsx)(`ol`,{className:`workflow-steps`,"data-workflow-step-count":e.steps.length,children:e.steps.map(e=>(0,P.jsx)(Sf,{step:e,names:t},e.index))})]})}var Tf=[{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 Ef({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=Tf.find(e=>e.id===t)??Tf[0];return(0,P.jsx)(`div`,{className:`overlay`,onClick:e,children:(0,P.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,P.jsxs)(`div`,{className:`settings-window-head help-window-head`,children:[(0,P.jsxs)(`div`,{className:`help-head-title`,children:[(0,P.jsx)(`h2`,{id:`help-window-title`,children:`使用指南与帮助`}),(0,P.jsx)(`span`,{className:`help-badge`,children:`v0.1.x`})]}),(0,P.jsx)(`button`,{type:`button`,className:`help-close-button`,"aria-label":`关闭指南`,onClick:e,children:`✕`})]}),(0,P.jsxs)(`div`,{className:`settings-window-body help-window-body`,children:[(0,P.jsxs)(`nav`,{className:`settings-nav help-nav`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":`使用指南分类`,children:[(0,P.jsx)(`div`,{className:`settings-nav-label`,children:`目录`}),Tf.map(e=>(0,P.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,P.jsx)(`span`,{className:`help-tab-icon`,"aria-hidden":`true`,children:e.icon}),(0,P.jsx)(`span`,{children:e.label})]},e.id))]}),(0,P.jsxs)(`div`,{id:`help-panel`,className:`settings-panel help-panel`,role:`tabpanel`,"aria-labelledby":`help-tab-${r.id}`,children:[(0,P.jsxs)(`div`,{className:`help-panel-header`,children:[(0,P.jsx)(`h3`,{className:`help-panel-title`,children:r.title}),(0,P.jsx)(`p`,{className:`help-panel-desc`,children:r.description})]}),(0,P.jsxs)(`div`,{className:`help-panel-content`,children:[r.id===`agents`&&(0,P.jsx)(kf,{}),r.id===`workspace`&&(0,P.jsx)(Af,{}),r.id===`subagents`&&(0,P.jsx)(Mf,{}),r.id===`model-policy`&&(0,P.jsx)(jf,{}),r.id===`memory`&&(0,P.jsx)(Df,{}),r.id===`knowledge`&&(0,P.jsx)(Of,{}),r.id===`feishu`&&(0,P.jsx)(Nf,{}),r.id===`tools`&&(0,P.jsx)(Pf,{}),r.id===`cli`&&(0,P.jsx)(Ff,{}),r.id===`themes`&&(0,P.jsx)(If,{})]}),(0,P.jsx)(`div`,{className:`picker-actions help-actions`,children:(0,P.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e,children:`关闭`})})]})]})]})})}function Df(){return(0,P.jsxs)(`div`,{className:`help-section-group`,children:[(0,P.jsxs)(`div`,{className:`help-card highlight`,children:[(0,P.jsx)(`h4`,{children:`🧠 它会记住什么?`}),(0,P.jsx)(`p`,{children:`用户档案保存跨工作区的长期偏好;工作区事实保存环境与项目约定;技能保存已经验证过的步骤、命令和坑。临时结果、秘密和未验证的失败不会保存。`})]}),(0,P.jsxs)(`div`,{className:`help-card`,children:[(0,P.jsx)(`h4`,{children:`主动保存与后台复盘`}),(0,P.jsxs)(`ul`,{className:`help-list`,children:[(0,P.jsxs)(`li`,{children:[`主 Agent 可以使用 `,(0,P.jsx)(`code`,{children:`memory`}),` 和 `,(0,P.jsx)(`code`,{children:`skill_manage`}),` 工具主动保存;说“记住了”本身不会写入。`]}),(0,P.jsx)(`li`,{children:`每隔若干回合,系统会在独立会话中复盘最近证据。复盘不能读写工作区文件、执行命令或派发任务。`}),(0,P.jsx)(`li`,{children:`读取记忆和历史只返回带来源的参考数据,不能把记忆中的文字当作新的指令。`})]})]}),(0,P.jsxs)(`div`,{className:`help-card`,children:[(0,P.jsx)(`h4`,{children:`权限与审批`}),(0,P.jsxs)(`ul`,{className:`help-list`,children:[(0,P.jsx)(`li`,{children:`子 Agent 可以读取相关记忆,但没有写入权限。`}),(0,P.jsx)(`li`,{children:`后台复盘新增记忆可以直接保存;修改或删除旧条目会进入设置中的待审批列表。`}),(0,P.jsx)(`li`,{children:`在“设置 → 主动记忆”可以开关功能、调整复盘间隔、编辑条目和批准提案。`})]})]})]})}function Of(){return(0,P.jsxs)(`div`,{className:`help-section-group`,children:[(0,P.jsxs)(`div`,{className:`help-card highlight`,children:[(0,P.jsx)(`h4`,{children:`📚 它解决什么问题?`}),(0,P.jsx)(`p`,{children:`Agent 默认靠训练时的记忆回答项目里的问题。知识库让你把规范、设计稿、会议纪要导入工作区,Agent 在回答前检索这些文档的原文片段,而不是凭印象编造。它与“主动记忆”不同:记忆是 Agent 自己沉淀的事实和技能,知识库的内容来自工作区里真实存在的文档。`})]}),(0,P.jsxs)(`div`,{className:`help-card`,children:[(0,P.jsx)(`h4`,{children:`怎么用`}),(0,P.jsxs)(`ul`,{className:`help-list`,children:[(0,P.jsxs)(`li`,{children:[`在“设置 → 知识库”里点“浏览工作区文件…”,在弹出的浏览器里挑一个 Markdown 或文本文件,挑完即导入。也可以直接粘贴正文、手动填写相对路径,或者直接对 Agent 说“把某某文件加入知识库”——它会用 `,(0,P.jsx)(`code`,{children:`knowledge_import`}),` 导入,走的是同一条服务端校验。`]}),(0,P.jsx)(`li`,{children:`同一个文件内容改了再导入就是更新,不会留下旧版本;同样的内容换个标题再导入也不会变成两篇。`}),(0,P.jsx)(`li`,{children:`面板里的“试检索”会用和 Agent 相同的检索器回答,方便你在交给 Agent 之前先确认它找得到。`}),(0,P.jsxs)(`li`,{children:[`从下一条消息开始生效。Agent 使用 `,(0,P.jsx)(`code`,{children:`knowledge_search`}),` 检索,只拿得到片段和来源,拿不到整篇文档。`]})]})]}),(0,P.jsxs)(`div`,{className:`help-card`,children:[(0,P.jsx)(`h4`,{children:`语义检索是内置的`}),(0,P.jsxs)(`ul`,{className:`help-list`,children:[(0,P.jsxs)(`li`,{children:[`关键词检索始终可用。语义检索让“撤销购买”也能找到写着“取消订单”的段落,它靠一个`,(0,P.jsx)(`strong`,{children:`随安装包一起分发`}),`的中文模型在本机运行,不需要额外下载、不需要联网、也不会把文档发到任何服务。`]}),(0,P.jsxs)(`li`,{children:[`第一次检索时加载模型(约一秒),之后一直可用。设 `,(0,P.jsx)(`code`,{children:`SUPER_PI_KNOWLEDGE_EMBEDDINGS=0`}),` 可以彻底关闭语义检索,只保留关键词检索。`]})]})]}),(0,P.jsxs)(`div`,{className:`help-card`,children:[(0,P.jsx)(`h4`,{children:`它不知道的事`}),(0,P.jsxs)(`ul`,{className:`help-list`,children:[(0,P.jsx)(`li`,{children:`知识库只会检索它有的东西。文档里没写的,它检索出来也不会有——所以导入什么,直接决定它能回答什么。`}),(0,P.jsx)(`li`,{children:`语义检索总会返回“最接近的那一段”,即使这一段其实并不回答问题。检索结果带一个分数,低分意味着这可能只是最像的一条,Agent 会被要求先核对再使用。`}),(0,P.jsxs)(`li`,{children:[`Agent 可以按你的要求把工作区文件导入知识库(`,(0,P.jsx)(`code`,{children:`knowledge_import`}),`,只接受文本类文件),但`,(0,P.jsx)(`strong`,{children:`不能删除`}),`——删除文档只有你能在“设置 → 知识库”里做。`]})]})]})]})}function kf(){return(0,P.jsxs)(`div`,{className:`help-section-group`,children:[(0,P.jsxs)(`div`,{className:`help-card highlight`,children:[(0,P.jsx)(`h4`,{children:`💡 Agent 是什么?`}),(0,P.jsxs)(`p`,{children:[`在 Super Pi 中,`,(0,P.jsx)(`strong`,{children:`Agent(智能体)`}),` 是一套独立的「角色提示词设定与能力配置」。 通过切换 Agent,模型将扮演专精工程师、系统架构师、代码审查员或规划专家等不同角色,遵循指定的原则来协助你完成任务。`]})]}),(0,P.jsxs)(`div`,{className:`help-card`,children:[(0,P.jsx)(`h4`,{children:`📁 Agent 文件存放在哪里?`}),(0,P.jsxs)(`ul`,{className:`help-list`,children:[(0,P.jsxs)(`li`,{children:[(0,P.jsx)(`strong`,{children:`内置 Agent 目录:`}),`项目根目录下的 `,(0,P.jsx)(`code`,{children:`agents/`}),` 文件夹,例如 `,(0,P.jsx)(`code`,{children:`agents/coder.md`}),`、`,(0,P.jsx)(`code`,{children:`agents/planner.md`}),`、`,(0,P.jsx)(`code`,{children:`agents/reviewer.md`}),` 等。`]}),(0,P.jsxs)(`li`,{children:[(0,P.jsx)(`strong`,{children:`用户自定义持久化目录:`}),`用户主目录下的 `,(0,P.jsx)(`code`,{children:`~/.super-pi/agents/`}),`,放入此目录的文件在所有项目和更新中均持久有效。`]})]})]}),(0,P.jsxs)(`div`,{className:`help-card`,children:[(0,P.jsx)(`h4`,{children:`🚀 如何创建一个全新的自定义 Agent?`}),(0,P.jsxs)(`div`,{className:`help-steps`,children:[(0,P.jsxs)(`div`,{className:`help-step`,children:[(0,P.jsx)(`span`,{className:`step-num`,children:`1`}),(0,P.jsxs)(`div`,{className:`step-body`,children:[(0,P.jsx)(`strong`,{children:`创建 Markdown 文件`}),(0,P.jsxs)(`p`,{children:[`在 `,(0,P.jsx)(`code`,{children:`agents/`}),` 或 `,(0,P.jsx)(`code`,{children:`~/.super-pi/agents/`}),` 目录下新建文件,例如 `,(0,P.jsx)(`code`,{children:`architect.md`}),`。`]})]})]}),(0,P.jsxs)(`div`,{className:`help-step`,children:[(0,P.jsx)(`span`,{className:`step-num`,children:`2`}),(0,P.jsxs)(`div`,{className:`step-body`,children:[(0,P.jsx)(`strong`,{children:`编写元数据与系统提示词`}),(0,P.jsx)(`p`,{children:`文件开头使用 YAML Frontmatter 声明名称和描述,正文编写设定提示词:`}),(0,P.jsx)(`pre`,{className:`help-code-block`,children:(0,P.jsx)(`code`,{children:`---
|
|
@@ -337,7 +337,7 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
337
337
|
`).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 VT({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?BT(e):{label:zT(e),state:`user`},C=()=>{let t=g.trim();t&&t!==e.content&&p(e.id,t),h(!1)};return(0,P.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,P.jsx)(`input`,{type:`checkbox`,className:`queue-select`,"data-waiting-select":e.id,checked:o,"aria-label":`选择「${x}」`,onChange:()=>s?.(e.id)}),(0,P.jsx)(`span`,{className:`queue-index`,"aria-hidden":`true`,children:t}),y?(0,P.jsxs)(`span`,{className:`queue-reminder`,"data-queue-reminder":!0,children:[(0,P.jsxs)(`span`,{className:`reminder-label`,children:[(0,P.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,P.jsx)(`span`,{className:`queue-text`,title:x,children:x})]}):b?(0,P.jsxs)(`span`,{className:`queue-bg-result`,title:x,children:[(0,P.jsx)(`span`,{className:`bg-result-glyph`,"aria-hidden":`true`,children:S===`error`?`✕`:`↩`}),(0,P.jsx)(`span`,{className:`bg-result-label`,children:`后台回传`}),(0,P.jsx)(`span`,{className:`bg-result-summary`,children:x})]}):m?(0,P.jsxs)(`div`,{className:`queue-row-edit`,children:[(0,P.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,P.jsx)(`button`,{type:`button`,className:`queue-edit-save`,"data-waiting-save":e.id,onClick:C,children:`保存`}),(0,P.jsx)(`button`,{type:`button`,className:`queue-edit-cancel`,"data-waiting-cancel-edit":e.id,onClick:()=>{_(e.content),h(!1)},children:`取消`})]}):(0,P.jsx)(`span`,{className:`queue-text`,title:x,children:x}),(0,P.jsx)(`span`,{className:`queue-state`,"data-waiting-state":v?`sending`:`queued`,children:v?`已交给 Agent`:t===1?`下一条回答这条`:`等待回答 · 第 ${t} 条`}),v?(0,P.jsx)(`span`,{className:`queue-locked`,"data-waiting-locked":e.id,children:`暂时改不了`}):(0,P.jsxs)(P.Fragment,{children:[r?(0,P.jsxs)(P.Fragment,{children:[(0,P.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,P.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,P.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,P.jsx)(`button`,{type:`button`,className:`queue-edit`,"data-waiting-edit":e.id,title:`回答这条之前改字`,"aria-label":`修改「${x}」`,onClick:()=>{_(e.content),h(!0)},children:`改字`}),(0,P.jsx)(`button`,{type:`button`,className:`queue-cancel`,"data-waiting-cancel":e.id,title:`撤回这条消息,它不会被回答`,"aria-label":`撤回「${x}」`,onClick:()=>f(e.id),children:`撤回`})]})]})}function HT({question:e,index:t,expanded:n,onToggle:r,onAnswer:i}){return(0,P.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,P.jsx)(`button`,{type:`button`,className:`call-fold-edge`,"data-question-fold-edge":t,"aria-expanded":n,"aria-label":`${n?`折叠`:`展开`}提问`,title:n?`折叠这段提问`:`展开这段提问`,onClick:r}),(0,P.jsxs)(`div`,{className:`call-head-row`,children:[(0,P.jsxs)(`button`,{type:`button`,className:`call-head`,"data-call-head":t,"aria-expanded":n,onClick:r,children:[(0,P.jsx)(`span`,{className:`call-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,P.jsx)(`span`,{className:`call-glyph`,"aria-hidden":`true`,children:e.status===`answered`?`✓`:e.status===`cancelled`?`✕`:`?`}),(0,P.jsx)(`span`,{className:`call-label`,children:`提问`}),(0,P.jsxs)(`span`,{className:`call-detail`,children:[e.items.length,` 个问题`]})]}),n&&(0,P.jsx)(`button`,{type:`button`,className:`call-fold-top`,"data-call-fold-top":t,onClick:r,children:`收起`})]}),n&&(0,P.jsx)(`div`,{className:`question-body`,"data-question-body":t,children:(0,P.jsx)(UT,{question:e,onAnswer:i})})]})}function UT({question:e,onAnswer:t}){let[n,r]=(0,u.useState)(()=>Object.fromEntries((e.answers??[]).map(e=>[e.id,e.selected]))),[i,a]=(0,u.useState)(()=>e.answers?.map(e=>e.note??``).join(`
|
|
338
338
|
`)??``),o=(e,t,n)=>{r(r=>{let i=r[e]??[];return n?{...r,[e]:i.includes(t)?i.filter(e=>e!==t):[...i,t]}:{...r,[e]:[t]}})},s=()=>{t(e.items.map(e=>({id:e.id,selected:n[e.id]??[],...e.extraNote&&i.trim()?{note:i.trim()}:{}})),!1)},c=e.items.some(e=>(n[e.id]??[]).length>0);return(0,P.jsxs)(`div`,{className:`question-block question-${e.status}`,"data-question-status":e.status,children:[e.items.map(t=>(0,P.jsxs)(`div`,{className:`question-item`,children:[(0,P.jsx)(`div`,{className:`question-text`,children:t.header?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`question-header`,children:t.header}),(0,P.jsx)(`span`,{className:`question-sep`,children:` · `}),(0,P.jsx)(wl,{source:t.question})]}):(0,P.jsx)(wl,{source:t.question})}),(0,P.jsx)(`div`,{className:`question-options`,"data-question-options":t.id,children:t.options.map(r=>{let i=e.status!==`pending`,a=(i?e.answers?.find(e=>e.id===t.id)?.selected:n[t.id])?.includes(r)??!1;return(0,P.jsxs)(`label`,{className:a?`is-chosen`:``,"data-chosen":i&&a?`1`:void 0,children:[(0,P.jsx)(`input`,{type:t.multiple?`checkbox`:`radio`,name:`q-${t.id}`,checked:a,disabled:i,onChange:()=>o(t.id,r,t.multiple)}),(0,P.jsx)(Tl,{source:r}),i&&a?(0,P.jsx)(`span`,{className:`question-mark`,"aria-label":`已选择`,children:`✓`}):null]},r)})}),e.status===`pending`&&t.extraNote?(0,P.jsx)(`textarea`,{value:i,placeholder:`补充说明(可选)`,onChange:e=>a(e.target.value)}):e.status===`answered`&&(e.answers??[]).some(e=>e.note)?(0,P.jsxs)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:[`补充:`,(e.answers??[]).map(e=>e.note).filter(Boolean).join(`;`)]}):null,e.status===`cancelled`&&(0,P.jsx)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:`已取消,没有作答。`})]},t.id)),e.status===`pending`&&(0,P.jsxs)(`div`,{className:`question-actions`,children:[(0,P.jsx)(`button`,{type:`button`,onClick:s,disabled:!c,children:`提交`}),(0,P.jsx)(`button`,{type:`button`,className:`question-skip`,onClick:()=>t([],!0),children:`跳过`})]})]})}function WT({request:e,onAnswer:t,pending:n}){let[r,i]=(0,u.useState)(e.prefill??``),a=e.method===`input`||e.method===`editor`,o=(0,P.jsx)(`button`,{type:`button`,className:`extui-cancel`,onClick:()=>t({cancelled:!0}),children:`取消提问`});return(0,P.jsxs)(`article`,{className:`extui-card extui-${e.method}`,"data-request-id":e.requestId,"data-method":e.method,children:[(0,P.jsxs)(`div`,{className:`extui-head`,children:[(0,P.jsx)(`span`,{className:`extui-badge`,children:`扩展提问`}),e.timeoutMs!==void 0&&(0,P.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,P.jsx)(`p`,{className:`extui-pending`,role:`status`,children:`提交中…`}),(0,P.jsxs)(`fieldset`,{disabled:n,style:{border:0,padding:0,margin:0},children:[(0,P.jsx)(`h3`,{className:`extui-title`,children:e.title||iE[e.method]}),e.method===`confirm`&&(0,P.jsx)(`p`,{className:`extui-body`,children:e.message}),e.method===`select`&&(0,P.jsxs)(`div`,{className:`extui-options`,children:[(e.options??[]).map(e=>(0,P.jsx)(`button`,{type:`button`,className:`extui-option`,onClick:()=>t({value:e}),children:e},e)),(e.options??[]).length===0&&(0,P.jsx)(`p`,{className:`extui-body`,children:`扩展没有提供任何选项`})]}),a&&(0,P.jsxs)(`form`,{className:`extui-form`,onSubmit:e=>{e.preventDefault(),!n&&r.trim()&&t({value:r})},children:[e.method===`input`?(0,P.jsx)(`input`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Uw(e)&&e.preventDefault()},placeholder:e.placeholder??``}):(0,P.jsx)(`textarea`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Uw(e)&&e.preventDefault()}}),(0,P.jsxs)(`div`,{className:`extui-actions`,children:[(0,P.jsx)(`button`,{type:`submit`,className:`extui-primary`,disabled:!r.trim(),children:`提交`}),o]})]}),!a&&(0,P.jsxs)(`div`,{className:`extui-actions`,children:[e.method===`confirm`&&(0,P.jsx)(`button`,{type:`button`,className:`extui-primary`,onClick:()=>t({confirmed:!0}),children:`确认`}),e.method===`confirm`&&(0,P.jsx)(`button`,{type:`button`,className:`extui-no`,onClick:()=>t({confirmed:!1}),children:`拒绝`}),o]})]})]})}function GT({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,P.jsxs)(`div`,{className:`inline-edit`,"data-editing":`1`,children:[(0,P.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(Uw(e))return;e.preventDefault(),d()}else e.key===`Escape`&&(e.preventDefault(),l())},onBlur:()=>{s.current||r()}}),(0,P.jsx)(`button`,{type:`button`,className:`inline-edit-ok`,title:`确认重命名`,"aria-label":`确认重命名`,disabled:c,onMouseDown:e=>e.preventDefault(),onClick:d,children:`✓`}),(0,P.jsx)(`button`,{type:`button`,className:`inline-edit-cancel`,title:`取消重命名`,"aria-label":`取消重命名`,onMouseDown:e=>e.preventDefault(),onClick:l,children:`✗`})]})}function KT({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=_T(l?i.filter(e=>_===`*`||e.key!==qT&&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(Uw(e))return;e.preventDefault(),D&&(s(D.key),O(!0))}}},M=`picker-list-${c??e}`,N=t=>`picker-option-${c??e}-${t}`;return(0,P.jsxs)(`div`,{className:`session-picker-item session-picker-${e}`,ref:y,onKeyDown:d?j:void 0,children:[(0,P.jsxs)(`button`,{ref:b,type:`button`,className:`session-picker-trigger`,disabled:a,"aria-haspopup":`listbox`,"aria-expanded":d,title:o??`${lT[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,P.jsx)(`span`,{className:`session-picker-kind`,children:lT[e]}),(0,P.jsx)(`span`,{className:`session-picker-name`,children:t}),r&&(0,P.jsx)(`span`,{className:`session-picker-detail`,children:r}),(0,P.jsx)(`span`,{className:`session-picker-caret`,"aria-hidden":`true`,children:`▾`})]}),d&&(0,P.jsxs)(`div`,{className:`picker-menu`,ref:x,"data-picker-menu":e,"data-picker-highlight":E,children:[l&&(0,P.jsxs)(`label`,{className:`picker-provider-filter`,children:[(0,P.jsx)(`span`,{children:`Provider`}),(0,P.jsxs)(`select`,{"data-picker-provider":e,"aria-label":`筛选模型 Provider`,value:_,onKeyDown:e=>e.stopPropagation(),onChange:e=>{v(e.target.value),g(0)},children:[(0,P.jsx)(`option`,{value:`*`,children:`全部 Provider`}),l.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]})]}),(0,P.jsxs)(`div`,{className:`picker-filter`,children:[(0,P.jsx)(`span`,{className:`picker-filter-icon`,"aria-hidden":`true`,children:`🔍`}),(0,P.jsx)(`input`,{ref:S,className:`picker-filter-input`,"data-picker-filter":e,role:`combobox`,"aria-label":`筛选${dT[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,P.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,P.jsxs)(`div`,{className:`picker-current`,"data-picker-current":e,"data-picker-current-value":w.key,children:[(0,P.jsx)(`span`,{className:`picker-current-label`,children:`当前`}),(0,P.jsx)(`span`,{className:`picker-current-value`,children:w.label})]}),(0,P.jsxs)(`div`,{className:`picker-list`,role:`listbox`,id:M,"aria-label":pT[e],children:[T.map((e,t)=>(0,P.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,P.jsx)(`span`,{className:`picker-option-swatch`,style:{background:e.color},"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:`picker-option-name`,children:e.label}),e.badge&&(0,P.jsx)(`span`,{className:`picker-option-badge`,"data-picker-option-badge":e.badge,children:e.badge}),e.detail&&(0,P.jsx)(`span`,{className:`picker-option-detail`,children:e.detail}),e.selected&&(0,P.jsx)(`span`,{className:`picker-option-mark`,"aria-hidden":`true`,children:`✓`})]},e.key)),T.length===0&&(0,P.jsx)(`div`,{className:`picker-empty`,"data-picker-empty":e,children:i.length===0?fT[e]:`没有匹配「${p.trim()}」的${dT[e]}`})]})]})]})}var qT=`__pi_default__`;function JT({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:qT,label:`跟随 Pi 默认`,detail:`不为新会话指定模型`,selected:l===void 0},...(t?.models??[]).map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,Pw(e.contextWindow)?`${Pw(e.contextWindow)} 上下文`:``,Fw(e.maxTokens)?`${Fw(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:hT(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:qT,label:`跟随 Pi 默认`,detail:`不为新会话指定思考等级`,selected:f===void 0},..._.map(e=>({key:e,label:e,selected:e===f}))],y=e=>{if(e===qT){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===qT?void 0:e),x=[{key:qT,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,P.jsx)(`div`,{className:`overlay`,onClick:o,children:(0,P.jsxs)(`div`,{className:`picker settings-dialog`,"data-settings-dialog":`1`,onClick:e=>e.stopPropagation(),children:[(0,P.jsx)(`h2`,{children:`工作区设置`}),(0,P.jsxs)(`div`,{className:`settings-scope`,children:[e.name,` · 默认值只影响之后新建的会话,已有会话不变`]}),(0,P.jsx)(`div`,{className:`workspace-settings-path`,children:e.path}),(0,P.jsxs)(`div`,{className:`settings-row`,children:[(0,P.jsx)(`span`,{className:`settings-label`,children:`默认智能体`}),(0,P.jsx)(KT,{kind:`agent`,scope:`settings-agent`,label:n?.agents.find(e=>e.id===s)?.name??`跟随 Pi 默认`,value:s??qT,detail:s?`${n?.agents.find(e=>e.id===s)?.toolSummary??``}`:void 0,options:x,disabled:!n||n.source===`unavailable`,note:wT(n),onChoose:e=>c(e===qT?void 0:e)})]}),(0,P.jsxs)(`div`,{className:`settings-row`,children:[(0,P.jsx)(`span`,{className:`settings-label`,children:`默认模型`}),(0,P.jsx)(KT,{kind:`model`,scope:`settings-model`,label:l?.label??`跟随 Pi 默认`,value:l?`${l.provider}/${l.modelId}`:qT,detail:l?`${l.provider}/${l.modelId}`:void 0,options:h,providerOptions:[...new Set((t?.models??[]).map(e=>e.provider))],disabled:!m,note:CT(`模型`,t),onChoose:y})]}),(0,P.jsxs)(`div`,{className:`settings-row`,children:[(0,P.jsx)(`span`,{className:`settings-label`,children:`思考强度`}),(0,P.jsx)(KT,{kind:`thinking`,scope:`settings-thinking`,label:f??`跟随 Pi 默认`,value:f??qT,options:v,disabled:!m,note:CT(`思考等级`,t),onChoose:b})]}),l&&g&&_.length===0&&(0,P.jsx)(`div`,{className:`settings-scope`,children:`Pi 未提供此模型的可选等级,使用模型默认值。`}),(0,P.jsxs)(`div`,{className:`picker-actions`,children:[(0,P.jsx)(`button`,{type:`button`,className:`settings-rename`,"data-settings-rename":`1`,onClick:i,children:`重命名工作区`}),(0,P.jsx)(`button`,{type:`button`,className:`picker-cancel`,"data-settings-cancel":`1`,onClick:o,children:`取消`}),(0,P.jsx)(`button`,{type:`button`,className:`picker-ok`,"data-settings-save":`1`,onClick:()=>r(s,l,f),children:`保存`})]}),(0,P.jsx)(`button`,{type:`button`,className:`workspace-delete`,onClick:a,children:`从列表移除工作区`})]})})}var YT=[{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:`terminal`,label:`终端`,name:`终端 tab`}],XT=`super-pi.right-tabs.v1`;function ZT(){let e=e=>YT.some(t=>t.id===e),t={tab:YT[0].id,byConversation:{}};try{let n=JSON.parse(window.sessionStorage.getItem(XT)??`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 QT={waiting:`⋯`,running:``,failed:``,question:`?`,completed:``,unread:`•`,idle:``,awaiting_background:`⚙`,pending_report:`↑`,awaiting_subordinates:`↓`,awaiting_decision:`▲`},$T={idle:`空闲`,running:`讨论中`,awaiting_background:`后台任务进行中`,completed:`讨论已完成`,failed:`讨论未完成`},eE={waiting:`等待 LLM`,running:`进行中`,failed:`出错`,question:`等你回答`,completed:`已完成`,unread:`有未读`,idle:`空闲`,awaiting_background:`等待后台任务`,pending_report:`待汇报`,awaiting_subordinates:`等待下级`,awaiting_decision:`等上面拍板`},tE={idle:`就绪`,waiting:`等待 LLM`,running:`正在生成`,completed:`已完成`,stopped:`已停止`,failed:`运行失败`,awaiting_background:`等待后台任务`},nE=e=>e?.status===`running`||e?.status===`waiting`,rE={running:`运行中`,completed:`已完成`,failed:`失败`,stopped:`已停止`,cancelled:`已取消`,interrupted:`已中断`},iE={select:`请选择一项`,confirm:`请确认`,input:`请输入内容`,editor:`请输入内容`,notify:`扩展通知`,setStatus:`扩展状态`,setWidget:`扩展内容`,setTitle:`扩展标题`,set_editor_text:`扩展输入`};function aE(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 oE(e,t,n){let r=(t||[]).filter(t=>t.parentConversationId===e.id),i=(t||[]).find(t=>t.id===e.parentConversationId),a=n??``;return BS({conversation:e,parent:i,directChildren:r,isTopLevelUnread:e.updatedAt>a})}function sE(e,t,n,r){let i=oE(e,r,n);return VS({status:e.status,reportingState:i,awaitingQuestion:t,quietWhenRead:!0})}function cE(e,t){return t===`awaiting_decision`||e===`awaiting_decision`?(0,P.jsx)(`span`,{className:`conversation-status-badge badge--warning project-status-awaiting_decision`,"data-session-status":`awaiting_decision`,"data-reporting-badge":`awaiting_decision`,title:eE.awaiting_decision,children:eE.awaiting_decision}):t===`awaiting_subordinates`||e===`awaiting_subordinates`?(0,P.jsx)(`span`,{className:`conversation-status-badge project-status-awaiting_subordinates`,"data-session-status":`awaiting_subordinates`,"data-reporting-badge":`awaiting_subordinates`,title:eE.awaiting_subordinates,children:eE.awaiting_subordinates}):t===`pending_report`||e===`pending_report`?(0,P.jsx)(`span`,{className:`conversation-status-badge project-status-pending_report`,"data-session-status":`pending_report`,"data-reporting-badge":`pending_report`,title:eE.pending_report,children:eE.pending_report}):null}function lE({state:e,label:t=eE[e]}){let n=QT[e];if(e===`idle`)return null;let r=e.replace(/_/g,`-`);return(0,P.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,P.jsx)(`i`,{className:`session-state-mark`,"aria-hidden":`true`,children:n})})}function uE(e,t){return(0,P.jsxs)(P.Fragment,{children:[e.origin===`orchestrator`&&(0,P.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`orchestrator`,title:`编排会话:由上级智能体创建`,"aria-label":`编排会话:由上级智能体创建`,children:`编排`}),t&&(0,P.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`scheduled`,title:`定时任务会话:${t.name}`,"aria-label":`定时任务会话:${t.name}`,children:`定时`})]})}function dE(e,t){let n=[];return e.origin===`orchestrator`&&n.push(`编排会话`),t&&n.push(`定时任务会话:${t.name}`),n.length?`(${n.join(`;`)})`:``}var fE={pending:`未开始`,in_progress:`运行中`,completed:`已完成`},pE={pending:`○`,in_progress:`◐`,completed:`✓`},mE={high:`高`,medium:`中`,low:`低`};function hE(e){let t=e.filter(e=>e.status!==`completed`).length;return e.length?t?`${t} 个未完成 / 共 ${e.length} 个`:`全部完成:${e.length} 个`:`0 个待办任务`}function gE({todo:e,index:t}){let n=e.id??`todo_${t}`;return(0,P.jsxs)(`li`,{className:`todo-item todo-${e.status}`,"data-todo-item":n,"data-todo-status":e.status,title:`状态:${fE[e.status]}`,children:[(0,P.jsx)(`span`,{className:`todo-mark`,"aria-hidden":`true`,children:pE[e.status]}),(0,P.jsx)(`span`,{className:`todo-text`,children:e.content}),(0,P.jsx)(`span`,{className:`todo-status`,"data-todo-status-text":`1`,children:fE[e.status]}),e.priority&&(0,P.jsx)(`span`,{className:`todo-priority`,"data-todo-priority":e.priority,children:mE[e.priority]})]})}function _E(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 vE({tasks:e,runs:t,execOutputs:n,onStop:r}){return(0,P.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?rE[o]??(/[\u3400-\u9fff]/.test(o)?o:`未知状态`):`未知状态`;return(0,P.jsx)(yE,{task:e,status:s,run:t?.get(e.id),execOutputs:n,onStop:r},a)})})}function yE({task:e,status:t,run:n,execOutputs:r,onStop:i}){let[a,o]=(0,u.useState)(!1),s=kT(e.id,r),c=n?zw(n):s?.text||e.output,l=c&&Rw(c),d=n?n.outputTruncated||n.toolCalls?.some(e=>e.outputTruncated):s?.truncated??e.outputTruncated;return(0,P.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,P.jsxs)(`button`,{type:`button`,className:`bg-item-toggle`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-label":`展开后台任务详情`,children:[(0,P.jsx)(`span`,{className:`bg-title`,children:e.title?.trim()||e.id||`未命名任务`}),(0,P.jsxs)(`span`,{className:`bg-meta`,children:[e.agentId?.trim()&&(0,P.jsx)(`span`,{className:`bg-agent`,"data-bg-agent":e.agentId,children:e.agentId}),(0,P.jsx)(`span`,{className:`bg-status`,children:t})]})]}),i&&(0,P.jsx)(`button`,{type:`button`,className:`bg-stop-btn`,"data-bg-task-stop":e.id,title:`终止后台任务`,onClick:()=>i(e.id),children:`终止`}),a&&(0,P.jsx)(`pre`,{className:`bg-output`,"data-bg-output":e.id,children:[d?`日志仅保留最近一段。`:``,l].filter(Boolean).join(`
|
|
339
339
|
|
|
340
|
-
`)||`运行中,暂无输出`})]})}var bE=(0,u.lazy)(()=>Bu(()=>import(`./GitDiffEditor-
|
|
340
|
+
`)||`运行中,暂无输出`})]})}var bE=(0,u.lazy)(()=>Bu(()=>import(`./GitDiffEditor-CNCMPKVv.js`),__vite__mapDeps([4,1,0,2,5,3,6])));function xE({todos:e,tasks:t,backgroundRuns:n,execOutputs:r,scheduledTasks:i,scheduledCatalog:a,scheduledAgents:o,collapsed:s,onToggle:c,workspaceId:l,workspaceLabel:u,workspaceName:d,cwd:f=``,conversationId:p,followedWorktreeId:m,connected:h,files:g,onOpenFile:_,onOpenChanged:v,onOpenGitDiff:y,activeGitDiffUrl:b,onFileReference:x,onFilesMoved:S,onSearchFolder:C,activeTab:w,onSelectTab:T,sendCommand:E,registerTerminalSink:D,terminalShell:O,notify:k,serverTimeZone:A,onOpenSession:j,side:M,onArrange:N,pinned:ee=!0,sharedGit:te}){let ne=YT,re=M===`left`;return(0,P.jsx)(`div`,{className:`right-rail${M?` workbench-panel workbench-panel-`+M:``}${s?` right-rail-collapsed`:``}`,role:`complementary`,"aria-label":re?`左侧栏`:`右侧栏`,"data-right-rail":re?void 0:`1`,"data-right-rail-collapsed":s,"data-workbench-panel":M,hidden:M&&s?!0:void 0,children:s?!M&&(0,P.jsx)(`button`,{type:`button`,className:`right-rail-open`,"data-right-rail-open":`1`,title:`展开右侧栏`,"aria-label":`展开右侧栏`,onClick:c,children:`‹`}):(0,P.jsxs)(P.Fragment,{children:[M?(0,P.jsxs)(`div`,{className:`workbench-panel-heading`,children:[(0,P.jsx)(`h2`,{children:oe[w]}),N&&(0,P.jsx)(_e,{view:w,side:M,pinned:ee,onArrange:N}),(0,P.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-right-rail-collapse":re?void 0:`1`,title:re?`收起左侧栏`:`收起右侧栏`,"aria-label":re?`收起左侧栏`:`收起右侧栏`,onClick:c,children:(0,P.jsx)(I,{name:`close`})})]}):(0,P.jsxs)(`div`,{className:`right-rail-head`,children:[(0,P.jsx)(`div`,{className:`right-tabs`,role:`tablist`,"aria-label":`右侧栏 tab`,"data-right-tab-count":ne.length,children:ne.map(e=>(0,P.jsx)(`button`,{type:`button`,role:`tab`,id:`right-tab-${e.id}`,className:`right-tab${e.id===w?` right-tab-active`:``}`,"data-right-tab":e.id,"aria-selected":e.id===w,"aria-controls":`right-panel-${e.id}`,title:e.name,"aria-label":e.name,onClick:()=>T(e.id),children:e.label},e.id))}),(0,P.jsx)(`button`,{type:`button`,className:`right-rail-collapse`,"data-right-rail-collapse":`1`,title:`收起右侧栏(聊天区会变宽)`,"aria-label":`收起右侧栏`,onClick:c,children:`›`})]}),YT.filter(e=>e.id===w).map(s=>(0,P.jsxs)(`div`,{className:`right-rail-body`,role:`tabpanel`,id:`right-panel-${s.id}`,"aria-label":M?oe[s.id]:void 0,"aria-labelledby":M?void 0:`right-tab-${s.id}`,"data-right-panel":s.id,children:[s.id===`main`&&(0,P.jsxs)(P.Fragment,{children:[(e.length>0||t.length>0)&&(0,P.jsxs)(`p`,{className:`rail-legend`,"data-rail-legend":`1`,children:[(0,P.jsx)(`span`,{className:`rail-legend-label`,children:`左侧竖条=状态`}),(0,P.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,P.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-pending`,"aria-hidden":`true`}),`未开始`]}),(0,P.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,P.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-running`,"aria-hidden":`true`}),`运行中`]}),(0,P.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,P.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-done`,"aria-hidden":`true`}),`已完成`]})]}),(0,P.jsxs)(`div`,{className:`rail-task-sections`,children:[(0,P.jsx)(Lx,{id:`todos`,title:`待办任务`,icon:`tasks`,count:(0,P.jsx)(`span`,{"data-todo-summary":`1`,children:hE(e)}),children:e.length>0?(0,P.jsx)(`ol`,{className:`todo-list`,"data-todo-count":e.length,children:e.map((e,t)=>(0,P.jsx)(gE,{todo:e,index:t},e.id??`todo_${t}`))}):(0,P.jsx)(`p`,{className:`rail-empty`,"data-todo-empty":`1`,children:`暂无待办任务。开始多步骤任务后会自动显示。`})}),(0,P.jsx)(Lx,{id:`background`,title:`后台任务`,icon:`activity`,count:(0,P.jsx)(`span`,{"data-bg-summary":`1`,children:t.length?`${t.filter(e=>e.status===`running`).length} 个运行中 / 共 ${t.length} 个`:`0 个`}),children:t.length>0?(0,P.jsx)(vE,{tasks:t,runs:n,execOutputs:r,onStop:e=>E({type:`backgroundTask.stop`,taskId:e})}):(0,P.jsx)(`p`,{className:`rail-empty`,"data-bg-empty":`1`,children:`当前没有正在运行的后台任务。`})}),(0,P.jsx)(Zx,{tasks:i,workspaceId:l,catalog:a,agents:o,sendCommand:E,notify:k,serverTimeZone:A})]})]}),s.id===`projects`&&(0,P.jsx)(IS,{workspaceId:l,notify:k,onOpenSession:j,onOpenFile:_,cwd:f},l),s.id===`tools`&&(0,P.jsx)(SE,{workspaceId:l},l),s.id===`files`&&(0,P.jsx)(Qd,{workspaceId:l,workspaceName:d,cwd:f,files:g,onOpenFile:_,onOpenChanged:v,onReference:x,onMoved:S,onSearchFolder:C}),s.id===`git`&&(0,P.jsx)(vn,{workspaceId:l??null,conversationId:p,cwd:f,followedWorktreeId:m,onOpenDiff:e=>y({...e,comparison:d?`${d} · ${e.comparison}`:e.comparison}),activeDiffUrl:b,onOpenConversation:j,sharedGit:te},JSON.stringify([l,f,p])),s.id===`terminal`&&(0,P.jsx)(Ix,{workspaceId:l,workspaceLabel:u,cwd:f,conversationId:p,connected:h,sendCommand:E,registerSink:D,terminalShell:O},JSON.stringify([l,p]))]},s.id))]})})}function SE({workspaceId:e}){let{tools:t,mountedTools:n,openToolId:r,shortcuts:i}=gw(),[a,o]=(0,u.useState)(),s=async e=>{o(void 0);let t=await yw(e);t&&o(`移除工具失败:${j(t)}`)},c=(e,t)=>t?`打开${e}(快捷键 ${GC(t)})`:`打开${e}`;return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`rail-section-head`,children:[(0,P.jsx)(`h2`,{className:`rail-section-title`,children:`工具`}),(0,P.jsxs)(`span`,{className:`rail-section-count`,"data-tool-summary":`1`,children:[t.length+n.length,` 个`]})]}),t.length+n.length>0?(0,P.jsxs)(`ul`,{className:`tool-grid`,"data-tool-count":t.length+n.length,children:[t.map(e=>(0,P.jsxs)(`li`,{className:`tool-slot`,children:[(0,P.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:()=>_w.toggleTool(e.id),children:[(0,P.jsx)(CC,{className:`tool-icon-glyph`,glyph:e.glyph}),(0,P.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,P.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${GC(i[e.id])}`,children:KC(i[e.id])}),e.kind===`link`&&(0,P.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>_w.removeTool(e.id),children:`✕`})]},e.id)),n.map(e=>(0,P.jsxs)(`li`,{className:`tool-slot`,children:[(0,P.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:()=>_w.toggleTool(e.id),children:[(0,P.jsx)(CC,{className:`tool-icon-glyph`,glyph:TC(e)}),(0,P.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,P.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${GC(i[e.id])}`,children:KC(i[e.id])}),(0,P.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,P.jsx)(`p`,{className:`rail-empty`,"data-tool-empty":`1`,children:`还没有工具。点下面的「工具设置」添加。`}),(0,P.jsx)(`button`,{type:`button`,className:`tools-settings-btn`,"data-tool-settings-trigger":`1`,title:`添加预置工具、网址工具、快捷键与说明`,"aria-label":`打开工具设置`,onClick:()=>_w.openSettings(),children:`⚙ 工具设置`}),a&&(0,P.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-error":`1`,children:a})]})}function CE({onClose:e}){let{tools:t,mountedTools:n,shortcuts:r}=gw(),[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(),[f,p]=(0,u.useState)(!1),[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)(),[E,D]=(0,u.useState)(!1),[O,k]=(0,u.useState)(),[A,M]=(0,u.useState)(),N=(0,u.useRef)(null),ee=(0,u.useRef)(null),[te,ne]=(0,u.useState)(),[re,ie]=(0,u.useState)(),F=(0,u.useRef)(null),[ae,oe]=(0,u.useState)(()=>{let e=cw();return!e||typeof window>`u`?e:uw(e,window.innerWidth,window.innerHeight)}),se=async()=>{let e=await dl(`请为 Super Pi 开发一个全局右侧栏工具。不要启动独立 HTTP 服务器,也不要监听端口。
|
|
341
341
|
|
|
342
342
|
工具不属于当前 workspace;通过内置 tool_register 一次性提交完整文件(index.html、JS/CSS,必要时 .py),并用 glyph 提供一个易辨识的短图标(1 至 4 个字符,例如 {}、∑、◷),Super Pi 会保存为全局工具并自动出现在每个 workspace 的工具 Tab。
|
|
343
343
|
|
package/dist/client/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<link rel="alternate icon" href="/favicon.ico" />
|
|
9
9
|
<link rel="apple-touch-icon" href="/favicon.svg" />
|
|
10
10
|
<title>Super Pi</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-WcUajwk6.js"></script>
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-BvAvBj_1.css">
|
|
14
14
|
</head>
|
|
@@ -1602,11 +1602,34 @@ export function createHttpServer(options) {
|
|
|
1602
1602
|
json(403, { error: "Git 写操作只允许来自本机或局域网的请求。" });
|
|
1603
1603
|
return;
|
|
1604
1604
|
}
|
|
1605
|
-
const asked = await readRequestText(request, 512000);
|
|
1605
|
+
const asked = await readRequestText(request, op === "diff-edit-save" ? MAX_FILE_BYTES * 2 : 512000);
|
|
1606
1606
|
if (asked.tooLarge) {
|
|
1607
1607
|
json(413, { error: "请求过大" });
|
|
1608
1608
|
return;
|
|
1609
1609
|
}
|
|
1610
|
+
if (op === "diff-edit-save") {
|
|
1611
|
+
const body = asked.text ? JSON.parse(asked.text) : {};
|
|
1612
|
+
if (!body || typeof body !== "object" || Array.isArray(body)
|
|
1613
|
+
|| typeof body.path !== "string" || typeof body.content !== "string"
|
|
1614
|
+
|| typeof body.baseEtag !== "string") {
|
|
1615
|
+
json(400, { error: "差异保存需要 path、content 和 baseEtag", code: "bad_request" });
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
const worktreeId = url.searchParams.get("worktreeId");
|
|
1619
|
+
if (worktreeId !== null && !/^[a-f0-9]{64}$/.test(worktreeId)) {
|
|
1620
|
+
json(400, { error: "请先选择有效工作树", code: "bad_worktree" });
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
const checkout = worktreeId ? await resolveGitWorktree(workspace.path, worktreeId) : undefined;
|
|
1624
|
+
const editRoot = checkout?.path ?? workspace.path;
|
|
1625
|
+
const editSession = checkout?.path ?? sessionRoot;
|
|
1626
|
+
await explorerPath(editRoot, editSession, body.path, true);
|
|
1627
|
+
const path = await workspacePathFromSession(editRoot, editSession, body.path);
|
|
1628
|
+
const saved = await serializeWorkspaceWrite(workspace.path, () => writeWorkspaceFile(editRoot, path, body.content, body.baseEtag));
|
|
1629
|
+
broadcaster.broadcast({ type: "files.invalidated", workspaceId: workspace.id, paths: checkout ? [] : [path] });
|
|
1630
|
+
json(200, saved);
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1610
1633
|
if (op === "draft") {
|
|
1611
1634
|
if (!context.runtime?.askOnce) {
|
|
1612
1635
|
json(503, { error: "未配置可生成提交说明的模型" });
|
|
@@ -1690,11 +1713,19 @@ export function createHttpServer(options) {
|
|
|
1690
1713
|
json(400, { error: "差异编辑需要 path", code: "bad_path" });
|
|
1691
1714
|
return;
|
|
1692
1715
|
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1716
|
+
const worktreeId = url.searchParams.get("worktreeId");
|
|
1717
|
+
if (worktreeId !== null && !/^[a-f0-9]{64}$/.test(worktreeId)) {
|
|
1718
|
+
json(400, { error: "请先选择有效工作树", code: "bad_worktree" });
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
const checkout = worktreeId ? await resolveGitWorktree(workspace.path, worktreeId) : undefined;
|
|
1722
|
+
const editRoot = checkout?.path ?? workspace.path;
|
|
1723
|
+
const editSession = checkout?.path ?? sessionRoot;
|
|
1724
|
+
await explorerPath(editRoot, editSession, requested, true);
|
|
1725
|
+
const path = await workspacePathFromSession(editRoot, editSession, requested);
|
|
1695
1726
|
const [original, file] = await Promise.all([
|
|
1696
|
-
gitIndexFileContent(
|
|
1697
|
-
readWorkspaceFile(
|
|
1727
|
+
gitIndexFileContent(editRoot, path),
|
|
1728
|
+
readWorkspaceFile(editRoot, path),
|
|
1698
1729
|
]);
|
|
1699
1730
|
json(200, { path: file.path, original, content: file.content, eol: file.eol, bom: file.bom, meta: file.meta });
|
|
1700
1731
|
}
|