@evandu/super-pi 0.1.266 → 0.1.268

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D978o95T.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-DlPa5gNa.js","assets/CodeMirrorEditor-B1roGtGI.js","assets/GitDiffEditor-BdeOO3TB.js","assets/dist-ZAR1Tu2c.js","assets/dist-i79xiXVk.js","assets/GitDiffEditor-CpoDDQrA.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D978o95T.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-DlPa5gNa.js","assets/CodeMirrorEditor-CtY_gf8i.js","assets/GitDiffEditor-CtSWZrJJ.js","assets/dist-ZAR1Tu2c.js","assets/dist-i79xiXVk.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 F(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(F.bind(null,e))}var ie={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=ie,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=F,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`),F=Symbol.for(`react.memo`),ie=Symbol.for(`react.lazy`),ae=Symbol.for(`react.activity`),oe=Symbol.for(`react.legacy_hidden`),se=Symbol.for(`react.memo_cache_sentinel`),ce=Symbol.for(`react.view_transition`),le=Symbol.for(`react.recoverable`),ue=Symbol.iterator;function de(e){return typeof e!=`object`||!e?null:(e=ue&&e[ue]||e[`@@iterator`],typeof e==`function`?e:null)}var fe=Symbol.for(`react.client.reference`);function pe(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===fe?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case 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 F:return t=e.displayName||null,t===null?pe(e.type)||`Memo`:t;case ie:t=e._payload,e=e._init;try{return pe(e(t))}catch{}}return null}var me=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,he=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ge={pending:!1,data:null,method:null,action:null},_e=[],ve=-1;function ye(e){return{current:e}}function be(e){0>ve||(e.current=_e[ve],_e[ve]=null,ve--)}function xe(e,t){ve++,_e[ve]=e.current,e.current=t}var Se=ye(null),Ce=ye(null),we=ye(null),Te=ye(null);function Ee(e,t){switch(xe(we,t),xe(Ce,e),xe(Se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?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 De(){be(Se),be(Ce),be(we)}function Oe(e){var t=e.memoizedState;t!==null&&(lh._currentValue=t.memoizedState,xe(Te,e)),t=Se.current;var n=pp(t,e.type);t!==n&&(xe(Ce,e),xe(Se,n))}function ke(e){Ce.current===e&&(be(Se),be(Ce)),Te.current===e&&(be(Te),lh._currentValue=ge)}var Ae,je;function Me(e){if(Ae===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ae=t&&t[1]||``,je=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+Ae+e+je}var Ne=!1;function Pe(e,t){if(!e||Ne)return``;Ne=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -19,7 +19,7 @@ Error generating stack: `+e.message+`
19
19
  `),t)});continue}let c=Un(n,i);if(c){c.prefix&&r.push({type:`paragraph`,children:jn(c.prefix,t)});let e=Kn(c.header),a=Kn(n[i+1]).map(qn),o=[];for(i+=2;i<n.length&&n[i].trim()&&n[i].includes(`|`);)o.push(Jn(Kn(n[i]),e.length).map(e=>jn(e,t))),i+=1;r.push({type:`table`,head:e.map(e=>jn(e,t)),align:a,rows:o});continue}if(Fn.test(e)||In.test(e)){let e=Gn(n,i,t);r.push(e.node),i=e.next;continue}let l=[];for(;i<n.length&&n[i].trim()&&!Wn(n,i);)l.push(n[i]),i+=1;l.length||(l.push(n[i]),i+=1),r.push({type:`paragraph`,children:jn(l.join(`
20
20
  `),t)})}return r}function Un(e,t){let n=e[t],r=e[t+1];if(!n?.includes(`|`)||!r||!Rn.test(r)||!r.includes(`-`))return;if(Kn(n).length===Kn(r).length)return{header:n};let i=n.indexOf(`|`);if(i<=0)return{header:n};let a=n.slice(0,i).trim(),o=n.slice(i);if(a&&Kn(o).length===Kn(r).length)return{header:o,prefix:a}}function Wn(e,t){let n=e[t];return Mn.test(n)||Nn.test(n)||Pn.test(n)||Ln.test(n)||!!Un(e,t)||Fn.test(n)||In.test(n)||zn.test(n)}function Gn(e,t,n){let r=In.test(e[t]),i=r?In.exec(e[t]):Fn.exec(e[t]),a=i[1].length,o=[],s=t;for(;s<e.length;){let t=Fn.exec(e[s]),i=In.exec(e[s]),c=r?i:t;if(!c)break;let l=c[1].length;if(l<a)break;let u=[c[c.length-1]];for(s+=1;s<e.length;){let n=e[s];if(!n.trim()){let t=e[s+1]??``;if(!t.trim()||t.search(/\S/)<=l)break;u.push(``),s+=1;continue}let r=n.search(/\S/);if(r===0&&t||r===0&&i)break;if(r>l)u.push(n.slice(Math.min(r,l+2))),s+=1;else if(r===l){if(Wn(e,s))break;u.push(n),s+=1}else break}o.push(Hn(u.join(`
21
21
  `),n))}return{node:{type:`list`,ordered:r,start:r?Number(i[2]):1,items:o},next:s}}function Kn(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),t.endsWith(`|`)&&!t.endsWith(`\\|`)&&(t=t.slice(0,-1));let n=[],r=``;for(let e=0;e<t.length;e+=1){let i=An(t,e);if(i)r+=t.slice(e,i.next),e=i.next-1;else if(t[e]==="`"){let n=bn(t,e,"`"),i=Sn(t,e+n,n),a=i===-1?e+n:i+n;r+=t.slice(e,a),e=a-1}else t[e]===`\\`&&t[e+1]===`|`?(r+=`|`,e+=1):t[e]===`|`?(n.push(r.trim()),r=``):r+=t[e]}return n.push(r.trim()),n}function qn(e){let t=e.startsWith(`:`),n=e.endsWith(`:`);return t&&n?`center`:n?`right`:t?`left`:null}function Jn(e,t){let n=e.slice(0,t);for(;n.length<t;)n.push(``);return n}var Yn=[{kind:`calculator`,name:`计算器`,glyph:`∑`,blurb:`算术表达式,四则运算与乘方。除零会明确报错。`},{kind:`timestamp`,name:`时间戳`,glyph:`◷`,blurb:`Unix 时间戳与日期互转,本地计算,不联网。`}],Xn=[{id:`preset_calculator`,kind:`calculator`,name:`计算器`,glyph:`∑`}],Zn=40,Qn=2048,$n=`super-pi:tools:v1`;function er(e){return typeof e==`string`?e.replace(/\s+/g,` `).trim().slice(0,Zn):``}function tr(e){let t=e.trim();if(!t)return{ok:!1,reason:`请填写网址。`};if(t.length>Qn)return{ok:!1,reason:`网址太长了,请控制在 ${Qn} 个字符以内。`};let n=_n(t);return n?{ok:!0,url:n}:{ok:!1,reason:`这个网址不是允许的协议。只支持 http / https / mailto 开头的网址。`}}function nr(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];let n=[],r=new Set;for(let e of t){if(n.length>=32)break;if(typeof e!=`object`||!e)continue;let t=e,i=t.kind;if(typeof i!=`string`||i!==`calculator`&&i!==`timestamp`&&i!==`link`)continue;let a=er(t.name);if(!a)continue;let o=typeof t.glyph==`string`&&t.glyph.trim()?t.glyph.trim().slice(0,4):``;if(!o)continue;let s=typeof t.id==`string`&&t.id.trim()?t.id.trim().slice(0,64):``;if(s&&!r.has(s)){if(i===`link`){let e=_n(typeof t.url==`string`?t.url:``);if(!e)continue;r.add(s),n.push({id:s,kind:`link`,name:a,glyph:o,url:e})}else r.add(s),n.push({id:s,kind:i,name:a,glyph:o})}}return n}function rr(e){return JSON.stringify(e.map(e=>e.kind===`link`?{...e}:{id:e.id,kind:e.kind,name:e.name,glyph:e.glyph}))}function ir(){let e=typeof globalThis<`u`?globalThis.crypto:void 0;return typeof e?.randomUUID==`function`?e.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function ar(e,t){let n=e===`link`?`link`:`preset_${e}`,r=ir().replace(/-/g,``).slice(0,8),i=`${n}_${r}`,a=1;for(;t.includes(i);)i=`${n}_${r}_${a}`,a+=1;return i}function or(e,t){if(e.some(e=>e.kind===t))return e.slice();let n=Yn.find(e=>e.kind===t);return n?[...e,{id:ar(t,e.map(e=>e.id)),kind:t,name:n.name,glyph:n.glyph}]:e.slice()}function sr(e,t){return e.filter(e=>e.id!==t)}var cr=e=>({ok:!1,reason:e}),lr=`除数不能为 0:除以零没有结果,请换一个非零的除数。`,ur=new Set([`/`,`%`]),dr=e=>e!==void 0&&e>=`0`&&e<=`9`,fr=e=>e!==void 0&&/\s/.test(e);function pr(e){for(;fr(e.source[e.at]);)e.at+=1}function mr(e){let t=e.at,n=0;for(;dr(e.source[e.at]);)e.at+=1,n+=1;if(e.source[e.at]===`.`)for(e.at+=1;dr(e.source[e.at]);)e.at+=1,n+=1;if(!n)return e.at=t,cr(`「${e.source[t]}」不是有效的数字。`);let r=Number(e.source.slice(t,e.at));return Number.isFinite(r)?{ok:!0,value:r}:cr(`数字太长了,无法表示。`)}function hr(e){pr(e);let t=e.source[e.at];if(t===void 0)return cr(`算式不完整:末尾还缺一个数字或右括号。`);if(t===`(`){e.at+=1;let t=yr(e);return t.ok?(pr(e),e.source[e.at]===`)`?(e.at+=1,t):cr(`括号不匹配:少了一个右括号「)」。`)):t}return dr(t)||t===`.`?mr(e):cr(`无法识别的字符「${t}」。`)}function gr(e){let t=hr(e);if(!t.ok||(pr(e),e.source[e.at]!==`^`))return t;e.at+=1;let n=_r(e);if(!n.ok)return n;let r=t.value**n.value;return Number.isFinite(r)?{ok:!0,value:r}:cr(`结果超出了可计算的数值范围。`)}function _r(e){pr(e);let t=e.source[e.at];if(t!==`+`&&t!==`-`)return gr(e);e.at+=1;let n=_r(e);if(!n.ok)return n;let r=t===`-`?-n.value:n.value;return Number.isFinite(r)?{ok:!0,value:r}:cr(`结果超出了可计算的数值范围。`)}function vr(e){let t=_r(e);if(!t.ok)return t;for(;;){pr(e);let n=e.source[e.at];if(n!==`*`&&!ur.has(n))return t;e.at+=1;let r=_r(e);if(!r.ok)return r;if(ur.has(n)&&r.value===0)return cr(lr);let i=n===`*`?t.value*r.value:n===`%`?t.value%r.value:t.value/r.value;if(!Number.isFinite(i))return cr(`结果超出了可计算的数值范围。`);t={ok:!0,value:i}}}function yr(e){let t=vr(e);if(!t.ok)return t;for(;;){pr(e);let n=e.source[e.at];if(n!==`+`&&n!==`-`)return t;e.at+=1;let r=vr(e);if(!r.ok)return r;let i=n===`+`?t.value+r.value:t.value-r.value;if(!Number.isFinite(i))return cr(`结果超出了可计算的数值范围。`);t={ok:!0,value:i}}}function br(e){let t=e.trim();if(!t)return cr(`请输入算式。`);if(t.length>200)return cr(`算式太长了,请控制在 200 个字符以内。`);let n={source:t,at:0},r=yr(n);return r.ok?(pr(n),n.at===t.length?Number.isFinite(r.value)?r:cr(`结果不是有限数字。`):cr(`「${t[n.at]}」后面的内容无法识别,请检查是否漏了运算符。`)):r}function xr(e){return String(!Number.isFinite(e)||Number.isInteger(e)&&Math.abs(e)<1e21?e:Number(e.toPrecision(12)))}function Sr(e){let t=e.trim();if(!t)return{ok:!1,reason:`请输入时间戳或日期。`};if(/^-?\d+$/.test(t)){let e=Number(t);if(!Number.isFinite(e))return{ok:!1,reason:`这个数字太大,无法表示。`};let n=t.replace(`-`,``).length<=11?e*1e3:e;return!Number.isFinite(n)||Math.abs(n)>864e13?{ok:!1,reason:`这个时间戳超出了日期能表示的范围。`}:{ok:!0,ms:n}}let n=Date.parse(t);return Number.isNaN(n)?{ok:!1,reason:`看不懂这个日期。试试 1757000000、2026-10-08 或 2026-10-08T09:00:00。`}:{ok:!0,ms:n}}var Cr=e=>String(Math.abs(e)).padStart(2,`0`);function wr(e){let t=new Date(e);return Number.isNaN(t.getTime())?null:{local:`${t.getFullYear()}-${Cr(t.getMonth()+1)}-${Cr(t.getDate())} ${Cr(t.getHours())}:${Cr(t.getMinutes())}:${Cr(t.getSeconds())}`,iso:t.toISOString(),seconds:String(Math.floor(e/1e3)),milliseconds:String(e)}}function Tr(e){let t=new Map,n=[],r=0,i=1,a=(e,t)=>{let r=t??n.indexOf(!1),a=r<0?n.length:r;return n[a]=!0,i=Math.max(i,a+1),{index:a,color:e}},o=e.map(({hash:e,parents:i})=>{let o=t.get(e),s=o??a(r++);t.delete(e),n[s.index]=!1;let c=[...t.values()],l=[...new Set(i)].map((e,n)=>{let i=t.get(e);return i||(i=n===0?a(s.color,s.index):a(r++),t.set(e,i)),{hash:e,lane:i}});return{node:s,incoming:o!==void 0,through:c,parents:l}});return{columns:i,rows:o}}function Er(e,t){if(t===`untracked`||e.startsWith(`?`))return{label:`?`,kind:`untracked`,slot:`index`};let n=(t===`staged`?e[0]:e[1])||e[0]||`M`;return n===`A`?{label:`A`,kind:`added`,slot:t===`staged`?`index`:`worktree`}:n===`D`?{label:`D`,kind:`deleted`,slot:t===`staged`?`index`:`worktree`}:n===`R`?{label:`R`,kind:`renamed`,slot:t===`staged`?`index`:`worktree`}:{label:`M`,kind:`modified`,slot:t===`staged`?`index`:`worktree`}}var Dr=e=>e.path.endsWith(`/`),Or=[{id:`changes`,title:`工作区改动`,search:`搜索文件名或路径`,icon:`main`},{id:`log`,title:`提交历史`,search:`搜索提交说明或哈希`,icon:`update`},{id:`graph`,title:`提交图`,search:``,icon:`git`},{id:`branches`,title:`分支`,search:`搜索本地或远程分支`,icon:`git`},{id:`stash`,title:`Stash`,search:`搜索贮藏记录`,icon:`files`},{id:`worktrees`,title:`工作树`,search:``,icon:`worktree`}],kr=`请选择具体 session 以确定工作区`,Ar=e=>e===`changes`||e===`log`||e===`stash`,jr=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},Mr=15e3,Nr=(e,t)=>new jr(408,{error:`请求超时:${t/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function Pr(e,t,n=Mr){let r=new AbortController,i=setTimeout(()=>r.abort(),n);try{let n=t?.signal?AbortSignal.any([t.signal,r.signal]):r.signal,i=await ke(e,{...t,signal:n}),a;try{a=await i.json()}catch(e){if(i.ok)throw e}if(!i.ok)throw new jr(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw r.signal.aborted?Nr(e,n):t}finally{clearTimeout(i)}}var Fr=e=>e instanceof jr?e:new jr(0,{error:e instanceof Error?e.message:`读取失败`}),Ir=e=>encodeURIComponent(e),Lr=e=>e?`&cwd=${Ir(e)}`:``,Rr=(e,t)=>`/api/git?workspaceId=${Ir(e)}&op=status${Lr(t)}`,zr=(e,t,n,r)=>`/api/git?workspaceId=${Ir(e)}&op=diff&path=${Ir(t)}${n?`&staged=1`:``}${Lr(r)}`;async function Br(e,t,n={},r){let i=t===`draft`?35e3:[`fetch`,`pull`,`push`].includes(t)?65e3:Mr;return Pr(`/api/git?workspaceId=${Ir(e)}&op=${Ir(t)}${Lr(r)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(n)},i)}var Vr=20,Hr=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`})},Ur=e=>e.detached||e.branch===null?`(未在任何分支上)`:e.unborn?`${e.branch}(起始提交)`:e.branch,Wr=e=>{let t=[];return e.ahead!==null&&t.push(`↑${e.ahead}`),e.behind!==null&&t.push(`↓${e.behind}`),t.length===0?null:t.join(` `)},Gr=[{key:`staged`,title:`已暂存`},{key:`unstaged`,title:`未暂存`},{key:`untracked`,title:`未跟踪`}];function Kr({path:e,onCancel:t,onConfirm:n}){let r=(0,u.useRef)(null),i=(0,u.useRef)(null);(0,u.useEffect)(()=>{i.current?.focus();let e=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let a=(0,L.jsx)(`div`,{className:`overlay git-confirm-overlay`,"data-git-confirm-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{className:`picker git-confirm-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`git-confirm-title`,tabIndex:-1,ref:r,onClick:e=>e.stopPropagation(),onKeyDown:e=>{if(e.key!==`Tab`)return;let t=r.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), [tabindex]:not([tabindex='-1'])`));if(n.length===0)return;let i=n[0],a=n[n.length-1];e.shiftKey?document.activeElement===i&&(e.preventDefault(),a.focus()):document.activeElement===a&&(e.preventDefault(),i.focus())},"data-git-confirm-dialog":`1`,children:[(0,L.jsx)(`h2`,{id:`git-confirm-title`,className:`git-confirm-title`,children:`确认丢弃更改?`}),(0,L.jsx)(`p`,{className:`git-confirm-desc`,children:`即将丢弃以下文件的所有未暂存修改:`}),(0,L.jsx)(`div`,{className:`git-confirm-path`,"data-git-confirm-path":e,title:e,children:e}),(0,L.jsx)(`p`,{className:`git-confirm-warning`,"data-git-confirm-warning":`1`,children:`⚠ 丢弃后不可撤销,此文件的本地未暂存修改将永久丢失(无法找回)。`}),(0,L.jsxs)(`div`,{className:`git-confirm-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`picker-cancel git-confirm-cancel`,"data-git-confirm-cancel":`1`,ref:i,onClick:t,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,className:`git-confirm-danger`,"data-git-confirm-ok":`1`,onClick:n,children:`确认丢弃`})]})]})});return typeof document>`u`?a:(0,xt.createPortal)(a,document.body)}function qr(e,t,n){let r=e?Rr(e,t):``,[i,a]=(0,u.useState)(),o=(0,u.useRef)({scope:r,ticket:0,busy:!1});o.current.scope!==r&&(o.current={scope:r,ticket:0,busy:!1});let s=(0,u.useCallback)((e=!1)=>{let t=o.current;if(!r||t.scope!==r||!n||t.busy&&!e)return;t.busy=!0;let i=++t.ticket,s=()=>o.current===t&&t.ticket===i;Pr(r).then(e=>{s()&&(ei(Xr,r,e,16),a({scope:r,status:e,error:null}))}).catch(e=>{s()&&a({scope:r,status:null,error:Fr(e)})}).finally(()=>{s()&&(t.busy=!1)})},[r,n]);(0,u.useEffect)(()=>{let e=o.current;s(!0);let t=()=>{document.visibilityState===`visible`&&s()},n=window.setInterval(t,15e3);return window.addEventListener(`focus`,t),()=>{window.clearInterval(n),window.removeEventListener(`focus`,t),e.ticket++,e.busy=!1}},[s]);let c=(0,u.useCallback)(e=>{r&&o.current.scope===r&&(o.current.ticket++,o.current.busy=!1,ei(Xr,r,e,16),a({scope:r,status:e,error:null}))},[r]),l=i?.scope===r?i:void 0;return{status:l?l.status:Xr.get(r)??null,error:l?.error??null,refresh:s,publish:c}}function Jr(e,t,n={}){return`/api/git?${new URLSearchParams({workspaceId:e,op:t,...n})}`}function Yr(e,t,n,r,i){return Jr(e,i===void 0?`commit-detail`:`commit-diff`,{hash:n,...t?{cwd:t}:{},...r?{worktreeId:r}:{},...i===void 0?{}:{path:i}})}var Xr=new Map,Zr=new Map,Qr=new Map,$r=new Map;function ei(e,t,n,r){if(e.delete(t),e.set(t,n),e.size>r){let t=e.keys().next().value;t!==void 0&&e.delete(t)}}function ti(e){return e.length?`${e.length>1?`第一父提交`:`父提交`} ${e[0].slice(0,8)}`:`空树`}var ni={A:`新增`,M:`修改`,D:`删除`,R:`重命名`,C:`复制`,T:`类型更改`};function ri({commits:e,workspaceId:t,cwd:n,worktreeId:r,onDiff:i,graph:a}){let[o,s]=(0,u.useState)(),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(0),p=o&&e.some(e=>e.hash===o)?Yr(t,n,o,r):``;(0,u.useEffect)(()=>{if(!p||Qr.has(p))return;let e=new AbortController;return Pr(p,{signal:e.signal}).then(t=>{e.signal.aborted||(ei(Qr,p,t,40),l({url:p,detail:t}))}).catch(t=>{e.signal.aborted||l({url:p,error:Fr(t).message})}),()=>e.abort()},[p,d]);let m=Qr.get(p),h=c?.url===p?c:m?{detail:m}:void 0;return(0,L.jsx)(L.Fragment,{children:e.map((e,t)=>{let n=o===e.hash,c=n?h?.detail:void 0,u=c?ti(c.parents):``,d=a?.rows[t],p=`refs`in e?e.refs:[],m=`parents`in e&&e.parents.length>1;return(0,L.jsxs)(`div`,{className:d?`git-history-item git-graph-item`:`git-history-item`,style:d&&a?{minWidth:a.columns*ii+142}:void 0,children:[d&&a&&(0,L.jsx)(z,{row:d,columns:a.columns,merge:m}),(0,L.jsxs)(`button`,{type:`button`,className:`git-log-row`,"data-git-commit":e.hash,"aria-expanded":n,onClick:()=>{s(n?void 0:e.hash),l(void 0)},children:[(0,L.jsx)(`span`,{className:`git-log-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,L.jsx)(`span`,{className:`git-log-subject`,title:e.subject,children:e.subject||`(无提交说明)`}),(0,L.jsxs)(`span`,{className:`git-log-meta`,children:[(0,L.jsx)(`span`,{className:`git-log-hash`,title:e.hash,children:e.short}),(0,L.jsx)(`span`,{className:`git-log-author`,title:e.author,children:e.author}),(0,L.jsx)(`time`,{className:`git-log-date`,dateTime:e.date,title:e.date,children:Hr(e.date)})]}),(m||p.length>0)&&(0,L.jsxs)(`span`,{className:`git-graph-refs`,children:[m&&(0,L.jsx)(`span`,{className:`git-graph-ref`,children:`合并`}),p.slice(0,3).map(e=>(0,L.jsx)(oi,{refItem:e},e.checkoutId??`${e.kind}:${e.name}`)),p.length>3&&(0,L.jsxs)(`span`,{className:`git-graph-ref`,title:`展开提交查看全部引用`,children:[`+`,p.length-3]})]})]}),n&&(0,L.jsxs)(`div`,{className:`git-commit-changes`,"data-git-commit-changes":e.hash,children:[!h&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取提交中的文件…`}),h?.error&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,children:Bt(h.error,`读取提交失败。`)}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,onClick:()=>{l(void 0),f(e=>e+1)},children:`重试`})]}),c&&(0,L.jsxs)(L.Fragment,{children:[p.length>3&&(0,L.jsxs)(`details`,{className:`git-commit-extra`,children:[(0,L.jsxs)(`summary`,{children:[p.length,` 个引用`]}),(0,L.jsx)(`div`,{className:`git-graph-refs`,children:p.map(e=>(0,L.jsx)(oi,{refItem:e},e.checkoutId??`${e.kind}:${e.name}`))})]}),c.message.includes(`
22
- `)&&(0,L.jsxs)(`details`,{className:`git-commit-extra`,children:[(0,L.jsx)(`summary`,{children:`完整提交说明`}),(0,L.jsx)(`pre`,{children:c.message})]}),(0,L.jsxs)(`p`,{className:`git-scope-note`,title:c.parents[0],children:[c.files.length,` 个文件 · 对比`,u]}),!c.files.length&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`当前目录内没有文件改动。`}),c.files.map(t=>{let n=t.path.split(`/`).at(-1)??t.path,a=t.previousPath===void 0?t.path:`${t.previousPath} → ${t.path}`,o=ni[t.status[0]]??t.status;return(0,L.jsxs)(`button`,{type:`button`,className:`git-worktree-file git-commit-file`,"data-git-commit-file":t.path,title:`${o} · ${a}`,onClick:()=>i({hash:e.hash,base:u,file:t,worktreeId:r}),children:[(0,L.jsx)(qt,{path:t.path,size:15}),(0,L.jsxs)(`span`,{className:`git-commit-file-label`,children:[(0,L.jsx)(`span`,{children:n}),a!==n&&(0,L.jsx)(`small`,{children:a})]}),(0,L.jsx)(`span`,{className:`git-commit-file-status`,"aria-label":o,children:t.status[0]})]},t.path)})]})]})]},e.hash)})})}var ii=14,ai={head:`当前检出`,worktree:`工作树`,branch:`本地分支`,remote:`远程跟踪分支`,tag:`标签`,stash:`贮藏`};function oi({refItem:e}){let{kind:t,name:n}=e;return(0,L.jsxs)(`span`,{className:`git-graph-ref`,"data-git-graph-ref":t,title:`${ai[t]} · ${n}`,children:[t===`tag`||t===`worktree`?`${ai[t]} `:``,n]})}function z({row:e,columns:t,merge:n}){let r=e=>e*ii+ii/2,i=r(e.node.index),a=t*ii;return(0,L.jsxs)(`div`,{className:`git-graph-lines`,"aria-hidden":`true`,"data-git-graph-lane":e.node.index,"data-git-graph-incoming":e.incoming||void 0,children:[(0,L.jsxs)(`svg`,{className:`git-graph-top`,width:a,height:`32`,viewBox:`0 0 ${a} 32`,children:[e.through.map(e=>(0,L.jsx)(`path`,{"data-color":e.color%5,d:`M ${r(e.index)} 0 V 32`},e.index)),e.incoming&&(0,L.jsx)(`path`,{"data-color":e.node.color%5,d:`M ${i} 0 V 16`}),e.parents.map(({hash:e,lane:t},n)=>(0,L.jsx)(`path`,{"data-git-graph-parent":e,"data-color":t.color%5,d:`M ${i} 16 C ${i} 24 ${r(t.index)} 22 ${r(t.index)} 32`},n)),n?(0,L.jsx)(`rect`,{"data-color":e.node.color%5,x:i-3.5,y:`12.5`,width:`7`,height:`7`,rx:`1`}):(0,L.jsx)(`circle`,{"data-color":e.node.color%5,cx:i,cy:`16`,r:`3.5`})]}),(0,L.jsx)(`svg`,{className:`git-graph-tail`,width:a,viewBox:`0 0 ${a} 1`,preserveAspectRatio:`none`,children:[...e.through,...e.parents.map(e=>e.lane).filter(t=>!e.through.some(e=>e.index===t.index))].map(e=>(0,L.jsx)(`path`,{"data-color":e.color%5,d:`M ${r(e.index)} 0 V 1`},e.index))})]})}function si({workspaceId:e,cwd:t,revision:n,onDiff:r}){let i=Jr(e,`graph`,t?{cwd:t}:{}),[a,o]=(0,u.useState)(()=>({page:Zr.get(i),loading:!0})),s=(0,u.useRef)(void 0),c=(0,u.useCallback)(e=>{s.current?.abort();let t=new AbortController;s.current=t;let n=Zr.get(i);o(t=>({page:e??n??t.page,loading:!0}));let r=new URLSearchParams(e?{offset:String(e.commits.length),snapshot:e.snapshot,after:e.commits.at(-1)?.hash??``}:n?{knownSnapshot:n.snapshot}:{});Pr(`${i}&${r}`,{signal:t.signal}).then(r=>{if(t.signal.aborted)return;let a=`unchanged`in r?Zr.get(i)??n:e?{...r,commits:[...e.commits,...r.commits]}:r;a&&ei(Zr,i,a,8),o({page:a,loading:!1})}).catch(n=>{t.signal.aborted||o(t=>({page:t.page,error:Fr(n),loading:!1,append:!!e}))})},[i]);(0,u.useEffect)(()=>(c(),()=>s.current?.abort()),[c,n]);let l=a.page,d=(0,u.useMemo)(()=>l&&Tr(l.commits),[l]),f=a.error?.body.code===`graph_changed`;return(0,L.jsxs)(`section`,{className:`git-graph`,"data-git-graph":!0,"aria-label":`提交图`,"aria-busy":a.loading,children:[(0,L.jsx)(`p`,{className:`git-scope-note`,children:`仓库历史 · 文件差异按当前会话目录`}),l&&d&&l.commits.length>0&&(0,L.jsx)(`div`,{className:`git-graph-list`,tabIndex:0,role:`region`,"aria-label":`提交关系`,children:(0,L.jsx)(ri,{commits:l.commits,workspaceId:e,cwd:t,onDiff:r,graph:d})}),l&&!l.commits.length&&(0,L.jsx)(`p`,{className:`rail-empty`,children:`暂无提交记录。`}),a.error&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,children:Bt(a.error,`读取提交图失败。`)}),a.loading&&!l&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取提交图…`}),(a.error||l?.hasMore)&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action git-graph-more`,"data-git-graph-more":!0,disabled:a.loading,onClick:()=>c(f||a.error&&!a.append?void 0:l),children:a.loading?`读取中…`:f?`重新加载提交图`:a.error?`重试`:`加载更早的提交`})]})}function ci({workspaceId:e,conversationId:t,followedWorktreeId:n,revision:r,onDiff:i,onCommitDiff:a,onOpenConversation:o,repositoryOnly:s=!1}){let[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(``),p=`super-pi.git-worktree:${JSON.stringify([e,t])}`,[m,h]=(0,u.useState)(()=>{try{return window.sessionStorage.getItem(p)??n??``}catch{return n??``}}),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(0),O=(0,u.useRef)(n),k=c?.find(e=>e.current),A=m?c?.find(e=>e.id===m):k??c?.[0],j=e=>{h(e);try{window.sessionStorage.setItem(p,e)}catch{}};(0,u.useEffect)(()=>{n&&n!==O.current&&j(n),O.current=n},[n,p]);let M=async(n,r)=>{if(!(S||s&&n!==`open`)){C(n),T(``);try{let i={action:n,requestId:ir(),worktreeId:r,...t&&!t.startsWith(`pending:`)?{conversationId:t}:{},...n===`create`?{branch:v.trim(),base:b.trim()}:{}},a=await Pr(Jr(e,`worktree-manage`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)},65e3);j(a.worktree.id),D(e=>e+1),n===`create`&&(y(``),x(``)),a.conversationId&&o?.(a.conversationId,a.workspaceId)}catch(e){T(Fr(e).message)}finally{C(``)}}};(0,u.useEffect)(()=>{let t=!0,n=!1,r=async()=>{if(!n){n=!0;try{let n=await Pr(Jr(e,`worktrees`));t&&(l(n.worktrees),f(``))}catch(e){t&&f(Fr(e).message)}finally{n=!1}}};r();let i=window.setInterval(()=>{document.visibilityState===`visible`&&r()},1e4);return()=>{t=!1,window.clearInterval(i)}},[e,r,E]),(0,u.useEffect)(()=>{if(s||!A||A.missing)return;let t=A.id,n=!0,r=!1,i=async()=>{if(!r){r=!0;try{let r=await Pr(Jr(e,`worktree-inspect`,{worktreeId:t}));n&&_({id:t,value:r})}catch(e){n&&_({id:t,error:Fr(e).message})}finally{r=!1}}};i();let a=window.setInterval(()=>{document.visibilityState===`visible`&&i()},5e3);return()=>{n=!1,window.clearInterval(a)}},[e,A?.id,A?.missing,r,E,s]);let N=!s&&g?.id===A?.id?g:void 0,ee=N?.value?.comparison,P=N?.value?.status,te=P?Gr.map(e=>({...e,files:P[e.key]})):[],ne=(e,t)=>(0,L.jsxs)(`button`,{type:`button`,className:`git-worktree-file`,title:e.path,"data-git-worktree-file":e.path,onClick:()=>i({...t,label:A?.branch??A?.name??`关联工作树`}),children:[(0,L.jsx)(qt,{path:e.path,size:15}),` `,(0,L.jsx)(`span`,{children:e.path}),(0,L.jsx)(`small`,{children:e.xy.trim()})]},e.path);return(0,L.jsxs)(`section`,{className:`git-worktrees`,"data-git-worktrees":!0,"aria-label":`仓库工作树`,children:[d&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:d}),!c&&!d&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取工作树…`}),c&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`select`,{className:`git-view-search`,"aria-label":`选择要查看的工作树`,value:A?.id??``,onChange:e=>j(e.target.value),children:[!A&&(0,L.jsx)(`option`,{value:``,children:`选择工作树`}),c.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.branch??(e.head.slice(0,8)||e.name),` · `,e.name,e.primary?` · 主检出`:``,e.current?` · 当前`:``,e.missing?` · 已丢失`:``,e.locked?` · 已锁定`:``]},e.id))]}),A&&(0,L.jsx)(`p`,{className:`git-worktree-path`,title:A.path,"data-git-worktree-path":!0,children:A.path}),(0,L.jsxs)(`div`,{className:`git-worktree-actions`,children:[A&&!A.missing&&o&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-worktree-open":!0,disabled:!!S,onClick:()=>void M(`open`,A.id),children:`在此新建会话`}),A&&!A.missing&&t&&!t.startsWith(`pending:`)&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-worktree-follow":!0,disabled:!!S||A.id===n,onClick:()=>void M(`follow`,A.id),children:A.id===n?`会话已跟随`:`会话跟随`})]}),(0,L.jsxs)(`details`,{className:`git-worktree-create`,children:[(0,L.jsx)(`summary`,{title:s?kr:void 0,children:`新建工作树`}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),M(`create`)},children:[(0,L.jsx)(`input`,{disabled:s,title:s?kr:void 0,className:`git-view-search`,"aria-label":`工作树起点分支`,placeholder:`起点分支(默认当前提交)`,value:b,onChange:e=>x(e.target.value),maxLength:180}),(0,L.jsx)(`input`,{disabled:s,title:s?kr:void 0,className:`git-view-search`,"aria-label":`工作树的新分支`,placeholder:`新分支(可选)`,value:v,onChange:e=>y(e.target.value),maxLength:180}),(0,L.jsx)(`button`,{type:`submit`,className:`git-group-action`,"data-git-worktree-create":!0,title:s?kr:void 0,disabled:s||!!S,children:S===`create`?`创建中…`:`创建工作树`})]})]}),w&&(0,L.jsx)(`p`,{className:`tool-error`,"data-git-worktree-error":!0,role:`alert`,children:w}),A?.missing&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`此工作树目录已丢失。`}),!s&&A&&!A.missing&&!N&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取工作树状态…`}),N?.error&&!A?.missing&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`alert`,children:N.error}),A&&!A.missing&&N?.value&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`git-worktree-summary`,"data-git-worktree-status":!0,children:[N.value.status.branch??`分离 HEAD`,A.current?` · 当前会话检出`:` · 仅查看`]}),te.every(e=>!e.files.length)&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`无未提交改动。`}),te.filter(e=>e.files.length).map(e=>(0,L.jsxs)(`div`,{className:`git-worktree-group`,children:[(0,L.jsxs)(`strong`,{children:[e.title,` · `,e.files.length]}),e.files.map(t=>ne(t,{worktreeId:A.id,path:t.path,staged:e.key===`staged`}))]},e.key)),ee&&!A.primary&&(0,L.jsxs)(`div`,{className:`git-worktree-group`,"data-git-worktree-comparison":!0,children:[(0,L.jsxs)(`strong`,{children:[`相对 `,ee.base,` · ↑`,ee.ahead,` ↓`,ee.behind]}),ee.files.map(e=>ne(e,{worktreeId:A.id,path:e.path,staged:!1,comparison:`committed`})),(0,L.jsx)(ri,{commits:ee.commits,workspaceId:e,cwd:``,worktreeId:A.id,onDiff:e=>a({...e,worktreeLabel:A.branch??A.name})},A.id),ee.truncated&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`显示最近 20 条独有提交。`})]})]})]})]})}function li({workspaceId:e,conversationId:t,cwd:n=``,followedWorktreeId:r,onOpenDiff:i,activeDiffUrl:a,onOpenConversation:o,sharedGit:s,repositoryOnly:c=!1}){let[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(null),m=s?s.status:l,h=s?s.error:f,g=s?.refresh,_=s?.publish,[v,y]=(0,u.useState)(()=>c||r?`worktrees`:`changes`),b=c&&Ar(v)?`worktrees`:v;(0,u.useEffect)(()=>{r&&y(`worktrees`)},[r]);let[x,S]=(0,u.useState)(``),[C,w]=(0,u.useState)(0),[T,E]=(0,u.useState)(0),[D,O]=(0,u.useState)(),[k,A]=(0,u.useState)({}),[j,M]=(0,u.useState)(``),[N,ee]=(0,u.useState)(null),[P,te]=(0,u.useState)(``),[ne,re]=(0,u.useState)(``),[F,ie]=(0,u.useState)(null),[ae,oe]=(0,u.useState)(null),se=(0,u.useRef)(0),ce=(0,u.useCallback)(e=>{let t=++se.current;p(null),re(``),E(e=>e+1),g?g(!0):Pr(Rr(e,n)).then(e=>{t===se.current&&d(e)}).catch(e=>{t===se.current&&(d(null),p(Fr(e)))})},[n,g]);(0,u.useEffect)(()=>{if(e)return ce(e),()=>{se.current++}},[e,n,ce]);let le=e=>{c&&Ar(e)||e!==b&&(y(e),S(``),w(0))},ue=Or.find(e=>e.id===b)??Or[0],de=b===`log`||b===`branches`||b===`stash`,fe=e&&m&&de?`/api/git?workspaceId=${Ir(e)}&op=${b}&limit=${Vr}${Lr(n)}&q=${Ir(x.trim())}&offset=${C}`:``;(0,u.useEffect)(()=>{if(!fe)return;let e=!0;O({url:fe,result:$r.get(fe)});let t=window.setTimeout(()=>{Pr(fe).then(t=>{e&&(ei($r,fe,t,32),O({url:fe,result:t}),`branches`in t&&A(e=>({...e,branches:t.total})),`stashes`in t&&A(e=>({...e,stash:t.total})))}).catch(t=>{e&&O({url:fe,result:$r.get(fe),error:Fr(t).message})})},x.trim()?180:0);return()=>{e=!1,window.clearTimeout(t)}},[fe,x,T]);let pe=(t,r,a,o=!1)=>{if(!e||c)return;let s=a?.comparison?`共同祖先 → 工作树 HEAD`:o?`未跟踪文件`:r?`HEAD → 暂存区`:`暂存区 → 工作区`,l=a?.comparison?`已提交`:o?`未跟踪`:r?`已暂存`:`未暂存`;i({url:a?Jr(e,`worktree-diff`,{worktreeId:a.worktreeId,path:t,staged:r?`1`:`0`,...a.comparison?{comparison:a.comparison}:{}}):zr(e,t,r,n),path:t,label:a?`${a.label} · ${l}`:l,comparison:a?`${a.label} · ${s}`:s})},me=t=>{if(!e)return;let r=t.file.path,a=t.hash.slice(0,8);i({url:Yr(e,t.worktreeId?``:n,t.hash,t.worktreeId,r),path:r,label:t.worktreeLabel?`${t.worktreeLabel} · ${a}`:a,comparison:`提交 ${a} · 对比${t.base}`,previousPath:t.file.previousPath,commitHash:t.hash})},I=(0,u.useCallback)(async(t,r={})=>{if(!e||F||c&&t!==`fetch`)return!1;ie(t),re(``);try{if(t===`draft`)return ee(await Br(e,t,r,n)),!0;let i=await Br(e,t,r,n);return _?_(i):d(i),t!==`fetch`&&t!==`push`&&ee(null),(t===`stash-save`||t===`switch`)&&w(0),E(e=>e+1),!0}catch(n){let r=Fr(n);return t===`stash-apply`&&ce(e),re(r.body?.error||r.message||`操作失败`),!1}finally{ie(null)}},[e,n,_,F,ce,c]),he=(0,u.useCallback)(()=>{if(!ae)return;let e=ae;oe(null),I(`discard`,{path:e})},[ae,I]),ge=(0,u.useCallback)(()=>{oe(null)},[]),_e=m===null?null:Wr(m),ve=x.trim().toLowerCase(),ye=m===null?[]:Gr.map(e=>({...e,entries:m[e.key].filter(e=>e.path.toLowerCase().includes(ve))})),be=m?new Set(Gr.flatMap(e=>m[e.key].map(e=>e.path))).size:0,xe=D?.url===fe?D.result:void 0,Se=D?.url===fe?D.error:void 0,Ce=xe&&`commits`in xe?xe:null,we=xe&&`branches`in xe?xe:null,Te=xe&&`stashes`in xe?xe:null,Ee=b===`log`?Vr:50,De=we??Te,Oe=Ce?Ce.truncated:De?C+Ee<De.matches:!1;return e?(0,L.jsxs)(`div`,{className:`git-panel`,"data-git-panel":`1`,"data-git-scope":c?`repository`:`checkout`,children:[c&&(0,L.jsxs)(`p`,{className:`git-scope-note`,role:`status`,children:[`仓库浏览 · `,kr]}),m===null&&h===null&&(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-loading":`1`,children:`读取 Git 状态…`}),h!==null&&(0,L.jsxs)(`div`,{className:`git-state-card${h.body.code===`not_a_repo`?` git-state-card-empty`:` git-error`}`,"data-git-error":`1`,role:`status`,"data-git-error-code":h.body.code??``,children:[(0,L.jsx)(`span`,{className:`git-state-icon`,"aria-hidden":`true`,children:h.body.code===`not_a_repo`?`⌁`:`!`}),(0,L.jsx)(`strong`,{children:h.body.code===`not_a_repo`?`此工作区不是 git 仓库`:`Git 状态暂时不可用`}),(0,L.jsx)(`p`,{children:h.body.code===`not_a_repo`?`当前工作区没有 Git 仓库,因此没有分支、变更或提交记录可显示。文件和对话功能仍可正常使用。`:`读取仓库状态时遇到问题,请稍后重试。`}),(0,L.jsx)(`button`,{type:`button`,className:`git-state-action`,onClick:()=>ce(e),children:`重新检查`})]}),m!==null&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`git-head`,"data-git-head":`1`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-branch`,"data-git-branch":`1`,title:c?`查看仓库分支`:Ur(m),"aria-label":c?`查看仓库分支`:`当前分支 ${Ur(m)},查看分支`,onClick:()=>le(`branches`),children:[(0,L.jsx)(rn,{name:`git`}),(0,L.jsx)(`span`,{children:c?`仓库分支`:Ur(m)})]}),!c&&_e!==null&&(0,L.jsx)(`span`,{className:`git-ahead-behind`,"data-git-ahead-behind":`1`,children:_e}),(0,L.jsx)(`button`,{type:`button`,className:`git-refresh`,"data-git-refresh":`1`,title:`刷新 Git 状态`,"aria-label":`刷新 Git 状态`,onClick:()=>ce(e),children:(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`})})]}),(0,L.jsxs)(`div`,{className:`git-sync-actions`,"aria-label":`远程操作`,children:[(0,L.jsx)(`button`,{type:`button`,"data-git-action":`fetch`,onClick:()=>void I(`fetch`),disabled:F!==null,title:`从上游获取远程引用`,children:F===`fetch`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`获取中…`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),` Fetch`]})}),(0,L.jsx)(`button`,{type:`button`,"data-git-action":`pull`,onClick:()=>void I(`pull`),disabled:c||F!==null,title:c?kr:void 0,children:F===`pull`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`拉取中…`]}):`拉取`}),(0,L.jsx)(`button`,{type:`button`,"data-git-action":`push`,onClick:()=>void I(`push`),disabled:c||F!==null,title:c?kr:void 0,children:F===`push`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`推送中…`]}):`推送`})]}),(0,L.jsx)(`nav`,{className:`git-view-nav`,"aria-label":`源代码管理视图`,children:Or.map(e=>{let t=c&&Ar(e.id),n=t?void 0:e.id===`changes`?be:e.id===`branches`||e.id===`stash`?k[e.id]:void 0;return(0,L.jsxs)(`button`,{type:`button`,disabled:t,title:t?kr:void 0,"data-git-view":e.id,"aria-pressed":e.id===b,onClick:()=>le(e.id),children:[(0,L.jsx)(rn,{name:e.icon}),(0,L.jsx)(`span`,{className:`git-view-label`,children:e.title}),n!==void 0&&(0,L.jsx)(`span`,{className:`git-view-count`,children:n})]},e.id)})}),ue.search&&(0,L.jsx)(`input`,{className:`git-view-search`,type:`search`,"aria-label":ue.search,placeholder:ue.search,value:x,maxLength:160,onChange:e=>{S(e.target.value),w(0)}}),b===`worktrees`&&(0,L.jsx)(ci,{repositoryOnly:c,workspaceId:e,conversationId:t,followedWorktreeId:r,revision:T,onOpenConversation:o,onDiff:e=>pe(e.path,e.staged,e),onCommitDiff:me}),b===`graph`&&m&&(0,L.jsx)(si,{workspaceId:e,cwd:n,revision:T,onDiff:me}),ne&&(0,L.jsx)(`p`,{className:`tool-error`,"data-git-action-error":`1`,role:`alert`,children:ne}),b===`changes`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`section`,{className:`git-scm-actions`,"data-git-actions":`1`,"aria-label":`提交已暂存的更改`,children:[(0,L.jsxs)(`form`,{className:`git-commit-input`,onSubmit:async e=>{e.preventDefault(),await I(`commit`,{message:j})&&M(``)},children:[(0,L.jsx)(`input`,{value:j,onChange:e=>M(e.target.value),placeholder:`提交说明…`,"aria-label":`提交消息`,disabled:F!==null}),(0,L.jsx)(`button`,{type:`submit`,className:`git-commit-submit`,"data-git-action":`commit`,disabled:!m.staged.length||!j.trim()||F!==null,children:F===`commit`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`提交中…`]}):`提交`})]}),(0,L.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,L.jsxs)(`span`,{children:[m.staged.length,` 个已暂存`]}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`draft`,"aria-label":`用 AI 根据当前目录的暂存差异生成提交信息`,title:`用 AI 根据当前目录的暂存差异生成提交信息`,disabled:!m.staged.length||F!==null,onClick:()=>void I(`draft`),children:F===`draft`?`生成中…`:`✧ AI 生成`})]}),N&&(0,L.jsxs)(`div`,{className:`git-draft`,"data-git-draft":!0,children:[(0,L.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,L.jsx)(`strong`,{children:N.truncated?`提交说明建议 · 差异已截断`:`提交说明建议`}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"aria-label":`关闭提交说明建议`,onClick:()=>ee(null),children:`×`})]}),(0,L.jsx)(`p`,{children:N.message}),(0,L.jsx)(`button`,{type:`button`,"data-git-draft-apply":!0,onClick:()=>{M(N.message.replace(/\s*\n\s*/g,` `)),ee(null)},children:`替换输入`})]})]}),ye.map(t=>(0,L.jsxs)(`div`,{className:`git-group`,"data-git-group":t.key,children:[(0,L.jsxs)(`div`,{className:`git-group-head`,"data-git-group-head":t.key,children:[(0,L.jsx)(`span`,{className:`git-group-title`,children:t.title}),(0,L.jsx)(`span`,{className:`git-group-count`,"data-git-count":t.key,children:t.entries.length}),!ve&&t.key===`staged`&&t.entries.length>0&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`unstage-all`,disabled:F!==null,onClick:()=>void I(`unstage-all`),children:`全部取消暂存`}),!ve&&t.key===`unstaged`&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`stage-all`,disabled:F!==null||!m.unstaged.length&&!m.untracked.length,onClick:()=>void I(`stage-all`),children:`全部暂存`})]}),(0,L.jsx)(`div`,{className:`git-group-body`,children:t.entries.length===0?(0,L.jsx)(`p`,{className:`git-group-empty`,"data-git-empty":t.key,children:ve?`无匹配文件。`:`无${t.title}变更。`}):t.entries.map(r=>{let i=Er(r.xy,t.key),o=Dr(r),s=a===zr(e,r.path,t.key===`staged`,n);return(0,L.jsxs)(`div`,{className:`git-file-row${s?` is-active`:``}`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-file-open`,"data-git-file":r.path,"data-git-kind":o?`dir`:`file`,title:r.path,onClick:()=>pe(r.path,t.key===`staged`,void 0,t.key===`untracked`),children:[(0,L.jsx)(qt,{path:r.path,category:o?`folder`:void 0,size:15}),(0,L.jsx)(`span`,{className:`git-path`,children:o?`${r.name}/`:r.name}),r.path.includes(`/`)&&!o&&(0,L.jsx)(`span`,{className:`git-parent-path`,children:r.path.slice(0,r.path.lastIndexOf(`/`))})]}),(0,L.jsxs)(`span`,{className:`git-file-actions`,children:[t.key===`staged`?(0,L.jsx)(`button`,{type:`button`,title:`取消暂存`,disabled:F!==null,onClick:e=>{e.stopPropagation(),I(`unstage`,{path:r.path})},children:`−`}):(0,L.jsx)(`button`,{type:`button`,title:`暂存`,disabled:F!==null,onClick:e=>{e.stopPropagation(),I(`stage`,{path:r.path})},children:`+`}),t.key===`unstaged`&&(0,L.jsx)(`button`,{type:`button`,className:`git-file-action`,"data-git-action":`discard`,title:`丢弃 ${r.path} 的更改`,"aria-label":`丢弃更改 ${r.path}`,disabled:ae!==null||F!==null,onClick:e=>{e.stopPropagation(),oe(r.path)},children:`↶`})]}),(0,L.jsx)(`span`,{className:`git-badge git-badge-${i.kind} git-badge-slot-${i.slot}`,"data-git-badge":i.kind,"data-git-badge-slot":i.slot,children:i.label})]},r.path)})})]},t.key))]}),de&&!xe&&!Se&&(0,L.jsxs)(`p`,{className:`rail-empty`,"data-git-log-loading":b===`log`?`1`:void 0,role:`status`,children:[`读取`,ue.title,`…`]}),de&&Se&&(0,L.jsxs)(`div`,{className:`git-page-error`,"data-git-log-error":b===`log`?`1`:void 0,children:[(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,title:Vt(Se),children:Bt(Se,`读取 Git 列表失败。`)}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,onClick:()=>E(e=>e+1),children:`重试`})]}),b===`log`&&Ce&&(0,L.jsx)(`div`,{className:`git-log`,"data-git-log":`1`,children:Ce.commits.length===0?(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-log-empty":`1`,children:x.trim()?`没有匹配的提交。`:`暂无提交记录。`}):(0,L.jsx)(ri,{commits:Ce.commits,workspaceId:e,cwd:n,onDiff:me})}),b===`branches`&&we&&(0,L.jsxs)(`div`,{className:`git-index-list`,"data-git-branches":!0,children:[!we.canWrite&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`切换分支会改变整个工作树,请在仓库根目录操作。`}),we.branches.length===0&&(0,L.jsx)(`p`,{className:`rail-empty`,children:x.trim()?`没有匹配的分支。`:`暂无分支。`}),we.branches.map(e=>(0,L.jsxs)(`div`,{className:`git-index-row`,"data-git-ref":e.name,children:[(0,L.jsx)(`span`,{className:`git-index-name`,title:e.name,children:e.name}),e.current?!c&&(0,L.jsx)(`span`,{className:`git-index-current`,children:`当前`}):e.local?we.canWrite&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`switch`,"aria-label":`切换到 ${e.name}`,disabled:c||F!==null,title:c?kr:void 0,onClick:()=>void I(`switch`,{target:e.name}),children:`切换`}):(0,L.jsx)(`span`,{className:`git-index-meta`,children:`远程`})]},`${e.local}:${e.name}`))]}),b===`stash`&&Te&&(0,L.jsxs)(`div`,{className:`git-index-list`,"data-git-stashes":!0,children:[Te.canWrite?(0,L.jsxs)(`form`,{className:`git-stash-form`,onSubmit:async e=>{e.preventDefault(),await I(`stash-save`,{message:P})&&te(``)},children:[(0,L.jsxs)(`div`,{className:`git-commit-input`,children:[(0,L.jsx)(`input`,{className:`git-view-search`,value:P,onChange:e=>te(e.target.value),maxLength:200,"aria-label":`贮藏说明`,placeholder:`贮藏说明(可选)`}),(0,L.jsx)(`button`,{type:`submit`,className:`git-group-action`,"data-git-action":`stash-save`,disabled:!be||F!==null,children:`贮藏改动`})]}),(0,L.jsx)(`p`,{className:`git-scope-note`,children:`保存整个工作树的改动,包括未跟踪文件。`})]}):(0,L.jsx)(`p`,{className:`git-scope-note`,children:`贮藏影响整个工作树,请在仓库根目录操作。`}),Te.stashes.length===0&&(0,L.jsx)(`p`,{className:`rail-empty`,children:x.trim()?`没有匹配的贮藏。`:`暂无贮藏记录。`}),Te.stashes.map(e=>(0,L.jsxs)(`div`,{className:`git-index-row`,"data-git-stash":e.hash,children:[(0,L.jsxs)(`div`,{className:`git-index-name`,title:e.subject,children:[e.subject,(0,L.jsxs)(`small`,{className:`git-index-meta`,children:[e.ref,` · `,Hr(e.date)]})]}),Te.canWrite&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`stash-apply`,"aria-label":`恢复 ${e.ref}`,title:`恢复改动并保留贮藏记录`,disabled:F!==null,onClick:()=>void I(`stash-apply`,{target:e.hash}),children:`恢复`})]},`${e.ref}:${e.hash}`))]}),b!==`changes`&&xe&&(C>0||Oe)&&(0,L.jsxs)(`div`,{className:`git-pages`,children:[(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,disabled:!C,onClick:()=>w(Math.max(0,C-Ee)),children:`上一页`}),(0,L.jsxs)(`span`,{children:[`第 `,C/Ee+1,` 页`,De?` · ${De.matches} 项`:``]}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-log-truncated":Ce?.truncated?`1`:void 0,disabled:!Oe,onClick:()=>w(C+Ee),children:`下一页`})]}),ae!==null&&(0,L.jsx)(Kr,{path:ae,onCancel:ge,onConfirm:he})]})]}):(0,L.jsx)(`div`,{className:`git-panel`,"data-git-panel":`1`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-empty":`noworkspace`,children:`请选择一个工作区查看 Git 状态。`})})}var ui=e=>e?.phase===`waiting`||e?.phase===`installing`||e?.phase===`restarting`;async function di(e,t={},n=f){let r=await ke(e,{...t,cache:`no-store`,signal:t.signal??AbortSignal.timeout(12e3)},n),i=await r.json().catch(()=>null);if(!i||!r.ok&&!(r.status===409&&i.operation))throw Error(i?.error??`更新服务未返回有效状态(HTTP ${r.status})`);return i}async function fi(e,t){let n;for(let r=0;r<2;r++)try{let n=AbortSignal.any([e,AbortSignal.timeout(8e3)]),r=await ke(`/api/update-status`,{cache:`no-store`,signal:n},t);if(r.status===404||r.ok&&r.headers.get(`content-type`)?.includes(`text/html`))return{...await di(`/api/health`,{signal:n},t),operation:null};let i=await r.json();if(!r.ok)throw Error(i?.error??`无法读取更新状态(HTTP ${r.status})`);return i}catch(t){if(n=t,e.aborted||r===1)break;await new Promise(e=>setTimeout(e,400))}throw n}var pi=e=>e===`entry`?`super-pi.update-legacy-receipt`:`super-pi.update-legacy-receipt:${e}`;function mi(e,t){try{if(t!==void 0)return t?sessionStorage.setItem(pi(e),JSON.stringify(t)):sessionStorage.removeItem(pi(e)),t;let n=JSON.parse(sessionStorage.getItem(pi(e))??`null`);return n?.id&&Date.now()-Date.parse(n.startedAt)<18e5?n:null}catch{return t??null}}var hi=e=>e?`v${e}`:`—`,gi=e=>!(!e.managed||e.legacy||e.transport===`direct`),_i=e=>e?.status?.needsRestart?`restart`:e?.latest&&e.status&&e.latest!==e.status.diskVersion?`update`:void 0;function vi(e){return e?.submitting?`starting`:e?.checking?`checking`:ui(e?.status?.operation)?e.status.operation.phase:e?.status?.needsRestart?`needs-restart`:e?.status?.operation?.phase===`failed`||e?.error?`failed`:e?.status?.operation?.phase===`completed`?`completed`:`idle`}function yi(e){let t=vi(e);return t===`starting`?`正在提交更新`:t===`checking`?`正在检查可用版本`:t===`waiting`?`等待选中的托管服务更新结束,再更新本地入口`:t===`installing`?`正在下载并安装更新`:t===`restarting`?e?.connectionLost?`等待服务重新上线`:`正在重启服务`:t===`needs-restart`?`${hi(e?.status?.diskVersion)} 已安装,等待重启`:t===`failed`?e?.error??e?.status?.operation?.failure?.message??`更新失败`:t===`completed`?`更新完成`:_i(e)?`有新版本可安装`:e?.latest?`当前已是最新版本`:`等待检查更新`}function bi(e){let{connections:t,activeServer:n}=oe(),[r,i]=(0,u.useState)({}),a=(0,u.useRef)(r);a.current=r;let[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(()=>new Set),[d,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(),[g,_]=(0,u.useState)(``),v=(0,u.useRef)(null),y=(0,u.useId)(),b=(0,u.useRef)(new Map),x=(0,u.useRef)(new Set),S=(0,u.useRef)(!1),C=(0,u.useRef)(new Map),w=(e,t)=>{let n={...a.current[e]??{},...t};a.current={...a.current,[e]:n},i(t=>JSON.stringify(t[e])===JSON.stringify(n)?t:{...t,[e]:n})},T=e=>{let t=(b.current.get(e)??0)+1;return b.current.set(e,t),t},E=JSON.stringify(t.map(({id:e,url:t,enabled:n,revision:r})=>[e,t,n,r]));(0,u.useEffect)(()=>{let e=new AbortController,n,r=async()=>{if(t.some(gi))try{let t=await di(`/api/managed-servers`,{signal:e.signal});C.current=new Map((t.profiles??[]).map(e=>[e.id,e]))}catch{}await Promise.allSettled(t.filter(e=>e.enabled).map(async t=>{if(x.current.has(t.id))return;let n=b.current.get(t.id);try{let r=await fi(e.signal,t.id);if(e.signal.aborted||n!==b.current.get(t.id))return;let i=t.managedId&&C.current.get(t.managedId);if(gi(t)&&i&&i.updateOperation&&(r.operation=i.updateOperation),r.operation)mi(t.id,null);else{let e=mi(t.id);e&&(r.operation=e.targetVersion===r.runningVersion&&!r.needsRestart?mi(t.id,{...e,phase:`completed`,changedAt:new Date().toISOString()}):Date.now()-Date.parse(e.changedAt)>15e4&&e.phase===`restarting`?mi(t.id,{...e,phase:`failed`,changedAt:new Date().toISOString(),failure:{step:`restarting`,message:`服务尚未恢复,请检查所选服务的运行状态后重试。`}}):e)}w(t.id,{status:r,connectionLost:!1})}catch{!e.signal.aborted&&n===b.current.get(t.id)&&w(t.id,{connectionLost:!0})}})),window.superPiDesktop&&window.superPiDesktop.status().then(t=>{e.signal.aborted||h(t)}).catch(()=>{}),e.signal.aborted||(n=window.setTimeout(r,o||Object.values(a.current).some(e=>ui(e.status?.operation))?1600:5e3))};return r(),()=>{e.abort(),clearTimeout(n)}},[E,o]),(0,u.useEffect)(()=>{o?v.current?.open||v.current?.showModal():v.current?.close()},[o]);async function D(e){if(x.current.has(e.id)||ui(a.current[e.id]?.status?.operation))return;if(!e.enabled){w(e.id,{error:`连接已停用,请先连接此服务端再更新。`,latest:void 0});return}x.current.add(e.id);let t=T(e.id);w(e.id,{checking:!0,error:void 0});try{let n=await di(`/api/update-check`,{signal:AbortSignal.timeout(7e4)},e.id);if(b.current.get(e.id)!==t)return;let r=e.managedId&&C.current.get(e.managedId);gi(e)&&r&&r.updateOperation&&(n.operation=r.updateOperation),w(e.id,{status:n,latest:n.latestVersion,connectionLost:!1})}catch(n){b.current.get(e.id)===t&&w(e.id,{error:n instanceof Error?n.message:`检查更新失败。`,latest:void 0})}finally{x.current.delete(e.id),w(e.id,{checking:!1})}}async function O(){await Promise.allSettled(t.filter(e=>!c.has(e.id)).map(D))}function k(e,t){for(let n of t){let t=e.profiles?.find(e=>e.id===n.managedId),r=a.current[n.id]?.status;w(n.id,{error:e.errors?.[n.managedId],status:t?.updateOperation&&r?{...r,operation:t.updateOperation}:r,submitting:!1})}}async function A(e,t){let n=a.current[e.id],r=_i(n);if(r&&n.status&&!x.current.has(e.id)&&!ui(n.status.operation)){x.current.add(e.id),T(e.id),w(e.id,{submitting:!0,error:void 0});try{let i=r===`restart`?{restartOnly:!0}:{version:n.latest},a=await di(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...i,...t?.length?{managedUpdates:t}:{}})},e.id);if(!a.operation){let t=new Date().toISOString();a.operation=mi(e.id,{id:t,action:r,phase:r===`restart`?`restarting`:`installing`,fromVersion:n.status.runningVersion,targetVersion:r===`restart`?n.status.diskVersion:n.latest,startedAt:t,changedAt:t})}return w(e.id,{status:a,connectionLost:!1}),a.managedResult}catch(t){w(e.id,{error:t instanceof Error?t.message:`无法确认更新请求是否送达,请检查状态。`})}finally{x.current.delete(e.id),w(e.id,{submitting:!1})}}}async function j(){if(S.current)return;S.current=!0,p(!0);let e=t.filter(e=>!c.has(e.id));try{await Promise.allSettled(e.filter(e=>!a.current[e.id]?.latest&&!a.current[e.id]?.status?.needsRestart).map(D));let t=e.filter(e=>e.enabled&&!a.current[e.id]?.error&&_i(a.current[e.id])),n=t.filter(gi),r=t.find(e=>e.id===f),i=n.map(e=>({id:e.managedId,version:a.current[e.id].status?.needsRestart?a.current[e.id].status.diskVersion:a.current[e.id].latest}));if(await Promise.allSettled(t.filter(e=>e.id!==`entry`&&!gi(e)).map(e=>A(e))),r){for(let e of n)w(e.id,{submitting:!0,error:void 0});if(k({errors:(await A(r,i))?.errors},n),a.current[r.id]?.error)for(let e of n)w(e.id,{error:`本地入口未受理托管更新,请检查本地状态后重试。`})}else if(i.length){for(let e of n)w(e.id,{submitting:!0,error:void 0});try{k(await di(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`updateSelected`,updates:i})}),n)}catch(e){for(let t of n)w(t.id,{error:e instanceof Error?e.message:`无法启动托管更新`,submitting:!1})}}}finally{S.current=!1,p(!1)}}let M=t.map(e=>vi(r[e.id])),N=d||M.some(e=>[`starting`,`waiting`,`installing`,`restarting`,`checking`].includes(e)),ee=d?`starting`:M.find(e=>[`waiting`,`installing`,`restarting`,`checking`].includes(e))??(M.includes(`needs-restart`)?`needs-restart`:M.includes(`failed`)?`failed`:M.includes(`completed`)?`completed`:`idle`),P=t.filter(e=>!c.has(e.id)),te=P.some(e=>_i(r[e.id])),ne=P.some(e=>_i(r[e.id])===`restart`)&&!P.some(e=>_i(r[e.id])===`update`);return{entry:e=>(0,L.jsxs)(`button`,{type:`button`,className:`software-update-entry ${e}`,"data-software-update-entry":ee,"aria-haspopup":`dialog`,title:`软件更新`,"aria-label":`软件更新`,onClick:()=>{s(!0),O()},children:[(0,L.jsx)(rn,{name:`update`}),(0,L.jsx)(`span`,{children:`软件更新`}),N&&(0,L.jsx)(`small`,{children:`进行中`}),!N&&ee===`needs-restart`&&(0,L.jsx)(`small`,{children:`待重启`})]}),panel:(0,L.jsx)(`dialog`,{ref:v,className:`software-update-dialog software-update-multi`,"aria-labelledby":y,onClose:()=>s(!1),onClick:e=>{e.target===e.currentTarget&&s(!1)},children:(0,L.jsxs)(`div`,{className:`software-update-content`,children:[(0,L.jsxs)(`div`,{className:`software-update-header`,children:[(0,L.jsxs)(`h2`,{id:y,children:[(0,L.jsx)(rn,{name:`update`}),`软件更新`]}),(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"aria-label":`关闭软件更新`,onClick:()=>s(!1),children:(0,L.jsx)(rn,{name:`close`})})]}),(0,L.jsxs)(`div`,{className:`software-update-selection`,children:[(0,L.jsxs)(`span`,{children:[`已选择 `,P.length,` / `,t.length,` 个服务端`]}),(0,L.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>l(new Set),children:`全选`}),(0,L.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>l(new Set(t.map(e=>e.id))),children:`全不选`})]}),(0,L.jsx)(`div`,{className:`software-update-targets`,children:t.map(e=>{let t=r[e.id],n=vi(t),i=t?.status?.operation;return(0,L.jsxs)(`section`,{className:`software-update-target`,"data-update-target":e.id,children:[(0,L.jsxs)(`label`,{className:`software-update-target-label`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:!c.has(e.id),disabled:N,onChange:t=>{let n=t.target.checked;l(t=>{let r=new Set(t);return n?r.delete(e.id):r.add(e.id),r})}}),(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`small`,{children:e.id===`entry`?`本地入口`:gi(e)?`SSH 托管服务`:e.managed?`SSH 原有服务`:`远端服务`})]}),(0,L.jsxs)(`dl`,{className:`software-update-versions`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`运行版本`}),(0,L.jsx)(`dd`,{"data-update-version":`running`,children:hi(t?.status?.runningVersion)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`已安装`}),(0,L.jsx)(`dd`,{"data-update-version":`disk`,children:hi(t?.status?.diskVersion)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`目标版本`}),(0,L.jsx)(`dd`,{"data-update-version":`target`,children:hi(ui(i)?i?.targetVersion:t?.latest??t?.status?.diskVersion)})]})]}),(0,L.jsxs)(`div`,{className:`software-update-progress`,"data-update-progress":n,children:[(0,L.jsx)(`div`,{className:`software-update-summary`,role:`status`,children:yi(t)}),[`starting`,`checking`,`waiting`,`installing`,`restarting`].includes(n)&&(0,L.jsx)(`progress`,{"aria-label":yi(t)}),t?.connectionLost&&(0,L.jsx)(`small`,{children:`服务连接暂时中断,正在自动重试。`}),!e.enabled&&(0,L.jsx)(`small`,{children:`此连接已停用,需连接后才能更新。`}),t?.error&&(0,L.jsx)(`p`,{role:`alert`,children:t.error}),i?.phase===`failed`&&(0,L.jsx)(`p`,{role:`alert`,children:i.failure?.message})]}),e.id===`entry`&&m&&(0,L.jsxs)(`p`,{className:`software-update-note`,children:[`桌面运行版本:`,hi(m.desktopVersion),m.needsDesktopRestart?` · 桌面端待重启`:m.desktopVersion?` · 服务更新完成后会自动重新打开桌面端`:` · 旧桌面外壳,本次更新后请从托盘退出并重新打开一次,之后支持自动重启`]})]},e.id)})}),(0,L.jsx)(`p`,{className:`software-update-note`,children:`远端先更新,本地入口最后重启。重启可能中断对应服务正在运行的任务和终端。`}),g&&(0,L.jsx)(`p`,{role:`alert`,children:g}),(0,L.jsxs)(`div`,{className:`software-update-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`software-update-secondary`,"data-update-check":!0,disabled:N||!P.length,onClick:()=>void O(),children:`检查更新`}),m?.needsDesktopRestart&&!r.entry?.status?.needsRestart&&window.superPiDesktop?.restart&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{window.superPiDesktop.restart().catch(()=>_(`无法重新启动桌面端,请从托盘退出后重新打开。`))},children:`重启桌面端`}),(0,L.jsxs)(`button`,{type:`button`,className:`software-update-primary`,"data-update-install":ne?void 0:`1`,"data-update-restart":ne?`1`:void 0,disabled:N||!P.length||!te,onClick:()=>void j(),children:[(0,L.jsx)(rn,{name:ne?`restart`:`update`}),ne?`重启所选服务`:`更新并重启所选服务`]})]})]})}),status:r[n]?.status}}function xi(e){let t=0;return e.map(e=>e.key.startsWith(`m:`)?(t=Math.max(t,Number.isFinite(e.at)?e.at:0),{...e,at:t}):e).sort((e,t)=>e.at-t.at||e.seq-t.seq).map(e=>e.key)}var Si=new Set,Ci=new Map,wi=new Map,Ti=!1;function Ei(){return typeof window<`u`&&window.superPiDesktop?.notifications?`native`:typeof window>`u`||!(`Notification`in window)?`unsupported`:window.isSecureContext?Notification.permission:`insecure`}async function Di(){return window.superPiDesktop?.notifications?(await window.superPiDesktop.notifications.status()).supported?`native`:`unsupported`:`Notification`in window?Notification.requestPermission():`denied`}function Oi(e,t){let n=window.superPiDesktop?.notifications;if(!n)return new Notification(e,{...t,icon:new URL(`/favicon.png`,location.origin).href});Ti||(Ti=!0,n.onClick(e=>wi.get(e)?.onclick?.()));let r={close:()=>{wi.delete(t.tag),n.close(t.tag),r.onclose?.()}};return wi.get(t.tag)?.close(),wi.set(t.tag,r),wi.size>64&&wi.values().next().value?.close(),r.ready=n.show({id:t.tag,title:e,body:t.body}),r.ready.catch(()=>{wi.get(t.tag)===r&&wi.delete(t.tag)}),r}function ki(e,t,n,r,i){if(!Si.has(e)){Si.add(e);try{let t=`super-pi.notification.${e}`;if(localStorage.getItem(t))return;localStorage.setItem(t,`shown`)}catch{}if(!r&&[`granted`,`native`].includes(Ei()))try{let r=Oi(t,{body:n,tag:e});Ci.set(e,r),r.onclick=()=>{window.focus(),i(),r.close(),Ci.delete(e)}}catch{}}}function Ai(e){for(let[t,n]of Ci)e.has(t)||(n.close(),Ci.delete(t))}var B=class e extends Error{constructor(t,n){var r=`KaTeX parse error: `+t,i,a,o=n&&n.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start,a=o.end,i===s.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;var c=s.slice(i,a).replace(/[^]/g,`$&̲`),l=i>15?`…`+s.slice(i-15,i):s.slice(0,i),u=a+15<s.length?s.slice(a,a+15)+`…`:s.slice(a);r+=l+c+u}super(r),this.name=`ParseError`,this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,e.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=t}},ji=/([A-Z])/g,Mi=e=>e.replace(ji,`-$1`).toLowerCase(),Ni={"&":`&amp;`,">":`&gt;`,"<":`&lt;`,'"':`&quot;`,"'":`&#x27;`},Pi=/[&><"']/g,Fi=e=>String(e).replace(Pi,e=>Ni[e]),Ii=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?Ii(e.body[0]):e:e.type===`font`?Ii(e.body):e,Li=new Set([`mathord`,`textord`,`atom`]),Ri=e=>Li.has(Ii(e).type),zi=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},Bi={displayMode:{type:`boolean`,description:`Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.`,cli:`-d, --display-mode`},output:{type:{enum:[`htmlAndMathml`,`html`,`mathml`]},description:`Determines the markup language of the output.`,cli:`-F, --format <type>`},leqno:{type:`boolean`,description:`Render display math in leqno style (left-justified tags).`},fleqn:{type:`boolean`,description:`Render display math flush left.`},throwOnError:{type:`boolean`,default:!0,cli:`-t, --no-throw-on-error`,cliDescription:`Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.`},errorColor:{type:`string`,default:`#cc0000`,cli:`-c, --error-color <color>`,cliDescription:`A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.`,cliProcessor:e=>`#`+e},macros:{type:`object`,cli:`-m, --macro <def>`,cliDescription:`Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).`,cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:`number`,description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:`--min-rule-thickness <size>`,cliProcessor:parseFloat},colorIsTextColor:{type:`boolean`,description:`Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.`,cli:`-b, --color-is-text-color`},strict:{type:[{enum:[`warn`,`ignore`,`error`]},`boolean`,`function`],description:`Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.`,cli:`-S, --strict`,cliDefault:!1},trust:{type:[`boolean`,`function`],description:`Trust the input, enabling all HTML features such as \\url.`,cli:`-T, --trust`},maxSize:{type:`number`,default:1/0,description:`If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large`,processor:e=>Math.max(0,e),cli:`-s, --max-size <n>`,cliProcessor:parseInt},maxExpand:{type:`number`,default:1e3,description:`Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.`,processor:e=>Math.max(0,e),cli:`-e, --max-expand <n>`,cliProcessor:e=>e===`Infinity`?1/0:parseInt(e)},globalGroup:{type:`boolean`,cli:!1}};function Vi(e){if(typeof e!=`string`)return e.enum[0];switch(e){case`boolean`:return!1;case`string`:return``;case`number`:return 0;case`object`:return{};default:throw Error(`Unexpected schema type; settings must declare an explicit default.`)}}function Hi(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:Vi(Array.isArray(e.type)?e.type[0]:e.type)}function Ui(e,t,n,r){var i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,a=Object.prototype.hasOwnProperty.call(r,`processor`)?r.processor:void 0;e[t]=i===void 0?Hi(r):a?a(i):i}var Wi=class{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e||={};for(var t of Object.keys(Bi)){var n=Bi[t];n&&Ui(this,t,e,n)}}isTrusted(e){if(`url`in e&&e.url&&!e.protocol){var t=zi(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},Gi=class{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return ea[ta[this.id]]}sub(){return ea[na[this.id]]}fracNum(){return ea[ra[this.id]]}fracDen(){return ea[ia[this.id]]}cramp(){return ea[aa[this.id]]}text(){return ea[oa[this.id]]}isTight(){return this.size>=2}},Ki=0,qi=1,Ji=2,Yi=3,Xi=4,Zi=5,Qi=6,$i=7,ea=[new Gi(Ki,0,!1),new Gi(qi,0,!0),new Gi(Ji,1,!1),new Gi(Yi,1,!0),new Gi(Xi,2,!1),new Gi(Zi,2,!0),new Gi(Qi,3,!1),new Gi($i,3,!0)],ta=[Xi,Zi,Xi,Zi,Qi,$i,Qi,$i],na=[Zi,Zi,Zi,Zi,$i,$i,$i,$i],ra=[Ji,Yi,Xi,Zi,Qi,$i,Qi,$i],ia=[Yi,Yi,Zi,Zi,$i,$i,$i,$i],aa=[qi,qi,Yi,Yi,Zi,Zi,$i,$i],oa=[Ki,qi,Ji,Yi,Ji,Yi,Ji,Yi],sa={DISPLAY:ea[Ki],TEXT:ea[Ji],SCRIPT:ea[Xi],SCRIPTSCRIPT:ea[Qi]},ca=[{name:`latin`,blocks:[[256,591],[768,879]]},{name:`cyrillic`,blocks:[[1024,1279]]},{name:`armenian`,blocks:[[1328,1423]]},{name:`brahmic`,blocks:[[2304,4255]]},{name:`georgian`,blocks:[[4256,4351]]},{name:`cjk`,blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:`hangul`,blocks:[[44032,55215]]}];function la(e){for(var t=0;t<ca.length;t++)for(var n=ca[t],r=0;r<n.blocks.length;r++){var i=n.blocks[r];if(e>=i[0]&&e<=i[1])return n.name}return null}var ua=[];ca.forEach(e=>e.blocks.forEach(e=>ua.push(...e)));function da(e){for(var t=0;t<ua.length;t+=2)if(e>=ua[t]&&e<=ua[t+1])return!0;return!1}var fa=e=>e+` `+e,pa=80,ma=function(e,t){return`M95,`+(622+e+t)+`
22
+ `)&&(0,L.jsxs)(`details`,{className:`git-commit-extra`,children:[(0,L.jsx)(`summary`,{children:`完整提交说明`}),(0,L.jsx)(`pre`,{children:c.message})]}),(0,L.jsxs)(`p`,{className:`git-scope-note`,title:c.parents[0],children:[c.files.length,` 个文件 · 对比`,u]}),!c.files.length&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`当前目录内没有文件改动。`}),c.files.map(t=>{let n=t.path.split(`/`).at(-1)??t.path,a=t.previousPath===void 0?t.path:`${t.previousPath} → ${t.path}`,o=ni[t.status[0]]??t.status;return(0,L.jsxs)(`button`,{type:`button`,className:`git-worktree-file git-commit-file`,"data-git-commit-file":t.path,title:`${o} · ${a}`,onClick:()=>i({hash:e.hash,base:u,file:t,worktreeId:r}),children:[(0,L.jsx)(qt,{path:t.path,size:15}),(0,L.jsxs)(`span`,{className:`git-commit-file-label`,children:[(0,L.jsx)(`span`,{children:n}),a!==n&&(0,L.jsx)(`small`,{children:a})]}),(0,L.jsx)(`span`,{className:`git-commit-file-status`,"aria-label":o,children:t.status[0]})]},t.path)})]})]})]},e.hash)})})}var ii=14,ai={head:`当前检出`,worktree:`工作树`,branch:`本地分支`,remote:`远程跟踪分支`,tag:`标签`,stash:`贮藏`};function oi({refItem:e}){let{kind:t,name:n}=e;return(0,L.jsxs)(`span`,{className:`git-graph-ref`,"data-git-graph-ref":t,title:`${ai[t]} · ${n}`,children:[t===`tag`||t===`worktree`?`${ai[t]} `:``,n]})}function z({row:e,columns:t,merge:n}){let r=e=>e*ii+ii/2,i=r(e.node.index),a=t*ii;return(0,L.jsxs)(`div`,{className:`git-graph-lines`,"aria-hidden":`true`,"data-git-graph-lane":e.node.index,"data-git-graph-incoming":e.incoming||void 0,children:[(0,L.jsxs)(`svg`,{className:`git-graph-top`,width:a,height:`32`,viewBox:`0 0 ${a} 32`,children:[e.through.map(e=>(0,L.jsx)(`path`,{"data-color":e.color%5,d:`M ${r(e.index)} 0 V 32`},e.index)),e.incoming&&(0,L.jsx)(`path`,{"data-color":e.node.color%5,d:`M ${i} 0 V 16`}),e.parents.map(({hash:e,lane:t},n)=>(0,L.jsx)(`path`,{"data-git-graph-parent":e,"data-color":t.color%5,d:`M ${i} 16 C ${i} 24 ${r(t.index)} 22 ${r(t.index)} 32`},n)),n?(0,L.jsx)(`rect`,{"data-color":e.node.color%5,x:i-3.5,y:`12.5`,width:`7`,height:`7`,rx:`1`}):(0,L.jsx)(`circle`,{"data-color":e.node.color%5,cx:i,cy:`16`,r:`3.5`})]}),(0,L.jsx)(`svg`,{className:`git-graph-tail`,width:a,viewBox:`0 0 ${a} 1`,preserveAspectRatio:`none`,children:[...e.through,...e.parents.map(e=>e.lane).filter(t=>!e.through.some(e=>e.index===t.index))].map(e=>(0,L.jsx)(`path`,{"data-color":e.color%5,d:`M ${r(e.index)} 0 V 1`},e.index))})]})}function si({workspaceId:e,cwd:t,revision:n,onDiff:r}){let i=Jr(e,`graph`,t?{cwd:t}:{}),[a,o]=(0,u.useState)(()=>({page:Zr.get(i),loading:!0})),s=(0,u.useRef)(void 0),c=(0,u.useCallback)(e=>{s.current?.abort();let t=new AbortController;s.current=t;let n=Zr.get(i);o(t=>({page:e??n??t.page,loading:!0}));let r=new URLSearchParams(e?{offset:String(e.commits.length),snapshot:e.snapshot,after:e.commits.at(-1)?.hash??``}:n?{knownSnapshot:n.snapshot}:{});Pr(`${i}&${r}`,{signal:t.signal}).then(r=>{if(t.signal.aborted)return;let a=`unchanged`in r?Zr.get(i)??n:e?{...r,commits:[...e.commits,...r.commits]}:r;a&&ei(Zr,i,a,8),o({page:a,loading:!1})}).catch(n=>{t.signal.aborted||o(t=>({page:t.page,error:Fr(n),loading:!1,append:!!e}))})},[i]);(0,u.useEffect)(()=>(c(),()=>s.current?.abort()),[c,n]);let l=a.page,d=(0,u.useMemo)(()=>l&&Tr(l.commits),[l]),f=a.error?.body.code===`graph_changed`;return(0,L.jsxs)(`section`,{className:`git-graph`,"data-git-graph":!0,"aria-label":`提交图`,"aria-busy":a.loading,children:[(0,L.jsx)(`p`,{className:`git-scope-note`,children:`仓库历史 · 文件差异按当前会话目录`}),l&&d&&l.commits.length>0&&(0,L.jsx)(`div`,{className:`git-graph-list`,tabIndex:0,role:`region`,"aria-label":`提交关系`,children:(0,L.jsx)(ri,{commits:l.commits,workspaceId:e,cwd:t,onDiff:r,graph:d})}),l&&!l.commits.length&&(0,L.jsx)(`p`,{className:`rail-empty`,children:`暂无提交记录。`}),a.error&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,children:Bt(a.error,`读取提交图失败。`)}),a.loading&&!l&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取提交图…`}),(a.error||l?.hasMore)&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action git-graph-more`,"data-git-graph-more":!0,disabled:a.loading,onClick:()=>c(f||a.error&&!a.append?void 0:l),children:a.loading?`读取中…`:f?`重新加载提交图`:a.error?`重试`:`加载更早的提交`})]})}function ci({workspaceId:e,conversationId:t,followedWorktreeId:n,revision:r,onDiff:i,onCommitDiff:a,onOpenConversation:o,repositoryOnly:s=!1}){let[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(``),p=`super-pi.git-worktree:${JSON.stringify([e,t])}`,[m,h]=(0,u.useState)(()=>{try{return window.sessionStorage.getItem(p)??n??``}catch{return n??``}}),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(``),[E,D]=(0,u.useState)(0),O=(0,u.useRef)(n),k=c?.find(e=>e.current),A=m?c?.find(e=>e.id===m):k??c?.[0],j=e=>{h(e);try{window.sessionStorage.setItem(p,e)}catch{}};(0,u.useEffect)(()=>{n&&n!==O.current&&j(n),O.current=n},[n,p]);let M=async(n,r)=>{if(!(S||s&&n!==`open`)){C(n),T(``);try{let i={action:n,requestId:ir(),worktreeId:r,...t&&!t.startsWith(`pending:`)?{conversationId:t}:{},...n===`create`?{branch:v.trim(),base:b.trim()}:{}},a=await Pr(Jr(e,`worktree-manage`),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)},65e3);j(a.worktree.id),D(e=>e+1),n===`create`&&(y(``),x(``)),a.conversationId&&o?.(a.conversationId,a.workspaceId)}catch(e){T(Fr(e).message)}finally{C(``)}}};(0,u.useEffect)(()=>{let t=!0,n=!1,r=async()=>{if(!n){n=!0;try{let n=await Pr(Jr(e,`worktrees`));t&&(l(n.worktrees),f(``))}catch(e){t&&f(Fr(e).message)}finally{n=!1}}};r();let i=window.setInterval(()=>{document.visibilityState===`visible`&&r()},1e4);return()=>{t=!1,window.clearInterval(i)}},[e,r,E]),(0,u.useEffect)(()=>{if(s||!A||A.missing)return;let t=A.id,n=!0,r=!1,i=async()=>{if(!r){r=!0;try{let r=await Pr(Jr(e,`worktree-inspect`,{worktreeId:t}));n&&_({id:t,value:r})}catch(e){n&&_({id:t,error:Fr(e).message})}finally{r=!1}}};i();let a=window.setInterval(()=>{document.visibilityState===`visible`&&i()},5e3);return()=>{n=!1,window.clearInterval(a)}},[e,A?.id,A?.missing,r,E,s]);let N=!s&&g?.id===A?.id?g:void 0,ee=N?.value?.comparison,P=N?.value?.status,te=P?Gr.map(e=>({...e,files:P[e.key]})):[],ne=(e,t)=>(0,L.jsxs)(`button`,{type:`button`,className:`git-worktree-file`,title:e.path,"data-git-worktree-file":e.path,onClick:()=>i({...t,label:A?.branch??A?.name??`关联工作树`}),children:[(0,L.jsx)(qt,{path:e.path,size:15}),` `,(0,L.jsx)(`span`,{children:e.path}),(0,L.jsx)(`small`,{children:e.xy.trim()})]},e.path);return(0,L.jsxs)(`section`,{className:`git-worktrees`,"data-git-worktrees":!0,"aria-label":`仓库工作树`,children:[d&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:d}),!c&&!d&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取工作树…`}),c&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`select`,{className:`git-view-search`,"aria-label":`选择要查看的工作树`,value:A?.id??``,onChange:e=>j(e.target.value),children:[!A&&(0,L.jsx)(`option`,{value:``,children:`选择工作树`}),c.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.branch??(e.head.slice(0,8)||e.name),` · `,e.name,e.primary?` · 主检出`:``,e.current?` · 当前`:``,e.missing?` · 已丢失`:``,e.locked?` · 已锁定`:``]},e.id))]}),A&&(0,L.jsx)(`p`,{className:`git-worktree-path`,title:A.path,"data-git-worktree-path":!0,children:A.path}),(0,L.jsxs)(`div`,{className:`git-worktree-actions`,children:[A&&!A.missing&&o&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-worktree-open":!0,disabled:!!S,onClick:()=>void M(`open`,A.id),children:`在此新建会话`}),A&&!A.missing&&t&&!t.startsWith(`pending:`)&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-worktree-follow":!0,disabled:!!S||A.id===n,onClick:()=>void M(`follow`,A.id),children:A.id===n?`会话已跟随`:`会话跟随`})]}),(0,L.jsxs)(`details`,{className:`git-worktree-create`,children:[(0,L.jsx)(`summary`,{title:s?kr:void 0,children:`新建工作树`}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),M(`create`)},children:[(0,L.jsx)(`input`,{disabled:s,title:s?kr:void 0,className:`git-view-search`,"aria-label":`工作树起点分支`,placeholder:`起点分支(默认当前提交)`,value:b,onChange:e=>x(e.target.value),maxLength:180}),(0,L.jsx)(`input`,{disabled:s,title:s?kr:void 0,className:`git-view-search`,"aria-label":`工作树的新分支`,placeholder:`新分支(可选)`,value:v,onChange:e=>y(e.target.value),maxLength:180}),(0,L.jsx)(`button`,{type:`submit`,className:`git-group-action`,"data-git-worktree-create":!0,title:s?kr:void 0,disabled:s||!!S,children:S===`create`?`创建中…`:`创建工作树`})]})]}),w&&(0,L.jsx)(`p`,{className:`tool-error`,"data-git-worktree-error":!0,role:`alert`,children:w}),A?.missing&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`此工作树目录已丢失。`}),!s&&A&&!A.missing&&!N&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`status`,children:`读取工作树状态…`}),N?.error&&!A?.missing&&(0,L.jsx)(`p`,{className:`git-scope-note`,role:`alert`,children:N.error}),A&&!A.missing&&N?.value&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`git-worktree-summary`,"data-git-worktree-status":!0,children:[N.value.status.branch??`分离 HEAD`,A.current?` · 当前会话检出`:` · 仅查看`]}),te.every(e=>!e.files.length)&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`无未提交改动。`}),te.filter(e=>e.files.length).map(e=>(0,L.jsxs)(`div`,{className:`git-worktree-group`,children:[(0,L.jsxs)(`strong`,{children:[e.title,` · `,e.files.length]}),e.files.map(t=>ne(t,{worktreeId:A.id,path:t.path,staged:e.key===`staged`}))]},e.key)),ee&&!A.primary&&(0,L.jsxs)(`div`,{className:`git-worktree-group`,"data-git-worktree-comparison":!0,children:[(0,L.jsxs)(`strong`,{children:[`相对 `,ee.base,` · ↑`,ee.ahead,` ↓`,ee.behind]}),ee.files.map(e=>ne(e,{worktreeId:A.id,path:e.path,staged:!1,comparison:`committed`})),(0,L.jsx)(ri,{commits:ee.commits,workspaceId:e,cwd:``,worktreeId:A.id,onDiff:e=>a({...e,worktreeLabel:A.branch??A.name})},A.id),ee.truncated&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`显示最近 20 条独有提交。`})]})]})]})]})}function li({workspaceId:e,conversationId:t,cwd:n=``,followedWorktreeId:r,onOpenDiff:i,activeDiffUrl:a,onOpenConversation:o,sharedGit:s,repositoryOnly:c=!1}){let[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(null),m=s?s.status:l,h=s?s.error:f,g=s?.refresh,_=s?.publish,[v,y]=(0,u.useState)(()=>c||r?`worktrees`:`changes`),b=c&&Ar(v)?`worktrees`:v;(0,u.useEffect)(()=>{r&&y(`worktrees`)},[r]);let[x,S]=(0,u.useState)(``),[C,w]=(0,u.useState)(0),[T,E]=(0,u.useState)(0),[D,O]=(0,u.useState)(),[k,A]=(0,u.useState)({}),[j,M]=(0,u.useState)(``),[N,ee]=(0,u.useState)(null),[P,te]=(0,u.useState)(``),[ne,re]=(0,u.useState)(``),[F,ie]=(0,u.useState)(null),[ae,oe]=(0,u.useState)(null),se=(0,u.useRef)(0),ce=(0,u.useCallback)(e=>{let t=++se.current;p(null),re(``),E(e=>e+1),g?g(!0):Pr(Rr(e,n)).then(e=>{t===se.current&&d(e)}).catch(e=>{t===se.current&&(d(null),p(Fr(e)))})},[n,g]);(0,u.useEffect)(()=>{if(e)return ce(e),()=>{se.current++}},[e,n,ce]);let le=e=>{c&&Ar(e)||e!==b&&(y(e),S(``),w(0))},ue=Or.find(e=>e.id===b)??Or[0],de=b===`log`||b===`branches`||b===`stash`,fe=e&&m&&de?`/api/git?workspaceId=${Ir(e)}&op=${b}&limit=${Vr}${Lr(n)}&q=${Ir(x.trim())}&offset=${C}`:``;(0,u.useEffect)(()=>{if(!fe)return;let e=!0;O({url:fe,result:$r.get(fe)});let t=window.setTimeout(()=>{Pr(fe).then(t=>{e&&(ei($r,fe,t,32),O({url:fe,result:t}),`branches`in t&&A(e=>({...e,branches:t.total})),`stashes`in t&&A(e=>({...e,stash:t.total})))}).catch(t=>{e&&O({url:fe,result:$r.get(fe),error:Fr(t).message})})},x.trim()?180:0);return()=>{e=!1,window.clearTimeout(t)}},[fe,x,T]);let pe=(t,r,a,o=!1)=>{if(!e||c)return;let s=a?.comparison?`共同祖先 → 工作树 HEAD`:o?`未跟踪文件`:r?`HEAD → 暂存区`:`暂存区 → 工作区`,l=a?.comparison?`已提交`:o?`未跟踪`:r?`已暂存`:`未暂存`;i({url:a?Jr(e,`worktree-diff`,{worktreeId:a.worktreeId,path:t,staged:r?`1`:`0`,...a.comparison?{comparison:a.comparison}:{}}):zr(e,t,r,n),path:t,label:a?`${a.label} · ${l}`:l,comparison:a?`${a.label} · ${s}`:s})},me=t=>{if(!e)return;let r=t.file.path,a=t.hash.slice(0,8);i({url:Yr(e,t.worktreeId?``:n,t.hash,t.worktreeId,r),path:r,label:t.worktreeLabel?`${t.worktreeLabel} · ${a}`:a,comparison:`提交 ${a} · 对比${t.base}`,previousPath:t.file.previousPath,commitHash:t.hash})},I=(0,u.useCallback)(async(t,r={})=>{if(!e||F||c&&t!==`fetch`)return!1;ie(t),re(``);try{if(t===`draft`)return ee(await Br(e,t,r,n)),!0;let i=await Br(e,t,r,n);return _?_(i):d(i),t!==`fetch`&&t!==`push`&&ee(null),(t===`stash-save`||t===`switch`)&&w(0),E(e=>e+1),!0}catch(n){let r=Fr(n);return t===`stash-apply`&&ce(e),re(r.body?.error||r.message||`操作失败`),!1}finally{ie(null)}},[e,n,_,F,ce,c]),he=(0,u.useCallback)(()=>{if(!ae)return;let e=ae;oe(null),I(`discard`,{path:e})},[ae,I]),ge=(0,u.useCallback)(()=>{oe(null)},[]),_e=m===null?null:Wr(m),ve=x.trim().toLowerCase(),ye=m===null?[]:Gr.map(e=>({...e,entries:m[e.key].filter(e=>e.path.toLowerCase().includes(ve))})),be=m?new Set(Gr.flatMap(e=>m[e.key].map(e=>e.path))).size:0,xe=D?.url===fe?D.result:void 0,Se=D?.url===fe?D.error:void 0,Ce=xe&&`commits`in xe?xe:null,we=xe&&`branches`in xe?xe:null,Te=xe&&`stashes`in xe?xe:null,Ee=b===`log`?Vr:50,De=we??Te,Oe=Ce?Ce.truncated:De?C+Ee<De.matches:!1;return e?(0,L.jsxs)(`div`,{className:`git-panel`,"data-git-panel":`1`,"data-git-scope":c?`repository`:`checkout`,children:[c&&(0,L.jsxs)(`p`,{className:`git-scope-note`,role:`status`,children:[`仓库浏览 · `,kr]}),m===null&&h===null&&(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-loading":`1`,children:`读取 Git 状态…`}),h!==null&&(0,L.jsxs)(`div`,{className:`git-state-card${h.body.code===`not_a_repo`?` git-state-card-empty`:` git-error`}`,"data-git-error":`1`,role:`status`,"data-git-error-code":h.body.code??``,children:[(0,L.jsx)(`span`,{className:`git-state-icon`,"aria-hidden":`true`,children:h.body.code===`not_a_repo`?`⌁`:`!`}),(0,L.jsx)(`strong`,{children:h.body.code===`not_a_repo`?`此工作区不是 git 仓库`:`Git 状态暂时不可用`}),(0,L.jsx)(`p`,{children:h.body.code===`not_a_repo`?`当前工作区没有 Git 仓库,因此没有分支、变更或提交记录可显示。文件和对话功能仍可正常使用。`:`读取仓库状态时遇到问题,请稍后重试。`}),(0,L.jsx)(`button`,{type:`button`,className:`git-state-action`,onClick:()=>ce(e),children:`重新检查`})]}),m!==null&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`git-head`,"data-git-head":`1`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-branch`,"data-git-branch":`1`,title:c?`查看仓库分支`:Ur(m),"aria-label":c?`查看仓库分支`:`当前分支 ${Ur(m)},查看分支`,onClick:()=>le(`branches`),children:[(0,L.jsx)(rn,{name:`git`}),(0,L.jsx)(`span`,{children:c?`仓库分支`:Ur(m)})]}),!c&&_e!==null&&(0,L.jsx)(`span`,{className:`git-ahead-behind`,"data-git-ahead-behind":`1`,children:_e}),(0,L.jsx)(`button`,{type:`button`,className:`git-refresh`,"data-git-refresh":`1`,title:`刷新 Git 状态`,"aria-label":`刷新 Git 状态`,onClick:()=>ce(e),children:(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`})})]}),(0,L.jsxs)(`div`,{className:`git-sync-actions`,"aria-label":`远程操作`,children:[(0,L.jsx)(`button`,{type:`button`,"data-git-action":`fetch`,onClick:()=>void I(`fetch`),disabled:F!==null,title:`从上游获取远程引用`,children:F===`fetch`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`获取中…`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),` Fetch`]})}),(0,L.jsx)(`button`,{type:`button`,"data-git-action":`pull`,onClick:()=>void I(`pull`),disabled:c||F!==null,title:c?kr:void 0,children:F===`pull`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`拉取中…`]}):`拉取`}),(0,L.jsx)(`button`,{type:`button`,"data-git-action":`push`,onClick:()=>void I(`push`),disabled:c||F!==null,title:c?kr:void 0,children:F===`push`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`推送中…`]}):`推送`})]}),(0,L.jsx)(`nav`,{className:`git-view-nav`,"aria-label":`源代码管理视图`,children:Or.map(e=>{let t=c&&Ar(e.id),n=t?void 0:e.id===`changes`?be:e.id===`branches`||e.id===`stash`?k[e.id]:void 0;return(0,L.jsxs)(`button`,{type:`button`,disabled:t,title:t?kr:void 0,"data-git-view":e.id,"aria-pressed":e.id===b,onClick:()=>le(e.id),children:[(0,L.jsx)(rn,{name:e.icon}),(0,L.jsx)(`span`,{className:`git-view-label`,children:e.title}),n!==void 0&&(0,L.jsx)(`span`,{className:`git-view-count`,children:n})]},e.id)})}),ue.search&&(0,L.jsx)(`input`,{className:`git-view-search`,type:`search`,"aria-label":ue.search,placeholder:ue.search,value:x,maxLength:160,onChange:e=>{S(e.target.value),w(0)}}),b===`worktrees`&&(0,L.jsx)(ci,{repositoryOnly:c,workspaceId:e,conversationId:t,followedWorktreeId:r,revision:T,onOpenConversation:o,onDiff:e=>pe(e.path,e.staged,e),onCommitDiff:me}),b===`graph`&&m&&(0,L.jsx)(si,{workspaceId:e,cwd:n,revision:T,onDiff:me}),ne&&(0,L.jsx)(`p`,{className:`tool-error`,"data-git-action-error":`1`,role:`alert`,children:ne}),b===`changes`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`section`,{className:`git-scm-actions`,"data-git-actions":`1`,"aria-label":`提交已暂存的更改`,children:[(0,L.jsxs)(`form`,{className:`git-commit-input`,onSubmit:async e=>{e.preventDefault(),await I(`commit`,{message:j})&&M(``)},children:[(0,L.jsx)(`input`,{value:j,onChange:e=>M(e.target.value),placeholder:`提交说明…`,"aria-label":`提交消息`,disabled:F!==null}),(0,L.jsx)(`button`,{type:`submit`,className:`git-commit-submit`,"data-git-action":`commit`,disabled:!m.staged.length||!j.trim()||F!==null,children:F===`commit`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`git-spinner`,"aria-hidden":`true`}),`提交中…`]}):`提交`})]}),(0,L.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,L.jsxs)(`span`,{children:[m.staged.length,` 个已暂存`]}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`draft`,"aria-label":`用 AI 根据当前目录的暂存差异生成提交信息`,title:`用 AI 根据当前目录的暂存差异生成提交信息`,disabled:!m.staged.length||F!==null,onClick:()=>void I(`draft`),children:F===`draft`?`生成中…`:`✧ AI 生成`})]}),N&&(0,L.jsxs)(`div`,{className:`git-draft`,"data-git-draft":!0,children:[(0,L.jsxs)(`div`,{className:`git-commit-heading`,children:[(0,L.jsx)(`strong`,{children:N.truncated?`提交说明建议 · 差异已截断`:`提交说明建议`}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"aria-label":`关闭提交说明建议`,onClick:()=>ee(null),children:`×`})]}),(0,L.jsx)(`p`,{children:N.message}),(0,L.jsx)(`button`,{type:`button`,"data-git-draft-apply":!0,onClick:()=>{M(N.message.replace(/\s*\n\s*/g,` `)),ee(null)},children:`替换输入`})]})]}),ye.map(t=>(0,L.jsxs)(`div`,{className:`git-group`,"data-git-group":t.key,children:[(0,L.jsxs)(`div`,{className:`git-group-head`,"data-git-group-head":t.key,children:[(0,L.jsx)(`span`,{className:`git-group-title`,children:t.title}),(0,L.jsx)(`span`,{className:`git-group-count`,"data-git-count":t.key,children:t.entries.length}),!ve&&t.key===`staged`&&t.entries.length>0&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`unstage-all`,disabled:F!==null,onClick:()=>void I(`unstage-all`),children:`全部取消暂存`}),!ve&&t.key===`unstaged`&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`stage-all`,disabled:F!==null||!m.unstaged.length&&!m.untracked.length,onClick:()=>void I(`stage-all`),children:`全部暂存`})]}),(0,L.jsx)(`div`,{className:`git-group-body`,children:t.entries.length===0?(0,L.jsx)(`p`,{className:`git-group-empty`,"data-git-empty":t.key,children:ve?`无匹配文件。`:`无${t.title}变更。`}):t.entries.map(r=>{let i=Er(r.xy,t.key),o=Dr(r),s=a===zr(e,r.path,t.key===`staged`,n);return(0,L.jsxs)(`div`,{className:`git-file-row${s?` is-active`:``}`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`git-file-open`,"data-git-file":r.path,"data-git-kind":o?`dir`:`file`,title:r.path,onClick:()=>pe(r.path,t.key===`staged`,void 0,t.key===`untracked`),children:[(0,L.jsx)(qt,{path:r.path,category:o?`folder`:void 0,size:15}),(0,L.jsx)(`span`,{className:`git-path`,children:o?`${r.name}/`:r.name}),r.path.includes(`/`)&&!o&&(0,L.jsx)(`span`,{className:`git-parent-path`,children:r.path.slice(0,r.path.lastIndexOf(`/`))})]}),(0,L.jsxs)(`span`,{className:`git-file-actions`,children:[t.key===`staged`?(0,L.jsx)(`button`,{type:`button`,title:`取消暂存`,disabled:F!==null,onClick:e=>{e.stopPropagation(),I(`unstage`,{path:r.path})},children:`−`}):(0,L.jsx)(`button`,{type:`button`,title:`暂存`,disabled:F!==null,onClick:e=>{e.stopPropagation(),I(`stage`,{path:r.path})},children:`+`}),t.key===`unstaged`&&(0,L.jsx)(`button`,{type:`button`,className:`git-file-action`,"data-git-action":`discard`,title:`丢弃 ${r.path} 的更改`,"aria-label":`丢弃更改 ${r.path}`,disabled:ae!==null||F!==null,onClick:e=>{e.stopPropagation(),oe(r.path)},children:`↶`})]}),(0,L.jsx)(`span`,{className:`git-badge git-badge-${i.kind} git-badge-slot-${i.slot}`,"data-git-badge":i.kind,"data-git-badge-slot":i.slot,children:i.label})]},r.path)})})]},t.key))]}),de&&!xe&&!Se&&(0,L.jsxs)(`p`,{className:`rail-empty`,"data-git-log-loading":b===`log`?`1`:void 0,role:`status`,children:[`读取`,ue.title,`…`]}),de&&Se&&(0,L.jsxs)(`div`,{className:`git-page-error`,"data-git-log-error":b===`log`?`1`:void 0,children:[(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,title:Vt(Se),children:Bt(Se,`读取 Git 列表失败。`)}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,onClick:()=>E(e=>e+1),children:`重试`})]}),b===`log`&&Ce&&(0,L.jsx)(`div`,{className:`git-log`,"data-git-log":`1`,children:Ce.commits.length===0?(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-log-empty":`1`,children:x.trim()?`没有匹配的提交。`:`暂无提交记录。`}):(0,L.jsx)(ri,{commits:Ce.commits,workspaceId:e,cwd:n,onDiff:me})}),b===`branches`&&we&&(0,L.jsxs)(`div`,{className:`git-index-list`,"data-git-branches":!0,children:[!we.canWrite&&(0,L.jsx)(`p`,{className:`git-scope-note`,children:`切换分支会改变整个工作树,请在仓库根目录操作。`}),we.branches.length===0&&(0,L.jsx)(`p`,{className:`rail-empty`,children:x.trim()?`没有匹配的分支。`:`暂无分支。`}),we.branches.map(e=>(0,L.jsxs)(`div`,{className:`git-index-row`,"data-git-ref":e.name,children:[(0,L.jsx)(`span`,{className:`git-index-name`,title:e.name,children:e.name}),e.current?!c&&(0,L.jsx)(`span`,{className:`git-index-current`,children:`当前`}):e.local?we.canWrite&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`switch`,"aria-label":`切换到 ${e.name}`,disabled:c||F!==null,title:c?kr:void 0,onClick:()=>void I(`switch`,{target:e.name}),children:`切换`}):(0,L.jsx)(`span`,{className:`git-index-meta`,children:`远程`})]},`${e.local}:${e.name}`))]}),b===`stash`&&Te&&(0,L.jsxs)(`div`,{className:`git-index-list`,"data-git-stashes":!0,children:[Te.canWrite?(0,L.jsxs)(`form`,{className:`git-stash-form`,onSubmit:async e=>{e.preventDefault(),await I(`stash-save`,{message:P})&&te(``)},children:[(0,L.jsxs)(`div`,{className:`git-commit-input`,children:[(0,L.jsx)(`input`,{className:`git-view-search`,value:P,onChange:e=>te(e.target.value),maxLength:200,"aria-label":`贮藏说明`,placeholder:`贮藏说明(可选)`}),(0,L.jsx)(`button`,{type:`submit`,className:`git-group-action`,"data-git-action":`stash-save`,disabled:!be||F!==null,children:`贮藏改动`})]}),(0,L.jsx)(`p`,{className:`git-scope-note`,children:`保存整个工作树的改动,包括未跟踪文件。`})]}):(0,L.jsx)(`p`,{className:`git-scope-note`,children:`贮藏影响整个工作树,请在仓库根目录操作。`}),Te.stashes.length===0&&(0,L.jsx)(`p`,{className:`rail-empty`,children:x.trim()?`没有匹配的贮藏。`:`暂无贮藏记录。`}),Te.stashes.map(e=>(0,L.jsxs)(`div`,{className:`git-index-row`,"data-git-stash":e.hash,children:[(0,L.jsxs)(`div`,{className:`git-index-name`,title:e.subject,children:[e.subject,(0,L.jsxs)(`small`,{className:`git-index-meta`,children:[e.ref,` · `,Hr(e.date)]})]}),Te.canWrite&&(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-action":`stash-apply`,"aria-label":`恢复 ${e.ref}`,title:`恢复改动并保留贮藏记录`,disabled:F!==null,onClick:()=>void I(`stash-apply`,{target:e.hash}),children:`恢复`})]},`${e.ref}:${e.hash}`))]}),b!==`changes`&&xe&&(C>0||Oe)&&(0,L.jsxs)(`div`,{className:`git-pages`,children:[(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,disabled:!C,onClick:()=>w(Math.max(0,C-Ee)),children:`上一页`}),(0,L.jsxs)(`span`,{children:[`第 `,C/Ee+1,` 页`,De?` · ${De.matches} 项`:``]}),(0,L.jsx)(`button`,{type:`button`,className:`git-group-action`,"data-git-log-truncated":Ce?.truncated?`1`:void 0,disabled:!Oe,onClick:()=>w(C+Ee),children:`下一页`})]}),ae!==null&&(0,L.jsx)(Kr,{path:ae,onCancel:ge,onConfirm:he})]})]}):(0,L.jsx)(`div`,{className:`git-panel`,"data-git-panel":`1`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-git-empty":`noworkspace`,children:`请选择一个工作区查看 Git 状态。`})})}var ui=e=>e?.phase===`waiting`||e?.phase===`installing`||e?.phase===`restarting`;async function di(e,t={},n=f){let r=await ke(e,{...t,cache:`no-store`,signal:t.signal??AbortSignal.timeout(12e3)},n),i=await r.json().catch(()=>null);if(!i||!r.ok&&!(r.status===409&&i.operation))throw Error(i?.error??`更新服务未返回有效状态(HTTP ${r.status})`);return i}async function fi(e,t){let n;for(let r=0;r<2;r++)try{let n=AbortSignal.any([e,AbortSignal.timeout(8e3)]),r=await ke(`/api/update-status`,{cache:`no-store`,signal:n},t);if(r.status===404||r.ok&&r.headers.get(`content-type`)?.includes(`text/html`))return{...await di(`/api/health`,{signal:n},t),operation:null};let i=await r.json();if(!r.ok)throw Error(i?.error??`无法读取更新状态(HTTP ${r.status})`);return i}catch(t){if(n=t,e.aborted||r===1)break;await new Promise(e=>setTimeout(e,400))}throw n}var pi=e=>e===`entry`?`super-pi.update-legacy-receipt`:`super-pi.update-legacy-receipt:${e}`;function mi(e,t){try{if(t!==void 0)return t?sessionStorage.setItem(pi(e),JSON.stringify(t)):sessionStorage.removeItem(pi(e)),t;let n=JSON.parse(sessionStorage.getItem(pi(e))??`null`);return n?.id&&Date.now()-Date.parse(n.startedAt)<18e5?n:null}catch{return t??null}}var hi=e=>e?`v${e}`:`—`,gi=e=>!(!e.managed||e.legacy||e.transport===`direct`),_i=e=>e?.status?.needsRestart?`restart`:e?.latest&&e.status&&e.latest!==e.status.diskVersion?`update`:void 0;function vi(e){return e?.submitting?`starting`:e?.checking?`checking`:ui(e?.status?.operation)?e.status.operation.phase:e?.status?.needsRestart?`needs-restart`:e?.status?.operation?.phase===`failed`||e?.error?`failed`:e?.status?.operation?.phase===`completed`?`completed`:`idle`}function yi(e,t=!1){let n=vi(e);return n===`starting`?`正在提交更新`:n===`checking`?`正在检查可用版本`:n===`waiting`?`等待选中的托管服务更新结束,再更新本地入口`:n===`installing`?`正在下载并安装更新`:n===`restarting`?t?`正在自动退出并重新启动 Super Pi 桌面和本地服务`:e?.connectionLost?`等待服务重新上线`:`正在重启服务`:n===`needs-restart`?`${hi(e?.status?.diskVersion)} 已安装,等待重启`:n===`failed`?e?.error??e?.status?.operation?.failure?.message??`更新失败`:n===`completed`?`更新完成`:_i(e)?`有新版本可安装`:e?.latest?`当前已是最新版本`:`等待检查更新`}function bi(e){let{connections:t,activeServer:n}=oe(),[r,i]=(0,u.useState)({}),a=(0,u.useRef)(r);a.current=r;let[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(()=>new Set),[d,p]=(0,u.useState)(!1),[m,h]=(0,u.useState)(),[g,_]=(0,u.useState)(``),v=(0,u.useRef)(null),y=(0,u.useId)(),b=(0,u.useRef)(new Map),x=(0,u.useRef)(new Set),S=(0,u.useRef)(!1),C=(0,u.useRef)(new Map),w=(e,t)=>{let n={...a.current[e]??{},...t};a.current={...a.current,[e]:n},i(t=>JSON.stringify(t[e])===JSON.stringify(n)?t:{...t,[e]:n})},T=e=>{let t=(b.current.get(e)??0)+1;return b.current.set(e,t),t},E=JSON.stringify(t.map(({id:e,url:t,enabled:n,revision:r})=>[e,t,n,r]));(0,u.useEffect)(()=>{let e=new AbortController,n,r=async()=>{if(t.some(gi))try{let t=await di(`/api/managed-servers`,{signal:e.signal});C.current=new Map((t.profiles??[]).map(e=>[e.id,e]))}catch{}await Promise.allSettled(t.filter(e=>e.enabled).map(async t=>{if(x.current.has(t.id))return;let n=b.current.get(t.id);try{let r=await fi(e.signal,t.id);if(e.signal.aborted||n!==b.current.get(t.id))return;let i=t.managedId&&C.current.get(t.managedId);if(gi(t)&&i&&i.updateOperation&&(r.operation=i.updateOperation),r.operation)mi(t.id,null);else{let e=mi(t.id);e&&(r.operation=e.targetVersion===r.runningVersion&&!r.needsRestart?mi(t.id,{...e,phase:`completed`,changedAt:new Date().toISOString()}):Date.now()-Date.parse(e.changedAt)>15e4&&e.phase===`restarting`?mi(t.id,{...e,phase:`failed`,changedAt:new Date().toISOString(),failure:{step:`restarting`,message:`服务尚未恢复,请检查所选服务的运行状态后重试。`}}):e)}w(t.id,{status:r,connectionLost:!1})}catch{!e.signal.aborted&&n===b.current.get(t.id)&&w(t.id,{connectionLost:!0})}})),window.superPiDesktop&&window.superPiDesktop.status().then(t=>{e.signal.aborted||h(t)}).catch(()=>{}),e.signal.aborted||(n=window.setTimeout(r,o||Object.values(a.current).some(e=>ui(e.status?.operation))?1600:5e3))};return r(),()=>{e.abort(),clearTimeout(n)}},[E,o]),(0,u.useEffect)(()=>{o?v.current?.open||v.current?.showModal():v.current?.close()},[o]);async function D(e){if(x.current.has(e.id)||ui(a.current[e.id]?.status?.operation))return;if(!e.enabled){w(e.id,{error:`连接已停用,请先连接此服务端再更新。`,latest:void 0});return}x.current.add(e.id);let t=T(e.id);w(e.id,{checking:!0,error:void 0});try{let n=await di(`/api/update-check`,{signal:AbortSignal.timeout(7e4)},e.id);if(b.current.get(e.id)!==t)return;let r=e.managedId&&C.current.get(e.managedId);gi(e)&&r&&r.updateOperation&&(n.operation=r.updateOperation),w(e.id,{status:n,latest:n.latestVersion,connectionLost:!1})}catch(n){b.current.get(e.id)===t&&w(e.id,{error:n instanceof Error?n.message:`检查更新失败。`,latest:void 0})}finally{x.current.delete(e.id),w(e.id,{checking:!1})}}async function O(){await Promise.allSettled(t.filter(e=>!c.has(e.id)).map(D))}function k(e,t){for(let n of t){let t=e.profiles?.find(e=>e.id===n.managedId),r=a.current[n.id]?.status;w(n.id,{error:e.errors?.[n.managedId],status:t?.updateOperation&&r?{...r,operation:t.updateOperation}:r,submitting:!1})}}async function A(e,t){let n=a.current[e.id],r=_i(n);if(r&&n.status&&!x.current.has(e.id)&&!ui(n.status.operation)){x.current.add(e.id),T(e.id),w(e.id,{submitting:!0,error:void 0});try{let i=r===`restart`?{restartOnly:!0}:{version:n.latest},a=await di(`/api/update`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...i,...t?.length?{managedUpdates:t}:{}})},e.id);if(!a.operation){let t=new Date().toISOString();a.operation=mi(e.id,{id:t,action:r,phase:r===`restart`?`restarting`:`installing`,fromVersion:n.status.runningVersion,targetVersion:r===`restart`?n.status.diskVersion:n.latest,startedAt:t,changedAt:t})}return w(e.id,{status:a,connectionLost:!1}),a.managedResult}catch(t){w(e.id,{error:t instanceof Error?t.message:`无法确认更新请求是否送达,请检查状态。`})}finally{x.current.delete(e.id),w(e.id,{submitting:!1})}}}async function j(){if(S.current)return;S.current=!0,p(!0);let e=t.filter(e=>!c.has(e.id));try{await Promise.allSettled(e.filter(e=>!a.current[e.id]?.latest&&!a.current[e.id]?.status?.needsRestart).map(D));let t=e.filter(e=>e.enabled&&!a.current[e.id]?.error&&_i(a.current[e.id])),n=t.filter(gi),r=t.find(e=>e.id===f),i=n.map(e=>({id:e.managedId,version:a.current[e.id].status?.needsRestart?a.current[e.id].status.diskVersion:a.current[e.id].latest}));if(await Promise.allSettled(t.filter(e=>e.id!==`entry`&&!gi(e)).map(e=>A(e))),r){for(let e of n)w(e.id,{submitting:!0,error:void 0});if(k({errors:(await A(r,i))?.errors},n),a.current[r.id]?.error)for(let e of n)w(e.id,{error:`本地入口未受理托管更新,请检查本地状态后重试。`})}else if(i.length){for(let e of n)w(e.id,{submitting:!0,error:void 0});try{k(await di(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({action:`updateSelected`,updates:i})}),n)}catch(e){for(let t of n)w(t.id,{error:e instanceof Error?e.message:`无法启动托管更新`,submitting:!1})}}}finally{S.current=!1,p(!1)}}let M=t.map(e=>vi(r[e.id])),N=d||M.some(e=>[`starting`,`waiting`,`installing`,`restarting`,`checking`].includes(e)),ee=d?`starting`:M.find(e=>[`waiting`,`installing`,`restarting`,`checking`].includes(e))??(M.includes(`needs-restart`)?`needs-restart`:M.includes(`failed`)?`failed`:M.includes(`completed`)?`completed`:`idle`),P=t.filter(e=>!c.has(e.id)),te=P.some(e=>_i(r[e.id])),ne=P.some(e=>_i(r[e.id])===`restart`)&&!P.some(e=>_i(r[e.id])===`update`);return{entry:e=>(0,L.jsxs)(`button`,{type:`button`,className:`software-update-entry ${e}`,"data-software-update-entry":ee,"aria-haspopup":`dialog`,title:`软件更新`,"aria-label":`软件更新`,onClick:()=>{s(!0),O()},children:[(0,L.jsx)(rn,{name:`update`}),(0,L.jsx)(`span`,{children:`软件更新`}),N&&(0,L.jsx)(`small`,{children:`进行中`}),!N&&ee===`needs-restart`&&(0,L.jsx)(`small`,{children:`待重启`})]}),panel:(0,L.jsx)(`dialog`,{ref:v,className:`software-update-dialog software-update-multi`,"aria-labelledby":y,onClose:()=>s(!1),onClick:e=>{e.target===e.currentTarget&&s(!1)},children:(0,L.jsxs)(`div`,{className:`software-update-content`,children:[(0,L.jsxs)(`div`,{className:`software-update-header`,children:[(0,L.jsxs)(`h2`,{id:y,children:[(0,L.jsx)(rn,{name:`update`}),`软件更新`]}),(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"aria-label":`关闭软件更新`,onClick:()=>s(!1),children:(0,L.jsx)(rn,{name:`close`})})]}),(0,L.jsxs)(`div`,{className:`software-update-selection`,children:[(0,L.jsxs)(`span`,{children:[`已选择 `,P.length,` / `,t.length,` 个服务端`]}),(0,L.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>l(new Set),children:`全选`}),(0,L.jsx)(`button`,{type:`button`,disabled:N,onClick:()=>l(new Set(t.map(e=>e.id))),children:`全不选`})]}),(0,L.jsx)(`div`,{className:`software-update-targets`,children:t.map(e=>{let t=r[e.id],n=vi(t),i=t?.status?.operation;return(0,L.jsxs)(`section`,{className:`software-update-target`,"data-update-target":e.id,children:[(0,L.jsxs)(`label`,{className:`software-update-target-label`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:!c.has(e.id),disabled:N,onChange:t=>{let n=t.target.checked;l(t=>{let r=new Set(t);return n?r.delete(e.id):r.add(e.id),r})}}),(0,L.jsx)(`strong`,{children:e.name}),(0,L.jsx)(`small`,{children:e.id===`entry`?`本地入口`:gi(e)?`SSH 托管服务`:e.managed?`SSH 原有服务`:`远端服务`})]}),(0,L.jsxs)(`dl`,{className:`software-update-versions`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`运行版本`}),(0,L.jsx)(`dd`,{"data-update-version":`running`,children:hi(t?.status?.runningVersion)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`已安装`}),(0,L.jsx)(`dd`,{"data-update-version":`disk`,children:hi(t?.status?.diskVersion)})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`目标版本`}),(0,L.jsx)(`dd`,{"data-update-version":`target`,children:hi(ui(i)?i?.targetVersion:t?.latest??t?.status?.diskVersion)})]})]}),(0,L.jsxs)(`div`,{className:`software-update-progress`,"data-update-progress":n,children:[(0,L.jsx)(`div`,{className:`software-update-summary`,role:`status`,children:yi(t,e.id===`entry`&&!!m)}),[`starting`,`checking`,`waiting`,`installing`,`restarting`].includes(n)&&(0,L.jsx)(`progress`,{"aria-label":yi(t,e.id===`entry`&&!!m)}),t?.connectionLost&&(0,L.jsx)(`small`,{children:`服务连接暂时中断,正在自动重试。`}),!e.enabled&&(0,L.jsx)(`small`,{children:`此连接已停用,需连接后才能更新。`}),t?.error&&(0,L.jsx)(`p`,{role:`alert`,children:t.error}),i?.phase===`failed`&&(0,L.jsx)(`p`,{role:`alert`,children:i.failure?.message})]}),e.id===`entry`&&m&&(0,L.jsxs)(`p`,{className:`software-update-note`,children:[`桌面运行版本:`,hi(m.desktopVersion),m.needsDesktopRestart?` · 桌面端待重启`:m.desktopVersion?` · 服务更新完成后会自动重新打开桌面端`:` · 旧桌面外壳,本次更新后请从托盘退出并重新打开一次,之后支持自动重启`]})]},e.id)})}),(0,L.jsx)(`p`,{className:`software-update-note`,children:`远端先更新,本地入口最后重启。重启可能中断对应服务正在运行的任务和终端。`}),g&&(0,L.jsx)(`p`,{role:`alert`,children:g}),(0,L.jsxs)(`div`,{className:`software-update-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`software-update-secondary`,"data-update-check":!0,disabled:N||!P.length,onClick:()=>void O(),children:`检查更新`}),m?.needsDesktopRestart&&!r.entry?.status?.needsRestart&&window.superPiDesktop?.restart&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{window.superPiDesktop.restart().catch(()=>_(`无法重新启动桌面端,请从托盘退出后重新打开。`))},children:`重启桌面端`}),(0,L.jsxs)(`button`,{type:`button`,className:`software-update-primary`,"data-update-install":ne?void 0:`1`,"data-update-restart":ne?`1`:void 0,disabled:N||!P.length||!te,onClick:()=>void j(),children:[(0,L.jsx)(rn,{name:ne?`restart`:`update`}),ne?`重启所选服务`:`更新并重启所选服务`]})]})]})}),status:r[n]?.status}}function xi(e){let t=0;return e.map(e=>e.key.startsWith(`m:`)?(t=Math.max(t,Number.isFinite(e.at)?e.at:0),{...e,at:t}):e).sort((e,t)=>e.at-t.at||e.seq-t.seq).map(e=>e.key)}var Si=new Set,Ci=new Map,wi=new Map,Ti=!1;function Ei(){return typeof window<`u`&&window.superPiDesktop?.notifications?`native`:typeof window>`u`||!(`Notification`in window)?`unsupported`:window.isSecureContext?Notification.permission:`insecure`}async function Di(){return window.superPiDesktop?.notifications?(await window.superPiDesktop.notifications.status()).supported?`native`:`unsupported`:`Notification`in window?Notification.requestPermission():`denied`}function Oi(e,t){let n=window.superPiDesktop?.notifications;if(!n)return new Notification(e,{...t,icon:new URL(`/favicon.png`,location.origin).href});Ti||(Ti=!0,n.onClick(e=>wi.get(e)?.onclick?.()));let r={close:()=>{wi.delete(t.tag),n.close(t.tag),r.onclose?.()}};return wi.get(t.tag)?.close(),wi.set(t.tag,r),wi.size>64&&wi.values().next().value?.close(),r.ready=n.show({id:t.tag,title:e,body:t.body}),r.ready.catch(()=>{wi.get(t.tag)===r&&wi.delete(t.tag)}),r}function ki(e,t,n,r,i){if(!Si.has(e)){Si.add(e);try{let t=`super-pi.notification.${e}`;if(localStorage.getItem(t))return;localStorage.setItem(t,`shown`)}catch{}if(!r&&[`granted`,`native`].includes(Ei()))try{let r=Oi(t,{body:n,tag:e});Ci.set(e,r),r.onclick=()=>{window.focus(),i(),r.close(),Ci.delete(e)}}catch{}}}function Ai(e){for(let[t,n]of Ci)e.has(t)||(n.close(),Ci.delete(t))}var B=class e extends Error{constructor(t,n){var r=`KaTeX parse error: `+t,i,a,o=n&&n.loc;if(o&&o.start<=o.end){var s=o.lexer.input;i=o.start,a=o.end,i===s.length?r+=` at end of input: `:r+=` at position `+(i+1)+`: `;var c=s.slice(i,a).replace(/[^]/g,`$&̲`),l=i>15?`…`+s.slice(i-15,i):s.slice(0,i),u=a+15<s.length?s.slice(a,a+15)+`…`:s.slice(a);r+=l+c+u}super(r),this.name=`ParseError`,this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,e.prototype),this.position=i,i!=null&&a!=null&&(this.length=a-i),this.rawMessage=t}},ji=/([A-Z])/g,Mi=e=>e.replace(ji,`-$1`).toLowerCase(),Ni={"&":`&amp;`,">":`&gt;`,"<":`&lt;`,'"':`&quot;`,"'":`&#x27;`},Pi=/[&><"']/g,Fi=e=>String(e).replace(Pi,e=>Ni[e]),Ii=e=>e.type===`ordgroup`||e.type===`color`?e.body.length===1?Ii(e.body[0]):e:e.type===`font`?Ii(e.body):e,Li=new Set([`mathord`,`textord`,`atom`]),Ri=e=>Li.has(Ii(e).type),zi=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(e);return t?t[2]!==`:`||!/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?null:t[1].toLowerCase():`_relative`},Bi={displayMode:{type:`boolean`,description:`Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.`,cli:`-d, --display-mode`},output:{type:{enum:[`htmlAndMathml`,`html`,`mathml`]},description:`Determines the markup language of the output.`,cli:`-F, --format <type>`},leqno:{type:`boolean`,description:`Render display math in leqno style (left-justified tags).`},fleqn:{type:`boolean`,description:`Render display math flush left.`},throwOnError:{type:`boolean`,default:!0,cli:`-t, --no-throw-on-error`,cliDescription:`Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error.`},errorColor:{type:`string`,default:`#cc0000`,cli:`-c, --error-color <color>`,cliDescription:`A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.`,cliProcessor:e=>`#`+e},macros:{type:`object`,cli:`-m, --macro <def>`,cliDescription:`Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).`,cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:`number`,description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:`--min-rule-thickness <size>`,cliProcessor:parseFloat},colorIsTextColor:{type:`boolean`,description:`Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.`,cli:`-b, --color-is-text-color`},strict:{type:[{enum:[`warn`,`ignore`,`error`]},`boolean`,`function`],description:`Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.`,cli:`-S, --strict`,cliDefault:!1},trust:{type:[`boolean`,`function`],description:`Trust the input, enabling all HTML features such as \\url.`,cli:`-T, --trust`},maxSize:{type:`number`,default:1/0,description:`If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large`,processor:e=>Math.max(0,e),cli:`-s, --max-size <n>`,cliProcessor:parseInt},maxExpand:{type:`number`,default:1e3,description:`Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.`,processor:e=>Math.max(0,e),cli:`-e, --max-expand <n>`,cliProcessor:e=>e===`Infinity`?1/0:parseInt(e)},globalGroup:{type:`boolean`,cli:!1}};function Vi(e){if(typeof e!=`string`)return e.enum[0];switch(e){case`boolean`:return!1;case`string`:return``;case`number`:return 0;case`object`:return{};default:throw Error(`Unexpected schema type; settings must declare an explicit default.`)}}function Hi(e){return Object.prototype.hasOwnProperty.call(e,`default`)&&e.default!==void 0?e.default:Vi(Array.isArray(e.type)?e.type[0]:e.type)}function Ui(e,t,n,r){var i=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0,a=Object.prototype.hasOwnProperty.call(r,`processor`)?r.processor:void 0;e[t]=i===void 0?Hi(r):a?a(i):i}var Wi=class{constructor(e){e===void 0&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e||={};for(var t of Object.keys(Bi)){var n=Bi[t];n&&Ui(this,t,e,n)}}isTrusted(e){if(`url`in e&&e.url&&!e.protocol){var t=zi(e.url);if(t==null)return!1;e.protocol=t}return!!(typeof this.trust==`function`?this.trust(e):this.trust)}},Gi=class{constructor(e,t,n){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=n}sup(){return ea[ta[this.id]]}sub(){return ea[na[this.id]]}fracNum(){return ea[ra[this.id]]}fracDen(){return ea[ia[this.id]]}cramp(){return ea[aa[this.id]]}text(){return ea[oa[this.id]]}isTight(){return this.size>=2}},Ki=0,qi=1,Ji=2,Yi=3,Xi=4,Zi=5,Qi=6,$i=7,ea=[new Gi(Ki,0,!1),new Gi(qi,0,!0),new Gi(Ji,1,!1),new Gi(Yi,1,!0),new Gi(Xi,2,!1),new Gi(Zi,2,!0),new Gi(Qi,3,!1),new Gi($i,3,!0)],ta=[Xi,Zi,Xi,Zi,Qi,$i,Qi,$i],na=[Zi,Zi,Zi,Zi,$i,$i,$i,$i],ra=[Ji,Yi,Xi,Zi,Qi,$i,Qi,$i],ia=[Yi,Yi,Zi,Zi,$i,$i,$i,$i],aa=[qi,qi,Yi,Yi,Zi,Zi,$i,$i],oa=[Ki,qi,Ji,Yi,Ji,Yi,Ji,Yi],sa={DISPLAY:ea[Ki],TEXT:ea[Ji],SCRIPT:ea[Xi],SCRIPTSCRIPT:ea[Qi]},ca=[{name:`latin`,blocks:[[256,591],[768,879]]},{name:`cyrillic`,blocks:[[1024,1279]]},{name:`armenian`,blocks:[[1328,1423]]},{name:`brahmic`,blocks:[[2304,4255]]},{name:`georgian`,blocks:[[4256,4351]]},{name:`cjk`,blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:`hangul`,blocks:[[44032,55215]]}];function la(e){for(var t=0;t<ca.length;t++)for(var n=ca[t],r=0;r<n.blocks.length;r++){var i=n.blocks[r];if(e>=i[0]&&e<=i[1])return n.name}return null}var ua=[];ca.forEach(e=>e.blocks.forEach(e=>ua.push(...e)));function da(e){for(var t=0;t<ua.length;t+=2)if(e>=ua[t]&&e<=ua[t+1])return!0;return!1}var fa=e=>e+` `+e,pa=80,ma=function(e,t){return`M95,`+(622+e+t)+`
23
23
  c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
24
24
  c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
25
25
  c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
@@ -284,7 +284,7 @@ ${h}.`);break;case m:switch(t){case`xml`:break;case``:e.fail(`the default namesp
284
284
  `&&(s+=1),n.length===500&&s<e.length-1))return{rows:n,clipped:!0}}else i+=c}return(i||r.length)&&(r.length<50?r.push(i):o=!0,n.push(r)),{rows:n,clipped:o}}function Xd({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?Jd(r,e,t,f,i):qd(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 ke(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?Yd(a,/\.tsv$/i.test(n)?` `:`,`):void 0,[i,a,n,m]);return(0,L.jsxs)(`section`,{className:`workspace-file-preview`,"aria-label":`预览 ${r}`,"data-workspace-file-preview":i,"data-file-readonly":f?`1`:void 0,children:[(0,L.jsxs)(`div`,{className:`workspace-file-preview-head`,children:[d,(0,L.jsxs)(`div`,{className:`workspace-file-preview-actions`,children:[f&&(0,L.jsx)(`span`,{children:`外部文件 · 只读`}),f&&p&&(0,L.jsx)(`button`,{type:`button`,onClick:p,children:`重新读取`}),o&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),children:m?`查看表格`:f?`查看原文`:`编辑原文`}),(0,L.jsxs)(`a`,{href:S,download:r,children:[(0,L.jsx)(Ud,{name:`download`}),`下载`]})]})]}),l&&!m&&(0,L.jsx)(`p`,{role:`status`,children:o?`磁盘上的文件已变化,请打开原文查看。`:`磁盘上的文件已移走或无法读取。`}),m?o:v?(0,L.jsx)(`p`,{role:`status`,children:`预览无法打开,可以下载文件。`}):(0,L.jsxs)(L.Fragment,{children:[i===`download`&&(0,L.jsx)(`p`,{children:`此文件可以下载。`}),i===`image`&&(0,L.jsx)(`img`,{src:x,alt:r,onError:()=>y(!0)}),i===`pdf`&&(0,L.jsx)(`iframe`,{src:x,title:r}),i===`audio`&&(0,L.jsx)(`audio`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`video`&&(0,L.jsx)(`video`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`document`&&(g?.error?(0,L.jsx)(`p`,{role:`alert`,children:g.error}):g?(0,L.jsxs)(L.Fragment,{children:[g.warnings?.map(e=>(0,L.jsx)(`p`,{children:e},e)),(0,L.jsx)(`pre`,{children:g.text||`此文档没有可显示的文字。`})]}):(0,L.jsx)(`p`,{children:`正在读取文档…`})),w&&(w.rows.length?(0,L.jsx)(`div`,{className:`workspace-file-table`,children:(0,L.jsx)(`table`,{children:(0,L.jsx)(`tbody`,{children:w.rows.map((e,t)=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{scope:`row`,children:t+1}),e.map((e,t)=>(0,L.jsx)(`td`,{children:e},t))]},t))})})}):(0,L.jsx)(`p`,{children:`文件为空。`})),w?.clipped&&(0,L.jsx)(`p`,{className:`workspace-file-preview-limit`,children:`表格超出预览范围。完整内容可在原文中查看。`})]})]})}var Zd={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 Qd(e){return/\.([^./]+)$/.exec(e)?.[1].toLowerCase()??``}function $d(e){let t=Qd(e);return Object.hasOwn(Zd,t)?Zd[t]:void 0}function ef(e){let t=$d(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 tf=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`))),nf=(e,t)=>!t||e===t||e.startsWith(`${t}/`),rf=e=>e.split(`/`).at(-1)??e;function af(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 of({title:e,cancel:t,children:n}){let r=(0,u.useRef)(null);return(0,u.useEffect)(()=>{let e=r.current,t=document.activeElement;return e?.showModal(),()=>{e?.close(),t?.isConnected&&t.focus()}},[]),(0,L.jsx)(`dialog`,{ref:r,className:`file-explorer-dialog`,"aria-label":e,onCancel:e=>{e.preventDefault(),t()},onClick:e=>{e.target===e.currentTarget&&t()},children:(0,L.jsxs)(`div`,{className:`file-explorer-dialog-body`,children:[(0,L.jsx)(`h2`,{children:e}),n]})})}function sf({target:e,label:t,initial:n,busy:r,error:i,depth:a,submit:o,close:s}){let c=(0,u.useRef)(null);return(0,u.useLayoutEffect)(()=>{let t=c.current;if(!t)return;t.focus();let r=n.lastIndexOf(`.`);t.setSelectionRange(0,!e.directory&&r>0?r:n.length)},[n,e.directory]),(0,L.jsxs)(`form`,{className:`file-inline-edit`,"data-file-inline-edit":e.path,"aria-label":t,style:{paddingInlineStart:23+a*15},onSubmit:o,onKeyDown:e=>{e.key===`Escape`&&!r&&(e.preventDefault(),e.stopPropagation(),s())},children:[(0,L.jsxs)(`div`,{className:`file-inline-row`,children:[(0,L.jsx)(qt,{path:e.path,category:e.directory?`folder`:void 0}),(0,L.jsx)(`input`,{ref:c,name:`name`,required:!0,defaultValue:n,placeholder:t,"aria-label":t,"aria-invalid":!!i,readOnly:r,autoComplete:`off`,spellCheck:!1}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`submit`,title:t,"aria-label":t,disabled:r,children:(0,L.jsx)(Ud,{name:`right`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,onClick:s,disabled:r,title:`取消`,"aria-label":`取消`,children:(0,L.jsx)(Ud,{name:`close`})})]}),i&&(0,L.jsx)(`p`,{className:`file-inline-error`,role:`alert`,children:i})]})}function cf({files:e,source:t,scopeName:n}){let[r,i]=(0,u.useState)(tf(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&&nf(e.path,t.path))):[];return(0,L.jsxs)(`div`,{className:`file-move-picker`,children:[(0,L.jsx)(`input`,{type:`hidden`,name:`parent`,value:r}),(0,L.jsxs)(`div`,{className:`file-move-location`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:!r,"aria-label":`上一级`,onClick:()=>i(tf(r)),children:`↑`}),(0,L.jsx)(`span`,{title:r||n,children:r||n})]}),(0,L.jsx)(`ul`,{"aria-label":`目标文件夹`,children:s.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),children:[(0,L.jsx)(qt,{category:`folder`}),(0,L.jsx)(`span`,{children:e.name}),(0,L.jsx)(Ud,{name:`right`})]})},e.path))}),!s.length&&(0,L.jsx)(`p`,{children:a?`error`in a?a.error.message:`此处没有子文件夹。`:`正在读取文件夹…`})]})}function lf({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)=>qd(t,e??``,n,r,i);async function E(e,t){let n=await ke(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)nf(e.path,s.path)&&!e.dirty&&r.closeFile(e.path);r.locatePath(tf(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:rf(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])=>nf(e,n.path)&&t.state===`saving`)){v(`文件正在保存,等保存结束后再操作。`);return}if(t===`trash`&&r.open.some(e=>e.dirty&&nf(e.path,n.path))){v(`这里有未保存的草稿,请先保存。`);return}let i=new FormData(e.currentTarget),a=String(i.get(`name`)??rf(n.path));if(t===`move`&&!n.directory&&Qd(n.path)!==Qd(a)&&r.open.some(e=>e.path===n.path&&e.dirty)){v(`更换文件扩展名之前,请先保存草稿。`);return}let o=String(i.get(`parent`)??(t===`move`?tf(n.path):n.path));d.move&&o===tf(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 P(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 te(e,t){l(void 0),a?.(e||`.`,t)}function ne(e){O(!0),pd(e||`.`).then(t=>r.setNotice(t?`已复制相对路径。`:`相对路径:${e||`.`}`))}let re=d?.action===`create-file`?`新建文件`:d?.action===`create-directory`?`新建文件夹`:d?.action===`trash`?`移到回收站`:d?.move?`移动到文件夹`:`重命名`,F={path:``,directory:!0},ie=d?.action===`create-file`||d?.action===`create-directory`,ae=d?.action===`move`&&!d.move,oe=(e,t,n)=>!d||d.target.path!==e||(t===`child`?!ie:!ae)?null:(0,L.jsx)(sf,{target:{...d.target,directory:ie?d.action===`create-directory`:d.target.directory},label:re,initial:ae?rf(e):``,busy:h,error:_,depth:n,submit:M,close:A},`${d.action}:${e}`),se=(e,t)=>{h||e.linked||e.directory&&nf(t,e.path)||t===tf(e.path)||(Object.entries(r.saves).some(([t,n])=>nf(t,e.path)&&n.state===`saving`)?r.setNotice(`文件正在保存,等保存结束后再移动。`):j({action:`move`,path:e.path,parent:t,name:rf(e.path)}))},ce=(0,L.jsxs)(`div`,{className:`file-explorer-toolbar`,role:`group`,"aria-label":`文件操作`,children:[(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-file`,title:`新建文件`,"aria-label":`新建文件`,onClick:e=>k(`create-file`,F,!1,e.currentTarget),disabled:!e||h,children:(0,L.jsx)(Ud,{name:`file`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-directory`,title:`新建文件夹`,"aria-label":`新建文件夹`,onClick:e=>k(`create-directory`,F,!1,e.currentTarget),disabled:!e||h,children:(0,L.jsx)(Ud,{name:`folder`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-refresh":`1`,title:`刷新目录`,"aria-label":`刷新目录`,onClick:r.refreshTree,disabled:!e,children:(0,L.jsx)(Ud,{name:`refresh`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-collapse-all":`1`,title:`折叠所有文件夹`,"aria-label":`折叠所有文件夹`,onClick:r.collapseDirectories,disabled:!r.expanded.size,children:(0,L.jsx)(Ud,{name:`collapse`})}),(0,L.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`root-menu`,"aria-haspopup":`menu`,"aria-expanded":c?.target.path===``,onClick:e=>D(F,Wd(e.currentTarget)),title:`更多文件操作`,"aria-label":`更多文件操作`,disabled:!e||h,children:(0,L.jsx)(Ud,{name:`more`})})]}),le=(e,t,n,r,i)=>(0,L.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`file-context-item`,"data-explorer-command":r,onClick:n,children:[(0,L.jsx)(Ud,{name:t}),(0,L.jsx)(`span`,{children:e}),i&&(0,L.jsx)(`kbd`,{children:i})]});return{controls:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{ref:x,type:`file`,multiple:!0,hidden:!0,"aria-label":`上传工作区文件`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,P(S.current,t)}}),c&&(0,L.jsxs)(Gd,{label:c.target.path||t,anchor:c.anchor,close:O,children:[c.target.directory&&!c.target.linked&&(0,L.jsxs)(L.Fragment,{children:[s&&le(`在此文件夹中搜索`,`search`,()=>{let e=c.target.path;O(!1),s(e)},`search-folder`),le(`新建文件`,`file`,()=>k(`create-file`,c.target),`new-file`),le(`新建文件夹`,`folder`,()=>k(`create-directory`,c.target),`new-directory`),le(`上传到此处`,`upload`,()=>ee(c.target.path),`upload`),(0,L.jsx)(`div`,{role:`separator`})]}),c.target.path&&!c.target.linked&&(0,L.jsxs)(L.Fragment,{children:[le(`重命名`,`rename`,()=>k(`move`,c.target),`rename`,`F2`),le(`移动到文件夹`,`move`,()=>k(`move`,c.target,!0),`move`),(0,L.jsx)(`div`,{role:`separator`})]}),!c.target.linked&&a&&le(`引用到会话`,`reference`,()=>te(c.target.path,c.target.directory),`reference`),le(`复制相对路径`,`copy`,()=>ne(c.target.path)),!c.target.directory&&!c.target.linked&&(0,L.jsxs)(`a`,{role:`menuitem`,tabIndex:-1,className:`file-context-item`,href:T(`asset`,c.target.path,{download:`1`}),download:rf(c.target.path),onClick:()=>O(!0),children:[(0,L.jsx)(Ud,{name:`download`}),(0,L.jsx)(`span`,{children:`下载`})]}),!c.target.path&&le(`打开回收站`,`trash`,()=>void N(),`trash-list`),!!c.target.path&&!c.target.linked&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{role:`separator`}),le(`移到回收站`,`trash`,()=>k(`trash`,c.target),`trash`,`Delete`)]})]}),d&&!ie&&!ae&&(0,L.jsx)(of,{title:re,cancel:()=>{h||A()},children:(0,L.jsxs)(`form`,{onSubmit:M,className:`file-explorer-form`,children:[d.action===`trash`?(0,L.jsxs)(`p`,{children:[`将「`,d.target.path,`」移到回收站?`]}):(0,L.jsx)(cf,{files:r,source:d.target,scopeName:t}),_&&(0,L.jsx)(`p`,{role:`alert`,children:_}),(0,L.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:h,onClick:A,children:`取消`}),(0,L.jsx)(`button`,{type:`submit`,disabled:h,children:d.move?`移动到此处`:re})]})]})}),p&&(0,L.jsxs)(of,{title:`回收站`,cancel:()=>{h||m(void 0)},children:[_&&(0,L.jsx)(`p`,{role:`alert`,children:_}),p.length?(0,L.jsx)(`ul`,{className:`file-explorer-trash`,children:p.map(e=>(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`span`,{children:e.path}),(0,L.jsx)(`button`,{type:`button`,"data-explorer-restore":e.path,disabled:h,onClick:()=>void j({action:`restore`,id:e.id}),children:`还原`})]},e.id))}):(0,L.jsx)(`p`,{children:`回收站为空。`}),(0,L.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>m(void 0),children:`关闭`})]}),y&&(0,L.jsxs)(of,{title:`同名文件`,cancel:()=>b(void 0),children:[(0,L.jsx)(`p`,{children:`以下文件已经存在。替换前会再次检查磁盘版本。`}),(0,L.jsx)(`ul`,{children:y.items.map(e=>(0,L.jsx)(`li`,{children:e.file.name},e.file.name))}),(0,L.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{r.setNotice(`已跳过 ${y.items.length} 个同名文件。`),b(void 0)},children:`跳过`}),(0,L.jsx)(`button`,{type:`button`,"data-file-replace-upload":`1`,onClick:()=>void P(y.parent,y.items.map(e=>e.file),y.items),children:`替换`})]})]})]}),toolbar:ce,inline:oe,editing:ie||ae,busy:h,openMenu:D,showAction:k,upload:P,moveTo:se}}var uf=[{id:`path`,label:`文件名 / 路径`,shortcut:`Ctrl+P`},{id:`content`,label:`文件内容`,shortcut:`Ctrl+Shift+F`},{id:`session`,label:`会话消息`}];function df({mode:e,query:t,onClose:n,onMode:r,children:i,presentation:a}){let o=e===`path`?{"data-quick-open":`1`}:e===`content`?{"data-content-search":`1`}:{"data-session-search":`1`},s=(0,L.jsx)(`div`,{className:`workbench-search-modes`,role:`group`,"aria-label":`搜索范围`,children:uf.map(n=>(0,L.jsx)(`button`,{type:`button`,"data-workbench-search-mode":n.id,"aria-pressed":n.id===e,title:n.shortcut,onClick:()=>{n.id!==e&&r(n.id,t)},children:n.label},n.id))});return a===`sidebar`?(0,L.jsxs)(`div`,{className:`workbench-search-embedded`,...o,children:[s,i]}):(0,L.jsx)(`div`,{className:`quick-open-backdrop`,...o,role:`presentation`,onMouseDown:n,children:(0,L.jsxs)(`div`,{className:e===`path`?`quick-open`:`quick-open content-search`,role:`dialog`,"aria-modal":`true`,"aria-label":uf.find(t=>t.id===e)?.label,onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key===`Escape`&&!e.nativeEvent.isComposing&&(e.preventDefault(),n())},children:[s,i]})})}function ff({workspaceId:e,initialQuery:t=``,onClose:n,onMode:r,onOpen:i,presentation:a}){let[o,s]=(0,u.useState)(t),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(0),[h,g]=(0,u.useState)(!1),_=(0,u.useRef)(null),v=(0,u.useRef)(null);return(0,u.useEffect)(()=>{_.current?.focus()},[]),(0,u.useEffect)(()=>{v.current?.scrollIntoView({block:`nearest`})},[p]),(0,u.useEffect)(()=>{let t=o.trim();if(l(void 0),m(0),f(``),g(!1),!e||!t)return;if(t.length>256){f(`搜索词不能超过 256 个字符。`);return}let n=new AbortController;g(!0);let r=setTimeout(()=>{ke(`/api/session-search?${new URLSearchParams({workspaceId:e,q:t})}`,{signal:n.signal}).then(async e=>{if(!e.ok)throw Error(`会话搜索没有完成。`);return await e.json()}).then(e=>{n.signal.aborted||l(e)}).catch(e=>{n.signal.aborted||f(Bt(e,`会话搜索没有完成。`))}).finally(()=>{n.signal.aborted||g(!1)})},180);return()=>{clearTimeout(r),n.abort()}},[o,e]),(0,L.jsxs)(df,{mode:`session`,query:o,onMode:r,onClose:n,presentation:a,children:[(0,L.jsx)(`input`,{ref:_,className:`quick-open-input`,"data-session-search-input":!0,value:o,"aria-label":`搜索会话消息`,placeholder:`输入要在会话消息中查找的文字`,onChange:e=>s(e.target.value),onKeyDown:e=>{if(!e.nativeEvent.isComposing&&(e.key===`ArrowDown`&&(e.preventDefault(),m(e=>Math.min(e+1,Math.max(0,(c?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),m(e=>Math.max(0,e-1))),e.key===`Enter`)){e.preventDefault();let t=c?.hits[p];t&&i(t)}}}),(0,L.jsx)(`p`,{className:`quick-open-status`,role:`status`,"data-session-search-status":!0,children:d||(h?`搜索中…`:e?c?c.truncated?`显示前 60 条命中`:`${c.hits.length} 条命中`:`当前工作区的未归档会话 · 用户和 Agent 消息`:`请选择工作区`)}),(0,L.jsx)(`ul`,{className:`quick-open-results content-search-results`,"aria-label":`会话搜索结果`,children:c?.hits.map((e,t)=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{ref:t===p?v:void 0,type:`button`,"data-session-search-result":e.messageId,className:`quick-open-result content-search-result${p===t?` quick-open-result-active`:``}`,onMouseEnter:()=>m(t),onClick:()=>i(e),children:[(0,L.jsxs)(`span`,{children:[e.title,` · `,e.role===`user`?`用户`:`Agent`]}),(0,L.jsxs)(`small`,{children:[e.before,(0,L.jsx)(`mark`,{children:e.match}),e.after]})]})},`${e.conversationId}:${e.messageId}`))})]})}var pf=class extends u.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[SuperPi ErrorBoundary captured error]:`,e,t)}reset=()=>{this.setState({error:null})};render(){let{error:e}=this.state;return e?this.props.fallback?this.props.fallback(e,this.reset):(0,L.jsxs)(`div`,{className:`error-boundary-card`,"data-error-boundary":`1`,children:[(0,L.jsxs)(`div`,{className:`error-boundary-head`,children:[(0,L.jsx)(`span`,{className:`error-boundary-icon`,"aria-hidden":`true`,children:`⚠️`}),(0,L.jsx)(`strong`,{children:`视图渲染遇到异常`})]}),(0,L.jsx)(`p`,{className:`error-boundary-msg`,children:e.message||`未知组件错误`}),(0,L.jsx)(`button`,{type:`button`,className:`error-boundary-retry`,onClick:this.reset,children:`重试`})]}):this.props.children}};function mf(){}mf.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(hf(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 hf(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 mf;var gf=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,_f=/\S/,vf=new mf;vf.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!_f.test(e)&&!_f.test(t)},vf.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]&&gf.test(t[n])&&gf.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var yf=new mf;yf.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,`
285
285
  `));var t=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var r=0;r<n.length;r++){var i=n[r];r%2&&!this.options.newlineIsToken?t[t.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),t.push(i))}return t};function bf(e,t,n){return yf.diff(e,t,n)}var xf=new mf;xf.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var Sf=new mf;Sf.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Cf(e){"@babel/helpers - typeof";return Cf=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},Cf(e)}var wf=Object.prototype.toString,Tf=new mf;Tf.useLongestToken=!0,Tf.tokenize=yf.tokenize,Tf.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(Ef(e,null,null,i),i,` `)},Tf.equals=function(e,t){return mf.prototype.equals.call(Tf,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function Ef(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(wf.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Ef(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),Cf(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]=Ef(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var Df=new mf;Df.tokenize=function(e){return e.slice()},Df.join=Df.removeEmpty=function(e){return e};function Of(e,t){let n=bf(e??``,t??``),r=[],i=0,a=0,o=1,s=1;for(let e of n){let t=e.value.split(`
286
286
  `),n=t.length>0&&t[t.length-1]===``;n&&t.pop();for(let c=0;c<t.length;c+=1){let l=t[c],u=c===t.length-1&&!n;e.added?(r.push({kind:`added`,text:l,newLine:s,noNewline:u}),s+=1,i+=1):e.removed?(r.push({kind:`removed`,text:l,oldLine:o,noNewline:u}),o+=1,a+=1):(r.push({kind:`same`,text:l,oldLine:o,newLine:s,noNewline:u}),o+=1,s+=1)}}return{lines:r,added:i,removed:a,identical:i===0&&a===0}}function kf(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 Af=`super-pi.outbox.v1.`,jf=e=>Af+JSON.stringify([e.conversationId,e.clientId]);function Mf(){try{let e=[];for(let t of Object.keys(window.localStorage).filter(e=>e.startsWith(Af)))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===jf(r)&&e.push(n)}catch{}return e.sort((e,t)=>e.queuedAt-t.queuedAt).map(e=>e.send)}catch{return[]}}function Nf(e){try{return window.localStorage.setItem(jf(e),JSON.stringify({queuedAt:Date.now(),send:e})),!0}catch{return!1}}function Pf(e,t){try{window.localStorage.removeItem(jf({conversationId:e,clientId:t}))}catch{}}function Ff(e){return m(h(e.conversationId).server,e.clientId)}function If(e,t,n){let r=e.conversations.find(e=>e.id===t.conversationId),i=Ff(t);if(!r||r.messages.some(e=>e.id===i))return e;let a=r.status===`running`||r.status===`waiting`;return{...e,conversations:e.conversations.map(e=>e===r?{...e,...a?{}:{status:`waiting`,updatedAt:n},messages:[...e.messages,{id:i,role:`user`,content:t.content,createdAt:n,...t.images?.length?{images:t.images}:{},...t.attachments?.length?{attachments:t.attachments}:{},...a?{delivery:`waiting`}:{}}]}:e)}}function Lf(e,t){try{return JSON.parse(Ke(e)??`null`)??t}catch{return t}}function Rf(e,t){try{return qe(e,JSON.stringify(t)),!0}catch{return!1}}var zf=`modulepreload`,Bf=function(e){return`/`+e},Vf={},Hf=function(e){return e.pathname.endsWith(`.css`)},Uf=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},Wf=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=Bf(t,n);let r=s(t),i=Hf(r);return Uf(Vf,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`:zf,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)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).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)})},Gf=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.name=`BlameApiError`,this.status=e,this.body=t}},Kf=class extends Error{constructor(){super(`Blame 请求已取消`),this.name=`BlameCancelledError`}},qf=(e,t,n=``)=>`/api/git?workspaceId=${encodeURIComponent(e)}&op=blame&path=${encodeURIComponent(t)}${n?`&cwd=${encodeURIComponent(n)}`:``}`;async function Jf(e,t,n={}){if(n.signal?.aborted)throw new Kf;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 ke(qf(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 Gf(r.status,{error:e.error||`HTTP ${r.status}`,...e.code?{code:e.code}:{}})}return a}catch(e){throw n.signal?.aborted?new Kf:a?new Gf(408,{error:`请求超时:${Math.round(r/1e3)} 秒内服务端没有响应`,code:`timeout`}):e}finally{clearTimeout(o),n.signal?.removeEventListener(`abort`,s)}}var Yf=`\0`,Xf=(e,t,n)=>[e,t,n??``].join(Yf),Zf=24,Qf=new Map;function $f(e){let t=Qf.get(e);if(t)return Qf.delete(e),Qf.set(e,t),t}function ep(e,t){for(Qf.delete(e),Qf.set(e,t);Qf.size>Zf;){let e=Qf.keys().next();if(e.done)break;Qf.delete(e.value)}}var tp={untracked:`这个文件尚未被 Git 跟踪`,binary:`二进制文件不支持 Blame`,too_large:`文件过大,未显示 Blame`,no_head:`仓库还没有提交`,not_in_revision:`这个版本里没有这个文件`},np=`此工作区不是 Git 仓库`;function rp(e){return e&&tp[e]?{code:e,text:tp[e]}:{code:`unsupported`,text:`这个文件暂时不能显示 Blame`}}function ip(e){return e instanceof Gf&&e.body.code===`not_a_repo`?{state:`unsupported`,note:{code:`not_a_repo`,text:np}}:{state:`error`,note:{code:`error`,text:`读取 Blame 失败:${e instanceof Error&&e.message?e.message:`未知错误`}`}}}var ap=`${Yf}uncommitted`;function op(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?ap:n.commit??`${Yf}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 sp(e){let t=0;for(let n of e.lines)n.line>t&&(t=n.line);return t}function cp(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 lp(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,up(t.date),t.summary?.trim()||`(没有提交摘要)`]}function up(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 dp(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 fp(e,t,n=!1){return!t||!t.supported?!1:n||dp(e)!==t.totalLines}var pp=new WeakMap;function mp(e){let t=pp.get(e);if(t)return t;let n={response:e,models:op(e),covered:sp(e)};return pp.set(e,n),n}function hp(e,t){if(!e||t<1)return null;let n=e.models[t-1];return n&&n.line===t?n:null}var gp=`a1b2c3d · Author`;async function _p(){let[e,t]=await Promise.all([Wf(()=>import(`./dist-D978o95T.js`).then(e=>e.S),__vite__mapDeps([0,1])),Wf(()=>import(`./dist-DlPa5gNa.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=lp(this.model);return e.setAttribute(`title`,t.join(`
287
- `)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=cp(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=gp,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=hp(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=hp(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:vp(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 vp(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 lp(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function yp(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 bp=4e3,xp=(0,u.lazy)(()=>Wf(()=>import(`./CodeMirrorEditor-B1roGtGI.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([3,1]))),Sp=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},Cp=15e3,wp=e=>new Sp(408,{error:`请求超时:${Cp/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function Tp(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),Cp);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await ke(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new Sp(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?wp(e):t}finally{clearTimeout(r)}}var Ep=e=>e instanceof Sp?e:new Sp(0,{error:e instanceof Error?e.message:`读取失败`}),Dp=e=>encodeURIComponent(e),Op=e=>e?`&cwd=${Dp(e)}`:``,kp=(e,t,n)=>`/api/files?workspaceId=${Dp(e)}&path=${Dp(t)}${Op(n)}`,Ap=`//workspace/`,jp=e=>e.startsWith(Ap)?e.slice(12):void 0,Mp=(e,t,n)=>{let r=jp(t);return`/api/file?workspaceId=${Dp(e)}&path=${Dp(r??t)}${Op(r?``:n)}`},Np=(e,t,n)=>Mp(e,t,n)+`&meta=1`,Pp=(e,t,n)=>`/api/files?workspaceId=${Dp(e)}&q=${Dp(t)}${Op(n)}`;async function Fp(e,t,n){let r=t.current;if(!r)return t.current=Tp(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return Tp(e,{cache:`no-store`})}function Ip(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 Lp(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function Rp(e){let t=Ip(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return Lp(t)}function zp(e){return Ip(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function Bp(e,t,n){if(n.openLink){let r=await Tp(`/api/files/open?workspaceId=${Dp(e)}${Op(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=ef(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=ef(r);if(a===!1&&!o)throw Error(`此文件可通过文件操作菜单下载。`);if(o&&o!==`table`)return{path:r,name:i,content:``,etag:(await Tp(Np(e,r,t))).etag,dirty:!1,view:o};try{let n=await Tp(Mp(e,r,t));return{path:jp(r)?r:n.path,name:i,content:n.content,etag:n.meta.etag,dirty:!1,view:o}}catch(n){if(!(n instanceof Sp)||![413,415].includes(n.status))throw n;return{path:r,name:i,content:``,etag:(await Tp(Np(e,r,t))).etag,dirty:!1,view:`download`}}}var Vp=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function Hp({workspaceId:e,entryPath:t,name:n,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f,linked:p,presentation:m}){let h=r[t],g=i.has(t);(0,u.useEffect)(()=>{g&&h===void 0&&o(t)},[g,t,h,o]);let _=m.inline(t,`entry`,f),v=m.inline(t,`child`,f+1);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-dir`,"data-file-dir-toggle":t,"aria-expanded":g,tabIndex:-1,draggable:!p,title:c.has(t)?`${t} 里有 agent 改过的文件`:t,onClick:()=>a(t),children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,L.jsx)(Ud,{name:g?`down`:`right`})}),(0,L.jsx)(qt,{category:g?`folder-open`:`folder`}),(0,L.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${n} 的文件操作`,children:(0,L.jsx)(Ud,{name:`more`})})]}),_,g&&(0,L.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,L.jsx)(`li`,{children:v}),h===void 0?(0,L.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,L.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:Vt(h.error.message),children:Bt(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,L.jsxs)(L.Fragment,{children:[h.truncated&&(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,L.jsx)(Hp,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f+1,presentation:m},t.path):(0,L.jsx)(Up,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function Up({entry:e,depth:t,openPaths:n,changedPaths:r,onOpen:i,presentation:a}){let o={"--file-depth":t};if(e.kind===`symlink`&&!e.openLink)return(0,L.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=ef(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-entry":e.path,"data-linked":e.symlink,"data-file-outside":e.outside?e.path:void 0,"data-file-row-open":s?`1`:`0`,"data-file-row-changed":c?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-open":e.path,"aria-disabled":!u||void 0,title:u?e.path:`${e.name} 可以通过文件操作菜单下载`,tabIndex:-1,"aria-current":d?`true`:void 0,draggable:!e.symlink,onClick:t=>{u&&i(e.openLink&&!e.outside?{...e,openLink:void 0}:e,t.detail>1)},children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(qt,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,L.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,"aria-haspopup":`menu`,tabIndex:-1,"aria-label":`${e.name} 的文件操作`,children:(0,L.jsx)(Ud,{name:`more`})})]}),f]})}function Wp({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=Xf(T,e.path,e.etag),a=r?void 0:$f(i);if(a){x({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:T,note:a.supported?null:rp(a.reason)});return}x({state:`loading`,response:null,path:e.path,workspaceId:T,note:null});let o=jp(e.path);return Jf(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===S.current&&(r||ep(i,n),x({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:T,note:n.supported?null:rp(n.reason)}))}).catch(n=>{if(t!==S.current||n instanceof Kf)return;let r=ip(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`&&fp(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
+ `)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=cp(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=gp,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=hp(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=hp(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:vp(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 vp(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 lp(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function yp(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 bp=4e3,xp=(0,u.lazy)(()=>Wf(()=>import(`./CodeMirrorEditor-CtY_gf8i.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([3,1]))),Sp=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},Cp=15e3,wp=e=>new Sp(408,{error:`请求超时:${Cp/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function Tp(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),Cp);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await ke(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new Sp(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?wp(e):t}finally{clearTimeout(r)}}var Ep=e=>e instanceof Sp?e:new Sp(0,{error:e instanceof Error?e.message:`读取失败`}),Dp=e=>encodeURIComponent(e),Op=e=>e?`&cwd=${Dp(e)}`:``,kp=(e,t,n)=>`/api/files?workspaceId=${Dp(e)}&path=${Dp(t)}${Op(n)}`,Ap=`//workspace/`,jp=e=>e.startsWith(Ap)?e.slice(12):void 0,Mp=(e,t,n)=>{let r=jp(t);return`/api/file?workspaceId=${Dp(e)}&path=${Dp(r??t)}${Op(r?``:n)}`},Np=(e,t,n)=>Mp(e,t,n)+`&meta=1`,Pp=(e,t,n)=>`/api/files?workspaceId=${Dp(e)}&q=${Dp(t)}${Op(n)}`;async function Fp(e,t,n){let r=t.current;if(!r)return t.current=Tp(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return Tp(e,{cache:`no-store`})}function Ip(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 Lp(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function Rp(e){let t=Ip(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return Lp(t)}function zp(e){return Ip(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function Bp(e,t,n){if(n.openLink){let r=await Tp(`/api/files/open?workspaceId=${Dp(e)}${Op(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=ef(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=ef(r);if(a===!1&&!o)throw Error(`此文件可通过文件操作菜单下载。`);if(o&&o!==`table`)return{path:r,name:i,content:``,etag:(await Tp(Np(e,r,t))).etag,dirty:!1,view:o};try{let n=await Tp(Mp(e,r,t));return{path:jp(r)?r:n.path,name:i,content:n.content,etag:n.meta.etag,dirty:!1,view:o}}catch(n){if(!(n instanceof Sp)||![413,415].includes(n.status))throw n;return{path:r,name:i,content:``,etag:(await Tp(Np(e,r,t))).etag,dirty:!1,view:`download`}}}var Vp=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function Hp({workspaceId:e,entryPath:t,name:n,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f,linked:p,presentation:m}){let h=r[t],g=i.has(t);(0,u.useEffect)(()=>{g&&h===void 0&&o(t)},[g,t,h,o]);let _=m.inline(t,`entry`,f),v=m.inline(t,`child`,f+1);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-dir`,"data-file-dir-toggle":t,"aria-expanded":g,tabIndex:-1,draggable:!p,title:c.has(t)?`${t} 里有 agent 改过的文件`:t,onClick:()=>a(t),children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,L.jsx)(Ud,{name:g?`down`:`right`})}),(0,L.jsx)(qt,{category:g?`folder-open`:`folder`}),(0,L.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${n} 的文件操作`,children:(0,L.jsx)(Ud,{name:`more`})})]}),_,g&&(0,L.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,L.jsx)(`li`,{children:v}),h===void 0?(0,L.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,L.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:Vt(h.error.message),children:Bt(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,L.jsxs)(L.Fragment,{children:[h.truncated&&(0,L.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,L.jsx)(Hp,{workspaceId:e,entryPath:t.path,name:t.name,linked:t.symlink,listings:r,expanded:i,toggle:a,loadDirectory:o,openPaths:s,changedDirs:c,changedPaths:l,onOpen:d,depth:f+1,presentation:m},t.path):(0,L.jsx)(Up,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function Up({entry:e,depth:t,openPaths:n,changedPaths:r,onOpen:i,presentation:a}){let o={"--file-depth":t};if(e.kind===`symlink`&&!e.openLink)return(0,L.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=ef(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,L.jsxs)(`li`,{className:`file-node`,"data-file-entry":e.path,"data-linked":e.symlink,"data-file-outside":e.outside?e.path:void 0,"data-file-row-open":s?`1`:`0`,"data-file-row-changed":c?`1`:`0`,children:[(0,L.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-open":e.path,"aria-disabled":!u||void 0,title:u?e.path:`${e.name} 可以通过文件操作菜单下载`,tabIndex:-1,"aria-current":d?`true`:void 0,draggable:!e.symlink,onClick:t=>{u&&i(e.openLink&&!e.outside?{...e,openLink:void 0}:e,t.detail>1)},children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(qt,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,L.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,L.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,"aria-haspopup":`menu`,tabIndex:-1,"aria-label":`${e.name} 的文件操作`,children:(0,L.jsx)(Ud,{name:`more`})})]}),f]})}function Wp({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=Xf(T,e.path,e.etag),a=r?void 0:$f(i);if(a){x({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:T,note:a.supported?null:rp(a.reason)});return}x({state:`loading`,response:null,path:e.path,workspaceId:T,note:null});let o=jp(e.path);return Jf(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===S.current&&(r||ep(i,n),x({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:T,note:n.supported?null:rp(n.reason)}))}).catch(n=>{if(t!==S.current||n instanceof Kf)return;let r=ip(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`&&fp(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(`
288
288
  `).length),n=e.value.split(`
289
289
  `),r=n.slice(0,t-1).reduce((e,t)=>e+t.length+1,0),a=n[t-1].length;e.focus(),e.setSelectionRange(r+Math.min(a,(i.column??1)-1),r+a);let o=parseFloat(getComputedStyle(e).lineHeight);e.scrollTop=Math.max(0,(t-1)*o-e.clientHeight/2),e.scrollLeft=0;let s=e.previousElementSibling;s instanceof HTMLElement&&(s.scrollTop=e.scrollTop,s.scrollLeft=0)},[e.path,i,h]);let j=/\.md$/i.test(e.path);return(0,L.jsxs)(`div`,{className:`file-editor`,"data-file-editor":e.path,"data-save-state":t,"data-file-readonly":C?`1`:void 0,children:[(0,L.jsxs)(`div`,{className:`file-editor-head`,children:[f??(!p&&(0,L.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path})),(0,L.jsxs)(`span`,{className:`file-editor-flags`,children:[j&&(0,L.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:()=>g(e=>!e),children:h?`原文`:`预览`}),e.assetTicket&&l&&!p&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{children:`外部文件 · 只读`}),(0,L.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:s,children:`重新读取`}),(0,L.jsx)(`a`,{className:`file-preview-toggle`,href:Jd(`asset`,l,d,e.assetTicket,{download:`1`}),download:e.name,children:`下载`})]}),!C&&(0,L.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,L.jsx)(`span`,{className:`file-dirty`,"data-file-dirty":`1`,children:`未保存`}),!C&&(0,L.jsxs)(`button`,{type:`button`,className:`file-save`,"data-file-save":e.path,onClick:o,title:`保存文件 (Ctrl+S)`,disabled:t===`saving`,children:[(0,L.jsx)(Ud,{name:`save`}),t===`saving`?`保存中…`:`保存`]})]})]}),k.length>0&&(0,L.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,L.jsxs)(`div`,{className:`file-conflict`,"data-file-external":e.path,role:`alert`,children:[(0,L.jsx)(`p`,{children:`这个文件在磁盘上已经被改过了,你的修改还没有覆盖它。`}),(0,L.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,L.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,L.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),t===`conflict`&&(0,L.jsxs)(`div`,{className:`file-conflict`,"data-file-conflict":e.path,role:`alert`,children:[(0,L.jsx)(`p`,{children:`保存被拒绝:这个文件在磁盘上已经被改过了,覆盖会丢掉对方的改动。`}),(0,L.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,L.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,L.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),n&&t!==`conflict`&&!r&&(0,L.jsx)(`p`,{className:`file-editor-message file-message-${t}`,"data-file-message":t,role:`status`,children:n}),j&&h?(0,L.jsx)(`div`,{className:`file-markdown-preview`,"data-file-preview":`markdown`,children:(0,L.jsx)(Ed,{source:e.content})}):(0,L.jsx)(pf,{fallback:(t,n)=>(0,L.jsxs)(`div`,{className:`file-editor-fallback`,"data-file-editor-fallback":`1`,children:[(0,L.jsxs)(`div`,{className:`file-editor-fallback-bar`,children:[(0,L.jsxs)(`span`,{children:[`⚠️ 高级编辑器加载异常(`,t.message||`未知错误`,`),已自动降级为安全模式`]}),(0,L.jsx)(`button`,{type:`button`,onClick:n,children:`重新加载`})]}),(0,L.jsx)(`textarea`,{className:`file-textarea`,readOnly:C,value:e.content,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),o())}})]}),children:(0,L.jsx)(u.Suspense,{fallback:(0,L.jsx)(`div`,{className:`file-cm-wrap`,"data-file-text":e.path,"data-file-content":e.content,"data-file-selection":`0,0`,"data-file-editor-ready":`0`,children:(0,L.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`})}),children:(0,L.jsx)(xp,{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 Gp({line:e}){if(e.kind===`fold`)return(0,L.jsx)(`div`,{className:`file-diff-line file-diff-fold`,"data-diff-kind":`fold`,children:e.text});let t=e.kind===`added`?`+`:e.kind===`removed`?`-`:` `;return(0,L.jsxs)(`div`,{className:`file-diff-line file-diff-${e.kind}`,"data-diff-kind":e.kind,"data-diff-no-newline":e.noNewline?`1`:void 0,children:[(0,L.jsx)(`span`,{className:`file-diff-mark`,"aria-hidden":`true`,children:t}),(0,L.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.oldLine??``}),(0,L.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.newLine??``}),(0,L.jsx)(`span`,{className:`file-diff-text`,children:e.text}),e.noNewline&&(0,L.jsx)(`span`,{className:`file-diff-no-newline`,title:`这个版本的末尾没有换行`,children:`(末尾无换行)`})]})}function Kp({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}=yp(l,`.file-diff-added, .file-diff-removed`);if(t)return(0,L.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`loading`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-diff-loading":`1`,children:`正在读取差异…`})});if(n)return(0,L.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`error`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-diff-error":`1`,title:Vt(n),children:Bt(n,`这个文件的差异读取失败。`)})});if(!e)return(0,L.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`empty`,children:(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-diff-empty":`1`,children:`没有选中的差异。`})});let 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,L.jsxs)(`span`,{className:`file-diff-switch`,"data-file-diff-switch":`1`,children:[(0,L.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,L.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,L.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`none`,"data-file-diff-baseline":v,children:[(0,L.jsxs)(`div`,{className:`file-editor-head`,children:[(0,L.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,L.jsx)(`span`,{className:`file-editor-flags`,children:y})]}),(0,L.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-nobaseline":`1`,children:_})]});let b=Of(h,g),x=kf(b);return(0,L.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,L.jsxs)(`div`,{className:`file-editor-head`,children:[(0,L.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,L.jsxs)(`span`,{className:`file-editor-flags`,children:[y,(0,L.jsx)(`span`,{className:`file-diff-baseline`,"data-file-diff-label":`1`,children:_}),(0,L.jsxs)(`span`,{className:`file-diff-count`,"data-file-diff-count":`1`,children:[`+`,b.added,` / -`,b.removed]}),!b.identical&&x.folded>0&&(0,L.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,L.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-before-unknown":`1`,role:`status`,children:`读不到改动前的版本(文件太大或无法读取),这里只显示现在的内容。`}),e.before===null&&!e.beforeUnknown&&!m&&(0,L.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-is-new":`1`,role:`status`,children:`这个文件是新建的,下面是它的全部内容。`}),b.identical?(0,L.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-identical":`1`,children:`两个版本没有区别。`}):(0,L.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,L.jsx)(Gp,{line:e},t))})]})}function qp({error:e}){let t=e.body.code,n=typeof e.body.details?.path==`string`?e.body.details.path:``,r=t===`workspace_missing`?`missing`:t===`timeout`?`timeout`:`failed`;return(0,L.jsxs)(`div`,{className:`rail-empty file-problem`,"data-file-root-error":`1`,"data-file-error-kind":r,role:`alert`,children:[r===`missing`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`工作区路径不存在,无法读取文件。`}),(0,L.jsx)(`p`,{className:`file-problem-hint`,children:`请确认这个路径是写错了,还是目录被移动或删除了:`}),(0,L.jsx)(`code`,{className:`file-problem-path`,"data-file-error-path":`1`,children:n||Bt(e.message,`路径未知`)})]}),r===`timeout`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取超时,服务端没有回应。`}),(0,L.jsxs)(`p`,{className:`file-problem-hint`,children:[`已经等了 `,Cp/1e3,` 秒。如果这个工作区在网络盘上,请检查它是否已连接,然后点上面的 ↻ 重试。`]})]}),r===`failed`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取失败。`}),(0,L.jsx)(`p`,{className:`file-problem-hint`,title:Vt(e.message),children:Bt(e.message,`读取失败,请稍后重试。`)})]})]})}function Jp(e,t=``,{navigation:n,showingFile:r=!1,splitFilePath:i}={}){let a=t.trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``),o=e?a?`${e}:${a}`:e:void 0,s=(0,u.useRef)(o);s.current=o;let[c,l]=(0,u.useState)([]),[d,f]=(0,u.useState)(e),p=(0,u.useRef)(c);p.current=c;let[m,h]=(0,u.useState)(),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)({}),[b,x]=(0,u.useState)({}),[S,C]=(0,u.useState)({}),[w,T]=(0,u.useState)(()=>new Set),[E,D]=(0,u.useState)(),O=(0,u.useRef)(w);O.current=w;let k=(0,u.useRef)(new Map),A=(0,u.useRef)(new Map),[j,M]=(0,u.useState)(0),[N,ee]=(0,u.useState)(``),[P,te]=(0,u.useState)(null),[ne,re]=(0,u.useState)(null),[F,ie]=(0,u.useState)(!1),[ae,oe]=(0,u.useState)({});(0,u.useEffect)(()=>{if(f(e),k.current=new Map,l([]),h(void 0),_(``),y({}),x({}),C({}),T(new Set),D(void 0),te(null),re(null),ee(``),ie(!1),!e)return;let t=!0;return Tp(kp(e,``,a)).then(e=>{t&&C({"":e})}).catch(e=>{t&&C({"":{error:Ep(e)}})}),()=>{if(t=!1,o&&s.current!==o){let e=p.current.filter(e=>e.dirty);e.length?A.current.set(o,e):A.current.delete(o),Rf(`super-pi.file-drafts.v1.`+o,e),Qp(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=Xp()[o]??{expanded:[],open:[]},i=e=>({path:e,name:e.split(/[\\/]/).at(-1)||e,text:!0,openLink:r.explicit?.includes(e)?!0:void 0}),a=Lf(`super-pi.file-drafts.v1.`+o,[]),c=new Map((A.current.get(o)??a).map(e=>[e.path,e]));r.expanded.length&&T(new Set(r.expanded)),typeof r.listHeight==`number`&&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,p=()=>t&&n?.current===f;return(async()=>{let e,n=r.preview&&!c.has(r.preview)?r.preview:void 0;for(let r of u){if(r===n)continue;let a=c.get(r);a&&l(e=>e.some(e=>e.path===r)?e:[...e,a]);let u=a?.path??await Se(i(r),{activate:!1,isCurrent:()=>t});if(!t||s.current!==o)return;r===d&&(e=u)}if(n&&p()&&(e=await Se(i(n),{activate:!1,isCurrent:p})),e&&s.current===o&&p()){let t=e;r.preview===r.active&&l(e=>e.map(e=>e.path===t&&!e.dirty?{...e,preview:!0}:e)),h(t),ue(t)}})().finally(()=>{t&&s.current===o&&ce(o)}),()=>{t=!1}},[e,a,o,n]),(0,u.useEffect)(()=>{if(!e||!o)return;let t=setTimeout(()=>{let e=Xp();e[o]={open:c.map(e=>e.path),explicit:c.filter(e=>e.assetTicket).map(e=>e.path),expanded:[...w],...r&&m?{active:m}:{},...r&&m&&c.some(e=>e.path===m&&e.preview)?{preview:m}:{},...P===null?{}:{listHeight:P}},Zp(e)},400);return()=>{clearTimeout(t)}},[e,o,c,w,m,P,r]),(0,u.useEffect)(()=>{if(!o||se!==o)return;let e=()=>{if(s.current!==o)return;let e=p.current.filter(e=>e.dirty);return Rf(`super-pi.file-drafts.v1.`+o,e)||e.length===0},t=window.setTimeout(()=>{e()===!1&&_(`浏览器无法保存文件草稿,刷新前请先保存修改。`)},250);return window.addEventListener(`pagehide`,e),()=>{window.clearTimeout(t),window.removeEventListener(`pagehide`,e)}},[o,se,c]);let de=(0,u.useCallback)(async(t,n=!1)=>{if(!e)return;let r={},i=k.current;i.set(t,r);let c=()=>s.current===o&&k.current===i&&i.get(t)===r;await Tp(kp(e,t,a)+(n?`&revalidate=1`:``)).then(e=>{c()&&C(n=>({...n,[t]:e}))}).catch(e=>{c()&&C(n=>({...n,[t]:{error:Ep(e)}}))}).finally(()=>{c()&&i.delete(t)})},[e,a,o]),fe=(0,u.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),pe=(0,u.useCallback)(t=>{if(!e)return;let n=new Set([``,...O.current]),r=t&&new Set(t.map(tf)),i=e=>!r||r.has(e)||t.some(t=>nf(e,t));C(e=>Object.fromEntries(Object.entries(e).filter(([e])=>n.has(e)||!i(e))));for(let e of k.current.keys())!n.has(e)&&i(e)&&k.current.delete(e);Promise.all([...n].filter(i).map(e=>de(e,!t&&!e))).then(()=>{s.current===o&&M(e=>e+1)})},[e,o,de]),me=(0,u.useCallback)(()=>pe(),[pe]),I=(0,u.useRef)(void 0),he=(0,u.useRef)(new Set);(0,u.useEffect)(()=>()=>{clearTimeout(I.current),I.current=void 0,he.current=new Set},[o]);let ge=(0,u.useCallback)((t,n)=>{if(t!==e)return;let r=a?`${a}/`:``,i=n?.flatMap(e=>e.startsWith(r)?[e.slice(r.length)]:[]);if(i?.length===0){if(!n?.some(e=>nf(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=tf(e);n;n=tf(n))t.add(n);ee(``),T(e=>new Set([...e,...t]))},[]),ve=(0,u.useCallback)((e,t)=>{_e(t&&e?`${e}/`:e),D({path:e,directory:t})},[_e]),ye=(0,u.useCallback)(()=>T(new Set),[]),be=(0,u.useCallback)((e,t,n)=>{let r=n=>nf(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=ef(i),o=t.view&&t.view!==`table`&&(!a||a===`table`)||t.path===e&&n===!1&&!a?`download`:a;return{...t,path:i,view:o,name:i.split(`/`).at(-1)??t.name}})),h(e=>e&&r(e)),T(e=>new Set([...e].map(r))),y(i),x(i);for(let t of k.current.keys())nf(t,e)&&k.current.delete(t);C(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!nf(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=zp(N);if(!e||!t||Rp(N)){xe.current=void 0,re(null),ie(!1);return}let n=!0,r,i=async()=>{try{let o=await Fp(Pp(e,t,a),xe,()=>n);if(!n||!o)return;re(o),ie(!1),o.indexed||(r=setTimeout(()=>void i(),400))}catch(e){if(!n)return;re(null),ie(!1),_(Bt(e,`文件查找没有完成`))}};return ie(!0),r=setTimeout(()=>void i(),80),()=>{n=!1,clearTimeout(r)}},[N,e,a,j]);let Se=(0,u.useCallback)(async(t,{preview:n=!1,activate:r=!0,isCurrent:i,throwOnError:c,requireText:u}={})=>{if(!(!e||i&&!i())){_(``);try{let c=p.current.find(e=>e.path===t.path),d=c??await Bp(e,a,t);if(s.current!==o||i&&!i())return;if(u&&d.view&&d.view!==`table`)throw Error(`已找到匹配行,但此文件无法在文本编辑器中定位。可以在搜索结果中查看这一行。`);return c?(r&&h(t.path),t.path):(l(e=>e.some(e=>e.path===d.path)?e:[...e,{...d,...n?{preview:n}:{}}]),r&&h(d.path),x(e=>({...e,[d.path]:!1})),d.path)}catch(e){if(s.current!==o||i&&!i())return;if(c)throw e;_(`打不开「${t.name}」:${e instanceof Error?e.message:`未知错误`}`)}}},[e,a,o]),Ce=(0,u.useCallback)(e=>{o&&p.current.some(t=>t.path===e&&t.preview&&!t.dirty)&&Qp(o,e),l(t=>{let n=t.find(t=>t.path===e);if(n?.dirty&&!window.confirm(`「${n.name}」有未保存的修改,关掉就丢了。仍然关闭?`))return t;let r=t.findIndex(t=>t.path===e),i=t.filter(t=>t.path!==e);return e===m&&h(i.length===0?void 0:i[Math.min(r,i.length-1)]?.path),i})},[m,o]),we=(0,u.useCallback)(e=>{l(t=>t.map(t=>t.path===e&&t.preview?{...t,preview:!1}:t))},[]),Te=(0,u.useCallback)(e=>{l(t=>t.filter(t=>t.path!==e||!t.preview||t.dirty)),h(t=>t===e?void 0:t),o&&Qp(o,e)},[o]),Ee=(0,u.useCallback)((e,t)=>{l(n=>n.map(n=>n.path===e&&!n.assetTicket&&n.content!==t?{...n,content:t,dirty:!0,preview:!1}:n))},[]);(0,u.useEffect)(()=>{if(!e||c.length===0)return;let t=!0,n=setInterval(()=>{for(let{path:n,assetTicket:r}of p.current)r||Tp(Np(e,n,a)).then(e=>{if(!t)return;let r=p.current.find(e=>e.path===n);r?.view&&r.view!==`table`&&e.etag!==r.etag?l(t=>t.map(t=>t.path===n&&t.etag===r.etag?{...t,etag:e.etag}:t)):r&&e.etag!==r.etag&&x(e=>({...e,[n]:!0}))}).catch(e=>{t&&Ep(e).status===404&&x(e=>({...e,[n]:!0}))})},bp);return()=>{t=!1,clearInterval(n)}},[e,a,c.length]);let De=(0,u.useCallback)(async(t,n)=>{if(!e)return;let r=c.find(e=>e.path===t);if(!r||r.assetTicket)return;y(e=>({...e,[t]:{state:`saving`,message:``}}));let i=r.etag;if(n)try{i=(await Tp(Np(e,t,a))).etag}catch(e){s.current===o&&y(n=>({...n,[t]:{state:`error`,message:`无法读取磁盘上的最新版本:${e instanceof Error?e.message:`未知错误`}`}}));return}let u=r.content;try{let n=await Tp(Mp(e,t,a),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:jp(t)??t,content:u,baseEtag:i})});if(s.current!==o)return;let r=p.current.find(e=>e.path===t),c=r!==void 0&&r.content!==u;l(e=>e.map(e=>e.path===t?{...e,etag:n.meta.etag,dirty:e.content!==u}:e)),x(e=>({...e,[t]:!1})),y(e=>({...e,[t]:{state:`saved`,message:c?`已保存,但你又改了;最新修改仍未保存`:`已保存 ${Vp(n.meta.modifiedAt)}`}}))}catch(e){if(s.current!==o)return;let n=e instanceof Sp&&e.body.code===`stale`;y(r=>({...r,[t]:{state:n?`conflict`:`error`,message:e instanceof Error?e.message:`保存失败`}})),n&&x(e=>({...e,[t]:!0}))}},[e,a,o,c]),Oe=(0,u.useCallback)(async t=>{if(!e)return;let n=p.current.find(e=>e.path===t),r=n?.content;try{if(n?.assetTicket){let r=await Bp(e,a,{path:t,name:n.name,text:null,openLink:!0});if(!r.assetTicket||r.path!==t)throw Error(`链接目标已变化,请关闭后重新打开。`);s.current===o&&(l(e=>e.map(e=>e.path===t?{...r,preview:e.preview}:e)),y(e=>({...e,[t]:{state:`idle`,message:``}})));return}let i=await Tp(Mp(e,t,a));if(s.current!==o)return;let c=p.current.find(e=>e.path===t),u=c!==void 0&&c.content!==r;l(e=>e.map(e=>e.path===t?{...e,content:u?e.content:i.content,etag:i.meta.etag,dirty:u}:e)),x(e=>({...e,[t]:!1})),y(e=>({...e,[t]:{state:`saved`,message:u?`已读取磁盘版本;你后来输入的修改仍未保存`:`已重新载入磁盘版本`}}))}catch(e){s.current===o&&y(n=>({...n,[t]:{state:`error`,message:e instanceof Error?e.message:`重新载入失败`}}))}},[e,a,o]),ke=c.find(e=>e.path===m),Ae=(0,u.useMemo)(()=>c.map(e=>({id:e.path,label:e.name,title:jp(e.path)??e.path,closable:!0,badge:e.dirty?(0,L.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[c]),je=(0,u.useMemo)(()=>new Set(c.map(e=>e.path)),[c]),Me=(0,u.useCallback)((e,t,n)=>{oe(r=>({...r,[e]:{changes:t,dropped:n}}))},[]),Ne=e?ae[e]:void 0,Pe=(0,u.useMemo)(()=>{let e=Ne?.changes??[];if(!a)return e;let t=`${a}/`;return e.flatMap(e=>e.path.startsWith(t)?[{...e,path:e.path.slice(t.length)}]:[])},[Ne,a]),Fe=Ne?.dropped??0,Ie=(0,u.useMemo)(()=>new Set(Pe.map(e=>e.path)),[Pe]),Le=(0,u.useMemo)(()=>{let e=new Set;for(let t of Pe){let n=t.path.split(`/`);for(let t=1;t<n.length;t++)e.add(n.slice(0,t).join(`/`))}return e},[Pe]);return{ownerWorkspaceId:d,open:c,activePath:m,visiblePath:r?m:i,location:E,active:ke,tabItems:Ae,openPaths:je,notice:g,setNotice:_,saves:v,external:b,restoringWorkbench:!!(o&&se!==o),openFile:Se,setActivePath:h,closeFile:Ce,pinFile:we,discardPreview:Te,updateBuffer:Ee,save:De,reload:Oe,listings:S,expanded:w,toggleDirectory:fe,loadDirectory:de,refreshTree:me,invalidateTree:ge,revealPath:_e,locatePath:ve,collapseDirectories:ye,movePath:be,listHeight:P,setListHeight:te,query:N,setQuery:ee,hits:ne,searching:F,changed:Pe,changedPaths:Ie,changedDirs:Le,changedDropped:Fe,setChangedFor:Me,restoredActive:le}}var Yp=`super-pi.file-workbench.v1`;function Xp(){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 Zp(e){try{typeof window<`u`&&window.localStorage.setItem(Yp,JSON.stringify(e))}catch{}}function Qp(e,t){let n=Xp(),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},Zp(n))}function $p({height:e,onHeight:t,panelRef:n,min:r=120}){let[i,a]=(0,u.useState)(!1),o=()=>{let e=n.current?.querySelector(`.files-tree`)??null;return{list:e,height:e?.getBoundingClientRect().height??0}},s=e=>{e.preventDefault(),e.currentTarget.focus();let n=e.clientY,{height:i}=o();a(!0);let s=document.body,c=s.style.cursor,l=s.style.userSelect;s.style.cursor=`row-resize`,s.style.userSelect=`none`;let u=e=>{let a=Math.round(i+(e.clientY-n));t(Math.max(r,a))},d=()=>{s.style.cursor=c,s.style.userSelect=l,a(!1),window.removeEventListener(`mousemove`,u),window.removeEventListener(`mouseup`,d)};window.addEventListener(`mousemove`,u),window.addEventListener(`mouseup`,d)},c=e=>e.shiftKey?96:24;return(0,L.jsx)(`div`,{className:`files-splitter${i?` files-splitter-dragging`:``}`,"data-file-splitter":`1`,"data-file-splitter-dragging":i?`true`:`false`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`调整文件列表高度`,"aria-valuenow":e??void 0,"aria-valuemin":r,tabIndex:0,onMouseDown:s,onKeyDown:e=>{let i=c(e);if(e.key===`ArrowDown`){e.preventDefault();let{height:n}=o();t(Math.max(r,Math.round(n)+i))}else if(e.key===`ArrowUp`){e.preventDefault();let{height:n}=o(),a=Math.round(n)-i;t(a<=r?null:a)}else if(e.key===`Home`)e.preventDefault(),t(null);else if(e.key===`End`){e.preventDefault();let i=n.current?.querySelector(`.files-tree`)?.parentElement?.clientHeight??0;t(Math.max(r,i))}}})}var em=()=>null,tm=`application/x-super-pi-workspace-file`;function nm({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=lf({workspaceId:e,cwd:n,scopeName:j,files:r,onOpen:A,onReference:o,onMoved:s,onSearchFolder:c}),[N,ee]=(0,u.useState)(),P=(0,u.useRef)(void 0),[te,ne]=(0,u.useState)(!1),re=M.editing?M.inline:em,F=(0,u.useMemo)(()=>({currentPath:r.visiblePath,dropPath:N,inline:re}),[r.visiblePath,N,re]);(0,u.useEffect)(()=>{y();function e(){y()}return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[y]),(0,u.useEffect)(()=>{ee(void 0),P.current=void 0,ne(!1)},[e,n]);let ie=h[``],ae=S.trim(),oe=e?Rp(S):void 0,se=(0,u.useRef)(null),ce=(0,u.useRef)(null),le=(0,u.useRef)(void 0);function ue(e){let t=ce.current;t&&(le.current&&le.current!==e&&(le.current.tabIndex=-1),le.current=e,t.tabIndex=e?-1:0,e&&(e.tabIndex=0))}let de=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{let{location:e}=r;if(!e||de.current===e)return;let t=se.current?.querySelector(e.path?`[${e.directory?`data-file-dir-toggle`:`data-file-open`}="${CSS.escape(e.path)}"]`:`[data-explorer-root]`);t&&(de.current=e,t.focus({preventScroll:!0}),t.scrollIntoView({block:`nearest`}))},[r.location,h,g,S]),(0,u.useEffect)(()=>{if(!N||g.has(N))return;let e=window.setTimeout(()=>_(N),650);return()=>window.clearTimeout(e)},[N,g,_]);let fe=(0,u.useCallback)(e=>{let t=se.current;if(!t)return;let n=e.target?.closest(`.file-row`);if(!n)return;let r=af(n);if(r&&!M.busy){if(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`){e.preventDefault(),M.openMenu(r,Wd(n));return}if(!r.linked&&e.key===`F2`){e.preventDefault(),M.showAction(`move`,r,!1,n);return}if(!r.linked&&e.key===`Delete`){e.preventDefault(),M.showAction(`trash`,r,!1,n);return}}let i=[...(n.closest(`.files-tree, .files-changed`)??t).querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),a=i.indexOf(n);if(a<0)return;let o=e=>{let t=Math.max(0,Math.min(i.length-1,e));i[t]?.focus()};if(e.key===`ArrowDown`)e.preventDefault(),o(a+1);else if(e.key===`ArrowUp`)e.preventDefault(),o(a-1);else if(e.key===`Home`)e.preventDefault(),o(0);else if(e.key===`End`)e.preventDefault(),o(i.length-1);else if(e.key===`ArrowRight`){let t=n.getAttribute(`data-file-dir-toggle`);if(t&&n.getAttribute(`aria-expanded`)===`false`)e.preventDefault(),_(t);else if(t){let t=n.closest(`.file-node`)?.querySelector(`.file-children .file-row:not(:disabled)`);t&&(e.preventDefault(),t.focus())}}else if(e.key===`ArrowLeft`){let r=n.getAttribute(`data-file-dir-toggle`);if(r&&n.getAttribute(`aria-expanded`)===`true`){e.preventDefault(),_(r);return}let i=n.getAttribute(`data-file-open`)??n.getAttribute(`data-file-hit`)??r;if(i){e.preventDefault();let n=i.lastIndexOf(`/`),r=n<0?``:i.slice(0,n);(r?t.querySelector(`[data-file-dir-toggle="${CSS.escape(r)}"]`):null)?.focus()}}},[_,M]),[pe,me]=(0,u.useState)(200);(0,u.useEffect)(()=>{me(200)},[ae,e]);let I=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(ae===``)return;let e=I.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&me(e=>e>=(w?.hits.length??0)?e:e+200)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[ae,w]);let he=(0,u.useMemo)(()=>{if(oe)return(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-exact-path":oe.path,title:oe.path,onClick:()=>A(oe),children:[(0,L.jsx)(qt,{path:oe.path}),(0,L.jsxs)(`span`,{className:`file-name`,children:[`打开 `,oe.name]})]});if(ae){if(T)return(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-searching":`1`,children:`搜索中…`});if(!w)return null;if(w.hits.length===0)return(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-search-empty":`1`,children:w.indexed?`没有匹配「${ae}」的文件。`:`正在建立索引…`});let e=w.hits.slice(0,pe),t=[],n=new Map;for(let r of e){let e=n.get(r.directory);if(e)e.push(r);else{let e=[r];n.set(r.directory,e),t.push({directory:r.directory,hits:e})}}return(0,L.jsxs)(L.Fragment,{children:[t.map(e=>(0,L.jsxs)(`section`,{className:`file-group`,"data-file-search-group":e.directory,children:[(0,L.jsxs)(`h3`,{className:`file-group-head`,"data-file-search-group-head":e.directory,children:[(0,L.jsx)(`span`,{className:`file-group-name`,children:e.directory||`/`}),(0,L.jsx)(`span`,{className:`file-group-count`,children:e.hits.length})]}),(0,L.jsx)(`ul`,{className:`file-list`,children:e.hits.map(e=>(0,L.jsxs)(`li`,{className:`file-explorer-row`,"data-file-entry":e.path,"data-linked":e.openLink,"data-file-current":r.visiblePath===e.path?`1`:void 0,children:[(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-hit":e.path,tabIndex:-1,"aria-current":r.visiblePath===e.path?`true`:void 0,"data-file-hit-open":d.has(e.path)?`1`:`0`,onClick:()=>A({...e,text:!0}),children:[(0,L.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,L.jsx)(qt,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.name}),d.has(e.path)&&(0,L.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`})]}),!e.openLink&&(0,L.jsx)(`button`,{type:`button`,className:`file-explorer-more explorer-icon-button`,"data-explorer-action":`1`,tabIndex:-1,"aria-haspopup":`menu`,"aria-label":`${e.name} 的文件操作`,children:(0,L.jsx)(Ud,{name:`more`})})]},e.path))})]},e.directory||`/`)),e.length<w.hits.length&&(0,L.jsx)(`div`,{ref:I,className:`file-sentinel`,"data-file-search-more":`1`,children:`正在载入更多…`})]})}return e?ie===void 0?(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-root-loading":`1`,children:`读取工作区…`}):`error`in ie?(0,L.jsx)(qp,{error:ie.error}):(0,L.jsxs)(L.Fragment,{children:[ie.truncated&&(0,L.jsx)(`p`,{className:`file-search-note`,"data-file-truncated-root":`1`,children:`条目过多,只显示前一部分。`}),ie.entries.length===0?(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-root-empty":`1`,children:`这个工作区是空的,没有文件也没有子目录。`}):(0,L.jsx)(`ul`,{className:`file-list`,children:ie.entries.map(t=>t.kind===`directory`?(0,L.jsx)(Hp,{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,L.jsx)(Up,{entry:t,depth:0,openPaths:d,changedPaths:D,onOpen:A,presentation:F},t.path))})]}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-file-no-workspace":`1`,children:`先在左侧选一个工作区,这里会显示它的文件。`})},[oe,ae,T,w,pe,e,ie,h,g,_,v,A,d,O,D,F,r.visiblePath]),ge=e=>{let t=af(e);if(!t?.linked)return t?t.directory?t.path:tf(t.path):``},_e=(e,t)=>e!==tf(t.path)&&!(t.directory&&nf(e,t.path));return(0,u.useLayoutEffect)(()=>{let e=ce.current;if(!e)return;let t=[...e.querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),n=le.current;ue(n&&t.includes(n)?n:t.find(e=>e.hasAttribute(`aria-current`))??t[0])},[he,M.editing]),(0,L.jsxs)(`div`,{className:`files-panel`,"data-files-panel":`1`,"data-files-open-count":l.length,"data-files-changed-count":E.length,ref:se,onKeyDown:fe,onClick:e=>{let t=e.target instanceof Element?e.target.closest(`[data-explorer-action]`):void 0,n=af(t??null);t&&n&&!M.busy&&M.openMenu(n,Wd(t))},onContextMenu:e=>{let t=af(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=af(e.target instanceof Element?e.target.closest(`.file-row[draggable=true]`):null);!t||t.linked||M.busy||ae||(P.current=t,e.dataTransfer.setData(tm,t.path),e.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{P.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=P.current&&t.dataTransfer.types.includes(tm)?P.current:void 0;if(!e||M.busy||!n&&!r)return;t.preventDefault();let i=ge(t.target),a=i!==void 0&&(!r||_e(i,r));t.dataTransfer.dropEffect=a?r?`move`:`copy`:`none`,ee(a?i:void 0)},onDrop:t=>{ee(void 0);let n=t.dataTransfer.types.includes(tm)?P.current:void 0;if(P.current=void 0,!e||M.busy||!n&&!t.dataTransfer.types.includes(`Files`))return;t.preventDefault();let r=ge(t.target);if(r===void 0){p(`请选择工作区里的普通文件夹。`);return}if(n){_e(r,n)&&M.moveTo(n,r);return}let i=Array.from(t.dataTransfer.items).filter(e=>!e.webkitGetAsEntry?.()?.isDirectory).map(e=>e.getAsFile()).filter(e=>e!==null);i.length?M.upload(r,i):t.dataTransfer.files.length&&!t.dataTransfer.items.length?M.upload(r,Array.from(t.dataTransfer.files)):p(`请选择要上传的文件。`)},children:[(0,L.jsxs)(`header`,{className:`file-explorer-header`,"data-file-drop-target":N===``?`1`:void 0,children:[(0,L.jsxs)(`div`,{className:`file-explorer-scope`,"data-explorer-root":`1`,tabIndex:-1,title:n?`${t??`工作区`}/${n}`:j,children:[(0,L.jsx)(qt,{category:`folder-open`}),(0,L.jsx)(`span`,{children:j})]}),M.toolbar]}),(0,L.jsxs)(`div`,{className:`files-search`,children:[(0,L.jsx)(`span`,{className:`files-search-icon`,"aria-hidden":`true`,children:(0,L.jsx)(Ud,{name:`search`})}),(0,L.jsx)(`input`,{type:`search`,className:`files-search-input`,"data-file-search-input":`1`,value:S,placeholder:`筛选文件或输入绝对路径`,"aria-label":`按文件名搜索`,onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),C(``)):e.key===`Enter`&&oe&&(e.preventDefault(),A(oe))},onChange:e=>C(e.target.value)}),(0,L.jsx)(`button`,{type:`button`,className:`explorer-icon-button`,disabled:!r.activePath||!!jp(r.activePath)||!!(r.active?.assetTicket&&Rp(r.activePath)),onClick:()=>{r.activePath&&r.locatePath(r.activePath,!1)},title:`定位打开的文件`,"aria-label":`在文件树中定位当前文件`,children:(0,L.jsx)(Ud,{name:`locate`})})]}),M.controls,!oe&&ae&&w&&!T&&(0,L.jsxs)(`p`,{className:`files-count`,"data-file-search-count":`1`,role:`status`,children:[(0,L.jsx)(`b`,{children:w.total.toLocaleString(`zh-CN`)}),` 个结果`,w.indexed===!1&&(0,L.jsx)(`span`,{className:`files-count-note`,"data-file-search-indexing":`1`,children:`正在建立索引…`}),w.indexed&&w.incomplete&&(0,L.jsx)(`span`,{className:`files-count-note`,children:`索引不完整`})]}),f&&(0,L.jsx)(`p`,{className:`rail-empty file-explorer-notice`,"data-file-notice":`1`,role:`status`,children:f}),M.busy&&(0,L.jsx)(`p`,{className:`file-explorer-notice`,role:`status`,children:`正在处理文件…`}),(0,L.jsx)(`div`,{className:`files-tree`,ref:ce,"data-file-tree":ae?`search`:`browse`,tabIndex:0,"aria-label":`文件树`,onFocus:e=>{e.target instanceof HTMLElement&&e.target.matches(`.file-row:not(:disabled)`)&&ue(e.target)},style:b===null?void 0:{height:`${b}px`,flex:`0 0 auto`},children:(0,L.jsxs)(`div`,{className:`files-tree-body`,children:[M.inline(``,`child`,0),he]})}),(0,L.jsx)($p,{height:b,onHeight:x,panelRef:se}),(0,L.jsxs)(`div`,{className:`files-changed`,"data-file-changed-list":`1`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`files-changed-head`,"data-file-changed-head":`1`,"aria-expanded":te,onClick:()=>ne(e=>!e),children:[(0,L.jsx)(Ud,{name:te?`down`:`right`}),(0,L.jsx)(Ud,{name:`changes`}),(0,L.jsx)(`span`,{children:`改动`}),(0,L.jsx)(`span`,{className:`files-change-count`,children:E.length})]}),te&&(0,L.jsxs)(`div`,{className:`files-change-list`,children:[k>0&&(0,L.jsxs)(`p`,{className:`file-search-note`,"data-file-changed-dropped":`1`,children:[`还有 `,k,` 个改动没有记录(超过保留上限)。`]}),!E.length&&(0,L.jsx)(`p`,{className:`file-row-empty`,children:`没有 agent 改动。`}),(0,L.jsx)(`ul`,{className:`file-list`,children:E.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-changed-open":e.path,title:`${e.path}(点击查看改动)`,onClick:()=>a?.(e.path),children:[(0,L.jsx)(qt,{path:e.path}),(0,L.jsx)(`span`,{className:`file-name`,children:e.path.split(`/`).pop()}),(0,L.jsx)(`span`,{className:`file-badge-path`,children:e.path.split(`/`).slice(0,-1).join(`/`)||`/`}),(0,L.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed-kind":e.path,children:e.baseline===null&&!e.baselineUnknown?`新建`:`已改`})]})},e.path))})]})]})]})}function rm(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(Bt(e,`文件无法打开`))}finally{r(!1)}}},openError:i,opening:n,setOpenError:a}}var im=200;async function am(e,t,n){let r=await ke(e,{signal:t,cache:`no-store`});if(!r.ok)throw new Sp(r.status,await r.json());if(!r.body)throw Error(`服务端没有返回搜索结果。`);let i=r.body.pipeThrough(new TextDecoderStream).getReader(),a=``,o=!1;try{for(;;){let e=await i.read();if(e.done)break;let t=(a+e.value).split(`
290
290
  `);a=t.pop();for(let e of t){if(!e)continue;let t=JSON.parse(e);if(t.type===`error`)throw Error(t.error);n(t),t.type===`done`&&(o=!0)}}if(!o)throw Error(`搜索连接提前断开,结果可能不完整。`)}finally{await i.cancel().catch(()=>void 0),i.releaseLock()}}function om(e,t,n){let r=t?t+`/`+e.path:e.path;return{path:n?r.startsWith(n+`/`)?r.slice(n.length+1):Ap+r:r,name:e.name,text:!0}}function sm({workspaceId:e,cwd:t=``,directory:n,initialQuery:r=``,onOpen:i,onClose:a,onMode:o,presentation:s}){let[c,l]=(0,u.useState)(r),[d,f]=(0,u.useState)(n??``),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(!0),[y,b]=(0,u.useState)([]),[x,S]=(0,u.useState)(),[C,w]=(0,u.useState)(im),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(!1),[k,A]=(0,u.useState)(!1),[j,M]=(0,u.useState)(0),{choose:N,openError:ee,opening:P,setOpenError:te}=rm(i,a),ne=!!Rp(c),re=(0,u.useRef)(null),F=(0,u.useRef)(null),ie=(0,u.useRef)(void 0),ae=(0,u.useId)();(0,u.useEffect)(()=>{re.current?.focus()},[]),(0,u.useEffect)(()=>{F.current?.scrollIntoView({block:`nearest`})},[j]),(0,u.useEffect)(()=>{let t=c.trim(),n=new AbortController;if(ie.current=n,b([]),S(void 0),E(``),A(!1),w(im),M(0),!e||!t){O(!1);return}if(t.length>256){E(`搜索词不能超过 256 个字符。`),O(!1);return}let r=new URLSearchParams({workspaceId:e,q:t,stream:`1`,ignore:_?`1`:`0`});d&&r.set(`cwd`,d),p.trim()&&r.set(`include`,p.trim()),h.trim()&&r.set(`exclude`,h.trim()),O(!0);let i=setTimeout(()=>{n.signal.aborted||am(`/api/files/search?`+r,n.signal,e=>{n.signal.aborted||(e.type===`matches`?b(t=>[...t,...e.hits]):e.type===`done`&&S(e.summary))}).catch(e=>{n.signal.aborted||E(Bt(e,`搜索没有完成`))}).finally(()=>{n.signal.aborted||O(!1)})},220);return()=>{n.abort(),clearTimeout(i)}},[c,e,d,p,h,_]);let oe=(0,u.useMemo)(()=>{let e=new Map;return y.slice(0,C).forEach((t,n)=>{let r=e.get(t.path);r?r.push({hit:t,row:n}):e.set(t.path,[{hit:t,row:n}])}),[...e]},[y,C]),se=e=>{e&&N(om(e,d,t),e.line,e.column)},ce=x?.complete===!1,le={time:`搜索超时`,results:`达到全局结果上限`,line:`部分行太长`,encoding:`部分文件的编码无法读取`,unreadable:`部分文件无法读取`};return(0,L.jsxs)(df,{mode:`content`,query:c,onMode:o,onClose:a,presentation:s,children:[(0,L.jsx)(`input`,{ref:re,className:`quick-open-input`,"data-content-search-input":`1`,value:c,readOnly:P,placeholder:`内容搜索(区分大小写,按字面匹配)`,role:`combobox`,"aria-label":`内容搜索`,"aria-autocomplete":`list`,"aria-controls":ae,"aria-expanded":y.length>0,"aria-activedescendant":y[j]?`${ae}-${j}`:void 0,onChange:e=>{l(e.target.value),te(``)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),M(e=>Math.min(e+1,Math.max(0,Math.min(C,y.length)-1)))):e.key===`ArrowUp`?(e.preventDefault(),M(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),se(y[j])))}}),(0,L.jsxs)(`div`,{className:`content-search-controls`,children:[(0,L.jsxs)(`label`,{children:[`范围 `,(0,L.jsxs)(`select`,{value:d,"aria-label":`搜索范围`,onChange:e=>f(e.target.value),children:[(0,L.jsx)(`option`,{value:``,children:`整个工作区`}),t&&(0,L.jsxs)(`option`,{value:t,children:[`当前目录 · `,t]}),n&&n!==t&&(0,L.jsxs)(`option`,{value:n,children:[`文件夹 · `,n]})]})]}),D&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{ie.current?.abort(),re.current?.focus(),O(!1),A(!0)},children:`取消搜索`})]}),(0,L.jsxs)(`details`,{className:`content-search-filters`,children:[(0,L.jsx)(`summary`,{children:`文件筛选`}),(0,L.jsxs)(`label`,{children:[`包含 `,(0,L.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`例如 **/*.cpp`})]}),(0,L.jsxs)(`label`,{children:[`排除 `,(0,L.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`例如 **/generated/**`})]}),(0,L.jsxs)(`label`,{children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),` 遵循忽略文件和默认排除`]})]}),(0,L.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"data-content-search-status":T?`error`:D?`searching`:k?`cancelled`:ce?`partial`:`complete`,children:[T?`搜索失败:`+T:D?`搜索中…`:k?`已取消`:e?ce?`结果不完整`:x?`搜索完成`:`输入要搜索的内容`:`请先选择工作区`,(y.length>0||x)&&` · ${y.length} 条命中`]}),ne&&(0,L.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>o(`path`,c),children:`按文件路径打开`}),ce&&(0,L.jsx)(`p`,{className:`quick-open-status`,"data-content-search-partial":`1`,children:x.reasons.map(e=>le[e]??e).join(`;`)}),x?.complete&&!y.length&&(0,L.jsx)(`p`,{className:`quick-open-status`,"data-content-search-empty":`1`,children:`没有匹配的行`}),ee&&(0,L.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:ee}),(0,L.jsx)(`ul`,{id:ae,className:`quick-open-results content-search-results`,role:`listbox`,"aria-label":`正文搜索结果`,children:oe.map(([e,t])=>(0,L.jsxs)(`li`,{className:`content-search-group`,role:`presentation`,children:[(0,L.jsx)(`div`,{className:`content-search-file`,title:e,children:e}),t.map(({hit:e,row:t})=>(0,L.jsxs)(`button`,{id:`${ae}-${t}`,ref:t===j?F:void 0,type:`button`,role:`option`,tabIndex:-1,"data-content-search-result":`${e.path}:${e.line}`,className:`quick-open-result content-search-result${j===t?` quick-open-result-active`:``}`,"aria-selected":j===t,"aria-label":`${e.path}:${e.line}:${e.column} ${e.text}`,onMouseEnter:()=>M(t),onClick:()=>se(e),children:[(0,L.jsxs)(`span`,{title:`${e.path}:${e.line}:${e.column}`,className:`content-search-result-position`,children:[e.line,`:`,e.column]}),(0,L.jsx)(`small`,{title:e.text,children:e.text})]},e.line))]},e))}),y.length>C&&(0,L.jsxs)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-content-search-more":`1`,onClick:()=>{C+im>=y.length&&re.current?.focus(),w(e=>e+im)},children:[`显示更多结果(已显示 `,C,` / `,y.length,`)`]})]})}function cm({workspaceId:e,cwd:t=``,connected:n,initialQuery:r=``,onOpen:i,onClose:a,onMode:o,presentation:s}){let[c,l]=(0,u.useState)(r),[d,f]=(0,u.useState)(0),[p,m]=(0,u.useState)(0),[h,g]=(0,u.useState)(),_=(0,u.useRef)(void 0),v=(0,u.useRef)(void 0),{choose:y,openError:b,opening:x,setOpenError:S}=rm(i,a),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=zp(c),E=e?Rp(c):void 0,D=!!E;(0,u.useEffect)(()=>{if(!n||!e)return;let r=new AbortController,i=Pp(e,``,t)+`&quick=1&refresh=1`;return _.current=Tp(i,{cache:`no-store`,signal:r.signal}).catch(()=>void 0),()=>{r.abort(),_.current=void 0}},[n,e,t]),(0,u.useEffect)(()=>{if(!n||!e||D)return;let r=new AbortController,i=r.signal,a=Pp(e,T,t)+`&quick=1&page=${p}`,o,s=async e=>{try{let t=e?await _.current:void 0;if(i.aborted)return;let n=e&&!T&&t?t:await Tp(a,{cache:`no-store`,signal:i});if(i.aborted)return;g({query:T,page:p,response:n}),n.indexed||(o=setTimeout(()=>void s(!1),350))}catch(e){i.aborted||g({query:T,page:p,error:Bt(e,`文件查找没有完成`)})}};return o=setTimeout(()=>void s(!0),T?120:0),()=>{r.abort(),clearTimeout(o)}},[n,e,t,T,D,p]);let O=h?.query===T&&h.page===p?h:void 0,k=O?.response,A=(0,u.useMemo)(()=>{if(E)return[E];let t=k?.hits.map(e=>({...e,text:null}))??[];return p>0||e&&T.includes(`/`)&&!T.endsWith(`/`)&&!T.split(`/`).includes(`..`)&&!t.some(e=>e.path.toLowerCase()===T.toLowerCase())&&(k?.total?t.push(Lp(T)):t.unshift(Lp(T))),t},[E,T,k,p,e]),j=e=>{v.current=void 0,m(e),g(void 0),f(0),S(``),C.current?.focus()},M=!D&&!(!e||O?.error||k?.indexed);return(0,u.useEffect)(()=>{let e=v.current;e===void 0||M||(v.current=void 0,y(A[Math.min(e,A.length-1)]))},[M,A,y]),(0,u.useEffect)(()=>{C.current?.focus()},[]),(0,u.useEffect)(()=>{w.current?.scrollIntoView({block:`nearest`})},[d]),(0,L.jsxs)(df,{mode:`path`,query:c,onMode:o,onClose:a,presentation:s,children:[(0,L.jsx)(`input`,{ref:C,className:`quick-open-input`,"data-quick-open-input":`1`,value:c,readOnly:x,placeholder:`快速打开:输入文件名或路径`,"aria-label":`快速打开文件路径`,onChange:e=>{let t=e.target.value;v.current=void 0,(zp(t)!==T||p!==0)&&g(void 0),l(t),m(0),f(0),S(``)},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`ArrowDown`)e.preventDefault(),f(e=>Math.min(e+1,Math.max(0,A.length-1)));else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=A[Math.min(d,A.length-1)],n=k?.hits.some(e=>e.path===t?.path&&[e.name,e.path].some(e=>e.toLowerCase()===T.toLowerCase()));M&&!n?v.current=d:y(t)}}}}),(0,L.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"aria-live":`polite`,"data-quick-open-status":D||k?.indexed&&!k.incomplete?`complete`:`partial`,children:[D?`按 Enter 打开指定文件`:e?n?O?.error||(M?`正在检查文件索引…`:T?k?.incomplete?`索引不完整 · ${k.total} 条命中`:k?.total?`${k.total} 条命中${p?` · 第 ${p+1} 页`:``}`:A.length?`近似路径`:`没有匹配的文件名或路径`:`输入文件名或路径以查找当前目录中的文件`):`等待连接…`:`请先选择工作区`,` · Esc 关闭`]}),b&&(0,L.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:b}),(0,L.jsx)(`ul`,{className:`quick-open-results`,role:`listbox`,children:A.map((e,t)=>(0,L.jsx)(`li`,{children:(0,L.jsxs)(`button`,{ref:t===d?w:void 0,type:`button`,"data-quick-open-result":e.path,className:t===d?`quick-open-result quick-open-result-active`:`quick-open-result`,"aria-selected":t===d,onMouseMove:()=>f(t),onClick:()=>{v.current=void 0,y(e)},children:[(0,L.jsx)(`span`,{title:e.name,children:e.name}),(0,L.jsx)(`small`,{title:e.path,children:e.path})]})},e.path))}),T&&k?.indexed&&(p>0||k.truncated)&&(0,L.jsxs)(`div`,{className:`quick-open-pages`,"aria-label":`文件搜索翻页`,children:[p>0&&(0,L.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>j(p-1),children:`上一页`}),k.truncated&&(0,L.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-quick-open-next-page":!0,onClick:()=>j(p+1),children:`下一页`})]})]})}function lm({workspaceId:e,workspaceName:t,cwd:n,connected:r,onOpen:i,onSession:a}){let[o,s]=(0,u.useState)(`content`),[c,l]=(0,u.useState)(``),d={workspaceId:e,cwd:n,initialQuery:c,presentation:`sidebar`,onClose:()=>{},onMode:(e,t)=>{l(t),s(e)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`workbench-search-heading`,children:[(0,L.jsx)(`strong`,{children:`搜索`}),(0,L.jsx)(`span`,{title:t,children:t??`请选择工作区`})]}),o===`content`?(0,L.jsx)(sm,{...d,onOpen:i}):o===`path`?(0,L.jsx)(cm,{...d,connected:r,onOpen:i}):(0,L.jsx)(ff,{...d,onOpen:a})]})}function um(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 dm(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 fm(e,t,n=88,r=200){let[i,a]=(0,u.useState)(()=>um(e,0,n,r)),[o,s]=(0,u.useState)(null),c=(0,u.useCallback)(()=>{let i=um(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 pm({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:_}=fm(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=dm(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,L.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,L.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,L.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,L.jsx)(`span`,{className:`${c}-icon workspace-tab-icon`,children:a.icon}),a.badge,(0,L.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,L.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 mm=25,hm=75;function gm({share:e,onShare:t}){let n=(0,u.useRef)(null),[r,i]=(0,u.useState)(!1),a=e=>t(Math.round(Math.min(hm,Math.max(mm,e))));return(0,u.useLayoutEffect)(()=>{let e=n.current?.parentElement;if(!e)return;let t=()=>i(getComputedStyle(e).flexDirection===`column`);t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[]),(0,L.jsx)(`div`,{ref:n,className:`workbench-split-divider`,"data-workbench-split-divider":!0,role:`separator`,"aria-label":`调整拆分大小`,"aria-orientation":r?`horizontal`:`vertical`,"aria-valuenow":e,"aria-valuemin":mm,"aria-valuemax":hm,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(mm);else if(t.key===`End`)a(hm);else return;t.preventDefault()}})}function _m({tabs:e,selected:t,onSelect:n,onPin:r,onCloseTab:i,onClose:a,children:o}){let s=e.find(e=>e.id===t);return(0,L.jsxs)(`section`,{className:`workbench-split-pane`,"data-workbench-split-pane":!0,"aria-label":`拆分区`,children:[(0,L.jsxs)(`div`,{className:`workbench-split-bar`,children:[(0,L.jsxs)(`select`,{"aria-label":`拆分区标签页`,"data-workbench-split-tabs":!0,value:t??``,onChange:e=>n(e.target.value),title:s?.title,"data-workbench-split-preview":s?.preview||void 0,children:[(0,L.jsx)(`option`,{value:``,disabled:!0,children:`选择文件或差异`}),e.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),t&&s?.preview&&(0,L.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`固定标签页`,"aria-label":`固定拆分区标签页`,onClick:()=>r(t),children:(0,L.jsx)(rn,{name:`pin`})}),t&&(0,L.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`关闭此标签页`,"aria-label":`关闭拆分区标签页`,onClick:()=>i(t),children:(0,L.jsx)(rn,{name:`close`})}),(0,L.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,"data-close-workbench-split":!0,title:`合并主区`,"aria-label":`合并主区`,onClick:a,children:(0,L.jsx)(rn,{name:`split`})})]}),o??(0,L.jsx)(`p`,{className:`rail-empty`,children:`从文件或 Git 面板打开一个文件或差异。`})]})}function vm(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 ym(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 bm={pending:`未开始`,running:`运行中`,completed:`已完成`,failed:`失败`,skipped:`已跳过`,stopped:`已停止`},xm={running:`运行中`,completed:`全部完成`,failed:`中途失败`,stopped:`已停止`},Sm={pending:`○`,running:`◐`,completed:`✓`,failed:`✕`,skipped:`→`,stopped:`■`},Cm={stop:`失败即停`,skip:`失败跳过`,"retry:1":`失败重试 1 次`,"retry:2":`失败重试 2 次`,"retry:3":`失败重试 3 次`};function wm(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 Tm(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 Em({step:e,names:t}){let n=e.attempts.length,r=e.attempts[n-1],i=t.get(e.agentId)||e.agentId,a=e.label?.trim()||i;return(0,L.jsxs)(`li`,{className:`workflow-step workflow-step-${e.status}`,"data-workflow-step":e.index+1,"data-workflow-step-status":e.status,"data-workflow-step-agent":e.agentId,"data-workflow-step-attempts":n,children:[(0,L.jsx)(`span`,{className:`workflow-step-mark`,"aria-hidden":`true`,children:Sm[e.status]}),(0,L.jsxs)(`span`,{className:`workflow-step-n`,"data-workflow-step-n":e.index+1,children:[`第 `,e.index+1,` 步`]}),(0,L.jsx)(`strong`,{className:`workflow-step-name`,"data-workflow-step-name":e.index+1,children:a}),(0,L.jsx)(`span`,{className:`workflow-step-agent`,"data-workflow-step-agent-name":e.index+1,children:i}),n>1&&(0,L.jsxs)(`span`,{className:`workflow-step-tries`,"data-workflow-step-retried":e.index+1,children:[`尝试 `,n,` 次`]}),(0,L.jsx)(`span`,{className:`workflow-step-status`,"data-workflow-step-status-text":e.index+1,children:bm[e.status]}),e.status===`failed`&&r?.error&&(0,L.jsx)(`span`,{className:`workflow-step-why`,"data-workflow-step-error":e.index+1,title:Vt(r.error),children:Bt(r.error,`这一步没有完成。`)})]})}function Dm({nodes:e,steps:t,names:n}){return(0,L.jsx)(`ol`,{className:`workflow-steps`,children:e.map((e,r)=>{if(e.kind===`step`){let r=t[e.stepIndex];return r?(0,L.jsx)(Em,{step:r,names:n},`step-${e.stepIndex}`):null}return e.kind===`loop`?(0,L.jsxs)(`li`,{className:`workflow-node workflow-loop`,"data-workflow-loop":!0,"data-workflow-loop-rounds":e.rounds.length,"data-workflow-loop-max":e.max,"data-workflow-until":e.until,children:[(0,L.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),(0,L.jsx)(`strong`,{children:`循环`}),(0,L.jsxs)(`span`,{children:[`直到「`,e.until,`」`]}),(0,L.jsxs)(`span`,{"data-workflow-loop-progress":!0,children:[`已跑 `,e.rounds.length,`/`,e.max,` 轮`]})]}),e.rounds.map(e=>(0,L.jsxs)(`section`,{className:`workflow-round`,"data-workflow-round":e.n,"data-workflow-round-met":e.untilMet?`true`:`false`,children:[(0,L.jsxs)(`div`,{className:`workflow-round-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:e.untilMet?`✓`:`○`}),`第 `,e.n,` 轮 · `,e.untilMet?`条件满足`:`条件未满足`]}),(0,L.jsx)(Dm,{nodes:e.nodes,steps:t,names:n})]},e.n))]},`loop-${r}`):(0,L.jsxs)(`li`,{className:`workflow-node workflow-foreach`,"data-workflow-foreach":!0,"data-workflow-foreach-count":e.items.length,children:[(0,L.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`≡`}),(0,L.jsx)(`strong`,{children:`逐项执行`}),(0,L.jsxs)(`span`,{children:[e.items.length,` 个由 primary 给出的项目`]})]}),e.iterations.map((e,r)=>(0,L.jsxs)(`section`,{className:`workflow-item`,"data-workflow-item":r+1,"data-workflow-item-value":e.item,children:[(0,L.jsxs)(`div`,{className:`workflow-item-head`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),`第 `,r+1,` 项 · `,e.item]}),(0,L.jsx)(Dm,{nodes:e.nodes,steps:t,names:n})]},`${r}-${e.item}`))]},`foreach-${r}`)})})}function Om({workflow:e,names:t,onStop:n,stopping:r}){let i=e.status===`running`,a=Tm(e),o=e.steps.filter(e=>e.status===`completed`||e.status===`skipped`).length;return(0,L.jsxs)(`article`,{className:`workflow-card workflow-${e.status}`,"data-workflow-card":e.id,"data-workflow-status":e.status,"data-workflow-steps":e.steps.length,"data-workflow-current":e.currentIndex+1,children:[(0,L.jsxs)(`div`,{className:`workflow-head`,children:[(0,L.jsx)(`span`,{className:`workflow-badge`,children:`编排`}),(0,L.jsx)(`strong`,{className:`workflow-summary`,"data-workflow-summary":e.id,children:e.summary}),(0,L.jsxs)(`span`,{className:`workflow-progress`,"data-workflow-progress":e.id,children:[o,`/`,e.steps.length]}),(0,L.jsx)(`span`,{className:`workflow-status`,"data-workflow-status-text":e.id,children:xm[e.status]??`未知状态`}),(0,L.jsx)(`span`,{className:`workflow-policy`,"data-workflow-policy":e.onFailure,children:Cm[e.onFailure]??e.onFailure}),a!==void 0&&(0,L.jsxs)(`span`,{className:`workflow-clock`,"data-workflow-elapsed":e.id,children:[i?`已运行 `:`用时 `,wm(a)]}),i&&(0,L.jsx)(`button`,{type:`button`,className:`workflow-stop`,"data-workflow-stop":e.id,disabled:r,onClick:n,children:`停止`})]}),e.nodes?(0,L.jsx)(Dm,{nodes:e.nodes,steps:e.steps,names:t}):(0,L.jsx)(`ol`,{className:`workflow-steps`,"data-workflow-step-count":e.steps.length,children:e.steps.map(e=>(0,L.jsx)(Em,{step:e,names:t},e.index))})]})}var km=[{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 Am({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=km.find(e=>e.id===t)??km[0];return(0,L.jsx)(`div`,{className:`overlay`,onClick:e,children:(0,L.jsxs)(`div`,{className:`picker settings-window help-window`,"data-help-window":`1`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`help-window-title`,children:[(0,L.jsxs)(`div`,{className:`settings-window-head help-window-head`,children:[(0,L.jsxs)(`div`,{className:`help-head-title`,children:[(0,L.jsx)(`h2`,{id:`help-window-title`,children:`使用指南与帮助`}),(0,L.jsx)(`span`,{className:`help-badge`,children:`v0.1.x`})]}),(0,L.jsx)(`button`,{type:`button`,className:`help-close-button`,"aria-label":`关闭指南`,onClick:e,children:`✕`})]}),(0,L.jsxs)(`div`,{className:`settings-window-body help-window-body`,children:[(0,L.jsxs)(`nav`,{className:`settings-nav help-nav`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":`使用指南分类`,children:[(0,L.jsx)(`div`,{className:`settings-nav-label`,children:`目录`}),km.map(e=>(0,L.jsxs)(`button`,{type:`button`,id:`help-tab-${e.id}`,className:`settings-category help-category`,role:`tab`,"aria-selected":e.id===r.id,"aria-controls":`help-panel`,tabIndex:e.id===r.id?0:-1,onClick:()=>n(e.id),children:[(0,L.jsx)(`span`,{className:`help-tab-icon`,"aria-hidden":`true`,children:e.icon}),(0,L.jsx)(`span`,{children:e.label})]},e.id))]}),(0,L.jsxs)(`div`,{id:`help-panel`,className:`settings-panel help-panel`,role:`tabpanel`,"aria-labelledby":`help-tab-${r.id}`,children:[(0,L.jsxs)(`div`,{className:`help-panel-header`,children:[(0,L.jsx)(`h3`,{className:`help-panel-title`,children:r.title}),(0,L.jsx)(`p`,{className:`help-panel-desc`,children:r.description})]}),(0,L.jsxs)(`div`,{className:`help-panel-content`,children:[r.id===`agents`&&(0,L.jsx)(Nm,{}),r.id===`workspace`&&(0,L.jsx)(Pm,{}),r.id===`subagents`&&(0,L.jsx)(Im,{}),r.id===`model-policy`&&(0,L.jsx)(Fm,{}),r.id===`memory`&&(0,L.jsx)(jm,{}),r.id===`knowledge`&&(0,L.jsx)(Mm,{}),r.id===`feishu`&&(0,L.jsx)(Lm,{}),r.id===`tools`&&(0,L.jsx)(Rm,{}),r.id===`cli`&&(0,L.jsx)(zm,{}),r.id===`themes`&&(0,L.jsx)(Bm,{})]}),(0,L.jsx)(`div`,{className:`picker-actions help-actions`,children:(0,L.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e,children:`关闭`})})]})]})]})})}function jm(){return(0,L.jsxs)(`div`,{className:`help-section-group`,children:[(0,L.jsxs)(`div`,{className:`help-card highlight`,children:[(0,L.jsx)(`h4`,{children:`🧠 它会记住什么?`}),(0,L.jsx)(`p`,{children:`用户档案保存跨工作区的长期偏好;工作区事实保存环境与项目约定;技能保存已经验证过的步骤、命令和坑。临时结果、秘密和未验证的失败不会保存。`})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`主动保存与后台复盘`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[`主 Agent 可以使用 `,(0,L.jsx)(`code`,{children:`memory`}),` 和 `,(0,L.jsx)(`code`,{children:`skill_manage`}),` 工具主动保存;说“记住了”本身不会写入。`]}),(0,L.jsx)(`li`,{children:`每隔若干回合,系统会在独立会话中复盘最近证据。复盘不能读写工作区文件、执行命令或派发任务。`}),(0,L.jsx)(`li`,{children:`读取记忆和历史只返回带来源的参考数据,不能把记忆中的文字当作新的指令。`})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`权限与审批`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsx)(`li`,{children:`子 Agent 可以读取相关记忆,但没有写入权限。`}),(0,L.jsx)(`li`,{children:`后台复盘新增记忆可以直接保存;修改或删除旧条目会进入设置中的待审批列表。`}),(0,L.jsx)(`li`,{children:`在“设置 → 主动记忆”可以开关功能、调整复盘间隔、编辑条目和批准提案。`})]})]})]})}function Mm(){return(0,L.jsxs)(`div`,{className:`help-section-group`,children:[(0,L.jsxs)(`div`,{className:`help-card highlight`,children:[(0,L.jsx)(`h4`,{children:`📚 它解决什么问题?`}),(0,L.jsx)(`p`,{children:`Agent 默认靠训练时的记忆回答项目里的问题。知识库让你把规范、设计稿、会议纪要导入工作区,Agent 在回答前检索这些文档的原文片段,而不是凭印象编造。它与“主动记忆”不同:记忆是 Agent 自己沉淀的事实和技能,知识库的内容来自工作区里真实存在的文档。`})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`怎么用`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[`在“设置 → 知识库”里点“浏览工作区文件…”,在弹出的浏览器里挑一个 Markdown 或文本文件,挑完即导入。也可以直接粘贴正文、手动填写相对路径,或者直接对 Agent 说“把某某文件加入知识库”——它会用 `,(0,L.jsx)(`code`,{children:`knowledge_import`}),` 导入,走的是同一条服务端校验。`]}),(0,L.jsx)(`li`,{children:`同一个文件内容改了再导入就是更新,不会留下旧版本;同样的内容换个标题再导入也不会变成两篇。`}),(0,L.jsx)(`li`,{children:`面板里的“试检索”会用和 Agent 相同的检索器回答,方便你在交给 Agent 之前先确认它找得到。`}),(0,L.jsxs)(`li`,{children:[`从下一条消息开始生效。Agent 使用 `,(0,L.jsx)(`code`,{children:`knowledge_search`}),` 检索,只拿得到片段和来源,拿不到整篇文档。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`语义检索是内置的`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[`关键词检索始终可用。语义检索让“撤销购买”也能找到写着“取消订单”的段落,它靠一个`,(0,L.jsx)(`strong`,{children:`随安装包一起分发`}),`的中文模型在本机运行,不需要额外下载、不需要联网、也不会把文档发到任何服务。`]}),(0,L.jsxs)(`li`,{children:[`第一次检索时加载模型(约一秒),之后一直可用。设 `,(0,L.jsx)(`code`,{children:`SUPER_PI_KNOWLEDGE_EMBEDDINGS=0`}),` 可以彻底关闭语义检索,只保留关键词检索。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`它不知道的事`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsx)(`li`,{children:`知识库只会检索它有的东西。文档里没写的,它检索出来也不会有——所以导入什么,直接决定它能回答什么。`}),(0,L.jsx)(`li`,{children:`语义检索总会返回“最接近的那一段”,即使这一段其实并不回答问题。检索结果带一个分数,低分意味着这可能只是最像的一条,Agent 会被要求先核对再使用。`}),(0,L.jsxs)(`li`,{children:[`Agent 可以按你的要求把工作区文件导入知识库(`,(0,L.jsx)(`code`,{children:`knowledge_import`}),`,只接受文本类文件),但`,(0,L.jsx)(`strong`,{children:`不能删除`}),`——删除文档只有你能在“设置 → 知识库”里做。`]})]})]})]})}function Nm(){return(0,L.jsxs)(`div`,{className:`help-section-group`,children:[(0,L.jsxs)(`div`,{className:`help-card highlight`,children:[(0,L.jsx)(`h4`,{children:`💡 Agent 是什么?`}),(0,L.jsxs)(`p`,{children:[`在 Super Pi 中,`,(0,L.jsx)(`strong`,{children:`Agent(智能体)`}),` 是一套独立的「角色提示词设定与能力配置」。 通过切换 Agent,模型将扮演专精工程师、系统架构师、代码审查员或规划专家等不同角色,遵循指定的原则来协助你完成任务。`]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`📁 Agent 文件存放在哪里?`}),(0,L.jsxs)(`ul`,{className:`help-list`,children:[(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`内置 Agent 目录:`}),`项目根目录下的 `,(0,L.jsx)(`code`,{children:`agents/`}),` 文件夹,例如 `,(0,L.jsx)(`code`,{children:`agents/coder.md`}),`、`,(0,L.jsx)(`code`,{children:`agents/planner.md`}),`、`,(0,L.jsx)(`code`,{children:`agents/reviewer.md`}),` 等。`]}),(0,L.jsxs)(`li`,{children:[(0,L.jsx)(`strong`,{children:`用户自定义持久化目录:`}),`用户主目录下的 `,(0,L.jsx)(`code`,{children:`~/.super-pi/agents/`}),`,放入此目录的文件在所有项目和更新中均持久有效。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-card`,children:[(0,L.jsx)(`h4`,{children:`🚀 如何创建一个全新的自定义 Agent?`}),(0,L.jsxs)(`div`,{className:`help-steps`,children:[(0,L.jsxs)(`div`,{className:`help-step`,children:[(0,L.jsx)(`span`,{className:`step-num`,children:`1`}),(0,L.jsxs)(`div`,{className:`step-body`,children:[(0,L.jsx)(`strong`,{children:`创建 Markdown 文件`}),(0,L.jsxs)(`p`,{children:[`在 `,(0,L.jsx)(`code`,{children:`agents/`}),` 或 `,(0,L.jsx)(`code`,{children:`~/.super-pi/agents/`}),` 目录下新建文件,例如 `,(0,L.jsx)(`code`,{children:`architect.md`}),`。`]})]})]}),(0,L.jsxs)(`div`,{className:`help-step`,children:[(0,L.jsx)(`span`,{className:`step-num`,children:`2`}),(0,L.jsxs)(`div`,{className:`step-body`,children:[(0,L.jsx)(`strong`,{children:`编写元数据与系统提示词`}),(0,L.jsx)(`p`,{children:`文件开头使用 YAML Frontmatter 声明名称和描述,正文编写设定提示词:`}),(0,L.jsx)(`pre`,{className:`help-code-block`,children:(0,L.jsx)(`code`,{children:`---
@@ -338,7 +338,7 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
338
338
  `).find(e=>e.trim().length>0)??``).trim().slice(0,60)||`任务指令`,state:`running`};let t=(()=>{let t=/<summary>([\s\S]*?)<\/summary>/.exec(e.content);return t?t[1].trim():`后台回传`})(),n=/<task id="[^"]+" state="([^"]+)"/.exec(e.content);return{label:t,state:n?n[1]:`completed`}}function VD({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?BD(e):{label:zD(e),state:`user`},C=()=>{let t=g.trim();t&&t!==e.content&&p(e.id,t),h(!1)};return(0,L.jsxs)(`li`,{className:`queue-row ${v?`queue-row-sending`:`queue-row-queued`} ${b?`queue-row-bg-result`:``}`,"data-queue-id":e.id,"data-message-delivery":e.delivery,"data-message-role":e.role,"data-bg-result-state":b?S:void 0,"data-waiting-order":t,"data-waiting-total":n,children:[a&&(0,L.jsx)(`input`,{type:`checkbox`,className:`queue-select`,"data-waiting-select":e.id,checked:o,"aria-label":`选择「${x}」`,onChange:()=>s?.(e.id)}),(0,L.jsx)(`span`,{className:`queue-index`,"aria-hidden":`true`,children:t}),y?(0,L.jsxs)(`span`,{className:`queue-reminder`,"data-queue-reminder":!0,children:[(0,L.jsxs)(`span`,{className:`reminder-label`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,L.jsx)(`span`,{className:`queue-text`,title:x,children:x})]}):b?(0,L.jsxs)(`span`,{className:`queue-bg-result`,title:x,children:[(0,L.jsx)(`span`,{className:`bg-result-glyph`,"aria-hidden":`true`,children:S===`error`?`✕`:`↩`}),(0,L.jsx)(`span`,{className:`bg-result-label`,children:`后台回传`}),(0,L.jsx)(`span`,{className:`bg-result-summary`,children:x})]}):m?(0,L.jsxs)(`div`,{className:`queue-row-edit`,children:[(0,L.jsx)(`textarea`,{value:g,autoFocus:!0,rows:2,"aria-label":`修改这条等待中的消息`,onChange:e=>_(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),_(e.content),h(!1)),t.key===`Enter`&&(t.metaKey||t.ctrlKey)&&(t.preventDefault(),C())}}),(0,L.jsx)(`button`,{type:`button`,className:`queue-edit-save`,"data-waiting-save":e.id,onClick:C,children:`保存`}),(0,L.jsx)(`button`,{type:`button`,className:`queue-edit-cancel`,"data-waiting-cancel-edit":e.id,onClick:()=>{_(e.content),h(!1)},children:`取消`})]}):(0,L.jsx)(`span`,{className:`queue-text`,title:x,children:x}),(0,L.jsx)(`span`,{className:`queue-state`,"data-waiting-state":v?`sending`:`queued`,children:v?`已交给 Agent`:t===1?`下一条回答这条`:`等待回答 · 第 ${t} 条`}),v?(0,L.jsx)(`span`,{className:`queue-locked`,"data-waiting-locked":e.id,children:`暂时改不了`}):(0,L.jsxs)(L.Fragment,{children:[r?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,className:`queue-interrupt`,"data-waiting-interrupt":e.id,disabled:i,title:`停止当前任务,立即回答这条消息`,"aria-label":`停止当前任务并回答「${x}」`,onClick:()=>l(e.id),children:i?`◌ 打断中…`:`打断并回答`}),(0,L.jsx)(`button`,{type:`button`,className:`queue-steer`,"data-waiting-steer":e.id,title:t===1?`当前工具完成后回答这条消息`:`插到最前:让它成为下一条被回答的消息`,"aria-label":t===1?`当前工具完成后回答「${x}」`:`让「${x}」插到最前`,onClick:()=>c(e.id),children:t===1?`当前工具完成后回答`:`插到最前`})]}):(0,L.jsx)(`button`,{type:`button`,className:`queue-steer`,"data-waiting-send":e.id,title:`现在就回答这条消息`,"aria-label":`现在就回答「${x}」`,onClick:()=>d(e.id),children:`现在就回答`}),e.role===`user`&&(0,L.jsx)(`button`,{type:`button`,className:`queue-edit`,"data-waiting-edit":e.id,title:`回答这条之前改字`,"aria-label":`修改「${x}」`,onClick:()=>{_(e.content),h(!0)},children:`改字`}),(0,L.jsx)(`button`,{type:`button`,className:`queue-cancel`,"data-waiting-cancel":e.id,title:`撤回这条消息,它不会被回答`,"aria-label":`撤回「${x}」`,onClick:()=>f(e.id),children:`撤回`})]})]})}function HD(e,t,n){return`${e}:${t}:${n}`}function UD(e){return{picked:Object.fromEntries((e.answers??[]).map(e=>[e.id,e.selected])),note:e.answers?.map(e=>e.note??``).join(`
339
339
  `)??``}}function WD({question:e,index:t,expanded:n,draft:r,onDraftChange:i,onToggle:a,onAnswer:o}){return(0,L.jsxs)(`div`,{className:`call-block question-block-${e.status}`,"data-call-block":t,"data-call-tool":`question`,"data-call-detail":`提问`,"data-call-status":e.status===`answered`?`ok`:e.status===`cancelled`?`error`:`running`,"data-call-expanded":n?`true`:`false`,"data-question-block":t,children:[(0,L.jsx)(`button`,{type:`button`,className:`call-fold-edge`,"data-question-fold-edge":t,"aria-expanded":n,"aria-label":`${n?`折叠`:`展开`}提问`,title:n?`折叠这段提问`:`展开这段提问`,onClick:a}),(0,L.jsxs)(`div`,{className:`call-head-row`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`call-head`,"data-call-head":t,"aria-expanded":n,onClick:a,children:[(0,L.jsx)(`span`,{className:`call-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,L.jsx)(`span`,{className:`call-glyph`,"aria-hidden":`true`,children:e.status===`answered`?`✓`:e.status===`cancelled`?`✕`:`?`}),(0,L.jsx)(`span`,{className:`call-label`,children:`提问`}),(0,L.jsxs)(`span`,{className:`call-detail`,children:[e.items.length,` 个问题`]})]}),n&&(0,L.jsx)(`button`,{type:`button`,className:`call-fold-top`,"data-call-fold-top":t,onClick:a,children:`收起`})]}),n&&(0,L.jsx)(`div`,{className:`question-body`,"data-question-body":t,children:(0,L.jsx)(GD,{question:e,draft:r,onDraftChange:i,instanceId:`inline`,onAnswer:o})})]})}function GD({question:e,draft:t,onDraftChange:n,instanceId:r,onAnswer:i}){let{picked:a,note:o}=t,s=(e,r,i)=>{let o=(()=>{let t=a,n=t[e]??[];return i?{...t,[e]:n.includes(r)?n.filter(e=>e!==r):[...n,r]}:{...t,[e]:[r]}})();n({...t,picked:o})},c=()=>{i(e.items.map(e=>({id:e.id,selected:a[e.id]??[],...e.extraNote&&o.trim()?{note:o.trim()}:{}})),!1)},l=e.items.some(e=>(a[e.id]??[]).length>0);return(0,L.jsxs)(`div`,{className:`question-block question-${e.status}`,"data-question-status":e.status,children:[e.items.map(i=>(0,L.jsxs)(`div`,{className:`question-item`,children:[(0,L.jsx)(`div`,{className:`question-text`,children:i.header?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`question-header`,children:i.header}),(0,L.jsx)(`span`,{className:`question-sep`,children:` · `}),(0,L.jsx)(Ed,{source:i.question})]}):(0,L.jsx)(Ed,{source:i.question})}),(0,L.jsx)(`div`,{className:`question-options`,"data-question-options":i.id,children:i.options.map(t=>{let n=e.status!==`pending`,o=(n?e.answers?.find(e=>e.id===i.id)?.selected:a[i.id])?.includes(t)??!1;return(0,L.jsxs)(`label`,{className:o?`is-chosen`:``,"data-chosen":n&&o?`1`:void 0,children:[(0,L.jsx)(`input`,{type:i.multiple?`checkbox`:`radio`,name:`q-${r}-${i.id}`,checked:o,disabled:n,onChange:()=>s(i.id,t,i.multiple)}),(0,L.jsx)(Dd,{source:t}),n&&o?(0,L.jsx)(`span`,{className:`question-mark`,"aria-label":`已选择`,children:`✓`}):null]},t)})}),e.status===`pending`&&i.extraNote?(0,L.jsx)(`textarea`,{value:o,placeholder:`补充说明(可选)`,onChange:e=>n({...t,note:e.target.value})}):e.status===`answered`&&(e.answers??[]).some(e=>e.note)?(0,L.jsxs)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:[`补充:`,(e.answers??[]).map(e=>e.note).filter(Boolean).join(`;`)]}):null,e.status===`cancelled`&&(0,L.jsx)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:`已取消,没有作答。`})]},i.id)),e.status===`pending`&&(0,L.jsxs)(`div`,{className:`question-actions`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:c,disabled:!l,children:`提交`}),(0,L.jsx)(`button`,{type:`button`,className:`question-skip`,onClick:()=>i([],!0),children:`跳过`})]})]})}function KD({question:e,pendingCount:t,minimized:n,floatingRight:r,onMinimize:i,onExpand:a,onLocate:o,draft:s,onDraftChange:c,onAnswer:l}){return n?(0,xt.createPortal)((0,L.jsxs)(`button`,{type:`button`,className:`question-floating-ball`,style:{"--question-floating-right":r},"data-question-floating-ball":e.key,onClick:a,"aria-label":`展开待回答的问题${t>1?`,还有 ${t-1} 个待处理`:``}`,title:`展开待回答的问题`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,children:`?`}),t>1&&(0,L.jsx)(`small`,{children:t})]}),document.body):(0,xt.createPortal)((0,L.jsxs)(`section`,{className:`question-floating-panel`,style:{"--question-floating-right":r},"data-question-floating-panel":e.key,role:`dialog`,"aria-labelledby":`question-floating-title`,children:[(0,L.jsxs)(`header`,{className:`question-floating-head`,children:[(0,L.jsx)(`span`,{className:`question-floating-mark`,"aria-hidden":`true`,children:`?`}),(0,L.jsxs)(`h2`,{id:`question-floating-title`,children:[`需要你回答`,t>1?` · 还有 ${t-1} 个`:``]}),(0,L.jsx)(`button`,{type:`button`,className:`question-floating-minimize`,onClick:o,title:`定位到消息上下文并最小化`,children:`查看上下文`}),(0,L.jsx)(`button`,{type:`button`,className:`question-floating-minimize-icon`,onClick:i,title:`最小化为悬浮球`,"aria-label":`最小化问题`,children:`−`})]}),(0,L.jsx)(`div`,{className:`question-floating-body`,children:(0,L.jsx)(GD,{question:e.value,draft:s,onDraftChange:c,instanceId:`floating`,onAnswer:l})})]}),document.body)}function qD({request:e,onAnswer:t,pending:n}){let[r,i]=(0,u.useState)(e.prefill??``),a=e.method===`input`||e.method===`editor`,o=(0,L.jsx)(`button`,{type:`button`,className:`extui-cancel`,onClick:()=>t({cancelled:!0}),children:`取消提问`});return(0,L.jsxs)(`article`,{className:`extui-card extui-${e.method}`,"data-request-id":e.requestId,"data-method":e.method,children:[(0,L.jsxs)(`div`,{className:`extui-head`,children:[(0,L.jsx)(`span`,{className:`extui-badge`,children:`扩展提问`}),e.timeoutMs!==void 0&&(0,L.jsxs)(`span`,{className:`extui-deadline`,children:[Math.ceil(Math.max(0,e.deadlineAt===void 0?e.timeoutMs:e.deadlineAt-Date.now())/1e3),`s 超时`]})]}),n&&(0,L.jsx)(`p`,{className:`extui-pending`,role:`status`,children:`提交中…`}),(0,L.jsxs)(`fieldset`,{disabled:n,style:{border:0,padding:0,margin:0},children:[(0,L.jsx)(`h3`,{className:`extui-title`,children:e.title||sO[e.method]}),e.method===`confirm`&&(0,L.jsx)(`p`,{className:`extui-body`,children:e.message}),e.method===`select`&&(0,L.jsxs)(`div`,{className:`extui-options`,children:[(e.options??[]).map(e=>(0,L.jsx)(`button`,{type:`button`,className:`extui-option`,onClick:()=>t({value:e}),children:e},e)),(e.options??[]).length===0&&(0,L.jsx)(`p`,{className:`extui-body`,children:`扩展没有提供任何选项`})]}),a&&(0,L.jsxs)(`form`,{className:`extui-form`,onSubmit:e=>{e.preventDefault(),!n&&r.trim()&&t({value:r})},children:[e.method===`input`?(0,L.jsx)(`input`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&GE(e)&&e.preventDefault()},placeholder:e.placeholder??``}):(0,L.jsx)(`textarea`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&GE(e)&&e.preventDefault()}}),(0,L.jsxs)(`div`,{className:`extui-actions`,children:[(0,L.jsx)(`button`,{type:`submit`,className:`extui-primary`,disabled:!r.trim(),children:`提交`}),o]})]}),!a&&(0,L.jsxs)(`div`,{className:`extui-actions`,children:[e.method===`confirm`&&(0,L.jsx)(`button`,{type:`button`,className:`extui-primary`,onClick:()=>t({confirmed:!0}),children:`确认`}),e.method===`confirm`&&(0,L.jsx)(`button`,{type:`button`,className:`extui-no`,onClick:()=>t({confirmed:!1}),children:`拒绝`}),o]})]})]})}function JD({initial:e,label:t,onCommit:n,onClose:r}){let[i,a]=(0,u.useState)(e),o=(0,u.useRef)(null),s=(0,u.useRef)(!1);(0,u.useEffect)(()=>{o.current?.focus(),o.current?.select()},[]);let c=!i.trim(),l=()=>{s.current=!0,r()},d=()=>{if(c)return;let t=i.trim();(t===e||n(t))&&l()};return(0,L.jsxs)(`div`,{className:`inline-edit`,"data-editing":`1`,children:[(0,L.jsx)(`input`,{ref:o,className:`inline-edit-input`,value:i,"aria-label":t,onChange:e=>a(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){if(GE(e))return;e.preventDefault(),d()}else e.key===`Escape`&&(e.preventDefault(),l())},onBlur:()=>{s.current||r()}}),(0,L.jsx)(`button`,{type:`button`,className:`inline-edit-ok`,title:`确认重命名`,"aria-label":`确认重命名`,disabled:c,onMouseDown:e=>e.preventDefault(),onClick:d,children:`✓`}),(0,L.jsx)(`button`,{type:`button`,className:`inline-edit-cancel`,title:`取消重命名`,"aria-label":`取消重命名`,onMouseDown:e=>e.preventDefault(),onClick:l,children:`✗`})]})}function YD({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=_D(l?i.filter(e=>_===`*`||e.key!==XD&&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(GE(e))return;e.preventDefault(),D&&(s(D.key),O(!0))}}},M=`picker-list-${c??e}`,N=t=>`picker-option-${c??e}-${t}`;return(0,L.jsxs)(`div`,{className:`session-picker-item session-picker-${e}`,ref:y,onKeyDown:d?j:void 0,children:[(0,L.jsxs)(`button`,{ref:b,type:`button`,className:`session-picker-trigger`,disabled:a,"aria-haspopup":`listbox`,"aria-expanded":d,title:o??`${lD[e]}:${r?`${t} · ${r}`:t}`,"data-picker-trigger":e,"data-picker-value":n??t,"data-picker-selected":i.some(e=>e.selected),onClick:()=>d?O():k(),children:[(0,L.jsx)(`span`,{className:`session-picker-kind`,children:lD[e]}),(0,L.jsx)(`span`,{className:`session-picker-name`,children:t}),r&&(0,L.jsx)(`span`,{className:`session-picker-detail`,children:r}),(0,L.jsx)(`span`,{className:`session-picker-caret`,"aria-hidden":`true`,children:`▾`})]}),d&&(0,L.jsxs)(`div`,{className:`picker-menu`,ref:x,"data-picker-menu":e,"data-picker-highlight":E,children:[l&&(0,L.jsxs)(`label`,{className:`picker-provider-filter`,children:[(0,L.jsx)(`span`,{children:`Provider`}),(0,L.jsxs)(`select`,{"data-picker-provider":e,"aria-label":`筛选模型 Provider`,value:_,onKeyDown:e=>e.stopPropagation(),onChange:e=>{v(e.target.value),g(0)},children:[(0,L.jsx)(`option`,{value:`*`,children:`全部 Provider`}),l.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))]})]}),(0,L.jsxs)(`div`,{className:`picker-filter`,children:[(0,L.jsx)(`span`,{className:`picker-filter-icon`,"aria-hidden":`true`,children:`🔍`}),(0,L.jsx)(`input`,{ref:S,className:`picker-filter-input`,"data-picker-filter":e,role:`combobox`,"aria-label":`筛选${dD[e]}选项`,"aria-expanded":`true`,"aria-controls":M,"aria-autocomplete":`list`,"aria-activedescendant":D?N(E):void 0,value:p,placeholder:`输入以筛选…`,autoComplete:`off`,spellCheck:!1,onChange:e=>{m(e.target.value),g(0)}}),p&&(0,L.jsx)(`button`,{type:`button`,className:`picker-filter-clear`,"data-picker-filter-clear":e,title:`清空筛选`,"aria-label":`清空筛选`,onMouseDown:e=>e.preventDefault(),onClick:()=>{m(``),g(0),S.current?.focus()},children:`✕`})]}),w&&!T.some(e=>e.key===w.key)&&(0,L.jsxs)(`div`,{className:`picker-current`,"data-picker-current":e,"data-picker-current-value":w.key,children:[(0,L.jsx)(`span`,{className:`picker-current-label`,children:`当前`}),(0,L.jsx)(`span`,{className:`picker-current-value`,children:w.label})]}),(0,L.jsxs)(`div`,{className:`picker-list`,role:`listbox`,id:M,"aria-label":pD[e],children:[T.map((e,t)=>(0,L.jsxs)(`button`,{id:N(t),type:`button`,role:`option`,"aria-selected":e.selected,ref:e=>{C.current[t]=e},className:`picker-option${e.selected?` selected`:``}${t===E&&!e.selected?` preview`:``}`,"data-picker-option":e.key,"data-picker-option-selected":e.selected,"data-picker-highlight":t===E,onClick:()=>{s(e.key),O(!0)},children:[e.color&&(0,L.jsx)(`span`,{className:`picker-option-swatch`,style:{background:e.color},"aria-hidden":`true`}),(0,L.jsx)(`span`,{className:`picker-option-name`,children:e.label}),e.badge&&(0,L.jsx)(`span`,{className:`picker-option-badge`,"data-picker-option-badge":e.badge,children:e.badge}),e.detail&&(0,L.jsx)(`span`,{className:`picker-option-detail`,children:e.detail}),e.selected&&(0,L.jsx)(`span`,{className:`picker-option-mark`,"aria-hidden":`true`,children:`✓`})]},e.key)),T.length===0&&(0,L.jsx)(`div`,{className:`picker-empty`,"data-picker-empty":e,children:i.length===0?fD[e]:`没有匹配「${p.trim()}」的${dD[e]}`})]})]})]})}var XD=`__pi_default__`;function ZD({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:XD,label:`跟随 Pi 默认`,detail:`不为新会话指定模型`,selected:l===void 0},...(t?.models??[]).map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,FE(e.contextWindow)?`${FE(e.contextWindow)} 上下文`:``,IE(e.maxTokens)?`${IE(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:hD(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:XD,label:`跟随 Pi 默认`,detail:`不为新会话指定思考等级`,selected:f===void 0},..._.map(e=>({key:e,label:e,selected:e===f}))],y=e=>{if(e===XD){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===XD?void 0:e),x=[{key:XD,label:`跟随 Pi 默认`,detail:`新会话不使用任何 agent 角色`,selected:s===void 0},...(n?.agents??[]).map(e=>({key:e.id,label:e.name,detail:e.toolSummary,color:e.color,selected:s===e.id}))];return(0,L.jsx)(`div`,{className:`overlay`,onClick:o,children:(0,L.jsxs)(`div`,{className:`picker settings-dialog`,"data-settings-dialog":`1`,onClick:e=>e.stopPropagation(),children:[(0,L.jsx)(`h2`,{children:`工作区设置`}),(0,L.jsxs)(`div`,{className:`settings-scope`,children:[e.name,` · 默认值只影响之后新建的会话,已有会话不变`]}),(0,L.jsx)(`div`,{className:`workspace-settings-path`,children:e.path}),(0,L.jsxs)(`div`,{className:`settings-row`,children:[(0,L.jsx)(`span`,{className:`settings-label`,children:`默认智能体`}),(0,L.jsx)(YD,{kind:`agent`,scope:`settings-agent`,label:n?.agents.find(e=>e.id===s)?.name??`跟随 Pi 默认`,value:s??XD,detail:s?`${n?.agents.find(e=>e.id===s)?.toolSummary??``}`:void 0,options:x,disabled:!n||n.source===`unavailable`,note:wD(n),onChoose:e=>c(e===XD?void 0:e)})]}),(0,L.jsxs)(`div`,{className:`settings-row`,children:[(0,L.jsx)(`span`,{className:`settings-label`,children:`默认模型`}),(0,L.jsx)(YD,{kind:`model`,scope:`settings-model`,label:l?.label??`跟随 Pi 默认`,value:l?`${l.provider}/${l.modelId}`:XD,detail:l?`${l.provider}/${l.modelId}`:void 0,options:h,providerOptions:[...new Set((t?.models??[]).map(e=>e.provider))],disabled:!m,note:CD(`模型`,t),onChoose:y})]}),(0,L.jsxs)(`div`,{className:`settings-row`,children:[(0,L.jsx)(`span`,{className:`settings-label`,children:`思考强度`}),(0,L.jsx)(YD,{kind:`thinking`,scope:`settings-thinking`,label:f??`跟随 Pi 默认`,value:f??XD,options:v,disabled:!m,note:CD(`思考等级`,t),onChoose:b})]}),l&&g&&_.length===0&&(0,L.jsx)(`div`,{className:`settings-scope`,children:`Pi 未提供此模型的可选等级,使用模型默认值。`}),(0,L.jsxs)(`div`,{className:`picker-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`settings-rename`,"data-settings-rename":`1`,onClick:i,children:`重命名工作区`}),(0,L.jsx)(`button`,{type:`button`,className:`picker-cancel`,"data-settings-cancel":`1`,onClick:o,children:`取消`}),(0,L.jsx)(`button`,{type:`button`,className:`picker-ok`,"data-settings-save":`1`,onClick:()=>r(s,l,f),children:`保存`})]}),(0,L.jsx)(`button`,{type:`button`,className:`workspace-delete`,onClick:a,children:`从列表移除工作区`})]})})}var QD=[{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`}],$D=`super-pi.right-tabs.v1`;function eO(){let e=e=>QD.some(t=>t.id===e),t={tab:QD[0].id,byConversation:{}};try{let n=JSON.parse(Ke($D)??`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 tO={waiting:`⋯`,running:``,failed:``,question:`?`,completed:``,unread:`•`,idle:``,awaiting_background:`⚙`,pending_report:`↑`,awaiting_subordinates:`↓`,awaiting_decision:`▲`},nO={idle:`空闲`,running:`讨论中`,awaiting_background:`后台任务进行中`,completed:`讨论已完成`,failed:`讨论未完成`},rO={waiting:`等待 LLM`,running:`进行中`,failed:`出错`,question:`等你回答`,completed:`已完成`,unread:`有未读`,idle:`空闲`,awaiting_background:`等待后台任务`,pending_report:`待汇报`,awaiting_subordinates:`等待下级`,awaiting_decision:`等上面拍板`},iO={idle:`就绪`,waiting:`等待 LLM`,running:`正在生成`,completed:`已完成`,stopped:`已停止`,failed:`运行失败`,awaiting_background:`等待后台任务`},aO=e=>e?.status===`running`||e?.status===`waiting`,oO={running:`运行中`,completed:`已完成`,failed:`失败`,stopped:`已停止`,cancelled:`已取消`,interrupted:`已中断`},sO={select:`请选择一项`,confirm:`请确认`,input:`请输入内容`,editor:`请输入内容`,notify:`扩展通知`,setStatus:`扩展状态`,setWidget:`扩展内容`,setTitle:`扩展标题`,set_editor_text:`扩展输入`};function cO(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 lO(e,t,n){let r=(t||[]).filter(t=>t.parentConversationId===e.id),i=(t||[]).find(t=>t.id===e.parentConversationId),a=n??``;return et({conversation:e,parent:i,directChildren:r,isTopLevelUnread:e.updatedAt>a})}function uO(e,t,n,r){let i=lO(e,r,n);return R({status:e.status,reportingState:i,awaitingQuestion:t,quietWhenRead:!0})}function dO(e,t){return t===`awaiting_decision`||e===`awaiting_decision`?(0,L.jsx)(`span`,{className:`conversation-status-badge badge--warning project-status-awaiting_decision`,"data-session-status":`awaiting_decision`,"data-reporting-badge":`awaiting_decision`,title:rO.awaiting_decision,children:rO.awaiting_decision}):t===`awaiting_subordinates`||e===`awaiting_subordinates`?(0,L.jsx)(`span`,{className:`conversation-status-badge project-status-awaiting_subordinates`,"data-session-status":`awaiting_subordinates`,"data-reporting-badge":`awaiting_subordinates`,title:rO.awaiting_subordinates,children:rO.awaiting_subordinates}):t===`pending_report`||e===`pending_report`?(0,L.jsx)(`span`,{className:`conversation-status-badge project-status-pending_report`,"data-session-status":`pending_report`,"data-reporting-badge":`pending_report`,title:rO.pending_report,children:rO.pending_report}):null}function fO({state:e,label:t=rO[e]}){let n=tO[e];if(e===`idle`)return null;let r=e.replace(/_/g,`-`);return(0,L.jsx)(`i`,{className:`session-state session-state-${e} session-state-${r}`,"data-session-state":e,title:t,"aria-label":t,...e===`awaiting_background`?{style:{color:`var(--accent)`}}:{},children:(0,L.jsx)(`i`,{className:`session-state-mark`,"aria-hidden":`true`,children:n})})}function pO(e,t){return(0,L.jsxs)(L.Fragment,{children:[e.origin===`orchestrator`&&(0,L.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`orchestrator`,title:`编排会话:由上级智能体创建`,"aria-label":`编排会话:由上级智能体创建`,children:`编排`}),t&&(0,L.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`scheduled`,title:`定时任务会话:${t.name}`,"aria-label":`定时任务会话:${t.name}`,children:`定时`})]})}function mO(e,t){let n=[];return e.origin===`orchestrator`&&n.push(`编排会话`),t&&n.push(`定时任务会话:${t.name}`),n.length?`(${n.join(`;`)})`:``}var hO={pending:`未开始`,in_progress:`运行中`,completed:`已完成`},gO={pending:`○`,in_progress:`◐`,completed:`✓`},_O={high:`高`,medium:`中`,low:`低`};function vO(e){let t=e.filter(e=>e.status!==`completed`).length;return e.length?t?`${t} 个未完成 / 共 ${e.length} 个`:`全部完成:${e.length} 个`:`0 个待办任务`}function yO({todo:e,index:t}){let n=e.id??`todo_${t}`;return(0,L.jsxs)(`li`,{className:`todo-item todo-${e.status}`,"data-todo-item":n,"data-todo-status":e.status,title:`状态:${hO[e.status]}`,children:[(0,L.jsx)(`span`,{className:`todo-mark`,"aria-hidden":`true`,children:gO[e.status]}),(0,L.jsx)(`span`,{className:`todo-text`,children:e.content}),(0,L.jsx)(`span`,{className:`todo-status`,"data-todo-status-text":`1`,children:hO[e.status]}),e.priority&&(0,L.jsx)(`span`,{className:`todo-priority`,"data-todo-priority":e.priority,children:_O[e.priority]})]})}function bO(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 xO({tasks:e,runs:t,execOutputs:n,onStop:r}){return(0,L.jsx)(`ul`,{className:`bg-list`,"data-bg-task-count":e.length,children:e.map((e,i)=>{let a=e.id||`bg_${i}`,o=e.status?.trim()||``,s=o?oO[o]??(/[\u3400-\u9fff]/.test(o)?o:`未知状态`):`未知状态`;return(0,L.jsx)(SO,{task:e,status:s,run:t?.get(e.id),execOutputs:n,onStop:r},a)})})}function SO({task:e,status:t,run:n,execOutputs:r,onStop:i}){let[a,o]=(0,u.useState)(!1),s=kD(e.id,r),c=n?BE(n):s?.text||e.output,l=c&&zE(c),d=n?n.outputTruncated||n.toolCalls?.some(e=>e.outputTruncated):s?.truncated??e.outputTruncated;return(0,L.jsxs)(`li`,{className:`bg-item${a?` bg-item-expanded`:``}`,"data-bg-task":e.id,"data-bg-task-status":e.status??`unknown`,title:`状态:${t}`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`bg-item-toggle`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-label":`展开后台任务详情`,children:[(0,L.jsx)(`span`,{className:`bg-title`,children:e.title?.trim()||e.id||`未命名任务`}),(0,L.jsxs)(`span`,{className:`bg-meta`,children:[e.agentId?.trim()&&(0,L.jsx)(`span`,{className:`bg-agent`,"data-bg-agent":e.agentId,children:e.agentId}),(0,L.jsx)(`span`,{className:`bg-status`,children:t})]})]}),i&&(0,L.jsx)(`button`,{type:`button`,className:`bg-stop-btn`,"data-bg-task-stop":e.id,title:`终止后台任务`,onClick:()=>i(e.id),children:`终止`}),a&&(0,L.jsx)(`pre`,{className:`bg-output`,"data-bg-output":e.id,children:[d?`日志仅保留最近一段。`:``,l].filter(Boolean).join(`
340
340
 
341
- `)||`运行中,暂无输出`})]})}var CO=(0,u.lazy)(()=>Wf(()=>import(`./GitDiffEditor-BdeOO3TB.js`),__vite__mapDeps([4,1,2,0,5,6,3,7])));function wO({todos:e,tasks:t,backgroundRuns:n,execOutputs:r,scheduledTasks:i,scheduledCatalog:a,scheduledAgents:o,collapsed:s,onToggle:c,workspaceId:l,gitWorkspaceId:u=l,gitRepositoryOnly:d=!1,workspaceLabel:f,workspaceName:p,gitWorkspaceName:m=p,cwd:h=``,conversationId:g,followedWorktreeId:_,connected:v,files:y,onOpenFile:b,onOpenChanged:x,onOpenGitDiff:S,activeGitDiffUrl:C,onFileReference:w,onFilesMoved:T,onSearchFolder:E,activeTab:D,onSelectTab:O,sendCommand:k,registerTerminalSink:A,terminalShell:j,notify:M,serverTimeZone:N,onOpenSession:ee,side:P,onArrange:te,pinned:ne=!0,sharedGit:re}){let F=QD,ie=P===`left`;return(0,L.jsx)(`div`,{className:`right-rail${P?` workbench-panel workbench-panel-`+P:``}${s?` right-rail-collapsed`:``}`,role:`complementary`,"aria-label":ie?`左侧栏`:`右侧栏`,"data-right-rail":ie?void 0:`1`,"data-right-rail-collapsed":s,"data-workbench-panel":P,hidden:P&&s?!0:void 0,children:s?!P&&(0,L.jsx)(`button`,{type:`button`,className:`right-rail-open`,"data-right-rail-open":`1`,title:`展开右侧栏`,"aria-label":`展开右侧栏`,onClick:c,children:`‹`}):(0,L.jsxs)(L.Fragment,{children:[P?(0,L.jsxs)(`div`,{className:`workbench-panel-heading`,children:[(0,L.jsx)(`h2`,{children:Jt[D]}),te&&(0,L.jsx)(sn,{view:D,side:P,pinned:ne,onArrange:te}),(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-right-rail-collapse":ie?void 0:`1`,title:ie?`收起左侧栏`:`收起右侧栏`,"aria-label":ie?`收起左侧栏`:`收起右侧栏`,onClick:c,children:(0,L.jsx)(rn,{name:`close`})})]}):(0,L.jsxs)(`div`,{className:`right-rail-head`,children:[(0,L.jsx)(`div`,{className:`right-tabs`,role:`tablist`,"aria-label":`右侧栏 tab`,"data-right-tab-count":F.length,children:F.map(e=>(0,L.jsx)(`button`,{type:`button`,role:`tab`,id:`right-tab-${e.id}`,className:`right-tab${e.id===D?` right-tab-active`:``}`,"data-right-tab":e.id,"aria-selected":e.id===D,"aria-controls":`right-panel-${e.id}`,title:e.name,"aria-label":e.name,onClick:()=>O(e.id),children:e.label},e.id))}),(0,L.jsx)(`button`,{type:`button`,className:`right-rail-collapse`,"data-right-rail-collapse":`1`,title:`收起右侧栏(聊天区会变宽)`,"aria-label":`收起右侧栏`,onClick:c,children:`›`})]}),QD.filter(e=>e.id===D).map(s=>(0,L.jsxs)(`div`,{className:`right-rail-body`,role:`tabpanel`,id:`right-panel-${s.id}`,"aria-label":P?Jt[s.id]:void 0,"aria-labelledby":P?void 0:`right-tab-${s.id}`,"data-right-panel":s.id,children:[s.id===`main`&&(0,L.jsxs)(L.Fragment,{children:[(e.length>0||t.length>0)&&(0,L.jsxs)(`p`,{className:`rail-legend`,"data-rail-legend":`1`,children:[(0,L.jsx)(`span`,{className:`rail-legend-label`,children:`左侧竖条=状态`}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-pending`,"aria-hidden":`true`}),`未开始`]}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-running`,"aria-hidden":`true`}),`运行中`]}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-done`,"aria-hidden":`true`}),`已完成`]})]}),(0,L.jsxs)(`div`,{className:`rail-task-sections`,children:[(0,L.jsx)(qC,{id:`todos`,title:`待办任务`,icon:`tasks`,count:(0,L.jsx)(`span`,{"data-todo-summary":`1`,children:vO(e)}),children:e.length>0?(0,L.jsx)(`ol`,{className:`todo-list`,"data-todo-count":e.length,children:e.map((e,t)=>(0,L.jsx)(yO,{todo:e,index:t},e.id??`todo_${t}`))}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-todo-empty":`1`,children:`暂无待办任务。开始多步骤任务后会自动显示。`})}),(0,L.jsx)(qC,{id:`background`,title:`后台任务`,icon:`activity`,count:(0,L.jsx)(`span`,{"data-bg-summary":`1`,children:t.length?`${t.filter(e=>e.status===`running`).length} 个运行中 / 共 ${t.length} 个`:`0 个`}),children:t.length>0?(0,L.jsx)(xO,{tasks:t,runs:n,execOutputs:r,onStop:e=>k({type:`backgroundTask.stop`,taskId:e})}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-bg-empty":`1`,children:`当前没有正在运行的后台任务。`})}),(0,L.jsx)(sw,{tasks:i,workspaceId:l,catalog:a,agents:o,sendCommand:k,notify:M,serverTimeZone:N})]})]}),s.id===`projects`&&(0,L.jsx)(Kw,{workspaceId:l,notify:M,onOpenSession:ee,onOpenFile:b,cwd:h},l),s.id===`tools`&&(0,L.jsx)(TO,{workspaceId:l},l),s.id===`files`&&(0,L.jsx)(nm,{workspaceId:l,workspaceName:p,cwd:h,files:y,onOpenFile:b,onOpenChanged:x,onReference:w,onMoved:T,onSearchFolder:E}),s.id===`git`&&(0,L.jsx)(li,{repositoryOnly:d,workspaceId:u??null,conversationId:g,cwd:u===l?h:``,followedWorktreeId:_,onOpenDiff:e=>S({...e,comparison:m?`${m} · ${e.comparison}`:e.comparison}),activeDiffUrl:C,onOpenConversation:ee,sharedGit:re},JSON.stringify([u,h,g,d])),s.id===`terminal`&&(0,L.jsx)(KC,{workspaceId:l,workspaceLabel:f,cwd:h,conversationId:g,connected:v,sendCommand:k,registerSink:A,terminalShell:j},JSON.stringify([l,g]))]},s.id))]})})}function TO({workspaceId:e}){let{tools:t,mountedTools:n,openToolId:r,shortcuts:i}=_E(),[a,o]=(0,u.useState)(),s=async e=>{o(void 0);let t=await bE(e);t&&o(`移除工具失败:${Bt(t)}`)},c=(e,t)=>t?`打开${e}(快捷键 ${WT(t)})`:`打开${e}`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`rail-section-head`,children:[(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`工具`}),(0,L.jsxs)(`span`,{className:`rail-section-count`,"data-tool-summary":`1`,children:[t.length+n.length,` 个`]})]}),t.length+n.length>0?(0,L.jsxs)(`ul`,{className:`tool-grid`,"data-tool-count":t.length+n.length,children:[t.map(e=>(0,L.jsxs)(`li`,{className:`tool-slot`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`tool-icon`,"data-tool-icon":e.id,"data-tool-kind":e.kind,"data-tool-state":r===e.id?`open`:`idle`,title:c(e.name,i[e.id]),"aria-label":c(e.name,i[e.id]),"aria-current":r===e.id?`true`:void 0,onClick:()=>vE.toggleTool(e.id),children:[(0,L.jsx)(ST,{className:`tool-icon-glyph`,glyph:e.glyph}),(0,L.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,L.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${WT(i[e.id])}`,children:GT(i[e.id])}),e.kind===`link`&&(0,L.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>vE.removeTool(e.id),children:`✕`})]},e.id)),n.map(e=>(0,L.jsxs)(`li`,{className:`tool-slot`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`tool-icon`,"data-mounted-tool-icon":e.id,"data-tool-state":r===e.id?`open`:`idle`,title:c(e.name,i[e.id]),"aria-label":c(e.name,i[e.id]),onClick:()=>vE.toggleTool(e.id),children:[(0,L.jsx)(ST,{className:`tool-icon-glyph`,glyph:wT(e)}),(0,L.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,L.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${WT(i[e.id])}`,children:GT(i[e.id])}),(0,L.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>void s(e.id),children:`✕`})]},e.id))]}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-tool-empty":`1`,children:`还没有工具。点下面的「工具设置」添加。`}),(0,L.jsx)(`button`,{type:`button`,className:`tools-settings-btn`,"data-tool-settings-trigger":`1`,title:`添加预置工具、网址工具、快捷键与说明`,"aria-label":`打开工具设置`,onClick:()=>vE.openSettings(),children:`⚙ 工具设置`}),a&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-error":`1`,children:a})]})}function EO({onClose:e}){let{tools:t,mountedTools:n,shortcuts:r}=_E(),[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(),[h,g]=(0,u.useState)(),[_,v]=(0,u.useState)(),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(),[C,w]=(0,u.useState)(),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(),[k,A]=(0,u.useState)(),j=(0,u.useRef)(null),M=(0,u.useRef)(null),[N,ee]=(0,u.useState)(),[P,te]=(0,u.useState)(),ne=(0,u.useRef)(null),[re,F]=(0,u.useState)(()=>{let e=cE();return!e||typeof window>`u`?e:uE(e,window.innerWidth,window.innerHeight)}),ie=async()=>{let e=await pd(`请为 Super Pi 开发一个全局右侧栏工具。不要启动独立 HTTP 服务器,也不要监听端口。
341
+ `)||`运行中,暂无输出`})]})}var CO=(0,u.lazy)(()=>Wf(()=>import(`./GitDiffEditor-CtSWZrJJ.js`),__vite__mapDeps([4,1,2,0,5,6,3,7])));function wO({todos:e,tasks:t,backgroundRuns:n,execOutputs:r,scheduledTasks:i,scheduledCatalog:a,scheduledAgents:o,collapsed:s,onToggle:c,workspaceId:l,gitWorkspaceId:u=l,gitRepositoryOnly:d=!1,workspaceLabel:f,workspaceName:p,gitWorkspaceName:m=p,cwd:h=``,conversationId:g,followedWorktreeId:_,connected:v,files:y,onOpenFile:b,onOpenChanged:x,onOpenGitDiff:S,activeGitDiffUrl:C,onFileReference:w,onFilesMoved:T,onSearchFolder:E,activeTab:D,onSelectTab:O,sendCommand:k,registerTerminalSink:A,terminalShell:j,notify:M,serverTimeZone:N,onOpenSession:ee,side:P,onArrange:te,pinned:ne=!0,sharedGit:re}){let F=QD,ie=P===`left`;return(0,L.jsx)(`div`,{className:`right-rail${P?` workbench-panel workbench-panel-`+P:``}${s?` right-rail-collapsed`:``}`,role:`complementary`,"aria-label":ie?`左侧栏`:`右侧栏`,"data-right-rail":ie?void 0:`1`,"data-right-rail-collapsed":s,"data-workbench-panel":P,hidden:P&&s?!0:void 0,children:s?!P&&(0,L.jsx)(`button`,{type:`button`,className:`right-rail-open`,"data-right-rail-open":`1`,title:`展开右侧栏`,"aria-label":`展开右侧栏`,onClick:c,children:`‹`}):(0,L.jsxs)(L.Fragment,{children:[P?(0,L.jsxs)(`div`,{className:`workbench-panel-heading`,children:[(0,L.jsx)(`h2`,{children:Jt[D]}),te&&(0,L.jsx)(sn,{view:D,side:P,pinned:ne,onArrange:te}),(0,L.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-right-rail-collapse":ie?void 0:`1`,title:ie?`收起左侧栏`:`收起右侧栏`,"aria-label":ie?`收起左侧栏`:`收起右侧栏`,onClick:c,children:(0,L.jsx)(rn,{name:`close`})})]}):(0,L.jsxs)(`div`,{className:`right-rail-head`,children:[(0,L.jsx)(`div`,{className:`right-tabs`,role:`tablist`,"aria-label":`右侧栏 tab`,"data-right-tab-count":F.length,children:F.map(e=>(0,L.jsx)(`button`,{type:`button`,role:`tab`,id:`right-tab-${e.id}`,className:`right-tab${e.id===D?` right-tab-active`:``}`,"data-right-tab":e.id,"aria-selected":e.id===D,"aria-controls":`right-panel-${e.id}`,title:e.name,"aria-label":e.name,onClick:()=>O(e.id),children:e.label},e.id))}),(0,L.jsx)(`button`,{type:`button`,className:`right-rail-collapse`,"data-right-rail-collapse":`1`,title:`收起右侧栏(聊天区会变宽)`,"aria-label":`收起右侧栏`,onClick:c,children:`›`})]}),QD.filter(e=>e.id===D).map(s=>(0,L.jsxs)(`div`,{className:`right-rail-body`,role:`tabpanel`,id:`right-panel-${s.id}`,"aria-label":P?Jt[s.id]:void 0,"aria-labelledby":P?void 0:`right-tab-${s.id}`,"data-right-panel":s.id,children:[s.id===`main`&&(0,L.jsxs)(L.Fragment,{children:[(e.length>0||t.length>0)&&(0,L.jsxs)(`p`,{className:`rail-legend`,"data-rail-legend":`1`,children:[(0,L.jsx)(`span`,{className:`rail-legend-label`,children:`左侧竖条=状态`}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-pending`,"aria-hidden":`true`}),`未开始`]}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-running`,"aria-hidden":`true`}),`运行中`]}),(0,L.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,L.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-done`,"aria-hidden":`true`}),`已完成`]})]}),(0,L.jsxs)(`div`,{className:`rail-task-sections`,children:[(0,L.jsx)(qC,{id:`todos`,title:`待办任务`,icon:`tasks`,count:(0,L.jsx)(`span`,{"data-todo-summary":`1`,children:vO(e)}),children:e.length>0?(0,L.jsx)(`ol`,{className:`todo-list`,"data-todo-count":e.length,children:e.map((e,t)=>(0,L.jsx)(yO,{todo:e,index:t},e.id??`todo_${t}`))}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-todo-empty":`1`,children:`暂无待办任务。开始多步骤任务后会自动显示。`})}),(0,L.jsx)(qC,{id:`background`,title:`后台任务`,icon:`activity`,count:(0,L.jsx)(`span`,{"data-bg-summary":`1`,children:t.length?`${t.filter(e=>e.status===`running`).length} 个运行中 / 共 ${t.length} 个`:`0 个`}),children:t.length>0?(0,L.jsx)(xO,{tasks:t,runs:n,execOutputs:r,onStop:e=>k({type:`backgroundTask.stop`,taskId:e})}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-bg-empty":`1`,children:`当前没有正在运行的后台任务。`})}),(0,L.jsx)(sw,{tasks:i,workspaceId:l,catalog:a,agents:o,sendCommand:k,notify:M,serverTimeZone:N})]})]}),s.id===`projects`&&(0,L.jsx)(Kw,{workspaceId:l,notify:M,onOpenSession:ee,onOpenFile:b,cwd:h},l),s.id===`tools`&&(0,L.jsx)(TO,{workspaceId:l},l),s.id===`files`&&(0,L.jsx)(nm,{workspaceId:l,workspaceName:p,cwd:h,files:y,onOpenFile:b,onOpenChanged:x,onReference:w,onMoved:T,onSearchFolder:E}),s.id===`git`&&(0,L.jsx)(li,{repositoryOnly:d,workspaceId:u??null,conversationId:g,cwd:u===l?h:``,followedWorktreeId:_,onOpenDiff:e=>S({...e,comparison:m?`${m} · ${e.comparison}`:e.comparison}),activeDiffUrl:C,onOpenConversation:ee,sharedGit:re},JSON.stringify([u,h,g,d])),s.id===`terminal`&&(0,L.jsx)(KC,{workspaceId:l,workspaceLabel:f,cwd:h,conversationId:g,connected:v,sendCommand:k,registerSink:A,terminalShell:j},JSON.stringify([l,g]))]},s.id))]})})}function TO({workspaceId:e}){let{tools:t,mountedTools:n,openToolId:r,shortcuts:i}=_E(),[a,o]=(0,u.useState)(),s=async e=>{o(void 0);let t=await bE(e);t&&o(`移除工具失败:${Bt(t)}`)},c=(e,t)=>t?`打开${e}(快捷键 ${WT(t)})`:`打开${e}`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`rail-section-head`,children:[(0,L.jsx)(`h2`,{className:`rail-section-title`,children:`工具`}),(0,L.jsxs)(`span`,{className:`rail-section-count`,"data-tool-summary":`1`,children:[t.length+n.length,` 个`]})]}),t.length+n.length>0?(0,L.jsxs)(`ul`,{className:`tool-grid`,"data-tool-count":t.length+n.length,children:[t.map(e=>(0,L.jsxs)(`li`,{className:`tool-slot`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`tool-icon`,"data-tool-icon":e.id,"data-tool-kind":e.kind,"data-tool-state":r===e.id?`open`:`idle`,title:c(e.name,i[e.id]),"aria-label":c(e.name,i[e.id]),"aria-current":r===e.id?`true`:void 0,onClick:()=>vE.toggleTool(e.id),children:[(0,L.jsx)(ST,{className:`tool-icon-glyph`,glyph:e.glyph}),(0,L.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,L.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${WT(i[e.id])}`,children:GT(i[e.id])}),e.kind===`link`&&(0,L.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>vE.removeTool(e.id),children:`✕`})]},e.id)),n.map(e=>(0,L.jsxs)(`li`,{className:`tool-slot`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`tool-icon`,"data-mounted-tool-icon":e.id,"data-tool-state":r===e.id?`open`:`idle`,title:c(e.name,i[e.id]),"aria-label":c(e.name,i[e.id]),onClick:()=>vE.toggleTool(e.id),children:[(0,L.jsx)(ST,{className:`tool-icon-glyph`,glyph:wT(e)}),(0,L.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,L.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${WT(i[e.id])}`,children:GT(i[e.id])}),(0,L.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>void s(e.id),children:`✕`})]},e.id))]}):(0,L.jsx)(`p`,{className:`rail-empty`,"data-tool-empty":`1`,children:`还没有工具。点下面的「工具设置」添加。`}),(0,L.jsx)(`button`,{type:`button`,className:`tools-settings-btn`,"data-tool-settings-trigger":`1`,title:`添加预置工具、网址工具、快捷键与说明`,"aria-label":`打开工具设置`,onClick:()=>vE.openSettings(),children:`⚙ 工具设置`}),a&&(0,L.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-error":`1`,children:a})]})}function EO({onClose:e}){let{tools:t,mountedTools:n,shortcuts:r}=_E(),[i,a]=(0,u.useState)(``),[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(),[h,g]=(0,u.useState)(),[_,v]=(0,u.useState)(),[y,b]=(0,u.useState)(``),[x,S]=(0,u.useState)(),[C,w]=(0,u.useState)(),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(),[k,A]=(0,u.useState)(),j=(0,u.useRef)(null),M=(0,u.useRef)(null),[N,ee]=(0,u.useState)(),[P,te]=(0,u.useState)(),ne=(0,u.useRef)(null),[re,F]=(0,u.useState)(()=>{let e=cE();return!e||typeof window>`u`?e:uE(e,window.innerWidth,window.innerHeight)}),ie=async()=>{let e=await pd(`请为 Super Pi 开发一个全局右侧栏工具。不要启动独立 HTTP 服务器,也不要监听端口。
342
342
 
343
343
  工具不属于当前 workspace;通过内置 tool_register 一次性提交完整文件(index.html、JS/CSS,必要时 .py),并用 glyph 提供一个易辨识的短图标(1 至 4 个字符,例如 {}、∑、◷),Super Pi 会保存为全局工具并自动出现在每个 workspace 的工具 Tab。
344
344