@evandu/super-pi 0.1.278 → 0.1.280
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/desktop/main.cjs +5 -1
- package/dist/.super-pi-check-inputs.json +2 -2
- package/dist/client/.super-pi-client-sources.json +4 -4
- package/dist/client/assets/{CodeMirrorEditor-CmfIAppR.js → CodeMirrorEditor-D-UuYizz.js} +1 -1
- package/dist/client/assets/{GitDiffEditor-BZ2Kff1j.js → GitDiffEditor-Bt1n2la-.js} +1 -1
- package/dist/client/assets/{index-sXiJhOAC.js → index-rWE1xu-t.js} +5 -5
- package/dist/client/index.html +1 -1
- package/dist/server/application/rsi-service.js +17 -4
- package/package.json +1 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-J6XWqRpB.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-D978o95T.js","assets/dist-B3-a6uF0.js","assets/dist-Cus6_oaF.js","assets/dist-Dc1MBGAG.js","assets/dist-BXAOrsjq.js","assets/dist-Cx00EZKR.js","assets/dist-moiMRpw_.js","assets/dist-Dds-qLxY.js","assets/dist-AW5lyI3I.js","assets/dist-BGxkyh6e.js","assets/dist-CKF2Jksy.js","assets/dist-BV64A9Ji.js","assets/dist-Dvb0SqcK.js","assets/dist-D71y2EI1.js","assets/dist-DeD9copn.js","assets/dist-QzbOCAU6.js","assets/dist-DuvGReu-.js","assets/dist-BRVQKlcp.js","assets/dist-BJxfd7yb.js","assets/CodeMirrorEditor-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-J6XWqRpB.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-D978o95T.js","assets/dist-B3-a6uF0.js","assets/dist-Cus6_oaF.js","assets/dist-Dc1MBGAG.js","assets/dist-BXAOrsjq.js","assets/dist-Cx00EZKR.js","assets/dist-moiMRpw_.js","assets/dist-Dds-qLxY.js","assets/dist-AW5lyI3I.js","assets/dist-BGxkyh6e.js","assets/dist-CKF2Jksy.js","assets/dist-BV64A9Ji.js","assets/dist-Dvb0SqcK.js","assets/dist-D71y2EI1.js","assets/dist-DeD9copn.js","assets/dist-QzbOCAU6.js","assets/dist-DuvGReu-.js","assets/dist-BRVQKlcp.js","assets/dist-BJxfd7yb.js","assets/CodeMirrorEditor-D-UuYizz.js","assets/GitDiffEditor-Bt1n2la-.js","assets/GitDiffEditor-DP0DQ9Y5.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function ee(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function M(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 te(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,te(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ee(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),te(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+ee(a,u),c+=te(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+ee(a,u++),c+=te(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return te(M(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 N(e,t,n){if(e==null)return e;var r=[],i=0;return te(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ne(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 re=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 ie(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,re)}catch(e){re(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ae(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 ie(ae.bind(null,e))}var oe={map:N,forEach:function(e,t,n){N(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return N(e,function(){t++}),t},toArray:function(e){return N(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=oe,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=ae,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:ne}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=ie,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`),ee=Symbol.for(`react.strict_mode`),M=Symbol.for(`react.profiler`),te=Symbol.for(`react.consumer`),N=Symbol.for(`react.context`),ne=Symbol.for(`react.forward_ref`),re=Symbol.for(`react.suspense`),ie=Symbol.for(`react.suspense_list`),ae=Symbol.for(`react.memo`),oe=Symbol.for(`react.lazy`),se=Symbol.for(`react.activity`),ce=Symbol.for(`react.legacy_hidden`),le=Symbol.for(`react.memo_cache_sentinel`),ue=Symbol.for(`react.view_transition`),de=Symbol.for(`react.recoverable`),fe=Symbol.iterator;function pe(e){return typeof e!=`object`||!e?null:(e=fe&&e[fe]||e[`@@iterator`],typeof e==`function`?e:null)}var me=Symbol.for(`react.client.reference`);function he(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===me?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case M:return`Profiler`;case ee:return`StrictMode`;case re:return`Suspense`;case ie:return`SuspenseList`;case se:return`Activity`;case ue:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case N:return e.displayName||`Context`;case te:return(e._context.displayName||`Context`)+`.Consumer`;case ne:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ae:return t=e.displayName||null,t===null?he(e.type)||`Memo`:t;case oe:t=e._payload,e=e._init;try{return he(e(t))}catch{}}return null}var ge=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_e=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ve={pending:!1,data:null,method:null,action:null},ye=[],be=-1;function xe(e){return{current:e}}function Se(e){0>be||(e.current=ye[be],ye[be]=null,be--)}function Ce(e,t){be++,ye[be]=e.current,e.current=t}var we=xe(null),Te=xe(null),Ee=xe(null),De=xe(null);function Oe(e,t){switch(Ce(Ee,t),Ce(Te,e),Ce(we,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}}Se(we),Ce(we,e)}function ke(){Se(we),Se(Te),Se(Ee)}function Ae(e){var t=e.memoizedState;t!==null&&(lh._currentValue=t.memoizedState,Ce(De,e)),t=we.current;var n=pp(t,e.type);t!==n&&(Ce(Te,e),Ce(we,n))}function je(e){Te.current===e&&(Se(we),Se(Te)),De.current===e&&(Se(De),lh._currentValue=ve)}var Me,Ne;function Pe(e){if(Me===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Me=t&&t[1]||``,Ne=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Me+e+Ne}var Fe=!1;function Ie(e,t){if(!e||Fe)return``;Fe=!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(`
|
|
@@ -7,7 +7,7 @@ import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";(function(){let e=document.
|
|
|
7
7
|
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Fe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Pe(n):``}function Le(e,t){switch(e.tag){case 26:case 27:case 5:return Pe(e.type);case 16:return Pe(`Lazy`);case 13:return e.child!==t&&t!==null?Pe(`Suspense Fallback`):Pe(`Suspense`);case 19:return Pe(`SuspenseList`);case 0:case 15:return Ie(e.type,!1);case 11:return Ie(e.type.render,!1);case 1:return Ie(e.type,!0);case 31:return Pe(`Activity`);case 30:return Pe(`ViewTransition`);default:return``}}function Re(e){try{var t=``,n=null;do t+=Le(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
8
|
Error generating stack: `+e.message+`
|
|
9
9
|
`+e.stack}}var ze=Object.prototype.hasOwnProperty,Be=t.unstable_scheduleCallback,F=t.unstable_cancelCallback,Ve=t.unstable_shouldYield,He=t.unstable_requestPaint,Ue=t.unstable_now,We=t.unstable_getCurrentPriorityLevel,Ge=t.unstable_ImmediatePriority,Ke=t.unstable_UserBlockingPriority,qe=t.unstable_NormalPriority,Je=t.unstable_LowPriority,Ye=t.unstable_IdlePriority,Xe=t.log,Ze=t.unstable_setDisableYieldValue,I=null,Qe=null;function $e(e){if(typeof Xe==`function`&&Ze(e),Qe&&typeof Qe.setStrictMode==`function`)try{Qe.setStrictMode(I,e)}catch{}}var et=Math.clz32?Math.clz32:rt,tt=Math.log,nt=Math.LN2;function rt(e){return e>>>=0,e===0?32:31-(tt(e)/nt|0)|0}var it=256,at=262144,ot=4194304;function st(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ct(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=st(n))):i=st(o):i=st(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=st(n))):i=st(o)):i=st(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function lt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ut(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-et(n),i=1<<r;t|=e[r],n&=~i}return t}function dt(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ft(){var e=ot;return ot<<=1,!(ot&62914560)&&(ot=4194304),e}function pt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function mt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ht(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-et(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&>(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function gt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-et(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function _t(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-et(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function vt(e,t){var n=t&-t;return n=n&42?1:yt(n),(n&(e.suspendedLanes|t))===0?n:0}function yt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function bt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function xt(){var e=_e.p;return e===0?(e=window.event,e===void 0?32:Th(e.type)):e}function St(e,t){var n=_e.p;try{return _e.p=e,t()}finally{_e.p=n}}var Ct=Math.random().toString(36).slice(2),wt=`__reactFiber$`+Ct,Tt=`__reactProps$`+Ct,Et=`__reactContainer$`+Ct,Dt=`__reactEvents$`+Ct,Ot=`__reactListeners$`+Ct,kt=`__reactHandles$`+Ct,At=`__reactResources$`+Ct,jt=`__reactMarker$`+Ct,Mt=`__reactLoad$`+Ct;function Nt(e){delete e[wt],delete e[Tt],delete e[Ot],delete e[kt]}function Pt(e){var t;if(t=e[wt])return t;for(var n=e.parentNode;n;){if(t=n[Et]||n[wt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=mm(e);e!==null;){if(n=e[wt])return n;e=mm(e)}return t}e=n,n=e.parentNode}return null}function Ft(e){if(e=e[wt]||e[Et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function It(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function Lt(e){var t=e[At];return t||=e[At]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Rt(e){e[jt]=!0}function zt(e){e[Mt]=void 0}var Bt=new Set,Vt={};function Ht(e,t){Ut(e,t),Ut(e+`Capture`,t)}function Ut(e,t){for(Vt[e]=t,e=0;e<t.length;e++)Bt.add(t[e])}var Wt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Gt={},Kt={};function qt(e){return ze.call(Kt,e)?!0:ze.call(Gt,e)?!1:Wt.test(e)?Kt[e]=!0:(Gt[e]=!0,!1)}var Jt=!1;function Yt(){var e=Jt;return Jt=!1,e}function Xt(e,t,n){if(qt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Zt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function Qt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function $t(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function en(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function tn(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function nn(e){if(!e._valueTracker){var t=en(e)?`checked`:`value`;e._valueTracker=tn(e,t,``+e[t])}}function rn(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=en(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var an=/[\n"\\]/g;function on(e){return e.replace(an,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function sn(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+$t(t)):e.value!==``+$t(t)&&(e.value=``+$t(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):ln(e,$t(n)):o===`number`&&e.value==t?ln(e,$t(e.value)):ln(e,$t(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+$t(s):e.removeAttribute(`name`)}function cn(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){nn(e);return}n=n==null?``:``+$t(n),t=t==null?n:``+$t(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),nn(e)}function ln(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function un(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+$t(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function dn(e,t,n){t!=null&&(t=``+$t(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+$t(n)}function fn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(o(92));if(ge(r)){if(1<r.length)throw Error(o(93));r=r[0]}n=r}n??=``,t=n}n=$t(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),nn(e)}function pn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var mn=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function hn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||mn.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function gn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(o(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,Jt=!0);for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&(hn(e,i,r),Jt=!0)}else for(var a in t)t.hasOwnProperty(a)&&hn(e,a,t[a])}function _n(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var vn=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),yn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function bn(e){return yn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function xn(){}var Sn=null;function Cn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var wn=null,Tn=null;function En(e){var t=Ft(e);if(t&&(e=t.stateNode)){var n=e[Tt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(sn(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+on(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[Tt]||null;if(!i)throw Error(o(90));sn(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&rn(r)}break a;case`textarea`:dn(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&un(e,!!n.multiple,t,!1)}}}var Dn=!1;function On(e,t,n){if(Dn)return e(t,n);Dn=!0;try{return e(t)}finally{if(Dn=!1,(wn!==null||Tn!==null)&&(Rd(),wn&&(t=wn,e=Tn,Tn=wn=null,En(t),e)))for(t=0;t<e.length;t++)En(e[t])}}function kn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[Tt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(o(231,t,typeof n));return n}var An=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,jn=!1;if(An)try{var Mn={};Object.defineProperty(Mn,"passive",{get:function(){jn=!0}}),window.addEventListener(`test`,Mn,Mn),window.removeEventListener(`test`,Mn,Mn)}catch{jn=!1}var Nn=null,Pn=null,Fn=null;function In(){if(Fn)return Fn;var e,t=Pn,n=t.length,r,i=`value`in Nn?Nn.value:Nn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Fn=i.slice(e,1<r?1-r:void 0)}function Ln(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Rn(){return!0}function zn(){return!1}function Bn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Rn:zn,this.isPropagationStopped=zn,this}return D(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Rn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Rn)},persist:function(){},isPersistent:Rn}),t}var Vn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Hn=Bn(Vn),Un=D({},Vn,{view:0,detail:0}),Wn=Bn(Un),Gn,Kn,qn,Jn=D({},Un,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ar,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==qn&&(qn&&e.type===`mousemove`?(Gn=e.screenX-qn.screenX,Kn=e.screenY-qn.screenY):Kn=Gn=0,qn=e),Gn)},movementY:function(e){return`movementY`in e?e.movementY:Kn}}),Yn=Bn(Jn),Xn=Bn(D({},Jn,{dataTransfer:0})),Zn=Bn(D({},Un,{relatedTarget:0})),Qn=Bn(D({},Vn,{animationName:0,elapsedTime:0,pseudoElement:0})),$n=Bn(D({},Vn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),er=Bn(D({},Vn,{data:0})),tr={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},nr={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},rr={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function ir(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=rr[e])?!!t[e]:!1}function ar(){return ir}var or=Bn(D({},Un,{key:function(e){if(e.key){var t=tr[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Ln(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?nr[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ar,charCode:function(e){return e.type===`keypress`?Ln(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Ln(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),sr=Bn(D({},Jn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),cr=Bn(D({},Vn,{submitter:0})),lr=Bn(D({},Un,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ar})),ur=Bn(D({},Vn,{propertyName:0,elapsedTime:0,pseudoElement:0})),dr=Bn(D({},Jn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),fr=Bn(D({},Vn,{newState:0,oldState:0,source:0})),pr=[9,13,27,32],mr=An&&`CompositionEvent`in window,hr=null;An&&`documentMode`in document&&(hr=document.documentMode);var gr=An&&`TextEvent`in window&&!hr,_r=An&&(!mr||hr&&8<hr&&11>=hr),vr=` `,yr=!1;function br(e,t){switch(e){case`keyup`:return pr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function xr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Sr=!1;function Cr(e,t){switch(e){case`compositionend`:return xr(t);case`keypress`:return t.which===32?(yr=!0,vr):null;case`textInput`:return e=t.data,e===vr&&yr?null:e;default:return null}}function wr(e,t){if(Sr)return e===`compositionend`||!mr&&br(e,t)?(e=In(),Fn=Pn=Nn=null,Sr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return _r&&t.locale!==`ko`?null:t.data;default:return null}}var Tr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Er(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Tr[e.type]:t===`textarea`}function Dr(e,t,n,r){wn?Tn?Tn.push(r):Tn=[r]:wn=r,t=Yf(t,`onChange`),0<t.length&&(n=new Hn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Or=null,kr=null;function Ar(e){Vf(e,0)}function jr(e){if(rn(It(e)))return e}function Mr(e,t){if(e===`change`)return t}var Nr=!1;if(An){var Pr;if(An){var Fr=`oninput`in document;if(!Fr){var Ir=document.createElement(`div`);Ir.setAttribute(`oninput`,`return;`),Fr=typeof Ir.oninput==`function`}Pr=Fr}else Pr=!1;Nr=Pr&&(!document.documentMode||9<document.documentMode)}function Lr(){Or&&(Or.detachEvent(`onpropertychange`,Rr),kr=Or=null)}function Rr(e){if(e.propertyName===`value`&&jr(kr)){var t=[];Dr(t,kr,e,Cn(e)),On(Ar,t)}}function zr(e,t,n){e===`focusin`?(Lr(),Or=t,kr=n,Or.attachEvent(`onpropertychange`,Rr)):e===`focusout`&&Lr()}function Br(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return jr(kr)}function Vr(e,t){if(e===`click`)return jr(t)}function Hr(e,t){if(e===`input`||e===`change`)return jr(t)}function Ur(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Wr=typeof Object.is==`function`?Object.is:Ur;function Gr(e,t){if(Wr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!ze.call(t,i)||!Wr(e[i],t[i]))return!1}return!0}function Kr(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function qr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Jr(e,t){var n=qr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=qr(n)}}function Yr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Yr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Kr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Kr(e.document)}return t}function Zr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Qr=An&&`documentMode`in document&&11>=document.documentMode,$r=null,ei=null,ti=null,ni=!1;function ri(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ni||$r==null||$r!==Kr(r)||(r=$r,`selectionStart`in r&&Zr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ti&&Gr(ti,r)||(ti=r,r=Yf(ei,`onSelect`),0<r.length&&(t=new Hn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=$r)))}function ii(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var ai={animationend:ii(`Animation`,`AnimationEnd`),animationiteration:ii(`Animation`,`AnimationIteration`),animationstart:ii(`Animation`,`AnimationStart`),transitionrun:ii(`Transition`,`TransitionRun`),transitionstart:ii(`Transition`,`TransitionStart`),transitioncancel:ii(`Transition`,`TransitionCancel`),transitionend:ii(`Transition`,`TransitionEnd`)},oi={},si={};An&&(si=document.createElement(`div`).style,`AnimationEvent`in window||(delete ai.animationend.animation,delete ai.animationiteration.animation,delete ai.animationstart.animation),`TransitionEvent`in window||delete ai.transitionend.transition);function ci(e){if(oi[e])return oi[e];if(!ai[e])return e;var t=ai[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in si)return oi[e]=t[n];return e}var li=ci(`animationend`),ui=ci(`animationiteration`),di=ci(`animationstart`),fi=ci(`transitionrun`),L=ci(`transitionstart`),pi=ci(`transitioncancel`),mi=ci(`transitionend`),hi=new Map,gi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);gi.push(`scrollEnd`);function _i(e,t){hi.set(e,t),Ht(t,[e])}var vi=0;function yi(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=yd.identifierPrefix;var n=vi++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function bi(e){if(e==null||typeof e==`string`)return e;var t=null,n=Dd;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function xi(e,t){return e=bi(e),t=bi(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var Si=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)},Ci=[],wi=0,Ti=0;function Ei(){for(var e=wi,t=Ti=wi=0;t<e;){var n=Ci[t];Ci[t++]=null;var r=Ci[t];Ci[t++]=null;var i=Ci[t];Ci[t++]=null;var a=Ci[t];if(Ci[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Ai(n,i,a)}}function Di(e,t,n,r){Ci[wi++]=e,Ci[wi++]=t,Ci[wi++]=n,Ci[wi++]=r,Ti|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Oi(e,t,n,r){return Di(e,t,n,r),ji(e)}function ki(e,t){return Di(e,null,null,t),ji(e)}function Ai(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-et(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ji(e){if(50<Od)throw Od=0,kd=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Mi={};function Ni(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pi(e,t,n,r){return new Ni(e,t,n,r)}function Fi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ii(e,t){var n=e.alternate;return n===null?(n=Pi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Li(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ri(e,t,n,r,i,a){var s=0;if(r=e,typeof r==`function`)Fi(r)&&(s=1);else if(typeof r==`string`)s=Ym(e,n,we.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case se:return e=Pi(31,n,t,i),e.elementType=se,e.lanes=a,e;case j:return zi(n.children,i,a,t);case ee:s=8,i|=24;break;case M:return e=Pi(12,n,t,i|2),e.elementType=M,e.lanes=a,e;case re:return e=Pi(13,n,t,i),e.elementType=re,e.lanes=a,e;case ie:return e=Pi(19,n,t,i),e.elementType=ie,e.lanes=a,e;case ce:case ue:return e=i|32,e=Pi(30,n,t,e),e.elementType=ue,e.lanes=a,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case N:s=10;break a;case te:s=9;break a;case ne:s=11;break a;case ae:s=14;break a;case oe:s=16,r=null;break a}s=29,n=Error(o(130,e===null?`null`:typeof e,``)),r=null}return t=Pi(s,n,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function zi(e,t,n,r){return e=Pi(7,e,r,t),e.lanes=n,e}function Bi(e,t,n){return e=Pi(6,e,null,t),e.lanes=n,e}function Vi(e){var t=Pi(18,null,null,0);return t.stateNode=e,t}function Hi(e,t,n){return t=Pi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Ui=new WeakMap;function Wi(e,t){if(typeof e==`object`&&e){var n=Ui.get(e);return n===void 0?(t={value:e,source:t,stack:Re(t)},Ui.set(e,t),t):n}return{value:e,source:t,stack:Re(t)}}var Gi=[],Ki=0,qi=null,Ji=0,Yi=[],Xi=0,Zi=null,Qi=1,$i=``;function ea(e,t){Gi[Ki++]=Ji,Gi[Ki++]=qi,qi=e,Ji=t}function ta(e,t,n){Yi[Xi++]=Qi,Yi[Xi++]=$i,Yi[Xi++]=Zi,Zi=e;var r=Qi;e=$i;var i=32-et(r)-1;r&=~(1<<i),n+=1;var a=32-et(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Qi=1<<32-et(t)+i|n<<i|r,$i=a+e}else Qi=1<<a|n<<i|r,$i=e}function na(e){e.return!==null&&(ea(e,1),ta(e,1,0))}function ra(e){for(;e===qi;)qi=Gi[--Ki],Gi[Ki]=null,Ji=Gi[--Ki],Gi[Ki]=null;for(;e===Zi;)Zi=Yi[--Xi],Yi[Xi]=null,$i=Yi[--Xi],Yi[Xi]=null,Qi=Yi[--Xi],Yi[Xi]=null}function ia(e,t){Yi[Xi++]=Qi,Yi[Xi++]=$i,Yi[Xi++]=Zi,Qi=t.id,$i=t.overflow,Zi=e}var aa=null,R=null,oa=!1,sa=null,ca=!1,la=Error(o(519));function ua(e){throw ga(Wi(Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),la}function da(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[wt]=e,t[Tt]=r,n){case`dialog`:Hf(`cancel`,t),Hf(`close`,t);break;case`iframe`:case`object`:case`embed`:Hf(`load`,t);break;case`video`:case`audio`:for(n=0;n<zf.length;n++)Hf(zf[n],t);break;case`source`:Hf(`error`,t);break;case`img`:case`image`:case`link`:Hf(`error`,t),Hf(`load`,t);break;case`details`:Hf(`toggle`,t);break;case`input`:Hf(`invalid`,t),cn(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Hf(`invalid`,t);break;case`textarea`:Hf(`invalid`,t),fn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||tp(t.textContent,n)?(r.popover!=null&&(Hf(`beforetoggle`,t),Hf(`toggle`,t)),r.onScroll!=null&&Hf(`scroll`,t),r.onScrollEnd!=null&&Hf(`scrollend`,t),r.onClick!=null&&(t.onclick=xn),t=!0):t=!1,t||ua(e,!0)}function fa(e){for(aa=e.return;aa;)switch(aa.tag){case 5:case 31:case 13:ca=!1;return;case 27:case 3:ca=!0;return;default:aa=aa.return}}function pa(e){if(e!==aa)return!1;if(!oa)return fa(e),oa=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||hp(e.type,e.memoizedProps)),n=!n),n&&R&&ua(e),fa(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));R=pm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));R=pm(e)}else t===27?(t=R,wp(e.type)?(e=fm,fm=null,R=e):R=t):R=aa?dm(e.stateNode.nextSibling):null;return!0}function ma(){R=aa=null,oa=!1}function ha(){var e=sa;return e!==null&&(dd===null?dd=e:dd.push.apply(dd,e),sa=null),e}function ga(e){sa===null?sa=[e]:sa.push(e)}var _a=xe(null),va=null,ya=null;function ba(e,t,n){Ce(_a,t._currentValue),t._currentValue=n}function xa(e){e._currentValue=_a.current,Se(_a)}function Sa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ca(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){var s=i.child;a=a.firstContext;a:for(;a!==null;){var c=a;a=i;for(var l=0;l<t.length;l++)if(c.context===t[l]){a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),Sa(a.return,n,e),r||(s=null);break a}a=c.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(o(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),Sa(s,n,e),s=null}else i.tag===13&&i.memoizedState!==null&&i.memoizedState.dehydrated===null?(i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),Sa(i.return,n,e),s=i.child,s=s===null?null:s.sibling):s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function wa(e,t,n,r){e=null;for(var i=t,a=!1;i!==null;){if(!a){if(i.flags&524288)a=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(o(387));if(s=s.memoizedProps,s!==null){var c=i.type;Wr(i.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(i===De.current){if(s=i.alternate,s===null)throw Error(o(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e===null?e=[lh]:e.push(lh))}i=i.return}return e!==null&&Ca(t,e,n,r),t.flags|=262144,e!==null}function Ta(e){for(e=e.firstContext;e!==null;){if(!Wr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ea(e){va=e,ya=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Da(e){return ka(va,e)}function Oa(e,t){return va===null&&Ea(e),ka(e,t)}function ka(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ya===null){if(e===null)throw Error(o(308));ya=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ya=ya.next=t;return n}var Aa=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ja=t.unstable_scheduleCallback,Ma=t.unstable_NormalPriority,Na={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Pa(){return{controller:new Aa,data:new Map,refCount:0}}function Fa(e){e.refCount--,e.refCount===0&&ja(Ma,function(){e.controller.abort()})}function Ia(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var La=null;function Ra(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var za=null,Ba=0,z=0,Va=null;function Ha(e,t){if(za===null){var n=za=[];Ba=0,z=Pf(),Va={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Ba++,t.then(Ua,Ua),t}function Ua(){if(--Ba===0&&(La=null,za!==null)){Va!==null&&(Va.status=`fulfilled`);var e=za;za=null,z=0,Va=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Wa(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Ga=P.S;P.S=function(e,t){if(md=Ue(),typeof t==`object`&&t&&typeof t.then==`function`&&Ha(e,t),La!==null)for(var n=bf;n!==null;)Ia(n,La),n=n.next;if(n=e.types,n!==null){for(var r=bf;r!==null;)Ia(r,n),r=r.next;if(z!==0){r=La,r===null&&(r=La=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Ga!==null&&Ga(e,t)};var Ka=xe(null);function qa(){var e=Ka.current;return e===null?Yu.pooledCache:e}function Ja(e,t){t===null?Ce(Ka,Ka.current):Ce(Ka,t.pool)}function Ya(){var e=qa();return e===null?null:{parent:Na._currentValue,pool:e}}var Xa=Error(o(460)),Za=Error(o(474)),Qa=Error(o(542)),$a={then:function(){}};function eo(e){return e=e.status,e===`fulfilled`||e===`rejected`}function to(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(xn,xn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,B(e),e===void 0&&!(`reason`in t)?Error(o(600)):e;default:if(typeof t.status==`string`)t.then(xn,xn);else{if(e=Yu,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,B(e),e}throw ro=t,Xa}}function no(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ro=e,Xa):e}}var ro=null;function io(){if(ro===null)throw Error(o(459));var e=ro;return ro=null,e}function B(e){if(e===Xa||e===Qa)throw Error(o(483))}var ao=null,oo=0;function so(e){var t=oo;return oo+=1,ao===null&&(ao=[]),to(ao,e,t)}function co(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function lo(e,t){throw t.$$typeof===O?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function uo(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function i(e,t){return e=Ii(e,t),e.index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Bi(n,e.mode,r),t.return=e,t):(t=i(t,n),t.return=e,t)}function l(e,t,n,r){var a=n.type;return a===j?(e=d(e,t,n.props.children,r,n.key),co(e,n),e):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===oe&&no(a)===t.type)?(t=i(t,n.props),co(t,n),t.return=e,t):(t=Ri(n.type,n.key,n.props,null,e.mode,r),co(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Hi(n,e.mode,r),t.return=e,t):(t=i(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,a){return t===null||t.tag!==7?(t=zi(n,e.mode,r,a),t.return=e,t):(t=i(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Bi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case k:return n=Ri(t.type,t.key,t.props,null,e.mode,n),co(n,t),n.return=e,n;case A:return t=Hi(t,e.mode,n),t.return=e,t;case oe:return t=no(t),f(e,t,n)}if(ge(t)||pe(t))return t=zi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,so(t),n);if(t.$$typeof===N)return f(e,Oa(e,t),n);lo(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case k:return n.key===i?l(e,t,n,r):null;case A:return n.key===i?u(e,t,n,r):null;case oe:return n=no(n),p(e,t,n,r)}if(ge(n)||pe(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,so(n),r);if(n.$$typeof===N)return p(e,t,Oa(e,n),r);lo(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case k:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case A:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case oe:return r=no(r),m(e,t,n,r,i)}if(ge(r)||pe(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,so(r),i);if(r.$$typeof===N)return m(e,t,n,Oa(t,r),i);lo(t,r)}return null}function h(i,o,s,c){for(var l=null,u=null,d=o,h=o=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),oa&&ea(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(o=a(d,o,h),u===null?l=d:u.sibling=d,u=d);return oa&&ea(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),o=a(g,o,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),oa&&ea(i,h),l}function g(i,s,c,l){if(c==null)throw Error(o(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=a(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),oa&&ea(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return oa&&ea(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),oa&&ea(i,g),u}function _(e,r,a,c){if(typeof a==`object`&&a&&a.type===j&&a.key===null&&a.props.ref===void 0&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case k:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===j){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),co(c,a),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===oe&&no(l)===r.type){n(e,r.sibling),c=i(r,a.props),co(c,a),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}a.type===j?(c=zi(a.props.children,e.mode,c,a.key),co(c,a),c.return=e,e=c):(c=Ri(a.type,a.key,a.props,null,e.mode,c),co(c,a),c.return=e,e=c)}return s(e);case A:a:{for(l=a.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Hi(a,e.mode,c),c.return=e,e=c}return s(e);case oe:return a=no(a),_(e,r,a,c)}if(ge(a))return h(e,r,a,c);if(pe(a)){if(l=pe(a),typeof l!=`function`)throw Error(o(150));return a=l.call(a),g(e,r,a,c)}if(typeof a.then==`function`)return _(e,r,so(a),c);if(a.$$typeof===N)return _(e,r,Oa(e,a),c);lo(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=Bi(a,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{oo=0;var i=_(e,t,n,r);return ao=null,i}catch(t){if(t===Xa||t===Qa)throw t;var a=Pi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var fo=uo(!0),po=uo(!1),mo=!1;function ho(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function go(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function _o(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function vo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ju&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ji(e),Ai(e,null,n),t}return Di(e,r,t,n),ji(e)}function yo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}function bo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var xo=!1;function So(){if(xo){var e=Va;if(e!==null)throw e}}function Co(e,t,n,r){xo=!1;var i=e.updateQueue;mo=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Zu&f)===f:(r&f)===f){f!==0&&f===z&&(xo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=D({},d,f);break a;case 2:mo=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),ad|=o,e.lanes=o,e.memoizedState=d}}function wo(e,t){if(typeof e!=`function`)throw Error(o(191,e));e.call(t)}function To(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)wo(n[e],t)}var Eo=xe(null),Do=xe(0);function Oo(e,t){e=rd,Ce(Do,e),Ce(Eo,t),rd=e|t.baseLanes}function ko(){Ce(Do,rd),Ce(Eo,Eo.current)}function Ao(){rd=Do.current,Se(Eo),Se(Do)}var V=xe(null),H=null;function U(e){var t=e.alternate;Ce(No,No.current&1),Ce(V,e),H===null&&(t===null||Eo.current!==null||t.memoizedState!==null)&&(H=e)}function W(e){Ce(No,No.current),Ce(V,e),H===null&&(H=e)}function G(e){e.tag===22?(Ce(No,No.current),Ce(V,e),H===null&&(H=e)):jo()}function jo(){Ce(No,No.current),Ce(V,V.current)}function Mo(e){Se(V),H===e&&(H=null),Se(No)}var No=xe(0);function Po(e,t){Ce(V,V.current),Ce(No,t)}function Fo(e){Se(No),Se(V),H===e&&(H=null)}function Io(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||cm(n)||lm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Lo=0,Ro=null,K=null,zo=null,q=!1,Bo=!1,Vo=!1,Ho=0,Uo=0,Wo=null,Go=0;function Ko(){throw Error(o(321))}function qo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Wr(e[n],t[n]))return!1;return!0}function Jo(e,t,n,r,i,a){return Lo=a,Ro=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,P.H=e===null||e.memoizedState===null?lc:uc,Vo=!1,a=n(r,i),Vo=!1,Bo&&(a=Xo(t,n,r,i)),Yo(e),a}function Yo(e){P.H=cc;var t=K!==null&&K.next!==null;if(Lo=0,zo=K=Ro=null,q=!1,Uo=0,Wo=null,t)throw Error(o(300));e===null||Ec||(e=e.dependencies,e!==null&&Ta(e)&&(Ec=!0))}function Xo(e,t,n,r){Ro=e;var i=0;do{if(Bo&&(Wo=null),Uo=0,Bo=!1,25<=i)throw Error(o(301));if(i+=1,zo=K=null,e.updateQueue!=null){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,a.memoCache!=null&&(a.memoCache.index=0)}P.H=X,a=t(n,r)}while(Bo);return a}function Zo(){var e=P.H,t=e.useState()[0];return t=typeof t.then==`function`?is(t):t,e=e.useState()[0],(K===null?null:K.memoizedState)!==e&&(Ro.flags|=1024),t}function Qo(){var e=Ho!==0;return Ho=0,e}function $o(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function es(e){if(q){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}q=!1}Lo=0,zo=K=Ro=null,Bo=!1,Uo=Ho=0,Wo=null}function ts(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return zo===null?Ro.memoizedState=zo=e:zo=zo.next=e,zo}function ns(){if(K===null){var e=Ro.alternate;e=e===null?null:e.memoizedState}else e=K.next;var t=zo===null?Ro.memoizedState:zo.next;if(t!==null)zo=t,K=e;else{if(e===null)throw Ro.alternate===null?Error(o(467)):Error(o(310));K=e,e={memoizedState:K.memoizedState,baseState:K.baseState,baseQueue:K.baseQueue,queue:K.queue,next:null},zo===null?Ro.memoizedState=zo=e:zo=zo.next=e}return zo}function rs(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function is(e){var t=Uo;return Uo+=1,Wo===null&&(Wo=[]),e=to(Wo,e,t),t=Ro,(zo===null?t.memoizedState:zo.next)===null&&(t=t.alternate,P.H=t===null||t.memoizedState===null?lc:uc),e}function as(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return is(e);if(e.$$typeof===de)return;if(e.$$typeof===N)return Da(e)}throw Error(o(438,String(e)))}function os(e){var t=null,n=Ro.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Ro.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=rs(),Ro.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=le;return t.index++,n}function ss(e,t){return typeof t==`function`?t(e):t}function cs(e){return ls(ns(),K,e)}function ls(e,t,n){var r=e.queue;if(r===null)throw Error(o(311));r.lastRenderedReducer=n;var i=e.baseQueue,a=r.pending;if(a!==null){if(i!==null){var s=i.next;i.next=a.next,a.next=s}t.baseQueue=i=a,r.pending=null}if(a=e.baseState,i===null)e.memoizedState=a;else{t=i.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Lo&f)===f:(Zu&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===z&&(d=!0);else if((Lo&p)===p){u=u.next,p===z&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=a):l=l.next=f,Ro.lanes|=p,ad|=p;f=u.action,Vo&&n(a,f),a=u.hasEagerState?u.eagerState:n(a,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=a):l=l.next=p,Ro.lanes|=f,ad|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=a:l.next=c,!Wr(a,e.memoizedState)&&(Ec=!0,d&&(n=Va,n!==null)))throw n;e.memoizedState=a,e.baseState=s,e.baseQueue=l,r.lastRenderedState=a}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function us(e){var t=ns(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,a=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do a=e(a,s.action),s=s.next;while(s!==i);Wr(a,t.memoizedState)||(Ec=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function ds(e,t,n){var r=Ro,i=ns(),a=oa;if(a){if(n===void 0)throw Error(o(407));n=n()}else n=t();var s=!Wr((K||i).memoizedState,n);if(s&&(i.memoizedState=n,Ec=!0),i=i.queue,Fs(ms.bind(null,r,i,e),[e]),e=i.getSnapshot!==t||s||zo!==null&&!!(zo.memoizedState.tag&1),As(e?9:8,{destroy:void 0},ps.bind(null,r,i,n,t),null),e){if(r.flags|=2048,Yu===null)throw Error(o(349));a||Lo&127||fs(r,t,n)}return n}function fs(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ro.updateQueue,t===null?(t=rs(),Ro.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function ps(e,t,n,r){t.value=n,t.getSnapshot=r,hs(t)&&gs(e)}function ms(e,t,n){return n(function(){hs(t)&&gs(e)})}function hs(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Wr(e,n)}catch{return!0}}function gs(e){var t=ki(e,2);t!==null&&Nd(t,e,2)}function _s(e){var t=ts();if(typeof e==`function`){var n=e;if(e=n(),Vo){$e(!0);try{n()}finally{$e(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:e},t}function vs(e,t,n,r){return e.baseState=n,ls(e,K,typeof r==`function`?r:ss)}function ys(e,t,n,r,i){if(ac(e))throw Error(o(485));if(e=t.action,e!==null){var a={payload:i,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){a.listeners.push(e)}};P.T===null?a.isTransition=!1:n(!0),r(a),n=t.pending,n===null?(a.next=t.pending=a,bs(t,a)):(a.next=n.next,t.pending=n.next=a)}}function bs(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=P.T,o={};o.types=a===null?null:a.types,P.T=o;try{var s=n(i,r),c=P.S;c!==null&&c(o,s),xs(e,t,s)}catch(n){Cs(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),P.T=a}}else try{a=n(i,r),xs(e,t,a)}catch(n){Cs(e,t,n)}}function xs(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ss(e,t,n)},function(n){return Cs(e,t,n)}):Ss(e,t,n)}function Ss(e,t,n){t.status=`fulfilled`,t.value=n,ws(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,bs(e,n)))}function Cs(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,ws(t),t=t.next;while(t!==r)}e.action=null}function ws(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Ts(e,t){return t}function Es(e,t){if(oa){var n=Yu.formState;if(n!==null){a:{var r=Ro;if(oa){if(R){b:{for(var i=R,a=ca;i.nodeType!==8;)if(!a||(i=dm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){R=dm(i.nextSibling),r=i.data===`F!`;break a}}ua(r)}r=!1}r&&(t=n[0])}}return n=ts(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ts,lastRenderedState:t},n.queue=r,n=nc.bind(null,Ro,r),r.dispatch=n,r=_s(!1),a=ic.bind(null,Ro,!1,r.queue),r=ts(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=ys.bind(null,Ro,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ds(e){return J(ns(),K,e)}function J(e,t,n){if(t=ls(e,t,Ts)[0],e=cs(ss)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=is(t)}catch(e){throw e===Xa?Qa:e}else r=t;t=ns();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Ro.flags|=2048,As(9,{destroy:void 0},Os.bind(null,i,n),null)),[r,a,e]}function Os(e,t){e.action=t}function ks(e){var t=ns(),n=K;if(n!==null)return J(t,n,e);ns(),t=t.memoizedState,n=ns();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function As(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Ro.updateQueue,t===null&&(t=rs(),Ro.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function js(){return ns().memoizedState}function Ms(e,t,n,r){var i=ts();Ro.flags|=e,i.memoizedState=As(1|t,{destroy:void 0},n,r===void 0?null:r)}function Ns(e,t,n,r){var i=ns();r=r===void 0?null:r;var a=i.memoizedState.inst;K!==null&&r!==null&&qo(r,K.memoizedState.deps)?i.memoizedState=As(t,a,n,r):(Ro.flags|=e,i.memoizedState=As(1|t,a,n,r))}function Ps(e,t){Ms(8390656,8,e,t)}function Fs(e,t){Ns(2048,8,e,t)}function Is(e){Ro.flags|=4;var t=Ro.updateQueue;if(t===null)t=rs(),Ro.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Ls(e){var t=ns().memoizedState;return Is({ref:t,nextImpl:e}),function(){if(Ju&2)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function Rs(e,t){return Ns(4,2,e,t)}function zs(e,t){return Ns(4,4,e,t)}function Bs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Vs(e,t,n){n=n==null?null:n.concat([e]),Ns(4,4,Bs.bind(null,t,e),n)}function Hs(){}function Us(e,t){var n=ns();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&qo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ws(e,t){var n=ns();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&qo(t,r[1]))return r[0];if(r=e(),Vo){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r}function Gs(e,t,n){return n===void 0||Lo&1073741824&&!(Zu&261930)?e.memoizedState=t:(e.memoizedState=n,e=jd(),Ro.lanes|=e,ad|=e,n)}function Ks(e,t,n,r){return Wr(n,t)?n:Eo.current===null?!(Lo&106)||Lo&1073741824&&!(Zu&261930)?(Ec=!0,e.memoizedState=n):(e=jd(),Ro.lanes|=e,ad|=e,t):(e=Gs(e,n,r),Wr(e,t)||(Ec=!0),e)}function qs(e,t,n,r,i){var a=_e.p;_e.p=a!==0&&8>a?a:8;var o=P.T,s={};s.types=o===null?null:o.types,P.T=s,ic(e,!1,t,n);try{var c=i(),l=P.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?rc(e,t,Wa(c,r),Ad(e)):rc(e,t,r,Ad(e))}catch(n){rc(e,t,{then:function(){},status:`rejected`,reason:n},Ad())}finally{_e.p=a,o!==null&&s.types!==null&&(o.types=s.types),P.T=o}}function Y(){}function Js(e,t,n,r){if(e.tag!==5)throw Error(o(476));var i=Ys(e).queue;qs(e,i,t,ve,n===null?Y:function(){return Xs(e),n(r)})}function Ys(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ve,baseState:ve,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:ve},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Xs(e){var t=Ys(e);t.next===null&&(t=e.alternate.memoizedState),rc(e,t.next.queue,{},Ad())}function Zs(){return Da(lh)}function Qs(){return ns().memoizedState}function $s(){return ns().memoizedState}function ec(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Ad();e=_o(n);var r=vo(t,e,n);r!==null&&(Nd(r,t,n),yo(r,t,n)),t={cache:Pa()},e.payload=t;return}t=t.return}}function tc(e,t,n){var r=Ad();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},ac(e)?oc(t,n):(n=Oi(e,t,n,r),n!==null&&(Nd(n,e,r),sc(n,t,r)))}function nc(e,t,n){rc(e,t,n,Ad())}function rc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(ac(e))oc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Wr(s,o))return Di(e,t,i,0),Yu===null&&Ei(),!1}catch{}if(n=Oi(e,t,i,r),n!==null)return Nd(n,e,r),sc(n,t,r),!0}return!1}function ic(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},ac(e)){if(t)throw Error(o(479))}else t=Oi(e,n,r,2),t!==null&&Nd(t,e,2)}function ac(e){var t=e.alternate;return e===Ro||t!==null&&t===Ro}function oc(e,t){Bo=q=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function sc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,_t(e,n)}}var cc={readContext:Da,use:as,useCallback:Ko,useContext:Ko,useEffect:Ko,useImperativeHandle:Ko,useLayoutEffect:Ko,useInsertionEffect:Ko,useMemo:Ko,useReducer:Ko,useRef:Ko,useState:Ko,useDebugValue:Ko,useDeferredValue:Ko,useTransition:Ko,useSyncExternalStore:Ko,useId:Ko,useHostTransitionStatus:Ko,useFormState:Ko,useActionState:Ko,useOptimistic:Ko,useMemoCache:Ko,useCacheRefresh:Ko,useEffectEvent:Ko},lc={readContext:Da,use:as,useCallback:function(e,t){return ts().memoizedState=[e,t===void 0?null:t],e},useContext:Da,useEffect:Ps,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Ms(4194308,4,Bs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ms(4194308,4,e,t)},useInsertionEffect:function(e,t){Ms(4,2,e,t)},useMemo:function(e,t){var n=ts();t=t===void 0?null:t;var r=e();if(Vo){$e(!0);try{e()}finally{$e(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ts();if(n!==void 0){var i=n(t);if(Vo){$e(!0);try{n(t)}finally{$e(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=tc.bind(null,Ro,e),[r.memoizedState,e]},useRef:function(e){var t=ts();return e={current:e},t.memoizedState=e},useState:function(e){e=_s(e);var t=e.queue,n=nc.bind(null,Ro,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Hs,useDeferredValue:function(e,t){return Gs(ts(),e,t)},useTransition:function(){var e=_s(!1);return e=qs.bind(null,Ro,e.queue,!0,!1),ts().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ro,i=ts();if(oa){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),Yu===null)throw Error(o(349));Zu&127||fs(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,Ps(ms.bind(null,r,a,e),[e]),r.flags|=2048,As(9,{destroy:void 0},ps.bind(null,r,a,n,t),null),n},useId:function(){var e=ts(),t=Yu.identifierPrefix;if(oa){var n=$i,r=Qi;n=(r&~(1<<32-et(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Ho++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Go++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Zs,useFormState:Es,useActionState:Es,useOptimistic:function(e){var t=ts();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=ic.bind(null,Ro,!0,n),n.dispatch=t,[e,t]},useMemoCache:os,useCacheRefresh:function(){return ts().memoizedState=ec.bind(null,Ro)},useEffectEvent:function(e){var t=ts(),n={impl:e};return t.memoizedState=n,function(){if(Ju&2)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},uc={readContext:Da,use:as,useCallback:Us,useContext:Da,useEffect:Fs,useImperativeHandle:Vs,useInsertionEffect:Rs,useLayoutEffect:zs,useMemo:Ws,useReducer:cs,useRef:js,useState:function(){return cs(ss)},useDebugValue:Hs,useDeferredValue:function(e,t){return Ks(ns(),K.memoizedState,e,t)},useTransition:function(){var e=cs(ss)[0],t=ns().memoizedState;return[typeof e==`boolean`?e:is(e),t]},useSyncExternalStore:ds,useId:Qs,useHostTransitionStatus:Zs,useFormState:Ds,useActionState:Ds,useOptimistic:function(e,t){return vs(ns(),K,e,t)},useMemoCache:os,useCacheRefresh:$s,useEffectEvent:Ls},X={readContext:Da,use:as,useCallback:Us,useContext:Da,useEffect:Fs,useImperativeHandle:Vs,useInsertionEffect:Rs,useLayoutEffect:zs,useMemo:Ws,useReducer:us,useRef:js,useState:function(){return us(ss)},useDebugValue:Hs,useDeferredValue:function(e,t){var n=ns();return K===null?Gs(n,e,t):Ks(n,K.memoizedState,e,t)},useTransition:function(){var e=us(ss)[0],t=ns().memoizedState;return[typeof e==`boolean`?e:is(e),t]},useSyncExternalStore:ds,useId:Qs,useHostTransitionStatus:Zs,useFormState:ks,useActionState:ks,useOptimistic:function(e,t){var n=ns();return K===null?(n.baseState=e,[e,n.queue.dispatch]):vs(n,K,e,t)},useMemoCache:os,useCacheRefresh:$s,useEffectEvent:Ls};function dc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:D({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var fc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ad(),i=_o(r);i.payload=t,n!=null&&(i.callback=n),t=vo(e,i,r),t!==null&&(Nd(t,e,r),yo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ad(),i=_o(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=vo(e,i,r),t!==null&&(Nd(t,e,r),yo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ad(),r=_o(n);r.tag=2,t!=null&&(r.callback=t),t=vo(e,r,n),t!==null&&(Nd(t,e,n),yo(t,e,n))}};function pc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Gr(n,r)||!Gr(i,a):!0}function mc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&fc.enqueueReplaceState(t,t.state,null)}function hc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=D({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function gc(e){Si(e)}function _c(e){console.error(e)}function vc(e){Si(e)}function yc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function bc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function xc(e,t,n){return n=_o(n),n.tag=3,n.payload={element:null},n.callback=function(){yc(e,t)},n}function Sc(e){return e=_o(e),e.tag=3,e}function Cc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){bc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){bc(t,n,r),typeof i!=`function`&&(_d===null?_d=new Set([this]):_d.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function wc(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&wa(t,n,i,!0),n=V.current,n!==null){switch(n.tag){case 31:case 13:case 19:return H===null?Gd():n.alternate===null&&id===0&&(id=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===$a?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),mf(e,r,i)),!1;case 22:return n.flags|=65536,r===$a?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),mf(e,r,i)),!1}throw Error(o(435,n.tag))}return mf(e,r,i),Gd(),!1}if(oa)return t=V.current,t===null?(r!==la&&(t=Error(o(423),{cause:r}),ga(Wi(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=Wi(r,n),i=xc(e.stateNode,r,i),bo(e,i),id!==4&&(id=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==la&&(e=Error(o(422),{cause:r}),ga(Wi(e,n)))),!1;var a=Error(o(520),{cause:r});if(a=Wi(a,n),ud===null?ud=[a]:ud.push(a),id!==4&&(id=2),t===null)return!0;r=Wi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=xc(n.stateNode,r,e),bo(n,e),!1;case 1:if(t=n.type,a=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||a!==null&&typeof a.componentDidCatch==`function`&&(_d===null||!_d.has(a))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Sc(i),Cc(i,e,n,r),bo(n,i),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Tc=Error(o(461)),Ec=!1;function Dc(e,t,n,r){t.child=e===null?po(t,null,n,r):fo(t,e.child,n,r)}function Oc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Ea(t),r=Jo(e,t,n,o,a,i),s=Qo(),e!==null&&!Ec?($o(e,t,i),nl(e,t,i)):(oa&&s&&na(t),t.flags|=1,Dc(e,t,r,i),t.child)}function kc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Fi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Ac(e,t,a,r,i)):(e=Ri(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!rl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Gr:n,n(o,r)&&e.ref===t.ref)return nl(e,t,i)}return t.flags|=1,e=Ii(a,r),e.ref=t.ref,e.return=t,t.child=e}function Ac(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Gr(a,r)&&e.ref===t.ref){if(Ec=!1,t.pendingProps=r=a,rl(e,i))e.flags&131072&&(Ec=!0);else return t.lanes=e.lanes,nl(e,t,i)}}return Rc(e,t,n,r,i)}function jc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Nc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ja(t,a===null?null:a.cachePool),a===null?ko():Oo(t,a),G(t);else return r=t.lanes=536870912,Nc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Ja(t,null),ko(),jo()):(Ja(t,a.cachePool),Oo(t,a),jo(),t.memoizedState=null);return Dc(e,t,i,n),t.child}function Mc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Nc(e,t,n,r,i){var a=qa();return a=a===null?null:{parent:Na._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Ja(t,null),ko(),G(t),e!==null&&wa(e,t,r,!0),t.childLanes=i,null}function Pc(e,t){return t=qc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Fc(e,t,n){return fo(t,e.child,null,n),e=Pc(t,t.pendingProps),e.flags|=2,Mo(t),t.memoizedState=null,e}function Ic(e,t,n){var r=t.pendingProps,i=!!(t.flags&128);if(t.flags&=-129,e===null){if(oa){if(r.mode===`hidden`)return e=Pc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Mc(null,e);if(W(t),(e=R)?(e=sm(e,ca),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Zi===null?null:{id:Qi,overflow:$i},retryLane:536870912,hydrationErrors:null},n=Vi(e),n.return=t,t.child=n,aa=t,R=null)):e=null,e===null)throw ua(t);return t.lanes=536870912,null}return Pc(t,r)}var a=e.memoizedState;if(a!==null){var s=a.dehydrated;if(W(t),i){if(t.flags&256)t.flags&=-257,t=Fc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558))}else if(Ec||wa(e,t,n,!1),i=(n&e.childLanes)!==0,Ec||i){if(Eo.current===null){if(r=Yu,r!==null&&(s=vt(r,n),s!==0&&s!==a.retryLane))throw a.retryLane=s,ki(e,s),Nd(r,e,s),Tc;Gd()}t=Fc(e,t,n)}else e=a.treeContext,R=dm(s.nextSibling),aa=t,oa=!0,sa=null,ca=!1,e!==null&&ia(t,e),t=Pc(t,r),t.flags|=134221824;return t}return e=Ii(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Lc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Rc(e,t,n,r,i){return Ea(t),n=Jo(e,t,n,r,void 0,i),r=Qo(),e!==null&&!Ec?($o(e,t,i),nl(e,t,i)):(oa&&r&&na(t),t.flags|=1,Dc(e,t,n,i),t.child)}function zc(e,t,n,r,i,a){return Ea(t),t.updateQueue=null,n=Xo(t,r,n,i),Yo(e),r=Qo(),e!==null&&!Ec?($o(e,t,a),nl(e,t,a)):(oa&&r&&na(t),t.flags|=1,Dc(e,t,n,a),t.child)}function Bc(e,t,n,r,i){if(Ea(t),t.stateNode===null){var a=Mi,o=n.contextType;typeof o==`object`&&o&&(a=Da(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=fc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ho(t),o=n.contextType,a.context=typeof o==`object`&&o?Da(o):Mi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(dc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&fc.enqueueReplaceState(a,a.state,null),Co(t,r,a,i),So(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=hc(n,s);a.props=c;var l=a.context,u=n.contextType;o=Mi,typeof u==`object`&&u&&(o=Da(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&mc(t,a,r,o),mo=!1;var f=t.memoizedState;a.state=f,Co(t,r,a,i),So(),l=t.memoizedState,s||f!==l||mo?(typeof d==`function`&&(dc(t,n,d,r),l=t.memoizedState),(c=mo||pc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,go(e,t),o=t.memoizedProps,u=hc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Mi,typeof l==`object`&&l&&(c=Da(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&mc(t,a,r,c),mo=!1,f=t.memoizedState,a.state=f,Co(t,r,a,i),So();var p=t.memoizedState;o!==d||f!==p||mo||e!==null&&e.dependencies!==null&&Ta(e.dependencies)?(typeof s==`function`&&(dc(t,n,s,r),p=t.memoizedState),(u=mo||pc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ta(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Lc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=fo(t,e.child,null,i),t.child=fo(t,null,n,i)):Dc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=nl(e,t,i),e}function Vc(e,t,n,r){return ma(),t.flags|=256,Dc(e,t,n,r),t.child}var Hc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Uc(e){return{baseLanes:e,cachePool:Ya()}}function Wc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=cd),e}function Gc(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(No.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(oa){if(i?U(t):jo(),(e=R)?(e=sm(e,ca),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Zi===null?null:{id:Qi,overflow:$i},retryLane:536870912,hydrationErrors:null},n=Vi(e),n.return=t,t.child=n,aa=t,R=null)):e=null,e===null)throw ua(t);return t.lanes=lm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(jo(),i=t.mode,a=qc({mode:`hidden`,children:a},i),r=zi(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Uc(n),r.childLanes=Wc(e,o,n),t.memoizedState=Hc,Mc(null,r)):(U(t),Kc(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return Yc(e,t,a,o,r,c,s,n)}return i?(jo(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Ii(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=zi(i,a,n,null),i.flags|=2):i=Ii(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Mc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Uc(n):(a=i.cachePool,a===null?a=Ya():(s=Na._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Wc(e,o,n),t.memoizedState=Hc,Mc(e.child,r)):(U(t),n=e.child,e=n.sibling,n=Ii(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function Kc(e,t){return t=qc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function qc(e,t){return e=Pi(22,e,null,t),e.lanes=0,e}function Jc(e,t,n){return fo(t,e.child,null,n),e=Kc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Yc(e,t,n,r,i,a,s,c){if(n)return t.flags&256?(U(t),t.flags&=-257,Jc(e,t,c)):t.memoizedState===null?(jo(),a=i.fallback,s=t.mode,i=qc({mode:`visible`,children:i.children},s),a=zi(a,s,c,null),a.flags|=2,i.return=t,a.return=t,i.sibling=a,t.child=i,fo(t,e.child,null,c),i=t.child,i.memoizedState=Uc(c),i.childLanes=Wc(e,r,c),t.memoizedState=Hc,Mc(null,i)):(jo(),t.child=e.child,t.flags|=128,null);if(U(t),lm(a)){if(r=a.nextSibling&&a.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(i=Error(o(419)),i.stack=``,i.digest=r,ga({value:i,source:null,stack:null})),Jc(e,t,c)}if(Ec||wa(e,t,c,!1),r=(c&e.childLanes)!==0,Ec||r){if(Eo.current!==null)return Jc(e,t,c);if(r=Yu,r!==null&&(i=vt(r,c),i!==0&&i!==s.retryLane))throw s.retryLane=i,ki(e,i),Nd(r,e,i),Tc;return cm(a)||Gd(),Jc(e,t,c)}return cm(a)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,R=dm(a.nextSibling),aa=t,oa=!0,sa=null,ca=!1,e!==null&&ia(t,e),t=Kc(t,i.children),t.flags|=134221824,t)}function Xc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Sa(e.return,t,n)}function Zc(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Io(n)===null&&(t=e),e=e.sibling}return t}function Qc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function $c(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function el(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=No.current;if(t.flags&128)return Po(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Po(t,o),i===`backwards`&&e!==null?($c(e),Dc(e,t,r,n),$c(e)):Dc(e,t,r,n),r=oa?Ji:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Xc(e,n,t);else if(e.tag===19)Xc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=Zc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,$c(t)),Qc(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Io(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Qc(t,!0,n,null,a,r);break;case`together`:Qc(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=Zc(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Qc(t,!1,i,n,a,r)}return t.child}function tl(e,t,n){var r=t.pendingProps;return ba(t,t.type,r.value),Dc(e,t,r.children,n),t.child}function nl(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ad|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(wa(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=Ii(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Ii(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function rl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Ta(e)))}function il(e,t,n){switch(t.tag){case 3:Oe(t,t.stateNode.containerInfo),ba(t,Na,e.memoizedState.cache),ma();break;case 27:case 5:Ae(t);break;case 4:Oe(t,t.stateNode.containerInfo);break;case 10:ba(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,W(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return U(t),t.flags|=128,null;r=wa(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?Gc(e,t,n):(U(t),e=nl(e,t,n),e===null?null:e.sibling)}U(t);break;case 19:if(t.flags&128)return el(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(wa(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return el(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Po(t,No.current),r)break;return null;case 22:return t.lanes=0,jc(e,t,n,t.pendingProps);case 24:ba(t,Na,e.memoizedState.cache)}return nl(e,t,n)}function al(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Ec=!0;else{if(!rl(e,n)&&!(t.flags&128))return Ec=!1,il(e,t,n);Ec=!!(e.flags&131072)}}else Ec=!1,oa&&t.flags&1048576&&ta(t,Ji,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=no(t.elementType),t.type=e,typeof e==`function`)Fi(e)?(r=hc(e,r),t.tag=1,t=Bc(null,t,e,r,n)):(t.tag=0,t=Rc(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===ne){t.tag=11,t=Oc(null,t,e,r,n);break a}if(i===ae){t.tag=14,t=kc(null,t,e,r,n);break a}if(i===N){t.tag=10,t.type=e,t=tl(null,t,n);break a}}throw t=he(e)||e,Error(o(306,t,``))}}return t;case 0:return Rc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=hc(r,t.pendingProps),Bc(e,t,r,i,n);case 3:a:{if(Oe(t,t.stateNode.containerInfo),e===null)throw Error(o(387));r=t.pendingProps;var a=t.memoizedState;i=a.element,go(e,t),Co(t,r,null,n);var s=t.memoizedState;if(r=s.cache,ba(t,Na,r),r!==a.cache&&Ca(t,[Na],n,!0),So(),r=s.element,a.isDehydrated){if(a={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=Vc(e,t,r,n);break a}if(r!==i){i=Wi(Error(o(424)),t),ga(i),t=Vc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(R=dm(e.firstChild),aa=t,oa=!0,sa=null,ca=!0,n=po(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(ma(),r===i){t=nl(e,t,n);break a}Dc(e,t,r,n)}t=t.child}return t;case 26:return Lc(e,t),e===null?(n=Fm(t.type,null,t.pendingProps,null))?t.memoizedState=n:oa||(t.stateNode=mp(t.type,t.pendingProps,Ee.current,t)):t.memoizedState=Fm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Ae(t),e===null&&oa&&(r=t.stateNode=_m(t.type,t.pendingProps,Ee.current),aa=t,ca=!0,i=R,wp(t.type)?(fm=i,R=dm(r.firstChild)):R=i),Dc(e,t,t.pendingProps.children,n),Lc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&oa&&((i=r=R)&&(r=am(r,t.type,t.pendingProps,ca),r===null?i=!1:(t.stateNode=r,aa=t,R=dm(r.firstChild),ca=!1,i=!0)),i||ua(t)),Ae(t),i=t.type,a=t.pendingProps,s=e===null?null:e.memoizedProps,r=a.children,hp(i,a)?r=null:s!==null&&hp(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=Jo(e,t,Zo,null,null,n),lh._currentValue=i),Lc(e,t),Dc(e,t,r,n),t.child;case 6:return e===null&&oa&&((e=n=R)&&(n=om(n,t.pendingProps,ca),n===null?e=!1:(t.stateNode=n,aa=t,R=null,e=!0)),e||ua(t)),null;case 13:return Gc(e,t,n);case 4:return Oe(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=fo(t,null,r,n):Dc(e,t,r,n),t.child;case 11:return Oc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Lc(e,t),Dc(e,t,r,n),t.child;case 8:return Dc(e,t,t.pendingProps.children,n),t.child;case 12:return Dc(e,t,t.pendingProps.children,n),t.child;case 10:return tl(e,t,n);case 9:return i=t.type._context,r=t.pendingProps.children,Ea(t),i=Da(i),r=r(i),t.flags|=1,Dc(e,t,r,n),t.child;case 14:return kc(e,t,t.type,t.pendingProps,n);case 15:return Ac(e,t,t.type,t.pendingProps,n);case 19:return el(e,t,n);case 31:return Ic(e,t,n);case 22:return jc(e,t,n,t.pendingProps);case 24:return Ea(t),r=Da(Na),e===null?(i=qa(),i===null&&(i=Yu,a=Pa(),i.pooledCache=a,a.refCount++,a!==null&&(i.pooledCacheLanes|=n),i=a),t.memoizedState={parent:r,cache:i},ho(t),ba(t,Na,i)):((e.lanes&n)!==0&&(go(e,t),Co(t,null,null,n),So()),i=e.memoizedState,a=t.memoizedState,i.parent===r?(r=a.cache,ba(t,Na,r),r!==i.cache&&Ca(t,[Na],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),ba(t,Na,r))),Dc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:oa&&na(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Lc(e,t),Dc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function ol(e){e.flags|=4}function sl(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?Xm(t,r):Xm(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Hd())e.flags|=8192;else throw ro=$a,Za}}else e.flags&=-16777217}function cl(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Zm(t)){if(Hd())e.flags|=8192;else throw ro=$a,Za}}function ll(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:ft(),e.lanes|=t,ld|=t)}function ul(e,t){if(!oa)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function dl(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function fl(e,t,n){var r=t.pendingProps;switch(ra(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dl(t),null;case 1:return dl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),xa(Na),ke(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(pa(t)?ol(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,ha())),dl(t),null;case 26:var i=t.type,a=t.memoizedState;return e===null?(ol(t),a===null?(dl(t),sl(t,i,null,r,n)):(dl(t),cl(t,a))):a?a===e.memoizedState?(dl(t),t.flags&=-16777217):(ol(t),dl(t),cl(t,a)):(e=e.memoizedProps,e!==r&&ol(t),dl(t),sl(t,i,e,r,n)),null;case 27:if(je(t),n=Ee.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ol(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return dl(t),t.subtreeFlags&=-33554433,null}e=we.current,pa(t)?da(t,e):(e=_m(i,r,n),t.stateNode=e,ol(t))}return dl(t),t.subtreeFlags&=-33554433,null;case 5:if(je(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ol(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return dl(t),t.subtreeFlags&=-33554433,null}if(a=we.current,pa(t))da(t,a);else{var s=dp(Ee.current);switch(a){case 1:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case 2:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;default:switch(i){case`svg`:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case`math`:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;case`script`:a=s.createElement(`div`),a.innerHTML=`<script><\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}a[wt]=t,a[Tt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)a.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=a;a:switch(ip(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&ol(t)}}return dl(t),t.subtreeFlags&=-33554433,sl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&ol(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(o(166));if(e=Ee.current,pa(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=aa,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[wt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||tp(e.nodeValue,n)),e||ua(t,!0)}else e=dp(e).createTextNode(r),e[wt]=t,t.stateNode=e}return dl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=pa(t),n!==null){if(e===null){if(!r)throw Error(o(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(557));e[wt]=t}else ma(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dl(t),e=!1}else n=ha(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Mo(t),t):(Mo(t),null);if(t.flags&128)throw Error(o(558))}return dl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=pa(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(o(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(o(317));i[wt]=t}else ma(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;dl(t),i=!1}else i=ha(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Mo(t),t):(Mo(t),null)}return Mo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),ll(t,t.updateQueue),dl(t),null);case 4:return ke(),e===null&&Gf(t.stateNode.containerInfo),t.flags|=67108864,dl(t),null;case 10:return xa(t.type),dl(t),null;case 19:if(Fo(t),r=t.memoizedState,r===null)return dl(t),null;if(i=!!(t.flags&128),a=r.rendering,a===null){if(i)ul(r,!1);else{if(id!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Io(e),a!==null){for(t.flags|=128,ul(r,!1),e=a.updateQueue,t.updateQueue=e,ll(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Li(n,e),n=n.sibling;return Po(t,No.current&1|2),oa&&ea(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ue()>hd&&(t.flags|=128,i=!0,ul(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Io(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,ll(t,e),ul(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!a.alternate&&!oa)return dl(t),null}else 2*Ue()-r.renderingStartTime>hd&&n!==536870912&&(t.flags|=128,i=!0,ul(r,!1),t.lanes=4194304)}r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ue(),e.sibling=null,a=No.current,a=i?a&1|2:a&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||oa?Po(t,a):(n=a,Ce(V,t),Ce(No,n),H===null&&(H=t)),oa&&ea(t,r.treeForkCount),e}return dl(t),null;case 22:case 23:return Mo(t),Ao(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(dl(t),t.subtreeFlags&6&&(t.flags|=8192)):dl(t),n=t.updateQueue,n!==null&&ll(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Se(Ka),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),xa(Na),dl(t),null;case 25:return null;case 30:return t.flags|=33554432,dl(t),null}throw Error(o(156,t.tag))}function pl(e,t){switch(ra(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xa(Na),ke(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return je(t),null;case 31:if(t.memoizedState!==null){if(Mo(t),t.alternate===null)throw Error(o(340));ma()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Mo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));ma()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Fo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return ke(),null;case 10:return xa(t.type),null;case 22:case 23:return Mo(t),Ao(),e!==null&&Se(Ka),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return xa(Na),null;case 25:return null;default:return null}}function ml(e,t){switch(ra(t),t.tag){case 3:xa(Na),ke();break;case 26:case 27:case 5:je(t);break;case 4:ke();break;case 31:t.memoizedState!==null&&Mo(t);break;case 13:Mo(t);break;case 19:Fo(t);break;case 10:xa(t.type);break;case 22:case 23:Mo(t),Ao(),e!==null&&Se(Ka);break;case 24:xa(Na)}}function hl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){pf(t,t.return,e)}}function gl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){pf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){pf(t,t.return,e)}}function _l(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{To(t,n)}catch(t){pf(e,e.return,t)}}}function vl(e,t,n){n.props=hc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){pf(e,t,n)}}function yl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=yi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Ip(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Lp(e);h(e.child,!1,em,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){pf(e,t,n)}}function bl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){pf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){pf(e,t,n)}else n.current=null}}function xl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)nm(e.stateNode,t[n])}function Sl(e){for(var t=e.return;t!==null&&(Tl(t)&&nm(e.stateNode,t.stateNode),!wl(t));)t=t.return}function Cl(e){for(var t=e.return;t!==null&&(Tl(t)&&rm(e.stateNode,t.stateNode),!wl(t));)t=t.return}function wl(e){return e.tag===5||e.tag===3||e.tag===27}function Tl(e){return e&&e.tag===7&&e.stateNode!==null}function El(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){pf(e,e.return,t)}}function Dl(e,t,n){try{var r=e.stateNode;op(r,e.type,n,t),r[Tt]=t}catch(t){pf(e,e.return,t)}}function Ol(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&wp(e.type)||e.tag===4}function kl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Ol(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&wp(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Al(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=xn)),xl(e,r),Jt=!0;else if(i!==4&&(i===27&&(xl(e,r),r=null,wp(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(Al(e,t,n,r),e=e.sibling;e!==null;)Al(e,t,n,r),e=e.sibling}function jl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),xl(e,r),Jt=!0;else if(i!==4&&(i===27&&(xl(e,r),r=null,wp(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(jl(e,t,n,r),e=e.sibling;e!==null;)jl(e,t,n,r),e=e.sibling}function Ml(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);ip(t,r,n),t[wt]=e,t[Tt]=n}catch(t){pf(e,e.return,t)}}var Nl=!1,Pl=null;function Fl(e){(e.tag===30||e.subtreeFlags&33554432)&&(Nl=!0)}var Il=null;function Ll(){var e=Il;return Il=null,e}var Rl=0;function zl(e,t,n,r,i){return Rl=0,Bl(e.child,t,n,r,i)}function Bl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=Ap(o);r.push(s),s.view&&(a=!0)}else a||Ap(o).view&&(a=!0);Nl=!0,Dp(o,Rl===0?t:t+`_`+Rl,n),Rl++}else(e.tag!==22||e.memoizedState===null)&&(e.tag===30&&i||Bl(e.child,t,n,r,i)&&(a=!0));e=e.sibling}return a}function Vl(e,t){for(;e!==null;)e.tag===5?Op(e.stateNode,e.memoizedProps):(e.tag!==22||e.memoizedState===null)&&(e.tag===30&&t||Vl(e.child,t)),e=e.sibling}function Hl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Hl(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(o(544));var n=t.name;t=xi(t.default,t.share),t!==`none`&&(zl(e,n,t,null,!1)||Vl(e.child,!1))}e=e.sibling}}function Ul(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=yi(r,n),a=xi(r.default,n.paired?r.share:r.enter);a===`none`?Hl(e):zl(e,i,a,null,!1)?(Hl(e),n.paired||t||Md(e,r.onEnter)):Vl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Ul(e,t),e=e.sibling;else Hl(e)}function Wl(e){if(Pl!==null&&Pl.size!==0){var t=Pl;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=xi(n.default,n.share);if(a!==`none`&&(zl(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Md(e,n.onShare)):Vl(e.child,!1)),t.delete(r),t.size===0)break}}}Wl(e)}e=e.sibling}}}function Gl(e){if(e.tag===30){var t=e.memoizedProps,n=yi(t,e.stateNode),r=Pl===null?void 0:Pl.get(n),i=xi(t.default,r===void 0?t.exit:t.share);i!==`none`&&(zl(e,n,i,null,!1)?r===void 0?Md(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Pl.delete(n),Md(e,t.onShare)):Vl(e.child,!1)),Pl!==null&&Wl(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Gl(e),e=e.sibling;else Pl!==null&&Wl(e)}function Kl(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=yi(t,e.stateNode);t=xi(t.default,t.update),e.flags&=-5,t!==`none`&&zl(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&Kl(e);e=e.sibling}}function ql(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Vl(e.child,!1))}ql(e)}e=e.sibling}}function Z(e){if(e.tag===30)e.stateNode.paired=null,Vl(e.child,!1),ql(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Z(e),e=e.sibling;else ql(e)}function Jl(e){for(e=e.child;e!==null;)e.tag===30?Vl(e.child,!1):e.subtreeFlags&33554432&&Jl(e),e=e.sibling}function Yl(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Rl<a.length){var l=a[Rl],u=Ap(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Dp(c,Rl===0?n:n+`_`+Rl,i),s&&e.flags&4||(Il===null&&(Il=[]),Il.push(c,Rl===0?r:r+`_`+Rl,t.memoizedProps)),Rl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:Yl(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function Xl(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=yi(n,r),a=xi(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(jp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Rl=0,i=Yl(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Md(e,n.onUpdate))}else e.subtreeFlags&33554432&&Xl(e,t);e=e.sibling}}var Zl=!1,Ql=!1,$l=!1,eu=!1,tu=typeof WeakSet==`function`?WeakSet:Set,nu=null,ru=!1,iu=!1,au=!1,ou=!1;function su(e,t,n){if(e=e.containerInfo,lp=vh,e=Xr(e),Zr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(up={focusedElem:e,selectionRange:r},vh=!1,n=(n&335544064)===n,nu=t,t=n?9270:1024;nu!==null;){if(e=nu,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&Gl(r[a]);if(e.alternate===null&&e.flags&2)n&&Fl(e),cu(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&Gl(r),cu(n);continue}if(r!==null&&r.memoizedState!==null){n&&Fl(e),cu(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,nu=r):(n&&Kl(e),cu(n))}}Pl=null}function cu(e){for(;nu!==null;){var t=nu,n=e,r=t.alternate,i=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(i&1024&&r!==null){n=void 0,i=r.memoizedProps,r=r.memoizedState;var a=t.stateNode;try{var s=hc(t.type,i);n=a.getSnapshotBeforeUpdate(s,r),a.__reactInternalSnapshotBeforeUpdate=n}catch(e){pf(t,t.return,e)}}break;case 3:if(i&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)im(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:im(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=yi(r.memoizedProps,r.stateNode),i=t.memoizedProps,i=xi(i.default,i.update),i!==`none`&&zl(r,n,i,r.memoizedState=[],!0));break;default:if(i&1024)throw Error(o(163))}if(r=t.sibling,r!==null){r.return=t.return,nu=r;break}nu=t.return}}function lu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:ku(e,n),r&4&&hl(5,n);break;case 1:if(ku(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){pf(n,n.return,e)}else{var i=hc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){pf(n,n.return,e)}}}r&64&&_l(n),r&512&&yl(n,n.return);break;case 3:if(ku(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{To(e,t)}catch(e){pf(n,n.return,e)}}break;case 27:t===null&&r&4&&Ml(n);case 26:case 5:ku(e,n),t===null&&r&4&&El(n),r&512&&yl(n,n.return);break;case 12:ku(e,n);break;case 31:ku(e,n),r&4&&vu(e,n);break;case 13:ku(e,n),r&4&&yu(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=_f.bind(null,n),um(e,n))));break;case 22:if(r=n.memoizedState!==null||Zl,!r){var a=t!==null&&t.memoizedState!==null||Ql;t=Zl,i=Ql,Zl=r,(Ql=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),ju(e,n,r)):ku(e,n),Zl=t,Ql=i}break;case 30:ku(e,n),r&512&&yl(n,n.return);break;case 7:r&512&&yl(n,n.return);default:ku(e,n)}}function uu(e,t){for(e=e.child;e!==null;)du(e,t),e=e.sibling}function du(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){pf(e,e.return,t)}fu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,Jt=!0}catch(t){pf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?Ep(s,!0):Ep(e.stateNode,!1)}catch(t){pf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&uu(e,t);break;default:uu(e,t)}}function fu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:du(n,r);break a;case 22:n.memoizedState===null&&fu(n,r);break a;default:fu(n,r)}}e=e.sibling}}function pu(e){var t=e.alternate;t!==null&&(e.alternate=null,pu(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Nt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var mu=null,hu=!1;function gu(e,t,n){for(n=n.child;n!==null;)_u(e,t,n),n=n.sibling}function _u(e,t,n){if(Qe&&typeof Qe.onCommitFiberUnmount==`function`)try{Qe.onCommitFiberUnmount(I,n)}catch{}switch(n.tag){case 26:Ql||bl(n,t),gu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!Ql&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Ql||bl(n,t),Cl(n);var r=mu,i=hu;wp(n.type)&&(mu=n.stateNode,hu=!1),gu(e,t,n),vm(n.stateNode,n.type,n.memoizedProps),mu=r,hu=i;break;case 5:Ql||bl(n,t),Cl(n);case 6:if(n.tag===6&&Cl(n),r=mu,i=hu,mu=null,gu(e,t,n),mu=r,hu=i,mu!==null){if(hu)try{(mu.nodeType===9?mu.body:mu.nodeName===`HTML`?mu.ownerDocument.body:mu).removeChild(n.stateNode),Jt=!0}catch(e){pf(n,t,e)}else try{mu.removeChild(n.stateNode),Jt=!0}catch(e){pf(n,t,e)}}break;case 18:mu!==null&&(hu?(e=mu,Tp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Wh(e)):Tp(mu,n.stateNode));break;case 4:r=mu,i=hu,mu=n.stateNode.containerInfo,hu=!0,gu(e,t,n),mu=r,hu=i;break;case 0:case 11:case 14:case 15:gl(2,n,t),Ql||gl(4,n,t),gu(e,t,n);break;case 1:Ql||(bl(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&vl(n,t,r)),gu(e,t,n);break;case 21:gu(e,t,n);break;case 22:Ql=(r=Ql)||n.memoizedState!==null,gu(e,t,n),Ql=r;break;case 30:bl(n,t),gu(e,t,n);break;case 7:Ql||bl(n,t),gu(e,t,n);break;default:gu(e,t,n)}}function vu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Wh(e)}catch(e){pf(t,t.return,e)}}}function yu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Wh(e)}catch(e){pf(t,t.return,e)}}function bu(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new tu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new tu),t;default:throw Error(o(435,e.tag))}}function xu(e,t){var n=bu(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=vf.bind(null,e,t);t.then(r,r)}})}function Su(e,t,n){var r=t.deletions;if(r!==null)for(var i=0;i<r.length;i++){var a=r[i],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(wp(l.type)){mu=l.stateNode,hu=!1;break a}break;case 5:mu=l.stateNode,hu=!1;break a;case 3:case 4:mu=l.stateNode.containerInfo,hu=!0;break a}l=l.return}if(mu===null)throw Error(o(160));_u(s,c,a),mu=null,hu=!1,s=a.alternate,s!==null&&(s.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)wu(t,e,n),t=t.sibling}var Cu=null;function wu(e,t,n){var r=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(i&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var a=0;a<r.length;a++){var s=r[a];s.ref.impl=s.nextImpl}Su(t,e,n),Tu(e),i&4&&(gl(3,e,e.return),hl(3,e),gl(5,e,e.return));break;case 1:Su(t,e,n),Tu(e),i&512&&(Ql||r===null||bl(r,r.return)),i&64&&Zl&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(a=Cu,Su(t,e,n),Tu(e),i&512&&(Ql||r===null||bl(r,r.return)),i&4){if(i=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(Zl)e.stateNode=mp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,i=a.ownerDocument||a;b:switch(t){case`title`:r=i.getElementsByTagName(`title`)[0],(!r||r[jt]||r[wt]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=i.createElement(t),i.head.insertBefore(r,i.querySelector(`head > title`))),ip(r,t,n),r[wt]=e,Rt(r),t=r;break a;case`link`:if(a=qm(`link`,`href`,i).get(t+(n.href||``))){for(s=0;s<a.length;s++)if(r=a[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){a.splice(s,1);break b}}r=i.createElement(t),ip(r,t,n),i.head.appendChild(r);break;case`meta`:if(a=qm(`meta`,`content`,i).get(t+(n.content||``))){for(s=0;s<a.length;s++)if(r=a[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){a.splice(s,1);break b}}r=i.createElement(t),ip(r,t,n),i.head.appendChild(r);break;default:throw Error(o(468,t))}r[wt]=e,Rt(r),t=r}e.stateNode=t}}else Zl||Jm(a,e.type,e.stateNode)}else e.stateNode=Hm(a,n,e.memoizedProps)}else i===n?n===null&&e.stateNode!==null&&Dl(e,e.memoizedProps,r.memoizedProps):(i===null?(t=r.stateNode,t===null||Ql||t.parentNode.removeChild(t)):i.count--,n===null?Zl||Jm(a,e.type,e.stateNode):Hm(a,n,e.memoizedProps))}break;case 27:Su(t,e,n),Tu(e),i&512&&(Ql||r===null||bl(r,r.return)),r!==null&&i&4&&Dl(e,e.memoizedProps,r.memoizedProps);break;case 5:if(a=$l,$l=!1,Su(t,e,n),$l=a,Tu(e),i&512&&(Ql||r===null||bl(r,r.return)),e.flags&32){t=e.stateNode;try{pn(t,``),Jt=!0}catch(t){pf(e,e.return,t)}}i&4&&e.stateNode!=null&&(t=e.memoizedProps,Dl(e,t,r===null?t:r.memoizedProps)),i&1024&&(eu=!0);break;case 6:if(Su(t,e,n),Tu(e),i&4){if(e.stateNode===null)throw Error(o(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,Jt=!0}catch(t){pf(e,e.return,t)}}break;case 3:if(Jt=!1,Km=null,a=Cu,Cu=Sm(t.containerInfo),Su(t,e,n),Cu=a,Tu(e),i&4&&r!==null&&r.memoizedState.isDehydrated)try{Wh(t.containerInfo)}catch(t){pf(e,e.return,t)}eu&&(eu=!1,Eu(e)),Jt=!1;break;case 4:i=$l,$l=Zl,r=Yt(),a=Cu,Cu=Sm(e.stateNode.containerInfo),Su(t,e,n),Tu(e),Cu=a,Jt&&iu&&(au=!0),Jt=r,$l=i;break;case 12:Su(t,e,n),Tu(e);break;case 31:Su(t,e,n),Tu(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 13:Su(t,e,n),Tu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(pd=Ue()),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 22:a=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=Zl,l=Ql,u=$l;Zl=c||a,$l=u||a,Ql=l||s,Su(t,e,n),Ql=l,$l=u,Zl=c,Tu(e),i&8192&&(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,!a||r===null||s||Zl||Ql||(t=s||Ql,n=Zl,r=Ql,Zl=a||Zl,Ql=t,Au(e,2),Zl=n,Ql=r),!a&&$l||uu(e,a)),i&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,xu(e,n))));break;case 19:Su(t,e,n),Tu(e),i&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,xu(e,t)));break;case 30:i&512&&(Ql||r===null||bl(r,r.return)),i=Yt(),a=iu,s=(n&335544064)===n,c=e.memoizedProps,iu=s&&xi(c.default,c.update)!==`none`,Su(t,e,n),Tu(e),s&&r!==null&&Jt&&(e.flags|=4),iu=a,Jt=i;break;case 21:break;case 7:i&512&&(Ql||r===null||bl(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:Su(t,e,n),Tu(e)}}function Tu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Ol(r)){n=r;break}r=r.return}r=null;for(var i=e.return;i!==null;){if(Tl(i)){var a=i.stateNode;r===null?r=[a]:r.push(a)}if(wl(i))break;i=i.return}var s=r;if(n==null)throw Error(o(160));switch(n.tag){case 27:var c=n.stateNode;jl(e,kl(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(pn(l,``),n.flags&=-33),jl(e,kl(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;Al(e,kl(e),u,s);break;default:throw Error(o(161))}}catch(t){pf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Eu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Eu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,vh=!0,t.reset(),vh=!1),e=e.sibling}}function Du(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Ou(t,e),t=t.sibling;else Xl(t,!1)}function Ou(e,t){var n=e.alternate;if(n===null)Ul(e,!1);else switch(e.tag){case 3:if(ou=ru=!1,Ll(),Du(t,e),!ru&&!au){if(e=Il,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Op(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),ou=!0}Il=null;break;case 5:Du(t,e);break;case 4:r=ru,ru=!1,Du(t,e),ru&&(au=!0),ru=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Du(t,e):Ul(e,!1));break;case 30:r=ru,i=Ll(),ru=!1,Du(t,e),ru&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=yi(a,o),o=yi(n.memoizedProps,o);var s=xi(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Rl=0,t=Yl(e,n,t,o,s,a,!0),Rl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Md(e,e.memoizedProps.onUpdate),Il=i):i!==null&&(i.push.apply(i,Il),Il=i),ru=e.flags&32?!0:r;break;default:Du(t,e)}}function ku(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)lu(e,t.alternate,t),t=t.sibling}function Au(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:gl(4,n,n.return),Au(n,r);break;case 1:bl(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&vl(n,n.return,i),Au(n,r);break;case 27:r&2&&vm(n.stateNode,n.type,n.memoizedProps);case 5:bl(n,n.return),n.tag!==5&&n.tag!==27||Cl(n),Au(n,r);break;case 6:Cl(n);break;case 26:bl(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||Ql||i.parentNode.removeChild(i),Au(n,r);break;case 22:n.memoizedState===null&&Au(n,r);break;case 30:bl(n,n.return),Au(n,r);break;case 7:bl(n,n.return);default:Au(n,r)}e=e.sibling}}function ju(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:ju(i,a,n),hl(4,a);break;case 1:if(ju(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){pf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)wo(l[i],c)}catch(e){pf(r,r.return,e)}}s&&o&64&&_l(a),yl(a,a.return);break;case 27:n&2&&Ml(a);case 5:a.tag!==5&&a.tag!==27||Sl(a),ju(i,a,n),s&&r===null&&o&4&&El(a),yl(a,a.return);break;case 6:Sl(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||Zl||Jm(Sm(c.ownerDocument),a.type,c),ju(i,a,n),s&&r===null&&o&4&&El(a),yl(a,a.return);break;case 12:ju(i,a,n);break;case 31:ju(i,a,n),s&&o&4&&vu(i,a);break;case 13:ju(i,a,n),s&&o&4&&yu(i,a);break;case 22:a.memoizedState===null&&ju(i,a,n),yl(a,a.return);break;case 30:ju(i,a,n),yl(a,a.return);break;case 7:yl(a,a.return);default:ju(i,a,n)}t=t.sibling}}function Mu(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Fa(n))}function Nu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Fa(e))}function Pu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Fu(e,t,n,r),t=t.sibling;else i&&Jl(t)}function Fu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&Z(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Pu(e,t,n,r),a&2048&&hl(9,t);break;case 1:Pu(e,t,n,r);break;case 3:Pu(e,t,n,r),i&&ou&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&Fa(a)));break;case 12:if(a&2048){Pu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){pf(t,t.return,e)}}else Pu(e,t,n,r);break;case 31:Pu(e,t,n,r);break;case 13:Pu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&Z(t),o._visibility&2?Pu(e,t,n,r):(o._visibility|=2,Iu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&Z(s),o._visibility&2?Pu(e,t,n,r):Lu(e,t)),a&2048&&Mu(s,t);break;case 24:Pu(e,t,n,r),a&2048&&Nu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Vl(a.child,!0),Vl(t.child,!0))),Pu(e,t,n,r);break;default:Pu(e,t,n,r)}}function Iu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Iu(a,o,s,c,i),hl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Iu(a,o,s,c,i)):u._visibility&2?Iu(a,o,s,c,i):Lu(a,o),i&&l&2048&&Mu(o.alternate,o);break;case 24:Iu(a,o,s,c,i),i&&l&2048&&Nu(o.alternate,o);break;default:Iu(a,o,s,c,i)}t=t.sibling}}function Lu(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Lu(n,r),i&2048&&Mu(r.alternate,r);break;case 24:Lu(n,r),i&2048&&Nu(r.alternate,r);break;default:Lu(n,r)}t=t.sibling}}var Ru=8192;function zu(e,t,n){if(e.subtreeFlags&Ru)for(e=e.child;e!==null;)Bu(e,t,n),e=e.sibling}function Bu(e,t,n){switch(e.tag){case 26:zu(e,t,n),e.flags&Ru&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&$m(n,e)):eh(n,Cu,e.memoizedState,e.memoizedProps));break;case 5:zu(e,t,n),e.flags&Ru&&(e=e.stateNode,(t&335544128)===t&&$m(n,e));break;case 3:case 4:var r=Cu;Cu=Sm(e.stateNode.containerInfo),zu(e,t,n),Cu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Ru,Ru=16777216,zu(e,t,n),Ru=r):zu(e,t,n));break;case 30:if((e.flags&Ru)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Pl===null&&(Pl=new Map),Pl.set(r,i)}zu(e,t,n);break;default:zu(e,t,n)}}function Vu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Hu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];nu=r,Gu(r,e)}Vu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Uu(e),e=e.sibling}function Uu(e){switch(e.tag){case 0:case 11:case 15:Hu(e),e.flags&2048&&gl(9,e,e.return);break;case 3:Hu(e);break;case 12:Hu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Wu(e)):Hu(e);break;default:Hu(e)}}function Wu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];nu=r,Gu(r,e)}Vu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:gl(8,t,t.return),Wu(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Wu(t));break;default:Wu(t)}e=e.sibling}}function Gu(e,t){for(;nu!==null;){var n=nu;switch(n.tag){case 0:case 11:case 15:gl(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Fa(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,nu=r;else a:for(n=e;nu!==null;){r=nu;var i=r.sibling,a=r.return;if(pu(r),r===n){nu=null;break a}if(i!==null){i.return=a,nu=i;break a}nu=a}}}var Ku={getCacheForType:function(e){var t=Da(Na),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Da(Na).controller.signal}},qu=typeof WeakMap==`function`?WeakMap:Map,Ju=0,Yu=null,Xu=null,Zu=0,Qu=0,$u=null,ed=!1,td=!1,nd=!1,rd=0,id=0,ad=0,od=0,sd=0,cd=0,ld=0,ud=null,dd=null,fd=!1,pd=0,md=0,hd=1/0,gd=null,_d=null,vd=0,yd=null,bd=null,xd=0,Sd=0,Cd=null,wd=null,Td=null,Ed=null,Dd=null,Od=0,kd=null;function Ad(){return Ju&2&&Zu!==0?Zu&-Zu:P.T===null?xt():Pf()}function jd(){if(cd===0){if(!(Zu&536870912)||oa){var e=at;at<<=1,!(at&3932160)&&(at=262144),cd=e}else cd=536870912}return e=V.current,e!==null&&(e.flags|=32),cd}function Md(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Ip(yi(e.memoizedProps,n))),Ed===null&&(Ed=[]),Ed.push(t.bind(null,r))}}function Nd(e,t,n){(e===Yu&&(Qu===2||Qu===9)||e.cancelPendingCommit!==null)&&(Bd(e,0),Ld(e,Zu,cd,!1)),mt(e,n),(!(Ju&2)||e!==Yu)&&(e===Yu&&(!(Ju&2)&&(od|=n),id===4&&Ld(e,Zu,cd,!1)),Ef(e))}function Pd(e,t,n){if(Ju&6)throw Error(o(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||lt(e,t),i=r?Jd(e,t):Kd(e,t,!0),a=r;do{if(i===0){td&&!r&&Ld(e,t,0,!1);break}if(n=e.current.alternate,a&&!Id(n))i=Kd(e,t,!1),a=!1;else{if(i===2){if(a=t,e.errorRecoveryDisabledLanes&a)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;i=ud;var l=c.current.memoizedState.isDehydrated;if(l&&(Bd(c,s).flags|=256),s=Kd(c,s,!1),s!==2&&s!==6){if(nd&&!l){c.errorRecoveryDisabledLanes|=a,od|=a,i=4;break a}a=dd,dd=i,a!==null&&(dd===null?dd=a:dd.push.apply(dd,a))}i=s}if(a=!1,i!==2)continue}}if(i===1){Bd(e,0),Ld(e,t,0,!0);break}a:{switch(r=e,a=i,a){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Ld(r,t,cd,!ed);break a;case 2:dd=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(i=pd+300-Ue(),10<i)){if(Ld(r,t,cd,!ed),ct(r,0,!0)!==0)break a;xd=t,r.timeoutHandle=vp(Fd.bind(null,r,n,dd,gd,fd,t,cd,od,ld,ed,a,`Throttled`,-0,0),i);break a}Fd(r,n,dd,gd,fd,t,cd,od,ld,ed,a,null,-0,0)}break}}while(1);Ef(e)}function Fd(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:xn},Pl=null,Bu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=ih.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?pd-Ue():(a&4194048)===a?md-Ue():0,m=nh(d,m),m!==null)?(xd=a,e.cancelPendingCommit=m(tf.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Ld(e,a,o,!l)):tf(e,t,a,n,r,i,o,s,c,l,u,d)}function Id(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Wr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ld(e,t,n,r){t=ut(e,t),t&=~sd,t&=~od,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-et(i),o=1<<a;r[a]=-1,i&=~o}n!==0&>(e,n,t)}function Rd(){return Ju&6?!0:(Df(0,!1),!1)}function zd(){if(Xu!==null){if(Qu===0)var e=Xu.return;else e=Xu,ya=va=null,es(e),ao=null,oo=0,e=Xu;for(;e!==null;)ml(e.alternate,e),e=e.return;Xu=null}}function Bd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,yp(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),xd=0,zd(),Yu=e,Xu=n=Ii(e.current,null),Zu=t,Qu=0,$u=null,ed=!1,td=lt(e,t),nd=!1,ld=cd=sd=od=ad=id=0,dd=ud=null,fd=!1,rd=ut(e,t),Ei(),n}function Vd(e,t){Ro=null,P.H=cc,t===Xa||t===Qa?(t=io(),Qu=3):t===Za?(t=io(),Qu=4):Qu=t===Tc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,$u=t,Xu===null&&(id=1,yc(e,Wi(t,e.current)))}function Hd(){var e=V.current;return e===null?!0:(Zu&4194048)===Zu?H===null:(Zu&62914560)===Zu||Zu&536870912?e===H:!1}function Ud(){var e=P.H;return P.H=cc,e===null?cc:e}function Wd(){var e=P.A;return P.A=Ku,e}function Gd(){id=4,ed||(Zu&4194048)!==Zu&&V.current!==null||(td=!0),!(ad&134217727)&&!(od&134217727)||Yu===null||Ld(Yu,Zu,cd,!1)}function Kd(e,t,n){var r=Ju;Ju|=2;var i=Ud(),a=Wd();(Yu!==e||Zu!==t)&&(gd=null,Bd(e,t)),t=!1;var o=id;a:do try{if(Qu!==0&&Xu!==null){var s=Xu,c=$u;switch(Qu){case 8:zd(),o=6;break a;case 3:case 2:case 9:case 6:V.current===null&&(t=!0);var l=Qu;if(Qu=0,$u=null,Qd(e,s,c,l),n&&td){o=0;break a}break;default:l=Qu,Qu=0,$u=null,Qd(e,s,c,l)}}qd(),o=id;break}catch(t){Vd(e,t)}while(1);return t&&e.shellSuspendCounter++,ya=va=null,Ju=r,P.H=i,P.A=a,Xu===null&&(Yu=null,Zu=0,Ei()),o}function qd(){for(;Xu!==null;)Xd(Xu)}function Jd(e,t){var n=Ju;Ju|=2;var r=Ud(),i=Wd();Yu!==e||Zu!==t?(gd=null,hd=Ue()+500,Bd(e,t)):td=lt(e,t);a:do try{if(Qu!==0&&Xu!==null){t=Xu;var a=$u;b:switch(Qu){case 1:Qu=0,$u=null,Qd(e,t,a,1);break;case 2:case 9:if(eo(a)){Qu=0,$u=null,Zd(t);break}t=function(){Qu!==2&&Qu!==9||Yu!==e||(Qu=7),Ef(e)},a.then(t,t);break a;case 3:Qu=7;break a;case 4:Qu=5;break a;case 7:eo(a)?(Qu=0,$u=null,Zd(t)):(Qu=0,$u=null,Qd(e,t,a,7));break;case 5:var s=null;switch(Xu.tag){case 26:s=Xu.memoizedState;case 5:case 27:var c=Xu;if(s?Zm(s):c.stateNode.complete){Qu=0,$u=null;var l=c.sibling;if(l!==null)Xu=l;else{var u=c.return;u===null?Xu=null:(Xu=u,$d(u))}break b}}Qu=0,$u=null,Qd(e,t,a,5);break;case 6:Qu=0,$u=null,Qd(e,t,a,6);break;case 8:zd(),id=6;break a;default:throw Error(o(462))}}Yd();break}catch(t){Vd(e,t)}while(1);return ya=va=null,P.H=r,P.A=i,Ju=n,Xu===null?(Yu=null,Zu=0,Ei(),id):0}function Yd(){for(;Xu!==null&&!Ve();)Xd(Xu)}function Xd(e){var t=al(e.alternate,e,rd);e.memoizedProps=e.pendingProps,t===null?$d(e):Xu=t}function Zd(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=zc(n,t,t.pendingProps,t.type,void 0,Zu);break;case 11:t=zc(n,t,t.pendingProps,t.type.render,t.ref,Zu);break;case 5:es(t);var r=t;r===aa&&(oa?(fa(r),r.tag===5&&r.stateNode!=null&&(R=r.stateNode)):(fa(r),oa=!0));default:ml(n,t),t=Xu=Li(t,rd),t=al(n,t,rd)}e.memoizedProps=e.pendingProps,t===null?$d(e):Xu=t}function Qd(e,t,n,r){ya=va=null,es(t),ao=null,oo=0;var i=t.return;try{if(wc(e,i,t,n,Zu)){id=1,yc(e,Wi(n,e.current)),Xu=null;return}}catch(t){if(i!==null)throw Xu=i,t;id=1,yc(e,Wi(n,e.current)),Xu=null;return}t.flags&32768?(oa||r===1?e=!0:td||Zu&536870912?e=!1:(ed=e=!0,(r===2||r===9||r===3||r===6)&&(r=V.current,r!==null&&r.tag===13&&(r.flags|=16384))),ef(t,e)):$d(t)}function $d(e){var t=e;do{if(t.flags&32768){ef(t,ed);return}e=t.return;var n=fl(t.alternate,t,rd);if(n!==null){Xu=n;return}if(t=t.sibling,t!==null){Xu=t;return}Xu=t=e}while(t!==null);id===0&&(id=5)}function ef(e,t){do{var n=pl(e.alternate,e);if(n!==null){n.flags&=32767,Xu=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Xu=e;return}Xu=e=n}while(e!==null);id=6,Xu=null}function tf(e,t,n,r,i,a,s,c,l,u,d,f){e.cancelPendingCommit=null;do uf();while(vd!==0);if(Ju&6)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));e===Yu&&(Xu=Yu=null,Zu=0),bd=t,yd=e,xd=n,Cd=i,wd=r,nf(e,t,n,s,c,l,f)}}function nf(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(Sd=s,s|=Ti,ht(e,n,s,r,i,a),Ed=null,(n&335544064)===n?(Dd=Ra(e),r=10262):(Dd=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,yf(qe,function(){return df(),null})):(e.callbackNode=null,e.callbackPriority=0),Nl=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=P.T,P.T=null,i=_e.p,_e.p=2,a=Ju,Ju|=4;try{su(e,t,n)}finally{Ju=a,_e.p=i,P.T=r}}vd=1,Nl?Td=Pp(o,e.containerInfo,Dd,of,sf,af,cf,df,rf,null,null):(of(),sf(),cf())}function rf(e){if(vd!==0){var t=yd.onRecoverableError;t(e,{componentStack:null})}}function af(){vd===3&&(vd=0,Ou(bd,yd),vd=4)}function of(){if(vd===1){vd=0;var e=yd,t=bd,n=xd,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=P.T,P.T=null;var i=_e.p;_e.p=2;var a=Ju;Ju|=4;try{iu=au=!1,wu(t,e,n),n=up;var o=Xr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Yr(s.ownerDocument.documentElement,s)){if(c!==null&&Zr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Jr(s,h),v=Jr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}vh=!!lp,up=lp=null}finally{Ju=a,_e.p=i,P.T=r}}e.current=t,vd=2}}function sf(){if(vd===2){vd=0;var e=yd,t=bd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=P.T,P.T=null;var r=_e.p;_e.p=2;var i=Ju;Ju|=4;try{lu(e,t.alternate,t)}finally{Ju=i,_e.p=r,P.T=n}}vd=3}}function cf(){if(vd===4||vd===3){vd=0;var e=Td;Td=null,He();var t=yd,n=bd,r=xd,i=wd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?vd=5:(vd=0,bd=yd=null,lf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(_d=null),bt(r),n=n.stateNode,Qe&&typeof Qe.onCommitFiberRoot==`function`)try{Qe.onCommitFiberRoot(I,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=P.T,a=_e.p,_e.p=2,P.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{P.T=n,_e.p=a}}if(i=Ed,o=Dd,Dd=null,i!==null&&(Ed=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);xd&3&&uf(),Ef(t),a=t.pendingLanes,r&261930&&a&42?t===kd?Od++:(Od=0,kd=t):(Od=0,kd=null),Df(0,!1)}}function lf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Fa(t)))}function uf(){return Td!==null&&(Td.skipTransition(),Td=null),of(),sf(),cf(),df()}function df(){if(vd!==5)return!1;var e=yd,t=Sd;Sd=0;var n=bt(xd),r=P.T,i=_e.p;try{_e.p=32>n?32:n,P.T=null,n=Cd,Cd=null;var a=yd,s=xd;if(vd=0,bd=yd=null,xd=0,Ju&6)throw Error(o(331));var c=Ju;if(Ju|=4,Uu(a.current),Fu(a,a.current,s,n),Ju=c,Df(0,!1),Qe&&typeof Qe.onPostCommitFiberRoot==`function`)try{Qe.onPostCommitFiberRoot(I,a)}catch{}return!0}finally{_e.p=i,P.T=r,lf(e,t)}}function ff(e,t,n){t=Wi(n,t),t=xc(e.stateNode,t,2),e=vo(e,t,2),e!==null&&(mt(e,2),Ef(e))}function pf(e,t,n){if(e.tag===3)ff(e,e,n);else for(;t!==null;){if(t.tag===3){ff(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(_d===null||!_d.has(r))){e=Wi(n,e),n=Sc(2),r=vo(t,n,2),r!==null&&(Cc(n,r,t,e),mt(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new qu;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(nd=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Yu===e&&(Zu&n)===n&&(id===4||id===3&&(Zu&62914560)===Zu&&300>Ue()-pd?Ju&2?sd|=n:Bd(e,0):sd|=n,ld===Zu&&(ld=0)),Ef(e)}function gf(e,t){t===0&&(t=ft()),e=ki(e,t),e!==null&&(mt(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return Be(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-et(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=Zu,a=ct(r,r===Yu?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||lt(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&_p()&&(e=Tf);for(var t=Ue(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}vd!==0&&vd!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-et(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=dt(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Yu,n=Zu,n=ct(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Qu===2||Qu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&F(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||lt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&F(r),bt(n)){case 2:case 8:n=Ke;break;case 32:n=qe;break;case 268435456:n=Ye;break;default:n=qe}return r=jf.bind(null,e),n=Be(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&F(r),e.callbackPriority=2,e.callbackNode=null,2}function jf(e,t){if(vd!==0&&vd!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(uf()&&e.callbackNode!==n)return null;var r=Zu;return r=ct(e,e===Yu?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Pd(e,r,t),Af(e,Ue()),e.callbackNode!=null&&e.callbackNode===n?jf.bind(null,e):null)}function Mf(e,t){if(uf())return null;Pd(e,t,!0)}function Nf(){Sp(function(){Ju&6?Be(Ge,Of):kf()})}function Pf(){if(Tf===0){var e=z;e===0&&(e=it,it<<=1,!(it&261888)&&(it=256)),Tf=e}return Tf}function Ff(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:bn(e)}function If(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Ff((i[Tt]||null).action),o=r.submitter;o&&(t=(t=o[Tt]||null)?Ff(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Hn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Tf!==0){var e=new FormData(i,o);Js(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),Js(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Lf=0;Lf<gi.length;Lf++){var Rf=gi[Lf];_i(Rf.toLowerCase(),`on`+(Rf[0].toUpperCase()+Rf.slice(1)))}_i(li,`onAnimationEnd`),_i(ui,`onAnimationIteration`),_i(di,`onAnimationStart`),_i(`dblclick`,`onDoubleClick`),_i(`focusin`,`onFocus`),_i(`focusout`,`onBlur`),_i(fi,`onTransitionRun`),_i(L,`onTransitionStart`),_i(pi,`onTransitionCancel`),_i(mi,`onTransitionEnd`),Ut(`onMouseEnter`,[`mouseout`,`mouseover`]),Ut(`onMouseLeave`,[`mouseout`,`mouseover`]),Ut(`onPointerEnter`,[`pointerout`,`pointerover`]),Ut(`onPointerLeave`,[`pointerout`,`pointerover`]),Ht(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Ht(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Ht(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Ht(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Ht(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Ht(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var zf=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Bf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(zf));function Vf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Si(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Si(e)}i.currentTarget=null,a=c}}}}function Hf(e,t){var n=t[Dt];n===void 0&&(n=t[Dt]=new Set);var r=e+`__bubble`;n.has(r)||(Kf(t,e,2,!1),n.add(r))}function Uf(e,t,n){var r=0;t&&(r|=4),Kf(n,e,r,t)}var Wf=`_reactListening`+Math.random().toString(36).slice(2);function Gf(e){if(!e[Wf]){e[Wf]=!0,Bt.forEach(function(t){t!==`selectionchange`&&(Bf.has(t)||Uf(t,!1,e),Uf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Wf]||(t[Wf]=!0,Uf(`selectionchange`,!1,t))}}function Kf(e,t,n,r){switch(Th(t)){case 2:var i=yh;break;case 8:i=bh;break;default:i=xh}n=i.bind(null,t,n,e),i=void 0,!jn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function qf(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=Pt(s),o===null)return;if(c=o.tag,c===5||c===6||c===26||c===27){r=a=o;continue a}s=s.parentNode}}r=r.return}On(function(){var r=a,i=Cn(n),o=[];a:{var s=hi.get(e);if(s!==void 0){var c=Hn,u=e;switch(e){case`keypress`:if(Ln(n)===0)break a;case`keydown`:case`keyup`:c=or;break;case`focusin`:u=`focus`,c=Zn;break;case`focusout`:u=`blur`,c=Zn;break;case`beforeblur`:case`afterblur`:c=Zn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:c=Yn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:c=Xn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:c=lr;break;case li:case ui:case di:c=Qn;break;case mi:c=ur;break;case`scroll`:case`scrollend`:c=Wn;break;case`wheel`:c=dr;break;case`copy`:case`cut`:case`paste`:c=$n;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:c=sr;break;case`submit`:c=cr;break;case`toggle`:case`beforetoggle`:c=fr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=kn(m,p),g!=null&&d.push(Jf(m,g,h))),f)break;m=m.return}0<d.length&&(s=new c(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,s=e===`mouseout`||e===`pointerout`,c&&n!==Sn&&(u=n.relatedTarget||n.fromElement)&&(Pt(u)||u[Et]))break a;(s||c)&&(u=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,s?(c=n.relatedTarget||n.toElement,s=r,c=c?Pt(c):null,c!==null&&(f=l(c),d=c.tag,c!==f||d!==5&&d!==27&&d!==6)&&(c=null)):(s=null,c=r),s!==c&&(d=Yn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=sr,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=s==null?u:It(s),h=c==null?u:It(c),u=new d(g,m+`leave`,s,n,i),u.target=f,u.relatedTarget=h,g=null,Pt(i)===r&&(d=new d(p,m+`enter`,c,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=s&&c?E(s,c,Xf):null,s!==null&&Zf(o,u,s,d,!1),c!==null&&f!==null&&Zf(o,f,c,d,!0)))}a:{if(s=r?It(r):window,c=s.nodeName&&s.nodeName.toLowerCase(),c===`select`||c===`input`&&s.type===`file`)var _=Mr;else if(Er(s)){if(Nr)_=Hr;else{_=Br;var v=zr}}else c=s.nodeName,!c||c.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&_n(r.elementType)&&(_=Mr):_=Vr;if(_&&=_(e,r)){Dr(o,_,n,i);break a}v&&v(e,s,r)}switch(v=r?It(r):window,e){case`focusin`:(Er(v)||v.contentEditable===`true`)&&($r=v,ei=r,ti=null);break;case`focusout`:ti=ei=$r=null;break;case`mousedown`:ni=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:ni=!1,ri(o,n,i);break;case`selectionchange`:if(Qr)break;case`keydown`:case`keyup`:ri(o,n,i)}var y;if(mr)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else Sr?br(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(_r&&n.locale!==`ko`&&(Sr||b!==`onCompositionStart`?b===`onCompositionEnd`&&Sr&&(y=In()):(Nn=i,Pn=`value`in Nn?Nn.value:Nn.textContent,Sr=!0)),v=Yf(r,b),0<v.length&&(b=new er(b,e,null,n,i),o.push({event:b,listeners:v}),y?b.data=y:(y=xr(n),y!==null&&(b.data=y)))),(y=gr?Cr(e,n):wr(e,n))&&(b=Yf(r,`onBeforeInput`),0<b.length&&(v=new er(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:v,listeners:b}),v.data=y)),If(o,e,r,n,i)}Vf(o,t)})}function Jf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Yf(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=kn(e,n),i!=null&&r.unshift(Jf(e,i,a)),i=kn(e,t),i!=null&&r.push(Jf(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Xf(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Zf(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=kn(n,a),l!=null&&o.unshift(Jf(n,l,c))):i||(l=kn(n,a),l!=null&&o.push(Jf(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Qf=/\r\n?/g,$f=/\u0000|\uFFFD/g;function ep(e){return(typeof e==`string`?e:``+e).replace(Qf,`
|
|
10
|
-
`).replace($f,``)}function tp(e,t){return t=ep(t),ep(e)===t}function np(e,t,n,r,i,a){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||pn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&pn(e,``+r);else return;break;case`className`:Zt(e,`class`,r);break;case`tabIndex`:Zt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Zt(e,n,r);break;case`style`:gn(e,r,a);return;case`data`:if(t!==`object`){Zt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=bn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof a==`function`&&(n===`formAction`?(t!==`input`&&np(e,t,`name`,i.name,i,null),np(e,t,`formEncType`,i.formEncType,i,null),np(e,t,`formMethod`,i.formMethod,i,null),np(e,t,`formTarget`,i.formTarget,i,null)):(np(e,t,`encType`,i.encType,i,null),np(e,t,`method`,i.method,i,null),np(e,t,`target`,i.target,i,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=bn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=xn);return;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=bn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Xt(e,`popover`,r);break;case`xlinkActuate`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Xt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=vn.get(n)||n,Xt(e,n,r);else return}Jt=!0}function rp(e,t,n,r,i,a){switch(n){case`style`:gn(e,r,a);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)pn(e,r);else if(typeof r==`number`||typeof r==`bigint`)pn(e,``+r);else return;break;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=xn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Vt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),a=n.slice(2,i?n.length-7:void 0),t=e[Tt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(a,t,i),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(a,r,i);break a}Jt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Xt(e,n,r)}return}Jt=!0}function ip(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Hf(`error`,e),Hf(`load`,e);var r=!1,i=!1,a;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(s!=null)switch(a){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:np(e,t,a,s,n,null)}}i&&np(e,t,`srcSet`,n.srcSet,n,null),r&&np(e,t,`src`,n.src,n,null);return;case`input`:Hf(`invalid`,e);var c=a=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:a=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(o(137,t));break;default:np(e,t,r,d,n,null)}}cn(e,a,c,l,u,s,i,!1);return;case`select`:for(i in Hf(`invalid`,e),r=s=a=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:a=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:np(e,t,i,c,n,null)}t=a,n=s,e.multiple=!!r,t==null?n!=null&&un(e,!!r,n,!0):un(e,!!r,t,!1);return;case`textarea`:for(s in Hf(`invalid`,e),a=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:a=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(o(91));break;default:np(e,t,s,c,n,null)}fn(e,r,i,a);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:np(e,t,l,r,n,null)}return;case`dialog`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Hf(`cancel`,e),Hf(`close`,e);break;case`iframe`:case`object`:Hf(`load`,e);break;case`video`:case`audio`:for(r=0;r<zf.length;r++)Hf(zf[r],e);break;case`image`:Hf(`error`,e),Hf(`load`,e);break;case`details`:Hf(`toggle`,e);break;case`embed`:case`source`:case`link`:Hf(`error`,e),Hf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:np(e,t,u,r,n,null)}return;default:if(_n(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&rp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&np(e,t,c,r,n,null))}var ap={};function op(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,a=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||np(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Jt=!0),a=m;break;case`name`:m!==f&&(Jt=!0),i=m;break;case`checked`:m!==f&&(Jt=!0),u=m;break;case`defaultChecked`:m!==f&&(Jt=!0),d=m;break;case`value`:m!==f&&(Jt=!0),s=m;break;case`defaultValue`:m!==f&&(Jt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(o(137,t));break;default:m!==f&&np(e,t,p,m,r,f)}}sn(e,s,c,l,u,d,a,i);return;case`select`:for(a in m=s=c=p=null,n)if(l=n[a],n.hasOwnProperty(a)&&l!=null)switch(a){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(a)||np(e,t,a,null,r,l)}for(i in r)if(a=r[i],l=n[i],r.hasOwnProperty(i)&&(a!=null||l!=null))switch(i){case`value`:a!==l&&(Jt=!0),p=a;break;case`defaultValue`:a!==l&&(Jt=!0),c=a;break;case`multiple`:a!==l&&(Jt=!0),s=a;default:a!==l&&np(e,t,i,a,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?un(e,!!n,n?[]:``,!1):un(e,!!n,t,!0)):un(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:np(e,t,c,null,r,i)}for(s in r)if(i=r[s],a=n[s],r.hasOwnProperty(s)&&(i!=null||a!=null))switch(s){case`value`:i!==a&&(Jt=!0),p=i;break;case`defaultValue`:i!==a&&(Jt=!0),m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(o(91));break;default:i!==a&&np(e,t,s,i,r,a)}dn(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:np(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Jt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:np(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&np(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(o(137,t));break;default:np(e,t,u,p,r,m)}return;default:if(_n(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&rp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||rp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&np(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||np(e,t,f,p,r,m)}function sp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function cp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&sp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&sp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var lp=null,up=null;function dp(e){return e.nodeType===9?e:e.ownerDocument}function fp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function pp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function mp(e,t,n,r){return n=dp(n).createElement(e),n[wt]=r,n[Tt]=t,ip(n,e,t),Rt(n),n}function hp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var gp=null;function _p(){var e=window.event;return e&&e.type===`popstate`?e!==gp&&(gp=e,!0):(gp=null,!1)}var vp=typeof setTimeout==`function`?setTimeout:void 0,yp=typeof clearTimeout==`function`?clearTimeout:void 0,bp=typeof Promise==`function`?Promise:void 0,xp=typeof requestAnimationFrame==`function`?requestAnimationFrame:vp,Sp=typeof queueMicrotask==`function`?queueMicrotask:bp===void 0?vp:function(e){return bp.resolve(null).then(e).catch(Cp)};function Cp(e){setTimeout(function(){throw e})}function wp(e){return e===`head`}function Tp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Wh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)ym(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,ym(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[jt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&ym(e.ownerDocument.body)}n=i}while(n);Wh(t)}function Ep(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Dp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Op(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function kp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Ap(e){return kp(e.getBoundingClientRect(),getComputedStyle(e),e)}function jp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return kp(t,n,e)}function Mp(e){return e.documentElement.clientHeight}function Np(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Pp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Mp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Qm(f),u>th){s.length=o;break}f=new Promise(Np.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Fp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Fp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Fp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Fp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Ip(e){return{name:e,group:new Fp(`group`,e),imagePair:new Fp(`image-pair`,e),old:new Fp(`old`,e),new:new Fp(`new`,e)}}function Lp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Lp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Hp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Bp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),h(this._fragmentFiber.child,!1,Rp,e,s,r)}this._eventListeners=a}};function Rp(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Lp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Hp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Bp(i.optionsOrUseCapture),h(this._fragmentFiber.child,!1,zp,e,n,i),r.splice(t,1),a!==null&&a()}};function zp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function Bp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Vp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Hp(e,t,n,r){if(e.length===0)return-1;r=Vp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Vp(a.optionsOrUseCapture)===r)return i}return-1}Lp.prototype.dispatchEvent=function(e){var t=g(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Lp.prototype.focus=function(e){h(this._fragmentFiber.child,!0,Up,e,void 0,void 0)};function Up(e,t){return e.tag!==6&&(e=b(e),hm(e,t))}Lp.prototype.focusLast=function(e){var t=[];h(this._fragmentFiber.child,!0,Wp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Up(t[n],e);n--);};function Wp(e,t){return t.push(e),!1}Lp.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=dp(e).activeElement,e!==null&&h(this._fragmentFiber.child,!1,Gp,e,void 0,void 0))};function Gp(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Lp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),h(this._fragmentFiber.child,!1,Kp,e,void 0,void 0)};function Kp(e,t){return e.tag===6||(e=b(e),t.observe(e)),!1}Lp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),h(this._fragmentFiber.child,!1,qp,e,void 0,void 0);for(var n=t=0;n<Jp.length;n++){var r=Jp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Jp[t++]=r}Jp.length=t}};function qp(e,t){return e.tag===6||(e=b(e),t.unobserve(e)),!1}var Jp=[],Yp=!1;function Xp(e,t,n){Jp.push({fragmentInstance:e,observer:t,instance:n}),Yp||(Yp=!0,gm(function(){Yp=!1;var e=Jp;Jp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Lp.prototype.getClientRects=function(){var e=[];return h(this._fragmentFiber.child,!1,Zp,e,void 0,void 0),e};function Zp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}Lp.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Lp.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];h(this._fragmentFiber.child,!1,Wp,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Qp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Qp(e,t,n,r,i){var a=Pt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=g(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=E(n,a,T),t===null?t=!1:(h(t,!0,C,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=E(r,a,T),t===null?t=!1:(h(t,!0,w,a,r),a=x,S=x=null,t=a!==null)),t):!1}function $p(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Lp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(o(566));var t=[];h(this._fragmentFiber.child,!1,Wp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||g(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),$p(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var i=t[r];i.tag===6?(i=b(i),$p(i,n)):b(i).scrollIntoView(e),r+=n?-1:1}};function em(e,t){return e=b(e),tm(e,t),!1}function tm(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function nm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Jp.length;i++){var a=Jp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Jp[r++]=a)}Jp.length=r,n.observe(e)}),tm(e,t))}function rm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Xp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function im(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:im(n),Nt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function am(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[jt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=dm(e.nextSibling),e===null)break}return null}function om(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=dm(e.nextSibling),e===null))return null;return e}function sm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=dm(e.nextSibling),e===null))return null;return e}function cm(e){return e.data===`$?`||e.data===`$~`}function lm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function um(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function dm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var fm=null;function pm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return dm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function mm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function hm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function gm(e){xp(function(){xp(function(t){return e(t)})})}function _m(e,t,n){switch(t=dp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(o(452));return e;case`head`:if(e=t.head,!e)throw Error(o(453));return e;case`body`:if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function vm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&np(e,t,r,null,ap,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===xn&&(e.onclick=null),Nt(e)}function ym(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Nt(e)}var bm=new Map,xm=new Set;function Sm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Cm=_e.d;_e.d={f:wm,r:Tm,D:Om,C:km,L:Am,m:jm,X:Nm,S:Mm,M:Pm};function wm(){var e=Cm.f(),t=Rd();return e||t}function Tm(e){var t=Ft(e);t!==null&&t.tag===5&&t.type===`form`?Xs(t):Cm.r(e)}var Em=typeof document>`u`?null:document;function Dm(e,t,n){var r=Em;if(r&&typeof t==`string`&&t){var i=on(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),xm.has(i)||(xm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),ip(t,`link`,e),Rt(t),r.head.appendChild(t)))}}function Om(e){Cm.D(e),Dm(`dns-prefetch`,e,null)}function km(e,t){Cm.C(e,t),Dm(`preconnect`,e,t)}function Am(e,t,n){Cm.L(e,t,n);var r=Em;if(r&&e&&t){var i=`link[rel="preload"][as="`+on(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+on(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+on(n.imageSizes)+`"]`)):i+=`[href="`+on(e)+`"]`;var a=i;switch(t){case`style`:a=Im(e);break;case`script`:a=Bm(e)}if(!(bm.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),bm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Lm(a))||t===`script`&&r.querySelector(Vm(a))))){var o=r.createElement(`link`);ip(o,`link`,e),t===`style`&&(o[Mt]=!0,o.onload=o.onerror=function(){zt(o)}),Rt(o),r.head.appendChild(o)}}}function jm(e,t){Cm.m(e,t);var n=Em;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+on(r)+`"][href="`+on(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Bm(e)}if(!bm.has(a)&&(e=D({rel:`modulepreload`,href:e},t),bm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Vm(a)))return}r=n.createElement(`link`),ip(r,`link`,e),Rt(r),n.head.appendChild(r)}}}function Mm(e,t,n){Cm.S(e,t,n);var r=Em;if(r&&e){var i=Lt(r).hoistableStyles,a=Im(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Lm(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=bm.get(a))&&Wm(e,n);var c=o=r.createElement(`link`);Rt(c),ip(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Um(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Nm(e,t){Cm.X(e,t);var n=Em;if(n&&e){var r=Lt(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Rt(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Pm(e,t){Cm.M(e,t);var n=Em;if(n&&e){var r=Lt(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Rt(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Fm(e,t,n,r){var i=(i=Ee.current)?Sm(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Im(n.href),t=Lt(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Im(n.href);var a=Lt(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(Lm(e)))?a._p||(s.instance=a,s.state.loading=5):(a=bm.get(e),a||(a={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},bm.set(e,a)),zm(i,e,a,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Bm(n),t=Lt(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Im(e){return`href="`+on(e)+`"`}function Lm(e){return`link[rel="stylesheet"][`+e+`]`}function Rm(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function zm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Mt]){r.loading=1;return}}else t=e.createElement(`link`),t[Mt]=!0,t.onload=t.onerror=zt.bind(null,t),ip(t,`link`,n),Rt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Bm(e){return`[src="`+on(e)+`"]`}function Vm(e){return`script[async]`+e}function Hm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+on(n.href)+`"]`);if(r)return t.instance=r,Rt(r),r;var i=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Rt(r),ip(r,`style`,i),Um(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Im(n.href);var a=e.querySelector(Lm(i));if(a)return t.state.loading|=4,t.instance=a,Rt(a),a;r=Rm(n),(i=bm.get(i))&&Wm(r,i),a=(e.ownerDocument||e).createElement(`link`),Rt(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ip(a,`link`,r),t.state.loading|=4,Um(a,n.precedence,e),t.instance=a;case`script`:return a=Bm(n.src),(i=e.querySelector(Vm(a)))?(t.instance=i,Rt(i),i):(r=n,(i=bm.get(a))&&(r=D({},n),Gm(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Rt(i),ip(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Um(r,n.precedence,e));return t.instance}function Um(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Wm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Gm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Km=null;function qm(e,t,n){if(Km===null){var r=new Map,i=Km=new Map;i.set(n,r)}else i=Km,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[jt]||a[wt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Jm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Ym(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Xm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Zm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Qm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function $m(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Qm(t),e.suspenseyImages.push(t)),e=ah.bind(e),t.decode().then(e,e))}function eh(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Im(r.href),a=t.querySelector(Lm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ih.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Rt(a);return}a=t.ownerDocument||t,r=Rm(r),(i=bm.get(i))&&Wm(r,i),a=a.createElement(`link`),Rt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ip(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ih.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var th=0;function nh(e,t){return e.stylesheets&&e.count===0&&sh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&th===0&&(th=62500*cp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>th?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function rh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)sh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function ih(){this.count--,rh(this)}function ah(){this.imgCount--,rh(this)}var oh=null;function sh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oh=new Map,t.forEach(ch,e),oh=null,ih.call(e))}function ch(e,t){if(!(t.state.loading&4)){var n=oh.get(e);if(n)var r=n.get(null);else{n=new Map,oh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=ih.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var lh={$$typeof:N,Provider:null,Consumer:null,_currentValue:ve,_currentValue2:ve,_threadCount:0};function uh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pt(0),this.hiddenUpdates=pt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function dh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new uh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Pi(3,null,null,t),e.current=a,a.stateNode=e,t=Pa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ho(a),e}function fh(e){return e?(e=Mi,e):Mi}function ph(e,t,n,r,i,a){i=fh(i),r.context===null?r.context=i:r.pendingContext=i,r=_o(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=vo(e,r,t),n!==null&&(Nd(n,e,t),yo(n,e,t))}function mh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function hh(e,t){mh(e,t),(e=e.alternate)&&mh(e,t)}function gh(e){if(e.tag===13||e.tag===31){var t=ki(e,67108864);t!==null&&Nd(t,e,67108864),hh(e,67108864)}}function _h(e){if(e.tag===13||e.tag===31){var t=Ad();t=yt(t);var n=ki(e,t);n!==null&&Nd(n,e,t),hh(e,t)}}var vh=!0;function yh(e,t,n,r){var i=P.T;P.T=null;var a=_e.p;try{_e.p=2,xh(e,t,n,r)}finally{_e.p=a,P.T=i}}function bh(e,t,n,r){var i=P.T;P.T=null;var a=_e.p;try{_e.p=8,xh(e,t,n,r)}finally{_e.p=a,P.T=i}}function xh(e,t,n,r){if(vh){var i=Sh(r);if(i===null)qf(e,t,r,Ch,n),Ph(e,r);else if(Ih(i,e,t,n,r))r.stopPropagation();else if(Ph(e,r),t&4&&-1<Nh.indexOf(e)){for(;i!==null;){var a=Ft(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=st(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-et(o);s.entanglements[1]|=c,o&=~c}Ef(a),!(Ju&6)&&(hd=Ue()+500,Df(0,!1))}}break;case 31:case 13:s=ki(a,2),s!==null&&Nd(s,a,2),Rd(),hh(a,2)}if(a=Sh(r),a===null&&qf(e,t,r,Ch,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else qf(e,t,r,null,n)}}function Sh(e){return e=Cn(e),wh(e)}var Ch=null;function wh(e){if(Ch=null,e=Pt(e),e!==null){var t=l(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=u(t),e!==null)return e;e=null}else if(n===31){if(e=d(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ch=e,null}function Th(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(We()){case Ge:return 2;case Ke:return 8;case qe:case Je:return 32;case Ye:return 268435456;default:return 32}default:return 32}}var Eh=!1,Dh=null,Oh=null,kh=null,Ah=new Map,jh=new Map,Mh=[],Nh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Ph(e,t){switch(e){case`focusin`:case`focusout`:Dh=null;break;case`dragenter`:case`dragleave`:Oh=null;break;case`mouseover`:case`mouseout`:kh=null;break;case`pointerover`:case`pointerout`:Ah.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:jh.delete(t.pointerId)}}function Fh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Ft(t),t!==null&&gh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ih(e,t,n,r,i){switch(t){case`focusin`:return Dh=Fh(Dh,e,t,n,r,i),!0;case`dragenter`:return Oh=Fh(Oh,e,t,n,r,i),!0;case`mouseover`:return kh=Fh(kh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Ah.set(a,Fh(Ah.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,jh.set(a,Fh(jh.get(a)||null,e,t,n,r,i)),!0}return!1}function Lh(e){var t=Pt(e.target);if(t!==null){var n=l(t);if(n!==null){if(t=n.tag,t===13){if(t=u(n),t!==null){e.blockedOn=t,St(e.priority,function(){_h(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,St(e.priority,function(){_h(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Rh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Sh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Sn=r,n.target.dispatchEvent(r),Sn=null}else return t=Ft(n),t!==null&&gh(t),e.blockedOn=n,!1;t.shift()}return!0}function zh(e,t,n){Rh(e)&&n.delete(t)}function Bh(){Eh=!1,Dh!==null&&Rh(Dh)&&(Dh=null),Oh!==null&&Rh(Oh)&&(Oh=null),kh!==null&&Rh(kh)&&(kh=null),Ah.forEach(zh),jh.forEach(zh)}function Vh(e,n){e.blockedOn===n&&(e.blockedOn=null,Eh||(Eh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Bh)))}var Hh=null;function Uh(e){Hh!==e&&(Hh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Hh===e&&(Hh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(wh(r||n)===null)continue;break}var a=Ft(n);a!==null&&(e.splice(t,3),t-=3,Js(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Wh(e){function t(t){return Vh(t,e)}Dh!==null&&Vh(Dh,e),Oh!==null&&Vh(Oh,e),kh!==null&&Vh(kh,e),Ah.forEach(t),jh.forEach(t);for(var n=0;n<Mh.length;n++){var r=Mh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Mh.length&&(n=Mh[0],n.blockedOn===null);)Lh(n),n.blockedOn===null&&Mh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Tt]||null;if(typeof a==`function`)o||Uh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Tt]||null)s=o.formAction;else if(wh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Uh(n)}}}function Gh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Kh(e){this._internalRoot=e}qh.prototype.render=Kh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current;ph(n,Ad(),e,t,null,null)},qh.prototype.unmount=Kh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ph(e.current,2,null,e,null,null),Rd(),t[Et]=null}};function qh(e){this._internalRoot=e}qh.prototype.unstable_scheduleHydration=function(e){if(e){var t=xt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Mh.length&&t!==0&&t<Mh[n].priority;n++);Mh.splice(n,0,e),n===0&&Lh(e)}};var Jh=n.version;if(Jh!==`19.3.1`)throw Error(o(527,Jh,`19.3.1`));_e.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(o(188)):(e=Object.keys(e).join(`,`),Error(o(268,e)));return e=p(t),e=e===null?null:m(e),e=e===null?null:e.stateNode,e};var Yh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Xh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xh.isDisabled&&Xh.supportsFiber)try{I=Xh.inject(Yh),Qe=Xh}catch{}}e.createRoot=function(e,t){if(!c(e))throw Error(o(299));var n=!1,r=``,i=gc,a=_c,s=vc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=dh(e,1,!1,null,null,n,r,null,i,a,s,Gh),e[Et]=t.current,Gf(e),new Kh(t)}})),l=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=c()})),u=e(r(),1),d=l(),f=`entry`,p=`sp-remote:`;function m(e,t){return e===`entry`?t:`${p}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function h(e){if(!e.startsWith(p))return{server:f,id:e};let t=e.indexOf(`:`,10);if(t<0)throw Error(`服务器资源标识无效`);return{server:decodeURIComponent(e.slice(10,t)),id:decodeURIComponent(e.slice(t+1))}}function g(e,t){if(!t.startsWith(p))return t;let n=h(t);if(n.server!==e)throw Error(`图片不属于此服务器,请在当前会话重新上传`);return n.id}var _=new Set([`workspaceId`,`conversationId`,`contextConversationId`,`messageId`,`sessionId`,`runId`,`taskId`,`parentConversationId`,`originMessageId`,`followedWorktreeId`,`worktreeOf`,`ownerConversationId`,`parentRunId`,`projectId`,`roomId`,`topicId`,`entityId`,`sourceConversationId`,`targetConversationId`,`forkedId`,`checkoutId`,`replyToMessageId`,`parentMessageId`,`replyTo`,`activate`]),v=new Set([`workspaces`,`conversations`,`messages`,`subagentRuns`,`backgroundTasks`,`workflows`,`scheduledTasks`,`warmSessions`,`rooms`,`topics`,`run`,`workflow`,`room`,`task`,`conversation`,`workspace`,`withdrawn`,`terminals`,`sessions`,`tools`,`projects`]),y=new Set([`collapsedConversationIds`,`unlockedChildConversationIds`,`stoppingConversationIds`,`conversationIds`,`workspaceIds`,`messageIds`]),b=new Set([`todosByConversation`,`pendingUserDecisionsByConversation`]),x=new Set([`args`,`arguments`,`parameters`,`schema`,`result`,`providers`,`images`,`attachments`,`toolCalls`,`defaultModel`,`model`,`agents`]);function S(e,t,n=``){return Array.isArray(e)?e.map(e=>S(e,t,n)):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([r,i])=>typeof i==`string`&&i.length>0&&(_.has(r)||(r===`id`||r===`execution`)&&i.startsWith(p)||r===`id`&&(v.has(n)||`workspaceId`in e||`conversationId`in e||e.type===`group.activity`))?[r,t(i)]:y.has(r)&&Array.isArray(i)?[r,i.map(e=>typeof e==`string`?t(e):e)]:b.has(r)&&i&&typeof i==`object`?[r,Object.fromEntries(Object.entries(i).map(([e,n])=>[t(e),n]))]:x.has(r)?[r,i]:[r,S(i,t,r)]))}function C(e){let t=new Set;return S(e,e=>(t.add(h(e).server),e)),t}var w=`super-pi.server-connections.v1`,T=`super-pi.server-credentials.v1`,E=(e,t)=>globalThis.fetch(e,t),D=typeof location>`u`?`http://localhost`:location.origin,O=[{id:f,name:`当前入口`,url:D,enabled:!0}],k={};try{let e=JSON.parse(localStorage.getItem(w)??`[]`);O=[{...O[0],name:e.find(e=>e.id===`entry`)?.name||`当前入口`},...e.filter(e=>e.id!==f)],k=JSON.parse(localStorage.getItem(T)??`{}`)}catch{}var A=f,j=f,ee=!1,M={};function te(e){let t=Object.fromEntries(e.map(e=>[e.id,e.enabled?e.modelTransport===`direct`?e.modelChannel===`online`?`已连接 · 服务端口`:`正在连接服务端口`:e.modelChannel===`online`?`已连接`:e.modelChannelPaused?`已暂停`:e.ssh===`awaitingVerification`?`等待 SSH 验证`:e.ssh===`connecting`?`正在恢复`:`未连接`:`已停用`]));JSON.stringify(t)!==JSON.stringify(M)&&(M=t,ce())}var N=new Map,ne=new Set;function re(e){if(!e)return!1;let t=h(e).server;return O.some(e=>e.id===t)&&!ne.has(t)}var ie=0,ae=new Set,oe=new Map,se=new Map,ce=()=>{ie++;for(let e of ae)e()},le=e=>(ae.add(e),()=>{ae.delete(e)});function ue(){return(0,u.useSyncExternalStore)(le,()=>ie),{connections:O,statuses:oe,modelChannels:M,activeServer:A,settingsServer:j,settingsSnapshot:N.get(j)}}function de(e){return e?h(e).server:A}function fe(){return A}function pe(){return j}function me(e){if(!O.some(t=>t.id===e))throw Error(`目标服务器已移除`);j!==e&&(j=e,ce(),window.dispatchEvent(new Event(`super-pi-settings-server`)))}function he(){ee=!0,me(A)}function ge(){ee=!1,me(A)}function P(e){return O.find(t=>t.id===e)?.name??`未知服务器`}function _e(e){return P(h(e).server)}function ve(e){if(e!==A){if(!O.some(t=>t.id===e))throw Error(`服务器已被移除`);A=e,ee||me(e),ce(),window.dispatchEvent(new Event(`super-pi-active-server`))}}function ye(){localStorage.setItem(w,JSON.stringify(O)),localStorage.setItem(T,JSON.stringify(k)),ce(),window.dispatchEvent(new Event(`super-pi-server-connections`))}function be(e,t){if(!t.trim())throw Error(`服务器名称不能为空`);if(O.some(n=>n.id!==e&&n.name===t.trim()))throw Error(`服务器名称已存在,请使用容易区分的名称`);O=O.map(n=>n.id===e?{...n,name:t.trim()}:n),ye()}function xe(e){if(e===`entry`)return;let t=A===e;O=O.filter(t=>t.id!==e),delete k[e],se.delete(e),t&&(A=f),j===e&&me(f),ye(),t&&window.dispatchEvent(new Event(`super-pi-active-server`))}function Se(e,t){O=O.map(n=>n.id===e?{...n,enabled:t}:n),ye()}async function Ce(e,t,n){let r=new URL(t);if(![`http:`,`https:`].includes(r.protocol)||r.username||r.password||r.search||r.hash||r.pathname!==`/`)throw Error(`请输入 http(s)://主机:端口,不能包含路径或凭证`);if(location.protocol===`https:`&&r.protocol===`http:`)throw Error(`HTTPS 页面无法连接 HTTP 服务,请为目标服务启用 HTTPS,或从 HTTP 入口访问`);if(!e.trim()||!n.trim())throw Error(`请填写服务器名称和连接密钥`);if(O.some(t=>t.name===e.trim()))throw Error(`服务器名称已存在,请使用不同的名称`);let i=await we(r.origin,n.trim());if(!i.ok)throw Error(`连接失败(${i.status}),请检查服务版本、地址和连接密钥`);let a=await i.json();if(a.protocol!==1||typeof a.id!=`string`)throw Error(`目标服务不支持多服务端协议,请先更新目标服务`);if(O.some(e=>e.url===r.origin||e.identity===a.id))throw Error(`这台服务器已经添加`);let o=await E(`/api/browser-access`).then(e=>e.json()).catch(()=>void 0);if(a.id===o?.id)throw Error(`这是当前入口服务器,无需重复添加`);let s=crypto.randomUUID();return k[s]=n.trim(),O=[...O,{id:s,name:e.trim(),url:r.origin,enabled:!0,identity:a.id}],ye(),s}async function we(e,t){try{return await E(`${e}/api/browser-access`,{headers:{authorization:`Bearer ${t}`},signal:AbortSignal.timeout(15e3),credentials:`omit`})}catch(e){throw Error(e instanceof Error&&e.name===`TimeoutError`?`连接超时,请检查目标服务器是否启动、端口是否开放`:`浏览器无法连接目标服务器,请检查地址、网络可达性、HTTPS 证书,以及目标是否已更新到支持多服务端的版本`)}}async function Te(e,t,n,r){let i=Ee(e),a=new URL(n);if(![`http:`,`https:`].includes(a.protocol)||a.username||a.password||a.search||a.hash||a.pathname!==`/`)throw Error(`请输入不包含路径或凭证的 HTTP(S) 服务地址`);if(location.protocol===`https:`&&a.protocol===`http:`)throw Error(`HTTPS 页面不能连接 HTTP 服务`);if(!t.trim())throw Error(`请输入服务器名称`);if(O.some(n=>n.id!==e&&n.name===t.trim()))throw Error(`服务器名称已存在`);let o=r.trim()||k[e],s=await we(a.origin,o);if(!s.ok)throw Error(`连接失败(${s.status}),请检查地址和密钥`);let c=await s.json();if(c.protocol!==1||c.id!==i.identity)throw Error(`地址指向另一台服务器,请使用“添加服务器”,以保护现有资源和标签的归属`);k[e]=o,O=O.map(n=>n.id===e?{...n,name:t.trim(),url:a.origin,revision:(n.revision??0)+1}:n),se.delete(e),ye()}function Ee(e){let t=O.find(t=>t.id===e);if(!t||!t.enabled)throw Error(`目标服务器已移除或停用,操作未发送`);return t}function De(e,t){return new URL(`${e.url.replace(/\/$/,``)}${t.startsWith(`/`)?t:`/${t}`}`)}async function Oe(){try{let e=await E(`/api/managed-servers`,{signal:AbortSignal.timeout(8e3)});if(!e.ok){te([]);return}let t=await e.json();if(te(Array.isArray(t.profiles)?t.profiles:[]),!t.available||!Array.isArray(t.connections))return;let n=t.connections.map(e=>({...e,url:new URL(e.url,D).href})),r=[...O.filter(e=>!e.managed),...n];if(JSON.stringify(r)!==JSON.stringify(O)){O=r;let e=!O.some(e=>e.id===A);e&&(A=f),O.some(e=>e.id===j)||me(f),ye(),e&&window.dispatchEvent(new Event(`super-pi-active-server`))}}catch{te([])}}function ke(e,t=A){let n=C(e);if(n.size>1)throw Error(`一次操作不能混用不同服务器的资源`);return[...n][0]??t}function Ae(e,t){return S(e,e=>{let n=h(e);if(n.server!==t)throw Error(`资源不属于目标服务器`);return n.id})}function je(e){let t=/^(\/api\/upload\/|\/api\/projects\/|\/tools\/)([^/]+)(.*)$/.exec(e.pathname);if(!t)return{path:e.pathname};let n=h(decodeURIComponent(t[2])),r=t[3];return t[1]===`/api/upload/`&&/^\/[^/]+$/.test(r)&&(r=`/${encodeURIComponent(g(n.server,decodeURIComponent(r.slice(1))))}`),{server:n.server,path:`${t[1]}${encodeURIComponent(n.id)}${r}`}}function Me(e){let t=new URL(e,location.origin);if(O.some(e=>e.managed&&t.href.startsWith(`${e.url}/`))||t.origin!==location.origin)return e;let n=Object.fromEntries(t.searchParams),r=je(t),i=ke(n,r.server??A),a=Ee(i);for(let[e,r]of Object.entries(Ae(n,i)))t.searchParams.set(e,r);if(i===`entry`)return`${r.path}${t.search}${t.hash}`;let o=De(a,`${r.path}${t.search}${t.hash}`),s=se.get(i);return s&&!a.managed&&o.searchParams.set(`browserAsset`,s),o.href}async function Ne(e,t,n){if(typeof e!=`string`&&!(e instanceof URL))throw Error(`服务器请求必须使用明确的 URL`);let r=new URL(String(e),location.origin),i=O.find(e=>e.managed&&r.href.startsWith(`${e.url}/`));if(i){if(n&&n!==i.id)throw Error(`资源不属于指定的服务器`);return Fe(i.id,r,t)}if(r.origin!==location.origin){let n=O.find(e=>e.url===r.origin);return n?(r.searchParams.delete(`browserAsset`),Fe(n.id,r,t)):E(e,t)}if(!r.pathname.startsWith(`/api/`))return E(e,t);let a;if(typeof t?.body==`string`)try{a=JSON.parse(t.body)}catch{}t?.body instanceof FormData&&(a=Object.fromEntries([...t.body].filter(([,e])=>typeof e==`string`)));let o=je(r),s=ke({...Object.fromEntries(r.searchParams),payload:a},o.server??n??A);if(n&&n!==s)throw Error(`资源不属于指定的服务器`);if(o.server&&o.server!==s)throw Error(`路径和参数属于不同服务器`);let c=Ee(s);for(let[e,t]of Object.entries(Ae(Object.fromEntries(r.searchParams),s)))r.searchParams.set(e,t);let l=t;if(typeof t?.body==`string`&&a&&(l={...t,body:JSON.stringify(Ae(a,s))}),t?.body instanceof FormData){let e=new FormData,n=Ae(a,s);for(let[r,i]of t.body)e.append(r,typeof i==`string`?n[r]:i);l={...t,body:e}}return Fe(s,De(c,`${o.path}${r.search}`),l)}function Pe(e,t){return Ne(e,t,j)}async function Fe(e,t,n){let r=Ee(e),i=new Headers(n?.headers);e!==`entry`&&!r.managed&&i.set(`authorization`,`Bearer ${k[e]??``}`);let a=await E(e===`entry`?`${t.pathname}${t.search}`:t.href,{...n,headers:i,...e!==`entry`&&!r.managed?{credentials:`omit`}:{}});if(e===`entry`||!a.headers.get(`content-type`)?.includes(`application/json`))return a;let o=a.json.bind(a);return a.json=async()=>S(await o(),t=>m(e,t)),a}var Ie=new Set([`model.catalog`,`model.catalog.all`,`providers.list`,`agent.catalog`,`prompt.catalog`,`subagent.catalog`,`server.version`,`terminal.status`,`exec.status`]),Le=class{focus;onserveropen=null;ondisconnect=null;onopen=null;onclose=null;onmessage=null;onerror=null;sockets=new Map;snapshots=new Map;catalogs=new Map;timers=new Map;connecting=new Set;socketRevisions=new Map;leaseTimers=new Map;terminalServer=f;stopped=!1;constructor(e){this.focus=e,window.addEventListener(`super-pi-server-connections`,this.reconfigure),window.addEventListener(`super-pi-active-server`,this.activate),window.addEventListener(`super-pi-settings-server`,this.activateSettings),queueMicrotask(this.reconfigure),Oe(),this.managementTimer=setInterval(()=>{Oe()},3e3)}managementTimer;get readyState(){return this.sockets.get(A)?.readyState??WebSocket.CLOSED}deliver(e){this.onmessage?.({data:JSON.stringify(e)})}aggregate(){let e=this.snapshots.get(A),t=[...this.snapshots.values()],n={...e,workspaces:t.flatMap(e=>e.workspaces),conversations:t.flatMap(e=>e.conversations),subagentRuns:t.flatMap(e=>e.subagentRuns)};for(let e of[`backgroundTasks`,`workflows`,`scheduledTasks`,`warmSessions`,`extensionUi`,`stoppingConversationIds`,`collapsedConversationIds`,`unlockedChildConversationIds`])n[e]=t.flatMap(t=>t[e]??[]);for(let e of[`todosByConversation`,`pendingUserDecisionsByConversation`])n[e]=Object.assign({},...t.map(t=>t[e]));t.length&&this.deliver({type:`state`,state:n})}activate=()=>{this.aggregate(),this.deliver({type:`server.version`,version:{runningVersion:``,diskVersion:``,needsRestart:!1}});let e={source:`unavailable`,models:[],levels:[],agents:[],problems:[],directory:``,prompts:[],workspaceId:``,skills:[],commands:[],fetchedAt:new Date().toISOString()};for(let t of[`model.catalog`,`model.catalog.all`,`agent.catalog`,`subagent.catalog`,`prompt.catalog`])this.deliver({type:t,catalog:e});for(let[e,t]of this.catalogs.get(A)??[])[`providers.list`,`model.catalog.all`].includes(e)||this.deliver({...t,sourceServerId:A});let t=this.sockets.get(A);if(t?.readyState===WebSocket.OPEN){this.onopen?.();for(let e of[`catalog.fetch`,`agent.catalog.fetch`,`subagent.catalog.fetch`])t.send(JSON.stringify({type:e}))}this.activateSettings()};activateSettings=()=>{for(let e of[`agent.catalog`,`subagent.catalog`])this.deliver({type:e,catalog:{source:`unavailable`,agents:[],problems:[],directory:``,fetchedAt:``},sourceServerId:j});this.deliver({type:`model.catalog.all`,catalog:{source:`unavailable`,models:[],levels:[],fetchedAt:``},sourceServerId:j}),this.deliver({type:`providers.list`,providers:[],apis:[],sourceServerId:j});for(let[e,t]of this.catalogs.get(j)??[])[`providers.list`,`model.catalog.all`,`agent.catalog`,`subagent.catalog`].includes(e)&&this.deliver({...t,sourceServerId:j});let e=this.sockets.get(j);if(e?.readyState===WebSocket.OPEN)for(let t of[`catalog.fetchAll`,`providers.fetch`,`agent.catalog.fetch`,`subagent.catalog.fetch`])e.send(JSON.stringify({type:t}))};reconfigure=()=>{for(let e of this.snapshots.keys())O.some(t=>t.id===e)||(this.snapshots.delete(e),N.delete(e),this.catalogs.delete(e),oe.delete(e),ne.delete(e));for(let[e,t]of this.sockets)O.some(t=>t.id===e&&t.enabled&&(t.revision??0)===this.socketRevisions.get(e))||(this.sockets.delete(e),t.close(),clearInterval(this.leaseTimers.get(e)),this.leaseTimers.delete(e),O.some(t=>t.id===e)||(this.snapshots.delete(e),ne.delete(e)));for(let e of O)e.enabled||oe.set(e.id,{state:`disabled`}),e.enabled&&!this.sockets.has(e.id)&&!this.connecting.has(e.id)&&this.connect(e.id);this.aggregate()};async connect(e,t=0){if(!(this.stopped||this.sockets.has(e)||!O.some(t=>t.id===e&&t.enabled))){this.connecting.add(e),oe.set(e,{state:`connecting`}),ce();try{let n=Ee(e);if(e!==`entry`){let t=await Fe(e,De(n,`/api/browser-access`),{signal:AbortSignal.timeout(15e3)});if(!t.ok)throw Error(`授权或连接失败(${t.status})`);let r=await t.json();if(r.id!==n.identity||r.protocol!==1)throw Error(`服务器身份或协议发生变化,请重新添加连接`);se.set(e,r.assetLease)}if(this.stopped||!O.some(t=>t.id===e&&t.enabled))return;let r=De(n,`/ws?state=focused`);r.protocol=r.protocol===`https:`?`wss:`:`ws:`,this.focus&&h(this.focus).server===e&&r.searchParams.set(`conversationId`,h(this.focus).id);let i=e===`entry`||n.managed?new WebSocket(r):new WebSocket(r,[`super-pi`,`super-pi-key.${k[e]}`]),a=!1;this.sockets.set(e,i),this.socketRevisions.set(e,n.revision??0),i.onopen=()=>{a=!0,oe.set(e,{state:`online`}),ce(),i.send(JSON.stringify({type:`stream.configure`,coalesce:!0})),e===A&&this.onopen?.(),this.onserveropen?.(e),e!==`entry`&&this.leaseTimers.set(e,setInterval(()=>{Fe(e,De(n,`/api/browser-access`)).then(e=>e.json()).then(t=>{t.assetLease&&(se.set(e,t.assetLease),ce())}).catch(()=>{})},9e5))},i.onmessage=({data:t})=>{let n=S(JSON.parse(String(t)),t=>m(e,t));if(n.type===`state`)ne.add(e),this.snapshots.set(e,n.state),N.set(e,n.state),this.aggregate();else{if(Ie.has(n.type)){let t=this.catalogs.get(e)??new Map;t.set(n.type,n),this.catalogs.set(e,t);let r=[`providers.list`,`model.catalog.all`].includes(n.type),i=[`agent.catalog`,`subagent.catalog`].includes(n.type);if(r?e!==j:e!==A&&!(i&&e===j))return}this.deliver({...n,sourceServerId:e})}},i.onclose=n=>{this.stopped||this.sockets.get(e)!==i||(clearInterval(this.leaseTimers.get(e)),this.leaseTimers.delete(e),this.sockets.delete(e),oe.set(e,{state:`offline`,error:`连接中断(code ${n.code}${n.reason?` · ${n.reason}`:``}),正在重连`}),ce(),a&&this.ondisconnect?.(e,n),this.retry(e,a?1:t+1))},i.onerror=()=>{}}catch(n){oe.set(e,{state:`offline`,error:n instanceof Error?n.message:`连接失败`}),ce(),this.retry(e,t+1)}finally{this.connecting.delete(e)}}}retry(e,t){clearTimeout(this.timers.get(e)),this.timers.set(e,setTimeout(()=>{this.timers.delete(e),this.connect(e,t)},Math.min(3e4,1e3*2**Math.min(t,5))))}send(e){let t=JSON.parse(e),n=t.type?.startsWith(`terminal.`)&&t.type!==`terminal.shell.set`,r=typeof t._server==`string`?t._server:void 0,i=ke(t,r??(n?this.terminalServer:A));if(r&&i!==r)throw Error(`命令资源不属于指定服务器`);delete t._server;let a=this.sockets.get(i);if(!a||a.readyState!==WebSocket.OPEN)throw Error(`${P(i)} 未连接,操作未发送`);t.type===`state.subscribe`&&(this.focus=t.conversationId),t.type===`terminal.sync`&&(this.terminalServer=i),Array.isArray(t.images)&&(t.images=t.images.map(e=>({...e,id:g(i,e.id)}))),a.send(JSON.stringify(Ae(t,i)))}canSend(e){try{let t=e,n=t.type?.startsWith(`terminal.`)&&t.type!==`terminal.shell.set`?this.terminalServer:A,r=ke(e,t._server??n);return(!t._server||r===t._server)&&this.sockets.get(r)?.readyState===WebSocket.OPEN}catch{return!1}}close(){this.stopped=!0,clearInterval(this.managementTimer),window.removeEventListener(`super-pi-server-connections`,this.reconfigure),window.removeEventListener(`super-pi-active-server`,this.activate),window.removeEventListener(`super-pi-settings-server`,this.activateSettings);for(let e of this.timers.values())clearTimeout(e);for(let e of this.leaseTimers.values())clearInterval(e);for(let e of this.sockets.values())e.close()}},Re=s(),ze=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Be=t(((e,t)=>{t.exports=ze()})),F=Be();function Ve({anchor:e,label:t,className:n=``,onClose:r,onKeyDown:i,children:a}){let o=(0,u.useRef)(null),s=(0,u.useRef)(e??(document.activeElement instanceof HTMLElement?document.activeElement:null));s.current=e??s.current;let c=(0,u.useRef)(r);return c.current=r,(0,u.useLayoutEffect)(()=>{let e=o.current,t={},n=0,r=()=>{let t=s.current,n=t?.isConnected&&t!==document.body?t.getBoundingClientRect():void 0,r=window.visualViewport,i=r?.width??window.innerWidth,a=r?.height??window.innerHeight,o=n?.top??a-28,c=Math.max(0,o-8-8),l=Math.max(0,a-(n?.bottom??a-28)-8-8),u=c>=Math.min(e.scrollHeight,280)||c>=l;e.style.maxHeight=`${Math.max(64,u?c:l)}px`;let d=e.getBoundingClientRect();e.style.left=`${Math.max(8,Math.min(n?.left??i-d.width-8,i-d.width-8))}px`;let f=u?o-8-d.height:(n?.bottom??8)+8;e.style.top=`${Math.max(8,Math.min(f,a-d.height-8))}px`},i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(r)},a=t=>{let n=t.target;!e.contains(n)&&!s.current?.contains(n)&&c.current()},l=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),c.current(),s.current?.focus())},u=e=>{e.detail!==t&&c.current()};document.addEventListener(`pointerdown`,a,!0),document.addEventListener(`keydown`,l,!0),window.addEventListener(`resize`,i),window.visualViewport?.addEventListener(`resize`,i),window.addEventListener(`super-pi-status-popover`,u),window.dispatchEvent(new CustomEvent(`super-pi-status-popover`,{detail:t}));let d=new ResizeObserver(i);return d.observe(e),r(),e.contains(document.activeElement)||(e.querySelector(`input:not([disabled]),select:not([disabled])`)??e.querySelector(`button:not([disabled])`))?.focus({preventScroll:!0}),()=>{d.disconnect(),cancelAnimationFrame(n),document.removeEventListener(`pointerdown`,a,!0),document.removeEventListener(`keydown`,l,!0),window.removeEventListener(`resize`,i),window.visualViewport?.removeEventListener(`resize`,i),window.removeEventListener(`super-pi-status-popover`,u),(e.contains(document.activeElement)||document.activeElement===document.body)&&s.current?.focus({preventScroll:!0})}},[]),(0,u.useLayoutEffect)(()=>{window.dispatchEvent(new Event(`resize`))},[e]),(0,Re.createPortal)((0,F.jsx)(`dialog`,{open:!0,ref:o,"aria-label":t,"aria-modal":`false`,className:`anchored-popover ${n}`,onKeyDown:i,children:a}),document.body)}function He({verification:e,onAnswer:t,onCancel:n}){let r=(0,u.useId)(),[i,a]=(0,u.useState)(()=>e.prompts.map(()=>``)),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``);return(0,F.jsxs)(`form`,{className:`managed-server-form managed-auth-challenge`,"data-ssh-verification":e.id,"aria-labelledby":r,onSubmit:async n=>{n.preventDefault(),s(!0),l(``);let r=i;a(e.prompts.map(()=>``));try{await t(r)}catch(e){l(e instanceof Error?e.message:`验证未完成,请重试`)}finally{s(!1)}},children:[(0,F.jsxs)(`h4`,{id:r,children:[`等待 SSH 交互验证`,e.name?` · ${e.name}`:``]}),e.instruction&&(0,F.jsx)(`p`,{className:`managed-auth-instruction`,children:e.instruction}),e.prompts.map((e,t)=>(0,F.jsxs)(`label`,{children:[e.prompt||`验证输入 ${t+1}`,(0,F.jsx)(`input`,{type:e.echo?`text`:`password`,value:i[t],autoComplete:e.echo?`off`:`new-password`,spellCheck:!1,autoFocus:t===0,disabled:o,onChange:e=>a(n=>n.map((n,r)=>r===t?e.target.value:n))})]},t)),(0,F.jsxs)(`small`,{children:[`仅用于本次连接,不保存验证回答。请在 `,new Date(e.expiresAt).toLocaleTimeString(),` 前完成。`]}),c&&(0,F.jsx)(`p`,{className:`server-connection-error`,role:`alert`,children:c}),(0,F.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,F.jsx)(`button`,{type:`submit`,disabled:o,children:o?`正在验证…`:e.prompts.length?`提交验证`:`继续验证`}),(0,F.jsx)(`button`,{type:`button`,disabled:o,onClick:async()=>{a(e.prompts.map(()=>``)),s(!0);try{await n()}catch(e){l(e instanceof Error?e.message:`取消失败,请重试`)}finally{s(!1)}},children:`取消验证`})]})]})}function Ue({connected:e,onSettings:t,onSelectServer:n}){let{connections:r,activeServer:i}=ue(),a=r.find(e=>e.id===i),[o,s]=(0,u.useState)(),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(!1),p=(0,u.useRef)(null),m=async e=>{let t=await Ne(`/api/managed-servers`,{signal:e},`entry`),n=await t.json();if(!t.ok)throw Error(n.error??`无法读取服务器状态`);return n.profiles.find(e=>e.id===a?.managedId)};(0,u.useEffect)(()=>{if(s(void 0),l(``),!a?.managedId)return;let e=new AbortController,t=()=>{m(e.signal).then(t=>{e.signal.aborted||(s(t),l(``))}).catch(t=>{e.signal.aborted||l(t.message)})};t();let n=setInterval(t,2e3);return()=>{e.abort(),clearInterval(n)}},[a?.managedId]);let h=async(e,t={})=>{let n=await Ne(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:a?.managedId,action:e,...t})},`entry`),r=await n.json();if(!n.ok)throw Error(r.error??`操作未完成`);s(r.profiles?.find(e=>e.id===a?.managedId))};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{ref:p,type:`button`,className:`workbench-connection workbench-status-button`,"data-workbench-connection":e?`online`:`offline`,"aria-haspopup":`dialog`,"aria-expanded":d,title:`查看连接状态与完成验证`,onClick:()=>f(e=>!e),children:[(0,F.jsx)(`i`,{"aria-hidden":`true`}),(0,F.jsx)(`span`,{children:o?.verification?`SSH 等待验证`:e?`已连接`:`正在连接`}),(0,F.jsx)(`code`,{children:a?.name})]}),d&&(0,F.jsx)(Ve,{anchor:p.current,label:`服务连接详情`,className:`connection-status-dialog`,onClose:()=>f(!1),children:(0,F.jsxs)(`div`,{className:`connection-status-content`,children:[(0,F.jsxs)(`header`,{children:[(0,F.jsxs)(`h2`,{children:[a?.name,` · 连接`]}),(0,F.jsx)(`button`,{type:`button`,"aria-label":`关闭连接详情`,onClick:()=>f(!1),children:`关闭`})]}),(0,F.jsxs)(`label`,{children:[`当前服务端 `,(0,F.jsx)(`select`,{"aria-label":`切换当前服务端`,value:i,onChange:e=>{n(e.target.value),f(!1)},children:r.filter(e=>e.enabled).map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,F.jsxs)(`dl`,{children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`服务连接`}),(0,F.jsx)(`dd`,{children:e?`已连接`:`连接中断,正在重连`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`服务地址`}),(0,F.jsx)(`dd`,{children:o?.serviceUrl??a?.url})]}),o&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`SSH 管理`}),(0,F.jsx)(`dd`,{children:o.ssh===`online`?`已连接`:o.ssh===`awaitingVerification`?`等待验证`:o.ssh===`connecting`?`连接中`:`未连接`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`模型通道`}),(0,F.jsxs)(`dd`,{children:[o.modelChannel===`online`?`已连接`:`未连接`,o.modelTransport===`direct`?` · 服务端口`:``]})]})]})]}),o?.sshError&&(0,F.jsx)(`p`,{role:`status`,children:o.sshError}),o?.modelError&&(0,F.jsx)(`p`,{role:`status`,children:o.modelError}),o?.verification&&(0,F.jsx)(He,{verification:o.verification,onAnswer:e=>h(`answerVerification`,{verificationId:o.verification.id,answers:e}),onCancel:()=>h(`cancelVerification`,{verificationId:o.verification.id})},o.verification.id),c&&(0,F.jsx)(`p`,{role:`alert`,children:c}),o&&!o.verification&&o.ssh!==`online`&&(0,F.jsx)(`button`,{type:`button`,disabled:o.ssh===`connecting`,onClick:()=>void h(`connectSsh`).catch(e=>l(e.message)),children:`连接 SSH 管理`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{f(!1),t()},children:`管理服务器连接`})]})})]})}function We({title:e,choices:t,onChoose:n,onClose:r,children:i,onHighlight:a,anchor:o}){let[s,c]=(0,u.useState)(``),l=t?.filter(e=>[e.label,e.detail,e.group].join(` `).toLowerCase().includes(s.toLowerCase()));return(0,F.jsxs)(Ve,{anchor:o,label:e,className:`status-bar-menu`,onClose:r,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=[...e.currentTarget.querySelectorAll(`[data-status-option]:not(:disabled)`)];if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[n<0?e.key===`ArrowDown`?0:t.length-1:(n+(e.key===`ArrowDown`?1:t.length-1))%t.length]?.focus()},children:[(0,F.jsxs)(`header`,{children:[(0,F.jsx)(`h2`,{children:e}),(0,F.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`关闭状态栏操作`,children:`关闭`})]}),t&&(0,F.jsx)(`input`,{autoFocus:!0,placeholder:`搜索…`,"aria-label":e+`搜索`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l?.length===1&&!l[0].disabled&&n?.(l[0].id)}}),(0,F.jsxs)(`div`,{className:`status-bar-options`,children:[l?.map((e,t)=>(0,F.jsxs)(`div`,{children:[e.group&&e.group!==l[t-1]?.group&&(0,F.jsx)(`h3`,{children:e.group}),(0,F.jsxs)(`button`,{type:`button`,"data-status-option":e.id,disabled:e.disabled,onFocus:()=>a?.(e.id),onMouseEnter:()=>a?.(e.id),onClick:()=>n?.(e.id),children:[(0,F.jsx)(`strong`,{children:e.label}),e.detail&&(0,F.jsx)(`small`,{children:e.detail})]})]},e.id)),l?.length===0&&(0,F.jsx)(`p`,{children:`没有匹配项`})]}),i]})}var Ge=`default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; frame-src 'self'; object-src 'none'; form-action 'none'; base-uri 'none'`,Ke={png:{kind:`image`,mime:`image/png`},jpg:{kind:`image`,mime:`image/jpeg`},jpeg:{kind:`image`,mime:`image/jpeg`},gif:{kind:`image`,mime:`image/gif`},webp:{kind:`image`,mime:`image/webp`},svg:{kind:`image`,mime:`image/svg+xml`},html:{kind:`html`,mime:`text/html; charset=utf-8`},htm:{kind:`html`,mime:`text/html; charset=utf-8`}};function qe(e){return Ke[/\.([a-z]+)$/i.exec(e)?.[1].toLowerCase()??``]}function Je(e){if(!(!e||/[\u0000-\u001f\u007f]/.test(e)||/^[\\/]{2}/.test(e))&&(!/^[a-z][a-z\d+.-]*:/i.test(e)||/^[a-z]:[\\/]/i.test(e)))return qe(e)?.kind}function Ye(e,t,n){return`/api/message-artifact?${new URLSearchParams({workspaceId:e,conversationId:t,path:n})}`}function Xe(e){let t=Ze(e);if(t&&/\.pptx$/i.test(t))return{path:e,line:1,artifact:!0};let n=/#L([1-9]\d*)(?:C([1-9]\d*))?(?:-L?[1-9]\d*)?$/i.exec(e)??/:([1-9]\d*)(?::([1-9]\d*))?$/.exec(e);if(!n||n.index===0)return;let r=Number(n[1]),i=n[2]?Number(n[2]):void 0;if(Number.isSafeInteger(r)&&(i===void 0||Number.isSafeInteger(i)))return{path:e.slice(0,n.index),line:r,column:i}}function Ze(e){try{let t=decodeURIComponent(e).replaceAll(`\\`,`/`);if(!t||t.startsWith(`//`)||/[\u0000-\u001f\u007f?#]/.test(t)||/:/.test(t.replace(/^[a-z]:\//i,``)))return;let n=t.split(`/`).at(-1)??``;return!/^(?:[\w.-]*\.[\w.-]+|Makefile|Dockerfile|LICENSE)$/iu.test(n)&&!/\.[\p{L}\p{N}_-]+$/u.test(n)?void 0:t}catch{return}}function I(e){let t=Xe(e);return!!(t&&Ze(t.path))}function Qe(e,t){let n=e;if(/^https?:\/\//i.test(e)){let r;try{r=new URL(e)}catch{return}let i=[`localhost`,`127.0.0.1`,`[::1]`].includes(r.hostname)&&r.port===`3080`;if(r.username||r.password||r.search||!r.hash||r.origin!==t.origin&&!i)return;n=r.pathname+r.hash}let r=Xe(n);if(!r)return;let i=Ze(r.path);if(!i)return;let a=t.root.replaceAll(`\\`,`/`).replace(/\/+$/,``),o=/^[a-z]:\//i.test(a),s=e=>o?e.toLowerCase():e,c=s(i).startsWith(s(a+`/`));if(/^[a-z]:\//i.test(i)&&!c)return;let l=(c||i.startsWith(`/`)?``:t.cwd).split(`/`).filter(Boolean),u=c?i.slice(a.length+1):i;for(let e of u.split(`/`))if(e&&e!==`.`){if(e===`..`){if(!l.length)return;l.pop()}else l.push(e)}return{...r,path:l.join(`/`)}}function $e(e){let t=/(\/\/.*|#[^\n]*|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:const|let|var|function|return|if|else|for|while|class|import|from|export|def|fn|true|false|null|undefined|async|await|try|catch|throw|switch|case|break|continue|new|this|static|public|private|interface|type|enum|struct|impl|pub|mod|use|as|where|match|loop|mut|ref|self|Self)\b|\b\d+(?:\.\d+)?\b)/g,n=[],r=0,i;for(;i=t.exec(e);){i.index>r&&n.push({text:e.slice(r,i.index),kind:`plain`});let t=i[0],a=/^(\/\/|#)/.test(t)?`comment`:/^["']/.test(t)?`string`:/^\d/.test(t)?`number`:`keyword`;n.push({text:t,kind:a}),r=i.index+t.length}return r<e.length&&n.push({text:e.slice(r),kind:`plain`}),n}var et=new Set([`http`,`https`,`mailto`]),tt=e=>{let t=e.codePointAt(0)??0;return t<=32||t===127||/\s/.test(e)},nt=/^([a-z][a-z0-9+.-]*):/i;function rt(e){let t=[...e].filter(e=>!tt(e)).join(``);if(!t)return;let n=nt.exec(t);return n?et.has(n[1].toLowerCase())?e:void 0:e}var it=/[!-/:-@[-`{-~]/,at=e=>e!==void 0&&/[\p{L}\p{N}]/u.test(e);function ot(e,t,n){let r=0;for(;e[t+r]===n;)r+=1;return r}function st(e){let t=e.replace(/\n/g,` `);return t.length>2&&t.startsWith(` `)&&t.endsWith(` `)&&t.trim()!==``?t.slice(1,-1):t}function ct(e,t,n){for(let r=t;r<e.length;r+=1){if(e[r]===`\\`){r+=1;continue}if(e[r]!=="`")continue;let t=ot(e,r,"`");if(t===n)return r;r+=t-1}return-1}function lt(e,t,n,r){for(let i=t;i<e.length;i+=1){if(n===`$`){if(e[i]===`
|
|
10
|
+
`).replace($f,``)}function tp(e,t){return t=ep(t),ep(e)===t}function np(e,t,n,r,i,a){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||pn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&pn(e,``+r);else return;break;case`className`:Zt(e,`class`,r);break;case`tabIndex`:Zt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Zt(e,n,r);break;case`style`:gn(e,r,a);return;case`data`:if(t!==`object`){Zt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=bn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof a==`function`&&(n===`formAction`?(t!==`input`&&np(e,t,`name`,i.name,i,null),np(e,t,`formEncType`,i.formEncType,i,null),np(e,t,`formMethod`,i.formMethod,i,null),np(e,t,`formTarget`,i.formTarget,i,null)):(np(e,t,`encType`,i.encType,i,null),np(e,t,`method`,i.method,i,null),np(e,t,`target`,i.target,i,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=bn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=xn);return;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=bn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Xt(e,`popover`,r);break;case`xlinkActuate`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Qt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Xt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=vn.get(n)||n,Xt(e,n,r);else return}Jt=!0}function rp(e,t,n,r,i,a){switch(n){case`style`:gn(e,r,a);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));a?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)pn(e,r);else if(typeof r==`number`||typeof r==`bigint`)pn(e,``+r);else return;break;case`onScroll`:r!=null&&Hf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Hf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=xn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Vt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),a=n.slice(2,i?n.length-7:void 0),t=e[Tt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(a,t,i),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(a,r,i);break a}Jt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Xt(e,n,r)}return}Jt=!0}function ip(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Hf(`error`,e),Hf(`load`,e);var r=!1,i=!1,a;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(s!=null)switch(a){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:np(e,t,a,s,n,null)}}i&&np(e,t,`srcSet`,n.srcSet,n,null),r&&np(e,t,`src`,n.src,n,null);return;case`input`:Hf(`invalid`,e);var c=a=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:a=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(o(137,t));break;default:np(e,t,r,d,n,null)}}cn(e,a,c,l,u,s,i,!1);return;case`select`:for(i in Hf(`invalid`,e),r=s=a=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:a=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:np(e,t,i,c,n,null)}t=a,n=s,e.multiple=!!r,t==null?n!=null&&un(e,!!r,n,!0):un(e,!!r,t,!1);return;case`textarea`:for(s in Hf(`invalid`,e),a=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:a=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(o(91));break;default:np(e,t,s,c,n,null)}fn(e,r,i,a);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:np(e,t,l,r,n,null)}return;case`dialog`:Hf(`beforetoggle`,e),Hf(`toggle`,e),Hf(`cancel`,e),Hf(`close`,e);break;case`iframe`:case`object`:Hf(`load`,e);break;case`video`:case`audio`:for(r=0;r<zf.length;r++)Hf(zf[r],e);break;case`image`:Hf(`error`,e),Hf(`load`,e);break;case`details`:Hf(`toggle`,e);break;case`embed`:case`source`:case`link`:Hf(`error`,e),Hf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:np(e,t,u,r,n,null)}return;default:if(_n(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&rp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&np(e,t,c,r,n,null))}var ap={};function op(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,a=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||np(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Jt=!0),a=m;break;case`name`:m!==f&&(Jt=!0),i=m;break;case`checked`:m!==f&&(Jt=!0),u=m;break;case`defaultChecked`:m!==f&&(Jt=!0),d=m;break;case`value`:m!==f&&(Jt=!0),s=m;break;case`defaultValue`:m!==f&&(Jt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(o(137,t));break;default:m!==f&&np(e,t,p,m,r,f)}}sn(e,s,c,l,u,d,a,i);return;case`select`:for(a in m=s=c=p=null,n)if(l=n[a],n.hasOwnProperty(a)&&l!=null)switch(a){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(a)||np(e,t,a,null,r,l)}for(i in r)if(a=r[i],l=n[i],r.hasOwnProperty(i)&&(a!=null||l!=null))switch(i){case`value`:a!==l&&(Jt=!0),p=a;break;case`defaultValue`:a!==l&&(Jt=!0),c=a;break;case`multiple`:a!==l&&(Jt=!0),s=a;default:a!==l&&np(e,t,i,a,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?un(e,!!n,n?[]:``,!1):un(e,!!n,t,!0)):un(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:np(e,t,c,null,r,i)}for(s in r)if(i=r[s],a=n[s],r.hasOwnProperty(s)&&(i!=null||a!=null))switch(s){case`value`:i!==a&&(Jt=!0),p=i;break;case`defaultValue`:i!==a&&(Jt=!0),m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(o(91));break;default:i!==a&&np(e,t,s,i,r,a)}dn(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:np(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Jt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:np(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&np(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(o(137,t));break;default:np(e,t,u,p,r,m)}return;default:if(_n(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&rp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||rp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&np(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||np(e,t,f,p,r,m)}function sp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function cp(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&sp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&sp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var lp=null,up=null;function dp(e){return e.nodeType===9?e:e.ownerDocument}function fp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function pp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function mp(e,t,n,r){return n=dp(n).createElement(e),n[wt]=r,n[Tt]=t,ip(n,e,t),Rt(n),n}function hp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var gp=null;function _p(){var e=window.event;return e&&e.type===`popstate`?e!==gp&&(gp=e,!0):(gp=null,!1)}var vp=typeof setTimeout==`function`?setTimeout:void 0,yp=typeof clearTimeout==`function`?clearTimeout:void 0,bp=typeof Promise==`function`?Promise:void 0,xp=typeof requestAnimationFrame==`function`?requestAnimationFrame:vp,Sp=typeof queueMicrotask==`function`?queueMicrotask:bp===void 0?vp:function(e){return bp.resolve(null).then(e).catch(Cp)};function Cp(e){setTimeout(function(){throw e})}function wp(e){return e===`head`}function Tp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Wh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)ym(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,ym(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[jt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&ym(e.ownerDocument.body)}n=i}while(n);Wh(t)}function Ep(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Dp(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Op(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function kp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function Ap(e){return kp(e.getBoundingClientRect(),getComputedStyle(e),e)}function jp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return kp(t,n,e)}function Mp(e){return e.documentElement.clientHeight}function Np(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Pp(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Mp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=Qm(f),u>th){s.length=o;break}f=new Promise(Np.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Fp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Fp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:D({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Fp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Fp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Ip(e){return{name:e,group:new Fp(`group`,e),imagePair:new Fp(`image-pair`,e),old:new Fp(`old`,e),new:new Fp(`new`,e)}}function Lp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Lp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Hp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Bp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),h(this._fragmentFiber.child,!1,Rp,e,s,r)}this._eventListeners=a}};function Rp(e,t,n,r){return b(e).addEventListener(t,n,r),!1}Lp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Hp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Bp(i.optionsOrUseCapture),h(this._fragmentFiber.child,!1,zp,e,n,i),r.splice(t,1),a!==null&&a()}};function zp(e,t,n,r){return b(e).removeEventListener(t,n,r),!1}function Bp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Vp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Hp(e,t,n,r){if(e.length===0)return-1;r=Vp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Vp(a.optionsOrUseCapture)===r)return i}return-1}Lp.prototype.dispatchEvent=function(e){var t=g(this._fragmentFiber);if(t===null)return!0;t=b(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Bp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Lp.prototype.focus=function(e){h(this._fragmentFiber.child,!0,Up,e,void 0,void 0)};function Up(e,t){return e.tag!==6&&(e=b(e),hm(e,t))}Lp.prototype.focusLast=function(e){var t=[];h(this._fragmentFiber.child,!0,Wp,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Up(t[n],e);n--);};function Wp(e,t){return t.push(e),!1}Lp.prototype.blur=function(){var e=g(this._fragmentFiber);e!==null&&(e=b(e),e=dp(e).activeElement,e!==null&&h(this._fragmentFiber.child,!1,Gp,e,void 0,void 0))};function Gp(e,t){return e.tag!==6&&(e=b(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Lp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),h(this._fragmentFiber.child,!1,Kp,e,void 0,void 0)};function Kp(e,t){return e.tag===6||(e=b(e),t.observe(e)),!1}Lp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),h(this._fragmentFiber.child,!1,qp,e,void 0,void 0);for(var n=t=0;n<Jp.length;n++){var r=Jp[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):Jp[t++]=r}Jp.length=t}};function qp(e,t){return e.tag===6||(e=b(e),t.unobserve(e)),!1}var Jp=[],Yp=!1;function Xp(e,t,n){Jp.push({fragmentInstance:e,observer:t,instance:n}),Yp||(Yp=!0,gm(function(){Yp=!1;var e=Jp;Jp=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Lp.prototype.getClientRects=function(){var e=[];return h(this._fragmentFiber.child,!1,Zp,e,void 0,void 0),e};function Zp(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=b(e),t.push.apply(t,e.getClientRects());return!1}Lp.prototype.getRootNode=function(e){var t=g(this._fragmentFiber);return t===null?this:b(t).getRootNode(e)},Lp.prototype.compareDocumentPosition=function(e){var t=g(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];h(this._fragmentFiber.child,!1,Wp,n,void 0,void 0);var r=b(t);if(n.length===0){if(n=r,_(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=v(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=b(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=b(n[0]),i=b(n[n.length-1]);var a=_(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||Qp(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function Qp(e,t,n,r,i){var a=Pt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=g(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=E(n,a,T),t===null?t=!1:(h(t,!0,C,a,n),a=x,x=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=E(r,a,T),t===null?t=!1:(h(t,!0,w,a,r),a=x,S=x=null,t=a!==null)),t):!1}function $p(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Lp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(o(566));var t=[];h(this._fragmentFiber.child,!1,Wp,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=v(this._fragmentFiber);if(r=n?r[1]||r[0]||g(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=b(r),$p(e,n);return}if(r=b(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var i=t[r];i.tag===6?(i=b(i),$p(i,n)):b(i).scrollIntoView(e),r+=n?-1:1}};function em(e,t){return e=b(e),tm(e,t),!1}function tm(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function nm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<Jp.length;i++){var a=Jp[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(Jp[r++]=a)}Jp.length=r,n.observe(e)}),tm(e,t))}function rm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Bp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?Xp(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function im(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:im(n),Nt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function am(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[jt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=dm(e.nextSibling),e===null)break}return null}function om(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=dm(e.nextSibling),e===null))return null;return e}function sm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=dm(e.nextSibling),e===null))return null;return e}function cm(e){return e.data===`$?`||e.data===`$~`}function lm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function um(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function dm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var fm=null;function pm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return dm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function mm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function hm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function gm(e){xp(function(){xp(function(t){return e(t)})})}function _m(e,t,n){switch(t=dp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(o(452));return e;case`head`:if(e=t.head,!e)throw Error(o(453));return e;case`body`:if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function vm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&np(e,t,r,null,ap,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===xn&&(e.onclick=null),Nt(e)}function ym(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Nt(e)}var bm=new Map,xm=new Set;function Sm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Cm=_e.d;_e.d={f:wm,r:Tm,D:Om,C:km,L:Am,m:jm,X:Nm,S:Mm,M:Pm};function wm(){var e=Cm.f(),t=Rd();return e||t}function Tm(e){var t=Ft(e);t!==null&&t.tag===5&&t.type===`form`?Xs(t):Cm.r(e)}var Em=typeof document>`u`?null:document;function Dm(e,t,n){var r=Em;if(r&&typeof t==`string`&&t){var i=on(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),xm.has(i)||(xm.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),ip(t,`link`,e),Rt(t),r.head.appendChild(t)))}}function Om(e){Cm.D(e),Dm(`dns-prefetch`,e,null)}function km(e,t){Cm.C(e,t),Dm(`preconnect`,e,t)}function Am(e,t,n){Cm.L(e,t,n);var r=Em;if(r&&e&&t){var i=`link[rel="preload"][as="`+on(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+on(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+on(n.imageSizes)+`"]`)):i+=`[href="`+on(e)+`"]`;var a=i;switch(t){case`style`:a=Im(e);break;case`script`:a=Bm(e)}if(!(bm.has(a)||(e=D({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),bm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Lm(a))||t===`script`&&r.querySelector(Vm(a))))){var o=r.createElement(`link`);ip(o,`link`,e),t===`style`&&(o[Mt]=!0,o.onload=o.onerror=function(){zt(o)}),Rt(o),r.head.appendChild(o)}}}function jm(e,t){Cm.m(e,t);var n=Em;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+on(r)+`"][href="`+on(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Bm(e)}if(!bm.has(a)&&(e=D({rel:`modulepreload`,href:e},t),bm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Vm(a)))return}r=n.createElement(`link`),ip(r,`link`,e),Rt(r),n.head.appendChild(r)}}}function Mm(e,t,n){Cm.S(e,t,n);var r=Em;if(r&&e){var i=Lt(r).hoistableStyles,a=Im(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Lm(a)))s.loading=5;else{e=D({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=bm.get(a))&&Wm(e,n);var c=o=r.createElement(`link`);Rt(c),ip(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Um(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Nm(e,t){Cm.X(e,t);var n=Em;if(n&&e){var r=Lt(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Rt(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Pm(e,t){Cm.M(e,t);var n=Em;if(n&&e){var r=Lt(n).hoistableScripts,i=Bm(e),a=r.get(i);a||(a=n.querySelector(Vm(i)),a||(e=D({src:e,async:!0,type:`module`},t),(t=bm.get(i))&&Gm(e,t),a=n.createElement(`script`),Rt(a),ip(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Fm(e,t,n,r){var i=(i=Ee.current)?Sm(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Im(n.href),t=Lt(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Im(n.href);var a=Lt(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(Lm(e)))?a._p||(s.instance=a,s.state.loading=5):(a=bm.get(e),a||(a={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},bm.set(e,a)),zm(i,e,a,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Bm(n),t=Lt(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Im(e){return`href="`+on(e)+`"`}function Lm(e){return`link[rel="stylesheet"][`+e+`]`}function Rm(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function zm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Mt]){r.loading=1;return}}else t=e.createElement(`link`),t[Mt]=!0,t.onload=t.onerror=zt.bind(null,t),ip(t,`link`,n),Rt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Bm(e){return`[src="`+on(e)+`"]`}function Vm(e){return`script[async]`+e}function Hm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+on(n.href)+`"]`);if(r)return t.instance=r,Rt(r),r;var i=D({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Rt(r),ip(r,`style`,i),Um(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Im(n.href);var a=e.querySelector(Lm(i));if(a)return t.state.loading|=4,t.instance=a,Rt(a),a;r=Rm(n),(i=bm.get(i))&&Wm(r,i),a=(e.ownerDocument||e).createElement(`link`),Rt(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),ip(a,`link`,r),t.state.loading|=4,Um(a,n.precedence,e),t.instance=a;case`script`:return a=Bm(n.src),(i=e.querySelector(Vm(a)))?(t.instance=i,Rt(i),i):(r=n,(i=bm.get(a))&&(r=D({},n),Gm(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Rt(i),ip(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Um(r,n.precedence,e));return t.instance}function Um(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Wm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Gm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Km=null;function qm(e,t,n){if(Km===null){var r=new Map,i=Km=new Map;i.set(n,r)}else i=Km,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[jt]||a[wt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Jm(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Ym(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Xm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Zm(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Qm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function $m(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Qm(t),e.suspenseyImages.push(t)),e=ah.bind(e),t.decode().then(e,e))}function eh(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Im(r.href),a=t.querySelector(Lm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ih.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Rt(a);return}a=t.ownerDocument||t,r=Rm(r),(i=bm.get(i))&&Wm(r,i),a=a.createElement(`link`),Rt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),ip(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ih.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var th=0;function nh(e,t){return e.stylesheets&&e.count===0&&sh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&th===0&&(th=62500*cp());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&sh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>th?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function rh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)sh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function ih(){this.count--,rh(this)}function ah(){this.imgCount--,rh(this)}var oh=null;function sh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oh=new Map,t.forEach(ch,e),oh=null,ih.call(e))}function ch(e,t){if(!(t.state.loading&4)){var n=oh.get(e);if(n)var r=n.get(null);else{n=new Map,oh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=ih.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var lh={$$typeof:N,Provider:null,Consumer:null,_currentValue:ve,_currentValue2:ve,_threadCount:0};function uh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pt(0),this.hiddenUpdates=pt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function dh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new uh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Pi(3,null,null,t),e.current=a,a.stateNode=e,t=Pa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},ho(a),e}function fh(e){return e?(e=Mi,e):Mi}function ph(e,t,n,r,i,a){i=fh(i),r.context===null?r.context=i:r.pendingContext=i,r=_o(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=vo(e,r,t),n!==null&&(Nd(n,e,t),yo(n,e,t))}function mh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function hh(e,t){mh(e,t),(e=e.alternate)&&mh(e,t)}function gh(e){if(e.tag===13||e.tag===31){var t=ki(e,67108864);t!==null&&Nd(t,e,67108864),hh(e,67108864)}}function _h(e){if(e.tag===13||e.tag===31){var t=Ad();t=yt(t);var n=ki(e,t);n!==null&&Nd(n,e,t),hh(e,t)}}var vh=!0;function yh(e,t,n,r){var i=P.T;P.T=null;var a=_e.p;try{_e.p=2,xh(e,t,n,r)}finally{_e.p=a,P.T=i}}function bh(e,t,n,r){var i=P.T;P.T=null;var a=_e.p;try{_e.p=8,xh(e,t,n,r)}finally{_e.p=a,P.T=i}}function xh(e,t,n,r){if(vh){var i=Sh(r);if(i===null)qf(e,t,r,Ch,n),Ph(e,r);else if(Ih(i,e,t,n,r))r.stopPropagation();else if(Ph(e,r),t&4&&-1<Nh.indexOf(e)){for(;i!==null;){var a=Ft(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=st(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-et(o);s.entanglements[1]|=c,o&=~c}Ef(a),!(Ju&6)&&(hd=Ue()+500,Df(0,!1))}}break;case 31:case 13:s=ki(a,2),s!==null&&Nd(s,a,2),Rd(),hh(a,2)}if(a=Sh(r),a===null&&qf(e,t,r,Ch,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else qf(e,t,r,null,n)}}function Sh(e){return e=Cn(e),wh(e)}var Ch=null;function wh(e){if(Ch=null,e=Pt(e),e!==null){var t=l(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=u(t),e!==null)return e;e=null}else if(n===31){if(e=d(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Ch=e,null}function Th(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(We()){case Ge:return 2;case Ke:return 8;case qe:case Je:return 32;case Ye:return 268435456;default:return 32}default:return 32}}var Eh=!1,Dh=null,Oh=null,kh=null,Ah=new Map,jh=new Map,Mh=[],Nh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Ph(e,t){switch(e){case`focusin`:case`focusout`:Dh=null;break;case`dragenter`:case`dragleave`:Oh=null;break;case`mouseover`:case`mouseout`:kh=null;break;case`pointerover`:case`pointerout`:Ah.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:jh.delete(t.pointerId)}}function Fh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=Ft(t),t!==null&&gh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Ih(e,t,n,r,i){switch(t){case`focusin`:return Dh=Fh(Dh,e,t,n,r,i),!0;case`dragenter`:return Oh=Fh(Oh,e,t,n,r,i),!0;case`mouseover`:return kh=Fh(kh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Ah.set(a,Fh(Ah.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,jh.set(a,Fh(jh.get(a)||null,e,t,n,r,i)),!0}return!1}function Lh(e){var t=Pt(e.target);if(t!==null){var n=l(t);if(n!==null){if(t=n.tag,t===13){if(t=u(n),t!==null){e.blockedOn=t,St(e.priority,function(){_h(n)});return}}else if(t===31){if(t=d(n),t!==null){e.blockedOn=t,St(e.priority,function(){_h(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Rh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Sh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Sn=r,n.target.dispatchEvent(r),Sn=null}else return t=Ft(n),t!==null&&gh(t),e.blockedOn=n,!1;t.shift()}return!0}function zh(e,t,n){Rh(e)&&n.delete(t)}function Bh(){Eh=!1,Dh!==null&&Rh(Dh)&&(Dh=null),Oh!==null&&Rh(Oh)&&(Oh=null),kh!==null&&Rh(kh)&&(kh=null),Ah.forEach(zh),jh.forEach(zh)}function Vh(e,n){e.blockedOn===n&&(e.blockedOn=null,Eh||(Eh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Bh)))}var Hh=null;function Uh(e){Hh!==e&&(Hh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Hh===e&&(Hh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(wh(r||n)===null)continue;break}var a=Ft(n);a!==null&&(e.splice(t,3),t-=3,Js(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Wh(e){function t(t){return Vh(t,e)}Dh!==null&&Vh(Dh,e),Oh!==null&&Vh(Oh,e),kh!==null&&Vh(kh,e),Ah.forEach(t),jh.forEach(t);for(var n=0;n<Mh.length;n++){var r=Mh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Mh.length&&(n=Mh[0],n.blockedOn===null);)Lh(n),n.blockedOn===null&&Mh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[Tt]||null;if(typeof a==`function`)o||Uh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[Tt]||null)s=o.formAction;else if(wh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Uh(n)}}}function Gh(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Kh(e){this._internalRoot=e}qh.prototype.render=Kh.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current;ph(n,Ad(),e,t,null,null)},qh.prototype.unmount=Kh.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ph(e.current,2,null,e,null,null),Rd(),t[Et]=null}};function qh(e){this._internalRoot=e}qh.prototype.unstable_scheduleHydration=function(e){if(e){var t=xt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Mh.length&&t!==0&&t<Mh[n].priority;n++);Mh.splice(n,0,e),n===0&&Lh(e)}};var Jh=n.version;if(Jh!==`19.3.1`)throw Error(o(527,Jh,`19.3.1`));_e.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(o(188)):(e=Object.keys(e).join(`,`),Error(o(268,e)));return e=p(t),e=e===null?null:m(e),e=e===null?null:e.stateNode,e};var Yh={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Xh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Xh.isDisabled&&Xh.supportsFiber)try{I=Xh.inject(Yh),Qe=Xh}catch{}}e.createRoot=function(e,t){if(!c(e))throw Error(o(299));var n=!1,r=``,i=gc,a=_c,s=vc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=dh(e,1,!1,null,null,n,r,null,i,a,s,Gh),e[Et]=t.current,Gf(e),new Kh(t)}})),l=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=c()})),u=e(r(),1),d=l(),f=`entry`,p=`sp-remote:`;function m(e,t){return e===`entry`?t:`${p}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function h(e){if(!e.startsWith(p))return{server:f,id:e};let t=e.indexOf(`:`,10);if(t<0)throw Error(`服务器资源标识无效`);return{server:decodeURIComponent(e.slice(10,t)),id:decodeURIComponent(e.slice(t+1))}}function g(e,t){if(!t.startsWith(p))return t;let n=h(t);if(n.server!==e)throw Error(`图片不属于此服务器,请在当前会话重新上传`);return n.id}var _=new Set([`workspaceId`,`conversationId`,`contextConversationId`,`messageId`,`sessionId`,`runId`,`taskId`,`parentConversationId`,`originMessageId`,`followedWorktreeId`,`worktreeOf`,`ownerConversationId`,`parentRunId`,`projectId`,`roomId`,`topicId`,`entityId`,`sourceConversationId`,`targetConversationId`,`forkedId`,`checkoutId`,`replyToMessageId`,`parentMessageId`,`replyTo`,`activate`]),v=new Set([`workspaces`,`conversations`,`messages`,`subagentRuns`,`backgroundTasks`,`workflows`,`scheduledTasks`,`warmSessions`,`rooms`,`topics`,`run`,`workflow`,`room`,`task`,`conversation`,`workspace`,`withdrawn`,`terminals`,`sessions`,`tools`,`projects`]),y=new Set([`collapsedConversationIds`,`unlockedChildConversationIds`,`stoppingConversationIds`,`conversationIds`,`workspaceIds`,`messageIds`]),b=new Set([`todosByConversation`,`pendingUserDecisionsByConversation`]),x=new Set([`args`,`arguments`,`parameters`,`schema`,`result`,`providers`,`images`,`attachments`,`toolCalls`,`defaultModel`,`model`,`agents`]);function S(e,t,n=``){return Array.isArray(e)?e.map(e=>S(e,t,n)):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([r,i])=>typeof i==`string`&&i.length>0&&(_.has(r)||(r===`id`||r===`execution`)&&i.startsWith(p)||r===`id`&&(v.has(n)||`workspaceId`in e||`conversationId`in e||e.type===`group.activity`))?[r,t(i)]:y.has(r)&&Array.isArray(i)?[r,i.map(e=>typeof e==`string`?t(e):e)]:b.has(r)&&i&&typeof i==`object`?[r,Object.fromEntries(Object.entries(i).map(([e,n])=>[t(e),n]))]:x.has(r)?[r,i]:[r,S(i,t,r)]))}function C(e){let t=new Set;return S(e,e=>(t.add(h(e).server),e)),t}var w=`super-pi.server-connections.v1`,T=`super-pi.server-credentials.v1`,E=(e,t)=>globalThis.fetch(e,t),D=typeof location>`u`?`http://localhost`:location.origin,O=[{id:f,name:`当前入口`,url:D,enabled:!0}],k={};try{let e=JSON.parse(localStorage.getItem(w)??`[]`);O=[{...O[0],name:e.find(e=>e.id===`entry`)?.name||`当前入口`},...e.filter(e=>e.id!==f)],k=JSON.parse(localStorage.getItem(T)??`{}`)}catch{}var A=f,j=f,ee=!1,M={};function te(e){let t=Object.fromEntries(e.map(e=>[e.id,e.enabled?e.modelTransport===`direct`?e.modelChannel===`online`?`已连接 · 服务端口`:`正在连接服务端口`:e.modelChannel===`online`?`已连接`:e.modelChannelPaused?`已暂停`:e.ssh===`awaitingVerification`?`等待 SSH 验证`:e.ssh===`connecting`?`正在恢复`:`未连接`:`已停用`]));JSON.stringify(t)!==JSON.stringify(M)&&(M=t,ce())}var N=new Map,ne=new Set;function re(e){if(!e)return!1;let t=h(e).server;return O.some(e=>e.id===t)&&!ne.has(t)}var ie=0,ae=new Set,oe=new Map,se=new Map,ce=()=>{ie++;for(let e of ae)e()},le=e=>(ae.add(e),()=>{ae.delete(e)});function ue(){return(0,u.useSyncExternalStore)(le,()=>ie),{connections:O,statuses:oe,modelChannels:M,activeServer:A,settingsServer:j,settingsSnapshot:N.get(j)}}function de(e){return e?h(e).server:A}function fe(){return A}function pe(){return j}function me(e){if(!O.some(t=>t.id===e))throw Error(`目标服务器已移除`);j!==e&&(j=e,ce(),window.dispatchEvent(new Event(`super-pi-settings-server`)))}function he(){ee=!0,me(A)}function ge(){ee=!1,me(A)}function P(e){return O.find(t=>t.id===e)?.name??`未知服务器`}function _e(e){return P(h(e).server)}function ve(e){if(e!==A){if(!O.some(t=>t.id===e))throw Error(`服务器已被移除`);A=e,ee||me(e),ce(),window.dispatchEvent(new Event(`super-pi-active-server`))}}function ye(){localStorage.setItem(w,JSON.stringify(O)),localStorage.setItem(T,JSON.stringify(k)),ce(),window.dispatchEvent(new Event(`super-pi-server-connections`))}function be(e,t){if(!t.trim())throw Error(`服务器名称不能为空`);if(O.some(n=>n.id!==e&&n.name===t.trim()))throw Error(`服务器名称已存在,请使用容易区分的名称`);O=O.map(n=>n.id===e?{...n,name:t.trim()}:n),ye()}function xe(e){if(e===`entry`)return;let t=A===e;O=O.filter(t=>t.id!==e),delete k[e],se.delete(e),t&&(A=f),j===e&&me(f),ye(),t&&window.dispatchEvent(new Event(`super-pi-active-server`))}function Se(e,t){O=O.map(n=>n.id===e?{...n,enabled:t}:n),ye()}async function Ce(e,t,n){let r=new URL(t);if(![`http:`,`https:`].includes(r.protocol)||r.username||r.password||r.search||r.hash||r.pathname!==`/`)throw Error(`请输入 http(s)://主机:端口,不能包含路径或凭证`);if(location.protocol===`https:`&&r.protocol===`http:`)throw Error(`HTTPS 页面无法连接 HTTP 服务,请为目标服务启用 HTTPS,或从 HTTP 入口访问`);if(!e.trim()||!n.trim())throw Error(`请填写服务器名称和连接密钥`);if(O.some(t=>t.name===e.trim()))throw Error(`服务器名称已存在,请使用不同的名称`);let i=await we(r.origin,n.trim());if(!i.ok)throw Error(`连接失败(${i.status}),请检查服务版本、地址和连接密钥`);let a=await i.json();if(a.protocol!==1||typeof a.id!=`string`)throw Error(`目标服务不支持多服务端协议,请先更新目标服务`);if(O.some(e=>e.url===r.origin||e.identity===a.id))throw Error(`这台服务器已经添加`);let o=await E(`/api/browser-access`).then(e=>e.json()).catch(()=>void 0);if(a.id===o?.id)throw Error(`这是当前入口服务器,无需重复添加`);let s=crypto.randomUUID();return k[s]=n.trim(),O=[...O,{id:s,name:e.trim(),url:r.origin,enabled:!0,identity:a.id}],ye(),s}async function we(e,t){try{return await E(`${e}/api/browser-access`,{headers:{authorization:`Bearer ${t}`},signal:AbortSignal.timeout(15e3),credentials:`omit`})}catch(e){throw Error(e instanceof Error&&e.name===`TimeoutError`?`连接超时,请检查目标服务器是否启动、端口是否开放`:`浏览器无法连接目标服务器,请检查地址、网络可达性、HTTPS 证书,以及目标是否已更新到支持多服务端的版本`)}}async function Te(e,t,n,r){let i=Ee(e),a=new URL(n);if(![`http:`,`https:`].includes(a.protocol)||a.username||a.password||a.search||a.hash||a.pathname!==`/`)throw Error(`请输入不包含路径或凭证的 HTTP(S) 服务地址`);if(location.protocol===`https:`&&a.protocol===`http:`)throw Error(`HTTPS 页面不能连接 HTTP 服务`);if(!t.trim())throw Error(`请输入服务器名称`);if(O.some(n=>n.id!==e&&n.name===t.trim()))throw Error(`服务器名称已存在`);let o=r.trim()||k[e],s=await we(a.origin,o);if(!s.ok)throw Error(`连接失败(${s.status}),请检查地址和密钥`);let c=await s.json();if(c.protocol!==1||c.id!==i.identity)throw Error(`地址指向另一台服务器,请使用“添加服务器”,以保护现有资源和标签的归属`);k[e]=o,O=O.map(n=>n.id===e?{...n,name:t.trim(),url:a.origin,revision:(n.revision??0)+1}:n),se.delete(e),ye()}function Ee(e){let t=O.find(t=>t.id===e);if(!t||!t.enabled)throw Error(`目标服务器已移除或停用,操作未发送`);return t}function De(e,t){return new URL(`${e.url.replace(/\/$/,``)}${t.startsWith(`/`)?t:`/${t}`}`)}async function Oe(){try{let e=await E(`/api/managed-servers`,{signal:AbortSignal.timeout(8e3)});if(!e.ok){te([]);return}let t=await e.json();if(te(Array.isArray(t.profiles)?t.profiles:[]),!t.available||!Array.isArray(t.connections))return;let n=t.connections.map(e=>({...e,url:new URL(e.url,D).href})),r=[...O.filter(e=>!e.managed),...n];if(JSON.stringify(r)!==JSON.stringify(O)){O=r;let e=!O.some(e=>e.id===A);e&&(A=f),O.some(e=>e.id===j)||me(f),ye(),e&&window.dispatchEvent(new Event(`super-pi-active-server`))}}catch{te([])}}function ke(e,t=A){let n=C(e);if(n.size>1)throw Error(`一次操作不能混用不同服务器的资源`);return[...n][0]??t}function Ae(e,t){return S(e,e=>{let n=h(e);if(n.server!==t)throw Error(`资源不属于目标服务器`);return n.id})}function je(e){let t=/^(\/api\/upload\/|\/api\/projects\/|\/tools\/)([^/]+)(.*)$/.exec(e.pathname);if(!t)return{path:e.pathname};let n=h(decodeURIComponent(t[2])),r=t[3];return t[1]===`/api/upload/`&&/^\/[^/]+$/.test(r)&&(r=`/${encodeURIComponent(g(n.server,decodeURIComponent(r.slice(1))))}`),{server:n.server,path:`${t[1]}${encodeURIComponent(n.id)}${r}`}}function Me(e){let t=new URL(e,location.origin);if(O.some(e=>e.managed&&t.href.startsWith(`${e.url}/`))||t.origin!==location.origin)return e;let n=Object.fromEntries(t.searchParams),r=je(t),i=ke(n,r.server??A),a=Ee(i);for(let[e,r]of Object.entries(Ae(n,i)))t.searchParams.set(e,r);if(i===`entry`)return`${r.path}${t.search}${t.hash}`;let o=De(a,`${r.path}${t.search}${t.hash}`),s=se.get(i);return s&&!a.managed&&o.searchParams.set(`browserAsset`,s),o.href}async function Ne(e,t,n){if(typeof e!=`string`&&!(e instanceof URL))throw Error(`服务器请求必须使用明确的 URL`);let r=new URL(String(e),location.origin),i=O.find(e=>e.managed&&r.href.startsWith(`${e.url}/`));if(i){if(n&&n!==i.id)throw Error(`资源不属于指定的服务器`);return Fe(i.id,r,t)}if(r.origin!==location.origin){let n=O.find(e=>e.url===r.origin);return n?(r.searchParams.delete(`browserAsset`),Fe(n.id,r,t)):E(e,t)}if(!r.pathname.startsWith(`/api/`))return E(e,t);let a;if(typeof t?.body==`string`)try{a=JSON.parse(t.body)}catch{}t?.body instanceof FormData&&(a=Object.fromEntries([...t.body].filter(([,e])=>typeof e==`string`)));let o=je(r),s=ke({...Object.fromEntries(r.searchParams),payload:a},o.server??n??A);if(n&&n!==s)throw Error(`资源不属于指定的服务器`);if(o.server&&o.server!==s)throw Error(`路径和参数属于不同服务器`);let c=Ee(s);for(let[e,t]of Object.entries(Ae(Object.fromEntries(r.searchParams),s)))r.searchParams.set(e,t);let l=t;if(typeof t?.body==`string`&&a&&(l={...t,body:JSON.stringify(Ae(a,s))}),t?.body instanceof FormData){let e=new FormData,n=Ae(a,s);for(let[r,i]of t.body)e.append(r,typeof i==`string`?n[r]:i);l={...t,body:e}}return Fe(s,De(c,`${o.path}${r.search}`),l)}function Pe(e,t){return Ne(e,t,j)}async function Fe(e,t,n){let r=Ee(e),i=new Headers(n?.headers);e!==`entry`&&!r.managed&&i.set(`authorization`,`Bearer ${k[e]??``}`);let a=await E(e===`entry`?`${t.pathname}${t.search}`:t.href,{...n,headers:i,...e!==`entry`&&!r.managed?{credentials:`omit`}:{}});if(e===`entry`||!a.headers.get(`content-type`)?.includes(`application/json`))return a;let o=a.json.bind(a);return a.json=async()=>S(await o(),t=>m(e,t)),a}var Ie=new Set([`model.catalog`,`model.catalog.all`,`providers.list`,`agent.catalog`,`prompt.catalog`,`subagent.catalog`,`server.version`,`terminal.status`,`exec.status`]),Le=class{focus;onserveropen=null;ondisconnect=null;onopen=null;onclose=null;onmessage=null;onerror=null;sockets=new Map;snapshots=new Map;catalogs=new Map;timers=new Map;connecting=new Set;socketRevisions=new Map;leaseTimers=new Map;terminalServer=f;stopped=!1;constructor(e){this.focus=e,window.addEventListener(`super-pi-server-connections`,this.reconfigure),window.addEventListener(`super-pi-active-server`,this.activate),window.addEventListener(`super-pi-settings-server`,this.activateSettings),queueMicrotask(this.reconfigure),Oe(),this.managementTimer=setInterval(()=>{Oe()},3e3)}managementTimer;get readyState(){return this.sockets.get(A)?.readyState??WebSocket.CLOSED}deliver(e){this.onmessage?.({data:JSON.stringify(e)})}aggregate(){let e=this.snapshots.get(A),t=[...this.snapshots.values()],n={...e,workspaces:t.flatMap(e=>e.workspaces),conversations:t.flatMap(e=>e.conversations),subagentRuns:t.flatMap(e=>e.subagentRuns)};for(let e of[`backgroundTasks`,`workflows`,`scheduledTasks`,`warmSessions`,`extensionUi`,`stoppingConversationIds`,`collapsedConversationIds`,`unlockedChildConversationIds`])n[e]=t.flatMap(t=>t[e]??[]);for(let e of[`todosByConversation`,`pendingUserDecisionsByConversation`])n[e]=Object.assign({},...t.map(t=>t[e]));t.length&&this.deliver({type:`state`,state:n})}activate=()=>{this.aggregate(),this.deliver({type:`server.version`,version:{runningVersion:``,diskVersion:``,needsRestart:!1}});let e={source:`unavailable`,models:[],levels:[],agents:[],problems:[],directory:``,prompts:[],workspaceId:``,skills:[],commands:[],fetchedAt:new Date().toISOString()};for(let t of[`model.catalog`,`model.catalog.all`,`agent.catalog`,`subagent.catalog`,`prompt.catalog`])this.deliver({type:t,catalog:e});for(let[e,t]of this.catalogs.get(A)??[])[`providers.list`,`model.catalog.all`].includes(e)||this.deliver({...t,sourceServerId:A});let t=this.sockets.get(A);if(t?.readyState===WebSocket.OPEN){this.onopen?.();for(let e of[`catalog.fetch`,`agent.catalog.fetch`,`subagent.catalog.fetch`])t.send(JSON.stringify({type:e}))}this.activateSettings()};activateSettings=()=>{for(let e of[`agent.catalog`,`subagent.catalog`])this.deliver({type:e,catalog:{source:`unavailable`,agents:[],problems:[],directory:``,fetchedAt:``},sourceServerId:j});this.deliver({type:`model.catalog.all`,catalog:{source:`unavailable`,models:[],levels:[],fetchedAt:``},sourceServerId:j}),this.deliver({type:`providers.list`,providers:[],apis:[],sourceServerId:j});for(let[e,t]of this.catalogs.get(j)??[])[`providers.list`,`model.catalog.all`,`agent.catalog`,`subagent.catalog`].includes(e)&&this.deliver({...t,sourceServerId:j});let e=this.sockets.get(j);if(e?.readyState===WebSocket.OPEN)for(let t of[`catalog.fetchAll`,`providers.fetch`,`agent.catalog.fetch`,`subagent.catalog.fetch`])e.send(JSON.stringify({type:t}))};reconfigure=()=>{for(let e of this.snapshots.keys())O.some(t=>t.id===e)||(this.snapshots.delete(e),N.delete(e),this.catalogs.delete(e),oe.delete(e),ne.delete(e));for(let[e,t]of this.sockets)O.some(t=>t.id===e&&t.enabled&&(t.revision??0)===this.socketRevisions.get(e))||(this.sockets.delete(e),t.close(),clearInterval(this.leaseTimers.get(e)),this.leaseTimers.delete(e),O.some(t=>t.id===e)||(this.snapshots.delete(e),ne.delete(e)));for(let e of O)e.enabled||oe.set(e.id,{state:`disabled`}),e.enabled&&!this.sockets.has(e.id)&&!this.connecting.has(e.id)&&this.connect(e.id);this.aggregate()};async connect(e,t=0){if(!(this.stopped||this.sockets.has(e)||!O.some(t=>t.id===e&&t.enabled))){this.connecting.add(e),oe.set(e,{state:`connecting`}),ce();try{let n=Ee(e);if(e!==`entry`){let t=await Fe(e,De(n,`/api/browser-access`),{signal:AbortSignal.timeout(15e3)});if(!t.ok)throw Error(`授权或连接失败(${t.status})`);let r=await t.json();if(r.id!==n.identity||r.protocol!==1)throw Error(`服务器身份或协议发生变化,请重新添加连接`);se.set(e,r.assetLease)}if(this.stopped||!O.some(t=>t.id===e&&t.enabled))return;let r=De(n,`/ws?state=focused`);r.protocol=r.protocol===`https:`?`wss:`:`ws:`,this.focus&&h(this.focus).server===e&&r.searchParams.set(`conversationId`,h(this.focus).id);let i=e===`entry`||n.managed?new WebSocket(r):new WebSocket(r,[`super-pi`,`super-pi-key.${k[e]}`]),a=!1;this.sockets.set(e,i),this.socketRevisions.set(e,n.revision??0),i.onopen=()=>{a=!0,oe.set(e,{state:`online`}),ce(),i.send(JSON.stringify({type:`stream.configure`,coalesce:!0})),e===A&&this.onopen?.(),this.onserveropen?.(e),e!==`entry`&&this.leaseTimers.set(e,setInterval(()=>{Fe(e,De(n,`/api/browser-access`)).then(e=>e.json()).then(t=>{t.assetLease&&(se.set(e,t.assetLease),ce())}).catch(()=>{})},9e5))},i.onmessage=({data:t})=>{let n=S(JSON.parse(String(t)),t=>m(e,t));if(n.type===`state`)ne.add(e),this.snapshots.set(e,n.state),N.set(e,n.state),this.aggregate();else{if(Ie.has(n.type)){let t=this.catalogs.get(e)??new Map;t.set(n.type,n),this.catalogs.set(e,t);let r=[`providers.list`,`model.catalog.all`].includes(n.type),i=[`agent.catalog`,`subagent.catalog`].includes(n.type);if(r?e!==j:e!==A&&!(i&&e===j))return}this.deliver({...n,sourceServerId:e})}},i.onclose=n=>{this.stopped||this.sockets.get(e)!==i||(clearInterval(this.leaseTimers.get(e)),this.leaseTimers.delete(e),this.sockets.delete(e),oe.set(e,{state:`offline`,error:`连接中断(code ${n.code}${n.reason?` · ${n.reason}`:``}),正在重连`}),ce(),a&&this.ondisconnect?.(e,n),this.retry(e,a?1:t+1))},i.onerror=()=>{}}catch(n){oe.set(e,{state:`offline`,error:n instanceof Error?n.message:`连接失败`}),ce(),this.retry(e,t+1)}finally{this.connecting.delete(e)}}}retry(e,t){clearTimeout(this.timers.get(e)),this.timers.set(e,setTimeout(()=>{this.timers.delete(e),this.connect(e,t)},Math.min(3e4,1e3*2**Math.min(t,5))))}send(e){let t=JSON.parse(e),n=t.type?.startsWith(`terminal.`)&&t.type!==`terminal.shell.set`,r=typeof t._server==`string`?t._server:void 0,i=ke(t,r??(n?this.terminalServer:A));if(r&&i!==r)throw Error(`命令资源不属于指定服务器`);delete t._server;let a=this.sockets.get(i);if(!a||a.readyState!==WebSocket.OPEN)throw Error(`${P(i)} 未连接,操作未发送`);t.type===`state.subscribe`&&(this.focus=t.conversationId),t.type===`terminal.sync`&&(this.terminalServer=i),Array.isArray(t.images)&&(t.images=t.images.map(e=>({...e,id:g(i,e.id)}))),a.send(JSON.stringify(Ae(t,i)))}canSend(e){try{let t=e,n=t.type?.startsWith(`terminal.`)&&t.type!==`terminal.shell.set`?this.terminalServer:A,r=ke(e,t._server??n);return(!t._server||r===t._server)&&this.sockets.get(r)?.readyState===WebSocket.OPEN}catch{return!1}}close(){this.stopped=!0,clearInterval(this.managementTimer),window.removeEventListener(`super-pi-server-connections`,this.reconfigure),window.removeEventListener(`super-pi-active-server`,this.activate),window.removeEventListener(`super-pi-settings-server`,this.activateSettings);for(let e of this.timers.values())clearTimeout(e);for(let e of this.leaseTimers.values())clearInterval(e);for(let e of this.sockets.values())e.close()}},Re=s(),ze=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Be=t(((e,t)=>{t.exports=ze()})),F=Be();function Ve({anchor:e,label:t,className:n=``,onClose:r,onKeyDown:i,children:a}){let o=(0,u.useRef)(null),s=(0,u.useRef)(null),c=(0,u.useRef)(e??(document.activeElement instanceof HTMLElement?document.activeElement:null));c.current=e??c.current;let l=(0,u.useRef)(r);return l.current=r,(0,u.useLayoutEffect)(()=>{let e=o.current,t={},n=0,r=()=>{let t=c.current,n=t?.isConnected&&t!==document.body?t.getBoundingClientRect():void 0,r=window.visualViewport,i=r?.width??window.innerWidth,a=r?.height??window.innerHeight,o=n?.top??a-28,s=Math.max(0,o-8-8),l=Math.max(0,a-(n?.bottom??a-28)-8-8),u=s>=Math.min(e.scrollHeight,280)||s>=l;e.style.maxHeight=`${Math.max(64,u?s:l)}px`;let d=e.getBoundingClientRect();e.style.left=`${Math.max(8,Math.min(n?.left??i-d.width-8,i-d.width-8))}px`;let f=u?o-8-d.height:(n?.bottom??8)+8;e.style.top=`${Math.max(8,Math.min(f,a-d.height-8))}px`};s.current=r;let i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(r)},a=t=>{let n=t.target;!e.contains(n)&&!c.current?.contains(n)&&l.current()},u=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),l.current(),c.current?.focus())},d=e=>{e.detail!==t&&l.current()};document.addEventListener(`pointerdown`,a,!0),document.addEventListener(`keydown`,u,!0),window.addEventListener(`resize`,i),window.visualViewport?.addEventListener(`resize`,i),window.addEventListener(`super-pi-status-popover`,d),window.dispatchEvent(new CustomEvent(`super-pi-status-popover`,{detail:t}));let f=new ResizeObserver(i);return f.observe(e),r(),e.contains(document.activeElement)||(e.querySelector(`input:not([disabled]),select:not([disabled])`)??e.querySelector(`button:not([disabled])`))?.focus({preventScroll:!0}),()=>{s.current=null,f.disconnect(),cancelAnimationFrame(n),document.removeEventListener(`pointerdown`,a,!0),document.removeEventListener(`keydown`,u,!0),window.removeEventListener(`resize`,i),window.visualViewport?.removeEventListener(`resize`,i),window.removeEventListener(`super-pi-status-popover`,d),(e.contains(document.activeElement)||document.activeElement===document.body)&&c.current?.focus({preventScroll:!0})}},[]),(0,u.useLayoutEffect)(()=>{s.current?.()}),(0,u.useLayoutEffect)(()=>{window.dispatchEvent(new Event(`resize`))},[e]),(0,Re.createPortal)((0,F.jsx)(`dialog`,{open:!0,ref:o,"aria-label":t,"aria-modal":`false`,className:`anchored-popover ${n}`,onKeyDown:i,children:a}),document.body)}function He({verification:e,onAnswer:t,onCancel:n}){let r=(0,u.useId)(),[i,a]=(0,u.useState)(()=>e.prompts.map(()=>``)),[o,s]=(0,u.useState)(!1),[c,l]=(0,u.useState)(``);return(0,F.jsxs)(`form`,{className:`managed-server-form managed-auth-challenge`,"data-ssh-verification":e.id,"aria-labelledby":r,onSubmit:async n=>{n.preventDefault(),s(!0),l(``);let r=i;a(e.prompts.map(()=>``));try{await t(r)}catch(e){l(e instanceof Error?e.message:`验证未完成,请重试`)}finally{s(!1)}},children:[(0,F.jsxs)(`h4`,{id:r,children:[`等待 SSH 交互验证`,e.name?` · ${e.name}`:``]}),e.instruction&&(0,F.jsx)(`p`,{className:`managed-auth-instruction`,children:e.instruction}),e.prompts.map((e,t)=>(0,F.jsxs)(`label`,{children:[e.prompt||`验证输入 ${t+1}`,(0,F.jsx)(`input`,{type:e.echo?`text`:`password`,value:i[t],autoComplete:e.echo?`off`:`new-password`,spellCheck:!1,autoFocus:t===0,disabled:o,onChange:e=>a(n=>n.map((n,r)=>r===t?e.target.value:n))})]},t)),(0,F.jsxs)(`small`,{children:[`仅用于本次连接,不保存验证回答。请在 `,new Date(e.expiresAt).toLocaleTimeString(),` 前完成。`]}),c&&(0,F.jsx)(`p`,{className:`server-connection-error`,role:`alert`,children:c}),(0,F.jsxs)(`div`,{className:`server-connection-actions`,children:[(0,F.jsx)(`button`,{type:`submit`,disabled:o,children:o?`正在验证…`:e.prompts.length?`提交验证`:`继续验证`}),(0,F.jsx)(`button`,{type:`button`,disabled:o,onClick:async()=>{a(e.prompts.map(()=>``)),s(!0);try{await n()}catch(e){l(e instanceof Error?e.message:`取消失败,请重试`)}finally{s(!1)}},children:`取消验证`})]})]})}function Ue({connected:e,onSettings:t,onSelectServer:n}){let{connections:r,activeServer:i}=ue(),a=r.find(e=>e.id===i),[o,s]=(0,u.useState)(),[c,l]=(0,u.useState)(``),[d,f]=(0,u.useState)(!1),p=(0,u.useRef)(null),m=async e=>{let t=await Ne(`/api/managed-servers`,{signal:e},`entry`),n=await t.json();if(!t.ok)throw Error(n.error??`无法读取服务器状态`);return n.profiles.find(e=>e.id===a?.managedId)};(0,u.useEffect)(()=>{if(s(void 0),l(``),!a?.managedId)return;let e=new AbortController,t=()=>{m(e.signal).then(t=>{e.signal.aborted||(s(t),l(``))}).catch(t=>{e.signal.aborted||l(t.message)})};t();let n=setInterval(t,2e3);return()=>{e.abort(),clearInterval(n)}},[a?.managedId]);let h=async(e,t={})=>{let n=await Ne(`/api/managed-servers`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:a?.managedId,action:e,...t})},`entry`),r=await n.json();if(!n.ok)throw Error(r.error??`操作未完成`);s(r.profiles?.find(e=>e.id===a?.managedId))};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{ref:p,type:`button`,className:`workbench-connection workbench-status-button`,"data-workbench-connection":e?`online`:`offline`,"aria-haspopup":`dialog`,"aria-expanded":d,title:`查看连接状态与完成验证`,onClick:()=>f(e=>!e),children:[(0,F.jsx)(`i`,{"aria-hidden":`true`}),(0,F.jsx)(`span`,{children:o?.verification?`SSH 等待验证`:e?`已连接`:`正在连接`}),(0,F.jsx)(`code`,{children:a?.name})]}),d&&(0,F.jsx)(Ve,{anchor:p.current,label:`服务连接详情`,className:`connection-status-dialog`,onClose:()=>f(!1),children:(0,F.jsxs)(`div`,{className:`connection-status-content`,children:[(0,F.jsxs)(`header`,{children:[(0,F.jsxs)(`h2`,{children:[a?.name,` · 连接`]}),(0,F.jsx)(`button`,{type:`button`,"aria-label":`关闭连接详情`,onClick:()=>f(!1),children:`关闭`})]}),(0,F.jsxs)(`label`,{children:[`当前服务端 `,(0,F.jsx)(`select`,{"aria-label":`切换当前服务端`,value:i,onChange:e=>{n(e.target.value),f(!1)},children:r.filter(e=>e.enabled).map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,F.jsxs)(`dl`,{children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`服务连接`}),(0,F.jsx)(`dd`,{children:e?`已连接`:`连接中断,正在重连`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`服务地址`}),(0,F.jsx)(`dd`,{children:o?.serviceUrl??a?.url})]}),o&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`SSH 管理`}),(0,F.jsx)(`dd`,{children:o.ssh===`online`?`已连接`:o.ssh===`awaitingVerification`?`等待验证`:o.ssh===`connecting`?`连接中`:`未连接`})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`dt`,{children:`模型通道`}),(0,F.jsxs)(`dd`,{children:[o.modelChannel===`online`?`已连接`:`未连接`,o.modelTransport===`direct`?` · 服务端口`:``]})]})]})]}),o?.sshError&&(0,F.jsx)(`p`,{role:`status`,children:o.sshError}),o?.modelError&&(0,F.jsx)(`p`,{role:`status`,children:o.modelError}),o?.verification&&(0,F.jsx)(He,{verification:o.verification,onAnswer:e=>h(`answerVerification`,{verificationId:o.verification.id,answers:e}),onCancel:()=>h(`cancelVerification`,{verificationId:o.verification.id})},o.verification.id),c&&(0,F.jsx)(`p`,{role:`alert`,children:c}),o&&!o.verification&&o.ssh!==`online`&&(0,F.jsx)(`button`,{type:`button`,disabled:o.ssh===`connecting`,onClick:()=>void h(`connectSsh`).catch(e=>l(e.message)),children:`连接 SSH 管理`}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{f(!1),t()},children:`管理服务器连接`})]})})]})}function We({title:e,choices:t,onChoose:n,onClose:r,children:i,onHighlight:a,anchor:o}){let[s,c]=(0,u.useState)(``),l=t?.filter(e=>[e.label,e.detail,e.group].join(` `).toLowerCase().includes(s.toLowerCase()));return(0,F.jsxs)(Ve,{anchor:o,label:e,className:`status-bar-menu`,onClose:r,onKeyDown:e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=[...e.currentTarget.querySelectorAll(`[data-status-option]:not(:disabled)`)];if(!t.length)return;e.preventDefault();let n=t.indexOf(document.activeElement);t[n<0?e.key===`ArrowDown`?0:t.length-1:(n+(e.key===`ArrowDown`?1:t.length-1))%t.length]?.focus()},children:[(0,F.jsxs)(`header`,{children:[(0,F.jsx)(`h2`,{children:e}),(0,F.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`关闭状态栏操作`,children:`关闭`})]}),t&&(0,F.jsx)(`input`,{autoFocus:!0,placeholder:`搜索…`,"aria-label":e+`搜索`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l?.length===1&&!l[0].disabled&&n?.(l[0].id)}}),(0,F.jsxs)(`div`,{className:`status-bar-options`,children:[l?.map((e,t)=>(0,F.jsxs)(`div`,{children:[e.group&&e.group!==l[t-1]?.group&&(0,F.jsx)(`h3`,{children:e.group}),(0,F.jsxs)(`button`,{type:`button`,"data-status-option":e.id,disabled:e.disabled,onFocus:()=>a?.(e.id),onMouseEnter:()=>a?.(e.id),onClick:()=>n?.(e.id),children:[(0,F.jsx)(`strong`,{children:e.label}),e.detail&&(0,F.jsx)(`small`,{children:e.detail})]})]},e.id)),l?.length===0&&(0,F.jsx)(`p`,{children:`没有匹配项`})]}),i]})}var Ge=`default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; frame-src 'self'; object-src 'none'; form-action 'none'; base-uri 'none'`,Ke={png:{kind:`image`,mime:`image/png`},jpg:{kind:`image`,mime:`image/jpeg`},jpeg:{kind:`image`,mime:`image/jpeg`},gif:{kind:`image`,mime:`image/gif`},webp:{kind:`image`,mime:`image/webp`},svg:{kind:`image`,mime:`image/svg+xml`},html:{kind:`html`,mime:`text/html; charset=utf-8`},htm:{kind:`html`,mime:`text/html; charset=utf-8`}};function qe(e){return Ke[/\.([a-z]+)$/i.exec(e)?.[1].toLowerCase()??``]}function Je(e){if(!(!e||/[\u0000-\u001f\u007f]/.test(e)||/^[\\/]{2}/.test(e))&&(!/^[a-z][a-z\d+.-]*:/i.test(e)||/^[a-z]:[\\/]/i.test(e)))return qe(e)?.kind}function Ye(e,t,n){return`/api/message-artifact?${new URLSearchParams({workspaceId:e,conversationId:t,path:n})}`}function Xe(e){let t=Ze(e);if(t&&/\.pptx$/i.test(t))return{path:e,line:1,artifact:!0};let n=/#L([1-9]\d*)(?:C([1-9]\d*))?(?:-L?[1-9]\d*)?$/i.exec(e)??/:([1-9]\d*)(?::([1-9]\d*))?$/.exec(e);if(!n||n.index===0)return;let r=Number(n[1]),i=n[2]?Number(n[2]):void 0;if(Number.isSafeInteger(r)&&(i===void 0||Number.isSafeInteger(i)))return{path:e.slice(0,n.index),line:r,column:i}}function Ze(e){try{let t=decodeURIComponent(e).replaceAll(`\\`,`/`);if(!t||t.startsWith(`//`)||/[\u0000-\u001f\u007f?#]/.test(t)||/:/.test(t.replace(/^[a-z]:\//i,``)))return;let n=t.split(`/`).at(-1)??``;return!/^(?:[\w.-]*\.[\w.-]+|Makefile|Dockerfile|LICENSE)$/iu.test(n)&&!/\.[\p{L}\p{N}_-]+$/u.test(n)?void 0:t}catch{return}}function I(e){let t=Xe(e);return!!(t&&Ze(t.path))}function Qe(e,t){let n=e;if(/^https?:\/\//i.test(e)){let r;try{r=new URL(e)}catch{return}let i=[`localhost`,`127.0.0.1`,`[::1]`].includes(r.hostname)&&r.port===`3080`;if(r.username||r.password||r.search||!r.hash||r.origin!==t.origin&&!i)return;n=r.pathname+r.hash}let r=Xe(n);if(!r)return;let i=Ze(r.path);if(!i)return;let a=t.root.replaceAll(`\\`,`/`).replace(/\/+$/,``),o=/^[a-z]:\//i.test(a),s=e=>o?e.toLowerCase():e,c=s(i).startsWith(s(a+`/`));if(/^[a-z]:\//i.test(i)&&!c)return;let l=(c||i.startsWith(`/`)?``:t.cwd).split(`/`).filter(Boolean),u=c?i.slice(a.length+1):i;for(let e of u.split(`/`))if(e&&e!==`.`){if(e===`..`){if(!l.length)return;l.pop()}else l.push(e)}return{...r,path:l.join(`/`)}}function $e(e){let t=/(\/\/.*|#[^\n]*|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:const|let|var|function|return|if|else|for|while|class|import|from|export|def|fn|true|false|null|undefined|async|await|try|catch|throw|switch|case|break|continue|new|this|static|public|private|interface|type|enum|struct|impl|pub|mod|use|as|where|match|loop|mut|ref|self|Self)\b|\b\d+(?:\.\d+)?\b)/g,n=[],r=0,i;for(;i=t.exec(e);){i.index>r&&n.push({text:e.slice(r,i.index),kind:`plain`});let t=i[0],a=/^(\/\/|#)/.test(t)?`comment`:/^["']/.test(t)?`string`:/^\d/.test(t)?`number`:`keyword`;n.push({text:t,kind:a}),r=i.index+t.length}return r<e.length&&n.push({text:e.slice(r),kind:`plain`}),n}var et=new Set([`http`,`https`,`mailto`]),tt=e=>{let t=e.codePointAt(0)??0;return t<=32||t===127||/\s/.test(e)},nt=/^([a-z][a-z0-9+.-]*):/i;function rt(e){let t=[...e].filter(e=>!tt(e)).join(``);if(!t)return;let n=nt.exec(t);return n?et.has(n[1].toLowerCase())?e:void 0:e}var it=/[!-/:-@[-`{-~]/,at=e=>e!==void 0&&/[\p{L}\p{N}]/u.test(e);function ot(e,t,n){let r=0;for(;e[t+r]===n;)r+=1;return r}function st(e){let t=e.replace(/\n/g,` `);return t.length>2&&t.startsWith(` `)&&t.endsWith(` `)&&t.trim()!==``?t.slice(1,-1):t}function ct(e,t,n){for(let r=t;r<e.length;r+=1){if(e[r]===`\\`){r+=1;continue}if(e[r]!=="`")continue;let t=ot(e,r,"`");if(t===n)return r;r+=t-1}return-1}function lt(e,t,n,r){for(let i=t;i<e.length;i+=1){if(n===`$`){if(e[i]===`
|
|
11
11
|
`)break;if(e[i]==="`"){let t=ot(e,i,"`");if(ct(e,i+t,t)!==-1)break}}if(e.startsWith(n,i)||r&&e.startsWith(r,i))return i;e[i]===`\\`&&(i+=1)}return-1}function ut(e,t){if(e[t]!==`(`)return;let n=1,r=-1;for(let i=t+1;i<e.length;i+=1){let t=e[i];if(t===`\\`)i+=1;else if(t===`(`)n+=1;else if(t===`)`&&(--n,n===0)){r=i;break}}if(r===-1)return;let i=e.slice(t+1,r).trim();if(i.length>1&&i.startsWith(`<`)&&i.endsWith(`>`))return{href:i.slice(1,-1),next:r+1};let a=/^(.*?)\s+"([^"]*)"$/.exec(i);if(a)return{href:a[1],title:a[2],next:r+1};if(!/\s/.test(i))return{href:i,next:r+1}}function dt(e,t){let n=1;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`\\`)r+=1;else if(t===`[`)n+=1;else if(t===`]`&&(--n,n===0))return r}return-1}function ft(e,t,n,r){for(let i=t;i<e.length;i+=1){let t=gt(e,i);if(t)i=t.next-1;else if(e[i]===`\\`)i+=1;else if(e[i]==="`"){let t=ot(e,i,"`"),n=ct(e,i+t,t);if(n!==-1){i=n+t-1;continue}i+=t-1}else if(e[i]===r&&!(ot(e,i,r)<n.length)&&!(r===`_`&&at(e[i-1])&&at(e[i+1])))return i}return-1}var pt=/^<([a-z][a-z0-9+.-]*:[^<>\s]*)>/i,mt=/[\s(\[{,:;=+\/|(【「『]/,ht=/[\u2E80-\u9FFF\uF900-\uFAFF\u3000-\uFF60\uFFE0-\uFFE6]/;function gt(e,t){let n=e[t],r=e[t+1],i=n===`$`&&r===`$`||n===`\\`&&r===`[`,a=n===`\\`&&r===`(`,o=n===`$`&&!i;if(!i&&!a&&!o||o&&t>0&&!mt.test(e[t-1])&&!ht.test(e[t-1]))return;let s=n===`\\`?a?`\\)`:`\\]`:i?`$$`:`$`,c=t+s.length,l=lt(e,c,s);if(l===-1)return;let u=e.slice(c,l);if(u.trim()&&!(o&&(/^\s|\s$/.test(u)||/[0-9$]/.test(e[l+1]??``)||/^\d[\d.,]*[\s,、:;。?!]*\p{Script=Han}/u.test(u))))return{node:{type:`math`,source:u,display:i},next:l+s.length}}function _t(e,t={}){let n=[],r=``,i=()=>{r&&=(n.push({type:`text`,value:r}),``)},a=e=>{i(),n.push(e)};for(let o=0;o<e.length;){let s=e[o],c=gt(e,o);if(c){a(c.node),o=c.next;continue}let l=e.slice(o,o+2);if(l===`$$`||l===`\\(`||l===`\\[`||l===`\\)`||l===`\\]`)r+=l,o+=2;else if(s===`\\`&&it.test(e[o+1]??``))r+=e[o+1],o+=2;else if(s==="`"){let t=ot(e,o,"`"),n=ct(e,o+t,t);if(n!==-1){a({type:`code`,value:st(e.slice(o+t,n))}),o=n+t;continue}r+="`".repeat(t),o+=t}else if(s===`<`){let t=pt.exec(e.slice(o));if(t){let e=rt(t[1]);if(e){a({type:`link`,href:e,children:[{type:`text`,value:t[1]}]}),o+=t[0].length;continue}}r+=s,o+=1}else if(s===`!`&&e[o+1]===`[`||s===`[`){let n=s===`!`,i=o+(n?2:1),c=dt(e,i),l=c===-1?void 0:ut(e,c+1);if(l){let r=Je(l.href);if(r&&(n||r===`html`)){a({type:`artifact`,kind:r,path:l.href,label:e.slice(i,c)}),o=l.next;continue}if(!n&&I(l.href)){a({type:`source-link`,destination:l.href,children:_t(e.slice(i,c),t)}),o=l.next;continue}let s=rt(l.href);if(s){a({type:`link`,href:s,...l.title===void 0?{}:{title:l.title},children:_t(e.slice(i,c),t)}),o=l.next;continue}}r+=s,o+=1}else if(t.strikethrough!==!1&&s===`~`&&e[o+1]===`~`){let n=ft(e,o+2,`~~`,`~`);if(n>o+2){a({type:`del`,children:_t(e.slice(o+2,n),t)}),o=n+2;continue}r+=`~~`,o+=2}else if(s===`*`||s===`_`){let n=ot(e,o,s);if((n>=2?t.bold:t.italic)===!1){r+=s.repeat(n),o+=n;continue}let i=n>=2?s.repeat(2):s,c=s===`_`&&at(e[o-1])&&at(e[o+n])?-1:ft(e,o+i.length,i,s);if(c>o+i.length){let r=_t(e.slice(o+i.length,c),t);a(n>=2?{type:`strong`,children:r}:{type:`em`,children:r}),o=c+i.length;continue}r+=i,o+=i.length}else s===`
|
|
12
12
|
`?(/[ \t]{2,}$/.test(r)||r.endsWith(`\\`)?(r=r.replace(/(?:[ \t]+|\\)$/,``),i(),n.push({type:`break`})):r+=s,o+=1):(r+=s,o+=1)}return i(),n}var vt=/^(\s*)(`{3,}|~{3,})\s*([^`\s]*)\s*$/,yt=/^ {0,3}(#{1,6})(?:\s+(.*?))?\s*#*\s*$/,bt=/^ {0,3}(?:(?:\*\s*){3,}|(?:-\s*){3,}|(?:_\s*){3,})$/,xt=/^(\s*)([-*+])(\s+)(.*)$/,St=/^(\s*)(\d{1,9})([.)])(\s+)(.*)$/,Ct=/^ {0,3}>\s?(.*)$/,wt=/^ {0,3}\|?\s*:?-{1,}:?\s*(?:\|\s*:?-{1,}:?\s*)*\|?\s*$/,Tt=/^\s*(\$\$(?!\$)|\\\[|\\begin\{((?:equation|align|alignat|gather|multline|flalign|matrix|pmatrix|bmatrix|vmatrix|Vmatrix|Bmatrix|cases)\*?|aligned|alignedat|gathered|split|array|smallmatrix|dcases|rcases)\})/;function Et(e,t){let n=Tt.exec(e[t]);if(!n)return;let r=n[1],i=n[2],a=i?`\\end{`+i+`}`:r===`$$`?`$$`:`\\]`,o=[],s=1;for(let c=t;c<e.length;c+=1){let l=e[c];if(c!==t&&(vt.test(l)||yt.test(l)||l.trimStart().startsWith(`\\[`)))return;let u=c===t?n[0].length:0,d=lt(l,u,a,i&&r);for(;i&&d!==-1;){let e=l.startsWith(r,d);if(s+=e?1:-1,!s)break;d=lt(l,d+(e?r:a).length,a,r)}if(d===-1){o.push(l.slice(u));continue}if(l.slice(d+a.length).trim())return;o.push(l.slice(u,d));let f=o.join(`
|
|
13
13
|
`).trim();return f?{node:{type:`math-block`,source:i?r+o.join(`
|
|
@@ -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 Df({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?Tf(r,e,t,f,i):wf(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 Ne(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?Ef(a,/\.tsv$/i.test(n)?` `:`,`):void 0,[i,a,n,m]);return(0,F.jsxs)(`section`,{className:`workspace-file-preview`,"aria-label":`预览 ${r}`,"data-workspace-file-preview":i,"data-file-readonly":f?`1`:void 0,children:[(0,F.jsxs)(`div`,{className:`workspace-file-preview-head`,children:[d,(0,F.jsxs)(`div`,{className:`workspace-file-preview-actions`,children:[f&&(0,F.jsx)(`span`,{children:`外部文件 · 只读`}),f&&p&&(0,F.jsx)(`button`,{type:`button`,onClick:p,children:`重新读取`}),o&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),children:m?`查看表格`:f?`查看原文`:`编辑原文`}),(0,F.jsxs)(`a`,{href:S,download:r,children:[(0,F.jsx)(yf,{name:`download`}),`下载`]})]})]}),l&&!m&&(0,F.jsx)(`p`,{role:`status`,children:o?`磁盘上的文件已变化,请打开原文查看。`:`磁盘上的文件已移走或无法读取。`}),m?o:v?(0,F.jsx)(`p`,{role:`status`,children:`预览无法打开,可以下载文件。`}):(0,F.jsxs)(F.Fragment,{children:[i===`download`&&(0,F.jsx)(`p`,{children:`此文件可以下载。`}),i===`presentation`&&(f?(0,F.jsx)(`p`,{children:`外部演示稿可通过上方按钮下载。`}):(0,F.jsx)(Cf,{workspaceId:e,cwd:t,path:n,version:s})),i===`image`&&(0,F.jsx)(`img`,{src:x,alt:r,onError:()=>y(!0)}),i===`pdf`&&(0,F.jsx)(`iframe`,{src:x,title:r}),i===`audio`&&(0,F.jsx)(`audio`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`video`&&(0,F.jsx)(`video`,{src:x,controls:!0,preload:`metadata`,onError:()=>y(!0)}),i===`document`&&(g?.error?(0,F.jsx)(`p`,{role:`alert`,children:g.error}):g?(0,F.jsxs)(F.Fragment,{children:[g.warnings?.map(e=>(0,F.jsx)(`p`,{children:e},e)),(0,F.jsx)(`pre`,{children:g.text||`此文档没有可显示的文字。`})]}):(0,F.jsx)(`p`,{children:`正在读取文档…`})),w&&(w.rows.length?(0,F.jsx)(`div`,{className:`workspace-file-table`,children:(0,F.jsx)(`table`,{children:(0,F.jsx)(`tbody`,{children:w.rows.map((e,t)=>(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{scope:`row`,children:t+1}),e.map((e,t)=>(0,F.jsx)(`td`,{children:e},t))]},t))})})}):(0,F.jsx)(`p`,{children:`文件为空。`})),w?.clipped&&(0,F.jsx)(`p`,{className:`workspace-file-preview-limit`,children:`表格超出预览范围。完整内容可在原文中查看。`})]})]})}var Of={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 kf(e){return/\.([^./]+)$/.exec(e)?.[1].toLowerCase()??``}function Af(e){let t=kf(e);return Object.hasOwn(Of,t)?Of[t]:void 0}function jf(e){let t=Af(e);if(t===`application/pdf`)return`pdf`;if(t?.startsWith(`image/`))return`image`;if(t?.startsWith(`audio/`))return`audio`;if(t?.startsWith(`video/`))return`video`;if(/\.(csv|tsv)$/i.test(e))return`table`;if(/\.docx$/i.test(e))return`document`;if(/\.pptx$/i.test(e))return`presentation`}var Mf=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`))),Nf=(e,t)=>!t||e===t||e.startsWith(`${t}/`),Pf=e=>e.split(`/`).at(-1)??e;function Ff(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 If({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,F.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,F.jsxs)(`div`,{className:`file-explorer-dialog-body`,children:[(0,F.jsx)(`h2`,{children:e}),n]})})}function Lf({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,F.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,F.jsxs)(`div`,{className:`file-inline-row`,children:[(0,F.jsx)(Fr,{path:e.path,category:e.directory?`folder`:void 0}),(0,F.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,F.jsx)(`button`,{className:`explorer-icon-button`,type:`submit`,title:t,"aria-label":t,disabled:r,children:(0,F.jsx)(yf,{name:`right`})}),(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,onClick:s,disabled:r,title:`取消`,"aria-label":`取消`,children:(0,F.jsx)(yf,{name:`close`})})]}),i&&(0,F.jsx)(`p`,{className:`file-inline-error`,role:`alert`,children:i})]})}function Rf({files:e,source:t,scopeName:n}){let[r,i]=(0,u.useState)(Mf(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,F.jsxs)(`div`,{className:`file-move-picker`,children:[(0,F.jsx)(`input`,{type:`hidden`,name:`parent`,value:r}),(0,F.jsxs)(`div`,{className:`file-move-location`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:!r,"aria-label":`上一级`,onClick:()=>i(Mf(r)),children:`↑`}),(0,F.jsx)(`span`,{title:r||n,children:r||n})]}),(0,F.jsx)(`ul`,{"aria-label":`目标文件夹`,children:s.map(e=>(0,F.jsx)(`li`,{children:(0,F.jsxs)(`button`,{type:`button`,onClick:()=>i(e.path),children:[(0,F.jsx)(Fr,{category:`folder`}),(0,F.jsx)(`span`,{children:e.name}),(0,F.jsx)(yf,{name:`right`})]})},e.path))}),!s.length&&(0,F.jsx)(`p`,{children:a?`error`in a?a.error.message:`此处没有子文件夹。`:`正在读取文件夹…`})]})}function zf({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)=>wf(t,e??``,n,r,i);async function E(e,t){let n=await Ne(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(Mf(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:Pf(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 ee(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`)??Pf(n.path));if(t===`move`&&!n.directory&&kf(n.path)!==kf(a)&&r.open.some(e=>e.path===n.path&&e.dirty)){v(`更换文件扩展名之前,请先保存草稿。`);return}let o=String(i.get(`parent`)??(t===`move`?Mf(n.path):n.path));d.move&&o===Mf(n.path)?v(`请选择另一个文件夹。`):j({action:t,path:n.path,parent:o,name:a})}async function M(){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 te(e){S.current=e,O(!0),x.current?.click()}async function N(t,i,a){let o=w.current;if(!e||!o||!i.length||h)return;g(!0),v(``),b(void 0);let s=[],c=[],l=[];try{for(let e of i){if(o!==w.current)return;try{let n=a?.find(t=>t.file===e)?.etag;if(!a){let n=await E(T(`upload-check`,t,{name:e.name}));if(n.exists){!n.replaceable||!n.meta?c.push(`${e.name}:同名目录或链接`):s.push({file:e,etag:n.meta.etag});continue}}let r=await E(T(`upload`,t,{name:e.name}),{method:`POST`,headers:{"content-type":`application/octet-stream`,...n?{"if-match":n}:{}},body:e});l.push(r.path)}catch(t){c.push(`${e.name}:${t.message}`)}}if(w.current!==o)return;l[0]&&r.revealPath(l[0]),l.length&&r.invalidateTree(e,l.map(e=>n?`${n}/${e}`:e)),s.length&&b({parent:t,items:s}),r.setNotice([l.length?`已上传 ${l.length} 个文件`:``,...c].filter(Boolean).join(`。`))}finally{w.current===o&&g(!1)}}function ne(e,t){l(void 0),a?.(e||`.`,t)}function re(e){O(!0),Bd(e||`.`).then(t=>r.setNotice(t?`已复制相对路径。`:`相对路径:${e||`.`}`))}let ie=d?.action===`create-file`?`新建文件`:d?.action===`create-directory`?`新建文件夹`:d?.action===`trash`?`移到回收站`:d?.move?`移动到文件夹`:`重命名`,ae={path:``,directory:!0},oe=d?.action===`create-file`||d?.action===`create-directory`,se=d?.action===`move`&&!d.move,ce=(e,t,n)=>!d||d.target.path!==e||(t===`child`?!oe:!se)?null:(0,F.jsx)(Lf,{target:{...d.target,directory:oe?d.action===`create-directory`:d.target.directory},label:ie,initial:se?Pf(e):``,busy:h,error:_,depth:n,submit:ee,close:A},`${d.action}:${e}`),le=(e,t)=>{h||e.linked||e.directory&&Nf(t,e.path)||t===Mf(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:Pf(e.path)}))},ue=(0,F.jsxs)(`div`,{className:`file-explorer-toolbar`,role:`group`,"aria-label":`文件操作`,children:[(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-file`,title:`新建文件`,"aria-label":`新建文件`,onClick:e=>k(`create-file`,ae,!1,e.currentTarget),disabled:!e||h,children:(0,F.jsx)(yf,{name:`file`})}),(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`new-directory`,title:`新建文件夹`,"aria-label":`新建文件夹`,onClick:e=>k(`create-directory`,ae,!1,e.currentTarget),disabled:!e||h,children:(0,F.jsx)(yf,{name:`folder`})}),(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-file-refresh":`1`,title:`刷新目录`,"aria-label":`刷新目录`,onClick:r.refreshTree,disabled:!e,children:(0,F.jsx)(yf,{name:`refresh`})}),(0,F.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,F.jsx)(yf,{name:`collapse`})}),(0,F.jsx)(`button`,{className:`explorer-icon-button`,type:`button`,"data-explorer-command":`root-menu`,"aria-haspopup":`menu`,"aria-expanded":c?.target.path===``,onClick:e=>D(ae,bf(e.currentTarget)),title:`更多文件操作`,"aria-label":`更多文件操作`,disabled:!e||h,children:(0,F.jsx)(yf,{name:`more`})})]}),de=(e,t,n,r,i)=>(0,F.jsxs)(`button`,{type:`button`,role:`menuitem`,tabIndex:-1,className:`file-context-item`,"data-explorer-command":r,onClick:n,children:[(0,F.jsx)(yf,{name:t}),(0,F.jsx)(`span`,{children:e}),i&&(0,F.jsx)(`kbd`,{children:i})]});return{controls:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`input`,{ref:x,type:`file`,multiple:!0,hidden:!0,"aria-label":`上传工作区文件`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,N(S.current,t)}}),c&&(0,F.jsxs)(xf,{label:c.target.path||t,anchor:c.anchor,close:O,children:[c.target.directory&&!c.target.linked&&(0,F.jsxs)(F.Fragment,{children:[s&&de(`在此文件夹中搜索`,`search`,()=>{let e=c.target.path;O(!1),s(e)},`search-folder`),de(`新建文件`,`file`,()=>k(`create-file`,c.target),`new-file`),de(`新建文件夹`,`folder`,()=>k(`create-directory`,c.target),`new-directory`),de(`上传到此处`,`upload`,()=>te(c.target.path),`upload`),(0,F.jsx)(`div`,{role:`separator`})]}),c.target.path&&!c.target.linked&&(0,F.jsxs)(F.Fragment,{children:[de(`重命名`,`rename`,()=>k(`move`,c.target),`rename`,`F2`),de(`移动到文件夹`,`move`,()=>k(`move`,c.target,!0),`move`),(0,F.jsx)(`div`,{role:`separator`})]}),!c.target.linked&&a&&de(`引用到会话`,`reference`,()=>ne(c.target.path,c.target.directory),`reference`),de(`复制相对路径`,`copy`,()=>re(c.target.path)),!c.target.directory&&!c.target.linked&&(0,F.jsxs)(`a`,{role:`menuitem`,tabIndex:-1,className:`file-context-item`,href:T(`asset`,c.target.path,{download:`1`}),download:Pf(c.target.path),onClick:()=>O(!0),children:[(0,F.jsx)(yf,{name:`download`}),(0,F.jsx)(`span`,{children:`下载`})]}),!c.target.path&&de(`打开回收站`,`trash`,()=>void M(),`trash-list`),!!c.target.path&&!c.target.linked&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{role:`separator`}),de(`移到回收站`,`trash`,()=>k(`trash`,c.target),`trash`,`Delete`)]})]}),d&&!oe&&!se&&(0,F.jsx)(If,{title:ie,cancel:()=>{h||A()},children:(0,F.jsxs)(`form`,{onSubmit:ee,className:`file-explorer-form`,children:[d.action===`trash`?(0,F.jsxs)(`p`,{children:[`将「`,d.target.path,`」移到回收站?`]}):(0,F.jsx)(Rf,{files:r,source:d.target,scopeName:t}),_&&(0,F.jsx)(`p`,{role:`alert`,children:_}),(0,F.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:h,onClick:A,children:`取消`}),(0,F.jsx)(`button`,{type:`submit`,disabled:h,children:d.move?`移动到此处`:ie})]})]})}),p&&(0,F.jsxs)(If,{title:`回收站`,cancel:()=>{h||m(void 0)},children:[_&&(0,F.jsx)(`p`,{role:`alert`,children:_}),p.length?(0,F.jsx)(`ul`,{className:`file-explorer-trash`,children:p.map(e=>(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`span`,{children:e.path}),(0,F.jsx)(`button`,{type:`button`,"data-explorer-restore":e.path,disabled:h,onClick:()=>void j({action:`restore`,id:e.id}),children:`还原`})]},e.id))}):(0,F.jsx)(`p`,{children:`回收站为空。`}),(0,F.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>m(void 0),children:`关闭`})]}),y&&(0,F.jsxs)(If,{title:`同名文件`,cancel:()=>b(void 0),children:[(0,F.jsx)(`p`,{children:`以下文件已经存在。替换前会再次检查磁盘版本。`}),(0,F.jsx)(`ul`,{children:y.items.map(e=>(0,F.jsx)(`li`,{children:e.file.name},e.file.name))}),(0,F.jsxs)(`div`,{className:`file-explorer-form-buttons`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>{r.setNotice(`已跳过 ${y.items.length} 个同名文件。`),b(void 0)},children:`跳过`}),(0,F.jsx)(`button`,{type:`button`,"data-file-replace-upload":`1`,onClick:()=>void N(y.parent,y.items.map(e=>e.file),y.items),children:`替换`})]})]})]}),toolbar:ue,inline:ce,editing:oe||se,busy:h,openMenu:D,showAction:k,upload:N,moveTo:le}}var Bf=[{id:`path`,label:`文件名 / 路径`,shortcut:`Ctrl+P`},{id:`content`,label:`文件内容`,shortcut:`Ctrl+Shift+F`},{id:`session`,label:`会话消息`}];function Vf({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,F.jsx)(`div`,{className:`workbench-search-modes`,role:`group`,"aria-label":`搜索范围`,children:Bf.map(n=>(0,F.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,F.jsxs)(`div`,{className:`workbench-search-embedded`,...o,children:[s,i]}):(0,F.jsx)(`div`,{className:`quick-open-backdrop`,...o,role:`presentation`,onMouseDown:n,children:(0,F.jsxs)(`div`,{className:e===`path`?`quick-open`:`quick-open content-search`,role:`dialog`,"aria-modal":`true`,"aria-label":Bf.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 Hf({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(()=>{Ne(`/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(Or(e,`会话搜索没有完成。`))}).finally(()=>{n.signal.aborted||g(!1)})},180);return()=>{clearTimeout(r),n.abort()}},[o,e]),(0,F.jsxs)(Vf,{mode:`session`,query:o,onMode:r,onClose:n,presentation:a,children:[(0,F.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,F.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,F.jsx)(`ul`,{className:`quick-open-results content-search-results`,"aria-label":`会话搜索结果`,children:c?.hits.map((e,t)=>(0,F.jsx)(`li`,{children:(0,F.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,F.jsxs)(`span`,{children:[e.title,` · `,e.role===`user`?`用户`:`Agent`]}),(0,F.jsxs)(`small`,{children:[e.before,(0,F.jsx)(`mark`,{children:e.match}),e.after]})]})},`${e.conversationId}:${e.messageId}`))})]})}var Uf=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,F.jsxs)(`div`,{className:`error-boundary-card`,"data-error-boundary":`1`,children:[(0,F.jsxs)(`div`,{className:`error-boundary-head`,children:[(0,F.jsx)(`span`,{className:`error-boundary-icon`,"aria-hidden":`true`,children:`⚠️`}),(0,F.jsx)(`strong`,{children:`视图渲染遇到异常`})]}),(0,F.jsx)(`p`,{className:`error-boundary-msg`,children:e.message||`未知组件错误`}),(0,F.jsx)(`button`,{type:`button`,className:`error-boundary-retry`,onClick:this.reset,children:`重试`})]}):this.props.children}};function Wf(){}Wf.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(Gf(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 Gf(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 Wf;var Kf=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,qf=/\S/,Jf=new Wf;Jf.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!qf.test(e)&&!qf.test(t)},Jf.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]&&Kf.test(t[n])&&Kf.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var Yf=new Wf;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 Xf(e,t,n){return Yf.diff(e,t,n)}var Zf=new Wf;Zf.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var Qf=new Wf;Qf.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function $f(e){"@babel/helpers - typeof";return $f=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},$f(e)}var ep=Object.prototype.toString,tp=new Wf;tp.useLongestToken=!0,tp.tokenize=Yf.tokenize,tp.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(np(e,null,null,i),i,` `)},tp.equals=function(e,t){return Wf.prototype.equals.call(tp,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function np(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(ep.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=np(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),$f(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]=np(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var rp=new Wf;rp.tokenize=function(e){return e.slice()},rp.join=rp.removeEmpty=function(e){return e};function ip(e,t){let n=Xf(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 ap(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 op=`super-pi.outbox.v1.`,sp=e=>op+JSON.stringify([e.conversationId,e.clientId]);function cp(){try{let e=[];for(let t of Object.keys(window.localStorage).filter(e=>e.startsWith(op)))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===sp(r)&&e.push(n)}catch{}return e.sort((e,t)=>e.queuedAt-t.queuedAt).map(e=>e.send)}catch{return[]}}function lp(e){try{return window.localStorage.setItem(sp(e),JSON.stringify({queuedAt:Date.now(),send:e})),!0}catch{return!1}}function up(e,t){try{window.localStorage.removeItem(sp({conversationId:e,clientId:t}))}catch{}}function dp(e){return m(h(e.conversationId).server,e.clientId)}function fp(e,t,n){let r=e.conversations.find(e=>e.id===t.conversationId),i=dp(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 pp(e,t){try{return JSON.parse(Pn(e)??`null`)??t}catch{return t}}function mp(e,t){try{return Fn(e,JSON.stringify(t)),!0}catch{return!1}}var hp=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.name=`BlameApiError`,this.status=e,this.body=t}},gp=class extends Error{constructor(){super(`Blame 请求已取消`),this.name=`BlameCancelledError`}},_p=(e,t,n=``)=>`/api/git?workspaceId=${encodeURIComponent(e)}&op=blame&path=${encodeURIComponent(t)}${n?`&cwd=${encodeURIComponent(n)}`:``}`;async function vp(e,t,n={}){if(n.signal?.aborted)throw new gp;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 Ne(_p(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 hp(r.status,{error:e.error||`HTTP ${r.status}`,...e.code?{code:e.code}:{}})}return a}catch(e){throw n.signal?.aborted?new gp:a?new hp(408,{error:`请求超时:${Math.round(r/1e3)} 秒内服务端没有响应`,code:`timeout`}):e}finally{clearTimeout(o),n.signal?.removeEventListener(`abort`,s)}}var yp=`\0`,bp=(e,t,n)=>[e,t,n??``].join(yp),xp=24,Sp=new Map;function Cp(e){let t=Sp.get(e);if(t)return Sp.delete(e),Sp.set(e,t),t}function wp(e,t){for(Sp.delete(e),Sp.set(e,t);Sp.size>xp;){let e=Sp.keys().next();if(e.done)break;Sp.delete(e.value)}}var Tp={untracked:`这个文件尚未被 Git 跟踪`,binary:`二进制文件不支持 Blame`,too_large:`文件过大,未显示 Blame`,no_head:`仓库还没有提交`,not_in_revision:`这个版本里没有这个文件`},Ep=`此工作区不是 Git 仓库`;function Dp(e){return e&&Tp[e]?{code:e,text:Tp[e]}:{code:`unsupported`,text:`这个文件暂时不能显示 Blame`}}function Op(e){return e instanceof hp&&e.body.code===`not_a_repo`?{state:`unsupported`,note:{code:`not_a_repo`,text:Ep}}:{state:`error`,note:{code:`error`,text:`读取 Blame 失败:${e instanceof Error&&e.message?e.message:`未知错误`}`}}}var kp=`${yp}uncommitted`;function Ap(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?kp:n.commit??`${yp}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 jp(e){let t=0;for(let n of e.lines)n.line>t&&(t=n.line);return t}function Mp(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 Np(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,Pp(t.date),t.summary?.trim()||`(没有提交摘要)`]}function Pp(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 Fp(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 Ip(e,t,n=!1){return!t||!t.supported?!1:n||Fp(e)!==t.totalLines}var Lp=new WeakMap;function Rp(e){let t=Lp.get(e);if(t)return t;let n={response:e,models:Ap(e),covered:jp(e)};return Lp.set(e,n),n}function zp(e,t){if(!e||t<1)return null;let n=e.models[t-1];return n&&n.line===t?n:null}var Bp=`a1b2c3d · Author`;async function Vp(){let[e,t]=await Promise.all([vn(()=>import(`./dist-D978o95T.js`).then(e=>e.S),__vite__mapDeps([2,1])),vn(()=>import(`./dist-B3-a6uF0.js`).then(e=>e.s),__vite__mapDeps([3,1,2]))]),n=e.StateEffect.define(),r=e.StateField.define({create:()=>null,update:(e,t)=>{for(let e of t.effects)if(e.is(n))return e.value;return e}}),i=e.StateEffect.define(),a=e.StateField.define({create:()=>null,update:(e,t)=>{for(let e of t.effects)if(e.is(i))return e.value;return e}}),o=t.GutterMarker;class s extends o{model;constructor(e){super(),this.model=e}eq(e){let t=e.model;return t?t.line===this.model.line&&t.kind===this.model.kind&&t.data?.commit===this.model.data?.commit&&t.data?.summary===this.model.data?.summary&&t.data?.author===this.model.data?.author:!1}toDOM(){let e=document.createElement(`span`);e.className=`cm-blame-marker cm-blame-${this.model.kind}`,e.setAttribute(`data-file-blame-line`,String(this.model.line)),e.setAttribute(`data-file-blame-kind`,this.model.kind),this.model.data?.commit&&e.setAttribute(`data-file-blame-commit`,this.model.data.commit);let t=Np(this.model);return e.setAttribute(`title`,t.join(`
|
|
287
|
-
`)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=Mp(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=Bp,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=zp(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=zp(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:Hp(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 Hp(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 Np(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function Up(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 Wp=`super-pi.diff-layout.v1`,Gp=`super-pi-diff-layout`;function Kp(){try{return localStorage.getItem(Wp)===`split`}catch{return!1}}function qp(e){let t=t=>{(t.key===Wp||t.key===null)&&e()};return window.addEventListener(Gp,e),window.addEventListener(`storage`,t),()=>{window.removeEventListener(Gp,e),window.removeEventListener(`storage`,t)}}var Jp;function Yp(){return Jp??Kp()}function Xp(){return[(0,u.useSyncExternalStore)(qp,Yp,()=>!1),e=>{Jp=e;try{localStorage.setItem(Wp,e?`split`:`inline`),Jp=void 0}catch{}window.dispatchEvent(new Event(Gp))}]}var Zp=4e3,Qp=(0,u.lazy)(()=>vn(()=>import(`./CodeMirrorEditor-CmfIAppR.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([21,1]))),$p=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},em=15e3,tm=e=>new $p(408,{error:`请求超时:${em/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function nm(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),em);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await Ne(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new $p(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?tm(e):t}finally{clearTimeout(r)}}var rm=e=>e instanceof $p?e:new $p(0,{error:e instanceof Error?e.message:`读取失败`}),im=e=>encodeURIComponent(e),am=e=>e?`&cwd=${im(e)}`:``,om=(e,t,n)=>`/api/files?workspaceId=${im(e)}&path=${im(t)}${am(n)}`,sm=`//workspace/`,cm=e=>e.startsWith(sm)?e.slice(12):void 0,lm=(e,t,n)=>{let r=cm(t);return`/api/file?workspaceId=${im(e)}&path=${im(r??t)}${am(r?``:n)}`},um=(e,t,n)=>lm(e,t,n)+`&meta=1`,dm=(e,t,n)=>`/api/files?workspaceId=${im(e)}&q=${im(t)}${am(n)}`;async function fm(e,t,n){let r=t.current;if(!r)return t.current=nm(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return nm(e,{cache:`no-store`})}function pm(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 mm(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function hm(e){let t=pm(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return mm(t)}function gm(e){return pm(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function _m(e,t,n){if(n.openLink){let r=await nm(`/api/files/open?workspaceId=${im(e)}${am(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=jf(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=jf(r);if(a===!1&&!o)throw Error(`此文件可通过文件操作菜单下载。`);if(o&&o!==`table`)return{path:r,name:i,content:``,etag:(await nm(um(e,r,t))).etag,dirty:!1,view:o};try{let n=await nm(lm(e,r,t));return{path:cm(r)?r:n.path,name:i,content:n.content,etag:n.meta.etag,dirty:!1,view:o}}catch(n){if(!(n instanceof $p)||![413,415].includes(n.status))throw n;return{path:r,name:i,content:``,etag:(await nm(um(e,r,t))).etag,dirty:!1,view:`download`}}}var vm=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function ym({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,F.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,F.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,F.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,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,F.jsx)(yf,{name:g?`down`:`right`})}),(0,F.jsx)(Fr,{category:g?`folder-open`:`folder`}),(0,F.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,F.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,F.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,F.jsx)(yf,{name:`more`})})]}),_,g&&(0,F.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,F.jsx)(`li`,{children:v}),h===void 0?(0,F.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,F.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:kr(h.error.message),children:Or(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,F.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,F.jsxs)(F.Fragment,{children:[h.truncated&&(0,F.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,F.jsx)(ym,{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,F.jsx)(bm,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function bm({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,F.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,F.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`file-name`,children:e.name}),(0,F.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=jf(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,F.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,F.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,F.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,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,F.jsx)(Fr,{path:e.path}),(0,F.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,F.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,F.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,F.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,F.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,F.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,F.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,F.jsx)(yf,{name:`more`})})]}),f]})}function xm({file:e,state:t,message:n,external:r,jumpToLine:i,onChange:a,onSave:o,onReload:s,onOverwrite:c,workspaceId:l,cwd:d=``,navigation:f,embedded:p=!1,onPosition:m,languageOverride:h}){let[g,_]=(0,u.useState)(!0),v=(0,u.useRef)(null),[y,b]=(0,u.useState)({}),[x,S]=(0,u.useState)(null),C=(0,u.useRef)(0),w=!!e.assetTicket,T=!w&&y[e.path]===!0&&!!l,E=l?d?`${l}:${d}`:l:``;(0,u.useEffect)(()=>{let t=++C.current;if(!T||!l){S(null);return}let n=new AbortController,i=bp(E,e.path,e.etag),a=r?void 0:Cp(i);if(a){S({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:E,note:a.supported?null:Dp(a.reason)});return}S({state:`loading`,response:null,path:e.path,workspaceId:E,note:null});let o=cm(e.path);return vp(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===C.current&&(r||wp(i,n),S({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:E,note:n.supported?null:Dp(n.reason)}))}).catch(n=>{if(t!==C.current||n instanceof gp)return;let r=Op(n);S({state:r.state,response:null,path:e.path,workspaceId:E,note:r.note})}),()=>{n.abort()}},[T,l,d,E,e.path,e.etag,r]);let D=x&&x.path===e.path&&x.workspaceId===E?x:null,O=T?D?.state??`loading`:`off`,k=O===`ready`&&Ip(e.content,D?.response??null,e.dirty||r),A=[];D?.note&&A.push(D.note),O===`ready`&&D?.response?.truncated&&A.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${D.response.totalLines} 行)`}),k&&A.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let j=O===`loading`?`⌛ Blame`:O===`ready`?`✓ Blame`:O===`off`?`Blame`:`! Blame`;(0,u.useEffect)(()=>{i&&_(!1)},[e.path,i]),(0,u.useEffect)(()=>{let e=v.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
|
|
287
|
+
`)),e.setAttribute(`aria-label`,t.join(` · `)),e.textContent=Mp(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=Bp,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=zp(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=zp(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:Hp(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 Hp(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 Np(e)){let e=document.createElement(`div`);e.className=`cm-blame-tooltip-row`,e.textContent=n,t.appendChild(e)}return t}function Up(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 Wp=`super-pi.diff-layout.v1`,Gp=`super-pi-diff-layout`;function Kp(){try{return localStorage.getItem(Wp)===`split`}catch{return!1}}function qp(e){let t=t=>{(t.key===Wp||t.key===null)&&e()};return window.addEventListener(Gp,e),window.addEventListener(`storage`,t),()=>{window.removeEventListener(Gp,e),window.removeEventListener(`storage`,t)}}var Jp;function Yp(){return Jp??Kp()}function Xp(){return[(0,u.useSyncExternalStore)(qp,Yp,()=>!1),e=>{Jp=e;try{localStorage.setItem(Wp,e?`split`:`inline`),Jp=void 0}catch{}window.dispatchEvent(new Event(Gp))}]}var Zp=4e3,Qp=(0,u.lazy)(()=>vn(()=>import(`./CodeMirrorEditor-D-UuYizz.js`).then(e=>({default:e.CodeMirrorEditor})),__vite__mapDeps([21,1]))),$p=class extends Error{status;body;constructor(e,t){super(t.error||`HTTP ${e}`),this.status=e,this.body=t,this.name=`ApiError`}},em=15e3,tm=e=>new $p(408,{error:`请求超时:${em/1e3} 秒内服务端没有响应`,code:`timeout`,details:{path:e}});async function nm(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),em);try{let r=t?.signal?AbortSignal.any([t.signal,n.signal]):n.signal,i=await Ne(e,{...t,signal:r}),a;try{a=await i.json()}catch{a=void 0}if(!i.ok)throw new $p(i.status,a??{error:`HTTP ${i.status}`});return a}catch(t){throw n.signal.aborted?tm(e):t}finally{clearTimeout(r)}}var rm=e=>e instanceof $p?e:new $p(0,{error:e instanceof Error?e.message:`读取失败`}),im=e=>encodeURIComponent(e),am=e=>e?`&cwd=${im(e)}`:``,om=(e,t,n)=>`/api/files?workspaceId=${im(e)}&path=${im(t)}${am(n)}`,sm=`//workspace/`,cm=e=>e.startsWith(sm)?e.slice(12):void 0,lm=(e,t,n)=>{let r=cm(t);return`/api/file?workspaceId=${im(e)}&path=${im(r??t)}${am(r?``:n)}`},um=(e,t,n)=>lm(e,t,n)+`&meta=1`,dm=(e,t,n)=>`/api/files?workspaceId=${im(e)}&q=${im(t)}${am(n)}`;async function fm(e,t,n){let r=t.current;if(!r)return t.current=nm(e+`&refresh=1`,{cache:`no-store`}),t.current;if(await r.catch(()=>{}),n())return nm(e,{cache:`no-store`})}function pm(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 mm(e){return{path:e,name:e.split(/[\\/]/).at(-1)||e,text:null,openLink:!0}}function hm(e){let t=pm(e);if(/^(?:\/|[a-z]:[\\/]|\\\\)/iu.test(t))return mm(t)}function gm(e){return pm(e).replaceAll(`\\`,`/`).replace(/^\.\//u,``)}async function _m(e,t,n){if(n.openLink){let r=await nm(`/api/files/open?workspaceId=${im(e)}${am(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=jf(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=jf(r);if(a===!1&&!o)throw Error(`此文件可通过文件操作菜单下载。`);if(o&&o!==`table`)return{path:r,name:i,content:``,etag:(await nm(um(e,r,t))).etag,dirty:!1,view:o};try{let n=await nm(lm(e,r,t));return{path:cm(r)?r:n.path,name:i,content:n.content,etag:n.meta.etag,dirty:!1,view:o}}catch(n){if(!(n instanceof $p)||![413,415].includes(n.status))throw n;return{path:r,name:i,content:``,etag:(await nm(um(e,r,t))).etag,dirty:!1,view:`download`}}}var vm=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`})};function ym({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,F.jsxs)(`li`,{className:`file-node`,"data-file-dir":t,"data-linked":p,"data-file-dir-changed":c.has(t)?`1`:`0`,children:[(0,F.jsxs)(`div`,{className:`file-explorer-row`,"data-file-drop-target":m.dropPath===t?`1`:void 0,hidden:!!_,style:{"--file-depth":f},children:[(0,F.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,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`,children:(0,F.jsx)(yf,{name:g?`down`:`right`})}),(0,F.jsx)(Fr,{category:g?`folder-open`:`folder`}),(0,F.jsx)(`span`,{className:`file-name`,children:n}),c.has(t)&&(0,F.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-dir-changed-badge":t,title:`里面有 agent 改过的文件`,children:`✎`})]}),(0,F.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,F.jsx)(yf,{name:`more`})})]}),_,g&&(0,F.jsxs)(`ul`,{className:`file-children`,children:[v&&(0,F.jsx)(`li`,{children:v}),h===void 0?(0,F.jsx)(`li`,{className:`file-row-loading`,"data-file-loading":t,children:`读取中…`}):`error`in h?(0,F.jsx)(`li`,{className:`file-row-error`,"data-file-error":t,title:kr(h.error.message),children:Or(h.error.message,`这个目录读取失败。`)}):h.entries.length===0?(0,F.jsx)(`li`,{className:`file-row-empty`,"data-file-empty":t,children:`空目录`}):(0,F.jsxs)(F.Fragment,{children:[h.truncated&&(0,F.jsx)(`li`,{className:`file-row-empty`,"data-file-truncated":t,children:`条目过多,只显示前一部分`}),h.entries.map(t=>t.kind===`directory`?(0,F.jsx)(ym,{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,F.jsx)(bm,{entry:t,depth:f+1,openPaths:s,changedPaths:l,onOpen:d,presentation:m},t.path))]})]})]})}function bm({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,F.jsx)(`li`,{className:`file-node file-explorer-row`,"data-file-entry":e.path,"data-file-outside":e.path,style:o,children:(0,F.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,disabled:!0,title:`${e.path} 的目标目录在当前工作区之外,或目标文件不可用`,tabIndex:-1,children:[(0,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`file-name`,children:e.name}),(0,F.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`})]})});let s=n.has(e.path),c=r.has(e.path),l=jf(e.path),u=!!(e.outside&&e.openLink||e.text||l),d=a.currentPath===e.path,f=a.inline(e.path,`entry`,t);return(0,F.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,F.jsxs)(`div`,{className:`file-explorer-row`,"data-file-current":d?`1`:void 0,hidden:!!f,style:o,children:[(0,F.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,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,F.jsx)(Fr,{path:e.path}),(0,F.jsx)(`span`,{className:`file-name`,children:e.name}),s&&(0,F.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`}),c&&(0,F.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed":e.path,title:`agent 改过这个文件`,children:`✎ 已改`}),e.document&&(0,F.jsx)(`span`,{className:`file-badge`,"data-file-document":`1`,"aria-label":`文档文件`,children:`文档`}),e.outside&&(0,F.jsx)(`span`,{className:`file-badge`,"data-file-outside-badge":`1`,children:`外部链接`}),!u&&!e.document&&(0,F.jsx)(`span`,{className:`file-badge`,"data-file-binary":`1`,"aria-label":`不支持的文件类型`,children:`不支持`})]}),!e.outside&&(0,F.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,F.jsx)(yf,{name:`more`})})]}),f]})}function xm({file:e,state:t,message:n,external:r,jumpToLine:i,onChange:a,onSave:o,onReload:s,onOverwrite:c,workspaceId:l,cwd:d=``,navigation:f,embedded:p=!1,onPosition:m,languageOverride:h}){let[g,_]=(0,u.useState)(!0),v=(0,u.useRef)(null),[y,b]=(0,u.useState)({}),[x,S]=(0,u.useState)(null),C=(0,u.useRef)(0),w=!!e.assetTicket,T=!w&&y[e.path]===!0&&!!l,E=l?d?`${l}:${d}`:l:``;(0,u.useEffect)(()=>{let t=++C.current;if(!T||!l){S(null);return}let n=new AbortController,i=bp(E,e.path,e.etag),a=r?void 0:Cp(i);if(a){S({state:a.supported?`ready`:`unsupported`,response:a,path:e.path,workspaceId:E,note:a.supported?null:Dp(a.reason)});return}S({state:`loading`,response:null,path:e.path,workspaceId:E,note:null});let o=cm(e.path);return vp(l,o??e.path,{signal:n.signal,cwd:o?``:d}).then(n=>{t===C.current&&(r||wp(i,n),S({state:n.supported?`ready`:`unsupported`,response:n,path:e.path,workspaceId:E,note:n.supported?null:Dp(n.reason)}))}).catch(n=>{if(t!==C.current||n instanceof gp)return;let r=Op(n);S({state:r.state,response:null,path:e.path,workspaceId:E,note:r.note})}),()=>{n.abort()}},[T,l,d,E,e.path,e.etag,r]);let D=x&&x.path===e.path&&x.workspaceId===E?x:null,O=T?D?.state??`loading`:`off`,k=O===`ready`&&Ip(e.content,D?.response??null,e.dirty||r),A=[];D?.note&&A.push(D.note),O===`ready`&&D?.response?.truncated&&A.push({code:`truncated`,text:`Blame 数据已截断,只显示了前面一部分(共 ${D.response.totalLines} 行)`}),k&&A.push({code:`stale`,text:`内容已改动,Blame 对应的是磁盘上的版本`});let j=O===`loading`?`⌛ Blame`:O===`ready`?`✓ Blame`:O===`off`?`Blame`:`! Blame`;(0,u.useEffect)(()=>{i&&_(!1)},[e.path,i]),(0,u.useEffect)(()=>{let e=v.current;if(!i||!e)return;let t=Math.min(i.line,e.value.split(`
|
|
288
288
|
`).length),n=e.value.split(`
|
|
289
289
|
`),r=n.slice(0,t-1).reduce((e,t)=>e+t.length+1,0),a=n[t-1].length;e.focus(),e.setSelectionRange(r+Math.min(a,(i.column??1)-1),r+a);let o=parseFloat(getComputedStyle(e).lineHeight);e.scrollTop=Math.max(0,(t-1)*o-e.clientHeight/2),e.scrollLeft=0;let s=e.previousElementSibling;s instanceof HTMLElement&&(s.scrollTop=e.scrollTop,s.scrollLeft=0)},[e.path,i,g]);let ee=/\.md$/i.test(e.path);return(0,F.jsxs)(`div`,{className:`file-editor`,"data-file-editor":e.path,"data-save-state":t,"data-file-readonly":w?`1`:void 0,children:[(0,F.jsxs)(`div`,{className:`file-editor-head`,children:[f??(!p&&(0,F.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path})),(0,F.jsxs)(`span`,{className:`file-editor-flags`,children:[ee&&(0,F.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:()=>_(e=>!e),children:g?`原文`:`预览`}),e.assetTicket&&l&&!p&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{children:`外部文件 · 只读`}),(0,F.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,onClick:s,children:`重新读取`}),(0,F.jsx)(`a`,{className:`file-preview-toggle`,href:Tf(`asset`,l,d,e.assetTicket,{download:`1`}),download:e.name,children:`下载`})]}),!w&&(0,F.jsx)(`button`,{type:`button`,className:`file-blame-toggle`,"data-file-blame-toggle":e.path,"data-file-blame-state":O,"aria-pressed":T,"aria-label":T?`关闭 Git Blame`:`显示 Git Blame`,onClick:()=>b(t=>({...t,[e.path]:t[e.path]!==!0})),children:j}),e.dirty&&(0,F.jsx)(`span`,{className:`file-dirty`,"data-file-dirty":`1`,children:`未保存`}),!w&&(0,F.jsxs)(`button`,{type:`button`,className:`file-save`,"data-file-save":e.path,onClick:o,title:`保存文件 (Ctrl+S)`,disabled:t===`saving`,children:[(0,F.jsx)(yf,{name:`save`}),t===`saving`?`保存中…`:`保存`]})]})]}),A.length>0&&(0,F.jsx)(`p`,{className:`file-blame-note`,"data-file-blame-reason":A.map(e=>e.code).join(` `),role:`status`,children:A.map(e=>e.text).join(`;`)}),r&&t!==`conflict`&&(0,F.jsxs)(`div`,{className:`file-conflict`,"data-file-external":e.path,role:`alert`,children:[(0,F.jsx)(`p`,{children:`这个文件在磁盘上已经被改过了,你的修改还没有覆盖它。`}),(0,F.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,F.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,F.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),t===`conflict`&&(0,F.jsxs)(`div`,{className:`file-conflict`,"data-file-conflict":e.path,role:`alert`,children:[(0,F.jsx)(`p`,{children:`保存被拒绝:这个文件在磁盘上已经被改过了,覆盖会丢掉对方的改动。`}),(0,F.jsxs)(`div`,{className:`file-conflict-actions`,children:[(0,F.jsx)(`button`,{type:`button`,"data-file-reload":e.path,onClick:s,children:`丢掉我的修改,读磁盘版本`}),(0,F.jsx)(`button`,{type:`button`,"data-file-overwrite":e.path,onClick:c,children:`仍然覆盖磁盘`})]})]}),n&&t!==`conflict`&&!r&&(0,F.jsx)(`p`,{className:`file-editor-message file-message-${t}`,"data-file-message":t,role:`status`,children:n}),ee&&g?(0,F.jsx)(`div`,{className:`file-markdown-preview`,"data-file-preview":`markdown`,children:(0,F.jsx)(ef,{source:e.content})}):(0,F.jsx)(Uf,{fallback:(t,n)=>(0,F.jsxs)(`div`,{className:`file-editor-fallback`,"data-file-editor-fallback":`1`,children:[(0,F.jsxs)(`div`,{className:`file-editor-fallback-bar`,children:[(0,F.jsxs)(`span`,{children:[`⚠️ 高级编辑器加载异常(`,t.message||`未知错误`,`),已自动降级为安全模式`]}),(0,F.jsx)(`button`,{type:`button`,onClick:n,children:`重新加载`})]}),(0,F.jsx)(`textarea`,{className:`file-textarea`,readOnly:w,value:e.content,onChange:e=>a(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),o())}})]}),children:(0,F.jsx)(u.Suspense,{fallback:(0,F.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,F.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`})}),children:(0,F.jsx)(Qp,{path:e.path,languageOverride:h,value:e.content,onChange:a,jumpToLine:i,onSave:o,readOnly:w,workspaceId:l,onPosition:m,blame:T&&D&&!k?{state:D.state,response:D.response,path:D.path,workspaceId:l??``}:void 0})})})]})}function Sm({line:e}){if(e.kind===`fold`)return(0,F.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,F.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,F.jsx)(`span`,{className:`file-diff-mark`,"aria-hidden":`true`,children:t}),(0,F.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.oldLine??``}),(0,F.jsx)(`span`,{className:`file-diff-number`,"aria-hidden":`true`,children:e.newLine??``}),(0,F.jsx)(`span`,{className:`file-diff-text`,children:e.text}),e.noNewline&&(0,F.jsx)(`span`,{className:`file-diff-no-newline`,title:`这个版本的末尾没有换行`,children:`(末尾无换行)`})]})}function Cm(e){let t=[];for(let n=0;n<e.length;){let r=e[n];if(r.kind===`same`||r.kind===`fold`){t.push({before:r,after:r}),n++;continue}let i=[],a=[];for(;n<e.length&&[`removed`,`added`].includes(e[n].kind);){let t=e[n++];(t.kind===`removed`?i:a).push(t)}for(let e=0;e<Math.max(i.length,a.length);e++)t.push({before:i[e],after:a[e]})}return t}function wm({diff:e,loading:t,error:n,bufferContent:r,mode:i,onMode:a}){let[o,s]=(0,u.useState)(),[c,l]=Xp(),d=JSON.stringify([e?.path,i]),f=o===d,{scrollBox:p,capture:m}=Up(f,`.file-diff-added, .file-diff-removed`);if(t)return(0,F.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`loading`,children:(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-diff-loading":`1`,children:`正在读取差异…`})});if(n)return(0,F.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`error`,children:(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-diff-error":`1`,title:kr(n),children:Or(n,`这个文件的差异读取失败。`)})});if(!e)return(0,F.jsx)(`div`,{className:`file-diff`,"data-file-diff-state":`empty`,children:(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-diff-empty":`1`,children:`没有选中的差异。`})});let h=typeof r==`string`,g=i===`buffer`&&h,_=g?e.after:e.before,v=g?r:e.after,y=g?`我未保存的修改`:e.label,b=g?`buffer`:e.baseline,x=h&&e.baseline!==`none`?(0,F.jsxs)(`span`,{className:`file-diff-switch`,"data-file-diff-switch":`1`,children:[(0,F.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${g?``:` file-diff-switch-active`}`,"data-file-diff-base":`server`,"aria-pressed":!g,onClick:()=>a(`server`),children:`agent 的改动`}),(0,F.jsx)(`button`,{type:`button`,className:`file-diff-switch-btn${g?` file-diff-switch-active`:``}`,"data-file-diff-base":`buffer`,"aria-pressed":g,onClick:()=>a(`buffer`),children:`我的修改`})]}):null;if(b===`none`)return(0,F.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`none`,"data-file-diff-baseline":b,children:[(0,F.jsxs)(`div`,{className:`file-editor-head`,children:[(0,F.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,F.jsx)(`span`,{className:`file-editor-flags`,children:x})]}),(0,F.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-nobaseline":`1`,children:y})]});let S=ip(_,v),C=ap(S),w=f?S.lines:C.lines,T=c?Cm(w):[];return(0,F.jsxs)(`div`,{className:`file-diff`,"data-file-diff-state":`ready`,"data-file-diff-baseline":b,"data-file-diff-added":S.added,"data-file-diff-removed":S.removed,"data-file-diff-layout":c?`split`:`inline`,children:[(0,F.jsxs)(`div`,{className:`file-editor-head`,children:[(0,F.jsx)(`span`,{className:`file-editor-path`,title:e.path,children:e.path}),(0,F.jsxs)(`span`,{className:`file-editor-flags`,children:[x,(0,F.jsx)(`span`,{className:`file-diff-baseline`,"data-file-diff-label":`1`,children:y}),(0,F.jsxs)(`span`,{className:`file-diff-count`,"data-file-diff-count":`1`,children:[`+`,S.added,` / -`,S.removed]}),(0,F.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,"data-file-diff-layout-button":!0,onClick:()=>l(!c),title:c?`切换为全局内联视图`:`切换为全局分栏视图`,children:c?`内联`:`分栏`}),!S.identical&&C.folded>0&&(0,F.jsx)(`button`,{type:`button`,className:`file-preview-toggle`,"data-file-diff-context":!0,"aria-pressed":f,onClick:()=>{m(),s(f?void 0:d)},children:f?`折叠未改动行`:`显示全文`})]})]}),e.beforeUnknown&&!g&&(0,F.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-before-unknown":`1`,role:`status`,children:`读不到改动前的版本(文件太大或无法读取),这里只显示现在的内容。`}),e.before===null&&!e.beforeUnknown&&!g&&(0,F.jsx)(`p`,{className:`file-diff-warning`,"data-file-diff-is-new":`1`,role:`status`,children:`这个文件是新建的,下面是它的全部内容。`}),S.identical?(0,F.jsx)(`p`,{className:`file-diff-nobaseline`,"data-file-diff-identical":`1`,children:`两个版本没有区别。`}):(0,F.jsx)(`div`,{ref:p,className:`file-diff-body`,"data-file-diff-body":`1`,"data-file-diff-context-mode":f?`full`:`compact`,children:c?(0,F.jsx)(`div`,{className:`file-diff-split-grid`,children:[`before`,`after`].map(e=>(0,F.jsx)(`div`,{"data-diff-side":e,"aria-label":e===`before`?`修改前`:`修改后`,children:T.map((t,n)=>t[e]?(0,F.jsx)(Sm,{line:t[e]},n):(0,F.jsx)(`div`,{className:`file-diff-line`,"aria-hidden":`true`,children:`\xA0`},n))},e))}):w.map((e,t)=>(0,F.jsx)(Sm,{line:e},t))})]})}function Tm({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,F.jsxs)(`div`,{className:`rail-empty file-problem`,"data-file-root-error":`1`,"data-file-error-kind":r,role:`alert`,children:[r===`missing`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`工作区路径不存在,无法读取文件。`}),(0,F.jsx)(`p`,{className:`file-problem-hint`,children:`请确认这个路径是写错了,还是目录被移动或删除了:`}),(0,F.jsx)(`code`,{className:`file-problem-path`,"data-file-error-path":`1`,children:n||Or(e.message,`路径未知`)})]}),r===`timeout`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取超时,服务端没有回应。`}),(0,F.jsxs)(`p`,{className:`file-problem-hint`,children:[`已经等了 `,em/1e3,` 秒。如果这个工作区在网络盘上,请检查它是否已连接,然后点上面的 ↻ 重试。`]})]}),r===`failed`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`file-problem-title`,"data-file-error-title":`1`,children:`读取失败。`}),(0,F.jsx)(`p`,{className:`file-problem-hint`,title:kr(e.message),children:Or(e.message,`读取失败,请稍后重试。`)})]})]})}function Em(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,ee]=(0,u.useState)(0),[M,te]=(0,u.useState)(``),[N,ne]=(0,u.useState)(null),[re,ie]=(0,u.useState)(null),[ae,oe]=(0,u.useState)(!1),[se,ce]=(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),ne(null),ie(null),te(``),oe(!1),!e)return;let t=!0;return nm(om(e,``,a)).then(e=>{t&&C({"":e})}).catch(e=>{t&&C({"":{error:rm(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),mp(`super-pi.file-drafts.v1.`+o,e),Am(o)}}},[e,a,o]);let[le,ue]=(0,u.useState)(),[de,fe]=(0,u.useState)(void 0);(0,u.useEffect)(()=>{if(!e||!o)return;let t=!0;fe(void 0),ue(void 0);let r=Om()[o]??{expanded:[],open:[]},i=e=>({path:e,name:e.split(/[\\/]/).at(-1)||e,text:!0,openLink:r.explicit?.includes(e)?!0:void 0}),a=pp(`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`&&ne(r.listHeight);let u=new Set([...r.open,...c.keys()]);if(!u.size){ue(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 we(i(r),{activate:!1,isCurrent:()=>t});if(!t||s.current!==o)return;r===d&&(e=u)}if(n&&p()&&(e=await we(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),fe(t)}})().finally(()=>{t&&s.current===o&&ue(o)}),()=>{t=!1}},[e,a,o,n]),(0,u.useEffect)(()=>{if(!e||!o)return;let t=setTimeout(()=>{let e=Om();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}:{},...N===null?{}:{listHeight:N}},km(e)},400);return()=>{clearTimeout(t)}},[e,o,c,w,m,N,r]),(0,u.useEffect)(()=>{if(!o||le!==o)return;let e=()=>{if(s.current!==o)return;let e=p.current.filter(e=>e.dirty);return mp(`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,le,c]);let pe=(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 nm(om(e,t,a)+(n?`&revalidate=1`:``)).then(e=>{c()&&C(n=>({...n,[t]:e}))}).catch(e=>{c()&&C(n=>({...n,[t]:{error:rm(e)}}))}).finally(()=>{c()&&i.delete(t)})},[e,a,o]),me=(0,u.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),he=(0,u.useCallback)(t=>{if(!e)return;let n=new Set([``,...O.current]),r=t&&new Set(t.map(Mf)),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=>pe(e,!t&&!e))).then(()=>{s.current===o&&ee(e=>e+1)})},[e,o,pe]),ge=(0,u.useCallback)(()=>he(),[he]),P=(0,u.useRef)(void 0),_e=(0,u.useRef)(new Set);(0,u.useEffect)(()=>()=>{clearTimeout(P.current),P.current=void 0,_e.current=new Set},[o]);let ve=(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;_e.current=null}else if(!i)_e.current=null;else for(let e of i)_e.current?.add(e);P.current||=setTimeout(()=>{P.current=void 0;let e=_e.current;_e.current=new Set,he(e?[...e]:void 0)},100)},[e,a,he]),ye=(0,u.useCallback)(e=>{let t=new Set;for(let n=Mf(e);n;n=Mf(n))t.add(n);te(``),T(e=>new Set([...e,...t]))},[]),be=(0,u.useCallback)((e,t)=>{ye(t&&e?`${e}/`:e),D({path:e,directory:t})},[ye]),xe=(0,u.useCallback)(()=>T(new Set),[]),Se=(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=jf(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)))),ye(t)},[ye]),Ce=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{Ce.current=void 0},[e,a]),(0,u.useEffect)(()=>{let t=gm(M);if(!e||!t||hm(M)){Ce.current=void 0,ie(null),oe(!1);return}let n=!0,r,i=async()=>{try{let o=await fm(dm(e,t,a),Ce,()=>n);if(!n||!o)return;ie(o),oe(!1),o.indexed||(r=setTimeout(()=>void i(),400))}catch(e){if(!n)return;ie(null),oe(!1),_(Or(e,`文件查找没有完成`))}};return oe(!0),r=setTimeout(()=>void i(),80),()=>{n=!1,clearTimeout(r)}},[M,e,a,j]);let we=(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 _m(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]),Te=(0,u.useCallback)(e=>{o&&p.current.some(t=>t.path===e&&t.preview&&!t.dirty)&&Am(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]),Ee=(0,u.useCallback)(e=>{l(t=>t.map(t=>t.path===e&&t.preview?{...t,preview:!1}:t))},[]),De=(0,u.useCallback)(e=>{l(t=>t.filter(t=>t.path!==e||!t.preview||t.dirty)),h(t=>t===e?void 0:t),o&&Am(o,e)},[o]),Oe=(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||nm(um(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&&rm(e).status===404&&x(e=>({...e,[n]:!0}))})},Zp);return()=>{t=!1,clearInterval(n)}},[e,a,c.length]);let ke=(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 nm(um(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 nm(lm(e,t,a),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:cm(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?`已保存,但你又改了;最新修改仍未保存`:`已保存 ${vm(n.meta.modifiedAt)}`}}))}catch(e){if(s.current!==o)return;let n=e instanceof $p&&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]),Ae=(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 _m(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 nm(lm(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]),je=c.find(e=>e.path===m),Me=(0,u.useMemo)(()=>c.map(e=>({id:e.path,label:e.name,title:cm(e.path)??e.path,closable:!0,badge:e.dirty?(0,F.jsx)(`span`,{className:`file-tab-badge`,"data-file-tab-dirty":e.path,"aria-label":`未保存`,children:`●`}):void 0})),[c]),Ne=(0,u.useMemo)(()=>new Set(c.map(e=>e.path)),[c]),Pe=(0,u.useCallback)((e,t,n)=>{ce(r=>({...r,[e]:{changes:t,dropped:n}}))},[]),Fe=e?se[e]:void 0,Ie=(0,u.useMemo)(()=>{let e=Fe?.changes??[];if(!a)return e;let t=`${a}/`;return e.flatMap(e=>e.path.startsWith(t)?[{...e,path:e.path.slice(t.length)}]:[])},[Fe,a]),Le=Fe?.dropped??0,Re=(0,u.useMemo)(()=>new Set(Ie.map(e=>e.path)),[Ie]),ze=(0,u.useMemo)(()=>{let e=new Set;for(let t of Ie){let n=t.path.split(`/`);for(let t=1;t<n.length;t++)e.add(n.slice(0,t).join(`/`))}return e},[Ie]);return{ownerWorkspaceId:d,open:c,activePath:m,visiblePath:r?m:i,location:E,active:je,tabItems:Me,openPaths:Ne,notice:g,setNotice:_,saves:v,external:b,restoringWorkbench:!!(o&&le!==o),openFile:we,setActivePath:h,closeFile:Te,pinFile:Ee,discardPreview:De,updateBuffer:Oe,save:ke,reload:Ae,listings:S,expanded:w,toggleDirectory:me,loadDirectory:pe,refreshTree:ge,invalidateTree:ve,revealPath:ye,locatePath:be,collapseDirectories:xe,movePath:Se,listHeight:N,setListHeight:ne,query:M,setQuery:te,hits:re,searching:ae,changed:Ie,changedPaths:Re,changedDirs:ze,changedDropped:Le,setChangedFor:Pe,restoredActive:de}}var Dm=`super-pi.file-workbench.v1`;function Om(){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 km(e){try{typeof window<`u`&&window.localStorage.setItem(Dm,JSON.stringify(e))}catch{}}function Am(e,t){let n=Om(),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},km(n))}function jm({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,F.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 Mm=()=>null,Nm=`application/x-super-pi-workspace-file`;function Pm({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||`工作目录`,ee=zf({workspaceId:e,cwd:n,scopeName:j,files:r,onOpen:A,onReference:o,onMoved:s,onSearchFolder:c}),[M,te]=(0,u.useState)(),N=(0,u.useRef)(void 0),[ne,re]=(0,u.useState)(!1),ie=ee.editing?ee.inline:Mm,ae=(0,u.useMemo)(()=>({currentPath:r.visiblePath,dropPath:M,inline:ie}),[r.visiblePath,M,ie]);(0,u.useEffect)(()=>{y();function e(){y()}return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[y]),(0,u.useEffect)(()=>{te(void 0),N.current=void 0,re(!1)},[e,n]);let oe=h[``],se=S.trim(),ce=e?hm(S):void 0,le=(0,u.useRef)(null),ue=(0,u.useRef)(null),de=(0,u.useRef)(void 0);function fe(e){let t=ue.current;t&&(de.current&&de.current!==e&&(de.current.tabIndex=-1),de.current=e,t.tabIndex=e?-1:0,e&&(e.tabIndex=0))}let pe=(0,u.useRef)(void 0);(0,u.useEffect)(()=>{let{location:e}=r;if(!e||pe.current===e)return;let t=le.current?.querySelector(e.path?`[${e.directory?`data-file-dir-toggle`:`data-file-open`}="${CSS.escape(e.path)}"]`:`[data-explorer-root]`);t&&(pe.current=e,t.focus({preventScroll:!0}),t.scrollIntoView({block:`nearest`}))},[r.location,h,g,S]),(0,u.useEffect)(()=>{if(!M||g.has(M))return;let e=window.setTimeout(()=>_(M),650);return()=>window.clearTimeout(e)},[M,g,_]);let me=(0,u.useCallback)(e=>{let t=le.current;if(!t)return;let n=e.target?.closest(`.file-row`);if(!n)return;let r=Ff(n);if(r&&!ee.busy){if(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`){e.preventDefault(),ee.openMenu(r,bf(n));return}if(!r.linked&&e.key===`F2`){e.preventDefault(),ee.showAction(`move`,r,!1,n);return}if(!r.linked&&e.key===`Delete`){e.preventDefault(),ee.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()}}},[_,ee]),[he,ge]=(0,u.useState)(200);(0,u.useEffect)(()=>{ge(200)},[se,e]);let P=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(se===``)return;let e=P.current;if(!e||typeof IntersectionObserver>`u`)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&ge(e=>e>=(w?.hits.length??0)?e:e+200)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[se,w]);let _e=(0,u.useMemo)(()=>{if(ce)return(0,F.jsxs)(`button`,{type:`button`,className:`file-row file-row-file`,"data-file-exact-path":ce.path,title:ce.path,onClick:()=>A(ce),children:[(0,F.jsx)(Fr,{path:ce.path}),(0,F.jsxs)(`span`,{className:`file-name`,children:[`打开 `,ce.name]})]});if(se){if(T)return(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-searching":`1`,children:`搜索中…`});if(!w)return null;if(w.hits.length===0)return(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-search-empty":`1`,children:w.indexed?`没有匹配「${se}」的文件。`:`正在建立索引…`});let e=w.hits.slice(0,he),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,F.jsxs)(F.Fragment,{children:[t.map(e=>(0,F.jsxs)(`section`,{className:`file-group`,"data-file-search-group":e.directory,children:[(0,F.jsxs)(`h3`,{className:`file-group-head`,"data-file-search-group-head":e.directory,children:[(0,F.jsx)(`span`,{className:`file-group-name`,children:e.directory||`/`}),(0,F.jsx)(`span`,{className:`file-group-count`,children:e.hits.length})]}),(0,F.jsx)(`ul`,{className:`file-list`,children:e.hits.map(e=>(0,F.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,F.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,F.jsx)(`span`,{className:`file-caret`,"aria-hidden":`true`}),(0,F.jsx)(Fr,{path:e.path}),(0,F.jsx)(`span`,{className:`file-name`,children:e.name}),d.has(e.path)&&(0,F.jsx)(`span`,{className:`file-open-mark`,"data-file-open-mark":e.path,title:`已经打开`,"aria-label":`已经打开`,children:`●`})]}),!e.openLink&&(0,F.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,F.jsx)(yf,{name:`more`})})]},e.path))})]},e.directory||`/`)),e.length<w.hits.length&&(0,F.jsx)(`div`,{ref:P,className:`file-sentinel`,"data-file-search-more":`1`,children:`正在载入更多…`})]})}return e?oe===void 0?(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-root-loading":`1`,children:`读取工作区…`}):`error`in oe?(0,F.jsx)(Tm,{error:oe.error}):(0,F.jsxs)(F.Fragment,{children:[oe.truncated&&(0,F.jsx)(`p`,{className:`file-search-note`,"data-file-truncated-root":`1`,children:`条目过多,只显示前一部分。`}),oe.entries.length===0?(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-root-empty":`1`,children:`这个工作区是空的,没有文件也没有子目录。`}):(0,F.jsx)(`ul`,{className:`file-list`,children:oe.entries.map(t=>t.kind===`directory`?(0,F.jsx)(ym,{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:ae},t.path):(0,F.jsx)(bm,{entry:t,depth:0,openPaths:d,changedPaths:D,onOpen:A,presentation:ae},t.path))})]}):(0,F.jsx)(`p`,{className:`rail-empty`,"data-file-no-workspace":`1`,children:`先在左侧选一个工作区,这里会显示它的文件。`})},[ce,se,T,w,he,e,oe,h,g,_,v,A,d,O,D,ae,r.visiblePath]),ve=e=>{let t=Ff(e);if(!t?.linked)return t?t.directory?t.path:Mf(t.path):``},ye=(e,t)=>e!==Mf(t.path)&&!(t.directory&&Nf(e,t.path));return(0,u.useLayoutEffect)(()=>{let e=ue.current;if(!e)return;let t=[...e.querySelectorAll(`.file-row:not(:disabled)`)].filter(e=>e.offsetParent!==null),n=de.current;fe(n&&t.includes(n)?n:t.find(e=>e.hasAttribute(`aria-current`))??t[0])},[_e,ee.editing]),(0,F.jsxs)(`div`,{className:`files-panel`,"data-files-panel":`1`,"data-files-open-count":l.length,"data-files-changed-count":E.length,ref:le,onKeyDown:me,onClick:e=>{let t=e.target instanceof Element?e.target.closest(`[data-explorer-action]`):void 0,n=Ff(t??null);t&&n&&!ee.busy&&ee.openMenu(n,bf(t))},onContextMenu:e=>{let t=Ff(e.target),n=e.target instanceof Element?e.target.closest(`.file-row, [data-explorer-action]`):void 0;t&&n&&!ee.busy&&(e.preventDefault(),ee.openMenu(t,{x:e.clientX,y:e.clientY,origin:n}))},onDragStart:e=>{let t=Ff(e.target instanceof Element?e.target.closest(`.file-row[draggable=true]`):null);!t||t.linked||ee.busy||se||(N.current=t,e.dataTransfer.setData(Nm,t.path),e.dataTransfer.effectAllowed=`move`)},onDragEnd:()=>{N.current=void 0,te(void 0)},onDragLeave:e=>{(!(e.relatedTarget instanceof Node)||!e.currentTarget.contains(e.relatedTarget))&&te(void 0)},onDragOver:t=>{let n=t.dataTransfer.types.includes(`Files`),r=N.current&&t.dataTransfer.types.includes(Nm)?N.current:void 0;if(!e||ee.busy||!n&&!r)return;t.preventDefault();let i=ve(t.target),a=i!==void 0&&(!r||ye(i,r));t.dataTransfer.dropEffect=a?r?`move`:`copy`:`none`,te(a?i:void 0)},onDrop:t=>{te(void 0);let n=t.dataTransfer.types.includes(Nm)?N.current:void 0;if(N.current=void 0,!e||ee.busy||!n&&!t.dataTransfer.types.includes(`Files`))return;t.preventDefault();let r=ve(t.target);if(r===void 0){p(`请选择工作区里的普通文件夹。`);return}if(n){ye(r,n)&&ee.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?ee.upload(r,i):t.dataTransfer.files.length&&!t.dataTransfer.items.length?ee.upload(r,Array.from(t.dataTransfer.files)):p(`请选择要上传的文件。`)},children:[(0,F.jsxs)(`header`,{className:`file-explorer-header`,"data-file-drop-target":M===``?`1`:void 0,children:[(0,F.jsxs)(`div`,{className:`file-explorer-scope`,"data-explorer-root":`1`,tabIndex:-1,title:n?`${t??`工作区`}/${n}`:j,children:[(0,F.jsx)(Fr,{category:`folder-open`}),(0,F.jsx)(`span`,{children:j})]}),ee.toolbar]}),(0,F.jsxs)(`div`,{className:`files-search`,children:[(0,F.jsx)(`span`,{className:`files-search-icon`,"aria-hidden":`true`,children:(0,F.jsx)(yf,{name:`search`})}),(0,F.jsx)(`input`,{type:`search`,className:`files-search-input`,"data-file-search-input":`1`,value:S,placeholder:`筛选文件或输入绝对路径`,"aria-label":`按文件名搜索`,onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),C(``)):e.key===`Enter`&&ce&&(e.preventDefault(),A(ce))},onChange:e=>C(e.target.value)}),(0,F.jsx)(`button`,{type:`button`,className:`explorer-icon-button`,disabled:!r.activePath||!!cm(r.activePath)||!!(r.active?.assetTicket&&hm(r.activePath)),onClick:()=>{r.activePath&&r.locatePath(r.activePath,!1)},title:`定位打开的文件`,"aria-label":`在文件树中定位当前文件`,children:(0,F.jsx)(yf,{name:`locate`})})]}),ee.controls,!ce&&se&&w&&!T&&(0,F.jsxs)(`p`,{className:`files-count`,"data-file-search-count":`1`,role:`status`,children:[(0,F.jsx)(`b`,{children:w.total.toLocaleString(`zh-CN`)}),` 个结果`,w.indexed===!1&&(0,F.jsx)(`span`,{className:`files-count-note`,"data-file-search-indexing":`1`,children:`正在建立索引…`}),w.indexed&&w.incomplete&&(0,F.jsx)(`span`,{className:`files-count-note`,children:`索引不完整`})]}),f&&(0,F.jsx)(`p`,{className:`rail-empty file-explorer-notice`,"data-file-notice":`1`,role:`status`,children:f}),ee.busy&&(0,F.jsx)(`p`,{className:`file-explorer-notice`,role:`status`,children:`正在处理文件…`}),(0,F.jsx)(`div`,{className:`files-tree`,ref:ue,"data-file-tree":se?`search`:`browse`,tabIndex:0,"aria-label":`文件树`,onFocus:e=>{e.target instanceof HTMLElement&&e.target.matches(`.file-row:not(:disabled)`)&&fe(e.target)},style:b===null?void 0:{height:`${b}px`,flex:`0 0 auto`},children:(0,F.jsxs)(`div`,{className:`files-tree-body`,children:[ee.inline(``,`child`,0),_e]})}),(0,F.jsx)(jm,{height:b,onHeight:x,panelRef:le}),(0,F.jsxs)(`div`,{className:`files-changed`,"data-file-changed-list":`1`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`files-changed-head`,"data-file-changed-head":`1`,"aria-expanded":ne,onClick:()=>re(e=>!e),children:[(0,F.jsx)(yf,{name:ne?`down`:`right`}),(0,F.jsx)(yf,{name:`changes`}),(0,F.jsx)(`span`,{children:`改动`}),(0,F.jsx)(`span`,{className:`files-change-count`,children:E.length})]}),ne&&(0,F.jsxs)(`div`,{className:`files-change-list`,children:[k>0&&(0,F.jsxs)(`p`,{className:`file-search-note`,"data-file-changed-dropped":`1`,children:[`还有 `,k,` 个改动没有记录(超过保留上限)。`]}),!E.length&&(0,F.jsx)(`p`,{className:`file-row-empty`,children:`没有 agent 改动。`}),(0,F.jsx)(`ul`,{className:`file-list`,children:E.map(e=>(0,F.jsx)(`li`,{children:(0,F.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,F.jsx)(Fr,{path:e.path}),(0,F.jsx)(`span`,{className:`file-name`,children:e.path.split(`/`).pop()}),(0,F.jsx)(`span`,{className:`file-badge-path`,children:e.path.split(`/`).slice(0,-1).join(`/`)||`/`}),(0,F.jsx)(`span`,{className:`file-badge file-badge-changed`,"data-file-changed-kind":e.path,children:e.baseline===null&&!e.baselineUnknown?`新建`:`已改`})]})},e.path))})]})]})]})}function Fm(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(Or(e,`文件无法打开`))}finally{r(!1)}}},openError:i,opening:n,setOpenError:a}}var Im=200;async function Lm(e,t,n){let r=await Ne(e,{signal:t,cache:`no-store`});if(!r.ok)throw new $p(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 Rm(e,t){return{path:t?e.startsWith(t+`/`)?e.slice(t.length+1):sm+e:e,name:e.split(`/`).at(-1)??e,text:!0}}function zm(e,t,n){return{...Rm(t?t+`/`+e.path:e.path,n),name:e.name}}function Bm({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,ee]=(0,u.useState)(0),{choose:M,openError:te,opening:N,setOpenError:ne}=Fm(i,a),re=!!hm(c),ie=(0,u.useRef)(null),ae=(0,u.useRef)(null),oe=(0,u.useRef)(void 0),se=(0,u.useId)();(0,u.useEffect)(()=>{ie.current?.focus()},[]),(0,u.useEffect)(()=>{ae.current?.scrollIntoView({block:`nearest`})},[j]),(0,u.useEffect)(()=>{let t=c.trim(),n=new AbortController;if(oe.current=n,b([]),S(void 0),E(``),A(!1),w(Im),ee(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||Lm(`/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(Or(e,`搜索没有完成`))}).finally(()=>{n.signal.aborted||O(!1)})},220);return()=>{n.abort(),clearTimeout(i)}},[c,e,d,p,h,_]);let ce=(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]),le=e=>{e&&M(zm(e,d,t),e.line,e.column)},ue=x?.complete===!1,de={time:`搜索超时`,results:`达到全局结果上限`,line:`部分行太长`,encoding:`部分文件的编码无法读取`,unreadable:`部分文件无法读取`};return(0,F.jsxs)(Vf,{mode:`content`,query:c,onMode:o,onClose:a,presentation:s,children:[(0,F.jsx)(`input`,{ref:ie,className:`quick-open-input`,"data-content-search-input":`1`,value:c,readOnly:N,placeholder:`内容搜索(区分大小写,按字面匹配)`,role:`combobox`,"aria-label":`内容搜索`,"aria-autocomplete":`list`,"aria-controls":se,"aria-expanded":y.length>0,"aria-activedescendant":y[j]?`${se}-${j}`:void 0,onChange:e=>{l(e.target.value),ne(``)},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),ee(e=>Math.min(e+1,Math.max(0,Math.min(C,y.length)-1)))):e.key===`ArrowUp`?(e.preventDefault(),ee(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),le(y[j])))}}),(0,F.jsxs)(`div`,{className:`content-search-controls`,children:[(0,F.jsxs)(`label`,{children:[`范围 `,(0,F.jsxs)(`select`,{value:d,"aria-label":`搜索范围`,onChange:e=>f(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:`整个工作区`}),t&&(0,F.jsxs)(`option`,{value:t,children:[`当前目录 · `,t]}),n&&n!==t&&(0,F.jsxs)(`option`,{value:n,children:[`文件夹 · `,n]})]})]}),D&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{oe.current?.abort(),ie.current?.focus(),O(!1),A(!0)},children:`取消搜索`})]}),(0,F.jsxs)(`details`,{className:`content-search-filters`,children:[(0,F.jsx)(`summary`,{children:`文件筛选`}),(0,F.jsxs)(`label`,{children:[`包含 `,(0,F.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`例如 **/*.cpp`})]}),(0,F.jsxs)(`label`,{children:[`排除 `,(0,F.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`例如 **/generated/**`})]}),(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),` 遵循忽略文件和默认排除`]})]}),(0,F.jsxs)(`p`,{className:`quick-open-status`,role:`status`,"data-content-search-status":T?`error`:D?`searching`:k?`cancelled`:ue?`partial`:`complete`,children:[T?`搜索失败:`+T:D?`搜索中…`:k?`已取消`:e?ue?`结果不完整`:x?`搜索完成`:`输入要搜索的内容`:`请先选择工作区`,(y.length>0||x)&&` · ${y.length} 条命中`]}),re&&(0,F.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>o(`path`,c),children:`按文件路径打开`}),ue&&(0,F.jsx)(`p`,{className:`quick-open-status`,"data-content-search-partial":`1`,children:x.reasons.map(e=>de[e]??e).join(`;`)}),x?.complete&&!y.length&&(0,F.jsx)(`p`,{className:`quick-open-status`,"data-content-search-empty":`1`,children:`没有匹配的行`}),te&&(0,F.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:te}),(0,F.jsx)(`ul`,{id:se,className:`quick-open-results content-search-results`,role:`listbox`,"aria-label":`正文搜索结果`,children:ce.map(([e,t])=>(0,F.jsxs)(`li`,{className:`content-search-group`,role:`presentation`,children:[(0,F.jsx)(`div`,{className:`content-search-file`,title:e,children:e}),t.map(({hit:e,row:t})=>(0,F.jsxs)(`button`,{id:`${se}-${t}`,ref:t===j?ae: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:()=>ee(t),onClick:()=>le(e),children:[(0,F.jsxs)(`span`,{title:`${e.path}:${e.line}:${e.column}`,className:`content-search-result-position`,children:[e.line,`:`,e.column]}),(0,F.jsx)(`small`,{title:e.text,children:e.text})]},e.line))]},e))}),y.length>C&&(0,F.jsxs)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-content-search-more":`1`,onClick:()=>{C+Im>=y.length&&ie.current?.focus(),w(e=>e+Im)},children:[`显示更多结果(已显示 `,C,` / `,y.length,`)`]})]})}function Vm({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}=Fm(i,a),C=(0,u.useRef)(null),w=(0,u.useRef)(null),T=gm(c),E=e?hm(c):void 0,D=!!E;(0,u.useEffect)(()=>{if(!n||!e)return;let r=new AbortController,i=dm(e,``,t)+`&quick=1&refresh=1`;return _.current=nm(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=dm(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 nm(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:Or(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(mm(T)):t.unshift(mm(T))),t},[E,T,k,p,e]),j=e=>{v.current=void 0,m(e),g(void 0),f(0),S(``),C.current?.focus()},ee=!D&&!(!e||O?.error||k?.indexed);return(0,u.useEffect)(()=>{let e=v.current;e===void 0||ee||(v.current=void 0,y(A[Math.min(e,A.length-1)]))},[ee,A,y]),(0,u.useEffect)(()=>{C.current?.focus()},[]),(0,u.useEffect)(()=>{w.current?.scrollIntoView({block:`nearest`})},[d]),(0,F.jsxs)(Vf,{mode:`path`,query:c,onMode:o,onClose:a,presentation:s,children:[(0,F.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,(gm(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()));ee&&!n?v.current=d:y(t)}}}}),(0,F.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||(ee?`正在检查文件索引…`:T?k?.incomplete?`索引不完整 · ${k.total} 条命中`:k?.total?`${k.total} 条命中${p?` · 第 ${p+1} 页`:``}`:A.length?`近似路径`:`没有匹配的文件名或路径`:`输入文件名或路径以查找当前目录中的文件`):`等待连接…`:`请先选择工作区`,` · Esc 关闭`]}),b&&(0,F.jsx)(`p`,{className:`quick-open-status`,role:`alert`,children:b}),(0,F.jsx)(`ul`,{className:`quick-open-results`,role:`listbox`,children:A.map((e,t)=>(0,F.jsx)(`li`,{children:(0,F.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,F.jsx)(`span`,{title:e.name,children:e.name}),(0,F.jsx)(`small`,{title:e.path,children:e.path})]})},e.path))}),T&&k?.indexed&&(p>0||k.truncated)&&(0,F.jsxs)(`div`,{className:`quick-open-pages`,"aria-label":`文件搜索翻页`,children:[p>0&&(0,F.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,onClick:()=>j(p-1),children:`上一页`}),k.truncated&&(0,F.jsx)(`button`,{className:`workbench-search-path-link`,type:`button`,"data-quick-open-next-page":!0,onClick:()=>j(p+1),children:`下一页`})]})]})}function Hm({workspaceId:e,workspaceName:t,cwd:n,connected:r,onOpen:i,onSession:a,active:o=!0}){let[s,c]=(0,u.useState)(`content`),[l,d]=(0,u.useState)(``),f=(0,u.useRef)(null);(0,u.useEffect)(()=>{if(!o)return;let e=requestAnimationFrame(()=>f.current?.parentElement?.querySelector(`[data-content-search-input], [data-quick-open-input], [data-session-search-input]`)?.focus());return()=>cancelAnimationFrame(e)},[o,s]);let p={workspaceId:e,cwd:n,initialQuery:l,presentation:`sidebar`,onClose:()=>{},onMode:(e,t)=>{d(t),c(e)}};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{ref:f,className:`workbench-search-heading`,children:[(0,F.jsx)(`strong`,{children:`搜索`}),(0,F.jsx)(`span`,{title:t,children:t??`请选择工作区`})]}),s===`content`?(0,F.jsx)(Bm,{...p,onOpen:i}):s===`path`?(0,F.jsx)(Vm,{...p,connected:r,onOpen:i}):(0,F.jsx)(Hf,{...p,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 Wm(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 Gm(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 Km({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:_}=Gm(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=Wm(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,F.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,F.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,F.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,F.jsx)(`span`,{className:`${c}-icon workspace-tab-icon`,children:a.icon}),a.badge,(0,F.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,F.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 qm=25,Jm=75;function Ym({share:e,onShare:t}){let n=(0,u.useRef)(null),[r,i]=(0,u.useState)(!1),a=e=>t(Math.round(Math.min(Jm,Math.max(qm,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,F.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":qm,"aria-valuemax":Jm,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(qm);else if(t.key===`End`)a(Jm);else return;t.preventDefault()}})}function Xm({tabs:e,selected:t,onSelect:n,onPin:r,onCloseTab:i,onClose:a,children:o}){let s=e.find(e=>e.id===t);return(0,F.jsxs)(`section`,{className:`workbench-split-pane`,"data-workbench-split-pane":!0,"aria-label":`拆分区`,children:[(0,F.jsxs)(`div`,{className:`workbench-split-bar`,children:[(0,F.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,F.jsx)(`option`,{value:``,disabled:!0,children:`选择文件或差异`}),e.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.label},e.id))]}),t&&s?.preview&&(0,F.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`固定标签页`,"aria-label":`固定拆分区标签页`,onClick:()=>r(t),children:(0,F.jsx)(Gr,{name:`pin`})}),t&&(0,F.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,title:`关闭此标签页`,"aria-label":`关闭拆分区标签页`,onClick:()=>i(t),children:(0,F.jsx)(Gr,{name:`close`})}),(0,F.jsx)(`button`,{className:`workbench-icon-button`,type:`button`,"data-close-workbench-split":!0,title:`合并主区`,"aria-label":`合并主区`,onClick:a,children:(0,F.jsx)(Gr,{name:`split`})})]}),o??(0,F.jsx)(`p`,{className:`rail-empty`,children:`从文件或 Git 面板打开一个文件或差异。`})]})}function Zm(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 Qm(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 $m={pending:`未开始`,running:`运行中`,completed:`已完成`,failed:`失败`,skipped:`已跳过`,stopped:`已停止`},eh={running:`运行中`,completed:`全部完成`,failed:`中途失败`,stopped:`已停止`},th={pending:`○`,running:`◐`,completed:`✓`,failed:`✕`,skipped:`→`,stopped:`■`},nh={stop:`失败即停`,skip:`失败跳过`,"retry:1":`失败重试 1 次`,"retry:2":`失败重试 2 次`,"retry:3":`失败重试 3 次`};function rh(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 ih(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 ah({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,F.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,F.jsx)(`span`,{className:`workflow-step-mark`,"aria-hidden":`true`,children:th[e.status]}),(0,F.jsxs)(`span`,{className:`workflow-step-n`,"data-workflow-step-n":e.index+1,children:[`第 `,e.index+1,` 步`]}),(0,F.jsx)(`strong`,{className:`workflow-step-name`,"data-workflow-step-name":e.index+1,children:a}),(0,F.jsx)(`span`,{className:`workflow-step-agent`,"data-workflow-step-agent-name":e.index+1,children:i}),n>1&&(0,F.jsxs)(`span`,{className:`workflow-step-tries`,"data-workflow-step-retried":e.index+1,children:[`尝试 `,n,` 次`]}),(0,F.jsx)(`span`,{className:`workflow-step-status`,"data-workflow-step-status-text":e.index+1,children:$m[e.status]}),e.status===`failed`&&r?.error&&(0,F.jsx)(`span`,{className:`workflow-step-why`,"data-workflow-step-error":e.index+1,title:kr(r.error),children:Or(r.error,`这一步没有完成。`)})]})}function oh({nodes:e,steps:t,names:n}){return(0,F.jsx)(`ol`,{className:`workflow-steps`,children:e.map((e,r)=>{if(e.kind===`step`){let r=t[e.stepIndex];return r?(0,F.jsx)(ah,{step:r,names:n},`step-${e.stepIndex}`):null}return e.kind===`loop`?(0,F.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,F.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`↻`}),(0,F.jsx)(`strong`,{children:`循环`}),(0,F.jsxs)(`span`,{children:[`直到「`,e.until,`」`]}),(0,F.jsxs)(`span`,{"data-workflow-loop-progress":!0,children:[`已跑 `,e.rounds.length,`/`,e.max,` 轮`]})]}),e.rounds.map(e=>(0,F.jsxs)(`section`,{className:`workflow-round`,"data-workflow-round":e.n,"data-workflow-round-met":e.untilMet?`true`:`false`,children:[(0,F.jsxs)(`div`,{className:`workflow-round-head`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:e.untilMet?`✓`:`○`}),`第 `,e.n,` 轮 · `,e.untilMet?`条件满足`:`条件未满足`]}),(0,F.jsx)(oh,{nodes:e.nodes,steps:t,names:n})]},e.n))]},`loop-${r}`):(0,F.jsxs)(`li`,{className:`workflow-node workflow-foreach`,"data-workflow-foreach":!0,"data-workflow-foreach-count":e.items.length,children:[(0,F.jsxs)(`div`,{className:`workflow-node-head`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`≡`}),(0,F.jsx)(`strong`,{children:`逐项执行`}),(0,F.jsxs)(`span`,{children:[e.items.length,` 个由 primary 给出的项目`]})]}),e.iterations.map((e,r)=>(0,F.jsxs)(`section`,{className:`workflow-item`,"data-workflow-item":r+1,"data-workflow-item-value":e.item,children:[(0,F.jsxs)(`div`,{className:`workflow-item-head`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),`第 `,r+1,` 项 · `,e.item]}),(0,F.jsx)(oh,{nodes:e.nodes,steps:t,names:n})]},`${r}-${e.item}`))]},`foreach-${r}`)})})}function sh({workflow:e,names:t,onStop:n,stopping:r}){let i=e.status===`running`,a=ih(e),o=e.steps.filter(e=>e.status===`completed`||e.status===`skipped`).length;return(0,F.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,F.jsxs)(`div`,{className:`workflow-head`,children:[(0,F.jsx)(`span`,{className:`workflow-badge`,children:`编排`}),(0,F.jsx)(`strong`,{className:`workflow-summary`,"data-workflow-summary":e.id,children:e.summary}),(0,F.jsxs)(`span`,{className:`workflow-progress`,"data-workflow-progress":e.id,children:[o,`/`,e.steps.length]}),(0,F.jsx)(`span`,{className:`workflow-status`,"data-workflow-status-text":e.id,children:eh[e.status]??`未知状态`}),(0,F.jsx)(`span`,{className:`workflow-policy`,"data-workflow-policy":e.onFailure,children:nh[e.onFailure]??e.onFailure}),a!==void 0&&(0,F.jsxs)(`span`,{className:`workflow-clock`,"data-workflow-elapsed":e.id,children:[i?`已运行 `:`用时 `,rh(a)]}),i&&(0,F.jsx)(`button`,{type:`button`,className:`workflow-stop`,"data-workflow-stop":e.id,disabled:r,onClick:n,children:`停止`})]}),e.nodes?(0,F.jsx)(oh,{nodes:e.nodes,steps:e.steps,names:t}):(0,F.jsx)(`ol`,{className:`workflow-steps`,"data-workflow-step-count":e.steps.length,children:e.steps.map(e=>(0,F.jsx)(ah,{step:e,names:t},e.index))})]})}var ch=[{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 lh({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=ch.find(e=>e.id===t)??ch[0];return(0,F.jsx)(`div`,{className:`overlay`,onClick:e,children:(0,F.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,F.jsxs)(`div`,{className:`settings-window-head help-window-head`,children:[(0,F.jsxs)(`div`,{className:`help-head-title`,children:[(0,F.jsx)(`h2`,{id:`help-window-title`,children:`使用指南与帮助`}),(0,F.jsx)(`span`,{className:`help-badge`,children:`v0.1.x`})]}),(0,F.jsx)(`button`,{type:`button`,className:`help-close-button`,"aria-label":`关闭指南`,onClick:e,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`settings-window-body help-window-body`,children:[(0,F.jsxs)(`nav`,{className:`settings-nav help-nav`,role:`tablist`,"aria-orientation":`vertical`,"aria-label":`使用指南分类`,children:[(0,F.jsx)(`div`,{className:`settings-nav-label`,children:`目录`}),ch.map(e=>(0,F.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,F.jsx)(`span`,{className:`help-tab-icon`,"aria-hidden":`true`,children:e.icon}),(0,F.jsx)(`span`,{children:e.label})]},e.id))]}),(0,F.jsxs)(`div`,{id:`help-panel`,className:`settings-panel help-panel`,role:`tabpanel`,"aria-labelledby":`help-tab-${r.id}`,children:[(0,F.jsxs)(`div`,{className:`help-panel-header`,children:[(0,F.jsx)(`h3`,{className:`help-panel-title`,children:r.title}),(0,F.jsx)(`p`,{className:`help-panel-desc`,children:r.description})]}),(0,F.jsxs)(`div`,{className:`help-panel-content`,children:[r.id===`agents`&&(0,F.jsx)(fh,{}),r.id===`workspace`&&(0,F.jsx)(ph,{}),r.id===`subagents`&&(0,F.jsx)(hh,{}),r.id===`model-policy`&&(0,F.jsx)(mh,{}),r.id===`memory`&&(0,F.jsx)(uh,{}),r.id===`knowledge`&&(0,F.jsx)(dh,{}),r.id===`feishu`&&(0,F.jsx)(gh,{}),r.id===`tools`&&(0,F.jsx)(_h,{}),r.id===`cli`&&(0,F.jsx)(vh,{}),r.id===`themes`&&(0,F.jsx)(yh,{})]}),(0,F.jsx)(`div`,{className:`picker-actions help-actions`,children:(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:e,children:`关闭`})})]})]})]})})}function uh(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card highlight`,children:[(0,F.jsx)(`h4`,{children:`🧠 它会记住什么?`}),(0,F.jsx)(`p`,{children:`用户档案保存跨工作区的长期偏好;工作区事实保存环境与项目约定;技能保存已经验证过的步骤、命令和坑。临时结果、秘密和未验证的失败不会保存。`})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`主动保存与后台复盘`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[`主 Agent 可以使用 `,(0,F.jsx)(`code`,{children:`memory`}),` 和 `,(0,F.jsx)(`code`,{children:`skill_manage`}),` 工具主动保存;说“记住了”本身不会写入。`]}),(0,F.jsx)(`li`,{children:`每隔若干回合,系统会在独立会话中复盘最近证据。复盘不能读写工作区文件、执行命令或派发任务。`}),(0,F.jsx)(`li`,{children:`读取记忆和历史只返回带来源的参考数据,不能把记忆中的文字当作新的指令。`})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`权限与审批`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsx)(`li`,{children:`子 Agent 可以读取相关记忆,但没有写入权限。`}),(0,F.jsx)(`li`,{children:`后台复盘新增记忆可以直接保存;修改或删除旧条目会进入设置中的待审批列表。`}),(0,F.jsx)(`li`,{children:`在“设置 → 主动记忆”可以开关功能、调整复盘间隔、编辑条目和批准提案。`})]})]})]})}function dh(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card highlight`,children:[(0,F.jsx)(`h4`,{children:`📚 它解决什么问题?`}),(0,F.jsx)(`p`,{children:`Agent 默认靠训练时的记忆回答项目里的问题。知识库让你把规范、设计稿、会议纪要导入工作区,Agent 在回答前检索这些文档的原文片段,而不是凭印象编造。它与“主动记忆”不同:记忆是 Agent 自己沉淀的事实和技能,知识库的内容来自工作区里真实存在的文档。`})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`怎么用`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[`在“设置 → 知识库”里点“浏览工作区文件…”,在弹出的浏览器里挑一个 Markdown 或文本文件,挑完即导入。也可以直接粘贴正文、手动填写相对路径,或者直接对 Agent 说“把某某文件加入知识库”——它会用 `,(0,F.jsx)(`code`,{children:`knowledge_import`}),` 导入,走的是同一条服务端校验。`]}),(0,F.jsx)(`li`,{children:`同一个文件内容改了再导入就是更新,不会留下旧版本;同样的内容换个标题再导入也不会变成两篇。`}),(0,F.jsx)(`li`,{children:`面板里的“试检索”会用和 Agent 相同的检索器回答,方便你在交给 Agent 之前先确认它找得到。`}),(0,F.jsxs)(`li`,{children:[`从下一条消息开始生效。Agent 使用 `,(0,F.jsx)(`code`,{children:`knowledge_search`}),` 检索,只拿得到片段和来源,拿不到整篇文档。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`语义检索是内置的`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[`关键词检索始终可用。语义检索让“撤销购买”也能找到写着“取消订单”的段落,它靠一个`,(0,F.jsx)(`strong`,{children:`随安装包一起分发`}),`的中文模型在本机运行,不需要额外下载、不需要联网、也不会把文档发到任何服务。`]}),(0,F.jsxs)(`li`,{children:[`第一次检索时加载模型(约一秒),之后一直可用。设 `,(0,F.jsx)(`code`,{children:`SUPER_PI_KNOWLEDGE_EMBEDDINGS=0`}),` 可以彻底关闭语义检索,只保留关键词检索。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`它不知道的事`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsx)(`li`,{children:`知识库只会检索它有的东西。文档里没写的,它检索出来也不会有——所以导入什么,直接决定它能回答什么。`}),(0,F.jsx)(`li`,{children:`语义检索总会返回“最接近的那一段”,即使这一段其实并不回答问题。检索结果带一个分数,低分意味着这可能只是最像的一条,Agent 会被要求先核对再使用。`}),(0,F.jsxs)(`li`,{children:[`Agent 可以按你的要求把工作区文件导入知识库(`,(0,F.jsx)(`code`,{children:`knowledge_import`}),`,只接受文本类文件),但`,(0,F.jsx)(`strong`,{children:`不能删除`}),`——删除文档只有你能在“设置 → 知识库”里做。`]})]})]})]})}function fh(){return(0,F.jsxs)(`div`,{className:`help-section-group`,children:[(0,F.jsxs)(`div`,{className:`help-card highlight`,children:[(0,F.jsx)(`h4`,{children:`💡 Agent 是什么?`}),(0,F.jsxs)(`p`,{children:[`在 Super Pi 中,`,(0,F.jsx)(`strong`,{children:`Agent(智能体)`}),` 是一套独立的「角色提示词设定与能力配置」。 通过切换 Agent,模型将扮演专精工程师、系统架构师、代码审查员或规划专家等不同角色,遵循指定的原则来协助你完成任务。`]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`📁 Agent 文件存放在哪里?`}),(0,F.jsxs)(`ul`,{className:`help-list`,children:[(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`内置 Agent 目录:`}),`项目根目录下的 `,(0,F.jsx)(`code`,{children:`agents/`}),` 文件夹,例如 `,(0,F.jsx)(`code`,{children:`agents/coder.md`}),`、`,(0,F.jsx)(`code`,{children:`agents/planner.md`}),`、`,(0,F.jsx)(`code`,{children:`agents/reviewer.md`}),` 等。`]}),(0,F.jsxs)(`li`,{children:[(0,F.jsx)(`strong`,{children:`用户自定义持久化目录:`}),`用户主目录下的 `,(0,F.jsx)(`code`,{children:`~/.super-pi/agents/`}),`,放入此目录的文件在所有项目和更新中均持久有效。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-card`,children:[(0,F.jsx)(`h4`,{children:`🚀 如何创建一个全新的自定义 Agent?`}),(0,F.jsxs)(`div`,{className:`help-steps`,children:[(0,F.jsxs)(`div`,{className:`help-step`,children:[(0,F.jsx)(`span`,{className:`step-num`,children:`1`}),(0,F.jsxs)(`div`,{className:`step-body`,children:[(0,F.jsx)(`strong`,{children:`创建 Markdown 文件`}),(0,F.jsxs)(`p`,{children:[`在 `,(0,F.jsx)(`code`,{children:`agents/`}),` 或 `,(0,F.jsx)(`code`,{children:`~/.super-pi/agents/`}),` 目录下新建文件,例如 `,(0,F.jsx)(`code`,{children:`architect.md`}),`。`]})]})]}),(0,F.jsxs)(`div`,{className:`help-step`,children:[(0,F.jsx)(`span`,{className:`step-num`,children:`2`}),(0,F.jsxs)(`div`,{className:`step-body`,children:[(0,F.jsx)(`strong`,{children:`编写元数据与系统提示词`}),(0,F.jsx)(`p`,{children:`文件开头使用 YAML Frontmatter 声明名称和描述,正文编写设定提示词:`}),(0,F.jsx)(`pre`,{className:`help-code-block`,children:(0,F.jsx)(`code`,{children:`---
|
|
@@ -327,7 +327,7 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
327
327
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),Dx&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Xx(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=dx(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-Zx),Zx),t/=Zx,t/Math.abs(t)+Math.round(t*(Qx-1)))}shouldForceSelection(e){return Cx?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),$x)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Cx&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<eS&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=Ix(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);n?!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,n):this._oldHasSelection&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Xx(n,this._bufferService.cols)}};nS=yg([bg(3,qg),bg(4,Yg),bg(5,s_),bg(6,$g),bg(7,c_),bg(8,o_)],nS);var rS=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},iS=class{constructor(){this._color=new rS,this._css=new rS}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},aS=Object.freeze((()=>{let e=[Nb.toColor(`#2e3436`),Nb.toColor(`#cc0000`),Nb.toColor(`#4e9a06`),Nb.toColor(`#c4a000`),Nb.toColor(`#3465a4`),Nb.toColor(`#75507b`),Nb.toColor(`#06989a`),Nb.toColor(`#d3d7cf`),Nb.toColor(`#555753`),Nb.toColor(`#ef2929`),Nb.toColor(`#8ae234`),Nb.toColor(`#fce94f`),Nb.toColor(`#729fcf`),Nb.toColor(`#ad7fa8`),Nb.toColor(`#34e2e2`),Nb.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:jb.toCss(r,i,a),rgba:jb.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:jb.toCss(n,n,n),rgba:jb.toRgba(n,n,n)})}return e})()),oS=Nb.toColor(`#ffffff`),sS=Nb.toColor(`#000000`),cS=Nb.toColor(`#ffffff`),lS=sS,uS={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},dS=oS,fS=class extends I_{constructor(e){super(),this._optionsService=e,this._contrastCache=new iS,this._halfContrastCache=new iS,this._onChangeColors=this._register(new Q),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:oS,background:sS,cursor:cS,cursorAccent:lS,selectionForeground:void 0,selectionBackgroundTransparent:uS,selectionBackgroundOpaque:Mb.blend(sS,uS),selectionInactiveBackgroundTransparent:uS,selectionInactiveBackgroundOpaque:Mb.blend(sS,uS),scrollbarSliderBackground:Mb.opacity(oS,.2),scrollbarSliderHoverBackground:Mb.opacity(oS,.4),scrollbarSliderActiveBackground:Mb.opacity(oS,.5),overviewRulerBorder:oS,ansi:aS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=pS(e.foreground,oS),t.background=pS(e.background,sS),t.cursor=Mb.blend(t.background,pS(e.cursor,cS)),t.cursorAccent=Mb.blend(t.background,pS(e.cursorAccent,lS)),t.selectionBackgroundTransparent=pS(e.selectionBackground,uS),t.selectionBackgroundOpaque=Mb.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=pS(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Mb.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?pS(e.selectionForeground,Ab):void 0,t.selectionForeground===Ab&&(t.selectionForeground=void 0),Mb.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Mb.opacity(t.selectionBackgroundTransparent,.3)),Mb.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Mb.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=pS(e.scrollbarSliderBackground,Mb.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=pS(e.scrollbarSliderHoverBackground,Mb.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=pS(e.scrollbarSliderActiveBackground,Mb.opacity(t.foreground,.5)),t.overviewRulerBorder=pS(e.overviewRulerBorder,dS),t.ansi=aS.slice(),t.ansi[0]=pS(e.black,aS[0]),t.ansi[1]=pS(e.red,aS[1]),t.ansi[2]=pS(e.green,aS[2]),t.ansi[3]=pS(e.yellow,aS[3]),t.ansi[4]=pS(e.blue,aS[4]),t.ansi[5]=pS(e.magenta,aS[5]),t.ansi[6]=pS(e.cyan,aS[6]),t.ansi[7]=pS(e.white,aS[7]),t.ansi[8]=pS(e.brightBlack,aS[8]),t.ansi[9]=pS(e.brightRed,aS[9]),t.ansi[10]=pS(e.brightGreen,aS[10]),t.ansi[11]=pS(e.brightYellow,aS[11]),t.ansi[12]=pS(e.brightBlue,aS[12]),t.ansi[13]=pS(e.brightMagenta,aS[13]),t.ansi[14]=pS(e.brightCyan,aS[14]),t.ansi[15]=pS(e.brightWhite,aS[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=pS(e.extendedAnsi[r],aS[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0)for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];else switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};fS=yg([bg(0,$g)],fS);function pS(e,t){if(e!==void 0)try{return Nb.toColor(e)}catch{}return t}var mS=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},hS=class{constructor(){this._services=new mS,this._services.set(Zg,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=Wg(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},gS={trace:0,debug:1,info:2,warn:3,error:4,off:5},_S=`xterm.js: `,vS=class extends I_{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),yS=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=gS[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:_S)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};vS=yg([bg(0,$g)],vS);var yS,bS=class extends I_{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Q),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Q),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Q),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},xS=3,SS=Object.freeze(new Rg),CS=0,wS=2,TS=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*xS);let r=t||Bg.fromCharData([0,Ig,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*xS+0],n=t&2097151;return[this._data[e*xS+1],t&2097152?this._combined[e]:n?Mg(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*xS+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*xS+0]=e|2097152|t[2]<<22):this._data[e*xS+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*xS+0]>>22}hasWidth(e){return this._data[e*xS+0]&12582912}getFg(e){return this._data[e*xS+1]}getBg(e){return this._data[e*xS+2]}hasContent(e){return this._data[e*xS+0]&4194303}getCodePoint(e){let t=this._data[e*xS+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*xS+0]&2097152}getString(e){let t=this._data[e*xS+0];return t&2097152?this._combined[e]:t&2097151?Mg(t&2097151):``}isProtected(e){return this._data[e*xS+2]&536870912}loadCell(e,t){return CS=e*xS,t.content=this._data[CS+0],t.fg=this._data[CS+1],t.bg=this._data[CS+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*xS+0]=t.content,this._data[e*xS+1]=t.fg,this._data[e*xS+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*xS+0]=t|n<<22,this._data[e*xS+1]=r.fg,this._data[e*xS+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*xS+0];r&2097152?this._combined[e]+=Mg(t):r&2097151?(this._combined[e]=Mg(r&2097151)+Mg(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*xS+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new Bg;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new Bg;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r)for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;else for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*wS<this._data.buffer.byteLength;let n=e*xS;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*wS<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*wS<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t)for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);else{this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*xS+0]&4194303)return e+(this._data[e*xS+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*xS+0]&4194303||this._data[e*xS+2]&50331648)return e+(this._data[e*xS+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<xS;e++)this._data[(n+i)*xS+e]=a[(t+i)*xS+e];a[(t+i)*xS+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<xS;e++)this._data[(n+i)*xS+e]=a[(t+i)*xS+e];a[(t+i)*xS+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*xS+0],n=e&2097151,a=e&2097152?this._combined[t]:n?Mg(n):Lg;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function ES(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=AS(u,d,t),p=1,m=0;for(;p<u.length;){let e=AS(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function DS(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function OS(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function kS(e,t,n){let r=[],i=e.map((n,r)=>AS(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=AS(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function AS(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var jS=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Q),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),j_(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};jS._nextId=1;var MS=jS,NS={},PS=NS.B;NS[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:``,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},NS.A={"#":`£`},NS.B=void 0,NS[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},NS.C=NS[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},NS.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},NS.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},NS.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},NS.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},NS.E=NS[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},NS.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},NS.H=NS[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},NS[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var FS=4294967295,IS=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=SS.clone(),this.savedCharset=PS,this.markers=[],this._nullCell=Bg.fromCharData([0,Ig,1,0]),this._whitespaceCell=Bg.fromCharData([0,Lg,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Mx,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new bS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new zg),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new zg),this._whitespaceCell}getBlankLine(e,t){return new TS(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>FS?FS:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=SS);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new bS(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(SS),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new TS(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new TS(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=ES(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(SS),n);if(r.length>0){let n=DS(this.lines,r);OS(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(SS),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new TS(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(SS),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=kS(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(SS,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=AS(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new MS(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},LS=class extends I_{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Q),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new IS(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new IS(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},RS=2,zS=1,BS=class extends I_{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,RS),this.rows=Math.max(e.rawOptions.rows||0,zS),this.buffers=this._register(new LS(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};BS=yg([bg(0,$g)],BS);var VS={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Cx,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},HS=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],US=class extends I_{constructor(e){super(),this._onOptionChange=this._register(new Q),this.onOptionChange=this._onOptionChange.event;let t={...VS};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(N_(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in VS))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in VS))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=VS[e],!WS(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=VS[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=HS.includes(t)?t:VS[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function WS(e){return e===`block`||e===`underline`||e===`bar`}function GS(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&GS(e[r],t-1);return n}var KS=Object.freeze({insertMode:!1}),qS=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),JS=class extends I_{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Q),this.onData=this._onData.event,this._onUserInput=this._register(new Q),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Q),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=GS(KS),this.decPrivateModes=GS(qS)}reset(){this.modes=GS(KS),this.decPrivateModes=GS(qS)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};JS=yg([bg(0,qg),bg(1,Qg),bg(2,$g)],JS);var YS={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function XS(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var ZS=String.fromCharCode,QS={DEFAULT:e=>{let t=[XS(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${ZS(t[0])}${ZS(t[1])}${ZS(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${XS(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${XS(e,!0)};${e.x};${e.y}${t}`}},$S=class extends I_{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Q),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(YS))this.addProtocol(e,YS[e]);for(let e of Object.keys(QS))this.addEncoding(e,QS[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};$S=yg([bg(0,qg),bg(1,Yg),bg(2,$g)],$S);var eC=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],tC=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],nC;function rC(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var iC=class{constructor(){if(this.version=`6`,!nC){nC=new Uint8Array(65536),nC.fill(1),nC[0]=0,nC.fill(0,1,32),nC.fill(0,127,160),nC.fill(2,4352,4448),nC[9001]=2,nC[9002]=2,nC.fill(2,11904,42192),nC[12351]=1,nC.fill(2,44032,55204),nC.fill(2,63744,64256),nC.fill(2,65040,65050),nC.fill(2,65072,65136),nC.fill(2,65280,65377),nC.fill(2,65504,65511);for(let e=0;e<eC.length;++e)nC.fill(0,eC[e][0],eC[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?nC[e]:rC(e,tC)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=aC.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return aC.createPropertyValue(0,n,r)}},aC=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Q,this.onChange=this._onChange.event;let e=new iC;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},oC=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function sC(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var cC=2147483647,lC=256,uC=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>lC)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>cC?cC:e}}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>cC?cC:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,cC):e}},dC=[],fC=class{constructor(){this._state=0,this._active=dC,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=dC}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=dC,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||dC,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,Ng(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=dC,this._id=-1,this._state=0}}},pC=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Ng(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},mC=[],hC=class{constructor(){this._handlers=Object.create(null),this._active=mC,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=mC}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=mC,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||mC,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,Ng(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=mC,this._ident=0}},gC=new uC;gC.addParam(0);var _C=class{constructor(e){this._handler=e,this._data=``,this._params=gC,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():gC,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Ng(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=gC,this._data=``,this._hitLimit=!1,e));return this._params=gC,this._data=``,this._hitLimit=!1,t}},vC=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},yC=160,bC=function(){let e=new vC(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(yC,0,2,0),e.add(yC,8,5,8),e.add(yC,6,0,6),e.add(yC,11,0,11),e.add(yC,13,13,13),e}(),xC=class extends I_{constructor(e=bC){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new uC,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(N_(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new fC),this._dcsParser=this._register(new hC),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:yC)],i>>4){case 2:for(let i=n+1;;++i)if(i>=t||(r=e[i])<32||r>126&&r<yC||++i>=t||(r=e[i])<32||r>126&&r<yC||++i>=t||(r=e[i])<32||r>126&&r<yC||++i>=t||(r=e[i])<32||r>126&&r<yC){this._printHandler(e,n,i),n=i-1;break}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<yC){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<yC){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},SC=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,CC=/^[\da-f]+$/;function wC(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=SC.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),CC.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function TC(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function EC(e,t=16){let[n,r,i]=e;return`rgb:${TC(n,t)}/${TC(r,t)}/${TC(i,t)}`}var DC={"(":0,")":1,"*":2,"+":3,"-":1,".":2},OC=131072,kC=10;function AC(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var jC=5e3,MC=0,NC=class extends I_{constructor(e,t,n,r,i,a,o,s,c=new xC){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Pg,this._utf8Decoder=new Fg,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=SS.clone(),this._eraseAttrDataInternal=SS.clone(),this._onRequestBell=this._register(new Q),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Q),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Q),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Q),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Q),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Q),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Q),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Q),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Q),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Q),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new PC(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Cb.IND,()=>this.index()),this._parser.setExecuteHandler(Cb.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Cb.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new pC(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new pC(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new pC(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new pC(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new pC(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new pC(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new pC(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new pC(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new pC(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new pC(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new pC(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new pC(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in NS)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new _C((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),jC))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${jC} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>OC&&(a=this._parseStack.position+OC)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<OC&&(this._parseBuffer=new Uint32Array(Math.min(e.length,OC))),o||this._dirtyRowTracker.clearRange(),e.length>OC)for(let t=a;t<e.length;t+=OC){let a=t+OC<e.length?t+OC:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=aC.extractWidth(t);let n=aC.extractShouldJoin(t),m=n?aC.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(Mg(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof TS&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}else if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!AC(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new _C(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new pC(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(SS));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=aC.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,PS),this._charsetService.setgCharset(1,PS),this._charsetService.setgCharset(2,PS),this._charsetService.setgCharset(3,PS);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=Rg.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=SS.fg,e.bg=SS.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=SS.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=SS.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=SS.fg&16777215,r.bg&=-67108864,r.bg|=SS.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=SS.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!AC(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>kC&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>kC&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(FC(n)){if(r===`?`)t.push({type:0,index:n});else{let e=wC(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=wC(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);FC(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,PS),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(DC[e[0]],NS[e[1]]||PS),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=SS.clone(),this._eraseAttrDataInternal=SS.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Bg;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},PC=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(MC=e,e=t,t=MC),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};PC=yg([bg(0,qg)],PC);function FC(e){return 0<=e&&e<256}var IC=5e7,LC=12,RC=50,zC=class extends I_{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>IC)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=LC?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=LC)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>RC&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},BC=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};BC=yg([bg(0,qg)],BC);var VC=!1,HC=class extends I_{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new L_),this._onBinary=this._register(new Q),this.onBinary=this._onBinary.event,this._onData=this._register(new Q),this.onData=this._onData.event,this._onLineFeed=this._register(new Q),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Q),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Q),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Q),this._instantiationService=new hS,this.optionsService=this._register(new US(e)),this._instantiationService.setService($g,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(BS)),this._instantiationService.setService(qg,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(vS)),this._instantiationService.setService(Qg,this._logService),this.coreService=this._register(this._instantiationService.createInstance(JS)),this._instantiationService.setService(Yg,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance($S)),this._instantiationService.setService(Jg,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(aC)),this._instantiationService.setService(t_,this.unicodeService),this._charsetService=this._instantiationService.createInstance(oC),this._instantiationService.setService(Xg,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(BC),this._instantiationService.setService(e_,this._oscLinkService),this._inputHandler=this._register(new NC(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(W_.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(W_.forward(this._bufferService.onResize,this._onResize)),this._register(W_.forward(this.coreService.onData,this._onData)),this._register(W_.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new zC((e,t)=>this._inputHandler.parse(e,t))),this._register(W_.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Q),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!VC&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),VC=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,RS),t=Math.max(t,zS),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(sC.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(sC(this._bufferService),!1))),this._windowsWrappingHeuristics.value=N_(()=>{for(let t of e)t.dispose()})}}},UC={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function WC(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?$.ESC+`OA`:$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?$.ESC+`OD`:$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?$.ESC+`OC`:$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?$.ESC+`OB`:$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`D`:t?$.ESC+`OD`:$.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`C`:t?$.ESC+`OC`:$.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`A`:t?$.ESC+`OA`:$.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`B`:t?$.ESC+`OB`:$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:i.key=a?$.ESC+`[3;`+(a+1)+`~`:$.ESC+`[3~`;break;case 36:i.key=a?$.ESC+`[1;`+(a+1)+`H`:t?$.ESC+`OH`:$.ESC+`[H`;break;case 35:i.key=a?$.ESC+`[1;`+(a+1)+`F`:t?$.ESC+`OF`:$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?$.ESC+`[5;`+(a+1)+`~`:$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?$.ESC+`[6;`+(a+1)+`~`:$.ESC+`[6~`;break;case 112:i.key=a?$.ESC+`[1;`+(a+1)+`P`:$.ESC+`OP`;break;case 113:i.key=a?$.ESC+`[1;`+(a+1)+`Q`:$.ESC+`OQ`;break;case 114:i.key=a?$.ESC+`[1;`+(a+1)+`R`:$.ESC+`OR`;break;case 115:i.key=a?$.ESC+`[1;`+(a+1)+`S`:$.ESC+`OS`;break;case 116:i.key=a?$.ESC+`[15;`+(a+1)+`~`:$.ESC+`[15~`;break;case 117:i.key=a?$.ESC+`[17;`+(a+1)+`~`:$.ESC+`[17~`;break;case 118:i.key=a?$.ESC+`[18;`+(a+1)+`~`:$.ESC+`[18~`;break;case 119:i.key=a?$.ESC+`[19;`+(a+1)+`~`:$.ESC+`[19~`;break;case 120:i.key=a?$.ESC+`[20;`+(a+1)+`~`:$.ESC+`[20~`;break;case 121:i.key=a?$.ESC+`[21;`+(a+1)+`~`:$.ESC+`[21~`;break;case 122:i.key=a?$.ESC+`[23;`+(a+1)+`~`:$.ESC+`[23~`;break;case 123:i.key=a?$.ESC+`[24;`+(a+1)+`~`:$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=UC[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL))}return i}var GC=0,KC=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Mx,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Mx,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(GC=this._search(t),GC===-1)||this._getKey(this._array[GC])!==t)return!1;do if(this._array[GC]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(GC),!0;while(++GC<this._array.length&&this._getKey(this._array[GC])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(GC=this._search(e),!(GC<0||GC>=this._array.length)&&this._getKey(this._array[GC])===e))do yield this._array[GC];while(++GC<this._array.length&&this._getKey(this._array[GC])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(GC=this._search(e),!(GC<0||GC>=this._array.length)&&this._getKey(this._array[GC])===e))do t(this._array[GC]);while(++GC<this._array.length&&this._getKey(this._array[GC])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},qC=0,JC=0,YC=class extends I_{constructor(){super(),this._decorations=new KC(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Q),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Q),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(N_(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new XC(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{qC=t.options.x??0,JC=qC+(t.options.width??1),e>=qC&&e<JC&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},XC=class extends F_{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Q),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Q),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?Nb.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?Nb.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},ZC=1e3,QC=class{constructor(e,t=ZC){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},$C=20,ew=class extends I_{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new QC(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
328
328
|
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ey(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(N_(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<$C+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
329
329
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===$C+1&&(this._liveRegion.textContent+=wg.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};ew=yg([bg(1,Zg),bg(2,o_),bg(3,c_)],ew);var tw=class extends I_{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Q),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Q),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(N_(()=>{j_(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ey(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ey(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(Ey(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(Ey(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){this._activeLine!==e.y||this._wasResized?(this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1):this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){(!this._activeProviderReplies||!t)&&(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&nw(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,j_(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};tw=yg([bg(1,s_),bg(2,c_),bg(3,qg),bg(4,f_)],tw);function nw(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var rw=class extends HC{constructor(e={}){super(e),this._linkifier=this._register(new L_),this.browser=hx,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new L_),this._onCursorMove=this._register(new Q),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Q),this.onKey=this._onKey.event,this._onRender=this._register(new Q),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Q),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Q),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Q),this.onBell=this._onBell.event,this._onFocus=this._register(new Q),this._onBlur=this._register(new Q),this._onA11yCharEmitter=this._register(new Q),this._onA11yTabEmitter=this._register(new Q),this._onWillOpen=this._register(new Q),this._setup(),this._decorationService=this._instantiationService.createInstance(YC),this._instantiationService.setService(n_,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ux),this._instantiationService.setService(f_,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(r_)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(W_.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(W_.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(W_.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(W_.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(N_(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=Mb.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${EC(r)}${wb.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=jb.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=jb.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(ew,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(Ey(this.element,`copy`,e=>{this.hasSelection()&&Dg(e,this._selectionService)}));let e=e=>Og(e,this.textarea,this.coreService,this.optionsService);this._register(Ey(this.textarea,`paste`,e)),this._register(Ey(this.element,`paste`,e)),yx?this._register(Ey(this.element,`mousedown`,e=>{e.button===2&&jg(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ey(this.element,`contextmenu`,e=>{jg(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Dx&&this._register(Ey(this.element,`auxclick`,e=>{e.button===1&&Ag(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ey(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(Ey(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(Ey(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(Ey(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(Ey(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(Ey(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(Ey(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(Ey(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,Sg.get()),Ox||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(cx,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(o_,this._coreBrowserService),this._register(Ey(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(Ey(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(ix,this._document,this._helperContainer),this._instantiationService.setService(a_,this._charSizeService),this._themeService=this._instantiationService.createInstance(fS),this._instantiationService.setService(d_,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(zb),this._instantiationService.setService(u_,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Px,this.rows,this.screenElement)),this._instantiationService.setService(c_,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(Tb,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(px),this._instantiationService.setService(s_,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(tw,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(gb,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(nS,this.element,this.screenElement,r)),this._instantiationService.setService(l_,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(W_.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(_b,this.screenElement)),this._register(Ey(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(ew,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Sb,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Sb,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(rx,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ey(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(Ey(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){kg(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=WC(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(iw(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(SS));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function iw(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var aw=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},ow=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Bg)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},sw=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new ow(t)}getNullCell(){return new Bg}},cw=class extends I_{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Q),this.onBufferChange=this._onBufferChange.event,this._normal=new sw(this._core.buffers.normal,`normal`),this._alternate=new sw(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},lw=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},uw=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},dw=[`cols`,`rows`],fw=0,pw=class extends I_{constructor(e){super(),this._core=this._register(new rw(e)),this._addonManager=this._register(new aw),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(dw.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new lw(this._core),this._parser}get unicode(){return this._checkProposedApi(),new uw(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new cw(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
330
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Sg.get()},set promptLabel(e){Sg.set(e)},get tooMuchOutput(){return wg.get()},set tooMuchOutput(e){wg.set(e)}}}_verifyIntegers(...e){for(fw of e)if(fw===1/0||isNaN(fw)||fw%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(fw of e)if(fw&&(fw===1/0||isNaN(fw)||fw%1!=0||fw<0))throw Error(`This API only accepts positive integers`)}},mw=2,hw=1,gw=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(mw,Math.floor(u/e.css.cell.width)),rows:Math.max(hw,Math.floor(l/e.css.cell.height))}}},_w=`super-pi.terminal-owner.v1`,vw=`super-pi.terminal-selection.v1.`,yw=20,bw=5,xw=240,Sw=120,Cw={checking:`正在连接`,unavailable:`不可用`,starting:`启动中`,running:`运行中`,exited:`已结束`,empty:`没有打开的终端`},ww;function Tw(){if(ww)return ww;try{let e=window.localStorage.getItem(_w);if(e&&/^[0-9a-f]{32}$/.test(e))return ww=e}catch{}ww=Array.from(window.crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);try{window.localStorage.setItem(_w,ww)}catch{}return ww}function Ew(e){try{return window.sessionStorage.getItem(e)??void 0}catch{return}}function Dw({workspaceId:e,workspaceLabel:t,cwd:n=``,connected:r,sendCommand:i,registerSink:a,conversationId:o,terminalShell:s}){let c=vw+JSON.stringify([e,o]),[l,d]=(0,u.useState)([]),[f,p]=(0,u.useState)(()=>Ew(c)??``),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),S=(0,u.useRef)(new Map),C=(0,u.useRef)(new Map),w=(0,u.useRef)(new Map),T=(0,u.useRef)(new Map),E=(0,u.useRef)(!1),D=(0,u.useRef)(f);D.current=f;let O=(0,u.useRef)(!1),k=(0,u.useRef)(void 0),A=(0,u.useCallback)(e=>{let t=C.current.get(e);if(!t||!t.host.clientWidth||!t.host.clientHeight||T.current.has(e))return;let{terminal:n,fitAddon:r}=t,a=r.proposeDimensions();if(!a||!Number.isFinite(a.cols)||!Number.isFinite(a.rows))return;let o=Math.max(yw,Math.min(xw,a.cols)),s=Math.max(bw,Math.min(Sw,a.rows));(n.cols!==o||n.rows!==s)&&n.resize(o,s);let c=S.current.get(e);E.current&&c&&c.exitCode===void 0&&(c.cols!==o||c.rows!==s)&&i({type:`terminal.resize`,sessionId:e,cols:o,rows:s})},[i]),j=(0,u.useCallback)((e,t)=>{let n=e.sessionId;if(e.type===`terminal.output`){t.write(e.data);return}let r=S.current.get(n),i=T.current.get(n);r&&t.resize(r.cols,r.rows),t.write(`\x1Bc\x1B[3J`+e.data,()=>{T.current.get(n)===i&&(T.current.delete(n),D.current===n&&A(n))})},[A]),ee=(0,u.useCallback)((e,t)=>{if(!t||C.current.has(e))return;let n=getComputedStyle(t),r=(e,t)=>n.getPropertyValue(e).trim()||t,a=S.current.get(e),o=new pw({cols:a?.cols,rows:a?.rows,cursorBlink:!0,convertEol:!1,scrollback:5e3,fontFamily:`Consolas, 'Cascadia Mono', 'DejaVu Sans Mono', monospace`,fontSize:12,lineHeight:1.35,theme:{background:`#00000000`,foreground:r(`--term-fg`,`#dbe4f0`),cursor:r(`--term-fg`,`#dbe4f0`),selectionBackground:r(`--term-selection`,`#3a4f6b`)},allowProposedApi:!0}),s=new gw;o.loadAddon(s),o.open(t),o.onData(t=>{E.current&&!T.current.has(e)&&S.current.get(e)?.exitCode===void 0&&i({type:`terminal.input`,sessionId:e,data:t})}),C.current.set(e,{terminal:o,fitAddon:s,host:t});for(let t of w.current.get(e)??[])j(t,o);w.current.delete(e),requestAnimationFrame(()=>A(e))},[A,i,j]),M=(0,u.useCallback)(t=>{if(t.type===`terminal.sessions`){if(t.workspaceId!==e||t.conversationId!==o)return;let n=new Map(t.sessions.map(e=>[e.id,e]));for(let[e,r]of C.current)n.has(e)?!t.replay&&S.current.get(e)?.exitCode!==void 0&&n.get(e)?.exitCode===void 0&&r.terminal.write(`\x1Bc\x1B[3J`):(r.terminal.dispose(),C.current.delete(e));for(let e of w.current.keys())(!n.has(e)||t.replay)&&w.current.delete(e);if(t.replay){T.current.clear();for(let e of n.keys())T.current.set(e,Symbol())}!t.replay&&O.current&&t.activate&&n.has(t.activate)&&(k.current=t.activate,O.current=!1),S.current=n,E.current=!0,d(t.sessions),p(e=>t.activate??(n.has(e)?e:t.sessions[0]?.id??``)),_(void 0),h(!0)}else if(t.type===`terminal.output`||t.type===`terminal.replay`){if(!S.current.has(t.sessionId))return;let e=C.current.get(t.sessionId)?.terminal;if(e)j(t,e);else{let e=w.current.get(t.sessionId)??[];e.push(t),w.current.set(t.sessionId,e)}}else if(t.type===`terminal.size`){let e=S.current.get(t.sessionId);e&&(Object.assign(e,{cols:t.cols,rows:t.rows}),C.current.get(e.id)?.terminal.resize(e.cols,e.rows))}else if(t.type===`terminal.exit`){let e=S.current.get(t.sessionId);if(!e)return;let n={...e,exitCode:t.exitCode,reason:t.reason};S.current.set(n.id,n),d(e=>e.map(e=>e.id===n.id?n:e))}else(t.type===`terminal.error`||t.type===`terminal.status`&&!t.enabled)&&(O.current=!1,_(void 0),y(t.type===`terminal.error`?t.message:t.reason||`终端未启用`))},[o,e,j]);(0,u.useEffect)(()=>(a(M),()=>a(void 0)),[M,a]);let te=(0,u.useCallback)(()=>{E.current=!1,h(!1),_(void 0),y(``),r&&e&&i({type:`terminal.sync`,ownerId:Tw(),workspaceId:e,conversationId:o,cwd:n,initialize:Ew(c)===void 0})},[r,e,o,n,c,i]);(0,u.useEffect)(()=>(te(),()=>{r&&i({type:`terminal.detach`})}),[r,i,te]),(0,u.useEffect)(()=>()=>{for(let e of C.current.values())e.terminal.dispose();C.current.clear()},[]),(0,u.useEffect)(()=>{if(m)try{window.sessionStorage.setItem(c,f)}catch{}},[f,m,c]),(0,u.useEffect)(()=>{let e=!1;return Ne(`/api/terminal-shell`).then(e=>e.json()).then(t=>{let n=t.shell;!e&&n&&x(n.file+(n.args.length?` `+n.args.join(` `):``)+`(`+(t.source??``)+`)`)}).catch(()=>void 0),()=>{e=!0}},[s?.file,s?.args.join(`\0`)]),(0,u.useLayoutEffect)(()=>{let e=C.current.get(f);if(!e)return;let t=new ResizeObserver(()=>A(f));if(t.observe(e.host),A(f),k.current===f){let e=f;requestAnimationFrame(()=>{k.current===e&&(C.current.get(e)?.terminal.focus(),k.current=void 0)})}return()=>t.disconnect()},[f,A,l]);let N=e=>!r||!m||g?!1:i(e)?(y(``),_(e.type===`terminal.open`?`open`:`close`),!0):!1,ne=e=>{let t=C.current.get(f)?.terminal;O.current=!0,N({type:`terminal.open`,sessionId:e,cols:t?.cols,rows:t?.rows})||(O.current=!1)},re=l.find(e=>e.id===f),ie=r&&m&&!g,ae=e?r?m?g===`open`?`starting`:re?re.exitCode===void 0?`running`:`exited`:`empty`:v?`unavailable`:`checking`:`checking`:`unavailable`,oe=v||re?.reason;return(0,F.jsxs)(`div`,{className:`terminal-panel`,"data-terminal-panel":`1`,"data-terminal-phase":ae,children:[(0,F.jsxs)(`div`,{className:`terminal-strip`,role:`tablist`,"aria-label":`终端会话`,"data-terminal-strip":`1`,children:[l.map(e=>(0,F.jsxs)(`div`,{className:`terminal-tab${e.id===f?` is-active`:``}`,children:[(0,F.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===f,className:`terminal-tab-btn`,"data-terminal-slot":e.id,onClick:()=>p(e.id),title:Cw[e.exitCode===void 0?`running`:`exited`],children:[(0,F.jsx)(`span`,{className:`terminal-tab-dot terminal-tab-dot-${e.exitCode===void 0?`running`:`exited`}`,"aria-hidden":`true`}),e.title]}),(0,F.jsx)(`button`,{type:`button`,className:`terminal-tab-close`,disabled:!ie,"aria-label":`关闭终端 ${e.title}`,"data-terminal-slot-close":e.id,onClick:()=>N({type:`terminal.close`,sessionId:e.id}),children:`×`})]},e.id)),l.length<5&&(0,F.jsx)(`button`,{type:`button`,className:`terminal-strip-add`,disabled:!ie,"data-terminal-add":`1`,onClick:()=>ne(),title:`新建终端`,"aria-label":`新建终端`,children:`+`})]}),(0,F.jsxs)(`div`,{className:`terminal-toolbar`,children:[(0,F.jsxs)(`span`,{className:`terminal-status terminal-status-${ae}`,"data-terminal-status":ae,children:[(0,F.jsx)(`span`,{className:`terminal-status-dot`,"aria-hidden":`true`}),Cw[ae]]}),(0,F.jsxs)(`span`,{className:`terminal-toolbar-right`,children:[b&&(0,F.jsx)(`span`,{className:`terminal-cwd`,"data-terminal-shell-hint":`1`,title:b,children:b}),t&&(0,F.jsx)(`span`,{className:`terminal-cwd`,"data-terminal-hint":`1`,title:t,children:t}),re?.exitCode!==void 0&&(0,F.jsx)(`button`,{type:`button`,className:`terminal-restart-btn`,"data-terminal-restart":`1`,disabled:!ie,onClick:()=>ne(re.id),children:`重新打开`}),!m&&v&&r&&(0,F.jsx)(`button`,{type:`button`,className:`terminal-restart-btn`,onClick:te,children:`重试连接`})]})]}),oe&&(0,F.jsx)(`p`,{className:`tool-error`,"data-terminal-error":`1`,role:`alert`,title:kr(oe),children:Or(oe,`终端出错了。`)}),re?.exitCode!==void 0&&re.exitCode!==0&&(0,F.jsxs)(`p`,{className:`tool-error`,"data-terminal-exit":`1`,children:[`会话已结束,退出码 `,re.exitCode,`。`]}),(0,F.jsxs)(`div`,{className:`terminal-surface`,"data-terminal-surface":`1`,children:[l.map(e=>(0,F.jsx)(`div`,{ref:t=>ee(e.id,t),className:`terminal-xterm-host`,"data-terminal-xterm":e.id,style:{display:e.id===f?`block`:`none`}},e.id)),ae===`empty`&&(0,F.jsx)(`div`,{className:`terminal-surface-empty`,"data-terminal-empty":`1`,children:(0,F.jsx)(`p`,{className:`rail-empty`,children:Cw.empty})}),!re&&ae===`checking`&&(0,F.jsx)(`p`,{className:`rail-empty terminal-surface-message`,"data-terminal-phase":`checking`,children:`正在连接终端…`}),!e&&(0,F.jsx)(`p`,{className:`rail-empty terminal-surface-message`,children:`选择一个工作区后即可打开终端。`})]})]})}function Ow({id:e,title:t,icon:n,count:r,actions:i,children:a}){let o=(0,u.useId)();return(0,F.jsxs)(`section`,{className:`rail-card`,"data-rail-section":e,"aria-labelledby":o,children:[(0,F.jsxs)(`div`,{className:`rail-section-head`,children:[(0,F.jsxs)(`h2`,{className:`rail-section-title`,id:o,children:[(0,F.jsx)(kw,{kind:n}),t]}),r&&(0,F.jsx)(`span`,{className:`rail-section-count`,children:r}),i]}),(0,F.jsx)(`div`,{className:`rail-card-body`,children:a})]})}function kw({kind:e}){return(0,F.jsx)(`svg`,{className:`rail-section-icon`,viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e===`tasks`?(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(`path`,{d:`m3 6 2 2 3-4M11 6h10M3 13h5m3 0h10M3 20h5m3 0h10`})}):e===`clock`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,F.jsx)(`path`,{d:`M12 7v5l3 2`})]}):(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(`path`,{d:`M3 12h4l3-7 4 14 3-7h4`})})})}var Aw=[{day:1,label:`一`},{day:2,label:`二`},{day:3,label:`三`},{day:4,label:`四`},{day:5,label:`五`},{day:6,label:`六`},{day:0,label:`日`}];function jw(e){return e.kind===`interval`?`每隔 ${e.everyMinutes} 分钟`:e.kind===`daily`?`每天 ${e.time}`:e.kind===`weekly`?`每周${e.weekdays.map(e=>Aw.find(t=>t.day===e)?.label??`?`).join(`、`)} ${e.time}`:`仅一次:${Mw(e.at)}`}function Mw(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function Nw(){return typeof Intl<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0}function Pw(e,t){let n=new Date(e);if(!t){let e=e=>String(e).padStart(2,`0`);return`${n.getFullYear()}-${e(n.getMonth()+1)}-${e(n.getDate())} ${e(n.getHours())}:${e(n.getMinutes())}`}let r=new Intl.DateTimeFormat(`en-CA`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(n),i=e=>r.find(t=>t.type===e)?.value??``;return`${i(`year`)}-${i(`month`)}-${i(`day`)} ${i(`hour`)}:${i(`minute`)}`}function Fw(e,t){let n=new Date(e);if(!t){let e=e=>String(e).padStart(2,`0`);return`${e(n.getHours())}:${e(n.getMinutes())}`}let r=new Intl.DateTimeFormat(`en-GB`,{timeZone:t,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(n),i=e=>r.find(t=>t.type===e)?.value??``;return`${i(`hour`)}:${i(`minute`)}`}function Iw(e,t){if(!e)return``;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).formatToParts(t).find(e=>e.type===`timeZoneName`)?.value??e}catch{return e}}function Lw(e,t,n){let r=Fw(e,n),i=Rw(e,t,n);return i===0?`今天 ${r}`:i===1?`明天 ${r}`:Pw(e,n)}function Rw(e,t,n){let r=e=>{let[t]=Pw(e,n).split(` `),[r,i,a]=t.split(`-`).map(Number);return Date.UTC(r,i-1,a)},i=Math.round((r(e)-r(t))/864e5);return Number.isFinite(i)?i:0}function zw(e,t,n){if(!e||!t||e===t)return``;let r=Iw(e,n),i=Iw(t,n);return Fw(n,e)===Fw(n,t)?`服务器在 ${r} 时区,你的时区也是 ${i},下面的时间按你的时区显示`:`服务器在 ${r} 时区,下面的时间按你的时区(${i})显示`}function Bw(e,t,n){return e.enabled?e.nextRunAt===void 0?{glyph:`✓`,word:`已结束`,detail:``}:{glyph:`●`,word:`启用中`,detail:`下次 ${Lw(e.nextRunAt,t,n)}`}:e.schedule.kind===`once`&&e.lastRunAt!==void 0?{glyph:`✓`,word:`已结束`,detail:e.lastRunAt?`上次 ${Pw(e.lastRunAt,n)}`:``}:{glyph:`○`,word:`已停用`,detail:``}}function Vw(e,t){if(e.lastRunAt===void 0)return``;let n=Pw(e.lastRunAt,t);return e.lastRunStatus===`failed`?`上次 ${n} · 失败${e.lastRunMessage?`:${e.lastRunMessage}`:``}`:`上次 ${n} · 成功`}function Hw({tasks:e,workspaceId:t,catalog:n,agents:r,sendCommand:i,notify:a,serverTimeZone:o}){let[s,c]=(0,u.useState)(()=>Date.now()),[l,d]=(0,u.useState)();(0,u.useEffect)(()=>{let e=window.setInterval(()=>c(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let f=Nw(),p=zw(o,f,s),m=e=>{i({type:`scheduledTask.toggle`,id:e.id,enabled:!e.enabled})},h=e=>{i({type:`scheduledTask.trigger`,id:e.id}),a(`已触发「${e.name}」,结果会出现在它自己的会话里。`,`info`)},g=e=>{i({type:`scheduledTask.delete`,id:e.id}),a(`已删除定时任务「${e.name}」,它的会话和结果保留着。`,`info`)};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(Ow,{id:`scheduled`,title:`定时任务`,icon:`clock`,count:(0,F.jsx)(`span`,{"data-sched-count":`1`,children:e.length?`${e.length} 个`:`0 个`}),actions:(0,F.jsx)(`button`,{type:`button`,className:`scheduled-add`,"data-sched-add":`1`,title:`新建定时任务`,onClick:()=>d(`new`),children:`+ 新建`}),children:[p&&(0,F.jsx)(`p`,{className:`scheduled-zone-note`,"data-sched-zone-note":`1`,children:p}),e.length>0?(0,F.jsx)(`ul`,{className:`scheduled-list`,"data-sched-list":`1`,children:e.map(e=>{let t=Bw(e,s,f),n=Vw(e,f);return(0,F.jsxs)(`li`,{className:`scheduled-item`,"data-scheduled-task":e.id,children:[(0,F.jsx)(`button`,{type:`button`,className:`scheduled-toggle`,"data-sched-toggle":`1`,title:e.enabled?`点击停用`:`点击启用`,"aria-label":e.enabled?`停用 ${e.name}`:`启用 ${e.name}`,onClick:()=>m(e),children:t.glyph}),(0,F.jsxs)(`div`,{className:`scheduled-main`,children:[(0,F.jsxs)(`div`,{className:`scheduled-name-row`,children:[(0,F.jsx)(`span`,{className:`scheduled-name`,children:e.name}),(0,F.jsx)(`span`,{className:`scheduled-status-word`,"data-sched-word":`1`,children:t.word}),e.createdBy===`agent`&&(0,F.jsx)(`span`,{className:`scheduled-by`,title:`这个定时任务是 agent 创建的,你可以像编辑自己建的一样编辑它`,children:`agent`})]}),(0,F.jsxs)(`div`,{className:`scheduled-meta`,"data-sched-meta":`1`,children:[jw(e.schedule),t.detail?` · ${t.detail}`:``]}),n&&(0,F.jsx)(`div`,{className:`scheduled-last`,"data-sched-last":`1`,children:n})]}),(0,F.jsxs)(`div`,{className:`scheduled-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`scheduled-action`,"data-sched-trigger":`1`,title:`立即执行一次(不改变周期)`,"aria-label":`立即执行 ${e.name}`,onClick:()=>h(e),children:`⚡`}),(0,F.jsx)(`button`,{type:`button`,className:`scheduled-action`,"data-sched-edit":`1`,title:`编辑`,"aria-label":`编辑 ${e.name}`,onClick:()=>d(e),children:`✎`}),(0,F.jsx)(`button`,{type:`button`,className:`scheduled-action scheduled-action-danger`,"data-sched-delete":`1`,title:`删除(会话与结果保留)`,"aria-label":`删除 ${e.name}`,onClick:()=>g(e),children:`✕`})]})]},e.id)})}):(0,F.jsx)(`p`,{className:`rail-empty`,"data-sched-empty":`1`,children:`还没有定时任务。可以新建周期任务,或让 AI 安排。`})]}),l!==void 0&&(0,F.jsx)(Kw,{task:l===`new`?void 0:l,workspaceId:t,catalog:n,agents:r,sendCommand:i,notify:a,onClose:()=>d(void 0)},l===`new`?`new`:l.id)]})}function Uw(e){let t=e?.schedule;return{name:e?.name??``,prompt:e?.prompt??``,kind:t?.kind??`daily`,everyMinutes:t?.kind===`interval`?String(t.everyMinutes):`30`,time:t&&(t.kind===`daily`||t.kind===`weekly`)?t.time:`09:00`,weekdays:t?.kind===`weekly`?[...t.weekdays]:[1],onceAt:t?.kind===`once`?Ww(t.at):``,modelKey:e?.model?`${e.model.provider}/${e.model.modelId}`:``,agentId:e?.agentId??``}}function Ww(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Gw(e){if(e.kind===`interval`){let t=Number(e.everyMinutes);return!Number.isInteger(t)||t<1||t>10080?{ok:!1,reason:`间隔分钟数要是一个 1 到 10080 之间的整数。`}:{ok:!0,schedule:{kind:`interval`,everyMinutes:t}}}if(e.kind===`daily`||e.kind===`weekly`){let t=/^(\d{1,2}):(\d{2})$/.exec(e.time.trim()),n=t?Number(t[1]):NaN,r=t?Number(t[2]):NaN;if(!t||n>23||r>59)return{ok:!1,reason:`触发时刻要写成 HH:MM,比如 09:00。`};let i=`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`;return e.kind===`daily`?{ok:!0,schedule:{kind:`daily`,time:i}}:e.weekdays.length?{ok:!0,schedule:{kind:`weekly`,weekdays:[...e.weekdays].sort((e,t)=>e-t),time:i}}:{ok:!1,reason:`每周任务至少要选一天。`}}if(!e.onceAt)return{ok:!1,reason:`选一下这一次的运行时刻。`};let t=new Date(e.onceAt).getTime();return Number.isNaN(t)?{ok:!1,reason:`这一次的运行时刻不是有效时间。`}:{ok:!0,schedule:{kind:`once`,at:t}}}function Kw({task:e,workspaceId:t,catalog:n,agents:r,sendCommand:i,notify:a,onClose:o}){let[s,c]=(0,u.useState)(()=>Uw(e)),[l,d]=(0,u.useState)();(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let f=e=>{c(t=>({...t,...e})),d(void 0)};return(0,Re.createPortal)((0,F.jsx)(`div`,{className:`tool-overlay`,"data-sched-dialog-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&o()},children:(0,F.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`scheduled-dialog-title`,"data-sched-dialog":`1`,children:[(0,F.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,F.jsx)(`h2`,{className:`tool-dialog-title`,id:`scheduled-dialog-title`,children:e?`编辑定时任务`:`新建定时任务`}),(0,F.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-sched-dialog-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭定时任务编辑`,onClick:o,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`tool-dialog-body scheduled-form`,children:[(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`名称`}),(0,F.jsx)(`input`,{className:`scheduled-input`,"data-sched-field":`name`,value:s.name,placeholder:`留空则取提示词首句`,onChange:e=>f({name:e.target.value})})]}),(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`提示词`}),(0,F.jsx)(`textarea`,{className:`scheduled-textarea`,"data-sched-field":`prompt`,rows:5,value:s.prompt,placeholder:`到点时这段话会作为用户消息发给 agent,所以它要是一条完整、自包含的指令`,onChange:e=>f({prompt:e.target.value})})]}),(0,F.jsxs)(`div`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`周期`}),(0,F.jsx)(`div`,{className:`scheduled-kind-row`,role:`radiogroup`,"aria-label":`周期类型`,children:[[`interval`,`每隔 N 分钟`],[`daily`,`每天`],[`weekly`,`每周`],[`once`,`仅一次`]].map(([e,t])=>(0,F.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":s.kind===e,className:`scheduled-kind${s.kind===e?` scheduled-kind-active`:``}`,"data-sched-kind":e,onClick:()=>f({kind:e}),children:t},e))})]}),s.kind===`interval`&&(0,F.jsxs)(`label`,{className:`scheduled-field scheduled-field-inline`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`间隔`}),(0,F.jsx)(`input`,{className:`scheduled-input scheduled-input-narrow`,"data-sched-field":`everyMinutes`,inputMode:`numeric`,value:s.everyMinutes,onChange:e=>f({everyMinutes:e.target.value})}),(0,F.jsx)(`span`,{className:`scheduled-hint`,children:`分钟(1 – 10080)`})]}),(s.kind===`daily`||s.kind===`weekly`)&&(0,F.jsxs)(`label`,{className:`scheduled-field scheduled-field-inline`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`时刻`}),(0,F.jsx)(`input`,{className:`scheduled-input scheduled-input-narrow`,"data-sched-field":`time`,inputMode:`numeric`,placeholder:`09:00`,value:s.time,onChange:e=>f({time:e.target.value})}),(0,F.jsx)(`span`,{className:`scheduled-hint`,children:`服务器本地时间,每天/每周的这一天到点触发`})]}),s.kind===`weekly`&&(0,F.jsxs)(`div`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`星期`}),(0,F.jsx)(`div`,{className:`scheduled-weekdays`,children:Aw.map(({day:e,label:t})=>{let n=s.weekdays.includes(e);return(0,F.jsx)(`button`,{type:`button`,"aria-pressed":n,className:`scheduled-weekday${n?` scheduled-weekday-on`:``}`,"data-sched-weekday":e,onClick:()=>f({weekdays:n?s.weekdays.filter(t=>t!==e):[...s.weekdays,e]}),children:t},e)})})]}),s.kind===`once`&&(0,F.jsxs)(`label`,{className:`scheduled-field scheduled-field-inline`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`时刻`}),(0,F.jsx)(`input`,{className:`scheduled-input`,type:`datetime-local`,"data-sched-field":`onceAt`,value:s.onceAt,onChange:e=>f({onceAt:e.target.value})}),(0,F.jsx)(`span`,{className:`scheduled-hint`,children:`这一次运行之后就结束`})]}),(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`模型`}),(0,F.jsxs)(`select`,{className:`scheduled-input`,"data-sched-field":`model`,value:s.modelKey,onChange:e=>f({modelKey:e.target.value}),children:[(0,F.jsx)(`option`,{value:``,children:`跟随工作区默认`}),(n?.models??[]).map(e=>(0,F.jsxs)(`option`,{value:`${e.provider}/${e.modelId}`,children:[e.label,`(`,e.detail,`)`]},`${e.provider}/${e.modelId}`))]})]}),(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`Agent`}),(0,F.jsxs)(`select`,{className:`scheduled-input`,"data-sched-field":`agent`,value:s.agentId,onChange:e=>f({agentId:e.target.value}),children:[(0,F.jsx)(`option`,{value:``,children:`跟随工作区默认`}),(r?.agents??[]).map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))]})]}),l&&(0,F.jsx)(`p`,{className:`scheduled-error`,"data-sched-error":`1`,role:`alert`,children:l}),(0,F.jsxs)(`div`,{className:`scheduled-actions-row`,children:[(0,F.jsx)(`button`,{type:`button`,className:`scheduled-cancel`,onClick:o,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`scheduled-save`,"data-sched-save":`1`,onClick:()=>{let r=s.prompt.trim();if(!r){d(`定时任务需要一段提示词:到点时这段话会被当作用户消息发给 agent。`);return}if(!t){d(`先选一个工作区,再建定时任务。`);return}let c=Gw(s);if(!c.ok){d(c.reason);return}let l=n?.models.find(e=>`${e.provider}/${e.modelId}`===s.modelKey),u=l?{provider:l.provider,modelId:l.modelId,label:l.label}:null,f=s.agentId||null,p=s.name.trim()||void 0;i(e?{type:`scheduledTask.update`,id:e.id,name:p,prompt:r,schedule:c.schedule,model:u,agentId:f}:{type:`scheduledTask.create`,name:p,prompt:r,schedule:c.schedule,workspaceId:t,model:u,agentId:f})?(a(e?`已保存对「${s.name.trim()||e.name}」的修改。`:`定时任务已创建,到点会自动运行。`,`info`),o()):d(`连接已断开,没能保存。等重连后再试一次。`)},children:e?`保存修改`:`创建任务`})]})]})]})}),document.body)}function qw(e){return e.status===`open`&&(e.audience===`boss`||e.audience===void 0)}function Jw(e){return(e.escalations??[]).filter(qw)}function Yw(e){let t=e.filter(e=>Jw(e).length>0);return{projects:t.length,cases:t.reduce((e,t)=>e+Jw(t).length,0)}}function Xw(e,t=!1){return[`cancelled`,`failed`].includes(e.status??``)?!0:t}function Zw(e,t,n){let r=Xw(e,t),i=Jw(e).length>0;return n===`history`?r&&!i:!r||i}function Qw(e){return(e.reports??[]).filter(t=>!t.taskId&&[`progress`,`delivery`].includes(t.kind??``)&&(t.authorConversationId===e.ownerConversationId&&!!e.ownerConversationId||t.kind===`delivery`&&!t.authorConversationId))}function $w(e){return[...e.reports??[]].reverse().find(t=>t.kind===`delivery`&&!t.taskId&&(!t.authorConversationId||t.authorConversationId===e.ownerConversationId))}function eT(e){let t=Jw(e),n=[...Qw(e)].reverse().find(e=>e.kind===`progress`),r=$w(e),i=[`cancelled`,`failed`].includes(e.status),a=e.resources?.sessions?.find(t=>t.id===e.ownerConversationId),o=(e.resources?.activeWorkers??0)>0||[`running`,`waiting`,`awaiting_background`].includes(a?.status??``);return{label:e.status===`cancelled`?`已取消`:e.status===`failed`?`执行暂停`:t.length?`需要你决定`:o?`正在推进`:e.ownerConversationId?[`failed`,`stopped`].includes(a?.status??``)?`执行暂停`:r?`待继续`:`未交付`:`待启动`,summary:n?.progress?.trim()||n?.summary?.trim()||(i?`项目已结束,已有记录会保留。`:r?`可继续安排新任务或追加验证。`:`已交由负责人推进,进展和成果会在这里汇总。`),progress:n,delivery:r,decisions:t,ended:i,deliveryLabel:e.mode===`lightweight`?`自评交付`:`交付成果`}}var tT=/\.[A-Za-z][A-Za-z0-9]{0,9}$/,nT=new Set([`makefile`,`dockerfile`,`license`,`readme`,`changelog`]),rT=/^[A-Za-z]:/;function iT(e){let t=(e??``).trim();if(!t||/\s/.test(t)||t.includes(`://`)||t.startsWith(`/`)||t.startsWith(`\\`)||rT.test(t))return;let n=t.split(/[\\/]/);if(n.some(e=>e===``||e===`.`||e===`..`))return;let r=n[n.length-1];if(tT.test(r)||nT.has(r.toLowerCase()))return n.join(`/`)}function aT(e){return/\s/.test(e)||e.includes(`://`)||e.startsWith(`/`)||e.startsWith(`\\`)||rT.test(e)?!1:!e.split(/[\\/]/).some(e=>e===``||e===`.`||e===`..`)}function oT(e){let t=e.split(/[\\/]/);return t[t.length-1]||e}function sT(e,t){let n=iT(e);if(!n)return;let r=(t??``).trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``);if(!r)return n;if(aT(r))return n===r||n.startsWith(`${r}/`)?n:`${r}/${n}`}function cT(e,t){let n=(e??``).trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``);if(!n)return;let r=(t??``).trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``);if(!r)return n;if(n!==r&&n.startsWith(`${r}/`))return n.slice(r.length+1)}function lT(e){return[`cancelled`,`failed`].includes(e.status??``)}function uT(e,t){return e.filter(e=>Zw(e,e.ownerArchived===!0,t?`history`:`current`))}function dT(e){let[t,n]=(0,u.useState)(0),r=(0,u.useRef)(null),i=(0,u.useRef)(null);return(0,u.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=i.current;if(!e||!t)return;let a=getComputedStyle(e),o=Number.parseFloat(a.lineHeight)||Number.parseFloat(a.fontSize)*1.6||16,s=t.getBoundingClientRect().height;n(Math.max(1,Math.round(s/o)))};e();let t=typeof ResizeObserver==`function`?new ResizeObserver(()=>e()):null;return t&&(r.current&&t.observe(r.current),i.current&&t.observe(i.current)),window.addEventListener(`resize`,e),()=>{t?.disconnect(),window.removeEventListener(`resize`,e)}},[e]),{lines:t,visible:r,measured:i}}function fT({text:e,what:t}){let[n,r]=(0,u.useState)(!1),{lines:i,visible:a,measured:o}=dT(e),s=Math.max(0,i-2);return e?(0,F.jsxs)(`div`,{className:`project-prose-wrap`,children:[(0,F.jsx)(`p`,{className:`project-prose${n?` project-prose-open`:``}`,"data-prose-text":!0,ref:a,children:e}),(0,F.jsx)(`span`,{className:`project-prose-measure`,"aria-hidden":`true`,ref:o,children:e}),s>0?(0,F.jsx)(`button`,{type:`button`,className:`project-prose-expand`,"data-prose-expand":!0,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`收起${t}`:`展开完整${t}(还有 ${s} 行)`}):null]}):null}function pT({refs:e,baseCwd:t,cwd:n,onOpenFile:r}){return(0,F.jsx)(`ul`,{children:e.map((e,i)=>{let a=sT(e,t),o=a?cT(a,n):void 0;return(0,F.jsx)(`li`,{children:o&&r?(0,F.jsx)(`button`,{type:`button`,className:`project-evidence-path`,"data-team-evidence-file":o,onClick:()=>r({path:o,name:oT(o),text:null}),children:e}):e},i)})})}function mT(e){if(!e)return``;let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));return n<60?`刚刚`:n<3600?`${Math.floor(n/60)} 分钟前`:n<86400?`${Math.floor(n/3600)} 小时前`:`${Math.floor(n/86400)} 天前`}async function hT(e){let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(typeof t?.error==`string`?t.error:`请求失败(${e.status})`);return t}async function gT(e){let t=(await e.text().catch(()=>``)).trim();if(!t)return`报告打不开(${e.status})`;try{let n=JSON.parse(t);return n&&typeof n==`object`&&typeof n.error==`string`&&n.error.trim()?n.error.trim():`报告打不开(${e.status})`}catch{return t}}function _T(e,t){return`/api/projects/${encodeURIComponent(e)}/report?workspaceId=${encodeURIComponent(t??``)}`}function vT(e,t=60){let n=(e??``).replace(/\s+/g,` `).trim();return n?n.length<=t?n:`${n.slice(0,t-1)}…`:``}function yT(e){let t=(e.title??``).trim();if(t)return t;let n=(e.reason??``).trim();return n?n.match(/^[\s\S]*?[。!?!?]/)?.[0]?.trim()||n:`需要处理`}var bT={decision:0,delivery:1},xT=5;function ST(e,t){let n=Jw(e)[0],r={projectId:e.id,projectTitle:e.title,updatedAt:Date.parse(e.updatedAt??``)||0};if(n)return{...r,reminderId:`${e.id}:decision:${Jw(e).map(e=>e.id).join(`,`)}`,kind:`decision`,label:`要你决定`,detail:vT(n.title||n.reason||`需要你的决定`,lT(e)?36:60)+(lT(e)?`(项目已结束:记录后不会唤醒任何人)`:``),actionLabel:`去看看`,target:{kind:`exception`,escalationId:n.id}};let i=eT(e).delivery,a=Date.parse(i?.createdAt??``);return!i||!Number.isFinite(a)||t-a>864e5?null:{...r,updatedAt:a,reminderId:`${e.id}:delivery:${i.id}`,kind:`delivery`,label:`阶段交付`,detail:vT(i.progress||i.summary||`已提交阶段成果`),actionLabel:`查看交付`,target:{kind:`top`}}}function CT({text:e}){let[t,n]=(0,u.useState)(!1),{lines:r,visible:i,measured:a}=dT(e),o=Math.max(0,r-2);return e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`project-exception-reason-wrap`,children:[(0,F.jsx)(`p`,{className:`project-exception-reason${t?` project-exception-reason-open`:``}`,"data-project-exception-reason":!0,ref:i,children:e}),(0,F.jsx)(`span`,{className:`project-exception-reason-measure`,"aria-hidden":`true`,ref:a,children:e})]}),o>0&&(0,F.jsx)(`button`,{type:`button`,className:`project-exception-expand`,"data-project-exception-expand":!0,"aria-expanded":t,onClick:()=>n(e=>!e),children:t?`收起理由`:`展开完整理由(还有 ${o} 行)`})]}):null}function wT({item:e,project:t,busy:n,onResolve:r,onReturn:i}){let[a,o]=(0,u.useState)(``),s=lT(t);return(0,F.jsxs)(`li`,{className:`project-exception`,"data-project-exception":e.id,children:[(0,F.jsx)(`strong`,{className:`project-exception-title`,"data-project-exception-title":!0,children:yT(e)}),e.reason&&(0,F.jsx)(CT,{text:e.reason}),s&&(0,F.jsx)(`p`,{className:`project-exception-ended`,"data-project-exception-ended":!0,"data-project-exception-ended-note":!0,children:`项目已结束:你的处理意见会记进项目记录,但不会唤醒任何人。`}),(0,F.jsxs)(`label`,{className:`project-decision-label`,children:[`你的决定`,(0,F.jsx)(`textarea`,{"data-project-decision":e.id,"data-project-exception-decision":!0,value:a,onChange:e=>o(e.target.value),disabled:n})]}),(0,F.jsxs)(`div`,{className:`project-detail-actions`,children:[(0,F.jsx)(`button`,{type:`button`,"data-project-decision-submit":e.id,"data-project-exception-resolve":!0,disabled:n||!a.trim(),onClick:()=>r(a.trim()),children:s?`记录处理意见`:`记录决定并答复主会话`}),(0,F.jsx)(`button`,{type:`button`,"data-project-decision-return":e.id,"data-project-exception-return":!0,disabled:n||!a.trim(),onClick:()=>i(a.trim()),children:`退回补充`})]})]})}function TT({project:e,workspaceId:t,notify:n,onOpenSession:r,onOpenFile:i,cwd:a,onChanged:o}){let s=eT(e),[c,l]=(0,u.useState)(!1),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(``),y=(0,u.useRef)(``);(0,u.useEffect)(()=>()=>{y.current&&URL.revokeObjectURL(y.current)},[]);let b=async(r,i,a={})=>{if(t&&!c){l(!0),f(``);try{await Ne(`/api/projects/${encodeURIComponent(e.id)}/${r}`,{method:i,headers:{"content-type":`application/json`},body:JSON.stringify({...a,workspaceId:t})}).then(hT),await o?.(),n?.(`已记录并交给负责人`,`info`)}catch(e){f(e instanceof Error?e.message:`操作失败`)}finally{l(!1)}}},x=async()=>{if(t&&!p){m(!0),g(``);try{let n=await Ne(_T(e.id,t));if(!n.ok){g(await gT(n));return}let r=await n.text();y.current&&URL.revokeObjectURL(y.current);let i=URL.createObjectURL(new Blob([r],{type:`text/plain;charset=utf-8`}));y.current=i,v(i),window.open(i,`_blank`,`noopener`)}catch(e){g(e instanceof Error?e.message:`报告打不开`)}finally{m(!1)}}},S=e.resources?.usage,C=s.delivery?.evidenceRefs??[],w=e.resources?.sessions?.find(t=>t.id===e.ownerConversationId),T=!e.ownerConversationId||!!(w&&[`failed`,`stopped`].includes(w.status??``)&&!e.resources?.activeWorkers);return(0,F.jsxs)(`div`,{className:`project-detail project-overview`,"data-project-detail":e.id,children:[e.objective&&(0,F.jsxs)(`div`,{className:`project-goal`,children:[(0,F.jsx)(`span`,{children:`项目目标`}),(0,F.jsx)(`p`,{className:`project-detail-objective`,children:e.objective})]}),(0,F.jsxs)(`section`,{className:`project-section`,"data-project-owner-summary":!0,children:[(0,F.jsx)(`h3`,{children:`当前进展`}),(0,F.jsx)(fT,{text:s.summary,what:`进展`}),e.updatedAt&&(0,F.jsxs)(`p`,{className:`project-overview-time`,children:[mT(e.updatedAt),`更新`]})]}),s.delivery&&(0,F.jsxs)(`section`,{className:`project-section`,"data-project-stage-delivery":!0,children:[(0,F.jsx)(`h3`,{children:s.deliveryLabel}),(0,F.jsx)(fT,{text:s.delivery.progress||s.delivery.summary||`已提交阶段成果`,what:`交付`}),C.length?(0,F.jsx)(pT,{refs:C,baseCwd:e.resources?.ownerCwd??w?.cwd,cwd:a,onOpenFile:i}):(0,F.jsx)(`p`,{"data-project-no-evidence":!0,children:`未附可核对的交付证据。`})]}),s.decisions.length>0&&(0,F.jsxs)(`section`,{className:`project-section`,"data-project-exception-section":!0,children:[(0,F.jsx)(`h3`,{"data-project-exception-heading":!0,children:`需要你决定`}),(0,F.jsx)(`ul`,{className:`project-exception-list`,children:s.decisions.map(t=>(0,F.jsx)(wT,{item:t,project:e,busy:c,onResolve:e=>void b(`escalations/${encodeURIComponent(t.id)}`,`PATCH`,{decision:e,status:`resolved`}),onReturn:e=>void b(`escalations/${encodeURIComponent(t.id)}`,`PATCH`,{decision:e,status:`returned`})},t.id))})]}),d&&(0,F.jsx)(`p`,{className:`project-error`,role:`alert`,children:d}),(0,F.jsxs)(`div`,{className:`project-detail-actions project-overview-actions`,children:[w&&r&&(0,F.jsx)(`button`,{type:`button`,className:T&&!s.ended?``:`project-primary-action`,"data-project-open-owner":!0,onClick:()=>r(w.id),children:`查看负责人会话`}),!s.ended&&T&&(0,F.jsx)(`button`,{type:`button`,className:`project-primary-action`,disabled:c,"data-project-resume":!0,onClick:()=>void b(`start`,`POST`),children:`让负责人继续`}),!s.ended&&(0,F.jsx)(`button`,{type:`button`,className:`project-stop-action`,disabled:c,"data-project-stop":!0,onClick:()=>void b(``,`PATCH`,{status:`cancelled`}),children:`停止项目`}),(0,F.jsx)(`button`,{type:`button`,disabled:p,"data-project-report":e.id,onClick:()=>void x(),children:p?`正在读取…`:`导出记录`})]}),h&&(0,F.jsx)(`p`,{className:`project-error`,role:`alert`,"data-project-report-error":!0,children:h}),_&&(0,F.jsx)(`a`,{href:_,target:`_blank`,rel:`noopener noreferrer`,"data-project-report-link":!0,children:`打开已读取的记录`}),e.resources&&(0,F.jsxs)(`details`,{className:`project-section project-secondary`,"data-project-usage":!0,children:[(0,F.jsx)(`summary`,{children:`查看用量`}),(0,F.jsxs)(`div`,{"data-project-budget":e.id,children:[(0,F.jsxs)(`p`,{"data-project-budget-used":e.id,children:[`等效 Token `,e.resources.usageKnown?e.resources.tokens.toLocaleString():`未知`]}),S&&(0,F.jsxs)(`p`,{"data-project-budget-raw":e.id,children:[`原始口径 `,(e.resources.rawTokens??S.input+S.output+S.cacheRead+S.cacheWrite).toLocaleString(),`;输入 `,S.input.toLocaleString(),`;输出 `,S.output.toLocaleString(),`;缓存写入 `,S.cacheWrite.toLocaleString(),`;缓存读取 `,S.cacheRead.toLocaleString()]}),(0,F.jsx)(`p`,{"data-project-budget-basis":`1`,children:`等效 Token = 输入 + 输出 + 缓存写入×1.25 + 缓存读取×0.1`})]})]})]})}function ET({project:e,workspaceId:t,notify:n,onOpenSession:r,onOpenFile:i,cwd:a,onChanged:o,onClose:s}){let c=(0,u.useId)(),l=(0,u.useRef)(null),d=(0,u.useRef)(s);return d.current=s,(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),d.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,u.useEffect)(()=>{l.current?.focus({preventScroll:!0})},[e.id]),(0,Re.createPortal)((0,F.jsx)(`div`,{className:`tool-overlay project-dialog-overlay`,"data-project-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&s()},children:(0,F.jsxs)(`div`,{ref:l,className:`tool-dialog project-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":c,"data-project-dialog":e.id,tabIndex:-1,onKeyDown:e=>{if(e.key!==`Tab`)return;let t=l.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), a[href], select:not([disabled]), input:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex='-1'])`)).filter(e=>e.offsetParent!==null||e.getClientRects().length>0);if(n.length===0)return;let r=n[0],i=n[n.length-1];e.shiftKey?(document.activeElement===r||document.activeElement===t)&&(e.preventDefault(),i.focus()):document.activeElement===i&&(e.preventDefault(),r.focus())},children:[(0,F.jsxs)(`div`,{className:`tool-dialog-head project-dialog-head`,children:[(0,F.jsxs)(`div`,{className:`project-dialog-title-group`,children:[(0,F.jsx)(`h2`,{className:`tool-dialog-title project-dialog-title`,id:c,children:e.title}),(0,F.jsx)(`span`,{className:`project-detail-flags`,children:(0,F.jsx)(`span`,{className:`project-status project-status-${e.status}`,children:eT(e).label})})]}),(0,F.jsx)(`button`,{type:`button`,className:`tool-dialog-close project-dialog-close`,"data-project-dialog-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭 ${e.title}`,onClick:s,children:`✕`})]}),(0,F.jsx)(`div`,{className:`tool-dialog-body project-dialog-body`,children:(0,F.jsx)(TT,{project:e,workspaceId:t,notify:n,onOpenSession:r?e=>{s(),r(e)}:void 0,onOpenFile:i?e=>{s(),i(e)}:void 0,cwd:a,onChanged:o})})]})}),document.body)}function DT({workspaceId:e,notify:t,onOpenSession:n,onOpenFile:r,cwd:i}){let[a,o]=(0,u.useState)([]),[s,c]=(0,u.useState)(!1),l=(0,u.useMemo)(()=>uT(a,s),[a,s]),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(null),y=(0,u.useRef)(null),[b,x]=(0,u.useState)([]),S=(0,u.useCallback)(async t=>{if(!e)o([]);else{f(!0),g(``);try{let n=await Ne(`/api/projects?workspaceId=${encodeURIComponent(e)}${s?`&view=history`:``}`,{signal:t}).then(hT),r=Array.isArray(n)?n:Array.isArray(n.projects)?n.projects:[];o(r)}catch(e){e.name!==`AbortError`&&g(e instanceof Error?e.message:`项目列表加载失败`)}finally{t?.aborted||(f(!1),m(!0))}}},[e,s]);(0,u.useEffect)(()=>{let e=new AbortController;return S(e.signal),()=>e.abort()},[S]),(0,u.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>void S(),5e3);return()=>window.clearInterval(t)},[S,e]);let C=(0,u.useMemo)(()=>{let e=Date.now();return l.map(t=>ST(t,e)).filter(e=>!!e).filter(e=>!b.includes(e.reminderId)).sort((e,t)=>bT[e.kind]-bT[t.kind]||t.updatedAt-e.updatedAt)},[l,b]),w=(0,u.useMemo)(()=>l.flatMap(e=>Jw(e).map(t=>({project:e,decision:t}))),[l]),T=(0,u.useMemo)(()=>Yw(l).projects,[l]),E=(0,u.useMemo)(()=>C.slice(0,xT),[C]),D=C.length-E.length,[O,k]=(0,u.useState)(!1),A=O?C:E,[j,ee]=(0,u.useState)(!1),M=(0,u.useMemo)(()=>{let e=new Set;for(let t of C)e.add(t.projectId);return e},[l,C]),te=(0,u.useMemo)(()=>j?l.filter(e=>M.has(e.id)):l,[j,l,M]),N=(0,u.useMemo)(()=>_?l.find(e=>e.id===_)??null:null,[l,_]),ne=(0,u.useRef)(null),[re,ie]=(0,u.useState)(0),ae=(0,u.useCallback)((e,t,n)=>{y.current=t??document.querySelector(`[data-project-row="${e}"]`),v(e),n&&(ne.current={projectId:e,target:n},ie(e=>e+1))},[]),oe=(0,u.useCallback)(()=>{let e=_,t=y.current;y.current=null,v(null),window.requestAnimationFrame(()=>{(t?.isConnected?t:e?document.querySelector(`[data-project-row="${e}"]`):null)?.focus()})},[_]),se=e=>{let t=document.querySelector(`[data-project-row="${e.projectId}"]`);ae(e.projectId,t,e.target)};return(0,u.useEffect)(()=>{if(!re)return;let e=ne.current;if(ne.current=null,!e)return;let t=document.querySelector(`[data-project-detail="${e.projectId}"]`);if(!t)return;let n=null;if(e.target.kind===`exception`){let e=t.querySelector(`[data-project-exception-section]`);e&&(e.open=!0,n=e.querySelector(`[data-project-exception-heading]`)??e)}let r=n??t,i=window.requestAnimationFrame(()=>{r.scrollIntoView({block:e.target.kind===`top`?`start`:`center`,inline:`nearest`})});return()=>window.cancelAnimationFrame(i)},[re,N?.id]),(0,F.jsxs)(`section`,{className:`project-panel`,"data-project-panel":`1`,children:[(0,F.jsx)(`div`,{className:`rail-section-head project-panel-head`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`rail-section-title`,children:`项目进展`}),(0,F.jsx)(`p`,{className:`project-panel-subtitle`,children:`查看负责人汇总的进展、成果和需要你决定的事。`})]})}),w.length>0&&(0,F.jsxs)(`div`,{className:`warning`,role:`status`,"data-project-team-notice":`1`,"data-project-team-notice-count":T,children:[(0,F.jsxs)(`span`,{"data-project-team-notice-text":!0,children:[T===1?`有 1 个项目的事需要你决定`:`有 ${T} 个项目的事需要你决定`,`:`,vT(yT(w[0].decision),48)]}),(0,F.jsx)(`button`,{type:`button`,"data-project-team-notice-action":`1`,onClick:()=>ae(w[0].project.id,void 0,{kind:`exception`,escalationId:w[0].decision.id}),children:`去看看`})]}),C.length>0&&(0,F.jsxs)(`div`,{className:`project-pending`,"data-project-pending":`1`,"data-project-pending-count":C.length,children:[A.map(e=>(0,F.jsxs)(`div`,{className:`project-pending-item`,"data-project-pending-item":e.projectId,"data-project-pending-kind":e.kind,children:[(0,F.jsxs)(`div`,{className:`project-pending-row`,children:[(0,F.jsx)(`span`,{className:`project-pending-kind project-pending-kind-${e.kind}`,"data-project-pending-label":e.kind,children:e.label}),(0,F.jsx)(`span`,{className:`project-pending-title`,"data-project-pending-title":e.projectId,children:e.projectTitle}),(0,F.jsx)(`button`,{type:`button`,className:`project-pending-action`,"data-project-pending-action":e.projectId,onClick:()=>se(e),children:e.actionLabel}),(0,F.jsx)(`button`,{type:`button`,className:`project-pending-close`,"data-project-pending-dismiss":e.projectId,"aria-label":`关闭「${e.projectTitle}」的这条提醒`,title:`关闭这条提醒(不改变项目状态)`,onClick:()=>x(t=>[...t,e.reminderId]),children:`×`})]}),(0,F.jsx)(`p`,{className:`project-pending-detail`,"data-project-pending-detail":e.projectId,children:e.detail})]},`${e.projectId}:${e.kind}`)),D>0&&(0,F.jsx)(`button`,{type:`button`,className:`project-pending-more`,"data-project-pending-more":`1`,"aria-expanded":O,onClick:()=>k(e=>!e),children:O?`收起`:`还有 ${D} 个`})]}),(0,F.jsxs)(`label`,{className:`project-pending-filter`,"data-project-pending-only-label":`1`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-project-pending-only":`1`,checked:j,onChange:e=>ee(e.target.checked)}),(0,F.jsx)(`span`,{className:`project-pending-filter-name`,children:`只看提醒`}),(0,F.jsx)(`span`,{className:`project-pending-filter-state`,"data-project-pending-only-state":j?`on`:`off`,children:j?`已开启`:`已关闭`})]}),(0,F.jsxs)(`label`,{className:`project-pending-filter`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-project-history":`1`,checked:s,onChange:e=>{c(e.target.checked),ee(!1),v(null)}}),(0,F.jsx)(`span`,{className:`project-pending-filter-name`,children:`查看历史项目`})]}),h&&(0,F.jsx)(`p`,{className:`project-error`,role:`alert`,"data-project-error":`1`,children:h}),e?d&&!p&&l.length===0?(0,F.jsx)(`p`,{className:`rail-empty`,children:`正在加载项目…`}):l.length===0?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`rail-empty`,"data-project-empty":`1`,children:s?`没有已结束的项目。`:`当前没有进行中的项目。`}),(0,F.jsx)(`p`,{className:`project-empty-hint`,"data-project-empty-hint":`1`,children:`在对话里告诉 AI 你要完成什么,负责人会推进工作并向你交付。`})]}):te.length===0?(0,F.jsx)(`p`,{className:`rail-empty`,"data-project-pending-empty":`1`,children:`没有需要关注的项目。`}):(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(`div`,{className:`project-list`,"data-project-count":te.length,children:te.map(e=>{let t=N?.id===e.id;return(0,F.jsxs)(`button`,{type:`button`,className:`project-row`,"data-project-row":e.id,"data-project-block":e.id,"data-project-summary":e.id,"aria-haspopup":`dialog`,"aria-expanded":t,onClick:t=>ae(e.id,t.currentTarget),children:[(0,F.jsx)(`span`,{className:`project-list-title`,title:e.title,children:e.title}),(0,F.jsx)(`span`,{className:`project-status project-status-${e.status}`,children:eT(e).label}),(0,F.jsx)(`span`,{className:`project-row-summary`,children:eT(e).summary}),e.updatedAt&&(0,F.jsxs)(`span`,{className:`project-row-updated`,children:[mT(e.updatedAt),`更新`]})]},e.id)})})}):(0,F.jsx)(`p`,{className:`rail-empty`,children:`请先选择工作区。`}),N?(0,F.jsx)(ET,{project:N,workspaceId:e,notify:t,onOpenSession:n,onOpenFile:r,cwd:i,onChanged:()=>S(),onClose:oe}):null]})}var OT=()=>({text:``,mentions:[],files:[]}),kT=(e,t)=>`super-pi.group-draft.v1:${JSON.stringify([e,t])}`;function AT(e,t){try{let n=JSON.parse(localStorage.getItem(kT(e,t))??`null`);return!n||typeof n.text!=`string`?OT():{text:n.text.slice(0,32e3),replyTo:typeof n.replyTo==`string`?n.replyTo:void 0,mentions:Array.isArray(n.mentions)?n.mentions.filter(e=>typeof e?.memberId==`string`&&typeof e.text==`string`):[],files:Array.isArray(n.files)?n.files.filter(e=>typeof e?.path==`string`&&typeof e.text==`string`):[]}}catch{return OT()}}function jT(e,t,n){try{let r=kT(e,t);!n.text&&!n.replyTo?localStorage.removeItem(r):localStorage.setItem(r,JSON.stringify(n))}catch{}}function MT(e,t,n){AT(e,t).text===n&&jT(e,t,OT())}var NT=`super-pi.group-presets.v1`;function PT(){try{let e=JSON.parse(localStorage.getItem(`super-pi.group-presets.v1`)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e?.id==`string`&&typeof e.name==`string`&&Array.isArray(e.memberIds)&&e.memberIds.every(e=>typeof e==`string`)&&e.memberModels&&typeof e.memberModels==`object`&&!Array.isArray(e.memberModels)&&typeof e.moderator?.prompt==`string`).slice(0,100):[]}catch{return[]}}var FT=e=>JSON.stringify([e.provider,e.modelId]);function IT({value:e,models:t,onChange:n,label:r,inheritLabel:i}){let[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)(``),l=(0,u.useRef)(null),d=t.find(t=>FT(t)===e),f=t.filter(e=>(!a||e.provider===a)&&`${e.label} ${e.modelId}`.toLocaleLowerCase().includes(s.toLocaleLowerCase())),p=e=>{n(e),l.current&&(l.current.open=!1)};return(0,F.jsxs)(`details`,{className:`group-model-picker`,ref:l,onKeyDown:e=>{e.key===`Escape`&&l.current&&(l.current.open=!1,l.current.querySelector(`summary`)?.focus())},children:[(0,F.jsxs)(`summary`,{"aria-label":r,title:d?`${d.provider} / ${d.modelId}`:void 0,children:[(0,F.jsx)(`span`,{children:e?d?.label??`当前模型不可用,请重新选择`:i??`继承 Agent / 工作区模型`}),(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`⌄`})]}),(0,F.jsxs)(`div`,{className:`group-model-popup`,children:[(0,F.jsxs)(`select`,{"aria-label":`${r} Provider`,value:a,onChange:e=>o(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:`全部 Provider`}),[...new Set(t.map(e=>e.provider))].sort().map(e=>(0,F.jsx)(`option`,{children:e},e))]}),(0,F.jsx)(`input`,{"aria-label":`${r} 筛选`,placeholder:`筛选模型…`,value:s,onChange:e=>c(e.target.value)}),(0,F.jsxs)(`div`,{className:`group-model-options`,role:`group`,"aria-label":r,children:[(0,F.jsx)(`button`,{type:`button`,"aria-pressed":!e,onClick:()=>p(``),children:i??`继承默认模型`}),f.map(t=>(0,F.jsxs)(`button`,{type:`button`,"aria-pressed":e===FT(t),onClick:()=>p(FT(t)),children:[(0,F.jsx)(`span`,{children:t.label}),(0,F.jsx)(`small`,{children:t.provider})]},FT(t))),!f.length&&(0,F.jsx)(`p`,{children:`没有匹配的模型`})]})]})]})}var LT={division:`分工`,prompt:`Prompt`,tools:`工具`,mechanism:`协作机制`,execution:`执行策略`};function RT({value:e}){if(/(?:^|\n)\s*(?:[-*+] |\d+[.)] |#{1,4} |```)/.test(e))return(0,F.jsx)(`div`,{className:`rsi-prose`,children:(0,F.jsx)(ef,{source:e,handoffs:!1})});let t=e.split(/\n+/).map(e=>e.trim()).filter(Boolean),n=t.length>1?t:e.length>100?e.split(/(?<=[。;!?])\s*/u).filter(Boolean):t;return(0,F.jsx)(`ul`,{className:`rsi-points`,children:n.map((e,t)=>(0,F.jsx)(`li`,{children:(0,F.jsx)(tf,{source:e})},t))})}function zT({state:e,models:t,archived:n,onAction:r,onClose:i,extra:a}){let[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(e?.enabled!==!1),[d,f]=(0,u.useState)(e?.automaticImprovements!==!1),[p,m]=(0,u.useState)(e?.prompt??``),[h,g]=(0,u.useState)(e?.model?FT(e.model):``),[_,v]=(0,u.useState)({}),[y,b]=(0,u.useState)(!1),[x,S]=(0,u.useState)(``),C=e?.reports??[],w=C.find(e=>e.id===o)??C.at(-1),T=async e=>{if(!y){b(!0),S(``);try{await r(e)}catch(e){S(e instanceof Error?e.message:`RSI 操作失败`)}finally{b(!1)}}};return(0,F.jsxs)(`aside`,{className:`group-rsi-panel`,"data-group-rsi-panel":!0,"aria-label":`RSI 观察与建议`,children:[(0,F.jsxs)(`header`,{children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{children:`RSI 观察与建议`}),(0,F.jsx)(`span`,{role:`status`,children:e?.enabled===!1?`已暂停`:e?.status===`running`?`后台观察中`:e?.status===`failed`?`观察失败`:e?.pending?`有新过程,等待更新观察`:w?`观察已更新`:`等待任务产生可观察的过程`})]}),(0,F.jsx)(`button`,{type:`button`,"aria-label":`关闭 RSI 面板`,onClick:i,children:`关闭`})]}),(0,F.jsxs)(`div`,{className:`group-rsi-body`,children:[(0,F.jsx)(`p`,{className:`rsi-intro`,children:`观察任务效率和交付质量。通用缺口归平台,企业专用能力在用户侧开发、验证并复用。`}),!n&&(0,F.jsx)(`button`,{type:`button`,"data-rsi-refresh":!0,disabled:y||e?.status===`running`||e?.enabled===!1,onClick:()=>void T({action:`rsi.refresh`}),children:`更新观察`}),(x||e?.error)&&(0,F.jsx)(`p`,{role:`alert`,children:x||e?.error}),C.length>0&&(0,F.jsxs)(`label`,{children:[`观察记录`,(0,F.jsx)(`select`,{"aria-label":`RSI 观察记录`,value:w?.id,onChange:e=>s(e.target.value),children:[...C].reverse().map(e=>(0,F.jsx)(`option`,{value:e.id,children:new Date(e.createdAt).toLocaleString()},e.id))})]}),w&&(0,F.jsxs)(`section`,{"data-rsi-report":w.id,children:[(0,F.jsxs)(`div`,{className:`rsi-report-meta`,children:[(0,F.jsxs)(`span`,{children:[w.observedMessages,` / `,w.totalMessages,` 条发言`]}),(0,F.jsxs)(`span`,{children:[w.findings.length,` 条建议`]}),w.model&&(0,F.jsx)(`span`,{title:`观察模型`,children:w.model.label||w.model.modelId})]}),w.compressed&&(0,F.jsx)(`p`,{className:`group-rsi-coverage`,children:`部分历史或执行摘要已压缩;下列结论仅基于可见过程。`}),!!w.artifactReads?.length&&(0,F.jsxs)(`details`,{className:`rsi-detail`,children:[(0,F.jsxs)(`summary`,{children:[`本轮实际读取的产物证据 · `,w.artifactReads.length]}),(0,F.jsx)(`ul`,{children:w.artifactReads.map((e,t)=>(0,F.jsx)(`li`,{children:e},t))})]}),!!w.runEvidence?.length&&(0,F.jsxs)(`details`,{className:`rsi-detail`,children:[(0,F.jsx)(`summary`,{children:`实际运行用时(含工具及等人)`}),(0,F.jsx)(`ul`,{children:w.runEvidence.map((e,t)=>(0,F.jsxs)(`li`,{children:[Math.round(e.elapsedMs/1e3),` 秒 · `,new Date(e.finishedAt).toLocaleTimeString()]},t))}),(0,F.jsx)(`p`,{children:`这是完整运行用时,不能直接当作模型思考耗时。`})]}),(0,F.jsxs)(`section`,{className:`rsi-overview`,children:[(0,F.jsx)(`h4`,{children:`本轮结论`}),(0,F.jsx)(RT,{value:w.summary})]}),w.retrospective&&(0,F.jsxs)(`details`,{className:`rsi-retrospective`,children:[(0,F.jsx)(`summary`,{children:`前次建议的后续观察`}),(0,F.jsx)(RT,{value:w.retrospective})]}),!w.findings.length&&(0,F.jsx)(`p`,{children:`当前证据未形成具体改进建议。`}),[...w.findings].sort((e,t)=>({high:0,medium:1,low:2})[e.priority]-{high:0,medium:1,low:2}[t.priority]).map((e,t)=>(0,F.jsxs)(`article`,{className:`group-rsi-finding`,"data-rsi-finding":e.id,children:[(0,F.jsxs)(`header`,{className:`rsi-finding-heading`,children:[(0,F.jsxs)(`h4`,{children:[(0,F.jsx)(`span`,{className:`rsi-finding-number`,children:String(t+1).padStart(2,`0`)}),LT[e.category]]}),(0,F.jsx)(`span`,{className:`rsi-priority`,"data-priority":e.priority,children:{high:`优先处理`,medium:`建议改进`,low:`可选优化`}[e.priority]})]}),(0,F.jsxs)(`p`,{className:`rsi-ownership`,"data-rsi-ownership":e.ownership??`unclassified`,children:[(0,F.jsx)(`strong`,{children:{platform:`平台通用能力`,user:`用户专用能力`,mixed:`通用底座与专用适配需拆分`,unclassified:`归属待澄清`}[e.ownership??`unclassified`]}),e.ownershipReason&&` · ${e.ownershipReason}`]}),(0,F.jsxs)(`section`,{className:`rsi-finding-observation`,children:[(0,F.jsx)(`h5`,{children:`观察到的问题`}),(0,F.jsx)(RT,{value:e.observation})]}),(0,F.jsxs)(`section`,{className:`rsi-recommendation`,children:[(0,F.jsx)(`h5`,{children:`改进建议`}),(0,F.jsx)(RT,{value:e.recommendation})]}),(0,F.jsxs)(`details`,{className:`rsi-detail`,children:[(0,F.jsxs)(`summary`,{children:[`证据 · `,e.evidence.length,` 处关联发言`]}),e.evidence.map((e,t)=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>{[...document.querySelectorAll(`[data-group-post-id]`)].find(t=>t.dataset.groupPostId===e.messageId)?.scrollIntoView({block:`center`,behavior:`smooth`})},children:`定位发言`}),e.quote&&(0,F.jsx)(`blockquote`,{children:e.quote})]},t))]}),(0,F.jsxs)(`details`,{className:`rsi-detail`,children:[(0,F.jsx)(`summary`,{children:`适用范围与验证办法`}),(0,F.jsx)(`h5`,{children:`适用范围`}),(0,F.jsx)(RT,{value:e.applicability}),(0,F.jsx)(`h5`,{children:`验证办法`}),(0,F.jsx)(RT,{value:e.verification})]}),e.disposition&&(0,F.jsxs)(`p`,{role:`status`,children:[e.disposition===`accepted`?`已标记采纳 · 待后续过程验证`:`已标记不适用`,e.feedback&&` · ${e.feedback}`]}),!n&&(0,F.jsxs)(`div`,{className:`group-rsi-feedback`,children:[e.ownership===`user`&&e.capability&&(0,F.jsxs)(`button`,{type:`button`,disabled:y,"data-rsi-improve":e.id,onClick:()=>void T({action:`rsi.improve`,reportId:w.id,findingId:e.id}),children:[`开发并验证 · `,e.capability.name]}),(0,F.jsx)(`textarea`,{"aria-label":`RSI 建议反馈`,placeholder:`说明适用差异或实际效果,供下一轮观察参考`,value:_[e.id]??e.feedback??``,onChange:t=>v(n=>({...n,[e.id]:t.target.value})),maxLength:2e3}),(0,F.jsx)(`div`,{children:[`accepted`,`dismissed`].map(t=>(0,F.jsx)(`button`,{type:`button`,disabled:y,"aria-pressed":e.disposition===t,onClick:()=>void T({action:`rsi.feedback`,reportId:w.id,findingId:e.id,disposition:t,feedback:_[e.id]??e.feedback??``}),children:t===`accepted`?`标记采纳`:`不适用`},t))})]})]},e.id))]}),a,!n&&(0,F.jsxs)(`details`,{className:`group-rsi-settings`,children:[(0,F.jsx)(`summary`,{children:`RSI 设置`}),(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked)}),`自动观察`]}),(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),`自动开发符合条件的用户专用能力`]}),(0,F.jsx)(`p`,{children:`观察会产生独立模型请求与费用,可随时暂停。每个来源至少间隔一分钟,每次最多 90 秒、12 次只读检查;同一工作区同时最多一个能力开发,预算十分钟。未指定模型时跟随来源会话、主持人或工作区。`}),(0,F.jsx)(IT,{value:h,models:t,label:`RSI 模型`,inheritLabel:`跟随主持人 / 工作区模型`,onChange:g}),(0,F.jsxs)(`label`,{children:[`补充观察要求`,(0,F.jsx)(`textarea`,{"aria-label":`RSI 补充要求`,value:p,onChange:e=>m(e.target.value),maxLength:8e3})]}),(0,F.jsx)(`button`,{type:`button`,"data-rsi-save":!0,disabled:y,onClick:()=>void T({action:`rsi.configure`,enabled:c,automaticImprovements:d,model:t.find(e=>FT(e)===h)??null,prompt:p}),children:`保存 RSI 设置`})]})]})]})}function BT({source:e,models:t,archived:n=!1,onClose:r}){let[i,a]=(0,u.useState)(),[o,s]=(0,u.useState)(``),c=`/api/rsi?${new URLSearchParams({kind:e.kind,workspaceId:e.workspaceId,id:e.id})}`;(0,u.useEffect)(()=>{let e=!1,t=new AbortController,n=async()=>{try{let n=await Ne(c,{signal:t.signal}),r=await n.json();if(!n.ok)throw Error(r.error??`RSI 暂时不可用。`);e||(a(r),s(``))}catch(t){e||s(t instanceof Error?t.message:String(t))}};n();let r=setInterval(()=>void n(),3e3);return()=>{e=!0,t.abort(),clearInterval(r)}},[c]);let l=async e=>{let t=await Ne(c,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw Error(n.error??`RSI 操作失败。`);a(n)};return i?(0,F.jsx)(zT,{state:i?.state,models:t,archived:n,onClose:r,onAction:l,extra:(0,F.jsxs)(`section`,{className:`rsi-work`,"data-rsi-work":!0,children:[o&&(0,F.jsx)(`p`,{role:`alert`,children:o}),(0,F.jsx)(`h4`,{children:`能力改进`}),!i?.improvements.length&&(0,F.jsx)(`p`,{children:`符合条件的用户侧建议会在后台开发;平台建议保留在报告中。`}),i?.improvements.map(e=>(0,F.jsxs)(`article`,{"data-rsi-job":e.id,children:[(0,F.jsxs)(`h5`,{children:[e.name,` · `,{queued:`等待开发`,running:`开发与验证中`,available:`已注册可用 · 收益待验证`,failed:`开发未通过`,interrupted:`已中断`,cancelled:`已取消`}[e.status]]}),(0,F.jsxs)(`p`,{children:[e.slug,e.version?` · v${e.version}`:``]}),e.error&&(0,F.jsx)(`p`,{role:`alert`,children:e.error}),e.conversationId&&(0,F.jsx)(`button`,{type:`button`,"data-rsi-open-work":e.id,onClick:()=>{window.dispatchEvent(new CustomEvent(`super-pi-open-rsi-work`,{detail:e.conversationId})),r()},children:`查看开发过程`}),[`running`,`queued`].includes(e.status)&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>void l({action:`rsi.cancel`,jobId:e.id}).catch(e=>s(String(e))),children:`取消改进`})]},e.id)),!!i?.usage.length&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`h4`,{children:`实际复用记录`}),(0,F.jsx)(`ul`,{children:i.usage.slice(-8).reverse().map((e,t)=>(0,F.jsxs)(`li`,{children:[e.slug,` v`,e.version,` · `,e.status,` · `,e.durationMs,` ms`]},t))}),(0,F.jsx)(`p`,{children:`调用成功仅表示执行成功,不能单独证明整个任务更快或质量更好。`})]})]})},c):(0,F.jsxs)(`aside`,{className:`group-rsi-panel`,"data-group-rsi-panel":!0,children:[(0,F.jsxs)(`header`,{children:[(0,F.jsx)(`h3`,{children:`RSI 观察与建议`}),(0,F.jsx)(`button`,{type:`button`,onClick:r,children:`关闭`})]}),(0,F.jsx)(`div`,{className:`group-rsi-body`,children:(0,F.jsx)(`p`,{role:o?`alert`:`status`,children:o||`正在读取观察与能力改进记录…`})})]})}function VT({id:e,workspaceId:t,models:n}){let[r,i]=(0,u.useState)(!1),a=(0,u.useRef)(null);return(0,u.useEffect)(()=>i(!1),[e]),(0,u.useEffect)(()=>{if(!r)return;let e=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{ref:a,type:`button`,"data-session-rsi":e,"aria-expanded":r,title:`RSI:任务效率与能力改进`,onClick:()=>i(e=>!e),children:`RSI`}),r&&(0,Re.createPortal)((0,F.jsx)(`div`,{className:`session-rsi-dock`,role:`region`,"aria-label":`会话 RSI`,children:(0,F.jsx)(BT,{source:{kind:`session`,id:e,workspaceId:t},models:n,onClose:()=>{i(!1),a.current?.focus()}})}),a.current?.closest(`.workbench-main-panes`)??document.body)]})}var HT={queued:`排队中`,running:`进行中`,completed:`已完成`,failed:`失败`,cancelled:`已停止`,interrupted:`已中断`},UT=new Map([[`read`,`读取文件`],[`write`,`写入文件`],[`edit`,`编辑文件`],[`grep`,`搜索内容`],[`find`,`查找文件`],[`ls`,`列出目录`],[`bash`,`运行命令`],[`powershell`,`运行命令`]]),WT=new Map([[`solution-designer`,`案`],[`code-designer`,`码`],[`code-auditor`,`审`],[`document-organizer`,`文`]]),GT=e=>e.status===`queued`||e.status===`running`,KT=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),qT=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function JT(e,t=!1){let n=Date.parse(e);return Number.isFinite(n)?(t?qT:KT).format(n):``}function YT({name:e,memberId:t,busy:n}){let r=e.trim(),i=t&&WT.get(t)||(/\p{Script=Han}/u.test(r)?Array.from(r).slice(-2).join(``):r.split(/\s+/u).filter(Boolean).map(e=>Array.from(e)[0]).slice(0,2).join(``).toUpperCase())||`?`,a=Wn.findIndex(e=>e===t),o=a>=0?a:Array.from(t??``).reduce((e,t)=>(e*31+(t.codePointAt(0)??0))%4,0);return(0,F.jsx)(`span`,{className:`group-avatar`,"data-avatar-tone":t?o:`self`,"data-avatar-busy":n||void 0,"aria-hidden":`true`,children:i})}function XT({step:e}){return e.kind===`thinking`?(0,F.jsxs)(`details`,{className:`group-execution-step`,"data-execution-kind":`thinking`,"data-execution-status":e.status,open:!0,children:[(0,F.jsxs)(`summary`,{children:[(0,F.jsx)(`span`,{children:e.status===`running`?`正在思考`:`思考摘要`}),(0,F.jsx)(`time`,{dateTime:e.startedAt,children:JT(e.startedAt,!0)})]}),e.text?(0,F.jsx)(`div`,{className:`message-body`,children:(0,F.jsx)(ef,{source:e.text,handoffs:!1})}):(0,F.jsx)(`p`,{className:`group-execution-muted`,children:e.status===`running`?`正在等待模型返回摘要。`:`模型未提供可显示的摘要。`}),e.status===`interrupted`&&(0,F.jsx)(`p`,{className:`group-execution-muted`,children:`思考已中断`})]}):(0,F.jsxs)(`li`,{className:`group-execution-step`,"data-execution-kind":`tool`,"data-execution-status":e.status,children:[(0,F.jsxs)(`div`,{className:`group-execution-tool`,children:[(0,F.jsx)(`strong`,{children:UT.get(e.name)??`工具调用`}),(0,F.jsx)(`code`,{children:e.name}),(0,F.jsx)(`span`,{className:`group-execution-step-status`,children:HT[e.status]})]}),e.detail&&(0,F.jsx)(`p`,{className:`group-execution-target`,children:(0,F.jsx)(`code`,{children:e.detail})}),(0,F.jsxs)(`div`,{className:`group-execution-muted`,children:[(0,F.jsx)(`time`,{dateTime:e.startedAt,children:JT(e.startedAt,!0)}),e.durationMs===void 0?e.status===`running`&&e.lastUpdateAt?` · 最近更新 ${JT(e.lastUpdateAt,!0)}`:null:` · ${(e.durationMs/1e3).toFixed(1)} 秒`]})]})}function ZT({workspaceId:e,roomId:t,memberId:n,name:r,runs:i,postId:a,onSelect:o,onClose:s,onStop:c,models:l,memberModel:d,onModelChange:f,onRetry:p}){let m=(0,u.useId)(),h=(0,u.useRef)(null),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(),[b,x]=(0,u.useState)(!1),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(!1),E=i.find(e=>e.id===a)??i.find(e=>e.status===`running`)??i[0],D=E?.id,O=g?.id===D?g?.value:void 0,k=v?.id===D?v?.message:void 0;return(0,u.useLayoutEffect)(()=>{h.current?.focus()},[]),(0,u.useEffect)(()=>{if(!D)return;let n=new AbortController,r,i,a=!1,o=async()=>{try{let r=await nr(er(e,t,i,D),{signal:n.signal});if(n.signal.aborted)return;y(void 0),r&&(i=r.revision,a=!GT(r),_({id:D,value:r}))}catch(e){n.signal.aborted||y({id:D,message:e instanceof Error?e.message:`暂时无法读取执行记录。`})}finally{!n.signal.aborted&&!a&&(r=window.setTimeout(o,500))}};return o(),()=>{n.abort(),window.clearTimeout(r)}},[D,e,t]),(0,F.jsxs)(`aside`,{className:`group-execution`,"aria-labelledby":m,"data-group-execution":n,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),s())},children:[(0,F.jsxs)(`header`,{className:`group-execution-header`,children:[(0,F.jsx)(YT,{name:r,memberId:n,busy:i.some(GT)}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{id:m,children:r}),(0,F.jsx)(`p`,{children:`执行详情`})]}),(0,F.jsx)(`button`,{ref:h,type:`button`,className:`group-close-execution`,"data-close-group-execution":!0,"aria-label":`关闭执行详情`,title:`关闭执行详情`,onClick:s,children:(0,F.jsx)(Gr,{name:`close`})})]}),f&&(0,F.jsxs)(`div`,{className:`group-execution-model-settings`,"aria-busy":b,children:[(0,F.jsx)(`span`,{children:`该成员后续使用的模型`}),(0,F.jsx)(IT,{label:`${r} 后续使用的模型`,value:d?FT(d):``,models:l,onChange:e=>{b||(x(!0),C(``),f(e).catch(e=>C(String(e.message??e))).finally(()=>x(!1)))}}),(0,F.jsx)(`small`,{children:b?`正在保存…`:`当前执行使用原模型。如需立即切换,请先停止再重试。`}),S&&(0,F.jsx)(`p`,{className:`group-error`,role:`alert`,children:S})]}),E?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`group-execution-summary`,children:[i.length>1&&(0,F.jsx)(`select`,{"aria-label":`选择执行记录`,value:D,onChange:e=>o(e.target.value),children:i.map(e=>(0,F.jsxs)(`option`,{value:e.id,children:[JT(e.createdAt,!0),` · `,e.assignment??HT[e.status]]},e.id))}),(0,F.jsx)(`div`,{"aria-live":`polite`,"data-execution-run-status":O?.status??E.status,children:HT[O?.status??E.status]}),E.assignment&&(0,F.jsx)(`p`,{children:E.assignment}),(0,F.jsx)(`p`,{"data-group-execution-model":!0,children:E.model?`${E.model.label} · ${E.model.provider}`:`模型尚未记录`}),GT(E)&&c&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>c(E.id),children:`停止这次执行`}),[`failed`,`cancelled`,`interrupted`].includes(E.status)&&p&&(0,F.jsx)(`button`,{type:`button`,"data-group-retry":!0,disabled:w||b,onClick:()=>{T(!0),C(``),p(E.id).catch(e=>C(String(e.message??e))).finally(()=>T(!1))},children:w?`正在提交重试…`:`用当前模型继续任务`}),E.error&&(0,F.jsx)(`p`,{className:`group-error`,children:E.error})]}),(0,F.jsxs)(`div`,{className:`group-execution-scroll`,children:[k&&(0,F.jsx)(`p`,{className:`group-error`,role:`alert`,children:k}),O?.steps.length?(0,F.jsx)(`ol`,{className:`group-execution-steps`,children:O.steps.map(e=>e.kind===`thinking`?(0,F.jsx)(`li`,{children:(0,F.jsx)(XT,{step:e})},e.id):(0,F.jsx)(XT,{step:e},e.id))}):!k&&(0,F.jsx)(`p`,{className:`group-execution-muted`,children:O?GT(O)?`等待模型或工具事件。`:`这次发言没有可查看的执行明细。`:`正在读取执行记录…`}),O?.truncated&&(0,F.jsx)(`p`,{className:`group-execution-muted`,children:`部分执行记录超过保留长度,已省略。`})]})]}):(0,F.jsx)(`p`,{className:`group-execution-scroll group-execution-muted`,children:`该成员还没有执行记录。`})]})}var QT=e=>JSON.stringify([e.provider,e.modelId]),$T=`super-pi.group-moderator-prompt-presets.v1`;function eE(){try{let e=JSON.parse(localStorage.getItem($T)??`[]`);return Array.isArray(e)?e.filter(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&typeof e.prompt==`string`).slice(0,100).map(e=>({id:e.id.slice(0,100),name:e.name.slice(0,80),prompt:e.prompt.slice(0,8e3)})):[]}catch{return[]}}var tE=e=>/\s/u.test(e)?`@"${e}"`:`@${e}`,nE=e=>new Set([...e.matchAll(/(?:^|[\s([{])(@(?:"(?:[^"\\]|\\.)+"|[^\s,。;、!?,::;!?,)\]}]+))/gu)].map(e=>e[1])),rE=rr;function iE({workspaceId:e,roomId:t,agents:n,catalog:r,userLabel:i,archivedAt:a,restoring:o,onRestore:s,onRoomSeen:c,onRoomRead:l,onRoomMissing:d,onCreated:f,onCancelCreate:p,onEnableNotifications:m,composerResize:h,sourceLink:g}){let[_,v]=(0,u.useState)(),[y,b]=(0,u.useState)(!1),[x,S]=(0,u.useState)(!1);(0,u.useEffect)(()=>{let e=e=>{e.detail?.roomId===t&&b(!0)};return window.addEventListener(`super-pi-status-group-models`,e),()=>window.removeEventListener(`super-pi-status-group-models`,e)},[t]);let[C,w]=(0,u.useState)(``),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(!1),[k,A]=(0,u.useState)({}),[j,ee]=(0,u.useState)(),[M,te]=(0,u.useState)(``),[N]=(0,u.useState)(()=>AT(e,t)),[ne,re]=(0,u.useState)(N.text),[ie,ae]=(0,u.useState)(N.replyTo),[oe,se]=(0,u.useState)(),[ce,le]=(0,u.useState)(N.mentions),[ue,de]=(0,u.useState)(N.files),[fe,pe]=(0,u.useState)([]),[me,he]=(0,u.useState)(0),[ge,P]=(0,u.useState)(),_e=(0,u.useRef)(null),ve=(0,u.useRef)(null),ye=(0,u.useRef)(void 0),be=(0,u.useRef)(null),xe=(0,u.useRef)(!0),Se=(0,u.useRef)(void 0),Ce=(0,u.useRef)(!1),we=(0,u.useRef)(void 0),Te=(0,u.useRef)(new Map),Ee=_?.id===t?_:void 0,De=!!(a||Ee?.archivedAt),Oe=Ee?.messages.find(e=>e.id===ie),ke=e=>Ee?.members.find(t=>t.id===e)?.name??e,Ae=e=>e.role===`user`?i:e.memberName??ke(e.memberId),je=De?void 0:oe?.query,Me=oe?[...(Ee?.members??[]).filter(e=>`${e.name} ${e.id}`.toLocaleLowerCase().includes(oe.query.toLocaleLowerCase())).map(e=>({kind:`member`,member:e})),...fe.map(e=>({kind:`file`,file:e}))]:[];(0,u.useEffect)(()=>{jT(e,t,{text:ne,replyTo:ie,mentions:ce,files:ue})},[e,t,ne,ie,ce,ue]);let Ne=e=>{if(e.id!==t)return;let n=Se.current;if(n?.id===e.id){let[t,r]=n.revision.split(`:`).map(Number),[i,a]=e.revision.split(`:`).map(Number);if(t>i||t===i&&r>a)return}Se.current=e,v(e),e.archivedAt&&b(!1),(n?.title!==e.title||n?.archivedAt!==e.archivedAt||n?.activity.status!==e.activity.status||n?.activity.lastReplyAt!==e.activity.lastReplyAt)&&c(e)};(0,u.useEffect)(()=>{let e=be.current;if(!Ee||y||!e)return;let t=!0,n=()=>{let n=e.getBoundingClientRect();t&&document.visibilityState===`visible`&&getComputedStyle(e).visibility===`visible`&&n.width>0&&n.height>0&&n.bottom>0&&n.top<window.innerHeight&&n.right>0&&n.left<window.innerWidth&&l(Ee)};n();let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&n()});return r.observe(e),document.addEventListener(`visibilitychange`,n),()=>{t=!1,r.disconnect(),document.removeEventListener(`visibilitychange`,n)}},[Ee?.id,Ee?.activity.lastReplyAt,y,ge?.memberId,ge?.postId,l]),(0,u.useEffect)(()=>(Ce.current=!0,()=>{Ce.current=!1}),[]),(0,u.useEffect)(()=>{if(!t)return;let n=new AbortController,r,i=!1,a=async()=>{try{let r=await nr(er(e,t,Se.current?.revision),{signal:n.signal});n.signal.aborted||(E(``),r&&Ne(r))}catch(r){n.signal.aborted||(r instanceof tr&&r.status===404?(i=!0,d({workspaceId:e,roomId:t})):E(Se.current?`群聊连接暂时中断,正在重试。`:String(r.message??r)))}finally{!n.signal.aborted&&!i&&(r=window.setTimeout(a,Se.current?.messages.some(GT)?450:1600))}};return a(),()=>{n.abort(),window.clearTimeout(r)}},[e,t,d]),(0,u.useEffect)(()=>{if(pe([]),!je)return;let t=new AbortController,n,r=()=>{nr(`/api/files/mentions?${new URLSearchParams({workspaceId:e,cwd:``,q:je})}`,{signal:t.signal}).then(e=>{!t.signal.aborted&&e&&(pe(e.hits.filter(e=>e.kind===`file`).slice(0,8)),e.indexed||(n=window.setTimeout(r,650)))}).catch(()=>{})};return n=window.setTimeout(r,160),()=>{window.clearTimeout(n),t.abort()}},[je,e]),(0,u.useLayoutEffect)(()=>{be.current&&xe.current&&(be.current.scrollTop=be.current.scrollHeight)},[Ee?.revision]),(0,u.useLayoutEffect)(()=>{let e=ye.current;e!==void 0&&ve.current&&(ye.current=void 0,ve.current.focus(),ve.current.setSelectionRange(e,e))},[ne]);async function Pe(n){O(!0),w(``);try{let r=await rE(er(e,t),t?{action:`configure`,memberIds:n.memberIds,memberModels:n.memberModels,...n.moderator,model:n.moderator.model??null,cloneLimit:n.moderator.cloneLimit??null}:n);if(!r)throw Error(`服务没有返回群聊。`);t?(Ne(r),b(!1)):f(r,Ce.current)}catch(e){w(String(e.message??e))}finally{O(!1)}}async function Fe(n){if(n.preventDefault(),!Ee||De||!ne.trim()||D)return;let r=ne.trim(),i=nE(r),a=ce.filter(e=>i.has(e.text)),o=Ee.members.filter(e=>a.some(t=>t.memberId===e.id)||i.has(tE(e.name))&&Ee.members.filter(t=>t.name===e.name).length===1).map(e=>e.id),s=ue.filter(e=>i.has(e.text)).map(e=>e.path),c=JSON.stringify([Ee.id,r,o,ie,s]);we.current?.signature!==c&&(we.current={signature:c,clientId:Wt()}),O(!0),w(``);try{let n=await rE(er(e,Ee.id),{action:`send`,content:r,memberIds:o,replyTo:ie,filePaths:s,clientId:we.current.clientId});if(!n)throw Error(`服务没有确认收到消息。`);MT(e,t,ne),xe.current=!0,Ne(n),Ce.current&&t===n.id&&(re(``),ae(void 0),le([]),de([]),se(void 0)),we.current=void 0}catch(e){w(String(e.message??e))}finally{O(!1)}}function Ie(e){if(!oe)return;let t;if(e.kind===`member`){let n=e.member,r=tE(n.name);re(ne.slice(0,oe.start)+r+` `+ne.slice(oe.end)),le(e=>[...e.filter(e=>e.text!==r),{memberId:n.id,text:r}]),t=oe.start+r.length+1}else{let n=e.file,r=_f(ne,oe,n),i=r.text.slice(oe.start,r.caret).trimEnd();re(r.text),de(e=>[...e.filter(e=>e.path!==n.path),{path:n.path,text:i}]),t=r.caret}ye.current=t,se(void 0)}async function Le(n){try{let r=await rE(er(e,t),{action:`stop`,postId:n});r&&Ne(r)}catch(e){w(String(e.message??e))}}async function Re(n,i){let a=r?.models.find(e=>QT(e)===i);if(i&&!a)throw Error(`所选模型不可用,请刷新模型列表后重试。`);if(!Ee)throw Error(`群聊尚未加载,请稍后重试。`);let o=await rE(er(e,t),{action:`configure`,memberModels:{[n]:a??null},...Ee.moderator,model:Ee.moderator.model??null,cloneLimit:Ee.moderator.cloneLimit??null});if(!o)throw Error(`服务没有确认模型更改。`);Ne(o);let s=o.members.find(e=>e.id===n)?.model;if((s?QT(s):``)!==i)throw Error(`目标服务端没有应用成员模型设置,可能版本过旧。请先升级目标服务端后重试;群聊历史仍保留。`)}async function ze(n){let r=Ee?.messages.find(e=>e.id===n&&e.role===`assistant`),i=r&&Ee?.messages.find(e=>e.id===r.topicId);if(!r||!i||![`failed`,`interrupted`,`cancelled`].includes(r.status))throw Error(`只能重试已失败或停止的执行。`);let a=Te.current.get(n)??Wt();Te.current.set(n,a);let o=`请使用当前模型继续这次未完成的任务。先检查已有产物,避免重复执行。\n原分工:${r.assignment??`按原请求完成工作`}\n原请求:${i.content}`.slice(0,32e3),s=await rE(er(e,t),{action:`send`,content:o,memberIds:[r.memberId],replyTo:r.id,clientId:a,filePaths:i.role===`user`?i.files?.map(e=>e.path):void 0});if(!s)throw Error(`服务没有确认重试请求。`);Ne(s),Te.current.delete(n)}async function Be(n,r,i){ee(n),w(``);try{let a=await rE(er(e,t),{action:`clone.resolve`,requestId:n,choice:r,name:i});a&&Ne(a)}catch(e){w(e instanceof Error?e.message:String(e))}finally{ee(void 0)}}function Ve(e,t,n,r){S(!1);let i=n.closest(`[data-group-post-id]`)?.querySelector(`[data-group-message-avatar]`)??void 0;_e.current={origin:n,avatar:i},P({memberId:e,name:t,postId:r})}function He(){let e=ge?.memberId;P(void 0);let t=_e.current;requestAnimationFrame(()=>{let n=[...document.querySelectorAll(`[data-group-message-avatar]`)].filter(t=>t.dataset.groupMessageAvatar===e).at(-1);(t?.origin.isConnected?t.origin:t?.avatar?.isConnected?t.avatar:n)?.focus({preventScroll:!0})})}let Ue=Ee?.messages??[],We=Kn(Ue),Ge=Ue.filter(e=>e.role===`assistant`&>(e)).filter((e,t,n)=>n.findIndex(t=>t.memberId===e.memberId)===t),Ke=new Map(Ue.map(e=>[e.id,e])),qe=new Set(Ue.flatMap(e=>e.role===`assistant`&>(e)?[e.memberId]:[])),Je=ge?Ue.filter(e=>e.role===`assistant`&&e.memberId===ge.memberId).reverse():[],Ye;return(0,F.jsxs)(`section`,{className:`group-chat`,"data-group-chat":t,children:[(C||T)&&(0,F.jsx)(`div`,{className:`group-error`,role:`alert`,children:C||T}),!t||y&&!De?(0,F.jsx)(aE,{room:y?Ee:void 0,agents:n,catalog:r,saving:D,onSave:Pe,onCancel:t?()=>b(!1):p}):Ee?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`group-members`,children:[(0,F.jsx)(`div`,{className:`group-roster`,"aria-label":`群成员`,children:Ee.members.map(e=>(0,F.jsxs)(`button`,{type:`button`,className:`group-roster-member`,"data-group-member-avatar":e.id,"aria-label":`查看 ${e.name} 的执行详情${qe.has(e.id)?`,工作中`:``}`,title:`${e.name}${e.agentId?` · 分身 · ${e.worktreePath??e.agentId}`:``}`,"aria-pressed":ge?.memberId===e.id,onClick:t=>Ve(e.id,e.name,t.currentTarget),children:[(0,F.jsx)(YT,{name:e.name,memberId:e.id,busy:qe.has(e.id)}),(0,F.jsxs)(`span`,{children:[e.name,e.agentId?` · 分身`:``]})]},e.id))}),!De&&(0,F.jsx)(`button`,{type:`button`,"data-group-settings":!0,disabled:D,onClick:()=>{w(``),P(void 0),b(!0)},children:`群聊设置`}),(0,F.jsxs)(`button`,{type:`button`,"data-group-rsi":!0,"aria-pressed":x,onClick:()=>{S(e=>!e),P(void 0)},children:[`RSI`,Ee.rsi?.status===`running`?` · 观察中`:Ee.rsi?.status===`failed`?` · 需处理`:``]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{m?m():na().then(e=>te(e===`granted`?`系统通知已开启`:`请在浏览器站点设置中允许通知`))},children:`系统通知`})]}),M&&(0,F.jsx)(`p`,{role:`status`,children:M}),(Ee.cloneRequests??[]).filter((e,t,n)=>e.status===`pending`||t>=n.length-3).map(e=>{let t=Ee.members.find(t=>t.id===e.memberId),n=2;for(;Ee.members.some(e=>e.name===`${t?.name??`Agent`} ${n}`);)n+=1;let r=k[e.id]??`${t?.name??`Agent`} ${n}`;return(0,F.jsx)(`section`,{className:`group-clone-request`,"data-clone-request":e.id,"aria-label":`创建 Agent 分身`,children:e.status===`pending`&&e.automatic?(0,F.jsx)(`span`,{children:`主持人正在准备独立分身…`}):e.status===`pending`&&!De?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`strong`,{children:[t?.name??`Agent`,` 正在工作,是否创建分身?`]}),(0,F.jsx)(`p`,{children:e.reason}),(0,F.jsx)(`p`,{children:e.assignment}),(0,F.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),Be(e.id,`create`,r)},children:[(0,F.jsxs)(`label`,{children:[`分身名字`,(0,F.jsx)(`input`,{maxLength:80,required:!0,value:r,onChange:t=>A(n=>({...n,[e.id]:t.target.value}))})]}),(0,F.jsx)(`button`,{disabled:!!j||!r.trim(),children:j===e.id?`正在准备…`:`创建分身并处理`}),(0,F.jsx)(`button`,{type:`button`,disabled:!!j,onClick:()=>void Be(e.id,`wait`,``),children:`等待空闲`})]}),(0,F.jsx)(`small`,{children:`分身共享源 Agent 的能力与经验,在独立 Git 工作树处理此 case。`})]}):(0,F.jsx)(`span`,{children:e.status===`created`?`已安排 ${Ee.members.find(t=>t.id===e.cloneId)?.name??`分身`}`:e.status===`waiting`?`已选择等待原成员`:`成员或任务状态已变化,无需创建分身`})},e.id)}),(0,F.jsxs)(`div`,{className:`group-stage${ge?` group-stage-inspecting`:``}${x?` group-stage-rsi`:``}`,children:[(0,F.jsxs)(`div`,{className:`group-dialogue`,children:[(0,F.jsxs)(`div`,{className:`group-thread`,ref:be,onScroll:e=>{let t=e.currentTarget;xe.current=t.scrollHeight-t.clientHeight-t.scrollTop<64},children:[!Ue.length&&(0,F.jsx)(`p`,{className:`group-empty`,children:De?`这个群聊没有消息。`:`发条消息开始讨论。用 @ 点名一个或多个成员。`}),We.map(e=>{let t=e.replyTo?Ke.get(e.replyTo):void 0;e.role===`user`&&(Ye=e.id);let n=t&&(e.role===`user`||t.id!==e.topicId||e.topicId!==Ye)?t:void 0,r=Ae(e),i=e.role===`assistant`&&e.background&&e.status===`running`?`后台进行中`:HT[e.status],a=e.role===`assistant`&&ge?.postId===e.id;return(0,F.jsxs)(`article`,{className:`group-post group-post-${e.role}`,"data-group-post":e.role,"data-group-status":e.status,"data-group-post-id":e.id,children:[e.role===`assistant`?(0,F.jsx)(`button`,{className:`group-post-avatar`,type:`button`,"data-group-message-avatar":e.memberId,"aria-label":`查看 ${r} 这次发言的执行详情`,title:`${r} · 执行详情`,"aria-pressed":a,onClick:t=>Ve(e.memberId,r,t.currentTarget,e.id),children:(0,F.jsx)(YT,{name:r,memberId:e.memberId,busy:GT(e)})}):(0,F.jsx)(YT,{name:r}),(0,F.jsxs)(`div`,{className:`group-post-content`,children:[(0,F.jsxs)(`div`,{className:`group-post-head`,children:[(0,F.jsx)(`strong`,{children:r}),e.role===`assistant`&&(0,F.jsx)(`span`,{className:`group-message-model`,"data-group-message-model":e.model?QT(e.model):`unknown`,title:e.model?`${e.model.provider} / ${e.model.modelId}`:`这条历史消息没有记录使用的模型`,children:e.model?`${e.model.label} · ${e.model.provider}`:`模型未记录`}),e.status!==`completed`&&(0,F.jsx)(`span`,{className:`group-post-state`,children:i}),(0,F.jsx)(`time`,{dateTime:Gn(e),children:JT(Gn(e))}),!De&&(0,F.jsxs)(`div`,{className:`group-post-actions`,children:[!GT(e)&&(0,F.jsx)(`button`,{type:`button`,className:`group-reply-action`,disabled:D,onClick:()=>{ae(e.id),ve.current?.focus()},children:`回复`}),GT(e)&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>void Le(e.id),children:`停止`})]})]}),(n||e.content||e.error||e.role===`user`&&e.memoryNotice)&&(0,F.jsxs)(`div`,{className:`group-bubble`,children:[n&&(0,F.jsxs)(`div`,{className:`group-quote`,children:[Ae(n),` · `,n.content.slice(0,120)]}),e.content&&(0,F.jsx)(`div`,{className:`message-body`,children:(0,F.jsx)(ef,{source:e.content,handoffs:!1,sourceLink:e.role===`assistant`&&_?.members.some(t=>t.id===e.memberId&&!t.worktreePath)?g:void 0})}),e.role===`user`&&e.memoryNotice&&(0,F.jsx)(`div`,{className:`group-route`,children:e.memoryNotice}),e.error&&(0,F.jsx)(`p`,{className:`group-error`,children:e.error})]}),e.role===`assistant`&&e.routeReason&&(0,F.jsxs)(`details`,{className:`group-route group-post-footer`,children:[(0,F.jsx)(`summary`,{children:`接话原因`}),e.routeReason]})]})]},e.id)})]}),Ge.length>0&&(0,F.jsx)(`div`,{className:`group-preparing`,"data-group-preparing":!0,role:`group`,"aria-label":`正在准备回复的成员`,children:Ge.map(e=>(0,F.jsx)(`button`,{type:`button`,"data-group-preparing-avatar":e.memberId,title:`${Ae(e)} · 正在准备回复`,"aria-label":`查看 ${Ae(e)} 的准备详情`,"aria-pressed":ge?.memberId===e.memberId,onClick:t=>Ve(e.memberId,Ae(e),t.currentTarget,e.id),children:(0,F.jsx)(YT,{name:Ae(e),memberId:e.memberId,busy:!0})},e.memberId))}),De?(0,F.jsxs)(`div`,{className:`group-archive-notice`,"data-group-archive-notice":!0,children:[(0,F.jsx)(`p`,{children:`群聊已归档。恢复后可继续发消息。`}),(0,F.jsx)(`button`,{type:`button`,"data-group-restore":!0,disabled:o,onClick:()=>s(Ee),children:`恢复群聊`})]}):(0,F.jsxs)(`form`,{className:`group-composer`,onSubmit:Fe,children:[h,Oe&&(0,F.jsxs)(`div`,{className:`group-quote`,children:[`回复 `,Ae(Oe),` · `,Oe.content.slice(0,60),` `,(0,F.jsx)(`button`,{type:`button`,onClick:()=>ae(void 0),"aria-label":`取消引用`,children:`×`})]}),Me.length>0&&(0,F.jsx)(`div`,{className:`group-suggestions`,role:`listbox`,"aria-label":`点名群成员或引用文件`,children:Me.map((e,t)=>(0,F.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":t===me,"data-group-member-option":e.kind===`member`?e.member.id:void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>Ie(e),children:e.kind===`member`?e.member.name:`文件 · ${e.file.path}`},e.kind===`member`?`member:${e.member.id}`:`file:${e.file.path}`))}),(0,F.jsx)(`textarea`,{ref:ve,"data-group-composer":!0,"aria-label":`群聊消息`,placeholder:`输入消息,@ 点名或引用文件`,value:ne,maxLength:32e3,readOnly:D,onChange:e=>{re(e.target.value),se(gf(e.target.value,e.target.selectionStart,e.target.selectionEnd)),he(0)},onSelect:e=>{let t=e.currentTarget;se(gf(t.value,t.selectionStart,t.selectionEnd))},onKeyDown:e=>{e.nativeEvent.isComposing||(Me.length&&(e.key===`ArrowDown`||e.key===`ArrowUp`)?(e.preventDefault(),he(t=>(t+Me.length+(e.key===`ArrowDown`?1:-1))%Me.length)):Me.length&&(e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey?(e.preventDefault(),Ie(Me[me]??Me[0])):e.key===`Escape`?se(void 0):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit()))}}),(0,F.jsx)(`button`,{type:`submit`,"data-group-send":!0,disabled:!ne.trim()||D,children:`发送`})]})]}),x&&(0,F.jsx)(BT,{source:{kind:`group`,workspaceId:e,id:t},models:r?.models??[],archived:De,onClose:()=>S(!1)}),!x&&ge&&(0,F.jsx)(ZT,{workspaceId:e,roomId:t,memberId:ge.memberId,name:ge.name,runs:Je,postId:ge.postId,onStop:e=>void Le(e),onSelect:e=>P({...ge,postId:e}),onClose:He,models:r?.models??[],memberModel:Ee.members.find(e=>e.id===ge.memberId)?.model,onModelChange:De?void 0:e=>Re(ge.memberId,e),onRetry:De?void 0:ze},ge.memberId)]})]}):!T&&(0,F.jsx)(`p`,{className:`group-empty`,children:`正在加载群聊…`})]})}function aE({room:e,agents:t,catalog:n,saving:r,onSave:i,onCancel:a}){let[o,s]=(0,u.useState)(e?.title??``),[c,l]=(0,u.useState)({}),d=t.filter(e=>e.mode===`primary`&&!e.hidden),f=[...d,...e?.members.filter(e=>!d.some(t=>t.id===e.id))??[]],p=e?.members.map(e=>e.id)??Wn,m=[...new Set([...p,...f.map(e=>e.id)])].filter(e=>f.some(t=>t.id===e)&&(c[e]??p.includes(e))),[h,g]=(0,u.useState)(e?.moderator.model?QT(e.moderator.model):``),[_,v]=(0,u.useState)(e?.moderator.prompt??``),[y,b]=(0,u.useState)(e?.moderator.cloneLimit??0),[x,S]=(0,u.useState)(()=>Object.fromEntries((e?.members??[]).map(e=>[e.id,e.model?QT(e.model):``]))),[C,w]=(0,u.useState)(PT),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(``),[k,A]=(0,u.useState)(``),[j,ee]=(0,u.useState)(eE),[M,te]=(0,u.useState)(``),[N,ne]=(0,u.useState)(``),[re,ie]=(0,u.useState)(``);(0,u.useEffect)(()=>{try{localStorage.setItem($T,JSON.stringify(j))}catch{ie(`浏览器无法保存预设,请检查本地存储空间或隐私设置。`)}},[j]);let ae=[...n?.models??[]];if(e?.moderator.model&&!ae.some(t=>QT(t)===QT(e.moderator.model))){let t=e.moderator.model;n||ae.push(t)}let oe=()=>Object.fromEntries(m.map(e=>[e,ae.find(t=>QT(t)===x[e])??null])),se=()=>({prompt:_,cloneLimit:y||void 0,model:ae.find(e=>QT(e)===h)}),ce=!(!h||ae.some(e=>QT(e)===h))||m.some(e=>x[e]&&!ae.some(t=>QT(t)===x[e])),le=e=>{try{return localStorage.setItem(NT,JSON.stringify(e)),w(e),!0}catch{return A(`浏览器无法保存群聊预设,请检查本地存储空间或隐私设置。`),!1}};return(0,F.jsxs)(`form`,{className:`group-settings`,onSubmit:e=>{e.preventDefault();let t=ae.find(e=>QT(e)===h);h&&!t||ce||i({title:o,memberIds:m,memberModels:oe(),moderator:se()})},children:[(0,F.jsxs)(`div`,{className:`group-settings-heading`,children:[(0,F.jsx)(`h2`,{children:e?`群聊设置`:`创建群聊`}),(0,F.jsx)(`p`,{children:`安排成员与模型,让主持人协调讨论和执行。`})]}),(0,F.jsxs)(`section`,{className:`group-settings-card`,"data-group-presets":!0,children:[(0,F.jsx)(`h3`,{children:`群聊预设`}),(0,F.jsx)(`p`,{className:`group-settings-hint`,children:`一并保存成员、各自模型和主持人设置。`}),(0,F.jsxs)(`label`,{children:[`加载群聊预设`,(0,F.jsxs)(`select`,{"aria-label":`加载群聊预设`,value:T,onChange:e=>{E(e.target.value);let t=C.find(t=>t.id===e.target.value);if(!t)return;O(t.name),l(Object.fromEntries([...new Set([...p,...f.map(e=>e.id),...t.memberIds])].map(e=>[e,t.memberIds.includes(e)]))),S(Object.fromEntries(Object.entries(t.memberModels).map(([e,t])=>[e,t?QT(t):``]))),v(t.moderator.prompt),g(t.moderator.model?QT(t.moderator.model):``),b(t.moderator.cloneLimit??0);let n=t.memberIds.filter(e=>!f.some(t=>t.id===e));A(n.length?`已加载「${t.name}」。${n.length} 位成员在当前服务端不可用,请检查成员列表后保存。`:`已加载「${t.name}」。可继续调整,不影响其他群聊。`)},children:[(0,F.jsx)(`option`,{value:``,children:`选择预设…`}),C.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,F.jsxs)(`div`,{className:`group-prompt-preset-actions`,children:[(0,F.jsx)(`input`,{"aria-label":`群聊预设名称`,placeholder:`例如:日常开发评审`,value:D,maxLength:80,onChange:e=>O(e.target.value)}),(0,F.jsx)(`button`,{type:`button`,disabled:!D.trim()||m.length<2||ce,onClick:()=>{let t=D.trim(),n=C.find(e=>e.name.toLocaleLowerCase()===t.toLocaleLowerCase()),r=m.map(t=>e?.members.find(e=>e.id===t)?.agentId??t),i=oe(),a={id:n?.id??Wt(),name:t,memberIds:[...new Set(r)],memberModels:Object.fromEntries(r.map((e,t)=>[e,i[m[t]]])),moderator:se()};le(n?C.map(e=>e.id===n.id?a:e):[a,...C].slice(0,100))&&(E(a.id),A(`已保存群聊预设「${t}」。`))},children:`保存预设`}),T&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{le(C.filter(e=>e.id!==T))&&(E(``),A(`群聊预设已删除。`))},children:`删除`})]}),k&&(0,F.jsx)(`p`,{className:`group-settings-hint`,role:`status`,children:k})]}),!e&&(0,F.jsxs)(`label`,{children:[`群名`,(0,F.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),maxLength:100,required:!0})]}),(0,F.jsxs)(`fieldset`,{className:`group-member-settings`,children:[(0,F.jsx)(`legend`,{children:`群成员与模型`}),f.map(e=>(0,F.jsxs)(`div`,{className:`group-member-card`,"data-selected":m.includes(e.id),children:[(0,F.jsxs)(`label`,{className:`group-choice`,title:e.description,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-group-member-choice":e.id,checked:m.includes(e.id),disabled:!m.includes(e.id)&&m.length>=8,onChange:t=>{let n=t.target.checked;l(t=>({...t,[e.id]:n}))}}),(0,F.jsx)(YT,{name:e.name,memberId:e.id}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`strong`,{children:e.name}),(0,F.jsx)(`small`,{children:e.description})]})]}),m.includes(e.id)&&(0,F.jsx)(IT,{label:`${e.name} 的模型`,value:x[e.id]??``,models:ae,onChange:t=>S(n=>({...n,[e.id]:t}))})]},e.id))]}),(0,F.jsx)(`p`,{className:`group-settings-hint`,children:`取消勾选可移除成员。请选择 2 到 8 位主 Agent。`}),(0,F.jsxs)(`details`,{className:`group-settings-card`,open:!0,children:[(0,F.jsx)(`summary`,{children:`主持人设置`}),(0,F.jsxs)(`label`,{children:[`同类 Agent 分身`,(0,F.jsxs)(`select`,{value:y,onChange:e=>b(Number(e.target.value)),children:[(0,F.jsx)(`option`,{value:0,children:`创建前询问我`}),[2,3,4,8].map(e=>(0,F.jsxs)(`option`,{value:e,children:[`允许自动创建 · 同类最多 `,e,` 人`]},e))]})]}),(0,F.jsxs)(`div`,{className:`group-model-field`,children:[(0,F.jsx)(`span`,{children:`主持人模型`}),(0,F.jsx)(IT,{label:`主持人模型`,value:h,models:ae,onChange:g})]}),(0,F.jsxs)(`label`,{children:[`主持人 Prompt`,(0,F.jsx)(`textarea`,{value:_,maxLength:8e3,onChange:e=>v(e.target.value),placeholder:`例如:先请最熟悉模块的成员回答,结论足够时结束。`})]}),(0,F.jsxs)(`details`,{className:`group-prompt-presets`,"data-moderator-prompt-presets":!0,children:[(0,F.jsx)(`summary`,{children:`旧版 Prompt 预设`}),(0,F.jsxs)(`label`,{children:[`加载已保存的 Prompt`,(0,F.jsxs)(`select`,{"aria-label":`加载主持人 Prompt 预设`,value:M,onChange:e=>{let t=j.find(t=>t.id===e.target.value);te(e.target.value),t?(v(t.prompt),ne(t.name),ie(`已加载「${t.name}」,可继续修改后用于当前群聊。`)):ie(``)},children:[(0,F.jsx)(`option`,{value:``,children:`选择预设…`}),j.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,F.jsxs)(`div`,{className:`group-prompt-preset-actions`,children:[(0,F.jsx)(`input`,{"aria-label":`Prompt 预设名称`,value:N,maxLength:80,onChange:e=>ne(e.target.value),placeholder:`预设名称`}),(0,F.jsx)(`button`,{type:`button`,disabled:!N.trim()||!_.trim(),onClick:()=>{let e=N.trim(),t=j.find(t=>t.name.toLocaleLowerCase()===e.toLocaleLowerCase()),n={id:t?.id??Wt(),name:e,prompt:_};ee(e=>t?e.map(e=>e.id===t.id?n:e):[n,...e].slice(0,100)),te(n.id),ie(`已保存「${e}」。`)},children:`保存预设`}),M&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{let e=j.find(e=>e.id===M);ee(e=>e.filter(e=>e.id!==M)),te(``),ne(``),ie(e?`已删除「${e.name}」。`:`预设已删除。`)},children:`删除预设`})]}),re&&(0,F.jsx)(`p`,{className:`group-settings-hint`,role:`status`,children:re})]})]}),(0,F.jsxs)(`div`,{className:`group-settings-actions`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:r,onClick:a,children:`取消`}),(0,F.jsx)(`button`,{type:`submit`,disabled:r||!o.trim()||m.length<2||m.length>8||ce,children:e?`保存`:`创建群聊`})]})]})}var oE=`__pi_default__`;function sE({workspaces:e,catalog:t,onClose:n,onSave:r}){let[i,a]=(0,u.useState)(oE),[o,s]=(0,u.useState)(oE);(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let c=t.models.find(e=>`${e.provider}/${e.modelId}`===i),l=c?.provider===t.defaultModel?.provider&&c?.modelId===t.defaultModel?.modelId,d=c?.thinkingLevels??(l?t.levels:[]),f=c?{provider:c.provider,modelId:c.modelId,label:c.label}:void 0;return(0,F.jsx)(`div`,{className:`overlay`,onClick:n,children:(0,F.jsxs)(`div`,{className:`picker settings-dialog bulk-workspace-settings`,"data-bulk-workspace-settings":`1`,onClick:e=>e.stopPropagation(),children:[(0,F.jsx)(`h2`,{children:`批量设置工作区`}),(0,F.jsxs)(`div`,{className:`settings-scope`,children:[`将统一修改 `,e.length,` 个现存工作区的默认模型与思考等级,只影响之后新建的会话。`]}),(0,F.jsxs)(`label`,{className:`bulk-settings-field`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`默认模型`}),(0,F.jsxs)(`select`,{className:`bulk-settings-select`,"aria-label":`批量默认模型`,value:i,disabled:t.source!==`pi`,onChange:e=>{a(e.target.value),s(oE)},children:[(0,F.jsx)(`option`,{value:oE,children:`跟随 Pi 默认`}),t.models.map(e=>(0,F.jsxs)(`option`,{value:`${e.provider}/${e.modelId}`,children:[e.label,` · `,e.provider]},`${e.provider}/${e.modelId}`))]})]}),(0,F.jsxs)(`label`,{className:`bulk-settings-field`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`默认思考等级`}),(0,F.jsxs)(`select`,{className:`bulk-settings-select`,"aria-label":`批量默认思考等级`,value:o,disabled:!c||t.source!==`pi`,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:oE,children:`跟随 Pi 默认`}),d.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})]}),c&&d.length===0&&(0,F.jsx)(`p`,{className:`bulk-settings-note`,children:`Pi 没有为此模型提供可选择的思考等级;新会话会使用 Pi 默认值。`}),(0,F.jsxs)(`div`,{className:`bulk-settings-workspaces`,"aria-label":`将被更新的工作区`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`应用到`}),(0,F.jsx)(`div`,{children:e.map(e=>(0,F.jsx)(`span`,{children:e.name},e.id))})]}),(0,F.jsxs)(`div`,{className:`picker-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:n,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`picker-ok`,disabled:!e.length||t.source!==`pi`,onClick:()=>r(f,o===oE?void 0:o),children:`应用到全部工作区`})]})]})})}function cE({glyph:e,className:t}){return(0,F.jsx)(`span`,{className:t,"data-tool-glyph-length":Math.min(4,Math.max(1,Array.from(e).length)),"aria-hidden":`true`,children:e})}function lE(e){if(e!==void 0){if(typeof e!=`string`||!e.trim()||Array.from(e.trim()).length>4||/[<>\u0000-\u001f\u007f]/.test(e))throw Error(`工具图标须为 1 至 4 个字符的文字或符号`);return e.trim()}}function uE(e){try{let t=lE(e.glyph);if(t)return t}catch{}let t=`${e.name} ${e.slug??``}`.toLowerCase();return[[/json/,`{}`],[/正则|regex/,`.*`],[/计算|calc/,`∑`],[/时间|timestamp|date/,`◷`],[/差异|diff/,`±`],[/markdown/,`M↓`],[/图像|图片|image/,`▧`],[/表格|csv|excel/,`▦`],[/颜色|color/,`◐`],[/base64/,`64`],[/hash|哈希/,`#`],[/git/,`⑂`]].find(([e])=>e.test(t))?.[1]??(Array.from(e.name.trim()).slice(0,2).join(``)||`◇`)}function dE(e){return!!(e&&typeof e==`object`&&e.type===`message.send`)}function fE(e){let t=[],n=[];for(let r of e)(r.retry?t:n).push(r);return{retry:t,failed:n}}function pE(e){let t=new Map;for(let[n,r]of e.entries())t.has(r.id)||t.set(r.id,n);return t}function mE(e,t){if(!t||t.length===0)return e;let n=new Map(t.map((e,t)=>[e,t])),r=e.filter(e=>n.has(e.id)).sort((e,t)=>(n.get(e.id)??0)-(n.get(t.id)??0));return[...e.filter(e=>!n.has(e.id)),...r]}function hE(e,t,n){if(e.indexOf(t)<0)return[...e];let r=e.filter(e=>e!==t),i=Math.max(0,Math.min(n,r.length));return[...r.slice(0,i),t,...r.slice(i)]}var gE=`super-pi.session-order.v1`;function _E(){try{if(typeof window>`u`)return{};let e=JSON.parse(window.localStorage.getItem(`super-pi.session-order.v1`)??`null`);if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&(t[n]=r.filter(e=>typeof e==`string`));return t}catch{return{}}}function vE(e){try{typeof window<`u`&&window.localStorage.setItem(gE,JSON.stringify(e))}catch{}}function yE(e,t,n){let r=new Set(e.map(e=>e.id)),i=pE(e),a=(e,t)=>(i.get(e.id)??2**53-1)-(i.get(t.id)??2**53-1),o=new Map,s=[];for(let t of e){let e=t.parentConversationId;if(e&&r.has(e)){let n=o.get(e);n?n.push(t):o.set(e,[t])}else s.push(t)}for(let e of o.values())e.sort(a);let c=mE(s.sort(a),n?.manualRoots),l=[],u=new Set,d=(e,n,r,i=!0)=>{if(u.has(e.id))return;u.add(e.id);let a=o.get(e.id)??[];i&&l.push({conversation:e,depth:Math.min(n,8),childCount:a.length,isLastSibling:r});let s=!i||t.has(e.id);for(let[e,t]of a.entries())d(t,n+1,e===a.length-1,!s)};for(let e of c)d(e,0,!1);let f=e.filter(e=>!u.has(e.id)).sort(a);for(let e of f)d(e,0,!1);return l}var bE=`super-pi:tool-shortcuts:v1`,xE=new Set([`Control`,`Alt`,`Shift`,`Meta`,`AltGraph`,`CapsLock`,`Fn`,`FnLock`,`Hyper`,`Super`,`Symbol`,`SymbolLock`]),SE=new Set([`Escape`]),CE=new Set([`Enter`,` `,`Tab`]),wE={" ":`Space`,ArrowUp:`↑`,ArrowDown:`↓`,ArrowLeft:`←`,ArrowRight:`→`,Escape:`Esc`},TE={ctrl:`⌃`,alt:`⌥`,shift:`⇧`,meta:`⌘`};function EE(e){if(e===` `)return` `;let t=e.trim();return t?t.length===1?t.toLowerCase():t:``}function DE(e){return xE.has(e)}function OE(e){let t=e.key;if(!t||t===`Unidentified`||t===`Dead`||DE(t))return;let n=EE(t);if(!n)return;let r=!!e.shiftKey;if(r&&n.length===1&&!/[a-z]/.test(n)){let t=/^Digit([0-9])$/.exec(e.code??``);t&&(n=t[1])}let i={key:n};return e.ctrlKey&&(i.ctrl=!0),e.altKey&&(i.alt=!0),r&&(i.shift=!0),e.metaKey&&(i.meta=!0),i}function kE(e){return wE[e]||(e.length===1||/^f\d{1,2}$/.test(e)?e.toUpperCase():e)}function AE(e){let t=[];return e.ctrl&&t.push(`Ctrl`),e.alt&&t.push(`Alt`),e.shift&&t.push(`Shift`),e.meta&&t.push(`Meta`),t.push(kE(e.key)),t.join(`+`)}function jE(e){let t=``;return e.ctrl&&(t+=TE.ctrl),e.alt&&(t+=TE.alt),e.shift&&(t+=TE.shift),e.meta&&(t+=TE.meta),t+kE(e.key)}function ME(e,t){return e.key===t.key&&!!e.ctrl==!!t.ctrl&&!!e.alt==!!t.alt&&!!e.shift==!!t.shift&&!!e.meta==!!t.meta}function NE(e){return!!(e.ctrl||e.alt||e.shift||e.meta)}function PE(e){return e.key?SE.has(e.key)?{ok:!1,reason:`Esc 是所有弹窗的退出键,不能拿来当工具快捷键。`}:!NE(e)&&CE.has(e.key)?{ok:!1,reason:`「${FE(e.key)}」是当前焦点控件的激活键,加一个修饰键(Ctrl / Alt / Shift)才能当快捷键用。`}:{ok:!0}:{ok:!1,reason:`这个组合键不完整,请按一个具体的键。`}}function FE(e){return kE(e)}function IE(e){let t=e;if(!t||typeof t!=`object`)return!1;let n=t.tagName;return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable===!0}function LE(e,t){if(t.isComposing||t.defaultPrevented)return!1;let n=OE(t);return!(!n||!ME(e,n)||!NE(e)&&IE(t.target??null))}function RE(e){if(!e)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||typeof r!=`object`||!r)continue;let t=r,i=EE(typeof t.key==`string`?t.key:``);if(!i)continue;let a={key:i};t.ctrl===!0&&(a.ctrl=!0),t.alt===!0&&(a.alt=!0),t.shift===!0&&(a.shift=!0),t.meta===!0&&(a.meta=!0),PE(a).ok&&(n[e]=a)}return n}function zE(e){let t={};for(let n of Object.keys(e).sort()){let r=e[n];if(!r)continue;let i={key:r.key};r.ctrl&&(i.ctrl=!0),r.alt&&(i.alt=!0),r.shift&&(i.shift=!0),r.meta&&(i.meta=!0),t[n]=i}return JSON.stringify(t)}function BE(e,t,n){for(let[r,i]of Object.entries(e))if(r!==n&&ME(i,t))return r}var VE=`super-pi:tool-settings-size:v1`,HE={width:480,height:320};function UE(){try{if(typeof window>`u`)return It.slice();let e=Ht(window.localStorage.getItem(zt));return window.localStorage.getItem(`super-pi:tools:v1`)===null?It.slice():e}catch{return It.slice()}}function WE(e){try{if(typeof window>`u`)return;window.localStorage.setItem(zt,Ut(e))}catch{}}function GE(){try{return typeof window>`u`?{}:RE(window.localStorage.getItem(bE))}catch{return{}}}function KE(e){try{if(typeof window>`u`)return;window.localStorage.setItem(bE,zE(e))}catch{}}function qE(e,t,n){let r={};for(let n of t)e[n.id]&&(r[n.id]=e[n.id]);for(let e of n)e.shortcut&&(r[e.id]=e.shortcut);return r}function JE(){try{if(typeof window>`u`)return;let e=window.localStorage.getItem(VE);if(!e)return;let t=JSON.parse(e);return typeof t?.width!=`number`||typeof t?.height!=`number`||!Number.isFinite(t.width)||!Number.isFinite(t.height)||t.width<HE.width||t.height<HE.height?void 0:{width:Math.round(t.width),height:Math.round(t.height)}}catch{return}}function YE(e){try{if(typeof window>`u`)return;e?window.localStorage.setItem(VE,JSON.stringify({width:Math.round(e.width),height:Math.round(e.height)})):window.localStorage.removeItem(VE)}catch{}}function XE(e,t,n){let r=Math.max(HE.width,t-32),i=Math.max(HE.height,n-32);return{width:Math.round(Math.min(Math.max(e.width,HE.width),r)),height:Math.round(Math.min(Math.max(e.height,HE.height),i))}}var ZE=GE(),QE={tools:UE(),mountedTools:[],settingsOpen:!1,shortcuts:{}};QE.shortcuts=qE(ZE,QE.tools,QE.mountedTools);var $E=new Set;function eD(e){QE={...QE,...e};for(let e of $E)e()}function tD(e){return $E.add(e),()=>{$E.delete(e)}}var nD=()=>QE;function rD(){return(0,u.useSyncExternalStore)(tD,nD,nD)}var iD={setTools(e){WE(e);let t=new Set(e.map(e=>e.id));ZE=Object.fromEntries(Object.entries(ZE).filter(([e])=>t.has(e))),KE(ZE),eD({tools:e,shortcuts:qE(ZE,e,QE.mountedTools)})},removeTool(e){let t=qt(QE.tools,e);ZE[e]&&(ZE={...ZE},delete ZE[e],KE(ZE)),WE(t),eD({tools:t,shortcuts:qE(ZE,t,QE.mountedTools),openToolId:QE.openToolId===e?void 0:QE.openToolId})},setMountedTools(e){let t=new Set(QE.tools.map(e=>e.id));ZE=Object.fromEntries(Object.entries(ZE).filter(([e])=>t.has(e))),KE(ZE),eD({mountedTools:e,shortcuts:qE(ZE,QE.tools,e)})},openTool(e){eD({openToolId:e,settingsOpen:!1})},closeTool(){eD({openToolId:void 0})},toggleTool(e){QE.openToolId===e?iD.closeTool():iD.openTool(e)},openSettings(){eD({settingsOpen:!0,openToolId:void 0})},closeSettings(){eD({settingsOpen:!1})},async setShortcut(e,t){let n=QE.mountedTools.find(t=>t.id===e);if(n){try{let e=await Ne(`/api/tools/shortcut`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({slug:n.slug,shortcut:t})}),r=await e.json();if(!e.ok)return r.error??`快捷键保存失败(HTTP ${e.status})。`}catch(e){return e instanceof Error?e.message:String(e)}eD({mountedTools:QE.mountedTools.map(n=>n.id===e?{...n,shortcut:t}:n),shortcuts:{...QE.shortcuts,[e]:t}})}else ZE={...ZE,[e]:t},KE(ZE),eD({shortcuts:qE(ZE,QE.tools,QE.mountedTools)})},async clearShortcut(e){if(!QE.shortcuts[e])return;let t=QE.mountedTools.find(t=>t.id===e);if(t){try{let e=await Ne(`/api/tools/shortcut`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({slug:t.slug,shortcut:null})}),n=await e.json();if(!e.ok)return n.error??`快捷键清除失败(HTTP ${e.status})。`}catch(e){return e instanceof Error?e.message:String(e)}eD({mountedTools:QE.mountedTools.map(t=>t.id===e?{...t,shortcut:void 0}:t),shortcuts:Object.fromEntries(Object.entries(QE.shortcuts).filter(([t])=>t!==e))})}else ZE={...ZE},delete ZE[e],KE(ZE),eD({shortcuts:qE(ZE,QE.tools,QE.mountedTools)})},persistTools(){WE(QE.tools)}};async function aD(){let e=fe();try{let t=await Ne(`/api/tools`),n=await t.json();fe()===e&&t.ok&&Array.isArray(n.tools)&&iD.setMountedTools(n.tools.filter(e=>e.enabled))}catch{}}async function oD(e){try{let t=await Ne(`/api/tools?id=${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);iD.closeTool(),await aD();return}catch(e){return e instanceof Error?e.message:String(e)}}var sD=`.super-pi-tool.json`,cD=512e3,lD=/^[a-z0-9][a-z0-9-]{0,63}$/,uD=/^[A-Za-z0-9][A-Za-z0-9_.-]*==[^=\s,;<>|'"`\\]{1,80}$/;function dD(e,t){let n;try{n=JSON.parse(e)}catch{return{ok:!1,reason:`「${t}」不是 JSON。确认一下选的是别人分享的工具文件(${sD})。`}}if(!n||typeof n!=`object`||Array.isArray(n))return{ok:!1,reason:`这个 JSON 不是一个工具包。`};let r=n,i;try{i=lE(r.glyph)}catch{return{ok:!1,reason:`工具图标须为 1 至 4 个字符的文字或符号。`}}let a=typeof r.format==`string`?r.format:void 0;if(a!==void 0&&a!==`super-pi.tool`)return{ok:!1,reason:`这不是 Super Pi 的工具文件(format: ${a})。`};if(typeof r.version==`number`&&r.version>1)return{ok:!1,reason:`这个工具文件是更新版本的 Super Pi 导出的(version: ${r.version}),当前版本读不了。`};let o=typeof r.slug==`string`?r.slug.trim():``,s=typeof r.name==`string`?r.name.trim():``;if(!o)return{ok:!1,reason:`这个工具包里没有 slug(那是它的短名字,也是它在磁盘上的目录名)。`};if(!s)return{ok:!1,reason:`这个工具包里没有名字。`};if(!Array.isArray(r.files)||!r.files.length)return{ok:!1,reason:`这个工具包里没有文件。`};if(r.files.length>32)return{ok:!1,reason:`文件太多了:${r.files.length} 个,上限 32 个。`};let c=[],l=0;for(let e of r.files){let t=e;if(!t||typeof t.path!=`string`||typeof t.content!=`string`)return{ok:!1,reason:`工具包里的文件项格式不对(每一项都要有 path 和 content)。`};let n=t.path.trim();if(!n||n.startsWith(`/`)||n.includes(`\\`)||n.includes(`\0`)||n.split(`/`).includes(`..`))return{ok:!1,reason:`文件路径「${n}」不合法:不能是绝对路径,也不能跳出工具自己的目录。`};if(c.some(e=>e.path===n))return{ok:!1,reason:`工具包里有重复的文件:${n}`};if(l+=new TextEncoder().encode(t.content).length,l>512e3)return{ok:!1,reason:`工具文件合计超过 ${yD(cD)} 的上限。`};c.push({path:n,content:t.content})}let u=typeof r.entrypoint==`string`&&r.entrypoint.trim()?r.entrypoint.trim():`index.html`;if(!u.endsWith(`.html`))return{ok:!1,reason:`入口文件必须是一个 HTML 文件。`};if(!c.some(e=>e.path===u))return{ok:!1,reason:`工具包里没有包含入口文件 ${u}。`};let d;if(r.script!==void 0&&r.script!==null){let e=r.script,t=typeof e.path==`string`?e.path.trim():``;if(!t.endsWith(`.py`))return{ok:!1,reason:`工具包声明的脚本必须是一个 .py 文件。`};if(!c.some(e=>e.path===t))return{ok:!1,reason:`工具包里没有包含它声明的脚本 ${t}。`};d={path:t,timeoutMs:typeof e.timeoutMs==`number`?e.timeoutMs:void 0,parameters:typeof e.parameters==`object`&&e.parameters!==null?e.parameters:void 0}}let f;if(r.environment!==void 0&&r.environment!==null){let e=r.environment,t=e.requires;if(t!==void 0&&!Array.isArray(t))return{ok:!1,reason:`工具包声明的依赖列表格式不对(requires 必须是数组)。`};if(Array.isArray(t)){for(let e of t)if(typeof e!=`string`||!uD.test(e.trim()))return{ok:!1,reason:`依赖必须钉死到精确版本(写成 pkg==version):${String(e).slice(0,60)}。`}}let n=e.fingerprint&&typeof e.fingerprint==`object`?e.fingerprint:void 0;f={requiresPython:typeof e.requiresPython==`string`?e.requiresPython:void 0,requires:Array.isArray(t)?t.map(e=>String(e).trim()):void 0,fingerprint:n}}let p=r.permissions&&typeof r.permissions==`object`&&r.permissions.llm===!0?{llm:!0}:void 0;return{ok:!0,unnamedFormat:a===void 0,bundle:{...a===void 0?{}:{format:a},...typeof r.version==`number`?{version:r.version}:{},...typeof r.exportedAt==`string`?{exportedAt:r.exportedAt}:{},slug:o,name:s,...i?{glyph:i}:{},...typeof r.description==`string`&&r.description.trim()?{description:r.description.trim().slice(0,500)}:{},entrypoint:u,files:c,script:d,environment:f,...p?{permissions:p}:{}}}}function fD(e){let t=e.trim().toLowerCase();return t?lD.test(t)?{ok:!0,slug:t}:{ok:!1,reason:`slug 只能用小写字母、数字和连字符,且要以字母或数字开头。`}:{ok:!1,reason:`请填写 slug(工具的短名字,只能用小写字母、数字和连字符)。`}}function pD(e,t){let n=e.trim().toLowerCase().slice(0,60).replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``)||`tool`;if(!t.includes(n))return n;for(let e=2;e<100;e+=1){let r=`${n}-${e}`;if(!t.includes(r))return r}return n}function mD(e){return`${e.slug}${sD}`}function hD(e){let t=e.trim().replace(/[\\/:*?"<>|]/g,``).replace(/\.+$/,``).trim();return t?t.length>80?{ok:!1,reason:`文件名太长了,请控制在 80 个字符以内。`}:{ok:!0,name:t.endsWith(`.super-pi-tool.json`)?t:`${t}${sD}`}:{ok:!1,reason:`请填写文件名。`}}function gD(e){if(e.permissions?.llm)return{tone:`warn`,text:`这个工具可以调用模型:它能把内容发给你的模型回答,每次调用都会用你的模型额度`}}function _D(e){let t=e.environment?.requires??[];return!e.script&&t.length===0?{tone:`ok`,text:`纯页面工具 · 导入即用,不需要 Python`}:t.length===0?{tone:`ok`,text:`只用 Python 标准库 · 导入即用,不需要安装任何包${e.environment?.requiresPython?`(需要 Python ${e.environment.requiresPython})`:``}`}:{tone:`warn`,text:`首次运行时会安装 ${t.length} 个依赖:${t.join(`、`)}(装进这个工具自己的虚拟环境)${e.environment?.requiresPython?` · 需要 Python ${e.environment.requiresPython}`:``}`}}function vD(e){if(e)return e.state===`zero-deps`?{text:`零依赖`,warn:!1}:e.state===`ready`?{text:`环境就绪`,warn:!1}:e.state===`needs-env`?{text:`首次运行时安装依赖`,warn:!1}:e.state===`needs-python`?{text:`缺少可用的 Python`,warn:!0}:{text:`与导出方环境不一致`,warn:!0}}function yD(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function bD(e,t){let{format:n,version:r,exportedAt:i,...a}=e;return{...a,slug:t}}var xD=`请基于上面的请求、已输出的内容和已完成的操作继续完成任务。优先给出简洁结论或执行必要的小步骤,不要重复已有内容或已成功的写入。`;function SD(e){return/^\s*<continue_output>([\s\S]*?)<\/continue_output>\s*$/.exec(e)?.[1].trim()}function CD(e){return!Number.isFinite(e)||e<=0?``:e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function wD(e){return!Number.isFinite(e)||e<=0?``:e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function TD(e,t){if(!e)return 0;let n=0;for(let r of t)n+=e[r]??0;return n}var ED=128e3;function DD(e){let t=[[]],n=0,r=0,i=[0,0],a=e=>{for(;t.length<=e;)t.push([])},o=e=>{let i=t[n];for(;i.length<r;)i.push(` `);for(let t of e)i[r]=t,r+=1},s=e=>e.replace(/^[?>!]/u,``).split(`;`).map(e=>Number.parseInt(e,10)||0),c=(e,o)=>{let c=s(e),l=Math.max(1,c[0]||1);switch(o){case`A`:n=Math.max(0,n-l);break;case`B`:case`e`:n+=l,a(n);break;case`C`:case`a`:r+=l;break;case`D`:r=Math.max(0,r-l);break;case`E`:n+=l,a(n),r=0;break;case`F`:n=Math.max(0,n-l),r=0;break;case`G`:case"`":r=Math.max(0,l-1);break;case`d`:n=Math.max(0,l-1),a(n);break;case`H`:case`f`:n=Math.max(0,l-1),a(n),r=Math.max(0,(c[1]||1)-1);break;case`K`:{let e=t[n];(c[0]??0)===2?t[n]=[]:(c[0]??0)===1?t[n]=[...Array.from({length:Math.min(r+1,e.length)},()=>` `),...e.slice(r+1)]:e.splice(r);break}case`J`:(c[0]??0)===2||(c[0]??0)===3?(t.splice(0,t.length,[]),n=0,r=0):(c[0]??0)===0?t.splice(n+1):(c[0]??0)===1&&(t.splice(0,n),n=0,t[0]=[]);break;case`s`:i=[n,r];break;case`u`:[n,r]=i,a(n);break;case`P`:t[n].splice(r,l);break;case`X`:{let e=t[n];for(let t=r;t<Math.min(e.length,r+l);t+=1)e[t]=` `;break}case`@`:t[n].splice(r,0,...Array.from({length:l},()=>` `))}},l=t=>{for(let n=t;n<e.length;n+=1){if(e[n]===`\x07`)return n+1;if(e[n]===`\x1B`&&e[n+1]===`\\`)return n+2}return e.length};for(let t=0;t<e.length;){let i=e[t];if(i===``||i===``||i===``||i===``){t=l(t+1);continue}if(i===`\x1B`||i===``){let n=e[t+1];if(i===`\x1B`&&(n===`]`||n===`P`||n===`^`||n===`_`)){t=l(t+2);continue}if(i===`\x1B`&&n===`[`||i===``){let n=t+(i===``?1:2),r=n;for(;r<e.length&&!(e.charCodeAt(r)>=64&&e.charCodeAt(r)<=126);)r+=1;r<e.length&&c(e.slice(n,r),e[r]),t=Math.min(e.length,r+1);continue}t+=n===void 0?1:2;continue}if(i===`\r`){t+=1,r=0;continue}if(i===`
|
|
330
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Sg.get()},set promptLabel(e){Sg.set(e)},get tooMuchOutput(){return wg.get()},set tooMuchOutput(e){wg.set(e)}}}_verifyIntegers(...e){for(fw of e)if(fw===1/0||isNaN(fw)||fw%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(fw of e)if(fw&&(fw===1/0||isNaN(fw)||fw%1!=0||fw<0))throw Error(`This API only accepts positive integers`)}},mw=2,hw=1,gw=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(mw,Math.floor(u/e.css.cell.width)),rows:Math.max(hw,Math.floor(l/e.css.cell.height))}}},_w=`super-pi.terminal-owner.v1`,vw=`super-pi.terminal-selection.v1.`,yw=20,bw=5,xw=240,Sw=120,Cw={checking:`正在连接`,unavailable:`不可用`,starting:`启动中`,running:`运行中`,exited:`已结束`,empty:`没有打开的终端`},ww;function Tw(){if(ww)return ww;try{let e=window.localStorage.getItem(_w);if(e&&/^[0-9a-f]{32}$/.test(e))return ww=e}catch{}ww=Array.from(window.crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);try{window.localStorage.setItem(_w,ww)}catch{}return ww}function Ew(e){try{return window.sessionStorage.getItem(e)??void 0}catch{return}}function Dw({workspaceId:e,workspaceLabel:t,cwd:n=``,connected:r,sendCommand:i,registerSink:a,conversationId:o,terminalShell:s}){let c=vw+JSON.stringify([e,o]),[l,d]=(0,u.useState)([]),[f,p]=(0,u.useState)(()=>Ew(c)??``),[m,h]=(0,u.useState)(!1),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),S=(0,u.useRef)(new Map),C=(0,u.useRef)(new Map),w=(0,u.useRef)(new Map),T=(0,u.useRef)(new Map),E=(0,u.useRef)(!1),D=(0,u.useRef)(f);D.current=f;let O=(0,u.useRef)(!1),k=(0,u.useRef)(void 0),A=(0,u.useCallback)(e=>{let t=C.current.get(e);if(!t||!t.host.clientWidth||!t.host.clientHeight||T.current.has(e))return;let{terminal:n,fitAddon:r}=t,a=r.proposeDimensions();if(!a||!Number.isFinite(a.cols)||!Number.isFinite(a.rows))return;let o=Math.max(yw,Math.min(xw,a.cols)),s=Math.max(bw,Math.min(Sw,a.rows));(n.cols!==o||n.rows!==s)&&n.resize(o,s);let c=S.current.get(e);E.current&&c&&c.exitCode===void 0&&(c.cols!==o||c.rows!==s)&&i({type:`terminal.resize`,sessionId:e,cols:o,rows:s})},[i]),j=(0,u.useCallback)((e,t)=>{let n=e.sessionId;if(e.type===`terminal.output`){t.write(e.data);return}let r=S.current.get(n),i=T.current.get(n);r&&t.resize(r.cols,r.rows),t.write(`\x1Bc\x1B[3J`+e.data,()=>{T.current.get(n)===i&&(T.current.delete(n),D.current===n&&A(n))})},[A]),ee=(0,u.useCallback)((e,t)=>{if(!t||C.current.has(e))return;let n=getComputedStyle(t),r=(e,t)=>n.getPropertyValue(e).trim()||t,a=S.current.get(e),o=new pw({cols:a?.cols,rows:a?.rows,cursorBlink:!0,convertEol:!1,scrollback:5e3,fontFamily:`Consolas, 'Cascadia Mono', 'DejaVu Sans Mono', monospace`,fontSize:12,lineHeight:1.35,theme:{background:`#00000000`,foreground:r(`--term-fg`,`#dbe4f0`),cursor:r(`--term-fg`,`#dbe4f0`),selectionBackground:r(`--term-selection`,`#3a4f6b`)},allowProposedApi:!0}),s=new gw;o.loadAddon(s),o.open(t),o.onData(t=>{E.current&&!T.current.has(e)&&S.current.get(e)?.exitCode===void 0&&i({type:`terminal.input`,sessionId:e,data:t})}),C.current.set(e,{terminal:o,fitAddon:s,host:t});for(let t of w.current.get(e)??[])j(t,o);w.current.delete(e),requestAnimationFrame(()=>A(e))},[A,i,j]),M=(0,u.useCallback)(t=>{if(t.type===`terminal.sessions`){if(t.workspaceId!==e||t.conversationId!==o)return;let n=new Map(t.sessions.map(e=>[e.id,e]));for(let[e,r]of C.current)n.has(e)?!t.replay&&S.current.get(e)?.exitCode!==void 0&&n.get(e)?.exitCode===void 0&&r.terminal.write(`\x1Bc\x1B[3J`):(r.terminal.dispose(),C.current.delete(e));for(let e of w.current.keys())(!n.has(e)||t.replay)&&w.current.delete(e);if(t.replay){T.current.clear();for(let e of n.keys())T.current.set(e,Symbol())}!t.replay&&O.current&&t.activate&&n.has(t.activate)&&(k.current=t.activate,O.current=!1),S.current=n,E.current=!0,d(t.sessions),p(e=>t.activate??(n.has(e)?e:t.sessions[0]?.id??``)),_(void 0),h(!0)}else if(t.type===`terminal.output`||t.type===`terminal.replay`){if(!S.current.has(t.sessionId))return;let e=C.current.get(t.sessionId)?.terminal;if(e)j(t,e);else{let e=w.current.get(t.sessionId)??[];e.push(t),w.current.set(t.sessionId,e)}}else if(t.type===`terminal.size`){let e=S.current.get(t.sessionId);e&&(Object.assign(e,{cols:t.cols,rows:t.rows}),C.current.get(e.id)?.terminal.resize(e.cols,e.rows))}else if(t.type===`terminal.exit`){let e=S.current.get(t.sessionId);if(!e)return;let n={...e,exitCode:t.exitCode,reason:t.reason};S.current.set(n.id,n),d(e=>e.map(e=>e.id===n.id?n:e))}else(t.type===`terminal.error`||t.type===`terminal.status`&&!t.enabled)&&(O.current=!1,_(void 0),y(t.type===`terminal.error`?t.message:t.reason||`终端未启用`))},[o,e,j]);(0,u.useEffect)(()=>(a(M),()=>a(void 0)),[M,a]);let te=(0,u.useCallback)(()=>{E.current=!1,h(!1),_(void 0),y(``),r&&e&&i({type:`terminal.sync`,ownerId:Tw(),workspaceId:e,conversationId:o,cwd:n,initialize:Ew(c)===void 0})},[r,e,o,n,c,i]);(0,u.useEffect)(()=>(te(),()=>{r&&i({type:`terminal.detach`})}),[r,i,te]),(0,u.useEffect)(()=>()=>{for(let e of C.current.values())e.terminal.dispose();C.current.clear()},[]),(0,u.useEffect)(()=>{if(m)try{window.sessionStorage.setItem(c,f)}catch{}},[f,m,c]),(0,u.useEffect)(()=>{let e=!1;return Ne(`/api/terminal-shell`).then(e=>e.json()).then(t=>{let n=t.shell;!e&&n&&x(n.file+(n.args.length?` `+n.args.join(` `):``)+`(`+(t.source??``)+`)`)}).catch(()=>void 0),()=>{e=!0}},[s?.file,s?.args.join(`\0`)]),(0,u.useLayoutEffect)(()=>{let e=C.current.get(f);if(!e)return;let t=new ResizeObserver(()=>A(f));if(t.observe(e.host),A(f),k.current===f){let e=f;requestAnimationFrame(()=>{k.current===e&&(C.current.get(e)?.terminal.focus(),k.current=void 0)})}return()=>t.disconnect()},[f,A,l]);let N=e=>!r||!m||g?!1:i(e)?(y(``),_(e.type===`terminal.open`?`open`:`close`),!0):!1,ne=e=>{let t=C.current.get(f)?.terminal;O.current=!0,N({type:`terminal.open`,sessionId:e,cols:t?.cols,rows:t?.rows})||(O.current=!1)},re=l.find(e=>e.id===f),ie=r&&m&&!g,ae=e?r?m?g===`open`?`starting`:re?re.exitCode===void 0?`running`:`exited`:`empty`:v?`unavailable`:`checking`:`checking`:`unavailable`,oe=v||re?.reason;return(0,F.jsxs)(`div`,{className:`terminal-panel`,"data-terminal-panel":`1`,"data-terminal-phase":ae,children:[(0,F.jsxs)(`div`,{className:`terminal-strip`,role:`tablist`,"aria-label":`终端会话`,"data-terminal-strip":`1`,children:[l.map(e=>(0,F.jsxs)(`div`,{className:`terminal-tab${e.id===f?` is-active`:``}`,children:[(0,F.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===f,className:`terminal-tab-btn`,"data-terminal-slot":e.id,onClick:()=>p(e.id),title:Cw[e.exitCode===void 0?`running`:`exited`],children:[(0,F.jsx)(`span`,{className:`terminal-tab-dot terminal-tab-dot-${e.exitCode===void 0?`running`:`exited`}`,"aria-hidden":`true`}),e.title]}),(0,F.jsx)(`button`,{type:`button`,className:`terminal-tab-close`,disabled:!ie,"aria-label":`关闭终端 ${e.title}`,"data-terminal-slot-close":e.id,onClick:()=>N({type:`terminal.close`,sessionId:e.id}),children:`×`})]},e.id)),l.length<5&&(0,F.jsx)(`button`,{type:`button`,className:`terminal-strip-add`,disabled:!ie,"data-terminal-add":`1`,onClick:()=>ne(),title:`新建终端`,"aria-label":`新建终端`,children:`+`})]}),(0,F.jsxs)(`div`,{className:`terminal-toolbar`,children:[(0,F.jsxs)(`span`,{className:`terminal-status terminal-status-${ae}`,"data-terminal-status":ae,children:[(0,F.jsx)(`span`,{className:`terminal-status-dot`,"aria-hidden":`true`}),Cw[ae]]}),(0,F.jsxs)(`span`,{className:`terminal-toolbar-right`,children:[b&&(0,F.jsx)(`span`,{className:`terminal-cwd`,"data-terminal-shell-hint":`1`,title:b,children:b}),t&&(0,F.jsx)(`span`,{className:`terminal-cwd`,"data-terminal-hint":`1`,title:t,children:t}),re?.exitCode!==void 0&&(0,F.jsx)(`button`,{type:`button`,className:`terminal-restart-btn`,"data-terminal-restart":`1`,disabled:!ie,onClick:()=>ne(re.id),children:`重新打开`}),!m&&v&&r&&(0,F.jsx)(`button`,{type:`button`,className:`terminal-restart-btn`,onClick:te,children:`重试连接`})]})]}),oe&&(0,F.jsx)(`p`,{className:`tool-error`,"data-terminal-error":`1`,role:`alert`,title:kr(oe),children:Or(oe,`终端出错了。`)}),re?.exitCode!==void 0&&re.exitCode!==0&&(0,F.jsxs)(`p`,{className:`tool-error`,"data-terminal-exit":`1`,children:[`会话已结束,退出码 `,re.exitCode,`。`]}),(0,F.jsxs)(`div`,{className:`terminal-surface`,"data-terminal-surface":`1`,children:[l.map(e=>(0,F.jsx)(`div`,{ref:t=>ee(e.id,t),className:`terminal-xterm-host`,"data-terminal-xterm":e.id,style:{display:e.id===f?`block`:`none`}},e.id)),ae===`empty`&&(0,F.jsx)(`div`,{className:`terminal-surface-empty`,"data-terminal-empty":`1`,children:(0,F.jsx)(`p`,{className:`rail-empty`,children:Cw.empty})}),!re&&ae===`checking`&&(0,F.jsx)(`p`,{className:`rail-empty terminal-surface-message`,"data-terminal-phase":`checking`,children:`正在连接终端…`}),!e&&(0,F.jsx)(`p`,{className:`rail-empty terminal-surface-message`,children:`选择一个工作区后即可打开终端。`})]})]})}function Ow({id:e,title:t,icon:n,count:r,actions:i,children:a}){let o=(0,u.useId)();return(0,F.jsxs)(`section`,{className:`rail-card`,"data-rail-section":e,"aria-labelledby":o,children:[(0,F.jsxs)(`div`,{className:`rail-section-head`,children:[(0,F.jsxs)(`h2`,{className:`rail-section-title`,id:o,children:[(0,F.jsx)(kw,{kind:n}),t]}),r&&(0,F.jsx)(`span`,{className:`rail-section-count`,children:r}),i]}),(0,F.jsx)(`div`,{className:`rail-card-body`,children:a})]})}function kw({kind:e}){return(0,F.jsx)(`svg`,{className:`rail-section-icon`,viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e===`tasks`?(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(`path`,{d:`m3 6 2 2 3-4M11 6h10M3 13h5m3 0h10M3 20h5m3 0h10`})}):e===`clock`?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,F.jsx)(`path`,{d:`M12 7v5l3 2`})]}):(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(`path`,{d:`M3 12h4l3-7 4 14 3-7h4`})})})}var Aw=[{day:1,label:`一`},{day:2,label:`二`},{day:3,label:`三`},{day:4,label:`四`},{day:5,label:`五`},{day:6,label:`六`},{day:0,label:`日`}];function jw(e){return e.kind===`interval`?`每隔 ${e.everyMinutes} 分钟`:e.kind===`daily`?`每天 ${e.time}`:e.kind===`weekly`?`每周${e.weekdays.map(e=>Aw.find(t=>t.day===e)?.label??`?`).join(`、`)} ${e.time}`:`仅一次:${Mw(e.at)}`}function Mw(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function Nw(){return typeof Intl<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0}function Pw(e,t){let n=new Date(e);if(!t){let e=e=>String(e).padStart(2,`0`);return`${n.getFullYear()}-${e(n.getMonth()+1)}-${e(n.getDate())} ${e(n.getHours())}:${e(n.getMinutes())}`}let r=new Intl.DateTimeFormat(`en-CA`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(n),i=e=>r.find(t=>t.type===e)?.value??``;return`${i(`year`)}-${i(`month`)}-${i(`day`)} ${i(`hour`)}:${i(`minute`)}`}function Fw(e,t){let n=new Date(e);if(!t){let e=e=>String(e).padStart(2,`0`);return`${e(n.getHours())}:${e(n.getMinutes())}`}let r=new Intl.DateTimeFormat(`en-GB`,{timeZone:t,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(n),i=e=>r.find(t=>t.type===e)?.value??``;return`${i(`hour`)}:${i(`minute`)}`}function Iw(e,t){if(!e)return``;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).formatToParts(t).find(e=>e.type===`timeZoneName`)?.value??e}catch{return e}}function Lw(e,t,n){let r=Fw(e,n),i=Rw(e,t,n);return i===0?`今天 ${r}`:i===1?`明天 ${r}`:Pw(e,n)}function Rw(e,t,n){let r=e=>{let[t]=Pw(e,n).split(` `),[r,i,a]=t.split(`-`).map(Number);return Date.UTC(r,i-1,a)},i=Math.round((r(e)-r(t))/864e5);return Number.isFinite(i)?i:0}function zw(e,t,n){if(!e||!t||e===t)return``;let r=Iw(e,n),i=Iw(t,n);return Fw(n,e)===Fw(n,t)?`服务器在 ${r} 时区,你的时区也是 ${i},下面的时间按你的时区显示`:`服务器在 ${r} 时区,下面的时间按你的时区(${i})显示`}function Bw(e,t,n){return e.enabled?e.nextRunAt===void 0?{glyph:`✓`,word:`已结束`,detail:``}:{glyph:`●`,word:`启用中`,detail:`下次 ${Lw(e.nextRunAt,t,n)}`}:e.schedule.kind===`once`&&e.lastRunAt!==void 0?{glyph:`✓`,word:`已结束`,detail:e.lastRunAt?`上次 ${Pw(e.lastRunAt,n)}`:``}:{glyph:`○`,word:`已停用`,detail:``}}function Vw(e,t){if(e.lastRunAt===void 0)return``;let n=Pw(e.lastRunAt,t);return e.lastRunStatus===`failed`?`上次 ${n} · 失败${e.lastRunMessage?`:${e.lastRunMessage}`:``}`:`上次 ${n} · 成功`}function Hw({tasks:e,workspaceId:t,catalog:n,agents:r,sendCommand:i,notify:a,serverTimeZone:o}){let[s,c]=(0,u.useState)(()=>Date.now()),[l,d]=(0,u.useState)();(0,u.useEffect)(()=>{let e=window.setInterval(()=>c(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let f=Nw(),p=zw(o,f,s),m=e=>{i({type:`scheduledTask.toggle`,id:e.id,enabled:!e.enabled})},h=e=>{i({type:`scheduledTask.trigger`,id:e.id}),a(`已触发「${e.name}」,结果会出现在它自己的会话里。`,`info`)},g=e=>{i({type:`scheduledTask.delete`,id:e.id}),a(`已删除定时任务「${e.name}」,它的会话和结果保留着。`,`info`)};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(Ow,{id:`scheduled`,title:`定时任务`,icon:`clock`,count:(0,F.jsx)(`span`,{"data-sched-count":`1`,children:e.length?`${e.length} 个`:`0 个`}),actions:(0,F.jsx)(`button`,{type:`button`,className:`scheduled-add`,"data-sched-add":`1`,title:`新建定时任务`,onClick:()=>d(`new`),children:`+ 新建`}),children:[p&&(0,F.jsx)(`p`,{className:`scheduled-zone-note`,"data-sched-zone-note":`1`,children:p}),e.length>0?(0,F.jsx)(`ul`,{className:`scheduled-list`,"data-sched-list":`1`,children:e.map(e=>{let t=Bw(e,s,f),n=Vw(e,f);return(0,F.jsxs)(`li`,{className:`scheduled-item`,"data-scheduled-task":e.id,children:[(0,F.jsx)(`button`,{type:`button`,className:`scheduled-toggle`,"data-sched-toggle":`1`,title:e.enabled?`点击停用`:`点击启用`,"aria-label":e.enabled?`停用 ${e.name}`:`启用 ${e.name}`,onClick:()=>m(e),children:t.glyph}),(0,F.jsxs)(`div`,{className:`scheduled-main`,children:[(0,F.jsxs)(`div`,{className:`scheduled-name-row`,children:[(0,F.jsx)(`span`,{className:`scheduled-name`,children:e.name}),(0,F.jsx)(`span`,{className:`scheduled-status-word`,"data-sched-word":`1`,children:t.word}),e.createdBy===`agent`&&(0,F.jsx)(`span`,{className:`scheduled-by`,title:`这个定时任务是 agent 创建的,你可以像编辑自己建的一样编辑它`,children:`agent`})]}),(0,F.jsxs)(`div`,{className:`scheduled-meta`,"data-sched-meta":`1`,children:[jw(e.schedule),t.detail?` · ${t.detail}`:``]}),n&&(0,F.jsx)(`div`,{className:`scheduled-last`,"data-sched-last":`1`,children:n})]}),(0,F.jsxs)(`div`,{className:`scheduled-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`scheduled-action`,"data-sched-trigger":`1`,title:`立即执行一次(不改变周期)`,"aria-label":`立即执行 ${e.name}`,onClick:()=>h(e),children:`⚡`}),(0,F.jsx)(`button`,{type:`button`,className:`scheduled-action`,"data-sched-edit":`1`,title:`编辑`,"aria-label":`编辑 ${e.name}`,onClick:()=>d(e),children:`✎`}),(0,F.jsx)(`button`,{type:`button`,className:`scheduled-action scheduled-action-danger`,"data-sched-delete":`1`,title:`删除(会话与结果保留)`,"aria-label":`删除 ${e.name}`,onClick:()=>g(e),children:`✕`})]})]},e.id)})}):(0,F.jsx)(`p`,{className:`rail-empty`,"data-sched-empty":`1`,children:`还没有定时任务。可以新建周期任务,或让 AI 安排。`})]}),l!==void 0&&(0,F.jsx)(Kw,{task:l===`new`?void 0:l,workspaceId:t,catalog:n,agents:r,sendCommand:i,notify:a,onClose:()=>d(void 0)},l===`new`?`new`:l.id)]})}function Uw(e){let t=e?.schedule;return{name:e?.name??``,prompt:e?.prompt??``,kind:t?.kind??`daily`,everyMinutes:t?.kind===`interval`?String(t.everyMinutes):`30`,time:t&&(t.kind===`daily`||t.kind===`weekly`)?t.time:`09:00`,weekdays:t?.kind===`weekly`?[...t.weekdays]:[1],onceAt:t?.kind===`once`?Ww(t.at):``,modelKey:e?.model?`${e.model.provider}/${e.model.modelId}`:``,agentId:e?.agentId??``}}function Ww(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Gw(e){if(e.kind===`interval`){let t=Number(e.everyMinutes);return!Number.isInteger(t)||t<1||t>10080?{ok:!1,reason:`间隔分钟数要是一个 1 到 10080 之间的整数。`}:{ok:!0,schedule:{kind:`interval`,everyMinutes:t}}}if(e.kind===`daily`||e.kind===`weekly`){let t=/^(\d{1,2}):(\d{2})$/.exec(e.time.trim()),n=t?Number(t[1]):NaN,r=t?Number(t[2]):NaN;if(!t||n>23||r>59)return{ok:!1,reason:`触发时刻要写成 HH:MM,比如 09:00。`};let i=`${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`;return e.kind===`daily`?{ok:!0,schedule:{kind:`daily`,time:i}}:e.weekdays.length?{ok:!0,schedule:{kind:`weekly`,weekdays:[...e.weekdays].sort((e,t)=>e-t),time:i}}:{ok:!1,reason:`每周任务至少要选一天。`}}if(!e.onceAt)return{ok:!1,reason:`选一下这一次的运行时刻。`};let t=new Date(e.onceAt).getTime();return Number.isNaN(t)?{ok:!1,reason:`这一次的运行时刻不是有效时间。`}:{ok:!0,schedule:{kind:`once`,at:t}}}function Kw({task:e,workspaceId:t,catalog:n,agents:r,sendCommand:i,notify:a,onClose:o}){let[s,c]=(0,u.useState)(()=>Uw(e)),[l,d]=(0,u.useState)();(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let f=e=>{c(t=>({...t,...e})),d(void 0)};return(0,Re.createPortal)((0,F.jsx)(`div`,{className:`tool-overlay`,"data-sched-dialog-overlay":`1`,onClick:e=>{e.target===e.currentTarget&&o()},children:(0,F.jsxs)(`div`,{className:`tool-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`scheduled-dialog-title`,"data-sched-dialog":`1`,children:[(0,F.jsxs)(`div`,{className:`tool-dialog-head`,children:[(0,F.jsx)(`h2`,{className:`tool-dialog-title`,id:`scheduled-dialog-title`,children:e?`编辑定时任务`:`新建定时任务`}),(0,F.jsx)(`button`,{type:`button`,className:`tool-dialog-close`,"data-sched-dialog-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭定时任务编辑`,onClick:o,children:`✕`})]}),(0,F.jsxs)(`div`,{className:`tool-dialog-body scheduled-form`,children:[(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`名称`}),(0,F.jsx)(`input`,{className:`scheduled-input`,"data-sched-field":`name`,value:s.name,placeholder:`留空则取提示词首句`,onChange:e=>f({name:e.target.value})})]}),(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`提示词`}),(0,F.jsx)(`textarea`,{className:`scheduled-textarea`,"data-sched-field":`prompt`,rows:5,value:s.prompt,placeholder:`到点时这段话会作为用户消息发给 agent,所以它要是一条完整、自包含的指令`,onChange:e=>f({prompt:e.target.value})})]}),(0,F.jsxs)(`div`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`周期`}),(0,F.jsx)(`div`,{className:`scheduled-kind-row`,role:`radiogroup`,"aria-label":`周期类型`,children:[[`interval`,`每隔 N 分钟`],[`daily`,`每天`],[`weekly`,`每周`],[`once`,`仅一次`]].map(([e,t])=>(0,F.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":s.kind===e,className:`scheduled-kind${s.kind===e?` scheduled-kind-active`:``}`,"data-sched-kind":e,onClick:()=>f({kind:e}),children:t},e))})]}),s.kind===`interval`&&(0,F.jsxs)(`label`,{className:`scheduled-field scheduled-field-inline`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`间隔`}),(0,F.jsx)(`input`,{className:`scheduled-input scheduled-input-narrow`,"data-sched-field":`everyMinutes`,inputMode:`numeric`,value:s.everyMinutes,onChange:e=>f({everyMinutes:e.target.value})}),(0,F.jsx)(`span`,{className:`scheduled-hint`,children:`分钟(1 – 10080)`})]}),(s.kind===`daily`||s.kind===`weekly`)&&(0,F.jsxs)(`label`,{className:`scheduled-field scheduled-field-inline`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`时刻`}),(0,F.jsx)(`input`,{className:`scheduled-input scheduled-input-narrow`,"data-sched-field":`time`,inputMode:`numeric`,placeholder:`09:00`,value:s.time,onChange:e=>f({time:e.target.value})}),(0,F.jsx)(`span`,{className:`scheduled-hint`,children:`服务器本地时间,每天/每周的这一天到点触发`})]}),s.kind===`weekly`&&(0,F.jsxs)(`div`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`星期`}),(0,F.jsx)(`div`,{className:`scheduled-weekdays`,children:Aw.map(({day:e,label:t})=>{let n=s.weekdays.includes(e);return(0,F.jsx)(`button`,{type:`button`,"aria-pressed":n,className:`scheduled-weekday${n?` scheduled-weekday-on`:``}`,"data-sched-weekday":e,onClick:()=>f({weekdays:n?s.weekdays.filter(t=>t!==e):[...s.weekdays,e]}),children:t},e)})})]}),s.kind===`once`&&(0,F.jsxs)(`label`,{className:`scheduled-field scheduled-field-inline`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`时刻`}),(0,F.jsx)(`input`,{className:`scheduled-input`,type:`datetime-local`,"data-sched-field":`onceAt`,value:s.onceAt,onChange:e=>f({onceAt:e.target.value})}),(0,F.jsx)(`span`,{className:`scheduled-hint`,children:`这一次运行之后就结束`})]}),(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`模型`}),(0,F.jsxs)(`select`,{className:`scheduled-input`,"data-sched-field":`model`,value:s.modelKey,onChange:e=>f({modelKey:e.target.value}),children:[(0,F.jsx)(`option`,{value:``,children:`跟随工作区默认`}),(n?.models??[]).map(e=>(0,F.jsxs)(`option`,{value:`${e.provider}/${e.modelId}`,children:[e.label,`(`,e.detail,`)`]},`${e.provider}/${e.modelId}`))]})]}),(0,F.jsxs)(`label`,{className:`scheduled-field`,children:[(0,F.jsx)(`span`,{className:`scheduled-label`,children:`Agent`}),(0,F.jsxs)(`select`,{className:`scheduled-input`,"data-sched-field":`agent`,value:s.agentId,onChange:e=>f({agentId:e.target.value}),children:[(0,F.jsx)(`option`,{value:``,children:`跟随工作区默认`}),(r?.agents??[]).map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name??e.id},e.id))]})]}),l&&(0,F.jsx)(`p`,{className:`scheduled-error`,"data-sched-error":`1`,role:`alert`,children:l}),(0,F.jsxs)(`div`,{className:`scheduled-actions-row`,children:[(0,F.jsx)(`button`,{type:`button`,className:`scheduled-cancel`,onClick:o,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`scheduled-save`,"data-sched-save":`1`,onClick:()=>{let r=s.prompt.trim();if(!r){d(`定时任务需要一段提示词:到点时这段话会被当作用户消息发给 agent。`);return}if(!t){d(`先选一个工作区,再建定时任务。`);return}let c=Gw(s);if(!c.ok){d(c.reason);return}let l=n?.models.find(e=>`${e.provider}/${e.modelId}`===s.modelKey),u=l?{provider:l.provider,modelId:l.modelId,label:l.label}:null,f=s.agentId||null,p=s.name.trim()||void 0;i(e?{type:`scheduledTask.update`,id:e.id,name:p,prompt:r,schedule:c.schedule,model:u,agentId:f}:{type:`scheduledTask.create`,name:p,prompt:r,schedule:c.schedule,workspaceId:t,model:u,agentId:f})?(a(e?`已保存对「${s.name.trim()||e.name}」的修改。`:`定时任务已创建,到点会自动运行。`,`info`),o()):d(`连接已断开,没能保存。等重连后再试一次。`)},children:e?`保存修改`:`创建任务`})]})]})]})}),document.body)}function qw(e){return e.status===`open`&&(e.audience===`boss`||e.audience===void 0)}function Jw(e){return(e.escalations??[]).filter(qw)}function Yw(e){let t=e.filter(e=>Jw(e).length>0);return{projects:t.length,cases:t.reduce((e,t)=>e+Jw(t).length,0)}}function Xw(e,t=!1){return[`cancelled`,`failed`].includes(e.status??``)?!0:t}function Zw(e,t,n){let r=Xw(e,t),i=Jw(e).length>0;return n===`history`?r&&!i:!r||i}function Qw(e){return(e.reports??[]).filter(t=>!t.taskId&&[`progress`,`delivery`].includes(t.kind??``)&&(t.authorConversationId===e.ownerConversationId&&!!e.ownerConversationId||t.kind===`delivery`&&!t.authorConversationId))}function $w(e){return[...e.reports??[]].reverse().find(t=>t.kind===`delivery`&&!t.taskId&&(!t.authorConversationId||t.authorConversationId===e.ownerConversationId))}function eT(e){let t=Jw(e),n=[...Qw(e)].reverse().find(e=>e.kind===`progress`),r=$w(e),i=[`cancelled`,`failed`].includes(e.status),a=e.resources?.sessions?.find(t=>t.id===e.ownerConversationId),o=(e.resources?.activeWorkers??0)>0||[`running`,`waiting`,`awaiting_background`].includes(a?.status??``);return{label:e.status===`cancelled`?`已取消`:e.status===`failed`?`执行暂停`:t.length?`需要你决定`:o?`正在推进`:e.ownerConversationId?[`failed`,`stopped`].includes(a?.status??``)?`执行暂停`:r?`待继续`:`未交付`:`待启动`,summary:n?.progress?.trim()||n?.summary?.trim()||(i?`项目已结束,已有记录会保留。`:r?`可继续安排新任务或追加验证。`:`已交由负责人推进,进展和成果会在这里汇总。`),progress:n,delivery:r,decisions:t,ended:i,deliveryLabel:e.mode===`lightweight`?`自评交付`:`交付成果`}}var tT=/\.[A-Za-z][A-Za-z0-9]{0,9}$/,nT=new Set([`makefile`,`dockerfile`,`license`,`readme`,`changelog`]),rT=/^[A-Za-z]:/;function iT(e){let t=(e??``).trim();if(!t||/\s/.test(t)||t.includes(`://`)||t.startsWith(`/`)||t.startsWith(`\\`)||rT.test(t))return;let n=t.split(/[\\/]/);if(n.some(e=>e===``||e===`.`||e===`..`))return;let r=n[n.length-1];if(tT.test(r)||nT.has(r.toLowerCase()))return n.join(`/`)}function aT(e){return/\s/.test(e)||e.includes(`://`)||e.startsWith(`/`)||e.startsWith(`\\`)||rT.test(e)?!1:!e.split(/[\\/]/).some(e=>e===``||e===`.`||e===`..`)}function oT(e){let t=e.split(/[\\/]/);return t[t.length-1]||e}function sT(e,t){let n=iT(e);if(!n)return;let r=(t??``).trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``);if(!r)return n;if(aT(r))return n===r||n.startsWith(`${r}/`)?n:`${r}/${n}`}function cT(e,t){let n=(e??``).trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``);if(!n)return;let r=(t??``).trim().replaceAll(`\\`,`/`).replace(/^\/+|\/+$/g,``);if(!r)return n;if(n!==r&&n.startsWith(`${r}/`))return n.slice(r.length+1)}function lT(e){return[`cancelled`,`failed`].includes(e.status??``)}function uT(e,t){return e.filter(e=>Zw(e,e.ownerArchived===!0,t?`history`:`current`))}function dT(e){let[t,n]=(0,u.useState)(0),r=(0,u.useRef)(null),i=(0,u.useRef)(null);return(0,u.useLayoutEffect)(()=>{let e=()=>{let e=r.current,t=i.current;if(!e||!t)return;let a=getComputedStyle(e),o=Number.parseFloat(a.lineHeight)||Number.parseFloat(a.fontSize)*1.6||16,s=t.getBoundingClientRect().height;n(Math.max(1,Math.round(s/o)))};e();let t=typeof ResizeObserver==`function`?new ResizeObserver(()=>e()):null;return t&&(r.current&&t.observe(r.current),i.current&&t.observe(i.current)),window.addEventListener(`resize`,e),()=>{t?.disconnect(),window.removeEventListener(`resize`,e)}},[e]),{lines:t,visible:r,measured:i}}function fT({text:e,what:t}){let[n,r]=(0,u.useState)(!1),{lines:i,visible:a,measured:o}=dT(e),s=Math.max(0,i-2);return e?(0,F.jsxs)(`div`,{className:`project-prose-wrap`,children:[(0,F.jsx)(`p`,{className:`project-prose${n?` project-prose-open`:``}`,"data-prose-text":!0,ref:a,children:e}),(0,F.jsx)(`span`,{className:`project-prose-measure`,"aria-hidden":`true`,ref:o,children:e}),s>0?(0,F.jsx)(`button`,{type:`button`,className:`project-prose-expand`,"data-prose-expand":!0,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`收起${t}`:`展开完整${t}(还有 ${s} 行)`}):null]}):null}function pT({refs:e,baseCwd:t,cwd:n,onOpenFile:r}){return(0,F.jsx)(`ul`,{children:e.map((e,i)=>{let a=sT(e,t),o=a?cT(a,n):void 0;return(0,F.jsx)(`li`,{children:o&&r?(0,F.jsx)(`button`,{type:`button`,className:`project-evidence-path`,"data-team-evidence-file":o,onClick:()=>r({path:o,name:oT(o),text:null}),children:e}):e},i)})})}function mT(e){if(!e)return``;let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=Math.max(0,Math.floor((Date.now()-t)/1e3));return n<60?`刚刚`:n<3600?`${Math.floor(n/60)} 分钟前`:n<86400?`${Math.floor(n/3600)} 小时前`:`${Math.floor(n/86400)} 天前`}async function hT(e){let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(typeof t?.error==`string`?t.error:`请求失败(${e.status})`);return t}async function gT(e){let t=(await e.text().catch(()=>``)).trim();if(!t)return`报告打不开(${e.status})`;try{let n=JSON.parse(t);return n&&typeof n==`object`&&typeof n.error==`string`&&n.error.trim()?n.error.trim():`报告打不开(${e.status})`}catch{return t}}function _T(e,t){return`/api/projects/${encodeURIComponent(e)}/report?workspaceId=${encodeURIComponent(t??``)}`}function vT(e,t=60){let n=(e??``).replace(/\s+/g,` `).trim();return n?n.length<=t?n:`${n.slice(0,t-1)}…`:``}function yT(e){let t=(e.title??``).trim();if(t)return t;let n=(e.reason??``).trim();return n?n.match(/^[\s\S]*?[。!?!?]/)?.[0]?.trim()||n:`需要处理`}var bT={decision:0,delivery:1},xT=5;function ST(e,t){let n=Jw(e)[0],r={projectId:e.id,projectTitle:e.title,updatedAt:Date.parse(e.updatedAt??``)||0};if(n)return{...r,reminderId:`${e.id}:decision:${Jw(e).map(e=>e.id).join(`,`)}`,kind:`decision`,label:`要你决定`,detail:vT(n.title||n.reason||`需要你的决定`,lT(e)?36:60)+(lT(e)?`(项目已结束:记录后不会唤醒任何人)`:``),actionLabel:`去看看`,target:{kind:`exception`,escalationId:n.id}};let i=eT(e).delivery,a=Date.parse(i?.createdAt??``);return!i||!Number.isFinite(a)||t-a>864e5?null:{...r,updatedAt:a,reminderId:`${e.id}:delivery:${i.id}`,kind:`delivery`,label:`阶段交付`,detail:vT(i.progress||i.summary||`已提交阶段成果`),actionLabel:`查看交付`,target:{kind:`top`}}}function CT({text:e}){let[t,n]=(0,u.useState)(!1),{lines:r,visible:i,measured:a}=dT(e),o=Math.max(0,r-2);return e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`project-exception-reason-wrap`,children:[(0,F.jsx)(`p`,{className:`project-exception-reason${t?` project-exception-reason-open`:``}`,"data-project-exception-reason":!0,ref:i,children:e}),(0,F.jsx)(`span`,{className:`project-exception-reason-measure`,"aria-hidden":`true`,ref:a,children:e})]}),o>0&&(0,F.jsx)(`button`,{type:`button`,className:`project-exception-expand`,"data-project-exception-expand":!0,"aria-expanded":t,onClick:()=>n(e=>!e),children:t?`收起理由`:`展开完整理由(还有 ${o} 行)`})]}):null}function wT({item:e,project:t,busy:n,onResolve:r,onReturn:i}){let[a,o]=(0,u.useState)(``),s=lT(t);return(0,F.jsxs)(`li`,{className:`project-exception`,"data-project-exception":e.id,children:[(0,F.jsx)(`strong`,{className:`project-exception-title`,"data-project-exception-title":!0,children:yT(e)}),e.reason&&(0,F.jsx)(CT,{text:e.reason}),s&&(0,F.jsx)(`p`,{className:`project-exception-ended`,"data-project-exception-ended":!0,"data-project-exception-ended-note":!0,children:`项目已结束:你的处理意见会记进项目记录,但不会唤醒任何人。`}),(0,F.jsxs)(`label`,{className:`project-decision-label`,children:[`你的决定`,(0,F.jsx)(`textarea`,{"data-project-decision":e.id,"data-project-exception-decision":!0,value:a,onChange:e=>o(e.target.value),disabled:n})]}),(0,F.jsxs)(`div`,{className:`project-detail-actions`,children:[(0,F.jsx)(`button`,{type:`button`,"data-project-decision-submit":e.id,"data-project-exception-resolve":!0,disabled:n||!a.trim(),onClick:()=>r(a.trim()),children:s?`记录处理意见`:`记录决定并答复主会话`}),(0,F.jsx)(`button`,{type:`button`,"data-project-decision-return":e.id,"data-project-exception-return":!0,disabled:n||!a.trim(),onClick:()=>i(a.trim()),children:`退回补充`})]})]})}function TT({project:e,workspaceId:t,notify:n,onOpenSession:r,onOpenFile:i,cwd:a,onChanged:o}){let s=eT(e),[c,l]=(0,u.useState)(!1),[d,f]=(0,u.useState)(``),[p,m]=(0,u.useState)(!1),[h,g]=(0,u.useState)(``),[_,v]=(0,u.useState)(``),y=(0,u.useRef)(``);(0,u.useEffect)(()=>()=>{y.current&&URL.revokeObjectURL(y.current)},[]);let b=async(r,i,a={})=>{if(t&&!c){l(!0),f(``);try{await Ne(`/api/projects/${encodeURIComponent(e.id)}/${r}`,{method:i,headers:{"content-type":`application/json`},body:JSON.stringify({...a,workspaceId:t})}).then(hT),await o?.(),n?.(`已记录并交给负责人`,`info`)}catch(e){f(e instanceof Error?e.message:`操作失败`)}finally{l(!1)}}},x=async()=>{if(t&&!p){m(!0),g(``);try{let n=await Ne(_T(e.id,t));if(!n.ok){g(await gT(n));return}let r=await n.text();y.current&&URL.revokeObjectURL(y.current);let i=URL.createObjectURL(new Blob([r],{type:`text/plain;charset=utf-8`}));y.current=i,v(i),window.open(i,`_blank`,`noopener`)}catch(e){g(e instanceof Error?e.message:`报告打不开`)}finally{m(!1)}}},S=e.resources?.usage,C=s.delivery?.evidenceRefs??[],w=e.resources?.sessions?.find(t=>t.id===e.ownerConversationId),T=!e.ownerConversationId||!!(w&&[`failed`,`stopped`].includes(w.status??``)&&!e.resources?.activeWorkers);return(0,F.jsxs)(`div`,{className:`project-detail project-overview`,"data-project-detail":e.id,children:[e.objective&&(0,F.jsxs)(`div`,{className:`project-goal`,children:[(0,F.jsx)(`span`,{children:`项目目标`}),(0,F.jsx)(`p`,{className:`project-detail-objective`,children:e.objective})]}),(0,F.jsxs)(`section`,{className:`project-section`,"data-project-owner-summary":!0,children:[(0,F.jsx)(`h3`,{children:`当前进展`}),(0,F.jsx)(fT,{text:s.summary,what:`进展`}),e.updatedAt&&(0,F.jsxs)(`p`,{className:`project-overview-time`,children:[mT(e.updatedAt),`更新`]})]}),s.delivery&&(0,F.jsxs)(`section`,{className:`project-section`,"data-project-stage-delivery":!0,children:[(0,F.jsx)(`h3`,{children:s.deliveryLabel}),(0,F.jsx)(fT,{text:s.delivery.progress||s.delivery.summary||`已提交阶段成果`,what:`交付`}),C.length?(0,F.jsx)(pT,{refs:C,baseCwd:e.resources?.ownerCwd??w?.cwd,cwd:a,onOpenFile:i}):(0,F.jsx)(`p`,{"data-project-no-evidence":!0,children:`未附可核对的交付证据。`})]}),s.decisions.length>0&&(0,F.jsxs)(`section`,{className:`project-section`,"data-project-exception-section":!0,children:[(0,F.jsx)(`h3`,{"data-project-exception-heading":!0,children:`需要你决定`}),(0,F.jsx)(`ul`,{className:`project-exception-list`,children:s.decisions.map(t=>(0,F.jsx)(wT,{item:t,project:e,busy:c,onResolve:e=>void b(`escalations/${encodeURIComponent(t.id)}`,`PATCH`,{decision:e,status:`resolved`}),onReturn:e=>void b(`escalations/${encodeURIComponent(t.id)}`,`PATCH`,{decision:e,status:`returned`})},t.id))})]}),d&&(0,F.jsx)(`p`,{className:`project-error`,role:`alert`,children:d}),(0,F.jsxs)(`div`,{className:`project-detail-actions project-overview-actions`,children:[w&&r&&(0,F.jsx)(`button`,{type:`button`,className:T&&!s.ended?``:`project-primary-action`,"data-project-open-owner":!0,onClick:()=>r(w.id),children:`查看负责人会话`}),!s.ended&&T&&(0,F.jsx)(`button`,{type:`button`,className:`project-primary-action`,disabled:c,"data-project-resume":!0,onClick:()=>void b(`start`,`POST`),children:`让负责人继续`}),!s.ended&&(0,F.jsx)(`button`,{type:`button`,className:`project-stop-action`,disabled:c,"data-project-stop":!0,onClick:()=>void b(``,`PATCH`,{status:`cancelled`}),children:`停止项目`}),(0,F.jsx)(`button`,{type:`button`,disabled:p,"data-project-report":e.id,onClick:()=>void x(),children:p?`正在读取…`:`导出记录`})]}),h&&(0,F.jsx)(`p`,{className:`project-error`,role:`alert`,"data-project-report-error":!0,children:h}),_&&(0,F.jsx)(`a`,{href:_,target:`_blank`,rel:`noopener noreferrer`,"data-project-report-link":!0,children:`打开已读取的记录`}),e.resources&&(0,F.jsxs)(`details`,{className:`project-section project-secondary`,"data-project-usage":!0,children:[(0,F.jsx)(`summary`,{children:`查看用量`}),(0,F.jsxs)(`div`,{"data-project-budget":e.id,children:[(0,F.jsxs)(`p`,{"data-project-budget-used":e.id,children:[`等效 Token `,e.resources.usageKnown?e.resources.tokens.toLocaleString():`未知`]}),S&&(0,F.jsxs)(`p`,{"data-project-budget-raw":e.id,children:[`原始口径 `,(e.resources.rawTokens??S.input+S.output+S.cacheRead+S.cacheWrite).toLocaleString(),`;输入 `,S.input.toLocaleString(),`;输出 `,S.output.toLocaleString(),`;缓存写入 `,S.cacheWrite.toLocaleString(),`;缓存读取 `,S.cacheRead.toLocaleString()]}),(0,F.jsx)(`p`,{"data-project-budget-basis":`1`,children:`等效 Token = 输入 + 输出 + 缓存写入×1.25 + 缓存读取×0.1`})]})]})]})}function ET({project:e,workspaceId:t,notify:n,onOpenSession:r,onOpenFile:i,cwd:a,onChanged:o,onClose:s}){let c=(0,u.useId)(),l=(0,u.useRef)(null),d=(0,u.useRef)(s);return d.current=s,(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),d.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,u.useEffect)(()=>{l.current?.focus({preventScroll:!0})},[e.id]),(0,Re.createPortal)((0,F.jsx)(`div`,{className:`tool-overlay project-dialog-overlay`,"data-project-overlay":e.id,onClick:e=>{e.target===e.currentTarget&&s()},children:(0,F.jsxs)(`div`,{ref:l,className:`tool-dialog project-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":c,"data-project-dialog":e.id,tabIndex:-1,onKeyDown:e=>{if(e.key!==`Tab`)return;let t=l.current;if(!t)return;let n=Array.from(t.querySelectorAll(`button:not([disabled]), a[href], select:not([disabled]), input:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex='-1'])`)).filter(e=>e.offsetParent!==null||e.getClientRects().length>0);if(n.length===0)return;let r=n[0],i=n[n.length-1];e.shiftKey?(document.activeElement===r||document.activeElement===t)&&(e.preventDefault(),i.focus()):document.activeElement===i&&(e.preventDefault(),r.focus())},children:[(0,F.jsxs)(`div`,{className:`tool-dialog-head project-dialog-head`,children:[(0,F.jsxs)(`div`,{className:`project-dialog-title-group`,children:[(0,F.jsx)(`h2`,{className:`tool-dialog-title project-dialog-title`,id:c,children:e.title}),(0,F.jsx)(`span`,{className:`project-detail-flags`,children:(0,F.jsx)(`span`,{className:`project-status project-status-${e.status}`,children:eT(e).label})})]}),(0,F.jsx)(`button`,{type:`button`,className:`tool-dialog-close project-dialog-close`,"data-project-dialog-close":`1`,title:`关闭(Esc)`,"aria-label":`关闭 ${e.title}`,onClick:s,children:`✕`})]}),(0,F.jsx)(`div`,{className:`tool-dialog-body project-dialog-body`,children:(0,F.jsx)(TT,{project:e,workspaceId:t,notify:n,onOpenSession:r?e=>{s(),r(e)}:void 0,onOpenFile:i?e=>{s(),i(e)}:void 0,cwd:a,onChanged:o})})]})}),document.body)}function DT({workspaceId:e,notify:t,onOpenSession:n,onOpenFile:r,cwd:i}){let[a,o]=(0,u.useState)([]),[s,c]=(0,u.useState)(!1),l=(0,u.useMemo)(()=>uT(a,s),[a,s]),[d,f]=(0,u.useState)(!1),[p,m]=(0,u.useState)(``),[h,g]=(0,u.useState)(null),_=(0,u.useRef)(null),[v,y]=(0,u.useState)([]),b=(0,u.useCallback)(async t=>{if(!e)o([]);else{m(``);try{let n=await Ne(`/api/projects?workspaceId=${encodeURIComponent(e)}${s?`&view=history`:``}`,{signal:t}).then(hT),r=Array.isArray(n)?n:Array.isArray(n.projects)?n.projects:[];o(r)}catch(e){e.name!==`AbortError`&&m(e instanceof Error?e.message:`项目列表加载失败`)}finally{t?.aborted||f(!0)}}},[e,s]);(0,u.useEffect)(()=>{let e=new AbortController;return b(e.signal),()=>e.abort()},[b]),(0,u.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>void b(),5e3);return()=>window.clearInterval(t)},[b,e]);let x=(0,u.useMemo)(()=>{let e=Date.now();return l.map(t=>ST(t,e)).filter(e=>!!e).filter(e=>!v.includes(e.reminderId)).sort((e,t)=>bT[e.kind]-bT[t.kind]||t.updatedAt-e.updatedAt)},[l,v]),S=(0,u.useMemo)(()=>l.flatMap(e=>Jw(e).map(t=>({project:e,decision:t}))),[l]),C=(0,u.useMemo)(()=>Yw(l).projects,[l]),w=(0,u.useMemo)(()=>x.slice(0,xT),[x]),T=x.length-w.length,[E,D]=(0,u.useState)(!1),O=E?x:w,[k,A]=(0,u.useState)(!1),j=(0,u.useMemo)(()=>{let e=new Set;for(let t of x)e.add(t.projectId);return e},[l,x]),ee=(0,u.useMemo)(()=>k?l.filter(e=>j.has(e.id)):l,[k,l,j]),M=(0,u.useMemo)(()=>h?l.find(e=>e.id===h)??null:null,[l,h]),te=(0,u.useRef)(null),[N,ne]=(0,u.useState)(0),re=(0,u.useCallback)((e,t,n)=>{_.current=t??document.querySelector(`[data-project-row="${e}"]`),g(e),n&&(te.current={projectId:e,target:n},ne(e=>e+1))},[]),ie=(0,u.useCallback)(()=>{let e=h,t=_.current;_.current=null,g(null),window.requestAnimationFrame(()=>{(t?.isConnected?t:e?document.querySelector(`[data-project-row="${e}"]`):null)?.focus()})},[h]),ae=e=>{let t=document.querySelector(`[data-project-row="${e.projectId}"]`);re(e.projectId,t,e.target)};return(0,u.useEffect)(()=>{if(!N)return;let e=te.current;if(te.current=null,!e)return;let t=document.querySelector(`[data-project-detail="${e.projectId}"]`);if(!t)return;let n=null;if(e.target.kind===`exception`){let e=t.querySelector(`[data-project-exception-section]`);e&&(e.open=!0,n=e.querySelector(`[data-project-exception-heading]`)??e)}let r=n??t,i=window.requestAnimationFrame(()=>{r.scrollIntoView({block:e.target.kind===`top`?`start`:`center`,inline:`nearest`})});return()=>window.cancelAnimationFrame(i)},[N,M?.id]),(0,F.jsxs)(`section`,{className:`project-panel`,"data-project-panel":`1`,children:[(0,F.jsx)(`div`,{className:`rail-section-head project-panel-head`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`rail-section-title`,children:`项目进展`}),(0,F.jsx)(`p`,{className:`project-panel-subtitle`,children:`查看负责人汇总的进展、成果和需要你决定的事。`})]})}),S.length>0&&(0,F.jsxs)(`div`,{className:`warning`,role:`status`,"data-project-team-notice":`1`,"data-project-team-notice-count":C,children:[(0,F.jsxs)(`span`,{"data-project-team-notice-text":!0,children:[C===1?`有 1 个项目的事需要你决定`:`有 ${C} 个项目的事需要你决定`,`:`,vT(yT(S[0].decision),48)]}),(0,F.jsx)(`button`,{type:`button`,"data-project-team-notice-action":`1`,onClick:()=>re(S[0].project.id,void 0,{kind:`exception`,escalationId:S[0].decision.id}),children:`去看看`})]}),x.length>0&&(0,F.jsxs)(`div`,{className:`project-pending`,"data-project-pending":`1`,"data-project-pending-count":x.length,children:[O.map(e=>(0,F.jsxs)(`div`,{className:`project-pending-item`,"data-project-pending-item":e.projectId,"data-project-pending-kind":e.kind,children:[(0,F.jsxs)(`div`,{className:`project-pending-row`,children:[(0,F.jsx)(`span`,{className:`project-pending-kind project-pending-kind-${e.kind}`,"data-project-pending-label":e.kind,children:e.label}),(0,F.jsx)(`span`,{className:`project-pending-title`,"data-project-pending-title":e.projectId,children:e.projectTitle}),(0,F.jsx)(`button`,{type:`button`,className:`project-pending-action`,"data-project-pending-action":e.projectId,onClick:()=>ae(e),children:e.actionLabel}),(0,F.jsx)(`button`,{type:`button`,className:`project-pending-close`,"data-project-pending-dismiss":e.projectId,"aria-label":`关闭「${e.projectTitle}」的这条提醒`,title:`关闭这条提醒(不改变项目状态)`,onClick:()=>y(t=>[...t,e.reminderId]),children:`×`})]}),(0,F.jsx)(`p`,{className:`project-pending-detail`,"data-project-pending-detail":e.projectId,children:e.detail})]},`${e.projectId}:${e.kind}`)),T>0&&(0,F.jsx)(`button`,{type:`button`,className:`project-pending-more`,"data-project-pending-more":`1`,"aria-expanded":E,onClick:()=>D(e=>!e),children:E?`收起`:`还有 ${T} 个`})]}),(0,F.jsxs)(`label`,{className:`project-pending-filter`,"data-project-pending-only-label":`1`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-project-pending-only":`1`,checked:k,onChange:e=>A(e.target.checked)}),(0,F.jsx)(`span`,{className:`project-pending-filter-name`,children:`只看提醒`}),(0,F.jsx)(`span`,{className:`project-pending-filter-state`,"data-project-pending-only-state":k?`on`:`off`,children:k?`已开启`:`已关闭`})]}),(0,F.jsxs)(`label`,{className:`project-pending-filter`,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-project-history":`1`,checked:s,onChange:e=>{c(e.target.checked),A(!1),g(null)}}),(0,F.jsx)(`span`,{className:`project-pending-filter-name`,children:`查看历史项目`})]}),p&&(0,F.jsx)(`p`,{className:`project-error`,role:`alert`,"data-project-error":`1`,children:p}),e?!d&&l.length===0?(0,F.jsx)(`p`,{className:`rail-empty`,children:`正在加载项目…`}):l.length===0?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`rail-empty`,"data-project-empty":`1`,children:s?`没有已结束的项目。`:`当前没有进行中的项目。`}),(0,F.jsx)(`p`,{className:`project-empty-hint`,"data-project-empty-hint":`1`,children:`在对话里告诉 AI 你要完成什么,负责人会推进工作并向你交付。`})]}):ee.length===0?(0,F.jsx)(`p`,{className:`rail-empty`,"data-project-pending-empty":`1`,children:`没有需要关注的项目。`}):(0,F.jsx)(F.Fragment,{children:(0,F.jsx)(`div`,{className:`project-list`,"data-project-count":ee.length,children:ee.map(e=>{let t=M?.id===e.id;return(0,F.jsxs)(`button`,{type:`button`,className:`project-row`,"data-project-row":e.id,"data-project-block":e.id,"data-project-summary":e.id,"aria-haspopup":`dialog`,"aria-expanded":t,onClick:t=>re(e.id,t.currentTarget),children:[(0,F.jsx)(`span`,{className:`project-list-title`,title:e.title,children:e.title}),(0,F.jsx)(`span`,{className:`project-status project-status-${e.status}`,children:eT(e).label}),(0,F.jsx)(`span`,{className:`project-row-summary`,children:eT(e).summary}),e.updatedAt&&(0,F.jsxs)(`span`,{className:`project-row-updated`,children:[mT(e.updatedAt),`更新`]})]},e.id)})})}):(0,F.jsx)(`p`,{className:`rail-empty`,children:`请先选择工作区。`}),M?(0,F.jsx)(ET,{project:M,workspaceId:e,notify:t,onOpenSession:n,onOpenFile:r,cwd:i,onChanged:()=>b(),onClose:ie}):null]})}var OT=()=>({text:``,mentions:[],files:[]}),kT=(e,t)=>`super-pi.group-draft.v1:${JSON.stringify([e,t])}`;function AT(e,t){try{let n=JSON.parse(localStorage.getItem(kT(e,t))??`null`);return!n||typeof n.text!=`string`?OT():{text:n.text.slice(0,32e3),replyTo:typeof n.replyTo==`string`?n.replyTo:void 0,mentions:Array.isArray(n.mentions)?n.mentions.filter(e=>typeof e?.memberId==`string`&&typeof e.text==`string`):[],files:Array.isArray(n.files)?n.files.filter(e=>typeof e?.path==`string`&&typeof e.text==`string`):[]}}catch{return OT()}}function jT(e,t,n){try{let r=kT(e,t);!n.text&&!n.replyTo?localStorage.removeItem(r):localStorage.setItem(r,JSON.stringify(n))}catch{}}function MT(e,t,n){AT(e,t).text===n&&jT(e,t,OT())}var NT=`super-pi.group-presets.v1`;function PT(){try{let e=JSON.parse(localStorage.getItem(`super-pi.group-presets.v1`)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e?.id==`string`&&typeof e.name==`string`&&Array.isArray(e.memberIds)&&e.memberIds.every(e=>typeof e==`string`)&&e.memberModels&&typeof e.memberModels==`object`&&!Array.isArray(e.memberModels)&&typeof e.moderator?.prompt==`string`).slice(0,100):[]}catch{return[]}}var FT=e=>JSON.stringify([e.provider,e.modelId]);function IT({value:e,models:t,onChange:n,label:r,inheritLabel:i}){let[a,o]=(0,u.useState)(``),[s,c]=(0,u.useState)(``),l=(0,u.useRef)(null),d=t.find(t=>FT(t)===e),f=t.filter(e=>(!a||e.provider===a)&&`${e.label} ${e.modelId}`.toLocaleLowerCase().includes(s.toLocaleLowerCase())),p=e=>{n(e),l.current&&(l.current.open=!1)};return(0,F.jsxs)(`details`,{className:`group-model-picker`,ref:l,onKeyDown:e=>{e.key===`Escape`&&l.current&&(l.current.open=!1,l.current.querySelector(`summary`)?.focus())},children:[(0,F.jsxs)(`summary`,{"aria-label":r,title:d?`${d.provider} / ${d.modelId}`:void 0,children:[(0,F.jsx)(`span`,{children:e?d?.label??`当前模型不可用,请重新选择`:i??`继承 Agent / 工作区模型`}),(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`⌄`})]}),(0,F.jsxs)(`div`,{className:`group-model-popup`,children:[(0,F.jsxs)(`select`,{"aria-label":`${r} Provider`,value:a,onChange:e=>o(e.target.value),children:[(0,F.jsx)(`option`,{value:``,children:`全部 Provider`}),[...new Set(t.map(e=>e.provider))].sort().map(e=>(0,F.jsx)(`option`,{children:e},e))]}),(0,F.jsx)(`input`,{"aria-label":`${r} 筛选`,placeholder:`筛选模型…`,value:s,onChange:e=>c(e.target.value)}),(0,F.jsxs)(`div`,{className:`group-model-options`,role:`group`,"aria-label":r,children:[(0,F.jsx)(`button`,{type:`button`,"aria-pressed":!e,onClick:()=>p(``),children:i??`继承默认模型`}),f.map(t=>(0,F.jsxs)(`button`,{type:`button`,"aria-pressed":e===FT(t),onClick:()=>p(FT(t)),children:[(0,F.jsx)(`span`,{children:t.label}),(0,F.jsx)(`small`,{children:t.provider})]},FT(t))),!f.length&&(0,F.jsx)(`p`,{children:`没有匹配的模型`})]})]})]})}var LT={division:`分工`,prompt:`Prompt`,tools:`工具`,mechanism:`协作机制`,execution:`执行策略`};function RT({value:e}){if(/(?:^|\n)\s*(?:[-*+] |\d+[.)] |#{1,4} |```)/.test(e))return(0,F.jsx)(`div`,{className:`rsi-prose`,children:(0,F.jsx)(ef,{source:e,handoffs:!1})});let t=e.split(/\n+/).map(e=>e.trim()).filter(Boolean),n=t.length>1?t:e.length>100?e.split(/(?<=[。;!?])\s*/u).filter(Boolean):t;return(0,F.jsx)(`ul`,{className:`rsi-points`,children:n.map((e,t)=>(0,F.jsx)(`li`,{children:(0,F.jsx)(tf,{source:e})},t))})}function zT({state:e,models:t,archived:n,onAction:r,onClose:i,extra:a}){let[o,s]=(0,u.useState)(``),[c,l]=(0,u.useState)(e?.enabled!==!1),[d,f]=(0,u.useState)(e?.automaticImprovements!==!1),[p,m]=(0,u.useState)(e?.prompt??``),[h,g]=(0,u.useState)(e?.model?FT(e.model):``),[_,v]=(0,u.useState)({}),[y,b]=(0,u.useState)(!1),[x,S]=(0,u.useState)(``),C=e?.reports??[],w=C.find(e=>e.id===o)??C.at(-1),T=async e=>{if(!y){b(!0),S(``);try{await r(e)}catch(e){S(e instanceof Error?e.message:`RSI 操作失败`)}finally{b(!1)}}};return(0,F.jsxs)(`aside`,{className:`group-rsi-panel`,"data-group-rsi-panel":!0,"aria-label":`RSI 观察与建议`,children:[(0,F.jsxs)(`header`,{children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{children:`RSI 观察与建议`}),(0,F.jsx)(`span`,{role:`status`,children:e?.enabled===!1?`已暂停`:e?.status===`running`?`后台观察中`:e?.status===`failed`?`观察失败`:e?.pending?`有新过程,等待更新观察`:w?`观察已更新`:`等待任务产生可观察的过程`})]}),(0,F.jsx)(`button`,{type:`button`,"aria-label":`关闭 RSI 面板`,onClick:i,children:`关闭`})]}),(0,F.jsxs)(`div`,{className:`group-rsi-body`,children:[(0,F.jsx)(`p`,{className:`rsi-intro`,children:`观察任务效率和交付质量。通用缺口归平台,企业专用能力在用户侧开发、验证并复用。`}),!n&&(0,F.jsx)(`button`,{type:`button`,"data-rsi-refresh":!0,disabled:y||e?.status===`running`||e?.enabled===!1,onClick:()=>void T({action:`rsi.refresh`}),children:`更新观察`}),(x||e?.error)&&(0,F.jsx)(`p`,{role:`alert`,children:x||e?.error}),C.length>0&&(0,F.jsxs)(`label`,{children:[`观察记录`,(0,F.jsx)(`select`,{"aria-label":`RSI 观察记录`,value:w?.id,onChange:e=>s(e.target.value),children:[...C].reverse().map(e=>(0,F.jsx)(`option`,{value:e.id,children:new Date(e.createdAt).toLocaleString()},e.id))})]}),w&&(0,F.jsxs)(`section`,{"data-rsi-report":w.id,children:[(0,F.jsxs)(`div`,{className:`rsi-report-meta`,children:[(0,F.jsxs)(`span`,{children:[w.observedMessages,` / `,w.totalMessages,` 条发言`]}),(0,F.jsxs)(`span`,{children:[w.findings.length,` 条建议`]}),w.model&&(0,F.jsx)(`span`,{title:`观察模型`,children:w.model.label||w.model.modelId})]}),w.compressed&&(0,F.jsx)(`p`,{className:`group-rsi-coverage`,children:`部分历史或执行摘要已压缩;下列结论仅基于可见过程。`}),!!w.artifactReads?.length&&(0,F.jsxs)(`details`,{className:`rsi-detail`,children:[(0,F.jsxs)(`summary`,{children:[`本轮实际读取的产物证据 · `,w.artifactReads.length]}),(0,F.jsx)(`ul`,{children:w.artifactReads.map((e,t)=>(0,F.jsx)(`li`,{children:e},t))})]}),!!w.runEvidence?.length&&(0,F.jsxs)(`details`,{className:`rsi-detail`,children:[(0,F.jsx)(`summary`,{children:`实际运行用时(含工具及等人)`}),(0,F.jsx)(`ul`,{children:w.runEvidence.map((e,t)=>(0,F.jsxs)(`li`,{children:[Math.round(e.elapsedMs/1e3),` 秒 · `,new Date(e.finishedAt).toLocaleTimeString()]},t))}),(0,F.jsx)(`p`,{children:`这是完整运行用时,不能直接当作模型思考耗时。`})]}),(0,F.jsxs)(`section`,{className:`rsi-overview`,children:[(0,F.jsx)(`h4`,{children:`本轮结论`}),(0,F.jsx)(RT,{value:w.summary})]}),w.retrospective&&(0,F.jsxs)(`details`,{className:`rsi-retrospective`,children:[(0,F.jsx)(`summary`,{children:`前次建议的后续观察`}),(0,F.jsx)(RT,{value:w.retrospective})]}),!w.findings.length&&(0,F.jsx)(`p`,{children:`当前证据未形成具体改进建议。`}),[...w.findings].sort((e,t)=>({high:0,medium:1,low:2})[e.priority]-{high:0,medium:1,low:2}[t.priority]).map((e,t)=>(0,F.jsxs)(`article`,{className:`group-rsi-finding`,"data-rsi-finding":e.id,children:[(0,F.jsxs)(`header`,{className:`rsi-finding-heading`,children:[(0,F.jsxs)(`h4`,{children:[(0,F.jsx)(`span`,{className:`rsi-finding-number`,children:String(t+1).padStart(2,`0`)}),LT[e.category]]}),(0,F.jsx)(`span`,{className:`rsi-priority`,"data-priority":e.priority,children:{high:`优先处理`,medium:`建议改进`,low:`可选优化`}[e.priority]})]}),(0,F.jsxs)(`p`,{className:`rsi-ownership`,"data-rsi-ownership":e.ownership??`unclassified`,children:[(0,F.jsx)(`strong`,{children:{platform:`平台通用能力`,user:`用户专用能力`,mixed:`通用底座与专用适配需拆分`,unclassified:`归属待澄清`}[e.ownership??`unclassified`]}),e.ownershipReason&&` · ${e.ownershipReason}`]}),(0,F.jsxs)(`section`,{className:`rsi-finding-observation`,children:[(0,F.jsx)(`h5`,{children:`观察到的问题`}),(0,F.jsx)(RT,{value:e.observation})]}),(0,F.jsxs)(`section`,{className:`rsi-recommendation`,children:[(0,F.jsx)(`h5`,{children:`改进建议`}),(0,F.jsx)(RT,{value:e.recommendation})]}),(0,F.jsxs)(`details`,{className:`rsi-detail`,children:[(0,F.jsxs)(`summary`,{children:[`证据 · `,e.evidence.length,` 处关联发言`]}),e.evidence.map((e,t)=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`button`,{type:`button`,onClick:()=>{[...document.querySelectorAll(`[data-group-post-id]`)].find(t=>t.dataset.groupPostId===e.messageId)?.scrollIntoView({block:`center`,behavior:`smooth`})},children:`定位发言`}),e.quote&&(0,F.jsx)(`blockquote`,{children:e.quote})]},t))]}),(0,F.jsxs)(`details`,{className:`rsi-detail`,children:[(0,F.jsx)(`summary`,{children:`适用范围与验证办法`}),(0,F.jsx)(`h5`,{children:`适用范围`}),(0,F.jsx)(RT,{value:e.applicability}),(0,F.jsx)(`h5`,{children:`验证办法`}),(0,F.jsx)(RT,{value:e.verification})]}),e.disposition&&(0,F.jsxs)(`p`,{role:`status`,children:[e.disposition===`accepted`?`已标记采纳 · 待后续过程验证`:`已标记不适用`,e.feedback&&` · ${e.feedback}`]}),!n&&(0,F.jsxs)(`div`,{className:`group-rsi-feedback`,children:[e.ownership===`user`&&e.capability&&(0,F.jsxs)(`button`,{type:`button`,disabled:y,"data-rsi-improve":e.id,onClick:()=>void T({action:`rsi.improve`,reportId:w.id,findingId:e.id}),children:[`开发并验证 · `,e.capability.name]}),(0,F.jsx)(`textarea`,{"aria-label":`RSI 建议反馈`,placeholder:`说明适用差异或实际效果,供下一轮观察参考`,value:_[e.id]??e.feedback??``,onChange:t=>v(n=>({...n,[e.id]:t.target.value})),maxLength:2e3}),(0,F.jsx)(`div`,{children:[`accepted`,`dismissed`].map(t=>(0,F.jsx)(`button`,{type:`button`,disabled:y,"aria-pressed":e.disposition===t,onClick:()=>void T({action:`rsi.feedback`,reportId:w.id,findingId:e.id,disposition:t,feedback:_[e.id]??e.feedback??``}),children:t===`accepted`?`标记采纳`:`不适用`},t))})]})]},e.id))]}),a,!n&&(0,F.jsxs)(`details`,{className:`group-rsi-settings`,children:[(0,F.jsx)(`summary`,{children:`RSI 设置`}),(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked)}),`自动观察`]}),(0,F.jsxs)(`label`,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),`自动开发符合条件的用户专用能力`]}),(0,F.jsx)(`p`,{children:`观察会产生独立模型请求与费用,可随时暂停。每个来源至少间隔一分钟,每次最多 90 秒、12 次只读检查;同一工作区同时最多一个能力开发,预算十分钟。未指定模型时跟随来源会话、主持人或工作区。`}),(0,F.jsx)(IT,{value:h,models:t,label:`RSI 模型`,inheritLabel:`跟随主持人 / 工作区模型`,onChange:g}),(0,F.jsxs)(`label`,{children:[`补充观察要求`,(0,F.jsx)(`textarea`,{"aria-label":`RSI 补充要求`,value:p,onChange:e=>m(e.target.value),maxLength:8e3})]}),(0,F.jsx)(`button`,{type:`button`,"data-rsi-save":!0,disabled:y,onClick:()=>void T({action:`rsi.configure`,enabled:c,automaticImprovements:d,model:t.find(e=>FT(e)===h)??null,prompt:p}),children:`保存 RSI 设置`})]})]})]})}function BT({source:e,models:t,archived:n=!1,onClose:r}){let[i,a]=(0,u.useState)(),[o,s]=(0,u.useState)(``),c=`/api/rsi?${new URLSearchParams({kind:e.kind,workspaceId:e.workspaceId,id:e.id})}`;(0,u.useEffect)(()=>{let e=!1,t=new AbortController,n=async()=>{try{let n=await Ne(c,{signal:t.signal}),r=await n.json();if(!n.ok)throw Error(r.error??`RSI 暂时不可用。`);e||(a(r),s(``))}catch(t){e||s(t instanceof Error?t.message:String(t))}};n();let r=setInterval(()=>void n(),3e3);return()=>{e=!0,t.abort(),clearInterval(r)}},[c]);let l=async e=>{let t=await Ne(c,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw Error(n.error??`RSI 操作失败。`);a(n)};return i?(0,F.jsx)(zT,{state:i?.state,models:t,archived:n,onClose:r,onAction:l,extra:(0,F.jsxs)(`section`,{className:`rsi-work`,"data-rsi-work":!0,children:[o&&(0,F.jsx)(`p`,{role:`alert`,children:o}),(0,F.jsx)(`h4`,{children:`能力改进`}),!i?.improvements.length&&(0,F.jsx)(`p`,{children:`符合条件的用户侧建议会在后台开发;平台建议保留在报告中。`}),i?.improvements.map(e=>(0,F.jsxs)(`article`,{"data-rsi-job":e.id,children:[(0,F.jsxs)(`h5`,{children:[e.name,` · `,{queued:`等待开发`,running:`开发与验证中`,available:`已注册可用 · 收益待验证`,failed:`开发未通过`,interrupted:`已中断`,cancelled:`已取消`}[e.status]]}),(0,F.jsxs)(`p`,{children:[e.slug,e.version?` · v${e.version}`:``]}),e.error&&(0,F.jsx)(`p`,{role:`alert`,children:e.error}),e.conversationId&&(0,F.jsx)(`button`,{type:`button`,"data-rsi-open-work":e.id,onClick:()=>{window.dispatchEvent(new CustomEvent(`super-pi-open-rsi-work`,{detail:e.conversationId})),r()},children:`查看开发过程`}),[`running`,`queued`].includes(e.status)&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>void l({action:`rsi.cancel`,jobId:e.id}).catch(e=>s(String(e))),children:`取消改进`})]},e.id)),!!i?.usage.length&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`h4`,{children:`实际复用记录`}),(0,F.jsx)(`ul`,{children:i.usage.slice(-8).reverse().map((e,t)=>(0,F.jsxs)(`li`,{children:[e.slug,` v`,e.version,` · `,e.status,` · `,e.durationMs,` ms`]},t))}),(0,F.jsx)(`p`,{children:`调用成功仅表示执行成功,不能单独证明整个任务更快或质量更好。`})]})]})},c):(0,F.jsxs)(`aside`,{className:`group-rsi-panel`,"data-group-rsi-panel":!0,children:[(0,F.jsxs)(`header`,{children:[(0,F.jsx)(`h3`,{children:`RSI 观察与建议`}),(0,F.jsx)(`button`,{type:`button`,onClick:r,children:`关闭`})]}),(0,F.jsx)(`div`,{className:`group-rsi-body`,children:(0,F.jsx)(`p`,{role:o?`alert`:`status`,children:o||`正在读取观察与能力改进记录…`})})]})}function VT({id:e,workspaceId:t,models:n}){let[r,i]=(0,u.useState)(!1),a=(0,u.useRef)(null);return(0,u.useEffect)(()=>i(!1),[e]),(0,u.useEffect)(()=>{if(!r)return;let e=e=>{e.key===`Escape`&&i(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`button`,{ref:a,type:`button`,"data-session-rsi":e,"aria-expanded":r,title:`RSI:任务效率与能力改进`,onClick:()=>i(e=>!e),children:`RSI`}),r&&(0,Re.createPortal)((0,F.jsx)(`div`,{className:`session-rsi-dock`,role:`region`,"aria-label":`会话 RSI`,children:(0,F.jsx)(BT,{source:{kind:`session`,id:e,workspaceId:t},models:n,onClose:()=>{i(!1),a.current?.focus()}})}),a.current?.closest(`.workbench-main-panes`)??document.body)]})}var HT={queued:`排队中`,running:`进行中`,completed:`已完成`,failed:`失败`,cancelled:`已停止`,interrupted:`已中断`},UT=new Map([[`read`,`读取文件`],[`write`,`写入文件`],[`edit`,`编辑文件`],[`grep`,`搜索内容`],[`find`,`查找文件`],[`ls`,`列出目录`],[`bash`,`运行命令`],[`powershell`,`运行命令`]]),WT=new Map([[`solution-designer`,`案`],[`code-designer`,`码`],[`code-auditor`,`审`],[`document-organizer`,`文`]]),GT=e=>e.status===`queued`||e.status===`running`,KT=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),qT=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function JT(e,t=!1){let n=Date.parse(e);return Number.isFinite(n)?(t?qT:KT).format(n):``}function YT({name:e,memberId:t,busy:n}){let r=e.trim(),i=t&&WT.get(t)||(/\p{Script=Han}/u.test(r)?Array.from(r).slice(-2).join(``):r.split(/\s+/u).filter(Boolean).map(e=>Array.from(e)[0]).slice(0,2).join(``).toUpperCase())||`?`,a=Wn.findIndex(e=>e===t),o=a>=0?a:Array.from(t??``).reduce((e,t)=>(e*31+(t.codePointAt(0)??0))%4,0);return(0,F.jsx)(`span`,{className:`group-avatar`,"data-avatar-tone":t?o:`self`,"data-avatar-busy":n||void 0,"aria-hidden":`true`,children:i})}function XT({step:e}){return e.kind===`thinking`?(0,F.jsxs)(`details`,{className:`group-execution-step`,"data-execution-kind":`thinking`,"data-execution-status":e.status,open:!0,children:[(0,F.jsxs)(`summary`,{children:[(0,F.jsx)(`span`,{children:e.status===`running`?`正在思考`:`思考摘要`}),(0,F.jsx)(`time`,{dateTime:e.startedAt,children:JT(e.startedAt,!0)})]}),e.text?(0,F.jsx)(`div`,{className:`message-body`,children:(0,F.jsx)(ef,{source:e.text,handoffs:!1})}):(0,F.jsx)(`p`,{className:`group-execution-muted`,children:e.status===`running`?`正在等待模型返回摘要。`:`模型未提供可显示的摘要。`}),e.status===`interrupted`&&(0,F.jsx)(`p`,{className:`group-execution-muted`,children:`思考已中断`})]}):(0,F.jsxs)(`li`,{className:`group-execution-step`,"data-execution-kind":`tool`,"data-execution-status":e.status,children:[(0,F.jsxs)(`div`,{className:`group-execution-tool`,children:[(0,F.jsx)(`strong`,{children:UT.get(e.name)??`工具调用`}),(0,F.jsx)(`code`,{children:e.name}),(0,F.jsx)(`span`,{className:`group-execution-step-status`,children:HT[e.status]})]}),e.detail&&(0,F.jsx)(`p`,{className:`group-execution-target`,children:(0,F.jsx)(`code`,{children:e.detail})}),(0,F.jsxs)(`div`,{className:`group-execution-muted`,children:[(0,F.jsx)(`time`,{dateTime:e.startedAt,children:JT(e.startedAt,!0)}),e.durationMs===void 0?e.status===`running`&&e.lastUpdateAt?` · 最近更新 ${JT(e.lastUpdateAt,!0)}`:null:` · ${(e.durationMs/1e3).toFixed(1)} 秒`]})]})}function ZT({workspaceId:e,roomId:t,memberId:n,name:r,runs:i,postId:a,onSelect:o,onClose:s,onStop:c,models:l,memberModel:d,onModelChange:f,onRetry:p}){let m=(0,u.useId)(),h=(0,u.useRef)(null),[g,_]=(0,u.useState)(),[v,y]=(0,u.useState)(),[b,x]=(0,u.useState)(!1),[S,C]=(0,u.useState)(``),[w,T]=(0,u.useState)(!1),E=i.find(e=>e.id===a)??i.find(e=>e.status===`running`)??i[0],D=E?.id,O=g?.id===D?g?.value:void 0,k=v?.id===D?v?.message:void 0;return(0,u.useLayoutEffect)(()=>{h.current?.focus()},[]),(0,u.useEffect)(()=>{if(!D)return;let n=new AbortController,r,i,a=!1,o=async()=>{try{let r=await nr(er(e,t,i,D),{signal:n.signal});if(n.signal.aborted)return;y(void 0),r&&(i=r.revision,a=!GT(r),_({id:D,value:r}))}catch(e){n.signal.aborted||y({id:D,message:e instanceof Error?e.message:`暂时无法读取执行记录。`})}finally{!n.signal.aborted&&!a&&(r=window.setTimeout(o,500))}};return o(),()=>{n.abort(),window.clearTimeout(r)}},[D,e,t]),(0,F.jsxs)(`aside`,{className:`group-execution`,"aria-labelledby":m,"data-group-execution":n,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),s())},children:[(0,F.jsxs)(`header`,{className:`group-execution-header`,children:[(0,F.jsx)(YT,{name:r,memberId:n,busy:i.some(GT)}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{id:m,children:r}),(0,F.jsx)(`p`,{children:`执行详情`})]}),(0,F.jsx)(`button`,{ref:h,type:`button`,className:`group-close-execution`,"data-close-group-execution":!0,"aria-label":`关闭执行详情`,title:`关闭执行详情`,onClick:s,children:(0,F.jsx)(Gr,{name:`close`})})]}),f&&(0,F.jsxs)(`div`,{className:`group-execution-model-settings`,"aria-busy":b,children:[(0,F.jsx)(`span`,{children:`该成员后续使用的模型`}),(0,F.jsx)(IT,{label:`${r} 后续使用的模型`,value:d?FT(d):``,models:l,onChange:e=>{b||(x(!0),C(``),f(e).catch(e=>C(String(e.message??e))).finally(()=>x(!1)))}}),(0,F.jsx)(`small`,{children:b?`正在保存…`:`当前执行使用原模型。如需立即切换,请先停止再重试。`}),S&&(0,F.jsx)(`p`,{className:`group-error`,role:`alert`,children:S})]}),E?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`group-execution-summary`,children:[i.length>1&&(0,F.jsx)(`select`,{"aria-label":`选择执行记录`,value:D,onChange:e=>o(e.target.value),children:i.map(e=>(0,F.jsxs)(`option`,{value:e.id,children:[JT(e.createdAt,!0),` · `,e.assignment??HT[e.status]]},e.id))}),(0,F.jsx)(`div`,{"aria-live":`polite`,"data-execution-run-status":O?.status??E.status,children:HT[O?.status??E.status]}),E.assignment&&(0,F.jsx)(`p`,{children:E.assignment}),(0,F.jsx)(`p`,{"data-group-execution-model":!0,children:E.model?`${E.model.label} · ${E.model.provider}`:`模型尚未记录`}),GT(E)&&c&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>c(E.id),children:`停止这次执行`}),[`failed`,`cancelled`,`interrupted`].includes(E.status)&&p&&(0,F.jsx)(`button`,{type:`button`,"data-group-retry":!0,disabled:w||b,onClick:()=>{T(!0),C(``),p(E.id).catch(e=>C(String(e.message??e))).finally(()=>T(!1))},children:w?`正在提交重试…`:`用当前模型继续任务`}),E.error&&(0,F.jsx)(`p`,{className:`group-error`,children:E.error})]}),(0,F.jsxs)(`div`,{className:`group-execution-scroll`,children:[k&&(0,F.jsx)(`p`,{className:`group-error`,role:`alert`,children:k}),O?.steps.length?(0,F.jsx)(`ol`,{className:`group-execution-steps`,children:O.steps.map(e=>e.kind===`thinking`?(0,F.jsx)(`li`,{children:(0,F.jsx)(XT,{step:e})},e.id):(0,F.jsx)(XT,{step:e},e.id))}):!k&&(0,F.jsx)(`p`,{className:`group-execution-muted`,children:O?GT(O)?`等待模型或工具事件。`:`这次发言没有可查看的执行明细。`:`正在读取执行记录…`}),O?.truncated&&(0,F.jsx)(`p`,{className:`group-execution-muted`,children:`部分执行记录超过保留长度,已省略。`})]})]}):(0,F.jsx)(`p`,{className:`group-execution-scroll group-execution-muted`,children:`该成员还没有执行记录。`})]})}var QT=e=>JSON.stringify([e.provider,e.modelId]),$T=`super-pi.group-moderator-prompt-presets.v1`;function eE(){try{let e=JSON.parse(localStorage.getItem($T)??`[]`);return Array.isArray(e)?e.filter(e=>e&&typeof e.id==`string`&&typeof e.name==`string`&&typeof e.prompt==`string`).slice(0,100).map(e=>({id:e.id.slice(0,100),name:e.name.slice(0,80),prompt:e.prompt.slice(0,8e3)})):[]}catch{return[]}}var tE=e=>/\s/u.test(e)?`@"${e}"`:`@${e}`,nE=e=>new Set([...e.matchAll(/(?:^|[\s([{])(@(?:"(?:[^"\\]|\\.)+"|[^\s,。;、!?,::;!?,)\]}]+))/gu)].map(e=>e[1])),rE=rr;function iE({workspaceId:e,roomId:t,agents:n,catalog:r,userLabel:i,archivedAt:a,restoring:o,onRestore:s,onRoomSeen:c,onRoomRead:l,onRoomMissing:d,onCreated:f,onCancelCreate:p,onEnableNotifications:m,composerResize:h,sourceLink:g}){let[_,v]=(0,u.useState)(),[y,b]=(0,u.useState)(!1),[x,S]=(0,u.useState)(!1);(0,u.useEffect)(()=>{let e=e=>{e.detail?.roomId===t&&b(!0)};return window.addEventListener(`super-pi-status-group-models`,e),()=>window.removeEventListener(`super-pi-status-group-models`,e)},[t]);let[C,w]=(0,u.useState)(``),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(!1),[k,A]=(0,u.useState)({}),[j,ee]=(0,u.useState)(),[M,te]=(0,u.useState)(``),[N]=(0,u.useState)(()=>AT(e,t)),[ne,re]=(0,u.useState)(N.text),[ie,ae]=(0,u.useState)(N.replyTo),[oe,se]=(0,u.useState)(),[ce,le]=(0,u.useState)(N.mentions),[ue,de]=(0,u.useState)(N.files),[fe,pe]=(0,u.useState)([]),[me,he]=(0,u.useState)(0),[ge,P]=(0,u.useState)(),_e=(0,u.useRef)(null),ve=(0,u.useRef)(null),ye=(0,u.useRef)(void 0),be=(0,u.useRef)(null),xe=(0,u.useRef)(!0),Se=(0,u.useRef)(void 0),Ce=(0,u.useRef)(!1),we=(0,u.useRef)(void 0),Te=(0,u.useRef)(new Map),Ee=_?.id===t?_:void 0,De=!!(a||Ee?.archivedAt),Oe=Ee?.messages.find(e=>e.id===ie),ke=e=>Ee?.members.find(t=>t.id===e)?.name??e,Ae=e=>e.role===`user`?i:e.memberName??ke(e.memberId),je=De?void 0:oe?.query,Me=oe?[...(Ee?.members??[]).filter(e=>`${e.name} ${e.id}`.toLocaleLowerCase().includes(oe.query.toLocaleLowerCase())).map(e=>({kind:`member`,member:e})),...fe.map(e=>({kind:`file`,file:e}))]:[];(0,u.useEffect)(()=>{jT(e,t,{text:ne,replyTo:ie,mentions:ce,files:ue})},[e,t,ne,ie,ce,ue]);let Ne=e=>{if(e.id!==t)return;let n=Se.current;if(n?.id===e.id){let[t,r]=n.revision.split(`:`).map(Number),[i,a]=e.revision.split(`:`).map(Number);if(t>i||t===i&&r>a)return}Se.current=e,v(e),e.archivedAt&&b(!1),(n?.title!==e.title||n?.archivedAt!==e.archivedAt||n?.activity.status!==e.activity.status||n?.activity.lastReplyAt!==e.activity.lastReplyAt)&&c(e)};(0,u.useEffect)(()=>{let e=be.current;if(!Ee||y||!e)return;let t=!0,n=()=>{let n=e.getBoundingClientRect();t&&document.visibilityState===`visible`&&getComputedStyle(e).visibility===`visible`&&n.width>0&&n.height>0&&n.bottom>0&&n.top<window.innerHeight&&n.right>0&&n.left<window.innerWidth&&l(Ee)};n();let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&n()});return r.observe(e),document.addEventListener(`visibilitychange`,n),()=>{t=!1,r.disconnect(),document.removeEventListener(`visibilitychange`,n)}},[Ee?.id,Ee?.activity.lastReplyAt,y,ge?.memberId,ge?.postId,l]),(0,u.useEffect)(()=>(Ce.current=!0,()=>{Ce.current=!1}),[]),(0,u.useEffect)(()=>{if(!t)return;let n=new AbortController,r,i=!1,a=async()=>{try{let r=await nr(er(e,t,Se.current?.revision),{signal:n.signal});n.signal.aborted||(E(``),r&&Ne(r))}catch(r){n.signal.aborted||(r instanceof tr&&r.status===404?(i=!0,d({workspaceId:e,roomId:t})):E(Se.current?`群聊连接暂时中断,正在重试。`:String(r.message??r)))}finally{!n.signal.aborted&&!i&&(r=window.setTimeout(a,Se.current?.messages.some(GT)?450:1600))}};return a(),()=>{n.abort(),window.clearTimeout(r)}},[e,t,d]),(0,u.useEffect)(()=>{if(pe([]),!je)return;let t=new AbortController,n,r=()=>{nr(`/api/files/mentions?${new URLSearchParams({workspaceId:e,cwd:``,q:je})}`,{signal:t.signal}).then(e=>{!t.signal.aborted&&e&&(pe(e.hits.filter(e=>e.kind===`file`).slice(0,8)),e.indexed||(n=window.setTimeout(r,650)))}).catch(()=>{})};return n=window.setTimeout(r,160),()=>{window.clearTimeout(n),t.abort()}},[je,e]),(0,u.useLayoutEffect)(()=>{be.current&&xe.current&&(be.current.scrollTop=be.current.scrollHeight)},[Ee?.revision]),(0,u.useLayoutEffect)(()=>{let e=ye.current;e!==void 0&&ve.current&&(ye.current=void 0,ve.current.focus(),ve.current.setSelectionRange(e,e))},[ne]);async function Pe(n){O(!0),w(``);try{let r=await rE(er(e,t),t?{action:`configure`,memberIds:n.memberIds,memberModels:n.memberModels,...n.moderator,model:n.moderator.model??null,cloneLimit:n.moderator.cloneLimit??null}:n);if(!r)throw Error(`服务没有返回群聊。`);t?(Ne(r),b(!1)):f(r,Ce.current)}catch(e){w(String(e.message??e))}finally{O(!1)}}async function Fe(n){if(n.preventDefault(),!Ee||De||!ne.trim()||D)return;let r=ne.trim(),i=nE(r),a=ce.filter(e=>i.has(e.text)),o=Ee.members.filter(e=>a.some(t=>t.memberId===e.id)||i.has(tE(e.name))&&Ee.members.filter(t=>t.name===e.name).length===1).map(e=>e.id),s=ue.filter(e=>i.has(e.text)).map(e=>e.path),c=JSON.stringify([Ee.id,r,o,ie,s]);we.current?.signature!==c&&(we.current={signature:c,clientId:Wt()}),O(!0),w(``);try{let n=await rE(er(e,Ee.id),{action:`send`,content:r,memberIds:o,replyTo:ie,filePaths:s,clientId:we.current.clientId});if(!n)throw Error(`服务没有确认收到消息。`);MT(e,t,ne),xe.current=!0,Ne(n),Ce.current&&t===n.id&&(re(``),ae(void 0),le([]),de([]),se(void 0)),we.current=void 0}catch(e){w(String(e.message??e))}finally{O(!1)}}function Ie(e){if(!oe)return;let t;if(e.kind===`member`){let n=e.member,r=tE(n.name);re(ne.slice(0,oe.start)+r+` `+ne.slice(oe.end)),le(e=>[...e.filter(e=>e.text!==r),{memberId:n.id,text:r}]),t=oe.start+r.length+1}else{let n=e.file,r=_f(ne,oe,n),i=r.text.slice(oe.start,r.caret).trimEnd();re(r.text),de(e=>[...e.filter(e=>e.path!==n.path),{path:n.path,text:i}]),t=r.caret}ye.current=t,se(void 0)}async function Le(n){try{let r=await rE(er(e,t),{action:`stop`,postId:n});r&&Ne(r)}catch(e){w(String(e.message??e))}}async function Re(n,i){let a=r?.models.find(e=>QT(e)===i);if(i&&!a)throw Error(`所选模型不可用,请刷新模型列表后重试。`);if(!Ee)throw Error(`群聊尚未加载,请稍后重试。`);let o=await rE(er(e,t),{action:`configure`,memberModels:{[n]:a??null},...Ee.moderator,model:Ee.moderator.model??null,cloneLimit:Ee.moderator.cloneLimit??null});if(!o)throw Error(`服务没有确认模型更改。`);Ne(o);let s=o.members.find(e=>e.id===n)?.model;if((s?QT(s):``)!==i)throw Error(`目标服务端没有应用成员模型设置,可能版本过旧。请先升级目标服务端后重试;群聊历史仍保留。`)}async function ze(n){let r=Ee?.messages.find(e=>e.id===n&&e.role===`assistant`),i=r&&Ee?.messages.find(e=>e.id===r.topicId);if(!r||!i||![`failed`,`interrupted`,`cancelled`].includes(r.status))throw Error(`只能重试已失败或停止的执行。`);let a=Te.current.get(n)??Wt();Te.current.set(n,a);let o=`请使用当前模型继续这次未完成的任务。先检查已有产物,避免重复执行。\n原分工:${r.assignment??`按原请求完成工作`}\n原请求:${i.content}`.slice(0,32e3),s=await rE(er(e,t),{action:`send`,content:o,memberIds:[r.memberId],replyTo:r.id,clientId:a,filePaths:i.role===`user`?i.files?.map(e=>e.path):void 0});if(!s)throw Error(`服务没有确认重试请求。`);Ne(s),Te.current.delete(n)}async function Be(n,r,i){ee(n),w(``);try{let a=await rE(er(e,t),{action:`clone.resolve`,requestId:n,choice:r,name:i});a&&Ne(a)}catch(e){w(e instanceof Error?e.message:String(e))}finally{ee(void 0)}}function Ve(e,t,n,r){S(!1);let i=n.closest(`[data-group-post-id]`)?.querySelector(`[data-group-message-avatar]`)??void 0;_e.current={origin:n,avatar:i},P({memberId:e,name:t,postId:r})}function He(){let e=ge?.memberId;P(void 0);let t=_e.current;requestAnimationFrame(()=>{let n=[...document.querySelectorAll(`[data-group-message-avatar]`)].filter(t=>t.dataset.groupMessageAvatar===e).at(-1);(t?.origin.isConnected?t.origin:t?.avatar?.isConnected?t.avatar:n)?.focus({preventScroll:!0})})}let Ue=Ee?.messages??[],We=Kn(Ue),Ge=Ue.filter(e=>e.role===`assistant`&>(e)).filter((e,t,n)=>n.findIndex(t=>t.memberId===e.memberId)===t),Ke=new Map(Ue.map(e=>[e.id,e])),qe=new Set(Ue.flatMap(e=>e.role===`assistant`&>(e)?[e.memberId]:[])),Je=ge?Ue.filter(e=>e.role===`assistant`&&e.memberId===ge.memberId).reverse():[],Ye;return(0,F.jsxs)(`section`,{className:`group-chat`,"data-group-chat":t,children:[(C||T)&&(0,F.jsx)(`div`,{className:`group-error`,role:`alert`,children:C||T}),!t||y&&!De?(0,F.jsx)(aE,{room:y?Ee:void 0,agents:n,catalog:r,saving:D,onSave:Pe,onCancel:t?()=>b(!1):p}):Ee?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`group-members`,children:[(0,F.jsx)(`div`,{className:`group-roster`,"aria-label":`群成员`,children:Ee.members.map(e=>(0,F.jsxs)(`button`,{type:`button`,className:`group-roster-member`,"data-group-member-avatar":e.id,"aria-label":`查看 ${e.name} 的执行详情${qe.has(e.id)?`,工作中`:``}`,title:`${e.name}${e.agentId?` · 分身 · ${e.worktreePath??e.agentId}`:``}`,"aria-pressed":ge?.memberId===e.id,onClick:t=>Ve(e.id,e.name,t.currentTarget),children:[(0,F.jsx)(YT,{name:e.name,memberId:e.id,busy:qe.has(e.id)}),(0,F.jsxs)(`span`,{children:[e.name,e.agentId?` · 分身`:``]})]},e.id))}),!De&&(0,F.jsx)(`button`,{type:`button`,"data-group-settings":!0,disabled:D,onClick:()=>{w(``),P(void 0),b(!0)},children:`群聊设置`}),(0,F.jsxs)(`button`,{type:`button`,"data-group-rsi":!0,"aria-pressed":x,onClick:()=>{S(e=>!e),P(void 0)},children:[`RSI`,Ee.rsi?.status===`running`?` · 观察中`:Ee.rsi?.status===`failed`?` · 需处理`:``]}),(0,F.jsx)(`button`,{type:`button`,onClick:()=>{m?m():na().then(e=>te(e===`granted`?`系统通知已开启`:`请在浏览器站点设置中允许通知`))},children:`系统通知`})]}),M&&(0,F.jsx)(`p`,{role:`status`,children:M}),(Ee.cloneRequests??[]).filter((e,t,n)=>e.status===`pending`||t>=n.length-3).map(e=>{let t=Ee.members.find(t=>t.id===e.memberId),n=2;for(;Ee.members.some(e=>e.name===`${t?.name??`Agent`} ${n}`);)n+=1;let r=k[e.id]??`${t?.name??`Agent`} ${n}`;return(0,F.jsx)(`section`,{className:`group-clone-request`,"data-clone-request":e.id,"aria-label":`创建 Agent 分身`,children:e.status===`pending`&&e.automatic?(0,F.jsx)(`span`,{children:`主持人正在准备独立分身…`}):e.status===`pending`&&!De?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`strong`,{children:[t?.name??`Agent`,` 正在工作,是否创建分身?`]}),(0,F.jsx)(`p`,{children:e.reason}),(0,F.jsx)(`p`,{children:e.assignment}),(0,F.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),Be(e.id,`create`,r)},children:[(0,F.jsxs)(`label`,{children:[`分身名字`,(0,F.jsx)(`input`,{maxLength:80,required:!0,value:r,onChange:t=>A(n=>({...n,[e.id]:t.target.value}))})]}),(0,F.jsx)(`button`,{disabled:!!j||!r.trim(),children:j===e.id?`正在准备…`:`创建分身并处理`}),(0,F.jsx)(`button`,{type:`button`,disabled:!!j,onClick:()=>void Be(e.id,`wait`,``),children:`等待空闲`})]}),(0,F.jsx)(`small`,{children:`分身共享源 Agent 的能力与经验,在独立 Git 工作树处理此 case。`})]}):(0,F.jsx)(`span`,{children:e.status===`created`?`已安排 ${Ee.members.find(t=>t.id===e.cloneId)?.name??`分身`}`:e.status===`waiting`?`已选择等待原成员`:`成员或任务状态已变化,无需创建分身`})},e.id)}),(0,F.jsxs)(`div`,{className:`group-stage${ge?` group-stage-inspecting`:``}${x?` group-stage-rsi`:``}`,children:[(0,F.jsxs)(`div`,{className:`group-dialogue`,children:[(0,F.jsxs)(`div`,{className:`group-thread`,ref:be,onScroll:e=>{let t=e.currentTarget;xe.current=t.scrollHeight-t.clientHeight-t.scrollTop<64},children:[!Ue.length&&(0,F.jsx)(`p`,{className:`group-empty`,children:De?`这个群聊没有消息。`:`发条消息开始讨论。用 @ 点名一个或多个成员。`}),We.map(e=>{let t=e.replyTo?Ke.get(e.replyTo):void 0;e.role===`user`&&(Ye=e.id);let n=t&&(e.role===`user`||t.id!==e.topicId||e.topicId!==Ye)?t:void 0,r=Ae(e),i=e.role===`assistant`&&e.background&&e.status===`running`?`后台进行中`:HT[e.status],a=e.role===`assistant`&&ge?.postId===e.id;return(0,F.jsxs)(`article`,{className:`group-post group-post-${e.role}`,"data-group-post":e.role,"data-group-status":e.status,"data-group-post-id":e.id,children:[e.role===`assistant`?(0,F.jsx)(`button`,{className:`group-post-avatar`,type:`button`,"data-group-message-avatar":e.memberId,"aria-label":`查看 ${r} 这次发言的执行详情`,title:`${r} · 执行详情`,"aria-pressed":a,onClick:t=>Ve(e.memberId,r,t.currentTarget,e.id),children:(0,F.jsx)(YT,{name:r,memberId:e.memberId,busy:GT(e)})}):(0,F.jsx)(YT,{name:r}),(0,F.jsxs)(`div`,{className:`group-post-content`,children:[(0,F.jsxs)(`div`,{className:`group-post-head`,children:[(0,F.jsx)(`strong`,{children:r}),e.role===`assistant`&&(0,F.jsx)(`span`,{className:`group-message-model`,"data-group-message-model":e.model?QT(e.model):`unknown`,title:e.model?`${e.model.provider} / ${e.model.modelId}`:`这条历史消息没有记录使用的模型`,children:e.model?`${e.model.label} · ${e.model.provider}`:`模型未记录`}),e.status!==`completed`&&(0,F.jsx)(`span`,{className:`group-post-state`,children:i}),(0,F.jsx)(`time`,{dateTime:Gn(e),children:JT(Gn(e))}),!De&&(0,F.jsxs)(`div`,{className:`group-post-actions`,children:[!GT(e)&&(0,F.jsx)(`button`,{type:`button`,className:`group-reply-action`,disabled:D,onClick:()=>{ae(e.id),ve.current?.focus()},children:`回复`}),GT(e)&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>void Le(e.id),children:`停止`})]})]}),(n||e.content||e.error||e.role===`user`&&e.memoryNotice)&&(0,F.jsxs)(`div`,{className:`group-bubble`,children:[n&&(0,F.jsxs)(`div`,{className:`group-quote`,children:[Ae(n),` · `,n.content.slice(0,120)]}),e.content&&(0,F.jsx)(`div`,{className:`message-body`,children:(0,F.jsx)(ef,{source:e.content,handoffs:!1,sourceLink:e.role===`assistant`&&_?.members.some(t=>t.id===e.memberId&&!t.worktreePath)?g:void 0})}),e.role===`user`&&e.memoryNotice&&(0,F.jsx)(`div`,{className:`group-route`,children:e.memoryNotice}),e.error&&(0,F.jsx)(`p`,{className:`group-error`,children:e.error})]}),e.role===`assistant`&&e.routeReason&&(0,F.jsxs)(`details`,{className:`group-route group-post-footer`,children:[(0,F.jsx)(`summary`,{children:`接话原因`}),e.routeReason]})]})]},e.id)})]}),Ge.length>0&&(0,F.jsx)(`div`,{className:`group-preparing`,"data-group-preparing":!0,role:`group`,"aria-label":`正在准备回复的成员`,children:Ge.map(e=>(0,F.jsx)(`button`,{type:`button`,"data-group-preparing-avatar":e.memberId,title:`${Ae(e)} · 正在准备回复`,"aria-label":`查看 ${Ae(e)} 的准备详情`,"aria-pressed":ge?.memberId===e.memberId,onClick:t=>Ve(e.memberId,Ae(e),t.currentTarget,e.id),children:(0,F.jsx)(YT,{name:Ae(e),memberId:e.memberId,busy:!0})},e.memberId))}),De?(0,F.jsxs)(`div`,{className:`group-archive-notice`,"data-group-archive-notice":!0,children:[(0,F.jsx)(`p`,{children:`群聊已归档。恢复后可继续发消息。`}),(0,F.jsx)(`button`,{type:`button`,"data-group-restore":!0,disabled:o,onClick:()=>s(Ee),children:`恢复群聊`})]}):(0,F.jsxs)(`form`,{className:`group-composer`,onSubmit:Fe,children:[h,Oe&&(0,F.jsxs)(`div`,{className:`group-quote`,children:[`回复 `,Ae(Oe),` · `,Oe.content.slice(0,60),` `,(0,F.jsx)(`button`,{type:`button`,onClick:()=>ae(void 0),"aria-label":`取消引用`,children:`×`})]}),Me.length>0&&(0,F.jsx)(`div`,{className:`group-suggestions`,role:`listbox`,"aria-label":`点名群成员或引用文件`,children:Me.map((e,t)=>(0,F.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":t===me,"data-group-member-option":e.kind===`member`?e.member.id:void 0,onMouseDown:e=>e.preventDefault(),onClick:()=>Ie(e),children:e.kind===`member`?e.member.name:`文件 · ${e.file.path}`},e.kind===`member`?`member:${e.member.id}`:`file:${e.file.path}`))}),(0,F.jsx)(`textarea`,{ref:ve,"data-group-composer":!0,"aria-label":`群聊消息`,placeholder:`输入消息,@ 点名或引用文件`,value:ne,maxLength:32e3,readOnly:D,onChange:e=>{re(e.target.value),se(gf(e.target.value,e.target.selectionStart,e.target.selectionEnd)),he(0)},onSelect:e=>{let t=e.currentTarget;se(gf(t.value,t.selectionStart,t.selectionEnd))},onKeyDown:e=>{e.nativeEvent.isComposing||(Me.length&&(e.key===`ArrowDown`||e.key===`ArrowUp`)?(e.preventDefault(),he(t=>(t+Me.length+(e.key===`ArrowDown`?1:-1))%Me.length)):Me.length&&(e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey?(e.preventDefault(),Ie(Me[me]??Me[0])):e.key===`Escape`?se(void 0):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),e.currentTarget.form?.requestSubmit()))}}),(0,F.jsx)(`button`,{type:`submit`,"data-group-send":!0,disabled:!ne.trim()||D,children:`发送`})]})]}),x&&(0,F.jsx)(BT,{source:{kind:`group`,workspaceId:e,id:t},models:r?.models??[],archived:De,onClose:()=>S(!1)}),!x&&ge&&(0,F.jsx)(ZT,{workspaceId:e,roomId:t,memberId:ge.memberId,name:ge.name,runs:Je,postId:ge.postId,onStop:e=>void Le(e),onSelect:e=>P({...ge,postId:e}),onClose:He,models:r?.models??[],memberModel:Ee.members.find(e=>e.id===ge.memberId)?.model,onModelChange:De?void 0:e=>Re(ge.memberId,e),onRetry:De?void 0:ze},ge.memberId)]})]}):!T&&(0,F.jsx)(`p`,{className:`group-empty`,children:`正在加载群聊…`})]})}function aE({room:e,agents:t,catalog:n,saving:r,onSave:i,onCancel:a}){let[o,s]=(0,u.useState)(e?.title??``),[c,l]=(0,u.useState)({}),d=t.filter(e=>e.mode===`primary`&&!e.hidden),f=[...d,...e?.members.filter(e=>!d.some(t=>t.id===e.id))??[]],p=e?.members.map(e=>e.id)??Wn,m=[...new Set([...p,...f.map(e=>e.id)])].filter(e=>f.some(t=>t.id===e)&&(c[e]??p.includes(e))),[h,g]=(0,u.useState)(e?.moderator.model?QT(e.moderator.model):``),[_,v]=(0,u.useState)(e?.moderator.prompt??``),[y,b]=(0,u.useState)(e?.moderator.cloneLimit??0),[x,S]=(0,u.useState)(()=>Object.fromEntries((e?.members??[]).map(e=>[e.id,e.model?QT(e.model):``]))),[C,w]=(0,u.useState)(PT),[T,E]=(0,u.useState)(``),[D,O]=(0,u.useState)(``),[k,A]=(0,u.useState)(``),[j,ee]=(0,u.useState)(eE),[M,te]=(0,u.useState)(``),[N,ne]=(0,u.useState)(``),[re,ie]=(0,u.useState)(``);(0,u.useEffect)(()=>{try{localStorage.setItem($T,JSON.stringify(j))}catch{ie(`浏览器无法保存预设,请检查本地存储空间或隐私设置。`)}},[j]);let ae=[...n?.models??[]];if(e?.moderator.model&&!ae.some(t=>QT(t)===QT(e.moderator.model))){let t=e.moderator.model;n||ae.push(t)}let oe=()=>Object.fromEntries(m.map(e=>[e,ae.find(t=>QT(t)===x[e])??null])),se=()=>({prompt:_,cloneLimit:y||void 0,model:ae.find(e=>QT(e)===h)}),ce=!(!h||ae.some(e=>QT(e)===h))||m.some(e=>x[e]&&!ae.some(t=>QT(t)===x[e])),le=e=>{try{return localStorage.setItem(NT,JSON.stringify(e)),w(e),!0}catch{return A(`浏览器无法保存群聊预设,请检查本地存储空间或隐私设置。`),!1}};return(0,F.jsxs)(`form`,{className:`group-settings`,onSubmit:e=>{e.preventDefault();let t=ae.find(e=>QT(e)===h);h&&!t||ce||i({title:o,memberIds:m,memberModels:oe(),moderator:se()})},children:[(0,F.jsxs)(`div`,{className:`group-settings-heading`,children:[(0,F.jsx)(`h2`,{children:e?`群聊设置`:`创建群聊`}),(0,F.jsx)(`p`,{children:`安排成员与模型,让主持人协调讨论和执行。`})]}),(0,F.jsxs)(`section`,{className:`group-settings-card`,"data-group-presets":!0,children:[(0,F.jsx)(`h3`,{children:`群聊预设`}),(0,F.jsx)(`p`,{className:`group-settings-hint`,children:`一并保存成员、各自模型和主持人设置。`}),(0,F.jsxs)(`label`,{children:[`加载群聊预设`,(0,F.jsxs)(`select`,{"aria-label":`加载群聊预设`,value:T,onChange:e=>{E(e.target.value);let t=C.find(t=>t.id===e.target.value);if(!t)return;O(t.name),l(Object.fromEntries([...new Set([...p,...f.map(e=>e.id),...t.memberIds])].map(e=>[e,t.memberIds.includes(e)]))),S(Object.fromEntries(Object.entries(t.memberModels).map(([e,t])=>[e,t?QT(t):``]))),v(t.moderator.prompt),g(t.moderator.model?QT(t.moderator.model):``),b(t.moderator.cloneLimit??0);let n=t.memberIds.filter(e=>!f.some(t=>t.id===e));A(n.length?`已加载「${t.name}」。${n.length} 位成员在当前服务端不可用,请检查成员列表后保存。`:`已加载「${t.name}」。可继续调整,不影响其他群聊。`)},children:[(0,F.jsx)(`option`,{value:``,children:`选择预设…`}),C.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,F.jsxs)(`div`,{className:`group-prompt-preset-actions`,children:[(0,F.jsx)(`input`,{"aria-label":`群聊预设名称`,placeholder:`例如:日常开发评审`,value:D,maxLength:80,onChange:e=>O(e.target.value)}),(0,F.jsx)(`button`,{type:`button`,disabled:!D.trim()||m.length<2||ce,onClick:()=>{let t=D.trim(),n=C.find(e=>e.name.toLocaleLowerCase()===t.toLocaleLowerCase()),r=m.map(t=>e?.members.find(e=>e.id===t)?.agentId??t),i=oe(),a={id:n?.id??Wt(),name:t,memberIds:[...new Set(r)],memberModels:Object.fromEntries(r.map((e,t)=>[e,i[m[t]]])),moderator:se()};le(n?C.map(e=>e.id===n.id?a:e):[a,...C].slice(0,100))&&(E(a.id),A(`已保存群聊预设「${t}」。`))},children:`保存预设`}),T&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{le(C.filter(e=>e.id!==T))&&(E(``),A(`群聊预设已删除。`))},children:`删除`})]}),k&&(0,F.jsx)(`p`,{className:`group-settings-hint`,role:`status`,children:k})]}),!e&&(0,F.jsxs)(`label`,{children:[`群名`,(0,F.jsx)(`input`,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),maxLength:100,required:!0})]}),(0,F.jsxs)(`fieldset`,{className:`group-member-settings`,children:[(0,F.jsx)(`legend`,{children:`群成员与模型`}),f.map(e=>(0,F.jsxs)(`div`,{className:`group-member-card`,"data-selected":m.includes(e.id),children:[(0,F.jsxs)(`label`,{className:`group-choice`,title:e.description,children:[(0,F.jsx)(`input`,{type:`checkbox`,"data-group-member-choice":e.id,checked:m.includes(e.id),disabled:!m.includes(e.id)&&m.length>=8,onChange:t=>{let n=t.target.checked;l(t=>({...t,[e.id]:n}))}}),(0,F.jsx)(YT,{name:e.name,memberId:e.id}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`strong`,{children:e.name}),(0,F.jsx)(`small`,{children:e.description})]})]}),m.includes(e.id)&&(0,F.jsx)(IT,{label:`${e.name} 的模型`,value:x[e.id]??``,models:ae,onChange:t=>S(n=>({...n,[e.id]:t}))})]},e.id))]}),(0,F.jsx)(`p`,{className:`group-settings-hint`,children:`取消勾选可移除成员。请选择 2 到 8 位主 Agent。`}),(0,F.jsxs)(`details`,{className:`group-settings-card`,open:!0,children:[(0,F.jsx)(`summary`,{children:`主持人设置`}),(0,F.jsxs)(`label`,{children:[`同类 Agent 分身`,(0,F.jsxs)(`select`,{value:y,onChange:e=>b(Number(e.target.value)),children:[(0,F.jsx)(`option`,{value:0,children:`创建前询问我`}),[2,3,4,8].map(e=>(0,F.jsxs)(`option`,{value:e,children:[`允许自动创建 · 同类最多 `,e,` 人`]},e))]})]}),(0,F.jsxs)(`div`,{className:`group-model-field`,children:[(0,F.jsx)(`span`,{children:`主持人模型`}),(0,F.jsx)(IT,{label:`主持人模型`,value:h,models:ae,onChange:g})]}),(0,F.jsxs)(`label`,{children:[`主持人 Prompt`,(0,F.jsx)(`textarea`,{value:_,maxLength:8e3,onChange:e=>v(e.target.value),placeholder:`例如:先请最熟悉模块的成员回答,结论足够时结束。`})]}),(0,F.jsxs)(`details`,{className:`group-prompt-presets`,"data-moderator-prompt-presets":!0,children:[(0,F.jsx)(`summary`,{children:`旧版 Prompt 预设`}),(0,F.jsxs)(`label`,{children:[`加载已保存的 Prompt`,(0,F.jsxs)(`select`,{"aria-label":`加载主持人 Prompt 预设`,value:M,onChange:e=>{let t=j.find(t=>t.id===e.target.value);te(e.target.value),t?(v(t.prompt),ne(t.name),ie(`已加载「${t.name}」,可继续修改后用于当前群聊。`)):ie(``)},children:[(0,F.jsx)(`option`,{value:``,children:`选择预设…`}),j.map(e=>(0,F.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,F.jsxs)(`div`,{className:`group-prompt-preset-actions`,children:[(0,F.jsx)(`input`,{"aria-label":`Prompt 预设名称`,value:N,maxLength:80,onChange:e=>ne(e.target.value),placeholder:`预设名称`}),(0,F.jsx)(`button`,{type:`button`,disabled:!N.trim()||!_.trim(),onClick:()=>{let e=N.trim(),t=j.find(t=>t.name.toLocaleLowerCase()===e.toLocaleLowerCase()),n={id:t?.id??Wt(),name:e,prompt:_};ee(e=>t?e.map(e=>e.id===t.id?n:e):[n,...e].slice(0,100)),te(n.id),ie(`已保存「${e}」。`)},children:`保存预设`}),M&&(0,F.jsx)(`button`,{type:`button`,onClick:()=>{let e=j.find(e=>e.id===M);ee(e=>e.filter(e=>e.id!==M)),te(``),ne(``),ie(e?`已删除「${e.name}」。`:`预设已删除。`)},children:`删除预设`})]}),re&&(0,F.jsx)(`p`,{className:`group-settings-hint`,role:`status`,children:re})]})]}),(0,F.jsxs)(`div`,{className:`group-settings-actions`,children:[(0,F.jsx)(`button`,{type:`button`,disabled:r,onClick:a,children:`取消`}),(0,F.jsx)(`button`,{type:`submit`,disabled:r||!o.trim()||m.length<2||m.length>8||ce,children:e?`保存`:`创建群聊`})]})]})}var oE=`__pi_default__`;function sE({workspaces:e,catalog:t,onClose:n,onSave:r}){let[i,a]=(0,u.useState)(oE),[o,s]=(0,u.useState)(oE);(0,u.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let c=t.models.find(e=>`${e.provider}/${e.modelId}`===i),l=c?.provider===t.defaultModel?.provider&&c?.modelId===t.defaultModel?.modelId,d=c?.thinkingLevels??(l?t.levels:[]),f=c?{provider:c.provider,modelId:c.modelId,label:c.label}:void 0;return(0,F.jsx)(`div`,{className:`overlay`,onClick:n,children:(0,F.jsxs)(`div`,{className:`picker settings-dialog bulk-workspace-settings`,"data-bulk-workspace-settings":`1`,onClick:e=>e.stopPropagation(),children:[(0,F.jsx)(`h2`,{children:`批量设置工作区`}),(0,F.jsxs)(`div`,{className:`settings-scope`,children:[`将统一修改 `,e.length,` 个现存工作区的默认模型与思考等级,只影响之后新建的会话。`]}),(0,F.jsxs)(`label`,{className:`bulk-settings-field`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`默认模型`}),(0,F.jsxs)(`select`,{className:`bulk-settings-select`,"aria-label":`批量默认模型`,value:i,disabled:t.source!==`pi`,onChange:e=>{a(e.target.value),s(oE)},children:[(0,F.jsx)(`option`,{value:oE,children:`跟随 Pi 默认`}),t.models.map(e=>(0,F.jsxs)(`option`,{value:`${e.provider}/${e.modelId}`,children:[e.label,` · `,e.provider]},`${e.provider}/${e.modelId}`))]})]}),(0,F.jsxs)(`label`,{className:`bulk-settings-field`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`默认思考等级`}),(0,F.jsxs)(`select`,{className:`bulk-settings-select`,"aria-label":`批量默认思考等级`,value:o,disabled:!c||t.source!==`pi`,onChange:e=>s(e.target.value),children:[(0,F.jsx)(`option`,{value:oE,children:`跟随 Pi 默认`}),d.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})]}),c&&d.length===0&&(0,F.jsx)(`p`,{className:`bulk-settings-note`,children:`Pi 没有为此模型提供可选择的思考等级;新会话会使用 Pi 默认值。`}),(0,F.jsxs)(`div`,{className:`bulk-settings-workspaces`,"aria-label":`将被更新的工作区`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`应用到`}),(0,F.jsx)(`div`,{children:e.map(e=>(0,F.jsx)(`span`,{children:e.name},e.id))})]}),(0,F.jsxs)(`div`,{className:`picker-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,onClick:n,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`picker-ok`,disabled:!e.length||t.source!==`pi`,onClick:()=>r(f,o===oE?void 0:o),children:`应用到全部工作区`})]})]})})}function cE({glyph:e,className:t}){return(0,F.jsx)(`span`,{className:t,"data-tool-glyph-length":Math.min(4,Math.max(1,Array.from(e).length)),"aria-hidden":`true`,children:e})}function lE(e){if(e!==void 0){if(typeof e!=`string`||!e.trim()||Array.from(e.trim()).length>4||/[<>\u0000-\u001f\u007f]/.test(e))throw Error(`工具图标须为 1 至 4 个字符的文字或符号`);return e.trim()}}function uE(e){try{let t=lE(e.glyph);if(t)return t}catch{}let t=`${e.name} ${e.slug??``}`.toLowerCase();return[[/json/,`{}`],[/正则|regex/,`.*`],[/计算|calc/,`∑`],[/时间|timestamp|date/,`◷`],[/差异|diff/,`±`],[/markdown/,`M↓`],[/图像|图片|image/,`▧`],[/表格|csv|excel/,`▦`],[/颜色|color/,`◐`],[/base64/,`64`],[/hash|哈希/,`#`],[/git/,`⑂`]].find(([e])=>e.test(t))?.[1]??(Array.from(e.name.trim()).slice(0,2).join(``)||`◇`)}function dE(e){return!!(e&&typeof e==`object`&&e.type===`message.send`)}function fE(e){let t=[],n=[];for(let r of e)(r.retry?t:n).push(r);return{retry:t,failed:n}}function pE(e){let t=new Map;for(let[n,r]of e.entries())t.has(r.id)||t.set(r.id,n);return t}function mE(e,t){if(!t||t.length===0)return e;let n=new Map(t.map((e,t)=>[e,t])),r=e.filter(e=>n.has(e.id)).sort((e,t)=>(n.get(e.id)??0)-(n.get(t.id)??0));return[...e.filter(e=>!n.has(e.id)),...r]}function hE(e,t,n){if(e.indexOf(t)<0)return[...e];let r=e.filter(e=>e!==t),i=Math.max(0,Math.min(n,r.length));return[...r.slice(0,i),t,...r.slice(i)]}var gE=`super-pi.session-order.v1`;function _E(){try{if(typeof window>`u`)return{};let e=JSON.parse(window.localStorage.getItem(`super-pi.session-order.v1`)??`null`);if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e))Array.isArray(r)&&(t[n]=r.filter(e=>typeof e==`string`));return t}catch{return{}}}function vE(e){try{typeof window<`u`&&window.localStorage.setItem(gE,JSON.stringify(e))}catch{}}function yE(e,t,n){let r=new Set(e.map(e=>e.id)),i=pE(e),a=(e,t)=>(i.get(e.id)??2**53-1)-(i.get(t.id)??2**53-1),o=new Map,s=[];for(let t of e){let e=t.parentConversationId;if(e&&r.has(e)){let n=o.get(e);n?n.push(t):o.set(e,[t])}else s.push(t)}for(let e of o.values())e.sort(a);let c=mE(s.sort(a),n?.manualRoots),l=[],u=new Set,d=(e,n,r,i=!0)=>{if(u.has(e.id))return;u.add(e.id);let a=o.get(e.id)??[];i&&l.push({conversation:e,depth:Math.min(n,8),childCount:a.length,isLastSibling:r});let s=!i||t.has(e.id);for(let[e,t]of a.entries())d(t,n+1,e===a.length-1,!s)};for(let e of c)d(e,0,!1);let f=e.filter(e=>!u.has(e.id)).sort(a);for(let e of f)d(e,0,!1);return l}var bE=`super-pi:tool-shortcuts:v1`,xE=new Set([`Control`,`Alt`,`Shift`,`Meta`,`AltGraph`,`CapsLock`,`Fn`,`FnLock`,`Hyper`,`Super`,`Symbol`,`SymbolLock`]),SE=new Set([`Escape`]),CE=new Set([`Enter`,` `,`Tab`]),wE={" ":`Space`,ArrowUp:`↑`,ArrowDown:`↓`,ArrowLeft:`←`,ArrowRight:`→`,Escape:`Esc`},TE={ctrl:`⌃`,alt:`⌥`,shift:`⇧`,meta:`⌘`};function EE(e){if(e===` `)return` `;let t=e.trim();return t?t.length===1?t.toLowerCase():t:``}function DE(e){return xE.has(e)}function OE(e){let t=e.key;if(!t||t===`Unidentified`||t===`Dead`||DE(t))return;let n=EE(t);if(!n)return;let r=!!e.shiftKey;if(r&&n.length===1&&!/[a-z]/.test(n)){let t=/^Digit([0-9])$/.exec(e.code??``);t&&(n=t[1])}let i={key:n};return e.ctrlKey&&(i.ctrl=!0),e.altKey&&(i.alt=!0),r&&(i.shift=!0),e.metaKey&&(i.meta=!0),i}function kE(e){return wE[e]||(e.length===1||/^f\d{1,2}$/.test(e)?e.toUpperCase():e)}function AE(e){let t=[];return e.ctrl&&t.push(`Ctrl`),e.alt&&t.push(`Alt`),e.shift&&t.push(`Shift`),e.meta&&t.push(`Meta`),t.push(kE(e.key)),t.join(`+`)}function jE(e){let t=``;return e.ctrl&&(t+=TE.ctrl),e.alt&&(t+=TE.alt),e.shift&&(t+=TE.shift),e.meta&&(t+=TE.meta),t+kE(e.key)}function ME(e,t){return e.key===t.key&&!!e.ctrl==!!t.ctrl&&!!e.alt==!!t.alt&&!!e.shift==!!t.shift&&!!e.meta==!!t.meta}function NE(e){return!!(e.ctrl||e.alt||e.shift||e.meta)}function PE(e){return e.key?SE.has(e.key)?{ok:!1,reason:`Esc 是所有弹窗的退出键,不能拿来当工具快捷键。`}:!NE(e)&&CE.has(e.key)?{ok:!1,reason:`「${FE(e.key)}」是当前焦点控件的激活键,加一个修饰键(Ctrl / Alt / Shift)才能当快捷键用。`}:{ok:!0}:{ok:!1,reason:`这个组合键不完整,请按一个具体的键。`}}function FE(e){return kE(e)}function IE(e){let t=e;if(!t||typeof t!=`object`)return!1;let n=t.tagName;return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable===!0}function LE(e,t){if(t.isComposing||t.defaultPrevented)return!1;let n=OE(t);return!(!n||!ME(e,n)||!NE(e)&&IE(t.target??null))}function RE(e){if(!e)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t)){if(!e||typeof r!=`object`||!r)continue;let t=r,i=EE(typeof t.key==`string`?t.key:``);if(!i)continue;let a={key:i};t.ctrl===!0&&(a.ctrl=!0),t.alt===!0&&(a.alt=!0),t.shift===!0&&(a.shift=!0),t.meta===!0&&(a.meta=!0),PE(a).ok&&(n[e]=a)}return n}function zE(e){let t={};for(let n of Object.keys(e).sort()){let r=e[n];if(!r)continue;let i={key:r.key};r.ctrl&&(i.ctrl=!0),r.alt&&(i.alt=!0),r.shift&&(i.shift=!0),r.meta&&(i.meta=!0),t[n]=i}return JSON.stringify(t)}function BE(e,t,n){for(let[r,i]of Object.entries(e))if(r!==n&&ME(i,t))return r}var VE=`super-pi:tool-settings-size:v1`,HE={width:480,height:320};function UE(){try{if(typeof window>`u`)return It.slice();let e=Ht(window.localStorage.getItem(zt));return window.localStorage.getItem(`super-pi:tools:v1`)===null?It.slice():e}catch{return It.slice()}}function WE(e){try{if(typeof window>`u`)return;window.localStorage.setItem(zt,Ut(e))}catch{}}function GE(){try{return typeof window>`u`?{}:RE(window.localStorage.getItem(bE))}catch{return{}}}function KE(e){try{if(typeof window>`u`)return;window.localStorage.setItem(bE,zE(e))}catch{}}function qE(e,t,n){let r={};for(let n of t)e[n.id]&&(r[n.id]=e[n.id]);for(let e of n)e.shortcut&&(r[e.id]=e.shortcut);return r}function JE(){try{if(typeof window>`u`)return;let e=window.localStorage.getItem(VE);if(!e)return;let t=JSON.parse(e);return typeof t?.width!=`number`||typeof t?.height!=`number`||!Number.isFinite(t.width)||!Number.isFinite(t.height)||t.width<HE.width||t.height<HE.height?void 0:{width:Math.round(t.width),height:Math.round(t.height)}}catch{return}}function YE(e){try{if(typeof window>`u`)return;e?window.localStorage.setItem(VE,JSON.stringify({width:Math.round(e.width),height:Math.round(e.height)})):window.localStorage.removeItem(VE)}catch{}}function XE(e,t,n){let r=Math.max(HE.width,t-32),i=Math.max(HE.height,n-32);return{width:Math.round(Math.min(Math.max(e.width,HE.width),r)),height:Math.round(Math.min(Math.max(e.height,HE.height),i))}}var ZE=GE(),QE={tools:UE(),mountedTools:[],settingsOpen:!1,shortcuts:{}};QE.shortcuts=qE(ZE,QE.tools,QE.mountedTools);var $E=new Set;function eD(e){QE={...QE,...e};for(let e of $E)e()}function tD(e){return $E.add(e),()=>{$E.delete(e)}}var nD=()=>QE;function rD(){return(0,u.useSyncExternalStore)(tD,nD,nD)}var iD={setTools(e){WE(e);let t=new Set(e.map(e=>e.id));ZE=Object.fromEntries(Object.entries(ZE).filter(([e])=>t.has(e))),KE(ZE),eD({tools:e,shortcuts:qE(ZE,e,QE.mountedTools)})},removeTool(e){let t=qt(QE.tools,e);ZE[e]&&(ZE={...ZE},delete ZE[e],KE(ZE)),WE(t),eD({tools:t,shortcuts:qE(ZE,t,QE.mountedTools),openToolId:QE.openToolId===e?void 0:QE.openToolId})},setMountedTools(e){let t=new Set(QE.tools.map(e=>e.id));ZE=Object.fromEntries(Object.entries(ZE).filter(([e])=>t.has(e))),KE(ZE),eD({mountedTools:e,shortcuts:qE(ZE,QE.tools,e)})},openTool(e){eD({openToolId:e,settingsOpen:!1})},closeTool(){eD({openToolId:void 0})},toggleTool(e){QE.openToolId===e?iD.closeTool():iD.openTool(e)},openSettings(){eD({settingsOpen:!0,openToolId:void 0})},closeSettings(){eD({settingsOpen:!1})},async setShortcut(e,t){let n=QE.mountedTools.find(t=>t.id===e);if(n){try{let e=await Ne(`/api/tools/shortcut`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({slug:n.slug,shortcut:t})}),r=await e.json();if(!e.ok)return r.error??`快捷键保存失败(HTTP ${e.status})。`}catch(e){return e instanceof Error?e.message:String(e)}eD({mountedTools:QE.mountedTools.map(n=>n.id===e?{...n,shortcut:t}:n),shortcuts:{...QE.shortcuts,[e]:t}})}else ZE={...ZE,[e]:t},KE(ZE),eD({shortcuts:qE(ZE,QE.tools,QE.mountedTools)})},async clearShortcut(e){if(!QE.shortcuts[e])return;let t=QE.mountedTools.find(t=>t.id===e);if(t){try{let e=await Ne(`/api/tools/shortcut`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({slug:t.slug,shortcut:null})}),n=await e.json();if(!e.ok)return n.error??`快捷键清除失败(HTTP ${e.status})。`}catch(e){return e instanceof Error?e.message:String(e)}eD({mountedTools:QE.mountedTools.map(t=>t.id===e?{...t,shortcut:void 0}:t),shortcuts:Object.fromEntries(Object.entries(QE.shortcuts).filter(([t])=>t!==e))})}else ZE={...ZE},delete ZE[e],KE(ZE),eD({shortcuts:qE(ZE,QE.tools,QE.mountedTools)})},persistTools(){WE(QE.tools)}};async function aD(){let e=fe();try{let t=await Ne(`/api/tools`),n=await t.json();fe()===e&&t.ok&&Array.isArray(n.tools)&&iD.setMountedTools(n.tools.filter(e=>e.enabled))}catch{}}async function oD(e){try{let t=await Ne(`/api/tools?id=${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);iD.closeTool(),await aD();return}catch(e){return e instanceof Error?e.message:String(e)}}var sD=`.super-pi-tool.json`,cD=512e3,lD=/^[a-z0-9][a-z0-9-]{0,63}$/,uD=/^[A-Za-z0-9][A-Za-z0-9_.-]*==[^=\s,;<>|'"`\\]{1,80}$/;function dD(e,t){let n;try{n=JSON.parse(e)}catch{return{ok:!1,reason:`「${t}」不是 JSON。确认一下选的是别人分享的工具文件(${sD})。`}}if(!n||typeof n!=`object`||Array.isArray(n))return{ok:!1,reason:`这个 JSON 不是一个工具包。`};let r=n,i;try{i=lE(r.glyph)}catch{return{ok:!1,reason:`工具图标须为 1 至 4 个字符的文字或符号。`}}let a=typeof r.format==`string`?r.format:void 0;if(a!==void 0&&a!==`super-pi.tool`)return{ok:!1,reason:`这不是 Super Pi 的工具文件(format: ${a})。`};if(typeof r.version==`number`&&r.version>1)return{ok:!1,reason:`这个工具文件是更新版本的 Super Pi 导出的(version: ${r.version}),当前版本读不了。`};let o=typeof r.slug==`string`?r.slug.trim():``,s=typeof r.name==`string`?r.name.trim():``;if(!o)return{ok:!1,reason:`这个工具包里没有 slug(那是它的短名字,也是它在磁盘上的目录名)。`};if(!s)return{ok:!1,reason:`这个工具包里没有名字。`};if(!Array.isArray(r.files)||!r.files.length)return{ok:!1,reason:`这个工具包里没有文件。`};if(r.files.length>32)return{ok:!1,reason:`文件太多了:${r.files.length} 个,上限 32 个。`};let c=[],l=0;for(let e of r.files){let t=e;if(!t||typeof t.path!=`string`||typeof t.content!=`string`)return{ok:!1,reason:`工具包里的文件项格式不对(每一项都要有 path 和 content)。`};let n=t.path.trim();if(!n||n.startsWith(`/`)||n.includes(`\\`)||n.includes(`\0`)||n.split(`/`).includes(`..`))return{ok:!1,reason:`文件路径「${n}」不合法:不能是绝对路径,也不能跳出工具自己的目录。`};if(c.some(e=>e.path===n))return{ok:!1,reason:`工具包里有重复的文件:${n}`};if(l+=new TextEncoder().encode(t.content).length,l>512e3)return{ok:!1,reason:`工具文件合计超过 ${yD(cD)} 的上限。`};c.push({path:n,content:t.content})}let u=typeof r.entrypoint==`string`&&r.entrypoint.trim()?r.entrypoint.trim():`index.html`;if(!u.endsWith(`.html`))return{ok:!1,reason:`入口文件必须是一个 HTML 文件。`};if(!c.some(e=>e.path===u))return{ok:!1,reason:`工具包里没有包含入口文件 ${u}。`};let d;if(r.script!==void 0&&r.script!==null){let e=r.script,t=typeof e.path==`string`?e.path.trim():``;if(!t.endsWith(`.py`))return{ok:!1,reason:`工具包声明的脚本必须是一个 .py 文件。`};if(!c.some(e=>e.path===t))return{ok:!1,reason:`工具包里没有包含它声明的脚本 ${t}。`};d={path:t,timeoutMs:typeof e.timeoutMs==`number`?e.timeoutMs:void 0,parameters:typeof e.parameters==`object`&&e.parameters!==null?e.parameters:void 0}}let f;if(r.environment!==void 0&&r.environment!==null){let e=r.environment,t=e.requires;if(t!==void 0&&!Array.isArray(t))return{ok:!1,reason:`工具包声明的依赖列表格式不对(requires 必须是数组)。`};if(Array.isArray(t)){for(let e of t)if(typeof e!=`string`||!uD.test(e.trim()))return{ok:!1,reason:`依赖必须钉死到精确版本(写成 pkg==version):${String(e).slice(0,60)}。`}}let n=e.fingerprint&&typeof e.fingerprint==`object`?e.fingerprint:void 0;f={requiresPython:typeof e.requiresPython==`string`?e.requiresPython:void 0,requires:Array.isArray(t)?t.map(e=>String(e).trim()):void 0,fingerprint:n}}let p=r.permissions&&typeof r.permissions==`object`&&r.permissions.llm===!0?{llm:!0}:void 0;return{ok:!0,unnamedFormat:a===void 0,bundle:{...a===void 0?{}:{format:a},...typeof r.version==`number`?{version:r.version}:{},...typeof r.exportedAt==`string`?{exportedAt:r.exportedAt}:{},slug:o,name:s,...i?{glyph:i}:{},...typeof r.description==`string`&&r.description.trim()?{description:r.description.trim().slice(0,500)}:{},entrypoint:u,files:c,script:d,environment:f,...p?{permissions:p}:{}}}}function fD(e){let t=e.trim().toLowerCase();return t?lD.test(t)?{ok:!0,slug:t}:{ok:!1,reason:`slug 只能用小写字母、数字和连字符,且要以字母或数字开头。`}:{ok:!1,reason:`请填写 slug(工具的短名字,只能用小写字母、数字和连字符)。`}}function pD(e,t){let n=e.trim().toLowerCase().slice(0,60).replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``)||`tool`;if(!t.includes(n))return n;for(let e=2;e<100;e+=1){let r=`${n}-${e}`;if(!t.includes(r))return r}return n}function mD(e){return`${e.slug}${sD}`}function hD(e){let t=e.trim().replace(/[\\/:*?"<>|]/g,``).replace(/\.+$/,``).trim();return t?t.length>80?{ok:!1,reason:`文件名太长了,请控制在 80 个字符以内。`}:{ok:!0,name:t.endsWith(`.super-pi-tool.json`)?t:`${t}${sD}`}:{ok:!1,reason:`请填写文件名。`}}function gD(e){if(e.permissions?.llm)return{tone:`warn`,text:`这个工具可以调用模型:它能把内容发给你的模型回答,每次调用都会用你的模型额度`}}function _D(e){let t=e.environment?.requires??[];return!e.script&&t.length===0?{tone:`ok`,text:`纯页面工具 · 导入即用,不需要 Python`}:t.length===0?{tone:`ok`,text:`只用 Python 标准库 · 导入即用,不需要安装任何包${e.environment?.requiresPython?`(需要 Python ${e.environment.requiresPython})`:``}`}:{tone:`warn`,text:`首次运行时会安装 ${t.length} 个依赖:${t.join(`、`)}(装进这个工具自己的虚拟环境)${e.environment?.requiresPython?` · 需要 Python ${e.environment.requiresPython}`:``}`}}function vD(e){if(e)return e.state===`zero-deps`?{text:`零依赖`,warn:!1}:e.state===`ready`?{text:`环境就绪`,warn:!1}:e.state===`needs-env`?{text:`首次运行时安装依赖`,warn:!1}:e.state===`needs-python`?{text:`缺少可用的 Python`,warn:!0}:{text:`与导出方环境不一致`,warn:!0}}function yD(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function bD(e,t){let{format:n,version:r,exportedAt:i,...a}=e;return{...a,slug:t}}var xD=`请基于上面的请求、已输出的内容和已完成的操作继续完成任务。优先给出简洁结论或执行必要的小步骤,不要重复已有内容或已成功的写入。`;function SD(e){return/^\s*<continue_output>([\s\S]*?)<\/continue_output>\s*$/.exec(e)?.[1].trim()}function CD(e){return!Number.isFinite(e)||e<=0?``:e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function wD(e){return!Number.isFinite(e)||e<=0?``:e>=1e6?`${Math.round(e/1e6)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function TD(e,t){if(!e)return 0;let n=0;for(let r of t)n+=e[r]??0;return n}var ED=128e3;function DD(e){let t=[[]],n=0,r=0,i=[0,0],a=e=>{for(;t.length<=e;)t.push([])},o=e=>{let i=t[n];for(;i.length<r;)i.push(` `);for(let t of e)i[r]=t,r+=1},s=e=>e.replace(/^[?>!]/u,``).split(`;`).map(e=>Number.parseInt(e,10)||0),c=(e,o)=>{let c=s(e),l=Math.max(1,c[0]||1);switch(o){case`A`:n=Math.max(0,n-l);break;case`B`:case`e`:n+=l,a(n);break;case`C`:case`a`:r+=l;break;case`D`:r=Math.max(0,r-l);break;case`E`:n+=l,a(n),r=0;break;case`F`:n=Math.max(0,n-l),r=0;break;case`G`:case"`":r=Math.max(0,l-1);break;case`d`:n=Math.max(0,l-1),a(n);break;case`H`:case`f`:n=Math.max(0,l-1),a(n),r=Math.max(0,(c[1]||1)-1);break;case`K`:{let e=t[n];(c[0]??0)===2?t[n]=[]:(c[0]??0)===1?t[n]=[...Array.from({length:Math.min(r+1,e.length)},()=>` `),...e.slice(r+1)]:e.splice(r);break}case`J`:(c[0]??0)===2||(c[0]??0)===3?(t.splice(0,t.length,[]),n=0,r=0):(c[0]??0)===0?t.splice(n+1):(c[0]??0)===1&&(t.splice(0,n),n=0,t[0]=[]);break;case`s`:i=[n,r];break;case`u`:[n,r]=i,a(n);break;case`P`:t[n].splice(r,l);break;case`X`:{let e=t[n];for(let t=r;t<Math.min(e.length,r+l);t+=1)e[t]=` `;break}case`@`:t[n].splice(r,0,...Array.from({length:l},()=>` `))}},l=t=>{for(let n=t;n<e.length;n+=1){if(e[n]===`\x07`)return n+1;if(e[n]===`\x1B`&&e[n+1]===`\\`)return n+2}return e.length};for(let t=0;t<e.length;){let i=e[t];if(i===``||i===``||i===``||i===``){t=l(t+1);continue}if(i===`\x1B`||i===``){let n=e[t+1];if(i===`\x1B`&&(n===`]`||n===`P`||n===`^`||n===`_`)){t=l(t+2);continue}if(i===`\x1B`&&n===`[`||i===``){let n=t+(i===``?1:2),r=n;for(;r<e.length&&!(e.charCodeAt(r)>=64&&e.charCodeAt(r)<=126);)r+=1;r<e.length&&c(e.slice(n,r),e[r]),t=Math.min(e.length,r+1);continue}t+=n===void 0?1:2;continue}if(i===`\r`){t+=1,r=0;continue}if(i===`
|
|
331
331
|
`){t+=1,n+=1,a(n),r=0;continue}if(i===`\b`){t+=1,r=Math.max(0,r-1);continue}if(i===` `){t+=1,o(` `.repeat(8-r%8));continue}let s=e.codePointAt(t)??0;if(s<32||s===127||s>=128&&s<=159){t+=s>65535?2:1;continue}let u=String.fromCodePoint(s);o(u),t+=u.length}return t.map(e=>e.join(``)).join(`
|
|
332
332
|
`).replace(/\n+$/u,``)}function OD(e){return[e.partialOutput??e.output,...(e.toolCalls??[]).map(e=>e.output)].filter(Boolean).join(`
|
|
333
333
|
|
|
@@ -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 kO({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?OO(e):{label:DO(e),state:`user`},C=()=>{let t=g.trim();t&&t!==e.content&&p(e.id,t),h(!1)};return(0,F.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,F.jsx)(`input`,{type:`checkbox`,className:`queue-select`,"data-waiting-select":e.id,checked:o,"aria-label":`选择「${x}」`,onChange:()=>s?.(e.id)}),(0,F.jsx)(`span`,{className:`queue-index`,"aria-hidden":`true`,children:t}),y?(0,F.jsxs)(`span`,{className:`queue-reminder`,"data-queue-reminder":!0,children:[(0,F.jsxs)(`span`,{className:`reminder-label`,children:[(0,F.jsx)(`span`,{"aria-hidden":`true`,children:`◷`}),` 定时提醒`]}),(0,F.jsx)(`span`,{className:`queue-text`,title:x,children:x})]}):b?(0,F.jsxs)(`span`,{className:`queue-bg-result`,title:x,children:[(0,F.jsx)(`span`,{className:`bg-result-glyph`,"aria-hidden":`true`,children:S===`error`?`✕`:`↩`}),(0,F.jsx)(`span`,{className:`bg-result-label`,children:`后台回传`}),(0,F.jsx)(`span`,{className:`bg-result-summary`,children:x})]}):m?(0,F.jsxs)(`div`,{className:`queue-row-edit`,children:[(0,F.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,F.jsx)(`button`,{type:`button`,className:`queue-edit-save`,"data-waiting-save":e.id,onClick:C,children:`保存`}),(0,F.jsx)(`button`,{type:`button`,className:`queue-edit-cancel`,"data-waiting-cancel-edit":e.id,onClick:()=>{_(e.content),h(!1)},children:`取消`})]}):(0,F.jsx)(`span`,{className:`queue-text`,title:x,children:x}),(0,F.jsx)(`span`,{className:`queue-state`,"data-waiting-state":v?`sending`:`queued`,children:v?`已交给 Agent`:t===1?`下一条回答这条`:`等待回答 · 第 ${t} 条`}),v?(0,F.jsx)(`span`,{className:`queue-locked`,"data-waiting-locked":e.id,children:`暂时改不了`}):(0,F.jsxs)(F.Fragment,{children:[r?(0,F.jsxs)(F.Fragment,{children:[(0,F.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,F.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,F.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,F.jsx)(`button`,{type:`button`,className:`queue-edit`,"data-waiting-edit":e.id,title:`回答这条之前改字`,"aria-label":`修改「${x}」`,onClick:()=>{_(e.content),h(!0)},children:`改字`}),(0,F.jsx)(`button`,{type:`button`,className:`queue-cancel`,"data-waiting-cancel":e.id,title:`撤回这条消息,它不会被回答`,"aria-label":`撤回「${x}」`,onClick:()=>f(e.id),children:`撤回`})]})]})}function AO(e,t,n){return`${e}:${t}:${n}`}function jO(e){return{picked:Object.fromEntries((e.answers??[]).map(e=>[e.id,e.selected])),note:e.answers?.map(e=>e.note??``).join(`
|
|
339
339
|
`)??``}}function MO({question:e,index:t,expanded:n,draft:r,onDraftChange:i,onToggle:a,onAnswer:o}){return(0,F.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,F.jsx)(`button`,{type:`button`,className:`call-fold-edge`,"data-question-fold-edge":t,"aria-expanded":n,"aria-label":`${n?`折叠`:`展开`}提问`,title:n?`折叠这段提问`:`展开这段提问`,onClick:a}),(0,F.jsxs)(`div`,{className:`call-head-row`,children:[(0,F.jsxs)(`button`,{type:`button`,className:`call-head`,"data-call-head":t,"aria-expanded":n,onClick:a,children:[(0,F.jsx)(`span`,{className:`call-chevron`,"aria-hidden":`true`,children:n?`▾`:`▸`}),(0,F.jsx)(`span`,{className:`call-glyph`,"aria-hidden":`true`,children:e.status===`answered`?`✓`:e.status===`cancelled`?`✕`:`?`}),(0,F.jsx)(`span`,{className:`call-label`,children:`提问`}),(0,F.jsxs)(`span`,{className:`call-detail`,children:[e.items.length,` 个问题`]})]}),n&&(0,F.jsx)(`button`,{type:`button`,className:`call-fold-top`,"data-call-fold-top":t,onClick:a,children:`收起`})]}),n&&(0,F.jsx)(`div`,{className:`question-body`,"data-question-body":t,children:(0,F.jsx)(NO,{question:e,draft:r,onDraftChange:i,instanceId:`inline`,onAnswer:o})})]})}function NO({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,F.jsxs)(`div`,{className:`question-block question-${e.status}`,"data-question-status":e.status,children:[e.items.map(i=>(0,F.jsxs)(`div`,{className:`question-item`,children:[(0,F.jsx)(`div`,{className:`question-text`,children:i.header?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`question-header`,children:i.header}),(0,F.jsx)(`span`,{className:`question-sep`,children:` · `}),(0,F.jsx)(ef,{source:i.question})]}):(0,F.jsx)(ef,{source:i.question})}),(0,F.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,F.jsxs)(`label`,{className:o?`is-chosen`:``,"data-chosen":n&&o?`1`:void 0,children:[(0,F.jsx)(`input`,{type:i.multiple?`checkbox`:`radio`,name:`q-${r}-${i.id}`,checked:o,disabled:n,onChange:()=>s(i.id,t,i.multiple)}),(0,F.jsx)(tf,{source:t}),n&&o?(0,F.jsx)(`span`,{className:`question-mark`,"aria-label":`已选择`,children:`✓`}):null]},t)})}),e.status===`pending`&&i.extraNote?(0,F.jsx)(`textarea`,{value:o,placeholder:`补充说明(可选)`,onChange:e=>n({...t,note:e.target.value})}):e.status===`answered`&&(e.answers??[]).some(e=>e.note)?(0,F.jsxs)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:[`补充:`,(e.answers??[]).map(e=>e.note).filter(Boolean).join(`;`)]}):null,e.status===`cancelled`&&(0,F.jsx)(`div`,{className:`question-summary`,"data-question-summary":`1`,children:`已取消,没有作答。`})]},i.id)),e.status===`pending`&&(0,F.jsxs)(`div`,{className:`question-actions`,children:[(0,F.jsx)(`button`,{type:`button`,onClick:c,disabled:!l,children:`提交`}),(0,F.jsx)(`button`,{type:`button`,className:`question-skip`,onClick:()=>i([],!0),children:`跳过`})]})]})}function PO({question:e,pendingCount:t,minimized:n,floatingRight:r,onMinimize:i,onExpand:a,onLocate:o,draft:s,onDraftChange:c,onAnswer:l}){return n?(0,Re.createPortal)((0,F.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,F.jsx)(`span`,{"aria-hidden":`true`,children:`?`}),t>1&&(0,F.jsx)(`small`,{children:t})]}),document.body):(0,Re.createPortal)((0,F.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,F.jsxs)(`header`,{className:`question-floating-head`,children:[(0,F.jsx)(`span`,{className:`question-floating-mark`,"aria-hidden":`true`,children:`?`}),(0,F.jsxs)(`h2`,{id:`question-floating-title`,children:[`需要你回答`,t>1?` · 还有 ${t-1} 个`:``]}),(0,F.jsx)(`button`,{type:`button`,className:`question-floating-minimize`,onClick:o,title:`定位到消息上下文并最小化`,children:`查看上下文`}),(0,F.jsx)(`button`,{type:`button`,className:`question-floating-minimize-icon`,onClick:i,title:`最小化为悬浮球`,"aria-label":`最小化问题`,children:`−`})]}),(0,F.jsx)(`div`,{className:`question-floating-body`,children:(0,F.jsx)(NO,{question:e.value,draft:s,onDraftChange:c,instanceId:`floating`,onAnswer:l})})]}),document.body)}function FO({request:e,onAnswer:t,pending:n}){let[r,i]=(0,u.useState)(e.prefill??``),a=e.method===`input`||e.method===`editor`,o=(0,F.jsx)(`button`,{type:`button`,className:`extui-cancel`,onClick:()=>t({cancelled:!0}),children:`取消提问`});return(0,F.jsxs)(`article`,{className:`extui-card extui-${e.method}`,"data-request-id":e.requestId,"data-method":e.method,children:[(0,F.jsxs)(`div`,{className:`extui-head`,children:[(0,F.jsx)(`span`,{className:`extui-badge`,children:`扩展提问`}),e.timeoutMs!==void 0&&(0,F.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,F.jsx)(`p`,{className:`extui-pending`,role:`status`,children:`提交中…`}),(0,F.jsxs)(`fieldset`,{disabled:n,style:{border:0,padding:0,margin:0},children:[(0,F.jsx)(`h3`,{className:`extui-title`,children:e.title||YO[e.method]}),e.method===`confirm`&&(0,F.jsx)(`p`,{className:`extui-body`,children:e.message}),e.method===`select`&&(0,F.jsxs)(`div`,{className:`extui-options`,children:[(e.options??[]).map(e=>(0,F.jsx)(`button`,{type:`button`,className:`extui-option`,onClick:()=>t({value:e}),children:e},e)),(e.options??[]).length===0&&(0,F.jsx)(`p`,{className:`extui-body`,children:`扩展没有提供任何选项`})]}),a&&(0,F.jsxs)(`form`,{className:`extui-form`,onSubmit:e=>{e.preventDefault(),!n&&r.trim()&&t({value:r})},children:[e.method===`input`?(0,F.jsx)(`input`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ND(e)&&e.preventDefault()},placeholder:e.placeholder??``}):(0,F.jsx)(`textarea`,{className:`extui-field`,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ND(e)&&e.preventDefault()}}),(0,F.jsxs)(`div`,{className:`extui-actions`,children:[(0,F.jsx)(`button`,{type:`submit`,className:`extui-primary`,disabled:!r.trim(),children:`提交`}),o]})]}),!a&&(0,F.jsxs)(`div`,{className:`extui-actions`,children:[e.method===`confirm`&&(0,F.jsx)(`button`,{type:`button`,className:`extui-primary`,onClick:()=>t({confirmed:!0}),children:`确认`}),e.method===`confirm`&&(0,F.jsx)(`button`,{type:`button`,className:`extui-no`,onClick:()=>t({confirmed:!1}),children:`拒绝`}),o]})]})]})}function IO({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,F.jsxs)(`div`,{className:`inline-edit`,"data-editing":`1`,children:[(0,F.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(ND(e))return;e.preventDefault(),d()}else e.key===`Escape`&&(e.preventDefault(),l())},onBlur:()=>{s.current||r()}}),(0,F.jsx)(`button`,{type:`button`,className:`inline-edit-ok`,title:`确认重命名`,"aria-label":`确认重命名`,disabled:c,onMouseDown:e=>e.preventDefault(),onClick:d,children:`✓`}),(0,F.jsx)(`button`,{type:`button`,className:`inline-edit-cancel`,title:`取消重命名`,"aria-label":`取消重命名`,onMouseDown:e=>e.preventDefault(),onClick:l,children:`✗`})]})}function LO({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=aO(l?i.filter(e=>_===`*`||e.key!==RO&&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(ND(e))return;e.preventDefault(),D&&(s(D.key),O(!0))}}},ee=`picker-list-${c??e}`,M=t=>`picker-option-${c??e}-${t}`;return(0,F.jsxs)(`div`,{className:`session-picker-item session-picker-${e}`,ref:y,onKeyDown:d?j:void 0,children:[(0,F.jsxs)(`button`,{ref:b,type:`button`,className:`session-picker-trigger`,disabled:a,"aria-haspopup":`listbox`,"aria-expanded":d,title:o??`${ZD[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,F.jsx)(`span`,{className:`session-picker-kind`,children:ZD[e]}),(0,F.jsx)(`span`,{className:`session-picker-name`,children:t}),r&&(0,F.jsx)(`span`,{className:`session-picker-detail`,children:r}),(0,F.jsx)(`span`,{className:`session-picker-caret`,"aria-hidden":`true`,children:`▾`})]}),d&&(0,F.jsxs)(`div`,{className:`picker-menu`,ref:x,"data-picker-menu":e,"data-picker-highlight":E,children:[l&&(0,F.jsxs)(`label`,{className:`picker-provider-filter`,children:[(0,F.jsx)(`span`,{children:`Provider`}),(0,F.jsxs)(`select`,{"data-picker-provider":e,"aria-label":`筛选模型 Provider`,value:_,onKeyDown:e=>e.stopPropagation(),onChange:e=>{v(e.target.value),g(0)},children:[(0,F.jsx)(`option`,{value:`*`,children:`全部 Provider`}),l.map(e=>(0,F.jsx)(`option`,{value:e,children:e},e))]})]}),(0,F.jsxs)(`div`,{className:`picker-filter`,children:[(0,F.jsx)(`span`,{className:`picker-filter-icon`,"aria-hidden":`true`,children:`🔍`}),(0,F.jsx)(`input`,{ref:S,className:`picker-filter-input`,"data-picker-filter":e,role:`combobox`,"aria-label":`筛选${$D[e]}选项`,"aria-expanded":`true`,"aria-controls":ee,"aria-autocomplete":`list`,"aria-activedescendant":D?M(E):void 0,value:p,placeholder:`输入以筛选…`,autoComplete:`off`,spellCheck:!1,onChange:e=>{m(e.target.value),g(0)}}),p&&(0,F.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,F.jsxs)(`div`,{className:`picker-current`,"data-picker-current":e,"data-picker-current-value":w.key,children:[(0,F.jsx)(`span`,{className:`picker-current-label`,children:`当前`}),(0,F.jsx)(`span`,{className:`picker-current-value`,children:w.label})]}),(0,F.jsxs)(`div`,{className:`picker-list`,role:`listbox`,id:ee,"aria-label":tO[e],children:[T.map((e,t)=>(0,F.jsxs)(`button`,{id:M(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,F.jsx)(`span`,{className:`picker-option-swatch`,style:{background:e.color},"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`picker-option-name`,children:e.label}),e.badge&&(0,F.jsx)(`span`,{className:`picker-option-badge`,"data-picker-option-badge":e.badge,children:e.badge}),e.detail&&(0,F.jsx)(`span`,{className:`picker-option-detail`,children:e.detail}),e.selected&&(0,F.jsx)(`span`,{className:`picker-option-mark`,"aria-hidden":`true`,children:`✓`})]},e.key)),T.length===0&&(0,F.jsx)(`div`,{className:`picker-empty`,"data-picker-empty":e,children:i.length===0?eO[e]:`没有匹配「${p.trim()}」的${$D[e]}`})]})]})]})}var RO=`__pi_default__`;function zO({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:RO,label:`跟随 Pi 默认`,detail:`不为新会话指定模型`,selected:l===void 0},...(t?.models??[]).map(e=>({key:`${e.provider}/${e.modelId}`,label:e.label,detail:[e.detail,CD(e.contextWindow)?`${CD(e.contextWindow)} 上下文`:``,wD(e.maxTokens)?`${wD(e.maxTokens)} 输出`:``].filter(Boolean).join(` · `),badge:rO(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:RO,label:`跟随 Pi 默认`,detail:`不为新会话指定思考等级`,selected:f===void 0},..._.map(e=>({key:e,label:e,selected:e===f}))],y=e=>{if(e===RO){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===RO?void 0:e),x=[{key:RO,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,F.jsx)(`div`,{className:`overlay`,onClick:o,children:(0,F.jsxs)(`div`,{className:`picker settings-dialog`,"data-settings-dialog":`1`,onClick:e=>e.stopPropagation(),children:[(0,F.jsx)(`h2`,{children:`工作区设置`}),(0,F.jsxs)(`div`,{className:`settings-scope`,children:[e.name,` · 默认值只影响之后新建的会话,已有会话不变`]}),(0,F.jsx)(`div`,{className:`workspace-settings-path`,children:e.path}),(0,F.jsxs)(`div`,{className:`settings-row`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`默认智能体`}),(0,F.jsx)(LO,{kind:`agent`,scope:`settings-agent`,label:n?.agents.find(e=>e.id===s)?.name??`跟随 Pi 默认`,value:s??RO,detail:s?`${n?.agents.find(e=>e.id===s)?.toolSummary??``}`:void 0,options:x,disabled:!n||n.source===`unavailable`,note:fO(n),onChoose:e=>c(e===RO?void 0:e)})]}),(0,F.jsxs)(`div`,{className:`settings-row`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`默认模型`}),(0,F.jsx)(LO,{kind:`model`,scope:`settings-model`,label:l?.label??`跟随 Pi 默认`,value:l?`${l.provider}/${l.modelId}`:RO,detail:l?`${l.provider}/${l.modelId}`:void 0,options:h,providerOptions:[...new Set((t?.models??[]).map(e=>e.provider))],disabled:!m,note:dO(`模型`,t),onChoose:y})]}),(0,F.jsxs)(`div`,{className:`settings-row`,children:[(0,F.jsx)(`span`,{className:`settings-label`,children:`思考强度`}),(0,F.jsx)(LO,{kind:`thinking`,scope:`settings-thinking`,label:f??`跟随 Pi 默认`,value:f??RO,options:v,disabled:!m,note:dO(`思考等级`,t),onChoose:b})]}),l&&g&&_.length===0&&(0,F.jsx)(`div`,{className:`settings-scope`,children:`Pi 未提供此模型的可选等级,使用模型默认值。`}),(0,F.jsxs)(`div`,{className:`picker-actions`,children:[(0,F.jsx)(`button`,{type:`button`,className:`settings-rename`,"data-settings-rename":`1`,onClick:i,children:`重命名工作区`}),(0,F.jsx)(`button`,{type:`button`,className:`picker-cancel`,"data-settings-cancel":`1`,onClick:o,children:`取消`}),(0,F.jsx)(`button`,{type:`button`,className:`picker-ok`,"data-settings-save":`1`,onClick:()=>r(s,l,f),children:`保存`})]}),(0,F.jsx)(`button`,{type:`button`,className:`workspace-delete`,onClick:a,children:`从列表移除工作区`})]})})}var BO=[{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`}],VO=`super-pi.right-tabs.v1`;function HO(){let e=e=>BO.some(t=>t.id===e),t={tab:BO[0].id,byConversation:{}};try{let n=JSON.parse(Pn(VO)??`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 UO={waiting:`⋯`,running:``,failed:``,question:`?`,completed:``,unread:`•`,idle:``,awaiting_background:`⚙`,pending_report:`↑`,awaiting_subordinates:`↓`,awaiting_decision:`▲`},WO={idle:`空闲`,running:`讨论中`,awaiting_background:`后台任务进行中`,completed:`讨论已完成`,failed:`讨论未完成`},GO={waiting:`等待 LLM`,running:`进行中`,failed:`出错`,question:`等你回答`,completed:`已完成`,unread:`有未读`,idle:`空闲`,awaiting_background:`等待后台任务`,pending_report:`待汇报`,awaiting_subordinates:`等待下级`,awaiting_decision:`等上面拍板`},KO={idle:`就绪`,waiting:`等待 LLM`,running:`正在生成`,completed:`已完成`,stopped:`已停止`,failed:`运行失败`,awaiting_background:`等待后台任务`},qO=e=>e?.status===`running`||e?.status===`waiting`,JO={running:`运行中`,completed:`已完成`,failed:`失败`,stopped:`已停止`,cancelled:`已取消`,interrupted:`已中断`},YO={select:`请选择一项`,confirm:`请确认`,input:`请输入内容`,editor:`请输入内容`,notify:`扩展通知`,setStatus:`扩展状态`,setWidget:`扩展内容`,setTitle:`扩展标题`,set_editor_text:`扩展输入`};function XO(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 ZO(e,t,n){let r=(t||[]).filter(t=>t.parentConversationId===e.id),i=(t||[]).find(t=>t.id===e.parentConversationId),a=n??``;return Hn({conversation:e,parent:i,directChildren:r,isTopLevelUnread:e.updatedAt>a})}function QO(e,t,n,r){let i=ZO(e,r,n);return Un({status:e.status,reportingState:i,awaitingQuestion:t,quietWhenRead:!0})}function $O(e,t){return t===`awaiting_decision`||e===`awaiting_decision`?(0,F.jsx)(`span`,{className:`conversation-status-badge badge--warning project-status-awaiting_decision`,"data-session-status":`awaiting_decision`,"data-reporting-badge":`awaiting_decision`,title:GO.awaiting_decision,children:GO.awaiting_decision}):t===`awaiting_subordinates`||e===`awaiting_subordinates`?(0,F.jsx)(`span`,{className:`conversation-status-badge project-status-awaiting_subordinates`,"data-session-status":`awaiting_subordinates`,"data-reporting-badge":`awaiting_subordinates`,title:GO.awaiting_subordinates,children:GO.awaiting_subordinates}):t===`pending_report`||e===`pending_report`?(0,F.jsx)(`span`,{className:`conversation-status-badge project-status-pending_report`,"data-session-status":`pending_report`,"data-reporting-badge":`pending_report`,title:GO.pending_report,children:GO.pending_report}):null}function ek({state:e,label:t=GO[e]}){let n=UO[e];if(e===`idle`)return null;let r=e.replace(/_/g,`-`);return(0,F.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,F.jsx)(`i`,{className:`session-state-mark`,"aria-hidden":`true`,children:n})})}function tk(e,t){return(0,F.jsxs)(F.Fragment,{children:[e.origin===`orchestrator`&&(0,F.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`orchestrator`,title:`编排会话:由上级智能体创建`,"aria-label":`编排会话:由上级智能体创建`,children:`编排`}),t&&(0,F.jsx)(`span`,{className:`conversation-origin`,"data-conversation-origin":`scheduled`,title:`定时任务会话:${t.name}`,"aria-label":`定时任务会话:${t.name}`,children:`定时`})]})}function nk(e,t){let n=[];return e.origin===`orchestrator`&&n.push(`编排会话`),t&&n.push(`定时任务会话:${t.name}`),n.length?`(${n.join(`;`)})`:``}var rk={pending:`未开始`,in_progress:`运行中`,completed:`已完成`},ik={pending:`○`,in_progress:`◐`,completed:`✓`},ak={high:`高`,medium:`中`,low:`低`};function ok(e){let t=e.filter(e=>e.status!==`completed`).length;return e.length?t?`${t} 个未完成 / 共 ${e.length} 个`:`全部完成:${e.length} 个`:`0 个待办任务`}function sk({todo:e,index:t}){let n=e.id??`todo_${t}`;return(0,F.jsxs)(`li`,{className:`todo-item todo-${e.status}`,"data-todo-item":n,"data-todo-status":e.status,title:`状态:${rk[e.status]}`,children:[(0,F.jsx)(`span`,{className:`todo-mark`,"aria-hidden":`true`,children:ik[e.status]}),(0,F.jsx)(`span`,{className:`todo-text`,children:e.content}),(0,F.jsx)(`span`,{className:`todo-status`,"data-todo-status-text":`1`,children:rk[e.status]}),e.priority&&(0,F.jsx)(`span`,{className:`todo-priority`,"data-todo-priority":e.priority,children:ak[e.priority]})]})}function ck(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 lk({tasks:e,runs:t,execOutputs:n,onStop:r}){return(0,F.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?JO[o]??(/[\u3400-\u9fff]/.test(o)?o:`未知状态`):`未知状态`;return(0,F.jsx)(uk,{task:e,status:s,run:t?.get(e.id),execOutputs:n,onStop:r},a)})})}function uk({task:e,status:t,run:n,execOutputs:r,onStop:i}){let[a,o]=(0,u.useState)(!1),s=_O(e.id,r),c=n?OD(n):s?.text||e.output,l=c&&DD(c),d=n?n.outputTruncated||n.toolCalls?.some(e=>e.outputTruncated):s?.truncated??e.outputTruncated;return(0,F.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,F.jsxs)(`button`,{type:`button`,className:`bg-item-toggle`,onClick:()=>o(e=>!e),"aria-expanded":a,"aria-label":`展开后台任务详情`,children:[(0,F.jsx)(`span`,{className:`bg-title`,children:e.title?.trim()||e.id||`未命名任务`}),(0,F.jsxs)(`span`,{className:`bg-meta`,children:[e.agentId?.trim()&&(0,F.jsx)(`span`,{className:`bg-agent`,"data-bg-agent":e.agentId,children:e.agentId}),(0,F.jsx)(`span`,{className:`bg-status`,children:t})]})]}),i&&(0,F.jsx)(`button`,{type:`button`,className:`bg-stop-btn`,"data-bg-task-stop":e.id,title:`终止后台任务`,onClick:()=>i(e.id),children:`终止`}),a&&(0,F.jsx)(`pre`,{className:`bg-output`,"data-bg-output":e.id,children:[d?`日志仅保留最近一段。`:``,l].filter(Boolean).join(`
|
|
340
340
|
|
|
341
|
-
`)||`运行中,暂无输出`})]})}var dk=(0,u.lazy)(()=>vn(()=>import(`./GitDiffEditor-
|
|
341
|
+
`)||`运行中,暂无输出`})]})}var dk=(0,u.lazy)(()=>vn(()=>import(`./GitDiffEditor-Bt1n2la-.js`),__vite__mapDeps([22,1,2,3,4,0,21,23])));function fk({todos:e,tasks:t,backgroundRuns:n,execOutputs:r,scheduledTasks:i,scheduledCatalog:a,scheduledAgents:o,collapsed:s,onToggle:c,workspaceId:l,gitWorkspaceId:u=l,gitRepositoryOnly:d=!1,workspaceLabel:f,workspaceName:p,gitWorkspaceName:m=p,cwd:h=``,conversationId:g,followedWorktreeId:_,connected:v,files:y,onOpenFile:b,onOpenChanged:x,onOpenGitDiff:S,activeGitDiffUrl:C,onFileReference:w,onFilesMoved:T,onSearchFolder:E,activeTab:D,onSelectTab:O,sendCommand:k,registerTerminalSink:A,terminalShell:j,notify:ee,serverTimeZone:M,onOpenSession:te,side:N,onArrange:ne,pinned:re=!0,sharedGit:ie}){let ae=BO,oe=N===`left`;return(0,F.jsx)(`div`,{className:`right-rail${N?` workbench-panel workbench-panel-`+N:``}${s?` right-rail-collapsed`:``}`,role:`complementary`,"aria-label":oe?`左侧栏`:`右侧栏`,"data-right-rail":oe?void 0:`1`,"data-right-rail-collapsed":s,"data-workbench-panel":N,hidden:N&&s?!0:void 0,children:s?!N&&(0,F.jsx)(`button`,{type:`button`,className:`right-rail-open`,"data-right-rail-open":`1`,title:`展开右侧栏`,"aria-label":`展开右侧栏`,onClick:c,children:`‹`}):(0,F.jsxs)(F.Fragment,{children:[N?(0,F.jsxs)(`div`,{className:`workbench-panel-heading`,children:[(0,F.jsx)(`h2`,{children:Ir[D]}),ne&&(0,F.jsx)(Jr,{view:D,side:N,pinned:re,onArrange:ne}),(0,F.jsx)(`button`,{type:`button`,className:`workbench-icon-button`,"data-right-rail-collapse":oe?void 0:`1`,title:oe?`收起左侧栏`:`收起右侧栏`,"aria-label":oe?`收起左侧栏`:`收起右侧栏`,onClick:c,children:(0,F.jsx)(Gr,{name:`close`})})]}):(0,F.jsxs)(`div`,{className:`right-rail-head`,children:[(0,F.jsx)(`div`,{className:`right-tabs`,role:`tablist`,"aria-label":`右侧栏 tab`,"data-right-tab-count":ae.length,children:ae.map(e=>(0,F.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,F.jsx)(`button`,{type:`button`,className:`right-rail-collapse`,"data-right-rail-collapse":`1`,title:`收起右侧栏(聊天区会变宽)`,"aria-label":`收起右侧栏`,onClick:c,children:`›`})]}),BO.filter(e=>e.id===D).map(s=>(0,F.jsxs)(`div`,{className:`right-rail-body`,role:`tabpanel`,id:`right-panel-${s.id}`,"aria-label":N?Ir[s.id]:void 0,"aria-labelledby":N?void 0:`right-tab-${s.id}`,"data-right-panel":s.id,children:[s.id===`main`&&(0,F.jsxs)(F.Fragment,{children:[(e.length>0||t.length>0)&&(0,F.jsxs)(`p`,{className:`rail-legend`,"data-rail-legend":`1`,children:[(0,F.jsx)(`span`,{className:`rail-legend-label`,children:`左侧竖条=状态`}),(0,F.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,F.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-pending`,"aria-hidden":`true`}),`未开始`]}),(0,F.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,F.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-running`,"aria-hidden":`true`}),`运行中`]}),(0,F.jsxs)(`span`,{className:`rail-legend-item`,children:[(0,F.jsx)(`span`,{className:`rail-legend-swatch rail-legend-swatch-done`,"aria-hidden":`true`}),`已完成`]})]}),(0,F.jsxs)(`div`,{className:`rail-task-sections`,children:[(0,F.jsx)(Ow,{id:`todos`,title:`待办任务`,icon:`tasks`,count:(0,F.jsx)(`span`,{"data-todo-summary":`1`,children:ok(e)}),children:e.length>0?(0,F.jsx)(`ol`,{className:`todo-list`,"data-todo-count":e.length,children:e.map((e,t)=>(0,F.jsx)(sk,{todo:e,index:t},e.id??`todo_${t}`))}):(0,F.jsx)(`p`,{className:`rail-empty`,"data-todo-empty":`1`,children:`暂无待办任务。开始多步骤任务后会自动显示。`})}),(0,F.jsx)(Ow,{id:`background`,title:`后台任务`,icon:`activity`,count:(0,F.jsx)(`span`,{"data-bg-summary":`1`,children:t.length?`${t.filter(e=>e.status===`running`).length} 个运行中 / 共 ${t.length} 个`:`0 个`}),children:t.length>0?(0,F.jsx)(lk,{tasks:t,runs:n,execOutputs:r,onStop:e=>k({type:`backgroundTask.stop`,taskId:e})}):(0,F.jsx)(`p`,{className:`rail-empty`,"data-bg-empty":`1`,children:`当前没有正在运行的后台任务。`})}),(0,F.jsx)(Hw,{tasks:i,workspaceId:l,catalog:a,agents:o,sendCommand:k,notify:ee,serverTimeZone:M})]})]}),s.id===`projects`&&(0,F.jsx)(DT,{workspaceId:l,notify:ee,onOpenSession:te,onOpenFile:b,cwd:h},l),s.id===`tools`&&(0,F.jsx)(pk,{workspaceId:l},l),s.id===`files`&&(0,F.jsx)(Pm,{workspaceId:l,workspaceName:p,cwd:h,files:y,onOpenFile:b,onOpenChanged:x,onReference:w,onMoved:T,onSearchFolder:E}),s.id===`git`&&(0,F.jsx)(Ni,{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:te,sharedGit:ie},JSON.stringify([u,h,g,d])),s.id===`terminal`&&(0,F.jsx)(Dw,{workspaceId:l,workspaceLabel:f,cwd:h,conversationId:g,connected:v,sendCommand:k,registerSink:A,terminalShell:j},JSON.stringify([l,g]))]},s.id))]})})}function pk({workspaceId:e}){let{tools:t,mountedTools:n,openToolId:r,shortcuts:i}=rD(),[a,o]=(0,u.useState)(),s=async e=>{o(void 0);let t=await oD(e);t&&o(`移除工具失败:${Or(t)}`)},c=(e,t)=>t?`打开${e}(快捷键 ${AE(t)})`:`打开${e}`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`rail-section-head`,children:[(0,F.jsx)(`h2`,{className:`rail-section-title`,children:`工具`}),(0,F.jsxs)(`span`,{className:`rail-section-count`,"data-tool-summary":`1`,children:[t.length+n.length,` 个`]})]}),t.length+n.length>0?(0,F.jsxs)(`ul`,{className:`tool-grid`,"data-tool-count":t.length+n.length,children:[t.map(e=>(0,F.jsxs)(`li`,{className:`tool-slot`,children:[(0,F.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:()=>iD.toggleTool(e.id),children:[(0,F.jsx)(cE,{className:`tool-icon-glyph`,glyph:e.glyph}),(0,F.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,F.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${AE(i[e.id])}`,children:jE(i[e.id])}),e.kind===`link`&&(0,F.jsx)(`button`,{type:`button`,className:`tool-remove`,"data-tool-remove":e.id,title:`移除${e.name}`,"aria-label":`移除${e.name}`,onClick:()=>iD.removeTool(e.id),children:`✕`})]},e.id)),n.map(e=>(0,F.jsxs)(`li`,{className:`tool-slot`,children:[(0,F.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:()=>iD.toggleTool(e.id),children:[(0,F.jsx)(cE,{className:`tool-icon-glyph`,glyph:uE(e)}),(0,F.jsx)(`span`,{className:`tool-icon-name`,children:e.name})]}),i[e.id]&&(0,F.jsx)(`span`,{className:`tool-key-badge`,"data-tool-key-badge":e.id,"aria-hidden":`true`,title:`快捷键 ${AE(i[e.id])}`,children:jE(i[e.id])}),(0,F.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,F.jsx)(`p`,{className:`rail-empty`,"data-tool-empty":`1`,children:`还没有工具。点下面的「工具设置」添加。`}),(0,F.jsx)(`button`,{type:`button`,className:`tools-settings-btn`,"data-tool-settings-trigger":`1`,title:`添加预置工具、网址工具、快捷键与说明`,"aria-label":`打开工具设置`,onClick:()=>iD.openSettings(),children:`⚙ 工具设置`}),a&&(0,F.jsx)(`p`,{className:`tool-error`,role:`alert`,"data-tool-error":`1`,children:a})]})}function mk({onClose:e}){let{tools:t,mountedTools:n,shortcuts:r}=rD(),[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),ee=(0,u.useRef)(null),[M,te]=(0,u.useState)(),[N,ne]=(0,u.useState)(),re=(0,u.useRef)(null),[ie,ae]=(0,u.useState)(()=>{let e=JE();return!e||typeof window>`u`?e:XE(e,window.innerWidth,window.innerHeight)}),oe=async()=>{let e=await Bd(`请为 Super Pi 开发一个全局右侧栏工具。不要启动独立 HTTP 服务器,也不要监听端口。
|
|
342
342
|
|
|
343
343
|
工具不属于当前 workspace;通过内置 tool_register 一次性提交完整文件(index.html、JS/CSS,必要时 .py),并用 glyph 提供一个易辨识的短图标(1 至 4 个字符,例如 {}、∑、◷),Super Pi 会保存为全局工具并自动出现在每个 workspace 的工具 Tab。
|
|
344
344
|
|