dsh-multigameassistant 2.0.0 → 2.0.2
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/README.md +7 -3
- package/cordis.patch.yml +3 -1
- package/lib/analyzer.js +3 -3
- package/lib/{chunk-FLQD3DKB.js → chunk-I5AFAEXG.js} +471 -75
- package/lib/{chunk-7XMNAHZ2.js → chunk-NWM5ZN7E.js} +1 -1
- package/lib/{chunk-2DZ75ANX.js → chunk-OPV336S5.js} +380 -58
- package/lib/{chunk-BL6OSR2I.js → chunk-QAP7IYBS.js} +248 -29
- package/lib/{chunk-KIAOFNCB.js → chunk-YG4B5G7F.js} +38 -5
- package/lib/{chunk-5WTH2CYW.js → chunk-ZR74PFWR.js} +2 -2
- package/lib/emulator.js +2 -2
- package/lib/feishu.js +3 -3
- package/lib/game-intel.js +583 -37
- package/lib/gateway.js +2 -2
- package/lib/guard.js +1 -1
- package/lib/intervene.js +8 -6
- package/lib/monitor.js +3 -3
- package/lib/notify.js +3 -3
- package/lib/orchestrator.js +5 -5
- package/lib/qqbot.js +3 -3
- package/lib/runner.js +3 -3
- package/lib/scheduler.js +1 -1
- package/lib/script-registry.js +42 -9
- package/package.json +4 -3
- package/skills/game-intel.md +10 -0
- package/web/assets/index-9SCfW_a1.js +241 -0
- package/web/assets/index-9SCfW_a1.js.map +1 -0
- package/web/assets/index-BodAAefM.css +1 -0
- package/web/index.html +2 -2
- package/web/assets/index-B8Gy9VoQ.css +0 -1
- package/web/assets/index-DAKeB3Cw.js +0 -235
- package/web/assets/index-DAKeB3Cw.js.map +0 -1
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
var W_=Object.defineProperty;var wv=e=>{throw TypeError(e)};var q_=(e,t,n)=>t in e?W_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ut=(e,t,n)=>q_(e,typeof t!="symbol"?t+"":t,n),oh=(e,t,n)=>t.has(e)||wv("Cannot "+n);var Re=(e,t,n)=>(oh(e,t,"read from private field"),n?n.call(e):t.get(e)),Lt=(e,t,n)=>t.has(e)?wv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Zt=(e,t,n,r)=>(oh(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),xt=(e,t,n)=>(oh(e,t,"access private method"),n);var Nv=(e,t,n,r)=>({set _(i){Zt(e,t,i,n)},get _(){return Re(e,t,r)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function pm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lh={exports:{}},hl={},ch={exports:{}},mt={};/**
|
|
2
|
-
* @license React
|
|
3
|
-
* react.production.min.js
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
-
*
|
|
7
|
-
* This source code is licensed under the MIT license found in the
|
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var jv;function G_(){if(jv)return mt;jv=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.iterator;function g(V){return V===null||typeof V!="object"?null:(V=m&&V[m]||V["@@iterator"],typeof V=="function"?V:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,S={};function k(V,Y,fe){this.props=V,this.context=Y,this.refs=S,this.updater=fe||v}k.prototype.isReactComponent={},k.prototype.setState=function(V,Y){if(typeof V!="object"&&typeof V!="function"&&V!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,V,Y,"setState")},k.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function w(){}w.prototype=k.prototype;function T(V,Y,fe){this.props=V,this.context=Y,this.refs=S,this.updater=fe||v}var N=T.prototype=new w;N.constructor=T,y(N,k.prototype),N.isPureReactComponent=!0;var $=Array.isArray,D=Object.prototype.hasOwnProperty,O={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function U(V,Y,fe){var xe,me={},ie=null,ke=null;if(Y!=null)for(xe in Y.ref!==void 0&&(ke=Y.ref),Y.key!==void 0&&(ie=""+Y.key),Y)D.call(Y,xe)&&!F.hasOwnProperty(xe)&&(me[xe]=Y[xe]);var ae=arguments.length-2;if(ae===1)me.children=fe;else if(1<ae){for(var Ne=Array(ae),Fe=0;Fe<ae;Fe++)Ne[Fe]=arguments[Fe+2];me.children=Ne}if(V&&V.defaultProps)for(xe in ae=V.defaultProps,ae)me[xe]===void 0&&(me[xe]=ae[xe]);return{$$typeof:e,type:V,key:ie,ref:ke,props:me,_owner:O.current}}function M(V,Y){return{$$typeof:e,type:V.type,key:Y,ref:V.ref,props:V.props,_owner:V._owner}}function P(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function R(V){var Y={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(fe){return Y[fe]})}var Z=/\/+/g;function E(V,Y){return typeof V=="object"&&V!==null&&V.key!=null?R(""+V.key):Y.toString(36)}function C(V,Y,fe,xe,me){var ie=typeof V;(ie==="undefined"||ie==="boolean")&&(V=null);var ke=!1;if(V===null)ke=!0;else switch(ie){case"string":case"number":ke=!0;break;case"object":switch(V.$$typeof){case e:case t:ke=!0}}if(ke)return ke=V,me=me(ke),V=xe===""?"."+E(ke,0):xe,$(me)?(fe="",V!=null&&(fe=V.replace(Z,"$&/")+"/"),C(me,Y,fe,"",function(Fe){return Fe})):me!=null&&(P(me)&&(me=M(me,fe+(!me.key||ke&&ke.key===me.key?"":(""+me.key).replace(Z,"$&/")+"/")+V)),Y.push(me)),1;if(ke=0,xe=xe===""?".":xe+":",$(V))for(var ae=0;ae<V.length;ae++){ie=V[ae];var Ne=xe+E(ie,ae);ke+=C(ie,Y,fe,Ne,me)}else if(Ne=g(V),typeof Ne=="function")for(V=Ne.call(V),ae=0;!(ie=V.next()).done;)ie=ie.value,Ne=xe+E(ie,ae++),ke+=C(ie,Y,fe,Ne,me);else if(ie==="object")throw Y=String(V),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return ke}function I(V,Y,fe){if(V==null)return V;var xe=[],me=0;return C(V,xe,"","",function(ie){return Y.call(fe,ie,me++)}),xe}function L(V){if(V._status===-1){var Y=V._result;Y=Y(),Y.then(function(fe){(V._status===0||V._status===-1)&&(V._status=1,V._result=fe)},function(fe){(V._status===0||V._status===-1)&&(V._status=2,V._result=fe)}),V._status===-1&&(V._status=0,V._result=Y)}if(V._status===1)return V._result.default;throw V._result}var W={current:null},H={transition:null},G={ReactCurrentDispatcher:W,ReactCurrentBatchConfig:H,ReactCurrentOwner:O};function K(){throw Error("act(...) is not supported in production builds of React.")}return mt.Children={map:I,forEach:function(V,Y,fe){I(V,function(){Y.apply(this,arguments)},fe)},count:function(V){var Y=0;return I(V,function(){Y++}),Y},toArray:function(V){return I(V,function(Y){return Y})||[]},only:function(V){if(!P(V))throw Error("React.Children.only expected to receive a single React element child.");return V}},mt.Component=k,mt.Fragment=n,mt.Profiler=i,mt.PureComponent=T,mt.StrictMode=r,mt.Suspense=d,mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,mt.act=K,mt.cloneElement=function(V,Y,fe){if(V==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+V+".");var xe=y({},V.props),me=V.key,ie=V.ref,ke=V._owner;if(Y!=null){if(Y.ref!==void 0&&(ie=Y.ref,ke=O.current),Y.key!==void 0&&(me=""+Y.key),V.type&&V.type.defaultProps)var ae=V.type.defaultProps;for(Ne in Y)D.call(Y,Ne)&&!F.hasOwnProperty(Ne)&&(xe[Ne]=Y[Ne]===void 0&&ae!==void 0?ae[Ne]:Y[Ne])}var Ne=arguments.length-2;if(Ne===1)xe.children=fe;else if(1<Ne){ae=Array(Ne);for(var Fe=0;Fe<Ne;Fe++)ae[Fe]=arguments[Fe+2];xe.children=ae}return{$$typeof:e,type:V.type,key:me,ref:ie,props:xe,_owner:ke}},mt.createContext=function(V){return V={$$typeof:c,_currentValue:V,_currentValue2:V,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},V.Provider={$$typeof:o,_context:V},V.Consumer=V},mt.createElement=U,mt.createFactory=function(V){var Y=U.bind(null,V);return Y.type=V,Y},mt.createRef=function(){return{current:null}},mt.forwardRef=function(V){return{$$typeof:u,render:V}},mt.isValidElement=P,mt.lazy=function(V){return{$$typeof:p,_payload:{_status:-1,_result:V},_init:L}},mt.memo=function(V,Y){return{$$typeof:f,type:V,compare:Y===void 0?null:Y}},mt.startTransition=function(V){var Y=H.transition;H.transition={};try{V()}finally{H.transition=Y}},mt.unstable_act=K,mt.useCallback=function(V,Y){return W.current.useCallback(V,Y)},mt.useContext=function(V){return W.current.useContext(V)},mt.useDebugValue=function(){},mt.useDeferredValue=function(V){return W.current.useDeferredValue(V)},mt.useEffect=function(V,Y){return W.current.useEffect(V,Y)},mt.useId=function(){return W.current.useId()},mt.useImperativeHandle=function(V,Y,fe){return W.current.useImperativeHandle(V,Y,fe)},mt.useInsertionEffect=function(V,Y){return W.current.useInsertionEffect(V,Y)},mt.useLayoutEffect=function(V,Y){return W.current.useLayoutEffect(V,Y)},mt.useMemo=function(V,Y){return W.current.useMemo(V,Y)},mt.useReducer=function(V,Y,fe){return W.current.useReducer(V,Y,fe)},mt.useRef=function(V){return W.current.useRef(V)},mt.useState=function(V){return W.current.useState(V)},mt.useSyncExternalStore=function(V,Y,fe){return W.current.useSyncExternalStore(V,Y,fe)},mt.useTransition=function(){return W.current.useTransition()},mt.version="18.3.1",mt}var Sv;function sc(){return Sv||(Sv=1,ch.exports=G_()),ch.exports}/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.production.min.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var _v;function K_(){if(_v)return hl;_v=1;var e=sc(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(u,d,f){var p,m={},g=null,v=null;f!==void 0&&(g=""+f),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(v=d.ref);for(p in d)r.call(d,p)&&!o.hasOwnProperty(p)&&(m[p]=d[p]);if(u&&u.defaultProps)for(p in d=u.defaultProps,d)m[p]===void 0&&(m[p]=d[p]);return{$$typeof:t,type:u,key:g,ref:v,props:m,_owner:i.current}}return hl.Fragment=n,hl.jsx=c,hl.jsxs=c,hl}var Ev;function Y_(){return Ev||(Ev=1,lh.exports=K_()),lh.exports}var s=Y_(),du={},uh={exports:{}},gs={},dh={exports:{}},fh={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* scheduler.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var Cv;function X_(){return Cv||(Cv=1,(function(e){function t(H,G){var K=H.length;H.push(G);e:for(;0<K;){var V=K-1>>>1,Y=H[V];if(0<i(Y,G))H[V]=G,H[K]=Y,K=V;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var G=H[0],K=H.pop();if(K!==G){H[0]=K;e:for(var V=0,Y=H.length,fe=Y>>>1;V<fe;){var xe=2*(V+1)-1,me=H[xe],ie=xe+1,ke=H[ie];if(0>i(me,K))ie<Y&&0>i(ke,me)?(H[V]=ke,H[ie]=K,V=ie):(H[V]=me,H[xe]=K,V=xe);else if(ie<Y&&0>i(ke,K))H[V]=ke,H[ie]=K,V=ie;else break e}}return G}function i(H,G){var K=H.sortIndex-G.sortIndex;return K!==0?K:H.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var d=[],f=[],p=1,m=null,g=3,v=!1,y=!1,S=!1,k=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(H){for(var G=n(f);G!==null;){if(G.callback===null)r(f);else if(G.startTime<=H)r(f),G.sortIndex=G.expirationTime,t(d,G);else break;G=n(f)}}function $(H){if(S=!1,N(H),!y)if(n(d)!==null)y=!0,L(D);else{var G=n(f);G!==null&&W($,G.startTime-H)}}function D(H,G){y=!1,S&&(S=!1,w(U),U=-1),v=!0;var K=g;try{for(N(G),m=n(d);m!==null&&(!(m.expirationTime>G)||H&&!R());){var V=m.callback;if(typeof V=="function"){m.callback=null,g=m.priorityLevel;var Y=V(m.expirationTime<=G);G=e.unstable_now(),typeof Y=="function"?m.callback=Y:m===n(d)&&r(d),N(G)}else r(d);m=n(d)}if(m!==null)var fe=!0;else{var xe=n(f);xe!==null&&W($,xe.startTime-G),fe=!1}return fe}finally{m=null,g=K,v=!1}}var O=!1,F=null,U=-1,M=5,P=-1;function R(){return!(e.unstable_now()-P<M)}function Z(){if(F!==null){var H=e.unstable_now();P=H;var G=!0;try{G=F(!0,H)}finally{G?E():(O=!1,F=null)}}else O=!1}var E;if(typeof T=="function")E=function(){T(Z)};else if(typeof MessageChannel<"u"){var C=new MessageChannel,I=C.port2;C.port1.onmessage=Z,E=function(){I.postMessage(null)}}else E=function(){k(Z,0)};function L(H){F=H,O||(O=!0,E())}function W(H,G){U=k(function(){H(e.unstable_now())},G)}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(H){H.callback=null},e.unstable_continueExecution=function(){y||v||(y=!0,L(D))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(H){switch(g){case 1:case 2:case 3:var G=3;break;default:G=g}var K=g;g=G;try{return H()}finally{g=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,G){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var K=g;g=H;try{return G()}finally{g=K}},e.unstable_scheduleCallback=function(H,G,K){var V=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?V+K:V):K=V,H){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=K+Y,H={id:p++,callback:G,priorityLevel:H,startTime:K,expirationTime:Y,sortIndex:-1},K>V?(H.sortIndex=K,t(f,H),n(d)===null&&H===n(f)&&(S?(w(U),U=-1):S=!0,W($,K-V))):(H.sortIndex=Y,t(d,H),y||v||(y=!0,L(D))),H},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(H){var G=g;return function(){var K=g;g=G;try{return H.apply(this,arguments)}finally{g=K}}}})(fh)),fh}var Iv;function Q_(){return Iv||(Iv=1,dh.exports=X_()),dh.exports}/**
|
|
26
|
-
* @license React
|
|
27
|
-
* react-dom.production.min.js
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the MIT license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var Av;function J_(){if(Av)return gs;Av=1;var e=sc(),t=Q_();function n(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,h=1;h<arguments.length;h++)l+="&args[]="+encodeURIComponent(arguments[h]);return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,i={};function o(a,l){c(a,l),c(a+"Capture",l)}function c(a,l){for(i[a]=l,a=0;a<l.length;a++)r.add(l[a])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,f=/^[: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]*$/,p={},m={};function g(a){return d.call(m,a)?!0:d.call(p,a)?!1:f.test(a)?m[a]=!0:(p[a]=!0,!1)}function v(a,l,h,x){if(h!==null&&h.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return x?!1:h!==null?!h.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function y(a,l,h,x){if(l===null||typeof l>"u"||v(a,l,h,x))return!0;if(x)return!1;if(h!==null)switch(h.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function S(a,l,h,x,j,A,B){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=x,this.attributeNamespace=j,this.mustUseProperty=h,this.propertyName=a,this.type=l,this.sanitizeURL=A,this.removeEmptyString=B}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){k[a]=new S(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];k[l]=new S(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){k[a]=new S(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){k[a]=new S(a,2,!1,a,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){k[a]=new S(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){k[a]=new S(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){k[a]=new S(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){k[a]=new S(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){k[a]=new S(a,5,!1,a.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function T(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var l=a.replace(w,T);k[l]=new S(l,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var l=a.replace(w,T);k[l]=new S(l,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var l=a.replace(w,T);k[l]=new S(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){k[a]=new S(a,1,!1,a.toLowerCase(),null,!1,!1)}),k.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){k[a]=new S(a,1,!1,a.toLowerCase(),null,!0,!0)});function N(a,l,h,x){var j=k.hasOwnProperty(l)?k[l]:null;(j!==null?j.type!==0:x||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(y(l,h,j,x)&&(h=null),x||j===null?g(l)&&(h===null?a.removeAttribute(l):a.setAttribute(l,""+h)):j.mustUseProperty?a[j.propertyName]=h===null?j.type===3?!1:"":h:(l=j.attributeName,x=j.attributeNamespace,h===null?a.removeAttribute(l):(j=j.type,h=j===3||j===4&&h===!0?"":""+h,x?a.setAttributeNS(x,l,h):a.setAttribute(l,h))))}var $=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,D=Symbol.for("react.element"),O=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),R=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),W=Symbol.for("react.offscreen"),H=Symbol.iterator;function G(a){return a===null||typeof a!="object"?null:(a=H&&a[H]||a["@@iterator"],typeof a=="function"?a:null)}var K=Object.assign,V;function Y(a){if(V===void 0)try{throw Error()}catch(h){var l=h.stack.trim().match(/\n( *(at )?)/);V=l&&l[1]||""}return`
|
|
34
|
-
`+V+a}var fe=!1;function xe(a,l){if(!a||fe)return"";fe=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(de){var x=de}Reflect.construct(a,[],l)}else{try{l.call()}catch(de){x=de}a.call(l.prototype)}else{try{throw Error()}catch(de){x=de}a()}}catch(de){if(de&&x&&typeof de.stack=="string"){for(var j=de.stack.split(`
|
|
35
|
-
`),A=x.stack.split(`
|
|
36
|
-
`),B=j.length-1,X=A.length-1;1<=B&&0<=X&&j[B]!==A[X];)X--;for(;1<=B&&0<=X;B--,X--)if(j[B]!==A[X]){if(B!==1||X!==1)do if(B--,X--,0>X||j[B]!==A[X]){var J=`
|
|
37
|
-
`+j[B].replace(" at new "," at ");return a.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",a.displayName)),J}while(1<=B&&0<=X);break}}}finally{fe=!1,Error.prepareStackTrace=h}return(a=a?a.displayName||a.name:"")?Y(a):""}function me(a){switch(a.tag){case 5:return Y(a.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("SuspenseList");case 0:case 2:case 15:return a=xe(a.type,!1),a;case 11:return a=xe(a.type.render,!1),a;case 1:return a=xe(a.type,!0),a;default:return""}}function ie(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case F:return"Fragment";case O:return"Portal";case M:return"Profiler";case U:return"StrictMode";case E:return"Suspense";case C:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case R:return(a.displayName||"Context")+".Consumer";case P:return(a._context.displayName||"Context")+".Provider";case Z:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case I:return l=a.displayName||null,l!==null?l:ie(a.type)||"Memo";case L:l=a._payload,a=a._init;try{return ie(a(l))}catch{}}return null}function ke(a){var l=a.type;switch(a.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=l.render,a=a.displayName||a.name||"",l.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ie(l);case 8:return l===U?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function ae(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function Ne(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function Fe(a){var l=Ne(a)?"checked":"value",h=Object.getOwnPropertyDescriptor(a.constructor.prototype,l),x=""+a[l];if(!a.hasOwnProperty(l)&&typeof h<"u"&&typeof h.get=="function"&&typeof h.set=="function"){var j=h.get,A=h.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return j.call(this)},set:function(B){x=""+B,A.call(this,B)}}),Object.defineProperty(a,l,{enumerable:h.enumerable}),{getValue:function(){return x},setValue:function(B){x=""+B},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function ce(a){a._valueTracker||(a._valueTracker=Fe(a))}function je(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var h=l.getValue(),x="";return a&&(x=Ne(a)?a.checked?"true":"false":a.value),a=x,a!==h?(l.setValue(a),!0):!1}function re(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function he(a,l){var h=l.checked;return K({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:h??a._wrapperState.initialChecked})}function ze(a,l){var h=l.defaultValue==null?"":l.defaultValue,x=l.checked!=null?l.checked:l.defaultChecked;h=ae(l.value!=null?l.value:h),a._wrapperState={initialChecked:x,initialValue:h,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Te(a,l){l=l.checked,l!=null&&N(a,"checked",l,!1)}function Ge(a,l){Te(a,l);var h=ae(l.value),x=l.type;if(h!=null)x==="number"?(h===0&&a.value===""||a.value!=h)&&(a.value=""+h):a.value!==""+h&&(a.value=""+h);else if(x==="submit"||x==="reset"){a.removeAttribute("value");return}l.hasOwnProperty("value")?tt(a,l.type,h):l.hasOwnProperty("defaultValue")&&tt(a,l.type,ae(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(a.defaultChecked=!!l.defaultChecked)}function Ie(a,l,h){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var x=l.type;if(!(x!=="submit"&&x!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+a._wrapperState.initialValue,h||l===a.value||(a.value=l),a.defaultValue=l}h=a.name,h!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,h!==""&&(a.name=h)}function tt(a,l,h){(l!=="number"||re(a.ownerDocument)!==a)&&(h==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+h&&(a.defaultValue=""+h))}var et=Array.isArray;function jt(a,l,h,x){if(a=a.options,l){l={};for(var j=0;j<h.length;j++)l["$"+h[j]]=!0;for(h=0;h<a.length;h++)j=l.hasOwnProperty("$"+a[h].value),a[h].selected!==j&&(a[h].selected=j),j&&x&&(a[h].defaultSelected=!0)}else{for(h=""+ae(h),l=null,j=0;j<a.length;j++){if(a[j].value===h){a[j].selected=!0,x&&(a[j].defaultSelected=!0);return}l!==null||a[j].disabled||(l=a[j])}l!==null&&(l.selected=!0)}}function On(a,l){if(l.dangerouslySetInnerHTML!=null)throw Error(n(91));return K({},l,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function sn(a,l){var h=l.value;if(h==null){if(h=l.children,l=l.defaultValue,h!=null){if(l!=null)throw Error(n(92));if(et(h)){if(1<h.length)throw Error(n(93));h=h[0]}l=h}l==null&&(l=""),h=l}a._wrapperState={initialValue:ae(h)}}function ln(a,l){var h=ae(l.value),x=ae(l.defaultValue);h!=null&&(h=""+h,h!==a.value&&(a.value=h),l.defaultValue==null&&a.defaultValue!==h&&(a.defaultValue=h)),x!=null&&(a.defaultValue=""+x)}function cn(a){var l=a.textContent;l===a._wrapperState.initialValue&&l!==""&&l!==null&&(a.value=l)}function rn(a){switch(a){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function an(a,l){return a==null||a==="http://www.w3.org/1999/xhtml"?rn(l):a==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var Ft,Bn=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,h,x,j){MSApp.execUnsafeLocalFunction(function(){return a(l,h,x,j)})}:a})(function(a,l){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=l;else{for(Ft=Ft||document.createElement("div"),Ft.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=Ft.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}});function wn(a,l){if(l){var h=a.firstChild;if(h&&h===a.lastChild&&h.nodeType===3){h.nodeValue=l;return}}a.textContent=l}var ws={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},_r=["Webkit","ms","Moz","O"];Object.keys(ws).forEach(function(a){_r.forEach(function(l){l=l+a.charAt(0).toUpperCase()+a.substring(1),ws[l]=ws[a]})});function Ks(a,l,h){return l==null||typeof l=="boolean"||l===""?"":h||typeof l!="number"||l===0||ws.hasOwnProperty(a)&&ws[a]?(""+l).trim():l+"px"}function Ys(a,l){a=a.style;for(var h in l)if(l.hasOwnProperty(h)){var x=h.indexOf("--")===0,j=Ks(h,l[h],x);h==="float"&&(h="cssFloat"),x?a.setProperty(h,j):a[h]=j}}var $s=K({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Rs(a,l){if(l){if($s[a]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(n(137,a));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(n(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(n(61))}if(l.style!=null&&typeof l.style!="object")throw Error(n(62))}}function Os(a,l){if(a.indexOf("-")===-1)return typeof l.is=="string";switch(a){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 zs=null;function Xs(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var Qs=null,rs=null,Yn=null;function Nn(a){if(a=Qo(a)){if(typeof Qs!="function")throw Error(n(280));var l=a.stateNode;l&&(l=_c(l),Qs(a.stateNode,a.type,l))}}function Q(a){rs?Yn?Yn.push(a):Yn=[a]:rs=a}function pe(){if(rs){var a=rs,l=Yn;if(Yn=rs=null,Nn(a),l)for(a=0;a<l.length;a++)Nn(l[a])}}function Oe(a,l){return a(l)}function st(){}var It=!1;function Tt(a,l,h){if(It)return a(l,h);It=!0;try{return Oe(a,l,h)}finally{It=!1,(rs!==null||Yn!==null)&&(st(),pe())}}function Be(a,l){var h=a.stateNode;if(h===null)return null;var x=_c(h);if(x===null)return null;h=x[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(x=!x.disabled)||(a=a.type,x=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!x;break e;default:a=!1}if(a)return null;if(h&&typeof h!="function")throw Error(n(231,l,typeof h));return h}var De=!1;if(u)try{var Xe={};Object.defineProperty(Xe,"passive",{get:function(){De=!0}}),window.addEventListener("test",Xe,Xe),window.removeEventListener("test",Xe,Xe)}catch{De=!1}function bt(a,l,h,x,j,A,B,X,J){var de=Array.prototype.slice.call(arguments,3);try{l.apply(h,de)}catch(_e){this.onError(_e)}}var yt=!1,Un=null,is=!1,Js=null,hi={onError:function(a){yt=!0,Un=a}};function er(a,l,h,x,j,A,B,X,J){yt=!1,Un=null,bt.apply(hi,arguments)}function pi(a,l,h,x,j,A,B,X,J){if(er.apply(this,arguments),yt){if(yt){var de=Un;yt=!1,Un=null}else throw Error(n(198));is||(is=!0,Js=de)}}function Hn(a){var l=a,h=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(h=l.return),a=l.return;while(a)}return l.tag===3?h:null}function Br(a){if(a.tag===13){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function as(a){if(Hn(a)!==a)throw Error(n(188))}function Er(a){var l=a.alternate;if(!l){if(l=Hn(a),l===null)throw Error(n(188));return l!==a?null:a}for(var h=a,x=l;;){var j=h.return;if(j===null)break;var A=j.alternate;if(A===null){if(x=j.return,x!==null){h=x;continue}break}if(j.child===A.child){for(A=j.child;A;){if(A===h)return as(j),a;if(A===x)return as(j),l;A=A.sibling}throw Error(n(188))}if(h.return!==x.return)h=j,x=A;else{for(var B=!1,X=j.child;X;){if(X===h){B=!0,h=j,x=A;break}if(X===x){B=!0,x=j,h=A;break}X=X.sibling}if(!B){for(X=A.child;X;){if(X===h){B=!0,h=A,x=j;break}if(X===x){B=!0,x=A,h=j;break}X=X.sibling}if(!B)throw Error(n(189))}}if(h.alternate!==x)throw Error(n(190))}if(h.tag!==3)throw Error(n(188));return h.stateNode.current===h?a:l}function mi(a){return a=Er(a),a!==null?Rt(a):null}function Rt(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var l=Rt(a);if(l!==null)return l;a=a.sibling}return null}var Ns=t.unstable_scheduleCallback,Xn=t.unstable_cancelCallback,Ur=t.unstable_shouldYield,tr=t.unstable_requestPaint,Ot=t.unstable_now,gi=t.unstable_getCurrentPriorityLevel,Hr=t.unstable_ImmediatePriority,nr=t.unstable_UserBlockingPriority,Cr=t.unstable_NormalPriority,Ae=t.unstable_LowPriority,Ze=t.unstable_IdlePriority,ct=null,ft=null;function At(a){if(ft&&typeof ft.onCommitFiberRoot=="function")try{ft.onCommitFiberRoot(ct,a,void 0,(a.current.flags&128)===128)}catch{}}var zt=Math.clz32?Math.clz32:un,Zn=Math.log,Ps=Math.LN2;function un(a){return a>>>=0,a===0?32:31-(Zn(a)/Ps|0)|0}var jn=64,Ls=4194304;function Ds(a){switch(a&-a){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: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 a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function os(a,l){var h=a.pendingLanes;if(h===0)return 0;var x=0,j=a.suspendedLanes,A=a.pingedLanes,B=h&268435455;if(B!==0){var X=B&~j;X!==0?x=Ds(X):(A&=B,A!==0&&(x=Ds(A)))}else B=h&~j,B!==0?x=Ds(B):A!==0&&(x=Ds(A));if(x===0)return 0;if(l!==0&&l!==x&&(l&j)===0&&(j=x&-x,A=l&-l,j>=A||j===16&&(A&4194240)!==0))return l;if((x&4)!==0&&(x|=h&16),l=a.entangledLanes,l!==0)for(a=a.entanglements,l&=x;0<l;)h=31-zt(l),j=1<<h,x|=a[h],l&=~j;return x}function Qi(a,l){switch(a){case 1:case 2:case 4:return l+250;case 8:case 16:case 32:case 64: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 l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function xi(a,l){for(var h=a.suspendedLanes,x=a.pingedLanes,j=a.expirationTimes,A=a.pendingLanes;0<A;){var B=31-zt(A),X=1<<B,J=j[B];J===-1?((X&h)===0||(X&x)!==0)&&(j[B]=Qi(X,l)):J<=l&&(a.expiredLanes|=X),A&=~X}}function Ir(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function vi(){var a=jn;return jn<<=1,(jn&4194240)===0&&(jn=64),a}function Qn(a){for(var l=[],h=0;31>h;h++)l.push(a);return l}function ls(a,l,h){a.pendingLanes|=l,l!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,l=31-zt(l),a[l]=h}function Sn(a,l){var h=a.pendingLanes&~l;a.pendingLanes=l,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=l,a.mutableReadLanes&=l,a.entangledLanes&=l,l=a.entanglements;var x=a.eventTimes;for(a=a.expirationTimes;0<h;){var j=31-zt(h),A=1<<j;l[j]=0,x[j]=-1,a[j]=-1,h&=~A}}function Fs(a,l){var h=a.entangledLanes|=l;for(a=a.entanglements;h;){var x=31-zt(h),j=1<<x;j&l|a[x]&l&&(a[x]|=l),h&=~j}}var vt=0;function at(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var cs,Pt,ht,Zr,Jn,Vr=!1,sr=[],Me=null,Ue=null,ot=null,gt=new Map,Bt=new Map,pn=[],Fo="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 submit".split(" ");function Ji(a,l){switch(a){case"focusin":case"focusout":Me=null;break;case"dragenter":case"dragleave":Ue=null;break;case"mouseover":case"mouseout":ot=null;break;case"pointerover":case"pointerout":gt.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Bt.delete(l.pointerId)}}function Wr(a,l,h,x,j,A){return a===null||a.nativeEvent!==A?(a={blockedOn:l,domEventName:h,eventSystemFlags:x,nativeEvent:A,targetContainers:[j]},l!==null&&(l=Qo(l),l!==null&&Pt(l)),a):(a.eventSystemFlags|=x,l=a.targetContainers,j!==null&&l.indexOf(j)===-1&&l.push(j),a)}function ea(a,l,h,x,j){switch(l){case"focusin":return Me=Wr(Me,a,l,h,x,j),!0;case"dragenter":return Ue=Wr(Ue,a,l,h,x,j),!0;case"mouseover":return ot=Wr(ot,a,l,h,x,j),!0;case"pointerover":var A=j.pointerId;return gt.set(A,Wr(gt.get(A)||null,a,l,h,x,j)),!0;case"gotpointercapture":return A=j.pointerId,Bt.set(A,Wr(Bt.get(A)||null,a,l,h,x,j)),!0}return!1}function Pa(a){var l=ta(a.target);if(l!==null){var h=Hn(l);if(h!==null){if(l=h.tag,l===13){if(l=Br(h),l!==null){a.blockedOn=l,Jn(a.priority,function(){ht(h)});return}}else if(l===3&&h.stateNode.current.memoizedState.isDehydrated){a.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}a.blockedOn=null}function we(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var h=In(a.domEventName,a.eventSystemFlags,l[0],a.nativeEvent);if(h===null){h=a.nativeEvent;var x=new h.constructor(h.type,h);zs=x,h.target.dispatchEvent(x),zs=null}else return l=Qo(h),l!==null&&Pt(l),a.blockedOn=h,!1;l.shift()}return!0}function q(a,l,h){we(a)&&h.delete(l)}function te(){Vr=!1,Me!==null&&we(Me)&&(Me=null),Ue!==null&&we(Ue)&&(Ue=null),ot!==null&&we(ot)&&(ot=null),gt.forEach(q),Bt.forEach(q)}function ve(a,l){a.blockedOn===l&&(a.blockedOn=null,Vr||(Vr=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,te)))}function ye(a){function l(j){return ve(j,a)}if(0<sr.length){ve(sr[0],a);for(var h=1;h<sr.length;h++){var x=sr[h];x.blockedOn===a&&(x.blockedOn=null)}}for(Me!==null&&ve(Me,a),Ue!==null&&ve(Ue,a),ot!==null&&ve(ot,a),gt.forEach(l),Bt.forEach(l),h=0;h<pn.length;h++)x=pn[h],x.blockedOn===a&&(x.blockedOn=null);for(;0<pn.length&&(h=pn[0],h.blockedOn===null);)Pa(h),h.blockedOn===null&&pn.shift()}var qe=$.ReactCurrentBatchConfig,nt=!0;function pt(a,l,h,x){var j=vt,A=qe.transition;qe.transition=null;try{vt=1,us(a,l,h,x)}finally{vt=j,qe.transition=A}}function dn(a,l,h,x){var j=vt,A=qe.transition;qe.transition=null;try{vt=4,us(a,l,h,x)}finally{vt=j,qe.transition=A}}function us(a,l,h,x){if(nt){var j=In(a,l,h,x);if(j===null)Yd(a,l,x,mn,h),Ji(a,x);else if(ea(j,a,l,h,x))x.stopPropagation();else if(Ji(a,x),l&4&&-1<Fo.indexOf(a)){for(;j!==null;){var A=Qo(j);if(A!==null&&cs(A),A=In(a,l,h,x),A===null&&Yd(a,l,x,mn,h),A===j)break;j=A}j!==null&&x.stopPropagation()}else Yd(a,l,x,null,h)}}var mn=null;function In(a,l,h,x){if(mn=null,a=Xs(x),a=ta(a),a!==null)if(l=Hn(a),l===null)a=null;else if(h=l.tag,h===13){if(a=Br(l),a!==null)return a;a=null}else if(h===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null);return mn=a,null}function qr(a){switch(a){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"resize":case"seeked":case"submit":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"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(gi()){case Hr:return 1;case nr:return 4;case Cr:case Ae:return 16;case Ze:return 536870912;default:return 16}default:return 16}}var Yt=null,La=null,mc=null;function cg(){if(mc)return mc;var a,l=La,h=l.length,x,j="value"in Yt?Yt.value:Yt.textContent,A=j.length;for(a=0;a<h&&l[a]===j[a];a++);var B=h-a;for(x=1;x<=B&&l[h-x]===j[A-x];x++);return mc=j.slice(a,1<x?1-x:void 0)}function gc(a){var l=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&l===13&&(a=13)):a=l,a===10&&(a=13),32<=a||a===13?a:0}function xc(){return!0}function ug(){return!1}function js(a){function l(h,x,j,A,B){this._reactName=h,this._targetInst=j,this.type=x,this.nativeEvent=A,this.target=B,this.currentTarget=null;for(var X in a)a.hasOwnProperty(X)&&(h=a[X],this[X]=h?h(A):A[X]);return this.isDefaultPrevented=(A.defaultPrevented!=null?A.defaultPrevented:A.returnValue===!1)?xc:ug,this.isPropagationStopped=ug,this}return K(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=xc)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=xc)},persist:function(){},isPersistent:xc}),l}var Da={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Od=js(Da),Bo=K({},Da,{view:0,detail:0}),yS=js(Bo),zd,Pd,Uo,vc=K({},Bo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Dd,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==Uo&&(Uo&&a.type==="mousemove"?(zd=a.screenX-Uo.screenX,Pd=a.screenY-Uo.screenY):Pd=zd=0,Uo=a),zd)},movementY:function(a){return"movementY"in a?a.movementY:Pd}}),dg=js(vc),bS=K({},vc,{dataTransfer:0}),kS=js(bS),wS=K({},Bo,{relatedTarget:0}),Ld=js(wS),NS=K({},Da,{animationName:0,elapsedTime:0,pseudoElement:0}),jS=js(NS),SS=K({},Da,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),_S=js(SS),ES=K({},Da,{data:0}),fg=js(ES),CS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},IS={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"},AS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function TS(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=AS[a])?!!l[a]:!1}function Dd(){return TS}var MS=K({},Bo,{key:function(a){if(a.key){var l=CS[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=gc(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?IS[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Dd,charCode:function(a){return a.type==="keypress"?gc(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?gc(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),$S=js(MS),RS=K({},vc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),hg=js(RS),OS=K({},Bo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Dd}),zS=js(OS),PS=K({},Da,{propertyName:0,elapsedTime:0,pseudoElement:0}),LS=js(PS),DS=K({},vc,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),FS=js(DS),BS=[9,13,27,32],Fd=u&&"CompositionEvent"in window,Ho=null;u&&"documentMode"in document&&(Ho=document.documentMode);var US=u&&"TextEvent"in window&&!Ho,pg=u&&(!Fd||Ho&&8<Ho&&11>=Ho),mg=" ",gg=!1;function xg(a,l){switch(a){case"keyup":return BS.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function vg(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Fa=!1;function HS(a,l){switch(a){case"compositionend":return vg(l);case"keypress":return l.which!==32?null:(gg=!0,mg);case"textInput":return a=l.data,a===mg&&gg?null:a;default:return null}}function ZS(a,l){if(Fa)return a==="compositionend"||!Fd&&xg(a,l)?(a=cg(),mc=La=Yt=null,Fa=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return pg&&l.locale!=="ko"?null:l.data;default:return null}}var VS={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 yg(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!VS[a.type]:l==="textarea"}function bg(a,l,h,x){Q(x),l=Nc(l,"onChange"),0<l.length&&(h=new Od("onChange","change",null,h,x),a.push({event:h,listeners:l}))}var Zo=null,Vo=null;function WS(a){Lg(a,0)}function yc(a){var l=Va(a);if(je(l))return a}function qS(a,l){if(a==="change")return l}var kg=!1;if(u){var Bd;if(u){var Ud="oninput"in document;if(!Ud){var wg=document.createElement("div");wg.setAttribute("oninput","return;"),Ud=typeof wg.oninput=="function"}Bd=Ud}else Bd=!1;kg=Bd&&(!document.documentMode||9<document.documentMode)}function Ng(){Zo&&(Zo.detachEvent("onpropertychange",jg),Vo=Zo=null)}function jg(a){if(a.propertyName==="value"&&yc(Vo)){var l=[];bg(l,Vo,a,Xs(a)),Tt(WS,l)}}function GS(a,l,h){a==="focusin"?(Ng(),Zo=l,Vo=h,Zo.attachEvent("onpropertychange",jg)):a==="focusout"&&Ng()}function KS(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return yc(Vo)}function YS(a,l){if(a==="click")return yc(l)}function XS(a,l){if(a==="input"||a==="change")return yc(l)}function QS(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var rr=typeof Object.is=="function"?Object.is:QS;function Wo(a,l){if(rr(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var h=Object.keys(a),x=Object.keys(l);if(h.length!==x.length)return!1;for(x=0;x<h.length;x++){var j=h[x];if(!d.call(l,j)||!rr(a[j],l[j]))return!1}return!0}function Sg(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function _g(a,l){var h=Sg(a);a=0;for(var x;h;){if(h.nodeType===3){if(x=a+h.textContent.length,a<=l&&x>=l)return{node:h,offset:l-a};a=x}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=Sg(h)}}function Eg(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?Eg(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function Cg(){for(var a=window,l=re();l instanceof a.HTMLIFrameElement;){try{var h=typeof l.contentWindow.location.href=="string"}catch{h=!1}if(h)a=l.contentWindow;else break;l=re(a.document)}return l}function Hd(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l&&(l==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||l==="textarea"||a.contentEditable==="true")}function JS(a){var l=Cg(),h=a.focusedElem,x=a.selectionRange;if(l!==h&&h&&h.ownerDocument&&Eg(h.ownerDocument.documentElement,h)){if(x!==null&&Hd(h)){if(l=x.start,a=x.end,a===void 0&&(a=l),"selectionStart"in h)h.selectionStart=l,h.selectionEnd=Math.min(a,h.value.length);else if(a=(l=h.ownerDocument||document)&&l.defaultView||window,a.getSelection){a=a.getSelection();var j=h.textContent.length,A=Math.min(x.start,j);x=x.end===void 0?A:Math.min(x.end,j),!a.extend&&A>x&&(j=x,x=A,A=j),j=_g(h,A);var B=_g(h,x);j&&B&&(a.rangeCount!==1||a.anchorNode!==j.node||a.anchorOffset!==j.offset||a.focusNode!==B.node||a.focusOffset!==B.offset)&&(l=l.createRange(),l.setStart(j.node,j.offset),a.removeAllRanges(),A>x?(a.addRange(l),a.extend(B.node,B.offset)):(l.setEnd(B.node,B.offset),a.addRange(l)))}}for(l=[],a=h;a=a.parentNode;)a.nodeType===1&&l.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;h<l.length;h++)a=l[h],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var e_=u&&"documentMode"in document&&11>=document.documentMode,Ba=null,Zd=null,qo=null,Vd=!1;function Ig(a,l,h){var x=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Vd||Ba==null||Ba!==re(x)||(x=Ba,"selectionStart"in x&&Hd(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),qo&&Wo(qo,x)||(qo=x,x=Nc(Zd,"onSelect"),0<x.length&&(l=new Od("onSelect","select",null,l,h),a.push({event:l,listeners:x}),l.target=Ba)))}function bc(a,l){var h={};return h[a.toLowerCase()]=l.toLowerCase(),h["Webkit"+a]="webkit"+l,h["Moz"+a]="moz"+l,h}var Ua={animationend:bc("Animation","AnimationEnd"),animationiteration:bc("Animation","AnimationIteration"),animationstart:bc("Animation","AnimationStart"),transitionend:bc("Transition","TransitionEnd")},Wd={},Ag={};u&&(Ag=document.createElement("div").style,"AnimationEvent"in window||(delete Ua.animationend.animation,delete Ua.animationiteration.animation,delete Ua.animationstart.animation),"TransitionEvent"in window||delete Ua.transitionend.transition);function kc(a){if(Wd[a])return Wd[a];if(!Ua[a])return a;var l=Ua[a],h;for(h in l)if(l.hasOwnProperty(h)&&h in Ag)return Wd[a]=l[h];return a}var Tg=kc("animationend"),Mg=kc("animationiteration"),$g=kc("animationstart"),Rg=kc("transitionend"),Og=new Map,zg="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error 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(" ");function yi(a,l){Og.set(a,l),o(l,[a])}for(var qd=0;qd<zg.length;qd++){var Gd=zg[qd],t_=Gd.toLowerCase(),n_=Gd[0].toUpperCase()+Gd.slice(1);yi(t_,"on"+n_)}yi(Tg,"onAnimationEnd"),yi(Mg,"onAnimationIteration"),yi($g,"onAnimationStart"),yi("dblclick","onDoubleClick"),yi("focusin","onFocus"),yi("focusout","onBlur"),yi(Rg,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Go="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(" "),s_=new Set("cancel close invalid load scroll toggle".split(" ").concat(Go));function Pg(a,l,h){var x=a.type||"unknown-event";a.currentTarget=h,pi(x,l,void 0,a),a.currentTarget=null}function Lg(a,l){l=(l&4)!==0;for(var h=0;h<a.length;h++){var x=a[h],j=x.event;x=x.listeners;e:{var A=void 0;if(l)for(var B=x.length-1;0<=B;B--){var X=x[B],J=X.instance,de=X.currentTarget;if(X=X.listener,J!==A&&j.isPropagationStopped())break e;Pg(j,X,de),A=J}else for(B=0;B<x.length;B++){if(X=x[B],J=X.instance,de=X.currentTarget,X=X.listener,J!==A&&j.isPropagationStopped())break e;Pg(j,X,de),A=J}}}if(is)throw a=Js,is=!1,Js=null,a}function Ut(a,l){var h=l[nf];h===void 0&&(h=l[nf]=new Set);var x=a+"__bubble";h.has(x)||(Dg(l,a,2,!1),h.add(x))}function Kd(a,l,h){var x=0;l&&(x|=4),Dg(h,a,x,l)}var wc="_reactListening"+Math.random().toString(36).slice(2);function Ko(a){if(!a[wc]){a[wc]=!0,r.forEach(function(h){h!=="selectionchange"&&(s_.has(h)||Kd(h,!1,a),Kd(h,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[wc]||(l[wc]=!0,Kd("selectionchange",!1,l))}}function Dg(a,l,h,x){switch(qr(l)){case 1:var j=pt;break;case 4:j=dn;break;default:j=us}h=j.bind(null,l,h,a),j=void 0,!De||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(j=!0),x?j!==void 0?a.addEventListener(l,h,{capture:!0,passive:j}):a.addEventListener(l,h,!0):j!==void 0?a.addEventListener(l,h,{passive:j}):a.addEventListener(l,h,!1)}function Yd(a,l,h,x,j){var A=x;if((l&1)===0&&(l&2)===0&&x!==null)e:for(;;){if(x===null)return;var B=x.tag;if(B===3||B===4){var X=x.stateNode.containerInfo;if(X===j||X.nodeType===8&&X.parentNode===j)break;if(B===4)for(B=x.return;B!==null;){var J=B.tag;if((J===3||J===4)&&(J=B.stateNode.containerInfo,J===j||J.nodeType===8&&J.parentNode===j))return;B=B.return}for(;X!==null;){if(B=ta(X),B===null)return;if(J=B.tag,J===5||J===6){x=A=B;continue e}X=X.parentNode}}x=x.return}Tt(function(){var de=A,_e=Xs(h),Ce=[];e:{var Se=Og.get(a);if(Se!==void 0){var He=Od,We=a;switch(a){case"keypress":if(gc(h)===0)break e;case"keydown":case"keyup":He=$S;break;case"focusin":We="focus",He=Ld;break;case"focusout":We="blur",He=Ld;break;case"beforeblur":case"afterblur":He=Ld;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":He=dg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=kS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=zS;break;case Tg:case Mg:case $g:He=jS;break;case Rg:He=LS;break;case"scroll":He=yS;break;case"wheel":He=FS;break;case"copy":case"cut":case"paste":He=_S;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=hg}var Ke=(l&4)!==0,fn=!Ke&&a==="scroll",oe=Ke?Se!==null?Se+"Capture":null:Se;Ke=[];for(var ne=de,le;ne!==null;){le=ne;var $e=le.stateNode;if(le.tag===5&&$e!==null&&(le=$e,oe!==null&&($e=Be(ne,oe),$e!=null&&Ke.push(Yo(ne,$e,le)))),fn)break;ne=ne.return}0<Ke.length&&(Se=new He(Se,We,null,h,_e),Ce.push({event:Se,listeners:Ke}))}}if((l&7)===0){e:{if(Se=a==="mouseover"||a==="pointerover",He=a==="mouseout"||a==="pointerout",Se&&h!==zs&&(We=h.relatedTarget||h.fromElement)&&(ta(We)||We[Gr]))break e;if((He||Se)&&(Se=_e.window===_e?_e:(Se=_e.ownerDocument)?Se.defaultView||Se.parentWindow:window,He?(We=h.relatedTarget||h.toElement,He=de,We=We?ta(We):null,We!==null&&(fn=Hn(We),We!==fn||We.tag!==5&&We.tag!==6)&&(We=null)):(He=null,We=de),He!==We)){if(Ke=dg,$e="onMouseLeave",oe="onMouseEnter",ne="mouse",(a==="pointerout"||a==="pointerover")&&(Ke=hg,$e="onPointerLeave",oe="onPointerEnter",ne="pointer"),fn=He==null?Se:Va(He),le=We==null?Se:Va(We),Se=new Ke($e,ne+"leave",He,h,_e),Se.target=fn,Se.relatedTarget=le,$e=null,ta(_e)===de&&(Ke=new Ke(oe,ne+"enter",We,h,_e),Ke.target=le,Ke.relatedTarget=fn,$e=Ke),fn=$e,He&&We)t:{for(Ke=He,oe=We,ne=0,le=Ke;le;le=Ha(le))ne++;for(le=0,$e=oe;$e;$e=Ha($e))le++;for(;0<ne-le;)Ke=Ha(Ke),ne--;for(;0<le-ne;)oe=Ha(oe),le--;for(;ne--;){if(Ke===oe||oe!==null&&Ke===oe.alternate)break t;Ke=Ha(Ke),oe=Ha(oe)}Ke=null}else Ke=null;He!==null&&Fg(Ce,Se,He,Ke,!1),We!==null&&fn!==null&&Fg(Ce,fn,We,Ke,!0)}}e:{if(Se=de?Va(de):window,He=Se.nodeName&&Se.nodeName.toLowerCase(),He==="select"||He==="input"&&Se.type==="file")var Ye=qS;else if(yg(Se))if(kg)Ye=XS;else{Ye=KS;var rt=GS}else(He=Se.nodeName)&&He.toLowerCase()==="input"&&(Se.type==="checkbox"||Se.type==="radio")&&(Ye=YS);if(Ye&&(Ye=Ye(a,de))){bg(Ce,Ye,h,_e);break e}rt&&rt(a,Se,de),a==="focusout"&&(rt=Se._wrapperState)&&rt.controlled&&Se.type==="number"&&tt(Se,"number",Se.value)}switch(rt=de?Va(de):window,a){case"focusin":(yg(rt)||rt.contentEditable==="true")&&(Ba=rt,Zd=de,qo=null);break;case"focusout":qo=Zd=Ba=null;break;case"mousedown":Vd=!0;break;case"contextmenu":case"mouseup":case"dragend":Vd=!1,Ig(Ce,h,_e);break;case"selectionchange":if(e_)break;case"keydown":case"keyup":Ig(Ce,h,_e)}var it;if(Fd)e:{switch(a){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else Fa?xg(a,h)&&(lt="onCompositionEnd"):a==="keydown"&&h.keyCode===229&&(lt="onCompositionStart");lt&&(pg&&h.locale!=="ko"&&(Fa||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&Fa&&(it=cg()):(Yt=_e,La="value"in Yt?Yt.value:Yt.textContent,Fa=!0)),rt=Nc(de,lt),0<rt.length&&(lt=new fg(lt,a,null,h,_e),Ce.push({event:lt,listeners:rt}),it?lt.data=it:(it=vg(h),it!==null&&(lt.data=it)))),(it=US?HS(a,h):ZS(a,h))&&(de=Nc(de,"onBeforeInput"),0<de.length&&(_e=new fg("onBeforeInput","beforeinput",null,h,_e),Ce.push({event:_e,listeners:de}),_e.data=it))}Lg(Ce,l)})}function Yo(a,l,h){return{instance:a,listener:l,currentTarget:h}}function Nc(a,l){for(var h=l+"Capture",x=[];a!==null;){var j=a,A=j.stateNode;j.tag===5&&A!==null&&(j=A,A=Be(a,h),A!=null&&x.unshift(Yo(a,A,j)),A=Be(a,l),A!=null&&x.push(Yo(a,A,j))),a=a.return}return x}function Ha(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function Fg(a,l,h,x,j){for(var A=l._reactName,B=[];h!==null&&h!==x;){var X=h,J=X.alternate,de=X.stateNode;if(J!==null&&J===x)break;X.tag===5&&de!==null&&(X=de,j?(J=Be(h,A),J!=null&&B.unshift(Yo(h,J,X))):j||(J=Be(h,A),J!=null&&B.push(Yo(h,J,X)))),h=h.return}B.length!==0&&a.push({event:l,listeners:B})}var r_=/\r\n?/g,i_=/\u0000|\uFFFD/g;function Bg(a){return(typeof a=="string"?a:""+a).replace(r_,`
|
|
38
|
-
`).replace(i_,"")}function jc(a,l,h){if(l=Bg(l),Bg(a)!==l&&h)throw Error(n(425))}function Sc(){}var Xd=null,Qd=null;function Jd(a,l){return a==="textarea"||a==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var ef=typeof setTimeout=="function"?setTimeout:void 0,a_=typeof clearTimeout=="function"?clearTimeout:void 0,Ug=typeof Promise=="function"?Promise:void 0,o_=typeof queueMicrotask=="function"?queueMicrotask:typeof Ug<"u"?function(a){return Ug.resolve(null).then(a).catch(l_)}:ef;function l_(a){setTimeout(function(){throw a})}function tf(a,l){var h=l,x=0;do{var j=h.nextSibling;if(a.removeChild(h),j&&j.nodeType===8)if(h=j.data,h==="/$"){if(x===0){a.removeChild(j),ye(l);return}x--}else h!=="$"&&h!=="$?"&&h!=="$!"||x++;h=j}while(h);ye(l)}function bi(a){for(;a!=null;a=a.nextSibling){var l=a.nodeType;if(l===1||l===3)break;if(l===8){if(l=a.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return a}function Hg(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var h=a.data;if(h==="$"||h==="$!"||h==="$?"){if(l===0)return a;l--}else h==="/$"&&l++}a=a.previousSibling}return null}var Za=Math.random().toString(36).slice(2),Ar="__reactFiber$"+Za,Xo="__reactProps$"+Za,Gr="__reactContainer$"+Za,nf="__reactEvents$"+Za,c_="__reactListeners$"+Za,u_="__reactHandles$"+Za;function ta(a){var l=a[Ar];if(l)return l;for(var h=a.parentNode;h;){if(l=h[Gr]||h[Ar]){if(h=l.alternate,l.child!==null||h!==null&&h.child!==null)for(a=Hg(a);a!==null;){if(h=a[Ar])return h;a=Hg(a)}return l}a=h,h=a.parentNode}return null}function Qo(a){return a=a[Ar]||a[Gr],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function Va(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function _c(a){return a[Xo]||null}var sf=[],Wa=-1;function ki(a){return{current:a}}function Ht(a){0>Wa||(a.current=sf[Wa],sf[Wa]=null,Wa--)}function Dt(a,l){Wa++,sf[Wa]=a.current,a.current=l}var wi={},Vn=ki(wi),ds=ki(!1),na=wi;function qa(a,l){var h=a.type.contextTypes;if(!h)return wi;var x=a.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===l)return x.__reactInternalMemoizedMaskedChildContext;var j={},A;for(A in h)j[A]=l[A];return x&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=l,a.__reactInternalMemoizedMaskedChildContext=j),j}function fs(a){return a=a.childContextTypes,a!=null}function Ec(){Ht(ds),Ht(Vn)}function Zg(a,l,h){if(Vn.current!==wi)throw Error(n(168));Dt(Vn,l),Dt(ds,h)}function Vg(a,l,h){var x=a.stateNode;if(l=l.childContextTypes,typeof x.getChildContext!="function")return h;x=x.getChildContext();for(var j in x)if(!(j in l))throw Error(n(108,ke(a)||"Unknown",j));return K({},h,x)}function Cc(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||wi,na=Vn.current,Dt(Vn,a),Dt(ds,ds.current),!0}function Wg(a,l,h){var x=a.stateNode;if(!x)throw Error(n(169));h?(a=Vg(a,l,na),x.__reactInternalMemoizedMergedChildContext=a,Ht(ds),Ht(Vn),Dt(Vn,a)):Ht(ds),Dt(ds,h)}var Kr=null,Ic=!1,rf=!1;function qg(a){Kr===null?Kr=[a]:Kr.push(a)}function d_(a){Ic=!0,qg(a)}function Ni(){if(!rf&&Kr!==null){rf=!0;var a=0,l=vt;try{var h=Kr;for(vt=1;a<h.length;a++){var x=h[a];do x=x(!0);while(x!==null)}Kr=null,Ic=!1}catch(j){throw Kr!==null&&(Kr=Kr.slice(a+1)),Ns(Hr,Ni),j}finally{vt=l,rf=!1}}return null}var Ga=[],Ka=0,Ac=null,Tc=0,Bs=[],Us=0,sa=null,Yr=1,Xr="";function ra(a,l){Ga[Ka++]=Tc,Ga[Ka++]=Ac,Ac=a,Tc=l}function Gg(a,l,h){Bs[Us++]=Yr,Bs[Us++]=Xr,Bs[Us++]=sa,sa=a;var x=Yr;a=Xr;var j=32-zt(x)-1;x&=~(1<<j),h+=1;var A=32-zt(l)+j;if(30<A){var B=j-j%5;A=(x&(1<<B)-1).toString(32),x>>=B,j-=B,Yr=1<<32-zt(l)+j|h<<j|x,Xr=A+a}else Yr=1<<A|h<<j|x,Xr=a}function af(a){a.return!==null&&(ra(a,1),Gg(a,1,0))}function of(a){for(;a===Ac;)Ac=Ga[--Ka],Ga[Ka]=null,Tc=Ga[--Ka],Ga[Ka]=null;for(;a===sa;)sa=Bs[--Us],Bs[Us]=null,Xr=Bs[--Us],Bs[Us]=null,Yr=Bs[--Us],Bs[Us]=null}var Ss=null,_s=null,qt=!1,ir=null;function Kg(a,l){var h=Ws(5,null,null,0);h.elementType="DELETED",h.stateNode=l,h.return=a,l=a.deletions,l===null?(a.deletions=[h],a.flags|=16):l.push(h)}function Yg(a,l){switch(a.tag){case 5:var h=a.type;return l=l.nodeType!==1||h.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(a.stateNode=l,Ss=a,_s=bi(l.firstChild),!0):!1;case 6:return l=a.pendingProps===""||l.nodeType!==3?null:l,l!==null?(a.stateNode=l,Ss=a,_s=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(h=sa!==null?{id:Yr,overflow:Xr}:null,a.memoizedState={dehydrated:l,treeContext:h,retryLane:1073741824},h=Ws(18,null,null,0),h.stateNode=l,h.return=a,a.child=h,Ss=a,_s=null,!0):!1;default:return!1}}function lf(a){return(a.mode&1)!==0&&(a.flags&128)===0}function cf(a){if(qt){var l=_s;if(l){var h=l;if(!Yg(a,l)){if(lf(a))throw Error(n(418));l=bi(h.nextSibling);var x=Ss;l&&Yg(a,l)?Kg(x,h):(a.flags=a.flags&-4097|2,qt=!1,Ss=a)}}else{if(lf(a))throw Error(n(418));a.flags=a.flags&-4097|2,qt=!1,Ss=a}}}function Xg(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Ss=a}function Mc(a){if(a!==Ss)return!1;if(!qt)return Xg(a),qt=!0,!1;var l;if((l=a.tag!==3)&&!(l=a.tag!==5)&&(l=a.type,l=l!=="head"&&l!=="body"&&!Jd(a.type,a.memoizedProps)),l&&(l=_s)){if(lf(a))throw Qg(),Error(n(418));for(;l;)Kg(a,l),l=bi(l.nextSibling)}if(Xg(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));e:{for(a=a.nextSibling,l=0;a;){if(a.nodeType===8){var h=a.data;if(h==="/$"){if(l===0){_s=bi(a.nextSibling);break e}l--}else h!=="$"&&h!=="$!"&&h!=="$?"||l++}a=a.nextSibling}_s=null}}else _s=Ss?bi(a.stateNode.nextSibling):null;return!0}function Qg(){for(var a=_s;a;)a=bi(a.nextSibling)}function Ya(){_s=Ss=null,qt=!1}function uf(a){ir===null?ir=[a]:ir.push(a)}var f_=$.ReactCurrentBatchConfig;function Jo(a,l,h){if(a=h.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(h._owner){if(h=h._owner,h){if(h.tag!==1)throw Error(n(309));var x=h.stateNode}if(!x)throw Error(n(147,a));var j=x,A=""+a;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===A?l.ref:(l=function(B){var X=j.refs;B===null?delete X[A]:X[A]=B},l._stringRef=A,l)}if(typeof a!="string")throw Error(n(284));if(!h._owner)throw Error(n(290,a))}return a}function $c(a,l){throw a=Object.prototype.toString.call(l),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a))}function Jg(a){var l=a._init;return l(a._payload)}function ex(a){function l(oe,ne){if(a){var le=oe.deletions;le===null?(oe.deletions=[ne],oe.flags|=16):le.push(ne)}}function h(oe,ne){if(!a)return null;for(;ne!==null;)l(oe,ne),ne=ne.sibling;return null}function x(oe,ne){for(oe=new Map;ne!==null;)ne.key!==null?oe.set(ne.key,ne):oe.set(ne.index,ne),ne=ne.sibling;return oe}function j(oe,ne){return oe=Ti(oe,ne),oe.index=0,oe.sibling=null,oe}function A(oe,ne,le){return oe.index=le,a?(le=oe.alternate,le!==null?(le=le.index,le<ne?(oe.flags|=2,ne):le):(oe.flags|=2,ne)):(oe.flags|=1048576,ne)}function B(oe){return a&&oe.alternate===null&&(oe.flags|=2),oe}function X(oe,ne,le,$e){return ne===null||ne.tag!==6?(ne=th(le,oe.mode,$e),ne.return=oe,ne):(ne=j(ne,le),ne.return=oe,ne)}function J(oe,ne,le,$e){var Ye=le.type;return Ye===F?_e(oe,ne,le.props.children,$e,le.key):ne!==null&&(ne.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===L&&Jg(Ye)===ne.type)?($e=j(ne,le.props),$e.ref=Jo(oe,ne,le),$e.return=oe,$e):($e=su(le.type,le.key,le.props,null,oe.mode,$e),$e.ref=Jo(oe,ne,le),$e.return=oe,$e)}function de(oe,ne,le,$e){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==le.containerInfo||ne.stateNode.implementation!==le.implementation?(ne=nh(le,oe.mode,$e),ne.return=oe,ne):(ne=j(ne,le.children||[]),ne.return=oe,ne)}function _e(oe,ne,le,$e,Ye){return ne===null||ne.tag!==7?(ne=fa(le,oe.mode,$e,Ye),ne.return=oe,ne):(ne=j(ne,le),ne.return=oe,ne)}function Ce(oe,ne,le){if(typeof ne=="string"&&ne!==""||typeof ne=="number")return ne=th(""+ne,oe.mode,le),ne.return=oe,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case D:return le=su(ne.type,ne.key,ne.props,null,oe.mode,le),le.ref=Jo(oe,null,ne),le.return=oe,le;case O:return ne=nh(ne,oe.mode,le),ne.return=oe,ne;case L:var $e=ne._init;return Ce(oe,$e(ne._payload),le)}if(et(ne)||G(ne))return ne=fa(ne,oe.mode,le,null),ne.return=oe,ne;$c(oe,ne)}return null}function Se(oe,ne,le,$e){var Ye=ne!==null?ne.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Ye!==null?null:X(oe,ne,""+le,$e);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case D:return le.key===Ye?J(oe,ne,le,$e):null;case O:return le.key===Ye?de(oe,ne,le,$e):null;case L:return Ye=le._init,Se(oe,ne,Ye(le._payload),$e)}if(et(le)||G(le))return Ye!==null?null:_e(oe,ne,le,$e,null);$c(oe,le)}return null}function He(oe,ne,le,$e,Ye){if(typeof $e=="string"&&$e!==""||typeof $e=="number")return oe=oe.get(le)||null,X(ne,oe,""+$e,Ye);if(typeof $e=="object"&&$e!==null){switch($e.$$typeof){case D:return oe=oe.get($e.key===null?le:$e.key)||null,J(ne,oe,$e,Ye);case O:return oe=oe.get($e.key===null?le:$e.key)||null,de(ne,oe,$e,Ye);case L:var rt=$e._init;return He(oe,ne,le,rt($e._payload),Ye)}if(et($e)||G($e))return oe=oe.get(le)||null,_e(ne,oe,$e,Ye,null);$c(ne,$e)}return null}function We(oe,ne,le,$e){for(var Ye=null,rt=null,it=ne,lt=ne=0,Mn=null;it!==null&<<le.length;lt++){it.index>lt?(Mn=it,it=null):Mn=it.sibling;var St=Se(oe,it,le[lt],$e);if(St===null){it===null&&(it=Mn);break}a&&it&&St.alternate===null&&l(oe,it),ne=A(St,ne,lt),rt===null?Ye=St:rt.sibling=St,rt=St,it=Mn}if(lt===le.length)return h(oe,it),qt&&ra(oe,lt),Ye;if(it===null){for(;lt<le.length;lt++)it=Ce(oe,le[lt],$e),it!==null&&(ne=A(it,ne,lt),rt===null?Ye=it:rt.sibling=it,rt=it);return qt&&ra(oe,lt),Ye}for(it=x(oe,it);lt<le.length;lt++)Mn=He(it,oe,lt,le[lt],$e),Mn!==null&&(a&&Mn.alternate!==null&&it.delete(Mn.key===null?lt:Mn.key),ne=A(Mn,ne,lt),rt===null?Ye=Mn:rt.sibling=Mn,rt=Mn);return a&&it.forEach(function(Mi){return l(oe,Mi)}),qt&&ra(oe,lt),Ye}function Ke(oe,ne,le,$e){var Ye=G(le);if(typeof Ye!="function")throw Error(n(150));if(le=Ye.call(le),le==null)throw Error(n(151));for(var rt=Ye=null,it=ne,lt=ne=0,Mn=null,St=le.next();it!==null&&!St.done;lt++,St=le.next()){it.index>lt?(Mn=it,it=null):Mn=it.sibling;var Mi=Se(oe,it,St.value,$e);if(Mi===null){it===null&&(it=Mn);break}a&&it&&Mi.alternate===null&&l(oe,it),ne=A(Mi,ne,lt),rt===null?Ye=Mi:rt.sibling=Mi,rt=Mi,it=Mn}if(St.done)return h(oe,it),qt&&ra(oe,lt),Ye;if(it===null){for(;!St.done;lt++,St=le.next())St=Ce(oe,St.value,$e),St!==null&&(ne=A(St,ne,lt),rt===null?Ye=St:rt.sibling=St,rt=St);return qt&&ra(oe,lt),Ye}for(it=x(oe,it);!St.done;lt++,St=le.next())St=He(it,oe,lt,St.value,$e),St!==null&&(a&&St.alternate!==null&&it.delete(St.key===null?lt:St.key),ne=A(St,ne,lt),rt===null?Ye=St:rt.sibling=St,rt=St);return a&&it.forEach(function(V_){return l(oe,V_)}),qt&&ra(oe,lt),Ye}function fn(oe,ne,le,$e){if(typeof le=="object"&&le!==null&&le.type===F&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case D:e:{for(var Ye=le.key,rt=ne;rt!==null;){if(rt.key===Ye){if(Ye=le.type,Ye===F){if(rt.tag===7){h(oe,rt.sibling),ne=j(rt,le.props.children),ne.return=oe,oe=ne;break e}}else if(rt.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===L&&Jg(Ye)===rt.type){h(oe,rt.sibling),ne=j(rt,le.props),ne.ref=Jo(oe,rt,le),ne.return=oe,oe=ne;break e}h(oe,rt);break}else l(oe,rt);rt=rt.sibling}le.type===F?(ne=fa(le.props.children,oe.mode,$e,le.key),ne.return=oe,oe=ne):($e=su(le.type,le.key,le.props,null,oe.mode,$e),$e.ref=Jo(oe,ne,le),$e.return=oe,oe=$e)}return B(oe);case O:e:{for(rt=le.key;ne!==null;){if(ne.key===rt)if(ne.tag===4&&ne.stateNode.containerInfo===le.containerInfo&&ne.stateNode.implementation===le.implementation){h(oe,ne.sibling),ne=j(ne,le.children||[]),ne.return=oe,oe=ne;break e}else{h(oe,ne);break}else l(oe,ne);ne=ne.sibling}ne=nh(le,oe.mode,$e),ne.return=oe,oe=ne}return B(oe);case L:return rt=le._init,fn(oe,ne,rt(le._payload),$e)}if(et(le))return We(oe,ne,le,$e);if(G(le))return Ke(oe,ne,le,$e);$c(oe,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,ne!==null&&ne.tag===6?(h(oe,ne.sibling),ne=j(ne,le),ne.return=oe,oe=ne):(h(oe,ne),ne=th(le,oe.mode,$e),ne.return=oe,oe=ne),B(oe)):h(oe,ne)}return fn}var Xa=ex(!0),tx=ex(!1),Rc=ki(null),Oc=null,Qa=null,df=null;function ff(){df=Qa=Oc=null}function hf(a){var l=Rc.current;Ht(Rc),a._currentValue=l}function pf(a,l,h){for(;a!==null;){var x=a.alternate;if((a.childLanes&l)!==l?(a.childLanes|=l,x!==null&&(x.childLanes|=l)):x!==null&&(x.childLanes&l)!==l&&(x.childLanes|=l),a===h)break;a=a.return}}function Ja(a,l){Oc=a,df=Qa=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&l)!==0&&(hs=!0),a.firstContext=null)}function Hs(a){var l=a._currentValue;if(df!==a)if(a={context:a,memoizedValue:l,next:null},Qa===null){if(Oc===null)throw Error(n(308));Qa=a,Oc.dependencies={lanes:0,firstContext:a}}else Qa=Qa.next=a;return l}var ia=null;function mf(a){ia===null?ia=[a]:ia.push(a)}function nx(a,l,h,x){var j=l.interleaved;return j===null?(h.next=h,mf(l)):(h.next=j.next,j.next=h),l.interleaved=h,Qr(a,x)}function Qr(a,l){a.lanes|=l;var h=a.alternate;for(h!==null&&(h.lanes|=l),h=a,a=a.return;a!==null;)a.childLanes|=l,h=a.alternate,h!==null&&(h.childLanes|=l),h=a,a=a.return;return h.tag===3?h.stateNode:null}var ji=!1;function gf(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function sx(a,l){a=a.updateQueue,l.updateQueue===a&&(l.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function Jr(a,l){return{eventTime:a,lane:l,tag:0,payload:null,callback:null,next:null}}function Si(a,l,h){var x=a.updateQueue;if(x===null)return null;if(x=x.shared,(kt&2)!==0){var j=x.pending;return j===null?l.next=l:(l.next=j.next,j.next=l),x.pending=l,Qr(a,h)}return j=x.interleaved,j===null?(l.next=l,mf(x)):(l.next=j.next,j.next=l),x.interleaved=l,Qr(a,h)}function zc(a,l,h){if(l=l.updateQueue,l!==null&&(l=l.shared,(h&4194240)!==0)){var x=l.lanes;x&=a.pendingLanes,h|=x,l.lanes=h,Fs(a,h)}}function rx(a,l){var h=a.updateQueue,x=a.alternate;if(x!==null&&(x=x.updateQueue,h===x)){var j=null,A=null;if(h=h.firstBaseUpdate,h!==null){do{var B={eventTime:h.eventTime,lane:h.lane,tag:h.tag,payload:h.payload,callback:h.callback,next:null};A===null?j=A=B:A=A.next=B,h=h.next}while(h!==null);A===null?j=A=l:A=A.next=l}else j=A=l;h={baseState:x.baseState,firstBaseUpdate:j,lastBaseUpdate:A,shared:x.shared,effects:x.effects},a.updateQueue=h;return}a=h.lastBaseUpdate,a===null?h.firstBaseUpdate=l:a.next=l,h.lastBaseUpdate=l}function Pc(a,l,h,x){var j=a.updateQueue;ji=!1;var A=j.firstBaseUpdate,B=j.lastBaseUpdate,X=j.shared.pending;if(X!==null){j.shared.pending=null;var J=X,de=J.next;J.next=null,B===null?A=de:B.next=de,B=J;var _e=a.alternate;_e!==null&&(_e=_e.updateQueue,X=_e.lastBaseUpdate,X!==B&&(X===null?_e.firstBaseUpdate=de:X.next=de,_e.lastBaseUpdate=J))}if(A!==null){var Ce=j.baseState;B=0,_e=de=J=null,X=A;do{var Se=X.lane,He=X.eventTime;if((x&Se)===Se){_e!==null&&(_e=_e.next={eventTime:He,lane:0,tag:X.tag,payload:X.payload,callback:X.callback,next:null});e:{var We=a,Ke=X;switch(Se=l,He=h,Ke.tag){case 1:if(We=Ke.payload,typeof We=="function"){Ce=We.call(He,Ce,Se);break e}Ce=We;break e;case 3:We.flags=We.flags&-65537|128;case 0:if(We=Ke.payload,Se=typeof We=="function"?We.call(He,Ce,Se):We,Se==null)break e;Ce=K({},Ce,Se);break e;case 2:ji=!0}}X.callback!==null&&X.lane!==0&&(a.flags|=64,Se=j.effects,Se===null?j.effects=[X]:Se.push(X))}else He={eventTime:He,lane:Se,tag:X.tag,payload:X.payload,callback:X.callback,next:null},_e===null?(de=_e=He,J=Ce):_e=_e.next=He,B|=Se;if(X=X.next,X===null){if(X=j.shared.pending,X===null)break;Se=X,X=Se.next,Se.next=null,j.lastBaseUpdate=Se,j.shared.pending=null}}while(!0);if(_e===null&&(J=Ce),j.baseState=J,j.firstBaseUpdate=de,j.lastBaseUpdate=_e,l=j.shared.interleaved,l!==null){j=l;do B|=j.lane,j=j.next;while(j!==l)}else A===null&&(j.shared.lanes=0);la|=B,a.lanes=B,a.memoizedState=Ce}}function ix(a,l,h){if(a=l.effects,l.effects=null,a!==null)for(l=0;l<a.length;l++){var x=a[l],j=x.callback;if(j!==null){if(x.callback=null,x=h,typeof j!="function")throw Error(n(191,j));j.call(x)}}}var el={},Tr=ki(el),tl=ki(el),nl=ki(el);function aa(a){if(a===el)throw Error(n(174));return a}function xf(a,l){switch(Dt(nl,l),Dt(tl,a),Dt(Tr,el),a=l.nodeType,a){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:an(null,"");break;default:a=a===8?l.parentNode:l,l=a.namespaceURI||null,a=a.tagName,l=an(l,a)}Ht(Tr),Dt(Tr,l)}function eo(){Ht(Tr),Ht(tl),Ht(nl)}function ax(a){aa(nl.current);var l=aa(Tr.current),h=an(l,a.type);l!==h&&(Dt(tl,a),Dt(Tr,h))}function vf(a){tl.current===a&&(Ht(Tr),Ht(tl))}var Xt=ki(0);function Lc(a){for(var l=a;l!==null;){if(l.tag===13){var h=l.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||h.data==="$?"||h.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var yf=[];function bf(){for(var a=0;a<yf.length;a++)yf[a]._workInProgressVersionPrimary=null;yf.length=0}var Dc=$.ReactCurrentDispatcher,kf=$.ReactCurrentBatchConfig,oa=0,Qt=null,_n=null,An=null,Fc=!1,sl=!1,rl=0,h_=0;function Wn(){throw Error(n(321))}function wf(a,l){if(l===null)return!1;for(var h=0;h<l.length&&h<a.length;h++)if(!rr(a[h],l[h]))return!1;return!0}function Nf(a,l,h,x,j,A){if(oa=A,Qt=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,Dc.current=a===null||a.memoizedState===null?x_:v_,a=h(x,j),sl){A=0;do{if(sl=!1,rl=0,25<=A)throw Error(n(301));A+=1,An=_n=null,l.updateQueue=null,Dc.current=y_,a=h(x,j)}while(sl)}if(Dc.current=Hc,l=_n!==null&&_n.next!==null,oa=0,An=_n=Qt=null,Fc=!1,l)throw Error(n(300));return a}function jf(){var a=rl!==0;return rl=0,a}function Mr(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return An===null?Qt.memoizedState=An=a:An=An.next=a,An}function Zs(){if(_n===null){var a=Qt.alternate;a=a!==null?a.memoizedState:null}else a=_n.next;var l=An===null?Qt.memoizedState:An.next;if(l!==null)An=l,_n=a;else{if(a===null)throw Error(n(310));_n=a,a={memoizedState:_n.memoizedState,baseState:_n.baseState,baseQueue:_n.baseQueue,queue:_n.queue,next:null},An===null?Qt.memoizedState=An=a:An=An.next=a}return An}function il(a,l){return typeof l=="function"?l(a):l}function Sf(a){var l=Zs(),h=l.queue;if(h===null)throw Error(n(311));h.lastRenderedReducer=a;var x=_n,j=x.baseQueue,A=h.pending;if(A!==null){if(j!==null){var B=j.next;j.next=A.next,A.next=B}x.baseQueue=j=A,h.pending=null}if(j!==null){A=j.next,x=x.baseState;var X=B=null,J=null,de=A;do{var _e=de.lane;if((oa&_e)===_e)J!==null&&(J=J.next={lane:0,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null}),x=de.hasEagerState?de.eagerState:a(x,de.action);else{var Ce={lane:_e,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null};J===null?(X=J=Ce,B=x):J=J.next=Ce,Qt.lanes|=_e,la|=_e}de=de.next}while(de!==null&&de!==A);J===null?B=x:J.next=X,rr(x,l.memoizedState)||(hs=!0),l.memoizedState=x,l.baseState=B,l.baseQueue=J,h.lastRenderedState=x}if(a=h.interleaved,a!==null){j=a;do A=j.lane,Qt.lanes|=A,la|=A,j=j.next;while(j!==a)}else j===null&&(h.lanes=0);return[l.memoizedState,h.dispatch]}function _f(a){var l=Zs(),h=l.queue;if(h===null)throw Error(n(311));h.lastRenderedReducer=a;var x=h.dispatch,j=h.pending,A=l.memoizedState;if(j!==null){h.pending=null;var B=j=j.next;do A=a(A,B.action),B=B.next;while(B!==j);rr(A,l.memoizedState)||(hs=!0),l.memoizedState=A,l.baseQueue===null&&(l.baseState=A),h.lastRenderedState=A}return[A,x]}function ox(){}function lx(a,l){var h=Qt,x=Zs(),j=l(),A=!rr(x.memoizedState,j);if(A&&(x.memoizedState=j,hs=!0),x=x.queue,Ef(dx.bind(null,h,x,a),[a]),x.getSnapshot!==l||A||An!==null&&An.memoizedState.tag&1){if(h.flags|=2048,al(9,ux.bind(null,h,x,j,l),void 0,null),Tn===null)throw Error(n(349));(oa&30)!==0||cx(h,l,j)}return j}function cx(a,l,h){a.flags|=16384,a={getSnapshot:l,value:h},l=Qt.updateQueue,l===null?(l={lastEffect:null,stores:null},Qt.updateQueue=l,l.stores=[a]):(h=l.stores,h===null?l.stores=[a]:h.push(a))}function ux(a,l,h,x){l.value=h,l.getSnapshot=x,fx(l)&&hx(a)}function dx(a,l,h){return h(function(){fx(l)&&hx(a)})}function fx(a){var l=a.getSnapshot;a=a.value;try{var h=l();return!rr(a,h)}catch{return!0}}function hx(a){var l=Qr(a,1);l!==null&&cr(l,a,1,-1)}function px(a){var l=Mr();return typeof a=="function"&&(a=a()),l.memoizedState=l.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:il,lastRenderedState:a},l.queue=a,a=a.dispatch=g_.bind(null,Qt,a),[l.memoizedState,a]}function al(a,l,h,x){return a={tag:a,create:l,destroy:h,deps:x,next:null},l=Qt.updateQueue,l===null?(l={lastEffect:null,stores:null},Qt.updateQueue=l,l.lastEffect=a.next=a):(h=l.lastEffect,h===null?l.lastEffect=a.next=a:(x=h.next,h.next=a,a.next=x,l.lastEffect=a)),a}function mx(){return Zs().memoizedState}function Bc(a,l,h,x){var j=Mr();Qt.flags|=a,j.memoizedState=al(1|l,h,void 0,x===void 0?null:x)}function Uc(a,l,h,x){var j=Zs();x=x===void 0?null:x;var A=void 0;if(_n!==null){var B=_n.memoizedState;if(A=B.destroy,x!==null&&wf(x,B.deps)){j.memoizedState=al(l,h,A,x);return}}Qt.flags|=a,j.memoizedState=al(1|l,h,A,x)}function gx(a,l){return Bc(8390656,8,a,l)}function Ef(a,l){return Uc(2048,8,a,l)}function xx(a,l){return Uc(4,2,a,l)}function vx(a,l){return Uc(4,4,a,l)}function yx(a,l){if(typeof l=="function")return a=a(),l(a),function(){l(null)};if(l!=null)return a=a(),l.current=a,function(){l.current=null}}function bx(a,l,h){return h=h!=null?h.concat([a]):null,Uc(4,4,yx.bind(null,l,a),h)}function Cf(){}function kx(a,l){var h=Zs();l=l===void 0?null:l;var x=h.memoizedState;return x!==null&&l!==null&&wf(l,x[1])?x[0]:(h.memoizedState=[a,l],a)}function wx(a,l){var h=Zs();l=l===void 0?null:l;var x=h.memoizedState;return x!==null&&l!==null&&wf(l,x[1])?x[0]:(a=a(),h.memoizedState=[a,l],a)}function Nx(a,l,h){return(oa&21)===0?(a.baseState&&(a.baseState=!1,hs=!0),a.memoizedState=h):(rr(h,l)||(h=vi(),Qt.lanes|=h,la|=h,a.baseState=!0),l)}function p_(a,l){var h=vt;vt=h!==0&&4>h?h:4,a(!0);var x=kf.transition;kf.transition={};try{a(!1),l()}finally{vt=h,kf.transition=x}}function jx(){return Zs().memoizedState}function m_(a,l,h){var x=Ii(a);if(h={lane:x,action:h,hasEagerState:!1,eagerState:null,next:null},Sx(a))_x(l,h);else if(h=nx(a,l,h,x),h!==null){var j=ts();cr(h,a,x,j),Ex(h,l,x)}}function g_(a,l,h){var x=Ii(a),j={lane:x,action:h,hasEagerState:!1,eagerState:null,next:null};if(Sx(a))_x(l,j);else{var A=a.alternate;if(a.lanes===0&&(A===null||A.lanes===0)&&(A=l.lastRenderedReducer,A!==null))try{var B=l.lastRenderedState,X=A(B,h);if(j.hasEagerState=!0,j.eagerState=X,rr(X,B)){var J=l.interleaved;J===null?(j.next=j,mf(l)):(j.next=J.next,J.next=j),l.interleaved=j;return}}catch{}finally{}h=nx(a,l,j,x),h!==null&&(j=ts(),cr(h,a,x,j),Ex(h,l,x))}}function Sx(a){var l=a.alternate;return a===Qt||l!==null&&l===Qt}function _x(a,l){sl=Fc=!0;var h=a.pending;h===null?l.next=l:(l.next=h.next,h.next=l),a.pending=l}function Ex(a,l,h){if((h&4194240)!==0){var x=l.lanes;x&=a.pendingLanes,h|=x,l.lanes=h,Fs(a,h)}}var Hc={readContext:Hs,useCallback:Wn,useContext:Wn,useEffect:Wn,useImperativeHandle:Wn,useInsertionEffect:Wn,useLayoutEffect:Wn,useMemo:Wn,useReducer:Wn,useRef:Wn,useState:Wn,useDebugValue:Wn,useDeferredValue:Wn,useTransition:Wn,useMutableSource:Wn,useSyncExternalStore:Wn,useId:Wn,unstable_isNewReconciler:!1},x_={readContext:Hs,useCallback:function(a,l){return Mr().memoizedState=[a,l===void 0?null:l],a},useContext:Hs,useEffect:gx,useImperativeHandle:function(a,l,h){return h=h!=null?h.concat([a]):null,Bc(4194308,4,yx.bind(null,l,a),h)},useLayoutEffect:function(a,l){return Bc(4194308,4,a,l)},useInsertionEffect:function(a,l){return Bc(4,2,a,l)},useMemo:function(a,l){var h=Mr();return l=l===void 0?null:l,a=a(),h.memoizedState=[a,l],a},useReducer:function(a,l,h){var x=Mr();return l=h!==void 0?h(l):l,x.memoizedState=x.baseState=l,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:l},x.queue=a,a=a.dispatch=m_.bind(null,Qt,a),[x.memoizedState,a]},useRef:function(a){var l=Mr();return a={current:a},l.memoizedState=a},useState:px,useDebugValue:Cf,useDeferredValue:function(a){return Mr().memoizedState=a},useTransition:function(){var a=px(!1),l=a[0];return a=p_.bind(null,a[1]),Mr().memoizedState=a,[l,a]},useMutableSource:function(){},useSyncExternalStore:function(a,l,h){var x=Qt,j=Mr();if(qt){if(h===void 0)throw Error(n(407));h=h()}else{if(h=l(),Tn===null)throw Error(n(349));(oa&30)!==0||cx(x,l,h)}j.memoizedState=h;var A={value:h,getSnapshot:l};return j.queue=A,gx(dx.bind(null,x,A,a),[a]),x.flags|=2048,al(9,ux.bind(null,x,A,h,l),void 0,null),h},useId:function(){var a=Mr(),l=Tn.identifierPrefix;if(qt){var h=Xr,x=Yr;h=(x&~(1<<32-zt(x)-1)).toString(32)+h,l=":"+l+"R"+h,h=rl++,0<h&&(l+="H"+h.toString(32)),l+=":"}else h=h_++,l=":"+l+"r"+h.toString(32)+":";return a.memoizedState=l},unstable_isNewReconciler:!1},v_={readContext:Hs,useCallback:kx,useContext:Hs,useEffect:Ef,useImperativeHandle:bx,useInsertionEffect:xx,useLayoutEffect:vx,useMemo:wx,useReducer:Sf,useRef:mx,useState:function(){return Sf(il)},useDebugValue:Cf,useDeferredValue:function(a){var l=Zs();return Nx(l,_n.memoizedState,a)},useTransition:function(){var a=Sf(il)[0],l=Zs().memoizedState;return[a,l]},useMutableSource:ox,useSyncExternalStore:lx,useId:jx,unstable_isNewReconciler:!1},y_={readContext:Hs,useCallback:kx,useContext:Hs,useEffect:Ef,useImperativeHandle:bx,useInsertionEffect:xx,useLayoutEffect:vx,useMemo:wx,useReducer:_f,useRef:mx,useState:function(){return _f(il)},useDebugValue:Cf,useDeferredValue:function(a){var l=Zs();return _n===null?l.memoizedState=a:Nx(l,_n.memoizedState,a)},useTransition:function(){var a=_f(il)[0],l=Zs().memoizedState;return[a,l]},useMutableSource:ox,useSyncExternalStore:lx,useId:jx,unstable_isNewReconciler:!1};function ar(a,l){if(a&&a.defaultProps){l=K({},l),a=a.defaultProps;for(var h in a)l[h]===void 0&&(l[h]=a[h]);return l}return l}function If(a,l,h,x){l=a.memoizedState,h=h(x,l),h=h==null?l:K({},l,h),a.memoizedState=h,a.lanes===0&&(a.updateQueue.baseState=h)}var Zc={isMounted:function(a){return(a=a._reactInternals)?Hn(a)===a:!1},enqueueSetState:function(a,l,h){a=a._reactInternals;var x=ts(),j=Ii(a),A=Jr(x,j);A.payload=l,h!=null&&(A.callback=h),l=Si(a,A,j),l!==null&&(cr(l,a,j,x),zc(l,a,j))},enqueueReplaceState:function(a,l,h){a=a._reactInternals;var x=ts(),j=Ii(a),A=Jr(x,j);A.tag=1,A.payload=l,h!=null&&(A.callback=h),l=Si(a,A,j),l!==null&&(cr(l,a,j,x),zc(l,a,j))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var h=ts(),x=Ii(a),j=Jr(h,x);j.tag=2,l!=null&&(j.callback=l),l=Si(a,j,x),l!==null&&(cr(l,a,x,h),zc(l,a,x))}};function Cx(a,l,h,x,j,A,B){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(x,A,B):l.prototype&&l.prototype.isPureReactComponent?!Wo(h,x)||!Wo(j,A):!0}function Ix(a,l,h){var x=!1,j=wi,A=l.contextType;return typeof A=="object"&&A!==null?A=Hs(A):(j=fs(l)?na:Vn.current,x=l.contextTypes,A=(x=x!=null)?qa(a,j):wi),l=new l(h,A),a.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=Zc,a.stateNode=l,l._reactInternals=a,x&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=j,a.__reactInternalMemoizedMaskedChildContext=A),l}function Ax(a,l,h,x){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(h,x),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(h,x),l.state!==a&&Zc.enqueueReplaceState(l,l.state,null)}function Af(a,l,h,x){var j=a.stateNode;j.props=h,j.state=a.memoizedState,j.refs={},gf(a);var A=l.contextType;typeof A=="object"&&A!==null?j.context=Hs(A):(A=fs(l)?na:Vn.current,j.context=qa(a,A)),j.state=a.memoizedState,A=l.getDerivedStateFromProps,typeof A=="function"&&(If(a,l,A,h),j.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(l=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),l!==j.state&&Zc.enqueueReplaceState(j,j.state,null),Pc(a,h,j,x),j.state=a.memoizedState),typeof j.componentDidMount=="function"&&(a.flags|=4194308)}function to(a,l){try{var h="",x=l;do h+=me(x),x=x.return;while(x);var j=h}catch(A){j=`
|
|
39
|
-
Error generating stack: `+A.message+`
|
|
40
|
-
`+A.stack}return{value:a,source:l,stack:j,digest:null}}function Tf(a,l,h){return{value:a,source:null,stack:h??null,digest:l??null}}function Mf(a,l){try{console.error(l.value)}catch(h){setTimeout(function(){throw h})}}var b_=typeof WeakMap=="function"?WeakMap:Map;function Tx(a,l,h){h=Jr(-1,h),h.tag=3,h.payload={element:null};var x=l.value;return h.callback=function(){Xc||(Xc=!0,qf=x),Mf(a,l)},h}function Mx(a,l,h){h=Jr(-1,h),h.tag=3;var x=a.type.getDerivedStateFromError;if(typeof x=="function"){var j=l.value;h.payload=function(){return x(j)},h.callback=function(){Mf(a,l)}}var A=a.stateNode;return A!==null&&typeof A.componentDidCatch=="function"&&(h.callback=function(){Mf(a,l),typeof x!="function"&&(Ei===null?Ei=new Set([this]):Ei.add(this));var B=l.stack;this.componentDidCatch(l.value,{componentStack:B!==null?B:""})}),h}function $x(a,l,h){var x=a.pingCache;if(x===null){x=a.pingCache=new b_;var j=new Set;x.set(l,j)}else j=x.get(l),j===void 0&&(j=new Set,x.set(l,j));j.has(h)||(j.add(h),a=R_.bind(null,a,l,h),l.then(a,a))}function Rx(a){do{var l;if((l=a.tag===13)&&(l=a.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return a;a=a.return}while(a!==null);return null}function Ox(a,l,h,x,j){return(a.mode&1)===0?(a===l?a.flags|=65536:(a.flags|=128,h.flags|=131072,h.flags&=-52805,h.tag===1&&(h.alternate===null?h.tag=17:(l=Jr(-1,1),l.tag=2,Si(h,l,1))),h.lanes|=1),a):(a.flags|=65536,a.lanes=j,a)}var k_=$.ReactCurrentOwner,hs=!1;function es(a,l,h,x){l.child=a===null?tx(l,null,h,x):Xa(l,a.child,h,x)}function zx(a,l,h,x,j){h=h.render;var A=l.ref;return Ja(l,j),x=Nf(a,l,h,x,A,j),h=jf(),a!==null&&!hs?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~j,ei(a,l,j)):(qt&&h&&af(l),l.flags|=1,es(a,l,x,j),l.child)}function Px(a,l,h,x,j){if(a===null){var A=h.type;return typeof A=="function"&&!eh(A)&&A.defaultProps===void 0&&h.compare===null&&h.defaultProps===void 0?(l.tag=15,l.type=A,Lx(a,l,A,x,j)):(a=su(h.type,null,x,l,l.mode,j),a.ref=l.ref,a.return=l,l.child=a)}if(A=a.child,(a.lanes&j)===0){var B=A.memoizedProps;if(h=h.compare,h=h!==null?h:Wo,h(B,x)&&a.ref===l.ref)return ei(a,l,j)}return l.flags|=1,a=Ti(A,x),a.ref=l.ref,a.return=l,l.child=a}function Lx(a,l,h,x,j){if(a!==null){var A=a.memoizedProps;if(Wo(A,x)&&a.ref===l.ref)if(hs=!1,l.pendingProps=x=A,(a.lanes&j)!==0)(a.flags&131072)!==0&&(hs=!0);else return l.lanes=a.lanes,ei(a,l,j)}return $f(a,l,h,x,j)}function Dx(a,l,h){var x=l.pendingProps,j=x.children,A=a!==null?a.memoizedState:null;if(x.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Dt(so,Es),Es|=h;else{if((h&1073741824)===0)return a=A!==null?A.baseLanes|h:h,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:a,cachePool:null,transitions:null},l.updateQueue=null,Dt(so,Es),Es|=a,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=A!==null?A.baseLanes:h,Dt(so,Es),Es|=x}else A!==null?(x=A.baseLanes|h,l.memoizedState=null):x=h,Dt(so,Es),Es|=x;return es(a,l,j,h),l.child}function Fx(a,l){var h=l.ref;(a===null&&h!==null||a!==null&&a.ref!==h)&&(l.flags|=512,l.flags|=2097152)}function $f(a,l,h,x,j){var A=fs(h)?na:Vn.current;return A=qa(l,A),Ja(l,j),h=Nf(a,l,h,x,A,j),x=jf(),a!==null&&!hs?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~j,ei(a,l,j)):(qt&&x&&af(l),l.flags|=1,es(a,l,h,j),l.child)}function Bx(a,l,h,x,j){if(fs(h)){var A=!0;Cc(l)}else A=!1;if(Ja(l,j),l.stateNode===null)Wc(a,l),Ix(l,h,x),Af(l,h,x,j),x=!0;else if(a===null){var B=l.stateNode,X=l.memoizedProps;B.props=X;var J=B.context,de=h.contextType;typeof de=="object"&&de!==null?de=Hs(de):(de=fs(h)?na:Vn.current,de=qa(l,de));var _e=h.getDerivedStateFromProps,Ce=typeof _e=="function"||typeof B.getSnapshotBeforeUpdate=="function";Ce||typeof B.UNSAFE_componentWillReceiveProps!="function"&&typeof B.componentWillReceiveProps!="function"||(X!==x||J!==de)&&Ax(l,B,x,de),ji=!1;var Se=l.memoizedState;B.state=Se,Pc(l,x,B,j),J=l.memoizedState,X!==x||Se!==J||ds.current||ji?(typeof _e=="function"&&(If(l,h,_e,x),J=l.memoizedState),(X=ji||Cx(l,h,X,x,Se,J,de))?(Ce||typeof B.UNSAFE_componentWillMount!="function"&&typeof B.componentWillMount!="function"||(typeof B.componentWillMount=="function"&&B.componentWillMount(),typeof B.UNSAFE_componentWillMount=="function"&&B.UNSAFE_componentWillMount()),typeof B.componentDidMount=="function"&&(l.flags|=4194308)):(typeof B.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=x,l.memoizedState=J),B.props=x,B.state=J,B.context=de,x=X):(typeof B.componentDidMount=="function"&&(l.flags|=4194308),x=!1)}else{B=l.stateNode,sx(a,l),X=l.memoizedProps,de=l.type===l.elementType?X:ar(l.type,X),B.props=de,Ce=l.pendingProps,Se=B.context,J=h.contextType,typeof J=="object"&&J!==null?J=Hs(J):(J=fs(h)?na:Vn.current,J=qa(l,J));var He=h.getDerivedStateFromProps;(_e=typeof He=="function"||typeof B.getSnapshotBeforeUpdate=="function")||typeof B.UNSAFE_componentWillReceiveProps!="function"&&typeof B.componentWillReceiveProps!="function"||(X!==Ce||Se!==J)&&Ax(l,B,x,J),ji=!1,Se=l.memoizedState,B.state=Se,Pc(l,x,B,j);var We=l.memoizedState;X!==Ce||Se!==We||ds.current||ji?(typeof He=="function"&&(If(l,h,He,x),We=l.memoizedState),(de=ji||Cx(l,h,de,x,Se,We,J)||!1)?(_e||typeof B.UNSAFE_componentWillUpdate!="function"&&typeof B.componentWillUpdate!="function"||(typeof B.componentWillUpdate=="function"&&B.componentWillUpdate(x,We,J),typeof B.UNSAFE_componentWillUpdate=="function"&&B.UNSAFE_componentWillUpdate(x,We,J)),typeof B.componentDidUpdate=="function"&&(l.flags|=4),typeof B.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof B.componentDidUpdate!="function"||X===a.memoizedProps&&Se===a.memoizedState||(l.flags|=4),typeof B.getSnapshotBeforeUpdate!="function"||X===a.memoizedProps&&Se===a.memoizedState||(l.flags|=1024),l.memoizedProps=x,l.memoizedState=We),B.props=x,B.state=We,B.context=J,x=de):(typeof B.componentDidUpdate!="function"||X===a.memoizedProps&&Se===a.memoizedState||(l.flags|=4),typeof B.getSnapshotBeforeUpdate!="function"||X===a.memoizedProps&&Se===a.memoizedState||(l.flags|=1024),x=!1)}return Rf(a,l,h,x,A,j)}function Rf(a,l,h,x,j,A){Fx(a,l);var B=(l.flags&128)!==0;if(!x&&!B)return j&&Wg(l,h,!1),ei(a,l,A);x=l.stateNode,k_.current=l;var X=B&&typeof h.getDerivedStateFromError!="function"?null:x.render();return l.flags|=1,a!==null&&B?(l.child=Xa(l,a.child,null,A),l.child=Xa(l,null,X,A)):es(a,l,X,A),l.memoizedState=x.state,j&&Wg(l,h,!0),l.child}function Ux(a){var l=a.stateNode;l.pendingContext?Zg(a,l.pendingContext,l.pendingContext!==l.context):l.context&&Zg(a,l.context,!1),xf(a,l.containerInfo)}function Hx(a,l,h,x,j){return Ya(),uf(j),l.flags|=256,es(a,l,h,x),l.child}var Of={dehydrated:null,treeContext:null,retryLane:0};function zf(a){return{baseLanes:a,cachePool:null,transitions:null}}function Zx(a,l,h){var x=l.pendingProps,j=Xt.current,A=!1,B=(l.flags&128)!==0,X;if((X=B)||(X=a!==null&&a.memoizedState===null?!1:(j&2)!==0),X?(A=!0,l.flags&=-129):(a===null||a.memoizedState!==null)&&(j|=1),Dt(Xt,j&1),a===null)return cf(l),a=l.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((l.mode&1)===0?l.lanes=1:a.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(B=x.children,a=x.fallback,A?(x=l.mode,A=l.child,B={mode:"hidden",children:B},(x&1)===0&&A!==null?(A.childLanes=0,A.pendingProps=B):A=ru(B,x,0,null),a=fa(a,x,h,null),A.return=l,a.return=l,A.sibling=a,l.child=A,l.child.memoizedState=zf(h),l.memoizedState=Of,a):Pf(l,B));if(j=a.memoizedState,j!==null&&(X=j.dehydrated,X!==null))return w_(a,l,B,x,X,j,h);if(A){A=x.fallback,B=l.mode,j=a.child,X=j.sibling;var J={mode:"hidden",children:x.children};return(B&1)===0&&l.child!==j?(x=l.child,x.childLanes=0,x.pendingProps=J,l.deletions=null):(x=Ti(j,J),x.subtreeFlags=j.subtreeFlags&14680064),X!==null?A=Ti(X,A):(A=fa(A,B,h,null),A.flags|=2),A.return=l,x.return=l,x.sibling=A,l.child=x,x=A,A=l.child,B=a.child.memoizedState,B=B===null?zf(h):{baseLanes:B.baseLanes|h,cachePool:null,transitions:B.transitions},A.memoizedState=B,A.childLanes=a.childLanes&~h,l.memoizedState=Of,x}return A=a.child,a=A.sibling,x=Ti(A,{mode:"visible",children:x.children}),(l.mode&1)===0&&(x.lanes=h),x.return=l,x.sibling=null,a!==null&&(h=l.deletions,h===null?(l.deletions=[a],l.flags|=16):h.push(a)),l.child=x,l.memoizedState=null,x}function Pf(a,l){return l=ru({mode:"visible",children:l},a.mode,0,null),l.return=a,a.child=l}function Vc(a,l,h,x){return x!==null&&uf(x),Xa(l,a.child,null,h),a=Pf(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function w_(a,l,h,x,j,A,B){if(h)return l.flags&256?(l.flags&=-257,x=Tf(Error(n(422))),Vc(a,l,B,x)):l.memoizedState!==null?(l.child=a.child,l.flags|=128,null):(A=x.fallback,j=l.mode,x=ru({mode:"visible",children:x.children},j,0,null),A=fa(A,j,B,null),A.flags|=2,x.return=l,A.return=l,x.sibling=A,l.child=x,(l.mode&1)!==0&&Xa(l,a.child,null,B),l.child.memoizedState=zf(B),l.memoizedState=Of,A);if((l.mode&1)===0)return Vc(a,l,B,null);if(j.data==="$!"){if(x=j.nextSibling&&j.nextSibling.dataset,x)var X=x.dgst;return x=X,A=Error(n(419)),x=Tf(A,x,void 0),Vc(a,l,B,x)}if(X=(B&a.childLanes)!==0,hs||X){if(x=Tn,x!==null){switch(B&-B){case 4:j=2;break;case 16:j=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:j=32;break;case 536870912:j=268435456;break;default:j=0}j=(j&(x.suspendedLanes|B))!==0?0:j,j!==0&&j!==A.retryLane&&(A.retryLane=j,Qr(a,j),cr(x,a,j,-1))}return Jf(),x=Tf(Error(n(421))),Vc(a,l,B,x)}return j.data==="$?"?(l.flags|=128,l.child=a.child,l=O_.bind(null,a),j._reactRetry=l,null):(a=A.treeContext,_s=bi(j.nextSibling),Ss=l,qt=!0,ir=null,a!==null&&(Bs[Us++]=Yr,Bs[Us++]=Xr,Bs[Us++]=sa,Yr=a.id,Xr=a.overflow,sa=l),l=Pf(l,x.children),l.flags|=4096,l)}function Vx(a,l,h){a.lanes|=l;var x=a.alternate;x!==null&&(x.lanes|=l),pf(a.return,l,h)}function Lf(a,l,h,x,j){var A=a.memoizedState;A===null?a.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:x,tail:h,tailMode:j}:(A.isBackwards=l,A.rendering=null,A.renderingStartTime=0,A.last=x,A.tail=h,A.tailMode=j)}function Wx(a,l,h){var x=l.pendingProps,j=x.revealOrder,A=x.tail;if(es(a,l,x.children,h),x=Xt.current,(x&2)!==0)x=x&1|2,l.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=l.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&Vx(a,h,l);else if(a.tag===19)Vx(a,h,l);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===l)break e;for(;a.sibling===null;){if(a.return===null||a.return===l)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}x&=1}if(Dt(Xt,x),(l.mode&1)===0)l.memoizedState=null;else switch(j){case"forwards":for(h=l.child,j=null;h!==null;)a=h.alternate,a!==null&&Lc(a)===null&&(j=h),h=h.sibling;h=j,h===null?(j=l.child,l.child=null):(j=h.sibling,h.sibling=null),Lf(l,!1,j,h,A);break;case"backwards":for(h=null,j=l.child,l.child=null;j!==null;){if(a=j.alternate,a!==null&&Lc(a)===null){l.child=j;break}a=j.sibling,j.sibling=h,h=j,j=a}Lf(l,!0,h,null,A);break;case"together":Lf(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function Wc(a,l){(l.mode&1)===0&&a!==null&&(a.alternate=null,l.alternate=null,l.flags|=2)}function ei(a,l,h){if(a!==null&&(l.dependencies=a.dependencies),la|=l.lanes,(h&l.childLanes)===0)return null;if(a!==null&&l.child!==a.child)throw Error(n(153));if(l.child!==null){for(a=l.child,h=Ti(a,a.pendingProps),l.child=h,h.return=l;a.sibling!==null;)a=a.sibling,h=h.sibling=Ti(a,a.pendingProps),h.return=l;h.sibling=null}return l.child}function N_(a,l,h){switch(l.tag){case 3:Ux(l),Ya();break;case 5:ax(l);break;case 1:fs(l.type)&&Cc(l);break;case 4:xf(l,l.stateNode.containerInfo);break;case 10:var x=l.type._context,j=l.memoizedProps.value;Dt(Rc,x._currentValue),x._currentValue=j;break;case 13:if(x=l.memoizedState,x!==null)return x.dehydrated!==null?(Dt(Xt,Xt.current&1),l.flags|=128,null):(h&l.child.childLanes)!==0?Zx(a,l,h):(Dt(Xt,Xt.current&1),a=ei(a,l,h),a!==null?a.sibling:null);Dt(Xt,Xt.current&1);break;case 19:if(x=(h&l.childLanes)!==0,(a.flags&128)!==0){if(x)return Wx(a,l,h);l.flags|=128}if(j=l.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),Dt(Xt,Xt.current),x)break;return null;case 22:case 23:return l.lanes=0,Dx(a,l,h)}return ei(a,l,h)}var qx,Df,Gx,Kx;qx=function(a,l){for(var h=l.child;h!==null;){if(h.tag===5||h.tag===6)a.appendChild(h.stateNode);else if(h.tag!==4&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===l)break;for(;h.sibling===null;){if(h.return===null||h.return===l)return;h=h.return}h.sibling.return=h.return,h=h.sibling}},Df=function(){},Gx=function(a,l,h,x){var j=a.memoizedProps;if(j!==x){a=l.stateNode,aa(Tr.current);var A=null;switch(h){case"input":j=he(a,j),x=he(a,x),A=[];break;case"select":j=K({},j,{value:void 0}),x=K({},x,{value:void 0}),A=[];break;case"textarea":j=On(a,j),x=On(a,x),A=[];break;default:typeof j.onClick!="function"&&typeof x.onClick=="function"&&(a.onclick=Sc)}Rs(h,x);var B;h=null;for(de in j)if(!x.hasOwnProperty(de)&&j.hasOwnProperty(de)&&j[de]!=null)if(de==="style"){var X=j[de];for(B in X)X.hasOwnProperty(B)&&(h||(h={}),h[B]="")}else de!=="dangerouslySetInnerHTML"&&de!=="children"&&de!=="suppressContentEditableWarning"&&de!=="suppressHydrationWarning"&&de!=="autoFocus"&&(i.hasOwnProperty(de)?A||(A=[]):(A=A||[]).push(de,null));for(de in x){var J=x[de];if(X=j!=null?j[de]:void 0,x.hasOwnProperty(de)&&J!==X&&(J!=null||X!=null))if(de==="style")if(X){for(B in X)!X.hasOwnProperty(B)||J&&J.hasOwnProperty(B)||(h||(h={}),h[B]="");for(B in J)J.hasOwnProperty(B)&&X[B]!==J[B]&&(h||(h={}),h[B]=J[B])}else h||(A||(A=[]),A.push(de,h)),h=J;else de==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,X=X?X.__html:void 0,J!=null&&X!==J&&(A=A||[]).push(de,J)):de==="children"?typeof J!="string"&&typeof J!="number"||(A=A||[]).push(de,""+J):de!=="suppressContentEditableWarning"&&de!=="suppressHydrationWarning"&&(i.hasOwnProperty(de)?(J!=null&&de==="onScroll"&&Ut("scroll",a),A||X===J||(A=[])):(A=A||[]).push(de,J))}h&&(A=A||[]).push("style",h);var de=A;(l.updateQueue=de)&&(l.flags|=4)}},Kx=function(a,l,h,x){h!==x&&(l.flags|=4)};function ol(a,l){if(!qt)switch(a.tailMode){case"hidden":l=a.tail;for(var h=null;l!==null;)l.alternate!==null&&(h=l),l=l.sibling;h===null?a.tail=null:h.sibling=null;break;case"collapsed":h=a.tail;for(var x=null;h!==null;)h.alternate!==null&&(x=h),h=h.sibling;x===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:x.sibling=null}}function qn(a){var l=a.alternate!==null&&a.alternate.child===a.child,h=0,x=0;if(l)for(var j=a.child;j!==null;)h|=j.lanes|j.childLanes,x|=j.subtreeFlags&14680064,x|=j.flags&14680064,j.return=a,j=j.sibling;else for(j=a.child;j!==null;)h|=j.lanes|j.childLanes,x|=j.subtreeFlags,x|=j.flags,j.return=a,j=j.sibling;return a.subtreeFlags|=x,a.childLanes=h,l}function j_(a,l,h){var x=l.pendingProps;switch(of(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qn(l),null;case 1:return fs(l.type)&&Ec(),qn(l),null;case 3:return x=l.stateNode,eo(),Ht(ds),Ht(Vn),bf(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(a===null||a.child===null)&&(Mc(l)?l.flags|=4:a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,ir!==null&&(Yf(ir),ir=null))),Df(a,l),qn(l),null;case 5:vf(l);var j=aa(nl.current);if(h=l.type,a!==null&&l.stateNode!=null)Gx(a,l,h,x,j),a.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!x){if(l.stateNode===null)throw Error(n(166));return qn(l),null}if(a=aa(Tr.current),Mc(l)){x=l.stateNode,h=l.type;var A=l.memoizedProps;switch(x[Ar]=l,x[Xo]=A,a=(l.mode&1)!==0,h){case"dialog":Ut("cancel",x),Ut("close",x);break;case"iframe":case"object":case"embed":Ut("load",x);break;case"video":case"audio":for(j=0;j<Go.length;j++)Ut(Go[j],x);break;case"source":Ut("error",x);break;case"img":case"image":case"link":Ut("error",x),Ut("load",x);break;case"details":Ut("toggle",x);break;case"input":ze(x,A),Ut("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!A.multiple},Ut("invalid",x);break;case"textarea":sn(x,A),Ut("invalid",x)}Rs(h,A),j=null;for(var B in A)if(A.hasOwnProperty(B)){var X=A[B];B==="children"?typeof X=="string"?x.textContent!==X&&(A.suppressHydrationWarning!==!0&&jc(x.textContent,X,a),j=["children",X]):typeof X=="number"&&x.textContent!==""+X&&(A.suppressHydrationWarning!==!0&&jc(x.textContent,X,a),j=["children",""+X]):i.hasOwnProperty(B)&&X!=null&&B==="onScroll"&&Ut("scroll",x)}switch(h){case"input":ce(x),Ie(x,A,!0);break;case"textarea":ce(x),cn(x);break;case"select":case"option":break;default:typeof A.onClick=="function"&&(x.onclick=Sc)}x=j,l.updateQueue=x,x!==null&&(l.flags|=4)}else{B=j.nodeType===9?j:j.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=rn(h)),a==="http://www.w3.org/1999/xhtml"?h==="script"?(a=B.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof x.is=="string"?a=B.createElement(h,{is:x.is}):(a=B.createElement(h),h==="select"&&(B=a,x.multiple?B.multiple=!0:x.size&&(B.size=x.size))):a=B.createElementNS(a,h),a[Ar]=l,a[Xo]=x,qx(a,l,!1,!1),l.stateNode=a;e:{switch(B=Os(h,x),h){case"dialog":Ut("cancel",a),Ut("close",a),j=x;break;case"iframe":case"object":case"embed":Ut("load",a),j=x;break;case"video":case"audio":for(j=0;j<Go.length;j++)Ut(Go[j],a);j=x;break;case"source":Ut("error",a),j=x;break;case"img":case"image":case"link":Ut("error",a),Ut("load",a),j=x;break;case"details":Ut("toggle",a),j=x;break;case"input":ze(a,x),j=he(a,x),Ut("invalid",a);break;case"option":j=x;break;case"select":a._wrapperState={wasMultiple:!!x.multiple},j=K({},x,{value:void 0}),Ut("invalid",a);break;case"textarea":sn(a,x),j=On(a,x),Ut("invalid",a);break;default:j=x}Rs(h,j),X=j;for(A in X)if(X.hasOwnProperty(A)){var J=X[A];A==="style"?Ys(a,J):A==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,J!=null&&Bn(a,J)):A==="children"?typeof J=="string"?(h!=="textarea"||J!=="")&&wn(a,J):typeof J=="number"&&wn(a,""+J):A!=="suppressContentEditableWarning"&&A!=="suppressHydrationWarning"&&A!=="autoFocus"&&(i.hasOwnProperty(A)?J!=null&&A==="onScroll"&&Ut("scroll",a):J!=null&&N(a,A,J,B))}switch(h){case"input":ce(a),Ie(a,x,!1);break;case"textarea":ce(a),cn(a);break;case"option":x.value!=null&&a.setAttribute("value",""+ae(x.value));break;case"select":a.multiple=!!x.multiple,A=x.value,A!=null?jt(a,!!x.multiple,A,!1):x.defaultValue!=null&&jt(a,!!x.multiple,x.defaultValue,!0);break;default:typeof j.onClick=="function"&&(a.onclick=Sc)}switch(h){case"button":case"input":case"select":case"textarea":x=!!x.autoFocus;break e;case"img":x=!0;break e;default:x=!1}}x&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return qn(l),null;case 6:if(a&&l.stateNode!=null)Kx(a,l,a.memoizedProps,x);else{if(typeof x!="string"&&l.stateNode===null)throw Error(n(166));if(h=aa(nl.current),aa(Tr.current),Mc(l)){if(x=l.stateNode,h=l.memoizedProps,x[Ar]=l,(A=x.nodeValue!==h)&&(a=Ss,a!==null))switch(a.tag){case 3:jc(x.nodeValue,h,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&jc(x.nodeValue,h,(a.mode&1)!==0)}A&&(l.flags|=4)}else x=(h.nodeType===9?h:h.ownerDocument).createTextNode(x),x[Ar]=l,l.stateNode=x}return qn(l),null;case 13:if(Ht(Xt),x=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(qt&&_s!==null&&(l.mode&1)!==0&&(l.flags&128)===0)Qg(),Ya(),l.flags|=98560,A=!1;else if(A=Mc(l),x!==null&&x.dehydrated!==null){if(a===null){if(!A)throw Error(n(318));if(A=l.memoizedState,A=A!==null?A.dehydrated:null,!A)throw Error(n(317));A[Ar]=l}else Ya(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qn(l),A=!1}else ir!==null&&(Yf(ir),ir=null),A=!0;if(!A)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=h,l):(x=x!==null,x!==(a!==null&&a.memoizedState!==null)&&x&&(l.child.flags|=8192,(l.mode&1)!==0&&(a===null||(Xt.current&1)!==0?En===0&&(En=3):Jf())),l.updateQueue!==null&&(l.flags|=4),qn(l),null);case 4:return eo(),Df(a,l),a===null&&Ko(l.stateNode.containerInfo),qn(l),null;case 10:return hf(l.type._context),qn(l),null;case 17:return fs(l.type)&&Ec(),qn(l),null;case 19:if(Ht(Xt),A=l.memoizedState,A===null)return qn(l),null;if(x=(l.flags&128)!==0,B=A.rendering,B===null)if(x)ol(A,!1);else{if(En!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(B=Lc(a),B!==null){for(l.flags|=128,ol(A,!1),x=B.updateQueue,x!==null&&(l.updateQueue=x,l.flags|=4),l.subtreeFlags=0,x=h,h=l.child;h!==null;)A=h,a=x,A.flags&=14680066,B=A.alternate,B===null?(A.childLanes=0,A.lanes=a,A.child=null,A.subtreeFlags=0,A.memoizedProps=null,A.memoizedState=null,A.updateQueue=null,A.dependencies=null,A.stateNode=null):(A.childLanes=B.childLanes,A.lanes=B.lanes,A.child=B.child,A.subtreeFlags=0,A.deletions=null,A.memoizedProps=B.memoizedProps,A.memoizedState=B.memoizedState,A.updateQueue=B.updateQueue,A.type=B.type,a=B.dependencies,A.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),h=h.sibling;return Dt(Xt,Xt.current&1|2),l.child}a=a.sibling}A.tail!==null&&Ot()>ro&&(l.flags|=128,x=!0,ol(A,!1),l.lanes=4194304)}else{if(!x)if(a=Lc(B),a!==null){if(l.flags|=128,x=!0,h=a.updateQueue,h!==null&&(l.updateQueue=h,l.flags|=4),ol(A,!0),A.tail===null&&A.tailMode==="hidden"&&!B.alternate&&!qt)return qn(l),null}else 2*Ot()-A.renderingStartTime>ro&&h!==1073741824&&(l.flags|=128,x=!0,ol(A,!1),l.lanes=4194304);A.isBackwards?(B.sibling=l.child,l.child=B):(h=A.last,h!==null?h.sibling=B:l.child=B,A.last=B)}return A.tail!==null?(l=A.tail,A.rendering=l,A.tail=l.sibling,A.renderingStartTime=Ot(),l.sibling=null,h=Xt.current,Dt(Xt,x?h&1|2:h&1),l):(qn(l),null);case 22:case 23:return Qf(),x=l.memoizedState!==null,a!==null&&a.memoizedState!==null!==x&&(l.flags|=8192),x&&(l.mode&1)!==0?(Es&1073741824)!==0&&(qn(l),l.subtreeFlags&6&&(l.flags|=8192)):qn(l),null;case 24:return null;case 25:return null}throw Error(n(156,l.tag))}function S_(a,l){switch(of(l),l.tag){case 1:return fs(l.type)&&Ec(),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return eo(),Ht(ds),Ht(Vn),bf(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 5:return vf(l),null;case 13:if(Ht(Xt),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(n(340));Ya()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return Ht(Xt),null;case 4:return eo(),null;case 10:return hf(l.type._context),null;case 22:case 23:return Qf(),null;case 24:return null;default:return null}}var qc=!1,Gn=!1,__=typeof WeakSet=="function"?WeakSet:Set,Ve=null;function no(a,l){var h=a.ref;if(h!==null)if(typeof h=="function")try{h(null)}catch(x){on(a,l,x)}else h.current=null}function Ff(a,l,h){try{h()}catch(x){on(a,l,x)}}var Yx=!1;function E_(a,l){if(Xd=nt,a=Cg(),Hd(a)){if("selectionStart"in a)var h={start:a.selectionStart,end:a.selectionEnd};else e:{h=(h=a.ownerDocument)&&h.defaultView||window;var x=h.getSelection&&h.getSelection();if(x&&x.rangeCount!==0){h=x.anchorNode;var j=x.anchorOffset,A=x.focusNode;x=x.focusOffset;try{h.nodeType,A.nodeType}catch{h=null;break e}var B=0,X=-1,J=-1,de=0,_e=0,Ce=a,Se=null;t:for(;;){for(var He;Ce!==h||j!==0&&Ce.nodeType!==3||(X=B+j),Ce!==A||x!==0&&Ce.nodeType!==3||(J=B+x),Ce.nodeType===3&&(B+=Ce.nodeValue.length),(He=Ce.firstChild)!==null;)Se=Ce,Ce=He;for(;;){if(Ce===a)break t;if(Se===h&&++de===j&&(X=B),Se===A&&++_e===x&&(J=B),(He=Ce.nextSibling)!==null)break;Ce=Se,Se=Ce.parentNode}Ce=He}h=X===-1||J===-1?null:{start:X,end:J}}else h=null}h=h||{start:0,end:0}}else h=null;for(Qd={focusedElem:a,selectionRange:h},nt=!1,Ve=l;Ve!==null;)if(l=Ve,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,Ve=a;else for(;Ve!==null;){l=Ve;try{var We=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(We!==null){var Ke=We.memoizedProps,fn=We.memoizedState,oe=l.stateNode,ne=oe.getSnapshotBeforeUpdate(l.elementType===l.type?Ke:ar(l.type,Ke),fn);oe.__reactInternalSnapshotBeforeUpdate=ne}break;case 3:var le=l.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch($e){on(l,l.return,$e)}if(a=l.sibling,a!==null){a.return=l.return,Ve=a;break}Ve=l.return}return We=Yx,Yx=!1,We}function ll(a,l,h){var x=l.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var j=x=x.next;do{if((j.tag&a)===a){var A=j.destroy;j.destroy=void 0,A!==void 0&&Ff(l,h,A)}j=j.next}while(j!==x)}}function Gc(a,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var h=l=l.next;do{if((h.tag&a)===a){var x=h.create;h.destroy=x()}h=h.next}while(h!==l)}}function Bf(a){var l=a.ref;if(l!==null){var h=a.stateNode;switch(a.tag){case 5:a=h;break;default:a=h}typeof l=="function"?l(a):l.current=a}}function Xx(a){var l=a.alternate;l!==null&&(a.alternate=null,Xx(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&(delete l[Ar],delete l[Xo],delete l[nf],delete l[c_],delete l[u_])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function Qx(a){return a.tag===5||a.tag===3||a.tag===4}function Jx(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||Qx(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Uf(a,l,h){var x=a.tag;if(x===5||x===6)a=a.stateNode,l?h.nodeType===8?h.parentNode.insertBefore(a,l):h.insertBefore(a,l):(h.nodeType===8?(l=h.parentNode,l.insertBefore(a,h)):(l=h,l.appendChild(a)),h=h._reactRootContainer,h!=null||l.onclick!==null||(l.onclick=Sc));else if(x!==4&&(a=a.child,a!==null))for(Uf(a,l,h),a=a.sibling;a!==null;)Uf(a,l,h),a=a.sibling}function Hf(a,l,h){var x=a.tag;if(x===5||x===6)a=a.stateNode,l?h.insertBefore(a,l):h.appendChild(a);else if(x!==4&&(a=a.child,a!==null))for(Hf(a,l,h),a=a.sibling;a!==null;)Hf(a,l,h),a=a.sibling}var zn=null,or=!1;function _i(a,l,h){for(h=h.child;h!==null;)ev(a,l,h),h=h.sibling}function ev(a,l,h){if(ft&&typeof ft.onCommitFiberUnmount=="function")try{ft.onCommitFiberUnmount(ct,h)}catch{}switch(h.tag){case 5:Gn||no(h,l);case 6:var x=zn,j=or;zn=null,_i(a,l,h),zn=x,or=j,zn!==null&&(or?(a=zn,h=h.stateNode,a.nodeType===8?a.parentNode.removeChild(h):a.removeChild(h)):zn.removeChild(h.stateNode));break;case 18:zn!==null&&(or?(a=zn,h=h.stateNode,a.nodeType===8?tf(a.parentNode,h):a.nodeType===1&&tf(a,h),ye(a)):tf(zn,h.stateNode));break;case 4:x=zn,j=or,zn=h.stateNode.containerInfo,or=!0,_i(a,l,h),zn=x,or=j;break;case 0:case 11:case 14:case 15:if(!Gn&&(x=h.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){j=x=x.next;do{var A=j,B=A.destroy;A=A.tag,B!==void 0&&((A&2)!==0||(A&4)!==0)&&Ff(h,l,B),j=j.next}while(j!==x)}_i(a,l,h);break;case 1:if(!Gn&&(no(h,l),x=h.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=h.memoizedProps,x.state=h.memoizedState,x.componentWillUnmount()}catch(X){on(h,l,X)}_i(a,l,h);break;case 21:_i(a,l,h);break;case 22:h.mode&1?(Gn=(x=Gn)||h.memoizedState!==null,_i(a,l,h),Gn=x):_i(a,l,h);break;default:_i(a,l,h)}}function tv(a){var l=a.updateQueue;if(l!==null){a.updateQueue=null;var h=a.stateNode;h===null&&(h=a.stateNode=new __),l.forEach(function(x){var j=z_.bind(null,a,x);h.has(x)||(h.add(x),x.then(j,j))})}}function lr(a,l){var h=l.deletions;if(h!==null)for(var x=0;x<h.length;x++){var j=h[x];try{var A=a,B=l,X=B;e:for(;X!==null;){switch(X.tag){case 5:zn=X.stateNode,or=!1;break e;case 3:zn=X.stateNode.containerInfo,or=!0;break e;case 4:zn=X.stateNode.containerInfo,or=!0;break e}X=X.return}if(zn===null)throw Error(n(160));ev(A,B,j),zn=null,or=!1;var J=j.alternate;J!==null&&(J.return=null),j.return=null}catch(de){on(j,l,de)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)nv(l,a),l=l.sibling}function nv(a,l){var h=a.alternate,x=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(lr(l,a),$r(a),x&4){try{ll(3,a,a.return),Gc(3,a)}catch(Ke){on(a,a.return,Ke)}try{ll(5,a,a.return)}catch(Ke){on(a,a.return,Ke)}}break;case 1:lr(l,a),$r(a),x&512&&h!==null&&no(h,h.return);break;case 5:if(lr(l,a),$r(a),x&512&&h!==null&&no(h,h.return),a.flags&32){var j=a.stateNode;try{wn(j,"")}catch(Ke){on(a,a.return,Ke)}}if(x&4&&(j=a.stateNode,j!=null)){var A=a.memoizedProps,B=h!==null?h.memoizedProps:A,X=a.type,J=a.updateQueue;if(a.updateQueue=null,J!==null)try{X==="input"&&A.type==="radio"&&A.name!=null&&Te(j,A),Os(X,B);var de=Os(X,A);for(B=0;B<J.length;B+=2){var _e=J[B],Ce=J[B+1];_e==="style"?Ys(j,Ce):_e==="dangerouslySetInnerHTML"?Bn(j,Ce):_e==="children"?wn(j,Ce):N(j,_e,Ce,de)}switch(X){case"input":Ge(j,A);break;case"textarea":ln(j,A);break;case"select":var Se=j._wrapperState.wasMultiple;j._wrapperState.wasMultiple=!!A.multiple;var He=A.value;He!=null?jt(j,!!A.multiple,He,!1):Se!==!!A.multiple&&(A.defaultValue!=null?jt(j,!!A.multiple,A.defaultValue,!0):jt(j,!!A.multiple,A.multiple?[]:"",!1))}j[Xo]=A}catch(Ke){on(a,a.return,Ke)}}break;case 6:if(lr(l,a),$r(a),x&4){if(a.stateNode===null)throw Error(n(162));j=a.stateNode,A=a.memoizedProps;try{j.nodeValue=A}catch(Ke){on(a,a.return,Ke)}}break;case 3:if(lr(l,a),$r(a),x&4&&h!==null&&h.memoizedState.isDehydrated)try{ye(l.containerInfo)}catch(Ke){on(a,a.return,Ke)}break;case 4:lr(l,a),$r(a);break;case 13:lr(l,a),$r(a),j=a.child,j.flags&8192&&(A=j.memoizedState!==null,j.stateNode.isHidden=A,!A||j.alternate!==null&&j.alternate.memoizedState!==null||(Wf=Ot())),x&4&&tv(a);break;case 22:if(_e=h!==null&&h.memoizedState!==null,a.mode&1?(Gn=(de=Gn)||_e,lr(l,a),Gn=de):lr(l,a),$r(a),x&8192){if(de=a.memoizedState!==null,(a.stateNode.isHidden=de)&&!_e&&(a.mode&1)!==0)for(Ve=a,_e=a.child;_e!==null;){for(Ce=Ve=_e;Ve!==null;){switch(Se=Ve,He=Se.child,Se.tag){case 0:case 11:case 14:case 15:ll(4,Se,Se.return);break;case 1:no(Se,Se.return);var We=Se.stateNode;if(typeof We.componentWillUnmount=="function"){x=Se,h=Se.return;try{l=x,We.props=l.memoizedProps,We.state=l.memoizedState,We.componentWillUnmount()}catch(Ke){on(x,h,Ke)}}break;case 5:no(Se,Se.return);break;case 22:if(Se.memoizedState!==null){iv(Ce);continue}}He!==null?(He.return=Se,Ve=He):iv(Ce)}_e=_e.sibling}e:for(_e=null,Ce=a;;){if(Ce.tag===5){if(_e===null){_e=Ce;try{j=Ce.stateNode,de?(A=j.style,typeof A.setProperty=="function"?A.setProperty("display","none","important"):A.display="none"):(X=Ce.stateNode,J=Ce.memoizedProps.style,B=J!=null&&J.hasOwnProperty("display")?J.display:null,X.style.display=Ks("display",B))}catch(Ke){on(a,a.return,Ke)}}}else if(Ce.tag===6){if(_e===null)try{Ce.stateNode.nodeValue=de?"":Ce.memoizedProps}catch(Ke){on(a,a.return,Ke)}}else if((Ce.tag!==22&&Ce.tag!==23||Ce.memoizedState===null||Ce===a)&&Ce.child!==null){Ce.child.return=Ce,Ce=Ce.child;continue}if(Ce===a)break e;for(;Ce.sibling===null;){if(Ce.return===null||Ce.return===a)break e;_e===Ce&&(_e=null),Ce=Ce.return}_e===Ce&&(_e=null),Ce.sibling.return=Ce.return,Ce=Ce.sibling}}break;case 19:lr(l,a),$r(a),x&4&&tv(a);break;case 21:break;default:lr(l,a),$r(a)}}function $r(a){var l=a.flags;if(l&2){try{e:{for(var h=a.return;h!==null;){if(Qx(h)){var x=h;break e}h=h.return}throw Error(n(160))}switch(x.tag){case 5:var j=x.stateNode;x.flags&32&&(wn(j,""),x.flags&=-33);var A=Jx(a);Hf(a,A,j);break;case 3:case 4:var B=x.stateNode.containerInfo,X=Jx(a);Uf(a,X,B);break;default:throw Error(n(161))}}catch(J){on(a,a.return,J)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function C_(a,l,h){Ve=a,sv(a)}function sv(a,l,h){for(var x=(a.mode&1)!==0;Ve!==null;){var j=Ve,A=j.child;if(j.tag===22&&x){var B=j.memoizedState!==null||qc;if(!B){var X=j.alternate,J=X!==null&&X.memoizedState!==null||Gn;X=qc;var de=Gn;if(qc=B,(Gn=J)&&!de)for(Ve=j;Ve!==null;)B=Ve,J=B.child,B.tag===22&&B.memoizedState!==null?av(j):J!==null?(J.return=B,Ve=J):av(j);for(;A!==null;)Ve=A,sv(A),A=A.sibling;Ve=j,qc=X,Gn=de}rv(a)}else(j.subtreeFlags&8772)!==0&&A!==null?(A.return=j,Ve=A):rv(a)}}function rv(a){for(;Ve!==null;){var l=Ve;if((l.flags&8772)!==0){var h=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Gn||Gc(5,l);break;case 1:var x=l.stateNode;if(l.flags&4&&!Gn)if(h===null)x.componentDidMount();else{var j=l.elementType===l.type?h.memoizedProps:ar(l.type,h.memoizedProps);x.componentDidUpdate(j,h.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var A=l.updateQueue;A!==null&&ix(l,A,x);break;case 3:var B=l.updateQueue;if(B!==null){if(h=null,l.child!==null)switch(l.child.tag){case 5:h=l.child.stateNode;break;case 1:h=l.child.stateNode}ix(l,B,h)}break;case 5:var X=l.stateNode;if(h===null&&l.flags&4){h=X;var J=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":J.autoFocus&&h.focus();break;case"img":J.src&&(h.src=J.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var de=l.alternate;if(de!==null){var _e=de.memoizedState;if(_e!==null){var Ce=_e.dehydrated;Ce!==null&&ye(Ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Gn||l.flags&512&&Bf(l)}catch(Se){on(l,l.return,Se)}}if(l===a){Ve=null;break}if(h=l.sibling,h!==null){h.return=l.return,Ve=h;break}Ve=l.return}}function iv(a){for(;Ve!==null;){var l=Ve;if(l===a){Ve=null;break}var h=l.sibling;if(h!==null){h.return=l.return,Ve=h;break}Ve=l.return}}function av(a){for(;Ve!==null;){var l=Ve;try{switch(l.tag){case 0:case 11:case 15:var h=l.return;try{Gc(4,l)}catch(J){on(l,h,J)}break;case 1:var x=l.stateNode;if(typeof x.componentDidMount=="function"){var j=l.return;try{x.componentDidMount()}catch(J){on(l,j,J)}}var A=l.return;try{Bf(l)}catch(J){on(l,A,J)}break;case 5:var B=l.return;try{Bf(l)}catch(J){on(l,B,J)}}}catch(J){on(l,l.return,J)}if(l===a){Ve=null;break}var X=l.sibling;if(X!==null){X.return=l.return,Ve=X;break}Ve=l.return}}var I_=Math.ceil,Kc=$.ReactCurrentDispatcher,Zf=$.ReactCurrentOwner,Vs=$.ReactCurrentBatchConfig,kt=0,Tn=null,gn=null,Pn=0,Es=0,so=ki(0),En=0,cl=null,la=0,Yc=0,Vf=0,ul=null,ps=null,Wf=0,ro=1/0,ti=null,Xc=!1,qf=null,Ei=null,Qc=!1,Ci=null,Jc=0,dl=0,Gf=null,eu=-1,tu=0;function ts(){return(kt&6)!==0?Ot():eu!==-1?eu:eu=Ot()}function Ii(a){return(a.mode&1)===0?1:(kt&2)!==0&&Pn!==0?Pn&-Pn:f_.transition!==null?(tu===0&&(tu=vi()),tu):(a=vt,a!==0||(a=window.event,a=a===void 0?16:qr(a.type)),a)}function cr(a,l,h,x){if(50<dl)throw dl=0,Gf=null,Error(n(185));ls(a,h,x),((kt&2)===0||a!==Tn)&&(a===Tn&&((kt&2)===0&&(Yc|=h),En===4&&Ai(a,Pn)),ms(a,x),h===1&&kt===0&&(l.mode&1)===0&&(ro=Ot()+500,Ic&&Ni()))}function ms(a,l){var h=a.callbackNode;xi(a,l);var x=os(a,a===Tn?Pn:0);if(x===0)h!==null&&Xn(h),a.callbackNode=null,a.callbackPriority=0;else if(l=x&-x,a.callbackPriority!==l){if(h!=null&&Xn(h),l===1)a.tag===0?d_(lv.bind(null,a)):qg(lv.bind(null,a)),o_(function(){(kt&6)===0&&Ni()}),h=null;else{switch(at(x)){case 1:h=Hr;break;case 4:h=nr;break;case 16:h=Cr;break;case 536870912:h=Ze;break;default:h=Cr}h=gv(h,ov.bind(null,a))}a.callbackPriority=l,a.callbackNode=h}}function ov(a,l){if(eu=-1,tu=0,(kt&6)!==0)throw Error(n(327));var h=a.callbackNode;if(io()&&a.callbackNode!==h)return null;var x=os(a,a===Tn?Pn:0);if(x===0)return null;if((x&30)!==0||(x&a.expiredLanes)!==0||l)l=nu(a,x);else{l=x;var j=kt;kt|=2;var A=uv();(Tn!==a||Pn!==l)&&(ti=null,ro=Ot()+500,ua(a,l));do try{M_();break}catch(X){cv(a,X)}while(!0);ff(),Kc.current=A,kt=j,gn!==null?l=0:(Tn=null,Pn=0,l=En)}if(l!==0){if(l===2&&(j=Ir(a),j!==0&&(x=j,l=Kf(a,j))),l===1)throw h=cl,ua(a,0),Ai(a,x),ms(a,Ot()),h;if(l===6)Ai(a,x);else{if(j=a.current.alternate,(x&30)===0&&!A_(j)&&(l=nu(a,x),l===2&&(A=Ir(a),A!==0&&(x=A,l=Kf(a,A))),l===1))throw h=cl,ua(a,0),Ai(a,x),ms(a,Ot()),h;switch(a.finishedWork=j,a.finishedLanes=x,l){case 0:case 1:throw Error(n(345));case 2:da(a,ps,ti);break;case 3:if(Ai(a,x),(x&130023424)===x&&(l=Wf+500-Ot(),10<l)){if(os(a,0)!==0)break;if(j=a.suspendedLanes,(j&x)!==x){ts(),a.pingedLanes|=a.suspendedLanes&j;break}a.timeoutHandle=ef(da.bind(null,a,ps,ti),l);break}da(a,ps,ti);break;case 4:if(Ai(a,x),(x&4194240)===x)break;for(l=a.eventTimes,j=-1;0<x;){var B=31-zt(x);A=1<<B,B=l[B],B>j&&(j=B),x&=~A}if(x=j,x=Ot()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*I_(x/1960))-x,10<x){a.timeoutHandle=ef(da.bind(null,a,ps,ti),x);break}da(a,ps,ti);break;case 5:da(a,ps,ti);break;default:throw Error(n(329))}}}return ms(a,Ot()),a.callbackNode===h?ov.bind(null,a):null}function Kf(a,l){var h=ul;return a.current.memoizedState.isDehydrated&&(ua(a,l).flags|=256),a=nu(a,l),a!==2&&(l=ps,ps=h,l!==null&&Yf(l)),a}function Yf(a){ps===null?ps=a:ps.push.apply(ps,a)}function A_(a){for(var l=a;;){if(l.flags&16384){var h=l.updateQueue;if(h!==null&&(h=h.stores,h!==null))for(var x=0;x<h.length;x++){var j=h[x],A=j.getSnapshot;j=j.value;try{if(!rr(A(),j))return!1}catch{return!1}}}if(h=l.child,l.subtreeFlags&16384&&h!==null)h.return=l,l=h;else{if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Ai(a,l){for(l&=~Vf,l&=~Yc,a.suspendedLanes|=l,a.pingedLanes&=~l,a=a.expirationTimes;0<l;){var h=31-zt(l),x=1<<h;a[h]=-1,l&=~x}}function lv(a){if((kt&6)!==0)throw Error(n(327));io();var l=os(a,0);if((l&1)===0)return ms(a,Ot()),null;var h=nu(a,l);if(a.tag!==0&&h===2){var x=Ir(a);x!==0&&(l=x,h=Kf(a,x))}if(h===1)throw h=cl,ua(a,0),Ai(a,l),ms(a,Ot()),h;if(h===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=l,da(a,ps,ti),ms(a,Ot()),null}function Xf(a,l){var h=kt;kt|=1;try{return a(l)}finally{kt=h,kt===0&&(ro=Ot()+500,Ic&&Ni())}}function ca(a){Ci!==null&&Ci.tag===0&&(kt&6)===0&&io();var l=kt;kt|=1;var h=Vs.transition,x=vt;try{if(Vs.transition=null,vt=1,a)return a()}finally{vt=x,Vs.transition=h,kt=l,(kt&6)===0&&Ni()}}function Qf(){Es=so.current,Ht(so)}function ua(a,l){a.finishedWork=null,a.finishedLanes=0;var h=a.timeoutHandle;if(h!==-1&&(a.timeoutHandle=-1,a_(h)),gn!==null)for(h=gn.return;h!==null;){var x=h;switch(of(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&Ec();break;case 3:eo(),Ht(ds),Ht(Vn),bf();break;case 5:vf(x);break;case 4:eo();break;case 13:Ht(Xt);break;case 19:Ht(Xt);break;case 10:hf(x.type._context);break;case 22:case 23:Qf()}h=h.return}if(Tn=a,gn=a=Ti(a.current,null),Pn=Es=l,En=0,cl=null,Vf=Yc=la=0,ps=ul=null,ia!==null){for(l=0;l<ia.length;l++)if(h=ia[l],x=h.interleaved,x!==null){h.interleaved=null;var j=x.next,A=h.pending;if(A!==null){var B=A.next;A.next=j,x.next=B}h.pending=x}ia=null}return a}function cv(a,l){do{var h=gn;try{if(ff(),Dc.current=Hc,Fc){for(var x=Qt.memoizedState;x!==null;){var j=x.queue;j!==null&&(j.pending=null),x=x.next}Fc=!1}if(oa=0,An=_n=Qt=null,sl=!1,rl=0,Zf.current=null,h===null||h.return===null){En=1,cl=l,gn=null;break}e:{var A=a,B=h.return,X=h,J=l;if(l=Pn,X.flags|=32768,J!==null&&typeof J=="object"&&typeof J.then=="function"){var de=J,_e=X,Ce=_e.tag;if((_e.mode&1)===0&&(Ce===0||Ce===11||Ce===15)){var Se=_e.alternate;Se?(_e.updateQueue=Se.updateQueue,_e.memoizedState=Se.memoizedState,_e.lanes=Se.lanes):(_e.updateQueue=null,_e.memoizedState=null)}var He=Rx(B);if(He!==null){He.flags&=-257,Ox(He,B,X,A,l),He.mode&1&&$x(A,de,l),l=He,J=de;var We=l.updateQueue;if(We===null){var Ke=new Set;Ke.add(J),l.updateQueue=Ke}else We.add(J);break e}else{if((l&1)===0){$x(A,de,l),Jf();break e}J=Error(n(426))}}else if(qt&&X.mode&1){var fn=Rx(B);if(fn!==null){(fn.flags&65536)===0&&(fn.flags|=256),Ox(fn,B,X,A,l),uf(to(J,X));break e}}A=J=to(J,X),En!==4&&(En=2),ul===null?ul=[A]:ul.push(A),A=B;do{switch(A.tag){case 3:A.flags|=65536,l&=-l,A.lanes|=l;var oe=Tx(A,J,l);rx(A,oe);break e;case 1:X=J;var ne=A.type,le=A.stateNode;if((A.flags&128)===0&&(typeof ne.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(Ei===null||!Ei.has(le)))){A.flags|=65536,l&=-l,A.lanes|=l;var $e=Mx(A,X,l);rx(A,$e);break e}}A=A.return}while(A!==null)}fv(h)}catch(Ye){l=Ye,gn===h&&h!==null&&(gn=h=h.return);continue}break}while(!0)}function uv(){var a=Kc.current;return Kc.current=Hc,a===null?Hc:a}function Jf(){(En===0||En===3||En===2)&&(En=4),Tn===null||(la&268435455)===0&&(Yc&268435455)===0||Ai(Tn,Pn)}function nu(a,l){var h=kt;kt|=2;var x=uv();(Tn!==a||Pn!==l)&&(ti=null,ua(a,l));do try{T_();break}catch(j){cv(a,j)}while(!0);if(ff(),kt=h,Kc.current=x,gn!==null)throw Error(n(261));return Tn=null,Pn=0,En}function T_(){for(;gn!==null;)dv(gn)}function M_(){for(;gn!==null&&!Ur();)dv(gn)}function dv(a){var l=mv(a.alternate,a,Es);a.memoizedProps=a.pendingProps,l===null?fv(a):gn=l,Zf.current=null}function fv(a){var l=a;do{var h=l.alternate;if(a=l.return,(l.flags&32768)===0){if(h=j_(h,l,Es),h!==null){gn=h;return}}else{if(h=S_(h,l),h!==null){h.flags&=32767,gn=h;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{En=6,gn=null;return}}if(l=l.sibling,l!==null){gn=l;return}gn=l=a}while(l!==null);En===0&&(En=5)}function da(a,l,h){var x=vt,j=Vs.transition;try{Vs.transition=null,vt=1,$_(a,l,h,x)}finally{Vs.transition=j,vt=x}return null}function $_(a,l,h,x){do io();while(Ci!==null);if((kt&6)!==0)throw Error(n(327));h=a.finishedWork;var j=a.finishedLanes;if(h===null)return null;if(a.finishedWork=null,a.finishedLanes=0,h===a.current)throw Error(n(177));a.callbackNode=null,a.callbackPriority=0;var A=h.lanes|h.childLanes;if(Sn(a,A),a===Tn&&(gn=Tn=null,Pn=0),(h.subtreeFlags&2064)===0&&(h.flags&2064)===0||Qc||(Qc=!0,gv(Cr,function(){return io(),null})),A=(h.flags&15990)!==0,(h.subtreeFlags&15990)!==0||A){A=Vs.transition,Vs.transition=null;var B=vt;vt=1;var X=kt;kt|=4,Zf.current=null,E_(a,h),nv(h,a),JS(Qd),nt=!!Xd,Qd=Xd=null,a.current=h,C_(h),tr(),kt=X,vt=B,Vs.transition=A}else a.current=h;if(Qc&&(Qc=!1,Ci=a,Jc=j),A=a.pendingLanes,A===0&&(Ei=null),At(h.stateNode),ms(a,Ot()),l!==null)for(x=a.onRecoverableError,h=0;h<l.length;h++)j=l[h],x(j.value,{componentStack:j.stack,digest:j.digest});if(Xc)throw Xc=!1,a=qf,qf=null,a;return(Jc&1)!==0&&a.tag!==0&&io(),A=a.pendingLanes,(A&1)!==0?a===Gf?dl++:(dl=0,Gf=a):dl=0,Ni(),null}function io(){if(Ci!==null){var a=at(Jc),l=Vs.transition,h=vt;try{if(Vs.transition=null,vt=16>a?16:a,Ci===null)var x=!1;else{if(a=Ci,Ci=null,Jc=0,(kt&6)!==0)throw Error(n(331));var j=kt;for(kt|=4,Ve=a.current;Ve!==null;){var A=Ve,B=A.child;if((Ve.flags&16)!==0){var X=A.deletions;if(X!==null){for(var J=0;J<X.length;J++){var de=X[J];for(Ve=de;Ve!==null;){var _e=Ve;switch(_e.tag){case 0:case 11:case 15:ll(8,_e,A)}var Ce=_e.child;if(Ce!==null)Ce.return=_e,Ve=Ce;else for(;Ve!==null;){_e=Ve;var Se=_e.sibling,He=_e.return;if(Xx(_e),_e===de){Ve=null;break}if(Se!==null){Se.return=He,Ve=Se;break}Ve=He}}}var We=A.alternate;if(We!==null){var Ke=We.child;if(Ke!==null){We.child=null;do{var fn=Ke.sibling;Ke.sibling=null,Ke=fn}while(Ke!==null)}}Ve=A}}if((A.subtreeFlags&2064)!==0&&B!==null)B.return=A,Ve=B;else e:for(;Ve!==null;){if(A=Ve,(A.flags&2048)!==0)switch(A.tag){case 0:case 11:case 15:ll(9,A,A.return)}var oe=A.sibling;if(oe!==null){oe.return=A.return,Ve=oe;break e}Ve=A.return}}var ne=a.current;for(Ve=ne;Ve!==null;){B=Ve;var le=B.child;if((B.subtreeFlags&2064)!==0&&le!==null)le.return=B,Ve=le;else e:for(B=ne;Ve!==null;){if(X=Ve,(X.flags&2048)!==0)try{switch(X.tag){case 0:case 11:case 15:Gc(9,X)}}catch(Ye){on(X,X.return,Ye)}if(X===B){Ve=null;break e}var $e=X.sibling;if($e!==null){$e.return=X.return,Ve=$e;break e}Ve=X.return}}if(kt=j,Ni(),ft&&typeof ft.onPostCommitFiberRoot=="function")try{ft.onPostCommitFiberRoot(ct,a)}catch{}x=!0}return x}finally{vt=h,Vs.transition=l}}return!1}function hv(a,l,h){l=to(h,l),l=Tx(a,l,1),a=Si(a,l,1),l=ts(),a!==null&&(ls(a,1,l),ms(a,l))}function on(a,l,h){if(a.tag===3)hv(a,a,h);else for(;l!==null;){if(l.tag===3){hv(l,a,h);break}else if(l.tag===1){var x=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(Ei===null||!Ei.has(x))){a=to(h,a),a=Mx(l,a,1),l=Si(l,a,1),a=ts(),l!==null&&(ls(l,1,a),ms(l,a));break}}l=l.return}}function R_(a,l,h){var x=a.pingCache;x!==null&&x.delete(l),l=ts(),a.pingedLanes|=a.suspendedLanes&h,Tn===a&&(Pn&h)===h&&(En===4||En===3&&(Pn&130023424)===Pn&&500>Ot()-Wf?ua(a,0):Vf|=h),ms(a,l)}function pv(a,l){l===0&&((a.mode&1)===0?l=1:(l=Ls,Ls<<=1,(Ls&130023424)===0&&(Ls=4194304)));var h=ts();a=Qr(a,l),a!==null&&(ls(a,l,h),ms(a,h))}function O_(a){var l=a.memoizedState,h=0;l!==null&&(h=l.retryLane),pv(a,h)}function z_(a,l){var h=0;switch(a.tag){case 13:var x=a.stateNode,j=a.memoizedState;j!==null&&(h=j.retryLane);break;case 19:x=a.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(l),pv(a,h)}var mv;mv=function(a,l,h){if(a!==null)if(a.memoizedProps!==l.pendingProps||ds.current)hs=!0;else{if((a.lanes&h)===0&&(l.flags&128)===0)return hs=!1,N_(a,l,h);hs=(a.flags&131072)!==0}else hs=!1,qt&&(l.flags&1048576)!==0&&Gg(l,Tc,l.index);switch(l.lanes=0,l.tag){case 2:var x=l.type;Wc(a,l),a=l.pendingProps;var j=qa(l,Vn.current);Ja(l,h),j=Nf(null,l,x,a,j,h);var A=jf();return l.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,fs(x)?(A=!0,Cc(l)):A=!1,l.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,gf(l),j.updater=Zc,l.stateNode=j,j._reactInternals=l,Af(l,x,a,h),l=Rf(null,l,x,!0,A,h)):(l.tag=0,qt&&A&&af(l),es(null,l,j,h),l=l.child),l;case 16:x=l.elementType;e:{switch(Wc(a,l),a=l.pendingProps,j=x._init,x=j(x._payload),l.type=x,j=l.tag=L_(x),a=ar(x,a),j){case 0:l=$f(null,l,x,a,h);break e;case 1:l=Bx(null,l,x,a,h);break e;case 11:l=zx(null,l,x,a,h);break e;case 14:l=Px(null,l,x,ar(x.type,a),h);break e}throw Error(n(306,x,""))}return l;case 0:return x=l.type,j=l.pendingProps,j=l.elementType===x?j:ar(x,j),$f(a,l,x,j,h);case 1:return x=l.type,j=l.pendingProps,j=l.elementType===x?j:ar(x,j),Bx(a,l,x,j,h);case 3:e:{if(Ux(l),a===null)throw Error(n(387));x=l.pendingProps,A=l.memoizedState,j=A.element,sx(a,l),Pc(l,x,null,h);var B=l.memoizedState;if(x=B.element,A.isDehydrated)if(A={element:x,isDehydrated:!1,cache:B.cache,pendingSuspenseBoundaries:B.pendingSuspenseBoundaries,transitions:B.transitions},l.updateQueue.baseState=A,l.memoizedState=A,l.flags&256){j=to(Error(n(423)),l),l=Hx(a,l,x,h,j);break e}else if(x!==j){j=to(Error(n(424)),l),l=Hx(a,l,x,h,j);break e}else for(_s=bi(l.stateNode.containerInfo.firstChild),Ss=l,qt=!0,ir=null,h=tx(l,null,x,h),l.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling;else{if(Ya(),x===j){l=ei(a,l,h);break e}es(a,l,x,h)}l=l.child}return l;case 5:return ax(l),a===null&&cf(l),x=l.type,j=l.pendingProps,A=a!==null?a.memoizedProps:null,B=j.children,Jd(x,j)?B=null:A!==null&&Jd(x,A)&&(l.flags|=32),Fx(a,l),es(a,l,B,h),l.child;case 6:return a===null&&cf(l),null;case 13:return Zx(a,l,h);case 4:return xf(l,l.stateNode.containerInfo),x=l.pendingProps,a===null?l.child=Xa(l,null,x,h):es(a,l,x,h),l.child;case 11:return x=l.type,j=l.pendingProps,j=l.elementType===x?j:ar(x,j),zx(a,l,x,j,h);case 7:return es(a,l,l.pendingProps,h),l.child;case 8:return es(a,l,l.pendingProps.children,h),l.child;case 12:return es(a,l,l.pendingProps.children,h),l.child;case 10:e:{if(x=l.type._context,j=l.pendingProps,A=l.memoizedProps,B=j.value,Dt(Rc,x._currentValue),x._currentValue=B,A!==null)if(rr(A.value,B)){if(A.children===j.children&&!ds.current){l=ei(a,l,h);break e}}else for(A=l.child,A!==null&&(A.return=l);A!==null;){var X=A.dependencies;if(X!==null){B=A.child;for(var J=X.firstContext;J!==null;){if(J.context===x){if(A.tag===1){J=Jr(-1,h&-h),J.tag=2;var de=A.updateQueue;if(de!==null){de=de.shared;var _e=de.pending;_e===null?J.next=J:(J.next=_e.next,_e.next=J),de.pending=J}}A.lanes|=h,J=A.alternate,J!==null&&(J.lanes|=h),pf(A.return,h,l),X.lanes|=h;break}J=J.next}}else if(A.tag===10)B=A.type===l.type?null:A.child;else if(A.tag===18){if(B=A.return,B===null)throw Error(n(341));B.lanes|=h,X=B.alternate,X!==null&&(X.lanes|=h),pf(B,h,l),B=A.sibling}else B=A.child;if(B!==null)B.return=A;else for(B=A;B!==null;){if(B===l){B=null;break}if(A=B.sibling,A!==null){A.return=B.return,B=A;break}B=B.return}A=B}es(a,l,j.children,h),l=l.child}return l;case 9:return j=l.type,x=l.pendingProps.children,Ja(l,h),j=Hs(j),x=x(j),l.flags|=1,es(a,l,x,h),l.child;case 14:return x=l.type,j=ar(x,l.pendingProps),j=ar(x.type,j),Px(a,l,x,j,h);case 15:return Lx(a,l,l.type,l.pendingProps,h);case 17:return x=l.type,j=l.pendingProps,j=l.elementType===x?j:ar(x,j),Wc(a,l),l.tag=1,fs(x)?(a=!0,Cc(l)):a=!1,Ja(l,h),Ix(l,x,j),Af(l,x,j,h),Rf(null,l,x,!0,a,h);case 19:return Wx(a,l,h);case 22:return Dx(a,l,h)}throw Error(n(156,l.tag))};function gv(a,l){return Ns(a,l)}function P_(a,l,h,x){this.tag=a,this.key=h,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ws(a,l,h,x){return new P_(a,l,h,x)}function eh(a){return a=a.prototype,!(!a||!a.isReactComponent)}function L_(a){if(typeof a=="function")return eh(a)?1:0;if(a!=null){if(a=a.$$typeof,a===Z)return 11;if(a===I)return 14}return 2}function Ti(a,l){var h=a.alternate;return h===null?(h=Ws(a.tag,l,a.key,a.mode),h.elementType=a.elementType,h.type=a.type,h.stateNode=a.stateNode,h.alternate=a,a.alternate=h):(h.pendingProps=l,h.type=a.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=a.flags&14680064,h.childLanes=a.childLanes,h.lanes=a.lanes,h.child=a.child,h.memoizedProps=a.memoizedProps,h.memoizedState=a.memoizedState,h.updateQueue=a.updateQueue,l=a.dependencies,h.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},h.sibling=a.sibling,h.index=a.index,h.ref=a.ref,h}function su(a,l,h,x,j,A){var B=2;if(x=a,typeof a=="function")eh(a)&&(B=1);else if(typeof a=="string")B=5;else e:switch(a){case F:return fa(h.children,j,A,l);case U:B=8,j|=8;break;case M:return a=Ws(12,h,l,j|2),a.elementType=M,a.lanes=A,a;case E:return a=Ws(13,h,l,j),a.elementType=E,a.lanes=A,a;case C:return a=Ws(19,h,l,j),a.elementType=C,a.lanes=A,a;case W:return ru(h,j,A,l);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case P:B=10;break e;case R:B=9;break e;case Z:B=11;break e;case I:B=14;break e;case L:B=16,x=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return l=Ws(B,h,l,j),l.elementType=a,l.type=x,l.lanes=A,l}function fa(a,l,h,x){return a=Ws(7,a,x,l),a.lanes=h,a}function ru(a,l,h,x){return a=Ws(22,a,x,l),a.elementType=W,a.lanes=h,a.stateNode={isHidden:!1},a}function th(a,l,h){return a=Ws(6,a,null,l),a.lanes=h,a}function nh(a,l,h){return l=Ws(4,a.children!==null?a.children:[],a.key,l),l.lanes=h,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}function D_(a,l,h,x,j){this.tag=l,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Qn(0),this.expirationTimes=Qn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qn(0),this.identifierPrefix=x,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function sh(a,l,h,x,j,A,B,X,J){return a=new D_(a,l,h,X,J),l===1?(l=1,A===!0&&(l|=8)):l=0,A=Ws(3,null,null,l),a.current=A,A.stateNode=a,A.memoizedState={element:x,isDehydrated:h,cache:null,transitions:null,pendingSuspenseBoundaries:null},gf(A),a}function F_(a,l,h){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:x==null?null:""+x,children:a,containerInfo:l,implementation:h}}function xv(a){if(!a)return wi;a=a._reactInternals;e:{if(Hn(a)!==a||a.tag!==1)throw Error(n(170));var l=a;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(fs(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(n(171))}if(a.tag===1){var h=a.type;if(fs(h))return Vg(a,h,l)}return l}function vv(a,l,h,x,j,A,B,X,J){return a=sh(h,x,!0,a,j,A,B,X,J),a.context=xv(null),h=a.current,x=ts(),j=Ii(h),A=Jr(x,j),A.callback=l??null,Si(h,A,j),a.current.lanes=j,ls(a,j,x),ms(a,x),a}function iu(a,l,h,x){var j=l.current,A=ts(),B=Ii(j);return h=xv(h),l.context===null?l.context=h:l.pendingContext=h,l=Jr(A,B),l.payload={element:a},x=x===void 0?null:x,x!==null&&(l.callback=x),a=Si(j,l,B),a!==null&&(cr(a,j,B,A),zc(a,j,B)),B}function au(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function yv(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var h=a.retryLane;a.retryLane=h!==0&&h<l?h:l}}function rh(a,l){yv(a,l),(a=a.alternate)&&yv(a,l)}function B_(){return null}var bv=typeof reportError=="function"?reportError:function(a){console.error(a)};function ih(a){this._internalRoot=a}ou.prototype.render=ih.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(n(409));iu(a,l,null,null)},ou.prototype.unmount=ih.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;ca(function(){iu(null,a,null,null)}),l[Gr]=null}};function ou(a){this._internalRoot=a}ou.prototype.unstable_scheduleHydration=function(a){if(a){var l=Zr();a={blockedOn:null,target:a,priority:l};for(var h=0;h<pn.length&&l!==0&&l<pn[h].priority;h++);pn.splice(h,0,a),h===0&&Pa(a)}};function ah(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function lu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function kv(){}function U_(a,l,h,x,j){if(j){if(typeof x=="function"){var A=x;x=function(){var de=au(B);A.call(de)}}var B=vv(l,x,a,0,null,!1,!1,"",kv);return a._reactRootContainer=B,a[Gr]=B.current,Ko(a.nodeType===8?a.parentNode:a),ca(),B}for(;j=a.lastChild;)a.removeChild(j);if(typeof x=="function"){var X=x;x=function(){var de=au(J);X.call(de)}}var J=sh(a,0,!1,null,null,!1,!1,"",kv);return a._reactRootContainer=J,a[Gr]=J.current,Ko(a.nodeType===8?a.parentNode:a),ca(function(){iu(l,J,h,x)}),J}function cu(a,l,h,x,j){var A=h._reactRootContainer;if(A){var B=A;if(typeof j=="function"){var X=j;j=function(){var J=au(B);X.call(J)}}iu(l,B,a,j)}else B=U_(h,l,a,j,x);return au(B)}cs=function(a){switch(a.tag){case 3:var l=a.stateNode;if(l.current.memoizedState.isDehydrated){var h=Ds(l.pendingLanes);h!==0&&(Fs(l,h|1),ms(l,Ot()),(kt&6)===0&&(ro=Ot()+500,Ni()))}break;case 13:ca(function(){var x=Qr(a,1);if(x!==null){var j=ts();cr(x,a,1,j)}}),rh(a,1)}},Pt=function(a){if(a.tag===13){var l=Qr(a,134217728);if(l!==null){var h=ts();cr(l,a,134217728,h)}rh(a,134217728)}},ht=function(a){if(a.tag===13){var l=Ii(a),h=Qr(a,l);if(h!==null){var x=ts();cr(h,a,l,x)}rh(a,l)}},Zr=function(){return vt},Jn=function(a,l){var h=vt;try{return vt=a,l()}finally{vt=h}},Qs=function(a,l,h){switch(l){case"input":if(Ge(a,h),l=h.name,h.type==="radio"&&l!=null){for(h=a;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<h.length;l++){var x=h[l];if(x!==a&&x.form===a.form){var j=_c(x);if(!j)throw Error(n(90));je(x),Ge(x,j)}}}break;case"textarea":ln(a,h);break;case"select":l=h.value,l!=null&&jt(a,!!h.multiple,l,!1)}},Oe=Xf,st=ca;var H_={usingClientEntryPoint:!1,Events:[Qo,Va,_c,Q,pe,Xf]},fl={findFiberByHostInstance:ta,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Z_={bundleType:fl.bundleType,version:fl.version,rendererPackageName:fl.rendererPackageName,rendererConfig:fl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:$.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=mi(a),a===null?null:a.stateNode},findFiberByHostInstance:fl.findFiberByHostInstance||B_,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var uu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!uu.isDisabled&&uu.supportsFiber)try{ct=uu.inject(Z_),ft=uu}catch{}}return gs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H_,gs.createPortal=function(a,l){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ah(l))throw Error(n(200));return F_(a,l,null,h)},gs.createRoot=function(a,l){if(!ah(a))throw Error(n(299));var h=!1,x="",j=bv;return l!=null&&(l.unstable_strictMode===!0&&(h=!0),l.identifierPrefix!==void 0&&(x=l.identifierPrefix),l.onRecoverableError!==void 0&&(j=l.onRecoverableError)),l=sh(a,1,!1,null,null,h,!1,x,j),a[Gr]=l.current,Ko(a.nodeType===8?a.parentNode:a),new ih(l)},gs.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var l=a._reactInternals;if(l===void 0)throw typeof a.render=="function"?Error(n(188)):(a=Object.keys(a).join(","),Error(n(268,a)));return a=mi(l),a=a===null?null:a.stateNode,a},gs.flushSync=function(a){return ca(a)},gs.hydrate=function(a,l,h){if(!lu(l))throw Error(n(200));return cu(null,a,l,!0,h)},gs.hydrateRoot=function(a,l,h){if(!ah(a))throw Error(n(405));var x=h!=null&&h.hydratedSources||null,j=!1,A="",B=bv;if(h!=null&&(h.unstable_strictMode===!0&&(j=!0),h.identifierPrefix!==void 0&&(A=h.identifierPrefix),h.onRecoverableError!==void 0&&(B=h.onRecoverableError)),l=vv(l,null,a,1,h??null,j,!1,A,B),a[Gr]=l.current,Ko(a),x)for(a=0;a<x.length;a++)h=x[a],j=h._getVersion,j=j(h._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[h,j]:l.mutableSourceEagerHydrationData.push(h,j);return new ou(l)},gs.render=function(a,l,h){if(!lu(l))throw Error(n(200));return cu(null,a,l,!1,h)},gs.unmountComponentAtNode=function(a){if(!lu(a))throw Error(n(40));return a._reactRootContainer?(ca(function(){cu(null,null,a,!1,function(){a._reactRootContainer=null,a[Gr]=null})}),!0):!1},gs.unstable_batchedUpdates=Xf,gs.unstable_renderSubtreeIntoContainer=function(a,l,h,x){if(!lu(h))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return cu(a,l,h,!1,x)},gs.version="18.3.1-next-f1338f8080-20240426",gs}var Tv;function Rb(){if(Tv)return uh.exports;Tv=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),uh.exports=J_(),uh.exports}var Mv;function eE(){if(Mv)return du;Mv=1;var e=Rb();return du.createRoot=e.createRoot,du.hydrateRoot=e.hydrateRoot,du}var tE=eE(),Li,wo,No;class zr{constructor(t){Lt(this,Li);Lt(this,wo,new Set);Lt(this,No,!1);ut(this,"get",()=>Re(this,Li));ut(this,"subscribe",t=>(Re(this,wo).add(t),()=>{Re(this,wo).delete(t)}));Zt(this,Li,t)}set(t){const n=typeof t=="function"?t(Re(this,Li)):t;Object.is(n,Re(this,Li))||(Zt(this,Li,n),!Re(this,No)&&(Zt(this,No,!0),queueMicrotask(()=>{Zt(this,No,!1);for(const r of[...Re(this,wo)])r()})))}}Li=new WeakMap,wo=new WeakMap,No=new WeakMap;var $v;function ge(e,t,n){function r(u,d){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:d,constr:c,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,d);const f=c.prototype,p=Object.keys(f);for(let m=0;m<p.length;m++){const g=p[m];g in u||(u[g]=f[g].bind(u))}}const i=(n==null?void 0:n.Parent)??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function c(u){var d;const f=n!=null&&n.Parent?new o:this;r(f,u),(d=f._zod).deferred??(d.deferred=[]);for(const p of f._zod.deferred)p();return f}return Object.defineProperty(c,"init",{value:r}),Object.defineProperty(c,Symbol.hasInstance,{value:u=>{var d,f;return n!=null&&n.Parent&&u instanceof n.Parent?!0:(f=(d=u==null?void 0:u._zod)==null?void 0:d.traits)==null?void 0:f.has(e)}}),Object.defineProperty(c,"name",{value:e}),c}class xo extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ob extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}($v=globalThis).__zod_globalConfig??($v.__zod_globalConfig={});const mm=globalThis.__zod_globalConfig;function li(e){return mm}function zb(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function gp(e,t){return typeof t=="bigint"?t.toString():t}function fd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function gm(e){return e==null}function xm(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function nE(e,t){const n=e/t,r=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}const Rv=Symbol("evaluating");function Mt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Rv)return r===void 0&&(r=Rv,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Ra(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Yi(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Ov(e){return JSON.stringify(e)}function sE(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Pb="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Bl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const rE=fd(()=>{var e;if(mm.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Io(e){if(Bl(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Bl(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Lb(e){return Io(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const iE=new Set(["string","number","symbol"]);function Ao(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function Je(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function aE(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const oE={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function lE(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=Yi(e._zod.def,{get shape(){const c={};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n.shape[u])}return Ra(this,"shape",c),c},checks:[]});return Xi(e,o)}function cE(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=Yi(e._zod.def,{get shape(){const c={...e._zod.def.shape};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&delete c[u]}return Ra(this,"shape",c),c},checks:[]});return Xi(e,o)}function uE(e,t){if(!Io(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=e._zod.def.shape;for(const c in t)if(Object.getOwnPropertyDescriptor(o,c)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Yi(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Ra(this,"shape",o),o}});return Xi(e,i)}function dE(e,t){if(!Io(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Yi(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Ra(this,"shape",r),r}});return Xi(e,n)}function fE(e,t){var r;if((r=e._zod.def.checks)!=null&&r.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Yi(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return Ra(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Xi(e,n)}function hE(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const c=Yi(t._zod.def,{get shape(){const u=t._zod.def.shape,d={...u};if(n)for(const f in n){if(!(f in u))throw new Error(`Unrecognized key: "${f}"`);n[f]&&(d[f]=e?new e({type:"optional",innerType:u[f]}):u[f])}else for(const f in u)d[f]=e?new e({type:"optional",innerType:u[f]}):u[f];return Ra(this,"shape",d),d},checks:[]});return Xi(t,c)}function pE(e,t,n){const r=Yi(t._zod.def,{get shape(){const i=t._zod.def.shape,o={...i};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(o[c]=new e({type:"nonoptional",innerType:i[c]}))}else for(const c in i)o[c]=new e({type:"nonoptional",innerType:i[c]});return Ra(this,"shape",o),o}});return Xi(t,r)}function ho(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function mE(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function po(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function fu(e){return typeof e=="string"?e:e==null?void 0:e.message}function ci(e,t,n){var d,f,p,m,g,v;const r=e.message?e.message:fu((p=(f=(d=e.inst)==null?void 0:d._zod.def)==null?void 0:f.error)==null?void 0:p.call(f,e))??fu((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??fu((g=n.customError)==null?void 0:g.call(n,e))??fu((v=n.localeError)==null?void 0:v.call(n,e))??"Invalid input",{inst:i,continue:o,input:c,...u}=e;return u.path??(u.path=[]),u.message=r,t!=null&&t.reportInput&&(u.input=c),u}function vm(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ul(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Db=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,gp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Fb=ge("$ZodError",Db),Bb=ge("$ZodError",Db,{Parent:Error});function gE(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function xE(e,t=n=>n.message){const n={_errors:[]},r=(i,o=[])=>{for(const c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>r({issues:u},[...o,...c.path]));else if(c.code==="invalid_key")r({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")r({issues:c.issues},[...o,...c.path]);else{const u=[...o,...c.path];if(u.length===0)n._errors.push(t(c));else{let d=n,f=0;for(;f<u.length;){const p=u[f];f===u.length-1?(d[p]=d[p]||{_errors:[]},d[p]._errors.push(t(c))):d[p]=d[p]||{_errors:[]},d=d[p],f++}}}};return r(e),n}const ym=e=>(t,n,r,i)=>{const o=r?{...r,async:!1}:{async:!1},c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise)throw new xo;if(c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(d=>ci(d,o,li())));throw Pb(u,i==null?void 0:i.callee),u}return c.value},bm=e=>async(t,n,r,i)=>{const o=r?{...r,async:!0}:{async:!0};let c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(d=>ci(d,o,li())));throw Pb(u,i==null?void 0:i.callee),u}return c.value},hd=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new xo;return o.issues.length?{success:!1,error:new(e??Fb)(o.issues.map(c=>ci(c,i,li())))}:{success:!0,data:o.value}},vE=hd(Bb),pd=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(c=>ci(c,i,li())))}:{success:!0,data:o.value}},yE=pd(Bb),bE=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return ym(e)(t,n,i)},kE=e=>(t,n,r)=>ym(e)(t,n,r),wE=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return bm(e)(t,n,i)},NE=e=>async(t,n,r)=>bm(e)(t,n,r),jE=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return hd(e)(t,n,i)},SE=e=>(t,n,r)=>hd(e)(t,n,r),_E=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return pd(e)(t,n,i)},EE=e=>async(t,n,r)=>pd(e)(t,n,r),CE=/^[cC][0-9a-z]{6,}$/,IE=/^[0-9a-z]+$/,AE=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,TE=/^[0-9a-vA-V]{20}$/,ME=/^[A-Za-z0-9]{27}$/,$E=/^[a-zA-Z0-9_-]{21}$/,RE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,OE=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zv=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,zE=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,PE="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function LE(){return new RegExp(PE,"u")}const DE=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,FE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,BE=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,UE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,HE=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ub=/^[A-Za-z0-9_-]*$/,ZE=/^https?$/,VE=/^\+[1-9]\d{6,14}$/,Hb="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",WE=new RegExp(`^${Hb}$`);function Zb(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function qE(e){return new RegExp(`^${Zb(e)}$`)}function GE(e){const t=Zb({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Hb}T(?:${r})$`)}const KE=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},YE=/^-?\d+$/,Vb=/^-?\d+(?:\.\d+)?$/,XE=/^(?:true|false)$/i,QE=/^[^A-Z]*$/,JE=/^[^a-z]*$/,ks=ge("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Wb={number:"number",bigint:"bigint",object:"date"},qb=ge("$ZodCheckLessThan",(e,t)=>{ks.init(e,t);const n=Wb[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Gb=ge("$ZodCheckGreaterThan",(e,t)=>{ks.init(e,t);const n=Wb[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),e1=ge("$ZodCheckMultipleOf",(e,t)=>{ks.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):nE(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),t1=ge("$ZodCheckNumberFormat",(e,t)=>{var c;ks.init(e,t),t.format=t.format||"float64";const n=(c=t.format)==null?void 0:c.includes("int"),r=n?"int":"number",[i,o]=oE[t.format];e._zod.onattach.push(u=>{const d=u._zod.bag;d.format=t.format,d.minimum=i,d.maximum=o,n&&(d.pattern=YE)}),e._zod.check=u=>{const d=u.value;if(n){if(!Number.isInteger(d)){u.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?u.issues.push({input:d,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):u.issues.push({input:d,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}d<i&&u.issues.push({origin:"number",input:d,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),d>o&&u.issues.push({origin:"number",input:d,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),n1=ge("$ZodCheckMaxLength",(e,t)=>{var n;ks.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!gm(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const c=vm(i);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),s1=ge("$ZodCheckMinLength",(e,t)=>{var n;ks.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!gm(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const c=vm(i);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),r1=ge("$ZodCheckLengthEquals",(e,t)=>{var n;ks.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!gm(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=r=>{const i=r.value,o=i.length;if(o===t.length)return;const c=vm(i),u=o>t.length;r.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),md=ge("$ZodCheckStringFormat",(e,t)=>{var n,r;ks.init(e,t),e._zod.onattach.push(i=>{const o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),i1=ge("$ZodCheckRegex",(e,t)=>{md.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),a1=ge("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=QE),md.init(e,t)}),o1=ge("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=JE),md.init(e,t)}),l1=ge("$ZodCheckIncludes",(e,t)=>{ks.init(e,t);const n=Ao(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(i=>{const o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),c1=ge("$ZodCheckStartsWith",(e,t)=>{ks.init(e,t);const n=new RegExp(`^${Ao(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),u1=ge("$ZodCheckEndsWith",(e,t)=>{ks.init(e,t);const n=new RegExp(`.*${Ao(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),d1=ge("$ZodCheckOverwrite",(e,t)=>{ks.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class f1{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
41
|
-
`).filter(c=>c),i=Math.min(...r.map(c=>c.length-c.trimStart().length)),o=r.map(c=>c.slice(i)).map(c=>" ".repeat(this.indent*2)+c);for(const c of o)this.content.push(c)}compile(){const t=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new t(...n,i.join(`
|
|
42
|
-
`))}}const h1={major:4,minor:4,patch:3},en=ge("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=h1;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const c of o._zod.onattach)c(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const o=(u,d,f)=>{let p=ho(u),m;for(const g of d){if(g._zod.def.when){if(mE(u)||!g._zod.def.when(u))continue}else if(p)continue;const v=u.issues.length,y=g._zod.check(u);if(y instanceof Promise&&(f==null?void 0:f.async)===!1)throw new xo;if(m||y instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await y,u.issues.length!==v&&(p||(p=ho(u,v)))});else{if(u.issues.length===v)continue;p||(p=ho(u,v))}}return m?m.then(()=>u):u},c=(u,d,f)=>{if(ho(u))return u.aborted=!0,u;const p=o(d,r,f);if(p instanceof Promise){if(f.async===!1)throw new xo;return p.then(m=>e._zod.parse(m,f))}return e._zod.parse(p,f)};e._zod.run=(u,d)=>{if(d.skipChecks)return e._zod.parse(u,d);if(d.direction==="backward"){const p=e._zod.parse({value:u.value,issues:[]},{...d,skipChecks:!0});return p instanceof Promise?p.then(m=>c(m,u,d)):c(p,u,d)}const f=e._zod.parse(u,d);if(f instanceof Promise){if(d.async===!1)throw new xo;return f.then(p=>o(p,r,d))}return o(f,r,d)}}Mt(e,"~standard",()=>({validate:o=>{var c;try{const u=vE(e,o);return u.success?{value:u.data}:{issues:(c=u.error)==null?void 0:c.issues}}catch{return yE(e,o).then(d=>{var f;return d.success?{value:d.data}:{issues:(f=d.error)==null?void 0:f.issues}})}},vendor:"zod",version:1}))}),km=ge("$ZodString",(e,t)=>{var n;en.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??KE(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Kt=ge("$ZodStringFormat",(e,t)=>{md.init(e,t),km.init(e,t)}),p1=ge("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=OE),Kt.init(e,t)}),m1=ge("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=zv(r))}else t.pattern??(t.pattern=zv());Kt.init(e,t)}),g1=ge("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=zE),Kt.init(e,t)}),x1=ge("$ZodURL",(e,t)=>{Kt.init(e,t),e._zod.check=n=>{var r;try{const i=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===ZE.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),v1=ge("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=LE()),Kt.init(e,t)}),y1=ge("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=$E),Kt.init(e,t)}),b1=ge("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=CE),Kt.init(e,t)}),k1=ge("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=IE),Kt.init(e,t)}),w1=ge("$ZodULID",(e,t)=>{t.pattern??(t.pattern=AE),Kt.init(e,t)}),N1=ge("$ZodXID",(e,t)=>{t.pattern??(t.pattern=TE),Kt.init(e,t)}),j1=ge("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ME),Kt.init(e,t)}),S1=ge("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=GE(t)),Kt.init(e,t)}),_1=ge("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=WE),Kt.init(e,t)}),E1=ge("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=qE(t)),Kt.init(e,t)}),C1=ge("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=RE),Kt.init(e,t)}),I1=ge("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=DE),Kt.init(e,t),e._zod.bag.format="ipv4"}),A1=ge("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=FE),Kt.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),T1=ge("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=BE),Kt.init(e,t)}),M1=ge("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=UE),Kt.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,o]=r;if(!o)throw new Error;const c=Number(o);if(`${c}`!==o)throw new Error;if(c<0||c>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Kb(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const $1=ge("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=HE),Kt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Kb(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function R1(e){if(!Ub.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Kb(n)}const O1=ge("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ub),Kt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{R1(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),z1=ge("$ZodE164",(e,t)=>{t.pattern??(t.pattern=VE),Kt.init(e,t)});function P1(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const L1=ge("$ZodJWT",(e,t)=>{Kt.init(e,t),e._zod.check=n=>{P1(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Yb=ge("$ZodNumber",(e,t)=>{en.init(e,t),e._zod.pattern=e._zod.bag.pattern??Vb,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),D1=ge("$ZodNumberFormat",(e,t)=>{t1.init(e,t),Yb.init(e,t)}),F1=ge("$ZodBoolean",(e,t)=>{en.init(e,t),e._zod.pattern=XE,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),B1=ge("$ZodUnknown",(e,t)=>{en.init(e,t),e._zod.parse=n=>n}),U1=ge("$ZodNever",(e,t)=>{en.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Pv(e,t,n){e.issues.length&&t.issues.push(...po(n,e.issues)),t.value[n]=e.value}const H1=ge("$ZodArray",(e,t)=>{en.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let c=0;c<i.length;c++){const u=i[c],d=t.element._zod.run({value:u,issues:[]},r);d instanceof Promise?o.push(d.then(f=>Pv(f,n,c))):Pv(d,n,c)}return o.length?Promise.all(o).then(()=>n):n}});function Bu(e,t,n,r,i,o){const c=n in r;if(e.issues.length){if(i&&o&&!c)return;t.issues.push(...po(n,e.issues))}if(!c&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?c&&(t.value[n]=void 0):t.value[n]=e.value}function Xb(e){var r,i,o,c;const t=Object.keys(e.shape);for(const u of t)if(!((c=(o=(i=(r=e.shape)==null?void 0:r[u])==null?void 0:i._zod)==null?void 0:o.traits)!=null&&c.has("$ZodType")))throw new Error(`Invalid element at key "${u}": expected a Zod schema`);const n=aE(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Qb(e,t,n,r,i,o){const c=[],u=i.keySet,d=i.catchall._zod,f=d.def.type,p=d.optin==="optional",m=d.optout==="optional";for(const g in t){if(g==="__proto__"||u.has(g))continue;if(f==="never"){c.push(g);continue}const v=d.run({value:t[g],issues:[]},r);v instanceof Promise?e.push(v.then(y=>Bu(y,n,g,t,p,m))):Bu(v,n,g,t,p,m)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const Z1=ge("$ZodObject",(e,t)=>{en.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...u};return Object.defineProperty(t,"shape",{value:d}),d}})}const r=fd(()=>Xb(t));Mt(e._zod,"propValues",()=>{const u=t.shape,d={};for(const f in u){const p=u[f]._zod;if(p.values){d[f]??(d[f]=new Set);for(const m of p.values)d[f].add(m)}}return d});const i=Bl,o=t.catchall;let c;e._zod.parse=(u,d)=>{c??(c=r.value);const f=u.value;if(!i(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;u.value={};const p=[],m=c.shape;for(const g of c.keys){const v=m[g],y=v._zod.optin==="optional",S=v._zod.optout==="optional",k=v._zod.run({value:f[g],issues:[]},d);k instanceof Promise?p.push(k.then(w=>Bu(w,u,g,f,y,S))):Bu(k,u,g,f,y,S)}return o?Qb(p,f,u,d,r.value,e):p.length?Promise.all(p).then(()=>u):u}}),V1=ge("$ZodObjectJIT",(e,t)=>{Z1.init(e,t);const n=e._zod.parse,r=fd(()=>Xb(t)),i=g=>{var N,$;const v=new f1(["shape","payload","ctx"]),y=r.value,S=D=>{const O=Ov(D);return`shape[${O}]._zod.run({ value: input[${O}], issues: [] }, ctx)`};v.write("const input = payload.value;");const k=Object.create(null);let w=0;for(const D of y.keys)k[D]=`key_${w++}`;v.write("const newResult = {};");for(const D of y.keys){const O=k[D],F=Ov(D),U=g[D],M=((N=U==null?void 0:U._zod)==null?void 0:N.optin)==="optional",P=(($=U==null?void 0:U._zod)==null?void 0:$.optout)==="optional";v.write(`const ${O} = ${S(D)};`),M&&P?v.write(`
|
|
43
|
-
if (${O}.issues.length) {
|
|
44
|
-
if (${F} in input) {
|
|
45
|
-
payload.issues = payload.issues.concat(${O}.issues.map(iss => ({
|
|
46
|
-
...iss,
|
|
47
|
-
path: iss.path ? [${F}, ...iss.path] : [${F}]
|
|
48
|
-
})));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (${O}.value === undefined) {
|
|
53
|
-
if (${F} in input) {
|
|
54
|
-
newResult[${F}] = undefined;
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
newResult[${F}] = ${O}.value;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
`):M?v.write(`
|
|
61
|
-
if (${O}.issues.length) {
|
|
62
|
-
payload.issues = payload.issues.concat(${O}.issues.map(iss => ({
|
|
63
|
-
...iss,
|
|
64
|
-
path: iss.path ? [${F}, ...iss.path] : [${F}]
|
|
65
|
-
})));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (${O}.value === undefined) {
|
|
69
|
-
if (${F} in input) {
|
|
70
|
-
newResult[${F}] = undefined;
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
newResult[${F}] = ${O}.value;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
`):v.write(`
|
|
77
|
-
const ${O}_present = ${F} in input;
|
|
78
|
-
if (${O}.issues.length) {
|
|
79
|
-
payload.issues = payload.issues.concat(${O}.issues.map(iss => ({
|
|
80
|
-
...iss,
|
|
81
|
-
path: iss.path ? [${F}, ...iss.path] : [${F}]
|
|
82
|
-
})));
|
|
83
|
-
}
|
|
84
|
-
if (!${O}_present && !${O}.issues.length) {
|
|
85
|
-
payload.issues.push({
|
|
86
|
-
code: "invalid_type",
|
|
87
|
-
expected: "nonoptional",
|
|
88
|
-
input: undefined,
|
|
89
|
-
path: [${F}]
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (${O}_present) {
|
|
94
|
-
if (${O}.value === undefined) {
|
|
95
|
-
newResult[${F}] = undefined;
|
|
96
|
-
} else {
|
|
97
|
-
newResult[${F}] = ${O}.value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
`)}v.write("payload.value = newResult;"),v.write("return payload;");const T=v.compile();return(D,O)=>T(g,D,O)};let o;const c=Bl,u=!mm.jitless,f=u&&rE.value,p=t.catchall;let m;e._zod.parse=(g,v)=>{m??(m=r.value);const y=g.value;return c(y)?u&&f&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(o||(o=i(t.shape)),g=o(g,v),p?Qb([],y,g,v,m,e):g):n(g,v):(g.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),g)}});function Lv(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!ho(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(c=>ci(c,r,li())))}),t)}const Jb=ge("$ZodUnion",(e,t)=>{en.init(e,t),Mt(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Mt(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Mt(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Mt(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${r.map(i=>xm(i.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const c=[];for(const u of t.options){const d=u._zod.run({value:r.value,issues:[]},i);if(d instanceof Promise)c.push(d),o=!0;else{if(d.issues.length===0)return d;c.push(d)}}return o?Promise.all(c).then(u=>Lv(u,r,e,i)):Lv(c,r,e,i)}}),W1=ge("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Jb.init(e,t);const n=e._zod.parse;Mt(e._zod,"propValues",()=>{const i={};for(const o of t.options){const c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[u,d]of Object.entries(c)){i[u]||(i[u]=new Set);for(const f of d)i[u].add(f)}}return i});const r=fd(()=>{var c;const i=t.options,o=new Map;for(const u of i){const d=(c=u._zod.propValues)==null?void 0:c[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const f of d){if(o.has(f))throw new Error(`Duplicate discriminator value "${String(f)}"`);o.set(f,u)}}return o});e._zod.parse=(i,o)=>{const c=i.value;if(!Bl(c))return i.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),i;const u=r.value.get(c==null?void 0:c[t.discriminator]);return u?u._zod.run(i,o):t.unionFallback||o.direction==="backward"?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:c,path:[t.discriminator],inst:e}),i)}}),q1=ge("$ZodIntersection",(e,t)=>{en.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},r),c=t.right._zod.run({value:i,issues:[]},r);return o instanceof Promise||c instanceof Promise?Promise.all([o,c]).then(([d,f])=>Dv(n,d,f)):Dv(n,o,c)}});function xp(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Io(e)&&Io(t)){const n=Object.keys(t),r=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};for(const o of r){const c=xp(e[o],t[o]);if(!c.valid)return{valid:!1,mergeErrorPath:[o,...c.mergeErrorPath]};i[o]=c.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],o=t[r],c=xp(i,o);if(!c.valid)return{valid:!1,mergeErrorPath:[r,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Dv(e,t,n){const r=new Map;let i;for(const u of t.issues)if(u.code==="unrecognized_keys"){i??(i=u);for(const d of u.keys)r.has(d)||r.set(d,{}),r.get(d).l=!0}else e.issues.push(u);for(const u of n.issues)if(u.code==="unrecognized_keys")for(const d of u.keys)r.has(d)||r.set(d,{}),r.get(d).r=!0;else e.issues.push(u);const o=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(o.length&&i&&e.issues.push({...i,keys:o}),ho(e))return e;const c=xp(t.value,n.value);if(!c.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`);return e.value=c.data,e}const G1=ge("$ZodRecord",(e,t)=>{en.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Io(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const o=[],c=t.keyType._zod.values;if(c){n.value={};const u=new Set;for(const f of c)if(typeof f=="string"||typeof f=="number"||typeof f=="symbol"){u.add(typeof f=="number"?f.toString():f);const p=t.keyType._zod.run({value:f,issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(v=>ci(v,r,li())),input:f,path:[f],inst:e});continue}const m=p.value,g=t.valueType._zod.run({value:i[f],issues:[]},r);g instanceof Promise?o.push(g.then(v=>{v.issues.length&&n.issues.push(...po(f,v.issues)),n.value[m]=v.value})):(g.issues.length&&n.issues.push(...po(f,g.issues)),n.value[m]=g.value)}let d;for(const f in i)u.has(f)||(d=d??[],d.push(f));d&&d.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:d})}else{n.value={};for(const u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Vb.test(u)&&d.issues.length){const m=t.keyType._zod.run({value:Number(u),issues:[]},r);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(d=m)}if(d.issues.length){t.mode==="loose"?n.value[u]=i[u]:n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>ci(m,r,li())),input:u,path:[u],inst:e});continue}const p=t.valueType._zod.run({value:i[u],issues:[]},r);p instanceof Promise?o.push(p.then(m=>{m.issues.length&&n.issues.push(...po(u,m.issues)),n.value[d.value]=m.value})):(p.issues.length&&n.issues.push(...po(u,p.issues)),n.value[d.value]=p.value)}}return o.length?Promise.all(o).then(()=>n):n}}),K1=ge("$ZodEnum",(e,t)=>{en.init(e,t);const n=zb(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>iE.has(typeof i)).map(i=>typeof i=="string"?Ao(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{const c=i.value;return r.has(c)||i.issues.push({code:"invalid_value",values:n,input:c,inst:e}),i}}),Y1=ge("$ZodLiteral",(e,t)=>{if(en.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Ao(r):r?Ao(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),X1=ge("$ZodTransform",(e,t)=>{en.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ob(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(c=>(n.value=c,n.fallback=!0,n));if(i instanceof Promise)throw new xo;return n.value=i,n.fallback=!0,n}});function Fv(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const ek=ge("$ZodOptional",(e,t)=>{en.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Mt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Mt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${xm(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const i=n.value,o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(c=>Fv(c,i)):Fv(o,i)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Q1=ge("$ZodExactOptional",(e,t)=>{ek.init(e,t),Mt(e._zod,"values",()=>t.innerType._zod.values),Mt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),J1=ge("$ZodNullable",(e,t)=>{en.init(e,t),Mt(e._zod,"optin",()=>t.innerType._zod.optin),Mt(e._zod,"optout",()=>t.innerType._zod.optout),Mt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${xm(n.source)}|null)$`):void 0}),Mt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),eC=ge("$ZodDefault",(e,t)=>{en.init(e,t),e._zod.optin="optional",Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Bv(o,t)):Bv(i,t)}});function Bv(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const tC=ge("$ZodPrefault",(e,t)=>{en.init(e,t),e._zod.optin="optional",Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),nC=ge("$ZodNonOptional",(e,t)=>{en.init(e,t),Mt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Uv(o,e)):Uv(i,e)}});function Uv(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const sC=ge("$ZodCatch",(e,t)=>{en.init(e,t),e._zod.optin="optional",Mt(e._zod,"optout",()=>t.innerType._zod.optout),Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(c=>ci(c,r,li()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>ci(o,r,li()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),rC=ge("$ZodPipe",(e,t)=>{en.init(e,t),Mt(e._zod,"values",()=>t.in._zod.values),Mt(e._zod,"optin",()=>t.in._zod.optin),Mt(e._zod,"optout",()=>t.out._zod.optout),Mt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(c=>hu(c,t.in,r)):hu(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>hu(o,t.out,r)):hu(i,t.out,r)}});function hu(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const iC=ge("$ZodReadonly",(e,t)=>{en.init(e,t),Mt(e._zod,"propValues",()=>t.innerType._zod.propValues),Mt(e._zod,"values",()=>t.innerType._zod.values),Mt(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Mt(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(Hv):Hv(i)}});function Hv(e){return e.value=Object.freeze(e.value),e}const aC=ge("$ZodCustom",(e,t)=>{ks.init(e,t),en.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(o=>Zv(o,n,r,e));Zv(i,n,r,e)}});function Zv(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Ul(i))}}var Vv;class oC{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function lC(){return new oC}(Vv=globalThis).__zod_globalRegistry??(Vv.__zod_globalRegistry=lC());const _l=globalThis.__zod_globalRegistry;function cC(e,t){return new e({type:"string",...Je(t)})}function uC(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Je(t)})}function Wv(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Je(t)})}function dC(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Je(t)})}function fC(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Je(t)})}function hC(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Je(t)})}function pC(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Je(t)})}function tk(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Je(t)})}function mC(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Je(t)})}function gC(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Je(t)})}function xC(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Je(t)})}function vC(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Je(t)})}function yC(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Je(t)})}function bC(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Je(t)})}function kC(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Je(t)})}function wC(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Je(t)})}function NC(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Je(t)})}function jC(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Je(t)})}function SC(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Je(t)})}function _C(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Je(t)})}function EC(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Je(t)})}function CC(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Je(t)})}function IC(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Je(t)})}function AC(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Je(t)})}function TC(e,t){return new e({type:"string",format:"date",check:"string_format",...Je(t)})}function MC(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Je(t)})}function $C(e,t){return new e({type:"string",format:"duration",check:"string_format",...Je(t)})}function RC(e,t){return new e({type:"number",checks:[],...Je(t)})}function OC(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Je(t)})}function zC(e,t){return new e({type:"boolean",...Je(t)})}function PC(e){return new e({type:"unknown"})}function LC(e,t){return new e({type:"never",...Je(t)})}function qv(e,t){return new qb({check:"less_than",...Je(t),value:e,inclusive:!1})}function hh(e,t){return new qb({check:"less_than",...Je(t),value:e,inclusive:!0})}function Gv(e,t){return new Gb({check:"greater_than",...Je(t),value:e,inclusive:!1})}function ph(e,t){return new Gb({check:"greater_than",...Je(t),value:e,inclusive:!0})}function Kv(e,t){return new e1({check:"multiple_of",...Je(t),value:e})}function nk(e,t){return new n1({check:"max_length",...Je(t),maximum:e})}function Uu(e,t){return new s1({check:"min_length",...Je(t),minimum:e})}function sk(e,t){return new r1({check:"length_equals",...Je(t),length:e})}function DC(e,t){return new i1({check:"string_format",format:"regex",...Je(t),pattern:e})}function FC(e){return new a1({check:"string_format",format:"lowercase",...Je(e)})}function BC(e){return new o1({check:"string_format",format:"uppercase",...Je(e)})}function UC(e,t){return new l1({check:"string_format",format:"includes",...Je(t),includes:e})}function HC(e,t){return new c1({check:"string_format",format:"starts_with",...Je(t),prefix:e})}function ZC(e,t){return new u1({check:"string_format",format:"ends_with",...Je(t),suffix:e})}function Do(e){return new d1({check:"overwrite",tx:e})}function VC(e){return Do(t=>t.normalize(e))}function WC(){return Do(e=>e.trim())}function qC(){return Do(e=>e.toLowerCase())}function GC(){return Do(e=>e.toUpperCase())}function KC(){return Do(e=>sE(e))}function YC(e,t,n){return new e({type:"array",element:t,...Je(n)})}function XC(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Je(n)})}function QC(e,t){const n=JC(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(Ul(i,r.value,n._zod.def));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),r.issues.push(Ul(o))}},e(r.value,r)),t);return n}function JC(e,t){const n=new ks({check:"custom",...Je(t)});return n._zod.check=e,n}function rk(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??_l,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function bn(e,t,n={path:[],schemaPath:[]}){var p,m;var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const c={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,c);const u=(m=(p=e._zod).toJSONSchema)==null?void 0:m.call(p);if(u)c.schema=u;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,g);else{const y=c.schema,S=t.processors[i.type];if(!S)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);S(e,t,y,g)}const v=e._zod.parent;v&&(c.ref||(c.ref=v),bn(v,t,g),t.seen.get(v).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Object.assign(c.schema,d),t.io==="input"&&ns(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&"_prefault"in c.schema&&((r=c.schema).default??(r.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function ik(e,t){var c,u,d,f;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const p of e.seen.entries()){const m=(c=e.metadataRegistry.get(p[0]))==null?void 0:c.id;if(m){const g=r.get(m);if(g&&g!==p[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,p[0])}}const i=p=>{var S;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const k=(S=e.external.registry.get(p[0]))==null?void 0:S.id,w=e.external.uri??(N=>N);if(k)return{ref:w(k)};const T=p[1].defId??p[1].schema.id??`schema${e.counter++}`;return p[1].defId=T,{defId:T,ref:`${w("__shared")}#/${m}/${T}`}}if(p[1]===n)return{ref:"#"};const v=`#/${m}/`,y=p[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:v+y}},o=p=>{if(p[1].schema.$ref)return;const m=p[1],{ref:g,defId:v}=i(p);m.def={...m.schema},v&&(m.defId=v);const y=m.schema;for(const S in y)delete y[S];y.$ref=g};if(e.cycles==="throw")for(const p of e.seen.entries()){const m=p[1];if(m.cycle)throw new Error(`Cycle detected: #/${(u=m.cycle)==null?void 0:u.join("/")}/<root>
|
|
102
|
-
|
|
103
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of e.seen.entries()){const m=p[1];if(t===p[0]){o(p);continue}if(e.external){const v=(d=e.external.registry.get(p[0]))==null?void 0:d.id;if(t!==p[0]&&v){o(p);continue}}if((f=e.metadataRegistry.get(p[0]))==null?void 0:f.id){o(p);continue}if(m.cycle){o(p);continue}if(m.count>1&&e.reused==="ref"){o(p);continue}}}function ak(e,t){var u,d,f,p;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const g=e.seen.get(m);if(g.ref===null)return;const v=g.def??g.schema,y={...v},S=g.ref;if(g.ref=null,S){r(S);const w=e.seen.get(S),T=w.schema;if(T.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(v.allOf=v.allOf??[],v.allOf.push(T)):Object.assign(v,T),Object.assign(v,y),m._zod.parent===S)for(const $ in v)$==="$ref"||$==="allOf"||$ in y||delete v[$];if(T.$ref&&w.def)for(const $ in v)$==="$ref"||$==="allOf"||$ in w.def&&JSON.stringify(v[$])===JSON.stringify(w.def[$])&&delete v[$]}const k=m._zod.parent;if(k&&k!==S){r(k);const w=e.seen.get(k);if(w!=null&&w.schema.$ref&&(v.$ref=w.schema.$ref,w.def))for(const T in v)T==="$ref"||T==="allOf"||T in w.def&&JSON.stringify(v[T])===JSON.stringify(w.def[T])&&delete v[T]}e.override({zodSchema:m,jsonSchema:v,path:g.path??[]})};for(const m of[...e.seen.entries()].reverse())r(m[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(u=e.external)!=null&&u.uri){const m=(d=e.external.registry.get(t))==null?void 0:d.id;if(!m)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(m)}Object.assign(i,n.def??n.schema);const o=(f=e.metadataRegistry.get(t))==null?void 0:f.id;o!==void 0&&i.id===o&&delete i.id;const c=((p=e.external)==null?void 0:p.defs)??{};for(const m of e.seen.entries()){const g=m[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,c[g.defId]=g.def)}e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?i.$defs=c:i.definitions=c);try{const m=JSON.parse(JSON.stringify(i));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Hu(t,"input",e.processors),output:Hu(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function ns(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ns(r.element,n);if(r.type==="set")return ns(r.valueType,n);if(r.type==="lazy")return ns(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return ns(r.innerType,n);if(r.type==="intersection")return ns(r.left,n)||ns(r.right,n);if(r.type==="record"||r.type==="map")return ns(r.keyType,n)||ns(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ns(r.in,n)||ns(r.out,n);if(r.type==="object"){for(const i in r.shape)if(ns(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(ns(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(ns(i,n))return!0;return!!(r.rest&&ns(r.rest,n))}return!1}const eI=(e,t={})=>n=>{const r=rk({...n,processors:t});return bn(e,r),ik(r,e),ak(r,e)},Hu=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},c=rk({...i??{},target:o,io:t,processors:n});return bn(e,c),ik(c,e),ak(c,e)},tI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},nI=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:c,format:u,patterns:d,contentEncoding:f}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof c=="number"&&(i.maxLength=c),u&&(i.format=tI[u]??u,i.format===""&&delete i.format,u==="time"&&delete i.format),f&&(i.contentEncoding=f),d&&d.size>0){const p=[...d];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},sI=(e,t,n,r)=>{const i=n,{minimum:o,maximum:c,format:u,multipleOf:d,exclusiveMaximum:f,exclusiveMinimum:p}=e._zod.bag;typeof u=="string"&&u.includes("int")?i.type="integer":i.type="number";const m=typeof p=="number"&&p>=(o??Number.NEGATIVE_INFINITY),g=typeof f=="number"&&f<=(c??Number.POSITIVE_INFINITY),v=t.target==="draft-04"||t.target==="openapi-3.0";m?v?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p:typeof o=="number"&&(i.minimum=o),g?v?(i.maximum=f,i.exclusiveMaximum=!0):i.exclusiveMaximum=f:typeof c=="number"&&(i.maximum=c),typeof d=="number"&&(i.multipleOf=d)},rI=(e,t,n,r)=>{n.type="boolean"},iI=(e,t,n,r)=>{n.not={}},aI=(e,t,n,r)=>{},oI=(e,t,n,r)=>{const i=e._zod.def,o=zb(i.entries);o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),n.enum=o},lI=(e,t,n,r)=>{const i=e._zod.def,o=[];for(const c of i.values)if(c===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof c=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(c))}else o.push(c);if(o.length!==0)if(o.length===1){const c=o[0];n.type=c===null?"null":typeof c,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[c]:n.const=c}else o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),o.every(c=>typeof c=="boolean")&&(n.type="boolean"),o.every(c=>c===null)&&(n.type="null"),n.enum=o},cI=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},uI=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},dI=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:c,maximum:u}=e._zod.bag;typeof c=="number"&&(i.minItems=c),typeof u=="number"&&(i.maxItems=u),i.type="array",i.items=bn(o.element,t,{...r,path:[...r.path,"items"]})},fI=(e,t,n,r)=>{var f;const i=n,o=e._zod.def;i.type="object",i.properties={};const c=o.shape;for(const p in c)i.properties[p]=bn(c[p],t,{...r,path:[...r.path,"properties",p]});const u=new Set(Object.keys(c)),d=new Set([...u].filter(p=>{const m=o.shape[p]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));d.size>0&&(i.required=Array.from(d)),((f=o.catchall)==null?void 0:f._zod.def.type)==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=bn(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},hI=(e,t,n,r)=>{const i=e._zod.def,o=i.inclusive===!1,c=i.options.map((u,d)=>bn(u,t,{...r,path:[...r.path,o?"oneOf":"anyOf",d]}));o?n.oneOf=c:n.anyOf=c},pI=(e,t,n,r)=>{const i=e._zod.def,o=bn(i.left,t,{...r,path:[...r.path,"allOf",0]}),c=bn(i.right,t,{...r,path:[...r.path,"allOf",1]}),u=f=>"allOf"in f&&Object.keys(f).length===1,d=[...u(o)?o.allOf:[o],...u(c)?c.allOf:[c]];n.allOf=d},mI=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const c=o.keyType,u=c._zod.bag,d=u==null?void 0:u.patterns;if(o.mode==="loose"&&d&&d.size>0){const p=bn(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const m of d)i.patternProperties[m.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=bn(o.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=bn(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const f=c._zod.values;if(f){const p=[...f].filter(m=>typeof m=="string"||typeof m=="number");p.length>0&&(i.required=p)}},gI=(e,t,n,r)=>{const i=e._zod.def,o=bn(i.innerType,t,r),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},xI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},vI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},yI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},bI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;let c;try{c=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=c},kI=(e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),c=t.io==="input"?o?i.out:i.in:i.out;bn(c,t,r);const u=t.seen.get(e);u.ref=c},wI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},ok=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},NI=ge("ZodISODateTime",(e,t)=>{S1.init(e,t),nn.init(e,t)});function jI(e){return AC(NI,e)}const SI=ge("ZodISODate",(e,t)=>{_1.init(e,t),nn.init(e,t)});function _I(e){return TC(SI,e)}const EI=ge("ZodISOTime",(e,t)=>{E1.init(e,t),nn.init(e,t)});function CI(e){return MC(EI,e)}const II=ge("ZodISODuration",(e,t)=>{C1.init(e,t),nn.init(e,t)});function AI(e){return $C(II,e)}const TI=(e,t)=>{Fb.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>xE(e,n)},flatten:{value:n=>gE(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,gp,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,gp,2)}},isEmpty:{get(){return e.issues.length===0}}})},Gs=ge("ZodError",TI,{Parent:Error}),MI=ym(Gs),$I=bm(Gs),RI=hd(Gs),OI=pd(Gs),zI=bE(Gs),PI=kE(Gs),LI=wE(Gs),DI=NE(Gs),FI=jE(Gs),BI=SE(Gs),UI=_E(Gs),HI=EE(Gs),Yv=new WeakMap;function rc(e,t,n){const r=Object.getPrototypeOf(e);let i=Yv.get(r);if(i||(i=new Set,Yv.set(r,i)),!i.has(t)){i.add(t);for(const o in n){const c=n[o];Object.defineProperty(r,o,{configurable:!0,enumerable:!1,get(){const u=c.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:u}),u},set(u){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:u})}})}}}const tn=ge("ZodType",(e,t)=>(en.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Hu(e,"input"),output:Hu(e,"output")}}),e.toJSONSchema=eI(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>MI(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>RI(e,n,r),e.parseAsync=async(n,r)=>$I(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>OI(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>zI(e,n,r),e.decode=(n,r)=>PI(e,n,r),e.encodeAsync=async(n,r)=>LI(e,n,r),e.decodeAsync=async(n,r)=>DI(e,n,r),e.safeEncode=(n,r)=>FI(e,n,r),e.safeDecode=(n,r)=>BI(e,n,r),e.safeEncodeAsync=async(n,r)=>UI(e,n,r),e.safeDecodeAsync=async(n,r)=>HI(e,n,r),rc(e,"ZodType",{check(...n){const r=this.def;return this.clone(Yi(r,{checks:[...r.checks??[],...n.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return Xi(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(RA(n,r))},superRefine(n,r){return this.check(OA(n,r))},overwrite(n){return this.check(Do(n))},optional(){return e0(this)},exactOptional(){return kA(this)},nullable(){return t0(this)},nullish(){return e0(t0(this))},nonoptional(n){return EA(this,n)},array(){return ue(this)},or(n){return To([this,n])},and(n){return gA(this,n)},transform(n){return n0(this,yA(n))},default(n){return jA(this,n)},prefault(n){return _A(this,n)},catch(n){return IA(this,n)},pipe(n){return n0(this,n)},readonly(){return MA(this)},describe(n){const r=this.clone();return _l.add(r,{description:n}),r},meta(...n){if(n.length===0)return _l.get(this);const r=this.clone();return _l.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=_l.get(e))==null?void 0:n.description},configurable:!0}),e)),lk=ge("_ZodString",(e,t)=>{km.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(r,i,o)=>nI(e,r,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,rc(e,"_ZodString",{regex(...r){return this.check(DC(...r))},includes(...r){return this.check(UC(...r))},startsWith(...r){return this.check(HC(...r))},endsWith(...r){return this.check(ZC(...r))},min(...r){return this.check(Uu(...r))},max(...r){return this.check(nk(...r))},length(...r){return this.check(sk(...r))},nonempty(...r){return this.check(Uu(1,...r))},lowercase(r){return this.check(FC(r))},uppercase(r){return this.check(BC(r))},trim(){return this.check(WC())},normalize(...r){return this.check(VC(...r))},toLowerCase(){return this.check(qC())},toUpperCase(){return this.check(GC())},slugify(){return this.check(KC())}})}),ZI=ge("ZodString",(e,t)=>{km.init(e,t),lk.init(e,t),e.email=n=>e.check(uC(VI,n)),e.url=n=>e.check(tk(ck,n)),e.jwt=n=>e.check(IC(aA,n)),e.emoji=n=>e.check(mC(WI,n)),e.guid=n=>e.check(Wv(Xv,n)),e.uuid=n=>e.check(dC(pu,n)),e.uuidv4=n=>e.check(fC(pu,n)),e.uuidv6=n=>e.check(hC(pu,n)),e.uuidv7=n=>e.check(pC(pu,n)),e.nanoid=n=>e.check(gC(qI,n)),e.guid=n=>e.check(Wv(Xv,n)),e.cuid=n=>e.check(xC(GI,n)),e.cuid2=n=>e.check(vC(KI,n)),e.ulid=n=>e.check(yC(YI,n)),e.base64=n=>e.check(_C(sA,n)),e.base64url=n=>e.check(EC(rA,n)),e.xid=n=>e.check(bC(XI,n)),e.ksuid=n=>e.check(kC(QI,n)),e.ipv4=n=>e.check(wC(JI,n)),e.ipv6=n=>e.check(NC(eA,n)),e.cidrv4=n=>e.check(jC(tA,n)),e.cidrv6=n=>e.check(SC(nA,n)),e.e164=n=>e.check(CC(iA,n)),e.datetime=n=>e.check(jI(n)),e.date=n=>e.check(_I(n)),e.time=n=>e.check(CI(n)),e.duration=n=>e.check(AI(n))});function _(e){return cC(ZI,e)}const nn=ge("ZodStringFormat",(e,t)=>{Kt.init(e,t),lk.init(e,t)}),VI=ge("ZodEmail",(e,t)=>{g1.init(e,t),nn.init(e,t)}),Xv=ge("ZodGUID",(e,t)=>{p1.init(e,t),nn.init(e,t)}),pu=ge("ZodUUID",(e,t)=>{m1.init(e,t),nn.init(e,t)}),ck=ge("ZodURL",(e,t)=>{x1.init(e,t),nn.init(e,t)});function vp(e){return tk(ck,e)}const WI=ge("ZodEmoji",(e,t)=>{v1.init(e,t),nn.init(e,t)}),qI=ge("ZodNanoID",(e,t)=>{y1.init(e,t),nn.init(e,t)}),GI=ge("ZodCUID",(e,t)=>{b1.init(e,t),nn.init(e,t)}),KI=ge("ZodCUID2",(e,t)=>{k1.init(e,t),nn.init(e,t)}),YI=ge("ZodULID",(e,t)=>{w1.init(e,t),nn.init(e,t)}),XI=ge("ZodXID",(e,t)=>{N1.init(e,t),nn.init(e,t)}),QI=ge("ZodKSUID",(e,t)=>{j1.init(e,t),nn.init(e,t)}),JI=ge("ZodIPv4",(e,t)=>{I1.init(e,t),nn.init(e,t)}),eA=ge("ZodIPv6",(e,t)=>{A1.init(e,t),nn.init(e,t)}),tA=ge("ZodCIDRv4",(e,t)=>{T1.init(e,t),nn.init(e,t)}),nA=ge("ZodCIDRv6",(e,t)=>{M1.init(e,t),nn.init(e,t)}),sA=ge("ZodBase64",(e,t)=>{$1.init(e,t),nn.init(e,t)}),rA=ge("ZodBase64URL",(e,t)=>{O1.init(e,t),nn.init(e,t)}),iA=ge("ZodE164",(e,t)=>{z1.init(e,t),nn.init(e,t)}),aA=ge("ZodJWT",(e,t)=>{L1.init(e,t),nn.init(e,t)}),uk=ge("ZodNumber",(e,t)=>{Yb.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(r,i,o)=>sI(e,r,i),rc(e,"ZodNumber",{gt(r,i){return this.check(Gv(r,i))},gte(r,i){return this.check(ph(r,i))},min(r,i){return this.check(ph(r,i))},lt(r,i){return this.check(qv(r,i))},lte(r,i){return this.check(hh(r,i))},max(r,i){return this.check(hh(r,i))},int(r){return this.check(Qv(r))},safe(r){return this.check(Qv(r))},positive(r){return this.check(Gv(0,r))},nonnegative(r){return this.check(ph(0,r))},negative(r){return this.check(qv(0,r))},nonpositive(r){return this.check(hh(0,r))},multipleOf(r,i){return this.check(Kv(r,i))},step(r,i){return this.check(Kv(r,i))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function se(e){return RC(uk,e)}const oA=ge("ZodNumberFormat",(e,t)=>{D1.init(e,t),uk.init(e,t)});function Qv(e){return OC(oA,e)}const lA=ge("ZodBoolean",(e,t)=>{F1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rI(e,n,r)});function be(e){return zC(lA,e)}const cA=ge("ZodUnknown",(e,t)=>{B1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>aI()});function yp(){return PC(cA)}const uA=ge("ZodNever",(e,t)=>{U1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>iI(e,n,r)});function dA(e){return LC(uA,e)}const fA=ge("ZodArray",(e,t)=>{H1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dI(e,n,r,i),e.element=t.element,rc(e,"ZodArray",{min(n,r){return this.check(Uu(n,r))},nonempty(n){return this.check(Uu(1,n))},max(n,r){return this.check(nk(n,r))},length(n,r){return this.check(sk(n,r))},unwrap(){return this.element}})});function ue(e,t){return YC(fA,e,t)}const hA=ge("ZodObject",(e,t)=>{V1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fI(e,n,r,i),Mt(e,"shape",()=>t.shape),rc(e,"ZodObject",{keyof(){return Le(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:yp()})},loose(){return this.clone({...this._zod.def,catchall:yp()})},strict(){return this.clone({...this._zod.def,catchall:dA()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return uE(this,n)},safeExtend(n){return dE(this,n)},merge(n){return fE(this,n)},pick(n){return lE(this,n)},omit(n){return cE(this,n)},partial(...n){return hE(fk,this,n[0])},required(...n){return pE(hk,this,n[0])}})});function z(e,t){const n={type:"object",shape:e??{},...Je(t)};return new hA(n)}const dk=ge("ZodUnion",(e,t)=>{Jb.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hI(e,n,r,i),e.options=t.options});function To(e,t){return new dk({type:"union",options:e,...Je(t)})}const pA=ge("ZodDiscriminatedUnion",(e,t)=>{dk.init(e,t),W1.init(e,t)});function Oa(e,t,n){return new pA({type:"union",options:t,discriminator:e,...Je(n)})}const mA=ge("ZodIntersection",(e,t)=>{q1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pI(e,n,r,i)});function gA(e,t){return new mA({type:"intersection",left:e,right:t})}const Jv=ge("ZodRecord",(e,t)=>{G1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mI(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function di(e,t,n){return!t||!t._zod?new Jv({type:"record",keyType:_(),valueType:e,...Je(t)}):new Jv({type:"record",keyType:e,valueType:t,...Je(n)})}const bp=ge("ZodEnum",(e,t)=>{K1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(r,i,o)=>oI(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const o={};for(const c of r)if(n.has(c))o[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new bp({...t,checks:[],...Je(i),entries:o})},e.exclude=(r,i)=>{const o={...t.entries};for(const c of r)if(n.has(c))delete o[c];else throw new Error(`Key ${c} not found in enum`);return new bp({...t,checks:[],...Je(i),entries:o})}});function Le(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new bp({type:"enum",entries:n,...Je(t)})}const xA=ge("ZodLiteral",(e,t)=>{Y1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lI(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function dt(e,t){return new xA({type:"literal",values:Array.isArray(e)?e:[e],...Je(t)})}const vA=ge("ZodTransform",(e,t)=>{X1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uI(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ob(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Ul(o,n.value,t));else{const c=o;c.fatal&&(c.continue=!1),c.code??(c.code="custom"),c.input??(c.input=n.value),c.inst??(c.inst=e),n.issues.push(Ul(c))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function yA(e){return new vA({type:"transform",transform:e})}const fk=ge("ZodOptional",(e,t)=>{ek.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ok(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function e0(e){return new fk({type:"optional",innerType:e})}const bA=ge("ZodExactOptional",(e,t)=>{Q1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ok(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function kA(e){return new bA({type:"optional",innerType:e})}const wA=ge("ZodNullable",(e,t)=>{J1.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function t0(e){return new wA({type:"nullable",innerType:e})}const NA=ge("ZodDefault",(e,t)=>{eC.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function jA(e,t){return new NA({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Lb(t)}})}const SA=ge("ZodPrefault",(e,t)=>{tC.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function _A(e,t){return new SA({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Lb(t)}})}const hk=ge("ZodNonOptional",(e,t)=>{nC.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function EA(e,t){return new hk({type:"nonoptional",innerType:e,...Je(t)})}const CA=ge("ZodCatch",(e,t)=>{sC.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function IA(e,t){return new CA({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const AA=ge("ZodPipe",(e,t)=>{rC.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kI(e,n,r,i),e.in=t.in,e.out=t.out});function n0(e,t){return new AA({type:"pipe",in:e,out:t})}const TA=ge("ZodReadonly",(e,t)=>{iC.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function MA(e){return new TA({type:"readonly",innerType:e})}const $A=ge("ZodCustom",(e,t)=>{aC.init(e,t),tn.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cI(e,n)});function RA(e,t={}){return XC($A,e,t)}function OA(e,t){return QC(e,t)}const mh=Oa("type",[z({type:dt("text"),text:_()}),z({type:dt("reasoning"),text:_()}),z({type:dt("image"),name:_().optional(),mediaType:_().optional(),width:se().optional(),height:se().optional(),attachmentId:_().optional(),bytes:se().optional()}),z({type:dt("file"),name:_().optional(),size:se().optional(),mediaType:_().optional()}),z({type:dt("tool-call"),callId:_(),name:_(),arguments:_()}),z({type:dt("other"),kind:_()})]),s0=z({inputTokens:se(),outputTokens:se(),totalTokens:se().optional(),cacheReadTokens:se().optional(),cacheWriteTokens:se().optional(),reasoningTokens:se().optional()}),r0=z({firstChunkAt:se().optional(),firstTokenAt:se().optional(),lastChunkAt:se().optional(),tokenChunks:se()}),i0=z({message:_(),code:_().optional()}),zA=z({kind:_(),message:_().optional()}),PA=z({kind:_(),human:be(),summary:_().optional()}),$n={seq:se(),time:se()},kp=Oa("type",[z({...$n,type:dt("turn/start"),turn:se()}),z({...$n,type:dt("turn/end"),turn:se(),reason:zA}),z({...$n,type:dt("step/start"),turn:se(),step:se()}),z({...$n,type:dt("step/end"),turn:se(),step:se()}),z({...$n,type:dt("user/message"),messageId:_(),content:ue(mh),origin:PA,requestId:_().optional(),replacesHistory:be().optional()}),z({...$n,type:dt("system/message"),turn:se(),step:se(),text:_()}),z({...$n,type:dt("assistant/message"),turn:se(),step:se(),messageId:_(),content:ue(mh),timing:r0,usage:s0.optional(),interrupted:be().optional(),provider:_().optional(),model:_().optional()}),z({...$n,type:dt("assistant/attempt"),turn:se(),step:se(),timing:r0,error:i0.optional()}),z({...$n,type:dt("tool/call"),turn:se(),step:se(),callId:_(),name:_(),arguments:_()}),z({...$n,type:dt("tool/result"),turn:se(),step:se(),callId:_(),isError:be(),content:ue(mh),error:i0.optional()}),z({...$n,type:dt("request/header"),provider:_().optional(),model:_().optional(),reasoningEffort:_().optional(),toolNames:ue(_()),reason:_()}),z({...$n,type:dt("compaction/start"),compactionId:_(),turn:se().nullable()}),z({...$n,type:dt("compaction/summary"),compactionId:_(),shadowedTokenCount:se(),provider:_().optional(),model:_().optional(),usage:s0.optional()}),z({...$n,type:dt("compaction/end"),compactionId:_(),turn:se().nullable(),error:_().optional()}),z({...$n,type:dt("approval/asked"),approvalId:_(),toolName:_(),callId:_().optional(),reason:_().optional()}),z({...$n,type:dt("approval/decided"),approvalId:_(),outcome:_()}),z({...$n,type:dt("session/title"),title:_()}),z({...$n,type:dt("unknown"),upstreamType:_(),data:yp()})]),pk=Oa("type",[z({type:dt("start"),attemptId:_(),turn:se(),step:se(),afterSeq:se()}),z({type:dt("delta"),attemptId:_(),time:se(),kind:Le(["text","reasoning","tool-args"]),index:se(),text:_(),callId:_().optional(),toolName:_().optional()}),z({type:dt("end"),attemptId:_(),outcome:Le(["committed","abandoned"]),seq:se().optional()})]),LA=z({attemptId:_(),turn:se(),step:se(),afterSeq:se(),deltas:ue(pk.options[1])}),DA=z({index:se().int().min(0),name:_(),running:be(),ready:be(),adb:_().optional()}),FA=z({kind:Le(["mumu"]),name:_(),manager:_(),version:_().optional(),instances:ue(DA),error:_().optional()}),mk=z({mumuManager:_().optional(),instance:se().int().min(0).max(63),manualAddress:_().regex(/^[\w.-]+:\d{1,5}$/).optional(),adbPath:_().optional(),autoStart:be(),bootTimeoutSeconds:se().int().min(30).max(900)});z({providers:ue(FA),settings:mk,selection:z({label:_(),address:_().optional(),problem:_().optional()})});z({refresh:be().optional()}),z({index:se().int().min(0).optional()}),z({address:_(),label:_()}),z({index:se().int().min(0).optional()}),z({}),mk.partial().extend({mumuManager:_().nullable().optional(),manualAddress:_().regex(/^[\w.-]+:\d{1,5}$/).nullable().optional(),adbPath:_().nullable().optional()});z({});const wm=Le(["maafw-pi","cli","gui-config","generic-process","visual"]),Et=_().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/,"use lowercase letters, digits, dot, dash or underscore (max 64)"),$l=_().trim().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,"use owner/repo"),gh=_().trim().regex(/^[A-Za-z0-9_.-]{1,100}$/,"use the resource id, e.g. MAA or BGI"),BA=Oa("kind",[z({kind:dt("github"),repo:_()}),z({kind:dt("mirrorchyan"),rid:_(),platform:be(),os:be().optional(),arch:be().optional()}),z({kind:dt("local"),path:_()})]),UA=z({version:_(),dir:_(),installedAt:se(),asset:z({name:_(),size:se()}).optional(),current:be()}),HA=Le(["ok","missing","outdated","unknown","unsupported"]),ZA=z({kind:_(),label:_(),required:_().optional(),status:HA,found:_().optional(),detail:_().optional(),fix:z({kind:Le(["auto","installer","manual"]),description:_(),needsAdmin:be()}).optional()}),VA=z({checkedAt:se(),ok:be(),items:ue(ZA)}),WA=z({executables:ue(_()),markers:ue(_()),family:wm.optional()}),a0=Le(["install","pack","known","user"]),qA=z({github:z({repo:_(),from:a0}).optional(),mirrorchyan:z({rid:_(),from:a0}).optional()}),GA=z({version:_(),from:_()}),KA=z({state:Le(["running","done","failed"]),at:se(),text:_().optional(),sessionId:_().optional()}),YA=z({id:_(),name:_(),source:BA,packId:_().optional(),family:wm.optional(),current:_().optional(),dir:_().optional(),versions:ue(UA),env:VA.optional(),probe:WA.optional(),update:z({latest:_(),available:be(),checkedAt:se()}).optional(),channels:qA,known:_().optional(),localVersion:GA.optional(),undo:z({from:_().optional(),to:_(),at:se()}).optional(),jobId:_().optional(),addedAt:se(),summary:KA.optional(),packReview:z({from:_().optional(),to:_()}).optional(),optimize:z({runs:se(),at:se().optional(),due:Le(["runs","updated"]).optional()}).optional()}),XA=z({id:_(),name:_(),description:_().optional(),repo:_().optional(),mirrorchyan:_().optional(),family:wm.optional(),builtin:be(),installed:be(),error:_().optional()});z({rid:_(),version:_(),platform:be(),os:be().optional(),arch:be().optional(),name:_().optional(),description:_().optional(),repo:_().optional()});const wp=z({rid:_(),name:_(),description:_(),repo:_().optional(),url:_().optional(),installed:be(),known:be()}),QA=z({id:_(),name:_(),repo:_().optional(),mirrorchyan:_().optional(),installed:be()}),JA=z({name:_(),size:se(),downloadUrl:_(),digest:_().optional()}),eT=z({tag:_(),name:_(),prerelease:be(),publishedAt:_().optional(),url:_().optional(),assets:ue(JA),suggestedAsset:_().optional(),notes:_().optional()}),tT=Le(["queued","resolving","downloading","verifying","extracting","checking","running","done","failed","cancelled"]),nT=z({sessionId:_(),state:Le(["running","failed"]),reason:_().optional()}),sT=z({scriptId:_(),name:_(),kind:Le(["nsis","inno"]),version:_(),dir:_(),update:be(),at:se(),agent:nT.optional()}),rT=z({id:_(),kind:Le(["install","update","env-fix"]),scriptId:_(),phase:tT,message:_().optional(),received:se().optional(),total:se().optional(),version:_().optional(),error:_().optional(),setup:z({kind:Le(["nsis","inno"]),dir:_(),sessionId:_().optional()}).optional(),startedAt:se(),endedAt:se().optional()}),o0=z({apiBase:vp({protocol:/^https?$/}),downloadMirror:_().trim().max(300),mirrorFallback:be(),tokenRef:_().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),keepVersions:se().int().min(1).max(10),includePrereleases:be(),cdkRef:_().regex(/^[A-Za-z_][A-Za-z0-9_]*$/)});z({});z({id:Et});z({scripts:ue(YA),packs:ue(XA),known:ue(QA),setups:ue(sT).default([]),toolsDir:_()}),z({query:_().trim().min(1).max(200)}),z({items:ue(z({repo:_(),description:_().optional(),stars:se(),packId:_().optional()}))}),z({repo:$l,limit:se().int().min(1).max(30).optional()}),z({repo:_(),packId:_().optional(),releases:ue(eT)}),z({repo:$l.optional(),mirrorchyan:gh.optional(),tag:_().min(1).max(200).optional(),asset:_().min(1).max(300).optional(),branch:_().min(1).max(200).optional(),id:Et.optional()}).refine(e=>e.repo===void 0!=(e.mirrorchyan===void 0),"give either repo or mirrorchyan"),z({jobId:_(),scriptId:_()}),z({current:_().optional(),latest:_(),available:be()}),z({jobId:_().optional(),upToDate:be()}),z({id:Et,repo:$l.nullable().optional(),mirrorchyan:gh.nullable().optional(),reset:ue(Le(["repo","mirrorchyan"])).optional()}),z({items:ue(wp.extend({by:Le(["repo","name"])})),from:Le(["mirrorchyan","builtin"])}),z({rid:gh}),z({query:_().trim().max(100)}),z({items:ue(wp),from:Le(["mirrorchyan","builtin"]),fetchedAt:se().optional()}),z({id:_(),decision:Le(["check","keep"])}),z({sessionId:_().optional()}),z({id:Et,version:_().optional()}),z({dir:_()}),z({sessionId:_()}),z({path:_().trim().min(1).max(1e3),id:Et.optional(),name:_().trim().min(1).max(100).optional(),packId:Et.optional()}),z({id:Et,decision:Le(["run","keep"])}),z({sessionId:_().optional()}),z({id:Et}),z({sessionId:_()}),z({id:Et,deleteFiles:be().optional()}),z({id:Et,kind:_().min(1).max(64)}),z({jobId:_()}),z({items:ue(rT)}),z({jobId:_()}),o0.extend({tokenConfigured:be(),cdkConfigured:be()}),z({ok:be(),message:_(),expiresAt:se().optional()}),o0.partial();z({id:_().optional()});const iT=z({packId:_(),scriptId:_(),proposedAt:se(),sessionId:_().optional(),summary:_(),docs:ue(z({source:_(),used:_()})).optional(),noDocs:_().optional(),manifest:_(),skill:_(),current:z({manifest:_(),skill:_().optional(),builtin:be()}).optional(),tasks:ue(z({id:_(),title:_()}))});z({scriptId:Et.optional()}),z({items:ue(iT)}),z({packId:Et}),z({packId:_(),dir:_()}),z({packId:Et}),z({});z({packId:_().optional()});const aT=z({scriptId:_(),dir:_(),grantedAt:se(),expiresAt:se()});z({}),z({items:ue(aT),blocked:se()}),z({scriptId:Et,minutes:se().int().min(1).max(240)}),z({scriptId:Et}),z({});z({}),z({toolName:_(),target:_(),sessionId:_().optional(),at:se()});const oT=Le(["error","warning","failed","stalled","overtime"]),lT=z({at:se(),action:Le(["reconnect-adb","restart","stop","screenshot","notify","resolve","intervene"]),by:Le(["rule","user","agent"]),ok:be(),detail:_()}),cT=z({id:_(),runId:_(),scriptId:_(),scriptName:_(),taskId:_(),taskTitle:_(),kind:oT,severity:Le(["warning","error"]),tag:_(),title:_(),detail:_(),lines:ue(_()),status:Le(["open","resolved"]),resolution:_().optional(),createdAt:se(),updatedAt:se(),steps:ue(lT),screenshot:be()}),uT=z({seconds:se().int().min(5).max(24*3600),by:Le(["learned","agent","user"]),note:_().max(300).optional(),samples:ue(se().min(0)).max(10).default([]),at:se()}),dT=z({defaultStallSeconds:se().int().min(0).max(24*3600),scriptStall:di(_(),uT),notifyWarnings:be(),screenshot:be(),intervene:Le(["off","diagnose","act"]),interventionsPerDay:se().int().min(0).max(200)});z({status:Le(["open","all"]).optional(),runId:_().optional(),limit:se().int().min(1).max(500).optional()}),z({items:ue(cT)}),z({incidentId:_(),action:Le(["stop","retry","resolve","resume"])}),z({incidentId:_()}),z({mime:dt("image/png"),data:_()}),z({}),dT.partial();const fT="ADG_FEISHU_APP_SECRET",hT="ADG_QQBOT_APP_SECRET",Np=z({id:_(),label:_(),ok:be().nullable(),detail:_().optional()}),pT=z({id:_(),name:_(),state:Le(["off","connecting","ready","error"]),detail:_().optional(),recipients:se().int().min(0),checks:ue(Np)}),mT=z({openId:_().min(1),name:_().optional(),addedAt:se()}),gT=z({enabled:be(),appId:_().optional(),domain:Le(["feishu","lark"]),allowedUsers:ue(mT),chatId:_().optional(),otherApprovals:be()}),xT=z({openId:_(),at:se(),text:_()});z({settings:gT,secretConfigured:be(),pending:ue(xT)});const vT=z({openId:_().min(1),name:_().optional(),addedAt:se()}),yT=z({enabled:be(),appId:_().optional(),allowedUsers:ue(vT)}),bT=z({openId:_(),at:se(),text:_()});z({settings:yT,secretConfigured:be(),pending:ue(bT)});const gk=z({id:_(),title:_(),text:_(),severity:Le(["info","success","warning","error"]),at:se(),actions:ue(z({id:_(),label:_(),style:Le(["primary","danger","default"]).optional()})),channels:ue(_()),image:be().optional(),done:_().optional(),acted:z({by:_(),label:_(),result:_(),at:se()}).optional()});z({}),z({channels:ue(pT)}),z({}),z({items:ue(z({sessionId:_(),channel:_(),user:_()}))}),z({}),z({items:ue(gk)}),z({noticeId:_(),actionId:_()}),z({result:_()}),z({channel:_().optional()}),z({sent:ue(_()),failed:ue(z({channel:_(),error:_()}))}),z({}),z({enabled:be().optional(),appId:_().trim().regex(/^cli_[0-9a-fA-F]{16}$/,"App ID 是 cli_ 加 16 位字母数字,在「凭证与基础信息」里复制").nullable().optional(),domain:Le(["feishu","lark"]).optional(),chatId:_().trim().regex(/^oc_[A-Za-z0-9]+$/,"群 ID 以 oc_ 开头").nullable().optional(),otherApprovals:be().optional()}),z({openId:_().trim().regex(/^ou_[A-Za-z0-9]+$/,"open_id 以 ou_ 开头"),name:_().max(40).optional()}),z({openId:_()}),z({}),z({checks:ue(Np)}),z({}),z({enabled:be().optional(),appId:_().trim().regex(/^\d{6,20}$/,"AppID 是一串数字,在 QQ 开放平台「开发设置」里复制").nullable().optional()}),z({openId:_().trim().regex(/^[0-9A-Za-z_-]{8,64}$/,"user_openid 是一串字母数字(机器人回复你的那条消息里有)"),name:_().max(40).optional()}),z({openId:_()}),z({}),z({checks:ue(Np)});z({}),z({item:gk});const ga=_().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,"小写字母、数字和短横线").max(64),Hl=_().regex(/^[A-Za-z0-9_-]{1,40}$/),Nm=_().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"时间写成 HH:MM,例如 04:30"),xk=z({retries:se().int().min(0).max(5).default(0),then:Le(["continue","stop"]).default("continue")}),ha={id:Hl,title:_().max(60).optional(),position:z({x:se(),y:se()}).optional(),onFailure:xk.optional(),waitForAll:be().optional()},kT=Oa("kind",[z({...ha,kind:dt("script-task"),scriptId:Et,taskId:_().min(1).max(64),params:di(_(),To([_(),se(),be()])).default({}),profile:_().min(1).max(64).optional()}),z({...ha,kind:dt("agent"),prompt:_().min(1).max(4e3)}),z({...ha,kind:dt("wait"),minutes:se().int().min(1).max(1440).optional(),until:Nm.optional()}).refine(e=>e.minutes===void 0!=(e.until===void 0),"等待节点写分钟数或时间其中一个"),z({...ha,kind:dt("notify"),text:_().min(1).max(2e3)}),z({...ha,kind:dt("gate"),text:_().min(1).max(2e3)}),z({...ha,kind:dt("start")}),z({...ha,kind:dt("end")})]);function Vi(e){return e.kind==="start"||e.kind==="end"}function wT(e){const t=e.nodes.some(g=>g.kind==="start"),n=e.nodes.some(g=>g.kind==="end");if(t&&n)return e;const r=e.nodes.filter(g=>!Vi(g)),i=new Set(e.nodes.map(g=>g.id)),o=g=>{let v=g;for(let y=2;i.has(v);y++)v=`${g}${y}`;return i.add(v),v},c=r.filter(g=>g.position!==void 0).map(g=>g.position),u=Math.min(...c.map(g=>g.x)),d=Math.max(...c.map(g=>g.x)),f=c.length===0?40:Math.round(c.reduce((g,v)=>g+v.y,0)/c.length),p=[...e.nodes],m=[...e.edges];if(!t){const g=o("start");p.unshift({id:g,kind:"start",...c.length===0?{}:{position:{x:u-240,y:f}}});for(const v of r)e.edges.some(y=>y.to===v.id)||m.push({from:g,to:v.id,when:"success"})}if(!n){const g=o("end");p.push({id:g,kind:"end",...c.length===0?{}:{position:{x:d+300,y:f}}});for(const v of r)e.edges.some(y=>y.from===v.id)||m.push({from:v.id,to:g,when:"always"})}return{...e,nodes:p,edges:m}}const NT=z({from:Hl,to:Hl,when:Le(["success","failure","always"]).default("success")}),jm=z({enabled:be().default(!1),times:ue(Nm).max(12).default([]),days:ue(se().int().min(0).max(6)).max(7).default([]),catchUpMinutes:se().int().min(0).max(720).default(10),after:ga.optional()}),vk=Le(["none","sleep","hibernate","shutdown"]),xh=z({id:ga,name:_().min(1).max(60),description:_().max(500).optional(),nodes:ue(kT).max(60),edges:ue(NT).max(200).default([]),onFailure:xk.default({retries:0,then:"continue"}),schedule:jm.default({enabled:!1,times:[],days:[],catchUpMinutes:10}),stopEmulatorAfter:be().default(!1),closeGameAfter:be().default(!1),powerAfter:vk.default("none"),draft:be().optional(),createdAt:se().optional(),updatedAt:se().optional()}),jT=z({level:Le(["error","warning","info"]),nodeId:_().optional(),message:_()}),ST=z({ok:be(),issues:ue(jT),serialized:ue(z({a:_(),b:_(),resource:_()})),estimateMinutes:se().optional()}),_T=Le(["pending","waiting","running","succeeded","failed","skipped","cancelled"]),ET=z({state:_T,detail:_().optional(),runIds:ue(_()),attempts:se().int().min(0),startedAt:se().optional(),endedAt:se().optional()}),yk=z({kind:Le(["manual","schedule","autostart","agent","after"]),detail:_().optional()}),bk=z({id:_(),pipelineId:_(),pipelineName:_(),trigger:yk,from:_().optional(),state:Le(["running","succeeded","failed","cancelled"]),stopping:_().optional(),nodes:di(_(),ET),startedAt:se(),endedAt:se().optional(),outcome:_().optional()}),CT=z({id:_(),name:_(),description:_().optional(),nodes:se(),draft:be(),schedule:jm,updatedAt:se().optional(),lastRun:bk.pick({id:!0,state:!0,startedAt:!0,endedAt:!0}).optional()}),El=_().regex(/^task-[a-z0-9]{4,24}$/),l0=z({id:El,agent:_().min(1).max(64),title:_().trim().min(1).max(60),prompt:_().trim().min(1).max(4e3),schedule:jm,createdAt:se().optional(),updatedAt:se().optional()}),c0=z({id:_(),taskId:_(),trigger:yk,state:Le(["running","done","failed"]),outcome:_().optional(),startedAt:se(),endedAt:se().optional()}),kk=z({autostart:be(),autostartPipelines:ue(ga),autostartDelaySeconds:se().int().min(0).max(1800),skipIfRanToday:be(),firstStartOnly:be().default(!1),wakeToRun:be().default(!1),powerCountdownSeconds:se().int().min(10).max(600).default(60)}),wk={agent:_().optional()},IT=z({pipelineId:_(),pipelineName:_(),...wk,slot:_(),at:se(),outcome:Le(["fired","missed","skipped","failed"]),detail:_().optional()}),AT=z({awake:be(),pending:z({action:vk.exclude(["none"]),pipelineName:_(),at:se().optional()}).optional()});z({settings:kk,autostart:z({available:be(),registered:be(),detail:_().optional()}),autostarted:be(),wake:z({available:be(),registered:be(),next:se().optional(),detail:_().optional()}),power:AT,upcoming:ue(z({pipelineId:_(),pipelineName:_(),at:se(),...wk})),history:ue(IT)});z({}),z({items:ue(CT)}),z({id:ga}),z({pipeline:xh}),z({pipeline:xh,check:ST}),z({id:ga}),z({}),z({pipeline:xh}),z({id:ga,from:Hl.optional()}),z({runId:_()}),z({}),z({pipelineId:ga.optional(),limit:se().int().min(1).max(100).optional()}),z({items:ue(bk)}),z({runId:_(),nodeId:Hl,decision:Le(["continue","stop"])}),z({}),z({}),kk.partial(),z({}),z({}),z({agent:_().optional()}),z({items:ue(l0.extend({lastRun:c0.optional()}))}),z({task:l0.extend({id:El.optional()})}),z({id:El}),z({}),z({id:El}),z({id:El}),z({items:ue(c0)});z({}),z({}),z({});const TT=Le(["running","resolved","retried","gave-up","taken-over","timeout","failed"]),MT=z({id:_(),incidentId:_().optional(),runId:_().optional(),title:_(),mode:Le(["diagnose","act"]),state:TT,sessionId:_().optional(),paused:be(),summary:_().optional(),startedAt:se(),endedAt:se().optional()});z({limit:se().int().min(1).max(100).optional()}),z({items:ue(MT)}),z({id:_()}),z({id:_(),then:Le(["resume","restart","stop"])});const $T=z({id:_(),game:_(),name:_(),startsAt:se().optional(),endsAt:se().optional(),shopEndsAt:se().optional(),url:_().optional(),kind:_().optional(),description:_().optional(),cover:_().optional(),site:z({source:_(),name:_(),at:se()}).optional(),sources:ue(z({id:_(),name:_(),at:se(),web:be(),endsAt:se().optional()})).optional(),screen:z({at:se(),remaining:_().optional(),endsAt:se().optional(),evidence:be(),sessionId:_().optional()}).optional(),todo:ue(_()),done:ue(_()),progress:_().optional(),finished:z({at:se()}).optional(),mismatch:_().optional()}),RT=z({id:_(),name:_(),homepage:_().optional(),auto:be(),added:be().optional()}),OT=z({id:_(),name:_(),aliases:ue(_()),scripts:ue(_()),timezone:_(),screen:z({target:Le(["emulator","window"]),window:_().optional()}).optional(),sources:ue(RT),builtin:be(),art:_().optional(),followed:be().optional(),version:z({name:_(),title:_().optional(),startsAt:se().optional(),endsAt:se().optional(),cover:_().optional(),source:_(),at:se()}).optional(),pools:ue(z({name:_(),type:_().optional(),startsAt:se().optional(),endsAt:se(),cover:_().optional(),up:ue(_())})).optional(),refreshed:z({at:se(),ok:be(),count:se(),detail:_().optional()}).optional(),reading:z({state:Le(["running","done","failed"]),at:se(),sessionId:_().optional(),summary:_().optional()}).optional(),webReading:z({state:Le(["running","done","failed"]),at:se(),sessionId:_().optional(),summary:_().optional()}).optional()}),u0=z({report:z({enabled:be(),at:Nm,games:ue(_()),soonDays:se().int().min(1).max(30),ai:be()}),followed:ue(_())}),zT=z({lastSentAt:se().optional(),lastDay:_().optional(),lastResult:_().optional(),lastText:_().optional(),next:se().optional()});z({}),z({games:ue(OT),activities:ue($T),settings:u0,report:zT}),z({game:_().optional()}),z({results:ue(z({game:_(),ok:be(),count:se(),detail:_().optional()}))}),z({game:_(),how:Le(["screen","web"]).optional(),source:_().optional()}),z({sessionId:_()}),z({}),z({title:_(),text:_()}),z({}),z({channels:ue(_()),text:_()}),z({report:u0.shape.report.partial().optional()}),z({activityId:_()}),z({mediaType:_(),data:_()}),z({url:_().url()}),z({mediaType:_(),data:_()}),z({name:_().min(1).max(60)}),z({sessionId:_()}),z({game:_()}),z({items:ue(wp),from:Le(["mirrorchyan","builtin"])}),z({game:_(),url:_().url().refine(e=>/^https?:\/\//.test(e),"只能是 http 或 https 网址"),name:_().max(30).optional()}),z({source:_(),sessionId:_()}),z({game:_(),source:_()}),z({}),z({}),z({games:ue(z({sra:_(),name:_(),followed:be(),pack:_().optional()}))}),z({sra:_(),follow:be()}),z({}),z({activityId:_(),todo:ue(_().min(1).max(80)).max(30).optional(),done:ue(_().min(1).max(80)).max(30).optional(),finished:be().optional()}),z({activityId:_()}),z({});z({game:_().optional()});const Nk=Le(["ask","full"]),jk=Le(["default","allow","ask","deny"]),PT=[{id:"pipelines-edit",title:"编辑流水线和定时",description:"起草、修改流水线,设定时间(schedule_set),以及 dsh 自己的定时任务。",tools:["pipeline_draft","schedule_set","schedule_create","schedule_update","schedule_delete"]},{id:"run",title:"运行流水线和脚本",description:"启动、停止流水线和脚本任务。",tools:["pipeline_run","script_run","script_stop"]},{id:"scripts-config",title:"改脚本配置",description:"修改脚本的配置副本、导入配置、新建选项、打开脚本自己的设置界面、设置游戏位置。",tools:["script_config_set","script_config_import","script_choice_create","script_settings","game_path_set"]},{id:"scripts-install",title:"安装、更新、删除脚本",description:"从 GitHub 安装、更新、回滚、删除脚本,运行脚本的安装程序,导入本地脚本,修复运行环境,起草脚本包。",tools:["script_install","script_update","script_rollback","script_remove","script_setup_run","script_import","script_env_fix","pack_propose"]},{id:"screen",title:"操作屏幕和模拟器",description:"在游戏窗口或模拟器里点击、输入、按键、滑动、切换窗口(截图不算)。",tools:["screen_tap","screen_type","screen_key","screen_scroll","screen_swipe","window_focus"]},{id:"games",title:"启动、关闭游戏和模拟器",description:"打开、关掉游戏,启动、关闭、安装、设置模拟器。",tools:["game_launch","game_close","emulator_start","emulator_stop","emulator_install","emulator_configure"]},{id:"game-records",title:"记录活动、添加游戏",description:"把读到的活动写进日历,给新游戏建游戏包。",tools:["game_record","game_add"]},{id:"skills",title:"保存技能",description:"把做法存成技能,以后的对话都会用到。",tools:["skill_save"]},{id:"web",title:"上网查资料",description:"读网页、搜索。",tools:["web_fetch","web_search"]},{id:"shell",title:"运行命令、改文件",description:"dsh 自带的命令行和文件编辑。只在它请求确认时按这里的设置处理(沙箱里的普通命令不会请求)。",tools:["pwsh","bash","edit","write"],approvalOnly:!0}];z({mode:Nk,since:se().optional(),areas:di(_(),jk).default({}),recent:ue(z({at:se(),sessionId:_(),toolName:_(),reason:_().optional()}))});z({}),z({mode:Nk}),z({area:_(),policy:jk});const LT=z({label:_(),description:_().optional()}),DT=z({id:_(),question:_(),detail:_().optional(),header:_().optional(),options:ue(LT).optional(),multiSelect:be().optional()});z({questionId:_(),sessionId:_(),callId:_().optional(),questions:ue(DT)});const Sk=z({id:_(),selected:ue(_()),custom:_().optional()}),FT=Le(["answered","cancelled","unavailable"]);z({questionId:_(),answers:ue(Sk)}),z({});z({questionId:_(),outcome:FT,answers:ue(Sk).optional()});const BT=z({pid:se().int(),label:_(),dataDir:_().optional(),startedAt:se(),warnings:ue(_())});z({others:ue(BT)});z({});const _k=z({scripts:ue(_()).optional(),games:ue(_()).optional()}),d0=z({name:_(),description:_(),whenToUse:_().optional(),source:_(),provider:_(),path:_().optional(),modelInvocable:be(),userInvocable:be(),owner:_k.optional(),removable:be().optional()}),Ek=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,jp=48;z({}),z({skills:ue(d0)}),z({name:_()}),d0.extend({content:_()}),z({name:_().regex(Ek).max(jp),description:_().trim().min(10).max(400),content:_().trim().min(20).max(2e4),scripts:ue(_().min(1).max(64)).max(20).optional(),games:ue(_().min(1).max(64)).max(20).optional(),replace:be().optional()}),z({name:_(),replaced:be()}),z({name:_()}),z({});z({});const vh=z({repo:$l,branch:_().trim().min(1).max(100).regex(/^[\w./-]+$/)}),f0=z({name:_(),description:_(),title:_().optional(),kind:Le(["game","script","general"]),games:ue(_()),scripts:ue(_()),repo:_(),path:_(),hash:_(),installed:z({at:se(),modified:be(),update:be()}).optional(),blocked:_().optional()}),yh=z({name:_().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});z({refresh:be().optional()}),z({items:ue(f0),repos:ue(vh),errors:ue(_()),fetchedAt:se().optional()}),yh.extend({repo:$l.optional()}),yh.extend({resolve:Le(["keep","replace","merge"]).optional()}),z({state:Le(["current","updated","kept","conflict","merging"]),item:f0,backup:_().optional(),sessionId:_().optional()}),z({mine:_(),theirs:_()}),z({}),yh.extend({owner:_k.nullable()}),z({}),z({repos:ue(vh).min(1).max(10)}),z({repos:ue(vh)});z({});const UT=Le(["default","concise","patient","lively","buddy","butler"]),bh=z({style:UT,name:_().max(20).optional(),callUser:_().max(20).optional(),custom:_().optional()});z({}),z({persona:bh,prompt:_()}),z({persona:bh}),z({persona:bh,prompt:_()});const HT=80,Ck=50,Ik=95,Sp=z({auto:be(),threshold:se().int().min(Ck).max(Ik)});z({settings:Sp,applied:Sp});z({}),z({settings:Sp});const ZT=Le(["starting","running","stopping","succeeded","failed","cancelled"]),VT=z({type:Le(["string","integer","number","boolean"]),default:To([_(),se(),be()]).optional(),enum:ue(To([_(),se()])).optional(),description:_().optional(),choices:ue(z({value:_(),label:_(),detail:_().optional()})).optional(),canCreate:be().optional()}),WT=z({mode:Le(["auto","platform","off"]),pcLaunch:Le(["program","maaend"]).optional(),pcRegion:Le(["CN","Global","Bilibili","TapTap","Steam","Epic"]).optional(),pcExe:_().optional(),pcProcess:_().optional(),androidPackage:_().optional()});z({settings:WT,game:z({name:_().optional(),androidPackage:_().optional(),pcProcess:_().optional(),selfLaunch:_()}),uses:z({adb:be(),desktop:be()})});const qT=z({id:_(),title:_(),description:_().optional(),utterances:ue(_()),params:di(_(),VT),input:Le(["desktop","window","adb","none"]),account:_().optional(),expectedDuration:_().optional()}),Rr=_().trim().min(1).max(64),_p=z({id:_(),name:_(),createdAt:se().optional()}),Ak=z({current:_(),items:ue(_p)}),GT=z({id:_(),scriptId:_(),scriptName:_(),taskId:_(),taskTitle:_(),params:di(_(),To([_(),se(),be()])),state:ZT,outcome:_().optional(),startedAt:se(),endedAt:se().optional(),exitCode:se().optional(),command:ue(_()),resources:ue(_()),tags:ue(_()),warnings:ue(_()),kind:Le(["task","settings"]),retryOf:_().optional(),halted:be().optional(),profile:_().optional(),profileName:_().optional()}),Tk=z({at:se(),source:_(),text:_(),level:Le(["info","progress","done","warning","error"]).optional(),tag:_().optional()});z({scriptId:Et,profile:Rr.optional()}),z({tasks:ue(qT),runnable:be(),problem:_().optional()}),z({scriptId:Et,taskId:_().min(1).max(64),params:di(_(),To([_(),se(),be()])).optional(),profile:Rr.optional()}),z({runId:_()}),z({}),z({scriptId:Et.optional()}),z({items:ue(GT)}),z({runId:_(),limit:se().int().min(1).max(2e3).optional()}),z({lines:ue(Tk)}),z({scriptId:Et}),z({scriptId:Et,name:_().trim().min(1).max(30),from:Oa("kind",[z({kind:dt("copy"),profile:Rr}),z({kind:dt("original")}),z({kind:dt("folder"),dir:_().trim().min(1).max(500)})])}),z({profile:_p,files:ue(_()),list:Ak}),z({scriptId:Et,profile:Rr,name:_().trim().min(1).max(30).optional(),current:dt(!0).optional()}),z({scriptId:Et,profile:Rr}),z({scriptId:Et,profile:Rr.optional()}),z({importedAt:se().optional(),dir:_(),profile:_p,files:ue(z({file:_(),local:be(),original:be(),changed:be()})),drift:ue(_())}),z({scriptId:Et,file:_().min(1),profile:Rr.optional()}),z({file:_(),content:_(),truncated:be()}),z({scriptId:Et,profile:Rr.optional()}),z({imported:ue(_())}),z({scriptId:Et,profile:Rr.optional()}),z({runId:_()}),z({}),z({scriptId:Et,taskId:_().min(1),param:_().min(1),name:_().trim().min(1).max(40),profile:Rr.optional()}),z({value:_()}),z({scriptId:Et}),z({scriptId:Et,mode:Le(["auto","platform","off"]).optional(),pcLaunch:Le(["program","maaend"]).nullable().optional(),pcRegion:Le(["CN","Global","Bilibili","TapTap","Steam","Epic"]).nullable().optional(),pcExe:_().trim().nullable().optional(),pcProcess:_().trim().nullable().optional(),androidPackage:_().trim().regex(/^[A-Za-z][\w]*(\.[A-Za-z_][\w]*)+$/,"安卓包名像 com.example.game").nullable().optional()}),z({scriptId:Et}),z({exe:_().optional(),candidates:ue(z({path:_(),source:_()}))});z({scriptId:_(),list:Ak}),z({runId:_(),lines:ue(Tk)});const KT=1,kh=_().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"credential names use letters, digits and underscores"),Mk=z({configured:be(),source:_().optional(),writable:be()}),Ep="DEEPSEEK_API_KEY",YT=z({id:_(),version:se().int().positive()}),$k=z({id:_(),title:_().nullable(),updatedAt:se(),running:be(),blank:be(),live:be(),cwd:_().optional(),parentId:_().optional(),origin:Le(["subagent"]).optional(),role:_().optional(),requestedBy:_().optional(),home:_().optional()}),Rk=z({id:_(),name:_(),description:_(),order:se()}),Ok=z({id:_(),requestId:_().optional(),text:_(),images:se().int().optional(),placement:Le(["next-turn","next-step"])}),zk=z({contextWindow:se().int().positive(),usedTokens:se().int().nonnegative(),breakdown:z({systemTokens:se().int().nonnegative(),toolsTokens:se().int().nonnegative(),messageTokens:se().int().nonnegative()}).optional()}),XT=z({id:_(),createdAt:se(),cwd:_().optional(),parentId:_().optional(),agentPreset:_().optional()}),xa=z({provider:_(),model:_(),reasoningEffort:_().optional()}),Pk=z({id:_(),fromSession:_(),callId:_().optional(),by:_(),to:_(),toSession:_(),title:_(),task:_(),expecting:_().optional(),state:Le(["running","done","failed"]),reply:_().optional(),startedAt:se(),endedAt:se().optional()}),QT=z({id:_(),agent:_(),sessionId:_(),title:_(),prompt:_(),rule:_(),repeats:be(),next:se()});z({default:xa,groups:ue(z({id:_(),name:_(),models:ue(z({id:_(),name:_(),description:_().optional(),efforts:ue(z({id:_(),name:_()})),defaultEffort:_().optional()}))})),failures:ue(z({id:_(),name:_(),message:_()}))});const JT=z({lastUsed:xa.nullable(),next:xa.nullable()}),wh=Le(["openai-completions","openai-responses","anthropic-messages"]),eM=_().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"use lowercase letters, digits and single hyphens, starting with a letter"),Cp=z({id:_().min(1),name:_().optional(),contextWindow:se().int().positive().optional(),maxTokens:se().int().positive().optional(),input:ue(Le(["text","image"])).optional(),efforts:ue(_().min(1)).optional()}),tM=z({id:_(),displayName:_(),api:_().optional(),baseURL:_().optional(),models:ue(Cp),apiKeyRef:_().optional(),credential:Mk.optional(),declared:be(),active:be(),error:_().optional()}),Ip=35e5,nM=z({mediaType:Le(["image/png","image/jpeg","image/gif","image/webp"]),data:_().min(1).max(Ip).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix"),name:_().max(200).optional()});z({});z({accepted:dt(!0)});z({protocolVersion:se().int(),client:z({name:_(),version:_()})}),z({protocolVersion:se().int(),server:z({name:_(),version:_(),dsh:_().optional()}),capabilities:ue(YT)}),z({items:ue($k)}),z({cwd:_().optional(),focus:z({scripts:ue(_()).optional(),games:ue(_()).optional()}).optional(),role:_().optional()}),z({sessionId:_()}),z({sessionIds:ue(_()).max(60)}),z({items:ue(z({sessionId:_(),text:_().nullable()}))}),z({items:ue(Rk)}),z({agentId:_()}),z({sessionId:_()}),z({sessionId:_()}),z({items:ue(Pk)}),z({id:_()}),z({agent:_().optional()}),z({items:ue(QT)}),z({id:_()}),z({}),z({sessionId:_(),title:_().min(1)}),z({title:_()}),z({sessionId:_(),maxMessages:se().int().positive().optional()}),z({subscriptionId:_(),header:XT,cursor:se(),events:ue(kp),hasMore:be(),title:_().nullable(),live:LA.nullable(),queue:ue(Ok).optional(),context:zk.optional()}),z({subscriptionId:_()}),z({sessionId:_(),throughSeq:se(),beforeSeq:se(),maxMessages:se().int().positive().optional()}),z({events:ue(kp),hasMore:be()}),z({sessionId:_(),requestId:_(),text:_(),mode:Le(["queue","steer"]),images:ue(nM).max(4).optional()}).refine(e=>{var t;return e.text.trim()!==""||(((t=e.images)==null?void 0:t.length)??0)>0},"消息是空的"),z({sessionId:_()}),z({sessionId:_()}),z({compacted:be(),message:_()}),z({sessionId:_(),itemId:_(),action:Le(["steer","remove"])}),z({attachmentId:_(),mediaType:_(),bytes:se(),width:se(),height:se()}),z({mediaType:_(),data:_()}),z({sessionIds:ue(_())}),z({sessionId:_()}),z({sessionIds:ue(_())}),z({sessionId:_()}),z({sessionIds:ue(_())}),z({model:xa.nullable()}),z({model:xa.nullable()}),z({warning:_().optional()}),xa.extend({sessionId:_()}),z({selected:xa}),z({sessionId:_()}),z({approvalId:_(),decision:Le(["allow-once","reject"])}),z({refs:ue(kh).min(1).max(64)}),z({items:di(_(),Mk)}),z({ref:kh,value:_().min(1).max(4096)}),z({ref:kh}),z({providers:ue(tM),revision:se(),writable:be(),protocols:ue(wh),taken:ue(_())}),z({provider:_().optional(),baseURL:vp({protocol:/^https?$/}).optional(),api:wh.optional(),apiKey:_().min(1).max(4096).optional()}),z({models:ue(Cp)}),z({id:eM,create:be(),displayName:_().max(80).optional(),api:wh,baseURL:vp({protocol:/^https?$/}),models:ue(Cp).min(1),apiKey:_().min(1).max(4096).optional(),expectedRevision:se().optional()}),z({revision:se(),apiKeyRef:_().optional()}),z({id:_().min(1),removeKey:be().optional(),expectedRevision:se().optional()}),z({revision:se(),defaultReset:be()});Oa("kind",[z({kind:dt("upsert"),item:$k.partial().extend({id:_()})}),z({kind:dt("removed"),sessionId:_()})]);z({approvalId:_(),sessionId:_(),toolName:_(),callId:_().optional(),reason:_().optional(),displayReason:di(_(),_()).optional()});z({subscriptionId:_(),event:kp}),z({subscriptionId:_(),frame:pk}),z({subscriptionId:_(),reason:_()}),z({sessionId:_(),title:_().nullable()}),z({sessionId:_(),message:_()}),z({sessionId:_(),items:ue(Ok)}),z({sessionId:_(),context:zk.nullable()}),z({approvalId:_(),outcome:_()}),z({ref:_()}),z({sessionIds:ue(_())}),z({items:ue(Rk)}),z({item:Pk}),z({}),z({}),JT.extend({sessionId:_()});const mu={InternalError:-32603,NotInitialized:-32002};class pl extends Error{constructor(n,r,i){super(r);ut(this,"code");ut(this,"data");this.name="RpcError",this.code=n,this.data=i}toJSON(){return this.data===void 0?{code:this.code,message:this.message}:{code:this.code,message:this.message,data:this.data}}}function sM(e){if(typeof e!="object"||e===null||e.jsonrpc!=="2.0")return"invalid";const t=e;return typeof t.method=="string"?"id"in t?"request":"notification":"result"in t||"error"in t?"response":"invalid"}function Lk(e){try{const t=JSON.parse(e);for(const r of["command","cmd","path","file_path","pattern","query","url","description","prompt"]){const i=t[r];if(typeof i=="string"&&i!=="")return i.split(`
|
|
104
|
-
`)[0].slice(0,160)}const n=Object.values(t).find(r=>typeof r=="string");return typeof n=="string"?n.slice(0,160):""}catch{return e.slice(0,160)}}const Dk=["把这次走通的做法保存成技能(用 skill_save),让下次同样的事可以直接照着做、少调用模型。要求:","- 只写最后成功的路径,不写失败的尝试和闲聊;","- 写清楚适用场景(用户会怎么说)、一步一步的操作(用到的工具、命令、路径、参数照实写,会变的写成「把 X 换成…」)、怎样算成功、注意事项和踩过的坑;","- 名字用简短的英文小写加短横线,description 一两句话说清楚做什么、什么时候用;","- 分到对应的游戏和脚本:只有用某个脚本时才用得上的(它的配置、报错、日志),scripts 填脚本 id;和游戏本身有关、换个脚本也用得上的(游戏里的操作、界面、活动、机制),games 填游戏 id(用 game_list 查);和哪个游戏都无关才当通用技能;","- 保存后告诉我技能名,以及以后我说什么时会用到它。"].join(`
|
|
105
|
-
`);function rM(e,t,n){return[`优化脚本${e===""?":最近运行过的脚本(script_runs 看最近一周跑过哪些,一个一个来)":`「${e}」`}。把这段时间运行攒下的信息用起来,一次做完下面几件事:`,"1. 重新总结脚本包:script_tasks、script_help 看它现在有哪些任务和参数,script_runs、script_run_log 看最近的运行(成功的看正常流程和用时,失败的看原因);更新过版本就先用 script_changelog 读更新日志。对照它的脚本包,任务、参数、配置文件、完成和出错的日志文字、预计用时有不对或缺的,用原来的脚本包 id 提交 pack_propose(summary 写明依据);都对就不提交;","2. 改善监控时间:monitor_stall_check 看它正常运行时日志的节奏,按建议值和你看日志的判断用 monitor_stall_set 设它多久没新日志算卡住,note 写明依据(例如「战斗中最长 70 秒不输出」);","3. 把做过的步骤总结成技能,分到对应的游戏和脚本:运行和处理这个脚本时反复用到、已经走通的做法(常见报错怎么处理、怎么确认跑完、配置怎么改)用 skill_save 存成技能,scripts 填这个脚本的 id,只给它用;其中和游戏本身有关、别的脚本也用得上的(游戏里的操作、界面、活动、机制)单独存,games 填它玩的游戏 id(game_list 查),不填 scripts;已有的技能就合并更新(replace),不要重复存,没有值得存的就不存;","4. 不要运行脚本、不要改它的配置;最后用几句话告诉我:脚本包改了什么(草稿在「脚本」页等我确认)、卡住时间设成多少、存了或更新了哪些技能。"].join(`
|
|
106
|
-
`)}const Sm=[{name:"技能",aliases:["skill"],title:"把刚才走通的做法存成技能,下次少调用模型",expand:()=>Dk},{name:"资讯",aliases:["news"],title:"上网查游戏资讯:活动、版本、维护公告",arg:"游戏名(可选,不写就查游戏页上的游戏)",expand:e=>[`上网查${e===""?"我游戏页上的游戏":`「${e}」`}最近的资讯,按技能 web-reading:`,"1. 先 game_list、game_activities 看日历里已经有什么,不重复查;","2. 先用公开 API(SRA 公共 API、Wiki 的 api.php),没有再读官网公告列表页,只打开最近的活动、版本和维护公告;","3. 查到起止时间的活动用 game_record(source=site,写上 url)记进日历;","4. 最后按游戏列一下:正在进行、快结束、即将开始的活动,和其他值得知道的消息(新版本、维护、福利、兑换码)。"].join(`
|
|
107
|
-
`)},{name:"编排",aliases:["plan","pipeline"],title:"把脚本编成流水线(先起草,我确认后才生效)",arg:"想做什么(可选,例如「每天早上跑完三个游戏的日常」)",expand:e=>[`帮我把脚本编排成流水线:${e===""?"把我装好的各个脚本的日常任务排成每天能自动跑的流程":e}。按技能 pipeline-planning:`,"1. 先 system_info 看电脑配置(能不能同时跑几个游戏),pipeline_list 看已有的流水线,script_tasks 看各脚本有哪些任务;","2. 用 pipeline_draft 起草(草稿,我在「编排」页保存后才会按定时运行):模拟器和前台脚本能并行的并行,失败不要挡住别的;","3. 说清楚为什么这样排、哪些步骤并行、估计多久、建议定在几点跑。"].join(`
|
|
108
|
-
`)},{name:"诊断",aliases:["diagnose","why"],title:"分析脚本为什么失败,给出怎么改的建议",arg:"脚本名或运行 id(可选,不写就看最近失败的)",expand:e=>[`分析${e===""?"最近失败的脚本运行":`「${e}」`}为什么失败:`,"1. 用 script_runs 找到失败的那次运行,script_run_log 看日志(先按错误级别筛,再看出错前后);","2. 对照这个脚本包的技能说明原因:是脚本本身、配置、游戏状态(更新、公告、掉线)、模拟器 / ADB,还是电脑环境;","3. 给出怎么改:改哪项配置、游戏里要做什么、要不要重跑。先不要改任何东西、不要重跑,等我决定。"].join(`
|
|
109
|
-
`)},{name:"优化脚本",aliases:["optimize"],title:"用运行攒下的信息优化脚本:重新总结脚本包、调监控时间、把做过的步骤存成技能",arg:"脚本名(可选,不写就看最近运行过的)",expand:e=>rM(e)},{name:"压缩",aliases:["compact"],title:"压缩这个对话:较早的部分换成摘要,agent 会忘掉其中的细节",expand:()=>"",local:"compact"}];function iM(e){var n,r,i;const t=(r=(n=/^\/(\S+)/.exec(e.trim()))==null?void 0:n[1])==null?void 0:r.toLowerCase();return t===void 0||(i=Sm.find(o=>o.local!==void 0&&(o.name===t||o.aliases.includes(t))))==null?void 0:i.local}function aM(e,t){return`使用技能「${e}」:先用 skill 工具加载它,再按它的说明做${t===""?"。":`:${t}`}`}function oM(e,t){const n=e.trim(),r=/^\/(\S+)(?:\s+([\s\S]*))?$/.exec(n);if(r===null)return n;const i=r[1],o=(r[2]??"").trim(),c=Sm.find(d=>d.name===i.toLowerCase()||d.aliases.includes(i.toLowerCase()));if((c==null?void 0:c.local)!==void 0)return n;if(c!==void 0)return`${n}
|
|
110
|
-
|
|
111
|
-
${c.expand(o)}`;const u=t.find(d=>d.name===i);return u===void 0?n:`${n}
|
|
112
|
-
|
|
113
|
-
${aM(u.name,o)}`}function lM(e){if(!e.startsWith("/"))return;const t=e.indexOf(`
|
|
114
|
-
|
|
115
|
-
`);return t<0?void 0:{typed:e.slice(0,t),expansion:e.slice(t+2)}}function cM(e,t,n=!1){const r=/^\/(\S*)$/.exec(e);if(r===null)return[];const i=r[1].toLowerCase(),o=Sm.filter(d=>(n||d.local===void 0)&&[d.name,...d.aliases].some(f=>f.toLowerCase().includes(i))).map(d=>({kind:"command",name:d.name,description:d.title,...d.arg===void 0?{}:{arg:d.arg},command:d})),c=d=>d.toLowerCase().startsWith(i)?0:1,u=t.filter(d=>d.name.toLowerCase().includes(i)||i.length>0&&d.description.toLowerCase().includes(i)).sort((d,f)=>+(d.group===void 0)-+(f.group===void 0)||(d.group??"").localeCompare(f.group??"")||c(d.name)-c(f.name)||d.name.localeCompare(f.name)).map(d=>({kind:"skill",name:d.name,description:d.description,...d.group===void 0?{}:{group:d.group}}));return[...o,...u]}const uM=new Set(["issues","pulls","wiki","actions","discussions","blob","commits","commit","compare","security","pulse","graphs","network","settings","projects","stargazers","forks","watchers","tags","branches"]);function dM(e){var y,S;const t=e.trim().replace(/^<|>$/g,""),n=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/.exec(t);if(n!==null&&!t.includes(":"))return{repo:`${n[1]}/${n[2]}`};const r=/git@github\.com:([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/i.exec(t);if(r!==null)return{repo:`${r[1]}/${r[2]}`};const i=k=>{try{return decodeURIComponent(k)}catch{return k}},o=/raw\.githubusercontent\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/([^/?#]+)/i.exec(t);if(o!==null)return{repo:`${o[1]}/${o[2]}`,branch:i(o[3])};const c=/api\.github\.com\/repos\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)/i.exec(t);if(c!==null)return{repo:`${c[1]}/${c[2]}`};const u=t.toLowerCase().lastIndexOf("github.com/");if(u===-1)return;const f=t.slice(u+11).split(/[?#]/)[0].replace(/\/+$/,"").split("/");if(f.length<2||!/^[A-Za-z0-9_.-]+$/.test(f[0]))return;const p=f[1].replace(/\.git$/i,"");if(!/^[A-Za-z0-9_.-]+$/.test(p))return;const m=`${f[0]}/${p}`,[g,...v]=f.slice(2);if(g==="releases")return v[0]==="tag"&&v[1]!==void 0?{repo:m,tag:i(v.slice(1).join("/"))}:v[0]==="download"&&v.length>=3?{repo:m,tag:i(v.slice(1,-1).join("/")),asset:i(v.at(-1))}:{repo:m};if(g==="tree"&&v.length>0)return{repo:m,branch:i(v[0])};if(g==="archive"){const k=v.join("/").replace(/\.(zip|tar\.gz)$/i,""),w=(y=/^refs\/tags\/(.+)$/.exec(k))==null?void 0:y[1];if(w!==void 0)return{repo:m,tag:i(w)};const T=(S=/^refs\/heads\/(.+)$/.exec(k))==null?void 0:S[1];return T!==void 0?{repo:m,branch:i(T)}:{repo:m,tag:i(k)}}return g===void 0||uM.has(g)?{repo:m}:{repo:m}}const Fk="你",fM="(不用告诉用户)";function hM(e){return e.replace(/[。.\s]/g,"")===fM}const pM="(做完后你这一轮的最后一段回复会原样交回去:把结论写在那里。)";function mM(e){const[t="",...n]=e.split(`
|
|
116
|
-
`),r=/^(你在软件里点的:(.*))$/.exec(t),i=r===null?/^(([^():]{1,20})交给你的事:(.*))$/.exec(t):null;if(r===null&&i===null)return;const o=n[0]===pM;return{by:r!==null?Fk:i[1],title:r!==null?r[1]:i[2],returns:o,body:(o?n.slice(1):n).join(`
|
|
117
|
-
`).trim()}}function gM(e){const[t="",...n]=e.split(`
|
|
118
|
-
`),r=/^(「([^」]+)」(交回了|没有做完)([^()]{1,20}?)交给它的事:(.*))$/.exec(t);if(r===null)return;const i=n.join(`
|
|
119
|
-
`).trim(),o=i.lastIndexOf(`
|
|
120
|
-
|
|
121
|
-
(`);return{agent:r[1],ok:r[2]==="交回了",asker:r[3],title:r[4],reply:(o===-1?i:i.slice(0,o)).trim()}}function xM(e){return e.replace(/\s+/g," ").replace(/[()]/g,t=>t==="("?"(":")").trim()}function h0(e){const t=/^\[SCHEDULE REMINDER\]\n[\s\S]*?^reminder_prompt_json: (.*)$/m.exec(e);if(t!==null)return[yM(t[1])];const n=/^\[SCHEDULE REMINDER BATCH\]\n[\s\S]*?^reminders_json: (.*)$/m.exec(e);if(n!==null)try{return JSON.parse(n[1]).map(i=>String(i.reminder_prompt??"")).filter(i=>i!=="")}catch{return[]}}function vM(e){return e.length===0?"定时提醒":`定时提醒:${e.map(t=>xM(t)).join(";")}`}function yM(e){try{const t=JSON.parse(e);return typeof t=="string"?t:e}catch{return e}}const p0=1;var ii,xs,Di,ka,dd,ur,jo,So,Jl,hn,Ap,Tp,Mp,Bk,Uk,$p,Rp;class bM{constructor(t){Lt(this,hn);ut(this,"status",new zr({state:"idle",attempt:0}));ut(this,"server",new zr(null));Lt(this,ii);Lt(this,xs,null);Lt(this,Di,!1);Lt(this,ka,0);Lt(this,dd,1);Lt(this,ur,new Map);Lt(this,jo,new Map);Lt(this,So,new Set);Lt(this,Jl);Zt(this,ii,t)}get generation(){return Re(this,ka)}get ready(){return Re(this,Di)}start(){this.status.get().state!=="idle"&&this.status.get().state!=="stopped"||xt(this,hn,Mp).call(this)}stop(){clearTimeout(Re(this,Jl)),this.status.set({state:"stopped",attempt:0});const t=Re(this,xs);Zt(this,xs,null),xt(this,hn,$p).call(this,"connection stopped"),t==null||t.close(1e3,"client stopped")}on(t,n){let r=Re(this,jo).get(t);return r===void 0&&Re(this,jo).set(t,r=new Set),r.add(n),()=>{r.delete(n)}}onReady(t){return Re(this,So).add(t),Re(this,Di)&&queueMicrotask(()=>t(Re(this,ka))),()=>{Re(this,So).delete(t)}}call(t,n,r){return!Re(this,Di)&&t!=="initialize"?Promise.reject(new pl(mu.NotInitialized,"not connected to the gateway")):xt(this,hn,Ap).call(this,t,n,r)}}ii=new WeakMap,xs=new WeakMap,Di=new WeakMap,ka=new WeakMap,dd=new WeakMap,ur=new WeakMap,jo=new WeakMap,So=new WeakMap,Jl=new WeakMap,hn=new WeakSet,Ap=function(t,n,r){const i=Re(this,xs);if(i===null||i.readyState!==p0)return Promise.reject(new pl(mu.NotInitialized,"not connected to the gateway"));if((r==null?void 0:r.aborted)===!0)return Promise.reject(r.reason??new Error("aborted"));const o=Nv(this,dd)._++;return new Promise((c,u)=>{const d=Re(this,ii).callTimeoutMs??6e4,f=d>0?setTimeout(()=>{var g;(g=Re(this,ur).get(o))==null||g.reject(new pl(mu.InternalError,`${t} timed out`))},d):void 0,p=()=>{var g;Re(this,ur).has(o)&&(xt(this,hn,Tp).call(this,{jsonrpc:"2.0",method:"$/cancelRequest",params:{id:o}}),(g=Re(this,ur).get(o))==null||g.reject((r==null?void 0:r.reason)instanceof Error?r.reason:new Error("aborted")))};r==null||r.addEventListener("abort",p,{once:!0});const m=()=>{clearTimeout(f),r==null||r.removeEventListener("abort",p),Re(this,ur).delete(o)};Re(this,ur).set(o,{resolve:g=>{m(),c(g)},reject:g=>{m(),u(g)},cleanup:m}),xt(this,hn,Tp).call(this,{jsonrpc:"2.0",id:o,method:t,params:n})})},Tp=function(t){var n;((n=Re(this,xs))==null?void 0:n.readyState)===p0&&Re(this,xs).send(JSON.stringify(t))},Mp=function(){const t=this.status.get();this.status.set({state:t.attempt===0?"connecting":"reconnecting",attempt:t.attempt,...t.error===void 0?{}:{error:t.error}});let n;try{n=(Re(this,ii).createSocket??(r=>new WebSocket(r)))(Re(this,ii).url)}catch(r){xt(this,hn,Rp).call(this,r instanceof Error?r.message:String(r));return}Zt(this,xs,n),n.addEventListener("open",()=>{Re(this,xs)===n&&xt(this,hn,Bk).call(this,n)}),n.addEventListener("message",r=>{Re(this,xs)===n&&xt(this,hn,Uk).call(this,String(r.data))}),n.addEventListener("close",r=>{if(Re(this,xs)!==n)return;Zt(this,xs,null),xt(this,hn,$p).call(this,"connection lost");const i=typeof r.reason=="string"&&r.reason!==""?r.reason:`closed (${r.code??"?"})`;xt(this,hn,Rp).call(this,i)}),n.addEventListener("error",()=>{})},Bk=async function(t){try{const n=await xt(this,hn,Ap).call(this,"initialize",{protocolVersion:KT,client:Re(this,ii).clientInfo});if(Re(this,xs)!==t)return;Zt(this,Di,!0),Zt(this,ka,Re(this,ka)+1),this.server.set(n),this.status.set({state:"open",attempt:0});for(const r of[...Re(this,So)])r(Re(this,ka))}catch(n){t.close(4e3,n instanceof Error?n.message:"initialize failed")}},Uk=function(t){let n;try{n=JSON.parse(t)}catch{return}const r=sM(n);if(r==="response"){const i=Re(this,ur).get(n.id);if(i===void 0)return;"error"in n?i.reject(new pl(n.error.code,n.error.message,n.error.data)):i.resolve(n.result)}else if(r==="notification")for(const i of[...Re(this,jo).get(n.method)??[]])try{i(n.params)}catch(o){console.error(`notification handler for ${n.method} failed`,o)}},$p=function(t){Zt(this,Di,!1);for(const n of[...Re(this,ur).values()])n.reject(new pl(mu.InternalError,t));Re(this,ur).clear()},Rp=function(t){if(this.status.get().state==="stopped")return;const n=this.status.get().attempt+1,{initial:r,max:i}=Re(this,ii).backoffMs??{initial:500,max:1e4},o=Math.min(i,r*2**Math.min(n-1,10))*(.8+Math.random()*.4);this.status.set({state:"reconnecting",attempt:n,error:t}),Zt(this,Jl,setTimeout(()=>xt(this,hn,Mp).call(this),o))};const kM={status:"opening",header:null,title:null,events:[],cursor:-1,hasMore:!1,loadingOlder:!1,live:null,pending:[],queue:[],context:null,running:!1,version:0,error:null};var vs,ec,_o,Eo,ai,Fi,tc,nc,Vt,Op,$u,Kn;class wM{constructor(t,n,r){Lt(this,Vt);ut(this,"id");ut(this,"state",new zr(kM));Lt(this,vs);Lt(this,ec);Lt(this,_o,null);Lt(this,Eo,-1);Lt(this,ai,!1);Lt(this,Fi,null);Lt(this,tc);Lt(this,nc);this.id=t,Zt(this,vs,n),Zt(this,ec,r),Zt(this,tc,n.onReady(i=>{i!==Re(this,Eo)&&xt(this,Vt,Op).call(this,i)}))}get subscriptionId(){return Re(this,_o)}async prompt(t,n="queue",r=[]){const i=crypto.randomUUID(),o={requestId:i,text:t,mode:n,sentAt:Date.now(),...r.length===0?{}:{images:r.length}};xt(this,Vt,Kn).call(this,c=>({...c,pending:[...c.pending,o]}));try{await Re(this,vs).call("session/prompt",{sessionId:this.id,requestId:i,text:t,mode:n,...r.length===0?{}:{images:[...r]}})}catch(c){const u=c instanceof Error?c.message:String(c);throw xt(this,Vt,Kn).call(this,d=>({...d,pending:d.pending.map(f=>f.requestId===i?{...f,failed:u}:f)})),c}}dismissPending(t){xt(this,Vt,Kn).call(this,n=>({...n,pending:n.pending.filter(r=>r.requestId!==t)}))}async updateQueue(t,n){await Re(this,vs).call("session/queue/update",{sessionId:this.id,itemId:t,action:n})}async cancel(){await Re(this,vs).call("session/cancel",{sessionId:this.id})}async compact(){return Re(this,vs).call("session/compact",{sessionId:this.id})}async loadOlder(){const t=this.state.get(),n=t.events[0];if(!(!t.hasMore||t.loadingOlder||n===void 0)){xt(this,Vt,Kn).call(this,r=>({...r,loadingOlder:!0}));try{const r=await Re(this,vs).call("session/history",{sessionId:this.id,throughSeq:t.cursor,beforeSeq:n.seq});xt(this,Vt,Kn).call(this,i=>{var u;const o=((u=i.events[0])==null?void 0:u.seq)??Number.POSITIVE_INFINITY,c=r.events.filter(d=>d.seq<o);return{...i,events:[...c,...i.events],hasMore:r.hasMore,loadingOlder:!1}})}catch(r){xt(this,Vt,Kn).call(this,i=>({...i,loadingOlder:!1,error:r instanceof Error?r.message:String(r)}))}}}close(){if(Re(this,ai))return;Zt(this,ai,!0),clearTimeout(Re(this,nc)),Re(this,tc).call(this);const t=Re(this,_o);xt(this,Vt,$u).call(this,null),t!==null&&Re(this,vs).ready&&Re(this,vs).call("session/close",{subscriptionId:t}).catch(()=>{}),xt(this,Vt,Kn).call(this,n=>({...n,status:"closed"}))}receiveEvent(t){xt(this,Vt,Kn).call(this,n=>{const r=n.events.at(-1);if(r!==void 0&&t.seq<=r.seq)return n;let i=n.pending;t.type==="user/message"&&t.requestId!==void 0&&(i=i.filter(d=>d.requestId!==t.requestId));let o=n.live;(t.type==="assistant/message"||t.type==="assistant/attempt")&&o!==null&&o.turn===t.turn&&o.step===t.step&&(o=null);const c=t.type==="session/title"?t.title:n.title,u=[...n.events,t];return{...n,events:u,pending:i,live:o,title:c,running:Nh(u,o)}})}receiveLive(t){xt(this,Vt,Kn).call(this,n=>{var r;switch(t.type){case"start":{const i={attemptId:t.attemptId,turn:t.turn,step:t.step,afterSeq:t.afterSeq,deltas:[]};return{...n,live:i,running:!0}}case"delta":{const i=n.live;return i===null||i.attemptId!==t.attemptId?n:(i.deltas.push(t),{...n,live:{...i}})}case"end":return((r=n.live)==null?void 0:r.attemptId)!==t.attemptId?n:{...n,live:null,running:Nh(n.events,null)}}})}receiveClosed(t){xt(this,Vt,$u).call(this,null),!Re(this,ai)&&(xt(this,Vt,Kn).call(this,n=>({...n,status:"error",error:`stream ended: ${t}`})),Zt(this,nc,setTimeout(()=>{!Re(this,ai)&&Re(this,vs).ready&&xt(this,Vt,Op).call(this,Re(this,Eo))},1e3)))}receiveQueue(t){xt(this,Vt,Kn).call(this,n=>({...n,queue:t,pending:m0(n.pending,t)}))}receiveContext(t){xt(this,Vt,Kn).call(this,n=>({...n,context:t}))}receiveTitle(t){xt(this,Vt,Kn).call(this,n=>n.title===t?n:{...n,title:t})}}vs=new WeakMap,ec=new WeakMap,_o=new WeakMap,Eo=new WeakMap,ai=new WeakMap,Fi=new WeakMap,tc=new WeakMap,nc=new WeakMap,Vt=new WeakSet,Op=async function(t){if(!Re(this,ai))return Re(this,Fi)!==null?Re(this,Fi):(Zt(this,Eo,t),Zt(this,Fi,(async()=>{try{const n=await Re(this,vs).call("session/open",{sessionId:this.id});if(Re(this,ai)){Re(this,vs).call("session/close",{subscriptionId:n.subscriptionId}).catch(()=>{});return}xt(this,Vt,$u).call(this,n.subscriptionId);const r=n.live===null?null:{...n.live,deltas:[...n.live.deltas]};xt(this,Vt,Kn).call(this,i=>{const o=new Set(n.events.flatMap(c=>c.type==="user/message"&&c.requestId!==void 0?[c.requestId]:[]));return{...i,status:"open",header:n.header,title:n.title,events:n.events,cursor:n.cursor,hasMore:n.hasMore,live:r,pending:m0(i.pending.filter(c=>!o.has(c.requestId)),n.queue??[]),queue:n.queue??[],context:n.context??i.context,running:Nh(n.events,r),loadingOlder:!1,error:null}})}catch(n){xt(this,Vt,Kn).call(this,r=>({...r,status:"error",error:n instanceof Error?n.message:String(n)}))}finally{Zt(this,Fi,null)}})()),Re(this,Fi))},$u=function(t){Zt(this,_o,t),Re(this,ec).bindSubscription(this,t)},Kn=function(t){this.state.set(n=>{const r=t(n);return r===n?n:{...r,version:n.version+1}})};function m0(e,t){const n=new Set(t.flatMap(r=>r.requestId===void 0?[]:[r.requestId]));return n.size===0?e:e.filter(r=>!n.has(r.requestId))}function Nh(e,t){if(t!==null)return!0;for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.type==="turn/end")return!1;if(r.type==="turn/start")return!0}return!1}const g0=(e,t)=>t.updatedAt-e.updatedAt;var Is,Pr,Co,Gi,Ru,Hk;class NM{constructor(t){Lt(this,Gi);ut(this,"connection");ut(this,"sessions",new zr({items:[],loaded:!1,error:null}));ut(this,"approvals",new zr([]));ut(this,"questions",new zr([]));ut(this,"capabilities",new zr(new Set));ut(this,"credentialRevision",new zr(0));ut(this,"providersRevision",new zr(0));ut(this,"sessionModels",new zr(new Map));Lt(this,Is,new Map);Lt(this,Pr,new Map);Lt(this,Co,!1);this.connection=new bM({...t,clientInfo:t.clientInfo??{name:"adg-client",version:"0.1.0"}});const n=this.connection;n.onReady(()=>{var r;this.capabilities.set(new Set(((r=n.server.get())==null?void 0:r.capabilities.map(i=>i.id))??[])),this.approvals.set([]),this.questions.set([]),this.refreshSessions()}),n.on("sessions/changed",r=>{if(r.kind==="removed"){this.sessions.set(o=>({...o,items:o.items.filter(c=>c.id!==r.sessionId)}));return}if(!this.sessions.get().items.some(o=>o.id===r.item.id)){xt(this,Gi,Hk).call(this);return}this.sessions.set(o=>({...o,items:o.items.map(c=>c.id===r.item.id?{...c,...jM(r.item)}:c).sort(g0)}))}),n.on("session/title",({sessionId:r,title:i})=>{var o;(o=Re(this,Is).get(r))==null||o.handle.receiveTitle(i)}),n.on("session/queue",({sessionId:r,items:i})=>{var o;(o=Re(this,Is).get(r))==null||o.handle.receiveQueue(i)}),n.on("session/context",({sessionId:r,context:i})=>{var o;(o=Re(this,Is).get(r))==null||o.handle.receiveContext(i)}),n.on("session/event",({subscriptionId:r,event:i})=>{var o;return(o=Re(this,Pr).get(r))==null?void 0:o.receiveEvent(i)}),n.on("session/live",({subscriptionId:r,frame:i})=>{var o;return(o=Re(this,Pr).get(r))==null?void 0:o.receiveLive(i)}),n.on("session/closed",({subscriptionId:r,reason:i})=>{const o=Re(this,Pr).get(r);o!==void 0&&o.subscriptionId===r&&o.receiveClosed(i)}),n.on("approval/requested",r=>{this.approvals.set(i=>i.some(o=>o.approvalId===r.approvalId)?i:[...i,r])}),n.on("approval/resolved",({approvalId:r})=>{this.approvals.set(i=>i.filter(o=>o.approvalId!==r))}),n.on("question/requested",r=>{this.questions.set(i=>i.some(o=>o.questionId===r.questionId)?i:[...i,r])}),n.on("question/resolved",({questionId:r})=>{this.questions.set(i=>i.filter(o=>o.questionId!==r))}),n.on("credentials/changed",()=>this.credentialRevision.set(r=>r+1)),n.on("providers/changed",()=>this.providersRevision.set(r=>r+1)),n.on("session/model",({sessionId:r,lastUsed:i,next:o})=>xt(this,Gi,Ru).call(this,r,{lastUsed:i,next:o}))}async describeCredentials(t){const{items:n}=await this.connection.call("credentials/describe",{refs:[...t]});return n}async setCredential(t,n){await this.connection.call("credentials/set",{ref:t,value:n}),this.credentialRevision.set(r=>r+1)}async unsetCredential(t){await this.connection.call("credentials/unset",{ref:t}),this.credentialRevision.set(n=>n+1)}start(){this.connection.start()}stop(){for(const{handle:t}of Re(this,Is).values())t.close();Re(this,Is).clear(),Re(this,Pr).clear(),this.connection.stop()}has(t){return this.capabilities.get().has(t)}async refreshSessions(){try{const{items:t}=await this.connection.call("sessions/list",{});this.sessions.set({items:[...t].sort(g0),loaded:!0,error:null})}catch(t){this.sessions.set(n=>({...n,error:t instanceof Error?t.message:String(t)}))}}async createSession(t,n={}){const{sessionId:r}=await this.connection.call("sessions/create",{...t===void 0?{}:{cwd:t},...n.role===void 0?{}:{role:n.role}});return await this.refreshSessions(),r}async renameSession(t,n){var i;const r=await this.connection.call("sessions/rename",{sessionId:t,title:n});this.sessions.set(o=>({...o,items:o.items.map(c=>c.id===t?{...c,title:r.title}:c)})),(i=Re(this,Is).get(t))==null||i.handle.receiveTitle(r.title)}modelCatalog(){return this.connection.call("models/catalog",{})}async sessionModel(t){const n=await this.connection.call("session/model",{sessionId:t});return xt(this,Gi,Ru).call(this,t,n),n}async selectModel(t,n){var o;const{selected:r}=await this.connection.call("session/selectModel",{sessionId:t,...n}),i=((o=this.sessionModels.get().get(t))==null?void 0:o.lastUsed)??null;return xt(this,Gi,Ru).call(this,t,{lastUsed:i,next:r}),r}listProviders(){return this.connection.call("providers/list",{})}async discoverModels(t,n){const{models:r}=await this.connection.call("providers/discover",t,n);return r}async saveProvider(t){const n=await this.connection.call("providers/save",t);return this.providersRevision.set(r=>r+1),t.apiKey!==void 0&&this.credentialRevision.set(r=>r+1),n}async removeProvider(t){const n=await this.connection.call("providers/remove",t);return this.providersRevision.set(r=>r+1),t.removeKey===!0&&this.credentialRevision.set(r=>r+1),n}async respondApproval(t,n){await this.connection.call("approval/respond",{approvalId:t,decision:n}),this.approvals.set(r=>r.filter(i=>i.approvalId!==t))}async answerQuestion(t,n){await this.connection.call("question/respond",{questionId:t,answers:[...n]}),this.questions.set(r=>r.filter(i=>i.questionId!==t))}openSession(t){const n=Re(this,Is).get(t);if(n!==void 0)return n.refs+=1,n.handle;const r=new wM(t,this.connection,{bindSubscription:(i,o)=>{for(const[c,u]of Re(this,Pr))u===i&&Re(this,Pr).delete(c);o!==null&&Re(this,Pr).set(o,i)}});return Re(this,Is).set(t,{handle:r,refs:1}),r}release(t){const n=Re(this,Is).get(t.id);n===void 0||n.handle!==t||(n.refs-=1,!(n.refs>0)&&(Re(this,Is).delete(t.id),t.close()))}}Is=new WeakMap,Pr=new WeakMap,Co=new WeakMap,Gi=new WeakSet,Ru=function(t,n){this.sessionModels.set(r=>new Map(r).set(t,n))},Hk=function(){Re(this,Co)||(Zt(this,Co,!0),setTimeout(()=>{Zt(this,Co,!1),this.refreshSessions()},150))};function jM(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const jh=(e,t)=>e.map(n=>n.type===t?n.text:"").join(""),x0=e=>e.flatMap(t=>t.type==="image"&&t.attachmentId!==void 0&&t.mediaType!==void 0&&t.bytes!==void 0&&t.width!==void 0&&t.height!==void 0?[{attachmentId:t.attachmentId,mediaType:t.mediaType,bytes:t.bytes,width:t.width,height:t.height,...t.name===void 0?{}:{name:t.name}}]:[]),SM=e=>e.map(t=>t.type==="text"?t.text:t.type==="image"?"[image]":t.type==="file"?`[file ${t.name??""}]`:"").join("");function _M(e,t,n=[]){var d;const r=[],i=new Map,o=new Set,c=new Map,u=new Map;for(const f of e)switch(f.type){case"user/message":{const p=jh(f.content,"text");f.origin.human?r.push({kind:"user",id:`u:${f.seq}`,text:p,time:f.time,images:f.content.filter(m=>m.type==="image").length,imageRefs:x0(f.content),files:f.content.filter(m=>m.type==="file").length}):h0(p)!==void 0?r.push({kind:"context",id:`c:${f.seq}`,title:"定时提醒",summary:vM(h0(p)),text:p,startsTurn:!0}):f.replacesHistory===!0?r.push({kind:"context",id:`c:${f.seq}`,title:"较早的对话已压缩成摘要(agent 只记得摘要里的内容)",summary:"",text:p}):f.origin.summary!==void 0&&r.push({kind:"context",id:`c:${f.seq}`,title:f.origin.kind,summary:f.origin.summary,text:p});break}case"assistant/message":{o.add(`${f.turn}:${f.step}`);const p=jh(f.content,"text"),m=jh(f.content,"reasoning");(p.trim()!==""||m.trim()!=="")&&r.push({kind:"assistant",id:`a:${f.seq}`,text:p,reasoning:m,live:!1,interrupted:f.interrupted===!0,time:f.time,...f.model===void 0?{}:{model:f.model}});break}case"tool/call":{const p={kind:"tool",id:`t:${f.callId}`,callId:f.callId,name:f.name,arguments:f.arguments,status:"running",time:f.time},m=c.get(f.callId);m!==void 0&&(p.approval=m),i.set(f.callId,p),r.push(p);break}case"tool/result":{const p=i.get(f.callId);if(p===void 0)break;p.result=SM(f.content);const m=x0(f.content);m.length>0&&(p.images=m),p.status=f.isError?"error":"ok",f.error!==void 0&&(p.error=f.error.message);break}case"approval/asked":if(f.callId!==void 0){u.set(f.approvalId,f.callId),c.set(f.callId,"asked");const p=i.get(f.callId);p!==void 0&&(p.approval="asked")}break;case"approval/decided":{const p=u.get(f.approvalId);if(p===void 0)break;c.set(p,f.outcome);const m=i.get(p);m!==void 0&&(m.approval=f.outcome);break}case"turn/end":for(const p of i.values())p.status==="running"&&(p.status="interrupted");f.reason.kind==="error"?r.push({kind:"notice",id:`e:${f.seq}`,tone:"error",text:f.reason.message??"这一轮出错了"}):f.reason.kind==="aborted"?r.push({kind:"notice",id:`e:${f.seq}`,tone:"info",text:"已停止"}):f.reason.kind==="max-tokens"&&r.push({kind:"notice",id:`e:${f.seq}`,tone:"info",text:"回复太长,达到了输出上限"});break;case"compaction/end":r.push({kind:"notice",id:`k:${f.seq}`,tone:f.error===void 0?"info":"error",text:f.error===void 0?"对话太长,较早的内容已压缩成摘要":`压缩对话历史失败:${f.error}`});break}if(t!==null&&!o.has(`${t.turn}:${t.step}`)){let f="",p="";for(const m of t.deltas)m.kind==="text"?f+=m.text:m.kind==="reasoning"&&(p+=m.text);r.push({kind:"assistant",id:`live:${t.attemptId}`,text:f,reasoning:p,live:!0,interrupted:!1,time:((d=t.deltas[0])==null?void 0:d.time)??Date.now()})}for(const f of n)r.push({kind:"user",id:`p:${f.requestId}`,text:f.text,images:f.images??0,imageRefs:[],files:0,time:f.sentAt,pending:{requestId:f.requestId,...f.failed===void 0?{}:{failed:f.failed}}});return r}var b=sc();const EM=pm(b);function CM(e,t){return e.filter(n=>{var r;return((r=n.available)==null?void 0:r.call(n,t))??!0})}const Bi=new Map,Zu=new Set;function Fn(e){if(Bi.has(e.id))throw new Error(`UI plugin "${e.id}" is already registered`);Bi.set(e.id,e);for(const t of Zu)t();return()=>{if(Bi.get(e.id)===e){Bi.delete(e.id);for(const t of Zu)t()}}}function Zk(e){return Zu.add(e),()=>{Zu.delete(e)}}function IM(e){return[...Bi.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.sessionViews??[]).sort((t,n)=>t.order-n.order)}function AM(e){return[...Bi.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.settingsPages??[]).sort((t,n)=>t.order-n.order)}function TM(e){return[...Bi.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.pages??[]).sort((t,n)=>t.order-n.order)}function MM(e){return[...Bi.values()].map(t=>({plugin:t,missing:t.requires.filter(n=>!e.has(n))}))}function Ee(e){return b.useSyncExternalStore(e.subscribe,e.get,e.get)}function Vk(e,t){const[n,r]=b.useState(null);return b.useEffect(()=>{const i=e.openSession(t);return r(i),()=>e.release(i)},[e,t]),n!==null&&n.id===t?n:null}function Wk(e){const t=Ee(e.capabilities),n=_m();return b.useMemo(()=>IM(t),[t,n])}function $M(e){const t=Ee(e.capabilities),n=_m();return b.useMemo(()=>AM(t),[t,n])}function RM(e){const t=Ee(e.capabilities),n=_m();return b.useMemo(()=>TM(t),[t,n])}function _m(){const[e,t]=b.useState(0);return b.useEffect(()=>Zk(()=>t(n=>n+1)),[]),e}function qk(e,t){const n=Ee(e.credentialRevision),r=Ee(e.connection.status),i=Ee(e.capabilities),o=t.join(`
|
|
122
|
-
`),[c,u]=b.useState({items:null,error:null});return b.useEffect(()=>{if(r.state!=="open"||!i.has("credentials")||o==="")return;let d=!0;return e.describeCredentials(o.split(`
|
|
123
|
-
`)).then(f=>{d&&u({items:f,error:null})}).catch(f=>{d&&u(p=>({...p,error:f instanceof Error?f.message:String(f)}))}),()=>{d=!1}},[e,o,n,r.state,i]),c}function ic(e){const t=Ee(e.credentialRevision),n=Ee(e.providersRevision),r=Ee(e.connection.status),i=Ee(e.capabilities),[o,c]=b.useState({catalog:null,error:null});return b.useEffect(()=>{if(r.state!=="open"||!i.has("models"))return;let u=!0;return e.modelCatalog().then(d=>{u&&c({catalog:d,error:null})}).catch(d=>{u&&c(f=>({...f,error:d instanceof Error?d.message:String(d)}))}),()=>{u=!1}},[e,t,n,r.state,i]),o}function Cn(e){const[t,n]=b.useState(()=>Date.now());return b.useEffect(()=>{const r=setInterval(()=>n(Date.now()),e);return()=>clearInterval(r)},[e]),t}function OM(e){const t=Ee(e.connection.status),n=Ee(e.capabilities),[r,i]=b.useState(void 0);return b.useEffect(()=>e.connection.on("permissions/changed",o=>i(o.mode)),[e]),b.useEffect(()=>{if(t.state!=="open"||!n.has("permissions"))return;let o=!0;return e.connection.call("permissions/get",{}).then(c=>{o&&i(c.mode)}).catch(()=>{}),()=>{o=!1}},[e,t.state,n]),r}const zM={plus:"M12 5v14M5 12h14",chat:"M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5Z",settings:"M4 7h9m4 0h3M4 17h3m4 0h9M13 4v6M7 14v6",arrow:"M12 19V5m-6 6 6-6 6 6",activity:"M3 12h4l3-8 4 16 3-8h4",layers:"m12 3 9 5-9 5-9-5 9-5Zm-9 9 9 5 9-5M3 16l9 5 9-5",sparkles:"m12 3 2.5 6.5L21 12l-6.5 2.5L12 21l-2.5-6.5L3 12l6.5-2.5L12 3Z",close:"m6 6 12 12M6 18 18 6",gauge:"M12 14l4-4M3.5 15a8.5 8.5 0 1 1 17 0M6.5 19h11",popout:"M14 4h6v6M20 4l-8.5 8.5M18 14v4.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 4 18.5v-11A1.5 1.5 0 0 1 5.5 6H10",search:"M11 17.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13ZM20 20l-4-4",check:"m5 12.5 4.5 4.5L19 7.5",pencil:"M4 20h4L18.5 9.5a2.1 2.1 0 0 0-4-4L4 16v4ZM13.5 6.5l4 4",copy:"M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2ZM16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2",chevron:"m9 6 6 6-6 6","chevron-down":"m6 9 6 6 6-6",back:"M19 12H5M11 6l-6 6 6 6",shield:"M12 3 4 6v6c0 4.5 3.4 8 8 9 4.6-1 8-4.5 8-9V6l-8-3ZM12 9v4M12 16.5v.01",terminal:"M4 17l6-6-6-6M12 19h8",image:"M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1ZM4 16l5-5 4 4 2-2 5 5M15 9.5v.01",paperclip:"m20 11.5-8.2 8.2a5 5 0 0 1-7-7l8.5-8.5a3.3 3.3 0 0 1 4.7 4.7l-8.5 8.5a1.7 1.7 0 0 1-2.4-2.4l7.8-7.8",info:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM12 11v5M12 7.5v.01",key:"M8 19a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM11 12l8-8M16 7l2 2M14 9l2 2",sidebar:"M6.5 4.5h11a3 3 0 0 1 3 3v9a3 3 0 0 1-3 3h-11a3 3 0 0 1-3-3v-9a3 3 0 0 1 3-3ZM9.5 4.5v15",alert:"M12 4 2.5 20h19L12 4ZM12 10v4M12 17v.01",package:"m12 3 8 4.5v9L12 21l-8-4.5v-9L12 3Zm0 9 8-4.5M12 12v9M12 12 4 7.5",flow:"M5 4h4v4H5zM15 16h4v4h-4zM15 4h4v4h-4zM9 6h6M17 8v8M7 8v6a2 2 0 0 0 2 2h6",monitor:"M4 5h16v11H4zM9 20h6M12 16v4M7 12l2.5-3 2.5 2 3-4 2 2",gamepad:"M7 9v4M5 11h4M15 10.5v.01M17.5 12.5v.01M6.5 6h11a4 4 0 0 1 4 4.4l-.6 5.3a2.6 2.6 0 0 1-4.5 1.4L14.5 15h-5l-1.9 2.1a2.6 2.6 0 0 1-4.5-1.4l-.6-5.3A4 4 0 0 1 6.5 6Z",plug:"M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0V8ZM12 17v4",home:"M4 11 12 4l8 7M6 9.5V20h12V9.5",archive:"M4 5h16v4H4zM5.5 9v10h13V9M10 13h4",refresh:"M20 11a8 8 0 0 0-14.3-4.9L4 8M4 4v4h4M4 13a8 8 0 0 0 14.3 4.9L20 16M20 20v-4h-4",calendar:"M5 5.5h14a1 1 0 0 1 1 1V19a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6.5a1 1 0 0 1 1-1ZM4 10h16M8 3.5v4M16 3.5v4M8 14h2M14 14h2M8 17h2",send:"M20.5 3.5 10 14M20.5 3.5 14 20.5l-4-6.5-6.5-4 17-6.5Z",power:"M12 3.5v8M7.2 6.5a7 7 0 1 0 9.6 0",download:"M12 4v11M7 10.5l5 5 5-5M5 20h14",compress:"M12 3v6M9 6l3 3 3-3M12 21v-6M9 18l3-3 3 3M4 12h16"};function ee({name:e,className:t=""}){return s.jsx("svg",{className:`ui-icon ${t}`,width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:zM[e]})})}function PM(){return s.jsx("svg",{className:"ui-icon stop-glyph",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"3",fill:"currentColor"})})}function gd({size:e="md"}){return s.jsx("span",{className:`adg-mark ${e}`,"aria-hidden":"true",children:s.jsxs("svg",{className:"ui-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M9 7.5v9l7.5-4.5L9 7.5Z"}),s.jsx("path",{d:"M4 12a8 8 0 0 1 14.5-4.7M20 12a8 8 0 0 1-14.5 4.7"})]})})}const v0="adg.otherCopies.seen";function LM(e){const t=Ee(e.connection.status),r=Ee(e.capabilities).has("instances"),[i,o]=b.useState([]);return b.useEffect(()=>e.connection.on("instances/changed",c=>o(c.others)),[e]),b.useEffect(()=>{if(t.state!=="open"||!r){o([]);return}let c=!0;return e.connection.call("instances/others",{}).then(u=>{c&&o(u.others)}).catch(()=>{}),()=>{c=!1}},[e,t.state,r]),i}function DM({client:e}){const t=LM(e),n=JSON.stringify(t.map(c=>[c.pid,c.warnings])),[r,i]=b.useState(()=>{try{return localStorage.getItem(v0)}catch{return null}});if(t.length===0||r===n)return null;const o=()=>{try{localStorage.setItem(v0,n)}catch{}i(n)};return s.jsxs("div",{className:"approval-card other-copies",role:"status",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(ee,{name:"alert"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("span",{className:"approval-title",children:t.length===1?"另一个多游戏助手也开着":`另外 ${t.length} 个多游戏助手也开着`}),s.jsx("span",{className:"approval-tool",children:t.map(c=>c.label).join("、")})]})]}),s.jsx("ul",{className:"other-copies-list",children:[...new Set(t.flatMap(c=>c.warnings))].map(c=>s.jsx("li",{children:c},c))}),s.jsx("div",{className:"approval-actions",children:s.jsx("button",{onClick:o,children:"知道了"})})]})}const FM={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function BM(e){const t=Ee(e.connection.status),r=Ee(e.capabilities).has("schedule"),[i,o]=b.useState(void 0);return b.useEffect(()=>e.connection.on("schedule/power",o),[e]),b.useEffect(()=>{if(t.state!=="open"||!r){o(void 0);return}let c=!0;return e.connection.call("schedule/power",{}).then(u=>{c&&o(u)}).catch(()=>{}),()=>{c=!1}},[e,t.state,r]),i}function UM({client:e,pending:t}){const n=Cn(1e3),[r,i]=b.useState(!1),[o,c]=b.useState(null),u=FM[t.action],d=async()=>{i(!0),c(null);try{await e.connection.call("schedule/power/cancel",{})}catch(p){c(p instanceof Error?p.message:String(p))}finally{i(!1)}},f=t.at===void 0?void 0:Math.max(0,Math.ceil((t.at-n)/1e3));return s.jsxs("div",{className:"approval-card power-card",role:"alertdialog","aria-label":`即将${u}`,children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(ee,{name:"power"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("div",{className:"approval-title",children:f===void 0?`其他任务结束后${u}`:`${f} 秒后${u}`}),s.jsxs("span",{className:"approval-tool",children:["「",t.pipelineName,"」设置了结束后",u]})]})]}),t.action==="shutdown"&&f!==void 0&&s.jsx("div",{className:"approval-reason",children:"关机会强制关闭所有程序,没保存的内容会丢失。"}),o!==null&&s.jsx("div",{className:"error small",children:o}),s.jsx("div",{className:"approval-actions",children:s.jsxs("button",{className:"inverse",disabled:r,onClick:()=>void d(),children:["取消",u]})})]})}function kr(){return window.adgDesktop}const y0="adg.update.later";function Gk(){var r;const e=(r=kr())==null?void 0:r.updates,[t,n]=b.useState(e===void 0?null:void 0);return b.useEffect(()=>{if(e===void 0)return;let i=!0;e.state().then(c=>{i&&n(c)},()=>{i&&n(null)});const o=e.onChange(c=>{i&&n(c)});return()=>{i=!1,o()}},[e]),{bridge:e,state:t}}function Sh(e){return e>=1024*1024?`${Math.round(e/1024/1024)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function Kk({bridge:e,state:t,extra:n}){var p;const[r,i]=b.useState(null),[o,c]=b.useState(!1),u=t.latest;if(u===void 0)return null;const d=((p=t.download)==null?void 0:p.version)===u.version?t.download:void 0,f=m=>{i(null),m().catch(g=>i(g instanceof Error?g.message.replace(/^Error invoking remote method '[^']+': (Error: )?/,""):String(g)))};return s.jsxs("div",{className:"update-actions",children:[(d==null?void 0:d.state)==="downloading"&&s.jsxs("div",{className:"update-progress",children:[s.jsx("div",{className:"progress",role:"progressbar","aria-label":"下载进度","aria-valuemin":0,"aria-valuemax":d.total,"aria-valuenow":d.received,children:s.jsx("span",{style:{width:`${d.total>0?Math.min(100,d.received/d.total*100):0}%`}})}),s.jsxs("small",{className:"muted",children:["正在下载 ",Sh(d.received)," / ",Sh(d.total)]})]}),(d==null?void 0:d.state)==="ready"&&s.jsx("p",{className:"muted small",children:"安装时程序会退出,正在跑的脚本会被中断;装好后自动重新打开,数据和定时任务都在。"}),(d==null?void 0:d.state)==="failed"&&s.jsx("p",{className:"error small",children:d.error}),r!==null&&s.jsx("p",{className:"error small",children:r}),s.jsxs("div",{className:"update-buttons",children:[n,(d==null?void 0:d.state)==="ready"?s.jsx("button",{className:"primary small-button",disabled:o,onClick:()=>{c(!0),f(()=>e.install().finally(()=>c(!1)))},children:o?"正在启动安装…":"退出并安装"}):s.jsx("button",{className:"primary small-button",disabled:(d==null?void 0:d.state)==="downloading",onClick:()=>f(()=>e.download()),children:(d==null?void 0:d.state)==="failed"?"重新下载":(d==null?void 0:d.state)==="downloading"?"正在下载…":`下载更新(${Sh(u.size)})`})]})]})}function HM(){var u;const{bridge:e,state:t}=Gk(),[n,r]=b.useState(()=>{try{return sessionStorage.getItem(y0)}catch{return null}}),i=t==null?void 0:t.latest;if(e===void 0||t==null||i===void 0)return null;const o=((u=t.download)==null?void 0:u.version)===i.version&&t.download.state!=="failed";if(!o&&(i.version===t.skipped||i.version===n))return null;const c=()=>{try{sessionStorage.setItem(y0,i.version)}catch{}r(i.version)};return s.jsxs("div",{className:"approval-card update-card",role:"status",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(ee,{name:"download"}),s.jsxs("div",{className:"approval-text",children:[s.jsxs("span",{className:"approval-title",children:["MultiGameAssistant ",i.version," 可以更新了"]}),s.jsxs("span",{className:"approval-tool",children:["当前 ",t.current,i.prerelease?" · 预发布版":""," · ",s.jsx("a",{href:i.notesUrl,target:"_blank",rel:"noreferrer",children:"查看更新内容"})]})]}),!o&&s.jsx("button",{className:"ghost icon-button update-close","aria-label":"稍后提醒",title:"稍后(下次启动再提醒)",onClick:c,children:s.jsx(ee,{name:"close"})})]}),s.jsx(Kk,{bridge:e,state:t,extra:!o&&s.jsx("button",{className:"ghost small-button",onClick:()=>void e.skip(i.version),children:"跳过这个版本"})})]})}function ZM({client:e,sessionId:t,onSelect:n}){var p;const r=Ee(e.approvals),i=Ee(e.questions),o=(p=BM(e))==null?void 0:p.pending,c=r.filter(m=>m.sessionId===t),u=i.filter(m=>m.sessionId===t),d=[...r,...i].filter(m=>m.sessionId!==t),f=d.some(m=>"approvalId"in m)?d.some(m=>"questionId"in m)?"审批或回答":"审批":"回答";return s.jsxs("div",{className:"approval-dock",children:[o!==void 0&&s.jsx(UM,{client:e,pending:o}),u.map(m=>s.jsx(WM,{client:e,request:m},m.questionId)),c.map(m=>s.jsx(VM,{client:e,request:m},m.approvalId)),d.length>0&&s.jsxs("button",{className:"approval-elsewhere",onClick:()=>n(d[0].sessionId),children:[s.jsx("span",{className:"approval-dot"}),"另有 ",new Set(d.map(m=>m.sessionId)).size," 个会话在等你",f,s.jsx(ee,{name:"chevron"})]}),s.jsx(DM,{client:e}),s.jsx(HM,{})]})}function VM({client:e,request:t}){var d,f,p;const[n,r]=b.useState(!1),[i,o]=b.useState(null),c=((d=t.displayReason)==null?void 0:d.zh)??((f=t.displayReason)==null?void 0:f["zh-CN"])??((p=t.displayReason)==null?void 0:p.en)??t.reason,u=async m=>{r(!0);try{await e.respondApproval(t.approvalId,m)}catch(g){o(g instanceof Error?g.message:String(g)),r(!1)}};return s.jsxs("div",{className:"approval-card",role:"alertdialog","aria-label":"需要审批",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(ee,{name:"shield"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("div",{className:"approval-title",children:"需要你的批准"}),s.jsx("code",{className:"approval-tool",children:t.toolName})]})]}),c!==void 0&&s.jsx("div",{className:"approval-reason",children:c}),i!==null&&s.jsx("div",{className:"error small",children:i}),s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{disabled:n,onClick:()=>void u("reject"),children:"拒绝"}),s.jsx("button",{className:"inverse",disabled:n,onClick:()=>void u("allow-once"),children:"允许本次"})]})]})}function WM({client:e,request:t}){var S;const[n,r]=b.useState({}),[i,o]=b.useState(!1),[c,u]=b.useState(null),d=t.questions.length===1&&t.questions[0].multiSelect!==!0&&(((S=t.questions[0].options)==null?void 0:S.length)??0)>0,f=k=>n[k]??{selected:[],custom:""},p=async k=>{o(!0),u(null);try{await e.answerQuestion(t.questionId,k)}catch(w){u(w instanceof Error?w.message:String(w)),o(!1)}},m=(k,w)=>{if(d)return void p([{id:k.id,selected:[w]}]);r(T=>{const N=T[k.id]??{selected:[],custom:""},$=k.multiSelect===!0?N.selected.includes(w)?N.selected.filter(D=>D!==w):[...N.selected,w]:N.selected.includes(w)?[]:[w];return{...T,[k.id]:{...N,selected:$}}})},g=(k,w)=>r(T=>({...T,[k.id]:{...T[k.id]??{selected:[]},custom:w}})),v=()=>t.questions.map(k=>{const{selected:w,custom:T}=f(k.id),N=T.trim();return{id:k.id,selected:N!==""&&k.multiSelect!==!0?[]:w,...N===""?{}:{custom:N}}}),y=t.questions.every(k=>f(k.id).selected.length>0||f(k.id).custom.trim()!=="");return s.jsxs("div",{className:"approval-card question-card",role:"alertdialog","aria-label":"agent 在问你",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(ee,{name:"chat"}),s.jsx("div",{className:"approval-text",children:s.jsx("div",{className:"approval-title",children:"agent 在问你"})})]}),t.questions.map(k=>{var w,T;return s.jsxs("div",{className:"question-item",children:[k.header!==void 0&&s.jsx("span",{className:"question-header",children:k.header}),s.jsx("div",{className:"question-text",children:k.question}),k.detail!==void 0&&s.jsx("div",{className:"question-detail",children:k.detail}),(((w=k.options)==null?void 0:w.length)??0)>0&&s.jsx("div",{className:"question-options",role:k.multiSelect===!0?"group":"radiogroup",children:k.options.map(N=>{const $=f(k.id).selected.includes(N.label);return s.jsxs("button",{className:`question-option${$?" on":""}`,disabled:i,role:k.multiSelect===!0?"checkbox":"radio","aria-checked":$,onClick:()=>m(k,N.label),children:[s.jsx("span",{className:"question-option-label",children:N.label}),N.description!==void 0&&s.jsx("span",{className:"question-option-desc",children:N.description})]},N.label)})}),s.jsx("input",{className:"text-input question-custom",value:f(k.id).custom,disabled:i,placeholder:(((T=k.options)==null?void 0:T.length)??0)>0?"或者直接写你的回答":"写下你的回答",onChange:N=>g(k,N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&y&&p(v())}})]},k.id)}),c!==null&&s.jsx("div",{className:"error small",children:c}),s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{disabled:i,onClick:()=>void p(t.questions.map(k=>({id:k.id,selected:[]}))),children:"跳过"}),s.jsx("button",{className:"inverse",disabled:i||!y,onClick:()=>void p(v()),children:"回答"})]})]})}const xr="main",qM={intervene:"alert",games:"gamepad",scripts:"package",pipelines:"flow"},br={id:xr,name:"助手",description:"和你对话、替你安排;飞书里的消息也到这里",icon:"chat"};function ac(e){return{id:e.id,name:e.name,description:e.description,icon:qM[e.id]??"sparkles"}}function fi(e){const t=Ee(e.connection.status),[n,r]=b.useState([]);return b.useEffect(()=>{if(t.state!=="open")return;let i=!0;return e.connection.call("roles/list",{}).then(o=>{i&&r(o.items)}).catch(()=>{}),()=>{i=!1}},[e,t.state]),b.useEffect(()=>e.connection.on("roles/changed",i=>r(i.items)),[e]),n}function _a(e,t){return e.role!==void 0&&t.some(n=>n.id===e.role)?e.role:xr}function GM(e){return e==="你"?"你布置的":`来自${e}`}function KM(e,t){const n=Ee(e.connection.status),[r,i]=b.useState(new Map),o=b.useRef(new Map),c=d=>`${d.updatedAt}${d.running?"+":""}`,u=t.map(d=>`${d.id}@${c(d)}`).join(",");return b.useEffect(()=>{if(n.state!=="open")return;const d=t.filter(f=>o.current.get(f.id)!==c(f)).slice(0,60);if(d.length!==0){for(const f of d)o.current.set(f.id,c(f));e.connection.call("sessions/lastReplies",{sessionIds:d.map(f=>f.id)}).then(f=>{i(p=>{const m=new Map(p);for(const g of f.items)m.set(g.sessionId,g.text);return m})}).catch(()=>{for(const f of d)o.current.delete(f.id)})}},[e,n.state,u]),r}const Yk="adg.agentSeen";function YM(){try{const e=JSON.parse(localStorage.getItem(Yk)??"{}");return e!==null&&typeof e=="object"?e:{}}catch{return{}}}function XM(){const[e,t]=b.useState(YM);return{seen:e,markSeen:(r,i)=>{t(o=>{if((o[r]??0)>=i)return o;const c={...o,[r]:i};try{localStorage.setItem(Yk,JSON.stringify(c))}catch{}return c})}}}function Xk(e,t){const n=Ee(e.connection.status),[r,i]=b.useState({agentId:t,sessionId:null,error:null});return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return e.connection.call("agents/home",{agentId:t}).then(c=>{o&&i({agentId:t,sessionId:c.sessionId,error:null})},c=>{o&&i({agentId:t,sessionId:null,error:c instanceof Error?c.message:String(c)})}),()=>{o=!1}},[e,t,n.state]),r.agentId===t?r:{sessionId:null,error:null}}function QM(e,t){const n=Ee(e.connection.status),r=Ee(e.capabilities),[i,o]=b.useState([]);return b.useEffect(()=>{if(n.state!=="open"||!r.has("agents"))return;let c=!0;return e.connection.call("handoffs/list",{sessionId:t}).then(u=>{c&&o(u.items)}).catch(()=>{}),()=>{c=!1}},[e,t,n.state,r]),b.useEffect(()=>e.connection.on("handoffs/changed",({item:c})=>{c.fromSession!==t&&c.toSession!==t||o(u=>[...u.filter(d=>d.id!==c.id),c])}),[e,t]),i}const JM={feishu:"飞书"},_h=30;function Qk(e){const t=Ee(e.connection.status),n=Ee(e.capabilities),[r,i]=b.useState(new Set),o=n.has("archive");return b.useEffect(()=>{if(t.state!=="open"||!o)return;let c=!0;return e.connection.call("sessions/archived",{}).then(u=>{c&&i(new Set(u.sessionIds))}).catch(()=>{}),()=>{c=!1}},[e,t.state,o]),b.useEffect(()=>e.connection.on("sessions/archived",c=>i(new Set(c.sessionIds))),[e]),r}function e$(e,t){const n=Ee(e.sessions),r=Ee(e.approvals),i=Ee(e.questions),o=fi(e),c=Qk(e),{seen:u,markSeen:d}=XM(),f=b.useMemo(()=>[br,...o.map(ac)],[o]),p=b.useMemo(()=>{var v;const g=new Map(f.map(y=>[y.id,[]]));for(const y of n.items)y.origin==="subagent"||y.blank||c.has(y.id)||(v=g.get(_a(y,o)))==null||v.push(y);for(const y of g.values())y.sort((S,k)=>k.updatedAt-S.updatedAt);return g},[n.items,c,f,o]);b.useEffect(()=>{var g,v;if(n.loaded)for(const y of f){const S=(v=(g=p.get(y.id))==null?void 0:g[0])==null?void 0:v.updatedAt;S!==void 0&&(y.id===t||u[y.id]===void 0)&&d(y.id,S)}},[n.loaded,p,t]);const m=g=>{const v=n.items.find(y=>y.id===g);return v===void 0?void 0:_a(v,o)};return f.map(g=>{const v=p.get(g.id)??[],y=v[0];return{agent:g,running:v.filter(S=>S.running).length,unread:g.id!==t&&y!==void 0&&y.updatedAt>(u[g.id]??1/0),waiting:[...r,...i].filter(S=>m(S.sessionId)===g.id).length}})}function t$(e,t){const n=Ee(e.sessions),r=fi(e);return n.items.some(i=>i.origin!=="subagent"&&!i.blank&&i.home!==t&&_a(i,r)===t)}function n$({client:e,agentId:t,onSelect:n}){const r=Ee(e.sessions),i=Ee(e.connection.status),o=Ee(e.capabilities),c=fi(e),u=Qk(e),d=Cn(3e4),[f,p]=b.useState(null),[m,g]=b.useState(""),[v,y]=b.useState(!1),[S,k]=b.useState(!1),[w,T]=b.useState(new Map),[N,$]=b.useState(0),D=o.has("archive");b.useEffect(()=>e.connection.on("notify/changed",()=>$(I=>I+1)),[e]),b.useEffect(()=>{if(i.state!=="open"||!o.has("notify"))return;let I=!0;return e.connection.call("notify/conversations",{}).then(L=>{I&&T(new Map(L.items.map(W=>[W.sessionId,{channel:W.channel,user:W.user}])))}).catch(()=>{}),()=>{I=!1}},[e,i.state,o,N]);const O=I=>{const L=w.get(I.id);return L!==void 0?JM[L.channel]??L.channel:/^(飞书|feishu):/.test(I.title??"")?"飞书":void 0},F=m.trim().toLowerCase(),{earlier:U,archivedItems:M}=b.useMemo(()=>{const I=r.items.filter(L=>L.origin!=="subagent"&&!L.blank&&L.home!==t&&_a(L,c)===t&&(F===""||ao(L).toLowerCase().includes(F))).sort((L,W)=>W.updatedAt-L.updatedAt);return{earlier:I.filter(L=>!u.has(L.id)),archivedItems:I.filter(L=>u.has(L.id))}},[r.items,t,c,u,F]),[P,R]=b.useState(null),Z=async()=>{const I=P;R(null);const L=(I==null?void 0:I.value.trim())??"",W=r.items.find(H=>H.id===(I==null?void 0:I.id));I===null||W===void 0||L===""||L===ao(W)||await e.renameSession(I.id,L).catch(H=>p(H instanceof Error?H.message:String(H)))},E=async(I,L)=>{p(null),await e.connection.call(L?"sessions/archive":"sessions/unarchive",{sessionId:I}).catch(W=>p(W instanceof Error?W.message:String(W)))},C=I=>{const L=O(I),W=u.has(I.id);return s.jsxs("div",{className:"session-row",children:[(P==null?void 0:P.id)===I.id?s.jsx("input",{className:"text-input session-rename",autoFocus:!0,value:P.value,maxLength:80,"aria-label":"会话名称",onFocus:H=>H.target.select(),onChange:H=>R({id:I.id,value:H.target.value}),onKeyDown:H=>{H.key==="Enter"&&!H.nativeEvent.isComposing&&Z(),H.key==="Escape"&&R(null)},onBlur:()=>void Z()}):s.jsxs("button",{className:"nav-item session-item",onClick:()=>n(I.id),onDoubleClick:()=>R({id:I.id,value:ao(I)}),title:"双击改名",children:[L!==void 0&&s.jsx("span",{className:"channel-badge",children:L}),s.jsx("span",{className:"nav-item-label",children:L!==void 0?ao(I).replace(/^(飞书|feishu):/,""):ao(I)}),I.running?s.jsx("span",{className:"run-dot",role:"img","aria-label":"运行中"}):s.jsx("span",{className:"session-time",children:$t(I.updatedAt,d)})]}),(P==null?void 0:P.id)!==I.id&&s.jsxs("span",{className:"session-row-actions",children:[s.jsx("button",{className:"session-action",title:"改名","aria-label":"改名",onClick:()=>R({id:I.id,value:ao(I)}),children:s.jsx(ee,{name:"pencil"})}),D&&!I.running&&s.jsx("button",{className:"session-action",title:W?"恢复":"归档:从列表里移走,之后可以在「已归档」里找回","aria-label":W?"恢复":"归档",onClick:()=>void E(I.id,!W),children:s.jsx(ee,{name:W?"back":"archive"})})]})]},I.id)};return s.jsx("section",{className:"main history-page",children:s.jsxs("div",{className:"history-body",children:[s.jsxs("label",{className:"sidebar-search",children:[s.jsx(ee,{name:"search"}),s.jsx("input",{"aria-label":"搜索以前的对话",placeholder:"搜索以前的对话",value:m,onChange:I=>g(I.target.value),onKeyDown:I=>{I.key==="Escape"&&g("")}})]}),f!==null&&s.jsx("div",{className:"error small",children:f}),s.jsxs("nav",{className:"session-list","aria-label":"以前的对话",children:[!r.loaded&&i.state==="open"&&s.jsx("div",{className:"muted small pad",children:"加载中…"}),r.loaded&&U.length===0&&s.jsxs("div",{className:"sidebar-empty",children:[s.jsx(ee,{name:F===""?"chat":"search"}),s.jsx("span",{children:F===""?"没有以前的对话":"没有匹配的对话"})]}),(S?U:U.slice(0,_h)).map(C),!S&&U.length>_h&&s.jsxs("button",{className:"nav-item more-sessions",onClick:()=>k(!0),children:["更多(",U.length-_h,")"]}),D&&M.length>0&&s.jsxs("div",{className:"archive-entry",children:[s.jsxs("button",{className:"nav-item role-row",onClick:()=>y(I=>!I),"aria-expanded":v,children:[s.jsx(ee,{name:"archive"}),s.jsx("span",{className:"nav-item-label",children:"已归档"}),s.jsx("span",{className:"tab-count",children:M.length}),s.jsx(ee,{name:v?"chevron-down":"chevron",className:"role-chevron"})]}),v&&M.map(C)]})]})]})})}function ao(e){return e.title??(e.blank?"新会话":"未命名会话")}function $t(e,t){const n=Math.max(0,Math.round((t-e)/1e3));return n<60?"刚刚":n<3600?`${Math.floor(n/60)} 分钟前`:n<86400?`${Math.floor(n/3600)} 小时前`:n<86400*7?`${Math.floor(n/86400)} 天前`:new Date(e).toLocaleDateString(void 0,{month:"numeric",day:"numeric"})}function s$({client:e,pages:t,current:n,onAgent:r,onPage:i,onSchedule:o,onSettings:c}){const u=Ee(e.connection.status),d=Ee(e.capabilities),f=e$(e,n.kind==="agent"?n.id:void 0),p=m=>s.jsx(Eh,{icon:m.icon,label:m.title,active:n.kind==="page"&&n.id===m.id,onClick:()=>i(m.id)},m.id);return s.jsxs("nav",{className:"rail","aria-label":"功能区",children:[s.jsx("button",{className:"rail-brand",onClick:()=>{var m;return r(((m=f[0])==null?void 0:m.agent.id)??"")},title:"MultiGameAssistant",children:s.jsx(gd,{})}),s.jsxs("div",{className:"rail-items",children:[t.filter(m=>m.order<0).map(p),s.jsx("span",{className:"rail-divider",role:"separator"}),f.map(m=>s.jsx(r$,{state:m,active:n.kind==="agent"&&n.id===m.agent.id,onClick:()=>r(m.agent.id)},m.agent.id)),t.filter(m=>m.order>=0).map(p)]}),s.jsxs("div",{className:"rail-footer",children:[d.has("pipelines")&&s.jsx(Eh,{icon:"calendar",label:"定时",title:"每个 agent 的定时任务,和按时运行的流水线",active:n.kind==="schedule",onClick:o}),s.jsx(Eh,{icon:"settings",label:"设置",active:n.kind==="settings",onClick:c}),s.jsxs("span",{className:`rail-connection ${u.state}`,role:"status",title:b0(u.state,u.attempt,u.error),children:[s.jsx("span",{className:"conn-dot"}),s.jsx("span",{className:"sr-only",children:b0(u.state,u.attempt,u.error)})]})]})]})}function r$({state:e,active:t,onClick:n}){const{agent:r,running:i,unread:o,waiting:c}=e;return s.jsxs("button",{className:`rail-item rail-agent ${t?"active":""}`,"aria-current":t?"page":void 0,onClick:n,title:`${r.name}:${r.description}${i>0?`(进行中${i>1?` ${i}`:""})`:""}`,children:[s.jsxs("span",{className:`agent-avatar rail-avatar agent-${r.id}`,children:[s.jsx(ee,{name:r.icon}),i>0&&s.jsx("span",{className:"agent-busy",role:"img","aria-label":`${i} 个正在运行`})]}),s.jsx("span",{className:`rail-label ${o?"unread":""}`,children:r.name}),c>0?s.jsx("span",{className:"rail-badge","aria-label":`${c} 个等你处理`,children:c}):o&&s.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新结果"})]})}function Eh({icon:e,label:t,title:n=t,active:r,onClick:i,disabled:o=!1}){return s.jsxs("button",{className:`rail-item ${r?"active":""}`,"aria-current":r?"page":void 0,onClick:i,title:n,disabled:o,children:[s.jsx(ee,{name:e}),s.jsx("span",{className:"rail-label",children:t})]})}function b0(e,t,n){const r=e==="open"?"已连接 agent":e==="connecting"?"正在连接…":e==="reconnecting"?`重连中(第 ${t} 次)`:"未连接";return n===void 0?r:`${r}:${n}`}const zp="adg.token",Em=/^\/adg(\/|$)/.test(location.pathname);function i$(){var e;for(const t of[window,window.parent])try{const n=(e=t.__DSH_TRANSPORT__)==null?void 0:e.streamBaseUrl;if(typeof n=="string"&&n!=="")return n}catch{}}function Jk(){const e=new URL(location.href),t=e.searchParams.get("token");if(t!==null&&t!==""){try{sessionStorage.setItem(zp,t)}catch{}return e.searchParams.delete("token"),history.replaceState(history.state,"",e),t}try{return sessionStorage.getItem(zp)}catch{return null}}function a$(e){try{sessionStorage.setItem(zp,e)}catch{}}function o$(e){if(Em){const n=new URL(i$()??location.origin);return`${n.protocol==="https:"?"wss":"ws"}://${n.host}/adg/rpc`}return`${location.protocol==="https:"?"wss":"ws"}://${location.host}/rpc?token=${encodeURIComponent(e??"")}`}function k0(){if(location.hash==="#/settings")return{kind:"settings"};const e=/^#\/settings\/(.+)$/.exec(location.hash);if(e!==null)return{kind:"settings",section:decodeURIComponent(e[1])};const t=/^#\/w\/([^/]+)\/(.+)$/.exec(location.hash);if(t!==null)return{kind:"window",view:decodeURIComponent(t[1]),sessionId:decodeURIComponent(t[2])};const n=/^#\/p\/([^/]+)(?:\/(.+))?$/.exec(location.hash);if(n!==null)return{kind:"page",id:decodeURIComponent(n[1]),...n[2]===void 0?{}:{arg:decodeURIComponent(n[2])}};if(location.hash==="#/chat")return{kind:"home"};if(location.hash==="#/schedule")return{kind:"schedule"};const r=/^#\/h\/(.+)$/.exec(location.hash);if(r!==null)return{kind:"handoff",id:decodeURIComponent(r[1])};const i=/^#\/a\/(.+)\/(schedule|history)$/.exec(location.hash);if(i!==null)return{kind:"agent",id:decodeURIComponent(i[1]),tab:i[2]};const o=/^#\/a\/(.+)$/.exec(location.hash);if(o!==null)return{kind:"agent",id:decodeURIComponent(o[1])};const c=/^#\/s\/(.+)$/.exec(location.hash);return c===null?{kind:"start"}:{kind:"session",id:decodeURIComponent(c[1])}}function l$(e,t="push"){const n=e.kind==="window"?`#/w/${encodeURIComponent(e.view)}/${encodeURIComponent(e.sessionId)}`:e.kind==="session"?`#/s/${encodeURIComponent(e.id)}`:e.kind==="agent"?`#/a/${encodeURIComponent(e.id)}${e.tab===void 0?"":`/${e.tab}`}`:e.kind==="handoff"?`#/h/${encodeURIComponent(e.id)}`:e.kind==="schedule"?"#/schedule":e.kind==="page"?`#/p/${encodeURIComponent(e.id)}${e.arg===void 0?"":`/${encodeURIComponent(e.arg)}`}`:e.kind==="settings"?e.section===void 0?"#/settings":`#/settings/${encodeURIComponent(e.section)}`:e.kind==="home"?"#/chat":"";if(location.hash===n)return;const r=`${location.pathname}${location.search}${n}`;t==="replace"?history.replaceState(history.state,"",r):history.pushState(null,"",r)}function c$(e,t){const n=new URL(location.href),r=Jk();return r!==null&&n.searchParams.set("token",r),n.hash=`#/w/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n.href}const Vu="adg.draft.",w0=60,Pp=new Map;function u$(e){try{const t=localStorage.getItem(Vu+e);if(t===null)return"";const n=JSON.parse(t);return typeof n.text=="string"?n.text:""}catch{return""}}function d$(e,t){try{if(t.trim()===""){localStorage.removeItem(Vu+e);return}localStorage.setItem(Vu+e,JSON.stringify({text:t,at:Date.now()})),p$()}catch{}}function f$(e){return Pp.get(e)??[]}function h$(e,t){t.length===0?Pp.delete(e):Pp.set(e,[...t])}function p$(){const e=[];for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(!(n===null||!n.startsWith(Vu)))try{e.push({key:n,at:Number(JSON.parse(localStorage.getItem(n)??"{}").at)||0})}catch{e.push({key:n,at:0})}}if(!(e.length<=w0))for(const t of e.sort((n,r)=>n.at-r.at).slice(0,e.length-w0))localStorage.removeItem(t.key)}const m$={off:"不思考",none:"不思考",minimal:"最少",low:"低",medium:"中",high:"高",xhigh:"很高",max:"最大"},N0=(e,t)=>m$[e]??(t!==void 0&&t!==e?t:e);function g$(e,t){var n;if(!(e===null||t===null))return(n=e.groups.find(r=>r.id===t.provider))==null?void 0:n.models.find(r=>r.id===t.model)}function x$({client:e,sessionId:t,disabled:n,value:r,onChange:i}){var Z;const{catalog:o,error:c}=ic(e),u=Ee(e.sessionModels),d=Ee(e.connection.status),[f,p]=b.useState(!1),[m,g]=b.useState(null),[v,y]=b.useState(!1),[S,k]=b.useState(""),w=b.useRef(null);b.useEffect(()=>{d.state!=="open"||t===void 0||e.sessionModel(t).catch(()=>{})},[e,t,d.state]),b.useEffect(()=>{if(!v)return;const E=I=>{w.current!==null&&!w.current.contains(I.target)&&y(!1)},C=I=>{I.key==="Escape"&&y(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",C)}},[v]);const T=t===void 0?void 0:u.get(t),N=(t===void 0?r:(T==null?void 0:T.next)??(T==null?void 0:T.lastUsed))??(o==null?void 0:o.default)??null,$=g$(o,N),D=N!==null&&o!==null&&$===void 0,O=async E=>{if(g(null),t===void 0){i==null||i(E);return}p(!0);try{await e.selectModel(t,E)}catch(C){g(C instanceof Error?C.message:String(C))}finally{p(!1)}},F=(E,C)=>{const I=(N==null?void 0:N.reasoningEffort)!==void 0&&C.efforts.some(L=>L.id===N.reasoningEffort)?N.reasoningEffort:C.defaultEffort;O({provider:E,model:C.id,...I===void 0?{}:{reasoningEffort:I}}),C.efforts.length===0&&y(!1)},U=b.useMemo(()=>{const E=S.trim().toLowerCase();return((o==null?void 0:o.groups)??[]).map(C=>({...C,models:C.models.filter(I=>E===""||I.id.toLowerCase().includes(E)||I.name.toLowerCase().includes(E)||C.name.toLowerCase().includes(E))})).filter(C=>C.models.length>0)},[o,S]),M=[m,c,...(o==null?void 0:o.failures.map(E=>`${E.name}:${E.message}`))??[]].filter(Boolean);if(o===null)return null;const P=(N==null?void 0:N.reasoningEffort)??($==null?void 0:$.defaultEffort),R=(Z=$==null?void 0:$.efforts.find(E=>E.id===P))==null?void 0:Z.name;return s.jsxs("div",{className:`model-picker${m!==null?" has-error":""}`,ref:w,children:[s.jsxs("button",{type:"button",className:"model-trigger","aria-haspopup":"dialog","aria-expanded":v,disabled:n||f,title:M.length>0?M.join(`
|
|
124
|
-
`):"选择模型和思考强度",onClick:()=>y(E=>!E),children:[s.jsx("span",{className:`model-dot ${D?"off":""}`}),s.jsx("span",{className:"model-name",children:($==null?void 0:$.name)??(N===null?"选择模型":`${N.model}(不可用)`)}),P!==void 0&&$!==void 0&&$.efforts.length>0&&s.jsx("span",{className:"model-effort",children:N0(P,R)}),s.jsx(ee,{name:"chevron-down"})]}),v&&s.jsxs("div",{className:"model-panel",role:"dialog","aria-label":"选择模型",children:[s.jsx("input",{className:"text-input plain model-search",autoFocus:!0,placeholder:"搜索模型",value:S,onChange:E=>k(E.target.value)}),s.jsxs("div",{className:"model-list",role:"listbox","aria-label":"模型",children:[U.length===0&&s.jsx("div",{className:"muted small pad",children:"没有匹配的模型"}),U.map(E=>s.jsxs("div",{className:"model-group",children:[s.jsx("div",{className:"model-group-name",children:E.name}),E.models.map(C=>{const I=(N==null?void 0:N.provider)===E.id&&N.model===C.id;return s.jsxs("button",{type:"button",role:"option","aria-selected":I,className:`model-option ${I?"active":""}`,onClick:()=>F(E.id,C),children:[s.jsxs("span",{className:"model-option-main",children:[s.jsx("span",{children:C.name}),C.name!==C.id&&s.jsx("span",{className:"muted small",children:C.id})]}),C.efforts.length>0&&s.jsx("span",{className:"model-tag",children:"思考"}),I&&s.jsx(ee,{name:"check"})]},C.id)})]},E.id))]}),$!==void 0&&N!==null&&s.jsxs("div",{className:"model-efforts",children:[s.jsx("span",{className:"field-label",children:"思考强度"}),$.efforts.length===0?s.jsx("span",{className:"muted small",children:"这个模型没有可选的思考强度(在「设置 → 模型」里给模型打开「思考」)"}):s.jsx("div",{className:"segmented-control",role:"radiogroup","aria-label":"思考强度",children:$.efforts.map(E=>s.jsx("button",{type:"button",role:"radio","aria-checked":P===E.id,className:P===E.id?"active":"",onClick:()=>void O({provider:N.provider,model:N.model,reasoningEffort:E.id}),children:N0(E.id,E.name)},E.id))})]}),M.length>0&&s.jsx("div",{className:"error small model-problems",children:M.join(";")})]})]})}function ew(e,t){return t.find(n=>n.scripts.includes(e.packId??e.id)||n.scripts.includes(e.id))}function Lp(e,t){const n=e.toLowerCase();return t.find(r=>[r.id,r.name,...r.aliases].some(i=>i.toLowerCase()===n))}function Dp(e,t,n){const r=[];for(const i of new Set((e==null?void 0:e.scripts)??[])){const o=t.find(u=>u.id===i||u.packId===i),c=o===void 0?n.find(u=>u.scripts.includes(i)):ew(o,n);r.push({script:o===void 0?{id:i,name:i}:{id:o.id,name:o.name},...c===void 0?{}:{game:{id:c.id,name:c.name}}})}if(r.length===0)for(const i of new Set((e==null?void 0:e.games)??[])){const o=Lp(i,n);r.push({game:o===void 0?{id:i,name:i}:{id:o.id,name:o.name}})}return r}function tw(e){var t,n;return[(t=e.game)==null?void 0:t.name,(n=e.script)==null?void 0:n.name].filter(r=>r!==void 0).join(" · ")}let Ch=[];function v$(e){const t=Ee(e.capabilities),n=t.has("skills"),r=t.has("scripts"),i=t.has("games"),[o,c]=b.useState(Ch),[u,d]=b.useState(0);return b.useEffect(()=>e.connection.on("skills/changed",()=>d(f=>f+1)),[e]),b.useEffect(()=>{if(!n)return;let f=!0;const p=r?e.connection.call("scripts/list",{}).then(g=>g.scripts,()=>[]):Promise.resolve([]),m=i?e.connection.call("games/list",{}).then(g=>g.games,()=>[]):Promise.resolve([]);return Promise.all([e.connection.call("skills/list",{}),p,m]).then(([g,v,y])=>{Ch=g.skills.filter(S=>S.userInvocable).map(S=>{const k=[...new Set(Dp(S.owner,v,y).map(tw))].join("、");return{name:S.name,description:S.description,...k===""?{}:{group:k}}}),f&&c(Ch)},()=>{}),()=>{f=!1}},[e,n,r,i,u]),o}const Ih=e=>e.kind==="command"?"命令":e.group??"通用技能";function nw({client:e,text:t,setText:n,area:r,submit:i,placement:o="above",inSession:c=!1}){const u=v$(e),[d,f]=b.useState(0),[p,m]=b.useState(!1),g=p?[]:cM(t,u,c),v=t.split(/\s/)[0];b.useEffect(()=>{f(0),m(!1)},[v]);const y=Math.min(d,Math.max(0,g.length-1)),S=N=>{var $;n(`/${N.name} `),m(!0),($=r.current)==null||$.focus()},k=N=>{var $;if(i!==void 0&&N.kind==="command"&&N.arg===void 0){n(""),i(`/${N.name}`),($=r.current)==null||$.focus();return}S(N)},w=N=>{if(g.length===0||N.nativeEvent.isComposing)return!1;if(N.key==="ArrowDown"||N.key==="ArrowUp")return N.preventDefault(),f((y+(N.key==="ArrowDown"?1:g.length-1))%g.length),!0;if(N.key==="Tab"||N.key==="Enter"&&!N.shiftKey){N.preventDefault();const $=g[y];return N.key==="Tab"?S($):k($),!0}return N.key==="Escape"?(N.preventDefault(),m(!0),!0):!1};return{menu:g.length===0?null:s.jsx(y$,{options:g,active:y,placement:o,onHover:f,onChoose:k}),onKeyDown:w,expand:N=>oM(N,u)}}function y$({options:e,active:t,placement:n,onHover:r,onChoose:i}){const o=b.useRef(null),[c,u]=b.useState(0);b.useLayoutEffect(()=>{var p;const f=(p=o.current)==null?void 0:p.querySelector(`[data-index="${t}"]`);f==null||o.current===null||(f.scrollIntoView({block:"nearest"}),u(f.offsetTop-o.current.scrollTop))},[t,e]);const d=e[t];return s.jsxs("div",{className:`slash-pop ${n}`,children:[s.jsx("div",{ref:o,className:"slash-list",role:"listbox","aria-label":"命令和技能",onScroll:()=>{var p;const f=(p=o.current)==null?void 0:p.querySelector(`[data-index="${t}"]`);f!=null&&o.current!==null&&u(f.offsetTop-o.current.scrollTop)},children:e.map((f,p)=>s.jsxs("div",{children:[(p===0||Ih(e[p-1])!==Ih(f))&&s.jsx("div",{className:"slash-group",children:Ih(f)}),s.jsx("button",{type:"button",role:"option","data-index":p,"aria-selected":p===t,className:`slash-item ${p===t?"active":""}`,onMouseEnter:()=>r(p),onMouseDown:m=>m.preventDefault(),onClick:()=>i(f),children:f.name})]},`${f.kind}:${f.name}`))}),d!==void 0&&s.jsxs("div",{className:"slash-tip",style:{top:c},role:"tooltip",children:[d.kind==="skill"&&s.jsx("span",{className:"slash-tip-kind",children:d.group===void 0?"技能":`${d.group} 的技能`}),d.description,d.kind==="command"&&d.arg!==void 0&&s.jsxs("span",{className:"slash-tip-arg",children:["后面可以接:",d.arg]}),d.kind==="skill"&&s.jsx("span",{className:"slash-tip-arg",children:"后面写要它做的事"})]})]})}const Fp=5.5,j0=2*Math.PI*Fp,S0=[{key:"systemTokens",label:"系统提示词",tone:"system"},{key:"toolsTokens",label:"工具定义",tone:"tools"},{key:"messageTokens",label:"对话消息",tone:"messages"}];function Ah(e){return e>=1e6?`${_0(e/1e6)}M`:e>=1e3?`${_0(e/1e3)}k`:String(Math.round(e))}const _0=e=>e>=100?Math.round(e).toString():e.toFixed(1).replace(/\.0$/,"");function b$({context:e}){const[t,n]=b.useState(!1),r=b.useRef(null);if(b.useEffect(()=>{if(!t)return;const p=g=>{var v;(v=r.current)!=null&&v.contains(g.target)||n(!1)},m=g=>{g.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",m)}},[t]),e===null)return null;const i=Math.min(100,Math.round(e.usedTokens/e.contextWindow*100)),o=i>=90?"high":i>=70?"raised":"normal",c=e.breakdown,u=c===void 0?0:c.systemTokens+c.toolsTokens+c.messageTokens,d=c===void 0||u===0?[{key:"total",tone:"messages",width:i}]:S0.map(p=>({key:p.key,tone:p.tone,width:i*c[p.key]/u})).filter(p=>p.width>0),f=`上下文已用 ${i}%`;return s.jsxs("span",{ref:r,className:`context-meter ${o}`,children:[s.jsxs("button",{type:"button",className:"context-trigger",title:f,"aria-label":f,"aria-haspopup":"dialog","aria-expanded":t,onClick:()=>n(!t),children:[s.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[s.jsx("circle",{className:"context-track",cx:"7",cy:"7",r:Fp}),s.jsx("circle",{className:"context-fill",cx:"7",cy:"7",r:Fp,strokeDasharray:`${j0*i/100} ${j0}`,transform:"rotate(-90 7 7)"})]}),s.jsxs("span",{children:[i,"%"]})]}),t&&s.jsxs("div",{className:"context-panel",role:"dialog","aria-label":"上下文用量",children:[s.jsxs("div",{className:"context-head",children:[s.jsxs("span",{children:["上下文已用 ",s.jsxs("strong",{children:[i,"%"]})]}),s.jsxs("span",{className:"context-figures",children:["~",Ah(e.usedTokens)," / ",Ah(e.contextWindow)]})]}),s.jsx("div",{className:"context-bar",children:d.map(p=>s.jsx("span",{className:`context-segment ${p.tone}`,style:{width:`${p.width}%`}},p.key))}),c!==void 0&&s.jsx("dl",{className:"context-rows",children:S0.map(p=>s.jsxs("div",{children:[s.jsxs("dt",{children:[s.jsx("span",{className:`context-swatch ${p.tone}`,"aria-hidden":"true"}),p.label]}),s.jsxs("dd",{children:["~",Ah(c[p.key])]})]},p.key))}),s.jsxs("p",{className:"context-tip",children:["快满时会自动压缩(「设置 → 对话压缩」)。也可以输入 ",s.jsx("kbd",{children:"/压缩"})," 手动压缩:较早的部分换成摘要,agent 会忘掉其中的细节。"]})]})]})}function k$({client:e,session:t,running:n,disabled:r,initialPrompt:i,onInitialSent:o}){const c=Ee(e.capabilities),{queue:u,context:d}=Ee(t.state),[f,p]=b.useState(()=>u$(t.id)),[m,g]=b.useState(!1),[v,y]=b.useState(null),[S,k]=b.useState(null),w=b.useRef(null),T=b.useRef(null),N=b.useRef(!1),[$,D]=b.useState(()=>f$(t.id));b.useEffect(()=>d$(t.id,f),[t.id,f]),b.useEffect(()=>h$(t.id,$),[t.id,$]);const O=OM(e),[F,U]=b.useState(!1),M=async H=>{const G=H.filter(V=>V.type.startsWith("image/"));if(G.length===0)return;y(null);const K=ml-$.length;if(K<=0){y(`一条消息最多 ${ml} 张图片`);return}try{const V=await Promise.all(G.slice(0,K).map(j$));D(Y=>[...Y,...V].slice(0,ml)),G.length>K&&y(`一条消息最多 ${ml} 张图片,多的没有加上`)}catch(V){y(`图片没能加上:${V instanceof Error?V.message:String(V)}`)}},P=H=>{const G=[...H.clipboardData.items].filter(K=>K.kind==="file"&&K.type.startsWith("image/")).map(K=>K.getAsFile()).filter(K=>K!==null);G.length!==0&&(H.preventDefault(),M(G))},R=H=>{U(!1),H.dataTransfer.files.length!==0&&(H.preventDefault(),M([...H.dataTransfer.files]))};b.useEffect(()=>{var H;i===void 0||N.current||r||(N.current=!0,t.prompt(i,"queue").catch(G=>y(G instanceof Error?G.message:String(G))),o==null||o(),(H=w.current)==null||H.focus())},[i,r,t,o]);const Z=H=>iM(H)!=="compact"?!1:(p(""),y(null),n?(y("agent 正在工作,等它停下再压缩"),!0):(window.confirm(w$)&&(k("正在压缩对话:模型在写摘要,可能要一两分钟…"),t.compact().then(G=>k(G.message),G=>{k(null),y(G instanceof Error?G.message:String(G))})),!0)),E=nw({client:e,text:f,setText:p,area:w,inSession:!0,submit:H=>{r||Z(H)||(y(null),t.prompt(E.expand(H),n&&m?"steer":"queue").catch(G=>y(G instanceof Error?G.message:String(G))))}}),C=()=>{var K;if(!r&&$.length===0&&Z(f))return;const H=E.expand(f);if(H===""&&$.length===0||r)return;const G=$.map(({url:V,...Y})=>Y);p(""),D([]),y(null),t.prompt(H,n&&m?"steer":"queue",G).catch(V=>y(V instanceof Error?V.message:String(V))),(K=w.current)==null||K.focus()},I=H=>{E.onKeyDown(H)||H.key==="Enter"&&!H.shiftKey&&!H.nativeEvent.isComposing&&(H.preventDefault(),C())},L=H=>{t.updateQueue(H.id,"remove").then(()=>{f.trim()===""&&H.text!==""&&p(H.text)},G=>y(G instanceof Error?G.message:String(G)))},W=H=>{t.updateQueue(H.id,"steer").catch(G=>y(G instanceof Error?G.message:String(G)))};return s.jsxs("div",{className:"composer",children:[v!==null&&s.jsx("div",{className:"error small composer-error",children:v}),S!==null&&s.jsxs("div",{className:"composer-note small",role:"status",children:[s.jsx("span",{children:S}),s.jsx("button",{type:"button",className:"ghost small-button",onClick:()=>k(null),children:"知道了"})]}),u.length>0&&s.jsx("div",{className:"queue","aria-label":"等待发送的消息",children:u.map(H=>s.jsxs("div",{className:"queue-item",children:[s.jsx("span",{className:`queue-tag ${H.placement}`,children:H.placement==="next-step"?"插入中":"排队中"}),s.jsxs("span",{className:"queue-text",title:H.text,children:[H.text===""?"(图片)":H.text,H.images!==void 0&&s.jsxs("span",{className:"muted",children:[" · ",H.images," 张图片"]})]}),s.jsx("span",{className:"queue-when muted",children:H.placement==="next-step"?"这一步做完就交给 agent":"这一轮结束后发送"}),H.placement==="next-turn"&&n&&s.jsx("button",{type:"button",className:"small-button",title:"不等这一轮结束,现在就交给 agent",onClick:()=>W(H),children:"现在插入"}),s.jsx("button",{type:"button",className:"small-button",title:"撤回这条消息",onClick:()=>L(H),children:"撤回"})]},H.id))}),s.jsxs("div",{className:"slash-anchor",children:[E.menu,s.jsxs("div",{className:`composer-box ${F?"dragging":""}`,onDragOver:H=>{[...H.dataTransfer.items].some(G=>G.kind==="file")&&(H.preventDefault(),U(!0))},onDragLeave:()=>U(!1),onDrop:R,children:[$.length>0&&s.jsx("div",{className:"composer-images",children:$.map((H,G)=>s.jsxs("span",{className:"composer-image",children:[s.jsx("img",{src:H.url,alt:H.name??`图片 ${G+1}`}),s.jsx("button",{type:"button","aria-label":"移除这张图片",onClick:()=>D(K=>K.filter((V,Y)=>Y!==G)),children:"✕"})]},G))}),s.jsx("textarea",{onPaste:P,ref:w,"aria-label":"消息内容",value:f,onChange:H=>p(H.target.value),onKeyDown:I,rows:Math.min(8,Math.max(2,f.split(`
|
|
125
|
-
`).length)),placeholder:r?"未连接到 agent":n?"运行中:消息会排队到下一轮":"继续追问,或描述下一步要做的事",disabled:r}),s.jsxs("div",{className:"composer-actions",children:[c.has("models")&&s.jsx(x$,{client:e,sessionId:t.id,disabled:r}),s.jsx("button",{type:"button",className:"attach-button",title:"添加图片(也可以直接粘贴或拖进来)","aria-label":"添加图片",disabled:r||$.length>=ml,onClick:()=>{var H;return(H=T.current)==null?void 0:H.click()},children:s.jsx(ee,{name:"image"})}),s.jsx("input",{ref:T,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:H=>{M([...H.target.files??[]]),H.target.value=""}}),O==="full"&&s.jsxs("button",{type:"button",className:"full-access-chip",title:"agent 做事不再请求确认,点这里修改",onClick:()=>{location.hash="#/settings/permissions"},children:[s.jsx(ee,{name:"alert"}),"完全访问"]}),s.jsx("span",{className:"spacer"}),s.jsx(b$,{context:d}),n&&s.jsxs("label",{className:"steer-toggle",title:"把消息插入正在进行的轮次,而不是等下一轮",children:[s.jsx("input",{type:"checkbox",checked:m,onChange:H=>g(H.target.checked)}),"插入当前轮次"]}),n&&s.jsxs("button",{className:"stop-button",onClick:()=>void t.cancel().catch(H=>y(String(H))),disabled:r,children:[s.jsx(PM,{}),"停止"]}),s.jsx("button",{className:"send-button","aria-label":"发送",title:"发送(Enter)",onClick:C,disabled:r||f.trim()===""&&$.length===0,children:s.jsx(ee,{name:"arrow"})})]})]})]}),s.jsxs("div",{className:"composer-hint",children:[s.jsxs("span",{children:[s.jsx("kbd",{children:"/"})," 命令和技能"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"Enter"})," 发送"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"Shift+Enter"})," 换行"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"Ctrl+V"})," 粘贴图片"]})]})]})}const w$=["压缩会把这个对话较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:","","· 会丢失记忆:早先的细节 agent 不再记得(具体的命令和输出、日志、截图、你说过的原话);","· 摘要可能漏掉或写错内容;","· 不能撤销。界面上的聊天记录还在,但 agent 看不到了。","","对话很长、回复变慢或报上下文超长时再压缩。确定压缩吗?"].join(`
|
|
126
|
-
`),ml=4,N$=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function j$(e){const t=await new Promise((o,c)=>{const u=new FileReader;u.onload=()=>o(String(u.result)),u.onerror=()=>c(u.error??new Error("读取失败")),u.readAsDataURL(e)}),n=e.name===""||e.name==="image.png"?`粘贴的图片.${e.type.split("/")[1]??"png"}`:e.name,r=t.slice(t.indexOf(",")+1);if(N$.has(e.type)&&r.length<=Ip)return{mediaType:e.type,data:r,name:n,url:t};const i=new Image;i.src=t,await i.decode();for(let o=2560;o>=640;o=Math.round(o*.75)){const c=Math.min(1,o/Math.max(i.naturalWidth,i.naturalHeight)),u=document.createElement("canvas");u.width=Math.max(1,Math.round(i.naturalWidth*c)),u.height=Math.max(1,Math.round(i.naturalHeight*c)),u.getContext("2d").drawImage(i,0,0,u.width,u.height);const d=u.toDataURL("image/jpeg",.88),f=d.slice(d.indexOf(",")+1);if(f.length<=Ip)return{mediaType:"image/jpeg",data:f,name:n.replace(/\.\w+$/,".jpg"),url:d}}throw new Error("图片太大")}function Bp({client:e,sessionId:t,reminder:n,initialPrompt:r,onInitialSent:i,onAgent:o}){const c=Vk(e,t);return c===null?s.jsx("div",{className:"main empty",children:"正在打开会话…"}):s.jsx(S$,{client:e,session:c,reminder:n,initialPrompt:r,onInitialSent:i,onAgent:o})}function S$({client:e,session:t,reminder:n,initialPrompt:r,onInitialSent:i,onAgent:o}){const c=Ee(t.state),u=Ee(e.connection.status),d=fi(e),f=Ee(e.sessions).items.find(T=>T.id===t.id),p=f===void 0?xr:_a(f,d),m=d.find(T=>T.id===p),g=m===void 0?br:ac(m),v=(f==null?void 0:f.home)!==void 0,y=CM(Wk(e),c),[S,k]=b.useState(()=>I$()),w=y.find(T=>T.id===S)??y[0];return b.useEffect(()=>A$(S),[S]),s.jsxs("section",{className:"main",children:[s.jsxs("header",{className:"session-header",children:[s.jsxs("div",{className:"session-heading",children:[v?s.jsxs("div",{className:"breadcrumb agent-heading",children:[s.jsx("span",{className:`agent-avatar small agent-${g.id}`,children:s.jsx(ee,{name:g.icon})}),s.jsx("h1",{children:g.name})]}):s.jsxs("div",{className:"breadcrumb",children:[o!==void 0?s.jsx("button",{type:"button",className:"link-button breadcrumb-link",title:`回到「${g.name}」的对话`,onClick:()=>o(p),children:g.name}):s.jsx("span",{children:g.name}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx(C$,{title:c.title,onRename:T=>e.renameSession(t.id,T)})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx(sw,{running:c.running}),v?s.jsx("span",{children:g.description}):s.jsx("span",{children:"以前的对话"}),!v&&p!==xr&&(f==null?void 0:f.requestedBy)!==void 0&&s.jsx("span",{children:GM(f.requestedBy)})]})]}),s.jsxs("div",{className:"session-actions",children:[s.jsx("nav",{className:"tabs",role:"tablist","aria-label":"会话视图",children:y.map(T=>s.jsx("button",{role:"tab","aria-selected":T.id===(w==null?void 0:w.id),className:T.id===(w==null?void 0:w.id)?"active":"",onClick:()=>k(T.id),children:T.title},T.id))}),w!==void 0&&s.jsx("button",{className:"icon-button popout-button",title:`在新窗口打开「${w.title}」`,"aria-label":`在新窗口打开「${w.title}」`,onClick:()=>window.open(c$(w.id,t.id),`dsh-${w.id}-${t.id}`),children:s.jsx(ee,{name:"popout"})})]})]}),c.error!==null&&s.jsx("div",{className:"banner error",children:c.error}),s.jsx("div",{className:"view",children:w===void 0?s.jsx("div",{className:"empty",children:"当前连接没有提供可用的视图插件。"}):s.jsx(w.component,{client:e,session:t,state:c})}),n,s.jsx(k$,{client:e,session:t,running:c.running,disabled:u.state!=="open",initialPrompt:r,onInitialSent:i})]})}function _$({client:e,viewId:t,sessionId:n}){const r=Vk(e,n),i=Wk(e),o=Ee(e.connection.status),c=i.find(u=>u.id===t);return r===null||c===void 0?s.jsx("div",{className:"popped",children:s.jsx("section",{className:"main empty",children:o.state==="open"&&c===void 0?"当前连接没有提供这个视图。":"正在打开…"})}):s.jsx(E$,{client:e,session:r,view:c})}function E$({client:e,session:t,view:n}){const r=Ee(t.state);return b.useEffect(()=>{document.title=`${n.title} · ${r.title??"会话"}`},[n.title,r.title]),s.jsx("div",{className:"popped",children:s.jsxs("section",{className:"main",children:[s.jsx("header",{className:"session-header",children:s.jsxs("div",{className:"session-heading",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:n.title}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:r.title??"新会话"})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx(sw,{running:r.running}),s.jsx("span",{children:"与主窗口同步更新"})]})]})}),r.error!==null&&s.jsx("div",{className:"banner error",children:r.error}),s.jsx("div",{className:"view",children:s.jsx(n.component,{client:e,session:t,state:r})})]})})}function C$({title:e,onRename:t}){const[n,r]=b.useState(null),[i,o]=b.useState(null),c=e??"新会话",u=async()=>{const d=(n==null?void 0:n.trim())??"";if(d===""||d===e){r(null);return}try{await t(d),r(null),o(null)}catch(f){o(f instanceof Error?f.message:String(f))}};return n!==null?s.jsxs("span",{className:"title-edit",children:[s.jsx("input",{className:"text-input",autoFocus:!0,value:n,maxLength:80,"aria-label":"会话名称",onChange:d=>r(d.target.value),onFocus:d=>d.target.select(),onKeyDown:d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&u(),d.key==="Escape"&&(r(null),o(null))},onBlur:()=>void u()}),i!==null&&s.jsx("span",{className:"error small",children:i})]}):s.jsxs("span",{className:"session-title",children:[s.jsx("h1",{title:"双击改名",onDoubleClick:()=>r(c),children:c}),s.jsx("button",{type:"button",className:"icon-button rename-button",title:"改名","aria-label":"给这个会话改名",onClick:()=>r(c),children:s.jsx(ee,{name:"pencil"})})]})}function sw({running:e}){return e?s.jsxs("span",{className:"status-pill running",children:[s.jsx("span",{className:"pill-dot"}),"运行中"]}):s.jsx("span",{className:"status-pill",children:"空闲"})}const rw="adg.sessionTab";function I$(){try{return localStorage.getItem(rw)??"chat"}catch{return"chat"}}function A$(e){try{localStorage.setItem(rw,e)}catch{}}const iw="adg.theme",Up=new Set;let Rl=T$();function T$(){try{const e=localStorage.getItem(iw);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function aw(){var e,t;Rl==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=Rl,(t=(e=kr())==null?void 0:e.setTheme)==null||t.call(e,Rl).catch(()=>{})}function M$(e){Rl=e;try{localStorage.setItem(iw,e)}catch{}aw();for(const t of Up)t()}function ow(){return b.useSyncExternalStore(e=>(Up.add(e),()=>Up.delete(e)),()=>Rl)}const $$={"api-keys":"key",permissions:"shield",plugins:"plug","script-install":"package",emulators:"monitor",schedule:"calendar",feishu:"send",compaction:"compress",about:"info"},R$=[["light","浅色"],["dark","深色"],["system","跟随系统"]];function O$({client:e,onClose:t,section:n,onSection:r}){const i=$M(e),o=ow(),[c,u]=b.useState(null),d=c??n??null,f=m=>{u(m),r==null||r(m)},p=i.find(m=>m.id===d)??i[0];return s.jsxs(s.Fragment,{children:[s.jsxs("aside",{className:"sidebar settings-sidebar",children:[s.jsxs("button",{className:"nav-item back-link",onClick:t,children:[s.jsx(ee,{name:"back"}),s.jsx("span",{className:"nav-item-label",children:"返回"})]}),s.jsx("h1",{className:"settings-title",children:"设置"}),s.jsxs("nav",{className:"page-list","aria-label":"设置分类",children:[s.jsx("div",{className:"sidebar-label",children:"偏好设置"}),i.map(m=>s.jsxs("button",{className:`nav-item ${m.id===(p==null?void 0:p.id)?"active":""}`,"aria-current":m.id===(p==null?void 0:p.id)?"page":void 0,onClick:()=>f(m.id),children:[s.jsx(ee,{name:$$[m.id]??"settings"}),s.jsx("span",{className:"nav-item-label",children:m.title})]},m.id))]}),s.jsxs("div",{className:"page-list",children:[s.jsx("div",{className:"sidebar-label",id:"theme-label",children:"外观"}),s.jsx("div",{className:"segmented-control",role:"radiogroup","aria-labelledby":"theme-label",children:R$.map(([m,g])=>s.jsx("button",{role:"radio","aria-checked":o===m,className:o===m?"active":"",onClick:()=>M$(m),children:g},m))})]})]}),s.jsx("section",{className:"main settings",children:s.jsx("div",{className:"settings-content",children:p===void 0?s.jsx("div",{className:"empty",children:"当前连接没有提供可配置的项目。"}):s.jsx(p.component,{client:e})})})]})}function Cm(e){const t=Ee(e.connection.status),[n,r]=b.useState({data:null,error:null}),[i,o]=b.useState(0),c=b.useCallback(()=>o(u=>u+1),[]);return b.useEffect(()=>e.connection.on("scripts/changed",()=>c()),[e,c]),b.useEffect(()=>{if(t.state!=="open")return;let u=!0;return e.connection.call("scripts/list",{}).then(d=>{u&&r({data:d,error:null})}).catch(d=>{u&&r(f=>({...f,error:Pe(d)}))}),()=>{u=!1}},[e,t.state,i]),{...n,refresh:c}}function z$(e){const t=Ee(e.connection.status),[n,r]=b.useState(new Map);return b.useEffect(()=>e.connection.on("scripts/job",i=>{r(o=>{const c=o.get(i.scriptId);return c!==void 0&&c.id!==i.id&&c.startedAt>i.startedAt?o:new Map(o).set(i.scriptId,i)})}),[e]),b.useEffect(()=>{if(t.state!=="open")return;let i=!0;return e.connection.call("scripts/jobs",{}).then(({items:o})=>{if(!i)return;const c=new Map;for(const u of[...o].sort((d,f)=>d.startedAt-f.startedAt))c.set(u.scriptId,u);r(c)}).catch(()=>{}),()=>{i=!1}},[e,t.state]),n}function Pe(e){return e instanceof Error?e.message:String(e)}function va(e){return e<1024?`${e} B`:e<1024**2?`${(e/1024).toFixed(0)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}const Wu={queued:"排队中",resolving:"读取发布信息",downloading:"下载中",verifying:"校验中",extracting:"解压中",checking:"检查环境",running:"处理中",done:"完成",failed:"失败",cancelled:"已取消"},lw={"maafw-pi":"MaaFramework",cli:"命令行","gui-config":"配置驱动 GUI","generic-process":"通用程序",visual:"界面操作"};function co(e){return e!==void 0&&e.endedAt===void 0}const cw=["日","一","二","三","四","五","六"],uw=[1,2,3,4,5,6,0];function Im(e){return e.enabled?e.times.length===0?e.after===void 0?"没有设时间":`「${e.after}」跑完后`:`${e.days.length===0||e.days.length===7?"每天":`每周${uw.filter(n=>e.days.includes(n)).map(n=>cw[n]).join("、")}`} ${[...e.times].sort().join("、")}`:"已暂停"}function vo(e,t){if(!e.enabled)return;const n=new Date(t);n.setHours(0,0,0,0);for(let r=0;r<8;r++,n.setDate(n.getDate()+1)){if(e.days.length>0&&!e.days.includes(n.getDay()))continue;const i=e.times.map(o=>{const[c,u]=o.split(":").map(Number);return new Date(n.getFullYear(),n.getMonth(),n.getDate(),c,u).getTime()}).filter(o=>o>t).sort((o,c)=>o-c);if(i[0]!==void 0)return i[0]}}const oc=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"});function dw(e,t){const n=Ee(e.connection.status),[r,i]=b.useState(0),[o,c]=b.useState({items:null,error:null});return b.useEffect(()=>e.connection.on("tasks/changed",()=>i(u=>u+1)),[e]),b.useEffect(()=>{if(n.state!=="open")return;let u=!0;return e.connection.call("tasks/list",t===void 0?{}:{agent:t}).then(d=>{u&&c({items:d.items,error:null})},d=>{u&&c(f=>({...f,error:Pe(d)}))}),()=>{u=!1}},[e,t,n.state,r]),o}function fw(e,t){const n=Ee(e.connection.status),r=Ee(e.capabilities),[i,o]=b.useState(0),[c,u]=b.useState([]);return b.useEffect(()=>e.connection.on("reminders/changed",()=>o(d=>d+1)),[e]),b.useEffect(()=>{if(n.state!=="open"||!r.has("agents"))return;let d=!0;return e.connection.call("reminders/list",t===void 0?{}:{agent:t}).then(f=>{d&&u(f.items)}).catch(()=>{}),()=>{d=!1}},[e,t,n.state,r,i]),c}function hw(e){const t=Ee(e.connection.status),[n,r]=b.useState(0),[i,o]=b.useState([]);return b.useEffect(()=>e.connection.on("pipelines/changed",()=>r(c=>c+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let c=!0;return e.connection.call("pipelines/list",{}).then(u=>{c&&o(u.items)}).catch(()=>{}),()=>{c=!1}},[e,t.state,n]),i}function pw(e){const t=Ee(e.connection.status),n=Ee(e.capabilities),[r,i]=b.useState(null);return b.useEffect(()=>{if(t.state!=="open"||!n.has("games"))return;let o=!0;return e.connection.call("games/list",{}).then(c=>{o&&i({schedule:{enabled:c.settings.report.enabled,times:[c.settings.report.at],days:[],catchUpMinutes:0},next:c.report.next})}).catch(()=>{}),()=>{o=!1}},[e,t.state,n]),r}function mw({report:e,now:t}){const n=vo(e.schedule,t);return s.jsxs("a",{className:"task-card pipeline-line",href:"#/p/games/report",title:"在游戏页的「日报」里设置",children:[s.jsx(ee,{name:"send"}),s.jsx("span",{className:"task-title",children:"每日日报"}),s.jsxs("span",{className:"muted small",children:[Im(e.schedule),n===void 0?"":` · 下次 ${oc(n)}`," · 发到飞书"]}),s.jsx(ee,{name:"chevron"})]})}function gw(e){const t=fi(e);return b.useMemo(()=>[br,...t.map(ac)],[t])}function P$({client:e,agentId:t}){const n=gw(e),r=n.find(v=>v.id===t)??br,{items:i,error:o}=dw(e,t),c=fw(e,t),u=hw(e),d=pw(e),f=Cn(3e4),[p,m]=b.useState(null),g=u.filter(v=>v.schedule.enabled&&v.draft!==!0);return s.jsxs("section",{className:"main scripts-page agent-schedule",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:r.name}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"定时任务"})]}),s.jsx("div",{className:"page-actions",children:s.jsxs("button",{className:"small-button primary",onClick:()=>m("new"),disabled:p!==null,children:[s.jsx(ee,{name:"plus"}),"新建定时任务"]})})]}),s.jsxs("div",{className:"schedule-body",children:[s.jsxs("p",{className:"muted small",children:["到点把一段话交给",r.name,"去做,在它的对话里做。",t===xr?"":"做完后,要紧的由助手告诉你。","要跑脚本的多步任务,用「编排」做成流水线。"]}),o!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:o})]}),p==="new"&&s.jsx(Hp,{client:e,agents:n,task:{agent:t},onDone:()=>m(null)}),t==="games"&&d!==null&&s.jsx(mw,{report:d,now:f}),i!==null&&i.length===0&&c.length===0&&p===null&&s.jsxs("div",{className:"empty-card muted",children:[r.name,"还没有定时任务。"]}),i==null?void 0:i.map(v=>p!=="new"&&(p==null?void 0:p.id)===v.id?s.jsx(Hp,{client:e,agents:n,task:v,onDone:()=>m(null)},v.id):s.jsx(yw,{client:e,task:v,now:f,onEdit:()=>m(v)},v.id)),c.length>0&&s.jsxs("section",{className:"schedule-group",children:[s.jsxs("h3",{children:[r.name,"在对话里设的提醒"]}),s.jsx("p",{className:"muted small",children:"你在对话里让它「几点提醒我…」时它自己设的。到点后它在对话里接着做,回复也会同步到飞书和 QQ。"}),c.map(v=>s.jsx(vw,{client:e,reminder:v,now:f},v.id))]}),t==="pipelines"&&s.jsxs("section",{className:"schedule-group",children:[s.jsx("h3",{children:"按时运行的流水线"}),g.length===0&&s.jsx("p",{className:"muted small",children:"没有开着定时的流水线。"}),g.map(v=>s.jsx(xw,{pipeline:v,now:f},v.id))]})]})]})}function L$({client:e,onAgent:t}){const n=gw(e),{items:r,error:i}=dw(e),o=fw(e),c=hw(e),u=pw(e),d=Cn(3e4),[f,p]=b.useState(!1),m=n.find(y=>y.id==="pipelines"),g=n.find(y=>y.id==="games"),v=b.useMemo(()=>[...u===null?[]:[{key:"daily-report",agent:g,title:"每日日报",at:vo(u.schedule,d)}],...(r??[]).map(y=>({key:y.id,agent:n.find(S=>S.id===y.agent),title:y.title,at:vo(y.schedule,d)})),...c.filter(y=>y.draft!==!0).map(y=>({key:y.id,agent:m,title:`流水线「${y.name}」`,at:vo(y.schedule,d)})),...o.map(y=>({key:y.id,agent:n.find(S=>S.id===y.agent),title:`提醒:${y.title}`,at:y.next}))].filter(y=>y.at!==void 0).sort((y,S)=>y.at-S.at).slice(0,8),[r,o,c,n,m,g,u,d]);return s.jsxs("section",{className:"main scripts-page agent-schedule",children:[s.jsxs("header",{className:"page-header",children:[s.jsx("div",{className:"breadcrumb",children:s.jsx("h1",{children:"定时任务"})}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("a",{className:"small-button",href:"#/settings/schedule",children:[s.jsx(ee,{name:"settings"}),"开机自启与唤醒"]}),s.jsxs("button",{className:"small-button primary",onClick:()=>p(!0),disabled:f,children:[s.jsx(ee,{name:"plus"}),"新建定时任务"]})]})]}),s.jsxs("div",{className:"schedule-body",children:[i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:i})]}),f&&s.jsx(Hp,{client:e,agents:n,task:{agent:xr},chooseAgent:!0,onDone:()=>p(!1)}),s.jsxs("section",{className:"schedule-group",children:[s.jsx("h3",{children:"接下来"}),v.length===0&&s.jsx("p",{className:"muted small",children:"一周内没有要按时做的事。"}),s.jsx("ol",{className:"schedule-timeline",children:v.map(y=>{var S,k,w;return s.jsxs("li",{children:[s.jsx("span",{className:"schedule-when",children:oc(y.at)}),s.jsx("span",{className:`agent-avatar small agent-${((S=y.agent)==null?void 0:S.id)??"unknown"}`,children:s.jsx(ee,{name:((k=y.agent)==null?void 0:k.icon)??"sparkles"})}),s.jsx("span",{className:"schedule-who",children:((w=y.agent)==null?void 0:w.name)??"?"}),s.jsx("span",{className:"schedule-what",children:y.title})]},`${y.key}@${y.at}`)})})]}),n.map(y=>{const S=(r??[]).filter(N=>N.agent===y.id),k=o.filter(N=>N.agent===y.id),w=y.id==="pipelines"?c.filter(N=>N.schedule.enabled&&N.draft!==!0):[],T=y.id==="games"&&(u==null?void 0:u.schedule.enabled)===!0?u:null;return S.length===0&&k.length===0&&w.length===0&&T===null?null:s.jsxs("section",{className:"schedule-group",children:[s.jsxs("h3",{className:"schedule-agent",children:[s.jsx("span",{className:`agent-avatar small agent-${y.id}`,children:s.jsx(ee,{name:y.icon})}),y.name,s.jsx("span",{className:"tab-count",children:S.length+k.length+w.length+(T===null?0:1)}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"link-button",onClick:()=>t(y.id),children:"管理"})]}),T!==null&&s.jsx(mw,{report:T,now:d}),S.map(N=>s.jsx(yw,{client:e,task:N,now:d},N.id)),k.map(N=>s.jsx(vw,{client:e,reminder:N,now:d},N.id)),w.map(N=>s.jsx(xw,{pipeline:N,now:d},N.id))]},y.id)})]})]})}function xw({pipeline:e,now:t}){const n=vo(e.schedule,t);return s.jsxs("a",{className:"task-card pipeline-line",href:`#/p/pipelines/${encodeURIComponent(e.id)}`,children:[s.jsx(ee,{name:"flow"}),s.jsx("span",{className:"task-title",children:e.name}),s.jsxs("span",{className:"muted small",children:[Im(e.schedule),n===void 0?"":` · 下次 ${oc(n)}`]}),s.jsx(ee,{name:"chevron"})]})}function vw({client:e,reminder:t,now:n}){const[r,i]=b.useState(null),o=()=>{confirm(`删除提醒「${t.title}」?`)&&(i(null),e.connection.call("reminders/remove",{id:t.id}).catch(c=>i(Pe(c))))};return s.jsxs("div",{className:"task-card reminder-card",children:[s.jsxs("div",{className:"task-card-head",children:[s.jsx(ee,{name:"calendar"}),s.jsx("span",{className:"task-title",children:t.title}),s.jsxs("span",{className:"muted small",children:[t.rule==="一次"?"":`${t.rule} · `,t.repeats?"下次 ":"",oc(t.next),t.next>n?`(${D$(t.next-n)}后)`:""]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"icon-button",onClick:o,title:"删除这个提醒","aria-label":"删除",children:s.jsx(ee,{name:"close"})})]}),s.jsx("div",{className:"task-prompt",children:t.prompt}),r!==null&&s.jsx("div",{className:"error small",children:r})]})}function D$(e){const t=Math.max(1,Math.round(e/6e4));if(t<60)return`${t} 分钟`;const n=Math.round(t/60);return n<48?`${n} 小时`:`${Math.round(n/24)} 天`}function yw({client:e,task:t,now:n,onEdit:r}){const[i,o]=b.useState(null),c=vo(t.schedule,n),u=t.lastRun,d=p=>{o(null),e.connection.call(p,{id:t.id}).catch(m=>o(Pe(m)))},f=()=>{o(null),e.connection.call("tasks/save",{task:{...t,schedule:{...t.schedule,enabled:!t.schedule.enabled}}}).catch(p=>o(Pe(p)))};return s.jsxs("div",{className:`task-card ${t.schedule.enabled?"":"paused"}`,children:[s.jsxs("div",{className:"task-card-head",children:[s.jsx("span",{className:"task-title",children:t.title}),s.jsxs("span",{className:"muted small",children:[Im(t.schedule),c===void 0?"":` · 下次 ${oc(c)}`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>d("tasks/run"),disabled:(u==null?void 0:u.state)==="running",title:"现在就交给它做一次",children:(u==null?void 0:u.state)==="running"?"在做":"立即运行"}),s.jsx("button",{className:"small-button",onClick:f,children:t.schedule.enabled?"暂停":"开启"}),r!==void 0&&s.jsx("button",{className:"icon-button",onClick:r,title:"修改","aria-label":"修改",children:s.jsx(ee,{name:"pencil"})}),r!==void 0&&s.jsx("button",{className:"icon-button",onClick:()=>{confirm(`删除定时任务「${t.title}」?`)&&d("tasks/remove")},title:"删除","aria-label":"删除",children:s.jsx(ee,{name:"close"})})]}),s.jsx("div",{className:"task-prompt",children:t.prompt}),u!==void 0&&s.jsxs("div",{className:`task-run tone-${u.state==="done"?"ok":u.state==="failed"?"failed":"running"}`,children:[u.state==="running"?s.jsx("span",{className:"tool-spinner","aria-hidden":!0}):s.jsx(ee,{name:u.state==="done"?"check":"alert"}),s.jsxs("span",{children:[u.state==="running"?"正在做":`${$t(u.endedAt??u.startedAt,n)}${u.state==="done"?"做完":"没做成"}`,u.outcome===void 0?"":`:${u.outcome.split(`
|
|
127
|
-
`)[0]}`]})]}),i!==null&&s.jsx("div",{className:"error small",children:i})]})}function Hp({client:e,agents:t,task:n,chooseAgent:r=!1,onDone:i}){var $,D;const[o,c]=b.useState(n.agent),[u,d]=b.useState(n.title??""),[f,p]=b.useState(n.prompt??""),[m,g]=b.useState(((($=n.schedule)==null?void 0:$.times)??["09:00"]).join(", ")),[v,y]=b.useState(((D=n.schedule)==null?void 0:D.days)??[]),[S,k]=b.useState(!1),[w,T]=b.useState(null),N=async()=>{var O,F;k(!0),T(null);try{const U=m.split(/[,,、\s]+/).filter(M=>M!=="").map(M=>/^\d:\d\d$/.test(M)?`0${M}`:M);await e.connection.call("tasks/save",{task:{...n.id===void 0?{}:{id:n.id},agent:o,title:u,prompt:f,schedule:{enabled:((O=n.schedule)==null?void 0:O.enabled)??!0,times:U,days:[...v],catchUpMinutes:((F=n.schedule)==null?void 0:F.catchUpMinutes)??10}}}),i()}catch(U){T(Pe(U))}finally{k(!1)}};return s.jsxs("div",{className:"task-card task-form",children:[r&&s.jsxs("label",{className:"field-label",children:["交给谁",s.jsx("select",{className:"text-input",value:o,onChange:O=>c(O.target.value),children:t.map(O=>s.jsx("option",{value:O.id,children:O.name},O.id))})]}),s.jsxs("label",{className:"field-label",children:["名字",s.jsx("input",{className:"text-input plain",value:u,maxLength:60,onChange:O=>d(O.target.value),placeholder:"例如:看今天结束的活动"})]}),s.jsxs("label",{className:"field-label",children:["交给它的话",s.jsx("textarea",{className:"text-input plain",rows:3,value:f,maxLength:4e3,onChange:O=>p(O.target.value),placeholder:"写完整:要做什么、要交回什么"})]}),s.jsxs("div",{className:"task-form-row",children:[s.jsxs("label",{className:"field-label",children:["时间",s.jsx("input",{className:"text-input plain-mono",value:m,onChange:O=>g(O.target.value),placeholder:"09:00, 21:30"})]}),s.jsxs("div",{className:"field-label",children:["星期",s.jsxs("div",{className:"day-chips",children:[uw.map(O=>s.jsx("button",{type:"button",className:`day-chip ${v.includes(O)?"on":""}`,"aria-pressed":v.includes(O),onClick:()=>y(v.includes(O)?v.filter(F=>F!==O):[...v,O]),children:cw[O]},O)),s.jsx("span",{className:"muted small",children:v.length===0?"不选就是每天":""})]})]})]}),w!==null&&s.jsx("div",{className:"error small",children:w}),s.jsxs("div",{className:"task-form-actions",children:[s.jsx("button",{className:"small-button",onClick:i,disabled:S,children:"取消"}),s.jsx("button",{className:"small-button primary",onClick:()=>void N(),disabled:S||u.trim()===""||f.trim()==="",children:"保存"})]})]})}/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */function E0(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function F$(e){if(Array.isArray(e))return e}function B$(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,c,u=[],d=!0,f=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(d=(r=o.call(n)).done)&&(u.push(r.value),u.length!==t);d=!0);}catch(p){f=!0,i=p}finally{try{if(!d&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(f)throw i}}return u}}function U$(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
128
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */function H$(e,t){return F$(e)||B$(e,t)||Z$(e,t)||U$()}function Z$(e,t){if(e){if(typeof e=="string")return E0(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E0(e,t):void 0}}const bw=Object.entries,C0=Object.setPrototypeOf,V$=Object.isFrozen,kw=Object.getPrototypeOf,ww=Object.getOwnPropertyDescriptor;let Rn=Object.freeze,Dn=Object.seal,uo=Object.create,Nw=typeof Reflect<"u"&&Reflect,Zp=Nw.apply,Vp=Nw.construct;Rn||(Rn=function(t){return t});Dn||(Dn=function(t){return t});Zp||(Zp=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return t.apply(n,i)});Vp||(Vp=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new t(...r)});const ni=Gt(Array.prototype.forEach),W$=Gt(Array.prototype.lastIndexOf),I0=Gt(Array.prototype.pop),gl=Gt(Array.prototype.push),q$=Gt(Array.prototype.slice),G$=Gt(Array.prototype.splice),yo=Array.isArray,Th=jw(Set),Mh=Gt(Set.prototype.add),xl=Gt(Set.prototype.has),pa=Gt(String.prototype.toLowerCase),$h=Gt(String.prototype.toString),A0=Gt(String.prototype.match),vl=Gt(String.prototype.replace),T0=Gt(String.prototype.indexOf),K$=Gt(String.prototype.trim),Y$=Gt(Number.prototype.toString),X$=Gt(Boolean.prototype.toString),M0=typeof BigInt>"u"?null:Gt(BigInt.prototype.toString),$0=typeof Symbol>"u"?null:Gt(Symbol.prototype.toString),ys=Gt(Object.prototype.hasOwnProperty),yl=Gt(Object.prototype.toString),Ln=Gt(RegExp.prototype.test),si=jw(TypeError);function Gt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Zp(e,t,r)}}function jw(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Vp(e,n)}}function wt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pa;if(C0&&C0(e,null),!yo(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const o=n(i);o!==i&&(V$(t)||(t[r]=o),i=o)}e[i]=!0}return e}function Q$(e){for(let t=0;t<e.length;t++)ys(e,t)||(e[t]=null);return e}function Cs(e){const t=uo(null);for(const r of bw(e)){var n=H$(r,2);const i=n[0],o=n[1];ys(e,i)&&(yo(o)?t[i]=Q$(o):o&&typeof o=="object"&&o.constructor===Object?t[i]=Cs(o):t[i]=o)}return t}function J$(e){switch(typeof e){case"string":return e;case"number":return Y$(e);case"boolean":return X$(e);case"bigint":return M0?M0(e):"0";case"symbol":return $0?$0(e):"Symbol()";case"undefined":return yl(e);case"function":case"object":{if(e===null)return yl(e);const t=e,n=qs(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:yl(r)}return yl(e)}default:return yl(e)}}function qs(e,t){for(;e!==null;){const r=ww(e,t);if(r){if(r.get)return Gt(r.get);if(typeof r.value=="function")return Gt(r.value)}e=kw(e)}function n(){return null}return n}function eR(e,t){for(;e!==null;){const n=ww(e,t);if(n)return n.get?Gt(n.get):null;e=kw(e)}return null}function tR(e){try{return Ln(e,""),!0}catch{return!1}}const R0=Rn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Rh=Rn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Oh=Rn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),nR=Rn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),zh=Rn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),sR=Rn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),O0=Rn(["#text"]),z0=Rn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ph=Rn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),P0=Rn(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),gu=Rn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),rR=Dn(/{{[\w\W]*|^[\w\W]*}}/g),iR=Dn(/<%[\w\W]*|^[\w\W]*%>/g),aR=Dn(/\${[\w\W]*/g),oR=Dn(/^data-[\-\w.\u00B7-\uFFFF]+$/),lR=Dn(/^aria-[\-\w]+$/),L0=Dn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),cR=Dn(/^(?:\w+script|data):/i),uR=Dn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),dR=Dn(/^html$/i),fR=Dn(/^[a-z][.\w]*(-[.\w]+)+$/i),Lh=Dn(/<[/\w!]/g),D0=Dn(/<[/\w]/g),hR=Dn(/<\/no(script|embed|frames)/i),F0=Dn(/\/>/i),xn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},pR=Rn(wt({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),mR=function(){return typeof window>"u"?null:window},gR=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));const o="dompurify"+(r?"#"+r:"");try{return t.createPolicy(o,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},B0=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},$i=function(t,n,r,i){return ys(t,n)&&yo(t[n])?wt(i.base?Cs(i.base):{},t[n],i.transform):r},Dh=function(t,n,r){const i=ys(t,n)?t[n]:void 0;return i&&typeof i=="object"?Cs(i):r()};function Sw(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mR();const t=we=>Sw(we);if(t.version="3.4.17",t.removed=[],!e||!e.document||e.document.nodeType!==xn.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,i=r.currentScript;e.DocumentFragment;const o=e.HTMLTemplateElement,c=e.Node,u=e.Element,d=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const f=e.DOMParser,p=e.trustedTypes,m=u.prototype,g=qs(m,"cloneNode"),v=qs(m,"remove"),y=qs(m,"removeAttributeNode"),S=qs(m,"nextSibling"),k=qs(m,"childNodes"),w=qs(m,"parentNode"),T=qs(m,"shadowRoot"),N=qs(m,"attributes"),$=c&&c.prototype?qs(c.prototype,"nodeType"):null,D=c&&c.prototype?qs(c.prototype,"nodeName"):null,O=c&&c.prototype?qs(c.prototype,"ownerDocument"):null,F=function(q){return $?$(q):q.nodeType},U=function(q){return D?D(q):q.nodeName},M=eR(m,"namespaceURI"),P=function(q){return M?M(q):q.namespaceURI};if(typeof o=="function"){const we=n.createElement("template");we.content&&we.content.ownerDocument&&(n=we.content.ownerDocument)}let R,Z="",E,C=!1,I=0;const L=function(){if(I>0)throw si('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},W=function(q){L(),I++;try{return R.createHTML(q)}finally{I--}},H=function(q){L(),I++;try{return R.createScriptURL(q)}finally{I--}},G=function(){return C||(E=gR(p,i),C=!0),E},K=n,V=K.implementation,Y=K.createNodeIterator,fe=K.createDocumentFragment,xe=K.getElementsByTagName,me=r.importNode;let ie=B0();t.isSupported=typeof bw=="function"&&typeof w=="function"&&V&&V.createHTMLDocument!==void 0;const ke=rR,ae=iR,Ne=aR,Fe=oR,ce=lR,je=cR,re=uR,he=fR;let ze=L0,Te=null;const Ge=wt({},[...R0,...Rh,...Oh,...zh,...O0]);let Ie=null;const tt=wt({},[...z0,...Ph,...P0,...gu]);let et=Object.seal(uo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),jt=null,On=null;const sn=Object.seal(uo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ln=!0,cn=!0,rn=!1,an=!0,Ft=!1,Bn=!0,wn=!1,ws=!1,_r=null,Ks=null,Ys=!1,$s=!1,Rs=!1,Os=!1,zs=!0,Xs=!1;const Qs="user-content-";let rs=!0,Yn=!1,Nn=null,Q={},pe=null;const Oe=wt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let st=null;const It=wt({},["audio","video","img","source","image","track"]);let Tt=null;const Be=wt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),De="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",bt="http://www.w3.org/1999/xhtml";let yt=bt,Un=!1,is=null;const Js=wt({},[De,Xe,bt],$h),hi=Rn(["mi","mo","mn","ms","mtext"]);let er=wt({},hi);const pi=Rn(["annotation-xml"]);let Hn=wt({},pi);const Br=wt({},["title","style","font","a","script"]);let as=null;const Er=["application/xhtml+xml","text/html"],mi="text/html";let Rt=null,Ns=null;const Xn=n.createElement("form"),Ur=function(q){return q instanceof RegExp||q instanceof Function},tr=function(){let q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ns&&Ns===q)return;(!q||typeof q!="object")&&(q={}),q=Cs(q),as=Er.indexOf(q.PARSER_MEDIA_TYPE)===-1?mi:q.PARSER_MEDIA_TYPE,Rt=as==="application/xhtml+xml"?$h:pa,Te=$i(q,"ALLOWED_TAGS",Ge,{transform:Rt}),Ie=$i(q,"ALLOWED_ATTR",tt,{transform:Rt}),is=$i(q,"ALLOWED_NAMESPACES",Js,{transform:$h}),Tt=$i(q,"ADD_URI_SAFE_ATTR",Be,{transform:Rt,base:Be}),st=$i(q,"ADD_DATA_URI_TAGS",It,{transform:Rt,base:It}),pe=$i(q,"FORBID_CONTENTS",Oe,{transform:Rt}),jt=$i(q,"FORBID_TAGS",Cs({}),{transform:Rt}),On=$i(q,"FORBID_ATTR",Cs({}),{transform:Rt}),Q=ys(q,"USE_PROFILES")?q.USE_PROFILES&&typeof q.USE_PROFILES=="object"?Cs(q.USE_PROFILES):q.USE_PROFILES:!1,ln=q.ALLOW_ARIA_ATTR!==!1,cn=q.ALLOW_DATA_ATTR!==!1,rn=q.ALLOW_UNKNOWN_PROTOCOLS||!1,an=q.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ft=q.SAFE_FOR_TEMPLATES||!1,Bn=q.SAFE_FOR_XML!==!1,wn=q.WHOLE_DOCUMENT||!1,$s=q.RETURN_DOM||!1,Rs=q.RETURN_DOM_FRAGMENT||!1,Os=q.RETURN_TRUSTED_TYPE||!1,Ys=q.FORCE_BODY||!1,zs=q.SANITIZE_DOM!==!1,Xs=q.SANITIZE_NAMED_PROPS||!1,rs=q.KEEP_CONTENT!==!1,Yn=q.IN_PLACE||!1,ze=tR(q.ALLOWED_URI_REGEXP)?q.ALLOWED_URI_REGEXP:L0,yt=typeof q.NAMESPACE=="string"?q.NAMESPACE:bt,er=Dh(q,"MATHML_TEXT_INTEGRATION_POINTS",()=>wt({},hi)),Hn=Dh(q,"HTML_INTEGRATION_POINTS",()=>wt({},pi));const te=Dh(q,"CUSTOM_ELEMENT_HANDLING",()=>uo(null));if(et=uo(null),ys(te,"tagNameCheck")&&Ur(te.tagNameCheck)&&(et.tagNameCheck=te.tagNameCheck),ys(te,"attributeNameCheck")&&Ur(te.attributeNameCheck)&&(et.attributeNameCheck=te.attributeNameCheck),ys(te,"allowCustomizedBuiltInElements")&&typeof te.allowCustomizedBuiltInElements=="boolean"&&(et.allowCustomizedBuiltInElements=te.allowCustomizedBuiltInElements),Dn(et),Ft&&(cn=!1),Rs&&($s=!0),Q&&(Te=wt({},O0),Ie=uo(null),Q.html===!0&&(wt(Te,R0),wt(Ie,z0)),Q.svg===!0&&(wt(Te,Rh),wt(Ie,Ph),wt(Ie,gu)),Q.svgFilters===!0&&(wt(Te,Oh),wt(Ie,Ph),wt(Ie,gu)),Q.mathMl===!0&&(wt(Te,zh),wt(Ie,P0),wt(Ie,gu))),sn.tagCheck=null,sn.attributeCheck=null,ys(q,"ADD_TAGS")&&(typeof q.ADD_TAGS=="function"?sn.tagCheck=q.ADD_TAGS:yo(q.ADD_TAGS)&&(Te===Ge&&(Te=Cs(Te)),wt(Te,q.ADD_TAGS,Rt))),ys(q,"ADD_ATTR")&&(typeof q.ADD_ATTR=="function"?sn.attributeCheck=q.ADD_ATTR:yo(q.ADD_ATTR)&&(Ie===tt&&(Ie=Cs(Ie)),wt(Ie,q.ADD_ATTR,Rt))),ys(q,"ADD_FORBID_CONTENTS")&&yo(q.ADD_FORBID_CONTENTS)&&(pe===Oe&&(pe=Cs(pe)),wt(pe,q.ADD_FORBID_CONTENTS,Rt)),rs&&(Te["#text"]=!0),wn&&wt(Te,["html","head","body"]),Te.table&&(wt(Te,["tbody"]),delete jt.tbody),q.TRUSTED_TYPES_POLICY){if(typeof q.TRUSTED_TYPES_POLICY.createHTML!="function")throw si('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof q.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw si('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const ve=R;R=q.TRUSTED_TYPES_POLICY;try{Z=W("")}catch(ye){throw R=ve,ye}}else q.TRUSTED_TYPES_POLICY===null?(R=void 0,Z=""):(R===void 0&&(R=G()),R&&typeof Z=="string"&&(Z=W("")));Rn&&Rn(q),Ns=q},Ot=wt({},[...Rh,...Oh,...nR]),gi=wt({},[...zh,...sR]),Hr=function(q,te,ve){return te.namespaceURI===bt?q==="svg":te.namespaceURI===De?q==="svg"&&(ve==="annotation-xml"||er[ve]):!!Ot[q]},nr=function(q,te,ve){return te.namespaceURI===bt?q==="math":te.namespaceURI===Xe?q==="math"&&Hn[ve]:!!gi[q]},Cr=function(q,te,ve){return te.namespaceURI===Xe&&!Hn[ve]||te.namespaceURI===De&&!er[ve]?!1:!gi[q]&&(Br[q]||!Ot[q])},Ae=function(q){const te=P(q),ve=pa(U(q)),ye=w(q);let qe,nt;return ye&&F(ye)===xn.element?(qe={namespaceURI:P(ye)},nt=pa(U(ye))):(qe={namespaceURI:yt},nt="template"),is[te]?te===Xe?Hr(ve,qe,nt):te===De?nr(ve,qe,nt):te===bt?Cr(ve,qe,nt):!!(as==="application/xhtml+xml"&&is[te]):!1},Ze=function(q){gl(t.removed,{element:q});try{w(q).removeChild(q)}catch{if(v(q),!w(q))throw si("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ct=function(q,te,ve){try{y(q,te)}catch{try{q.removeAttribute(ve)}catch{}}},ft=function(q){Ps(q);const te=k(q);te&&ni(q$(te),ye=>{try{v(ye)}catch{}});const ve=F(q)===xn.element?N(q):null;if(ve)for(let ye=ve.length-1;ye>=0;--ye){const qe=ve[ye],nt=qe&&qe.name;typeof nt=="string"&&ct(q,qe,nt)}},At=function(q,te,ve){if(!ve)try{ve=te.getAttributeNode(q)}catch{ve=null}gl(t.removed,{attribute:ve||null,from:te});try{ve?y(te,ve):te.removeAttribute(q)}catch{try{te.removeAttribute(q)}catch{}}if(q==="is")if($s||Rs)try{Ze(te)}catch{}else try{te.setAttribute(q,"")}catch{}},zt=function(q){const te=N(q);if(te)for(let ve=te.length-1;ve>=0;--ve){const ye=te[ve],qe=ye&&ye.name;typeof qe!="string"||Ie[Rt(qe)]||ct(q,ye,qe)}},Zn=function(q,te){let ve=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const ye=[q];for(;ye.length>0;){const qe=ye.pop();if(te(qe)===!1)continue;if(ve&&F(qe)===xn.element){const pt=T(qe);cs(pt)&&ye.push(pt)}const nt=k(qe);if(nt)for(let pt=nt.length-1;pt>=0;--pt)ye.push(nt[pt])}},Ps=function(q){Zn(q,te=>{F(te)===xn.element&&zt(te)})},un=function(q){const te=[];return Zn(q,ve=>{te.push(ve)},!0),te},jn=function(q,te){const ve=Th();ni(un(q),ye=>{F(ye)===xn.element&&Mh(ve,ye)}),ni(te,ye=>{F(ye)===xn.element&&!xl(ve,ye)&&zt(ye)})},Ls=function(q,te){let ve=!1;return ni(t.removed,ye=>{ye.element&&(ve=ve||ye.element===q,Ps(ye.element))}),jn(q,te),ve},Ds=8,os=function(q,te){const ve=Nn;let ye=null;const qe=()=>(ye||(ye=Th(),ni(te,nt=>{Mh(ye,nt)})),ye);for(let nt=0;;nt++){const pt=un(q),dn=[q];let us=!1;if(ni(pt,mn=>{F(mn)===xn.documentFragment?gl(dn,mn):!us&&!xl(ve,mn)&&(us=xl(qe(),mn))}),!us)return;if(nt>=Ds)throw si("the tree kept changing during in-place sanitization; refusing to return it");ni(dn,(mn,In)=>{Qi(mn,In>0,q,qe())})}},Qi=function(q,te,ve,ye){const qe=ls(q);let nt;for(;nt=qe.nextNode();)!xl(ye,nt)||xl(Nn,nt)||(te&&ht(ie.uponSanitizeShadowNode,nt,null),Ue(nt,ve),Wr(nt,ve),cs(nt.content)&&ea(nt.content))},xi=function(q){Nn&&Mh(Nn,q)},Ir=function(q,te){return Bn?q==="patchsrc"?!0:q==="for"&&te!=="label"&&te!=="output":!1},vi=function(q){Bn&&Zn(q,te=>{const ve=F(te);if(ve===xn.processingInstruction||ve===xn.comment&&Ln(D0,te.data)){try{v(te)}catch{}return!1}if(ve===xn.element){const ye=te,qe=Rt(U(te));try{ye.hasAttribute&&ye.hasAttribute("patchsrc")&&ye.removeAttribute("patchsrc"),ye.hasAttribute&&ye.hasAttribute("for")&&Ir("for",qe)&&ye.removeAttribute("for")}catch{}}return!0})},Qn=function(q){let te=null,ve=null;if(Ys)q="<remove></remove>"+q;else{const nt=A0(q,/^[\r\n\t ]+/);ve=nt&&nt[0]}as==="application/xhtml+xml"&&yt===bt&&(q='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+q+"</body></html>");const ye=R?W(q):q;if(yt===bt)try{te=new f().parseFromString(ye,as)}catch{}if(!te||!te.documentElement){te=V.createDocument(yt,"template",null);try{te.documentElement.innerHTML=Un?Z:ye}catch{}}const qe=te.body||te.documentElement;return q&&ve&&qe.insertBefore(n.createTextNode(ve),qe.childNodes[0]||null),yt===bt?xe.call(te,wn?"html":"body")[0]:wn?te.documentElement:qe},ls=function(q){const te=O?O(q):q.ownerDocument;return Y.call(te||q,q,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},Sn=function(q){return q=vl(q,ke," "),q=vl(q,ae," "),q=vl(q,Ne," "),q},Fs=function(q){var te;vt(q);const ve=(te=q.querySelectorAll)===null||te===void 0?void 0:te.call(q,"template");ve&&ni(ve,ye=>{cs(ye.content)&&Fs(ye.content)})},vt=function(q){q.normalize();const te=O?O(q):q.ownerDocument,ve=Y.call(te||q,q,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let ye=ve.nextNode();for(;ye;)ye.data=Sn(ye.data),ye=ve.nextNode()},at=function(q){const te=D?D(q):null;return typeof te!="string"||Rt(te)!=="form"?!1:typeof q.nodeName!="string"||typeof q.textContent!="string"||typeof q.removeChild!="function"||q.attributes!==N(q)||typeof q.removeAttribute!="function"||typeof q.removeAttributeNode!="function"||typeof q.getAttributeNode!="function"||typeof q.setAttribute!="function"||typeof q.namespaceURI!="string"||typeof q.insertBefore!="function"||typeof q.hasChildNodes!="function"||q.nodeType!==$(q)||q.childNodes!==k(q)},cs=function(q){if(!$||typeof q!="object"||q===null)return!1;try{return $(q)===xn.documentFragment}catch{return!1}},Pt=function(q){if(!$||typeof q!="object"||q===null)return!1;try{return typeof $(q)=="number"}catch{return!1}};function ht(we,q,te){we.length!==0&&ni(we,ve=>{ve.call(t,q,te,Ns)})}const Zr=function(q,te){return!!(Bn&&q.hasChildNodes()&&!Pt(q.firstElementChild)&&Ln(Lh,q.textContent)&&Ln(Lh,q.innerHTML)||Bn&&pR[te]&&F(q)===xn.element&&P(q)===bt&&(Pt(q.firstElementChild)||typeof q.textContent=="string"&&Ln(Lh,q.textContent))||q.nodeType===xn.processingInstruction||Bn&&q.nodeType===xn.comment&&Ln(D0,q.data))},Jn=function(q,te){if(q instanceof RegExp)return Ln(q,te);if(q instanceof Function){for(var ve=arguments.length,ye=new Array(ve>2?ve-2:0),qe=2;qe<ve;qe++)ye[qe-2]=arguments[qe];return!!q(te,...ye)}return!1},Vr=function(q,te,ve){if(!jt[te]&&Bt(te)&&Jn(et.tagNameCheck,te))return!1;if(rs&&!pe[te]&&!pe[pa(te)]){const ye=w(q),qe=k(q);if(qe&&ye){const nt=qe.length;for(let pt=nt-1;pt>=0;--pt){const dn=q===ve?g(qe[pt],!0):qe[pt];ye.insertBefore(dn,S(q))}}}return Ze(q),!0},sr=function(q,te,ve,ye){return q.length===0?te:te===ve||te===ye?Cs(te):te},Me=function(q,te){return q===te||w(q)!==null?!1:(Yn&&Ps(q),!0)},Ue=function(q,te){if(xi(q),ht(ie.beforeSanitizeElements,q,null),Me(q,te))return!0;if(at(q))return Ze(q),!0;const ve=Rt(U(q));if(Te=sr(ie.uponSanitizeElement,Te,Ge,_r),ht(ie.uponSanitizeElement,q,{tagName:ve,allowedTags:Te}),Me(q,te))return!0;if(Zr(q,ve))return Ze(q),!0;if(jt[ve]||!(sn.tagCheck instanceof Function&&sn.tagCheck(ve))&&!Te[ve]){const ye=Vr(q,ve,te);return ye===!1&&(ht(ie.afterSanitizeElements,q,null),Me(q,te))?!0:ye}if(F(q)===xn.element&&!Ae(q)||(ve==="noscript"||ve==="noembed"||ve==="noframes")&&Ln(hR,q.innerHTML))return Ze(q),!0;if(Ft&&q.nodeType===xn.text){const ye=Sn(q.textContent);q.textContent!==ye&&(gl(t.removed,{element:q.cloneNode()}),q.textContent=ye)}return ht(ie.afterSanitizeElements,q,null),Me(q,te)},ot=function(q,te,ve){if(On[te]||Ir(te,q)||zs&&(te==="id"||te==="name")&&(ve in n||ve in Xn))return!1;const ye=Ie[te]||sn.attributeCheck instanceof Function&&sn.attributeCheck(te,q);return cn&&Ln(Fe,te)||ln&&Ln(ce,te)?!0:ye?Tt[te]||Ln(ze,vl(ve,re,""))||(te==="src"||te==="xlink:href"||te==="href")&&q!=="script"&&T0(ve,"data:")===0&&st[q]||rn&&!Ln(je,vl(ve,re,""))?!0:!ve:Bt(q)&&Jn(et.tagNameCheck,q)&&Jn(et.attributeNameCheck,te,q)||te==="is"&&et.allowCustomizedBuiltInElements&&Jn(et.tagNameCheck,ve)},gt=wt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Bt=function(q){return!gt[pa(q)]&&Ln(he,q)},pn=function(q,te,ve,ye){if(R&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!ve)switch(p.getAttributeType(q,te)){case"TrustedHTML":return W(ye);case"TrustedScriptURL":return H(ye)}return ye},Fo=function(q,te,ve,ye){try{return ve?q.setAttributeNS(ve,te,ye):q.setAttribute(te,ye),at(q)?(Ze(q),!1):!0}catch{return At(te,q),!1}},Ji=function(q,te){return Bn&&Ln(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,te)?!0:pa(q)==="attributename"&&A0(te,"href")!==null},Wr=function(q,te){if(ht(ie.beforeSanitizeAttributes,q,null),Me(q,te))return;const ve=q.attributes;if(!ve||at(q))return;Ie=sr(ie.uponSanitizeAttribute,Ie,tt,Ks);const ye={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ie,forceKeepAttr:void 0};let qe=ve.length;const nt=Rt(q.nodeName);for(;qe--;){const pt=ve[qe],dn=pt.name,us=pt.namespaceURI,mn=pt.value,In=Rt(dn),qr=mn;let Yt=dn==="value"?qr:K$(qr),La=!1;if(ye.attrName=In,ye.attrValue=Yt,ye.keepAttr=!0,ye.forceKeepAttr=void 0,ht(ie.uponSanitizeAttribute,q,ye),Yt=ye.attrValue,Xs&&(In==="id"||In==="name")&&T0(Yt,Qs)!==0&&(At(dn,q,pt),Yt=Qs+Yt,La=!0),Ji(dn,Yt)){At(dn,q,pt);continue}if(!ye.forceKeepAttr){if(!ye.keepAttr){At(dn,q,pt);continue}if(!an&&Ln(F0,Yt)){At(dn,q,pt);continue}if(Ft&&(Yt=Sn(Yt)),!ot(nt,In,Yt)){At(dn,q,pt);continue}Yt=pn(nt,In,us,Yt),Yt!==qr&&Fo(q,dn,us,Yt)&&La&&I0(t.removed)}}ht(ie.afterSanitizeAttributes,q,null),Me(q,te)},ea=function(q){let te=null;const ve=ls(q);for(ht(ie.beforeSanitizeShadowDOM,q,null);te=ve.nextNode();)if(ht(ie.uponSanitizeShadowNode,te,null),Ue(te,q),Wr(te,q),cs(te.content)&&ea(te.content),F(te)===xn.element){const ye=T(te);cs(ye)&&(Pa(ye),ea(ye))}Ft&&vt(q),ht(ie.afterSanitizeShadowDOM,q,null)},Pa=function(q){const te=[{node:q,shadow:null}];for(;te.length>0;){const ve=te.pop();if(ve.shadow){ea(ve.shadow);continue}const ye=ve.node,qe=F(ye)===xn.element,nt=k(ye);if(nt)for(let pt=nt.length-1;pt>=0;--pt)te.push({node:nt[pt],shadow:null});if(qe){const pt=D?D(ye):null;if(typeof pt=="string"&&Rt(pt)==="template"){const dn=ye.content;cs(dn)&&te.push({node:dn,shadow:null})}}if(qe){const pt=T(ye);cs(pt)&&te.push({node:null,shadow:pt},{node:pt,shadow:null})}}};return t.sanitize=function(we){let q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},te=null,ve=null,ye=null,qe=null;if(Un=!we,Un&&(we="<!-->"),typeof we!="string"&&!Pt(we)&&(we=J$(we),typeof we!="string"))throw si("dirty is not a string, aborting");if(!t.isSupported)return we;ws?(Te=_r,Ie=Ks):tr(q),(ie.uponSanitizeElement.length>0||ie.uponSanitizeAttribute.length>0)&&(Te=Cs(Te)),ie.uponSanitizeAttribute.length>0&&(Ie=Cs(Ie)),t.removed=[];const nt=Yn&&typeof we!="string"&&Pt(we);let pt=[];const dn=Nn;if(nt){vi(we);const In=U(we);if(typeof In=="string"){const qr=Rt(In);if(!Te[qr]||jt[qr])throw ft(we),si("root node is forbidden and cannot be sanitized in-place")}if(at(we))throw ft(we),si("root node is clobbered and cannot be sanitized in-place");pt=un(we),Nn=Th()}else if(Pt(we))te=Qn("<!---->"),ve=te.ownerDocument.importNode(we,!0),ve.nodeType===xn.element&&ve.nodeName==="BODY"||ve.nodeName==="HTML"?te=ve:te.appendChild(ve),Pa(te);else{if(!$s&&!Ft&&!wn&&we.indexOf("<")===-1)return R&&Os?W(we):we;if(te=Qn(we),!te)return $s?null:Os?Z:""}te&&Ys&&Ze(te.firstChild);const us=nt?we:te;try{nt&&Pa(we);const In=ls(us);for(;ye=In.nextNode();)Ue(ye,us),Wr(ye,us),cs(ye.content)&&ea(ye.content);nt&&os(we,pt)}catch(In){throw nt&&(ft(we),Ls(we,pt)),In}finally{Nn=dn}if(nt){if(Ls(we,pt))throw si("a node selected for removal could not be safely returned; refusing to sanitize in place");return Ft&&Fs(we),we}if($s){if(Ft&&Fs(te),Rs)for(qe=fe.call(te.ownerDocument);te.firstChild;)qe.appendChild(te.firstChild);else qe=te;return(Ie.shadowroot||Ie.shadowrootmode)&&(qe=me.call(r,qe,!0)),qe}let mn=wn?te.outerHTML:te.innerHTML;return wn&&Te["!doctype"]&&te.ownerDocument&&te.ownerDocument.doctype&&te.ownerDocument.doctype.name&&Ln(dR,te.ownerDocument.doctype.name)&&(mn="<!DOCTYPE "+te.ownerDocument.doctype.name+`>
|
|
129
|
-
`+mn),Ft&&(mn=Sn(mn)),R&&Os?W(mn):mn},t.setConfig=function(){let we=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};tr(we),ws=!0,_r=Te,Ks=Ie},t.clearConfig=function(){Ns=null,ws=!1,_r=null,Ks=null,R=E,Z=""},t.isValidAttribute=function(we,q,te){Ns||tr({});const ve=Rt(we),ye=Rt(q);return typeof te=="string"&&(Ji(q,te)||!an&&Ln(F0,te))?!1:ot(ve,ye,te)},t.addHook=function(we,q){typeof q=="function"&&ys(ie,we)&&gl(ie[we],q)},t.removeHook=function(we,q){if(ys(ie,we)){if(q!==void 0){const te=W$(ie[we],q);return te===-1?void 0:G$(ie[we],te,1)[0]}return I0(ie[we])}},t.removeHooks=function(we){ys(ie,we)&&(ie[we]=[])},t.removeAllHooks=function(){ie=B0()},t}var Am=Sw();function Tm(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var za=Tm();function _w(e){za=e}var Ol={exec:()=>null};function _t(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,o)=>{let c=typeof o=="string"?o:o.source;return c=c.replace(ss.caret,"$1"),n=n.replace(i,c),r},getRegex:()=>new RegExp(n,t)};return r}var xR=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ss={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},vR=/^(?:[ \t]*(?:\n|$))+/,yR=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,bR=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,lc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,kR=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Mm=/(?:[*+-]|\d{1,9}[.)])/,Ew=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Cw=_t(Ew).replace(/bull/g,Mm).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),wR=_t(Ew).replace(/bull/g,Mm).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),$m=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,NR=/^[^\n]+/,Rm=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,jR=_t(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Rm).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),SR=_t(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Mm).getRegex(),xd="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Om=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_R=_t("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Om).replace("tag",xd).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Iw=_t($m).replace("hr",lc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",xd).getRegex(),ER=_t(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Iw).getRegex(),zm={blockquote:ER,code:yR,def:jR,fences:bR,heading:kR,hr:lc,html:_R,lheading:Cw,list:SR,newline:vR,paragraph:Iw,table:Ol,text:NR},U0=_t("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",lc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",xd).getRegex(),CR={...zm,lheading:wR,table:U0,paragraph:_t($m).replace("hr",lc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",U0).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",xd).getRegex()},IR={...zm,html:_t(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Om).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ol,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:_t($m).replace("hr",lc).replace("heading",` *#{1,6} *[^
|
|
130
|
-
]`).replace("lheading",Cw).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},AR=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,TR=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Aw=/^( {2,}|\\)\n(?!\s*$)/,MR=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,vd=/[\p{P}\p{S}]/u,Pm=/[\s\p{P}\p{S}]/u,Tw=/[^\s\p{P}\p{S}]/u,$R=_t(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Pm).getRegex(),Mw=/(?!~)[\p{P}\p{S}]/u,RR=/(?!~)[\s\p{P}\p{S}]/u,OR=/(?:[^\s\p{P}\p{S}]|~)/u,zR=_t(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",xR?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),$w=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,PR=_t($w,"u").replace(/punct/g,vd).getRegex(),LR=_t($w,"u").replace(/punct/g,Mw).getRegex(),Rw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",DR=_t(Rw,"gu").replace(/notPunctSpace/g,Tw).replace(/punctSpace/g,Pm).replace(/punct/g,vd).getRegex(),FR=_t(Rw,"gu").replace(/notPunctSpace/g,OR).replace(/punctSpace/g,RR).replace(/punct/g,Mw).getRegex(),BR=_t("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Tw).replace(/punctSpace/g,Pm).replace(/punct/g,vd).getRegex(),UR=_t(/\\(punct)/,"gu").replace(/punct/g,vd).getRegex(),HR=_t(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ZR=_t(Om).replace("(?:-->|$)","-->").getRegex(),VR=_t("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ZR).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qu=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,WR=_t(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qu).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ow=_t(/^!?\[(label)\]\[(ref)\]/).replace("label",qu).replace("ref",Rm).getRegex(),zw=_t(/^!?\[(ref)\](?:\[\])?/).replace("ref",Rm).getRegex(),qR=_t("reflink|nolink(?!\\()","g").replace("reflink",Ow).replace("nolink",zw).getRegex(),H0=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Lm={_backpedal:Ol,anyPunctuation:UR,autolink:HR,blockSkip:zR,br:Aw,code:TR,del:Ol,emStrongLDelim:PR,emStrongRDelimAst:DR,emStrongRDelimUnd:BR,escape:AR,link:WR,nolink:zw,punctuation:$R,reflink:Ow,reflinkSearch:qR,tag:VR,text:MR,url:Ol},GR={...Lm,link:_t(/^!?\[(label)\]\((.*?)\)/).replace("label",qu).getRegex(),reflink:_t(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qu).getRegex()},Wp={...Lm,emStrongRDelimAst:FR,emStrongLDelim:LR,url:_t(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",H0).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:_t(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",H0).getRegex()},KR={...Wp,br:_t(Aw).replace("{2,}","*").getRegex(),text:_t(Wp.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},xu={normal:zm,gfm:CR,pedantic:IR},bl={normal:Lm,gfm:Wp,breaks:KR,pedantic:GR},YR={"&":"&","<":"<",">":">",'"':""","'":"'"},Z0=e=>YR[e];function Or(e,t){if(t){if(ss.escapeTest.test(e))return e.replace(ss.escapeReplace,Z0)}else if(ss.escapeTestNoEncode.test(e))return e.replace(ss.escapeReplaceNoEncode,Z0);return e}function V0(e){try{e=encodeURI(e).replace(ss.percentDecode,"%")}catch{return null}return e}function W0(e,t){var o;let n=e.replace(ss.findPipe,(c,u,d)=>{let f=!1,p=u;for(;--p>=0&&d[p]==="\\";)f=!f;return f?"|":" |"}),r=n.split(ss.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((o=r.at(-1))!=null&&o.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(ss.slashPipe,"|");return r}function kl(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r&&e.charAt(r-i-1)===t;)i++;return e.slice(0,r-i)}function XR(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function q0(e,t,n,r,i){let o=t.href,c=t.title||null,u=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let d={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:c,text:u,tokens:r.inlineTokens(u)};return r.state.inLink=!1,d}function QR(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
131
|
-
`).map(o=>{let c=o.match(n.other.beginningSpace);if(c===null)return o;let[u]=c;return u.length>=i.length?o.slice(i.length):o}).join(`
|
|
132
|
-
`)}var Gu=class{constructor(e){ut(this,"options");ut(this,"rules");ut(this,"lexer");this.options=e||za}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:kl(n,`
|
|
133
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=QR(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=kl(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:kl(t[0],`
|
|
134
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=kl(t[0],`
|
|
135
|
-
`).split(`
|
|
136
|
-
`),r="",i="",o=[];for(;n.length>0;){let c=!1,u=[],d;for(d=0;d<n.length;d++)if(this.rules.other.blockquoteStart.test(n[d]))u.push(n[d]),c=!0;else if(!c)u.push(n[d]);else break;n=n.slice(d);let f=u.join(`
|
|
137
|
-
`),p=f.replace(this.rules.other.blockquoteSetextReplace,`
|
|
138
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
139
|
-
${f}`:f,i=i?`${i}
|
|
140
|
-
${p}`:p;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,o,!0),this.lexer.state.top=m,n.length===0)break;let g=o.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let v=g,y=v.raw+`
|
|
141
|
-
`+n.join(`
|
|
142
|
-
`),S=this.blockquote(y);o[o.length-1]=S,r=r.substring(0,r.length-v.raw.length)+S.raw,i=i.substring(0,i.length-v.text.length)+S.text;break}else if((g==null?void 0:g.type)==="list"){let v=g,y=v.raw+`
|
|
143
|
-
`+n.join(`
|
|
144
|
-
`),S=this.list(y);o[o.length-1]=S,r=r.substring(0,r.length-g.raw.length)+S.raw,i=i.substring(0,i.length-v.raw.length)+S.raw,n=y.substring(o.at(-1).raw.length).split(`
|
|
145
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),c=!1;for(;e;){let d=!1,f="",p="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;f=t[0],e=e.substring(f.length);let m=t[2].split(`
|
|
146
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,w=>" ".repeat(3*w.length)),g=e.split(`
|
|
147
|
-
`,1)[0],v=!m.trim(),y=0;if(this.options.pedantic?(y=2,p=m.trimStart()):v?y=t[1].length+1:(y=t[2].search(this.rules.other.nonSpaceChar),y=y>4?1:y,p=m.slice(y),y+=t[1].length),v&&this.rules.other.blankLine.test(g)&&(f+=g+`
|
|
148
|
-
`,e=e.substring(g.length+1),d=!0),!d){let w=this.rules.other.nextBulletRegex(y),T=this.rules.other.hrRegex(y),N=this.rules.other.fencesBeginRegex(y),$=this.rules.other.headingBeginRegex(y),D=this.rules.other.htmlBeginRegex(y);for(;e;){let O=e.split(`
|
|
149
|
-
`,1)[0],F;if(g=O,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),F=g):F=g.replace(this.rules.other.tabCharGlobal," "),N.test(g)||$.test(g)||D.test(g)||w.test(g)||T.test(g))break;if(F.search(this.rules.other.nonSpaceChar)>=y||!g.trim())p+=`
|
|
150
|
-
`+F.slice(y);else{if(v||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(m)||$.test(m)||T.test(m))break;p+=`
|
|
151
|
-
`+g}!v&&!g.trim()&&(v=!0),f+=O+`
|
|
152
|
-
`,e=e.substring(O.length+1),m=F.slice(y)}}i.loose||(c?i.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(c=!0));let S=null,k;this.options.gfm&&(S=this.rules.other.listIsTask.exec(p),S&&(k=S[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:f,task:!!S,checked:k,loose:!1,text:p,tokens:[]}),i.raw+=f}let u=i.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let d=0;d<i.items.length;d++)if(this.lexer.state.top=!1,i.items[d].tokens=this.lexer.blockTokens(i.items[d].text,[]),!i.loose){let f=i.items[d].tokens.filter(m=>m.type==="space"),p=f.length>0&&f.some(m=>this.rules.other.anyLine.test(m.raw));i.loose=p}if(i.loose)for(let d=0;d<i.items.length;d++)i.items[d].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){var c;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=W0(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(c=t[3])!=null&&c.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
153
|
-
`):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let u of r)this.rules.other.tableAlignRight.test(u)?o.align.push("right"):this.rules.other.tableAlignCenter.test(u)?o.align.push("center"):this.rules.other.tableAlignLeft.test(u)?o.align.push("left"):o.align.push(null);for(let u=0;u<n.length;u++)o.header.push({text:n[u],tokens:this.lexer.inline(n[u]),header:!0,align:o.align[u]});for(let u of i)o.rows.push(W0(u,o.header.length).map((d,f)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:o.align[f]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
154
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=kl(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=XR(t[2],"()");if(o===-2)return;if(o>-1){let c=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),q0(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return q0(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,c,u=i,d=0,f=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(f.lastIndex=0,t=t.slice(-1*e.length+i);(r=f.exec(t))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(c=[...o].length,r[3]||r[4]){u+=c;continue}else if((r[5]||r[6])&&i%3&&!((i+c)%3)){d+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);let p=[...r[0]][0].length,m=e.slice(0,i+r.index+p+c);if(Math.min(i,c)%2){let v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}let g=m.slice(2,-2);return{type:"strong",raw:m,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,i;if(t[2]==="@")r=t[0],i="mailto:"+r;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);r=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},hr=class qp{constructor(t){ut(this,"tokens");ut(this,"options");ut(this,"state");ut(this,"tokenizer");ut(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||za,this.options.tokenizer=this.options.tokenizer||new Gu,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ss,block:xu.normal,inline:bl.normal};this.options.pedantic?(n.block=xu.pedantic,n.inline=bl.pedantic):this.options.gfm&&(n.block=xu.gfm,this.options.breaks?n.inline=bl.breaks:n.inline=bl.gfm),this.tokenizer.rules=n}static get rules(){return{block:xu,inline:bl}}static lex(t,n){return new qp(n).lex(t)}static lexInline(t,n){return new qp(n).inlineTokens(t)}lex(t){t=t.replace(ss.carriageReturn,`
|
|
155
|
-
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var i,o,c;for(this.options.pedantic&&(t=t.replace(ss.tabCharGlobal," ").replace(ss.spaceLine,""));t;){let u;if((o=(i=this.options.extensions)==null?void 0:i.block)!=null&&o.some(f=>(u=f.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let f=n.at(-1);u.raw.length===1&&f!==void 0?f.raw+=`
|
|
156
|
-
`:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let f=n.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
|
|
157
|
-
`)?"":`
|
|
158
|
-
`)+u.raw,f.text+=`
|
|
159
|
-
`+u.text,this.inlineQueue.at(-1).src=f.text):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let f=n.at(-1);(f==null?void 0:f.type)==="paragraph"||(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
|
|
160
|
-
`)?"":`
|
|
161
|
-
`)+u.raw,f.text+=`
|
|
162
|
-
`+u.raw,this.inlineQueue.at(-1).src=f.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},n.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let d=t;if((c=this.options.extensions)!=null&&c.startBlock){let f=1/0,p=t.slice(1),m;this.options.extensions.startBlock.forEach(g=>{m=g.call({lexer:this},p),typeof m=="number"&&m>=0&&(f=Math.min(f,m))}),f<1/0&&f>=0&&(d=t.substring(0,f+1))}if(this.state.top&&(u=this.tokenizer.paragraph(d))){let f=n.at(-1);r&&(f==null?void 0:f.type)==="paragraph"?(f.raw+=(f.raw.endsWith(`
|
|
163
|
-
`)?"":`
|
|
164
|
-
`)+u.raw,f.text+=`
|
|
165
|
-
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):n.push(u),r=d.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let f=n.at(-1);(f==null?void 0:f.type)==="text"?(f.raw+=(f.raw.endsWith(`
|
|
166
|
-
`)?"":`
|
|
167
|
-
`)+u.raw,f.text+=`
|
|
168
|
-
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=f.text):n.push(u);continue}if(t){let f="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(f);break}else throw new Error(f)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var d,f,p,m,g;let r=t,i=null;if(this.tokens.links){let v=Object.keys(this.tokens.links);if(v.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)v.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)o=i[2]?i[2].length:0,r=r.slice(0,i.index+o)+"["+"a".repeat(i[0].length-o-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((f=(d=this.options.hooks)==null?void 0:d.emStrongMask)==null?void 0:f.call({lexer:this},r))??r;let c=!1,u="";for(;t;){c||(u=""),c=!1;let v;if((m=(p=this.options.extensions)==null?void 0:p.inline)!=null&&m.some(S=>(v=S.call({lexer:this},t,n))?(t=t.substring(v.raw.length),n.push(v),!0):!1))continue;if(v=this.tokenizer.escape(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.tag(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.link(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(v.raw.length);let S=n.at(-1);v.type==="text"&&(S==null?void 0:S.type)==="text"?(S.raw+=v.raw,S.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(t,r,u)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.codespan(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.br(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.del(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.autolink(t)){t=t.substring(v.raw.length),n.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(t))){t=t.substring(v.raw.length),n.push(v);continue}let y=t;if((g=this.options.extensions)!=null&&g.startInline){let S=1/0,k=t.slice(1),w;this.options.extensions.startInline.forEach(T=>{w=T.call({lexer:this},k),typeof w=="number"&&w>=0&&(S=Math.min(S,w))}),S<1/0&&S>=0&&(y=t.substring(0,S+1))}if(v=this.tokenizer.inlineText(y)){t=t.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(u=v.raw.slice(-1)),c=!0;let S=n.at(-1);(S==null?void 0:S.type)==="text"?(S.raw+=v.raw,S.text+=v.text):n.push(v);continue}if(t){let S="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(S);break}else throw new Error(S)}}return n}},Ku=class{constructor(e){ut(this,"options");ut(this,"parser");this.options=e||za}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let r=(o=(t||"").match(ss.notSpaceStart))==null?void 0:o[0],i=e.replace(ss.endingNewline,"")+`
|
|
169
|
-
`;return r?'<pre><code class="language-'+Or(r)+'">'+(n?i:Or(i,!0))+`</code></pre>
|
|
170
|
-
`:"<pre><code>"+(n?i:Or(i,!0))+`</code></pre>
|
|
171
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
172
|
-
${this.parser.parse(e)}</blockquote>
|
|
173
|
-
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
174
|
-
`}hr(e){return`<hr>
|
|
175
|
-
`}list(e){let t=e.ordered,n=e.start,r="";for(let c=0;c<e.items.length;c++){let u=e.items[c];r+=this.listitem(u)}let i=t?"ol":"ul",o=t&&n!==1?' start="'+n+'"':"";return"<"+i+o+`>
|
|
176
|
-
`+r+"</"+i+`>
|
|
177
|
-
`}listitem(e){var n;let t="";if(e.task){let r=this.checkbox({checked:!!e.checked});e.loose?((n=e.tokens[0])==null?void 0:n.type)==="paragraph"?(e.tokens[0].text=r+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=r+" "+Or(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):t+=r+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
|
|
178
|
-
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
179
|
-
`}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let o=e.rows[i];n="";for(let c=0;c<o.length;c++)n+=this.tablecell(o[c]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
180
|
-
<thead>
|
|
181
|
-
`+t+`</thead>
|
|
182
|
-
`+r+`</table>
|
|
183
|
-
`}tablerow({text:e}){return`<tr>
|
|
184
|
-
${e}</tr>
|
|
185
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
186
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Or(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=V0(e);if(i===null)return r;e=i;let o='<a href="'+e+'"';return t&&(o+=' title="'+Or(t)+'"'),o+=">"+r+"</a>",o}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=V0(e);if(i===null)return Or(n);e=i;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Or(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Or(e.text)}},Dm=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}},pr=class Gp{constructor(t){ut(this,"options");ut(this,"renderer");ut(this,"textRenderer");this.options=t||za,this.options.renderer=this.options.renderer||new Ku,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Dm}static parse(t,n){return new Gp(n).parse(t)}static parseInline(t,n){return new Gp(n).parseInline(t)}parse(t,n=!0){var i,o;let r="";for(let c=0;c<t.length;c++){let u=t[c];if((o=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&o[u.type]){let f=u,p=this.options.extensions.renderers[f.type].call({parser:this},f);if(p!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(f.type)){r+=p||"";continue}}let d=u;switch(d.type){case"space":{r+=this.renderer.space(d);continue}case"hr":{r+=this.renderer.hr(d);continue}case"heading":{r+=this.renderer.heading(d);continue}case"code":{r+=this.renderer.code(d);continue}case"table":{r+=this.renderer.table(d);continue}case"blockquote":{r+=this.renderer.blockquote(d);continue}case"list":{r+=this.renderer.list(d);continue}case"html":{r+=this.renderer.html(d);continue}case"def":{r+=this.renderer.def(d);continue}case"paragraph":{r+=this.renderer.paragraph(d);continue}case"text":{let f=d,p=this.renderer.text(f);for(;c+1<t.length&&t[c+1].type==="text";)f=t[++c],p+=`
|
|
187
|
-
`+this.renderer.text(f);n?r+=this.renderer.paragraph({type:"paragraph",raw:p,text:p,tokens:[{type:"text",raw:p,text:p,escaped:!0}]}):r+=p;continue}default:{let f='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}parseInline(t,n=this.renderer){var i,o;let r="";for(let c=0;c<t.length;c++){let u=t[c];if((o=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&o[u.type]){let f=this.options.extensions.renderers[u.type].call({parser:this},u);if(f!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(u.type)){r+=f||"";continue}}let d=u;switch(d.type){case"escape":{r+=n.text(d);break}case"html":{r+=n.html(d);break}case"link":{r+=n.link(d);break}case"image":{r+=n.image(d);break}case"strong":{r+=n.strong(d);break}case"em":{r+=n.em(d);break}case"codespan":{r+=n.codespan(d);break}case"br":{r+=n.br(d);break}case"del":{r+=n.del(d);break}case"text":{r+=n.text(d);break}default:{let f='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(f),"";throw new Error(f)}}}return r}},Mu,Cl=(Mu=class{constructor(e){ut(this,"options");ut(this,"block");this.options=e||za}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?hr.lex:hr.lexInline}provideParser(){return this.block?pr.parse:pr.parseInline}},ut(Mu,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ut(Mu,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Mu),JR=class{constructor(...e){ut(this,"defaults",Tm());ut(this,"options",this.setOptions);ut(this,"parse",this.parseMarkdown(!0));ut(this,"parseInline",this.parseMarkdown(!1));ut(this,"Parser",pr);ut(this,"Renderer",Ku);ut(this,"TextRenderer",Dm);ut(this,"Lexer",hr);ut(this,"Tokenizer",Gu);ut(this,"Hooks",Cl);this.use(...e)}walkTokens(e,t){var r,i;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let c=o;for(let u of c.header)n=n.concat(this.walkTokens(u.tokens,t));for(let u of c.rows)for(let d of u)n=n.concat(this.walkTokens(d.tokens,t));break}case"list":{let c=o;n=n.concat(this.walkTokens(c.items,t));break}default:{let c=o;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[c.type]?this.defaults.extensions.childTokens[c.type].forEach(u=>{let d=c[u].flat(1/0);n=n.concat(this.walkTokens(d,t))}):c.tokens&&(n=n.concat(this.walkTokens(c.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=t.renderers[i.name];o?t.renderers[i.name]=function(...c){let u=i.renderer.apply(this,c);return u===!1&&(u=o.apply(this,c)),u}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[i.level];o?o.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new Ku(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let c=o,u=n.renderer[c],d=i[c];i[c]=(...f)=>{let p=u.apply(i,f);return p===!1&&(p=d.apply(i,f)),p||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Gu(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let c=o,u=n.tokenizer[c],d=i[c];i[c]=(...f)=>{let p=u.apply(i,f);return p===!1&&(p=d.apply(i,f)),p}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Cl;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let c=o,u=n.hooks[c],d=i[c];Cl.passThroughHooks.has(o)?i[c]=f=>{if(this.defaults.async&&Cl.passThroughHooksRespectAsync.has(o))return(async()=>{let m=await u.call(i,f);return d.call(i,m)})();let p=u.call(i,f);return d.call(i,p)}:i[c]=(...f)=>{if(this.defaults.async)return(async()=>{let m=await u.apply(i,f);return m===!1&&(m=await d.apply(i,f)),m})();let p=u.apply(i,f);return p===!1&&(p=d.apply(i,f)),p}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(c){let u=[];return u.push(o.call(this,c)),i&&(u=u.concat(i.call(this,c))),u}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return hr.lex(e,t??this.defaults)}parser(e,t){return pr.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let c=i.hooks?await i.hooks.preprocess(t):t,u=await(i.hooks?await i.hooks.provideLexer():e?hr.lex:hr.lexInline)(c,i),d=i.hooks?await i.hooks.processAllTokens(u):u;i.walkTokens&&await Promise.all(this.walkTokens(d,i.walkTokens));let f=await(i.hooks?await i.hooks.provideParser():e?pr.parse:pr.parseInline)(d,i);return i.hooks?await i.hooks.postprocess(f):f})().catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let c=(i.hooks?i.hooks.provideLexer():e?hr.lex:hr.lexInline)(t,i);i.hooks&&(c=i.hooks.processAllTokens(c)),i.walkTokens&&this.walkTokens(c,i.walkTokens);let u=(i.hooks?i.hooks.provideParser():e?pr.parse:pr.parseInline)(c,i);return i.hooks&&(u=i.hooks.postprocess(u)),u}catch(c){return o(c)}}}onError(e,t){return n=>{if(n.message+=`
|
|
188
|
-
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Or(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Ea=new JR;function Ct(e,t){return Ea.parse(e,t)}Ct.options=Ct.setOptions=function(e){return Ea.setOptions(e),Ct.defaults=Ea.defaults,_w(Ct.defaults),Ct};Ct.getDefaults=Tm;Ct.defaults=za;Ct.use=function(...e){return Ea.use(...e),Ct.defaults=Ea.defaults,_w(Ct.defaults),Ct};Ct.walkTokens=function(e,t){return Ea.walkTokens(e,t)};Ct.parseInline=Ea.parseInline;Ct.Parser=pr;Ct.parser=pr.parse;Ct.Renderer=Ku;Ct.TextRenderer=Dm;Ct.Lexer=hr;Ct.lexer=hr.lex;Ct.Tokenizer=Gu;Ct.Hooks=Cl;Ct.parse=Ct;Ct.options;Ct.setOptions;Ct.use;Ct.walkTokens;Ct.parseInline;pr.parse;hr.lex;var Fh,G0;function eO(){if(G0)return Fh;G0=1;function e(Q){return Q instanceof Map?Q.clear=Q.delete=Q.set=function(){throw new Error("map is read-only")}:Q instanceof Set&&(Q.add=Q.clear=Q.delete=function(){throw new Error("set is read-only")}),Object.freeze(Q),Object.getOwnPropertyNames(Q).forEach(pe=>{const Oe=Q[pe],st=typeof Oe;(st==="object"||st==="function")&&!Object.isFrozen(Oe)&&e(Oe)}),Q}class t{constructor(pe){pe.data===void 0&&(pe.data={}),this.data=pe.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(Q){return Q.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(Q,...pe){const Oe=Object.create(null);for(const st in Q)Oe[st]=Q[st];return pe.forEach(function(st){for(const It in st)Oe[It]=st[It]}),Oe}const i="</span>",o=Q=>!!Q.scope,c=(Q,{prefix:pe})=>{if(Q.startsWith("language:"))return Q.replace("language:","language-");if(Q.includes(".")){const Oe=Q.split(".");return[`${pe}${Oe.shift()}`,...Oe.map((st,It)=>`${st}${"_".repeat(It+1)}`)].join(" ")}return`${pe}${Q}`};class u{constructor(pe,Oe){this.buffer="",this.classPrefix=Oe.classPrefix,pe.walk(this)}addText(pe){this.buffer+=n(pe)}openNode(pe){if(!o(pe))return;const Oe=c(pe.scope,{prefix:this.classPrefix});this.span(Oe)}closeNode(pe){o(pe)&&(this.buffer+=i)}value(){return this.buffer}span(pe){this.buffer+=`<span class="${pe}">`}}const d=(Q={})=>{const pe={children:[]};return Object.assign(pe,Q),pe};class f{constructor(){this.rootNode=d(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(pe){this.top.children.push(pe)}openNode(pe){const Oe=d({scope:pe});this.add(Oe),this.stack.push(Oe)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(pe){return this.constructor._walk(pe,this.rootNode)}static _walk(pe,Oe){return typeof Oe=="string"?pe.addText(Oe):Oe.children&&(pe.openNode(Oe),Oe.children.forEach(st=>this._walk(pe,st)),pe.closeNode(Oe)),pe}static _collapse(pe){typeof pe!="string"&&pe.children&&(pe.children.every(Oe=>typeof Oe=="string")?pe.children=[pe.children.join("")]:pe.children.forEach(Oe=>{f._collapse(Oe)}))}}class p extends f{constructor(pe){super(),this.options=pe}addText(pe){pe!==""&&this.add(pe)}startScope(pe){this.openNode(pe)}endScope(){this.closeNode()}__addSublanguage(pe,Oe){const st=pe.root;Oe&&(st.scope=`language:${Oe}`),this.add(st)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(Q){return Q?typeof Q=="string"?Q:Q.source:null}function g(Q){return S("(?=",Q,")")}function v(Q){return S("(?:",Q,")*")}function y(Q){return S("(?:",Q,")?")}function S(...Q){return Q.map(Oe=>m(Oe)).join("")}function k(Q){const pe=Q[Q.length-1];return typeof pe=="object"&&pe.constructor===Object?(Q.splice(Q.length-1,1),pe):{}}function w(...Q){return"("+(k(Q).capture?"":"?:")+Q.map(st=>m(st)).join("|")+")"}function T(Q){return new RegExp(Q.toString()+"|").exec("").length-1}function N(Q,pe){const Oe=Q&&Q.exec(pe);return Oe&&Oe.index===0}const $=new RegExp(w(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function D(Q,{joinWith:pe}){let Oe=0;return Q.map(st=>{Oe+=1;const It=Oe;let Tt=m(st),Be="";for(;Tt.length>0;){const De=$.exec(Tt);if(!De){Be+=Tt;break}Be+=Tt.substring(0,De.index),Tt=Tt.substring(De.index+De[0].length),De[0][0]==="\\"&&De[1]?Be+="\\"+String(Number(De[1])+It):(Be+=De[0],(De[0]==="("||/^\(\?[<']/.test(De[0]))&&Oe++)}return Be}).map(st=>`(${st})`).join(pe)}const O=/\b\B/,F="[a-zA-Z]\\w*",U="[a-zA-Z_]\\w*",M="\\b\\d+(\\.\\d+)?",P="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",R="\\b(0b[01]+)",Z="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",E=(Q={})=>{const pe=/^#![ ]*\//;return Q.binary&&(Q.begin=S(pe,/.*\b/,Q.binary,/\b.*/)),r({scope:"meta",begin:pe,end:/$/,relevance:0,"on:begin":(Oe,st)=>{Oe.index!==0&&st.ignoreMatch()}},Q)},C={begin:"\\\\[\\s\\S]",relevance:0},I={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[C]},L={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[C]},W={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},H=function(Q,pe,Oe={}){const st=r({scope:"comment",begin:Q,end:pe,contains:[]},Oe);st.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const It=w("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return st.contains.push({begin:S(/[ ]+/,"(",It,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),st},G=H("//","$"),K=H("/\\*","\\*/"),V=H("#","$"),Y={scope:"number",begin:M,relevance:0},fe={scope:"number",begin:P,relevance:0},xe={scope:"number",begin:R,relevance:0},me={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[C,{begin:/\[/,end:/\]/,relevance:0,contains:[C]}]},ie={scope:"title",begin:F,relevance:0},ke={scope:"title",begin:U,relevance:0},ae={begin:"\\.\\s*"+U,relevance:0};var Fe=Object.freeze({__proto__:null,APOS_STRING_MODE:I,BACKSLASH_ESCAPE:C,BINARY_NUMBER_MODE:xe,BINARY_NUMBER_RE:R,COMMENT:H,C_BLOCK_COMMENT_MODE:K,C_LINE_COMMENT_MODE:G,C_NUMBER_MODE:fe,C_NUMBER_RE:P,END_SAME_AS_BEGIN:function(Q){return Object.assign(Q,{"on:begin":(pe,Oe)=>{Oe.data._beginMatch=pe[1]},"on:end":(pe,Oe)=>{Oe.data._beginMatch!==pe[1]&&Oe.ignoreMatch()}})},HASH_COMMENT_MODE:V,IDENT_RE:F,MATCH_NOTHING_RE:O,METHOD_GUARD:ae,NUMBER_MODE:Y,NUMBER_RE:M,PHRASAL_WORDS_MODE:W,QUOTE_STRING_MODE:L,REGEXP_MODE:me,RE_STARTERS_RE:Z,SHEBANG:E,TITLE_MODE:ie,UNDERSCORE_IDENT_RE:U,UNDERSCORE_TITLE_MODE:ke});function ce(Q,pe){Q.input[Q.index-1]==="."&&pe.ignoreMatch()}function je(Q,pe){Q.className!==void 0&&(Q.scope=Q.className,delete Q.className)}function re(Q,pe){pe&&Q.beginKeywords&&(Q.begin="\\b("+Q.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",Q.__beforeBegin=ce,Q.keywords=Q.keywords||Q.beginKeywords,delete Q.beginKeywords,Q.relevance===void 0&&(Q.relevance=0))}function he(Q,pe){Array.isArray(Q.illegal)&&(Q.illegal=w(...Q.illegal))}function ze(Q,pe){if(Q.match){if(Q.begin||Q.end)throw new Error("begin & end are not supported with match");Q.begin=Q.match,delete Q.match}}function Te(Q,pe){Q.relevance===void 0&&(Q.relevance=1)}const Ge=(Q,pe)=>{if(!Q.beforeMatch)return;if(Q.starts)throw new Error("beforeMatch cannot be used with starts");const Oe=Object.assign({},Q);Object.keys(Q).forEach(st=>{delete Q[st]}),Q.keywords=Oe.keywords,Q.begin=S(Oe.beforeMatch,g(Oe.begin)),Q.starts={relevance:0,contains:[Object.assign(Oe,{endsParent:!0})]},Q.relevance=0,delete Oe.beforeMatch},Ie=["of","and","for","in","not","or","if","then","parent","list","value"],tt="keyword";function et(Q,pe,Oe=tt){const st=Object.create(null);return typeof Q=="string"?It(Oe,Q.split(" ")):Array.isArray(Q)?It(Oe,Q):Object.keys(Q).forEach(function(Tt){Object.assign(st,et(Q[Tt],pe,Tt))}),st;function It(Tt,Be){pe&&(Be=Be.map(De=>De.toLowerCase())),Be.forEach(function(De){const Xe=De.split("|");st[Xe[0]]=[Tt,jt(Xe[0],Xe[1])]})}}function jt(Q,pe){return pe?Number(pe):On(Q)?0:1}function On(Q){return Ie.includes(Q.toLowerCase())}const sn={},ln=Q=>{console.error(Q)},cn=(Q,...pe)=>{console.log(`WARN: ${Q}`,...pe)},rn=(Q,pe)=>{sn[`${Q}/${pe}`]||(console.log(`Deprecated as of ${Q}. ${pe}`),sn[`${Q}/${pe}`]=!0)},an=new Error;function Ft(Q,pe,{key:Oe}){let st=0;const It=Q[Oe],Tt={},Be={};for(let De=1;De<=pe.length;De++)Be[De+st]=It[De],Tt[De+st]=!0,st+=T(pe[De-1]);Q[Oe]=Be,Q[Oe]._emit=Tt,Q[Oe]._multi=!0}function Bn(Q){if(Array.isArray(Q.begin)){if(Q.skip||Q.excludeBegin||Q.returnBegin)throw ln("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),an;if(typeof Q.beginScope!="object"||Q.beginScope===null)throw ln("beginScope must be object"),an;Ft(Q,Q.begin,{key:"beginScope"}),Q.begin=D(Q.begin,{joinWith:""})}}function wn(Q){if(Array.isArray(Q.end)){if(Q.skip||Q.excludeEnd||Q.returnEnd)throw ln("skip, excludeEnd, returnEnd not compatible with endScope: {}"),an;if(typeof Q.endScope!="object"||Q.endScope===null)throw ln("endScope must be object"),an;Ft(Q,Q.end,{key:"endScope"}),Q.end=D(Q.end,{joinWith:""})}}function ws(Q){Q.scope&&typeof Q.scope=="object"&&Q.scope!==null&&(Q.beginScope=Q.scope,delete Q.scope)}function _r(Q){ws(Q),typeof Q.beginScope=="string"&&(Q.beginScope={_wrap:Q.beginScope}),typeof Q.endScope=="string"&&(Q.endScope={_wrap:Q.endScope}),Bn(Q),wn(Q)}function Ks(Q){function pe(Be,De){return new RegExp(m(Be),"m"+(Q.case_insensitive?"i":"")+(Q.unicodeRegex?"u":"")+(De?"g":""))}class Oe{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(De,Xe){Xe.position=this.position++,this.matchIndexes[this.matchAt]=Xe,this.regexes.push([Xe,De]),this.matchAt+=T(De)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const De=this.regexes.map(Xe=>Xe[1]);this.matcherRe=pe(D(De,{joinWith:"|"}),!0),this.lastIndex=0}exec(De){this.matcherRe.lastIndex=this.lastIndex;const Xe=this.matcherRe.exec(De);if(!Xe)return null;const bt=Xe.findIndex((Un,is)=>is>0&&Un!==void 0),yt=this.matchIndexes[bt];return Xe.splice(0,bt),Object.assign(Xe,yt)}}class st{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(De){if(this.multiRegexes[De])return this.multiRegexes[De];const Xe=new Oe;return this.rules.slice(De).forEach(([bt,yt])=>Xe.addRule(bt,yt)),Xe.compile(),this.multiRegexes[De]=Xe,Xe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(De,Xe){this.rules.push([De,Xe]),Xe.type==="begin"&&this.count++}exec(De){const Xe=this.getMatcher(this.regexIndex);Xe.lastIndex=this.lastIndex;let bt=Xe.exec(De);if(this.resumingScanAtSamePosition()&&!(bt&&bt.index===this.lastIndex)){const yt=this.getMatcher(0);yt.lastIndex=this.lastIndex+1,bt=yt.exec(De)}return bt&&(this.regexIndex+=bt.position+1,this.regexIndex===this.count&&this.considerAll()),bt}}function It(Be){const De=new st;return Be.contains.forEach(Xe=>De.addRule(Xe.begin,{rule:Xe,type:"begin"})),Be.terminatorEnd&&De.addRule(Be.terminatorEnd,{type:"end"}),Be.illegal&&De.addRule(Be.illegal,{type:"illegal"}),De}function Tt(Be,De){const Xe=Be;if(Be.isCompiled)return Xe;[je,ze,_r,Ge].forEach(yt=>yt(Be,De)),Q.compilerExtensions.forEach(yt=>yt(Be,De)),Be.__beforeBegin=null,[re,he,Te].forEach(yt=>yt(Be,De)),Be.isCompiled=!0;let bt=null;return typeof Be.keywords=="object"&&Be.keywords.$pattern&&(Be.keywords=Object.assign({},Be.keywords),bt=Be.keywords.$pattern,delete Be.keywords.$pattern),bt=bt||/\w+/,Be.keywords&&(Be.keywords=et(Be.keywords,Q.case_insensitive)),Xe.keywordPatternRe=pe(bt,!0),De&&(Be.begin||(Be.begin=/\B|\b/),Xe.beginRe=pe(Xe.begin),!Be.end&&!Be.endsWithParent&&(Be.end=/\B|\b/),Be.end&&(Xe.endRe=pe(Xe.end)),Xe.terminatorEnd=m(Xe.end)||"",Be.endsWithParent&&De.terminatorEnd&&(Xe.terminatorEnd+=(Be.end?"|":"")+De.terminatorEnd)),Be.illegal&&(Xe.illegalRe=pe(Be.illegal)),Be.contains||(Be.contains=[]),Be.contains=[].concat(...Be.contains.map(function(yt){return $s(yt==="self"?Be:yt)})),Be.contains.forEach(function(yt){Tt(yt,Xe)}),Be.starts&&Tt(Be.starts,De),Xe.matcher=It(Xe),Xe}if(Q.compilerExtensions||(Q.compilerExtensions=[]),Q.contains&&Q.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return Q.classNameAliases=r(Q.classNameAliases||{}),Tt(Q)}function Ys(Q){return Q?Q.endsWithParent||Ys(Q.starts):!1}function $s(Q){return Q.variants&&!Q.cachedVariants&&(Q.cachedVariants=Q.variants.map(function(pe){return r(Q,{variants:null},pe)})),Q.cachedVariants?Q.cachedVariants:Ys(Q)?r(Q,{starts:Q.starts?r(Q.starts):null}):Object.isFrozen(Q)?r(Q):Q}var Rs="11.12.0";class Os extends Error{constructor(pe,Oe){super(pe),this.name="HTMLInjectionError",this.html=Oe}}const zs=n,Xs=r,Qs=Symbol("nomatch"),rs=7,Yn=function(Q){const pe=Object.create(null),Oe=Object.create(null),st=[];let It=!0;const Tt="Could not find the language '{}', did you forget to load/include a language module?",Be={disableAutodetect:!0,name:"Plain text",contains:[]};let De={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Xe(Ae){return De.noHighlightRe.test(Ae)}function bt(Ae){let Ze=Ae.className+" ";Ze+=Ae.parentNode?Ae.parentNode.className:"";const ct=De.languageDetectRe.exec(Ze);if(ct){const ft=Xn(ct[1]);return ft||(cn(Tt.replace("{}",ct[1])),cn("Falling back to no-highlight mode for this block.",Ae)),ft?ct[1]:"no-highlight"}return Ze.split(/\s+/).find(ft=>Xe(ft)||Xn(ft))}function yt(Ae,Ze,ct){let ft="",At="";typeof Ze=="object"?(ft=Ae,ct=Ze.ignoreIllegals,At=Ze.language):(rn("10.7.0","highlight(lang, code, ...args) has been deprecated."),rn("10.7.0",`Please use highlight(code, options) instead.
|
|
189
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),At=Ae,ft=Ze),ct===void 0&&(ct=!0);const zt={code:ft,language:At};nr("before:highlight",zt);const Zn=zt.result?zt.result:Un(zt.language,zt.code,ct);return Zn.code=zt.code,nr("after:highlight",Zn),Zn}function Un(Ae,Ze,ct,ft){const At=Object.create(null);function zt(Me,Ue){return Me.keywords[Ue]}function Zn(){if(!at.keywords){Pt.addText(ht);return}let Me=0;at.keywordPatternRe.lastIndex=0;let Ue=at.keywordPatternRe.exec(ht),ot="";for(;Ue;){ot+=ht.substring(Me,Ue.index);const gt=Sn.case_insensitive?Ue[0].toLowerCase():Ue[0],Bt=zt(at,gt);if(Bt){const[pn,Fo]=Bt;if(Pt.addText(ot),ot="",At[gt]=(At[gt]||0)+1,At[gt]<=rs&&(Zr+=Fo),pn.startsWith("_"))ot+=Ue[0];else{const Ji=Sn.classNameAliases[pn]||pn;jn(Ue[0],Ji)}}else ot+=Ue[0];Me=at.keywordPatternRe.lastIndex,Ue=at.keywordPatternRe.exec(ht)}ot+=ht.substring(Me),Pt.addText(ot)}function Ps(){if(ht==="")return;let Me=null;if(typeof at.subLanguage=="string"){if(!pe[at.subLanguage]){Pt.addText(ht);return}Me=Un(at.subLanguage,ht,!0,cs[at.subLanguage]),cs[at.subLanguage]=Me._top}else Me=Js(ht,at.subLanguage.length?at.subLanguage:null);at.relevance>0&&(Zr+=Me.relevance),Pt.__addSublanguage(Me._emitter,Me.language)}function un(){at.subLanguage!=null?Ps():Zn(),ht=""}function jn(Me,Ue){Me!==""&&(Pt.startScope(Ue),Pt.addText(Me),Pt.endScope())}function Ls(Me,Ue){let ot=1;const gt=Ue.length-1;for(;ot<=gt;){if(!Me._emit[ot]){ot++;continue}const Bt=Sn.classNameAliases[Me[ot]]||Me[ot],pn=Ue[ot];Bt?jn(pn,Bt):(ht=pn,Zn(),ht=""),ot++}}function Ds(Me,Ue){return Me.scope&&typeof Me.scope=="string"&&Pt.openNode(Sn.classNameAliases[Me.scope]||Me.scope),Me.beginScope&&(Me.beginScope._wrap?(jn(ht,Sn.classNameAliases[Me.beginScope._wrap]||Me.beginScope._wrap),ht=""):Me.beginScope._multi&&(Ls(Me.beginScope,Ue),ht="")),at=Object.create(Me,{parent:{value:at}}),at}function os(Me,Ue,ot){let gt=N(Me.endRe,ot);if(gt){if(Me["on:end"]){const Bt=new t(Me);Me["on:end"](Ue,Bt),Bt.isMatchIgnored&&(gt=!1)}if(gt){for(;Me.endsParent&&Me.parent;)Me=Me.parent;return Me}}if(Me.endsWithParent)return os(Me.parent,Ue,ot)}function Qi(Me){return at.matcher.regexIndex===0?(ht+=Me[0],1):(sr=!0,0)}function xi(Me){const Ue=Me[0],ot=Me.rule,gt=new t(ot),Bt=[ot.__beforeBegin,ot["on:begin"]];for(const pn of Bt)if(pn&&(pn(Me,gt),gt.isMatchIgnored))return Qi(Ue);return ot.skip?ht+=Ue:(ot.excludeBegin&&(ht+=Ue),un(),!ot.returnBegin&&!ot.excludeBegin&&(ht=Ue)),Ds(ot,Me),ot.returnBegin?0:Ue.length}function Ir(Me){const Ue=Me[0],ot=Ze.substring(Me.index),gt=os(at,Me,ot);if(!gt)return Qs;const Bt=at;at.endScope&&at.endScope._wrap?(un(),jn(Ue,at.endScope._wrap)):at.endScope&&at.endScope._multi?(un(),Ls(at.endScope,Me)):Bt.skip?ht+=Ue:(Bt.returnEnd||Bt.excludeEnd||(ht+=Ue),un(),Bt.excludeEnd&&(ht=Ue));do at.scope&&Pt.closeNode(),!at.skip&&!at.subLanguage&&(Zr+=at.relevance),at=at.parent;while(at!==gt.parent);return gt.starts&&Ds(gt.starts,Me),Bt.returnEnd?0:Ue.length}function vi(){const Me=[];for(let Ue=at;Ue!==Sn;Ue=Ue.parent)Ue.scope&&Me.unshift(Ue.scope);Me.forEach(Ue=>Pt.openNode(Ue))}let Qn={};function ls(Me,Ue){const ot=Ue&&Ue[0];if(ht+=Me,ot==null)return un(),0;if(Qn.type==="begin"&&Ue.type==="end"&&Qn.index===Ue.index&&ot===""){if(ht+=Ze.slice(Ue.index,Ue.index+1),!It){const gt=new Error(`0 width match regex (${Ae})`);throw gt.languageName=Ae,gt.badRule=Qn.rule,gt}return 1}if(Qn=Ue,Ue.type==="begin")return xi(Ue);if(Ue.type==="illegal"&&!ct){const gt=new Error('Illegal lexeme "'+ot+'" for mode "'+(at.scope||"<unnamed>")+'"');throw gt.mode=at,gt}else if(Ue.type==="end"){const gt=Ir(Ue);if(gt!==Qs)return gt}if(Ue.type==="illegal"&&ot==="")return Ue.index===Ze.length||(ht+=`
|
|
190
|
-
`),1;if(Vr>1e5&&Vr>Ue.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ht+=ot,ot.length}const Sn=Xn(Ae);if(!Sn)throw ln(Tt.replace("{}",Ae)),new Error('Unknown language: "'+Ae+'"');const Fs=Ks(Sn);let vt="",at=ft||Fs;const cs={},Pt=new De.__emitter(De);vi();let ht="",Zr=0,Jn=0,Vr=0,sr=!1;try{if(Sn.__emitTokens)Sn.__emitTokens(Ze,Pt);else{for(at.matcher.considerAll();;){Vr++,sr?sr=!1:at.matcher.considerAll(),at.matcher.lastIndex=Jn;const Me=at.matcher.exec(Ze);if(!Me)break;const Ue=Ze.substring(Jn,Me.index),ot=ls(Ue,Me);Jn=Me.index+ot}ls(Ze.substring(Jn))}return Pt.finalize(),vt=Pt.toHTML(),{language:Ae,value:vt,relevance:Zr,illegal:!1,_emitter:Pt,_top:at}}catch(Me){if(Me.message&&Me.message.includes("Illegal"))return{language:Ae,value:zs(Ze),illegal:!0,relevance:0,_illegalBy:{message:Me.message,index:Jn,context:Ze.slice(Jn-100,Jn+100),mode:Me.mode,resultSoFar:vt},_emitter:Pt};if(It)return{language:Ae,value:zs(Ze),illegal:!1,relevance:0,errorRaised:Me,_emitter:Pt,_top:at};throw Me}}function is(Ae){const Ze={value:zs(Ae),illegal:!1,relevance:0,_top:Be,_emitter:new De.__emitter(De)};return Ze._emitter.addText(Ae),Ze}function Js(Ae,Ze){Ze=Ze||De.languages||Object.keys(pe);const ct=is(Ae),ft=Ze.filter(Xn).filter(tr).map(un=>Un(un,Ae,!1));ft.unshift(ct);const At=ft.sort((un,jn)=>{if(un.relevance!==jn.relevance)return jn.relevance-un.relevance;if(un.language&&jn.language){if(Xn(un.language).supersetOf===jn.language)return 1;if(Xn(jn.language).supersetOf===un.language)return-1}return 0}),[zt,Zn]=At,Ps=zt;return Ps.secondBest=Zn,Ps}function hi(Ae,Ze,ct){const ft=Ze&&Oe[Ze]||ct;Ae.classList.add("hljs"),Ae.classList.add(`language-${ft}`)}function er(Ae){let Ze=null;const ct=bt(Ae);if(Xe(ct))return;if(nr("before:highlightElement",{el:Ae,language:ct}),Ae.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ae);return}if(Ae.children.length>0&&(De.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Ae)),De.throwUnescapedHTML))throw new Os("One of your code blocks includes unescaped HTML.",Ae.innerHTML);Ze=Ae;const ft=Ze.textContent,At=ct?yt(ft,{language:ct,ignoreIllegals:!0}):Js(ft);Ae.innerHTML=At.value,Ae.dataset.highlighted="yes",hi(Ae,ct,At.language),Ae.result={language:At.language,re:At.relevance,relevance:At.relevance},At.secondBest&&(Ae.secondBest={language:At.secondBest.language,relevance:At.secondBest.relevance}),nr("after:highlightElement",{el:Ae,result:At,text:ft})}function pi(Ae){De=Xs(De,Ae)}const Hn=()=>{Er(),rn("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Br(){Er(),rn("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let as=!1;function Er(){function Ae(){Er()}if(document.readyState==="loading"){as||window.addEventListener("DOMContentLoaded",Ae,!1),as=!0;return}document.querySelectorAll(De.cssSelector).forEach(er)}function mi(Ae,Ze){let ct=null;try{ct=Ze(Q)}catch(ft){if(ln("Language definition for '{}' could not be registered.".replace("{}",Ae)),It)ln(ft);else throw ft;ct=Be}ct.name||(ct.name=Ae),pe[Ae]=ct,ct.rawDefinition=Ze.bind(null,Q),ct.aliases&&Ur(ct.aliases,{languageName:Ae})}function Rt(Ae){delete pe[Ae];for(const Ze of Object.keys(Oe))Oe[Ze]===Ae&&delete Oe[Ze]}function Ns(){return Object.keys(pe)}function Xn(Ae){return Ae=(Ae||"").toLowerCase(),pe[Ae]||pe[Oe[Ae]]}function Ur(Ae,{languageName:Ze}){typeof Ae=="string"&&(Ae=[Ae]),Ae.forEach(ct=>{Oe[ct.toLowerCase()]=Ze})}function tr(Ae){const Ze=Xn(Ae);return Ze&&!Ze.disableAutodetect}function Ot(Ae){Ae["before:highlightBlock"]&&!Ae["before:highlightElement"]&&(Ae["before:highlightElement"]=Ze=>{Ae["before:highlightBlock"](Object.assign({block:Ze.el},Ze))}),Ae["after:highlightBlock"]&&!Ae["after:highlightElement"]&&(Ae["after:highlightElement"]=Ze=>{Ae["after:highlightBlock"](Object.assign({block:Ze.el},Ze))})}function gi(Ae){Ot(Ae),st.push(Ae)}function Hr(Ae){const Ze=st.indexOf(Ae);Ze!==-1&&st.splice(Ze,1)}function nr(Ae,Ze){const ct=Ae;st.forEach(function(ft){ft[ct]&&ft[ct](Ze)})}function Cr(Ae){return rn("10.7.0","highlightBlock will be removed entirely in v12.0"),rn("10.7.0","Please use highlightElement now."),er(Ae)}Object.assign(Q,{highlight:yt,highlightAuto:Js,highlightAll:Er,highlightElement:er,highlightBlock:Cr,configure:pi,initHighlighting:Hn,initHighlightingOnLoad:Br,registerLanguage:mi,unregisterLanguage:Rt,listLanguages:Ns,getLanguage:Xn,registerAliases:Ur,autoDetection:tr,inherit:Xs,addPlugin:gi,removePlugin:Hr}),Q.debugMode=function(){It=!1},Q.safeMode=function(){It=!0},Q.versionString=Rs,Q.regex={concat:S,lookahead:g,either:w,optional:y,anyNumberOfTimes:v};for(const Ae in Fe)typeof Fe[Ae]=="object"&&e(Fe[Ae]);return Object.assign(Q,Fe),Q},Nn=Yn({});return Nn.newInstance=()=>Yn({}),Fh=Nn,Nn.HighlightJS=Nn,Nn.default=Nn,Fh}var tO=eO();const wr=pm(tO);function nO(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const i={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},o=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),c={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},u={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(u);const d={match:/\\"/},f={className:"string",begin:/'/,end:/'/},p={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],v=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),y={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},S=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],k=["true","false"],w={match:/(\/[a-z._-]+)+/},T=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],N=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],$=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],D=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:S,literal:k,built_in:[...T,...N,"set","shopt",...$,...D]},contains:[v,e.SHEBANG(),y,m,o,c,w,u,d,f,p,n]}}const sO=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},UNICODE_RANGE:{scope:"number",begin:/\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,5}(-[0-9A-Fa-f][0-9A-Fa-f]{0,5})?/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),rO=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],iO=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],aO=[...rO,...iO],oO=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),lO=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),cO=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),uO=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","corner-bottom-left-shape","corner-bottom-right-shape","corner-shape","corner-top-left-shape","corner-top-right-shape","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","unicode-range","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function dO(e){const t=e.regex,n=sO(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i="and or not only",o=/@-?\w[\w]*(-\w+)*/,c="[a-zA-Z-][a-zA-Z0-9_-]*",u=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+c,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+lO.join("|")+")"},{begin:":(:)?("+cO.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+uO.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...u,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...u,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:o},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:oO.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+aO.join("|")+")\\b"}]}}function fO(e){const t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^@@ +-\d+ +\+\d+,\d+ +@@/,/^@@ +-\d+,\d+ +\+\d+ +@@/,/^@@ +-\d+ +\+\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function hO(e){const o={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:o,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\b0[bB](_?[01])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:o,illegal:/["']/}]}]}}var fo="[0-9](_*[0-9])*",vu=`\\.(${fo})`,yu="[0-9a-fA-F](_*[0-9a-fA-F])*",K0={className:"number",variants:[{begin:`(\\b(${fo})((${vu})|\\.)?|(${vu}))[eE][+-]?(${fo})[fFdD]?\\b`},{begin:`\\b(${fo})((${vu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${vu})[fFdD]?\\b`},{begin:`\\b(${fo})[fFdD]\\b`},{begin:`\\b0[xX]((${yu})\\.?|(${yu})?\\.(${yu}))[pP][+-]?(${fo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${yu})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Pw(e,t,n){return n===-1?"":e.replace(t,r=>Pw(e,t,n-1))}function pO(e){const t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r="(?:(?:\\s*\\[\\s*])+)?",i=n+"<@@@>"+r,c="(?:"+("\\?(?:\\s+(?:extends|super)\\s+"+i+")?")+"|"+i+")",u=Pw("(?:\\s*<\\s*"+c+"(?:\\s*,\\s*"+c+")*\\s*>)?",/<@@@>/g,2),g={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},v={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},y={className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:g,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{beginKeywords:"new throw return else yield assert",relevance:0},{begin:[n,t.concat(u,r,/\s+/),n,r,/\s*/,/=(?!=)/],className:{1:"type",3:"variable",6:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{begin:[n,t.concat(u,r,/\s+/),n,/\s*(?=\()/],className:{1:"type",3:"title.function"},keywords:g,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[v,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,K0,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},K0,v]}}const Y0="[A-Za-z$_][0-9A-Za-z$_]*",mO=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],gO=["true","false","null","undefined","NaN","Infinity"],Lw=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Dw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Fw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],xO=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],vO=[].concat(Fw,Lw,Dw);function yO(e){const t=e.regex,n=(H,{after:G})=>{const K="</"+H[0].slice(1);return H.input.indexOf(K,G)!==-1},r=Y0,i={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,G)=>{const K=H[0].length+H.index,V=H.input[K];if(V==="<"||V===","){G.ignoreMatch();return}V===">"&&(n(H,{after:K})||G.ignoreMatch());let Y;const fe=H.input.substring(K);if(Y=fe.match(/^\s*=/)){G.ignoreMatch();return}if((Y=fe.match(/^\s+extends\s+/))&&Y.index===0){G.ignoreMatch();return}}},u={$pattern:Y0,keyword:mO,literal:gO,built_in:vO,"variable.language":xO},d="[0-9](_?[0-9])*",f=`\\.(${d})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${d})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},S={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},k={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},T={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,y,S,k,{match:/\$\d+/},m];g.contains=N.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(N)});const $=[].concat(T,g.contains),D=$.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat($)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:D},F={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},U={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Lw,...Dw]}},M={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},R={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Z(H){return t.concat("(?!",H.join("|"),")")}const E={match:t.concat(/\b/,Z([...Fw,"super","import","await"].map(H=>`${H}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},C={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},I={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},O]},L="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",W={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(L)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:D,CLASS_REFERENCE:U},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),M,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,y,S,k,T,{match:/\$\d+/},m,U,{scope:"attr",match:r+t.lookahead(":"),relevance:0},W,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,e.REGEXP_MODE,{className:"function",begin:L,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:D}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:o},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},P,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},C,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},E,R,F,I,{match:/\$[(.]/}]}}const bO="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",kO={scope:"number",match:bO,relevance:0};function wO(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:r},contains:[t,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,i,kO,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function NO(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},i={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},o={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},c={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,d={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,u,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(f,{contains:[]}),g=e.inherit(p,{contains:[]});f.contains.push(g),p.contains.push(m);let v=[n,d];return[f,p,m,g].forEach(w=>{w.contains=w.contains.concat(v)}),v=v.concat(f,p),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:v},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:v}]}]},n,o,r,f,p,{className:"quote",begin:"^>\\s+",contains:v,end:"$"},i,d,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function jO(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],u={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},d={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},p={begin:/\{\{/,relevance:0},m={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,d,p,f]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d,p,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,p,f]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,f]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",v=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,y=`\\b|${r.join("|")}`,S={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${v}))[eE][+-]?(${g})[jJ]?(?=${y})`},{begin:`(${v})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${y})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${y})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${y})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${y})`},{begin:`\\b(${g})[jJ](?=${y})`}]},k={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},w={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",d,S,m,e.HASH_COMMENT_MODE]}]};return f.contains=[m,S,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[d,S,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,k,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[w]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[S,w,m]}]}}function SO(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),o={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,i,t.lookahead(/\s*\(/))},c="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",u=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],d=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],p=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:p,keyword:u,literal:d,built_in:f},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+c},{begin:"\\b0o([0-7_]+)"+c},{begin:"\\b0x([A-Fa-f0-9_]+)"+c},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+c}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,r],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:p}},{scope:"punctuation",begin:"->"},o]}}function _O(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],c=["double precision","large object","with timezone","without timezone"],u=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],d=["add","asc","collation","desc","final","first","last","view"],f=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],p=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],m=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],g=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],v=p,y=[...f,...d].filter(D=>!p.includes(D)),S={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},k={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},w={match:t.concat(/\b/,t.either(...v),/\s*\(/),relevance:0,keywords:{built_in:v}};function T(D){return t.concat(/\b/,t.either(...D.map(O=>O.replace(/\s+/,"\\s+"))),/\b/)}const N={scope:"keyword",match:T(g),relevance:0};function $(D,{exceptions:O,when:F}={}){const U=F;return O=O||[],D.map(M=>M.match(/\|\d+$/)||O.includes(M)?M:U(M)?`${M}|0`:M)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:$(y,{when:D=>D.length<3}),literal:o,type:u,built_in:m},contains:[{scope:"type",match:T(c)},N,w,S,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,k]}}const Yu="[A-Za-z$_][0-9A-Za-z$_]*",Bw=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Uw=["true","false","null","undefined","NaN","Infinity"],Hw=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Zw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Vw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Ww=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],qw=[].concat(Vw,Hw,Zw);function EO(e){const t=e.regex,n=(H,{after:G})=>{const K="</"+H[0].slice(1);return H.input.indexOf(K,G)!==-1},r=Yu,i={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,G)=>{const K=H[0].length+H.index,V=H.input[K];if(V==="<"||V===","){G.ignoreMatch();return}V===">"&&(n(H,{after:K})||G.ignoreMatch());let Y;const fe=H.input.substring(K);if(Y=fe.match(/^\s*=/)){G.ignoreMatch();return}if((Y=fe.match(/^\s+extends\s+/))&&Y.index===0){G.ignoreMatch();return}}},u={$pattern:Yu,keyword:Bw,literal:Uw,built_in:qw,"variable.language":Ww},d="[0-9](_?[0-9])*",f=`\\.(${d})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${d})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},S={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},k={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},T={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,y,S,k,{match:/\$\d+/},m];g.contains=N.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(N)});const $=[].concat(T,g.contains),D=$.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat($)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:D},F={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},U={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Hw,...Zw]}},M={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},R={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Z(H){return t.concat("(?!",H.join("|"),")")}const E={match:t.concat(/\b/,Z([...Vw,"super","import","await"].map(H=>`${H}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},C={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},I={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},O]},L="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",W={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(L)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:D,CLASS_REFERENCE:U},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),M,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,y,S,k,T,{match:/\$\d+/},m,U,{scope:"attr",match:r+t.lookahead(":"),relevance:0},W,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,e.REGEXP_MODE,{className:"function",begin:L,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:D}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:o},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},P,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},C,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},E,R,F,I,{match:/\$[(.]/}]}}function CO(e){const t=e.regex,n=EO(e),r=Yu,i=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},c={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:i},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},d=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:Yu,keyword:Bw.concat(d),literal:Uw,built_in:qw.concat(i),"variable.language":Ww},p={className:"meta",begin:"@"+r},m=(S,k,w)=>{const T=S.contains.findIndex(N=>N.label===k);if(T===-1)throw new Error("can not find mode to replace");S.contains.splice(T,1,w)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(p);const g=n.contains.find(S=>S.scope==="attr"),v=Object.assign({},g,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,v]),n.contains=n.contains.concat([p,o,c,v]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",u);const y=n.contains.find(S=>S.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function IO(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},o={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},c=e.inherit(o,{begin:/\(/,end:/\)/}),u=e.inherit(e.APOS_STRING_MODE,{className:"string"}),d=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),f={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[o,d,u,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,c,d,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[d]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:f}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function AO(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},o={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},c={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},u=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},v={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},y={begin:/\{/,end:/\}/,contains:[v],illegal:"\\n",relevance:0},S={begin:"\\[",end:"\\]",contains:[v],illegal:"\\n",relevance:0},k=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},g,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,S,o,c],w=[...k];return w.pop(),w.push(u),v.contains=w,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:k}}for(const[e,t]of Object.entries({bash:nO,css:dO,diff:fO,go:hO,java:pO,javascript:yO,json:wO,markdown:NO,python:jO,rust:SO,sql:_O,typescript:CO,xml:IO,yaml:AO}))wr.registerLanguage(e,t);wr.registerAliases(["sh","shell","zsh","console"],{languageName:"bash"});wr.registerAliases(["ts","tsx","mts","cts"],{languageName:"typescript"});wr.registerAliases(["js","jsx","mjs","cjs"],{languageName:"javascript"});wr.registerAliases(["html","svg","vue"],{languageName:"xml"});wr.registerAliases(["py"],{languageName:"python"});wr.registerAliases(["yml"],{languageName:"yaml"});wr.registerAliases(["rs"],{languageName:"rust"});wr.registerAliases(["md"],{languageName:"markdown"});const X0=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");Ct.setOptions({gfm:!0,breaks:!1});Ct.use({renderer:{code({text:e,lang:t}){const n=(t??"").trim().split(/\s+/)[0]??"",i=n!==""&&wr.getLanguage(n)!==void 0?wr.highlight(e,{language:n,ignoreIllegals:!0}).value:X0(e);return`<div class="code-block"><div class="code-head"><span class="code-lang">${X0(n===""?"text":n)}</span><button type="button" class="code-copy" data-copy="">复制</button></div><pre><code class="hljs">${i}</code></pre></div>`}}});function TO(e){let t=e.trim();if(/^file:/i.test(t)){try{t=decodeURIComponent(t.replace(/^file:\/{2,3}/i,""))}catch{return}/^[A-Za-z]:/.test(t)===!1&&/^[^/]+\//.test(t)&&(t=`//${t}`)}const n=/^\/([A-Za-z])\/(.*)$/.exec(t);if(n!==null&&(t=`${n[1].toUpperCase()}:/${n[2]}`),!(!/^[A-Za-z]:[\\/]/.test(t)&&!/^(\\\\|\/\/)[^\\/]/.test(t)))return t.replace(/\//g,"\\").replace(/[#?].*$/,"")}Am.addHook("beforeSanitizeAttributes",e=>{if(e.tagName!=="A")return;const t=TO(e.getAttribute("href")??"");t!==void 0&&(e.removeAttribute("href"),e.setAttribute("data-local-path",t),e.setAttribute("title",t),e.classList.add("local-path"))});Am.addHook("afterSanitizeAttributes",e=>{if(e.tagName==="A"&&/^#\/(p|s|settings)(\/|$)/.test(e.getAttribute("href")??"")){e.classList.add("app-link");return}e.tagName==="A"&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"))});function MO(e){var o;const t=e.dataset.localPath;if(t===void 0)return;const n=c=>{e.dataset.note=c,setTimeout(()=>{delete e.dataset.note},2200)},r=kr();if((r==null?void 0:r.openPath)!==void 0){r.openPath(t).then(c=>n(c==="missing"?"找不到这个文件":c==="revealed"?"已在文件夹中显示":"已打开"),()=>n("打不开"));return}(((o=navigator.clipboard)==null?void 0:o.writeText(t))??Promise.reject(new Error("no clipboard"))).then(()=>n("浏览器里打不开本地文件,路径已复制"),()=>n(Gw(t)?"浏览器里打不开本地文件,路径已复制":t))}function $O(e){var u,d;const t=e.target.closest("a[data-local-path]");if(t!==null){e.preventDefault(),MO(t);return}const n=e.target.closest("button[data-copy]"),r=(u=n==null?void 0:n.closest(".code-block"))==null?void 0:u.querySelector("pre");if(n==null||r==null)return;const i=r.innerText,o=f=>{n.textContent=f?"已复制":"复制失败",n.classList.toggle("copied",f),setTimeout(()=>{n.textContent="复制",n.classList.remove("copied")},1600)};(((d=navigator.clipboard)==null?void 0:d.writeText(i))??Promise.reject(new Error("no clipboard"))).then(()=>o(!0),()=>o(Gw(i)))}function Gw(e){const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch{return!1}finally{t.remove()}}const Ki=b.memo(function({text:t,className:n}){const r=b.useMemo(()=>Am.sanitize(Ct.parse(t,{async:!1})),[t]);return s.jsx("div",{className:`markdown ${n??""}`,onClick:$O,dangerouslySetInnerHTML:{__html:r}})}),Q0="agent_delegate",Kw=b.createContext([]);function yd(e){return`#/h/${encodeURIComponent(e.id)}`}function RO(e){try{const t=JSON.parse(e);return{agent:String(t.agent??""),task:String(t.task??"")}}catch{return{agent:"",task:e}}}function Ca(e,t){const r=fi(e).find(i=>i.name===t||i.id===t);return r===void 0?t===br.name||t===br.id?br:void 0:ac(r)}const wa={running:{label:"进行中",tone:"running"},done:{label:"交回了",tone:"ok"},failed:{label:"没做成",tone:"failed"}};function bd({from:e,to:t,avatar:n,title:r,state:i,href:o}){const c=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`agent-avatar small agent-${(n==null?void 0:n.id)??"unknown"}`,children:s.jsx(ee,{name:(n==null?void 0:n.icon)??"sparkles"})}),s.jsxs("span",{className:"exchange-who",children:[e,s.jsx(ee,{name:"arrow",className:"delegation-arrow"}),s.jsx("strong",{children:t})]}),s.jsx("span",{className:"exchange-title",title:r,children:r}),i!==void 0&&s.jsxs("span",{className:`delegation-state tone-${i.tone}`,children:[i.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),i.label]}),o!==void 0&&s.jsx(ee,{name:"chevron",className:"exchange-open"})]});return o===void 0?s.jsx("div",{className:`exchange-line tone-${(i==null?void 0:i.tone)??""}`,children:c}):s.jsx("a",{className:`exchange-line tone-${(i==null?void 0:i.tone)??""}`,href:o,title:"看它们说了什么",children:c})}function OO({client:e,item:t,handOffs:n}){const{agent:r,task:i}=b.useMemo(()=>RO(t.arguments),[t.arguments]),o=Ca(e,r),c=n.find(f=>f.callId===t.callId),u=t.status==="error"||t.status==="interrupted",d=u?wa.failed:c===void 0?t.status==="running"?wa.running:void 0:wa[c.state];return s.jsxs("div",{className:"delegation",children:[s.jsx(bd,{from:br.name,to:(o==null?void 0:o.name)??r,avatar:o,title:(c==null?void 0:c.title)??i.split(`
|
|
191
|
-
`)[0]??"",state:d,href:c===void 0?void 0:yd(c)}),u&&s.jsxs("div",{className:"delegation-failed",children:[s.jsx(ee,{name:"alert"}),t.result??t.error??"没有交出去"]})]})}function zO({client:e,handOff:t}){const n=Ca(e,t.to);return s.jsx("div",{className:"delegation app-handoff",children:s.jsx(bd,{from:t.by,to:(n==null?void 0:n.name)??t.to,avatar:n,title:t.title,state:wa.running,href:yd(t)})})}function PO({client:e,note:t,handOffs:n}){const r=Ca(e,t.agent),i=n.filter(c=>c.state!=="running"&&c.title===t.title&&(c.to===(r==null?void 0:r.id)||c.to===t.agent)).at(-1),o=i!==void 0?yd(i):r!==void 0?`#/a/${encodeURIComponent(r.id)}`:void 0;return s.jsx("div",{className:"delegation relay-line",children:s.jsx(bd,{from:t.agent,to:br.name,avatar:r,title:t.title,state:t.ok?wa.done:{label:"没有做完",tone:"failed"},href:o})})}function LO({client:e,note:t,handOffs:n}){const[r,i]=b.useState(!1),o=n.filter(d=>d.by===t.by&&d.title===t.title).at(-1),c=Ca(e,t.by),u=Ca(e,(o==null?void 0:o.to)??"");return t.by===Fk?s.jsxs("div",{className:"msg user delegated",children:[s.jsx("div",{className:"msg-from",children:"你在软件里点的"}),s.jsx("div",{className:"bubble",children:s.jsxs("details",{className:"task-note",children:[s.jsx("summary",{children:t.title}),s.jsx("div",{className:"task-note-body",children:t.body})]})})]}):o!==void 0?s.jsx("div",{className:"delegation task-line",children:s.jsx(bd,{from:t.by,to:(u==null?void 0:u.name)??o.to,avatar:c,title:t.title,state:wa[o.state],href:yd(o)})}):s.jsxs("div",{className:"delegation task-line",children:[s.jsxs("button",{className:"exchange-line",onClick:()=>i(d=>!d),"aria-expanded":r,title:r?"收起":"看交给了什么",children:[s.jsx("span",{className:`agent-avatar small agent-${(c==null?void 0:c.id)??"unknown"}`,children:s.jsx(ee,{name:(c==null?void 0:c.icon)??"calendar"})}),s.jsxs("span",{className:"exchange-who",children:[t.by,"交给的事"]}),s.jsx("span",{className:"exchange-title",title:t.title,children:t.title}),s.jsx(ee,{name:r?"chevron-down":"chevron",className:"exchange-open"})]}),r&&s.jsx("div",{className:"exchange-msg-body task-unfolded",children:s.jsx(Ki,{text:t.body})})]})}function DO({client:e,handOff:t,name:n}){const r=Ee(e.sessions).items.find(d=>d.id===t.toSession),i=KM(e,r===void 0?[]:[{id:r.id,updatedAt:r.updatedAt,running:r.running}]),o=r===void 0?void 0:i.get(r.id),c=b.useRef(void 0);c.current===void 0&&o!==void 0&&(c.current=o);const u=o!=null&&o!==""&&o!==c.current?o:void 0;return s.jsxs("div",{className:"delegation-now",children:[s.jsx("span",{className:"tool-spinner",role:"img","aria-label":"进行中"}),s.jsx("span",{children:(r==null?void 0:r.running)===!0?u??`${n} 正在做…`:`排在 ${n} 手上的事后面`})]})}function FO(e,t){const n=Ee(e.connection.status),[r,i]=b.useState({item:null,error:null});return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return e.connection.call("handoffs/get",{id:t}).then(c=>{o&&i({item:c,error:null})},c=>{o&&i({item:null,error:c instanceof Error?c.message:String(c)})}),()=>{o=!1}},[e,t,n.state]),b.useEffect(()=>e.connection.on("handoffs/changed",({item:o})=>{o.id===t&&i({item:o,error:null})}),[e,t]),r}function BO({client:e,id:t,onClose:n}){const{item:r,error:i}=FO(e,t),o=Ca(e,(r==null?void 0:r.by)??""),c=Ca(e,(r==null?void 0:r.to)??"");if(r===null)return s.jsx("section",{className:"main empty",children:i??"正在打开…"});const u=(c==null?void 0:c.name)??r.to,d=wa[r.state];return s.jsxs("section",{className:"main exchange-page",children:[s.jsx("header",{className:"session-header",children:s.jsxs("div",{className:"session-heading",children:[s.jsxs("div",{className:"breadcrumb agent-heading",children:[s.jsx("span",{className:`agent-avatar small agent-${(o==null?void 0:o.id)??"unknown"}`,children:s.jsx(ee,{name:(o==null?void 0:o.icon)??"calendar"})}),s.jsx("span",{children:r.by}),s.jsx(ee,{name:"arrow",className:"delegation-arrow"}),s.jsx("span",{className:`agent-avatar small agent-${(c==null?void 0:c.id)??"unknown"}`,children:s.jsx(ee,{name:(c==null?void 0:c.icon)??"sparkles"})}),s.jsx("h1",{children:u})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx("span",{className:`delegation-state tone-${d.tone}`,children:d.label}),s.jsx("span",{children:r.title}),s.jsx("span",{children:new Date(r.startedAt).toLocaleString()})]})]})}),s.jsx("div",{className:"view",children:s.jsx("div",{className:"chat",children:s.jsxs("div",{className:"chat-inner",children:[s.jsxs(Bh,{who:r.by,agent:o,children:[s.jsx(Ki,{text:r.task}),r.expecting!==void 0&&s.jsxs("div",{className:"delegation-expecting",children:["要交回:",r.expecting]})]}),r.state==="running"?s.jsx(Bh,{who:u,agent:c,children:s.jsx(DO,{client:e,handOff:r,name:u})}):s.jsx(Bh,{who:u,agent:c,failed:r.state==="failed",children:s.jsx(Ki,{text:r.reply??(r.state==="failed"?"没有做完":"它没有留下回复")})})]})})}),s.jsx("footer",{className:"exchange-footer",children:s.jsxs("button",{className:"small-button",onClick:n,children:[s.jsx(ee,{name:"close"}),"关闭"]})})]})}function Bh({who:e,agent:t,failed:n=!1,children:r}){return s.jsxs("div",{className:`exchange-msg ${n?"failed":""}`,children:[s.jsxs("div",{className:"exchange-msg-head",children:[s.jsx("span",{className:`agent-avatar small agent-${(t==null?void 0:t.id)??"unknown"}`,children:s.jsx(ee,{name:(t==null?void 0:t.icon)??"calendar"})}),s.jsx("strong",{children:e})]}),s.jsx("div",{className:"exchange-msg-body",children:r})]})}const UO=["切换到 dsh 官方界面:DeepSeek Harness 自带的原版界面,没有 MultiGameAssistant 的脚本、编排、游戏等功能。","","· 它是另一个独立的 dsh:聊天记录、设置和模型密钥都和这里分开,第一次用要在那边重新填模型密钥;","· 第一次切换要启动它,可能要等一会儿;","· 这边的定时任务和脚本在后台照常运行。","","点标题栏左上角的「返回 MultiGameAssistant」切回来。现在切换吗?"].join(`
|
|
192
|
-
`),Yw="adg.officialIntro";function HO(){var c;const e=(c=kr())==null?void 0:c.uiMode,[t,n]=b.useState(null);if(b.useEffect(()=>{if(e===void 0)return;let u=!0;e.state().then(f=>{u&&n(f)},()=>{});const d=e.onChange(n);return()=>{u=!1,d()}},[e]),e===void 0||t===null)return null;const r=t.mode==="official",i=()=>{if(r){e.set("adg");return}!ZO()&&!window.confirm(UO)||(VO(),e.set("official"))},o=t.starting?"正在启动官方界面…":r?"返回 MultiGameAssistant":"dsh 官方界面";return s.jsxs("div",{className:"ui-switch",children:[s.jsxs("button",{type:"button",className:`ui-switch-button ${r?"active":""}`,disabled:t.starting,onClick:i,title:r?"切回 MultiGameAssistant 的界面":"切换到 DeepSeek Harness 自带的界面(聊天记录分开)",children:[s.jsx(ee,{name:r?"back":"layers"}),s.jsx("span",{children:o})]}),t.error!==void 0&&s.jsxs("span",{className:"ui-switch-error",role:"alert",title:t.error,children:[s.jsx("span",{children:t.error}),s.jsx("button",{type:"button",className:"icon-button","aria-label":"关闭",onClick:()=>void e.set("adg"),children:s.jsx(ee,{name:"close"})})]})]})}function ZO(){try{return localStorage.getItem(Yw)==="1"}catch{return!1}}function VO(){try{localStorage.setItem(Yw,"1")}catch{}}const Uh="games";function WO({client:e}){const[t,n]=b.useState(()=>k0()),r=Ee(e.sessions),i=RM(e),o=Ee(e.connection.status),c=fi(e),u=b.useRef(!1),d=b.useRef(null);b.useEffect(()=>{l$(t,u.current?"replace":"push"),u.current=!1,t.kind!=="handoff"&&t.kind!=="window"&&(d.current=t)},[t]),b.useEffect(()=>{const R=()=>n(k0());return window.addEventListener("hashchange",R),()=>window.removeEventListener("hashchange",R)},[]);const f=b.useRef(new Set);b.useEffect(()=>{for(const E of r.items)f.current.add(E.id);if(t.kind!=="session"||!r.loaded||r.items.some(E=>E.id===t.id))return;const R=()=>{u.current=!0,n(E=>E.kind==="session"&&E.id===t.id?{kind:"home"}:E)};if(f.current.has(t.id)){R();return}const Z=setTimeout(R,8e3);return()=>clearTimeout(Z)},[t,r]),b.useEffect(()=>{t.kind!=="start"||o.state!=="open"||(u.current=!0,n(i.some(R=>R.id===Uh)?{kind:"page",id:Uh}:{kind:"home"}))},[t,o.state,i]);const p=R=>n({kind:"session",id:R}),m=R=>n({kind:"settings",...R===void 0?{}:{section:R}}),g=R=>n({kind:"page",id:R}),v=t.kind==="session"?t.id:null,y=v===null?void 0:r.items.find(R=>R.id===v),S=t.kind==="start"?{kind:"page",id:Uh}:t,k=S.kind==="page"?i.find(R=>R.id===S.id):void 0,w=R=>R.agent===void 0?void 0:c.some(Z=>Z.id===R.agent)?R.agent:xr,T=k===void 0?void 0:w(k),N=R=>n({kind:"agent",id:R}),$=()=>N(xr),D=s.jsx(KO,{client:e,onSettings:()=>m("api-keys")}),O=t.kind==="home"?xr:t.kind==="agent"?t.id:t.kind==="session"?y===void 0?void 0:_a(y,c):T,F=(R,Z)=>n(Z==="chat"?{kind:"agent",id:R}:Z==="schedule"||Z==="history"?{kind:"agent",id:R,tab:Z}:{kind:"page",id:Z});if(t.kind==="window")return s.jsx(_$,{client:e,viewId:t.view,sessionId:t.sessionId});const U=t.kind==="settings"?{kind:"settings"}:t.kind==="schedule"?{kind:"schedule"}:O!==void 0?{kind:"agent",id:O}:S.kind==="page"?{kind:"page",id:S.id}:{kind:"none"},M=k===void 0?null:s.jsx(k.component,{client:e,openSession:p,openSettings:m,openPage:g,arg:S.kind==="page"?S.arg:void 0},k.id),P=O===void 0?null:s.jsx(qO,{client:e,agentId:O,pages:i.filter(R=>w(R)===O),current:t.kind==="agent"&&t.tab!==void 0?t.tab:t.kind==="session"?"history":S.kind==="page"?S.id:"chat",onTab:R=>F(O,R)});return s.jsxs("div",{className:`app ${t.kind==="settings"?"with-sidebar":""}`,children:[s.jsx(s$,{client:e,pages:i.filter(R=>R.agent===void 0),current:U,onAgent:N,onPage:g,onSchedule:()=>n({kind:"schedule"}),onSettings:()=>m()}),t.kind==="settings"&&s.jsx(O$,{client:e,onClose:$,section:t.section,onSection:R=>n({kind:"settings",section:R})}),S.kind==="page"&&T===void 0&&(M??s.jsx("section",{className:"main empty",children:o.state==="open"?"当前连接没有提供这个功能。":"正在连接…"})),O!==void 0&&s.jsxs("div",{className:"agent-area",children:[P,T!==void 0?M:t.kind==="agent"&&t.tab==="schedule"?s.jsx(P$,{client:e,agentId:t.id},t.id):t.kind==="agent"&&t.tab==="history"?s.jsx(n$,{client:e,agentId:t.id,onSelect:p},t.id):t.kind==="session"?s.jsx(Bp,{client:e,sessionId:t.id,onAgent:N,reminder:D},t.id):s.jsx(GO,{client:e,agentId:O,onMain:$,onAgent:N,reminder:D},O)]}),t.kind==="handoff"&&s.jsx(BO,{client:e,id:t.id,onClose:()=>n(d.current??{kind:"agent",id:xr})},t.id),t.kind==="schedule"&&s.jsx(L$,{client:e,onAgent:R=>n({kind:"agent",id:R,tab:"schedule"})}),t.kind==="session"&&O===void 0&&s.jsx(Bp,{client:e,sessionId:t.id,onAgent:N,reminder:D},t.id),s.jsx(ZM,{client:e,sessionId:v,onSelect:p}),s.jsx(HO,{})]})}function qO({client:e,agentId:t,pages:n,current:r,onTab:i}){const o=fi(e),c=Ee(e.capabilities),u=o.find(m=>m.id===t),d=u===void 0?br:ac(u),f=t$(e,t)||r==="history",p=[{id:"chat",title:"对话",icon:"chat"},...c.has("pipelines")?[{id:"schedule",title:"定时",icon:"calendar"}]:[],...[...n].sort((m,g)=>m.order-g.order).map(m=>({id:m.id,title:m.title,icon:m.icon})),...f?[{id:"history",title:"以前的对话",icon:"archive"}]:[]];return p.length===1?null:s.jsx("nav",{className:"agent-tabs",role:"tablist","aria-label":d.name,children:p.map(m=>s.jsxs("button",{role:"tab","aria-selected":m.id===r,className:m.id===r?"active":"",onClick:()=>i(m.id),children:[s.jsx(ee,{name:m.icon}),m.title]},m.id))})}function GO({client:e,agentId:t,onMain:n,onAgent:r,reminder:i}){const{sessionId:o,error:c}=Xk(e,t);return c!==null?s.jsx("section",{className:"main empty",children:s.jsxs("span",{children:[c,s.jsx("button",{className:"link-button",onClick:n,children:"回到助手"})]})}):o===null?s.jsx("section",{className:"main empty",children:"正在打开…"}):s.jsx(Bp,{client:e,sessionId:o,onAgent:r,reminder:i},o)}function KO({client:e,onSettings:t}){var o;const{items:n}=qk(e,[Ep]),{catalog:r}=ic(e),i=(r==null?void 0:r.groups.some(c=>c.id!=="deepseek-official"&&c.models.length>0))??!1;return((o=n==null?void 0:n[Ep])==null?void 0:o.configured)!==!1||i?null:s.jsxs("div",{className:"reminder",children:[s.jsx(ee,{name:"key"}),s.jsx("span",{children:"还没有可用的模型:请填写 DeepSeek API Key,或添加一个自定义 API(Claude、ChatGPT 等)。"}),s.jsx("button",{className:"primary small-button",onClick:t,children:"去设置"})]})}function YO({onSubmit:e}){const[t,n]=b.useState("");return s.jsx("div",{className:"token-prompt",children:s.jsxs("form",{onSubmit:r=>{r.preventDefault(),t.trim()!==""&&e(t.trim())},children:[s.jsx(gd,{size:"lg"}),s.jsxs("div",{className:"token-heading",children:[s.jsx("p",{className:"eyebrow",children:"MULTI GAME ASSISTANT"}),s.jsx("h1",{children:"连接 agent"}),s.jsxs("p",{className:"muted",children:["输入后端启动时打印的连接 token(",s.jsx("code",{children:"adg gateway: …?token="})," 后面的部分)。"]})]}),s.jsx("label",{className:"field-label",htmlFor:"adg-token",children:"连接 Token"}),s.jsx("input",{id:"adg-token",className:"text-input",autoFocus:!0,value:t,onChange:r=>n(r.target.value),placeholder:"粘贴连接 token"}),s.jsx("button",{className:"primary",type:"submit",disabled:t.trim()==="",children:"连接"})]})})}const XO=["准备环境","启动服务","载入界面","连接 agent"],QO=8e3,JO=400;function e2({client:e}){const t=Ee(e.connection.status),n=Ee(e.sessions),[r,i]=b.useState("shown"),[o,c]=b.useState(!1),u=t.state==="open"&&n.loaded;if(b.useEffect(()=>{const p=setTimeout(()=>c(!0),QO);return()=>clearTimeout(p)},[]),b.useEffect(()=>{u&&i(p=>p==="shown"?"leaving":p)},[u]),b.useEffect(()=>{if(r!=="leaving")return;const p=setTimeout(()=>i("gone"),JO);return()=>clearTimeout(p)},[r]),r==="gone")return null;const d=t.state==="open"?"正在读取对话":t.state==="reconnecting"?`连不上 agent,正在重试(第 ${t.attempt} 次)`:t.state==="connecting"?"正在连接 agent":"没有连上 agent",f=o?t.error!==void 0?`连接出错:${t.error}`:"比平时慢一些,agent 服务可能还在启动。":"";return s.jsxs("div",{className:`boot${r==="leaving"?" leaving":""}`,"aria-hidden":r==="leaving",children:[s.jsxs("div",{className:"boot-center",children:[s.jsxs("div",{className:"boot-mark","aria-hidden":"true",children:[s.jsxs("svg",{className:"boot-orbit",viewBox:"0 0 132 132",children:[s.jsx("circle",{className:"track",cx:"66",cy:"66",r:"62"}),s.jsx("circle",{className:"comet",cx:"66",cy:"66",r:"62"})]}),s.jsx("span",{className:"boot-tile",children:s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M9.5 8.3v7.4l6.2-3.7-6.2-3.7Z"}),s.jsx("path",{className:"loop",d:"M4 12a8 8 0 0 1 14.5-4.7M20 12a8 8 0 0 1-14.5 4.7"})]})})]}),s.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),s.jsx("p",{className:"boot-stage",role:"status","aria-live":"polite",children:s.jsx("span",{children:d})}),s.jsx("ol",{className:"boot-steps",children:XO.map((p,m)=>s.jsxs("li",{className:m<3?"done":"now",children:[s.jsx("i",{}),s.jsx("span",{children:p})]},p))}),s.jsx("p",{className:`boot-hint${f!==""?" shown":""}`,children:f}),o&&s.jsx("button",{type:"button",className:"boot-skip",onClick:()=>i("leaving"),children:"先进入界面"})]}),s.jsx("p",{className:"boot-foot",children:"日常交给 agent · 在本机运行"})]})}class t2 extends b.Component{constructor(){super(...arguments);ut(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n instanceof Error?n:new Error(String(n))}}componentDidCatch(n,r){console.error(`界面出错:${n instanceof Error?n.stack??n.message:String(n)}${r.componentStack??""}`)}render(){const{error:n}=this.state;if(n===null)return this.props.children;const r=`${n.message}
|
|
193
|
-
|
|
194
|
-
${(n.stack??"").split(`
|
|
195
|
-
`).slice(1,8).join(`
|
|
196
|
-
`)}`;return s.jsx("div",{className:"boot failed",children:s.jsxs("div",{className:"boot-center",children:[s.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),s.jsx("p",{className:"boot-stage",role:"alert",children:s.jsx("span",{children:"界面出错了"})}),s.jsx("div",{className:"boot-detail",children:s.jsx("pre",{tabIndex:0,children:r})}),s.jsxs("div",{className:"boot-actions",children:[s.jsx("button",{type:"button",className:"primary",onClick:()=>location.reload(),children:"重新载入"}),s.jsx("button",{type:"button",onClick:()=>{var i;return void((i=navigator.clipboard)==null?void 0:i.writeText(r))},children:"复制错误信息"})]})]})})}}function Xw(e){const t=b.useRef(!0),n=b.useRef(0);return{following:t,onScroll:r=>{const i=r.currentTarget,o=i.scrollHeight-i.scrollTop-i.clientHeight,c=i.scrollTop<n.current-1;n.current=i.scrollTop,o<=2?t.current=!0:c?t.current=!1:o<e&&(t.current=!0)},onWheel:r=>{r.deltaY<0&&(t.current=!1)}}}const n2=160;function zl(e,t=n2){var r;const n=((r=e.split(/\r?\n/).find(i=>i.trim()!==""))==null?void 0:r.trim())??"";return n.length>t?`${n.slice(0,t-1)}…`:n}function J0(e,t="text"){return e.filter(n=>n.type===t).map(n=>n.text).join("")}function Il(e){const t=zl(J0(e));if(t!=="")return t;const n=zl(J0(e,"reasoning"));if(n!=="")return n;const r=e.filter(c=>c.type==="tool-call").map(c=>c.name);if(r.length>0)return`→ ${r.join(", ")}`;const i=e.filter(c=>c.type==="image").length,o=e.filter(c=>c.type==="file").length;return[i>0?`${i} image(s)`:"",o>0?`${o} file(s)`:""].filter(Boolean).join(" · ")}function s2(e,t=null,n={}){var O,F,U,M,P,R,Z;const r=[],i=new Map,o=[],c=new Map,u=new Map,d=new Map;let f=null,p=null,m=null,g=0,v=0;const y=(E,C)=>{let I=i.get(E);return I===void 0&&(I=Hh(`t:${E}`,E,C,!0),i.set(E,I),r.push(I)),p=null,I},S=(E,C)=>f!==null?f:(p===null&&(p=Hh(`b:${C}`,null,E,!1),r.push(p)),p),k=(E,C,I,L)=>{let W=E.steps.get(I);return W===void 0&&(W={turn:C,step:I,start:L,startKnown:!1,end:null,records:[],retries:0},E.steps.set(I,W),E.stepOrder.push(I)),W},w=(E,C,I)=>{E.records.push(I),C==null||C.records.push(I),o.push(I)},T=E=>(E.requestIndex??(E.requestIndex=++g),E.requestIndex),N=new Set;for(const E of e)switch(v=Math.max(v,E.time),E.type){case"turn/start":{const C=Hh(`t:${E.turn}`,E.turn,E.time,!1);i.set(E.turn,C),r.push(C),f=C,p=null;break}case"turn/end":{const C=y(E.turn,E.time);C.end=E.time,C.reason=E.reason;for(const I of C.steps.values())I.end??(I.end=E.time);for(const I of c.values())I.turn===E.turn&&I.status==="running"&&(I.status="interrupted",I.end=E.time);f===C&&(f=null);break}case"step/start":{const C=y(E.turn,E.time),I=k(C,E.turn,E.step,E.time);I.start=E.time,I.startKnown=!0;break}case"step/end":{const C=y(E.turn,E.time);k(C,E.turn,E.step,E.time).end=E.time;break}case"user/message":{const C=S(E.time,E.seq);w(C,null,r2(E,C.turn));break}case"system/message":{if(E.text.trim()==="")break;const C=y(E.turn,E.time),I=k(C,E.turn,E.step,E.time),L={kind:"system",id:`system:${E.seq}`,seq:E.seq,turn:E.turn,step:E.step,start:E.time,end:E.time,status:"ok",title:"System prompt",preview:zl(E.text),text:E.text};w(C,I,L);break}case"request/header":{m={...E.provider===void 0?{}:{provider:E.provider},...E.model===void 0?{}:{model:E.model},...E.reasoningEffort===void 0?{}:{reasoningEffort:E.reasoningEffort},toolCount:E.toolNames.length};break}case"assistant/attempt":{const C=y(E.turn,E.time),I=k(C,E.turn,E.step,E.time);Zh(I,E.timing.firstTokenAt),I.retries+=1,E.error!==void 0&&(I.lastRetryError=E.error);const L={kind:"attempt",id:`attempt:${E.seq}`,seq:E.seq,turn:E.turn,step:E.step,start:E.timing.firstChunkAt??I.start,end:E.timing.lastChunkAt??E.time,status:"error",title:"Failed attempt",preview:((O=E.error)==null?void 0:O.message)??"attempt ended without output",...E.error===void 0?{}:{error:E.error}};w(C,I,L);break}case"assistant/message":{const C=y(E.turn,E.time),I=k(C,E.turn,E.step,E.time);Zh(I,E.timing.firstTokenAt),N.add(`${E.turn}:${E.step}`);const L=E.timing.firstTokenAt,W=E.timing.lastChunkAt,H=L!==void 0&&W!==void 0?W-L:void 0,G=E.model??(m==null?void 0:m.model),K=E.provider??(m==null?void 0:m.provider),V={kind:"assistant",id:`assistant:${E.seq}`,seq:E.seq,turn:E.turn,step:E.step,start:I.start,end:W??E.time,status:E.interrupted===!0?"interrupted":"ok",title:G===void 0?"Assistant":`Assistant · ${G}`,preview:Il(E.content),content:E.content,live:!1,interrupted:E.interrupted===!0,request:ty({index:T(I),provider:K,model:G,reasoningEffort:m==null?void 0:m.reasoningEffort,toolCount:m==null?void 0:m.toolCount,ttftMs:ey(I),decodeMs:H,tokensPerSecond:i2((F=E.usage)==null?void 0:F.outputTokens,H),usage:E.usage,retries:I.retries,lastRetryError:I.lastRetryError})};w(C,I,V);break}case"tool/call":{const C=y(E.turn,E.time),I=k(C,E.turn,E.step,E.time),L=d.get(E.callId),W={kind:"tool",id:`tool:${E.callId}`,seq:E.seq,turn:E.turn,step:E.step,start:E.time,end:null,status:C.end===null?"running":"interrupted",title:E.name,preview:zl(E.arguments),name:E.name,callId:E.callId,arguments:E.arguments,isError:!1,...L===void 0?{}:{approval:{approvalId:L}}};c.set(E.callId,W),w(C,I,W);break}case"tool/result":{const C=c.get(E.callId);if(C===void 0){const L=y(E.turn,E.time),W=k(L,E.turn,E.step,E.time),H={kind:"tool",id:`tool:${E.callId}`,seq:E.seq,turn:E.turn,step:E.step,start:E.time,end:E.time,status:E.isError?"error":"ok",title:"tool result",preview:Il(E.content),name:"tool result",callId:E.callId,arguments:"",result:E.content,isError:E.isError,...E.error===void 0?{}:{error:E.error}};w(L,W,H);break}C.end=E.time,C.result=E.content,C.isError=E.isError,C.status=E.isError?"error":"ok",E.error!==void 0&&(C.error=E.error);const I=Il(E.content);I!==""&&(C.preview=`${zl(C.arguments,80)} ⇒ ${I}`);break}case"approval/asked":{if(E.callId===void 0)break;d.set(E.callId,E.approvalId);const C=c.get(E.callId);C!==void 0&&(C.approval={approvalId:E.approvalId,...E.reason===void 0?{}:{reason:E.reason}});break}case"approval/decided":{for(const C of c.values())((U=C.approval)==null?void 0:U.approvalId)===E.approvalId&&(C.approval={...C.approval,outcome:E.outcome});break}case"compaction/start":{const C=E.turn===null?S(E.time,E.seq):y(E.turn,E.time),I={kind:"compaction",id:`compaction:${E.compactionId}`,seq:E.seq,turn:C.turn,step:null,start:E.time,end:null,status:"running",title:"Compaction",preview:"summarizing history…",compactionId:E.compactionId};u.set(E.compactionId,I),w(C,null,I);break}case"compaction/summary":{const C=u.get(E.compactionId);if(C===void 0)break;C.shadowedTokenCount=E.shadowedTokenCount,E.usage!==void 0&&(C.usage=E.usage),C.preview=`${E.shadowedTokenCount.toLocaleString("en-US")} tokens summarized`;break}case"compaction/end":{const C=u.get(E.compactionId);if(C===void 0)break;C.end=E.time,C.status=E.error===void 0?"ok":"error",E.error!==void 0&&(C.error=E.error,C.preview=E.error);break}}if(t!==null&&!N.has(`${t.turn}:${t.step}`)){const E=y(t.turn,((M=t.deltas[0])==null?void 0:M.time)??n.now??v),C=k(E,t.turn,t.step,((P=t.deltas[0])==null?void 0:P.time)??n.now??v),I=(R=t.deltas.find(G=>G.text!==""||G.toolName!==void 0))==null?void 0:R.time;Zh(C,I);const L=a2(t.deltas),W=(Z=t.deltas.at(-1))==null?void 0:Z.time;W!==void 0&&(v=Math.max(v,W));const H={kind:"assistant",id:`live:${t.attemptId}`,seq:t.afterSeq,turn:t.turn,step:t.step,start:C.start,end:null,status:"running",title:(m==null?void 0:m.model)===void 0?"Assistant":`Assistant · ${m.model}`,preview:Il(L)||"waiting for output…",content:L,live:!0,interrupted:!1,request:ty({index:T(C),provider:m==null?void 0:m.provider,model:m==null?void 0:m.model,reasoningEffort:m==null?void 0:m.reasoningEffort,toolCount:m==null?void 0:m.toolCount,ttftMs:ey(C),retries:C.retries,lastRetryError:C.lastRetryError})};w(E,C,H)}const $=r.map(E=>({key:E.key,turn:E.turn,start:E.start,end:E.end,partialStart:E.partialStart,...E.reason===void 0?{}:{reason:E.reason},steps:E.stepOrder.map(C=>{const I=E.steps.get(C);return{turn:I.turn,step:I.step,start:I.start,end:I.end,records:I.records}}),records:E.records})),D=n.now??v;return{groups:$,records:o,totals:o2(o),span:l2(o,D)}}function Hh(e,t,n,r){return{key:e,turn:t,start:n,end:null,partialStart:r,steps:new Map,stepOrder:[],records:[]}}function r2(e,t){const n=e.origin.human,r=n?"user":"context",i=e.content.filter(u=>u.type==="image").length,o=e.content.filter(u=>u.type==="file").length,c=n?"User":e.replacesHistory===!0?"Compacted history":`Context · ${e.origin.kind}`;return{kind:r,id:`user:${e.seq}`,seq:e.seq,turn:t,step:null,start:e.time,end:e.time,status:"ok",title:c,preview:e.origin.summary??Il(e.content),content:e.content,origin:e.origin,imageCount:i,fileCount:o}}function Zh(e,t){t!==void 0&&(e.firstTokenAt===void 0||t<e.firstTokenAt)&&(e.firstTokenAt=t)}function ey(e){if(!e.startKnown||e.firstTokenAt===void 0)return;const t=e.firstTokenAt-e.start;return t>=0?t:void 0}function i2(e,t){if(!(e===void 0||t===void 0||t<=0))return e/(t/1e3)}function a2(e){const t=new Map;for(const n of e){const r=t.get(n.index);if(n.kind==="tool-args"){const i=(r==null?void 0:r.type)==="tool-call"?r:void 0;t.set(n.index,{type:"tool-call",callId:n.callId??(i==null?void 0:i.callId)??"",name:n.toolName??(i==null?void 0:i.name)??"",arguments:((i==null?void 0:i.arguments)??"")+n.text})}else{const i=n.kind==="text"?"text":"reasoning",o=(r==null?void 0:r.type)===i?r.text:"";t.set(n.index,{type:i,text:o+n.text})}}return[...t.entries()].sort((n,r)=>n[0]-r[0]).map(([,n])=>n)}function o2(e){const t={requests:0,toolCalls:0,errors:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,reasoningTokens:0};for(const n of e){n.status==="error"&&(t.errors+=1),n.kind==="tool"&&(t.toolCalls+=1);const r=n.kind==="assistant"?n.request.usage:n.kind==="compaction"?n.usage:void 0;n.kind==="assistant"&&(t.requests+=1),r!==void 0&&(t.inputTokens+=r.inputTokens,t.outputTokens+=r.outputTokens,t.cacheReadTokens+=r.cacheReadTokens??0,t.cacheWriteTokens+=r.cacheWriteTokens??0,t.reasoningTokens+=r.reasoningTokens??0)}return t}function l2(e,t){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const i of e)n=Math.min(n,i.start),r=Math.max(r,i.end??Math.max(i.start,t));return Number.isFinite(n)?{start:n,end:Math.max(n,r)}:null}function ty(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const Qw=[{id:"input",kinds:["user","context","system"],label:"Input"},{id:"model",kinds:["assistant","attempt"],label:"Model"},{id:"tool",kinds:["tool"],label:"Tools"},{id:"compaction",kinds:["compaction"],label:"Compaction"}],c2=new Map(Qw.flatMap((e,t)=>e.kinds.map(n=>[n,t])));function u2(e){return e.records.map(t=>{const n=t.end===null||t.end<=t.start,r={record:t,lane:c2.get(t.kind)??0,start:t.start,end:t.end===null?t.start:Math.max(t.start,t.end),instant:n};return t.kind==="assistant"&&t.request.ttftMs!==void 0&&t.end!==null?{...r,firstTokenAt:t.start+t.request.ttftMs}:r})}function d2(e,t){const n=e.end??e.start;return e.start<=t.end&&n>=t.start}function f2(e,t,n,r){const o=Math.max(10,(e.end-e.start)*n),c=e.end===e.start?.5:(t-e.start)/(e.end-e.start);let u=t-o*c,d=u+o;return d-u>=r.end-r.start?r:(u<r.start&&(d+=r.start-u,u=r.start),d>r.end&&(u-=d-r.end,d=r.end),{start:u,end:d})}function h2(e,t,n){const r=e.end-e.start,i=Math.min(Math.max(n.start,e.start+t),n.end-r);return{start:i,end:i+r}}function p2(e,t){const n=t.trim().toLowerCase();return n===""?e:e.filter(r=>r.title.toLowerCase().includes(n)||r.preview.toLowerCase().includes(n)?!0:r.kind==="tool"?r.arguments.toLowerCase().includes(n):!1)}function Ts(e){if(e==null||!Number.isFinite(e))return"—";if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?2:1)} s`;const n=Math.floor(t/60);return n<60?`${n}m ${String(Math.floor(t%60)).padStart(2,"0")}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,"0")}m`}function vn(e){return e==null?"—":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(e<1e4?2:1)}k`:`${(e/1e6).toFixed(2)}M`}function Ui(e){const t=new Date(e),n=(r,i=2)=>String(r).padStart(i,"0");return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}.${n(t.getMilliseconds(),3)}`}function Fm(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}var Bm=Rb();const ny=["#ff3b30","#ffcc00","#34c759","#0a84ff","#000000","#ffffff"],m2=[["rect","框"],["arrow","箭头"],["line","直线"],["pen","画笔"]],sy=[[2,"细"],[4,"中"],[7,"粗"]],g2=.05,ry=16,iy=44;function Jw({src:e,width:t,height:n,name:r,onClose:i}){const[o,c]=b.useState({src:e,width:t,height:n}),{src:u,width:d,height:f}=o,p=b.useRef(null),m=b.useRef(null),[g,v]=b.useState(()=>x2(t,n)),[y,S]=b.useState({scale:1,x:0,y:0}),[k,w]=b.useState(!1),[T,N]=b.useState("rect"),[$,D]=b.useState(ny[0]),[O,F]=b.useState(sy[0][0]),[U,M]=b.useState([]),[P,R]=b.useState(null),[Z,E]=b.useState(!0),[C,I]=b.useState(null),L=b.useRef(null),W=b.useRef(null),H=b.useCallback(()=>{var ze;const re=(ze=p.current)==null?void 0:ze.getBoundingClientRect();if(re===void 0||re.width===0)return;const he=Math.min(ry,(re.width-24)/d,(re.height-24)/f);S({scale:he,x:(re.width-d*he)/2,y:(re.height-f*he)/2})},[d,f]);b.useLayoutEffect(H,[H]),b.useEffect(()=>{const re=p.current;if(re===null||typeof ResizeObserver>"u")return;const he=new ResizeObserver(()=>H());return he.observe(re),()=>he.disconnect()},[H]);const G=(re,he,ze)=>{var tt;const Te=(tt=p.current)==null?void 0:tt.getBoundingClientRect();if(Te===void 0)return;const Ge=he??Te.width/2,Ie=ze??Te.height/2;S(et=>{const jt=Math.min(ry,Math.max(g2,et.scale*re)),On=jt/et.scale;return{scale:jt,x:Ge-(Ge-et.x)*On,y:Ie-(Ie-et.y)*On}})},K=()=>{var he;const re=(he=p.current)==null?void 0:he.getBoundingClientRect();re!==void 0&&S({scale:1,x:(re.width-d)/2,y:(re.height-f)/2})};b.useEffect(()=>{const re=p.current;if(re===null)return;const he=ze=>{ze.preventDefault();const Te=re.getBoundingClientRect();G(Math.exp(-ze.deltaY*.0015),ze.clientX-Te.left,ze.clientY-Te.top)};return re.addEventListener("wheel",he,{passive:!1}),()=>re.removeEventListener("wheel",he)});const V=re=>{I(re),setTimeout(()=>I(he=>he===re?null:he),1800)},Y=b.useCallback(async(re,he=0)=>{const ze=new Image;ze.src=u,await ze.decode();const Te=document.createElement("canvas");Te.width=d,Te.height=f;const Ge=Te.getContext("2d");Ge.drawImage(ze,0,0,d,f);for(const et of re)b2(Ge,et);if(he===0)return Te;const Ie=document.createElement("canvas");Ie.width=f,Ie.height=d;const tt=Ie.getContext("2d");return tt.translate(f/2,d/2),tt.rotate(he),tt.drawImage(Te,-d/2,-f/2),Ie},[u,d,f]),fe=b.useCallback(async re=>{try{const he=await Y(re),ze=await new Promise((Te,Ge)=>he.toBlob(Ie=>Ie===null?Ge(new Error("没能生成图片")):Te(Ie),"image/png"));try{await navigator.clipboard.write([new ClipboardItem({"image/png":ze})])}catch(Te){const Ge=kr();if((Ge==null?void 0:Ge.copyImage)===void 0)throw Te;await Ge.copyImage(he.toDataURL("image/png"))}V(re.length>0?"已复制(带标注)":"已复制")}catch(he){V(`复制失败:${he instanceof Error?he.message:String(he)}`)}},[Y]),xe=async()=>{const re=await Y(U),he=document.createElement("a");he.href=re.toDataURL("image/png"),he.download=`${r.replace(/[\\/:*?"<>|]/g,"_").replace(/\.\w+$/,"")}${U.length>0?"-标注":""}.png`,he.click()},me=async()=>{const re=await Y(U,Math.PI/2);M([]),c({src:re.toDataURL("image/png"),width:re.width,height:re.height})},ie=()=>M(re=>re.slice(0,-1));b.useEffect(()=>{const re=he=>{if(!(m.current===null||!m.current.contains(document.activeElement))){if(he.key==="Escape"){P!==null?(R(null),L.current=null):k?w(!1):i();return}if((he.ctrlKey||he.metaKey)&&he.key.toLowerCase()==="z"){he.preventDefault(),ie();return}if((he.ctrlKey||he.metaKey)&&he.key.toLowerCase()==="c"){he.preventDefault(),fe(U);return}he.key==="0"&&H(),(he.key==="+"||he.key==="=")&&G(1.25),he.key==="-"&&G(.8)}};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)});const ke=re=>{const he=p.current.getBoundingClientRect(),ze=(re.clientX-he.left-y.x)/y.scale,Te=(re.clientY-he.top-y.y)/y.scale;return[Math.max(0,Math.min(d,ze)),Math.max(0,Math.min(f,Te))]},ae=re=>{if(re.button!==0&&re.button!==1)return;if(re.currentTarget.setPointerCapture(re.pointerId),!k||re.button===1){L.current={kind:"pan",sx:re.clientX,sy:re.clientY,ox:y.x,oy:y.y};return}const[he,ze]=ke(re),Te=O/y.scale;L.current={kind:"mark"},R(T==="pen"?{kind:"pen",points:[[he,ze]],color:$,width:Te}:{kind:T,x1:he,y1:ze,x2:he,y2:ze,color:$,width:Te})},Ne=re=>{const he=L.current;if(he===null)return;if(he.kind==="pan"){S(Ge=>({...Ge,x:he.ox+re.clientX-he.sx,y:he.oy+re.clientY-he.sy}));return}const[ze,Te]=ke(re);R(Ge=>Ge===null?Ge:Ge.kind==="pen"?{...Ge,points:[...Ge.points,[ze,Te]]}:{...Ge,x2:ze,y2:Te})},Fe=()=>{const re=L.current;if(L.current=null,(re==null?void 0:re.kind)!=="mark"||P===null||(R(null),(P.kind==="pen"?P.points.length>2?99:0:Math.hypot(P.x2-P.x1,P.y2-P.y1)*y.scale)<4))return;const ze=[...U,P];M(ze),Z&&fe(ze)},ce=re=>{if(re.target.closest("button")!==null)return;re.currentTarget.setPointerCapture(re.pointerId),W.current={sx:re.clientX,sy:re.clientY,ox:g.x,oy:g.y};const he=m.current;he!==null&&v(ze=>({...ze,w:he.offsetWidth,h:he.offsetHeight}))},je=re=>{const he=W.current;he!==null&&v(ze=>({...ze,x:Math.max(-ze.w+120,Math.min(window.innerWidth-120,he.ox+re.clientX-he.sx)),y:Math.max(0,Math.min(window.innerHeight-40,he.oy+re.clientY-he.sy))}))};return b.useEffect(()=>{var re;(re=m.current)==null||re.focus()},[]),Bm.createPortal(s.jsxs("div",{ref:m,className:"image-viewer",role:"dialog","aria-label":r,tabIndex:-1,style:{left:g.x,top:g.y,width:g.w,height:g.h},children:[s.jsxs("div",{className:"viewer-title",onPointerDown:ce,onPointerMove:je,onPointerUp:()=>{W.current=null},onDoubleClick:H,children:[s.jsx("span",{className:"viewer-name",children:r}),s.jsxs("span",{className:"viewer-dim",children:[d,"×",f]}),s.jsx("button",{className:"viewer-icon",onClick:i,title:"关闭(Esc)","aria-label":"关闭",children:"✕"})]}),s.jsxs("div",{ref:p,className:`viewer-stage ${k?"marking":""}`,onPointerDown:ae,onPointerMove:Ne,onPointerUp:Fe,onPointerCancel:Fe,children:[s.jsxs("div",{className:"viewer-canvas",style:{width:d,height:f,transform:`translate(${y.x}px, ${y.y}px) scale(${y.scale})`},children:[s.jsx("img",{src:u,alt:r,width:d,height:f,draggable:!1}),s.jsx("svg",{viewBox:`0 0 ${d} ${f}`,width:d,height:f,"aria-hidden":"true",children:[...U,...P===null?[]:[P]].map((re,he)=>s.jsx(y2,{mark:re},he))})]}),C!==null&&s.jsx("div",{className:"viewer-toast",role:"status",children:C})]}),k&&s.jsxs("div",{className:"viewer-marks",children:[s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"标注工具",children:m2.map(([re,he])=>s.jsx("button",{role:"radio","aria-checked":T===re,className:`viewer-icon ${T===re?"active":""}`,title:he,onClick:()=>N(re),children:s.jsx(v2,{tool:re})},re))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"粗细",children:sy.map(([re,he])=>s.jsx("button",{role:"radio","aria-checked":O===re,className:`viewer-icon ${O===re?"active":""}`,title:he,onClick:()=>F(re),children:s.jsx("span",{className:"width-dot",style:{width:re+3,height:re+3}})},re))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"颜色",children:ny.map(re=>s.jsx("button",{role:"radio","aria-checked":$===re,"aria-label":re,className:`swatch ${$===re?"active":""}`,style:{background:re},onClick:()=>D(re)},re))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("button",{className:"viewer-icon",disabled:U.length===0,onClick:ie,title:"撤销(Ctrl+Z)",children:"↶"}),s.jsxs("label",{className:"viewer-check",title:"每画完一笔就把带标注的图片复制到剪贴板",children:[s.jsx("input",{type:"checkbox",checked:Z,onChange:re=>E(re.target.checked)}),"自动复制"]})]}),s.jsxs("div",{className:"viewer-bar",children:[s.jsx("button",{className:"viewer-icon",onClick:()=>G(.8),title:"缩小",children:"-"}),s.jsxs("button",{className:"viewer-zoom",onClick:H,title:"适应窗口(0)",children:[Math.round(y.scale*100),"%"]}),s.jsx("button",{className:"viewer-icon",onClick:()=>G(1.25),title:"放大",children:"+"}),s.jsx("button",{className:"viewer-icon",onClick:K,title:"原始大小",children:"1:1"}),s.jsx("span",{className:"viewer-sep"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void me(),title:"旋转",children:"⟳"}),s.jsx("button",{className:`viewer-icon ${k?"active":""}`,onClick:()=>w(re=>!re),title:"标注:画框、箭头、直线",children:"✎"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void fe(U),title:"复制(Ctrl+C)",children:"⧉"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void xe(),title:"保存",children:"⤓"})]})]}),document.body)}function x2(e,t){const n=Math.round(window.innerWidth*.7),r=Math.round(window.innerHeight*.78)-iy*2,i=Math.min(1,n/e,r/t),o=Math.max(420,Math.round(e*i)+24),c=Math.max(300,Math.round(t*i)+24+iy*2);return{x:Math.round((window.innerWidth-o)/2),y:Math.max(16,Math.round((window.innerHeight-c)/2)),w:o,h:c}}function v2({tool:e}){const t={rect:"M5 6h14v12H5z",arrow:"M5 19 19 5M10 5h9v9",line:"M5 19 19 5",pen:"M4 20c3-1 4-5 7-8s6-6 9-8"}[e];return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:t})})}function eN(e){const t=Math.atan2(e.y2-e.y1,e.x2-e.x1),n=e.width*4.5;return[-.5,.5].map(r=>[e.x2-n*Math.cos(t+r),e.y2-n*Math.sin(t+r)])}function y2({mark:e}){const t={stroke:e.color,strokeWidth:e.width,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};if(e.kind==="pen")return s.jsx("polyline",{...t,points:e.points.map(r=>r.join(",")).join(" ")});if(e.kind==="rect")return s.jsx("rect",{...t,x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)});const n=e.kind==="arrow"?eN(e):[];return s.jsxs("g",{...t,children:[s.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}),n.length>0&&s.jsx("polyline",{points:`${n[0][0]},${n[0][1]} ${e.x2},${e.y2} ${n[1][0]},${n[1][1]}`})]})}function b2(e,t){if(e.strokeStyle=t.color,e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round",e.beginPath(),t.kind==="pen")t.points.forEach(([n,r],i)=>i===0?e.moveTo(n,r):e.lineTo(n,r));else if(t.kind==="rect")e.rect(Math.min(t.x1,t.x2),Math.min(t.y1,t.y2),Math.abs(t.x2-t.x1),Math.abs(t.y2-t.y1));else if(e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),t.kind==="arrow"){const[n,r]=eN(t);e.moveTo(n[0],n[1]),e.lineTo(t.x2,t.y2),e.lineTo(r[0],r[1])}e.stroke()}const Um=b.createContext(null),Vh=new Map;function k2(e,t){let n=Vh.get(t.attachmentId);if(n===void 0){const{attachmentId:r,mediaType:i,bytes:o,width:c,height:u}=t;n=e.connection.call("attachments/image",{attachmentId:r,mediaType:i,bytes:o,width:c,height:u}).then(d=>`data:${d.mediaType};base64,${d.data}`),n.catch(()=>Vh.delete(t.attachmentId)),Vh.set(t.attachmentId,n)}return n}function tN({image:e}){const t=b.useContext(Um),[n,r]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(!1),d=(t==null?void 0:t.capabilities.get().has("attachments"))===!0;b.useEffect(()=>{if(t===null||!d)return;let p=!0;return k2(t,e).then(m=>{p&&r(m)},m=>{p&&o(m instanceof Error?m.message:String(m))}),()=>{p=!1}},[t,d,e]);const f=e.name??`${e.width}×${e.height} 图片`;return d?i!==null?s.jsxs("span",{className:"stored-image missing",children:[f,"没能加载:",i]}):n===null?s.jsx("span",{className:"stored-image loading",style:{aspectRatio:`${e.width} / ${e.height}`}}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"stored-image",onClick:()=>u(!0),title:"点击放大、标注、复制",children:s.jsx("img",{src:n,alt:f,width:e.width,height:e.height})}),c&&s.jsx(Jw,{src:n,width:e.width,height:e.height,name:e.name??"screenshot.png",onClose:()=>u(!1)})]}):s.jsxs("span",{className:"stored-image missing",children:[f,"(当前后端不支持显示图片)"]})}const w2=3,N2=/^(编排|游戏信息|干预)[::]/,ay="adg:skill-offer:off",oy=e=>`adg:skill-offer:${e}`;function ly(e){try{return localStorage.getItem(e)}catch{return null}}function cy(e,t){try{localStorage.setItem(e,t)}catch{}}function j2(e){var i;let t=e.length-1;for(;t>=0&&e[t].kind!=="user";)t--;if(t<0)return;const n=e.slice(t+1),r=n.filter(o=>o.kind==="tool");if(!r.some(o=>o.name==="skill"||o.name==="skill_save"||o.status!=="ok")&&!n.some(o=>o.kind==="notice"&&o.tone==="error")&&!n.some(o=>o.kind==="context")&&!(r.length<w2||((i=n.at(-1))==null?void 0:i.kind)!=="assistant"))return e[t].id}function S2({session:e,title:t,items:n}){const r=j2(n),[i,o]=b.useState(()=>ly(ay)==="1"),[c,u]=b.useState(()=>ly(oy(e.id))),[d,f]=b.useState(!1);if(r===void 0||i||c===r||t!==null&&N2.test(t))return null;const p=()=>{cy(oy(e.id),r),u(r)},m=async()=>{f(!0);try{await e.prompt(Dk),p()}finally{f(!1)}};return s.jsxs("div",{className:"skill-offer",role:"region","aria-label":"存成技能",children:[s.jsx(ee,{name:"sparkles"}),s.jsxs("div",{className:"skill-offer-text",children:[s.jsx("strong",{children:"要把这次的做法存成技能吗?"}),s.jsx("span",{children:"agent 会把刚才走通的步骤浓缩成一份技能;下次做同样的事直接照着做,不用重新摸索,少调用模型。"})]}),s.jsxs("div",{className:"skill-offer-actions",children:[s.jsx("button",{className:"link-button small",onClick:()=>{cy(ay,"1"),o(!0)},children:"不再提示"}),s.jsx("button",{className:"small-button",disabled:d,onClick:p,children:"这次不用"}),s.jsx("button",{className:"small-button primary",disabled:d,onClick:()=>void m(),children:"存成技能"})]})]})}function _2(e,t){const n=Ee(e.connection.status),r=Ee(e.capabilities),[i,o]=b.useState([]),c=t&&r.has("notify");return b.useEffect(()=>{if(!c||n.state!=="open")return;let u=!0;return e.connection.call("notify/notices",{}).then(d=>{u&&o(d.items)}).catch(()=>{}),()=>{u=!1}},[e,c,n.state]),b.useEffect(()=>{if(c)return e.connection.on("notify/notice",({item:u})=>o(d=>d.findIndex(p=>p.id===u.id)<0?[...d,u]:d.map(p=>p.id===u.id?u:p)))},[e,c]),c?i:[]}function E2(e,t,n,r){const i=t.filter(f=>f.at>=n);if(i.length===0)return[...e];const o=new Array(e.length);let c=1/0;for(let f=e.length-1;f>=0;f--){const p=e[f];"time"in p&&typeof p.time=="number"&&(c=p.time),o[f]=c}const u=[];let d=0;for(e.forEach((f,p)=>{if(r(f))for(;d<i.length&&i[d].at<o[p];)u.push(uy(i[d++]));u.push(f)});d<i.length;)u.push(uy(i[d++]));return u}function uy(e){return{kind:"sent",id:`sent:${e.id}`,notice:e}}const C2={info:"send",success:"check",warning:"alert",error:"alert"};function I2({client:e,notice:t}){const[n,r]=b.useState(null),[i,o]=b.useState(null),c=t.acted===void 0&&t.done===void 0&&t.actions.length>0,u=f=>{r(f),o(null),e.connection.call("notify/act",{noticeId:t.id,actionId:f}).catch(p=>o(Pe(p))).finally(()=>r(null))},d=new Date(t.at).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});return s.jsxs("div",{className:`sent-notice ${t.severity}`,children:[s.jsxs("div",{className:"sent-notice-head",children:[s.jsx(ee,{name:C2[t.severity]}),s.jsx("span",{className:"sent-notice-title",children:t.title}),s.jsx("span",{className:"spacer"}),s.jsxs("span",{className:"muted small",children:[t.channels.length>0?`发到${t.channels.join("、")}`:"只在软件里"," · ",d]})]}),s.jsx("div",{className:"sent-notice-text",children:t.text}),t.image===!0&&s.jsx("div",{className:"muted small",children:"(附了一张截图,在聊天软件里看)"}),c&&s.jsxs("div",{className:"sent-notice-actions",children:[t.actions.map(f=>s.jsx("button",{className:`small-button ${f.style==="primary"?"primary":f.style==="danger"?"danger-outline":""}`,disabled:n!==null,onClick:()=>u(f.id),children:n===f.id?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),f.label]}):f.label},f.id)),s.jsx("span",{className:"muted small",children:"也可以直接跟助手说"})]}),t.acted!==void 0&&s.jsxs("div",{className:"sent-notice-result",children:[s.jsx(ee,{name:"check"}),t.acted.by,"选了「",t.acted.label,"」——",t.acted.result]}),t.acted===void 0&&t.done!==void 0&&s.jsxs("div",{className:"sent-notice-result",children:[s.jsx(ee,{name:"check"}),t.done]}),i!==null&&s.jsx("div",{className:"error small",children:i})]})}const A2=80;function T2({client:e,session:t,state:n}){var N,$,D;const r=b.useMemo(()=>_M(n.events,n.live,n.pending),[n.events,n.live,n.pending,n.version]),i=Xk(e,xr),o=_2(e,i.sessionId===t.id),c=n.hasMore?((N=n.events[0])==null?void 0:N.time)??0:0,u=b.useMemo(()=>M2(E2(r,o,c,nN)),[r,o,c]),d=fi(e),f=Ee(e.sessions).items.find(O=>O.id===t.id),p=(($=d.find(O=>O.id===(f===void 0?void 0:_a(f,d))))==null?void 0:$.name)??br.name,m=QM(e,t.id),g=m.filter(O=>O.fromSession===t.id&&O.callId===void 0&&O.state==="running"),v=b.useRef(null),y=Xw(A2),S=y.following,k=O=>{y.onScroll(O),O.currentTarget.scrollTop<40&&n.hasMore&&!n.loadingOlder&&t.loadOlder()};b.useLayoutEffect(()=>{const O=v.current;O!==null&&S.current&&(O.scrollTop=O.scrollHeight)},[r,o]);const w=(D=n.events[0])==null?void 0:D.seq,T=b.useRef(0);return b.useLayoutEffect(()=>{const O=v.current;O!==null&&(T.current!==0&&!S.current&&(O.scrollTop+=O.scrollHeight-T.current),T.current=O.scrollHeight)},[w]),s.jsx(Um.Provider,{value:e,children:s.jsx(Kw.Provider,{value:m,children:s.jsx("div",{className:"chat",ref:v,onScroll:k,onWheel:y.onWheel,children:s.jsxs("div",{className:"chat-inner",children:[n.hasMore&&s.jsx("button",{className:"link-button load-older",disabled:n.loadingOlder,onClick:()=>void t.loadOlder(),children:n.loadingOlder?"加载中…":"加载更早的消息"}),n.status==="opening"&&r.length===0&&s.jsx("div",{className:"empty",children:"正在打开会话…"}),n.status!=="opening"&&r.length===0&&s.jsxs("div",{className:"empty chat-empty",children:[s.jsx(gd,{size:"lg"}),s.jsx("h2",{children:"今天,我们一起完成什么?"}),s.jsxs("p",{children:["一个问题、一段代码,或一个还不成熟的想法。",s.jsx("br",{}),"在下方写下来,让对话开始。"]})]}),u.map((O,F)=>O.kind==="sent"?s.jsx(I2,{client:e,notice:O.item.notice},O.item.id):O.kind==="tools"?s.jsx(bu,{name:p,header:O.header,children:s.jsx(rN,{tools:O.tools})},O.id):O.kind==="delegation"?s.jsx(bu,{name:p,header:O.header,children:s.jsx(OO,{client:e,item:O.item,handOffs:m})},O.item.id):O.kind==="process"?s.jsx(bu,{name:p,header:O.header,children:s.jsx(L2,{items:O.items,active:n.running&&F===u.length-1,onDismiss:U=>t.dismissPending(U)})},O.id):s.jsx(bu,{name:p,header:O.header,children:s.jsx(sN,{item:O.item,onDismiss:U=>t.dismissPending(U)})},O.item.id)),g.map(O=>s.jsx(zO,{client:e,handOff:O},O.id)),n.running&&n.live===null&&s.jsxs("div",{className:"thinking",children:[s.jsxs("span",{className:"dot-pulse",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}),"正在处理…"]}),!n.running&&n.queue.length===0&&s.jsx(S2,{session:t,title:n.title,items:r})]})})})})}function M2(e){const t=[];let n=0;for(let r=0;r<=e.length;r++){const i=e[r];i!==void 0&&i.kind!=="sent"&&!nN(i)||($2(e.slice(n,r),t),i!==void 0&&t.push(i.kind==="sent"?{kind:"sent",item:i}:{kind:"item",item:i,header:null}),n=r+1)}return t}function nN(e){return e.kind==="user"||e.kind==="context"&&e.startsTurn===!0}function $2(e,t){let n=!1;const r=e.find(f=>f.kind==="assistant"&&f.model!==void 0),i=()=>n?null:(n=!0,{model:(r==null?void 0:r.kind)==="assistant"?r.model:void 0}),o=f=>{if(f.kind==="tool"&&f.name===Q0)t.push({kind:"delegation",item:f,header:i()});else if(f.kind==="tool"){const p=t.at(-1);(p==null?void 0:p.kind)==="tools"?t[t.length-1]={...p,tools:[...p.tools,f]}:t.push({kind:"tools",id:`tools-${f.id}`,tools:[f],header:i()})}else t.push({kind:"item",item:f,header:f.kind==="assistant"?i():null})};let c=[];const u=()=>{if(c.some(f=>f.kind==="tool"))t.push({kind:"process",id:`process-${c[0].id}`,items:c,header:i()});else for(const f of c)o(f);c=[]};let d=e.length;for(let f=e.length-1;f>=0;f--){const p=e[f];if(p.kind==="assistant"&&p.text.trim()!==""){d=f;break}}for(let f=0;f<d;f++){const p=e[f];p.kind==="notice"||p.kind==="context"||p.kind==="tool"&&(p.approval==="asked"||p.name===Q0)?(u(),o(p)):c.push(p)}u();for(let f=d;f<e.length;f++)o(e[f])}function bu({name:e,header:t,children:n}){return t===null?s.jsx(s.Fragment,{children:n}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"turn-header",children:[s.jsx(gd,{size:"sm"}),s.jsx("span",{className:"turn-name",children:e}),t.model!==void 0&&s.jsx("span",{className:"turn-model",children:t.model})]}),n]})}function R2({text:e}){const t=lM(e);return t===void 0?s.jsx(s.Fragment,{children:e}):s.jsxs(s.Fragment,{children:[t.typed,s.jsxs("details",{className:"slash-expansion",children:[s.jsx("summary",{children:"发给 agent 的完整指令"}),t.expansion]})]})}const O2=/^(这条消息来自([^。)]+)。[^\n]*)\n/,z2=/^(距离这个对话的上一条消息已经过了[^\n]*)\n/;function P2(e){const t=O2.exec(e),n=(t===null?e:e.slice(t[0].length)).replace(z2,"");return t===null?{text:n}:{text:n,channel:t[1]}}const sN=b.memo(function({item:t,onDismiss:n}){var o;const r=b.useContext(Um),i=b.useContext(Kw);switch(t.kind){case"user":{const c=t.pending===void 0?gM(t.text):void 0;if(c!==void 0&&r!==null)return s.jsx(PO,{client:r,note:c,handOffs:i});const u=t.pending===void 0?mM(t.text):void 0;if(u!==void 0&&r!==null)return s.jsx(LO,{client:r,note:u,handOffs:i});const d=P2(t.text);return s.jsxs("div",{className:`msg user ${t.pending===void 0?"":"pending"}`,children:[d.channel!==void 0&&s.jsxs("div",{className:"msg-from",children:["来自",d.channel]}),s.jsxs("div",{className:"bubble",children:[s.jsx(R2,{text:d.text}),t.imageRefs.length>0&&s.jsx("div",{className:"chat-images",children:t.imageRefs.map(f=>s.jsx(tN,{image:f},f.attachmentId))}),(t.images>t.imageRefs.length||t.files>0)&&s.jsxs("div",{className:"attachments",children:[t.images>t.imageRefs.length&&s.jsxs("span",{children:[s.jsx(ee,{name:"image"}),t.images-t.imageRefs.length," 张图片"]}),t.files>0&&s.jsxs("span",{children:[s.jsx(ee,{name:"paperclip"}),t.files," 个文件"]})]})]}),((o=t.pending)==null?void 0:o.failed)!==void 0&&s.jsxs("div",{className:"send-failed",children:["发送失败:",t.pending.failed,s.jsx("button",{className:"link-button",onClick:()=>n(t.pending.requestId),children:"移除"})]})]})}case"assistant":return!t.live&&hM(t.text)?s.jsxs("div",{className:"quiet-reply",children:[s.jsx(ee,{name:"check"}),"看过了,没有要告诉你的"]}):s.jsxs("div",{className:`msg assistant ${t.live?"live":""}`,children:[t.reasoning.trim()!==""&&s.jsxs("details",{className:"reasoning",open:t.live&&t.text==="",children:[s.jsxs("summary",{children:[s.jsx(ee,{name:"chevron"}),t.live&&t.text===""?s.jsx("span",{className:"shimmer",children:"正在思考…"}):"思考过程"]}),s.jsx(Ki,{text:t.reasoning})]}),t.text!==""&&s.jsx(Ki,{text:t.text}),t.live&&s.jsx("span",{className:"cursor"}),t.interrupted&&s.jsx("div",{className:"muted small",children:"(已中断)"})]});case"tool":return s.jsx(rN,{tools:[t]});case"context":return s.jsxs("details",{className:"context-row",children:[s.jsxs("summary",{children:[s.jsx(ee,{name:"info"}),t.summary!==""?t.summary:t.title]}),s.jsx("pre",{children:t.text})]});case"notice":return s.jsxs("div",{className:`notice ${t.tone}`,children:[t.tone==="error"&&s.jsx(ee,{name:"alert"}),t.text]})}});function L2({items:e,active:t,onDismiss:n}){const r=e.filter(f=>f.kind==="tool"),i=r.filter(f=>f.status==="running").length,o=r.filter(f=>f.status==="error").length,[c,u]=b.useState(!1),d=t&&!c?D2(e.at(-1)):void 0;return s.jsxs("div",{className:"tool-group process-group",children:[s.jsxs("button",{className:"tool-group-head",onClick:()=>u(!c),"aria-expanded":c,children:[s.jsx(ee,{name:"terminal"}),s.jsx("span",{className:"tool-group-title",children:`执行了 ${r.length} 个步骤`}),d!==void 0&&d!==""&&s.jsx("span",{className:"process-now",children:d}),s.jsxs("span",{className:"tool-group-meta",children:[i>0&&s.jsxs("span",{className:"tone-running",children:[i," 个进行中"]}),o>0&&s.jsxs("span",{className:"tone-failed",children:[o," 个失败"]})]}),s.jsx(ee,{name:"chevron-down",className:`chevron-icon ${c?"open":""}`})]}),c&&e.map(f=>f.kind==="tool"?s.jsx(aN,{item:f},f.id):s.jsx("div",{className:"process-note",children:s.jsx(sN,{item:f,onDismiss:n})},f.id))]})}function D2(e){return e.kind==="tool"?`${e.name} ${Lk(e.arguments)}`.trim():e.kind==="assistant"?e.text.trim().split(`
|
|
197
|
-
`)[0]||"正在思考…":""}function rN({tools:e}){const t=e.filter(c=>c.status==="running").length,n=e.filter(c=>c.status==="error").length,[r,i]=b.useState(null),o=r??(t>0||n>0||e.length<=4);return s.jsxs("div",{className:"tool-group",children:[s.jsxs("button",{className:"tool-group-head",onClick:()=>i(!o),"aria-expanded":o,children:[s.jsx(ee,{name:"terminal"}),s.jsx("span",{className:"tool-group-title",children:e.length===1?"执行了 1 个步骤":`执行了 ${e.length} 个步骤`}),s.jsxs("span",{className:"tool-group-meta",children:[t>0&&s.jsxs("span",{className:"tone-running",children:[t," 个进行中"]}),n>0&&s.jsxs("span",{className:"tone-failed",children:[n," 个失败"]})]}),s.jsx(ee,{name:"chevron-down",className:`chevron-icon ${o?"open":""}`})]}),o&&e.map(c=>s.jsx(aN,{item:c},c.id))]})}const iN={running:"运行中",ok:"完成",error:"失败",interrupted:"已中断"};function aN({item:e}){const[t,n]=b.useState(!1),r=b.useMemo(()=>Lk(e.arguments),[e.arguments]);return b.useEffect(()=>{e.status==="error"&&n(!0)},[e.status]),s.jsxs("div",{className:`tool ${e.status}`,children:[s.jsxs("button",{className:"tool-head",onClick:()=>n(i=>!i),"aria-expanded":t,children:[s.jsx(F2,{status:e.status}),s.jsx("span",{className:"tool-name",children:e.name}),s.jsx("span",{className:"tool-summary",children:r}),e.approval!==void 0&&s.jsx("span",{className:`badge approval-${e.approval}`,children:B2(e.approval)}),s.jsx("span",{className:"tool-status",children:iN[e.status]})]}),e.images!==void 0&&s.jsx("div",{className:"chat-images tool-images",children:e.images.map(i=>s.jsx(tN,{image:i},i.attachmentId))}),t&&s.jsxs("div",{className:"tool-body",children:[s.jsx("div",{className:"label",children:"参数"}),s.jsx("pre",{children:Fm(e.arguments)}),e.result!==void 0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"label",children:["结果",e.error!==void 0?` · ${e.error}`:""]}),s.jsx("pre",{children:e.result})]})]})]})}function F2({status:e}){return e==="running"?s.jsx("span",{className:"tool-spinner",role:"img","aria-label":"运行中"}):e==="ok"?s.jsx("span",{className:"tool-icon ok",role:"img","aria-label":"完成",children:s.jsx(ee,{name:"check"})}):e==="error"?s.jsx("span",{className:"tool-icon error",role:"img","aria-label":"失败",children:s.jsx(ee,{name:"close"})}):s.jsx("span",{className:"tool-icon",role:"img","aria-label":iN[e]??e,children:s.jsx(ee,{name:"info"})})}function B2(e){switch(e){case"asked":return"等待审批";case"allowed-once":return"已允许";case"rejected":return"已拒绝";case"cancelled":return"已撤回";default:return e}}const U2={id:"chat",title:"对话",requires:["sessions","chat"],sessionViews:[{id:"chat",title:"对话",order:0,component:T2}]},H2=[],Wh=320,ku=4;function yn({value:e,options:t,onChange:n,id:r,disabled:i,placeholder:o="请选择",inline:c,className:u,...d}){const f=b.useId(),p=b.useRef(null),m=b.useRef(null),[g,v]=b.useState(!1),[y,S]=b.useState(-1),[k,w]=b.useState({}),T=t.findIndex(R=>R.value===e),N=T===-1?void 0:t[T],$=R=>t[R]!==void 0&&t[R].disabled!==!0,D=(R,Z)=>{for(let E=R+Z;E>=0&&E<t.length;E+=Z)if($(E))return E;return R},O=(R=T)=>{i!==!0&&(S($(R)?R:D(-1,1)),v(!0))},F=(R=!0)=>{var Z;v(!1),R&&((Z=p.current)==null||Z.focus())},U=R=>{$(R)&&(t[R].value!==e&&n(t[R].value),F())};b.useLayoutEffect(()=>{if(!g)return;const R=()=>{var W,H;const Z=(W=p.current)==null?void 0:W.getBoundingClientRect();if(Z===void 0)return;const E=window.innerHeight-Z.bottom-ku-8,C=Z.top-ku-8,I=E<Math.min(Wh,((H=m.current)==null?void 0:H.scrollHeight)??Wh)&&C>E,L=Math.max(Z.width,180);w({left:Math.max(8,Math.min(Z.left,window.innerWidth-L-8)),minWidth:L,maxWidth:Math.max(L,Math.min(520,window.innerWidth-16)),maxHeight:Math.min(Wh,I?C:E),...I?{bottom:window.innerHeight-Z.top+ku}:{top:Z.bottom+ku}})};return R(),window.addEventListener("resize",R),window.addEventListener("scroll",R,!0),()=>{window.removeEventListener("resize",R),window.removeEventListener("scroll",R,!0)}},[g]),b.useEffect(()=>{var Z;if(!g)return;(Z=m.current)==null||Z.focus({preventScroll:!0});const R=E=>{var I,L;const C=E.target;!((I=m.current)!=null&&I.contains(C))&&!((L=p.current)!=null&&L.contains(C))&&F(!1)};return document.addEventListener("pointerdown",R,!0),()=>document.removeEventListener("pointerdown",R,!0)},[g]),b.useEffect(()=>{var R,Z;g&&y>=0&&((Z=(R=m.current)==null?void 0:R.querySelector(`[data-index="${y}"]`))==null||Z.scrollIntoView({block:"nearest"}))},[g,y]);const M=R=>{(R.key==="ArrowDown"||R.key==="ArrowUp"||R.key==="Enter"||R.key===" ")&&(R.preventDefault(),O())},P=R=>{const E={ArrowDown:()=>S(C=>D(C,1)),ArrowUp:()=>S(C=>D(C,-1)),Home:()=>S(D(-1,1)),End:()=>S(D(t.length,-1)),Enter:()=>U(y)," ":()=>U(y),Escape:()=>F(),Tab:()=>F()}[R.key];if(E!==void 0){R.key!=="Tab"&&R.preventDefault(),E();return}if(R.key.length===1&&!R.ctrlKey&&!R.metaKey&&!R.altKey){const C=R.key.toLowerCase();for(let I=1;I<=t.length;I++){const L=(y+I)%t.length;if($(L)&&t[L].label.toLowerCase().startsWith(C)){S(L);break}}}};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:p,id:r,type:"button",disabled:i,className:`select-trigger text-input plain ${c===!0?"inline":""} ${g?"open":""} ${u??""}`,"aria-haspopup":"listbox","aria-expanded":g,"aria-controls":g?f:void 0,"aria-label":d["aria-label"],onClick:()=>g?F():O(),onKeyDown:M,children:s.jsx("span",{className:`select-value ${N===void 0?"placeholder":""}`,children:(N==null?void 0:N.label)??o})}),g&&Bm.createPortal(s.jsxs("ul",{ref:m,id:f,role:"listbox",tabIndex:-1,className:"select-list",style:k,"aria-label":d["aria-label"],"aria-activedescendant":y>=0?`${f}-${y}`:void 0,onKeyDown:P,children:[t.map((R,Z)=>{var E;return s.jsxs("li",{role:"presentation",children:[R.group!==void 0&&R.group!==((E=t[Z-1])==null?void 0:E.group)&&s.jsx("div",{className:"select-group",children:R.group}),s.jsxs("div",{id:`${f}-${Z}`,"data-index":Z,role:"option","aria-selected":Z===T,"aria-disabled":R.disabled===!0,className:`select-option ${Z===y?"active":""} ${Z===T?"selected":""} ${R.disabled===!0?"disabled":""}`,onPointerMove:()=>{$(Z)&&Z!==y&&S(Z)},onClick:()=>U(Z),children:[s.jsxs("span",{className:"select-text",children:[s.jsx("span",{children:R.label}),R.hint!==void 0&&s.jsx("span",{className:"select-hint",children:R.hint})]}),Z===T&&s.jsx(ee,{name:"check",className:"select-check"})]})]},`${R.group??""}\0${R.value}`)}),t.length===0&&s.jsx("li",{role:"presentation",className:"select-empty",children:"没有可选的"})]}),document.body)]})}const Z2={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function V2({client:e}){const t=Ee(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(null),[u,d]=b.useState(0),[f,p]=b.useState(null),[m,g]=b.useState(null),[v,y]=b.useState(null),[S,k]=b.useState(""),[w,T]=b.useState(""),[N,$]=b.useState(""),[D,O]=b.useState(""),[F,U]=b.useState({});b.useEffect(()=>e.connection.on("notify/changed",()=>d(I=>I+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let I=!0;return e.connection.call("feishu/settings",{}).then(L=>{I&&(i(L),k(W=>W===""?L.settings.appId??"":W),$(W=>W===""?L.settings.chatId??"":W))}).catch(L=>{I&&g(Pe(L))}),e.connection.call("notify/status",{}).then(L=>{I&&c(L.channels.find(W=>W.id==="feishu")??null)}).catch(()=>{}),()=>{I=!1}},[e,t.state,u]);const M=async(I,L,W)=>{p(I),g(null),y(null);try{const H=await L();H!==null&&typeof H=="object"&&"settings"in H&&i(H),W!==void 0&&y(W),d(G=>G+1)}catch(H){g(Pe(H))}finally{p(null)}},P=()=>M("credentials",async()=>(w.trim()!==""&&await e.setCredential(fT,w.trim()),T(""),e.connection.call("feishu/settings/set",{appId:S.trim()===""?null:S.trim(),enabled:!0})),"已保存,正在连接…"),R=()=>M("test",async()=>{const I=await e.connection.call("notify/test",{channel:"feishu"});if(I.failed.length>0)throw new Error(I.failed.map(L=>L.error).join(";"))},"测试消息已发送,去飞书看看"),Z=r==null?void 0:r.settings,[E,C]=Z2[(o==null?void 0:o.state)??"off"];return s.jsxs("div",{className:"remote-section",children:[s.jsx("p",{className:"muted",children:"脚本出问题的通知带截图和「停止 / 重试 / 忽略」按钮;agent 需要你确认的操作也会发成卡片,在飞书或这里先回答的生效。"}),s.jsxs("details",{className:"card guide",children:[s.jsx("summary",{children:s.jsx("strong",{children:"第一次使用:在飞书开放平台创建应用(约 5 分钟)"})}),s.jsxs("ol",{className:"guide-steps",children:[s.jsxs("li",{children:["打开 ",s.jsx("a",{href:"https://open.feishu.cn/app",target:"_blank",rel:"noreferrer",children:"open.feishu.cn/app"}),"(国际版 Lark 用 open.larksuite.com/app),「创建企业自建应用」。"]}),s.jsx("li",{children:"「添加应用能力」→ 添加「机器人」。"}),s.jsxs("li",{children:["「权限管理」开通:",s.jsx("code",{children:"im:message"}),"(获取与发送单聊、群组消息)、",s.jsx("code",{children:"im:message:send_as_bot"}),"、",s.jsx("code",{children:"im:message.p2p_msg:readonly"}),"(读取用户发给机器人的单聊消息)、",s.jsx("code",{children:"im:message.group_at_msg:readonly"}),"(接收群聊中 @ 机器人的消息,可选)、",s.jsx("code",{children:"im:resource"}),"(上传截图)。"]}),s.jsxs("li",{children:["「事件与回调」→「事件配置」:订阅方式选",s.jsx("strong",{children:"使用长连接接收事件"}),",添加事件 ",s.jsx("code",{children:"im.message.receive_v1"}),"(接收消息)。"]}),s.jsxs("li",{children:["「事件与回调」→「回调配置」:订阅方式同样选",s.jsx("strong",{children:"使用长连接接收回调"}),",添加回调 ",s.jsx("code",{children:"card.action.trigger"}),"(卡片回传交互)。"]}),s.jsx("li",{children:"「版本管理与发布」创建版本并发布,可用范围包含你自己。权限或事件改过以后都要重新发布才生效。"}),s.jsx("li",{children:"把「凭证与基础信息」里的 App ID 和 App Secret 填到下面;保存后在飞书里搜索机器人名字,给它发一条消息,再回到这里「允许」自己。"})]}),s.jsx("p",{className:"muted small",children:"先保存凭证再配置长连接:飞书要求应用在线时才能保存「长连接」订阅方式。"})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"连接"}),s.jsx("p",{className:"muted small",children:(o==null?void 0:o.detail)??((o==null?void 0:o.state)==="ready"?`通知会发给 ${o.recipients} 个接收方`:"…")})]}),s.jsx("span",{className:`badge ${E}`,children:C})]}),o!==null&&o.checks.length>0&&s.jsx("ul",{className:"check-list",children:o.checks.map(I=>s.jsxs("li",{className:I.ok===!0?"ok":I.ok===!1?"failed":"",children:[s.jsx("span",{className:"check-mark",children:I.ok===!0?"✓":I.ok===!1?"✗":"…"}),s.jsx("span",{children:I.label}),I.detail!==void 0&&s.jsx("span",{className:"muted small",children:I.detail})]},I.id))}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:f!==null,onClick:()=>void M("check",()=>e.connection.call("feishu/check",{})),children:f==="check"?"检查中…":"重新检查"}),s.jsx("button",{className:"small-button",disabled:f!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void R(),children:"发送测试消息"}),Z!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:Z.enabled,disabled:f!==null,onChange:I=>void M("enable",()=>e.connection.call("feishu/settings/set",{enabled:I.target.checked}))}),"启用飞书"]})]})]}),Z!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"应用凭证"}),s.jsx("label",{className:"field-label",htmlFor:"feishu-domain",children:"平台"}),s.jsx(yn,{id:"feishu-domain",value:Z.domain,disabled:f!==null,onChange:I=>void M("domain",()=>e.connection.call("feishu/settings/set",{domain:I})),options:[{value:"feishu",label:"飞书",hint:"open.feishu.cn"},{value:"lark",label:"Lark 国际版",hint:"open.larksuite.com"}]}),s.jsx("label",{className:"field-label",htmlFor:"feishu-app-id",children:"App ID"}),s.jsx("input",{id:"feishu-app-id",className:"text-input",value:S,onChange:I=>k(I.target.value),placeholder:"cli_xxxxxxxx",spellCheck:!1}),s.jsxs("label",{className:"field-label",htmlFor:"feishu-secret",children:["App Secret ",(r==null?void 0:r.secretConfigured)===!0&&s.jsx("span",{className:"badge ok",children:"已保存"})]}),s.jsx("input",{id:"feishu-secret",className:"text-input",type:"password",value:w,onChange:I=>T(I.target.value),placeholder:(r==null?void 0:r.secretConfigured)===!0?"留空则保持不变":"在「凭证与基础信息」里复制",spellCheck:!1,autoComplete:"off"}),s.jsx("p",{className:"muted small",children:"App Secret 存在本机的 dsh 凭据里,不会再显示出来。"}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:f!==null||S.trim()==="",onClick:()=>void P(),children:f==="credentials"?"保存中…":"保存并连接"})]})]}),Z!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"允许的用户"}),s.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令、按卡片上的按钮;通知也发给他们。"}),Z.allowedUsers.length===0&&s.jsx("div",{className:"muted small",children:"还没有。给机器人发一条消息,它会出现在下面的「待允许」里。"}),s.jsx("ul",{className:"version-list",children:Z.allowedUsers.map(I=>s.jsxs("li",{children:[s.jsx("span",{children:I.name??"(未命名)"}),s.jsx("span",{className:"muted small",children:I.openId}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:f!==null,onClick:()=>void M(`rm-${I.openId}`,()=>e.connection.call("feishu/users/remove",{openId:I.openId})),children:"移除"})]},I.openId))}),((r==null?void 0:r.pending.length)??0)>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),s.jsx("ul",{className:"version-list",children:r.pending.map(I=>s.jsxs("li",{children:[s.jsx("span",{className:"muted small",children:I.openId}),s.jsxs("span",{className:"muted small",children:["「",I.text,"」 · ",$t(I.at,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:F[I.openId]??"",onChange:L=>U(W=>({...W,[I.openId]:L.target.value}))}),s.jsx("button",{className:"small-button",disabled:f!==null,onClick:()=>void M(`dismiss-${I.openId}`,()=>e.connection.call("feishu/users/remove",{openId:I.openId})),children:"忽略"}),s.jsx("button",{className:"primary small-button",disabled:f!==null,onClick:()=>void M(`allow-${I.openId}`,()=>{var L;return e.connection.call("feishu/users/allow",{openId:I.openId,...(L=F[I.openId])!=null&&L.trim()?{name:F[I.openId].trim()}:{}})}),children:"允许"})]},I.openId))})]}),s.jsx("label",{className:"field-label",htmlFor:"feishu-manual",children:"手动添加 open_id"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"feishu-manual",className:"text-input",value:D,onChange:I=>O(I.target.value),placeholder:"ou_xxxxxxxx",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:f!==null||D.trim()==="",onClick:()=>void M("manual",async()=>{const I=await e.connection.call("feishu/users/allow",{openId:D.trim()});return O(""),I}),children:"添加"})]})]}),Z!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"通知"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:Z.otherApprovals,disabled:f!==null,onChange:I=>void M("approvals",()=>e.connection.call("feishu/settings/set",{otherApprovals:I.target.checked}))}),"软件里的会话(对话、定时运行、游戏读取)需要确认或 agent 提问时也发到飞书"]}),s.jsx("p",{className:"muted small",children:"在飞书里和 agent 的对话需要确认、或 agent 有问题问你时,只发给发消息的那个人(直接回复文字也算回答);软件里的会话默认只在界面里问。两边都能回答,先回答的生效。"}),s.jsx("label",{className:"field-label",htmlFor:"feishu-chat",children:"同时发到群(可选,填群 ID,机器人需要在群里)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"feishu-chat",className:"text-input",value:N,onChange:I=>$(I.target.value),placeholder:"oc_xxxxxxxx",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:f!==null,onClick:()=>void M("chat",()=>e.connection.call("feishu/settings/set",{chatId:N.trim()===""?null:N.trim()})),children:"保存"})]})]}),v!==null&&s.jsxs("div",{className:"notice info left",children:[s.jsx(ee,{name:"check"}),s.jsx("span",{children:v})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:m})]})]})}const W2={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function q2({client:e}){const t=Ee(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(null),[u,d]=b.useState(0),[f,p]=b.useState(null),[m,g]=b.useState(null),[v,y]=b.useState(null),[S,k]=b.useState(""),[w,T]=b.useState(""),[N,$]=b.useState(""),[D,O]=b.useState({});b.useEffect(()=>e.connection.on("notify/changed",()=>d(E=>E+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let E=!0;return e.connection.call("qqbot/settings",{}).then(C=>{E&&(i(C),k(I=>I===""?C.settings.appId??"":I))}).catch(C=>{E&&g(Pe(C))}),e.connection.call("notify/status",{}).then(C=>{E&&c(C.channels.find(I=>I.id==="qq")??null)}).catch(()=>{}),()=>{E=!1}},[e,t.state,u]);const F=async(E,C,I)=>{p(E),g(null),y(null);try{const L=await C();L!==null&&typeof L=="object"&&"settings"in L&&i(L),I!==void 0&&y(I),d(W=>W+1)}catch(L){g(Pe(L))}finally{p(null)}},U=()=>F("credentials",async()=>(w.trim()!==""&&await e.setCredential(hT,w.trim()),T(""),e.connection.call("qqbot/settings/set",{appId:S.trim()===""?null:S.trim(),enabled:!0})),"已保存,正在连接…"),M=()=>F("test",async()=>{const E=await e.connection.call("notify/test",{channel:"qq"});if(E.failed.length>0)throw new Error(E.failed.map(C=>C.error).join(";"))},"测试消息已发送,去 QQ 看看"),P=r==null?void 0:r.settings,[R,Z]=W2[(o==null?void 0:o.state)??"off"];return s.jsxs("div",{className:"remote-section",children:[s.jsx("p",{className:"muted",children:"QQ 官方机器人:在 QQ 里和它单聊。消息用 markdown 显示;通知、需要你确认的操作和助手问你的问题下面有按钮,点一下就是回复,也可以直接打字。机器人没有按钮权限时会改成文字,告诉你回复什么。"}),s.jsxs("details",{className:"card guide",children:[s.jsx("summary",{children:s.jsx("strong",{children:"第一次使用:在 QQ 开放平台创建机器人(约 10 分钟)"})}),s.jsxs("ol",{className:"guide-steps",children:[s.jsxs("li",{children:["打开 ",s.jsx("a",{href:"https://bot.q.qq.com/open",target:"_blank",rel:"noreferrer",children:"QQ 开放平台"}),",用 QQ 扫码登录,创建一个机器人。"]}),s.jsxs("li",{children:["在机器人的「开发设置」里复制 ",s.jsx("strong",{children:"AppID"})," 和 ",s.jsx("strong",{children:"AppSecret"}),",填到下面。"]}),s.jsxs("li",{children:["「功能配置」里开启",s.jsx("strong",{children:"单聊"}),"(消息走 WebSocket,不用填回调地址)。还在沙箱阶段的机器人,要把自己的 QQ 加进「沙箱配置」的测试成员。"]}),s.jsx("li",{children:"保存后用手机 QQ 找到机器人(资料卡或沙箱二维码),给它发一条消息,再回到这里「允许」自己。"})]}),s.jsx("p",{className:"muted small",children:"机器人发给你的不是回复的消息(同步的对话、通知)算「主动消息」:在机器人资料卡里要开着「允许主动发送」。"})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"连接"}),s.jsx("p",{className:"muted small",children:(o==null?void 0:o.detail)??((o==null?void 0:o.state)==="ready"?`通知和对话会发给 ${o.recipients} 个人`:"…")})]}),s.jsx("span",{className:`badge ${R}`,children:Z})]}),o!==null&&o.checks.length>0&&s.jsx("ul",{className:"check-list",children:o.checks.map(E=>s.jsxs("li",{className:E.ok===!0?"ok":E.ok===!1?"failed":"",children:[s.jsx("span",{className:"check-mark",children:E.ok===!0?"✓":E.ok===!1?"✗":"…"}),s.jsx("span",{children:E.label}),E.detail!==void 0&&s.jsx("span",{className:"muted small",children:E.detail})]},E.id))}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:f!==null,onClick:()=>void F("check",()=>e.connection.call("qqbot/check",{})),children:f==="check"?"检查中…":"重新检查"}),s.jsx("button",{className:"small-button",disabled:f!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void M(),children:"发送测试消息"}),P!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:P.enabled,disabled:f!==null,onChange:E=>void F("enable",()=>e.connection.call("qqbot/settings/set",{enabled:E.target.checked}))}),"启用 QQ 机器人"]})]})]}),P!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"机器人凭证"}),s.jsx("label",{className:"field-label",htmlFor:"qq-app-id",children:"AppID"}),s.jsx("input",{id:"qq-app-id",className:"text-input",value:S,onChange:E=>k(E.target.value),placeholder:"102xxxxxx",spellCheck:!1,inputMode:"numeric"}),s.jsxs("label",{className:"field-label",htmlFor:"qq-secret",children:["AppSecret ",(r==null?void 0:r.secretConfigured)===!0&&s.jsx("span",{className:"badge ok",children:"已保存"})]}),s.jsx("input",{id:"qq-secret",className:"text-input",type:"password",value:w,onChange:E=>T(E.target.value),placeholder:(r==null?void 0:r.secretConfigured)===!0?"留空则保持不变":"在「开发设置」里复制",spellCheck:!1,autoComplete:"off"}),s.jsx("p",{className:"muted small",children:"AppSecret 存在本机的 dsh 凭据里,不会再显示出来。"}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:f!==null||S.trim()==="",onClick:()=>void U(),children:f==="credentials"?"保存中…":"保存并连接"})]})]}),P!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"允许的用户"}),s.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令;通知和与助手的对话也发给他们。"}),P.allowedUsers.length===0&&s.jsx("div",{className:"muted small",children:"还没有。在 QQ 里给机器人发一条消息,它会出现在下面的「待允许」里。"}),s.jsx("ul",{className:"version-list",children:P.allowedUsers.map(E=>s.jsxs("li",{children:[s.jsx("span",{children:E.name??"(未命名)"}),s.jsx("span",{className:"muted small",children:E.openId}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:f!==null,onClick:()=>void F(`rm-${E.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:E.openId})),children:"移除"})]},E.openId))}),((r==null?void 0:r.pending.length)??0)>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),s.jsx("ul",{className:"version-list",children:r.pending.map(E=>s.jsxs("li",{children:[s.jsx("span",{className:"muted small",children:E.openId}),s.jsxs("span",{className:"muted small",children:["「",E.text,"」 · ",$t(E.at,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:D[E.openId]??"",onChange:C=>O(I=>({...I,[E.openId]:C.target.value}))}),s.jsx("button",{className:"small-button",disabled:f!==null,onClick:()=>void F(`dismiss-${E.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:E.openId})),children:"忽略"}),s.jsx("button",{className:"primary small-button",disabled:f!==null,onClick:()=>void F(`allow-${E.openId}`,()=>{var C;return e.connection.call("qqbot/users/allow",{openId:E.openId,...(C=D[E.openId])!=null&&C.trim()?{name:D[E.openId].trim()}:{}})}),children:"允许"})]},E.openId))})]}),s.jsx("label",{className:"field-label",htmlFor:"qq-manual",children:"手动添加 user_openid"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"qq-manual",className:"text-input",value:N,onChange:E=>$(E.target.value),placeholder:"机器人回复你的那条消息里有",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:f!==null||N.trim()==="",onClick:()=>void F("manual",async()=>{const E=await e.connection.call("qqbot/users/allow",{openId:N.trim()});return $(""),E}),children:"添加"})]})]}),v!==null&&s.jsxs("div",{className:"notice info left",children:[s.jsx(ee,{name:"check"}),s.jsx("span",{children:v})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:m})]})]})}const G2=[{id:"feishu",title:"飞书",capability:"feishu",component:V2},{id:"qq",title:"QQ 机器人",capability:"qqbot",component:q2}];function K2({client:e}){var c;const t=Ee(e.capabilities),n=G2.filter(u=>t.has(u.capability)),[r,i]=b.useState(((c=n[0])==null?void 0:c.id)??"feishu"),o=n.find(u=>u.id===r)??n[0];return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"远程连接"}),s.jsx("p",{children:"不在电脑前也能用:在飞书或 QQ 里和助手说话。和助手的对话两边完全一样——在软件里说的、在聊天软件里说的、助手和其他 agent 之间的往来、助手的回复,都会同步过去;脚本出问题的通知也发到那里,在聊天软件里点按钮或直接回复就能处理。"}),n.length>1&&s.jsx("nav",{className:"agent-tabs remote-tabs",role:"tablist","aria-label":"远程连接方式",children:n.map(u=>s.jsx("button",{role:"tab","aria-selected":u.id===(o==null?void 0:o.id),className:u.id===(o==null?void 0:o.id)?"active":"",onClick:()=>i(u.id),children:u.title},u.id))}),o===void 0?s.jsx("p",{className:"muted",children:"当前连接没有提供远程连接。"}):s.jsx(o.component,{client:e},o.id)]})}const Y2=(e,t)=>{try{const n=localStorage.getItem(`adg.fold.${e}`);return n===null?t:n==="1"}catch{return t}};function X2(e,t=!0){const[n,r]=b.useState(()=>Y2(e,t));return[n,()=>r(o=>{try{localStorage.setItem(`adg.fold.${e}`,o?"0":"1")}catch{}return!o})]}function Q2({open:e,onToggle:t,children:n,count:r,className:i=""}){return s.jsxs("button",{type:"button",className:`fold-head ${i}`,"aria-expanded":e,onClick:t,children:[s.jsx(ee,{name:"chevron",className:`fold-chevron ${e?"open":""}`}),s.jsx("span",{className:"fold-title",children:n}),r!==void 0&&s.jsx("span",{className:"fold-count",children:r})]})}function Na({id:e,title:t,count:n,initial:r=!0,children:i,className:o=""}){const[c,u]=X2(e,r);return s.jsxs("div",{className:`fold ${o}`,children:[s.jsx(Q2,{open:c,onToggle:u,...n===void 0?{}:{count:n},children:t}),c&&i]})}function oN({client:e,scriptId:t,taskId:n,name:r,spec:i,value:o,onChange:c,onCreated:u,profile:d}){const[f,p]=b.useState(null),[m,g]=b.useState(null),[v,y]=b.useState(!1),S=async()=>{const w=(m==null?void 0:m.trim())??"";if(w!==""){p(null),y(!0);try{const{value:T}=await e.connection.call("runs/choices/create",{scriptId:t,taskId:n,param:r,name:w,...d===void 0?{}:{profile:d}});g(null),u==null||u(),c(T)}catch(T){p(Pe(T))}finally{y(!1)}}};let k;if(i.choices!==void 0){const w=i.choices.some(T=>T.value===o);k=s.jsx(yn,{"aria-label":r,value:w?o:"",placeholder:i.choices.length===0?"本地配置里还没有,先新建或在脚本里建一个":"请选择",onChange:T=>{T==="\0new"?g(N=>N??"MultiGameAssistant"):c(T)},options:[...i.choices.map(T=>({value:T.value,label:T.label,...T.detail===void 0?{}:{hint:T.detail}})),...i.canCreate===!0?[{value:"\0new",label:"+ 新建…"}]:[]]})}else i.type==="boolean"?k=s.jsx(yn,{"aria-label":r,value:o,onChange:c,options:[{value:"true",label:"是"},{value:"false",label:"否"}]}):i.enum!==void 0?k=s.jsx(yn,{"aria-label":r,value:o,onChange:c,options:i.enum.map(w=>({value:String(w),label:String(w)}))}):k=s.jsx("input",{className:"text-input plain","aria-label":r,value:o,placeholder:i.default===void 0?"必填":String(i.default),inputMode:i.type==="string"?"text":"numeric",onChange:w=>c(w.target.value)});return s.jsxs("div",{className:"param-row",role:"group","aria-label":r,children:[s.jsxs("span",{className:"field-label",children:[r,i.description===void 0?"":` · ${i.description}`]}),k,m!==null&&s.jsxs("span",{className:"param-new",children:[s.jsx("input",{className:"text-input plain",autoFocus:!0,value:m,"aria-label":"新项的名字",onChange:w=>g(w.target.value),onKeyDown:w=>{w.key==="Enter"?(w.preventDefault(),S()):w.key==="Escape"&&g(null)}}),s.jsx("button",{type:"button",className:"primary small-button",disabled:v||m.trim()==="",onClick:()=>void S(),children:v?"新建中…":"新建"}),s.jsx("button",{type:"button",className:"small-button",disabled:v,onClick:()=>{g(null),p(null)},children:"取消"}),s.jsx("span",{className:"muted small",children:"复制一个现有的同类项,只存在本应用的本地配置里,原项目不变"})]}),f!==null&&s.jsx("span",{className:"error small",children:f})]})}function lN(e,t,n=!0){const r=Ee(e.connection.status),[i,o]=b.useState(null);return b.useEffect(()=>{if(o(null),t===void 0||!n||r.state!=="open")return;let c=!0;e.connection.call("configs/profiles",{scriptId:t}).then(d=>{c&&o(d)},()=>{});const u=e.connection.on("configs/profiles/changed",d=>{d.scriptId===t&&o(d.list)});return()=>{c=!1,u()}},[e,t,n,r.state]),i}function cN({list:e,value:t,onChange:n,id:r,label:i="配置"}){if(e===null||e.items.length<2)return null;const o=e.items.find(u=>u.id===e.current),c=t!==void 0&&!e.items.some(u=>u.id===t);return s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:r,children:i}),s.jsx(yn,{id:r,value:t??"",onChange:u=>n(u===""?void 0:u),options:[{value:"",label:"跟随当前使用的",hint:`现在是「${(o==null?void 0:o.name)??"默认"}」`},...e.items.map(u=>({value:u.id,label:u.name})),...c?[{value:t,label:"已删除的配置",disabled:!0}]:[]]}),c&&s.jsx("span",{className:"muted small",children:"这份配置已经删了,运行时会失败;请重新选一份。"})]})}const Hm={starting:["","启动中"],running:["","运行中"],stopping:["warn","停止中"],succeeded:["ok","成功"],failed:["warn","失败"],cancelled:["","已停止"]},J2={desktop:"占用鼠标键盘",window:"后台窗口",adb:"模拟器",none:"不占用"};function ez({client:e,scriptId:t,packId:n}){const r=Ee(e.connection.status),i=Cn(3e4),[o,c]=b.useState(null),[u,d]=b.useState([]),[f,p]=b.useState(""),[m,g]=b.useState({}),[v,y]=b.useState(!1),[S,k]=b.useState(null),[w,T]=b.useState(null),[N,$]=b.useState(0),D=lN(e,t,n!==void 0),[O,F]=b.useState(void 0);b.useEffect(()=>{if(r.state!=="open")return;let Z=!0;return e.connection.call("runs/tasks",{scriptId:t,...O===void 0?{}:{profile:O}}).then(E=>{Z&&(c(E),p(C=>{var I;return C===""?((I=E.tasks[0])==null?void 0:I.id)??"":C}))}).catch(E=>{Z&&k(Pe(E))}),e.connection.call("runs/list",{scriptId:t}).then(E=>{Z&&d(E.items)}).catch(()=>{}),()=>{Z=!1}},[e,t,n,r.state,N,O,D==null?void 0:D.current]),b.useEffect(()=>e.connection.on("runs/state",Z=>{Z.scriptId===t&&d(E=>[Z,...E.filter(C=>C.id!==Z.id)].sort((C,I)=>I.startedAt-C.startedAt))}),[e,t]);const U=o==null?void 0:o.tasks.find(Z=>Z.id===f);b.useEffect(()=>{U!==void 0&&g(Object.fromEntries(Object.entries(U.params).map(([Z,E])=>{var C;return[Z,E.default!==void 0?String(E.default):((C=E.choices)==null?void 0:C.length)===1?E.choices[0].value:""]})))},[U==null?void 0:U.id]);const M=u.find(Z=>Z.endedAt===void 0),P=u.find(Z=>{var E;return Z.id===(w??(M==null?void 0:M.id)??((E=u[0])==null?void 0:E.id))}),R=async()=>{if(U!==void 0){y(!0),k(null);try{const Z={};for(const[C,I]of Object.entries(U.params)){const L=m[C]??"";L!==""&&(Z[C]=I.type==="boolean"?L==="true":I.type==="integer"||I.type==="number"?Number(L):L)}const E=await e.connection.call("runs/start",{scriptId:t,taskId:U.id,params:Z,...O===void 0?{}:{profile:O}});T(E.id),E.state==="failed"&&k(E.outcome??"运行失败")}catch(Z){k(Pe(Z))}finally{y(!1)}}};return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"任务"}),s.jsx("p",{className:"muted small",children:"按脚本包运行,使用本地配置;原项目的配置在运行结束后会还原。"})]})}),o===null&&S===null&&s.jsx("div",{className:"muted small",children:"加载中…"}),o!==null&&!o.runnable&&s.jsx("div",{className:"notice info left small",children:o.problem}),o!==null&&o.tasks.length>0&&s.jsxs("div",{className:"run-form",children:[s.jsx("label",{className:"field-label",htmlFor:"task-select",children:"任务"}),s.jsx(yn,{id:"task-select",value:f,onChange:p,options:o.tasks.map(Z=>({value:Z.id,label:Z.title,hint:Z.id}))}),U!==void 0&&s.jsxs("div",{className:"task-facts muted small",children:[s.jsx("span",{className:"badge",children:J2[U.input]}),U.account!==void 0&&s.jsxs("span",{className:"badge",children:["账号 ",U.account]}),U.expectedDuration!==void 0&&s.jsxs("span",{children:["约 ",U.expectedDuration]}),U.description!==void 0&&s.jsx("span",{children:U.description})]}),s.jsx(cN,{id:"run-profile",list:D,value:O,onChange:F}),U!==void 0&&Object.entries(U.params).map(([Z,E])=>s.jsx(oN,{client:e,scriptId:t,taskId:U.id,name:Z,spec:E,profile:O,value:m[Z]??"",onChange:C=>g(I=>({...I,[Z]:C})),onCreated:()=>$(C=>C+1)},Z)),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),M!==void 0&&s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:M.id}).catch(Z=>k(Pe(Z))),children:"停止当前运行"}),s.jsxs("button",{className:"primary small-button",disabled:v||!o.runnable||M!==void 0,onClick:()=>void R(),children:[s.jsx(ee,{name:"arrow"}),v?"启动中…":"运行"]})]})]}),S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:S})]}),u.length>0&&s.jsxs(Na,{id:"scripts.recent-runs",title:"最近运行",count:Math.min(u.length,6),className:"run-history",children:[u.slice(0,6).map(Z=>{const[E,C]=Hm[Z.state];return s.jsxs("button",{className:`run-row ${Z.id===(P==null?void 0:P.id)?"active":""}`,"aria-expanded":Z.id===(P==null?void 0:P.id),onClick:()=>T(I=>I===Z.id||I===null&&Z.id===(P==null?void 0:P.id)?"":Z.id),children:[s.jsx("span",{className:`badge ${E}`,children:C}),s.jsxs("span",{className:"run-title",children:[Z.taskTitle,Z.profileName!==void 0&&((D==null?void 0:D.items.length)??0)>1&&s.jsxs("span",{className:"muted small",children:[" · ",Z.profileName]})]}),s.jsx("span",{className:"muted small run-outcome",children:Z.outcome??Z.resources.join(" · ")}),s.jsx("span",{className:"session-time",children:$t(Z.startedAt,i)})]},Z.id)}),P!==void 0&&s.jsx(uN,{client:e,run:P},P.id)]})]})}function uN({client:e,run:t}){const[n,r]=b.useState([]),i=b.useRef(null);b.useEffect(()=>{let f=!0;e.connection.call("runs/logs",{runId:t.id,limit:500}).then(m=>{f&&r(m.lines)}).catch(()=>{});const p=e.connection.on("runs/log",m=>{m.runId===t.id&&r(g=>[...g,...m.lines].slice(-1e3))});return()=>{f=!1,p()}},[e,t.id]),b.useEffect(()=>{const f=i.current;f!==null&&(f.scrollTop=f.scrollHeight)},[n.length]);const o=b.useMemo(()=>t.warnings,[t.warnings]),[c,u]=b.useState(null),d=async()=>{let f=n;try{f=(await e.connection.call("runs/logs",{runId:t.id,limit:2e3})).lines}catch{}const p=[`${t.scriptName} · ${t.taskTitle}(${t.id})${t.outcome===void 0?"":` — ${t.outcome}`}`,...f.map(g=>`${new Date(g.at).toLocaleTimeString("zh-CN",{hour12:!1})} [${g.source==="adg"?"平台":g.source}]${g.level===void 0?"":` [${g.level}]`} ${g.text}`)].join(`
|
|
198
|
-
`),m=await tz(p);u(m?`已复制 ${f.length} 行`:"复制失败"),setTimeout(()=>u(null),1800)};return s.jsxs("div",{className:"run-log-wrap",children:[o.map(f=>s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsx("span",{children:f})]},f)),s.jsxs("div",{className:"run-log-bar",children:[s.jsxs("span",{className:"muted small",children:[n.length," 行",n.length>=1e3?"(只显示最近的)":""]}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{type:"button",className:"small-button",disabled:n.length===0,onClick:()=>void d(),title:"复制整次运行的日志(最多 2000 行),方便发给别人或 agent",children:[s.jsx(ee,{name:"copy"}),c??"复制日志"]})]}),s.jsxs("div",{className:"run-log",ref:i,role:"log","aria-label":"运行日志",children:[n.length===0&&s.jsx("div",{className:"muted small",children:"还没有日志"}),n.map((f,p)=>s.jsxs("div",{className:`log-line ${f.level===void 0?"":`lv-${f.level}`} ${f.source==="adg"?"adg":""}`,children:[s.jsx("span",{className:"log-time",children:new Date(f.at).toLocaleTimeString()}),s.jsx("span",{className:"log-source",children:f.source==="adg"?"平台":f.source}),s.jsx("span",{className:"log-text",children:f.text})]},p))]})]})}async function tz(e){try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch{return!1}finally{t.remove()}}}const dN=b.createContext({byIncident:new Map,openSession:()=>{}}),nz={running:"agent 正在处理",resolved:"agent 已处理",retried:"agent 处理后重新运行","gave-up":"agent 处理不了","taken-over":"你接管了",timeout:"agent 超时",failed:"agent 没能开始"},sz={error:"出错",warning:"警告",failed:"失败",stalled:"卡住",overtime:"超时"};function rz({client:e,openSettings:t,openSession:n}){const r=Ee(e.connection.status),i=Cn(3e4),[o,c]=b.useState([]),[u,d]=b.useState([]),[f,p]=b.useState(null),[m,g]=b.useState(!1),[v,y]=b.useState(null),[S,k]=b.useState([]),w=Ee(e.capabilities);b.useEffect(()=>{if(r.state!=="open"||!w.has("intervene"))return;let M=!0;return e.connection.call("intervene/list",{limit:100}).then(P=>{M&&k(P.items)}).catch(()=>{}),()=>{M=!1}},[e,r.state,w]),b.useEffect(()=>e.connection.on("intervene/changed",M=>{k(P=>[M,...P.filter(R=>R.id!==M.id)])}),[e]);const T=b.useMemo(()=>{const M=new Map;for(const P of[...S].sort((R,Z)=>R.startedAt-Z.startedAt))P.incidentId!==void 0&&M.set(P.incidentId,P);return{byIncident:M,openSession:n}},[S,n]);b.useEffect(()=>{if(r.state!=="open")return;let M=!0;return e.connection.call("runs/list",{}).then(P=>{M&&c(P.items)}).catch(P=>{M&&y(Pe(P))}),e.connection.call("monitor/incidents",{status:"all",limit:200}).then(P=>{M&&d(P.items)}).catch(()=>{}),()=>{M=!1}},[e,r.state]),b.useEffect(()=>e.connection.on("runs/state",M=>{c(P=>[M,...P.filter(R=>R.id!==M.id)].sort((R,Z)=>Z.startedAt-R.startedAt))}),[e]),b.useEffect(()=>e.connection.on("monitor/incident",M=>{d(P=>[M,...P.filter(R=>R.id!==M.id)].sort((R,Z)=>Z.createdAt-R.createdAt))}),[e]);const N=o.filter(M=>M.endedAt===void 0),$=o.filter(M=>M.endedAt!==void 0).slice(0,30),D=u.filter(M=>M.status==="open"),O=o.find(M=>{var P,R;return M.id===(f??((P=N[0])==null?void 0:P.id)??((R=o[0])==null?void 0:R.id))}),F=b.useMemo(()=>{const M=new Map;for(const P of D)M.set(P.runId,(M.get(P.runId)??0)+1);return M},[D]),U=M=>{const[P,R]=Hm[M.state],Z=F.get(M.id)??0;return s.jsxs("button",{className:`script-row ${M.id===(O==null?void 0:O.id)?"active":""}`,onClick:()=>p(M.id),children:[s.jsxs("span",{className:"script-row-main",children:[s.jsxs("span",{className:"script-row-name",children:[M.scriptName," · ",M.taskTitle]}),s.jsxs("span",{className:"muted small",children:[M.kind==="settings"?"设置会话 · ":"",$t(M.startedAt,i),M.retryOf===void 0?"":" · 重新运行"]})]}),Z>0?s.jsxs("span",{className:"badge warn",children:["异常 ",Z]}):s.jsx("span",{className:`badge ${P}`,children:R})]},M.id)};return s.jsx(dN.Provider,{value:T,children:s.jsxs("section",{className:"main scripts-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"运行"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"运行监控"})]}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>t("feishu"),children:[s.jsx(ee,{name:"plug"}),"消息通知"]}),s.jsxs("button",{className:`small-button ${m?"primary":""}`,onClick:()=>g(M=>!M),children:[s.jsx(ee,{name:"settings"}),"监控设置"]})]})]}),s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"运行列表",children:[v!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:v})]}),s.jsxs(Na,{id:"monitor.active",title:"正在运行",count:N.length,className:"list-fold",children:[N.length===0&&s.jsx("div",{className:"muted small pad",children:"没有正在运行的任务"}),N.map(U)]}),$.length>0&&s.jsx(Na,{id:"monitor.recent",title:"最近",count:$.length,className:"list-fold",children:$.map(U)})]}),s.jsx("div",{className:"scripts-detail",children:s.jsxs("div",{className:"script-detail",children:[m&&s.jsx(az,{client:e}),D.length>0&&s.jsx("section",{className:"card",children:s.jsxs(Na,{id:"monitor.open-incidents",title:s.jsxs("h3",{children:["待处理的异常(",D.length,")"]}),className:"card-fold",children:[s.jsx("p",{className:"muted small",children:"脚本包里写了自动处理的(如重连模拟器、重新运行)会先自动处理;处理不了的才推送到飞书。"}),s.jsx("div",{className:"incident-list",children:D.map(M=>s.jsx(fN,{client:e,incident:M,now:i,onOpen:()=>p(M.runId)},M.id))})]})}),O===void 0&&D.length===0&&s.jsxs("div",{className:"empty",children:[s.jsx(ee,{name:"monitor"}),s.jsx("p",{children:"还没有运行记录。在「脚本」页运行一个任务,或对 agent 说「跑一下方舟日常」。"})]}),O!==void 0&&s.jsx(iz,{client:e,run:O,incidents:u.filter(M=>M.runId===O.id),now:i,openRun:p})]})})]})]})})}function iz({client:e,run:t,incidents:n,now:r,openRun:i}){const[o,c]=Hm[t.state],[u,d]=b.useState(null);return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsxs("h3",{children:[t.scriptName," · ",t.taskTitle]}),s.jsxs("p",{className:"muted small",children:[new Date(t.startedAt).toLocaleString("zh-CN",{hour12:!1}),t.endedAt===void 0?"":` → ${new Date(t.endedAt).toLocaleTimeString("zh-CN",{hour12:!1})}`,t.resources.length>0?` · ${t.resources.join(" · ")}`:""]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:`badge ${o}`,children:c}),t.endedAt===void 0&&s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:t.id}).catch(f=>d(Pe(f))),children:"停止"})]})]}),t.outcome!==void 0&&s.jsxs("div",{className:"muted small",children:["结果:",t.outcome]}),t.retryOf!==void 0&&s.jsxs("button",{className:"link-button small",onClick:()=>i(t.retryOf),children:["这是 ",t.retryOf," 的重新运行"]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:u})]}),s.jsx(Na,{id:"monitor.run-log",title:"日志",children:s.jsx(uN,{client:e,run:t},t.id)}),n.length>0&&s.jsx(Na,{id:"monitor.run-incidents",title:"这次运行的异常",count:n.length,children:s.jsx("div",{className:"incident-list",children:n.map(f=>s.jsx(fN,{client:e,incident:f,now:r},f.id))})})]})}function fN({client:e,incident:t,now:n,onOpen:r}){const{byIncident:i,openSession:o}=b.useContext(dN),c=i.get(t.id),[u,d]=b.useState(!1),[f,p]=b.useState(null),[m,g]=b.useState(null),v=async()=>{if(c!==void 0){d(!0),p(null);try{await e.connection.call("intervene/takeover",{id:c.id})}catch(k){p(Pe(k))}finally{d(!1)}}},y=async k=>{d(!0),p(null);try{await e.connection.call("monitor/act",{incidentId:t.id,action:k})}catch(w){p(Pe(w))}finally{d(!1)}},S=async()=>{if(m!==null)return g(null);try{const k=await e.connection.call("monitor/screenshot",{incidentId:t.id});g(`data:${k.mime};base64,${k.data}`)}catch(k){p(Pe(k))}};return s.jsxs("div",{className:`incident ${t.severity} ${t.status}`,children:[s.jsxs("div",{className:"incident-head",children:[s.jsx("span",{className:`badge ${t.severity==="error"?"warn":""}`,children:sz[t.kind]}),r===void 0?s.jsx("span",{className:"incident-title",children:t.title}):s.jsx("button",{className:"link-button incident-title",onClick:r,children:t.title}),s.jsx("span",{className:"session-time",children:$t(t.createdAt,n)})]}),s.jsx("div",{className:"incident-detail",children:t.detail}),t.steps.length>0&&s.jsx("ul",{className:"incident-steps",children:t.steps.filter(k=>(c==null?void 0:c.summary)===void 0||c.state==="running"||!k.detail.endsWith(c.summary)).map((k,w)=>s.jsxs("li",{className:k.ok?"ok":"failed",children:[k.ok?"✓":"✗"," ",k.detail]},w))}),t.status==="resolved"&&s.jsxs("div",{className:"muted small",children:["已处理:",t.resolution]}),c!==void 0&&s.jsxs("div",{className:`agent-line ${c.state}`,children:[s.jsxs("span",{className:"badge",children:[nz[c.state],c.mode==="diagnose"?"(只诊断)":""]}),c.summary!==void 0&&s.jsx("span",{className:"small",children:c.summary}),c.paused&&s.jsx("span",{className:"badge warn",children:"脚本暂停中"}),s.jsx("span",{className:"spacer"}),c.sessionId!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>o(c.sessionId),children:"看 agent 的处理过程"}),c.state==="running"&&s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void v(),children:"我来接管"})]}),t.status==="open"&&s.jsxs("div",{className:"key-actions",children:[t.screenshot&&s.jsxs("button",{className:"small-button",onClick:()=>void S(),children:[s.jsx(ee,{name:"image"}),m===null?"截图":"收起截图"]}),s.jsx("span",{className:"spacer"}),(c==null?void 0:c.paused)===!0&&s.jsx("button",{className:"primary small-button",disabled:u,onClick:()=>void y("resume"),children:"继续"}),s.jsx("button",{className:"danger-outline small-button",disabled:u,onClick:()=>void y("stop"),children:"停止"}),s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void y("retry"),children:"重试"}),s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void y("resolve"),children:"忽略"})]}),m!==null&&s.jsx("img",{className:"incident-shot",src:m,alt:"异常时的截图"}),f!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:f})]})]})}function az({client:e}){var d;const[t,n]=b.useState(null),[r,i]=b.useState(null);b.useEffect(()=>{e.connection.call("monitor/settings",{}).then(n).catch(f=>i(Pe(f)))},[e]);const o=f=>e.connection.call("monitor/settings/set",f).then(n).catch(p=>i(Pe(p))),c=((d=Cm(e).data)==null?void 0:d.scripts)??[],u=Object.entries((t==null?void 0:t.scriptStall)??{}).sort(([f],[p])=>f.localeCompare(p));return s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"监控设置"}),t!==null&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"stall-seconds",children:"多少秒没有新日志算卡住、交给干预(默认值;0 = 不检测)"}),s.jsx("input",{id:"stall-seconds",className:"text-input plain",type:"number",min:0,max:86400,defaultValue:t.defaultStallSeconds,onBlur:f=>void o({defaultStallSeconds:Math.max(0,Math.min(86400,Math.round(Number(f.target.value)||0)))})}),s.jsx("p",{className:"muted small",children:"每个脚本会从自己跑成功的记录里学:卡住时间取最近几次里最长安静时间的 1.5 倍(不低于上面的默认值);agent 看过日志节奏后也会替它调。"}),u.length>0&&s.jsx("ul",{className:"stall-list",children:u.map(([f,p])=>{var m;return s.jsxs("li",{children:[s.jsx("span",{children:((m=c.find(g=>g.id===f))==null?void 0:m.name)??f}),s.jsxs("span",{className:"muted small",children:[p.seconds," 秒 · ",p.by==="learned"?"学到的":p.by==="agent"?"agent 设的":"你设的",p.note===void 0?"":`:${p.note}`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"link-button small",onClick:()=>{const{[f]:g,...v}=t.scriptStall;o({scriptStall:v})},children:"恢复自动"})]},f)})}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.screenshot,onChange:f=>void o({screenshot:f.target.checked})}),"出错时截图(模拟器画面或桌面)并随通知发送"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.notifyWarnings,onChange:f=>void o({notifyWarnings:f.target.checked})}),"警告也推送(默认只推送出错、失败、卡住)"]}),s.jsx("label",{className:"field-label",htmlFor:"intervene-mode",children:"自动处理解决不了的问题,先交给 agent(需要能看图的模型)"}),s.jsx(yn,{id:"intervene-mode",value:t.intervene,onChange:f=>void o({intervene:f}),options:[{value:"act",label:"诊断并处理(推荐)",hint:"暂停脚本,agent 看屏幕、点击和输入来解决"},{value:"diagnose",label:"只诊断",hint:"agent 看截图说明原因,由你决定"},{value:"off",label:"关闭",hint:"直接通知我"}]}),s.jsx("label",{className:"field-label",htmlFor:"intervene-cap",children:"每天最多交给 agent 几次(控制模型费用)"}),s.jsx("input",{id:"intervene-cap",className:"text-input plain",type:"number",min:0,max:200,defaultValue:t.interventionsPerDay,onBlur:f=>void o({interventionsPerDay:Math.max(0,Math.min(200,Math.round(Number(f.target.value)||0)))})})]}),r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:r})]})]})}const oz={id:"runs",title:"运行监控",milestone:"M3",requires:["runs","monitor"],pages:[{id:"runs",title:"运行",icon:"monitor",order:30,agent:"intervene",component:rz}]},lz={id:"feishu",title:"远程连接",milestone:"M3",requires:["notify","credentials"],settingsPages:[{id:"feishu",title:"远程连接",order:12,component:K2}]};function kn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=kn(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var cz={value:()=>{}};function kd(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Ou(n)}function Ou(e){this._=e}function uz(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Ou.prototype=kd.prototype={constructor:Ou,on:function(e,t){var n=this._,r=uz(e+"",n),i,o=-1,c=r.length;if(arguments.length<2){for(;++o<c;)if((i=(e=r[o]).type)&&(i=dz(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<c;)if(i=(e=r[o]).type)n[i]=dy(n[i],e.name,t);else if(t==null)for(i in n)n[i]=dy(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ou(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function dz(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function dy(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=cz,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Kp="http://www.w3.org/1999/xhtml";const fy={svg:"http://www.w3.org/2000/svg",xhtml:Kp,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function wd(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),fy.hasOwnProperty(t)?{space:fy[t],local:e}:e}function fz(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Kp&&t.documentElement.namespaceURI===Kp?t.createElement(e):t.createElementNS(n,e)}}function hz(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function hN(e){var t=wd(e);return(t.local?hz:fz)(t)}function pz(){}function Zm(e){return e==null?pz:function(){return this.querySelector(e)}}function mz(e){typeof e!="function"&&(e=Zm(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],c=o.length,u=r[i]=new Array(c),d,f,p=0;p<c;++p)(d=o[p])&&(f=e.call(d,d.__data__,p,o))&&("__data__"in d&&(f.__data__=d.__data__),u[p]=f);return new Ms(r,this._parents)}function gz(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function xz(){return[]}function pN(e){return e==null?xz:function(){return this.querySelectorAll(e)}}function vz(e){return function(){return gz(e.apply(this,arguments))}}function yz(e){typeof e=="function"?e=vz(e):e=pN(e);for(var t=this._groups,n=t.length,r=[],i=[],o=0;o<n;++o)for(var c=t[o],u=c.length,d,f=0;f<u;++f)(d=c[f])&&(r.push(e.call(d,d.__data__,f,c)),i.push(d));return new Ms(r,i)}function mN(e){return function(){return this.matches(e)}}function gN(e){return function(t){return t.matches(e)}}var bz=Array.prototype.find;function kz(e){return function(){return bz.call(this.children,e)}}function wz(){return this.firstElementChild}function Nz(e){return this.select(e==null?wz:kz(typeof e=="function"?e:gN(e)))}var jz=Array.prototype.filter;function Sz(){return Array.from(this.children)}function _z(e){return function(){return jz.call(this.children,e)}}function Ez(e){return this.selectAll(e==null?Sz:_z(typeof e=="function"?e:gN(e)))}function Cz(e){typeof e!="function"&&(e=mN(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],c=o.length,u=r[i]=[],d,f=0;f<c;++f)(d=o[f])&&e.call(d,d.__data__,f,o)&&u.push(d);return new Ms(r,this._parents)}function xN(e){return new Array(e.length)}function Iz(){return new Ms(this._enter||this._groups.map(xN),this._parents)}function Xu(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Xu.prototype={constructor:Xu,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Az(e){return function(){return e}}function Tz(e,t,n,r,i,o){for(var c=0,u,d=t.length,f=o.length;c<f;++c)(u=t[c])?(u.__data__=o[c],r[c]=u):n[c]=new Xu(e,o[c]);for(;c<d;++c)(u=t[c])&&(i[c]=u)}function Mz(e,t,n,r,i,o,c){var u,d,f=new Map,p=t.length,m=o.length,g=new Array(p),v;for(u=0;u<p;++u)(d=t[u])&&(g[u]=v=c.call(d,d.__data__,u,t)+"",f.has(v)?i[u]=d:f.set(v,d));for(u=0;u<m;++u)v=c.call(e,o[u],u,o)+"",(d=f.get(v))?(r[u]=d,d.__data__=o[u],f.delete(v)):n[u]=new Xu(e,o[u]);for(u=0;u<p;++u)(d=t[u])&&f.get(g[u])===d&&(i[u]=d)}function $z(e){return e.__data__}function Rz(e,t){if(!arguments.length)return Array.from(this,$z);var n=t?Mz:Tz,r=this._parents,i=this._groups;typeof e!="function"&&(e=Az(e));for(var o=i.length,c=new Array(o),u=new Array(o),d=new Array(o),f=0;f<o;++f){var p=r[f],m=i[f],g=m.length,v=Oz(e.call(p,p&&p.__data__,f,r)),y=v.length,S=u[f]=new Array(y),k=c[f]=new Array(y),w=d[f]=new Array(g);n(p,m,S,k,w,v,t);for(var T=0,N=0,$,D;T<y;++T)if($=S[T]){for(T>=N&&(N=T+1);!(D=k[N])&&++N<y;);$._next=D||null}}return c=new Ms(c,r),c._enter=u,c._exit=d,c}function Oz(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function zz(){return new Ms(this._exit||this._groups.map(xN),this._parents)}function Pz(e,t,n){var r=this.enter(),i=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function Lz(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,o=r.length,c=Math.min(i,o),u=new Array(i),d=0;d<c;++d)for(var f=n[d],p=r[d],m=f.length,g=u[d]=new Array(m),v,y=0;y<m;++y)(v=f[y]||p[y])&&(g[y]=v);for(;d<i;++d)u[d]=n[d];return new Ms(u,this._parents)}function Dz(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,o=r[i],c;--i>=0;)(c=r[i])&&(o&&c.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(c,o),o=c);return this}function Fz(e){e||(e=Bz);function t(m,g){return m&&g?e(m.__data__,g.__data__):!m-!g}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var c=n[o],u=c.length,d=i[o]=new Array(u),f,p=0;p<u;++p)(f=c[p])&&(d[p]=f);d.sort(t)}return new Ms(i,this._parents).order()}function Bz(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Uz(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Hz(){return Array.from(this)}function Zz(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length;i<o;++i){var c=r[i];if(c)return c}return null}function Vz(){let e=0;for(const t of this)++e;return e}function Wz(){return!this.node()}function qz(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],o=0,c=i.length,u;o<c;++o)(u=i[o])&&e.call(u,u.__data__,o,i);return this}function Gz(e){return function(){this.removeAttribute(e)}}function Kz(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Yz(e,t){return function(){this.setAttribute(e,t)}}function Xz(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Qz(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Jz(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function eP(e,t){var n=wd(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?Kz:Gz:typeof t=="function"?n.local?Jz:Qz:n.local?Xz:Yz)(n,t))}function vN(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function tP(e){return function(){this.style.removeProperty(e)}}function nP(e,t,n){return function(){this.style.setProperty(e,t,n)}}function sP(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function rP(e,t,n){return arguments.length>1?this.each((t==null?tP:typeof t=="function"?sP:nP)(e,t,n??"")):Mo(this.node(),e)}function Mo(e,t){return e.style.getPropertyValue(t)||vN(e).getComputedStyle(e,null).getPropertyValue(t)}function iP(e){return function(){delete this[e]}}function aP(e,t){return function(){this[e]=t}}function oP(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function lP(e,t){return arguments.length>1?this.each((t==null?iP:typeof t=="function"?oP:aP)(e,t)):this.node()[e]}function yN(e){return e.trim().split(/^|\s+/)}function Vm(e){return e.classList||new bN(e)}function bN(e){this._node=e,this._names=yN(e.getAttribute("class")||"")}bN.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function kN(e,t){for(var n=Vm(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function wN(e,t){for(var n=Vm(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function cP(e){return function(){kN(this,e)}}function uP(e){return function(){wN(this,e)}}function dP(e,t){return function(){(t.apply(this,arguments)?kN:wN)(this,e)}}function fP(e,t){var n=yN(e+"");if(arguments.length<2){for(var r=Vm(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?dP:t?cP:uP)(n,t))}function hP(){this.textContent=""}function pP(e){return function(){this.textContent=e}}function mP(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function gP(e){return arguments.length?this.each(e==null?hP:(typeof e=="function"?mP:pP)(e)):this.node().textContent}function xP(){this.innerHTML=""}function vP(e){return function(){this.innerHTML=e}}function yP(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function bP(e){return arguments.length?this.each(e==null?xP:(typeof e=="function"?yP:vP)(e)):this.node().innerHTML}function kP(){this.nextSibling&&this.parentNode.appendChild(this)}function wP(){return this.each(kP)}function NP(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function jP(){return this.each(NP)}function SP(e){var t=typeof e=="function"?e:hN(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function _P(){return null}function EP(e,t){var n=typeof e=="function"?e:hN(e),r=t==null?_P:typeof t=="function"?t:Zm(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function CP(){var e=this.parentNode;e&&e.removeChild(this)}function IP(){return this.each(CP)}function AP(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function TP(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function MP(e){return this.select(e?TP:AP)}function $P(e){return arguments.length?this.property("__data__",e):this.node().__data__}function RP(e){return function(t){e.call(this,t,this.__data__)}}function OP(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function zP(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,o;n<i;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function PP(e,t,n){return function(){var r=this.__on,i,o=RP(t);if(r){for(var c=0,u=r.length;c<u;++c)if((i=r[c]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=t;return}}this.addEventListener(e.type,o,n),i={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(i):this.__on=[i]}}function LP(e,t,n){var r=OP(e+""),i,o=r.length,c;if(arguments.length<2){var u=this.node().__on;if(u){for(var d=0,f=u.length,p;d<f;++d)for(i=0,p=u[d];i<o;++i)if((c=r[i]).type===p.type&&c.name===p.name)return p.value}return}for(u=t?PP:zP,i=0;i<o;++i)this.each(u(r[i],t,n));return this}function NN(e,t,n){var r=vN(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function DP(e,t){return function(){return NN(this,e,t)}}function FP(e,t){return function(){return NN(this,e,t.apply(this,arguments))}}function BP(e,t){return this.each((typeof t=="function"?FP:DP)(e,t))}function*UP(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length,c;i<o;++i)(c=r[i])&&(yield c)}var jN=[null];function Ms(e,t){this._groups=e,this._parents=t}function cc(){return new Ms([[document.documentElement]],jN)}function HP(){return this}Ms.prototype=cc.prototype={constructor:Ms,select:mz,selectAll:yz,selectChild:Nz,selectChildren:Ez,filter:Cz,data:Rz,enter:Iz,exit:zz,join:Pz,merge:Lz,selection:HP,order:Dz,sort:Fz,call:Uz,nodes:Hz,node:Zz,size:Vz,empty:Wz,each:qz,attr:eP,style:rP,property:lP,classed:fP,text:gP,html:bP,raise:wP,lower:jP,append:SP,insert:EP,remove:IP,clone:MP,datum:$P,on:LP,dispatch:BP,[Symbol.iterator]:UP};function As(e){return typeof e=="string"?new Ms([[document.querySelector(e)]],[document.documentElement]):new Ms([[e]],jN)}function ZP(e){let t;for(;t=e.sourceEvent;)e=t;return e}function dr(e,t){if(e=ZP(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const VP={passive:!1},Zl={capture:!0,passive:!1};function qh(e){e.stopImmediatePropagation()}function bo(e){e.preventDefault(),e.stopImmediatePropagation()}function SN(e){var t=e.document.documentElement,n=As(e).on("dragstart.drag",bo,Zl);"onselectstart"in t?n.on("selectstart.drag",bo,Zl):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function _N(e,t){var n=e.document.documentElement,r=As(e).on("dragstart.drag",null);t&&(r.on("click.drag",bo,Zl),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const wu=e=>()=>e;function Yp(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:c,y:u,dx:d,dy:f,dispatch:p}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:p}})}Yp.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function WP(e){return!e.ctrlKey&&!e.button}function qP(){return this.parentNode}function GP(e,t){return t??{x:e.x,y:e.y}}function KP(){return navigator.maxTouchPoints||"ontouchstart"in this}function EN(){var e=WP,t=qP,n=GP,r=KP,i={},o=kd("start","drag","end"),c=0,u,d,f,p,m=0;function g($){$.on("mousedown.drag",v).filter(r).on("touchstart.drag",k).on("touchmove.drag",w,VP).on("touchend.drag touchcancel.drag",T).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v($,D){if(!(p||!e.call(this,$,D))){var O=N(this,t.call(this,$,D),$,D,"mouse");O&&(As($.view).on("mousemove.drag",y,Zl).on("mouseup.drag",S,Zl),SN($.view),qh($),f=!1,u=$.clientX,d=$.clientY,O("start",$))}}function y($){if(bo($),!f){var D=$.clientX-u,O=$.clientY-d;f=D*D+O*O>m}i.mouse("drag",$)}function S($){As($.view).on("mousemove.drag mouseup.drag",null),_N($.view,f),bo($),i.mouse("end",$)}function k($,D){if(e.call(this,$,D)){var O=$.changedTouches,F=t.call(this,$,D),U=O.length,M,P;for(M=0;M<U;++M)(P=N(this,F,$,D,O[M].identifier,O[M]))&&(qh($),P("start",$,O[M]))}}function w($){var D=$.changedTouches,O=D.length,F,U;for(F=0;F<O;++F)(U=i[D[F].identifier])&&(bo($),U("drag",$,D[F]))}function T($){var D=$.changedTouches,O=D.length,F,U;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),F=0;F<O;++F)(U=i[D[F].identifier])&&(qh($),U("end",$,D[F]))}function N($,D,O,F,U,M){var P=o.copy(),R=dr(M||O,D),Z,E,C;if((C=n.call($,new Yp("beforestart",{sourceEvent:O,target:g,identifier:U,active:c,x:R[0],y:R[1],dx:0,dy:0,dispatch:P}),F))!=null)return Z=C.x-R[0]||0,E=C.y-R[1]||0,function I(L,W,H){var G=R,K;switch(L){case"start":i[U]=I,K=c++;break;case"end":delete i[U],--c;case"drag":R=dr(H||W,D),K=c;break}P.call(L,$,new Yp(L,{sourceEvent:W,subject:C,target:g,identifier:U,active:K,x:R[0]+Z,y:R[1]+E,dx:R[0]-G[0],dy:R[1]-G[1],dispatch:P}),F)}}return g.filter=function($){return arguments.length?(e=typeof $=="function"?$:wu(!!$),g):e},g.container=function($){return arguments.length?(t=typeof $=="function"?$:wu($),g):t},g.subject=function($){return arguments.length?(n=typeof $=="function"?$:wu($),g):n},g.touchable=function($){return arguments.length?(r=typeof $=="function"?$:wu(!!$),g):r},g.on=function(){var $=o.on.apply(o,arguments);return $===o?g:$},g.clickDistance=function($){return arguments.length?(m=($=+$)*$,g):Math.sqrt(m)},g}function Wm(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function CN(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function uc(){}var Vl=.7,Qu=1/Vl,ko="\\s*([+-]?\\d+)\\s*",Wl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Dr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",YP=/^#([0-9a-f]{3,8})$/,XP=new RegExp(`^rgb\\(${ko},${ko},${ko}\\)$`),QP=new RegExp(`^rgb\\(${Dr},${Dr},${Dr}\\)$`),JP=new RegExp(`^rgba\\(${ko},${ko},${ko},${Wl}\\)$`),eL=new RegExp(`^rgba\\(${Dr},${Dr},${Dr},${Wl}\\)$`),tL=new RegExp(`^hsl\\(${Wl},${Dr},${Dr}\\)$`),nL=new RegExp(`^hsla\\(${Wl},${Dr},${Dr},${Wl}\\)$`),hy={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Wm(uc,Ia,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:py,formatHex:py,formatHex8:sL,formatHsl:rL,formatRgb:my,toString:my});function py(){return this.rgb().formatHex()}function sL(){return this.rgb().formatHex8()}function rL(){return IN(this).formatHsl()}function my(){return this.rgb().formatRgb()}function Ia(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=YP.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?gy(t):n===3?new bs(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Nu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Nu(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=XP.exec(e))?new bs(t[1],t[2],t[3],1):(t=QP.exec(e))?new bs(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=JP.exec(e))?Nu(t[1],t[2],t[3],t[4]):(t=eL.exec(e))?Nu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=tL.exec(e))?yy(t[1],t[2]/100,t[3]/100,1):(t=nL.exec(e))?yy(t[1],t[2]/100,t[3]/100,t[4]):hy.hasOwnProperty(e)?gy(hy[e]):e==="transparent"?new bs(NaN,NaN,NaN,0):null}function gy(e){return new bs(e>>16&255,e>>8&255,e&255,1)}function Nu(e,t,n,r){return r<=0&&(e=t=n=NaN),new bs(e,t,n,r)}function iL(e){return e instanceof uc||(e=Ia(e)),e?(e=e.rgb(),new bs(e.r,e.g,e.b,e.opacity)):new bs}function Xp(e,t,n,r){return arguments.length===1?iL(e):new bs(e,t,n,r??1)}function bs(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Wm(bs,Xp,CN(uc,{brighter(e){return e=e==null?Qu:Math.pow(Qu,e),new bs(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Vl:Math.pow(Vl,e),new bs(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new bs(ja(this.r),ja(this.g),ja(this.b),Ju(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:xy,formatHex:xy,formatHex8:aL,formatRgb:vy,toString:vy}));function xy(){return`#${ya(this.r)}${ya(this.g)}${ya(this.b)}`}function aL(){return`#${ya(this.r)}${ya(this.g)}${ya(this.b)}${ya((isNaN(this.opacity)?1:this.opacity)*255)}`}function vy(){const e=Ju(this.opacity);return`${e===1?"rgb(":"rgba("}${ja(this.r)}, ${ja(this.g)}, ${ja(this.b)}${e===1?")":`, ${e})`}`}function Ju(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ja(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ya(e){return e=ja(e),(e<16?"0":"")+e.toString(16)}function yy(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new mr(e,t,n,r)}function IN(e){if(e instanceof mr)return new mr(e.h,e.s,e.l,e.opacity);if(e instanceof uc||(e=Ia(e)),!e)return new mr;if(e instanceof mr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),c=NaN,u=o-i,d=(o+i)/2;return u?(t===o?c=(n-r)/u+(n<r)*6:n===o?c=(r-t)/u+2:c=(t-n)/u+4,u/=d<.5?o+i:2-o-i,c*=60):u=d>0&&d<1?0:c,new mr(c,u,d,e.opacity)}function oL(e,t,n,r){return arguments.length===1?IN(e):new mr(e,t,n,r??1)}function mr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Wm(mr,oL,CN(uc,{brighter(e){return e=e==null?Qu:Math.pow(Qu,e),new mr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Vl:Math.pow(Vl,e),new mr(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new bs(Gh(e>=240?e-240:e+120,i,r),Gh(e,i,r),Gh(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new mr(by(this.h),ju(this.s),ju(this.l),Ju(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ju(this.opacity);return`${e===1?"hsl(":"hsla("}${by(this.h)}, ${ju(this.s)*100}%, ${ju(this.l)*100}%${e===1?")":`, ${e})`}`}}));function by(e){return e=(e||0)%360,e<0?e+360:e}function ju(e){return Math.max(0,Math.min(1,e||0))}function Gh(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const qm=e=>()=>e;function lL(e,t){return function(n){return e+n*t}}function cL(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function uL(e){return(e=+e)==1?AN:function(t,n){return n-t?cL(t,n,e):qm(isNaN(t)?n:t)}}function AN(e,t){var n=t-e;return n?lL(e,n):qm(isNaN(e)?t:e)}const ed=(function e(t){var n=uL(t);function r(i,o){var c=n((i=Xp(i)).r,(o=Xp(o)).r),u=n(i.g,o.g),d=n(i.b,o.b),f=AN(i.opacity,o.opacity);return function(p){return i.r=c(p),i.g=u(p),i.b=d(p),i.opacity=f(p),i+""}}return r.gamma=e,r})(1);function dL(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(o){for(i=0;i<n;++i)r[i]=e[i]*(1-o)+t[i]*o;return r}}function fL(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function hL(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),o=new Array(n),c;for(c=0;c<r;++c)i[c]=Pl(e[c],t[c]);for(;c<n;++c)o[c]=t[c];return function(u){for(c=0;c<r;++c)o[c]=i[c](u);return o}}function pL(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Lr(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function mL(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=Pl(e[i],t[i]):r[i]=t[i];return function(o){for(i in n)r[i]=n[i](o);return r}}var Qp=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Kh=new RegExp(Qp.source,"g");function gL(e){return function(){return e}}function xL(e){return function(t){return e(t)+""}}function TN(e,t){var n=Qp.lastIndex=Kh.lastIndex=0,r,i,o,c=-1,u=[],d=[];for(e=e+"",t=t+"";(r=Qp.exec(e))&&(i=Kh.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),u[c]?u[c]+=o:u[++c]=o),(r=r[0])===(i=i[0])?u[c]?u[c]+=i:u[++c]=i:(u[++c]=null,d.push({i:c,x:Lr(r,i)})),n=Kh.lastIndex;return n<t.length&&(o=t.slice(n),u[c]?u[c]+=o:u[++c]=o),u.length<2?d[0]?xL(d[0].x):gL(t):(t=d.length,function(f){for(var p=0,m;p<t;++p)u[(m=d[p]).i]=m.x(f);return u.join("")})}function Pl(e,t){var n=typeof t,r;return t==null||n==="boolean"?qm(t):(n==="number"?Lr:n==="string"?(r=Ia(t))?(t=r,ed):TN:t instanceof Ia?ed:t instanceof Date?pL:fL(t)?dL:Array.isArray(t)?hL:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?mL:Lr)(e,t)}var ky=180/Math.PI,Jp={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function MN(e,t,n,r,i,o){var c,u,d;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(d=e*n+t*r)&&(n-=e*d,r-=t*d),(u=Math.sqrt(n*n+r*r))&&(n/=u,r/=u,d/=u),e*r<t*n&&(e=-e,t=-t,d=-d,c=-c),{translateX:i,translateY:o,rotate:Math.atan2(t,e)*ky,skewX:Math.atan(d)*ky,scaleX:c,scaleY:u}}var Su;function vL(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Jp:MN(t.a,t.b,t.c,t.d,t.e,t.f)}function yL(e){return e==null||(Su||(Su=document.createElementNS("http://www.w3.org/2000/svg","g")),Su.setAttribute("transform",e),!(e=Su.transform.baseVal.consolidate()))?Jp:(e=e.matrix,MN(e.a,e.b,e.c,e.d,e.e,e.f))}function $N(e,t,n,r){function i(f){return f.length?f.pop()+" ":""}function o(f,p,m,g,v,y){if(f!==m||p!==g){var S=v.push("translate(",null,t,null,n);y.push({i:S-4,x:Lr(f,m)},{i:S-2,x:Lr(p,g)})}else(m||g)&&v.push("translate("+m+t+g+n)}function c(f,p,m,g){f!==p?(f-p>180?p+=360:p-f>180&&(f+=360),g.push({i:m.push(i(m)+"rotate(",null,r)-2,x:Lr(f,p)})):p&&m.push(i(m)+"rotate("+p+r)}function u(f,p,m,g){f!==p?g.push({i:m.push(i(m)+"skewX(",null,r)-2,x:Lr(f,p)}):p&&m.push(i(m)+"skewX("+p+r)}function d(f,p,m,g,v,y){if(f!==m||p!==g){var S=v.push(i(v)+"scale(",null,",",null,")");y.push({i:S-4,x:Lr(f,m)},{i:S-2,x:Lr(p,g)})}else(m!==1||g!==1)&&v.push(i(v)+"scale("+m+","+g+")")}return function(f,p){var m=[],g=[];return f=e(f),p=e(p),o(f.translateX,f.translateY,p.translateX,p.translateY,m,g),c(f.rotate,p.rotate,m,g),u(f.skewX,p.skewX,m,g),d(f.scaleX,f.scaleY,p.scaleX,p.scaleY,m,g),f=p=null,function(v){for(var y=-1,S=g.length,k;++y<S;)m[(k=g[y]).i]=k.x(v);return m.join("")}}}var bL=$N(vL,"px, ","px)","deg)"),kL=$N(yL,", ",")",")"),wL=1e-12;function wy(e){return((e=Math.exp(e))+1/e)/2}function NL(e){return((e=Math.exp(e))-1/e)/2}function jL(e){return((e=Math.exp(2*e))-1)/(e+1)}const zu=(function e(t,n,r){function i(o,c){var u=o[0],d=o[1],f=o[2],p=c[0],m=c[1],g=c[2],v=p-u,y=m-d,S=v*v+y*y,k,w;if(S<wL)w=Math.log(g/f)/t,k=function(F){return[u+F*v,d+F*y,f*Math.exp(t*F*w)]};else{var T=Math.sqrt(S),N=(g*g-f*f+r*S)/(2*f*n*T),$=(g*g-f*f-r*S)/(2*g*n*T),D=Math.log(Math.sqrt(N*N+1)-N),O=Math.log(Math.sqrt($*$+1)-$);w=(O-D)/t,k=function(F){var U=F*w,M=wy(D),P=f/(n*T)*(M*jL(t*U+D)-NL(D));return[u+P*v,d+P*y,f*M/wy(t*U+D)]}}return k.duration=w*1e3*t/Math.SQRT2,k}return i.rho=function(o){var c=Math.max(.001,+o),u=c*c,d=u*u;return e(c,u,d)},i})(Math.SQRT2,2,4);var $o=0,Al=0,wl=0,RN=1e3,td,Tl,nd=0,Aa=0,Nd=0,ql=typeof performance=="object"&&performance.now?performance:Date,ON=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Gm(){return Aa||(ON(SL),Aa=ql.now()+Nd)}function SL(){Aa=0}function sd(){this._call=this._time=this._next=null}sd.prototype=zN.prototype={constructor:sd,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Gm():+n)+(t==null?0:+t),!this._next&&Tl!==this&&(Tl?Tl._next=this:td=this,Tl=this),this._call=e,this._time=n,em()},stop:function(){this._call&&(this._call=null,this._time=1/0,em())}};function zN(e,t,n){var r=new sd;return r.restart(e,t,n),r}function _L(){Gm(),++$o;for(var e=td,t;e;)(t=Aa-e._time)>=0&&e._call.call(void 0,t),e=e._next;--$o}function Ny(){Aa=(nd=ql.now())+Nd,$o=Al=0;try{_L()}finally{$o=0,CL(),Aa=0}}function EL(){var e=ql.now(),t=e-nd;t>RN&&(Nd-=t,nd=e)}function CL(){for(var e,t=td,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:td=n);Tl=e,em(r)}function em(e){if(!$o){Al&&(Al=clearTimeout(Al));var t=e-Aa;t>24?(e<1/0&&(Al=setTimeout(Ny,e-ql.now()-Nd)),wl&&(wl=clearInterval(wl))):(wl||(nd=ql.now(),wl=setInterval(EL,RN)),$o=1,ON(Ny))}}function jy(e,t,n){var r=new sd;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var IL=kd("start","end","cancel","interrupt"),AL=[],PN=0,Sy=1,tm=2,Pu=3,_y=4,nm=5,Lu=6;function jd(e,t,n,r,i,o){var c=e.__transition;if(!c)e.__transition={};else if(n in c)return;TL(e,n,{name:t,index:r,group:i,on:IL,tween:AL,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:PN})}function Km(e,t){var n=jr(e,t);if(n.state>PN)throw new Error("too late; already scheduled");return n}function Fr(e,t){var n=jr(e,t);if(n.state>Pu)throw new Error("too late; already running");return n}function jr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function TL(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=zN(o,0,n.time);function o(f){n.state=Sy,n.timer.restart(c,n.delay,n.time),n.delay<=f&&c(f-n.delay)}function c(f){var p,m,g,v;if(n.state!==Sy)return d();for(p in r)if(v=r[p],v.name===n.name){if(v.state===Pu)return jy(c);v.state===_y?(v.state=Lu,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[p]):+p<t&&(v.state=Lu,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[p])}if(jy(function(){n.state===Pu&&(n.state=_y,n.timer.restart(u,n.delay,n.time),u(f))}),n.state=tm,n.on.call("start",e,e.__data__,n.index,n.group),n.state===tm){for(n.state=Pu,i=new Array(g=n.tween.length),p=0,m=-1;p<g;++p)(v=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(i[++m]=v);i.length=m+1}}function u(f){for(var p=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(d),n.state=nm,1),m=-1,g=i.length;++m<g;)i[m].call(e,p);n.state===nm&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=Lu,n.timer.stop(),delete r[t];for(var f in r)return;delete e.__transition}}function Du(e,t){var n=e.__transition,r,i,o=!0,c;if(n){t=t==null?null:t+"";for(c in n){if((r=n[c]).name!==t){o=!1;continue}i=r.state>tm&&r.state<nm,r.state=Lu,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[c]}o&&delete e.__transition}}function ML(e){return this.each(function(){Du(this,e)})}function $L(e,t){var n,r;return function(){var i=Fr(this,e),o=i.tween;if(o!==n){r=n=o;for(var c=0,u=r.length;c<u;++c)if(r[c].name===t){r=r.slice(),r.splice(c,1);break}}i.tween=r}}function RL(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Fr(this,e),c=o.tween;if(c!==r){i=(r=c).slice();for(var u={name:t,value:n},d=0,f=i.length;d<f;++d)if(i[d].name===t){i[d]=u;break}d===f&&i.push(u)}o.tween=i}}function OL(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=jr(this.node(),n).tween,i=0,o=r.length,c;i<o;++i)if((c=r[i]).name===e)return c.value;return null}return this.each((t==null?$L:RL)(n,e,t))}function Ym(e,t,n){var r=e._id;return e.each(function(){var i=Fr(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return jr(i,r).value[t]}}function LN(e,t){var n;return(typeof t=="number"?Lr:t instanceof Ia?ed:(n=Ia(t))?(t=n,ed):TN)(e,t)}function zL(e){return function(){this.removeAttribute(e)}}function PL(e){return function(){this.removeAttributeNS(e.space,e.local)}}function LL(e,t,n){var r,i=n+"",o;return function(){var c=this.getAttribute(e);return c===i?null:c===r?o:o=t(r=c,n)}}function DL(e,t,n){var r,i=n+"",o;return function(){var c=this.getAttributeNS(e.space,e.local);return c===i?null:c===r?o:o=t(r=c,n)}}function FL(e,t,n){var r,i,o;return function(){var c,u=n(this),d;return u==null?void this.removeAttribute(e):(c=this.getAttribute(e),d=u+"",c===d?null:c===r&&d===i?o:(i=d,o=t(r=c,u)))}}function BL(e,t,n){var r,i,o;return function(){var c,u=n(this),d;return u==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),d=u+"",c===d?null:c===r&&d===i?o:(i=d,o=t(r=c,u)))}}function UL(e,t){var n=wd(e),r=n==="transform"?kL:LN;return this.attrTween(e,typeof t=="function"?(n.local?BL:FL)(n,r,Ym(this,"attr."+e,t)):t==null?(n.local?PL:zL)(n):(n.local?DL:LL)(n,r,t))}function HL(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ZL(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function VL(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&ZL(e,o)),n}return i._value=t,i}function WL(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&HL(e,o)),n}return i._value=t,i}function qL(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=wd(e);return this.tween(n,(r.local?VL:WL)(r,t))}function GL(e,t){return function(){Km(this,e).delay=+t.apply(this,arguments)}}function KL(e,t){return t=+t,function(){Km(this,e).delay=t}}function YL(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?GL:KL)(t,e)):jr(this.node(),t).delay}function XL(e,t){return function(){Fr(this,e).duration=+t.apply(this,arguments)}}function QL(e,t){return t=+t,function(){Fr(this,e).duration=t}}function JL(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?XL:QL)(t,e)):jr(this.node(),t).duration}function eD(e,t){if(typeof t!="function")throw new Error;return function(){Fr(this,e).ease=t}}function tD(e){var t=this._id;return arguments.length?this.each(eD(t,e)):jr(this.node(),t).ease}function nD(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Fr(this,e).ease=n}}function sD(e){if(typeof e!="function")throw new Error;return this.each(nD(this._id,e))}function rD(e){typeof e!="function"&&(e=mN(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],c=o.length,u=r[i]=[],d,f=0;f<c;++f)(d=o[f])&&e.call(d,d.__data__,f,o)&&u.push(d);return new ui(r,this._parents,this._name,this._id)}function iD(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,o=Math.min(r,i),c=new Array(r),u=0;u<o;++u)for(var d=t[u],f=n[u],p=d.length,m=c[u]=new Array(p),g,v=0;v<p;++v)(g=d[v]||f[v])&&(m[v]=g);for(;u<r;++u)c[u]=t[u];return new ui(c,this._parents,this._name,this._id)}function aD(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function oD(e,t,n){var r,i,o=aD(t)?Km:Fr;return function(){var c=o(this,e),u=c.on;u!==r&&(i=(r=u).copy()).on(t,n),c.on=i}}function lD(e,t){var n=this._id;return arguments.length<2?jr(this.node(),n).on.on(e):this.each(oD(n,e,t))}function cD(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function uD(){return this.on("end.remove",cD(this._id))}function dD(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Zm(e));for(var r=this._groups,i=r.length,o=new Array(i),c=0;c<i;++c)for(var u=r[c],d=u.length,f=o[c]=new Array(d),p,m,g=0;g<d;++g)(p=u[g])&&(m=e.call(p,p.__data__,g,u))&&("__data__"in p&&(m.__data__=p.__data__),f[g]=m,jd(f[g],t,n,g,f,jr(p,n)));return new ui(o,this._parents,t,n)}function fD(e){var t=this._name,n=this._id;typeof e!="function"&&(e=pN(e));for(var r=this._groups,i=r.length,o=[],c=[],u=0;u<i;++u)for(var d=r[u],f=d.length,p,m=0;m<f;++m)if(p=d[m]){for(var g=e.call(p,p.__data__,m,d),v,y=jr(p,n),S=0,k=g.length;S<k;++S)(v=g[S])&&jd(v,t,n,S,g,y);o.push(g),c.push(p)}return new ui(o,c,t,n)}var hD=cc.prototype.constructor;function pD(){return new hD(this._groups,this._parents)}function mD(e,t){var n,r,i;return function(){var o=Mo(this,e),c=(this.style.removeProperty(e),Mo(this,e));return o===c?null:o===n&&c===r?i:i=t(n=o,r=c)}}function DN(e){return function(){this.style.removeProperty(e)}}function gD(e,t,n){var r,i=n+"",o;return function(){var c=Mo(this,e);return c===i?null:c===r?o:o=t(r=c,n)}}function xD(e,t,n){var r,i,o;return function(){var c=Mo(this,e),u=n(this),d=u+"";return u==null&&(d=u=(this.style.removeProperty(e),Mo(this,e))),c===d?null:c===r&&d===i?o:(i=d,o=t(r=c,u))}}function vD(e,t){var n,r,i,o="style."+t,c="end."+o,u;return function(){var d=Fr(this,e),f=d.on,p=d.value[o]==null?u||(u=DN(t)):void 0;(f!==n||i!==p)&&(r=(n=f).copy()).on(c,i=p),d.on=r}}function yD(e,t,n){var r=(e+="")=="transform"?bL:LN;return t==null?this.styleTween(e,mD(e,r)).on("end.style."+e,DN(e)):typeof t=="function"?this.styleTween(e,xD(e,r,Ym(this,"style."+e,t))).each(vD(this._id,e)):this.styleTween(e,gD(e,r,t),n).on("end.style."+e,null)}function bD(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function kD(e,t,n){var r,i;function o(){var c=t.apply(this,arguments);return c!==i&&(r=(i=c)&&bD(e,c,n)),r}return o._value=t,o}function wD(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,kD(e,t,n??""))}function ND(e){return function(){this.textContent=e}}function jD(e){return function(){var t=e(this);this.textContent=t??""}}function SD(e){return this.tween("text",typeof e=="function"?jD(Ym(this,"text",e)):ND(e==null?"":e+""))}function _D(e){return function(t){this.textContent=e.call(this,t)}}function ED(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&_D(i)),t}return r._value=e,r}function CD(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,ED(e))}function ID(){for(var e=this._name,t=this._id,n=FN(),r=this._groups,i=r.length,o=0;o<i;++o)for(var c=r[o],u=c.length,d,f=0;f<u;++f)if(d=c[f]){var p=jr(d,t);jd(d,e,n,f,c,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new ui(r,this._parents,e,n)}function AD(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(o,c){var u={value:c},d={value:function(){--i===0&&o()}};n.each(function(){var f=Fr(this,r),p=f.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(d)),f.on=t}),i===0&&o()})}var TD=0;function ui(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function FN(){return++TD}var ri=cc.prototype;ui.prototype={constructor:ui,select:dD,selectAll:fD,selectChild:ri.selectChild,selectChildren:ri.selectChildren,filter:rD,merge:iD,selection:pD,transition:ID,call:ri.call,nodes:ri.nodes,node:ri.node,size:ri.size,empty:ri.empty,each:ri.each,on:lD,attr:UL,attrTween:qL,style:yD,styleTween:wD,text:SD,textTween:CD,remove:uD,tween:OL,delay:YL,duration:JL,ease:tD,easeVarying:sD,end:AD,[Symbol.iterator]:ri[Symbol.iterator]};function MD(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var $D={time:null,delay:0,duration:250,ease:MD};function RD(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function OD(e){var t,n;e instanceof ui?(t=e._id,e=e._name):(t=FN(),(n=$D).time=Gm(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var c=r[o],u=c.length,d,f=0;f<u;++f)(d=c[f])&&jd(d,e,t,f,c,n||RD(d,t));return new ui(r,this._parents,e,t)}cc.prototype.interrupt=ML;cc.prototype.transition=OD;const _u=e=>()=>e;function zD(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function oi(e,t,n){this.k=e,this.x=t,this.y=n}oi.prototype={constructor:oi,scale:function(e){return e===1?this:new oi(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new oi(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Sd=new oi(1,0,0);BN.prototype=oi.prototype;function BN(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Sd;return e.__zoom}function Yh(e){e.stopImmediatePropagation()}function Nl(e){e.preventDefault(),e.stopImmediatePropagation()}function PD(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function LD(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Ey(){return this.__zoom||Sd}function DD(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function FD(){return navigator.maxTouchPoints||"ontouchstart"in this}function BD(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],c=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),c>o?(o+c)/2:Math.min(0,o)||Math.max(0,c))}function UN(){var e=PD,t=LD,n=BD,r=DD,i=FD,o=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,d=zu,f=kd("start","zoom","end"),p,m,g,v=500,y=150,S=0,k=10;function w(C){C.property("__zoom",Ey).on("wheel.zoom",U,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",P).filter(i).on("touchstart.zoom",R).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",E).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(C,I,L,W){var H=C.selection?C.selection():C;H.property("__zoom",Ey),C!==H?D(C,I,L,W):H.interrupt().each(function(){O(this,arguments).event(W).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},w.scaleBy=function(C,I,L,W){w.scaleTo(C,function(){var H=this.__zoom.k,G=typeof I=="function"?I.apply(this,arguments):I;return H*G},L,W)},w.scaleTo=function(C,I,L,W){w.transform(C,function(){var H=t.apply(this,arguments),G=this.__zoom,K=L==null?$(H):typeof L=="function"?L.apply(this,arguments):L,V=G.invert(K),Y=typeof I=="function"?I.apply(this,arguments):I;return n(N(T(G,Y),K,V),H,c)},L,W)},w.translateBy=function(C,I,L,W){w.transform(C,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof L=="function"?L.apply(this,arguments):L),t.apply(this,arguments),c)},null,W)},w.translateTo=function(C,I,L,W,H){w.transform(C,function(){var G=t.apply(this,arguments),K=this.__zoom,V=W==null?$(G):typeof W=="function"?W.apply(this,arguments):W;return n(Sd.translate(V[0],V[1]).scale(K.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof L=="function"?-L.apply(this,arguments):-L),G,c)},W,H)};function T(C,I){return I=Math.max(o[0],Math.min(o[1],I)),I===C.k?C:new oi(I,C.x,C.y)}function N(C,I,L){var W=I[0]-L[0]*C.k,H=I[1]-L[1]*C.k;return W===C.x&&H===C.y?C:new oi(C.k,W,H)}function $(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function D(C,I,L,W){C.on("start.zoom",function(){O(this,arguments).event(W).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(W).end()}).tween("zoom",function(){var H=this,G=arguments,K=O(H,G).event(W),V=t.apply(H,G),Y=L==null?$(V):typeof L=="function"?L.apply(H,G):L,fe=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),xe=H.__zoom,me=typeof I=="function"?I.apply(H,G):I,ie=d(xe.invert(Y).concat(fe/xe.k),me.invert(Y).concat(fe/me.k));return function(ke){if(ke===1)ke=me;else{var ae=ie(ke),Ne=fe/ae[2];ke=new oi(Ne,Y[0]-ae[0]*Ne,Y[1]-ae[1]*Ne)}K.zoom(null,ke)}})}function O(C,I,L){return!L&&C.__zooming||new F(C,I)}function F(C,I){this.that=C,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(C,I),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,I){return this.mouse&&C!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var I=As(this.that).datum();f.call(C,this.that,new zD(C,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:f}),I)}};function U(C,...I){if(!e.apply(this,arguments))return;var L=O(this,I).event(C),W=this.__zoom,H=Math.max(o[0],Math.min(o[1],W.k*Math.pow(2,r.apply(this,arguments)))),G=dr(C);if(L.wheel)(L.mouse[0][0]!==G[0]||L.mouse[0][1]!==G[1])&&(L.mouse[1]=W.invert(L.mouse[0]=G)),clearTimeout(L.wheel);else{if(W.k===H)return;L.mouse=[G,W.invert(G)],Du(this),L.start()}Nl(C),L.wheel=setTimeout(K,y),L.zoom("mouse",n(N(T(W,H),L.mouse[0],L.mouse[1]),L.extent,c));function K(){L.wheel=null,L.end()}}function M(C,...I){if(g||!e.apply(this,arguments))return;var L=C.currentTarget,W=O(this,I,!0).event(C),H=As(C.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",fe,!0),G=dr(C,L),K=C.clientX,V=C.clientY;SN(C.view),Yh(C),W.mouse=[G,this.__zoom.invert(G)],Du(this),W.start();function Y(xe){if(Nl(xe),!W.moved){var me=xe.clientX-K,ie=xe.clientY-V;W.moved=me*me+ie*ie>S}W.event(xe).zoom("mouse",n(N(W.that.__zoom,W.mouse[0]=dr(xe,L),W.mouse[1]),W.extent,c))}function fe(xe){H.on("mousemove.zoom mouseup.zoom",null),_N(xe.view,W.moved),Nl(xe),W.event(xe).end()}}function P(C,...I){if(e.apply(this,arguments)){var L=this.__zoom,W=dr(C.changedTouches?C.changedTouches[0]:C,this),H=L.invert(W),G=L.k*(C.shiftKey?.5:2),K=n(N(T(L,G),W,H),t.apply(this,I),c);Nl(C),u>0?As(this).transition().duration(u).call(D,K,W,C):As(this).call(w.transform,K,W,C)}}function R(C,...I){if(e.apply(this,arguments)){var L=C.touches,W=L.length,H=O(this,I,C.changedTouches.length===W).event(C),G,K,V,Y;for(Yh(C),K=0;K<W;++K)V=L[K],Y=dr(V,this),Y=[Y,this.__zoom.invert(Y),V.identifier],H.touch0?!H.touch1&&H.touch0[2]!==Y[2]&&(H.touch1=Y,H.taps=0):(H.touch0=Y,G=!0,H.taps=1+!!p);p&&(p=clearTimeout(p)),G&&(H.taps<2&&(m=Y[0],p=setTimeout(function(){p=null},v)),Du(this),H.start())}}function Z(C,...I){if(this.__zooming){var L=O(this,I).event(C),W=C.changedTouches,H=W.length,G,K,V,Y;for(Nl(C),G=0;G<H;++G)K=W[G],V=dr(K,this),L.touch0&&L.touch0[2]===K.identifier?L.touch0[0]=V:L.touch1&&L.touch1[2]===K.identifier&&(L.touch1[0]=V);if(K=L.that.__zoom,L.touch1){var fe=L.touch0[0],xe=L.touch0[1],me=L.touch1[0],ie=L.touch1[1],ke=(ke=me[0]-fe[0])*ke+(ke=me[1]-fe[1])*ke,ae=(ae=ie[0]-xe[0])*ae+(ae=ie[1]-xe[1])*ae;K=T(K,Math.sqrt(ke/ae)),V=[(fe[0]+me[0])/2,(fe[1]+me[1])/2],Y=[(xe[0]+ie[0])/2,(xe[1]+ie[1])/2]}else if(L.touch0)V=L.touch0[0],Y=L.touch0[1];else return;L.zoom("touch",n(N(K,V,Y),L.extent,c))}}function E(C,...I){if(this.__zooming){var L=O(this,I).event(C),W=C.changedTouches,H=W.length,G,K;for(Yh(C),g&&clearTimeout(g),g=setTimeout(function(){g=null},v),G=0;G<H;++G)K=W[G],L.touch0&&L.touch0[2]===K.identifier?delete L.touch0:L.touch1&&L.touch1[2]===K.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(K=dr(K,this),Math.hypot(m[0]-K[0],m[1]-K[1])<k)){var V=As(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return w.wheelDelta=function(C){return arguments.length?(r=typeof C=="function"?C:_u(+C),w):r},w.filter=function(C){return arguments.length?(e=typeof C=="function"?C:_u(!!C),w):e},w.touchable=function(C){return arguments.length?(i=typeof C=="function"?C:_u(!!C),w):i},w.extent=function(C){return arguments.length?(t=typeof C=="function"?C:_u([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),w):t},w.scaleExtent=function(C){return arguments.length?(o[0]=+C[0],o[1]=+C[1],w):[o[0],o[1]]},w.translateExtent=function(C){return arguments.length?(c[0][0]=+C[0][0],c[1][0]=+C[1][0],c[0][1]=+C[0][1],c[1][1]=+C[1][1],w):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},w.constrain=function(C){return arguments.length?(n=C,w):n},w.duration=function(C){return arguments.length?(u=+C,w):u},w.interpolate=function(C){return arguments.length?(d=C,w):d},w.on=function(){var C=f.on.apply(f,arguments);return C===f?w:C},w.clickDistance=function(C){return arguments.length?(S=(C=+C)*C,w):Math.sqrt(S)},w.tapDistance=function(C){return arguments.length?(k=+C,w):k},w}const Nr={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Gl=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],HN=["Enter"," ","Escape"],ZN={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Ro;(function(e){e.Strict="strict",e.Loose="loose"})(Ro||(Ro={}));var Sa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Sa||(Sa={}));var Kl;(function(e){e.Partial="partial",e.Full="full"})(Kl||(Kl={}));const VN={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Pi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Pi||(Pi={}));var rd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(rd||(rd={}));var Qe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Qe||(Qe={}));const Cy={[Qe.Left]:Qe.Right,[Qe.Right]:Qe.Left,[Qe.Top]:Qe.Bottom,[Qe.Bottom]:Qe.Top},WN=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,UD=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Xm=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),dc=(e,t=[0,0])=>{const{width:n,height:r}=Sr(e),i=e.origin??t,o=n*i[0],c=r*i[1];return{x:e.position.x-o,y:e.position.y-c}},HD=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const r=e.reduce((i,o)=>{const c=typeof o=="string";let u=!t.nodeLookup&&!c?o:void 0;return t.nodeLookup&&(u=c?t.nodeLookup.get(o):Xm(o)?o:t.nodeLookup.get(o.id)),u?(n=!0,_d(i,id(u,t.nodeOrigin))):i},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Ed(r):{x:0,y:0,width:0,height:0}},fc=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(i=>{(t.filter===void 0||t.filter(i))&&(n=_d(n,id(i)),r=!0)}),r?Ed(n):{x:0,y:0,width:0,height:0}},Qm=(e,t,[n,r,i]=[0,0,1],o=!1,c=!1)=>{const u=(t.x-n)/i,d=(t.y-r)/i,f=t.width/i,p=t.height/i,m=[];for(const g of e.values()){const{measured:v,selectable:y=!0,hidden:S=!1}=g;if(c&&!y||S)continue;const k=v.width??g.width??g.initialWidth??0,w=v.height??g.height??g.initialHeight??0,{x:T,y:N}=g.internals.positionAbsolute,$=YN(u,d,f,p,T,N,k,w),D=k*w,O=o&&$>0;(!g.internals.handleBounds||O||$>=D||g.dragging)&&m.push(g)}return m},ZD=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function VD(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(i=>i.id)):null;return e.forEach(i=>{let o;if(t!=null&&t.includeHiddenNodes){const{width:c,height:u}=Sr(i);o=c>0&&u>0}else o=!!(i.measured.width&&i.measured.height&&!i.hidden);o&&(!r||r.has(i.id))&&n.set(i.id,i)}),n}async function WD({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:o},c){if(e.size===0)return!0;const u=VD(e,c),d=fc(u),f=eg(d,t,n,(c==null?void 0:c.minZoom)??i,(c==null?void 0:c.maxZoom)??o,(c==null?void 0:c.padding)??.1);return await r.setViewport(f,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function qN({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:o}){const c=n.get(e),u=c.parentId?n.get(c.parentId):void 0,{x:d,y:f}=u?u.internals.positionAbsolute:{x:0,y:0},p=c.origin??r;let m=c.extent||i;if(c.extent==="parent"&&!c.expandParent)if(!u)o==null||o("005",Nr.error005());else{const{width:v,height:y}=Sr(u);v&&y&&(m=[[d,f],[d+v,f+y]])}else u&&Ma(c.extent)&&(m=[[c.extent[0][0]+d,c.extent[0][1]+f],[c.extent[1][0]+d,c.extent[1][1]+f]]);const g=Ma(m)?Ta(t,m,c.measured):t;return(c.measured.width===void 0||c.measured.height===void 0)&&(o==null||o("015",Nr.error015())),{position:{x:g.x-d+(c.measured.width??0)*p[0],y:g.y-f+(c.measured.height??0)*p[1]},positionAbsolute:g}}async function qD({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){const o=new Set(e.map(g=>g.id)),c=[];for(const g of n){if(g.deletable===!1)continue;const v=o.has(g.id),y=!v&&g.parentId&&c.find(S=>S.id===g.parentId);(v||y)&&c.push(g)}const u=new Set(t.map(g=>g.id)),d=r.filter(g=>g.deletable!==!1),p=ZD(c,d);for(const g of d)u.has(g.id)&&!p.find(y=>y.id===g.id)&&p.push(g);if(!i)return{edges:p,nodes:c};const m=await i({nodes:c,edges:p});return typeof m=="boolean"?m?{edges:p,nodes:c}:{edges:[],nodes:[]}:m}const Oo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ta=(e={x:0,y:0},t,n)=>({x:Oo(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Oo(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function GN(e,t,n){const{width:r,height:i}=Sr(n),{x:o,y:c}=n.internals.positionAbsolute;return Ta(e,[[o,c],[o+r,c+i]],t)}const Iy=(e,t,n)=>e<t?Oo(Math.abs(e-t),1,t)/t:e>n?-Oo(Math.abs(e-n),1,t)/t:0,Jm=(e,t,n=15,r=40)=>{const i=Iy(e.x,r,t.width-r)*n,o=Iy(e.y,r,t.height-r)*n;return[i,o]},_d=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),sm=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ed=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Yl=(e,t=[0,0])=>{var i,o;const{x:n,y:r}=Xm(e)?e.internals.positionAbsolute:dc(e,t);return{x:n,y:r,width:((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},id=(e,t=[0,0])=>{var i,o;const{x:n,y:r}=Xm(e)?e.internals.positionAbsolute:dc(e,t);return{x:n,y:r,x2:n+(((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0),y2:r+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},KN=(e,t)=>Ed(_d(sm(e),sm(t))),YN=(e,t,n,r,i,o,c,u)=>{const d=Math.max(0,Math.min(e+n,i+c)-Math.max(e,i)),f=Math.max(0,Math.min(t+r,o+u)-Math.max(t,o));return Math.ceil(d*f)},ad=(e,t)=>YN(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Ay=e=>vr(e.width)&&vr(e.height)&&vr(e.x)&&vr(e.y),vr=e=>!isNaN(e)&&isFinite(e),XN=(e,t)=>(n,r)=>{},hc=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),pc=({x:e,y:t},[n,r,i],o=!1,c=[1,1])=>{const u={x:(e-n)/i,y:(t-r)/i};return o?hc(u,c):u},zo=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function oo(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function GD(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=oo(e,n),i=oo(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e=="object"){const r=oo(e.top??e.y??0,n),i=oo(e.bottom??e.y??0,n),o=oo(e.left??e.x??0,t),c=oo(e.right??e.x??0,t);return{top:r,right:c,bottom:i,left:o,x:o+c,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function KD(e,t,n,r,i,o){const{x:c,y:u}=zo(e,[t,n,r]),{x:d,y:f}=zo({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=i-d,m=o-f;return{left:Math.floor(c),top:Math.floor(u),right:Math.floor(p),bottom:Math.floor(m)}}const eg=(e,t,n,r,i,o)=>{const c=GD(o,t,n),u=(t-c.x)/e.width,d=(n-c.y)/e.height,f=Math.min(u,d),p=Oo(f,r,i),m=e.x+e.width/2,g=e.y+e.height/2,v=t/2-m*p,y=n/2-g*p,S=KD(e,v,y,p,t,n),k={left:Math.min(S.left-c.left,0),top:Math.min(S.top-c.top,0),right:Math.min(S.right-c.right,0),bottom:Math.min(S.bottom-c.bottom,0)};return{x:v-k.left+k.right,y:y-k.top+k.bottom,zoom:p}},Xl=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ma(e){return e!=null&&e!=="parent"}function Sr(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function QN(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function JN(e,t={width:0,height:0},n,r,i){const o={...e},c=r.get(n);if(c){const u=c.origin||i;o.x+=c.internals.positionAbsolute.x-(t.width??0)*u[0],o.y+=c.internals.positionAbsolute.y-(t.height??0)*u[1]}return o}function Ty(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function YD(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function XD(e){return{...ZN,...e||{}}}function ej(e){return e===null?null:e?"valid":"invalid"}function Ll(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){const{x:o,y:c}=yr(e),u=pc({x:o-((i==null?void 0:i.left)??0),y:c-((i==null?void 0:i.top)??0)},r),{x:d,y:f}=n?hc(u,t):u;return{xSnapped:d,ySnapped:f,...u}}const tg=e=>({width:e.offsetWidth,height:e.offsetHeight}),tj=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},QD=["INPUT","SELECT","TEXTAREA"];function nj(e){var r,i;const t=((i=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:i[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:QD.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const sj=e=>"clientX"in e,yr=(e,t)=>{var o,c;const n=sj(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,i=n?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:i-((t==null?void 0:t.top)??0)}},My=(e,t,n,r,i)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(c=>{const u=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:i,position:c.getAttribute("data-handlepos"),x:(u.left-n.left)/r,y:(u.top-n.top)/r,...tg(c)}})};function rj({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:c,targetControlY:u}){const d=e*.125+i*.375+c*.375+n*.125,f=t*.125+o*.375+u*.375+r*.125,p=Math.abs(d-e),m=Math.abs(f-t);return[d,f,p,m]}function Eu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function $y({pos:e,x1:t,y1:n,x2:r,y2:i,c:o}){switch(e){case Qe.Left:return[t-Eu(t-r,o),n];case Qe.Right:return[t+Eu(r-t,o),n];case Qe.Top:return[t,n-Eu(n-i,o)];case Qe.Bottom:return[t,n+Eu(i-n,o)]}}function ij({sourceX:e,sourceY:t,sourcePosition:n=Qe.Bottom,targetX:r,targetY:i,targetPosition:o=Qe.Top,curvature:c=.25}){const[u,d]=$y({pos:n,x1:e,y1:t,x2:r,y2:i,c}),[f,p]=$y({pos:o,x1:r,y1:i,x2:e,y2:t,c}),[m,g,v,y]=rj({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:u,sourceControlY:d,targetControlX:f,targetControlY:p});return[`M${e},${t} C${u},${d} ${f},${p} ${r},${i}`,m,g,v,y]}function aj({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,o=n<e?n+i:n-i,c=Math.abs(r-t)/2,u=r<t?r+c:r-c;return[o,u,i,c]}function JD({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:o="basic"}){if(o==="manual")return r;const c=i&&n?r+1e3:r,u=Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0);return c+u}function e3({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){const o=_d(id(e),id(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const c={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]};return ad(c,Ed(o))>0}const t3=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,n3=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),s3=(e,t,n={})=>{var o;if(!e.source||!e.target)return(o=n.onError)==null||o.call(n,"006",Nr.error006()),t;const r=n.getEdgeId||t3;let i;return WN(e)?i={...e}:i={...e,id:r(e)},n3(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function oj({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,o,c,u]=aj({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,o,c,u]}const Ry={[Qe.Left]:{x:-1,y:0},[Qe.Right]:{x:1,y:0},[Qe.Top]:{x:0,y:-1},[Qe.Bottom]:{x:0,y:1}},r3=({source:e,sourcePosition:t=Qe.Bottom,target:n})=>t===Qe.Left||t===Qe.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Oy=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function i3({source:e,sourcePosition:t=Qe.Bottom,target:n,targetPosition:r=Qe.Top,center:i,offset:o,stepPosition:c}){const u=Ry[t],d=Ry[r],f={x:e.x+u.x*o,y:e.y+u.y*o},p={x:n.x+d.x*o,y:n.y+d.y*o},m=r3({source:f,sourcePosition:t,target:p}),g=m.x!==0?"x":"y",v=m[g];let y=[],S,k;const w={x:0,y:0},T={x:0,y:0},[,,N,$]=aj({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(u[g]*d[g]===-1){g==="x"?(S=i.x??f.x+(p.x-f.x)*c,k=i.y??(f.y+p.y)/2):(S=i.x??(f.x+p.x)/2,k=i.y??f.y+(p.y-f.y)*c);const U=[{x:S,y:f.y},{x:S,y:p.y}],M=[{x:f.x,y:k},{x:p.x,y:k}];u[g]===v?y=g==="x"?U:M:y=g==="x"?M:U}else{const U=[{x:f.x,y:p.y}],M=[{x:p.x,y:f.y}];if(g==="x"?y=u.x===v?M:U:y=u.y===v?U:M,t===r){const C=Math.abs(e[g]-n[g]);if(C<=o){const I=Math.min(o-1,o-C);u[g]===v?w[g]=(f[g]>e[g]?-1:1)*I:T[g]=(p[g]>n[g]?-1:1)*I}}if(t!==r){const C=g==="x"?"y":"x",I=u[g]===d[C],L=f[C]>p[C],W=f[C]<p[C];(u[g]===1&&(!I&&L||I&&W)||u[g]!==1&&(!I&&W||I&&L))&&(y=g==="x"?U:M)}const P={x:f.x+w.x,y:f.y+w.y},R={x:p.x+T.x,y:p.y+T.y},Z=Math.max(Math.abs(P.x-y[0].x),Math.abs(R.x-y[0].x)),E=Math.max(Math.abs(P.y-y[0].y),Math.abs(R.y-y[0].y));Z>=E?(S=(P.x+R.x)/2,k=y[0].y):(S=y[0].x,k=(P.y+R.y)/2)}const D={x:f.x+w.x,y:f.y+w.y},O={x:p.x+T.x,y:p.y+T.y};return[[e,...D.x!==y[0].x||D.y!==y[0].y?[D]:[],...y,...O.x!==y[y.length-1].x||O.y!==y[y.length-1].y?[O]:[],n],S,k,N,$]}function a3(e,t,n,r){const i=Math.min(Oy(e,t)/2,Oy(t,n)/2,r),{x:o,y:c}=t;if(e.x===o&&o===n.x||e.y===c&&c===n.y)return`L${o} ${c}`;if(e.y===c){const f=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${o+i*f},${c}Q ${o},${c} ${o},${c+i*p}`}const u=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${c+i*d}Q ${o},${c} ${o+i*u},${c}`}function rm({sourceX:e,sourceY:t,sourcePosition:n=Qe.Bottom,targetX:r,targetY:i,targetPosition:o=Qe.Top,borderRadius:c=5,centerX:u,centerY:d,offset:f=20,stepPosition:p=.5}){const[m,g,v,y,S]=i3({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:o,center:{x:u,y:d},offset:f,stepPosition:p});let k=`M${m[0].x} ${m[0].y}`;for(let w=1;w<m.length-1;w++)k+=a3(m[w-1],m[w],m[w+1],c);return k+=`L${m[m.length-1].x} ${m[m.length-1].y}`,[k,g,v,y,S]}function zy(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function o3(e){var m;const{sourceNode:t,targetNode:n}=e;if(!zy(t)||!zy(n))return null;const r=t.internals.handleBounds||Py(t.handles),i=n.internals.handleBounds||Py(n.handles),o=Ly((r==null?void 0:r.source)??[],e.sourceHandle),c=Ly(e.connectionMode===Ro.Strict?(i==null?void 0:i.target)??[]:((i==null?void 0:i.target)??[]).concat((i==null?void 0:i.source)??[]),e.targetHandle);if(!o||!c)return(m=e.onError)==null||m.call(e,"008",Nr.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const u=(o==null?void 0:o.position)||Qe.Bottom,d=(c==null?void 0:c.position)||Qe.Top,f=$a(t,o,u),p=$a(n,c,d);return{sourceX:f.x,sourceY:f.y,targetX:p.x,targetY:p.y,sourcePosition:u,targetPosition:d}}function Py(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function $a(e,t,n=Qe.Left,r=!1){const i=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:c,height:u}=t??Sr(e);if(r)return{x:i+c/2,y:o+u/2};switch((t==null?void 0:t.position)??n){case Qe.Top:return{x:i+c/2,y:o};case Qe.Right:return{x:i+c,y:o+u/2};case Qe.Bottom:return{x:i+c/2,y:o+u};case Qe.Left:return{x:i,y:o+u/2}}}function Ly(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function im(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function l3(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){const o=new Set;return e.reduce((c,u)=>([u.markerStart||r,u.markerEnd||i].forEach(d=>{if(d&&typeof d=="object"){const f=im(d,t);o.has(f)||(c.push({id:f,color:d.color||n,...d}),o.add(f))}}),c),[]).sort((c,u)=>c.id.localeCompare(u.id))}const lj=1e3,c3=10,ng={nodeOrigin:[0,0],nodeExtent:Gl,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},u3={...ng,checkEquality:!0};function sg(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function d3(e,t,n){const r=sg(ng,n);for(const i of e.values())if(i.parentId)ig(i,e,t,r);else{const o=dc(i,r.nodeOrigin),c=Ma(i.extent)?i.extent:r.nodeExtent,u=Ta(o,c,Sr(i));i.internals.positionAbsolute=u}}function f3(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const i of e.handles){const o={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(o):i.type==="target"&&r.push(o)}return{source:n,target:r}}function rg(e){return e==="manual"}function am(e,t,n,r={}){var p,m;const i=sg(u3,r),o={i:0},c=new Map(t),u=i!=null&&i.elevateNodesOnSelect&&!rg(i.zIndexMode)?lj:0;let d=e.length>0,f=!1;t.clear(),n.clear();for(const g of e){let v=c.get(g.id);if(i.checkEquality&&g===(v==null?void 0:v.internals.userNode))t.set(g.id,v);else{const y=dc(g,i.nodeOrigin),S=Ma(g.extent)?g.extent:i.nodeExtent,k=Ta(y,S,Sr(g));v={...i.defaults,...g,measured:{width:(p=g.measured)==null?void 0:p.width,height:(m=g.measured)==null?void 0:m.height},internals:{positionAbsolute:k,handleBounds:f3(g,v),z:cj(g,u,i.zIndexMode),userNode:g}},t.set(g.id,v)}(v.measured===void 0||v.measured.width===void 0||v.measured.height===void 0)&&!v.hidden&&(d=!1),g.parentId&&ig(v,t,n,r,o),f||(f=g.selected??!1)}return{nodesInitialized:d,hasSelectedNodes:f}}function h3(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function ig(e,t,n,r,i){const{elevateNodesOnSelect:o,nodeOrigin:c,nodeExtent:u,zIndexMode:d}=sg(ng,r),f=e.parentId,p=t.get(f);if(!p){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}h3(e,n),i&&!p.parentId&&p.internals.rootParentIndex===void 0&&d==="auto"&&(p.internals.rootParentIndex=++i.i,p.internals.z=p.internals.z+i.i*c3),i&&p.internals.rootParentIndex!==void 0&&(i.i=p.internals.rootParentIndex);const m=o&&!rg(d)?lj:0,{x:g,y:v,z:y}=p3(e,p,c,u,m,d),{positionAbsolute:S}=e.internals,k=g!==S.x||v!==S.y;(k||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:k?{x:g,y:v}:S,z:y}})}function cj(e,t,n){const r=vr(e.zIndex)?e.zIndex:0;return rg(n)?r:r+(e.selected?t:0)}function p3(e,t,n,r,i,o){const{x:c,y:u}=t.internals.positionAbsolute,d=Sr(e),f=dc(e,n),p=Ma(e.extent)?Ta(f,e.extent,d):f;let m=Ta({x:c+p.x,y:u+p.y},r,d);e.extent==="parent"&&(m=GN(m,d,t));const g=cj(e,i,o),v=t.internals.z??0;return{x:m.x,y:m.y,z:v>=g?v+1:g}}function ag(e,t,n,r=[0,0]){var c;const i=[],o=new Map;for(const u of e){const d=t.get(u.parentId);if(!d)continue;const f=((c=o.get(u.parentId))==null?void 0:c.expandedRect)??Yl(d),p=KN(f,u.rect);o.set(u.parentId,{expandedRect:p,parent:d})}return o.size>0&&o.forEach(({expandedRect:u,parent:d},f)=>{var N;const p=d.internals.positionAbsolute,m=Sr(d),g=d.origin??r,v=u.x<p.x?Math.round(Math.abs(p.x-u.x)):0,y=u.y<p.y?Math.round(Math.abs(p.y-u.y)):0,S=Math.max(m.width,Math.round(u.width)),k=Math.max(m.height,Math.round(u.height)),w=(S-m.width)*g[0],T=(k-m.height)*g[1];(v>0||y>0||w||T)&&(i.push({id:f,type:"position",position:{x:d.position.x-v+w,y:d.position.y-y+T}}),(N=n.get(f))==null||N.forEach($=>{e.some(D=>D.id===$.id)||i.push({id:$.id,type:"position",position:{x:$.position.x+v,y:$.position.y+y}})})),(m.width<u.width||m.height<u.height||v||y)&&i.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:S+(v?g[0]*v-w:0),height:k+(y?g[1]*y-T:0)}})}),i}function m3(e,t,n,r,i,o,c){const u=r==null?void 0:r.querySelector(".xyflow__viewport");let d=!1;if(!u)return{changes:[],updatedInternals:d};const f=[],p=window.getComputedStyle(u),{m22:m}=new window.DOMMatrixReadOnly(p.transform),g=[];for(const v of e.values()){const y=t.get(v.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),d=!0;continue}const S=tg(v.nodeElement),k=y.measured.width!==S.width||y.measured.height!==S.height;if(!!(S.width&&S.height&&(k||!y.internals.handleBounds||v.force))){const T=v.nodeElement.getBoundingClientRect(),N=Ma(y.extent)?y.extent:o;let{positionAbsolute:$}=y.internals;if(y.parentId&&y.extent==="parent"){const O=t.get(y.parentId);O&&($=GN($,S,O))}else N&&($=Ta($,N,S));const D={...y,measured:S,internals:{...y.internals,positionAbsolute:$,handleBounds:{source:My("source",v.nodeElement,T,m,y.id),target:My("target",v.nodeElement,T,m,y.id)}}};t.set(y.id,D),y.parentId&&ig(D,t,n,{nodeOrigin:i,zIndexMode:c}),d=!0,k&&(f.push({id:y.id,type:"dimensions",dimensions:S}),y.expandParent&&y.parentId&&g.push({id:y.id,parentId:y.parentId,rect:Yl(D,i)}))}}if(g.length>0){const v=ag(g,t,n,i);f.push(...v)}return{changes:f,updatedInternals:d}}async function g3({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:o}){if(!t||!e.x&&!e.y)return!1;const c=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,o]],r);return!!c&&(c.x!==n[0]||c.y!==n[1]||c.k!==n[2])}function Dy(e,t,n,r,i,o){let c=i;const u=r.get(c)||new Map;r.set(c,u.set(n,t)),c=`${i}-${e}`;const d=r.get(c)||new Map;if(r.set(c,d.set(n,t)),o){c=`${i}-${e}-${o}`;const f=r.get(c)||new Map;r.set(c,f.set(n,t))}}function uj(e,t,n){e.clear(),t.clear();for(const r of n){const{source:i,target:o,sourceHandle:c=null,targetHandle:u=null}=r,d={edgeId:r.id,source:i,target:o,sourceHandle:c,targetHandle:u},f=`${i}-${c}--${o}-${u}`,p=`${o}-${u}--${i}-${c}`;Dy("source",d,p,e,i,c),Dy("target",d,f,e,o,u),t.set(r.id,r)}}function dj(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:dj(n,t):!1}function Fy(e,t,n){var i;let r=e;do{if((i=r==null?void 0:r.matches)!=null&&i.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function x3(e,t,n,r){const i=new Map;for(const[o,c]of e)if((c.selected||c.id===r)&&(!c.parentId||!dj(c,e))&&(c.draggable||t&&typeof c.draggable>"u")){const u=e.get(o);u&&i.set(o,{id:o,position:u.position||{x:0,y:0},distance:{x:n.x-u.internals.positionAbsolute.x,y:n.y-u.internals.positionAbsolute.y},extent:u.extent,parentId:u.parentId,origin:u.origin,expandParent:u.expandParent,internals:{positionAbsolute:u.internals.positionAbsolute||{x:0,y:0}},measured:{width:u.measured.width??0,height:u.measured.height??0}})}return i}function Xh({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var c,u,d;const i=[];for(const[f,p]of t){const m=(c=n.get(f))==null?void 0:c.internals.userNode;m&&i.push({...m,position:p.position,dragging:r})}if(!e)return[i[0],i];const o=(u=n.get(e))==null?void 0:u.internals.userNode;return[o?{...o,position:((d=t.get(e))==null?void 0:d.position)||o.position,dragging:r}:i[0],i]}function v3({dragItems:e,snapGrid:t,x:n,y:r}){const i=e.values().next().value;if(!i)return null;const o={x:n-i.distance.x,y:r-i.distance.y},c=hc(o,t);return{x:c.x-o.x,y:c.y-o.y}}function y3({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let o={x:null,y:null},c=0,u=new Map,d=!1,f={x:0,y:0},p=null,m=!1,g=null,v=!1,y=!1,S=null;function k({noDragClassName:T,handleSelector:N,domNode:$,isSelectable:D,nodeId:O,nodeClickDistance:F=0}){g=As($);function U({x:Z,y:E}){const{nodeLookup:C,nodeExtent:I,snapGrid:L,snapToGrid:W,nodeOrigin:H,onNodeDrag:G,onSelectionDrag:K,onError:V,updateNodePositions:Y}=t();o={x:Z,y:E};let fe=!1;const xe=u.size>1,me=xe&&I?sm(fc(u)):null,ie=xe&&W?v3({dragItems:u,snapGrid:L,x:Z,y:E}):null;for(const[ke,ae]of u){if(!C.has(ke))continue;let Ne={x:Z-ae.distance.x,y:E-ae.distance.y};W&&(Ne=ie?{x:Math.round(Ne.x+ie.x),y:Math.round(Ne.y+ie.y)}:hc(Ne,L));let Fe=null;if(xe&&I&&!ae.extent&&me){const{positionAbsolute:re}=ae.internals,he=re.x-me.x+I[0][0],ze=re.x+ae.measured.width-me.x2+I[1][0],Te=re.y-me.y+I[0][1],Ge=re.y+ae.measured.height-me.y2+I[1][1];Fe=[[he,Te],[ze,Ge]]}const{position:ce,positionAbsolute:je}=qN({nodeId:ke,nextPosition:Ne,nodeLookup:C,nodeExtent:Fe||I,nodeOrigin:H,onError:V});fe=fe||ae.position.x!==ce.x||ae.position.y!==ce.y,ae.position=ce,ae.internals.positionAbsolute=je}if(y=y||fe,!!fe&&(Y(u,!0),S&&(r||G||!O&&K))){const[ke,ae]=Xh({nodeId:O,dragItems:u,nodeLookup:C});r==null||r(S,u,ke,ae),G==null||G(S,ke,ae),O||K==null||K(S,ae)}}async function M(){if(!p)return;const{transform:Z,panBy:E,autoPanSpeed:C,autoPanOnNodeDrag:I}=t();if(!I){d=!1,cancelAnimationFrame(c);return}const[L,W]=Jm(f,p,C);(L!==0||W!==0)&&(o.x=(o.x??0)-L/Z[2],o.y=(o.y??0)-W/Z[2],await E({x:L,y:W})&&U(o)),c=requestAnimationFrame(M)}function P(Z){var xe;const{nodeLookup:E,multiSelectionActive:C,nodesDraggable:I,transform:L,snapGrid:W,snapToGrid:H,selectNodesOnDrag:G,onNodeDragStart:K,onSelectionDragStart:V,unselectNodesAndEdges:Y}=t();m=!0,(!G||!D)&&!C&&O&&((xe=E.get(O))!=null&&xe.selected||Y()),D&&G&&O&&(e==null||e(O));const fe=Ll(Z.sourceEvent,{transform:L,snapGrid:W,snapToGrid:H,containerBounds:p});if(o=fe,u=x3(E,I,fe,O),u.size>0&&(n||K||!O&&V)){const[me,ie]=Xh({nodeId:O,dragItems:u,nodeLookup:E});n==null||n(Z.sourceEvent,u,me,ie),K==null||K(Z.sourceEvent,me,ie),O||V==null||V(Z.sourceEvent,ie)}}const R=EN().clickDistance(F).on("start",Z=>{const{domNode:E,nodeDragThreshold:C,transform:I,snapGrid:L,snapToGrid:W}=t();p=(E==null?void 0:E.getBoundingClientRect())||null,v=!1,y=!1,S=Z.sourceEvent,C===0&&P(Z),o=Ll(Z.sourceEvent,{transform:I,snapGrid:L,snapToGrid:W,containerBounds:p}),f=yr(Z.sourceEvent,p)}).on("drag",Z=>{const{autoPanOnNodeDrag:E,transform:C,snapGrid:I,snapToGrid:L,nodeDragThreshold:W,nodeLookup:H}=t(),G=Ll(Z.sourceEvent,{transform:C,snapGrid:I,snapToGrid:L,containerBounds:p});if(S=Z.sourceEvent,(Z.sourceEvent.type==="touchmove"&&Z.sourceEvent.touches.length>1||O&&!H.has(O))&&(v=!0),!v){if(!d&&E&&m&&(d=!0,M()),!m){const K=yr(Z.sourceEvent,p),V=K.x-f.x,Y=K.y-f.y;Math.sqrt(V*V+Y*Y)>W&&P(Z)}(o.x!==G.xSnapped||o.y!==G.ySnapped)&&u&&m&&(f=yr(Z.sourceEvent,p),U(G))}}).on("end",Z=>{if(!m||v){v&&u.size>0&&t().updateNodePositions(u,!1);return}if(d=!1,m=!1,cancelAnimationFrame(c),u.size>0){const{nodeLookup:E,updateNodePositions:C,onNodeDragStop:I,onSelectionDragStop:L}=t();if(y&&(C(u,!1),y=!1),i||I||!O&&L){const[W,H]=Xh({nodeId:O,dragItems:u,nodeLookup:E,dragging:!1});i==null||i(Z.sourceEvent,u,W,H),I==null||I(Z.sourceEvent,W,H),O||L==null||L(Z.sourceEvent,H)}}}).filter(Z=>{const E=Z.target;return!Z.button&&(!T||!Fy(E,`.${T}`,$))&&(!N||Fy(E,N,$))});g.call(R)}function w(){g==null||g.on(".drag",null)}return{update:k,destroy:w}}function b3(e,t,n){const r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())ad(i,Yl(o))>0&&r.push(o);return r}const k3=250;function w3(e,t,n,r){var u,d;let i=[],o=1/0;const c=b3(e,n,t+k3);for(const f of c){const p=[...((u=f.internals.handleBounds)==null?void 0:u.source)??[],...((d=f.internals.handleBounds)==null?void 0:d.target)??[]];for(const m of p){if(r.nodeId===m.nodeId&&r.type===m.type&&r.id===m.id)continue;const{x:g,y:v}=$a(f,m,m.position,!0),y=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(v-e.y,2));y>t||(y<o?(i=[{...m,x:g,y:v}],o=y):y===o&&i.push({...m,x:g,y:v}))}}if(!i.length)return null;if(i.length>1){const f=r.type==="source"?"target":"source";return i.find(p=>p.type===f)??i[0]}return i[0]}function fj(e,t,n,r,i,o=!1){var f,p,m;const c=r.get(e);if(!c)return null;const u=i==="strict"?(f=c.internals.handleBounds)==null?void 0:f[t]:[...((p=c.internals.handleBounds)==null?void 0:p.source)??[],...((m=c.internals.handleBounds)==null?void 0:m.target)??[]],d=(n?u==null?void 0:u.find(g=>g.id===n):u==null?void 0:u[0])??null;return d&&o?{...d,...$a(c,d,d.position,!0)}:d}function hj(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function N3(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const pj=()=>!0;function j3(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:o,isTarget:c,domNode:u,nodeLookup:d,lib:f,autoPanOnConnect:p,flowId:m,panBy:g,cancelConnection:v,onConnectStart:y,onConnect:S,onConnectEnd:k,isValidConnection:w=pj,onReconnectEnd:T,updateConnection:N,getTransform:$,getFromHandle:D,autoPanSpeed:O,dragThreshold:F=1,handleDomNode:U}){const M=tj(e.target);let P=0,R;const{x:Z,y:E}=yr(e),C=hj(o,U),I=u==null?void 0:u.getBoundingClientRect();let L=!1;if(!I||!C)return;const W=fj(i,C,r,d,t);if(!W)return;let H=yr(e,I),G=!1,K=null,V=!1,Y=null;function fe(){if(!p||!I)return;const[ce,je]=Jm(H,I,O);g({x:ce,y:je}),P=requestAnimationFrame(fe)}const xe={...W,nodeId:i,type:C,position:W.position},me=d.get(i);let ke={inProgress:!0,isValid:null,from:$a(me,xe,Qe.Left,!0),fromHandle:xe,fromPosition:xe.position,fromNode:me,to:H,toHandle:null,toPosition:Cy[xe.position],toNode:null,pointer:H};function ae(){L=!0,N(ke),y==null||y(e,{nodeId:i,handleId:r,handleType:C})}F===0&&ae();function Ne(ce){if(!L){const{x:Ge,y:Ie}=yr(ce),tt=Ge-Z,et=Ie-E;if(!(tt*tt+et*et>F*F))return;ae()}if(!D()||!xe){Fe(ce);return}const je=$();H=yr(ce,I),R=w3(pc(H,je,!1,[1,1]),n,d,xe),G||(fe(),G=!0);const re=mj(ce,{handle:R,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:c?"target":"source",isValidConnection:w,doc:M,lib:f,flowId:m,nodeLookup:d});Y=re.handleDomNode,K=re.connection,V=N3(!!R,re.isValid);const he=d.get(i),ze=he?$a(he,xe,Qe.Left,!0):ke.from,Te={...ke,from:ze,isValid:V,to:re.toHandle&&V?zo({x:re.toHandle.x,y:re.toHandle.y},je):H,toHandle:re.toHandle,toPosition:V&&re.toHandle?re.toHandle.position:Cy[xe.position],toNode:re.toHandle?d.get(re.toHandle.nodeId):null,pointer:H};N(Te),ke=Te}function Fe(ce){if(!("touches"in ce&&ce.touches.length>0)){if(L){(R||Y)&&K&&V&&(S==null||S(K));const{inProgress:je,...re}=ke,he={...re,toPosition:ke.toHandle?ke.toPosition:null};k==null||k(ce,he),o&&(T==null||T(ce,he))}v(),cancelAnimationFrame(P),G=!1,V=!1,K=null,Y=null,M.removeEventListener("mousemove",Ne),M.removeEventListener("mouseup",Fe),M.removeEventListener("touchmove",Ne),M.removeEventListener("touchend",Fe)}}M.addEventListener("mousemove",Ne),M.addEventListener("mouseup",Fe),M.addEventListener("touchmove",Ne),M.addEventListener("touchend",Fe)}function mj(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:o,doc:c,lib:u,flowId:d,isValidConnection:f=pj,nodeLookup:p}){const m=o==="target",g=t?c.querySelector(`.${u}-flow__handle[data-id="${d}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:v,y}=yr(e),S=c.elementFromPoint(v,y),k=S!=null&&S.classList.contains(`${u}-flow__handle`)?S:g,w={handleDomNode:k,isValid:!1,connection:null,toHandle:null};if(k){const T=hj(void 0,k),N=k.getAttribute("data-nodeid"),$=k.getAttribute("data-handleid"),D=k.classList.contains("connectable"),O=k.classList.contains("connectableend");if(!N||!T)return w;const F={source:m?N:r,sourceHandle:m?$:i,target:m?r:N,targetHandle:m?i:$};w.connection=F;const M=D&&O&&(n===Ro.Strict?m&&T==="source"||!m&&T==="target":N!==r||$!==i);w.isValid=M&&f(F),w.toHandle=fj(N,T,$,p,n,!0)}return w}const om={onPointerDown:j3,isValid:mj};function S3({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const i=As(e);function o({translateExtent:u,width:d,height:f,zoomStep:p=1,pannable:m=!0,zoomable:g=!0,inversePan:v=!1}){const y=N=>{if(N.sourceEvent.type!=="wheel"||!t)return;const $=n(),D=N.sourceEvent.ctrlKey&&Xl()?10:1,O=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*p,F=$[2]*Math.pow(2,O*D);t.scaleTo(F)};let S=[0,0];const k=N=>{(N.sourceEvent.type==="mousedown"||N.sourceEvent.type==="touchstart")&&(S=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY])},w=N=>{const $=n();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!t)return;const D=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],O=[D[0]-S[0],D[1]-S[1]];S=D;const F=r()*Math.max($[2],Math.log($[2]))*(v?-1:1),U={x:$[0]-O[0]*F,y:$[1]-O[1]*F},M=[[0,0],[d,f]];t.setViewportConstrained({x:U.x,y:U.y,zoom:$[2]},M,u)},T=UN().on("start",k).on("zoom",m?w:null).on("zoom.wheel",g?y:null);i.call(T,{})}function c(){i.on("zoom",null)}return{update:o,destroy:c,pointer:dr}}const Cd=e=>({x:e.x,y:e.y,zoom:e.k}),Qh=({x:e,y:t,zoom:n})=>Sd.translate(e,t).scale(n),zi=(e,t)=>e.target.closest(`.${t}`),gj=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),_3=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Jh=(e,t=0,n=_3,r=()=>{})=>{const i=typeof t=="number"&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on("end",r):e},xj=e=>{const t=e.ctrlKey&&Xl()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function E3({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:o,zoomOnPinch:c,onPanZoomStart:u,onPanZoom:d,onPanZoomEnd:f}){return p=>{if(zi(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const m=n.property("__zoom").k||1;if(p.ctrlKey&&c){const k=dr(p),w=xj(p),T=m*Math.pow(2,w);r.scaleTo(n,T,k,p);return}const g=p.deltaMode===1?20:1;let v=i===Sa.Vertical?0:p.deltaX*g,y=i===Sa.Horizontal?0:p.deltaY*g;!Xl()&&p.shiftKey&&i!==Sa.Vertical&&(v=p.deltaY*g,y=0),r.translateBy(n,-(v/m)*o,-(y/m)*o,{internal:!0});const S=Cd(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?d==null||d(p,S):(e.isPanScrolling=!0,u==null||u(p,S)),e.panScrollTimeout=setTimeout(()=>{f==null||f(p,S),e.isPanScrolling=!1},150)}}function C3({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){const o=r.type==="wheel",c=!t&&o&&!r.ctrlKey,u=zi(r,e);if(r.ctrlKey&&o&&u&&r.preventDefault(),c||u)return null;r.preventDefault(),n.call(this,r,i)}}function I3({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,c,u;if((o=r.sourceEvent)!=null&&o.internal)return;const i=Cd(r.transform);e.mouseButton=((c=r.sourceEvent)==null?void 0:c.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=i,((u=r.sourceEvent)==null?void 0:u.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,i))}}function A3({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return o=>{var c,u;e.usedRightMouseButton=!!(n&&gj(t,e.mouseButton??0)),(c=o.sourceEvent)!=null&&c.sync||r([o.transform.x,o.transform.y,o.transform.k]),i&&!((u=o.sourceEvent)!=null&&u.internal)&&(i==null||i(o.sourceEvent,Cd(o.transform)))}}function T3({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:o}){return c=>{var u;if(!((u=c.sourceEvent)!=null&&u.internal)&&(e.isZoomingOrPanning=!1,o&&gj(t,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&o(c.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){const d=Cd(c.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i==null||i(c.sourceEvent,d)},n?150:0)}}}function M3({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:o,zoomOnDoubleClick:c,userSelectionActive:u,noWheelClassName:d,noPanClassName:f,lib:p,connectionInProgress:m}){return g=>{var w;const v=t||n,y=r&&g.ctrlKey,S=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(zi(g,`${p}-flow__node`)||zi(g,`${p}-flow__edge`)||zi(g,`${p}-flow__selection`)||zi(g,`${p}-flow__nodesselection`)))return!0;if(!i&&!v&&!o&&!c&&!r||u||m&&!S||zi(g,d)&&S||zi(g,f)&&(!S||o&&S&&!t)||!r&&g.ctrlKey&&S)return!1;if(!r&&g.type==="touchstart"&&((w=g.touches)==null?void 0:w.length)>1)return g.preventDefault(),!1;if(!v&&!o&&!y&&S||!i&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(i)&&!i.includes(g.button)&&g.type==="mousedown")return!1;const k=Array.isArray(i)&&i.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||S||e)&&k}}function $3({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:o,onPanZoomStart:c,onPanZoomEnd:u,onDraggingChange:d}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect();let m=[[0,0],[p.width,p.height]];const g=typeof ResizeObserver<"u"?new ResizeObserver(E=>{const C=E[0];C&&(m=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;g==null||g.observe(e);const v=UN().extent(()=>m).scaleExtent([t,n]).translateExtent(r),y=As(e).call(v);$({x:i.x,y:i.y,zoom:Oo(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const S=y.on("wheel.zoom"),k=y.on("dblclick.zoom");v.wheelDelta(xj);async function w(E,C){return y?new Promise(I=>{v==null||v.interpolate((C==null?void 0:C.interpolate)==="linear"?Pl:zu).transform(Jh(y,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>I(!0)),E)}):!1}function T({noWheelClassName:E,noPanClassName:C,onPaneContextMenu:I,userSelectionActive:L,panOnScroll:W,panOnDrag:H,panOnScrollMode:G,panOnScrollSpeed:K,preventScrolling:V,zoomOnPinch:Y,zoomOnScroll:fe,zoomOnDoubleClick:xe,panActivationKeyPressed:me=!1,zoomActivationKeyPressed:ie,lib:ke,onTransformChange:ae,connectionInProgress:Ne,paneClickDistance:Fe,selectionOnDrag:ce}){L&&!f.isZoomingOrPanning&&N();const je=W&&!ie&&!L;v.clickDistance(ce?1/0:!vr(Fe)||Fe<0?0:Fe);const re=je?E3({zoomPanValues:f,noWheelClassName:E,d3Selection:y,d3Zoom:v,panOnScrollMode:G,panOnScrollSpeed:K,zoomOnPinch:Y,onPanZoomStart:c,onPanZoom:o,onPanZoomEnd:u}):C3({noWheelClassName:E,preventScrolling:V,d3ZoomHandler:S});y.on("wheel.zoom",re,{passive:!1});const he=I3({zoomPanValues:f,onDraggingChange:d,onPanZoomStart:c});v.on("start",he);const ze=A3({zoomPanValues:f,panOnDrag:H,onPaneContextMenu:!!I,onPanZoom:o,onTransformChange:ae});v.on("zoom",ze);const Te=T3({zoomPanValues:f,panOnDrag:H,panOnScroll:W,onPaneContextMenu:I,onPanZoomEnd:u,onDraggingChange:d});v.on("end",Te);const Ge=M3({panActivationKeyPressed:me,zoomActivationKeyPressed:ie,panOnDrag:H,zoomOnScroll:fe,panOnScroll:W,zoomOnDoubleClick:xe,zoomOnPinch:Y,userSelectionActive:L,noPanClassName:C,noWheelClassName:E,lib:ke,connectionInProgress:Ne});v.filter(Ge),xe?y.on("dblclick.zoom",k):y.on("dblclick.zoom",null)}function N(){v.on("zoom",null)}async function $(E,C,I){const L=Qh(E),W=v==null?void 0:v.constrain()(L,C,I);return W&&await w(W),W}async function D(E,C){const I=Qh(E);return await w(I,C),I}function O(E){if(y){const C=Qh(E),I=y.property("__zoom");(I.k!==E.zoom||I.x!==E.x||I.y!==E.y)&&(v==null||v.transform(y,C,null,{sync:!0}))}}function F(){const E=y?BN(y.node()):{x:0,y:0,k:1};return{x:E.x,y:E.y,zoom:E.k}}async function U(E,C){return y?new Promise(I=>{v==null||v.interpolate((C==null?void 0:C.interpolate)==="linear"?Pl:zu).scaleTo(Jh(y,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>I(!0)),E)}):!1}async function M(E,C){return y?new Promise(I=>{v==null||v.interpolate((C==null?void 0:C.interpolate)==="linear"?Pl:zu).scaleBy(Jh(y,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>I(!0)),E)}):!1}function P(E){v==null||v.scaleExtent(E)}function R(E){v==null||v.translateExtent(E)}function Z(E){const C=!vr(E)||E<0?0:E;v==null||v.clickDistance(C)}return{update:T,destroy:N,setViewport:D,setViewportConstrained:$,getViewport:F,scaleTo:U,scaleBy:M,setScaleExtent:P,setTranslateExtent:R,syncViewport:O,setClickDistance:Z}}var Po;(function(e){e.Line="line",e.Handle="handle"})(Po||(Po={}));function R3({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:o}){const c=e-t,u=n-r,d=[c>0?1:c<0?-1:0,u>0?1:u<0?-1:0];return c&&i&&(d[0]=d[0]*-1),u&&o&&(d[1]=d[1]*-1),d}function By(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),i=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:i}}function Ri(e,t){return Math.max(0,t-e)}function Oi(e,t){return Math.max(0,e-t)}function Cu(e,t,n){return Math.max(0,t-e,e-n)}function Uy(e,t){return e?!t:t}function O3(e,t,n,r,i,o,c,u){let{affectsX:d,affectsY:f}=t;const{isHorizontal:p,isVertical:m}=t,g=p&&m,{xSnapped:v,ySnapped:y}=n,{minWidth:S,maxWidth:k,minHeight:w,maxHeight:T}=r,{x:N,y:$,width:D,height:O,aspectRatio:F}=e;let U=Math.floor(p?v-e.pointerX:0),M=Math.floor(m?y-e.pointerY:0);const P=D+(d?-U:U),R=O+(f?-M:M),Z=-o[0]*D,E=-o[1]*O;let C=Cu(P,S,k),I=Cu(R,w,T);if(c){let H=0,G=0;d&&U<0?H=Ri(N+U+Z,c[0][0]):!d&&U>0&&(H=Oi(N+P+Z,c[1][0])),f&&M<0?G=Ri($+M+E,c[0][1]):!f&&M>0&&(G=Oi($+R+E,c[1][1])),C=Math.max(C,H),I=Math.max(I,G)}if(u){let H=0,G=0;d&&U>0?H=Oi(N+U,u[0][0]):!d&&U<0&&(H=Ri(N+P,u[1][0])),f&&M>0?G=Oi($+M,u[0][1]):!f&&M<0&&(G=Ri($+R,u[1][1])),C=Math.max(C,H),I=Math.max(I,G)}if(i){if(p){const H=Cu(P/F,w,T)*F;if(C=Math.max(C,H),c){let G=0;!d&&!f||d&&!f&&g?G=Oi($+E+P/F,c[1][1])*F:G=Ri($+E+(d?U:-U)/F,c[0][1])*F,C=Math.max(C,G)}if(u){let G=0;!d&&!f||d&&!f&&g?G=Ri($+P/F,u[1][1])*F:G=Oi($+(d?U:-U)/F,u[0][1])*F,C=Math.max(C,G)}}if(m){const H=Cu(R*F,S,k)/F;if(I=Math.max(I,H),c){let G=0;!d&&!f||f&&!d&&g?G=Oi(N+R*F+Z,c[1][0])/F:G=Ri(N+(f?M:-M)*F+Z,c[0][0])/F,I=Math.max(I,G)}if(u){let G=0;!d&&!f||f&&!d&&g?G=Ri(N+R*F,u[1][0])/F:G=Oi(N+(f?M:-M)*F,u[0][0])/F,I=Math.max(I,G)}}}M=M+(M<0?I:-I),U=U+(U<0?C:-C),i&&(g?P>R*F?M=(Uy(d,f)?-U:U)/F:U=(Uy(d,f)?-M:M)*F:p?(M=U/F,f=d):(U=M*F,d=f));const L=d?N+U:N,W=f?$+M:$;return{width:D+(d?-U:U),height:O+(f?-M:M),x:o[0]*U*(d?-1:1)+L,y:o[1]*M*(f?-1:1)+W}}const vj={width:0,height:0,x:0,y:0},z3={...vj,pointerX:0,pointerY:0,aspectRatio:1};function P3(e,t,n){const r=t.position.x+e.position.x,i=t.position.y+e.position.y,o=e.measured.width??0,c=e.measured.height??0,u=n[0]*o,d=n[1]*c;return[[r-u,i-d],[r+o-u,i+c-d]]}function L3({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){const o=As(e);let c={controlDirection:By("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function u({controlPosition:f,boundaries:p,keepAspectRatio:m,resizeDirection:g,onResizeStart:v,onResize:y,onResizeEnd:S,shouldResize:k}){let w={...vj},T={...z3};c={boundaries:p,resizeDirection:g,keepAspectRatio:m,controlDirection:By(f)};let N,$=null,D=[],O,F,U,M=!1;const P=EN().on("start",R=>{const{nodeLookup:Z,transform:E,snapGrid:C,snapToGrid:I,nodeOrigin:L,paneDomNode:W}=n();if(N=Z.get(t),!N)return;$=(W==null?void 0:W.getBoundingClientRect())??null;const{xSnapped:H,ySnapped:G}=Ll(R.sourceEvent,{transform:E,snapGrid:C,snapToGrid:I,containerBounds:$});w={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},T={...w,pointerX:H,pointerY:G,aspectRatio:w.width/w.height},O=void 0,F=Ma(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(O=Z.get(N.parentId)),O&&N.extent==="parent"&&(F=[[0,0],[O.measured.width,O.measured.height]]),D=[],U=void 0;for(const[K,V]of Z)if(V.parentId===t&&(D.push({id:K,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const Y=P3(V,N,V.origin??L);U?U=[[Math.min(Y[0][0],U[0][0]),Math.min(Y[0][1],U[0][1])],[Math.max(Y[1][0],U[1][0]),Math.max(Y[1][1],U[1][1])]]:U=Y}v==null||v(R,{...w})}).on("drag",R=>{const{transform:Z,snapGrid:E,snapToGrid:C,nodeOrigin:I}=n(),L=Ll(R.sourceEvent,{transform:Z,snapGrid:E,snapToGrid:C,containerBounds:$}),W=[];if(!N)return;const{x:H,y:G,width:K,height:V}=w,Y={},fe=N.origin??I,{width:xe,height:me,x:ie,y:ke}=O3(T,c.controlDirection,L,c.boundaries,c.keepAspectRatio,fe,F,U),ae=xe!==K,Ne=me!==V,Fe=ie!==H&&ae,ce=ke!==G&&Ne;if(!Fe&&!ce&&!ae&&!Ne)return;if((Fe||ce||fe[0]===1||fe[1]===1)&&(Y.x=Fe?ie:w.x,Y.y=ce?ke:w.y,w.x=Y.x,w.y=Y.y,D.length>0)){const ze=ie-H,Te=ke-G;for(const Ge of D)Ge.position={x:Ge.position.x-ze+fe[0]*(xe-K),y:Ge.position.y-Te+fe[1]*(me-V)},W.push(Ge)}if((ae||Ne)&&(Y.width=ae&&(!c.resizeDirection||c.resizeDirection==="horizontal")?xe:w.width,Y.height=Ne&&(!c.resizeDirection||c.resizeDirection==="vertical")?me:w.height,w.width=Y.width,w.height=Y.height),O&&N.expandParent){const ze=fe[0]*(Y.width??0);Y.x&&Y.x<ze&&(w.x=ze,T.x=T.x-(Y.x-ze));const Te=fe[1]*(Y.height??0);Y.y&&Y.y<Te&&(w.y=Te,T.y=T.y-(Y.y-Te))}const je=R3({width:w.width,prevWidth:K,height:w.height,prevHeight:V,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),re={...w,direction:je};(k==null?void 0:k(R,re))!==!1&&(M=!0,y==null||y(R,re),r(Y,W))}).on("end",R=>{M&&(S==null||S(R,{...w}),i==null||i({...w}),M=!1)});o.call(P)}function d(){o.on(".drag",null)}return{update:u,destroy:d}}var ep={exports:{}},tp={},np={exports:{}},sp={};/**
|
|
199
|
-
* @license React
|
|
200
|
-
* use-sync-external-store-shim.production.js
|
|
201
|
-
*
|
|
202
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
203
|
-
*
|
|
204
|
-
* This source code is licensed under the MIT license found in the
|
|
205
|
-
* LICENSE file in the root directory of this source tree.
|
|
206
|
-
*/var Hy;function D3(){if(Hy)return sp;Hy=1;var e=sc();function t(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,i=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function u(m,g){var v=g(),y=r({inst:{value:v,getSnapshot:g}}),S=y[0].inst,k=y[1];return o(function(){S.value=v,S.getSnapshot=g,d(S)&&k({inst:S})},[m,v,g]),i(function(){return d(S)&&k({inst:S}),m(function(){d(S)&&k({inst:S})})},[m]),c(v),v}function d(m){var g=m.getSnapshot;m=m.value;try{var v=g();return!n(m,v)}catch{return!0}}function f(m,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:u;return sp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,sp}var Zy;function F3(){return Zy||(Zy=1,np.exports=D3()),np.exports}/**
|
|
207
|
-
* @license React
|
|
208
|
-
* use-sync-external-store-shim/with-selector.production.js
|
|
209
|
-
*
|
|
210
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
211
|
-
*
|
|
212
|
-
* This source code is licensed under the MIT license found in the
|
|
213
|
-
* LICENSE file in the root directory of this source tree.
|
|
214
|
-
*/var Vy;function B3(){if(Vy)return tp;Vy=1;var e=sc(),t=F3();function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,u=e.useMemo,d=e.useDebugValue;return tp.useSyncExternalStoreWithSelector=function(f,p,m,g,v){var y=o(null);if(y.current===null){var S={hasValue:!1,value:null};y.current=S}else S=y.current;y=u(function(){function w(O){if(!T){if(T=!0,N=O,O=g(O),v!==void 0&&S.hasValue){var F=S.value;if(v(F,O))return $=F}return $=O}if(F=$,r(N,O))return F;var U=g(O);return v!==void 0&&v(F,U)?(N=O,F):(N=O,$=U)}var T=!1,N,$,D=m===void 0?null:m;return[function(){return w(p())},D===null?void 0:function(){return w(D())}]},[p,m,g,v]);var k=i(f,y[0],y[1]);return c(function(){S.hasValue=!0,S.value=k},[k]),d(k),k},tp}var Wy;function U3(){return Wy||(Wy=1,ep.exports=B3()),ep.exports}var H3=U3();const Z3=pm(H3),V3={},qy=e=>{let t;const n=new Set,r=(p,m)=>{const g=typeof p=="function"?p(t):p;if(!Object.is(g,t)){const v=t;t=m??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(y=>y(t,v))}},i=()=>t,d={setState:r,getState:i,getInitialState:()=>f,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(V3?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},f=t=e(r,i,d);return d},W3=e=>e?qy(e):qy,{useDebugValue:q3}=EM,{useSyncExternalStoreWithSelector:G3}=Z3,K3=e=>e;function yj(e,t=K3,n){const r=G3(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return q3(r),r}const Gy=(e,t)=>{const n=W3(e),r=(i,o=t)=>yj(n,i,o);return Object.assign(r,n),r},Y3=(e,t)=>e?Gy(e,t):Gy;function Jt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const Id=b.createContext(null),X3=Id.Provider,bj=Nr.error001("react");function Nt(e,t){const n=b.useContext(Id);if(n===null)throw new Error(bj);return yj(n,e,t)}function Wt(){const e=b.useContext(Id);if(e===null)throw new Error(bj);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Ky={display:"none"},Q3={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},kj="react-flow__node-desc",wj="react-flow__edge-desc",J3="react-flow__aria-live",e4=e=>e.ariaLiveMessage,t4=e=>e.ariaLabelConfig;function n4({rfId:e}){const t=Nt(e4);return s.jsx("div",{id:`${J3}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Q3,children:t})}function s4({rfId:e,disableKeyboardA11y:t}){const n=Nt(t4);return s.jsxs(s.Fragment,{children:[s.jsx("div",{id:`${kj}-${e}`,style:Ky,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),s.jsx("div",{id:`${wj}-${e}`,style:Ky,children:n["edge.a11yDescription.default"]}),!t&&s.jsx(n4,{rfId:e})]})}const Ad=b.forwardRef(({position:e="top-left",children:t,className:n,style:r,...i},o)=>{const c=`${e}`.split("-");return s.jsx("div",{className:kn(["react-flow__panel",n,...c]),style:r,ref:o,...i,children:t})});Ad.displayName="Panel";const Yy="https://reactflow.dev?utm_source=attribution";function r4({proOptions:e,position:t="bottom-right"}){return b.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:s.jsx(Ad,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Yy}`,children:s.jsx("a",{href:Yy,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const i4=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Iu=e=>e.id;function a4(e,t){return Jt(e.selectedNodes.map(Iu),t.selectedNodes.map(Iu))&&Jt(e.selectedEdges.map(Iu),t.selectedEdges.map(Iu))}function o4({onSelectionChange:e}){const t=Wt(),{selectedNodes:n,selectedEdges:r}=Nt(i4,a4);return b.useEffect(()=>{const i={nodes:n,edges:r};e==null||e(i),t.getState().onSelectionChangeHandlers.forEach(o=>o(i))},[n,r,e]),null}const l4=e=>!!e.onSelectionChangeHandlers;function c4({onSelectionChange:e}){const t=Nt(l4);return e||t?s.jsx(o4,{onSelectionChange:e}):null}const Nj=[0,0],u4={x:0,y:0,zoom:1},d4=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Xy=[...d4,"rfId"],f4=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Qy={translateExtent:Gl,nodeOrigin:Nj,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function h4(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:o,setNodeExtent:c,reset:u,setDefaultNodesAndEdges:d}=Nt(f4,Jt),f=Wt();b.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{p.current=Qy,u()}),[]);const p=b.useRef(Qy);return b.useEffect(()=>{for(const m of Xy){const g=e[m],v=p.current[m];g!==v&&(typeof e[m]>"u"||(m==="nodes"?t(g):m==="edges"?n(g):m==="minZoom"?r(g):m==="maxZoom"?i(g):m==="translateExtent"?o(g):m==="nodeExtent"?c(g):m==="ariaLabelConfig"?f.setState({ariaLabelConfig:XD(g)}):m==="fitView"?f.setState({fitViewQueued:g}):m==="fitViewOptions"?f.setState({fitViewOptions:g}):f.setState({[m]:g})))}p.current=e},Xy.map(m=>e[m])),null}function Jy(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function p4(e){var r;const[t,n]=b.useState(e==="system"?null:e);return b.useEffect(()=>{if(e!=="system"){n(e);return}const i=Jy(),o=()=>n(i!=null&&i.matches?"dark":"light");return o(),i==null||i.addEventListener("change",o),()=>{i==null||i.removeEventListener("change",o)}},[e]),t!==null?t:(r=Jy())!=null&&r.matches?"dark":"light"}const eb=typeof document<"u"?document:null;function Ql(e=null,t={target:eb,actInsideInputWithModifier:!0}){const[n,r]=b.useState(!1),i=b.useRef(!1),o=b.useRef(new Set([])),[c,u]=b.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.replace(/\+/g,`
|
|
215
|
-
`).replace(`
|
|
216
|
-
|
|
217
|
-
`,`
|
|
218
|
-
+`).split(`
|
|
219
|
-
`)),p=f.reduce((m,g)=>m.concat(...g),[]);return[f,p]}return[[],[]]},[e]);return b.useEffect(()=>{const d=(t==null?void 0:t.target)??eb,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=v=>{var k,w;if(i.current=v.ctrlKey||v.metaKey||v.shiftKey||v.altKey,(!i.current||i.current&&!f)&&nj(v))return!1;const S=nb(v.code,u);if(o.current.add(v[S]),tb(c,o.current,!1)){const T=((w=(k=v.composedPath)==null?void 0:k.call(v))==null?void 0:w[0])||v.target,N=(T==null?void 0:T.nodeName)==="BUTTON"||(T==null?void 0:T.nodeName)==="A";t.preventDefault!==!1&&(i.current||!N)&&v.preventDefault(),r(!0)}},m=v=>{const y=nb(v.code,u);tb(c,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(v[y]),v.key==="Meta"&&o.current.clear(),i.current=!1},g=()=>{o.current.clear(),r(!1)};return d==null||d.addEventListener("keydown",p),d==null||d.addEventListener("keyup",m),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{d==null||d.removeEventListener("keydown",p),d==null||d.removeEventListener("keyup",m),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,r]),n}function tb(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function nb(e,t){return t.includes(e)?"code":"key"}const m4=()=>{const e=Wt();return b.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,i,o],panZoom:c}=e.getState();return c?(await c.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??o},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:i,minZoom:o,maxZoom:c,panZoom:u}=e.getState(),d=eg(t,r,i,o,c,(n==null?void 0:n.padding)??.1);return u?(await u.setViewport(d,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:i,snapToGrid:o,domNode:c}=e.getState();if(!c)return t;const{x:u,y:d}=c.getBoundingClientRect(),f={x:t.x-u,y:t.y-d},p=n.snapGrid??i,m=n.snapToGrid??o;return pc(f,r,m,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:i,y:o}=r.getBoundingClientRect(),c=zo(t,n);return{x:c.x+i,y:c.y+o}}}),[])};function jj(e,t){const n=[],r=new Map,i=[];for(const o of e)if(o.type==="add"){i.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const c=r.get(o.id);c?c.push(o):r.set(o.id,[o])}for(const o of t){const c=r.get(o.id);if(!c){n.push(o);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){n.push({...c[0].item});continue}const u={...o};for(const d of c)g4(d,u);n.push(u)}return i.length&&i.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function g4(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function x4(e,t){return jj(e,t)}function v4(e,t){return jj(e,t)}function ma(e,t){return{id:e,type:"select",selected:t}}function mo(e,t=new Set,n=!1){const r=[];for(const[i,o]of e){const c=t.has(i);!(o.selected===void 0&&!c)&&o.selected!==c&&(n&&(o.selected=c),r.push(ma(o.id,c)))}return r}function sb({items:e=[],lookup:t}){var i;const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,c]of e.entries()){const u=t.get(c.id),d=((i=u==null?void 0:u.internals)==null?void 0:i.userNode)??u;d!==void 0&&d!==c&&n.push({id:c.id,item:c,type:"replace"}),d===void 0&&n.push({item:c,type:"add",index:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function rb(e){return{id:e.id,type:"remove"}}const y4=XN();function b4(e,t,n={}){return s3(e,t,{...n,onError:n.onError??y4})}const ib=e=>UD(e),k4=e=>WN(e);function Sj(e){return b.forwardRef(e)}const _j=typeof window<"u"?b.useLayoutEffect:b.useEffect;function ab(e){const[t,n]=b.useState(BigInt(0)),[r]=b.useState(()=>w4(()=>n(i=>i+BigInt(1))));return _j(()=>{const i=r.get();i.length&&(e(i),r.reset())},[t]),r}function w4(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Ej=b.createContext(null);function N4({children:e}){const t=Wt(),n=b.useCallback(u=>{const{nodes:d=[],setNodes:f,hasDefaultNodes:p,onNodesChange:m,nodeLookup:g,fitViewQueued:v,onNodesChangeMiddlewareMap:y}=t.getState();let S=d;for(const w of u)S=typeof w=="function"?w(S):w;let k=sb({items:S,lookup:g});for(const w of y.values())k=w(k);p&&f(S),k.length>0?m==null||m(k):v&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:T,setNodes:N}=t.getState();w&&N(T)})},[]),r=ab(n),i=b.useCallback(u=>{const{edges:d=[],setEdges:f,hasDefaultEdges:p,onEdgesChange:m,edgeLookup:g}=t.getState();let v=d;for(const y of u)v=typeof y=="function"?y(v):y;p?f(v):m&&m(sb({items:v,lookup:g}))},[]),o=ab(i),c=b.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return s.jsx(Ej.Provider,{value:c,children:e})}function j4(){const e=b.useContext(Ej);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const S4=e=>!!e.panZoom;function og(){const e=m4(),t=Wt(),n=j4(),r=Nt(S4),i=b.useMemo(()=>{const o=m=>t.getState().nodeLookup.get(m),c=m=>{n.nodeQueue.push(m)},u=m=>{n.edgeQueue.push(m)},d=m=>{var w,T;const{nodeLookup:g,nodeOrigin:v}=t.getState(),y=ib(m)?m:g.get(m.id),S=y.parentId?JN(y.position,y.measured,y.parentId,g,v):y.position,k={...y,position:S,width:((w=y.measured)==null?void 0:w.width)??y.width,height:((T=y.measured)==null?void 0:T.height)??y.height};return Yl(k)},f=(m,g,v={replace:!1})=>{c(y=>y.map(S=>{if(S.id===m){const k=typeof g=="function"?g(S):g;return v.replace&&ib(k)?k:{...S,...k}}return S}))},p=(m,g,v={replace:!1})=>{u(y=>y.map(S=>{if(S.id===m){const k=typeof g=="function"?g(S):g;return v.replace&&k4(k)?k:{...S,...k}}return S}))};return{getNodes:()=>t.getState().nodes.map(m=>({...m})),getNode:m=>{var g;return(g=o(m))==null?void 0:g.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:m=[]}=t.getState();return m.map(g=>({...g}))},getEdge:m=>t.getState().edgeLookup.get(m),setNodes:c,setEdges:u,addNodes:m=>{const g=Array.isArray(m)?m:[m];n.nodeQueue.push(v=>[...v,...g])},addEdges:m=>{const g=Array.isArray(m)?m:[m];n.edgeQueue.push(v=>[...v,...g])},toObject:()=>{const{nodes:m=[],edges:g=[],transform:v}=t.getState(),[y,S,k]=v;return{nodes:m.map(w=>({...w})),edges:g.map(w=>({...w})),viewport:{x:y,y:S,zoom:k}}},deleteElements:async({nodes:m=[],edges:g=[]})=>{const{nodes:v,edges:y,onNodesDelete:S,onEdgesDelete:k,triggerNodeChanges:w,triggerEdgeChanges:T,onDelete:N,onBeforeDelete:$}=t.getState(),{nodes:D,edges:O}=await qD({nodesToRemove:m,edgesToRemove:g,nodes:v,edges:y,onBeforeDelete:$}),F=O.length>0,U=D.length>0;if(F){const M=O.map(rb);k==null||k(O),T(M)}if(U){const M=D.map(rb);S==null||S(D),w(M)}return(U||F)&&(N==null||N({nodes:D,edges:O})),{deletedNodes:D,deletedEdges:O}},getIntersectingNodes:(m,g=!0,v)=>{const y=Ay(m),S=y?m:d(m),k=v!==void 0;return S?(v||t.getState().nodes).filter(w=>{const T=t.getState().nodeLookup.get(w.id);if(T&&!y&&(w.id===m.id||!T.internals.positionAbsolute))return!1;const N=Yl(k?w:T),$=ad(N,S);return g&&$>0||$>=N.width*N.height||$>=S.width*S.height}):[]},isNodeIntersecting:(m,g,v=!0)=>{const S=Ay(m)?m:d(m);if(!S)return!1;const k=ad(S,g);return v&&k>0||k>=g.width*g.height||k>=S.width*S.height},updateNode:f,updateNodeData:(m,g,v={replace:!1})=>{f(m,y=>{const S=typeof g=="function"?g(y):g;return v.replace?{...y,data:S}:{...y,data:{...y.data,...S}}},v)},updateEdge:p,updateEdgeData:(m,g,v={replace:!1})=>{p(m,y=>{const S=typeof g=="function"?g(y):g;return v.replace?{...y,data:S}:{...y,data:{...y.data,...S}}},v)},getNodesBounds:m=>{const{nodeLookup:g,nodeOrigin:v}=t.getState();return HD(m,{nodeLookup:g,nodeOrigin:v})},getHandleConnections:({type:m,id:g,nodeId:v})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${v}-${m}${g?`-${g}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:m,handleId:g,nodeId:v})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${v}${m?g?`-${m}-${g}`:`-${m}`:""}`))==null?void 0:y.values())??[])},fitView:async m=>{const g=t.getState().fitViewResolver??YD();return t.setState({fitViewQueued:!0,fitViewOptions:m,fitViewResolver:g}),n.nodeQueue.push(v=>[...v]),g.promise}}},[]);return b.useMemo(()=>({...i,...e,viewportInitialized:r}),[r])}const ob=e=>e.selected,_4=typeof window<"u"?window:void 0;function E4({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Wt(),{deleteElements:r}=og(),i=Ql(e,{actInsideInputWithModifier:!1}),o=Ql(t,{target:_4});b.useEffect(()=>{if(i){const{edges:c,nodes:u}=n.getState();r({nodes:u.filter(ob),edges:c.filter(ob)}),n.setState({nodesSelectionActive:!1})}},[i]),b.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function C4(e){const t=Wt();b.useEffect(()=>{const n=()=>{var i,o,c,u;if(!e.current||!(((o=(i=e.current).checkVisibility)==null?void 0:o.call(i))??!0))return!1;const r=tg(e.current);(r.height===0||r.width===0)&&((u=(c=t.getState()).onError)==null||u.call(c,"004",Nr.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const Td={position:"absolute",width:"100%",height:"100%",top:0,left:0},I4=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function A4({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:o=.5,panOnScrollMode:c=Sa.Free,zoomOnDoubleClick:u=!0,panOnDrag:d=!0,defaultViewport:f,translateExtent:p,minZoom:m,maxZoom:g,zoomActivationKeyCode:v,preventScrolling:y=!0,children:S,noWheelClassName:k,noPanClassName:w,onViewportChange:T,isControlledViewport:N,paneClickDistance:$,selectionOnDrag:D}){const O=Wt(),F=b.useRef(null),{userSelectionActive:U,lib:M,connectionInProgress:P}=Nt(I4,Jt),R=Ql(v),Z=b.useRef();C4(F);const E=b.useCallback(C=>{T==null||T({x:C[0],y:C[1],zoom:C[2]}),N||O.setState({transform:C})},[T,N]);return b.useEffect(()=>{if(F.current){Z.current=$3({domNode:F.current,minZoom:m,maxZoom:g,translateExtent:p,viewport:f,onDraggingChange:W=>O.setState(H=>H.paneDragging===W?H:{paneDragging:W}),onPanZoomStart:(W,H)=>{const{onViewportChangeStart:G,onMoveStart:K}=O.getState();K==null||K(W,H),G==null||G(H)},onPanZoom:(W,H)=>{const{onViewportChange:G,onMove:K}=O.getState();K==null||K(W,H),G==null||G(H)},onPanZoomEnd:(W,H)=>{const{onViewportChangeEnd:G,onMoveEnd:K}=O.getState();K==null||K(W,H),G==null||G(H)}});const{x:C,y:I,zoom:L}=Z.current.getViewport();return O.setState({panZoom:Z.current,transform:[C,I,L],domNode:F.current.closest(".react-flow")}),()=>{var W;(W=Z.current)==null||W.destroy()}}},[]),b.useEffect(()=>{var C;(C=Z.current)==null||C.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:o,panOnScrollMode:c,zoomOnDoubleClick:u,panOnDrag:d,zoomActivationKeyPressed:R,preventScrolling:y,noPanClassName:w,userSelectionActive:U,noWheelClassName:k,lib:M,onTransformChange:E,connectionInProgress:P,selectionOnDrag:D,paneClickDistance:$})},[e,t,n,r,i,o,c,u,d,R,y,w,U,k,M,E,P,D,$]),s.jsx("div",{className:"react-flow__renderer",ref:F,style:Td,children:S})}const T4=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function M4(){const{userSelectionActive:e,userSelectionRect:t}=Nt(T4,Jt);return e&&t?s.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const rp=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},$4=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function R4({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Kl.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:o,selectionOnDrag:c,onSelectionStart:u,onSelectionEnd:d,onPaneClick:f,onPaneContextMenu:p,onPaneScroll:m,onPaneMouseEnter:g,onPaneMouseMove:v,onPaneMouseLeave:y,children:S}){const k=b.useRef(0),w=Wt(),{userSelectionActive:T,elementsSelectable:N,dragging:$,panBy:D,autoPanSpeed:O}=Nt($4,Jt),F=N&&(e||T),U=b.useRef(null),M=b.useRef(),P=b.useRef(new Set),R=b.useRef(new Set),Z=b.useRef(!1),E=b.useRef(!1),C=b.useRef({x:0,y:0}),I=b.useRef(!1),L=ae=>{if(E.current||Z.current||w.getState().connection.inProgress){E.current=!1,Z.current=!1;return}f==null||f(ae),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},W=ae=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){ae.preventDefault();return}p==null||p(ae)},H=m?ae=>m(ae):void 0,G=ae=>{E.current&&(ae.stopPropagation(),E.current=!1)},K=ae=>{var Ge,Ie;if(ae.pointerType==="touch"&&r!==!1&&!t)return;const{domNode:Ne,transform:Fe}=w.getState();if(M.current=Ne==null?void 0:Ne.getBoundingClientRect(),!M.current)return;const ce=ae.target===U.current;if(!ce&&!!ae.target.closest(".nokey")||!e||!(c&&ce||t)||ae.button!==0||!ae.isPrimary)return;(Ie=(Ge=ae.target)==null?void 0:Ge.setPointerCapture)==null||Ie.call(Ge,ae.pointerId),E.current=!1;const{x:he,y:ze}=yr(ae.nativeEvent,M.current),Te=pc({x:he,y:ze},Fe);w.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:he,y:ze}}),ce||(ae.stopPropagation(),ae.preventDefault())};function V(ae,Ne){const{userSelectionRect:Fe}=w.getState();if(!Fe)return;const{transform:ce,nodeLookup:je,edgeLookup:re,connectionLookup:he,triggerNodeChanges:ze,triggerEdgeChanges:Te,defaultEdgeOptions:Ge}=w.getState(),Ie={x:Fe.startX,y:Fe.startY},{x:tt,y:et}=zo(Ie,ce),jt={startX:Ie.x,startY:Ie.y,x:ae<tt?ae:tt,y:Ne<et?Ne:et,width:Math.abs(ae-tt),height:Math.abs(Ne-et)},On=P.current,sn=R.current;P.current=new Set(Qm(je,jt,ce,n===Kl.Partial,!0).map(cn=>cn.id)),R.current=new Set;const ln=(Ge==null?void 0:Ge.selectable)??!0;for(const cn of P.current){const rn=he.get(cn);if(rn)for(const{edgeId:an}of rn.values()){const Ft=re.get(an);Ft&&(Ft.selectable??ln)&&R.current.add(an)}}if(!Ty(On,P.current)){const cn=mo(je,P.current,!0);ze(cn)}if(!Ty(sn,R.current)){const cn=mo(re,R.current);Te(cn)}w.setState({userSelectionRect:jt,userSelectionActive:!0,nodesSelectionActive:!1})}function Y(){if(!i||!M.current)return;const[ae,Ne]=Jm(C.current,M.current,O);D({x:ae,y:Ne}).then(Fe=>{if(!E.current||!Fe){k.current=requestAnimationFrame(Y);return}const{x:ce,y:je}=C.current;V(ce,je),k.current=requestAnimationFrame(Y)})}const fe=()=>{cancelAnimationFrame(k.current),k.current=0,I.current=!1};b.useEffect(()=>()=>fe(),[]);const xe=ae=>{const{userSelectionRect:Ne,transform:Fe,resetSelectedElements:ce}=w.getState();if(!M.current||!Ne)return;const{x:je,y:re}=yr(ae.nativeEvent,M.current);C.current={x:je,y:re};const he=zo({x:Ne.startX,y:Ne.startY},Fe);if(!E.current){const ze=t?0:o;if(Math.hypot(je-he.x,re-he.y)<=ze)return;ce(),u==null||u(ae)}E.current=!0,I.current||(Y(),I.current=!0),V(je,re)},me=ae=>{var Ne,Fe;if(!F){ae.target===U.current&&w.getState().connection.inProgress&&(Z.current=!0);return}ae.button===0&&((Fe=(Ne=ae.target)==null?void 0:Ne.releasePointerCapture)==null||Fe.call(Ne,ae.pointerId),!T&&ae.target===U.current&&w.getState().userSelectionRect&&(L==null||L(ae)),w.setState({userSelectionActive:!1,userSelectionRect:null}),E.current&&(d==null||d(ae),w.setState({nodesSelectionActive:P.current.size>0})),fe())},ie=ae=>{var Ne,Fe;(Fe=(Ne=ae.target)==null?void 0:Ne.releasePointerCapture)==null||Fe.call(Ne,ae.pointerId),fe()},ke=r===!0||Array.isArray(r)&&r.includes(0);return s.jsxs("div",{className:kn(["react-flow__pane",{draggable:ke,dragging:$,selection:e}]),onClick:F?void 0:rp(L,U),onContextMenu:rp(W,U),onWheel:rp(H,U),onPointerEnter:F?void 0:g,onPointerMove:F?xe:v,onPointerUp:me,onPointerCancel:F?ie:void 0,onPointerDownCapture:F?K:void 0,onClickCapture:F?G:void 0,onPointerLeave:y,ref:U,style:Td,children:[S,s.jsx(M4,{})]})}function lm({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:c,nodeLookup:u,onError:d}=t.getState(),f=u.get(e);if(!f){d==null||d("012",Nr.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&c)&&(o({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):i([e])}function Cj({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,nodeClickDistance:c}){const u=Wt(),[d,f]=b.useState(!1),p=b.useRef();return b.useEffect(()=>{if(!t)return p.current=y3({getStoreItems:()=>u.getState(),onNodeMouseDown:m=>{lm({id:m,store:u,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}}),()=>{var m;(m=p.current)==null||m.destroy(),p.current=void 0}},[t,u,e]),b.useEffect(()=>{t||!e.current||!p.current||p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:i,nodeClickDistance:c})},[n,r,t,o,e,i,c]),d}const O4=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Ij(){const e=Wt();return b.useCallback(n=>{const{nodeExtent:r,snapToGrid:i,snapGrid:o,nodesDraggable:c,onError:u,updateNodePositions:d,nodeLookup:f,nodeOrigin:p}=e.getState(),m=new Map,g=O4(c),v=i?o[0]:5,y=i?o[1]:5,S=n.direction.x*v*n.factor,k=n.direction.y*y*n.factor;for(const[,w]of f){if(!g(w))continue;let T={x:w.internals.positionAbsolute.x+S,y:w.internals.positionAbsolute.y+k};i&&(T=hc(T,o));const{position:N,positionAbsolute:$}=qN({nodeId:w.id,nextPosition:T,nodeLookup:f,nodeExtent:r,nodeOrigin:p,onError:u});w.position=N,w.internals.positionAbsolute=$,m.set(w.id,w)}d(m)},[])}const lg=b.createContext(null),z4=lg.Provider;lg.Consumer;const Aj=()=>b.useContext(lg),P4=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Tj=b.createContext(null);function L4({children:e}){const t=Nt(P4,Jt);return s.jsx(Tj.Provider,{value:t,children:e})}function D4(){const e=b.useContext(Tj);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const F4={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},B4=(e,t,n)=>r=>{const{connectionClickStartHandle:i,connectionMode:o,connection:c}=r,{fromHandle:u,toHandle:d,isValid:f}=c;if(!u&&!i)return F4;const p=(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.type)===n;return{connectingFrom:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n,connectingTo:p,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.id)===t&&(i==null?void 0:i.type)===n,isPossibleEndHandle:o===Ro.Strict?(u==null?void 0:u.type)!==n:e!==(u==null?void 0:u.nodeId)||t!==(u==null?void 0:u.id),connectionInProcess:!!u,clickConnectionInProcess:!!i,valid:p&&f}};function U4({type:e="source",position:t=Qe.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:o=!0,id:c,onConnect:u,children:d,className:f,onMouseDown:p,onTouchStart:m,...g},v){var I,L;const y=c||null,S=e==="target",k=Wt(),w=Aj(),{connectOnClick:T,noPanClassName:N,rfId:$}=D4(),{connectingFrom:D,connectingTo:O,clickConnecting:F,isPossibleEndHandle:U,connectionInProcess:M,clickConnectionInProcess:P,valid:R}=Nt(B4(w,y,e),Jt);w||(L=(I=k.getState()).onError)==null||L.call(I,"010",Nr.error010());const Z=W=>{const{defaultEdgeOptions:H,onConnect:G,hasDefaultEdges:K}=k.getState(),V={...H,...W};if(K){const{edges:Y,setEdges:fe,onError:xe}=k.getState();fe(b4(V,Y,{onError:xe}))}G==null||G(V),u==null||u(V)},E=W=>{if(!w)return;const H=sj(W.nativeEvent);if(i&&(H&&W.button===0||!H)){const G=k.getState();om.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:G.autoPanOnConnect,connectionMode:G.connectionMode,connectionRadius:G.connectionRadius,domNode:G.domNode,nodeLookup:G.nodeLookup,lib:G.lib,isTarget:S,handleId:y,nodeId:w,flowId:G.rfId,panBy:G.panBy,cancelConnection:G.cancelConnection,onConnectStart:G.onConnectStart,onConnectEnd:(...K)=>{var V,Y;return(Y=(V=k.getState()).onConnectEnd)==null?void 0:Y.call(V,...K)},updateConnection:G.updateConnection,onConnect:Z,isValidConnection:n||((...K)=>{var V,Y;return((Y=(V=k.getState()).isValidConnection)==null?void 0:Y.call(V,...K))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:G.autoPanSpeed,dragThreshold:G.connectionDragThreshold})}H?p==null||p(W):m==null||m(W)},C=W=>{const{onClickConnectStart:H,onClickConnectEnd:G,connectionClickStartHandle:K,connectionMode:V,isValidConnection:Y,lib:fe,rfId:xe,nodeLookup:me,connection:ie}=k.getState();if(!w||!K&&!i)return;if(!K){H==null||H(W.nativeEvent,{nodeId:w,handleId:y,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:w,type:e,id:y}});return}const ke=tj(W.target),ae=n||Y,{connection:Ne,isValid:Fe}=om.isValid(W.nativeEvent,{handle:{nodeId:w,id:y,type:e},connectionMode:V,fromNodeId:K.nodeId,fromHandleId:K.id||null,fromType:K.type,isValidConnection:ae,flowId:xe,doc:ke,lib:fe,nodeLookup:me});Fe&&Ne&&Z(Ne);const ce=structuredClone(ie);delete ce.inProgress,ce.toPosition=ce.toHandle?ce.toHandle.position:null,G==null||G(W,ce),k.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":y,"data-nodeid":w,"data-handlepos":t,"data-id":`${$}-${w}-${y}-${e}`,className:kn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",N,f,{source:!S,target:S,connectable:r,connectablestart:i,connectableend:o,clickconnecting:F,connectingfrom:D,connectingto:O,valid:R,connectionindicator:r&&(!M||U)&&(M||P?o:i)}]),onMouseDown:E,onTouchStart:E,onClick:T?C:void 0,ref:v,...g,children:d})}const Hi=b.memo(Sj(U4));function H4({data:e,isConnectable:t,sourcePosition:n=Qe.Bottom}){return s.jsxs(s.Fragment,{children:[e==null?void 0:e.label,s.jsx(Hi,{type:"source",position:n,isConnectable:t})]})}function Z4({data:e,isConnectable:t,targetPosition:n=Qe.Top,sourcePosition:r=Qe.Bottom}){return s.jsxs(s.Fragment,{children:[s.jsx(Hi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,s.jsx(Hi,{type:"source",position:r,isConnectable:t})]})}function V4(){return null}function W4({data:e,isConnectable:t,targetPosition:n=Qe.Top}){return s.jsxs(s.Fragment,{children:[s.jsx(Hi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const od={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},lb={input:H4,default:Z4,output:W4,group:V4};function q4(e){var t,n,r,i;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((i=e.style)==null?void 0:i.height)}}const G4=e=>{const{width:t,height:n,x:r,y:i}=fc(e.nodeLookup,{filter:o=>!!o.selected});return{width:vr(t)?t:null,height:vr(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function K4({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Wt(),{width:i,height:o,transformString:c,userSelectionActive:u}=Nt(G4,Jt),d=Ij(),f=b.useRef(null);b.useEffect(()=>{var v;n||(v=f.current)==null||v.focus({preventScroll:!0})},[n]);const p=!u&&i!==null&&o!==null;if(Cj({nodeRef:f,disabled:!p}),!p)return null;const m=e?v=>{const y=r.getState().nodes.filter(S=>S.selected);e(v,y)}:void 0,g=v=>{Object.prototype.hasOwnProperty.call(od,v.key)&&(v.preventDefault(),d({direction:od[v.key],factor:v.shiftKey?4:1}))};return s.jsx("div",{className:kn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c},children:s.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:g,style:{width:i,height:o}})})}const cb=typeof window<"u"?window:void 0,Y4=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Mj({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:c,paneClickDistance:u,deleteKeyCode:d,selectionKeyCode:f,selectionOnDrag:p,selectionMode:m,onSelectionStart:g,onSelectionEnd:v,multiSelectionKeyCode:y,panActivationKeyCode:S,zoomActivationKeyCode:k,elementsSelectable:w,zoomOnScroll:T,zoomOnPinch:N,panOnScroll:$,panOnScrollSpeed:D,panOnScrollMode:O,zoomOnDoubleClick:F,panOnDrag:U,autoPanOnSelection:M,defaultViewport:P,translateExtent:R,minZoom:Z,maxZoom:E,preventScrolling:C,onSelectionContextMenu:I,noWheelClassName:L,noPanClassName:W,disableKeyboardA11y:H,onViewportChange:G,isControlledViewport:K}){const{nodesSelectionActive:V,userSelectionActive:Y}=Nt(Y4,Jt),fe=Ql(f,{target:cb}),xe=Ql(S,{target:cb}),me=xe||U,ie=xe||$,ke=p&&me!==!0,ae=fe||Y||ke;return E4({deleteKeyCode:d,multiSelectionKeyCode:y}),s.jsx(A4,{onPaneContextMenu:o,elementsSelectable:w,zoomOnScroll:T,zoomOnPinch:N,panOnScroll:ie,panActivationKeyPressed:xe,panOnScrollSpeed:D,panOnScrollMode:O,zoomOnDoubleClick:F,panOnDrag:!fe&&me,defaultViewport:P,translateExtent:R,minZoom:Z,maxZoom:E,zoomActivationKeyCode:k,preventScrolling:C,noWheelClassName:L,noPanClassName:W,onViewportChange:G,isControlledViewport:K,paneClickDistance:u,selectionOnDrag:ke,children:s.jsxs(R4,{onSelectionStart:g,onSelectionEnd:v,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:c,panOnDrag:me,autoPanOnSelection:M,isSelecting:!!ae,selectionMode:m,selectionKeyPressed:fe,paneClickDistance:u,selectionOnDrag:ke,children:[e,V&&s.jsx(K4,{onSelectionContextMenu:I,noPanClassName:W,disableKeyboardA11y:H})]})})}Mj.displayName="FlowRenderer";const X4=b.memo(Mj),Q4=e=>t=>e?Qm(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function J4(e){return Nt(b.useCallback(Q4(e),[e]),Jt)}const eF=e=>e.updateNodeInternals;function tF(){const e=Nt(eF),[t]=b.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(i=>{const o=i.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:i.target,force:!0})}),e(r)}));return b.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function nF({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const i=Wt(),o=b.useRef(null),c=b.useRef(null),u=b.useRef(e.sourcePosition),d=b.useRef(e.targetPosition),f=b.useRef(t),p=n&&!!e.internals.handleBounds;return b.useEffect(()=>{o.current&&!e.hidden&&(!p||c.current!==o.current)&&(c.current&&(r==null||r.unobserve(c.current)),r==null||r.observe(o.current),c.current=o.current)},[p,e.hidden]),b.useEffect(()=>()=>{c.current&&(r==null||r.unobserve(c.current),c.current=null)},[]),b.useEffect(()=>{if(o.current){const m=f.current!==t,g=u.current!==e.sourcePosition,v=d.current!==e.targetPosition;(m||g||v)&&(f.current=t,u.current=e.sourcePosition,d.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function sF({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:o,onDoubleClick:c,nodesDraggable:u,elementsSelectable:d,nodesConnectable:f,nodesFocusable:p,resizeObserver:m,noDragClassName:g,noPanClassName:v,disableKeyboardA11y:y,rfId:S,nodeTypes:k,nodeClickDistance:w,onError:T}){const{node:N,internals:$,isParent:D}=Nt(ae=>{const Ne=ae.nodeLookup.get(e),Fe=ae.parentLookup.has(e);return{node:Ne,internals:Ne.internals,isParent:Fe}},Jt);let O=N.type||"default",F=(k==null?void 0:k[O])||lb[O];F===void 0&&(T==null||T("003",Nr.error003(O)),O="default",F=(k==null?void 0:k.default)||lb.default);const U=!!(N.draggable||u&&typeof N.draggable>"u"),M=!!(N.selectable||d&&typeof N.selectable>"u"),P=!!(N.connectable||f&&typeof N.connectable>"u"),R=!!(N.focusable||p&&typeof N.focusable>"u"),Z=Wt(),E=QN(N),C=nF({node:N,nodeType:O,hasDimensions:E,resizeObserver:m}),I=Cj({nodeRef:C,disabled:N.hidden||!U,noDragClassName:g,handleSelector:N.dragHandle,nodeId:e,isSelectable:M,nodeClickDistance:w}),L=Ij();if(N.hidden)return null;const W=Sr(N),H=q4(N),G=M||U||t||n||r||i,K=n?ae=>n(ae,{...$.userNode}):void 0,V=r?ae=>r(ae,{...$.userNode}):void 0,Y=i?ae=>i(ae,{...$.userNode}):void 0,fe=o?ae=>o(ae,{...$.userNode}):void 0,xe=c?ae=>c(ae,{...$.userNode}):void 0,me=ae=>{const{selectNodesOnDrag:Ne,nodeDragThreshold:Fe}=Z.getState();M&&(!Ne||!U||Fe>0)&&lm({id:e,store:Z,nodeRef:C}),t&&t(ae,{...$.userNode})},ie=ae=>{if(!(nj(ae.nativeEvent)||y)){if(HN.includes(ae.key)&&M){const Ne=ae.key==="Escape";lm({id:e,store:Z,unselect:Ne,nodeRef:C})}else if(U&&N.selected&&Object.prototype.hasOwnProperty.call(od,ae.key)){ae.preventDefault();const{ariaLabelConfig:Ne}=Z.getState();Z.setState({ariaLiveMessage:Ne["node.a11yDescription.ariaLiveMessage"]({direction:ae.key.replace("Arrow","").toLowerCase(),x:~~$.positionAbsolute.x,y:~~$.positionAbsolute.y})}),L({direction:od[ae.key],factor:ae.shiftKey?4:1})}}},ke=()=>{var he;if(y||!((he=C.current)!=null&&he.matches(":focus-visible")))return;const{transform:ae,width:Ne,height:Fe,autoPanOnNodeFocus:ce,setCenter:je}=Z.getState();if(!ce)return;Qm(new Map([[e,N]]),{x:0,y:0,width:Ne,height:Fe},ae,!0).length>0||je(N.position.x+W.width/2,N.position.y+W.height/2,{zoom:ae[2]})};return s.jsx("div",{className:kn(["react-flow__node",`react-flow__node-${O}`,{[v]:U},N.className,{selected:N.selected,selectable:M,parent:D,draggable:U,dragging:I}]),ref:C,style:{zIndex:$.z,transform:`translate(${$.positionAbsolute.x}px,${$.positionAbsolute.y}px)`,pointerEvents:G?"all":"none",visibility:E?"visible":"hidden",...N.style,...H},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:K,onMouseMove:V,onMouseLeave:Y,onContextMenu:fe,onClick:me,onDoubleClick:xe,onKeyDown:R?ie:void 0,tabIndex:R?0:void 0,onFocus:R?ke:void 0,role:N.ariaRole??(R?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${kj}-${S}`,"aria-label":N.ariaLabel,...N.domAttributes,children:s.jsx(z4,{value:e,children:s.jsx(F,{id:e,data:N.data,type:O,positionAbsoluteX:$.positionAbsolute.x,positionAbsoluteY:$.positionAbsolute.y,selected:N.selected??!1,selectable:M,draggable:U,deletable:N.deletable??!0,isConnectable:P,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:I,dragHandle:N.dragHandle,zIndex:$.z,parentId:N.parentId,...W})})})}var rF=b.memo(sF);const iF=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function $j(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=Nt(iF,Jt),o=J4(e.onlyRenderVisibleElements),c=tF();return s.jsx("div",{className:"react-flow__nodes",style:Td,children:o.map(u=>s.jsx(rF,{id:u,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},u))})}$j.displayName="NodeRenderer";const aF=b.memo($j);function oF(e){return Nt(b.useCallback(n=>{if(!e)return n.edges.map(i=>i.id);const r=[];if(n.width&&n.height)for(const i of n.edges){const o=n.nodeLookup.get(i.source),c=n.nodeLookup.get(i.target);o&&c&&e3({sourceNode:o,targetNode:c,width:n.width,height:n.height,transform:n.transform})&&r.push(i.id)}return r},[e]),Jt)}const lF=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return s.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},cF=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return s.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ub={[rd.Arrow]:lF,[rd.ArrowClosed]:cF};function uF(e){const t=Wt();return b.useMemo(()=>{var i,o;return Object.prototype.hasOwnProperty.call(ub,e)?ub[e]:((o=(i=t.getState()).onError)==null||o.call(i,"009",Nr.error009(e)),null)},[e])}const dF=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:c,orient:u="auto-start-reverse"})=>{const d=uF(t);return d?s.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:u,refX:"0",refY:"0",children:s.jsx(d,{color:n,strokeWidth:c})}):null},Rj=({defaultColor:e,rfId:t})=>{const n=Nt(o=>o.edges),r=Nt(o=>o.defaultEdgeOptions),i=b.useMemo(()=>l3(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return i.length?s.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:s.jsx("defs",{children:i.map(o=>s.jsx(dF,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};Rj.displayName="MarkerDefinitions";var fF=b.memo(Rj);function Oj({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:o,labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:d,className:f,...p}){const[m,g]=b.useState({x:1,y:0,width:0,height:0}),v=kn(["react-flow__edge-textwrapper",f]),y=b.useRef(null);return b.useEffect(()=>{if(y.current){const S=y.current.getBBox();g({x:S.x,y:S.y,width:S.width,height:S.height})}},[n]),n?s.jsxs("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:v,visibility:m.width?"visible":"hidden",...p,children:[i&&s.jsx("rect",{width:m.width+2*c[0],x:-c[0],y:-c[1],height:m.height+2*c[1],className:"react-flow__edge-textbg",style:o,rx:u,ry:u}),s.jsx("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:y,style:r,children:n}),d]}):null}Oj.displayName="EdgeText";const hF=b.memo(Oj);function Md({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,interactionWidth:f=20,...p}){return s.jsxs(s.Fragment,{children:[s.jsx("path",{...p,d:e,fill:"none",className:kn(["react-flow__edge-path",p.className])}),f?s.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,r&&vr(t)&&vr(n)?s.jsx(hF,{x:t,y:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d}):null]})}function db({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Qe.Left||e===Qe.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function zj({sourceX:e,sourceY:t,sourcePosition:n=Qe.Bottom,targetX:r,targetY:i,targetPosition:o=Qe.Top}){const[c,u]=db({pos:n,x1:e,y1:t,x2:r,y2:i}),[d,f]=db({pos:o,x1:r,y1:i,x2:e,y2:t}),[p,m,g,v]=rj({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:c,sourceControlY:u,targetControlX:d,targetControlY:f});return[`M${e},${t} C${c},${u} ${d},${f} ${r},${i}`,p,m,g,v]}function Pj(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:c,targetPosition:u,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:v,style:y,markerEnd:S,markerStart:k,interactionWidth:w})=>{const[T,N,$]=zj({sourceX:n,sourceY:r,sourcePosition:c,targetX:i,targetY:o,targetPosition:u}),D=e.isInternal?void 0:t;return s.jsx(Md,{id:D,path:T,labelX:N,labelY:$,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:v,style:y,markerEnd:S,markerStart:k,interactionWidth:w})})}const pF=Pj({isInternal:!1}),Lj=Pj({isInternal:!0});pF.displayName="SimpleBezierEdge";Lj.displayName="SimpleBezierEdgeInternal";function Dj(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:g,sourcePosition:v=Qe.Bottom,targetPosition:y=Qe.Top,markerEnd:S,markerStart:k,pathOptions:w,interactionWidth:T})=>{const[N,$,D]=rm({sourceX:n,sourceY:r,sourcePosition:v,targetX:i,targetY:o,targetPosition:y,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),O=e.isInternal?void 0:t;return s.jsx(Md,{id:O,path:N,labelX:$,labelY:D,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:S,markerStart:k,interactionWidth:T})})}const Fj=Dj({isInternal:!1}),Bj=Dj({isInternal:!0});Fj.displayName="SmoothStepEdge";Bj.displayName="SmoothStepEdgeInternal";function Uj(e){return b.memo(({id:t,...n})=>{var i;const r=e.isInternal?void 0:t;return s.jsx(Fj,{...n,id:r,pathOptions:b.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(i=n.pathOptions)==null?void 0:i.offset])})})}const mF=Uj({isInternal:!1}),Hj=Uj({isInternal:!0});mF.displayName="StepEdge";Hj.displayName="StepEdgeInternal";function Zj(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:v,markerStart:y,interactionWidth:S})=>{const[k,w,T]=oj({sourceX:n,sourceY:r,targetX:i,targetY:o}),N=e.isInternal?void 0:t;return s.jsx(Md,{id:N,path:k,labelX:w,labelY:T,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:v,markerStart:y,interactionWidth:S})})}const gF=Zj({isInternal:!1}),Vj=Zj({isInternal:!0});gF.displayName="StraightEdge";Vj.displayName="StraightEdgeInternal";function Wj(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:c=Qe.Bottom,targetPosition:u=Qe.Top,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:v,style:y,markerEnd:S,markerStart:k,pathOptions:w,interactionWidth:T})=>{const[N,$,D]=ij({sourceX:n,sourceY:r,sourcePosition:c,targetX:i,targetY:o,targetPosition:u,curvature:w==null?void 0:w.curvature}),O=e.isInternal?void 0:t;return s.jsx(Md,{id:O,path:N,labelX:$,labelY:D,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:v,style:y,markerEnd:S,markerStart:k,interactionWidth:T})})}const xF=Wj({isInternal:!1}),qj=Wj({isInternal:!0});xF.displayName="BezierEdge";qj.displayName="BezierEdgeInternal";const fb={default:qj,straight:Vj,step:Hj,smoothstep:Bj,simplebezier:Lj},hb={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},vF=(e,t,n)=>n===Qe.Left?e-t:n===Qe.Right?e+t:e,yF=(e,t,n)=>n===Qe.Top?e-t:n===Qe.Bottom?e+t:e,pb="react-flow__edgeupdater";function mb({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:c,type:u}){return s.jsx("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:c,className:kn([pb,`${pb}-${u}`]),cx:vF(t,r,e),cy:yF(n,r,e),r,stroke:"transparent",fill:"transparent"})}function bF({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:o,targetY:c,sourcePosition:u,targetPosition:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,setReconnecting:g,setUpdateHover:v}){const y=Wt(),S=($,D)=>{if($.button!==0)return;const{autoPanOnConnect:O,domNode:F,connectionMode:U,connectionRadius:M,lib:P,onConnectStart:R,cancelConnection:Z,nodeLookup:E,rfId:C,panBy:I,updateConnection:L}=y.getState(),W=D.type==="target",H=(V,Y)=>{g(!1),m==null||m(V,n,D.type,Y)},G=V=>f==null?void 0:f(n,V),K=(V,Y)=>{g(!0),p==null||p($,n,D.type),R==null||R(V,Y)};om.onPointerDown($.nativeEvent,{autoPanOnConnect:O,connectionMode:U,connectionRadius:M,domNode:F,handleId:D.id,nodeId:D.nodeId,nodeLookup:E,isTarget:W,edgeUpdaterType:D.type,lib:P,flowId:C,cancelConnection:Z,panBy:I,isValidConnection:(...V)=>{var Y,fe;return((fe=(Y=y.getState()).isValidConnection)==null?void 0:fe.call(Y,...V))??!0},onConnect:G,onConnectStart:K,onConnectEnd:(...V)=>{var Y,fe;return(fe=(Y=y.getState()).onConnectEnd)==null?void 0:fe.call(Y,...V)},onReconnectEnd:H,updateConnection:L,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:$.currentTarget})},k=$=>S($,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),w=$=>S($,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),T=()=>v(!0),N=()=>v(!1);return s.jsxs(s.Fragment,{children:[(e===!0||e==="source")&&s.jsx(mb,{position:u,centerX:r,centerY:i,radius:t,onMouseDown:k,onMouseEnter:T,onMouseOut:N,type:"source"}),(e===!0||e==="target")&&s.jsx(mb,{position:d,centerX:o,centerY:c,radius:t,onMouseDown:w,onMouseEnter:T,onMouseOut:N,type:"target"})]})}function kF({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:o,onContextMenu:c,onMouseEnter:u,onMouseMove:d,onMouseLeave:f,reconnectRadius:p,onReconnect:m,onReconnectStart:g,onReconnectEnd:v,rfId:y,edgeTypes:S,noPanClassName:k,onError:w,disableKeyboardA11y:T}){let N=Nt(je=>je.edgeLookup.get(e));const $=Nt(je=>je.defaultEdgeOptions);N=$?{...$,...N}:N;let D=N.type||"default",O=(S==null?void 0:S[D])||fb[D];O===void 0&&(w==null||w("011",Nr.error011(D)),D="default",O=(S==null?void 0:S.default)||fb.default);const F=!!(N.focusable||t&&typeof N.focusable>"u"),U=typeof m<"u"&&(N.reconnectable||n&&typeof N.reconnectable>"u"),M=!!(N.selectable||r&&typeof N.selectable>"u"),P=b.useRef(null),[R,Z]=b.useState(!1),[E,C]=b.useState(!1),I=Wt(),{zIndex:L=N.zIndex,sourceX:W,sourceY:H,targetX:G,targetY:K,sourcePosition:V,targetPosition:Y}=Nt(b.useCallback(je=>{const re=je.nodeLookup.get(N.source),he=je.nodeLookup.get(N.target);if(!re||!he)return hb;const ze=o3({id:e,sourceNode:re,targetNode:he,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:je.connectionMode,onError:w}),Te=JD({selected:N.selected,zIndex:N.zIndex,sourceNode:re,targetNode:he,elevateOnSelect:je.elevateEdgesOnSelect,zIndexMode:je.zIndexMode});return{...ze||hb,zIndex:Te}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,w]),Jt),fe=b.useMemo(()=>N.markerStart?`url('#${im(N.markerStart,y)}')`:void 0,[N.markerStart,y]),xe=b.useMemo(()=>N.markerEnd?`url('#${im(N.markerEnd,y)}')`:void 0,[N.markerEnd,y]);if(N.hidden||W===null||H===null||G===null||K===null)return null;const me=je=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:he,multiSelectionActive:ze}=I.getState();M&&(I.setState({nodesSelectionActive:!1}),N.selected&&ze?(he({nodes:[],edges:[N]}),(Te=P.current)==null||Te.blur()):re([e])),i&&i(je,N)},ie=o?je=>{o(je,{...N})}:void 0,ke=c?je=>{c(je,{...N})}:void 0,ae=u?je=>{u(je,{...N})}:void 0,Ne=d?je=>{d(je,{...N})}:void 0,Fe=f?je=>{f(je,{...N})}:void 0,ce=je=>{var re;if(!T&&HN.includes(je.key)&&M){const{unselectNodesAndEdges:he,addSelectedEdges:ze}=I.getState();je.key==="Escape"?((re=P.current)==null||re.blur(),he({edges:[N]})):ze([e])}};return s.jsx("svg",{style:{zIndex:L},children:s.jsxs("g",{className:kn(["react-flow__edge",`react-flow__edge-${D}`,N.className,k,{selected:N.selected,animated:N.animated,inactive:!M&&!i,updating:R,selectable:M}]),onClick:me,onDoubleClick:ie,onContextMenu:ke,onMouseEnter:ae,onMouseMove:Ne,onMouseLeave:Fe,onKeyDown:F?ce:void 0,tabIndex:F?0:void 0,role:N.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":N.ariaLabel===null?void 0:N.ariaLabel||`Edge from ${N.source} to ${N.target}`,"aria-describedby":F?`${wj}-${y}`:void 0,ref:P,...N.domAttributes,children:[!E&&s.jsx(O,{id:e,source:N.source,target:N.target,type:N.type,selected:N.selected,animated:N.animated,selectable:M,deletable:N.deletable??!0,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,sourceX:W,sourceY:H,targetX:G,targetY:K,sourcePosition:V,targetPosition:Y,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:fe,markerEnd:xe,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),U&&s.jsx(bF,{edge:N,isReconnectable:U,reconnectRadius:p,onReconnect:m,onReconnectStart:g,onReconnectEnd:v,sourceX:W,sourceY:H,targetX:G,targetY:K,sourcePosition:V,targetPosition:Y,setUpdateHover:Z,setReconnecting:C})]})})}var wF=b.memo(kF);const NF=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Gj({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:o,onEdgeContextMenu:c,onEdgeMouseEnter:u,onEdgeMouseMove:d,onEdgeMouseLeave:f,onEdgeClick:p,reconnectRadius:m,onEdgeDoubleClick:g,onReconnectStart:v,onReconnectEnd:y,disableKeyboardA11y:S}){const{edgesFocusable:k,edgesReconnectable:w,elementsSelectable:T,onError:N}=Nt(NF,Jt),$=oF(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(fF,{defaultColor:e,rfId:n}),$.map(D=>s.jsx(wF,{id:D,edgesFocusable:k,edgesReconnectable:w,elementsSelectable:T,noPanClassName:i,onReconnect:o,onContextMenu:c,onMouseEnter:u,onMouseMove:d,onMouseLeave:f,onClick:p,reconnectRadius:m,onDoubleClick:g,onReconnectStart:v,onReconnectEnd:y,rfId:n,onError:N,edgeTypes:r,disableKeyboardA11y:S},D))]})}Gj.displayName="EdgeRenderer";const jF=b.memo(Gj),gb=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function SF({children:e}){const t=Wt(),n=b.useRef(null),[r]=b.useState(()=>t.getState().transform);return _j(()=>{let i=null;const o=()=>{const c=t.getState().transform;i&&c[0]===i[0]&&c[1]===i[1]&&c[2]===i[2]||(i=c,n.current&&(n.current.style.transform=gb(c)))};return o(),t.subscribe(o)},[t]),s.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:gb(r)},children:e})}function _F(e){const t=og(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const EF=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function CF(e){const t=Nt(EF),n=Wt();return b.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function IF(e){return e.connection.inProgress?{...e.connection,to:pc(e.connection.to,e.transform)}:{...e.connection}}function AF(e){return IF}function TF(e){const t=AF();return Nt(t,Jt)}const MF=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function $F({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:i,width:o,height:c,isValid:u,inProgress:d}=Nt(MF,Jt);return!(o&&i&&d)?null:s.jsx("svg",{style:e,width:o,height:c,className:"react-flow__connectionline react-flow__container",children:s.jsx("g",{className:kn(["react-flow__connection",ej(u)]),children:s.jsx(Kj,{style:t,type:n,CustomComponent:r,isValid:u})})})}const Kj=({style:e,type:t=Pi.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:i,from:o,fromNode:c,fromHandle:u,fromPosition:d,to:f,toNode:p,toHandle:m,toPosition:g,pointer:v}=TF();if(!i)return;if(n)return s.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:c,fromHandle:u,fromX:o.x,fromY:o.y,toX:f.x,toY:f.y,fromPosition:d,toPosition:g,connectionStatus:ej(r),toNode:p,toHandle:m,pointer:v});let y="";const S={sourceX:o.x,sourceY:o.y,sourcePosition:d,targetX:f.x,targetY:f.y,targetPosition:g};switch(t){case Pi.Bezier:[y]=ij(S);break;case Pi.SimpleBezier:[y]=zj(S);break;case Pi.Step:[y]=rm({...S,borderRadius:0});break;case Pi.SmoothStep:[y]=rm(S);break;default:[y]=oj(S)}return s.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};Kj.displayName="ConnectionLine";const RF={};function xb(e=RF){b.useRef(e),Wt(),b.useEffect(()=>{},[e])}function OF(){Wt(),b.useRef(!1),b.useEffect(()=>{},[])}function Yj({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:o,onEdgeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:p,onSelectionContextMenu:m,onSelectionStart:g,onSelectionEnd:v,connectionLineType:y,connectionLineStyle:S,connectionLineComponent:k,connectionLineContainerStyle:w,selectionKeyCode:T,selectionOnDrag:N,selectionMode:$,multiSelectionKeyCode:D,panActivationKeyCode:O,zoomActivationKeyCode:F,deleteKeyCode:U,onlyRenderVisibleElements:M,elementsSelectable:P,defaultViewport:R,translateExtent:Z,minZoom:E,maxZoom:C,preventScrolling:I,defaultMarkerColor:L,zoomOnScroll:W,zoomOnPinch:H,panOnScroll:G,panOnScrollSpeed:K,panOnScrollMode:V,zoomOnDoubleClick:Y,panOnDrag:fe,autoPanOnSelection:xe,onPaneClick:me,onPaneMouseEnter:ie,onPaneMouseMove:ke,onPaneMouseLeave:ae,onPaneScroll:Ne,onPaneContextMenu:Fe,paneClickDistance:ce,nodeClickDistance:je,onEdgeContextMenu:re,onEdgeMouseEnter:he,onEdgeMouseMove:ze,onEdgeMouseLeave:Te,reconnectRadius:Ge,onReconnect:Ie,onReconnectStart:tt,onReconnectEnd:et,noDragClassName:jt,noWheelClassName:On,noPanClassName:sn,disableKeyboardA11y:ln,nodeExtent:cn,rfId:rn,viewport:an,onViewportChange:Ft,nodesDraggable:Bn}){return xb(e),xb(t),OF(),_F(n),CF(an),s.jsx(X4,{onPaneClick:me,onPaneMouseEnter:ie,onPaneMouseMove:ke,onPaneMouseLeave:ae,onPaneContextMenu:Fe,onPaneScroll:Ne,paneClickDistance:ce,deleteKeyCode:U,selectionKeyCode:T,selectionOnDrag:N,selectionMode:$,onSelectionStart:g,onSelectionEnd:v,multiSelectionKeyCode:D,panActivationKeyCode:O,zoomActivationKeyCode:F,elementsSelectable:P,zoomOnScroll:W,zoomOnPinch:H,zoomOnDoubleClick:Y,panOnScroll:G,panOnScrollSpeed:K,panOnScrollMode:V,panOnDrag:fe,autoPanOnSelection:xe,defaultViewport:R,translateExtent:Z,minZoom:E,maxZoom:C,onSelectionContextMenu:m,preventScrolling:I,noDragClassName:jt,noWheelClassName:On,noPanClassName:sn,disableKeyboardA11y:ln,onViewportChange:Ft,isControlledViewport:!!an,children:s.jsxs(SF,{children:[s.jsx(jF,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:c,onReconnect:Ie,onReconnectStart:tt,onReconnectEnd:et,onlyRenderVisibleElements:M,onEdgeContextMenu:re,onEdgeMouseEnter:he,onEdgeMouseMove:ze,onEdgeMouseLeave:Te,reconnectRadius:Ge,defaultMarkerColor:L,noPanClassName:sn,disableKeyboardA11y:ln,rfId:rn}),s.jsx($F,{style:S,type:y,component:k,containerStyle:w}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(aF,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:p,nodeClickDistance:je,onlyRenderVisibleElements:M,noPanClassName:sn,noDragClassName:jt,disableKeyboardA11y:ln,nodeExtent:cn,rfId:rn,nodesDraggable:Bn}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}Yj.displayName="GraphView";const zF=b.memo(Yj),PF=XN(),vb=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:c,fitViewOptions:u,minZoom:d=.5,maxZoom:f=2,nodeOrigin:p,nodeExtent:m,zIndexMode:g="basic"}={})=>{const v=new Map,y=new Map,S=new Map,k=new Map,w=r??t??[],T=n??e??[],N=p??[0,0],$=m??Gl;uj(S,k,w);const{nodesInitialized:D}=am(T,v,y,{nodeOrigin:N,nodeExtent:$,zIndexMode:g});let O=[0,0,1];if(c&&i&&o){const F=fc(v,{filter:R=>!!((R.width||R.initialWidth)&&(R.height||R.initialHeight))}),{x:U,y:M,zoom:P}=eg(F,i,o,d,f,(u==null?void 0:u.padding)??.1);O=[U,M,P]}return{rfId:"1",width:i??0,height:o??0,transform:O,nodes:T,nodesInitialized:D,nodeLookup:v,parentLookup:y,edges:w,edgeLookup:k,connectionLookup:S,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:d,maxZoom:f,translateExtent:Gl,nodeExtent:$,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ro.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:N,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:u,fitViewResolver:null,connection:{...VN},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:PF,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ZN,zIndexMode:g,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},LF=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:c,fitViewOptions:u,minZoom:d,maxZoom:f,nodeOrigin:p,nodeExtent:m,zIndexMode:g})=>Y3((v,y)=>{async function S(){const{nodeLookup:k,panZoom:w,fitViewOptions:T,fitViewResolver:N,width:$,height:D,minZoom:O,maxZoom:F}=y();w&&(await WD({nodes:k,width:$,height:D,panZoom:w,minZoom:O,maxZoom:F},T),N==null||N.resolve(!0),v({fitViewResolver:null}))}return{...vb({nodes:e,edges:t,width:i,height:o,fitView:c,fitViewOptions:u,minZoom:d,maxZoom:f,nodeOrigin:p,nodeExtent:m,defaultNodes:n,defaultEdges:r,zIndexMode:g}),setNodes:k=>{const{nodeLookup:w,parentLookup:T,nodeOrigin:N,nodeExtent:$,elevateNodesOnSelect:D,fitViewQueued:O,zIndexMode:F,nodesSelectionActive:U}=y(),{nodesInitialized:M,hasSelectedNodes:P}=am(k,w,T,{nodeOrigin:N,nodeExtent:$,elevateNodesOnSelect:D,checkEquality:!0,zIndexMode:F}),R=U&&P;O&&M?(S(),v({nodes:k,nodesInitialized:M,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:R})):v({nodes:k,nodesInitialized:M,nodesSelectionActive:R})},setEdges:k=>{const{connectionLookup:w,edgeLookup:T}=y();uj(w,T,k),v({edges:k})},setDefaultNodesAndEdges:(k,w)=>{if(k){const{setNodes:T}=y();T(k),v({hasDefaultNodes:!0})}if(w){const{setEdges:T}=y();T(w),v({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:w,nodeLookup:T,parentLookup:N,domNode:$,nodeOrigin:D,nodeExtent:O,debug:F,fitViewQueued:U,zIndexMode:M}=y(),{changes:P,updatedInternals:R}=m3(k,T,N,$,D,O,M);R&&(d3(T,N,{nodeOrigin:D,nodeExtent:O,zIndexMode:M}),U?(S(),v({fitViewQueued:!1,fitViewOptions:void 0})):v({}),(P==null?void 0:P.length)>0&&(F&&console.log("React Flow: trigger node changes",P),w==null||w(P)))},updateNodePositions:(k,w=!1)=>{const T=[];let N=[];const{nodeLookup:$,triggerNodeChanges:D,connection:O,updateConnection:F,onNodesChangeMiddlewareMap:U}=y();for(const[M,P]of k){const R=$.get(M),Z=!!(R!=null&&R.expandParent&&(R!=null&&R.parentId)&&(P!=null&&P.position)),E={id:M,type:"position",position:Z?{x:Math.max(0,P.position.x),y:Math.max(0,P.position.y)}:P.position,dragging:w};if(R&&O.inProgress&&O.fromNode.id===R.id){const C=$a(R,O.fromHandle,Qe.Left,!0);F({...O,from:C})}Z&&R.parentId&&T.push({id:M,parentId:R.parentId,rect:{...P.internals.positionAbsolute,width:P.measured.width??0,height:P.measured.height??0}}),N.push(E)}if(T.length>0){const{parentLookup:M,nodeOrigin:P}=y(),R=ag(T,$,M,P);N.push(...R)}for(const M of U.values())N=M(N);D(N)},triggerNodeChanges:k=>{const{onNodesChange:w,setNodes:T,nodes:N,hasDefaultNodes:$,debug:D}=y();if(k!=null&&k.length){if($){const O=x4(k,N);T(O)}D&&console.log("React Flow: trigger node changes",k),w==null||w(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:w,setEdges:T,edges:N,hasDefaultEdges:$,debug:D}=y();if(k!=null&&k.length){if($){const O=v4(k,N);T(O)}D&&console.log("React Flow: trigger edge changes",k),w==null||w(k)}},addSelectedNodes:k=>{const{multiSelectionActive:w,edgeLookup:T,nodeLookup:N,triggerNodeChanges:$,triggerEdgeChanges:D}=y();if(w){const O=k.map(F=>ma(F,!0));$(O);return}$(mo(N,new Set([...k]),!0)),D(mo(T))},addSelectedEdges:k=>{const{multiSelectionActive:w,edgeLookup:T,nodeLookup:N,triggerNodeChanges:$,triggerEdgeChanges:D}=y();if(w){const O=k.map(F=>ma(F,!0));D(O);return}D(mo(T,new Set([...k]))),$(mo(N,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:w}={})=>{const{edges:T,nodes:N,nodeLookup:$,triggerNodeChanges:D,triggerEdgeChanges:O}=y(),F=k||N,U=w||T,M=[];for(const R of F){if(!R.selected)continue;const Z=$.get(R.id);Z&&(Z.selected=!1),M.push(ma(R.id,!1))}const P=[];for(const R of U)R.selected&&P.push(ma(R.id,!1));D(M),O(P)},setMinZoom:k=>{const{panZoom:w,maxZoom:T}=y();w==null||w.setScaleExtent([k,T]),v({minZoom:k})},setMaxZoom:k=>{const{panZoom:w,minZoom:T}=y();w==null||w.setScaleExtent([T,k]),v({maxZoom:k})},setTranslateExtent:k=>{var w;(w=y().panZoom)==null||w.setTranslateExtent(k),v({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:w,triggerNodeChanges:T,triggerEdgeChanges:N,elementsSelectable:$}=y();if(!$)return;const D=w.reduce((F,U)=>U.selected?[...F,ma(U.id,!1)]:F,[]),O=k.reduce((F,U)=>U.selected?[...F,ma(U.id,!1)]:F,[]);T(D),N(O)},setNodeExtent:k=>{const{nodes:w,nodeLookup:T,parentLookup:N,nodeOrigin:$,elevateNodesOnSelect:D,nodeExtent:O,zIndexMode:F}=y();k[0][0]===O[0][0]&&k[0][1]===O[0][1]&&k[1][0]===O[1][0]&&k[1][1]===O[1][1]||(am(w,T,N,{nodeOrigin:$,nodeExtent:k,elevateNodesOnSelect:D,checkEquality:!1,zIndexMode:F}),v({nodeExtent:k}))},panBy:k=>{const{transform:w,width:T,height:N,panZoom:$,translateExtent:D}=y();return g3({delta:k,panZoom:$,transform:w,translateExtent:D,width:T,height:N})},setCenter:async(k,w,T)=>{const{width:N,height:$,maxZoom:D,panZoom:O}=y();if(!O)return!1;const F=typeof(T==null?void 0:T.zoom)<"u"?T.zoom:D;return await O.setViewport({x:N/2-k*F,y:$/2-w*F,zoom:F},{duration:T==null?void 0:T.duration,ease:T==null?void 0:T.ease,interpolate:T==null?void 0:T.interpolate}),!0},cancelConnection:()=>{v({connection:{...VN}})},updateConnection:k=>{v({connection:k})},reset:()=>v({...vb()})}},Object.is);function DF({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:o,initialMinZoom:c,initialMaxZoom:u,initialFitViewOptions:d,fitView:f,nodeOrigin:p,nodeExtent:m,zIndexMode:g,children:v}){const[y]=b.useState(()=>LF({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:f,minZoom:c,maxZoom:u,fitViewOptions:d,nodeOrigin:p,nodeExtent:m,zIndexMode:g}));return s.jsx(X3,{value:y,children:s.jsx(N4,{children:s.jsx(L4,{children:v})})})}function FF({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:o,height:c,fitView:u,fitViewOptions:d,minZoom:f,maxZoom:p,nodeOrigin:m,nodeExtent:g,zIndexMode:v}){return b.useContext(Id)?s.jsx(s.Fragment,{children:e}):s.jsx(DF,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:o,initialHeight:c,fitView:u,initialFitViewOptions:d,initialMinZoom:f,initialMaxZoom:p,nodeOrigin:m,nodeExtent:g,zIndexMode:v,children:e})}const BF={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function UF({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o,edgeTypes:c,onNodeClick:u,onEdgeClick:d,onInit:f,onMove:p,onMoveStart:m,onMoveEnd:g,onConnect:v,onConnectStart:y,onConnectEnd:S,onClickConnectStart:k,onClickConnectEnd:w,onNodeMouseEnter:T,onNodeMouseMove:N,onNodeMouseLeave:$,onNodeContextMenu:D,onNodeDoubleClick:O,onNodeDragStart:F,onNodeDrag:U,onNodeDragStop:M,onNodesDelete:P,onEdgesDelete:R,onDelete:Z,onSelectionChange:E,onSelectionDragStart:C,onSelectionDrag:I,onSelectionDragStop:L,onSelectionContextMenu:W,onSelectionStart:H,onSelectionEnd:G,onBeforeDelete:K,connectionMode:V,connectionLineType:Y=Pi.Bezier,connectionLineStyle:fe,connectionLineComponent:xe,connectionLineContainerStyle:me,deleteKeyCode:ie="Backspace",selectionKeyCode:ke="Shift",selectionOnDrag:ae=!1,selectionMode:Ne=Kl.Full,panActivationKeyCode:Fe="Space",multiSelectionKeyCode:ce=Xl()?"Meta":"Control",zoomActivationKeyCode:je=Xl()?"Meta":"Control",snapToGrid:re,snapGrid:he,onlyRenderVisibleElements:ze=!1,selectNodesOnDrag:Te,nodesDraggable:Ge,autoPanOnNodeFocus:Ie,nodesConnectable:tt,nodesFocusable:et,nodeOrigin:jt=Nj,edgesFocusable:On,edgesReconnectable:sn,elementsSelectable:ln=!0,defaultViewport:cn=u4,minZoom:rn=.5,maxZoom:an=2,translateExtent:Ft=Gl,preventScrolling:Bn=!0,nodeExtent:wn,defaultMarkerColor:ws="#b1b1b7",zoomOnScroll:_r=!0,zoomOnPinch:Ks=!0,panOnScroll:Ys=!1,panOnScrollSpeed:$s=.5,panOnScrollMode:Rs=Sa.Free,zoomOnDoubleClick:Os=!0,panOnDrag:zs=!0,onPaneClick:Xs,onPaneMouseEnter:Qs,onPaneMouseMove:rs,onPaneMouseLeave:Yn,onPaneScroll:Nn,onPaneContextMenu:Q,paneClickDistance:pe=1,nodeClickDistance:Oe=0,children:st,onReconnect:It,onReconnectStart:Tt,onReconnectEnd:Be,onEdgeContextMenu:De,onEdgeDoubleClick:Xe,onEdgeMouseEnter:bt,onEdgeMouseMove:yt,onEdgeMouseLeave:Un,reconnectRadius:is=10,onNodesChange:Js,onEdgesChange:hi,noDragClassName:er="nodrag",noWheelClassName:pi="nowheel",noPanClassName:Hn="nopan",fitView:Br,fitViewOptions:as,connectOnClick:Er,attributionPosition:mi,proOptions:Rt,defaultEdgeOptions:Ns,elevateNodesOnSelect:Xn=!0,elevateEdgesOnSelect:Ur=!1,disableKeyboardA11y:tr=!1,autoPanOnConnect:Ot,autoPanOnNodeDrag:gi,autoPanOnSelection:Hr=!0,autoPanSpeed:nr,connectionRadius:Cr,isValidConnection:Ae,onError:Ze,style:ct,id:ft,nodeDragThreshold:At,connectionDragThreshold:zt,viewport:Zn,onViewportChange:Ps,width:un,height:jn,colorMode:Ls="light",debug:Ds,onScroll:os,ariaLabelConfig:Qi,zIndexMode:xi="basic",...Ir},vi){const Qn=ft||"1",ls=p4(Ls),Sn=b.useCallback(Fs=>{Fs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),os==null||os(Fs)},[os]);return s.jsx("div",{"data-testid":"rf__wrapper",...Ir,onScroll:Sn,style:{...ct,...BF},ref:vi,className:kn(["react-flow",i,ls]),id:ft,role:"application",children:s.jsxs(FF,{nodes:e,edges:t,width:un,height:jn,fitView:Br,fitViewOptions:as,minZoom:rn,maxZoom:an,nodeOrigin:jt,nodeExtent:wn,zIndexMode:xi,children:[s.jsx(h4,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:v,onConnectStart:y,onConnectEnd:S,onClickConnectStart:k,onClickConnectEnd:w,nodesDraggable:Ge,autoPanOnNodeFocus:Ie,nodesConnectable:tt,nodesFocusable:et,edgesFocusable:On,edgesReconnectable:sn,elementsSelectable:ln,elevateNodesOnSelect:Xn,elevateEdgesOnSelect:Ur,minZoom:rn,maxZoom:an,nodeExtent:wn,onNodesChange:Js,onEdgesChange:hi,snapToGrid:re,snapGrid:he,connectionMode:V,translateExtent:Ft,connectOnClick:Er,defaultEdgeOptions:Ns,fitView:Br,fitViewOptions:as,onNodesDelete:P,onEdgesDelete:R,onDelete:Z,onNodeDragStart:F,onNodeDrag:U,onNodeDragStop:M,onSelectionDrag:I,onSelectionDragStart:C,onSelectionDragStop:L,onMove:p,onMoveStart:m,onMoveEnd:g,noPanClassName:Hn,nodeOrigin:jt,rfId:Qn,autoPanOnConnect:Ot,autoPanOnNodeDrag:gi,autoPanSpeed:nr,onError:Ze,connectionRadius:Cr,isValidConnection:Ae,selectNodesOnDrag:Te,nodeDragThreshold:At,connectionDragThreshold:zt,onBeforeDelete:K,debug:Ds,ariaLabelConfig:Qi,zIndexMode:xi}),s.jsx(zF,{onInit:f,onNodeClick:u,onEdgeClick:d,onNodeMouseEnter:T,onNodeMouseMove:N,onNodeMouseLeave:$,onNodeContextMenu:D,onNodeDoubleClick:O,nodeTypes:o,edgeTypes:c,connectionLineType:Y,connectionLineStyle:fe,connectionLineComponent:xe,connectionLineContainerStyle:me,selectionKeyCode:ke,selectionOnDrag:ae,selectionMode:Ne,deleteKeyCode:ie,multiSelectionKeyCode:ce,panActivationKeyCode:Fe,zoomActivationKeyCode:je,onlyRenderVisibleElements:ze,defaultViewport:cn,translateExtent:Ft,minZoom:rn,maxZoom:an,preventScrolling:Bn,zoomOnScroll:_r,zoomOnPinch:Ks,zoomOnDoubleClick:Os,panOnScroll:Ys,panOnScrollSpeed:$s,panOnScrollMode:Rs,panOnDrag:zs,autoPanOnSelection:Hr,onPaneClick:Xs,onPaneMouseEnter:Qs,onPaneMouseMove:rs,onPaneMouseLeave:Yn,onPaneScroll:Nn,onPaneContextMenu:Q,paneClickDistance:pe,nodeClickDistance:Oe,onSelectionContextMenu:W,onSelectionStart:H,onSelectionEnd:G,onReconnect:It,onReconnectStart:Tt,onReconnectEnd:Be,onEdgeContextMenu:De,onEdgeDoubleClick:Xe,onEdgeMouseEnter:bt,onEdgeMouseMove:yt,onEdgeMouseLeave:Un,reconnectRadius:is,defaultMarkerColor:ws,noDragClassName:er,noWheelClassName:pi,noPanClassName:Hn,rfId:Qn,disableKeyboardA11y:tr,nodeExtent:wn,viewport:Zn,onViewportChange:Ps,nodesDraggable:Ge}),s.jsx(c4,{onSelectionChange:E}),st,s.jsx(r4,{proOptions:Rt,position:mi}),s.jsx(s4,{rfId:Qn,disableKeyboardA11y:tr})]})})}var HF=Sj(UF);function ZF({dimensions:e,lineWidth:t,variant:n,className:r}){return s.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:kn(["react-flow__background-pattern",n,r])})}function VF({radius:e,className:t}){return s.jsx("circle",{cx:e,cy:e,r:e,className:kn(["react-flow__background-pattern","dots",t])})}var Wi;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Wi||(Wi={}));const WF={[Wi.Dots]:1,[Wi.Lines]:1,[Wi.Cross]:6},qF=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Xj({id:e,variant:t=Wi.Dots,gap:n=20,size:r,lineWidth:i=1,offset:o=0,color:c,bgColor:u,style:d,className:f,patternClassName:p}){const m=b.useRef(null),{transform:g,patternId:v}=Nt(qF,Jt),y=r||WF[t],S=t===Wi.Dots,k=t===Wi.Cross,w=Array.isArray(n)?n:[n,n],T=[w[0]*g[2]||1,w[1]*g[2]||1],N=y*g[2],$=Array.isArray(o)?o:[o,o],D=k?[N,N]:T,O=[$[0]*g[2]+D[0]/2,$[1]*g[2]+D[1]/2],F=`${v}${e||""}`;return s.jsxs("svg",{className:kn(["react-flow__background",f]),style:{...d,...Td,"--xy-background-color-props":u,"--xy-background-pattern-color-props":c},ref:m,"data-testid":"rf__background",children:[s.jsx("pattern",{id:F,x:g[0]%T[0],y:g[1]%T[1],width:T[0],height:T[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${O[0]},-${O[1]})`,children:S?s.jsx(VF,{radius:N/2,className:p}):s.jsx(ZF,{dimensions:D,lineWidth:i,variant:t,className:p})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}Xj.displayName="Background";const GF=b.memo(Xj);function KF(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:s.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function YF(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:s.jsx("path",{d:"M0 0h32v4.2H0z"})})}function XF(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:s.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function QF(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function JF(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Au({children:e,className:t,...n}){return s.jsx("button",{type:"button",className:kn(["react-flow__controls-button",t]),...n,children:e})}const e6=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Qj({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:c,onFitView:u,onInteractiveChange:d,className:f,children:p,position:m="bottom-left",orientation:g="vertical","aria-label":v}){const y=Wt(),{isInteractive:S,minZoomReached:k,maxZoomReached:w,ariaLabelConfig:T}=Nt(e6,Jt),{zoomIn:N,zoomOut:$,fitView:D}=og(),O=()=>{N(),o==null||o()},F=()=>{$(),c==null||c()},U=()=>{D(i),u==null||u()},M=()=>{y.setState({nodesDraggable:!S,nodesConnectable:!S,elementsSelectable:!S}),d==null||d(!S)},P=g==="horizontal"?"horizontal":"vertical";return s.jsxs(Ad,{className:kn(["react-flow__controls",P,f]),position:m,style:e,"data-testid":"rf__controls","aria-label":v??T["controls.ariaLabel"],children:[t&&s.jsxs(s.Fragment,{children:[s.jsx(Au,{onClick:O,className:"react-flow__controls-zoomin",title:T["controls.zoomIn.ariaLabel"],"aria-label":T["controls.zoomIn.ariaLabel"],disabled:w,children:s.jsx(KF,{})}),s.jsx(Au,{onClick:F,className:"react-flow__controls-zoomout",title:T["controls.zoomOut.ariaLabel"],"aria-label":T["controls.zoomOut.ariaLabel"],disabled:k,children:s.jsx(YF,{})})]}),n&&s.jsx(Au,{className:"react-flow__controls-fitview",onClick:U,title:T["controls.fitView.ariaLabel"],"aria-label":T["controls.fitView.ariaLabel"],children:s.jsx(XF,{})}),r&&s.jsx(Au,{className:"react-flow__controls-interactive",onClick:M,title:T["controls.interactive.ariaLabel"],"aria-label":T["controls.interactive.ariaLabel"],children:S?s.jsx(JF,{}):s.jsx(QF,{})}),p]})}Qj.displayName="Controls";const t6=b.memo(Qj);function n6({id:e,x:t,y:n,width:r,height:i,style:o,color:c,strokeColor:u,strokeWidth:d,className:f,borderRadius:p,shapeRendering:m,selected:g,onClick:v}){const{background:y,backgroundColor:S}=o||{},k=c||y||S;return s.jsx("rect",{className:kn(["react-flow__minimap-node",{selected:g},f]),x:t,y:n,rx:p,ry:p,width:r,height:i,style:{fill:k,stroke:u,strokeWidth:d},shapeRendering:m,onClick:v?w=>v(w,e):void 0})}const s6=b.memo(n6),r6=e=>e.nodes.map(t=>t.id),ip=e=>e instanceof Function?e:()=>e;function i6({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:o=s6,onClick:c}){const u=Nt(r6,Jt),d=ip(t),f=ip(e),p=ip(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return s.jsx(s.Fragment,{children:u.map(g=>s.jsx(o6,{id:g,nodeColorFunc:d,nodeStrokeColorFunc:f,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:o,onClick:c,shapeRendering:m},g))})}function a6({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:o,shapeRendering:c,NodeComponent:u,onClick:d}){const{node:f,x:p,y:m,width:g,height:v}=Nt(y=>{const S=y.nodeLookup.get(e);if(!S)return{node:void 0,x:0,y:0,width:0,height:0};const k=S.internals.userNode,{x:w,y:T}=S.internals.positionAbsolute,{width:N,height:$}=Sr(k);return{node:k,x:w,y:T,width:N,height:$}},Jt);return!f||f.hidden||!QN(f)?null:s.jsx(u,{x:p,y:m,width:g,height:v,style:f.style,selected:!!f.selected,className:r(f),color:t(f),borderRadius:i,strokeColor:n(f),strokeWidth:o,shapeRendering:c,onClick:d,id:f.id})}const o6=b.memo(a6);var l6=b.memo(i6);const c6=200,u6=150,d6=e=>!e.hidden,f6=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};let n=!1;for(const r of e.nodeLookup.values())if(!r.hidden){n=!0;break}return{viewBB:t,boundingRect:n?KN(fc(e.nodeLookup,{filter:d6}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},yb=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,h6=(e,t)=>yb(e.viewBB,t.viewBB)&&yb(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,p6="react-flow__minimap-desc";function Jj({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:c,nodeComponent:u,bgColor:d,maskColor:f,maskStrokeColor:p,maskStrokeWidth:m,position:g="bottom-right",onClick:v,onNodeClick:y,pannable:S=!1,zoomable:k=!1,ariaLabel:w,inversePan:T,zoomStep:N=1,offsetScale:$=5}){const D=Wt(),O=b.useRef(null),{boundingRect:F,panZoom:U,viewBB:M,rfId:P,translateExtent:R,flowWidth:Z,flowHeight:E,ariaLabelConfig:C}=Nt(f6,h6),I=(e==null?void 0:e.width)??c6,L=(e==null?void 0:e.height)??u6,W=F.width/I,H=F.height/L,G=Math.max(W,H),K=G*I,V=G*L,Y=$*G,fe=F.x-(K-F.width)/2-Y,xe=F.y-(V-F.height)/2-Y,me=K+Y*2,ie=V+Y*2,ke=`${p6}-${P}`,ae=b.useRef(0),Ne=b.useRef();ae.current=G,b.useEffect(()=>{const he=D.getState().panZoom;if(O.current&&he)return Ne.current=S3({domNode:O.current,panZoom:he,getTransform:()=>D.getState().transform,getViewScale:()=>ae.current}),()=>{var ze;(ze=Ne.current)==null||ze.destroy()}},[U]),b.useEffect(()=>{var he;(he=Ne.current)==null||he.update({translateExtent:R,width:Z,height:E,inversePan:T,pannable:S,zoomStep:N,zoomable:k})},[S,k,T,N,R,Z,E]);const Fe=v?he=>{var Ge;const[ze,Te]=((Ge=Ne.current)==null?void 0:Ge.pointer(he))||[0,0];v(he,{x:ze,y:Te})}:void 0,ce=b.useCallback((he,ze)=>{const Te=D.getState().nodeLookup.get(ze).internals.userNode;y==null||y(he,Te)},[y]),je=y?ce:void 0,re=w??C["minimap.ariaLabel"];return s.jsx(Ad,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof m=="number"?m*G:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:kn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:s.jsxs("svg",{width:I,height:L,viewBox:`${fe} ${xe} ${me} ${ie}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ke,ref:O,onClick:Fe,children:[re&&s.jsx("title",{id:ke,children:re}),s.jsx(l6,{onClick:je,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:i,nodeStrokeWidth:c,nodeComponent:u}),s.jsx("path",{className:"react-flow__minimap-mask",d:`M${fe-Y},${xe-Y}h${me+Y*2}v${ie+Y*2}h${-me-Y*2}z
|
|
220
|
-
M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Jj.displayName="MiniMap";b.memo(Jj);const m6=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,g6={[Po.Line]:"right",[Po.Handle]:"bottom-right"};function x6({nodeId:e,position:t,variant:n=Po.Handle,className:r,style:i=void 0,children:o,color:c,minWidth:u=10,minHeight:d=10,maxWidth:f=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:m=!1,resizeDirection:g,autoScale:v=!0,shouldResize:y,onResizeStart:S,onResize:k,onResizeEnd:w}){const T=Aj(),N=typeof e=="string"?e:T,$=Wt(),D=b.useRef(null),O=n===Po.Handle,F=Nt(b.useCallback(m6(O&&v),[O,v]),Jt),U=b.useRef(null),M=t??g6[n];b.useEffect(()=>{if(!(!D.current||!N))return U.current||(U.current=L3({domNode:D.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:R,transform:Z,snapGrid:E,snapToGrid:C,nodeOrigin:I,domNode:L}=$.getState();return{nodeLookup:R,transform:Z,snapGrid:E,snapToGrid:C,nodeOrigin:I,paneDomNode:L}},onChange:(R,Z)=>{const{triggerNodeChanges:E,nodeLookup:C,parentLookup:I,nodeOrigin:L}=$.getState(),W=[],H={x:R.x,y:R.y},G=C.get(N);if(G&&G.expandParent&&G.parentId){const K=G.origin??L,V=R.width??G.measured.width??0,Y=R.height??G.measured.height??0,fe={id:G.id,parentId:G.parentId,rect:{width:V,height:Y,...JN({x:R.x??G.position.x,y:R.y??G.position.y},{width:V,height:Y},G.parentId,C,K)}},xe=ag([fe],C,I,L);W.push(...xe),H.x=R.x?Math.max(K[0]*V,R.x):void 0,H.y=R.y?Math.max(K[1]*Y,R.y):void 0}if(H.x!==void 0&&H.y!==void 0){const K={id:N,type:"position",position:{...H}};W.push(K)}if(R.width!==void 0&&R.height!==void 0){const V={id:N,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:R.width,height:R.height}};W.push(V)}for(const K of Z){const V={...K,type:"position"};W.push(V)}E(W)},onEnd:({width:R,height:Z})=>{const E={id:N,type:"dimensions",resizing:!1,dimensions:{width:R,height:Z}};$.getState().triggerNodeChanges([E])}})),U.current.update({controlPosition:M,boundaries:{minWidth:u,minHeight:d,maxWidth:f,maxHeight:p},keepAspectRatio:m,resizeDirection:g,onResizeStart:S,onResize:k,onResizeEnd:w,shouldResize:y}),()=>{var R;(R=U.current)==null||R.destroy()}},[M,u,d,f,p,m,S,k,w,y]);const P=M.split("-");return s.jsx("div",{className:kn(["react-flow__resize-control","nodrag",...P,n,r]),ref:D,style:{...i,scale:F,...c&&{[O?"backgroundColor":"borderColor"]:c}},children:o})}b.memo(x6);function v6(e,t=0){const n=Ee(e.connection.status),[r,i]=b.useState([]);return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return(async()=>{const{scripts:c}=await e.connection.call("scripts/list",{}),u=[];for(const d of c){if(d.packId===void 0)continue;const f=await e.connection.call("runs/tasks",{scriptId:d.id}).catch(()=>{});if(f===void 0||f.tasks.length===0)continue;const p=await e.connection.call("configs/profiles",{scriptId:d.id}).catch(()=>{});u.push({scriptId:d.id,scriptName:d.name,tasks:f.tasks,profiles:p})}o&&i(u)})().catch(()=>{}),()=>{o=!1}},[e,n.state,t]),b.useEffect(()=>e.connection.on("configs/profiles/changed",o=>{i(c=>c.map(u=>u.scriptId===o.scriptId?{...u,profiles:o.list}:u))}),[e]),r}const eS=[0,1,2,3,4,5].map(e=>({value:String(e),label:e===0?"不重试":`重试 ${e} 次`})),tS=[{value:"continue",label:"然后继续其他分支"},{value:"stop",label:"然后停止流水线"}],Lo={"script-task":"脚本任务",agent:"agent 步骤",wait:"控制节点",notify:"发消息",gate:"人工确认",start:"开始",end:"结束"},cm={pending:"待运行",waiting:"等待中",running:"运行中",succeeded:"成功",failed:"失败",skipped:"跳过",cancelled:"取消"},y6={success:"成功后",failure:"失败后",always:"结束后"},ap={desktop:"鼠标键盘",adb:"模拟器",window:"后台窗口",none:""};function b6({data:e,selected:t}){var r,i,o,c;const n=(r=e.state)==null?void 0:r.state;return Vi(e.node)?s.jsxs("div",{className:`step-node marker ${e.node.kind} ${n??""} ${t?"selected":""}`,children:[e.node.kind==="end"&&s.jsx(Hi,{type:"target",position:Qe.Left}),s.jsx("span",{children:Lo[e.node.kind]}),e.node.kind==="end"&&n!==void 0&&n!=="pending"&&s.jsx("span",{className:`step-state ${n}`,children:((i=e.state)==null?void 0:i.detail)??cm[n]}),e.node.kind==="start"&&s.jsx(Hi,{type:"source",position:Qe.Right})]}):s.jsxs("div",{className:`step-node ${n??""} ${t?"selected":""} ${e.issue!==void 0?"has-issue":""}`,children:[s.jsx(Hi,{type:"target",position:Qe.Left}),s.jsxs("div",{className:"step-kind",children:[s.jsx("span",{children:Lo[e.node.kind]}),e.input!==""&&s.jsx("span",{className:"badge",children:e.input}),e.node.waitForAll===!0&&s.jsx("span",{className:"badge",title:"等前面的节点全部结束再开始",children:"等全部"}),n!==void 0&&s.jsxs("span",{className:`step-state ${n}`,children:[cm[n],(((o=e.state)==null?void 0:o.attempts)??0)>1?` · 第 ${e.state.attempts} 次`:""]})]}),s.jsx("div",{className:"step-title",children:e.label}),e.sub!==""&&s.jsx("div",{className:"step-sub",children:e.sub}),((c=e.state)==null?void 0:c.detail)!==void 0&&e.state.detail!==""&&s.jsx("div",{className:"step-detail",children:e.state.detail}),e.issue!==void 0&&e.state===void 0&&s.jsx("div",{className:"step-detail issue",children:e.issue}),s.jsx(Hi,{type:"source",position:Qe.Right})]})}const k6={step:b6};function w6(e){const t=new Map,n=(o,c)=>{if(t.has(o))return t.get(o);if(c.has(o))return 0;c.add(o);const u=e.edges.filter(f=>f.to===o).map(f=>n(f.from,c)+1),d=Math.max(0,...u);return t.set(o,d),d};for(const o of e.nodes)n(o.id,new Set);const r=new Map,i=new Map;for(const o of e.nodes){if(o.position!==void 0){i.set(o.id,o.position);continue}const c=t.get(o.id)??0,u=r.get(c)??0;r.set(c,u+1),i.set(o.id,{x:40+c*280,y:40+u*130})}return i}let N6=0;const jl=(e,t)=>{for(;;){const n=`${e}${++N6}`;if(!t.nodes.some(r=>r.id===n))return n}};function j6({client:e,pipeline:t,onChange:n,run:r,check:i,runFrom:o,idle:c}){var R,Z;const u=ow(),[d,f]=b.useState(0),p=v6(e,d),[m,g]=b.useState(null),[v,y]=b.useState(null),[S,k]=b.useState({}),w=b.useCallback(E=>{var C,I;if(E.kind==="script-task"){const L=p.find(K=>K.scriptId===E.scriptId),W=L==null?void 0:L.tasks.find(K=>K.id===E.taskId),H=Object.entries(E.params).map(([K,V])=>`${K}=${String(V)}`).join(" "),G=E.profile===void 0?void 0:((I=(C=L==null?void 0:L.profiles)==null?void 0:C.items.find(K=>K.id===E.profile))==null?void 0:I.name)??"已删除的配置";return{label:E.title??`${(L==null?void 0:L.scriptName)??E.scriptId} · ${(W==null?void 0:W.title)??E.taskId}`,sub:[G===void 0?"":`配置:${G}`,H].filter(Boolean).join(" · "),input:ap[(W==null?void 0:W.input)??"none"]??""}}return E.kind==="wait"?{label:E.title??(E.minutes!==void 0?`等 ${E.minutes} 分钟`:`等到 ${E.until}`),sub:"",input:""}:E.kind==="agent"?{label:E.title??"agent 步骤",sub:E.prompt.slice(0,40),input:""}:Vi(E)?{label:Lo[E.kind],sub:"",input:""}:{label:E.title??Lo[E.kind],sub:E.text.slice(0,40),input:""}},[p]),T=b.useMemo(()=>w6(t),[t]),N=b.useMemo(()=>t.nodes.map(E=>{var C;return{id:E.id,type:"step",position:T.get(E.id),selected:E.id===m,...S[E.id]===void 0?{}:{measured:S[E.id]},data:{node:E,...w(E),state:r==null?void 0:r.nodes[E.id],issue:(C=i==null?void 0:i.issues.find(I=>I.nodeId===E.id&&I.level==="error"))==null?void 0:C.message}}}),[t,T,w,r,i,m,S]),$=b.useMemo(()=>t.edges.map((E,C)=>{var I;return{id:`e${C}`,source:E.from,target:E.to,label:y6[E.when],selected:C===v,animated:((I=r==null?void 0:r.nodes[E.from])==null?void 0:I.state)==="running",className:`edge-${E.when}`}}),[t.edges,v,r]),D=b.useCallback(E=>{let C=t;const I={};for(const L of E)if(L.type==="dimensions"&&L.dimensions!==void 0)I[L.id]=L.dimensions;else if(L.type==="position"&&L.position!==void 0)C={...C,nodes:C.nodes.map(W=>W.id===L.id?{...W,position:{x:Math.round(L.position.x),y:Math.round(L.position.y)}}:W)};else if(L.type==="remove"){if(C.nodes.some(W=>W.id===L.id&&Vi(W)))continue;C={...C,nodes:C.nodes.filter(W=>W.id!==L.id),edges:C.edges.filter(W=>W.from!==L.id&&W.to!==L.id)},g(null)}Object.keys(I).length>0&&k(L=>({...L,...I})),C!==t&&n(C)},[t,n]),O=b.useCallback(E=>{var I;if(E.source===E.target||t.edges.some(L=>L.from===E.source&&L.to===E.target))return;const C=t.nodes.find(L=>L.id===E.target);(C==null?void 0:C.kind)==="start"||((I=t.nodes.find(L=>L.id===E.source))==null?void 0:I.kind)==="end"||n({...t,edges:[...t.edges,{from:E.source,to:E.target,when:(C==null?void 0:C.kind)==="end"?"always":"success"}]})},[t,n]),F=E=>{const C=t.nodes.find(Y=>Y.kind==="start"),I=t.nodes.find(Y=>Y.kind==="end"),L=t.nodes.find(Y=>Y.id===m&&Y.kind!=="end")??C,W=L===void 0?void 0:T.get(L.id),H=[...T.entries()].filter(([Y])=>Y!==(I==null?void 0:I.id)).map(([,Y])=>Y),G=W===void 0?Math.max(0,...H.map(Y=>Y.x))+280:W.x+280;let K=(W==null?void 0:W.y)??40;for(;H.some(Y=>Math.abs(Y.x-G)<200&&Math.abs(Y.y-K)<100);)K+=130;const V=[...t.nodes.map(Y=>{var fe,xe;return Y.kind==="end"?{...Y,position:{x:Math.max(((fe=T.get(Y.id))==null?void 0:fe.x)??0,G+300),y:((xe=T.get(Y.id))==null?void 0:xe.y)??K}}:Y}),{...E,position:{x:G,y:K}}];n({...t,nodes:V}),g(E.id),y(null)},U=t.nodes.find(E=>E.id===m),M=v===null?void 0:t.edges[v],P=E=>n({...t,nodes:t.nodes.map(C=>C.id===E.id?E:C)});return s.jsxs("div",{className:"pipeline-editor",children:[s.jsxs("div",{className:"pipeline-palette","aria-label":"节点",children:[s.jsx("div",{className:"sidebar-label",children:"脚本任务"}),p.length===0&&s.jsx("div",{className:"muted small pad",children:"脚本库里还没有带脚本包的脚本"}),p.map(E=>s.jsxs("details",{className:"palette-group",open:p.length<=3,children:[s.jsx("summary",{children:E.scriptName}),E.tasks.map(C=>s.jsxs("button",{className:"palette-item",title:C.description??C.title,onClick:()=>F({id:jl(E.scriptId.replace(/[^A-Za-z0-9_-]/g,"").slice(0,20)||"task",t),kind:"script-task",scriptId:E.scriptId,taskId:C.id,params:{}}),children:[s.jsx("span",{children:C.title}),ap[C.input]!==""&&s.jsx("span",{className:"badge",children:ap[C.input]})]},C.id))]},E.scriptId)),s.jsx("div",{className:"sidebar-label pack-label",children:"其他步骤"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:jl("agent",t),kind:"agent",prompt:"检查活动还剩几天,快结束的提醒我"}),children:"agent 步骤"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:jl("wait",t),kind:"wait",minutes:10}),children:"控制节点"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:jl("notify",t),kind:"notify",text:`${t.name}跑完了`}),children:"发消息"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:jl("gate",t),kind:"gate",text:"确认后继续"}),children:"人工确认"}),s.jsx("p",{className:"muted small pad",children:"从节点右边的圆点拖到另一个节点左边,表示「这个完成后再运行那个」。没有连线的节点会同时开始;需要同一资源的会自动排队。"})]}),s.jsxs("div",{className:"pipeline-canvas",children:[s.jsxs(HF,{nodes:N,edges:$,nodeTypes:k6,onNodesChange:D,onConnect:O,onNodeClick:(E,C)=>{g(C.id),y(null)},onEdgeClick:(E,C)=>{y(Number(C.id.slice(1))),g(null)},onPaneClick:()=>{g(null),y(null)},deleteKeyCode:["Delete","Backspace"],colorMode:u,fitView:!0,fitViewOptions:{maxZoom:1,padding:.2},proOptions:{hideAttribution:!0},children:[s.jsx(GF,{gap:20}),s.jsx(t6,{showInteractive:!1})]}),!t.nodes.some(E=>!Vi(E))&&s.jsx("div",{className:"canvas-hint",children:"从左边点一个任务加到画布上,再从节点右边的圆点拖到下一个节点,连成先后顺序"})]}),s.jsxs("aside",{className:"pipeline-inspector",children:[U!==void 0&&s.jsx(_6,{client:e,node:U,pipeline:t,run:r,scripts:p,onChange:P,onTasksChanged:()=>f(E=>E+1),runFrom:o,onRemove:()=>{n({...t,nodes:t.nodes.filter(E=>E.id!==U.id),edges:t.edges.filter(E=>E.from!==U.id&&E.to!==U.id)}),g(null)}}),M!==void 0&&s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:"连线"}),s.jsxs("p",{className:"muted small",children:["「",((R=t.nodes.find(E=>E.id===M.from))==null?void 0:R.title)??M.from,"」→「",((Z=t.nodes.find(E=>E.id===M.to))==null?void 0:Z.title)??M.to,"」"]}),s.jsx("label",{className:"field-label",htmlFor:"edge-when",children:"什么时候运行下一步"}),s.jsx(yn,{id:"edge-when",value:M.when,onChange:E=>n({...t,edges:t.edges.map((C,I)=>I===v?{...C,when:E}:C)}),options:[{value:"success",label:"上一步成功后"},{value:"failure",label:"上一步失败后"},{value:"always",label:"上一步结束后",hint:"不管成败"}]}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>{n({...t,edges:t.edges.filter((E,C)=>C!==v)}),y(null)},children:"删除连线"})]}),U===void 0&&M===void 0&&(c??s.jsx("p",{className:"muted small pad",children:"点一个节点或连线来修改。选中后按 Delete 也能删除。"})),(U!==void 0||M!==void 0)&&c!==void 0&&s.jsx("button",{className:"link-button small back-to-pipeline",onClick:()=>{g(null),y(null)},children:"← 流水线设置"})]})]})}function S6({client:e,value:t,onChange:n}){const r=b.useRef(null),i=nw({client:e,text:t,setText:n,area:r,placement:"below"});return s.jsxs("div",{className:"slash-anchor",children:[s.jsx("textarea",{id:"node-prompt",ref:r,className:"text-input plain",rows:4,value:t,placeholder:"例如:/game-arknights 看看活动商店还剩什么没换",onChange:o=>n(o.target.value),onKeyDown:o=>{i.onKeyDown(o)}}),i.menu,s.jsx("p",{className:"muted small",children:"输入 / 可以选命令或技能,运行时展开成完整的指令。"})]})}function _6({client:e,node:t,pipeline:n,run:r,scripts:i,onChange:o,onRemove:c,onTasksChanged:u,runFrom:d}){var y,S;const[f,p]=b.useState(null),m=r==null?void 0:r.nodes[t.id],g=t.kind==="script-task"?(y=i.find(k=>k.scriptId===t.scriptId))==null?void 0:y.tasks.find(k=>k.id===t.taskId):void 0,v=t.onFailure;return Vi(t)?s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:Lo[t.kind]}),s.jsx("p",{className:"muted small",children:t.kind==="start"?"流水线从这里开始。从它连出去的步骤最先运行(没有连线的步骤也会一开始就运行)。":"所有步骤都结束后到这里,不管成败;连到它的线只是为了看得清楚。"}),(m==null?void 0:m.detail)!==void 0&&s.jsx("div",{className:"muted small",children:m.detail})]}):s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:Lo[t.kind]}),s.jsx("label",{className:"field-label",htmlFor:"node-title",children:"名称(可选)"}),s.jsx("input",{id:"node-title",className:"text-input plain",value:t.title??"",maxLength:60,onChange:k=>{const{title:w,...T}=t;o(k.target.value===""?T:{...T,title:k.target.value})}}),t.kind==="script-task"&&s.jsx(cN,{id:"node-profile",label:"用哪份配置",list:((S=i.find(k=>k.scriptId===t.scriptId))==null?void 0:S.profiles)??null,value:t.profile,onChange:k=>{const{profile:w,...T}=t;o(k===void 0?T:{...T,profile:k})}}),t.kind==="script-task"&&g!==void 0&&Object.entries(g.params).map(([k,w])=>s.jsx(oN,{client:e,scriptId:t.scriptId,taskId:t.taskId,name:k,spec:w,profile:t.profile,value:String(t.params[k]??(w.type==="boolean"?w.default??!1:"")),onCreated:u,onChange:T=>{const{[k]:N,...$}=t.params,D=w.type==="boolean"?T==="true":w.type==="integer"||w.type==="number"?Number(T):T;o({...t,params:T===""?$:{...$,[k]:D}})}},k)),t.kind==="agent"&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-prompt",children:"让 agent 做什么"}),s.jsx(S6,{client:e,value:t.prompt,onChange:k=>o({...t,prompt:k})})]}),(t.kind==="notify"||t.kind==="gate")&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-text",children:t.kind==="notify"?"消息内容":"确认时显示的话"}),s.jsx("textarea",{id:"node-text",className:"text-input plain",rows:3,value:t.text,onChange:k=>o({...t,text:k.target.value})})]}),t.kind==="wait"&&s.jsxs("div",{className:"key-input",children:[s.jsx(yn,{"aria-label":"等待方式",value:t.minutes!==void 0?"minutes":"until",options:[{value:"minutes",label:"等几分钟"},{value:"until",label:"等到某个时间"}],onChange:k=>o(k==="minutes"?{id:t.id,kind:"wait",minutes:10,...t.title===void 0?{}:{title:t.title},...t.position===void 0?{}:{position:t.position}}:{id:t.id,kind:"wait",until:"05:00",...t.title===void 0?{}:{title:t.title},...t.position===void 0?{}:{position:t.position}})}),t.minutes!==void 0?s.jsx("input",{className:"text-input plain",type:"number",min:1,max:1440,value:t.minutes,onChange:k=>o({...t,minutes:Math.max(1,Math.min(1440,Math.round(Number(k.target.value)||1)))})}):s.jsx("input",{className:"text-input plain",type:"time",value:t.until,onChange:k=>o({...t,until:k.target.value})})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.waitForAll===!0,onChange:k=>{const{waitForAll:w,...T}=t;o(k.target.checked?{...T,waitForAll:!0}:T)}}),"等前面的节点全部结束再开始"]}),s.jsx("p",{className:"muted small",children:"不只等连进来的线:画布上不在它后面的节点(其他分支也算)都结束了(成功、失败、跳过都算)才开始。用来让并行的几条分支汇合。"}),t.kind!=="gate"&&t.kind!=="notify"&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-retries",children:"失败时"}),s.jsxs("div",{className:"select-stack",children:[s.jsx(yn,{id:"node-retries","aria-label":"重试次数",value:v===void 0?"inherit":String(v.retries),options:[{value:"inherit",label:"按流水线的设置"},...eS],onChange:k=>{const{onFailure:w,...T}=t;if(k==="inherit")return o(T);o({...T,onFailure:{retries:Number(k),then:(v==null?void 0:v.then)??n.onFailure.then}})}}),s.jsx(yn,{"aria-label":"仍失败时",disabled:v===void 0,value:(v??n.onFailure).then,options:tS,onChange:k=>o({...t,onFailure:{retries:(v==null?void 0:v.retries)??n.onFailure.retries,then:k}})})]}),v===void 0&&s.jsxs("p",{className:"muted small",children:["流水线的设置:",n.onFailure.retries>0?`重试 ${n.onFailure.retries} 次,`:"不重试,","然后",n.onFailure.then==="stop"?"停止流水线":"继续其他分支"]})]}),m!==void 0&&s.jsxs("div",{className:"inspector-run",children:[s.jsx("div",{className:"sidebar-label",children:"这次运行"}),s.jsxs("div",{children:[cm[m.state],m.attempts>1?` · 第 ${m.attempts} 次`:""]}),m.detail!==void 0&&s.jsx("div",{className:"muted small",children:m.detail}),m.runIds.length>0&&s.jsxs("div",{className:"muted small",children:["脚本运行:",m.runIds.join("、"),"(在「运行」页看日志)"]}),t.kind==="gate"&&m.state==="running"&&r!==void 0&&s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"primary small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:r.id,nodeId:t.id,decision:"continue"}).catch(k=>p(Pe(k))),children:"继续"}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:r.id,nodeId:t.id,decision:"stop"}).catch(k=>p(Pe(k))),children:"停止"})]})]}),f!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:f})]}),d!==void 0&&s.jsxs("div",{className:"run-from",children:[s.jsxs("button",{className:"small-button",onClick:()=>d(t.id),children:[s.jsx(ee,{name:"arrow"}),"从这里开始运行"]}),s.jsx("span",{className:"muted small",children:"这一步和它后面的会运行,前面的不运行(例如前面已经跑过了)"})]}),s.jsx("button",{className:"danger-outline small-button",onClick:c,children:"删除这个节点"})]})}const ld={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]},E6=()=>({id:`pipeline-${Date.now().toString(36)}`,name:"新流水线",nodes:[{id:"start",kind:"start",position:{x:40,y:120}},{id:"end",kind:"end",position:{x:360,y:120}}],edges:[],onFailure:{retries:0,then:"continue"},schedule:{enabled:!1,times:[],days:[],catchUpMinutes:10},stopEmulatorAfter:!1,closeGameAfter:!1,powerAfter:"none"});function C6({client:e,openSettings:t,arg:n}){const r=Ee(e.connection.status),i=Cn(3e4),[o,c]=b.useState(null),[u,d]=b.useState(null),[f,p]=b.useState(null),[m,g]=b.useState(""),[v,y]=b.useState([]),[S,k]=b.useState(null),[w,T]=b.useState(null),[N,$]=b.useState(null),[D,O]=b.useState(null),[F,U]=b.useState(0);b.useEffect(()=>e.connection.on("pipelines/changed",()=>U(ie=>ie+1)),[e]);const M=Ee(e.capabilities),[P,R]=b.useState(null),[Z,E]=b.useState(0);b.useEffect(()=>e.connection.on("schedule/changed",()=>E(ie=>ie+1)),[e]),b.useEffect(()=>{if(r.state!=="open"||!M.has("schedule"))return;let ie=!0;return e.connection.call("schedule/status",{}).then(ke=>{ie&&R(ke.settings)}).catch(()=>{}),()=>{ie=!1}},[e,r.state,M,Z]);const C=async ie=>{try{R((await e.connection.call("schedule/settings/set",ie)).settings)}catch(ke){O(Pe(ke))}};b.useEffect(()=>{n!==void 0&&d(n)},[n]),b.useEffect(()=>{if(r.state!=="open")return;let ie=!0;return e.connection.call("pipelines/list",{}).then(ke=>{ie&&(c(ke.items),d(ae=>{var Ne;return ae??((Ne=ke.items[0])==null?void 0:Ne.id)??null}))}).catch(ke=>{ie&&O(Pe(ke))}),()=>{ie=!1}},[e,r.state,F]),b.useEffect(()=>{if(u===null||r.state!=="open"||(f==null?void 0:f.id)===u&&(o!=null&&o.every(ke=>ke.id!==u)))return;let ie=!0;return e.connection.call("pipelines/get",{id:u}).then(ke=>{if(!ie)return;const ae=wT(ke);p(ae),g(JSON.stringify(ae)),T(null)}).catch(()=>{}),e.connection.call("pipelines/runs",{pipelineId:u,limit:10}).then(ke=>{ie&&y(ke.items)}).catch(()=>{}),k(null),()=>{ie=!1}},[e,u,r.state,F]),b.useEffect(()=>e.connection.on("pipelines/run",ie=>{ie.pipelineId===u&&y(ke=>[ie,...ke.filter(ae=>ae.id!==ie.id)].sort((ae,Ne)=>Ne.startedAt-ae.startedAt).slice(0,10))}),[e,u]);const I=f!==null&&JSON.stringify(f)!==m,L=f!==null&&o!==null&&o.every(ie=>ie.id!==f.id),W=v.find(ie=>{var ke;return ie.id===(S??((ke=v[0])==null?void 0:ke.id))}),H=v.find(ie=>ie.state==="running"),G=H!==void 0&&(H.stopping!==void 0||N==="cancel");b.useEffect(()=>{if(f===null||!f.nodes.some(ke=>!Vi(ke))){T(null);return}const ie=setTimeout(()=>{e.connection.call("pipelines/check",{pipeline:f}).then(T).catch(()=>{})},400);return()=>clearTimeout(ie)},[e,f]);const K=async(ie,ke)=>{$(ie),O(null);try{await ke()}catch(ae){O(Pe(ae))}finally{$(null)}},V=()=>K("save",async()=>{if(f===null)return;const ie=await e.connection.call("pipelines/save",{pipeline:f});p(ie.pipeline),g(JSON.stringify(ie.pipeline)),T(ie.check),d(ie.pipeline.id)}),Y=ie=>K("run",async()=>{if(f===null)return;(I||L)&&await V();const ke=await e.connection.call("pipelines/run",{id:f.id,...ie===void 0?{}:{from:ie}});k(ke.id)}),fe=()=>K("remove",async()=>{f!==null&&(L||await e.connection.call("pipelines/remove",{id:f.id}),p(null),d(null))}),xe=b.useCallback(ie=>p(ie),[]),me=()=>{const ie=E6();p(ie),g(""),d(ie.id),y([]),T(null)};return s.jsxs("section",{className:"main scripts-page pipelines-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"编排"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"流水线"})]}),s.jsx(T6,{list:o??[],current:f,isNew:L,now:i,onPick:d}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>t("schedule"),children:[s.jsx(ee,{name:"settings"}),"定时与自启"]}),s.jsxs("button",{className:"primary small-button",onClick:me,children:[s.jsx(ee,{name:"plus"}),"新建流水线"]})]})]}),s.jsx("div",{className:"pipeline-main",children:f===null?s.jsxs("div",{className:"empty",children:[s.jsx(ee,{name:"flow"}),o!==null&&o.length===0?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"还没有流水线。"}),s.jsx("p",{className:"muted small",children:"新建一条,或对 agent 说「先跑方舟日常,同时跑三月七,都完了发飞书」"})]}):s.jsx("p",{children:"在上面选一条流水线,或新建一条。"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"pipeline-toolbar",children:[s.jsx("input",{className:"text-input plain pipeline-name",value:f.name,maxLength:60,"aria-label":"流水线名称",onChange:ie=>p({...f,name:ie.target.value})}),f.draft===!0&&s.jsx("span",{className:"badge warn",title:"agent 生成的草稿:保存后才会按定时运行",children:"agent 草稿"}),I&&s.jsx("span",{className:"muted small",children:"未保存"}),s.jsx("span",{className:"spacer"}),G?s.jsxs("button",{className:"danger-outline small-button stopping",disabled:!0,"aria-busy":"true",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),"正在停止…"]}):H!==void 0?s.jsx("button",{className:"danger-outline small-button",disabled:N!==null,onClick:()=>void K("cancel",()=>e.connection.call("pipelines/cancel",{runId:H.id})),children:"取消运行"}):s.jsxs("button",{className:"small-button",disabled:N!==null||!f.nodes.some(ie=>!Vi(ie))||(w==null?void 0:w.ok)===!1,onClick:()=>void Y(),children:[s.jsx(ee,{name:"arrow"}),"运行"]}),s.jsx("button",{className:"primary small-button",disabled:N!==null||!I&&!L&&f.draft!==!0,onClick:()=>void V(),children:N==="save"?"保存中…":f.draft===!0&&!I?"确认并保存":"保存"}),s.jsx("button",{className:"small-button",disabled:N!==null||H!==void 0,onClick:()=>{confirm(`删除流水线「${f.name}」?`)&&fe()},children:"删除"})]}),G&&s.jsxs("div",{className:"notice info left small pipeline-stopping",role:"status",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),s.jsxs("span",{children:["已收到停止指令。",H.stopping??"正在通知正在运行的步骤…"]})]}),D!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:D})]}),s.jsx(j6,{client:e,pipeline:f,onChange:xe,run:W,check:w,runFrom:H!==void 0||N!==null||(w==null?void 0:w.ok)===!1?void 0:ie=>void Y(ie),idle:s.jsx(M6,{pipeline:f,check:w,runs:v,shownRun:W==null?void 0:W.id,onShowRun:k,others:o??[],onChange:xe,now:i,startup:P,onStartup:ie=>void C(ie)})},f.id)]})})]})}function I6({check:e,pipeline:t}){if(e===null)return null;const n=r=>{const i=t.nodes.find(o=>o.id===r);return i===void 0?"":`${i.title??i.id}:`};return s.jsxs("section",{className:"side-pane",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"运行前检查"}),s.jsx("p",{className:"muted small",children:e.estimateMinutes===void 0?"部分任务没有预计时长":`预计约 ${e.estimateMinutes} 分钟`})]}),s.jsx("span",{className:`badge ${e.ok?"ok":"warn"}`,children:e.ok?"可以运行":"有问题"})]}),e.issues.length===0&&s.jsx("div",{className:"muted small",children:"没有发现问题。"}),s.jsx("ul",{className:"incident-steps",children:e.issues.map((r,i)=>s.jsxs("li",{className:r.level==="error"||r.level==="warning"?"failed":"",children:[r.level==="error"?"✗":r.level==="warning"?"!":"ℹ"," ",n(r.nodeId),r.message]},i))})]})}function A6({runs:e,shown:t,onShow:n,now:r}){if(e.length===0)return s.jsx("section",{className:"side-pane",children:s.jsx("p",{className:"muted small",children:"还没有运行过。"})});const i={manual:"手动",schedule:"定时",autostart:"启动时",agent:"agent",after:"接续"};return s.jsxs("section",{className:"side-pane",children:[s.jsx("div",{className:"run-history",children:e.map(o=>s.jsxs("button",{className:`run-row ${o.id===t?"active":""}`,onClick:()=>n(o.id),children:[s.jsx("span",{className:`badge ${ld[o.state][0]}`,children:ld[o.state][1]}),s.jsx("span",{className:"run-title",children:i[o.trigger.kind]??o.trigger.kind}),s.jsx("span",{className:"muted small run-outcome",children:o.outcome??"…"}),s.jsx("span",{className:"session-time",children:$t(o.startedAt,r)})]},o.id))}),s.jsx("p",{className:"muted small",children:"选中一次运行,画布上的节点会显示它的状态;点节点看详情和对应的脚本运行。"})]})}function T6({list:e,current:t,isNew:n,now:r,onPick:i}){const[o,c]=b.useState(!1),u=b.useRef(null);return b.useEffect(()=>{if(!o)return;const d=f=>{u.current!==null&&!u.current.contains(f.target)&&c(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[o]),e.length===0&&t===null?s.jsx("span",{className:"spacer"}):s.jsxs("div",{className:"pipeline-switcher",ref:u,children:[s.jsxs("button",{className:"small-button switcher-button","aria-haspopup":"listbox","aria-expanded":o,onClick:()=>c(d=>!d),children:[s.jsx(ee,{name:"flow"}),s.jsxs("span",{className:"switcher-name",children:[(t==null?void 0:t.name)??"选择流水线",n?"(未保存)":""]}),s.jsxs("span",{className:"muted small",children:[e.length," 条"]}),s.jsx(ee,{name:"chevron-down"})]}),o&&s.jsxs("div",{className:"switcher-menu",role:"listbox","aria-label":"流水线",children:[e.map(d=>s.jsxs("button",{role:"option","aria-selected":d.id===(t==null?void 0:t.id),className:`switcher-item ${d.id===(t==null?void 0:t.id)&&!n?"active":""}`,onClick:()=>{i(d.id),c(!1)},children:[s.jsxs("span",{className:"switcher-item-main",children:[s.jsx("span",{children:d.name}),s.jsxs("span",{className:"muted small",children:[d.nodes," 个步骤",d.schedule.enabled&&d.schedule.times.length>0?` · 每天 ${d.schedule.times.join("、")}`:"",d.lastRun===void 0?"":` · ${$t(d.lastRun.startedAt,r)}`]})]}),d.draft?s.jsx("span",{className:"badge warn",children:"草稿"}):d.lastRun!==void 0?s.jsx("span",{className:`badge ${ld[d.lastRun.state][0]}`,children:ld[d.lastRun.state][1]}):null]},d.id)),e.length===0&&s.jsx("div",{className:"muted small pad",children:"还没有保存的流水线"})]})]})}function M6({pipeline:e,check:t,runs:n,shownRun:r,onShowRun:i,others:o,onChange:c,now:u,startup:d,onStartup:f}){const[p,m]=b.useState(n.some(v=>v.state==="running")?"runs":"check"),g=(t==null?void 0:t.issues.filter(v=>v.level==="error").length)??0;return s.jsxs("div",{className:"pipeline-side",children:[s.jsxs("nav",{className:"tabs side-tabs",role:"tablist","aria-label":"流水线",children:[s.jsxs("button",{role:"tab","aria-selected":p==="check",className:p==="check"?"active":"",onClick:()=>m("check"),children:["检查",g>0?` · ${g}`:""]}),s.jsx("button",{role:"tab","aria-selected":p==="runs",className:p==="runs"?"active":"",onClick:()=>m("runs"),children:"运行记录"}),s.jsx("button",{role:"tab","aria-selected":p==="schedule",className:p==="schedule"?"active":"",onClick:()=>m("schedule"),children:"定时与失败"})]}),p==="check"&&(t===null?s.jsx("p",{className:"muted small pad",children:"加上步骤后会自动检查。"}):s.jsx(I6,{check:t,pipeline:e})),p==="runs"&&s.jsx(A6,{runs:n,shown:r,onShow:i,now:u}),p==="schedule"&&s.jsx(R6,{pipeline:e,others:o,onChange:c,startup:d,onStartup:f}),s.jsx("p",{className:"muted small pad",children:"点画布上的节点或连线来修改它;选中后按 Delete 删除。"})]})}const $6=["日","一","二","三","四","五","六"],bb={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function R6({pipeline:e,others:t,onChange:n,startup:r,onStartup:i}){const o=(r==null?void 0:r.autostartPipelines.includes(e.id))===!0,c=e.schedule,[u,d]=b.useState(c.times.join(","));b.useEffect(()=>d(c.times.join(",")),[e.id]);const f=g=>n({...e,schedule:{...c,...g}}),p=b.useMemo(()=>u.split(/[,,\s]+/).map(g=>g.trim()).filter(Boolean).map(g=>/^\d:\d\d$/.test(g)?`0${g}`:g),[u]),m=p.filter(g=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(g));return s.jsxs("section",{className:"side-pane",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.enabled,onChange:g=>f({enabled:g.target.checked})}),"按定时自动运行",e.draft===!0?"(草稿要先保存)":""]}),s.jsx("label",{className:"field-label",htmlFor:"pl-times",children:"时间(24 小时制,多个用逗号分开)"}),s.jsx("input",{id:"pl-times",className:"text-input",value:u,placeholder:"04:30,16:30",onChange:g=>d(g.target.value),onBlur:()=>{m.length===0&&f({times:[...new Set(p)].sort()})}}),m.length>0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsxs("span",{children:["时间写成 HH:MM:",m.join("、")]})]}),s.jsxs("div",{className:"chip-row",role:"group","aria-label":"星期",children:[$6.map((g,v)=>s.jsxs("button",{className:`chip ${c.days.includes(v)?"active":""}`,onClick:()=>f({days:c.days.includes(v)?c.days.filter(y=>y!==v):[...c.days,v].sort()}),children:["周",g]},g)),s.jsx("span",{className:"muted small",children:c.days.length===0?"不选=每天":""})]}),r!==null&&s.jsxs("div",{className:"startup-box",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:o,disabled:e.draft===!0,onChange:g=>i({autostartPipelines:g.target.checked?[...r.autostartPipelines,e.id]:r.autostartPipelines.filter(v=>v!==e.id)})}),"软件启动时运行",e.draft===!0?"(草稿要先保存)":""]}),o&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"check-label sub",children:[s.jsx("input",{type:"checkbox",checked:r.firstStartOnly,onChange:g=>i({firstStartOnly:g.target.checked})}),"只在每天第一次启动时运行(每天从 4:00 算起)"]}),s.jsxs("label",{className:"check-label sub",children:[s.jsx("input",{type:"checkbox",checked:r.skipIfRanToday,onChange:g=>i({skipIfRanToday:g.target.checked})}),"今天(4:00 起)已经成功运行过就跳过"]}),s.jsxs("p",{className:"muted small",children:["打开桌面版(自己打开或开机自启)后",r.autostart?`开机自启时等 ${r.autostartDelaySeconds} 秒、自己打开时等 10 秒`:"等 10 秒","再运行;dsh 崩溃后自动重启不算。和游戏一样,每天从 4:00 算起:凌晨 2 点启动还算前一天。这两项对所有「软件启动时运行」的流水线生效。"]})]})]}),s.jsx("label",{className:"field-label",htmlFor:"pl-catchup",children:"错过多少分钟以内还补跑(睡眠、刚开机)"}),s.jsx("input",{id:"pl-catchup",className:"text-input plain",type:"number",min:0,max:720,value:c.catchUpMinutes,onChange:g=>f({catchUpMinutes:Math.max(0,Math.min(720,Math.round(Number(g.target.value)||0)))})}),s.jsx("label",{className:"field-label",htmlFor:"pl-after",children:"另一条流水线成功后接着运行"}),s.jsx(yn,{id:"pl-after",value:c.after??"",onChange:g=>{const{after:v,...y}=c;n({...e,schedule:g===""?y:{...y,after:g}})},options:[{value:"",label:"不接续"},...t.filter(g=>g.id!==e.id).map(g=>({value:g.id,label:g.name}))]}),s.jsx("label",{className:"field-label",htmlFor:"pl-fail",children:"节点失败时(节点自己没设置时)"}),s.jsxs("div",{className:"select-stack",children:[s.jsx(yn,{id:"pl-fail","aria-label":"重试次数",value:String(e.onFailure.retries),options:eS,onChange:g=>n({...e,onFailure:{...e.onFailure,retries:Number(g)}})}),s.jsx(yn,{"aria-label":"仍失败时",value:e.onFailure.then,options:tS,onChange:g=>n({...e,onFailure:{...e.onFailure,then:g}})})]}),s.jsx("div",{className:"field-label",children:"结束后"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:e.closeGameAfter,onChange:g=>n({...e,closeGameAfter:g.target.checked})}),"关闭游戏(任务玩过的电脑游戏和模拟器里的游戏)"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:e.stopEmulatorAfter,onChange:g=>n({...e,stopEmulatorAfter:g.target.checked})}),"关闭模拟器"]}),s.jsx("label",{className:"field-label",htmlFor:"pl-power",children:"然后电脑"}),s.jsx(yn,{id:"pl-power",value:e.powerAfter,onChange:g=>n({...e,powerAfter:g}),options:[{value:"none",label:"保持开着"},{value:"sleep",label:"睡眠"},{value:"hibernate",label:"休眠",hint:"断电也不丢失进度,唤醒比睡眠慢"},{value:"shutdown",label:"关机"}]}),e.powerAfter!=="none"&&s.jsxs("p",{className:"muted small",children:["等其他任务都结束后先倒计时",r===null?"":` ${r.powerCountdownSeconds} 秒`,",界面和飞书里都可以取消;15 分钟内还有定时任务就不",bb[e.powerAfter],"。在这里手动点运行、或运行被取消时不会",bb[e.powerAfter],"。",e.powerAfter==="shutdown"?"关机会强制关闭所有程序。":"想让电脑按时醒来跑定时任务,在「设置 → 定时与自启」打开定时唤醒。"]})]})}const kb=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"}),wb={fired:["ok","已运行"],missed:["warn","错过"],skipped:["","跳过"],failed:["warn","没能运行"]};function O6({client:e}){const t=Ee(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(0),[u,d]=b.useState(!1),[f,p]=b.useState(null);b.useEffect(()=>e.connection.on("schedule/changed",()=>c(v=>v+1)),[e]),b.useEffect(()=>e.connection.on("pipelines/changed",()=>c(v=>v+1)),[e]),b.useEffect(()=>e.connection.on("schedule/power",v=>i(y=>y===null?y:{...y,power:v})),[e]),b.useEffect(()=>{if(t.state!=="open")return;let v=!0;return e.connection.call("schedule/status",{}).then(y=>{v&&i(y)}).catch(y=>{v&&p(Pe(y))}),()=>{v=!1}},[e,t.state,o]);const m=async v=>{d(!0),p(null);try{i(await e.connection.call("schedule/settings/set",v))}catch(y){p(Pe(y))}finally{d(!1)}},g=r==null?void 0:r.settings;return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"定时与自启"}),s.jsx("p",{children:"每条流水线的运行时间和结束后做什么(关游戏、关模拟器、睡眠或关机)在「编排」页里设置。这里设置电脑开机登录后是否自动启动 MultiGameAssistant,以及电脑睡着时要不要按时醒来。关掉窗口后程序在托盘里继续运行,定时照常执行。"}),r!==null&&g!==void 0&&s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"开机自启"}),s.jsx("p",{className:"muted small",children:r.autostart.detail??(r.autostart.registered?"已在 Windows 任务计划程序中注册(登录后启动,最小化到托盘)":"登录 Windows 后自动启动并最小化到托盘")})]}),s.jsx("span",{className:`badge ${r.autostart.registered?"ok":""}`,children:r.autostart.registered?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:g.autostart,disabled:u||!r.autostart.available,onChange:v=>void m({autostart:v.target.checked})}),"登录 Windows 后自动启动"]}),s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsxs("span",{children:["软件启动时运行哪些流水线、是否只在每天第一次启动时运行,在「编排」页每条流水线的「定时与失败」里设置。",g.autostartPipelines.length>0?`现在有 ${g.autostartPipelines.length} 条。`:""]})]}),s.jsx("label",{className:"field-label",htmlFor:"autostart-delay",children:"开机自启后等待多少秒再运行流水线(等网络、桌面和显卡驱动就绪)"}),s.jsx("input",{id:"autostart-delay",className:"text-input plain",type:"number",min:0,max:1800,defaultValue:g.autostartDelaySeconds,onBlur:v=>void m({autostartDelaySeconds:Math.max(0,Math.min(1800,Math.round(Number(v.target.value)||0)))})}),r.autostarted&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsx("span",{children:"这次是开机自动启动的。"})]})]}),r!==null&&g!==void 0&&s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"定时唤醒"}),s.jsx("p",{className:"muted small",children:r.wake.detail??(r.wake.registered&&r.wake.next!==void 0?`已在 Windows 任务计划程序中注册,下次在 ${kb(r.wake.next)} 唤醒`:"电脑睡眠(或休眠)时,在定时任务开始前 2 分钟把它唤醒")})]}),s.jsx("span",{className:`badge ${r.wake.registered?"ok":""}`,children:r.wake.registered?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:g.wakeToRun,disabled:u||!r.wake.available,onChange:v=>void m({wakeToRun:v.target.checked})}),"睡眠时按定时唤醒电脑"]}),s.jsx("p",{className:"muted small",children:"关机后不能唤醒。程序没开着时,唤醒会顺便把它在托盘里打开(不运行「软件启动时运行」的流水线)。要在 Windows 电源选项里允许唤醒定时器:控制面板 → 电源选项 → 更改计划设置 → 更改高级电源设置 → 睡眠 → 允许使用唤醒定时器 → 启用(笔记本的「使用电池」也要改)。"}),s.jsx("h3",{children:"运行时防睡眠"}),s.jsxs("p",{className:"muted small",children:["流水线或脚本运行时,电脑不会自己睡眠;前台脚本(用鼠标键盘的)运行时屏幕也保持亮着。全部结束后恢复 Windows 自己的设置。",r.power.awake?"现在正在防睡眠。":""]}),s.jsx("label",{className:"field-label",htmlFor:"power-countdown",children:"流水线结束后睡眠、休眠或关机前倒计时多少秒(这段时间里可以取消)"}),s.jsx("input",{id:"power-countdown",className:"text-input plain",type:"number",min:10,max:600,defaultValue:g.powerCountdownSeconds,onBlur:v=>void m({powerCountdownSeconds:Math.max(10,Math.min(600,Math.round(Number(v.target.value)||60)))})})]}),r!==null&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"接下来"}),r.upcoming.length===0&&s.jsx("div",{className:"muted small",children:"没有开启定时的流水线。"}),s.jsx("ul",{className:"version-list",children:r.upcoming.map((v,y)=>s.jsxs("li",{children:[s.jsx("span",{className:"version-name",children:kb(v.at)}),s.jsx("span",{children:v.pipelineName})]},y))})]}),r!==null&&r.history.length>0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"最近的定时记录"}),s.jsx("ul",{className:"version-list",children:r.history.map((v,y)=>{var S,k;return s.jsxs("li",{children:[s.jsx("span",{className:`badge ${((S=wb[v.outcome])==null?void 0:S[0])??""}`,children:((k=wb[v.outcome])==null?void 0:k[1])??v.outcome}),s.jsx("span",{children:v.pipelineName}),s.jsxs("span",{className:"muted small",children:[v.slot,v.detail===void 0?"":` · ${v.detail}`]}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"session-time",children:$t(v.at,n)})]},y)})})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"无人值守检查清单"}),s.jsxs("ul",{className:"guide-steps",children:[s.jsxs("li",{children:["前台脚本(如三月七)需要已登录、没有锁屏的桌面:在 Windows 里设置自动登录(运行 ",s.jsx("code",{children:"netplwiz"}),"),关闭屏幕保护程序;睡眠唤醒后不要求登录(设置 → 帐户 → 登录选项 →「需要登录」选「从不」)。"]}),s.jsx("li",{children:"模拟器脚本(如 MAA)不受锁屏影响。"}),s.jsx("li",{children:"运行期间程序会阻止电脑睡眠;想让睡着的电脑按时醒来跑定时任务,打开上面的「定时唤醒」。关机后的电脑不能被唤醒,可以在主板 BIOS 里设置定时开机,再配合开机自启。"}),s.jsx("li",{children:"没接显示器时,游戏可能以很小的分辨率启动;可以接一个 HDMI 假负载(显卡欺骗器)。"}),s.jsx("li",{children:"想在手机上收到结果,先在「设置 → 飞书」接好飞书。"})]})]}),f!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:f})]})]})}const z6={id:"pipelines",title:"编排",milestone:"M4",requires:["pipelines","scripts","runs"],pages:[{id:"pipelines",title:"编排",icon:"flow",order:20,agent:"pipelines",component:C6}]},P6={id:"schedule",title:"定时与自启",milestone:"M4",requires:["schedule","pipelines"],settingsPages:[{id:"schedule",title:"定时与自启",order:9,component:O6}]},op=new Map;function nS(e,t){let n=op.get(t);return n===void 0&&(n=e.connection.call("games/image",{url:t}).then(r=>`data:${r.mediaType};base64,${r.data}`),n.catch(()=>op.delete(t)),op.set(t,n)),n}function L6(e,t){const[n,r]=b.useState(void 0),i=t.filter(o=>o!==void 0).filter((o,c,u)=>u.indexOf(o)===c);return b.useEffect(()=>{r(void 0);let o=!0;return(async()=>{for(const c of i){const u=await nS(e,c).catch(()=>{});if(u!==void 0){o&&r(u);return}}})(),()=>{o=!1}},[e,i.join(`
|
|
221
|
-
`)]),n}function sS(e,t){const[n,r]=b.useState(void 0);return b.useEffect(()=>{if(r(void 0),t===void 0)return;let i=!0;return nS(e,t).then(o=>{i&&r(o)},()=>{}),()=>{i=!1}},[e,t]),n}const fr=864e5,lp=2,D6=28,Dl=["#3b82c4","#c0567d","#2f9e7a","#c98a1b","#7a62d6","#d2643c","#4d9a3c","#2a93a8","#a86bb8","#8a7a3a"],Nb="adg:games:overview:shown",jb="adg:games:overview:mode";function Sb(e,t){try{const n=localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}}function _b(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function gr(e){const t=e.todo.length+e.done.length;return e.finished!==void 0?{state:"finished",done:t,total:t}:t===0?{state:"unknown",done:0,total:0}:{state:e.todo.length===0?"finished":"partial",done:e.done.length,total:t}}function F6(e,t){return new Date(e).toLocaleDateString("zh-CN",{timeZone:t,month:"numeric",day:"numeric"})}function cp(e,t){const n=e-t;return n<=0?"已结束":n<fr?`${Math.max(1,Math.floor(n/36e5))} 小时`:`${Math.floor(n/fr)} 天`}function B6({client:e,games:t,activities:n,now:r,soonDays:i,onOpenGame:o,onChanged:c}){const[u,d]=b.useState(()=>Sb(Nb,null)),[f,p]=b.useState(()=>Sb(jb,"time")),[m,g]=b.useState(null);b.useEffect(()=>_b(Nb,u),[u]),b.useEffect(()=>_b(jb,f),[f]);const v=b.useMemo(()=>new Map(t.map((R,Z)=>[R.id,Dl[Z%Dl.length]])),[t]),y=R=>u===null||u.includes(R),S=R=>d(Z=>{const E=Z??t.map(I=>I.id),C=E.includes(R)?E.filter(I=>I!==R):[...E,R];return C.length===t.length?null:C}),k=new Date(r-lp*fr).setHours(0,0,0,0),w=k+(lp+D6)*fr,T=R=>Math.min(100,Math.max(0,(R-k)/(w-k)*100)),N=n.filter(R=>y(R.game)&&(R.endsAt===void 0||Math.max(R.endsAt,R.shopEndsAt??0)>r)),$=(R,Z)=>(R.endsAt??1/0)-(Z.endsAt??1/0)||R.name.localeCompare(Z.name),D=N.filter(R=>(R.startsAt??0)<=r),O=N.filter(R=>R.startsAt!==void 0&&R.startsAt>r).sort((R,Z)=>R.startsAt-Z.startsAt),F=[];if(f==="time"){const R=k+(lp+7)*fr,Z=D.filter(I=>I.endsAt!==void 0&&I.endsAt-r<i*fr).sort($),E=D.filter(I=>!Z.includes(I)&&I.endsAt!==void 0&&I.endsAt<R).sort($),C=D.filter(I=>!Z.includes(I)&&!E.includes(I)).sort($);F.push({key:"soon",title:"快结束",hint:`${i} 天内`,rows:Z},{key:"week",title:"本周内结束",rows:E},{key:"later",title:"之后结束",rows:C},{key:"upcoming",title:"即将开始",rows:O})}else for(const R of t){if(!y(R.id))continue;const Z=[...D.filter(E=>E.game===R.id).sort($),...O.filter(E=>E.game===R.id)];F.push({key:R.id,title:R.name,rows:Z,game:R})}const U=D.reduce((R,Z)=>{const E=gr(Z);return{...R,[E.state]:R[E.state]+1}},{finished:0,partial:0,unknown:0}),M=D.filter(R=>R.endsAt!==void 0&&R.endsAt-r<i*fr&&gr(R).state!=="finished").length,P=[];for(let R=k;R<=w;R+=fr){const Z=Math.round((R-new Date(r).setHours(0,0,0,0))/fr);P.push({at:R,...Z>0&&Z%7===0?{label:F6(R,Intl.DateTimeFormat().resolvedOptions().timeZone)}:{}})}return s.jsxs("div",{className:"games-overview",children:[s.jsxs("section",{className:"card games-overview-head",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"全部活动"}),s.jsxs("p",{className:"muted small",children:["进行中 ",D.length," 个 · ",s.jsxs("span",{className:M>0?"tone-warn":"",children:[M," 个快结束还没做完"]})," · 做完 ",U.finished," 个 · 做了一部分 ",U.partial," 个 · 没记录 ",U.unknown," 个"]})]}),s.jsxs("div",{className:"segmented-control ov-mode",role:"group","aria-label":"排序",children:[s.jsx("button",{className:f==="time"?"active":"","aria-pressed":f==="time",onClick:()=>p("time"),children:"按时间"}),s.jsx("button",{className:f==="game"?"active":"","aria-pressed":f==="game",onClick:()=>p("game"),children:"按游戏"})]})]}),s.jsx("div",{className:"chip-row games-overview-games",role:"group","aria-label":"显示哪些游戏",children:t.map(R=>s.jsxs("button",{className:`chip chip-button game-chip ${y(R.id)?"active":""}`,style:{"--game":v.get(R.id)},"aria-pressed":y(R.id),onClick:()=>S(R.id),children:[s.jsx("span",{className:"game-dot"}),R.name]},R.id))})]}),s.jsx("section",{className:"card games-overview-board",children:s.jsxs("div",{className:"ov-grid",children:[s.jsxs("div",{className:"ov-row ov-axis","aria-hidden":"true",children:[s.jsx("div",{className:"ov-label"}),s.jsx("div",{className:"ov-track",children:P.map(R=>s.jsx("span",{className:`ov-tick ${R.label!==void 0?"major":""}`,style:{left:`${T(R.at)}%`},children:R.label!==void 0&&s.jsx("em",{children:R.label})},R.at))}),s.jsx("div",{className:"ov-side"})]}),F.every(R=>R.rows.length===0)&&s.jsxs("div",{className:"empty",children:[s.jsx(ee,{name:"calendar"}),s.jsx("p",{children:t.length===0?"没有游戏。":"选中的游戏现在没有活动。点「刷新全部数据站」读取,或在上面多选几个游戏。"})]}),F.filter(R=>R.rows.length>0).map(R=>{var Z;return s.jsxs("div",{className:"ov-section",children:[s.jsxs("div",{className:"ov-section-title",children:[R.game!==void 0&&s.jsx("span",{className:"game-dot",style:{"--game":v.get(R.game.id)}}),s.jsx("span",{children:R.title}),R.hint!==void 0&&s.jsx("span",{className:"muted small",children:R.hint}),((Z=R.game)==null?void 0:Z.version)!==void 0&&s.jsxs("span",{className:"muted small",children:["版本 ",R.game.version.name,R.game.version.title===void 0?"":`「${R.game.version.title}」`]}),s.jsxs("span",{className:"muted small",children:[R.rows.length," 个"]}),R.game!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>o(R.game.id),children:"打开"})]}),R.rows.map(E=>{const C=t.find(I=>I.id===E.game);return s.jsx(U6,{client:e,activity:E,game:C,color:v.get(E.game)??Dl[0],showGame:f==="time",now:r,soonDays:i,x:T,open:m===E.id,onToggle:()=>g(I=>I===E.id?null:E.id),onOpenGame:()=>o(E.game),onChanged:c},E.id)})]},R.key)}),s.jsx("div",{className:"ov-today",style:{left:`calc(var(--ov-label) + (100% - var(--ov-label) - var(--ov-side)) * ${T(r)/100})`},"aria-hidden":"true",children:s.jsx("span",{children:"今天"})})]})})]})}function U6({client:e,activity:t,game:n,color:r,showGame:i,now:o,soonDays:c,x:u,open:d,onToggle:f,onOpenGame:p,onChanged:m}){const g=gr(t),v=(t.startsAt??0)<=o,y=t.endsAt,S=v&&y!==void 0&&y-o<c*fr&&g.state!=="finished",k=u(t.startsAt??o-30*fr),w=y===void 0?100:u(y),T=t.shopEndsAt===void 0||y===void 0||t.shopEndsAt<=y?void 0:u(t.shopEndsAt);return s.jsxs("div",{className:`ov-item ${d?"open":""}`,style:{"--game":r},children:[s.jsxs("button",{className:`ov-row ${S?"soon":""} ${g.state==="finished"?"finished":""}`,onClick:f,"aria-expanded":d,children:[s.jsxs("div",{className:"ov-label",children:[s.jsx("span",{className:"ov-name",children:t.name}),s.jsxs("span",{className:"ov-meta",children:[i&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"game-dot"}),(n==null?void 0:n.name)??t.game]}),t.kind!==void 0&&s.jsx("span",{className:"ov-kind",children:t.kind})]})]}),s.jsxs("div",{className:"ov-track",children:[s.jsx("span",{className:`ov-bar ${v?"":"future"} ${k<=0?"cut-left":""} ${y===void 0||w>=100?"cut-right":""}`,style:{left:`${k}%`,width:`${Math.max(1.2,w-k)}%`},children:g.total>0&&s.jsx("span",{className:"ov-bar-done",style:{width:`${g.done/g.total*100}%`}})}),T!==void 0&&s.jsx("span",{className:"ov-shop",style:{left:`${w}%`,width:`${Math.max(.6,T-w)}%`},title:"之后只开商店"})]}),s.jsxs("div",{className:"ov-side",children:[s.jsx("span",{className:`ov-left ${S?"tone-warn":""}`,children:v?y===void 0?"时间未知":y<=o&&t.shopEndsAt!==void 0?`商店 ${cp(t.shopEndsAt,o)}`:cp(y,o):`${cp(t.startsAt,o)}后开始`}),s.jsx(rS,{progress:g})]})]}),d&&s.jsx(iS,{client:e,activity:t,game:n,onOpenGame:p,onChanged:m})]})}function rS({progress:e}){return e.state==="finished"?s.jsxs("span",{className:"ov-progress done",children:[s.jsx(ee,{name:"check"}),"做完了"]}):e.state==="unknown"?s.jsx("span",{className:"ov-progress unknown",children:"未记录"}):s.jsxs("span",{className:"ov-progress partial",title:`做了 ${e.done} 项,还剩 ${e.total-e.done} 项`,children:[s.jsx("span",{className:"ov-ring",style:{"--pct":`${e.done/e.total*100}%`}}),e.done,"/",e.total]})}function H6({activity:e}){var i;const t=Cn(6e4),n=e.sources??(e.site===void 0?[]:[{id:e.site.source,name:e.site.name,at:e.site.at,web:!1}]);if(n.length===0&&e.screen===void 0)return null;const r=(i=e.site)==null?void 0:i.name;return s.jsxs("div",{className:"activity-sources",children:[s.jsx("span",{className:"muted small",children:"来源"}),n.map(o=>s.jsxs("span",{className:`fact-chip ${o.web?"web":"site"}`,title:o.web?"网页上读到的;刷新数据站不会删掉它":"数据站,每次刷新更新",children:[o.name,s.jsxs("small",{children:[o.web?"网页":"数据站"," · ",$t(o.at,t)]}),n.length>1&&o.name===r&&s.jsx("small",{className:"fact-main",children:"时间以它为准"})]},o.id)),e.screen!==void 0&&s.jsxs("span",{className:"fact-chip screen",title:"agent 进游戏看到的剩余时间和进度",children:["游戏画面",s.jsxs("small",{children:["agent 看过 · ",$t(e.screen.at,t)]})]})]})}function iS({client:e,activity:t,game:n,onOpenGame:r,onChanged:i,openSession:o}){var $,D;const[c,u]=b.useState(null),[d,f]=b.useState(""),[p,m]=b.useState(!1),[g,v]=b.useState(null),y=(n==null?void 0:n.timezone)??"Asia/Shanghai",S=O=>new Date(O).toLocaleString("zh-CN",{timeZone:y,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),k=async O=>{m(!0),v(null);try{await e.connection.call("games/activity/progress",{activityId:t.id,...O}),i()}catch(F){v(Pe(F))}finally{m(!1)}},w=O=>void k({todo:t.todo.filter(F=>F!==O),done:[...t.done,O]}),T=O=>void k({todo:[...t.todo,O],done:t.done.filter(F=>F!==O)}),N=()=>{const O=d.trim();O===""||t.todo.includes(O)||t.done.includes(O)||(f(""),k({todo:[...t.todo,O]}))};return s.jsxs("div",{className:"ov-detail",children:[t.description!==void 0&&s.jsx("p",{className:"ov-description",children:t.description}),s.jsxs("div",{className:"activity-dates muted small",children:[t.startsAt!==void 0&&s.jsxs("span",{children:[S(t.startsAt)," 开始"]}),t.endsAt!==void 0&&s.jsxs("span",{children:[S(t.endsAt)," 结束"]}),t.shopEndsAt!==void 0&&s.jsxs("span",{children:["商店开到 ",S(t.shopEndsAt)]})]}),s.jsx(H6,{activity:t}),s.jsxs("div",{className:"ov-checklist",role:"list","aria-label":"要做的事",children:[t.todo.map(O=>s.jsxs("label",{className:"ov-check",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!1,disabled:p,onChange:()=>w(O)}),O]},`t${O}`)),t.done.map(O=>s.jsxs("label",{className:"ov-check done",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!0,disabled:p,onChange:()=>T(O)}),O]},`d${O}`)),t.todo.length+t.done.length===0&&s.jsx("p",{className:"muted small",children:"还没有要做的事。自己加几项(例如「活动商店换完」「剧情通关」),或者在游戏页让 agent 进游戏读一次。"})]}),s.jsxs("div",{className:"ov-add",children:[s.jsx("input",{className:"text-input plain",value:d,maxLength:80,placeholder:"加一项要做的事,回车添加",disabled:p,onChange:O=>f(O.target.value),onKeyDown:O=>{O.key==="Enter"&&N()}}),s.jsxs("button",{className:"small-button",disabled:p||d.trim()==="",onClick:N,children:[s.jsx(ee,{name:"plus"}),"添加"]})]}),s.jsxs("div",{className:"ov-detail-actions",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.finished!==void 0,disabled:p,onChange:O=>void k({finished:O.target.checked})}),"这个活动我做完了"]}),s.jsx("span",{className:"spacer"}),(($=t.screen)==null?void 0:$.evidence)===!0&&s.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:t.id}).then(O=>{const F=`data:${O.mediaType};base64,${O.data}`,U=new Image;U.onload=()=>u({src:F,width:U.naturalWidth,height:U.naturalHeight}),U.src=F},O=>v(Pe(O))),children:"看游戏截图"}),((D=t.screen)==null?void 0:D.sessionId)!==void 0&&o!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>o(t.screen.sessionId),children:"agent 的对话"}),t.url!==void 0&&s.jsx("a",{className:"link-button small",href:t.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),r!==void 0&&s.jsxs("button",{className:"link-button small",onClick:r,children:["去",(n==null?void 0:n.name)??"游戏"]}),s.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:p,onClick:()=>void e.connection.call("games/activity/remove",{activityId:t.id}).then(i,O=>v(Pe(O))),children:"从日历去掉"})]}),g!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:g})]}),c!==null&&s.jsx(Jw,{src:c.src,width:c.width,height:c.height,name:`${t.name}.png`,onClose:()=>u(null)})]})}function Z6({client:e,onChanged:t,onDiscover:n}){const[r,i]=b.useState(null),[o,c]=b.useState(""),[u,d]=b.useState(null),[f,p]=b.useState(null),[m,g]=b.useState(0);b.useEffect(()=>{let y=!0;return e.connection.call("games/catalog",{}).then(S=>{y&&i(S.games)}).catch(S=>{y&&p(Pe(S))}),()=>{y=!1}},[e,m]);const v=async(y,S)=>{d(y),p(null);try{await e.connection.call("games/follow",{sra:y,follow:S}),g(k=>k+1),t()}catch(k){p(Pe(k))}finally{d(null)}};return s.jsxs("div",{className:"catalog-picker",children:[s.jsxs("p",{className:"muted small",children:["这些游戏的活动来自 ",s.jsx("a",{href:"https://starrailassistant.top/reference/public-api/",target:"_blank",rel:"noreferrer",children:"SRA 公共 API"}),"(社区按官方公告整理,免费,不用模型)。勾上的游戏每天自动读一次。"]}),r===null&&f===null&&s.jsx("p",{className:"muted small",children:"正在读取…"}),s.jsx("div",{className:"catalog-grid",children:r==null?void 0:r.map(y=>s.jsxs("label",{className:`check-label ${y.pack!==void 0?"muted":""}`,title:y.pack!==void 0?"已经有游戏包在读它":void 0,children:[s.jsx("input",{type:"checkbox",checked:y.pack!==void 0||y.followed,disabled:y.pack!==void 0||u!==null,onChange:S=>void v(y.sra,S.target.checked)}),y.name,y.pack!==void 0?"(已有)":u===y.sra?"…":""]},y.sra))}),n!==void 0&&s.jsxs("form",{className:"discover-row",onSubmit:y=>{y.preventDefault();const S=o.trim();S!==""&&(n(S),c(""))},children:[s.jsx("span",{className:"field-title",children:"列表里没有?"}),s.jsx("input",{className:"text-input plain",value:o,maxLength:60,placeholder:"输入游戏名,例如:重返未来:1999",onChange:y=>c(y.target.value)}),s.jsxs("button",{className:"small-button primary",type:"submit",disabled:o.trim()==="",children:[s.jsx(ee,{name:"search"}),"让 agent 去找"]}),s.jsx("span",{className:"muted small",children:"agent 会找它的 Wiki、官网公告等来源,建一个游戏包加到游戏页。"})]}),f!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:f})]})]})}const qi=864e5,ba=36e5,um=6e4;function $d(e,t){const n=e-t;return n<=0?"已结束":n>=qi?`${Math.floor(n/qi)} 天 ${Math.floor(n%qi/ba)} 时`:`${Math.floor(n/ba)} 时 ${Math.floor(n%ba/um)} 分`}function V6(e){return e<=0?{value:"0",unit:"时",rest:""}:e>=qi?{value:String(Math.floor(e/qi)),unit:"天",rest:`${Math.floor(e%qi/ba)} 时`}:e>=ba?{value:String(Math.floor(e/ba)),unit:"时",rest:`${Math.floor(e%ba/um)} 分`}:{value:String(Math.max(1,Math.floor(e/um))),unit:"分",rest:""}}function dm(e,t){const n=Object.fromEntries(new Intl.DateTimeFormat("en-CA",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).formatToParts(new Date(e)).map(r=>[r.type,r.value]));return`${n.year}/${n.month}/${n.day} ${n.hour}:${n.minute}`}function aS(e,t){var r;return(((r=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(new Date(t)).find(i=>i.type==="timeZoneName"))==null?void 0:r.value)??"").replace("GMT","UTC")||e}function W6({client:e,game:t,activities:n,color:r,now:i,soonDays:o,busy:c,onRefresh:u,onRead:d,onReadWeb:f,onUnfollow:p,onChanged:m,openSession:g,openScripts:v}){var E,C;const[y,S]=b.useState(null),[k,w]=b.useState(!1),T=n.filter(I=>Math.max(I.endsAt??1/0,I.shopEndsAt??0)>i),N=(I,L)=>(I.endsAt??1/0)-(L.endsAt??1/0),$=T.filter(I=>(I.startsAt??0)<=i).sort(N),D=T.filter(I=>I.startsAt!==void 0&&I.startsAt>i).sort((I,L)=>I.startsAt-L.startsAt),O=$.filter(I=>gr(I).state!=="finished"&&(I.endsAt??1/0)-i<o*qi),F=t.sources.some(I=>I.auto),U={partial:0,unknown:1,finished:2},M=$.filter(I=>!O.includes(I)&&gr(I).state!=="finished").sort((I,L)=>U[gr(I).state]-U[gr(L).state]||N(I,L)),P=$.filter(I=>gr(I).state==="finished"),R=[{key:"soon",title:"需要关注",hint:`${o} 天内结束,还没做完`,rows:O,tone:"warn"},{key:"ongoing",title:"进行中",hint:"做了一部分的在前",rows:M},{key:"upcoming",title:"即将开始",hint:"按开始时间",rows:D}],Z=I=>s.jsxs("div",{className:`schedule-item ${y===I.id?"open":""}`,children:[s.jsx(Q6,{client:e,activity:I,game:t,now:i,soonDays:o,onClick:()=>S(L=>L===I.id?null:I.id),expanded:y===I.id}),y===I.id&&s.jsx(iS,{client:e,activity:I,game:t,onChanged:m,openSession:g})]},I.id);return s.jsxs("div",{className:"game-view",style:{"--game":r},children:[s.jsxs("div",{className:"game-main",children:[s.jsx(q6,{client:e,game:t,now:i,covers:$.map(I=>I.cover)}),s.jsx(K6,{client:e,game:t,running:$,soon:O,now:i,busy:c,onRead:d,onReadWeb:f,onUnfollow:p,openSession:g,openScripts:v}),(((E=t.pools)==null?void 0:E.length)??0)>0&&s.jsxs("section",{className:"card pools-card",children:[s.jsx("h3",{children:"卡池"}),s.jsx("div",{className:"pool-list",children:t.pools.map(I=>s.jsx(J6,{client:e,pool:I,game:t,now:i},`${I.name}-${I.endsAt}`))})]}),s.jsxs("div",{className:"game-sources",children:[t.sources.map(I=>{var L;return s.jsxs("span",{className:`source-chip ${I.auto?"auto":"agent"}`,children:[I.auto?s.jsxs("span",{className:"source-name",title:"每天自动读取(不用模型)",children:[s.jsx("span",{className:"source-dot auto"}),I.name]}):s.jsxs("button",{className:"source-name",disabled:c!==null||((L=t.webReading)==null?void 0:L.state)==="running",title:"让 agent 读这个来源,把活动记进日历",onClick:()=>f(I.id),children:[s.jsx("span",{className:"source-dot"}),I.name,s.jsx("span",{className:"source-action",children:"agent 读"})]}),I.homepage!==void 0&&s.jsx("a",{className:"source-open",href:I.homepage,target:"_blank",rel:"noreferrer",title:"在浏览器里打开","aria-label":`打开${I.name}`,children:s.jsx(ee,{name:"popout"})}),I.added===!0&&s.jsx("button",{className:"source-open",title:"不再读这个网址","aria-label":`删除${I.name}`,onClick:()=>void e.connection.call("games/source/remove",{game:t.id,source:I.id}).then(m,()=>{}),children:s.jsx(ee,{name:"close"})})]},I.id)}),s.jsx(G6,{client:e,game:t,onAdded:m}),t.refreshed!==void 0&&s.jsxs("span",{className:"muted small",children:[$t(t.refreshed.at,i),"刷新"]}),t.refreshed!==void 0&&!t.refreshed.ok&&s.jsxs("span",{className:"tone-error small",children:["上次没读到:",t.refreshed.detail]})]})]}),s.jsxs("aside",{className:"card game-schedule","aria-label":"活动日程",children:[s.jsxs("div",{className:"schedule-head",children:[s.jsx("h3",{children:"活动日程"}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"muted small",children:((C=t.sources.find(I=>I.auto))==null?void 0:C.name)??"数据站"}),s.jsx("button",{className:"icon-button",title:F?"刷新数据站(不用模型)":"这个游戏没有能自动读的数据站",disabled:c!==null||!F,onClick:u,children:s.jsx(ee,{name:"refresh"})})]}),s.jsxs("div",{className:"schedule-list",children:[T.length===0&&s.jsx("p",{className:"muted small schedule-empty",children:F?"还没有活动。点右上角刷新。":"这个游戏没有能自动读的数据站,让 agent 进游戏读一次。"}),R.filter(I=>I.rows.length>0).map(I=>s.jsxs("section",{className:`schedule-group ${I.tone??""}`,children:[s.jsxs("div",{className:"schedule-group-title",children:[s.jsx("span",{children:I.title}),s.jsx("span",{className:"count",children:I.rows.length}),s.jsx("span",{className:"muted small",children:I.hint})]}),I.rows.map(Z)]},I.key)),P.length>0&&s.jsxs("section",{className:"schedule-group done",children:[s.jsxs("button",{className:"schedule-group-title toggle","aria-expanded":k,onClick:()=>w(I=>!I),children:[s.jsx("span",{children:"已做完"}),s.jsx("span",{className:"count",children:P.length}),s.jsx("span",{className:"muted small",children:k?"收起":"展开"}),s.jsx(ee,{name:"chevron-down",className:`chevron-icon ${k?"open":""}`})]}),k&&P.map(Z)]})]})]})]})}function q6({client:e,game:t,now:n,covers:r}){const i=t.version,o=L6(e,[i==null?void 0:i.cover,t.art,...r]),c=(i==null?void 0:i.startsAt)!==void 0&&i.endsAt!==void 0?i.endsAt-i.startsAt:void 0,u=c===void 0||c<=0?void 0:Math.min(1,Math.max(0,(n-i.startsAt)/c)),d=f=>new Date(f).toLocaleDateString("zh-CN",{timeZone:t.timezone,month:"numeric",day:"numeric"});return s.jsxs("section",{className:"version-card",children:[s.jsxs("div",{className:`version-hero ${o===void 0?"no-art":""}`,children:[o!==void 0&&s.jsx("img",{className:"version-art",src:o,alt:""}),s.jsx("div",{className:"version-shade"}),s.jsxs("div",{className:"version-caption",children:[s.jsxs("span",{className:"version-kicker",children:[t.name,i===void 0?"":s.jsxs(s.Fragment,{children:[" · ",s.jsx("b",{children:i.name})," 版本"]})]}),s.jsx("h2",{children:(i==null?void 0:i.title)??t.name})]})]}),s.jsxs("div",{className:"version-strip",children:[i===void 0&&s.jsx("span",{className:"muted small",children:t.sources.some(f=>f.auto)?"还没有版本信息:点「活动日程」右上角刷新":"这个游戏的数据站不提供版本信息"}),i!==void 0&&u!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"version-end",children:d(i.startsAt)}),s.jsxs("div",{className:"version-track",role:"meter","aria-label":"版本进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u*100),children:[s.jsx("span",{className:"version-fill",style:{width:`${u*100}%`}}),s.jsx("span",{className:"version-now",style:{left:`${u*100}%`}})]}),s.jsx("span",{className:"version-end",children:d(i.endsAt)})]}),(i==null?void 0:i.endsAt)!==void 0&&s.jsx("span",{className:"version-remaining",children:i.endsAt>n?s.jsxs(s.Fragment,{children:["还剩 ",s.jsx("strong",{children:$d(i.endsAt,n)})]}):"本版本已结束"})]})]})}function G6({client:e,game:t,onAdded:n}){const[r,i]=b.useState(!1),[o,c]=b.useState(""),[u,d]=b.useState(!1),[f,p]=b.useState(null);if(!r)return s.jsxs("button",{className:"source-add",onClick:()=>i(!0),title:"添加一个关于这个游戏的网页,agent 会去读它",children:[s.jsx(ee,{name:"plus"}),"添加网址"]});const m=async()=>{const g=o.trim();if(g!==""){d(!0),p(null);try{await e.connection.call("games/source/add",{game:t.id,url:/^https?:\/\//.test(g)?g:`https://${g}`}),c(""),i(!1),n()}catch(v){p(Pe(v))}finally{d(!1)}}};return s.jsxs("form",{className:"source-form",onSubmit:g=>{g.preventDefault(),m()},children:[s.jsx("input",{className:"text-input plain",autoFocus:!0,type:"text",inputMode:"url",placeholder:"https://… 官网公告、Wiki 页面、帖子",value:o,disabled:u,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Escape"&&i(!1)}}),s.jsx("button",{className:"small-button primary",type:"submit",disabled:u||o.trim()==="",children:u?"添加中…":"添加并读取"}),s.jsx("button",{className:"small-button",type:"button",onClick:()=>{i(!1),p(null)},children:"取消"}),f!==null&&s.jsx("span",{className:"tone-error small",children:f})]})}function K6({client:e,game:t,running:n,soon:r,now:i,busy:o,onRead:c,onReadWeb:u,onUnfollow:d,openSession:f,openScripts:p}){var k,w;const m=n.map(gr),g=m.filter(T=>T.state==="finished").length,v=m.filter(T=>T.state==="partial").length,y=m.filter(T=>T.state==="unknown").length,S=t.reading;return s.jsxs("section",{className:"card status-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"我的状态"}),s.jsx("p",{className:"muted small",children:"进度来自你在活动卡片里勾的,和 agent 进游戏读到的。"})]}),s.jsxs("div",{className:"game-actions",children:[s.jsxs("button",{className:"small-button",disabled:o!==null||((k=t.webReading)==null?void 0:k.state)==="running",title:"agent 读官网公告、Wiki 等插件不能自己读的来源,把活动记进日历",onClick:()=>u(),children:[s.jsx(ee,{name:"search"}),((w=t.webReading)==null?void 0:w.state)==="running"?"agent 正在查…":"让 agent 上网查活动"]}),t.followed===!0?s.jsx("button",{className:"small-button",disabled:o!==null,title:"不再显示这个游戏",onClick:d,children:"取消关注"}):s.jsxs("button",{className:"small-button primary",disabled:o!==null||(S==null?void 0:S.state)==="running",title:"agent 会看游戏画面,进活动页读取剩余时间和没做完的事;只看不花东西",onClick:c,children:[s.jsx(ee,{name:"gamepad"}),(S==null?void 0:S.state)==="running"?"agent 正在读…":"让 agent 进游戏读取"]})]})]}),s.jsxs("div",{className:"status-stats",children:[s.jsxs("div",{className:"stat",children:[s.jsx("strong",{children:n.length}),s.jsx("span",{children:"进行中"})]}),s.jsxs("div",{className:`stat ${r.length>0?"warn":""}`,children:[s.jsx("strong",{children:r.length}),s.jsx("span",{children:"快结束未做完"})]}),s.jsxs("div",{className:"stat ok",children:[s.jsx("strong",{children:g}),s.jsx("span",{children:"已做完"})]}),s.jsxs("div",{className:"stat",children:[s.jsx("strong",{children:v}),s.jsx("span",{children:"做了一部分"})]}),s.jsxs("div",{className:"stat muted",children:[s.jsx("strong",{children:y}),s.jsx("span",{children:"没记录"})]})]}),r.length>0&&s.jsx("ul",{className:"soon-list",children:r.slice(0,4).map(T=>s.jsxs("li",{children:[s.jsx("span",{className:"tone-warn",children:$d(T.endsAt,i)}),s.jsx("span",{children:T.name}),T.todo.length>0&&s.jsxs("span",{className:"muted small",children:["还没做:",T.todo.slice(0,3).join("、")]})]},T.id))}),S!==void 0&&s.jsx(Eb,{what:"进游戏",reading:S,now:i,openSession:f}),t.webReading!==void 0&&s.jsx(Eb,{what:"上网查",reading:t.webReading,now:i,openSession:f}),s.jsx(X6,{client:e,game:t,now:i,openScripts:p})]})}function Eb({what:e,reading:t,now:n,openSession:r}){var o;const i=(o=t.summary)==null?void 0:o.replace(/[*_`#>]+/g,"").replace(/\s+/g," ").trim();return s.jsxs("div",{className:`reading ${t.state}`,children:[s.jsxs("div",{className:"reading-head",children:[s.jsx("span",{className:`badge ${t.state==="done"?"ok":t.state==="failed"?"warn":""}`,children:t.state==="running"?`正在${e}`:t.state==="done"?`上次${e}`:`${e}没完成`}),s.jsx("span",{className:"muted small",children:$t(t.at,n)}),s.jsx("span",{className:"spacer"}),t.sessionId!==void 0&&s.jsxs("button",{className:"link-button small reading-open",onClick:()=>r(t.sessionId),children:["查看对话",s.jsx(ee,{name:"chevron"})]})]}),i!==void 0&&i!==""&&s.jsx("p",{className:"reading-summary",title:i,children:i})]})}function Y6({client:e,game:t}){const n=Ee(e.capabilities),[r,i]=b.useState(null);return b.useEffect(()=>{if(!n.has("scripts"))return;let o=!0;return e.connection.call("games/mirrorchyan",{game:t.id}).then(c=>{o&&i(c.items)},()=>{o&&i([])}),()=>{o=!1}},[e,t.id,n.has("scripts")]),r===null||r.length===0?null:s.jsxs("div",{className:"mirror-tools",children:[s.jsx("div",{className:"muted small",children:"Mirror酱 上有这些玩它的工具:"}),s.jsx("ul",{children:r.slice(0,5).map(o=>s.jsxs("li",{children:[s.jsx("a",{href:`#/p/scripts/${encodeURIComponent(`mirror:${o.rid}`)}`,children:o.name}),s.jsx("span",{className:"chip subtle",children:o.rid}),o.description!==""&&s.jsx("span",{className:"muted small",children:o.description})]},o.rid))})]})}function X6({client:e,game:t,now:n,openScripts:r}){const i=Ee(e.capabilities),o=Ee(e.connection.status),[c,u]=b.useState(null),[d,f]=b.useState([]),[p,m]=b.useState(0),[g,v]=b.useState(null),[y,S]=b.useState(null),k=i.has("pipelines");b.useEffect(()=>e.connection.on("pipelines/changed",()=>m(N=>N+1)),[e]),b.useEffect(()=>e.connection.on("pipelines/run",N=>{N.state!=="running"&&m($=>$+1)}),[e]),b.useEffect(()=>{if(o.state!=="open"||!k||t.scripts.length===0){u([]);return}let N=!0;return(async()=>{const{items:$}=await e.connection.call("pipelines/list",{}),O=(await Promise.all($.filter(U=>!U.draft).map(async U=>({summary:U,pipeline:await e.connection.call("pipelines/get",{id:U.id})})))).filter(({pipeline:U})=>U.nodes.some(M=>M.kind==="script-task"&&t.scripts.includes(M.scriptId))),F=i.has("schedule")?await e.connection.call("schedule/status",{}).catch(()=>{}):void 0;N&&(u(O),f((F==null?void 0:F.upcoming)??[]))})().catch($=>{N&&S(Pe($))}),()=>{N=!1}},[e,o.state,k,t.id,t.scripts.join(","),p]);const w=async N=>{v(N),S(null);try{await e.connection.call("pipelines/run",{id:N}),m($=>$+1)}catch($){S(Pe($))}finally{v(null)}},T={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]};return s.jsxs("div",{className:"game-schedule-runs",children:[s.jsx("div",{className:"field-title",children:"日程"}),t.scripts.length===0&&s.jsxs("p",{className:"muted small",children:["还没有玩它的脚本。在",s.jsx("button",{className:"link-button",onClick:r,children:"脚本页"}),"安装或导入后,名字或仓库里提到这个游戏的脚本会自动对上。"]}),t.scripts.length===0&&s.jsx(Y6,{client:e,game:t}),t.scripts.length>0&&s.jsxs("p",{className:"muted small",children:["玩它的脚本:",t.scripts.map((N,$)=>s.jsxs("span",{children:[$>0?"、":"",s.jsx("button",{className:"link-button",onClick:r,children:N})]},N))]}),c!==null&&t.scripts.length>0&&c.length===0&&s.jsxs("p",{className:"muted small",children:["还没有自动跑这个游戏的流水线。在 ",s.jsx("a",{href:"#/p/pipelines",children:"编排"})," 里建一条并设上定时,日常就会每天自己跑。"]}),c!==null&&c.length>0&&s.jsx("ul",{className:"run-list",children:c.map(({summary:N})=>{var O,F;const $=d.filter(U=>U.pipelineId===N.id).map(U=>U.at).sort((U,M)=>U-M)[0],D=N.lastRun;return s.jsxs("li",{children:[s.jsx("a",{className:"run-name",href:`#/p/pipelines/${encodeURIComponent(N.id)}`,children:N.name}),s.jsx("span",{className:"muted small",children:$!==void 0?`下次 ${new Date($).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"})}`:N.schedule.enabled?"定时已开":"没有定时"}),D!==void 0&&s.jsxs("span",{className:`badge ${((O=T[D.state])==null?void 0:O[0])??""}`,title:new Date(D.startedAt).toLocaleString("zh-CN",{hour12:!1}),children:[((F=T[D.state])==null?void 0:F[1])??D.state," · ",$t(D.endedAt??D.startedAt,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:g!==null||(D==null?void 0:D.state)==="running",onClick:()=>void w(N.id),children:(D==null?void 0:D.state)==="running"?"运行中…":g===N.id?"启动中…":"运行"})]},N.id)})}),y!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:y})]})]})}function Q6({client:e,activity:t,game:n,now:r,soonDays:i,onClick:o,expanded:c}){var N,$;const u=sS(e,t.cover),d=gr(t),f=(t.startsAt??0)<=r,p=f&&t.endsAt!==void 0&&t.endsAt<=r,m=p?t.shopEndsAt:t.endsAt,g=f&&m!==void 0&&m-r<i*qi&&d.state!=="finished",v=t.startsAt!==void 0&&m!==void 0?m-t.startsAt:void 0,y=v===void 0||v<=0||!f?void 0:Math.min(1,Math.max(0,(r-t.startsAt)/v)),S=d.state==="finished"?["done","已做完"]:f?p?["shop","商店开放"]:["live","进行中"]:["upcoming","即将开始"],k=aS(n.timezone,r),w=f?m:t.startsAt,T=w===void 0?{value:"",unit:"",rest:""}:V6(w-r);return s.jsxs("button",{className:`sched-card ${u===void 0?"no-art":""} ${g?"soon":""}`,onClick:o,"aria-expanded":c,children:[u!==void 0&&s.jsx("img",{className:"sched-art",src:u,alt:""}),s.jsx("span",{className:"sched-shade"}),s.jsxs("span",{className:"sched-count","aria-label":w===void 0?"时间未知":`${f?"剩余":"距开始"}${$d(w,r)}`,children:[w===void 0?s.jsx("b",{children:"?"}):s.jsxs(s.Fragment,{children:[s.jsx("b",{children:T.value}),s.jsx("small",{children:T.unit}),T.rest!==""&&s.jsx("em",{children:T.rest})]}),s.jsx("i",{children:f?p?"商店":"剩余":"后开始"})]}),s.jsxs("span",{className:"sched-body",children:[s.jsxs("span",{className:"sched-top",children:[s.jsx("span",{className:`sched-tag ${S[0]}`,children:S[1]}),t.kind!==void 0&&s.jsx("span",{className:"sched-kind",children:t.kind}),((N=t.sources)==null?void 0:N.some(D=>D.web))===!0&&s.jsx("span",{className:"sched-kind",title:`来源:${t.sources.map(D=>D.name).join("、")}`,children:t.sources.every(D=>D.web)?"网页读到":"数据站 + 网页"}),s.jsx("span",{className:"spacer"}),s.jsx(rS,{progress:d})]}),s.jsx("span",{className:"sched-name",children:t.name}),s.jsx("span",{className:"sched-when",children:!f&&t.startsAt!==void 0?`${dm(t.startsAt,n.timezone)} 开始 · ${k}`:m!==void 0?`${dm(m,n.timezone)} ${p?"商店关闭":"结束"} · ${k}`:`结束时间未知${(($=t.screen)==null?void 0:$.remaining)===void 0?"":`,游戏里显示「${t.screen.remaining}」`}`})]}),y!==void 0&&s.jsx("span",{className:"sched-elapsed",style:{width:`${y*100}%`}})]})}function J6({client:e,pool:t,game:n,now:r}){const i=sS(e,t.cover),o=(t.startsAt??0)<=r;return s.jsxs("article",{className:"pool-card",children:[s.jsx("div",{className:"pool-art",children:i===void 0?s.jsx(ee,{name:"sparkles"}):s.jsx("img",{src:i,alt:""})}),s.jsxs("div",{className:"pool-main",children:[t.type!==void 0&&s.jsx("span",{className:"muted small",children:t.type}),s.jsx("strong",{children:t.name}),t.up.length>0&&s.jsxs("span",{className:"small",children:["UP:",t.up.join("、")]}),s.jsxs("span",{className:"small",children:[o?"剩余":"距开始"," ",s.jsx("strong",{className:"pool-left",children:$d(o?t.endsAt:t.startsAt,r)})]}),s.jsxs("span",{className:"muted small",children:[dm(t.endsAt,n.timezone)," 结束 (",aS(n.timezone,r),")"]})]})]})}function eB(e,t){return b.useMemo(()=>new Map(e.map((n,r)=>[n.id,t[r%t.length]])),[e,t])}const tB=864e5;function nB({client:e,openSession:t,openSettings:n,openPage:r,arg:i}){const o=Ee(e.connection.status),c=Cn(3e4),[u,d]=b.useState(null),[f,p]=b.useState(0),[m,g]=b.useState(i??""),[v,y]=b.useState(null),[S,k]=b.useState(null),[w,T]=b.useState(null),[N,$]=b.useState(!1);b.useEffect(()=>{i!==void 0&&g(i)},[i]),b.useEffect(()=>e.connection.on("games/changed",()=>p(C=>C+1)),[e]),b.useEffect(()=>{if(o.state!=="open")return;let C=!0;return e.connection.call("games/list",{}).then(I=>{C&&d(I)}).catch(I=>{C&&k(Pe(I))}),()=>{C=!1}},[e,o.state,f]);const D=(u==null?void 0:u.games)??[],O=eB(D,Dl),F=m==="report",U=F?void 0:D.find(C=>C.id===m),M=!F&&U===void 0,P=C=>{g(C),T(null),k(null)},R=async(C,I)=>{y(C),k(null),T(null);try{const L=await I();typeof L=="string"&&T(L)}catch(L){k(Pe(L))}finally{y(null),p(L=>L+1)}},Z=C=>R(`refresh:${C??""}`,async()=>{const{results:I}=await e.connection.call("games/refresh",C===void 0?{}:{game:C}),L=G=>{var K;return((K=D.find(V=>V.id===G))==null?void 0:K.name)??G},W=G=>{var K;return((K=D.find(V=>V.id===G))==null?void 0:K.sources.some(V=>V.auto))===!0},H=I.filter(G=>W(G.game)&&!G.ok);if(H.length>0)throw new Error(H.map(G=>`${L(G.game)}没读到:${G.detail??"未知原因"}`).join(";"));return C===void 0?`刷新完成:${I.filter(G=>W(G.game)).map(G=>`${L(G.game)} ${G.count} 个活动`).join(";")}`:void 0}),E=C=>{const I=((u==null?void 0:u.activities)??[]).filter(W=>W.game===C.id&&(W.startsAt??0)<=c&&Math.max(W.endsAt??1/0,W.shopEndsAt??0)>c),L=I.filter(W=>gr(W).state!=="finished"&&W.endsAt!==void 0&&W.endsAt>c&&W.endsAt-c<((u==null?void 0:u.settings.report.soonDays)??3)*tB).length;return s.jsxs("button",{role:"tab","aria-selected":(U==null?void 0:U.id)===C.id,className:`game-tab ${(U==null?void 0:U.id)===C.id?"active":""}`,style:{"--game":O.get(C.id)},title:`${I.length} 个进行中${C.refreshed===void 0?"":` · ${$t(C.refreshed.at,c)}刷新`}${C.followed===!0?" · 关注的游戏":""}`,onClick:()=>P(C.id),children:[s.jsx("span",{className:"game-dot"}),C.name,L>0&&s.jsx("span",{className:"game-tab-badge",title:`${L} 个快结束还没做完`,children:L})]},C.id)};return s.jsxs("section",{className:"main games-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"游戏"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:F?"每日日报":(U==null?void 0:U.name)??"全部活动"})]}),s.jsx("div",{className:"page-actions",children:s.jsxs("button",{className:"small-button",disabled:v!==null||D.length===0,onClick:()=>void Z(),children:[s.jsx(ee,{name:"refresh"}),v==="refresh:"?"刷新中…":"刷新全部"]})})]}),s.jsxs("nav",{className:"game-tabs",role:"tablist","aria-label":"游戏",children:[s.jsxs("button",{role:"tab","aria-selected":M,className:`game-tab ${M?"active":""}`,onClick:()=>P(""),children:[s.jsx(ee,{name:"calendar"}),"全部活动"]}),s.jsx("span",{className:"game-tabs-divider"}),D.map(E),s.jsxs("button",{className:`game-tab add ${N?"active":""}`,"aria-expanded":N,title:"关注更多游戏(SRA 公共 API)",onClick:()=>$(C=>!C),children:[s.jsx(ee,{name:"plus"}),"更多游戏"]}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{role:"tab","aria-selected":F,className:`game-tab ${F?"active":""}`,onClick:()=>P("report"),children:[s.jsx(ee,{name:"send"}),"日报"]})]}),s.jsxs("div",{className:"games-body",children:[N&&s.jsx("section",{className:"card",children:s.jsx(Z6,{client:e,onChanged:()=>p(C=>C+1),onDiscover:C=>void R("discover",async()=>{const{sessionId:I}=await e.connection.call("games/discover",{name:C});t(I)})})}),S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:S})]}),w!==null&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsx("span",{children:w})]}),u!==null&&D.length===0&&s.jsxs("div",{className:"empty",children:[s.jsx(ee,{name:"gamepad"}),s.jsx("p",{children:"没有游戏。点「更多游戏」关注几个。"})]}),u!==null&&M&&D.length>0&&s.jsx(B6,{client:e,games:D,activities:u.activities,now:c,soonDays:u.settings.report.soonDays,onOpenGame:P,onChanged:()=>p(C=>C+1)}),u!==null&&F&&s.jsx(sB,{client:e,data:u,games:D,now:c,openSettings:n,onChanged:()=>p(C=>C+1)}),u!==null&&U!==void 0&&s.jsx(W6,{client:e,game:U,activities:u.activities.filter(C=>C.game===U.id),color:O.get(U.id)??Dl[0],now:c,soonDays:u.settings.report.soonDays,busy:v,onRefresh:()=>void Z(U.id),onRead:()=>void R(`read:${U.id}`,async()=>{const{sessionId:C}=await e.connection.call("games/read",{game:U.id});t(C)}),onReadWeb:C=>void R(`read-web:${U.id}`,async()=>{const{sessionId:I}=await e.connection.call("games/read",{game:U.id,how:"web",...C===void 0?{}:{source:C}});t(I)}),onUnfollow:()=>void R(`unfollow:${U.id}`,async()=>(await e.connection.call("games/follow",{sra:U.id.replace(/^sra-/,""),follow:!1}),g(""),`不再关注${U.name}`)),onChanged:()=>p(C=>C+1),openSession:t,openScripts:()=>r("scripts")},U.id)]})]})}function sB({client:e,data:t,games:n,now:r,openSettings:i,onChanged:o}){const c=t.settings.report,[u,d]=b.useState(null),[f,p]=b.useState(!1),[m,g]=b.useState(null),[v,y]=b.useState(null);b.useEffect(()=>{let w=!0;return e.connection.call("games/report/preview",{}).then(T=>{w&&d(T)}).catch(()=>{}),()=>{w=!1}},[e,t]);const S=async w=>{p(!0),g(null);try{await e.connection.call("games/settings/set",{report:w}),o()}catch(T){g(Pe(T))}finally{p(!1)}},k=async()=>{p(!0),g(null),y(null);try{const{channels:w}=await e.connection.call("games/report/send",{});y(w.length===0?"没有发出去:还没有设置好的聊天渠道。":`已发到${w.join("、")}。`),o()}catch(w){g(Pe(w))}finally{p(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"每日日报"}),s.jsx("p",{className:"muted small",children:"每天先读一遍数据站,再把各游戏的活动、剩余天数和没做完的事发到飞书。进度来自 agent 最近一次进游戏读取(可以在编排里加一个 agent 节点,日常跑完后读一次)。"})]}),s.jsx("span",{className:`badge ${c.enabled?"ok":""}`,children:c.enabled?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.enabled,disabled:f,onChange:w=>void S({enabled:w.target.checked})}),"每天定时发送"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.ai,disabled:f,onChange:w=>void S({ai:w.target.checked})}),"用 AI 总结,只说近期的事(刚开始、快结束、即将开始),语气按「设置 → 回复风格」;agent 不可用时发下面的完整列表"]}),s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"发送时间"}),s.jsx("input",{className:"text-input plain",type:"time",defaultValue:c.at,disabled:f,onBlur:w=>{/^\d{2}:\d{2}$/.test(w.target.value)&&w.target.value!==c.at&&S({at:w.target.value})}},c.at)]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"剩余几天以内标成「快结束」"}),s.jsx("input",{className:"text-input plain",type:"number",min:1,max:30,defaultValue:c.soonDays,disabled:f,onBlur:w=>{const T=Math.max(1,Math.min(30,Math.round(Number(w.target.value)||3)));T!==c.soonDays&&S({soonDays:T})}},c.soonDays)]})]}),s.jsx("div",{className:"field-title",children:"包括的游戏(都不选就是全部)"}),s.jsx("div",{className:"chip-row",children:n.map(w=>{const T=c.games.includes(w.id);return s.jsx("button",{className:`chip chip-button ${T?"active":""}`,disabled:f,onClick:()=>void S({games:T?c.games.filter(N=>N!==w.id):[...c.games,w.id]}),children:w.name},w.id)})}),s.jsxs("p",{className:"muted small",children:[t.report.lastSentAt===void 0?"还没发过。":`上次:${$t(t.report.lastSentAt,r)}。`,t.report.lastResult===void 0?"":` ${t.report.lastResult}。`,c.enabled&&t.report.next!==void 0&&` 下一次:${new Date(t.report.next).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}。`," ",s.jsx("button",{className:"link-button",onClick:()=>i("feishu"),children:"远程连接"})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:m})]})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"今天的日报"}),s.jsx("p",{className:"muted small",children:c.ai?"完整列表。发送时 agent 从里面挑出近期的事写成总结,写不出来就发这份。":"发到飞书的就是这份。"})]}),s.jsxs("button",{className:"small-button primary",disabled:f,onClick:()=>void k(),children:[s.jsx(ee,{name:"send"}),f?"发送中…":"现在发送"]})]}),v!==null&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsx("span",{children:v})]}),u!==null&&s.jsxs("div",{className:"report-preview",children:[s.jsx("strong",{children:u.title}),`
|
|
222
|
-
|
|
223
|
-
`,u.text]})]}),t.report.lastText!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"上次发出的"}),t.report.lastSentAt!==void 0&&s.jsx("p",{className:"muted small",children:$t(t.report.lastSentAt,r)})]})}),s.jsx("div",{className:"report-preview",children:t.report.lastText})]})]})}const rB={id:"games",title:"游戏看板",milestone:"M6",requires:["games"],pages:[{id:"games",title:"游戏",icon:"gamepad",order:-10,component:nB}]},iB={game:"游戏",script:"脚本",general:"通用"};function aB({client:e,focus:t,openSession:n,openSkill:r}){const i=Cn(6e4),o=Ee(e.capabilities),[c,u]=b.useState(null),[d,f]=b.useState({games:new Set,scripts:new Set}),[p,m]=b.useState(null),[g,v]=b.useState(null),[y,S]=b.useState(null),[k,w]=b.useState(null),[T,N]=b.useState(!1),$=async(M=!1)=>{m(M?"refresh":p);try{u(await e.connection.call("skillhub/list",M?{refresh:!0}:{})),v(null)}catch(P){v(Pe(P))}finally{M&&m(null)}};b.useEffect(()=>{$()},[e]),b.useEffect(()=>e.connection.on("skillhub/changed",()=>void $()),[e]),b.useEffect(()=>{let M=!0;return(async()=>{var Z,E;const P=o.has("games")?((Z=await e.connection.call("games/list",{}).catch(()=>{}))==null?void 0:Z.games.map(C=>C.id))??[]:[],R=o.has("scripts")?((E=await e.connection.call("scripts/list",{}).catch(()=>{}))==null?void 0:E.scripts.flatMap(C=>[C.id,C.packId,C.known].filter(I=>I!==void 0)))??[]:[];M&&f({games:new Set(P),scripts:new Set(R)})})(),()=>{M=!1}},[e,o.has("games"),o.has("scripts")]);const D=async(M,P)=>{m(M),v(null),S(null);try{const R=await P();typeof R=="string"&&S(R),await $()}catch(R){v(Pe(R))}finally{m(null)}},O=M=>M.games.some(P=>d.games.has(P))||M.scripts.some(P=>d.scripts.has(P)),F=b.useMemo(()=>{const M=[...(c==null?void 0:c.items)??[]].sort((P,R)=>+(R.name===t)-+(P.name===t)||P.name.localeCompare(R.name));return[{label:"已下载",items:M.filter(P=>P.installed!==void 0)},{label:"推荐给你",hint:"你关注的游戏、装了的脚本",items:M.filter(P=>P.installed===void 0&&O(P))},{label:"其他",items:M.filter(P=>P.installed===void 0&&!O(P))}].filter(P=>P.items.length>0)},[c,d,t]),U=(M,P)=>D(`update:${M.name}`,async()=>{const R=await e.connection.call("skillhub/update",{name:M.name,...P===void 0?{}:{resolve:P}});return w(null),R.state==="merging"&&R.sessionId!==void 0?(n(R.sessionId),"agent 正在合并,合并完会写回你的这份技能"):R.state==="conflict"?"你改过这个技能:选「保留我的」「用新版」或「让 agent 合并」":R.state==="kept"?"已保留你的版本,这个新版本不再提示":R.state==="updated"?R.backup===void 0?`${M.name} 已更新`:`${M.name} 已更新,你原来的那份备份在 ${R.backup}`:"已是最新"});return s.jsxs("div",{className:"skill-hub",children:[s.jsxs("section",{className:"card skill-hub-head",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"技能库"}),s.jsxs("p",{className:"muted small",children:["游戏和脚本的技能放在 ",(c==null?void 0:c.repos.map(M=>M.repo).join("、"))??"MultiGameAssistant/skills",",按需下载;下载的可以改,更新时不会覆盖你的改动。软件自带的核心技能受保护,随软件更新。"]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:(c==null?void 0:c.fetchedAt)===void 0?"":`${$t(c.fetchedAt,i)}读取`}),s.jsxs("button",{className:"small-button",disabled:p!==null,onClick:()=>void $(!0),children:[s.jsx(ee,{name:"refresh"}),p==="refresh"?"读取中…":"检查更新"]}),s.jsx("button",{className:"ghost small-button",onClick:()=>N(M=>!M),children:"仓库"})]})]}),T&&c!==null&&s.jsx(oB,{repos:c.repos,disabled:p!==null,onSave:M=>D("repos",async()=>(await e.connection.call("skillhub/repos/set",{repos:M}),N(!1),await e.connection.call("skillhub/list",{refresh:!0}),"已保存,按新的仓库读取"))}),c==null?void 0:c.errors.map(M=>s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsxs("span",{children:["读不到:",M,c.items.length>0?"(下面是之前读到的)":""]})]},M))]}),y!==null&&s.jsx("div",{className:"notice info",children:y}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:g})]}),c===null&&g===null&&s.jsx("p",{className:"muted",children:"正在读取技能库…"}),c!==null&&c.items.length===0&&c.errors.length===0&&s.jsx("p",{className:"muted",children:"技能库里还没有技能。"}),F.map(M=>s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"sidebar-label",children:[M.label,s.jsx("span",{className:"skills-count",children:M.items.length}),"hint"in M&&s.jsxs("span",{children:["· ",M.hint]})]}),s.jsx("ul",{className:"hub-list",children:M.items.map(P=>{var R,Z,E,C;return s.jsxs("li",{className:P.name===t?"focused":"",children:[s.jsxs("div",{className:"hub-main",children:[s.jsxs("div",{className:"hub-title",children:[s.jsx("strong",{children:P.title??P.name}),P.title!==void 0&&s.jsx("code",{className:"muted small",children:P.name}),s.jsx("span",{className:"badge",children:iB[P.kind]}),((R=P.installed)==null?void 0:R.modified)===!0&&s.jsx("span",{className:"badge",title:"你改过这个技能;更新时不会覆盖",children:"你改过"}),((Z=P.installed)==null?void 0:Z.update)===!0&&s.jsx("span",{className:"badge ok",children:"有新版"})]}),s.jsx("span",{className:"muted small",children:P.description}),P.blocked!==void 0&&s.jsxs("span",{className:"muted small",children:[P.blocked,",没有下载(以你已有的为准)"]})]}),s.jsxs("div",{className:"hub-actions",children:[P.installed===void 0&&P.blocked===void 0&&s.jsx("button",{className:"primary small-button",disabled:p!==null,onClick:()=>void D(`install:${P.name}`,async()=>(await e.connection.call("skillhub/install",{name:P.name,repo:P.repo}),`已下载 ${P.name},agent 现在就能用`)),children:p===`install:${P.name}`?"下载中…":"下载"}),((E=P.installed)==null?void 0:E.update)===!0&&P.installed.modified!==!0&&s.jsx("button",{className:"primary small-button",disabled:p!==null,onClick:()=>void U(P),children:"更新"}),((C=P.installed)==null?void 0:C.update)===!0&&P.installed.modified===!0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"small-button",disabled:p!==null,onClick:()=>void D(`diff:${P.name}`,async()=>w({name:P.name,...await e.connection.call("skillhub/diff",{name:P.name})})),children:"看看哪里不同"}),s.jsx("button",{className:"small-button",disabled:p!==null,onClick:()=>void U(P,"keep"),children:"保留我的"}),s.jsx("button",{className:"small-button",disabled:p!==null,onClick:()=>void U(P,"replace"),children:"用新版"}),s.jsx("button",{className:"primary small-button",disabled:p!==null,onClick:()=>void U(P,"merge"),children:"让 agent 合并"})]}),P.installed!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ghost small-button",onClick:()=>r(P.name),children:"查看"}),s.jsx("button",{className:"ghost small-button",disabled:p!==null,onClick:()=>void D(`remove:${P.name}`,async()=>(await e.connection.call("skillhub/remove",{name:P.name}),`已删除下载的 ${P.name}`)),children:"删除"})]})]}),(k==null?void 0:k.name)===P.name&&s.jsx(lB,{mine:k.mine,theirs:k.theirs,onClose:()=>w(null)})]},`${P.repo}/${P.name}`)})})]},M.label))]})}function oB({repos:e,disabled:t,onSave:n}){const[r,i]=b.useState(e.map(u=>u.branch==="main"?u.repo:`${u.repo}@${u.branch}`).join(`
|
|
224
|
-
`)),o=r.split(/\r?\n/).map(u=>u.trim()).filter(Boolean).map(u=>{const[d,f]=u.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("@");return{repo:d??"",branch:f??"main"}}),c=o.length>0&&o.every(u=>/^[\w.-]+\/[\w.-]+$/.test(u.repo)&&/^[\w./-]+$/.test(u.branch));return s.jsxs("div",{className:"hub-repos",children:[s.jsx("label",{className:"field-label",htmlFor:"hub-repos",children:"技能仓库(一行一个 owner/repo,可以写 @分支;前面的同名技能优先)"}),s.jsx("textarea",{id:"hub-repos",className:"text-input plain",rows:3,value:r,onChange:u=>i(u.target.value),spellCheck:!1}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:"别的仓库里的技能会让 agent 照着做,只加你信得过的。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:t,onClick:()=>i("MultiGameAssistant/skills"),children:"恢复默认"}),s.jsx("button",{className:"primary small-button",disabled:t||!c,onClick:()=>n(o),children:"保存"})]})]})}function lB({mine:e,theirs:t,onClose:n}){const r=b.useMemo(()=>cB(e.split(/\r?\n/),t.split(/\r?\n/)),[e,t]);return s.jsxs("div",{className:"hub-diff",children:[s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[s.jsx("span",{className:"diff-del",children:"− 只在你的版本里"})," ",s.jsx("span",{className:"diff-add",children:"+ 只在新版本里"})]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"ghost small-button",onClick:n,children:"收起"})]}),s.jsx("pre",{children:r.map((i,o)=>s.jsxs("div",{className:i.kind==="-"?"diff-del":i.kind==="+"?"diff-add":"muted",children:[i.kind," ",i.text]},o))})]})}function cB(e,t){var p;const n=e.length,r=t.length,i=Array.from({length:n+1},()=>new Array(r+1).fill(0));for(let m=n-1;m>=0;m--)for(let g=r-1;g>=0;g--)i[m][g]=e[m]===t[g]?i[m+1][g+1]+1:Math.max(i[m+1][g],i[m][g+1]);const o=[];let c=0,u=0;for(;c<n||u<r;)c<n&&u<r&&e[c]===t[u]?(o.push({kind:" ",text:e[c]}),c++,u++):u<r&&(c===n||i[c][u+1]>=i[c+1][u])?(o.push({kind:"+",text:t[u]}),u++):(o.push({kind:"-",text:e[c]}),c++);const d=m=>o.slice(Math.max(0,m-2),m+3).some(g=>g.kind!==" "),f=[];for(let m=0;m<o.length;m++)o[m].kind!==" "||d(m)?f.push(o[m]):((p=f.at(-1))==null?void 0:p.text)!=="…"&&f.push({kind:" ",text:"…"});return f}const uB=[{label:"本应用自带 · 受保护",match:e=>e==="bundled"},{label:"从技能库下载的",match:e=>e==="hub"},{label:"脚本包和游戏包",match:e=>e==="custom"},{label:"你的技能文件夹",match:e=>e.startsWith("user-")},{label:"工作文件夹里的",match:e=>e.startsWith("project-")}];function dB(e){var t;return e.removable===!0?"在这里存的":((t=uB.find(n=>n.match(e.source)))==null?void 0:t.label)??"其他"}const fB="通用",oS="adg:skills:folded";function hB(){try{return new Set(JSON.parse(localStorage.getItem(oS)??"[]"))}catch{return new Set}}function pB(e){try{localStorage.setItem(oS,JSON.stringify([...e]))}catch{}}const mB=e=>e.startsWith("game:")?"gamepad":e.startsWith("script:")?"package":"layers";function gB({client:e,arg:t,openSession:n}){var ke,ae,Ne,Fe;const r=Ee(e.connection.status),i=Ee(e.capabilities),[o,c]=b.useState((t==null?void 0:t.startsWith("hub"))===!0?"hub":"mine"),u=(t==null?void 0:t.startsWith("hub:"))===!0?t.slice(4):void 0,[d,f]=b.useState(null),[p,m]=b.useState(""),[g,v]=b.useState(t??""),[y,S]=b.useState(null),[k,w]=b.useState(null),[T,N]=b.useState(0),[$,D]=b.useState(!1),[O,F]=b.useState(null),[U,M]=b.useState(hB),[P,R]=b.useState(!1),Z=ce=>M(je=>{const re=new Set(je);return re.delete(ce)||re.add(ce),pB(re),re}),E=((ke=Cm(e).data)==null?void 0:ke.scripts)??[],[C,I]=b.useState([]);b.useEffect(()=>{t!==void 0&&(t.startsWith("hub")?c("hub"):(c("mine"),v(t)))},[t]),b.useEffect(()=>e.connection.on("skills/changed",()=>N(ce=>ce+1)),[e]),b.useEffect(()=>{if(r.state!=="open"||!i.has("games"))return;let ce=!0;return e.connection.call("games/list",{}).then(je=>{ce&&I(je.games)},()=>{}),()=>{ce=!1}},[e,r.state,i]),b.useEffect(()=>{if(r.state!=="open")return;let ce=!0;return e.connection.call("skills/list",{}).then(je=>{ce&&(f(je.skills),w(null))},je=>{ce&&w(Pe(je))}),()=>{ce=!1}},[e,r.state,T,o]);const L=p.trim().toLowerCase(),W=b.useMemo(()=>(d??[]).filter(ce=>L===""||`${ce.name} ${ce.description} ${ce.whenToUse??""}`.toLowerCase().includes(L)),[d,L]),H=b.useMemo(()=>{const ce=new Map,je=(Ie,tt,et)=>{const jt=ce.get(Ie)??{key:Ie,label:tt,items:[],subs:[],...et};return ce.set(Ie,jt),jt},re=Ie=>je(`game:${Ie.id}`,Ie.name,{game:Ie.id}),he=(Ie,tt)=>{const et=Ie.subs.find(jt=>jt.script===tt.id)??{key:`${Ie.key}/${tt.id}`,label:tt.name,script:tt.id,items:[]};return Ie.subs.includes(et)||Ie.subs.push(et),et},ze=(Ie,tt)=>{Ie.includes(tt)||Ie.push(tt)};if(L===""){for(const Ie of C)re(Ie);for(const Ie of E){const tt=ew(Ie,C);tt===void 0?je(`script:${Ie.id}`,Ie.name,{script:Ie.id}):he(re(tt),Ie)}}for(const Ie of W){const tt=Dp(Ie.owner,E,C);tt.length===0&&ze(je("general",fB,{}).items,Ie);for(const et of tt)et.game!==void 0&&et.script!==void 0?ze(he(re(et.game),et.script).items,Ie):et.game!==void 0?ze(re(et.game).items,Ie):et.script!==void 0&&ze(je(`script:${et.script.id}`,et.script.name,{script:et.script.id}).items,Ie)}const Te=(Ie,tt)=>Ie.name.localeCompare(tt.name),Ge=Ie=>Ie.key.startsWith("game:")?0:Ie.key.startsWith("script:")?1:2;return[...ce.values()].map(Ie=>({...Ie,items:Ie.items.sort(Te),subs:Ie.subs.map(tt=>({...tt,items:tt.items.sort(Te)})).sort((tt,et)=>tt.label.localeCompare(et.label))})).sort((Ie,tt)=>Ge(Ie)-Ge(tt)||Ie.label.localeCompare(tt.label))},[W,E,C,L]),G=H.flatMap(ce=>[...ce.items,...ce.subs.flatMap(je=>je.items)])[0],K=W.find(ce=>ce.name===g)??G;b.useEffect(()=>{if(R(!1),K===void 0){S(null);return}let ce=!0;return D(!1),e.connection.call("skills/get",{name:K.name}).then(je=>{ce&&S(je)},je=>{ce&&w(Pe(je))}),()=>{ce=!1}},[e,K==null?void 0:K.name,T]);const V=ce=>{var je;(je=navigator.clipboard)==null||je.writeText(`/${ce} `).then(()=>D(!0),()=>{})},Y=async ce=>{if(confirm(`删除技能「${ce.name}」?它的文件夹会一起删掉,agent 以后就用不到它了。`))try{await e.connection.call("skills/remove",{name:ce.name}),v(""),N(je=>je+1)}catch(je){w(Pe(je))}},fe=ce=>[...new Set(Dp(ce.owner,E,C).map(tw))],xe=ce=>({name:"",description:"",content:"",scripts:ce.script===void 0?[]:[ce.script],games:ce.script===void 0&&ce.game!==void 0?[ce.game]:[]}),me=ce=>s.jsxs("button",{className:`script-row skill-row ${O===null&&(K==null?void 0:K.name)===ce.name?"active":""}`,onClick:()=>{F(null),v(ce.name)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:ce.name}),s.jsx("span",{className:"muted small skills-row-desc",children:ce.description})]}),ce.removable===!0&&s.jsx("span",{className:"skill-row-mark",title:"在这里存的:可以编辑和删除",children:s.jsx(ee,{name:"pencil"})})]},ce.name),ie=(ce,je,re)=>s.jsx("button",{className:"icon-button skills-add",title:re,"aria-label":`在${ce}下新建技能`,disabled:r.state!=="open",onClick:()=>F(xe(je)),children:s.jsx(ee,{name:"plus"})});return s.jsxs("section",{className:"main scripts-page skills-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"技能"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:o==="hub"?"技能库":"agent 的技能"})]}),s.jsxs("div",{className:"page-actions",children:[i.has("skillhub")&&s.jsxs("div",{className:"tabs",role:"tablist",children:[s.jsx("button",{role:"tab","aria-selected":o==="mine",className:o==="mine"?"active":"",onClick:()=>c("mine"),children:"已有的技能"}),s.jsx("button",{role:"tab","aria-selected":o==="hub",className:o==="hub"?"active":"",onClick:()=>c("hub"),children:"技能库"})]}),o==="mine"&&s.jsxs("button",{className:"small-button",disabled:r.state!=="open",onClick:()=>F(xe({})),children:[s.jsx(ee,{name:"plus"}),"新建技能"]}),o==="mine"&&s.jsxs("button",{className:"small-button",onClick:()=>N(ce=>ce+1),children:[s.jsx(ee,{name:"refresh"}),"刷新"]})]})]}),o==="hub"&&i.has("skillhub")?s.jsx("div",{className:"skill-hub-body",children:s.jsx(aB,{client:e,focus:u,openSession:n,openSkill:ce=>{v(ce),c("mine")}})}):s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"技能列表",children:[s.jsxs("div",{className:"skills-search",children:[s.jsx(ee,{name:"search"}),s.jsx("input",{className:"text-input",value:p,onChange:ce=>m(ce.target.value),placeholder:"搜索技能","aria-label":"搜索技能"})]}),d!==null&&L!==""&&s.jsx("p",{className:"muted small skills-found",children:W.length===0?"没有匹配的技能。":`找到 ${W.length} 个技能`}),d!==null&&L===""&&W.length===0&&s.jsx("p",{className:"muted small pad",children:"还没有技能。"}),H.map(ce=>{const je=L!==""||!U.has(ce.key);return s.jsxs("div",{className:`skills-group ${je?"":"folded"}`,children:[s.jsxs("div",{className:"skills-section-head",children:[s.jsxs("button",{className:"skills-fold","aria-expanded":je,onClick:()=>Z(ce.key),children:[s.jsx(ee,{name:"chevron-down",className:"skills-chevron"}),s.jsx(ee,{name:mB(ce.key),className:"skills-section-icon"}),s.jsx("span",{className:"skills-group-name",children:ce.label}),s.jsx("span",{className:"skills-count",children:new Set([...ce.items,...ce.subs.flatMap(re=>re.items)]).size})]}),ie(ce.label,ce,ce.game!==void 0?`给游戏「${ce.label}」新建一个技能(处理这个游戏的对话都能用)`:ce.script!==void 0?`给「${ce.label}」新建一个技能(只给它用)`:"新建一个通用技能")]}),je&&s.jsxs(s.Fragment,{children:[ce.items.map(me),ce.script!==void 0&&ce.items.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有只给它用的技能"}),ce.game!==void 0&&ce.items.length===0&&ce.subs.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有这个游戏的技能"}),ce.subs.map(re=>s.jsxs("div",{className:"skills-sub",children:[s.jsxs("div",{className:"skills-sub-label",children:[s.jsx(ee,{name:"package",className:"skills-section-icon"}),s.jsx("span",{className:"skills-group-name",children:re.label}),s.jsx("span",{className:"skills-count",children:re.items.length}),s.jsx("span",{className:"spacer"}),ie(re.label,{script:re.script},`给「${re.label}」新建一个技能(只给它用)`)]}),re.items.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有只给它用的技能"}),re.items.map(me)]},re.key))]})]},ce.key)})]}),s.jsx("div",{className:"scripts-detail",children:s.jsxs("div",{className:"script-detail",children:[k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:k})]}),O!==null?s.jsx(xB,{client:e,draft:O,scripts:E,games:C,onCancel:()=>F(null),onSaved:ce=>{F(null),v(ce),w(null),N(je=>je+1)}}):s.jsxs(s.Fragment,{children:[d===null&&k===null&&s.jsx("p",{className:"muted",children:"正在读取…"}),d!==null&&K===void 0&&s.jsxs("div",{className:"skills-blank",children:[s.jsx(ee,{name:"sparkles"}),s.jsx("strong",{children:"还没有技能"}),s.jsx("span",{className:"muted small",children:"agent 做成一件事后会提议存成技能;也可以自己写一个。"}),s.jsxs("button",{className:"small-button primary",disabled:r.state!=="open",onClick:()=>F(xe({})),children:[s.jsx(ee,{name:"plus"}),"新建技能"]})]}),K!==void 0&&s.jsxs("article",{className:"card skill-card",children:[s.jsxs("header",{className:"skill-top",children:[s.jsxs("div",{className:"skill-title",children:[s.jsx("h2",{children:K.name}),s.jsxs("div",{className:"skill-meta",children:[fe(K).length===0?s.jsxs("span",{className:"badge",title:"所有对话都看得到、用得了",children:[s.jsx(ee,{name:"layers"}),"通用"]}):s.jsxs("span",{className:"badge warn",title:"技能隔离:只有在处理这些游戏或脚本的对话里,agent 才看得到、用得了这个技能",children:[s.jsx(ee,{name:(Ne=(ae=K.owner)==null?void 0:ae.scripts)!=null&&Ne.length?"package":"gamepad"}),"只给 ",fe(K).join("、")," 用"]}),K.modelInvocable&&s.jsx("span",{className:"badge ok",title:"agent 遇到相关的事会自己读这个技能",children:"agent 自动使用"}),s.jsxs("span",{className:"badge",title:K.removable===!0?"存在这个软件的技能文件夹里,可以编辑和删除":`在这里不能改和删${K.source==="hub"?",到「技能库」里卸载":""}`,children:[dB(K),K.removable===!0?"":" · 只读"]})]})]}),s.jsxs("div",{className:"skill-buttons",children:[K.userInvocable&&s.jsxs("button",{className:"small-button",onClick:()=>V(K.name),title:"复制后粘贴到对话框,后面写要它做的事",children:[s.jsx(ee,{name:$?"check":"copy"}),$?"已复制":`/${K.name}`]}),(K.removable===!0||K.source==="hub")&&s.jsxs("button",{className:"small-button","aria-expanded":P,onClick:()=>R(ce=>!ce),title:"放错了游戏或脚本时,换到对的那个",children:[s.jsx(ee,{name:"gamepad"}),"更换游戏和脚本"]}),K.removable===!0&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"small-button",disabled:(y==null?void 0:y.name)!==K.name,onClick:()=>{var ce,je;return F({original:K.name,name:K.name,description:K.description,content:(y==null?void 0:y.content)??"",scripts:[...((ce=K.owner)==null?void 0:ce.scripts)??[]],games:[...((je=K.owner)==null?void 0:je.games)??[]]})},children:[s.jsx(ee,{name:"pencil"}),"编辑"]}),s.jsx("button",{className:"small-button danger-outline",onClick:()=>void Y(K),children:"删除"})]}),K.path!==void 0&&((Fe=kr())==null?void 0:Fe.openPath)!==void 0&&s.jsx("button",{className:"icon-button skill-folder",title:`打开所在文件夹:${K.path}`,"aria-label":"打开所在文件夹",onClick:()=>{var ce,je;return void((je=(ce=kr())==null?void 0:ce.openPath)==null?void 0:je.call(ce,K.path.replace(/[\\/][^\\/]+$/,"")))},children:s.jsx(ee,{name:"layers"})})]})]}),P&&s.jsx(vB,{client:e,skill:K,content:(y==null?void 0:y.name)===K.name?y.content:void 0,scripts:E,games:C,onCancel:()=>R(!1),onMoved:()=>{R(!1),w(null),N(ce=>ce+1)}},K.name),s.jsx("p",{className:"skill-desc",children:K.description}),K.whenToUse!==void 0&&s.jsxs("p",{className:"muted small",children:["什么时候用:",K.whenToUse]}),s.jsxs("section",{className:"skill-body","aria-label":"技能内容",children:[s.jsx("div",{className:"skill-body-label",children:"技能内容"}),(y==null?void 0:y.name)===K.name?s.jsx(Ki,{text:y.content}):s.jsx("p",{className:"muted",children:"正在读取…"})]}),K.path!==void 0&&s.jsx("code",{className:"muted small skill-path",title:K.path,children:K.path})]})]})]})})]})]})}function xB({client:e,draft:t,scripts:n,games:r,onCancel:i,onSaved:o}){const[c,u]=b.useState(t),[d,f]=b.useState(!1),[p,m]=b.useState(null);b.useEffect(()=>{u(t),m(null)},[t]);const g=t.original!==void 0,v=Ek.test(c.name)&&c.name.length<=jp,y=v&&c.description.trim().length>=10&&c.content.trim().length>=20,S=async()=>{f(!0),m(null);try{await e.connection.call("skills/save",{name:c.name,description:c.description.trim(),content:c.content.trim(),...c.scripts.length===0?{}:{scripts:c.scripts},...c.games.length===0?{}:{games:c.games},...g?{replace:!0}:{}}),o(c.name)}catch(k){m(Pe(k))}finally{f(!1)}};return s.jsxs("article",{className:"card skill-card skill-form",children:[s.jsx("div",{className:"skill-head",children:s.jsx("h2",{children:g?`编辑 ${t.original}`:"新建技能"})}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:"名字(在对话里用 /名字 调用它)"}),s.jsx("input",{className:"text-input",value:c.name,disabled:g,maxLength:jp,autoFocus:!g,onChange:k=>u(w=>({...w,name:k.target.value.trim().toLowerCase()})),placeholder:"例:maa-daily-check"}),c.name!==""&&!v&&s.jsx("span",{className:"error small",children:"只能用小写英文字母、数字和短横线,例如 maa-daily-check"})]}),s.jsx(lS,{scripts:n,games:r,value:c,onChange:k=>u(w=>({...w,...k}))}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:"说明:做什么、什么时候用(agent 靠它决定什么时候用,10–400 字)"}),s.jsx("textarea",{className:"text-input",rows:2,maxLength:400,value:c.description,onChange:k=>u(w=>({...w,description:k.target.value})),placeholder:"例:MAA 日常跑完后检查理智和基建是否都处理了;用户问「MAA 跑完了吗」时用。"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:"内容(Markdown):适用场景、一步一步的做法、怎样算成功、注意事项"}),s.jsx("textarea",{className:"text-input skill-content-input",rows:16,maxLength:2e4,value:c.content,onChange:k=>u(w=>({...w,content:k.target.value}))})]}),p!==null&&s.jsx("p",{className:"error small",children:p}),s.jsxs("div",{className:"skill-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:d,onClick:i,children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:d||!y,onClick:()=>void S(),children:d?"保存中…":"保存"})]})]})}function lS({scripts:e,games:t,value:n,onChange:r}){const[i]=b.useState(n),o=[...new Set([...i.scripts,...n.scripts])].filter(p=>!e.some(m=>m.id===p)),c=[...new Set([...i.games,...n.games])].filter(p=>Lp(p,t)===void 0),u=(p,m)=>{var g;return p===m||((g=Lp(p,t))==null?void 0:g.id)===m},d=p=>r({...n,scripts:n.scripts.includes(p)?n.scripts.filter(m=>m!==p):[...n.scripts,p]}),f=p=>r({...n,games:n.games.some(m=>u(m,p))?n.games.filter(m=>!u(m,p)):[...n.games,p]});return s.jsxs(s.Fragment,{children:[(t.length>0||c.length>0)&&s.jsxs("fieldset",{className:"field skill-owners",children:[s.jsx("legend",{className:"field-label",children:"给哪个游戏用(和游戏本身有关、换个脚本也用得上的:游戏里的操作、界面、活动、机制)"}),s.jsxs("div",{className:"skill-owner-list",children:[t.map(p=>s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.games.some(m=>u(m,p.id)),onChange:()=>f(p.id)}),p.name]},p.id)),c.map(p=>s.jsxs("label",{className:"check-label",title:"游戏页上没有这个游戏",children:[s.jsx("input",{type:"checkbox",checked:n.games.includes(p),onChange:()=>f(p)}),p]},p))]})]}),s.jsxs("fieldset",{className:"field skill-owners",children:[s.jsx("legend",{className:"field-label",children:"给哪个脚本用(只在用这个脚本时才用得上的做法:它的配置、报错、日志)"}),e.length===0&&o.length===0&&s.jsx("span",{className:"muted small",children:"还没有装脚本。"}),s.jsxs("div",{className:"skill-owner-list",children:[e.map(p=>s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.scripts.includes(p.id),onChange:()=>d(p.id)}),p.name]},p.id)),o.map(p=>s.jsxs("label",{className:"check-label",title:"这个脚本不在脚本库里(删掉了,或是脚本包 id)",children:[s.jsx("input",{type:"checkbox",checked:n.scripts.includes(p),onChange:()=>d(p)}),p]},p))]})]}),s.jsx("p",{className:"muted small",children:"游戏和脚本都不选就是通用技能,所有对话都能用。"})]})}function vB({client:e,skill:t,content:n,scripts:r,games:i,onCancel:o,onMoved:c}){var S,k;const[u,d]=b.useState({scripts:[...((S=t.owner)==null?void 0:S.scripts)??[]],games:[...((k=t.owner)==null?void 0:k.games)??[]]}),[f,p]=b.useState(!1),[m,g]=b.useState(null),v=t.source==="hub",y=async w=>{p(!0),g(null);try{if(v)await e.connection.call("skillhub/owner",{name:t.name,owner:w});else{if(n===void 0||w===null)return;await e.connection.call("skills/save",{name:t.name,description:t.description,content:n,replace:!0,...w.scripts.length===0?{}:{scripts:w.scripts},...w.games.length===0?{}:{games:w.games}})}c()}catch(T){g(Pe(T))}finally{p(!1)}};return s.jsxs("div",{className:"skill-move",role:"group","aria-label":"更换游戏和脚本",children:[s.jsx(lS,{scripts:r,games:i,value:u,onChange:d}),v&&s.jsx("p",{className:"muted small",children:"这是从技能库下载的技能:你选的会一直保留,技能库更新它也不变。"}),m!==null&&s.jsx("p",{className:"error small",children:m}),s.jsxs("div",{className:"skill-actions",children:[v&&s.jsx("button",{className:"link-button small",disabled:f,onClick:()=>void y(null),children:"恢复成技能库里的"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:f,onClick:o,children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:f||!v&&n===void 0,onClick:()=>void y(u),children:f?"保存中…":"保存"})]})]})}const yB={id:"skills",title:"技能",requires:["skills"],pages:[{id:"skills",title:"技能",icon:"sparkles",order:50,agent:"scripts",component:gB}]};function bB({client:e}){const t=Ee(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(0),[c,u]=b.useState(null),[d,f]=b.useState(null),[p,m]=b.useState(""),[g,v]=b.useState("");b.useEffect(()=>e.connection.on("emulators/changed",()=>o(k=>k+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let k=!0;return e.connection.call("emulators/status",{refresh:i===0}).then(w=>{k&&(r(w),m(w.settings.manualAddress??""),v(w.settings.adbPath??""))}).catch(w=>{k&&f(Pe(w))}),()=>{k=!1}},[e,t.state,i]);const y=async(k,w)=>{u(k),f(null);try{await w(),o(T=>T+1)}catch(T){f(Pe(T))}finally{u(null)}},S=k=>y("settings",()=>e.connection.call("emulators/settings/set",k));return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"模拟器"}),s.jsx("p",{children:"需要安卓模拟器的任务(如 MAA)运行前,会自动启动这里选定的实例并取得 ADB 地址。分辨率请设为 16:9(如 1280×720)。"}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"当前使用"}),s.jsx("p",{className:"muted small",children:(n==null?void 0:n.selection.label)??"…"})]}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y("refresh",()=>e.connection.call("emulators/status",{refresh:!0})),children:"重新检测"})]}),(n==null?void 0:n.selection.problem)!==void 0&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsxs("span",{children:[n.selection.problem,"。可以对 agent 说「安装 MuMu 模拟器」,或在下面填写手动 ADB 地址。"]})]})]}),n==null?void 0:n.providers.map(k=>s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsxs("h3",{children:[k.name,k.version===void 0?"":` ${k.version}`]}),s.jsx("p",{className:"muted small",children:k.manager})]}),n.settings.mumuManager===k.manager&&s.jsx("span",{className:"badge ok",children:"已指定"})]}),k.error!==void 0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:k.error})]}),s.jsx("ul",{className:"version-list",children:k.instances.map(w=>s.jsxs("li",{className:w.index===n.settings.instance?"current":"",children:[s.jsx("span",{className:"version-name",children:w.index}),s.jsx("span",{children:w.name}),s.jsx("span",{className:`badge ${w.ready?"ok":""}`,children:w.ready?"已启动":w.running?"启动中":"未运行"}),w.adb!==void 0&&s.jsx("span",{className:"muted small",children:w.adb}),s.jsx("span",{className:"spacer"}),w.index!==n.settings.instance&&s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void S({instance:w.index}),children:"任务用这个"}),w.ready?s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y(`stop-${w.index}`,()=>e.connection.call("emulators/stop",{index:w.index})),children:"关闭"}):s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y(`start-${w.index}`,()=>e.connection.call("emulators/start",{index:w.index})),children:c===`start-${w.index}`?"启动中…":"启动"})]},w.index))})]},k.manager)),n!==null&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"设置"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.settings.autoStart,onChange:k=>void S({autoStart:k.target.checked})}),"任务需要时自动启动模拟器"]}),s.jsx("label",{className:"field-label",htmlFor:"manual-adb",children:"手动 ADB 地址(其他模拟器或真机,可选)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"manual-adb",className:"text-input plain",value:p,onChange:k=>m(k.target.value),placeholder:"例如 127.0.0.1:5555;填写后不再管理 MuMu",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void S({manualAddress:p.trim()===""?null:p.trim()}),children:"保存"})]}),s.jsx("label",{className:"field-label",htmlFor:"adb-path",children:"adb.exe 位置(可选,出错时重连模拟器、截图用;默认用 MuMu 自带的)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"adb-path",className:"text-input plain",value:g,onChange:k=>v(k.target.value),placeholder:"例如 D:\\platform-tools\\adb.exe",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void S({adbPath:g.trim()===""?null:g.trim()}),children:"保存"})]}),s.jsx("label",{className:"field-label",htmlFor:"boot-timeout",children:"等待安卓启动的最长时间(秒)"}),s.jsx("input",{id:"boot-timeout",className:"text-input plain",type:"number",min:30,max:900,defaultValue:n.settings.bootTimeoutSeconds,onBlur:k=>void S({bootTimeoutSeconds:Math.max(30,Math.min(900,Number(k.target.value)||180))})})]}),d!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:d})]})]})}function kB({client:e}){const t=Ee(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(""),[d,f]=b.useState(""),[p,m]=b.useState(null),[g,v]=b.useState(!1),[y,S]=b.useState(null),[k,w]=b.useState(null),T=()=>e.connection.call("scripts/settings",{}).then(O=>{r(O),o(O)}).catch(O=>w(Pe(O)));if(b.useEffect(()=>{t.state==="open"&&T()},[e,t.state]),i===null||n===null)return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"脚本安装"}),k===null?s.jsx("p",{children:"加载中…"}):s.jsx("div",{className:"notice error left",children:k})]});const N=(O,F)=>o({...i,[O]:F}),$=async()=>{v(!0),w(null),S(null);try{const{tokenConfigured:O,cdkConfigured:F,...U}=n,M=Object.fromEntries(Object.entries(i).filter(([P,R])=>U[P]!==R));Object.keys(M).length>0&&await e.connection.call("scripts/settings/set",M),c.trim()!==""&&await e.connection.call("credentials/set",{ref:i.tokenRef,value:c.trim()}),u(""),d.trim()!==""&&(await e.connection.call("credentials/set",{ref:i.cdkRef,value:d.trim()}),f(""),D()),await T(),S("已保存,下一次安装起生效")}catch(O){w(Pe(O))}finally{v(!1)}},D=async()=>{m("checking");try{m(await e.connection.call("scripts/mirrorchyan/check",{}))}catch(O){m({ok:!1,message:Pe(O)})}};return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"脚本安装"}),s.jsx("p",{children:"从 GitHub 发布页下载脚本时使用的设置。国内网络下载慢或失败时,可以填写下载镜像前缀。"}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"下载镜像"}),s.jsx("input",{className:"text-input plain",value:i.downloadMirror,onChange:O=>N("downloadMirror",O.target.value),placeholder:"留空直接下载;例如 https://ghfast.top/",spellCheck:!1}),s.jsx("p",{className:"muted small",children:"镜像只用于 GitHub 上的文件:下载地址前面加上这个前缀。微软、Google 等官方组件始终直接下载。"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:i.mirrorFallback,onChange:O=>N("mirrorFallback",O.target.checked)}),"镜像失败时改为直接下载"]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"Mirror酱"}),s.jsxs("p",{className:"muted small",children:["在 ",s.jsx("a",{href:"https://mirrorchyan.com?source=multigameassistant_settings",target:"_blank",rel:"noreferrer",children:"Mirror酱"})," 发布的脚本(MAA、MaaEnd、三月七小助手、M9A、BetterGI 等)填了 CDK 后从 Mirror酱 更新:国内下载快,而且只下载改动的文件(增量更新)。不填照常从 GitHub 下载;CDK 过期、次数用完时也会自动改回 GitHub。"]}),s.jsx("label",{className:"field-label",htmlFor:"mc-cdk",children:"CDK"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"mc-cdk",className:"text-input",type:"password",value:d,onChange:O=>f(O.target.value),placeholder:n.cdkConfigured?"已配置;输入新值可替换":"在 Mirror酱 购买后得到的 CDK",autoComplete:"off"}),n.cdkConfigured?s.jsx("span",{className:"badge ok",children:"已配置"}):s.jsx("span",{className:"badge",children:"未配置"}),n.cdkConfigured&&s.jsx("button",{className:"small-button",disabled:p==="checking",onClick:()=>void D(),children:p==="checking"?"检查中…":"检查"})]}),p!==null&&p!=="checking"&&s.jsx("p",{className:"small",style:{color:p.ok?"var(--ok)":"var(--error)"},children:p.message}),s.jsxs("p",{className:"muted small",children:["保存在 dsh 的凭据文件里(",i.cdkRef,"),界面和日志里都不会显示它。"]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"GitHub 访问"}),s.jsx("label",{className:"field-label",htmlFor:"gh-token",children:"GitHub Token(可选)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"gh-token",className:"text-input",type:"password",value:c,onChange:O=>u(O.target.value),placeholder:n.tokenConfigured?"已配置;输入新值可替换":"不填也能用;填写后请求上限从每小时 60 次提高到 5000 次",autoComplete:"off"}),n.tokenConfigured?s.jsx("span",{className:"badge ok",children:"已配置"}):s.jsx("span",{className:"badge",children:"未配置"})]}),s.jsxs("p",{className:"muted small",children:["只需要读取公开仓库的权限。保存在 dsh 的凭据文件里(",i.tokenRef,"),界面不会显示它的内容。"]}),s.jsx("label",{className:"field-label",htmlFor:"gh-api",children:"API 地址"}),s.jsx("input",{id:"gh-api",className:"text-input plain",value:i.apiBase,onChange:O=>N("apiBase",O.target.value),spellCheck:!1})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"版本"}),s.jsx("label",{className:"field-label",htmlFor:"keep-versions",children:"每个脚本保留的版本数(含当前版本)"}),s.jsx("input",{id:"keep-versions",className:"text-input plain",type:"number",min:1,max:10,value:i.keepVersions,onChange:O=>N("keepVersions",Math.max(1,Math.min(10,Number(O.target.value)||1)))}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:i.includePrereleases,onChange:O=>N("includePrereleases",O.target.checked)}),"没有正式版时使用预发布版本"]})]}),s.jsxs("div",{className:"key-actions",children:[y!==null&&s.jsx("span",{className:"muted small",children:y}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary",disabled:g,onClick:()=>void $(),children:g?"保存中…":"保存"})]}),k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:k})]})]})}function wB({client:e,initialRepo:t,jobs:n,onDone:r,openSession:i,onClose:o}){const[c,u]=b.useState(t??""),[d,f]=b.useState(null),[p,m]=b.useState(""),[g,v]=b.useState(""),[y,S]=b.useState(!1),[k,w]=b.useState(null),[T,N]=b.useState(null),$=async(M=c)=>{var R;const P=dM(M);if(P===void 0){w("请输入 owner/repo,或粘贴 GitHub 上的仓库、发布或文件链接");return}S(!0),w(null);try{const Z=await e.connection.call("scripts/releases",{repo:P.repo,limit:10});u(P.repo),f({...Z,branch:P.branch});const E=Z.releases.find(I=>I.tag===P.tag),C=E??Z.releases.find(I=>!I.prerelease)??Z.releases[0];m((C==null?void 0:C.tag)??""),v(((R=C==null?void 0:C.assets.find(I=>I.name===P.asset))==null?void 0:R.name)??(C==null?void 0:C.suggestedAsset)??""),P.tag!==void 0&&E===void 0&&Z.releases.length>0&&w(`最近的发布里没有 ${P.tag},已改选最新版本`)}catch(Z){f(null),w(Pe(Z))}finally{S(!1)}};b.useEffect(()=>{t!==void 0&&$(t)},[t]);const D=d==null?void 0:d.releases.find(M=>M.tag===p),O=d!==null&&(d.branch!==void 0||d.releases.length===0),F=async()=>{if(d!==null){S(!0),w(null);try{const{jobId:M,scriptId:P}=await e.connection.call("scripts/install",{repo:d.repo,...d.branch===void 0?{}:{branch:d.branch}});N({jobId:M,scriptId:P,tag:d.branch===void 0?"默认分支":`${d.branch} 分支`,asset:"源码压缩包"})}catch(M){w(Pe(M))}finally{S(!1)}}},U=async()=>{var M;if(!(d===null||D===void 0||g==="")){S(!0),w(null);try{const{jobId:P,scriptId:R}=await e.connection.call("scripts/install",{repo:d.repo,tag:D.tag,asset:g});N({jobId:P,scriptId:R,tag:D.tag,asset:g,size:(M=D.assets.find(Z=>Z.name===g))==null?void 0:M.size})}catch(P){w(Pe(P))}finally{S(!1)}}};if(T!==null&&d!==null){const M=n.get(T.scriptId);return s.jsx(cS,{client:e,repo:d.repo,...T,job:(M==null?void 0:M.id)===T.jobId?M:void 0,onDone:()=>r(T.scriptId),openSession:i,onRetry:()=>N(null),onClose:o})}return s.jsxs("section",{className:"card panel-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"从 GitHub 安装"}),s.jsx("p",{className:"muted small",children:"优先使用发布版本;文件会放进统一的工具目录,旧版本保留用于回滚。"})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:o,children:s.jsx(ee,{name:"close"})})]}),s.jsxs("form",{className:"field-row",onSubmit:M=>{M.preventDefault(),$()},children:[s.jsx("input",{className:"text-input plain","aria-label":"GitHub 仓库",value:c,onChange:M=>u(M.target.value),placeholder:"owner/repo 或 GitHub 链接,例如 MaaAssistantArknights/MaaAssistantArknights",spellCheck:!1,disabled:y}),s.jsx("button",{type:"submit",disabled:y||c.trim()==="",children:y&&d===null?"读取中…":"读取发布"})]}),O&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:d.branch!==void 0?`链接指向 ${d.branch} 分支:会下载这个分支当前的源码,之后跟着它更新。`:"这个仓库还没有发布版本:可以下载默认分支当前的源码,之后跟着这个分支更新。"}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:d.releases.length===0?"primary":"",onClick:()=>void F(),disabled:y,children:["安装",d.branch===void 0?"源码":` ${d.branch} 分支`]})]}),d!==null&&d.releases.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"field-label",htmlFor:"release-select",children:["版本",d.packId!==void 0&&s.jsxs("span",{className:"chip subtle",children:["内置脚本包 ",d.packId]})]}),s.jsx(yn,{id:"release-select",value:p,disabled:y,onChange:M=>{var P;m(M),v(((P=d.releases.find(R=>R.tag===M))==null?void 0:P.suggestedAsset)??"")},options:d.releases.map(M=>({value:M.tag,label:`${M.tag}${M.prerelease?"(预发布)":""}`,...M.publishedAt===void 0?{}:{hint:`${M.publishedAt.slice(0,10)} 发布`}}))}),D!==void 0&&s.jsxs("fieldset",{className:"asset-list",disabled:y,children:[s.jsx("legend",{className:"field-label",children:"下载文件"}),D.assets.length===0&&s.jsx("div",{className:"muted small",children:"这个版本没有可下载的文件"}),[...D.assets].sort((M,P)=>+(P.name===D.suggestedAsset)-+(M.name===D.suggestedAsset)).map(M=>s.jsxs("label",{className:`asset-option ${M.name===g?"active":""}`,children:[s.jsx("input",{type:"radio",name:"asset",value:M.name,checked:M.name===g,onChange:()=>v(M.name)}),s.jsx("span",{className:"asset-name",children:M.name}),M.name===D.suggestedAsset&&s.jsx("span",{className:"badge ok",children:"推荐"}),s.jsx("span",{className:"muted small",children:va(M.size)})]},M.name))]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:(D==null?void 0:D.suggestedAsset)===void 0?"没有自动匹配到适合本机的文件,请手动选择。":"已按本机(Windows x64)选好文件。"}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:"primary",onClick:()=>void U(),disabled:y||g==="",children:["安装 ",D==null?void 0:D.tag]})]})]}),k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:k})]})]})}function NB({client:e,initialRid:t,jobs:n,onDone:r,openSession:i,onGitHub:o,onClose:c}){const[u,d]=b.useState(""),f=jB(e,u),[p,m]=b.useState(null),[g,v]=b.useState(null),[y,S]=b.useState(!1),[k,w]=b.useState(null),[T,N]=b.useState(null);b.useEffect(()=>{e.connection.call("scripts/settings",{}).then(U=>v(U.cdkConfigured),()=>v(null))},[e]);const $=async U=>{S(!0),w(null);try{m(await e.connection.call("scripts/mirrorchyan/lookup",{rid:U}))}catch(M){m(null),w(Pe(M))}finally{S(!1)}};b.useEffect(()=>{t!==void 0&&$(t)},[t]);const D=async()=>{if(p!==null){S(!0),w(null);try{N(await e.connection.call("scripts/install",{mirrorchyan:p.rid}))}catch(U){w(Pe(U))}finally{S(!1)}}};if(T!==null&&p!==null){const U=n.get(T.scriptId);return s.jsx(cS,{client:e,repo:`Mirror酱 · ${p.rid}`,tag:p.version,asset:`${p.name??p.rid}(Mirror酱 完整包)`,job:(U==null?void 0:U.id)===T.jobId?U:void 0,onDone:()=>r(T.scriptId),openSession:i,onRetry:()=>N(null),onClose:c})}const O=u.trim(),F=/^[\w.-]{1,100}$/.test(O)&&!(f.items??[]).some(U=>U.rid.toLowerCase()===O.toLowerCase());return s.jsxs("section",{className:"card panel-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"从 Mirror酱 安装"}),s.jsx("p",{className:"muted small",children:"按游戏名、工具名或资源 id 查找(查找和查询版本都不需要 CDK);下载需要在「设置 → 脚本安装」填写 CDK,以后的更新有增量包。"})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:c,children:s.jsx(ee,{name:"close"})})]}),s.jsx("input",{className:"text-input plain","aria-label":"搜索 Mirror酱",value:u,onChange:U=>d(U.target.value),placeholder:"例如 原神、鸣潮、BetterGI、MAA",spellCheck:!1,autoFocus:!0}),s.jsx(SB,{results:f,selected:p==null?void 0:p.rid,disabled:y,onPick:U=>void $(U)}),F&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:"small-button",disabled:y,onClick:()=>void $(O),children:["按资源 id 查询 ",O]})]}),p!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"install-file",children:[s.jsx(ee,{name:"package"}),s.jsx("span",{className:"asset-name",children:p.name??p.rid}),s.jsxs("span",{className:"badge",children:["Mirror酱 ",p.rid]}),s.jsxs("span",{className:"muted small",children:["最新 ",p.version]})]}),p.description!==void 0&&s.jsx("p",{className:"muted small mirror-desc",children:p.description}),g===!1&&s.jsx("div",{className:"notice info left small",children:s.jsxs("span",{children:["还没有填写 Mirror酱 CDK,没法从 Mirror酱 下载。",p.repo!==void 0?"也可以从 GitHub 安装,填了 CDK 后它的更新会走 Mirror酱。":""]})}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:p.repo===void 0?"":`GitHub:${p.repo}`}),s.jsx("span",{className:"spacer"}),p.repo!==void 0&&s.jsx("button",{className:"small-button",disabled:y,onClick:()=>o(p.repo),children:"从 GitHub 安装"}),s.jsxs("button",{className:"primary",onClick:()=>void D(),disabled:y||g===!1,children:["安装 ",p.version]})]})]}),k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:k})]})]})}function jB(e,t){const[n,r]=b.useState({loading:!0});return b.useEffect(()=>{let i=!0;r(c=>({...c,loading:!0}));const o=setTimeout(()=>{e.connection.call("scripts/mirrorchyan/search",{query:t.trim()}).then(c=>{i&&r({items:c.items,from:c.from,loading:!1})}).catch(c=>{i&&r({error:Pe(c),loading:!1})})},t.trim()===""?0:250);return()=>{i=!1,clearTimeout(o)}},[e,t]),n}function SB({results:e,selected:t,disabled:n,limit:r=8,onPick:i,pickLabel:o="选择"}){const[c,u]=b.useState(!1);if(e.error!==void 0)return s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:e.error})]});const d=e.items??[];if(d.length===0)return s.jsx("div",{className:"muted small mirror-empty",children:e.loading?"查找中…":"没有找到。可以换个说法(游戏简称、英文名),或直接输入资源 id。"});const f=c?d:d.slice(0,r);return s.jsxs(s.Fragment,{children:[e.from==="builtin"&&s.jsx("div",{className:"muted small mirror-empty",children:"读不到 Mirror酱 的项目列表,下面是已知的几个;也可以直接输入资源 id 查询。"}),s.jsx("ul",{className:"mirror-results",children:f.map(p=>s.jsxs("li",{className:p.rid===t?"active":"",children:[s.jsxs("div",{className:"mirror-result-main",children:[s.jsxs("span",{className:"mirror-result-name",children:[p.name,s.jsx("span",{className:"chip subtle",children:p.rid}),p.installed&&s.jsx("span",{className:"badge ok",children:"已在脚本库"})]}),p.description!==""&&s.jsx("span",{className:"muted small",children:p.description})]}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>i(p.rid),children:o})]},p.rid))}),!c&&d.length>r&&s.jsxs("button",{className:"link-button small",onClick:()=>u(!0),children:["还有 ",d.length-r," 个"]})]})}const Cb=["resolving","downloading","verifying","extracting","checking","done"];function cS({client:e,repo:t,tag:n,asset:r,size:i,job:o,onDone:c,openSession:u,onRetry:d,onClose:f}){const p=(o==null?void 0:o.phase)??"queued",m=p==="done"?o==null?void 0:o.setup:void 0,g=o===void 0||o.endedAt===void 0,v=_B(o==null?void 0:o.received),y=(o==null?void 0:o.total)??i,S=y!==void 0&&y>0&&(o==null?void 0:o.received)!==void 0?Math.min(1,o.received/y):void 0,k=b.useRef(-1),w=Cb.indexOf(p);w>k.current&&(k.current=w);const T=m!==void 0?"交给 agent 安装":p==="done"?"安装完成":p==="failed"?"安装失败":p==="cancelled"?"已取消安装":"正在安装",N=$=>p==="done"||$<k.current?"done":$===k.current?g?"active":"stopped":"todo";return s.jsxs("section",{className:"card panel-card install-progress","aria-live":"polite",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:T}),s.jsxs("p",{className:"muted small",children:[t," · ",n]})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",title:g?"关掉面板,安装在后台继续(左边列表里能看到进度)":"关闭",onClick:f,children:s.jsx(ee,{name:"close"})})]}),s.jsxs("div",{className:"install-file",children:[s.jsx(ee,{name:"package"}),s.jsx("span",{className:"asset-name",children:r}),i!==void 0&&s.jsx("span",{className:"muted small",children:va(i)})]}),s.jsx("ol",{className:"install-steps",children:Cb.slice(0,-1).map(($,D)=>{const O=N(D);return s.jsxs("li",{className:`install-step ${O}`,children:[s.jsx("span",{className:"install-step-mark",children:O==="done"?s.jsx(ee,{name:"check"}):O==="stopped"?s.jsx(ee,{name:"close"}):D+1}),s.jsx("span",{children:Wu[$]})]},$)})}),g&&s.jsxs("div",{className:"install-bar",children:[s.jsx("div",{className:`progress ${p==="downloading"&&S!==void 0?"":"indeterminate"}`,"aria-hidden":"true",children:s.jsx("span",{style:p==="downloading"&&S!==void 0?{width:`${(S*100).toFixed(1)}%`}:void 0})}),s.jsxs("div",{className:"install-numbers muted small",children:[s.jsx("span",{children:o===void 0?"等待开始…":o.message??Wu[p]}),p==="downloading"&&(o==null?void 0:o.received)!==void 0&&s.jsxs("span",{className:"install-bytes",children:[va(o.received),y!==void 0?` / ${va(y)}`:"",S!==void 0?` · ${Math.floor(S*100)}%`:"",v!==void 0?` · ${va(Math.round(v))}/s`:"",v!==void 0&&v>0&&y!==void 0?` · 还要 ${EB((y-o.received)/v)}`:""]})]})]}),(o==null?void 0:o.error)!==void 0&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:o.error})]}),m!==void 0&&s.jsxs("div",{className:"notice left",children:[s.jsx(ee,{name:"info"}),s.jsxs("span",{children:[o==null?void 0:o.message,"。它也在左边「等待安装」里:没配好模型时可以在那里自己安装。装好后脚本会出现在列表里。"]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:g?"可以关掉这个面板,安装会在后台继续。":m!==void 0?`下载好了 ${(o==null?void 0:o.version)??n} 的安装程序。`:p==="done"?`已安装 ${(o==null?void 0:o.version)??n}。`:""}),s.jsx("span",{className:"spacer"}),g&&o!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:o.id}).catch(()=>{}),children:"取消安装"}),(p==="failed"||p==="cancelled")&&s.jsx("button",{className:"small-button",onClick:d,children:"重新选择"}),(m==null?void 0:m.sessionId)!==void 0&&s.jsx("button",{className:"primary small-button",onClick:()=>u(m.sessionId),children:"查看对话"}),p==="done"&&m===void 0&&s.jsx("button",{className:"primary small-button",onClick:c,children:"查看脚本"})]})]})}function _B(e){const t=b.useRef([]),[n,r]=b.useState(void 0);return b.useEffect(()=>{if(e===void 0)return;const i=Date.now(),o=[...t.current.filter(u=>i-u.at<=4e3&&u.bytes<=e),{at:i,bytes:e}];t.current=o;const c=o[0];i-c.at>=500&&r((e-c.bytes)/((i-c.at)/1e3))},[e]),n}function EB(e){return!Number.isFinite(e)||e<0?"—":e<60?`${Math.max(1,Math.round(e))} 秒`:`${Math.floor(e/60)} 分 ${Math.round(e%60)} 秒`}function CB({client:e,onImported:t,onClose:n}){const[r,i]=b.useState(""),[o,c]=b.useState(""),[u,d]=b.useState(!1),[f,p]=b.useState(null),m=async()=>{d(!0),p(null);try{const g=await e.connection.call("scripts/import",{path:r.trim().replace(/^"|"$/g,""),...o.trim()===""?{}:{name:o.trim()}});t(g.id)}catch(g){p(Pe(g)),d(!1)}};return s.jsxs("section",{className:"card panel-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"导入本地项目"}),s.jsx("p",{className:"muted small",children:"登记电脑上已有的脚本目录,原地使用:不移动、不复制、不修改,移除时也不会删除。"})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:n,children:s.jsx(ee,{name:"close"})})]}),s.jsxs("form",{className:"import-form",onSubmit:g=>{g.preventDefault(),m()},children:[s.jsx("label",{className:"field-label",htmlFor:"import-path",children:"目录路径"}),s.jsx("input",{id:"import-path",className:"text-input plain",value:r,onChange:g=>i(g.target.value),placeholder:"例如 D:\\Games\\MAA",spellCheck:!1,disabled:u}),s.jsx("label",{className:"field-label",htmlFor:"import-name",children:"显示名称(可选)"}),s.jsx("input",{id:"import-name",className:"text-input plain",value:o,onChange:g=>c(g.target.value),placeholder:"留空则按脚本包或目录名",disabled:u}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:"会按内置脚本包自动识别是哪个脚本。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary",type:"submit",disabled:u||r.trim()==="",children:u?"导入中…":"导入"})]})]}),f!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:f})]})]})}function fm({client:e,job:t,compact:n=!1}){const r=t.endedAt===void 0,i=t.total!==void 0&&t.total>0&&t.received!==void 0?Math.min(1,t.received/t.total):void 0,o=t.kind==="env-fix"?"修复环境":t.kind==="update"?"更新":"安装";return s.jsxs("div",{className:`job ${t.phase}${n?" compact":""}`,role:"status",children:[s.jsxs("div",{className:"job-line",children:[s.jsxs("span",{className:"job-phase",children:[o," · ",t.setup!==void 0&&t.phase==="done"?"已交给 agent 安装":Wu[t.phase],t.version!==void 0&&t.phase==="done"?` ${t.version}`:""]}),i!==void 0&&r&&s.jsxs("span",{className:"job-bytes",children:[va(t.received??0)," / ",va(t.total??0)]}),r&&s.jsx("button",{className:"link-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:t.id}).catch(()=>{}),children:"取消"})]}),r&&s.jsx("div",{className:`progress ${i===void 0?"indeterminate":""}`,"aria-hidden":"true",children:s.jsx("span",{style:i===void 0?void 0:{width:`${(i*100).toFixed(1)}%`}})}),!n&&t.message!==void 0&&(r||t.setup!==void 0)&&s.jsx("div",{className:"job-message muted small",children:t.message}),t.error!==void 0&&s.jsx("div",{className:"job-error small",children:t.error})]})}const IB={install:"安装来源",pack:"脚本包",known:"已知项目",user:"你设置的"};function uS({client:e,script:t,disabled:n,act:r}){const[i,o]=b.useState(null),[c,u]=b.useState(""),[d,f]=b.useState(null),p=t.channels.github,m=t.channels.mirrorchyan,g=(k,w)=>r("channel",async()=>{await e.connection.call("scripts/source/set",w==="reset"?{id:t.id,reset:[k]}:k==="repo"?{id:t.id,repo:w}:{id:t.id,mirrorchyan:w}),o(null);const T=k==="repo"?"GitHub":"Mirror酱";return w===null?`已不再从 ${T} 更新`:w==="reset"?`${T} 更新渠道已恢复自动`:`${T} 更新渠道已设为 ${w}`}),v=()=>r("mirror-match",async()=>{const k=await e.connection.call("scripts/mirrorchyan/match",{id:t.id});return f({items:k.items,checked:!0}),k.items.length===0?`Mirror酱 上没有找到它${k.from==="builtin"?"(读不到 Mirror酱 的项目列表,只查了已知的)":""};知道资源 id 的话可以直接「设置」`:void 0}),y=(k,w)=>k==="repo"?/^[\w.-]+\/[\w.-]+$/.test(w):/^[\w.-]{1,100}$/.test(w),S=(k,w,T,N,$)=>s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:w}),s.jsx("dd",{children:i!==k?s.jsxs(s.Fragment,{children:[T!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:T.text}),s.jsxs("span",{className:"muted small",children:["(",IB[T.from],")"]})]}):s.jsx("span",{className:"muted small",children:N}),(T==null?void 0:T.from)!=="install"&&s.jsx("button",{className:"ghost small-button",disabled:n,onClick:()=>{u((T==null?void 0:T.text)??""),o(k)},children:T===void 0?"设置":"修改"}),k==="mirrorchyan"&&T===void 0&&s.jsx("button",{className:"ghost small-button",disabled:n,onClick:()=>void v(),children:"查询是否接入"})]}):s.jsxs("span",{className:"local-source-edit",children:[s.jsx("input",{className:"text-input plain","aria-label":`${w}更新渠道`,value:c,onChange:D=>u(D.target.value),placeholder:$,spellCheck:!1,autoFocus:!0}),s.jsx("button",{className:"primary small-button",disabled:n||!y(k,c.trim()),onClick:()=>void g(k,c.trim()),children:k==="mirrorchyan"?"查询并保存":"保存"}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void g(k,"reset"),children:"恢复自动"}),T!==void 0&&s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void g(k,null),children:"不用"}),s.jsx("button",{className:"ghost small-button",onClick:()=>o(null),children:"取消"})]})})]});return s.jsxs(s.Fragment,{children:[S("repo","GitHub",p===void 0?void 0:{text:p.repo,from:p.from},"未设置:填写它的 GitHub 仓库","owner/repo,例如 babalae/better-genshin-impact"),S("mirrorchyan","Mirror酱",m===void 0?void 0:{text:m.rid,from:m.from},"未设置:在 Mirror酱 发布的脚本填它的资源 id","资源 id,例如 BGI、MAA"),m===void 0&&d!==null&&d.items.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{}),s.jsxs("dd",{className:"mirror-matches",children:[s.jsx("span",{className:"muted small",children:"Mirror酱 上可能是它:"}),d.items.slice(0,5).map(k=>s.jsxs("span",{className:"mirror-match",children:[s.jsx("span",{children:k.name}),s.jsx("span",{className:"chip subtle",children:k.rid}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void g("mirrorchyan",k.rid).then(()=>f(null)),children:"用这个"})]},k.rid))]})]})]})}function AB({client:e,script:t,disabled:n,busy:r,now:i,act:o}){const[c,u]=b.useState(!1),d=t.localVersion,f=t.update,p=t.channels.github!==void 0||t.channels.mirrorchyan!==void 0;return s.jsxs("div",{className:"local-update",children:[s.jsxs("dl",{className:"local-facts",children:[s.jsx("dt",{children:"当前版本"}),s.jsx("dd",{children:d!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"version-name",children:d.version}),s.jsx("span",{className:"muted small",children:d.from==="更新"?"(由 MultiGameAssistant 更新)":`(读自 ${d.from})`})]}):s.jsx("span",{className:"muted small",children:"认不出这个目录的版本:检查更新时会当作可以更新"})}),s.jsx(uS,{client:e,script:t,disabled:n,act:o})]}),c?s.jsxs("div",{className:"local-confirm",children:[s.jsxs("p",{className:"small",children:["将在 ",s.jsx("code",{children:t.dir})," 里更新到 ",f==null?void 0:f.latest,":被替换的程序文件先备份到工具目录(可以撤销),已有的配置文件不动。请先关闭这个脚本。"]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>u(!1),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:n,onClick:()=>void o("update",async()=>(u(!1),(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0)),children:"确认更新"})]})]}):s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[f===void 0?"还没有检查过更新":f.available?`有新版本 ${f.latest}`:`已是最新(${f.latest})`,f!==void 0&&` · ${$t(f.checkedAt,i)}检查`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:n||!p,onClick:()=>void o("check",async()=>{const m=await e.connection.call("scripts/checkUpdate",{id:t.id});return m.available?`发现新版本 ${m.latest}${m.current===void 0?"(认不出当前版本)":`,当前 ${m.current}`}`:"已是最新版本"}),children:r==="check"?"检查中…":"检查更新"}),s.jsx("button",{className:"primary small-button",disabled:n||(f==null?void 0:f.available)!==!0,onClick:()=>u(!0),children:"更新"})]}),t.undo!==void 0&&s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:["上次更新:",t.undo.from??"(未知版本)"," → ",t.undo.to," · ",$t(t.undo.at,i)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void o("restore",async()=>{const m=await e.connection.call("scripts/restore",{id:t.id});return`已撤销,换回了更新前的文件${m.localVersion===void 0?"":`(${m.localVersion.version})`}`}),children:r==="restore"?"撤销中…":"撤销上次更新"})]})]})}function TB({client:e,script:t,openSession:n}){var O,F,U;const r=Ee(e.connection.status),i=Ee(e.capabilities),o=Cn(6e4),[c,u]=b.useState([]),[d,f]=b.useState(0),[p,m]=b.useState(!1),[g,v]=b.useState(null),[y,S]=b.useState(null);b.useEffect(()=>e.connection.on("packs/changed",()=>f(M=>M+1)),[e]),b.useEffect(()=>{if(r.state!=="open"||!i.has("packs"))return;let M=!0;return e.connection.call("packs/drafts",{scriptId:t.id}).then(P=>{M&&u(P.items)}).catch(()=>{}),()=>{M=!1}},[e,t.id,r.state,i,d]);const k=async M=>{m(!0),v(null);try{await M()}catch(P){v(Pe(P))}finally{m(!1)}},w=()=>k(async()=>{const{sessionId:M}=await e.connection.call("sessions/create",{focus:{scripts:[t.id]}});await e.connection.call("session/prompt",{sessionId:M,requestId:`analyze-${Date.now()}`,mode:"queue",text:`请按 script-analysis 技能分析脚本库里的「${t.name}」(id: ${t.id}),${t.packId===void 0?"为它生成":"检查并改进它的"}脚本包:先找到并读完这个项目自己的文档(目录里的说明、仓库 README、Wiki、文档站),再结合代码核对补全,实在没有文档才直接看代码。用 pack_propose 提交草稿,docs 里写明依据的文档。`}),n(M)}),T=M=>k(async()=>{const{sessionId:P}=await e.connection.call("scripts/packReview",{id:t.id,decision:M});P!==void 0&&n(P)}),N=M=>k(async()=>{const{sessionId:P}=await e.connection.call("scripts/optimize",{id:t.id,decision:M});P!==void 0&&n(P)}),$=c[0],D=(O=t.optimize)==null?void 0:O.due;return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"脚本包"}),s.jsx("p",{className:"muted small",children:t.packId===void 0?"还没有脚本包:agent 还不知道怎么运行它。":`使用脚本包 ${t.packId}。`})]}),s.jsxs("span",{className:"key-actions",children:[t.packId!==void 0&&s.jsxs("button",{className:"small-button",disabled:p||r.state!=="open",onClick:()=>void N("run"),title:"用运行攒下的信息:重新总结脚本包、调「多久没动静算卡住」、把走通的步骤存成只给它用的技能",children:[s.jsx(ee,{name:"sparkles"}),"优化脚本"]}),s.jsxs("button",{className:"small-button",disabled:p||r.state!=="open",onClick:()=>void w(),children:[s.jsx(ee,{name:"sparkles"}),t.packId===void 0?"让 agent 分析":"让 agent 改进"]})]})]}),t.packReview!==void 0&&$===void 0&&s.jsxs("div",{className:"notice left pack-review",children:[s.jsx(ee,{name:"refresh"}),s.jsxs("span",{children:[t.name," 从 ",t.packReview.from??"旧版本"," 更新到了 ",t.packReview.to,",脚本包是按旧版本写的。要让 agent 先读这次的更新日志,再检查脚本包要不要改吗?"]}),s.jsxs("span",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:p,onClick:()=>void T("keep"),children:"不用改"}),s.jsx("button",{className:"primary small-button",disabled:p||r.state!=="open",onClick:()=>void T("check"),children:"让 agent 检查"})]})]}),D!==void 0&&t.packReview===void 0&&$===void 0&&s.jsxs("div",{className:"notice left pack-review",children:[s.jsx(ee,{name:"sparkles"}),s.jsxs("span",{children:[D==="updated"?`${t.name} 更新后已经跑通了。`:`${t.name} ${((F=t.optimize)==null?void 0:F.at)===void 0?"装好以来":"上次优化以来"}已经跑成功 ${((U=t.optimize)==null?void 0:U.runs)??0} 次。`,"要让 agent 用这些运行记录优化它吗:重新总结脚本包、调卡住时间、把走通的步骤存成技能。"]}),s.jsxs("span",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:p,onClick:()=>void N("keep"),children:"这次不用"}),s.jsx("button",{className:"primary small-button",disabled:p||r.state!=="open",onClick:()=>void N("run"),children:"优化脚本"})]})]}),$!==void 0&&s.jsxs("div",{className:"draft",children:[s.jsxs("div",{className:"draft-head",children:[s.jsx("span",{className:"badge warn",children:"待确认的草稿"}),s.jsxs("span",{className:"muted small",children:[$t($.proposedAt,o),"提交 · 任务:",$.tasks.map(M=>M.title).join("、")||"无"]})]}),s.jsx("p",{className:"draft-summary",children:$.summary}),$.docs!==void 0&&$.docs.length>0&&s.jsxs("details",{className:"draft-docs",children:[s.jsxs("summary",{className:"muted small",children:["依据的文档(",$.docs.length,")"]}),s.jsx("ul",{children:$.docs.map(M=>s.jsxs("li",{children:[s.jsx("code",{children:M.source}),":",M.used]},M.source))})]}),$.noDocs!==void 0&&s.jsxs("p",{className:"muted small",children:["没有找到项目文档,按代码分析:",$.noDocs]}),$.current!==void 0&&s.jsxs("p",{className:"muted small",children:["接受后会替换当前的",$.current.builtin?"内置":"","脚本包(之前的版本会保留在历史里)。"]}),s.jsxs("div",{className:"segmented draft-tabs",children:[s.jsxs("label",{className:y==="manifest"?"active":"",children:[s.jsx("input",{type:"checkbox",checked:y==="manifest",onChange:()=>S(M=>M==="manifest"?null:"manifest")}),"adg.script.yaml"]}),s.jsxs("label",{className:y==="skill"?"active":"",children:[s.jsx("input",{type:"checkbox",checked:y==="skill",onChange:()=>S(M=>M==="skill"?null:"skill")}),"SKILL.md"]})]}),y!==null&&s.jsx("pre",{className:"draft-text",children:y==="manifest"?$.manifest:$.skill}),s.jsxs("div",{className:"key-actions",children:[$.sessionId!==void 0&&s.jsx("button",{className:"link-button",onClick:()=>n($.sessionId),children:"查看分析过程"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:p,onClick:()=>void k(()=>e.connection.call("packs/reject",{packId:$.packId})),children:"拒绝"}),s.jsx("button",{className:"primary small-button",disabled:p,onClick:()=>void k(()=>e.connection.call("packs/accept",{packId:$.packId})),children:"接受并使用"})]})]}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:g})]})]})}function MB({client:e,script:t}){const n=Ee(e.connection.status),r=Cn(15e3),[i,o]=b.useState(void 0),[c,u]=b.useState(0),[d,f]=b.useState(30),[p,m]=b.useState(null);b.useEffect(()=>e.connection.on("guard/changed",()=>u(y=>y+1)),[e]),b.useEffect(()=>{if(n.state!=="open")return;let y=!0;return e.connection.call("guard/grants",{}).then(S=>{y&&o(S.items.find(k=>k.scriptId===t.id))}).catch(()=>{}),()=>{y=!1}},[e,t.id,n.state,c]);const g=i!==void 0&&i.expiresAt>r?i:void 0,v=y=>{m(null),y().catch(S=>m(Pe(S)))};return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"修改脚本文件"}),s.jsx("p",{className:"muted small",children:"默认禁止:agent 只能改脚本包声明的配置文件、只能用官方更新。确实需要改代码时,在这里临时允许。"})]}),g===void 0?s.jsx("span",{className:"badge ok",children:"受保护"}):s.jsx("span",{className:"badge warn",children:"已允许"})]}),g===void 0?s.jsxs("div",{className:"key-actions",children:[s.jsxs("label",{className:"check-label",children:["允许 agent 修改",s.jsx(yn,{inline:!0,"aria-label":"允许多久",value:String(d),onChange:y=>f(Number(y)),options:[15,30,60,120].map(y=>({value:String(y),label:`${y} 分钟`}))})]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>v(()=>e.connection.call("guard/grant",{scriptId:t.id,minutes:d})),children:"临时允许"})]}):s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:["还剩约 ",Math.max(1,Math.round((g.expiresAt-r)/6e4))," 分钟"]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>v(()=>e.connection.call("guard/revoke",{scriptId:t.id})),children:"立即收回"})]}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:p})]})]})}function $B({client:e,script:t}){const n=Ee(e.connection.status),r=Cn(6e4),i=lN(e,t.id),[o,c]=b.useState(void 0),[u,d]=b.useState(null),[f,p]=b.useState(0),[m,g]=b.useState(null),[v,y]=b.useState(null),[S,k]=b.useState(null),[w,T]=b.useState(!1),[N,$]=b.useState(null),[D,O]=b.useState(null),[F,U]=b.useState(null),M=(i==null?void 0:i.items.find(L=>L.id===o))??(i==null?void 0:i.items.find(L=>L.id===i.current));b.useEffect(()=>{g(null),k(null)},[M==null?void 0:M.id]),b.useEffect(()=>e.connection.on("runs/state",L=>{L.scriptId!==t.id||L.endedAt===void 0||(p(W=>W+1),U(W=>W===null||W.runId!==L.id?W:($(L.state==="succeeded"?`修改已同步到「${W.profile}」`:L.state==="cancelled"?"已放弃这次修改,本地配置没变":`没能保存修改:${L.outcome??"脚本窗口异常退出"}`),null)))}),[e,t.id]);const P=async L=>{if(F!==null){U({...F,finishing:L});try{L==="done"?await e.connection.call("configs/done",{runId:F.runId}):await e.connection.call("runs/stop",{runId:F.runId})}catch(W){O(Pe(W)),U(null)}}};b.useEffect(()=>{if(n.state!=="open"||M===void 0)return;let L=!0;return e.connection.call("configs/status",{scriptId:t.id,profile:M.id}).then(W=>{L&&(d(W),O(null))}).catch(W=>{L&&O(Pe(W))}),()=>{L=!1}},[e,t.id,t.packId,n.state,f,M==null?void 0:M.id]);const R=async L=>{T(!0),O(null),$(null);try{const W=await L();typeof W=="string"&&$(W),p(H=>H+1)}catch(W){O(Pe(W))}finally{T(!1)}},Z=((i==null?void 0:i.items.length)??0)>1,E=M!==void 0&&M.id===(i==null?void 0:i.current),C=(u==null?void 0:u.files.filter(L=>L.local))??[],I=u!==null&&u.profile.id===(M==null?void 0:M.id)?u:null;return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"配置"}),s.jsx("p",{className:"muted small",children:"通过本应用运行时,用的是本地保存的配置;原项目里的配置不会被改动,你自己打开脚本时仍是它原来的设置。可以存几份(比如两个账号),运行和编排时选用哪一份。"})]}),s.jsxs("button",{className:"small-button",disabled:w||F!==null||n.state!=="open"||M===void 0,onClick:()=>void R(async()=>{const L=await e.connection.call("configs/open",{scriptId:t.id,profile:M.id});if(L.endedAt===void 0)U({runId:L.id,profile:M.name,finishing:null});else if(L.state!=="succeeded")throw new Error(L.outcome??"没能打开脚本的设置界面")}),children:[s.jsx(ee,{name:"settings"}),"打开脚本修改设置"]})]}),i!==null&&(Z||((u==null?void 0:u.files.length)??0)>0)&&s.jsxs("div",{className:"profile-bar",children:[s.jsxs("div",{className:"profile-chips",role:"tablist","aria-label":"配置",children:[i.items.map(L=>s.jsxs("button",{role:"tab","aria-selected":L.id===(M==null?void 0:M.id),className:`profile-chip ${L.id===(M==null?void 0:M.id)?"active":""}`,onClick:()=>c(L.id),children:[L.name,L.id===i.current&&Z&&s.jsx("span",{className:"profile-current",title:"不指定配置的运行都用它",children:"当前使用"})]},L.id)),s.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>y(L=>L===null?{name:"",source:"copy",dir:""}:null),children:"+ 另存一份"})]}),M!==void 0&&Z&&S===null&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:E?"运行时没有指定配置就用这一份":"在编排或运行时选它才会用到"}),s.jsx("span",{className:"spacer"}),!E&&s.jsx("button",{className:"small-button",disabled:w,onClick:()=>void R(async()=>(await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:M.id,current:!0}),`现在默认使用「${M.name}」`)),children:"设为当前使用"}),s.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>k(M.name),children:"改名"}),M.id!=="default"&&(m==="remove"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"muted small",children:"用了这份配置的编排步骤会运行失败"}),s.jsx("button",{className:"small-button",onClick:()=>g(null),children:"取消"}),s.jsx("button",{className:"danger-outline small-button",disabled:w,onClick:()=>void R(async()=>(await e.connection.call("configs/profiles/remove",{scriptId:t.id,profile:M.id}),g(null),c(void 0),`已删除「${M.name}」`)),children:"确认删除"})]}):s.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>g("remove"),children:"删除"}))]}),M!==void 0&&S!==null&&s.jsxs("div",{className:"key-input",children:[s.jsx("input",{className:"text-input plain","aria-label":"新名字",value:S,maxLength:30,autoFocus:!0,onChange:L=>k(L.target.value)}),s.jsx("button",{className:"small-button",onClick:()=>k(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:w||S.trim()==="",onClick:()=>void R(async()=>{await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:M.id,name:S.trim()}),k(null)}),children:"保存"})]}),v!==null&&M!==void 0&&s.jsxs("div",{className:"profile-save",children:[s.jsx("label",{className:"field-label",htmlFor:"profile-name",children:"新配置的名字"}),s.jsx("input",{id:"profile-name",className:"text-input plain",placeholder:"例如:小号、只清体力",value:v.name,maxLength:30,autoFocus:!0,onChange:L=>y({...v,name:L.target.value})}),s.jsxs("fieldset",{className:"asset-list",disabled:w,children:[s.jsx("legend",{className:"field-label",children:"内容从哪里来"}),[["copy",`复制「${M.name}」`,"复制后可以「打开脚本修改设置」单独改它"],["original","读取原项目现在的配置","在脚本自己的界面里设好了另一套设置时用"],["folder","从别的文件夹读取",`另一份同样的脚本,或存下来的配置;只读 ${(u==null?void 0:u.files.map(L=>L.file).join("、"))||"脚本包声明的配置文件"}`]].map(([L,W,H])=>s.jsxs("label",{className:`asset-option choice-option ${v.source===L?"active":""}`,children:[s.jsx("input",{type:"radio",name:"profile-source",value:L,checked:v.source===L,onChange:()=>y({...v,source:L})}),s.jsxs("span",{className:"choice-text",children:[s.jsx("span",{children:W}),s.jsx("span",{className:"muted small",children:H})]})]},L))]}),v.source==="folder"&&s.jsx("input",{className:"text-input plain","aria-label":"文件夹",placeholder:"文件夹的完整路径,例如 D:\\MAA2",value:v.dir,onChange:L=>y({...v,dir:L.target.value})}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>y(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:w||v.name.trim()===""||v.source==="folder"&&v.dir.trim()==="",onClick:()=>void R(async()=>{const L=v.source==="copy"?{kind:"copy",profile:M.id}:v.source==="original"?{kind:"original"}:{kind:"folder",dir:v.dir.trim()},W=await e.connection.call("configs/profiles/create",{scriptId:t.id,name:v.name.trim(),from:L});return y(null),c(W.profile.id),`已保存「${W.profile.name}」:${W.files.length>0?W.files.join("、"):"还没有配置文件"}`}),children:"保存"})]})]})]}),I!==null&&s.jsxs(s.Fragment,{children:[I.drift.length>0&&s.jsxs("div",{className:"notice warn-box left",children:[s.jsx(ee,{name:"info"}),s.jsxs("span",{children:["原项目的配置在导入后改过(",I.drift.join("、"),"),可能是在脚本自己的界面里改的。本应用仍按「",I.profile.name,"」运行;需要的话可以导入。"]})]}),s.jsx(Na,{id:`config.files.${t.id}`,title:"配置文件",count:I.files.length,children:s.jsxs("ul",{className:"version-list",children:[I.files.map(L=>s.jsx(RB,{client:e,scriptId:t.id,profile:I.profile.id,file:L},`${I.profile.id}:${L.file}`)),I.files.length===0&&s.jsx("li",{className:"muted small",children:"脚本包没有声明配置文件"})]})}),s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[I.importedAt===void 0?"还没有导入":`${$t(I.importedAt,r)}${Z?`存的「${I.profile.name}」`:"从原项目导入"}`,C.length>0&&" · ",C.length>0&&s.jsx("button",{className:"link-button",onClick:()=>{var L;return void((L=navigator.clipboard)==null?void 0:L.writeText(I.dir))},children:"复制本地配置目录"})]}),s.jsx("span",{className:"spacer"}),m!=="import"?s.jsx("button",{className:"small-button",disabled:w,onClick:()=>g("import"),children:"导入原项目设置"}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted small",children:["会用原项目当前的配置覆盖「",I.profile.name,"」"]}),s.jsx("button",{className:"small-button",onClick:()=>g(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:w,onClick:()=>void R(async()=>{const L=await e.connection.call("configs/import",{scriptId:t.id,profile:I.profile.id});return g(null),L.imported.length>0?`已导入到「${I.profile.name}」:${L.imported.join("、")}`:"原项目里还没有这些配置文件"}),children:"确认导入"})]})]})]}),N!==null&&s.jsx("div",{className:"notice info left small",children:N}),F!==null&&s.jsx("div",{className:"dialog-backdrop",children:s.jsxs("div",{className:"dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"config-edit-title",children:[s.jsxs("h3",{id:"config-edit-title",children:[s.jsx(ee,{name:"settings"}),"正在用脚本自己的界面修改设置"]}),s.jsxs("p",{children:[t.name," 的设置窗口已经打开,用的是本地配置「",F.profile,"」。在那个窗口里改好、保存后,回到这里点「我已手动改好」:脚本窗口会关闭,修改同步到「",F.profile,"」,之后的运行和编排都用它。"]}),s.jsx("p",{className:"muted small",children:"直接关掉脚本窗口也会保存。原项目里的配置不会被改动。"}),F.finishing!==null&&s.jsxs("p",{className:"dialog-progress",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),F.finishing==="done"?"正在关闭脚本窗口并保存修改…":"正在关闭脚本窗口,不保存…"]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:F.finishing!==null,onClick:()=>void P("discard"),children:"放弃修改"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:F.finishing!==null,onClick:()=>void P("done"),children:F.finishing==="done"?"保存中…":"我已手动改好"})]})]})}),D!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:D})]})]})}function RB({client:e,scriptId:t,profile:n,file:r}){const[i,o]=b.useState(!1),[c,u]=b.useState(null),[d,f]=b.useState(null),p=()=>{o(m=>!m),!(c!==null||!r.local)&&e.connection.call("configs/read",{scriptId:t,file:r.file,profile:n}).then(u,m=>f(Pe(m)))};return s.jsxs("li",{className:`config-file ${i?"open":""}`,children:[s.jsxs("button",{type:"button",className:"config-file-head","aria-expanded":i,onClick:p,disabled:!r.local,title:r.local?"展开看本地配置的内容":"本地还没有这个文件",children:[s.jsx(ee,{name:"chevron",className:`fold-chevron ${i?"open":""}`}),s.jsx("span",{className:"version-name",children:r.file}),r.local?s.jsx("span",{className:"badge ok",children:"本地已保存"}):s.jsx("span",{className:"badge",children:"本地没有"}),r.changed&&s.jsx("span",{className:"badge warn",children:"原项目已改动"}),!r.original&&s.jsx("span",{className:"muted small",children:"原项目里没有"})]}),i&&(d!==null?s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:d})]}):c===null?s.jsx("div",{className:"muted small",children:"读取中…"}):s.jsxs("pre",{className:"config-preview",children:[c.content,c.truncated?`
|
|
225
|
-
…(太长,只显示前一部分)`:""]}))]})}function OB({client:e,scriptId:t,scriptName:n,openSession:r}){const i=Ee(e.connection.status),[o,c]=b.useState(null),[u,d]=b.useState(""),[f,p]=b.useState(""),[m,g]=b.useState(""),[v,y]=b.useState(!1),[S,k]=b.useState(null),[w,T]=b.useState(!1),[N,$]=b.useState(null),[D,O]=b.useState(!1);b.useEffect(()=>{if(i.state!=="open")return;let I=!0;return e.connection.call("configs/launch",{scriptId:t}).then(L=>{I&&(c(L),d(L.settings.pcExe??""),p(L.settings.pcProcess??""),g(L.settings.androidPackage??""))}).catch(L=>{I&&k(Pe(L))}),()=>{I=!1}},[e,t,i.state]);const F=async I=>{y(!0),k(null),T(!1);try{c(await e.connection.call("configs/launch/set",{scriptId:t,...I})),T(!0)}catch(L){k(Pe(L))}finally{y(!1)}},U=async I=>{d(I),await F({pcExe:I})},M=async()=>{O(!0),k(null),T(!1),$(null);try{const I=await e.connection.call("configs/launch/locate",{scriptId:t});$(I),I.candidates.length===1&&await U(I.candidates[0].path)}catch(I){k(Pe(I))}finally{O(!1)}},P=async()=>{k(null);try{const{sessionId:I}=await e.connection.call("sessions/create",{focus:{scripts:[t]}});await e.connection.call("session/prompt",{sessionId:I,requestId:`locate-${Date.now()}`,mode:"queue",text:`帮我找到「${n}」(脚本 id: ${t})要玩的 PC 游戏${(o==null?void 0:o.game.name)===void 0?"":`「${o.game.name}」`}装在哪里:先用 game_locate;没找到就在各个磁盘上搜索名为 ${(N==null?void 0:N.exe)??(o==null?void 0:o.game.pcProcess)??"游戏进程名"} 的程序(可以问我装在哪个盘)。找到后告诉我路径和你怎么确认的,再用 game_path_set 保存。`}),r(I)}catch(I){k(Pe(I))}},R=async()=>{const I=kr();if(I===void 0)return;const L=await I.pickFile({title:"选择游戏程序",defaultPath:u.trim()===""?void 0:u.trim(),filterName:"程序",extensions:["exe"]});L!==null&&await U(L)};if(o===null)return S===null?null:s.jsx("section",{className:"card",children:s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:S})]})});const{settings:Z,game:E,uses:C}=o;return!C.adb&&!C.desktop?null:s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsxs("h3",{children:["启动游戏",E.name===void 0?"":`:${E.name}`]}),s.jsxs("p",{className:"muted small",children:["有的脚本不会自己打开游戏或模拟器。运行前,本应用会先启动模拟器(模拟器任务),再按这里的设置启动游戏;游戏已经开着、或脚本自己会启动时不会重复启动。",E.selfLaunch,"。"]})]})}),s.jsx("label",{className:"field-label",htmlFor:`launch-mode-${t}`,children:"运行前由谁启动游戏"}),s.jsx(yn,{id:`launch-mode-${t}`,value:Z.mode,disabled:v,onChange:I=>void F({mode:I}),options:[{value:"auto",label:"自动(推荐)",hint:"脚本自己不会启动游戏时,由本应用启动"},{value:"platform",label:"总是由本应用启动",hint:"游戏没开时先打开它"},{value:"off",label:"不启动",hint:"交给脚本或我自己"}]}),Z.mode!=="off"&&C.adb&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:`launch-pkg-${t}`,children:"模拟器里的游戏包名(模拟器任务)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-pkg-${t}`,className:"text-input plain",value:m,onChange:I=>g(I.target.value),placeholder:E.androidPackage??"例如 com.example.game(不填就不在模拟器里启动游戏)",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:v,onClick:()=>void F({androidPackage:m.trim()===""?null:m.trim()}),children:"保存"})]}),E.androidPackage!==void 0&&s.jsxs("p",{className:"muted small",children:["默认 ",E.androidPackage,";B 服、国际服等版本的包名不同时在这里改。"]})]}),Z.mode!=="off"&&C.desktop&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:`launch-exe-${t}`,children:"PC 游戏程序位置(占用鼠标键盘的任务)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-exe-${t}`,className:"text-input",value:u,onChange:I=>d(I.target.value),placeholder:"例如 D:\\Games\\Endfield\\Endfield.exe(也可以是游戏启动器)",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:v,onClick:()=>void F({pcExe:u.trim()===""?null:u.trim().replace(/^"|"$/g,"")}),children:"保存"})]}),s.jsxs("div",{className:"button-row",children:[s.jsx("button",{className:"small-button",disabled:v||D,onClick:()=>void M(),children:D?"正在查找…":"自动查找"}),kr()!==void 0&&s.jsx("button",{className:"small-button",disabled:v||D,onClick:()=>void R(),children:"选择文件…"}),s.jsx("button",{className:"link-button small",disabled:D,onClick:()=>void P(),children:"让 agent 找"})]}),N!==null&&N.exe===void 0&&s.jsx("p",{className:"muted small",children:"脚本包没有写游戏的进程名:先在下面填进程名,或用「选择文件…」/ 让 agent 找。"}),N!==null&&N.exe!==void 0&&N.candidates.length===0&&s.jsxs("p",{className:"muted small",children:["没找到 ",N.exe,"(查了正在运行的程序、已安装程序、开始菜单和桌面快捷方式、各盘的常见游戏目录)。可以「选择文件…」,或「让 agent 找」在整个磁盘上搜。"]}),N!==null&&N.candidates.length===1&&s.jsxs("p",{className:"muted small",children:["找到并保存了:",N.candidates[0].path,"(",N.candidates[0].source,")"]}),N!==null&&N.candidates.length>1&&s.jsxs("div",{className:"candidate-list",children:[s.jsxs("span",{className:"muted small",children:["找到 ",N.candidates.length," 个,选一个:"]}),N.candidates.map(I=>s.jsxs("button",{className:`candidate ${Z.pcExe===I.path?"chosen":""}`,disabled:v,onClick:()=>void U(I.path),children:[s.jsx("span",{className:"mono",children:I.path}),s.jsx("span",{className:"muted small",children:I.source})]},I.path))]}),s.jsx("label",{className:"field-label",htmlFor:`launch-proc-${t}`,children:"游戏进程名(判断游戏是否已经开着)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-proc-${t}`,className:"text-input",value:f,onChange:I=>p(I.target.value),placeholder:E.pcProcess??"默认是上面程序的文件名",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:v,onClick:()=>void F({pcProcess:f.trim()===""?null:f.trim()}),children:"保存"})]}),s.jsx("p",{className:"muted small",children:"填的是启动器时,进程名要填游戏本身的(在任务管理器「详细信息」里看)。"})]}),w&&s.jsx("div",{className:"muted small",children:"已保存,下次运行生效。"}),S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:S})]})]})}const zB=15*6e4;function PB({client:e,script:t,openSession:n}){const r=Cn(3e4),[i,o]=b.useState(!1),[c,u]=b.useState(null),d=t.summary,f=(d==null?void 0:d.state)==="running"&&r-d.at<zB,p=(d==null?void 0:d.state)==="failed"||d==null?void 0:d.text,m=async()=>{o(!0),u(null);try{await e.connection.call("scripts/summarize",{id:t.id})}catch(g){u(Pe(g))}finally{o(!1)}};return s.jsxs("section",{className:"card script-summary",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"简介"}),s.jsx("p",{className:"muted small",children:f?"agent 正在看它的说明和文件…":d===void 0?"让 AI 看看它的说明(README)、文件和脚本包,用几句话说清楚它是什么、能做什么。":d.state==="failed"||d.state==="running"?"上次总结没有完成":`AI 总结 · ${$t(d.at,r)}`})]}),s.jsxs("div",{className:"key-actions",children:[(d==null?void 0:d.sessionId)!==void 0&&s.jsx("button",{className:"ghost small-button",onClick:()=>n(d.sessionId),children:f?"看看进度":"查看对话"}),s.jsxs("button",{className:`${d===void 0?"primary ":""}small-button`,disabled:i||f,onClick:()=>void m(),children:[s.jsx(ee,{name:"sparkles"}),f?"总结中…":d===void 0?"让 AI 总结":"重新总结"]})]})]}),p!==void 0&&s.jsx("p",{className:`summary-text ${f?"muted":""}`,children:p}),(d==null?void 0:d.state)==="failed"&&d.text!==void 0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:d.text})]}),c!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:c})]})]})}const LB={nsis:"NSIS",inno:"Inno Setup"};function dS({client:e,setup:t,openSession:n,onImported:r}){const[i,o]=b.useState(t.dir),[c,u]=b.useState(!1),[d,f]=b.useState(null),[p,m]=b.useState(null),[g,v]=b.useState(!1),y=t.agent,S=async(k,w)=>{f(k),m(null);try{await w()}catch(T){m(Pe(T))}finally{f(null)}};return s.jsxs("section",{className:"card setup-card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsxs("h3",{children:[t.update?"更新":"安装"," ",t.name," ",t.version]}),s.jsxs("p",{className:"muted small",children:["下载到的是 ",LB[t.kind]," 安装程序,不是压缩包:要运行它把文件装好,再导入装好的文件夹。"]})]})}),(y==null?void 0:y.state)==="running"&&s.jsxs("div",{className:"notice left",children:[s.jsx(ee,{name:"info"}),s.jsx("span",{children:"agent 正在安装。也可以不等它,按下面的步骤自己装。"}),s.jsx("button",{className:"link-button",onClick:()=>n(y.sessionId),children:"查看对话"})]}),(y==null?void 0:y.state)==="failed"&&s.jsxs("div",{className:"notice warn-box left",children:[s.jsx(ee,{name:"alert"}),s.jsxs("span",{children:["agent 没能装好:",y.reason??"原因不明","。可以按下面的步骤自己装,也可以之后再交给 agent。"]}),s.jsx("button",{className:"link-button",onClick:()=>n(y.sessionId),children:"查看对话"})]}),s.jsxs("ol",{className:"setup-steps",children:[s.jsx("li",{children:s.jsxs("div",{className:"setup-step",children:[s.jsx("span",{children:"打开安装程序,按它的提示装完。安装位置已经填好,保持不变;最后不用勾选「立即运行」。"}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void S("open",async()=>{await e.connection.call("scripts/setup/open",{id:t.scriptId}),u(!0)}),children:d==="open"?"正在打开…":c?"再打开一次":"打开安装程序"})]})}),s.jsx("li",{children:s.jsxs("div",{className:"setup-step",children:[s.jsxs("span",{children:["装好后导入装好的文件夹。",t.update?"":"改了安装位置的话,填你选的文件夹。"]}),s.jsxs("form",{className:"setup-import",onSubmit:k=>{k.preventDefault(),S("import",async()=>{const w=await e.connection.call("scripts/import",{path:i.trim().replace(/^"|"$/g,""),id:t.scriptId});r(w.id)})},children:[s.jsx("input",{className:"text-input plain","aria-label":"装好的文件夹",value:i,onChange:k=>o(k.target.value),spellCheck:!1,disabled:d!==null}),s.jsx("button",{className:"primary small-button",type:"submit",disabled:d!==null||i.trim()==="",children:d==="import"?"导入中…":"装好了,导入"})]})]})})]}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:p})]}),s.jsx("div",{className:"key-actions",children:g?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"muted small",children:"删除下载好的安装程序,什么都不装。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>v(!1),children:"取消"}),s.jsx("button",{className:"danger small-button",disabled:d!==null,onClick:()=>void S("discard",async()=>{await e.connection.call("scripts/setup/discard",{id:t.scriptId})}),children:"确认删除"})]}):s.jsxs(s.Fragment,{children:[(y==null?void 0:y.state)!=="running"&&s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void S("agent",async()=>{const{sessionId:k}=await e.connection.call("scripts/setup/agent",{id:t.scriptId});n(k)}),children:d==="agent"?"正在交给 agent…":"让 agent 安装"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",disabled:d!==null,onClick:()=>v(!0),children:"不装了"})]})})]})}const DB={ok:["ok","满足"],missing:["warn","缺少"],outdated:["warn","版本过旧"],unknown:["warn","无法判断"],unsupported:["","暂不检测"]};function FB({client:e,script:t,job:n,setup:r,onRemoved:i,openSession:o}){var O;const c=Cn(6e4),[u,d]=b.useState(null),[f,p]=b.useState(null),[m,g]=b.useState(null),[v,y]=b.useState(!1),[S,k]=b.useState(!1),w=n!==void 0&&(n.endedAt===void 0||n.startedAt>=t.addedAt-1e3)?n:void 0,T=co(w),N=Ee(e.capabilities),$=t.source.kind!=="local",D=async(F,U)=>{d(F),p(null),g(null);try{const M=await U();typeof M=="string"&&g(M)}catch(M){p(Pe(M))}finally{d(null)}};return s.jsxs("div",{className:"script-detail",children:[s.jsx("header",{className:"script-detail-head",children:s.jsxs("div",{children:[s.jsx("h2",{children:t.name}),s.jsxs("div",{className:"script-meta",children:[s.jsx("span",{className:"chip",children:t.id}),t.family!==void 0&&s.jsx("span",{className:"badge",children:lw[t.family]??t.family}),t.packId!==void 0?s.jsxs("span",{className:"badge ok",children:["脚本包 ",t.packId]}):s.jsx("span",{className:"badge warn",children:"无脚本包"}),t.channels.mirrorchyan!==void 0&&s.jsxs("span",{className:"badge",title:"填了 Mirror酱 CDK 后从 Mirror酱 更新(增量)",children:["Mirror酱 ",t.channels.mirrorchyan.rid]}),s.jsx("span",{className:"muted small",children:t.source.kind==="github"?`GitHub · ${t.source.repo}`:t.source.kind==="mirrorchyan"?`Mirror酱 · ${t.source.rid}`:"本地导入"})]})]})}),w!==void 0&&s.jsx(fm,{client:e,job:w}),r!==void 0&&s.jsx(dS,{client:e,setup:r,openSession:o,onImported:()=>{}}),t.dir!==void 0&&s.jsx(PB,{client:e,script:t,openSession:o}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"位置与版本"}),s.jsx("p",{className:"muted small",children:t.dir??"(无)"})]}),t.dir!==void 0&&s.jsxs("button",{className:"ghost small-button",onClick:()=>{var F;return void((F=navigator.clipboard)==null?void 0:F.writeText(t.dir))},children:[s.jsx(ee,{name:"copy"}),"复制路径"]})]}),$?s.jsxs(s.Fragment,{children:[s.jsx("ul",{className:"version-list",children:t.versions.map(F=>{var U;return s.jsxs("li",{className:F.current?"current":"",children:[s.jsx("span",{className:"version-name",children:F.version}),F.current&&s.jsx("span",{className:"badge ok",children:"当前"}),s.jsxs("span",{className:"muted small",children:[((U=F.asset)==null?void 0:U.name)??""," · ",$t(F.installedAt,c)]}),s.jsx("span",{className:"spacer"}),!F.current&&s.jsx("button",{className:"small-button",disabled:T||u!==null,onClick:()=>void D("rollback",async()=>(await e.connection.call("scripts/rollback",{id:t.id,version:F.version}),`已切换到 ${F.version}`)),children:"切换到此版本"})]},F.version)})}),s.jsx("dl",{className:"local-facts channel-facts",children:s.jsx(uS,{client:e,script:t,disabled:T||u!==null,act:D})}),s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[t.update===void 0?"还没有检查过更新":t.update.available?`有新版本 ${t.update.latest}`:`已是最新(${t.update.latest})`,t.update!==void 0&&` · ${$t(t.update.checkedAt,c)}检查`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:T||u!==null,onClick:()=>void D("check",async()=>{const F=await e.connection.call("scripts/checkUpdate",{id:t.id});return F.available?`发现新版本 ${F.latest}`:"已是最新版本"}),children:u==="check"?"检查中…":"检查更新"}),s.jsx("button",{className:"primary small-button",disabled:T||u!==null||((O=t.update)==null?void 0:O.available)!==!0,onClick:()=>void D("update",async()=>(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0),children:"更新"})]})]}):s.jsx(AB,{client:e,script:t,disabled:T||u!==null,busy:u,now:c,act:D})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"运行环境"}),s.jsx("p",{className:"muted small",children:t.env===void 0?t.packId===void 0?"没有脚本包,暂时不知道它需要什么":"还没有检查":`${$t(t.env.checkedAt,c)}检查`})]}),s.jsx("button",{className:"small-button",disabled:T||u!==null,onClick:()=>void D("env",async()=>(await e.connection.call("scripts/envCheck",{id:t.id})).ok?"运行环境满足":"有依赖需要处理"),children:u==="env"?"检查中…":"重新检查"})]}),t.env!==void 0&&t.env.items.length===0&&s.jsx("div",{className:"muted small",children:"脚本包没有声明额外依赖。"}),t.env!==void 0&&t.env.items.length>0&&s.jsx("ul",{className:"env-list",children:t.env.items.map(F=>{const[U,M]=DB[F.status];return s.jsxs("li",{children:[s.jsxs("div",{className:"env-main",children:[s.jsx("span",{className:"env-label",children:F.label}),s.jsx("span",{className:`badge ${U}`,children:M}),F.found!==void 0&&s.jsx("span",{className:"muted small",children:F.found})]}),F.detail!==void 0&&s.jsx("div",{className:"muted small",children:F.detail}),F.fix!==void 0&&s.jsxs("div",{className:"env-fix",children:[s.jsx("span",{className:"muted small",children:F.fix.description}),F.fix.kind!=="manual"&&s.jsx("button",{className:"small-button",disabled:T||u!==null,onClick:()=>void D(`fix-${F.kind}`,async()=>{await e.connection.call("scripts/envFix",{id:t.id,kind:F.kind})}),children:F.fix.kind==="installer"?"安装(需要管理员)":"自动修复"})]})]},F.kind)})})]}),N.has("runs")&&t.dir!==void 0&&s.jsx(ez,{client:e,scriptId:t.id,packId:t.packId}),N.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&s.jsx($B,{client:e,script:t}),N.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&s.jsx(OB,{client:e,scriptId:t.id,scriptName:t.name,openSession:o},t.id),N.has("packs")&&s.jsx(TB,{client:e,script:t,openSession:o}),t.probe!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"目录概况"}),s.jsx("p",{className:"muted small",children:t.packId===void 0?"只是快速看一眼;启动方式、任务和配置的完整分析请用上面的「让 agent 分析」。":"导入时快速看到的文件;脚本怎么运行以脚本包为准。"})]})}),s.jsxs("div",{className:"probe-grid",children:[s.jsx("span",{className:"field-label",children:"可执行文件"}),s.jsx("div",{className:"chip-row",children:t.probe.executables.length===0?s.jsx("span",{className:"muted small",children:"未发现"}):t.probe.executables.map(F=>s.jsx("span",{className:"chip",children:F},F))}),s.jsx("span",{className:"field-label",children:"标志文件"}),s.jsx("div",{className:"chip-row",children:t.probe.markers.length===0?s.jsx("span",{className:"muted small",children:"未发现"}):t.probe.markers.map(F=>s.jsx("span",{className:"chip",children:F},F))})]})]}),N.has("guard")&&s.jsx(MB,{client:e,script:t}),s.jsx("section",{className:"card danger-zone",children:v?s.jsxs("div",{className:"key-actions",children:[$&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:S,onChange:F=>k(F.target.checked)}),"同时删除所有已安装版本"]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>y(!1),children:"取消"}),s.jsx("button",{className:"danger small-button",disabled:u!==null,onClick:()=>void D("remove",async()=>{await e.connection.call("scripts/remove",{id:t.id,deleteFiles:$&&S}),i()}),children:"确认移除"})]}):s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:$?"从脚本库移除;可选择同时删除已安装的文件。":"从脚本库移除;你的目录不会被删除。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",disabled:T,onClick:()=>y(!0),children:"移除"})]})}),m!==null&&s.jsx("div",{className:"notice info",children:m}),f!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:f})]})]})}function BB({client:e,openSession:t,arg:n}){const{data:r,error:i}=Cm(e),o=z$(e),[c,u]=b.useState(null),[d,f]=b.useState(null);b.useEffect(()=>{(n==null?void 0:n.startsWith("mirror:"))===!0&&f({kind:"mirror",rid:n.slice(7)})},[n]);const p=(r==null?void 0:r.scripts)??[],m=((r==null?void 0:r.packs)??[]).filter(N=>!N.installed&&N.repo!==void 0&&N.error===void 0),g=((r==null?void 0:r.packs)??[]).filter(N=>N.error!==void 0),v=((r==null?void 0:r.known)??[]).filter(N=>!N.installed),y=(r==null?void 0:r.setups)??[],S=y.filter(N=>!p.some($=>$.id===N.scriptId)),k=d===null?S.find(N=>N.scriptId===c):void 0,w=c===null||p.some(N=>N.id===c)||k!==void 0?void 0:o.get(c),T=p.find(N=>N.id===c)??(d===null&&w===void 0&&k===void 0?p[0]:void 0);return s.jsxs("section",{className:"main scripts-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"脚本"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"脚本库"})]}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>f({kind:"import"}),children:[s.jsx(ee,{name:"paperclip"}),"导入本地项目"]}),s.jsxs("button",{className:"small-button",onClick:()=>f({kind:"mirror"}),children:[s.jsx(ee,{name:"plus"}),"从 Mirror酱 安装"]}),s.jsxs("button",{className:"primary small-button",onClick:()=>f({kind:"install"}),children:[s.jsx(ee,{name:"plus"}),"从 GitHub 安装"]})]})]}),s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"脚本列表",children:[i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:i})]}),r===null&&i===null&&s.jsx("div",{className:"muted small pad",children:"加载中…"}),r!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sidebar-label",children:["我的脚本(",p.length,")"]}),p.length===0&&![...o.values()].some(co)&&s.jsxs("div",{className:"sidebar-empty",children:[s.jsx(ee,{name:"package"}),s.jsx("span",{children:"还没有脚本"}),s.jsx("span",{children:"从下面的脚本包安装,或导入已有目录"})]}),p.map(N=>{var O,F;const $=o.get(N.id),D=((O=N.env)==null?void 0:O.items.filter(U=>U.status!=="ok"&&U.status!=="unsupported").length)??0;return s.jsxs("button",{className:`script-row ${N.id===(T==null?void 0:T.id)&&d===null?"active":""}`,onClick:()=>{u(N.id),f(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:N.name}),s.jsxs("span",{className:"muted small",children:[N.source.kind==="local"?"本地":N.current??"未安装",N.family===void 0?"":` · ${lw[N.family]??N.family}`]})]}),co($)?s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):y.some(U=>U.scriptId===N.id)?s.jsx("span",{className:"badge warn",children:"待安装"}):((F=N.update)==null?void 0:F.available)===!0?s.jsx("span",{className:"badge ok",children:"可更新"}):D>0?s.jsxs("span",{className:"badge warn",children:["环境 ",D]}):null]},N.id)}),S.length>0&&s.jsxs("div",{className:"sidebar-label",children:["等待安装(",S.length,")"]}),S.map(N=>{var $,D,O;return s.jsxs("button",{className:`script-row ${N===k?"active":""}`,onClick:()=>{u(N.scriptId),f(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:N.name}),s.jsxs("span",{className:"muted small",children:[N.version," · ",(($=N.agent)==null?void 0:$.state)==="running"?"agent 正在安装":((D=N.agent)==null?void 0:D.state)==="failed"?"agent 没能装好":"安装程序已下载"]})]}),((O=N.agent)==null?void 0:O.state)==="running"?s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):s.jsx("span",{className:"badge warn",children:"待安装"})]},N.scriptId)}),[...o.values()].filter(N=>co(N)&&!p.some($=>$.id===N.scriptId)).map(N=>s.jsxs("button",{className:`script-row ${c===N.scriptId&&d===null?"active":""}`,onClick:()=>{u(N.scriptId),f(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:N.scriptId}),s.jsxs("span",{className:"muted small",children:["正在安装 · ",Wu[N.phase],N.total!==void 0&&N.received!==void 0&&N.total>0?` ${Math.floor(N.received/N.total*100)}%`:""]})]}),s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"})]},N.id)),(m.length>0||v.length>0)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label pack-label",children:"可安装的脚本包"}),m.map(N=>s.jsxs("div",{className:"pack-row",children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:N.name}),s.jsx("span",{className:"muted small",children:N.description??N.repo})]}),s.jsx("button",{className:"small-button",onClick:()=>f({kind:"install",repo:N.repo}),children:"安装"})]},N.id)),v.map(N=>s.jsxs("div",{className:"pack-row",children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:N.name}),s.jsx("span",{className:"muted small",children:[N.mirrorchyan===void 0?void 0:`Mirror酱 ${N.mirrorchyan}`,N.repo].filter(Boolean).join(" · ")})]}),s.jsx("button",{className:"small-button",onClick:()=>f(N.mirrorchyan!==void 0?{kind:"mirror",rid:N.mirrorchyan}:{kind:"install",repo:N.repo}),children:"安装"})]},N.id))]}),g.length>0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsxs("span",{children:[g.length," 个脚本包无法读取:",g.map(N=>N.id).join("、")]})]})]})]}),s.jsxs("div",{className:"scripts-detail",children:[(d==null?void 0:d.kind)==="install"&&s.jsx(wB,{client:e,jobs:o,...d.repo===void 0?{}:{initialRepo:d.repo},onClose:()=>f(null),onDone:N=>{u(N),f(null)},openSession:t},d.repo??"blank"),(d==null?void 0:d.kind)==="mirror"&&s.jsx(NB,{client:e,jobs:o,...d.rid===void 0?{}:{initialRid:d.rid},onClose:()=>f(null),onDone:N=>{u(N),f(null)},openSession:t,onGitHub:N=>f({kind:"install",repo:N})},d.rid??"blank"),(d==null?void 0:d.kind)==="import"&&s.jsx(CB,{client:e,onClose:()=>f(null),onImported:N=>{u(N),f(null)}}),d===null&&T!==void 0&&s.jsx(FB,{client:e,script:T,job:o.get(T.id),setup:y.find(N=>N.scriptId===T.id),onRemoved:()=>u(null),openSession:t},T.id),k!==void 0&&s.jsx(dS,{client:e,setup:k,openSession:t,onImported:N=>u(N)},k.scriptId),d===null&&T===void 0&&w!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:w.scriptId}),s.jsx("p",{className:"muted small",children:co(w)?"正在安装,装好后这里显示脚本的详情":"安装没有完成"})]})}),s.jsx(fm,{client:e,job:w})]}),d===null&&T===void 0&&w===void 0&&k===void 0&&r!==null&&s.jsxs("div",{className:"empty",children:[[...o.values()].filter(N=>co(N)&&!p.some($=>$.id===N.scriptId)).map(N=>s.jsxs("div",{className:"pending-install",children:[s.jsx("strong",{children:N.scriptId}),s.jsx(fm,{client:e,job:N})]},N.id)),s.jsx("p",{children:"选择左侧的脚本查看详情,或安装一个新脚本。"})]}),r!==null&&s.jsxs("p",{className:"tools-dir muted small",children:["工具目录:",r.toolsDir]})]})]})]})}const UB={id:"scripts",title:"脚本库",milestone:"M1",requires:["scripts"],pages:[{id:"scripts",title:"脚本",icon:"package",order:10,agent:"scripts",component:BB}],settingsPages:[{id:"script-install",title:"脚本安装",order:10,component:kB}]},HB={id:"emulators",title:"模拟器",milestone:"M2",requires:["emulators"],settingsPages:[{id:"emulators",title:"模拟器",order:11,component:bB}]},up="https://github.com/haaahhhis/MultiGameAssistant";function ZB(){const[e,t]=b.useState(void 0);b.useEffect(()=>{var o;const r=(o=kr())==null?void 0:o.appInfo;if(r===void 0){t(null);return}let i=!0;return r().then(c=>{i&&t(c)},()=>{i&&t(null)}),()=>{i=!1}},[]);const n=e===void 0?"…":e===null?"在浏览器里打开(版本见桌面版)":e.fromSource?`从源码运行(${e.arch})`:`${e.version??"未知版本"}(${e.arch}${e.commit===void 0?"":` · ${e.commit}`})`;return s.jsxs("div",{className:"settings-page about-page",children:[s.jsx("h2",{children:"关于"}),s.jsx("p",{children:"MultiGameAssistant(多游戏助手):让 agent 替你管好各个游戏的日常脚本。"}),s.jsx("section",{className:"card about-card",children:s.jsxs("dl",{className:"about-facts",children:[s.jsx("dt",{children:"版本"}),s.jsx("dd",{children:n}),s.jsx("dt",{children:"源代码"}),s.jsx("dd",{children:s.jsx("a",{href:up,target:"_blank",rel:"noreferrer",children:up.replace("https://","")})}),s.jsx("dt",{children:"许可证"}),s.jsx("dd",{children:s.jsx("a",{href:`${up}/blob/main/LICENSE`,target:"_blank",rel:"noreferrer",children:"GNU AGPL-3.0-only"})})]})}),(e==null?void 0:e.fromSource)===!0?s.jsxs("section",{className:"card about-card",children:[s.jsx("h3",{children:"更新"}),s.jsx("p",{className:"muted",children:"从源码运行:在项目目录 git pull 后重新构建(pnpm install、pnpm build)。"})]}):e!=null&&s.jsx(VB,{}),s.jsxs("section",{className:"card about-card",children:[s.jsx("h3",{children:"许可证"}),s.jsx("p",{children:"Copyright (C) 2026 MultiGameAssistant contributors"}),s.jsx("p",{children:"本程序是自由软件:你可以按自由软件基金会发布的 GNU Affero 通用公共许可证第 3 版(AGPL-3.0-only)再分发和修改它。分发修改后的版本,或让别人通过网络使用修改后的版本时,要以同样的许可证提供它的完整源代码。"}),s.jsx("p",{children:"发布本程序是希望它有用,但不提供任何担保,也没有适销性或特定用途适用性的默示担保。详见许可证全文。"}),s.jsx("p",{className:"muted small",children:"附带的第三方组件(Electron、DeepSeek Harness 等)遵循各自的许可证,许可证文件在程序的安装目录里。本程序安装和调度的游戏脚本是各自独立的项目,不属于本程序。"})]})]})}function VB(){const{bridge:e,state:t}=Gk();if(e===void 0||t===null)return null;const n=t==null?void 0:t.latest,r=t===void 0?"…":t.checking?"正在检查…":t.error!==void 0?t.error:n!==void 0?`有新版本 ${n.version}${n.prerelease?"(预发布版)":""}${n.version===t.skipped?",已跳过":""}`:t.checkedAt!==void 0?`已经是最新版本(${new Date(t.checkedAt).toLocaleString()} 检查)`:"还没有检查过";return s.jsxs("section",{className:"card about-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"更新"}),s.jsxs("p",{className:(t==null?void 0:t.error)!==void 0&&!t.checking?"error small":"muted small",children:[r,n!==void 0&&s.jsxs(s.Fragment,{children:[" · ",s.jsx("a",{href:n.notesUrl,target:"_blank",rel:"noreferrer",children:"查看更新内容"})]})]})]}),s.jsxs("button",{className:"small-button",disabled:t===void 0||t.checking,onClick:()=>void e.check(),children:[s.jsx(ee,{name:"refresh"}),"检查更新"]})]}),t!==void 0&&s.jsx(Kk,{bridge:e,state:t}),t!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.auto,onChange:i=>void e.setAuto(i.target.checked)}),"自动检查更新(启动后和每隔几小时,从 GitHub Releases;",/-/.test(t.current)?"预发布版也会收到更新的预发布版":"只提示正式版",")"]})]})}const Ml=e=>e.replace(/\/+$/,""),Ib=e=>{const t=Ml(e);return t.endsWith("/v1")?t.slice(0,-3):t},fS=[{id:"openai-completions",title:"OpenAI 兼容",subtitle:"Chat Completions",hint:"绝大多数第三方网关和本地服务都用这种:OneAPI / NewAPI、OpenRouter、硅基流动、vLLM、Ollama、LM Studio 等。",placeholder:"https://api.example.com/v1",requestPath:e=>`${Ml(e)}/chat/completions`,listPath:e=>`${Ml(e)}/models`},{id:"openai-responses",title:"OpenAI Responses",subtitle:"Responses API",hint:"OpenAI 的新一代接口,支持推理摘要等能力;仅在服务方明确支持 /responses 时使用。",placeholder:"https://api.openai.com/v1",requestPath:e=>`${Ml(e)}/responses`,listPath:e=>`${Ml(e)}/models`},{id:"anthropic-messages",title:"Anthropic 兼容",subtitle:"Messages API",hint:"Claude 官方接口以及兼容 Anthropic 格式的网关。地址写到域名即可,末尾的 /v1 可有可无。",placeholder:"https://api.anthropic.com",requestPath:e=>`${Ib(e)}/v1/messages`,listPath:e=>`${Ib(e)}/v1/models`}];function hm(e){return fS.find(t=>t.id===e)}function WB(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,40)}function qB(e){return`${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}_API_KEY`}const GB=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function KB(e){try{const{protocol:t}=new URL(e);return t==="http:"||t==="https:"}catch{return!1}}function go(e){return e===void 0?null:e%1048576===0?`${e/1048576}M`:e>=1e6?`${+(e/1e6).toFixed(1)}M`:e%1024===0?`${e/1024}K`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function YB({client:e,profile:t,preset:n,taken:r,revision:i,readOnly:o,onDone:c}){var xe;const u=t===void 0,d=n===void 0||n.id===""?"":r.includes(n.id)?`${n.id}-2`:n.id,[f,p]=b.useState(()=>{var me;return((me=hm((t==null?void 0:t.api)??(n==null?void 0:n.api)))==null?void 0:me.id)??"openai-completions"}),[m,g]=b.useState((t==null?void 0:t.displayName)??((n==null?void 0:n.baseURL)===""?"":(n==null?void 0:n.name)??"")),[v,y]=b.useState((t==null?void 0:t.id)??d),[S,k]=b.useState(!u||d!==""),[w,T]=b.useState((t==null?void 0:t.baseURL)??(n==null?void 0:n.baseURL)??""),[N,$]=b.useState(""),[D,O]=b.useState((t==null?void 0:t.models)??[]),[F,U]=b.useState(!1),[M,P]=b.useState(null),R=hm(f),Z=w.trim(),E=Z!==""&&!KB(Z),C=v!==""&&!GB.test(v),I=u&&r.includes(v),L=pS(N),W=(t==null?void 0:t.apiKeyRef)??(v===""?null:qB(v)),H=((xe=t==null?void 0:t.credential)==null?void 0:xe.configured)===!0,G=(t==null?void 0:t.credential)!==void 0&&!t.credential.writable,K=v===""?"请填写标识":C?"标识格式不正确":I?"这个标识已被占用":Z===""?"请填写 Base URL":E?"Base URL 需要以 http:// 或 https:// 开头":L!==null?L:D.length===0?"至少需要一个模型:点击「拉取模型列表」或手动添加":null,V=me=>{g(me),S||y(WB(me))},Y=async()=>{if(K===null){U(!0),P(null);try{await e.saveProvider({id:v,create:u,...m.trim()===""?{}:{displayName:m.trim()},api:f,baseURL:Z,models:[...D],...N.trim()===""?{}:{apiKey:N.trim()},expectedRevision:i}),c()}catch(me){const ie=me instanceof Error?me.message:String(me);P(/SETTINGS_CONFLICT|conflict/i.test(ie)?"配置在别处被修改过了,请返回列表后重试。":ie)}finally{U(!1)}}},fe=F||o;return s.jsxs("form",{className:"provider-editor",onSubmit:me=>{me.preventDefault(),Y()},children:[s.jsxs("div",{className:"page-head",children:[s.jsx("h3",{children:u?n!==void 0&&n.baseURL!==""?`添加 ${n.name}`:"添加模型服务":`编辑「${t.displayName}」`}),s.jsx("button",{type:"button",className:"ghost",onClick:c,disabled:F,children:"返回"})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{className:"field-title",children:"接口模式"}),s.jsx("div",{className:"mode-grid",role:"radiogroup","aria-label":"接口模式",children:fS.map(me=>s.jsxs("button",{type:"button",role:"radio","aria-checked":f===me.id,"aria-label":`${me.title}(${me.subtitle})`,className:`mode-option${f===me.id?" selected":""}`,onClick:()=>p(me.id),disabled:fe,children:[s.jsx("span",{className:"mode-title",children:me.title}),s.jsx("span",{className:"mode-subtitle",children:me.subtitle})]},me.id))}),s.jsx("div",{className:"muted small",children:R.hint})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"名称"}),s.jsx("input",{className:"text-input plain",value:m,onChange:me=>V(me.target.value),placeholder:"例如:我的中转站",disabled:fe})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"标识"}),s.jsx("input",{className:"text-input",value:v,onChange:me=>{y(me.target.value.trim()),k(!0)},placeholder:"my-gateway",disabled:fe||!u,spellCheck:!1})]})]}),s.jsx("div",{className:C||I?"error small":"muted small",children:C?"标识只能用小写字母、数字和单个连字符,并以字母开头。":I?"这个标识已被占用(可能是已有的提供方或 dsh 内置提供方)。":u?"用于区分提供方,保存后不能修改。":"标识创建后不能修改。"}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"Base URL"}),s.jsx("input",{className:"text-input",value:w,onChange:me=>T(me.target.value),placeholder:R.placeholder,disabled:fe,spellCheck:!1})]}),E?s.jsx("div",{className:"error small",children:"Base URL 需要以 http:// 或 https:// 开头。"}):Z!==""&&s.jsxs("div",{className:"muted small endpoint-preview",children:["对话请求 ",s.jsxs("code",{children:["POST ",R.requestPath(Z)]}),s.jsx("br",{}),"模型列表 ",s.jsxs("code",{children:["GET ",R.listPath(Z)]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"API Key"}),s.jsx("input",{className:"text-input",type:"password",value:N,onChange:me=>$(me.target.value),placeholder:G?"由启动环境变量提供,无法在此修改":H?"已配置,留空则保持不变":"粘贴 Key;本地服务不需要时可留空",autoComplete:"new-password",disabled:fe||G,spellCheck:!1})]}),L!==null?s.jsx("div",{className:"error small",children:L}):W!==null&&s.jsxs("div",{className:"muted small",children:["保存在 dsh 凭据 ",s.jsx("code",{children:W})," 中,界面不会再显示 Key 的内容。",(n==null?void 0:n.keyUrl)!==void 0&&s.jsxs(s.Fragment,{children:[" ",s.jsx("a",{href:n.keyUrl,target:"_blank",rel:"noopener noreferrer",children:"获取 Key ↗"})]})]}),(n==null?void 0:n.vision)!==void 0&&s.jsxs("div",{className:"muted small",children:["截图诊断、读游戏信息需要能看图的模型:",n.vision,"。"]})]}),s.jsx(XB,{client:e,models:D,onChange:O,probe:{...t===void 0?{}:{provider:t.id},api:f,baseURL:Z,apiKey:N.trim()},probeBlocked:Z===""?"先填写 Base URL":E?"Base URL 无效":L,disabled:fe}),M!==null&&s.jsx("div",{className:"banner error",children:M}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:K}),s.jsx("span",{className:"spacer"}),s.jsx("button",{type:"button",onClick:c,disabled:F,children:"取消"}),s.jsx("button",{type:"submit",className:"primary",disabled:fe||K!==null,children:F?"保存中…":u?"创建":"保存"})]})]})}function XB({client:e,models:t,onChange:n,probe:r,probeBlocked:i,disabled:o}){const[c,u]=b.useState(null),[d,f]=b.useState(""),[p,m]=b.useState(""),[g,v]=b.useState(!1),[y,S]=b.useState(null),k=b.useRef(null),w=b.useMemo(()=>new Set(t.map(M=>M.id)),[t]),T=async()=>{var P;(P=k.current)==null||P.abort();const M=new AbortController;k.current=M,v(!0),S(null);try{const R=await e.discoverModels({...r.provider===void 0?{}:{provider:r.provider},api:r.api,baseURL:r.baseURL,...r.apiKey===""?{}:{apiKey:r.apiKey}},M.signal);if(M.signal.aborted)return;u([...R].sort((Z,E)=>Z.id.localeCompare(E.id))),R.length===0&&S("接口返回了空的模型列表,可以手动添加模型 ID。")}catch(R){M.signal.aborted||S(R instanceof Error?R.message:String(R))}finally{k.current===M&&(k.current=null,v(!1))}},N=M=>{n(w.has(M.id)?t.filter(P=>P.id!==M.id):[...t,M])},$=M=>{n(t.map(P=>{if(P.id!==M)return P;if(P.efforts!==void 0&&P.efforts.length>0){const{efforts:R,...Z}=P;return Z}return{...P,efforts:["off","low","medium","high"]}}))},D=M=>{n(t.map(P=>{var R;return P.id!==M?P:{...P,input:((R=P.input)==null?void 0:R.includes("image"))===!0?["text"]:["text","image"]}}))},O=b.useMemo(()=>{const M=d.trim().toLowerCase();return(c??[]).filter(P=>M===""||P.id.toLowerCase().includes(M)||(P.name??"").toLowerCase().includes(M))},[c,d]),F=M=>{if(M){const P=O.filter(R=>!w.has(R.id));n([...t,...P])}else{const P=new Set(O.map(R=>R.id));n(t.filter(R=>!P.has(R.id)))}},U=()=>{const M=p.split(/[\s,,]+/).map(P=>P.trim()).filter(P=>P!==""&&!w.has(P));M.length!==0&&(n([...t,...M.map(P=>(c==null?void 0:c.find(R=>R.id===P))??{id:P})]),m(""))};return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"模型"}),s.jsxs("div",{className:"muted small",children:["已选 ",t.length," 个。只有选中的模型会出现在模型选择器里。能看图的模型点亮「图片」,否则 dsh 会拒绝发送图片;支持调思考强度的模型(如 GPT-5、o 系列、Claude、DeepSeek R 系列)点亮「思考」,对话里就能选强度。"]})]}),s.jsx("button",{type:"button",onClick:()=>void T(),disabled:o||g||i!==null,title:i??void 0,children:g?"拉取中…":c===null?"拉取模型列表":"重新拉取"})]}),y!==null&&s.jsx("div",{className:"error small",children:y}),t.length>0&&s.jsx("div",{className:"model-chips",children:t.map(M=>{var P,R,Z,E,C,I;return s.jsxs("span",{className:"chip removable",children:[M.id,go(M.contextWindow)!==null&&s.jsxs("span",{className:"muted",children:[" · ",go(M.contextWindow)]}),s.jsx("button",{type:"button",className:`chip-flag${((P=M.input)==null?void 0:P.includes("image"))===!0?" on":""}`,onClick:()=>D(M.id),disabled:o,"aria-pressed":((R=M.input)==null?void 0:R.includes("image"))===!0,title:((Z=M.input)==null?void 0:Z.includes("image"))===!0?"支持图片输入(点击关闭)":"不支持图片输入(点击开启)",children:"图片"}),s.jsx("button",{type:"button",className:`chip-flag${(((E=M.efforts)==null?void 0:E.length)??0)>0?" on":""}`,onClick:()=>$(M.id),disabled:o,"aria-pressed":(((C=M.efforts)==null?void 0:C.length)??0)>0,title:(((I=M.efforts)==null?void 0:I.length)??0)>0?`可选思考强度:${M.efforts.join(" / ")}(点击关闭)`:"没有声明思考强度(点击开启:不思考 / 低 / 中 / 高)",children:"思考"}),s.jsx("button",{type:"button",className:"chip-x",onClick:()=>n(t.filter(L=>L.id!==M.id)),disabled:o,"aria-label":`移除 ${M.id}`,children:"×"})]},M.id)})}),c!==null&&c.length>0&&s.jsxs("div",{className:"candidates",children:[s.jsxs("div",{className:"candidates-bar",children:[s.jsx("input",{className:"text-input plain",value:d,onChange:M=>f(M.target.value),placeholder:`搜索 ${c.length} 个模型`}),s.jsxs("button",{type:"button",className:"small-button",onClick:()=>F(!0),disabled:o,children:["全选",d!==""?"筛选结果":""]}),s.jsx("button",{type:"button",className:"small-button",onClick:()=>F(!1),disabled:o,children:"全不选"})]}),s.jsxs("ul",{className:"candidate-list",children:[O.map(M=>{var P;return s.jsx("li",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:w.has(M.id),onChange:()=>N(M),disabled:o}),s.jsx("span",{className:"mono",children:M.id}),M.name!==void 0&&s.jsxs("span",{className:"muted",children:[" ",M.name]}),s.jsx("span",{className:"spacer"}),((P=M.input)==null?void 0:P.includes("image"))===!0&&s.jsx("span",{className:"badge",children:"图像"}),go(M.contextWindow)!==null&&s.jsxs("span",{className:"muted small",children:[go(M.contextWindow)," 上下文"]})]})},M.id)}),O.length===0&&s.jsx("li",{className:"muted small",children:"没有匹配的模型。"})]})]}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{className:"text-input plain-mono",value:p,onChange:M=>m(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),U())},placeholder:"手动添加模型 ID,多个用空格或逗号分隔",disabled:o,spellCheck:!1}),s.jsx("button",{type:"button",onClick:U,disabled:o||p.trim()==="",children:"添加"})]})]})}const QB=[{key:"anthropic",name:"Claude(Anthropic)",note:"看图和工具调用都很强",api:"anthropic-messages",baseURL:"https://api.anthropic.com",id:"claude",keyUrl:"https://console.anthropic.com/settings/keys",vision:"所有 Claude 模型都能看图"},{key:"openai",name:"ChatGPT(OpenAI)",note:"GPT 系列",api:"openai-completions",baseURL:"https://api.openai.com/v1",id:"chatgpt",keyUrl:"https://platform.openai.com/api-keys",vision:"gpt-4o、gpt-4.1 等能看图"},{key:"gemini",name:"Gemini(Google)",note:"OpenAI 兼容接口",api:"openai-completions",baseURL:"https://generativelanguage.googleapis.com/v1beta/openai",id:"gemini",keyUrl:"https://aistudio.google.com/apikey",vision:"Gemini 模型都能看图"},{key:"openrouter",name:"OpenRouter",note:"一个 Key 用很多家的模型",api:"openai-completions",baseURL:"https://openrouter.ai/api/v1",id:"openrouter",keyUrl:"https://openrouter.ai/keys"},{key:"siliconflow",name:"硅基流动",note:"国内,开源模型多",api:"openai-completions",baseURL:"https://api.siliconflow.cn/v1",id:"siliconflow",keyUrl:"https://cloud.siliconflow.cn/account/ak"},{key:"dashscope",name:"阿里云百炼(通义千问)",note:"国内",api:"openai-completions",baseURL:"https://dashscope.aliyuncs.com/compatible-mode/v1",id:"dashscope",keyUrl:"https://bailian.console.aliyun.com/?apiKey=1",vision:"qwen-vl 系列能看图"},{key:"moonshot",name:"Kimi(月之暗面)",note:"国内",api:"openai-completions",baseURL:"https://api.moonshot.cn/v1",id:"moonshot",keyUrl:"https://platform.moonshot.cn/console/api-keys"},{key:"zhipu",name:"智谱 GLM",note:"国内",api:"openai-completions",baseURL:"https://open.bigmodel.cn/api/paas/v4",id:"zhipu",keyUrl:"https://open.bigmodel.cn/usercenter/apikeys",vision:"glm-4v 系列能看图"},{key:"ark",name:"火山方舟(豆包)",note:"国内",api:"openai-completions",baseURL:"https://ark.cn-beijing.volces.com/api/v3",id:"ark",keyUrl:"https://console.volcengine.com/ark"},{key:"ollama",name:"Ollama(本机)",note:"在自己电脑上跑开源模型,不需要 Key",api:"openai-completions",baseURL:"http://127.0.0.1:11434/v1",id:"ollama"},{key:"custom",name:"其他服务",note:"中转站、自建网关等任何 OpenAI / Anthropic 兼容接口",api:"openai-completions",baseURL:"",id:""}],dp=[{id:"deepseek-official",name:"DeepSeek",note:"内置,只需要填 Key",keyRef:Ep,keyUrl:"https://platform.deepseek.com/api_keys"}];function JB({client:e}){const{catalog:t}=ic(e),[n,r]=b.useState(!1),[i,o]=b.useState(void 0),c=Ee(e.providersRevision),u=Ee(e.credentialRevision),d=Ee(e.connection.status),[f,p]=b.useState(null),[m,g]=b.useState(null),[v,y]=b.useState(null),[S,k]=b.useState(null),w=b.useCallback(()=>{e.listProviders().then(N=>{p(N),g(null)}).catch(N=>g(N instanceof Error?N.message:String(N)))},[e]);if(b.useEffect(()=>{d.state==="open"&&w()},[w,c,u,d.state]),v!==null&&f!==null){const N=v==="new"?void 0:f.providers.find($=>$.id===v);return s.jsx("section",{className:"providers-section",children:s.jsx(YB,{client:e,profile:N,preset:v==="new"?i:void 0,taken:f.taken,revision:f.revision,readOnly:!f.writable,onDone:()=>{y(null),o(void 0),w()}},v)})}if(n)return s.jsxs("section",{className:"providers-section",children:[s.jsxs("div",{className:"page-head",children:[s.jsx("h3",{children:"添加模型服务"}),s.jsx("button",{className:"ghost",onClick:()=>r(!1),children:"返回"})]}),s.jsxs("div",{className:"preset-grid",children:[dp.map(N=>s.jsxs("button",{className:"preset-option",onClick:()=>{var $;r(!1),($=document.getElementById(`builtin-${N.id}`))==null||$.scrollIntoView({behavior:"smooth"})},children:[s.jsx("span",{className:"mode-title",children:N.name}),s.jsx("span",{className:"mode-subtitle",children:N.note})]},N.id)),QB.map(N=>s.jsxs("button",{className:"preset-option",disabled:f===null||!f.writable,onClick:()=>{o(N),r(!1),y("new")},children:[s.jsx("span",{className:"mode-title",children:N.name}),s.jsx("span",{className:"mode-subtitle",children:N.note})]},N.key))]})]});const T=new Set((f==null?void 0:f.providers.map(N=>N.id))??[]);return s.jsxs("section",{className:"providers-section",children:[s.jsxs("div",{className:"page-head",children:[s.jsx("h3",{children:"模型服务"}),s.jsx("button",{className:"primary",onClick:()=>r(!0),disabled:f===null,children:"+ 添加模型服务"})]}),s.jsx("p",{className:"muted",children:"每个服务填一次 Key,它的模型就会出现在输入框旁的模型选择器里。Claude、ChatGPT、Gemini、国内各家和本机的 Ollama 都可以接;需要看截图的功能请选能看图的模型。Key 保存在本机 dsh 的凭据文件里,界面不会再显示。"}),dp.map(N=>s.jsx(nU,{client:e,provider:N,catalog:t},N.id)),t==null?void 0:t.groups.filter(N=>!T.has(N.id)&&!dp.some($=>$.id===N.id)).map(N=>s.jsxs("section",{className:"card provider-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:N.name}),s.jsx("div",{className:"muted small",children:s.jsx("code",{children:N.id})})]}),s.jsx("span",{className:"badge",children:"内置"})]}),s.jsx("div",{className:"model-chips",children:N.models.map($=>s.jsx("span",{className:"chip",children:$.name},$.id))})]},N.id)),m!==null&&s.jsx("div",{className:"banner error",children:m}),S!==null&&s.jsx("div",{className:"success small",children:S}),f!==null&&!f.writable&&s.jsx("div",{className:"notice info left",children:"当前 profile 是只读的,无法在界面中修改提供方。"}),f===null&&m===null&&s.jsx("div",{className:"muted small",children:"读取中…"}),f==null?void 0:f.providers.map(N=>s.jsx(eU,{client:e,profile:N,revision:f.revision,readOnly:!f.writable,onEdit:()=>y(N.id),onRemoved:$=>{k($?"已删除。它原本是新会话的默认模型,默认模型已恢复为 profile 自带的设置。":null),w()}},N.id))]})}function eU({client:e,profile:t,revision:n,readOnly:r,onEdit:i,onRemoved:o}){const[c,u]=b.useState(!1),[d,f]=b.useState(null),p=hm(t.api),m=async()=>{var v,y;const g=t.apiKeyRef!==void 0&&((v=t.credential)==null?void 0:v.source)==="file"?`
|
|
226
|
-
|
|
227
|
-
同时删除已保存的 Key(${t.apiKeyRef})。`:"";if(window.confirm(`确定删除「${t.displayName}」吗?使用它的会话需要换一个模型。${g}`)){u(!0),f(null);try{const{defaultReset:S}=await e.removeProvider({id:t.id,removeKey:((y=t.credential)==null?void 0:y.source)==="file",expectedRevision:n});o(S)}catch(S){f(S instanceof Error?S.message:String(S))}finally{u(!1)}}};return s.jsxs("section",{className:"card provider-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:t.displayName}),s.jsxs("div",{className:"muted small",children:[s.jsx("code",{children:t.id}),t.baseURL!==void 0&&s.jsxs(s.Fragment,{children:[" · ",s.jsx("span",{className:"mono",children:t.baseURL})]})]})]}),s.jsxs("div",{className:"badges",children:[s.jsx("span",{className:"badge",children:p===void 0?t.api??"内置目录":`${p.title} · ${p.subtitle}`}),s.jsx(tU,{profile:t}),t.active?s.jsx("span",{className:"badge ok",children:"已生效"}):s.jsx("span",{className:"badge warn",title:t.error,children:"未生效"})]})]}),t.error!==void 0&&s.jsx("div",{className:"error small",children:t.error}),t.models.length>0?s.jsx("div",{className:"model-chips",children:t.models.map(g=>s.jsxs("span",{className:"chip",title:g.name??g.id,children:[g.id,go(g.contextWindow)!==null&&s.jsxs("span",{className:"muted",children:[" · ",go(g.contextWindow)]})]},g.id))}):s.jsx("div",{className:"muted small",children:"使用 dsh 内置的模型目录。"}),d!==null&&s.jsx("div",{className:"error small",children:d}),s.jsxs("div",{className:"key-actions",children:[!t.declared&&s.jsx("span",{className:"muted small",children:"这是 dsh 内置提供方的配置,请在 dsh 官方模型页面编辑。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline",onClick:()=>void m(),disabled:c||r,children:"删除"}),t.declared&&s.jsx("button",{onClick:i,disabled:c||r,children:"编辑"})]})]})}function tU({profile:e}){return e.apiKeyRef===void 0?s.jsx("span",{className:"badge",children:"无 Key"}):e.credential===void 0?s.jsxs("span",{className:"badge",children:["Key:",e.apiKeyRef]}):e.credential.configured?s.jsx("span",{className:"badge ok",title:e.apiKeyRef,children:"Key 已配置"}):s.jsx("span",{className:"badge warn",title:e.apiKeyRef,children:"Key 未配置"})}function nU({client:e,provider:t,catalog:n}){const{items:r}=qk(e,[t.keyRef]),i=(r==null?void 0:r[t.keyRef])??null,o=n==null?void 0:n.groups.find(u=>u.id===t.id),c=n==null?void 0:n.failures.find(u=>u.id===t.id);return s.jsxs("section",{className:"card provider-card",id:`builtin-${t.id}`,children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:t.name}),s.jsxs("div",{className:"muted small",children:[s.jsx("code",{children:t.id})," · ",t.note]})]}),s.jsxs("div",{className:"badges",children:[s.jsx("span",{className:"badge",children:"内置"}),i===null?null:i.configured?s.jsx("span",{className:"badge ok",children:"Key 已配置"}):s.jsx("span",{className:"badge warn",children:"Key 未配置"})]})]}),o!==void 0&&o.models.length>0&&s.jsx("div",{className:"model-chips",children:o.models.map(u=>s.jsx("span",{className:"chip",title:u.description,children:u.name},u.id))}),c!==void 0&&s.jsx("div",{className:"error small",children:c.message}),s.jsx(rU,{client:e,refName:t.keyRef,title:`${t.name} API Key`,description:"",helpUrl:t.keyUrl,info:i,bare:!0})]})}const hS={file:"dsh 凭据文件",env:"启动环境变量","project-env":"项目 .env 文件","user-env":"dsh 主目录 .env 文件"};function pS(e){const t=e.trim();return e.length>0&&t.length===0?"API Key 不能只包含空白字符。":t===""?null:/^[A-Z][A-Z0-9_]*=[^=]/.test(t)?'看起来粘贴了 "名称=值" 的整行,请只粘贴 Key 本身。':/^(["'`]).+\1$/.test(t)?"请去掉 Key 两侧的引号。":/^[\x21-\x7E]+$/.test(t)?null:"API Key 只能包含可见的 ASCII 字符,不能有空格或中文。"}function sU({client:e}){const t=Ee(e.capabilities);return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"模型"}),s.jsx("p",{className:"muted",children:"agent 用哪个模型、接哪些模型服务都在这里。保存后立即生效;新对话和飞书对话默认用下面选的模型,软件自己开的会话(干预、游戏等)可以另选一个;每个对话也可以在输入框旁边单独换。"}),s.jsx(aU,{client:e}),t.has("role-model")&&s.jsx(oU,{client:e}),t.has("providers")&&s.jsx(JB,{client:e})]})}function rU({client:e,refName:t,title:n,description:r,helpUrl:i,info:o,placeholder:c,bare:u=!1}){const[d,f]=b.useState(""),[p,m]=b.useState(!1),[g,v]=b.useState(!1),[y,S]=b.useState(null),k=pS(d),w=o!==null&&!o.writable,T=async()=>{if(!(d.trim()===""||k!==null)){v(!0),S(null);try{await e.setCredential(t,d.trim()),f(""),m(!1),S({tone:"ok",text:"已保存,立即生效。"})}catch(D){S({tone:"error",text:D instanceof Error?D.message:String(D)})}finally{v(!1)}}},N=async()=>{if(window.confirm(`确定要删除已保存的 ${n} 吗?删除后需要重新填写才能使用对应模型。`)){v(!0),S(null);try{await e.unsetCredential(t),S({tone:"ok",text:"已删除。"})}catch(D){S({tone:"error",text:D instanceof Error?D.message:String(D)})}finally{v(!1)}}},$=u?"div":"section";return s.jsxs($,{className:u?"credential-inline":"card",children:[!u&&s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:n}),s.jsxs("div",{className:"muted small",children:[r," ",s.jsx("code",{children:t})]})]}),s.jsx(iU,{info:o})]}),w?s.jsxs("div",{className:"notice info left",children:["当前 Key 来自",hS[o.source??""]??o.source,",优先级高于界面保存的值,因此这里无法修改。 如需在界面中管理,请先从启动 dsh 的环境中移除 ",s.jsx("code",{children:t})," 再重新启动。"]}):s.jsxs("form",{className:"key-form",onSubmit:D=>{D.preventDefault(),T()},children:[s.jsxs("div",{className:"key-input",children:[s.jsx("input",{type:p?"text":"password",value:d,onChange:D=>{f(D.target.value),S(null)},placeholder:(o==null?void 0:o.configured)===!0?"已配置。输入新的 Key 可替换":c??"粘贴你的 API Key(sk-…)",autoComplete:"off",spellCheck:!1,"aria-label":n,disabled:g}),s.jsx("button",{type:"button",className:"ghost",onClick:()=>m(D=>!D),disabled:d==="",children:p?"隐藏":"显示"})]}),k!==null&&s.jsx("div",{className:"error small",children:k}),s.jsxs("div",{className:"key-actions",children:[i!==void 0&&s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"small",children:"获取 API Key ↗"}),s.jsx("span",{className:"spacer"}),(o==null?void 0:o.configured)===!0&&o.source==="file"&&s.jsx("button",{type:"button",className:"danger-outline",onClick:()=>void N(),disabled:g,children:"删除"}),s.jsx("button",{type:"submit",className:"primary",disabled:g||d.trim()===""||k!==null,children:g?"保存中…":(o==null?void 0:o.configured)===!0?"替换":"保存"})]})]}),y!==null&&s.jsx("div",{className:y.tone==="ok"?"success small":"error small",children:y.text})]})}function iU({info:e}){return e===null?s.jsx("span",{className:"badge",children:"读取中…"}):e.configured?s.jsxs("span",{className:"badge ok",children:["已配置 · ",hS[e.source??""]??e.source??"未知来源"]}):s.jsx("span",{className:"badge warn",children:"未配置"})}function aU({client:e}){const{catalog:t,error:n}=ic(e),r=Ee(e.capabilities),[i,o]=b.useState(!1),[c,u]=b.useState(null),d=t===null?"":`${t.default.provider}/${t.default.model}`,f=async m=>{const[g,...v]=m.split("/");o(!0),u(null);try{await e.connection.call("models/setDefault",{provider:g,model:v.join("/")}),u("已设为默认,新对话会用它。")}catch(y){u(y instanceof Error?y.message:String(y))}finally{o(!1)}},p=(t==null?void 0:t.groups.some(m=>m.models.some(g=>`${m.id}/${g.id}`===d)))??!1;return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"默认模型"}),s.jsx("p",{className:"muted small",children:"先在下面的模型服务里填好 Key,这里就能选它的模型。"})]})}),n!==null&&s.jsx("div",{className:"error small",children:n}),t===null&&n===null&&s.jsx("div",{className:"muted small",children:"读取中…"}),t!==null&&s.jsx(yn,{"aria-label":"默认模型",value:d,disabled:i||!r.has("model-default"),onChange:m=>void f(m),options:[...p?[]:[{value:d,label:`${t.default.provider} / ${t.default.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...t.groups.flatMap(m=>m.models.map(g=>({value:`${m.id}/${g.id}`,label:g.name,group:m.name})))]}),t==null?void 0:t.failures.map(m=>s.jsxs("div",{className:"error small",children:[m.name,":",m.message]},m.id)),c!==null&&s.jsx("div",{className:"muted small",children:c})]})}function oU({client:e}){const{catalog:t}=ic(e),n=Ee(e.connection.status),[r,i]=b.useState(void 0),[o,c]=b.useState(!1),[u,d]=b.useState(null);b.useEffect(()=>{if(n.state!=="open")return;let g=!0;return e.connection.call("models/roleModel",{}).then(v=>{g&&i(v.model)}).catch(()=>{}),()=>{g=!1}},[e,n.state]);const f=r==null?"":`${r.provider}/${r.model}`,p=async g=>{const[v,...y]=g.split("/"),S=g===""?null:{provider:v,model:y.join("/")};c(!0),d(null);try{const{warning:k}=await e.connection.call("models/setRoleModel",{model:S});i(S),d(k!==void 0?{tone:"warn",text:k}:{tone:"ok",text:S===null?"角色 agent 和以前一样,用默认模型。":"之后新开的干预、游戏、脚本、编排会话用它;已经开着的会话不变。"})}catch(k){d({tone:"warn",text:k instanceof Error?k.message:String(k)})}finally{c(!1)}},m=f===""||((t==null?void 0:t.groups.some(g=>g.models.some(v=>`${g.id}/${v.id}`===f)))??!1);return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"角色 agent 的模型"}),s.jsx("p",{className:"muted small",children:"干预、游戏、脚本、编排这些软件自己开的会话用它。它们主要是截图、看日志、点击,选一个便宜、能看图的模型可以省用量;你自己的对话仍用上面的默认模型。"})]})}),t===null||r===void 0?s.jsx("div",{className:"muted small",children:"读取中…"}):s.jsx(yn,{"aria-label":"角色 agent 的模型",value:f,disabled:o,onChange:g=>void p(g),options:[{value:"",label:"和默认模型一样"},...m?[]:[{value:f,label:`${r.provider} / ${r.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...t.groups.flatMap(g=>g.models.map(v=>({value:`${g.id}/${v.id}`,label:v.name,group:g.name})))]}),u!==null&&s.jsx("div",{className:u.tone==="ok"?"muted small":"error small",children:u.text})]})}const lU=(e,t)=>e.auto===t.auto&&e.threshold===t.threshold;function cU({client:e}){var v;const t=Ee(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(!1),[d,f]=b.useState(null),p=(v=kr())==null?void 0:v.restartService;b.useEffect(()=>{if(d===null||n===null)return;if(d===n.settings.threshold){f(null);return}const y=setTimeout(()=>void m({...n.settings,threshold:d}).then(()=>f(null)),400);return()=>clearTimeout(y)},[d,n]),b.useEffect(()=>{if(t.state!=="open")return;let y=!0;return e.connection.call("compaction/get",{}).then(S=>{y&&r(S)}).catch(S=>{y&&o(Pe(S))}),()=>{y=!1}},[e,t.state]);const m=async y=>{if(!(!y.auto&&(n==null?void 0:n.settings.auto)===!0&&!window.confirm(`关掉自动压缩后,对话超过模型的上下文长度时会直接出错,要手动压缩或开新对话才能继续。
|
|
228
|
-
|
|
229
|
-
确定关掉吗?`))){u(!0),o(null);try{r(await e.connection.call("compaction/set",{settings:y}))}catch(S){o(Pe(S))}finally{u(!1)}}},g=async()=>{p===void 0||!window.confirm(`重启 agent 服务:正在进行的对话和正在跑的脚本、流水线会被中断,大约需要半分钟。
|
|
230
|
-
|
|
231
|
-
确定现在重启吗?`)||await p()};return s.jsxs("div",{className:"settings-page compaction-page",children:[s.jsx("h2",{children:"对话压缩"}),s.jsx("p",{children:"对话很长时,模型一次看不下全部内容。压缩会把较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:"}),s.jsxs("ul",{className:"compaction-costs",children:[s.jsxs("li",{children:[s.jsx("strong",{children:"会丢失记忆"}),":早先的细节(具体的命令和输出、日志、截图、你说过的原话)agent 不再记得;"]}),s.jsx("li",{children:"摘要可能漏掉或写错内容,而且不能撤销;"}),s.jsx("li",{children:"界面上的聊天记录还在,只是 agent 看不到了。"})]}),n!==null&&s.jsxs("section",{className:"card",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.settings.auto,disabled:c,onChange:y=>void m({...n.settings,auto:y.target.checked})}),"对话太长时自动压缩"]}),s.jsx("p",{className:"muted small",children:n.settings.auto?"关掉后不会自动压缩:对话超过模型的上下文长度时会出错,需要手动压缩或开新对话。":"已关闭:对话超过模型的上下文长度时会出错,需要手动压缩或开新对话。"}),s.jsxs("label",{className:"field compaction-threshold",children:[s.jsxs("span",{className:"field-title",children:["占满上下文的多少时压缩:",s.jsxs("strong",{children:[d??n.settings.threshold,"%"]}),(d??n.settings.threshold)===HT?"(默认)":""]}),s.jsx("input",{type:"range",min:Ck,max:Ik,step:5,value:d??n.settings.threshold,disabled:!n.settings.auto,"aria-label":"压缩阈值(百分比)",onChange:y=>f(Number(y.target.value))}),s.jsx("span",{className:"muted small",children:"调低:压缩得早,回复快、花费少,但记得的细节少;调高:记得的多,但更可能临时压缩一大段。"})]}),!lU(n.settings,n.applied)&&s.jsxs("div",{className:"notice left",children:[s.jsx(ee,{name:"info"}),s.jsxs("span",{children:["改动要重启 agent 服务才生效(现在还是:",n.applied.auto?`自动压缩,${n.applied.threshold}%`:"不自动压缩",")。",p===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),p!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void g(),children:"重启 agent 服务"})]}),i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:i})]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"手动压缩"}),s.jsxs("p",{className:"muted small",children:["在对话框里输入 ",s.jsx("kbd",{children:"/压缩"}),",会先说明代价再确认。对话框旁边的小圆圈显示上下文用了多少,点开能看到各部分占多少。对话变慢、或报上下文超长时用;agent 正在工作时不能压缩。"]})]}),n===null&&i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:i})]})]})}const Ab=[{policy:"default",label:"默认",hint:"跟着上面的模式走"},{policy:"allow",label:"允许",hint:"不问你,直接做"},{policy:"ask",label:"先问我",hint:"每次都先问你,「完全访问」时也问"},{policy:"deny",label:"不允许",hint:"agent 不能做,会告诉你被关掉了"}],uU=[{value:"act",label:"诊断并处理"},{value:"diagnose",label:"只诊断"},{value:"off",label:"不干预"}];function dU({client:e,state:t,onState:n}){const r=Ee(e.capabilities),[i,o]=b.useState(null),[c,u]=b.useState(null),[d,f]=b.useState(null),p=r.has("monitor");b.useEffect(()=>{if(!p)return;let v=!0;return e.connection.call("monitor/settings",{}).then(y=>{v&&f(y)}).catch(()=>{}),()=>{v=!1}},[e,p]);const m=async(v,y)=>{o(v),u(null);try{n(await e.connection.call("permissions/area/set",{area:v,policy:y}))}catch(S){u(Pe(S))}finally{o(null)}},g=async v=>{o("intervene"),u(null);try{f(await e.connection.call("monitor/settings/set",{intervene:v}))}catch(y){u(Pe(y))}finally{o(null)}};return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"按范围设置"}),s.jsxs("p",{className:"muted small",children:["agent 能自己做的事,一项一项决定:",Ab.map(v=>`「${v.label}」${v.hint}`).join(";"),"。"]})]})}),s.jsxs("div",{className:"area-list",children:[p&&d!==null&&s.jsxs("div",{className:"area-row",children:[s.jsxs("div",{className:"area-text",children:[s.jsx("strong",{children:"主动干预出问题的脚本"}),s.jsx("span",{className:"muted small",children:"脚本卡住、报错,自动处理解决不了时交给 agent:「诊断并处理」会暂停脚本、看屏幕、点击输入来解决;「只诊断」只说明原因由你决定。"})]}),s.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":"主动干预",children:uU.map(v=>s.jsx("button",{role:"radio","aria-checked":d.intervene===v.value,className:d.intervene===v.value?"active":"",disabled:i!==null,onClick:()=>void g(v.value),children:v.label},v.value))})]}),PT.map(v=>{const y=t.areas[v.id]??"default";return s.jsxs("div",{className:"area-row",children:[s.jsxs("div",{className:"area-text",children:[s.jsx("strong",{children:v.title}),s.jsx("span",{className:"muted small",children:v.description})]}),s.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":v.title,children:Ab.map(S=>s.jsx("button",{role:"radio","aria-checked":y===S.policy,title:S.hint,className:`${y===S.policy?"active":""} ${S.policy}`,disabled:i!==null,onClick:()=>void m(v.id,S.policy),children:S.label},S.policy))})]},v.id)})]}),c!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:c})]})]})}const fU=[{mode:"ask",title:"每次确认(推荐)",text:"agent 的命令在沙箱里运行;安装陌生仓库、操作屏幕、沙箱外的命令、修改脚本文件等,都先问你。"},{mode:"full",title:"完全访问",text:"不用沙箱,所有需要确认的操作都自动允许,也可以修改脚本文件:agent 想改什么就改什么,不再问你。"}];function hU({client:e}){const t=Ee(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(!1),[u,d]=b.useState(null);b.useEffect(()=>e.connection.on("permissions/changed",p=>i(p)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let p=!0;return e.connection.call("permissions/get",{}).then(m=>{p&&i(m)}).catch(m=>{p&&d(Pe(m))}),()=>{p=!1}},[e,t.state]);const f=async p=>{if((r==null?void 0:r.mode)!==p&&!(p==="full"&&!window.confirm(`打开「完全访问」后,agent 可以不经确认运行任何命令、修改或删除任何文件(包括脚本文件)、操作屏幕、安装软件。只在你信任当前模型、并且需要它自己完成整件事时打开。
|
|
232
|
-
|
|
233
|
-
确定打开吗?`))){c(!0),d(null);try{i(await e.connection.call("permissions/set",{mode:p}))}catch(m){d(Pe(m))}finally{c(!1)}}};return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"权限"}),s.jsx("p",{children:"决定 agent 做事之前要不要先问你。对所有会话都有效,包括飞书里的对话、异常处理和流水线里的 agent 步骤。"}),s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"permission-options",role:"radiogroup","aria-label":"权限",children:fU.map(p=>s.jsxs("button",{role:"radio","aria-checked":(r==null?void 0:r.mode)===p.mode,disabled:o||r===null,className:`permission-option ${p.mode} ${(r==null?void 0:r.mode)===p.mode?"active":""}`,onClick:()=>void f(p.mode),children:[s.jsx("span",{className:"permission-dot","aria-hidden":"true"}),s.jsxs("span",{className:"permission-text",children:[s.jsx("strong",{children:p.title}),s.jsx("span",{children:p.text})]})]},p.mode))}),(r==null?void 0:r.mode)==="full"&&s.jsxs("div",{className:"notice warn-note left small",children:[s.jsx(ee,{name:"alert"}),s.jsxs("span",{children:["完全访问一直开着,没有时间限制,直到你改回「每次确认」",r.since===void 0?"":`(${pU(r.since,n)})`,"。agent 不会再请求确认;它仍然不会替你输入密码、验证码或付款。"]})]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:u})]})]}),r!==null&&s.jsx(dU,{client:e,state:r,onState:i}),r!==null&&r.recent.length>0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"没问你就允许了的操作"}),s.jsxs("p",{className:"muted small",children:["因为「完全访问」或某个范围设成了「允许」。程序这次启动以来,最近 ",r.recent.length," 条。"]}),s.jsx("ul",{className:"version-list",children:r.recent.map((p,m)=>s.jsxs("li",{children:[s.jsx("span",{className:"badge",children:p.toolName}),s.jsx("span",{className:"permission-reason",children:p.reason??"(没有说明)"}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"session-time",children:$t(p.at,n)})]},m))})]})]})}function pU(e,t){const n=$t(e,t);return n==="刚刚"?"刚刚打开":/^\d+ (分钟|小时|天)$/.test(n)?`${n}前打开`:`${n} 打开`}const mU=[{style:"default",title:"默认",sample:"不加设定,按模型自己的说话方式。"},{style:"concise",title:"简洁干练",sample:"「日常跑完了,3 个成功 1 个失败:MAA 刷理智没体力了。」"},{style:"patient",title:"耐心细致",sample:"「我先帮你看了 MAA 的日志,失败是因为理智不够——这不是脚本坏了,等理智恢复再跑就行。」"},{style:"lively",title:"活泼可爱",sample:"「搞定啦~日常都跑完了!就是理智又见底了 (。•́︿•̀。)」"},{style:"buddy",title:"游戏搭子",sample:"「日常清完了,理智又被榨干了哈哈,活动商店还差两样,明天接着肝。」"},{style:"butler",title:"稳重管家",sample:"「今日日常已完成。另有一项需要您决定:活动商店剩余两件,是否明日继续兑换?」"}];function gU({client:e}){const t=Ee(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(""),[c,u]=b.useState(!1),[d,f]=b.useState(!1),[p,m]=b.useState(null),[g,v]=b.useState(!1);b.useEffect(()=>{if(t.state!=="open")return;let k=!0;return e.connection.call("persona/get",{}).then(w=>{k&&(r(w.persona),o(w.prompt))}).catch(w=>{k&&m(Pe(w))}),()=>{k=!1}},[e,t.state]);const y=k=>{r(w=>w===null?w:{...w,...k}),u(!0),v(!1)},S=async(k=n)=>{if(k!==null){f(!0),m(null);try{const w=await e.connection.call("persona/set",{persona:k});r(w.persona),o(w.prompt),u(!1),v(!0)}catch(w){m(Pe(w))}finally{f(!1)}}};return s.jsxs("div",{className:"settings-page persona-page",children:[s.jsx("h2",{children:"回复风格"}),s.jsx("p",{children:"agent 说话的方式和人设,对所有对话都有效:软件里的对话、飞书里的回复、流水线里的 agent 步骤。只改说话方式,不改做事的规则:该确认的照样确认,密码、验证码和付款照样不碰。"}),n!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"风格"}),s.jsx("div",{className:"persona-styles",role:"radiogroup","aria-label":"风格",children:mU.map(k=>s.jsxs("button",{role:"radio","aria-checked":n.style===k.style,className:`mode-option persona-style ${n.style===k.style?"selected":""}`,onClick:()=>y({style:k.style}),children:[s.jsx("strong",{children:k.title}),s.jsx("span",{className:"muted small",children:k.sample})]},k.style))})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"人设"}),s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"agent 的名字(可选)"}),s.jsx("input",{className:"text-input plain",maxLength:20,placeholder:"例如:小助",value:n.name??"",onChange:k=>y({name:k.target.value})})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"怎么称呼你(可选)"}),s.jsx("input",{className:"text-input plain",maxLength:20,placeholder:"例如:博士、开拓者、指挥官",value:n.callUser??"",onChange:k=>y({callUser:k.target.value})})]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"其他要求(可选)"}),s.jsx("textarea",{className:"text-input plain",rows:6,placeholder:"例如:说话带一点罗德岛干员的口吻;汇报时先说有没有失败;不要用英文缩写。",value:n.custom??"",onChange:k=>y({custom:k.target.value})})]}),s.jsxs("div",{className:"persona-actions",children:[s.jsx("button",{className:"primary",disabled:d||!c,onClick:()=>void S(),children:d?"保存中…":"保存"}),s.jsx("button",{disabled:d,onClick:()=>void S({style:"default"}),children:"恢复默认"}),g&&!c&&s.jsx("span",{className:"muted small",children:"已保存,下一句回复开始生效。"})]}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:p})]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"加到 agent 提示词里的内容"}),i===""?s.jsx("p",{className:"muted small",children:"现在是默认风格,什么都不加。"}):s.jsx("pre",{className:"persona-prompt",children:i}),c&&s.jsx("p",{className:"muted small",children:"保存后更新。"})]})]}),n===null&&p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:p})]})]})}const xU={id:"settings-credentials",title:"模型",requires:["credentials","models"],settingsPages:[{id:"api-keys",title:"模型",order:0,component:sU}]},vU={id:"permissions",title:"权限",requires:["permissions"],settingsPages:[{id:"permissions",title:"权限",order:1,component:hU}]},yU={id:"persona",title:"回复风格",requires:["persona"],settingsPages:[{id:"persona",title:"回复风格",order:2,component:gU}]},bU={id:"compaction",title:"对话压缩",requires:["compaction"],settingsPages:[{id:"compaction",title:"对话压缩",order:3,component:cU}]},kU={id:"about",title:"关于",requires:[],settingsPages:[{id:"about",title:"关于",order:100,component:ZB}]};function wU({client:e}){const t=Ee(e.capabilities),n=Ee(e.connection.server),[r,i]=b.useState(0);b.useEffect(()=>Zk(()=>i(d=>d+1)),[]);const o=b.useMemo(()=>MM(t),[t,r]),c=o.filter(d=>d.missing.length===0),u=o.filter(d=>d.missing.length>0);return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"插件状态"}),s.jsx("p",{children:"界面插件只在后端提供了它需要的能力时启用。后端少装一个插件,对应的界面就自动隐藏。"}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"后端能力"}),s.jsx("p",{className:"muted small",children:n===null?"尚未连接":`${n.server.name} ${n.server.version}${n.server.dsh===void 0?"":` · dsh ${n.server.dsh}`}`}),s.jsxs("div",{className:"chip-row",children:[[...t].sort().map(d=>s.jsx("span",{className:"chip",children:d},d)),t.size===0&&s.jsx("span",{className:"muted small",children:"无"})]})]}),s.jsxs("section",{className:"card",children:[s.jsxs("h3",{children:["已启用(",c.length,")"]}),s.jsx("ul",{className:"plugin-list",children:c.map(({plugin:d})=>s.jsxs("li",{children:[s.jsx("span",{className:"plugin-name",children:d.title}),s.jsx("span",{className:"muted small",children:d.requires.length===0?"无需后端能力":d.requires.join(" · ")})]},d.id))})]}),u.length>0&&s.jsxs("section",{className:"card",children:[s.jsxs("h3",{children:["等待后端能力(",u.length,")"]}),s.jsx("ul",{className:"plugin-list",children:u.map(({plugin:d,missing:f})=>s.jsxs("li",{children:[s.jsxs("span",{className:"plugin-name",children:[d.title,d.milestone!==void 0&&s.jsx("span",{className:"chip subtle",children:d.milestone})]}),s.jsxs("span",{className:"muted small",children:["缺少:",f.join(" · ")]})]},d.id))})]})]})}const NU={id:"plugin-status",title:"插件状态",requires:[],settingsPages:[{id:"plugins",title:"插件状态",order:90,component:wU}]};function jU(e,t,n){const r=new Array(e);return new Proxy(r,{get(i,o,c){if(typeof o=="string"){const u=o.charCodeAt(0);if(u>=48&&u<=57){const d=+o;if(Number.isInteger(d)&&d>=0&&d<e){let f=i[d];if(!f){const p=t[d*2];f=i[d]={index:d,key:n(d),start:p,size:t[d*2+1],end:p+t[d*2+1],lane:0}}return f}}if(o==="length")return e}return Reflect.get(i,o,c)}})}function lo(e,t,n){let r=n.initialDeps??[],i,o=!0;function c(){const u=e();return(u.length!==r.length||u.some((f,p)=>r[p]!==f))&&(r=u,i=t(...u),n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(i),o=!1),i}return c.updateDeps=u=>{r=u},c}function Tb(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const SU=(e,t)=>Math.abs(e-t)<1.01,_U=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})};let Sl;const fp=()=>{if(Sl!==void 0)return Sl;if(typeof navigator>"u")return Sl=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Sl=!0;const e=navigator.maxTouchPoints;return Sl=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Mb=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},EU=e=>e,CU=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,i=new Array(r);for(let o=0;o<r;o++)i[o]=t+o;return i},IU=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const i=c=>{const{width:u,height:d}=c;t({width:Math.round(u),height:Math.round(d)})};if(i(Mb(n)),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(c=>{const u=()=>{const d=c[0];if(d!=null&&d.borderBoxSize){const f=d.borderBoxSize[0];if(f){i({width:f.inlineSize,height:f.blockSize});return}}i(Mb(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},cd={passive:!0},AU=typeof window>"u"?!0:"onscrollend"in window,TU=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const i=e.targetWindow;if(!i)return;const o=e.options.useScrollendEvent&&AU;let c=0;const u=o?null:_U(i,()=>t(c,!1),e.options.isScrollingResetDelay),d=m=>()=>{c=n(r),u==null||u(),t(c,m)},f=d(!0),p=d(!1);return r.addEventListener("scroll",f,cd),o&&r.addEventListener("scrollend",p,cd),()=>{r.removeEventListener("scroll",f),o&&r.removeEventListener("scrollend",p),u==null||u.cancel()}},MU=(e,t)=>TU(e,t,n=>{const{horizontal:r,isRtl:i}=e.options;return r?n.scrollLeft*(i&&-1||1):n.scrollTop}),$U=(e,t,n)=>{if(n.options.useCachedMeasurements){const r=n.indexFromElement(e),i=n.options.getItemKey(r);return n.itemSizeCache.get(i)??n.options.estimateSize(r)}if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const r=n.indexFromElement(e),i=n.options.getItemKey(r),o=n.itemSizeCache.get(i);if(o!==void 0)return o}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},RU=(e,{adjustments:t=0,behavior:n},r)=>{var i,o;(o=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||o.call(i,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},OU=RU;class zU{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,r,i;return((i=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:i.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(o=>{const c=()=>{const u=o.target,d=this.indexFromElement(u);if(!u.isConnected){this.observer.unobserve(u);for(const[f,p]of this.elementsCache)if(p===u){this.elementsCache.delete(f);break}return}this.isIndexInRange(d)&&this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(u,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var o;return(o=r())==null?void 0:o.observe(i,{box:"border-box"})},unobserve:i=>{var o;return(o=r())==null?void 0:o.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{var r,i;const o={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:EU,rangeExtractor:CU,onChange:()=>{},measureElement:$U,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const g in n){const v=n[g];v!==void 0&&(o[g]=v)}const c=this.options;let u=null,d=null,f=!1;if(c!==void 0&&c.enabled&&o.enabled&&o.anchorTo==="end"&&this.scrollElement!==null){const g=c.count,v=o.count,y=this.getMeasurements(),S=g>0?((r=y[0])==null?void 0:r.key)??c.getItemKey(0):null,k=g>0?((i=y[g-1])==null?void 0:i.key)??c.getItemKey(g-1):null;if(v!==g||g>0&&v>0&&(o.getItemKey(0)!==S||o.getItemKey(v-1)!==k)){f=!0;const N=g>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;N&&(u=[N.key,this.getScrollOffset()-N.start]);const $=o.followOnAppend===!0?"auto":o.followOnAppend||null;$&&v>g&&this.isAtEnd(c.scrollEndThreshold)&&(g===0||o.getItemKey(v-1)!==k)&&(d=$)}}this.options=o,f&&(this.pendingMin=0,this.itemSizeCacheVersion++);let p=!1,m=0;if(u&&this.scrollOffset!==null){const[g,v]=u,y=this.getMeasurements(),{count:S,getItemKey:k}=this.options;let w=0;for(;w<S&&k(w)!==g;)w++;if(w<S){const T=y[w];if(T){const N=Math.max(0,T.start+v);N!==this.scrollOffset&&(m=N-this.scrollOffset,this.scrollOffset=N,p=!0)}}}(p||d)&&(this.pendingScrollAnchor=[p?u[0]:null,p?u[1]:0,d,m])},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=lo(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,c)=>{if(c&&this._intendedScrollOffset===null&&o===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5&&(o=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const u=this.getScrollOffset();this.scrollDirection=c?u===o?this.scrollDirection:u<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=c,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,c=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},u=()=>{this._iosTouching=!1,!(!fp()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",c,cd),o.addEventListener("touchend",u,cd),this.unsubs.push(()=>{o.removeEventListener("touchstart",c),o.removeEventListener("touchend",u),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[o,c,u,d]=i;o!==null&&!u&&(fp()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),u&&this.scrollToEnd({behavior:u})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),r=this.getMaxScrollOffset();if(n<0||n>r)return;if(this._iosDeferredAdjustment<0&&n>=r-1){this._iosDeferredAdjustment=0;return}const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=lo(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,r,i,o,c,u,d,f)=>(this.prevLanes!==void 0&&this.prevLanes!==u&&(this.lanesChangedFlag=!0),this.prevLanes=u,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:i,getItemKey:o,enabled:c,lanes:u,laneAssignmentMode:d,gap:f}),{key:!1}),this.isIndexInRange=n=>n>=0&&n<this.options.count,this.getMeasurements=lo(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,scrollMargin:i,getItemKey:o,enabled:c,lanes:u,laneAssignmentMode:d,gap:f},p)=>{const m=this.itemSizeCache;if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const w of this.laneAssignments.keys())w>=n&&this.laneAssignments.delete(w);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(w=>{this.itemSizeCache.set(w.key,w.size)}));const g=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),u===1){const w=n*2;let T=this._flatMeasurements;if(!T||T.length<w){const D=new Float64Array(w);T&&g>0&&D.set(T.subarray(0,g*2)),T=D,this._flatMeasurements=T}let N;if(g===0)N=r+i;else{const D=g-1;N=T[D*2]+T[D*2+1]+f}for(let D=g;D<n;D++){const O=o(D),F=m.get(O),U=typeof F=="number"?F:this.options.estimateSize(D);T[D*2]=N,T[D*2+1]=U,N+=U+f}const $=jU(n,T,o);return this.measurementsCache=$,$}const v=this.measurementsCache.slice(0,g),y=new Array(u).fill(void 0),S=new Float64Array(u);let k=0;for(let w=0;w<g;w++){const T=v[w];T&&(y[T.lane]===void 0&&k++,y[T.lane]=w,S[T.lane]=T.end)}for(let w=g;w<n;w++){const T=o(w),N=this.laneAssignments.get(w);let $,D;const O=d==="estimate"||m.has(T);if(N!==void 0&&this.options.lanes>1){$=N;const P=y[$],R=P!==void 0?v[P]:void 0;D=R?R.end+f:r+i}else if(k===u){let P=0,R=S[0],Z=y[0];for(let E=1;E<u;E++){const C=S[E];(C<R||C===R&&y[E]<Z)&&(P=E,R=C,Z=y[E])}$=P,D=R+f,O&&this.laneAssignments.set(w,$)}else $=w%this.options.lanes,D=r+i,O&&this.laneAssignments.set(w,$);const F=m.get(T),U=typeof F=="number"?F:this.options.estimateSize(w),M=D+U;v[w]={index:w,start:D,size:U,end:M,key:T,lane:$},y[$]===void 0&&k++,y[$]=w,S[$]=M}return this.measurementsCache=v,v},{key:!1,debug:()=>this.options.debug}),this.calculateRange=lo(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,i,o)=>n.length===0||r===0?(this.range=null,null):(this.range=LU(n,r,i,o,o===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=lo(()=>{let n=null,r=null;const i=this.calculateRange();return i&&(n=i.startIndex,r=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,i,o,c)=>o===null||c===null?[]:n({startIndex:o,endIndex:c,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(i!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),c=Math.max(0,i-o),u=Math.min(this.options.count-1,i+o);return n>=c&&n<=u}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((c,u)=>{c.isConnected||(this.observer.unobserve(c),this.elementsCache.delete(u))});return}const r=this.indexFromElement(n);if(!this.isIndexInRange(r))return;const i=this.options.getItemKey(r),o=this.elementsCache.get(i);o!==n&&(o&&this.observer.unobserve(o),this.observer.observe(n),this.elementsCache.set(i,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var i,o;if(!this.isIndexInRange(n))return;let c,u,d;const f=this._flatMeasurements;if(this.options.lanes===1&&f!==null)d=this.options.getItemKey(n),u=f[n*2],c=f[n*2+1];else{const g=this.measurementsCache[n];if(!g)return;d=g.key,u=g.start,c=g.size}const p=this.itemSizeCache.get(d)??c,m=r-p;if(m!==0){const g=this.options.anchorTo==="end"&&((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,v=g?this.getTotalSize():0,y=this.getScrollOffset()+this.scrollAdjustments,k=!this.itemSizeCache.has(d)?u<y:u+p<=y&&this.scrollDirection!=="backward",w=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:d,start:u,size:c,end:u+c,lane:0},m,this):k);(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(d,r),this.itemSizeCacheVersion++;let T=!1;g?T=this.applyScrollAdjustment(this.getTotalSize()-v):w&&(T=this.applyScrollAdjustment(m)),this.notify(T)}},this.getVirtualItems=lo(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let o=0,c=n.length;o<c;o++){const u=n[o],d=r[u];i.push(d)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length===0)return;const i=this._flatMeasurements,o=this.options.lanes===1&&i!=null,c=mS(0,r.length-1,o?u=>i[u*2]:u=>Tb(r[u]).start,n);return Tb(r[c])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,r,i=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),c=this.getScrollOffset();r==="auto"&&(r=n>=c+o?"end":"start"),r==="center"?n+=(i-o)/2:r==="end"&&(n-=o);const u=this.getMaxScrollOffset();return Math.max(Math.min(u,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getSize(),o=this.getScrollOffset(),c=this.measurementsCache[n];if(!c)return;if(r==="auto")if(c.end>=o+i-this.options.scrollPaddingEnd)r="end";else if(c.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const u=r==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(u,r,c.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:i="auto"}={})=>{this._iosDeferredAdjustment=0;const o=this.getOffsetForAlignment(n,r),c=this.now();this.scrollState={index:null,align:r,behavior:i,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:i="auto"}={})=>{this._iosDeferredAdjustment=0,n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getOffsetForIndex(n,r);if(!o)return;const[c,u]=o,d=this.now();this.scrollState={index:n,align:u,behavior:i,startedAt:d,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const i=this.getScrollOffset()+n,o=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;if(r.length===0)i=this.options.paddingStart;else if(this.options.lanes===1){const o=r.length-1,c=this._flatMeasurements;c!=null?i=c[o*2]+c[o*2+1]:i=((n=r[o])==null?void 0:n.end)??0}else{const o=Array(this.options.lanes).fill(null);let c=r.length-1;for(;c>=0&&o.some(u=>u===null);){const u=r[c];o[u.lane]===null&&(o[u.lane]=u.end),c--}i=Math.max(...o.filter(u=>u!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const r=this.getMeasurements();for(const i of r)i&&this.itemSizeCache.has(i.key)&&n.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return n},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this._intendedScrollOffset=n+(r??0),this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){return t===0?!1:fp()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=t,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=r?r[0]:this.scrollState.lastTargetOffset,o=1,c=i!==this.scrollState.lastTargetOffset;if(!c&&SU(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.getScrollOffset()!==i&&this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,c){const u=this.getSize()||600,d=Math.abs(i-this.getScrollOffset()),f=this.scrollState.behavior==="smooth"&&d>u;this.scrollState.lastTargetOffset=i,f||(this.scrollState.behavior="auto"),this._scrollToOffset(i,{adjustments:void 0,behavior:f?"smooth":"auto"})}this.scheduleScrollReconcile()}}const mS=(e,t,n,r)=>{for(;e<=t;){const i=(e+t)/2|0,o=n(i);if(o<r)e=i+1;else if(o>r)t=i-1;else return i}return e>0?e-1:0};function PU(e,t,n){let r=0;for(;r<=t;){const i=(r+t)/2|0,o=e[i*2];if(o<n)r=i+1;else if(o>n)t=i-1;else return i}return r>0?r-1:0}function LU(e,t,n,r,i){const o=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:o};if(r===1&&i!==null){const f=PU(i,o,n);let p=f;const m=n+t;for(;p<o&&i[p*2]+i[p*2+1]<m;)p++;return{startIndex:f,endIndex:p}}let u=mS(0,o,f=>e[f].start,n),d=u;if(r===1)for(;d<o&&e[d].end<n+t;)d++;else if(r>1){const f=Array(r).fill(0);for(;d<o&&f.some(m=>m<n+t);){const m=e[d];f[m.lane]=m.end,d++}const p=Array(r).fill(n+t);for(;u>=0&&p.some(m=>m>=n);){const m=e[u];p[m.lane]=m.start,u--}u=Math.max(0,u-u%r),d=Math.min(o,d+(r-1-d%r))}return{startIndex:u,endIndex:d}}const hp=typeof document<"u"?b.useLayoutEffect:b.useEffect;function DU({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...r}){const i=b.useReducer(p=>p+1,0)[1],o=b.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=n;const c=p=>{const m=o.current;if(!m.enabled||!m.container)return;const g=p.getTotalSize();if(g!==m.lastSize){m.lastSize=g;const v=p.options.horizontal?"width":"height";m.container.style[v]=`${g}px`}},u=p=>{const m=o.current;if(!m.enabled||!m.container)return;c(p);const g=!!p.options.horizontal,v=m.mode==="transform",y=g?"left":"top",S=p.options.scrollMargin,k=p.getVirtualItems();for(const w of k){const T=w.start-S,N=p.elementsCache.get(w.key);N&&m.lastPositions.get(N)!==T&&(m.lastPositions.set(N,T),v?N.style.transform=g?`translate3d(${T}px, 0, 0)`:`translate3d(0, ${T}px, 0)`:N.style[y]=`${T}px`)}},d={...r,onChange:(p,m)=>{var g;const v=o.current;let y=!0;if(v.enabled){u(p);const S=p.range,k=v.prevRange;y=!k||k.isScrolling!==p.isScrolling||k.startIndex!==(S==null?void 0:S.startIndex)||k.endIndex!==(S==null?void 0:S.endIndex),y&&(v.prevRange=S?{startIndex:S.startIndex,endIndex:S.endIndex,isScrolling:p.isScrolling}:null)}y&&(e&&m?Bm.flushSync(i):i()),(g=r.onChange)==null||g.call(r,p,m)}},[f]=b.useState(()=>{const p=new zU(d);return Object.assign(p,{containerRef:m=>{const g=o.current;if(g.container=m,g.lastSize=null,m&&g.enabled){const v=p.getTotalSize();g.lastSize=v;const y=p.options.horizontal?"width":"height";m.style[y]=`${v}px`}}})});return f.setOptions(d),hp(()=>f._didMount(),[]),hp(()=>(c(f),f._willUpdate())),hp(()=>{u(f)}),f}function FU(e){return DU({observeElementRect:IU,observeElementOffset:MU,scrollToFn:OU,...e})}const Rd={user:"用户",context:"上下文",system:"系统",assistant:"助手",attempt:"失败尝试",tool:"工具",compaction:"压缩"},gS={ok:"已完成",error:"失败",running:"运行中",interrupted:"已中断"},BU={completed:"已完成",aborted:"已停止",error:"失败",blocked:"已阻止","max-tokens":"达到输出上限",interrupted:"已中断",forked:"已分叉"};function UU(e){return e.turn===null?"轮次之间":`第 ${e.turn} 轮`}function HU(e){return e.end===null?"进行中":e.reason===void 0?"":BU[e.reason.kind]??e.reason.kind}function xS(e){if(e.kind!=="assistant"||e.request.usage===void 0)return;const t=e.request.usage;return t.inputTokens+(t.cacheReadTokens??0)+(t.cacheWriteTokens??0)}function Fl(e){return e.end===null||e.end<e.start?void 0:e.end-e.start}function ud(e){return e.kind==="assistant"?e.content.filter(t=>t.type==="tool-call").length:0}function ZU({record:e,totals:t,onClose:n}){const r=WU(e,t),[i,o]=b.useState(r[0].id),c=r.find(u=>u.id===i)??r[0];return s.jsxs("aside",{className:"inspector","aria-label":"事件详情",children:[s.jsxs("header",{className:"inspector-head",children:[s.jsx("span",{className:`kind-badge kind-${e.kind}`,children:Rd[e.kind]}),s.jsx("span",{className:"inspector-title",title:e.title,children:VU(e)}),s.jsx("button",{className:"ghost icon",onClick:n,"aria-label":"关闭详情",children:s.jsx(ee,{name:"close"})})]}),s.jsx("nav",{className:"inspector-tabs",role:"tablist",children:r.map(u=>s.jsx("button",{role:"tab","aria-selected":u.id===c.id,className:u.id===c.id?"active":"",onClick:()=>o(u.id),children:u.label},u.id))}),s.jsx("div",{className:"inspector-body",children:c.render()})]})}function VU(e){switch(e.kind){case"assistant":return`请求 #${e.request.index}${e.request.model===void 0?"":` · ${e.request.model}`}`;case"tool":return e.name;case"context":return e.title==="Compacted history"?"已压缩的历史":`上下文 · ${e.origin.kind}`;case"system":return"系统提示词";case"attempt":return"失败的模型尝试";default:return Rd[e.kind]}}function WU(e,t){switch(e.kind){case"assistant":return[{id:"summary",label:"概述",render:()=>s.jsx(qU,{record:e})},{id:"raw",label:"原始输出",render:()=>s.jsx(pp,{content:e.content})},{id:"usage",label:"用量",render:()=>s.jsx(GU,{record:e,totals:t})},{id:"timing",label:"计时",render:()=>s.jsx(KU,{record:e})}];case"tool":return[{id:"summary",label:"概述",render:()=>s.jsx(Zi,{rows:[["状态",s.jsx(Fu,{record:e})],["工具",s.jsx("code",{children:e.name})],["调用 ID",s.jsx("code",{children:e.callId})],["开始时间",Ui(e.start)],["时长",e.end===null?"运行中":Ts(Fl(e))],["审批",e.approval===void 0?"无需审批":e.approval.outcome??"等待中"],["错误",e.error===void 0?void 0:`${e.error.message}${e.error.code===void 0?"":` (${e.error.code})`}`]]})},{id:"payload",label:"参数",render:()=>s.jsx("pre",{className:"payload",children:e.arguments===""?"未捕获参数":Fm(e.arguments)})},{id:"result",label:"结果",render:()=>e.result===void 0?s.jsx("p",{className:"muted",children:"未捕获结果"}):s.jsx(pp,{content:e.result})}];case"user":case"context":return[{id:"summary",label:"概述",render:()=>s.jsxs(s.Fragment,{children:[s.jsx(Zi,{rows:[["来源",e.origin.human?"用户":e.origin.kind],["时间",Ui(e.start)],["附件",e.imageCount+e.fileCount===0?void 0:`图片 ×${e.imageCount} · 文件 ×${e.fileCount}`]]}),s.jsx("div",{className:"label",children:"预览"}),s.jsx(pp,{content:e.content})]})},{id:"raw",label:"原始内容",render:()=>s.jsx("pre",{className:"payload",children:JSON.stringify(e.content,null,2)})}];case"system":return[{id:"prompt",label:"系统提示词",render:()=>s.jsx("pre",{className:"payload",children:e.text})}];case"attempt":return[{id:"summary",label:"概述",render:()=>s.jsx(Zi,{rows:[["状态",s.jsx(Fu,{record:e})],["开始时间",Ui(e.start)],["时长",Ts(Fl(e))],["错误",e.error===void 0?"尝试在没有输出的情况下结束":`${e.error.message}${e.error.code===void 0?"":` (${e.error.code})`}`]]})}];case"compaction":return[{id:"summary",label:"概述",render:()=>s.jsx(Zi,{rows:[["状态",s.jsx(Fu,{record:e})],["开始时间",Ui(e.start)],["时长",e.end===null?"运行中":Ts(Fl(e))],["已压缩",e.shadowedTokenCount===void 0?void 0:`${vn(e.shadowedTokenCount)} tok`],["输入 / 输出",e.usage===void 0?void 0:`${vn(e.usage.inputTokens)} / ${vn(e.usage.outputTokens)} tok`],["错误",e.error]]})}]}}function Fu({record:e}){return s.jsx("span",{className:`status-text status-${e.status}`,children:gS[e.status]})}function Zi({rows:e}){return s.jsx("dl",{className:"facts",children:e.filter(([,t])=>t!==void 0&&t!=="").map(([t,n])=>s.jsxs("div",{className:"fact",children:[s.jsx("dt",{children:t}),s.jsx("dd",{children:n})]},t))})}function qU({record:e}){const t=e.request,n=e.content.filter(i=>i.type==="text").map(i=>i.type==="text"?i.text:"").join(""),r=e.content.filter(i=>i.type==="tool-call");return s.jsxs(s.Fragment,{children:[s.jsx(Zi,{rows:[["状态",s.jsx(Fu,{record:e})],["请求",`#${t.index}`],["提供方",t.provider],["模型",t.model],["推理强度",t.reasoningEffort],["可用工具",t.toolCount===void 0?void 0:String(t.toolCount)],["工具调用",r.length===0?void 0:String(r.length)],["重试",t.retries===0?void 0:String(t.retries)],["上次尝试错误",t.lastRetryError===void 0?void 0:`${t.lastRetryError.message}${t.lastRetryError.code===void 0?"":` (${t.lastRetryError.code})`}`]]}),n.trim()!==""&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"label",children:"助手消息"}),s.jsx(Ki,{text:n,className:"inspector-markdown"})]}),n.trim()===""&&r.length>0&&s.jsx("p",{className:"muted small",children:"(仅工具调用)"}),r.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"label",children:"工具调用"}),s.jsx("ul",{className:"call-list",children:r.map(i=>s.jsxs("li",{children:[s.jsx("code",{children:i.name})," ",s.jsx("span",{className:"muted",children:i.arguments.slice(0,120)})]},i.callId))})]})]})}function pp({content:e}){return e.length===0?s.jsx("p",{className:"muted",children:"无内容"}):s.jsx("div",{className:"raw-blocks",children:e.map((t,n)=>{switch(t.type){case"reasoning":return s.jsxs("details",{className:"raw-block reasoning-block",children:[s.jsx("summary",{children:"思考"}),s.jsx(Ki,{text:t.text,className:"inspector-markdown"})]},n);case"text":return s.jsx("pre",{className:"payload",children:t.text},n);case"tool-call":return s.jsxs("div",{className:"raw-block",children:[s.jsxs("div",{className:"label",children:["工具调用 · ",s.jsx("code",{children:t.name})]}),s.jsx("pre",{className:"payload",children:Fm(t.arguments)})]},n);case"image":return s.jsxs("div",{className:"raw-block muted small",children:["🖼 ",t.name??`图片 ${n+1}`," ",t.width!==void 0?`${t.width}×${t.height}`:""]},n);case"file":return s.jsxs("div",{className:"raw-block muted small",children:["📎 ",t.name??"文件"," ",t.size===void 0?"":`${vn(t.size)}B`]},n);default:return s.jsxs("div",{className:"raw-block muted small",children:["[",t.kind,"]"]},n)}})})}function GU({record:e,totals:t}){const n=e.request.usage;return s.jsxs(s.Fragment,{children:[s.jsx("h4",{className:"usage-heading",children:"本次请求"}),n===void 0?s.jsx("p",{className:"muted",children:"未报告用量"}):s.jsx(Zi,{rows:[["输入(未缓存)",`${vn(n.inputTokens)} tok`],["缓存读取",n.cacheReadTokens===void 0?void 0:`${vn(n.cacheReadTokens)} tok`],["缓存写入",n.cacheWriteTokens===void 0?void 0:`${vn(n.cacheWriteTokens)} tok`],["输入合计",`${vn(xS(e))} tok`],["输出",`${vn(n.outputTokens)} tok`],["其中推理",n.reasoningTokens===void 0?void 0:`${vn(n.reasoningTokens)} tok`],["总计",n.totalTokens===void 0?void 0:`${vn(n.totalTokens)} tok`]]}),s.jsx("h4",{className:"usage-heading",children:"已加载窗口累计"}),s.jsx(Zi,{rows:[["请求数",String(t.requests)],["输入(未缓存)",`${vn(t.inputTokens)} tok`],["缓存读取",`${vn(t.cacheReadTokens)} tok`],["输出",`${vn(t.outputTokens)} tok`],["其中推理",`${vn(t.reasoningTokens)} tok`]]})]})}function KU({record:e}){const[t,n]=b.useState(!1),r=e.request;return s.jsx(Zi,{rows:[["开始时间",s.jsx("button",{className:"link-button",onClick:()=>n(i=>!i),title:t?"显示本地时间":"显示 Unix 时间戳",children:t?String(e.start):Ui(e.start)})],["总时长",e.end===null?"运行中":Ts(Fl(e))],["首 token 延迟",r.ttftMs===void 0?"不可用(步骤开始时间或首 token 不在已加载范围内)":Ts(r.ttftMs)],["生成",r.decodeMs===void 0?e.live?"运行中":"不可用":Ts(r.decodeMs)],["吞吐量",r.tokensPerSecond===void 0?r.usage===void 0?"用量不可用":"时长过短":`${r.tokensPerSecond.toFixed(1)} tok/s`],["工具调用",ud(e)===0?void 0:String(ud(e))],["计时来源",e.live?"会话时间戳(运行中)":"会话时间戳"]]})}const Tu=14,YU=b.memo(function({model:t,mode:n,brush:r,selectedId:i,onBrush:o,onSelect:c}){const u=b.useMemo(()=>u2(t),[t]),d=b.useMemo(()=>Qw.map((P,R)=>({...P,index:R})).filter(P=>P.id!=="compaction"||u.some(R=>R.lane===P.index)),[u]),f=new Map(d.map((P,R)=>[P.index,R])),p=t.span,[m,g]=b.useState(null),v=n==="actual"&&p!==null?XU(m,p):null,y=b.useRef(null),[S,k]=b.useState(null),w=b.useRef(null),T=t.records.length,N=(P,R)=>n==="equal"?T===0?0:P/T:v===null||v.end===v.start?0:(R-v.start)/(v.end-v.start),$=P=>{var Z;const R=(Z=y.current)==null?void 0:Z.getBoundingClientRect();return R===void 0||R.width===0?0:Math.min(1,Math.max(0,(P-R.left)/R.width))},D=P=>{if(P.button===2&&v!==null&&p!==null&&(v.start>p.start||v.end<p.end)){w.current={x:P.clientX,view:v};return}if(P.button!==0)return;const R=$(P.clientX);k({x0:R,x1:R})},O=P=>{if(w.current!==null&&p!==null&&y.current!==null){const R=(P.clientX-w.current.x)/y.current.clientWidth,Z=w.current.view.end-w.current.view.start;g(h2(w.current.view,-R*Z,p));return}S!==null&&k({...S,x1:$(P.clientX)})},F=()=>{if(w.current=null,S===null)return;const[P,R]=S.x0<S.x1?[S.x0,S.x1]:[S.x1,S.x0];if(k(null),!(R-P<.005)){if(n==="equal")o({mode:"equal",from:Math.floor(P*T),to:Math.max(Math.floor(P*T),Math.ceil(R*T)-1)});else if(v!==null){const Z=v.end-v.start;o({mode:"actual",range:{start:v.start+P*Z,end:v.start+R*Z}})}}},U=P=>{if(n!=="actual"||v===null||p===null)return;const R=v.end-v.start;g(f2(v,v.start+$(P.clientX)*R,P.deltaY>0?1.25:.8,p))};if(T===0||p===null)return s.jsx("div",{className:"overview empty-overview muted small",children:"无计时数据"});const M=r===null?null:r.mode==="equal"?n==="equal"?{left:r.from/T,right:(r.to+1)/T}:null:n==="actual"?{left:N(0,r.range.start),right:N(0,r.range.end)}:null;return s.jsxs("div",{className:"overview",onContextMenu:P=>{P.preventDefault(),w.current===null&&o(null)},children:[s.jsx("div",{className:"overview-lanes",children:d.map(P=>s.jsx("div",{className:"lane-label",style:{height:Tu},children:QU(P.id)},P.id))}),s.jsxs("div",{className:"overview-track",ref:y,style:{height:d.length*(Tu+2)},onMouseDown:D,onMouseMove:O,onMouseUp:F,onMouseLeave:F,onWheel:U,children:[u.map((P,R)=>{const Z=f.get(P.lane)??0,E=N(R,P.start),C=n==="equal"?(R+1)/T:N(R,P.end);if(C<0||E>1)return null;const I=P.record,L=Math.max(0,Math.min(1,C)-Math.max(0,E)),W=n==="actual"&&P.firstTokenAt!==void 0&&P.end>P.start?(P.firstTokenAt-P.start)/(P.end-P.start):null;return s.jsx("div",{className:`bar kind-${I.kind} status-${I.status} ${P.instant&&n==="actual"?"instant":""} ${I.id===i?"selected":""}`,style:{left:`${Math.max(0,E)*100}%`,width:n==="equal"?`calc(${L*100}% - 1px)`:`max(2px, ${L*100}%)`,top:Z*(Tu+2),height:Tu,...W===null?{}:{"--ttft":`${Math.min(100,Math.max(0,W*100))}%`}},title:JU(I,P.firstTokenAt),onMouseUp:H=>{S!==null&&Math.abs(S.x1-S.x0)<.005&&H.button===0&&c(I)}},I.id)}),M!==null&&s.jsx("div",{className:"brush",style:{left:`${Math.max(0,M.left)*100}%`,width:`${(Math.min(1,M.right)-Math.max(0,M.left))*100}%`}}),S!==null&&s.jsx("div",{className:"brush dragging",style:{left:`${Math.min(S.x0,S.x1)*100}%`,width:`${Math.abs(S.x1-S.x0)*100}%`}})]}),s.jsx("div",{className:"overview-scale muted",children:n==="actual"&&v!==null?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Ui(v.start)}),s.jsxs("span",{children:["总计 ",Ts(p.end-p.start),m!==null?" · 已缩放":""]}),s.jsx("span",{children:Ui(v.end)})]}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:[T," 条记录(等宽)"]}),s.jsxs("span",{children:["总计 ",Ts(p.end-p.start)]}),s.jsx("span",{children:"拖动选择区间 · 右键清除"})]})})]})});function XU(e,t){if(e===null)return t;const n=Math.max(t.start,e.start),r=Math.min(t.end,e.end);return r>n?{start:n,end:r}:t}function QU(e){return e==="input"?"输入":e==="model"?"模型":e==="tool"?"工具":"压缩"}function JU(e,t){const n=[`${Rd[e.kind]} · ${e.title}`,`开始于 ${Ui(e.start)}`];return e.end===null?n.push("进行中(只显示开始标记)"):n.push(`总计 ${Ts(e.end-e.start)}`),e.kind==="assistant"&&t!==void 0&&e.end!==null&&n.push(`首 token ${Ts(t-e.start)} · 解码 ${Ts(e.end-t)}`),n.join(`
|
|
234
|
-
`)}const e5=32,t5=34,n5=60;function s5({session:e,state:t}){const n=b.useMemo(()=>s2(t.events,t.live,{now:Date.now()}),[t.events,t.live,t.version]),[r,i]=b.useState("equal"),[o,c]=b.useState(null),[u,d]=b.useState(""),[f,p]=b.useState(new Set),[m,g]=b.useState(!0),[v,y]=b.useState(null),S=n.records.find(P=>P.id===v)??null,k=b.useMemo(()=>r5(n,{brush:o,query:u,collapsed:f,showCalls:m}),[n,o,u,f,m]),w=b.useMemo(()=>k.flatMap(P=>P.type==="record"?[P.record]:[]),[k]),T=b.useRef(null),N=Xw(n5),$=N.following,D=FU({count:k.length,getScrollElement:()=>T.current,estimateSize:P=>{var R;return((R=k[P])==null?void 0:R.type)==="group"?t5:e5},getItemKey:P=>{var R;return((R=k[P])==null?void 0:R.key)??P},overscan:12});b.useLayoutEffect(()=>{$.current&&k.length>0&&D.scrollToIndex(k.length-1,{align:"end"})},[k.length,t.version,D]),b.useEffect(()=>{if(v===null)return;const P=k.findIndex(R=>R.type==="record"&&R.record.id===v);P!==-1&&D.scrollToIndex(P,{align:"auto"})},[v]);const O=P=>p(R=>{const Z=new Set(R);return Z.has(P)?Z.delete(P):Z.add(P),Z}),F=n.groups.length>0&&n.groups.every(P=>f.has(P.key)),U=P=>{if(P.key!=="ArrowDown"&&P.key!=="ArrowUp"&&P.key!=="Escape")return;if(P.preventDefault(),P.key==="Escape"){y(null);return}const R=w.findIndex(E=>E.id===v),Z=w[P.key==="ArrowDown"?Math.min(w.length-1,R+1):Math.max(0,R-1)];Z!==void 0&&y(Z.id)},M=n.totals;return s.jsxs("div",{className:"trajectory",children:[s.jsxs("div",{className:"traj-toolbar",role:"toolbar","aria-label":"轨迹工具栏",children:[s.jsxs("button",{className:`toggle ${r==="actual"?"on":""}`,onClick:()=>{i(P=>P==="equal"?"actual":"equal"),c(null)},title:r==="equal"?"使用实际时长":"使用等宽操作",children:["⏱ ",r==="equal"?"等宽":"实际时间"]}),s.jsxs("button",{className:"toggle",onClick:()=>p(F?new Set:new Set(n.groups.map(P=>P.key))),children:["⊟ ",F?"展开所有轮次":"收起所有轮次"]}),s.jsxs("button",{className:`toggle ${m?"":"on"}`,onClick:()=>g(P=>!P),children:["⊟ ",m?"收起所有调用":"展开所有调用"]}),s.jsx("input",{className:"traj-search",value:u,onChange:P=>d(P.target.value),placeholder:"搜索轨迹","aria-label":"搜索轨迹"}),s.jsxs("span",{className:"traj-totals muted small",title:"已加载窗口内的累计",children:[M.requests," 次请求 · 输入 ",vn(M.inputTokens+M.cacheReadTokens+M.cacheWriteTokens)," · 输出 ",vn(M.outputTokens)," · ",M.toolCalls," 次工具调用",M.errors>0?` · ${M.errors} 个错误`:""]})]}),s.jsx(YU,{model:n,mode:r,brush:o,selectedId:v,onBrush:c,onSelect:P=>y(P.id)}),o!==null&&s.jsxs("div",{className:"brush-note small",children:["已按时间区间筛选,显示 ",w.length," 条记录 ",s.jsx("button",{className:"link-button",onClick:()=>c(null),children:"清除"})]}),s.jsxs("div",{className:"traj-main",children:[s.jsxs("div",{className:"ledger",ref:T,onScroll:N.onScroll,onWheel:N.onWheel,tabIndex:0,onKeyDown:U,role:"grid","aria-label":"轨迹事件表",children:[s.jsxs("div",{className:"ledger-head",role:"row",children:[s.jsx("span",{}),s.jsx("span",{children:"类型"}),s.jsx("span",{children:"内容"}),s.jsx("span",{className:"num",children:"输入"}),s.jsx("span",{className:"num",children:"输出"}),s.jsx("span",{className:"num",children:"思考"}),s.jsx("span",{className:"num",children:"时间"}),s.jsx("span",{children:"模型"}),s.jsx("span",{className:"num",children:"工具"})]}),t.hasMore&&s.jsx("button",{className:"link-button load-older",disabled:t.loadingOlder,onClick:()=>void e.loadOlder(),children:t.loadingOlder?"正在加载更早的历史…":"加载更早的历史"}),k.length===0&&s.jsx("div",{className:"empty",children:t.status==="opening"?"正在加载轨迹…":u!==""?"没有匹配的记录":"还没有记录"}),s.jsx("div",{style:{height:D.getTotalSize(),position:"relative"},children:D.getVirtualItems().map(P=>{const R=k[P.index];return s.jsx("div",{className:"vrow",style:{transform:`translateY(${P.start}px)`,height:P.size},children:R.type==="group"?s.jsx(i5,{row:R,onToggle:()=>O(R.group.key)}):s.jsx(a5,{row:R,selected:R.record.id===v,onSelect:()=>y(Z=>Z===R.record.id?null:R.record.id)})},P.key)})})]}),S!==null&&s.jsx(ZU,{record:S,totals:n.totals,onClose:()=>y(null)},S.id)]})]})}function r5(e,t){const n=new Set;let r=e.records;if(t.brush!==null){const c=t.brush;r=c.mode==="equal"?r.slice(c.from,c.to+1):r.filter(u=>d2(u,c.range))}for(const c of p2(r,t.query))n.add(c.id);const i=t.brush!==null||t.query.trim()!=="",o=[];for(const c of e.groups){const u=c.records.filter(p=>n.has(p.id)&&(t.showCalls||p.kind!=="tool"));if(i&&u.length===0)continue;const d=t.collapsed.has(c.key);if(o.push({type:"group",key:`g:${c.key}`,group:c,collapsed:d,matches:u.length}),d)continue;let f=null;for(const p of u){const m=p.step!==null&&p.step!==f?p.step:null;p.step!==null&&(f=p.step),o.push({type:"record",key:p.id,record:p,stepStart:m})}}return o}const i5=b.memo(function({row:t,onToggle:n}){var u,d;const r=t.group,i=r.records.filter(f=>f.kind==="tool").length,o=r.end===null?null:r.end-r.start,c=HU(r);return s.jsxs("button",{className:`group-row ${r.end===null?"open":""} reason-${((u=r.reason)==null?void 0:u.kind)??"none"}`,onClick:n,"aria-expanded":!t.collapsed,children:[s.jsx("span",{className:"chevron",children:t.collapsed?"▸":"▾"}),s.jsx("span",{className:"group-title",children:UU(r)}),s.jsxs("span",{className:"muted small",children:[r.steps.length>0&&`${r.steps.length} 个步骤`,i>0&&` · ${i} 个工具调用`,o!==null&&` · ${Ts(o)}`,r.partialStart&&" · 开头在已加载范围之外"]}),c!==""&&s.jsx("span",{className:`group-reason reason-${r.end===null?"running":((d=r.reason)==null?void 0:d.kind)??"none"}`,children:c})]})}),a5=b.memo(function({row:t,selected:n,onSelect:r}){var u;const i=t.record,o=i.kind==="assistant",c=Fl(i);return s.jsxs("div",{className:`record-row kind-${i.kind} status-${i.status} ${n?"selected":""} ${t.stepStart!==null?"step-start":""}`,onClick:r,role:"row","aria-selected":n,children:[s.jsx("span",{className:"gutter muted",children:t.stepStart!==null?`第 ${t.stepStart} 步`:""}),s.jsx("span",{children:s.jsx("span",{className:`kind-badge kind-${i.kind}`,children:o?`#${i.request.index}`:Rd[i.kind]})}),s.jsxs("span",{className:"record-content",title:i.preview,children:[i.status==="running"&&s.jsx("span",{className:"running-dot"}),i.status==="error"&&s.jsxs("span",{className:"status-text status-error",children:[gS.error," · "]}),i.kind==="tool"?s.jsxs(s.Fragment,{children:[s.jsx("code",{className:"tool-name-inline",children:i.name})," ",s.jsx("span",{className:"muted",children:i.preview})]}):i.preview||s.jsx("span",{className:"muted",children:"(无内容)"})]}),s.jsx("span",{className:"num",children:o?vn(xS(i)):""}),s.jsx("span",{className:"num",children:o&&i.request.usage!==void 0?vn(i.request.usage.outputTokens):""}),s.jsx("span",{className:"num",children:o&&((u=i.request.usage)==null?void 0:u.reasoningTokens)!==void 0?vn(i.request.usage.reasoningTokens):""}),s.jsx("span",{className:"num",children:i.status==="running"?"…":c!==void 0&&(o||i.kind==="tool"||i.kind==="compaction"||i.kind==="attempt")?Ts(c):""}),s.jsx("span",{className:"model-cell",children:o?i.request.model??"":""}),s.jsx("span",{className:"num",children:o&&ud(i)>0?ud(i):""})]})}),o5={id:"trajectory",title:"轨迹",requires:["sessions"],sessionViews:[{id:"trajectory",title:"轨迹",order:10,component:s5}]};aw();Fn(U2);Fn(o5);Fn(xU);Fn(vU);Fn(yU);Fn(bU);Fn(kU);Fn(NU);Fn(UB);Fn(HB);Fn(oz);Fn(lz);Fn(z6);Fn(P6);Fn(rB);Fn(yB);for(const e of H2)Fn(e);const vS=tE.createRoot(document.getElementById("root"));function mp(e){const t=new NM({url:o$(e),clientInfo:{name:"adg-web",version:"0.1.0"}});t.start(),vS.render(s.jsxs(t2,{children:[s.jsx(WO,{client:t}),s.jsx(e2,{client:t})]}))}const $b=Em?null:Jk();Em?mp(null):$b===null?vS.render(s.jsx(YO,{onSubmit:e=>{a$(e),mp(e)}})):mp($b);
|
|
235
|
-
//# sourceMappingURL=index-DAKeB3Cw.js.map
|