dsh-multigameassistant 2.2.2 → 2.3.0
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/cordis.patch.yml +6 -2
- package/lib/analyzer.js +80 -15
- package/lib/{chunk-LXHF6AKU.js → chunk-7EFZ5KR6.js} +99 -6
- package/lib/{chunk-CCYE6H2F.js → chunk-AJMAUHPI.js} +7 -5
- package/lib/{chunk-RGEGJH6R.js → chunk-TXW3NMBH.js} +209 -10
- package/lib/{chunk-DSWWQWQH.js → chunk-VBWSM7LF.js} +28 -9
- package/lib/{chunk-6YPSKAQ5.js → chunk-VG32XPZH.js} +91 -52
- package/lib/{chunk-TELJUUBZ.js → chunk-X5YYRNYA.js} +24 -13
- package/lib/{chunk-KMVQK5CI.js → chunk-Y3ZZBBLV.js} +1 -1
- package/lib/emulator.js +810 -12
- package/lib/feishu.js +4 -4
- package/lib/game-intel.js +1006 -53
- package/lib/gateway.js +3 -3
- package/lib/guard.js +159 -42
- package/lib/intervene.js +4 -4
- package/lib/low-context.js +2 -2
- package/lib/monitor.js +3 -3
- package/lib/notify.js +4 -4
- package/lib/orchestrator.js +6 -6
- package/lib/qqbot.js +4 -4
- package/lib/runner.js +3 -3
- package/lib/scheduler.js +1 -1
- package/lib/script-registry.js +6 -6
- package/package.json +1 -1
- package/skills/game-intel.md +12 -0
- package/skills/script-analysis.md +27 -2
- package/web/assets/index-CNGPsX3a.css +1 -0
- package/web/assets/index-mX8hPa2E.js +256 -0
- package/web/assets/index-mX8hPa2E.js.map +1 -0
- package/web/index.html +2 -2
- package/web/assets/index-DwItOcWq.css +0 -1
- package/web/assets/index-YiJ--jV1.js +0 -255
- package/web/assets/index-YiJ--jV1.js.map +0 -1
- /package/lib/{chunk-CCYE6H2F.js.LEGAL.txt → chunk-AJMAUHPI.js.LEGAL.txt} +0 -0
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
var XC=Object.defineProperty;var sy=e=>{throw TypeError(e)};var QC=(e,t,s)=>t in e?XC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var ht=(e,t,s)=>QC(e,typeof t!="symbol"?t+"":t,s),Qm=(e,t,s)=>t.has(e)||sy("Cannot "+s);var De=(e,t,s)=>(Qm(e,t,"read from private field"),s?s.call(e):t.get(e)),Ht=(e,t,s)=>t.has(e)?sy("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),Kt=(e,t,s,i)=>(Qm(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),bt=(e,t,s)=>(Qm(e,t,"access private method"),s);var iy=(e,t,s,i)=>({set _(r){Kt(e,t,r,s)},get _(){return De(e,t,i)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function s(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(r){if(r.ep)return;r.ep=!0;const o=s(r);fetch(r.href,o)}})();function $g(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Jm={exports:{}},Tl={},ef={exports:{}},kt={};/**
|
|
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 ry;function JC(){if(ry)return kt;ry=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.iterator;function g(G){return G===null||typeof G!="object"?null:(G=p&&G[p]||G["@@iterator"],typeof G=="function"?G:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,j={};function y(G,K,Z){this.props=G,this.context=K,this.refs=j,this.updater=Z||x}y.prototype.isReactComponent={},y.prototype.setState=function(G,K){if(typeof G!="object"&&typeof G!="function"&&G!=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,G,K,"setState")},y.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function k(){}k.prototype=y.prototype;function _(G,K,Z){this.props=G,this.context=K,this.refs=j,this.updater=Z||x}var S=_.prototype=new k;S.constructor=_,N(S,y.prototype),S.isPureReactComponent=!0;var E=Array.isArray,O=Object.prototype.hasOwnProperty,P={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function B(G,K,Z){var ee,J={},re=null,ie=null;if(K!=null)for(ee in K.ref!==void 0&&(ie=K.ref),K.key!==void 0&&(re=""+K.key),K)O.call(K,ee)&&!H.hasOwnProperty(ee)&&(J[ee]=K[ee]);var ne=arguments.length-2;if(ne===1)J.children=Z;else if(1<ne){for(var me=Array(ne),Ce=0;Ce<ne;Ce++)me[Ce]=arguments[Ce+2];J.children=me}if(G&&G.defaultProps)for(ee in ne=G.defaultProps,ne)J[ee]===void 0&&(J[ee]=ne[ee]);return{$$typeof:e,type:G,key:re,ref:ie,props:J,_owner:P.current}}function R(G,K){return{$$typeof:e,type:G.type,key:K,ref:G.ref,props:G.props,_owner:G._owner}}function M(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function F(G){var K={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(Z){return K[Z]})}var L=/\/+/g;function A(G,K){return typeof G=="object"&&G!==null&&G.key!=null?F(""+G.key):K.toString(36)}function I(G,K,Z,ee,J){var re=typeof G;(re==="undefined"||re==="boolean")&&(G=null);var ie=!1;if(G===null)ie=!0;else switch(re){case"string":case"number":ie=!0;break;case"object":switch(G.$$typeof){case e:case t:ie=!0}}if(ie)return ie=G,J=J(ie),G=ee===""?"."+A(ie,0):ee,E(J)?(Z="",G!=null&&(Z=G.replace(L,"$&/")+"/"),I(J,K,Z,"",function(Ce){return Ce})):J!=null&&(M(J)&&(J=R(J,Z+(!J.key||ie&&ie.key===J.key?"":(""+J.key).replace(L,"$&/")+"/")+G)),K.push(J)),1;if(ie=0,ee=ee===""?".":ee+":",E(G))for(var ne=0;ne<G.length;ne++){re=G[ne];var me=ee+A(re,ne);ie+=I(re,K,Z,me,J)}else if(me=g(G),typeof me=="function")for(G=me.call(G),ne=0;!(re=G.next()).done;)re=re.value,me=ee+A(re,ne++),ie+=I(re,K,Z,me,J);else if(re==="object")throw K=String(G),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.");return ie}function z(G,K,Z){if(G==null)return G;var ee=[],J=0;return I(G,ee,"","",function(re){return K.call(Z,re,J++)}),ee}function D(G){if(G._status===-1){var K=G._result;K=K(),K.then(function(Z){(G._status===0||G._status===-1)&&(G._status=1,G._result=Z)},function(Z){(G._status===0||G._status===-1)&&(G._status=2,G._result=Z)}),G._status===-1&&(G._status=0,G._result=K)}if(G._status===1)return G._result.default;throw G._result}var V={current:null},U={transition:null},q={ReactCurrentDispatcher:V,ReactCurrentBatchConfig:U,ReactCurrentOwner:P};function te(){throw Error("act(...) is not supported in production builds of React.")}return kt.Children={map:z,forEach:function(G,K,Z){z(G,function(){K.apply(this,arguments)},Z)},count:function(G){var K=0;return z(G,function(){K++}),K},toArray:function(G){return z(G,function(K){return K})||[]},only:function(G){if(!M(G))throw Error("React.Children.only expected to receive a single React element child.");return G}},kt.Component=y,kt.Fragment=s,kt.Profiler=r,kt.PureComponent=_,kt.StrictMode=i,kt.Suspense=d,kt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,kt.act=te,kt.cloneElement=function(G,K,Z){if(G==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+G+".");var ee=N({},G.props),J=G.key,re=G.ref,ie=G._owner;if(K!=null){if(K.ref!==void 0&&(re=K.ref,ie=P.current),K.key!==void 0&&(J=""+K.key),G.type&&G.type.defaultProps)var ne=G.type.defaultProps;for(me in K)O.call(K,me)&&!H.hasOwnProperty(me)&&(ee[me]=K[me]===void 0&&ne!==void 0?ne[me]:K[me])}var me=arguments.length-2;if(me===1)ee.children=Z;else if(1<me){ne=Array(me);for(var Ce=0;Ce<me;Ce++)ne[Ce]=arguments[Ce+2];ee.children=ne}return{$$typeof:e,type:G.type,key:J,ref:re,props:ee,_owner:ie}},kt.createContext=function(G){return G={$$typeof:l,_currentValue:G,_currentValue2:G,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},G.Provider={$$typeof:o,_context:G},G.Consumer=G},kt.createElement=B,kt.createFactory=function(G){var K=B.bind(null,G);return K.type=G,K},kt.createRef=function(){return{current:null}},kt.forwardRef=function(G){return{$$typeof:u,render:G}},kt.isValidElement=M,kt.lazy=function(G){return{$$typeof:m,_payload:{_status:-1,_result:G},_init:D}},kt.memo=function(G,K){return{$$typeof:h,type:G,compare:K===void 0?null:K}},kt.startTransition=function(G){var K=U.transition;U.transition={};try{G()}finally{U.transition=K}},kt.unstable_act=te,kt.useCallback=function(G,K){return V.current.useCallback(G,K)},kt.useContext=function(G){return V.current.useContext(G)},kt.useDebugValue=function(){},kt.useDeferredValue=function(G){return V.current.useDeferredValue(G)},kt.useEffect=function(G,K){return V.current.useEffect(G,K)},kt.useId=function(){return V.current.useId()},kt.useImperativeHandle=function(G,K,Z){return V.current.useImperativeHandle(G,K,Z)},kt.useInsertionEffect=function(G,K){return V.current.useInsertionEffect(G,K)},kt.useLayoutEffect=function(G,K){return V.current.useLayoutEffect(G,K)},kt.useMemo=function(G,K){return V.current.useMemo(G,K)},kt.useReducer=function(G,K,Z){return V.current.useReducer(G,K,Z)},kt.useRef=function(G){return V.current.useRef(G)},kt.useState=function(G){return V.current.useState(G)},kt.useSyncExternalStore=function(G,K,Z){return V.current.useSyncExternalStore(G,K,Z)},kt.useTransition=function(){return V.current.useTransition()},kt.version="18.3.1",kt}var ay;function zc(){return ay||(ay=1,ef.exports=JC()),ef.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 oy;function eA(){if(oy)return Tl;oy=1;var e=zc(),t=Symbol.for("react.element"),s=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function l(u,d,h){var m,p={},g=null,x=null;h!==void 0&&(g=""+h),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(x=d.ref);for(m in d)i.call(d,m)&&!o.hasOwnProperty(m)&&(p[m]=d[m]);if(u&&u.defaultProps)for(m in d=u.defaultProps,d)p[m]===void 0&&(p[m]=d[m]);return{$$typeof:t,type:u,key:g,ref:x,props:p,_owner:r.current}}return Tl.Fragment=s,Tl.jsx=l,Tl.jsxs=l,Tl}var ly;function tA(){return ly||(ly=1,Jm.exports=eA()),Jm.exports}var n=tA(),qu={},tf={exports:{}},Cs={},nf={exports:{}},sf={};/**
|
|
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 cy;function nA(){return cy||(cy=1,(function(e){function t(U,q){var te=U.length;U.push(q);e:for(;0<te;){var G=te-1>>>1,K=U[G];if(0<r(K,q))U[G]=q,U[te]=K,te=G;else break e}}function s(U){return U.length===0?null:U[0]}function i(U){if(U.length===0)return null;var q=U[0],te=U.pop();if(te!==q){U[0]=te;e:for(var G=0,K=U.length,Z=K>>>1;G<Z;){var ee=2*(G+1)-1,J=U[ee],re=ee+1,ie=U[re];if(0>r(J,te))re<K&&0>r(ie,J)?(U[G]=ie,U[re]=te,G=re):(U[G]=J,U[ee]=te,G=ee);else if(re<K&&0>r(ie,te))U[G]=ie,U[re]=te,G=re;else break e}}return q}function r(U,q){var te=U.sortIndex-q.sortIndex;return te!==0?te:U.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var d=[],h=[],m=1,p=null,g=3,x=!1,N=!1,j=!1,y=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(U){for(var q=s(h);q!==null;){if(q.callback===null)i(h);else if(q.startTime<=U)i(h),q.sortIndex=q.expirationTime,t(d,q);else break;q=s(h)}}function E(U){if(j=!1,S(U),!N)if(s(d)!==null)N=!0,D(O);else{var q=s(h);q!==null&&V(E,q.startTime-U)}}function O(U,q){N=!1,j&&(j=!1,k(B),B=-1),x=!0;var te=g;try{for(S(q),p=s(d);p!==null&&(!(p.expirationTime>q)||U&&!F());){var G=p.callback;if(typeof G=="function"){p.callback=null,g=p.priorityLevel;var K=G(p.expirationTime<=q);q=e.unstable_now(),typeof K=="function"?p.callback=K:p===s(d)&&i(d),S(q)}else i(d);p=s(d)}if(p!==null)var Z=!0;else{var ee=s(h);ee!==null&&V(E,ee.startTime-q),Z=!1}return Z}finally{p=null,g=te,x=!1}}var P=!1,H=null,B=-1,R=5,M=-1;function F(){return!(e.unstable_now()-M<R)}function L(){if(H!==null){var U=e.unstable_now();M=U;var q=!0;try{q=H(!0,U)}finally{q?A():(P=!1,H=null)}}else P=!1}var A;if(typeof _=="function")A=function(){_(L)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,z=I.port2;I.port1.onmessage=L,A=function(){z.postMessage(null)}}else A=function(){y(L,0)};function D(U){H=U,P||(P=!0,A())}function V(U,q){B=y(function(){U(e.unstable_now())},q)}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(U){U.callback=null},e.unstable_continueExecution=function(){N||x||(N=!0,D(O))},e.unstable_forceFrameRate=function(U){0>U||125<U?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<U?Math.floor(1e3/U):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return s(d)},e.unstable_next=function(U){switch(g){case 1:case 2:case 3:var q=3;break;default:q=g}var te=g;g=q;try{return U()}finally{g=te}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(U,q){switch(U){case 1:case 2:case 3:case 4:case 5:break;default:U=3}var te=g;g=U;try{return q()}finally{g=te}},e.unstable_scheduleCallback=function(U,q,te){var G=e.unstable_now();switch(typeof te=="object"&&te!==null?(te=te.delay,te=typeof te=="number"&&0<te?G+te:G):te=G,U){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=te+K,U={id:m++,callback:q,priorityLevel:U,startTime:te,expirationTime:K,sortIndex:-1},te>G?(U.sortIndex=te,t(h,U),s(d)===null&&U===s(h)&&(j?(k(B),B=-1):j=!0,V(E,te-G))):(U.sortIndex=K,t(d,U),N||x||(N=!0,D(O))),U},e.unstable_shouldYield=F,e.unstable_wrapCallback=function(U){var q=g;return function(){var te=g;g=q;try{return U.apply(this,arguments)}finally{g=te}}}})(sf)),sf}var uy;function sA(){return uy||(uy=1,nf.exports=nA()),nf.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 dy;function iA(){if(dy)return Cs;dy=1;var e=zc(),t=sA();function s(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,f=1;f<arguments.length;f++)c+="&args[]="+encodeURIComponent(arguments[f]);return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,r={};function o(a,c){l(a,c),l(a+"Capture",c)}function l(a,c){for(r[a]=c,a=0;a<c.length;a++)i.add(c[a])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,h=/^[: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]*$/,m={},p={};function g(a){return d.call(p,a)?!0:d.call(m,a)?!1:h.test(a)?p[a]=!0:(m[a]=!0,!1)}function x(a,c,f,b){if(f!==null&&f.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return b?!1:f!==null?!f.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function N(a,c,f,b){if(c===null||typeof c>"u"||x(a,c,f,b))return!0;if(b)return!1;if(f!==null)switch(f.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function j(a,c,f,b,C,$,W){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=b,this.attributeNamespace=C,this.mustUseProperty=f,this.propertyName=a,this.type=c,this.sanitizeURL=$,this.removeEmptyString=W}var y={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){y[a]=new j(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var c=a[0];y[c]=new j(c,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){y[a]=new j(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){y[a]=new j(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){y[a]=new j(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){y[a]=new j(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){y[a]=new j(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){y[a]=new j(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){y[a]=new j(a,5,!1,a.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function _(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 c=a.replace(k,_);y[c]=new j(c,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var c=a.replace(k,_);y[c]=new j(c,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var c=a.replace(k,_);y[c]=new j(c,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){y[a]=new j(a,1,!1,a.toLowerCase(),null,!1,!1)}),y.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){y[a]=new j(a,1,!1,a.toLowerCase(),null,!0,!0)});function S(a,c,f,b){var C=y.hasOwnProperty(c)?y[c]:null;(C!==null?C.type!==0:b||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(N(c,f,C,b)&&(f=null),b||C===null?g(c)&&(f===null?a.removeAttribute(c):a.setAttribute(c,""+f)):C.mustUseProperty?a[C.propertyName]=f===null?C.type===3?!1:"":f:(c=C.attributeName,b=C.attributeNamespace,f===null?a.removeAttribute(c):(C=C.type,f=C===3||C===4&&f===!0?"":""+f,b?a.setAttributeNS(b,c,f):a.setAttribute(c,f))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,O=Symbol.for("react.element"),P=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),M=Symbol.for("react.provider"),F=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),U=Symbol.iterator;function q(a){return a===null||typeof a!="object"?null:(a=U&&a[U]||a["@@iterator"],typeof a=="function"?a:null)}var te=Object.assign,G;function K(a){if(G===void 0)try{throw Error()}catch(f){var c=f.stack.trim().match(/\n( *(at )?)/);G=c&&c[1]||""}return`
|
|
34
|
-
`+G+a}var Z=!1;function ee(a,c){if(!a||Z)return"";Z=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(ye){var b=ye}Reflect.construct(a,[],c)}else{try{c.call()}catch(ye){b=ye}a.call(c.prototype)}else{try{throw Error()}catch(ye){b=ye}a()}}catch(ye){if(ye&&b&&typeof ye.stack=="string"){for(var C=ye.stack.split(`
|
|
35
|
-
`),$=b.stack.split(`
|
|
36
|
-
`),W=C.length-1,se=$.length-1;1<=W&&0<=se&&C[W]!==$[se];)se--;for(;1<=W&&0<=se;W--,se--)if(C[W]!==$[se]){if(W!==1||se!==1)do if(W--,se--,0>se||C[W]!==$[se]){var ae=`
|
|
37
|
-
`+C[W].replace(" at new "," at ");return a.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",a.displayName)),ae}while(1<=W&&0<=se);break}}}finally{Z=!1,Error.prepareStackTrace=f}return(a=a?a.displayName||a.name:"")?K(a):""}function J(a){switch(a.tag){case 5:return K(a.type);case 16:return K("Lazy");case 13:return K("Suspense");case 19:return K("SuspenseList");case 0:case 2:case 15:return a=ee(a.type,!1),a;case 11:return a=ee(a.type.render,!1),a;case 1:return a=ee(a.type,!0),a;default:return""}}function re(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 H:return"Fragment";case P:return"Portal";case R:return"Profiler";case B:return"StrictMode";case A:return"Suspense";case I:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case F:return(a.displayName||"Context")+".Consumer";case M:return(a._context.displayName||"Context")+".Provider";case L:var c=a.render;return a=a.displayName,a||(a=c.displayName||c.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case z:return c=a.displayName||null,c!==null?c:re(a.type)||"Memo";case D:c=a._payload,a=a._init;try{return re(a(c))}catch{}}return null}function ie(a){var c=a.type;switch(a.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=c.render,a=a.displayName||a.name||"",c.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return re(c);case 8:return c===B?"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 c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function ne(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function me(a){var c=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function Ce(a){var c=me(a)?"checked":"value",f=Object.getOwnPropertyDescriptor(a.constructor.prototype,c),b=""+a[c];if(!a.hasOwnProperty(c)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var C=f.get,$=f.set;return Object.defineProperty(a,c,{configurable:!0,get:function(){return C.call(this)},set:function(W){b=""+W,$.call(this,W)}}),Object.defineProperty(a,c,{enumerable:f.enumerable}),{getValue:function(){return b},setValue:function(W){b=""+W},stopTracking:function(){a._valueTracker=null,delete a[c]}}}}function Fe(a){a._valueTracker||(a._valueTracker=Ce(a))}function Me(a){if(!a)return!1;var c=a._valueTracker;if(!c)return!0;var f=c.getValue(),b="";return a&&(b=me(a)?a.checked?"true":"false":a.value),a=b,a!==f?(c.setValue(a),!0):!1}function fe(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 ke(a,c){var f=c.checked;return te({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f??a._wrapperState.initialChecked})}function ge(a,c){var f=c.defaultValue==null?"":c.defaultValue,b=c.checked!=null?c.checked:c.defaultChecked;f=ne(c.value!=null?c.value:f),a._wrapperState={initialChecked:b,initialValue:f,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function Ae(a,c){c=c.checked,c!=null&&S(a,"checked",c,!1)}function be(a,c){Ae(a,c);var f=ne(c.value),b=c.type;if(f!=null)b==="number"?(f===0&&a.value===""||a.value!=f)&&(a.value=""+f):a.value!==""+f&&(a.value=""+f);else if(b==="submit"||b==="reset"){a.removeAttribute("value");return}c.hasOwnProperty("value")?ft(a,c.type,f):c.hasOwnProperty("defaultValue")&&ft(a,c.type,ne(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(a.defaultChecked=!!c.defaultChecked)}function qe(a,c,f){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var b=c.type;if(!(b!=="submit"&&b!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+a._wrapperState.initialValue,f||c===a.value||(a.value=c),a.defaultValue=c}f=a.name,f!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,f!==""&&(a.name=f)}function ft(a,c,f){(c!=="number"||fe(a.ownerDocument)!==a)&&(f==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+f&&(a.defaultValue=""+f))}var gt=Array.isArray;function Rt(a,c,f,b){if(a=a.options,c){c={};for(var C=0;C<f.length;C++)c["$"+f[C]]=!0;for(f=0;f<a.length;f++)C=c.hasOwnProperty("$"+a[f].value),a[f].selected!==C&&(a[f].selected=C),C&&b&&(a[f].defaultSelected=!0)}else{for(f=""+ne(f),c=null,C=0;C<a.length;C++){if(a[C].value===f){a[C].selected=!0,b&&(a[C].defaultSelected=!0);return}c!==null||a[C].disabled||(c=a[C])}c!==null&&(c.selected=!0)}}function En(a,c){if(c.dangerouslySetInnerHTML!=null)throw Error(s(91));return te({},c,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function rt(a,c){var f=c.value;if(f==null){if(f=c.children,c=c.defaultValue,f!=null){if(c!=null)throw Error(s(92));if(gt(f)){if(1<f.length)throw Error(s(93));f=f[0]}c=f}c==null&&(c=""),f=c}a._wrapperState={initialValue:ne(f)}}function Pt(a,c){var f=ne(c.value),b=ne(c.defaultValue);f!=null&&(f=""+f,f!==a.value&&(a.value=f),c.defaultValue==null&&a.defaultValue!==f&&(a.defaultValue=f)),b!=null&&(a.defaultValue=""+b)}function rn(a){var c=a.textContent;c===a._wrapperState.initialValue&&c!==""&&c!==null&&(a.value=c)}function Zt(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 Qt(a,c){return a==null||a==="http://www.w3.org/1999/xhtml"?Zt(c):a==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var Ut,Rn=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,f,b,C){MSApp.execUnsafeLocalFunction(function(){return a(c,f,b,C)})}:a})(function(a,c){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=c;else{for(Ut=Ut||document.createElement("div"),Ut.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=Ut.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;c.firstChild;)a.appendChild(c.firstChild)}});function mn(a,c){if(c){var f=a.firstChild;if(f&&f===a.lastChild&&f.nodeType===3){f.nodeValue=c;return}}a.textContent=c}var Hn={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},Gs=["Webkit","ms","Moz","O"];Object.keys(Hn).forEach(function(a){Gs.forEach(function(c){c=c+a.charAt(0).toUpperCase()+a.substring(1),Hn[c]=Hn[a]})});function ps(a,c,f){return c==null||typeof c=="boolean"||c===""?"":f||typeof c!="number"||c===0||Hn.hasOwnProperty(a)&&Hn[a]?(""+c).trim():c+"px"}function rs(a,c){a=a.style;for(var f in c)if(c.hasOwnProperty(f)){var b=f.indexOf("--")===0,C=ps(f,c[f],b);f==="float"&&(f="cssFloat"),b?a.setProperty(f,C):a[f]=C}}var gs=te({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 Cn(a,c){if(c){if(gs[a]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(s(137,a));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(s(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(s(61))}if(c.style!=null&&typeof c.style!="object")throw Error(s(62))}}function as(a,c){if(a.indexOf("-")===-1)return typeof c.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 Kn=null;function Zn(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var An=null,Yn=null,On=null;function le(a){if(a=xl(a)){if(typeof An!="function")throw Error(s(280));var c=a.stateNode;c&&(c=lu(c),An(a.stateNode,a.type,c))}}function X(a){Yn?On?On.push(a):On=[a]:Yn=a}function de(){if(Yn){var a=Yn,c=On;if(On=Yn=null,le(a),c)for(a=0;a<c.length;a++)le(c[a])}}function Se(a,c){return a(c)}function Be(){}var ut=!1;function Nt(a,c,f){if(ut)return a(c,f);ut=!0;try{return Se(a,c,f)}finally{ut=!1,(Yn!==null||On!==null)&&(Be(),de())}}function He(a,c){var f=a.stateNode;if(f===null)return null;var b=lu(f);if(b===null)return null;f=b[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(b=!b.disabled)||(a=a.type,b=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!b;break e;default:a=!1}if(a)return null;if(f&&typeof f!="function")throw Error(s(231,c,typeof f));return f}var Ue=!1;if(u)try{var Xe={};Object.defineProperty(Xe,"passive",{get:function(){Ue=!0}}),window.addEventListener("test",Xe,Xe),window.removeEventListener("test",Xe,Xe)}catch{Ue=!1}function yt(a,c,f,b,C,$,W,se,ae){var ye=Array.prototype.slice.call(arguments,3);try{c.apply(f,ye)}catch(Te){this.onError(Te)}}var St=!1,Xn=null,xs=!1,ui=null,yr={onError:function(a){St=!0,Xn=a}};function di(a,c,f,b,C,$,W,se,ae){St=!1,Xn=null,yt.apply(yr,arguments)}function br(a,c,f,b,C,$,W,se,ae){if(di.apply(this,arguments),St){if(St){var ye=Xn;St=!1,Xn=null}else throw Error(s(198));xs||(xs=!0,ui=ye)}}function Qn(a){var c=a,f=a;if(a.alternate)for(;c.return;)c=c.return;else{a=c;do c=a,(c.flags&4098)!==0&&(f=c.return),a=c.return;while(a)}return c.tag===3?f:null}function Gi(a){if(a.tag===13){var c=a.memoizedState;if(c===null&&(a=a.alternate,a!==null&&(c=a.memoizedState)),c!==null)return c.dehydrated}return null}function vs(a){if(Qn(a)!==a)throw Error(s(188))}function Mi(a){var c=a.alternate;if(!c){if(c=Qn(a),c===null)throw Error(s(188));return c!==a?null:a}for(var f=a,b=c;;){var C=f.return;if(C===null)break;var $=C.alternate;if($===null){if(b=C.return,b!==null){f=b;continue}break}if(C.child===$.child){for($=C.child;$;){if($===f)return vs(C),a;if($===b)return vs(C),c;$=$.sibling}throw Error(s(188))}if(f.return!==b.return)f=C,b=$;else{for(var W=!1,se=C.child;se;){if(se===f){W=!0,f=C,b=$;break}if(se===b){W=!0,b=C,f=$;break}se=se.sibling}if(!W){for(se=$.child;se;){if(se===f){W=!0,f=$,b=C;break}if(se===b){W=!0,b=$,f=C;break}se=se.sibling}if(!W)throw Error(s(189))}}if(f.alternate!==b)throw Error(s(190))}if(f.tag!==3)throw Error(s(188));return f.stateNode.current===f?a:c}function kr(a){return a=Mi(a),a!==null?zt(a):null}function zt(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var c=zt(a);if(c!==null)return c;a=a.sibling}return null}var Os=t.unstable_scheduleCallback,os=t.unstable_cancelCallback,Ki=t.unstable_shouldYield,hi=t.unstable_requestPaint,Dt=t.unstable_now,jr=t.unstable_getCurrentPriorityLevel,Yi=t.unstable_ImmediatePriority,mi=t.unstable_UserBlockingPriority,Ri=t.unstable_NormalPriority,Pe=t.unstable_LowPriority,Ve=t.unstable_IdlePriority,dt=null,mt=null;function Ot(a){if(mt&&typeof mt.onCommitFiberRoot=="function")try{mt.onCommitFiberRoot(dt,a,void 0,(a.current.flags&128)===128)}catch{}}var Ft=Math.clz32?Math.clz32:fn,Jn=Math.log,Ks=Math.LN2;function fn(a){return a>>>=0,a===0?32:31-(Jn(a)/Ks|0)|0}var $n=64,Ys=4194304;function Xs(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 ys(a,c){var f=a.pendingLanes;if(f===0)return 0;var b=0,C=a.suspendedLanes,$=a.pingedLanes,W=f&268435455;if(W!==0){var se=W&~C;se!==0?b=Xs(se):($&=W,$!==0&&(b=Xs($)))}else W=f&~C,W!==0?b=Xs(W):$!==0&&(b=Xs($));if(b===0)return 0;if(c!==0&&c!==b&&(c&C)===0&&(C=b&-b,$=c&-c,C>=$||C===16&&($&4194240)!==0))return c;if((b&4)!==0&&(b|=f&16),c=a.entangledLanes,c!==0)for(a=a.entanglements,c&=b;0<c;)f=31-Ft(c),C=1<<f,b|=a[f],c&=~C;return b}function la(a,c){switch(a){case 1:case 2:case 4:return c+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 c+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 Nr(a,c){for(var f=a.suspendedLanes,b=a.pingedLanes,C=a.expirationTimes,$=a.pendingLanes;0<$;){var W=31-Ft($),se=1<<W,ae=C[W];ae===-1?((se&f)===0||(se&b)!==0)&&(C[W]=la(se,c)):ae<=c&&(a.expiredLanes|=se),$&=~se}}function Oi(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function wr(){var a=$n;return $n<<=1,($n&4194240)===0&&($n=64),a}function ls(a){for(var c=[],f=0;31>f;f++)c.push(a);return c}function bs(a,c,f){a.pendingLanes|=c,c!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,c=31-Ft(c),a[c]=f}function In(a,c){var f=a.pendingLanes&~c;a.pendingLanes=c,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=c,a.mutableReadLanes&=c,a.entangledLanes&=c,c=a.entanglements;var b=a.eventTimes;for(a=a.expirationTimes;0<f;){var C=31-Ft(f),$=1<<C;c[C]=0,b[C]=-1,a[C]=-1,f&=~$}}function Qs(a,c){var f=a.entangledLanes|=c;for(a=a.entanglements;f;){var b=31-Ft(f),C=1<<b;C&c|a[b]&c&&(a[b]|=c),f&=~C}}var wt=0;function at(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var ks,Bt,pt,Xi,cs,Qi=!1,fi=[],Le=null,Ze=null,ot=null,jt=new Map,Vt=new Map,yn=[],rl="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 ca(a,c){switch(a){case"focusin":case"focusout":Le=null;break;case"dragenter":case"dragleave":Ze=null;break;case"mouseover":case"mouseout":ot=null;break;case"pointerover":case"pointerout":jt.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vt.delete(c.pointerId)}}function Ji(a,c,f,b,C,$){return a===null||a.nativeEvent!==$?(a={blockedOn:c,domEventName:f,eventSystemFlags:b,nativeEvent:$,targetContainers:[C]},c!==null&&(c=xl(c),c!==null&&Bt(c)),a):(a.eventSystemFlags|=b,c=a.targetContainers,C!==null&&c.indexOf(C)===-1&&c.push(C),a)}function ua(a,c,f,b,C){switch(c){case"focusin":return Le=Ji(Le,a,c,f,b,C),!0;case"dragenter":return Ze=Ji(Ze,a,c,f,b,C),!0;case"mouseover":return ot=Ji(ot,a,c,f,b,C),!0;case"pointerover":var $=C.pointerId;return jt.set($,Ji(jt.get($)||null,a,c,f,b,C)),!0;case"gotpointercapture":return $=C.pointerId,Vt.set($,Ji(Vt.get($)||null,a,c,f,b,C)),!0}return!1}function Ya(a){var c=da(a.target);if(c!==null){var f=Qn(c);if(f!==null){if(c=f.tag,c===13){if(c=Gi(f),c!==null){a.blockedOn=c,cs(a.priority,function(){pt(f)});return}}else if(c===3&&f.stateNode.current.memoizedState.isDehydrated){a.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Ee(a){if(a.blockedOn!==null)return!1;for(var c=a.targetContainers;0<c.length;){var f=Pn(a.domEventName,a.eventSystemFlags,c[0],a.nativeEvent);if(f===null){f=a.nativeEvent;var b=new f.constructor(f.type,f);Kn=b,f.target.dispatchEvent(b),Kn=null}else return c=xl(f),c!==null&&Bt(c),a.blockedOn=f,!1;c.shift()}return!0}function Y(a,c,f){Ee(a)&&f.delete(c)}function ce(){Qi=!1,Le!==null&&Ee(Le)&&(Le=null),Ze!==null&&Ee(Ze)&&(Ze=null),ot!==null&&Ee(ot)&&(ot=null),jt.forEach(Y),Vt.forEach(Y)}function Ne(a,c){a.blockedOn===c&&(a.blockedOn=null,Qi||(Qi=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ce)))}function we(a){function c(C){return Ne(C,a)}if(0<fi.length){Ne(fi[0],a);for(var f=1;f<fi.length;f++){var b=fi[f];b.blockedOn===a&&(b.blockedOn=null)}}for(Le!==null&&Ne(Le,a),Ze!==null&&Ne(Ze,a),ot!==null&&Ne(ot,a),jt.forEach(c),Vt.forEach(c),f=0;f<yn.length;f++)b=yn[f],b.blockedOn===a&&(b.blockedOn=null);for(;0<yn.length&&(f=yn[0],f.blockedOn===null);)Ya(f),f.blockedOn===null&&yn.shift()}var Ye=E.ReactCurrentBatchConfig,nt=!0;function xt(a,c,f,b){var C=wt,$=Ye.transition;Ye.transition=null;try{wt=1,js(a,c,f,b)}finally{wt=C,Ye.transition=$}}function pn(a,c,f,b){var C=wt,$=Ye.transition;Ye.transition=null;try{wt=4,js(a,c,f,b)}finally{wt=C,Ye.transition=$}}function js(a,c,f,b){if(nt){var C=Pn(a,c,f,b);if(C===null)Bh(a,c,b,bn,f),ca(a,b);else if(ua(C,a,c,f,b))b.stopPropagation();else if(ca(a,b),c&4&&-1<rl.indexOf(a)){for(;C!==null;){var $=xl(C);if($!==null&&ks($),$=Pn(a,c,f,b),$===null&&Bh(a,c,b,bn,f),$===C)break;C=$}C!==null&&b.stopPropagation()}else Bh(a,c,b,null,f)}}var bn=null;function Pn(a,c,f,b){if(bn=null,a=Zn(b),a=da(a),a!==null)if(c=Qn(a),c===null)a=null;else if(f=c.tag,f===13){if(a=Gi(c),a!==null)return a;a=null}else if(f===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;a=null}else c!==a&&(a=null);return bn=a,null}function er(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(jr()){case Yi:return 1;case mi:return 4;case Ri:case Pe:return 16;case Ve:return 536870912;default:return 16}default:return 16}}var an=null,Xa=null,Xc=null;function Zx(){if(Xc)return Xc;var a,c=Xa,f=c.length,b,C="value"in an?an.value:an.textContent,$=C.length;for(a=0;a<f&&c[a]===C[a];a++);var W=f-a;for(b=1;b<=W&&c[f-b]===C[$-b];b++);return Xc=C.slice(a,1<b?1-b:void 0)}function Qc(a){var c=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&c===13&&(a=13)):a=c,a===10&&(a=13),32<=a||a===13?a:0}function Jc(){return!0}function Wx(){return!1}function Ps(a){function c(f,b,C,$,W){this._reactName=f,this._targetInst=C,this.type=b,this.nativeEvent=$,this.target=W,this.currentTarget=null;for(var se in a)a.hasOwnProperty(se)&&(f=a[se],this[se]=f?f($):$[se]);return this.isDefaultPrevented=($.defaultPrevented!=null?$.defaultPrevented:$.returnValue===!1)?Jc:Wx,this.isPropagationStopped=Wx,this}return te(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=Jc)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=Jc)},persist:function(){},isPersistent:Jc}),c}var Qa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Eh=Ps(Qa),al=te({},Qa,{view:0,detail:0}),wE=Ps(al),Ch,Ah,ol,eu=te({},al,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ih,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!==ol&&(ol&&a.type==="mousemove"?(Ch=a.screenX-ol.screenX,Ah=a.screenY-ol.screenY):Ah=Ch=0,ol=a),Ch)},movementY:function(a){return"movementY"in a?a.movementY:Ah}}),Vx=Ps(eu),SE=te({},eu,{dataTransfer:0}),_E=Ps(SE),EE=te({},al,{relatedTarget:0}),$h=Ps(EE),CE=te({},Qa,{animationName:0,elapsedTime:0,pseudoElement:0}),AE=Ps(CE),$E=te({},Qa,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),IE=Ps($E),TE=te({},Qa,{data:0}),qx=Ps(TE),ME={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},RE={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"},OE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function PE(a){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(a):(a=OE[a])?!!c[a]:!1}function Ih(){return PE}var LE=te({},al,{key:function(a){if(a.key){var c=ME[a.key]||a.key;if(c!=="Unidentified")return c}return a.type==="keypress"?(a=Qc(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?RE[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ih,charCode:function(a){return a.type==="keypress"?Qc(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Qc(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),zE=Ps(LE),DE=te({},eu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gx=Ps(DE),FE=te({},al,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ih}),UE=Ps(FE),BE=te({},Qa,{propertyName:0,elapsedTime:0,pseudoElement:0}),HE=Ps(BE),ZE=te({},eu,{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}),WE=Ps(ZE),VE=[9,13,27,32],Th=u&&"CompositionEvent"in window,ll=null;u&&"documentMode"in document&&(ll=document.documentMode);var qE=u&&"TextEvent"in window&&!ll,Kx=u&&(!Th||ll&&8<ll&&11>=ll),Yx=" ",Xx=!1;function Qx(a,c){switch(a){case"keyup":return VE.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Jx(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Ja=!1;function GE(a,c){switch(a){case"compositionend":return Jx(c);case"keypress":return c.which!==32?null:(Xx=!0,Yx);case"textInput":return a=c.data,a===Yx&&Xx?null:a;default:return null}}function KE(a,c){if(Ja)return a==="compositionend"||!Th&&Qx(a,c)?(a=Zx(),Xc=Xa=an=null,Ja=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return Kx&&c.locale!=="ko"?null:c.data;default:return null}}var YE={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 ev(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c==="input"?!!YE[a.type]:c==="textarea"}function tv(a,c,f,b){X(b),c=ru(c,"onChange"),0<c.length&&(f=new Eh("onChange","change",null,f,b),a.push({event:f,listeners:c}))}var cl=null,ul=null;function XE(a){yv(a,0)}function tu(a){var c=io(a);if(Me(c))return a}function QE(a,c){if(a==="change")return c}var nv=!1;if(u){var Mh;if(u){var Rh="oninput"in document;if(!Rh){var sv=document.createElement("div");sv.setAttribute("oninput","return;"),Rh=typeof sv.oninput=="function"}Mh=Rh}else Mh=!1;nv=Mh&&(!document.documentMode||9<document.documentMode)}function iv(){cl&&(cl.detachEvent("onpropertychange",rv),ul=cl=null)}function rv(a){if(a.propertyName==="value"&&tu(ul)){var c=[];tv(c,ul,a,Zn(a)),Nt(XE,c)}}function JE(a,c,f){a==="focusin"?(iv(),cl=c,ul=f,cl.attachEvent("onpropertychange",rv)):a==="focusout"&&iv()}function eC(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return tu(ul)}function tC(a,c){if(a==="click")return tu(c)}function nC(a,c){if(a==="input"||a==="change")return tu(c)}function sC(a,c){return a===c&&(a!==0||1/a===1/c)||a!==a&&c!==c}var pi=typeof Object.is=="function"?Object.is:sC;function dl(a,c){if(pi(a,c))return!0;if(typeof a!="object"||a===null||typeof c!="object"||c===null)return!1;var f=Object.keys(a),b=Object.keys(c);if(f.length!==b.length)return!1;for(b=0;b<f.length;b++){var C=f[b];if(!d.call(c,C)||!pi(a[C],c[C]))return!1}return!0}function av(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function ov(a,c){var f=av(a);a=0;for(var b;f;){if(f.nodeType===3){if(b=a+f.textContent.length,a<=c&&b>=c)return{node:f,offset:c-a};a=b}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=av(f)}}function lv(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?lv(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function cv(){for(var a=window,c=fe();c instanceof a.HTMLIFrameElement;){try{var f=typeof c.contentWindow.location.href=="string"}catch{f=!1}if(f)a=c.contentWindow;else break;c=fe(a.document)}return c}function Oh(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c&&(c==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||c==="textarea"||a.contentEditable==="true")}function iC(a){var c=cv(),f=a.focusedElem,b=a.selectionRange;if(c!==f&&f&&f.ownerDocument&&lv(f.ownerDocument.documentElement,f)){if(b!==null&&Oh(f)){if(c=b.start,a=b.end,a===void 0&&(a=c),"selectionStart"in f)f.selectionStart=c,f.selectionEnd=Math.min(a,f.value.length);else if(a=(c=f.ownerDocument||document)&&c.defaultView||window,a.getSelection){a=a.getSelection();var C=f.textContent.length,$=Math.min(b.start,C);b=b.end===void 0?$:Math.min(b.end,C),!a.extend&&$>b&&(C=b,b=$,$=C),C=ov(f,$);var W=ov(f,b);C&&W&&(a.rangeCount!==1||a.anchorNode!==C.node||a.anchorOffset!==C.offset||a.focusNode!==W.node||a.focusOffset!==W.offset)&&(c=c.createRange(),c.setStart(C.node,C.offset),a.removeAllRanges(),$>b?(a.addRange(c),a.extend(W.node,W.offset)):(c.setEnd(W.node,W.offset),a.addRange(c)))}}for(c=[],a=f;a=a.parentNode;)a.nodeType===1&&c.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof f.focus=="function"&&f.focus(),f=0;f<c.length;f++)a=c[f],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var rC=u&&"documentMode"in document&&11>=document.documentMode,eo=null,Ph=null,hl=null,Lh=!1;function uv(a,c,f){var b=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;Lh||eo==null||eo!==fe(b)||(b=eo,"selectionStart"in b&&Oh(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),hl&&dl(hl,b)||(hl=b,b=ru(Ph,"onSelect"),0<b.length&&(c=new Eh("onSelect","select",null,c,f),a.push({event:c,listeners:b}),c.target=eo)))}function nu(a,c){var f={};return f[a.toLowerCase()]=c.toLowerCase(),f["Webkit"+a]="webkit"+c,f["Moz"+a]="moz"+c,f}var to={animationend:nu("Animation","AnimationEnd"),animationiteration:nu("Animation","AnimationIteration"),animationstart:nu("Animation","AnimationStart"),transitionend:nu("Transition","TransitionEnd")},zh={},dv={};u&&(dv=document.createElement("div").style,"AnimationEvent"in window||(delete to.animationend.animation,delete to.animationiteration.animation,delete to.animationstart.animation),"TransitionEvent"in window||delete to.transitionend.transition);function su(a){if(zh[a])return zh[a];if(!to[a])return a;var c=to[a],f;for(f in c)if(c.hasOwnProperty(f)&&f in dv)return zh[a]=c[f];return a}var hv=su("animationend"),mv=su("animationiteration"),fv=su("animationstart"),pv=su("transitionend"),gv=new Map,xv="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 Sr(a,c){gv.set(a,c),o(c,[a])}for(var Dh=0;Dh<xv.length;Dh++){var Fh=xv[Dh],aC=Fh.toLowerCase(),oC=Fh[0].toUpperCase()+Fh.slice(1);Sr(aC,"on"+oC)}Sr(hv,"onAnimationEnd"),Sr(mv,"onAnimationIteration"),Sr(fv,"onAnimationStart"),Sr("dblclick","onDoubleClick"),Sr("focusin","onFocus"),Sr("focusout","onBlur"),Sr(pv,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("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 ml="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(" "),lC=new Set("cancel close invalid load scroll toggle".split(" ").concat(ml));function vv(a,c,f){var b=a.type||"unknown-event";a.currentTarget=f,br(b,c,void 0,a),a.currentTarget=null}function yv(a,c){c=(c&4)!==0;for(var f=0;f<a.length;f++){var b=a[f],C=b.event;b=b.listeners;e:{var $=void 0;if(c)for(var W=b.length-1;0<=W;W--){var se=b[W],ae=se.instance,ye=se.currentTarget;if(se=se.listener,ae!==$&&C.isPropagationStopped())break e;vv(C,se,ye),$=ae}else for(W=0;W<b.length;W++){if(se=b[W],ae=se.instance,ye=se.currentTarget,se=se.listener,ae!==$&&C.isPropagationStopped())break e;vv(C,se,ye),$=ae}}}if(xs)throw a=ui,xs=!1,ui=null,a}function qt(a,c){var f=c[Gh];f===void 0&&(f=c[Gh]=new Set);var b=a+"__bubble";f.has(b)||(bv(c,a,2,!1),f.add(b))}function Uh(a,c,f){var b=0;c&&(b|=4),bv(f,a,b,c)}var iu="_reactListening"+Math.random().toString(36).slice(2);function fl(a){if(!a[iu]){a[iu]=!0,i.forEach(function(f){f!=="selectionchange"&&(lC.has(f)||Uh(f,!1,a),Uh(f,!0,a))});var c=a.nodeType===9?a:a.ownerDocument;c===null||c[iu]||(c[iu]=!0,Uh("selectionchange",!1,c))}}function bv(a,c,f,b){switch(er(c)){case 1:var C=xt;break;case 4:C=pn;break;default:C=js}f=C.bind(null,c,f,a),C=void 0,!Ue||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(C=!0),b?C!==void 0?a.addEventListener(c,f,{capture:!0,passive:C}):a.addEventListener(c,f,!0):C!==void 0?a.addEventListener(c,f,{passive:C}):a.addEventListener(c,f,!1)}function Bh(a,c,f,b,C){var $=b;if((c&1)===0&&(c&2)===0&&b!==null)e:for(;;){if(b===null)return;var W=b.tag;if(W===3||W===4){var se=b.stateNode.containerInfo;if(se===C||se.nodeType===8&&se.parentNode===C)break;if(W===4)for(W=b.return;W!==null;){var ae=W.tag;if((ae===3||ae===4)&&(ae=W.stateNode.containerInfo,ae===C||ae.nodeType===8&&ae.parentNode===C))return;W=W.return}for(;se!==null;){if(W=da(se),W===null)return;if(ae=W.tag,ae===5||ae===6){b=$=W;continue e}se=se.parentNode}}b=b.return}Nt(function(){var ye=$,Te=Zn(f),Re=[];e:{var Ie=gv.get(a);if(Ie!==void 0){var We=Eh,Ke=a;switch(a){case"keypress":if(Qc(f)===0)break e;case"keydown":case"keyup":We=zE;break;case"focusin":Ke="focus",We=$h;break;case"focusout":Ke="blur",We=$h;break;case"beforeblur":case"afterblur":We=$h;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":We=Vx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":We=_E;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":We=UE;break;case hv:case mv:case fv:We=AE;break;case pv:We=HE;break;case"scroll":We=wE;break;case"wheel":We=WE;break;case"copy":case"cut":case"paste":We=IE;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":We=Gx}var Qe=(c&4)!==0,gn=!Qe&&a==="scroll",pe=Qe?Ie!==null?Ie+"Capture":null:Ie;Qe=[];for(var ue=ye,xe;ue!==null;){xe=ue;var ze=xe.stateNode;if(xe.tag===5&&ze!==null&&(xe=ze,pe!==null&&(ze=He(ue,pe),ze!=null&&Qe.push(pl(ue,ze,xe)))),gn)break;ue=ue.return}0<Qe.length&&(Ie=new We(Ie,Ke,null,f,Te),Re.push({event:Ie,listeners:Qe}))}}if((c&7)===0){e:{if(Ie=a==="mouseover"||a==="pointerover",We=a==="mouseout"||a==="pointerout",Ie&&f!==Kn&&(Ke=f.relatedTarget||f.fromElement)&&(da(Ke)||Ke[tr]))break e;if((We||Ie)&&(Ie=Te.window===Te?Te:(Ie=Te.ownerDocument)?Ie.defaultView||Ie.parentWindow:window,We?(Ke=f.relatedTarget||f.toElement,We=ye,Ke=Ke?da(Ke):null,Ke!==null&&(gn=Qn(Ke),Ke!==gn||Ke.tag!==5&&Ke.tag!==6)&&(Ke=null)):(We=null,Ke=ye),We!==Ke)){if(Qe=Vx,ze="onMouseLeave",pe="onMouseEnter",ue="mouse",(a==="pointerout"||a==="pointerover")&&(Qe=Gx,ze="onPointerLeave",pe="onPointerEnter",ue="pointer"),gn=We==null?Ie:io(We),xe=Ke==null?Ie:io(Ke),Ie=new Qe(ze,ue+"leave",We,f,Te),Ie.target=gn,Ie.relatedTarget=xe,ze=null,da(Te)===ye&&(Qe=new Qe(pe,ue+"enter",Ke,f,Te),Qe.target=xe,Qe.relatedTarget=gn,ze=Qe),gn=ze,We&&Ke)t:{for(Qe=We,pe=Ke,ue=0,xe=Qe;xe;xe=no(xe))ue++;for(xe=0,ze=pe;ze;ze=no(ze))xe++;for(;0<ue-xe;)Qe=no(Qe),ue--;for(;0<xe-ue;)pe=no(pe),xe--;for(;ue--;){if(Qe===pe||pe!==null&&Qe===pe.alternate)break t;Qe=no(Qe),pe=no(pe)}Qe=null}else Qe=null;We!==null&&kv(Re,Ie,We,Qe,!1),Ke!==null&&gn!==null&&kv(Re,gn,Ke,Qe,!0)}}e:{if(Ie=ye?io(ye):window,We=Ie.nodeName&&Ie.nodeName.toLowerCase(),We==="select"||We==="input"&&Ie.type==="file")var Je=QE;else if(ev(Ie))if(nv)Je=nC;else{Je=eC;var st=JE}else(We=Ie.nodeName)&&We.toLowerCase()==="input"&&(Ie.type==="checkbox"||Ie.type==="radio")&&(Je=tC);if(Je&&(Je=Je(a,ye))){tv(Re,Je,f,Te);break e}st&&st(a,Ie,ye),a==="focusout"&&(st=Ie._wrapperState)&&st.controlled&&Ie.type==="number"&&ft(Ie,"number",Ie.value)}switch(st=ye?io(ye):window,a){case"focusin":(ev(st)||st.contentEditable==="true")&&(eo=st,Ph=ye,hl=null);break;case"focusout":hl=Ph=eo=null;break;case"mousedown":Lh=!0;break;case"contextmenu":case"mouseup":case"dragend":Lh=!1,uv(Re,f,Te);break;case"selectionchange":if(rC)break;case"keydown":case"keyup":uv(Re,f,Te)}var it;if(Th)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 Ja?Qx(a,f)&&(lt="onCompositionEnd"):a==="keydown"&&f.keyCode===229&&(lt="onCompositionStart");lt&&(Kx&&f.locale!=="ko"&&(Ja||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&Ja&&(it=Zx()):(an=Te,Xa="value"in an?an.value:an.textContent,Ja=!0)),st=ru(ye,lt),0<st.length&&(lt=new qx(lt,a,null,f,Te),Re.push({event:lt,listeners:st}),it?lt.data=it:(it=Jx(f),it!==null&&(lt.data=it)))),(it=qE?GE(a,f):KE(a,f))&&(ye=ru(ye,"onBeforeInput"),0<ye.length&&(Te=new qx("onBeforeInput","beforeinput",null,f,Te),Re.push({event:Te,listeners:ye}),Te.data=it))}yv(Re,c)})}function pl(a,c,f){return{instance:a,listener:c,currentTarget:f}}function ru(a,c){for(var f=c+"Capture",b=[];a!==null;){var C=a,$=C.stateNode;C.tag===5&&$!==null&&(C=$,$=He(a,f),$!=null&&b.unshift(pl(a,$,C)),$=He(a,c),$!=null&&b.push(pl(a,$,C))),a=a.return}return b}function no(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function kv(a,c,f,b,C){for(var $=c._reactName,W=[];f!==null&&f!==b;){var se=f,ae=se.alternate,ye=se.stateNode;if(ae!==null&&ae===b)break;se.tag===5&&ye!==null&&(se=ye,C?(ae=He(f,$),ae!=null&&W.unshift(pl(f,ae,se))):C||(ae=He(f,$),ae!=null&&W.push(pl(f,ae,se)))),f=f.return}W.length!==0&&a.push({event:c,listeners:W})}var cC=/\r\n?/g,uC=/\u0000|\uFFFD/g;function jv(a){return(typeof a=="string"?a:""+a).replace(cC,`
|
|
38
|
-
`).replace(uC,"")}function au(a,c,f){if(c=jv(c),jv(a)!==c&&f)throw Error(s(425))}function ou(){}var Hh=null,Zh=null;function Wh(a,c){return a==="textarea"||a==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var Vh=typeof setTimeout=="function"?setTimeout:void 0,dC=typeof clearTimeout=="function"?clearTimeout:void 0,Nv=typeof Promise=="function"?Promise:void 0,hC=typeof queueMicrotask=="function"?queueMicrotask:typeof Nv<"u"?function(a){return Nv.resolve(null).then(a).catch(mC)}:Vh;function mC(a){setTimeout(function(){throw a})}function qh(a,c){var f=c,b=0;do{var C=f.nextSibling;if(a.removeChild(f),C&&C.nodeType===8)if(f=C.data,f==="/$"){if(b===0){a.removeChild(C),we(c);return}b--}else f!=="$"&&f!=="$?"&&f!=="$!"||b++;f=C}while(f);we(c)}function _r(a){for(;a!=null;a=a.nextSibling){var c=a.nodeType;if(c===1||c===3)break;if(c===8){if(c=a.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return a}function wv(a){a=a.previousSibling;for(var c=0;a;){if(a.nodeType===8){var f=a.data;if(f==="$"||f==="$!"||f==="$?"){if(c===0)return a;c--}else f==="/$"&&c++}a=a.previousSibling}return null}var so=Math.random().toString(36).slice(2),Pi="__reactFiber$"+so,gl="__reactProps$"+so,tr="__reactContainer$"+so,Gh="__reactEvents$"+so,fC="__reactListeners$"+so,pC="__reactHandles$"+so;function da(a){var c=a[Pi];if(c)return c;for(var f=a.parentNode;f;){if(c=f[tr]||f[Pi]){if(f=c.alternate,c.child!==null||f!==null&&f.child!==null)for(a=wv(a);a!==null;){if(f=a[Pi])return f;a=wv(a)}return c}a=f,f=a.parentNode}return null}function xl(a){return a=a[Pi]||a[tr],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function io(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(s(33))}function lu(a){return a[gl]||null}var Kh=[],ro=-1;function Er(a){return{current:a}}function Gt(a){0>ro||(a.current=Kh[ro],Kh[ro]=null,ro--)}function Wt(a,c){ro++,Kh[ro]=a.current,a.current=c}var Cr={},es=Er(Cr),Ns=Er(!1),ha=Cr;function ao(a,c){var f=a.type.contextTypes;if(!f)return Cr;var b=a.stateNode;if(b&&b.__reactInternalMemoizedUnmaskedChildContext===c)return b.__reactInternalMemoizedMaskedChildContext;var C={},$;for($ in f)C[$]=c[$];return b&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=c,a.__reactInternalMemoizedMaskedChildContext=C),C}function ws(a){return a=a.childContextTypes,a!=null}function cu(){Gt(Ns),Gt(es)}function Sv(a,c,f){if(es.current!==Cr)throw Error(s(168));Wt(es,c),Wt(Ns,f)}function _v(a,c,f){var b=a.stateNode;if(c=c.childContextTypes,typeof b.getChildContext!="function")return f;b=b.getChildContext();for(var C in b)if(!(C in c))throw Error(s(108,ie(a)||"Unknown",C));return te({},f,b)}function uu(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||Cr,ha=es.current,Wt(es,a),Wt(Ns,Ns.current),!0}function Ev(a,c,f){var b=a.stateNode;if(!b)throw Error(s(169));f?(a=_v(a,c,ha),b.__reactInternalMemoizedMergedChildContext=a,Gt(Ns),Gt(es),Wt(es,a)):Gt(Ns),Wt(Ns,f)}var nr=null,du=!1,Yh=!1;function Cv(a){nr===null?nr=[a]:nr.push(a)}function gC(a){du=!0,Cv(a)}function Ar(){if(!Yh&&nr!==null){Yh=!0;var a=0,c=wt;try{var f=nr;for(wt=1;a<f.length;a++){var b=f[a];do b=b(!0);while(b!==null)}nr=null,du=!1}catch(C){throw nr!==null&&(nr=nr.slice(a+1)),Os(Yi,Ar),C}finally{wt=c,Yh=!1}}return null}var oo=[],lo=0,hu=null,mu=0,Js=[],ei=0,ma=null,sr=1,ir="";function fa(a,c){oo[lo++]=mu,oo[lo++]=hu,hu=a,mu=c}function Av(a,c,f){Js[ei++]=sr,Js[ei++]=ir,Js[ei++]=ma,ma=a;var b=sr;a=ir;var C=32-Ft(b)-1;b&=~(1<<C),f+=1;var $=32-Ft(c)+C;if(30<$){var W=C-C%5;$=(b&(1<<W)-1).toString(32),b>>=W,C-=W,sr=1<<32-Ft(c)+C|f<<C|b,ir=$+a}else sr=1<<$|f<<C|b,ir=a}function Xh(a){a.return!==null&&(fa(a,1),Av(a,1,0))}function Qh(a){for(;a===hu;)hu=oo[--lo],oo[lo]=null,mu=oo[--lo],oo[lo]=null;for(;a===ma;)ma=Js[--ei],Js[ei]=null,ir=Js[--ei],Js[ei]=null,sr=Js[--ei],Js[ei]=null}var Ls=null,zs=null,Jt=!1,gi=null;function $v(a,c){var f=ii(5,null,null,0);f.elementType="DELETED",f.stateNode=c,f.return=a,c=a.deletions,c===null?(a.deletions=[f],a.flags|=16):c.push(f)}function Iv(a,c){switch(a.tag){case 5:var f=a.type;return c=c.nodeType!==1||f.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(a.stateNode=c,Ls=a,zs=_r(c.firstChild),!0):!1;case 6:return c=a.pendingProps===""||c.nodeType!==3?null:c,c!==null?(a.stateNode=c,Ls=a,zs=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(f=ma!==null?{id:sr,overflow:ir}:null,a.memoizedState={dehydrated:c,treeContext:f,retryLane:1073741824},f=ii(18,null,null,0),f.stateNode=c,f.return=a,a.child=f,Ls=a,zs=null,!0):!1;default:return!1}}function Jh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function em(a){if(Jt){var c=zs;if(c){var f=c;if(!Iv(a,c)){if(Jh(a))throw Error(s(418));c=_r(f.nextSibling);var b=Ls;c&&Iv(a,c)?$v(b,f):(a.flags=a.flags&-4097|2,Jt=!1,Ls=a)}}else{if(Jh(a))throw Error(s(418));a.flags=a.flags&-4097|2,Jt=!1,Ls=a}}}function Tv(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Ls=a}function fu(a){if(a!==Ls)return!1;if(!Jt)return Tv(a),Jt=!0,!1;var c;if((c=a.tag!==3)&&!(c=a.tag!==5)&&(c=a.type,c=c!=="head"&&c!=="body"&&!Wh(a.type,a.memoizedProps)),c&&(c=zs)){if(Jh(a))throw Mv(),Error(s(418));for(;c;)$v(a,c),c=_r(c.nextSibling)}if(Tv(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(s(317));e:{for(a=a.nextSibling,c=0;a;){if(a.nodeType===8){var f=a.data;if(f==="/$"){if(c===0){zs=_r(a.nextSibling);break e}c--}else f!=="$"&&f!=="$!"&&f!=="$?"||c++}a=a.nextSibling}zs=null}}else zs=Ls?_r(a.stateNode.nextSibling):null;return!0}function Mv(){for(var a=zs;a;)a=_r(a.nextSibling)}function co(){zs=Ls=null,Jt=!1}function tm(a){gi===null?gi=[a]:gi.push(a)}var xC=E.ReactCurrentBatchConfig;function vl(a,c,f){if(a=f.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(f._owner){if(f=f._owner,f){if(f.tag!==1)throw Error(s(309));var b=f.stateNode}if(!b)throw Error(s(147,a));var C=b,$=""+a;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===$?c.ref:(c=function(W){var se=C.refs;W===null?delete se[$]:se[$]=W},c._stringRef=$,c)}if(typeof a!="string")throw Error(s(284));if(!f._owner)throw Error(s(290,a))}return a}function pu(a,c){throw a=Object.prototype.toString.call(c),Error(s(31,a==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":a))}function Rv(a){var c=a._init;return c(a._payload)}function Ov(a){function c(pe,ue){if(a){var xe=pe.deletions;xe===null?(pe.deletions=[ue],pe.flags|=16):xe.push(ue)}}function f(pe,ue){if(!a)return null;for(;ue!==null;)c(pe,ue),ue=ue.sibling;return null}function b(pe,ue){for(pe=new Map;ue!==null;)ue.key!==null?pe.set(ue.key,ue):pe.set(ue.index,ue),ue=ue.sibling;return pe}function C(pe,ue){return pe=Lr(pe,ue),pe.index=0,pe.sibling=null,pe}function $(pe,ue,xe){return pe.index=xe,a?(xe=pe.alternate,xe!==null?(xe=xe.index,xe<ue?(pe.flags|=2,ue):xe):(pe.flags|=2,ue)):(pe.flags|=1048576,ue)}function W(pe){return a&&pe.alternate===null&&(pe.flags|=2),pe}function se(pe,ue,xe,ze){return ue===null||ue.tag!==6?(ue=Vm(xe,pe.mode,ze),ue.return=pe,ue):(ue=C(ue,xe),ue.return=pe,ue)}function ae(pe,ue,xe,ze){var Je=xe.type;return Je===H?Te(pe,ue,xe.props.children,ze,xe.key):ue!==null&&(ue.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===D&&Rv(Je)===ue.type)?(ze=C(ue,xe.props),ze.ref=vl(pe,ue,xe),ze.return=pe,ze):(ze=Du(xe.type,xe.key,xe.props,null,pe.mode,ze),ze.ref=vl(pe,ue,xe),ze.return=pe,ze)}function ye(pe,ue,xe,ze){return ue===null||ue.tag!==4||ue.stateNode.containerInfo!==xe.containerInfo||ue.stateNode.implementation!==xe.implementation?(ue=qm(xe,pe.mode,ze),ue.return=pe,ue):(ue=C(ue,xe.children||[]),ue.return=pe,ue)}function Te(pe,ue,xe,ze,Je){return ue===null||ue.tag!==7?(ue=ja(xe,pe.mode,ze,Je),ue.return=pe,ue):(ue=C(ue,xe),ue.return=pe,ue)}function Re(pe,ue,xe){if(typeof ue=="string"&&ue!==""||typeof ue=="number")return ue=Vm(""+ue,pe.mode,xe),ue.return=pe,ue;if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case O:return xe=Du(ue.type,ue.key,ue.props,null,pe.mode,xe),xe.ref=vl(pe,null,ue),xe.return=pe,xe;case P:return ue=qm(ue,pe.mode,xe),ue.return=pe,ue;case D:var ze=ue._init;return Re(pe,ze(ue._payload),xe)}if(gt(ue)||q(ue))return ue=ja(ue,pe.mode,xe,null),ue.return=pe,ue;pu(pe,ue)}return null}function Ie(pe,ue,xe,ze){var Je=ue!==null?ue.key:null;if(typeof xe=="string"&&xe!==""||typeof xe=="number")return Je!==null?null:se(pe,ue,""+xe,ze);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case O:return xe.key===Je?ae(pe,ue,xe,ze):null;case P:return xe.key===Je?ye(pe,ue,xe,ze):null;case D:return Je=xe._init,Ie(pe,ue,Je(xe._payload),ze)}if(gt(xe)||q(xe))return Je!==null?null:Te(pe,ue,xe,ze,null);pu(pe,xe)}return null}function We(pe,ue,xe,ze,Je){if(typeof ze=="string"&&ze!==""||typeof ze=="number")return pe=pe.get(xe)||null,se(ue,pe,""+ze,Je);if(typeof ze=="object"&&ze!==null){switch(ze.$$typeof){case O:return pe=pe.get(ze.key===null?xe:ze.key)||null,ae(ue,pe,ze,Je);case P:return pe=pe.get(ze.key===null?xe:ze.key)||null,ye(ue,pe,ze,Je);case D:var st=ze._init;return We(pe,ue,xe,st(ze._payload),Je)}if(gt(ze)||q(ze))return pe=pe.get(xe)||null,Te(ue,pe,ze,Je,null);pu(ue,ze)}return null}function Ke(pe,ue,xe,ze){for(var Je=null,st=null,it=ue,lt=ue=0,Dn=null;it!==null&<<xe.length;lt++){it.index>lt?(Dn=it,it=null):Dn=it.sibling;var $t=Ie(pe,it,xe[lt],ze);if($t===null){it===null&&(it=Dn);break}a&&it&&$t.alternate===null&&c(pe,it),ue=$($t,ue,lt),st===null?Je=$t:st.sibling=$t,st=$t,it=Dn}if(lt===xe.length)return f(pe,it),Jt&&fa(pe,lt),Je;if(it===null){for(;lt<xe.length;lt++)it=Re(pe,xe[lt],ze),it!==null&&(ue=$(it,ue,lt),st===null?Je=it:st.sibling=it,st=it);return Jt&&fa(pe,lt),Je}for(it=b(pe,it);lt<xe.length;lt++)Dn=We(it,pe,lt,xe[lt],ze),Dn!==null&&(a&&Dn.alternate!==null&&it.delete(Dn.key===null?lt:Dn.key),ue=$(Dn,ue,lt),st===null?Je=Dn:st.sibling=Dn,st=Dn);return a&&it.forEach(function(zr){return c(pe,zr)}),Jt&&fa(pe,lt),Je}function Qe(pe,ue,xe,ze){var Je=q(xe);if(typeof Je!="function")throw Error(s(150));if(xe=Je.call(xe),xe==null)throw Error(s(151));for(var st=Je=null,it=ue,lt=ue=0,Dn=null,$t=xe.next();it!==null&&!$t.done;lt++,$t=xe.next()){it.index>lt?(Dn=it,it=null):Dn=it.sibling;var zr=Ie(pe,it,$t.value,ze);if(zr===null){it===null&&(it=Dn);break}a&&it&&zr.alternate===null&&c(pe,it),ue=$(zr,ue,lt),st===null?Je=zr:st.sibling=zr,st=zr,it=Dn}if($t.done)return f(pe,it),Jt&&fa(pe,lt),Je;if(it===null){for(;!$t.done;lt++,$t=xe.next())$t=Re(pe,$t.value,ze),$t!==null&&(ue=$($t,ue,lt),st===null?Je=$t:st.sibling=$t,st=$t);return Jt&&fa(pe,lt),Je}for(it=b(pe,it);!$t.done;lt++,$t=xe.next())$t=We(it,pe,lt,$t.value,ze),$t!==null&&(a&&$t.alternate!==null&&it.delete($t.key===null?lt:$t.key),ue=$($t,ue,lt),st===null?Je=$t:st.sibling=$t,st=$t);return a&&it.forEach(function(YC){return c(pe,YC)}),Jt&&fa(pe,lt),Je}function gn(pe,ue,xe,ze){if(typeof xe=="object"&&xe!==null&&xe.type===H&&xe.key===null&&(xe=xe.props.children),typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case O:e:{for(var Je=xe.key,st=ue;st!==null;){if(st.key===Je){if(Je=xe.type,Je===H){if(st.tag===7){f(pe,st.sibling),ue=C(st,xe.props.children),ue.return=pe,pe=ue;break e}}else if(st.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===D&&Rv(Je)===st.type){f(pe,st.sibling),ue=C(st,xe.props),ue.ref=vl(pe,st,xe),ue.return=pe,pe=ue;break e}f(pe,st);break}else c(pe,st);st=st.sibling}xe.type===H?(ue=ja(xe.props.children,pe.mode,ze,xe.key),ue.return=pe,pe=ue):(ze=Du(xe.type,xe.key,xe.props,null,pe.mode,ze),ze.ref=vl(pe,ue,xe),ze.return=pe,pe=ze)}return W(pe);case P:e:{for(st=xe.key;ue!==null;){if(ue.key===st)if(ue.tag===4&&ue.stateNode.containerInfo===xe.containerInfo&&ue.stateNode.implementation===xe.implementation){f(pe,ue.sibling),ue=C(ue,xe.children||[]),ue.return=pe,pe=ue;break e}else{f(pe,ue);break}else c(pe,ue);ue=ue.sibling}ue=qm(xe,pe.mode,ze),ue.return=pe,pe=ue}return W(pe);case D:return st=xe._init,gn(pe,ue,st(xe._payload),ze)}if(gt(xe))return Ke(pe,ue,xe,ze);if(q(xe))return Qe(pe,ue,xe,ze);pu(pe,xe)}return typeof xe=="string"&&xe!==""||typeof xe=="number"?(xe=""+xe,ue!==null&&ue.tag===6?(f(pe,ue.sibling),ue=C(ue,xe),ue.return=pe,pe=ue):(f(pe,ue),ue=Vm(xe,pe.mode,ze),ue.return=pe,pe=ue),W(pe)):f(pe,ue)}return gn}var uo=Ov(!0),Pv=Ov(!1),gu=Er(null),xu=null,ho=null,nm=null;function sm(){nm=ho=xu=null}function im(a){var c=gu.current;Gt(gu),a._currentValue=c}function rm(a,c,f){for(;a!==null;){var b=a.alternate;if((a.childLanes&c)!==c?(a.childLanes|=c,b!==null&&(b.childLanes|=c)):b!==null&&(b.childLanes&c)!==c&&(b.childLanes|=c),a===f)break;a=a.return}}function mo(a,c){xu=a,nm=ho=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&c)!==0&&(Ss=!0),a.firstContext=null)}function ti(a){var c=a._currentValue;if(nm!==a)if(a={context:a,memoizedValue:c,next:null},ho===null){if(xu===null)throw Error(s(308));ho=a,xu.dependencies={lanes:0,firstContext:a}}else ho=ho.next=a;return c}var pa=null;function am(a){pa===null?pa=[a]:pa.push(a)}function Lv(a,c,f,b){var C=c.interleaved;return C===null?(f.next=f,am(c)):(f.next=C.next,C.next=f),c.interleaved=f,rr(a,b)}function rr(a,c){a.lanes|=c;var f=a.alternate;for(f!==null&&(f.lanes|=c),f=a,a=a.return;a!==null;)a.childLanes|=c,f=a.alternate,f!==null&&(f.childLanes|=c),f=a,a=a.return;return f.tag===3?f.stateNode:null}var $r=!1;function om(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function zv(a,c){a=a.updateQueue,c.updateQueue===a&&(c.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function ar(a,c){return{eventTime:a,lane:c,tag:0,payload:null,callback:null,next:null}}function Ir(a,c,f){var b=a.updateQueue;if(b===null)return null;if(b=b.shared,(Et&2)!==0){var C=b.pending;return C===null?c.next=c:(c.next=C.next,C.next=c),b.pending=c,rr(a,f)}return C=b.interleaved,C===null?(c.next=c,am(b)):(c.next=C.next,C.next=c),b.interleaved=c,rr(a,f)}function vu(a,c,f){if(c=c.updateQueue,c!==null&&(c=c.shared,(f&4194240)!==0)){var b=c.lanes;b&=a.pendingLanes,f|=b,c.lanes=f,Qs(a,f)}}function Dv(a,c){var f=a.updateQueue,b=a.alternate;if(b!==null&&(b=b.updateQueue,f===b)){var C=null,$=null;if(f=f.firstBaseUpdate,f!==null){do{var W={eventTime:f.eventTime,lane:f.lane,tag:f.tag,payload:f.payload,callback:f.callback,next:null};$===null?C=$=W:$=$.next=W,f=f.next}while(f!==null);$===null?C=$=c:$=$.next=c}else C=$=c;f={baseState:b.baseState,firstBaseUpdate:C,lastBaseUpdate:$,shared:b.shared,effects:b.effects},a.updateQueue=f;return}a=f.lastBaseUpdate,a===null?f.firstBaseUpdate=c:a.next=c,f.lastBaseUpdate=c}function yu(a,c,f,b){var C=a.updateQueue;$r=!1;var $=C.firstBaseUpdate,W=C.lastBaseUpdate,se=C.shared.pending;if(se!==null){C.shared.pending=null;var ae=se,ye=ae.next;ae.next=null,W===null?$=ye:W.next=ye,W=ae;var Te=a.alternate;Te!==null&&(Te=Te.updateQueue,se=Te.lastBaseUpdate,se!==W&&(se===null?Te.firstBaseUpdate=ye:se.next=ye,Te.lastBaseUpdate=ae))}if($!==null){var Re=C.baseState;W=0,Te=ye=ae=null,se=$;do{var Ie=se.lane,We=se.eventTime;if((b&Ie)===Ie){Te!==null&&(Te=Te.next={eventTime:We,lane:0,tag:se.tag,payload:se.payload,callback:se.callback,next:null});e:{var Ke=a,Qe=se;switch(Ie=c,We=f,Qe.tag){case 1:if(Ke=Qe.payload,typeof Ke=="function"){Re=Ke.call(We,Re,Ie);break e}Re=Ke;break e;case 3:Ke.flags=Ke.flags&-65537|128;case 0:if(Ke=Qe.payload,Ie=typeof Ke=="function"?Ke.call(We,Re,Ie):Ke,Ie==null)break e;Re=te({},Re,Ie);break e;case 2:$r=!0}}se.callback!==null&&se.lane!==0&&(a.flags|=64,Ie=C.effects,Ie===null?C.effects=[se]:Ie.push(se))}else We={eventTime:We,lane:Ie,tag:se.tag,payload:se.payload,callback:se.callback,next:null},Te===null?(ye=Te=We,ae=Re):Te=Te.next=We,W|=Ie;if(se=se.next,se===null){if(se=C.shared.pending,se===null)break;Ie=se,se=Ie.next,Ie.next=null,C.lastBaseUpdate=Ie,C.shared.pending=null}}while(!0);if(Te===null&&(ae=Re),C.baseState=ae,C.firstBaseUpdate=ye,C.lastBaseUpdate=Te,c=C.shared.interleaved,c!==null){C=c;do W|=C.lane,C=C.next;while(C!==c)}else $===null&&(C.shared.lanes=0);va|=W,a.lanes=W,a.memoizedState=Re}}function Fv(a,c,f){if(a=c.effects,c.effects=null,a!==null)for(c=0;c<a.length;c++){var b=a[c],C=b.callback;if(C!==null){if(b.callback=null,b=f,typeof C!="function")throw Error(s(191,C));C.call(b)}}}var yl={},Li=Er(yl),bl=Er(yl),kl=Er(yl);function ga(a){if(a===yl)throw Error(s(174));return a}function lm(a,c){switch(Wt(kl,c),Wt(bl,a),Wt(Li,yl),a=c.nodeType,a){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:Qt(null,"");break;default:a=a===8?c.parentNode:c,c=a.namespaceURI||null,a=a.tagName,c=Qt(c,a)}Gt(Li),Wt(Li,c)}function fo(){Gt(Li),Gt(bl),Gt(kl)}function Uv(a){ga(kl.current);var c=ga(Li.current),f=Qt(c,a.type);c!==f&&(Wt(bl,a),Wt(Li,f))}function cm(a){bl.current===a&&(Gt(Li),Gt(bl))}var on=Er(0);function bu(a){for(var c=a;c!==null;){if(c.tag===13){var f=c.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||f.data==="$?"||f.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var um=[];function dm(){for(var a=0;a<um.length;a++)um[a]._workInProgressVersionPrimary=null;um.length=0}var ku=E.ReactCurrentDispatcher,hm=E.ReactCurrentBatchConfig,xa=0,ln=null,Tn=null,Ln=null,ju=!1,jl=!1,Nl=0,vC=0;function ts(){throw Error(s(321))}function mm(a,c){if(c===null)return!1;for(var f=0;f<c.length&&f<a.length;f++)if(!pi(a[f],c[f]))return!1;return!0}function fm(a,c,f,b,C,$){if(xa=$,ln=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,ku.current=a===null||a.memoizedState===null?jC:NC,a=f(b,C),jl){$=0;do{if(jl=!1,Nl=0,25<=$)throw Error(s(301));$+=1,Ln=Tn=null,c.updateQueue=null,ku.current=wC,a=f(b,C)}while(jl)}if(ku.current=Su,c=Tn!==null&&Tn.next!==null,xa=0,Ln=Tn=ln=null,ju=!1,c)throw Error(s(300));return a}function pm(){var a=Nl!==0;return Nl=0,a}function zi(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ln===null?ln.memoizedState=Ln=a:Ln=Ln.next=a,Ln}function ni(){if(Tn===null){var a=ln.alternate;a=a!==null?a.memoizedState:null}else a=Tn.next;var c=Ln===null?ln.memoizedState:Ln.next;if(c!==null)Ln=c,Tn=a;else{if(a===null)throw Error(s(310));Tn=a,a={memoizedState:Tn.memoizedState,baseState:Tn.baseState,baseQueue:Tn.baseQueue,queue:Tn.queue,next:null},Ln===null?ln.memoizedState=Ln=a:Ln=Ln.next=a}return Ln}function wl(a,c){return typeof c=="function"?c(a):c}function gm(a){var c=ni(),f=c.queue;if(f===null)throw Error(s(311));f.lastRenderedReducer=a;var b=Tn,C=b.baseQueue,$=f.pending;if($!==null){if(C!==null){var W=C.next;C.next=$.next,$.next=W}b.baseQueue=C=$,f.pending=null}if(C!==null){$=C.next,b=b.baseState;var se=W=null,ae=null,ye=$;do{var Te=ye.lane;if((xa&Te)===Te)ae!==null&&(ae=ae.next={lane:0,action:ye.action,hasEagerState:ye.hasEagerState,eagerState:ye.eagerState,next:null}),b=ye.hasEagerState?ye.eagerState:a(b,ye.action);else{var Re={lane:Te,action:ye.action,hasEagerState:ye.hasEagerState,eagerState:ye.eagerState,next:null};ae===null?(se=ae=Re,W=b):ae=ae.next=Re,ln.lanes|=Te,va|=Te}ye=ye.next}while(ye!==null&&ye!==$);ae===null?W=b:ae.next=se,pi(b,c.memoizedState)||(Ss=!0),c.memoizedState=b,c.baseState=W,c.baseQueue=ae,f.lastRenderedState=b}if(a=f.interleaved,a!==null){C=a;do $=C.lane,ln.lanes|=$,va|=$,C=C.next;while(C!==a)}else C===null&&(f.lanes=0);return[c.memoizedState,f.dispatch]}function xm(a){var c=ni(),f=c.queue;if(f===null)throw Error(s(311));f.lastRenderedReducer=a;var b=f.dispatch,C=f.pending,$=c.memoizedState;if(C!==null){f.pending=null;var W=C=C.next;do $=a($,W.action),W=W.next;while(W!==C);pi($,c.memoizedState)||(Ss=!0),c.memoizedState=$,c.baseQueue===null&&(c.baseState=$),f.lastRenderedState=$}return[$,b]}function Bv(){}function Hv(a,c){var f=ln,b=ni(),C=c(),$=!pi(b.memoizedState,C);if($&&(b.memoizedState=C,Ss=!0),b=b.queue,vm(Vv.bind(null,f,b,a),[a]),b.getSnapshot!==c||$||Ln!==null&&Ln.memoizedState.tag&1){if(f.flags|=2048,Sl(9,Wv.bind(null,f,b,C,c),void 0,null),zn===null)throw Error(s(349));(xa&30)!==0||Zv(f,c,C)}return C}function Zv(a,c,f){a.flags|=16384,a={getSnapshot:c,value:f},c=ln.updateQueue,c===null?(c={lastEffect:null,stores:null},ln.updateQueue=c,c.stores=[a]):(f=c.stores,f===null?c.stores=[a]:f.push(a))}function Wv(a,c,f,b){c.value=f,c.getSnapshot=b,qv(c)&&Gv(a)}function Vv(a,c,f){return f(function(){qv(c)&&Gv(a)})}function qv(a){var c=a.getSnapshot;a=a.value;try{var f=c();return!pi(a,f)}catch{return!0}}function Gv(a){var c=rr(a,1);c!==null&&bi(c,a,1,-1)}function Kv(a){var c=zi();return typeof a=="function"&&(a=a()),c.memoizedState=c.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:wl,lastRenderedState:a},c.queue=a,a=a.dispatch=kC.bind(null,ln,a),[c.memoizedState,a]}function Sl(a,c,f,b){return a={tag:a,create:c,destroy:f,deps:b,next:null},c=ln.updateQueue,c===null?(c={lastEffect:null,stores:null},ln.updateQueue=c,c.lastEffect=a.next=a):(f=c.lastEffect,f===null?c.lastEffect=a.next=a:(b=f.next,f.next=a,a.next=b,c.lastEffect=a)),a}function Yv(){return ni().memoizedState}function Nu(a,c,f,b){var C=zi();ln.flags|=a,C.memoizedState=Sl(1|c,f,void 0,b===void 0?null:b)}function wu(a,c,f,b){var C=ni();b=b===void 0?null:b;var $=void 0;if(Tn!==null){var W=Tn.memoizedState;if($=W.destroy,b!==null&&mm(b,W.deps)){C.memoizedState=Sl(c,f,$,b);return}}ln.flags|=a,C.memoizedState=Sl(1|c,f,$,b)}function Xv(a,c){return Nu(8390656,8,a,c)}function vm(a,c){return wu(2048,8,a,c)}function Qv(a,c){return wu(4,2,a,c)}function Jv(a,c){return wu(4,4,a,c)}function e0(a,c){if(typeof c=="function")return a=a(),c(a),function(){c(null)};if(c!=null)return a=a(),c.current=a,function(){c.current=null}}function t0(a,c,f){return f=f!=null?f.concat([a]):null,wu(4,4,e0.bind(null,c,a),f)}function ym(){}function n0(a,c){var f=ni();c=c===void 0?null:c;var b=f.memoizedState;return b!==null&&c!==null&&mm(c,b[1])?b[0]:(f.memoizedState=[a,c],a)}function s0(a,c){var f=ni();c=c===void 0?null:c;var b=f.memoizedState;return b!==null&&c!==null&&mm(c,b[1])?b[0]:(a=a(),f.memoizedState=[a,c],a)}function i0(a,c,f){return(xa&21)===0?(a.baseState&&(a.baseState=!1,Ss=!0),a.memoizedState=f):(pi(f,c)||(f=wr(),ln.lanes|=f,va|=f,a.baseState=!0),c)}function yC(a,c){var f=wt;wt=f!==0&&4>f?f:4,a(!0);var b=hm.transition;hm.transition={};try{a(!1),c()}finally{wt=f,hm.transition=b}}function r0(){return ni().memoizedState}function bC(a,c,f){var b=Or(a);if(f={lane:b,action:f,hasEagerState:!1,eagerState:null,next:null},a0(a))o0(c,f);else if(f=Lv(a,c,f,b),f!==null){var C=ds();bi(f,a,b,C),l0(f,c,b)}}function kC(a,c,f){var b=Or(a),C={lane:b,action:f,hasEagerState:!1,eagerState:null,next:null};if(a0(a))o0(c,C);else{var $=a.alternate;if(a.lanes===0&&($===null||$.lanes===0)&&($=c.lastRenderedReducer,$!==null))try{var W=c.lastRenderedState,se=$(W,f);if(C.hasEagerState=!0,C.eagerState=se,pi(se,W)){var ae=c.interleaved;ae===null?(C.next=C,am(c)):(C.next=ae.next,ae.next=C),c.interleaved=C;return}}catch{}finally{}f=Lv(a,c,C,b),f!==null&&(C=ds(),bi(f,a,b,C),l0(f,c,b))}}function a0(a){var c=a.alternate;return a===ln||c!==null&&c===ln}function o0(a,c){jl=ju=!0;var f=a.pending;f===null?c.next=c:(c.next=f.next,f.next=c),a.pending=c}function l0(a,c,f){if((f&4194240)!==0){var b=c.lanes;b&=a.pendingLanes,f|=b,c.lanes=f,Qs(a,f)}}var Su={readContext:ti,useCallback:ts,useContext:ts,useEffect:ts,useImperativeHandle:ts,useInsertionEffect:ts,useLayoutEffect:ts,useMemo:ts,useReducer:ts,useRef:ts,useState:ts,useDebugValue:ts,useDeferredValue:ts,useTransition:ts,useMutableSource:ts,useSyncExternalStore:ts,useId:ts,unstable_isNewReconciler:!1},jC={readContext:ti,useCallback:function(a,c){return zi().memoizedState=[a,c===void 0?null:c],a},useContext:ti,useEffect:Xv,useImperativeHandle:function(a,c,f){return f=f!=null?f.concat([a]):null,Nu(4194308,4,e0.bind(null,c,a),f)},useLayoutEffect:function(a,c){return Nu(4194308,4,a,c)},useInsertionEffect:function(a,c){return Nu(4,2,a,c)},useMemo:function(a,c){var f=zi();return c=c===void 0?null:c,a=a(),f.memoizedState=[a,c],a},useReducer:function(a,c,f){var b=zi();return c=f!==void 0?f(c):c,b.memoizedState=b.baseState=c,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:c},b.queue=a,a=a.dispatch=bC.bind(null,ln,a),[b.memoizedState,a]},useRef:function(a){var c=zi();return a={current:a},c.memoizedState=a},useState:Kv,useDebugValue:ym,useDeferredValue:function(a){return zi().memoizedState=a},useTransition:function(){var a=Kv(!1),c=a[0];return a=yC.bind(null,a[1]),zi().memoizedState=a,[c,a]},useMutableSource:function(){},useSyncExternalStore:function(a,c,f){var b=ln,C=zi();if(Jt){if(f===void 0)throw Error(s(407));f=f()}else{if(f=c(),zn===null)throw Error(s(349));(xa&30)!==0||Zv(b,c,f)}C.memoizedState=f;var $={value:f,getSnapshot:c};return C.queue=$,Xv(Vv.bind(null,b,$,a),[a]),b.flags|=2048,Sl(9,Wv.bind(null,b,$,f,c),void 0,null),f},useId:function(){var a=zi(),c=zn.identifierPrefix;if(Jt){var f=ir,b=sr;f=(b&~(1<<32-Ft(b)-1)).toString(32)+f,c=":"+c+"R"+f,f=Nl++,0<f&&(c+="H"+f.toString(32)),c+=":"}else f=vC++,c=":"+c+"r"+f.toString(32)+":";return a.memoizedState=c},unstable_isNewReconciler:!1},NC={readContext:ti,useCallback:n0,useContext:ti,useEffect:vm,useImperativeHandle:t0,useInsertionEffect:Qv,useLayoutEffect:Jv,useMemo:s0,useReducer:gm,useRef:Yv,useState:function(){return gm(wl)},useDebugValue:ym,useDeferredValue:function(a){var c=ni();return i0(c,Tn.memoizedState,a)},useTransition:function(){var a=gm(wl)[0],c=ni().memoizedState;return[a,c]},useMutableSource:Bv,useSyncExternalStore:Hv,useId:r0,unstable_isNewReconciler:!1},wC={readContext:ti,useCallback:n0,useContext:ti,useEffect:vm,useImperativeHandle:t0,useInsertionEffect:Qv,useLayoutEffect:Jv,useMemo:s0,useReducer:xm,useRef:Yv,useState:function(){return xm(wl)},useDebugValue:ym,useDeferredValue:function(a){var c=ni();return Tn===null?c.memoizedState=a:i0(c,Tn.memoizedState,a)},useTransition:function(){var a=xm(wl)[0],c=ni().memoizedState;return[a,c]},useMutableSource:Bv,useSyncExternalStore:Hv,useId:r0,unstable_isNewReconciler:!1};function xi(a,c){if(a&&a.defaultProps){c=te({},c),a=a.defaultProps;for(var f in a)c[f]===void 0&&(c[f]=a[f]);return c}return c}function bm(a,c,f,b){c=a.memoizedState,f=f(b,c),f=f==null?c:te({},c,f),a.memoizedState=f,a.lanes===0&&(a.updateQueue.baseState=f)}var _u={isMounted:function(a){return(a=a._reactInternals)?Qn(a)===a:!1},enqueueSetState:function(a,c,f){a=a._reactInternals;var b=ds(),C=Or(a),$=ar(b,C);$.payload=c,f!=null&&($.callback=f),c=Ir(a,$,C),c!==null&&(bi(c,a,C,b),vu(c,a,C))},enqueueReplaceState:function(a,c,f){a=a._reactInternals;var b=ds(),C=Or(a),$=ar(b,C);$.tag=1,$.payload=c,f!=null&&($.callback=f),c=Ir(a,$,C),c!==null&&(bi(c,a,C,b),vu(c,a,C))},enqueueForceUpdate:function(a,c){a=a._reactInternals;var f=ds(),b=Or(a),C=ar(f,b);C.tag=2,c!=null&&(C.callback=c),c=Ir(a,C,b),c!==null&&(bi(c,a,b,f),vu(c,a,b))}};function c0(a,c,f,b,C,$,W){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(b,$,W):c.prototype&&c.prototype.isPureReactComponent?!dl(f,b)||!dl(C,$):!0}function u0(a,c,f){var b=!1,C=Cr,$=c.contextType;return typeof $=="object"&&$!==null?$=ti($):(C=ws(c)?ha:es.current,b=c.contextTypes,$=(b=b!=null)?ao(a,C):Cr),c=new c(f,$),a.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=_u,a.stateNode=c,c._reactInternals=a,b&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=C,a.__reactInternalMemoizedMaskedChildContext=$),c}function d0(a,c,f,b){a=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(f,b),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(f,b),c.state!==a&&_u.enqueueReplaceState(c,c.state,null)}function km(a,c,f,b){var C=a.stateNode;C.props=f,C.state=a.memoizedState,C.refs={},om(a);var $=c.contextType;typeof $=="object"&&$!==null?C.context=ti($):($=ws(c)?ha:es.current,C.context=ao(a,$)),C.state=a.memoizedState,$=c.getDerivedStateFromProps,typeof $=="function"&&(bm(a,c,$,f),C.state=a.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(c=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),c!==C.state&&_u.enqueueReplaceState(C,C.state,null),yu(a,f,C,b),C.state=a.memoizedState),typeof C.componentDidMount=="function"&&(a.flags|=4194308)}function po(a,c){try{var f="",b=c;do f+=J(b),b=b.return;while(b);var C=f}catch($){C=`
|
|
39
|
-
Error generating stack: `+$.message+`
|
|
40
|
-
`+$.stack}return{value:a,source:c,stack:C,digest:null}}function jm(a,c,f){return{value:a,source:null,stack:f??null,digest:c??null}}function Nm(a,c){try{console.error(c.value)}catch(f){setTimeout(function(){throw f})}}var SC=typeof WeakMap=="function"?WeakMap:Map;function h0(a,c,f){f=ar(-1,f),f.tag=3,f.payload={element:null};var b=c.value;return f.callback=function(){Mu||(Mu=!0,zm=b),Nm(a,c)},f}function m0(a,c,f){f=ar(-1,f),f.tag=3;var b=a.type.getDerivedStateFromError;if(typeof b=="function"){var C=c.value;f.payload=function(){return b(C)},f.callback=function(){Nm(a,c)}}var $=a.stateNode;return $!==null&&typeof $.componentDidCatch=="function"&&(f.callback=function(){Nm(a,c),typeof b!="function"&&(Mr===null?Mr=new Set([this]):Mr.add(this));var W=c.stack;this.componentDidCatch(c.value,{componentStack:W!==null?W:""})}),f}function f0(a,c,f){var b=a.pingCache;if(b===null){b=a.pingCache=new SC;var C=new Set;b.set(c,C)}else C=b.get(c),C===void 0&&(C=new Set,b.set(c,C));C.has(f)||(C.add(f),a=DC.bind(null,a,c,f),c.then(a,a))}function p0(a){do{var c;if((c=a.tag===13)&&(c=a.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return a;a=a.return}while(a!==null);return null}function g0(a,c,f,b,C){return(a.mode&1)===0?(a===c?a.flags|=65536:(a.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(c=ar(-1,1),c.tag=2,Ir(f,c,1))),f.lanes|=1),a):(a.flags|=65536,a.lanes=C,a)}var _C=E.ReactCurrentOwner,Ss=!1;function us(a,c,f,b){c.child=a===null?Pv(c,null,f,b):uo(c,a.child,f,b)}function x0(a,c,f,b,C){f=f.render;var $=c.ref;return mo(c,C),b=fm(a,c,f,b,$,C),f=pm(),a!==null&&!Ss?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~C,or(a,c,C)):(Jt&&f&&Xh(c),c.flags|=1,us(a,c,b,C),c.child)}function v0(a,c,f,b,C){if(a===null){var $=f.type;return typeof $=="function"&&!Wm($)&&$.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0?(c.tag=15,c.type=$,y0(a,c,$,b,C)):(a=Du(f.type,null,b,c,c.mode,C),a.ref=c.ref,a.return=c,c.child=a)}if($=a.child,(a.lanes&C)===0){var W=$.memoizedProps;if(f=f.compare,f=f!==null?f:dl,f(W,b)&&a.ref===c.ref)return or(a,c,C)}return c.flags|=1,a=Lr($,b),a.ref=c.ref,a.return=c,c.child=a}function y0(a,c,f,b,C){if(a!==null){var $=a.memoizedProps;if(dl($,b)&&a.ref===c.ref)if(Ss=!1,c.pendingProps=b=$,(a.lanes&C)!==0)(a.flags&131072)!==0&&(Ss=!0);else return c.lanes=a.lanes,or(a,c,C)}return wm(a,c,f,b,C)}function b0(a,c,f){var b=c.pendingProps,C=b.children,$=a!==null?a.memoizedState:null;if(b.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wt(xo,Ds),Ds|=f;else{if((f&1073741824)===0)return a=$!==null?$.baseLanes|f:f,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:a,cachePool:null,transitions:null},c.updateQueue=null,Wt(xo,Ds),Ds|=a,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},b=$!==null?$.baseLanes:f,Wt(xo,Ds),Ds|=b}else $!==null?(b=$.baseLanes|f,c.memoizedState=null):b=f,Wt(xo,Ds),Ds|=b;return us(a,c,C,f),c.child}function k0(a,c){var f=c.ref;(a===null&&f!==null||a!==null&&a.ref!==f)&&(c.flags|=512,c.flags|=2097152)}function wm(a,c,f,b,C){var $=ws(f)?ha:es.current;return $=ao(c,$),mo(c,C),f=fm(a,c,f,b,$,C),b=pm(),a!==null&&!Ss?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~C,or(a,c,C)):(Jt&&b&&Xh(c),c.flags|=1,us(a,c,f,C),c.child)}function j0(a,c,f,b,C){if(ws(f)){var $=!0;uu(c)}else $=!1;if(mo(c,C),c.stateNode===null)Cu(a,c),u0(c,f,b),km(c,f,b,C),b=!0;else if(a===null){var W=c.stateNode,se=c.memoizedProps;W.props=se;var ae=W.context,ye=f.contextType;typeof ye=="object"&&ye!==null?ye=ti(ye):(ye=ws(f)?ha:es.current,ye=ao(c,ye));var Te=f.getDerivedStateFromProps,Re=typeof Te=="function"||typeof W.getSnapshotBeforeUpdate=="function";Re||typeof W.UNSAFE_componentWillReceiveProps!="function"&&typeof W.componentWillReceiveProps!="function"||(se!==b||ae!==ye)&&d0(c,W,b,ye),$r=!1;var Ie=c.memoizedState;W.state=Ie,yu(c,b,W,C),ae=c.memoizedState,se!==b||Ie!==ae||Ns.current||$r?(typeof Te=="function"&&(bm(c,f,Te,b),ae=c.memoizedState),(se=$r||c0(c,f,se,b,Ie,ae,ye))?(Re||typeof W.UNSAFE_componentWillMount!="function"&&typeof W.componentWillMount!="function"||(typeof W.componentWillMount=="function"&&W.componentWillMount(),typeof W.UNSAFE_componentWillMount=="function"&&W.UNSAFE_componentWillMount()),typeof W.componentDidMount=="function"&&(c.flags|=4194308)):(typeof W.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=b,c.memoizedState=ae),W.props=b,W.state=ae,W.context=ye,b=se):(typeof W.componentDidMount=="function"&&(c.flags|=4194308),b=!1)}else{W=c.stateNode,zv(a,c),se=c.memoizedProps,ye=c.type===c.elementType?se:xi(c.type,se),W.props=ye,Re=c.pendingProps,Ie=W.context,ae=f.contextType,typeof ae=="object"&&ae!==null?ae=ti(ae):(ae=ws(f)?ha:es.current,ae=ao(c,ae));var We=f.getDerivedStateFromProps;(Te=typeof We=="function"||typeof W.getSnapshotBeforeUpdate=="function")||typeof W.UNSAFE_componentWillReceiveProps!="function"&&typeof W.componentWillReceiveProps!="function"||(se!==Re||Ie!==ae)&&d0(c,W,b,ae),$r=!1,Ie=c.memoizedState,W.state=Ie,yu(c,b,W,C);var Ke=c.memoizedState;se!==Re||Ie!==Ke||Ns.current||$r?(typeof We=="function"&&(bm(c,f,We,b),Ke=c.memoizedState),(ye=$r||c0(c,f,ye,b,Ie,Ke,ae)||!1)?(Te||typeof W.UNSAFE_componentWillUpdate!="function"&&typeof W.componentWillUpdate!="function"||(typeof W.componentWillUpdate=="function"&&W.componentWillUpdate(b,Ke,ae),typeof W.UNSAFE_componentWillUpdate=="function"&&W.UNSAFE_componentWillUpdate(b,Ke,ae)),typeof W.componentDidUpdate=="function"&&(c.flags|=4),typeof W.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof W.componentDidUpdate!="function"||se===a.memoizedProps&&Ie===a.memoizedState||(c.flags|=4),typeof W.getSnapshotBeforeUpdate!="function"||se===a.memoizedProps&&Ie===a.memoizedState||(c.flags|=1024),c.memoizedProps=b,c.memoizedState=Ke),W.props=b,W.state=Ke,W.context=ae,b=ye):(typeof W.componentDidUpdate!="function"||se===a.memoizedProps&&Ie===a.memoizedState||(c.flags|=4),typeof W.getSnapshotBeforeUpdate!="function"||se===a.memoizedProps&&Ie===a.memoizedState||(c.flags|=1024),b=!1)}return Sm(a,c,f,b,$,C)}function Sm(a,c,f,b,C,$){k0(a,c);var W=(c.flags&128)!==0;if(!b&&!W)return C&&Ev(c,f,!1),or(a,c,$);b=c.stateNode,_C.current=c;var se=W&&typeof f.getDerivedStateFromError!="function"?null:b.render();return c.flags|=1,a!==null&&W?(c.child=uo(c,a.child,null,$),c.child=uo(c,null,se,$)):us(a,c,se,$),c.memoizedState=b.state,C&&Ev(c,f,!0),c.child}function N0(a){var c=a.stateNode;c.pendingContext?Sv(a,c.pendingContext,c.pendingContext!==c.context):c.context&&Sv(a,c.context,!1),lm(a,c.containerInfo)}function w0(a,c,f,b,C){return co(),tm(C),c.flags|=256,us(a,c,f,b),c.child}var _m={dehydrated:null,treeContext:null,retryLane:0};function Em(a){return{baseLanes:a,cachePool:null,transitions:null}}function S0(a,c,f){var b=c.pendingProps,C=on.current,$=!1,W=(c.flags&128)!==0,se;if((se=W)||(se=a!==null&&a.memoizedState===null?!1:(C&2)!==0),se?($=!0,c.flags&=-129):(a===null||a.memoizedState!==null)&&(C|=1),Wt(on,C&1),a===null)return em(c),a=c.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((c.mode&1)===0?c.lanes=1:a.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(W=b.children,a=b.fallback,$?(b=c.mode,$=c.child,W={mode:"hidden",children:W},(b&1)===0&&$!==null?($.childLanes=0,$.pendingProps=W):$=Fu(W,b,0,null),a=ja(a,b,f,null),$.return=c,a.return=c,$.sibling=a,c.child=$,c.child.memoizedState=Em(f),c.memoizedState=_m,a):Cm(c,W));if(C=a.memoizedState,C!==null&&(se=C.dehydrated,se!==null))return EC(a,c,W,b,se,C,f);if($){$=b.fallback,W=c.mode,C=a.child,se=C.sibling;var ae={mode:"hidden",children:b.children};return(W&1)===0&&c.child!==C?(b=c.child,b.childLanes=0,b.pendingProps=ae,c.deletions=null):(b=Lr(C,ae),b.subtreeFlags=C.subtreeFlags&14680064),se!==null?$=Lr(se,$):($=ja($,W,f,null),$.flags|=2),$.return=c,b.return=c,b.sibling=$,c.child=b,b=$,$=c.child,W=a.child.memoizedState,W=W===null?Em(f):{baseLanes:W.baseLanes|f,cachePool:null,transitions:W.transitions},$.memoizedState=W,$.childLanes=a.childLanes&~f,c.memoizedState=_m,b}return $=a.child,a=$.sibling,b=Lr($,{mode:"visible",children:b.children}),(c.mode&1)===0&&(b.lanes=f),b.return=c,b.sibling=null,a!==null&&(f=c.deletions,f===null?(c.deletions=[a],c.flags|=16):f.push(a)),c.child=b,c.memoizedState=null,b}function Cm(a,c){return c=Fu({mode:"visible",children:c},a.mode,0,null),c.return=a,a.child=c}function Eu(a,c,f,b){return b!==null&&tm(b),uo(c,a.child,null,f),a=Cm(c,c.pendingProps.children),a.flags|=2,c.memoizedState=null,a}function EC(a,c,f,b,C,$,W){if(f)return c.flags&256?(c.flags&=-257,b=jm(Error(s(422))),Eu(a,c,W,b)):c.memoizedState!==null?(c.child=a.child,c.flags|=128,null):($=b.fallback,C=c.mode,b=Fu({mode:"visible",children:b.children},C,0,null),$=ja($,C,W,null),$.flags|=2,b.return=c,$.return=c,b.sibling=$,c.child=b,(c.mode&1)!==0&&uo(c,a.child,null,W),c.child.memoizedState=Em(W),c.memoizedState=_m,$);if((c.mode&1)===0)return Eu(a,c,W,null);if(C.data==="$!"){if(b=C.nextSibling&&C.nextSibling.dataset,b)var se=b.dgst;return b=se,$=Error(s(419)),b=jm($,b,void 0),Eu(a,c,W,b)}if(se=(W&a.childLanes)!==0,Ss||se){if(b=zn,b!==null){switch(W&-W){case 4:C=2;break;case 16:C=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:C=32;break;case 536870912:C=268435456;break;default:C=0}C=(C&(b.suspendedLanes|W))!==0?0:C,C!==0&&C!==$.retryLane&&($.retryLane=C,rr(a,C),bi(b,a,C,-1))}return Zm(),b=jm(Error(s(421))),Eu(a,c,W,b)}return C.data==="$?"?(c.flags|=128,c.child=a.child,c=FC.bind(null,a),C._reactRetry=c,null):(a=$.treeContext,zs=_r(C.nextSibling),Ls=c,Jt=!0,gi=null,a!==null&&(Js[ei++]=sr,Js[ei++]=ir,Js[ei++]=ma,sr=a.id,ir=a.overflow,ma=c),c=Cm(c,b.children),c.flags|=4096,c)}function _0(a,c,f){a.lanes|=c;var b=a.alternate;b!==null&&(b.lanes|=c),rm(a.return,c,f)}function Am(a,c,f,b,C){var $=a.memoizedState;$===null?a.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:b,tail:f,tailMode:C}:($.isBackwards=c,$.rendering=null,$.renderingStartTime=0,$.last=b,$.tail=f,$.tailMode=C)}function E0(a,c,f){var b=c.pendingProps,C=b.revealOrder,$=b.tail;if(us(a,c,b.children,f),b=on.current,(b&2)!==0)b=b&1|2,c.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=c.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&_0(a,f,c);else if(a.tag===19)_0(a,f,c);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===c)break e;for(;a.sibling===null;){if(a.return===null||a.return===c)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}b&=1}if(Wt(on,b),(c.mode&1)===0)c.memoizedState=null;else switch(C){case"forwards":for(f=c.child,C=null;f!==null;)a=f.alternate,a!==null&&bu(a)===null&&(C=f),f=f.sibling;f=C,f===null?(C=c.child,c.child=null):(C=f.sibling,f.sibling=null),Am(c,!1,C,f,$);break;case"backwards":for(f=null,C=c.child,c.child=null;C!==null;){if(a=C.alternate,a!==null&&bu(a)===null){c.child=C;break}a=C.sibling,C.sibling=f,f=C,C=a}Am(c,!0,f,null,$);break;case"together":Am(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function Cu(a,c){(c.mode&1)===0&&a!==null&&(a.alternate=null,c.alternate=null,c.flags|=2)}function or(a,c,f){if(a!==null&&(c.dependencies=a.dependencies),va|=c.lanes,(f&c.childLanes)===0)return null;if(a!==null&&c.child!==a.child)throw Error(s(153));if(c.child!==null){for(a=c.child,f=Lr(a,a.pendingProps),c.child=f,f.return=c;a.sibling!==null;)a=a.sibling,f=f.sibling=Lr(a,a.pendingProps),f.return=c;f.sibling=null}return c.child}function CC(a,c,f){switch(c.tag){case 3:N0(c),co();break;case 5:Uv(c);break;case 1:ws(c.type)&&uu(c);break;case 4:lm(c,c.stateNode.containerInfo);break;case 10:var b=c.type._context,C=c.memoizedProps.value;Wt(gu,b._currentValue),b._currentValue=C;break;case 13:if(b=c.memoizedState,b!==null)return b.dehydrated!==null?(Wt(on,on.current&1),c.flags|=128,null):(f&c.child.childLanes)!==0?S0(a,c,f):(Wt(on,on.current&1),a=or(a,c,f),a!==null?a.sibling:null);Wt(on,on.current&1);break;case 19:if(b=(f&c.childLanes)!==0,(a.flags&128)!==0){if(b)return E0(a,c,f);c.flags|=128}if(C=c.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),Wt(on,on.current),b)break;return null;case 22:case 23:return c.lanes=0,b0(a,c,f)}return or(a,c,f)}var C0,$m,A0,$0;C0=function(a,c){for(var f=c.child;f!==null;){if(f.tag===5||f.tag===6)a.appendChild(f.stateNode);else if(f.tag!==4&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===c)break;for(;f.sibling===null;){if(f.return===null||f.return===c)return;f=f.return}f.sibling.return=f.return,f=f.sibling}},$m=function(){},A0=function(a,c,f,b){var C=a.memoizedProps;if(C!==b){a=c.stateNode,ga(Li.current);var $=null;switch(f){case"input":C=ke(a,C),b=ke(a,b),$=[];break;case"select":C=te({},C,{value:void 0}),b=te({},b,{value:void 0}),$=[];break;case"textarea":C=En(a,C),b=En(a,b),$=[];break;default:typeof C.onClick!="function"&&typeof b.onClick=="function"&&(a.onclick=ou)}Cn(f,b);var W;f=null;for(ye in C)if(!b.hasOwnProperty(ye)&&C.hasOwnProperty(ye)&&C[ye]!=null)if(ye==="style"){var se=C[ye];for(W in se)se.hasOwnProperty(W)&&(f||(f={}),f[W]="")}else ye!=="dangerouslySetInnerHTML"&&ye!=="children"&&ye!=="suppressContentEditableWarning"&&ye!=="suppressHydrationWarning"&&ye!=="autoFocus"&&(r.hasOwnProperty(ye)?$||($=[]):($=$||[]).push(ye,null));for(ye in b){var ae=b[ye];if(se=C!=null?C[ye]:void 0,b.hasOwnProperty(ye)&&ae!==se&&(ae!=null||se!=null))if(ye==="style")if(se){for(W in se)!se.hasOwnProperty(W)||ae&&ae.hasOwnProperty(W)||(f||(f={}),f[W]="");for(W in ae)ae.hasOwnProperty(W)&&se[W]!==ae[W]&&(f||(f={}),f[W]=ae[W])}else f||($||($=[]),$.push(ye,f)),f=ae;else ye==="dangerouslySetInnerHTML"?(ae=ae?ae.__html:void 0,se=se?se.__html:void 0,ae!=null&&se!==ae&&($=$||[]).push(ye,ae)):ye==="children"?typeof ae!="string"&&typeof ae!="number"||($=$||[]).push(ye,""+ae):ye!=="suppressContentEditableWarning"&&ye!=="suppressHydrationWarning"&&(r.hasOwnProperty(ye)?(ae!=null&&ye==="onScroll"&&qt("scroll",a),$||se===ae||($=[])):($=$||[]).push(ye,ae))}f&&($=$||[]).push("style",f);var ye=$;(c.updateQueue=ye)&&(c.flags|=4)}},$0=function(a,c,f,b){f!==b&&(c.flags|=4)};function _l(a,c){if(!Jt)switch(a.tailMode){case"hidden":c=a.tail;for(var f=null;c!==null;)c.alternate!==null&&(f=c),c=c.sibling;f===null?a.tail=null:f.sibling=null;break;case"collapsed":f=a.tail;for(var b=null;f!==null;)f.alternate!==null&&(b=f),f=f.sibling;b===null?c||a.tail===null?a.tail=null:a.tail.sibling=null:b.sibling=null}}function ns(a){var c=a.alternate!==null&&a.alternate.child===a.child,f=0,b=0;if(c)for(var C=a.child;C!==null;)f|=C.lanes|C.childLanes,b|=C.subtreeFlags&14680064,b|=C.flags&14680064,C.return=a,C=C.sibling;else for(C=a.child;C!==null;)f|=C.lanes|C.childLanes,b|=C.subtreeFlags,b|=C.flags,C.return=a,C=C.sibling;return a.subtreeFlags|=b,a.childLanes=f,c}function AC(a,c,f){var b=c.pendingProps;switch(Qh(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ns(c),null;case 1:return ws(c.type)&&cu(),ns(c),null;case 3:return b=c.stateNode,fo(),Gt(Ns),Gt(es),dm(),b.pendingContext&&(b.context=b.pendingContext,b.pendingContext=null),(a===null||a.child===null)&&(fu(c)?c.flags|=4:a===null||a.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,gi!==null&&(Um(gi),gi=null))),$m(a,c),ns(c),null;case 5:cm(c);var C=ga(kl.current);if(f=c.type,a!==null&&c.stateNode!=null)A0(a,c,f,b,C),a.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!b){if(c.stateNode===null)throw Error(s(166));return ns(c),null}if(a=ga(Li.current),fu(c)){b=c.stateNode,f=c.type;var $=c.memoizedProps;switch(b[Pi]=c,b[gl]=$,a=(c.mode&1)!==0,f){case"dialog":qt("cancel",b),qt("close",b);break;case"iframe":case"object":case"embed":qt("load",b);break;case"video":case"audio":for(C=0;C<ml.length;C++)qt(ml[C],b);break;case"source":qt("error",b);break;case"img":case"image":case"link":qt("error",b),qt("load",b);break;case"details":qt("toggle",b);break;case"input":ge(b,$),qt("invalid",b);break;case"select":b._wrapperState={wasMultiple:!!$.multiple},qt("invalid",b);break;case"textarea":rt(b,$),qt("invalid",b)}Cn(f,$),C=null;for(var W in $)if($.hasOwnProperty(W)){var se=$[W];W==="children"?typeof se=="string"?b.textContent!==se&&($.suppressHydrationWarning!==!0&&au(b.textContent,se,a),C=["children",se]):typeof se=="number"&&b.textContent!==""+se&&($.suppressHydrationWarning!==!0&&au(b.textContent,se,a),C=["children",""+se]):r.hasOwnProperty(W)&&se!=null&&W==="onScroll"&&qt("scroll",b)}switch(f){case"input":Fe(b),qe(b,$,!0);break;case"textarea":Fe(b),rn(b);break;case"select":case"option":break;default:typeof $.onClick=="function"&&(b.onclick=ou)}b=C,c.updateQueue=b,b!==null&&(c.flags|=4)}else{W=C.nodeType===9?C:C.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=Zt(f)),a==="http://www.w3.org/1999/xhtml"?f==="script"?(a=W.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof b.is=="string"?a=W.createElement(f,{is:b.is}):(a=W.createElement(f),f==="select"&&(W=a,b.multiple?W.multiple=!0:b.size&&(W.size=b.size))):a=W.createElementNS(a,f),a[Pi]=c,a[gl]=b,C0(a,c,!1,!1),c.stateNode=a;e:{switch(W=as(f,b),f){case"dialog":qt("cancel",a),qt("close",a),C=b;break;case"iframe":case"object":case"embed":qt("load",a),C=b;break;case"video":case"audio":for(C=0;C<ml.length;C++)qt(ml[C],a);C=b;break;case"source":qt("error",a),C=b;break;case"img":case"image":case"link":qt("error",a),qt("load",a),C=b;break;case"details":qt("toggle",a),C=b;break;case"input":ge(a,b),C=ke(a,b),qt("invalid",a);break;case"option":C=b;break;case"select":a._wrapperState={wasMultiple:!!b.multiple},C=te({},b,{value:void 0}),qt("invalid",a);break;case"textarea":rt(a,b),C=En(a,b),qt("invalid",a);break;default:C=b}Cn(f,C),se=C;for($ in se)if(se.hasOwnProperty($)){var ae=se[$];$==="style"?rs(a,ae):$==="dangerouslySetInnerHTML"?(ae=ae?ae.__html:void 0,ae!=null&&Rn(a,ae)):$==="children"?typeof ae=="string"?(f!=="textarea"||ae!=="")&&mn(a,ae):typeof ae=="number"&&mn(a,""+ae):$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&$!=="autoFocus"&&(r.hasOwnProperty($)?ae!=null&&$==="onScroll"&&qt("scroll",a):ae!=null&&S(a,$,ae,W))}switch(f){case"input":Fe(a),qe(a,b,!1);break;case"textarea":Fe(a),rn(a);break;case"option":b.value!=null&&a.setAttribute("value",""+ne(b.value));break;case"select":a.multiple=!!b.multiple,$=b.value,$!=null?Rt(a,!!b.multiple,$,!1):b.defaultValue!=null&&Rt(a,!!b.multiple,b.defaultValue,!0);break;default:typeof C.onClick=="function"&&(a.onclick=ou)}switch(f){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}}b&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return ns(c),null;case 6:if(a&&c.stateNode!=null)$0(a,c,a.memoizedProps,b);else{if(typeof b!="string"&&c.stateNode===null)throw Error(s(166));if(f=ga(kl.current),ga(Li.current),fu(c)){if(b=c.stateNode,f=c.memoizedProps,b[Pi]=c,($=b.nodeValue!==f)&&(a=Ls,a!==null))switch(a.tag){case 3:au(b.nodeValue,f,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&au(b.nodeValue,f,(a.mode&1)!==0)}$&&(c.flags|=4)}else b=(f.nodeType===9?f:f.ownerDocument).createTextNode(b),b[Pi]=c,c.stateNode=b}return ns(c),null;case 13:if(Gt(on),b=c.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(Jt&&zs!==null&&(c.mode&1)!==0&&(c.flags&128)===0)Mv(),co(),c.flags|=98560,$=!1;else if($=fu(c),b!==null&&b.dehydrated!==null){if(a===null){if(!$)throw Error(s(318));if($=c.memoizedState,$=$!==null?$.dehydrated:null,!$)throw Error(s(317));$[Pi]=c}else co(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;ns(c),$=!1}else gi!==null&&(Um(gi),gi=null),$=!0;if(!$)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=f,c):(b=b!==null,b!==(a!==null&&a.memoizedState!==null)&&b&&(c.child.flags|=8192,(c.mode&1)!==0&&(a===null||(on.current&1)!==0?Mn===0&&(Mn=3):Zm())),c.updateQueue!==null&&(c.flags|=4),ns(c),null);case 4:return fo(),$m(a,c),a===null&&fl(c.stateNode.containerInfo),ns(c),null;case 10:return im(c.type._context),ns(c),null;case 17:return ws(c.type)&&cu(),ns(c),null;case 19:if(Gt(on),$=c.memoizedState,$===null)return ns(c),null;if(b=(c.flags&128)!==0,W=$.rendering,W===null)if(b)_l($,!1);else{if(Mn!==0||a!==null&&(a.flags&128)!==0)for(a=c.child;a!==null;){if(W=bu(a),W!==null){for(c.flags|=128,_l($,!1),b=W.updateQueue,b!==null&&(c.updateQueue=b,c.flags|=4),c.subtreeFlags=0,b=f,f=c.child;f!==null;)$=f,a=b,$.flags&=14680066,W=$.alternate,W===null?($.childLanes=0,$.lanes=a,$.child=null,$.subtreeFlags=0,$.memoizedProps=null,$.memoizedState=null,$.updateQueue=null,$.dependencies=null,$.stateNode=null):($.childLanes=W.childLanes,$.lanes=W.lanes,$.child=W.child,$.subtreeFlags=0,$.deletions=null,$.memoizedProps=W.memoizedProps,$.memoizedState=W.memoizedState,$.updateQueue=W.updateQueue,$.type=W.type,a=W.dependencies,$.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),f=f.sibling;return Wt(on,on.current&1|2),c.child}a=a.sibling}$.tail!==null&&Dt()>vo&&(c.flags|=128,b=!0,_l($,!1),c.lanes=4194304)}else{if(!b)if(a=bu(W),a!==null){if(c.flags|=128,b=!0,f=a.updateQueue,f!==null&&(c.updateQueue=f,c.flags|=4),_l($,!0),$.tail===null&&$.tailMode==="hidden"&&!W.alternate&&!Jt)return ns(c),null}else 2*Dt()-$.renderingStartTime>vo&&f!==1073741824&&(c.flags|=128,b=!0,_l($,!1),c.lanes=4194304);$.isBackwards?(W.sibling=c.child,c.child=W):(f=$.last,f!==null?f.sibling=W:c.child=W,$.last=W)}return $.tail!==null?(c=$.tail,$.rendering=c,$.tail=c.sibling,$.renderingStartTime=Dt(),c.sibling=null,f=on.current,Wt(on,b?f&1|2:f&1),c):(ns(c),null);case 22:case 23:return Hm(),b=c.memoizedState!==null,a!==null&&a.memoizedState!==null!==b&&(c.flags|=8192),b&&(c.mode&1)!==0?(Ds&1073741824)!==0&&(ns(c),c.subtreeFlags&6&&(c.flags|=8192)):ns(c),null;case 24:return null;case 25:return null}throw Error(s(156,c.tag))}function $C(a,c){switch(Qh(c),c.tag){case 1:return ws(c.type)&&cu(),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return fo(),Gt(Ns),Gt(es),dm(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 5:return cm(c),null;case 13:if(Gt(on),a=c.memoizedState,a!==null&&a.dehydrated!==null){if(c.alternate===null)throw Error(s(340));co()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 19:return Gt(on),null;case 4:return fo(),null;case 10:return im(c.type._context),null;case 22:case 23:return Hm(),null;case 24:return null;default:return null}}var Au=!1,ss=!1,IC=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function go(a,c){var f=a.ref;if(f!==null)if(typeof f=="function")try{f(null)}catch(b){hn(a,c,b)}else f.current=null}function Im(a,c,f){try{f()}catch(b){hn(a,c,b)}}var I0=!1;function TC(a,c){if(Hh=nt,a=cv(),Oh(a)){if("selectionStart"in a)var f={start:a.selectionStart,end:a.selectionEnd};else e:{f=(f=a.ownerDocument)&&f.defaultView||window;var b=f.getSelection&&f.getSelection();if(b&&b.rangeCount!==0){f=b.anchorNode;var C=b.anchorOffset,$=b.focusNode;b=b.focusOffset;try{f.nodeType,$.nodeType}catch{f=null;break e}var W=0,se=-1,ae=-1,ye=0,Te=0,Re=a,Ie=null;t:for(;;){for(var We;Re!==f||C!==0&&Re.nodeType!==3||(se=W+C),Re!==$||b!==0&&Re.nodeType!==3||(ae=W+b),Re.nodeType===3&&(W+=Re.nodeValue.length),(We=Re.firstChild)!==null;)Ie=Re,Re=We;for(;;){if(Re===a)break t;if(Ie===f&&++ye===C&&(se=W),Ie===$&&++Te===b&&(ae=W),(We=Re.nextSibling)!==null)break;Re=Ie,Ie=Re.parentNode}Re=We}f=se===-1||ae===-1?null:{start:se,end:ae}}else f=null}f=f||{start:0,end:0}}else f=null;for(Zh={focusedElem:a,selectionRange:f},nt=!1,Ge=c;Ge!==null;)if(c=Ge,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,Ge=a;else for(;Ge!==null;){c=Ge;try{var Ke=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(Ke!==null){var Qe=Ke.memoizedProps,gn=Ke.memoizedState,pe=c.stateNode,ue=pe.getSnapshotBeforeUpdate(c.elementType===c.type?Qe:xi(c.type,Qe),gn);pe.__reactInternalSnapshotBeforeUpdate=ue}break;case 3:var xe=c.stateNode.containerInfo;xe.nodeType===1?xe.textContent="":xe.nodeType===9&&xe.documentElement&&xe.removeChild(xe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(ze){hn(c,c.return,ze)}if(a=c.sibling,a!==null){a.return=c.return,Ge=a;break}Ge=c.return}return Ke=I0,I0=!1,Ke}function El(a,c,f){var b=c.updateQueue;if(b=b!==null?b.lastEffect:null,b!==null){var C=b=b.next;do{if((C.tag&a)===a){var $=C.destroy;C.destroy=void 0,$!==void 0&&Im(c,f,$)}C=C.next}while(C!==b)}}function $u(a,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var f=c=c.next;do{if((f.tag&a)===a){var b=f.create;f.destroy=b()}f=f.next}while(f!==c)}}function Tm(a){var c=a.ref;if(c!==null){var f=a.stateNode;switch(a.tag){case 5:a=f;break;default:a=f}typeof c=="function"?c(a):c.current=a}}function T0(a){var c=a.alternate;c!==null&&(a.alternate=null,T0(c)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(c=a.stateNode,c!==null&&(delete c[Pi],delete c[gl],delete c[Gh],delete c[fC],delete c[pC])),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 M0(a){return a.tag===5||a.tag===3||a.tag===4}function R0(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||M0(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 Mm(a,c,f){var b=a.tag;if(b===5||b===6)a=a.stateNode,c?f.nodeType===8?f.parentNode.insertBefore(a,c):f.insertBefore(a,c):(f.nodeType===8?(c=f.parentNode,c.insertBefore(a,f)):(c=f,c.appendChild(a)),f=f._reactRootContainer,f!=null||c.onclick!==null||(c.onclick=ou));else if(b!==4&&(a=a.child,a!==null))for(Mm(a,c,f),a=a.sibling;a!==null;)Mm(a,c,f),a=a.sibling}function Rm(a,c,f){var b=a.tag;if(b===5||b===6)a=a.stateNode,c?f.insertBefore(a,c):f.appendChild(a);else if(b!==4&&(a=a.child,a!==null))for(Rm(a,c,f),a=a.sibling;a!==null;)Rm(a,c,f),a=a.sibling}var Wn=null,vi=!1;function Tr(a,c,f){for(f=f.child;f!==null;)O0(a,c,f),f=f.sibling}function O0(a,c,f){if(mt&&typeof mt.onCommitFiberUnmount=="function")try{mt.onCommitFiberUnmount(dt,f)}catch{}switch(f.tag){case 5:ss||go(f,c);case 6:var b=Wn,C=vi;Wn=null,Tr(a,c,f),Wn=b,vi=C,Wn!==null&&(vi?(a=Wn,f=f.stateNode,a.nodeType===8?a.parentNode.removeChild(f):a.removeChild(f)):Wn.removeChild(f.stateNode));break;case 18:Wn!==null&&(vi?(a=Wn,f=f.stateNode,a.nodeType===8?qh(a.parentNode,f):a.nodeType===1&&qh(a,f),we(a)):qh(Wn,f.stateNode));break;case 4:b=Wn,C=vi,Wn=f.stateNode.containerInfo,vi=!0,Tr(a,c,f),Wn=b,vi=C;break;case 0:case 11:case 14:case 15:if(!ss&&(b=f.updateQueue,b!==null&&(b=b.lastEffect,b!==null))){C=b=b.next;do{var $=C,W=$.destroy;$=$.tag,W!==void 0&&(($&2)!==0||($&4)!==0)&&Im(f,c,W),C=C.next}while(C!==b)}Tr(a,c,f);break;case 1:if(!ss&&(go(f,c),b=f.stateNode,typeof b.componentWillUnmount=="function"))try{b.props=f.memoizedProps,b.state=f.memoizedState,b.componentWillUnmount()}catch(se){hn(f,c,se)}Tr(a,c,f);break;case 21:Tr(a,c,f);break;case 22:f.mode&1?(ss=(b=ss)||f.memoizedState!==null,Tr(a,c,f),ss=b):Tr(a,c,f);break;default:Tr(a,c,f)}}function P0(a){var c=a.updateQueue;if(c!==null){a.updateQueue=null;var f=a.stateNode;f===null&&(f=a.stateNode=new IC),c.forEach(function(b){var C=UC.bind(null,a,b);f.has(b)||(f.add(b),b.then(C,C))})}}function yi(a,c){var f=c.deletions;if(f!==null)for(var b=0;b<f.length;b++){var C=f[b];try{var $=a,W=c,se=W;e:for(;se!==null;){switch(se.tag){case 5:Wn=se.stateNode,vi=!1;break e;case 3:Wn=se.stateNode.containerInfo,vi=!0;break e;case 4:Wn=se.stateNode.containerInfo,vi=!0;break e}se=se.return}if(Wn===null)throw Error(s(160));O0($,W,C),Wn=null,vi=!1;var ae=C.alternate;ae!==null&&(ae.return=null),C.return=null}catch(ye){hn(C,c,ye)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)L0(c,a),c=c.sibling}function L0(a,c){var f=a.alternate,b=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(yi(c,a),Di(a),b&4){try{El(3,a,a.return),$u(3,a)}catch(Qe){hn(a,a.return,Qe)}try{El(5,a,a.return)}catch(Qe){hn(a,a.return,Qe)}}break;case 1:yi(c,a),Di(a),b&512&&f!==null&&go(f,f.return);break;case 5:if(yi(c,a),Di(a),b&512&&f!==null&&go(f,f.return),a.flags&32){var C=a.stateNode;try{mn(C,"")}catch(Qe){hn(a,a.return,Qe)}}if(b&4&&(C=a.stateNode,C!=null)){var $=a.memoizedProps,W=f!==null?f.memoizedProps:$,se=a.type,ae=a.updateQueue;if(a.updateQueue=null,ae!==null)try{se==="input"&&$.type==="radio"&&$.name!=null&&Ae(C,$),as(se,W);var ye=as(se,$);for(W=0;W<ae.length;W+=2){var Te=ae[W],Re=ae[W+1];Te==="style"?rs(C,Re):Te==="dangerouslySetInnerHTML"?Rn(C,Re):Te==="children"?mn(C,Re):S(C,Te,Re,ye)}switch(se){case"input":be(C,$);break;case"textarea":Pt(C,$);break;case"select":var Ie=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!$.multiple;var We=$.value;We!=null?Rt(C,!!$.multiple,We,!1):Ie!==!!$.multiple&&($.defaultValue!=null?Rt(C,!!$.multiple,$.defaultValue,!0):Rt(C,!!$.multiple,$.multiple?[]:"",!1))}C[gl]=$}catch(Qe){hn(a,a.return,Qe)}}break;case 6:if(yi(c,a),Di(a),b&4){if(a.stateNode===null)throw Error(s(162));C=a.stateNode,$=a.memoizedProps;try{C.nodeValue=$}catch(Qe){hn(a,a.return,Qe)}}break;case 3:if(yi(c,a),Di(a),b&4&&f!==null&&f.memoizedState.isDehydrated)try{we(c.containerInfo)}catch(Qe){hn(a,a.return,Qe)}break;case 4:yi(c,a),Di(a);break;case 13:yi(c,a),Di(a),C=a.child,C.flags&8192&&($=C.memoizedState!==null,C.stateNode.isHidden=$,!$||C.alternate!==null&&C.alternate.memoizedState!==null||(Lm=Dt())),b&4&&P0(a);break;case 22:if(Te=f!==null&&f.memoizedState!==null,a.mode&1?(ss=(ye=ss)||Te,yi(c,a),ss=ye):yi(c,a),Di(a),b&8192){if(ye=a.memoizedState!==null,(a.stateNode.isHidden=ye)&&!Te&&(a.mode&1)!==0)for(Ge=a,Te=a.child;Te!==null;){for(Re=Ge=Te;Ge!==null;){switch(Ie=Ge,We=Ie.child,Ie.tag){case 0:case 11:case 14:case 15:El(4,Ie,Ie.return);break;case 1:go(Ie,Ie.return);var Ke=Ie.stateNode;if(typeof Ke.componentWillUnmount=="function"){b=Ie,f=Ie.return;try{c=b,Ke.props=c.memoizedProps,Ke.state=c.memoizedState,Ke.componentWillUnmount()}catch(Qe){hn(b,f,Qe)}}break;case 5:go(Ie,Ie.return);break;case 22:if(Ie.memoizedState!==null){F0(Re);continue}}We!==null?(We.return=Ie,Ge=We):F0(Re)}Te=Te.sibling}e:for(Te=null,Re=a;;){if(Re.tag===5){if(Te===null){Te=Re;try{C=Re.stateNode,ye?($=C.style,typeof $.setProperty=="function"?$.setProperty("display","none","important"):$.display="none"):(se=Re.stateNode,ae=Re.memoizedProps.style,W=ae!=null&&ae.hasOwnProperty("display")?ae.display:null,se.style.display=ps("display",W))}catch(Qe){hn(a,a.return,Qe)}}}else if(Re.tag===6){if(Te===null)try{Re.stateNode.nodeValue=ye?"":Re.memoizedProps}catch(Qe){hn(a,a.return,Qe)}}else if((Re.tag!==22&&Re.tag!==23||Re.memoizedState===null||Re===a)&&Re.child!==null){Re.child.return=Re,Re=Re.child;continue}if(Re===a)break e;for(;Re.sibling===null;){if(Re.return===null||Re.return===a)break e;Te===Re&&(Te=null),Re=Re.return}Te===Re&&(Te=null),Re.sibling.return=Re.return,Re=Re.sibling}}break;case 19:yi(c,a),Di(a),b&4&&P0(a);break;case 21:break;default:yi(c,a),Di(a)}}function Di(a){var c=a.flags;if(c&2){try{e:{for(var f=a.return;f!==null;){if(M0(f)){var b=f;break e}f=f.return}throw Error(s(160))}switch(b.tag){case 5:var C=b.stateNode;b.flags&32&&(mn(C,""),b.flags&=-33);var $=R0(a);Rm(a,$,C);break;case 3:case 4:var W=b.stateNode.containerInfo,se=R0(a);Mm(a,se,W);break;default:throw Error(s(161))}}catch(ae){hn(a,a.return,ae)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function MC(a,c,f){Ge=a,z0(a)}function z0(a,c,f){for(var b=(a.mode&1)!==0;Ge!==null;){var C=Ge,$=C.child;if(C.tag===22&&b){var W=C.memoizedState!==null||Au;if(!W){var se=C.alternate,ae=se!==null&&se.memoizedState!==null||ss;se=Au;var ye=ss;if(Au=W,(ss=ae)&&!ye)for(Ge=C;Ge!==null;)W=Ge,ae=W.child,W.tag===22&&W.memoizedState!==null?U0(C):ae!==null?(ae.return=W,Ge=ae):U0(C);for(;$!==null;)Ge=$,z0($),$=$.sibling;Ge=C,Au=se,ss=ye}D0(a)}else(C.subtreeFlags&8772)!==0&&$!==null?($.return=C,Ge=$):D0(a)}}function D0(a){for(;Ge!==null;){var c=Ge;if((c.flags&8772)!==0){var f=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:ss||$u(5,c);break;case 1:var b=c.stateNode;if(c.flags&4&&!ss)if(f===null)b.componentDidMount();else{var C=c.elementType===c.type?f.memoizedProps:xi(c.type,f.memoizedProps);b.componentDidUpdate(C,f.memoizedState,b.__reactInternalSnapshotBeforeUpdate)}var $=c.updateQueue;$!==null&&Fv(c,$,b);break;case 3:var W=c.updateQueue;if(W!==null){if(f=null,c.child!==null)switch(c.child.tag){case 5:f=c.child.stateNode;break;case 1:f=c.child.stateNode}Fv(c,W,f)}break;case 5:var se=c.stateNode;if(f===null&&c.flags&4){f=se;var ae=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":ae.autoFocus&&f.focus();break;case"img":ae.src&&(f.src=ae.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var ye=c.alternate;if(ye!==null){var Te=ye.memoizedState;if(Te!==null){var Re=Te.dehydrated;Re!==null&&we(Re)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}ss||c.flags&512&&Tm(c)}catch(Ie){hn(c,c.return,Ie)}}if(c===a){Ge=null;break}if(f=c.sibling,f!==null){f.return=c.return,Ge=f;break}Ge=c.return}}function F0(a){for(;Ge!==null;){var c=Ge;if(c===a){Ge=null;break}var f=c.sibling;if(f!==null){f.return=c.return,Ge=f;break}Ge=c.return}}function U0(a){for(;Ge!==null;){var c=Ge;try{switch(c.tag){case 0:case 11:case 15:var f=c.return;try{$u(4,c)}catch(ae){hn(c,f,ae)}break;case 1:var b=c.stateNode;if(typeof b.componentDidMount=="function"){var C=c.return;try{b.componentDidMount()}catch(ae){hn(c,C,ae)}}var $=c.return;try{Tm(c)}catch(ae){hn(c,$,ae)}break;case 5:var W=c.return;try{Tm(c)}catch(ae){hn(c,W,ae)}}}catch(ae){hn(c,c.return,ae)}if(c===a){Ge=null;break}var se=c.sibling;if(se!==null){se.return=c.return,Ge=se;break}Ge=c.return}}var RC=Math.ceil,Iu=E.ReactCurrentDispatcher,Om=E.ReactCurrentOwner,si=E.ReactCurrentBatchConfig,Et=0,zn=null,kn=null,Vn=0,Ds=0,xo=Er(0),Mn=0,Cl=null,va=0,Tu=0,Pm=0,Al=null,_s=null,Lm=0,vo=1/0,lr=null,Mu=!1,zm=null,Mr=null,Ru=!1,Rr=null,Ou=0,$l=0,Dm=null,Pu=-1,Lu=0;function ds(){return(Et&6)!==0?Dt():Pu!==-1?Pu:Pu=Dt()}function Or(a){return(a.mode&1)===0?1:(Et&2)!==0&&Vn!==0?Vn&-Vn:xC.transition!==null?(Lu===0&&(Lu=wr()),Lu):(a=wt,a!==0||(a=window.event,a=a===void 0?16:er(a.type)),a)}function bi(a,c,f,b){if(50<$l)throw $l=0,Dm=null,Error(s(185));bs(a,f,b),((Et&2)===0||a!==zn)&&(a===zn&&((Et&2)===0&&(Tu|=f),Mn===4&&Pr(a,Vn)),Es(a,b),f===1&&Et===0&&(c.mode&1)===0&&(vo=Dt()+500,du&&Ar()))}function Es(a,c){var f=a.callbackNode;Nr(a,c);var b=ys(a,a===zn?Vn:0);if(b===0)f!==null&&os(f),a.callbackNode=null,a.callbackPriority=0;else if(c=b&-b,a.callbackPriority!==c){if(f!=null&&os(f),c===1)a.tag===0?gC(H0.bind(null,a)):Cv(H0.bind(null,a)),hC(function(){(Et&6)===0&&Ar()}),f=null;else{switch(at(b)){case 1:f=Yi;break;case 4:f=mi;break;case 16:f=Ri;break;case 536870912:f=Ve;break;default:f=Ri}f=X0(f,B0.bind(null,a))}a.callbackPriority=c,a.callbackNode=f}}function B0(a,c){if(Pu=-1,Lu=0,(Et&6)!==0)throw Error(s(327));var f=a.callbackNode;if(yo()&&a.callbackNode!==f)return null;var b=ys(a,a===zn?Vn:0);if(b===0)return null;if((b&30)!==0||(b&a.expiredLanes)!==0||c)c=zu(a,b);else{c=b;var C=Et;Et|=2;var $=W0();(zn!==a||Vn!==c)&&(lr=null,vo=Dt()+500,ba(a,c));do try{LC();break}catch(se){Z0(a,se)}while(!0);sm(),Iu.current=$,Et=C,kn!==null?c=0:(zn=null,Vn=0,c=Mn)}if(c!==0){if(c===2&&(C=Oi(a),C!==0&&(b=C,c=Fm(a,C))),c===1)throw f=Cl,ba(a,0),Pr(a,b),Es(a,Dt()),f;if(c===6)Pr(a,b);else{if(C=a.current.alternate,(b&30)===0&&!OC(C)&&(c=zu(a,b),c===2&&($=Oi(a),$!==0&&(b=$,c=Fm(a,$))),c===1))throw f=Cl,ba(a,0),Pr(a,b),Es(a,Dt()),f;switch(a.finishedWork=C,a.finishedLanes=b,c){case 0:case 1:throw Error(s(345));case 2:ka(a,_s,lr);break;case 3:if(Pr(a,b),(b&130023424)===b&&(c=Lm+500-Dt(),10<c)){if(ys(a,0)!==0)break;if(C=a.suspendedLanes,(C&b)!==b){ds(),a.pingedLanes|=a.suspendedLanes&C;break}a.timeoutHandle=Vh(ka.bind(null,a,_s,lr),c);break}ka(a,_s,lr);break;case 4:if(Pr(a,b),(b&4194240)===b)break;for(c=a.eventTimes,C=-1;0<b;){var W=31-Ft(b);$=1<<W,W=c[W],W>C&&(C=W),b&=~$}if(b=C,b=Dt()-b,b=(120>b?120:480>b?480:1080>b?1080:1920>b?1920:3e3>b?3e3:4320>b?4320:1960*RC(b/1960))-b,10<b){a.timeoutHandle=Vh(ka.bind(null,a,_s,lr),b);break}ka(a,_s,lr);break;case 5:ka(a,_s,lr);break;default:throw Error(s(329))}}}return Es(a,Dt()),a.callbackNode===f?B0.bind(null,a):null}function Fm(a,c){var f=Al;return a.current.memoizedState.isDehydrated&&(ba(a,c).flags|=256),a=zu(a,c),a!==2&&(c=_s,_s=f,c!==null&&Um(c)),a}function Um(a){_s===null?_s=a:_s.push.apply(_s,a)}function OC(a){for(var c=a;;){if(c.flags&16384){var f=c.updateQueue;if(f!==null&&(f=f.stores,f!==null))for(var b=0;b<f.length;b++){var C=f[b],$=C.getSnapshot;C=C.value;try{if(!pi($(),C))return!1}catch{return!1}}}if(f=c.child,c.subtreeFlags&16384&&f!==null)f.return=c,c=f;else{if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function Pr(a,c){for(c&=~Pm,c&=~Tu,a.suspendedLanes|=c,a.pingedLanes&=~c,a=a.expirationTimes;0<c;){var f=31-Ft(c),b=1<<f;a[f]=-1,c&=~b}}function H0(a){if((Et&6)!==0)throw Error(s(327));yo();var c=ys(a,0);if((c&1)===0)return Es(a,Dt()),null;var f=zu(a,c);if(a.tag!==0&&f===2){var b=Oi(a);b!==0&&(c=b,f=Fm(a,b))}if(f===1)throw f=Cl,ba(a,0),Pr(a,c),Es(a,Dt()),f;if(f===6)throw Error(s(345));return a.finishedWork=a.current.alternate,a.finishedLanes=c,ka(a,_s,lr),Es(a,Dt()),null}function Bm(a,c){var f=Et;Et|=1;try{return a(c)}finally{Et=f,Et===0&&(vo=Dt()+500,du&&Ar())}}function ya(a){Rr!==null&&Rr.tag===0&&(Et&6)===0&&yo();var c=Et;Et|=1;var f=si.transition,b=wt;try{if(si.transition=null,wt=1,a)return a()}finally{wt=b,si.transition=f,Et=c,(Et&6)===0&&Ar()}}function Hm(){Ds=xo.current,Gt(xo)}function ba(a,c){a.finishedWork=null,a.finishedLanes=0;var f=a.timeoutHandle;if(f!==-1&&(a.timeoutHandle=-1,dC(f)),kn!==null)for(f=kn.return;f!==null;){var b=f;switch(Qh(b),b.tag){case 1:b=b.type.childContextTypes,b!=null&&cu();break;case 3:fo(),Gt(Ns),Gt(es),dm();break;case 5:cm(b);break;case 4:fo();break;case 13:Gt(on);break;case 19:Gt(on);break;case 10:im(b.type._context);break;case 22:case 23:Hm()}f=f.return}if(zn=a,kn=a=Lr(a.current,null),Vn=Ds=c,Mn=0,Cl=null,Pm=Tu=va=0,_s=Al=null,pa!==null){for(c=0;c<pa.length;c++)if(f=pa[c],b=f.interleaved,b!==null){f.interleaved=null;var C=b.next,$=f.pending;if($!==null){var W=$.next;$.next=C,b.next=W}f.pending=b}pa=null}return a}function Z0(a,c){do{var f=kn;try{if(sm(),ku.current=Su,ju){for(var b=ln.memoizedState;b!==null;){var C=b.queue;C!==null&&(C.pending=null),b=b.next}ju=!1}if(xa=0,Ln=Tn=ln=null,jl=!1,Nl=0,Om.current=null,f===null||f.return===null){Mn=1,Cl=c,kn=null;break}e:{var $=a,W=f.return,se=f,ae=c;if(c=Vn,se.flags|=32768,ae!==null&&typeof ae=="object"&&typeof ae.then=="function"){var ye=ae,Te=se,Re=Te.tag;if((Te.mode&1)===0&&(Re===0||Re===11||Re===15)){var Ie=Te.alternate;Ie?(Te.updateQueue=Ie.updateQueue,Te.memoizedState=Ie.memoizedState,Te.lanes=Ie.lanes):(Te.updateQueue=null,Te.memoizedState=null)}var We=p0(W);if(We!==null){We.flags&=-257,g0(We,W,se,$,c),We.mode&1&&f0($,ye,c),c=We,ae=ye;var Ke=c.updateQueue;if(Ke===null){var Qe=new Set;Qe.add(ae),c.updateQueue=Qe}else Ke.add(ae);break e}else{if((c&1)===0){f0($,ye,c),Zm();break e}ae=Error(s(426))}}else if(Jt&&se.mode&1){var gn=p0(W);if(gn!==null){(gn.flags&65536)===0&&(gn.flags|=256),g0(gn,W,se,$,c),tm(po(ae,se));break e}}$=ae=po(ae,se),Mn!==4&&(Mn=2),Al===null?Al=[$]:Al.push($),$=W;do{switch($.tag){case 3:$.flags|=65536,c&=-c,$.lanes|=c;var pe=h0($,ae,c);Dv($,pe);break e;case 1:se=ae;var ue=$.type,xe=$.stateNode;if(($.flags&128)===0&&(typeof ue.getDerivedStateFromError=="function"||xe!==null&&typeof xe.componentDidCatch=="function"&&(Mr===null||!Mr.has(xe)))){$.flags|=65536,c&=-c,$.lanes|=c;var ze=m0($,se,c);Dv($,ze);break e}}$=$.return}while($!==null)}q0(f)}catch(Je){c=Je,kn===f&&f!==null&&(kn=f=f.return);continue}break}while(!0)}function W0(){var a=Iu.current;return Iu.current=Su,a===null?Su:a}function Zm(){(Mn===0||Mn===3||Mn===2)&&(Mn=4),zn===null||(va&268435455)===0&&(Tu&268435455)===0||Pr(zn,Vn)}function zu(a,c){var f=Et;Et|=2;var b=W0();(zn!==a||Vn!==c)&&(lr=null,ba(a,c));do try{PC();break}catch(C){Z0(a,C)}while(!0);if(sm(),Et=f,Iu.current=b,kn!==null)throw Error(s(261));return zn=null,Vn=0,Mn}function PC(){for(;kn!==null;)V0(kn)}function LC(){for(;kn!==null&&!Ki();)V0(kn)}function V0(a){var c=Y0(a.alternate,a,Ds);a.memoizedProps=a.pendingProps,c===null?q0(a):kn=c,Om.current=null}function q0(a){var c=a;do{var f=c.alternate;if(a=c.return,(c.flags&32768)===0){if(f=AC(f,c,Ds),f!==null){kn=f;return}}else{if(f=$C(f,c),f!==null){f.flags&=32767,kn=f;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{Mn=6,kn=null;return}}if(c=c.sibling,c!==null){kn=c;return}kn=c=a}while(c!==null);Mn===0&&(Mn=5)}function ka(a,c,f){var b=wt,C=si.transition;try{si.transition=null,wt=1,zC(a,c,f,b)}finally{si.transition=C,wt=b}return null}function zC(a,c,f,b){do yo();while(Rr!==null);if((Et&6)!==0)throw Error(s(327));f=a.finishedWork;var C=a.finishedLanes;if(f===null)return null;if(a.finishedWork=null,a.finishedLanes=0,f===a.current)throw Error(s(177));a.callbackNode=null,a.callbackPriority=0;var $=f.lanes|f.childLanes;if(In(a,$),a===zn&&(kn=zn=null,Vn=0),(f.subtreeFlags&2064)===0&&(f.flags&2064)===0||Ru||(Ru=!0,X0(Ri,function(){return yo(),null})),$=(f.flags&15990)!==0,(f.subtreeFlags&15990)!==0||$){$=si.transition,si.transition=null;var W=wt;wt=1;var se=Et;Et|=4,Om.current=null,TC(a,f),L0(f,a),iC(Zh),nt=!!Hh,Zh=Hh=null,a.current=f,MC(f),hi(),Et=se,wt=W,si.transition=$}else a.current=f;if(Ru&&(Ru=!1,Rr=a,Ou=C),$=a.pendingLanes,$===0&&(Mr=null),Ot(f.stateNode),Es(a,Dt()),c!==null)for(b=a.onRecoverableError,f=0;f<c.length;f++)C=c[f],b(C.value,{componentStack:C.stack,digest:C.digest});if(Mu)throw Mu=!1,a=zm,zm=null,a;return(Ou&1)!==0&&a.tag!==0&&yo(),$=a.pendingLanes,($&1)!==0?a===Dm?$l++:($l=0,Dm=a):$l=0,Ar(),null}function yo(){if(Rr!==null){var a=at(Ou),c=si.transition,f=wt;try{if(si.transition=null,wt=16>a?16:a,Rr===null)var b=!1;else{if(a=Rr,Rr=null,Ou=0,(Et&6)!==0)throw Error(s(331));var C=Et;for(Et|=4,Ge=a.current;Ge!==null;){var $=Ge,W=$.child;if((Ge.flags&16)!==0){var se=$.deletions;if(se!==null){for(var ae=0;ae<se.length;ae++){var ye=se[ae];for(Ge=ye;Ge!==null;){var Te=Ge;switch(Te.tag){case 0:case 11:case 15:El(8,Te,$)}var Re=Te.child;if(Re!==null)Re.return=Te,Ge=Re;else for(;Ge!==null;){Te=Ge;var Ie=Te.sibling,We=Te.return;if(T0(Te),Te===ye){Ge=null;break}if(Ie!==null){Ie.return=We,Ge=Ie;break}Ge=We}}}var Ke=$.alternate;if(Ke!==null){var Qe=Ke.child;if(Qe!==null){Ke.child=null;do{var gn=Qe.sibling;Qe.sibling=null,Qe=gn}while(Qe!==null)}}Ge=$}}if(($.subtreeFlags&2064)!==0&&W!==null)W.return=$,Ge=W;else e:for(;Ge!==null;){if($=Ge,($.flags&2048)!==0)switch($.tag){case 0:case 11:case 15:El(9,$,$.return)}var pe=$.sibling;if(pe!==null){pe.return=$.return,Ge=pe;break e}Ge=$.return}}var ue=a.current;for(Ge=ue;Ge!==null;){W=Ge;var xe=W.child;if((W.subtreeFlags&2064)!==0&&xe!==null)xe.return=W,Ge=xe;else e:for(W=ue;Ge!==null;){if(se=Ge,(se.flags&2048)!==0)try{switch(se.tag){case 0:case 11:case 15:$u(9,se)}}catch(Je){hn(se,se.return,Je)}if(se===W){Ge=null;break e}var ze=se.sibling;if(ze!==null){ze.return=se.return,Ge=ze;break e}Ge=se.return}}if(Et=C,Ar(),mt&&typeof mt.onPostCommitFiberRoot=="function")try{mt.onPostCommitFiberRoot(dt,a)}catch{}b=!0}return b}finally{wt=f,si.transition=c}}return!1}function G0(a,c,f){c=po(f,c),c=h0(a,c,1),a=Ir(a,c,1),c=ds(),a!==null&&(bs(a,1,c),Es(a,c))}function hn(a,c,f){if(a.tag===3)G0(a,a,f);else for(;c!==null;){if(c.tag===3){G0(c,a,f);break}else if(c.tag===1){var b=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(Mr===null||!Mr.has(b))){a=po(f,a),a=m0(c,a,1),c=Ir(c,a,1),a=ds(),c!==null&&(bs(c,1,a),Es(c,a));break}}c=c.return}}function DC(a,c,f){var b=a.pingCache;b!==null&&b.delete(c),c=ds(),a.pingedLanes|=a.suspendedLanes&f,zn===a&&(Vn&f)===f&&(Mn===4||Mn===3&&(Vn&130023424)===Vn&&500>Dt()-Lm?ba(a,0):Pm|=f),Es(a,c)}function K0(a,c){c===0&&((a.mode&1)===0?c=1:(c=Ys,Ys<<=1,(Ys&130023424)===0&&(Ys=4194304)));var f=ds();a=rr(a,c),a!==null&&(bs(a,c,f),Es(a,f))}function FC(a){var c=a.memoizedState,f=0;c!==null&&(f=c.retryLane),K0(a,f)}function UC(a,c){var f=0;switch(a.tag){case 13:var b=a.stateNode,C=a.memoizedState;C!==null&&(f=C.retryLane);break;case 19:b=a.stateNode;break;default:throw Error(s(314))}b!==null&&b.delete(c),K0(a,f)}var Y0;Y0=function(a,c,f){if(a!==null)if(a.memoizedProps!==c.pendingProps||Ns.current)Ss=!0;else{if((a.lanes&f)===0&&(c.flags&128)===0)return Ss=!1,CC(a,c,f);Ss=(a.flags&131072)!==0}else Ss=!1,Jt&&(c.flags&1048576)!==0&&Av(c,mu,c.index);switch(c.lanes=0,c.tag){case 2:var b=c.type;Cu(a,c),a=c.pendingProps;var C=ao(c,es.current);mo(c,f),C=fm(null,c,b,a,C,f);var $=pm();return c.flags|=1,typeof C=="object"&&C!==null&&typeof C.render=="function"&&C.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,ws(b)?($=!0,uu(c)):$=!1,c.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,om(c),C.updater=_u,c.stateNode=C,C._reactInternals=c,km(c,b,a,f),c=Sm(null,c,b,!0,$,f)):(c.tag=0,Jt&&$&&Xh(c),us(null,c,C,f),c=c.child),c;case 16:b=c.elementType;e:{switch(Cu(a,c),a=c.pendingProps,C=b._init,b=C(b._payload),c.type=b,C=c.tag=HC(b),a=xi(b,a),C){case 0:c=wm(null,c,b,a,f);break e;case 1:c=j0(null,c,b,a,f);break e;case 11:c=x0(null,c,b,a,f);break e;case 14:c=v0(null,c,b,xi(b.type,a),f);break e}throw Error(s(306,b,""))}return c;case 0:return b=c.type,C=c.pendingProps,C=c.elementType===b?C:xi(b,C),wm(a,c,b,C,f);case 1:return b=c.type,C=c.pendingProps,C=c.elementType===b?C:xi(b,C),j0(a,c,b,C,f);case 3:e:{if(N0(c),a===null)throw Error(s(387));b=c.pendingProps,$=c.memoizedState,C=$.element,zv(a,c),yu(c,b,null,f);var W=c.memoizedState;if(b=W.element,$.isDehydrated)if($={element:b,isDehydrated:!1,cache:W.cache,pendingSuspenseBoundaries:W.pendingSuspenseBoundaries,transitions:W.transitions},c.updateQueue.baseState=$,c.memoizedState=$,c.flags&256){C=po(Error(s(423)),c),c=w0(a,c,b,f,C);break e}else if(b!==C){C=po(Error(s(424)),c),c=w0(a,c,b,f,C);break e}else for(zs=_r(c.stateNode.containerInfo.firstChild),Ls=c,Jt=!0,gi=null,f=Pv(c,null,b,f),c.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(co(),b===C){c=or(a,c,f);break e}us(a,c,b,f)}c=c.child}return c;case 5:return Uv(c),a===null&&em(c),b=c.type,C=c.pendingProps,$=a!==null?a.memoizedProps:null,W=C.children,Wh(b,C)?W=null:$!==null&&Wh(b,$)&&(c.flags|=32),k0(a,c),us(a,c,W,f),c.child;case 6:return a===null&&em(c),null;case 13:return S0(a,c,f);case 4:return lm(c,c.stateNode.containerInfo),b=c.pendingProps,a===null?c.child=uo(c,null,b,f):us(a,c,b,f),c.child;case 11:return b=c.type,C=c.pendingProps,C=c.elementType===b?C:xi(b,C),x0(a,c,b,C,f);case 7:return us(a,c,c.pendingProps,f),c.child;case 8:return us(a,c,c.pendingProps.children,f),c.child;case 12:return us(a,c,c.pendingProps.children,f),c.child;case 10:e:{if(b=c.type._context,C=c.pendingProps,$=c.memoizedProps,W=C.value,Wt(gu,b._currentValue),b._currentValue=W,$!==null)if(pi($.value,W)){if($.children===C.children&&!Ns.current){c=or(a,c,f);break e}}else for($=c.child,$!==null&&($.return=c);$!==null;){var se=$.dependencies;if(se!==null){W=$.child;for(var ae=se.firstContext;ae!==null;){if(ae.context===b){if($.tag===1){ae=ar(-1,f&-f),ae.tag=2;var ye=$.updateQueue;if(ye!==null){ye=ye.shared;var Te=ye.pending;Te===null?ae.next=ae:(ae.next=Te.next,Te.next=ae),ye.pending=ae}}$.lanes|=f,ae=$.alternate,ae!==null&&(ae.lanes|=f),rm($.return,f,c),se.lanes|=f;break}ae=ae.next}}else if($.tag===10)W=$.type===c.type?null:$.child;else if($.tag===18){if(W=$.return,W===null)throw Error(s(341));W.lanes|=f,se=W.alternate,se!==null&&(se.lanes|=f),rm(W,f,c),W=$.sibling}else W=$.child;if(W!==null)W.return=$;else for(W=$;W!==null;){if(W===c){W=null;break}if($=W.sibling,$!==null){$.return=W.return,W=$;break}W=W.return}$=W}us(a,c,C.children,f),c=c.child}return c;case 9:return C=c.type,b=c.pendingProps.children,mo(c,f),C=ti(C),b=b(C),c.flags|=1,us(a,c,b,f),c.child;case 14:return b=c.type,C=xi(b,c.pendingProps),C=xi(b.type,C),v0(a,c,b,C,f);case 15:return y0(a,c,c.type,c.pendingProps,f);case 17:return b=c.type,C=c.pendingProps,C=c.elementType===b?C:xi(b,C),Cu(a,c),c.tag=1,ws(b)?(a=!0,uu(c)):a=!1,mo(c,f),u0(c,b,C),km(c,b,C,f),Sm(null,c,b,!0,a,f);case 19:return E0(a,c,f);case 22:return b0(a,c,f)}throw Error(s(156,c.tag))};function X0(a,c){return Os(a,c)}function BC(a,c,f,b){this.tag=a,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=b,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ii(a,c,f,b){return new BC(a,c,f,b)}function Wm(a){return a=a.prototype,!(!a||!a.isReactComponent)}function HC(a){if(typeof a=="function")return Wm(a)?1:0;if(a!=null){if(a=a.$$typeof,a===L)return 11;if(a===z)return 14}return 2}function Lr(a,c){var f=a.alternate;return f===null?(f=ii(a.tag,c,a.key,a.mode),f.elementType=a.elementType,f.type=a.type,f.stateNode=a.stateNode,f.alternate=a,a.alternate=f):(f.pendingProps=c,f.type=a.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=a.flags&14680064,f.childLanes=a.childLanes,f.lanes=a.lanes,f.child=a.child,f.memoizedProps=a.memoizedProps,f.memoizedState=a.memoizedState,f.updateQueue=a.updateQueue,c=a.dependencies,f.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},f.sibling=a.sibling,f.index=a.index,f.ref=a.ref,f}function Du(a,c,f,b,C,$){var W=2;if(b=a,typeof a=="function")Wm(a)&&(W=1);else if(typeof a=="string")W=5;else e:switch(a){case H:return ja(f.children,C,$,c);case B:W=8,C|=8;break;case R:return a=ii(12,f,c,C|2),a.elementType=R,a.lanes=$,a;case A:return a=ii(13,f,c,C),a.elementType=A,a.lanes=$,a;case I:return a=ii(19,f,c,C),a.elementType=I,a.lanes=$,a;case V:return Fu(f,C,$,c);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case M:W=10;break e;case F:W=9;break e;case L:W=11;break e;case z:W=14;break e;case D:W=16,b=null;break e}throw Error(s(130,a==null?a:typeof a,""))}return c=ii(W,f,c,C),c.elementType=a,c.type=b,c.lanes=$,c}function ja(a,c,f,b){return a=ii(7,a,b,c),a.lanes=f,a}function Fu(a,c,f,b){return a=ii(22,a,b,c),a.elementType=V,a.lanes=f,a.stateNode={isHidden:!1},a}function Vm(a,c,f){return a=ii(6,a,null,c),a.lanes=f,a}function qm(a,c,f){return c=ii(4,a.children!==null?a.children:[],a.key,c),c.lanes=f,c.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},c}function ZC(a,c,f,b,C){this.tag=c,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=ls(0),this.expirationTimes=ls(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ls(0),this.identifierPrefix=b,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function Gm(a,c,f,b,C,$,W,se,ae){return a=new ZC(a,c,f,se,ae),c===1?(c=1,$===!0&&(c|=8)):c=0,$=ii(3,null,null,c),a.current=$,$.stateNode=a,$.memoizedState={element:b,isDehydrated:f,cache:null,transitions:null,pendingSuspenseBoundaries:null},om($),a}function WC(a,c,f){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:P,key:b==null?null:""+b,children:a,containerInfo:c,implementation:f}}function Q0(a){if(!a)return Cr;a=a._reactInternals;e:{if(Qn(a)!==a||a.tag!==1)throw Error(s(170));var c=a;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(ws(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(s(171))}if(a.tag===1){var f=a.type;if(ws(f))return _v(a,f,c)}return c}function J0(a,c,f,b,C,$,W,se,ae){return a=Gm(f,b,!0,a,C,$,W,se,ae),a.context=Q0(null),f=a.current,b=ds(),C=Or(f),$=ar(b,C),$.callback=c??null,Ir(f,$,C),a.current.lanes=C,bs(a,C,b),Es(a,b),a}function Uu(a,c,f,b){var C=c.current,$=ds(),W=Or(C);return f=Q0(f),c.context===null?c.context=f:c.pendingContext=f,c=ar($,W),c.payload={element:a},b=b===void 0?null:b,b!==null&&(c.callback=b),a=Ir(C,c,W),a!==null&&(bi(a,C,W,$),vu(a,C,W)),W}function Bu(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 ey(a,c){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var f=a.retryLane;a.retryLane=f!==0&&f<c?f:c}}function Km(a,c){ey(a,c),(a=a.alternate)&&ey(a,c)}function VC(){return null}var ty=typeof reportError=="function"?reportError:function(a){console.error(a)};function Ym(a){this._internalRoot=a}Hu.prototype.render=Ym.prototype.render=function(a){var c=this._internalRoot;if(c===null)throw Error(s(409));Uu(a,c,null,null)},Hu.prototype.unmount=Ym.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var c=a.containerInfo;ya(function(){Uu(null,a,null,null)}),c[tr]=null}};function Hu(a){this._internalRoot=a}Hu.prototype.unstable_scheduleHydration=function(a){if(a){var c=Xi();a={blockedOn:null,target:a,priority:c};for(var f=0;f<yn.length&&c!==0&&c<yn[f].priority;f++);yn.splice(f,0,a),f===0&&Ya(a)}};function Xm(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Zu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function ny(){}function qC(a,c,f,b,C){if(C){if(typeof b=="function"){var $=b;b=function(){var ye=Bu(W);$.call(ye)}}var W=J0(c,b,a,0,null,!1,!1,"",ny);return a._reactRootContainer=W,a[tr]=W.current,fl(a.nodeType===8?a.parentNode:a),ya(),W}for(;C=a.lastChild;)a.removeChild(C);if(typeof b=="function"){var se=b;b=function(){var ye=Bu(ae);se.call(ye)}}var ae=Gm(a,0,!1,null,null,!1,!1,"",ny);return a._reactRootContainer=ae,a[tr]=ae.current,fl(a.nodeType===8?a.parentNode:a),ya(function(){Uu(c,ae,f,b)}),ae}function Wu(a,c,f,b,C){var $=f._reactRootContainer;if($){var W=$;if(typeof C=="function"){var se=C;C=function(){var ae=Bu(W);se.call(ae)}}Uu(c,W,a,C)}else W=qC(f,c,a,C,b);return Bu(W)}ks=function(a){switch(a.tag){case 3:var c=a.stateNode;if(c.current.memoizedState.isDehydrated){var f=Xs(c.pendingLanes);f!==0&&(Qs(c,f|1),Es(c,Dt()),(Et&6)===0&&(vo=Dt()+500,Ar()))}break;case 13:ya(function(){var b=rr(a,1);if(b!==null){var C=ds();bi(b,a,1,C)}}),Km(a,1)}},Bt=function(a){if(a.tag===13){var c=rr(a,134217728);if(c!==null){var f=ds();bi(c,a,134217728,f)}Km(a,134217728)}},pt=function(a){if(a.tag===13){var c=Or(a),f=rr(a,c);if(f!==null){var b=ds();bi(f,a,c,b)}Km(a,c)}},Xi=function(){return wt},cs=function(a,c){var f=wt;try{return wt=a,c()}finally{wt=f}},An=function(a,c,f){switch(c){case"input":if(be(a,f),c=f.name,f.type==="radio"&&c!=null){for(f=a;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<f.length;c++){var b=f[c];if(b!==a&&b.form===a.form){var C=lu(b);if(!C)throw Error(s(90));Me(b),be(b,C)}}}break;case"textarea":Pt(a,f);break;case"select":c=f.value,c!=null&&Rt(a,!!f.multiple,c,!1)}},Se=Bm,Be=ya;var GC={usingClientEntryPoint:!1,Events:[xl,io,lu,X,de,Bm]},Il={findFiberByHostInstance:da,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},KC={bundleType:Il.bundleType,version:Il.version,rendererPackageName:Il.rendererPackageName,rendererConfig:Il.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=kr(a),a===null?null:a.stateNode},findFiberByHostInstance:Il.findFiberByHostInstance||VC,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 Vu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vu.isDisabled&&Vu.supportsFiber)try{dt=Vu.inject(KC),mt=Vu}catch{}}return Cs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=GC,Cs.createPortal=function(a,c){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Xm(c))throw Error(s(200));return WC(a,c,null,f)},Cs.createRoot=function(a,c){if(!Xm(a))throw Error(s(299));var f=!1,b="",C=ty;return c!=null&&(c.unstable_strictMode===!0&&(f=!0),c.identifierPrefix!==void 0&&(b=c.identifierPrefix),c.onRecoverableError!==void 0&&(C=c.onRecoverableError)),c=Gm(a,1,!1,null,null,f,!1,b,C),a[tr]=c.current,fl(a.nodeType===8?a.parentNode:a),new Ym(c)},Cs.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var c=a._reactInternals;if(c===void 0)throw typeof a.render=="function"?Error(s(188)):(a=Object.keys(a).join(","),Error(s(268,a)));return a=kr(c),a=a===null?null:a.stateNode,a},Cs.flushSync=function(a){return ya(a)},Cs.hydrate=function(a,c,f){if(!Zu(c))throw Error(s(200));return Wu(null,a,c,!0,f)},Cs.hydrateRoot=function(a,c,f){if(!Xm(a))throw Error(s(405));var b=f!=null&&f.hydratedSources||null,C=!1,$="",W=ty;if(f!=null&&(f.unstable_strictMode===!0&&(C=!0),f.identifierPrefix!==void 0&&($=f.identifierPrefix),f.onRecoverableError!==void 0&&(W=f.onRecoverableError)),c=J0(c,null,a,1,f??null,C,!1,$,W),a[tr]=c.current,fl(a),b)for(a=0;a<b.length;a++)f=b[a],C=f._getVersion,C=C(f._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[f,C]:c.mutableSourceEagerHydrationData.push(f,C);return new Hu(c)},Cs.render=function(a,c,f){if(!Zu(c))throw Error(s(200));return Wu(null,a,c,!1,f)},Cs.unmountComponentAtNode=function(a){if(!Zu(a))throw Error(s(40));return a._reactRootContainer?(ya(function(){Wu(null,null,a,!1,function(){a._reactRootContainer=null,a[tr]=null})}),!0):!1},Cs.unstable_batchedUpdates=Bm,Cs.unstable_renderSubtreeIntoContainer=function(a,c,f,b){if(!Zu(f))throw Error(s(200));if(a==null||a._reactInternals===void 0)throw Error(s(38));return Wu(a,c,f,!1,b)},Cs.version="18.3.1-next-f1338f8080-20240426",Cs}var hy;function sN(){if(hy)return tf.exports;hy=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(),tf.exports=iA(),tf.exports}var my;function rA(){if(my)return qu;my=1;var e=sN();return qu.createRoot=e.createRoot,qu.hydrateRoot=e.hydrateRoot,qu}var aA=rA(),Vr,Po,Lo;class Bi{constructor(t){Ht(this,Vr);Ht(this,Po,new Set);Ht(this,Lo,!1);ht(this,"get",()=>De(this,Vr));ht(this,"subscribe",t=>(De(this,Po).add(t),()=>{De(this,Po).delete(t)}));Kt(this,Vr,t)}set(t){const s=typeof t=="function"?t(De(this,Vr)):t;Object.is(s,De(this,Vr))||(Kt(this,Vr,s),!De(this,Lo)&&(Kt(this,Lo,!0),queueMicrotask(()=>{Kt(this,Lo,!1);for(const i of[...De(this,Po)])i()})))}}Vr=new WeakMap,Po=new WeakMap,Lo=new WeakMap;var fy;function je(e,t,s){function i(u,d){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:d,constr:l,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,d);const h=l.prototype,m=Object.keys(h);for(let p=0;p<m.length;p++){const g=m[p];g in u||(u[g]=h[g].bind(u))}}const r=(s==null?void 0:s.Parent)??Object;class o extends r{}Object.defineProperty(o,"name",{value:e});function l(u){var d;const h=s!=null&&s.Parent?new o:this;i(h,u),(d=h._zod).deferred??(d.deferred=[]);for(const m of h._zod.deferred)m();return h}return Object.defineProperty(l,"init",{value:i}),Object.defineProperty(l,Symbol.hasInstance,{value:u=>{var d,h;return s!=null&&s.Parent&&u instanceof s.Parent?!0:(h=(d=u==null?void 0:u._zod)==null?void 0:d.traits)==null?void 0:h.has(e)}}),Object.defineProperty(l,"name",{value:e}),l}class Ao extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class iN extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(fy=globalThis).__zod_globalConfig??(fy.__zod_globalConfig={});const Ig=globalThis.__zod_globalConfig;function gr(e){return Ig}function rN(e){const t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function yp(e,t){return typeof t=="bigint"?t.toString():t}function th(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Tg(e){return e==null}function Mg(e){const t=e.startsWith("^")?1:0,s=e.endsWith("$")?e.length-1:e.length;return e.slice(t,s)}function oA(e,t){const s=e/t,i=Math.round(s),r=Number.EPSILON*Math.max(Math.abs(s),1);return Math.abs(s-i)<r?0:s-i}const py=Symbol("evaluating");function Lt(e,t,s){let i;Object.defineProperty(e,t,{get(){if(i!==py)return i===void 0&&(i=py,i=s()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Va(e,t,s){Object.defineProperty(e,t,{value:s,writable:!0,enumerable:!0,configurable:!0})}function sa(...e){const t={};for(const s of e){const i=Object.getOwnPropertyDescriptors(s);Object.assign(t,i)}return Object.defineProperties({},t)}function gy(e){return JSON.stringify(e)}function lA(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const aN="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function yc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const cA=th(()=>{var e;if(Ig.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 Ho(e){if(yc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const s=t.prototype;return!(yc(s)===!1||Object.prototype.hasOwnProperty.call(s,"isPrototypeOf")===!1)}function oN(e){return Ho(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const uA=new Set(["string","number","symbol"]);function Zo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ia(e,t,s){const i=new e._zod.constr(t??e._zod.def);return(!t||s!=null&&s.parent)&&(i._zod.parent=e),i}function et(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 dA(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const hA={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 mA(e,t){const s=e._zod.def,i=s.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=sa(e._zod.def,{get shape(){const l={};for(const u in t){if(!(u in s.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(l[u]=s.shape[u])}return Va(this,"shape",l),l},checks:[]});return ia(e,o)}function fA(e,t){const s=e._zod.def,i=s.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=sa(e._zod.def,{get shape(){const l={...e._zod.def.shape};for(const u in t){if(!(u in s.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&delete l[u]}return Va(this,"shape",l),l},checks:[]});return ia(e,o)}function pA(e,t){if(!Ho(t))throw new Error("Invalid input to extend: expected a plain object");const s=e._zod.def.checks;if(s&&s.length>0){const o=e._zod.def.shape;for(const l in t)if(Object.getOwnPropertyDescriptor(o,l)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=sa(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Va(this,"shape",o),o}});return ia(e,r)}function gA(e,t){if(!Ho(t))throw new Error("Invalid input to safeExtend: expected a plain object");const s=sa(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Va(this,"shape",i),i}});return ia(e,s)}function xA(e,t){var i;if((i=e._zod.def.checks)!=null&&i.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const s=sa(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Va(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ia(e,s)}function vA(e,t,s){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const l=sa(t._zod.def,{get shape(){const u=t._zod.def.shape,d={...u};if(s)for(const h in s){if(!(h in u))throw new Error(`Unrecognized key: "${h}"`);s[h]&&(d[h]=e?new e({type:"optional",innerType:u[h]}):u[h])}else for(const h in u)d[h]=e?new e({type:"optional",innerType:u[h]}):u[h];return Va(this,"shape",d),d},checks:[]});return ia(t,l)}function yA(e,t,s){const i=sa(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(s)for(const l in s){if(!(l in o))throw new Error(`Unrecognized key: "${l}"`);s[l]&&(o[l]=new e({type:"nonoptional",innerType:r[l]}))}else for(const l in r)o[l]=new e({type:"nonoptional",innerType:r[l]});return Va(this,"shape",o),o}});return ia(t,i)}function _o(e,t=0){var s;if(e.aborted===!0)return!0;for(let i=t;i<e.issues.length;i++)if(((s=e.issues[i])==null?void 0:s.continue)!==!0)return!0;return!1}function bA(e,t=0){var s;if(e.aborted===!0)return!0;for(let i=t;i<e.issues.length;i++)if(((s=e.issues[i])==null?void 0:s.continue)===!1)return!0;return!1}function Eo(e,t){return t.map(s=>{var i;return(i=s).path??(i.path=[]),s.path.unshift(e),s})}function Gu(e){return typeof e=="string"?e:e==null?void 0:e.message}function xr(e,t,s){var d,h,m,p,g,x;const i=e.message?e.message:Gu((m=(h=(d=e.inst)==null?void 0:d._zod.def)==null?void 0:h.error)==null?void 0:m.call(h,e))??Gu((p=t==null?void 0:t.error)==null?void 0:p.call(t,e))??Gu((g=s.customError)==null?void 0:g.call(s,e))??Gu((x=s.localeError)==null?void 0:x.call(s,e))??"Invalid input",{inst:r,continue:o,input:l,...u}=e;return u.path??(u.path=[]),u.message=i,t!=null&&t.reportInput&&(u.input=l),u}function Rg(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function bc(...e){const[t,s,i]=e;return typeof t=="string"?{message:t,code:"custom",input:s,inst:i}:{...t}}const lN=(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,yp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},cN=je("$ZodError",lN),uN=je("$ZodError",lN,{Parent:Error});function kA(e,t=s=>s.message){const s={},i=[];for(const r of e.issues)r.path.length>0?(s[r.path[0]]=s[r.path[0]]||[],s[r.path[0]].push(t(r))):i.push(t(r));return{formErrors:i,fieldErrors:s}}function jA(e,t=s=>s.message){const s={_errors:[]},i=(r,o=[])=>{for(const l of r.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>i({issues:u},[...o,...l.path]));else if(l.code==="invalid_key")i({issues:l.issues},[...o,...l.path]);else if(l.code==="invalid_element")i({issues:l.issues},[...o,...l.path]);else{const u=[...o,...l.path];if(u.length===0)s._errors.push(t(l));else{let d=s,h=0;for(;h<u.length;){const m=u[h];h===u.length-1?(d[m]=d[m]||{_errors:[]},d[m]._errors.push(t(l))):d[m]=d[m]||{_errors:[]},d=d[m],h++}}}};return i(e),s}const Og=e=>(t,s,i,r)=>{const o=i?{...i,async:!1}:{async:!1},l=t._zod.run({value:s,issues:[]},o);if(l instanceof Promise)throw new Ao;if(l.issues.length){const u=new((r==null?void 0:r.Err)??e)(l.issues.map(d=>xr(d,o,gr())));throw aN(u,r==null?void 0:r.callee),u}return l.value},Pg=e=>async(t,s,i,r)=>{const o=i?{...i,async:!0}:{async:!0};let l=t._zod.run({value:s,issues:[]},o);if(l instanceof Promise&&(l=await l),l.issues.length){const u=new((r==null?void 0:r.Err)??e)(l.issues.map(d=>xr(d,o,gr())));throw aN(u,r==null?void 0:r.callee),u}return l.value},nh=e=>(t,s,i)=>{const r=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:s,issues:[]},r);if(o instanceof Promise)throw new Ao;return o.issues.length?{success:!1,error:new(e??cN)(o.issues.map(l=>xr(l,r,gr())))}:{success:!0,data:o.value}},NA=nh(uN),sh=e=>async(t,s,i)=>{const r=i?{...i,async:!0}:{async:!0};let o=t._zod.run({value:s,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(l=>xr(l,r,gr())))}:{success:!0,data:o.value}},wA=sh(uN),SA=e=>(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Og(e)(t,s,r)},_A=e=>(t,s,i)=>Og(e)(t,s,i),EA=e=>async(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Pg(e)(t,s,r)},CA=e=>async(t,s,i)=>Pg(e)(t,s,i),AA=e=>(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return nh(e)(t,s,r)},$A=e=>(t,s,i)=>nh(e)(t,s,i),IA=e=>async(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return sh(e)(t,s,r)},TA=e=>async(t,s,i)=>sh(e)(t,s,i),MA=/^[cC][0-9a-z]{6,}$/,RA=/^[0-9a-z]+$/,OA=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,PA=/^[0-9a-vA-V]{20}$/,LA=/^[A-Za-z0-9]{27}$/,zA=/^[a-zA-Z0-9_-]{21}$/,DA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,FA=/^([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})$/,xy=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)$/,UA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,BA="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function HA(){return new RegExp(BA,"u")}const ZA=/^(?:(?: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])$/,WA=/^(([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}|:))$/,VA=/^((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])$/,qA=/^(([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])$/,GA=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dN=/^[A-Za-z0-9_-]*$/,KA=/^https?$/,YA=/^\+[1-9]\d{6,14}$/,hN="(?:(?:\\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])))",XA=new RegExp(`^${hN}$`);function mN(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 QA(e){return new RegExp(`^${mN(e)}$`)}function JA(e){const t=mN({precision:e.precision}),s=["Z"];e.local&&s.push(""),e.offset&&s.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${t}(?:${s.join("|")})`;return new RegExp(`^${hN}T(?:${i})$`)}const e$=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}$`)},t$=/^-?\d+$/,fN=/^-?\d+(?:\.\d+)?$/,n$=/^(?:true|false)$/i,s$=/^null$/i,i$=/^[^A-Z]*$/,r$=/^[^a-z]*$/,Rs=je("$ZodCheck",(e,t)=>{var s;e._zod??(e._zod={}),e._zod.def=t,(s=e._zod).onattach??(s.onattach=[])}),pN={number:"number",bigint:"bigint",object:"date"},gN=je("$ZodCheckLessThan",(e,t)=>{Rs.init(e,t);const s=pN[typeof t.value];e._zod.onattach.push(i=>{const r=i._zod.bag,o=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:s,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xN=je("$ZodCheckGreaterThan",(e,t)=>{Rs.init(e,t);const s=pN[typeof t.value];e._zod.onattach.push(i=>{const r=i._zod.bag,o=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:s,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),a$=je("$ZodCheckMultipleOf",(e,t)=>{Rs.init(e,t),e._zod.onattach.push(s=>{var i;(i=s._zod.bag).multipleOf??(i.multipleOf=t.value)}),e._zod.check=s=>{if(typeof s.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof s.value=="bigint"?s.value%t.value===BigInt(0):oA(s.value,t.value)===0)||s.issues.push({origin:typeof s.value,code:"not_multiple_of",divisor:t.value,input:s.value,inst:e,continue:!t.abort})}}),o$=je("$ZodCheckNumberFormat",(e,t)=>{var l;Rs.init(e,t),t.format=t.format||"float64";const s=(l=t.format)==null?void 0:l.includes("int"),i=s?"int":"number",[r,o]=hA[t.format];e._zod.onattach.push(u=>{const d=u._zod.bag;d.format=t.format,d.minimum=r,d.maximum=o,s&&(d.pattern=t$)}),e._zod.check=u=>{const d=u.value;if(s){if(!Number.isInteger(d)){u.issues.push({expected:i,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:i,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:i,inclusive:!0,continue:!t.abort});return}}d<r&&u.issues.push({origin:"number",input:d,code:"too_small",minimum:r,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})}}),l$=je("$ZodCheckMaxLength",(e,t)=>{var s;Rs.init(e,t),(s=e._zod.def).when??(s.when=i=>{const r=i.value;return!Tg(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{const r=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{const r=i.value;if(r.length<=t.maximum)return;const l=Rg(r);i.issues.push({origin:l,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),c$=je("$ZodCheckMinLength",(e,t)=>{var s;Rs.init(e,t),(s=e._zod.def).when??(s.when=i=>{const r=i.value;return!Tg(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{const r=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{const r=i.value;if(r.length>=t.minimum)return;const l=Rg(r);i.issues.push({origin:l,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),u$=je("$ZodCheckLengthEquals",(e,t)=>{var s;Rs.init(e,t),(s=e._zod.def).when??(s.when=i=>{const r=i.value;return!Tg(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{const r=i._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=i=>{const r=i.value,o=r.length;if(o===t.length)return;const l=Rg(r),u=o>t.length;i.issues.push({origin:l,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),ih=je("$ZodCheckStringFormat",(e,t)=>{var s,i;Rs.init(e,t),e._zod.onattach.push(r=>{const o=r._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(s=e._zod).check??(s.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),d$=je("$ZodCheckRegex",(e,t)=>{ih.init(e,t),e._zod.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:"regex",input:s.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),h$=je("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=i$),ih.init(e,t)}),m$=je("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=r$),ih.init(e,t)}),f$=je("$ZodCheckIncludes",(e,t)=>{Rs.init(e,t);const s=Zo(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${s}`:s);t.pattern=i,e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),p$=je("$ZodCheckStartsWith",(e,t)=>{Rs.init(e,t);const s=new RegExp(`^${Zo(t.prefix)}.*`);t.pattern??(t.pattern=s),e._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(s)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),g$=je("$ZodCheckEndsWith",(e,t)=>{Rs.init(e,t);const s=new RegExp(`.*${Zo(t.suffix)}$`);t.pattern??(t.pattern=s),e._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(s)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}}),x$=je("$ZodCheckOverwrite",(e,t)=>{Rs.init(e,t),e._zod.check=s=>{s.value=t.tx(s.value)}});class v${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 i=t.split(`
|
|
41
|
-
`).filter(l=>l),r=Math.min(...i.map(l=>l.length-l.trimStart().length)),o=i.map(l=>l.slice(r)).map(l=>" ".repeat(this.indent*2)+l);for(const l of o)this.content.push(l)}compile(){const t=Function,s=this==null?void 0:this.args,r=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new t(...s,r.join(`
|
|
42
|
-
`))}}const y$={major:4,minor:4,patch:3},tn=je("$ZodType",(e,t)=>{var r;var s;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=y$;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const o of i)for(const l of o._zod.onattach)l(e);if(i.length===0)(s=e._zod).deferred??(s.deferred=[]),(r=e._zod.deferred)==null||r.push(()=>{e._zod.run=e._zod.parse});else{const o=(u,d,h)=>{let m=_o(u),p;for(const g of d){if(g._zod.def.when){if(bA(u)||!g._zod.def.when(u))continue}else if(m)continue;const x=u.issues.length,N=g._zod.check(u);if(N instanceof Promise&&(h==null?void 0:h.async)===!1)throw new Ao;if(p||N instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await N,u.issues.length!==x&&(m||(m=_o(u,x)))});else{if(u.issues.length===x)continue;m||(m=_o(u,x))}}return p?p.then(()=>u):u},l=(u,d,h)=>{if(_o(u))return u.aborted=!0,u;const m=o(d,i,h);if(m instanceof Promise){if(h.async===!1)throw new Ao;return m.then(p=>e._zod.parse(p,h))}return e._zod.parse(m,h)};e._zod.run=(u,d)=>{if(d.skipChecks)return e._zod.parse(u,d);if(d.direction==="backward"){const m=e._zod.parse({value:u.value,issues:[]},{...d,skipChecks:!0});return m instanceof Promise?m.then(p=>l(p,u,d)):l(m,u,d)}const h=e._zod.parse(u,d);if(h instanceof Promise){if(d.async===!1)throw new Ao;return h.then(m=>o(m,i,d))}return o(h,i,d)}}Lt(e,"~standard",()=>({validate:o=>{var l;try{const u=NA(e,o);return u.success?{value:u.data}:{issues:(l=u.error)==null?void 0:l.issues}}catch{return wA(e,o).then(d=>{var h;return d.success?{value:d.data}:{issues:(h=d.error)==null?void 0:h.issues}})}},vendor:"zod",version:1}))}),Lg=je("$ZodString",(e,t)=>{var s;tn.init(e,t),e._zod.pattern=[...((s=e==null?void 0:e._zod.bag)==null?void 0:s.patterns)??[]].pop()??e$(e._zod.bag),e._zod.parse=(i,r)=>{if(t.coerce)try{i.value=String(i.value)}catch{}return typeof i.value=="string"||i.issues.push({expected:"string",code:"invalid_type",input:i.value,inst:e}),i}}),nn=je("$ZodStringFormat",(e,t)=>{ih.init(e,t),Lg.init(e,t)}),b$=je("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=FA),nn.init(e,t)}),k$=je("$ZodUUID",(e,t)=>{if(t.version){const i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=xy(i))}else t.pattern??(t.pattern=xy());nn.init(e,t)}),j$=je("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=UA),nn.init(e,t)}),N$=je("$ZodURL",(e,t)=>{nn.init(e,t),e._zod.check=s=>{var i;try{const r=s.value.trim();if(!t.normalize&&((i=t.protocol)==null?void 0:i.source)===KA.source&&!/^https?:\/\//i.test(r)){s.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:s.value,inst:e,continue:!t.abort});return}const o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||s.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:s.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)||s.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:s.value,inst:e,continue:!t.abort})),t.normalize?s.value=o.href:s.value=r;return}catch{s.issues.push({code:"invalid_format",format:"url",input:s.value,inst:e,continue:!t.abort})}}}),w$=je("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=HA()),nn.init(e,t)}),S$=je("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=zA),nn.init(e,t)}),_$=je("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=MA),nn.init(e,t)}),E$=je("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=RA),nn.init(e,t)}),C$=je("$ZodULID",(e,t)=>{t.pattern??(t.pattern=OA),nn.init(e,t)}),A$=je("$ZodXID",(e,t)=>{t.pattern??(t.pattern=PA),nn.init(e,t)}),$$=je("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=LA),nn.init(e,t)}),I$=je("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=JA(t)),nn.init(e,t)}),T$=je("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=XA),nn.init(e,t)}),M$=je("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=QA(t)),nn.init(e,t)}),R$=je("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=DA),nn.init(e,t)}),O$=je("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ZA),nn.init(e,t),e._zod.bag.format="ipv4"}),P$=je("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=WA),nn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=s=>{try{new URL(`http://[${s.value}]`)}catch{s.issues.push({code:"invalid_format",format:"ipv6",input:s.value,inst:e,continue:!t.abort})}}}),L$=je("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=VA),nn.init(e,t)}),z$=je("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=qA),nn.init(e,t),e._zod.check=s=>{const i=s.value.split("/");try{if(i.length!==2)throw new Error;const[r,o]=i;if(!o)throw new Error;const l=Number(o);if(`${l}`!==o)throw new Error;if(l<0||l>128)throw new Error;new URL(`http://[${r}]`)}catch{s.issues.push({code:"invalid_format",format:"cidrv6",input:s.value,inst:e,continue:!t.abort})}}});function vN(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const D$=je("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=GA),nn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=s=>{vN(s.value)||s.issues.push({code:"invalid_format",format:"base64",input:s.value,inst:e,continue:!t.abort})}});function F$(e){if(!dN.test(e))return!1;const t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),s=t.padEnd(Math.ceil(t.length/4)*4,"=");return vN(s)}const U$=je("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=dN),nn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=s=>{F$(s.value)||s.issues.push({code:"invalid_format",format:"base64url",input:s.value,inst:e,continue:!t.abort})}}),B$=je("$ZodE164",(e,t)=>{t.pattern??(t.pattern=YA),nn.init(e,t)});function H$(e,t=null){try{const s=e.split(".");if(s.length!==3)return!1;const[i]=s;if(!i)return!1;const r=JSON.parse(atob(i));return!("typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const Z$=je("$ZodJWT",(e,t)=>{nn.init(e,t),e._zod.check=s=>{H$(s.value,t.alg)||s.issues.push({code:"invalid_format",format:"jwt",input:s.value,inst:e,continue:!t.abort})}}),yN=je("$ZodNumber",(e,t)=>{tn.init(e,t),e._zod.pattern=e._zod.bag.pattern??fN,e._zod.parse=(s,i)=>{if(t.coerce)try{s.value=Number(s.value)}catch{}const r=s.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return s;const o=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return s.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...o?{received:o}:{}}),s}}),W$=je("$ZodNumberFormat",(e,t)=>{o$.init(e,t),yN.init(e,t)}),V$=je("$ZodBoolean",(e,t)=>{tn.init(e,t),e._zod.pattern=n$,e._zod.parse=(s,i)=>{if(t.coerce)try{s.value=!!s.value}catch{}const r=s.value;return typeof r=="boolean"||s.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),s}}),q$=je("$ZodNull",(e,t)=>{tn.init(e,t),e._zod.pattern=s$,e._zod.values=new Set([null]),e._zod.parse=(s,i)=>{const r=s.value;return r===null||s.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),s}}),G$=je("$ZodUnknown",(e,t)=>{tn.init(e,t),e._zod.parse=s=>s}),K$=je("$ZodNever",(e,t)=>{tn.init(e,t),e._zod.parse=(s,i)=>(s.issues.push({expected:"never",code:"invalid_type",input:s.value,inst:e}),s)});function vy(e,t,s){e.issues.length&&t.issues.push(...Eo(s,e.issues)),t.value[s]=e.value}const Y$=je("$ZodArray",(e,t)=>{tn.init(e,t),e._zod.parse=(s,i)=>{const r=s.value;if(!Array.isArray(r))return s.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),s;s.value=Array(r.length);const o=[];for(let l=0;l<r.length;l++){const u=r[l],d=t.element._zod.run({value:u,issues:[]},i);d instanceof Promise?o.push(d.then(h=>vy(h,s,l))):vy(d,s,l)}return o.length?Promise.all(o).then(()=>s):s}});function Cd(e,t,s,i,r,o){const l=s in i;if(e.issues.length){if(r&&o&&!l)return;t.issues.push(...Eo(s,e.issues))}if(!l&&!r){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[s]});return}e.value===void 0?l&&(t.value[s]=void 0):t.value[s]=e.value}function bN(e){var i,r,o,l;const t=Object.keys(e.shape);for(const u of t)if(!((l=(o=(r=(i=e.shape)==null?void 0:i[u])==null?void 0:r._zod)==null?void 0:o.traits)!=null&&l.has("$ZodType")))throw new Error(`Invalid element at key "${u}": expected a Zod schema`);const s=dA(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function kN(e,t,s,i,r,o){const l=[],u=r.keySet,d=r.catchall._zod,h=d.def.type,m=d.optin==="optional",p=d.optout==="optional";for(const g in t){if(g==="__proto__"||u.has(g))continue;if(h==="never"){l.push(g);continue}const x=d.run({value:t[g],issues:[]},i);x instanceof Promise?e.push(x.then(N=>Cd(N,s,g,t,m,p))):Cd(x,s,g,t,m,p)}return l.length&&s.issues.push({code:"unrecognized_keys",keys:l,input:t,inst:o}),e.length?Promise.all(e).then(()=>s):s}const X$=je("$ZodObject",(e,t)=>{tn.init(e,t);const s=Object.getOwnPropertyDescriptor(t,"shape");if(!(s!=null&&s.get)){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...u};return Object.defineProperty(t,"shape",{value:d}),d}})}const i=th(()=>bN(t));Lt(e._zod,"propValues",()=>{const u=t.shape,d={};for(const h in u){const m=u[h]._zod;if(m.values){d[h]??(d[h]=new Set);for(const p of m.values)d[h].add(p)}}return d});const r=yc,o=t.catchall;let l;e._zod.parse=(u,d)=>{l??(l=i.value);const h=u.value;if(!r(h))return u.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),u;u.value={};const m=[],p=l.shape;for(const g of l.keys){const x=p[g],N=x._zod.optin==="optional",j=x._zod.optout==="optional",y=x._zod.run({value:h[g],issues:[]},d);y instanceof Promise?m.push(y.then(k=>Cd(k,u,g,h,N,j))):Cd(y,u,g,h,N,j)}return o?kN(m,h,u,d,i.value,e):m.length?Promise.all(m).then(()=>u):u}}),Q$=je("$ZodObjectJIT",(e,t)=>{X$.init(e,t);const s=e._zod.parse,i=th(()=>bN(t)),r=g=>{var S,E;const x=new v$(["shape","payload","ctx"]),N=i.value,j=O=>{const P=gy(O);return`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`};x.write("const input = payload.value;");const y=Object.create(null);let k=0;for(const O of N.keys)y[O]=`key_${k++}`;x.write("const newResult = {};");for(const O of N.keys){const P=y[O],H=gy(O),B=g[O],R=((S=B==null?void 0:B._zod)==null?void 0:S.optin)==="optional",M=((E=B==null?void 0:B._zod)==null?void 0:E.optout)==="optional";x.write(`const ${P} = ${j(O)};`),R&&M?x.write(`
|
|
43
|
-
if (${P}.issues.length) {
|
|
44
|
-
if (${H} in input) {
|
|
45
|
-
payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
|
|
46
|
-
...iss,
|
|
47
|
-
path: iss.path ? [${H}, ...iss.path] : [${H}]
|
|
48
|
-
})));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (${P}.value === undefined) {
|
|
53
|
-
if (${H} in input) {
|
|
54
|
-
newResult[${H}] = undefined;
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
newResult[${H}] = ${P}.value;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
`):R?x.write(`
|
|
61
|
-
if (${P}.issues.length) {
|
|
62
|
-
payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
|
|
63
|
-
...iss,
|
|
64
|
-
path: iss.path ? [${H}, ...iss.path] : [${H}]
|
|
65
|
-
})));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (${P}.value === undefined) {
|
|
69
|
-
if (${H} in input) {
|
|
70
|
-
newResult[${H}] = undefined;
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
newResult[${H}] = ${P}.value;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
`):x.write(`
|
|
77
|
-
const ${P}_present = ${H} in input;
|
|
78
|
-
if (${P}.issues.length) {
|
|
79
|
-
payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
|
|
80
|
-
...iss,
|
|
81
|
-
path: iss.path ? [${H}, ...iss.path] : [${H}]
|
|
82
|
-
})));
|
|
83
|
-
}
|
|
84
|
-
if (!${P}_present && !${P}.issues.length) {
|
|
85
|
-
payload.issues.push({
|
|
86
|
-
code: "invalid_type",
|
|
87
|
-
expected: "nonoptional",
|
|
88
|
-
input: undefined,
|
|
89
|
-
path: [${H}]
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (${P}_present) {
|
|
94
|
-
if (${P}.value === undefined) {
|
|
95
|
-
newResult[${H}] = undefined;
|
|
96
|
-
} else {
|
|
97
|
-
newResult[${H}] = ${P}.value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
`)}x.write("payload.value = newResult;"),x.write("return payload;");const _=x.compile();return(O,P)=>_(g,O,P)};let o;const l=yc,u=!Ig.jitless,h=u&&cA.value,m=t.catchall;let p;e._zod.parse=(g,x)=>{p??(p=i.value);const N=g.value;return l(N)?u&&h&&(x==null?void 0:x.async)===!1&&x.jitless!==!0?(o||(o=r(t.shape)),g=o(g,x),m?kN([],N,g,x,p,e):g):s(g,x):(g.issues.push({expected:"object",code:"invalid_type",input:N,inst:e}),g)}});function yy(e,t,s,i){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const r=e.filter(o=>!_o(o));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:s,errors:e.map(o=>o.issues.map(l=>xr(l,i,gr())))}),t)}const jN=je("$ZodUnion",(e,t)=>{tn.init(e,t),Lt(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Lt(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Lt(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Lt(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${i.map(r=>Mg(r.source)).join("|")})$`)}});const s=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(s)return s(i,r);let o=!1;const l=[];for(const u of t.options){const d=u._zod.run({value:i.value,issues:[]},r);if(d instanceof Promise)l.push(d),o=!0;else{if(d.issues.length===0)return d;l.push(d)}}return o?Promise.all(l).then(u=>yy(u,i,e,r)):yy(l,i,e,r)}}),J$=je("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,jN.init(e,t);const s=e._zod.parse;Lt(e._zod,"propValues",()=>{const r={};for(const o of t.options){const l=o._zod.propValues;if(!l||Object.keys(l).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[u,d]of Object.entries(l)){r[u]||(r[u]=new Set);for(const h of d)r[u].add(h)}}return r});const i=th(()=>{var l;const r=t.options,o=new Map;for(const u of r){const d=(l=u._zod.propValues)==null?void 0:l[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const h of d){if(o.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);o.set(h,u)}}return o});e._zod.parse=(r,o)=>{const l=r.value;if(!yc(l))return r.issues.push({code:"invalid_type",expected:"object",input:l,inst:e}),r;const u=i.value.get(l==null?void 0:l[t.discriminator]);return u?u._zod.run(r,o):t.unionFallback||o.direction==="backward"?s(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()),input:l,path:[t.discriminator],inst:e}),r)}}),eI=je("$ZodIntersection",(e,t)=>{tn.init(e,t),e._zod.parse=(s,i)=>{const r=s.value,o=t.left._zod.run({value:r,issues:[]},i),l=t.right._zod.run({value:r,issues:[]},i);return o instanceof Promise||l instanceof Promise?Promise.all([o,l]).then(([d,h])=>by(s,d,h)):by(s,o,l)}});function bp(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(Ho(e)&&Ho(t)){const s=Object.keys(t),i=Object.keys(e).filter(o=>s.indexOf(o)!==-1),r={...e,...t};for(const o of i){const l=bp(e[o],t[o]);if(!l.valid)return{valid:!1,mergeErrorPath:[o,...l.mergeErrorPath]};r[o]=l.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const s=[];for(let i=0;i<e.length;i++){const r=e[i],o=t[i],l=bp(r,o);if(!l.valid)return{valid:!1,mergeErrorPath:[i,...l.mergeErrorPath]};s.push(l.data)}return{valid:!0,data:s}}return{valid:!1,mergeErrorPath:[]}}function by(e,t,s){const i=new Map;let r;for(const u of t.issues)if(u.code==="unrecognized_keys"){r??(r=u);for(const d of u.keys)i.has(d)||i.set(d,{}),i.get(d).l=!0}else e.issues.push(u);for(const u of s.issues)if(u.code==="unrecognized_keys")for(const d of u.keys)i.has(d)||i.set(d,{}),i.get(d).r=!0;else e.issues.push(u);const o=[...i].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(o.length&&r&&e.issues.push({...r,keys:o}),_o(e))return e;const l=bp(t.value,s.value);if(!l.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`);return e.value=l.data,e}const tI=je("$ZodRecord",(e,t)=>{tn.init(e,t),e._zod.parse=(s,i)=>{const r=s.value;if(!Ho(r))return s.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),s;const o=[],l=t.keyType._zod.values;if(l){s.value={};const u=new Set;for(const h of l)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){u.add(typeof h=="number"?h.toString():h);const m=t.keyType._zod.run({value:h,issues:[]},i);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(m.issues.length){s.issues.push({code:"invalid_key",origin:"record",issues:m.issues.map(x=>xr(x,i,gr())),input:h,path:[h],inst:e});continue}const p=m.value,g=t.valueType._zod.run({value:r[h],issues:[]},i);g instanceof Promise?o.push(g.then(x=>{x.issues.length&&s.issues.push(...Eo(h,x.issues)),s.value[p]=x.value})):(g.issues.length&&s.issues.push(...Eo(h,g.issues)),s.value[p]=g.value)}let d;for(const h in r)u.has(h)||(d=d??[],d.push(h));d&&d.length>0&&s.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:d})}else{s.value={};for(const u of Reflect.ownKeys(r)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(r,u))continue;let d=t.keyType._zod.run({value:u,issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&fN.test(u)&&d.issues.length){const p=t.keyType._zod.run({value:Number(u),issues:[]},i);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(d=p)}if(d.issues.length){t.mode==="loose"?s.value[u]=r[u]:s.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(p=>xr(p,i,gr())),input:u,path:[u],inst:e});continue}const m=t.valueType._zod.run({value:r[u],issues:[]},i);m instanceof Promise?o.push(m.then(p=>{p.issues.length&&s.issues.push(...Eo(u,p.issues)),s.value[d.value]=p.value})):(m.issues.length&&s.issues.push(...Eo(u,m.issues)),s.value[d.value]=m.value)}}return o.length?Promise.all(o).then(()=>s):s}}),nI=je("$ZodEnum",(e,t)=>{tn.init(e,t);const s=rN(t.entries),i=new Set(s);e._zod.values=i,e._zod.pattern=new RegExp(`^(${s.filter(r=>uA.has(typeof r)).map(r=>typeof r=="string"?Zo(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const l=r.value;return i.has(l)||r.issues.push({code:"invalid_value",values:s,input:l,inst:e}),r}}),sI=je("$ZodLiteral",(e,t)=>{if(tn.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const s=new Set(t.values);e._zod.values=s,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?Zo(i):i?Zo(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,r)=>{const o=i.value;return s.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),iI=je("$ZodTransform",(e,t)=>{tn.init(e,t),e._zod.optin="optional",e._zod.parse=(s,i)=>{if(i.direction==="backward")throw new iN(e.constructor.name);const r=t.transform(s.value,s);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(l=>(s.value=l,s.fallback=!0,s));if(r instanceof Promise)throw new Ao;return s.value=r,s.fallback=!0,s}});function ky(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const NN=je("$ZodOptional",(e,t)=>{tn.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Lt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Lt(e._zod,"pattern",()=>{const s=t.innerType._zod.pattern;return s?new RegExp(`^(${Mg(s.source)})?$`):void 0}),e._zod.parse=(s,i)=>{if(t.innerType._zod.optin==="optional"){const r=s.value,o=t.innerType._zod.run(s,i);return o instanceof Promise?o.then(l=>ky(l,r)):ky(o,r)}return s.value===void 0?s:t.innerType._zod.run(s,i)}}),rI=je("$ZodExactOptional",(e,t)=>{NN.init(e,t),Lt(e._zod,"values",()=>t.innerType._zod.values),Lt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(s,i)=>t.innerType._zod.run(s,i)}),aI=je("$ZodNullable",(e,t)=>{tn.init(e,t),Lt(e._zod,"optin",()=>t.innerType._zod.optin),Lt(e._zod,"optout",()=>t.innerType._zod.optout),Lt(e._zod,"pattern",()=>{const s=t.innerType._zod.pattern;return s?new RegExp(`^(${Mg(s.source)}|null)$`):void 0}),Lt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(s,i)=>s.value===null?s:t.innerType._zod.run(s,i)}),oI=je("$ZodDefault",(e,t)=>{tn.init(e,t),e._zod.optin="optional",Lt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(s,i)=>{if(i.direction==="backward")return t.innerType._zod.run(s,i);if(s.value===void 0)return s.value=t.defaultValue,s;const r=t.innerType._zod.run(s,i);return r instanceof Promise?r.then(o=>jy(o,t)):jy(r,t)}});function jy(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const lI=je("$ZodPrefault",(e,t)=>{tn.init(e,t),e._zod.optin="optional",Lt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(s,i)=>(i.direction==="backward"||s.value===void 0&&(s.value=t.defaultValue),t.innerType._zod.run(s,i))}),cI=je("$ZodNonOptional",(e,t)=>{tn.init(e,t),Lt(e._zod,"values",()=>{const s=t.innerType._zod.values;return s?new Set([...s].filter(i=>i!==void 0)):void 0}),e._zod.parse=(s,i)=>{const r=t.innerType._zod.run(s,i);return r instanceof Promise?r.then(o=>Ny(o,e)):Ny(r,e)}});function Ny(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 uI=je("$ZodCatch",(e,t)=>{tn.init(e,t),e._zod.optin="optional",Lt(e._zod,"optout",()=>t.innerType._zod.optout),Lt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(s,i)=>{if(i.direction==="backward")return t.innerType._zod.run(s,i);const r=t.innerType._zod.run(s,i);return r instanceof Promise?r.then(o=>(s.value=o.value,o.issues.length&&(s.value=t.catchValue({...s,error:{issues:o.issues.map(l=>xr(l,i,gr()))},input:s.value}),s.issues=[],s.fallback=!0),s)):(s.value=r.value,r.issues.length&&(s.value=t.catchValue({...s,error:{issues:r.issues.map(o=>xr(o,i,gr()))},input:s.value}),s.issues=[],s.fallback=!0),s)}}),dI=je("$ZodPipe",(e,t)=>{tn.init(e,t),Lt(e._zod,"values",()=>t.in._zod.values),Lt(e._zod,"optin",()=>t.in._zod.optin),Lt(e._zod,"optout",()=>t.out._zod.optout),Lt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(s,i)=>{if(i.direction==="backward"){const o=t.out._zod.run(s,i);return o instanceof Promise?o.then(l=>Ku(l,t.in,i)):Ku(o,t.in,i)}const r=t.in._zod.run(s,i);return r instanceof Promise?r.then(o=>Ku(o,t.out,i)):Ku(r,t.out,i)}});function Ku(e,t,s){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},s)}const hI=je("$ZodReadonly",(e,t)=>{tn.init(e,t),Lt(e._zod,"propValues",()=>t.innerType._zod.propValues),Lt(e._zod,"values",()=>t.innerType._zod.values),Lt(e._zod,"optin",()=>{var s,i;return(i=(s=t.innerType)==null?void 0:s._zod)==null?void 0:i.optin}),Lt(e._zod,"optout",()=>{var s,i;return(i=(s=t.innerType)==null?void 0:s._zod)==null?void 0:i.optout}),e._zod.parse=(s,i)=>{if(i.direction==="backward")return t.innerType._zod.run(s,i);const r=t.innerType._zod.run(s,i);return r instanceof Promise?r.then(wy):wy(r)}});function wy(e){return e.value=Object.freeze(e.value),e}const mI=je("$ZodCustom",(e,t)=>{Rs.init(e,t),tn.init(e,t),e._zod.parse=(s,i)=>s,e._zod.check=s=>{const i=s.value,r=t.fn(i);if(r instanceof Promise)return r.then(o=>Sy(o,s,i,e));Sy(r,s,i,e)}});function Sy(e,t,s,i){if(!e){const r={code:"custom",input:s,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),t.issues.push(bc(r))}}var _y;class fI{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...s){const i=s[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const s=this._map.get(t);return s&&typeof s=="object"&&"id"in s&&this._idmap.delete(s.id),this._map.delete(t),this}get(t){const s=t._zod.parent;if(s){const i={...this.get(s)??{}};delete i.id;const r={...i,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function pI(){return new fI}(_y=globalThis).__zod_globalRegistry??(_y.__zod_globalRegistry=pI());const Kl=globalThis.__zod_globalRegistry;function gI(e,t){return new e({type:"string",...et(t)})}function xI(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...et(t)})}function Ey(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...et(t)})}function vI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...et(t)})}function yI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...et(t)})}function bI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...et(t)})}function kI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...et(t)})}function wN(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...et(t)})}function jI(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...et(t)})}function NI(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...et(t)})}function wI(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...et(t)})}function SI(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...et(t)})}function _I(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...et(t)})}function EI(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...et(t)})}function CI(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...et(t)})}function AI(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...et(t)})}function $I(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...et(t)})}function II(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...et(t)})}function TI(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...et(t)})}function MI(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...et(t)})}function RI(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...et(t)})}function OI(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...et(t)})}function PI(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...et(t)})}function LI(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...et(t)})}function zI(e,t){return new e({type:"string",format:"date",check:"string_format",...et(t)})}function DI(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...et(t)})}function FI(e,t){return new e({type:"string",format:"duration",check:"string_format",...et(t)})}function UI(e,t){return new e({type:"number",checks:[],...et(t)})}function BI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...et(t)})}function HI(e,t){return new e({type:"boolean",...et(t)})}function ZI(e,t){return new e({type:"null",...et(t)})}function WI(e){return new e({type:"unknown"})}function VI(e,t){return new e({type:"never",...et(t)})}function Cy(e,t){return new gN({check:"less_than",...et(t),value:e,inclusive:!1})}function rf(e,t){return new gN({check:"less_than",...et(t),value:e,inclusive:!0})}function Ay(e,t){return new xN({check:"greater_than",...et(t),value:e,inclusive:!1})}function af(e,t){return new xN({check:"greater_than",...et(t),value:e,inclusive:!0})}function $y(e,t){return new a$({check:"multiple_of",...et(t),value:e})}function SN(e,t){return new l$({check:"max_length",...et(t),maximum:e})}function Ad(e,t){return new c$({check:"min_length",...et(t),minimum:e})}function _N(e,t){return new u$({check:"length_equals",...et(t),length:e})}function qI(e,t){return new d$({check:"string_format",format:"regex",...et(t),pattern:e})}function GI(e){return new h$({check:"string_format",format:"lowercase",...et(e)})}function KI(e){return new m$({check:"string_format",format:"uppercase",...et(e)})}function YI(e,t){return new f$({check:"string_format",format:"includes",...et(t),includes:e})}function XI(e,t){return new p$({check:"string_format",format:"starts_with",...et(t),prefix:e})}function QI(e,t){return new g$({check:"string_format",format:"ends_with",...et(t),suffix:e})}function il(e){return new x$({check:"overwrite",tx:e})}function JI(e){return il(t=>t.normalize(e))}function eT(){return il(e=>e.trim())}function tT(){return il(e=>e.toLowerCase())}function nT(){return il(e=>e.toUpperCase())}function sT(){return il(e=>lA(e))}function iT(e,t,s){return new e({type:"array",element:t,...et(s)})}function rT(e,t,s){return new e({type:"custom",check:"custom",fn:t,...et(s)})}function aT(e,t){const s=oT(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(bc(r,i.value,s._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=i.value),o.inst??(o.inst=s),o.continue??(o.continue=!s._zod.def.abort),i.issues.push(bc(o))}},e(i.value,i)),t);return s}function oT(e,t){const s=new Rs({check:"custom",...et(t)});return s._zod.check=e,s}function EN(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)??Kl,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 Sn(e,t,s={path:[],schemaPath:[]}){var m,p;var i;const r=e._zod.def,o=t.seen.get(e);if(o)return o.count++,s.schemaPath.includes(e)&&(o.cycle=s.path),o.schema;const l={schema:{},count:1,cycle:void 0,path:s.path};t.seen.set(e,l);const u=(p=(m=e._zod).toJSONSchema)==null?void 0:p.call(m);if(u)l.schema=u;else{const g={...s,schemaPath:[...s.schemaPath,e],path:s.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,g);else{const N=l.schema,j=t.processors[r.type];if(!j)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);j(e,t,N,g)}const x=e._zod.parent;x&&(l.ref||(l.ref=x),Sn(x,t,g),t.seen.get(x).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Object.assign(l.schema,d),t.io==="input"&&hs(e)&&(delete l.schema.examples,delete l.schema.default),t.io==="input"&&"_prefault"in l.schema&&((i=l.schema).default??(i.default=l.schema._prefault)),delete l.schema._prefault,t.seen.get(e).schema}function CN(e,t){var l,u,d,h;const s=e.seen.get(t);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const m of e.seen.entries()){const p=(l=e.metadataRegistry.get(m[0]))==null?void 0:l.id;if(p){const g=i.get(p);if(g&&g!==m[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(p,m[0])}}const r=m=>{var j;const p=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const y=(j=e.external.registry.get(m[0]))==null?void 0:j.id,k=e.external.uri??(S=>S);if(y)return{ref:k(y)};const _=m[1].defId??m[1].schema.id??`schema${e.counter++}`;return m[1].defId=_,{defId:_,ref:`${k("__shared")}#/${p}/${_}`}}if(m[1]===s)return{ref:"#"};const x=`#/${p}/`,N=m[1].schema.id??`__schema${e.counter++}`;return{defId:N,ref:x+N}},o=m=>{if(m[1].schema.$ref)return;const p=m[1],{ref:g,defId:x}=r(m);p.def={...p.schema},x&&(p.defId=x);const N=p.schema;for(const j in N)delete N[j];N.$ref=g};if(e.cycles==="throw")for(const m of e.seen.entries()){const p=m[1];if(p.cycle)throw new Error(`Cycle detected: #/${(u=p.cycle)==null?void 0:u.join("/")}/<root>
|
|
102
|
-
|
|
103
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const m of e.seen.entries()){const p=m[1];if(t===m[0]){o(m);continue}if(e.external){const x=(d=e.external.registry.get(m[0]))==null?void 0:d.id;if(t!==m[0]&&x){o(m);continue}}if((h=e.metadataRegistry.get(m[0]))==null?void 0:h.id){o(m);continue}if(p.cycle){o(m);continue}if(p.count>1&&e.reused==="ref"){o(m);continue}}}function AN(e,t){var u,d,h,m;const s=e.seen.get(t);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=p=>{const g=e.seen.get(p);if(g.ref===null)return;const x=g.def??g.schema,N={...x},j=g.ref;if(g.ref=null,j){i(j);const k=e.seen.get(j),_=k.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(x.allOf=x.allOf??[],x.allOf.push(_)):Object.assign(x,_),Object.assign(x,N),p._zod.parent===j)for(const E in x)E==="$ref"||E==="allOf"||E in N||delete x[E];if(_.$ref&&k.def)for(const E in x)E==="$ref"||E==="allOf"||E in k.def&&JSON.stringify(x[E])===JSON.stringify(k.def[E])&&delete x[E]}const y=p._zod.parent;if(y&&y!==j){i(y);const k=e.seen.get(y);if(k!=null&&k.schema.$ref&&(x.$ref=k.schema.$ref,k.def))for(const _ in x)_==="$ref"||_==="allOf"||_ in k.def&&JSON.stringify(x[_])===JSON.stringify(k.def[_])&&delete x[_]}e.override({zodSchema:p,jsonSchema:x,path:g.path??[]})};for(const p of[...e.seen.entries()].reverse())i(p[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,(u=e.external)!=null&&u.uri){const p=(d=e.external.registry.get(t))==null?void 0:d.id;if(!p)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(p)}Object.assign(r,s.def??s.schema);const o=(h=e.metadataRegistry.get(t))==null?void 0:h.id;o!==void 0&&r.id===o&&delete r.id;const l=((m=e.external)==null?void 0:m.defs)??{};for(const p of e.seen.entries()){const g=p[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,l[g.defId]=g.def)}e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?r.$defs=l:r.definitions=l);try{const p=JSON.parse(JSON.stringify(r));return Object.defineProperty(p,"~standard",{value:{...t["~standard"],jsonSchema:{input:$d(t,"input",e.processors),output:$d(t,"output",e.processors)}},enumerable:!1,writable:!1}),p}catch{throw new Error("Error converting schema to JSON.")}}function hs(e,t){const s=t??{seen:new Set};if(s.seen.has(e))return!1;s.seen.add(e);const i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return hs(i.element,s);if(i.type==="set")return hs(i.valueType,s);if(i.type==="lazy")return hs(i.getter(),s);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return hs(i.innerType,s);if(i.type==="intersection")return hs(i.left,s)||hs(i.right,s);if(i.type==="record"||i.type==="map")return hs(i.keyType,s)||hs(i.valueType,s);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:hs(i.in,s)||hs(i.out,s);if(i.type==="object"){for(const r in i.shape)if(hs(i.shape[r],s))return!0;return!1}if(i.type==="union"){for(const r of i.options)if(hs(r,s))return!0;return!1}if(i.type==="tuple"){for(const r of i.items)if(hs(r,s))return!0;return!!(i.rest&&hs(i.rest,s))}return!1}const lT=(e,t={})=>s=>{const i=EN({...s,processors:t});return Sn(e,i),CN(i,e),AN(i,e)},$d=(e,t,s={})=>i=>{const{libraryOptions:r,target:o}=i??{},l=EN({...r??{},target:o,io:t,processors:s});return Sn(e,l),CN(l,e),AN(l,e)},cT={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},uT=(e,t,s,i)=>{const r=s;r.type="string";const{minimum:o,maximum:l,format:u,patterns:d,contentEncoding:h}=e._zod.bag;if(typeof o=="number"&&(r.minLength=o),typeof l=="number"&&(r.maxLength=l),u&&(r.format=cT[u]??u,r.format===""&&delete r.format,u==="time"&&delete r.format),h&&(r.contentEncoding=h),d&&d.size>0){const m=[...d];m.length===1?r.pattern=m[0].source:m.length>1&&(r.allOf=[...m.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},dT=(e,t,s,i)=>{const r=s,{minimum:o,maximum:l,format:u,multipleOf:d,exclusiveMaximum:h,exclusiveMinimum:m}=e._zod.bag;typeof u=="string"&&u.includes("int")?r.type="integer":r.type="number";const p=typeof m=="number"&&m>=(o??Number.NEGATIVE_INFINITY),g=typeof h=="number"&&h<=(l??Number.POSITIVE_INFINITY),x=t.target==="draft-04"||t.target==="openapi-3.0";p?x?(r.minimum=m,r.exclusiveMinimum=!0):r.exclusiveMinimum=m:typeof o=="number"&&(r.minimum=o),g?x?(r.maximum=h,r.exclusiveMaximum=!0):r.exclusiveMaximum=h:typeof l=="number"&&(r.maximum=l),typeof d=="number"&&(r.multipleOf=d)},hT=(e,t,s,i)=>{s.type="boolean"},mT=(e,t,s,i)=>{t.target==="openapi-3.0"?(s.type="string",s.nullable=!0,s.enum=[null]):s.type="null"},fT=(e,t,s,i)=>{s.not={}},pT=(e,t,s,i)=>{},gT=(e,t,s,i)=>{const r=e._zod.def,o=rN(r.entries);o.every(l=>typeof l=="number")&&(s.type="number"),o.every(l=>typeof l=="string")&&(s.type="string"),s.enum=o},xT=(e,t,s,i)=>{const r=e._zod.def,o=[];for(const l of r.values)if(l===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof l=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(l))}else o.push(l);if(o.length!==0)if(o.length===1){const l=o[0];s.type=l===null?"null":typeof l,t.target==="draft-04"||t.target==="openapi-3.0"?s.enum=[l]:s.const=l}else o.every(l=>typeof l=="number")&&(s.type="number"),o.every(l=>typeof l=="string")&&(s.type="string"),o.every(l=>typeof l=="boolean")&&(s.type="boolean"),o.every(l=>l===null)&&(s.type="null"),s.enum=o},vT=(e,t,s,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},yT=(e,t,s,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},bT=(e,t,s,i)=>{const r=s,o=e._zod.def,{minimum:l,maximum:u}=e._zod.bag;typeof l=="number"&&(r.minItems=l),typeof u=="number"&&(r.maxItems=u),r.type="array",r.items=Sn(o.element,t,{...i,path:[...i.path,"items"]})},kT=(e,t,s,i)=>{var h;const r=s,o=e._zod.def;r.type="object",r.properties={};const l=o.shape;for(const m in l)r.properties[m]=Sn(l[m],t,{...i,path:[...i.path,"properties",m]});const u=new Set(Object.keys(l)),d=new Set([...u].filter(m=>{const p=o.shape[m]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));d.size>0&&(r.required=Array.from(d)),((h=o.catchall)==null?void 0:h._zod.def.type)==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=Sn(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},jT=(e,t,s,i)=>{const r=e._zod.def,o=r.inclusive===!1,l=r.options.map((u,d)=>Sn(u,t,{...i,path:[...i.path,o?"oneOf":"anyOf",d]}));o?s.oneOf=l:s.anyOf=l},NT=(e,t,s,i)=>{const r=e._zod.def,o=Sn(r.left,t,{...i,path:[...i.path,"allOf",0]}),l=Sn(r.right,t,{...i,path:[...i.path,"allOf",1]}),u=h=>"allOf"in h&&Object.keys(h).length===1,d=[...u(o)?o.allOf:[o],...u(l)?l.allOf:[l]];s.allOf=d},wT=(e,t,s,i)=>{const r=s,o=e._zod.def;r.type="object";const l=o.keyType,u=l._zod.bag,d=u==null?void 0:u.patterns;if(o.mode==="loose"&&d&&d.size>0){const m=Sn(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(const p of d)r.patternProperties[p.source]=m}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=Sn(o.keyType,t,{...i,path:[...i.path,"propertyNames"]})),r.additionalProperties=Sn(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]});const h=l._zod.values;if(h){const m=[...h].filter(p=>typeof p=="string"||typeof p=="number");m.length>0&&(r.required=m)}},ST=(e,t,s,i)=>{const r=e._zod.def,o=Sn(r.innerType,t,i),l=t.seen.get(e);t.target==="openapi-3.0"?(l.ref=r.innerType,s.nullable=!0):s.anyOf=[o,{type:"null"}]},_T=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType},ET=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,s.default=JSON.parse(JSON.stringify(r.defaultValue))},CT=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,t.io==="input"&&(s._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},AT=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType;let l;try{l=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}s.default=l},$T=(e,t,s,i)=>{const r=e._zod.def,o=r.in._zod.traits.has("$ZodTransform"),l=t.io==="input"?o?r.out:r.in:r.out;Sn(l,t,i);const u=t.seen.get(e);u.ref=l},IT=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,s.readOnly=!0},$N=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType},TT=je("ZodISODateTime",(e,t)=>{I$.init(e,t),dn.init(e,t)});function MT(e){return LI(TT,e)}const RT=je("ZodISODate",(e,t)=>{T$.init(e,t),dn.init(e,t)});function OT(e){return zI(RT,e)}const PT=je("ZodISOTime",(e,t)=>{M$.init(e,t),dn.init(e,t)});function LT(e){return DI(PT,e)}const zT=je("ZodISODuration",(e,t)=>{R$.init(e,t),dn.init(e,t)});function DT(e){return FI(zT,e)}const FT=(e,t)=>{cN.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:s=>jA(e,s)},flatten:{value:s=>kA(e,s)},addIssue:{value:s=>{e.issues.push(s),e.message=JSON.stringify(e.issues,yp,2)}},addIssues:{value:s=>{e.issues.push(...s),e.message=JSON.stringify(e.issues,yp,2)}},isEmpty:{get(){return e.issues.length===0}}})},ci=je("ZodError",FT,{Parent:Error}),UT=Og(ci),BT=Pg(ci),HT=nh(ci),ZT=sh(ci),WT=SA(ci),VT=_A(ci),qT=EA(ci),GT=CA(ci),KT=AA(ci),YT=$A(ci),XT=IA(ci),QT=TA(ci),Iy=new WeakMap;function Dc(e,t,s){const i=Object.getPrototypeOf(e);let r=Iy.get(i);if(r||(r=new Set,Iy.set(i,r)),!r.has(t)){r.add(t);for(const o in s){const l=s[o];Object.defineProperty(i,o,{configurable:!0,enumerable:!1,get(){const u=l.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 sn=je("ZodType",(e,t)=>(tn.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:$d(e,"input"),output:$d(e,"output")}}),e.toJSONSchema=lT(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(s,i)=>UT(e,s,i,{callee:e.parse}),e.safeParse=(s,i)=>HT(e,s,i),e.parseAsync=async(s,i)=>BT(e,s,i,{callee:e.parseAsync}),e.safeParseAsync=async(s,i)=>ZT(e,s,i),e.spa=e.safeParseAsync,e.encode=(s,i)=>WT(e,s,i),e.decode=(s,i)=>VT(e,s,i),e.encodeAsync=async(s,i)=>qT(e,s,i),e.decodeAsync=async(s,i)=>GT(e,s,i),e.safeEncode=(s,i)=>KT(e,s,i),e.safeDecode=(s,i)=>YT(e,s,i),e.safeEncodeAsync=async(s,i)=>XT(e,s,i),e.safeDecodeAsync=async(s,i)=>QT(e,s,i),Dc(e,"ZodType",{check(...s){const i=this.def;return this.clone(sa(i,{checks:[...i.checks??[],...s.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...s){return this.check(...s)},clone(s,i){return ia(this,s,i)},brand(){return this},register(s,i){return s.add(this,i),this},refine(s,i){return this.check(WM(s,i))},superRefine(s,i){return this.check(VM(s,i))},overwrite(s){return this.check(il(s))},optional(){return Oy(this)},exactOptional(){return TM(this)},nullable(){return Py(this)},nullish(){return Oy(Py(this))},nonoptional(s){return zM(this,s)},array(){return he(this)},or(s){return Wo([this,s])},and(s){return EM(this,s)},transform(s){return Ly(this,$M(s))},default(s){return OM(this,s)},prefault(s){return LM(this,s)},catch(s){return FM(this,s)},pipe(s){return Ly(this,s)},readonly(){return HM(this)},describe(s){const i=this.clone();return Kl.add(i,{description:s}),i},meta(...s){if(s.length===0)return Kl.get(this);const i=this.clone();return Kl.add(i,s[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(s){return s(this)}}),Object.defineProperty(e,"description",{get(){var s;return(s=Kl.get(e))==null?void 0:s.description},configurable:!0}),e)),IN=je("_ZodString",(e,t)=>{Lg.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(i,r,o)=>uT(e,i,r);const s=e._zod.bag;e.format=s.format??null,e.minLength=s.minimum??null,e.maxLength=s.maximum??null,Dc(e,"_ZodString",{regex(...i){return this.check(qI(...i))},includes(...i){return this.check(YI(...i))},startsWith(...i){return this.check(XI(...i))},endsWith(...i){return this.check(QI(...i))},min(...i){return this.check(Ad(...i))},max(...i){return this.check(SN(...i))},length(...i){return this.check(_N(...i))},nonempty(...i){return this.check(Ad(1,...i))},lowercase(i){return this.check(GI(i))},uppercase(i){return this.check(KI(i))},trim(){return this.check(eT())},normalize(...i){return this.check(JI(...i))},toLowerCase(){return this.check(tT())},toUpperCase(){return this.check(nT())},slugify(){return this.check(sT())}})}),JT=je("ZodString",(e,t)=>{Lg.init(e,t),IN.init(e,t),e.email=s=>e.check(xI(eM,s)),e.url=s=>e.check(wN(TN,s)),e.jwt=s=>e.check(PI(pM,s)),e.emoji=s=>e.check(jI(tM,s)),e.guid=s=>e.check(Ey(Ty,s)),e.uuid=s=>e.check(vI(Yu,s)),e.uuidv4=s=>e.check(yI(Yu,s)),e.uuidv6=s=>e.check(bI(Yu,s)),e.uuidv7=s=>e.check(kI(Yu,s)),e.nanoid=s=>e.check(NI(nM,s)),e.guid=s=>e.check(Ey(Ty,s)),e.cuid=s=>e.check(wI(sM,s)),e.cuid2=s=>e.check(SI(iM,s)),e.ulid=s=>e.check(_I(rM,s)),e.base64=s=>e.check(MI(hM,s)),e.base64url=s=>e.check(RI(mM,s)),e.xid=s=>e.check(EI(aM,s)),e.ksuid=s=>e.check(CI(oM,s)),e.ipv4=s=>e.check(AI(lM,s)),e.ipv6=s=>e.check($I(cM,s)),e.cidrv4=s=>e.check(II(uM,s)),e.cidrv6=s=>e.check(TI(dM,s)),e.e164=s=>e.check(OI(fM,s)),e.datetime=s=>e.check(MT(s)),e.date=s=>e.check(OT(s)),e.time=s=>e.check(LT(s)),e.duration=s=>e.check(DT(s))});function w(e){return gI(JT,e)}const dn=je("ZodStringFormat",(e,t)=>{nn.init(e,t),IN.init(e,t)}),eM=je("ZodEmail",(e,t)=>{j$.init(e,t),dn.init(e,t)}),Ty=je("ZodGUID",(e,t)=>{b$.init(e,t),dn.init(e,t)}),Yu=je("ZodUUID",(e,t)=>{k$.init(e,t),dn.init(e,t)}),TN=je("ZodURL",(e,t)=>{N$.init(e,t),dn.init(e,t)});function Id(e){return wN(TN,e)}const tM=je("ZodEmoji",(e,t)=>{w$.init(e,t),dn.init(e,t)}),nM=je("ZodNanoID",(e,t)=>{S$.init(e,t),dn.init(e,t)}),sM=je("ZodCUID",(e,t)=>{_$.init(e,t),dn.init(e,t)}),iM=je("ZodCUID2",(e,t)=>{E$.init(e,t),dn.init(e,t)}),rM=je("ZodULID",(e,t)=>{C$.init(e,t),dn.init(e,t)}),aM=je("ZodXID",(e,t)=>{A$.init(e,t),dn.init(e,t)}),oM=je("ZodKSUID",(e,t)=>{$$.init(e,t),dn.init(e,t)}),lM=je("ZodIPv4",(e,t)=>{O$.init(e,t),dn.init(e,t)}),cM=je("ZodIPv6",(e,t)=>{P$.init(e,t),dn.init(e,t)}),uM=je("ZodCIDRv4",(e,t)=>{L$.init(e,t),dn.init(e,t)}),dM=je("ZodCIDRv6",(e,t)=>{z$.init(e,t),dn.init(e,t)}),hM=je("ZodBase64",(e,t)=>{D$.init(e,t),dn.init(e,t)}),mM=je("ZodBase64URL",(e,t)=>{U$.init(e,t),dn.init(e,t)}),fM=je("ZodE164",(e,t)=>{B$.init(e,t),dn.init(e,t)}),pM=je("ZodJWT",(e,t)=>{Z$.init(e,t),dn.init(e,t)}),MN=je("ZodNumber",(e,t)=>{yN.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(i,r,o)=>dT(e,i,r),Dc(e,"ZodNumber",{gt(i,r){return this.check(Ay(i,r))},gte(i,r){return this.check(af(i,r))},min(i,r){return this.check(af(i,r))},lt(i,r){return this.check(Cy(i,r))},lte(i,r){return this.check(rf(i,r))},max(i,r){return this.check(rf(i,r))},int(i){return this.check(My(i))},safe(i){return this.check(My(i))},positive(i){return this.check(Ay(0,i))},nonnegative(i){return this.check(af(0,i))},negative(i){return this.check(Cy(0,i))},nonpositive(i){return this.check(rf(0,i))},multipleOf(i,r){return this.check($y(i,r))},step(i,r){return this.check($y(i,r))},finite(){return this}});const s=e._zod.bag;e.minValue=Math.max(s.minimum??Number.NEGATIVE_INFINITY,s.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(s.maximum??Number.POSITIVE_INFINITY,s.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(s.format??"").includes("int")||Number.isSafeInteger(s.multipleOf??.5),e.isFinite=!0,e.format=s.format??null});function oe(e){return UI(MN,e)}const gM=je("ZodNumberFormat",(e,t)=>{W$.init(e,t),MN.init(e,t)});function My(e){return BI(gM,e)}const xM=je("ZodBoolean",(e,t)=>{V$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>hT(e,s,i)});function ve(e){return HI(xM,e)}const vM=je("ZodNull",(e,t)=>{q$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>mT(e,s,i)});function yM(e){return ZI(vM,e)}const bM=je("ZodUnknown",(e,t)=>{G$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>pT()});function kp(){return WI(bM)}const kM=je("ZodNever",(e,t)=>{K$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>fT(e,s,i)});function jM(e){return VI(kM,e)}const NM=je("ZodArray",(e,t)=>{Y$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>bT(e,s,i,r),e.element=t.element,Dc(e,"ZodArray",{min(s,i){return this.check(Ad(s,i))},nonempty(s){return this.check(Ad(1,s))},max(s,i){return this.check(SN(s,i))},length(s,i){return this.check(_N(s,i))},unwrap(){return this.element}})});function he(e,t){return iT(NM,e,t)}const wM=je("ZodObject",(e,t)=>{Q$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>kT(e,s,i,r),Lt(e,"shape",()=>t.shape),Dc(e,"ZodObject",{keyof(){return Oe(Object.keys(this._zod.def.shape))},catchall(s){return this.clone({...this._zod.def,catchall:s})},passthrough(){return this.clone({...this._zod.def,catchall:kp()})},loose(){return this.clone({...this._zod.def,catchall:kp()})},strict(){return this.clone({...this._zod.def,catchall:jM()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(s){return pA(this,s)},safeExtend(s){return gA(this,s)},merge(s){return xA(this,s)},pick(s){return mA(this,s)},omit(s){return fA(this,s)},partial(...s){return vA(ON,this,s[0])},required(...s){return yA(PN,this,s[0])}})});function T(e,t){const s={type:"object",shape:e??{},...et(t)};return new wM(s)}const RN=je("ZodUnion",(e,t)=>{jN.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>jT(e,s,i,r),e.options=t.options});function Wo(e,t){return new RN({type:"union",options:e,...et(t)})}const SM=je("ZodDiscriminatedUnion",(e,t)=>{RN.init(e,t),J$.init(e,t)});function ra(e,t,s){return new SM({type:"union",options:t,discriminator:e,...et(s)})}const _M=je("ZodIntersection",(e,t)=>{eI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>NT(e,s,i,r)});function EM(e,t){return new _M({type:"intersection",left:e,right:t})}const Ry=je("ZodRecord",(e,t)=>{tI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>wT(e,s,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ws(e,t,s){return!t||!t._zod?new Ry({type:"record",keyType:w(),valueType:e,...et(t)}):new Ry({type:"record",keyType:e,valueType:t,...et(s)})}const jp=je("ZodEnum",(e,t)=>{nI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(i,r,o)=>gT(e,i,r),e.enum=t.entries,e.options=Object.values(t.entries);const s=new Set(Object.keys(t.entries));e.extract=(i,r)=>{const o={};for(const l of i)if(s.has(l))o[l]=t.entries[l];else throw new Error(`Key ${l} not found in enum`);return new jp({...t,checks:[],...et(r),entries:o})},e.exclude=(i,r)=>{const o={...t.entries};for(const l of i)if(s.has(l))delete o[l];else throw new Error(`Key ${l} not found in enum`);return new jp({...t,checks:[],...et(r),entries:o})}});function Oe(e,t){const s=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new jp({type:"enum",entries:s,...et(t)})}const CM=je("ZodLiteral",(e,t)=>{sI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>xT(e,s,i),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 ct(e,t){return new CM({type:"literal",values:Array.isArray(e)?e:[e],...et(t)})}const AM=je("ZodTransform",(e,t)=>{iI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>yT(e,s),e._zod.parse=(s,i)=>{if(i.direction==="backward")throw new iN(e.constructor.name);s.addIssue=o=>{if(typeof o=="string")s.issues.push(bc(o,s.value,t));else{const l=o;l.fatal&&(l.continue=!1),l.code??(l.code="custom"),l.input??(l.input=s.value),l.inst??(l.inst=e),s.issues.push(bc(l))}};const r=t.transform(s.value,s);return r instanceof Promise?r.then(o=>(s.value=o,s.fallback=!0,s)):(s.value=r,s.fallback=!0,s)}});function $M(e){return new AM({type:"transform",transform:e})}const ON=je("ZodOptional",(e,t)=>{NN.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>$N(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function Oy(e){return new ON({type:"optional",innerType:e})}const IM=je("ZodExactOptional",(e,t)=>{rI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>$N(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function TM(e){return new IM({type:"optional",innerType:e})}const MM=je("ZodNullable",(e,t)=>{aI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>ST(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function Py(e){return new MM({type:"nullable",innerType:e})}const RM=je("ZodDefault",(e,t)=>{oI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>ET(e,s,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function OM(e,t){return new RM({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():oN(t)}})}const PM=je("ZodPrefault",(e,t)=>{lI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>CT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function LM(e,t){return new PM({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():oN(t)}})}const PN=je("ZodNonOptional",(e,t)=>{cI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>_T(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function zM(e,t){return new PN({type:"nonoptional",innerType:e,...et(t)})}const DM=je("ZodCatch",(e,t)=>{uI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>AT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function FM(e,t){return new DM({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const UM=je("ZodPipe",(e,t)=>{dI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>$T(e,s,i,r),e.in=t.in,e.out=t.out});function Ly(e,t){return new UM({type:"pipe",in:e,out:t})}const BM=je("ZodReadonly",(e,t)=>{hI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>IT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function HM(e){return new BM({type:"readonly",innerType:e})}const ZM=je("ZodCustom",(e,t)=>{mI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>vT(e,s)});function WM(e,t={}){return rT(ZM,e,t)}function VM(e,t){return aT(e,t)}const of=ra("type",[T({type:ct("text"),text:w()}),T({type:ct("reasoning"),text:w()}),T({type:ct("image"),name:w().optional(),mediaType:w().optional(),width:oe().optional(),height:oe().optional(),attachmentId:w().optional(),bytes:oe().optional()}),T({type:ct("file"),name:w().optional(),size:oe().optional(),mediaType:w().optional()}),T({type:ct("tool-call"),callId:w(),name:w(),arguments:w()}),T({type:ct("other"),kind:w()})]),lf=T({inputTokens:oe(),outputTokens:oe(),totalTokens:oe().optional(),cacheReadTokens:oe().optional(),cacheWriteTokens:oe().optional(),reasoningTokens:oe().optional()}),zy=T({firstChunkAt:oe().optional(),firstTokenAt:oe().optional(),lastChunkAt:oe().optional(),tokenChunks:oe()}),Dy=T({message:w(),code:w().optional()}),qM=T({kind:w(),message:w().optional()}),Fy=T({provider:w(),providerName:w(),model:w(),modelName:w()}),GM=T({from:Fy,to:Fy,reason:w(),error:w(),code:w(),sub:ve().optional()}),KM="adg-model-fallback",YM=T({kind:w(),human:ve(),summary:w().optional(),fallback:GM.optional(),childId:w().optional()}),Fn={seq:oe(),time:oe()},Np=ra("type",[T({...Fn,type:ct("turn/start"),turn:oe()}),T({...Fn,type:ct("turn/end"),turn:oe(),reason:qM}),T({...Fn,type:ct("step/start"),turn:oe(),step:oe()}),T({...Fn,type:ct("step/end"),turn:oe(),step:oe()}),T({...Fn,type:ct("user/message"),messageId:w(),content:he(of),origin:YM,requestId:w().optional(),replacesHistory:ve().optional()}),T({...Fn,type:ct("system/message"),turn:oe(),step:oe(),text:w()}),T({...Fn,type:ct("assistant/message"),turn:oe(),step:oe(),messageId:w(),content:he(of),timing:zy,usage:lf.optional(),interrupted:ve().optional(),provider:w().optional(),model:w().optional()}),T({...Fn,type:ct("assistant/attempt"),usage:lf.optional(),turn:oe(),step:oe(),timing:zy,error:Dy.optional()}),T({...Fn,type:ct("tool/call"),turn:oe(),step:oe(),callId:w(),name:w(),arguments:w()}),T({...Fn,type:ct("tool/result"),turn:oe(),step:oe(),callId:w(),isError:ve(),content:he(of),error:Dy.optional()}),T({...Fn,type:ct("request/header"),provider:w().optional(),model:w().optional(),reasoningEffort:w().optional(),toolNames:he(w()),reason:w()}),T({...Fn,type:ct("compaction/start"),compactionId:w(),turn:oe().nullable()}),T({...Fn,type:ct("compaction/summary"),compactionId:w(),shadowedTokenCount:oe(),provider:w().optional(),model:w().optional(),usage:lf.optional()}),T({...Fn,type:ct("compaction/end"),compactionId:w(),turn:oe().nullable(),error:w().optional()}),T({...Fn,type:ct("approval/asked"),approvalId:w(),toolName:w(),callId:w().optional(),reason:w().optional()}),T({...Fn,type:ct("approval/decided"),approvalId:w(),outcome:w()}),T({...Fn,type:ct("session/title"),title:w()}),T({...Fn,type:ct("unknown"),upstreamType:w(),data:kp()})]),LN=ra("type",[T({type:ct("start"),attemptId:w(),turn:oe(),step:oe(),afterSeq:oe()}),T({type:ct("delta"),attemptId:w(),time:oe(),kind:Oe(["text","reasoning","tool-args"]),index:oe(),text:w(),callId:w().optional(),toolName:w().optional()}),T({type:ct("end"),attemptId:w(),outcome:Oe(["committed","abandoned"]),seq:oe().optional()})]),XM=T({attemptId:w(),turn:oe(),step:oe(),afterSeq:oe(),deltas:he(LN.options[1])}),QM=T({index:oe().int().min(0),name:w(),running:ve(),ready:ve(),adb:w().optional()}),JM=T({kind:Oe(["mumu"]),name:w(),manager:w(),version:w().optional(),instances:he(QM),error:w().optional()}),zN=T({mumuManager:w().optional(),instance:oe().int().min(0).max(63),manualAddress:w().regex(/^[\w.-]+:\d{1,5}$/).optional(),adbPath:w().optional(),autoStart:ve(),bootTimeoutSeconds:oe().int().min(30).max(900)});T({providers:he(JM),settings:zN,selection:T({label:w(),address:w().optional(),problem:w().optional()})});T({refresh:ve().optional()}),T({index:oe().int().min(0).optional()}),T({address:w(),label:w()}),T({index:oe().int().min(0).optional()}),T({}),zN.partial().extend({mumuManager:w().nullable().optional(),manualAddress:w().regex(/^[\w.-]+:\d{1,5}$/).nullable().optional(),adbPath:w().nullable().optional()});T({});const zg=Oe(["maafw-pi","cli","gui-config","generic-process","visual"]),_t=w().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/,"use lowercase letters, digits, dot, dash or underscore (max 64)"),ac=w().trim().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,"use owner/repo"),cf=w().trim().regex(/^[A-Za-z0-9_.-]{1,100}$/,"use the resource id, e.g. MAA or BGI"),eR=ra("kind",[T({kind:ct("github"),repo:w()}),T({kind:ct("mirrorchyan"),rid:w(),platform:ve(),os:ve().optional(),arch:ve().optional()}),T({kind:ct("local"),path:w()})]),tR=T({version:w(),dir:w(),installedAt:oe(),asset:T({name:w(),size:oe()}).optional(),current:ve()}),nR=Oe(["ok","missing","outdated","unknown","unsupported"]),sR=T({kind:w(),label:w(),required:w().optional(),status:nR,found:w().optional(),detail:w().optional(),fix:T({kind:Oe(["auto","installer","manual"]),description:w(),needsAdmin:ve()}).optional()}),iR=T({checkedAt:oe(),ok:ve(),items:he(sR)}),rR=T({executables:he(w()),markers:he(w()),family:zg.optional()}),Uy=Oe(["install","pack","known","user"]),aR=T({github:T({repo:w(),from:Uy}).optional(),mirrorchyan:T({rid:w(),from:Uy}).optional()}),oR=T({version:w(),from:w()}),lR=T({state:Oe(["running","done","failed"]),at:oe(),text:w().optional(),sessionId:w().optional()}),cR=T({id:w(),name:w(),source:eR,packId:w().optional(),family:zg.optional(),current:w().optional(),dir:w().optional(),versions:he(tR),env:iR.optional(),probe:rR.optional(),update:T({latest:w(),available:ve(),checkedAt:oe()}).optional(),channels:aR,known:w().optional(),localVersion:oR.optional(),undo:T({from:w().optional(),to:w(),at:oe()}).optional(),jobId:w().optional(),addedAt:oe(),summary:lR.optional(),packReview:T({from:w().optional(),to:w()}).optional(),optimize:T({runs:oe(),at:oe().optional(),due:Oe(["runs","updated"]).optional()}).optional()}),uR=T({id:w(),name:w(),description:w().optional(),repo:w().optional(),mirrorchyan:w().optional(),family:zg.optional(),builtin:ve(),installed:ve(),own:ve().optional(),error:w().optional()}),dR=T({packId:w(),name:w(),builtin:ve(),written:ve(),overview:w().optional(),tasks:he(T({id:w(),title:w(),description:w().optional(),utterances:he(w()),input:Oe(["desktop","window","adb","none"]),expectedDuration:w().optional(),params:he(T({name:w(),type:Oe(["string","integer","number","boolean"]),description:w().optional(),default:w().optional(),values:w().optional()}))})),setup:he(w()),checks:he(w()),features:he(T({title:w(),description:w().optional(),enable:w(),config:he(T({file:w(),key:w(),value:w()})),tasks:he(w())})),config:he(T({file:w(),about:w().optional(),keys:he(T({key:w(),meaning:w(),values:w().optional(),default:w().optional(),advice:w().optional()})),changes:he(T({key:w(),value:w(),note:w().optional(),when:w().optional(),tasks:he(w())}))})),troubleshooting:he(T({problem:w(),cause:w().optional(),fix:w()}))});T({rid:w(),version:w(),platform:ve(),os:ve().optional(),arch:ve().optional(),name:w().optional(),description:w().optional(),repo:w().optional()});const wp=T({rid:w(),name:w(),description:w(),repo:w().optional(),url:w().optional(),installed:ve(),known:ve()}),hR=T({id:w(),name:w(),repo:w().optional(),mirrorchyan:w().optional(),installed:ve()}),mR=T({name:w(),size:oe(),downloadUrl:w(),digest:w().optional()}),fR=T({tag:w(),name:w(),prerelease:ve(),publishedAt:w().optional(),url:w().optional(),assets:he(mR),suggestedAsset:w().optional(),notes:w().optional()}),pR=Oe(["queued","resolving","downloading","verifying","extracting","checking","running","done","failed","cancelled"]),gR=T({sessionId:w(),taskId:w().optional(),state:Oe(["running","failed"]),reason:w().optional()}),xR=T({scriptId:w(),name:w(),kind:Oe(["nsis","inno","kachina"]),version:w(),dir:w(),update:ve(),at:oe(),agent:gR.optional()}),vR=T({id:w(),kind:Oe(["install","update","env-fix"]),scriptId:w(),phase:pR,message:w().optional(),received:oe().optional(),total:oe().optional(),version:w().optional(),error:w().optional(),setup:T({kind:Oe(["nsis","inno","kachina"]),dir:w(),sessionId:w().optional()}).optional(),startedAt:oe(),endedAt:oe().optional()}),yR=Oe(["auto","ask","off"]),By=T({apiBase:Id({protocol:/^https?$/}),downloadMirror:w().trim().max(300),mirrorFallback:ve(),tokenRef:w().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),keepVersions:oe().int().min(1).max(10),includePrereleases:ve(),cdkRef:w().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),autoUpdate:yR});T({});const bR=T({name:w(),source:Oe(["pack","discovered"]),transport:Oe(["stdio","http","sse"]),target:w(),file:w().optional(),needsRunning:ve(),description:w().optional(),problem:w().optional(),trusted:ve(),connected:ve()}),kR=T({name:w(),description:w(),path:w(),problem:w().optional(),imported:T({name:w(),current:ve(),changed:ve()}).optional()});T({id:_t});T({scripts:he(cR),packs:he(uR),known:he(hR),setups:he(xR).default([]),toolsDir:w()}),T({guide:dR.nullable()}),T({icon:T({mediaType:w(),data:w()}).optional()}),T({query:w().trim().min(1).max(200)}),T({items:he(T({repo:w(),description:w().optional(),stars:oe(),packId:w().optional()}))}),T({repo:ac,limit:oe().int().min(1).max(30).optional()}),T({repo:w(),packId:w().optional(),releases:he(fR)}),T({repo:ac.optional(),mirrorchyan:cf.optional(),tag:w().min(1).max(200).optional(),asset:w().min(1).max(300).optional(),branch:w().min(1).max(200).optional(),id:_t.optional()}).refine(e=>e.repo===void 0!=(e.mirrorchyan===void 0),"give either repo or mirrorchyan"),T({jobId:w(),scriptId:w()}),T({current:w().optional(),latest:w(),available:ve()}),T({jobId:w().optional(),upToDate:ve()}),T({id:_t,repo:ac.nullable().optional(),mirrorchyan:cf.nullable().optional(),reset:he(Oe(["repo","mirrorchyan"])).optional()}),T({items:he(wp.extend({by:Oe(["repo","name"])})),from:Oe(["mirrorchyan","builtin"])}),T({rid:cf}),T({query:w().trim().max(100)}),T({items:he(wp),from:Oe(["mirrorchyan","builtin"]),fetchedAt:oe().optional()}),T({id:w(),decision:Oe(["check","keep"])}),T({sessionId:w().optional()}),T({id:_t,version:w().optional()}),T({dir:w()}),T({sessionId:w()}),T({path:w().trim().min(1).max(1e3),id:_t.optional(),name:w().trim().min(1).max(100).optional(),packId:_t.optional()}),T({id:_t,decision:Oe(["run","keep"])}),T({sessionId:w().optional()}),T({id:_t}),T({sessionId:w()}),T({id:_t,deleteFiles:ve().optional()}),T({id:w().min(1)}),T({servers:he(bR),usage:w().optional(),note:w().optional(),skills:he(kR)}),T({id:_t,server:w().min(1).max(32)}),T({ok:ve(),tools:he(T({name:w(),title:w().optional(),description:w().optional()})).optional(),server:T({name:w(),version:w()}).optional(),error:w().optional()}),T({id:_t,names:he(w().min(1).max(200)).max(50).optional()}),T({imported:he(T({skill:w(),name:w(),replaced:ve()})),skipped:he(T({skill:w(),reason:w()}))}),T({id:_t,kind:w().min(1).max(64)}),T({jobId:w()}),T({items:he(vR)}),T({jobId:w()}),By.extend({tokenConfigured:ve(),cdkConfigured:ve()}),T({ok:ve(),message:w(),expiresAt:oe().optional()}),By.partial();T({id:w().optional()});const jR=T({packId:w(),scriptId:w(),proposedAt:oe(),sessionId:w().optional(),summary:w(),docs:he(T({source:w(),used:w()})).optional(),noDocs:w().optional(),manifest:w(),skill:w(),current:T({manifest:w(),skill:w().optional(),builtin:ve()}).optional(),tasks:he(T({id:w(),title:w()}))}),NR=T({id:w(),at:oe().optional(),builtin:ve().optional(),tasks:he(T({id:w(),title:w()}))});T({packId:_t}),T({items:he(NR)}),T({packId:_t,version:w().min(1).max(64)}),T({}),T({scriptId:_t.optional()}),T({items:he(jR)}),T({packId:_t}),T({packId:w(),dir:w()}),T({packId:_t}),T({});T({packId:w().optional()});const wR=T({scriptId:w(),dir:w(),grantedAt:oe(),expiresAt:oe()});T({}),T({items:he(wR),blocked:oe()}),T({scriptId:_t,minutes:oe().int().min(1).max(240)}),T({scriptId:_t}),T({});T({}),T({toolName:w(),target:w(),sessionId:w().optional(),at:oe()});const SR=Oe(["error","warning","failed","stalled","overtime"]),_R=T({at:oe(),action:Oe(["reconnect-adb","restart","stop","screenshot","notify","resolve","intervene"]),by:Oe(["rule","user","agent"]),ok:ve(),detail:w()}),ER=T({id:w(),runId:w(),scriptId:w(),scriptName:w(),taskId:w(),taskTitle:w(),kind:SR,severity:Oe(["warning","error"]),tag:w(),title:w(),detail:w(),lines:he(w()),status:Oe(["open","resolved"]),resolution:w().optional(),createdAt:oe(),updatedAt:oe(),steps:he(_R),screenshot:ve()}),CR=T({seconds:oe().int().min(5).max(24*3600),by:Oe(["learned","agent","user"]),note:w().max(300).optional(),samples:he(oe().min(0)).max(10).default([]),at:oe()}),AR=T({defaultStallSeconds:oe().int().min(0).max(24*3600),scriptStall:Ws(w(),CR),notifyWarnings:ve(),screenshot:ve(),intervene:Oe(["off","diagnose","act"]),interventionsPerDay:oe().int().min(0).max(200)});T({status:Oe(["open","all"]).optional(),runId:w().optional(),limit:oe().int().min(1).max(500).optional()}),T({items:he(ER)}),T({incidentId:w(),action:Oe(["stop","retry","resolve","resume"])}),T({incidentId:w()}),T({mime:ct("image/png"),data:w()}),T({}),AR.partial();const $R="ADG_FEISHU_APP_SECRET",IR="ADG_QQBOT_APP_SECRET",Sp=T({id:w(),label:w(),ok:ve().nullable(),detail:w().optional()}),TR=T({id:w(),name:w(),state:Oe(["off","connecting","ready","error"]),detail:w().optional(),recipients:oe().int().min(0),checks:he(Sp)}),MR=T({openId:w().min(1),name:w().optional(),addedAt:oe()}),RR=T({enabled:ve(),appId:w().optional(),domain:Oe(["feishu","lark"]),allowedUsers:he(MR),chatId:w().optional(),otherApprovals:ve()}),OR=T({openId:w(),at:oe(),text:w()});T({settings:RR,secretConfigured:ve(),pending:he(OR)});const PR=T({openId:w().min(1),name:w().optional(),addedAt:oe()}),LR=T({enabled:ve(),appId:w().optional(),allowedUsers:he(PR)}),zR=T({openId:w(),at:oe(),text:w()});T({settings:LR,secretConfigured:ve(),pending:he(zR)});const DN=T({id:w(),title:w(),text:w(),severity:Oe(["info","success","warning","error"]),at:oe(),actions:he(T({id:w(),label:w(),style:Oe(["primary","danger","default"]).optional()})),channels:he(w()),image:ve().optional(),done:w().optional(),acted:T({by:w(),label:w(),result:w(),at:oe()}).optional()});T({}),T({channels:he(TR)}),T({}),T({items:he(T({sessionId:w(),channel:w(),user:w()}))}),T({}),T({items:he(DN)}),T({noticeId:w(),actionId:w()}),T({result:w()}),T({channel:w().optional()}),T({sent:he(w()),failed:he(T({channel:w(),error:w()}))}),T({}),T({enabled:ve().optional(),appId:w().trim().regex(/^cli_[0-9a-fA-F]{16}$/,"App ID 是 cli_ 加 16 位字母数字,在「凭证与基础信息」里复制").nullable().optional(),domain:Oe(["feishu","lark"]).optional(),chatId:w().trim().regex(/^oc_[A-Za-z0-9]+$/,"群 ID 以 oc_ 开头").nullable().optional(),otherApprovals:ve().optional()}),T({openId:w().trim().regex(/^ou_[A-Za-z0-9]+$/,"open_id 以 ou_ 开头"),name:w().max(40).optional()}),T({openId:w()}),T({}),T({checks:he(Sp)}),T({}),T({enabled:ve().optional(),appId:w().trim().regex(/^\d{6,20}$/,"AppID 是一串数字,在 QQ 开放平台「开发设置」里复制").nullable().optional()}),T({openId:w().trim().regex(/^[0-9A-Za-z_-]{8,64}$/,"user_openid 是一串字母数字(机器人回复你的那条消息里有)"),name:w().max(40).optional()}),T({openId:w()}),T({}),T({checks:he(Sp)});T({}),T({item:DN});const Ia=w().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,"小写字母、数字和短横线").max(64),kc=w().regex(/^[A-Za-z0-9_-]{1,40}$/),Dg=w().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"时间写成 HH:MM,例如 04:30"),FN=T({retries:oe().int().min(0).max(5).default(0),then:Oe(["continue","stop"]).default("continue")}),Na={id:kc,title:w().max(60).optional(),position:T({x:oe(),y:oe()}).optional(),onFailure:FN.optional(),waitForAll:ve().optional()},DR=ra("kind",[T({...Na,kind:ct("script-task"),scriptId:_t,taskId:w().min(1).max(64),params:Ws(w(),Wo([w(),oe(),ve()])).default({}),profile:w().min(1).max(64).optional()}),T({...Na,kind:ct("agent"),prompt:w().min(1).max(4e3)}),T({...Na,kind:ct("wait"),minutes:oe().int().min(1).max(1440).optional(),until:Dg.optional()}).refine(e=>e.minutes===void 0!=(e.until===void 0),"等待节点写分钟数或时间其中一个"),T({...Na,kind:ct("notify"),text:w().min(1).max(2e3)}),T({...Na,kind:ct("gate"),text:w().min(1).max(2e3)}),T({...Na,kind:ct("start")}),T({...Na,kind:ct("end")})]);function Wi(e){return e.kind==="start"||e.kind==="end"}function FR(e){const t=e.nodes.some(g=>g.kind==="start"),s=e.nodes.some(g=>g.kind==="end");if(t&&s)return e;const i=e.nodes.filter(g=>!Wi(g)),r=new Set(e.nodes.map(g=>g.id)),o=g=>{let x=g;for(let N=2;r.has(x);N++)x=`${g}${N}`;return r.add(x),x},l=i.filter(g=>g.position!==void 0).map(g=>g.position),u=Math.min(...l.map(g=>g.x)),d=Math.max(...l.map(g=>g.x)),h=l.length===0?40:Math.round(l.reduce((g,x)=>g+x.y,0)/l.length),m=[...e.nodes],p=[...e.edges];if(!t){const g=o("start");m.unshift({id:g,kind:"start",...l.length===0?{}:{position:{x:u-240,y:h}}});for(const x of i)e.edges.some(N=>N.to===x.id)||p.push({from:g,to:x.id,when:"success"})}if(!s){const g=o("end");m.push({id:g,kind:"end",...l.length===0?{}:{position:{x:d+300,y:h}}});for(const x of i)e.edges.some(N=>N.from===x.id)||p.push({from:x.id,to:g,when:"always"})}return{...e,nodes:m,edges:p}}const UR=T({from:kc,to:kc,when:Oe(["success","failure","always"]).default("success")}),Fg=T({enabled:ve().default(!1),times:he(Dg).max(12).default([]),days:he(oe().int().min(0).max(6)).max(7).default([]),catchUpMinutes:oe().int().min(0).max(720).default(10),after:Ia.optional()}),BR=["日","一","二","三","四","五","六"],HR=[1,2,3,4,5,6,0];function Ug(e){return e.enabled?e.times.length===0?e.after===void 0?"没有设时间":`「${e.after}」跑完后`:`${e.days.length===0||e.days.length===7?"每天":`每周${HR.filter(s=>e.days.includes(s)).map(s=>BR[s]).join("、")}`} ${[...e.times].sort().join("、")}`:"已暂停"}T({kind:Oe(["task","reminder"]),id:w().optional(),by:w(),agent:w(),title:w(),when:w(),changed:ve()});const UN=Oe(["none","sleep","hibernate","shutdown"]),uf=T({id:Ia,name:w().min(1).max(60),description:w().max(500).optional(),nodes:he(DR).max(60),edges:he(UR).max(200).default([]),onFailure:FN.default({retries:0,then:"continue"}),schedule:Fg.default({enabled:!1,times:[],days:[],catchUpMinutes:10}),stopEmulatorAfter:ve().default(!1),closeGameAfter:ve().default(!1),powerAfter:UN.default("none"),draft:ve().optional(),createdAt:oe().optional(),updatedAt:oe().optional()}),ZR=T({level:Oe(["error","warning","info"]),nodeId:w().optional(),message:w()}),WR=T({ok:ve(),issues:he(ZR),serialized:he(T({a:w(),b:w(),resource:w()})),estimateMinutes:oe().optional()}),VR=Oe(["pending","waiting","running","succeeded","failed","skipped","cancelled"]),qR=T({state:VR,detail:w().optional(),repair:T({runId:w(),state:Oe(["succeeded","failed","cancelled"]),at:oe()}).optional(),runIds:he(w()),attempts:oe().int().min(0),startedAt:oe().optional(),endedAt:oe().optional()}),BN=T({kind:Oe(["manual","schedule","autostart","agent","after"]),detail:w().optional()}),HN=T({id:w(),pipelineId:w(),pipelineName:w(),trigger:BN,from:w().optional(),state:Oe(["running","succeeded","failed","cancelled"]),stopping:w().optional(),nodes:Ws(w(),qR),startedAt:oe(),endedAt:oe().optional(),outcome:w().optional()}),GR=T({id:w(),name:w(),description:w().optional(),nodes:oe(),draft:ve(),schedule:Fg,updatedAt:oe().optional(),lastRun:HN.pick({id:!0,state:!0,startedAt:!0,endedAt:!0}).optional()}),Yl=w().regex(/^task-[a-z0-9]{4,24}$/),Hy=T({id:Yl,agent:w().min(1).max(64),title:w().trim().min(1).max(60),prompt:w().trim().min(1).max(4e3),schedule:Fg,createdAt:oe().optional(),updatedAt:oe().optional()}),Zy=T({id:w(),taskId:w(),trigger:BN,state:Oe(["running","done","failed"]),outcome:w().optional(),startedAt:oe(),endedAt:oe().optional()}),ZN=T({autostart:ve(),autostartPipelines:he(Ia),autostartDelaySeconds:oe().int().min(0).max(1800),skipIfRanToday:ve(),firstStartOnly:ve().default(!1),wakeToRun:ve().default(!1),powerCountdownSeconds:oe().int().min(10).max(600).default(60)}),WN={agent:w().optional()},KR=T({pipelineId:w(),pipelineName:w(),...WN,slot:w(),at:oe(),outcome:Oe(["fired","missed","skipped","failed"]),detail:w().optional()}),YR=T({awake:ve(),pending:T({action:UN.exclude(["none"]),pipelineName:w(),at:oe().optional()}).optional()});T({settings:ZN,autostart:T({available:ve(),registered:ve(),detail:w().optional()}),autostarted:ve(),wake:T({available:ve(),registered:ve(),next:oe().optional(),detail:w().optional()}),power:YR,upcoming:he(T({pipelineId:w(),pipelineName:w(),at:oe(),...WN})),history:he(KR)});T({}),T({items:he(GR)}),T({id:Ia}),T({pipeline:uf}),T({pipeline:uf,check:WR}),T({id:Ia}),T({}),T({pipeline:uf}),T({id:Ia,from:kc.optional()}),T({runId:w()}),T({}),T({pipelineId:Ia.optional(),limit:oe().int().min(1).max(100).optional()}),T({items:he(HN)}),T({runId:w(),nodeId:kc,decision:Oe(["continue","stop"])}),T({}),T({}),ZN.partial(),T({}),T({}),T({agent:w().optional()}),T({items:he(Hy.extend({lastRun:Zy.optional()}))}),T({task:Hy.extend({id:Yl.optional()})}),T({id:Yl}),T({}),T({id:Yl}),T({id:Yl}),T({items:he(Zy)});T({}),T({}),T({});const XR=Oe(["running","resolved","retried","gave-up","taken-over","timeout","failed"]),QR=T({id:w(),incidentId:w().optional(),runId:w().optional(),title:w(),mode:Oe(["diagnose","act"]),state:XR,sessionId:w().optional(),paused:ve(),summary:w().optional(),startedAt:oe(),endedAt:oe().optional()});T({limit:oe().int().min(1).max(100).optional()}),T({items:he(QR)}),T({id:w()}),T({id:w(),then:Oe(["resume","restart","stop"])});const VN=T({id:w(),game:w(),title:w(),kind:Oe(["update","notice","news"]),publishedAt:oe().optional(),version:w().optional(),summary:w().optional(),url:w().optional(),cover:w().optional(),lasting:ve().optional(),source:T({id:w(),name:w()}),at:oe()}),JR=he(ra("type",[T({type:ct("text"),text:w()}),T({type:ct("image"),url:Id({protocol:/^https$/})})]));VN.extend({article:JR.optional()});const Wy=T({id:w(),game:w(),name:w(),startsAt:oe().optional(),endsAt:oe().optional(),shopEndsAt:oe().optional(),url:w().optional(),kind:w().optional(),description:w().optional(),cover:w().optional(),site:T({source:w(),name:w(),at:oe()}).optional(),sources:he(T({id:w(),name:w(),at:oe(),web:ve(),url:w().optional(),startsAt:oe().optional(),endsAt:oe().optional(),shopEndsAt:oe().optional(),cover:w().optional()})).optional(),chosen:w().optional(),shown:T({cover:w().optional(),startsAt:w().optional(),endsAt:w().optional()}).optional(),screen:T({at:oe(),remaining:w().optional(),endsAt:oe().optional(),evidence:ve(),image:w().optional(),sessionId:w().optional()}).optional(),todo:he(w()),done:he(w()),progress:w().optional(),finished:T({at:oe()}).optional(),mismatch:w().optional(),own:T({at:oe(),fields:he(Oe(["name","startsAt","endsAt","kind","description","url","cover"])),startsAt:oe().optional(),endsAt:oe().optional(),cover:w().optional()}).optional()}),$o="@own",oc="@screen",e2=112e5,Vy=T({mediaType:Oe(["image/png","image/jpeg","image/gif","image/webp","image/avif"]),data:w().min(1).max(e2).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix")}),t2=/^own:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,n2=/^shot:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,s2=T({id:w(),name:w(),homepage:w().optional(),auto:ve(),added:ve().optional()}),qy=T({state:Oe(["queued","running","done","partial","failed","cancelled"]),at:oe(),sessionId:w().optional(),taskId:w().optional(),scope:w().optional(),remainingUrls:he(w()).optional(),summary:w().optional()}),i2=T({id:w(),name:w(),aliases:he(w()),scripts:he(w()),timezone:w(),screen:T({target:Oe(["emulator","window"]),window:w().optional()}).optional(),sources:he(s2),builtin:ve(),art:w().optional(),banner:w().optional(),followed:ve().optional(),sra:he(w()).optional(),own:ve().optional(),single:ve().optional(),version:T({name:w(),title:w().optional(),startsAt:oe().optional(),endsAt:oe().optional(),cover:w().optional(),source:w(),at:oe()}).optional(),pools:he(T({name:w(),type:w().optional(),startsAt:oe().optional(),endsAt:oe(),cover:w().optional(),up:he(w())})).optional(),refreshed:T({at:oe(),ok:ve(),count:oe(),detail:w().optional()}).optional(),reading:qy.optional(),webReading:qy.optional()}),Gy=T({report:T({enabled:ve(),at:Dg,games:he(w()),soonDays:oe().int().min(1).max(30),ai:ve()}),followed:he(w()),hidden:he(w()).optional()}),r2=T({lastSentAt:oe().optional(),lastDay:w().optional(),lastResult:w().optional(),lastText:w().optional(),next:oe().optional()});T({}),T({games:he(i2),activities:he(Wy),notices:he(VN).default([]),settings:Gy,report:r2}),T({game:w(),noticeId:w()}),T({game:w().optional()}),T({results:he(T({game:w(),ok:ve(),count:oe(),notices:oe().optional(),detail:w().optional()}))}),T({game:w(),how:Oe(["screen","web"]).optional(),source:w().optional()}),T({sessionId:w()}),T({taskId:w()}),T({cancelled:ve()}),T({}),T({title:w(),text:w()}),T({}),T({channels:he(w()),text:w()}),T({report:Gy.shape.report.partial().optional()}),T({activityId:w()}),T({mediaType:w(),data:w()}),T({url:w().refine(e=>t2.test(e)||n2.test(e)||/^https?:\/\/\S+$/.test(e),"不是图片地址")}),T({mediaType:w(),data:w()}),T({game:w().min(1)}),T({icon:T({mediaType:w(),data:w()}).optional()}),T({name:w().trim().min(1).max(60)}),T({game:w()}),T({game:w()}),T({}),T({game:w()}),T({sessionId:w()}),T({game:w()}),T({items:he(wp),from:Oe(["mirrorchyan","builtin"])}),T({game:w(),url:w().url().refine(e=>/^https?:\/\//.test(e),"只能是 http 或 https 网址"),name:w().max(30).optional()}),T({source:w(),sessionId:w()}),T({game:w(),source:w()}),T({}),T({}),T({games:he(T({sra:w(),name:w(),followed:ve(),pack:w().optional()}))}),T({sra:w(),follow:ve()}),T({}),T({activityId:w(),todo:he(w().min(1).max(80)).max(30).optional(),done:he(w().min(1).max(80)).max(30).optional(),finished:ve().optional()}),T({game:w().min(1),image:Vy.optional(),path:w().trim().min(1).max(1e3).optional()}).refine(e=>e.image===void 0||e.path===void 0,"图片和路径只能给一个"),T({banner:w().optional()}),T({game:w(),activityId:w().optional(),name:w().trim().min(1).max(60).nullable().optional(),startsAt:oe().nullable().optional(),endsAt:oe().nullable().optional(),kind:w().trim().max(20).nullable().optional(),description:w().trim().max(500).nullable().optional(),url:w().trim().refine(e=>e===""||/^https?:\/\/\S+$/.test(e),"只能是 http 或 https 网址").nullable().optional(),cover:yM().optional(),image:Vy.optional(),todo:he(w().min(1).max(80)).max(30).optional()}),T({activityId:w(),source:w().nullable()}),T({activityId:w()}),T({activity:Wy.optional()}),T({activityId:w()}),T({});T({game:w().optional()});const qN=Oe(["ask","full"]),GN=Oe(["default","allow","ask","deny"]),a2=[{id:"pipelines-edit",title:"编辑流水线和定时",description:"起草流水线,「编排」直接修改、保存流水线(pipeline_save),设定时间(schedule_set),以及 dsh 自己的定时任务。",tools:["pipeline_draft","pipeline_save","schedule_set","schedule_create","schedule_edit"]},{id:"run",title:"运行流水线和脚本",description:"启动、停止流水线和脚本任务,通过脚本自带的 MCP 服务操控脚本。",tools:["pipeline_run","script_run","script_stop","script_mcp_call"]},{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 安装、更新、回滚、删除脚本,运行脚本的安装程序,导入本地脚本,修复运行环境,写、改脚本包(pack_propose,直接生效)。",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_activity_save","game_activity_remove","game_add"]},{id:"skills",title:"保存技能",description:"把做法存成技能,以后的对话都会用到;把脚本自带的技能放进技能库。",tools:["skill_save","script_skills_import"]},{id:"web",title:"上网查资料",description:"读网页、搜索。",tools:["web_fetch","web_search"]},{id:"browser",title:"操作内置浏览器",description:"在内置浏览器里打开网页、点击、输入、按键、滚动、切换标签页(读页面和截图不算)。",tools:["browser_navigate","browser_click","browser_type","browser_press","browser_scroll","browser_tabs"]},{id:"shell",title:"运行命令、改文件",description:"dsh 自带的命令行和文件编辑。只在它请求确认时按这里的设置处理(沙箱里的普通命令不会请求)。",tools:["pwsh","bash","edit","write"],approvalOnly:!0}];T({mode:qN,since:oe().optional(),areas:Ws(w(),GN).default({}),recent:he(T({at:oe(),sessionId:w(),toolName:w(),reason:w().optional()}))});T({}),T({mode:qN}),T({area:w(),policy:GN});const o2=T({label:w(),description:w().optional()}),l2=T({id:w(),question:w(),detail:w().optional(),header:w().optional(),options:he(o2).optional(),multiSelect:ve().optional()});T({questionId:w(),sessionId:w(),callId:w().optional(),questions:he(l2)});const KN=T({id:w(),selected:he(w()),custom:w().optional()}),c2=Oe(["answered","cancelled","unavailable"]);T({questionId:w(),answers:he(KN)}),T({});T({questionId:w(),outcome:c2,answers:he(KN).optional()});const u2=T({pid:oe().int(),label:w(),dataDir:w().optional(),startedAt:oe(),warnings:he(w())});T({others:he(u2)});T({});const Bg=T({scripts:he(w()).optional(),games:he(w()).optional()}),Ky=T({name:w(),description:w(),whenToUse:w().optional(),source:w(),provider:w(),path:w().optional(),modelInvocable:ve(),userInvocable:ve(),owner:Bg.optional(),removable:ve().optional(),kind:Oe(["script-pack","game-pack"]).optional(),pack:w().optional(),ownPack:ve().optional()}),YN=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,_p=48;T({}),T({skills:he(Ky)}),T({name:w()}),Ky.extend({content:w()}),T({name:w().regex(YN).max(_p),description:w().trim().min(10).max(400),content:w().trim().min(20).max(2e4),scripts:he(w().min(1).max(64)).max(20).optional(),games:he(w().min(1).max(64)).max(20).optional(),replace:ve().optional()}),T({name:w(),replaced:ve()}),T({sessionId:w()}),Bg.required(),T({name:w()}),T({});T({}),T({sessionId:w(),scripts:he(w()),games:he(w())});const df=T({repo:ac,branch:w().trim().min(1).max(100).regex(/^[\w./-]+$/)}),Yy=T({name:w(),description:w(),title:w().optional(),kind:Oe(["game","script","general"]),pack:Oe(["script","game"]).optional(),game:w().optional(),sra:he(w()).optional(),default:ve().optional(),games:he(w()),scripts:he(w()),repo:w(),author:w().optional(),path:w(),hash:w(),version:w().optional(),changes:w().optional(),requires:w().optional(),history:he(T({version:w(),changes:w().optional()})).optional(),installed:T({at:oe(),update:ve(),version:w().optional(),previous:T({version:w().optional(),at:oe()}).optional(),held:ve().optional()}).optional(),incompatible:w().optional(),blocked:w().optional()}),Xu=T({name:w().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});T({refresh:ve().optional()}),T({items:he(Yy),repos:he(df),errors:he(w()),fetchedAt:oe().optional()}),T({content:w()}),Xu.extend({description:w().trim().min(10).max(400),content:w().trim().min(20).max(2e4)}),T({}),Xu.extend({repo:ac.optional()}),T({state:Oe(["current","updated"]),item:Yy}),Xu.extend({version:w().min(1).max(40)}),T({}),Xu.extend({owner:Bg.nullable()}),T({}),T({repos:he(df).min(1).max(10)}),T({repos:he(df)});T({});const Hg="你",XN="(不用告诉用户)",Xy=e=>e.replace(/[^\p{Script=Han}a-zA-Z0-9]/gu,"");function d2(e){return Xy(e)===Xy(XN)}const h2="(你这一轮的最后一段回复会作为结论交回去。在那之前要让对方知道的,用 agent_message 的 update 说,马上送到,说几次都行;交回结论以后还有话,同样发到这条线索:你的普通回复对方看不到。)",m2="(做完后你这一轮的最后一段回复会原样交回去:把结论写在那里。)",f2=/^(这件事的线索是 (\S+):做的过程中要问清楚什么,用 agent_message 问,thread 填它;不要猜。)$/,p2=/^(你和.{1,20}之前的来往,/,g2=")";function QN(e){var m;const[t="",...s]=e.split(`
|
|
104
|
-
`),i=/^(你在软件里点的:(.*))$/.exec(t),r=i===null?/^(([^():]{1,20})交给你的事:(.*))$/.exec(t):null;if(i===null&&r===null)return;const o=s[0]===h2||s[0]===m2,l=o?s.slice(1):s,u=(m=f2.exec(l[0]??""))==null?void 0:m[1],d=u===void 0?l:l.slice(1),h=p2.test(d[0]??"")?d.indexOf(g2):-1;return{by:i!==null?Hg:r[1],title:i!==null?i[1]:r[2],returns:o,...u===void 0?{}:{thread:u},body:d.slice(h+1).join(`
|
|
105
|
-
`).trim()}}function JN(e){const[t="",...s]=e.split(`
|
|
106
|
-
`),i=/^(「([^」]+)」在线索 (\S+) 里(问你|回答了你|告诉你):(.*))$/.exec(t);if(i===null)return;const r=s.join(`
|
|
107
|
-
`).trim(),o=r.lastIndexOf(`
|
|
108
|
-
|
|
109
|
-
(`);return{from:i[1],thread:i[2],kind:i[3]==="问你"?"question":i[3]==="告诉你"?"update":"answer",title:i[4],text:(o===-1?r:r.slice(0,o)).trim()}}function ew(e){const[t="",...s]=e.split(`
|
|
110
|
-
`),i=/^(「([^」]+)」(交回了|没有做完)([^()]{1,20}?)交给它的事:(.*))$/.exec(t);if(i===null)return;const r=s.join(`
|
|
111
|
-
`).trim(),o=r.lastIndexOf(`
|
|
112
|
-
|
|
113
|
-
(`);return{agent:i[1],ok:i[2]==="交回了",asker:i[3],title:i[4],reply:(o===-1?r:r.slice(0,o)).trim()}}function x2(e){return e.replace(/\s+/g," ").replace(/[()]/g,t=>t==="("?"(":")").trim()}const Qy=/\n\n(这是你在线索 \S+ 上定的提醒:[^)]*)$/;function Jy(e){const t=/^\[SCHEDULE REMINDER\]\n[\s\S]*?^reminder_prompt_json: (.*)$/m.exec(e);if(t!==null)return[y2(t[1]).replace(Qy,"")];const s=/^\[SCHEDULE REMINDER BATCH\]\n[\s\S]*?^reminders_json: (.*)$/m.exec(e);if(s!==null)try{return JSON.parse(s[1]).map(r=>String(r.reminder_prompt??"").replace(Qy,"")).filter(r=>r!=="")}catch{return[]}}function v2(e){return e.length===0?"定时提醒":`定时提醒:${e.map(t=>x2(t)).join(";")}`}function y2(e){try{const t=JSON.parse(e);return typeof t=="string"?t:e}catch{return e}}const b2=Oe(["default","concise","patient","lively","buddy","butler"]),k2=Oe(["plain","same"]),tw=T({style:b2,callUser:w().max(20).optional(),custom:w().optional(),peerStyle:k2.optional()}),j2=tw.partial().extend({name:w().max(20).optional()}),N2=T({persona:tw,agents:Ws(w(),j2)});N2.extend({prompt:w(),prompts:Ws(w(),w())});const eb={default:"",concise:"回答简短直接:先给结论,再给必要的细节;少寒暄,不用表情。",patient:"耐心、讲清楚:每一步说明为什么这么做,用对方听得懂的话,像教一个刚接触的人。",lively:"语气轻松活泼,可以用一点语气词和表情,但信息要准确、不啰嗦。",buddy:"像一起玩游戏的老朋友那样说话:熟悉游戏里的说法,可以适当吐槽和鼓励,但不夸张、不油腻。",butler:"像一位稳重周到的管家:礼貌、条理清楚,主动汇报进度和需要对方决定的事。"};function tb(e,t){const s=Object.entries(e.agents[t]??{}).filter(([,i])=>i!==void 0);return{...e.persona,...Object.fromEntries(s)}}function nb(e){const t=[];return e.name!==void 0&&e.name.trim()!==""&&t.push(`你的名字是「${e.name.trim()}」,自称时用这个名字。`),e.callUser!==void 0&&e.callUser.trim()!==""&&t.push(`称呼用户为「${e.callUser.trim()}」。`),eb[e.style]!==""&&t.push(eb[e.style]),e.custom!==void 0&&e.custom.trim()!==""&&t.push(`用户对你说话方式的要求:${e.custom.trim()}`),t.length===0?"":(t.push(e.peerStyle==="same"?"和其他 agent 说话时也用这个方式。":"上面是对用户说话的方式。和其他 agent 说话(agent_delegate、agent_message、交回去的结论)用平实的话,直接说事,不用人设和称呼:它们要读的是内容。"),t.push(`软件约定的固定写法(比如「${XN}」这一句、线索编号、工具的参数)一字不差照写,不加语气词和表情。`),["# 回复风格",...t,"这些只影响你说话的方式,不改变做事的规则:确认、安全限制和不能做的事都照旧;在飞书里回复也一样。"].join(`
|
|
114
|
-
`))}T({});const w2=80,nw=5,sw=100,S2=30,_2=1,E2=365,C2=[3,7,14,30],Ep=T({auto:ve(),threshold:oe().int().min(nw).max(sw),lowContext:ve(),archiveDays:oe().int().min(_2).max(E2).nullable().default(null),ptcSubagents:ve().default(!0),summarizer:T({provider:w().min(1).max(200),model:w().min(1).max(200),maxTokens:oe().int().positive().optional()}).nullable().default(null)});T({settings:Ep,applied:Ep});T({}),T({settings:Ep});const wa="shared",Cp=Oe(["profile","journal","core"]),Zg=2e3,A2=T({agent:w(),sessionId:w(),seq:oe().int().min(0)}),Wg=600,hf=T({id:w(),kind:Cp,scope:w(),text:w(),createdAt:w(),updatedAt:w(),by:w(),source:A2.optional()}),$2=T({auto:ve(),model:T({provider:w(),model:w(),reasoningEffort:w().optional()}).nullable()}),sb=w().trim().min(1).max(Wg);T({}),T({items:he(hf)}),T({kind:Cp,scope:w().min(1).max(64),text:sb}),T({item:hf}),T({id:w(),text:sb,kind:Cp.optional(),scope:w().min(1).max(64).optional()}),T({item:hf}),T({}),$2.extend({forced:ve().optional()}),T({id:w()}),T({removed:ve()});T({});const I2=Oe(["starting","running","stopping","succeeded","failed","cancelled"]),T2=T({type:Oe(["string","integer","number","boolean"]),default:Wo([w(),oe(),ve()]).optional(),enum:he(Wo([w(),oe()])).optional(),description:w().optional(),choices:he(T({value:w(),label:w(),detail:w().optional()})).optional(),canCreate:ve().optional()}),M2=T({mode:Oe(["auto","platform","off"]),pcLaunch:Oe(["program","maaend"]).optional(),pcRegion:Oe(["CN","Global","Bilibili","TapTap","Steam","Epic"]).optional(),pcExe:w().optional(),pcProcess:w().optional(),androidPackage:w().optional()});T({settings:M2,game:T({name:w().optional(),androidPackage:w().optional(),pcProcess:w().optional(),selfLaunch:w()}),uses:T({adb:ve(),desktop:ve()})});const R2=T({id:w(),title:w(),description:w().optional(),utterances:he(w()),params:Ws(w(),T2),input:Oe(["desktop","window","adb","none"]),account:w().optional(),expectedDuration:w().optional()}),Fi=w().trim().min(1).max(64),Ap=T({id:w(),name:w(),createdAt:oe().optional()}),iw=T({current:w(),items:he(Ap)}),O2=T({id:w(),scriptId:w(),scriptName:w(),taskId:w(),taskTitle:w(),params:Ws(w(),Wo([w(),oe(),ve()])),state:I2,outcome:w().optional(),startedAt:oe(),endedAt:oe().optional(),exitCode:oe().optional(),command:he(w()),resources:he(w()),tags:he(w()),warnings:he(w()),kind:Oe(["task","settings"]),retryOf:w().optional(),halted:ve().optional(),profile:w().optional(),profileName:w().optional()}),rw=T({at:oe(),source:w(),text:w(),level:Oe(["info","progress","done","warning","error"]).optional(),tag:w().optional()});T({scriptId:_t,profile:Fi.optional()}),T({tasks:he(R2),runnable:ve(),problem:w().optional()}),T({scriptId:_t,taskId:w().min(1).max(64),params:Ws(w(),Wo([w(),oe(),ve()])).optional(),profile:Fi.optional()}),T({runId:w()}),T({}),T({scriptId:_t.optional()}),T({items:he(O2)}),T({runId:w(),limit:oe().int().min(1).max(2e3).optional()}),T({lines:he(rw)}),T({scriptId:_t}),T({scriptId:_t,name:w().trim().min(1).max(30),from:ra("kind",[T({kind:ct("copy"),profile:Fi}),T({kind:ct("original")}),T({kind:ct("folder"),dir:w().trim().min(1).max(500)})])}),T({profile:Ap,files:he(w()),list:iw}),T({scriptId:_t,profile:Fi,name:w().trim().min(1).max(30).optional(),current:ct(!0).optional()}),T({scriptId:_t,profile:Fi}),T({scriptId:_t,profile:Fi.optional()}),T({importedAt:oe().optional(),dir:w(),profile:Ap,files:he(T({file:w(),local:ve(),original:ve(),changed:ve()})),drift:he(w())}),T({scriptId:_t,file:w().min(1),profile:Fi.optional()}),T({file:w(),content:w(),truncated:ve()}),T({scriptId:_t,profile:Fi.optional()}),T({imported:he(w())}),T({scriptId:_t,profile:Fi.optional()}),T({runId:w()}),T({}),T({scriptId:_t,taskId:w().min(1),param:w().min(1),name:w().trim().min(1).max(40),profile:Fi.optional()}),T({value:w()}),T({scriptId:_t}),T({scriptId:_t,mode:Oe(["auto","platform","off"]).optional(),pcLaunch:Oe(["program","maaend"]).nullable().optional(),pcRegion:Oe(["CN","Global","Bilibili","TapTap","Steam","Epic"]).nullable().optional(),pcExe:w().trim().nullable().optional(),pcProcess:w().trim().nullable().optional(),androidPackage:w().trim().regex(/^[A-Za-z][\w]*(\.[A-Za-z_][\w]*)+$/,"安卓包名像 com.example.game").nullable().optional()}),T({scriptId:_t}),T({exe:w().optional(),candidates:he(T({path:w(),source:w()}))});T({scriptId:w(),list:iw}),T({runId:w(),lines:he(rw)});const P2=1,mf=w().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"credential names use letters, digits and underscores"),aw=T({configured:ve(),source:w().optional(),writable:ve()}),$p="DEEPSEEK_API_KEY",L2=T({id:w(),version:oe().int().positive()}),ow=T({id:w(),title:w().nullable(),updatedAt:oe(),running:ve(),blank:ve(),live:ve(),cwd:w().optional(),parentId:w().optional(),origin:Oe(["subagent"]).optional(),role:w().optional(),requestedBy:w().optional(),home:w().optional()}),lw=T({id:w(),name:w(),description:w(),order:oe()}),cw=T({id:w(),requestId:w().optional(),text:w(),images:oe().int().optional(),placement:Oe(["next-turn","next-step","taken"])}),uw=T({contextWindow:oe().int().positive(),usedTokens:oe().int().nonnegative(),breakdown:T({systemTokens:oe().int().nonnegative(),toolsTokens:oe().int().nonnegative(),messageTokens:oe().int().nonnegative()}).optional()}),z2=T({id:w(),createdAt:oe(),cwd:w().optional(),parentId:w().optional(),agentPreset:w().optional()}),li=T({provider:w(),model:w(),reasoningEffort:w().optional()}),D2=T({agents:he(li),subAgents:he(li)});T({agents:Ws(w(),li),subAgents:li.nullable(),subAgentsOf:Ws(w(),li),fallbacks:D2.optional()});const F2=T({from:w(),kind:Oe(["question","answer","update","done"]),text:w(),at:oe()}),Ip=T({id:w(),messages:he(F2).optional(),chain:he(w()).optional(),parent:w().optional(),fromSession:w(),callId:w().optional(),by:w(),to:w(),toSession:w(),isolated:ve().optional(),ownerSession:w().optional(),title:w(),task:w(),expecting:w().optional(),state:Oe(["running","waiting","done","failed"]),reply:w().optional(),startedAt:oe(),endedAt:oe().optional()}),U2=T({id:w(),agent:w(),sessionId:w(),title:w(),prompt:w(),rule:w(),repeats:ve(),next:oe()});T({default:li,groups:he(T({id:w(),name:w(),models:he(T({id:w(),name:w(),description:w().optional(),efforts:he(T({id:w(),name:w()})),defaultEffort:w().optional()}))})),failures:he(T({id:w(),name:w(),message:w()}))});const B2=T({lastUsed:li.nullable(),next:li.nullable()}),ff=Oe(["openai-completions","openai-responses","anthropic-messages"]),H2=w().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"use lowercase letters, digits and single hyphens, starting with a letter"),Tp=T({id:w().min(1),name:w().optional(),contextWindow:oe().int().positive().optional(),maxTokens:oe().int().positive().optional(),input:he(Oe(["text","image"])).optional(),efforts:he(w().min(1)).optional()}),Z2=T({id:w(),displayName:w(),api:w().optional(),baseURL:w().optional(),models:he(Tp),apiKeyRef:w().optional(),credential:aw.optional(),declared:ve(),active:ve(),error:w().optional()}),W2=T({available:ve(),balances:he(T({currency:w(),total:w(),granted:w(),toppedUp:w()}))}),Mp=35e5,V2=T({mediaType:Oe(["image/png","image/jpeg","image/gif","image/webp"]),data:w().min(1).max(Mp).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix"),name:w().max(200).optional()}),q2=T({version:w(),title:w().optional(),publishedAt:w().optional(),url:w(),body:w()});T({});T({accepted:ct(!0)});T({protocolVersion:oe().int(),client:T({name:w(),version:w()})}),T({protocolVersion:oe().int(),server:T({name:w(),version:w(),dsh:w().optional()}),capabilities:he(L2)}),T({items:he(ow)}),T({cwd:w().optional(),focus:T({scripts:he(w()).optional(),games:he(w()).optional()}).optional(),role:w().optional()}),T({sessionId:w()}),T({sessionIds:he(w()).max(60)}),T({items:he(T({sessionId:w(),text:w().nullable()}))}),T({items:he(lw)}),T({agentId:w(),focus:T({scripts:he(w()).optional(),games:he(w()).optional()}).optional()}),T({sessionId:w()}),T({sessionId:w()}),T({items:he(Ip)}),T({sessionId:w()}),T({a:w(),b:w()}),T({items:he(Ip)}),T({id:w()}),T({agent:w().optional()}),T({items:he(U2)}),T({id:w()}),T({}),T({sessionId:w(),title:w().min(1)}),T({title:w()}),T({sessionId:w(),maxMessages:oe().int().positive().optional()}),T({subscriptionId:w(),header:z2,cursor:oe(),events:he(Np),hasMore:ve(),title:w().nullable(),live:XM.nullable(),queue:he(cw).optional(),context:uw.optional()}),T({subscriptionId:w()}),T({sessionId:w(),throughSeq:oe(),beforeSeq:oe(),maxMessages:oe().int().positive().optional()}),T({events:he(Np),hasMore:ve()}),T({sessionId:w(),requestId:w(),text:w(),mode:Oe(["queue","steer"]),images:he(V2).max(4).optional()}).refine(e=>{var t;return e.text.trim()!==""||(((t=e.images)==null?void 0:t.length)??0)>0},"消息是空的"),T({sessionId:w()}),T({sessionId:w()}),T({compacted:ve(),message:w()}),T({sessionId:w(),itemId:w(),action:Oe(["steer","remove"])}),T({attachmentId:w(),mediaType:w(),bytes:oe(),width:oe(),height:oe()}),T({mediaType:w(),data:w()}),T({path:w().min(1)}),T({mediaType:w(),data:w(),path:w()}),T({kind:Oe(["file","folder"]),title:w().max(200).optional(),defaultPath:w().max(1e3).optional(),filterName:w().max(60).optional(),extensions:he(w().regex(/^\w+$/)).max(20).optional()}),T({path:w().optional()}),T({sessionIds:he(w())}),T({sessionId:w()}),T({sessionIds:he(w())}),T({sessionId:w()}),T({sessionIds:he(w())}),T({agentId:w().optional(),sub:ve().optional(),model:li.nullable()}),T({warning:w().optional()}),T({sub:ve(),models:he(li)}),li.extend({sessionId:w()}),T({selected:li}),T({sessionId:w()}),T({approvalId:w(),decision:Oe(["allow-once","reject"])}),T({refs:he(mf).min(1).max(64)}),T({items:Ws(w(),aw)}),T({ref:mf,value:w().min(1).max(4096)}),T({ref:mf}),T({edition:Oe(["plugin","other"]),version:w().optional()}),T({current:w(),latest:T({version:w(),prerelease:ve(),notesUrl:w(),onNpm:ve().optional(),notes:he(q2).optional()}).optional(),checkedAt:oe()}),T({providers:he(Z2),revision:oe(),writable:ve(),protocols:he(ff),taken:he(w())}),T({provider:w().optional(),baseURL:Id({protocol:/^https?$/}).optional(),api:ff.optional(),apiKey:w().min(1).max(4096).optional()}),T({models:he(Tp)}),T({provider:w().min(1)}),T({balance:W2.nullable()}),T({id:H2,create:ve(),displayName:w().max(80).optional(),api:ff,baseURL:Id({protocol:/^https?$/}),models:he(Tp).min(1),apiKey:w().min(1).max(4096).optional(),expectedRevision:oe().optional()}),T({revision:oe(),apiKeyRef:w().optional()}),T({id:w().min(1),removeKey:ve().optional(),expectedRevision:oe().optional()}),T({revision:oe(),defaultReset:ve()});ra("kind",[T({kind:ct("upsert"),item:ow.partial().extend({id:w()})}),T({kind:ct("removed"),sessionId:w()})]);T({approvalId:w(),sessionId:w(),toolName:w(),callId:w().optional(),reason:w().optional(),displayReason:Ws(w(),w()).optional()});T({subscriptionId:w(),event:Np}),T({subscriptionId:w(),frame:LN}),T({subscriptionId:w(),reason:w()}),T({sessionId:w(),title:w().nullable()}),T({sessionId:w(),message:w()}),T({sessionId:w(),items:he(cw)}),T({sessionId:w(),context:uw.nullable()}),T({approvalId:w(),outcome:w()}),T({ref:w()}),T({sessionIds:he(w())}),T({items:he(lw)}),T({item:Ip}),T({}),T({}),B2.extend({sessionId:w()});const Qu={InternalError:-32603,NotInitialized:-32002};class Ml extends Error{constructor(s,i,r){super(i);ht(this,"code");ht(this,"data");this.name="RpcError",this.code=s,this.data=r}toJSON(){return this.data===void 0?{code:this.code,message:this.message}:{code:this.code,message:this.message,data:this.data}}}function G2(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 Vg(e){try{const t=JSON.parse(e);for(const i of["command","cmd","path","file_path","pattern","query","url","description","prompt"]){const r=t[i];if(typeof r=="string"&&r!=="")return r.split(`
|
|
115
|
-
`)[0].slice(0,160)}const s=Object.values(t).find(i=>typeof i=="string");return typeof s=="string"?s.slice(0,160):""}catch{return e.slice(0,160)}}const dw=["把这次走通的做法保存成技能(用 skill_save),让下次同样的事可以直接照着做、少调用模型。要求:","- 只写最后成功的路径,不写失败的尝试和闲聊;","- 写清楚适用场景(用户会怎么说)、一步一步的操作(用到的工具、命令、路径、参数照实写,会变的写成「把 X 换成…」)、怎样算成功、注意事项和踩过的坑;","- 名字用简短的英文小写加短横线,description 一两句话说清楚做什么、什么时候用;","- 分到对应的游戏和脚本:只有用某个脚本时才用得上的(它的配置、报错、日志),scripts 填脚本 id;和游戏本身有关、换个脚本也用得上的(游戏里的操作、界面、活动、机制),games 填游戏 id(用 game_list 查);和哪个游戏都无关才当通用技能;","- 保存后告诉我技能名,以及以后我说什么时会用到它。"].join(`
|
|
116
|
-
`);function K2(e,t,s){return[`优化脚本${e===""?":最近运行过的脚本(script_runs 看最近一周跑过哪些,一个一个来)":`「${e}」`}。把这段时间运行攒下的信息用起来,一次做完下面几件事:`,"1. 重新总结脚本包:script_tasks、script_help 看它现在有哪些任务和参数,script_runs、script_run_log 看最近的运行(成功的看正常流程和用时,失败的看原因);更新过版本就先用 script_changelog 读更新日志。对照它的脚本包,任务、参数、配置文件、完成和出错的日志文字、预计用时有不对或缺的,或者使用说明(guide:功能怎么开启、配置怎么设、运行前检查、常见问题)缺了、过时了、能用运行里遇到的报错补上的,用原来的脚本包 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(`
|
|
117
|
-
`)}const qg=[{name:"技能",aliases:["skill"],title:"把刚才走通的做法存成技能,下次少调用模型",expand:()=>dw},{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(`
|
|
118
|
-
`)},{name:"编排",aliases:["plan","pipeline"],title:"把脚本编成流水线",arg:"想做什么(可选,例如「每天早上跑完三个游戏的日常」)",expand:e=>[`帮我把脚本编排成流水线:${e===""?"把我装好的各个脚本的日常任务排成每天能自动跑的流程":e}。按技能 pipeline-planning:`,"1. 先 system_info 看电脑配置(能不能同时跑几个游戏),pipeline_list 看已有的流水线,script_tasks 看各脚本有哪些任务;","2. 排好后保存:你是「编排」就用 pipeline_save 直接保存;不是就用 pipeline_draft 起草(草稿,我在「编排」页保存后才会按定时运行),或者交给「编排」。模拟器和前台脚本能并行的并行,失败不要挡住别的;","3. 说清楚为什么这样排、哪些步骤并行、估计多久、建议定在几点跑。"].join(`
|
|
119
|
-
`)},{name:"诊断",aliases:["diagnose","why"],title:"分析脚本为什么失败,给出怎么改的建议",arg:"脚本名或运行 id(可选,不写就看最近失败的)",expand:e=>[`分析${e===""?"最近失败的脚本运行":`「${e}」`}为什么失败:`,"1. 用 script_runs 找到失败的那次运行,script_run_log 看日志(先按错误级别筛,再看出错前后);","2. 对照这个脚本包的技能说明原因:是脚本本身、配置、游戏状态(更新、公告、掉线)、模拟器 / ADB,还是电脑环境;","3. 给出怎么改:改哪项配置、游戏里要做什么、要不要重跑。先不要改任何东西、不要重跑,等我决定。"].join(`
|
|
120
|
-
`)},{name:"优化脚本",aliases:["optimize"],title:"用运行攒下的信息优化脚本:重新总结脚本包、调监控时间、把做过的步骤存成技能",arg:"脚本名(可选,不写就看最近运行过的)",expand:e=>K2(e)},{name:"压缩",aliases:["compact"],title:"压缩这个对话:较早的部分换成摘要,agent 会忘掉其中的细节",expand:()=>"",local:"compact"}];function Y2(e){var s,i,r;const t=(i=(s=/^\/(\S+)/.exec(e.trim()))==null?void 0:s[1])==null?void 0:i.toLowerCase();return t===void 0||(r=qg.find(o=>o.local!==void 0&&(o.name===t||o.aliases.includes(t))))==null?void 0:r.local}function X2(e,t){return`使用技能「${e}」:先用 skill 工具加载它,再按它的说明做${t===""?"。":`:${t}`}`}function Q2(e,t){const s=e.trim(),i=/^\/(\S+)(?:\s+([\s\S]*))?$/.exec(s);if(i===null)return s;const r=i[1],o=(i[2]??"").trim(),l=qg.find(d=>d.name===r.toLowerCase()||d.aliases.includes(r.toLowerCase()));if((l==null?void 0:l.local)!==void 0)return s;if(l!==void 0)return`${s}
|
|
121
|
-
|
|
122
|
-
${l.expand(o)}`;const u=t.find(d=>d.name===r);return u===void 0?s:`${s}
|
|
123
|
-
|
|
124
|
-
${X2(u.name,o)}`}function J2(e){if(!e.startsWith("/"))return;const t=e.indexOf(`
|
|
125
|
-
|
|
126
|
-
`);return t<0?void 0:{typed:e.slice(0,t),expansion:e.slice(t+2)}}function eO(e,t,s=!1){const i=/^\/(\S*)$/.exec(e);if(i===null)return[];const r=i[1].toLowerCase(),o=qg.filter(d=>(s||d.local===void 0)&&[d.name,...d.aliases].some(h=>h.toLowerCase().includes(r))).map(d=>({kind:"command",name:d.name,description:d.title,...d.arg===void 0?{}:{arg:d.arg},command:d})),l=d=>d.toLowerCase().startsWith(r)?0:1,u=t.filter(d=>d.name.toLowerCase().includes(r)||r.length>0&&d.description.toLowerCase().includes(r)).sort((d,h)=>+(d.group===void 0)-+(h.group===void 0)||(d.group??"").localeCompare(h.group??"")||l(d.name)-l(h.name)||d.name.localeCompare(h.name)).map(d=>({kind:"skill",name:d.name,description:d.description,...d.group===void 0?{}:{group:d.group}}));return[...o,...u]}const tO=new Set(["issues","pulls","wiki","actions","discussions","blob","commits","commit","compare","security","pulse","graphs","network","settings","projects","stargazers","forks","watchers","tags","branches"]);function nO(e){var N,j;const t=e.trim().replace(/^<|>$/g,""),s=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/.exec(t);if(s!==null&&!t.includes(":"))return{repo:`${s[1]}/${s[2]}`};const i=/git@github\.com:([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/i.exec(t);if(i!==null)return{repo:`${i[1]}/${i[2]}`};const r=y=>{try{return decodeURIComponent(y)}catch{return y}},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:r(o[3])};const l=/api\.github\.com\/repos\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)/i.exec(t);if(l!==null)return{repo:`${l[1]}/${l[2]}`};const u=t.toLowerCase().lastIndexOf("github.com/");if(u===-1)return;const h=t.slice(u+11).split(/[?#]/)[0].replace(/\/+$/,"").split("/");if(h.length<2||!/^[A-Za-z0-9_.-]+$/.test(h[0]))return;const m=h[1].replace(/\.git$/i,"");if(!/^[A-Za-z0-9_.-]+$/.test(m))return;const p=`${h[0]}/${m}`,[g,...x]=h.slice(2);if(g==="releases")return x[0]==="tag"&&x[1]!==void 0?{repo:p,tag:r(x.slice(1).join("/"))}:x[0]==="download"&&x.length>=3?{repo:p,tag:r(x.slice(1,-1).join("/")),asset:r(x.at(-1))}:{repo:p};if(g==="tree"&&x.length>0)return{repo:p,branch:r(x[0])};if(g==="archive"){const y=x.join("/").replace(/\.(zip|tar\.gz)$/i,""),k=(N=/^refs\/tags\/(.+)$/.exec(y))==null?void 0:N[1];if(k!==void 0)return{repo:p,tag:r(k)};const _=(j=/^refs\/heads\/(.+)$/.exec(y))==null?void 0:j[1];return _!==void 0?{repo:p,branch:r(_)}:{repo:p,tag:r(y)}}return g===void 0||tO.has(g)?{repo:p}:{repo:p}}const ib=1;var hr,As,qr,Pa,eh,ki,zo,Do,Rc,xn,Rp,Op,Pp,hw,mw,Lp,zp;class sO{constructor(t){Ht(this,xn);ht(this,"status",new Bi({state:"idle",attempt:0}));ht(this,"server",new Bi(null));Ht(this,hr);Ht(this,As,null);Ht(this,qr,!1);Ht(this,Pa,0);Ht(this,eh,1);Ht(this,ki,new Map);Ht(this,zo,new Map);Ht(this,Do,new Set);Ht(this,Rc);Kt(this,hr,t)}get generation(){return De(this,Pa)}get ready(){return De(this,qr)}start(){this.status.get().state!=="idle"&&this.status.get().state!=="stopped"||bt(this,xn,Pp).call(this)}stop(){clearTimeout(De(this,Rc)),this.status.set({state:"stopped",attempt:0});const t=De(this,As);Kt(this,As,null),bt(this,xn,Lp).call(this,"connection stopped"),t==null||t.close(1e3,"client stopped")}on(t,s){let i=De(this,zo).get(t);return i===void 0&&De(this,zo).set(t,i=new Set),i.add(s),()=>{i.delete(s)}}onReady(t){return De(this,Do).add(t),De(this,qr)&&queueMicrotask(()=>t(De(this,Pa))),()=>{De(this,Do).delete(t)}}call(t,s,i){return!De(this,qr)&&t!=="initialize"?Promise.reject(new Ml(Qu.NotInitialized,"not connected to the gateway")):bt(this,xn,Rp).call(this,t,s,i)}}hr=new WeakMap,As=new WeakMap,qr=new WeakMap,Pa=new WeakMap,eh=new WeakMap,ki=new WeakMap,zo=new WeakMap,Do=new WeakMap,Rc=new WeakMap,xn=new WeakSet,Rp=function(t,s,i){const r=De(this,As);if(r===null||r.readyState!==ib)return Promise.reject(new Ml(Qu.NotInitialized,"not connected to the gateway"));if((i==null?void 0:i.aborted)===!0)return Promise.reject(i.reason??new Error("aborted"));const o=iy(this,eh)._++;return new Promise((l,u)=>{const d=De(this,hr).callTimeoutMs??6e4,h=d>0?setTimeout(()=>{var g;(g=De(this,ki).get(o))==null||g.reject(new Ml(Qu.InternalError,`${t} timed out`))},d):void 0,m=()=>{var g;De(this,ki).has(o)&&(bt(this,xn,Op).call(this,{jsonrpc:"2.0",method:"$/cancelRequest",params:{id:o}}),(g=De(this,ki).get(o))==null||g.reject((i==null?void 0:i.reason)instanceof Error?i.reason:new Error("aborted")))};i==null||i.addEventListener("abort",m,{once:!0});const p=()=>{clearTimeout(h),i==null||i.removeEventListener("abort",m),De(this,ki).delete(o)};De(this,ki).set(o,{resolve:g=>{p(),l(g)},reject:g=>{p(),u(g)},cleanup:p}),bt(this,xn,Op).call(this,{jsonrpc:"2.0",id:o,method:t,params:s})})},Op=function(t){var s;((s=De(this,As))==null?void 0:s.readyState)===ib&&De(this,As).send(JSON.stringify(t))},Pp=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 s;try{s=(De(this,hr).createSocket??(i=>new WebSocket(i)))(De(this,hr).url)}catch(i){bt(this,xn,zp).call(this,i instanceof Error?i.message:String(i));return}Kt(this,As,s),s.addEventListener("open",()=>{De(this,As)===s&&bt(this,xn,hw).call(this,s)}),s.addEventListener("message",i=>{De(this,As)===s&&bt(this,xn,mw).call(this,String(i.data))}),s.addEventListener("close",i=>{if(De(this,As)!==s)return;Kt(this,As,null),bt(this,xn,Lp).call(this,"connection lost");const r=typeof i.reason=="string"&&i.reason!==""?i.reason:`closed (${i.code??"?"})`;bt(this,xn,zp).call(this,r)}),s.addEventListener("error",()=>{})},hw=async function(t){try{const s=await bt(this,xn,Rp).call(this,"initialize",{protocolVersion:P2,client:De(this,hr).clientInfo});if(De(this,As)!==t)return;Kt(this,qr,!0),Kt(this,Pa,De(this,Pa)+1),this.server.set(s),this.status.set({state:"open",attempt:0});for(const i of[...De(this,Do)])i(De(this,Pa))}catch(s){t.close(4e3,s instanceof Error?s.message:"initialize failed")}},mw=function(t){let s;try{s=JSON.parse(t)}catch{return}const i=G2(s);if(i==="response"){const r=De(this,ki).get(s.id);if(r===void 0)return;"error"in s?r.reject(new Ml(s.error.code,s.error.message,s.error.data)):r.resolve(s.result)}else if(i==="notification")for(const r of[...De(this,zo).get(s.method)??[]])try{r(s.params)}catch(o){console.error(`notification handler for ${s.method} failed`,o)}},Lp=function(t){Kt(this,qr,!1);for(const s of[...De(this,ki).values()])s.reject(new Ml(Qu.InternalError,t));De(this,ki).clear()},zp=function(t){if(this.status.get().state==="stopped")return;const s=this.status.get().attempt+1,{initial:i,max:r}=De(this,hr).backoffMs??{initial:500,max:1e4},o=Math.min(r,i*2**Math.min(s-1,10))*(.8+Math.random()*.4);this.status.set({state:"reconnecting",attempt:s,error:t}),Kt(this,Rc,setTimeout(()=>bt(this,xn,Pp).call(this),o))};const iO={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 $s,Oc,Fo,Uo,mr,Gr,Pc,Lc,Yt,Dp,vd,is;class rO{constructor(t,s,i){Ht(this,Yt);ht(this,"id");ht(this,"state",new Bi(iO));Ht(this,$s);Ht(this,Oc);Ht(this,Fo,null);Ht(this,Uo,-1);Ht(this,mr,!1);Ht(this,Gr,null);Ht(this,Pc);Ht(this,Lc);this.id=t,Kt(this,$s,s),Kt(this,Oc,i),Kt(this,Pc,s.onReady(r=>{r!==De(this,Uo)&&bt(this,Yt,Dp).call(this,r)}))}get subscriptionId(){return De(this,Fo)}async prompt(t,s="queue",i=[]){const r=crypto.randomUUID(),o={requestId:r,text:t,mode:s,sentAt:Date.now(),...i.length===0?{}:{images:i.length}};bt(this,Yt,is).call(this,l=>({...l,pending:[...l.pending,o]}));try{await De(this,$s).call("session/prompt",{sessionId:this.id,requestId:r,text:t,mode:s,...i.length===0?{}:{images:[...i]}})}catch(l){const u=l instanceof Error?l.message:String(l);throw bt(this,Yt,is).call(this,d=>({...d,pending:d.pending.map(h=>h.requestId===r?{...h,failed:u}:h)})),l}}dismissPending(t){bt(this,Yt,is).call(this,s=>({...s,pending:s.pending.filter(i=>i.requestId!==t)}))}async updateQueue(t,s){await De(this,$s).call("session/queue/update",{sessionId:this.id,itemId:t,action:s})}async cancel(){await De(this,$s).call("session/cancel",{sessionId:this.id})}async compact(){return De(this,$s).call("session/compact",{sessionId:this.id})}async loadOlder(){const t=this.state.get(),s=t.events[0];if(!(!t.hasMore||t.loadingOlder||s===void 0)){bt(this,Yt,is).call(this,i=>({...i,loadingOlder:!0}));try{const i=await De(this,$s).call("session/history",{sessionId:this.id,throughSeq:t.cursor,beforeSeq:s.seq});bt(this,Yt,is).call(this,r=>{var u;const o=((u=r.events[0])==null?void 0:u.seq)??Number.POSITIVE_INFINITY,l=i.events.filter(d=>d.seq<o);return{...r,events:[...l,...r.events],hasMore:i.hasMore,loadingOlder:!1}})}catch(i){bt(this,Yt,is).call(this,r=>({...r,loadingOlder:!1,error:i instanceof Error?i.message:String(i)}))}}}close(){if(De(this,mr))return;Kt(this,mr,!0),clearTimeout(De(this,Lc)),De(this,Pc).call(this);const t=De(this,Fo);bt(this,Yt,vd).call(this,null),t!==null&&De(this,$s).ready&&De(this,$s).call("session/close",{subscriptionId:t}).catch(()=>{}),bt(this,Yt,is).call(this,s=>({...s,status:"closed"}))}receiveEvent(t){bt(this,Yt,is).call(this,s=>{const i=s.events.at(-1);if(i!==void 0&&t.seq<=i.seq)return s;let r=s.pending;t.type==="user/message"&&t.requestId!==void 0&&(r=r.filter(d=>d.requestId!==t.requestId));let o=s.live;(t.type==="assistant/message"||t.type==="assistant/attempt")&&o!==null&&o.turn===t.turn&&o.step===t.step&&(o=null);const l=t.type==="session/title"?t.title:s.title,u=[...s.events,t];return{...s,events:u,pending:r,live:o,title:l,running:pf(u,o)}})}receiveLive(t){bt(this,Yt,is).call(this,s=>{var i;switch(t.type){case"start":{const r={attemptId:t.attemptId,turn:t.turn,step:t.step,afterSeq:t.afterSeq,deltas:[]};return{...s,live:r,running:!0}}case"delta":{const r=s.live;return r===null||r.attemptId!==t.attemptId?s:(r.deltas.push(t),{...s,live:{...r}})}case"end":return((i=s.live)==null?void 0:i.attemptId)!==t.attemptId?s:{...s,live:null,running:pf(s.events,null)}}})}receiveClosed(t){bt(this,Yt,vd).call(this,null),!De(this,mr)&&(bt(this,Yt,is).call(this,s=>({...s,status:"error",error:`stream ended: ${t}`})),Kt(this,Lc,setTimeout(()=>{!De(this,mr)&&De(this,$s).ready&&bt(this,Yt,Dp).call(this,De(this,Uo))},1e3)))}receiveQueue(t){bt(this,Yt,is).call(this,s=>({...s,queue:t,pending:rb(s.pending,t)}))}receiveContext(t){bt(this,Yt,is).call(this,s=>({...s,context:t}))}receiveTitle(t){bt(this,Yt,is).call(this,s=>s.title===t?s:{...s,title:t})}}$s=new WeakMap,Oc=new WeakMap,Fo=new WeakMap,Uo=new WeakMap,mr=new WeakMap,Gr=new WeakMap,Pc=new WeakMap,Lc=new WeakMap,Yt=new WeakSet,Dp=async function(t){if(!De(this,mr))return De(this,Gr)!==null?De(this,Gr):(Kt(this,Uo,t),Kt(this,Gr,(async()=>{try{const s=await De(this,$s).call("session/open",{sessionId:this.id});if(De(this,mr)){De(this,$s).call("session/close",{subscriptionId:s.subscriptionId}).catch(()=>{});return}bt(this,Yt,vd).call(this,s.subscriptionId);const i=s.live===null?null:{...s.live,deltas:[...s.live.deltas]};bt(this,Yt,is).call(this,r=>{const o=new Set(s.events.flatMap(l=>l.type==="user/message"&&l.requestId!==void 0?[l.requestId]:[]));return{...r,status:"open",header:s.header,title:s.title,events:s.events,cursor:s.cursor,hasMore:s.hasMore,live:i,pending:rb(r.pending.filter(l=>!o.has(l.requestId)),s.queue??[]),queue:s.queue??[],context:s.context??r.context,running:pf(s.events,i),loadingOlder:!1,error:null}})}catch(s){bt(this,Yt,is).call(this,i=>({...i,status:"error",error:s instanceof Error?s.message:String(s)}))}finally{Kt(this,Gr,null)}})()),De(this,Gr))},vd=function(t){Kt(this,Fo,t),De(this,Oc).bindSubscription(this,t)},is=function(t){this.state.set(s=>{const i=t(s);return i===s?s:{...i,version:s.version+1}})};function rb(e,t){const s=new Set(t.flatMap(i=>i.requestId===void 0?[]:[i.requestId]));return s.size===0?e:e.filter(i=>!s.has(i.requestId))}function pf(e,t){if(t!==null)return!0;for(let s=e.length-1;s>=0;s-=1){const i=e[s];if(i.type==="turn/end")return!1;if(i.type==="turn/start")return!0}return!1}const ab=(e,t)=>t.updatedAt-e.updatedAt;var Us,Hi,Bo,pr,yd,Fp;class aO{constructor(t){Ht(this,pr);ht(this,"connection");ht(this,"sessions",new Bi({items:[],loaded:!1,error:null}));ht(this,"approvals",new Bi([]));ht(this,"questions",new Bi([]));ht(this,"capabilities",new Bi(new Set));ht(this,"credentialRevision",new Bi(0));ht(this,"providersRevision",new Bi(0));ht(this,"sessionModels",new Bi(new Map));Ht(this,Us,new Map);Ht(this,Hi,new Map);Ht(this,Bo,!1);this.connection=new sO({...t,clientInfo:t.clientInfo??{name:"adg-client",version:"0.1.0"}});const s=this.connection;s.onReady(()=>{var i;this.capabilities.set(new Set(((i=s.server.get())==null?void 0:i.capabilities.map(r=>r.id))??[])),this.approvals.set([]),this.questions.set([]),this.refreshSessions()}),s.on("sessions/changed",i=>{if(i.kind==="removed"){if(this.sessions.get().items.some(o=>o.id===i.sessionId&&o.origin==="subagent")){this.sessions.set(o=>({...o,items:o.items.map(l=>l.id===i.sessionId?{...l,running:!1,live:!1}:l)})),bt(this,pr,Fp).call(this);return}this.sessions.set(o=>({...o,items:o.items.filter(l=>l.id!==i.sessionId)}));return}if(!this.sessions.get().items.some(o=>o.id===i.item.id)){bt(this,pr,Fp).call(this);return}this.sessions.set(o=>({...o,items:o.items.map(l=>l.id===i.item.id?{...l,...oO(i.item)}:l).sort(ab)}))}),s.on("session/title",({sessionId:i,title:r})=>{var o;(o=De(this,Us).get(i))==null||o.handle.receiveTitle(r)}),s.on("session/queue",({sessionId:i,items:r})=>{var o;(o=De(this,Us).get(i))==null||o.handle.receiveQueue(r)}),s.on("session/context",({sessionId:i,context:r})=>{var o;(o=De(this,Us).get(i))==null||o.handle.receiveContext(r)}),s.on("session/event",({subscriptionId:i,event:r})=>{var o;return(o=De(this,Hi).get(i))==null?void 0:o.receiveEvent(r)}),s.on("session/live",({subscriptionId:i,frame:r})=>{var o;return(o=De(this,Hi).get(i))==null?void 0:o.receiveLive(r)}),s.on("session/closed",({subscriptionId:i,reason:r})=>{const o=De(this,Hi).get(i);o!==void 0&&o.subscriptionId===i&&o.receiveClosed(r)}),s.on("approval/requested",i=>{this.approvals.set(r=>r.some(o=>o.approvalId===i.approvalId)?r:[...r,i])}),s.on("approval/resolved",({approvalId:i})=>{this.approvals.set(r=>r.filter(o=>o.approvalId!==i))}),s.on("question/requested",i=>{this.questions.set(r=>r.some(o=>o.questionId===i.questionId)?r:[...r,i])}),s.on("question/resolved",({questionId:i})=>{this.questions.set(r=>r.filter(o=>o.questionId!==i))}),s.on("credentials/changed",()=>this.credentialRevision.set(i=>i+1)),s.on("providers/changed",()=>this.providersRevision.set(i=>i+1)),s.on("session/model",({sessionId:i,lastUsed:r,next:o})=>bt(this,pr,yd).call(this,i,{lastUsed:r,next:o}))}async describeCredentials(t){const{items:s}=await this.connection.call("credentials/describe",{refs:[...t]});return s}async setCredential(t,s){await this.connection.call("credentials/set",{ref:t,value:s}),this.credentialRevision.set(i=>i+1)}async unsetCredential(t){await this.connection.call("credentials/unset",{ref:t}),this.credentialRevision.set(s=>s+1)}start(){this.connection.start()}stop(){for(const{handle:t}of De(this,Us).values())t.close();De(this,Us).clear(),De(this,Hi).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(ab),loaded:!0,error:null})}catch(t){this.sessions.set(s=>({...s,error:t instanceof Error?t.message:String(t)}))}}async createSession(t,s={}){const{sessionId:i}=await this.connection.call("sessions/create",{...t===void 0?{}:{cwd:t},...s.role===void 0?{}:{role:s.role}});return await this.refreshSessions(),i}async renameSession(t,s){var r;const i=await this.connection.call("sessions/rename",{sessionId:t,title:s});this.sessions.set(o=>({...o,items:o.items.map(l=>l.id===t?{...l,title:i.title}:l)})),(r=De(this,Us).get(t))==null||r.handle.receiveTitle(i.title)}modelCatalog(){return this.connection.call("models/catalog",{})}async sessionModel(t){const s=await this.connection.call("session/model",{sessionId:t});return bt(this,pr,yd).call(this,t,s),s}async selectModel(t,s){var o;const{selected:i}=await this.connection.call("session/selectModel",{sessionId:t,...s}),r=((o=this.sessionModels.get().get(t))==null?void 0:o.lastUsed)??null;return bt(this,pr,yd).call(this,t,{lastUsed:r,next:i}),i}listProviders(){return this.connection.call("providers/list",{})}async discoverModels(t,s){const{models:i}=await this.connection.call("providers/discover",t,s);return i}async providerBalance(t){const{balance:s}=await this.connection.call("providers/balance",{provider:t});return s}async saveProvider(t){const s=await this.connection.call("providers/save",t);return this.providersRevision.set(i=>i+1),t.apiKey!==void 0&&this.credentialRevision.set(i=>i+1),s}async removeProvider(t){const s=await this.connection.call("providers/remove",t);return this.providersRevision.set(i=>i+1),t.removeKey===!0&&this.credentialRevision.set(i=>i+1),s}async respondApproval(t,s){await this.connection.call("approval/respond",{approvalId:t,decision:s}),this.approvals.set(i=>i.filter(r=>r.approvalId!==t))}async answerQuestion(t,s){await this.connection.call("question/respond",{questionId:t,answers:[...s]}),this.questions.set(i=>i.filter(r=>r.questionId!==t))}openSession(t){const s=De(this,Us).get(t);if(s!==void 0)return s.refs+=1,s.handle;const i=new rO(t,this.connection,{bindSubscription:(r,o)=>{for(const[l,u]of De(this,Hi))u===r&&De(this,Hi).delete(l);o!==null&&De(this,Hi).set(o,r)}});return De(this,Us).set(t,{handle:i,refs:1}),i}release(t){const s=De(this,Us).get(t.id);s===void 0||s.handle!==t||(s.refs-=1,!(s.refs>0)&&(De(this,Us).delete(t.id),t.close()))}}Us=new WeakMap,Hi=new WeakMap,Bo=new WeakMap,pr=new WeakSet,yd=function(t,s){this.sessionModels.set(i=>new Map(i).set(t,s))},Fp=function(){De(this,Bo)||(Kt(this,Bo,!0),setTimeout(()=>{Kt(this,Bo,!1),this.refreshSessions()},150))};function oO(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const gf=(e,t)=>e.map(s=>s.type===t?s.text:"").join(""),xf=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}}]:[]),lO=e=>e.map(t=>t.type==="text"?t.text:t.type==="image"?"[image]":t.type==="file"?`[file ${t.name??""}]`:"").join(""),fw="model-selection",cO="run_code",uO="ptc-mode";function dO(e){return(e==null?void 0:e.kind)==="context"&&e.title===fw}function rh(e,t,s=[],i=[]){var x,N,j;const r=[],o=new Map;let l;const u=new Set,d=new Set,h=(y,k)=>{d.has(y)||(d.add(y),r.push({kind:"context",id:"dispatch:"+y,childId:y,title:"adg-task-dispatched",summary:k,text:""}))},m=new Map,p=new Map;for(const y of e)switch(y.type){case"unknown":{if(y.upstreamType!=="agent/inbox/spliced")break;const k=y.data;if(!Array.isArray(k==null?void 0:k.inserted))break;for(const _ of k.inserted){const S=_==null?void 0:_.source;(S==null?void 0:S.kind)==="adg-task-dispatched"&&typeof S.childId=="string"&&S.childId&&typeof S.summary=="string"&&h(S.childId,S.summary)}break}case"user/message":{if(y.origin.kind==="adg-task-dispatched"&&y.origin.childId&&y.origin.summary!==void 0){h(y.origin.childId,y.origin.summary);break}const k=gf(y.content,"text");if(y.origin.human)r.push({kind:"user",id:`u:${y.seq}`,text:k,time:y.time,images:y.content.filter(_=>_.type==="image").length,imageRefs:xf(y.content),files:y.content.filter(_=>_.type==="file").length});else if(y.origin.kind===KM&&y.origin.fallback!==void 0){dO(r.at(-1))&&r.pop();const _=r.at(-1);(_==null?void 0:_.kind)==="notice"&&_.tone==="error"&&r.pop(),r.push({kind:"fallback",id:`f:${y.seq}`,notice:y.origin.fallback,time:y.time})}else if(!(y.origin.kind===fw&&((x=r.at(-1))==null?void 0:x.kind)==="fallback")){if(Jy(k)!==void 0)r.push({kind:"context",id:`c:${y.seq}`,title:"定时提醒",summary:v2(Jy(k)),text:k,startsTurn:!0});else if(y.replacesHistory===!0)r.push({kind:"context",id:`c:${y.seq}`,title:"较早的对话已压缩成摘要(agent 只记得摘要里的内容)",summary:"",text:k});else if(y.origin.summary!==void 0)r.push({kind:"context",id:`c:${y.seq}`,title:y.origin.kind,summary:y.origin.summary,text:k});else if(y.origin.kind===uO&&l!==void 0){const _=xf(y.content).filter(S=>{var E;return((E=l.images)==null?void 0:E.some(O=>O.attachmentId===S.attachmentId))!==!0});_.length>0&&(l.images=[...l.images??[],..._])}}break}case"assistant/message":{u.add(`${y.turn}:${y.step}`);const k=gf(y.content,"text"),_=gf(y.content,"reasoning");(k.trim()!==""||_.trim()!=="")&&r.push({kind:"assistant",id:`a:${y.seq}`,text:k,reasoning:_,live:!1,interrupted:y.interrupted===!0,time:y.time,...y.model===void 0?{}:{model:y.model}});break}case"tool/call":{const k={kind:"tool",id:`t:${y.callId}`,callId:y.callId,name:y.name,arguments:y.arguments,status:"running",time:y.time},_=m.get(y.callId);_!==void 0&&(k.approval=_),o.set(y.callId,k),r.push(k),y.name===cO&&(l=k);break}case"tool/result":{const k=o.get(y.callId);if(k===void 0)break;k.result=lO(y.content);const _=xf(y.content);_.length>0&&(k.images=_),k.status=y.isError?"error":"ok",y.error!==void 0&&(k.error=y.error.message);break}case"approval/asked":if(y.callId!==void 0){p.set(y.approvalId,y.callId),m.set(y.callId,"asked");const k=o.get(y.callId);k!==void 0&&(k.approval="asked")}break;case"approval/decided":{const k=p.get(y.approvalId);if(k===void 0)break;m.set(k,y.outcome);const _=o.get(k);_!==void 0&&(_.approval=y.outcome);break}case"turn/end":for(const k of o.values())k.status==="running"&&(k.status="interrupted");y.reason.kind==="error"?r.push({kind:"notice",id:`e:${y.seq}`,tone:"error",text:y.reason.message??"这一轮出错了"}):y.reason.kind==="aborted"?r.push({kind:"notice",id:`e:${y.seq}`,tone:"info",text:"已停止"}):y.reason.kind==="max-tokens"&&r.push({kind:"notice",id:`e:${y.seq}`,tone:"info",text:"回复太长,达到了输出上限"});break;case"compaction/end":r.push({kind:"notice",id:`k:${y.seq}`,tone:y.error===void 0?"info":"error",text:y.error===void 0?"对话太长,较早的内容已压缩成摘要":`压缩对话历史失败:${y.error}`});break}if(t!==null&&!u.has(`${t.turn}:${t.step}`)){let y="",k="";for(const _ of t.deltas)_.kind==="text"?y+=_.text:_.kind==="reasoning"&&(k+=_.text);r.push({kind:"assistant",id:`live:${t.attemptId}`,text:y,reasoning:k,live:!0,interrupted:!1,time:((N=t.deltas[0])==null?void 0:N.time)??Date.now()})}const g=new Set(e.flatMap(y=>y.type==="user/message"?[y.messageId]:[]));for(const y of i)y.placement!=="taken"||g.has(y.id)||r.push({kind:"user",id:`q:${y.id}`,text:y.text,images:y.images??0,imageRefs:[],files:0,time:((j=e.at(-1))==null?void 0:j.time)??Date.now(),pending:{requestId:y.requestId??y.id}});for(const y of s)r.push({kind:"user",id:`p:${y.requestId}`,text:y.text,images:y.images??0,imageRefs:[],files:0,time:y.sentAt,pending:{requestId:y.requestId,...y.failed===void 0?{}:{failed:y.failed}}});return r}var v=zc();const hO=$g(v);var qa=sN();function mO(e,t){return e.filter(s=>{var i;return((i=s.available)==null?void 0:i.call(s,t))??!0})}const Kr=new Map,Td=new Set;function Bn(e){if(Kr.has(e.id))throw new Error(`UI plugin "${e.id}" is already registered`);Kr.set(e.id,e);for(const t of Td)t();return()=>{if(Kr.get(e.id)===e){Kr.delete(e.id);for(const t of Td)t()}}}function pw(e){return Td.add(e),()=>{Td.delete(e)}}function fO(e){return[...Kr.values()].filter(t=>t.requires.every(s=>e.has(s))).flatMap(t=>t.sessionViews??[]).sort((t,s)=>t.order-s.order)}function pO(e){return[...Kr.values()].filter(t=>t.requires.every(s=>e.has(s))).flatMap(t=>t.settingsPages??[]).sort((t,s)=>t.order-s.order)}function gO(e){return[...Kr.values()].filter(t=>t.requires.every(s=>e.has(s))).flatMap(t=>t.pages??[]).sort((t,s)=>t.order-s.order)}function xO(e){return[...Kr.values()].map(t=>({plugin:t,missing:t.requires.filter(s=>!e.has(s))}))}function _e(e){return v.useSyncExternalStore(e.subscribe,e.get,e.get)}function Fc(e,t){const[s,i]=v.useState(null);return v.useEffect(()=>{const r=e.openSession(t);return i(r),()=>e.release(r)},[e,t]),s!==null&&s.id===t?s:null}function vO(e){const t=_e(e.capabilities),s=Gg();return v.useMemo(()=>fO(t),[t,s])}function yO(e){const t=_e(e.capabilities),s=Gg();return v.useMemo(()=>pO(t),[t,s])}function bO(e){const t=_e(e.capabilities),s=Gg();return v.useMemo(()=>gO(t),[t,s])}function Gg(){const[e,t]=v.useState(0);return v.useEffect(()=>pw(()=>t(s=>s+1)),[]),e}function gw(e,t){const s=_e(e.credentialRevision),i=_e(e.connection.status),r=_e(e.capabilities),o=t.join(`
|
|
127
|
-
`),[l,u]=v.useState({items:null,error:null});return v.useEffect(()=>{if(i.state!=="open"||!r.has("credentials")||o==="")return;let d=!0;return e.describeCredentials(o.split(`
|
|
128
|
-
`)).then(h=>{d&&u({items:h,error:null})}).catch(h=>{d&&u(m=>({...m,error:h instanceof Error?h.message:String(h)}))}),()=>{d=!1}},[e,o,s,i.state,r]),l}function aa(e){const t=_e(e.credentialRevision),s=_e(e.providersRevision),i=_e(e.connection.status),r=_e(e.capabilities),[o,l]=v.useState({catalog:null,error:null});return v.useEffect(()=>{if(i.state!=="open"||!r.has("models"))return;let u=!0;return e.modelCatalog().then(d=>{u&&l({catalog:d,error:null})}).catch(d=>{u&&l(h=>({...h,error:d instanceof Error?d.message:String(d)}))}),()=>{u=!1}},[e,t,s,i.state,r]),o}function vn(e){const[t,s]=v.useState(()=>Date.now());return v.useEffect(()=>{const i=setInterval(()=>s(Date.now()),e);return()=>clearInterval(i)},[e]),t}function kO(e){const t=_e(e.connection.status),s=_e(e.capabilities),[i,r]=v.useState(void 0);return v.useEffect(()=>e.connection.on("permissions/changed",o=>r(o.mode)),[e]),v.useEffect(()=>{if(t.state!=="open"||!s.has("permissions"))return;let o=!0;return e.connection.call("permissions/get",{}).then(l=>{o&&r(l.mode)}).catch(()=>{}),()=>{o=!1}},[e,t.state,s]),i}const jO={plus:"M12 5v14M5 12h14",chat:"M6 4.5h12A3.5 3.5 0 0 1 21.5 8v6.5A3.5 3.5 0 0 1 18 18h-5.2l-4.3 3.2a.6.6 0 0 1-1-.5V18H6a3.5 3.5 0 0 1-3.5-3.5V8A3.5 3.5 0 0 1 6 4.5ZM8 11.25h.01M12 11.25h.01M16 11.25h.01",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",eye:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7ZM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z","eye-off":"M3 3l18 18M10.6 5.1A10 10 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-3.1 3.9M6.6 6.6A17 17 0 0 0 2 12s3.5 7 10 7a10 10 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2",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:"M10.27 4.5a2 2 0 0 1 3.46 0l7.36 12.75A2 2 0 0 1 19.36 20.25H4.64a2 2 0 0 1-1.73-3L10.27 4.5ZM12 9.5v4.25M12 16.75v.01",package:"M11 3.3a2 2 0 0 1 2 0l6.5 3.75a2 2 0 0 1 1 1.73v6.44a2 2 0 0 1-1 1.73L13 20.7a2 2 0 0 1-2 0l-6.5-3.75a2 2 0 0 1-1-1.73V8.78a2 2 0 0 1 1-1.73L11 3.3ZM3.8 7.7 12 12.4l8.2-4.7M12 12.4v8.5",flow:"M5.5 3.75h2.5a1.75 1.75 0 0 1 1.75 1.75V8A1.75 1.75 0 0 1 8 9.75H5.5A1.75 1.75 0 0 1 3.75 8V5.5A1.75 1.75 0 0 1 5.5 3.75ZM16 3.75h2.5a1.75 1.75 0 0 1 1.75 1.75V8a1.75 1.75 0 0 1-1.75 1.75H16A1.75 1.75 0 0 1 14.25 8V5.5A1.75 1.75 0 0 1 16 3.75ZM16 14.25h2.5a1.75 1.75 0 0 1 1.75 1.75v2.5a1.75 1.75 0 0 1-1.75 1.75H16a1.75 1.75 0 0 1-1.75-1.75V16A1.75 1.75 0 0 1 16 14.25ZM9.75 6.75h4.5M17.25 9.75v4.5M6.75 9.75v5a2.5 2.5 0 0 0 2.5 2.5h5",monitor:"M5.5 4h13A2.5 2.5 0 0 1 21 6.5v7a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 13.5v-7A2.5 2.5 0 0 1 5.5 4ZM9 20h6M12 16v4M6.75 10.25h2.5l1.5-2.75 2.5 5.25 1.5-2.5h2.5",gamepad:"M7.75 6.5h8.5a5 5 0 0 1 4.93 5.83l-.72 4.27a2.6 2.6 0 0 1-4.45 1.37L14.25 16h-4.5l-1.76 1.97a2.6 2.6 0 0 1-4.45-1.37l-.72-4.27A5 5 0 0 1 7.75 6.5ZM8.25 9.75v3.5M6.5 11.5H10M15.25 10.75v.01M17.25 12.75v.01",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:"M6.5 5h11A2.5 2.5 0 0 1 20 7.5v10a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 4 17.5v-10A2.5 2.5 0 0 1 6.5 5ZM4 10h16M8.5 3v4M15.5 3v4M8.5 13.5h.01M12 13.5h.01M15.5 13.5h.01M8.5 16.75h.01M12 16.75h.01",reply:"m9.5 5.25-5.75 5.5 5.75 5.5M4.5 10.75h8.25A6.75 6.75 0 0 1 19.5 17.5v1.25",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",globe:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM3.5 9h17M3.5 15h17M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9c-2.5-2.5-3.5-5.5-3.5-9s1-6.5 3.5-9Z",list:"M9 6h11M9 12h11M9 18h11M4.5 6v.01M4.5 12v.01M4.5 18v.01",clock:"M12 20.5a8.5 8.5 0 1 0 0-17 8.5 8.5 0 0 0 0 17ZM12 7.5V12l3 2",timeline:"M4.75 5h7.5a1.75 1.75 0 0 1 0 3.5h-7.5a1.75 1.75 0 0 1 0-3.5ZM9.75 10.25h9.5a1.75 1.75 0 0 1 0 3.5h-9.5a1.75 1.75 0 0 1 0-3.5ZM6.75 15.5h6.5a1.75 1.75 0 0 1 0 3.5h-6.5a1.75 1.75 0 0 1 0-3.5Z",more:"M5.5 12h.01M12 12h.01M18.5 12h.01",library:"M6.5 9h11A2.5 2.5 0 0 1 20 11.5v6a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 4 17.5v-6A2.5 2.5 0 0 1 6.5 9ZM6.5 6h11M8.5 3.25h7M10.75 12.25v4.5l3.75-2.25-3.75-2.25Z",swap:"M7 4.5 4 7.5l3 3M4 7.5h12.5M17 13.5l3 3-3 3M20 16.5H7.5",blank:""},ob={clock:"M12 20.5a8.5 8.5 0 1 0 0-17 8.5 8.5 0 0 0 0 17Z",timeline:"M4.75 5h7.5a1.75 1.75 0 0 1 0 3.5h-7.5a1.75 1.75 0 0 1 0-3.5ZM9.75 10.25h9.5a1.75 1.75 0 0 1 0 3.5h-9.5a1.75 1.75 0 0 1 0-3.5ZM6.75 15.5h6.5a1.75 1.75 0 0 1 0 3.5h-6.5a1.75 1.75 0 0 1 0-3.5Z",chat:"M6 4.5h12A3.5 3.5 0 0 1 21.5 8v6.5A3.5 3.5 0 0 1 18 18h-5.2l-4.3 3.2a.6.6 0 0 1-1-.5V18H6a3.5 3.5 0 0 1-3.5-3.5V8A3.5 3.5 0 0 1 6 4.5Z",alert:"M10.27 4.5a2 2 0 0 1 3.46 0l7.36 12.75A2 2 0 0 1 19.36 20.25H4.64a2 2 0 0 1-1.73-3L10.27 4.5Z",gamepad:"M7.75 6.5h8.5a5 5 0 0 1 4.93 5.83l-.72 4.27a2.6 2.6 0 0 1-4.45 1.37L14.25 16h-4.5l-1.76 1.97a2.6 2.6 0 0 1-4.45-1.37l-.72-4.27A5 5 0 0 1 7.75 6.5Z",package:"M3.8 7.7 12 12.4v8.5a2 2 0 0 1-1-.2l-6.5-3.75a2 2 0 0 1-1-1.73V8.78a2 2 0 0 1 .3-1.08Z",flow:"M5.5 3.75h2.5a1.75 1.75 0 0 1 1.75 1.75V8A1.75 1.75 0 0 1 8 9.75H5.5A1.75 1.75 0 0 1 3.75 8V5.5A1.75 1.75 0 0 1 5.5 3.75ZM16 14.25h2.5a1.75 1.75 0 0 1 1.75 1.75v2.5a1.75 1.75 0 0 1-1.75 1.75H16a1.75 1.75 0 0 1-1.75-1.75V16A1.75 1.75 0 0 1 16 14.25Z",calendar:"M6.5 5h11A2.5 2.5 0 0 1 20 7.5V10H4V7.5A2.5 2.5 0 0 1 6.5 5Z",monitor:"M5.5 4h13A2.5 2.5 0 0 1 21 6.5v7a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 13.5v-7A2.5 2.5 0 0 1 5.5 4Z",library:"M6.5 9h11A2.5 2.5 0 0 1 20 11.5v6a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 4 17.5v-6A2.5 2.5 0 0 1 6.5 9Z"};function Q({name:e,className:t=""}){return n.jsxs("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:[ob[e]!==void 0&&n.jsx("path",{className:"ui-icon-fill",d:ob[e],fill:"currentColor",stroke:"none"}),n.jsx("path",{d:jO[e]})]})}function NO(){return n.jsx("svg",{className:"ui-icon stop-glyph",viewBox:"0 0 24 24","aria-hidden":"true",children:n.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"3",fill:"currentColor"})})}function Kg({size:e="md"}){return n.jsx("span",{className:`adg-mark ${e}`,"aria-hidden":"true",children:n.jsxs("svg",{className:"ui-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 7.5v9l7.5-4.5L9 7.5Z"}),n.jsx("path",{d:"M4 12a8 8 0 0 1 14.5-4.7M20 12a8 8 0 0 1-14.5 4.7"})]})})}const lb="adg.otherCopies.seen";function wO(e){const t=_e(e.connection.status),i=_e(e.capabilities).has("instances"),[r,o]=v.useState([]);return v.useEffect(()=>e.connection.on("instances/changed",l=>o(l.others)),[e]),v.useEffect(()=>{if(t.state!=="open"||!i){o([]);return}let l=!0;return e.connection.call("instances/others",{}).then(u=>{l&&o(u.others)}).catch(()=>{}),()=>{l=!1}},[e,t.state,i]),r}function SO({client:e}){const t=wO(e),s=JSON.stringify(t.map(l=>[l.pid,l.warnings])),[i,r]=v.useState(()=>{try{return localStorage.getItem(lb)}catch{return null}});if(t.length===0||i===s)return null;const o=()=>{try{localStorage.setItem(lb,s)}catch{}r(s)};return n.jsxs("div",{className:"approval-card other-copies",role:"status",children:[n.jsxs("div",{className:"approval-head",children:[n.jsx(Q,{name:"alert"}),n.jsxs("div",{className:"approval-text",children:[n.jsx("span",{className:"approval-title",children:t.length===1?"另一个多游戏助手也开着":`另外 ${t.length} 个多游戏助手也开着`}),n.jsx("span",{className:"approval-tool",children:t.map(l=>l.label).join("、")})]})]}),n.jsx("ul",{className:"other-copies-list",children:[...new Set(t.flatMap(l=>l.warnings))].map(l=>n.jsx("li",{children:l},l))}),n.jsx("div",{className:"approval-actions",children:n.jsx("button",{onClick:o,children:"知道了"})})]})}const _O={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function EO(e){const t=_e(e.connection.status),i=_e(e.capabilities).has("schedule"),[r,o]=v.useState(void 0);return v.useEffect(()=>e.connection.on("schedule/power",o),[e]),v.useEffect(()=>{if(t.state!=="open"||!i){o(void 0);return}let l=!0;return e.connection.call("schedule/power",{}).then(u=>{l&&o(u)}).catch(()=>{}),()=>{l=!1}},[e,t.state,i]),r}function CO({client:e,pending:t}){const s=vn(1e3),[i,r]=v.useState(!1),[o,l]=v.useState(null),u=_O[t.action],d=async()=>{r(!0),l(null);try{await e.connection.call("schedule/power/cancel",{})}catch(m){l(m instanceof Error?m.message:String(m))}finally{r(!1)}},h=t.at===void 0?void 0:Math.max(0,Math.ceil((t.at-s)/1e3));return n.jsxs("div",{className:"approval-card power-card",role:"alertdialog","aria-label":`即将${u}`,children:[n.jsxs("div",{className:"approval-head",children:[n.jsx(Q,{name:"power"}),n.jsxs("div",{className:"approval-text",children:[n.jsx("div",{className:"approval-title",children:h===void 0?`其他任务结束后${u}`:`${h} 秒后${u}`}),n.jsxs("span",{className:"approval-tool",children:["「",t.pipelineName,"」设置了结束后",u]})]})]}),t.action==="shutdown"&&h!==void 0&&n.jsx("div",{className:"approval-reason",children:"关机会强制关闭所有程序,没保存的内容会丢失。"}),o!==null&&n.jsx("div",{className:"error small",children:o}),n.jsx("div",{className:"approval-actions",children:n.jsxs("button",{className:"inverse",disabled:i,onClick:()=>void d(),children:["取消",u]})})]})}function ah(e){const t=_e(e.connection.status),[s,i]=v.useState({data:null,error:null}),[r,o]=v.useState(0),l=v.useCallback(()=>o(u=>u+1),[]);return v.useEffect(()=>e.connection.on("scripts/changed",()=>l()),[e,l]),v.useEffect(()=>{if(t.state!=="open")return;let u=!0;return e.connection.call("scripts/list",{}).then(d=>{u&&i({data:d,error:null})}).catch(d=>{u&&i(h=>({...h,error:$e(d)}))}),()=>{u=!1}},[e,t.state,r]),{...s,refresh:l}}function xw(e){const t=_e(e.connection.status),[s,i]=v.useState(new Map);return v.useEffect(()=>e.connection.on("scripts/job",r=>{i(o=>{const l=o.get(r.scriptId);return l!==void 0&&l.id!==r.id&&l.startedAt>r.startedAt?o:new Map(o).set(r.scriptId,r)})}),[e]),v.useEffect(()=>{if(t.state!=="open")return;let r=!0;return e.connection.call("scripts/jobs",{}).then(({items:o})=>{if(!r)return;const l=new Map;for(const u of[...o].sort((d,h)=>d.startedAt-h.startedAt))l.set(u.scriptId,u);i(l)}).catch(()=>{}),()=>{r=!1}},[e,t.state]),s}function $e(e){return e instanceof Error?e.message:String(e)}function Ta(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 jc={queued:"排队中",resolving:"读取发布信息",downloading:"下载中",verifying:"校验中",extracting:"解压中",checking:"检查环境",running:"处理中",done:"完成",failed:"失败",cancelled:"已取消"},vw={"maafw-pi":"MaaFramework",cli:"命令行","gui-config":"配置驱动 GUI","generic-process":"通用程序",visual:"界面操作"};function Aa(e){return e!==void 0&&e.endedAt===void 0}function AO(e){const t=_e(e.connection.status),i=_e(e.capabilities).has("skillhub"),[r,o]=v.useState([]),[l,u]=v.useState(0);return v.useEffect(()=>e.connection.on("skillhub/changed",()=>u(d=>d+1)),[e]),v.useEffect(()=>{if(t.state!=="open"||!i)return;let d=!0;return e.connection.call("skillhub/list",{}).then(h=>{d&&o(h.items.filter(m=>{var p;return((p=m.installed)==null?void 0:p.update)===!0&&m.incompatible===void 0}))}).catch(()=>{}),()=>{d=!1}},[e,t.state,i,l]),r}function cb(e,t){const s=[e.id,e.packId,e.known].filter(i=>i!==void 0);return t.filter(i=>i.scripts.some(r=>s.includes(r)))}const yw="adg.scriptUpdate.later",ub=9e3;function db(){try{return JSON.parse(localStorage.getItem(yw)??"{}")}catch{return{}}}function $O({client:e}){return _e(e.capabilities).has("scripts")?n.jsx(MO,{client:e}):null}function IO({client:e}){return _e(e.capabilities).has("scripts")?n.jsx(TO,{client:e}):null}function TO({client:e}){const{data:t}=ah(e),s=xw(e),[i,r]=v.useState(null),[o,l]=v.useState(db),[u,d]=v.useState(new Map);if(v.useEffect(()=>{if(t===null)return;let g=!0;return e.connection.call("scripts/settings",{}).then(x=>{g&&r(x.autoUpdate)}).catch(()=>{}),()=>{g=!1}},[e,t]),t===null||i!=="ask")return null;const h=t.scripts.filter(g=>{var x;return((x=g.update)==null?void 0:x.available)===!0&&o[g.id]!==g.update.latest});if(h.length===0)return null;const m=(g,x)=>{const N={...db(),[g]:x};try{localStorage.setItem(yw,JSON.stringify(N))}catch{}l(N)},p=g=>{d(x=>{const N=new Map(x);return N.delete(g),N}),e.connection.call("scripts/update",{id:g}).catch(x=>d(N=>new Map(N).set(g,$e(x))))};return h.map(g=>{var k;const x=s.get(g.id),N=Aa(x),j=g.source.kind==="local"?(k=g.localVersion)==null?void 0:k.version:g.current,y=u.get(g.id);return n.jsxs("div",{className:"reminder script-update-note",role:"status",children:[n.jsx(Q,{name:"download"}),n.jsxs("span",{children:[n.jsx("strong",{children:g.name})," 有新版本 ",g.update.latest,"(当前 ",j??"认不出的版本","),要现在更新吗?",y!==void 0&&n.jsxs("span",{className:"error",children:[" 没有更新成功:",y]})]}),N?n.jsxs("span",{className:"script-update-progress muted",children:[n.jsx("span",{className:"spinner"}),x.message??jc[x.phase],"…"]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"ghost small-button",title:"有更新的版本时再问",onClick:()=>m(g.id,g.update.latest),children:"以后再说"}),n.jsx("button",{type:"button",className:"primary small-button",onClick:()=>p(g.id),children:"更新"})]})]},g.id)})}function MO({client:e}){const[t,s]=v.useState([]),i=v.useRef(new Set);v.useEffect(()=>e.connection.on("scripts/job",o=>{o.phase!=="done"||o.setup!==void 0||o.kind==="env-fix"||i.current.has(o.id)||(i.current.add(o.id),e.connection.call("scripts/get",{id:o.scriptId}).then(l=>l.name,()=>o.scriptId).then(l=>s(u=>[...u,{job:o,name:l}])))}),[e]);const r=o=>s(l=>l.filter(u=>u.job.id!==o));return t.map(o=>n.jsx(RO,{done:o,onClose:()=>r(o.job.id)},o.job.id))}function RO({done:e,onClose:t}){const[s,i]=v.useState(!1);v.useEffect(()=>{if(s)return;const u=setTimeout(t,ub);return()=>clearTimeout(u)},[s,t]);const{job:r,name:o}=e,l=r.kind==="update";return n.jsxs("div",{className:"approval-card done-card",role:"status",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[n.jsxs("div",{className:"approval-head",children:[n.jsx("span",{className:"done-badge","aria-hidden":"true",children:n.jsxs("svg",{viewBox:"0 0 24 24",children:[n.jsx("circle",{cx:"12",cy:"12",r:"10"}),n.jsx("path",{d:"M7.5 12.5l3 3 6-6.5"})]})}),n.jsxs("div",{className:"approval-text",children:[n.jsx("span",{className:"approval-title",children:l?"更新成功":"安装成功"}),n.jsxs("span",{className:"done-line",children:[o,r.version===void 0?"":l?` 已更新到 ${r.version}`:` ${r.version} 已装好`]})]}),n.jsx("button",{className:"ghost icon-button update-close","aria-label":"关闭",onClick:t,children:n.jsx(Q,{name:"close"})})]}),!s&&n.jsx("span",{className:"done-timer",style:{animationDuration:`${ub}ms`}})]})}function Vs(){return window.adgDesktop}/*! @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 hb(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,i=Array(t);s<t;s++)i[s]=e[s];return i}function OO(e){if(Array.isArray(e))return e}function PO(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var i,r,o,l,u=[],d=!0,h=!1;try{if(o=(s=s.call(e)).next,t!==0)for(;!(d=(i=o.call(s)).done)&&(u.push(i.value),u.length!==t);d=!0);}catch(m){h=!0,r=m}finally{try{if(!d&&s.return!=null&&(l=s.return(),Object(l)!==l))return}finally{if(h)throw r}}return u}}function LO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
129
|
-
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 zO(e,t){return OO(e)||PO(e,t)||DO(e,t)||LO()}function DO(e,t){if(e){if(typeof e=="string")return hb(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?hb(e,t):void 0}}const bw=Object.entries,mb=Object.setPrototypeOf,FO=Object.isFrozen,kw=Object.getPrototypeOf,jw=Object.getOwnPropertyDescriptor;let Un=Object.freeze,Gn=Object.seal,wo=Object.create,Nw=typeof Reflect<"u"&&Reflect,Up=Nw.apply,Bp=Nw.construct;Un||(Un=function(t){return t});Gn||(Gn=function(t){return t});Up||(Up=function(t,s){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return t.apply(s,r)});Bp||(Bp=function(t){for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;r<s;r++)i[r-1]=arguments[r];return new t(...i)});const cr=en(Array.prototype.forEach),UO=en(Array.prototype.lastIndexOf),fb=en(Array.prototype.pop),Rl=en(Array.prototype.push),BO=en(Array.prototype.slice),HO=en(Array.prototype.splice),Io=Array.isArray,vf=ww(Set),yf=en(Set.prototype.add),Ol=en(Set.prototype.has),_a=en(String.prototype.toLowerCase),bf=en(String.prototype.toString),pb=en(String.prototype.match),Pl=en(String.prototype.replace),gb=en(String.prototype.indexOf),ZO=en(String.prototype.trim),WO=en(Number.prototype.toString),VO=en(Boolean.prototype.toString),xb=typeof BigInt>"u"?null:en(BigInt.prototype.toString),vb=typeof Symbol>"u"?null:en(Symbol.prototype.toString),Is=en(Object.prototype.hasOwnProperty),Ll=en(Object.prototype.toString),qn=en(RegExp.prototype.test),ur=ww(TypeError);function en(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;r<s;r++)i[r-1]=arguments[r];return Up(e,t,i)}}function ww(e){return function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return Bp(e,s)}}function Ct(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_a;if(mb&&mb(e,null),!Io(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){const o=s(r);o!==r&&(FO(t)||(t[i]=o),r=o)}e[r]=!0}return e}function qO(e){for(let t=0;t<e.length;t++)Is(e,t)||(e[t]=null);return e}function Fs(e){const t=wo(null);for(const i of bw(e)){var s=zO(i,2);const r=s[0],o=s[1];Is(e,r)&&(Io(o)?t[r]=qO(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=Fs(o):t[r]=o)}return t}function GO(e){switch(typeof e){case"string":return e;case"number":return WO(e);case"boolean":return VO(e);case"bigint":return xb?xb(e):"0";case"symbol":return vb?vb(e):"Symbol()";case"undefined":return Ll(e);case"function":case"object":{if(e===null)return Ll(e);const t=e,s=ri(t,"toString");if(typeof s=="function"){const i=s(t);return typeof i=="string"?i:Ll(i)}return Ll(e)}default:return Ll(e)}}function ri(e,t){for(;e!==null;){const i=jw(e,t);if(i){if(i.get)return en(i.get);if(typeof i.value=="function")return en(i.value)}e=kw(e)}function s(){return null}return s}function KO(e,t){for(;e!==null;){const s=jw(e,t);if(s)return s.get?en(s.get):null;e=kw(e)}return null}function YO(e){try{return qn(e,""),!0}catch{return!1}}const yb=Un(["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"]),kf=Un(["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"]),jf=Un(["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"]),XO=Un(["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"]),Nf=Un(["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"]),QO=Un(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bb=Un(["#text"]),kb=Un(["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"]),wf=Un(["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"]),jb=Un(["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"]),Ju=Un(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),JO=Gn(/{{[\w\W]*|^[\w\W]*}}/g),eP=Gn(/<%[\w\W]*|^[\w\W]*%>/g),tP=Gn(/\${[\w\W]*/g),nP=Gn(/^data-[\-\w.\u00B7-\uFFFF]+$/),sP=Gn(/^aria-[\-\w]+$/),Nb=Gn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),iP=Gn(/^(?:\w+script|data):/i),rP=Gn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),aP=Gn(/^html$/i),oP=Gn(/^[a-z][.\w]*(-[.\w]+)+$/i),Sf=Gn(/<[/\w!]/g),wb=Gn(/<[/\w]/g),lP=Gn(/<\/no(script|embed|frames)/i),Sb=Gn(/\/>/i),jn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},cP=Un(Ct({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),uP=function(){return typeof window>"u"?null:window},dP=function(t,s){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const r="data-tt-policy-suffix";s&&s.hasAttribute(r)&&(i=s.getAttribute(r));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},_b=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Dr=function(t,s,i,r){return Is(t,s)&&Io(t[s])?Ct(r.base?Fs(r.base):{},t[s],r.transform):i},_f=function(t,s,i){const r=Is(t,s)?t[s]:void 0;return r&&typeof r=="object"?Fs(r):i()};function Sw(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:uP();const t=Ee=>Sw(Ee);if(t.version="3.4.17",t.removed=[],!e||!e.document||e.document.nodeType!==jn.document||!e.Element)return t.isSupported=!1,t;let s=e.document;const i=s,r=i.currentScript;e.DocumentFragment;const o=e.HTMLTemplateElement,l=e.Node,u=e.Element,d=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,m=e.trustedTypes,p=u.prototype,g=ri(p,"cloneNode"),x=ri(p,"remove"),N=ri(p,"removeAttributeNode"),j=ri(p,"nextSibling"),y=ri(p,"childNodes"),k=ri(p,"parentNode"),_=ri(p,"shadowRoot"),S=ri(p,"attributes"),E=l&&l.prototype?ri(l.prototype,"nodeType"):null,O=l&&l.prototype?ri(l.prototype,"nodeName"):null,P=l&&l.prototype?ri(l.prototype,"ownerDocument"):null,H=function(Y){return E?E(Y):Y.nodeType},B=function(Y){return O?O(Y):Y.nodeName},R=KO(p,"namespaceURI"),M=function(Y){return R?R(Y):Y.namespaceURI};if(typeof o=="function"){const Ee=s.createElement("template");Ee.content&&Ee.content.ownerDocument&&(s=Ee.content.ownerDocument)}let F,L="",A,I=!1,z=0;const D=function(){if(z>0)throw ur('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.')},V=function(Y){D(),z++;try{return F.createHTML(Y)}finally{z--}},U=function(Y){D(),z++;try{return F.createScriptURL(Y)}finally{z--}},q=function(){return I||(A=dP(m,r),I=!0),A},te=s,G=te.implementation,K=te.createNodeIterator,Z=te.createDocumentFragment,ee=te.getElementsByTagName,J=i.importNode;let re=_b();t.isSupported=typeof bw=="function"&&typeof k=="function"&&G&&G.createHTMLDocument!==void 0;const ie=JO,ne=eP,me=tP,Ce=nP,Fe=sP,Me=iP,fe=rP,ke=oP;let ge=Nb,Ae=null;const be=Ct({},[...yb,...kf,...jf,...Nf,...bb]);let qe=null;const ft=Ct({},[...kb,...wf,...jb,...Ju]);let gt=Object.seal(wo(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}})),Rt=null,En=null;const rt=Object.seal(wo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Pt=!0,rn=!0,Zt=!1,Qt=!0,Ut=!1,Rn=!0,mn=!1,Hn=!1,Gs=null,ps=null,rs=!1,gs=!1,Cn=!1,as=!1,Kn=!0,Zn=!1;const An="user-content-";let Yn=!0,On=!1,le=null,X={},de=null;const Se=Ct({},["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 Be=null;const ut=Ct({},["audio","video","img","source","image","track"]);let Nt=null;const He=Ct({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ue="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",yt="http://www.w3.org/1999/xhtml";let St=yt,Xn=!1,xs=null;const ui=Ct({},[Ue,Xe,yt],bf),yr=Un(["mi","mo","mn","ms","mtext"]);let di=Ct({},yr);const br=Un(["annotation-xml"]);let Qn=Ct({},br);const Gi=Ct({},["title","style","font","a","script"]);let vs=null;const Mi=["application/xhtml+xml","text/html"],kr="text/html";let zt=null,Os=null;const os=s.createElement("form"),Ki=function(Y){return Y instanceof RegExp||Y instanceof Function},hi=function(){let Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Os&&Os===Y)return;(!Y||typeof Y!="object")&&(Y={}),Y=Fs(Y),vs=Mi.indexOf(Y.PARSER_MEDIA_TYPE)===-1?kr:Y.PARSER_MEDIA_TYPE,zt=vs==="application/xhtml+xml"?bf:_a,Ae=Dr(Y,"ALLOWED_TAGS",be,{transform:zt}),qe=Dr(Y,"ALLOWED_ATTR",ft,{transform:zt}),xs=Dr(Y,"ALLOWED_NAMESPACES",ui,{transform:bf}),Nt=Dr(Y,"ADD_URI_SAFE_ATTR",He,{transform:zt,base:He}),Be=Dr(Y,"ADD_DATA_URI_TAGS",ut,{transform:zt,base:ut}),de=Dr(Y,"FORBID_CONTENTS",Se,{transform:zt}),Rt=Dr(Y,"FORBID_TAGS",Fs({}),{transform:zt}),En=Dr(Y,"FORBID_ATTR",Fs({}),{transform:zt}),X=Is(Y,"USE_PROFILES")?Y.USE_PROFILES&&typeof Y.USE_PROFILES=="object"?Fs(Y.USE_PROFILES):Y.USE_PROFILES:!1,Pt=Y.ALLOW_ARIA_ATTR!==!1,rn=Y.ALLOW_DATA_ATTR!==!1,Zt=Y.ALLOW_UNKNOWN_PROTOCOLS||!1,Qt=Y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ut=Y.SAFE_FOR_TEMPLATES||!1,Rn=Y.SAFE_FOR_XML!==!1,mn=Y.WHOLE_DOCUMENT||!1,gs=Y.RETURN_DOM||!1,Cn=Y.RETURN_DOM_FRAGMENT||!1,as=Y.RETURN_TRUSTED_TYPE||!1,rs=Y.FORCE_BODY||!1,Kn=Y.SANITIZE_DOM!==!1,Zn=Y.SANITIZE_NAMED_PROPS||!1,Yn=Y.KEEP_CONTENT!==!1,On=Y.IN_PLACE||!1,ge=YO(Y.ALLOWED_URI_REGEXP)?Y.ALLOWED_URI_REGEXP:Nb,St=typeof Y.NAMESPACE=="string"?Y.NAMESPACE:yt,di=_f(Y,"MATHML_TEXT_INTEGRATION_POINTS",()=>Ct({},yr)),Qn=_f(Y,"HTML_INTEGRATION_POINTS",()=>Ct({},br));const ce=_f(Y,"CUSTOM_ELEMENT_HANDLING",()=>wo(null));if(gt=wo(null),Is(ce,"tagNameCheck")&&Ki(ce.tagNameCheck)&&(gt.tagNameCheck=ce.tagNameCheck),Is(ce,"attributeNameCheck")&&Ki(ce.attributeNameCheck)&&(gt.attributeNameCheck=ce.attributeNameCheck),Is(ce,"allowCustomizedBuiltInElements")&&typeof ce.allowCustomizedBuiltInElements=="boolean"&&(gt.allowCustomizedBuiltInElements=ce.allowCustomizedBuiltInElements),Gn(gt),Ut&&(rn=!1),Cn&&(gs=!0),X&&(Ae=Ct({},bb),qe=wo(null),X.html===!0&&(Ct(Ae,yb),Ct(qe,kb)),X.svg===!0&&(Ct(Ae,kf),Ct(qe,wf),Ct(qe,Ju)),X.svgFilters===!0&&(Ct(Ae,jf),Ct(qe,wf),Ct(qe,Ju)),X.mathMl===!0&&(Ct(Ae,Nf),Ct(qe,jb),Ct(qe,Ju))),rt.tagCheck=null,rt.attributeCheck=null,Is(Y,"ADD_TAGS")&&(typeof Y.ADD_TAGS=="function"?rt.tagCheck=Y.ADD_TAGS:Io(Y.ADD_TAGS)&&(Ae===be&&(Ae=Fs(Ae)),Ct(Ae,Y.ADD_TAGS,zt))),Is(Y,"ADD_ATTR")&&(typeof Y.ADD_ATTR=="function"?rt.attributeCheck=Y.ADD_ATTR:Io(Y.ADD_ATTR)&&(qe===ft&&(qe=Fs(qe)),Ct(qe,Y.ADD_ATTR,zt))),Is(Y,"ADD_FORBID_CONTENTS")&&Io(Y.ADD_FORBID_CONTENTS)&&(de===Se&&(de=Fs(de)),Ct(de,Y.ADD_FORBID_CONTENTS,zt)),Yn&&(Ae["#text"]=!0),mn&&Ct(Ae,["html","head","body"]),Ae.table&&(Ct(Ae,["tbody"]),delete Rt.tbody),Y.TRUSTED_TYPES_POLICY){if(typeof Y.TRUSTED_TYPES_POLICY.createHTML!="function")throw ur('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof Y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ur('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const Ne=F;F=Y.TRUSTED_TYPES_POLICY;try{L=V("")}catch(we){throw F=Ne,we}}else Y.TRUSTED_TYPES_POLICY===null?(F=void 0,L=""):(F===void 0&&(F=q()),F&&typeof L=="string"&&(L=V("")));Un&&Un(Y),Os=Y},Dt=Ct({},[...kf,...jf,...XO]),jr=Ct({},[...Nf,...QO]),Yi=function(Y,ce,Ne){return ce.namespaceURI===yt?Y==="svg":ce.namespaceURI===Ue?Y==="svg"&&(Ne==="annotation-xml"||di[Ne]):!!Dt[Y]},mi=function(Y,ce,Ne){return ce.namespaceURI===yt?Y==="math":ce.namespaceURI===Xe?Y==="math"&&Qn[Ne]:!!jr[Y]},Ri=function(Y,ce,Ne){return ce.namespaceURI===Xe&&!Qn[Ne]||ce.namespaceURI===Ue&&!di[Ne]?!1:!jr[Y]&&(Gi[Y]||!Dt[Y])},Pe=function(Y){const ce=M(Y),Ne=_a(B(Y)),we=k(Y);let Ye,nt;return we&&H(we)===jn.element?(Ye={namespaceURI:M(we)},nt=_a(B(we))):(Ye={namespaceURI:St},nt="template"),xs[ce]?ce===Xe?Yi(Ne,Ye,nt):ce===Ue?mi(Ne,Ye,nt):ce===yt?Ri(Ne,Ye,nt):!!(vs==="application/xhtml+xml"&&xs[ce]):!1},Ve=function(Y){Rl(t.removed,{element:Y});try{k(Y).removeChild(Y)}catch{if(x(Y),!k(Y))throw ur("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},dt=function(Y,ce,Ne){try{N(Y,ce)}catch{try{Y.removeAttribute(Ne)}catch{}}},mt=function(Y){Ks(Y);const ce=y(Y);ce&&cr(BO(ce),we=>{try{x(we)}catch{}});const Ne=H(Y)===jn.element?S(Y):null;if(Ne)for(let we=Ne.length-1;we>=0;--we){const Ye=Ne[we],nt=Ye&&Ye.name;typeof nt=="string"&&dt(Y,Ye,nt)}},Ot=function(Y,ce,Ne){if(!Ne)try{Ne=ce.getAttributeNode(Y)}catch{Ne=null}Rl(t.removed,{attribute:Ne||null,from:ce});try{Ne?N(ce,Ne):ce.removeAttribute(Y)}catch{try{ce.removeAttribute(Y)}catch{}}if(Y==="is")if(gs||Cn)try{Ve(ce)}catch{}else try{ce.setAttribute(Y,"")}catch{}},Ft=function(Y){const ce=S(Y);if(ce)for(let Ne=ce.length-1;Ne>=0;--Ne){const we=ce[Ne],Ye=we&&we.name;typeof Ye!="string"||qe[zt(Ye)]||dt(Y,we,Ye)}},Jn=function(Y,ce){let Ne=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const we=[Y];for(;we.length>0;){const Ye=we.pop();if(ce(Ye)===!1)continue;if(Ne&&H(Ye)===jn.element){const xt=_(Ye);ks(xt)&&we.push(xt)}const nt=y(Ye);if(nt)for(let xt=nt.length-1;xt>=0;--xt)we.push(nt[xt])}},Ks=function(Y){Jn(Y,ce=>{H(ce)===jn.element&&Ft(ce)})},fn=function(Y){const ce=[];return Jn(Y,Ne=>{ce.push(Ne)},!0),ce},$n=function(Y,ce){const Ne=vf();cr(fn(Y),we=>{H(we)===jn.element&&yf(Ne,we)}),cr(ce,we=>{H(we)===jn.element&&!Ol(Ne,we)&&Ft(we)})},Ys=function(Y,ce){let Ne=!1;return cr(t.removed,we=>{we.element&&(Ne=Ne||we.element===Y,Ks(we.element))}),$n(Y,ce),Ne},Xs=8,ys=function(Y,ce){const Ne=le;let we=null;const Ye=()=>(we||(we=vf(),cr(ce,nt=>{yf(we,nt)})),we);for(let nt=0;;nt++){const xt=fn(Y),pn=[Y];let js=!1;if(cr(xt,bn=>{H(bn)===jn.documentFragment?Rl(pn,bn):!js&&!Ol(Ne,bn)&&(js=Ol(Ye(),bn))}),!js)return;if(nt>=Xs)throw ur("the tree kept changing during in-place sanitization; refusing to return it");cr(pn,(bn,Pn)=>{la(bn,Pn>0,Y,Ye())})}},la=function(Y,ce,Ne,we){const Ye=bs(Y);let nt;for(;nt=Ye.nextNode();)!Ol(we,nt)||Ol(le,nt)||(ce&&pt(re.uponSanitizeShadowNode,nt,null),Ze(nt,Ne),Ji(nt,Ne),ks(nt.content)&&ua(nt.content))},Nr=function(Y){le&&yf(le,Y)},Oi=function(Y,ce){return Rn?Y==="patchsrc"?!0:Y==="for"&&ce!=="label"&&ce!=="output":!1},wr=function(Y){Rn&&Jn(Y,ce=>{const Ne=H(ce);if(Ne===jn.processingInstruction||Ne===jn.comment&&qn(wb,ce.data)){try{x(ce)}catch{}return!1}if(Ne===jn.element){const we=ce,Ye=zt(B(ce));try{we.hasAttribute&&we.hasAttribute("patchsrc")&&we.removeAttribute("patchsrc"),we.hasAttribute&&we.hasAttribute("for")&&Oi("for",Ye)&&we.removeAttribute("for")}catch{}}return!0})},ls=function(Y){let ce=null,Ne=null;if(rs)Y="<remove></remove>"+Y;else{const nt=pb(Y,/^[\r\n\t ]+/);Ne=nt&&nt[0]}vs==="application/xhtml+xml"&&St===yt&&(Y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+Y+"</body></html>");const we=F?V(Y):Y;if(St===yt)try{ce=new h().parseFromString(we,vs)}catch{}if(!ce||!ce.documentElement){ce=G.createDocument(St,"template",null);try{ce.documentElement.innerHTML=Xn?L:we}catch{}}const Ye=ce.body||ce.documentElement;return Y&&Ne&&Ye.insertBefore(s.createTextNode(Ne),Ye.childNodes[0]||null),St===yt?ee.call(ce,mn?"html":"body")[0]:mn?ce.documentElement:Ye},bs=function(Y){const ce=P?P(Y):Y.ownerDocument;return K.call(ce||Y,Y,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},In=function(Y){return Y=Pl(Y,ie," "),Y=Pl(Y,ne," "),Y=Pl(Y,me," "),Y},Qs=function(Y){var ce;wt(Y);const Ne=(ce=Y.querySelectorAll)===null||ce===void 0?void 0:ce.call(Y,"template");Ne&&cr(Ne,we=>{ks(we.content)&&Qs(we.content)})},wt=function(Y){Y.normalize();const ce=P?P(Y):Y.ownerDocument,Ne=K.call(ce||Y,Y,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let we=Ne.nextNode();for(;we;)we.data=In(we.data),we=Ne.nextNode()},at=function(Y){const ce=O?O(Y):null;return typeof ce!="string"||zt(ce)!=="form"?!1:typeof Y.nodeName!="string"||typeof Y.textContent!="string"||typeof Y.removeChild!="function"||Y.attributes!==S(Y)||typeof Y.removeAttribute!="function"||typeof Y.removeAttributeNode!="function"||typeof Y.getAttributeNode!="function"||typeof Y.setAttribute!="function"||typeof Y.namespaceURI!="string"||typeof Y.insertBefore!="function"||typeof Y.hasChildNodes!="function"||Y.nodeType!==E(Y)||Y.childNodes!==y(Y)},ks=function(Y){if(!E||typeof Y!="object"||Y===null)return!1;try{return E(Y)===jn.documentFragment}catch{return!1}},Bt=function(Y){if(!E||typeof Y!="object"||Y===null)return!1;try{return typeof E(Y)=="number"}catch{return!1}};function pt(Ee,Y,ce){Ee.length!==0&&cr(Ee,Ne=>{Ne.call(t,Y,ce,Os)})}const Xi=function(Y,ce){return!!(Rn&&Y.hasChildNodes()&&!Bt(Y.firstElementChild)&&qn(Sf,Y.textContent)&&qn(Sf,Y.innerHTML)||Rn&&cP[ce]&&H(Y)===jn.element&&M(Y)===yt&&(Bt(Y.firstElementChild)||typeof Y.textContent=="string"&&qn(Sf,Y.textContent))||Y.nodeType===jn.processingInstruction||Rn&&Y.nodeType===jn.comment&&qn(wb,Y.data))},cs=function(Y,ce){if(Y instanceof RegExp)return qn(Y,ce);if(Y instanceof Function){for(var Ne=arguments.length,we=new Array(Ne>2?Ne-2:0),Ye=2;Ye<Ne;Ye++)we[Ye-2]=arguments[Ye];return!!Y(ce,...we)}return!1},Qi=function(Y,ce,Ne){if(!Rt[ce]&&Vt(ce)&&cs(gt.tagNameCheck,ce))return!1;if(Yn&&!de[ce]&&!de[_a(ce)]){const we=k(Y),Ye=y(Y);if(Ye&&we){const nt=Ye.length;for(let xt=nt-1;xt>=0;--xt){const pn=Y===Ne?g(Ye[xt],!0):Ye[xt];we.insertBefore(pn,j(Y))}}}return Ve(Y),!0},fi=function(Y,ce,Ne,we){return Y.length===0?ce:ce===Ne||ce===we?Fs(ce):ce},Le=function(Y,ce){return Y===ce||k(Y)!==null?!1:(On&&Ks(Y),!0)},Ze=function(Y,ce){if(Nr(Y),pt(re.beforeSanitizeElements,Y,null),Le(Y,ce))return!0;if(at(Y))return Ve(Y),!0;const Ne=zt(B(Y));if(Ae=fi(re.uponSanitizeElement,Ae,be,Gs),pt(re.uponSanitizeElement,Y,{tagName:Ne,allowedTags:Ae}),Le(Y,ce))return!0;if(Xi(Y,Ne))return Ve(Y),!0;if(Rt[Ne]||!(rt.tagCheck instanceof Function&&rt.tagCheck(Ne))&&!Ae[Ne]){const we=Qi(Y,Ne,ce);return we===!1&&(pt(re.afterSanitizeElements,Y,null),Le(Y,ce))?!0:we}if(H(Y)===jn.element&&!Pe(Y)||(Ne==="noscript"||Ne==="noembed"||Ne==="noframes")&&qn(lP,Y.innerHTML))return Ve(Y),!0;if(Ut&&Y.nodeType===jn.text){const we=In(Y.textContent);Y.textContent!==we&&(Rl(t.removed,{element:Y.cloneNode()}),Y.textContent=we)}return pt(re.afterSanitizeElements,Y,null),Le(Y,ce)},ot=function(Y,ce,Ne){if(En[ce]||Oi(ce,Y)||Kn&&(ce==="id"||ce==="name")&&(Ne in s||Ne in os))return!1;const we=qe[ce]||rt.attributeCheck instanceof Function&&rt.attributeCheck(ce,Y);return rn&&qn(Ce,ce)||Pt&&qn(Fe,ce)?!0:we?Nt[ce]||qn(ge,Pl(Ne,fe,""))||(ce==="src"||ce==="xlink:href"||ce==="href")&&Y!=="script"&&gb(Ne,"data:")===0&&Be[Y]||Zt&&!qn(Me,Pl(Ne,fe,""))?!0:!Ne:Vt(Y)&&cs(gt.tagNameCheck,Y)&&cs(gt.attributeNameCheck,ce,Y)||ce==="is"&>.allowCustomizedBuiltInElements&&cs(gt.tagNameCheck,Ne)},jt=Ct({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Vt=function(Y){return!jt[_a(Y)]&&qn(ke,Y)},yn=function(Y,ce,Ne,we){if(F&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ne)switch(m.getAttributeType(Y,ce)){case"TrustedHTML":return V(we);case"TrustedScriptURL":return U(we)}return we},rl=function(Y,ce,Ne,we){try{return Ne?Y.setAttributeNS(Ne,ce,we):Y.setAttribute(ce,we),at(Y)?(Ve(Y),!1):!0}catch{return Ot(ce,Y),!1}},ca=function(Y,ce){return Rn&&qn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ce)?!0:_a(Y)==="attributename"&&pb(ce,"href")!==null},Ji=function(Y,ce){if(pt(re.beforeSanitizeAttributes,Y,null),Le(Y,ce))return;const Ne=Y.attributes;if(!Ne||at(Y))return;qe=fi(re.uponSanitizeAttribute,qe,ft,ps);const we={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:qe,forceKeepAttr:void 0};let Ye=Ne.length;const nt=zt(Y.nodeName);for(;Ye--;){const xt=Ne[Ye],pn=xt.name,js=xt.namespaceURI,bn=xt.value,Pn=zt(pn),er=bn;let an=pn==="value"?er:ZO(er),Xa=!1;if(we.attrName=Pn,we.attrValue=an,we.keepAttr=!0,we.forceKeepAttr=void 0,pt(re.uponSanitizeAttribute,Y,we),an=we.attrValue,Zn&&(Pn==="id"||Pn==="name")&&gb(an,An)!==0&&(Ot(pn,Y,xt),an=An+an,Xa=!0),ca(pn,an)){Ot(pn,Y,xt);continue}if(!we.forceKeepAttr){if(!we.keepAttr){Ot(pn,Y,xt);continue}if(!Qt&&qn(Sb,an)){Ot(pn,Y,xt);continue}if(Ut&&(an=In(an)),!ot(nt,Pn,an)){Ot(pn,Y,xt);continue}an=yn(nt,Pn,js,an),an!==er&&rl(Y,pn,js,an)&&Xa&&fb(t.removed)}}pt(re.afterSanitizeAttributes,Y,null),Le(Y,ce)},ua=function(Y){let ce=null;const Ne=bs(Y);for(pt(re.beforeSanitizeShadowDOM,Y,null);ce=Ne.nextNode();)if(pt(re.uponSanitizeShadowNode,ce,null),Ze(ce,Y),Ji(ce,Y),ks(ce.content)&&ua(ce.content),H(ce)===jn.element){const we=_(ce);ks(we)&&(Ya(we),ua(we))}Ut&&wt(Y),pt(re.afterSanitizeShadowDOM,Y,null)},Ya=function(Y){const ce=[{node:Y,shadow:null}];for(;ce.length>0;){const Ne=ce.pop();if(Ne.shadow){ua(Ne.shadow);continue}const we=Ne.node,Ye=H(we)===jn.element,nt=y(we);if(nt)for(let xt=nt.length-1;xt>=0;--xt)ce.push({node:nt[xt],shadow:null});if(Ye){const xt=O?O(we):null;if(typeof xt=="string"&&zt(xt)==="template"){const pn=we.content;ks(pn)&&ce.push({node:pn,shadow:null})}}if(Ye){const xt=_(we);ks(xt)&&ce.push({node:null,shadow:xt},{node:xt,shadow:null})}}};return t.sanitize=function(Ee){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ce=null,Ne=null,we=null,Ye=null;if(Xn=!Ee,Xn&&(Ee="<!-->"),typeof Ee!="string"&&!Bt(Ee)&&(Ee=GO(Ee),typeof Ee!="string"))throw ur("dirty is not a string, aborting");if(!t.isSupported)return Ee;Hn?(Ae=Gs,qe=ps):hi(Y),(re.uponSanitizeElement.length>0||re.uponSanitizeAttribute.length>0)&&(Ae=Fs(Ae)),re.uponSanitizeAttribute.length>0&&(qe=Fs(qe)),t.removed=[];const nt=On&&typeof Ee!="string"&&Bt(Ee);let xt=[];const pn=le;if(nt){wr(Ee);const Pn=B(Ee);if(typeof Pn=="string"){const er=zt(Pn);if(!Ae[er]||Rt[er])throw mt(Ee),ur("root node is forbidden and cannot be sanitized in-place")}if(at(Ee))throw mt(Ee),ur("root node is clobbered and cannot be sanitized in-place");xt=fn(Ee),le=vf()}else if(Bt(Ee))ce=ls("<!---->"),Ne=ce.ownerDocument.importNode(Ee,!0),Ne.nodeType===jn.element&&Ne.nodeName==="BODY"||Ne.nodeName==="HTML"?ce=Ne:ce.appendChild(Ne),Ya(ce);else{if(!gs&&!Ut&&!mn&&Ee.indexOf("<")===-1)return F&&as?V(Ee):Ee;if(ce=ls(Ee),!ce)return gs?null:as?L:""}ce&&rs&&Ve(ce.firstChild);const js=nt?Ee:ce;try{nt&&Ya(Ee);const Pn=bs(js);for(;we=Pn.nextNode();)Ze(we,js),Ji(we,js),ks(we.content)&&ua(we.content);nt&&ys(Ee,xt)}catch(Pn){throw nt&&(mt(Ee),Ys(Ee,xt)),Pn}finally{le=pn}if(nt){if(Ys(Ee,xt))throw ur("a node selected for removal could not be safely returned; refusing to sanitize in place");return Ut&&Qs(Ee),Ee}if(gs){if(Ut&&Qs(ce),Cn)for(Ye=Z.call(ce.ownerDocument);ce.firstChild;)Ye.appendChild(ce.firstChild);else Ye=ce;return(qe.shadowroot||qe.shadowrootmode)&&(Ye=J.call(i,Ye,!0)),Ye}let bn=mn?ce.outerHTML:ce.innerHTML;return mn&&Ae["!doctype"]&&ce.ownerDocument&&ce.ownerDocument.doctype&&ce.ownerDocument.doctype.name&&qn(aP,ce.ownerDocument.doctype.name)&&(bn="<!DOCTYPE "+ce.ownerDocument.doctype.name+`>
|
|
130
|
-
`+bn),Ut&&(bn=In(bn)),F&&as?V(bn):bn},t.setConfig=function(){let Ee=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hi(Ee),Hn=!0,Gs=Ae,ps=qe},t.clearConfig=function(){Os=null,Hn=!1,Gs=null,ps=null,F=A,L=""},t.isValidAttribute=function(Ee,Y,ce){Os||hi({});const Ne=zt(Ee),we=zt(Y);return typeof ce=="string"&&(ca(Y,ce)||!Qt&&qn(Sb,ce))?!1:ot(Ne,we,ce)},t.addHook=function(Ee,Y){typeof Y=="function"&&Is(re,Ee)&&Rl(re[Ee],Y)},t.removeHook=function(Ee,Y){if(Is(re,Ee)){if(Y!==void 0){const ce=UO(re[Ee],Y);return ce===-1?void 0:HO(re[Ee],ce,1)[0]}return fb(re[Ee])}},t.removeHooks=function(Ee){Is(re,Ee)&&(re[Ee]=[])},t.removeAllHooks=function(){re=_b()},t}var Yg=Sw();function Xg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ga=Xg();function _w(e){Ga=e}var lc={exec:()=>null};function It(e,t=""){let s=typeof e=="string"?e:e.source,i={replace:(r,o)=>{let l=typeof o=="string"?o:o.source;return l=l.replace(fs.caret,"$1"),s=s.replace(r,l),i},getRegex:()=>new RegExp(s,t)};return i}var hP=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),fs={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")},mP=/^(?:[ \t]*(?:\n|$))+/,fP=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,pP=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Uc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,gP=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Qg=/(?:[*+-]|\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=It(Ew).replace(/bull/g,Qg).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(),xP=It(Ew).replace(/bull/g,Qg).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(),Jg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,vP=/^[^\n]+/,ex=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,yP=It(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",ex).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),bP=It(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Qg).getRegex(),oh="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",tx=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,kP=It("^ {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",tx).replace("tag",oh).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Aw=It(Jg).replace("hr",Uc).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",oh).getRegex(),jP=It(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Aw).getRegex(),nx={blockquote:jP,code:fP,def:yP,fences:pP,heading:gP,hr:Uc,html:kP,lheading:Cw,list:bP,newline:mP,paragraph:Aw,table:lc,text:vP},Eb=It("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Uc).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",oh).getRegex(),NP={...nx,lheading:xP,table:Eb,paragraph:It(Jg).replace("hr",Uc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Eb).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",oh).getRegex()},wP={...nx,html:It(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",tx).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:lc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:It(Jg).replace("hr",Uc).replace("heading",` *#{1,6} *[^
|
|
131
|
-
]`).replace("lheading",Cw).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},SP=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,_P=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$w=/^( {2,}|\\)\n(?!\s*$)/,EP=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,lh=/[\p{P}\p{S}]/u,sx=/[\s\p{P}\p{S}]/u,Iw=/[^\s\p{P}\p{S}]/u,CP=It(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,sx).getRegex(),Tw=/(?!~)[\p{P}\p{S}]/u,AP=/(?!~)[\s\p{P}\p{S}]/u,$P=/(?:[^\s\p{P}\p{S}]|~)/u,IP=It(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",hP?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Mw=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,TP=It(Mw,"u").replace(/punct/g,lh).getRegex(),MP=It(Mw,"u").replace(/punct/g,Tw).getRegex(),Rw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",RP=It(Rw,"gu").replace(/notPunctSpace/g,Iw).replace(/punctSpace/g,sx).replace(/punct/g,lh).getRegex(),OP=It(Rw,"gu").replace(/notPunctSpace/g,$P).replace(/punctSpace/g,AP).replace(/punct/g,Tw).getRegex(),PP=It("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Iw).replace(/punctSpace/g,sx).replace(/punct/g,lh).getRegex(),LP=It(/\\(punct)/,"gu").replace(/punct/g,lh).getRegex(),zP=It(/^<(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(),DP=It(tx).replace("(?:-->|$)","-->").getRegex(),FP=It("^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",DP).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Md=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,UP=It(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Md).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ow=It(/^!?\[(label)\]\[(ref)\]/).replace("label",Md).replace("ref",ex).getRegex(),Pw=It(/^!?\[(ref)\](?:\[\])?/).replace("ref",ex).getRegex(),BP=It("reflink|nolink(?!\\()","g").replace("reflink",Ow).replace("nolink",Pw).getRegex(),Cb=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ix={_backpedal:lc,anyPunctuation:LP,autolink:zP,blockSkip:IP,br:$w,code:_P,del:lc,emStrongLDelim:TP,emStrongRDelimAst:RP,emStrongRDelimUnd:PP,escape:SP,link:UP,nolink:Pw,punctuation:CP,reflink:Ow,reflinkSearch:BP,tag:FP,text:EP,url:lc},HP={...ix,link:It(/^!?\[(label)\]\((.*?)\)/).replace("label",Md).getRegex(),reflink:It(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Md).getRegex()},Hp={...ix,emStrongRDelimAst:OP,emStrongLDelim:MP,url:It(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Cb).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:It(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Cb).getRegex()},ZP={...Hp,br:It($w).replace("{2,}","*").getRegex(),text:It(Hp.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ed={normal:nx,gfm:NP,pedantic:wP},zl={normal:ix,gfm:Hp,breaks:ZP,pedantic:HP},WP={"&":"&","<":"<",">":">",'"':""","'":"'"},Ab=e=>WP[e];function Ui(e,t){if(t){if(fs.escapeTest.test(e))return e.replace(fs.escapeReplace,Ab)}else if(fs.escapeTestNoEncode.test(e))return e.replace(fs.escapeReplaceNoEncode,Ab);return e}function $b(e){try{e=encodeURI(e).replace(fs.percentDecode,"%")}catch{return null}return e}function Ib(e,t){var o;let s=e.replace(fs.findPipe,(l,u,d)=>{let h=!1,m=u;for(;--m>=0&&d[m]==="\\";)h=!h;return h?"|":" |"}),i=s.split(fs.splitPipe),r=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(fs.slashPipe,"|");return i}function Dl(e,t,s){let i=e.length;if(i===0)return"";let r=0;for(;r<i&&e.charAt(i-r-1)===t;)r++;return e.slice(0,i-r)}function VP(e,t){if(e.indexOf(t[1])===-1)return-1;let s=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])s++;else if(e[i]===t[1]&&(s--,s<0))return i;return s>0?-2:-1}function Tb(e,t,s,i,r){let o=t.href,l=t.title||null,u=e[1].replace(r.other.outputLinkReplace,"$1");i.state.inLink=!0;let d={type:e[0].charAt(0)==="!"?"image":"link",raw:s,href:o,title:l,text:u,tokens:i.inlineTokens(u)};return i.state.inLink=!1,d}function qP(e,t,s){let i=e.match(s.other.indentCodeCompensation);if(i===null)return t;let r=i[1];return t.split(`
|
|
132
|
-
`).map(o=>{let l=o.match(s.other.beginningSpace);if(l===null)return o;let[u]=l;return u.length>=r.length?o.slice(r.length):o}).join(`
|
|
133
|
-
`)}var Rd=class{constructor(e){ht(this,"options");ht(this,"rules");ht(this,"lexer");this.options=e||Ga}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 s=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?s:Dl(s,`
|
|
134
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let s=t[0],i=qP(s,t[3]||"",this.rules);return{type:"code",raw:s,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let s=t[2].trim();if(this.rules.other.endingHash.test(s)){let i=Dl(s,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(s=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Dl(t[0],`
|
|
135
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let s=Dl(t[0],`
|
|
136
|
-
`).split(`
|
|
137
|
-
`),i="",r="",o=[];for(;s.length>0;){let l=!1,u=[],d;for(d=0;d<s.length;d++)if(this.rules.other.blockquoteStart.test(s[d]))u.push(s[d]),l=!0;else if(!l)u.push(s[d]);else break;s=s.slice(d);let h=u.join(`
|
|
138
|
-
`),m=h.replace(this.rules.other.blockquoteSetextReplace,`
|
|
139
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
|
|
140
|
-
${h}`:h,r=r?`${r}
|
|
141
|
-
${m}`:m;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(m,o,!0),this.lexer.state.top=p,s.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 x=g,N=x.raw+`
|
|
142
|
-
`+s.join(`
|
|
143
|
-
`),j=this.blockquote(N);o[o.length-1]=j,i=i.substring(0,i.length-x.raw.length)+j.raw,r=r.substring(0,r.length-x.text.length)+j.text;break}else if((g==null?void 0:g.type)==="list"){let x=g,N=x.raw+`
|
|
144
|
-
`+s.join(`
|
|
145
|
-
`),j=this.list(N);o[o.length-1]=j,i=i.substring(0,i.length-g.raw.length)+j.raw,r=r.substring(0,r.length-x.raw.length)+j.raw,s=N.substring(o.at(-1).raw.length).split(`
|
|
146
|
-
`);continue}}return{type:"blockquote",raw:i,tokens:o,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),i=s.length>1,r={type:"list",raw:"",ordered:i,start:i?+s.slice(0,-1):"",loose:!1,items:[]};s=i?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=i?s:"[*+-]");let o=this.rules.other.listItemRegex(s),l=!1;for(;e;){let d=!1,h="",m="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let p=t[2].split(`
|
|
147
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,k=>" ".repeat(3*k.length)),g=e.split(`
|
|
148
|
-
`,1)[0],x=!p.trim(),N=0;if(this.options.pedantic?(N=2,m=p.trimStart()):x?N=t[1].length+1:(N=t[2].search(this.rules.other.nonSpaceChar),N=N>4?1:N,m=p.slice(N),N+=t[1].length),x&&this.rules.other.blankLine.test(g)&&(h+=g+`
|
|
149
|
-
`,e=e.substring(g.length+1),d=!0),!d){let k=this.rules.other.nextBulletRegex(N),_=this.rules.other.hrRegex(N),S=this.rules.other.fencesBeginRegex(N),E=this.rules.other.headingBeginRegex(N),O=this.rules.other.htmlBeginRegex(N);for(;e;){let P=e.split(`
|
|
150
|
-
`,1)[0],H;if(g=P,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),H=g):H=g.replace(this.rules.other.tabCharGlobal," "),S.test(g)||E.test(g)||O.test(g)||k.test(g)||_.test(g))break;if(H.search(this.rules.other.nonSpaceChar)>=N||!g.trim())m+=`
|
|
151
|
-
`+H.slice(N);else{if(x||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(p)||E.test(p)||_.test(p))break;m+=`
|
|
152
|
-
`+g}!x&&!g.trim()&&(x=!0),h+=P+`
|
|
153
|
-
`,e=e.substring(P.length+1),p=H.slice(N)}}r.loose||(l?r.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(l=!0));let j=null,y;this.options.gfm&&(j=this.rules.other.listIsTask.exec(m),j&&(y=j[0]!=="[ ] ",m=m.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:h,task:!!j,checked:y,loose:!1,text:m,tokens:[]}),r.raw+=h}let u=r.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let d=0;d<r.items.length;d++)if(this.lexer.state.top=!1,r.items[d].tokens=this.lexer.blockTokens(r.items[d].text,[]),!r.loose){let h=r.items[d].tokens.filter(p=>p.type==="space"),m=h.length>0&&h.some(p=>this.rules.other.anyLine.test(p.raw));r.loose=m}if(r.loose)for(let d=0;d<r.items.length;d++)r.items[d].loose=!0;return r}}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 s=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:s,raw:t[0],href:i,title:r}}}table(e){var l;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let s=Ib(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=(l=t[3])!=null&&l.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
154
|
-
`):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(s.length===i.length){for(let u of i)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<s.length;u++)o.header.push({text:s[u],tokens:this.lexer.inline(s[u]),header:!0,align:o.align[u]});for(let u of r)o.rows.push(Ib(u,o.header.length).map((d,h)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:o.align[h]})));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 s=t[1].charAt(t[1].length-1)===`
|
|
155
|
-
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:s,tokens:this.lexer.inline(s)}}}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 s=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(s)){if(!this.rules.other.endAngleBracket.test(s))return;let o=Dl(s.slice(0,-1),"\\");if((s.length-o.length)%2===0)return}else{let o=VP(t[2],"()");if(o===-2)return;if(o>-1){let l=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,l).trim(),t[3]=""}}let i=t[2],r="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(s)?i=i.slice(1):i=i.slice(1,-1)),Tb(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let s;if((s=this.rules.inline.reflink.exec(e))||(s=this.rules.inline.nolink.exec(e))){let i=(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[i.toLowerCase()];if(!r){let o=s[0].charAt(0);return{type:"text",raw:o,text:o}}return Tb(s,r,s[0],this.lexer,this.rules)}}emStrong(e,t,s=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!s||this.rules.inline.punctuation.exec(s))){let r=[...i[0]].length-1,o,l,u=r,d=0,h=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*e.length+r);(i=h.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(l=[...o].length,i[3]||i[4]){u+=l;continue}else if((i[5]||i[6])&&r%3&&!((r+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);let m=[...i[0]][0].length,p=e.slice(0,r+i.index+m+l);if(Math.min(r,l)%2){let x=p.slice(1,-1);return{type:"em",raw:p,text:x,tokens:this.lexer.inlineTokens(x)}}let g=p.slice(2,-2);return{type:"strong",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let s=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(s),r=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return i&&r&&(s=s.substring(1,s.length-1)),{type:"codespan",raw:t[0],text:s}}}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 s,i;return t[2]==="@"?(s=t[1],i="mailto:"+s):(s=t[1],i=s),{type:"link",raw:t[0],text:s,href:i,tokens:[{type:"text",raw:s,text:s}]}}}url(e){var s;let t;if(t=this.rules.inline.url.exec(e)){let i,r;if(t[2]==="@")i=t[0],r="mailto:"+i;else{let o;do o=t[0],t[0]=((s=this.rules.inline._backpedal.exec(t[0]))==null?void 0:s[0])??"";while(o!==t[0]);i=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:i,href:r,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let s=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:s}}}},Ni=class Zp{constructor(t){ht(this,"tokens");ht(this,"options");ht(this,"state");ht(this,"tokenizer");ht(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ga,this.options.tokenizer=this.options.tokenizer||new Rd,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 s={other:fs,block:ed.normal,inline:zl.normal};this.options.pedantic?(s.block=ed.pedantic,s.inline=zl.pedantic):this.options.gfm&&(s.block=ed.gfm,this.options.breaks?s.inline=zl.breaks:s.inline=zl.gfm),this.tokenizer.rules=s}static get rules(){return{block:ed,inline:zl}}static lex(t,s){return new Zp(s).lex(t)}static lexInline(t,s){return new Zp(s).inlineTokens(t)}lex(t){t=t.replace(fs.carriageReturn,`
|
|
156
|
-
`),this.blockTokens(t,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){let i=this.inlineQueue[s];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,s=[],i=!1){var r,o,l;for(this.options.pedantic&&(t=t.replace(fs.tabCharGlobal," ").replace(fs.spaceLine,""));t;){let u;if((o=(r=this.options.extensions)==null?void 0:r.block)!=null&&o.some(h=>(u=h.call({lexer:this},t,s))?(t=t.substring(u.raw.length),s.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let h=s.at(-1);u.raw.length===1&&h!==void 0?h.raw+=`
|
|
157
|
-
`:s.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let h=s.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
|
|
158
|
-
`)?"":`
|
|
159
|
-
`)+u.raw,h.text+=`
|
|
160
|
-
`+u.text,this.inlineQueue.at(-1).src=h.text):s.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let h=s.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
|
|
161
|
-
`)?"":`
|
|
162
|
-
`)+u.raw,h.text+=`
|
|
163
|
-
`+u.raw,this.inlineQueue.at(-1).src=h.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},s.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),s.push(u);continue}let d=t;if((l=this.options.extensions)!=null&&l.startBlock){let h=1/0,m=t.slice(1),p;this.options.extensions.startBlock.forEach(g=>{p=g.call({lexer:this},m),typeof p=="number"&&p>=0&&(h=Math.min(h,p))}),h<1/0&&h>=0&&(d=t.substring(0,h+1))}if(this.state.top&&(u=this.tokenizer.paragraph(d))){let h=s.at(-1);i&&(h==null?void 0:h.type)==="paragraph"?(h.raw+=(h.raw.endsWith(`
|
|
164
|
-
`)?"":`
|
|
165
|
-
`)+u.raw,h.text+=`
|
|
166
|
-
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):s.push(u),i=d.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let h=s.at(-1);(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
|
|
167
|
-
`)?"":`
|
|
168
|
-
`)+u.raw,h.text+=`
|
|
169
|
-
`+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):s.push(u);continue}if(t){let h="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return this.state.top=!0,s}inline(t,s=[]){return this.inlineQueue.push({src:t,tokens:s}),s}inlineTokens(t,s=[]){var d,h,m,p,g;let i=t,r=null;if(this.tokens.links){let x=Object.keys(this.tokens.links);if(x.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)x.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,r.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)o=r[2]?r[2].length:0,i=i.slice(0,r.index+o)+"["+"a".repeat(r[0].length-o-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((h=(d=this.options.hooks)==null?void 0:d.emStrongMask)==null?void 0:h.call({lexer:this},i))??i;let l=!1,u="";for(;t;){l||(u=""),l=!1;let x;if((p=(m=this.options.extensions)==null?void 0:m.inline)!=null&&p.some(j=>(x=j.call({lexer:this},t,s))?(t=t.substring(x.raw.length),s.push(x),!0):!1))continue;if(x=this.tokenizer.escape(t)){t=t.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.tag(t)){t=t.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.link(t)){t=t.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(x.raw.length);let j=s.at(-1);x.type==="text"&&(j==null?void 0:j.type)==="text"?(j.raw+=x.raw,j.text+=x.text):s.push(x);continue}if(x=this.tokenizer.emStrong(t,i,u)){t=t.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.codespan(t)){t=t.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.br(t)){t=t.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.del(t)){t=t.substring(x.raw.length),s.push(x);continue}if(x=this.tokenizer.autolink(t)){t=t.substring(x.raw.length),s.push(x);continue}if(!this.state.inLink&&(x=this.tokenizer.url(t))){t=t.substring(x.raw.length),s.push(x);continue}let N=t;if((g=this.options.extensions)!=null&&g.startInline){let j=1/0,y=t.slice(1),k;this.options.extensions.startInline.forEach(_=>{k=_.call({lexer:this},y),typeof k=="number"&&k>=0&&(j=Math.min(j,k))}),j<1/0&&j>=0&&(N=t.substring(0,j+1))}if(x=this.tokenizer.inlineText(N)){t=t.substring(x.raw.length),x.raw.slice(-1)!=="_"&&(u=x.raw.slice(-1)),l=!0;let j=s.at(-1);(j==null?void 0:j.type)==="text"?(j.raw+=x.raw,j.text+=x.text):s.push(x);continue}if(t){let j="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(j);break}else throw new Error(j)}}return s}},Od=class{constructor(e){ht(this,"options");ht(this,"parser");this.options=e||Ga}space(e){return""}code({text:e,lang:t,escaped:s}){var o;let i=(o=(t||"").match(fs.notSpaceStart))==null?void 0:o[0],r=e.replace(fs.endingNewline,"")+`
|
|
170
|
-
`;return i?'<pre><code class="language-'+Ui(i)+'">'+(s?r:Ui(r,!0))+`</code></pre>
|
|
171
|
-
`:"<pre><code>"+(s?r:Ui(r,!0))+`</code></pre>
|
|
172
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
173
|
-
${this.parser.parse(e)}</blockquote>
|
|
174
|
-
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
175
|
-
`}hr(e){return`<hr>
|
|
176
|
-
`}list(e){let t=e.ordered,s=e.start,i="";for(let l=0;l<e.items.length;l++){let u=e.items[l];i+=this.listitem(u)}let r=t?"ol":"ul",o=t&&s!==1?' start="'+s+'"':"";return"<"+r+o+`>
|
|
177
|
-
`+i+"</"+r+`>
|
|
178
|
-
`}listitem(e){var s;let t="";if(e.task){let i=this.checkbox({checked:!!e.checked});e.loose?((s=e.tokens[0])==null?void 0:s.type)==="paragraph"?(e.tokens[0].text=i+" "+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=i+" "+Ui(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:i+" ",text:i+" ",escaped:!0}):t+=i+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
|
|
179
|
-
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
180
|
-
`}table(e){let t="",s="";for(let r=0;r<e.header.length;r++)s+=this.tablecell(e.header[r]);t+=this.tablerow({text:s});let i="";for(let r=0;r<e.rows.length;r++){let o=e.rows[r];s="";for(let l=0;l<o.length;l++)s+=this.tablecell(o[l]);i+=this.tablerow({text:s})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
|
|
181
|
-
<thead>
|
|
182
|
-
`+t+`</thead>
|
|
183
|
-
`+i+`</table>
|
|
184
|
-
`}tablerow({text:e}){return`<tr>
|
|
185
|
-
${e}</tr>
|
|
186
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),s=e.header?"th":"td";return(e.align?`<${s} align="${e.align}">`:`<${s}>`)+t+`</${s}>
|
|
187
|
-
`}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>${Ui(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:s}){let i=this.parser.parseInline(s),r=$b(e);if(r===null)return i;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ui(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:s,tokens:i}){i&&(s=this.parser.parseInline(i,this.parser.textRenderer));let r=$b(e);if(r===null)return Ui(s);e=r;let o=`<img src="${e}" alt="${s}"`;return t&&(o+=` title="${Ui(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ui(e.text)}},rx=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""}},wi=class Wp{constructor(t){ht(this,"options");ht(this,"renderer");ht(this,"textRenderer");this.options=t||Ga,this.options.renderer=this.options.renderer||new Od,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new rx}static parse(t,s){return new Wp(s).parse(t)}static parseInline(t,s){return new Wp(s).parseInline(t)}parse(t,s=!0){var r,o;let i="";for(let l=0;l<t.length;l++){let u=t[l];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[u.type]){let h=u,m=this.options.extensions.renderers[h.type].call({parser:this},h);if(m!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(h.type)){i+=m||"";continue}}let d=u;switch(d.type){case"space":{i+=this.renderer.space(d);continue}case"hr":{i+=this.renderer.hr(d);continue}case"heading":{i+=this.renderer.heading(d);continue}case"code":{i+=this.renderer.code(d);continue}case"table":{i+=this.renderer.table(d);continue}case"blockquote":{i+=this.renderer.blockquote(d);continue}case"list":{i+=this.renderer.list(d);continue}case"html":{i+=this.renderer.html(d);continue}case"def":{i+=this.renderer.def(d);continue}case"paragraph":{i+=this.renderer.paragraph(d);continue}case"text":{let h=d,m=this.renderer.text(h);for(;l+1<t.length&&t[l+1].type==="text";)h=t[++l],m+=`
|
|
188
|
-
`+this.renderer.text(h);s?i+=this.renderer.paragraph({type:"paragraph",raw:m,text:m,tokens:[{type:"text",raw:m,text:m,escaped:!0}]}):i+=m;continue}default:{let h='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return i}parseInline(t,s=this.renderer){var r,o;let i="";for(let l=0;l<t.length;l++){let u=t[l];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[u.type]){let h=this.options.extensions.renderers[u.type].call({parser:this},u);if(h!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(u.type)){i+=h||"";continue}}let d=u;switch(d.type){case"escape":{i+=s.text(d);break}case"html":{i+=s.html(d);break}case"link":{i+=s.link(d);break}case"image":{i+=s.image(d);break}case"strong":{i+=s.strong(d);break}case"em":{i+=s.em(d);break}case"codespan":{i+=s.codespan(d);break}case"br":{i+=s.br(d);break}case"del":{i+=s.del(d);break}case"text":{i+=s.text(d);break}default:{let h='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return i}},xd,Xl=(xd=class{constructor(e){ht(this,"options");ht(this,"block");this.options=e||Ga}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ni.lex:Ni.lexInline}provideParser(){return this.block?wi.parse:wi.parseInline}},ht(xd,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ht(xd,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),xd),GP=class{constructor(...e){ht(this,"defaults",Xg());ht(this,"options",this.setOptions);ht(this,"parse",this.parseMarkdown(!0));ht(this,"parseInline",this.parseMarkdown(!1));ht(this,"Parser",wi);ht(this,"Renderer",Od);ht(this,"TextRenderer",rx);ht(this,"Lexer",Ni);ht(this,"Tokenizer",Rd);ht(this,"Hooks",Xl);this.use(...e)}walkTokens(e,t){var i,r;let s=[];for(let o of e)switch(s=s.concat(t.call(this,o)),o.type){case"table":{let l=o;for(let u of l.header)s=s.concat(this.walkTokens(u.tokens,t));for(let u of l.rows)for(let d of u)s=s.concat(this.walkTokens(d.tokens,t));break}case"list":{let l=o;s=s.concat(this.walkTokens(l.items,t));break}default:{let l=o;(r=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&r[l.type]?this.defaults.extensions.childTokens[l.type].forEach(u=>{let d=l[u].flat(1/0);s=s.concat(this.walkTokens(d,t))}):l.tokens&&(s=s.concat(this.walkTokens(l.tokens,t)))}}return s}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(s=>{let i={...s};if(i.async=this.defaults.async||i.async||!1,s.extensions&&(s.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let o=t.renderers[r.name];o?t.renderers[r.name]=function(...l){let u=r.renderer.apply(this,l);return u===!1&&(u=o.apply(this,l)),u}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),i.extensions=t),s.renderer){let r=this.defaults.renderer||new Od(this.defaults);for(let o in s.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let l=o,u=s.renderer[l],d=r[l];r[l]=(...h)=>{let m=u.apply(r,h);return m===!1&&(m=d.apply(r,h)),m||""}}i.renderer=r}if(s.tokenizer){let r=this.defaults.tokenizer||new Rd(this.defaults);for(let o in s.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let l=o,u=s.tokenizer[l],d=r[l];r[l]=(...h)=>{let m=u.apply(r,h);return m===!1&&(m=d.apply(r,h)),m}}i.tokenizer=r}if(s.hooks){let r=this.defaults.hooks||new Xl;for(let o in s.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let l=o,u=s.hooks[l],d=r[l];Xl.passThroughHooks.has(o)?r[l]=h=>{if(this.defaults.async&&Xl.passThroughHooksRespectAsync.has(o))return(async()=>{let p=await u.call(r,h);return d.call(r,p)})();let m=u.call(r,h);return d.call(r,m)}:r[l]=(...h)=>{if(this.defaults.async)return(async()=>{let p=await u.apply(r,h);return p===!1&&(p=await d.apply(r,h)),p})();let m=u.apply(r,h);return m===!1&&(m=d.apply(r,h)),m}}i.hooks=r}if(s.walkTokens){let r=this.defaults.walkTokens,o=s.walkTokens;i.walkTokens=function(l){let u=[];return u.push(o.call(this,l)),r&&(u=u.concat(r.call(this,l))),u}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ni.lex(e,t??this.defaults)}parser(e,t){return wi.parse(e,t??this.defaults)}parseMarkdown(e){return(t,s)=>{let i={...s},r={...this.defaults,...i},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.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(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let l=r.hooks?await r.hooks.preprocess(t):t,u=await(r.hooks?await r.hooks.provideLexer():e?Ni.lex:Ni.lexInline)(l,r),d=r.hooks?await r.hooks.processAllTokens(u):u;r.walkTokens&&await Promise.all(this.walkTokens(d,r.walkTokens));let h=await(r.hooks?await r.hooks.provideParser():e?wi.parse:wi.parseInline)(d,r);return r.hooks?await r.hooks.postprocess(h):h})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let l=(r.hooks?r.hooks.provideLexer():e?Ni.lex:Ni.lexInline)(t,r);r.hooks&&(l=r.hooks.processAllTokens(l)),r.walkTokens&&this.walkTokens(l,r.walkTokens);let u=(r.hooks?r.hooks.provideParser():e?wi.parse:wi.parseInline)(l,r);return r.hooks&&(u=r.hooks.postprocess(u)),u}catch(l){return o(l)}}}onError(e,t){return s=>{if(s.message+=`
|
|
189
|
-
Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Ui(s.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(s);throw s}}},Fa=new GP;function Tt(e,t){return Fa.parse(e,t)}Tt.options=Tt.setOptions=function(e){return Fa.setOptions(e),Tt.defaults=Fa.defaults,_w(Tt.defaults),Tt};Tt.getDefaults=Xg;Tt.defaults=Ga;Tt.use=function(...e){return Fa.use(...e),Tt.defaults=Fa.defaults,_w(Tt.defaults),Tt};Tt.walkTokens=function(e,t){return Fa.walkTokens(e,t)};Tt.parseInline=Fa.parseInline;Tt.Parser=wi;Tt.parser=wi.parse;Tt.Renderer=Od;Tt.TextRenderer=rx;Tt.Lexer=Ni;Tt.lexer=Ni.lex;Tt.Tokenizer=Rd;Tt.Hooks=Xl;Tt.parse=Tt;Tt.options;Tt.setOptions;Tt.use;Tt.walkTokens;Tt.parseInline;wi.parse;Ni.lex;const Mb=["#ff3b30","#ffcc00","#34c759","#0a84ff","#000000","#ffffff"],KP=[["rect","框"],["arrow","箭头"],["line","直线"],["pen","画笔"]],Rb=[[2,"细"],[4,"中"],[7,"粗"]],YP=.05,Ob=16,Pb=44;function ch({src:e,width:t,height:s,name:i,onClose:r}){const[o,l]=v.useState({src:e,width:t,height:s}),{src:u,width:d,height:h}=o,m=v.useRef(null),p=v.useRef(null),[g,x]=v.useState(()=>XP(t,s)),[N,j]=v.useState({scale:1,x:0,y:0}),[y,k]=v.useState(!1),[_,S]=v.useState("rect"),[E,O]=v.useState(Mb[0]),[P,H]=v.useState(Rb[0][0]),[B,R]=v.useState([]),[M,F]=v.useState(null),[L,A]=v.useState(!0),[I,z]=v.useState(null),D=v.useRef(null),V=v.useRef(null),U=v.useCallback(()=>{var ge;const fe=(ge=m.current)==null?void 0:ge.getBoundingClientRect();if(fe===void 0||fe.width===0)return;const ke=Math.min(Ob,(fe.width-24)/d,(fe.height-24)/h);j({scale:ke,x:(fe.width-d*ke)/2,y:(fe.height-h*ke)/2})},[d,h]);v.useLayoutEffect(U,[U]),v.useEffect(()=>{const fe=m.current;if(fe===null||typeof ResizeObserver>"u")return;const ke=new ResizeObserver(()=>U());return ke.observe(fe),()=>ke.disconnect()},[U]);const q=(fe,ke,ge)=>{var ft;const Ae=(ft=m.current)==null?void 0:ft.getBoundingClientRect();if(Ae===void 0)return;const be=ke??Ae.width/2,qe=ge??Ae.height/2;j(gt=>{const Rt=Math.min(Ob,Math.max(YP,gt.scale*fe)),En=Rt/gt.scale;return{scale:Rt,x:be-(be-gt.x)*En,y:qe-(qe-gt.y)*En}})},te=()=>{var ke;const fe=(ke=m.current)==null?void 0:ke.getBoundingClientRect();fe!==void 0&&j({scale:1,x:(fe.width-d)/2,y:(fe.height-h)/2})};v.useEffect(()=>{const fe=m.current;if(fe===null)return;const ke=ge=>{ge.preventDefault();const Ae=fe.getBoundingClientRect();q(Math.exp(-ge.deltaY*.0015),ge.clientX-Ae.left,ge.clientY-Ae.top)};return fe.addEventListener("wheel",ke,{passive:!1}),()=>fe.removeEventListener("wheel",ke)});const G=fe=>{z(fe),setTimeout(()=>z(ke=>ke===fe?null:ke),1800)},K=v.useCallback(async(fe,ke=0)=>{const ge=new Image;ge.src=u,await ge.decode();const Ae=document.createElement("canvas");Ae.width=d,Ae.height=h;const be=Ae.getContext("2d");be.drawImage(ge,0,0,d,h);for(const gt of fe)eL(be,gt);if(ke===0)return Ae;const qe=document.createElement("canvas");qe.width=h,qe.height=d;const ft=qe.getContext("2d");return ft.translate(h/2,d/2),ft.rotate(ke),ft.drawImage(Ae,-d/2,-h/2),qe},[u,d,h]),Z=v.useCallback(async fe=>{try{const ke=await K(fe),ge=await new Promise((Ae,be)=>ke.toBlob(qe=>qe===null?be(new Error("没能生成图片")):Ae(qe),"image/png"));try{await navigator.clipboard.write([new ClipboardItem({"image/png":ge})])}catch(Ae){const be=Vs();if((be==null?void 0:be.copyImage)===void 0)throw Ae;await be.copyImage(ke.toDataURL("image/png"))}G(fe.length>0?"已复制(带标注)":"已复制")}catch(ke){G(`复制失败:${ke instanceof Error?ke.message:String(ke)}`)}},[K]),ee=async()=>{const fe=await K(B),ke=document.createElement("a");ke.href=fe.toDataURL("image/png"),ke.download=`${i.replace(/[\\/:*?"<>|]/g,"_").replace(/\.\w+$/,"")}${B.length>0?"-标注":""}.png`,ke.click()},J=async()=>{const fe=await K(B,Math.PI/2);R([]),l({src:fe.toDataURL("image/png"),width:fe.width,height:fe.height})},re=()=>R(fe=>fe.slice(0,-1));v.useEffect(()=>{const fe=ke=>{if(!(p.current===null||!p.current.contains(document.activeElement))){if(ke.key==="Escape"){M!==null?(F(null),D.current=null):y?k(!1):r();return}if((ke.ctrlKey||ke.metaKey)&&ke.key.toLowerCase()==="z"){ke.preventDefault(),re();return}if((ke.ctrlKey||ke.metaKey)&&ke.key.toLowerCase()==="c"){ke.preventDefault(),Z(B);return}ke.key==="0"&&U(),(ke.key==="+"||ke.key==="=")&&q(1.25),ke.key==="-"&&q(.8)}};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)});const ie=fe=>{const ke=m.current.getBoundingClientRect(),ge=(fe.clientX-ke.left-N.x)/N.scale,Ae=(fe.clientY-ke.top-N.y)/N.scale;return[Math.max(0,Math.min(d,ge)),Math.max(0,Math.min(h,Ae))]},ne=fe=>{if(fe.button!==0&&fe.button!==1)return;if(fe.currentTarget.setPointerCapture(fe.pointerId),!y||fe.button===1){D.current={kind:"pan",sx:fe.clientX,sy:fe.clientY,ox:N.x,oy:N.y};return}const[ke,ge]=ie(fe),Ae=P/N.scale;D.current={kind:"mark"},F(_==="pen"?{kind:"pen",points:[[ke,ge]],color:E,width:Ae}:{kind:_,x1:ke,y1:ge,x2:ke,y2:ge,color:E,width:Ae})},me=fe=>{const ke=D.current;if(ke===null)return;if(ke.kind==="pan"){j(be=>({...be,x:ke.ox+fe.clientX-ke.sx,y:ke.oy+fe.clientY-ke.sy}));return}const[ge,Ae]=ie(fe);F(be=>be===null?be:be.kind==="pen"?{...be,points:[...be.points,[ge,Ae]]}:{...be,x2:ge,y2:Ae})},Ce=()=>{const fe=D.current;if(D.current=null,(fe==null?void 0:fe.kind)!=="mark"||M===null||(F(null),(M.kind==="pen"?M.points.length>2?99:0:Math.hypot(M.x2-M.x1,M.y2-M.y1)*N.scale)<4))return;const ge=[...B,M];R(ge),L&&Z(ge)},Fe=fe=>{if(fe.target.closest("button")!==null)return;fe.currentTarget.setPointerCapture(fe.pointerId),V.current={sx:fe.clientX,sy:fe.clientY,ox:g.x,oy:g.y};const ke=p.current;ke!==null&&x(ge=>({...ge,w:ke.offsetWidth,h:ke.offsetHeight}))},Me=fe=>{const ke=V.current;ke!==null&&x(ge=>({...ge,x:Math.max(-ge.w+120,Math.min(window.innerWidth-120,ke.ox+fe.clientX-ke.sx)),y:Math.max(0,Math.min(window.innerHeight-40,ke.oy+fe.clientY-ke.sy))}))};return v.useEffect(()=>{var fe;(fe=p.current)==null||fe.focus()},[]),qa.createPortal(n.jsxs("div",{ref:p,className:"image-viewer",role:"dialog","aria-label":i,tabIndex:-1,style:{left:g.x,top:g.y,width:g.w,height:g.h},children:[n.jsxs("div",{className:"viewer-title",onPointerDown:Fe,onPointerMove:Me,onPointerUp:()=>{V.current=null},onDoubleClick:U,children:[n.jsx("span",{className:"viewer-name",children:i}),n.jsxs("span",{className:"viewer-dim",children:[d,"×",h]}),n.jsx("button",{className:"viewer-icon",onClick:r,title:"关闭(Esc)","aria-label":"关闭",children:"✕"})]}),n.jsxs("div",{ref:m,className:`viewer-stage ${y?"marking":""}`,onPointerDown:ne,onPointerMove:me,onPointerUp:Ce,onPointerCancel:Ce,children:[n.jsxs("div",{className:"viewer-canvas",style:{width:d,height:h,transform:`translate(${N.x}px, ${N.y}px) scale(${N.scale})`},children:[n.jsx("img",{src:u,alt:i,width:d,height:h,draggable:!1}),n.jsx("svg",{viewBox:`0 0 ${d} ${h}`,width:d,height:h,"aria-hidden":"true",children:[...B,...M===null?[]:[M]].map((fe,ke)=>n.jsx(JP,{mark:fe},ke))})]}),I!==null&&n.jsx("div",{className:"viewer-toast",role:"status",children:I})]}),y&&n.jsxs("div",{className:"viewer-marks",children:[n.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"标注工具",children:KP.map(([fe,ke])=>n.jsx("button",{role:"radio","aria-checked":_===fe,className:`viewer-icon ${_===fe?"active":""}`,title:ke,onClick:()=>S(fe),children:n.jsx(QP,{tool:fe})},fe))}),n.jsx("span",{className:"viewer-sep"}),n.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"粗细",children:Rb.map(([fe,ke])=>n.jsx("button",{role:"radio","aria-checked":P===fe,className:`viewer-icon ${P===fe?"active":""}`,title:ke,onClick:()=>H(fe),children:n.jsx("span",{className:"width-dot",style:{width:fe+3,height:fe+3}})},fe))}),n.jsx("span",{className:"viewer-sep"}),n.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"颜色",children:Mb.map(fe=>n.jsx("button",{role:"radio","aria-checked":E===fe,"aria-label":fe,className:`swatch ${E===fe?"active":""}`,style:{background:fe},onClick:()=>O(fe)},fe))}),n.jsx("span",{className:"viewer-sep"}),n.jsx("button",{className:"viewer-icon",disabled:B.length===0,onClick:re,title:"撤销(Ctrl+Z)",children:"↶"}),n.jsxs("label",{className:"viewer-check",title:"每画完一笔就把带标注的图片复制到剪贴板",children:[n.jsx("input",{type:"checkbox",checked:L,onChange:fe=>A(fe.target.checked)}),"自动复制"]})]}),n.jsxs("div",{className:"viewer-bar",children:[n.jsx("button",{className:"viewer-icon",onClick:()=>q(.8),title:"缩小",children:"-"}),n.jsxs("button",{className:"viewer-zoom",onClick:U,title:"适应窗口(0)",children:[Math.round(N.scale*100),"%"]}),n.jsx("button",{className:"viewer-icon",onClick:()=>q(1.25),title:"放大",children:"+"}),n.jsx("button",{className:"viewer-icon",onClick:te,title:"原始大小",children:"1:1"}),n.jsx("span",{className:"viewer-sep"}),n.jsx("button",{className:"viewer-icon",onClick:()=>void J(),title:"旋转",children:"⟳"}),n.jsx("button",{className:`viewer-icon ${y?"active":""}`,onClick:()=>k(fe=>!fe),title:"标注:画框、箭头、直线",children:"✎"}),n.jsx("button",{className:"viewer-icon",onClick:()=>void Z(B),title:"复制(Ctrl+C)",children:"⧉"}),n.jsx("button",{className:"viewer-icon",onClick:()=>void ee(),title:"保存",children:"⤓"})]})]}),document.body)}function XP(e,t){const s=Math.round(window.innerWidth*.7),i=Math.round(window.innerHeight*.78)-Pb*2,r=Math.min(1,s/e,i/t),o=Math.max(420,Math.round(e*r)+24),l=Math.max(300,Math.round(t*r)+24+Pb*2);return{x:Math.round((window.innerWidth-o)/2),y:Math.max(16,Math.round((window.innerHeight-l)/2)),w:o,h:l}}function QP({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 n.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:n.jsx("path",{d:t})})}function Lw(e){const t=Math.atan2(e.y2-e.y1,e.x2-e.x1),s=e.width*4.5;return[-.5,.5].map(i=>[e.x2-s*Math.cos(t+i),e.y2-s*Math.sin(t+i)])}function JP({mark:e}){const t={stroke:e.color,strokeWidth:e.width,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};if(e.kind==="pen")return n.jsx("polyline",{...t,points:e.points.map(i=>i.join(",")).join(" ")});if(e.kind==="rect")return n.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 s=e.kind==="arrow"?Lw(e):[];return n.jsxs("g",{...t,children:[n.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}),s.length>0&&n.jsx("polyline",{points:`${s[0][0]},${s[0][1]} ${e.x2},${e.y2} ${s[1][0]},${s[1][1]}`})]})}function eL(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(([s,i],r)=>r===0?e.moveTo(s,i):e.lineTo(s,i));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[s,i]=Lw(t);e.moveTo(s[0],s[1]),e.lineTo(t.x2,t.y2),e.lineTo(i[0],i[1])}e.stroke()}const uh=v.createContext(null),Ef=new Map;function tL(e,t){let s=Ef.get(t.attachmentId);if(s===void 0){const{attachmentId:i,mediaType:r,bytes:o,width:l,height:u}=t;s=e.connection.call("attachments/image",{attachmentId:i,mediaType:r,bytes:o,width:l,height:u}).then(d=>`data:${d.mediaType};base64,${d.data}`),s.catch(()=>Ef.delete(t.attachmentId)),Ef.set(t.attachmentId,s)}return s}function zw({image:e}){const t=v.useContext(uh),[s,i]=v.useState(null),[r,o]=v.useState(null),[l,u]=v.useState(!1),d=(t==null?void 0:t.capabilities.get().has("attachments"))===!0;v.useEffect(()=>{if(t===null||!d)return;let m=!0;return tL(t,e).then(p=>{m&&i(p)},p=>{m&&o(p instanceof Error?p.message:String(p))}),()=>{m=!1}},[t,d,e]);const h=e.name??`${e.width}×${e.height} 图片`;return d?r!==null?n.jsxs("span",{className:"stored-image missing",children:[h,"没能加载:",r]}):s===null?n.jsx("span",{className:"stored-image loading",style:{width:e.width+2,aspectRatio:`${e.width+2} / ${e.height+2}`}}):n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"stored-image",onClick:()=>u(!0),title:"点击放大、标注、复制",children:n.jsx("img",{src:s,alt:h,width:e.width,height:e.height})}),l&&n.jsx(ch,{src:s,width:e.width,height:e.height,name:e.name??"screenshot.png",onClose:()=>u(!1)})]}):n.jsxs("span",{className:"stored-image missing",children:[h,"(当前后端不支持显示图片)"]})}var Cf,Lb;function nL(){if(Lb)return Cf;Lb=1;function e(X){return X instanceof Map?X.clear=X.delete=X.set=function(){throw new Error("map is read-only")}:X instanceof Set&&(X.add=X.clear=X.delete=function(){throw new Error("set is read-only")}),Object.freeze(X),Object.getOwnPropertyNames(X).forEach(de=>{const Se=X[de],Be=typeof Se;(Be==="object"||Be==="function")&&!Object.isFrozen(Se)&&e(Se)}),X}class t{constructor(de){de.data===void 0&&(de.data={}),this.data=de.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function s(X){return X.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function i(X,...de){const Se=Object.create(null);for(const Be in X)Se[Be]=X[Be];return de.forEach(function(Be){for(const ut in Be)Se[ut]=Be[ut]}),Se}const r="</span>",o=X=>!!X.scope,l=(X,{prefix:de})=>{if(X.startsWith("language:"))return X.replace("language:","language-");if(X.includes(".")){const Se=X.split(".");return[`${de}${Se.shift()}`,...Se.map((Be,ut)=>`${Be}${"_".repeat(ut+1)}`)].join(" ")}return`${de}${X}`};class u{constructor(de,Se){this.buffer="",this.classPrefix=Se.classPrefix,de.walk(this)}addText(de){this.buffer+=s(de)}openNode(de){if(!o(de))return;const Se=l(de.scope,{prefix:this.classPrefix});this.span(Se)}closeNode(de){o(de)&&(this.buffer+=r)}value(){return this.buffer}span(de){this.buffer+=`<span class="${de}">`}}const d=(X={})=>{const de={children:[]};return Object.assign(de,X),de};class h{constructor(){this.rootNode=d(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(de){this.top.children.push(de)}openNode(de){const Se=d({scope:de});this.add(Se),this.stack.push(Se)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(de){return this.constructor._walk(de,this.rootNode)}static _walk(de,Se){return typeof Se=="string"?de.addText(Se):Se.children&&(de.openNode(Se),Se.children.forEach(Be=>this._walk(de,Be)),de.closeNode(Se)),de}static _collapse(de){typeof de!="string"&&de.children&&(de.children.every(Se=>typeof Se=="string")?de.children=[de.children.join("")]:de.children.forEach(Se=>{h._collapse(Se)}))}}class m extends h{constructor(de){super(),this.options=de}addText(de){de!==""&&this.add(de)}startScope(de){this.openNode(de)}endScope(){this.closeNode()}__addSublanguage(de,Se){const Be=de.root;Se&&(Be.scope=`language:${Se}`),this.add(Be)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function p(X){return X?typeof X=="string"?X:X.source:null}function g(X){return j("(?=",X,")")}function x(X){return j("(?:",X,")*")}function N(X){return j("(?:",X,")?")}function j(...X){return X.map(Se=>p(Se)).join("")}function y(X){const de=X[X.length-1];return typeof de=="object"&&de.constructor===Object?(X.splice(X.length-1,1),de):{}}function k(...X){return"("+(y(X).capture?"":"?:")+X.map(Be=>p(Be)).join("|")+")"}function _(X){return new RegExp(X.toString()+"|").exec("").length-1}function S(X,de){const Se=X&&X.exec(de);return Se&&Se.index===0}const E=new RegExp(k(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function O(X,{joinWith:de}){let Se=0;return X.map(Be=>{Se+=1;const ut=Se;let Nt=p(Be),He="";for(;Nt.length>0;){const Ue=E.exec(Nt);if(!Ue){He+=Nt;break}He+=Nt.substring(0,Ue.index),Nt=Nt.substring(Ue.index+Ue[0].length),Ue[0][0]==="\\"&&Ue[1]?He+="\\"+String(Number(Ue[1])+ut):(He+=Ue[0],(Ue[0]==="("||/^\(\?[<']/.test(Ue[0]))&&Se++)}return He}).map(Be=>`(${Be})`).join(de)}const P=/\b\B/,H="[a-zA-Z]\\w*",B="[a-zA-Z_]\\w*",R="\\b\\d+(\\.\\d+)?",M="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",F="\\b(0b[01]+)",L="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",A=(X={})=>{const de=/^#![ ]*\//;return X.binary&&(X.begin=j(de,/.*\b/,X.binary,/\b.*/)),i({scope:"meta",begin:de,end:/$/,relevance:0,"on:begin":(Se,Be)=>{Se.index!==0&&Be.ignoreMatch()}},X)},I={begin:"\\\\[\\s\\S]",relevance:0},z={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[I]},D={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[I]},V={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/},U=function(X,de,Se={}){const Be=i({scope:"comment",begin:X,end:de,contains:[]},Se);Be.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 ut=k("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 Be.contains.push({begin:j(/[ ]+/,"(",ut,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Be},q=U("//","$"),te=U("/\\*","\\*/"),G=U("#","$"),K={scope:"number",begin:R,relevance:0},Z={scope:"number",begin:M,relevance:0},ee={scope:"number",begin:F,relevance:0},J={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[I,{begin:/\[/,end:/\]/,relevance:0,contains:[I]}]},re={scope:"title",begin:H,relevance:0},ie={scope:"title",begin:B,relevance:0},ne={begin:"\\.\\s*"+B,relevance:0};var Ce=Object.freeze({__proto__:null,APOS_STRING_MODE:z,BACKSLASH_ESCAPE:I,BINARY_NUMBER_MODE:ee,BINARY_NUMBER_RE:F,COMMENT:U,C_BLOCK_COMMENT_MODE:te,C_LINE_COMMENT_MODE:q,C_NUMBER_MODE:Z,C_NUMBER_RE:M,END_SAME_AS_BEGIN:function(X){return Object.assign(X,{"on:begin":(de,Se)=>{Se.data._beginMatch=de[1]},"on:end":(de,Se)=>{Se.data._beginMatch!==de[1]&&Se.ignoreMatch()}})},HASH_COMMENT_MODE:G,IDENT_RE:H,MATCH_NOTHING_RE:P,METHOD_GUARD:ne,NUMBER_MODE:K,NUMBER_RE:R,PHRASAL_WORDS_MODE:V,QUOTE_STRING_MODE:D,REGEXP_MODE:J,RE_STARTERS_RE:L,SHEBANG:A,TITLE_MODE:re,UNDERSCORE_IDENT_RE:B,UNDERSCORE_TITLE_MODE:ie});function Fe(X,de){X.input[X.index-1]==="."&&de.ignoreMatch()}function Me(X,de){X.className!==void 0&&(X.scope=X.className,delete X.className)}function fe(X,de){de&&X.beginKeywords&&(X.begin="\\b("+X.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",X.__beforeBegin=Fe,X.keywords=X.keywords||X.beginKeywords,delete X.beginKeywords,X.relevance===void 0&&(X.relevance=0))}function ke(X,de){Array.isArray(X.illegal)&&(X.illegal=k(...X.illegal))}function ge(X,de){if(X.match){if(X.begin||X.end)throw new Error("begin & end are not supported with match");X.begin=X.match,delete X.match}}function Ae(X,de){X.relevance===void 0&&(X.relevance=1)}const be=(X,de)=>{if(!X.beforeMatch)return;if(X.starts)throw new Error("beforeMatch cannot be used with starts");const Se=Object.assign({},X);Object.keys(X).forEach(Be=>{delete X[Be]}),X.keywords=Se.keywords,X.begin=j(Se.beforeMatch,g(Se.begin)),X.starts={relevance:0,contains:[Object.assign(Se,{endsParent:!0})]},X.relevance=0,delete Se.beforeMatch},qe=["of","and","for","in","not","or","if","then","parent","list","value"],ft="keyword";function gt(X,de,Se=ft){const Be=Object.create(null);return typeof X=="string"?ut(Se,X.split(" ")):Array.isArray(X)?ut(Se,X):Object.keys(X).forEach(function(Nt){Object.assign(Be,gt(X[Nt],de,Nt))}),Be;function ut(Nt,He){de&&(He=He.map(Ue=>Ue.toLowerCase())),He.forEach(function(Ue){const Xe=Ue.split("|");Be[Xe[0]]=[Nt,Rt(Xe[0],Xe[1])]})}}function Rt(X,de){return de?Number(de):En(X)?0:1}function En(X){return qe.includes(X.toLowerCase())}const rt={},Pt=X=>{console.error(X)},rn=(X,...de)=>{console.log(`WARN: ${X}`,...de)},Zt=(X,de)=>{rt[`${X}/${de}`]||(console.log(`Deprecated as of ${X}. ${de}`),rt[`${X}/${de}`]=!0)},Qt=new Error;function Ut(X,de,{key:Se}){let Be=0;const ut=X[Se],Nt={},He={};for(let Ue=1;Ue<=de.length;Ue++)He[Ue+Be]=ut[Ue],Nt[Ue+Be]=!0,Be+=_(de[Ue-1]);X[Se]=He,X[Se]._emit=Nt,X[Se]._multi=!0}function Rn(X){if(Array.isArray(X.begin)){if(X.skip||X.excludeBegin||X.returnBegin)throw Pt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Qt;if(typeof X.beginScope!="object"||X.beginScope===null)throw Pt("beginScope must be object"),Qt;Ut(X,X.begin,{key:"beginScope"}),X.begin=O(X.begin,{joinWith:""})}}function mn(X){if(Array.isArray(X.end)){if(X.skip||X.excludeEnd||X.returnEnd)throw Pt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Qt;if(typeof X.endScope!="object"||X.endScope===null)throw Pt("endScope must be object"),Qt;Ut(X,X.end,{key:"endScope"}),X.end=O(X.end,{joinWith:""})}}function Hn(X){X.scope&&typeof X.scope=="object"&&X.scope!==null&&(X.beginScope=X.scope,delete X.scope)}function Gs(X){Hn(X),typeof X.beginScope=="string"&&(X.beginScope={_wrap:X.beginScope}),typeof X.endScope=="string"&&(X.endScope={_wrap:X.endScope}),Rn(X),mn(X)}function ps(X){function de(He,Ue){return new RegExp(p(He),"m"+(X.case_insensitive?"i":"")+(X.unicodeRegex?"u":"")+(Ue?"g":""))}class Se{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Ue,Xe){Xe.position=this.position++,this.matchIndexes[this.matchAt]=Xe,this.regexes.push([Xe,Ue]),this.matchAt+=_(Ue)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Ue=this.regexes.map(Xe=>Xe[1]);this.matcherRe=de(O(Ue,{joinWith:"|"}),!0),this.lastIndex=0}exec(Ue){this.matcherRe.lastIndex=this.lastIndex;const Xe=this.matcherRe.exec(Ue);if(!Xe)return null;const yt=Xe.findIndex((Xn,xs)=>xs>0&&Xn!==void 0),St=this.matchIndexes[yt];return Xe.splice(0,yt),Object.assign(Xe,St)}}class Be{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Ue){if(this.multiRegexes[Ue])return this.multiRegexes[Ue];const Xe=new Se;return this.rules.slice(Ue).forEach(([yt,St])=>Xe.addRule(yt,St)),Xe.compile(),this.multiRegexes[Ue]=Xe,Xe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Ue,Xe){this.rules.push([Ue,Xe]),Xe.type==="begin"&&this.count++}exec(Ue){const Xe=this.getMatcher(this.regexIndex);Xe.lastIndex=this.lastIndex;let yt=Xe.exec(Ue);if(this.resumingScanAtSamePosition()&&!(yt&&yt.index===this.lastIndex)){const St=this.getMatcher(0);St.lastIndex=this.lastIndex+1,yt=St.exec(Ue)}return yt&&(this.regexIndex+=yt.position+1,this.regexIndex===this.count&&this.considerAll()),yt}}function ut(He){const Ue=new Be;return He.contains.forEach(Xe=>Ue.addRule(Xe.begin,{rule:Xe,type:"begin"})),He.terminatorEnd&&Ue.addRule(He.terminatorEnd,{type:"end"}),He.illegal&&Ue.addRule(He.illegal,{type:"illegal"}),Ue}function Nt(He,Ue){const Xe=He;if(He.isCompiled)return Xe;[Me,ge,Gs,be].forEach(St=>St(He,Ue)),X.compilerExtensions.forEach(St=>St(He,Ue)),He.__beforeBegin=null,[fe,ke,Ae].forEach(St=>St(He,Ue)),He.isCompiled=!0;let yt=null;return typeof He.keywords=="object"&&He.keywords.$pattern&&(He.keywords=Object.assign({},He.keywords),yt=He.keywords.$pattern,delete He.keywords.$pattern),yt=yt||/\w+/,He.keywords&&(He.keywords=gt(He.keywords,X.case_insensitive)),Xe.keywordPatternRe=de(yt,!0),Ue&&(He.begin||(He.begin=/\B|\b/),Xe.beginRe=de(Xe.begin),!He.end&&!He.endsWithParent&&(He.end=/\B|\b/),He.end&&(Xe.endRe=de(Xe.end)),Xe.terminatorEnd=p(Xe.end)||"",He.endsWithParent&&Ue.terminatorEnd&&(Xe.terminatorEnd+=(He.end?"|":"")+Ue.terminatorEnd)),He.illegal&&(Xe.illegalRe=de(He.illegal)),He.contains||(He.contains=[]),He.contains=[].concat(...He.contains.map(function(St){return gs(St==="self"?He:St)})),He.contains.forEach(function(St){Nt(St,Xe)}),He.starts&&Nt(He.starts,Ue),Xe.matcher=ut(Xe),Xe}if(X.compilerExtensions||(X.compilerExtensions=[]),X.contains&&X.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return X.classNameAliases=i(X.classNameAliases||{}),Nt(X)}function rs(X){return X?X.endsWithParent||rs(X.starts):!1}function gs(X){return X.variants&&!X.cachedVariants&&(X.cachedVariants=X.variants.map(function(de){return i(X,{variants:null},de)})),X.cachedVariants?X.cachedVariants:rs(X)?i(X,{starts:X.starts?i(X.starts):null}):Object.isFrozen(X)?i(X):X}var Cn="11.12.0";class as extends Error{constructor(de,Se){super(de),this.name="HTMLInjectionError",this.html=Se}}const Kn=s,Zn=i,An=Symbol("nomatch"),Yn=7,On=function(X){const de=Object.create(null),Se=Object.create(null),Be=[];let ut=!0;const Nt="Could not find the language '{}', did you forget to load/include a language module?",He={disableAutodetect:!0,name:"Plain text",contains:[]};let Ue={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:m};function Xe(Pe){return Ue.noHighlightRe.test(Pe)}function yt(Pe){let Ve=Pe.className+" ";Ve+=Pe.parentNode?Pe.parentNode.className:"";const dt=Ue.languageDetectRe.exec(Ve);if(dt){const mt=os(dt[1]);return mt||(rn(Nt.replace("{}",dt[1])),rn("Falling back to no-highlight mode for this block.",Pe)),mt?dt[1]:"no-highlight"}return Ve.split(/\s+/).find(mt=>Xe(mt)||os(mt))}function St(Pe,Ve,dt){let mt="",Ot="";typeof Ve=="object"?(mt=Pe,dt=Ve.ignoreIllegals,Ot=Ve.language):(Zt("10.7.0","highlight(lang, code, ...args) has been deprecated."),Zt("10.7.0",`Please use highlight(code, options) instead.
|
|
190
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),Ot=Pe,mt=Ve),dt===void 0&&(dt=!0);const Ft={code:mt,language:Ot};mi("before:highlight",Ft);const Jn=Ft.result?Ft.result:Xn(Ft.language,Ft.code,dt);return Jn.code=Ft.code,mi("after:highlight",Jn),Jn}function Xn(Pe,Ve,dt,mt){const Ot=Object.create(null);function Ft(Le,Ze){return Le.keywords[Ze]}function Jn(){if(!at.keywords){Bt.addText(pt);return}let Le=0;at.keywordPatternRe.lastIndex=0;let Ze=at.keywordPatternRe.exec(pt),ot="";for(;Ze;){ot+=pt.substring(Le,Ze.index);const jt=In.case_insensitive?Ze[0].toLowerCase():Ze[0],Vt=Ft(at,jt);if(Vt){const[yn,rl]=Vt;if(Bt.addText(ot),ot="",Ot[jt]=(Ot[jt]||0)+1,Ot[jt]<=Yn&&(Xi+=rl),yn.startsWith("_"))ot+=Ze[0];else{const ca=In.classNameAliases[yn]||yn;$n(Ze[0],ca)}}else ot+=Ze[0];Le=at.keywordPatternRe.lastIndex,Ze=at.keywordPatternRe.exec(pt)}ot+=pt.substring(Le),Bt.addText(ot)}function Ks(){if(pt==="")return;let Le=null;if(typeof at.subLanguage=="string"){if(!de[at.subLanguage]){Bt.addText(pt);return}Le=Xn(at.subLanguage,pt,!0,ks[at.subLanguage]),ks[at.subLanguage]=Le._top}else Le=ui(pt,at.subLanguage.length?at.subLanguage:null);at.relevance>0&&(Xi+=Le.relevance),Bt.__addSublanguage(Le._emitter,Le.language)}function fn(){at.subLanguage!=null?Ks():Jn(),pt=""}function $n(Le,Ze){Le!==""&&(Bt.startScope(Ze),Bt.addText(Le),Bt.endScope())}function Ys(Le,Ze){let ot=1;const jt=Ze.length-1;for(;ot<=jt;){if(!Le._emit[ot]){ot++;continue}const Vt=In.classNameAliases[Le[ot]]||Le[ot],yn=Ze[ot];Vt?$n(yn,Vt):(pt=yn,Jn(),pt=""),ot++}}function Xs(Le,Ze){return Le.scope&&typeof Le.scope=="string"&&Bt.openNode(In.classNameAliases[Le.scope]||Le.scope),Le.beginScope&&(Le.beginScope._wrap?($n(pt,In.classNameAliases[Le.beginScope._wrap]||Le.beginScope._wrap),pt=""):Le.beginScope._multi&&(Ys(Le.beginScope,Ze),pt="")),at=Object.create(Le,{parent:{value:at}}),at}function ys(Le,Ze,ot){let jt=S(Le.endRe,ot);if(jt){if(Le["on:end"]){const Vt=new t(Le);Le["on:end"](Ze,Vt),Vt.isMatchIgnored&&(jt=!1)}if(jt){for(;Le.endsParent&&Le.parent;)Le=Le.parent;return Le}}if(Le.endsWithParent)return ys(Le.parent,Ze,ot)}function la(Le){return at.matcher.regexIndex===0?(pt+=Le[0],1):(fi=!0,0)}function Nr(Le){const Ze=Le[0],ot=Le.rule,jt=new t(ot),Vt=[ot.__beforeBegin,ot["on:begin"]];for(const yn of Vt)if(yn&&(yn(Le,jt),jt.isMatchIgnored))return la(Ze);return ot.skip?pt+=Ze:(ot.excludeBegin&&(pt+=Ze),fn(),!ot.returnBegin&&!ot.excludeBegin&&(pt=Ze)),Xs(ot,Le),ot.returnBegin?0:Ze.length}function Oi(Le){const Ze=Le[0],ot=Ve.substring(Le.index),jt=ys(at,Le,ot);if(!jt)return An;const Vt=at;at.endScope&&at.endScope._wrap?(fn(),$n(Ze,at.endScope._wrap)):at.endScope&&at.endScope._multi?(fn(),Ys(at.endScope,Le)):Vt.skip?pt+=Ze:(Vt.returnEnd||Vt.excludeEnd||(pt+=Ze),fn(),Vt.excludeEnd&&(pt=Ze));do at.scope&&Bt.closeNode(),!at.skip&&!at.subLanguage&&(Xi+=at.relevance),at=at.parent;while(at!==jt.parent);return jt.starts&&Xs(jt.starts,Le),Vt.returnEnd?0:Ze.length}function wr(){const Le=[];for(let Ze=at;Ze!==In;Ze=Ze.parent)Ze.scope&&Le.unshift(Ze.scope);Le.forEach(Ze=>Bt.openNode(Ze))}let ls={};function bs(Le,Ze){const ot=Ze&&Ze[0];if(pt+=Le,ot==null)return fn(),0;if(ls.type==="begin"&&Ze.type==="end"&&ls.index===Ze.index&&ot===""){if(pt+=Ve.slice(Ze.index,Ze.index+1),!ut){const jt=new Error(`0 width match regex (${Pe})`);throw jt.languageName=Pe,jt.badRule=ls.rule,jt}return 1}if(ls=Ze,Ze.type==="begin")return Nr(Ze);if(Ze.type==="illegal"&&!dt){const jt=new Error('Illegal lexeme "'+ot+'" for mode "'+(at.scope||"<unnamed>")+'"');throw jt.mode=at,jt}else if(Ze.type==="end"){const jt=Oi(Ze);if(jt!==An)return jt}if(Ze.type==="illegal"&&ot==="")return Ze.index===Ve.length||(pt+=`
|
|
191
|
-
`),1;if(Qi>1e5&&Qi>Ze.index*3)throw new Error("potential infinite loop, way more iterations than matches");return pt+=ot,ot.length}const In=os(Pe);if(!In)throw Pt(Nt.replace("{}",Pe)),new Error('Unknown language: "'+Pe+'"');const Qs=ps(In);let wt="",at=mt||Qs;const ks={},Bt=new Ue.__emitter(Ue);wr();let pt="",Xi=0,cs=0,Qi=0,fi=!1;try{if(In.__emitTokens)In.__emitTokens(Ve,Bt);else{for(at.matcher.considerAll();;){Qi++,fi?fi=!1:at.matcher.considerAll(),at.matcher.lastIndex=cs;const Le=at.matcher.exec(Ve);if(!Le)break;const Ze=Ve.substring(cs,Le.index),ot=bs(Ze,Le);cs=Le.index+ot}bs(Ve.substring(cs))}return Bt.finalize(),wt=Bt.toHTML(),{language:Pe,value:wt,relevance:Xi,illegal:!1,_emitter:Bt,_top:at}}catch(Le){if(Le.message&&Le.message.includes("Illegal"))return{language:Pe,value:Kn(Ve),illegal:!0,relevance:0,_illegalBy:{message:Le.message,index:cs,context:Ve.slice(cs-100,cs+100),mode:Le.mode,resultSoFar:wt},_emitter:Bt};if(ut)return{language:Pe,value:Kn(Ve),illegal:!1,relevance:0,errorRaised:Le,_emitter:Bt,_top:at};throw Le}}function xs(Pe){const Ve={value:Kn(Pe),illegal:!1,relevance:0,_top:He,_emitter:new Ue.__emitter(Ue)};return Ve._emitter.addText(Pe),Ve}function ui(Pe,Ve){Ve=Ve||Ue.languages||Object.keys(de);const dt=xs(Pe),mt=Ve.filter(os).filter(hi).map(fn=>Xn(fn,Pe,!1));mt.unshift(dt);const Ot=mt.sort((fn,$n)=>{if(fn.relevance!==$n.relevance)return $n.relevance-fn.relevance;if(fn.language&&$n.language){if(os(fn.language).supersetOf===$n.language)return 1;if(os($n.language).supersetOf===fn.language)return-1}return 0}),[Ft,Jn]=Ot,Ks=Ft;return Ks.secondBest=Jn,Ks}function yr(Pe,Ve,dt){const mt=Ve&&Se[Ve]||dt;Pe.classList.add("hljs"),Pe.classList.add(`language-${mt}`)}function di(Pe){let Ve=null;const dt=yt(Pe);if(Xe(dt))return;if(mi("before:highlightElement",{el:Pe,language:dt}),Pe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Pe);return}if(Pe.children.length>0&&(Ue.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(Pe)),Ue.throwUnescapedHTML))throw new as("One of your code blocks includes unescaped HTML.",Pe.innerHTML);Ve=Pe;const mt=Ve.textContent,Ot=dt?St(mt,{language:dt,ignoreIllegals:!0}):ui(mt);Pe.innerHTML=Ot.value,Pe.dataset.highlighted="yes",yr(Pe,dt,Ot.language),Pe.result={language:Ot.language,re:Ot.relevance,relevance:Ot.relevance},Ot.secondBest&&(Pe.secondBest={language:Ot.secondBest.language,relevance:Ot.secondBest.relevance}),mi("after:highlightElement",{el:Pe,result:Ot,text:mt})}function br(Pe){Ue=Zn(Ue,Pe)}const Qn=()=>{Mi(),Zt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Gi(){Mi(),Zt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let vs=!1;function Mi(){function Pe(){Mi()}if(document.readyState==="loading"){vs||window.addEventListener("DOMContentLoaded",Pe,!1),vs=!0;return}document.querySelectorAll(Ue.cssSelector).forEach(di)}function kr(Pe,Ve){let dt=null;try{dt=Ve(X)}catch(mt){if(Pt("Language definition for '{}' could not be registered.".replace("{}",Pe)),ut)Pt(mt);else throw mt;dt=He}dt.name||(dt.name=Pe),de[Pe]=dt,dt.rawDefinition=Ve.bind(null,X),dt.aliases&&Ki(dt.aliases,{languageName:Pe})}function zt(Pe){delete de[Pe];for(const Ve of Object.keys(Se))Se[Ve]===Pe&&delete Se[Ve]}function Os(){return Object.keys(de)}function os(Pe){return Pe=(Pe||"").toLowerCase(),de[Pe]||de[Se[Pe]]}function Ki(Pe,{languageName:Ve}){typeof Pe=="string"&&(Pe=[Pe]),Pe.forEach(dt=>{Se[dt.toLowerCase()]=Ve})}function hi(Pe){const Ve=os(Pe);return Ve&&!Ve.disableAutodetect}function Dt(Pe){Pe["before:highlightBlock"]&&!Pe["before:highlightElement"]&&(Pe["before:highlightElement"]=Ve=>{Pe["before:highlightBlock"](Object.assign({block:Ve.el},Ve))}),Pe["after:highlightBlock"]&&!Pe["after:highlightElement"]&&(Pe["after:highlightElement"]=Ve=>{Pe["after:highlightBlock"](Object.assign({block:Ve.el},Ve))})}function jr(Pe){Dt(Pe),Be.push(Pe)}function Yi(Pe){const Ve=Be.indexOf(Pe);Ve!==-1&&Be.splice(Ve,1)}function mi(Pe,Ve){const dt=Pe;Be.forEach(function(mt){mt[dt]&&mt[dt](Ve)})}function Ri(Pe){return Zt("10.7.0","highlightBlock will be removed entirely in v12.0"),Zt("10.7.0","Please use highlightElement now."),di(Pe)}Object.assign(X,{highlight:St,highlightAuto:ui,highlightAll:Mi,highlightElement:di,highlightBlock:Ri,configure:br,initHighlighting:Qn,initHighlightingOnLoad:Gi,registerLanguage:kr,unregisterLanguage:zt,listLanguages:Os,getLanguage:os,registerAliases:Ki,autoDetection:hi,inherit:Zn,addPlugin:jr,removePlugin:Yi}),X.debugMode=function(){ut=!1},X.safeMode=function(){ut=!0},X.versionString=Cn,X.regex={concat:j,lookahead:g,either:k,optional:N,anyNumberOfTimes:x};for(const Pe in Ce)typeof Ce[Pe]=="object"&&e(Ce[Pe]);return Object.assign(X,Ce),X},le=On({});return le.newInstance=()=>On({}),Cf=le,le.HighlightJS=le,le.default=le,Cf}var sL=nL();const Ci=$g(sL);function iL(e){const t=e.regex,s={},i={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[s]}]};Object.assign(s,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},i]});const r={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},o=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),l={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,s,r]};r.contains.push(u);const d={match:/\\"/},h={className:"string",begin:/'/,end:/'/},m={match:/\\'/},p={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,s]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],x=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),N={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},j=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],k={match:/(\/[a-z._-]+)+/},_=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],S=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],E=["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"],O=["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:j,literal:y,built_in:[..._,...S,"set","shopt",...E,...O]},contains:[x,e.SHEBANG(),N,p,o,l,k,u,d,h,m,s]}}const rL=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_-]*/}}),aL=["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"],oL=["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"],lL=[...aL,...oL],cL=["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(),uL=["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(),dL=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),hL=["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 mL(e){const t=e.regex,s=rL(e),i={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},r="and or not only",o=/@-?\w[\w]*(-\w+)*/,l="[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:[s.BLOCK_COMMENT,i,s.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+l,relevance:0},s.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+uL.join("|")+")"},{begin:":(:)?("+dL.join("|")+")"}]},s.CSS_VARIABLE,{className:"attribute",begin:"\\b("+hL.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[s.BLOCK_COMMENT,s.HEXCOLOR,s.IMPORTANT,s.CSS_NUMBER_MODE,s.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}]},s.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:r,attribute:cL.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,s.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+lL.join("|")+")\\b"}]}}function fL(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 pL(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 So="[0-9](_*[0-9])*",td=`\\.(${So})`,nd="[0-9a-fA-F](_*[0-9a-fA-F])*",zb={className:"number",variants:[{begin:`(\\b(${So})((${td})|\\.)?|(${td}))[eE][+-]?(${So})[fFdD]?\\b`},{begin:`\\b(${So})((${td})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${td})[fFdD]?\\b`},{begin:`\\b(${So})[fFdD]\\b`},{begin:`\\b0[xX]((${nd})\\.?|(${nd})?\\.(${nd}))[pP][+-]?(${So})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${nd})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Dw(e,t,s){return s===-1?"":e.replace(t,i=>Dw(e,t,s-1))}function gL(e){const t=e.regex,s="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",i="(?:(?:\\s*\\[\\s*])+)?",r=s+"<@@@>"+i,l="(?:"+("\\?(?:\\s+(?:extends|super)\\s+"+r+")?")+"|"+r+")",u=Dw("(?:\\s*<\\s*"+l+"(?:\\s*,\\s*"+l+")*\\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"]},x={className:"meta",begin:"@"+s,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},N={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+/,s],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{beginKeywords:"new throw return else yield assert",relevance:0},{begin:[s,t.concat(u,i,/\s+/),s,i,/\s*/,/=(?!=)/],className:{1:"type",3:"variable",6:"operator"}},{begin:[/record/,/\s+/,s],className:{1:"keyword",3:"title.class"},contains:[N,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{begin:[s,t.concat(u,i,/\s+/),s,/\s*(?=\()/],className:{1:"type",3:"title.function"},keywords:g,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[x,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,zb,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},zb,x]}}const Db="[A-Za-z$_][0-9A-Za-z$_]*",xL=["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"],vL=["true","false","null","undefined","NaN","Infinity"],Fw=["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"],Uw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Bw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],yL=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],bL=[].concat(Bw,Fw,Uw);function kL(e){const t=e.regex,s=(U,{after:q})=>{const te="</"+U[0].slice(1);return U.input.indexOf(te,q)!==-1},i=Db,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(U,q)=>{const te=U[0].length+U.index,G=U.input[te];if(G==="<"||G===","){q.ignoreMatch();return}G===">"&&(s(U,{after:te})||q.ignoreMatch());let K;const Z=U.input.substring(te);if(K=Z.match(/^\s*=/)){q.ignoreMatch();return}if((K=Z.match(/^\s+extends\s+/))&&K.index===0){q.ignoreMatch();return}}},u={$pattern:Db,keyword:xL,literal:vL,built_in:bL,"variable.language":yL},d="[0-9](_?[0-9])*",h=`\\.(${d})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${m})((${h})|\\.)?|(${h}))[eE][+-]?(${d})\\b`},{begin:`\\b(${m})\\b((${h})\\b|\\.)?|(${h})\\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:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},N={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},j={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},_={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:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},S=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,N,j,y,{match:/\$\d+/},p];g.contains=S.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(S)});const E=[].concat(_,g.contains),O=E.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(E)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:O},H={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},B={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:{_:[...Fw,...Uw]}},R={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},M={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},F={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function L(U){return t.concat("(?!",U.join("|"),")")}const A={match:t.concat(/\b/,L([...Bw,"super","import","await"].map(U=>`${U}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},z={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},D="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",V={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(D)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:O,CLASS_REFERENCE:B},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),R,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,N,j,y,_,{match:/\$\d+/},p,B,{scope:"attr",match:i+t.lookahead(":"),relevance:0},V,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,e.REGEXP_MODE,{className:"function",begin:D,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:O}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:o},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},M,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[P,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},A,F,H,z,{match:/\$[(.]/}]}}const jL="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",NL={scope:"number",match:jL,relevance:0};function wL(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},s={match:/[{}[\],:]/,className:"punctuation",relevance:0},i=["true","false","null"],r={scope:"literal",beginKeywords:i.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:i},contains:[t,s,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,NL,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function SL(e){const t=e.regex,s={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},i={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},r={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},l={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}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},m={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=e.inherit(h,{contains:[]}),g=e.inherit(m,{contains:[]});h.contains.push(g),m.contains.push(p);let x=[s,d];return[h,m,p,g].forEach(k=>{k.contains=k.contains.concat(x)}),x=x.concat(h,m),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:x},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:x}]}]},s,o,i,h,m,{className:"quote",begin:"^>\\s+",contains:x,end:"$"},r,d,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function _L(e){const t=e.regex,s=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),i=["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:i,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:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},m={begin:/\{\{/,relevance:0},p={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,m,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d,m,h]},{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,m,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,m,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",x=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,N=`\\b|${i.join("|")}`,j={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${x}))[eE][+-]?(${g})[jJ]?(?=${N})`},{begin:`(${x})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${N})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${N})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${N})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${N})`},{begin:`\\b(${g})[jJ](?=${N})`}]},y={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},k={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",d,j,p,e.HASH_COMMENT_MODE]}]};return h.contains=[p,j,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[d,j,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,y,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,s],scope:{1:"keyword",3:"title.function"},contains:[k]},{variants:[{match:[/\bclass/,/\s+/,s,/\s*/,/\(\s*/,s,/\s*\)/]},{match:[/\bclass/,/\s+/,s]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[j,k,p]}]}}function EL(e){const t=e.regex,s=/(r#)?/,i=t.concat(s,e.UNDERSCORE_IDENT_RE),r=t.concat(s,e.IDENT_RE),o={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,r,t.lookahead(/\s*\(/))},l="([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"],h=["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!"],m=["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:m,keyword:u,literal:d,built_in:h},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_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,i],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,i],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,i,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,i],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,i],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:h,type:m}},{scope:"punctuation",begin:"->"},o]}}function CL(e){const t=e.regex,s=e.COMMENT("--","$"),i={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},r={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],l=["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"],h=["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"],m=["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"],p=["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"],x=m,N=[...h,...d].filter(O=>!m.includes(O)),j={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},y={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},k={match:t.concat(/\b/,t.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function _(O){return t.concat(/\b/,t.either(...O.map(P=>P.replace(/\s+/,"\\s+"))),/\b/)}const S={scope:"keyword",match:_(g),relevance:0};function E(O,{exceptions:P,when:H}={}){const B=H;return P=P||[],O.map(R=>R.match(/\|\d+$/)||P.includes(R)?R:B(R)?`${R}|0`:R)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:E(N,{when:O=>O.length<3}),literal:o,type:u,built_in:p},contains:[{scope:"type",match:_(l)},S,k,j,i,r,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,s,y]}}const Pd="[A-Za-z$_][0-9A-Za-z$_]*",Hw=["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"],Zw=["true","false","null","undefined","NaN","Infinity"],Ww=["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"],Vw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],qw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Gw=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],Kw=[].concat(qw,Ww,Vw);function AL(e){const t=e.regex,s=(U,{after:q})=>{const te="</"+U[0].slice(1);return U.input.indexOf(te,q)!==-1},i=Pd,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(U,q)=>{const te=U[0].length+U.index,G=U.input[te];if(G==="<"||G===","){q.ignoreMatch();return}G===">"&&(s(U,{after:te})||q.ignoreMatch());let K;const Z=U.input.substring(te);if(K=Z.match(/^\s*=/)){q.ignoreMatch();return}if((K=Z.match(/^\s+extends\s+/))&&K.index===0){q.ignoreMatch();return}}},u={$pattern:Pd,keyword:Hw,literal:Zw,built_in:Kw,"variable.language":Gw},d="[0-9](_?[0-9])*",h=`\\.(${d})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${m})((${h})|\\.)?|(${h}))[eE][+-]?(${d})\\b`},{begin:`\\b(${m})\\b((${h})\\b|\\.)?|(${h})\\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:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},N={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},j={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},_={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:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},S=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,N,j,y,{match:/\$\d+/},p];g.contains=S.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(S)});const E=[].concat(_,g.contains),O=E.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(E)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:O},H={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},B={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:{_:[...Ww,...Vw]}},R={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},M={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},F={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function L(U){return t.concat("(?!",U.join("|"),")")}const A={match:t.concat(/\b/,L([...qw,"super","import","await"].map(U=>`${U}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},z={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},D="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",V={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(D)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:O,CLASS_REFERENCE:B},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),R,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,N,j,y,_,{match:/\$\d+/},p,B,{scope:"attr",match:i+t.lookahead(":"),relevance:0},V,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,e.REGEXP_MODE,{className:"function",begin:D,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:O}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:o},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},M,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[P,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},A,F,H,z,{match:/\$[(.]/}]}}function $L(e){const t=e.regex,s=AL(e),i=Pd,r=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:r},contains:[s.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"],h={$pattern:Pd,keyword:Hw.concat(d),literal:Zw,built_in:Kw.concat(r),"variable.language":Gw},m={className:"meta",begin:"@"+i},p=(j,y,k)=>{const _=j.contains.findIndex(S=>S.label===y);if(_===-1)throw new Error("can not find mode to replace");j.contains.splice(_,1,k)};Object.assign(s.keywords,h),s.exports.PARAMS_CONTAINS.push(m);const g=s.contains.find(j=>j.scope==="attr"),x=Object.assign({},g,{match:t.concat(i,t.lookahead(/\s*\?:/))});s.exports.PARAMS_CONTAINS.push([s.exports.CLASS_REFERENCE,g,x]),s.contains=s.contains.concat([m,o,l,x]),p(s,"shebang",e.SHEBANG()),p(s,"use_strict",u);const N=s.contains.find(j=>j.label==="func.def");return N.relevance=0,Object.assign(s,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),s}function IL(e){const t=e.regex,s=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),i=/[\p{L}0-9._:-]+/u,r={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/}]},l=e.inherit(o,{begin:/\(/,end:/\)/}),u=e.inherit(e.APOS_STRING_MODE,{className:"string"}),d=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),h={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:i,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[r]},{begin:/'/,end:/'/,contains:[r]},{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,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,l,d,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},r,{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:[h],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[h],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(s,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:s,relevance:0,starts:h}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(s,/>/))),contains:[{className:"name",begin:s,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function TL(e){const t="true false yes no null",s="[\\w#;/?:@&=+$,.~*'()[\\]]+",i={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},r={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},o={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,r]},u=e.inherit(l,{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"},x={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},N={begin:/\{/,end:/\}/,contains:[x],illegal:"\\n",relevance:0},j={begin:"\\[",end:"\\]",contains:[x],illegal:"\\n",relevance:0},y=[i,{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+!"+s},{className:"type",begin:"!<"+s+">"},{className:"type",begin:"!"+s},{className:"type",begin:"!!"+s},{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},N,j,o,l],k=[...y];return k.pop(),k.push(u),x.contains=k,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:y}}for(const[e,t]of Object.entries({bash:iL,css:mL,diff:fL,go:pL,java:gL,javascript:kL,json:wL,markdown:SL,python:_L,rust:EL,sql:CL,typescript:$L,xml:IL,yaml:TL}))Ci.registerLanguage(e,t);Ci.registerAliases(["sh","shell","zsh","console"],{languageName:"bash"});Ci.registerAliases(["ts","tsx","mts","cts"],{languageName:"typescript"});Ci.registerAliases(["js","jsx","mjs","cjs"],{languageName:"javascript"});Ci.registerAliases(["html","svg","vue"],{languageName:"xml"});Ci.registerAliases(["py"],{languageName:"python"});Ci.registerAliases(["yml"],{languageName:"yaml"});Ci.registerAliases(["rs"],{languageName:"rust"});Ci.registerAliases(["md"],{languageName:"markdown"});const Fb=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");Tt.setOptions({gfm:!0,breaks:!1});Tt.use({renderer:{code({text:e,lang:t}){const s=(t??"").trim().split(/\s+/)[0]??"",r=s!==""&&Ci.getLanguage(s)!==void 0?Ci.highlight(e,{language:s,ignoreIllegals:!0}).value:Fb(e);return`<div class="code-block"><div class="code-head"><span class="code-lang">${Fb(s===""?"text":s)}</span><button type="button" class="code-copy" data-copy="">复制</button></div><pre><code class="hljs">${r}</code></pre></div>`}}});function Yw(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 s=/^\/([A-Za-z])\/(.*)$/.exec(t);if(s!==null&&(t=`${s[1].toUpperCase()}:/${s[2]}`),!(!/^[A-Za-z]:[\\/]/.test(t)&&!/^(\\\\|\/\/)[^\\/]/.test(t)))return t.replace(/\//g,"\\").replace(/[#?].*$/,"")}const Ub=/\.(png|jpe?g|gif|webp|bmp)$/i,ML=/^(#|\?|\/\/|[a-z][a-z0-9+.-]*:)/i;function Bb(e){const t=e.trim(),s=Yw(t);if(s!==void 0)return s;if(!(t===""||ML.test(t)))return t}Yg.addHook("beforeSanitizeAttributes",e=>{if(e.tagName==="IMG"){const r=e.getAttribute("src")??"";if(/^data:image\//i.test(r))return;e.removeAttribute("src"),e.classList.add("md-image");const o=Bb(r);o!==void 0?e.setAttribute("data-local-image",o):/^https?:/i.test(r)&&e.setAttribute("data-remote-image",r);return}if(e.tagName!=="A")return;const t=e.getAttribute("href")??"",s=Yw(t);if(s!==void 0){e.removeAttribute("href"),e.setAttribute("data-local-path",s),e.setAttribute("title",s),e.classList.add("local-path"),Ub.test(s)&&e.setAttribute("data-image-preview",s);return}const i=Bb(t);i!==void 0&&Ub.test(i)&&(e.removeAttribute("href"),e.setAttribute("data-image-preview",i),e.setAttribute("title",i),e.classList.add("local-path"))});Yg.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 RL(e){var o;const t=e.dataset.localPath;if(t===void 0)return;const s=l=>{e.dataset.note=l,setTimeout(()=>{delete e.dataset.note},2200)},i=Vs();if((i==null?void 0:i.openPath)!==void 0){i.openPath(t).then(l=>s(l==="missing"?"找不到这个文件":l==="revealed"?"已在文件夹中显示":"已打开"),()=>s("打不开"));return}(((o=navigator.clipboard)==null?void 0:o.writeText(t))??Promise.reject(new Error("no clipboard"))).then(()=>s("浏览器里打不开本地文件,路径已复制"),()=>s(Qw(t)?"浏览器里打不开本地文件,路径已复制":t))}function OL(e){var o;const t=e.target.closest("a[data-local-path]");if(t!==null){e.preventDefault(),RL(t);return}const s=e.target.closest("button[data-copy]"),i=(o=s==null?void 0:s.closest(".code-block"))==null?void 0:o.querySelector("pre");if(s==null||i==null)return;const r=l=>{s.textContent=l?"已复制":"复制失败",s.classList.toggle("copied",l),setTimeout(()=>{s.textContent="复制",s.classList.remove("copied")},1600)};Xw(i.innerText).then(r)}function Xw(e){var s;return(((s=navigator.clipboard)==null?void 0:s.writeText(e))??Promise.reject(new Error("no clipboard"))).then(()=>!0,()=>Qw(e))}function Qw(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 Af=new Map;function PL(e,t){let s=Af.get(t);return s===void 0&&(s=e.connection.call("attachments/file",{path:t}).then(i=>`data:${i.mediaType};base64,${i.data}`),s.catch(()=>Af.delete(t)),Af.set(t,s)),s}function LL(e,t){var o;let s=!0;const i=(t==null?void 0:t.capabilities.get().has("attachments"))===!0,r=(l,u)=>{if(!i||t===null){l.replaceWith(Hb(u,"当前后端不支持显示图片"));return}l.classList.add("loading"),PL(t,u).then(d=>{s&&(l.src=d,l.classList.remove("loading"))},d=>{s&&l.replaceWith(Hb(u,d instanceof Error?d.message:String(d)))})};for(const l of e.querySelectorAll("img[data-local-image]"))l.src===""&&r(l,l.dataset.localImage);for(const l of e.querySelectorAll("a[data-image-preview]")){if(((o=l.nextElementSibling)==null?void 0:o.classList.contains("md-link-preview"))===!0)continue;const u=document.createElement("img");u.className="md-image md-link-preview",u.alt=l.textContent??"",u.dataset.localImage=l.dataset.imagePreview,l.after(u),r(u,u.dataset.localImage)}for(const l of e.querySelectorAll("img[data-remote-image]")){const u=document.createElement("a");u.href=l.dataset.remoteImage,u.target="_blank",u.rel="noopener noreferrer",u.textContent=`🖼 ${l.alt!==""?l.alt:"网络图片"}`,u.title=u.href,l.replaceWith(u)}return()=>{s=!1}}function Hb(e,t){const s=document.createElement("span");return s.className="md-image-missing",s.textContent=`图片没能显示:${t}`,s.title=e,s}const Hs=v.memo(function({text:t,className:s}){const i=v.useMemo(()=>Yg.sanitize(Tt.parse(t,{async:!1})),[t]),r=v.useContext(uh),o=v.useRef(null),[l,u]=v.useState(null);v.useEffect(()=>o.current===null?void 0:LL(o.current,r),[i,r]);const d=h=>{const m=h.target,p=m.closest("a[data-image-preview]:not([data-local-path])"),g=m instanceof HTMLImageElement&&m.classList.contains("md-image")&&m.src!==""?m:(p==null?void 0:p.nextElementSibling)instanceof HTMLImageElement&&p.nextElementSibling.src!==""?p.nextElementSibling:null;if(g!==null){h.preventDefault();const x=g.dataset.localImage??"";u({src:g.src,width:g.naturalWidth,height:g.naturalHeight,name:x.split(/[\\/]/).pop()||"image.png"});return}OL(h)};return n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:o,className:`markdown ${s??""}`,onClick:d,dangerouslySetInnerHTML:{__html:i}}),l!==null&&n.jsx(ch,{src:l.src,width:l.width,height:l.height,name:l.name,onClose:()=>u(null)})]})}),Zb="adg.update.later",zL=360*6e4,Jw="https://github.com/haaahhhis/MultiGameAssistant/releases",$f="dsh-multigameassistant";function ax(){var i;const e=(i=Vs())==null?void 0:i.updates,[t,s]=v.useState(e===void 0?null:void 0);return v.useEffect(()=>{if(e===void 0)return;let r=!0;e.state().then(l=>{r&&s(l)},()=>{r&&s(null)});const o=e.onChange(l=>{r&&s(l)});return()=>{r=!1,o()}},[e]),{bridge:e,state:t}}const Wb=new WeakMap;function DL(e){let t=Wb.get(e);if(t!==void 0)return t;let s={checking:!1};const i=new Set,r=d=>{s=d;for(const h of i)h()};let o=0,l;const u=()=>{s.checking||(r({...s,checking:!0}),e.connection.call("about/checkUpdate",{}).then(d=>r({checking:!1,result:d}),d=>r({checking:!1,...s.result===void 0?{}:{result:s.result},error:d instanceof Error?d.message:String(d)})))};return t={get:()=>s,subscribe(d){return i.add(d),()=>{i.delete(d)}},check:u,watch(){return o++===0&&(s.result===void 0&&!s.checking&&u(),l=setInterval(u,zL)),()=>{--o===0&&l!==void 0&&(clearInterval(l),l=void 0)}}},Wb.set(e,t),t}function eS(e){const t=_e(e.capabilities),s=_e(e.connection.status),i=t.has("about"),[r,o]=v.useState(void 0);if(v.useEffect(()=>{if(s.state!=="open")return;if(!i){o(null);return}let l=!0;return e.connection.call("about/info",{}).then(u=>{l&&o(u)},()=>{l&&o(null)}),()=>{l=!1}},[e,i,s.state]),r!==void 0)return(r==null?void 0:r.edition)==="plugin"&&r.version!==void 0?{version:r.version}:!1}function tS(e,t){const s=DL(e),i=v.useSyncExternalStore(s.subscribe,s.get);return v.useEffect(()=>t?s.watch():void 0,[s,t]),{...i,check:s.check}}function nS(e){var l;const{bridge:t,state:s}=ax(),i=eS(e),r=tS(e,t===void 0&&i!==!1&&i!==void 0);if(t!==void 0){const u=s==null?void 0:s.latest;return s==null||u===void 0||u.version===s.skipped?null:{kind:"desktop",current:s.current,version:u.version,prerelease:u.prerelease,notesUrl:u.notesUrl,notes:u.notes??[],bridge:t,state:s}}const o=(l=r.result)==null?void 0:l.latest;return i===!1||i===void 0||o===void 0||r.result===void 0?null:{kind:"plugin",current:r.result.current,version:o.version,prerelease:o.prerelease,notesUrl:o.notesUrl||Jw,notes:o.notes??[],...o.onNpm===void 0?{}:{onNpm:o.onNpm}}}function FL(e,t=3){var r,o,l;const s=((r=e[0])==null?void 0:r.body)??"",i=[];for(const u of s.split(`
|
|
192
|
-
`)){const d=(o=/^\s*[-*]\s+(.+)$/.exec(u))==null?void 0:o[1];if(d===void 0)continue;const m=(((l=/^\*\*(.+?)\*\*/.exec(d))==null?void 0:l[1])??d).replace(/\*\*|`|\[([^\]]*)\]\([^)]*\)/g,(p,g)=>g??"").replace(/[::。]\s*$/,"").trim();if(m!==""&&!i.includes(m)&&i.push(m.length>40?`${m.slice(0,40)}…`:m),i.length>=t)break}return i}function UL(e){if(e===void 0)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric"})}function ox({notes:e,notesUrl:t}){return e.length===0?n.jsxs("p",{className:"muted small",children:["发布页没有写这次的更新说明。",n.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:"在 GitHub 上看"})]}):n.jsx("div",{className:"release-notes",children:e.map(s=>n.jsxs("section",{className:"release-note",children:[n.jsxs("div",{className:"release-note-head",children:[n.jsx("strong",{children:s.title!==void 0&&s.title!==`v${s.version}`?s.title:`版本 ${s.version}`}),n.jsx("span",{className:"muted small",children:UL(s.publishedAt)}),s.url!==""&&n.jsx("a",{className:"small",href:s.url,target:"_blank",rel:"noreferrer",children:"发布页"})]}),s.body===""?n.jsx("p",{className:"muted small",children:"这个版本没有写更新说明。"}):n.jsx(Hs,{className:"release-note-body",text:s.body})]},s.version))})}let sS=!1;const Vp=new Set,qp=e=>{sS=e;for(const t of Vp)t()},BL=e=>(Vp.add(e),()=>{Vp.delete(e)});function iS(){qp(!0)}function HL({client:e}){const t=v.useSyncExternalStore(BL,()=>sS),s=nS(e);if(v.useEffect(()=>{if(!t)return;const r=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),qp(!1))};return document.addEventListener("keydown",r,!0),()=>document.removeEventListener("keydown",r,!0)},[t]),!t||s===null)return null;const i=()=>qp(!1);return n.jsx("div",{className:"dialog-backdrop",onPointerDown:r=>{r.target===r.currentTarget&&i()},children:n.jsxs("div",{className:"dialog update-notes-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"update-notes-title",children:[n.jsxs("div",{className:"update-notes-head",children:[n.jsxs("h3",{id:"update-notes-title",children:[n.jsx(Q,{name:"download"}),"MultiGameAssistant ",s.version," 可以更新了"]}),n.jsx("button",{className:"ghost icon-button","aria-label":"关闭",title:"关闭",onClick:i,children:n.jsx(Q,{name:"close"})})]}),n.jsxs("p",{className:"muted small",children:["当前版本 ",s.current,s.prerelease?" · 新版本是预发布版":"",s.notes.length>1?` · 更新后会带上下面 ${s.notes.length} 个版本的改动`:""]}),n.jsx("div",{className:"update-notes-body",children:n.jsx(ox,{notes:s.notes,notesUrl:s.notesUrl})}),s.kind==="desktop"?n.jsx(lx,{bridge:s.bridge,state:s.state,extra:n.jsx("button",{className:"ghost small-button",onClick:()=>{s.bridge.skip(s.version),i()},children:"跳过这个版本"})}):n.jsx(rS,{version:s.version,onNpm:s.onNpm})]})})}function If(e){return e>=1024*1024?`${Math.round(e/1024/1024)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function lx({bridge:e,state:t,extra:s}){var m;const[i,r]=v.useState(null),[o,l]=v.useState(!1),u=t.latest;if(u===void 0)return null;const d=((m=t.download)==null?void 0:m.version)===u.version?t.download:void 0,h=p=>{r(null),p().catch(g=>r(g instanceof Error?g.message.replace(/^Error invoking remote method '[^']+': (Error: )?/,""):String(g)))};return n.jsxs("div",{className:"update-actions",children:[(d==null?void 0:d.state)==="downloading"&&n.jsxs("div",{className:"update-progress",children:[n.jsx("div",{className:"progress",role:"progressbar","aria-label":"下载进度","aria-valuemin":0,"aria-valuemax":d.total,"aria-valuenow":d.received,children:n.jsx("span",{style:{width:`${d.total>0?Math.min(100,d.received/d.total*100):0}%`}})}),n.jsxs("small",{className:"muted",children:["正在下载 ",If(d.received)," / ",If(d.total)]})]}),(d==null?void 0:d.state)==="ready"&&n.jsx("p",{className:"muted small",children:"安装时程序会退出,正在跑的脚本会被中断;装好后自动重新打开,数据和定时任务都在。"}),(d==null?void 0:d.state)==="failed"&&n.jsx("p",{className:"error small",children:d.error}),i!==null&&n.jsx("p",{className:"error small",children:i}),n.jsxs("div",{className:"update-buttons",children:[s,(d==null?void 0:d.state)==="ready"?n.jsx("button",{className:"primary small-button",disabled:o,onClick:()=>{l(!0),h(()=>e.install().finally(()=>l(!1)))},children:o?"正在启动安装…":"退出并安装"}):n.jsx("button",{className:"primary small-button",disabled:(d==null?void 0:d.state)==="downloading",onClick:()=>h(()=>e.download()),children:(d==null?void 0:d.state)==="failed"?"重新下载":(d==null?void 0:d.state)==="downloading"?"正在下载…":`下载更新(${If(u.size)})`})]})]})}function rS({version:e,onNpm:t}){const s=`${Jw}/download/v${e}/${$f}.tgz`;return n.jsxs("div",{className:"plugin-update",children:[t!==!1&&n.jsxs("p",{children:["在 dsh 的「Plugins」→「Add plugin」里再填一次 ",n.jsx(Tf,{text:$f})," 安装(命令行的 dsh:",n.jsx(Tf,{text:`dsh plugin add ${$f}`}),")。",t===void 0&&"没连上 npm,不知道那边有没有这个版本;装完版本没变的话,用下面的链接。"]}),t!==!0&&n.jsxs("p",{children:[t===!1&&"npm 上还没有这个版本(要等发布者批准)。","在「Add plugin」里填这个链接安装:",n.jsx(Tf,{text:s})]}),n.jsx("p",{className:"muted small",children:"装好后刷新这个页面。你的数据、脚本和定时任务都在 dsh 的数据目录里,重新安装不会丢。"})]})}function Tf({text:e}){const[t,s]=v.useState(!1),i=()=>{navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),1500)},()=>{})};return n.jsxs("span",{className:"copy-code",children:[n.jsx("code",{children:e}),n.jsx("button",{type:"button",className:"link-button",onClick:i,title:"复制",children:t?n.jsx(Q,{name:"check"}):n.jsx(Q,{name:"copy"})})]})}function ZL(){var d;const{bridge:e,state:t}=ax(),[s,i]=v.useState(()=>{try{return sessionStorage.getItem(Zb)}catch{return null}}),r=t==null?void 0:t.latest;if(e===void 0||t==null||r===void 0)return null;const o=((d=t.download)==null?void 0:d.version)===r.version&&t.download.state!=="failed";if(!o&&(r.version===t.skipped||r.version===s))return null;const l=()=>{try{sessionStorage.setItem(Zb,r.version)}catch{}i(r.version)},u=FL(r.notes??[]);return n.jsxs("div",{className:"approval-card update-card",role:"status",children:[n.jsxs("div",{className:"approval-head",children:[n.jsx(Q,{name:"download"}),n.jsxs("div",{className:"approval-text",children:[n.jsxs("span",{className:"approval-title",children:["MultiGameAssistant ",r.version," 可以更新了"]}),n.jsxs("span",{className:"approval-tool",children:["当前 ",t.current,r.prerelease?" · 预发布版":""]})]}),!o&&n.jsx("button",{className:"ghost icon-button update-close","aria-label":"稍后提醒",title:"稍后(下次启动再提醒)",onClick:l,children:n.jsx(Q,{name:"close"})})]}),u.length>0&&n.jsx("ul",{className:"update-highlights",children:u.map(h=>n.jsx("li",{children:h},h))}),n.jsx(lx,{bridge:e,state:t,extra:n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ghost small-button",onClick:iS,children:"更新介绍"}),!o&&n.jsx("button",{className:"ghost small-button",onClick:()=>void e.skip(r.version),children:"跳过这个版本"})]})})]})}function WL({client:e,sessionId:t,onSelect:s}){var m;const i=_e(e.approvals),r=_e(e.questions),o=(m=EO(e))==null?void 0:m.pending,l=i.filter(p=>p.sessionId===t),u=r.filter(p=>p.sessionId===t),d=[...i,...r].filter(p=>p.sessionId!==t),h=d.some(p=>"approvalId"in p)?d.some(p=>"questionId"in p)?"审批或回答":"审批":"回答";return n.jsxs("div",{className:"approval-dock",children:[o!==void 0&&n.jsx(CO,{client:e,pending:o}),u.map(p=>n.jsx(qL,{client:e,request:p},p.questionId)),l.map(p=>n.jsx(VL,{client:e,request:p},p.approvalId)),d.length>0&&n.jsxs("button",{className:"approval-elsewhere",onClick:()=>s(d[0].sessionId),children:[n.jsx("span",{className:"approval-dot"}),"另有 ",new Set(d.map(p=>p.sessionId)).size," 个会话在等你",h,n.jsx(Q,{name:"chevron"})]}),n.jsx($O,{client:e}),n.jsx(SO,{client:e}),n.jsx(ZL,{})]})}function VL({client:e,request:t}){var d,h,m;const[s,i]=v.useState(!1),[r,o]=v.useState(null),l=((d=t.displayReason)==null?void 0:d.zh)??((h=t.displayReason)==null?void 0:h["zh-CN"])??((m=t.displayReason)==null?void 0:m.en)??t.reason,u=async p=>{i(!0);try{await e.respondApproval(t.approvalId,p)}catch(g){o(g instanceof Error?g.message:String(g)),i(!1)}};return n.jsxs("div",{className:"approval-card",role:"alertdialog","aria-label":"需要审批",children:[n.jsxs("div",{className:"approval-head",children:[n.jsx(Q,{name:"shield"}),n.jsxs("div",{className:"approval-text",children:[n.jsx("div",{className:"approval-title",children:"需要你的批准"}),n.jsx("code",{className:"approval-tool",children:t.toolName})]})]}),l!==void 0&&n.jsx("div",{className:"approval-reason",children:l}),r!==null&&n.jsx("div",{className:"error small",children:r}),n.jsxs("div",{className:"approval-actions",children:[n.jsx("button",{disabled:s,onClick:()=>void u("reject"),children:"拒绝"}),n.jsx("button",{className:"inverse",disabled:s,onClick:()=>void u("allow-once"),children:"允许本次"})]})]})}function qL({client:e,request:t}){var j;const[s,i]=v.useState({}),[r,o]=v.useState(!1),[l,u]=v.useState(null),d=t.questions.length===1&&t.questions[0].multiSelect!==!0&&(((j=t.questions[0].options)==null?void 0:j.length)??0)>0,h=y=>s[y]??{selected:[],custom:""},m=async y=>{o(!0),u(null);try{await e.answerQuestion(t.questionId,y)}catch(k){u(k instanceof Error?k.message:String(k)),o(!1)}},p=(y,k)=>{if(d)return void m([{id:y.id,selected:[k]}]);i(_=>{const S=_[y.id]??{selected:[],custom:""},E=y.multiSelect===!0?S.selected.includes(k)?S.selected.filter(O=>O!==k):[...S.selected,k]:S.selected.includes(k)?[]:[k];return{..._,[y.id]:{...S,selected:E}}})},g=(y,k)=>i(_=>({..._,[y.id]:{..._[y.id]??{selected:[]},custom:k}})),x=()=>t.questions.map(y=>{const{selected:k,custom:_}=h(y.id),S=_.trim();return{id:y.id,selected:S!==""&&y.multiSelect!==!0?[]:k,...S===""?{}:{custom:S}}}),N=t.questions.every(y=>h(y.id).selected.length>0||h(y.id).custom.trim()!=="");return n.jsxs("div",{className:"approval-card question-card",role:"alertdialog","aria-label":"agent 在问你",children:[n.jsxs("div",{className:"approval-head",children:[n.jsx(Q,{name:"chat"}),n.jsx("div",{className:"approval-text",children:n.jsx("div",{className:"approval-title",children:"agent 在问你"})})]}),t.questions.map(y=>{var k,_;return n.jsxs("div",{className:"question-item",children:[y.header!==void 0&&n.jsx("span",{className:"question-header",children:y.header}),n.jsx("div",{className:"question-text",children:y.question}),y.detail!==void 0&&n.jsx("div",{className:"question-detail",children:y.detail}),(((k=y.options)==null?void 0:k.length)??0)>0&&n.jsx("div",{className:"question-options",role:y.multiSelect===!0?"group":"radiogroup",children:y.options.map(S=>{const E=h(y.id).selected.includes(S.label);return n.jsxs("button",{className:`question-option${E?" on":""}`,disabled:r,role:y.multiSelect===!0?"checkbox":"radio","aria-checked":E,onClick:()=>p(y,S.label),children:[n.jsx("span",{className:"question-option-label",children:S.label}),S.description!==void 0&&n.jsx("span",{className:"question-option-desc",children:S.description})]},S.label)})}),n.jsx("input",{className:"text-input question-custom",value:h(y.id).custom,disabled:r,placeholder:(((_=y.options)==null?void 0:_.length)??0)>0?"或者直接写你的回答":"写下你的回答",onChange:S=>g(y,S.target.value),onKeyDown:S=>{S.key==="Enter"&&!S.nativeEvent.isComposing&&N&&m(x())}})]},y.id)}),l!==null&&n.jsx("div",{className:"error small",children:l}),n.jsxs("div",{className:"approval-actions",children:[n.jsx("button",{disabled:r,onClick:()=>void m(t.questions.map(y=>({id:y.id,selected:[]}))),children:"跳过"}),n.jsx("button",{className:"inverse",disabled:r||!N,onClick:()=>void m(x()),children:"回答"})]})]})}const wn="main";function Gp(e,t){const s=new Set;let i=e;for(;i.parentId&&!s.has(i.id);){s.add(i.id);const r=t.get(i.parentId);if(!r)break;i=r}return i}const GL={intervene:"alert",games:"gamepad",scripts:"package",pipelines:"flow"},cn={id:wn,name:"助手",description:"和你对话、替你安排;飞书里的消息也到这里",icon:"chat"};function Ka(e){return{id:e.id,name:e.name,description:e.description,icon:GL[e.id]??"sparkles"}}function $i(e){const t=_e(e.connection.status),[s,i]=v.useState([]);return v.useEffect(()=>{if(t.state!=="open")return;let r=!0;return e.connection.call("roles/list",{}).then(o=>{r&&i(o.items)}).catch(()=>{}),()=>{r=!1}},[e,t.state]),v.useEffect(()=>e.connection.on("roles/changed",r=>i(r.items)),[e]),s}function aS(e,t){return e.role!==void 0&&t.some(s=>s.id===e.role)?e.role:wn}function cx(e,t){const s=_e(e.connection.status),[i,r]=v.useState(new Map),o=v.useRef(new Map),l=d=>`${d.updatedAt}${d.running?"+":""}`,u=t.map(d=>`${d.id}@${l(d)}`).join(",");return v.useEffect(()=>{if(s.state!=="open")return;const d=t.filter(h=>o.current.get(h.id)!==l(h)).slice(0,60);if(d.length!==0){for(const h of d)o.current.set(h.id,l(h));e.connection.call("sessions/lastReplies",{sessionIds:d.map(h=>h.id)}).then(h=>{r(m=>{const p=new Map(m);for(const g of h.items)p.set(g.sessionId,g.text);return p})}).catch(()=>{for(const h of d)o.current.delete(h.id)})}},[e,s.state,u]),i}const oS="adg.agentSeen";function KL(){try{const e=JSON.parse(localStorage.getItem(oS)??"{}");return e!==null&&typeof e=="object"?e:{}}catch{return{}}}function YL(){const[e,t]=v.useState(KL);return{seen:e,markSeen:(i,r)=>{t(o=>{if((o[i]??0)>=r)return o;const l={...o,[i]:r};try{localStorage.setItem(oS,JSON.stringify(l))}catch{}return l})}}}function lS(e,t){const s=_e(e.connection.status),[i,r]=v.useState({agentId:t,sessionId:null,error:null});return v.useEffect(()=>{if(s.state!=="open")return;let o=!0;return e.connection.call("agents/home",{agentId:t}).then(l=>{o&&r({agentId:t,sessionId:l.sessionId,error:null})},l=>{o&&r({agentId:t,sessionId:null,error:l instanceof Error?l.message:String(l)})}),()=>{o=!1}},[e,t,s.state]),i.agentId===t?i:{sessionId:null,error:null}}function XL(e,t){const s=_e(e.connection.status),i=_e(e.capabilities),[r,o]=v.useState([]);return v.useEffect(()=>{if(s.state!=="open"||!i.has("agents"))return;let l=!0;return e.connection.call("handoffs/list",{sessionId:t}).then(u=>{l&&o(u.items)}).catch(()=>{}),()=>{l=!1}},[e,t,s.state,i]),v.useEffect(()=>e.connection.on("handoffs/changed",({item:l})=>{l.fromSession!==t&&l.toSession!==t||o(u=>[...u.filter(d=>d.id!==l.id),l])}),[e,t]),r}function QL(e,t){const s=_e(e.sessions),i=v.useMemo(()=>new Map(s.items.map(g=>[g.id,g])),[s.items]),r=_e(e.approvals),o=_e(e.questions),l=$i(e),{seen:u,markSeen:d}=YL(),h=v.useMemo(()=>[cn,...l.map(Ka)],[l]),m=v.useMemo(()=>{var x;const g=new Map(h.map(N=>[N.id,[]]));for(const N of s.items){if(N.blank||!N.home&&N.origin!=="subagent")continue;const j=N.home??Gp(N,i).home;j&&((x=g.get(j))==null||x.push(N))}for(const N of g.values())N.sort((j,y)=>y.updatedAt-j.updatedAt);return g},[s.items,i,h]);v.useEffect(()=>{var g,x;if(s.loaded)for(const N of h){const j=(x=(g=m.get(N.id))==null?void 0:g[0])==null?void 0:x.updatedAt;j!==void 0&&(N.id===t||u[N.id]===void 0)&&d(N.id,j)}},[s.loaded,m,t]);const p=g=>{const x=i.get(g);return x&&Gp(x,i).home};return h.map(g=>{const x=m.get(g.id)??[],N=x[0];return{agent:g,running:x.filter(j=>j.running).length,unread:g.id!==t&&N!==void 0&&N.updatedAt>(u[g.id]??1/0),waiting:[...r,...o].filter(j=>p(j.sessionId)===g.id).length,last:x.find(j=>j.home===g.id)??N}})}function vt(e,t){const s=Math.max(0,Math.round((t-e)/1e3));return s<60?"刚刚":s<3600?`${Math.floor(s/60)} 分钟前`:s<86400?`${Math.floor(s/3600)} 小时前`:s<86400*7?`${Math.floor(s/86400)} 天前`:new Date(e).toLocaleDateString(void 0,{month:"numeric",day:"numeric"})}function JL({client:e,pages:t,current:s,onAgent:i,onPage:r,onSchedule:o,onSettings:l,width:u,onWidth:d,slot:h}){const m=_e(e.connection.status),p=_e(e.capabilities),g=QL(e,s.kind==="agent"?s.id:void 0),x=nS(e),N=u>=To,j=g.find(M=>M.agent.id===wn),y=g.filter(M=>M.agent.id!==wn),k=t.filter(M=>M.order<0),_=s.kind==="page"?k.find(M=>M.id===s.id):void 0,[S,...E]=k,O=s.kind==="agent"&&s.id===wn,P=cx(e,N?g.flatMap(M=>M.last===void 0?[]:[{id:M.last.id,updatedAt:M.last.updatedAt,running:M.last.running}]):[]),H=M=>M.last===void 0?void 0:P.get(M.last.id)??void 0,B=M=>n.jsx(Ql,{icon:M.icon,label:M.title,active:s.kind==="page"&&s.id===M.id,onClick:()=>r(M.id)},M.id),R=M=>n.jsx(sz,{state:M,wide:N,reply:H(M),active:s.kind==="agent"&&s.id===M.agent.id,onClick:()=>i(M.agent.id)},M.agent.id);return n.jsxs("nav",{className:`rail${N?" wide":""}`,"aria-label":"功能区",children:[n.jsx("div",{className:"rail-top",children:j!==void 0&&(S===void 0?R(j):n.jsx(iz,{state:j,page:S,wide:N,reply:H(j),showingPage:(_==null?void 0:_.id)===S.id,active:O||(_==null?void 0:_.id)===S.id,onClick:()=>O?r(S.id):i(wn)}))}),n.jsx("span",{className:"rail-divider",role:"separator"}),_!==void 0?n.jsx("div",{className:"rail-items rail-slot",ref:h,"aria-label":_.title}):n.jsxs("div",{className:"rail-items",children:[y.map(R),t.filter(M=>M.order>=0).map(B)]}),n.jsxs("div",{className:"rail-footer",children:[x!==null&&n.jsx(Ql,{icon:"download",label:"更新",title:`MultiGameAssistant ${x.version} 可以更新了:点开看更新了什么`,active:!1,onClick:iS,dot:!0}),(j===void 0?k:E).map(B),p.has("pipelines")&&n.jsx(Ql,{icon:"clock",label:"定时",title:"所有 agent 的定时任务、提醒和按时运行的流水线:在这里新建和修改",active:s.kind==="schedule",onClick:o}),n.jsx(Ql,{icon:"settings",label:"设置",active:s.kind==="settings",onClick:l}),m.state!=="open"&&n.jsxs("span",{className:`rail-connection ${m.state}`,role:"status",title:Gb(m.state,m.attempt,m.error),children:[n.jsx("span",{className:"conn-dot"}),n.jsx("span",{className:"sr-only",children:Gb(m.state,m.attempt,m.error)})]})]}),n.jsx(nz,{width:u,onWidth:d}),n.jsx(HL,{client:e})]})}const To=150,Ma=68,ez=360,Vb="adg.railWidth";function tz(){const[e,t]=v.useState(()=>{try{return qb(Number(localStorage.getItem(Vb)??Ma))}catch{return Ma}});return v.useEffect(()=>{const s=setTimeout(()=>{try{localStorage.setItem(Vb,String(e))}catch{}},200);return()=>clearTimeout(s)},[e]),[e,s=>t(qb(s))]}function qb(e){if(!Number.isFinite(e))return Ma;const t=Math.min(ez,Math.max(Ma,Math.round(e)));return t<To?t<(Ma+To)/2?Ma:To:t}function nz({width:e,onWidth:t}){const s=v.useRef(null),i=l=>{l.preventDefault(),s.current={x:l.clientX,width:e},l.currentTarget.setPointerCapture(l.pointerId)},r=l=>{s.current!==null&&t(s.current.width+l.clientX-s.current.x)},o=()=>{s.current=null};return n.jsx("div",{className:"rail-resizer",role:"separator","aria-orientation":"vertical","aria-label":"调整侧边栏宽度",title:"拖动调整宽度;双击展开或收起",onPointerDown:i,onPointerMove:r,onPointerUp:o,onPointerCancel:o,onDoubleClick:()=>t(e>=To?Ma:220)})}function sz({state:e,wide:t,reply:s,active:i,onClick:r}){const{agent:o,running:l,unread:u,waiting:d}=e,h=s==null?void 0:s.replace(/\s+/g," ").trim();return n.jsxs("button",{className:`rail-item rail-agent ${i?"active":""}`,"aria-current":i?"page":void 0,onClick:r,title:`${o.name}:${o.description}${l>0?`(进行中${l>1?` ${l}`:""})`:""}`,children:[n.jsxs("span",{className:`agent-avatar rail-avatar agent-${o.id}`,children:[n.jsx(Q,{name:o.icon}),l>0&&n.jsx("span",{className:"agent-busy",role:"img","aria-label":`${l} 个正在运行`})]}),t?n.jsxs("span",{className:"rail-text",children:[n.jsx("span",{className:`rail-label ${u?"unread":""}`,children:o.name}),n.jsx("span",{className:"rail-preview",children:l>0?"正在处理…":h!==void 0&&h!==""?h:o.description})]}):n.jsx("span",{className:`rail-label ${u?"unread":""}`,children:o.name}),d>0?n.jsx("span",{className:"rail-badge","aria-label":`${d} 个等你处理`,children:d}):u&&n.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新结果"})]})}function iz({state:e,page:t,wide:s,reply:i,showingPage:r,active:o,onClick:l}){const{agent:u,running:d,unread:h,waiting:m}=e,p=r?{name:t.title,icon:t.icon,className:`page-${t.id}`}:{name:u.name,icon:u.icon,className:`agent-${u.id}`},g=r?{name:u.name,icon:u.icon,className:`agent-${u.id}`}:{name:t.title,icon:t.icon,className:`page-${t.id}`},x=r?"各个游戏的活动和日程":d>0?"正在处理…":(i==null?void 0:i.replace(/\s+/g," ").trim())||u.description,N=o?`${p.name}:点一下切换到${g.name}`:`${p.name}:${u.description}(打开后再点一下切换到${g.name})`;return n.jsxs("button",{className:`rail-item rail-agent rail-switch ${o?"active":""}`,"aria-current":o?"page":void 0,onClick:l,title:N,children:[n.jsxs("span",{className:"rail-switch-stack",children:[n.jsx("span",{className:`agent-avatar rail-switch-peek ${g.className}`,"aria-hidden":"true",children:n.jsx(Q,{name:g.icon})}),n.jsxs("span",{className:`agent-avatar rail-avatar rail-switch-face ${p.className}`,children:[n.jsx(Q,{name:p.icon}),!r&&d>0&&n.jsx("span",{className:"agent-busy",role:"img","aria-label":`${d} 个正在运行`})]},p.className)]}),s?n.jsxs("span",{className:"rail-text",children:[n.jsxs("span",{className:`rail-label ${h&&!r?"unread":""}`,children:[p.name,n.jsxs("span",{className:"rail-switch-next","aria-hidden":"true",children:[n.jsx(Q,{name:"swap"}),g.name]})]}),n.jsx("span",{className:"rail-preview",children:x})]}):n.jsx("span",{className:"rail-label",children:p.name}),m>0?n.jsx("span",{className:"rail-badge","aria-label":`助手有 ${m} 个等你处理`,children:m}):h&&n.jsx("span",{className:"rail-unread",role:"img","aria-label":"助手有新结果"})]})}function Ql({icon:e,label:t,title:s=t,active:i,onClick:r,disabled:o=!1,dot:l=!1}){return n.jsxs("button",{className:`rail-item ${i?"active":""} ${l?"rail-new":""}`,"aria-current":i?"page":void 0,onClick:r,title:s,disabled:o,children:[n.jsx(Q,{name:e}),n.jsx("span",{className:"rail-label",children:t}),l&&n.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新版本"})]})}function Gb(e,t,s){const i=e==="open"?"已连接 agent":e==="connecting"?"正在连接…":e==="reconnecting"?`重连中(第 ${t} 次)`:"未连接";return s===void 0?i:`${i}:${s}`}const cS=v.createContext(null),rz=v.createContext(!1);function az({bridge:e,onClose:t}){const[s,i]=v.useState(null),[r,o]=v.useState(null),l=v.useRef(null),u=v.useRef(null),[d,h]=v.useState(""),[m,p]=v.useState(!1),[g,x]=v.useState(null),N=v.useRef(null),j=v.useRef(null),y=v.useRef(!1),k=v.useRef(0),_=s==null?void 0:s.tabs.find(U=>U.id===s.shown);v.useEffect(()=>{m||h((_==null?void 0:_.url)==="about:blank"?"":(_==null?void 0:_.url)??"")},[_==null?void 0:_.url,m]),v.useEffect(()=>{let U=!0;e.state().then(G=>{U&&G!==null&&i(G)});const q=e.onChange(i),te=e.onFrame(G=>{createImageBitmap(new Blob([G.data],{type:"image/jpeg"})).then(K=>{var Z;if(!U)return K.close();(Z=u.current)==null||Z.close(),u.current=K,S(),o(ee=>(ee==null?void 0:ee.width)===G.width&&ee.height===G.height?ee:{width:G.width,height:G.height})},()=>{})});return()=>{var G;U=!1,q(),te(),(G=u.current)==null||G.close(),u.current=null}},[e]),v.useEffect(()=>{const U=N.current;if(U===null)return;const q=()=>{const{width:G,height:K}=U.getBoundingClientRect();e.show(G>50&&K>50?{width:Math.floor(G),height:Math.floor(K)}:null)},te=new ResizeObserver(q);return te.observe(U),q(),()=>{te.disconnect(),e.show(null)}},[e]);function S(){var te;const U=l.current,q=u.current;U===null||q===null||((U.width!==q.width||U.height!==q.height)&&(U.width=q.width,U.height=q.height),(te=U.getContext("2d"))==null||te.drawImage(q,0,0))}v.useEffect(S,[r]);const E=U=>{x(null),U.catch(q=>x(q instanceof Error?q.message:String(q)))},O=U=>{const q=U.currentTarget.getBoundingClientRect(),te=r===null?1:r.width/q.width,G=r===null?1:r.height/q.height;return{x:Math.round((U.clientX-q.left)*te),y:Math.round((U.clientY-q.top)*G)}},P=U=>[U.shiftKey&&"shift",U.ctrlKey&&"control",U.altKey&&"alt",U.metaKey&&"meta"].filter(q=>q!==!1),H=U=>U===1?"middle":U===2?"right":"left",B=U=>e.input(U),R=U=>{var q;U.preventDefault(),(q=j.current)==null||q.focus(),B({type:"mouseDown",...O(U),button:H(U.button),clickCount:U.detail,modifiers:P(U)})},M=U=>B({type:"mouseUp",...O(U),button:H(U.button),clickCount:U.detail,modifiers:P(U)}),F=U=>{const q=Date.now();U.buttons===0&&q-k.current<50||(k.current=q,B({type:"mouseMove",...O(U),modifiers:P(U)}))},L=U=>B({type:"mouseWheel",...O(U),deltaX:-U.deltaX,deltaY:-U.deltaY,canScroll:!0,modifiers:P(U)}),A=U=>{if(y.current||U.nativeEvent.isComposing)return;const q={Enter:"Enter",Backspace:"Backspace",Tab:"Tab",Escape:"Escape",Delete:"Delete",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right"},te=(U.ctrlKey||U.metaKey||U.altKey)&&U.key.length===1,G=q[U.key]??(te?U.key.toUpperCase():void 0);if(G===void 0)return;U.preventDefault();const K=P(U);B({type:"keyDown",keyCode:G,modifiers:K}),G==="Enter"&&B({type:"char",keyCode:"\r",modifiers:K}),B({type:"keyUp",keyCode:G,modifiers:K})},I=()=>{const U=j.current;if(U===null||U.value==="")return;const q=U.value;U.value="",e.text(q)},z=()=>{const U=d.trim();U!==""&&(p(!1),E(e.navigate({url:U,..._===void 0?{newTab:!0}:{}})))},D=s!==null&&Date.now()-s.agentAt<5e3,[,V]=v.useState(0);return v.useEffect(()=>{if(!D||s===null)return;const U=setTimeout(()=>V(q=>q+1),s.agentAt+5e3-Date.now()+50);return()=>clearTimeout(U)},[D,s]),n.jsxs("aside",{className:"browser-panel","aria-label":"内置浏览器",children:[n.jsxs("div",{className:"browser-toolbar",children:[n.jsx("button",{type:"button",className:"icon-button",title:"后退","aria-label":"后退",disabled:(_==null?void 0:_.canGoBack)!==!0,onClick:()=>E(e.navigate({action:"back"})),children:n.jsx(Q,{name:"back"})}),n.jsx("button",{type:"button",className:"icon-button",title:"前进","aria-label":"前进",disabled:(_==null?void 0:_.canGoForward)!==!0,onClick:()=>E(e.navigate({action:"forward"})),children:n.jsx(Q,{name:"chevron"})}),n.jsx("button",{type:"button",className:"icon-button",title:"刷新","aria-label":"刷新",disabled:_===void 0,onClick:()=>E(e.navigate({action:"reload"})),children:n.jsx(Q,{name:"refresh"})}),n.jsx("input",{className:"text-input browser-address",value:d,placeholder:"输入网址,回车打开","aria-label":"网址",onFocus:U=>{p(!0),U.target.select()},onBlur:()=>p(!1),onChange:U=>h(U.target.value),onKeyDown:U=>{U.key==="Enter"&&!U.nativeEvent.isComposing&&z(),U.key==="Escape"&&U.target.blur()}}),n.jsx("button",{type:"button",className:"icon-button",title:"关闭浏览器面板(页面保留)","aria-label":"关闭浏览器面板",onClick:t,children:n.jsx(Q,{name:"close"})})]}),s!==null&&s.tabs.length>0&&n.jsxs("div",{className:"browser-tabs",role:"tablist","aria-label":"标签页",children:[s.tabs.map(U=>n.jsxs("span",{className:`browser-tab${U.id===s.shown?" active":""}`,children:[n.jsxs("button",{type:"button",role:"tab","aria-selected":U.id===s.shown,title:U.url,onClick:()=>E(e.select(U.id)),children:[U.loading&&n.jsx("span",{className:"pill-dot"}),U.title===""?U.url:U.title]}),n.jsx("button",{type:"button",className:"browser-tab-close",title:"关闭标签页","aria-label":`关闭 ${U.title}`,onClick:()=>E(e.close(U.id)),children:n.jsx(Q,{name:"close"})})]},U.id)),n.jsx("button",{type:"button",className:"browser-tab-new",title:"新标签页","aria-label":"新标签页",onClick:()=>{h(""),E(e.navigate({url:"about:blank",newTab:!0}))},children:n.jsx(Q,{name:"plus"})})]}),D&&n.jsxs("div",{className:"browser-status",children:[n.jsx("span",{className:"pill-dot"}),"agent 正在操作这个页面,你也可以直接接手"]}),g!==null&&n.jsx("div",{className:"banner error",children:g}),n.jsxs("div",{className:"browser-viewport",ref:N,children:[_===void 0?n.jsxs("div",{className:"empty",children:["还没有打开网页:在上面输入网址,或者让 agent 去打开。",n.jsx("br",{}),"内置浏览器不保存登录,也不能下载文件。"]}):r===null?n.jsx("div",{className:"empty",children:"正在载入…"}):n.jsx("canvas",{ref:l,className:"browser-frame","aria-label":_.title,onMouseDown:R,onMouseUp:M,onMouseMove:F,onWheel:L,onContextMenu:U=>U.preventDefault()}),n.jsx("textarea",{ref:j,className:"browser-typing","aria-label":"在页面里输入",tabIndex:-1,onKeyDown:A,onCompositionStart:()=>{y.current=!0},onCompositionEnd:()=>{y.current=!1,I()},onInput:()=>{y.current||I()}})]})]})}const Ld="adg.draft.",Kb=60,Kp=new Map;function uS(e){try{const t=localStorage.getItem(Ld+e);if(t===null)return"";const s=JSON.parse(t);return typeof s.text=="string"?s.text:""}catch{return""}}function oz(e,t){try{if(t.trim()===""){localStorage.removeItem(Ld+e);return}localStorage.setItem(Ld+e,JSON.stringify({text:t,at:Date.now()})),uz()}catch{}}function lz(e){return Kp.get(e)??[]}function cz(e,t){t.length===0?Kp.delete(e):Kp.set(e,[...t])}function uz(){const e=[];for(let t=0;t<localStorage.length;t++){const s=localStorage.key(t);if(!(s===null||!s.startsWith(Ld)))try{e.push({key:s,at:Number(JSON.parse(localStorage.getItem(s)??"{}").at)||0})}catch{e.push({key:s,at:0})}}if(!(e.length<=Kb))for(const t of e.sort((s,i)=>s.at-i.at).slice(0,e.length-Kb))localStorage.removeItem(t.key)}function dz({text:e,label:t="复制"}){const[s,i]=v.useState("idle"),r=v.useRef(void 0);v.useEffect(()=>()=>clearTimeout(r.current),[]);const o=async()=>{const u=await Xw(e);i(u?"copied":"failed"),clearTimeout(r.current),r.current=setTimeout(()=>i("idle"),1500)},l=s==="copied"?"已复制":s==="failed"?"复制失败":t;return n.jsx("button",{type:"button",className:`msg-action ${s==="idle"?"":s}`,title:l,"aria-label":l,onClick:()=>void o(),children:n.jsx(Q,{name:s==="copied"?"check":"copy"})})}function Mf(e,t){if(!t)return e;const s=t.text.replace(/\r\n?/g,`
|
|
193
|
-
`).split(`
|
|
194
|
-
`).map(i=>"> "+i);return`引用${t.author}消息(${t.id})
|
|
195
|
-
${s.join(`
|
|
196
|
-
`)}
|
|
197
|
-
|
|
198
|
-
${e}`}function cc(e){const t=/^引用(用户|助手)消息(([au]:\d+))\n/.exec(e),s=t?e.indexOf(`
|
|
199
|
-
|
|
200
|
-
`,t[0].length):-1;if(t&&s>=0){const i=e.slice(t[0].length,s).split(`
|
|
201
|
-
`);if(i.every(r=>r.startsWith("> "))){const r=t[1]==="用户"?"用户":"助手";return{body:e.slice(s+2),quote:{author:r,id:t[2],text:i.map(o=>o.slice(2)).join(`
|
|
202
|
-
`)}}}}return{body:e,quote:null}}const Nc=v.createContext(null);function hz({sessionId:e,children:t}){const[s,i]=v.useState(()=>cc(uS(e)).quote);return n.jsx(Nc.Provider,{value:{quote:s,select:i},children:t})}function dS({quote:e,onRemove:t}){return n.jsxs("div",{className:"message-quote",children:[n.jsxs("blockquote",{children:[n.jsxs("strong",{children:["回复",e.author]}),n.jsx("span",{title:e.text,children:e.text})]}),t&&n.jsx("button",{type:"button",className:"msg-action","aria-label":"取消引用",title:"取消引用",onClick:t,children:n.jsx(Q,{name:"close"})})]})}function Rf({text:e,author:t,id:s,canReply:i=!0}){const r=v.useContext(Nc);return n.jsxs("div",{className:"msg-actions",children:[n.jsx(dz,{text:e}),r&&i&&n.jsx("button",{type:"button",className:"msg-action","aria-label":"引用回复",title:"引用回复,可先选中一句话",onMouseDown:o=>o.preventDefault(),onClick:o=>{var h;const l=(h=o.currentTarget.closest(".message-line"))==null?void 0:h.querySelector("[data-reply-text]"),u=window.getSelection(),d=u&&(l!=null&&l.contains(u.anchorNode))&&l.contains(u.focusNode)?u.toString().trim():"";r.select({id:s,author:t,text:d||e})},children:n.jsx(Q,{name:"reply"})})]})}const mz={off:"不思考",none:"不思考",minimal:"最少",low:"低",medium:"中",high:"高",xhigh:"很高",max:"最大"},Yb=(e,t)=>mz[e]??(t!==void 0&&t!==e?t:e);function hS(e,t){return(t==null?void 0:t.next)??(t==null?void 0:t.lastUsed)??(e==null?void 0:e.default)??null}function fz(e,t){var s;if(!(e===null||t===null))return(s=e.groups.find(i=>i.id===t.provider))==null?void 0:s.models.find(i=>i.id===t.model)}function pz({client:e,sessionId:t,disabled:s,value:i,onChange:r}){var L;const{catalog:o,error:l}=aa(e),u=_e(e.sessionModels),d=_e(e.connection.status),[h,m]=v.useState(!1),[p,g]=v.useState(null),[x,N]=v.useState(!1),[j,y]=v.useState(""),k=v.useRef(null);v.useEffect(()=>{d.state!=="open"||t===void 0||e.sessionModel(t).catch(()=>{})},[e,t,d.state]),v.useEffect(()=>{if(!x)return;const A=z=>{k.current!==null&&!k.current.contains(z.target)&&N(!1)},I=z=>{z.key==="Escape"&&N(!1)};return document.addEventListener("mousedown",A),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",I)}},[x]);const _=t===void 0?void 0:u.get(t),S=t===void 0?i??(o==null?void 0:o.default)??null:hS(o,_),E=fz(o,S),O=S!==null&&o!==null&&E===void 0,P=async A=>{if(g(null),t===void 0){r==null||r(A);return}m(!0);try{await e.selectModel(t,A)}catch(I){g(I instanceof Error?I.message:String(I))}finally{m(!1)}},H=(A,I)=>{const z=(S==null?void 0:S.reasoningEffort)!==void 0&&I.efforts.some(D=>D.id===S.reasoningEffort)?S.reasoningEffort:I.defaultEffort;P({provider:A,model:I.id,...z===void 0?{}:{reasoningEffort:z}}),I.efforts.length===0&&N(!1)},B=v.useMemo(()=>{const A=j.trim().toLowerCase();return((o==null?void 0:o.groups)??[]).map(I=>({...I,models:I.models.filter(z=>A===""||z.id.toLowerCase().includes(A)||z.name.toLowerCase().includes(A)||I.name.toLowerCase().includes(A))})).filter(I=>I.models.length>0)},[o,j]),R=[p,l,...(o==null?void 0:o.failures.map(A=>`${A.name}:${A.message}`))??[]].filter(Boolean);if(o===null)return null;const M=(S==null?void 0:S.reasoningEffort)??(E==null?void 0:E.defaultEffort),F=(L=E==null?void 0:E.efforts.find(A=>A.id===M))==null?void 0:L.name;return n.jsxs("div",{className:`model-picker${p!==null?" has-error":""}`,ref:k,children:[n.jsxs("button",{type:"button",className:"model-trigger","aria-haspopup":"dialog","aria-expanded":x,disabled:s||h,title:R.length>0?R.join(`
|
|
203
|
-
`):"选择模型和思考强度",onClick:()=>N(A=>!A),children:[n.jsx("span",{className:`model-dot ${O?"off":""}`}),n.jsx("span",{className:"model-name",children:(E==null?void 0:E.name)??(S===null?"选择模型":`${S.model}(不可用)`)}),M!==void 0&&E!==void 0&&E.efforts.length>0&&n.jsx("span",{className:"model-effort",children:Yb(M,F)}),n.jsx(Q,{name:"chevron-down"})]}),x&&n.jsxs("div",{className:"model-panel",role:"dialog","aria-label":"选择模型",children:[n.jsx("input",{className:"text-input plain model-search",autoFocus:!0,placeholder:"搜索模型",value:j,onChange:A=>y(A.target.value)}),n.jsxs("div",{className:"model-list",role:"listbox","aria-label":"模型",children:[B.length===0&&n.jsx("div",{className:"muted small pad",children:"没有匹配的模型"}),B.map(A=>n.jsxs("div",{className:"model-group",children:[n.jsx("div",{className:"model-group-name",children:A.name}),A.models.map(I=>{const z=(S==null?void 0:S.provider)===A.id&&S.model===I.id;return n.jsxs("button",{type:"button",role:"option","aria-selected":z,className:`model-option ${z?"active":""}`,onClick:()=>H(A.id,I),children:[n.jsxs("span",{className:"model-option-main",children:[n.jsx("span",{children:I.name}),I.name!==I.id&&n.jsx("span",{className:"muted small",children:I.id})]}),I.efforts.length>0&&n.jsx("span",{className:"model-tag",children:"思考"}),z&&n.jsx(Q,{name:"check"})]},I.id)})]},A.id))]}),E!==void 0&&S!==null&&n.jsxs("div",{className:"model-efforts",children:[n.jsx("span",{className:"field-label",children:"思考强度"}),E.efforts.length===0?n.jsx("span",{className:"muted small",children:"这个模型没有可选的思考强度(在「设置 → 模型」里给模型打开「思考」)"}):n.jsx("div",{className:"segmented-control",role:"radiogroup","aria-label":"思考强度",children:E.efforts.map(A=>n.jsx("button",{type:"button",role:"radio","aria-checked":M===A.id,className:M===A.id?"active":"",onClick:()=>void P({provider:S.provider,model:S.model,reasoningEffort:A.id}),children:Yb(A.id,A.name)},A.id))})]}),R.length>0&&n.jsx("div",{className:"error small model-problems",children:R.join(";")})]})]})}let Jl=[],gz=1;const Yp=new Set,Xb=()=>{for(const e of Yp)e()},xz=e=>(Yp.add(e),()=>{Yp.delete(e)}),vz=()=>Jl[0];function yz(e,t){return new Promise(s=>{const i=gz++;Jl=[...Jl,{...e,id:i,single:t,settle:r=>{Jl=Jl.filter(o=>o.id!==i),Xb(),s(r)}}],Xb()})}function Ms(e){return yz(e,!1)}function bz(){const e=v.useSyncExternalStore(xz,vz);return e===void 0?null:n.jsx(kz,{pending:e},e.id)}function kz({pending:e}){const{title:t,message:s,quote:i,confirmLabel:r="确定",cancelLabel:o="取消",danger:l=!1,icon:u,single:d,settle:h}=e,m=v.useRef(null),p=v.useRef(null),g=v.useRef(null),x=`confirm-title-${e.id}`,N=`confirm-body-${e.id}`;return v.useEffect(()=>{var y;const j=document.activeElement;return(y=(l&&!d?g:p).current)==null||y.focus({preventScroll:!0}),()=>{j instanceof HTMLElement&&j.isConnected&&j.focus({preventScroll:!0})}},[l,d]),v.useEffect(()=>{const j=y=>{if(y.key==="Escape"){y.preventDefault(),y.stopPropagation(),h(!1);return}if(y.key!=="Tab"||m.current===null)return;const k=[...m.current.querySelectorAll("button:not(:disabled)")],_=k.indexOf(document.activeElement);y.preventDefault();const S=k[(_+(y.shiftKey?-1:1)+k.length)%k.length];S==null||S.focus()};return document.addEventListener("keydown",j,!0),()=>document.removeEventListener("keydown",j,!0)},[h]),n.jsx("div",{className:"dialog-backdrop confirm-backdrop",onPointerDown:j=>{j.target===j.currentTarget&&h(!1)},children:n.jsxs("div",{ref:m,className:`dialog confirm-dialog ${l?"danger":""}`,role:d?"dialog":"alertdialog","aria-modal":"true","aria-labelledby":x,"aria-describedby":s===void 0&&i===void 0?void 0:N,children:[n.jsxs("h3",{id:x,children:[(u!==void 0||l)&&n.jsx(Q,{name:u??"alert"}),t]}),(s!==void 0||i!==void 0)&&n.jsxs("div",{id:N,className:"confirm-body",children:[typeof s=="string"?n.jsx(jz,{text:s}):s,i!==void 0&&n.jsx("blockquote",{className:"confirm-quote",children:i})]}),n.jsxs("div",{className:"confirm-actions",children:[!d&&n.jsx("button",{ref:g,type:"button",onClick:()=>h(!1),children:o}),n.jsx("button",{ref:p,type:"button",className:l?"danger":"primary",onClick:()=>h(!0),children:r})]})]})})}function jz({text:e}){return n.jsx(n.Fragment,{children:e.split(/\n\s*\n/).map((t,s)=>{const i=t.split(`
|
|
204
|
-
`).filter(r=>r.trim()!=="");return i.length>0&&i.every(r=>r.startsWith("· "))?n.jsx("ul",{children:i.map((r,o)=>n.jsx("li",{children:r.slice(2)},o))},s):n.jsx("p",{children:t},s)})})}function Nz(e,t){return t.find(s=>s.scripts.includes(e.packId??e.id)||s.scripts.includes(e.id))}function zd(e,t){const s=e.toLowerCase();return t.find(i=>[i.id,i.name,...i.aliases].some(r=>r.toLowerCase()===s))}function mS(e,t,s){const i=[];for(const r of new Set((e==null?void 0:e.scripts)??[])){const o=t.find(u=>u.id===r||u.packId===r),l=o===void 0?s.find(u=>u.scripts.includes(r)):Nz(o,s);i.push({script:o===void 0?{id:r,name:r}:{id:o.id,name:o.name},...l===void 0?{}:{game:{id:l.id,name:l.name}}})}if(i.length===0)for(const r of new Set((e==null?void 0:e.games)??[])){const o=zd(r,s);i.push({game:o===void 0?{id:r,name:r}:{id:o.id,name:o.name}})}return i}function fS(e){var t,s;return[(t=e.game)==null?void 0:t.name,(s=e.script)==null?void 0:s.name].filter(i=>i!==void 0).join(" · ")}let Of=[];function wz(e){const t=_e(e.capabilities),s=t.has("skills"),i=t.has("scripts"),r=t.has("games"),[o,l]=v.useState(Of),[u,d]=v.useState(0);return v.useEffect(()=>e.connection.on("skills/changed",()=>d(h=>h+1)),[e]),v.useEffect(()=>{if(!s)return;let h=!0;const m=i?e.connection.call("scripts/list",{}).then(g=>g.scripts,()=>[]):Promise.resolve([]),p=r?e.connection.call("games/list",{}).then(g=>g.games,()=>[]):Promise.resolve([]);return Promise.all([e.connection.call("skills/list",{}),m,p]).then(([g,x,N])=>{Of=g.skills.filter(j=>j.userInvocable).map(j=>{const y=[...new Set(mS(j.owner,x,N).map(fS))].join("、");return{name:j.name,description:j.description,...y===""?{}:{group:y}}}),h&&l(Of)},()=>{}),()=>{h=!1}},[e,s,i,r,u]),o}const Pf=e=>e.kind==="command"?"命令":e.group??"通用技能";function pS({client:e,text:t,setText:s,area:i,submit:r,placement:o="above",inSession:l=!1}){const u=wz(e),[d,h]=v.useState(0),[m,p]=v.useState(!1),g=m?[]:eO(t,u,l),x=t.split(/\s/)[0];v.useEffect(()=>{h(0),p(!1)},[x]);const N=Math.min(d,Math.max(0,g.length-1)),j=S=>{var E;s(`/${S.name} `),p(!0),(E=i.current)==null||E.focus()},y=S=>{var E;if(r!==void 0&&S.kind==="command"&&S.arg===void 0){s(""),r(`/${S.name}`),(E=i.current)==null||E.focus();return}j(S)},k=S=>{if(g.length===0||S.nativeEvent.isComposing)return!1;if(S.key==="ArrowDown"||S.key==="ArrowUp")return S.preventDefault(),h((N+(S.key==="ArrowDown"?1:g.length-1))%g.length),!0;if(S.key==="Tab"||S.key==="Enter"&&!S.shiftKey){S.preventDefault();const E=g[N];return S.key==="Tab"?j(E):y(E),!0}return S.key==="Escape"?(S.preventDefault(),p(!0),!0):!1};return{menu:g.length===0?null:n.jsx(Sz,{options:g,active:N,placement:o,onHover:h,onChoose:y}),onKeyDown:k,expand:S=>Q2(S,u)}}function Sz({options:e,active:t,placement:s,onHover:i,onChoose:r}){const o=v.useRef(null),[l,u]=v.useState(0);v.useLayoutEffect(()=>{var m;const h=(m=o.current)==null?void 0:m.querySelector(`[data-index="${t}"]`);h==null||o.current===null||(h.scrollIntoView({block:"nearest"}),u(h.offsetTop-o.current.scrollTop))},[t,e]);const d=e[t];return n.jsxs("div",{className:`slash-pop ${s}`,children:[n.jsx("div",{ref:o,className:"slash-list",role:"listbox","aria-label":"命令和技能",onScroll:()=>{var m;const h=(m=o.current)==null?void 0:m.querySelector(`[data-index="${t}"]`);h!=null&&o.current!==null&&u(h.offsetTop-o.current.scrollTop)},children:e.map((h,m)=>n.jsxs("div",{children:[(m===0||Pf(e[m-1])!==Pf(h))&&n.jsx("div",{className:"slash-group",children:Pf(h)}),n.jsx("button",{type:"button",role:"option","data-index":m,"aria-selected":m===t,className:`slash-item ${m===t?"active":""}`,onMouseEnter:()=>i(m),onMouseDown:p=>p.preventDefault(),onClick:()=>r(h),children:h.name})]},`${h.kind}:${h.name}`))}),d!==void 0&&n.jsxs("div",{className:"slash-tip",style:{top:l},role:"tooltip",children:[d.kind==="skill"&&n.jsx("span",{className:"slash-tip-kind",children:d.group===void 0?"技能":`${d.group} 的技能`}),d.description,d.kind==="command"&&d.arg!==void 0&&n.jsxs("span",{className:"slash-tip-arg",children:["后面可以接:",d.arg]}),d.kind==="skill"&&n.jsx("span",{className:"slash-tip-arg",children:"后面写要它做的事"})]})]})}const Xp=5.5,Qb=2*Math.PI*Xp,Jb=[{key:"systemTokens",label:"系统提示词",tone:"system"},{key:"toolsTokens",label:"工具定义",tone:"tools"},{key:"messageTokens",label:"对话消息",tone:"messages"}];function Lf(e){return e>=1e6?`${ek(e/1e6)}M`:e>=1e3?`${ek(e/1e3)}k`:String(Math.round(e))}const ek=e=>e>=100?Math.round(e).toString():e.toFixed(1).replace(/\.0$/,"");function _z({context:e}){const[t,s]=v.useState(!1),i=v.useRef(null);if(v.useEffect(()=>{if(!t)return;const m=g=>{var x;(x=i.current)!=null&&x.contains(g.target)||s(!1)},p=g=>{g.key==="Escape"&&s(!1)};return document.addEventListener("pointerdown",m),document.addEventListener("keydown",p),()=>{document.removeEventListener("pointerdown",m),document.removeEventListener("keydown",p)}},[t]),e===null)return null;const r=Math.min(100,Math.round(e.usedTokens/e.contextWindow*100)),o=r>=90?"high":r>=70?"raised":"normal",l=e.breakdown,u=l===void 0?0:l.systemTokens+l.toolsTokens+l.messageTokens,d=l===void 0||u===0?[{key:"total",tone:"messages",width:r}]:Jb.map(m=>({key:m.key,tone:m.tone,width:r*l[m.key]/u})).filter(m=>m.width>0),h=`上下文已用 ${r}%`;return n.jsxs("span",{ref:i,className:`context-meter ${o}`,children:[n.jsxs("button",{type:"button",className:"context-trigger",title:h,"aria-label":h,"aria-haspopup":"dialog","aria-expanded":t,onClick:()=>s(!t),children:[n.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[n.jsx("circle",{className:"context-track",cx:"7",cy:"7",r:Xp}),n.jsx("circle",{className:"context-fill",cx:"7",cy:"7",r:Xp,strokeDasharray:`${Qb*r/100} ${Qb}`,transform:"rotate(-90 7 7)"})]}),n.jsxs("span",{children:[r,"%"]})]}),t&&n.jsxs("div",{className:"context-panel",role:"dialog","aria-label":"上下文用量",children:[n.jsxs("div",{className:"context-head",children:[n.jsxs("span",{children:["上下文已用 ",n.jsxs("strong",{children:[r,"%"]})]}),n.jsxs("span",{className:"context-figures",children:["~",Lf(e.usedTokens)," / ",Lf(e.contextWindow)]})]}),n.jsx("div",{className:"context-bar",children:d.map(m=>n.jsx("span",{className:`context-segment ${m.tone}`,style:{width:`${m.width}%`}},m.key))}),l!==void 0&&n.jsx("dl",{className:"context-rows",children:Jb.map(m=>n.jsxs("div",{children:[n.jsxs("dt",{children:[n.jsx("span",{className:`context-swatch ${m.tone}`,"aria-hidden":"true"}),m.label]}),n.jsxs("dd",{children:["~",Lf(l[m.key])]})]},m.key))}),n.jsxs("p",{className:"context-tip",children:["快满时会自动压缩(「设置 → 对话压缩」)。也可以输入 ",n.jsx("kbd",{children:"/压缩"})," 手动压缩:较早的部分换成摘要,agent 会忘掉其中的细节。"]})]})]})}const Ez=6e4,Cz={CNY:"¥",USD:"$"},bd=(e,t)=>{const s=Cz[e];return s===void 0?`${t} ${e}`:`${s}${t}`};function Az({balances:e}){const t=e.filter(s=>Number(s.total)!==0);return(t.length>0?t:e.slice(0,1)).map(s=>bd(s.currency,s.total)).join(" / ")}function $z(e){return`DeepSeek 账户余额 ${e.balances.map(s=>`${bd(s.currency,s.total)}(充值 ${bd(s.currency,s.toppedUp)},赠送 ${bd(s.currency,s.granted)})`).join("、")}${e.available?"":"。余额不足,调用模型会失败"}`}function Iz({client:e,sessionId:t,running:s}){var p;const{catalog:i}=aa(e),r=_e(e.sessionModels).get(t),o=((p=hS(i,r))==null?void 0:p.provider)??null,l=_e(e.credentialRevision),u=_e(e.connection.status),d=_e(e.capabilities),[h,m]=v.useState(null);return v.useEffect(()=>{if(o===null||u.state!=="open"||!d.has("providers"))return;let g=!0;const x=()=>e.providerBalance(o).then(j=>{g&&m({provider:o,balance:j,error:null})},j=>{g&&m({provider:o,balance:null,error:j instanceof Error?j.message:String(j)})});x();const N=s?setInterval(()=>void x(),Ez):void 0;return()=>{g=!1,clearInterval(N)}},[e,o,l,u.state,d,s]),h===null||h.provider!==o?null:h.error!==null?n.jsx("span",{className:"balance-chip failed",title:h.error,children:"余额 ?"}):h.balance===null||h.balance.balances.length===0?null:n.jsx("span",{className:`balance-chip ${h.balance.available?"":"low"}`,title:$z(h.balance),children:Az(h.balance)})}function Tz({client:e,session:t,running:s,disabled:i,initialPrompt:r,onInitialSent:o,reminder:l}){const u=_e(e.capabilities),{queue:d,context:h}=_e(t.state),m=d.filter(K=>K.placement!=="taken"),p=v.useContext(Nc),g=(p==null?void 0:p.quote)??null,[x,N]=v.useState(()=>cc(uS(t.id)).body),[j,y]=v.useState(!0),[k,_]=v.useState(null),[S,E]=v.useState(null),O=v.useRef(null),P=v.useRef(null),H=v.useRef(!1),[B,R]=v.useState(()=>lz(t.id));v.useEffect(()=>oz(t.id,Mf(x,g)),[t.id,x,g]),v.useEffect(()=>{var K;g&&((K=O.current)==null||K.focus())},[g]),v.useEffect(()=>cz(t.id,B),[t.id,B]);const M=kO(e),[F,L]=v.useState(!1),A=async K=>{const Z=K.filter(J=>J.type.startsWith("image/"));if(Z.length===0)return;_(null);const ee=Fl-B.length;if(ee<=0){_(`一条消息最多 ${Fl} 张图片`);return}try{const J=await Promise.all(Z.slice(0,ee).map(Oz));R(re=>[...re,...J].slice(0,Fl)),Z.length>ee&&_(`一条消息最多 ${Fl} 张图片,多的没有加上`)}catch(J){_(`图片没能加上:${J instanceof Error?J.message:String(J)}`)}},I=K=>{const Z=[...K.clipboardData.items].filter(ee=>ee.kind==="file"&&ee.type.startsWith("image/")).map(ee=>ee.getAsFile()).filter(ee=>ee!==null);Z.length!==0&&(K.preventDefault(),A(Z))},z=K=>{L(!1),K.dataTransfer.files.length!==0&&(K.preventDefault(),A([...K.dataTransfer.files]))};v.useEffect(()=>{var K;r===void 0||H.current||i||(H.current=!0,t.prompt(r,"queue").catch(Z=>_(Z instanceof Error?Z.message:String(Z))),o==null||o(),(K=O.current)==null||K.focus())},[r,i,t,o]);const D=K=>Y2(K)!=="compact"?!1:(N(""),_(null),s?(_("agent 正在工作,等它停下再压缩"),!0):(Ms({title:"压缩这个对话?",message:Mz,confirmLabel:"压缩",danger:!0}).then(Z=>{Z&&(E("正在压缩对话:模型在写摘要,可能要一两分钟…"),t.compact().then(ee=>E(ee.message),ee=>{E(null),_(ee instanceof Error?ee.message:String(ee))}))}),!0)),V=pS({client:e,text:x,setText:N,area:O,inSession:!0,submit:K=>{i||D(K)||(_(null),p==null||p.select(null),t.prompt(Mf(V.expand(K),g),s&&j?"steer":"queue").catch(Z=>_(Z instanceof Error?Z.message:String(Z))))}}),U=()=>{var ee;if(!i&&B.length===0&&D(x))return;const K=V.expand(x);if(!K.trim()&&B.length===0||i)return;const Z=B.map(({url:J,...re})=>re);N(""),R([]),_(null),p==null||p.select(null),t.prompt(Mf(K,g),s&&j?"steer":"queue",Z).catch(J=>_(J instanceof Error?J.message:String(J))),(ee=O.current)==null||ee.focus()},q=K=>{V.onKeyDown(K)||K.key==="Enter"&&!K.shiftKey&&!K.nativeEvent.isComposing&&(K.preventDefault(),U())},te=K=>{t.updateQueue(K.id,"remove").then(()=>{if(x.trim()===""&&!g&&K.text!==""){const Z=cc(K.text);N(Z.body),p==null||p.select(Z.quote)}},Z=>_(Z instanceof Error?Z.message:String(Z)))},G=K=>{t.updateQueue(K.id,"steer").catch(Z=>_(Z instanceof Error?Z.message:String(Z)))};return n.jsxs("div",{className:"composer",children:[k!==null&&n.jsx("div",{className:"error small composer-error",children:k}),m.length>0&&n.jsx("div",{className:"queue","aria-label":"等待发送的消息",children:m.map(K=>n.jsxs("div",{className:"queue-item",children:[n.jsx("span",{className:`queue-tag ${K.placement}`,children:K.placement==="next-step"?"插入中":"排队中"}),n.jsxs("span",{className:"queue-text",title:K.text,children:[cc(K.text).body||"(图片)",K.images!==void 0&&n.jsxs("span",{className:"muted",children:[" · ",K.images," 张图片"]})]}),n.jsx("span",{className:"queue-when muted",children:K.placement==="next-step"?"这一步做完就交给 agent":"这一轮结束后发送"}),K.placement==="next-turn"&&s&&n.jsx("button",{type:"button",className:"small-button",title:"不等这一轮结束,现在就交给 agent",onClick:()=>G(K),children:"现在插入"}),n.jsx("button",{type:"button",className:"small-button",title:"撤回这条消息",onClick:()=>te(K),children:"撤回"})]},K.id))}),l,S!==null&&n.jsxs("div",{className:"composer-note small",role:"status",children:[n.jsx("span",{children:S}),n.jsx("button",{type:"button",className:"ghost small-button",onClick:()=>E(null),children:"知道了"})]}),n.jsxs("div",{className:"slash-anchor",children:[V.menu,n.jsxs("div",{className:`composer-box ${F?"dragging":""}`,onDragOver:K=>{[...K.dataTransfer.items].some(Z=>Z.kind==="file")&&(K.preventDefault(),L(!0))},onDragLeave:()=>L(!1),onDrop:z,children:[g&&n.jsx(dS,{quote:g,onRemove:()=>{var K;p==null||p.select(null),(K=O.current)==null||K.focus()}}),B.length>0&&n.jsx("div",{className:"composer-images",children:B.map((K,Z)=>n.jsxs("span",{className:"composer-image",children:[n.jsx("img",{src:K.url,alt:K.name??`图片 ${Z+1}`}),n.jsx("button",{type:"button","aria-label":"移除这张图片",onClick:()=>R(ee=>ee.filter((J,re)=>re!==Z)),children:"✕"})]},Z))}),n.jsx("textarea",{onPaste:I,ref:O,"aria-label":"消息内容",value:x,onChange:K=>N(K.target.value),onKeyDown:q,rows:Math.min(8,Math.max(2,x.split(`
|
|
205
|
-
`).length)),placeholder:i?"未连接到 agent":s?j?"运行中:发出去会插进这一轮,改主意了直接说":"运行中:消息会排队到下一轮":"继续追问,或描述下一步要做的事",disabled:i}),n.jsxs("div",{className:"composer-actions",children:[u.has("models")&&n.jsx(pz,{client:e,sessionId:t.id,disabled:i}),n.jsx("button",{type:"button",className:"attach-button",title:"添加图片(也可以直接粘贴或拖进来)","aria-label":"添加图片",disabled:i||B.length>=Fl,onClick:()=>{var K;return(K=P.current)==null?void 0:K.click()},children:n.jsx(Q,{name:"image"})}),n.jsx("input",{ref:P,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:K=>{A([...K.target.files??[]]),K.target.value=""}}),M==="full"&&n.jsxs("button",{type:"button",className:"full-access-chip",title:"agent 做事不再请求确认,点这里修改",onClick:()=>{location.hash="#/settings/permissions"},children:[n.jsx(Q,{name:"alert"}),"完全访问"]}),n.jsx("span",{className:"spacer"}),n.jsx(Iz,{client:e,sessionId:t.id,running:s}),n.jsx(_z,{context:h}),s&&n.jsxs("label",{className:"steer-toggle",title:"这一步做完 agent 就会看到;不勾选就等这一轮结束再发",children:[n.jsx("input",{type:"checkbox",checked:j,onChange:K=>y(K.target.checked)}),"插入当前轮次"]}),s&&n.jsxs("button",{className:"stop-button",onClick:()=>void t.cancel().catch(K=>_(String(K))),disabled:i,children:[n.jsx(NO,{}),"停止"]}),n.jsx("button",{className:"send-button","aria-label":"发送",title:"发送(Enter)",onClick:U,disabled:i||x.trim()===""&&B.length===0,children:n.jsx(Q,{name:"arrow"})})]})]})]}),n.jsxs("div",{className:"composer-hint",children:[n.jsxs("span",{children:[n.jsx("kbd",{children:"/"})," 命令和技能"]}),n.jsxs("span",{children:[n.jsx("kbd",{children:"Enter"})," 发送"]}),n.jsxs("span",{children:[n.jsx("kbd",{children:"Shift+Enter"})," 换行"]}),n.jsxs("span",{children:[n.jsx("kbd",{children:"Ctrl+V"})," 粘贴图片"]})]})]})}const Mz=["压缩会把这个对话较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:","","· 会丢失记忆:早先的细节 agent 不再记得(具体的命令和输出、日志、截图、你说过的原话);","· 摘要可能漏掉或写错内容;","· 不能撤销。界面上的聊天记录还在,但 agent 看不到了。","","对话很长、回复变慢或报上下文超长时再压缩。"].join(`
|
|
206
|
-
`),Fl=4,Rz=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function Oz(e){const t=await new Promise((o,l)=>{const u=new FileReader;u.onload=()=>o(String(u.result)),u.onerror=()=>l(u.error??new Error("读取失败")),u.readAsDataURL(e)}),s=e.name===""||e.name==="image.png"?`粘贴的图片.${e.type.split("/")[1]??"png"}`:e.name,i=t.slice(t.indexOf(",")+1);if(Rz.has(e.type)&&i.length<=Mp)return{mediaType:e.type,data:i,name:s,url:t};const r=new Image;r.src=t,await r.decode();for(let o=2560;o>=640;o=Math.round(o*.75)){const l=Math.min(1,o/Math.max(r.naturalWidth,r.naturalHeight)),u=document.createElement("canvas");u.width=Math.max(1,Math.round(r.naturalWidth*l)),u.height=Math.max(1,Math.round(r.naturalHeight*l)),u.getContext("2d").drawImage(r,0,0,u.width,u.height);const d=u.toDataURL("image/jpeg",.88),h=d.slice(d.indexOf(",")+1);if(h.length<=Mp)return{mediaType:"image/jpeg",data:h,name:s.replace(/\.\w+$/,".jpg"),url:d}}throw new Error("图片太大")}const Qp=v.createContext(null);function tk({label:e,tone:t="running"}){return n.jsxs("div",{className:`thinking tone-${t}`,role:"status",children:[t==="waiting"?n.jsx(Q,{name:"clock"}):n.jsxs("span",{className:"dot-pulse","aria-hidden":!0,children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]}),e]})}const Pz={web_fetch:"正在读取网页",web_search:"正在搜索网页",read:"正在读取文件",write:"正在写入文件",edit:"正在编辑文件",run_code:"正在运行代码",game_activities:"正在核对游戏活动",game_notice:"正在保存公告",game_record:"正在保存活动",agent_threads:"正在查看任务进度",agent_message:"正在发送任务消息",script_runs:"正在查看脚本运行状态"};function gS(e){if(e.approval==="asked")return"等待你批准操作";if(e.name==="ask_user_question")return"等待你回答问题";if(e.name==="run_code")try{const{title:t}=JSON.parse(e.arguments);if(typeof t=="string"&&t.trim())return t.trim()}catch{}return Pz[e.name]??`正在调用 ${e.name}`}function Lz(e,t){v.useLayoutEffect(()=>{const s=e.current;if(s===null||typeof ResizeObserver>"u")return;let i=-1/0;const r=()=>{i=performance.now()},o=new ResizeObserver(()=>{!t.current||s.scrollHeight-s.scrollTop-s.clientHeight<=2||(performance.now()-i<zz?t.current=!1:s.scrollTop=s.scrollHeight)});o.observe(s);for(const l of s.children)o.observe(l);return s.addEventListener("pointerdown",r,!0),s.addEventListener("keydown",r,!0),()=>{o.disconnect(),s.removeEventListener("pointerdown",r,!0),s.removeEventListener("keydown",r,!0)}},[e,t])}const zz=400;function xS(e){const t=v.useRef(!0),s=v.useRef(0);return{following:t,onScroll:i=>{const r=i.currentTarget,o=r.scrollHeight-r.scrollTop-r.clientHeight,l=r.scrollTop<s.current-1;s.current=r.scrollTop,o<=2?t.current=!0:l?t.current=!1:o<e&&(t.current=!0)},onWheel:i=>{i.deltaY<0&&(t.current=!1)}}}const Dz=160;function uc(e,t=Dz){var i;const s=((i=e.split(/\r?\n/).find(r=>r.trim()!==""))==null?void 0:i.trim())??"";return s.length>t?`${s.slice(0,t-1)}…`:s}function nk(e,t="text"){return e.filter(s=>s.type===t).map(s=>s.text).join("")}function ec(e){const t=uc(nk(e));if(t!=="")return t;const s=uc(nk(e,"reasoning"));if(s!=="")return s;const i=e.filter(l=>l.type==="tool-call").map(l=>l.name);if(i.length>0)return`→ ${i.join(", ")}`;const r=e.filter(l=>l.type==="image").length,o=e.filter(l=>l.type==="file").length;return[r>0?`${r} image(s)`:"",o>0?`${o} file(s)`:""].filter(Boolean).join(" · ")}function Fz(e,t=null,s={}){var P,H,B,R,M,F,L;const i=[],r=new Map,o=[],l=new Map,u=new Map,d=new Map;let h=null,m=null,p=null,g=0,x=0;const N=(A,I)=>{let z=r.get(A);return z===void 0&&(z=zf(`t:${A}`,A,I,!0),r.set(A,z),i.push(z)),m=null,z},j=(A,I)=>h!==null?h:(m===null&&(m=zf(`b:${I}`,null,A,!1),i.push(m)),m),y=(A,I,z,D)=>{let V=A.steps.get(z);return V===void 0&&(V={turn:I,step:z,start:D,startKnown:!1,end:null,records:[],retries:0},A.steps.set(z,V),A.stepOrder.push(z)),V},k=(A,I,z)=>{A.records.push(z),I==null||I.records.push(z),o.push(z)},_=A=>(A.requestIndex??(A.requestIndex=++g),A.requestIndex),S=new Set;for(const A of e)switch(x=Math.max(x,A.time),A.type){case"turn/start":{const I=zf(`t:${A.turn}`,A.turn,A.time,!1);r.set(A.turn,I),i.push(I),h=I,m=null;break}case"turn/end":{const I=N(A.turn,A.time);I.end=A.time,I.reason=A.reason;for(const z of I.steps.values())z.end??(z.end=A.time);for(const z of l.values())z.turn===A.turn&&z.status==="running"&&(z.status="interrupted",z.end=A.time);h===I&&(h=null);break}case"step/start":{const I=N(A.turn,A.time),z=y(I,A.turn,A.step,A.time);z.start=A.time,z.startKnown=!0;break}case"step/end":{const I=N(A.turn,A.time);y(I,A.turn,A.step,A.time).end=A.time;break}case"user/message":{const I=j(A.time,A.seq);k(I,null,Uz(A,I.turn));break}case"system/message":{if(A.text.trim()==="")break;const I=N(A.turn,A.time),z=y(I,A.turn,A.step,A.time),D={kind:"system",id:`system:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:A.time,end:A.time,status:"ok",title:"System prompt",preview:uc(A.text),text:A.text};k(I,z,D);break}case"request/header":{p={...A.provider===void 0?{}:{provider:A.provider},...A.model===void 0?{}:{model:A.model},...A.reasoningEffort===void 0?{}:{reasoningEffort:A.reasoningEffort},toolCount:A.toolNames.length};break}case"assistant/attempt":{const I=N(A.turn,A.time),z=y(I,A.turn,A.step,A.time);Df(z,A.timing.firstTokenAt),z.retries+=1,A.error!==void 0&&(z.lastRetryError=A.error);const D={...A.usage===void 0?{}:{usage:A.usage},kind:"attempt",id:`attempt:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:A.timing.firstChunkAt??z.start,end:A.timing.lastChunkAt??A.time,status:"error",title:"Failed attempt",preview:((P=A.error)==null?void 0:P.message)??"attempt ended without output",...A.error===void 0?{}:{error:A.error}};k(I,z,D);break}case"assistant/message":{const I=N(A.turn,A.time),z=y(I,A.turn,A.step,A.time);Df(z,A.timing.firstTokenAt),S.add(`${A.turn}:${A.step}`);const D=A.timing.firstTokenAt,V=A.timing.lastChunkAt,U=D!==void 0&&V!==void 0?V-D:void 0,q=A.model??(p==null?void 0:p.model),te=A.provider??(p==null?void 0:p.provider),G={kind:"assistant",id:`assistant:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:z.start,end:V??A.time,status:A.interrupted===!0?"interrupted":"ok",title:q===void 0?"Assistant":`Assistant · ${q}`,preview:ec(A.content),content:A.content,live:!1,interrupted:A.interrupted===!0,request:ik({index:_(z),provider:te,model:q,reasoningEffort:p==null?void 0:p.reasoningEffort,toolCount:p==null?void 0:p.toolCount,ttftMs:sk(z),decodeMs:U,tokensPerSecond:Bz((H=A.usage)==null?void 0:H.outputTokens,U),usage:A.usage,retries:z.retries,lastRetryError:z.lastRetryError})};k(I,z,G);break}case"tool/call":{const I=N(A.turn,A.time),z=y(I,A.turn,A.step,A.time),D=d.get(A.callId),V={kind:"tool",id:`tool:${A.callId}`,seq:A.seq,turn:A.turn,step:A.step,start:A.time,end:null,status:I.end===null?"running":"interrupted",title:A.name,preview:uc(A.arguments),name:A.name,callId:A.callId,arguments:A.arguments,isError:!1,...D===void 0?{}:{approval:{approvalId:D}}};l.set(A.callId,V),k(I,z,V);break}case"tool/result":{const I=l.get(A.callId);if(I===void 0){const D=N(A.turn,A.time),V=y(D,A.turn,A.step,A.time),U={kind:"tool",id:`tool:${A.callId}`,seq:A.seq,turn:A.turn,step:A.step,start:A.time,end:A.time,status:A.isError?"error":"ok",title:"tool result",preview:ec(A.content),name:"tool result",callId:A.callId,arguments:"",result:A.content,isError:A.isError,...A.error===void 0?{}:{error:A.error}};k(D,V,U);break}I.end=A.time,I.result=A.content,I.isError=A.isError,I.status=A.isError?"error":"ok",A.error!==void 0&&(I.error=A.error);const z=ec(A.content);z!==""&&(I.preview=`${uc(I.arguments,80)} ⇒ ${z}`);break}case"approval/asked":{if(A.callId===void 0)break;d.set(A.callId,A.approvalId);const I=l.get(A.callId);I!==void 0&&(I.approval={approvalId:A.approvalId,...A.reason===void 0?{}:{reason:A.reason}});break}case"approval/decided":{for(const I of l.values())((B=I.approval)==null?void 0:B.approvalId)===A.approvalId&&(I.approval={...I.approval,outcome:A.outcome});break}case"compaction/start":{const I=A.turn===null?j(A.time,A.seq):N(A.turn,A.time),z={kind:"compaction",id:`compaction:${A.compactionId}`,seq:A.seq,turn:I.turn,step:null,start:A.time,end:null,status:"running",title:"Compaction",preview:"summarizing history…",compactionId:A.compactionId};u.set(A.compactionId,z),k(I,null,z);break}case"compaction/summary":{const I=u.get(A.compactionId);if(I===void 0)break;I.shadowedTokenCount=A.shadowedTokenCount,A.usage!==void 0&&(I.usage=A.usage),I.preview=`${A.shadowedTokenCount.toLocaleString("en-US")} tokens summarized`;break}case"compaction/end":{const I=u.get(A.compactionId);if(I===void 0)break;I.end=A.time,I.status=A.error===void 0?"ok":"error",A.error!==void 0&&(I.error=A.error,I.preview=A.error);break}}if(t!==null&&!S.has(`${t.turn}:${t.step}`)){const A=N(t.turn,((R=t.deltas[0])==null?void 0:R.time)??s.now??x),I=y(A,t.turn,t.step,((M=t.deltas[0])==null?void 0:M.time)??s.now??x),z=(F=t.deltas.find(q=>q.text!==""||q.toolName!==void 0))==null?void 0:F.time;Df(I,z);const D=Hz(t.deltas),V=(L=t.deltas.at(-1))==null?void 0:L.time;V!==void 0&&(x=Math.max(x,V));const U={kind:"assistant",id:`live:${t.attemptId}`,seq:t.afterSeq,turn:t.turn,step:t.step,start:I.start,end:null,status:"running",title:(p==null?void 0:p.model)===void 0?"Assistant":`Assistant · ${p.model}`,preview:ec(D)||"waiting for output…",content:D,live:!0,interrupted:!1,request:ik({index:_(I),provider:p==null?void 0:p.provider,model:p==null?void 0:p.model,reasoningEffort:p==null?void 0:p.reasoningEffort,toolCount:p==null?void 0:p.toolCount,ttftMs:sk(I),retries:I.retries,lastRetryError:I.lastRetryError})};k(A,I,U)}const E=i.map(A=>({key:A.key,turn:A.turn,start:A.start,end:A.end,partialStart:A.partialStart,...A.reason===void 0?{}:{reason:A.reason},steps:A.stepOrder.map(I=>{const z=A.steps.get(I);return{turn:z.turn,step:z.step,start:z.start,end:z.end,records:z.records}}),records:A.records})),O=s.now??x;return{groups:E,records:o,totals:Zz(o),span:Wz(o,O)}}function zf(e,t,s,i){return{key:e,turn:t,start:s,end:null,partialStart:i,steps:new Map,stepOrder:[],records:[]}}function Uz(e,t){const s=e.origin.human,i=s?"user":"context",r=e.content.filter(u=>u.type==="image").length,o=e.content.filter(u=>u.type==="file").length,l=s?"User":e.replacesHistory===!0?"Compacted history":`Context · ${e.origin.kind}`;return{kind:i,id:`user:${e.seq}`,seq:e.seq,turn:t,step:null,start:e.time,end:e.time,status:"ok",title:l,preview:e.origin.summary??ec(e.content),content:e.content,origin:e.origin,imageCount:r,fileCount:o}}function Df(e,t){t!==void 0&&(e.firstTokenAt===void 0||t<e.firstTokenAt)&&(e.firstTokenAt=t)}function sk(e){if(!e.startKnown||e.firstTokenAt===void 0)return;const t=e.firstTokenAt-e.start;return t>=0?t:void 0}function Bz(e,t){if(!(e===void 0||t===void 0||t<=0))return e/(t/1e3)}function Hz(e){const t=new Map;for(const s of e){const i=t.get(s.index);if(s.kind==="tool-args"){const r=(i==null?void 0:i.type)==="tool-call"?i:void 0;t.set(s.index,{type:"tool-call",callId:s.callId??(r==null?void 0:r.callId)??"",name:s.toolName??(r==null?void 0:r.name)??"",arguments:((r==null?void 0:r.arguments)??"")+s.text})}else{const r=s.kind==="text"?"text":"reasoning",o=(i==null?void 0:i.type)===r?i.text:"";t.set(s.index,{type:r,text:o+s.text})}}return[...t.entries()].sort((s,i)=>s[0]-i[0]).map(([,s])=>s)}function Zz(e){const t={requests:0,reportedUsage:0,missingUsage:0,toolCalls:0,errors:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,reasoningTokens:0};for(const s of e){s.status==="error"&&(t.errors+=1),s.kind==="tool"&&(t.toolCalls+=1);const i=s.kind==="assistant"?s.request.usage:s.kind==="compaction"||s.kind==="attempt"?s.usage:void 0;if(s.kind==="assistant"&&(t.requests+=1),i===void 0){(s.kind==="assistant"||s.kind==="attempt"||s.kind==="compaction"&&s.shadowedTokenCount!==void 0)&&t.missingUsage++;continue}t.reportedUsage++,t.inputTokens+=i.inputTokens,t.outputTokens+=i.outputTokens,t.cacheReadTokens+=i.cacheReadTokens??0,t.cacheWriteTokens+=i.cacheWriteTokens??0,t.reasoningTokens+=i.reasoningTokens??0}return t}function Wz(e,t){let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const r of e)s=Math.min(s,r.start),i=Math.max(i,r.end??Math.max(r.start,t));return Number.isFinite(s)?{start:s,end:Math.max(s,i)}:null}function ik(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const vS=[{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"}],Vz=new Map(vS.flatMap((e,t)=>e.kinds.map(s=>[s,t])));function qz(e){return e.records.map(t=>{const s=t.end===null||t.end<=t.start,i={record:t,lane:Vz.get(t.kind)??0,start:t.start,end:t.end===null?t.start:Math.max(t.start,t.end),instant:s};return t.kind==="assistant"&&t.request.ttftMs!==void 0&&t.end!==null?{...i,firstTokenAt:t.start+t.request.ttftMs}:i})}function Gz(e,t){const s=e.end??e.start;return e.start<=t.end&&s>=t.start}function Kz(e,t,s,i){const o=Math.max(10,(e.end-e.start)*s),l=e.end===e.start?.5:(t-e.start)/(e.end-e.start);let u=t-o*l,d=u+o;return d-u>=i.end-i.start?i:(u<i.start&&(d+=i.start-u,u=i.start),d>i.end&&(u-=d-i.end,d=i.end),{start:u,end:d})}function Yz(e,t,s){const i=e.end-e.start,r=Math.min(Math.max(s.start,e.start+t),s.end-i);return{start:r,end:r+i}}function Xz(e,t){const s=t.trim().toLowerCase();return s===""?e:e.filter(i=>i.title.toLowerCase().includes(s)||i.preview.toLowerCase().includes(s)?!0:i.kind==="tool"?i.arguments.toLowerCase().includes(s):!1)}function Zs(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 s=Math.floor(t/60);return s<60?`${s}m ${String(Math.floor(t%60)).padStart(2,"0")}s`:`${Math.floor(s/60)}h ${String(s%60).padStart(2,"0")}m`}function Nn(e){return e==null?"—":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(e<1e4?2:1)}k`:`${(e/1e6).toFixed(2)}M`}function Yr(e){const t=new Date(e),s=(i,r=2)=>String(i).padStart(r,"0");return`${s(t.getHours())}:${s(t.getMinutes())}:${s(t.getSeconds())}.${s(t.getMilliseconds(),3)}`}function ux(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const Qz=5*6e4,yS=["周日","周一","周二","周三","周四","周五","周六"],Dd=e=>{const t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()},tc=e=>`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`;function Jz(e,t=Date.now()){const s=new Date(e),i=Math.round((Dd(t)-Dd(e))/864e5);return i<=0?tc(s):i===1?`昨天 ${tc(s)}`:i<7?`${yS[s.getDay()]} ${tc(s)}`:`${s.getFullYear()===new Date(t).getFullYear()?"":`${s.getFullYear()}年`}${s.getMonth()+1}月${s.getDate()}日 ${tc(s)}`}function bS(e,t){return e===void 0?!1:t===void 0||e-t>=Qz||Dd(e)!==Dd(t)}function eD(e){const t=new Date(e);return`${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日${yS[t.getDay()]} ${tc(t)}`}function kS({at:e}){return n.jsxs("div",{className:"time-divider",children:[n.jsx("span",{className:"time-short",children:Jz(e)}),n.jsx("span",{className:"time-full","aria-hidden":!0,children:eD(e)})]})}const Jp="agent_delegate",jS=v.createContext([]),Vo=v.createContext(cn.name);function Bc(e){return`#/h/${encodeURIComponent(e.id)}`}function tD(e){try{const t=JSON.parse(e);return{agent:String(t.agent??""),task:String(t.task??"")}}catch{return{agent:"",task:e}}}function na(e,t){const i=$i(e).find(r=>r.name===t||r.id===t);return i===void 0?t===cn.name||t===cn.id?cn:void 0:Ka(i)}const dh={running:{label:"进行中",tone:"running"},waiting:{label:"等待答复",tone:"waiting"},done:{label:"交回了",tone:"ok"},failed:{label:"没做成",tone:"failed"}};function Hc({from:e,to:t,avatar:s,title:i,state:r,href:o}){const l=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`agent-avatar small agent-${(s==null?void 0:s.id)??"unknown"}`,children:n.jsx(Q,{name:(s==null?void 0:s.icon)??"sparkles"})}),n.jsxs("span",{className:"exchange-who",children:[e,n.jsx(Q,{name:"arrow",className:"delegation-arrow"}),n.jsx("strong",{children:t})]}),n.jsx("span",{className:"exchange-title",title:i,children:i}),r!==void 0&&n.jsxs("span",{className:`delegation-state tone-${r.tone}`,children:[r.tone==="running"&&n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),r.label]}),o!==void 0&&n.jsx(Q,{name:"chevron",className:"exchange-open"})]});return o===void 0?n.jsx("div",{className:`exchange-line tone-${(r==null?void 0:r.tone)??""}`,children:l}):n.jsx("a",{className:`exchange-line tone-${(r==null?void 0:r.tone)??""}`,href:o,title:"看它们说了什么",children:l})}function dx(e){var t;if(e.state==="failed"&&e.endedAt!==void 0){const s=(t=e.messages)==null?void 0:t.filter(i=>i.at>e.endedAt);if(s!=null&&s.some(i=>i.kind==="done"))return{label:"已补交结论",tone:"ok"};if(s!=null&&s.length)return{label:"结束后有新消息",tone:"asked"}}return dh[e.state]}function nD({client:e,item:t,handOffs:s}){const{agent:i,task:r}=v.useMemo(()=>tD(t.arguments),[t.arguments]),o=na(e,i),l=v.useContext(Vo),u=s.find(p=>p.callId===t.callId),d=t.status==="error"||t.status==="interrupted",h=t.status==="running"?{label:"正在派发",tone:"running"}:{label:"已派发",tone:"ok"},m=d?dh.failed:u?dx(u):h;return n.jsxs("div",{className:"delegation",children:[n.jsx(Hc,{from:l,to:(o==null?void 0:o.name)??i,avatar:o,title:(u==null?void 0:u.title)??r.split(`
|
|
207
|
-
`)[0]??"",state:m,href:u===void 0?void 0:Bc(u)}),d&&n.jsxs("div",{className:"delegation-failed",children:[n.jsx(Q,{name:"alert"}),t.result??t.error??"没有交出去"]})]})}function sD({client:e,handOff:t}){const s=na(e,t.to);return n.jsx("div",{className:"delegation app-handoff",children:n.jsx(Hc,{from:t.by,to:(s==null?void 0:s.name)??t.to,avatar:s,title:t.title,state:dx(t),href:Bc(t)})})}function iD({client:e,note:t,handOffs:s}){const i=na(e,t.agent),r=v.useContext(Vo),o=s.filter(u=>u.state!=="running"&&u.title===t.title&&(u.to===(i==null?void 0:i.id)||u.to===t.agent)).at(-1),l=o!==void 0?Bc(o):i!==void 0?`#/a/${encodeURIComponent(i.id)}`:void 0;return n.jsx("div",{className:"delegation relay-line",children:n.jsx(Hc,{from:t.agent,to:r,avatar:i,title:t.title,state:t.ok?dh.done:{label:"没有做完",tone:"failed"},href:l})})}function rD({client:e,note:t,handOffs:s}){const i=na(e,t.from),r=v.useContext(Vo),o=s.find(l=>l.id===t.thread);return n.jsx("div",{className:"delegation task-line",children:n.jsx(Hc,{from:t.from,to:r,avatar:i,title:t.text.split(`
|
|
208
|
-
`)[0]??t.title,state:{label:NS[t.kind],tone:t.kind==="question"?"asked":"ok"},href:o===void 0?void 0:Bc(o)})})}function aD({client:e,note:t,handOffs:s}){const[i,r]=v.useState(!1),o=s.filter(d=>d.by===t.by&&d.title===t.title).at(-1),l=na(e,t.by),u=na(e,(o==null?void 0:o.to)??"");return t.by===Hg?n.jsxs("div",{className:"msg user delegated",children:[n.jsx("div",{className:"msg-from",children:"你在软件里点的"}),n.jsx("div",{className:"bubble",children:n.jsxs("details",{className:"task-note",children:[n.jsx("summary",{children:t.title}),n.jsx("div",{className:"task-note-body",children:t.body})]})})]}):o!==void 0?n.jsx("div",{className:"delegation task-line",children:n.jsx(Hc,{from:t.by,to:(u==null?void 0:u.name)??o.to,avatar:l,title:t.title,state:dx(o),href:Bc(o)})}):n.jsxs("div",{className:"delegation task-line",children:[n.jsxs("button",{className:"exchange-line",onClick:()=>r(d=>!d),"aria-expanded":i,title:i?"收起":"看交给了什么",children:[n.jsx("span",{className:`agent-avatar small agent-${(l==null?void 0:l.id)??"unknown"}`,children:n.jsx(Q,{name:(l==null?void 0:l.icon)??"calendar"})}),n.jsxs("span",{className:"exchange-who",children:[t.by,"交给的事"]}),n.jsx("span",{className:"exchange-title",title:t.title,children:t.title}),n.jsx(Q,{name:i?"chevron-down":"chevron",className:"exchange-open"})]}),i&&n.jsx("div",{className:"exchange-msg-body task-unfolded",children:n.jsx(Hs,{text:t.body})})]})}function oD({client:e,handOff:t,name:s}){const i=_e(e.sessions).items.find(d=>d.id===t.toSession),r=cx(e,i===void 0?[]:[{id:i.id,updatedAt:i.updatedAt,running:i.running}]),o=i===void 0?void 0:r.get(i.id),l=v.useRef(void 0);l.current===void 0&&o!==void 0&&(l.current=o);const u=o!=null&&o!==""&&o!==l.current?o:void 0;return n.jsxs("div",{className:"delegation-now",children:[n.jsx("span",{className:"tool-spinner",role:"img","aria-label":"进行中"}),n.jsx("span",{children:(i==null?void 0:i.running)===!0?u??`${s} 正在做…`:`排在 ${s} 手上的事后面`})]})}function lD(e,t){const s=_e(e.connection.status),[i,r]=v.useState({item:null,error:null});return v.useEffect(()=>{if(s.state!=="open")return;let o=!0;return e.connection.call("handoffs/get",{id:t}).then(l=>{o&&r({item:l,error:null})},l=>{o&&r({item:null,error:l instanceof Error?l.message:String(l)})}),()=>{o=!1}},[e,t,s.state]),v.useEffect(()=>e.connection.on("handoffs/changed",({item:o})=>{o.id===t&&r({item:o,error:null})}),[e,t]),i}function cD(e,t){var h,m;const s=(h=t==null?void 0:t.chain)==null?void 0:h.at(-2),i=(m=t==null?void 0:t.chain)==null?void 0:m.at(-1),[r,o]=v.useState([]),[l,u]=v.useState(!1);return v.useEffect(()=>{if(t===null)return;if(s===void 0||i===void 0){u(!0);return}let p=!0;return e.connection.call("handoffs/between",{a:s,b:i}).then(g=>{p&&(o(g.items),u(!0))},()=>{p&&u(!0)}),()=>{p=!1}},[e,s,i,t===null]),v.useEffect(()=>e.connection.on("handoffs/changed",({item:p})=>{var N,j;const g=(N=p.chain)==null?void 0:N.at(-2),x=(j=p.chain)==null?void 0:j.at(-1);(g===s&&x===i||g===i&&x===s)&&o(y=>y.some(k=>k.id===p.id)?y.map(k=>k.id===p.id?p:k):[...y,p])}),[e,s,i]),t===null?{threads:[],ready:!1}:{threads:[...r.some(p=>p.id===t.id)?r:[...r,t]].sort((p,g)=>p.startedAt-g.startedAt),ready:l}}function uD(e,t,s,i){const r=[];for(const o of t){const l=s(o.by),u=s(o.to);r.push({kind:"said",key:`${o.id}:task`,thread:o.id,at:o.startedAt,who:l,body:n.jsxs(n.Fragment,{children:[n.jsx(Hs,{text:o.task}),o.expecting!==void 0&&n.jsxs("div",{className:"delegation-expecting",children:["要交回:",o.expecting]})]})}),r.push({kind:"aside",key:`${o.id}:subtasks`,thread:o.id,at:o.startedAt+1,body:n.jsx(KD,{client:e,session:o.toSession,from:o.startedAt,to:o.endedAt,onOpen:i})}),(o.messages??[]).forEach((h,m)=>{const p=o.endedAt!==void 0&&h.at>o.endedAt;h.kind==="done"&&!p||r.push({kind:"said",key:`${o.id}:${m}`,thread:o.id,at:h.at,who:s(h.from),kindOf:h.kind,body:n.jsxs(n.Fragment,{children:[p&&n.jsx("div",{className:"muted small",children:h.kind==="done"?"任务结束后补交的结论":"任务结束后收到的消息"}),n.jsx(Hs,{text:h.text})]})})}),o.state!=="running"&&o.state!=="waiting"?r.push({kind:"said",key:`${o.id}:reply`,thread:o.id,at:o.endedAt??o.startedAt,who:u,failed:o.state==="failed",body:n.jsxs(n.Fragment,{children:[n.jsx(Hs,{text:o.reply??(o.state==="failed"?"没有做完":"它没有留下回复")}),o.state==="failed"&&o.reply!==void 0&&n.jsx("div",{className:"muted small",children:"(该轮未完成)"})]})}):r.push({kind:"said",key:`${o.id}:now`,thread:o.id,at:Number.MAX_SAFE_INTEGER,who:u,body:o.state==="waiting"?n.jsxs("div",{className:"delegation-now",children:[n.jsx("span",{className:"tool-spinner",role:"img","aria-label":"等回答"}),n.jsxs("span",{children:["等",l,"回答"]})]}):n.jsx(oD,{client:e,handOff:o,name:u})})}return r.map((o,l)=>[o,l]).sort(([o,l],[u,d])=>o.at-u.at||l-d).map(([o])=>o)}function dD({client:e,id:t,onClose:s}){const{item:i,error:r}=lD(e,t),[o,l]=v.useState(null),u=$i(e),d=na(e,(i==null?void 0:i.by)??""),h=na(e,(i==null?void 0:i.to)??""),{threads:m,ready:p}=cD(e,i),g=GD(e,m),x=P=>{var H;return((H=u.find(B=>B.id===P))==null?void 0:H.name)??(P===cn.id?cn.name:P)},N=P=>{const H=u.find(B=>B.name===P||B.id===P);return H===void 0?P===cn.name||P===cn.id?cn:void 0:Ka(H)},j=i===null?[]:uD(e,m,x,l),y=v.useRef(null),k=v.useRef(!1);if(v.useLayoutEffect(()=>{const P=y.current;if(k.current||P===null||i===null||!p)return;k.current=!0;const H=P.querySelector(`[data-thread="${CSS.escape(i.id)}"]`);P.scrollTop=H===null?P.scrollHeight:P.scrollTop+H.getBoundingClientRect().top-P.getBoundingClientRect().top-12},[i,m,p]),v.useEffect(()=>{const P=H=>{H.key==="Escape"&&o===null&&s()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[s,o]),i===null)return n.jsx("section",{className:"main empty exchange-page",children:r??"正在打开…"});const _=(h==null?void 0:h.name)??i.to,S=dh[i.state],E=[];let O;for(const P of j){const H=P.at===Number.MAX_SAFE_INTEGER?void 0:P.at;if(H!==void 0&&bS(H,O)&&E.push(n.jsx(kS,{at:H},`t:${P.key}`)),H!==void 0&&(O=H),P.kind==="aside"){E.push(n.jsx("div",{className:"exchange-aside","data-thread":P.thread,children:P.body},P.key));continue}const B=N(P.who);E.push(n.jsxs("div",{className:`exchange-msg ${P.failed===!0?"failed":""}`,"data-thread":P.thread,children:[n.jsxs("div",{className:"exchange-msg-head",children:[n.jsx("span",{className:`agent-avatar small agent-${(B==null?void 0:B.id)??"unknown"}`,children:n.jsx(Q,{name:(B==null?void 0:B.icon)??"sparkles"})}),n.jsx("strong",{children:P.kindOf===void 0||P.kindOf==="done"?P.who:`${P.who} · ${NS[P.kindOf]}`})]}),n.jsx("div",{className:"exchange-msg-body",children:P.body})]},P.key))}return n.jsxs("section",{className:"main exchange-page",children:[n.jsx("header",{className:"session-header",children:n.jsxs("div",{className:"session-heading",children:[n.jsxs("div",{className:"breadcrumb agent-heading",children:[n.jsx("span",{className:`agent-avatar small agent-${(d==null?void 0:d.id)??"unknown"}`,children:n.jsx(Q,{name:(d==null?void 0:d.icon)??"calendar"})}),n.jsx("span",{children:i.by}),n.jsx(Q,{name:"arrow",className:"delegation-arrow"}),n.jsx("span",{className:`agent-avatar small agent-${(h==null?void 0:h.id)??"unknown"}`,children:n.jsx(Q,{name:(h==null?void 0:h.icon)??"sparkles"})}),n.jsx("h1",{children:_})]}),n.jsxs("div",{className:"session-meta",children:[n.jsx("span",{className:`delegation-state tone-${S.tone}`,children:S.label}),n.jsx("span",{children:i.title}),n.jsx("span",{children:new Date(i.startedAt).toLocaleString()})]})]})}),n.jsx("div",{className:"view",children:n.jsx(px.Provider,{value:l,children:n.jsxs("div",{className:`chat-split ${o===null?"":"with-pane"}`,children:[g.length>0&&n.jsx("div",{className:"chat-corner",children:n.jsx(ZS,{tasks:g,labels:hD,current:o==null?void 0:o.id,onOpen:l})}),n.jsx("div",{className:"chat",ref:y,children:n.jsx("div",{className:"chat-inner",children:E})}),o!==null&&n.jsx(gx,{client:e,task:o,parent:_,trail:i.by===_?[]:[i.by],onClose:()=>l(null)},o.id)]})})}),n.jsx("footer",{className:"exchange-footer",children:n.jsxs("button",{className:"small-button",onClick:s,children:[n.jsx(Q,{name:"close"}),"关闭"]})})]})}const hD=new Map,NS={question:"问",answer:"答",update:"说",done:"结论"},mD=3,fD=/^(编排|游戏信息|干预)[::]/,rk="adg:skill-offer:off",ak=e=>`adg:skill-offer:${e}`;function ok(e){try{return localStorage.getItem(e)}catch{return null}}function lk(e,t){try{localStorage.setItem(e,t)}catch{}}function pD(e){var r;let t=e.length-1;for(;t>=0&&e[t].kind!=="user";)t--;if(t<0)return;const s=e.slice(t+1),i=s.filter(o=>o.kind==="tool");if(!i.some(o=>o.name==="skill"||o.name==="skill_save"||o.status!=="ok")&&!s.some(o=>o.kind==="notice"&&o.tone==="error")&&!s.some(o=>o.kind==="context")&&!(i.length<mD||((r=s.at(-1))==null?void 0:r.kind)!=="assistant"))return e[t].id}function gD({session:e,title:t,items:s}){const i=pD(s),[r,o]=v.useState(()=>ok(rk)==="1"),[l,u]=v.useState(()=>ok(ak(e.id))),[d,h]=v.useState(!1);if(i===void 0||r||l===i||t!==null&&fD.test(t))return null;const m=()=>{lk(ak(e.id),i),u(i)},p=async()=>{h(!0);try{await e.prompt(dw),m()}finally{h(!1)}};return n.jsxs("div",{className:"skill-offer",role:"region","aria-label":"存成技能",children:[n.jsx(Q,{name:"sparkles"}),n.jsxs("div",{className:"skill-offer-text",children:[n.jsx("strong",{children:"要把这次的做法存成技能吗?"}),n.jsx("span",{children:"agent 会把刚才走通的步骤浓缩成一份技能;下次做同样的事直接照着做,不用重新摸索,少调用模型。"})]}),n.jsxs("div",{className:"skill-offer-actions",children:[n.jsx("button",{className:"link-button small",onClick:()=>{lk(rk,"1"),o(!0)},children:"不再提示"}),n.jsx("button",{className:"small-button",disabled:d,onClick:m,children:"这次不用"}),n.jsx("button",{className:"small-button primary",disabled:d,onClick:()=>void p(),children:"存成技能"})]})]})}function xD(e,t){const s=_e(e.connection.status),i=_e(e.capabilities),[r,o]=v.useState(null),l=t&&i.has("notify");return v.useEffect(()=>{if(!l||s.state!=="open")return;let u=!0;return e.connection.call("notify/notices",{}).then(d=>{u&&o(d.items)},()=>{u&&o(d=>d??[])}),()=>{u=!1}},[e,l,s.state]),v.useEffect(()=>{if(l)return e.connection.on("notify/notice",({item:u})=>o(d=>d===null?d:d.findIndex(m=>m.id===u.id)<0?[...d,u]:d.map(m=>m.id===u.id?u:m)))},[e,l]),l?r:vD}const vD=[];function yD(e,t,s,i){const r=t.filter(h=>h.at>=s);if(r.length===0)return[...e];const o=new Array(e.length);let l=1/0;for(let h=e.length-1;h>=0;h--){const m=e[h];"time"in m&&typeof m.time=="number"&&(l=m.time),o[h]=l}const u=[];let d=0;for(e.forEach((h,m)=>{if(i(h))for(;d<r.length&&r[d].at<o[m];)u.push(ck(r[d++]));u.push(h)});d<r.length;)u.push(ck(r[d++]));return u}function ck(e){return{kind:"sent",id:`sent:${e.id}`,notice:e}}const bD={info:"send",success:"check",warning:"alert",error:"alert"};function kD({client:e,notice:t}){const[s,i]=v.useState(null),[r,o]=v.useState(null),l=t.acted===void 0&&t.done===void 0&&t.actions.length>0,u=h=>{i(h),o(null),e.connection.call("notify/act",{noticeId:t.id,actionId:h}).catch(m=>o($e(m))).finally(()=>i(null))},d=new Date(t.at).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});return n.jsxs("div",{className:`sent-notice ${t.severity}`,children:[n.jsxs("div",{className:"sent-notice-head",children:[n.jsx(Q,{name:bD[t.severity]}),n.jsx("span",{className:"sent-notice-title",children:t.title}),n.jsx("span",{className:"spacer"}),n.jsxs("span",{className:"muted small",children:[t.channels.length>0?`发到${t.channels.join("、")}`:"只在软件里"," · ",d]})]}),n.jsx("div",{className:"sent-notice-text",children:t.text}),t.image===!0&&n.jsx("div",{className:"muted small",children:"(附了一张截图,在聊天软件里看)"}),l&&n.jsxs("div",{className:"sent-notice-actions",children:[t.actions.map(h=>n.jsx("button",{className:`small-button ${h.style==="primary"?"primary":h.style==="danger"?"danger-outline":""}`,disabled:s!==null,onClick:()=>u(h.id),children:s===h.id?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),h.label]}):h.label},h.id)),n.jsx("span",{className:"muted small",children:"也可以直接跟助手说"})]}),t.acted!==void 0&&n.jsxs("div",{className:"sent-notice-result",children:[n.jsx(Q,{name:"check"}),t.acted.by,"选了「",t.acted.label,"」——",t.acted.result]}),t.acted===void 0&&t.done!==void 0&&n.jsxs("div",{className:"sent-notice-result",children:[n.jsx(Q,{name:"check"}),t.done]}),r!==null&&n.jsx("div",{className:"error small",children:r})]})}const jD=80,ND=[];function wS({client:e,session:t,state:s,readOnly:i}){var ke,ge,Ae;const r=v.useMemo(()=>rh(s.events,s.live,s.pending,s.queue),[s.events,s.live,s.pending,s.queue,s.version]),o=v.useMemo(()=>r.filter(be=>!OS(be)),[r]),l=v.useMemo(()=>TS(s.events),[s.events]),u=v.useMemo(()=>RS(r,l,s.events),[r,l,s.events]),d=v.useMemo(()=>US(r,l),[r,l]),h=BS(e,t.id),m=$i(e),p=_e(e.sessions).items.find(be=>be.id===t.id),g=p===void 0?wn:aS(p,m),x=lS(e,wn),N=xD(e,p!==void 0?p.home===wn:x.sessionId===t.id),[j,y]=v.useState(!1),k=j||(s.status==="open"?N!==null:s.status!=="opening");k&&!j&&y(!0);const _=k&&N!==null?N:ND,S=s.hasMore?((ke=s.events[0])==null?void 0:ke.time)??0:0,E=v.useMemo(()=>CD(yD(o,_,S,_S)),[o,_,S]),O=v.useContext(fx),P=v.useContext(Vo),H=v.useContext(Nc),B=O!==null?P:((ge=m.find(be=>be.id===g))==null?void 0:ge.name)??cn.name,[R,M]=WD((p==null?void 0:p.role)??wn),F=O===null?R:3,L=v.useMemo(()=>ED(E,F),[E,F]),A=v.useMemo(()=>{let be;return L.map(qe=>{const ft=SD(qe),gt=bS(ft,be)?ft:void 0;return ft!==void 0&&(be=ft),gt})},[L]),[I,z]=v.useState(null),D=v.useContext(Qp),V=k&&O===null&&D===null?n.jsx(ZS,{tasks:h,labels:d,current:I==null?void 0:I.id,onOpen:z}):null,U=k&&O===null&&(s.running||h.length>0||E.some(be=>SS(be)>1)||o.some(be=>be.kind==="assistant"&&be.reasoning.trim()!=="")),q=XL(e,t.id),te=q.filter(be=>be.fromSession===t.id&&be.callId===void 0&&(be.state==="running"||be.state==="waiting")),G=F===1,K=s.events.findLast(be=>be.type==="turn/start"),Z=s.running?o.findLast(be=>be.kind==="tool"&&be.status==="running"&&be.time>=((K==null?void 0:K.time)??0)):void 0,ee=h.some(be=>be.running)||q.some(be=>be.state==="running"||be.state==="waiting"),J=o.at(-1),re=s.running&&s.events.some(be=>be.type==="user/message"&&be.origin.kind==="subagent-settled"&&be.seq>((K==null?void 0:K.seq)??0));let ie;s.running&&(Z?Z.name!==wc&&Z.name!==Jp&&(ie=gS(Z)):!ee&&!((J==null?void 0:J.kind)==="assistant"&&J.live&&J.text.trim())&&(ie=re?"正在汇总子任务结果":"正在处理请求"));const ne=v.useRef(null),me=xS(jD),Ce=me.following,Fe=be=>{me.onScroll(be),be.currentTarget.scrollTop<40&&s.hasMore&&!s.loadingOlder&&t.loadOlder()};v.useLayoutEffect(()=>{const be=ne.current;be!==null&&Ce.current&&(be.scrollTop=be.scrollHeight)},[o,_,k]),Lz(ne,Ce);const Me=(Ae=s.events[0])==null?void 0:Ae.seq,fe=v.useRef(0);return v.useLayoutEffect(()=>{const be=ne.current;be!==null&&(fe.current!==0&&!Ce.current&&(be.scrollTop+=be.scrollHeight-fe.current),fe.current=be.scrollHeight)},[Me]),n.jsx(Nc.Provider,{value:i?null:H,children:n.jsx(uh.Provider,{value:e,children:n.jsx(jS.Provider,{value:q,children:n.jsx(Vo.Provider,{value:B,children:n.jsx(px.Provider,{value:(D==null?void 0:D.openTask)??z,children:n.jsx(mx.Provider,{value:u,children:n.jsx(MS.Provider,{value:l,children:n.jsxs("div",{className:`chat-split ${I===null?"":"with-pane"}`,children:[(U||V!==null)&&n.jsxs("div",{className:"chat-corner",children:[V,U&&n.jsx(qD,{detail:R,onChange:M})]}),n.jsx("div",{className:"chat",ref:ne,onScroll:Fe,onWheel:me.onWheel,children:n.jsxs("div",{className:"chat-inner",children:[k&&s.hasMore&&n.jsx("button",{className:"link-button load-older",disabled:s.loadingOlder,onClick:()=>void t.loadOlder(),children:s.loadingOlder?"加载中…":"加载更早的消息"}),!k&&n.jsx("div",{className:"empty",children:"正在打开会话…"}),k&&s.status!=="opening"&&o.length===0&&n.jsxs("div",{className:"empty chat-empty",children:[n.jsx(Kg,{size:"lg"}),n.jsx("h2",{children:"今天,先从哪个游戏开始?"}),n.jsxs("p",{children:["问问哪些活动快结束、新版本有什么,或者让它把今天的日常清掉。",n.jsx("br",{}),"在下方写下来就行。"]})]}),k&&L.map((be,qe)=>n.jsx(_D,{at:A[qe],children:be.kind==="sent"?n.jsx(kD,{client:e,notice:be.item.notice},be.item.id):be.kind==="tools"?n.jsx(Ul,{name:B,header:be.header,children:n.jsx(CS,{tools:be.tools})},be.id):be.kind==="delegation"?n.jsx(Ul,{name:B,header:be.header,children:n.jsx(nD,{client:e,item:be.item,handOffs:q})},be.item.id):be.kind==="subtask"?n.jsx(Ul,{name:B,header:be.header,children:n.jsx(eg,{client:e,work:be.item,detailed:!G})},be.item.id):be.kind==="process"?n.jsx(Ul,{name:B,header:be.header,children:n.jsx(OD,{items:be.items,active:s.running&&qe===L.length-1,onDismiss:ft=>t.dismissPending(ft)})},be.id):n.jsx(Ul,{name:B,header:be.header,children:n.jsx(ES,{item:be.item,showReasoning:!G,onDismiss:ft=>t.dismissPending(ft)})},be.item.id)},wD(be))),k&&te.map(be=>n.jsx(sD,{client:e,handOff:be},be.id)),k&&(Z==null?void 0:Z.name)!==wc&&h.filter(be=>be.running&&!d.has(be.id)).map(be=>n.jsx(eg,{client:e,work:{id:be.id,label:qo(be.title??"")||"子任务"},detailed:!G},be.id)),k&&!s.running&&s.queue.length>0&&n.jsx(tk,{label:`${s.queue.length} 条消息排队中`,tone:"waiting"}),k&&ie&&n.jsx(tk,{label:ie,tone:(Z==null?void 0:Z.approval)==="asked"||(Z==null?void 0:Z.name)==="ask_user_question"?"waiting":"running"}),k&&i!==!0&&!s.running&&s.queue.length===0&&n.jsx(gD,{session:t,title:s.title,items:o})]})}),I!==null&&D===null&&n.jsx(gx,{client:e,task:I,parent:B,trail:g===wn?[]:[cn.name],onClose:()=>z(null)},I.id)]})})})})})})})})}function wD(e){return e.kind==="sent"?e.item.id:e.kind==="tools"||e.kind==="process"?e.id:e.item.id}function SD(e){var s;const t=i=>"time"in i?i.time:void 0;switch(e.kind){case"sent":return e.item.notice.at;case"tools":return(s=e.tools[0])==null?void 0:s.time;case"process":return e.items.map(t).find(i=>i!==void 0);default:return t(e.item)}}function _D({at:e,children:t}){return n.jsxs(n.Fragment,{children:[e!==void 0&&n.jsx(kS,{at:e}),t]})}function SS(e){switch(e.kind){case"subtask":return 3;case"delegation":case"process":return 2;case"tools":return e.tools.some(t=>t.approval==="asked")?1:2;case"sent":return 1;case"item":{if(e.item.kind!=="user"||e.item.pending!==void 0)return 1;const t=QN(e.item.text);return ew(e.item.text)!==void 0||JN(e.item.text)!==void 0||t!==void 0&&t.by!==Hg?2:1}}}function ED(e,t){if(t>1)return e;const s=[];let i=null;for(const r of e)r.kind==="sent"?s.push(r):SS(r)>1&&r.kind!=="subtask"&&r.kind!=="delegation"||r.kind==="item"&&r.item.kind==="assistant"&&!r.item.text.trim()&&!r.item.interrupted?i=r.header??i:r.kind==="item"&&r.item.kind==="user"?(i=null,s.push(r)):i!==null&&r.header===null&&!(r.kind==="item"&&(r.item.kind==="notice"||r.item.kind==="context"||r.item.kind==="fallback"))?(s.push({...r,header:i}),i=null):s.push(r);return s}function CD(e){const t=[];let s=0;for(let i=0;i<=e.length;i++){const r=e[i];r!==void 0&&r.kind!=="sent"&&!_S(r)||(AD(e.slice(s,i),t),r!==void 0&&t.push(r.kind==="sent"?{kind:"sent",item:r}:{kind:"item",item:r,header:null}),s=i+1)}return t}function _S(e){return e.kind==="user"||e.kind==="context"&&e.startsTurn===!0}function AD(e,t){let s=!1;const i=e.find(h=>h.kind==="assistant"&&h.model!==void 0),r=()=>s?null:(s=!0,{model:(i==null?void 0:i.kind)==="assistant"?i.model:void 0}),o=h=>{if(h.kind==="tool"&&h.name===Jp)t.push({kind:"delegation",item:h,header:r()});else if(h.kind==="tool"&&h.name===wc)t.push({kind:"subtask",item:h,header:r()});else if(h.kind==="tool"){const m=t.at(-1);(m==null?void 0:m.kind)==="tools"?t[t.length-1]={...m,tools:[...m.tools,h]}:t.push({kind:"tools",id:`tools-${h.id}`,tools:[h],header:r()})}else t.push({kind:"item",item:h,header:h.kind==="assistant"?r():null})};let l=[];const u=()=>{if(l.some(h=>h.kind==="tool"))t.push({kind:"process",id:`process-${l[0].id}`,items:l,header:r()});else for(const h of l)o(h);l=[]};let d=e.length;for(let h=e.length-1;h>=0;h--){const m=e[h];if(m.kind==="assistant"&&m.text.trim()!==""){d=h;break}}for(let h=0;h<d;h++){const m=e[h];m.kind==="notice"||m.kind==="context"||m.kind==="fallback"||m.kind==="tool"&&(m.approval==="asked"||m.name===Jp||m.name===wc)?(u(),o(m)):l.push(m)}u();for(let h=d;h<e.length;h++)o(e[h])}function Ul({name:e,header:t,children:s}){return t===null?n.jsx(n.Fragment,{children:s}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"turn-header",children:[n.jsx(Kg,{size:"sm"}),n.jsx("span",{className:"turn-name",children:e}),t.model!==void 0&&n.jsx("span",{className:"turn-model",children:t.model})]}),s]})}function $D({text:e}){const t=J2(e);return t===void 0?n.jsx(n.Fragment,{children:e}):n.jsxs(n.Fragment,{children:[t.typed,n.jsxs("details",{className:"slash-expansion",children:[n.jsx("summary",{children:"发给 agent 的完整指令"}),t.expansion]})]})}const ID=/^(这条消息来自([^。)]+)。[^\n]*)\n/,TD=/^(距离这个对话的上一条消息已经过了[^\n]*)\n/;function MD(e){const t=ID.exec(e),s=(t===null?e:e.slice(t[0].length)).replace(TD,"");return t===null?{text:s}:{text:s,channel:t[1]}}const ES=v.memo(function({item:t,onDismiss:s,showReasoning:i=!0}){var u;const r=v.useContext(uh),o=v.useContext(jS),l=v.useContext(fx);switch(t.kind){case"user":{if(l!==null)return n.jsxs("div",{className:"msg user delegated",children:[n.jsxs("div",{className:"msg-from",children:[l,"交给的事"]}),n.jsxs("div",{className:"message-line",children:[n.jsx("div",{className:"bubble",children:n.jsx(Hs,{text:qo(t.text)})}),n.jsx(Rf,{author:"助手",id:t.id,text:qo(t.text),canReply:!1})]})]});const d=t.pending===void 0?ew(t.text):void 0;if(d!==void 0&&r!==null)return n.jsx(iD,{client:r,note:d,handOffs:o});const h=t.pending===void 0?JN(t.text):void 0;if(h!==void 0&&r!==null)return n.jsx(rD,{client:r,note:h,handOffs:o});const m=t.pending===void 0?QN(t.text):void 0;if(m!==void 0&&r!==null)return n.jsx(aD,{client:r,note:m,handOffs:o});const p=MD(t.text),{body:g,quote:x}=cc(p.text);return n.jsxs("div",{className:`msg user ${t.pending===void 0?"":"pending"}`,children:[p.channel!==void 0&&n.jsxs("div",{className:"msg-from",children:["来自",p.channel]}),n.jsxs("div",{className:"message-line",children:[n.jsxs("div",{className:"bubble",children:[x&&n.jsx(dS,{quote:x}),n.jsx("div",{"data-reply-text":!0,children:n.jsx($D,{text:g})}),t.imageRefs.length>0&&n.jsx("div",{className:"chat-images",children:t.imageRefs.map(N=>n.jsx(zw,{image:N},N.attachmentId))}),(t.images>t.imageRefs.length||t.files>0)&&n.jsxs("div",{className:"attachments",children:[t.images>t.imageRefs.length&&n.jsxs("span",{children:[n.jsx(Q,{name:"image"}),t.images-t.imageRefs.length," 张图片"]}),t.files>0&&n.jsxs("span",{children:[n.jsx(Q,{name:"paperclip"}),t.files," 个文件"]})]})]}),g.trim()&&n.jsx(Rf,{author:"用户",id:t.id,text:g,canReply:t.pending===void 0})]}),((u=t.pending)==null?void 0:u.failed)!==void 0&&n.jsxs("div",{className:"send-failed",children:["发送失败:",t.pending.failed,n.jsx("button",{className:"link-button",onClick:()=>s(t.pending.requestId),children:"移除"})]})]})}case"assistant":return!t.live&&d2(t.text)?n.jsxs("div",{className:"quiet-reply",children:[n.jsx(Q,{name:"check"}),"看过了,没有要告诉你的"]}):n.jsxs("div",{className:`msg assistant ${t.live?"live":""}`,children:[i&&t.reasoning.trim()!==""&&n.jsxs("details",{className:"reasoning",open:t.live&&t.text==="",children:[n.jsxs("summary",{children:[n.jsx(Q,{name:"chevron"}),t.live&&t.text===""?n.jsx("span",{className:"shimmer",children:"正在思考…"}):"思考过程"]}),n.jsx(Hs,{text:t.reasoning})]}),t.text!==""&&n.jsxs("div",{className:"message-line",children:[n.jsx("div",{"data-reply-text":!0,children:n.jsx(Hs,{text:t.text})}),!t.live&&t.text.trim()&&n.jsx(Rf,{author:"助手",id:t.id,text:t.text})]}),t.live&&n.jsx("span",{className:"cursor"}),t.interrupted&&n.jsx("div",{className:"muted small",children:"(已中断)"})]});case"tool":return n.jsx(CS,{tools:[t]});case"context":return r&&"childId"in t&&typeof t.childId=="string"?n.jsx(eg,{client:r,work:{id:t.childId,label:t.summary},detailed:i}):n.jsxs("details",{className:"context-row",children:[n.jsxs("summary",{children:[n.jsx(Q,{name:"info"}),t.summary!==""?t.summary:t.title]}),n.jsx("pre",{children:t.text})]});case"notice":return n.jsxs("div",{className:`notice ${t.tone}`,children:[t.tone==="error"&&n.jsx(Q,{name:"alert"}),t.text]});case"fallback":return n.jsx(RD,{item:t})}});function RD({item:e}){const{from:t,to:s,reason:i,error:r,code:o,sub:l}=e.notice,u=d=>n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"fallback-provider",children:d.providerName}),n.jsx("span",{className:"fallback-model",children:d.modelName})]});return n.jsxs("div",{className:"fallback-card",role:"status",children:[n.jsxs("div",{className:"fallback-head",children:[n.jsx(Q,{name:"swap"}),n.jsx("strong",{children:l===!0?"子 agent 已切换到备用模型":"已切换到备用模型"}),n.jsx("span",{className:"fallback-reason",children:i})]}),n.jsxs("div",{className:"fallback-routes",children:[n.jsx("span",{className:"fallback-route from",children:u(t)}),n.jsx(Q,{name:"arrow",className:"fallback-arrow"}),n.jsx("span",{className:"fallback-route to",children:u(s)})]}),n.jsxs("details",{className:"fallback-error",children:[n.jsx("summary",{children:"报错原文"}),n.jsx("pre",{children:r.trim()===""?o:`${r}
|
|
209
|
-
(${o})`})]}),n.jsxs("div",{className:"fallback-foot muted small",children:["这个对话接下来用 ",s.modelName,",可以在输入框旁的模型选择里换回来;备用顺序在 设置 → 模型 里改。"]})]})}function OD({items:e,active:t,onDismiss:s}){const i=e.filter(h=>h.kind==="tool"),r=i.filter(h=>h.status==="running").length,o=i.filter(h=>h.status==="error").length,[l,u]=v.useState(!1),d=t&&!l?PD(e.at(-1)):void 0;return n.jsxs("div",{className:"tool-group process-group",children:[n.jsxs("button",{className:"tool-group-head",onClick:()=>u(!l),"aria-expanded":l,children:[n.jsx(Q,{name:"terminal"}),n.jsx("span",{className:"tool-group-title",children:`执行了 ${i.length} 个步骤`}),d!==void 0&&d!==""&&n.jsx("span",{className:"process-now",children:d}),n.jsxs("span",{className:"tool-group-meta",children:[r>0&&n.jsxs("span",{className:"tone-running",children:[r," 个进行中"]}),o>0&&n.jsxs("span",{className:"tone-failed",children:[o," 个失败"]})]}),n.jsx(Q,{name:"chevron-down",className:`chevron-icon ${l?"open":""}`})]}),l&&e.map(h=>h.kind==="tool"?n.jsx($S,{item:h},h.id):n.jsx("div",{className:"process-note",children:n.jsx(ES,{item:h,onDismiss:s})},h.id))]})}function PD(e){return e.kind==="tool"?`${e.name} ${Vg(e.arguments)}`.trim():e.kind==="assistant"?e.text.trim().split(`
|
|
210
|
-
`)[0]||"正在思考…":""}function CS({tools:e}){const t=e.filter(l=>l.status==="running").length,s=e.filter(l=>l.status==="error").length,[i,r]=v.useState(null),o=i??(t>0||s>0||e.length<=4);return n.jsxs("div",{className:"tool-group",children:[n.jsxs("button",{className:"tool-group-head",onClick:()=>r(!o),"aria-expanded":o,children:[n.jsx(Q,{name:"terminal"}),n.jsx("span",{className:"tool-group-title",children:e.length===1?"执行了 1 个步骤":`执行了 ${e.length} 个步骤`}),n.jsxs("span",{className:"tool-group-meta",children:[t>0&&n.jsxs("span",{className:"tone-running",children:[t," 个进行中"]}),s>0&&n.jsxs("span",{className:"tone-failed",children:[s," 个失败"]})]}),n.jsx(Q,{name:"chevron-down",className:`chevron-icon ${o?"open":""}`})]}),o&&e.map(l=>n.jsx($S,{item:l},l.id))]})}const AS={running:"运行中",ok:"完成",error:"失败",interrupted:"已中断"};function $S({item:e}){const[t,s]=v.useState(!1),i=v.useMemo(()=>Vg(e.arguments),[e.arguments]);return v.useEffect(()=>{e.status==="error"&&s(!0)},[e.status]),n.jsxs("div",{className:`tool ${e.status}`,children:[n.jsxs("button",{className:"tool-head",onClick:()=>s(r=>!r),"aria-expanded":t,children:[n.jsx(LD,{status:e.status}),n.jsx("span",{className:"tool-name",children:e.name}),n.jsx("span",{className:"tool-summary",children:i}),e.approval!==void 0&&n.jsx("span",{className:`badge approval-${e.approval}`,children:zD(e.approval)}),n.jsx("span",{className:"tool-status",children:AS[e.status]})]}),e.images!==void 0&&n.jsx("div",{className:"chat-images tool-images",children:e.images.map(r=>n.jsx(zw,{image:r},r.attachmentId))}),t&&n.jsxs("div",{className:"tool-body",children:[n.jsx("div",{className:"label",children:"参数"}),n.jsx("pre",{children:ux(e.arguments)}),e.result!==void 0&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"label",children:["结果",e.error!==void 0?` · ${e.error}`:""]}),n.jsx("pre",{children:e.result})]})]})]})}function LD({status:e}){return e==="running"?n.jsx("span",{className:"tool-spinner",role:"img","aria-label":"运行中"}):e==="ok"?n.jsx("span",{className:"tool-icon ok",role:"img","aria-label":"完成",children:n.jsx(Q,{name:"check"})}):e==="error"?n.jsx("span",{className:"tool-icon error",role:"img","aria-label":"失败",children:n.jsx(Q,{name:"close"})}):n.jsx("span",{className:"tool-icon",role:"img","aria-label":AS[e]??e,children:n.jsx(Q,{name:"info"})})}function zD(e){switch(e){case"asked":return"等待审批";case"allowed-once":return"已允许";case"rejected":return"已拒绝";case"cancelled":return"已撤回";default:return e}}const wc="subagent",IS=/started subagent (\S+)/;function TS(e){const t=new Map;for(const s of e){if(s.type!=="unknown"||s.upstreamType!=="subagent/catalog")continue;const i=s.data;typeof(i==null?void 0:i.childId)=="string"&&typeof i.name=="string"&&t.set(i.name,i.childId)}return t}const MS=v.createContext(new Map);function hx(e,t){if(e!==void 0)return t.get(e)??(/^agent-\d+$/.test(e)?void 0:e)}const DD=/\s*Your (?:parent agent\b|final answe)[\s\S]*$/;function qo(e){return e.replace(DD,"")}const FD=/^Background subagent (\S+) (finished|was stopped)?/;function RS(e,t,s=[]){const i=new Map;for(const r of e){if(!OS(r))continue;const o=FD.exec(r.summary);if(o===null)continue;const l=hx(o[1],t);l!==void 0&&i.set(l,o[2]==="finished"?Ko:o[2]==="was stopped"?uk:dk)}for(const r of s){if(r.type!=="unknown"||r.upstreamType!=="agent/inbox/spliced")continue;const o=r.data;for(const l of(o==null?void 0:o.inserted)??[]){const u=l.source;if((u==null?void 0:u.kind)!=="subagent-settled"||!u.senderSessionId||!u.stopReason)continue;const d=u.stopReason==="completed"?Ko:["aborted","interrupted"].includes(u.stopReason)?uk:dk;i.set(u.senderSessionId,{...d,at:r.time})}}return i}function OS(e){return e.kind==="context"&&e.title==="subagent-settled"}const mx=v.createContext(new Map),fx=v.createContext(null),px=v.createContext(()=>{});function PS(e){try{const t=JSON.parse(e);return{description:String(t.description??""),prompt:String(t.prompt??"")}}catch{return{description:"",prompt:e}}}function LS(e,t){return _e(e.sessions).items.find(s=>s.id===t)}const Go={label:"进行中",tone:"running"},Ko={label:"完成",tone:"ok"},uk={label:"已停止",tone:"failed"},dk={label:"没做成",tone:"failed"};function zS(e){const t=_e(e.state);return{tools:v.useMemo(()=>rh(t.events,t.live,t.pending).filter(i=>i.kind==="tool"),[t.events,t.live,t.pending,t.version]),events:t.events}}function UD({handle:e,label:t}){const{tools:s,events:i}=zS(e),r=i.findLast(u=>u.type==="turn/start"),o=s.findLast(u=>u.status==="running"&&u.time>=((r==null?void 0:r.time)??0)),l=o&&gS(o);return l&&l!==t?n.jsx("span",{title:l,children:l}):Go.label}function DS({client:e,id:t,label:s}){const i=Fc(e,t);return i?n.jsx(UD,{handle:i,label:s}):Go.label}function BD({client:e,id:t,running:s}){const i=Fc(e,t);return i?n.jsx(HD,{handle:i,running:s}):n.jsx("div",{className:"subtask-steps muted small",children:"正在打开…"})}function HD({handle:e,running:t}){const{tools:s}=zS(e);if(s.length===0)return n.jsx("div",{className:"subtask-steps muted small",children:t?"正在开始…":"没有用工具"});const i=t?s.slice(-4):s;return n.jsx("ol",{className:"subtask-steps",children:i.map(r=>n.jsxs("li",{className:r.status==="error"?"failed":"",children:[r.status==="running"?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(Q,{name:r.status==="error"?"alert":"check"}),n.jsx("span",{className:"subtask-step-name",children:r.name}),n.jsx("span",{className:"subtask-step-args",children:Vg(r.arguments)})]},r.id))})}function FS({label:e,title:t,state:s,action:i,onOpen:r}){return n.jsxs("button",{type:"button",className:`exchange-line subtask-line tone-${s.tone}`,disabled:!r,title:t,onClick:r,children:[n.jsx(Q,{name:"flow"}),n.jsx("span",{className:"exchange-who",children:"子任务"}),n.jsx("span",{className:"exchange-title",children:e}),n.jsxs("span",{className:`delegation-state tone-${s.tone}`,"aria-live":"polite",children:[s.tone==="running"&&n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),n.jsx("span",{className:"subtask-activity",children:i??s.label})]}),r&&n.jsx(Q,{name:"chevron",className:"exchange-open"})]})}function eg({client:e,work:t,detailed:s=!1}){var P;const i=v.useContext(MS),r=v.useContext(mx),o=v.useContext(px),l="kind"in t?t:void 0,u=l&&PS(l.arguments),d="kind"in t?hx((P=IS.exec(t.result??""))==null?void 0:P[1],i):t.id,h=("label"in t?t.label:(u==null?void 0:u.description)||(u==null?void 0:u.prompt.split(`
|
|
211
|
-
`)[0]))||"子任务",m=LS(e,d),p=_e(e.approvals).some(H=>H.sessionId===d),g=_e(e.questions).some(H=>H.sessionId===d),x=d?r.get(d):void 0,N=(l==null?void 0:l.status)==="error"||(l==null?void 0:l.status)==="interrupted",j=x&&(!(m!=null&&m.running)||x.at!==void 0&&m.updatedAt<=x.at);let y;N?y={label:l.status==="error"?"派发失败":"派发已中断",tone:"failed"}:j?y=x:p||g?y={label:p?"等待你批准操作":"等待你回答问题",tone:"waiting"}:m!=null&&m.running?y=Go:m&&!m.blank?y=Ko:y={label:d?"已派发":"正在派发子任务",tone:"running"};const k=!!(m!=null&&m.running)&&!j&&!N,_=cx(e,s&&m&&!k&&!N?[m]:[]),S=d&&_.get(d),[E,O]=v.useState(!1);return n.jsxs("div",{className:"delegation task-line",children:[n.jsx(FS,{label:h,title:(u==null?void 0:u.prompt)||h,state:y,onOpen:d?()=>o({id:d,label:h}):void 0,action:m&&y===Go?n.jsx(DS,{client:e,id:m.id,label:h}):void 0}),N&&n.jsxs("div",{className:"delegation-failed",children:[n.jsx(Q,{name:"alert"}),l.result||l.error||y.label]}),s&&d&&(k||E)&&n.jsx(BD,{client:e,id:d,running:k}),s&&S&&n.jsx("div",{className:"subtask-answer",children:n.jsx(Hs,{text:S})}),s&&!k&&!N&&d&&n.jsxs("button",{className:"link-button subtask-fold","aria-expanded":E,onClick:()=>O(H=>!H),children:[n.jsx(Q,{name:E?"chevron-down":"chevron"}),E?"收起步骤":"看步骤"]})]})}function gx({client:e,task:t,parent:s,trail:i,onClose:r}){const o=Fc(e,t.id),l=LS(e,t.id),[u,d]=v.useState(null),h=(l==null?void 0:l.running)===!0,m=()=>e.connection.call("subagents/stop",{sessionId:t.id}).then(()=>d(null),p=>d(p instanceof Error?p.message:String(p)));return n.jsxs("aside",{className:"subagent-pane","aria-label":`子任务:${t.label}`,children:[n.jsxs("header",{className:"subagent-pane-head",children:[n.jsxs("div",{className:"subagent-trail",children:[[...i,s].map((p,g)=>n.jsxs("span",{children:[p,n.jsx("span",{className:"subagent-trail-sep",children:"›"})]},g)),n.jsx("strong",{title:t.label,children:t.label})]}),h&&n.jsxs("button",{className:"small-button",onClick:()=>void m(),children:[n.jsx(Q,{name:"close"}),"停止"]}),n.jsx("button",{className:"icon-button","aria-label":"关闭",title:"关闭",onClick:r,children:n.jsx(Q,{name:"close"})})]}),u!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:u})]}),n.jsx("div",{className:"subagent-pane-body",children:o===null?n.jsx("div",{className:"empty",children:"正在打开…"}):n.jsx(ZD,{client:e,handle:o,parent:s})})]})}function ZD({client:e,handle:t,parent:s}){const i=_e(t.state);return n.jsx(fx.Provider,{value:s,children:n.jsx(Vo.Provider,{value:`${s}的子 agent`,children:n.jsx(wS,{client:e,session:t,state:i,readOnly:!0})})})}const hk="adg.chatDetail.";function WD(e){const t=()=>{try{return Number(localStorage.getItem(hk+e))===1?1:3}catch{return 3}},[s,i]=v.useState(()=>({agentId:e,detail:t()}));return[s.agentId===e?s.detail:t(),o=>{i({agentId:e,detail:o});try{localStorage.setItem(hk+e,String(o))}catch{}}]}const VD=[{level:1,label:"汇报",hint:"只看它和你说的话"},{level:3,label:"全部",hint:"加上 agent 之间的往来和子任务的步骤、答案"}];function qD({detail:e,onChange:t}){return n.jsx("div",{className:"chat-detail segmented-control",role:"radiogroup","aria-label":"显示多少",children:VD.map(s=>n.jsx("button",{role:"radio","aria-checked":e===s.level,className:e===s.level?"active":"",title:s.hint,onClick:()=>t(s.level),children:s.label},s.level))})}function US(e,t){var i;const s=new Map;for(const r of e){if(r.kind==="context"&&"childId"in r&&typeof r.childId=="string"&&s.set(r.childId,r.summary),r.kind!=="tool"||r.name!==wc)continue;const o=hx((i=IS.exec(r.result??""))==null?void 0:i[1],t);if(o===void 0)continue;const{description:l,prompt:u}=PS(r.arguments),d=l!==""?l:u.split(`
|
|
212
|
-
`)[0]??"";s.set(o,d||"子任务")}return s}function BS(e,t){const s=_e(e.sessions).items;return v.useMemo(()=>s.filter(i=>i.origin==="subagent"&&i.parentId===t),[s,t])}function HS(e,t,s,i){return e.origin==="subagent"&&e.parentId===t&&e.updatedAt>=s&&(i===void 0||e.updatedAt<=i+2e3)}function GD(e,t){const s=_e(e.sessions).items;return v.useMemo(()=>s.filter(i=>t.some(r=>HS(i,r.toSession,r.startedAt,r.endedAt))),[s,t])}const Ff=30;function ZS({tasks:e,labels:t,current:s,onOpen:i}){const r=v.useContext(mx),[o,l]=v.useState(!1),u=v.useRef(null),d=vn(6e4);v.useEffect(()=>{if(!o)return;const j=k=>{var _;(_=u.current)!=null&&_.contains(k.target)||l(!1)},y=k=>{k.key==="Escape"&&l(!1)};return document.addEventListener("pointerdown",j),document.addEventListener("keydown",y),()=>{document.removeEventListener("pointerdown",j),document.removeEventListener("keydown",y)}},[o]);const h=[...e].sort((j,y)=>y.updatedAt-j.updatedAt),m=h.filter(j=>j.running),p=h.filter(j=>!j.running);if(e.length===0)return null;const g=j=>t.get(j.id)??(qo(j.title??"")||"子任务"),x=j=>{const y=j.running?Go:r.get(j.id)??Ko,k=g(j);return n.jsx("li",{children:n.jsxs("button",{className:`subtask-tracker-row ${j.id===s?"active":""}`,title:k,onClick:()=>{l(!1),i({id:j.id,label:k})},children:[j.running?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(Q,{name:y===Ko?"check":"alert",className:`tone-${y.tone}`}),n.jsx("span",{className:"subtask-tracker-label",children:k}),n.jsx("span",{className:`delegation-state tone-${y.tone}`,children:j.running?y.label:`${y.label} · ${vt(j.updatedAt,d)}`}),n.jsx(Q,{name:"chevron",className:"exchange-open"})]})},j.id)},N=m.length>0?`${m.length} 个子任务在跑`:"子任务";return n.jsxs("div",{ref:u,className:"subtask-tracker",children:[n.jsxs("button",{type:"button",className:`subtask-tracker-toggle ${m.length>0?"tone-running":""}`,"aria-haspopup":"dialog","aria-expanded":o,title:`进行中 ${m.length} 个,已结束 ${p.length} 个;点开看每一个的窗口`,onClick:()=>l(j=>!j),children:[m.length>0?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(Q,{name:"flow"}),n.jsx("span",{children:N}),p.length>0&&n.jsxs("span",{className:"subtask-tracker-ended",children:["已结束 ",p.length]}),n.jsx(Q,{name:"chevron-down",className:"subtask-tracker-chevron"})]}),o&&n.jsxs("div",{className:"subtask-tracker-panel",role:"dialog","aria-label":"子任务",children:[n.jsxs("section",{children:[n.jsxs("div",{className:"subtask-tracker-head",children:["进行中",n.jsx("span",{className:"skills-count",children:m.length})]}),m.length===0?n.jsx("p",{className:"muted small subtask-tracker-empty",children:"现在没有在跑的子任务"}):n.jsx("ul",{children:m.map(x)})]}),p.length>0&&n.jsxs("section",{children:[n.jsxs("div",{className:"subtask-tracker-head",children:["已结束",n.jsx("span",{className:"skills-count",children:p.length})]}),n.jsx("ul",{children:p.slice(0,Ff).map(x)}),p.length>Ff&&n.jsxs("p",{className:"muted small subtask-tracker-empty",children:["更早的 ",p.length-Ff," 个在对话里"]})]})]})]})}function KD({client:e,session:t,from:s,to:i,onOpen:r}){const o=_e(e.sessions).items.filter(l=>HS(l,t,s,i));return o.length===0?null:n.jsx("div",{className:"delegation thread-subtasks",children:o.map(l=>{const u=qo(l.title??"")||"子任务",d=l.running?Go:Ko;return n.jsx(FS,{label:u,title:u,state:d,onOpen:()=>r({id:l.id,label:u}),action:l.running?n.jsx(DS,{client:e,id:l.id,label:u}):void 0},l.id)})})}const WS=[{id:"tasks",icon:"list",title:"子任务",hint:"子任务:正在做和做完的,点开看每一个的对话"},{id:"commands",icon:"terminal",title:"命令",hint:"命令:这个对话和它的子任务运行的命令和程序"},{id:"browser",icon:"globe",title:"浏览器",hint:"内置浏览器:看 agent 操作网页,也可以自己接手"}];function mk({title:e,actions:t,onClose:s,children:i}){return n.jsxs("aside",{className:"side-panel","aria-label":e,children:[n.jsxs("header",{className:"side-panel-head",children:[n.jsx("h2",{children:e}),t,n.jsx("button",{type:"button",className:"icon-button",title:"关闭侧栏","aria-label":"关闭侧栏",onClick:s,children:n.jsx(Q,{name:"close"})})]}),n.jsx("div",{className:"side-panel-body",children:i})]})}const YD={label:"进行中",tone:"running"},fk={label:"完成",tone:"ok"};function VS(e,t){return t.get(e.id)??(qo(e.title??"")||"子任务")}function XD({tasks:e,labels:t,settled:s,onOpen:i}){const r=vn(6e4),o=[...e].sort((h,m)=>m.updatedAt-h.updatedAt),l=o.filter(h=>h.running),u=o.filter(h=>!h.running),d=h=>{const m=h.running?YD:s.get(h.id)??fk,p=VS(h,t);return n.jsx("li",{children:n.jsxs("button",{className:"subtask-tracker-row",title:p,onClick:()=>i({id:h.id,label:p}),children:[h.running?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(Q,{name:m===fk?"check":"alert",className:`tone-${m.tone}`}),n.jsx("span",{className:"subtask-tracker-label",children:p}),n.jsx("span",{className:`delegation-state tone-${m.tone}`,children:h.running?m.label:`${m.label} · ${vt(h.updatedAt,r)}`}),n.jsx(Q,{name:"chevron",className:"exchange-open"})]})},h.id)};return e.length===0?n.jsxs("div",{className:"side-empty",children:["这个对话还没有开过子任务。",n.jsx("br",{}),"agent 把具体的活交给子 agent 时,会列在这里。"]}):n.jsxs("div",{className:"side-list",children:[n.jsxs("section",{children:[n.jsxs("div",{className:"subtask-tracker-head",children:["进行中",n.jsx("span",{className:"skills-count",children:l.length})]}),l.length===0?n.jsx("p",{className:"muted small subtask-tracker-empty",children:"现在没有在跑的子任务"}):n.jsx("ul",{children:l.map(d)})]}),u.length>0&&n.jsxs("section",{children:[n.jsxs("div",{className:"subtask-tracker-head",children:["已结束",n.jsx("span",{className:"skills-count",children:u.length})]}),n.jsx("ul",{children:u.map(d)})]})]})}const QD=new Set(["pwsh","bash","run_code"]);function JD(e){let t={};try{t=JSON.parse(e.arguments)}catch{}const s=e.name==="run_code";return{text:typeof(s?t.code:t.command)=="string"?String(s?t.code:t.command):"",description:typeof t.description=="string"?t.description:"",program:s}}function qS(e){return e.filter(t=>t.kind==="tool"&&QD.has(t.name))}function e3({client:e,own:t,tasks:s,labels:i}){const r=v.useMemo(()=>[...s].sort((o,l)=>Number(l.running)-Number(o.running)||l.updatedAt-o.updatedAt).slice(0,Uf),[s]);return n.jsxs("div",{className:"side-list commands",children:[r.map(o=>n.jsx(t3,{client:e,task:o,label:VS(o,i)},o.id)),n.jsx(xx,{title:"这个对话",running:!1,commands:t,empty:"这个对话自己没有运行命令(命令多由子任务运行)"}),s.length>Uf&&n.jsxs("p",{className:"muted small side-note",children:["更早的 ",s.length-Uf," 个子任务的命令在它们的对话里(子任务面板)"]})]})}const Uf=8;function t3({client:e,task:t,label:s}){const i=Fc(e,t.id);return i===null?n.jsx(xx,{title:s,running:t.running,commands:[],empty:"正在打开…"}):n.jsx(n3,{handle:i,label:s,running:t.running})}function n3({handle:e,label:t,running:s}){const i=_e(e.state),r=v.useMemo(()=>qS(rh(i.events,i.live,i.pending)),[i.events,i.live,i.pending,i.version]);return r.length===0&&!s?null:n.jsx(xx,{title:t,running:s,commands:r,empty:"还没有运行命令"})}function xx({title:e,running:t,commands:s,empty:i}){const[r,o]=v.useState(null),l=r??(t||s.some(u=>u.status==="running")||e==="这个对话");return n.jsxs("section",{className:"command-group",children:[n.jsxs("button",{type:"button",className:"command-group-head","aria-expanded":l,onClick:()=>o(!l),children:[n.jsx(Q,{name:l?"chevron-down":"chevron"}),n.jsx("span",{className:"command-group-title",title:e,children:e}),t&&n.jsx("span",{className:"tool-spinner","aria-label":"进行中"}),n.jsx("span",{className:"skills-count",children:s.length})]}),l&&(s.length===0?n.jsx("p",{className:"muted small side-note",children:i}):n.jsx("ol",{className:"command-list",children:s.map(u=>n.jsx(s3,{item:u},u.id))}))]})}function s3({item:e}){const{text:t,description:s,program:i}=JD(e),[r,o]=v.useState(e.status==="error"),l=vn(e.status==="running"?1e3:6e4),u=(e.result??e.error??"").trimEnd();return n.jsxs("li",{className:`command-row status-${e.status}`,children:[n.jsxs("div",{className:"command-row-head",children:[e.status==="running"?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(Q,{name:e.status==="error"?"alert":"check"}),n.jsx("span",{className:"command-desc",children:s!==""?s:i?"运行程序":"运行命令"}),n.jsx("span",{className:"command-time",children:e.status==="running"?`运行中 ${Math.max(0,Math.round((l-e.time)/1e3))} 秒`:vt(e.time,l)})]}),n.jsxs("pre",{className:"command-text",children:[n.jsx("span",{className:"command-prompt",children:i?"ts":e.name==="bash"?"$":"PS>"}),t]}),u!==""&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"link-button command-output-toggle",onClick:()=>o(!r),children:r?"收起输出":"看输出"}),r&&n.jsx("pre",{className:"command-output",children:u.length>pk?`…
|
|
213
|
-
${u.slice(-pk)}`:u})]})]})}const pk=6e3,Bf=new Map;function GS(e,t){let s=Bf.get(t);return s===void 0&&(s=e.connection.call("games/image",{url:t}).then(i=>`data:${i.mediaType};base64,${i.data}`),s.catch(()=>Bf.delete(t)),Bf.set(t,s)),s}function KS(e,t){const[s,i]=v.useState(void 0),r=t.filter(o=>o!==void 0).filter((o,l,u)=>u.indexOf(o)===l);return v.useEffect(()=>{i(void 0);let o=!0;return(async()=>{for(const l of r){const u=await GS(e,l).catch(()=>{});if(u!==void 0){o&&i(u);return}}})(),()=>{o=!1}},[e,r.join(`
|
|
214
|
-
`)]),s}function oa(e,t){const[s,i]=v.useState(void 0);return v.useEffect(()=>{if(i(void 0),t===void 0)return;let r=!0;return GS(e,t).then(o=>{r&&i(o)},()=>{}),()=>{r=!1}},[e,t]),s}const vx=["image/png","image/jpeg","image/gif","image/webp","image/avif"],i3=8*1024*1024;function tg(e,t){const s=Object.fromEntries(new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(e)).map(i=>[i.type,Number(i.value)]));return Date.UTC(s.year,s.month-1,s.day,s.hour,s.minute,s.second)-Math.floor(e/1e3)*1e3}function r3(e){var s;return(((s=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(new Date).find(i=>i.type==="timeZoneName"))==null?void 0:s.value)??"").replace("GMT","UTC")||e}function gk(e,t){return e===void 0?"":new Date(e+tg(e,t)).toISOString().slice(0,16)}function xk(e,t){const s=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(e);if(s===null)return;const i=Date.UTC(Number(s[1]),Number(s[2])-1,Number(s[3]),Number(s[4]),Number(s[5]));return i-tg(i-tg(i,t),t)}function YS(e){return new Promise((t,s)=>{if(!vx.includes(e.type)){s(new Error("只支持 png、jpg、gif、webp、avif 图片"));return}if(e.size>i3){s(new Error("图片太大(最多 8 MB)"));return}const i=new FileReader;i.onload=()=>{const r=String(i.result);t({image:{mediaType:e.type,data:r.slice(r.indexOf(",")+1)},src:r})},i.onerror=()=>s(new Error("图片读不出来")),i.readAsDataURL(e)})}function yx({client:e,game:t,activity:s,onDone:i,onCancel:r}){var M;const o=t.timezone,l={name:(s==null?void 0:s.name)??"",kind:(s==null?void 0:s.kind)??"",startsAt:gk(s==null?void 0:s.startsAt,o),endsAt:gk(s==null?void 0:s.endsAt,o),url:(s==null?void 0:s.url)??"",description:(s==null?void 0:s.description)??""},[u,d]=v.useState(l),[h,m]=v.useState(null),[p,g]=v.useState(!1),[x,N]=v.useState(!1),[j,y]=v.useState(null),k=v.useRef(null),_=((M=s==null?void 0:s.own)==null?void 0:M.fields.includes("cover"))===!0,S=oa(e,p||s==null?void 0:s.cover),E=(h==null?void 0:h.src)??S,O=s!==void 0&&(s.sources!==void 0||s.screen!==void 0);v.useEffect(()=>{y(null)},[u]);const P=F=>L=>d(A=>({...A,[F]:L.target.value})),H=F=>{F!==void 0&&YS(F).then(L=>{m(L),g(!1)},L=>y($e(L)))},B=F=>{const L=[...F.clipboardData.files].find(A=>A.type.startsWith("image/"));L!==void 0&&(F.preventDefault(),H(L))},R=async()=>{if(u.name.trim()===""){y("活动要有名字");return}const F=u.startsAt===""?null:xk(u.startsAt,o)??null,L=u.endsAt===""?null:xk(u.endsAt,o)??null;if(F!==null&&L!==null&&L<=F){y("结束时间要晚于开始时间");return}const A=D=>s===void 0||u[D]!==l[D],I=D=>A(D)?{[D]:u[D].trim()===""?null:u[D].trim()}:{},z={game:t.id,...s===void 0?{}:{activityId:s.id},...I("name"),...I("kind"),...I("url"),...I("description"),...A("startsAt")?{startsAt:F}:{},...A("endsAt")?{endsAt:L}:{},...h!==null?{image:h.image}:p?{cover:null}:{}};N(!0),y(null);try{i(await e.connection.call("games/activity/save",z))}catch(D){y($e(D))}finally{N(!1)}};return n.jsxs("form",{className:"activity-editor",onSubmit:F=>{F.preventDefault(),R()},onPaste:B,onKeyDown:F=>{F.key==="Escape"&&r()},children:[n.jsxs("div",{className:"activity-editor-head",children:[n.jsx("strong",{children:s===void 0?`添加${t.name}的活动`:"编辑活动"}),O&&n.jsx("span",{className:"muted small",children:"你改的内容比数据站优先,刷新不会改掉;没改的照来源走。"})]}),n.jsxs("div",{className:"activity-editor-body",children:[n.jsxs("div",{className:"activity-editor-image",children:[n.jsx("button",{type:"button",className:`activity-image-pick ${E===void 0?"empty":""}`,onClick:()=>{var F;return(F=k.current)==null?void 0:F.click()},title:"选一张图片(也可以直接粘贴)",children:E!==void 0?n.jsx("img",{src:E,alt:""}):n.jsxs(n.Fragment,{children:[n.jsx(Q,{name:"image"}),n.jsx("span",{children:"选图片"}),n.jsx("small",{children:"或粘贴"})]})}),n.jsx("input",{ref:k,type:"file",accept:vx.join(","),hidden:!0,onChange:F=>{var L;H((L=F.target.files)==null?void 0:L[0]),F.target.value=""}}),n.jsxs("div",{className:"activity-image-tools",children:[n.jsx("span",{className:"muted small",children:E===void 0?"点上面选图,或直接粘贴":"点图片换一张,或直接粘贴"}),(h!==null||_&&!p)&&n.jsx("button",{type:"button",className:"link-button small muted",onClick:()=>{m(null),_&&g(!0)},children:h!==null?"不用这张":O?"用回来源的图":"去掉图片"})]})]}),n.jsxs("div",{className:"activity-editor-fields top",children:[n.jsxs("div",{className:"field-row",children:[n.jsxs("label",{className:"field wide",children:[n.jsx("span",{className:"field-title",children:"活动名"}),n.jsx("input",{className:"text-input plain",autoFocus:s===void 0,maxLength:60,value:u.name,onChange:P("name"),placeholder:"例如:周年庆签到"})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"类型"}),n.jsx("input",{className:"text-input plain",maxLength:20,value:u.kind,onChange:P("kind"),placeholder:"签到、SideStory…"})]})]}),n.jsxs("div",{className:"field-row",children:[n.jsxs("label",{className:"field date",children:[n.jsx("span",{className:"field-title",children:"开始"}),n.jsx("input",{className:"text-input plain",type:"datetime-local",value:u.startsAt,onChange:P("startsAt")})]}),n.jsxs("label",{className:"field date",children:[n.jsx("span",{className:"field-title",children:"结束"}),n.jsx("input",{className:"text-input plain",type:"datetime-local",value:u.endsAt,onChange:P("endsAt")})]})]}),n.jsxs("span",{className:"muted small",children:["时间按游戏服务器时间(",r3(o),")",u.endsAt===""?";不填结束时间的会一直留着,直到你去掉它":""]})]}),n.jsxs("div",{className:"activity-editor-fields full",children:[n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"活动页面(可选)"}),n.jsx("input",{className:"text-input plain",type:"url",value:u.url,onChange:P("url"),placeholder:"https://…"})]}),n.jsxs("label",{className:"field description",children:[n.jsxs("span",{className:"field-title",children:["说明(可选)",n.jsxs("small",{className:"muted",children:[u.description.length,"/500"]})]}),n.jsx("textarea",{className:"text-input plain",rows:8,maxLength:500,value:u.description,onChange:P("description"),placeholder:"要做什么、奖励是什么"})]})]})]}),n.jsxs("div",{className:"activity-editor-actions",children:[n.jsx("button",{className:"small-button primary",type:"submit",disabled:x,children:x?"保存中…":s===void 0?"添加":"保存"}),n.jsx("button",{className:"small-button",type:"button",disabled:x,onClick:r,children:"取消"}),j!==null&&n.jsx("span",{className:"tone-error small",children:j})]})]})}async function hh(e,t){const s=Vs();if(s!==void 0){const{kind:r,...o}=t;return s.pickFile({...o,folder:r==="folder"})}const{path:i}=await e.connection.call("files/pick",{kind:t.kind,...t.title===void 0?{}:{title:t.title},...t.defaultPath===void 0||t.defaultPath===""?{}:{defaultPath:t.defaultPath},...t.filterName===void 0?{}:{filterName:t.filterName},...t.extensions===void 0?{}:{extensions:t.extensions}});return i??null}const a3={update:"版本更新",notice:"公告",news:"资讯"};function XS({notice:e,now:t}){const s=e.publishedAt===void 0?void 0:t-e.publishedAt;return n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"badge","data-notice-kind":e.kind,children:a3[e.kind]}),e.version&&n.jsx("span",{className:"notice-version",children:e.version}),e.lasting&&n.jsx("span",{className:"badge",title:"长期有效的公告",children:"长期"}),s!==void 0&&s>=0&&s<3*864e5&&n.jsx("span",{className:"badge ok",children:"新"})]})}function vk({client:e,url:t,title:s}){const i=oa(e,t);return i?n.jsx("img",{src:i,alt:s+" 配图"}):null}function o3({client:e,notice:t,now:s,color:i,onClose:r}){var y,k;const[o,l]=v.useState(),[u,d]=v.useState(!1),[h,m]=v.useState(0);v.useEffect(()=>{let _=!0;return d(!1),e.connection.call("games/notice/detail",{game:t.game,noticeId:t.id}).then(S=>{_&&l(S)},()=>{_&&d(!0)}),()=>{_=!1}},[e,t.game,t.id,h]);const p=((y=o==null?void 0:o.summary)==null?void 0:y.trim())||((k=t.summary)==null?void 0:k.trim()),g=o==null?void 0:o.article,x=(o==null?void 0:o.cover)??t.cover,N=t.url&&/^https?:\/\//i.test(t.url)?t.url:void 0,j=t.publishedAt&&new Date(t.publishedAt).toLocaleDateString("zh-CN");return n.jsxs(dc,{label:t.title,color:i,onClose:r,className:"notice-dialog",children:[n.jsxs("header",{className:"dialog-head",children:[n.jsxs("div",{className:"dialog-title",children:[n.jsx("h3",{children:t.title}),n.jsxs("div",{className:"dialog-meta",children:[n.jsx(XS,{notice:t,now:s}),n.jsx("span",{children:[t.source.name,j].filter(Boolean).join(" · ")})]})]}),N&&n.jsx("a",{className:"small-button notice-original",href:N,target:"_blank",rel:"noreferrer",children:"查看原文"}),n.jsx("button",{className:"dialog-close","aria-label":"关闭",onClick:r,children:n.jsx(Q,{name:"close"})})]}),n.jsxs("article",{className:"notice-article",children:[p&&n.jsxs("section",{className:"notice-abstract",children:[n.jsx("h4",{children:"摘要"}),n.jsx("p",{children:p})]}),x&&!(g!=null&&g.some(_=>_.type==="image"&&_.url===x))&&n.jsx(vk,{client:e,url:x,title:t.title},x),g!=null&&g.length?g.map((_,S)=>_.type==="image"?n.jsx(vk,{client:e,url:_.url,title:t.title},S+_.url):n.jsx("p",{children:_.text},S)):n.jsxs("p",{className:"muted small",role:"status",children:[u?"正文暂时无法加载。":o?"这条记录尚未收录正文。":"正在读取正文…",u&&n.jsx("button",{className:"link-button small",onClick:()=>m(_=>_+1),children:"重试"})]})]})]})}const ai=864e5,yk={name:"名字",startsAt:"开始时间",endsAt:"结束时间",kind:"类型",description:"说明",url:"页面",cover:"图片"},Hf=2,l3=28,Xr=["#3b82c4","#c0567d","#2f9e7a","#c98a1b","#7a62d6","#d2643c","#4d9a3c","#2a93a8","#a86bb8","#8a7a3a"],bk="adg:games:overview:shown",kk="adg:games:overview:mode";function jk(e,t){try{const s=localStorage.getItem(e);return s===null?t:JSON.parse(s)}catch{return t}}function Nk(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function ms(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 c3(e,t){return new Date(e).toLocaleDateString("zh-CN",{timeZone:t,month:"numeric",day:"numeric"})}function kd(e,t){const s=e-t;return s<=0?"已结束":s<ai?`${Math.max(1,Math.floor(s/36e5))} 小时`:`${Math.floor(s/ai)} 天`}function u3({client:e,games:t,activities:s,now:i,soonDays:r,onOpenGame:o,onChanged:l}){const[u,d]=v.useState(()=>jk(bk,null)),[h,m]=v.useState(()=>jk(kk,"time")),[p,g]=v.useState(null);v.useEffect(()=>Nk(bk,u),[u]),v.useEffect(()=>Nk(kk,h),[h]);const x=v.useMemo(()=>new Map(t.map((L,A)=>[L.id,Xr[A%Xr.length]])),[t]),N=L=>u===null||u.includes(L),j=L=>d(A=>{const I=A??t.map(D=>D.id),z=I.includes(L)?I.filter(D=>D!==L):[...I,L];return z.length===t.length?null:z}),y=new Date(i-Hf*ai).setHours(0,0,0,0),k=y+(Hf+l3)*ai,_=L=>Math.min(100,Math.max(0,(L-y)/(k-y)*100)),S=s.filter(L=>N(L.game)&&(L.endsAt===void 0||Math.max(L.endsAt,L.shopEndsAt??0)>i)),E=(L,A)=>(L.endsAt??1/0)-(A.endsAt??1/0)||L.name.localeCompare(A.name),O=S.filter(L=>(L.startsAt??0)<=i),P=S.filter(L=>L.startsAt!==void 0&&L.startsAt>i).sort((L,A)=>L.startsAt-A.startsAt),H=[];if(h==="time"){const L=y+(Hf+7)*ai,A=O.filter(D=>D.endsAt!==void 0&&D.endsAt-i<r*ai).sort(E),I=O.filter(D=>!A.includes(D)&&D.endsAt!==void 0&&D.endsAt<L).sort(E),z=O.filter(D=>!A.includes(D)&&!I.includes(D)).sort(E);H.push({key:"soon",title:"快结束",hint:`${r} 天内`,rows:A},{key:"week",title:"本周内结束",rows:I},{key:"later",title:"之后结束",rows:z},{key:"upcoming",title:"即将开始",rows:P})}else for(const L of t){if(!N(L.id))continue;const A=[...O.filter(I=>I.game===L.id).sort(E),...P.filter(I=>I.game===L.id)];H.push({key:L.id,title:L.name,rows:A,game:L})}const B=O.reduce((L,A)=>{const I=ms(A);return{...L,[I.state]:L[I.state]+1}},{finished:0,partial:0,unknown:0}),R=O.filter(L=>L.endsAt!==void 0&&L.endsAt-i<r*ai&&ms(L).state!=="finished").length,M=[];for(let L=y;L<=k;L+=ai){const A=Math.round((L-new Date(i).setHours(0,0,0,0))/ai);M.push({at:L,...A>0&&A%7===0?{label:c3(L,Intl.DateTimeFormat().resolvedOptions().timeZone)}:{}})}const F=L=>s.filter(A=>A.game===L&&(A.startsAt??0)<=i&&(A.endsAt===void 0||Math.max(A.endsAt,A.shopEndsAt??0)>i));return n.jsxs("div",{className:"games-overview",children:[n.jsx("div",{className:"game-tiles",role:"group","aria-label":"各游戏",children:t.map(L=>{const A=F(L.id);return n.jsx(d3,{client:e,game:L,color:x.get(L.id)??Xr[0],now:i,shown:N(L.id),running:A.length,soon:A.filter(I=>I.endsAt!==void 0&&I.endsAt-i<r*ai&&ms(I).state!=="finished").length,covers:A.map(I=>I.cover).filter(I=>(I==null?void 0:I.startsWith("shot:"))!==!0).slice(0,6),onOpen:()=>o(L.id),onToggle:()=>j(L.id)},L.id)})}),n.jsxs("section",{className:"card games-overview-board",children:[n.jsxs("div",{className:"ov-toolbar",children:[n.jsxs("div",{className:"ov-stats",children:[n.jsx(Bl,{value:O.length,label:"进行中"}),n.jsx(Bl,{value:R,label:"快结束未做完",tone:R>0?"warn":void 0}),n.jsx(Bl,{value:B.finished,label:"做完"}),n.jsx(Bl,{value:B.partial,label:"做了一部分"}),n.jsx(Bl,{value:B.unknown,label:"没记录"})]}),n.jsxs("div",{className:"segmented-control ov-mode",role:"group","aria-label":"排序",children:[n.jsx("button",{className:h==="time"?"active":"","aria-pressed":h==="time",onClick:()=>m("time"),children:"按时间"}),n.jsx("button",{className:h==="game"?"active":"","aria-pressed":h==="game",onClick:()=>m("game"),children:"按游戏"})]})]}),n.jsxs("div",{className:"ov-grid",children:[n.jsx("div",{className:"ov-lines","aria-hidden":"true",children:M.filter(L=>L.label!==void 0).map(L=>n.jsx("i",{style:{left:`${_(L.at)}%`}},L.at))}),n.jsxs("div",{className:"ov-row ov-axis","aria-hidden":"true",children:[n.jsx("div",{className:"ov-label"}),n.jsxs("div",{className:"ov-track",children:[M.map(L=>n.jsx("span",{className:`ov-tick ${L.label!==void 0?"major":""}`,style:{left:`${_(L.at)}%`},children:L.label!==void 0&&n.jsx("em",{children:L.label})},L.at)),n.jsx("span",{className:"ov-today-label",style:{left:`${_(i)}%`},children:"今天"})]}),n.jsx("div",{className:"ov-side"})]}),H.every(L=>L.rows.length===0)&&n.jsxs("div",{className:"empty",children:[n.jsx(Q,{name:"timeline"}),n.jsx("p",{children:t.length===0?"没有游戏。":"显示的游戏现在没有活动。点「刷新全部」读取,或点上面游戏卡片的眼睛多显示几个。"})]}),H.filter(L=>L.rows.length>0).map(L=>{var A;return n.jsxs("div",{className:`ov-section ${L.key==="soon"?"warn":""} ${L.game!==void 0?"by-game":""}`,style:L.game===void 0?void 0:{"--game":x.get(L.game.id)},children:[n.jsxs("div",{className:"ov-section-title",children:[L.game!==void 0&&n.jsx("span",{className:"game-dot"}),n.jsx("span",{className:"ov-section-name",children:L.title}),n.jsx("span",{className:"ov-section-count",children:L.rows.length}),L.hint!==void 0&&n.jsx("span",{className:"muted small",children:L.hint}),((A=L.game)==null?void 0:A.version)!==void 0&&n.jsxs("span",{className:"muted small ov-section-version",children:[L.game.version.name,L.game.version.title===void 0?"":`「${L.game.version.title}」`]}),L.game!==void 0&&n.jsxs("button",{className:"link-button small ov-section-open",onClick:()=>o(L.game.id),children:["打开",n.jsx(Q,{name:"chevron"})]})]}),L.rows.map(I=>{const z=t.find(D=>D.id===I.game);return n.jsx(h3,{client:e,activity:I,game:z,color:x.get(I.game)??Xr[0],showGame:h==="time",now:i,soonDays:r,x:_,open:p===I.id,onToggle:()=>g(D=>D===I.id?null:I.id),onOpenGame:()=>o(I.game),onChanged:l},I.id)})]},L.key)}),n.jsx("div",{className:"ov-today",style:{left:`calc(var(--ov-label) + (100% - var(--ov-label) - var(--ov-side)) * ${_(i)/100})`},"aria-hidden":"true"})]})]})]})}function Bl({value:e,label:t,tone:s}){return n.jsxs("span",{className:`ov-stat ${s??""} ${e===0?"zero":""}`,children:[n.jsx("strong",{children:e}),t]})}function d3({client:e,game:t,color:s,covers:i,now:r,running:o,soon:l,shown:u,onOpen:d,onToggle:h}){const m=t.version,p=KS(e,[t.banner,m==null?void 0:m.cover,t.art,...i]),g=(m==null?void 0:m.endsAt)!==void 0&&m.endsAt>r?` · 还剩 ${kd(m.endsAt,r)}`:"";return n.jsxs("article",{className:`game-tile ${p===void 0?"no-art":""} ${u?"":"off"}`,style:{"--game":s},children:[p!==void 0&&n.jsx("img",{className:"game-tile-art",src:p,alt:""}),n.jsx("span",{className:"game-tile-shade"}),n.jsxs("button",{className:"game-tile-open",title:`打开${t.name}`,onClick:d,children:[n.jsxs("span",{className:"game-tile-name",children:[n.jsx("span",{className:"game-dot"}),t.name]}),n.jsx("span",{className:"game-tile-version",children:m===void 0?"没有版本信息":`${m.name}${m.title===void 0?"":`「${m.title}」`}${g}`}),n.jsxs("span",{className:"game-tile-counts",children:[n.jsxs("span",{children:[n.jsx("b",{children:o})," 进行中"]}),l>0&&n.jsxs("span",{className:"soon",children:[n.jsx("b",{children:l})," 快结束"]})]})]}),n.jsx("button",{className:"game-tile-eye","aria-pressed":u,"aria-label":`在时间线上显示${t.name}`,title:u?"在时间线上隐藏":"在时间线上显示",onClick:h,children:n.jsx(Q,{name:u?"eye":"eye-off"})})]})}function h3({client:e,activity:t,game:s,color:i,showGame:r,now:o,soonDays:l,x:u,open:d,onToggle:h,onOpenGame:m,onChanged:p}){const g=ms(t),x=(t.startsAt??0)<=o,N=t.endsAt,j=x&&N!==void 0&&N-o<l*ai&&g.state!=="finished",y=u(t.startsAt??o-30*ai),k=N===void 0?100:u(N),_=t.shopEndsAt===void 0||N===void 0||t.shopEndsAt<=N?void 0:u(t.shopEndsAt),S=oa(e,t.cover);return n.jsxs("div",{className:`ov-item ${d?"open":""}`,style:{"--game":i},children:[n.jsxs("button",{className:`ov-row ${j?"soon":""} ${g.state==="finished"?"finished":""}`,onClick:h,"aria-expanded":d,children:[n.jsxs("div",{className:"ov-label",children:[n.jsx("span",{className:"ov-thumb",children:S!==void 0&&n.jsx("img",{src:S,alt:"",decoding:"async"})}),n.jsxs("span",{className:"ov-text",children:[n.jsx("span",{className:"ov-name",title:t.name,children:t.name}),(r||t.kind!==void 0)&&n.jsxs("span",{className:"ov-meta",children:[r&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"game-dot"}),(s==null?void 0:s.name)??t.game]}),t.kind!==void 0&&n.jsx("span",{className:"ov-kind",children:t.kind})]})]})]}),n.jsxs("div",{className:"ov-track",children:[n.jsx("span",{className:`ov-bar ${x?"":"future"} ${y<=0?"cut-left":""} ${N===void 0||k>=100?"cut-right":""}`,style:{left:`${y}%`,width:`${Math.max(1.2,k-y)}%`},children:g.total>0&&n.jsx("span",{className:"ov-bar-done",style:{width:`${g.done/g.total*100}%`}})}),_!==void 0&&n.jsx("span",{className:"ov-shop",style:{left:`${k}%`,width:`${Math.max(.6,_-k)}%`},title:"之后只开商店"})]}),n.jsxs("div",{className:"ov-side",children:[n.jsx("span",{className:`ov-left ${j?"tone-warn":""}`,children:x?N===void 0?"时间未知":N<=o&&t.shopEndsAt!==void 0?`商店 ${kd(t.shopEndsAt,o)}`:kd(N,o):`${kd(t.startsAt,o)}后开始`}),n.jsx(bx,{progress:g})]})]}),d&&n.jsx(f3,{client:e,activity:t,game:s,onOpenGame:m,onChanged:p})]})}function bx({progress:e}){return e.state==="finished"?n.jsxs("span",{className:"ov-progress done",children:[n.jsx(Q,{name:"check"}),"做完了"]}):e.state==="unknown"?n.jsx("span",{className:"ov-progress unknown",children:"未记录"}):n.jsxs("span",{className:"ov-progress partial",title:`做了 ${e.done} 项,还剩 ${e.total-e.done} 项`,children:[n.jsx("span",{className:"ov-ring",style:{"--pct":`${e.done/e.total*100}%`}}),e.done,"/",e.total]})}function m3({activity:e,game:t,chosen:s,onChoose:i}){const r=vn(6e4),o=e.sources??(e.site===void 0?[]:[{id:e.site.source,name:e.site.name,at:e.site.at,web:!1,startsAt:void 0,endsAt:void 0,cover:void 0}]);if(o.length===0&&e.screen===void 0&&e.own===void 0)return null;const l=(t==null?void 0:t.timezone)??"Asia/Shanghai",u=x=>new Date(x).toLocaleString("zh-CN",{timeZone:l,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),d=x=>`${x.startsAt===void 0&&x.endsAt===void 0?"没有时间":`${x.startsAt===void 0?"?":u(x.startsAt)} – ${x.endsAt===void 0?"?":u(x.endsAt)}`},${x.cover===void 0?"没有图片":"有图片"}`,h=x=>i(s===x?null:x),m=o.length===0&&e.screen===void 0,p=e.own!==void 0&&(e.own.startsAt!==void 0||e.own.endsAt!==void 0||e.own.cover!==void 0),g=e.screen!==void 0&&(e.screen.endsAt!==void 0||e.screen.image!==void 0);return n.jsxs("div",{className:"activity-sources",children:[n.jsx("span",{className:"muted small",children:"来源"}),o.map(x=>{var N;return n.jsxs("button",{className:`fact-chip ${x.web?"web":"site"} ${s===x.id?"on":""}`,"aria-pressed":s===x.id,title:`${d(x)}。点一下用它的图片和时间`,onClick:()=>h(x.id),children:[x.name,n.jsxs("small",{children:[x.web?"网页":"数据站"," · ",vt(x.at,r)]}),o.length>1&&((N=e.shown)==null?void 0:N.endsAt)===x.id&&n.jsx("small",{className:"fact-main",children:"时间以它为准"})]},x.id)}),e.screen!==void 0&&n.jsxs("button",{className:`fact-chip screen ${s===oc?"on":""}`,"aria-pressed":s===oc,disabled:!g,title:`agent 进游戏看到的。${d({endsAt:e.screen.endsAt,cover:e.screen.image})}`,onClick:()=>h(oc),children:["游戏画面",n.jsxs("small",{children:["agent 看过 · ",vt(e.screen.at,r)]})]}),e.own!==void 0&&n.jsxs("button",{className:`fact-chip own ${s===$o?"on":""}`,"aria-pressed":s===$o,disabled:!p||m,title:m?"你自己添加的活动":`你改过:${e.own.fields.map(x=>yk[x]).join("、")};比来源优先,刷新不会改掉`,onClick:()=>h($o),children:[m?"我添加的":"我改过",n.jsxs("small",{children:[m?"":`${e.own.fields.map(x=>yk[x]).join("、")} · `,vt(e.own.at,r)]})]}),s!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>i(null),children:"恢复默认"})]})}function f3({client:e,activity:t,game:s,onOpenGame:i,onChanged:r,openSession:o}){var I,z;const[l,u]=v.useState(null),[d,h]=v.useState(!1),[m,p]=v.useState(""),[g,x]=v.useState(!1),[N,j]=v.useState(null),[y,k]=v.useState(void 0);v.useEffect(()=>k(void 0),[t]);const _=y??t,[S,E]=v.useState(void 0);v.useEffect(()=>E(void 0),[_.chosen]);const O=D=>{E(D),j(null),e.connection.call("games/activity/source",{activityId:_.id,source:D}).then(V=>{k(V),r()},V=>{E(void 0),j($e(V))})},P=(s==null?void 0:s.timezone)??"Asia/Shanghai",H=D=>new Date(D).toLocaleString("zh-CN",{timeZone:P,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),B=async D=>{x(!0),j(null);try{await e.connection.call("games/activity/progress",{activityId:_.id,...D}),r()}catch(V){j($e(V))}finally{x(!1)}},R=D=>void B({todo:_.todo.filter(V=>V!==D),done:[..._.done,D]}),M=D=>void B({todo:[..._.todo,D],done:_.done.filter(V=>V!==D)}),F=()=>{const D=m.trim();D===""||_.todo.includes(D)||_.done.includes(D)||(p(""),B({todo:[..._.todo,D]}))},L=_.sources!==void 0||_.screen!==void 0,A=()=>{x(!0),j(null),e.connection.call("games/activity/reset",{activityId:_.id}).then(r,D=>j($e(D))).finally(()=>x(!1))};return d&&s!==void 0?n.jsx("div",{className:"ov-detail",children:n.jsx(yx,{client:e,game:s,activity:_,onDone:()=>{h(!1),r()},onCancel:()=>h(!1)})}):n.jsxs("div",{className:"ov-detail",children:[_.description!==void 0&&n.jsx("p",{className:"ov-description",children:_.description}),n.jsxs("div",{className:"activity-dates muted small",children:[_.startsAt!==void 0&&n.jsxs("span",{children:[H(_.startsAt)," 开始"]}),_.endsAt!==void 0&&n.jsxs("span",{children:[H(_.endsAt)," 结束"]}),_.shopEndsAt!==void 0&&n.jsxs("span",{children:["商店开到 ",H(_.shopEndsAt)]})]}),n.jsx(m3,{activity:_,game:s,chosen:S!==void 0?S??void 0:_.chosen,onChoose:O}),n.jsxs("div",{className:"ov-checklist",role:"list","aria-label":"要做的事",children:[_.todo.map(D=>n.jsxs("label",{className:"ov-check",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!1,disabled:g,onChange:()=>R(D)}),D]},`t${D}`)),_.done.map(D=>n.jsxs("label",{className:"ov-check done",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!0,disabled:g,onChange:()=>M(D)}),D]},`d${D}`)),_.todo.length+_.done.length===0&&n.jsx("p",{className:"muted small",children:"还没有要做的事。自己加几项(例如「活动商店换完」「剧情通关」),或者在游戏页让 agent 进游戏读一次。"})]}),n.jsxs("div",{className:"ov-add",children:[n.jsx("input",{className:"text-input plain",value:m,maxLength:80,placeholder:"加一项要做的事,回车添加",disabled:g,onChange:D=>p(D.target.value),onKeyDown:D=>{D.key==="Enter"&&F()}}),n.jsxs("button",{className:"small-button",disabled:g||m.trim()==="",onClick:F,children:[n.jsx(Q,{name:"plus"}),"添加"]})]}),n.jsxs("div",{className:"ov-detail-actions",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:_.finished!==void 0,disabled:g,onChange:D=>void B({finished:D.target.checked})}),"这个活动我做完了"]}),n.jsx("span",{className:"spacer"}),((I=_.screen)==null?void 0:I.evidence)===!0&&n.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:_.id}).then(D=>{const V=`data:${D.mediaType};base64,${D.data}`,U=new Image;U.onload=()=>u({src:V,width:U.naturalWidth,height:U.naturalHeight}),U.src=V},D=>j($e(D))),children:"看游戏截图"}),((z=_.screen)==null?void 0:z.sessionId)!==void 0&&o!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>o(_.screen.sessionId),children:"agent 的对话"}),_.url!==void 0&&n.jsx("a",{className:"link-button small",href:_.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),i!==void 0&&n.jsxs("button",{className:"link-button small",onClick:i,children:["去",(s==null?void 0:s.name)??"游戏"]}),s!==void 0&&n.jsxs("button",{className:"link-button small",disabled:g,onClick:()=>h(!0),children:[n.jsx(Q,{name:"pencil"}),"编辑"]}),_.own!==void 0&&L&&n.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:g,onClick:A,children:"恢复来源的内容"}),n.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:g,onClick:()=>void e.connection.call("games/activity/remove",{activityId:_.id}).then(r,D=>j($e(D))),children:"从日历去掉"})]}),N!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:N})]}),l!==null&&n.jsx(ch,{src:l.src,width:l.width,height:l.height,name:`${_.name}.png`,onClose:()=>u(null)})]})}function p3({client:e,onChanged:t,onCreate:s}){const[i,r]=v.useState(null),[o,l]=v.useState(""),[u,d]=v.useState(null),[h,m]=v.useState(null),[p,g]=v.useState(0);v.useEffect(()=>{let N=!0;return e.connection.call("games/catalog",{}).then(j=>{N&&r(j.games)}).catch(j=>{N&&m($e(j))}),()=>{N=!1}},[e,p]);const x=async(N,j)=>{d(N.sra),m(null),r(y=>(y==null?void 0:y.map(k=>k.sra===N.sra?{...k,followed:j}:k))??y);try{await e.connection.call("games/follow",{sra:N.sra,follow:j}),t()}catch(y){m($e(y))}finally{d(null),g(y=>y+1)}};return n.jsxs("div",{className:"catalog-picker",children:[n.jsxs("p",{className:"muted small",children:["这些游戏的活动来自 ",n.jsx("a",{href:"https://starrailassistant.top/reference/public-api/",target:"_blank",rel:"noreferrer",children:"SRA 公共 API"}),"(社区按官方公告整理,免费,不用模型)。勾上就显示在游戏页上,每天自动读一次;取消勾选只是不再显示。"]}),i===null&&h===null&&n.jsx("p",{className:"muted small",children:"正在读取…"}),n.jsx("div",{className:"catalog-grid",children:i==null?void 0:i.map(N=>n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:N.followed,disabled:u===N.sra,onChange:j=>void x(N,j.target.checked)}),N.name,u===N.sra?"…":""]},N.sra))}),s!==void 0&&n.jsxs("form",{className:"discover-row",onSubmit:N=>{N.preventDefault();const j=o.trim();j!==""&&(s(j),l(""))},children:[n.jsx("span",{className:"field-title",children:"列表里没有?"}),n.jsx("input",{className:"text-input plain",value:o,maxLength:60,placeholder:"输入游戏名,例如:重返未来:1999",onChange:N=>l(N.target.value)}),n.jsxs("button",{className:"small-button primary",type:"submit",disabled:o.trim()==="",children:[n.jsx(Q,{name:"plus"}),"添加"]}),n.jsx("span",{className:"muted small",children:"先加一个空的游戏页,再在它的页面上让 agent 去找活动来源。"})]}),h!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:h})]})]})}const ea=864e5,Ra=36e5,ng=6e4,wk=5;function kx(e,t){const s=e-t;return s<=0?"已结束":s>=ea?`${Math.floor(s/ea)} 天 ${Math.floor(s%ea/Ra)} 时`:`${Math.floor(s/Ra)} 时 ${Math.floor(s%Ra/ng)} 分`}function g3(e){return e<=0?{value:"0",unit:"时",rest:""}:e>=ea?{value:String(Math.floor(e/ea)),unit:"天",rest:`${Math.floor(e%ea/Ra)} 时`}:e>=Ra?{value:String(Math.floor(e/Ra)),unit:"时",rest:`${Math.floor(e%Ra/ng)} 分`}:{value:String(Math.max(1,Math.floor(e/ng))),unit:"分",rest:""}}function sg(e,t){const s=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(i=>[i.type,i.value]));return`${s.year}/${s.month}/${s.day} ${s.hour}:${s.minute}`}function jx(e,t){var i;return(((i=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(new Date(t)).find(r=>r.type==="timeZoneName"))==null?void 0:i.value)??"").replace("GMT","UTC")||e}function x3({client:e,game:t,activities:s,notices:i,color:r,now:o,soonDays:l,busy:u,open:d,adding:h,onOpen:m,onAdd:p,onRefresh:g,onRead:x,onReadWeb:N,onCancelReading:j,onDiscover:y,onRemove:k,onChanged:_,openSession:S,openScripts:E}){var ie,ne,me,Ce,Fe,Me,fe,ke;const[O,P]=v.useState(!1),[H,B]=v.useState(!1),[R,M]=v.useState(null),F=i.find(ge=>ge.id===R),L=s.filter(ge=>Math.max(ge.endsAt??1/0,ge.shopEndsAt??0)>o),A=(ge,Ae)=>(ge.endsAt??1/0)-(Ae.endsAt??1/0),I=L.filter(ge=>(ge.startsAt??0)<=o).sort(A),z=L.filter(ge=>ge.startsAt!==void 0&&ge.startsAt>o).sort((ge,Ae)=>ge.startsAt-Ae.startsAt),D=I.filter(ge=>ms(ge).state!=="finished"&&(ge.endsAt??1/0)-o<l*ea),V=t.sources.some(ge=>ge.auto),U={partial:0,unknown:1,finished:2},q=I.filter(ge=>!D.includes(ge)&&ms(ge).state!=="finished").sort((ge,Ae)=>U[ms(ge).state]-U[ms(Ae).state]||A(ge,Ae)),te=I.filter(ge=>ms(ge).state==="finished"),G=[{key:"soon",title:"需要关注",hint:`${l} 天内结束,还没做完`,rows:D,tone:"warn"},{key:"ongoing",title:"进行中",hint:"做了一部分的在前",rows:q},{key:"upcoming",title:"即将开始",hint:"按开始时间",rows:z}],K=ge=>n.jsx("div",{className:"schedule-item",children:n.jsx(w3,{client:e,activity:ge,game:t,now:o,soonDays:l,onClick:()=>m(ge.id),expanded:d===ge.id})},ge.id),Z=t.single===!0,ee=i.find(ge=>ge.kind==="update"),J=ee??[...i].sort((ge,Ae)=>(Ae.publishedAt??Ae.at)-(ge.publishedAt??ge.at))[0],re=i.length>0||Z?n.jsxs("section",{className:"game-section game-notices","aria-label":"公告",children:[n.jsxs("div",{className:"game-section-head",children:[n.jsx("h3",{children:Z?"公告与更新":"公告"}),n.jsx("span",{className:"count",children:i.length}),n.jsx("span",{className:"spacer"}),Z&&n.jsx("span",{className:"muted small",children:V?"每天自动读官方公告":"让 agent 上网查"}),n.jsx("button",{className:"icon-button",title:"让 agent 上网查最新的公告和更新","aria-label":"让 agent 查公告",disabled:u!==null||((ie=t.webReading)==null?void 0:ie.state)==="running"||((ne=t.webReading)==null?void 0:ne.state)==="queued",onClick:()=>N(),children:n.jsx(Q,{name:"search"})}),V&&n.jsx("button",{className:"icon-button",title:"刷新数据站(不用模型)",disabled:u!==null,onClick:g,children:n.jsx(Q,{name:"refresh"})})]}),i.length===0&&n.jsx("p",{className:"muted small schedule-empty",children:"还没有公告。点右上角让 agent 上网查;在 Steam 上的游戏,加上 Steam 来源后每天自动读它的官方公告。"}),n.jsx("ul",{className:"notice-list",children:(H?i:i.slice(0,wk)).map(ge=>n.jsx(S3,{client:e,notice:ge,now:o,onOpen:()=>M(ge.id)},ge.id))}),F&&n.jsx(o3,{client:e,notice:F,now:o,color:r,onClose:()=>M(null)},F.id),i.length>wk&&n.jsx("button",{className:"link-button small notice-more",onClick:()=>B(ge=>!ge),children:H?"收起":`展开全部 ${i.length} 条`})]}):null;return n.jsxs("div",{className:"game-view",style:{"--game":r},children:[n.jsx(v3,{client:e,game:t,now:o,update:J,covers:[ee==null?void 0:ee.cover,...i.map(ge=>ge.cover),...I.map(ge=>ge.cover).filter(ge=>(ge==null?void 0:ge.startsWith("shot:"))!==!0)],onChanged:_}),n.jsxs("div",{className:"game-columns",children:[n.jsxs("div",{className:"game-main",children:[t.sources.length===0&&n.jsxs("section",{className:"game-section game-unknown",children:[n.jsxs("div",{className:"game-unknown-text",children:[n.jsxs("h3",{children:["还不知道去哪里看「",t.name,"」的活动"]}),n.jsx("p",{className:"muted small",children:"让 agent 去找它的 Wiki、官网公告等来源,写进这个游戏的游戏包;找到能自动读的,以后每天自动刷新。也可以在「数据来源」里自己添加网址,或点「活动日程」的「+」自己记。"})]}),n.jsxs("button",{className:"small-button primary",disabled:u!==null||((me=t.webReading)==null?void 0:me.state)==="running"||((Ce=t.webReading)==null?void 0:Ce.state)==="queued",onClick:y,children:[n.jsx(Q,{name:"search"}),((Fe=t.webReading)==null?void 0:Fe.state)==="running"||((Me=t.webReading)==null?void 0:Me.state)==="queued"?"agent 正在找…":"让 agent 去找"]})]}),(((fe=t.pools)==null?void 0:fe.length)??0)>0&&n.jsxs("section",{className:"game-section pools-card",children:[n.jsxs("div",{className:"game-section-head",children:[n.jsx("h3",{children:"卡池"}),n.jsx("span",{className:"count",children:t.pools.length})]}),n.jsx("div",{className:"pool-list",children:t.pools.map(ge=>n.jsx(_3,{client:e,pool:ge,game:t,now:o},`${ge.name}-${ge.endsAt}`))})]}),Z&&re,!Z||L.length>0||te.length>0?n.jsxs("section",{className:"game-section game-events","aria-label":"活动日程",children:[n.jsxs("div",{className:"game-section-head",children:[n.jsx("h3",{children:"活动日程"}),n.jsx("span",{className:"count",children:L.length}),n.jsx("span",{className:"spacer"}),n.jsx("span",{className:"muted small",children:((ke=t.sources.find(ge=>ge.auto))==null?void 0:ke.name)??"数据站"}),n.jsx("button",{className:"icon-button",title:"自己添加一个活动","aria-label":"添加活动","aria-pressed":h,onClick:p,children:n.jsx(Q,{name:"plus"})}),n.jsx("button",{className:"icon-button",title:V?"刷新数据站(不用模型)":"这个游戏没有能自动读的数据站",disabled:u!==null||!V,onClick:g,children:n.jsx(Q,{name:"refresh"})})]}),L.length===0&&n.jsx("p",{className:"muted small schedule-empty",children:V?"还没有活动。点右上角刷新,或点「+」自己添加。":"这个游戏没有能自动读的数据站:让 agent 进游戏读一次,或点「+」自己添加。"}),G.filter(ge=>ge.rows.length>0).map(ge=>n.jsxs("section",{className:`schedule-group ${ge.tone??""}`,children:[n.jsxs("div",{className:"schedule-group-title",children:[n.jsx("span",{children:ge.title}),n.jsx("span",{className:"count",children:ge.rows.length}),n.jsx("span",{className:"muted small",children:ge.hint})]}),n.jsx("div",{className:"schedule-grid",children:ge.rows.map(K)})]},ge.key)),te.length>0&&n.jsxs("section",{className:"schedule-group done",children:[n.jsxs("button",{className:"schedule-group-title toggle","aria-expanded":O,onClick:()=>P(ge=>!ge),children:[n.jsx("span",{children:"已做完"}),n.jsx("span",{className:"count",children:te.length}),n.jsx("span",{className:"muted small",children:O?"收起":"展开"}),n.jsx(Q,{name:"chevron-down",className:`chevron-icon ${O?"open":""}`})]}),O&&n.jsx("div",{className:"schedule-grid",children:te.map(K)})]})]}):n.jsxs("p",{className:"muted small single-no-events",children:["单机游戏没有限时活动。有要记的事(限时折扣、联动)可以",n.jsx("button",{className:"link-button small",onClick:p,children:"自己加一个"}),"。"]}),!Z&&re]}),n.jsxs("aside",{className:"game-side",children:[n.jsx(k3,{game:t,single:Z,running:I,soon:D,now:o,busy:u,onRead:x,onReadWeb:N,onCancelReading:j,onRemove:k,openSession:S}),n.jsx("section",{className:"card game-runs-card",children:n.jsx(N3,{client:e,game:t,now:o,openScripts:E})}),n.jsxs("section",{className:"card game-sources-card",children:[n.jsx("h3",{children:"数据来源"}),n.jsxs("div",{className:"game-sources",children:[t.sources.map(ge=>{var Ae,be;return n.jsxs("span",{className:`source-chip ${ge.auto?"auto":"agent"}`,children:[ge.auto?n.jsxs("span",{className:"source-name",title:"每天自动读取(不用模型)",children:[n.jsx("span",{className:"source-dot auto"}),ge.name]}):n.jsxs("button",{className:"source-name",disabled:u!==null||((Ae=t.webReading)==null?void 0:Ae.state)==="running"||((be=t.webReading)==null?void 0:be.state)==="queued",title:"让 agent 读这个来源,把活动记进日历",onClick:()=>N(ge.id),children:[n.jsx("span",{className:"source-dot"}),ge.name,n.jsx("span",{className:"source-action",children:"agent 读"})]}),ge.homepage!==void 0&&n.jsx("a",{className:"source-open",href:ge.homepage,target:"_blank",rel:"noreferrer",title:"在浏览器里打开","aria-label":`打开${ge.name}`,children:n.jsx(Q,{name:"popout"})}),ge.added===!0&&n.jsx("button",{className:"source-open",title:"不再读这个网址","aria-label":`删除${ge.name}`,onClick:()=>void e.connection.call("games/source/remove",{game:t.id,source:ge.id}).then(_,()=>{}),children:n.jsx(Q,{name:"close"})})]},ge.id)}),n.jsx(b3,{client:e,game:t,onAdded:_})]}),t.refreshed!==void 0&&n.jsxs("span",{className:"muted small",children:[vt(t.refreshed.at,o),"刷新"]}),t.refreshed!==void 0&&!t.refreshed.ok&&n.jsxs("span",{className:"tone-error small",children:["上次没读到:",t.refreshed.detail]})]})]})]})]})}function v3({client:e,game:t,now:s,update:i,covers:r,onChanged:o}){const l=t.version,u=KS(e,[t.banner,l==null?void 0:l.cover,t.art,...r]),d=(l==null?void 0:l.startsAt)!==void 0&&l.endsAt!==void 0?l.endsAt-l.startsAt:void 0,h=d===void 0||d<=0?void 0:Math.min(1,Math.max(0,(s-l.startsAt)/d)),m=p=>new Date(p).toLocaleDateString("zh-CN",{timeZone:t.timezone,month:"numeric",day:"numeric"});return n.jsxs("section",{className:`version-hero ${u===void 0?"no-art":""} ${t.banner!==void 0?"custom":""}`,children:[u!==void 0&&n.jsx("img",{className:"version-art",src:u,alt:""},t.banner??"default"),n.jsx("div",{className:"version-shade"}),n.jsx(y3,{client:e,game:t,onChanged:o}),n.jsxs("div",{className:"version-caption",children:[n.jsxs("span",{className:"version-kicker",children:[t.name,l!==void 0?n.jsxs(n.Fragment,{children:[" · ",n.jsx("b",{children:l.name})," 版本"]}):(i==null?void 0:i.version)!==void 0?n.jsxs(n.Fragment,{children:[" · 最新 ",n.jsx("b",{children:i.version})]}):""]}),n.jsx("h2",{children:(l==null?void 0:l.title)??t.name})]}),n.jsxs("div",{className:"version-strip",children:[l===void 0&&i!==void 0&&n.jsxs("span",{className:"small version-none version-update",title:i.title,children:[i.kind==="update"?"最新更新":"近期公告",":",i.title,i.publishedAt===void 0?"":` · ${vt(i.publishedAt,s)}`]}),l===void 0&&i===void 0&&n.jsx("span",{className:"small version-none",children:t.single===!0?t.sources.some(p=>p.auto)?"还没有更新公告:点「公告与更新」右上角刷新":"还没有更新公告:点「公告与更新」右上角让 agent 查":t.sources.length===0?"还没有数据来源":t.sources.some(p=>p.auto)?"还没有版本信息:点「活动日程」右上角刷新":"这个游戏的数据站不提供版本信息"}),l!==void 0&&h!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"version-end",children:m(l.startsAt)}),n.jsxs("div",{className:"version-track",role:"meter","aria-label":"版本进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h*100),children:[n.jsx("span",{className:"version-fill",style:{width:`${h*100}%`}}),n.jsx("span",{className:"version-now",style:{left:`${h*100}%`}})]}),n.jsx("span",{className:"version-end",children:m(l.endsAt)})]}),(l==null?void 0:l.endsAt)!==void 0&&n.jsx("span",{className:"version-remaining",children:l.endsAt>s?n.jsxs(n.Fragment,{children:["还剩 ",n.jsx("strong",{children:kx(l.endsAt,s)})]}):"本版本已结束"})]})]})}function y3({client:e,game:t,onChanged:s}){const i=v.useRef(null),[r,o]=v.useState(!1),[l,u]=v.useState(null),d=async m=>{u(null);try{const p=await m();if(p===null)return;o(!0),await e.connection.call("games/banner/set",{game:t.id,...p}),s()}catch(p){u($e(p))}finally{o(!1)}},h=()=>{var m;if(Vs()===void 0){(m=i.current)==null||m.click();return}d(async()=>{const p=await hh(e,{kind:"file",title:"选择横幅背景图片",filterName:"图片",extensions:["png","jpg","jpeg","gif","webp","avif"]});return p===null?null:{path:p}})};return n.jsxs("div",{className:`version-tools ${l!==null?"has-error":""}`,children:[l!==null&&n.jsx("span",{className:"version-tools-error",role:"alert",title:l,children:l}),t.banner!==void 0&&n.jsx("button",{className:"version-tool",disabled:r,title:"不用自己的图片,换回版本的图",onClick:()=>void d(async()=>({})),children:"恢复默认"}),n.jsxs("button",{className:"version-tool",disabled:r,title:"选一张本地图片作为这个游戏横幅的背景",onClick:h,children:[n.jsx(Q,{name:"image"}),r?"保存中…":"换背景"]}),n.jsx("input",{ref:i,type:"file",accept:vx.join(","),hidden:!0,onChange:m=>{var g;const p=(g=m.target.files)==null?void 0:g[0];m.target.value="",p!==void 0&&d(async()=>({image:(await YS(p)).image}))}})]})}function b3({client:e,game:t,onAdded:s}){const[i,r]=v.useState(!1),[o,l]=v.useState(""),[u,d]=v.useState(!1),[h,m]=v.useState(null);if(!i)return n.jsxs("button",{className:"source-add",onClick:()=>r(!0),title:"添加一个关于这个游戏的网页,agent 会去读它",children:[n.jsx(Q,{name:"plus"}),"添加网址"]});const p=async()=>{const g=o.trim();if(g!==""){d(!0),m(null);try{await e.connection.call("games/source/add",{game:t.id,url:/^https?:\/\//.test(g)?g:`https://${g}`}),l(""),r(!1),s()}catch(x){m($e(x))}finally{d(!1)}}};return n.jsxs("form",{className:"source-form",onSubmit:g=>{g.preventDefault(),p()},children:[n.jsx("input",{className:"text-input plain",autoFocus:!0,type:"text",inputMode:"url",placeholder:"https://… 官网公告、Wiki 页面、帖子",value:o,disabled:u,onChange:g=>l(g.target.value),onKeyDown:g=>{g.key==="Escape"&&r(!1)}}),n.jsx("button",{className:"small-button primary",type:"submit",disabled:u||o.trim()==="",children:u?"添加中…":"添加并读取"}),n.jsx("button",{className:"small-button",type:"button",onClick:()=>{r(!1),m(null)},children:"取消"}),h!==null&&n.jsx("span",{className:"tone-error small",children:h})]})}function k3({game:e,single:t,running:s,soon:i,now:r,busy:o,onRead:l,onReadWeb:u,onCancelReading:d,onRemove:h,openSession:m}){var y,k,_,S;const p=s.map(ms),g=p.filter(E=>E.state==="finished").length,x=p.filter(E=>E.state==="partial").length,N=p.filter(E=>E.state==="unknown").length,j=e.reading;return n.jsxs("section",{className:"card status-card",children:[n.jsx("h3",{children:t?"这个游戏":"我的状态"}),t&&s.length===0?n.jsx("p",{className:"muted small",children:"单机游戏:这里先放它的官方公告和版本更新,agent 也能读到它们(game_activities)。"}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"status-figures",children:[n.jsxs("div",{className:"status-figure",children:[n.jsx("strong",{children:s.length}),n.jsx("span",{children:"进行中"})]}),n.jsxs("div",{className:`status-figure ${i.length>0?"warn":""}`,children:[n.jsx("strong",{children:i.length}),n.jsx("span",{children:"快结束未做完"})]})]}),s.length>0&&n.jsxs("div",{className:"status-bar",role:"img","aria-label":`已做完 ${g} 个,做了一部分 ${x} 个,没记录 ${N} 个`,children:[g>0&&n.jsx("span",{className:"done",style:{flexGrow:g}}),x>0&&n.jsx("span",{className:"partial",style:{flexGrow:x}}),N>0&&n.jsx("span",{className:"unknown",style:{flexGrow:N}})]}),n.jsxs("ul",{className:"status-legend",children:[n.jsxs("li",{children:[n.jsx("i",{className:"done"}),"已做完",n.jsx("b",{children:g})]}),n.jsxs("li",{children:[n.jsx("i",{className:"partial"}),"做了一部分",n.jsx("b",{children:x})]}),n.jsxs("li",{children:[n.jsx("i",{className:"unknown"}),"没记录",n.jsx("b",{children:N})]})]}),n.jsx("p",{className:"muted small",children:"进度来自你在活动卡片里勾的,和 agent 进游戏读到的。"})]}),n.jsxs("div",{className:"game-actions",children:[e.followed!==!0&&!t&&n.jsxs("button",{className:"small-button primary",disabled:o!==null||(j==null?void 0:j.state)==="running"||(j==null?void 0:j.state)==="queued",title:"agent 会看游戏画面,进活动页读取剩余时间和没做完的事;只看不花东西",onClick:l,children:[n.jsx(Q,{name:"gamepad"}),(j==null?void 0:j.state)==="running"?"agent 正在读…":"让 agent 进游戏读取"]}),n.jsxs("button",{className:"small-button",disabled:o!==null||((y=e.webReading)==null?void 0:y.state)==="running"||((k=e.webReading)==null?void 0:k.state)==="queued",title:t?"agent 读官方的更新日志、Steam 新闻和公告,记下版本更新和长期公告":"agent 读官网公告、Wiki 等插件不能自己读的来源,把活动记进日历",onClick:()=>u(),children:[n.jsx(Q,{name:"search"}),((_=e.webReading)==null?void 0:_.state)==="running"||((S=e.webReading)==null?void 0:S.state)==="queued"?"agent 正在查…":t?"让 agent 查最新公告":"让 agent 上网查活动"]}),n.jsx("button",{className:"small-button",disabled:o!==null,title:e.own===!0?"删掉这个游戏和它的活动(你或 agent 加的)":e.followed===!0?"不再关注,游戏页上不再显示":"游戏页上不再显示;它的游戏包和脚本包不删",onClick:h,children:e.own===!0?"删除这个游戏":"不再显示"})]}),j!==void 0&&n.jsx(Sk,{cancel:d,what:"进游戏",reading:j,now:r,openSession:m}),e.webReading!==void 0&&n.jsx(Sk,{cancel:d,what:"上网查",reading:e.webReading,now:r,openSession:m})]})}function Sk({what:e,reading:t,now:s,openSession:i,cancel:r}){var l,u;const o=(l=t.summary)==null?void 0:l.replace(/[*_`#>]+/g,"").replace(/\s+/g," ").trim();return n.jsxs("div",{className:`reading ${t.state}`,children:[n.jsxs("div",{className:"reading-head",children:[n.jsx("span",{className:`badge ${t.state==="done"?"ok":t.state==="failed"?"warn":""}`,children:t.state==="queued"?"等待执行":t.state==="partial"?"部分完成":t.state==="cancelled"?"已取消":t.state==="running"?`正在${e}`:t.state==="done"?`上次${e}`:`${e}没完成`}),n.jsx("span",{className:"muted small",children:vt(t.at,s)}),n.jsx("span",{className:"spacer"}),t.taskId!==void 0&&(t.state==="running"||t.state==="queued")&&n.jsx("button",{className:"link-button small",onClick:()=>r(t.taskId),children:"取消探查"}),t.sessionId!==void 0&&n.jsxs("button",{className:"link-button small reading-open",onClick:()=>i(t.sessionId),children:["查看对话",n.jsx(Q,{name:"chevron"})]})]}),!!((u=t.remainingUrls)!=null&&u.length)&&t.state!=="running"&&t.state!=="queued"&&n.jsxs("div",{className:"muted small",children:["剩余 ",t.remainingUrls.length," 个链接,再次按相同来源查活动将从这里继续。"]}),o!==void 0&&o!==""&&n.jsx("p",{className:"reading-summary",title:o,children:o})]})}function j3({client:e,game:t}){const s=_e(e.capabilities),[i,r]=v.useState(null);return v.useEffect(()=>{if(!s.has("scripts"))return;let o=!0;return e.connection.call("games/mirrorchyan",{game:t.id}).then(l=>{o&&r(l.items)},()=>{o&&r([])}),()=>{o=!1}},[e,t.id,s.has("scripts")]),i===null||i.length===0?null:n.jsxs("div",{className:"mirror-tools",children:[n.jsx("div",{className:"muted small",children:"Mirror酱 上有这些玩它的工具:"}),n.jsx("ul",{children:i.slice(0,5).map(o=>n.jsxs("li",{children:[n.jsx("a",{href:`#/p/scripts/${encodeURIComponent(`mirror:${o.rid}`)}`,children:o.name}),n.jsx("span",{className:"chip subtle",children:o.rid}),o.description!==""&&n.jsx("span",{className:"muted small",children:o.description})]},o.rid))})]})}function N3({client:e,game:t,now:s,openScripts:i}){const r=_e(e.capabilities),o=_e(e.connection.status),[l,u]=v.useState(null),[d,h]=v.useState([]),[m,p]=v.useState(0),[g,x]=v.useState(null),[N,j]=v.useState(null),y=r.has("pipelines");v.useEffect(()=>e.connection.on("pipelines/changed",()=>p(S=>S+1)),[e]),v.useEffect(()=>e.connection.on("pipelines/run",S=>{S.state!=="running"&&p(E=>E+1)}),[e]),v.useEffect(()=>{if(o.state!=="open"||!y||t.scripts.length===0){u([]);return}let S=!0;return(async()=>{const{items:E}=await e.connection.call("pipelines/list",{}),P=(await Promise.all(E.filter(B=>!B.draft).map(async B=>({summary:B,pipeline:await e.connection.call("pipelines/get",{id:B.id})})))).filter(({pipeline:B})=>B.nodes.some(R=>R.kind==="script-task"&&t.scripts.includes(R.scriptId))),H=r.has("schedule")?await e.connection.call("schedule/status",{}).catch(()=>{}):void 0;S&&(u(P),h((H==null?void 0:H.upcoming)??[]))})().catch(E=>{S&&j($e(E))}),()=>{S=!1}},[e,o.state,y,t.id,t.scripts.join(","),m]);const k=async S=>{x(S),j(null);try{await e.connection.call("pipelines/run",{id:S}),p(E=>E+1)}catch(E){j($e(E))}finally{x(null)}},_={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]};return n.jsxs("div",{className:"game-schedule-runs",children:[n.jsx("h3",{children:"自动日程"}),t.scripts.length===0&&n.jsxs("p",{className:"muted small",children:["还没有玩它的脚本。在",n.jsx("button",{className:"link-button",onClick:i,children:"脚本页"}),"安装或导入后,名字或仓库里提到这个游戏的脚本会自动对上。"]}),t.scripts.length===0&&n.jsx(j3,{client:e,game:t}),t.scripts.length>0&&n.jsxs("p",{className:"muted small",children:["玩它的脚本:",t.scripts.map((S,E)=>n.jsxs("span",{children:[E>0?"、":"",n.jsx("button",{className:"link-button",onClick:i,children:S})]},S))]}),l!==null&&t.scripts.length>0&&l.length===0&&n.jsxs("p",{className:"muted small",children:["还没有自动跑这个游戏的流水线。在 ",n.jsx("a",{href:"#/p/pipelines",children:"编排"})," 里建一条并设上定时,日常就会每天自己跑。"]}),l!==null&&l.length>0&&n.jsx("ul",{className:"run-list",children:l.map(({summary:S})=>{var P,H;const E=d.filter(B=>B.pipelineId===S.id).map(B=>B.at).sort((B,R)=>B-R)[0],O=S.lastRun;return n.jsxs("li",{children:[n.jsx("a",{className:"run-name",href:`#/p/pipelines/${encodeURIComponent(S.id)}`,children:S.name}),n.jsx("span",{className:"muted small",children:E!==void 0?`下次 ${new Date(E).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"})}`:S.schedule.enabled?"定时已开":"没有定时"}),O!==void 0&&n.jsxs("span",{className:`badge ${((P=_[O.state])==null?void 0:P[0])??""}`,title:new Date(O.startedAt).toLocaleString("zh-CN",{hour12:!1}),children:[((H=_[O.state])==null?void 0:H[1])??O.state," · ",vt(O.endedAt??O.startedAt,s)]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:g!==null||(O==null?void 0:O.state)==="running",onClick:()=>void k(S.id),children:(O==null?void 0:O.state)==="running"?"运行中…":g===S.id?"启动中…":"运行"})]},S.id)})}),N!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:N})]})]})}function QS(e,t,s){const i=(e.startsAt??0)<=t,r=i&&e.endsAt!==void 0&&e.endsAt<=t,o=r?e.shopEndsAt:e.endsAt,l=i&&o!==void 0&&o-t<s*ea&&ms(e).state!=="finished";return{started:i,shopOnly:r,end:o,soon:l,target:i?o:e.startsAt}}function JS({activity:e,art:t,now:s,soonDays:i}){var N;const{started:r,shopOnly:o,end:l,soon:u,target:d}=QS(e,s,i),h=e.startsAt!==void 0&&l!==void 0?l-e.startsAt:void 0,m=h===void 0||h<=0||!r?void 0:Math.min(1,Math.max(0,(s-e.startsAt)/h)),p=ms(e).state==="finished"?["done","已做完"]:r?o?["shop","商店开放"]:["live","进行中"]:["upcoming","即将开始"],g=d===void 0?{value:"",unit:"",rest:""}:g3(d-s),x=((N=e.cover)==null?void 0:N.startsWith("shot:"))===!0;return n.jsxs("span",{className:`sched-media ${u?"soon":""}`,children:[t!==void 0&&n.jsx("img",{className:`sched-art ${x?"shot":""}`,src:t,alt:"",title:x?"没有别的活动图,用的是 agent 读这个活动时的游戏截图":void 0},e.cover),n.jsx("span",{className:"sched-shade"}),n.jsx("span",{className:`sched-tag ${p[0]}`,children:p[1]}),n.jsxs("span",{className:"sched-count","aria-label":d===void 0?"时间未知":`${r?"剩余":"距开始"}${kx(d,s)}`,children:[d===void 0?n.jsx("b",{children:"?"}):n.jsxs(n.Fragment,{children:[n.jsx("b",{children:g.value}),n.jsx("small",{children:g.unit}),g.rest!==""&&n.jsx("em",{children:g.rest})]}),n.jsx("i",{children:r?o?"商店":"剩余":"后开始"})]}),m!==void 0&&n.jsx("span",{className:"sched-elapsed",style:{width:`${m*100}%`}})]})}function w3({client:e,activity:t,game:s,now:i,soonDays:r,onClick:o,expanded:l}){var j,y,k,_;const u=oa(e,t.cover),d=ms(t),{started:h,shopOnly:m,end:p,soon:g}=QS(t,i,r),x=jx(s.timezone,i),N=t.chosen===void 0?void 0:t.chosen===$o?"我设的":t.chosen===oc?"游戏画面":(y=(j=t.sources)==null?void 0:j.find(S=>S.id===t.chosen))==null?void 0:y.name;return n.jsxs("button",{className:`sched-card ${u===void 0?"no-art":""} ${g?"soon":""}`,onClick:o,"aria-expanded":l,children:[n.jsx(JS,{activity:t,art:u,now:i,soonDays:r}),n.jsxs("span",{className:"sched-body",children:[n.jsx("span",{className:"sched-name",title:t.name,children:t.name}),n.jsx("span",{className:"sched-when",children:!h&&t.startsAt!==void 0?`${sg(t.startsAt,s.timezone)} 开始 · ${x}`:p!==void 0?`${sg(p,s.timezone)} ${m?"商店关闭":"结束"} · ${x}`:`结束时间未知${((k=t.screen)==null?void 0:k.remaining)===void 0?"":`,游戏里显示「${t.screen.remaining}」`}`}),t.todo.length>0&&d.state!=="finished"&&n.jsxs("span",{className:"sched-todo",title:t.todo.join("、"),children:["还没做:",t.todo.slice(0,3).join("、")]}),n.jsxs("span",{className:"sched-foot",children:[n.jsxs("span",{className:"sched-kinds",children:[t.kind!==void 0&&n.jsx("span",{className:"sched-kind",children:t.kind}),N!==void 0&&n.jsxs("span",{className:"sched-kind",title:`你选了用「${N}」的图片和时间`,children:["用 ",N]}),t.own!==void 0&&n.jsx("span",{className:"sched-kind",title:t.sources===void 0&&t.screen===void 0?"你自己添加的活动":"你改过这个活动",children:t.sources===void 0&&t.screen===void 0?"我添加的":"我改过"}),((_=t.sources)==null?void 0:_.some(S=>S.web))===!0&&n.jsx("span",{className:"sched-kind",title:`来源:${t.sources.map(S=>S.name).join("、")}`,children:t.sources.every(S=>S.web)?"网页读到":"数据站 + 网页"})]}),n.jsx(bx,{progress:d})]})]})]})}function S3({client:e,notice:t,now:s,onOpen:i}){const r=oa(e,t.cover);return n.jsx("li",{className:`notice-row ${t.lasting===!0?"lasting":""}`,children:n.jsxs("button",{className:"notice-open","aria-label":t.title,"aria-haspopup":"dialog",onClick:i,children:[r!==void 0&&n.jsx("img",{className:"notice-art",src:r,alt:"",loading:"lazy"}),n.jsxs("span",{className:"notice-body",children:[n.jsxs("span",{className:"notice-meta",children:[n.jsx(XS,{notice:t,now:s}),n.jsx("span",{className:"spacer"}),t.publishedAt!==void 0&&n.jsx("span",{className:"muted small",title:new Date(t.publishedAt).toLocaleString("zh-CN",{hour12:!1}),children:new Date(t.publishedAt).toLocaleDateString("zh-CN")})]}),n.jsx("span",{className:"notice-title",children:t.title}),t.summary!==void 0&&n.jsx("span",{className:"notice-summary",children:t.summary}),n.jsx("span",{className:"muted small notice-source",children:t.source.name})]})]})})}function _3({client:e,pool:t,game:s,now:i}){const r=oa(e,t.cover),o=(t.startsAt??0)<=i;return n.jsxs("article",{className:"pool-card",children:[n.jsx("div",{className:"pool-art",children:r===void 0?n.jsx(Q,{name:"sparkles"}):n.jsx("img",{src:r,alt:""})}),n.jsxs("div",{className:"pool-main",children:[t.type!==void 0&&n.jsx("span",{className:"muted small",children:t.type}),n.jsx("strong",{children:t.name}),t.up.length>0&&n.jsxs("span",{className:"small",children:["UP:",t.up.join("、")]}),n.jsxs("span",{className:"small",children:[o?"剩余":"距开始"," ",n.jsx("strong",{className:"pool-left",children:kx(o?t.endsAt:t.startsAt,i)})]}),n.jsxs("span",{className:"muted small",children:[sg(t.endsAt,s.timezone)," 结束 (",jx(s.timezone,i),")"]})]})]})}function E3(e,t){return v.useMemo(()=>new Map(e.map((s,i)=>[s.id,t[i%t.length]])),[e,t])}function dc({color:e,label:t,onClose:s,className:i="",children:r}){const o=v.useRef(null),l=()=>{var u;return((u=o.current)==null?void 0:u.querySelector("form.activity-editor"))!==null};return v.useEffect(()=>{var d;const u=document.activeElement;return(d=o.current)==null||d.focus({preventScroll:!0}),()=>{u instanceof HTMLElement&&u.isConnected&&u.focus({preventScroll:!0})}},[]),v.useEffect(()=>{const u=d=>{if(document.querySelector(".image-viewer")!==null||(d.key==="Escape"&&!l()&&s(),d.key!=="Tab"||o.current===null))return;const h=[...o.current.querySelectorAll("a[href], button:not(:disabled), input:not(:disabled):not([hidden]), textarea:not(:disabled)")],m=h[0],p=h[h.length-1],g=document.activeElement;m===void 0||p===void 0||(d.shiftKey&&(g===m||g===o.current)?(d.preventDefault(),p.focus()):!d.shiftKey&&g===p&&(d.preventDefault(),m.focus()))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[s]),n.jsx("div",{className:"activity-scrim",onPointerDown:u=>{u.target===u.currentTarget&&!l()&&s()},children:n.jsx("div",{ref:o,className:`activity-dialog ${i}`,role:"dialog","aria-modal":"true","aria-label":t,tabIndex:-1,style:{"--game":e},children:r})})}function C3(e,t){const s=u=>vt(u,t),i=e.sources??[],r=e.own,o=u=>u.startsAt!==void 0||u.endsAt!==void 0||u.cover!==void 0,l=u=>({id:u.id,name:u.name,note:`${u.web?"网页":"数据站"} · ${s(u.at)}`,title:u.web?"agent 在网页上读到的;刷新数据站不会删掉它":"数据站,每次刷新更新",startsAt:u.startsAt,endsAt:u.endsAt,shopEndsAt:u.shopEndsAt,cover:u.cover,blank:!o(u)&&u.shopEndsAt===void 0});return[{id:$o,name:"我设的",note:r===void 0?"":s(r.at),title:"你自己填的:刷新不会改掉",startsAt:r==null?void 0:r.startsAt,endsAt:r==null?void 0:r.endsAt,cover:r==null?void 0:r.cover,blank:r===void 0||!o(r)},...i.filter(u=>!u.web).map(l),...i.filter(u=>u.web).map(l),...e.screen===void 0?[]:[{id:oc,name:"游戏画面",note:`agent 看过 · ${s(e.screen.at)}`,title:"agent 进游戏看到的剩余时间和截图",endsAt:e.screen.endsAt,cover:e.screen.image,blank:e.screen.endsAt===void 0&&e.screen.image===void 0}]]}function A3(e,t){var r,o,l;const s=((r=e.shown)==null?void 0:r.startsAt)===t,i=((o=e.shown)==null?void 0:o.endsAt)===t;return[...((l=e.shown)==null?void 0:l.cover)===t?["图片"]:[],...s&&i?["时间"]:s?["开始时间"]:i?["结束时间"]:[]]}function $3({client:e,url:t}){const s=oa(e,t);return n.jsx("span",{className:`source-thumb ${t===void 0?"none":""}`,children:s!==void 0?n.jsx("img",{src:s,alt:"",decoding:"async"}):t===void 0?"无图":null})}function I3({client:e,activity:t,game:s,now:i,soonDays:r,onClose:o,onChanged:l,openSession:u}){var ee,J,re;const[d,h]=v.useState(null),[m,p]=v.useState(!1),[g,x]=v.useState(""),[N,j]=v.useState(!1),[y,k]=v.useState(null),[_,S]=v.useState(void 0);v.useEffect(()=>S(void 0),[t]);const E=_??t,[O,P]=v.useState(void 0);v.useEffect(()=>P(void 0),[E.chosen]);const H=O!==void 0?O??void 0:E.chosen,B=oa(e,E.cover),R=v.useRef(void 0);B!==void 0&&(R.current=B);const M=E.cover===void 0?void 0:B??R.current,F=(s==null?void 0:s.timezone)??"Asia/Shanghai",L=ie=>new Date(ie).toLocaleString("zh-CN",{timeZone:F,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),A=C3(E,i),I=E.shopEndsAt!==void 0||A.some(ie=>ie.shopEndsAt!==void 0),z=E.sources!==void 0||E.screen!==void 0,D=(ie,ne)=>{j(!0),k(null),ie.then(()=>{l(),ne==null||ne()},me=>k($e(me))).finally(()=>j(!1))},V=ie=>D(e.connection.call("games/activity/progress",{activityId:E.id,...ie})),U=ie=>V({todo:E.todo.filter(ne=>ne!==ie),done:[...E.done,ie]}),q=ie=>V({todo:[...E.todo,ie],done:E.done.filter(ne=>ne!==ie)}),te=()=>{const ie=g.trim();ie===""||E.todo.includes(ie)||E.done.includes(ie)||(x(""),V({todo:[...E.todo,ie]}))},G=ie=>{P(ie),k(null),e.connection.call("games/activity/source",{activityId:E.id,source:ie}).then(ne=>{S(ne),l()},ne=>{P(void 0),k($e(ne))})},K=(ie,ne)=>{const me=new Image;me.onload=()=>h({src:ie,width:me.naturalWidth,height:me.naturalHeight,name:ne}),me.src=ie},Z=()=>{j(!0),k(null),e.connection.call("games/activity/reset",{activityId:E.id}).then(ie=>{l(),ie.activity===void 0&&o()},ie=>k($e(ie))).finally(()=>j(!1))};return m&&s!==void 0?n.jsx("div",{className:"dialog-form",children:n.jsx(yx,{client:e,game:s,activity:E,onDone:()=>{p(!1),l()},onCancel:()=>p(!1)})}):n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:"dialog-head",children:[n.jsxs("div",{className:"dialog-title",children:[n.jsx("h3",{title:E.name,children:E.name}),n.jsxs("div",{className:"dialog-meta",children:[n.jsxs("span",{className:"dialog-game",children:[n.jsx("span",{className:"game-dot"}),(s==null?void 0:s.name)??E.game]}),E.kind!==void 0&&n.jsx("span",{className:"sched-kind",children:E.kind})]})]}),n.jsx(bx,{progress:ms(E)}),n.jsx("button",{className:"dialog-close","aria-label":"关闭详情",title:"关闭(Esc)",onClick:o,children:n.jsx(Q,{name:"close"})})]}),n.jsxs("div",{className:"dialog-cols",children:[n.jsxs("div",{className:"dialog-col side",children:[n.jsx("button",{className:"dialog-media",disabled:M===void 0,title:M===void 0?void 0:"看大图","aria-label":"看大图",onClick:()=>{M!==void 0&&K(M,`${E.name}.png`)},children:n.jsx(JS,{activity:E,art:M,now:i,soonDays:r})}),n.jsxs("div",{className:"dialog-facts",children:[n.jsxs("dl",{className:"dialog-dates",children:[n.jsxs("div",{children:[n.jsx("dt",{children:"开始"}),n.jsx("dd",{children:E.startsAt===void 0?"未知":L(E.startsAt)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:"结束"}),n.jsx("dd",{children:E.endsAt===void 0?"未知":L(E.endsAt)})]}),I&&n.jsxs("div",{className:"wide",children:[n.jsx("dt",{children:"商店开到"}),n.jsx("dd",{children:E.shopEndsAt===void 0?"—":L(E.shopEndsAt)})]})]}),n.jsxs("span",{className:"muted small",children:[jx(F,i),",游戏服务器时间",((ee=E.screen)==null?void 0:ee.remaining)===void 0?"":`;游戏里显示「${E.screen.remaining}」`]}),E.description!==void 0&&n.jsx("p",{className:"ov-description",children:E.description})]})]}),n.jsxs("div",{className:"dialog-col main",children:[n.jsxs("section",{className:"dialog-section","aria-label":"信息来源",children:[n.jsxs("div",{className:"dialog-section-head",children:[n.jsx("h4",{children:"信息来源"}),n.jsx("span",{className:"spacer"}),H!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>G(null),children:"恢复默认"})]}),n.jsx("div",{className:"source-rows",children:A.map(ie=>{const ne=ie.id===$o,me=H===ie.id;return n.jsxs("button",{className:`source-row ${me?"on":""}`,"aria-pressed":me,disabled:ie.blank&&!ne,title:ie.title,onClick:()=>{ie.blank&&ne?p(!0):G(me?null:ie.id)},children:[n.jsx($3,{client:e,url:ie.cover}),n.jsxs("span",{className:"source-row-main",children:[n.jsxs("span",{className:"source-row-name",children:[n.jsx("b",{children:ie.name}),me&&n.jsx(Q,{name:"check"}),ie.note!==""&&n.jsx("small",{children:ie.note})]}),ie.blank?n.jsx("span",{className:"source-row-dates muted",children:ne?"还没填,点这里设置图片和时间":"没有时间和图片"}):n.jsxs("span",{className:"source-row-dates",children:[n.jsx("span",{children:ie.startsAt===void 0&&ie.endsAt===void 0?"没有时间":`${ie.startsAt===void 0?"?":L(ie.startsAt)} – ${ie.endsAt===void 0?"?":L(ie.endsAt)}`}),ie.shopEndsAt!==void 0&&n.jsxs("em",{children:["商店到 ",L(ie.shopEndsAt)]})]})]}),n.jsx("span",{className:"source-row-uses",children:A3(E,ie.id).map(Ce=>n.jsx("i",{children:Ce},Ce))})]},ie.id)})}),n.jsx("p",{className:"muted small dialog-hint",children:"默认图片按 我设的 › 数据站和网页 › 游戏截图 显示。点一个来源,图片和时间就用它的;它没有的还按默认。"})]}),n.jsxs("section",{className:"dialog-section","aria-label":"要做的事",children:[n.jsxs("div",{className:"dialog-section-head",children:[n.jsx("h4",{children:"要做的事"}),E.todo.length+E.done.length>0&&n.jsxs("span",{className:"count",children:[E.done.length,"/",E.todo.length+E.done.length]})]}),n.jsxs("div",{className:"ov-checklist",role:"list",children:[E.todo.map(ie=>n.jsxs("label",{className:"ov-check",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!1,disabled:N,onChange:()=>U(ie)}),ie]},`t${ie}`)),E.done.map(ie=>n.jsxs("label",{className:"ov-check done",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!0,disabled:N,onChange:()=>q(ie)}),ie]},`d${ie}`)),E.todo.length+E.done.length===0&&n.jsx("p",{className:"muted small",children:"还没有要做的事。自己加几项(例如「活动商店换完」),或者让 agent 进游戏读一次。"})]}),n.jsxs("div",{className:"ov-add",children:[n.jsx("input",{className:"text-input plain",value:g,maxLength:80,placeholder:"加一项,回车添加",disabled:N,onChange:ie=>x(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&te()}}),n.jsxs("button",{className:"small-button",disabled:N||g.trim()==="",onClick:te,children:[n.jsx(Q,{name:"plus"}),"添加"]})]})]}),n.jsxs("div",{className:"dialog-section dialog-links",children:[E.url!==void 0&&n.jsx("a",{className:"link-button small",href:E.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),((J=E.screen)==null?void 0:J.evidence)===!0&&n.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:E.id}).then(ie=>K(`data:${ie.mediaType};base64,${ie.data}`,`${E.name}-截图.png`),ie=>k($e(ie))),children:"看游戏截图"}),((re=E.screen)==null?void 0:re.sessionId)!==void 0&&u!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>u(E.screen.sessionId),children:"agent 的对话"}),n.jsx("span",{className:"spacer"}),E.own!==void 0&&z&&n.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:N,onClick:Z,children:"清除我设的"}),n.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:N,onClick:()=>D(e.connection.call("games/activity/remove",{activityId:E.id}),o),children:"从日历去掉"})]}),y!==null&&n.jsx("div",{className:"dialog-section",children:n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:y})]})})]})]}),n.jsxs("footer",{className:"dialog-foot",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:E.finished!==void 0,disabled:N,onChange:ie=>V({finished:ie.target.checked})}),"这个活动我做完了"]}),n.jsx("span",{className:"spacer"}),s!==void 0&&n.jsxs("button",{className:"small-button",disabled:N,onClick:()=>p(!0),children:[n.jsx(Q,{name:"pencil"}),"编辑"]})]}),d!==null&&n.jsx(ch,{src:d.src,width:d.width,height:d.height,name:d.name,onClose:()=>h(null)})]})}const e1="adg:pack-offer:declined",Zf=new Set,T3={game:"游戏包",script:"脚本包",skill:"技能"};function t1(){try{return new Set(JSON.parse(localStorage.getItem(e1)??"[]"))}catch{return new Set}}function _k(e){if(e.length!==0)try{localStorage.setItem(e1,JSON.stringify([...new Set([...t1(),...e])]))}catch{}}const oi=e=>e.trim().toLowerCase();function M3(e,t){const s=new Set,i=new Set;for(const l of t.games){for(const u of[l.id,l.name,...l.aliases])s.add(oi(u));for(const u of l.sra??[])i.add(u);l.id.startsWith("sra-")&&i.add(l.id.slice(4))}const r=e.filter(l=>{var u;return l.pack==="game"&&(l.game!==void 0&&s.has(oi(l.game))||((u=l.sra)==null?void 0:u.some(d=>i.has(d)))===!0||l.title!==void 0&&s.has(oi(l.title)))});for(const l of r)l.game!==void 0&&s.add(oi(l.game));const o=new Set((t.scripts??[]).map(oi));return e.filter(l=>r.includes(l)||l.games.some(u=>s.has(oi(u)))||l.scripts.some(u=>o.has(oi(u)))||l.pack==="script"&&o.has(oi(l.name)))}function n1({client:e,target:t,label:s,onInstalled:i}){const r=_e(e.capabilities),o=_e(e.connection.status),[l,u]=v.useState([]),[d,h]=v.useState(new Set),[m,p]=v.useState(null),[g,x]=v.useState(null),N=JSON.stringify(t),j=r.has("skillhub")&&o.state==="open";if(v.useEffect(()=>{var P;if(u([]),!j||t.games.length+(((P=t.scripts)==null?void 0:P.length)??0)===0)return;let O=!0;return e.connection.call("skillhub/list",{}).then(H=>{if(!O)return;const B=t1(),R=M3(H.items,t).filter(F=>F.installed===void 0&&F.blocked===void 0&&F.incompatible===void 0&&!B.has(F.name)&&!Zf.has(F.name)),M=F=>F.pack==="game"?0:F.pack==="script"?1:2;R.sort((F,L)=>M(F)-M(L)),u(R),h(new Set(R.filter(F=>F.default===!0||F.pack==="game").map(F=>F.name))),x(null)},()=>{}),()=>{O=!1}},[e,j,N]),l.length===0)return null;const y=()=>{for(const O of l)Zf.add(O.name);u([])},k=()=>{_k(l.map(O=>O.name)),y()},_=async()=>{x(null);const O=l.filter(H=>d.has(H.name)),P=[];for(const H of O){p(H.name);try{await e.connection.call("skillhub/install",{name:H.name,repo:H.repo})}catch(B){x(`「${H.title??H.name}」没装上:${$e(B)}`),p(null),P.length>0&&(i==null||i(P));return}H.pack==="game"&&H.game!==void 0&&P.push(H.game),u(B=>B.filter(R=>R.name!==H.name))}_k(l.filter(H=>!d.has(H.name)).map(H=>H.name));for(const H of l)Zf.add(H.name);p(null),u([]),P.length>0&&(i==null||i(P))},S=(O,P)=>h(H=>{const B=new Set(H);return P?B.add(O):B.delete(O),B}),E=l.filter(O=>d.has(O.name)).length;return n.jsxs(dc,{color:"var(--accent)",label:`安装${s}的包`,onClose:m===null?y:()=>{},className:"pack-offer-dialog",children:[n.jsxs("header",{className:"dialog-head",children:[n.jsxs("div",{className:"dialog-title",children:[n.jsxs("h3",{children:["要安装",s,"的包吗?"]}),n.jsx("div",{className:"dialog-meta",children:"技能库里有这些,还没装。装上后游戏页、脚本和 agent 都能用;以后可以在「技能」页删掉。"})]}),n.jsx("button",{className:"dialog-close","aria-label":"以后再说",title:"以后再说(Esc)",disabled:m!==null,onClick:y,children:n.jsx(Q,{name:"close"})})]}),n.jsxs("div",{className:"dialog-form pack-offer-body",children:[n.jsx("ul",{className:"pack-offer-list",children:l.map(O=>n.jsx("li",{children:n.jsxs("label",{className:"pack-offer-item",children:[n.jsx("input",{type:"checkbox",checked:d.has(O.name),disabled:m!==null,onChange:P=>S(O.name,P.target.checked)}),n.jsxs("span",{className:"pack-offer-text",children:[n.jsxs("span",{className:"pack-offer-name",children:[O.title??O.name,n.jsx("span",{className:"pack-offer-kind",children:T3[O.pack??"skill"]}),m===O.name&&n.jsx("span",{className:"muted small",children:"正在下载…"})]}),n.jsx("span",{className:"muted small",children:O.description})]})]})},O.name))}),g!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:g})]})]}),n.jsxs("footer",{className:"dialog-foot",children:[n.jsx("span",{className:"muted small",children:"不装也能用:活动照常显示。"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:m!==null,onClick:k,children:"不用了"}),n.jsx("button",{className:"small-button primary",disabled:m!==null||E===0,onClick:()=>void _(),children:m!==null?"正在安装…":`安装 ${E} 个`})]})]})}function R3({client:e,sessionId:t}){const s=_e(e.capabilities),[i,r]=v.useState({scripts:[],games:[]}),[o,l]=v.useState([]),u=s.has("skills");v.useEffect(()=>{if(r({scripts:[],games:[]}),!u)return;let p=!0;e.connection.call("skills/focus",{sessionId:t}).then(x=>{p&&r(x)},()=>{});const g=e.connection.on("skills/focused",x=>{x.sessionId===t&&r({scripts:x.scripts,games:x.games})});return()=>{p=!1,g()}},[e,t,u]);const d=i.games.length>0&&s.has("games");v.useEffect(()=>{if(!d)return;let p=!0;return e.connection.call("games/list",{}).then(g=>{p&&l(g.games)},()=>{}),()=>{p=!1}},[e,d,i]);const h=v.useMemo(()=>({games:i.games.map(p=>o.find(g=>g.id===p||oi(g.name)===oi(p)||g.aliases.some(x=>oi(x)===oi(p)))??{id:p,name:p,aliases:[]}),scripts:i.scripts}),[i,o]),m=[...h.games.map(p=>`「${p.name}」`),...(h.scripts??[]).map(p=>`「${p}」`)].join("");return n.jsx(n1,{client:e,target:h,label:m})}function O3({client:e,sessionId:t,reminder:s,initialPrompt:i,onInitialSent:r,child:o}){const l=Fc(e,t);return l===null?n.jsx("div",{className:"main empty",children:"正在打开会话…"}):n.jsx(hz,{sessionId:l.id,children:n.jsx(P3,{client:e,session:l,reminder:s,initialPrompt:i,onInitialSent:r,child:o})},l.id)}function P3({client:e,session:t,reminder:s,initialPrompt:i,onInitialSent:r,child:o}){const l=_e(t.state),u=_e(e.connection.status),d=$i(e),h=_e(e.sessions).items.find(A=>A.id===t.id),m=h===void 0?wn:aS(h,d),p=d.find(A=>A.id===m),g=p===void 0?cn:Ka(p),x=mO(vO(e),l),[N,j]=v.useState(()=>B3()),y=x.find(A=>A.id===N)??x[0];v.useEffect(()=>H3(N),[N]);const k=z3(),_=k.openTask;v.useEffect(()=>{o&&_({id:o,label:"子任务"})},[o,_]);const S=BS(e,t.id),E=S.filter(A=>A.running).length,O=k.panel==="tasks"||k.panel==="commands",P=v.useMemo(()=>O?rh(l.events,l.live,l.pending):L3,[O,l.events,l.live,l.pending,l.version]),H=v.useMemo(()=>TS(l.events),[l.events]),B=v.useMemo(()=>US(P,H),[P,H]),R=v.useMemo(()=>RS(P,H),[P,H]),M=v.useMemo(()=>qS(P),[P]),F=v.useMemo(()=>({openTask:k.openTask}),[k.openTask]),L=n.jsxs("div",{className:"title-tools in-title-bar",role:"toolbar","aria-label":"侧栏",children:[WS.filter(A=>A.id!=="browser"||k.bridge!==void 0).map(A=>{const I=k.panel===A.id,z=A.id==="tasks"&&E>0?`子任务:${E} 个进行中`:A.id==="browser"&&k.working?"agent 正在操作内置浏览器":A.hint;return n.jsxs("button",{type:"button",className:`side-icon${I?" active":""}`,"aria-pressed":I,"aria-label":A.title,title:z,onClick:()=>k.setPanel(I?null:A.id),children:[n.jsx(Q,{name:A.icon}),A.id==="tasks"&&E>0&&n.jsx("span",{className:"side-icon-badge",children:E}),A.id==="browser"&&k.working&&n.jsx("span",{className:"side-icon-dot"})]},A.id)}),n.jsx(U3,{views:x,onSelect:j})]});return n.jsxs("section",{className:"main",children:[qa.createPortal(L,document.body),l.error!==null&&n.jsx("div",{className:"banner error",children:l.error}),n.jsxs("div",{className:`session-body${k.panel!==null?" with-side":""}`,children:[n.jsxs("div",{className:"session-column",children:[n.jsxs("div",{className:"view",children:[y!==void 0&&x[0]!==void 0&&y.id!==x[0].id&&n.jsxs("div",{className:"view-back",children:[n.jsxs("button",{type:"button",className:"small-button",onClick:()=>j(x[0].id),children:[n.jsx(Q,{name:"back"}),"返回",x[0].title]}),n.jsx("span",{className:"view-back-title",children:y.title})]}),y===void 0?n.jsx("div",{className:"empty",children:"当前连接没有提供可用的视图插件。"}):n.jsx(Qp.Provider,{value:F,children:n.jsx(y.component,{client:e,session:t,state:l})})]}),n.jsx(Tz,{client:e,session:t,running:l.running,disabled:u.state!=="open",initialPrompt:i,onInitialSent:r,reminder:s}),n.jsx(R3,{client:e,sessionId:t.id})]}),k.panel!==null&&n.jsx("div",{className:`side-slot side-${k.panel}`,children:k.panel==="browser"&&k.bridge!==void 0?n.jsx(az,{bridge:k.bridge,onClose:()=>k.setPanel(null)}):k.panel==="tasks"&&k.task!==null?n.jsx(Qp.Provider,{value:F,children:n.jsx(gx,{client:e,task:k.task,parent:g.name,trail:m===wn?[]:[cn.name],onClose:()=>k.openTask(null)},k.task.id)}):k.panel==="tasks"?n.jsx(mk,{title:"子任务",onClose:()=>k.setPanel(null),children:n.jsx(XD,{tasks:S,labels:B,settled:R,onOpen:k.openTask})}):n.jsx(mk,{title:"命令",onClose:()=>k.setPanel(null),children:n.jsx(e3,{client:e,own:M,tasks:S,labels:B})})})]})]})}const L3=[];function z3(){var N;const e=(N=Vs())==null?void 0:N.browser,[t,s]=v.useState(()=>F3()),i=t==="browser"&&e===void 0?null:t,[r,o]=v.useState(null),l=v.useRef(0),u=v.useRef(i);u.current=i;const d=j=>{u.current==="browser"&&j!=="browser"&&(l.current=Date.now()),s(j),o(null),Ck(j)},h=v.useMemo(()=>j=>{o(j),j!==null&&(s("tasks"),Ck("tasks"))},[]),[m,p]=v.useState(0);v.useEffect(()=>{if(e===void 0)return;let j;return e.onChange(y=>{const k=j!==void 0&&y.agentAt>j;j=y.agentAt,p(y.agentAt),k&&u.current===null&&Date.now()-l.current>D3&&s("browser")})},[e]);const g=Date.now()-m<Ek,[,x]=v.useState(0);return v.useEffect(()=>{if(!g)return;const j=setTimeout(()=>x(y=>y+1),m+Ek-Date.now()+50);return()=>clearTimeout(j)},[g,m]),{bridge:e,panel:i,setPanel:d,task:i==="tasks"?r:null,openTask:h,working:g}}const s1="adg.sidePanel",D3=3*6e4,Ek=5e3;function F3(){try{const e=localStorage.getItem(s1);return e===null?localStorage.getItem("adg.browserPanel")==="1"?"browser":null:WS.some(t=>t.id===e)?e:null}catch{return null}}function Ck(e){try{localStorage.setItem(s1,e??"")}catch{}}function U3({views:e,onSelect:t}){const[s,i]=v.useState(!1),r=v.useRef(null);v.useEffect(()=>{if(!s)return;const l=d=>{var h;((h=r.current)==null?void 0:h.contains(d.target))!==!0&&i(!1)},u=d=>{d.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",u)}},[s]);const o=e.slice(1);return o.length===0?null:n.jsxs("div",{className:"view-menu",ref:r,children:[n.jsx("button",{type:"button",className:`side-icon${s?" active":""}`,"aria-haspopup":"menu","aria-expanded":s,"aria-label":"更多",title:"更多",onClick:()=>i(!s),children:n.jsx(Q,{name:"more"})}),s&&n.jsx("div",{className:"view-menu-list",role:"menu",children:o.map(l=>n.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{t(l.id),i(!1)},children:[n.jsx(Q,{name:l.id==="trajectory"?"flow":"eye"}),l.title]},l.id))})]})}const i1="adg.sessionTab";function B3(){try{return localStorage.getItem(i1)??"chat"}catch{return"chat"}}function H3(e){try{localStorage.setItem(i1,e)}catch{}}const r1="adg.theme",ig=new Set;let hc=Z3();function Z3(){try{const e=localStorage.getItem(r1);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function a1(){var e,t;hc==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=hc,(t=(e=Vs())==null?void 0:e.setTheme)==null||t.call(e,hc).catch(()=>{})}function W3(e){hc=e;try{localStorage.setItem(r1,e)}catch{}a1();for(const t of ig)t()}function o1(){return v.useSyncExternalStore(e=>(ig.add(e),()=>ig.delete(e)),()=>hc)}const V3={"api-keys":"key",permissions:"shield",plugins:"plug","script-install":"package",emulators:"monitor",schedule:"calendar",feishu:"send",compaction:"compress",memory:"archive",about:"info"},q3=[["light","浅色"],["dark","深色"],["system","跟随系统"]];function G3({client:e,onClose:t,section:s,onSection:i}){const r=yO(e),o=o1(),[l,u]=v.useState(null),d=l??s??null,h=p=>{u(p),i==null||i(p)},m=r.find(p=>p.id===d)??r[0];return n.jsxs(n.Fragment,{children:[n.jsxs("aside",{className:"sidebar settings-sidebar",children:[n.jsxs("button",{className:"nav-item back-link",onClick:t,children:[n.jsx(Q,{name:"back"}),n.jsx("span",{className:"nav-item-label",children:"返回"})]}),n.jsx("h1",{className:"settings-title",children:"设置"}),n.jsxs("nav",{className:"page-list","aria-label":"设置分类",children:[n.jsx("div",{className:"sidebar-label",children:"偏好设置"}),r.map(p=>n.jsxs("button",{className:`nav-item ${p.id===(m==null?void 0:m.id)?"active":""}`,"aria-current":p.id===(m==null?void 0:m.id)?"page":void 0,onClick:()=>h(p.id),children:[n.jsx(Q,{name:V3[p.id]??"settings"}),n.jsx("span",{className:"nav-item-label",children:p.title})]},p.id))]}),n.jsxs("div",{className:"page-list",children:[n.jsx("div",{className:"sidebar-label",id:"theme-label",children:"外观"}),n.jsx("div",{className:"segmented-control",role:"radiogroup","aria-labelledby":"theme-label",children:q3.map(([p,g])=>n.jsx("button",{role:"radio","aria-checked":o===p,className:o===p?"active":"",onClick:()=>W3(p),children:g},p))})]})]}),n.jsx("section",{className:"main settings",children:n.jsx("div",{className:"settings-content",children:m===void 0?n.jsx("div",{className:"empty",children:"当前连接没有提供可配置的项目。"}):n.jsx(m.component,{client:e})})})]})}const K3=["日","一","二","三","四","五","六"],Y3=[1,2,3,4,5,6,0],Wf=[1,2,3,4,5],Vf=[0,6],X3={[wn]:[{title:"早上说说今天要做什么",prompt:"看看今天有哪些活动快结束、哪些日常还没做,整理成几句话告诉我。"}],games:[{title:"看三天内结束的活动",prompt:"查各个游戏今天和三天内结束的活动,列出名字、所属游戏和剩余时间;已经做完的不用列。"},{title:"看新版本和公告",prompt:"看各个游戏最近一天的新版本、维护和重要公告,有变化的用一两句话说明,没有就说没有。"}],scripts:[{title:"检查脚本有没有新版本",prompt:"检查已安装的脚本有没有新版本,有的话说明更新了什么;先不要安装。"}],intervene:[{title:"汇总夜里的异常",prompt:"汇总最近 12 小时运行里出过的异常:哪些已经自动处理了,哪些还要我管、该怎么做。"}],pipelines:[{title:"检查流水线跑得怎么样",prompt:"看看各条流水线最近一次运行是否成功,失败的说明卡在哪一步、可能的原因。"}]};function Mo(e,t){if(!e.enabled)return;const s=new Date(t);s.setHours(0,0,0,0);for(let i=0;i<8;i++,s.setDate(s.getDate()+1)){if(e.days.length>0&&!e.days.includes(s.getDay()))continue;const r=e.times.map(o=>{const[l,u]=o.split(":").map(Number);return new Date(s.getFullYear(),s.getMonth(),s.getDate(),l,u).getTime()}).filter(o=>o>t).sort((o,l)=>o-l);if(r[0]!==void 0)return r[0]}}const Zc=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"});function Q3(e){const t=_e(e.connection.status),[s,i]=v.useState(0),[r,o]=v.useState({items:null,error:null});return v.useEffect(()=>e.connection.on("tasks/changed",()=>i(l=>l+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let l=!0;return e.connection.call("tasks/list",{}).then(u=>{l&&o({items:u.items,error:null})},u=>{l&&o(d=>({...d,error:$e(u)}))}),()=>{l=!1}},[e,t.state,s]),r}function J3(e){const t=_e(e.connection.status),s=_e(e.capabilities),[i,r]=v.useState(0),[o,l]=v.useState([]);return v.useEffect(()=>e.connection.on("reminders/changed",()=>r(u=>u+1)),[e]),v.useEffect(()=>{if(t.state!=="open"||!s.has("agents"))return;let u=!0;return e.connection.call("reminders/list",{}).then(d=>{u&&l(d.items)}).catch(()=>{}),()=>{u=!1}},[e,t.state,s,i]),o}function e5(e){const t=_e(e.connection.status),[s,i]=v.useState(0),[r,o]=v.useState([]);return v.useEffect(()=>e.connection.on("pipelines/changed",()=>i(l=>l+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let l=!0;return e.connection.call("pipelines/list",{}).then(u=>{l&&o(u.items)}).catch(()=>{}),()=>{l=!1}},[e,t.state,s]),r}function t5(e){const t=_e(e.connection.status),s=_e(e.capabilities),[i,r]=v.useState(null);return v.useEffect(()=>{if(t.state!=="open"||!s.has("games"))return;let o=!0;return e.connection.call("games/list",{}).then(l=>{o&&r({schedule:{enabled:l.settings.report.enabled,times:[l.settings.report.at],days:[],catchUpMinutes:0}})}).catch(()=>{}),()=>{o=!1}},[e,t.state,s]),i}function l1(e){const t=$i(e);return v.useMemo(()=>[cn,...t.map(Ka)],[t])}function mc({agent:e,size:t="small"}){return n.jsx("span",{className:`agent-avatar ${t} agent-${(e==null?void 0:e.id)??"unknown"}`,children:n.jsx(Q,{name:(e==null?void 0:e.icon)??"sparkles"})})}function n5({client:e,focus:t,agent:s}){const i=l1(e),{items:r,error:o}=Q3(e),l=J3(e),u=e5(e),d=t5(e),h=vn(3e4),[m,p]=v.useState(s??null),[g,x]=v.useState(null),[N,j]=v.useState(void 0),y=v.useRef(null),k=v.useRef(void 0),_=u.filter(R=>R.schedule.enabled&&R.draft!==!0),S=(d==null?void 0:d.schedule.enabled)===!0?d:null,E=new Map(i.map(R=>[R.id,0]));for(const R of r??[])E.set(R.agent,(E.get(R.agent)??0)+1);for(const R of l)E.set(R.agent,(E.get(R.agent)??0)+1);E.set("pipelines",(E.get("pipelines")??0)+_.length),S!==null&&E.set("games",(E.get("games")??0)+1);const O=[...E.values()].reduce((R,M)=>R+M,0),P=i.filter(R=>m===null||R.id===m);v.useEffect(()=>{s!==void 0&&p(s)},[s]),v.useEffect(()=>{var M,F;if(t===void 0||k.current===t)return;const R=((M=r==null?void 0:r.find(L=>L.id===t))==null?void 0:M.agent)??((F=l.find(L=>L.id===t))==null?void 0:F.agent);R!==void 0&&(k.current=t,p(L=>L===null||L===R?L:null),j(t))},[t,r,l]),v.useEffect(()=>{var F;if(N===void 0)return;const R=(F=y.current)==null?void 0:F.querySelector(`[data-schedule-id="${CSS.escape(N)}"]`);if(R==null)return;R.scrollIntoView({block:"center",behavior:"smooth"});const M=setTimeout(()=>j(void 0),2600);return()=>clearTimeout(M)},[N]);const H=v.useMemo(()=>[...S===null?[]:[{key:"daily-report",agent:"games",title:"每日日报",at:Mo(S.schedule,h)}],...(r??[]).map(R=>({key:R.id,agent:R.agent,title:R.title,at:Mo(R.schedule,h)})),..._.map(R=>({key:R.id,agent:"pipelines",title:`流水线「${R.name}」`,at:Mo(R.schedule,h)})),...l.map(R=>({key:R.id,agent:R.agent,title:`提醒:${R.title}`,at:R.next}))].filter(R=>R.at!==void 0&&(m===null||R.agent===m)).sort((R,M)=>R.at-M.at).slice(0,8),[r,l,_,S,h,m]),B=R=>{var M;x({kind:"new",agent:R}),(M=y.current)==null||M.scrollTo({top:0,behavior:"smooth"})};return n.jsxs("section",{className:"main scripts-page agent-schedule",children:[n.jsxs("header",{className:"page-header",children:[n.jsxs("div",{className:"breadcrumb",children:[n.jsx("h1",{children:"定时任务"}),O>0&&n.jsx("span",{className:"tab-count",children:O})]}),n.jsxs("div",{className:"page-actions",children:[n.jsxs("a",{className:"small-button",href:"#/settings/schedule",children:[n.jsx(Q,{name:"settings"}),"开机自启与唤醒"]}),n.jsxs("button",{className:"small-button primary",onClick:()=>B(m??wn),disabled:(g==null?void 0:g.kind)==="new",children:[n.jsx(Q,{name:"plus"}),"新建定时任务"]})]})]}),n.jsxs("div",{className:"schedule-body",ref:y,children:[n.jsx("p",{className:"muted small",children:"到点把一件事交给某个 agent,在它的对话里做;做完后要紧的由助手告诉你。所有 agent 的定时任务、它们在对话里自己设的提醒、按时运行的流水线和游戏的每日日报都在这里。要跑脚本的多步任务,用「编排」做成流水线。"}),o!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:o})]}),(g==null?void 0:g.kind)==="new"&&n.jsx(Ak,{client:e,agents:i,task:{agent:g.agent},onDone:()=>x(null)}),n.jsxs("div",{className:"schedule-filter",role:"group","aria-label":"只看谁的",children:[n.jsxs("button",{className:`agent-chip ${m===null?"on":""}`,"aria-pressed":m===null,onClick:()=>p(null),children:["全部",n.jsx("span",{className:"tab-count",children:O})]}),i.map(R=>n.jsxs("button",{className:`agent-chip ${m===R.id?"on":""}`,"aria-pressed":m===R.id,onClick:()=>p(m===R.id?null:R.id),children:[n.jsx(mc,{agent:R}),R.name,n.jsx("span",{className:"tab-count",children:E.get(R.id)??0})]},R.id))]}),n.jsxs("section",{className:"schedule-group",children:[n.jsx("h3",{children:"接下来"}),H.length===0&&n.jsx("p",{className:"muted small",children:"一周内没有要按时做的事。"}),n.jsx("ol",{className:"schedule-timeline",children:H.map(R=>{const M=i.find(F=>F.id===R.agent);return n.jsxs("li",{children:[n.jsx("span",{className:"schedule-when",children:Zc(R.at)}),n.jsx(mc,{agent:M}),n.jsx("span",{className:"schedule-who",children:(M==null?void 0:M.name)??"?"}),n.jsx("span",{className:"schedule-what",children:R.title})]},`${R.key}@${R.at}`)})})]}),P.map(R=>{const M=(r??[]).filter(z=>z.agent===R.id),F=l.filter(z=>z.agent===R.id),L=R.id==="pipelines"?_:[],A=R.id==="games"?S:null,I=M.length===0&&F.length===0&&L.length===0&&A===null;return I&&m!==R.id?null:n.jsxs("section",{className:"schedule-group",children:[n.jsxs("h3",{className:"schedule-agent",children:[n.jsx(mc,{agent:R}),R.name,n.jsx("span",{className:"tab-count",children:M.length+F.length+L.length+(A===null?0:1)}),n.jsx("span",{className:"spacer"}),n.jsxs("button",{className:"link-button",onClick:()=>B(R.id),children:[n.jsx(Q,{name:"plus"}),"给",R.name,"新建"]})]}),I&&n.jsxs("div",{className:"empty-card muted",children:[R.name,"还没有定时任务。"]}),A!==null&&n.jsx(s5,{report:A,now:h}),M.map(z=>(g==null?void 0:g.kind)==="edit"&&g.id===z.id?n.jsx(Ak,{client:e,agents:i,task:z,onDone:()=>x(null)},z.id):n.jsx(o5,{client:e,task:z,now:h,lit:N===z.id,onEdit:()=>x({kind:"edit",id:z.id})},z.id)),F.length>0&&n.jsxs("p",{className:"muted small schedule-sub",children:[R.name,"在对话里自己设的提醒:你让它「几点提醒我…」时设的,到点它在对话里接着做。要改时间,直接跟它说。"]}),F.map(z=>n.jsx(r5,{client:e,reminder:z,now:h,lit:N===z.id},z.id)),L.map(z=>n.jsx(i5,{pipeline:z,now:h},z.id))]},R.id)}),r!==null&&O===0&&g===null&&m===null&&n.jsx("div",{className:"empty-card muted",children:"还没有定时任务。点「新建定时任务」,选一个 agent、写下到点要它做的事。"})]})]})}function s5({report:e,now:t}){const s=Mo(e.schedule,t);return n.jsxs("a",{className:"task-card pipeline-line",href:"#/p/daily-report",title:"在游戏的「日报」里设置",children:[n.jsx(Q,{name:"send"}),n.jsx("span",{className:"task-title",children:"每日日报"}),n.jsxs("span",{className:"muted small",children:[Ug(e.schedule),s===void 0?"":` · 下次 ${Zc(s)}`," · 发到飞书"]}),n.jsx("span",{className:"muted small daily-report-where",children:"在游戏的「日报」里设置"}),n.jsx(Q,{name:"chevron"})]})}function i5({pipeline:e,now:t}){const s=Mo(e.schedule,t);return n.jsxs("a",{className:"task-card pipeline-line",href:`#/p/pipelines/${encodeURIComponent(e.id)}`,children:[n.jsx(Q,{name:"flow"}),n.jsx("span",{className:"task-title",children:e.name}),n.jsxs("span",{className:"muted small",children:[Ug(e.schedule),s===void 0?"":` · 下次 ${Zc(s)}`]}),n.jsx(Q,{name:"chevron"})]})}function r5({client:e,reminder:t,now:s,lit:i}){const[r,o]=v.useState(null),l=async()=>{await Ms({title:"删除这个提醒?",message:"agent 到时候就不会再被叫起来做这件事。要改时间,直接在对话里跟它说。",quote:t.title,confirmLabel:"删除",danger:!0})&&(o(null),e.connection.call("reminders/remove",{id:t.id}).catch(u=>o($e(u))))};return n.jsxs("div",{className:`task-card reminder-card ${i?"lit":""}`,"data-schedule-id":t.id,children:[n.jsxs("div",{className:"task-card-head",children:[n.jsx(Q,{name:"calendar"}),n.jsx("span",{className:"task-title",children:t.title}),n.jsxs("span",{className:"muted small",children:[t.rule==="一次"?"":`${t.rule} · `,t.repeats?"下次 ":"",Zc(t.next),t.next>s?`(${a5(t.next-s)}后)`:""]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"icon-button",onClick:()=>void l(),title:"删除这个提醒","aria-label":"删除",children:n.jsx(Q,{name:"close"})})]}),n.jsx("div",{className:"task-prompt",children:t.prompt}),r!==null&&n.jsx("div",{className:"error small",children:r})]})}function a5(e){const t=Math.max(1,Math.round(e/6e4));if(t<60)return`${t} 分钟`;const s=Math.round(t/60);return s<48?`${s} 小时`:`${Math.round(s/24)} 天`}function o5({client:e,task:t,now:s,lit:i,onEdit:r}){const[o,l]=v.useState(null),u=Mo(t.schedule,s),d=t.lastRun,h=g=>{l(null),e.connection.call(g,{id:t.id}).catch(x=>l($e(x)))},m=()=>{l(null),e.connection.call("tasks/save",{task:{...t,schedule:{...t.schedule,enabled:!t.schedule.enabled}}}).catch(g=>l($e(g)))},p=async()=>{await Ms({title:"删除这个定时任务?",message:"删掉后到点不会再交给 agent 做,不能撤销。",quote:t.title,confirmLabel:"删除",danger:!0})&&h("tasks/remove")};return n.jsxs("div",{className:`task-card ${t.schedule.enabled?"":"paused"} ${i?"lit":""}`,"data-schedule-id":t.id,children:[n.jsxs("div",{className:"task-card-head",children:[n.jsx("span",{className:"task-title",children:t.title}),n.jsxs("span",{className:"muted small",children:[Ug(t.schedule),u===void 0?"":` · 下次 ${Zc(u)}`]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>h("tasks/run"),disabled:(d==null?void 0:d.state)==="running",title:"现在就交给它做一次",children:(d==null?void 0:d.state)==="running"?"在做":"立即运行"}),n.jsx("button",{className:"small-button",onClick:m,children:t.schedule.enabled?"暂停":"开启"}),n.jsx("button",{className:"icon-button",onClick:r,title:"修改","aria-label":"修改",children:n.jsx(Q,{name:"pencil"})}),n.jsx("button",{className:"icon-button",onClick:()=>void p(),title:"删除","aria-label":"删除",children:n.jsx(Q,{name:"close"})})]}),n.jsx("div",{className:"task-prompt",children:t.prompt}),d!==void 0&&n.jsxs("div",{className:`task-run tone-${d.state==="done"?"ok":d.state==="failed"?"failed":"running"}`,children:[d.state==="running"?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(Q,{name:d.state==="done"?"check":"alert"}),n.jsxs("span",{children:[d.state==="running"?"正在做":`${vt(d.endedAt??d.startedAt,s)}${d.state==="done"?"做完":"没做成"}`,d.outcome===void 0?"":`:${d.outcome.split(`
|
|
215
|
-
`)[0]}`]})]}),o!==null&&n.jsx("div",{className:"error small",children:o})]})}function Ak({client:e,agents:t,task:s,onDone:i}){var P,H;const[r,o]=v.useState(s.agent),[l,u]=v.useState(s.title??""),[d,h]=v.useState(s.prompt??""),[m,p]=v.useState((((P=s.schedule)==null?void 0:P.times)??["09:00"]).join(", ")),[g,x]=v.useState(((H=s.schedule)==null?void 0:H.days)??[]),[N,j]=v.useState(!1),[y,k]=v.useState(null),_=t.find(B=>B.id===r)??cn,S=X3[r]??[],E=(B,R)=>B.length===R.length&&B.every(M=>R.includes(M)),O=async()=>{var B,R;j(!0),k(null);try{const M=m.split(/[,,、\s]+/).filter(F=>F!=="").map(F=>/^\d:\d\d$/.test(F)?`0${F}`:F);await e.connection.call("tasks/save",{task:{...s.id===void 0?{}:{id:s.id},agent:r,title:l,prompt:d,schedule:{enabled:((B=s.schedule)==null?void 0:B.enabled)??!0,times:M,days:[...g],catchUpMinutes:((R=s.schedule)==null?void 0:R.catchUpMinutes)??10}}}),i()}catch(M){k($e(M))}finally{j(!1)}};return n.jsxs("div",{className:"task-card task-form",children:[n.jsxs("div",{className:"task-form-step",children:[n.jsx("span",{className:"task-form-label",children:"交给谁"}),n.jsx("div",{className:"agent-pick",role:"radiogroup","aria-label":"交给谁",children:t.map(B=>n.jsxs("button",{type:"button",role:"radio","aria-checked":B.id===r,className:`agent-pick-item ${B.id===r?"on":""}`,onClick:()=>o(B.id),title:B.description,children:[n.jsx(mc,{agent:B,size:""}),n.jsxs("span",{className:"agent-pick-text",children:[n.jsx("span",{className:"agent-pick-name",children:B.name}),n.jsx("span",{className:"agent-pick-desc",children:B.description})]})]},B.id))}),r==="games"&&n.jsxs("p",{className:"muted small",children:["游戏的每日日报不在这里设:在游戏的",n.jsx("a",{href:"#/p/daily-report",children:"「日报」"}),"里设置时间和内容。"]})]}),n.jsxs("div",{className:"task-form-step",children:[n.jsxs("span",{className:"task-form-label",children:["要",_.name,"做什么"]}),S.length>0&&n.jsxs("div",{className:"task-examples",children:[n.jsx("span",{className:"muted small",children:"可以从这里开始:"}),S.map(B=>n.jsx("button",{type:"button",className:"example-chip",onClick:()=>{u(B.title),h(B.prompt)},children:B.title},B.title))]}),n.jsxs("label",{className:"field-label",children:["名字",n.jsx("input",{className:"text-input plain",value:l,maxLength:60,onChange:B=>u(B.target.value),placeholder:"例如:看今天结束的活动"})]}),n.jsxs("label",{className:"field-label",children:["交给它的话",n.jsx("textarea",{className:"text-input plain",rows:3,value:d,maxLength:4e3,onChange:B=>h(B.target.value),placeholder:"写完整:要做什么、要交回什么"})]})]}),n.jsxs("div",{className:"task-form-step",children:[n.jsx("span",{className:"task-form-label",children:"什么时候"}),n.jsxs("div",{className:"task-form-row",children:[n.jsxs("label",{className:"field-label",children:["时间",n.jsx("input",{className:"text-input plain-mono",value:m,onChange:B=>p(B.target.value),placeholder:"09:00, 21:30"})]}),n.jsxs("div",{className:"field-label",children:["星期",n.jsxs("div",{className:"day-chips",children:[n.jsx("button",{type:"button",className:`day-preset ${g.length===0?"on":""}`,"aria-pressed":g.length===0,onClick:()=>x([]),children:"每天"}),n.jsx("button",{type:"button",className:`day-preset ${E(g,Wf)?"on":""}`,"aria-pressed":E(g,Wf),onClick:()=>x(Wf),children:"工作日"}),n.jsx("button",{type:"button",className:`day-preset ${E(g,Vf)?"on":""}`,"aria-pressed":E(g,Vf),onClick:()=>x(Vf),children:"周末"}),n.jsx("span",{className:"day-chips-gap"}),Y3.map(B=>n.jsx("button",{type:"button",className:`day-chip ${g.includes(B)?"on":""}`,"aria-pressed":g.includes(B),onClick:()=>x(g.includes(B)?g.filter(R=>R!==B):[...g,B]),children:K3[B]},B))]})]})]})]}),y!==null&&n.jsx("div",{className:"error small",children:y}),n.jsxs("div",{className:"task-form-actions",children:[n.jsx("button",{className:"small-button",onClick:i,disabled:N,children:"取消"}),n.jsx("button",{className:"small-button primary",onClick:()=>void O(),disabled:N||l.trim()===""||d.trim()==="",children:s.id===void 0?`交给${_.name}`:"保存"})]})]})}function l5({client:e,onOpen:t}){const s=l1(e),[i,r]=v.useState([]),o=v.useRef(0);if(v.useEffect(()=>e.connection.on("schedule/agentSet",u=>{const d=o.current++;r(h=>[...h.slice(-2),{...u,key:d}]),setTimeout(()=>r(h=>h.filter(m=>m.key!==d)),2e4)}),[e]),i.length===0)return null;const l=u=>r(d=>d.filter(h=>h.key!==u));return n.jsx("div",{className:"schedule-notices","aria-live":"polite",children:i.map(u=>{const d=s.find(p=>p.id===u.by),h=s.find(p=>p.id===u.agent),m=u.kind==="task"?u.changed?"改了一个定时任务":"设了一个定时任务":"设了一个提醒";return n.jsxs("div",{className:"schedule-notice",role:"status",children:[n.jsx(mc,{agent:d,size:""}),n.jsxs("div",{className:"schedule-notice-text",children:[n.jsxs("span",{className:"schedule-notice-head",children:[(d==null?void 0:d.name)??"agent",m]}),n.jsx("span",{className:"schedule-notice-title",children:u.title}),n.jsxs("span",{className:"muted small",children:[u.kind==="task"&&u.agent!==u.by?`交给${(h==null?void 0:h.name)??u.agent}`:"",u.kind==="task"&&u.agent!==u.by&&u.when!==""?" · ":"",u.when]}),n.jsx("span",{className:"schedule-notice-actions",children:n.jsxs("button",{className:"small-button primary",onClick:()=>{l(u.key),t(u.id)},children:[n.jsx(Q,{name:"clock"}),"去定时任务看看"]})})]}),n.jsx("button",{className:"icon-button",onClick:()=>l(u.key),title:"知道了","aria-label":"关闭",children:n.jsx(Q,{name:"close"})})]},u.key)})})}const c5=["切换到 dsh 官方界面:DeepSeek Harness 自带的原版界面,没有 MultiGameAssistant 的脚本、编排、游戏等功能。","","· 它是另一个独立的 dsh:聊天记录、设置和模型密钥都和这里分开,第一次用要在那边重新填模型密钥;","· 第一次切换要启动它,可能要等一会儿;","· 这边的定时任务和脚本在后台照常运行。","","点标题栏左上角的「返回 MultiGameAssistant」切回来。"].join(`
|
|
216
|
-
`),c1="adg.officialIntro";function u5(){var l;const e=(l=Vs())==null?void 0:l.uiMode,[t,s]=v.useState(null);if(v.useEffect(()=>{if(e===void 0)return;let u=!0;e.state().then(h=>{u&&s(h)},()=>{});const d=e.onChange(s);return()=>{u=!1,d()}},[e]),e===void 0||t===null)return null;const i=t.mode==="official",r=()=>{if(i){e.set("adg");return}const u=()=>{h5(),e.set("official")};if(d5()){u();return}Ms({title:"切换到 dsh 官方界面?",message:c5,confirmLabel:"切换",icon:"popout"}).then(d=>{d&&u()})},o=t.starting?"正在启动官方界面…":i?"返回 MultiGameAssistant":"dsh 官方界面";return n.jsxs("div",{className:"ui-switch",children:[n.jsxs("button",{type:"button",className:`ui-switch-button ${i?"active":""}`,disabled:t.starting,onClick:r,title:i?"切回 MultiGameAssistant 的界面":"切换到 DeepSeek Harness 自带的界面(聊天记录分开)",children:[n.jsx(Q,{name:i?"back":"layers"}),n.jsx("span",{children:o})]}),t.error!==void 0&&n.jsxs("span",{className:"ui-switch-error",role:"alert",title:t.error,children:[n.jsx("span",{children:t.error}),n.jsx("button",{type:"button",className:"icon-button","aria-label":"关闭",onClick:()=>void e.set("adg"),children:n.jsx(Q,{name:"close"})})]})]})}function d5(){try{return localStorage.getItem(c1)==="1"}catch{return!1}}function h5(){try{localStorage.setItem(c1,"1")}catch{}}const rg="adg.token",mh=/^\/adg(\/|$)/.test(location.pathname);function m5(){var e;for(const t of[window,window.parent])try{const s=(e=t.__DSH_TRANSPORT__)==null?void 0:e.streamBaseUrl;if(typeof s=="string"&&s!=="")return s}catch{}}function f5(){const e=new URL(location.href),t=e.searchParams.get("token");if(t!==null&&t!==""){try{sessionStorage.setItem(rg,t)}catch{}return e.searchParams.delete("token"),history.replaceState(history.state,"",e),t}let s=null;try{s=sessionStorage.getItem(rg)}catch{}return s??null}function p5(e){try{sessionStorage.setItem(rg,e)}catch{}}function g5(e){if(mh){const s=new URL(m5()??location.origin);return`${s.protocol==="https:"?"wss":"ws"}://${s.host}/adg/rpc`}return`${location.protocol==="https:"?"wss":"ws"}://${location.host}/rpc?token=${encodeURIComponent(e??"")}`}function $k(){if(location.hash==="#/settings")return{kind:"settings"};const e=/^#\/settings\/(.+)$/.exec(location.hash);if(e!==null)return{kind:"settings",section:decodeURIComponent(e[1])};if(location.hash==="#/p/games/report")return{kind:"page",id:"daily-report"};const t=/^#\/p\/([^/]+)(?:\/(.+))?$/.exec(location.hash);if(t!==null)return{kind:"page",id:decodeURIComponent(t[1]),...t[2]===void 0?{}:{arg:decodeURIComponent(t[2])}};if(location.hash==="#/chat")return{kind:"home"};if(location.hash==="#/schedule")return{kind:"schedule"};const s=/^#\/schedule\/(.+)$/.exec(location.hash);if(s!==null)return{kind:"schedule",focus:decodeURIComponent(s[1])};const i=/^#\/a\/(.+)\/schedule$/.exec(location.hash);if(i!==null)return{kind:"schedule",agent:decodeURIComponent(i[1])};const r=/^#\/h\/(.+)$/.exec(location.hash);if(r!==null)return{kind:"handoff",id:decodeURIComponent(r[1])};const o=/^#\/a\/([^/]+)\/task\/([^/]+)$/.exec(location.hash);if(o)return{kind:"agent",id:decodeURIComponent(o[1]),child:decodeURIComponent(o[2])};const l=/^#\/a\/(.+)\/(history)$/.exec(location.hash);if(l!==null)return{kind:"agent",id:decodeURIComponent(l[1])};const u=/^#\/a\/(.+)$/.exec(location.hash);if(u!==null)return{kind:"agent",id:decodeURIComponent(u[1])};const d=/^#\/s\/(.+)$/.exec(location.hash);return d===null?{kind:"start"}:{kind:"session",id:decodeURIComponent(d[1])}}function x5(e,t="push"){const s=e.kind==="session"?`#/s/${encodeURIComponent(e.id)}`:e.kind==="agent"?`#/a/${encodeURIComponent(e.id)}${e.child===void 0?"":`/task/${encodeURIComponent(e.child)}`}`:e.kind==="handoff"?`#/h/${encodeURIComponent(e.id)}`:e.kind==="schedule"?e.focus===void 0?"#/schedule":`#/schedule/${encodeURIComponent(e.focus)}`: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===s)return;const i=`${location.pathname}${location.search}${s}`;t==="replace"?history.replaceState(history.state,"",i):history.pushState(null,"",i)}const qf="games";function v5({client:e}){const[t,s]=v.useState(()=>$k()),[i,r]=tz(),[o,l]=v.useState(null),u=_e(e.sessions),d=bO(e),h=_e(e.connection.status),m=$i(e),p=v.useRef(!1),g=v.useRef(null);v.useEffect(()=>{x5(t,p.current?"replace":"push"),p.current=!1,t.kind!=="handoff"&&(g.current=t)},[t]);const x=t.kind==="handoff"?t:null,N=g.current,j=x===null?t:N!==null&&N.kind!=="settings"?N:{kind:"agent",id:wn};v.useEffect(()=>{const V=()=>s($k());return window.addEventListener("hashchange",V),()=>window.removeEventListener("hashchange",V)},[]);const y=v.useRef(new Set);v.useEffect(()=>{for(const q of u.items)y.current.add(q.id);if(t.kind!=="session"||!u.loaded||u.items.some(q=>q.id===t.id))return;const V=()=>{p.current=!0,s(q=>q.kind==="session"&&q.id===t.id?{kind:"home"}:q)};if(y.current.has(t.id)){V();return}const U=setTimeout(V,8e3);return()=>clearTimeout(U)},[t,u]),v.useEffect(()=>{if(t.kind!=="session")return;const V=u.items.find(q=>q.id===t.id);if(!V)return;const U=Gp(V,new Map(u.items.map(q=>[q.id,q])));p.current=!0,s({kind:"agent",id:U.home??U.role??wn,...V.origin==="subagent"?{child:V.id}:{}})},[t,u]),v.useEffect(()=>{t.kind!=="start"||h.state!=="open"||(p.current=!0,s(d.some(V=>V.id===qf)?{kind:"page",id:qf}:{kind:"home"}))},[t,h.state,d]);const k=V=>s({kind:"session",id:V}),_=V=>s({kind:"settings",...V===void 0?{}:{section:V}}),S=V=>s({kind:"page",id:V}),E=j.kind==="session"?j.id:null,O=j.kind==="start"?{kind:"page",id:qf}:j,P=O.kind==="page"?d.find(V=>V.id===O.id):void 0,H=V=>V.agent===void 0?void 0:m.some(U=>U.id===V.agent)?V.agent:wn,B=P===void 0?void 0:H(P),R=V=>s({kind:"agent",id:V}),M=()=>R(wn),F=n.jsxs(n.Fragment,{children:[n.jsx(k5,{client:e,onSettings:()=>_("api-keys")}),n.jsx(IO,{client:e})]}),L=j.kind==="home"?wn:j.kind==="agent"?j.id:B,A=(V,U)=>s(U==="chat"?{kind:"agent",id:V}:{kind:"page",id:U}),I=j.kind==="settings"?{kind:"settings"}:j.kind==="schedule"?{kind:"schedule"}:L!==void 0?{kind:"agent",id:L}:O.kind==="page"?{kind:"page",id:O.id}:{kind:"none"},z=P===void 0?null:n.jsx(P.component,{client:e,openSession:k,openSettings:_,openPage:S,arg:O.kind==="page"?O.arg:void 0},P.id),D=L===void 0?null:n.jsx(y5,{client:e,agentId:L,pages:d.filter(V=>H(V)===L),current:O.kind==="page"?O.id:"chat",onTab:V=>A(L,V)});return n.jsx(cS.Provider,{value:o,children:n.jsx(rz.Provider,{value:i>=To,children:n.jsxs("div",{className:`app ${j.kind==="settings"?"with-sidebar":""}`,style:{"--rail-width":`${i}px`},children:[n.jsx(JL,{client:e,pages:d.filter(V=>V.agent===void 0),current:I,onAgent:R,onPage:S,onSchedule:()=>s({kind:"schedule"}),onSettings:()=>_(),width:i,onWidth:r,slot:l}),j.kind==="settings"&&n.jsx(G3,{client:e,onClose:M,section:j.section,onSection:V=>s({kind:"settings",section:V})}),j.kind!=="settings"&&n.jsxs("div",{className:`app-main ${x===null?"":"under-exchange"}`,children:[O.kind==="page"&&B===void 0&&(z??n.jsx("section",{className:"main empty",children:h.state==="open"?"当前连接没有提供这个功能。":"正在连接…"})),L!==void 0&&n.jsxs("div",{className:"agent-area",children:[D,B!==void 0?z:n.jsx(b5,{client:e,agentId:L,onMain:M,child:j.kind==="agent"?j.child:void 0,reminder:F},L)]}),j.kind==="schedule"&&n.jsx(n5,{client:e,focus:j.focus,agent:j.agent}),j.kind==="session"&&n.jsx("section",{className:"main empty",children:"正在打开助手对话…"}),x!==null&&n.jsx(dD,{client:e,id:x.id,onClose:()=>s(j)},x.id)]}),n.jsx(WL,{client:e,sessionId:E,onSelect:k}),n.jsx(l5,{client:e,onOpen:V=>s({kind:"schedule",...V===void 0?{}:{focus:V}})}),n.jsx(u5,{})]})})})}function y5({client:e,agentId:t,pages:s,current:i,onTab:r}){const l=$i(e).find(m=>m.id===t),u=l===void 0?cn:Ka(l),d=[{id:"chat",title:"对话",icon:"chat"},...[...s].sort((m,p)=>m.order-p.order).map(m=>({id:m.id,title:m.title,icon:m.icon}))];if(d.length===1)return null;const h=n.jsx("nav",{className:"agent-tabs in-title-bar",role:"tablist","aria-label":u.name,children:d.map(m=>n.jsxs("button",{role:"tab","aria-selected":m.id===i,className:m.id===i?"active":"",onClick:()=>r(m.id),children:[n.jsx(Q,{name:m.icon}),m.title]},m.id))});return qa.createPortal(h,document.body)}function b5({client:e,agentId:t,onMain:s,child:i,reminder:r}){const{sessionId:o,error:l}=lS(e,t);return l!==null?n.jsx("section",{className:"main empty",children:n.jsxs("span",{children:[l,n.jsx("button",{className:"link-button",onClick:s,children:"回到助手"})]})}):o===null?n.jsx("section",{className:"main empty",children:"正在打开…"}):n.jsx(O3,{client:e,sessionId:o,child:i,reminder:r},o)}function k5({client:e,onSettings:t}){var o;const{items:s}=gw(e,[$p]),{catalog:i}=aa(e),r=(i==null?void 0:i.groups.some(l=>l.id!=="deepseek-official"&&l.models.length>0))??!1;return((o=s==null?void 0:s[$p])==null?void 0:o.configured)!==!1||r?null:n.jsxs("div",{className:"reminder",children:[n.jsx(Q,{name:"key"}),n.jsx("span",{children:"还没有可用的模型:请填写 DeepSeek API Key,或添加一个自定义 API(Claude、ChatGPT 等)。"}),n.jsx("button",{className:"primary small-button",onClick:t,children:"去设置"})]})}function j5({onSubmit:e}){const[t,s]=v.useState("");return n.jsx("div",{className:"token-prompt",children:n.jsxs("form",{onSubmit:i=>{i.preventDefault(),t.trim()!==""&&e(t.trim())},children:[n.jsx(Kg,{size:"lg"}),n.jsxs("div",{className:"token-heading",children:[n.jsx("p",{className:"eyebrow",children:"MULTI GAME ASSISTANT"}),n.jsx("h1",{children:"连接 agent"}),n.jsxs("p",{className:"muted",children:["输入后端启动时打印的连接 token(",n.jsx("code",{children:"adg gateway: …?token="})," 后面的部分)。"]})]}),n.jsx("label",{className:"field-label",htmlFor:"adg-token",children:"连接 Token"}),n.jsx("input",{id:"adg-token",className:"text-input",autoFocus:!0,value:t,onChange:i=>s(i.target.value),placeholder:"粘贴连接 token"}),n.jsx("button",{className:"primary",type:"submit",disabled:t.trim()==="",children:"连接"})]})})}const N5=["准备环境","启动服务","载入界面","连接 agent"],w5=8e3,S5=400;function _5({client:e}){const t=_e(e.connection.status),s=_e(e.sessions),[i,r]=v.useState("shown"),[o,l]=v.useState(!1),u=t.state==="open"&&s.loaded;if(v.useEffect(()=>{const m=setTimeout(()=>l(!0),w5);return()=>clearTimeout(m)},[]),v.useEffect(()=>{u&&r(m=>m==="shown"?"leaving":m)},[u]),v.useEffect(()=>{if(i!=="leaving")return;const m=setTimeout(()=>r("gone"),S5);return()=>clearTimeout(m)},[i]),i==="gone")return null;const d=t.state==="open"?"正在读取对话":t.state==="reconnecting"?`连不上 agent,正在重试(第 ${t.attempt} 次)`:t.state==="connecting"?"正在连接 agent":"没有连上 agent",h=o?t.error!==void 0?`连接出错:${t.error}`:"比平时慢一些,agent 服务可能还在启动。":"";return n.jsxs("div",{className:`boot${i==="leaving"?" leaving":""}`,"aria-hidden":i==="leaving",children:[n.jsxs("div",{className:"boot-center",children:[n.jsxs("div",{className:"boot-mark","aria-hidden":"true",children:[n.jsxs("svg",{className:"boot-orbit",viewBox:"0 0 132 132",children:[n.jsx("circle",{className:"track",cx:"66",cy:"66",r:"62"}),n.jsx("circle",{className:"comet",cx:"66",cy:"66",r:"62"})]}),n.jsx("span",{className:"boot-tile",children:n.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9.5 8.3v7.4l6.2-3.7-6.2-3.7Z"}),n.jsx("path",{className:"loop",d:"M4 12a8 8 0 0 1 14.5-4.7M20 12a8 8 0 0 1-14.5 4.7"})]})})]}),n.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),n.jsx("p",{className:"boot-stage",role:"status","aria-live":"polite",children:n.jsx("span",{children:d})}),n.jsx("ol",{className:"boot-steps",children:N5.map((m,p)=>n.jsxs("li",{className:p<3?"done":"now",children:[n.jsx("i",{}),n.jsx("span",{children:m})]},m))}),n.jsx("p",{className:`boot-hint${h!==""?" shown":""}`,children:h}),o&&n.jsx("button",{type:"button",className:"boot-skip",onClick:()=>r("leaving"),children:"先进入界面"})]}),n.jsx("p",{className:"boot-foot",children:"日常交给 agent · 在本机运行"})]})}class E5 extends v.Component{constructor(){super(...arguments);ht(this,"state",{error:null})}static getDerivedStateFromError(s){return{error:s instanceof Error?s:new Error(String(s))}}componentDidCatch(s,i){console.error(`界面出错:${s instanceof Error?s.stack??s.message:String(s)}${i.componentStack??""}`)}render(){const{error:s}=this.state;if(s===null)return this.props.children;const i=`${s.message}
|
|
217
|
-
|
|
218
|
-
${(s.stack??"").split(`
|
|
219
|
-
`).slice(1,8).join(`
|
|
220
|
-
`)}`;return n.jsx("div",{className:"boot failed",children:n.jsxs("div",{className:"boot-center",children:[n.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),n.jsx("p",{className:"boot-stage",role:"alert",children:n.jsx("span",{children:"界面出错了"})}),n.jsx("div",{className:"boot-detail",children:n.jsx("pre",{tabIndex:0,children:i})}),n.jsxs("div",{className:"boot-actions",children:[n.jsx("button",{type:"button",className:"primary",onClick:()=>location.reload(),children:"重新载入"}),n.jsx("button",{type:"button",onClick:()=>{var r;return void((r=navigator.clipboard)==null?void 0:r.writeText(i))},children:"复制错误信息"})]})]})})}}const C5=450,sd=6,Hl=8,Gf="data-tip";function A5(){return Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--title-bar"))||0}function $5(){const[e,t]=v.useState(null),s=v.useRef(null),[i,r]=v.useState(null);return v.useEffect(()=>{let o=null,l;const u=()=>{if(window.clearTimeout(l),l=void 0,o!==null){const m=o.getAttribute(Gf);o.removeAttribute(Gf),m!==null&&!o.hasAttribute("title")&&o.setAttribute("title",m)}o=null,t(null)},d=m=>{var x,N,j,y;if(m.pointerType==="touch")return;if(o!==null&&o.contains(m.target)){const k=(N=(x=m.target).closest)==null?void 0:N.call(x,"[title]");if(k==null||!o.contains(k))return}const p=((y=(j=m.target)==null?void 0:j.closest)==null?void 0:y.call(j,"[title]"))??null;if(p===o||(u(),p===null))return;const g=p.getAttribute("title")??"";g.trim()!==""&&(o=p,p.setAttribute(Gf,g),p.removeAttribute("title"),l=window.setTimeout(()=>{o===p&&p.isConnected&&t({text:g,anchor:p.getBoundingClientRect(),side:p.closest(".rail")!==null?"right":"auto"})},C5))},h=m=>{if(o===null)return;const p=m.relatedTarget;(p===null||!o.contains(p))&&u()};return document.addEventListener("pointerover",d,!0),document.addEventListener("pointerout",h,!0),document.addEventListener("pointerdown",u,!0),document.addEventListener("keydown",u,!0),window.addEventListener("scroll",u,!0),window.addEventListener("blur",u),()=>{u(),document.removeEventListener("pointerover",d,!0),document.removeEventListener("pointerout",h,!0),document.removeEventListener("pointerdown",u,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("scroll",u,!0),window.removeEventListener("blur",u)}},[]),v.useLayoutEffect(()=>{if(e===null||s.current===null){r(null);return}const{width:o,height:l}=s.current.getBoundingClientRect(),u=e.anchor,d=p=>Math.max(Hl,Math.min(p,window.innerHeight-l-Hl));if(e.side==="right"){r({left:u.right+sd,top:d(u.top+u.height/2-l/2),side:"right"});return}const h=u.top-sd-l<Hl+A5(),m=Math.max(Hl,Math.min(u.left+u.width/2-o/2,window.innerWidth-o-Hl));r({left:m,top:h?u.bottom+sd:u.top-sd-l,side:h?"below":"above"})},[e]),e===null?null:qa.createPortal(n.jsx("div",{ref:s,className:`app-tooltip ${(i==null?void 0:i.side)??""}`,role:"tooltip",style:i===null?{left:0,top:0,visibility:"hidden"}:{left:i.left,top:i.top},children:e.text}),document.body)}const I5={id:"chat",title:"对话",requires:["sessions","chat"],sessionViews:[{id:"chat",title:"对话",order:0,component:wS}]},T5=[],Kf=320,id=4;function Mt({value:e,options:t,onChange:s,id:i,disabled:r,placeholder:o="请选择",inline:l,className:u,...d}){const h=v.useId(),m=v.useRef(null),p=v.useRef(null),[g,x]=v.useState(!1),[N,j]=v.useState(-1),[y,k]=v.useState({}),_=t.findIndex(F=>F.value===e),S=_===-1?void 0:t[_],E=F=>t[F]!==void 0&&t[F].disabled!==!0,O=(F,L)=>{for(let A=F+L;A>=0&&A<t.length;A+=L)if(E(A))return A;return F},P=(F=_)=>{r!==!0&&(j(E(F)?F:O(-1,1)),x(!0))},H=(F=!0)=>{var L;x(!1),F&&((L=m.current)==null||L.focus())},B=F=>{E(F)&&(t[F].value!==e&&s(t[F].value),H())};v.useLayoutEffect(()=>{if(!g)return;const F=()=>{var V,U;const L=(V=m.current)==null?void 0:V.getBoundingClientRect();if(L===void 0)return;const A=window.innerHeight-L.bottom-id-8,I=L.top-id-8,z=A<Math.min(Kf,((U=p.current)==null?void 0:U.scrollHeight)??Kf)&&I>A,D=Math.max(L.width,180);k({left:Math.max(8,Math.min(L.left,window.innerWidth-D-8)),minWidth:D,maxWidth:Math.max(D,Math.min(520,window.innerWidth-16)),maxHeight:Math.min(Kf,z?I:A),...z?{bottom:window.innerHeight-L.top+id}:{top:L.bottom+id}})};return F(),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[g]),v.useEffect(()=>{var L;if(!g)return;(L=p.current)==null||L.focus({preventScroll:!0});const F=A=>{var z,D;const I=A.target;!((z=p.current)!=null&&z.contains(I))&&!((D=m.current)!=null&&D.contains(I))&&H(!1)};return document.addEventListener("pointerdown",F,!0),()=>document.removeEventListener("pointerdown",F,!0)},[g]),v.useEffect(()=>{var F,L;g&&N>=0&&((L=(F=p.current)==null?void 0:F.querySelector(`[data-index="${N}"]`))==null||L.scrollIntoView({block:"nearest"}))},[g,N]);const R=F=>{(F.key==="ArrowDown"||F.key==="ArrowUp"||F.key==="Enter"||F.key===" ")&&(F.preventDefault(),P())},M=F=>{const A={ArrowDown:()=>j(I=>O(I,1)),ArrowUp:()=>j(I=>O(I,-1)),Home:()=>j(O(-1,1)),End:()=>j(O(t.length,-1)),Enter:()=>B(N)," ":()=>B(N),Escape:()=>H(),Tab:()=>H()}[F.key];if(A!==void 0){F.key!=="Tab"&&F.preventDefault(),A();return}if(F.key.length===1&&!F.ctrlKey&&!F.metaKey&&!F.altKey){const I=F.key.toLowerCase();for(let z=1;z<=t.length;z++){const D=(N+z)%t.length;if(E(D)&&t[D].label.toLowerCase().startsWith(I)){j(D);break}}}};return n.jsxs(n.Fragment,{children:[n.jsx("button",{ref:m,id:i,type:"button",disabled:r,className:`select-trigger text-input plain ${l===!0?"inline":""} ${g?"open":""} ${u??""}`,"aria-haspopup":"listbox","aria-expanded":g,"aria-controls":g?h:void 0,"aria-label":d["aria-label"],onClick:()=>g?H():P(),onKeyDown:R,children:n.jsx("span",{className:`select-value ${S===void 0?"placeholder":""}`,children:(S==null?void 0:S.label)??o})}),g&&qa.createPortal(n.jsxs("ul",{ref:p,id:h,role:"listbox",tabIndex:-1,className:"select-list",style:y,"aria-label":d["aria-label"],"aria-activedescendant":N>=0?`${h}-${N}`:void 0,onKeyDown:M,children:[t.map((F,L)=>{var A;return n.jsxs("li",{role:"presentation",children:[F.group!==void 0&&F.group!==((A=t[L-1])==null?void 0:A.group)&&n.jsx("div",{className:"select-group",children:F.group}),n.jsxs("div",{id:`${h}-${L}`,"data-index":L,role:"option","aria-selected":L===_,"aria-disabled":F.disabled===!0,className:`select-option ${L===N?"active":""} ${L===_?"selected":""} ${F.disabled===!0?"disabled":""}`,onPointerMove:()=>{E(L)&&L!==N&&j(L)},onClick:()=>B(L),children:[n.jsxs("span",{className:"select-text",children:[n.jsx("span",{children:F.label}),F.hint!==void 0&&n.jsx("span",{className:"select-hint",children:F.hint})]}),L===_&&n.jsx(Q,{name:"check",className:"select-check"})]})]},`${F.group??""}\0${F.value}`)}),t.length===0&&n.jsx("li",{role:"presentation",className:"select-empty",children:"没有可选的"})]}),document.body)]})}const M5={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function R5({client:e}){const t=_e(e.connection.status),s=vn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(null),[u,d]=v.useState(0),[h,m]=v.useState(null),[p,g]=v.useState(null),[x,N]=v.useState(null),[j,y]=v.useState(""),[k,_]=v.useState(""),[S,E]=v.useState(""),[O,P]=v.useState(""),[H,B]=v.useState({});v.useEffect(()=>e.connection.on("notify/changed",()=>d(z=>z+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let z=!0;return e.connection.call("feishu/settings",{}).then(D=>{z&&(r(D),y(V=>V===""?D.settings.appId??"":V),E(V=>V===""?D.settings.chatId??"":V))}).catch(D=>{z&&g($e(D))}),e.connection.call("notify/status",{}).then(D=>{z&&l(D.channels.find(V=>V.id==="feishu")??null)}).catch(()=>{}),()=>{z=!1}},[e,t.state,u]);const R=async(z,D,V)=>{m(z),g(null),N(null);try{const U=await D();U!==null&&typeof U=="object"&&"settings"in U&&r(U),V!==void 0&&N(V),d(q=>q+1)}catch(U){g($e(U))}finally{m(null)}},M=()=>R("credentials",async()=>(k.trim()!==""&&await e.setCredential($R,k.trim()),_(""),e.connection.call("feishu/settings/set",{appId:j.trim()===""?null:j.trim(),enabled:!0})),"已保存,正在连接…"),F=()=>R("test",async()=>{const z=await e.connection.call("notify/test",{channel:"feishu"});if(z.failed.length>0)throw new Error(z.failed.map(D=>D.error).join(";"))},"测试消息已发送,去飞书看看"),L=i==null?void 0:i.settings,[A,I]=M5[(o==null?void 0:o.state)??"off"];return n.jsxs("div",{className:"remote-section",children:[n.jsx("p",{className:"muted",children:"脚本出问题的通知带截图和「停止 / 重试 / 忽略」按钮;agent 需要你确认的操作也会发成卡片,在飞书或这里先回答的生效。"}),n.jsxs("details",{className:"card guide",children:[n.jsx("summary",{children:n.jsx("strong",{children:"第一次使用:在飞书开放平台创建应用(约 5 分钟)"})}),n.jsxs("ol",{className:"guide-steps",children:[n.jsxs("li",{children:["打开 ",n.jsx("a",{href:"https://open.feishu.cn/app",target:"_blank",rel:"noreferrer",children:"open.feishu.cn/app"}),"(国际版 Lark 用 open.larksuite.com/app),「创建企业自建应用」。"]}),n.jsx("li",{children:"「添加应用能力」→ 添加「机器人」。"}),n.jsxs("li",{children:["「权限管理」开通:",n.jsx("code",{children:"im:message"}),"(获取与发送单聊、群组消息)、",n.jsx("code",{children:"im:message:send_as_bot"}),"、",n.jsx("code",{children:"im:message.p2p_msg:readonly"}),"(读取用户发给机器人的单聊消息)、",n.jsx("code",{children:"im:message.group_at_msg:readonly"}),"(接收群聊中 @ 机器人的消息,可选)、",n.jsx("code",{children:"im:resource"}),"(上传截图)。"]}),n.jsxs("li",{children:["「事件与回调」→「事件配置」:订阅方式选",n.jsx("strong",{children:"使用长连接接收事件"}),",添加事件 ",n.jsx("code",{children:"im.message.receive_v1"}),"(接收消息)。"]}),n.jsxs("li",{children:["「事件与回调」→「回调配置」:订阅方式同样选",n.jsx("strong",{children:"使用长连接接收回调"}),",添加回调 ",n.jsx("code",{children:"card.action.trigger"}),"(卡片回传交互)。"]}),n.jsx("li",{children:"「版本管理与发布」创建版本并发布,可用范围包含你自己。权限或事件改过以后都要重新发布才生效。"}),n.jsx("li",{children:"把「凭证与基础信息」里的 App ID 和 App Secret 填到下面;保存后在飞书里搜索机器人名字,给它发一条消息,再回到这里「允许」自己。"})]}),n.jsx("p",{className:"muted small",children:"先保存凭证再配置长连接:飞书要求应用在线时才能保存「长连接」订阅方式。"})]}),n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"连接"}),n.jsx("p",{className:"muted small",children:(o==null?void 0:o.detail)??((o==null?void 0:o.state)==="ready"?`通知会发给 ${o.recipients} 个接收方`:"…")})]}),n.jsx("span",{className:`badge ${A}`,children:I})]}),o!==null&&o.checks.length>0&&n.jsx("ul",{className:"check-list",children:o.checks.map(z=>n.jsxs("li",{className:z.ok===!0?"ok":z.ok===!1?"failed":"",children:[n.jsx("span",{className:"check-mark",children:z.ok===!0?"✓":z.ok===!1?"✗":"…"}),n.jsx("span",{children:z.label}),z.detail!==void 0&&n.jsx("span",{className:"muted small",children:z.detail})]},z.id))}),n.jsxs("div",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void R("check",()=>e.connection.call("feishu/check",{})),children:h==="check"?"检查中…":"重新检查"}),n.jsx("button",{className:"small-button",disabled:h!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void F(),children:"发送测试消息"}),L!==void 0&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:L.enabled,disabled:h!==null,onChange:z=>void R("enable",()=>e.connection.call("feishu/settings/set",{enabled:z.target.checked}))}),"启用飞书"]})]})]}),L!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"应用凭证"}),n.jsx("label",{className:"field-label",htmlFor:"feishu-domain",children:"平台"}),n.jsx(Mt,{id:"feishu-domain",value:L.domain,disabled:h!==null,onChange:z=>void R("domain",()=>e.connection.call("feishu/settings/set",{domain:z})),options:[{value:"feishu",label:"飞书",hint:"open.feishu.cn"},{value:"lark",label:"Lark 国际版",hint:"open.larksuite.com"}]}),n.jsx("label",{className:"field-label",htmlFor:"feishu-app-id",children:"App ID"}),n.jsx("input",{id:"feishu-app-id",className:"text-input",value:j,onChange:z=>y(z.target.value),placeholder:"cli_xxxxxxxx",spellCheck:!1}),n.jsxs("label",{className:"field-label",htmlFor:"feishu-secret",children:["App Secret ",(i==null?void 0:i.secretConfigured)===!0&&n.jsx("span",{className:"badge ok",children:"已保存"})]}),n.jsx("input",{id:"feishu-secret",className:"text-input",type:"password",value:k,onChange:z=>_(z.target.value),placeholder:(i==null?void 0:i.secretConfigured)===!0?"留空则保持不变":"在「凭证与基础信息」里复制",spellCheck:!1,autoComplete:"off"}),n.jsx("p",{className:"muted small",children:"App Secret 存在本机的 dsh 凭据里,不会再显示出来。"}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"primary small-button",disabled:h!==null||j.trim()==="",onClick:()=>void M(),children:h==="credentials"?"保存中…":"保存并连接"})]})]}),L!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"允许的用户"}),n.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令、按卡片上的按钮;通知也发给他们。"}),L.allowedUsers.length===0&&n.jsx("div",{className:"muted small",children:"还没有。给机器人发一条消息,它会出现在下面的「待允许」里。"}),n.jsx("ul",{className:"version-list",children:L.allowedUsers.map(z=>n.jsxs("li",{children:[n.jsx("span",{children:z.name??"(未命名)"}),n.jsx("span",{className:"muted small",children:z.openId}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void R(`rm-${z.openId}`,()=>e.connection.call("feishu/users/remove",{openId:z.openId})),children:"移除"})]},z.openId))}),((i==null?void 0:i.pending.length)??0)>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),n.jsx("ul",{className:"version-list",children:i.pending.map(z=>n.jsxs("li",{children:[n.jsx("span",{className:"muted small",children:z.openId}),n.jsxs("span",{className:"muted small",children:["「",z.text,"」 · ",vt(z.at,s)]}),n.jsx("span",{className:"spacer"}),n.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:H[z.openId]??"",onChange:D=>B(V=>({...V,[z.openId]:D.target.value}))}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void R(`dismiss-${z.openId}`,()=>e.connection.call("feishu/users/remove",{openId:z.openId})),children:"忽略"}),n.jsx("button",{className:"primary small-button",disabled:h!==null,onClick:()=>void R(`allow-${z.openId}`,()=>{var D;return e.connection.call("feishu/users/allow",{openId:z.openId,...(D=H[z.openId])!=null&&D.trim()?{name:H[z.openId].trim()}:{}})}),children:"允许"})]},z.openId))})]}),n.jsx("label",{className:"field-label",htmlFor:"feishu-manual",children:"手动添加 open_id"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:"feishu-manual",className:"text-input",value:O,onChange:z=>P(z.target.value),placeholder:"ou_xxxxxxxx",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:h!==null||O.trim()==="",onClick:()=>void R("manual",async()=>{const z=await e.connection.call("feishu/users/allow",{openId:O.trim()});return P(""),z}),children:"添加"})]})]}),L!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"通知"}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:L.otherApprovals,disabled:h!==null,onChange:z=>void R("approvals",()=>e.connection.call("feishu/settings/set",{otherApprovals:z.target.checked}))}),"软件里的会话(对话、定时运行、游戏读取)需要确认或 agent 提问时也发到飞书"]}),n.jsx("p",{className:"muted small",children:"在飞书里和 agent 的对话需要确认、或 agent 有问题问你时,只发给发消息的那个人(直接回复文字也算回答);软件里的会话默认只在界面里问。两边都能回答,先回答的生效。"}),n.jsx("label",{className:"field-label",htmlFor:"feishu-chat",children:"同时发到群(可选,填群 ID,机器人需要在群里)"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:"feishu-chat",className:"text-input",value:S,onChange:z=>E(z.target.value),placeholder:"oc_xxxxxxxx",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void R("chat",()=>e.connection.call("feishu/settings/set",{chatId:S.trim()===""?null:S.trim()})),children:"保存"})]})]}),x!==null&&n.jsxs("div",{className:"notice info left",children:[n.jsx(Q,{name:"check"}),n.jsx("span",{children:x})]}),p!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:p})]})]})}const O5={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function P5({client:e}){const t=_e(e.connection.status),s=vn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(null),[u,d]=v.useState(0),[h,m]=v.useState(null),[p,g]=v.useState(null),[x,N]=v.useState(null),[j,y]=v.useState(""),[k,_]=v.useState(""),[S,E]=v.useState(""),[O,P]=v.useState({});v.useEffect(()=>e.connection.on("notify/changed",()=>d(A=>A+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let A=!0;return e.connection.call("qqbot/settings",{}).then(I=>{A&&(r(I),y(z=>z===""?I.settings.appId??"":z))}).catch(I=>{A&&g($e(I))}),e.connection.call("notify/status",{}).then(I=>{A&&l(I.channels.find(z=>z.id==="qq")??null)}).catch(()=>{}),()=>{A=!1}},[e,t.state,u]);const H=async(A,I,z)=>{m(A),g(null),N(null);try{const D=await I();D!==null&&typeof D=="object"&&"settings"in D&&r(D),z!==void 0&&N(z),d(V=>V+1)}catch(D){g($e(D))}finally{m(null)}},B=()=>H("credentials",async()=>(k.trim()!==""&&await e.setCredential(IR,k.trim()),_(""),e.connection.call("qqbot/settings/set",{appId:j.trim()===""?null:j.trim(),enabled:!0})),"已保存,正在连接…"),R=()=>H("test",async()=>{const A=await e.connection.call("notify/test",{channel:"qq"});if(A.failed.length>0)throw new Error(A.failed.map(I=>I.error).join(";"))},"测试消息已发送,去 QQ 看看"),M=i==null?void 0:i.settings,[F,L]=O5[(o==null?void 0:o.state)??"off"];return n.jsxs("div",{className:"remote-section",children:[n.jsx("p",{className:"muted",children:"QQ 官方机器人:在 QQ 里和它单聊。消息用 markdown 显示;通知、需要你确认的操作和助手问你的问题下面有按钮,点一下就是回复,也可以直接打字。机器人没有按钮权限时会改成文字,告诉你回复什么。"}),n.jsxs("details",{className:"card guide",children:[n.jsx("summary",{children:n.jsx("strong",{children:"第一次使用:在 QQ 开放平台创建机器人(约 10 分钟)"})}),n.jsxs("ol",{className:"guide-steps",children:[n.jsxs("li",{children:["打开 ",n.jsx("a",{href:"https://bot.q.qq.com/open",target:"_blank",rel:"noreferrer",children:"QQ 开放平台"}),",用 QQ 扫码登录,创建一个机器人。"]}),n.jsxs("li",{children:["在机器人的「开发设置」里复制 ",n.jsx("strong",{children:"AppID"})," 和 ",n.jsx("strong",{children:"AppSecret"}),",填到下面。"]}),n.jsxs("li",{children:["「功能配置」里开启",n.jsx("strong",{children:"单聊"}),"(消息走 WebSocket,不用填回调地址)。还在沙箱阶段的机器人,要把自己的 QQ 加进「沙箱配置」的测试成员。"]}),n.jsx("li",{children:"保存后用手机 QQ 找到机器人(资料卡或沙箱二维码),给它发一条消息,再回到这里「允许」自己。"})]}),n.jsx("p",{className:"muted small",children:"机器人发给你的不是回复的消息(同步的对话、通知)算「主动消息」:在机器人资料卡里要开着「允许主动发送」。"})]}),n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"连接"}),n.jsx("p",{className:"muted small",children:(o==null?void 0:o.detail)??((o==null?void 0:o.state)==="ready"?`通知和对话会发给 ${o.recipients} 个人`:"…")})]}),n.jsx("span",{className:`badge ${F}`,children:L})]}),o!==null&&o.checks.length>0&&n.jsx("ul",{className:"check-list",children:o.checks.map(A=>n.jsxs("li",{className:A.ok===!0?"ok":A.ok===!1?"failed":"",children:[n.jsx("span",{className:"check-mark",children:A.ok===!0?"✓":A.ok===!1?"✗":"…"}),n.jsx("span",{children:A.label}),A.detail!==void 0&&n.jsx("span",{className:"muted small",children:A.detail})]},A.id))}),n.jsxs("div",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void H("check",()=>e.connection.call("qqbot/check",{})),children:h==="check"?"检查中…":"重新检查"}),n.jsx("button",{className:"small-button",disabled:h!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void R(),children:"发送测试消息"}),M!==void 0&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:M.enabled,disabled:h!==null,onChange:A=>void H("enable",()=>e.connection.call("qqbot/settings/set",{enabled:A.target.checked}))}),"启用 QQ 机器人"]})]})]}),M!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"机器人凭证"}),n.jsx("label",{className:"field-label",htmlFor:"qq-app-id",children:"AppID"}),n.jsx("input",{id:"qq-app-id",className:"text-input",value:j,onChange:A=>y(A.target.value),placeholder:"102xxxxxx",spellCheck:!1,inputMode:"numeric"}),n.jsxs("label",{className:"field-label",htmlFor:"qq-secret",children:["AppSecret ",(i==null?void 0:i.secretConfigured)===!0&&n.jsx("span",{className:"badge ok",children:"已保存"})]}),n.jsx("input",{id:"qq-secret",className:"text-input",type:"password",value:k,onChange:A=>_(A.target.value),placeholder:(i==null?void 0:i.secretConfigured)===!0?"留空则保持不变":"在「开发设置」里复制",spellCheck:!1,autoComplete:"off"}),n.jsx("p",{className:"muted small",children:"AppSecret 存在本机的 dsh 凭据里,不会再显示出来。"}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"primary small-button",disabled:h!==null||j.trim()==="",onClick:()=>void B(),children:h==="credentials"?"保存中…":"保存并连接"})]})]}),M!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"允许的用户"}),n.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令;通知和与助手的对话也发给他们。"}),M.allowedUsers.length===0&&n.jsx("div",{className:"muted small",children:"还没有。在 QQ 里给机器人发一条消息,它会出现在下面的「待允许」里。"}),n.jsx("ul",{className:"version-list",children:M.allowedUsers.map(A=>n.jsxs("li",{children:[n.jsx("span",{children:A.name??"(未命名)"}),n.jsx("span",{className:"muted small",children:A.openId}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void H(`rm-${A.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:A.openId})),children:"移除"})]},A.openId))}),((i==null?void 0:i.pending.length)??0)>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),n.jsx("ul",{className:"version-list",children:i.pending.map(A=>n.jsxs("li",{children:[n.jsx("span",{className:"muted small",children:A.openId}),n.jsxs("span",{className:"muted small",children:["「",A.text,"」 · ",vt(A.at,s)]}),n.jsx("span",{className:"spacer"}),n.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:O[A.openId]??"",onChange:I=>P(z=>({...z,[A.openId]:I.target.value}))}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void H(`dismiss-${A.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:A.openId})),children:"忽略"}),n.jsx("button",{className:"primary small-button",disabled:h!==null,onClick:()=>void H(`allow-${A.openId}`,()=>{var I;return e.connection.call("qqbot/users/allow",{openId:A.openId,...(I=O[A.openId])!=null&&I.trim()?{name:O[A.openId].trim()}:{}})}),children:"允许"})]},A.openId))})]}),n.jsx("label",{className:"field-label",htmlFor:"qq-manual",children:"手动添加 user_openid"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:"qq-manual",className:"text-input",value:S,onChange:A=>E(A.target.value),placeholder:"机器人回复你的那条消息里有",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:h!==null||S.trim()==="",onClick:()=>void H("manual",async()=>{const A=await e.connection.call("qqbot/users/allow",{openId:S.trim()});return E(""),A}),children:"添加"})]})]}),x!==null&&n.jsxs("div",{className:"notice info left",children:[n.jsx(Q,{name:"check"}),n.jsx("span",{children:x})]}),p!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:p})]})]})}const L5=[{id:"feishu",title:"飞书",capability:"feishu",component:R5},{id:"qq",title:"QQ 机器人",capability:"qqbot",component:P5}];function z5({client:e}){var l;const t=_e(e.capabilities),s=L5.filter(u=>t.has(u.capability)),[i,r]=v.useState(((l=s[0])==null?void 0:l.id)??"feishu"),o=s.find(u=>u.id===i)??s[0];return n.jsxs("div",{className:"settings-page",children:[n.jsx("h2",{children:"远程连接"}),n.jsx("p",{children:"不在电脑前也能用:在飞书或 QQ 里和助手说话。和助手的对话两边完全一样——在软件里说的、在聊天软件里说的、助手和其他 agent 之间的往来、助手的回复,都会同步过去;脚本出问题的通知也发到那里,在聊天软件里点按钮或直接回复就能处理。"}),s.length>1&&n.jsx("nav",{className:"agent-tabs remote-tabs",role:"tablist","aria-label":"远程连接方式",children:s.map(u=>n.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:()=>r(u.id),children:u.title},u.id))}),o===void 0?n.jsx("p",{className:"muted",children:"当前连接没有提供远程连接。"}):n.jsx(o.component,{client:e},o.id)]})}const D5=(e,t)=>{try{const s=localStorage.getItem(`adg.fold.${e}`);return s===null?t:s==="1"}catch{return t}};function F5(e,t=!0){const[s,i]=v.useState(()=>D5(e,t));return[s,()=>i(o=>{try{localStorage.setItem(`adg.fold.${e}`,o?"0":"1")}catch{}return!o})]}function U5({open:e,onToggle:t,children:s,count:i,className:r=""}){return n.jsxs("button",{type:"button",className:`fold-head ${r}`,"aria-expanded":e,onClick:t,children:[n.jsx(Q,{name:"chevron",className:`fold-chevron ${e?"open":""}`}),n.jsx("span",{className:"fold-title",children:s}),i!==void 0&&n.jsx("span",{className:"fold-count",children:i})]})}function La({id:e,title:t,count:s,initial:i=!0,children:r,className:o=""}){const[l,u]=F5(e,i);return n.jsxs("div",{className:`fold ${o}`,children:[n.jsx(U5,{open:l,onToggle:u,...s===void 0?{}:{count:s},children:t}),l&&r]})}function u1({client:e,scriptId:t,taskId:s,name:i,spec:r,value:o,onChange:l,onCreated:u,profile:d}){const[h,m]=v.useState(null),[p,g]=v.useState(null),[x,N]=v.useState(!1),j=async()=>{const k=(p==null?void 0:p.trim())??"";if(k!==""){m(null),N(!0);try{const{value:_}=await e.connection.call("runs/choices/create",{scriptId:t,taskId:s,param:i,name:k,...d===void 0?{}:{profile:d}});g(null),u==null||u(),l(_)}catch(_){m($e(_))}finally{N(!1)}}};let y;if(r.choices!==void 0){const k=r.choices.some(_=>_.value===o);y=n.jsx(Mt,{"aria-label":i,value:k?o:"",placeholder:r.choices.length===0?"本地配置里还没有,先新建或在脚本里建一个":"请选择",onChange:_=>{_==="\0new"?g(S=>S??"MultiGameAssistant"):l(_)},options:[...r.choices.map(_=>({value:_.value,label:_.label,..._.detail===void 0?{}:{hint:_.detail}})),...r.canCreate===!0?[{value:"\0new",label:"+ 新建…"}]:[]]})}else r.type==="boolean"?y=n.jsx(Mt,{"aria-label":i,value:o,onChange:l,options:[{value:"true",label:"是"},{value:"false",label:"否"}]}):r.enum!==void 0?y=n.jsx(Mt,{"aria-label":i,value:o,onChange:l,options:r.enum.map(k=>({value:String(k),label:String(k)}))}):y=n.jsx("input",{className:"text-input plain","aria-label":i,value:o,placeholder:r.default===void 0?"必填":String(r.default),inputMode:r.type==="string"?"text":"numeric",onChange:k=>l(k.target.value)});return n.jsxs("div",{className:"param-row",role:"group","aria-label":i,children:[n.jsxs("span",{className:"field-label",children:[i,r.description===void 0?"":` · ${r.description}`]}),y,p!==null&&n.jsxs("span",{className:"param-new",children:[n.jsx("input",{className:"text-input plain",autoFocus:!0,value:p,"aria-label":"新项的名字",onChange:k=>g(k.target.value),onKeyDown:k=>{k.key==="Enter"?(k.preventDefault(),j()):k.key==="Escape"&&g(null)}}),n.jsx("button",{type:"button",className:"primary small-button",disabled:x||p.trim()==="",onClick:()=>void j(),children:x?"新建中…":"新建"}),n.jsx("button",{type:"button",className:"small-button",disabled:x,onClick:()=>{g(null),m(null)},children:"取消"}),n.jsx("span",{className:"muted small",children:"复制一个现有的同类项,只存在本应用的本地配置里,原项目不变"})]}),h!==null&&n.jsx("span",{className:"error small",children:h})]})}function d1(e,t,s=!0){const i=_e(e.connection.status),[r,o]=v.useState(null);return v.useEffect(()=>{if(o(null),t===void 0||!s||i.state!=="open")return;let l=!0;e.connection.call("configs/profiles",{scriptId:t}).then(d=>{l&&o(d)},()=>{});const u=e.connection.on("configs/profiles/changed",d=>{d.scriptId===t&&o(d.list)});return()=>{l=!1,u()}},[e,t,s,i.state]),r}function h1({list:e,value:t,onChange:s,id:i,label:r="配置"}){if(e===null||e.items.length<2)return null;const o=e.items.find(u=>u.id===e.current),l=t!==void 0&&!e.items.some(u=>u.id===t);return n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:i,children:r}),n.jsx(Mt,{id:i,value:t??"",onChange:u=>s(u===""?void 0:u),options:[{value:"",label:"跟随当前使用的",hint:`现在是「${(o==null?void 0:o.name)??"默认"}」`},...e.items.map(u=>({value:u.id,label:u.name})),...l?[{value:t,label:"已删除的配置",disabled:!0}]:[]]}),l&&n.jsx("span",{className:"muted small",children:"这份配置已经删了,运行时会失败;请重新选一份。"})]})}const Nx={starting:["","启动中"],running:["","运行中"],stopping:["warn","停止中"],succeeded:["ok","成功"],failed:["warn","失败"],cancelled:["","已停止"]},B5={desktop:"占用鼠标键盘",window:"后台窗口",adb:"模拟器",none:"不占用"};function H5({client:e,scriptId:t,packId:s}){const i=_e(e.connection.status),r=vn(3e4),[o,l]=v.useState(null),[u,d]=v.useState([]),[h,m]=v.useState(""),[p,g]=v.useState({}),[x,N]=v.useState(!1),[j,y]=v.useState(null),[k,_]=v.useState(null),[S,E]=v.useState(0),O=d1(e,t,s!==void 0),[P,H]=v.useState(void 0);v.useEffect(()=>{if(i.state!=="open")return;let L=!0;return e.connection.call("runs/tasks",{scriptId:t,...P===void 0?{}:{profile:P}}).then(A=>{L&&(l(A),m(I=>{var z;return I===""?((z=A.tasks[0])==null?void 0:z.id)??"":I}))}).catch(A=>{L&&y($e(A))}),e.connection.call("runs/list",{scriptId:t}).then(A=>{L&&d(A.items)}).catch(()=>{}),()=>{L=!1}},[e,t,s,i.state,S,P,O==null?void 0:O.current]),v.useEffect(()=>e.connection.on("runs/state",L=>{L.scriptId===t&&d(A=>[L,...A.filter(I=>I.id!==L.id)].sort((I,z)=>z.startedAt-I.startedAt))}),[e,t]);const B=o==null?void 0:o.tasks.find(L=>L.id===h);v.useEffect(()=>{B!==void 0&&g(Object.fromEntries(Object.entries(B.params).map(([L,A])=>{var I;return[L,A.default!==void 0?String(A.default):((I=A.choices)==null?void 0:I.length)===1?A.choices[0].value:""]})))},[B==null?void 0:B.id]);const R=u.find(L=>L.endedAt===void 0),M=u.find(L=>{var A;return L.id===(k??(R==null?void 0:R.id)??((A=u[0])==null?void 0:A.id))}),F=async()=>{if(B!==void 0){N(!0),y(null);try{const L={};for(const[I,z]of Object.entries(B.params)){const D=p[I]??"";D!==""&&(L[I]=z.type==="boolean"?D==="true":z.type==="integer"||z.type==="number"?Number(D):D)}const A=await e.connection.call("runs/start",{scriptId:t,taskId:B.id,params:L,...P===void 0?{}:{profile:P}});_(A.id),A.state==="failed"&&y(A.outcome??"运行失败")}catch(L){y($e(L))}finally{N(!1)}}};return n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:"任务"}),n.jsx("p",{className:"muted small",children:"按脚本包运行,使用本地配置;原项目的配置在运行结束后会还原。"})]})}),o===null&&j===null&&n.jsx("div",{className:"muted small",children:"加载中…"}),o!==null&&!o.runnable&&n.jsx("div",{className:"notice info left small",children:o.problem}),o!==null&&o.tasks.length>0&&n.jsxs("div",{className:"run-form",children:[n.jsx("label",{className:"field-label",htmlFor:"task-select",children:"任务"}),n.jsx(Mt,{id:"task-select",value:h,onChange:m,options:o.tasks.map(L=>({value:L.id,label:L.title,hint:L.id}))}),B!==void 0&&n.jsxs("div",{className:"task-facts muted small",children:[n.jsx("span",{className:"badge",children:B5[B.input]}),B.account!==void 0&&n.jsxs("span",{className:"badge",children:["账号 ",B.account]}),B.expectedDuration!==void 0&&n.jsxs("span",{children:["约 ",B.expectedDuration]}),B.description!==void 0&&n.jsx("span",{children:B.description})]}),n.jsx(h1,{id:"run-profile",list:O,value:P,onChange:H}),B!==void 0&&Object.entries(B.params).map(([L,A])=>n.jsx(u1,{client:e,scriptId:t,taskId:B.id,name:L,spec:A,profile:P,value:p[L]??"",onChange:I=>g(z=>({...z,[L]:I})),onCreated:()=>E(I=>I+1)},L)),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),R!==void 0&&n.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:R.id}).catch(L=>y($e(L))),children:"停止当前运行"}),n.jsxs("button",{className:"primary small-button",disabled:x||!o.runnable||R!==void 0,onClick:()=>void F(),children:[n.jsx(Q,{name:"arrow"}),x?"启动中…":"运行"]})]})]}),j!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:j})]}),u.length>0&&n.jsxs(La,{id:"scripts.recent-runs",title:"最近运行",count:Math.min(u.length,6),className:"run-history",children:[u.slice(0,6).map(L=>{const[A,I]=Nx[L.state];return n.jsxs("button",{className:`run-row ${L.id===(M==null?void 0:M.id)?"active":""}`,"aria-expanded":L.id===(M==null?void 0:M.id),onClick:()=>_(z=>z===L.id||z===null&&L.id===(M==null?void 0:M.id)?"":L.id),children:[n.jsx("span",{className:`badge ${A}`,children:I}),n.jsxs("span",{className:"run-title",children:[L.taskTitle,L.profileName!==void 0&&((O==null?void 0:O.items.length)??0)>1&&n.jsxs("span",{className:"muted small",children:[" · ",L.profileName]})]}),n.jsx("span",{className:"muted small run-outcome",children:L.outcome??L.resources.join(" · ")}),n.jsx("span",{className:"session-time",children:vt(L.startedAt,r)})]},L.id)}),M!==void 0&&n.jsx(m1,{client:e,run:M},M.id)]})]})}function m1({client:e,run:t}){const[s,i]=v.useState([]),r=v.useRef(null);v.useEffect(()=>{let h=!0;e.connection.call("runs/logs",{runId:t.id,limit:500}).then(p=>{h&&i(p.lines)}).catch(()=>{});const m=e.connection.on("runs/log",p=>{p.runId===t.id&&i(g=>[...g,...p.lines].slice(-1e3))});return()=>{h=!1,m()}},[e,t.id]),v.useEffect(()=>{const h=r.current;h!==null&&(h.scrollTop=h.scrollHeight)},[s.length]);const o=v.useMemo(()=>t.warnings,[t.warnings]),[l,u]=v.useState(null),d=async()=>{let h=s;try{h=(await e.connection.call("runs/logs",{runId:t.id,limit:2e3})).lines}catch{}const m=[`${t.scriptName} · ${t.taskTitle}(${t.id})${t.outcome===void 0?"":` — ${t.outcome}`}`,...h.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(`
|
|
221
|
-
`),p=await Z5(m);u(p?`已复制 ${h.length} 行`:"复制失败"),setTimeout(()=>u(null),1800)};return n.jsxs("div",{className:"run-log-wrap",children:[o.map(h=>n.jsxs("div",{className:"notice info left small",children:[n.jsx(Q,{name:"info"}),n.jsx("span",{children:h})]},h)),n.jsxs("div",{className:"run-log-bar",children:[n.jsxs("span",{className:"muted small",children:[s.length," 行",s.length>=1e3?"(只显示最近的)":""]}),n.jsx("span",{className:"spacer"}),n.jsxs("button",{type:"button",className:"small-button",disabled:s.length===0,onClick:()=>void d(),title:"复制整次运行的日志(最多 2000 行),方便发给别人或 agent",children:[n.jsx(Q,{name:"copy"}),l??"复制日志"]})]}),n.jsxs("div",{className:"run-log",ref:r,role:"log","aria-label":"运行日志",children:[s.length===0&&n.jsx("div",{className:"muted small",children:"还没有日志"}),s.map((h,m)=>n.jsxs("div",{className:`log-line ${h.level===void 0?"":`lv-${h.level}`} ${h.source==="adg"?"adg":""}`,children:[n.jsx("span",{className:"log-time",children:new Date(h.at).toLocaleTimeString()}),n.jsx("span",{className:"log-source",children:h.source==="adg"?"平台":h.source}),n.jsx("span",{className:"log-text",children:h.text})]},m))]})]})}async function Z5(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 f1=v.createContext({byIncident:new Map,openSession:()=>{}}),W5={running:"agent 正在处理",resolved:"agent 已处理",retried:"agent 处理后重新运行","gave-up":"agent 处理不了","taken-over":"你接管了",timeout:"agent 超时",failed:"agent 没能开始"},V5={error:"出错",warning:"警告",failed:"失败",stalled:"卡住",overtime:"超时"};function q5({client:e,openSettings:t,openSession:s}){const i=_e(e.connection.status),r=vn(3e4),[o,l]=v.useState([]),[u,d]=v.useState([]),[h,m]=v.useState(null),[p,g]=v.useState(!1),[x,N]=v.useState(null),[j,y]=v.useState([]),k=_e(e.capabilities);v.useEffect(()=>{if(i.state!=="open"||!k.has("intervene"))return;let R=!0;return e.connection.call("intervene/list",{limit:100}).then(M=>{R&&y(M.items)}).catch(()=>{}),()=>{R=!1}},[e,i.state,k]),v.useEffect(()=>e.connection.on("intervene/changed",R=>{y(M=>[R,...M.filter(F=>F.id!==R.id)])}),[e]);const _=v.useMemo(()=>{const R=new Map;for(const M of[...j].sort((F,L)=>F.startedAt-L.startedAt))M.incidentId!==void 0&&R.set(M.incidentId,M);return{byIncident:R,openSession:s}},[j,s]);v.useEffect(()=>{if(i.state!=="open")return;let R=!0;return e.connection.call("runs/list",{}).then(M=>{R&&l(M.items)}).catch(M=>{R&&N($e(M))}),e.connection.call("monitor/incidents",{status:"all",limit:200}).then(M=>{R&&d(M.items)}).catch(()=>{}),()=>{R=!1}},[e,i.state]),v.useEffect(()=>e.connection.on("runs/state",R=>{l(M=>[R,...M.filter(F=>F.id!==R.id)].sort((F,L)=>L.startedAt-F.startedAt))}),[e]),v.useEffect(()=>e.connection.on("monitor/incident",R=>{d(M=>[R,...M.filter(F=>F.id!==R.id)].sort((F,L)=>L.createdAt-F.createdAt))}),[e]);const S=o.filter(R=>R.endedAt===void 0),E=o.filter(R=>R.endedAt!==void 0).slice(0,30),O=u.filter(R=>R.status==="open"),P=o.find(R=>{var M,F;return R.id===(h??((M=S[0])==null?void 0:M.id)??((F=o[0])==null?void 0:F.id))}),H=v.useMemo(()=>{const R=new Map;for(const M of O)R.set(M.runId,(R.get(M.runId)??0)+1);return R},[O]),B=R=>{const[M,F]=Nx[R.state],L=H.get(R.id)??0;return n.jsxs("button",{className:`script-row ${R.id===(P==null?void 0:P.id)?"active":""}`,onClick:()=>m(R.id),children:[n.jsxs("span",{className:"script-row-main",children:[n.jsxs("span",{className:"script-row-name",children:[R.scriptName," · ",R.taskTitle]}),n.jsxs("span",{className:"muted small",children:[R.kind==="settings"?"设置会话 · ":"",vt(R.startedAt,r),R.retryOf===void 0?"":" · 重新运行"]})]}),L>0?n.jsxs("span",{className:"badge warn",children:["异常 ",L]}):n.jsx("span",{className:`badge ${M}`,children:F})]},R.id)};return n.jsx(f1.Provider,{value:_,children:n.jsxs("section",{className:"main scripts-page",children:[n.jsxs("header",{className:"page-header",children:[n.jsxs("div",{className:"breadcrumb",children:[n.jsx("span",{children:"运行"}),n.jsx("span",{className:"breadcrumb-divider",children:"/"}),n.jsx("h1",{children:"运行监控"})]}),n.jsxs("div",{className:"page-actions",children:[n.jsxs("button",{className:"small-button",onClick:()=>t("feishu"),children:[n.jsx(Q,{name:"plug"}),"消息通知"]}),n.jsxs("button",{className:`small-button ${p?"primary":""}`,onClick:()=>g(R=>!R),children:[n.jsx(Q,{name:"settings"}),"监控设置"]})]})]}),n.jsxs("div",{className:"scripts-body",children:[n.jsxs("aside",{className:"scripts-list","aria-label":"运行列表",children:[x!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:x})]}),n.jsxs(La,{id:"monitor.active",title:"正在运行",count:S.length,className:"list-fold",children:[S.length===0&&n.jsx("div",{className:"muted small pad",children:"没有正在运行的任务"}),S.map(B)]}),E.length>0&&n.jsx(La,{id:"monitor.recent",title:"最近",count:E.length,className:"list-fold",children:E.map(B)})]}),n.jsx("div",{className:"scripts-detail",children:n.jsxs("div",{className:"script-detail",children:[p&&n.jsx(K5,{client:e}),O.length>0&&n.jsx("section",{className:"card",children:n.jsxs(La,{id:"monitor.open-incidents",title:n.jsxs("h3",{children:["待处理的异常(",O.length,")"]}),className:"card-fold",children:[n.jsx("p",{className:"muted small",children:"脚本包里写了自动处理的(如重连模拟器、重新运行)会先自动处理;处理不了的才推送到飞书。"}),n.jsx("div",{className:"incident-list",children:O.map(R=>n.jsx(p1,{client:e,incident:R,now:r,onOpen:()=>m(R.runId)},R.id))})]})}),P===void 0&&O.length===0&&n.jsxs("div",{className:"empty",children:[n.jsx(Q,{name:"monitor"}),n.jsx("p",{children:"还没有运行记录。在「脚本」页运行一个任务,或对 agent 说「跑一下方舟日常」。"})]}),P!==void 0&&n.jsx(G5,{client:e,run:P,incidents:u.filter(R=>R.runId===P.id),now:r,openRun:m})]})})]})]})})}function G5({client:e,run:t,incidents:s,now:i,openRun:r}){const[o,l]=Nx[t.state],[u,d]=v.useState(null);return n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsxs("h3",{children:[t.scriptName," · ",t.taskTitle]}),n.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(" · ")}`:""]})]}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:`badge ${o}`,children:l}),t.endedAt===void 0&&n.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:t.id}).catch(h=>d($e(h))),children:"停止"})]})]}),t.outcome!==void 0&&n.jsxs("div",{className:"muted small",children:["结果:",t.outcome]}),t.retryOf!==void 0&&n.jsxs("button",{className:"link-button small",onClick:()=>r(t.retryOf),children:["这是 ",t.retryOf," 的重新运行"]}),u!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:u})]}),n.jsx(La,{id:"monitor.run-log",title:"日志",children:n.jsx(m1,{client:e,run:t},t.id)}),s.length>0&&n.jsx(La,{id:"monitor.run-incidents",title:"这次运行的异常",count:s.length,children:n.jsx("div",{className:"incident-list",children:s.map(h=>n.jsx(p1,{client:e,incident:h,now:i},h.id))})})]})}function p1({client:e,incident:t,now:s,onOpen:i}){const{byIncident:r,openSession:o}=v.useContext(f1),l=r.get(t.id),[u,d]=v.useState(!1),[h,m]=v.useState(null),[p,g]=v.useState(null),x=async()=>{if(l!==void 0){d(!0),m(null);try{await e.connection.call("intervene/takeover",{id:l.id})}catch(y){m($e(y))}finally{d(!1)}}},N=async y=>{d(!0),m(null);try{await e.connection.call("monitor/act",{incidentId:t.id,action:y})}catch(k){m($e(k))}finally{d(!1)}},j=async()=>{if(p!==null)return g(null);try{const y=await e.connection.call("monitor/screenshot",{incidentId:t.id});g(`data:${y.mime};base64,${y.data}`)}catch(y){m($e(y))}};return n.jsxs("div",{className:`incident ${t.severity} ${t.status}`,children:[n.jsxs("div",{className:"incident-head",children:[n.jsx("span",{className:`badge ${t.severity==="error"?"warn":""}`,children:V5[t.kind]}),i===void 0?n.jsx("span",{className:"incident-title",children:t.title}):n.jsx("button",{className:"link-button incident-title",onClick:i,children:t.title}),n.jsx("span",{className:"session-time",children:vt(t.createdAt,s)})]}),n.jsx("div",{className:"incident-detail",children:t.detail}),t.steps.length>0&&n.jsx("ul",{className:"incident-steps",children:t.steps.filter(y=>(l==null?void 0:l.summary)===void 0||l.state==="running"||!y.detail.endsWith(l.summary)).map((y,k)=>n.jsxs("li",{className:y.ok?"ok":"failed",children:[y.ok?"✓":"✗"," ",y.detail]},k))}),t.status==="resolved"&&n.jsxs("div",{className:"muted small",children:["已处理:",t.resolution]}),l!==void 0&&n.jsxs("div",{className:`agent-line ${l.state}`,children:[n.jsxs("span",{className:"badge",children:[W5[l.state],l.mode==="diagnose"?"(只诊断)":""]}),l.summary!==void 0&&n.jsx("span",{className:"small",children:l.summary}),l.paused&&n.jsx("span",{className:"badge warn",children:"脚本暂停中"}),n.jsx("span",{className:"spacer"}),l.sessionId!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>o(l.sessionId),children:"看 agent 的处理过程"}),l.state==="running"&&n.jsx("button",{className:"small-button",disabled:u,onClick:()=>void x(),children:"我来接管"})]}),t.status==="open"&&n.jsxs("div",{className:"key-actions",children:[t.screenshot&&n.jsxs("button",{className:"small-button",onClick:()=>void j(),children:[n.jsx(Q,{name:"image"}),p===null?"截图":"收起截图"]}),n.jsx("span",{className:"spacer"}),(l==null?void 0:l.paused)===!0&&n.jsx("button",{className:"primary small-button",disabled:u,onClick:()=>void N("resume"),children:"继续"}),n.jsx("button",{className:"danger-outline small-button",disabled:u,onClick:()=>void N("stop"),children:"停止"}),n.jsx("button",{className:"small-button",disabled:u,onClick:()=>void N("retry"),children:"重试"}),n.jsx("button",{className:"small-button",disabled:u,onClick:()=>void N("resolve"),children:"忽略"})]}),p!==null&&n.jsx("img",{className:"incident-shot",src:p,alt:"异常时的截图"}),h!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:h})]})]})}function K5({client:e}){var d;const[t,s]=v.useState(null),[i,r]=v.useState(null);v.useEffect(()=>{e.connection.call("monitor/settings",{}).then(s).catch(h=>r($e(h)))},[e]);const o=h=>e.connection.call("monitor/settings/set",h).then(s).catch(m=>r($e(m))),l=((d=ah(e).data)==null?void 0:d.scripts)??[],u=Object.entries((t==null?void 0:t.scriptStall)??{}).sort(([h],[m])=>h.localeCompare(m));return n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"监控设置"}),t!==null&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:"stall-seconds",children:"多少秒没有新日志算卡住、交给干预(默认值;0 = 不检测)"}),n.jsx("input",{id:"stall-seconds",className:"text-input plain",type:"number",min:0,max:86400,defaultValue:t.defaultStallSeconds,onBlur:h=>void o({defaultStallSeconds:Math.max(0,Math.min(86400,Math.round(Number(h.target.value)||0)))})}),n.jsx("p",{className:"muted small",children:"每个脚本会从自己跑成功的记录里学:卡住时间取最近几次里最长安静时间的 1.5 倍(不低于上面的默认值);agent 看过日志节奏后也会替它调。"}),u.length>0&&n.jsx("ul",{className:"stall-list",children:u.map(([h,m])=>{var p;return n.jsxs("li",{children:[n.jsx("span",{children:((p=l.find(g=>g.id===h))==null?void 0:p.name)??h}),n.jsxs("span",{className:"muted small",children:[m.seconds," 秒 · ",m.by==="learned"?"学到的":m.by==="agent"?"agent 设的":"你设的",m.note===void 0?"":`:${m.note}`]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"link-button small",onClick:()=>{const{[h]:g,...x}=t.scriptStall;o({scriptStall:x})},children:"恢复自动"})]},h)})}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:t.screenshot,onChange:h=>void o({screenshot:h.target.checked})}),"出错时截图(模拟器画面或桌面)并随通知发送"]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:t.notifyWarnings,onChange:h=>void o({notifyWarnings:h.target.checked})}),"警告也推送(默认只推送出错、失败、卡住)"]}),n.jsx("label",{className:"field-label",htmlFor:"intervene-mode",children:"自动处理解决不了的问题,先交给 agent(需要能看图的模型)"}),n.jsx(Mt,{id:"intervene-mode",value:t.intervene,onChange:h=>void o({intervene:h}),options:[{value:"act",label:"诊断并处理(推荐)",hint:"暂停脚本,agent 看屏幕、点击和输入来解决"},{value:"diagnose",label:"只诊断",hint:"agent 看截图说明原因,由你决定"},{value:"off",label:"关闭",hint:"直接通知我"}]}),n.jsx("label",{className:"field-label",htmlFor:"intervene-cap",children:"每天最多交给 agent 几次(控制模型费用)"}),n.jsx("input",{id:"intervene-cap",className:"text-input plain",type:"number",min:0,max:200,defaultValue:t.interventionsPerDay,onBlur:h=>void o({interventionsPerDay:Math.max(0,Math.min(200,Math.round(Number(h.target.value)||0)))})})]}),i!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:i})]})]})}const Y5={id:"runs",title:"运行监控",milestone:"M3",requires:["runs","monitor"],pages:[{id:"runs",title:"运行",icon:"monitor",order:30,agent:"intervene",component:q5}]},X5={id:"feishu",title:"远程连接",milestone:"M3",requires:["notify","credentials"],settingsPages:[{id:"feishu",title:"远程连接",order:12,component:z5}]};function _n(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let s=0,i;s<e.length;s++)(i=_n(e[s]))!==""&&(t+=(t&&" ")+i);else for(let s in e)e[s]&&(t+=(t&&" ")+s);return t}var Q5={value:()=>{}};function fh(){for(var e=0,t=arguments.length,s={},i;e<t;++e){if(!(i=arguments[e]+"")||i in s||/[\s.]/.test(i))throw new Error("illegal type: "+i);s[i]=[]}return new jd(s)}function jd(e){this._=e}function J5(e,t){return e.trim().split(/^|\s+/).map(function(s){var i="",r=s.indexOf(".");if(r>=0&&(i=s.slice(r+1),s=s.slice(0,r)),s&&!t.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:i}})}jd.prototype=fh.prototype={constructor:jd,on:function(e,t){var s=this._,i=J5(e+"",s),r,o=-1,l=i.length;if(arguments.length<2){for(;++o<l;)if((r=(e=i[o]).type)&&(r=e4(s[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<l;)if(r=(e=i[o]).type)s[r]=Ik(s[r],e.name,t);else if(t==null)for(r in s)s[r]=Ik(s[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var s in t)e[s]=t[s].slice();return new jd(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var s=new Array(r),i=0,r,o;i<r;++i)s[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],i=0,r=o.length;i<r;++i)o[i].value.apply(t,s)},apply:function(e,t,s){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,s)}};function e4(e,t){for(var s=0,i=e.length,r;s<i;++s)if((r=e[s]).name===t)return r.value}function Ik(e,t,s){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=Q5,e=e.slice(0,i).concat(e.slice(i+1));break}return s!=null&&e.push({name:t,value:s}),e}var ag="http://www.w3.org/1999/xhtml";const Tk={svg:"http://www.w3.org/2000/svg",xhtml:ag,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ph(e){var t=e+="",s=t.indexOf(":");return s>=0&&(t=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),Tk.hasOwnProperty(t)?{space:Tk[t],local:e}:e}function t4(e){return function(){var t=this.ownerDocument,s=this.namespaceURI;return s===ag&&t.documentElement.namespaceURI===ag?t.createElement(e):t.createElementNS(s,e)}}function n4(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function g1(e){var t=ph(e);return(t.local?n4:t4)(t)}function s4(){}function wx(e){return e==null?s4:function(){return this.querySelector(e)}}function i4(e){typeof e!="function"&&(e=wx(e));for(var t=this._groups,s=t.length,i=new Array(s),r=0;r<s;++r)for(var o=t[r],l=o.length,u=i[r]=new Array(l),d,h,m=0;m<l;++m)(d=o[m])&&(h=e.call(d,d.__data__,m,o))&&("__data__"in d&&(h.__data__=d.__data__),u[m]=h);return new qs(i,this._parents)}function r4(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function a4(){return[]}function x1(e){return e==null?a4:function(){return this.querySelectorAll(e)}}function o4(e){return function(){return r4(e.apply(this,arguments))}}function l4(e){typeof e=="function"?e=o4(e):e=x1(e);for(var t=this._groups,s=t.length,i=[],r=[],o=0;o<s;++o)for(var l=t[o],u=l.length,d,h=0;h<u;++h)(d=l[h])&&(i.push(e.call(d,d.__data__,h,l)),r.push(d));return new qs(i,r)}function v1(e){return function(){return this.matches(e)}}function y1(e){return function(t){return t.matches(e)}}var c4=Array.prototype.find;function u4(e){return function(){return c4.call(this.children,e)}}function d4(){return this.firstElementChild}function h4(e){return this.select(e==null?d4:u4(typeof e=="function"?e:y1(e)))}var m4=Array.prototype.filter;function f4(){return Array.from(this.children)}function p4(e){return function(){return m4.call(this.children,e)}}function g4(e){return this.selectAll(e==null?f4:p4(typeof e=="function"?e:y1(e)))}function x4(e){typeof e!="function"&&(e=v1(e));for(var t=this._groups,s=t.length,i=new Array(s),r=0;r<s;++r)for(var o=t[r],l=o.length,u=i[r]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new qs(i,this._parents)}function b1(e){return new Array(e.length)}function v4(){return new qs(this._enter||this._groups.map(b1),this._parents)}function Fd(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Fd.prototype={constructor:Fd,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 y4(e){return function(){return e}}function b4(e,t,s,i,r,o){for(var l=0,u,d=t.length,h=o.length;l<h;++l)(u=t[l])?(u.__data__=o[l],i[l]=u):s[l]=new Fd(e,o[l]);for(;l<d;++l)(u=t[l])&&(r[l]=u)}function k4(e,t,s,i,r,o,l){var u,d,h=new Map,m=t.length,p=o.length,g=new Array(m),x;for(u=0;u<m;++u)(d=t[u])&&(g[u]=x=l.call(d,d.__data__,u,t)+"",h.has(x)?r[u]=d:h.set(x,d));for(u=0;u<p;++u)x=l.call(e,o[u],u,o)+"",(d=h.get(x))?(i[u]=d,d.__data__=o[u],h.delete(x)):s[u]=new Fd(e,o[u]);for(u=0;u<m;++u)(d=t[u])&&h.get(g[u])===d&&(r[u]=d)}function j4(e){return e.__data__}function N4(e,t){if(!arguments.length)return Array.from(this,j4);var s=t?k4:b4,i=this._parents,r=this._groups;typeof e!="function"&&(e=y4(e));for(var o=r.length,l=new Array(o),u=new Array(o),d=new Array(o),h=0;h<o;++h){var m=i[h],p=r[h],g=p.length,x=w4(e.call(m,m&&m.__data__,h,i)),N=x.length,j=u[h]=new Array(N),y=l[h]=new Array(N),k=d[h]=new Array(g);s(m,p,j,y,k,x,t);for(var _=0,S=0,E,O;_<N;++_)if(E=j[_]){for(_>=S&&(S=_+1);!(O=y[S])&&++S<N;);E._next=O||null}}return l=new qs(l,i),l._enter=u,l._exit=d,l}function w4(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function S4(){return new qs(this._exit||this._groups.map(b1),this._parents)}function _4(e,t,s){var i=this.enter(),r=this,o=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),s==null?o.remove():s(o),i&&r?i.merge(r).order():r}function E4(e){for(var t=e.selection?e.selection():e,s=this._groups,i=t._groups,r=s.length,o=i.length,l=Math.min(r,o),u=new Array(r),d=0;d<l;++d)for(var h=s[d],m=i[d],p=h.length,g=u[d]=new Array(p),x,N=0;N<p;++N)(x=h[N]||m[N])&&(g[N]=x);for(;d<r;++d)u[d]=s[d];return new qs(u,this._parents)}function C4(){for(var e=this._groups,t=-1,s=e.length;++t<s;)for(var i=e[t],r=i.length-1,o=i[r],l;--r>=0;)(l=i[r])&&(o&&l.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(l,o),o=l);return this}function A4(e){e||(e=$4);function t(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var s=this._groups,i=s.length,r=new Array(i),o=0;o<i;++o){for(var l=s[o],u=l.length,d=r[o]=new Array(u),h,m=0;m<u;++m)(h=l[m])&&(d[m]=h);d.sort(t)}return new qs(r,this._parents).order()}function $4(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function I4(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function T4(){return Array.from(this)}function M4(){for(var e=this._groups,t=0,s=e.length;t<s;++t)for(var i=e[t],r=0,o=i.length;r<o;++r){var l=i[r];if(l)return l}return null}function R4(){let e=0;for(const t of this)++e;return e}function O4(){return!this.node()}function P4(e){for(var t=this._groups,s=0,i=t.length;s<i;++s)for(var r=t[s],o=0,l=r.length,u;o<l;++o)(u=r[o])&&e.call(u,u.__data__,o,r);return this}function L4(e){return function(){this.removeAttribute(e)}}function z4(e){return function(){this.removeAttributeNS(e.space,e.local)}}function D4(e,t){return function(){this.setAttribute(e,t)}}function F4(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function U4(e,t){return function(){var s=t.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function B4(e,t){return function(){var s=t.apply(this,arguments);s==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,s)}}function H4(e,t){var s=ph(e);if(arguments.length<2){var i=this.node();return s.local?i.getAttributeNS(s.space,s.local):i.getAttribute(s)}return this.each((t==null?s.local?z4:L4:typeof t=="function"?s.local?B4:U4:s.local?F4:D4)(s,t))}function k1(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Z4(e){return function(){this.style.removeProperty(e)}}function W4(e,t,s){return function(){this.style.setProperty(e,t,s)}}function V4(e,t,s){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,s)}}function q4(e,t,s){return arguments.length>1?this.each((t==null?Z4:typeof t=="function"?V4:W4)(e,t,s??"")):Yo(this.node(),e)}function Yo(e,t){return e.style.getPropertyValue(t)||k1(e).getComputedStyle(e,null).getPropertyValue(t)}function G4(e){return function(){delete this[e]}}function K4(e,t){return function(){this[e]=t}}function Y4(e,t){return function(){var s=t.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function X4(e,t){return arguments.length>1?this.each((t==null?G4:typeof t=="function"?Y4:K4)(e,t)):this.node()[e]}function j1(e){return e.trim().split(/^|\s+/)}function Sx(e){return e.classList||new N1(e)}function N1(e){this._node=e,this._names=j1(e.getAttribute("class")||"")}N1.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 w1(e,t){for(var s=Sx(e),i=-1,r=t.length;++i<r;)s.add(t[i])}function S1(e,t){for(var s=Sx(e),i=-1,r=t.length;++i<r;)s.remove(t[i])}function Q4(e){return function(){w1(this,e)}}function J4(e){return function(){S1(this,e)}}function eF(e,t){return function(){(t.apply(this,arguments)?w1:S1)(this,e)}}function tF(e,t){var s=j1(e+"");if(arguments.length<2){for(var i=Sx(this.node()),r=-1,o=s.length;++r<o;)if(!i.contains(s[r]))return!1;return!0}return this.each((typeof t=="function"?eF:t?Q4:J4)(s,t))}function nF(){this.textContent=""}function sF(e){return function(){this.textContent=e}}function iF(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function rF(e){return arguments.length?this.each(e==null?nF:(typeof e=="function"?iF:sF)(e)):this.node().textContent}function aF(){this.innerHTML=""}function oF(e){return function(){this.innerHTML=e}}function lF(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function cF(e){return arguments.length?this.each(e==null?aF:(typeof e=="function"?lF:oF)(e)):this.node().innerHTML}function uF(){this.nextSibling&&this.parentNode.appendChild(this)}function dF(){return this.each(uF)}function hF(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function mF(){return this.each(hF)}function fF(e){var t=typeof e=="function"?e:g1(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function pF(){return null}function gF(e,t){var s=typeof e=="function"?e:g1(e),i=t==null?pF:typeof t=="function"?t:wx(t);return this.select(function(){return this.insertBefore(s.apply(this,arguments),i.apply(this,arguments)||null)})}function xF(){var e=this.parentNode;e&&e.removeChild(this)}function vF(){return this.each(xF)}function yF(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function bF(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function kF(e){return this.select(e?bF:yF)}function jF(e){return arguments.length?this.property("__data__",e):this.node().__data__}function NF(e){return function(t){e.call(this,t,this.__data__)}}function wF(e){return e.trim().split(/^|\s+/).map(function(t){var s="",i=t.indexOf(".");return i>=0&&(s=t.slice(i+1),t=t.slice(0,i)),{type:t,name:s}})}function SF(e){return function(){var t=this.__on;if(t){for(var s=0,i=-1,r=t.length,o;s<r;++s)o=t[s],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++i]=o;++i?t.length=i:delete this.__on}}}function _F(e,t,s){return function(){var i=this.__on,r,o=NF(t);if(i){for(var l=0,u=i.length;l<u;++l)if((r=i[l]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=s),r.value=t;return}}this.addEventListener(e.type,o,s),r={type:e.type,name:e.name,value:t,listener:o,options:s},i?i.push(r):this.__on=[r]}}function EF(e,t,s){var i=wF(e+""),r,o=i.length,l;if(arguments.length<2){var u=this.node().__on;if(u){for(var d=0,h=u.length,m;d<h;++d)for(r=0,m=u[d];r<o;++r)if((l=i[r]).type===m.type&&l.name===m.name)return m.value}return}for(u=t?_F:SF,r=0;r<o;++r)this.each(u(i[r],t,s));return this}function _1(e,t,s){var i=k1(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,s):(r=i.document.createEvent("Event"),s?(r.initEvent(t,s.bubbles,s.cancelable),r.detail=s.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function CF(e,t){return function(){return _1(this,e,t)}}function AF(e,t){return function(){return _1(this,e,t.apply(this,arguments))}}function $F(e,t){return this.each((typeof t=="function"?AF:CF)(e,t))}function*IF(){for(var e=this._groups,t=0,s=e.length;t<s;++t)for(var i=e[t],r=0,o=i.length,l;r<o;++r)(l=i[r])&&(yield l)}var E1=[null];function qs(e,t){this._groups=e,this._parents=t}function Wc(){return new qs([[document.documentElement]],E1)}function TF(){return this}qs.prototype=Wc.prototype={constructor:qs,select:i4,selectAll:l4,selectChild:h4,selectChildren:g4,filter:x4,data:N4,enter:v4,exit:S4,join:_4,merge:E4,selection:TF,order:C4,sort:A4,call:I4,nodes:T4,node:M4,size:R4,empty:O4,each:P4,attr:H4,style:q4,property:X4,classed:tF,text:rF,html:cF,raise:dF,lower:mF,append:fF,insert:gF,remove:vF,clone:kF,datum:jF,on:EF,dispatch:$F,[Symbol.iterator]:IF};function Bs(e){return typeof e=="string"?new qs([[document.querySelector(e)]],[document.documentElement]):new qs([[e]],E1)}function MF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ji(e,t){if(e=MF(e),t===void 0&&(t=e.currentTarget),t){var s=t.ownerSVGElement||t;if(s.createSVGPoint){var i=s.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const RF={passive:!1},Sc={capture:!0,passive:!1};function Yf(e){e.stopImmediatePropagation()}function Ro(e){e.preventDefault(),e.stopImmediatePropagation()}function C1(e){var t=e.document.documentElement,s=Bs(e).on("dragstart.drag",Ro,Sc);"onselectstart"in t?s.on("selectstart.drag",Ro,Sc):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function A1(e,t){var s=e.document.documentElement,i=Bs(e).on("dragstart.drag",null);t&&(i.on("click.drag",Ro,Sc),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in s?i.on("selectstart.drag",null):(s.style.MozUserSelect=s.__noselect,delete s.__noselect)}const rd=e=>()=>e;function og(e,{sourceEvent:t,subject:s,target:i,identifier:r,active:o,x:l,y:u,dx:d,dy:h,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:m}})}og.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function OF(e){return!e.ctrlKey&&!e.button}function PF(){return this.parentNode}function LF(e,t){return t??{x:e.x,y:e.y}}function zF(){return navigator.maxTouchPoints||"ontouchstart"in this}function $1(){var e=OF,t=PF,s=LF,i=zF,r={},o=fh("start","drag","end"),l=0,u,d,h,m,p=0;function g(E){E.on("mousedown.drag",x).filter(i).on("touchstart.drag",y).on("touchmove.drag",k,RF).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(E,O){if(!(m||!e.call(this,E,O))){var P=S(this,t.call(this,E,O),E,O,"mouse");P&&(Bs(E.view).on("mousemove.drag",N,Sc).on("mouseup.drag",j,Sc),C1(E.view),Yf(E),h=!1,u=E.clientX,d=E.clientY,P("start",E))}}function N(E){if(Ro(E),!h){var O=E.clientX-u,P=E.clientY-d;h=O*O+P*P>p}r.mouse("drag",E)}function j(E){Bs(E.view).on("mousemove.drag mouseup.drag",null),A1(E.view,h),Ro(E),r.mouse("end",E)}function y(E,O){if(e.call(this,E,O)){var P=E.changedTouches,H=t.call(this,E,O),B=P.length,R,M;for(R=0;R<B;++R)(M=S(this,H,E,O,P[R].identifier,P[R]))&&(Yf(E),M("start",E,P[R]))}}function k(E){var O=E.changedTouches,P=O.length,H,B;for(H=0;H<P;++H)(B=r[O[H].identifier])&&(Ro(E),B("drag",E,O[H]))}function _(E){var O=E.changedTouches,P=O.length,H,B;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),H=0;H<P;++H)(B=r[O[H].identifier])&&(Yf(E),B("end",E,O[H]))}function S(E,O,P,H,B,R){var M=o.copy(),F=ji(R||P,O),L,A,I;if((I=s.call(E,new og("beforestart",{sourceEvent:P,target:g,identifier:B,active:l,x:F[0],y:F[1],dx:0,dy:0,dispatch:M}),H))!=null)return L=I.x-F[0]||0,A=I.y-F[1]||0,function z(D,V,U){var q=F,te;switch(D){case"start":r[B]=z,te=l++;break;case"end":delete r[B],--l;case"drag":F=ji(U||V,O),te=l;break}M.call(D,E,new og(D,{sourceEvent:V,subject:I,target:g,identifier:B,active:te,x:F[0]+L,y:F[1]+A,dx:F[0]-q[0],dy:F[1]-q[1],dispatch:M}),H)}}return g.filter=function(E){return arguments.length?(e=typeof E=="function"?E:rd(!!E),g):e},g.container=function(E){return arguments.length?(t=typeof E=="function"?E:rd(E),g):t},g.subject=function(E){return arguments.length?(s=typeof E=="function"?E:rd(E),g):s},g.touchable=function(E){return arguments.length?(i=typeof E=="function"?E:rd(!!E),g):i},g.on=function(){var E=o.on.apply(o,arguments);return E===o?g:E},g.clickDistance=function(E){return arguments.length?(p=(E=+E)*E,g):Math.sqrt(p)},g}function _x(e,t,s){e.prototype=t.prototype=s,s.constructor=e}function I1(e,t){var s=Object.create(e.prototype);for(var i in t)s[i]=t[i];return s}function Vc(){}var _c=.7,Ud=1/_c,Oo="\\s*([+-]?\\d+)\\s*",Ec="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Vi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",DF=/^#([0-9a-f]{3,8})$/,FF=new RegExp(`^rgb\\(${Oo},${Oo},${Oo}\\)$`),UF=new RegExp(`^rgb\\(${Vi},${Vi},${Vi}\\)$`),BF=new RegExp(`^rgba\\(${Oo},${Oo},${Oo},${Ec}\\)$`),HF=new RegExp(`^rgba\\(${Vi},${Vi},${Vi},${Ec}\\)$`),ZF=new RegExp(`^hsl\\(${Ec},${Vi},${Vi}\\)$`),WF=new RegExp(`^hsla\\(${Ec},${Vi},${Vi},${Ec}\\)$`),Mk={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};_x(Vc,Ua,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Rk,formatHex:Rk,formatHex8:VF,formatHsl:qF,formatRgb:Ok,toString:Ok});function Rk(){return this.rgb().formatHex()}function VF(){return this.rgb().formatHex8()}function qF(){return T1(this).formatHsl()}function Ok(){return this.rgb().formatRgb()}function Ua(e){var t,s;return e=(e+"").trim().toLowerCase(),(t=DF.exec(e))?(s=t[1].length,t=parseInt(t[1],16),s===6?Pk(t):s===3?new Ts(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):s===8?ad(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):s===4?ad(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=FF.exec(e))?new Ts(t[1],t[2],t[3],1):(t=UF.exec(e))?new Ts(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=BF.exec(e))?ad(t[1],t[2],t[3],t[4]):(t=HF.exec(e))?ad(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ZF.exec(e))?Dk(t[1],t[2]/100,t[3]/100,1):(t=WF.exec(e))?Dk(t[1],t[2]/100,t[3]/100,t[4]):Mk.hasOwnProperty(e)?Pk(Mk[e]):e==="transparent"?new Ts(NaN,NaN,NaN,0):null}function Pk(e){return new Ts(e>>16&255,e>>8&255,e&255,1)}function ad(e,t,s,i){return i<=0&&(e=t=s=NaN),new Ts(e,t,s,i)}function GF(e){return e instanceof Vc||(e=Ua(e)),e?(e=e.rgb(),new Ts(e.r,e.g,e.b,e.opacity)):new Ts}function lg(e,t,s,i){return arguments.length===1?GF(e):new Ts(e,t,s,i??1)}function Ts(e,t,s,i){this.r=+e,this.g=+t,this.b=+s,this.opacity=+i}_x(Ts,lg,I1(Vc,{brighter(e){return e=e==null?Ud:Math.pow(Ud,e),new Ts(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?_c:Math.pow(_c,e),new Ts(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ts(za(this.r),za(this.g),za(this.b),Bd(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:Lk,formatHex:Lk,formatHex8:KF,formatRgb:zk,toString:zk}));function Lk(){return`#${Oa(this.r)}${Oa(this.g)}${Oa(this.b)}`}function KF(){return`#${Oa(this.r)}${Oa(this.g)}${Oa(this.b)}${Oa((isNaN(this.opacity)?1:this.opacity)*255)}`}function zk(){const e=Bd(this.opacity);return`${e===1?"rgb(":"rgba("}${za(this.r)}, ${za(this.g)}, ${za(this.b)}${e===1?")":`, ${e})`}`}function Bd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function za(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Oa(e){return e=za(e),(e<16?"0":"")+e.toString(16)}function Dk(e,t,s,i){return i<=0?e=t=s=NaN:s<=0||s>=1?e=t=NaN:t<=0&&(e=NaN),new Si(e,t,s,i)}function T1(e){if(e instanceof Si)return new Si(e.h,e.s,e.l,e.opacity);if(e instanceof Vc||(e=Ua(e)),!e)return new Si;if(e instanceof Si)return e;e=e.rgb();var t=e.r/255,s=e.g/255,i=e.b/255,r=Math.min(t,s,i),o=Math.max(t,s,i),l=NaN,u=o-r,d=(o+r)/2;return u?(t===o?l=(s-i)/u+(s<i)*6:s===o?l=(i-t)/u+2:l=(t-s)/u+4,u/=d<.5?o+r:2-o-r,l*=60):u=d>0&&d<1?0:l,new Si(l,u,d,e.opacity)}function YF(e,t,s,i){return arguments.length===1?T1(e):new Si(e,t,s,i??1)}function Si(e,t,s,i){this.h=+e,this.s=+t,this.l=+s,this.opacity=+i}_x(Si,YF,I1(Vc,{brighter(e){return e=e==null?Ud:Math.pow(Ud,e),new Si(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?_c:Math.pow(_c,e),new Si(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,s=this.l,i=s+(s<.5?s:1-s)*t,r=2*s-i;return new Ts(Xf(e>=240?e-240:e+120,r,i),Xf(e,r,i),Xf(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new Si(Fk(this.h),od(this.s),od(this.l),Bd(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=Bd(this.opacity);return`${e===1?"hsl(":"hsla("}${Fk(this.h)}, ${od(this.s)*100}%, ${od(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Fk(e){return e=(e||0)%360,e<0?e+360:e}function od(e){return Math.max(0,Math.min(1,e||0))}function Xf(e,t,s){return(e<60?t+(s-t)*e/60:e<180?s:e<240?t+(s-t)*(240-e)/60:t)*255}const Ex=e=>()=>e;function XF(e,t){return function(s){return e+s*t}}function QF(e,t,s){return e=Math.pow(e,s),t=Math.pow(t,s)-e,s=1/s,function(i){return Math.pow(e+i*t,s)}}function JF(e){return(e=+e)==1?M1:function(t,s){return s-t?QF(t,s,e):Ex(isNaN(t)?s:t)}}function M1(e,t){var s=t-e;return s?XF(e,s):Ex(isNaN(e)?t:e)}const Hd=(function e(t){var s=JF(t);function i(r,o){var l=s((r=lg(r)).r,(o=lg(o)).r),u=s(r.g,o.g),d=s(r.b,o.b),h=M1(r.opacity,o.opacity);return function(m){return r.r=l(m),r.g=u(m),r.b=d(m),r.opacity=h(m),r+""}}return i.gamma=e,i})(1);function e6(e,t){t||(t=[]);var s=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(o){for(r=0;r<s;++r)i[r]=e[r]*(1-o)+t[r]*o;return i}}function t6(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function n6(e,t){var s=t?t.length:0,i=e?Math.min(s,e.length):0,r=new Array(i),o=new Array(s),l;for(l=0;l<i;++l)r[l]=fc(e[l],t[l]);for(;l<s;++l)o[l]=t[l];return function(u){for(l=0;l<i;++l)o[l]=r[l](u);return o}}function s6(e,t){var s=new Date;return e=+e,t=+t,function(i){return s.setTime(e*(1-i)+t*i),s}}function Zi(e,t){return e=+e,t=+t,function(s){return e*(1-s)+t*s}}function i6(e,t){var s={},i={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?s[r]=fc(e[r],t[r]):i[r]=t[r];return function(o){for(r in s)i[r]=s[r](o);return i}}var cg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qf=new RegExp(cg.source,"g");function r6(e){return function(){return e}}function a6(e){return function(t){return e(t)+""}}function R1(e,t){var s=cg.lastIndex=Qf.lastIndex=0,i,r,o,l=-1,u=[],d=[];for(e=e+"",t=t+"";(i=cg.exec(e))&&(r=Qf.exec(t));)(o=r.index)>s&&(o=t.slice(s,o),u[l]?u[l]+=o:u[++l]=o),(i=i[0])===(r=r[0])?u[l]?u[l]+=r:u[++l]=r:(u[++l]=null,d.push({i:l,x:Zi(i,r)})),s=Qf.lastIndex;return s<t.length&&(o=t.slice(s),u[l]?u[l]+=o:u[++l]=o),u.length<2?d[0]?a6(d[0].x):r6(t):(t=d.length,function(h){for(var m=0,p;m<t;++m)u[(p=d[m]).i]=p.x(h);return u.join("")})}function fc(e,t){var s=typeof t,i;return t==null||s==="boolean"?Ex(t):(s==="number"?Zi:s==="string"?(i=Ua(t))?(t=i,Hd):R1:t instanceof Ua?Hd:t instanceof Date?s6:t6(t)?e6:Array.isArray(t)?n6:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?i6:Zi)(e,t)}var Uk=180/Math.PI,ug={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function O1(e,t,s,i,r,o){var l,u,d;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(d=e*s+t*i)&&(s-=e*d,i-=t*d),(u=Math.sqrt(s*s+i*i))&&(s/=u,i/=u,d/=u),e*i<t*s&&(e=-e,t=-t,d=-d,l=-l),{translateX:r,translateY:o,rotate:Math.atan2(t,e)*Uk,skewX:Math.atan(d)*Uk,scaleX:l,scaleY:u}}var ld;function o6(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ug:O1(t.a,t.b,t.c,t.d,t.e,t.f)}function l6(e){return e==null||(ld||(ld=document.createElementNS("http://www.w3.org/2000/svg","g")),ld.setAttribute("transform",e),!(e=ld.transform.baseVal.consolidate()))?ug:(e=e.matrix,O1(e.a,e.b,e.c,e.d,e.e,e.f))}function P1(e,t,s,i){function r(h){return h.length?h.pop()+" ":""}function o(h,m,p,g,x,N){if(h!==p||m!==g){var j=x.push("translate(",null,t,null,s);N.push({i:j-4,x:Zi(h,p)},{i:j-2,x:Zi(m,g)})}else(p||g)&&x.push("translate("+p+t+g+s)}function l(h,m,p,g){h!==m?(h-m>180?m+=360:m-h>180&&(h+=360),g.push({i:p.push(r(p)+"rotate(",null,i)-2,x:Zi(h,m)})):m&&p.push(r(p)+"rotate("+m+i)}function u(h,m,p,g){h!==m?g.push({i:p.push(r(p)+"skewX(",null,i)-2,x:Zi(h,m)}):m&&p.push(r(p)+"skewX("+m+i)}function d(h,m,p,g,x,N){if(h!==p||m!==g){var j=x.push(r(x)+"scale(",null,",",null,")");N.push({i:j-4,x:Zi(h,p)},{i:j-2,x:Zi(m,g)})}else(p!==1||g!==1)&&x.push(r(x)+"scale("+p+","+g+")")}return function(h,m){var p=[],g=[];return h=e(h),m=e(m),o(h.translateX,h.translateY,m.translateX,m.translateY,p,g),l(h.rotate,m.rotate,p,g),u(h.skewX,m.skewX,p,g),d(h.scaleX,h.scaleY,m.scaleX,m.scaleY,p,g),h=m=null,function(x){for(var N=-1,j=g.length,y;++N<j;)p[(y=g[N]).i]=y.x(x);return p.join("")}}}var c6=P1(o6,"px, ","px)","deg)"),u6=P1(l6,", ",")",")"),d6=1e-12;function Bk(e){return((e=Math.exp(e))+1/e)/2}function h6(e){return((e=Math.exp(e))-1/e)/2}function m6(e){return((e=Math.exp(2*e))-1)/(e+1)}const Nd=(function e(t,s,i){function r(o,l){var u=o[0],d=o[1],h=o[2],m=l[0],p=l[1],g=l[2],x=m-u,N=p-d,j=x*x+N*N,y,k;if(j<d6)k=Math.log(g/h)/t,y=function(H){return[u+H*x,d+H*N,h*Math.exp(t*H*k)]};else{var _=Math.sqrt(j),S=(g*g-h*h+i*j)/(2*h*s*_),E=(g*g-h*h-i*j)/(2*g*s*_),O=Math.log(Math.sqrt(S*S+1)-S),P=Math.log(Math.sqrt(E*E+1)-E);k=(P-O)/t,y=function(H){var B=H*k,R=Bk(O),M=h/(s*_)*(R*m6(t*B+O)-h6(O));return[u+M*x,d+M*N,h*R/Bk(t*B+O)]}}return y.duration=k*1e3*t/Math.SQRT2,y}return r.rho=function(o){var l=Math.max(.001,+o),u=l*l,d=u*u;return e(l,u,d)},r})(Math.SQRT2,2,4);var Xo=0,nc=0,Zl=0,L1=1e3,Zd,sc,Wd=0,Ba=0,gh=0,Cc=typeof performance=="object"&&performance.now?performance:Date,z1=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Cx(){return Ba||(z1(f6),Ba=Cc.now()+gh)}function f6(){Ba=0}function Vd(){this._call=this._time=this._next=null}Vd.prototype=D1.prototype={constructor:Vd,restart:function(e,t,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?Cx():+s)+(t==null?0:+t),!this._next&&sc!==this&&(sc?sc._next=this:Zd=this,sc=this),this._call=e,this._time=s,dg()},stop:function(){this._call&&(this._call=null,this._time=1/0,dg())}};function D1(e,t,s){var i=new Vd;return i.restart(e,t,s),i}function p6(){Cx(),++Xo;for(var e=Zd,t;e;)(t=Ba-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Xo}function Hk(){Ba=(Wd=Cc.now())+gh,Xo=nc=0;try{p6()}finally{Xo=0,x6(),Ba=0}}function g6(){var e=Cc.now(),t=e-Wd;t>L1&&(gh-=t,Wd=e)}function x6(){for(var e,t=Zd,s,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(s=t._next,t._next=null,t=e?e._next=s:Zd=s);sc=e,dg(i)}function dg(e){if(!Xo){nc&&(nc=clearTimeout(nc));var t=e-Ba;t>24?(e<1/0&&(nc=setTimeout(Hk,e-Cc.now()-gh)),Zl&&(Zl=clearInterval(Zl))):(Zl||(Wd=Cc.now(),Zl=setInterval(g6,L1)),Xo=1,z1(Hk))}}function Zk(e,t,s){var i=new Vd;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,s),i}var v6=fh("start","end","cancel","interrupt"),y6=[],F1=0,Wk=1,hg=2,wd=3,Vk=4,mg=5,Sd=6;function xh(e,t,s,i,r,o){var l=e.__transition;if(!l)e.__transition={};else if(s in l)return;b6(e,s,{name:t,index:i,group:r,on:v6,tween:y6,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:F1})}function Ax(e,t){var s=Ii(e,t);if(s.state>F1)throw new Error("too late; already scheduled");return s}function qi(e,t){var s=Ii(e,t);if(s.state>wd)throw new Error("too late; already running");return s}function Ii(e,t){var s=e.__transition;if(!s||!(s=s[t]))throw new Error("transition not found");return s}function b6(e,t,s){var i=e.__transition,r;i[t]=s,s.timer=D1(o,0,s.time);function o(h){s.state=Wk,s.timer.restart(l,s.delay,s.time),s.delay<=h&&l(h-s.delay)}function l(h){var m,p,g,x;if(s.state!==Wk)return d();for(m in i)if(x=i[m],x.name===s.name){if(x.state===wd)return Zk(l);x.state===Vk?(x.state=Sd,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete i[m]):+m<t&&(x.state=Sd,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete i[m])}if(Zk(function(){s.state===wd&&(s.state=Vk,s.timer.restart(u,s.delay,s.time),u(h))}),s.state=hg,s.on.call("start",e,e.__data__,s.index,s.group),s.state===hg){for(s.state=wd,r=new Array(g=s.tween.length),m=0,p=-1;m<g;++m)(x=s.tween[m].value.call(e,e.__data__,s.index,s.group))&&(r[++p]=x);r.length=p+1}}function u(h){for(var m=h<s.duration?s.ease.call(null,h/s.duration):(s.timer.restart(d),s.state=mg,1),p=-1,g=r.length;++p<g;)r[p].call(e,m);s.state===mg&&(s.on.call("end",e,e.__data__,s.index,s.group),d())}function d(){s.state=Sd,s.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function _d(e,t){var s=e.__transition,i,r,o=!0,l;if(s){t=t==null?null:t+"";for(l in s){if((i=s[l]).name!==t){o=!1;continue}r=i.state>hg&&i.state<mg,i.state=Sd,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete s[l]}o&&delete e.__transition}}function k6(e){return this.each(function(){_d(this,e)})}function j6(e,t){var s,i;return function(){var r=qi(this,e),o=r.tween;if(o!==s){i=s=o;for(var l=0,u=i.length;l<u;++l)if(i[l].name===t){i=i.slice(),i.splice(l,1);break}}r.tween=i}}function N6(e,t,s){var i,r;if(typeof s!="function")throw new Error;return function(){var o=qi(this,e),l=o.tween;if(l!==i){r=(i=l).slice();for(var u={name:t,value:s},d=0,h=r.length;d<h;++d)if(r[d].name===t){r[d]=u;break}d===h&&r.push(u)}o.tween=r}}function w6(e,t){var s=this._id;if(e+="",arguments.length<2){for(var i=Ii(this.node(),s).tween,r=0,o=i.length,l;r<o;++r)if((l=i[r]).name===e)return l.value;return null}return this.each((t==null?j6:N6)(s,e,t))}function $x(e,t,s){var i=e._id;return e.each(function(){var r=qi(this,i);(r.value||(r.value={}))[t]=s.apply(this,arguments)}),function(r){return Ii(r,i).value[t]}}function U1(e,t){var s;return(typeof t=="number"?Zi:t instanceof Ua?Hd:(s=Ua(t))?(t=s,Hd):R1)(e,t)}function S6(e){return function(){this.removeAttribute(e)}}function _6(e){return function(){this.removeAttributeNS(e.space,e.local)}}function E6(e,t,s){var i,r=s+"",o;return function(){var l=this.getAttribute(e);return l===r?null:l===i?o:o=t(i=l,s)}}function C6(e,t,s){var i,r=s+"",o;return function(){var l=this.getAttributeNS(e.space,e.local);return l===r?null:l===i?o:o=t(i=l,s)}}function A6(e,t,s){var i,r,o;return function(){var l,u=s(this),d;return u==null?void this.removeAttribute(e):(l=this.getAttribute(e),d=u+"",l===d?null:l===i&&d===r?o:(r=d,o=t(i=l,u)))}}function $6(e,t,s){var i,r,o;return function(){var l,u=s(this),d;return u==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),d=u+"",l===d?null:l===i&&d===r?o:(r=d,o=t(i=l,u)))}}function I6(e,t){var s=ph(e),i=s==="transform"?u6:U1;return this.attrTween(e,typeof t=="function"?(s.local?$6:A6)(s,i,$x(this,"attr."+e,t)):t==null?(s.local?_6:S6)(s):(s.local?C6:E6)(s,i,t))}function T6(e,t){return function(s){this.setAttribute(e,t.call(this,s))}}function M6(e,t){return function(s){this.setAttributeNS(e.space,e.local,t.call(this,s))}}function R6(e,t){var s,i;function r(){var o=t.apply(this,arguments);return o!==i&&(s=(i=o)&&M6(e,o)),s}return r._value=t,r}function O6(e,t){var s,i;function r(){var o=t.apply(this,arguments);return o!==i&&(s=(i=o)&&T6(e,o)),s}return r._value=t,r}function P6(e,t){var s="attr."+e;if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;var i=ph(e);return this.tween(s,(i.local?R6:O6)(i,t))}function L6(e,t){return function(){Ax(this,e).delay=+t.apply(this,arguments)}}function z6(e,t){return t=+t,function(){Ax(this,e).delay=t}}function D6(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?L6:z6)(t,e)):Ii(this.node(),t).delay}function F6(e,t){return function(){qi(this,e).duration=+t.apply(this,arguments)}}function U6(e,t){return t=+t,function(){qi(this,e).duration=t}}function B6(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?F6:U6)(t,e)):Ii(this.node(),t).duration}function H6(e,t){if(typeof t!="function")throw new Error;return function(){qi(this,e).ease=t}}function Z6(e){var t=this._id;return arguments.length?this.each(H6(t,e)):Ii(this.node(),t).ease}function W6(e,t){return function(){var s=t.apply(this,arguments);if(typeof s!="function")throw new Error;qi(this,e).ease=s}}function V6(e){if(typeof e!="function")throw new Error;return this.each(W6(this._id,e))}function q6(e){typeof e!="function"&&(e=v1(e));for(var t=this._groups,s=t.length,i=new Array(s),r=0;r<s;++r)for(var o=t[r],l=o.length,u=i[r]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new vr(i,this._parents,this._name,this._id)}function G6(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,s=e._groups,i=t.length,r=s.length,o=Math.min(i,r),l=new Array(i),u=0;u<o;++u)for(var d=t[u],h=s[u],m=d.length,p=l[u]=new Array(m),g,x=0;x<m;++x)(g=d[x]||h[x])&&(p[x]=g);for(;u<i;++u)l[u]=t[u];return new vr(l,this._parents,this._name,this._id)}function K6(e){return(e+"").trim().split(/^|\s+/).every(function(t){var s=t.indexOf(".");return s>=0&&(t=t.slice(0,s)),!t||t==="start"})}function Y6(e,t,s){var i,r,o=K6(t)?Ax:qi;return function(){var l=o(this,e),u=l.on;u!==i&&(r=(i=u).copy()).on(t,s),l.on=r}}function X6(e,t){var s=this._id;return arguments.length<2?Ii(this.node(),s).on.on(e):this.each(Y6(s,e,t))}function Q6(e){return function(){var t=this.parentNode;for(var s in this.__transition)if(+s!==e)return;t&&t.removeChild(this)}}function J6(){return this.on("end.remove",Q6(this._id))}function eU(e){var t=this._name,s=this._id;typeof e!="function"&&(e=wx(e));for(var i=this._groups,r=i.length,o=new Array(r),l=0;l<r;++l)for(var u=i[l],d=u.length,h=o[l]=new Array(d),m,p,g=0;g<d;++g)(m=u[g])&&(p=e.call(m,m.__data__,g,u))&&("__data__"in m&&(p.__data__=m.__data__),h[g]=p,xh(h[g],t,s,g,h,Ii(m,s)));return new vr(o,this._parents,t,s)}function tU(e){var t=this._name,s=this._id;typeof e!="function"&&(e=x1(e));for(var i=this._groups,r=i.length,o=[],l=[],u=0;u<r;++u)for(var d=i[u],h=d.length,m,p=0;p<h;++p)if(m=d[p]){for(var g=e.call(m,m.__data__,p,d),x,N=Ii(m,s),j=0,y=g.length;j<y;++j)(x=g[j])&&xh(x,t,s,j,g,N);o.push(g),l.push(m)}return new vr(o,l,t,s)}var nU=Wc.prototype.constructor;function sU(){return new nU(this._groups,this._parents)}function iU(e,t){var s,i,r;return function(){var o=Yo(this,e),l=(this.style.removeProperty(e),Yo(this,e));return o===l?null:o===s&&l===i?r:r=t(s=o,i=l)}}function B1(e){return function(){this.style.removeProperty(e)}}function rU(e,t,s){var i,r=s+"",o;return function(){var l=Yo(this,e);return l===r?null:l===i?o:o=t(i=l,s)}}function aU(e,t,s){var i,r,o;return function(){var l=Yo(this,e),u=s(this),d=u+"";return u==null&&(d=u=(this.style.removeProperty(e),Yo(this,e))),l===d?null:l===i&&d===r?o:(r=d,o=t(i=l,u))}}function oU(e,t){var s,i,r,o="style."+t,l="end."+o,u;return function(){var d=qi(this,e),h=d.on,m=d.value[o]==null?u||(u=B1(t)):void 0;(h!==s||r!==m)&&(i=(s=h).copy()).on(l,r=m),d.on=i}}function lU(e,t,s){var i=(e+="")=="transform"?c6:U1;return t==null?this.styleTween(e,iU(e,i)).on("end.style."+e,B1(e)):typeof t=="function"?this.styleTween(e,aU(e,i,$x(this,"style."+e,t))).each(oU(this._id,e)):this.styleTween(e,rU(e,i,t),s).on("end.style."+e,null)}function cU(e,t,s){return function(i){this.style.setProperty(e,t.call(this,i),s)}}function uU(e,t,s){var i,r;function o(){var l=t.apply(this,arguments);return l!==r&&(i=(r=l)&&cU(e,l,s)),i}return o._value=t,o}function dU(e,t,s){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,uU(e,t,s??""))}function hU(e){return function(){this.textContent=e}}function mU(e){return function(){var t=e(this);this.textContent=t??""}}function fU(e){return this.tween("text",typeof e=="function"?mU($x(this,"text",e)):hU(e==null?"":e+""))}function pU(e){return function(t){this.textContent=e.call(this,t)}}function gU(e){var t,s;function i(){var r=e.apply(this,arguments);return r!==s&&(t=(s=r)&&pU(r)),t}return i._value=e,i}function xU(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,gU(e))}function vU(){for(var e=this._name,t=this._id,s=H1(),i=this._groups,r=i.length,o=0;o<r;++o)for(var l=i[o],u=l.length,d,h=0;h<u;++h)if(d=l[h]){var m=Ii(d,t);xh(d,e,s,h,l,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new vr(i,this._parents,e,s)}function yU(){var e,t,s=this,i=s._id,r=s.size();return new Promise(function(o,l){var u={value:l},d={value:function(){--r===0&&o()}};s.each(function(){var h=qi(this,i),m=h.on;m!==e&&(t=(e=m).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(d)),h.on=t}),r===0&&o()})}var bU=0;function vr(e,t,s,i){this._groups=e,this._parents=t,this._name=s,this._id=i}function H1(){return++bU}var dr=Wc.prototype;vr.prototype={constructor:vr,select:eU,selectAll:tU,selectChild:dr.selectChild,selectChildren:dr.selectChildren,filter:q6,merge:G6,selection:sU,transition:vU,call:dr.call,nodes:dr.nodes,node:dr.node,size:dr.size,empty:dr.empty,each:dr.each,on:X6,attr:I6,attrTween:P6,style:lU,styleTween:dU,text:fU,textTween:xU,remove:J6,tween:w6,delay:D6,duration:B6,ease:Z6,easeVarying:V6,end:yU,[Symbol.iterator]:dr[Symbol.iterator]};function kU(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var jU={time:null,delay:0,duration:250,ease:kU};function NU(e,t){for(var s;!(s=e.__transition)||!(s=s[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return s}function wU(e){var t,s;e instanceof vr?(t=e._id,e=e._name):(t=H1(),(s=jU).time=Cx(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,o=0;o<r;++o)for(var l=i[o],u=l.length,d,h=0;h<u;++h)(d=l[h])&&xh(d,e,t,h,l,s||NU(d,t));return new vr(i,this._parents,e,t)}Wc.prototype.interrupt=k6;Wc.prototype.transition=wU;const cd=e=>()=>e;function SU(e,{sourceEvent:t,target:s,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function fr(e,t,s){this.k=e,this.x=t,this.y=s}fr.prototype={constructor:fr,scale:function(e){return e===1?this:new fr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new fr(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 vh=new fr(1,0,0);Z1.prototype=fr.prototype;function Z1(e){for(;!e.__zoom;)if(!(e=e.parentNode))return vh;return e.__zoom}function Jf(e){e.stopImmediatePropagation()}function Wl(e){e.preventDefault(),e.stopImmediatePropagation()}function _U(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function EU(){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 qk(){return this.__zoom||vh}function CU(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function AU(){return navigator.maxTouchPoints||"ontouchstart"in this}function $U(e,t,s){var i=e.invertX(t[0][0])-s[0][0],r=e.invertX(t[1][0])-s[1][0],o=e.invertY(t[0][1])-s[0][1],l=e.invertY(t[1][1])-s[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),l>o?(o+l)/2:Math.min(0,o)||Math.max(0,l))}function W1(){var e=_U,t=EU,s=$U,i=CU,r=AU,o=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],u=250,d=Nd,h=fh("start","zoom","end"),m,p,g,x=500,N=150,j=0,y=10;function k(I){I.property("__zoom",qk).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",M).filter(r).on("touchstart.zoom",F).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}k.transform=function(I,z,D,V){var U=I.selection?I.selection():I;U.property("__zoom",qk),I!==U?O(I,z,D,V):U.interrupt().each(function(){P(this,arguments).event(V).start().zoom(null,typeof z=="function"?z.apply(this,arguments):z).end()})},k.scaleBy=function(I,z,D,V){k.scaleTo(I,function(){var U=this.__zoom.k,q=typeof z=="function"?z.apply(this,arguments):z;return U*q},D,V)},k.scaleTo=function(I,z,D,V){k.transform(I,function(){var U=t.apply(this,arguments),q=this.__zoom,te=D==null?E(U):typeof D=="function"?D.apply(this,arguments):D,G=q.invert(te),K=typeof z=="function"?z.apply(this,arguments):z;return s(S(_(q,K),te,G),U,l)},D,V)},k.translateBy=function(I,z,D,V){k.transform(I,function(){return s(this.__zoom.translate(typeof z=="function"?z.apply(this,arguments):z,typeof D=="function"?D.apply(this,arguments):D),t.apply(this,arguments),l)},null,V)},k.translateTo=function(I,z,D,V,U){k.transform(I,function(){var q=t.apply(this,arguments),te=this.__zoom,G=V==null?E(q):typeof V=="function"?V.apply(this,arguments):V;return s(vh.translate(G[0],G[1]).scale(te.k).translate(typeof z=="function"?-z.apply(this,arguments):-z,typeof D=="function"?-D.apply(this,arguments):-D),q,l)},V,U)};function _(I,z){return z=Math.max(o[0],Math.min(o[1],z)),z===I.k?I:new fr(z,I.x,I.y)}function S(I,z,D){var V=z[0]-D[0]*I.k,U=z[1]-D[1]*I.k;return V===I.x&&U===I.y?I:new fr(I.k,V,U)}function E(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function O(I,z,D,V){I.on("start.zoom",function(){P(this,arguments).event(V).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(V).end()}).tween("zoom",function(){var U=this,q=arguments,te=P(U,q).event(V),G=t.apply(U,q),K=D==null?E(G):typeof D=="function"?D.apply(U,q):D,Z=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),ee=U.__zoom,J=typeof z=="function"?z.apply(U,q):z,re=d(ee.invert(K).concat(Z/ee.k),J.invert(K).concat(Z/J.k));return function(ie){if(ie===1)ie=J;else{var ne=re(ie),me=Z/ne[2];ie=new fr(me,K[0]-ne[0]*me,K[1]-ne[1]*me)}te.zoom(null,ie)}})}function P(I,z,D){return!D&&I.__zooming||new H(I,z)}function H(I,z){this.that=I,this.args=z,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,z),this.taps=0}H.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,z){return this.mouse&&I!=="mouse"&&(this.mouse[1]=z.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=z.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=z.invert(this.touch1[0])),this.that.__zoom=z,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var z=Bs(this.that).datum();h.call(I,this.that,new SU(I,{sourceEvent:this.sourceEvent,target:k,transform:this.that.__zoom,dispatch:h}),z)}};function B(I,...z){if(!e.apply(this,arguments))return;var D=P(this,z).event(I),V=this.__zoom,U=Math.max(o[0],Math.min(o[1],V.k*Math.pow(2,i.apply(this,arguments)))),q=ji(I);if(D.wheel)(D.mouse[0][0]!==q[0]||D.mouse[0][1]!==q[1])&&(D.mouse[1]=V.invert(D.mouse[0]=q)),clearTimeout(D.wheel);else{if(V.k===U)return;D.mouse=[q,V.invert(q)],_d(this),D.start()}Wl(I),D.wheel=setTimeout(te,N),D.zoom("mouse",s(S(_(V,U),D.mouse[0],D.mouse[1]),D.extent,l));function te(){D.wheel=null,D.end()}}function R(I,...z){if(g||!e.apply(this,arguments))return;var D=I.currentTarget,V=P(this,z,!0).event(I),U=Bs(I.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",Z,!0),q=ji(I,D),te=I.clientX,G=I.clientY;C1(I.view),Jf(I),V.mouse=[q,this.__zoom.invert(q)],_d(this),V.start();function K(ee){if(Wl(ee),!V.moved){var J=ee.clientX-te,re=ee.clientY-G;V.moved=J*J+re*re>j}V.event(ee).zoom("mouse",s(S(V.that.__zoom,V.mouse[0]=ji(ee,D),V.mouse[1]),V.extent,l))}function Z(ee){U.on("mousemove.zoom mouseup.zoom",null),A1(ee.view,V.moved),Wl(ee),V.event(ee).end()}}function M(I,...z){if(e.apply(this,arguments)){var D=this.__zoom,V=ji(I.changedTouches?I.changedTouches[0]:I,this),U=D.invert(V),q=D.k*(I.shiftKey?.5:2),te=s(S(_(D,q),V,U),t.apply(this,z),l);Wl(I),u>0?Bs(this).transition().duration(u).call(O,te,V,I):Bs(this).call(k.transform,te,V,I)}}function F(I,...z){if(e.apply(this,arguments)){var D=I.touches,V=D.length,U=P(this,z,I.changedTouches.length===V).event(I),q,te,G,K;for(Jf(I),te=0;te<V;++te)G=D[te],K=ji(G,this),K=[K,this.__zoom.invert(K),G.identifier],U.touch0?!U.touch1&&U.touch0[2]!==K[2]&&(U.touch1=K,U.taps=0):(U.touch0=K,q=!0,U.taps=1+!!m);m&&(m=clearTimeout(m)),q&&(U.taps<2&&(p=K[0],m=setTimeout(function(){m=null},x)),_d(this),U.start())}}function L(I,...z){if(this.__zooming){var D=P(this,z).event(I),V=I.changedTouches,U=V.length,q,te,G,K;for(Wl(I),q=0;q<U;++q)te=V[q],G=ji(te,this),D.touch0&&D.touch0[2]===te.identifier?D.touch0[0]=G:D.touch1&&D.touch1[2]===te.identifier&&(D.touch1[0]=G);if(te=D.that.__zoom,D.touch1){var Z=D.touch0[0],ee=D.touch0[1],J=D.touch1[0],re=D.touch1[1],ie=(ie=J[0]-Z[0])*ie+(ie=J[1]-Z[1])*ie,ne=(ne=re[0]-ee[0])*ne+(ne=re[1]-ee[1])*ne;te=_(te,Math.sqrt(ie/ne)),G=[(Z[0]+J[0])/2,(Z[1]+J[1])/2],K=[(ee[0]+re[0])/2,(ee[1]+re[1])/2]}else if(D.touch0)G=D.touch0[0],K=D.touch0[1];else return;D.zoom("touch",s(S(te,G,K),D.extent,l))}}function A(I,...z){if(this.__zooming){var D=P(this,z).event(I),V=I.changedTouches,U=V.length,q,te;for(Jf(I),g&&clearTimeout(g),g=setTimeout(function(){g=null},x),q=0;q<U;++q)te=V[q],D.touch0&&D.touch0[2]===te.identifier?delete D.touch0:D.touch1&&D.touch1[2]===te.identifier&&delete D.touch1;if(D.touch1&&!D.touch0&&(D.touch0=D.touch1,delete D.touch1),D.touch0)D.touch0[1]=this.__zoom.invert(D.touch0[0]);else if(D.end(),D.taps===2&&(te=ji(te,this),Math.hypot(p[0]-te[0],p[1]-te[1])<y)){var G=Bs(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return k.wheelDelta=function(I){return arguments.length?(i=typeof I=="function"?I:cd(+I),k):i},k.filter=function(I){return arguments.length?(e=typeof I=="function"?I:cd(!!I),k):e},k.touchable=function(I){return arguments.length?(r=typeof I=="function"?I:cd(!!I),k):r},k.extent=function(I){return arguments.length?(t=typeof I=="function"?I:cd([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),k):t},k.scaleExtent=function(I){return arguments.length?(o[0]=+I[0],o[1]=+I[1],k):[o[0],o[1]]},k.translateExtent=function(I){return arguments.length?(l[0][0]=+I[0][0],l[1][0]=+I[1][0],l[0][1]=+I[0][1],l[1][1]=+I[1][1],k):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},k.constrain=function(I){return arguments.length?(s=I,k):s},k.duration=function(I){return arguments.length?(u=+I,k):u},k.interpolate=function(I){return arguments.length?(d=I,k):d},k.on=function(){var I=h.on.apply(h,arguments);return I===h?k:I},k.clickDistance=function(I){return arguments.length?(j=(I=+I)*I,k):Math.sqrt(j)},k.tapDistance=function(I){return arguments.length?(y=+I,k):y},k}const Ai={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:s,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:i}", 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.`},Ac=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],V1=["Enter"," ","Escape"],q1={"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:s})=>`Moved selected node ${e}. New position, x: ${t}, y: ${s}`,"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 Qo;(function(e){e.Strict="strict",e.Loose="loose"})(Qo||(Qo={}));var Da;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Da||(Da={}));var $c;(function(e){e.Partial="partial",e.Full="full"})($c||($c={}));const G1={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Wr;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Wr||(Wr={}));var qd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qd||(qd={}));var tt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(tt||(tt={}));const Gk={[tt.Left]:tt.Right,[tt.Right]:tt.Left,[tt.Top]:tt.Bottom,[tt.Bottom]:tt.Top},K1=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,IU=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Ix=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),qc=(e,t=[0,0])=>{const{width:s,height:i}=Ti(e),r=e.origin??t,o=s*r[0],l=i*r[1];return{x:e.position.x-o,y:e.position.y-l}},TU=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let s=!1;const i=e.reduce((r,o)=>{const l=typeof o=="string";let u=!t.nodeLookup&&!l?o:void 0;return t.nodeLookup&&(u=l?t.nodeLookup.get(o):Ix(o)?o:t.nodeLookup.get(o.id)),u?(s=!0,yh(r,Gd(u,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return s?bh(i):{x:0,y:0,width:0,height:0}},Gc=(e,t={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(s=yh(s,Gd(r)),i=!0)}),i?bh(s):{x:0,y:0,width:0,height:0}},Tx=(e,t,[s,i,r]=[0,0,1],o=!1,l=!1)=>{const u=(t.x-s)/r,d=(t.y-i)/r,h=t.width/r,m=t.height/r,p=[];for(const g of e.values()){const{measured:x,selectable:N=!0,hidden:j=!1}=g;if(l&&!N||j)continue;const y=x.width??g.width??g.initialWidth??0,k=x.height??g.height??g.initialHeight??0,{x:_,y:S}=g.internals.positionAbsolute,E=J1(u,d,h,m,_,S,y,k),O=y*k,P=o&&E>0;(!g.internals.handleBounds||P||E>=O||g.dragging)&&p.push(g)}return p},MU=(e,t)=>{const s=new Set;return e.forEach(i=>{s.add(i.id)}),t.filter(i=>s.has(i.source)||s.has(i.target))};function RU(e,t){const s=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let o;if(t!=null&&t.includeHiddenNodes){const{width:l,height:u}=Ti(r);o=l>0&&u>0}else o=!!(r.measured.width&&r.measured.height&&!r.hidden);o&&(!i||i.has(r.id))&&s.set(r.id,r)}),s}async function OU({nodes:e,width:t,height:s,panZoom:i,minZoom:r,maxZoom:o},l){if(e.size===0)return!0;const u=RU(e,l),d=Gc(u),h=Rx(d,t,s,(l==null?void 0:l.minZoom)??r,(l==null?void 0:l.maxZoom)??o,(l==null?void 0:l.padding)??.1);return await i.setViewport(h,{duration:l==null?void 0:l.duration,ease:l==null?void 0:l.ease,interpolate:l==null?void 0:l.interpolate}),!0}function Y1({nodeId:e,nextPosition:t,nodeLookup:s,nodeOrigin:i=[0,0],nodeExtent:r,onError:o}){const l=s.get(e),u=l.parentId?s.get(l.parentId):void 0,{x:d,y:h}=u?u.internals.positionAbsolute:{x:0,y:0},m=l.origin??i;let p=l.extent||r;if(l.extent==="parent"&&!l.expandParent)if(!u)o==null||o("005",Ai.error005());else{const{width:x,height:N}=Ti(u);x&&N&&(p=[[d,h],[d+x,h+N]])}else u&&Za(l.extent)&&(p=[[l.extent[0][0]+d,l.extent[0][1]+h],[l.extent[1][0]+d,l.extent[1][1]+h]]);const g=Za(p)?Ha(t,p,l.measured):t;return(l.measured.width===void 0||l.measured.height===void 0)&&(o==null||o("015",Ai.error015())),{position:{x:g.x-d+(l.measured.width??0)*m[0],y:g.y-h+(l.measured.height??0)*m[1]},positionAbsolute:g}}async function PU({nodesToRemove:e=[],edgesToRemove:t=[],nodes:s,edges:i,onBeforeDelete:r}){const o=new Set(e.map(g=>g.id)),l=[];for(const g of s){if(g.deletable===!1)continue;const x=o.has(g.id),N=!x&&g.parentId&&l.find(j=>j.id===g.parentId);(x||N)&&l.push(g)}const u=new Set(t.map(g=>g.id)),d=i.filter(g=>g.deletable!==!1),m=MU(l,d);for(const g of d)u.has(g.id)&&!m.find(N=>N.id===g.id)&&m.push(g);if(!r)return{edges:m,nodes:l};const p=await r({nodes:l,edges:m});return typeof p=="boolean"?p?{edges:m,nodes:l}:{edges:[],nodes:[]}:p}const Jo=(e,t=0,s=1)=>Math.min(Math.max(e,t),s),Ha=(e={x:0,y:0},t,s)=>({x:Jo(e.x,t[0][0],t[1][0]-((s==null?void 0:s.width)??0)),y:Jo(e.y,t[0][1],t[1][1]-((s==null?void 0:s.height)??0))});function X1(e,t,s){const{width:i,height:r}=Ti(s),{x:o,y:l}=s.internals.positionAbsolute;return Ha(e,[[o,l],[o+i,l+r]],t)}const Kk=(e,t,s)=>e<t?Jo(Math.abs(e-t),1,t)/t:e>s?-Jo(Math.abs(e-s),1,t)/t:0,Mx=(e,t,s=15,i=40)=>{const r=Kk(e.x,i,t.width-i)*s,o=Kk(e.y,i,t.height-i)*s;return[r,o]},yh=(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)}),fg=({x:e,y:t,width:s,height:i})=>({x:e,y:t,x2:e+s,y2:t+i}),bh=({x:e,y:t,x2:s,y2:i})=>({x:e,y:t,width:s-e,height:i-t}),Ic=(e,t=[0,0])=>{var r,o;const{x:s,y:i}=Ix(e)?e.internals.positionAbsolute:qc(e,t);return{x:s,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},Gd=(e,t=[0,0])=>{var r,o;const{x:s,y:i}=Ix(e)?e.internals.positionAbsolute:qc(e,t);return{x:s,y:i,x2:s+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},Q1=(e,t)=>bh(yh(fg(e),fg(t))),J1=(e,t,s,i,r,o,l,u)=>{const d=Math.max(0,Math.min(e+s,r+l)-Math.max(e,r)),h=Math.max(0,Math.min(t+i,o+u)-Math.max(t,o));return Math.ceil(d*h)},Kd=(e,t)=>J1(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Yk=e=>_i(e.width)&&_i(e.height)&&_i(e.x)&&_i(e.y),_i=e=>!isNaN(e)&&isFinite(e),e_=(e,t)=>(s,i)=>{},Kc=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Yc=({x:e,y:t},[s,i,r],o=!1,l=[1,1])=>{const u={x:(e-s)/r,y:(t-i)/r};return o?Kc(u,l):u},el=({x:e,y:t},[s,i,r])=>({x:e*r+s,y:t*r+i});function bo(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(s)}if(typeof e=="string"&&e.endsWith("%")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(t*s*.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 LU(e,t,s){if(typeof e=="string"||typeof e=="number"){const i=bo(e,s),r=bo(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=bo(e.top??e.y??0,s),r=bo(e.bottom??e.y??0,s),o=bo(e.left??e.x??0,t),l=bo(e.right??e.x??0,t);return{top:i,right:l,bottom:r,left:o,x:o+l,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function zU(e,t,s,i,r,o){const{x:l,y:u}=el(e,[t,s,i]),{x:d,y:h}=el({x:e.x+e.width,y:e.y+e.height},[t,s,i]),m=r-d,p=o-h;return{left:Math.floor(l),top:Math.floor(u),right:Math.floor(m),bottom:Math.floor(p)}}const Rx=(e,t,s,i,r,o)=>{const l=LU(o,t,s),u=(t-l.x)/e.width,d=(s-l.y)/e.height,h=Math.min(u,d),m=Jo(h,i,r),p=e.x+e.width/2,g=e.y+e.height/2,x=t/2-p*m,N=s/2-g*m,j=zU(e,x,N,m,t,s),y={left:Math.min(j.left-l.left,0),top:Math.min(j.top-l.top,0),right:Math.min(j.right-l.right,0),bottom:Math.min(j.bottom-l.bottom,0)};return{x:x-y.left+y.right,y:N-y.top+y.bottom,zoom:m}},Tc=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Za(e){return e!=null&&e!=="parent"}function Ti(e){var t,s;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0}}function t_(e){var t,s;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight)!==void 0}function n_(e,t={width:0,height:0},s,i,r){const o={...e},l=i.get(s);if(l){const u=l.origin||r;o.x+=l.internals.positionAbsolute.x-(t.width??0)*u[0],o.y+=l.internals.positionAbsolute.y-(t.height??0)*u[1]}return o}function Xk(e,t){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}function DU(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function FU(e){return{...q1,...e||{}}}function s_(e){return e===null?null:e?"valid":"invalid"}function pc(e,{snapGrid:t=[0,0],snapToGrid:s=!1,transform:i,containerBounds:r}){const{x:o,y:l}=Ei(e),u=Yc({x:o-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},i),{x:d,y:h}=s?Kc(u,t):u;return{xSnapped:d,ySnapped:h,...u}}const Ox=e=>({width:e.offsetWidth,height:e.offsetHeight}),i_=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},UU=["INPUT","SELECT","TEXTAREA"];function r_(e){var i,r;const t=((r=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:UU.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const a_=e=>"clientX"in e,Ei=(e,t)=>{var o,l;const s=a_(e),i=s?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,r=s?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},Qk=(e,t,s,i,r)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(l=>{const u=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:r,position:l.getAttribute("data-handlepos"),x:(u.left-s.left)/i,y:(u.top-s.top)/i,...Ox(l)}})};function o_({sourceX:e,sourceY:t,targetX:s,targetY:i,sourceControlX:r,sourceControlY:o,targetControlX:l,targetControlY:u}){const d=e*.125+r*.375+l*.375+s*.125,h=t*.125+o*.375+u*.375+i*.125,m=Math.abs(d-e),p=Math.abs(h-t);return[d,h,m,p]}function ud(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Jk({pos:e,x1:t,y1:s,x2:i,y2:r,c:o}){switch(e){case tt.Left:return[t-ud(t-i,o),s];case tt.Right:return[t+ud(i-t,o),s];case tt.Top:return[t,s-ud(s-r,o)];case tt.Bottom:return[t,s+ud(r-s,o)]}}function l_({sourceX:e,sourceY:t,sourcePosition:s=tt.Bottom,targetX:i,targetY:r,targetPosition:o=tt.Top,curvature:l=.25}){const[u,d]=Jk({pos:s,x1:e,y1:t,x2:i,y2:r,c:l}),[h,m]=Jk({pos:o,x1:i,y1:r,x2:e,y2:t,c:l}),[p,g,x,N]=o_({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:u,sourceControlY:d,targetControlX:h,targetControlY:m});return[`M${e},${t} C${u},${d} ${h},${m} ${i},${r}`,p,g,x,N]}function c_({sourceX:e,sourceY:t,targetX:s,targetY:i}){const r=Math.abs(s-e)/2,o=s<e?s+r:s-r,l=Math.abs(i-t)/2,u=i<t?i+l:i-l;return[o,u,r,l]}function BU({sourceNode:e,targetNode:t,selected:s=!1,zIndex:i=0,elevateOnSelect:r=!1,zIndexMode:o="basic"}){if(o==="manual")return i;const l=r&&s?i+1e3:i,u=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return l+u}function HU({sourceNode:e,targetNode:t,width:s,height:i,transform:r}){const o=yh(Gd(e),Gd(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const l={x:-r[0]/r[2],y:-r[1]/r[2],width:s/r[2],height:i/r[2]};return Kd(l,bh(o))>0}const ZU=({source:e,sourceHandle:t,target:s,targetHandle:i})=>`xy-edge__${e}${t||""}-${s}${i||""}`,WU=(e,t)=>t.some(s=>s.source===e.source&&s.target===e.target&&(s.sourceHandle===e.sourceHandle||!s.sourceHandle&&!e.sourceHandle)&&(s.targetHandle===e.targetHandle||!s.targetHandle&&!e.targetHandle)),VU=(e,t,s={})=>{var o;if(!e.source||!e.target)return(o=s.onError)==null||o.call(s,"006",Ai.error006()),t;const i=s.getEdgeId||ZU;let r;return K1(e)?r={...e}:r={...e,id:i(e)},WU(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function u_({sourceX:e,sourceY:t,targetX:s,targetY:i}){const[r,o,l,u]=c_({sourceX:e,sourceY:t,targetX:s,targetY:i});return[`M ${e},${t}L ${s},${i}`,r,o,l,u]}const ej={[tt.Left]:{x:-1,y:0},[tt.Right]:{x:1,y:0},[tt.Top]:{x:0,y:-1},[tt.Bottom]:{x:0,y:1}},qU=({source:e,sourcePosition:t=tt.Bottom,target:s})=>t===tt.Left||t===tt.Right?e.x<s.x?{x:1,y:0}:{x:-1,y:0}:e.y<s.y?{x:0,y:1}:{x:0,y:-1},tj=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function GU({source:e,sourcePosition:t=tt.Bottom,target:s,targetPosition:i=tt.Top,center:r,offset:o,stepPosition:l}){const u=ej[t],d=ej[i],h={x:e.x+u.x*o,y:e.y+u.y*o},m={x:s.x+d.x*o,y:s.y+d.y*o},p=qU({source:h,sourcePosition:t,target:m}),g=p.x!==0?"x":"y",x=p[g];let N=[],j,y;const k={x:0,y:0},_={x:0,y:0},[,,S,E]=c_({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(u[g]*d[g]===-1){g==="x"?(j=r.x??h.x+(m.x-h.x)*l,y=r.y??(h.y+m.y)/2):(j=r.x??(h.x+m.x)/2,y=r.y??h.y+(m.y-h.y)*l);const B=[{x:j,y:h.y},{x:j,y:m.y}],R=[{x:h.x,y},{x:m.x,y}];u[g]===x?N=g==="x"?B:R:N=g==="x"?R:B}else{const B=[{x:h.x,y:m.y}],R=[{x:m.x,y:h.y}];if(g==="x"?N=u.x===x?R:B:N=u.y===x?B:R,t===i){const I=Math.abs(e[g]-s[g]);if(I<=o){const z=Math.min(o-1,o-I);u[g]===x?k[g]=(h[g]>e[g]?-1:1)*z:_[g]=(m[g]>s[g]?-1:1)*z}}if(t!==i){const I=g==="x"?"y":"x",z=u[g]===d[I],D=h[I]>m[I],V=h[I]<m[I];(u[g]===1&&(!z&&D||z&&V)||u[g]!==1&&(!z&&V||z&&D))&&(N=g==="x"?B:R)}const M={x:h.x+k.x,y:h.y+k.y},F={x:m.x+_.x,y:m.y+_.y},L=Math.max(Math.abs(M.x-N[0].x),Math.abs(F.x-N[0].x)),A=Math.max(Math.abs(M.y-N[0].y),Math.abs(F.y-N[0].y));L>=A?(j=(M.x+F.x)/2,y=N[0].y):(j=N[0].x,y=(M.y+F.y)/2)}const O={x:h.x+k.x,y:h.y+k.y},P={x:m.x+_.x,y:m.y+_.y};return[[e,...O.x!==N[0].x||O.y!==N[0].y?[O]:[],...N,...P.x!==N[N.length-1].x||P.y!==N[N.length-1].y?[P]:[],s],j,y,S,E]}function KU(e,t,s,i){const r=Math.min(tj(e,t)/2,tj(t,s)/2,i),{x:o,y:l}=t;if(e.x===o&&o===s.x||e.y===l&&l===s.y)return`L${o} ${l}`;if(e.y===l){const h=e.x<s.x?-1:1,m=e.y<s.y?1:-1;return`L ${o+r*h},${l}Q ${o},${l} ${o},${l+r*m}`}const u=e.x<s.x?1:-1,d=e.y<s.y?-1:1;return`L ${o},${l+r*d}Q ${o},${l} ${o+r*u},${l}`}function pg({sourceX:e,sourceY:t,sourcePosition:s=tt.Bottom,targetX:i,targetY:r,targetPosition:o=tt.Top,borderRadius:l=5,centerX:u,centerY:d,offset:h=20,stepPosition:m=.5}){const[p,g,x,N,j]=GU({source:{x:e,y:t},sourcePosition:s,target:{x:i,y:r},targetPosition:o,center:{x:u,y:d},offset:h,stepPosition:m});let y=`M${p[0].x} ${p[0].y}`;for(let k=1;k<p.length-1;k++)y+=KU(p[k-1],p[k],p[k+1],l);return y+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[y,g,x,N,j]}function nj(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function YU(e){var p;const{sourceNode:t,targetNode:s}=e;if(!nj(t)||!nj(s))return null;const i=t.internals.handleBounds||sj(t.handles),r=s.internals.handleBounds||sj(s.handles),o=ij((i==null?void 0:i.source)??[],e.sourceHandle),l=ij(e.connectionMode===Qo.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!o||!l)return(p=e.onError)==null||p.call(e,"008",Ai.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const u=(o==null?void 0:o.position)||tt.Bottom,d=(l==null?void 0:l.position)||tt.Top,h=Wa(t,o,u),m=Wa(s,l,d);return{sourceX:h.x,sourceY:h.y,targetX:m.x,targetY:m.y,sourcePosition:u,targetPosition:d}}function sj(e){if(!e)return null;const t=[],s=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&s.push(i);return{source:t,target:s}}function Wa(e,t,s=tt.Left,i=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:l,height:u}=t??Ti(e);if(i)return{x:r+l/2,y:o+u/2};switch((t==null?void 0:t.position)??s){case tt.Top:return{x:r+l/2,y:o};case tt.Right:return{x:r+l,y:o+u/2};case tt.Bottom:return{x:r+l/2,y:o+u};case tt.Left:return{x:r,y:o+u/2}}}function ij(e,t){return e&&(t?e.find(s=>s.id===t):e[0])||null}function gg(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function XU(e,{id:t,defaultColor:s,defaultMarkerStart:i,defaultMarkerEnd:r}){const o=new Set;return e.reduce((l,u)=>([u.markerStart||i,u.markerEnd||r].forEach(d=>{if(d&&typeof d=="object"){const h=gg(d,t);o.has(h)||(l.push({id:h,color:d.color||s,...d}),o.add(h))}}),l),[]).sort((l,u)=>l.id.localeCompare(u.id))}const d_=1e3,QU=10,Px={nodeOrigin:[0,0],nodeExtent:Ac,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},JU={...Px,checkEquality:!0};function Lx(e,t){const s={...e};for(const i in t)t[i]!==void 0&&(s[i]=t[i]);return s}function eB(e,t,s){const i=Lx(Px,s);for(const r of e.values())if(r.parentId)Dx(r,e,t,i);else{const o=qc(r,i.nodeOrigin),l=Za(r.extent)?r.extent:i.nodeExtent,u=Ha(o,l,Ti(r));r.internals.positionAbsolute=u}}function tB(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const s=[],i=[];for(const r of e.handles){const o={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?s.push(o):r.type==="target"&&i.push(o)}return{source:s,target:i}}function zx(e){return e==="manual"}function xg(e,t,s,i={}){var m,p;const r=Lx(JU,i),o={i:0},l=new Map(t),u=r!=null&&r.elevateNodesOnSelect&&!zx(r.zIndexMode)?d_:0;let d=e.length>0,h=!1;t.clear(),s.clear();for(const g of e){let x=l.get(g.id);if(r.checkEquality&&g===(x==null?void 0:x.internals.userNode))t.set(g.id,x);else{const N=qc(g,r.nodeOrigin),j=Za(g.extent)?g.extent:r.nodeExtent,y=Ha(N,j,Ti(g));x={...r.defaults,...g,measured:{width:(m=g.measured)==null?void 0:m.width,height:(p=g.measured)==null?void 0:p.height},internals:{positionAbsolute:y,handleBounds:tB(g,x),z:h_(g,u,r.zIndexMode),userNode:g}},t.set(g.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(d=!1),g.parentId&&Dx(x,t,s,i,o),h||(h=g.selected??!1)}return{nodesInitialized:d,hasSelectedNodes:h}}function nB(e,t){if(!e.parentId)return;const s=t.get(e.parentId);s?s.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Dx(e,t,s,i,r){const{elevateNodesOnSelect:o,nodeOrigin:l,nodeExtent:u,zIndexMode:d}=Lx(Px,i),h=e.parentId,m=t.get(h);if(!m){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}nB(e,s),r&&!m.parentId&&m.internals.rootParentIndex===void 0&&d==="auto"&&(m.internals.rootParentIndex=++r.i,m.internals.z=m.internals.z+r.i*QU),r&&m.internals.rootParentIndex!==void 0&&(r.i=m.internals.rootParentIndex);const p=o&&!zx(d)?d_:0,{x:g,y:x,z:N}=sB(e,m,l,u,p,d),{positionAbsolute:j}=e.internals,y=g!==j.x||x!==j.y;(y||N!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:g,y:x}:j,z:N}})}function h_(e,t,s){const i=_i(e.zIndex)?e.zIndex:0;return zx(s)?i:i+(e.selected?t:0)}function sB(e,t,s,i,r,o){const{x:l,y:u}=t.internals.positionAbsolute,d=Ti(e),h=qc(e,s),m=Za(e.extent)?Ha(h,e.extent,d):h;let p=Ha({x:l+m.x,y:u+m.y},i,d);e.extent==="parent"&&(p=X1(p,d,t));const g=h_(e,r,o),x=t.internals.z??0;return{x:p.x,y:p.y,z:x>=g?x+1:g}}function Fx(e,t,s,i=[0,0]){var l;const r=[],o=new Map;for(const u of e){const d=t.get(u.parentId);if(!d)continue;const h=((l=o.get(u.parentId))==null?void 0:l.expandedRect)??Ic(d),m=Q1(h,u.rect);o.set(u.parentId,{expandedRect:m,parent:d})}return o.size>0&&o.forEach(({expandedRect:u,parent:d},h)=>{var S;const m=d.internals.positionAbsolute,p=Ti(d),g=d.origin??i,x=u.x<m.x?Math.round(Math.abs(m.x-u.x)):0,N=u.y<m.y?Math.round(Math.abs(m.y-u.y)):0,j=Math.max(p.width,Math.round(u.width)),y=Math.max(p.height,Math.round(u.height)),k=(j-p.width)*g[0],_=(y-p.height)*g[1];(x>0||N>0||k||_)&&(r.push({id:h,type:"position",position:{x:d.position.x-x+k,y:d.position.y-N+_}}),(S=s.get(h))==null||S.forEach(E=>{e.some(O=>O.id===E.id)||r.push({id:E.id,type:"position",position:{x:E.position.x+x,y:E.position.y+N}})})),(p.width<u.width||p.height<u.height||x||N)&&r.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:j+(x?g[0]*x-k:0),height:y+(N?g[1]*N-_:0)}})}),r}function iB(e,t,s,i,r,o,l){const u=i==null?void 0:i.querySelector(".xyflow__viewport");let d=!1;if(!u)return{changes:[],updatedInternals:d};const h=[],m=window.getComputedStyle(u),{m22:p}=new window.DOMMatrixReadOnly(m.transform),g=[];for(const x of e.values()){const N=t.get(x.id);if(!N)continue;if(N.hidden){t.set(N.id,{...N,internals:{...N.internals,handleBounds:void 0}}),d=!0;continue}const j=Ox(x.nodeElement),y=N.measured.width!==j.width||N.measured.height!==j.height;if(!!(j.width&&j.height&&(y||!N.internals.handleBounds||x.force))){const _=x.nodeElement.getBoundingClientRect(),S=Za(N.extent)?N.extent:o;let{positionAbsolute:E}=N.internals;if(N.parentId&&N.extent==="parent"){const P=t.get(N.parentId);P&&(E=X1(E,j,P))}else S&&(E=Ha(E,S,j));const O={...N,measured:j,internals:{...N.internals,positionAbsolute:E,handleBounds:{source:Qk("source",x.nodeElement,_,p,N.id),target:Qk("target",x.nodeElement,_,p,N.id)}}};t.set(N.id,O),N.parentId&&Dx(O,t,s,{nodeOrigin:r,zIndexMode:l}),d=!0,y&&(h.push({id:N.id,type:"dimensions",dimensions:j}),N.expandParent&&N.parentId&&g.push({id:N.id,parentId:N.parentId,rect:Ic(O,r)}))}}if(g.length>0){const x=Fx(g,t,s,r);h.push(...x)}return{changes:h,updatedInternals:d}}async function rB({delta:e,panZoom:t,transform:s,translateExtent:i,width:r,height:o}){if(!t||!e.x&&!e.y)return!1;const l=await t.setViewportConstrained({x:s[0]+e.x,y:s[1]+e.y,zoom:s[2]},[[0,0],[r,o]],i);return!!l&&(l.x!==s[0]||l.y!==s[1]||l.k!==s[2])}function rj(e,t,s,i,r,o){let l=r;const u=i.get(l)||new Map;i.set(l,u.set(s,t)),l=`${r}-${e}`;const d=i.get(l)||new Map;if(i.set(l,d.set(s,t)),o){l=`${r}-${e}-${o}`;const h=i.get(l)||new Map;i.set(l,h.set(s,t))}}function m_(e,t,s){e.clear(),t.clear();for(const i of s){const{source:r,target:o,sourceHandle:l=null,targetHandle:u=null}=i,d={edgeId:i.id,source:r,target:o,sourceHandle:l,targetHandle:u},h=`${r}-${l}--${o}-${u}`,m=`${o}-${u}--${r}-${l}`;rj("source",d,m,e,r,l),rj("target",d,h,e,o,u),t.set(i.id,i)}}function f_(e,t){if(!e.parentId)return!1;const s=t.get(e.parentId);return s?s.selected?!0:f_(s,t):!1}function aj(e,t,s){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===s)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function aB(e,t,s,i){const r=new Map;for(const[o,l]of e)if((l.selected||l.id===i)&&(!l.parentId||!f_(l,e))&&(l.draggable||t&&typeof l.draggable>"u")){const u=e.get(o);u&&r.set(o,{id:o,position:u.position||{x:0,y:0},distance:{x:s.x-u.internals.positionAbsolute.x,y:s.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 r}function ep({nodeId:e,dragItems:t,nodeLookup:s,dragging:i=!0}){var l,u,d;const r=[];for(const[h,m]of t){const p=(l=s.get(h))==null?void 0:l.internals.userNode;p&&r.push({...p,position:m.position,dragging:i})}if(!e)return[r[0],r];const o=(u=s.get(e))==null?void 0:u.internals.userNode;return[o?{...o,position:((d=t.get(e))==null?void 0:d.position)||o.position,dragging:i}:r[0],r]}function oB({dragItems:e,snapGrid:t,x:s,y:i}){const r=e.values().next().value;if(!r)return null;const o={x:s-r.distance.x,y:i-r.distance.y},l=Kc(o,t);return{x:l.x-o.x,y:l.y-o.y}}function lB({onNodeMouseDown:e,getStoreItems:t,onDragStart:s,onDrag:i,onDragStop:r}){let o={x:null,y:null},l=0,u=new Map,d=!1,h={x:0,y:0},m=null,p=!1,g=null,x=!1,N=!1,j=null;function y({noDragClassName:_,handleSelector:S,domNode:E,isSelectable:O,nodeId:P,nodeClickDistance:H=0}){g=Bs(E);function B({x:L,y:A}){const{nodeLookup:I,nodeExtent:z,snapGrid:D,snapToGrid:V,nodeOrigin:U,onNodeDrag:q,onSelectionDrag:te,onError:G,updateNodePositions:K}=t();o={x:L,y:A};let Z=!1;const ee=u.size>1,J=ee&&z?fg(Gc(u)):null,re=ee&&V?oB({dragItems:u,snapGrid:D,x:L,y:A}):null;for(const[ie,ne]of u){if(!I.has(ie))continue;let me={x:L-ne.distance.x,y:A-ne.distance.y};V&&(me=re?{x:Math.round(me.x+re.x),y:Math.round(me.y+re.y)}:Kc(me,D));let Ce=null;if(ee&&z&&!ne.extent&&J){const{positionAbsolute:fe}=ne.internals,ke=fe.x-J.x+z[0][0],ge=fe.x+ne.measured.width-J.x2+z[1][0],Ae=fe.y-J.y+z[0][1],be=fe.y+ne.measured.height-J.y2+z[1][1];Ce=[[ke,Ae],[ge,be]]}const{position:Fe,positionAbsolute:Me}=Y1({nodeId:ie,nextPosition:me,nodeLookup:I,nodeExtent:Ce||z,nodeOrigin:U,onError:G});Z=Z||ne.position.x!==Fe.x||ne.position.y!==Fe.y,ne.position=Fe,ne.internals.positionAbsolute=Me}if(N=N||Z,!!Z&&(K(u,!0),j&&(i||q||!P&&te))){const[ie,ne]=ep({nodeId:P,dragItems:u,nodeLookup:I});i==null||i(j,u,ie,ne),q==null||q(j,ie,ne),P||te==null||te(j,ne)}}async function R(){if(!m)return;const{transform:L,panBy:A,autoPanSpeed:I,autoPanOnNodeDrag:z}=t();if(!z){d=!1,cancelAnimationFrame(l);return}const[D,V]=Mx(h,m,I);(D!==0||V!==0)&&(o.x=(o.x??0)-D/L[2],o.y=(o.y??0)-V/L[2],await A({x:D,y:V})&&B(o)),l=requestAnimationFrame(R)}function M(L){var ee;const{nodeLookup:A,multiSelectionActive:I,nodesDraggable:z,transform:D,snapGrid:V,snapToGrid:U,selectNodesOnDrag:q,onNodeDragStart:te,onSelectionDragStart:G,unselectNodesAndEdges:K}=t();p=!0,(!q||!O)&&!I&&P&&((ee=A.get(P))!=null&&ee.selected||K()),O&&q&&P&&(e==null||e(P));const Z=pc(L.sourceEvent,{transform:D,snapGrid:V,snapToGrid:U,containerBounds:m});if(o=Z,u=aB(A,z,Z,P),u.size>0&&(s||te||!P&&G)){const[J,re]=ep({nodeId:P,dragItems:u,nodeLookup:A});s==null||s(L.sourceEvent,u,J,re),te==null||te(L.sourceEvent,J,re),P||G==null||G(L.sourceEvent,re)}}const F=$1().clickDistance(H).on("start",L=>{const{domNode:A,nodeDragThreshold:I,transform:z,snapGrid:D,snapToGrid:V}=t();m=(A==null?void 0:A.getBoundingClientRect())||null,x=!1,N=!1,j=L.sourceEvent,I===0&&M(L),o=pc(L.sourceEvent,{transform:z,snapGrid:D,snapToGrid:V,containerBounds:m}),h=Ei(L.sourceEvent,m)}).on("drag",L=>{const{autoPanOnNodeDrag:A,transform:I,snapGrid:z,snapToGrid:D,nodeDragThreshold:V,nodeLookup:U}=t(),q=pc(L.sourceEvent,{transform:I,snapGrid:z,snapToGrid:D,containerBounds:m});if(j=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||P&&!U.has(P))&&(x=!0),!x){if(!d&&A&&p&&(d=!0,R()),!p){const te=Ei(L.sourceEvent,m),G=te.x-h.x,K=te.y-h.y;Math.sqrt(G*G+K*K)>V&&M(L)}(o.x!==q.xSnapped||o.y!==q.ySnapped)&&u&&p&&(h=Ei(L.sourceEvent,m),B(q))}}).on("end",L=>{if(!p||x){x&&u.size>0&&t().updateNodePositions(u,!1);return}if(d=!1,p=!1,cancelAnimationFrame(l),u.size>0){const{nodeLookup:A,updateNodePositions:I,onNodeDragStop:z,onSelectionDragStop:D}=t();if(N&&(I(u,!1),N=!1),r||z||!P&&D){const[V,U]=ep({nodeId:P,dragItems:u,nodeLookup:A,dragging:!1});r==null||r(L.sourceEvent,u,V,U),z==null||z(L.sourceEvent,V,U),P||D==null||D(L.sourceEvent,U)}}}).filter(L=>{const A=L.target;return!L.button&&(!_||!aj(A,`.${_}`,E))&&(!S||aj(A,S,E))});g.call(F)}function k(){g==null||g.on(".drag",null)}return{update:y,destroy:k}}function cB(e,t,s){const i=[],r={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const o of t.values())Kd(r,Ic(o))>0&&i.push(o);return i}const uB=250;function dB(e,t,s,i){var u,d;let r=[],o=1/0;const l=cB(e,s,t+uB);for(const h of l){const m=[...((u=h.internals.handleBounds)==null?void 0:u.source)??[],...((d=h.internals.handleBounds)==null?void 0:d.target)??[]];for(const p of m){if(i.nodeId===p.nodeId&&i.type===p.type&&i.id===p.id)continue;const{x:g,y:x}=Wa(h,p,p.position,!0),N=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(x-e.y,2));N>t||(N<o?(r=[{...p,x:g,y:x}],o=N):N===o&&r.push({...p,x:g,y:x}))}}if(!r.length)return null;if(r.length>1){const h=i.type==="source"?"target":"source";return r.find(m=>m.type===h)??r[0]}return r[0]}function p_(e,t,s,i,r,o=!1){var h,m,p;const l=i.get(e);if(!l)return null;const u=r==="strict"?(h=l.internals.handleBounds)==null?void 0:h[t]:[...((m=l.internals.handleBounds)==null?void 0:m.source)??[],...((p=l.internals.handleBounds)==null?void 0:p.target)??[]],d=(s?u==null?void 0:u.find(g=>g.id===s):u==null?void 0:u[0])??null;return d&&o?{...d,...Wa(l,d,d.position,!0)}:d}function g_(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function hB(e,t){let s=null;return t?s=!0:e&&!t&&(s=!1),s}const x_=()=>!0;function mB(e,{connectionMode:t,connectionRadius:s,handleId:i,nodeId:r,edgeUpdaterType:o,isTarget:l,domNode:u,nodeLookup:d,lib:h,autoPanOnConnect:m,flowId:p,panBy:g,cancelConnection:x,onConnectStart:N,onConnect:j,onConnectEnd:y,isValidConnection:k=x_,onReconnectEnd:_,updateConnection:S,getTransform:E,getFromHandle:O,autoPanSpeed:P,dragThreshold:H=1,handleDomNode:B}){const R=i_(e.target);let M=0,F;const{x:L,y:A}=Ei(e),I=g_(o,B),z=u==null?void 0:u.getBoundingClientRect();let D=!1;if(!z||!I)return;const V=p_(r,I,i,d,t);if(!V)return;let U=Ei(e,z),q=!1,te=null,G=!1,K=null;function Z(){if(!m||!z)return;const[Fe,Me]=Mx(U,z,P);g({x:Fe,y:Me}),M=requestAnimationFrame(Z)}const ee={...V,nodeId:r,type:I,position:V.position},J=d.get(r);let ie={inProgress:!0,isValid:null,from:Wa(J,ee,tt.Left,!0),fromHandle:ee,fromPosition:ee.position,fromNode:J,to:U,toHandle:null,toPosition:Gk[ee.position],toNode:null,pointer:U};function ne(){D=!0,S(ie),N==null||N(e,{nodeId:r,handleId:i,handleType:I})}H===0&&ne();function me(Fe){if(!D){const{x:be,y:qe}=Ei(Fe),ft=be-L,gt=qe-A;if(!(ft*ft+gt*gt>H*H))return;ne()}if(!O()||!ee){Ce(Fe);return}const Me=E();U=Ei(Fe,z),F=dB(Yc(U,Me,!1,[1,1]),s,d,ee),q||(Z(),q=!0);const fe=v_(Fe,{handle:F,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:l?"target":"source",isValidConnection:k,doc:R,lib:h,flowId:p,nodeLookup:d});K=fe.handleDomNode,te=fe.connection,G=hB(!!F,fe.isValid);const ke=d.get(r),ge=ke?Wa(ke,ee,tt.Left,!0):ie.from,Ae={...ie,from:ge,isValid:G,to:fe.toHandle&&G?el({x:fe.toHandle.x,y:fe.toHandle.y},Me):U,toHandle:fe.toHandle,toPosition:G&&fe.toHandle?fe.toHandle.position:Gk[ee.position],toNode:fe.toHandle?d.get(fe.toHandle.nodeId):null,pointer:U};S(Ae),ie=Ae}function Ce(Fe){if(!("touches"in Fe&&Fe.touches.length>0)){if(D){(F||K)&&te&&G&&(j==null||j(te));const{inProgress:Me,...fe}=ie,ke={...fe,toPosition:ie.toHandle?ie.toPosition:null};y==null||y(Fe,ke),o&&(_==null||_(Fe,ke))}x(),cancelAnimationFrame(M),q=!1,G=!1,te=null,K=null,R.removeEventListener("mousemove",me),R.removeEventListener("mouseup",Ce),R.removeEventListener("touchmove",me),R.removeEventListener("touchend",Ce)}}R.addEventListener("mousemove",me),R.addEventListener("mouseup",Ce),R.addEventListener("touchmove",me),R.addEventListener("touchend",Ce)}function v_(e,{handle:t,connectionMode:s,fromNodeId:i,fromHandleId:r,fromType:o,doc:l,lib:u,flowId:d,isValidConnection:h=x_,nodeLookup:m}){const p=o==="target",g=t?l.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,y:N}=Ei(e),j=l.elementFromPoint(x,N),y=j!=null&&j.classList.contains(`${u}-flow__handle`)?j:g,k={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const _=g_(void 0,y),S=y.getAttribute("data-nodeid"),E=y.getAttribute("data-handleid"),O=y.classList.contains("connectable"),P=y.classList.contains("connectableend");if(!S||!_)return k;const H={source:p?S:i,sourceHandle:p?E:r,target:p?i:S,targetHandle:p?r:E};k.connection=H;const R=O&&P&&(s===Qo.Strict?p&&_==="source"||!p&&_==="target":S!==i||E!==r);k.isValid=R&&h(H),k.toHandle=p_(S,_,E,m,s,!0)}return k}const vg={onPointerDown:mB,isValid:v_};function fB({domNode:e,panZoom:t,getTransform:s,getViewScale:i}){const r=Bs(e);function o({translateExtent:u,width:d,height:h,zoomStep:m=1,pannable:p=!0,zoomable:g=!0,inversePan:x=!1}){const N=S=>{if(S.sourceEvent.type!=="wheel"||!t)return;const E=s(),O=S.sourceEvent.ctrlKey&&Tc()?10:1,P=-S.sourceEvent.deltaY*(S.sourceEvent.deltaMode===1?.05:S.sourceEvent.deltaMode?1:.002)*m,H=E[2]*Math.pow(2,P*O);t.scaleTo(H)};let j=[0,0];const y=S=>{(S.sourceEvent.type==="mousedown"||S.sourceEvent.type==="touchstart")&&(j=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY])},k=S=>{const E=s();if(S.sourceEvent.type!=="mousemove"&&S.sourceEvent.type!=="touchmove"||!t)return;const O=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY],P=[O[0]-j[0],O[1]-j[1]];j=O;const H=i()*Math.max(E[2],Math.log(E[2]))*(x?-1:1),B={x:E[0]-P[0]*H,y:E[1]-P[1]*H},R=[[0,0],[d,h]];t.setViewportConstrained({x:B.x,y:B.y,zoom:E[2]},R,u)},_=W1().on("start",y).on("zoom",p?k:null).on("zoom.wheel",g?N:null);r.call(_,{})}function l(){r.on("zoom",null)}return{update:o,destroy:l,pointer:ji}}const kh=e=>({x:e.x,y:e.y,zoom:e.k}),tp=({x:e,y:t,zoom:s})=>vh.translate(e,t).scale(s),Zr=(e,t)=>e.target.closest(`.${t}`),y_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),pB=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,np=(e,t=0,s=pB,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(s).on("end",i):e},b_=e=>{const t=e.ctrlKey&&Tc()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function gB({zoomPanValues:e,noWheelClassName:t,d3Selection:s,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:o,zoomOnPinch:l,onPanZoomStart:u,onPanZoom:d,onPanZoomEnd:h}){return m=>{if(Zr(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=s.property("__zoom").k||1;if(m.ctrlKey&&l){const y=ji(m),k=b_(m),_=p*Math.pow(2,k);i.scaleTo(s,_,y,m);return}const g=m.deltaMode===1?20:1;let x=r===Da.Vertical?0:m.deltaX*g,N=r===Da.Horizontal?0:m.deltaY*g;!Tc()&&m.shiftKey&&r!==Da.Vertical&&(x=m.deltaY*g,N=0),i.translateBy(s,-(x/p)*o,-(N/p)*o,{internal:!0});const j=kh(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?d==null||d(m,j):(e.isPanScrolling=!0,u==null||u(m,j)),e.panScrollTimeout=setTimeout(()=>{h==null||h(m,j),e.isPanScrolling=!1},150)}}function xB({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:s}){return function(i,r){const o=i.type==="wheel",l=!t&&o&&!i.ctrlKey,u=Zr(i,e);if(i.ctrlKey&&o&&u&&i.preventDefault(),l||u)return null;i.preventDefault(),s.call(this,i,r)}}function vB({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:s}){return i=>{var o,l,u;if((o=i.sourceEvent)!=null&&o.internal)return;const r=kh(i.transform);e.mouseButton=((l=i.sourceEvent)==null?void 0:l.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((u=i.sourceEvent)==null?void 0:u.type)==="mousedown"&&t(!0),s&&(s==null||s(i.sourceEvent,r))}}function yB({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:s,onTransformChange:i,onPanZoom:r}){return o=>{var l,u;e.usedRightMouseButton=!!(s&&y_(t,e.mouseButton??0)),(l=o.sourceEvent)!=null&&l.sync||i([o.transform.x,o.transform.y,o.transform.k]),r&&!((u=o.sourceEvent)!=null&&u.internal)&&(r==null||r(o.sourceEvent,kh(o.transform)))}}function bB({zoomPanValues:e,panOnDrag:t,panOnScroll:s,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:o}){return l=>{var u;if(!((u=l.sourceEvent)!=null&&u.internal)&&(e.isZoomingOrPanning=!1,o&&y_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&o(l.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const d=kh(l.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,d)},s?150:0)}}}function kB({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:s,zoomOnPinch:i,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:l,userSelectionActive:u,noWheelClassName:d,noPanClassName:h,lib:m,connectionInProgress:p}){return g=>{var k;const x=t||s,N=i&&g.ctrlKey,j=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(Zr(g,`${m}-flow__node`)||Zr(g,`${m}-flow__edge`)||Zr(g,`${m}-flow__selection`)||Zr(g,`${m}-flow__nodesselection`)))return!0;if(!r&&!x&&!o&&!l&&!i||u||p&&!j||Zr(g,d)&&j||Zr(g,h)&&(!j||o&&j&&!t)||!i&&g.ctrlKey&&j)return!1;if(!i&&g.type==="touchstart"&&((k=g.touches)==null?void 0:k.length)>1)return g.preventDefault(),!1;if(!x&&!o&&!N&&j||!r&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(r)&&!r.includes(g.button)&&g.type==="mousedown")return!1;const y=Array.isArray(r)&&r.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||j||e)&&y}}function jB({domNode:e,minZoom:t,maxZoom:s,translateExtent:i,viewport:r,onPanZoom:o,onPanZoomStart:l,onPanZoomEnd:u,onDraggingChange:d}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect();let p=[[0,0],[m.width,m.height]];const g=typeof ResizeObserver<"u"?new ResizeObserver(A=>{const I=A[0];I&&(p=[[0,0],[I.contentRect.width,I.contentRect.height]])}):null;g==null||g.observe(e);const x=W1().extent(()=>p).scaleExtent([t,s]).translateExtent(i),N=Bs(e).call(x);E({x:r.x,y:r.y,zoom:Jo(r.zoom,t,s)},[[0,0],[m.width,m.height]],i);const j=N.on("wheel.zoom"),y=N.on("dblclick.zoom");x.wheelDelta(b_);async function k(A,I){return N?new Promise(z=>{x==null||x.interpolate((I==null?void 0:I.interpolate)==="linear"?fc:Nd).transform(np(N,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>z(!0)),A)}):!1}function _({noWheelClassName:A,noPanClassName:I,onPaneContextMenu:z,userSelectionActive:D,panOnScroll:V,panOnDrag:U,panOnScrollMode:q,panOnScrollSpeed:te,preventScrolling:G,zoomOnPinch:K,zoomOnScroll:Z,zoomOnDoubleClick:ee,panActivationKeyPressed:J=!1,zoomActivationKeyPressed:re,lib:ie,onTransformChange:ne,connectionInProgress:me,paneClickDistance:Ce,selectionOnDrag:Fe}){D&&!h.isZoomingOrPanning&&S();const Me=V&&!re&&!D;x.clickDistance(Fe?1/0:!_i(Ce)||Ce<0?0:Ce);const fe=Me?gB({zoomPanValues:h,noWheelClassName:A,d3Selection:N,d3Zoom:x,panOnScrollMode:q,panOnScrollSpeed:te,zoomOnPinch:K,onPanZoomStart:l,onPanZoom:o,onPanZoomEnd:u}):xB({noWheelClassName:A,preventScrolling:G,d3ZoomHandler:j});N.on("wheel.zoom",fe,{passive:!1});const ke=vB({zoomPanValues:h,onDraggingChange:d,onPanZoomStart:l});x.on("start",ke);const ge=yB({zoomPanValues:h,panOnDrag:U,onPaneContextMenu:!!z,onPanZoom:o,onTransformChange:ne});x.on("zoom",ge);const Ae=bB({zoomPanValues:h,panOnDrag:U,panOnScroll:V,onPaneContextMenu:z,onPanZoomEnd:u,onDraggingChange:d});x.on("end",Ae);const be=kB({panActivationKeyPressed:J,zoomActivationKeyPressed:re,panOnDrag:U,zoomOnScroll:Z,panOnScroll:V,zoomOnDoubleClick:ee,zoomOnPinch:K,userSelectionActive:D,noPanClassName:I,noWheelClassName:A,lib:ie,connectionInProgress:me});x.filter(be),ee?N.on("dblclick.zoom",y):N.on("dblclick.zoom",null)}function S(){x.on("zoom",null)}async function E(A,I,z){const D=tp(A),V=x==null?void 0:x.constrain()(D,I,z);return V&&await k(V),V}async function O(A,I){const z=tp(A);return await k(z,I),z}function P(A){if(N){const I=tp(A),z=N.property("__zoom");(z.k!==A.zoom||z.x!==A.x||z.y!==A.y)&&(x==null||x.transform(N,I,null,{sync:!0}))}}function H(){const A=N?Z1(N.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}async function B(A,I){return N?new Promise(z=>{x==null||x.interpolate((I==null?void 0:I.interpolate)==="linear"?fc:Nd).scaleTo(np(N,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>z(!0)),A)}):!1}async function R(A,I){return N?new Promise(z=>{x==null||x.interpolate((I==null?void 0:I.interpolate)==="linear"?fc:Nd).scaleBy(np(N,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>z(!0)),A)}):!1}function M(A){x==null||x.scaleExtent(A)}function F(A){x==null||x.translateExtent(A)}function L(A){const I=!_i(A)||A<0?0:A;x==null||x.clickDistance(I)}return{update:_,destroy:S,setViewport:O,setViewportConstrained:E,getViewport:H,scaleTo:B,scaleBy:R,setScaleExtent:M,setTranslateExtent:F,syncViewport:P,setClickDistance:L}}var tl;(function(e){e.Line="line",e.Handle="handle"})(tl||(tl={}));function NB({width:e,prevWidth:t,height:s,prevHeight:i,affectsX:r,affectsY:o}){const l=e-t,u=s-i,d=[l>0?1:l<0?-1:0,u>0?1:u<0?-1:0];return l&&r&&(d[0]=d[0]*-1),u&&o&&(d[1]=d[1]*-1),d}function oj(e){const t=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:s,affectsX:i,affectsY:r}}function Fr(e,t){return Math.max(0,t-e)}function Ur(e,t){return Math.max(0,e-t)}function dd(e,t,s){return Math.max(0,t-e,e-s)}function lj(e,t){return e?!t:t}function wB(e,t,s,i,r,o,l,u){let{affectsX:d,affectsY:h}=t;const{isHorizontal:m,isVertical:p}=t,g=m&&p,{xSnapped:x,ySnapped:N}=s,{minWidth:j,maxWidth:y,minHeight:k,maxHeight:_}=i,{x:S,y:E,width:O,height:P,aspectRatio:H}=e;let B=Math.floor(m?x-e.pointerX:0),R=Math.floor(p?N-e.pointerY:0);const M=O+(d?-B:B),F=P+(h?-R:R),L=-o[0]*O,A=-o[1]*P;let I=dd(M,j,y),z=dd(F,k,_);if(l){let U=0,q=0;d&&B<0?U=Fr(S+B+L,l[0][0]):!d&&B>0&&(U=Ur(S+M+L,l[1][0])),h&&R<0?q=Fr(E+R+A,l[0][1]):!h&&R>0&&(q=Ur(E+F+A,l[1][1])),I=Math.max(I,U),z=Math.max(z,q)}if(u){let U=0,q=0;d&&B>0?U=Ur(S+B,u[0][0]):!d&&B<0&&(U=Fr(S+M,u[1][0])),h&&R>0?q=Ur(E+R,u[0][1]):!h&&R<0&&(q=Fr(E+F,u[1][1])),I=Math.max(I,U),z=Math.max(z,q)}if(r){if(m){const U=dd(M/H,k,_)*H;if(I=Math.max(I,U),l){let q=0;!d&&!h||d&&!h&&g?q=Ur(E+A+M/H,l[1][1])*H:q=Fr(E+A+(d?B:-B)/H,l[0][1])*H,I=Math.max(I,q)}if(u){let q=0;!d&&!h||d&&!h&&g?q=Fr(E+M/H,u[1][1])*H:q=Ur(E+(d?B:-B)/H,u[0][1])*H,I=Math.max(I,q)}}if(p){const U=dd(F*H,j,y)/H;if(z=Math.max(z,U),l){let q=0;!d&&!h||h&&!d&&g?q=Ur(S+F*H+L,l[1][0])/H:q=Fr(S+(h?R:-R)*H+L,l[0][0])/H,z=Math.max(z,q)}if(u){let q=0;!d&&!h||h&&!d&&g?q=Fr(S+F*H,u[1][0])/H:q=Ur(S+(h?R:-R)*H,u[0][0])/H,z=Math.max(z,q)}}}R=R+(R<0?z:-z),B=B+(B<0?I:-I),r&&(g?M>F*H?R=(lj(d,h)?-B:B)/H:B=(lj(d,h)?-R:R)*H:m?(R=B/H,h=d):(B=R*H,d=h));const D=d?S+B:S,V=h?E+R:E;return{width:O+(d?-B:B),height:P+(h?-R:R),x:o[0]*B*(d?-1:1)+D,y:o[1]*R*(h?-1:1)+V}}const k_={width:0,height:0,x:0,y:0},SB={...k_,pointerX:0,pointerY:0,aspectRatio:1};function _B(e,t,s){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,o=e.measured.width??0,l=e.measured.height??0,u=s[0]*o,d=s[1]*l;return[[i-u,r-d],[i+o-u,r+l-d]]}function EB({domNode:e,nodeId:t,getStoreItems:s,onChange:i,onEnd:r}){const o=Bs(e);let l={controlDirection:oj("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function u({controlPosition:h,boundaries:m,keepAspectRatio:p,resizeDirection:g,onResizeStart:x,onResize:N,onResizeEnd:j,shouldResize:y}){let k={...k_},_={...SB};l={boundaries:m,resizeDirection:g,keepAspectRatio:p,controlDirection:oj(h)};let S,E=null,O=[],P,H,B,R=!1;const M=$1().on("start",F=>{const{nodeLookup:L,transform:A,snapGrid:I,snapToGrid:z,nodeOrigin:D,paneDomNode:V}=s();if(S=L.get(t),!S)return;E=(V==null?void 0:V.getBoundingClientRect())??null;const{xSnapped:U,ySnapped:q}=pc(F.sourceEvent,{transform:A,snapGrid:I,snapToGrid:z,containerBounds:E});k={width:S.measured.width??0,height:S.measured.height??0,x:S.position.x??0,y:S.position.y??0},_={...k,pointerX:U,pointerY:q,aspectRatio:k.width/k.height},P=void 0,H=Za(S.extent)?S.extent:void 0,S.parentId&&(S.extent==="parent"||S.expandParent)&&(P=L.get(S.parentId)),P&&S.extent==="parent"&&(H=[[0,0],[P.measured.width,P.measured.height]]),O=[],B=void 0;for(const[te,G]of L)if(G.parentId===t&&(O.push({id:te,position:{...G.position},extent:G.extent}),G.extent==="parent"||G.expandParent)){const K=_B(G,S,G.origin??D);B?B=[[Math.min(K[0][0],B[0][0]),Math.min(K[0][1],B[0][1])],[Math.max(K[1][0],B[1][0]),Math.max(K[1][1],B[1][1])]]:B=K}x==null||x(F,{...k})}).on("drag",F=>{const{transform:L,snapGrid:A,snapToGrid:I,nodeOrigin:z}=s(),D=pc(F.sourceEvent,{transform:L,snapGrid:A,snapToGrid:I,containerBounds:E}),V=[];if(!S)return;const{x:U,y:q,width:te,height:G}=k,K={},Z=S.origin??z,{width:ee,height:J,x:re,y:ie}=wB(_,l.controlDirection,D,l.boundaries,l.keepAspectRatio,Z,H,B),ne=ee!==te,me=J!==G,Ce=re!==U&&ne,Fe=ie!==q&&me;if(!Ce&&!Fe&&!ne&&!me)return;if((Ce||Fe||Z[0]===1||Z[1]===1)&&(K.x=Ce?re:k.x,K.y=Fe?ie:k.y,k.x=K.x,k.y=K.y,O.length>0)){const ge=re-U,Ae=ie-q;for(const be of O)be.position={x:be.position.x-ge+Z[0]*(ee-te),y:be.position.y-Ae+Z[1]*(J-G)},V.push(be)}if((ne||me)&&(K.width=ne&&(!l.resizeDirection||l.resizeDirection==="horizontal")?ee:k.width,K.height=me&&(!l.resizeDirection||l.resizeDirection==="vertical")?J:k.height,k.width=K.width,k.height=K.height),P&&S.expandParent){const ge=Z[0]*(K.width??0);K.x&&K.x<ge&&(k.x=ge,_.x=_.x-(K.x-ge));const Ae=Z[1]*(K.height??0);K.y&&K.y<Ae&&(k.y=Ae,_.y=_.y-(K.y-Ae))}const Me=NB({width:k.width,prevWidth:te,height:k.height,prevHeight:G,affectsX:l.controlDirection.affectsX,affectsY:l.controlDirection.affectsY}),fe={...k,direction:Me};(y==null?void 0:y(F,fe))!==!1&&(R=!0,N==null||N(F,fe),i(K,V))}).on("end",F=>{R&&(j==null||j(F,{...k}),r==null||r({...k}),R=!1)});o.call(M)}function d(){o.on(".drag",null)}return{update:u,destroy:d}}var sp={exports:{}},ip={},rp={exports:{}},ap={};/**
|
|
222
|
-
* @license React
|
|
223
|
-
* use-sync-external-store-shim.production.js
|
|
224
|
-
*
|
|
225
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
226
|
-
*
|
|
227
|
-
* This source code is licensed under the MIT license found in the
|
|
228
|
-
* LICENSE file in the root directory of this source tree.
|
|
229
|
-
*/var cj;function CB(){if(cj)return ap;cj=1;var e=zc();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var s=typeof Object.is=="function"?Object.is:t,i=e.useState,r=e.useEffect,o=e.useLayoutEffect,l=e.useDebugValue;function u(p,g){var x=g(),N=i({inst:{value:x,getSnapshot:g}}),j=N[0].inst,y=N[1];return o(function(){j.value=x,j.getSnapshot=g,d(j)&&y({inst:j})},[p,x,g]),r(function(){return d(j)&&y({inst:j}),p(function(){d(j)&&y({inst:j})})},[p]),l(x),x}function d(p){var g=p.getSnapshot;p=p.value;try{var x=g();return!s(p,x)}catch{return!0}}function h(p,g){return g()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return ap.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,ap}var uj;function AB(){return uj||(uj=1,rp.exports=CB()),rp.exports}/**
|
|
230
|
-
* @license React
|
|
231
|
-
* use-sync-external-store-shim/with-selector.production.js
|
|
232
|
-
*
|
|
233
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
234
|
-
*
|
|
235
|
-
* This source code is licensed under the MIT license found in the
|
|
236
|
-
* LICENSE file in the root directory of this source tree.
|
|
237
|
-
*/var dj;function $B(){if(dj)return ip;dj=1;var e=zc(),t=AB();function s(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var i=typeof Object.is=="function"?Object.is:s,r=t.useSyncExternalStore,o=e.useRef,l=e.useEffect,u=e.useMemo,d=e.useDebugValue;return ip.useSyncExternalStoreWithSelector=function(h,m,p,g,x){var N=o(null);if(N.current===null){var j={hasValue:!1,value:null};N.current=j}else j=N.current;N=u(function(){function k(P){if(!_){if(_=!0,S=P,P=g(P),x!==void 0&&j.hasValue){var H=j.value;if(x(H,P))return E=H}return E=P}if(H=E,i(S,P))return H;var B=g(P);return x!==void 0&&x(H,B)?(S=P,H):(S=P,E=B)}var _=!1,S,E,O=p===void 0?null:p;return[function(){return k(m())},O===null?void 0:function(){return k(O())}]},[m,p,g,x]);var y=r(h,N[0],N[1]);return l(function(){j.hasValue=!0,j.value=y},[y]),d(y),y},ip}var hj;function IB(){return hj||(hj=1,sp.exports=$B()),sp.exports}var TB=IB();const MB=$g(TB),RB={},mj=e=>{let t;const s=new Set,i=(m,p)=>{const g=typeof m=="function"?m(t):m;if(!Object.is(g,t)){const x=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),s.forEach(N=>N(t,x))}},r=()=>t,d={setState:i,getState:r,getInitialState:()=>h,subscribe:m=>(s.add(m),()=>s.delete(m)),destroy:()=>{(RB?"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."),s.clear()}},h=t=e(i,r,d);return d},OB=e=>e?mj(e):mj,{useDebugValue:PB}=hO,{useSyncExternalStoreWithSelector:LB}=MB,zB=e=>e;function j_(e,t=zB,s){const i=LB(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,s);return PB(i),i}const fj=(e,t)=>{const s=OB(e),i=(r,o=t)=>j_(s,r,o);return Object.assign(i,s),i},DB=(e,t)=>e?fj(e,t):fj;function un(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[i,r]of e)if(!Object.is(r,t.get(i)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0}const s=Object.keys(e);if(s.length!==Object.keys(t).length)return!1;for(const i of s)if(!Object.prototype.hasOwnProperty.call(t,i)||!Object.is(e[i],t[i]))return!1;return!0}const jh=v.createContext(null),FB=jh.Provider,N_=Ai.error001("react");function At(e,t){const s=v.useContext(jh);if(s===null)throw new Error(N_);return j_(s,e,t)}function Xt(){const e=v.useContext(jh);if(e===null)throw new Error(N_);return v.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const pj={display:"none"},UB={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},w_="react-flow__node-desc",S_="react-flow__edge-desc",BB="react-flow__aria-live",HB=e=>e.ariaLiveMessage,ZB=e=>e.ariaLabelConfig;function WB({rfId:e}){const t=At(HB);return n.jsx("div",{id:`${BB}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:UB,children:t})}function VB({rfId:e,disableKeyboardA11y:t}){const s=At(ZB);return n.jsxs(n.Fragment,{children:[n.jsx("div",{id:`${w_}-${e}`,style:pj,children:t?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),n.jsx("div",{id:`${S_}-${e}`,style:pj,children:s["edge.a11yDescription.default"]}),!t&&n.jsx(WB,{rfId:e})]})}const Nh=v.forwardRef(({position:e="top-left",children:t,className:s,style:i,...r},o)=>{const l=`${e}`.split("-");return n.jsx("div",{className:_n(["react-flow__panel",s,...l]),style:i,ref:o,...r,children:t})});Nh.displayName="Panel";const gj="https://reactflow.dev?utm_source=attribution";function qB({proOptions:e,position:t="bottom-right"}){return v.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:n.jsx(Nh,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${gj}`,children:n.jsx("a",{href:gj,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const GB=e=>{const t=[],s=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&s.push(i);return{selectedNodes:t,selectedEdges:s}},hd=e=>e.id;function KB(e,t){return un(e.selectedNodes.map(hd),t.selectedNodes.map(hd))&&un(e.selectedEdges.map(hd),t.selectedEdges.map(hd))}function YB({onSelectionChange:e}){const t=Xt(),{selectedNodes:s,selectedEdges:i}=At(GB,KB);return v.useEffect(()=>{const r={nodes:s,edges:i};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(o=>o(r))},[s,i,e]),null}const XB=e=>!!e.onSelectionChangeHandlers;function QB({onSelectionChange:e}){const t=At(XB);return e||t?n.jsx(YB,{onSelectionChange:e}):null}const __=[0,0],JB={x:0,y:0,zoom:1},eH=["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"],xj=[...eH,"rfId"],tH=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}),vj={translateExtent:Ac,nodeOrigin:__,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function nH(e){const{setNodes:t,setEdges:s,setMinZoom:i,setMaxZoom:r,setTranslateExtent:o,setNodeExtent:l,reset:u,setDefaultNodesAndEdges:d}=At(tH,un),h=Xt();v.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{m.current=vj,u()}),[]);const m=v.useRef(vj);return v.useEffect(()=>{for(const p of xj){const g=e[p],x=m.current[p];g!==x&&(typeof e[p]>"u"||(p==="nodes"?t(g):p==="edges"?s(g):p==="minZoom"?i(g):p==="maxZoom"?r(g):p==="translateExtent"?o(g):p==="nodeExtent"?l(g):p==="ariaLabelConfig"?h.setState({ariaLabelConfig:FU(g)}):p==="fitView"?h.setState({fitViewQueued:g}):p==="fitViewOptions"?h.setState({fitViewOptions:g}):h.setState({[p]:g})))}m.current=e},xj.map(p=>e[p])),null}function yj(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function sH(e){var i;const[t,s]=v.useState(e==="system"?null:e);return v.useEffect(()=>{if(e!=="system"){s(e);return}const r=yj(),o=()=>s(r!=null&&r.matches?"dark":"light");return o(),r==null||r.addEventListener("change",o),()=>{r==null||r.removeEventListener("change",o)}},[e]),t!==null?t:(i=yj())!=null&&i.matches?"dark":"light"}const bj=typeof document<"u"?document:null;function Mc(e=null,t={target:bj,actInsideInputWithModifier:!0}){const[s,i]=v.useState(!1),r=v.useRef(!1),o=v.useRef(new Set([])),[l,u]=v.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace(/\+/g,`
|
|
238
|
-
`).replace(`
|
|
239
|
-
|
|
240
|
-
`,`
|
|
241
|
-
+`).split(`
|
|
242
|
-
`)),m=h.reduce((p,g)=>p.concat(...g),[]);return[h,m]}return[[],[]]},[e]);return v.useEffect(()=>{const d=(t==null?void 0:t.target)??bj,h=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=x=>{var y,k;if(r.current=x.ctrlKey||x.metaKey||x.shiftKey||x.altKey,(!r.current||r.current&&!h)&&r_(x))return!1;const j=jj(x.code,u);if(o.current.add(x[j]),kj(l,o.current,!1)){const _=((k=(y=x.composedPath)==null?void 0:y.call(x))==null?void 0:k[0])||x.target,S=(_==null?void 0:_.nodeName)==="BUTTON"||(_==null?void 0:_.nodeName)==="A";t.preventDefault!==!1&&(r.current||!S)&&x.preventDefault(),i(!0)}},p=x=>{const N=jj(x.code,u);kj(l,o.current,!0)?(i(!1),o.current.clear()):o.current.delete(x[N]),x.key==="Meta"&&o.current.clear(),r.current=!1},g=()=>{o.current.clear(),i(!1)};return d==null||d.addEventListener("keydown",m),d==null||d.addEventListener("keyup",p),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{d==null||d.removeEventListener("keydown",m),d==null||d.removeEventListener("keyup",p),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,i]),s}function kj(e,t,s){return e.filter(i=>s||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function jj(e,t){return t.includes(e)?"code":"key"}const iH=()=>{const e=Xt();return v.useMemo(()=>({zoomIn:async t=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:s}=e.getState();return s?s.scaleBy(1/1.2,t):!1},zoomTo:async(t,s)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,s):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,s)=>{const{transform:[i,r,o],panZoom:l}=e.getState();return l?(await l.setViewport({x:t.x??i,y:t.y??r,zoom:t.zoom??o},s),!0):!1},getViewport:()=>{const[t,s,i]=e.getState().transform;return{x:t,y:s,zoom:i}},setCenter:async(t,s,i)=>e.getState().setCenter(t,s,i),fitBounds:async(t,s)=>{const{width:i,height:r,minZoom:o,maxZoom:l,panZoom:u}=e.getState(),d=Rx(t,i,r,o,l,(s==null?void 0:s.padding)??.1);return u?(await u.setViewport(d,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),!0):!1},screenToFlowPosition:(t,s={})=>{const{transform:i,snapGrid:r,snapToGrid:o,domNode:l}=e.getState();if(!l)return t;const{x:u,y:d}=l.getBoundingClientRect(),h={x:t.x-u,y:t.y-d},m=s.snapGrid??r,p=s.snapToGrid??o;return Yc(h,i,p,m)},flowToScreenPosition:t=>{const{transform:s,domNode:i}=e.getState();if(!i)return t;const{x:r,y:o}=i.getBoundingClientRect(),l=el(t,s);return{x:l.x+r,y:l.y+o}}}),[])};function E_(e,t){const s=[],i=new Map,r=[];for(const o of e)if(o.type==="add"){r.push(o);continue}else if(o.type==="remove"||o.type==="replace")i.set(o.id,[o]);else{const l=i.get(o.id);l?l.push(o):i.set(o.id,[o])}for(const o of t){const l=i.get(o.id);if(!l){s.push(o);continue}if(l[0].type==="remove")continue;if(l[0].type==="replace"){s.push({...l[0].item});continue}const u={...o};for(const d of l)rH(d,u);s.push(u)}return r.length&&r.forEach(o=>{o.index!==void 0?s.splice(o.index,0,{...o.item}):s.push({...o.item})}),s}function rH(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 aH(e,t){return E_(e,t)}function oH(e,t){return E_(e,t)}function Ea(e,t){return{id:e,type:"select",selected:t}}function Co(e,t=new Set,s=!1){const i=[];for(const[r,o]of e){const l=t.has(r);!(o.selected===void 0&&!l)&&o.selected!==l&&(s&&(o.selected=l),i.push(Ea(o.id,l)))}return i}function Nj({items:e=[],lookup:t}){var r;const s=[],i=new Map(e.map(o=>[o.id,o]));for(const[o,l]of e.entries()){const u=t.get(l.id),d=((r=u==null?void 0:u.internals)==null?void 0:r.userNode)??u;d!==void 0&&d!==l&&s.push({id:l.id,item:l,type:"replace"}),d===void 0&&s.push({item:l,type:"add",index:o})}for(const[o]of t)i.get(o)===void 0&&s.push({id:o,type:"remove"});return s}function wj(e){return{id:e.id,type:"remove"}}const lH=e_();function cH(e,t,s={}){return VU(e,t,{...s,onError:s.onError??lH})}const Sj=e=>IU(e),uH=e=>K1(e);function C_(e){return v.forwardRef(e)}const A_=typeof window<"u"?v.useLayoutEffect:v.useEffect;function _j(e){const[t,s]=v.useState(BigInt(0)),[i]=v.useState(()=>dH(()=>s(r=>r+BigInt(1))));return A_(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function dH(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:s=>{t.push(s),e()}}}const $_=v.createContext(null);function hH({children:e}){const t=Xt(),s=v.useCallback(u=>{const{nodes:d=[],setNodes:h,hasDefaultNodes:m,onNodesChange:p,nodeLookup:g,fitViewQueued:x,onNodesChangeMiddlewareMap:N}=t.getState();let j=d;for(const k of u)j=typeof k=="function"?k(j):k;let y=Nj({items:j,lookup:g});for(const k of N.values())y=k(y);m&&h(j),y.length>0?p==null||p(y):x&&window.requestAnimationFrame(()=>{const{fitViewQueued:k,nodes:_,setNodes:S}=t.getState();k&&S(_)})},[]),i=_j(s),r=v.useCallback(u=>{const{edges:d=[],setEdges:h,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:g}=t.getState();let x=d;for(const N of u)x=typeof N=="function"?N(x):N;m?h(x):p&&p(Nj({items:x,lookup:g}))},[]),o=_j(r),l=v.useMemo(()=>({nodeQueue:i,edgeQueue:o}),[]);return n.jsx($_.Provider,{value:l,children:e})}function mH(){const e=v.useContext($_);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const fH=e=>!!e.panZoom;function Ux(){const e=iH(),t=Xt(),s=mH(),i=At(fH),r=v.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),l=p=>{s.nodeQueue.push(p)},u=p=>{s.edgeQueue.push(p)},d=p=>{var k,_;const{nodeLookup:g,nodeOrigin:x}=t.getState(),N=Sj(p)?p:g.get(p.id),j=N.parentId?n_(N.position,N.measured,N.parentId,g,x):N.position,y={...N,position:j,width:((k=N.measured)==null?void 0:k.width)??N.width,height:((_=N.measured)==null?void 0:_.height)??N.height};return Ic(y)},h=(p,g,x={replace:!1})=>{l(N=>N.map(j=>{if(j.id===p){const y=typeof g=="function"?g(j):g;return x.replace&&Sj(y)?y:{...j,...y}}return j}))},m=(p,g,x={replace:!1})=>{u(N=>N.map(j=>{if(j.id===p){const y=typeof g=="function"?g(j):g;return x.replace&&uH(y)?y:{...j,...y}}return j}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var g;return(g=o(p))==null?void 0:g.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(g=>({...g}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:l,setEdges:u,addNodes:p=>{const g=Array.isArray(p)?p:[p];s.nodeQueue.push(x=>[...x,...g])},addEdges:p=>{const g=Array.isArray(p)?p:[p];s.edgeQueue.push(x=>[...x,...g])},toObject:()=>{const{nodes:p=[],edges:g=[],transform:x}=t.getState(),[N,j,y]=x;return{nodes:p.map(k=>({...k})),edges:g.map(k=>({...k})),viewport:{x:N,y:j,zoom:y}}},deleteElements:async({nodes:p=[],edges:g=[]})=>{const{nodes:x,edges:N,onNodesDelete:j,onEdgesDelete:y,triggerNodeChanges:k,triggerEdgeChanges:_,onDelete:S,onBeforeDelete:E}=t.getState(),{nodes:O,edges:P}=await PU({nodesToRemove:p,edgesToRemove:g,nodes:x,edges:N,onBeforeDelete:E}),H=P.length>0,B=O.length>0;if(H){const R=P.map(wj);y==null||y(P),_(R)}if(B){const R=O.map(wj);j==null||j(O),k(R)}return(B||H)&&(S==null||S({nodes:O,edges:P})),{deletedNodes:O,deletedEdges:P}},getIntersectingNodes:(p,g=!0,x)=>{const N=Yk(p),j=N?p:d(p),y=x!==void 0;return j?(x||t.getState().nodes).filter(k=>{const _=t.getState().nodeLookup.get(k.id);if(_&&!N&&(k.id===p.id||!_.internals.positionAbsolute))return!1;const S=Ic(y?k:_),E=Kd(S,j);return g&&E>0||E>=S.width*S.height||E>=j.width*j.height}):[]},isNodeIntersecting:(p,g,x=!0)=>{const j=Yk(p)?p:d(p);if(!j)return!1;const y=Kd(j,g);return x&&y>0||y>=g.width*g.height||y>=j.width*j.height},updateNode:h,updateNodeData:(p,g,x={replace:!1})=>{h(p,N=>{const j=typeof g=="function"?g(N):g;return x.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},x)},updateEdge:m,updateEdgeData:(p,g,x={replace:!1})=>{m(p,N=>{const j=typeof g=="function"?g(N):g;return x.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},x)},getNodesBounds:p=>{const{nodeLookup:g,nodeOrigin:x}=t.getState();return TU(p,{nodeLookup:g,nodeOrigin:x})},getHandleConnections:({type:p,id:g,nodeId:x})=>{var N;return Array.from(((N=t.getState().connectionLookup.get(`${x}-${p}${g?`-${g}`:""}`))==null?void 0:N.values())??[])},getNodeConnections:({type:p,handleId:g,nodeId:x})=>{var N;return Array.from(((N=t.getState().connectionLookup.get(`${x}${p?g?`-${p}-${g}`:`-${p}`:""}`))==null?void 0:N.values())??[])},fitView:async p=>{const g=t.getState().fitViewResolver??DU();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:g}),s.nodeQueue.push(x=>[...x]),g.promise}}},[]);return v.useMemo(()=>({...r,...e,viewportInitialized:i}),[i])}const Ej=e=>e.selected,pH=typeof window<"u"?window:void 0;function gH({deleteKeyCode:e,multiSelectionKeyCode:t}){const s=Xt(),{deleteElements:i}=Ux(),r=Mc(e,{actInsideInputWithModifier:!1}),o=Mc(t,{target:pH});v.useEffect(()=>{if(r){const{edges:l,nodes:u}=s.getState();i({nodes:u.filter(Ej),edges:l.filter(Ej)}),s.setState({nodesSelectionActive:!1})}},[r]),v.useEffect(()=>{s.setState({multiSelectionActive:o})},[o])}function xH(e){const t=Xt();v.useEffect(()=>{const s=()=>{var r,o,l,u;if(!e.current||!(((o=(r=e.current).checkVisibility)==null?void 0:o.call(r))??!0))return!1;const i=Ox(e.current);(i.height===0||i.width===0)&&((u=(l=t.getState()).onError)==null||u.call(l,"004",Ai.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){s(),window.addEventListener("resize",s);const i=new ResizeObserver(()=>s());return i.observe(e.current),()=>{window.removeEventListener("resize",s),i&&e.current&&i.unobserve(e.current)}}},[])}const wh={position:"absolute",width:"100%",height:"100%",top:0,left:0},vH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function yH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panActivationKeyPressed:r,panOnScrollSpeed:o=.5,panOnScrollMode:l=Da.Free,zoomOnDoubleClick:u=!0,panOnDrag:d=!0,defaultViewport:h,translateExtent:m,minZoom:p,maxZoom:g,zoomActivationKeyCode:x,preventScrolling:N=!0,children:j,noWheelClassName:y,noPanClassName:k,onViewportChange:_,isControlledViewport:S,paneClickDistance:E,selectionOnDrag:O}){const P=Xt(),H=v.useRef(null),{userSelectionActive:B,lib:R,connectionInProgress:M}=At(vH,un),F=Mc(x),L=v.useRef();xH(H);const A=v.useCallback(I=>{_==null||_({x:I[0],y:I[1],zoom:I[2]}),S||P.setState({transform:I})},[_,S]);return v.useEffect(()=>{if(H.current){L.current=jB({domNode:H.current,minZoom:p,maxZoom:g,translateExtent:m,viewport:h,onDraggingChange:V=>P.setState(U=>U.paneDragging===V?U:{paneDragging:V}),onPanZoomStart:(V,U)=>{const{onViewportChangeStart:q,onMoveStart:te}=P.getState();te==null||te(V,U),q==null||q(U)},onPanZoom:(V,U)=>{const{onViewportChange:q,onMove:te}=P.getState();te==null||te(V,U),q==null||q(U)},onPanZoomEnd:(V,U)=>{const{onViewportChangeEnd:q,onMoveEnd:te}=P.getState();te==null||te(V,U),q==null||q(U)}});const{x:I,y:z,zoom:D}=L.current.getViewport();return P.setState({panZoom:L.current,transform:[I,z,D],domNode:H.current.closest(".react-flow")}),()=>{var V;(V=L.current)==null||V.destroy()}}},[]),v.useEffect(()=>{var I;(I=L.current)==null||I.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:s,panOnScroll:i,panActivationKeyPressed:r,panOnScrollSpeed:o,panOnScrollMode:l,zoomOnDoubleClick:u,panOnDrag:d,zoomActivationKeyPressed:F,preventScrolling:N,noPanClassName:k,userSelectionActive:B,noWheelClassName:y,lib:R,onTransformChange:A,connectionInProgress:M,selectionOnDrag:O,paneClickDistance:E})},[e,t,s,i,r,o,l,u,d,F,N,k,B,y,R,A,M,O,E]),n.jsx("div",{className:"react-flow__renderer",ref:H,style:wh,children:j})}const bH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function kH(){const{userSelectionActive:e,userSelectionRect:t}=At(bH,un);return e&&t?n.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 op=(e,t)=>s=>{s.target===t.current&&(e==null||e(s))},jH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function NH({isSelecting:e,selectionKeyPressed:t,selectionMode:s=$c.Full,panOnDrag:i,autoPanOnSelection:r,paneClickDistance:o,selectionOnDrag:l,onSelectionStart:u,onSelectionEnd:d,onPaneClick:h,onPaneContextMenu:m,onPaneScroll:p,onPaneMouseEnter:g,onPaneMouseMove:x,onPaneMouseLeave:N,children:j}){const y=v.useRef(0),k=Xt(),{userSelectionActive:_,elementsSelectable:S,dragging:E,panBy:O,autoPanSpeed:P}=At(jH,un),H=S&&(e||_),B=v.useRef(null),R=v.useRef(),M=v.useRef(new Set),F=v.useRef(new Set),L=v.useRef(!1),A=v.useRef(!1),I=v.useRef({x:0,y:0}),z=v.useRef(!1),D=ne=>{if(A.current||L.current||k.getState().connection.inProgress){A.current=!1,L.current=!1;return}h==null||h(ne),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},V=ne=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){ne.preventDefault();return}m==null||m(ne)},U=p?ne=>p(ne):void 0,q=ne=>{A.current&&(ne.stopPropagation(),A.current=!1)},te=ne=>{var be,qe;if(ne.pointerType==="touch"&&i!==!1&&!t)return;const{domNode:me,transform:Ce}=k.getState();if(R.current=me==null?void 0:me.getBoundingClientRect(),!R.current)return;const Fe=ne.target===B.current;if(!Fe&&!!ne.target.closest(".nokey")||!e||!(l&&Fe||t)||ne.button!==0||!ne.isPrimary)return;(qe=(be=ne.target)==null?void 0:be.setPointerCapture)==null||qe.call(be,ne.pointerId),A.current=!1;const{x:ke,y:ge}=Ei(ne.nativeEvent,R.current),Ae=Yc({x:ke,y:ge},Ce);k.setState({userSelectionRect:{width:0,height:0,startX:Ae.x,startY:Ae.y,x:ke,y:ge}}),Fe||(ne.stopPropagation(),ne.preventDefault())};function G(ne,me){const{userSelectionRect:Ce}=k.getState();if(!Ce)return;const{transform:Fe,nodeLookup:Me,edgeLookup:fe,connectionLookup:ke,triggerNodeChanges:ge,triggerEdgeChanges:Ae,defaultEdgeOptions:be}=k.getState(),qe={x:Ce.startX,y:Ce.startY},{x:ft,y:gt}=el(qe,Fe),Rt={startX:qe.x,startY:qe.y,x:ne<ft?ne:ft,y:me<gt?me:gt,width:Math.abs(ne-ft),height:Math.abs(me-gt)},En=M.current,rt=F.current;M.current=new Set(Tx(Me,Rt,Fe,s===$c.Partial,!0).map(rn=>rn.id)),F.current=new Set;const Pt=(be==null?void 0:be.selectable)??!0;for(const rn of M.current){const Zt=ke.get(rn);if(Zt)for(const{edgeId:Qt}of Zt.values()){const Ut=fe.get(Qt);Ut&&(Ut.selectable??Pt)&&F.current.add(Qt)}}if(!Xk(En,M.current)){const rn=Co(Me,M.current,!0);ge(rn)}if(!Xk(rt,F.current)){const rn=Co(fe,F.current);Ae(rn)}k.setState({userSelectionRect:Rt,userSelectionActive:!0,nodesSelectionActive:!1})}function K(){if(!r||!R.current)return;const[ne,me]=Mx(I.current,R.current,P);O({x:ne,y:me}).then(Ce=>{if(!A.current||!Ce){y.current=requestAnimationFrame(K);return}const{x:Fe,y:Me}=I.current;G(Fe,Me),y.current=requestAnimationFrame(K)})}const Z=()=>{cancelAnimationFrame(y.current),y.current=0,z.current=!1};v.useEffect(()=>()=>Z(),[]);const ee=ne=>{const{userSelectionRect:me,transform:Ce,resetSelectedElements:Fe}=k.getState();if(!R.current||!me)return;const{x:Me,y:fe}=Ei(ne.nativeEvent,R.current);I.current={x:Me,y:fe};const ke=el({x:me.startX,y:me.startY},Ce);if(!A.current){const ge=t?0:o;if(Math.hypot(Me-ke.x,fe-ke.y)<=ge)return;Fe(),u==null||u(ne)}A.current=!0,z.current||(K(),z.current=!0),G(Me,fe)},J=ne=>{var me,Ce;if(!H){ne.target===B.current&&k.getState().connection.inProgress&&(L.current=!0);return}ne.button===0&&((Ce=(me=ne.target)==null?void 0:me.releasePointerCapture)==null||Ce.call(me,ne.pointerId),!_&&ne.target===B.current&&k.getState().userSelectionRect&&(D==null||D(ne)),k.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(d==null||d(ne),k.setState({nodesSelectionActive:M.current.size>0})),Z())},re=ne=>{var me,Ce;(Ce=(me=ne.target)==null?void 0:me.releasePointerCapture)==null||Ce.call(me,ne.pointerId),Z()},ie=i===!0||Array.isArray(i)&&i.includes(0);return n.jsxs("div",{className:_n(["react-flow__pane",{draggable:ie,dragging:E,selection:e}]),onClick:H?void 0:op(D,B),onContextMenu:op(V,B),onWheel:op(U,B),onPointerEnter:H?void 0:g,onPointerMove:H?ee:x,onPointerUp:J,onPointerCancel:H?re:void 0,onPointerDownCapture:H?te:void 0,onClickCapture:H?q:void 0,onPointerLeave:N,ref:B,style:wh,children:[j,n.jsx(kH,{})]})}function yg({id:e,store:t,unselect:s=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:o,multiSelectionActive:l,nodeLookup:u,onError:d}=t.getState(),h=u.get(e);if(!h){d==null||d("012",Ai.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(s||h.selected&&l)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var m;return(m=i==null?void 0:i.current)==null?void 0:m.blur()})):r([e])}function I_({nodeRef:e,disabled:t=!1,noDragClassName:s,handleSelector:i,nodeId:r,isSelectable:o,nodeClickDistance:l}){const u=Xt(),[d,h]=v.useState(!1),m=v.useRef();return v.useEffect(()=>{if(!t)return m.current=lB({getStoreItems:()=>u.getState(),onNodeMouseDown:p=>{yg({id:p,store:u,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}}),()=>{var p;(p=m.current)==null||p.destroy(),m.current=void 0}},[t,u,e]),v.useEffect(()=>{t||!e.current||!m.current||m.current.update({noDragClassName:s,handleSelector:i,domNode:e.current,isSelectable:o,nodeId:r,nodeClickDistance:l})},[s,i,t,o,e,r,l]),d}const wH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function T_(){const e=Xt();return v.useCallback(s=>{const{nodeExtent:i,snapToGrid:r,snapGrid:o,nodesDraggable:l,onError:u,updateNodePositions:d,nodeLookup:h,nodeOrigin:m}=e.getState(),p=new Map,g=wH(l),x=r?o[0]:5,N=r?o[1]:5,j=s.direction.x*x*s.factor,y=s.direction.y*N*s.factor;for(const[,k]of h){if(!g(k))continue;let _={x:k.internals.positionAbsolute.x+j,y:k.internals.positionAbsolute.y+y};r&&(_=Kc(_,o));const{position:S,positionAbsolute:E}=Y1({nodeId:k.id,nextPosition:_,nodeLookup:h,nodeExtent:i,nodeOrigin:m,onError:u});k.position=S,k.internals.positionAbsolute=E,p.set(k.id,k)}d(p)},[])}const Bx=v.createContext(null),SH=Bx.Provider;Bx.Consumer;const M_=()=>v.useContext(Bx),_H=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),R_=v.createContext(null);function EH({children:e}){const t=At(_H,un);return n.jsx(R_.Provider,{value:t,children:e})}function CH(){const e=v.useContext(R_);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const AH={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},$H=(e,t,s)=>i=>{const{connectionClickStartHandle:r,connectionMode:o,connection:l}=i,{fromHandle:u,toHandle:d,isValid:h}=l;if(!u&&!r)return AH;const m=(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.type)===s;return{connectingFrom:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===s,connectingTo:m,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===s,isPossibleEndHandle:o===Qo.Strict?(u==null?void 0:u.type)!==s:e!==(u==null?void 0:u.nodeId)||t!==(u==null?void 0:u.id),connectionInProcess:!!u,clickConnectionInProcess:!!r,valid:m&&h}};function IH({type:e="source",position:t=tt.Top,isValidConnection:s,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:o=!0,id:l,onConnect:u,children:d,className:h,onMouseDown:m,onTouchStart:p,...g},x){var z,D;const N=l||null,j=e==="target",y=Xt(),k=M_(),{connectOnClick:_,noPanClassName:S,rfId:E}=CH(),{connectingFrom:O,connectingTo:P,clickConnecting:H,isPossibleEndHandle:B,connectionInProcess:R,clickConnectionInProcess:M,valid:F}=At($H(k,N,e),un);k||(D=(z=y.getState()).onError)==null||D.call(z,"010",Ai.error010());const L=V=>{const{defaultEdgeOptions:U,onConnect:q,hasDefaultEdges:te}=y.getState(),G={...U,...V};if(te){const{edges:K,setEdges:Z,onError:ee}=y.getState();Z(cH(G,K,{onError:ee}))}q==null||q(G),u==null||u(G)},A=V=>{if(!k)return;const U=a_(V.nativeEvent);if(r&&(U&&V.button===0||!U)){const q=y.getState();vg.onPointerDown(V.nativeEvent,{handleDomNode:V.currentTarget,autoPanOnConnect:q.autoPanOnConnect,connectionMode:q.connectionMode,connectionRadius:q.connectionRadius,domNode:q.domNode,nodeLookup:q.nodeLookup,lib:q.lib,isTarget:j,handleId:N,nodeId:k,flowId:q.rfId,panBy:q.panBy,cancelConnection:q.cancelConnection,onConnectStart:q.onConnectStart,onConnectEnd:(...te)=>{var G,K;return(K=(G=y.getState()).onConnectEnd)==null?void 0:K.call(G,...te)},updateConnection:q.updateConnection,onConnect:L,isValidConnection:s||((...te)=>{var G,K;return((K=(G=y.getState()).isValidConnection)==null?void 0:K.call(G,...te))??!0}),getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:q.autoPanSpeed,dragThreshold:q.connectionDragThreshold})}U?m==null||m(V):p==null||p(V)},I=V=>{const{onClickConnectStart:U,onClickConnectEnd:q,connectionClickStartHandle:te,connectionMode:G,isValidConnection:K,lib:Z,rfId:ee,nodeLookup:J,connection:re}=y.getState();if(!k||!te&&!r)return;if(!te){U==null||U(V.nativeEvent,{nodeId:k,handleId:N,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:k,type:e,id:N}});return}const ie=i_(V.target),ne=s||K,{connection:me,isValid:Ce}=vg.isValid(V.nativeEvent,{handle:{nodeId:k,id:N,type:e},connectionMode:G,fromNodeId:te.nodeId,fromHandleId:te.id||null,fromType:te.type,isValidConnection:ne,flowId:ee,doc:ie,lib:Z,nodeLookup:J});Ce&&me&&L(me);const Fe=structuredClone(re);delete Fe.inProgress,Fe.toPosition=Fe.toHandle?Fe.toHandle.position:null,q==null||q(V,Fe),y.setState({connectionClickStartHandle:null})};return n.jsx("div",{"data-handleid":N,"data-nodeid":k,"data-handlepos":t,"data-id":`${E}-${k}-${N}-${e}`,className:_n(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,h,{source:!j,target:j,connectable:i,connectablestart:r,connectableend:o,clickconnecting:H,connectingfrom:O,connectingto:P,valid:F,connectionindicator:i&&(!R||B)&&(R||M?o:r)}]),onMouseDown:A,onTouchStart:A,onClick:_?I:void 0,ref:x,...g,children:d})}const Qr=v.memo(C_(IH));function TH({data:e,isConnectable:t,sourcePosition:s=tt.Bottom}){return n.jsxs(n.Fragment,{children:[e==null?void 0:e.label,n.jsx(Qr,{type:"source",position:s,isConnectable:t})]})}function MH({data:e,isConnectable:t,targetPosition:s=tt.Top,sourcePosition:i=tt.Bottom}){return n.jsxs(n.Fragment,{children:[n.jsx(Qr,{type:"target",position:s,isConnectable:t}),e==null?void 0:e.label,n.jsx(Qr,{type:"source",position:i,isConnectable:t})]})}function RH(){return null}function OH({data:e,isConnectable:t,targetPosition:s=tt.Top}){return n.jsxs(n.Fragment,{children:[n.jsx(Qr,{type:"target",position:s,isConnectable:t}),e==null?void 0:e.label]})}const Yd={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Cj={input:TH,default:MH,output:OH,group:RH};function PH(e){var t,s,i,r;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((s=e.style)==null?void 0:s.height)}:{width:e.width??((i=e.style)==null?void 0:i.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const LH=e=>{const{width:t,height:s,x:i,y:r}=Gc(e.nodeLookup,{filter:o=>!!o.selected});return{width:_i(t)?t:null,height:_i(s)?s:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${r}px)`}};function zH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:s}){const i=Xt(),{width:r,height:o,transformString:l,userSelectionActive:u}=At(LH,un),d=T_(),h=v.useRef(null);v.useEffect(()=>{var x;s||(x=h.current)==null||x.focus({preventScroll:!0})},[s]);const m=!u&&r!==null&&o!==null;if(I_({nodeRef:h,disabled:!m}),!m)return null;const p=e?x=>{const N=i.getState().nodes.filter(j=>j.selected);e(x,N)}:void 0,g=x=>{Object.prototype.hasOwnProperty.call(Yd,x.key)&&(x.preventDefault(),d({direction:Yd[x.key],factor:x.shiftKey?4:1}))};return n.jsx("div",{className:_n(["react-flow__nodesselection","react-flow__container",t]),style:{transform:l},children:n.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:s?void 0:-1,onKeyDown:s?void 0:g,style:{width:r,height:o}})})}const Aj=typeof window<"u"?window:void 0,DH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function O_({children:e,onPaneClick:t,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:l,paneClickDistance:u,deleteKeyCode:d,selectionKeyCode:h,selectionOnDrag:m,selectionMode:p,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:y,elementsSelectable:k,zoomOnScroll:_,zoomOnPinch:S,panOnScroll:E,panOnScrollSpeed:O,panOnScrollMode:P,zoomOnDoubleClick:H,panOnDrag:B,autoPanOnSelection:R,defaultViewport:M,translateExtent:F,minZoom:L,maxZoom:A,preventScrolling:I,onSelectionContextMenu:z,noWheelClassName:D,noPanClassName:V,disableKeyboardA11y:U,onViewportChange:q,isControlledViewport:te}){const{nodesSelectionActive:G,userSelectionActive:K}=At(DH,un),Z=Mc(h,{target:Aj}),ee=Mc(j,{target:Aj}),J=ee||B,re=ee||E,ie=m&&J!==!0,ne=Z||K||ie;return gH({deleteKeyCode:d,multiSelectionKeyCode:N}),n.jsx(yH,{onPaneContextMenu:o,elementsSelectable:k,zoomOnScroll:_,zoomOnPinch:S,panOnScroll:re,panActivationKeyPressed:ee,panOnScrollSpeed:O,panOnScrollMode:P,zoomOnDoubleClick:H,panOnDrag:!Z&&J,defaultViewport:M,translateExtent:F,minZoom:L,maxZoom:A,zoomActivationKeyCode:y,preventScrolling:I,noWheelClassName:D,noPanClassName:V,onViewportChange:q,isControlledViewport:te,paneClickDistance:u,selectionOnDrag:ie,children:n.jsxs(NH,{onSelectionStart:g,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:l,panOnDrag:J,autoPanOnSelection:R,isSelecting:!!ne,selectionMode:p,selectionKeyPressed:Z,paneClickDistance:u,selectionOnDrag:ie,children:[e,G&&n.jsx(zH,{onSelectionContextMenu:z,noPanClassName:V,disableKeyboardA11y:U})]})})}O_.displayName="FlowRenderer";const FH=v.memo(O_),UH=e=>t=>e?Tx(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(s=>s.id):Array.from(t.nodeLookup.keys());function BH(e){return At(v.useCallback(UH(e),[e]),un)}const HH=e=>e.updateNodeInternals;function ZH(){const e=At(HH),[t]=v.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(s=>{const i=new Map;s.forEach(r=>{const o=r.target.getAttribute("data-id");i.set(o,{id:o,nodeElement:r.target,force:!0})}),e(i)}));return v.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function WH({node:e,nodeType:t,hasDimensions:s,resizeObserver:i}){const r=Xt(),o=v.useRef(null),l=v.useRef(null),u=v.useRef(e.sourcePosition),d=v.useRef(e.targetPosition),h=v.useRef(t),m=s&&!!e.internals.handleBounds;return v.useEffect(()=>{o.current&&!e.hidden&&(!m||l.current!==o.current)&&(l.current&&(i==null||i.unobserve(l.current)),i==null||i.observe(o.current),l.current=o.current)},[m,e.hidden]),v.useEffect(()=>()=>{l.current&&(i==null||i.unobserve(l.current),l.current=null)},[]),v.useEffect(()=>{if(o.current){const p=h.current!==t,g=u.current!==e.sourcePosition,x=d.current!==e.targetPosition;(p||g||x)&&(h.current=t,u.current=e.sourcePosition,d.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function VH({id:e,onClick:t,onMouseEnter:s,onMouseMove:i,onMouseLeave:r,onContextMenu:o,onDoubleClick:l,nodesDraggable:u,elementsSelectable:d,nodesConnectable:h,nodesFocusable:m,resizeObserver:p,noDragClassName:g,noPanClassName:x,disableKeyboardA11y:N,rfId:j,nodeTypes:y,nodeClickDistance:k,onError:_}){const{node:S,internals:E,isParent:O}=At(ne=>{const me=ne.nodeLookup.get(e),Ce=ne.parentLookup.has(e);return{node:me,internals:me.internals,isParent:Ce}},un);let P=S.type||"default",H=(y==null?void 0:y[P])||Cj[P];H===void 0&&(_==null||_("003",Ai.error003(P)),P="default",H=(y==null?void 0:y.default)||Cj.default);const B=!!(S.draggable||u&&typeof S.draggable>"u"),R=!!(S.selectable||d&&typeof S.selectable>"u"),M=!!(S.connectable||h&&typeof S.connectable>"u"),F=!!(S.focusable||m&&typeof S.focusable>"u"),L=Xt(),A=t_(S),I=WH({node:S,nodeType:P,hasDimensions:A,resizeObserver:p}),z=I_({nodeRef:I,disabled:S.hidden||!B,noDragClassName:g,handleSelector:S.dragHandle,nodeId:e,isSelectable:R,nodeClickDistance:k}),D=T_();if(S.hidden)return null;const V=Ti(S),U=PH(S),q=R||B||t||s||i||r,te=s?ne=>s(ne,{...E.userNode}):void 0,G=i?ne=>i(ne,{...E.userNode}):void 0,K=r?ne=>r(ne,{...E.userNode}):void 0,Z=o?ne=>o(ne,{...E.userNode}):void 0,ee=l?ne=>l(ne,{...E.userNode}):void 0,J=ne=>{const{selectNodesOnDrag:me,nodeDragThreshold:Ce}=L.getState();R&&(!me||!B||Ce>0)&&yg({id:e,store:L,nodeRef:I}),t&&t(ne,{...E.userNode})},re=ne=>{if(!(r_(ne.nativeEvent)||N)){if(V1.includes(ne.key)&&R){const me=ne.key==="Escape";yg({id:e,store:L,unselect:me,nodeRef:I})}else if(B&&S.selected&&Object.prototype.hasOwnProperty.call(Yd,ne.key)){ne.preventDefault();const{ariaLabelConfig:me}=L.getState();L.setState({ariaLiveMessage:me["node.a11yDescription.ariaLiveMessage"]({direction:ne.key.replace("Arrow","").toLowerCase(),x:~~E.positionAbsolute.x,y:~~E.positionAbsolute.y})}),D({direction:Yd[ne.key],factor:ne.shiftKey?4:1})}}},ie=()=>{var ke;if(N||!((ke=I.current)!=null&&ke.matches(":focus-visible")))return;const{transform:ne,width:me,height:Ce,autoPanOnNodeFocus:Fe,setCenter:Me}=L.getState();if(!Fe)return;Tx(new Map([[e,S]]),{x:0,y:0,width:me,height:Ce},ne,!0).length>0||Me(S.position.x+V.width/2,S.position.y+V.height/2,{zoom:ne[2]})};return n.jsx("div",{className:_n(["react-flow__node",`react-flow__node-${P}`,{[x]:B},S.className,{selected:S.selected,selectable:R,parent:O,draggable:B,dragging:z}]),ref:I,style:{zIndex:E.z,transform:`translate(${E.positionAbsolute.x}px,${E.positionAbsolute.y}px)`,pointerEvents:q?"all":"none",visibility:A?"visible":"hidden",...S.style,...U},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:te,onMouseMove:G,onMouseLeave:K,onContextMenu:Z,onClick:J,onDoubleClick:ee,onKeyDown:F?re:void 0,tabIndex:F?0:void 0,onFocus:F?ie:void 0,role:S.ariaRole??(F?"group":void 0),"aria-roledescription":"node","aria-describedby":N?void 0:`${w_}-${j}`,"aria-label":S.ariaLabel,...S.domAttributes,children:n.jsx(SH,{value:e,children:n.jsx(H,{id:e,data:S.data,type:P,positionAbsoluteX:E.positionAbsolute.x,positionAbsoluteY:E.positionAbsolute.y,selected:S.selected??!1,selectable:R,draggable:B,deletable:S.deletable??!0,isConnectable:M,sourcePosition:S.sourcePosition,targetPosition:S.targetPosition,dragging:z,dragHandle:S.dragHandle,zIndex:E.z,parentId:S.parentId,...V})})})}var qH=v.memo(VH);const GH=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function P_(e){const{nodesConnectable:t,nodesFocusable:s,elementsSelectable:i,onError:r}=At(GH,un),o=BH(e.onlyRenderVisibleElements),l=ZH();return n.jsx("div",{className:"react-flow__nodes",style:wh,children:o.map(u=>n.jsx(qH,{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:l,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:s,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:r},u))})}P_.displayName="NodeRenderer";const KH=v.memo(P_);function YH(e){return At(v.useCallback(s=>{if(!e)return s.edges.map(r=>r.id);const i=[];if(s.width&&s.height)for(const r of s.edges){const o=s.nodeLookup.get(r.source),l=s.nodeLookup.get(r.target);o&&l&&HU({sourceNode:o,targetNode:l,width:s.width,height:s.height,transform:s.transform})&&i.push(r.id)}return i},[e]),un)}const XH=({color:e="none",strokeWidth:t=1})=>{const s={strokeWidth:t,...e&&{stroke:e}};return n.jsx("polyline",{className:"arrow",style:s,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},QH=({color:e="none",strokeWidth:t=1})=>{const s={strokeWidth:t,...e&&{stroke:e,fill:e}};return n.jsx("polyline",{className:"arrowclosed",style:s,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},$j={[qd.Arrow]:XH,[qd.ArrowClosed]:QH};function JH(e){const t=Xt();return v.useMemo(()=>{var r,o;return Object.prototype.hasOwnProperty.call($j,e)?$j[e]:((o=(r=t.getState()).onError)==null||o.call(r,"009",Ai.error009(e)),null)},[e])}const e9=({id:e,type:t,color:s,width:i=12.5,height:r=12.5,markerUnits:o="strokeWidth",strokeWidth:l,orient:u="auto-start-reverse"})=>{const d=JH(t);return d?n.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:u,refX:"0",refY:"0",children:n.jsx(d,{color:s,strokeWidth:l})}):null},L_=({defaultColor:e,rfId:t})=>{const s=At(o=>o.edges),i=At(o=>o.defaultEdgeOptions),r=v.useMemo(()=>XU(s,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[s,i,t,e]);return r.length?n.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:n.jsx("defs",{children:r.map(o=>n.jsx(e9,{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};L_.displayName="MarkerDefinitions";var t9=v.memo(L_);function z_({x:e,y:t,label:s,labelStyle:i,labelShowBg:r=!0,labelBgStyle:o,labelBgPadding:l=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...m}){const[p,g]=v.useState({x:1,y:0,width:0,height:0}),x=_n(["react-flow__edge-textwrapper",h]),N=v.useRef(null);return v.useEffect(()=>{if(N.current){const j=N.current.getBBox();g({x:j.x,y:j.y,width:j.width,height:j.height})}},[s]),s?n.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:x,visibility:p.width?"visible":"hidden",...m,children:[r&&n.jsx("rect",{width:p.width+2*l[0],x:-l[0],y:-l[1],height:p.height+2*l[1],className:"react-flow__edge-textbg",style:o,rx:u,ry:u}),n.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:N,style:i,children:s}),d]}):null}z_.displayName="EdgeText";const n9=v.memo(z_);function Sh({path:e,labelX:t,labelY:s,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,interactionWidth:h=20,...m}){return n.jsxs(n.Fragment,{children:[n.jsx("path",{...m,d:e,fill:"none",className:_n(["react-flow__edge-path",m.className])}),h?n.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,i&&_i(t)&&_i(s)?n.jsx(n9,{x:t,y:s,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d}):null]})}function Ij({pos:e,x1:t,y1:s,x2:i,y2:r}){return e===tt.Left||e===tt.Right?[.5*(t+i),s]:[t,.5*(s+r)]}function D_({sourceX:e,sourceY:t,sourcePosition:s=tt.Bottom,targetX:i,targetY:r,targetPosition:o=tt.Top}){const[l,u]=Ij({pos:s,x1:e,y1:t,x2:i,y2:r}),[d,h]=Ij({pos:o,x1:i,y1:r,x2:e,y2:t}),[m,p,g,x]=o_({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:l,sourceControlY:u,targetControlX:d,targetControlY:h});return[`M${e},${t} C${l},${u} ${d},${h} ${i},${r}`,m,p,g,x]}function F_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,sourcePosition:l,targetPosition:u,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:N,markerEnd:j,markerStart:y,interactionWidth:k})=>{const[_,S,E]=D_({sourceX:s,sourceY:i,sourcePosition:l,targetX:r,targetY:o,targetPosition:u}),O=e.isInternal?void 0:t;return n.jsx(Sh,{id:O,path:_,labelX:S,labelY:E,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:N,markerEnd:j,markerStart:y,interactionWidth:k})})}const s9=F_({isInternal:!1}),U_=F_({isInternal:!0});s9.displayName="SimpleBezierEdge";U_.displayName="SimpleBezierEdgeInternal";function B_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:g,sourcePosition:x=tt.Bottom,targetPosition:N=tt.Top,markerEnd:j,markerStart:y,pathOptions:k,interactionWidth:_})=>{const[S,E,O]=pg({sourceX:s,sourceY:i,sourcePosition:x,targetX:r,targetY:o,targetPosition:N,borderRadius:k==null?void 0:k.borderRadius,offset:k==null?void 0:k.offset,stepPosition:k==null?void 0:k.stepPosition}),P=e.isInternal?void 0:t;return n.jsx(Sh,{id:P,path:S,labelX:E,labelY:O,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:j,markerStart:y,interactionWidth:_})})}const H_=B_({isInternal:!1}),Z_=B_({isInternal:!0});H_.displayName="SmoothStepEdge";Z_.displayName="SmoothStepEdgeInternal";function W_(e){return v.memo(({id:t,...s})=>{var r;const i=e.isInternal?void 0:t;return n.jsx(H_,{...s,id:i,pathOptions:v.useMemo(()=>{var o;return{borderRadius:0,offset:(o=s.pathOptions)==null?void 0:o.offset}},[(r=s.pathOptions)==null?void 0:r.offset])})})}const i9=W_({isInternal:!1}),V_=W_({isInternal:!0});i9.displayName="StepEdge";V_.displayName="StepEdgeInternal";function q_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:x,markerStart:N,interactionWidth:j})=>{const[y,k,_]=u_({sourceX:s,sourceY:i,targetX:r,targetY:o}),S=e.isInternal?void 0:t;return n.jsx(Sh,{id:S,path:y,labelX:k,labelY:_,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:x,markerStart:N,interactionWidth:j})})}const r9=q_({isInternal:!1}),G_=q_({isInternal:!0});r9.displayName="StraightEdge";G_.displayName="StraightEdgeInternal";function K_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,sourcePosition:l=tt.Bottom,targetPosition:u=tt.Top,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:N,markerEnd:j,markerStart:y,pathOptions:k,interactionWidth:_})=>{const[S,E,O]=l_({sourceX:s,sourceY:i,sourcePosition:l,targetX:r,targetY:o,targetPosition:u,curvature:k==null?void 0:k.curvature}),P=e.isInternal?void 0:t;return n.jsx(Sh,{id:P,path:S,labelX:E,labelY:O,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:N,markerEnd:j,markerStart:y,interactionWidth:_})})}const a9=K_({isInternal:!1}),Y_=K_({isInternal:!0});a9.displayName="BezierEdge";Y_.displayName="BezierEdgeInternal";const Tj={default:Y_,straight:G_,step:V_,smoothstep:Z_,simplebezier:U_},Mj={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},o9=(e,t,s)=>s===tt.Left?e-t:s===tt.Right?e+t:e,l9=(e,t,s)=>s===tt.Top?e-t:s===tt.Bottom?e+t:e,Rj="react-flow__edgeupdater";function Oj({position:e,centerX:t,centerY:s,radius:i=10,onMouseDown:r,onMouseEnter:o,onMouseOut:l,type:u}){return n.jsx("circle",{onMouseDown:r,onMouseEnter:o,onMouseOut:l,className:_n([Rj,`${Rj}-${u}`]),cx:o9(t,i,e),cy:l9(s,i,e),r:i,stroke:"transparent",fill:"transparent"})}function c9({isReconnectable:e,reconnectRadius:t,edge:s,sourceX:i,sourceY:r,targetX:o,targetY:l,sourcePosition:u,targetPosition:d,onReconnect:h,onReconnectStart:m,onReconnectEnd:p,setReconnecting:g,setUpdateHover:x}){const N=Xt(),j=(E,O)=>{if(E.button!==0)return;const{autoPanOnConnect:P,domNode:H,connectionMode:B,connectionRadius:R,lib:M,onConnectStart:F,cancelConnection:L,nodeLookup:A,rfId:I,panBy:z,updateConnection:D}=N.getState(),V=O.type==="target",U=(G,K)=>{g(!1),p==null||p(G,s,O.type,K)},q=G=>h==null?void 0:h(s,G),te=(G,K)=>{g(!0),m==null||m(E,s,O.type),F==null||F(G,K)};vg.onPointerDown(E.nativeEvent,{autoPanOnConnect:P,connectionMode:B,connectionRadius:R,domNode:H,handleId:O.id,nodeId:O.nodeId,nodeLookup:A,isTarget:V,edgeUpdaterType:O.type,lib:M,flowId:I,cancelConnection:L,panBy:z,isValidConnection:(...G)=>{var K,Z;return((Z=(K=N.getState()).isValidConnection)==null?void 0:Z.call(K,...G))??!0},onConnect:q,onConnectStart:te,onConnectEnd:(...G)=>{var K,Z;return(Z=(K=N.getState()).onConnectEnd)==null?void 0:Z.call(K,...G)},onReconnectEnd:U,updateConnection:D,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,dragThreshold:N.getState().connectionDragThreshold,handleDomNode:E.currentTarget})},y=E=>j(E,{nodeId:s.target,id:s.targetHandle??null,type:"target"}),k=E=>j(E,{nodeId:s.source,id:s.sourceHandle??null,type:"source"}),_=()=>x(!0),S=()=>x(!1);return n.jsxs(n.Fragment,{children:[(e===!0||e==="source")&&n.jsx(Oj,{position:u,centerX:i,centerY:r,radius:t,onMouseDown:y,onMouseEnter:_,onMouseOut:S,type:"source"}),(e===!0||e==="target")&&n.jsx(Oj,{position:d,centerX:o,centerY:l,radius:t,onMouseDown:k,onMouseEnter:_,onMouseOut:S,type:"target"})]})}function u9({id:e,edgesFocusable:t,edgesReconnectable:s,elementsSelectable:i,onClick:r,onDoubleClick:o,onContextMenu:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,reconnectRadius:m,onReconnect:p,onReconnectStart:g,onReconnectEnd:x,rfId:N,edgeTypes:j,noPanClassName:y,onError:k,disableKeyboardA11y:_}){let S=At(Me=>Me.edgeLookup.get(e));const E=At(Me=>Me.defaultEdgeOptions);S=E?{...E,...S}:S;let O=S.type||"default",P=(j==null?void 0:j[O])||Tj[O];P===void 0&&(k==null||k("011",Ai.error011(O)),O="default",P=(j==null?void 0:j.default)||Tj.default);const H=!!(S.focusable||t&&typeof S.focusable>"u"),B=typeof p<"u"&&(S.reconnectable||s&&typeof S.reconnectable>"u"),R=!!(S.selectable||i&&typeof S.selectable>"u"),M=v.useRef(null),[F,L]=v.useState(!1),[A,I]=v.useState(!1),z=Xt(),{zIndex:D=S.zIndex,sourceX:V,sourceY:U,targetX:q,targetY:te,sourcePosition:G,targetPosition:K}=At(v.useCallback(Me=>{const fe=Me.nodeLookup.get(S.source),ke=Me.nodeLookup.get(S.target);if(!fe||!ke)return Mj;const ge=YU({id:e,sourceNode:fe,targetNode:ke,sourceHandle:S.sourceHandle||null,targetHandle:S.targetHandle||null,connectionMode:Me.connectionMode,onError:k}),Ae=BU({selected:S.selected,zIndex:S.zIndex,sourceNode:fe,targetNode:ke,elevateOnSelect:Me.elevateEdgesOnSelect,zIndexMode:Me.zIndexMode});return{...ge||Mj,zIndex:Ae}},[S.source,S.target,S.sourceHandle,S.targetHandle,S.selected,S.zIndex,k]),un),Z=v.useMemo(()=>S.markerStart?`url('#${gg(S.markerStart,N)}')`:void 0,[S.markerStart,N]),ee=v.useMemo(()=>S.markerEnd?`url('#${gg(S.markerEnd,N)}')`:void 0,[S.markerEnd,N]);if(S.hidden||V===null||U===null||q===null||te===null)return null;const J=Me=>{var Ae;const{addSelectedEdges:fe,unselectNodesAndEdges:ke,multiSelectionActive:ge}=z.getState();R&&(z.setState({nodesSelectionActive:!1}),S.selected&&ge?(ke({nodes:[],edges:[S]}),(Ae=M.current)==null||Ae.blur()):fe([e])),r&&r(Me,S)},re=o?Me=>{o(Me,{...S})}:void 0,ie=l?Me=>{l(Me,{...S})}:void 0,ne=u?Me=>{u(Me,{...S})}:void 0,me=d?Me=>{d(Me,{...S})}:void 0,Ce=h?Me=>{h(Me,{...S})}:void 0,Fe=Me=>{var fe;if(!_&&V1.includes(Me.key)&&R){const{unselectNodesAndEdges:ke,addSelectedEdges:ge}=z.getState();Me.key==="Escape"?((fe=M.current)==null||fe.blur(),ke({edges:[S]})):ge([e])}};return n.jsx("svg",{style:{zIndex:D},children:n.jsxs("g",{className:_n(["react-flow__edge",`react-flow__edge-${O}`,S.className,y,{selected:S.selected,animated:S.animated,inactive:!R&&!r,updating:F,selectable:R}]),onClick:J,onDoubleClick:re,onContextMenu:ie,onMouseEnter:ne,onMouseMove:me,onMouseLeave:Ce,onKeyDown:H?Fe:void 0,tabIndex:H?0:void 0,role:S.ariaRole??(H?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":S.ariaLabel===null?void 0:S.ariaLabel||`Edge from ${S.source} to ${S.target}`,"aria-describedby":H?`${S_}-${N}`:void 0,ref:M,...S.domAttributes,children:[!A&&n.jsx(P,{id:e,source:S.source,target:S.target,type:S.type,selected:S.selected,animated:S.animated,selectable:R,deletable:S.deletable??!0,label:S.label,labelStyle:S.labelStyle,labelShowBg:S.labelShowBg,labelBgStyle:S.labelBgStyle,labelBgPadding:S.labelBgPadding,labelBgBorderRadius:S.labelBgBorderRadius,sourceX:V,sourceY:U,targetX:q,targetY:te,sourcePosition:G,targetPosition:K,data:S.data,style:S.style,sourceHandleId:S.sourceHandle,targetHandleId:S.targetHandle,markerStart:Z,markerEnd:ee,pathOptions:"pathOptions"in S?S.pathOptions:void 0,interactionWidth:S.interactionWidth}),B&&n.jsx(c9,{edge:S,isReconnectable:B,reconnectRadius:m,onReconnect:p,onReconnectStart:g,onReconnectEnd:x,sourceX:V,sourceY:U,targetX:q,targetY:te,sourcePosition:G,targetPosition:K,setUpdateHover:L,setReconnecting:I})]})})}var d9=v.memo(u9);const h9=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function X_({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:s,edgeTypes:i,noPanClassName:r,onReconnect:o,onEdgeContextMenu:l,onEdgeMouseEnter:u,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:g,onReconnectStart:x,onReconnectEnd:N,disableKeyboardA11y:j}){const{edgesFocusable:y,edgesReconnectable:k,elementsSelectable:_,onError:S}=At(h9,un),E=YH(t);return n.jsxs("div",{className:"react-flow__edges",children:[n.jsx(t9,{defaultColor:e,rfId:s}),E.map(O=>n.jsx(d9,{id:O,edgesFocusable:y,edgesReconnectable:k,elementsSelectable:_,noPanClassName:r,onReconnect:o,onContextMenu:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,onClick:m,reconnectRadius:p,onDoubleClick:g,onReconnectStart:x,onReconnectEnd:N,rfId:s,onError:S,edgeTypes:i,disableKeyboardA11y:j},O))]})}X_.displayName="EdgeRenderer";const m9=v.memo(X_),Pj=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function f9({children:e}){const t=Xt(),s=v.useRef(null),[i]=v.useState(()=>t.getState().transform);return A_(()=>{let r=null;const o=()=>{const l=t.getState().transform;r&&l[0]===r[0]&&l[1]===r[1]&&l[2]===r[2]||(r=l,s.current&&(s.current.style.transform=Pj(l)))};return o(),t.subscribe(o)},[t]),n.jsx("div",{ref:s,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Pj(i)},children:e})}function p9(e){const t=Ux(),s=v.useRef(!1);v.useEffect(()=>{!s.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),s.current=!0)},[e,t.viewportInitialized])}const g9=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function x9(e){const t=At(g9),s=Xt();return v.useEffect(()=>{e&&(t==null||t(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function v9(e){return e.connection.inProgress?{...e.connection,to:Yc(e.connection.to,e.transform)}:{...e.connection}}function y9(e){return v9}function b9(e){const t=y9();return At(t,un)}const k9=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function j9({containerStyle:e,style:t,type:s,component:i}){const{nodesConnectable:r,width:o,height:l,isValid:u,inProgress:d}=At(k9,un);return!(o&&r&&d)?null:n.jsx("svg",{style:e,width:o,height:l,className:"react-flow__connectionline react-flow__container",children:n.jsx("g",{className:_n(["react-flow__connection",s_(u)]),children:n.jsx(Q_,{style:t,type:s,CustomComponent:i,isValid:u})})})}const Q_=({style:e,type:t=Wr.Bezier,CustomComponent:s,isValid:i})=>{const{inProgress:r,from:o,fromNode:l,fromHandle:u,fromPosition:d,to:h,toNode:m,toHandle:p,toPosition:g,pointer:x}=b9();if(!r)return;if(s)return n.jsx(s,{connectionLineType:t,connectionLineStyle:e,fromNode:l,fromHandle:u,fromX:o.x,fromY:o.y,toX:h.x,toY:h.y,fromPosition:d,toPosition:g,connectionStatus:s_(i),toNode:m,toHandle:p,pointer:x});let N="";const j={sourceX:o.x,sourceY:o.y,sourcePosition:d,targetX:h.x,targetY:h.y,targetPosition:g};switch(t){case Wr.Bezier:[N]=l_(j);break;case Wr.SimpleBezier:[N]=D_(j);break;case Wr.Step:[N]=pg({...j,borderRadius:0});break;case Wr.SmoothStep:[N]=pg(j);break;default:[N]=u_(j)}return n.jsx("path",{d:N,fill:"none",className:"react-flow__connection-path",style:e})};Q_.displayName="ConnectionLine";const N9={};function Lj(e=N9){v.useRef(e),Xt(),v.useEffect(()=>{},[e])}function w9(){Xt(),v.useRef(!1),v.useEffect(()=>{},[])}function J_({nodeTypes:e,edgeTypes:t,onInit:s,onNodeClick:i,onEdgeClick:r,onNodeDoubleClick:o,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:x,connectionLineType:N,connectionLineStyle:j,connectionLineComponent:y,connectionLineContainerStyle:k,selectionKeyCode:_,selectionOnDrag:S,selectionMode:E,multiSelectionKeyCode:O,panActivationKeyCode:P,zoomActivationKeyCode:H,deleteKeyCode:B,onlyRenderVisibleElements:R,elementsSelectable:M,defaultViewport:F,translateExtent:L,minZoom:A,maxZoom:I,preventScrolling:z,defaultMarkerColor:D,zoomOnScroll:V,zoomOnPinch:U,panOnScroll:q,panOnScrollSpeed:te,panOnScrollMode:G,zoomOnDoubleClick:K,panOnDrag:Z,autoPanOnSelection:ee,onPaneClick:J,onPaneMouseEnter:re,onPaneMouseMove:ie,onPaneMouseLeave:ne,onPaneScroll:me,onPaneContextMenu:Ce,paneClickDistance:Fe,nodeClickDistance:Me,onEdgeContextMenu:fe,onEdgeMouseEnter:ke,onEdgeMouseMove:ge,onEdgeMouseLeave:Ae,reconnectRadius:be,onReconnect:qe,onReconnectStart:ft,onReconnectEnd:gt,noDragClassName:Rt,noWheelClassName:En,noPanClassName:rt,disableKeyboardA11y:Pt,nodeExtent:rn,rfId:Zt,viewport:Qt,onViewportChange:Ut,nodesDraggable:Rn}){return Lj(e),Lj(t),w9(),p9(s),x9(Qt),n.jsx(FH,{onPaneClick:J,onPaneMouseEnter:re,onPaneMouseMove:ie,onPaneMouseLeave:ne,onPaneContextMenu:Ce,onPaneScroll:me,paneClickDistance:Fe,deleteKeyCode:B,selectionKeyCode:_,selectionOnDrag:S,selectionMode:E,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:O,panActivationKeyCode:P,zoomActivationKeyCode:H,elementsSelectable:M,zoomOnScroll:V,zoomOnPinch:U,zoomOnDoubleClick:K,panOnScroll:q,panOnScrollSpeed:te,panOnScrollMode:G,panOnDrag:Z,autoPanOnSelection:ee,defaultViewport:F,translateExtent:L,minZoom:A,maxZoom:I,onSelectionContextMenu:p,preventScrolling:z,noDragClassName:Rt,noWheelClassName:En,noPanClassName:rt,disableKeyboardA11y:Pt,onViewportChange:Ut,isControlledViewport:!!Qt,children:n.jsxs(f9,{children:[n.jsx(m9,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:l,onReconnect:qe,onReconnectStart:ft,onReconnectEnd:gt,onlyRenderVisibleElements:R,onEdgeContextMenu:fe,onEdgeMouseEnter:ke,onEdgeMouseMove:ge,onEdgeMouseLeave:Ae,reconnectRadius:be,defaultMarkerColor:D,noPanClassName:rt,disableKeyboardA11y:Pt,rfId:Zt}),n.jsx(j9,{style:j,type:N,component:y,containerStyle:k}),n.jsx("div",{className:"react-flow__edgelabel-renderer"}),n.jsx(KH,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:o,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,nodeClickDistance:Me,onlyRenderVisibleElements:R,noPanClassName:rt,noDragClassName:Rt,disableKeyboardA11y:Pt,nodeExtent:rn,rfId:Zt,nodesDraggable:Rn}),n.jsx("div",{className:"react-flow__viewport-portal"})]})})}J_.displayName="GraphView";const S9=v.memo(J_),_9=e_(),zj=({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,width:r,height:o,fitView:l,fitViewOptions:u,minZoom:d=.5,maxZoom:h=2,nodeOrigin:m,nodeExtent:p,zIndexMode:g="basic"}={})=>{const x=new Map,N=new Map,j=new Map,y=new Map,k=i??t??[],_=s??e??[],S=m??[0,0],E=p??Ac;m_(j,y,k);const{nodesInitialized:O}=xg(_,x,N,{nodeOrigin:S,nodeExtent:E,zIndexMode:g});let P=[0,0,1];if(l&&r&&o){const H=Gc(x,{filter:F=>!!((F.width||F.initialWidth)&&(F.height||F.initialHeight))}),{x:B,y:R,zoom:M}=Rx(H,r,o,d,h,(u==null?void 0:u.padding)??.1);P=[B,R,M]}return{rfId:"1",width:r??0,height:o??0,transform:P,nodes:_,nodesInitialized:O,nodeLookup:x,parentLookup:N,edges:k,edgeLookup:y,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:s!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:d,maxZoom:h,translateExtent:Ac,nodeExtent:E,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Qo.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:S,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:l??!1,fitViewOptions:u,fitViewResolver:null,connection:{...G1},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:_9,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:q1,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}},E9=({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,width:r,height:o,fitView:l,fitViewOptions:u,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:p,zIndexMode:g})=>DB((x,N)=>{async function j(){const{nodeLookup:y,panZoom:k,fitViewOptions:_,fitViewResolver:S,width:E,height:O,minZoom:P,maxZoom:H}=N();k&&(await OU({nodes:y,width:E,height:O,panZoom:k,minZoom:P,maxZoom:H},_),S==null||S.resolve(!0),x({fitViewResolver:null}))}return{...zj({nodes:e,edges:t,width:r,height:o,fitView:l,fitViewOptions:u,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:p,defaultNodes:s,defaultEdges:i,zIndexMode:g}),setNodes:y=>{const{nodeLookup:k,parentLookup:_,nodeOrigin:S,nodeExtent:E,elevateNodesOnSelect:O,fitViewQueued:P,zIndexMode:H,nodesSelectionActive:B}=N(),{nodesInitialized:R,hasSelectedNodes:M}=xg(y,k,_,{nodeOrigin:S,nodeExtent:E,elevateNodesOnSelect:O,checkEquality:!0,zIndexMode:H}),F=B&&M;P&&R?(j(),x({nodes:y,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:F})):x({nodes:y,nodesInitialized:R,nodesSelectionActive:F})},setEdges:y=>{const{connectionLookup:k,edgeLookup:_}=N();m_(k,_,y),x({edges:y})},setDefaultNodesAndEdges:(y,k)=>{if(y){const{setNodes:_}=N();_(y),x({hasDefaultNodes:!0})}if(k){const{setEdges:_}=N();_(k),x({hasDefaultEdges:!0})}},updateNodeInternals:y=>{const{triggerNodeChanges:k,nodeLookup:_,parentLookup:S,domNode:E,nodeOrigin:O,nodeExtent:P,debug:H,fitViewQueued:B,zIndexMode:R}=N(),{changes:M,updatedInternals:F}=iB(y,_,S,E,O,P,R);F&&(eB(_,S,{nodeOrigin:O,nodeExtent:P,zIndexMode:R}),B?(j(),x({fitViewQueued:!1,fitViewOptions:void 0})):x({}),(M==null?void 0:M.length)>0&&(H&&console.log("React Flow: trigger node changes",M),k==null||k(M)))},updateNodePositions:(y,k=!1)=>{const _=[];let S=[];const{nodeLookup:E,triggerNodeChanges:O,connection:P,updateConnection:H,onNodesChangeMiddlewareMap:B}=N();for(const[R,M]of y){const F=E.get(R),L=!!(F!=null&&F.expandParent&&(F!=null&&F.parentId)&&(M!=null&&M.position)),A={id:R,type:"position",position:L?{x:Math.max(0,M.position.x),y:Math.max(0,M.position.y)}:M.position,dragging:k};if(F&&P.inProgress&&P.fromNode.id===F.id){const I=Wa(F,P.fromHandle,tt.Left,!0);H({...P,from:I})}L&&F.parentId&&_.push({id:R,parentId:F.parentId,rect:{...M.internals.positionAbsolute,width:M.measured.width??0,height:M.measured.height??0}}),S.push(A)}if(_.length>0){const{parentLookup:R,nodeOrigin:M}=N(),F=Fx(_,E,R,M);S.push(...F)}for(const R of B.values())S=R(S);O(S)},triggerNodeChanges:y=>{const{onNodesChange:k,setNodes:_,nodes:S,hasDefaultNodes:E,debug:O}=N();if(y!=null&&y.length){if(E){const P=aH(y,S);_(P)}O&&console.log("React Flow: trigger node changes",y),k==null||k(y)}},triggerEdgeChanges:y=>{const{onEdgesChange:k,setEdges:_,edges:S,hasDefaultEdges:E,debug:O}=N();if(y!=null&&y.length){if(E){const P=oH(y,S);_(P)}O&&console.log("React Flow: trigger edge changes",y),k==null||k(y)}},addSelectedNodes:y=>{const{multiSelectionActive:k,edgeLookup:_,nodeLookup:S,triggerNodeChanges:E,triggerEdgeChanges:O}=N();if(k){const P=y.map(H=>Ea(H,!0));E(P);return}E(Co(S,new Set([...y]),!0)),O(Co(_))},addSelectedEdges:y=>{const{multiSelectionActive:k,edgeLookup:_,nodeLookup:S,triggerNodeChanges:E,triggerEdgeChanges:O}=N();if(k){const P=y.map(H=>Ea(H,!0));O(P);return}O(Co(_,new Set([...y]))),E(Co(S,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:k}={})=>{const{edges:_,nodes:S,nodeLookup:E,triggerNodeChanges:O,triggerEdgeChanges:P}=N(),H=y||S,B=k||_,R=[];for(const F of H){if(!F.selected)continue;const L=E.get(F.id);L&&(L.selected=!1),R.push(Ea(F.id,!1))}const M=[];for(const F of B)F.selected&&M.push(Ea(F.id,!1));O(R),P(M)},setMinZoom:y=>{const{panZoom:k,maxZoom:_}=N();k==null||k.setScaleExtent([y,_]),x({minZoom:y})},setMaxZoom:y=>{const{panZoom:k,minZoom:_}=N();k==null||k.setScaleExtent([_,y]),x({maxZoom:y})},setTranslateExtent:y=>{var k;(k=N().panZoom)==null||k.setTranslateExtent(y),x({translateExtent:y})},resetSelectedElements:()=>{const{edges:y,nodes:k,triggerNodeChanges:_,triggerEdgeChanges:S,elementsSelectable:E}=N();if(!E)return;const O=k.reduce((H,B)=>B.selected?[...H,Ea(B.id,!1)]:H,[]),P=y.reduce((H,B)=>B.selected?[...H,Ea(B.id,!1)]:H,[]);_(O),S(P)},setNodeExtent:y=>{const{nodes:k,nodeLookup:_,parentLookup:S,nodeOrigin:E,elevateNodesOnSelect:O,nodeExtent:P,zIndexMode:H}=N();y[0][0]===P[0][0]&&y[0][1]===P[0][1]&&y[1][0]===P[1][0]&&y[1][1]===P[1][1]||(xg(k,_,S,{nodeOrigin:E,nodeExtent:y,elevateNodesOnSelect:O,checkEquality:!1,zIndexMode:H}),x({nodeExtent:y}))},panBy:y=>{const{transform:k,width:_,height:S,panZoom:E,translateExtent:O}=N();return rB({delta:y,panZoom:E,transform:k,translateExtent:O,width:_,height:S})},setCenter:async(y,k,_)=>{const{width:S,height:E,maxZoom:O,panZoom:P}=N();if(!P)return!1;const H=typeof(_==null?void 0:_.zoom)<"u"?_.zoom:O;return await P.setViewport({x:S/2-y*H,y:E/2-k*H,zoom:H},{duration:_==null?void 0:_.duration,ease:_==null?void 0:_.ease,interpolate:_==null?void 0:_.interpolate}),!0},cancelConnection:()=>{x({connection:{...G1}})},updateConnection:y=>{x({connection:y})},reset:()=>x({...zj()})}},Object.is);function C9({initialNodes:e,initialEdges:t,defaultNodes:s,defaultEdges:i,initialWidth:r,initialHeight:o,initialMinZoom:l,initialMaxZoom:u,initialFitViewOptions:d,fitView:h,nodeOrigin:m,nodeExtent:p,zIndexMode:g,children:x}){const[N]=v.useState(()=>E9({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,width:r,height:o,fitView:h,minZoom:l,maxZoom:u,fitViewOptions:d,nodeOrigin:m,nodeExtent:p,zIndexMode:g}));return n.jsx(FB,{value:N,children:n.jsx(hH,{children:n.jsx(EH,{children:x})})})}function A9({children:e,nodes:t,edges:s,defaultNodes:i,defaultEdges:r,width:o,height:l,fitView:u,fitViewOptions:d,minZoom:h,maxZoom:m,nodeOrigin:p,nodeExtent:g,zIndexMode:x}){return v.useContext(jh)?n.jsx(n.Fragment,{children:e}):n.jsx(C9,{initialNodes:t,initialEdges:s,defaultNodes:i,defaultEdges:r,initialWidth:o,initialHeight:l,fitView:u,initialFitViewOptions:d,initialMinZoom:h,initialMaxZoom:m,nodeOrigin:p,nodeExtent:g,zIndexMode:x,children:e})}const $9={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function I9({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,className:r,nodeTypes:o,edgeTypes:l,onNodeClick:u,onEdgeClick:d,onInit:h,onMove:m,onMoveStart:p,onMoveEnd:g,onConnect:x,onConnectStart:N,onConnectEnd:j,onClickConnectStart:y,onClickConnectEnd:k,onNodeMouseEnter:_,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:O,onNodeDoubleClick:P,onNodeDragStart:H,onNodeDrag:B,onNodeDragStop:R,onNodesDelete:M,onEdgesDelete:F,onDelete:L,onSelectionChange:A,onSelectionDragStart:I,onSelectionDrag:z,onSelectionDragStop:D,onSelectionContextMenu:V,onSelectionStart:U,onSelectionEnd:q,onBeforeDelete:te,connectionMode:G,connectionLineType:K=Wr.Bezier,connectionLineStyle:Z,connectionLineComponent:ee,connectionLineContainerStyle:J,deleteKeyCode:re="Backspace",selectionKeyCode:ie="Shift",selectionOnDrag:ne=!1,selectionMode:me=$c.Full,panActivationKeyCode:Ce="Space",multiSelectionKeyCode:Fe=Tc()?"Meta":"Control",zoomActivationKeyCode:Me=Tc()?"Meta":"Control",snapToGrid:fe,snapGrid:ke,onlyRenderVisibleElements:ge=!1,selectNodesOnDrag:Ae,nodesDraggable:be,autoPanOnNodeFocus:qe,nodesConnectable:ft,nodesFocusable:gt,nodeOrigin:Rt=__,edgesFocusable:En,edgesReconnectable:rt,elementsSelectable:Pt=!0,defaultViewport:rn=JB,minZoom:Zt=.5,maxZoom:Qt=2,translateExtent:Ut=Ac,preventScrolling:Rn=!0,nodeExtent:mn,defaultMarkerColor:Hn="#b1b1b7",zoomOnScroll:Gs=!0,zoomOnPinch:ps=!0,panOnScroll:rs=!1,panOnScrollSpeed:gs=.5,panOnScrollMode:Cn=Da.Free,zoomOnDoubleClick:as=!0,panOnDrag:Kn=!0,onPaneClick:Zn,onPaneMouseEnter:An,onPaneMouseMove:Yn,onPaneMouseLeave:On,onPaneScroll:le,onPaneContextMenu:X,paneClickDistance:de=1,nodeClickDistance:Se=0,children:Be,onReconnect:ut,onReconnectStart:Nt,onReconnectEnd:He,onEdgeContextMenu:Ue,onEdgeDoubleClick:Xe,onEdgeMouseEnter:yt,onEdgeMouseMove:St,onEdgeMouseLeave:Xn,reconnectRadius:xs=10,onNodesChange:ui,onEdgesChange:yr,noDragClassName:di="nodrag",noWheelClassName:br="nowheel",noPanClassName:Qn="nopan",fitView:Gi,fitViewOptions:vs,connectOnClick:Mi,attributionPosition:kr,proOptions:zt,defaultEdgeOptions:Os,elevateNodesOnSelect:os=!0,elevateEdgesOnSelect:Ki=!1,disableKeyboardA11y:hi=!1,autoPanOnConnect:Dt,autoPanOnNodeDrag:jr,autoPanOnSelection:Yi=!0,autoPanSpeed:mi,connectionRadius:Ri,isValidConnection:Pe,onError:Ve,style:dt,id:mt,nodeDragThreshold:Ot,connectionDragThreshold:Ft,viewport:Jn,onViewportChange:Ks,width:fn,height:$n,colorMode:Ys="light",debug:Xs,onScroll:ys,ariaLabelConfig:la,zIndexMode:Nr="basic",...Oi},wr){const ls=mt||"1",bs=sH(Ys),In=v.useCallback(Qs=>{Qs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),ys==null||ys(Qs)},[ys]);return n.jsx("div",{"data-testid":"rf__wrapper",...Oi,onScroll:In,style:{...dt,...$9},ref:wr,className:_n(["react-flow",r,bs]),id:mt,role:"application",children:n.jsxs(A9,{nodes:e,edges:t,width:fn,height:$n,fitView:Gi,fitViewOptions:vs,minZoom:Zt,maxZoom:Qt,nodeOrigin:Rt,nodeExtent:mn,zIndexMode:Nr,children:[n.jsx(nH,{nodes:e,edges:t,defaultNodes:s,defaultEdges:i,onConnect:x,onConnectStart:N,onConnectEnd:j,onClickConnectStart:y,onClickConnectEnd:k,nodesDraggable:be,autoPanOnNodeFocus:qe,nodesConnectable:ft,nodesFocusable:gt,edgesFocusable:En,edgesReconnectable:rt,elementsSelectable:Pt,elevateNodesOnSelect:os,elevateEdgesOnSelect:Ki,minZoom:Zt,maxZoom:Qt,nodeExtent:mn,onNodesChange:ui,onEdgesChange:yr,snapToGrid:fe,snapGrid:ke,connectionMode:G,translateExtent:Ut,connectOnClick:Mi,defaultEdgeOptions:Os,fitView:Gi,fitViewOptions:vs,onNodesDelete:M,onEdgesDelete:F,onDelete:L,onNodeDragStart:H,onNodeDrag:B,onNodeDragStop:R,onSelectionDrag:z,onSelectionDragStart:I,onSelectionDragStop:D,onMove:m,onMoveStart:p,onMoveEnd:g,noPanClassName:Qn,nodeOrigin:Rt,rfId:ls,autoPanOnConnect:Dt,autoPanOnNodeDrag:jr,autoPanSpeed:mi,onError:Ve,connectionRadius:Ri,isValidConnection:Pe,selectNodesOnDrag:Ae,nodeDragThreshold:Ot,connectionDragThreshold:Ft,onBeforeDelete:te,debug:Xs,ariaLabelConfig:la,zIndexMode:Nr}),n.jsx(S9,{onInit:h,onNodeClick:u,onEdgeClick:d,onNodeMouseEnter:_,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:O,onNodeDoubleClick:P,nodeTypes:o,edgeTypes:l,connectionLineType:K,connectionLineStyle:Z,connectionLineComponent:ee,connectionLineContainerStyle:J,selectionKeyCode:ie,selectionOnDrag:ne,selectionMode:me,deleteKeyCode:re,multiSelectionKeyCode:Fe,panActivationKeyCode:Ce,zoomActivationKeyCode:Me,onlyRenderVisibleElements:ge,defaultViewport:rn,translateExtent:Ut,minZoom:Zt,maxZoom:Qt,preventScrolling:Rn,zoomOnScroll:Gs,zoomOnPinch:ps,zoomOnDoubleClick:as,panOnScroll:rs,panOnScrollSpeed:gs,panOnScrollMode:Cn,panOnDrag:Kn,autoPanOnSelection:Yi,onPaneClick:Zn,onPaneMouseEnter:An,onPaneMouseMove:Yn,onPaneMouseLeave:On,onPaneScroll:le,onPaneContextMenu:X,paneClickDistance:de,nodeClickDistance:Se,onSelectionContextMenu:V,onSelectionStart:U,onSelectionEnd:q,onReconnect:ut,onReconnectStart:Nt,onReconnectEnd:He,onEdgeContextMenu:Ue,onEdgeDoubleClick:Xe,onEdgeMouseEnter:yt,onEdgeMouseMove:St,onEdgeMouseLeave:Xn,reconnectRadius:xs,defaultMarkerColor:Hn,noDragClassName:di,noWheelClassName:br,noPanClassName:Qn,rfId:ls,disableKeyboardA11y:hi,nodeExtent:mn,viewport:Jn,onViewportChange:Ks,nodesDraggable:be}),n.jsx(QB,{onSelectionChange:A}),Be,n.jsx(qB,{proOptions:zt,position:kr}),n.jsx(VB,{rfId:ls,disableKeyboardA11y:hi})]})})}var T9=C_(I9);function M9({dimensions:e,lineWidth:t,variant:s,className:i}){return n.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:_n(["react-flow__background-pattern",s,i])})}function R9({radius:e,className:t}){return n.jsx("circle",{cx:e,cy:e,r:e,className:_n(["react-flow__background-pattern","dots",t])})}var ta;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ta||(ta={}));const O9={[ta.Dots]:1,[ta.Lines]:1,[ta.Cross]:6},P9=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function eE({id:e,variant:t=ta.Dots,gap:s=20,size:i,lineWidth:r=1,offset:o=0,color:l,bgColor:u,style:d,className:h,patternClassName:m}){const p=v.useRef(null),{transform:g,patternId:x}=At(P9,un),N=i||O9[t],j=t===ta.Dots,y=t===ta.Cross,k=Array.isArray(s)?s:[s,s],_=[k[0]*g[2]||1,k[1]*g[2]||1],S=N*g[2],E=Array.isArray(o)?o:[o,o],O=y?[S,S]:_,P=[E[0]*g[2]+O[0]/2,E[1]*g[2]+O[1]/2],H=`${x}${e||""}`;return n.jsxs("svg",{className:_n(["react-flow__background",h]),style:{...d,...wh,"--xy-background-color-props":u,"--xy-background-pattern-color-props":l},ref:p,"data-testid":"rf__background",children:[n.jsx("pattern",{id:H,x:g[0]%_[0],y:g[1]%_[1],width:_[0],height:_[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${P[0]},-${P[1]})`,children:j?n.jsx(R9,{radius:S/2,className:m}):n.jsx(M9,{dimensions:O,lineWidth:r,variant:t,className:m})}),n.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${H})`})]})}eE.displayName="Background";const L9=v.memo(eE);function z9(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:n.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function D9(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:n.jsx("path",{d:"M0 0h32v4.2H0z"})})}function F9(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:n.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 U9(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:n.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 B9(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:n.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 md({children:e,className:t,...s}){return n.jsx("button",{type:"button",className:_n(["react-flow__controls-button",t]),...s,children:e})}const H9=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function tE({style:e,showZoom:t=!0,showFitView:s=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:o,onZoomOut:l,onFitView:u,onInteractiveChange:d,className:h,children:m,position:p="bottom-left",orientation:g="vertical","aria-label":x}){const N=Xt(),{isInteractive:j,minZoomReached:y,maxZoomReached:k,ariaLabelConfig:_}=At(H9,un),{zoomIn:S,zoomOut:E,fitView:O}=Ux(),P=()=>{S(),o==null||o()},H=()=>{E(),l==null||l()},B=()=>{O(r),u==null||u()},R=()=>{N.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),d==null||d(!j)},M=g==="horizontal"?"horizontal":"vertical";return n.jsxs(Nh,{className:_n(["react-flow__controls",M,h]),position:p,style:e,"data-testid":"rf__controls","aria-label":x??_["controls.ariaLabel"],children:[t&&n.jsxs(n.Fragment,{children:[n.jsx(md,{onClick:P,className:"react-flow__controls-zoomin",title:_["controls.zoomIn.ariaLabel"],"aria-label":_["controls.zoomIn.ariaLabel"],disabled:k,children:n.jsx(z9,{})}),n.jsx(md,{onClick:H,className:"react-flow__controls-zoomout",title:_["controls.zoomOut.ariaLabel"],"aria-label":_["controls.zoomOut.ariaLabel"],disabled:y,children:n.jsx(D9,{})})]}),s&&n.jsx(md,{className:"react-flow__controls-fitview",onClick:B,title:_["controls.fitView.ariaLabel"],"aria-label":_["controls.fitView.ariaLabel"],children:n.jsx(F9,{})}),i&&n.jsx(md,{className:"react-flow__controls-interactive",onClick:R,title:_["controls.interactive.ariaLabel"],"aria-label":_["controls.interactive.ariaLabel"],children:j?n.jsx(B9,{}):n.jsx(U9,{})}),m]})}tE.displayName="Controls";const Z9=v.memo(tE);function W9({id:e,x:t,y:s,width:i,height:r,style:o,color:l,strokeColor:u,strokeWidth:d,className:h,borderRadius:m,shapeRendering:p,selected:g,onClick:x}){const{background:N,backgroundColor:j}=o||{},y=l||N||j;return n.jsx("rect",{className:_n(["react-flow__minimap-node",{selected:g},h]),x:t,y:s,rx:m,ry:m,width:i,height:r,style:{fill:y,stroke:u,strokeWidth:d},shapeRendering:p,onClick:x?k=>x(k,e):void 0})}const V9=v.memo(W9),q9=e=>e.nodes.map(t=>t.id),lp=e=>e instanceof Function?e:()=>e;function G9({nodeStrokeColor:e,nodeColor:t,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:o=V9,onClick:l}){const u=At(q9,un),d=lp(t),h=lp(e),m=lp(s),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return n.jsx(n.Fragment,{children:u.map(g=>n.jsx(Y9,{id:g,nodeColorFunc:d,nodeStrokeColorFunc:h,nodeClassNameFunc:m,nodeBorderRadius:i,nodeStrokeWidth:r,NodeComponent:o,onClick:l,shapeRendering:p},g))})}function K9({id:e,nodeColorFunc:t,nodeStrokeColorFunc:s,nodeClassNameFunc:i,nodeBorderRadius:r,nodeStrokeWidth:o,shapeRendering:l,NodeComponent:u,onClick:d}){const{node:h,x:m,y:p,width:g,height:x}=At(N=>{const j=N.nodeLookup.get(e);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const y=j.internals.userNode,{x:k,y:_}=j.internals.positionAbsolute,{width:S,height:E}=Ti(y);return{node:y,x:k,y:_,width:S,height:E}},un);return!h||h.hidden||!t_(h)?null:n.jsx(u,{x:m,y:p,width:g,height:x,style:h.style,selected:!!h.selected,className:i(h),color:t(h),borderRadius:r,strokeColor:s(h),strokeWidth:o,shapeRendering:l,onClick:d,id:h.id})}const Y9=v.memo(K9);var X9=v.memo(G9);const Q9=200,J9=150,e8=e=>!e.hidden,t8=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 s=!1;for(const i of e.nodeLookup.values())if(!i.hidden){s=!0;break}return{viewBB:t,boundingRect:s?Q1(Gc(e.nodeLookup,{filter:e8}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Dj=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,n8=(e,t)=>Dj(e.viewBB,t.viewBB)&&Dj(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,s8="react-flow__minimap-desc";function nE({style:e,className:t,nodeStrokeColor:s,nodeColor:i,nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:l,nodeComponent:u,bgColor:d,maskColor:h,maskStrokeColor:m,maskStrokeWidth:p,position:g="bottom-right",onClick:x,onNodeClick:N,pannable:j=!1,zoomable:y=!1,ariaLabel:k,inversePan:_,zoomStep:S=1,offsetScale:E=5}){const O=Xt(),P=v.useRef(null),{boundingRect:H,panZoom:B,viewBB:R,rfId:M,translateExtent:F,flowWidth:L,flowHeight:A,ariaLabelConfig:I}=At(t8,n8),z=(e==null?void 0:e.width)??Q9,D=(e==null?void 0:e.height)??J9,V=H.width/z,U=H.height/D,q=Math.max(V,U),te=q*z,G=q*D,K=E*q,Z=H.x-(te-H.width)/2-K,ee=H.y-(G-H.height)/2-K,J=te+K*2,re=G+K*2,ie=`${s8}-${M}`,ne=v.useRef(0),me=v.useRef();ne.current=q,v.useEffect(()=>{const ke=O.getState().panZoom;if(P.current&&ke)return me.current=fB({domNode:P.current,panZoom:ke,getTransform:()=>O.getState().transform,getViewScale:()=>ne.current}),()=>{var ge;(ge=me.current)==null||ge.destroy()}},[B]),v.useEffect(()=>{var ke;(ke=me.current)==null||ke.update({translateExtent:F,width:L,height:A,inversePan:_,pannable:j,zoomStep:S,zoomable:y})},[j,y,_,S,F,L,A]);const Ce=x?ke=>{var be;const[ge,Ae]=((be=me.current)==null?void 0:be.pointer(ke))||[0,0];x(ke,{x:ge,y:Ae})}:void 0,Fe=v.useCallback((ke,ge)=>{const Ae=O.getState().nodeLookup.get(ge).internals.userNode;N==null||N(ke,Ae)},[N]),Me=N?Fe:void 0,fe=k??I["minimap.ariaLabel"];return n.jsx(Nh,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*q:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-width-props":typeof l=="number"?l:void 0},className:_n(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:n.jsxs("svg",{width:z,height:D,viewBox:`${Z} ${ee} ${J} ${re}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ie,ref:P,onClick:Ce,children:[fe&&n.jsx("title",{id:ie,children:fe}),n.jsx(X9,{onClick:Me,nodeColor:i,nodeStrokeColor:s,nodeBorderRadius:o,nodeClassName:r,nodeStrokeWidth:l,nodeComponent:u}),n.jsx("path",{className:"react-flow__minimap-mask",d:`M${Z-K},${ee-K}h${J+K*2}v${re+K*2}h${-J-K*2}z
|
|
243
|
-
M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}nE.displayName="MiniMap";v.memo(nE);const i8=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,r8={[tl.Line]:"right",[tl.Handle]:"bottom-right"};function a8({nodeId:e,position:t,variant:s=tl.Handle,className:i,style:r=void 0,children:o,color:l,minWidth:u=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:g,autoScale:x=!0,shouldResize:N,onResizeStart:j,onResize:y,onResizeEnd:k}){const _=M_(),S=typeof e=="string"?e:_,E=Xt(),O=v.useRef(null),P=s===tl.Handle,H=At(v.useCallback(i8(P&&x),[P,x]),un),B=v.useRef(null),R=t??r8[s];v.useEffect(()=>{if(!(!O.current||!S))return B.current||(B.current=EB({domNode:O.current,nodeId:S,getStoreItems:()=>{const{nodeLookup:F,transform:L,snapGrid:A,snapToGrid:I,nodeOrigin:z,domNode:D}=E.getState();return{nodeLookup:F,transform:L,snapGrid:A,snapToGrid:I,nodeOrigin:z,paneDomNode:D}},onChange:(F,L)=>{const{triggerNodeChanges:A,nodeLookup:I,parentLookup:z,nodeOrigin:D}=E.getState(),V=[],U={x:F.x,y:F.y},q=I.get(S);if(q&&q.expandParent&&q.parentId){const te=q.origin??D,G=F.width??q.measured.width??0,K=F.height??q.measured.height??0,Z={id:q.id,parentId:q.parentId,rect:{width:G,height:K,...n_({x:F.x??q.position.x,y:F.y??q.position.y},{width:G,height:K},q.parentId,I,te)}},ee=Fx([Z],I,z,D);V.push(...ee),U.x=F.x?Math.max(te[0]*G,F.x):void 0,U.y=F.y?Math.max(te[1]*K,F.y):void 0}if(U.x!==void 0&&U.y!==void 0){const te={id:S,type:"position",position:{...U}};V.push(te)}if(F.width!==void 0&&F.height!==void 0){const G={id:S,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:F.width,height:F.height}};V.push(G)}for(const te of L){const G={...te,type:"position"};V.push(G)}A(V)},onEnd:({width:F,height:L})=>{const A={id:S,type:"dimensions",resizing:!1,dimensions:{width:F,height:L}};E.getState().triggerNodeChanges([A])}})),B.current.update({controlPosition:R,boundaries:{minWidth:u,minHeight:d,maxWidth:h,maxHeight:m},keepAspectRatio:p,resizeDirection:g,onResizeStart:j,onResize:y,onResizeEnd:k,shouldResize:N}),()=>{var F;(F=B.current)==null||F.destroy()}},[R,u,d,h,m,p,j,y,k,N]);const M=R.split("-");return n.jsx("div",{className:_n(["react-flow__resize-control","nodrag",...M,s,i]),ref:O,style:{...r,scale:H,...l&&{[P?"backgroundColor":"borderColor"]:l}},children:o})}v.memo(a8);function o8(e,t=0){const s=_e(e.connection.status),[i,r]=v.useState([]);return v.useEffect(()=>{if(s.state!=="open")return;let o=!0;return(async()=>{const{scripts:l}=await e.connection.call("scripts/list",{}),u=[];for(const d of l){if(d.packId===void 0)continue;const h=await e.connection.call("runs/tasks",{scriptId:d.id}).catch(()=>{});if(h===void 0||h.tasks.length===0)continue;const m=await e.connection.call("configs/profiles",{scriptId:d.id}).catch(()=>{});u.push({scriptId:d.id,scriptName:d.name,tasks:h.tasks,profiles:m})}o&&r(u)})().catch(()=>{}),()=>{o=!1}},[e,s.state,t]),v.useEffect(()=>e.connection.on("configs/profiles/changed",o=>{r(l=>l.map(u=>u.scriptId===o.scriptId?{...u,profiles:o.list}:u))}),[e]),i}const sE=[0,1,2,3,4,5].map(e=>({value:String(e),label:e===0?"不重试":`重试 ${e} 次`})),iE=[{value:"continue",label:"然后继续其他分支"},{value:"stop",label:"然后停止流水线"}],nl={"script-task":"脚本任务",agent:"agent 步骤",wait:"控制节点",notify:"发消息",gate:"人工确认",start:"开始",end:"结束"},bg={pending:"待运行",waiting:"等待中",running:"运行中",succeeded:"成功",failed:"失败",skipped:"跳过",cancelled:"取消"},l8={success:"成功后",failure:"失败后",always:"结束后"},cp={desktop:"鼠标键盘",adb:"模拟器",window:"后台窗口",none:""};function c8({data:e,selected:t}){var i,r,o,l;const s=(i=e.state)==null?void 0:i.state;return Wi(e.node)?n.jsxs("div",{className:`step-node marker ${e.node.kind} ${s??""} ${t?"selected":""}`,children:[e.node.kind==="end"&&n.jsx(Qr,{type:"target",position:tt.Left}),n.jsx("span",{children:nl[e.node.kind]}),e.node.kind==="end"&&s!==void 0&&s!=="pending"&&n.jsx("span",{className:`step-state ${s}`,children:((r=e.state)==null?void 0:r.detail)??bg[s]}),e.node.kind==="start"&&n.jsx(Qr,{type:"source",position:tt.Right})]}):n.jsxs("div",{className:`step-node ${s??""} ${t?"selected":""} ${e.issue!==void 0?"has-issue":""}`,children:[n.jsx(Qr,{type:"target",position:tt.Left}),n.jsxs("div",{className:"step-kind",children:[n.jsx("span",{children:nl[e.node.kind]}),e.input!==""&&n.jsx("span",{className:"badge",children:e.input}),e.node.waitForAll===!0&&n.jsx("span",{className:"badge",title:"等前面的节点全部结束再开始",children:"等全部"}),s!==void 0&&n.jsxs("span",{className:`step-state ${s}`,children:[bg[s],(((o=e.state)==null?void 0:o.attempts)??0)>1?` · 第 ${e.state.attempts} 次`:""]})]}),n.jsx("div",{className:"step-title",children:e.label}),e.sub!==""&&n.jsx("div",{className:"step-sub",children:e.sub}),((l=e.state)==null?void 0:l.detail)!==void 0&&e.state.detail!==""&&n.jsx("div",{className:"step-detail",children:e.state.detail}),e.issue!==void 0&&e.state===void 0&&n.jsx("div",{className:"step-detail issue",children:e.issue}),n.jsx(Qr,{type:"source",position:tt.Right})]})}const u8={step:c8};function d8(e){const t=new Map,s=(o,l)=>{if(t.has(o))return t.get(o);if(l.has(o))return 0;l.add(o);const u=e.edges.filter(h=>h.to===o).map(h=>s(h.from,l)+1),d=Math.max(0,...u);return t.set(o,d),d};for(const o of e.nodes)s(o.id,new Set);const i=new Map,r=new Map;for(const o of e.nodes){if(o.position!==void 0){r.set(o.id,o.position);continue}const l=t.get(o.id)??0,u=i.get(l)??0;i.set(l,u+1),r.set(o.id,{x:40+l*280,y:40+u*130})}return r}let h8=0;const ko=(e,t,s=new Set)=>{for(;;){const i=`${e}${++h8}`;if(!s.has(i)&&!t.nodes.some(r=>r.id===i))return i}};function m8(e,t){return e.nodes.every(s=>s.position!==void 0)?e:{...e,nodes:e.nodes.map(s=>s.position!==void 0||!t.has(s.id)?s:{...s,position:t.get(s.id)})}}let Br=null;const f8=e=>e instanceof HTMLElement&&e.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]')!==null;function p8({client:e,pipeline:t,onChange:s,run:i,check:r,runFrom:o,idle:l}){var G,K;const u=o1(),[d,h]=v.useState(0),m=o8(e,d),[p,g]=v.useState([]),x=p.length===1?p[0]:null,N=Z=>g(Z===null?[]:[Z]),[j,y]=v.useState(null),k=v.useRef(null),[_,S]=v.useState({}),E=v.useCallback(Z=>{var ee,J;if(Z.kind==="script-task"){const re=m.find(Ce=>Ce.scriptId===Z.scriptId),ie=re==null?void 0:re.tasks.find(Ce=>Ce.id===Z.taskId),ne=Object.entries(Z.params).map(([Ce,Fe])=>`${Ce}=${String(Fe)}`).join(" "),me=Z.profile===void 0?void 0:((J=(ee=re==null?void 0:re.profiles)==null?void 0:ee.items.find(Ce=>Ce.id===Z.profile))==null?void 0:J.name)??"已删除的配置";return{label:Z.title??`${(re==null?void 0:re.scriptName)??Z.scriptId} · ${(ie==null?void 0:ie.title)??Z.taskId}`,sub:[me===void 0?"":`配置:${me}`,ne].filter(Boolean).join(" · "),input:cp[(ie==null?void 0:ie.input)??"none"]??""}}return Z.kind==="wait"?{label:Z.title??(Z.minutes!==void 0?`等 ${Z.minutes} 分钟`:`等到 ${Z.until}`),sub:"",input:""}:Z.kind==="agent"?{label:Z.title??"agent 步骤",sub:Z.prompt.slice(0,40),input:""}:Wi(Z)?{label:nl[Z.kind],sub:"",input:""}:{label:Z.title??nl[Z.kind],sub:Z.text.slice(0,40),input:""}},[m]),O=v.useMemo(()=>d8(t),[t]),P=v.useMemo(()=>t.nodes.map(Z=>{var ee;return{id:Z.id,type:"step",position:O.get(Z.id),selected:p.includes(Z.id),..._[Z.id]===void 0?{}:{measured:_[Z.id]},data:{node:Z,...E(Z),state:i==null?void 0:i.nodes[Z.id],issue:(ee=r==null?void 0:r.issues.find(J=>J.nodeId===Z.id&&J.level==="error"))==null?void 0:ee.message}}}),[t,O,E,i,r,p,_]),H=v.useMemo(()=>t.edges.map((Z,ee)=>{var J;return{id:`e${ee}`,source:Z.from,target:Z.to,label:l8[Z.when],selected:ee===j,animated:((J=i==null?void 0:i.nodes[Z.from])==null?void 0:J.state)==="running",className:`edge-${Z.when}`}}),[t.edges,j,i]),B=v.useRef({past:[],future:[],at:0}),R=v.useCallback((Z,ee)=>{const J=B.current,re=Date.now();(ee===void 0||ee!==J.group||re-J.at>1e3)&&(J.past=[...J.past.slice(-99),{nodes:t.nodes,edges:t.edges}]),J.future=[],J.group=ee,J.at=re,s(m8(Z,O))},[t,O,s]),M=Z=>{const ee=B.current,J=Z==="past"?"future":"past",re=ee[Z].pop();re!==void 0&&(ee[J].push({nodes:t.nodes,edges:t.edges}),ee.group=void 0,s({...t,...re}),g(ie=>ie.filter(ne=>re.nodes.some(me=>me.id===ne))),y(null))},F=v.useCallback(Z=>{let ee=t,J;const re={},ie=new Map;for(const ne of Z)if(ne.type==="dimensions"&&ne.dimensions!==void 0)re[ne.id]=ne.dimensions;else if(ne.type==="select")ie.set(ne.id,ne.selected);else if(ne.type==="position"&&ne.position!==void 0)ee={...ee,nodes:ee.nodes.map(me=>me.id===ne.id?{...me,position:{x:Math.round(ne.position.x),y:Math.round(ne.position.y)}}:me)},J="move";else if(ne.type==="remove"){if(ee.nodes.some(me=>me.id===ne.id&&Wi(me)))continue;ee={...ee,nodes:ee.nodes.filter(me=>me.id!==ne.id),edges:ee.edges.filter(me=>me.from!==ne.id&&me.to!==ne.id)},ie.set(ne.id,!1),J=void 0}Object.keys(re).length>0&&S(ne=>({...ne,...re})),ie.size>0&&(g(ne=>[...ne.filter(me=>ie.get(me)!==!1),...[...ie].filter(([me,Ce])=>Ce&&!ne.includes(me)).map(([me])=>me)]),[...ie.values()].some(Boolean)&&y(null)),ee!==t&&R(ee,J)},[t,R]),L=v.useCallback(Z=>{var J;if(Z.source===Z.target||t.edges.some(re=>re.from===Z.source&&re.to===Z.target))return;const ee=t.nodes.find(re=>re.id===Z.target);(ee==null?void 0:ee.kind)==="start"||((J=t.nodes.find(re=>re.id===Z.source))==null?void 0:J.kind)==="end"||R({...t,edges:[...t.edges,{from:Z.source,to:Z.target,when:(ee==null?void 0:ee.kind)==="end"?"always":"success"}]})},[t,R]),A=()=>{const Z=t.nodes.filter(J=>p.includes(J.id)&&!Wi(J));if(Z.length===0)return!1;const ee=new Set(Z.map(J=>J.id));return Br={nodes:Z.map(J=>({...J,position:O.get(J.id)??{x:40,y:40}})),edges:t.edges.filter(J=>ee.has(J.from)&&ee.has(J.to)),pasted:0},!0},I=()=>{if(Br===null||t.nodes.length+Br.nodes.length>60)return;const Z=++Br.pasted,ee=new Map;for(const ie of Br.nodes)ee.set(ie.id,ko(ie.id.replace(/\d+$/,"")||"step",t,new Set(ee.values())));const J=Br.nodes.map(ie=>{var ne,me;return{...ie,id:ee.get(ie.id),position:{x:(((ne=ie.position)==null?void 0:ne.x)??40)+40*Z,y:(((me=ie.position)==null?void 0:me.y)??40)+120*Z}}}),re=Br.edges.map(ie=>({...ie,from:ee.get(ie.from),to:ee.get(ie.to)}));R({...t,nodes:[...t.nodes,...J],edges:[...t.edges,...re]}),g(J.map(ie=>ie.id)),y(null)},z=()=>{const Z=new Set(t.nodes.filter(ee=>p.includes(ee.id)&&!Wi(ee)).map(ee=>ee.id));Z.size!==0&&(R({...t,nodes:t.nodes.filter(ee=>!Z.has(ee.id)),edges:t.edges.filter(ee=>!Z.has(ee.from)&&!Z.has(ee.to))}),g([]))},D=v.useRef(()=>{});D.current=Z=>{var J;if(!(Z.ctrlKey||Z.metaKey)||Z.altKey||f8(Z.target)||k.current===null||k.current.offsetParent===null)return;const ee=Z.key.toLowerCase();ee==="z"&&!Z.shiftKey?(Z.preventDefault(),M("past")):ee==="y"||ee==="z"&&Z.shiftKey?(Z.preventDefault(),M("future")):ee==="c"?(((J=window.getSelection())==null?void 0:J.toString())??"")===""&&A()&&Z.preventDefault():ee==="v"&&Br!==null&&(Z.preventDefault(),I())},v.useEffect(()=>{const Z=ee=>D.current(ee);return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[]);const V=Z=>{const ee=t.nodes.find(Me=>Me.kind==="start"),J=t.nodes.find(Me=>Me.kind==="end"),re=t.nodes.find(Me=>Me.id===x&&Me.kind!=="end")??ee,ie=re===void 0?void 0:O.get(re.id),ne=[...O.entries()].filter(([Me])=>Me!==(J==null?void 0:J.id)).map(([,Me])=>Me),me=ie===void 0?Math.max(0,...ne.map(Me=>Me.x))+280:ie.x+280;let Ce=(ie==null?void 0:ie.y)??40;for(;ne.some(Me=>Math.abs(Me.x-me)<200&&Math.abs(Me.y-Ce)<100);)Ce+=130;const Fe=[...t.nodes.map(Me=>{var fe,ke;return Me.kind==="end"?{...Me,position:{x:Math.max(((fe=O.get(Me.id))==null?void 0:fe.x)??0,me+300),y:((ke=O.get(Me.id))==null?void 0:ke.y)??Ce}}:Me}),{...Z,position:{x:me,y:Ce}}];R({...t,nodes:Fe}),N(Z.id),y(null)},U=t.nodes.find(Z=>Z.id===x),q=j===null?void 0:t.edges[j],te=Z=>R({...t,nodes:t.nodes.map(ee=>ee.id===Z.id?Z:ee)},`node:${Z.id}`);return n.jsxs("div",{className:"pipeline-editor",ref:k,children:[n.jsxs("div",{className:"pipeline-palette","aria-label":"节点",children:[n.jsx("div",{className:"sidebar-label",children:"脚本任务"}),m.length===0&&n.jsx("div",{className:"muted small pad",children:"脚本库里还没有带脚本包的脚本"}),m.map(Z=>n.jsxs("details",{className:"palette-group",open:m.length<=3,children:[n.jsx("summary",{children:Z.scriptName}),Z.tasks.map(ee=>n.jsxs("button",{className:"palette-item",title:ee.description??ee.title,onClick:()=>V({id:ko(Z.scriptId.replace(/[^A-Za-z0-9_-]/g,"").slice(0,20)||"task",t),kind:"script-task",scriptId:Z.scriptId,taskId:ee.id,params:{}}),children:[n.jsx("span",{children:ee.title}),cp[ee.input]!==""&&n.jsx("span",{className:"badge",children:cp[ee.input]})]},ee.id))]},Z.scriptId)),n.jsx("div",{className:"sidebar-label pack-label",children:"其他步骤"}),n.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("agent",t),kind:"agent",prompt:"检查活动还剩几天,快结束的提醒我"}),children:"agent 步骤"}),n.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("wait",t),kind:"wait",minutes:10}),children:"控制节点"}),n.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("notify",t),kind:"notify",text:`${t.name}跑完了`}),children:"发消息"}),n.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("gate",t),kind:"gate",text:"确认后继续"}),children:"人工确认"}),n.jsx("p",{className:"muted small pad",children:"从节点右边的圆点拖到另一个节点左边,表示「这个完成后再运行那个」。没有连线的节点会同时开始;需要同一资源的会自动排队。"})]}),n.jsxs("div",{className:"pipeline-canvas",children:[n.jsxs(T9,{nodes:P,edges:H,nodeTypes:u8,onNodesChange:F,onConnect:L,onNodeClick:()=>y(null),onEdgeClick:(Z,ee)=>{y(Number(ee.id.slice(1))),N(null)},onPaneClick:()=>{N(null),y(null)},deleteKeyCode:["Delete","Backspace"],colorMode:u,fitView:!0,fitViewOptions:{maxZoom:1,padding:.2},proOptions:{hideAttribution:!0},children:[n.jsx(L9,{gap:20}),n.jsx(Z9,{showInteractive:!1})]}),!t.nodes.some(Z=>!Wi(Z))&&n.jsx("div",{className:"canvas-hint",children:"从左边点一个任务加到画布上,再从节点右边的圆点拖到下一个节点,连成先后顺序"})]}),n.jsxs("aside",{className:"pipeline-inspector",children:[U!==void 0&&n.jsx(x8,{client:e,node:U,pipeline:t,run:i,scripts:m,onChange:te,onTasksChanged:()=>h(Z=>Z+1),runFrom:o,onRemove:z}),q!==void 0&&n.jsxs("section",{className:"inspector-section",children:[n.jsx("h4",{children:"连线"}),n.jsxs("p",{className:"muted small",children:["「",((G=t.nodes.find(Z=>Z.id===q.from))==null?void 0:G.title)??q.from,"」→「",((K=t.nodes.find(Z=>Z.id===q.to))==null?void 0:K.title)??q.to,"」"]}),n.jsx("label",{className:"field-label",htmlFor:"edge-when",children:"什么时候运行下一步"}),n.jsx(Mt,{id:"edge-when",value:q.when,onChange:Z=>R({...t,edges:t.edges.map((ee,J)=>J===j?{...ee,when:Z}:ee)}),options:[{value:"success",label:"上一步成功后"},{value:"failure",label:"上一步失败后"},{value:"always",label:"上一步结束后",hint:"不管成败"}]}),n.jsx("button",{className:"danger-outline small-button",onClick:()=>{R({...t,edges:t.edges.filter((Z,ee)=>ee!==j)}),y(null)},children:"删除连线"})]}),p.length>1&&q===void 0&&n.jsxs("section",{className:"inspector-section",children:[n.jsxs("h4",{children:["已选 ",p.length," 个节点"]}),n.jsx("p",{className:"muted small",children:"Ctrl+C 复制、Ctrl+V 粘贴(连同它们之间的连线),Delete 删除,Ctrl+Z 撤销。开始和结束不会被复制或删除。"}),n.jsx("button",{className:"danger-outline small-button",onClick:z,children:"删除这些节点"})]}),U===void 0&&q===void 0&&p.length<=1&&(l??n.jsx("p",{className:"muted small pad",children:"点一个节点或连线来修改。选中后按 Delete 也能删除,Ctrl+C / Ctrl+V 复制粘贴,Ctrl+Z 撤销。"})),(U!==void 0||q!==void 0||p.length>1)&&l!==void 0&&n.jsx("button",{className:"link-button small back-to-pipeline",onClick:()=>{N(null),y(null)},children:"← 流水线设置"})]})]})}function g8({client:e,value:t,onChange:s}){const i=v.useRef(null),r=pS({client:e,text:t,setText:s,area:i,placement:"below"});return n.jsxs("div",{className:"slash-anchor",children:[n.jsx("textarea",{id:"node-prompt",ref:i,className:"text-input plain",rows:4,value:t,placeholder:"例如:/game-arknights 看看活动商店还剩什么没换",onChange:o=>s(o.target.value),onKeyDown:o=>{r.onKeyDown(o)}}),r.menu,n.jsx("p",{className:"muted small",children:"输入 / 可以选命令或技能,运行时展开成完整的指令。"})]})}function x8({client:e,node:t,pipeline:s,run:i,scripts:r,onChange:o,onRemove:l,onTasksChanged:u,runFrom:d}){var N,j;const[h,m]=v.useState(null),p=i==null?void 0:i.nodes[t.id],g=t.kind==="script-task"?(N=r.find(y=>y.scriptId===t.scriptId))==null?void 0:N.tasks.find(y=>y.id===t.taskId):void 0,x=t.onFailure;return Wi(t)?n.jsxs("section",{className:"inspector-section",children:[n.jsx("h4",{children:nl[t.kind]}),n.jsx("p",{className:"muted small",children:t.kind==="start"?"流水线从这里开始。从它连出去的步骤最先运行(没有连线的步骤也会一开始就运行)。":"所有步骤都结束后到这里,不管成败;连到它的线只是为了看得清楚。"}),(p==null?void 0:p.detail)!==void 0&&n.jsx("div",{className:"muted small",children:p.detail})]}):n.jsxs("section",{className:"inspector-section",children:[n.jsx("h4",{children:nl[t.kind]}),n.jsx("label",{className:"field-label",htmlFor:"node-title",children:"名称(可选)"}),n.jsx("input",{id:"node-title",className:"text-input plain",value:t.title??"",maxLength:60,onChange:y=>{const{title:k,..._}=t;o(y.target.value===""?_:{..._,title:y.target.value})}}),t.kind==="script-task"&&n.jsx(h1,{id:"node-profile",label:"用哪份配置",list:((j=r.find(y=>y.scriptId===t.scriptId))==null?void 0:j.profiles)??null,value:t.profile,onChange:y=>{const{profile:k,..._}=t;o(y===void 0?_:{..._,profile:y})}}),t.kind==="script-task"&&g!==void 0&&Object.entries(g.params).map(([y,k])=>n.jsx(u1,{client:e,scriptId:t.scriptId,taskId:t.taskId,name:y,spec:k,profile:t.profile,value:String(t.params[y]??(k.type==="boolean"?k.default??!1:"")),onCreated:u,onChange:_=>{const{[y]:S,...E}=t.params,O=k.type==="boolean"?_==="true":k.type==="integer"||k.type==="number"?Number(_):_;o({...t,params:_===""?E:{...E,[y]:O}})}},y)),t.kind==="agent"&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:"node-prompt",children:"让 agent 做什么"}),n.jsx(g8,{client:e,value:t.prompt,onChange:y=>o({...t,prompt:y})})]}),(t.kind==="notify"||t.kind==="gate")&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:"node-text",children:t.kind==="notify"?"消息内容":"确认时显示的话"}),n.jsx("textarea",{id:"node-text",className:"text-input plain",rows:3,value:t.text,onChange:y=>o({...t,text:y.target.value})})]}),t.kind==="wait"&&n.jsxs("div",{className:"key-input",children:[n.jsx(Mt,{"aria-label":"等待方式",value:t.minutes!==void 0?"minutes":"until",options:[{value:"minutes",label:"等几分钟"},{value:"until",label:"等到某个时间"}],onChange:y=>o(y==="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?n.jsx("input",{className:"text-input plain",type:"number",min:1,max:1440,value:t.minutes,onChange:y=>o({...t,minutes:Math.max(1,Math.min(1440,Math.round(Number(y.target.value)||1)))})}):n.jsx("input",{className:"text-input plain",type:"time",value:t.until,onChange:y=>o({...t,until:y.target.value})})]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:t.waitForAll===!0,onChange:y=>{const{waitForAll:k,..._}=t;o(y.target.checked?{..._,waitForAll:!0}:_)}}),"等前面的节点全部结束再开始"]}),n.jsx("p",{className:"muted small",children:"不只等连进来的线:画布上不在它后面的节点(其他分支也算)都结束了(成功、失败、跳过都算)才开始。用来让并行的几条分支汇合。"}),t.kind!=="gate"&&t.kind!=="notify"&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:"node-retries",children:"失败时"}),n.jsxs("div",{className:"select-stack",children:[n.jsx(Mt,{id:"node-retries","aria-label":"重试次数",value:x===void 0?"inherit":String(x.retries),options:[{value:"inherit",label:"按流水线的设置"},...sE],onChange:y=>{const{onFailure:k,..._}=t;if(y==="inherit")return o(_);o({..._,onFailure:{retries:Number(y),then:(x==null?void 0:x.then)??s.onFailure.then}})}}),n.jsx(Mt,{"aria-label":"仍失败时",disabled:x===void 0,value:(x??s.onFailure).then,options:iE,onChange:y=>o({...t,onFailure:{retries:(x==null?void 0:x.retries)??s.onFailure.retries,then:y}})})]}),x===void 0&&n.jsxs("p",{className:"muted small",children:["流水线的设置:",s.onFailure.retries>0?`重试 ${s.onFailure.retries} 次,`:"不重试,","然后",s.onFailure.then==="stop"?"停止流水线":"继续其他分支"]})]}),p!==void 0&&n.jsxs("div",{className:"inspector-run",children:[n.jsx("div",{className:"sidebar-label",children:"这次运行"}),n.jsxs("div",{children:[bg[p.state],p.attempts>1?` · 第 ${p.attempts} 次`:""]}),p.detail!==void 0&&n.jsx("div",{className:"muted small",children:p.detail}),p.repair&&n.jsxs("div",{className:"small",children:["后续补偿",p.repair.state==="succeeded"?"成功":"未成功"," · ",p.repair.runId]}),p.runIds.length>0&&n.jsxs("div",{className:"muted small",children:["脚本运行:",p.runIds.join("、"),"(在「运行」页看日志)"]}),t.kind==="gate"&&p.state==="running"&&i!==void 0&&n.jsxs("div",{className:"key-actions",children:[n.jsx("button",{className:"primary small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:i.id,nodeId:t.id,decision:"continue"}).catch(y=>m($e(y))),children:"继续"}),n.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:i.id,nodeId:t.id,decision:"stop"}).catch(y=>m($e(y))),children:"停止"})]})]}),h!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:h})]}),d!==void 0&&n.jsxs("div",{className:"run-from",children:[n.jsxs("button",{className:"small-button",onClick:()=>d(t.id),children:[n.jsx(Q,{name:"arrow"}),"从这里开始运行"]}),n.jsx("span",{className:"muted small",children:"这一步和它后面的会运行,前面的不运行(例如前面已经跑过了)"})]}),n.jsx("button",{className:"danger-outline small-button",onClick:l,children:"删除这个节点"})]})}const Xd={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]},v8=()=>({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"}),y8=(e,t)=>{var s,i;return(((s=t.lastRun)==null?void 0:s.startedAt)??-1)-(((i=e.lastRun)==null?void 0:i.startedAt)??-1)||(t.updatedAt??0)-(e.updatedAt??0)||e.name.localeCompare(t.name,"zh-CN")},rE="adg.pipelines.last",b8=()=>{try{return localStorage.getItem(rE)}catch{return null}},k8=e=>{try{localStorage.setItem(rE,e)}catch{}};function j8({client:e,openSettings:t,arg:s}){const i=_e(e.connection.status),r=vn(3e4),[o,l]=v.useState(null),[u,d]=v.useState(null),[h,m]=v.useState(null),[p,g]=v.useState(""),[x,N]=v.useState([]),[j,y]=v.useState(null),[k,_]=v.useState(null),[S,E]=v.useState(null),[O,P]=v.useState(null),[H,B]=v.useState(0);v.useEffect(()=>e.connection.on("pipelines/changed",()=>B(re=>re+1)),[e]);const R=_e(e.capabilities),[M,F]=v.useState(null),[L,A]=v.useState(0);v.useEffect(()=>e.connection.on("schedule/changed",()=>A(re=>re+1)),[e]),v.useEffect(()=>{if(i.state!=="open"||!R.has("schedule"))return;let re=!0;return e.connection.call("schedule/status",{}).then(ie=>{re&&F(ie.settings)}).catch(()=>{}),()=>{re=!1}},[e,i.state,R,L]);const I=async re=>{try{F((await e.connection.call("schedule/settings/set",re)).settings)}catch(ie){P($e(ie))}};v.useEffect(()=>{s!==void 0&&d(s)},[s]),v.useEffect(()=>{if(i.state!=="open")return;let re=!0;return e.connection.call("pipelines/list",{}).then(ie=>{if(!re)return;const ne=[...ie.items].sort(y8);l(ne);const me=b8();d(Ce=>{var Fe,Me;return Ce??((Fe=ne.find(fe=>fe.id===me))==null?void 0:Fe.id)??((Me=ne[0])==null?void 0:Me.id)??null})}).catch(ie=>{re&&P($e(ie))}),()=>{re=!1}},[e,i.state,H]),v.useEffect(()=>{if(u===null||i.state!=="open"||(h==null?void 0:h.id)===u&&(o!=null&&o.every(ie=>ie.id!==u)))return;let re=!0;return e.connection.call("pipelines/get",{id:u}).then(ie=>{if(!re)return;const ne=FR(ie);k8(ne.id),m(ne),g(JSON.stringify(ne)),_(null)}).catch(()=>{}),e.connection.call("pipelines/runs",{pipelineId:u,limit:10}).then(ie=>{re&&N(ie.items)}).catch(()=>{}),y(null),()=>{re=!1}},[e,u,i.state,H]),v.useEffect(()=>e.connection.on("pipelines/run",re=>{re.pipelineId===u&&N(ie=>[re,...ie.filter(ne=>ne.id!==re.id)].sort((ne,me)=>me.startedAt-ne.startedAt).slice(0,10))}),[e,u]);const z=h!==null&&JSON.stringify(h)!==p,D=h!==null&&o!==null&&o.every(re=>re.id!==h.id),V=x.find(re=>{var ie;return re.id===(j??((ie=x[0])==null?void 0:ie.id))}),U=x.find(re=>re.state==="running"),q=U!==void 0&&(U.stopping!==void 0||S==="cancel");v.useEffect(()=>{if(h===null||!h.nodes.some(ie=>!Wi(ie))){_(null);return}const re=setTimeout(()=>{e.connection.call("pipelines/check",{pipeline:h}).then(_).catch(()=>{})},400);return()=>clearTimeout(re)},[e,h]);const te=async(re,ie)=>{E(re),P(null);try{await ie()}catch(ne){P($e(ne))}finally{E(null)}},G=()=>te("save",async()=>{if(h===null)return;const re=await e.connection.call("pipelines/save",{pipeline:h});m(re.pipeline),g(JSON.stringify(re.pipeline)),_(re.check),d(re.pipeline.id)}),K=re=>te("run",async()=>{if(h===null)return;(z||D)&&await G();const ie=await e.connection.call("pipelines/run",{id:h.id,...re===void 0?{}:{from:re}});y(ie.id)}),Z=()=>te("remove",async()=>{h!==null&&(D||await e.connection.call("pipelines/remove",{id:h.id}),m(null),d(null))}),ee=v.useCallback(re=>m(re),[]),J=()=>{const re=v8();m(re),g(""),d(re.id),N([]),_(null)};return n.jsxs("section",{className:"main scripts-page pipelines-page",children:[n.jsxs("header",{className:"page-header",children:[n.jsxs("div",{className:"breadcrumb",children:[n.jsx("span",{children:"编排"}),n.jsx("span",{className:"breadcrumb-divider",children:"/"}),n.jsx("h1",{children:"流水线"})]}),n.jsx(S8,{list:o??[],current:h,isNew:D,now:r,onPick:d}),n.jsxs("div",{className:"page-actions",children:[n.jsxs("button",{className:"small-button",onClick:()=>t("schedule"),children:[n.jsx(Q,{name:"settings"}),"定时与自启"]}),n.jsxs("button",{className:"primary small-button",onClick:J,children:[n.jsx(Q,{name:"plus"}),"新建流水线"]})]})]}),n.jsx("div",{className:"pipeline-main",children:h===null?n.jsxs("div",{className:"empty",children:[n.jsx(Q,{name:"flow"}),o!==null&&o.length===0?n.jsxs(n.Fragment,{children:[n.jsx("p",{children:"还没有流水线。"}),n.jsx("p",{className:"muted small",children:"新建一条,或对 agent 说「先跑方舟日常,同时跑三月七,都完了发飞书」"})]}):n.jsx("p",{children:"在上面选一条流水线,或新建一条。"})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"pipeline-toolbar",children:[n.jsx("input",{className:"text-input plain pipeline-name",value:h.name,maxLength:60,"aria-label":"流水线名称",onChange:re=>m({...h,name:re.target.value})}),h.draft===!0&&n.jsx("span",{className:"badge warn",title:"agent 生成的草稿:保存后才会按定时运行",children:"agent 草稿"}),z&&n.jsx("span",{className:"muted small",children:"未保存"}),n.jsx("span",{className:"spacer"}),q?n.jsxs("button",{className:"danger-outline small-button stopping",disabled:!0,"aria-busy":"true",children:[n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),"正在停止…"]}):U!==void 0?n.jsx("button",{className:"danger-outline small-button",disabled:S!==null,onClick:()=>void te("cancel",()=>e.connection.call("pipelines/cancel",{runId:U.id})),children:"取消运行"}):n.jsxs("button",{className:"small-button",disabled:S!==null||!h.nodes.some(re=>!Wi(re))||(k==null?void 0:k.ok)===!1,onClick:()=>void K(),children:[n.jsx(Q,{name:"arrow"}),"运行"]}),n.jsx("button",{className:"primary small-button",disabled:S!==null||!z&&!D&&h.draft!==!0,onClick:()=>void G(),children:S==="save"?"保存中…":h.draft===!0&&!z?"确认并保存":"保存"}),n.jsx("button",{className:"small-button",disabled:S!==null||U!==void 0,onClick:()=>void Ms({title:`删除流水线「${h.name}」?`,message:"它的步骤和定时都会删掉,不能撤销。",confirmLabel:"删除",danger:!0}).then(re=>{re&&Z()}),children:"删除"})]}),q&&n.jsxs("div",{className:"notice info left small pipeline-stopping",role:"status",children:[n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),n.jsxs("span",{children:["已收到停止指令。",U.stopping??"正在通知正在运行的步骤…"]})]}),O!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:O})]}),n.jsx(p8,{client:e,pipeline:h,onChange:ee,run:V,check:k,runFrom:U!==void 0||S!==null||(k==null?void 0:k.ok)===!1?void 0:re=>void K(re),idle:n.jsx(_8,{pipeline:h,check:k,runs:x,shownRun:V==null?void 0:V.id,onShowRun:y,others:o??[],onChange:ee,now:r,startup:M,onStartup:re=>void I(re)})},h.id)]})})]})}function N8({check:e,pipeline:t}){if(e===null)return null;const s=i=>{const r=t.nodes.find(o=>o.id===i);return r===void 0?"":`${r.title??r.id}:`};return n.jsxs("section",{className:"side-pane",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"运行前检查"}),n.jsx("p",{className:"muted small",children:e.estimateMinutes===void 0?"部分任务没有预计时长":`预计约 ${e.estimateMinutes} 分钟`})]}),n.jsx("span",{className:`badge ${e.ok?"ok":"warn"}`,children:e.ok?"可以运行":"有问题"})]}),e.issues.length===0&&n.jsx("div",{className:"muted small",children:"没有发现问题。"}),n.jsx("ul",{className:"incident-steps",children:e.issues.map((i,r)=>n.jsxs("li",{className:i.level==="error"||i.level==="warning"?"failed":"",children:[i.level==="error"?"✗":i.level==="warning"?"!":"ℹ"," ",s(i.nodeId),i.message]},r))})]})}function w8({runs:e,shown:t,onShow:s,now:i}){if(e.length===0)return n.jsx("section",{className:"side-pane",children:n.jsx("p",{className:"muted small",children:"还没有运行过。"})});const r={manual:"手动",schedule:"定时",autostart:"启动时",agent:"agent",after:"接续"};return n.jsxs("section",{className:"side-pane",children:[n.jsx("div",{className:"run-history",children:e.map(o=>n.jsxs("button",{className:`run-row ${o.id===t?"active":""}`,onClick:()=>s(o.id),children:[n.jsx("span",{className:`badge ${Xd[o.state][0]}`,children:Xd[o.state][1]}),n.jsx("span",{className:"run-title",children:r[o.trigger.kind]??o.trigger.kind}),n.jsx("span",{className:"muted small run-outcome",children:o.outcome??"…"}),n.jsx("span",{className:"session-time",children:vt(o.startedAt,i)})]},o.id))}),n.jsx("p",{className:"muted small",children:"选中一次运行,画布上的节点会显示它的状态;点节点看详情和对应的脚本运行。"})]})}function S8({list:e,current:t,isNew:s,now:i,onPick:r}){const[o,l]=v.useState(!1),u=v.useRef(null);return v.useEffect(()=>{if(!o)return;const d=h=>{u.current!==null&&!u.current.contains(h.target)&&l(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[o]),e.length===0&&t===null?n.jsx("span",{className:"spacer"}):n.jsxs("div",{className:"pipeline-switcher",ref:u,children:[n.jsxs("button",{className:"small-button switcher-button","aria-haspopup":"listbox","aria-expanded":o,onClick:()=>l(d=>!d),children:[n.jsx(Q,{name:"flow"}),n.jsxs("span",{className:"switcher-name",children:[(t==null?void 0:t.name)??"选择流水线",s?"(未保存)":""]}),n.jsxs("span",{className:"muted small",children:[e.length," 条"]}),n.jsx(Q,{name:"chevron-down"})]}),o&&n.jsxs("div",{className:"switcher-menu",role:"listbox","aria-label":"流水线",children:[e.map(d=>n.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)&&!s?"active":""}`,onClick:()=>{r(d.id),l(!1)},children:[n.jsxs("span",{className:"switcher-item-main",children:[n.jsx("span",{children:d.name}),n.jsxs("span",{className:"muted small",children:[d.nodes," 个步骤",d.schedule.enabled&&d.schedule.times.length>0?` · 每天 ${d.schedule.times.join("、")}`:"",d.lastRun===void 0?"":` · ${vt(d.lastRun.startedAt,i)}`]})]}),d.draft?n.jsx("span",{className:"badge warn",children:"草稿"}):d.lastRun!==void 0?n.jsx("span",{className:`badge ${Xd[d.lastRun.state][0]}`,children:Xd[d.lastRun.state][1]}):null]},d.id)),e.length===0&&n.jsx("div",{className:"muted small pad",children:"还没有保存的流水线"})]})]})}function _8({pipeline:e,check:t,runs:s,shownRun:i,onShowRun:r,others:o,onChange:l,now:u,startup:d,onStartup:h}){const[m,p]=v.useState(s.some(x=>x.state==="running")?"runs":"check"),g=(t==null?void 0:t.issues.filter(x=>x.level==="error").length)??0;return n.jsxs("div",{className:"pipeline-side",children:[n.jsxs("nav",{className:"tabs side-tabs",role:"tablist","aria-label":"流水线",children:[n.jsxs("button",{role:"tab","aria-selected":m==="check",className:m==="check"?"active":"",onClick:()=>p("check"),children:["检查",g>0?` · ${g}`:""]}),n.jsx("button",{role:"tab","aria-selected":m==="runs",className:m==="runs"?"active":"",onClick:()=>p("runs"),children:"运行记录"}),n.jsx("button",{role:"tab","aria-selected":m==="schedule",className:m==="schedule"?"active":"",onClick:()=>p("schedule"),children:"定时与失败"})]}),m==="check"&&(t===null?n.jsx("p",{className:"muted small pad",children:"加上步骤后会自动检查。"}):n.jsx(N8,{check:t,pipeline:e})),m==="runs"&&n.jsx(w8,{runs:s,shown:i,onShow:r,now:u}),m==="schedule"&&n.jsx(C8,{pipeline:e,others:o,onChange:l,startup:d,onStartup:h}),n.jsx("p",{className:"muted small pad",children:"点画布上的节点或连线来修改它;选中后按 Delete 删除。Ctrl+点击或按住 Shift 拖动可以选多个节点,Ctrl+C / Ctrl+V 复制粘贴,Ctrl+Z 撤销、Ctrl+Y 重做。"})]})}const E8=["日","一","二","三","四","五","六"],Fj={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function C8({pipeline:e,others:t,onChange:s,startup:i,onStartup:r}){const o=(i==null?void 0:i.autostartPipelines.includes(e.id))===!0,l=e.schedule,[u,d]=v.useState(l.times.join(","));v.useEffect(()=>d(l.times.join(",")),[e.id]);const h=g=>s({...e,schedule:{...l,...g}}),m=v.useMemo(()=>u.split(/[,,\s]+/).map(g=>g.trim()).filter(Boolean).map(g=>/^\d:\d\d$/.test(g)?`0${g}`:g),[u]),p=m.filter(g=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(g));return n.jsxs("section",{className:"side-pane",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:l.enabled,onChange:g=>h({enabled:g.target.checked})}),"按定时自动运行",e.draft===!0?"(草稿要先保存)":""]}),n.jsx("label",{className:"field-label",htmlFor:"pl-times",children:"时间(24 小时制,多个用逗号分开)"}),n.jsx("input",{id:"pl-times",className:"text-input",value:u,placeholder:"04:30,16:30",onChange:g=>d(g.target.value),onBlur:()=>{p.length===0&&h({times:[...new Set(m)].sort()})}}),p.length>0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsxs("span",{children:["时间写成 HH:MM:",p.join("、")]})]}),n.jsxs("div",{className:"chip-row",role:"group","aria-label":"星期",children:[E8.map((g,x)=>n.jsxs("button",{className:`chip ${l.days.includes(x)?"active":""}`,onClick:()=>h({days:l.days.includes(x)?l.days.filter(N=>N!==x):[...l.days,x].sort()}),children:["周",g]},g)),n.jsx("span",{className:"muted small",children:l.days.length===0?"不选=每天":""})]}),i!==null&&n.jsxs("div",{className:"startup-box",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:o,disabled:e.draft===!0,onChange:g=>r({autostartPipelines:g.target.checked?[...i.autostartPipelines,e.id]:i.autostartPipelines.filter(x=>x!==e.id)})}),"软件启动时运行",e.draft===!0?"(草稿要先保存)":""]}),o&&n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"check-label sub",children:[n.jsx("input",{type:"checkbox",checked:i.firstStartOnly,onChange:g=>r({firstStartOnly:g.target.checked})}),"只在每天第一次启动时运行(每天从 4:00 算起)"]}),n.jsxs("label",{className:"check-label sub",children:[n.jsx("input",{type:"checkbox",checked:i.skipIfRanToday,onChange:g=>r({skipIfRanToday:g.target.checked})}),"今天(4:00 起)已经成功运行过就跳过"]}),n.jsxs("p",{className:"muted small",children:["打开桌面版(自己打开或开机自启)后",i.autostart?`开机自启时等 ${i.autostartDelaySeconds} 秒、自己打开时等 10 秒`:"等 10 秒","再运行;dsh 崩溃后自动重启不算。和游戏一样,每天从 4:00 算起:凌晨 2 点启动还算前一天。这两项对所有「软件启动时运行」的流水线生效。"]})]})]}),n.jsx("label",{className:"field-label",htmlFor:"pl-catchup",children:"错过多少分钟以内还补跑(睡眠、刚开机)"}),n.jsx("input",{id:"pl-catchup",className:"text-input plain",type:"number",min:0,max:720,value:l.catchUpMinutes,onChange:g=>h({catchUpMinutes:Math.max(0,Math.min(720,Math.round(Number(g.target.value)||0)))})}),n.jsx("label",{className:"field-label",htmlFor:"pl-after",children:"另一条流水线成功后接着运行"}),n.jsx(Mt,{id:"pl-after",value:l.after??"",onChange:g=>{const{after:x,...N}=l;s({...e,schedule:g===""?N:{...N,after:g}})},options:[{value:"",label:"不接续"},...t.filter(g=>g.id!==e.id).map(g=>({value:g.id,label:g.name}))]}),n.jsx("label",{className:"field-label",htmlFor:"pl-fail",children:"节点失败时(节点自己没设置时)"}),n.jsxs("div",{className:"select-stack",children:[n.jsx(Mt,{id:"pl-fail","aria-label":"重试次数",value:String(e.onFailure.retries),options:sE,onChange:g=>s({...e,onFailure:{...e.onFailure,retries:Number(g)}})}),n.jsx(Mt,{"aria-label":"仍失败时",value:e.onFailure.then,options:iE,onChange:g=>s({...e,onFailure:{...e.onFailure,then:g}})})]}),n.jsx("div",{className:"field-label",children:"结束后"}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:e.closeGameAfter,onChange:g=>s({...e,closeGameAfter:g.target.checked})}),"关闭游戏(任务玩过的电脑游戏和模拟器里的游戏)"]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:e.stopEmulatorAfter,onChange:g=>s({...e,stopEmulatorAfter:g.target.checked})}),"关闭模拟器"]}),n.jsx("label",{className:"field-label",htmlFor:"pl-power",children:"然后电脑"}),n.jsx(Mt,{id:"pl-power",value:e.powerAfter,onChange:g=>s({...e,powerAfter:g}),options:[{value:"none",label:"保持开着"},{value:"sleep",label:"睡眠"},{value:"hibernate",label:"休眠",hint:"断电也不丢失进度,唤醒比睡眠慢"},{value:"shutdown",label:"关机"}]}),e.powerAfter!=="none"&&n.jsxs("p",{className:"muted small",children:["等其他任务都结束后先倒计时",i===null?"":` ${i.powerCountdownSeconds} 秒`,",界面和飞书里都可以取消;15 分钟内还有定时任务就不",Fj[e.powerAfter],"。在这里手动点运行、或运行被取消时不会",Fj[e.powerAfter],"。",e.powerAfter==="shutdown"?"关机会强制关闭所有程序。":"想让电脑按时醒来跑定时任务,在「设置 → 定时与自启」打开定时唤醒。"]})]})}const Uj=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"}),Bj={fired:["ok","已运行"],missed:["warn","错过"],skipped:["","跳过"],failed:["warn","没能运行"]};function A8({client:e}){const t=_e(e.connection.status),s=vn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(0),[u,d]=v.useState(!1),[h,m]=v.useState(null);v.useEffect(()=>e.connection.on("schedule/changed",()=>l(x=>x+1)),[e]),v.useEffect(()=>e.connection.on("pipelines/changed",()=>l(x=>x+1)),[e]),v.useEffect(()=>e.connection.on("schedule/power",x=>r(N=>N===null?N:{...N,power:x})),[e]),v.useEffect(()=>{if(t.state!=="open")return;let x=!0;return e.connection.call("schedule/status",{}).then(N=>{x&&r(N)}).catch(N=>{x&&m($e(N))}),()=>{x=!1}},[e,t.state,o]);const p=async x=>{d(!0),m(null);try{r(await e.connection.call("schedule/settings/set",x))}catch(N){m($e(N))}finally{d(!1)}},g=i==null?void 0:i.settings;return n.jsxs("div",{className:"settings-page",children:[n.jsx("h2",{children:"定时与自启"}),n.jsx("p",{children:"每条流水线的运行时间和结束后做什么(关游戏、关模拟器、睡眠或关机)在「编排」页里设置。这里设置电脑开机登录后是否自动启动 MultiGameAssistant,以及电脑睡着时要不要按时醒来。关掉窗口后程序在托盘里继续运行,定时照常执行。"}),i!==null&&g!==void 0&&n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"开机自启"}),n.jsx("p",{className:"muted small",children:i.autostart.detail??(i.autostart.registered?"已在 Windows 任务计划程序中注册(登录后启动,最小化到托盘)":"登录 Windows 后自动启动并最小化到托盘")})]}),n.jsx("span",{className:`badge ${i.autostart.registered?"ok":""}`,children:i.autostart.registered?"已开启":"未开启"})]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:g.autostart,disabled:u||!i.autostart.available,onChange:x=>void p({autostart:x.target.checked})}),"登录 Windows 后自动启动"]}),n.jsxs("div",{className:"notice info left small",children:[n.jsx(Q,{name:"info"}),n.jsxs("span",{children:["软件启动时运行哪些流水线、是否只在每天第一次启动时运行,在「编排」页每条流水线的「定时与失败」里设置。",g.autostartPipelines.length>0?`现在有 ${g.autostartPipelines.length} 条。`:""]})]}),n.jsx("label",{className:"field-label",htmlFor:"autostart-delay",children:"开机自启后等待多少秒再运行流水线(等网络、桌面和显卡驱动就绪)"}),n.jsx("input",{id:"autostart-delay",className:"text-input plain",type:"number",min:0,max:1800,defaultValue:g.autostartDelaySeconds,onBlur:x=>void p({autostartDelaySeconds:Math.max(0,Math.min(1800,Math.round(Number(x.target.value)||0)))})}),i.autostarted&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(Q,{name:"info"}),n.jsx("span",{children:"这次是开机自动启动的。"})]})]}),i!==null&&g!==void 0&&n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"定时唤醒"}),n.jsx("p",{className:"muted small",children:i.wake.detail??(i.wake.registered&&i.wake.next!==void 0?`已在 Windows 任务计划程序中注册,下次在 ${Uj(i.wake.next)} 唤醒`:"电脑睡眠(或休眠)时,在定时任务开始前 2 分钟把它唤醒")})]}),n.jsx("span",{className:`badge ${i.wake.registered?"ok":""}`,children:i.wake.registered?"已开启":"未开启"})]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:g.wakeToRun,disabled:u||!i.wake.available,onChange:x=>void p({wakeToRun:x.target.checked})}),"睡眠时按定时唤醒电脑"]}),n.jsx("p",{className:"muted small",children:"关机后不能唤醒。程序没开着时,唤醒会顺便把它在托盘里打开(不运行「软件启动时运行」的流水线)。要在 Windows 电源选项里允许唤醒定时器:控制面板 → 电源选项 → 更改计划设置 → 更改高级电源设置 → 睡眠 → 允许使用唤醒定时器 → 启用(笔记本的「使用电池」也要改)。"}),n.jsx("h3",{children:"运行时防睡眠"}),n.jsxs("p",{className:"muted small",children:["流水线或脚本运行时,电脑不会自己睡眠;前台脚本(用鼠标键盘的)运行时屏幕也保持亮着。全部结束后恢复 Windows 自己的设置。",i.power.awake?"现在正在防睡眠。":""]}),n.jsx("label",{className:"field-label",htmlFor:"power-countdown",children:"流水线结束后睡眠、休眠或关机前倒计时多少秒(这段时间里可以取消)"}),n.jsx("input",{id:"power-countdown",className:"text-input plain",type:"number",min:10,max:600,defaultValue:g.powerCountdownSeconds,onBlur:x=>void p({powerCountdownSeconds:Math.max(10,Math.min(600,Math.round(Number(x.target.value)||60)))})})]}),i!==null&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"接下来"}),i.upcoming.length===0&&n.jsx("div",{className:"muted small",children:"没有开启定时的流水线。"}),n.jsx("ul",{className:"version-list",children:i.upcoming.map((x,N)=>n.jsxs("li",{children:[n.jsx("span",{className:"version-name",children:Uj(x.at)}),n.jsx("span",{children:x.pipelineName})]},N))})]}),i!==null&&i.history.length>0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"最近的定时记录"}),n.jsx("ul",{className:"version-list",children:i.history.map((x,N)=>{var j,y;return n.jsxs("li",{children:[n.jsx("span",{className:`badge ${((j=Bj[x.outcome])==null?void 0:j[0])??""}`,children:((y=Bj[x.outcome])==null?void 0:y[1])??x.outcome}),n.jsx("span",{children:x.pipelineName}),n.jsxs("span",{className:"muted small",children:[x.slot,x.detail===void 0?"":` · ${x.detail}`]}),n.jsx("span",{className:"spacer"}),n.jsx("span",{className:"session-time",children:vt(x.at,s)})]},N)})})]}),n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"无人值守检查清单"}),n.jsxs("ul",{className:"guide-steps",children:[n.jsxs("li",{children:["前台脚本(如三月七)需要已登录、没有锁屏的桌面:在 Windows 里设置自动登录(运行 ",n.jsx("code",{children:"netplwiz"}),"),关闭屏幕保护程序;睡眠唤醒后不要求登录(设置 → 帐户 → 登录选项 →「需要登录」选「从不」)。"]}),n.jsx("li",{children:"模拟器脚本(如 MAA)不受锁屏影响。"}),n.jsx("li",{children:"运行期间程序会阻止电脑睡眠;想让睡着的电脑按时醒来跑定时任务,打开上面的「定时唤醒」。关机后的电脑不能被唤醒,可以在主板 BIOS 里设置定时开机,再配合开机自启。"}),n.jsx("li",{children:"没接显示器时,游戏可能以很小的分辨率启动;可以接一个 HDMI 假负载(显卡欺骗器)。"}),n.jsx("li",{children:"想在手机上收到结果,先在「设置 → 飞书」接好飞书。"})]})]}),h!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:h})]})]})}const $8={id:"pipelines",title:"编排",milestone:"M4",requires:["pipelines","scripts","runs"],pages:[{id:"pipelines",title:"编排",icon:"flow",order:20,agent:"pipelines",component:j8}]},I8={id:"schedule",title:"定时与自启",milestone:"M4",requires:["schedule","pipelines"],settingsPages:[{id:"schedule",title:"定时与自启",order:9,component:A8}]},Ca=new Map;let kg=0;const jg=new Set;function T8(e,t){let s=Ca.get(e);if(s===void 0){s=t().then(r=>r.icon===void 0?null:`data:${r.icon.mediaType};base64,${r.icon.data}`);const i=s;s.then(r=>{r===null&&Ca.get(e)===i&&Ca.delete(e)},()=>{Ca.get(e)===i&&Ca.delete(e)}),Ca.set(e,s)}return s}function aE(){Ca.clear(),kg++;for(const e of jg)e()}const up=new Map;function M8(e){let t=up.get(e);if(t===void 0){const i=["games/changed","scripts/changed","packs/changed"].map(r=>e.connection.on(r,aE));t={count:0,off:()=>{for(const r of i)r()}},up.set(e,t)}t.count++;const s=t;return()=>{--s.count===0&&(s.off(),up.delete(e))}}function oE({client:e,iconKey:t,load:s,name:i,className:r=""}){const o=_e(e.connection.status),[l,u]=v.useState(null),[d,h]=v.useState(kg);return v.useEffect(()=>{const m=()=>h(kg);return jg.add(m),()=>{jg.delete(m)}},[]),v.useEffect(()=>M8(e),[e]),v.useEffect(()=>{if(o.state!=="open")return;let m=!0;return T8(t,s).then(p=>{m&&u(p)},()=>{}),()=>{m=!1}},[t,o.state,d]),n.jsx("span",{className:`program-avatar${l===null?"":" with-icon"} ${r}`,children:l===null?[...i][0]??"?":n.jsx("img",{src:l,alt:"",draggable:!1,onError:()=>u(null)})})}function R8({client:e,game:t,className:s=""}){return n.jsx(oE,{client:e,iconKey:`game:${t.id}`,name:t.name,className:`rail-avatar game-avatar ${s}`,load:()=>e.connection.call("games/icon",{game:t.id})})}const O8=864e5;function P8({client:e,openSession:t,openPage:s,arg:i}){const r=_e(e.connection.status),o=vn(3e4),[l,u]=v.useState(null),[d,h]=v.useState(0),[m,p]=v.useState(i??""),[g,x]=v.useState(null),[N,j]=v.useState(null),[y,k]=v.useState(null),[_,S]=v.useState(!1),[E,O]=v.useState(null),P=v.useCallback(()=>O(null),[]),H=v.useCallback(()=>S(!1),[]);v.useEffect(()=>{i!==void 0&&p(i)},[i]),v.useEffect(()=>e.connection.on("games/changed",()=>h(Z=>Z+1)),[e]),v.useEffect(()=>{if(r.state!=="open")return;let Z=!0;return e.connection.call("games/list",{}).then(ee=>{Z&&u(ee)}).catch(ee=>{Z&&j($e(ee))}),()=>{Z=!1}},[e,r.state,d]);const B=(l==null?void 0:l.games)??[],R=E3(B,Xr),M=B.find(Z=>Z.id===m),F=M===void 0,L=Z=>{p(Z),O(null),k(null),j(null)},A=async(Z,ee)=>{x(Z),j(null),k(null);try{const J=await ee();typeof J=="string"&&k(J)}catch(J){j($e(J))}finally{x(null),h(J=>J+1)}},I=Z=>A(`refresh:${Z??""}`,async()=>{const{results:ee}=await e.connection.call("games/refresh",Z===void 0?{}:{game:Z}),J=ne=>{var me;return((me=B.find(Ce=>Ce.id===ne))==null?void 0:me.name)??ne},re=ne=>{var me;return((me=B.find(Ce=>Ce.id===ne))==null?void 0:me.sources.some(Ce=>Ce.auto))===!0},ie=ee.filter(ne=>re(ne.game)&&!ne.ok);if(ie.length>0)throw new Error(ie.map(ne=>`${J(ne.game)}没读到:${ne.detail??"未知原因"}`).join(";"));return Z===void 0?`刷新完成:${ee.filter(ne=>re(ne.game)).map(ne=>`${J(ne.game)} ${[...ne.count>0||ne.notices===void 0?[`${ne.count} 个活动`]:[],...ne.notices===void 0?[]:[`${ne.notices} 条公告`]].join("、")}`).join(";")}`:void 0}),z=Z=>A("create",async()=>{const{game:ee}=await e.connection.call("games/create",{name:Z});p(ee)}),D=Z=>{const ee=M;A("installed",async()=>{let J;for(const re of Z)J??(J=(await e.connection.call("games/create",{name:re})).game);J!==void 0&&(ee!==void 0&&ee.own===!0&&ee.sources.length===0&&ee.id!==J&&await e.connection.call("games/remove",{game:ee.id}),p(J))})},V=async Z=>{Z.own===!0&&!await Ms({title:`删除${Z.name}?`,message:`会删掉${Z.name}和它的活动记录(你自己记的也一起删)。脚本、脚本包和技能不受影响;以后可以在「更多游戏」里按名字再加回来。`,confirmLabel:"删除",danger:!0})||await A(`remove:${Z.id}`,async()=>(await e.connection.call("games/remove",{game:Z.id}),p(""),Z.own===!0?`已删除${Z.name}`:`${Z.name}不再显示:在「更多游戏」里勾上或按名字添加就回来`))},U=Z=>{const ee=((l==null?void 0:l.activities)??[]).filter(ie=>ie.game===Z.id&&(ie.startsAt??0)<=o&&Math.max(ie.endsAt??1/0,ie.shopEndsAt??0)>o),J=ee.filter(ie=>ms(ie).state!=="finished"&&ie.endsAt!==void 0&&ie.endsAt>o&&ie.endsAt-o<((l==null?void 0:l.settings.report.soonDays)??3)*O8).length,re=`${ee.length} 个进行中${Z.refreshed===void 0?"":` · ${vt(Z.refreshed.at,o)}刷新`}${Z.followed===!0?" · 关注的游戏":""}`;return{mine:ee,soon:J,title:re}},q=v.useContext(cS),te=q===null?null:n.jsxs("div",{className:"rail-games",role:"tablist","aria-label":"游戏",children:[n.jsxs("button",{role:"tab","aria-selected":F,className:`rail-item rail-game rail-overview ${F?"active":""}`,title:"全部活动:所有游戏的活动排在一条时间线上",onClick:()=>L(""),children:[n.jsx("span",{className:"rail-avatar overview-avatar",children:n.jsx(Q,{name:"timeline"})}),n.jsx("span",{className:"rail-label",children:"全部活动"})]}),B.map(Z=>{const{soon:ee,title:J}=U(Z);return n.jsxs("button",{role:"tab","aria-selected":(M==null?void 0:M.id)===Z.id,className:`rail-item rail-game ${(M==null?void 0:M.id)===Z.id?"active":""}`,style:{"--game":R.get(Z.id)},title:`${Z.name}:${J}`,onClick:()=>L(Z.id),children:[n.jsx(R8,{client:e,game:Z}),n.jsx("span",{className:"rail-label",children:Z.name}),ee>0&&n.jsx("span",{className:"rail-badge",title:`${ee} 个快结束还没做完`,children:ee})]},Z.id)}),n.jsx(Ql,{icon:"plus",label:"更多游戏",title:"选择游戏页上显示哪些游戏,或按名字添加",active:_,onClick:()=>S(!0)})]}),G=(M==null?void 0:M.name)??"全部活动",K=Z=>{const{mine:ee,soon:J}=U(Z);return n.jsxs("button",{role:"tab","aria-selected":(M==null?void 0:M.id)===Z.id,className:`game-tab ${(M==null?void 0:M.id)===Z.id?"active":""}`,style:{"--game":R.get(Z.id)},title:`${ee.length} 个进行中${Z.refreshed===void 0?"":` · ${vt(Z.refreshed.at,o)}刷新`}${Z.followed===!0?" · 关注的游戏":""}`,onClick:()=>L(Z.id),children:[n.jsx("span",{className:"game-dot"}),Z.name,J>0&&n.jsx("span",{className:"game-tab-badge",title:`${J} 个快结束还没做完`,children:J})]},Z.id)};return n.jsxs("section",{className:"main games-page",children:[q!==null&&te!==null&&qa.createPortal(te,q),n.jsxs("header",{className:"page-header games-header",children:[n.jsx("div",{className:"breadcrumb",children:n.jsx("h1",{children:q===null?"游戏":G})}),q===null?n.jsxs("nav",{className:"game-tabs",role:"tablist","aria-label":"游戏",children:[n.jsxs("button",{role:"tab","aria-selected":F,className:`game-tab ${F?"active":""}`,onClick:()=>L(""),children:[n.jsx(Q,{name:"timeline"}),"全部活动"]}),n.jsx("span",{className:"game-tabs-divider"}),B.map(K),n.jsxs("button",{className:`game-tab add ${_?"active":""}`,"aria-haspopup":"dialog",title:"选择游戏页上显示哪些游戏,或按名字添加",onClick:()=>S(!0),children:[n.jsx(Q,{name:"plus"}),"更多游戏"]})]}):n.jsx("span",{className:"spacer"}),n.jsx("div",{className:"page-actions",children:n.jsxs("button",{className:"small-button",disabled:g!==null||B.length===0,onClick:()=>void I(),children:[n.jsx(Q,{name:"refresh"}),g==="refresh:"?"刷新中…":"刷新全部"]})})]}),n.jsxs("div",{className:"games-body",children:[N!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:N})]}),y!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(Q,{name:"info"}),n.jsx("span",{children:y})]}),l!==null&&B.length===0&&n.jsxs("div",{className:"empty",children:[n.jsx(Q,{name:"gamepad"}),n.jsx("p",{children:"没有游戏。点「更多游戏」勾选几个,或按名字添加。"})]}),l!==null&&F&&B.length>0&&n.jsx(u3,{client:e,games:B,activities:l.activities,now:o,soonDays:l.settings.report.soonDays,onOpenGame:L,onChanged:()=>h(Z=>Z+1)}),l!==null&&M!==void 0&&n.jsx(x3,{client:e,game:M,activities:l.activities.filter(Z=>Z.game===M.id),notices:(l.notices??[]).filter(Z=>Z.game===M.id),color:R.get(M.id)??Xr[0],now:o,soonDays:l.settings.report.soonDays,busy:g,open:(E==null?void 0:E.kind)==="activity"?E.id:null,adding:(E==null?void 0:E.kind)==="add",onOpen:Z=>O({kind:"activity",id:Z}),onAdd:()=>O({kind:"add",game:M.id}),onRefresh:()=>void I(M.id),onRead:()=>void A(`read:${M.id}`,async()=>{const{sessionId:Z}=await e.connection.call("games/read",{game:M.id});t(Z)}),onReadWeb:Z=>void A(`read-web:${M.id}`,async()=>{const{sessionId:ee}=await e.connection.call("games/read",{game:M.id,how:"web",...Z===void 0?{}:{source:Z}});t(ee)}),onCancelReading:Z=>void A(`cancel:${Z}`,async()=>{await e.connection.call("games/read/cancel",{taskId:Z}),h(ee=>ee+1)}),onDiscover:()=>void A(`discover:${M.id}`,async()=>(await e.connection.call("games/discover",{game:M.id}),`agent 正在找${M.name}的活动来源,找到后这个页面会更新`)),onRemove:()=>void V(M),onChanged:()=>h(Z=>Z+1),openSession:t,openScripts:()=>s("scripts")},M.id)]}),_&&n.jsxs(dc,{color:"var(--accent)",label:"更多游戏",onClose:H,className:"catalog-dialog",children:[n.jsxs("header",{className:"dialog-head",children:[n.jsxs("div",{className:"dialog-title",children:[n.jsx("h3",{children:"更多游戏"}),n.jsx("div",{className:"dialog-meta",children:"勾上就显示在游戏页上,马上生效;列表里没有的,按名字添加"})]}),n.jsx("button",{className:"dialog-close","aria-label":"关闭",title:"关闭(Esc)",onClick:H,children:n.jsx(Q,{name:"close"})})]}),n.jsx("div",{className:"dialog-form catalog-dialog-body",children:n.jsx(p3,{client:e,onChanged:()=>h(Z=>Z+1),onCreate:Z=>{H(),z(Z)}})})]}),M!==void 0&&!_&&n.jsx(n1,{client:e,target:{games:[{id:M.id,name:M.name,aliases:M.aliases,...M.sra===void 0?{}:{sra:M.sra}}]},label:`「${M.name}」`,onInstalled:D}),l!==null&&E!==null&&(()=>{const Z=()=>h(J=>J+1);if(E.kind==="add"){const J=B.find(re=>re.id===E.game);return J===void 0?null:n.jsx(dc,{color:R.get(J.id)??Xr[0],label:"添加活动",onClose:P,children:n.jsx("div",{className:"dialog-form",children:n.jsx(yx,{client:e,game:J,onCancel:P,onDone:re=>{O({kind:"activity",id:re.id,saved:re}),Z()}})})})}const ee=l.activities.find(J=>J.id===E.id)??E.saved;return ee===void 0?null:n.jsx(dc,{color:R.get(ee.game)??Xr[0],label:`${ee.name}的详情`,onClose:P,children:n.jsx(I3,{client:e,activity:ee,game:B.find(J=>J.id===ee.game),now:o,soonDays:l.settings.report.soonDays,onClose:P,onChanged:Z,openSession:t},ee.id)})})()]})}function L8({client:e,openSettings:t}){const s=_e(e.connection.status),i=vn(3e4),[r,o]=v.useState(null),[l,u]=v.useState(0),[d,h]=v.useState(null);return v.useEffect(()=>e.connection.on("games/changed",()=>u(m=>m+1)),[e]),v.useEffect(()=>{if(s.state!=="open")return;let m=!0;return e.connection.call("games/list",{}).then(p=>{m&&(o(p),h(null))}).catch(p=>{m&&h($e(p))}),()=>{m=!1}},[e,s.state,l]),n.jsxs("section",{className:"main games-page",children:[n.jsx("header",{className:"page-header games-header",children:n.jsx("div",{className:"breadcrumb",children:n.jsx("h1",{children:"日报"})})}),n.jsxs("div",{className:"games-body",children:[d!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:d})]}),r!==null&&n.jsx(z8,{client:e,data:r,games:r.games,now:i,openSettings:t,onChanged:()=>u(m=>m+1)})]})]})}function z8({client:e,data:t,games:s,now:i,openSettings:r,onChanged:o}){const l=t.settings.report,[u,d]=v.useState(null),[h,m]=v.useState(!1),[p,g]=v.useState(null),[x,N]=v.useState(null);v.useEffect(()=>{let k=!0;return e.connection.call("games/report/preview",{}).then(_=>{k&&d(_)}).catch(()=>{}),()=>{k=!1}},[e,t]);const j=async k=>{m(!0),g(null);try{await e.connection.call("games/settings/set",{report:k}),o()}catch(_){g($e(_))}finally{m(!1)}},y=async()=>{m(!0),g(null),N(null);try{const{channels:k}=await e.connection.call("games/report/send",{});N(k.length===0?"没有发出去:还没有设置好的聊天渠道。":`已发到${k.join("、")}。`),o()}catch(k){g($e(k))}finally{m(!1)}};return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"每日日报"}),n.jsx("p",{className:"muted small",children:"每天先读一遍数据站,再把各游戏的活动、剩余天数和没做完的事发到飞书。进度来自 agent 最近一次进游戏读取(可以在编排里加一个 agent 节点,日常跑完后读一次)。"})]}),n.jsx("span",{className:`badge ${l.enabled?"ok":""}`,children:l.enabled?"已开启":"未开启"})]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:l.enabled,disabled:h,onChange:k=>void j({enabled:k.target.checked})}),"每天定时发送"]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:l.ai,disabled:h,onChange:k=>void j({ai:k.target.checked})}),"用 AI 总结,只说近期的事(刚开始、快结束、即将开始),语气按「设置 → 回复风格」;agent 不可用时发下面的完整列表"]}),n.jsxs("div",{className:"field-row",children:[n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"发送时间"}),n.jsx("input",{className:"text-input plain",type:"time",defaultValue:l.at,disabled:h,onBlur:k=>{/^\d{2}:\d{2}$/.test(k.target.value)&&k.target.value!==l.at&&j({at:k.target.value})}},l.at)]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"剩余几天以内标成「快结束」"}),n.jsx("input",{className:"text-input plain",type:"number",min:1,max:30,defaultValue:l.soonDays,disabled:h,onBlur:k=>{const _=Math.max(1,Math.min(30,Math.round(Number(k.target.value)||3)));_!==l.soonDays&&j({soonDays:_})}},l.soonDays)]})]}),n.jsx("div",{className:"field-title",children:"包括的游戏(都不选就是全部)"}),n.jsx("div",{className:"chip-row",children:s.map(k=>{const _=l.games.includes(k.id);return n.jsx("button",{className:`chip chip-button ${_?"active":""}`,disabled:h,onClick:()=>void j({games:_?l.games.filter(S=>S!==k.id):[...l.games,k.id]}),children:k.name},k.id)})}),n.jsxs("p",{className:"muted small",children:[t.report.lastSentAt===void 0?"还没发过。":`上次:${vt(t.report.lastSentAt,i)}。`,t.report.lastResult===void 0?"":` ${t.report.lastResult}。`,l.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"})}。`," ",n.jsx("button",{className:"link-button",onClick:()=>r("feishu"),children:"远程连接"})]}),p!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:p})]})]}),n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"今天的日报"}),n.jsx("p",{className:"muted small",children:l.ai?"完整列表。发送时 agent 从里面挑出近期的事写成总结,写不出来就发这份。":"发到飞书的就是这份。"})]}),n.jsxs("button",{className:"small-button primary",disabled:h,onClick:()=>void y(),children:[n.jsx(Q,{name:"send"}),h?"发送中…":"现在发送"]})]}),x!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(Q,{name:"info"}),n.jsx("span",{children:x})]}),u!==null&&n.jsxs("div",{className:"report-preview",children:[n.jsx("strong",{children:u.title}),`
|
|
244
|
-
|
|
245
|
-
`,u.text]})]}),t.report.lastText!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:"上次发出的"}),t.report.lastSentAt!==void 0&&n.jsx("p",{className:"muted small",children:vt(t.report.lastSentAt,i)})]})}),n.jsx("div",{className:"report-preview",children:t.report.lastText})]})]})}const D8={id:"games",title:"游戏看板",milestone:"M6",requires:["games"],pages:[{id:"games",title:"游戏",icon:"library",order:-10,component:P8},{id:"daily-report",title:"日报",icon:"send",order:10,agent:"games",component:L8}]},sl="MultiGameAssistant",lE=e=>e.pack==="script"?"脚本包":e.pack==="game"?"游戏包":"技能",Ng=e=>e.author??e.repo.split("/")[0]??e.repo;function F8(e,t,s){const i=x=>e.find(N=>N.pack==="script"&&N.name===x),r=x=>{var j,y;if(x.pack==="game")return x.game??x.games[0];if(x.games[0]!==void 0)return x.games[0];const N=x.pack==="script"?x.name:x.scripts[0];if(N!==void 0)return((j=i(N))==null?void 0:j.games[0])??((y=t.find(k=>k.scripts.includes(N)))==null?void 0:y.id)},o=x=>x.pack==="script"?x.name:x.pack==="game"?void 0:x.scripts[0],l=x=>{var N,j;return((N=t.find(y=>y.id===x))==null?void 0:N.name)??((j=e.find(y=>y.pack==="game"&&y.game===x))==null?void 0:j.title)??x},u=x=>{var N,j;return((N=i(x))==null?void 0:N.title)??((j=s.find(y=>y.id===x||y.packId===x))==null?void 0:j.name)??x},d=x=>{const N=t.findIndex(j=>j.id===x);return N<0?t.length:N},h=x=>s.some(N=>N.id===x||N.packId===x),m=x=>x.pack==="game"?0:x.pack==="script"?1:2,p=(x,N)=>{const j=new Map;for(const y of x)j.set(N(y),[...j.get(N(y))??[],y]);return j},g=p(e,x=>r(x)??"");return[...g.keys()].sort((x,N)=>+(x==="")-+(N==="")||d(x)-d(N)||l(x).localeCompare(l(N))).map(x=>{const N=p(g.get(x),j=>o(j)??"");return{key:x,name:x===""?"通用":l(x),children:[...N.keys()].sort((j,y)=>+(y==="")-+(j==="")||Number(h(y))-Number(h(j))||u(j).localeCompare(u(y))).map(j=>{const y=p(N.get(j),Ng);return{key:j,name:j===""?x===""?"不分脚本":"游戏本身":u(j),children:[...y.keys()].sort((k,_)=>+(_===sl)-+(k===sl)||k.localeCompare(_)).map(k=>({key:k,name:k,children:[...y.get(k)].sort((_,S)=>m(_)-m(S)||(_.title??_.name).localeCompare(S.title??S.name))}))}})}})}function U8({tree:e,selected:t,searching:s,folded:i,onFold:r,onPick:o}){return n.jsx(n.Fragment,{children:e.map(l=>{const u=`hub:${l.key||":general"}`,d=s||!i.has(u),h=l.children.reduce((m,p)=>m+p.children.reduce((g,x)=>g+x.children.length,0),0);return n.jsxs("div",{className:`skills-group ${d?"":"folded"}`,children:[n.jsx("div",{className:"skills-section-head",children:n.jsxs("button",{className:"skills-fold","aria-expanded":d,onClick:()=>r(u),children:[n.jsx(Q,{name:"chevron-down",className:"skills-chevron"}),n.jsx(Q,{name:l.key===""?"layers":"gamepad",className:"skills-section-icon"}),n.jsx("span",{className:"skills-group-name",children:l.name}),n.jsx("span",{className:"skills-count",children:h})]})}),d&&l.children.map(m=>n.jsxs("div",{className:"skills-sub hub-sub",children:[n.jsxs("div",{className:"hub-script-label",children:[n.jsx(Q,{name:m.key===""?"gamepad":"package"}),m.name]}),m.children.map(p=>n.jsxs("div",{className:"hub-author-block",children:[n.jsxs("div",{className:"hub-author-label",children:[p.name,p.name===sl&&n.jsx("span",{className:"hub-official",children:"官方"})]}),p.children.map(g=>{var x;return n.jsxs("button",{className:`script-row skill-row ${t===g.name?"active":""}`,title:g.installed!==void 0?"已下载":void 0,onClick:()=>o(g.name),children:[n.jsxs("span",{className:"script-row-main",children:[n.jsxs("span",{className:"skill-row-name-line",children:[n.jsx("span",{className:"script-row-name",children:g.title??g.name}),g.installed!==void 0&&n.jsx("span",{className:"skill-row-from",children:"已下载"})]}),n.jsx("span",{className:"muted small skills-row-desc",children:g.description})]}),n.jsx("span",{className:`skill-row-tag ${g.pack===void 0?"subtle":""}`,children:lE(g)}),((x=g.installed)==null?void 0:x.update)===!0&&g.incompatible===void 0&&n.jsx("span",{className:"skill-dot",title:"有新版"})]},`${g.repo}/${g.name}`)})]},p.key))]},m.key||":own"))]},u)})})}function B8({client:e,item:t,where:s,busy:i,now:r,act:o,onOpen:l}){const[u,d]=v.useState(null),h=t.installed,m=[...t.version===void 0?[]:[{version:t.version,changes:t.changes,latest:!0}],...(t.history??[]).map(S=>({...S,latest:!1}))],[p,g]=v.useState((h==null?void 0:h.version)??t.version??""),x=m.find(S=>S.version===p),N=t.blocked===void 0&&t.incompatible===void 0,j=S=>i===`${S}:${t.name}`;v.useEffect(()=>{let S=!0;return d(null),e.connection.call("skillhub/preview",{name:t.name}).then(E=>{S&&d(E.content.replace(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/,""))},()=>{S&&d("")}),()=>{S=!1}},[e,t.name,t.hash]);const y=()=>void o(`install:${t.name}`,async()=>(await e.connection.call("skillhub/install",{name:t.name,repo:t.repo}),`已下载 ${t.title??t.name}${t.pack==="script"?":脚本页可以按它安装这个脚本了":t.pack==="game"?":游戏页可以显示它了":",agent 现在就能用"}`)),k=()=>void o(`update:${t.name}`,async()=>(await e.connection.call("skillhub/update",{name:t.name})).state==="updated"?`${t.title??t.name} 已更新`:"已是最新"),_=()=>void o(`version:${t.name}`,async()=>(await e.connection.call("skillhub/version",{name:t.name,version:p}),`${t.title??t.name} ${h===void 0?"下载了":"换成了"} ${p}${(x==null?void 0:x.latest)===!0?"(最新)":""}`));return n.jsxs("article",{className:"card skill-card",children:[n.jsxs("header",{className:"skill-top",children:[n.jsxs("div",{className:"skill-title",children:[n.jsxs("div",{className:"skill-kicker",children:[n.jsx(Q,{name:t.pack==="game"?"gamepad":t.pack==="script"?"package":"sparkles"}),lE(t)," · 作者 ",Ng(t),Ng(t)===sl?"(官方)":""]}),n.jsx("h2",{children:t.title??t.name}),n.jsxs("div",{className:"skill-meta",children:[t.title!==void 0&&n.jsx("code",{className:"skill-name",children:t.name}),s!==""&&n.jsxs("span",{className:"badge",children:[n.jsx(Q,{name:t.pack==="script"||t.scripts.length>0?"package":"gamepad"}),s]}),t.version!==void 0&&n.jsx("span",{className:"badge",children:t.version}),m.length>1&&n.jsxs("span",{className:"badge",title:m.map(S=>S.version).join("、"),children:["共 ",m.length," 个版本"]}),h!==void 0&&n.jsxs("span",{className:"badge ok",title:`${vt(h.at,r)}下载`,children:["已下载",h.version===void 0||h.version===t.version?"":` ${h.version}`]}),(h==null?void 0:h.update)===!0&&t.incompatible===void 0&&n.jsx("span",{className:"badge warn",children:"有新版"})]})]}),n.jsxs("div",{className:"skill-buttons",children:[h===void 0&&N&&n.jsxs("button",{className:"small-button primary",disabled:i!==null,onClick:y,children:[n.jsx(Q,{name:"download"}),j("install")?"下载中…":"下载"]}),(h==null?void 0:h.update)===!0&&t.incompatible===void 0&&n.jsx("button",{className:"small-button primary",disabled:i!==null,onClick:k,children:j("update")?"更新中…":"更新"}),h!==void 0&&n.jsx("button",{className:"small-button",onClick:()=>l(t.name),children:"在技能列表里查看"})]})]}),n.jsx("p",{className:"skill-desc",children:t.description}),n.jsxs("div",{className:"skill-notes",children:[t.changes!==void 0&&(h===void 0||h.update)&&n.jsxs("p",{className:"small hub-changes",children:[t.version===void 0?"":`${t.version}:`,t.changes]}),t.incompatible!==void 0&&n.jsx("p",{className:"small hub-incompatible",children:t.incompatible}),t.blocked!==void 0&&n.jsxs("p",{className:"muted small",children:[t.blocked,",没有下载(以你已有的为准)"]})]}),m.length>1&&N&&n.jsxs("div",{className:"skill-versions",children:[n.jsxs("span",{className:"field-label",children:["版本(技能库留着的每一版都能",h===void 0?"下载":"换",")"]}),n.jsxs("div",{className:"skill-versions-row",children:[n.jsx(Mt,{className:"skill-version-select",value:p,onChange:g,disabled:i!==null,"aria-label":"版本",options:m.map(S=>({value:S.version,label:`${S.version}${S.latest?"(最新)":""}${S.version===(h==null?void 0:h.version)?"(正在用)":""}`,...S.changes===void 0?{}:{hint:S.changes}}))}),n.jsx("button",{className:"small-button",disabled:i!==null||p===(h==null?void 0:h.version),onClick:_,children:j("version")?"下载中…":h===void 0?"下载这个版本":"换成这个版本"})]})]}),n.jsxs("section",{className:"skill-body","aria-label":"内容",children:[n.jsx("div",{className:"skill-body-label",children:"技能库里的内容"}),u===null?n.jsx("p",{className:"muted",children:"正在读取…"}):u.trim()===""?n.jsx("p",{className:"muted",children:"(没有内容)"}):n.jsx(Hs,{text:u})]}),n.jsxs("code",{className:"muted small skill-path",children:[t.repo,"/",t.path]})]})}function H8({repos:e,disabled:t,onSave:s,onCancel:i}){const[r,o]=v.useState(e.map(d=>d.branch==="main"?d.repo:`${d.repo}@${d.branch}`).join(`
|
|
246
|
-
`)),l=v.useMemo(()=>r.split(/\r?\n/).map(d=>d.trim()).filter(Boolean).map(d=>{const[h,m]=d.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("@");return{repo:h??"",branch:m??"main"}}),[r]),u=l.length>0&&l.every(d=>/^[\w.-]+\/[\w.-]+$/.test(d.repo)&&/^[\w./-]+$/.test(d.branch));return n.jsxs("article",{className:"card skill-card",children:[n.jsx("div",{className:"skill-title",children:n.jsx("h2",{children:"技能仓库"})}),n.jsxs("p",{className:"muted small",children:["脚本包、游戏包和技能从这些 GitHub 仓库下载(整个仓库打包下载,不用装 git,走「设置 → 脚本安装」的下载镜像),一天最多读一次。只有默认仓库 ",sl,"/skills 的脚本包当作官方的;别的仓库里的会让 agent 照着做,只加你信得过的。"]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-label",children:"一行一个 owner/repo,可以写 @分支;前面的同名的优先"}),n.jsx("textarea",{className:"text-input plain skill-content-input",rows:4,value:r,onChange:d=>o(d.target.value),spellCheck:!1})]}),n.jsxs("div",{className:"skill-actions",children:[n.jsx("button",{className:"link-button small",disabled:t,onClick:()=>o(`${sl}/skills`),children:"恢复默认"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:t,onClick:i,children:"取消"}),n.jsx("button",{className:"small-button primary",disabled:t||!u,onClick:()=>s(l),children:"保存"})]})]})}const Hx=[{id:"script-pack",label:"脚本包",icon:"package",hint:"脚本怎么装、有哪些任务、运行前改哪些设置;按游戏分开,用不上的可以删"},{id:"game-pack",label:"游戏包",icon:"gamepad",hint:"游戏页从哪里读活动、游戏里怎么看;不玩的可以删"},{id:"skill",label:"技能",icon:"sparkles",hint:"按游戏分开:名字旁写着「下载」的是从技能库下载的,其余是你或 agent 写的;只在处理对应的游戏和脚本时用"},{id:"core",label:"核心技能",icon:"shield",hint:"软件自带、维持基本功能的技能:受保护,不能改,随软件更新"}],Z8=Object.fromEntries(Hx.map(e=>[e.id,e.label])),W8=new Set(["script-pack","skill"]),cE=e=>{var t,s;return((t=e.skill)==null?void 0:t.removable)===!0||((s=e.skill)==null?void 0:s.ownPack)===!0};function V8(e,t){return e.kind==="script-pack"||(t==null?void 0:t.pack)==="script"?"script-pack":e.kind==="game-pack"||(t==null?void 0:t.pack)==="game"?"game-pack":e.source==="bundled"&&e.removable!==!0?"core":"skill"}const uE="adg:skills:folded-kinds";function q8(){try{return new Set(JSON.parse(localStorage.getItem(uE)??"[]"))}catch{return new Set}}function G8(e){try{localStorage.setItem(uE,JSON.stringify([...e]))}catch{}}const Sa="",jo=":general";function K8({client:e,arg:t}){var On;const s=_e(e.connection.status),i=_e(e.capabilities),r=vn(6e4),[o,l]=v.useState(null),[u,d]=v.useState(null),[h,m]=v.useState(""),[p,g]=v.useState(Sa),[x,N]=v.useState((t==null?void 0:t.startsWith("hub"))===!0?"hub":"mine"),[j,y]=v.useState((t==null?void 0:t.startsWith("hub:"))===!0?t.slice(4):""),[k,_]=v.useState(""),[S,E]=v.useState(!1),[O,P]=v.useState(t===void 0||t.startsWith("hub")?"":t),[H,B]=v.useState(null),[R,M]=v.useState(null),[F,L]=v.useState(null),[A,I]=v.useState(null),[z,D]=v.useState(0),[V,U]=v.useState(0),[q,te]=v.useState(!1),[G,K]=v.useState(null),[Z,ee]=v.useState(!1),[J,re]=v.useState(q8),ie=le=>re(X=>{const de=new Set(X);return de.delete(le)||de.add(le),G8(de),de}),ne=((On=ah(e).data)==null?void 0:On.scripts)??[],[me,Ce]=v.useState([]),Fe=i.has("skillhub");v.useEffect(()=>{t!==void 0&&(t.startsWith("hub")?(N("hub"),t.startsWith("hub:")&&y(t.slice(4))):(N("mine"),P(t)),K(null))},[t]),v.useEffect(()=>e.connection.on("skills/changed",()=>D(le=>le+1)),[e]),v.useEffect(()=>e.connection.on("skillhub/changed",()=>U(le=>le+1)),[e]),v.useEffect(()=>{if(s.state!=="open"||!i.has("games"))return;let le=!0;return e.connection.call("games/list",{}).then(X=>{le&&Ce(X.games)},()=>{}),()=>{le=!1}},[e,s.state,i,V]),v.useEffect(()=>{if(s.state!=="open")return;let le=!0;return e.connection.call("skills/list",{}).then(X=>{le&&l(X.skills)},X=>{le&&M($e(X))}),()=>{le=!1}},[e,s.state,z]);const Me=async(le=!1)=>{const X=await e.connection.call("skillhub/list",le?{refresh:!0}:{});return d(X),X};v.useEffect(()=>{if(s.state!=="open"||!Fe)return;let le=!0;return e.connection.call("skillhub/list",{}).then(X=>{le&&d(X)},X=>{le&&M($e(X))}),()=>{le=!1}},[e,s.state,Fe,V]);const fe=v.useMemo(()=>{const le=(u==null?void 0:u.items)??[];return(o??[]).map(X=>{const de=X.source==="hub"?le.find(Se=>Se.name===X.name&&Se.installed!==void 0):void 0;return{name:X.name,title:(de==null?void 0:de.title)??X.name,description:X.description,category:V8(X,de),skill:X,...de===void 0?{}:{hub:de},...X.owner===void 0?{}:{owner:X.owner}}})},[o,u]),ke=le=>mS(le.owner,ne,me),ge=le=>[...new Set(ke(le).map(fS))].join("、"),Ae=le=>{var Be,ut,Nt,He,Ue,Xe;const X=(Be=ke(le).find(yt=>yt.game!==void 0))==null?void 0:Be.game;if(X!==void 0)return X;const de=((ut=le.hub)==null?void 0:ut.game)??((Nt=le.hub)==null?void 0:Nt.games[0])??((Ue=(He=le.owner)==null?void 0:He.games)==null?void 0:Ue[0]);if(de===void 0)return;const Se=zd(de,me);return Se!==void 0?{id:Se.id,name:Se.name}:{id:de,name:((Xe=((u==null?void 0:u.items)??[]).find(yt=>yt.pack==="game"&&yt.game===de))==null?void 0:Xe.title)??de}},be=le=>{const X=new Map;for(const Se of le){const Be=Ae(Se)??{id:jo,name:"通用"},ut=X.get(Be.id)??{...Be,items:[]};ut.items.push(Se),X.set(Be.id,ut)}const de=Se=>{const Be=me.findIndex(ut=>ut.id===Se);return Be<0?me.length:Be};return[...X.values()].sort((Se,Be)=>+(Se.id===jo)-+(Be.id===jo)||de(Se.id)-de(Be.id)||Se.name.localeCompare(Be.name))},qe=h.trim().toLowerCase(),ft=v.useMemo(()=>fe.filter(le=>{var de,Se;if(qe!==""&&!`${le.name} ${le.title} ${le.description} ${((de=le.skill)==null?void 0:de.whenToUse)??""}`.toLowerCase().includes(qe))return!1;if(p===Sa)return!0;const X=ke(le);return p===jo?X.length===0:X.some(Be=>{var ut;return((ut=Be.game)==null?void 0:ut.id)===p})||((Se=le.hub)==null?void 0:Se.game)===p}),[fe,qe,p,ne,me]),Rt=v.useMemo(()=>Hx.map(le=>({...le,items:ft.filter(X=>X.category===le.id).sort((X,de)=>X.title.localeCompare(de.title))})).filter(le=>le.items.length>0||le.id==="skill"&&qe===""&&p===Sa),[ft,qe,p]).map(le=>({...le,groups:W8.has(le.id)?be(le.items):void 0})),En=Rt.flatMap(le=>{var X;return((X=le.groups)==null?void 0:X.flatMap(de=>de.items))??le.items}),rt=ft.find(le=>le.name===O)??En[0];v.useEffect(()=>{if(ee(!1),te(!1),rt===void 0){B(null);return}let le=!0;const X=rt.name;return e.connection.call("skills/get",{name:X}).then(de=>de.content).then(de=>{le&&B({name:X,text:de})},de=>{le&&(B({name:X,text:""}),M($e(de)))}),()=>{le=!1}},[e,rt==null?void 0:rt.name,z,V]);const Pt=async(le,X)=>{I(le),M(null),L(null);try{const de=await X();typeof de=="string"&&L(de),D(Se=>Se+1),U(Se=>Se+1)}catch(de){M($e(de))}finally{I(null)}},rn=le=>{K(null),L(null),M(null),P(le)},Zt=le=>{N(le),K(null),L(null),M(null)},Qt=le=>Pt(`remove:${le.name}`,async()=>{var de,Se;const X=((de=le.skill)==null?void 0:de.ownPack)===!0?{title:`删除脚本包「${le.title}」?`,message:"这是 agent 为脚本写的脚本包:它的安装方式、任务和做法都会删掉,不能恢复(需要时让 agent 重新分析这个脚本)。用它的脚本保留,只是没有这些任务了。"}:le.category==="script-pack"?{title:`删除脚本包「${le.title}」?`,message:"脚本页不再有它的安装方式和任务说明,agent 也不再用它的做法;已经装好的脚本不会删。以后可以在「技能库」里再下载。"}:le.category==="game-pack"?{title:`删除游戏包「${le.title}」?`,message:"游戏页不再按它读这个游戏的活动(SRA 公共 API 有这个游戏的话,可以在「游戏 → 更多游戏」里勾上)。以后可以在「技能库」里再下载。"}:le.hub!==void 0?{title:`删除技能「${le.title}」?`,message:"它的文件夹会一起删掉,agent 以后就用不到它了。以后可以在「技能库」里再下载。"}:{title:`删除技能「${le.name}」?`,message:"它的文件夹会一起删掉,agent 以后就用不到它了。"};if(await Ms({...X,confirmLabel:"删除",danger:!0}))return le.hub!==void 0?await e.connection.call("skillhub/remove",{name:le.name}):((Se=le.skill)==null?void 0:Se.ownPack)===!0&&le.skill.pack!==void 0?await e.connection.call("scripts/packs/remove",{id:le.skill.pack}):await e.connection.call("skills/remove",{name:le.name}),P(""),`已删除 ${le.title}`}),Ut=le=>Pt(`update:${le.name}`,async()=>(await e.connection.call("skillhub/update",{name:le.name})).state==="updated"?`${le.title} 已更新`:"已是最新"),Rn=(le,X)=>Pt(`version:${le.name}`,async()=>{var Se,Be;const de=await e.connection.call("skillhub/version",{name:le.name,version:X});return`${le.title} 换成了 ${((Se=de.installed)==null?void 0:Se.version)??X}${X===((Be=le.hub)==null?void 0:Be.version)?"(最新)":":技能库再有更新的版本时会再提示"}`}),mn=le=>Pt(`rollback:${le.name}`,async()=>{var de;const X=await e.connection.call("skillhub/rollback",{name:le.name});return`${le.title} 已回退${((de=X.installed)==null?void 0:de.version)===void 0?"":`到 ${X.installed.version}`};技能库再有新版本时会再提示`}),Hn=()=>({name:"",description:"",content:"",scripts:[],games:p!==Sa&&p!==jo?[p]:[]}),Gs=le=>{var X,de;return n.jsxs(n.Fragment,{children:[((de=(X=le.hub)==null?void 0:X.installed)==null?void 0:de.update)===!0&&le.hub.incompatible===void 0&&n.jsx("span",{className:"skill-dot",title:"技能库有新版"}),le.category==="core"&&n.jsx("span",{className:"skill-row-mark",title:"核心技能:受保护,不能改",children:n.jsx(Q,{name:"shield"})})]})},ps=le=>n.jsxs("button",{className:`script-row skill-row ${G===null&&(rt==null?void 0:rt.name)===le.name?"active":""}`,title:le.hub!==void 0?`从技能库下载的(作者 ${le.hub.author??le.hub.repo})`:cE(le)?"你或 agent 写的":void 0,onClick:()=>rn(le.name),children:[n.jsxs("span",{className:"script-row-main",children:[n.jsxs("span",{className:"skill-row-name-line",children:[n.jsx("span",{className:"script-row-name",children:le.title}),le.hub!==void 0&&n.jsx("span",{className:"skill-row-from",children:"下载"})]}),n.jsx("span",{className:"muted small skills-row-desc",children:ge(le)||le.description})]}),Gs(le)]},le.name),rs=((u==null?void 0:u.items)??[]).filter(le=>{var X;return((X=le.installed)==null?void 0:X.update)===!0&&le.incompatible===void 0}).length,gs=x==="hub"&&Fe||G!==null,Cn=k.trim().toLowerCase(),as=v.useMemo(()=>((u==null?void 0:u.items)??[]).filter(le=>Cn===""||`${le.name} ${le.title??""} ${le.description} ${le.author??""}`.toLowerCase().includes(Cn)),[u,Cn]),Kn=v.useMemo(()=>F8(as,me,ne),[as,me,ne]),Zn=Kn.flatMap(le=>le.children.flatMap(X=>X.children.flatMap(de=>de.children))),An=Zn.find(le=>le.name===j)??Zn[0],Yn=le=>{for(const X of Kn)for(const de of X.children)if(de.children.some(Se=>Se.children.some(Be=>Be.name===le)))return X.key===""?de.key===""?"":de.name:de.key===""?X.name:`${X.name} · ${de.name}`;return""};return n.jsxs("section",{className:"main scripts-page skills-page",children:[n.jsxs("header",{className:"page-header skills-header",children:[n.jsxs("div",{className:"breadcrumb",children:[gs&&n.jsxs("button",{className:"small-button skills-back",title:"回到技能列表",onClick:()=>x==="hub"&&Fe?Zt("mine"):K(null),children:[n.jsx(Q,{name:"back"}),"返回"]}),n.jsx("h1",{children:x==="hub"&&Fe?"技能库":G===null?"技能":G.original===void 0?"新建技能":`编辑 ${G.original}`})]}),n.jsx("div",{className:"page-actions",children:x==="mine"||!Fe?G===null&&n.jsxs(n.Fragment,{children:[Fe&&n.jsxs("button",{className:"small-button",title:"下载脚本包、游戏包和别人写的技能",onClick:()=>Zt("hub"),children:[n.jsx(Q,{name:"library"}),"技能库",rs>0&&n.jsx("span",{className:"skills-hub-badge",title:`${rs} 个有新版`,children:rs})]}),n.jsxs("button",{className:"small-button primary",disabled:s.state!=="open",onClick:()=>K(Hn()),children:[n.jsx(Q,{name:"plus"}),"新建技能"]})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"muted small skills-fetched",children:(u==null?void 0:u.fetchedAt)===void 0?"":`${vt(u.fetchedAt,r)}读取`}),n.jsxs("button",{className:"small-button",disabled:A!==null,title:"现在读一次技能库,看有没有新版本",onClick:()=>void Pt("refresh",async()=>{await Me(!0)}),children:[n.jsx(Q,{name:"refresh"}),A==="refresh"?"读取中…":"检查更新"]}),n.jsx("button",{className:`small-button ${S?"active":""}`,"aria-expanded":S,onClick:()=>E(le=>!le),children:"仓库"})]})})]}),x==="hub"&&Fe?n.jsxs("div",{className:"scripts-body",children:[n.jsxs("aside",{className:"scripts-list","aria-label":"技能库目录",children:[n.jsx("div",{className:"skills-tools",children:n.jsxs("div",{className:"skills-search",children:[n.jsx(Q,{name:"search"}),n.jsx("input",{className:"text-input",value:k,onChange:le=>_(le.target.value),placeholder:"搜索游戏、脚本、作者或技能","aria-label":"搜索技能库"})]})}),u===null&&R===null&&n.jsx("p",{className:"muted small pad",children:"正在读取技能库…"}),u!==null&&Cn!==""&&n.jsx("p",{className:"muted small skills-found",children:Zn.length===0?"没有匹配的。":`找到 ${Zn.length} 个`}),u!==null&&Cn===""&&Zn.length===0&&n.jsx("p",{className:"muted small pad",children:"技能库里还没有东西。"}),n.jsx(U8,{tree:Kn,selected:S||An==null?void 0:An.name,searching:Cn!=="",folded:J,onFold:ie,onPick:le=>{y(le),E(!1),L(null),M(null)}})]}),n.jsx("div",{className:"scripts-detail",children:n.jsxs("div",{className:"script-detail",children:[R!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:R})]}),F!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(Q,{name:"check"}),n.jsx("span",{children:F})]}),u==null?void 0:u.errors.map(le=>n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsxs("span",{children:["技能库读不到:",le,u.items.length>0?"(列出的是之前读到的)":""]})]},le)),S&&u!==null?n.jsx(H8,{repos:u.repos,disabled:A!==null,onCancel:()=>E(!1),onSave:le=>void Pt("repos",async()=>(await e.connection.call("skillhub/repos/set",{repos:le}),E(!1),await Me(!0),"已保存,按新的仓库读取"))}):An!==void 0?n.jsx(B8,{client:e,item:An,where:Yn(An.name),busy:A,now:r,act:Pt,onOpen:le=>{Zt("mine"),P(le)}},An.name):null]})})]}):n.jsxs("div",{className:"scripts-body",children:[n.jsxs("aside",{className:"scripts-list","aria-label":"技能列表",children:[n.jsxs("div",{className:"skills-tools",children:[n.jsxs("div",{className:"skills-search",children:[n.jsx(Q,{name:"search"}),n.jsx("input",{className:"text-input",value:h,onChange:le=>m(le.target.value),placeholder:"搜索脚本包、游戏包和技能","aria-label":"搜索"})]}),me.length>0&&n.jsx(Mt,{className:"skills-filter",value:p,onChange:g,"aria-label":"只看一个游戏的",options:[{value:Sa,label:"所有游戏"},...me.map(le=>({value:le.id,label:le.name})),{value:jo,label:"通用",hint:"不分游戏的技能"}]})]}),(o===null||Fe&&u===null)&&R===null&&n.jsx("p",{className:"muted small pad",children:"正在读取…"}),o!==null&&qe!==""&&n.jsx("p",{className:"muted small skills-found",children:ft.length===0?"没有匹配的。":`找到 ${ft.length} 个`}),Rt.map(le=>{var Se;const X=qe!==""||p!==Sa,de=X||!J.has(le.id);return n.jsxs("div",{className:`skills-group ${de?"":"folded"}`,children:[n.jsxs("div",{className:"skills-section-head",title:le.hint,children:[n.jsxs("button",{className:"skills-fold","aria-expanded":de,onClick:()=>ie(le.id),children:[n.jsx(Q,{name:"chevron-down",className:"skills-chevron"}),n.jsx(Q,{name:le.icon,className:"skills-section-icon"}),n.jsx("span",{className:"skills-group-name",children:le.label}),n.jsx("span",{className:"skills-count",children:le.items.length})]}),le.id==="skill"&&n.jsx("button",{className:"icon-button skills-add",title:"新建一个技能","aria-label":"新建技能",disabled:s.state!=="open",onClick:()=>K(Hn()),children:n.jsx(Q,{name:"plus"})})]}),de&&le.items.length===0&&n.jsx("p",{className:"muted small skills-empty",children:le.id==="skill"?"agent 做成一件事后会提议存成技能;也可以自己写一个,或在「技能库」里下载。":"没有"}),de&&le.groups===void 0&&le.items.map(ps),de&&((Se=le.groups)==null?void 0:Se.map(Be=>{const ut=`${le.id}/${Be.id}`,Nt=X||!J.has(ut);return n.jsxs("div",{className:`skills-sub ${Nt?"":"folded"}`,children:[n.jsxs("button",{className:"skills-sub-head","aria-expanded":Nt,onClick:()=>ie(ut),children:[n.jsx(Q,{name:"chevron-down",className:"skills-chevron"}),n.jsx("span",{className:"skills-group-name",children:Be.name}),n.jsx("span",{className:"skills-count",children:Be.items.length})]}),Nt&&Be.items.map(ps)]},ut)}))]},le.id)})]}),n.jsx("div",{className:"scripts-detail",children:n.jsxs("div",{className:"script-detail",children:[R!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:R})]}),F!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(Q,{name:"check"}),n.jsx("span",{children:F})]}),G!==null?n.jsx(Q8,{client:e,draft:G,scripts:ne,games:me,onCancel:()=>K(null),onSaved:le=>{K(null),P(le),M(null),L(G.original===void 0?"已保存,agent 现在就能用":"已保存"),D(X=>X+1)}}):rt===void 0?o!==null&&n.jsxs("div",{className:"skills-blank",children:[n.jsx(Q,{name:"sparkles"}),n.jsx("strong",{children:qe===""&&p===Sa?"还没有技能":"没有匹配的"}),n.jsx("span",{className:"muted small",children:"agent 做成一件事后会提议存成技能;也可以自己写一个。"}),n.jsxs("button",{className:"small-button primary",disabled:s.state!=="open",onClick:()=>K(Hn()),children:[n.jsx(Q,{name:"plus"}),"新建技能"]})]}):n.jsx(Y8,{entry:rt,where:ge(rt),content:(H==null?void 0:H.name)===rt.name?H.text:void 0,busy:A,copied:q,moving:Z,now:r,onCopy:()=>{var le;(le=navigator.clipboard)==null||le.writeText(`/${rt.name} `).then(()=>te(!0),()=>{})},onUpdate:()=>void Ut(rt),onVersion:le=>void Rn(rt,le),onRollback:()=>void mn(rt),onRemove:()=>void Qt(rt),onEdit:()=>{var le,X;return K({original:rt.name,...rt.hub===void 0?{}:{hub:!0},name:rt.name,description:rt.description,content:(H==null?void 0:H.name)===rt.name?H.text.trim():"",scripts:[...((le=rt.owner)==null?void 0:le.scripts)??[]],games:[...((X=rt.owner)==null?void 0:X.games)??[]]})},onMove:()=>ee(le=>!le),move:Z&&rt.skill!==void 0?n.jsx(J8,{client:e,skill:rt.skill,content:(H==null?void 0:H.name)===rt.name?H.text:void 0,scripts:ne,games:me,onCancel:()=>ee(!1),onMoved:()=>{ee(!1),M(null),D(le=>le+1),U(le=>le+1)}}):null},rt.name)]})})]})]})}function Y8({entry:e,where:t,content:s,busy:i,copied:r,moving:o,now:l,onCopy:u,onUpdate:d,onVersion:h,onRollback:m,onRemove:p,onEdit:g,onMove:x,move:N}){var M,F,L;const{skill:j,hub:y}=e,k=y==null?void 0:y.installed,_=(j==null?void 0:j.removable)===!0||k!==void 0,S=y===void 0?void 0:X8(y),E=Hx.find(A=>A.id===e.category).icon,O=A=>i===`${A}:${e.name}`,P=y===void 0?[]:[...y.version===void 0?[]:[{version:y.version,changes:y.changes,latest:!0}],...(y.history??[]).map(A=>({...A,latest:!1}))],[H,B]=v.useState((k==null?void 0:k.version)??(y==null?void 0:y.version)??""),R=P.find(A=>A.version===H);return n.jsxs("article",{className:"card skill-card",children:[n.jsxs("header",{className:"skill-top",children:[n.jsxs("div",{className:"skill-title",children:[n.jsxs("div",{className:"skill-kicker",children:[n.jsx(Q,{name:E}),Z8[e.category],y!==void 0?` · 从技能库下载的 · 作者 ${y.author??y.repo}`:cE(e)?" · 你或 agent 写的":""]}),n.jsx("h2",{children:e.title}),n.jsxs("div",{className:"skill-meta",children:[e.title!==e.name&&n.jsx("code",{className:"skill-name",children:e.name}),t===""?n.jsxs("span",{className:"badge",title:"所有对话都看得到、用得了",children:[n.jsx(Q,{name:"layers"}),"通用"]}):n.jsxs("span",{className:"badge warn",title:"技能隔离:只有在处理这些游戏或脚本的对话里,agent 才看得到、用得了它",children:[n.jsx(Q,{name:(F=(M=e.owner)==null?void 0:M.scripts)!=null&&F.length?"package":"gamepad"}),"只给 ",t," 用"]}),(j==null?void 0:j.modelInvocable)===!0&&n.jsx("span",{className:"badge ok",title:"agent 遇到相关的事会自己读它",children:"agent 自动使用"}),S!==void 0&&n.jsx("span",{className:"badge",title:(k==null?void 0:k.at)===void 0?void 0:`${vt(k.at,l)}下载`,children:S}),(k==null?void 0:k.update)===!0&&(y==null?void 0:y.incompatible)===void 0&&n.jsx("span",{className:"badge ok",children:"有新版"}),(k==null?void 0:k.held)===!0&&n.jsx("span",{className:"badge",title:"回退过:技能库再有更新的版本才会提示",children:"已回退"}),e.category==="core"&&n.jsxs("span",{className:"badge",children:[n.jsx(Q,{name:"shield"}),"受保护"]})]})]}),n.jsxs("div",{className:"skill-buttons",children:[(k==null?void 0:k.update)===!0&&(y==null?void 0:y.incompatible)===void 0&&n.jsx("button",{className:"small-button primary",disabled:i!==null,onClick:d,children:O("update")?"更新中…":"更新"}),(k==null?void 0:k.held)===!0&&(y==null?void 0:y.incompatible)===void 0&&n.jsx("button",{className:"small-button",title:"回退过的那个新版本,再换回去",disabled:i!==null,onClick:d,children:O("update")?"更新中…":"重新更新"}),(k==null?void 0:k.previous)!==void 0&&n.jsx("button",{className:"small-button",title:`换回上一个版本${k.previous.version===void 0?"":` ${k.previous.version}`}(${vt(k.previous.at,l)}下载的)`,disabled:i!==null,onClick:m,children:O("rollback")?"回退中…":"回退"}),(j==null?void 0:j.userInvocable)===!0&&n.jsxs("button",{className:"small-button",onClick:u,title:"复制后粘贴到对话框,后面写要它做的事",children:[n.jsx(Q,{name:r?"check":"copy"}),r?"已复制":`/${e.name}`]}),_&&n.jsxs("button",{className:"small-button",disabled:s===void 0,onClick:g,children:[n.jsx(Q,{name:"pencil"}),"编辑"]}),_&&n.jsxs("button",{className:"small-button","aria-expanded":o,onClick:x,title:"放错了游戏或脚本时,换到对的那个",children:[n.jsx(Q,{name:"gamepad"}),"更换游戏和脚本"]}),(_||(j==null?void 0:j.ownPack)===!0)&&n.jsx("button",{className:"small-button danger-outline",disabled:i!==null,onClick:p,children:O("remove")?"删除中…":"删除"}),(j==null?void 0:j.path)!==void 0&&((L=Vs())==null?void 0:L.openPath)!==void 0&&n.jsx("button",{className:"icon-button skill-folder",title:`打开所在文件夹:${j.path}`,"aria-label":"打开所在文件夹",onClick:()=>{var A,I;return void((I=(A=Vs())==null?void 0:A.openPath)==null?void 0:I.call(A,j.path.replace(/[\\/][^\\/]+$/,"")))},children:n.jsx(Q,{name:"layers"})})]})]}),N,n.jsx("p",{className:"skill-desc",children:e.description}),(j==null?void 0:j.whenToUse)!==void 0&&n.jsxs("p",{className:"muted small",children:["什么时候用:",j.whenToUse]}),n.jsxs("div",{className:"skill-notes",children:[e.category==="script-pack"&&n.jsx("p",{className:"muted small",children:"脚本包:脚本页按它安装和运行这个脚本(有哪些任务、运行前改哪些设置),agent 按这里的做法处理它。删掉后已经装好的脚本保留,只是没有这些任务了。"}),e.category==="game-pack"&&n.jsx("p",{className:"muted small",children:"游戏包:游戏页按它读这个游戏的活动,agent 按这里的做法看游戏画面。不玩这个游戏可以删掉,或在「游戏 → 更多游戏」里取消勾选。"}),e.category==="core"&&n.jsx("p",{className:"muted small",children:"核心技能维持软件的基本功能,受保护,不能改和删,随软件更新。"}),k!==void 0&&n.jsx("p",{className:"muted small",children:"从技能库下载的:可以改,但技能库更新它时会整个换成新版本,这里改的不保留(被换掉的那版可以回退)。要一直留着的做法,另存成自己的技能。"}),(y==null?void 0:y.changes)!==void 0&&(k==null?void 0:k.update)===!0&&n.jsxs("p",{className:"small hub-changes",children:[y.version===void 0?"":`${y.version}:`,y.changes]}),(y==null?void 0:y.incompatible)!==void 0&&n.jsxs("p",{className:"small hub-incompatible",children:["新版",y.incompatible]})]}),k!==void 0&&P.length>1&&n.jsxs("div",{className:"skill-versions",children:[n.jsx("label",{className:"field-label",htmlFor:"skill-version",children:"版本(技能库留着的每一版都能换,往前往后都行)"}),n.jsxs("div",{className:"skill-versions-row",children:[n.jsx(Mt,{id:"skill-version",className:"skill-version-select",value:H,disabled:i!==null,onChange:B,"aria-label":"版本",options:P.map(A=>({value:A.version,label:`${A.version}${A.latest?"(最新)":""}${A.version===k.version?"(正在用)":""}`,...A.changes===void 0?{}:{hint:A.changes}}))}),n.jsx("button",{className:"small-button",disabled:i!==null||H===k.version,onClick:()=>h(H),children:O("version")?"切换中…":"换成这个版本"})]}),(R==null?void 0:R.changes)!==void 0&&n.jsxs("span",{className:"muted small",children:[R.version,":",R.changes]}),R!==void 0&&!R.latest&&H!==k.version&&n.jsx("span",{className:"muted small",children:"换到旧版后不再提示更新,直到技能库有更新的版本;随时可以换回最新。"})]}),n.jsxs("section",{className:"skill-body","aria-label":"内容",children:[n.jsx("div",{className:"skill-body-label",children:"内容"}),s===void 0?n.jsx("p",{className:"muted",children:"正在读取…"}):s.trim()===""?n.jsx("p",{className:"muted",children:"(没有内容)"}):n.jsx(Hs,{text:s})]}),(j==null?void 0:j.path)!==void 0&&n.jsx("code",{className:"muted small skill-path",title:j.path,children:j.path})]})}function X8(e){var s;const t=(s=e.installed)==null?void 0:s.version;return e.installed===void 0?e.version:e.installed.update&&e.version!==void 0&&e.version!==t?`${t??"旧版"} → ${e.version}`:t}function Q8({client:e,draft:t,scripts:s,games:i,onCancel:r,onSaved:o}){const[l,u]=v.useState(t),[d,h]=v.useState(!1),[m,p]=v.useState(null);v.useEffect(()=>{u(t),p(null)},[t]);const g=t.original!==void 0,x=YN.test(l.name)&&l.name.length<=_p,N=x&&l.description.trim().length>=10&&l.content.trim().length>=20,j=async()=>{h(!0),p(null);try{t.hub===!0?await e.connection.call("skillhub/save",{name:l.name,description:l.description.trim(),content:l.content.trim()}):await e.connection.call("skills/save",{name:l.name,description:l.description.trim(),content:l.content.trim(),...l.scripts.length===0?{}:{scripts:l.scripts},...l.games.length===0?{}:{games:l.games},...g?{replace:!0}:{}}),o(l.name)}catch(y){p($e(y))}finally{h(!1)}};return n.jsxs("article",{className:"card skill-card skill-form",children:[n.jsx("div",{className:"skill-title",children:n.jsx("h2",{children:g?`编辑 ${t.original}`:"新建技能"})}),t.hub===!0&&n.jsx("p",{className:"muted small",children:"这是从技能库下载的:技能库更新它时会整个换成新版本,这里改的不保留(被换掉的那版可以回退)。"}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-label",children:"名字(在对话里用 /名字 调用它)"}),n.jsx("input",{className:"text-input",value:l.name,disabled:g,maxLength:_p,autoFocus:!g,onChange:y=>u(k=>({...k,name:y.target.value.trim().toLowerCase()})),placeholder:"例:maa-daily-check"}),l.name!==""&&!x&&n.jsx("span",{className:"error small",children:"只能用小写英文字母、数字和短横线,例如 maa-daily-check"})]}),t.hub!==!0&&n.jsx(dE,{scripts:s,games:i,value:l,onChange:y=>u(k=>({...k,...y}))}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-label",children:"说明:做什么、什么时候用(agent 靠它决定什么时候用,10–400 字)"}),n.jsx("textarea",{className:"text-input",rows:2,maxLength:400,value:l.description,onChange:y=>u(k=>({...k,description:y.target.value})),placeholder:"例:MAA 日常跑完后检查理智和基建是否都处理了;用户问「MAA 跑完了吗」时用。"})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-label",children:"内容(Markdown):适用场景、一步一步的做法、怎样算成功、注意事项"}),n.jsx("textarea",{className:"text-input skill-content-input",rows:16,maxLength:2e4,value:l.content,onChange:y=>u(k=>({...k,content:y.target.value}))})]}),m!==null&&n.jsx("p",{className:"error small",children:m}),n.jsxs("div",{className:"skill-actions",children:[n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:d,onClick:r,children:"取消"}),n.jsx("button",{className:"small-button primary",disabled:d||!N,onClick:()=>void j(),children:d?"保存中…":"保存"})]})]})}function dE({scripts:e,games:t,value:s,onChange:i}){const[r]=v.useState(s),o=[...new Set([...r.scripts,...s.scripts])].filter(m=>!e.some(p=>p.id===m)),l=[...new Set([...r.games,...s.games])].filter(m=>zd(m,t)===void 0),u=(m,p)=>{var g;return m===p||((g=zd(m,t))==null?void 0:g.id)===p},d=m=>i({...s,scripts:s.scripts.includes(m)?s.scripts.filter(p=>p!==m):[...s.scripts,m]}),h=m=>i({...s,games:s.games.some(p=>u(p,m))?s.games.filter(p=>!u(p,m)):[...s.games,m]});return n.jsxs(n.Fragment,{children:[(t.length>0||l.length>0)&&n.jsxs("fieldset",{className:"field skill-owners",children:[n.jsx("legend",{className:"field-label",children:"给哪个游戏用(和游戏本身有关、换个脚本也用得上的:游戏里的操作、界面、活动、机制)"}),n.jsxs("div",{className:"skill-owner-list",children:[t.map(m=>n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:s.games.some(p=>u(p,m.id)),onChange:()=>h(m.id)}),m.name]},m.id)),l.map(m=>n.jsxs("label",{className:"check-label",title:"游戏页上没有这个游戏",children:[n.jsx("input",{type:"checkbox",checked:s.games.includes(m),onChange:()=>h(m)}),m]},m))]})]}),n.jsxs("fieldset",{className:"field skill-owners",children:[n.jsx("legend",{className:"field-label",children:"给哪个脚本用(只在用这个脚本时才用得上的做法:它的配置、报错、日志)"}),e.length===0&&o.length===0&&n.jsx("span",{className:"muted small",children:"还没有装脚本。"}),n.jsxs("div",{className:"skill-owner-list",children:[e.map(m=>n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:s.scripts.includes(m.id),onChange:()=>d(m.id)}),m.name]},m.id)),o.map(m=>n.jsxs("label",{className:"check-label",title:"这个脚本不在脚本库里(删掉了,或是脚本包 id)",children:[n.jsx("input",{type:"checkbox",checked:s.scripts.includes(m),onChange:()=>d(m)}),m]},m))]})]}),n.jsx("p",{className:"muted small",children:"游戏和脚本都不选就是通用技能,所有对话都能用。"})]})}function J8({client:e,skill:t,content:s,scripts:i,games:r,onCancel:o,onMoved:l}){var j,y;const[u,d]=v.useState({scripts:[...((j=t.owner)==null?void 0:j.scripts)??[]],games:[...((y=t.owner)==null?void 0:y.games)??[]]}),[h,m]=v.useState(!1),[p,g]=v.useState(null),x=t.source==="hub",N=async k=>{m(!0),g(null);try{if(x)await e.connection.call("skillhub/owner",{name:t.name,owner:k});else{if(s===void 0||k===null)return;await e.connection.call("skills/save",{name:t.name,description:t.description,content:s,replace:!0,...k.scripts.length===0?{}:{scripts:k.scripts},...k.games.length===0?{}:{games:k.games}})}l()}catch(_){g($e(_))}finally{m(!1)}};return n.jsxs("div",{className:"skill-move",role:"group","aria-label":"更换游戏和脚本",children:[n.jsx(dE,{scripts:i,games:r,value:u,onChange:d}),x&&n.jsx("p",{className:"muted small",children:"这是从技能库下载的:你选的会一直保留,技能库更新它也不变。"}),p!==null&&n.jsx("p",{className:"error small",children:p}),n.jsxs("div",{className:"skill-actions",children:[x&&n.jsx("button",{className:"link-button small",disabled:h,onClick:()=>void N(null),children:"恢复成技能库里的"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:h,onClick:o,children:"取消"}),n.jsx("button",{className:"small-button primary",disabled:h||!x&&s===void 0,onClick:()=>void N(u),children:h?"保存中…":"保存"})]})]})}const e7={id:"skills",title:"技能",requires:["skills"],pages:[{id:"skills",title:"技能",icon:"sparkles",order:50,agent:"scripts",component:K8}]};function t7({client:e}){const t=_e(e.connection.status),[s,i]=v.useState(null),[r,o]=v.useState(0),[l,u]=v.useState(null),[d,h]=v.useState(null),[m,p]=v.useState(""),[g,x]=v.useState("");v.useEffect(()=>e.connection.on("emulators/changed",()=>o(y=>y+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let y=!0;return e.connection.call("emulators/status",{refresh:r===0}).then(k=>{y&&(i(k),p(k.settings.manualAddress??""),x(k.settings.adbPath??""))}).catch(k=>{y&&h($e(k))}),()=>{y=!1}},[e,t.state,r]);const N=async(y,k)=>{u(y),h(null);try{await k(),o(_=>_+1)}catch(_){h($e(_))}finally{u(null)}},j=y=>N("settings",()=>e.connection.call("emulators/settings/set",y));return n.jsxs("div",{className:"settings-page",children:[n.jsx("h2",{children:"模拟器"}),n.jsx("p",{children:"需要安卓模拟器的任务(如 MAA)运行前,会自动启动这里选定的实例并取得 ADB 地址。分辨率请设为 16:9(如 1280×720)。"}),n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"当前使用"}),n.jsx("p",{className:"muted small",children:(s==null?void 0:s.selection.label)??"…"})]}),n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void N("refresh",()=>e.connection.call("emulators/status",{refresh:!0})),children:"重新检测"})]}),(s==null?void 0:s.selection.problem)!==void 0&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(Q,{name:"info"}),n.jsxs("span",{children:[s.selection.problem,"。可以对 agent 说「安装 MuMu 模拟器」,或在下面填写手动 ADB 地址。"]})]})]}),s==null?void 0:s.providers.map(y=>n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsxs("h3",{children:[y.name,y.version===void 0?"":` ${y.version}`]}),n.jsx("p",{className:"muted small",children:y.manager})]}),s.settings.mumuManager===y.manager&&n.jsx("span",{className:"badge ok",children:"已指定"})]}),y.error!==void 0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:y.error})]}),n.jsx("ul",{className:"version-list",children:y.instances.map(k=>n.jsxs("li",{className:k.index===s.settings.instance?"current":"",children:[n.jsx("span",{className:"version-name",children:k.index}),n.jsx("span",{children:k.name}),n.jsx("span",{className:`badge ${k.ready?"ok":""}`,children:k.ready?"已启动":k.running?"启动中":"未运行"}),k.adb!==void 0&&n.jsx("span",{className:"muted small",children:k.adb}),n.jsx("span",{className:"spacer"}),k.index!==s.settings.instance&&n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void j({instance:k.index}),children:"任务用这个"}),k.ready?n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void N(`stop-${k.index}`,()=>e.connection.call("emulators/stop",{index:k.index})),children:"关闭"}):n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void N(`start-${k.index}`,()=>e.connection.call("emulators/start",{index:k.index})),children:l===`start-${k.index}`?"启动中…":"启动"})]},k.index))})]},y.manager)),s!==null&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"设置"}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:s.settings.autoStart,onChange:y=>void j({autoStart:y.target.checked})}),"任务需要时自动启动模拟器"]}),n.jsx("label",{className:"field-label",htmlFor:"manual-adb",children:"手动 ADB 地址(其他模拟器或真机,可选)"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:"manual-adb",className:"text-input plain",value:m,onChange:y=>p(y.target.value),placeholder:"例如 127.0.0.1:5555;填写后不再管理 MuMu",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void j({manualAddress:m.trim()===""?null:m.trim()}),children:"保存"})]}),n.jsx("label",{className:"field-label",htmlFor:"adb-path",children:"adb.exe 位置(可选,出错时重连模拟器、截图用;默认用 MuMu 自带的)"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:"adb-path",className:"text-input plain",value:g,onChange:y=>x(y.target.value),placeholder:"例如 D:\\platform-tools\\adb.exe",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void j({adbPath:g.trim()===""?null:g.trim()}),children:"保存"}),n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void hh(e,{kind:"file",title:"选择 adb.exe",defaultPath:g.trim(),filterName:"程序",extensions:["exe"]}).then(y=>{y!==null&&(x(y),j({adbPath:y}))},y=>h($e(y))),children:"选择文件…"})]}),n.jsx("label",{className:"field-label",htmlFor:"boot-timeout",children:"等待安卓启动的最长时间(秒)"}),n.jsx("input",{id:"boot-timeout",className:"text-input plain",type:"number",min:30,max:900,defaultValue:s.settings.bootTimeoutSeconds,onBlur:y=>void j({bootTimeoutSeconds:Math.max(30,Math.min(900,Number(y.target.value)||180))})})]}),d!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:d})]})]})}function n7({client:e}){const t=_e(e.connection.status),[s,i]=v.useState(null),[r,o]=v.useState(null),[l,u]=v.useState(""),[d,h]=v.useState(""),[m,p]=v.useState(null),[g,x]=v.useState(!1),[N,j]=v.useState(null),[y,k]=v.useState(null),_=()=>e.connection.call("scripts/settings",{}).then(P=>{i(P),o(P)}).catch(P=>k($e(P)));if(v.useEffect(()=>{t.state==="open"&&_()},[e,t.state]),r===null||s===null)return n.jsxs("div",{className:"settings-page",children:[n.jsx("h2",{children:"脚本安装"}),y===null?n.jsx("p",{children:"加载中…"}):n.jsx("div",{className:"notice error left",children:y})]});const S=(P,H)=>o({...r,[P]:H}),E=async()=>{x(!0),k(null),j(null);try{const{tokenConfigured:P,cdkConfigured:H,...B}=s,R=Object.fromEntries(Object.entries(r).filter(([M,F])=>B[M]!==F));Object.keys(R).length>0&&await e.connection.call("scripts/settings/set",R),l.trim()!==""&&await e.connection.call("credentials/set",{ref:r.tokenRef,value:l.trim()}),u(""),d.trim()!==""&&(await e.connection.call("credentials/set",{ref:r.cdkRef,value:d.trim()}),h(""),O()),await _(),j("已保存,下一次安装起生效")}catch(P){k($e(P))}finally{x(!1)}},O=async()=>{p("checking");try{p(await e.connection.call("scripts/mirrorchyan/check",{}))}catch(P){p({ok:!1,message:$e(P)})}};return n.jsxs("div",{className:"settings-page",children:[n.jsx("h2",{children:"脚本安装"}),n.jsx("p",{children:"从 GitHub 发布页下载脚本时使用的设置。国内网络下载慢或失败时,可以填写下载镜像前缀。"}),n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"下载镜像"}),n.jsx("input",{className:"text-input plain",value:r.downloadMirror,onChange:P=>S("downloadMirror",P.target.value),placeholder:"留空直接下载;例如 https://ghfast.top/",spellCheck:!1}),n.jsx("p",{className:"muted small",children:"镜像只用于 GitHub 上的文件:下载地址前面加上这个前缀。微软、Google 等官方组件始终直接下载。"}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:r.mirrorFallback,onChange:P=>S("mirrorFallback",P.target.checked)}),"镜像失败时改为直接下载"]})]}),n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"Mirror酱"}),n.jsxs("p",{className:"muted small",children:["在 ",n.jsx("a",{href:"https://mirrorchyan.com?source=multigameassistant_settings",target:"_blank",rel:"noreferrer",children:"Mirror酱"})," 发布的脚本(MAA、MaaEnd、三月七小助手、M9A、BetterGI 等)填了 CDK 后从 Mirror酱 更新:国内下载快,而且只下载改动的文件(增量更新)。不填照常从 GitHub 下载;CDK 过期、次数用完时也会自动改回 GitHub。"]}),n.jsx("label",{className:"field-label",htmlFor:"mc-cdk",children:"CDK"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:"mc-cdk",className:"text-input",type:"password",value:d,onChange:P=>h(P.target.value),placeholder:s.cdkConfigured?"已配置;输入新值可替换":"在 Mirror酱 购买后得到的 CDK",autoComplete:"off"}),s.cdkConfigured?n.jsx("span",{className:"badge ok",children:"已配置"}):n.jsx("span",{className:"badge",children:"未配置"}),s.cdkConfigured&&n.jsx("button",{className:"small-button",disabled:m==="checking",onClick:()=>void O(),children:m==="checking"?"检查中…":"检查"})]}),m!==null&&m!=="checking"&&n.jsx("p",{className:"small",style:{color:m.ok?"var(--ok)":"var(--error)"},children:m.message}),n.jsxs("p",{className:"muted small",children:["保存在 dsh 的凭据文件里(",r.cdkRef,"),界面和日志里都不会显示它。"]})]}),n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"GitHub 访问"}),n.jsx("label",{className:"field-label",htmlFor:"gh-token",children:"GitHub Token(可选)"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:"gh-token",className:"text-input",type:"password",value:l,onChange:P=>u(P.target.value),placeholder:s.tokenConfigured?"已配置;输入新值可替换":"不填也能用;填写后请求上限从每小时 60 次提高到 5000 次",autoComplete:"off"}),s.tokenConfigured?n.jsx("span",{className:"badge ok",children:"已配置"}):n.jsx("span",{className:"badge",children:"未配置"})]}),n.jsxs("p",{className:"muted small",children:["只需要读取公开仓库的权限。保存在 dsh 的凭据文件里(",r.tokenRef,"),界面不会显示它的内容。"]}),n.jsx("label",{className:"field-label",htmlFor:"gh-api",children:"API 地址"}),n.jsx("input",{id:"gh-api",className:"text-input plain",value:r.apiBase,onChange:P=>S("apiBase",P.target.value),spellCheck:!1})]}),n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"版本"}),n.jsx("label",{className:"field-label",htmlFor:"keep-versions",children:"每个脚本保留的版本数(含当前版本)"}),n.jsx("input",{id:"keep-versions",className:"text-input plain",type:"number",min:1,max:10,value:r.keepVersions,onChange:P=>S("keepVersions",Math.max(1,Math.min(10,Number(P.target.value)||1)))}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:r.includePrereleases,onChange:P=>S("includePrereleases",P.target.checked)}),"没有正式版时使用预发布版本"]})]}),n.jsxs("div",{className:"key-actions",children:[N!==null&&n.jsx("span",{className:"muted small",children:N}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"primary",disabled:g,onClick:()=>void E(),children:g?"保存中…":"保存"})]}),y!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:y})]})]})}function s7({client:e,initialRepo:t,jobs:s,onDone:i,openSession:r,onClose:o}){const[l,u]=v.useState(t??""),[d,h]=v.useState(null),[m,p]=v.useState(""),[g,x]=v.useState(""),[N,j]=v.useState(!1),[y,k]=v.useState(null),[_,S]=v.useState(null),E=async(R=l)=>{var F;const M=nO(R);if(M===void 0){k("请输入 owner/repo,或粘贴 GitHub 上的仓库、发布或文件链接");return}j(!0),k(null);try{const L=await e.connection.call("scripts/releases",{repo:M.repo,limit:10});u(M.repo),h({...L,branch:M.branch});const A=L.releases.find(z=>z.tag===M.tag),I=A??L.releases.find(z=>!z.prerelease)??L.releases[0];p((I==null?void 0:I.tag)??""),x(((F=I==null?void 0:I.assets.find(z=>z.name===M.asset))==null?void 0:F.name)??(I==null?void 0:I.suggestedAsset)??""),M.tag!==void 0&&A===void 0&&L.releases.length>0&&k(`最近的发布里没有 ${M.tag},已改选最新版本`)}catch(L){h(null),k($e(L))}finally{j(!1)}};v.useEffect(()=>{t!==void 0&&E(t)},[t]);const O=d==null?void 0:d.releases.find(R=>R.tag===m),P=d!==null&&(d.branch!==void 0||d.releases.length===0),H=async()=>{if(d!==null){j(!0),k(null);try{const{jobId:R,scriptId:M}=await e.connection.call("scripts/install",{repo:d.repo,...d.branch===void 0?{}:{branch:d.branch}});S({jobId:R,scriptId:M,tag:d.branch===void 0?"默认分支":`${d.branch} 分支`,asset:"源码压缩包"})}catch(R){k($e(R))}finally{j(!1)}}},B=async()=>{var R;if(!(d===null||O===void 0||g==="")){j(!0),k(null);try{const{jobId:M,scriptId:F}=await e.connection.call("scripts/install",{repo:d.repo,tag:O.tag,asset:g});S({jobId:M,scriptId:F,tag:O.tag,asset:g,size:(R=O.assets.find(L=>L.name===g))==null?void 0:R.size})}catch(M){k($e(M))}finally{j(!1)}}};if(_!==null&&d!==null){const R=s.get(_.scriptId);return n.jsx(hE,{client:e,repo:d.repo,..._,job:(R==null?void 0:R.id)===_.jobId?R:void 0,onDone:()=>i(_.scriptId),openSession:r,onRetry:()=>S(null),onClose:o})}return n.jsxs("section",{className:"card panel-card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"从 GitHub 安装"}),n.jsx("p",{className:"muted small",children:"优先使用发布版本;文件会放进统一的工具目录,旧版本保留用于回滚。"})]}),n.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:o,children:n.jsx(Q,{name:"close"})})]}),n.jsxs("form",{className:"field-row",onSubmit:R=>{R.preventDefault(),E()},children:[n.jsx("input",{className:"text-input plain","aria-label":"GitHub 仓库",value:l,onChange:R=>u(R.target.value),placeholder:"owner/repo 或 GitHub 链接,例如 MaaAssistantArknights/MaaAssistantArknights",spellCheck:!1,disabled:N}),n.jsx("button",{type:"submit",disabled:N||l.trim()==="",children:N&&d===null?"读取中…":"读取发布"})]}),P&&n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:d.branch!==void 0?`链接指向 ${d.branch} 分支:会下载这个分支当前的源码,之后跟着它更新。`:"这个仓库还没有发布版本:可以下载默认分支当前的源码,之后跟着这个分支更新。"}),n.jsx("span",{className:"spacer"}),n.jsxs("button",{className:d.releases.length===0?"primary":"",onClick:()=>void H(),disabled:N,children:["安装",d.branch===void 0?"源码":` ${d.branch} 分支`]})]}),d!==null&&d.releases.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"field-label",htmlFor:"release-select",children:["版本",d.packId!==void 0&&n.jsxs("span",{className:"chip subtle",children:["官方脚本包 ",d.packId]})]}),n.jsx(Mt,{id:"release-select",value:m,disabled:N,onChange:R=>{var M;p(R),x(((M=d.releases.find(F=>F.tag===R))==null?void 0:M.suggestedAsset)??"")},options:d.releases.map(R=>({value:R.tag,label:`${R.tag}${R.prerelease?"(预发布)":""}`,...R.publishedAt===void 0?{}:{hint:`${R.publishedAt.slice(0,10)} 发布`}}))}),O!==void 0&&n.jsxs("fieldset",{className:"asset-list",disabled:N,children:[n.jsx("legend",{className:"field-label",children:"下载文件"}),O.assets.length===0&&n.jsx("div",{className:"muted small",children:"这个版本没有可下载的文件"}),[...O.assets].sort((R,M)=>+(M.name===O.suggestedAsset)-+(R.name===O.suggestedAsset)).map(R=>n.jsxs("label",{className:`asset-option ${R.name===g?"active":""}`,children:[n.jsx("input",{type:"radio",name:"asset",value:R.name,checked:R.name===g,onChange:()=>x(R.name)}),n.jsx("span",{className:"asset-name",children:R.name}),R.name===O.suggestedAsset&&n.jsx("span",{className:"badge ok",children:"推荐"}),n.jsx("span",{className:"muted small",children:Ta(R.size)})]},R.name))]}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:(O==null?void 0:O.suggestedAsset)===void 0?"没有自动匹配到适合本机的文件,请手动选择。":"已按本机(Windows x64)选好文件。"}),n.jsx("span",{className:"spacer"}),n.jsxs("button",{className:"primary",onClick:()=>void B(),disabled:N||g==="",children:["安装 ",O==null?void 0:O.tag]})]})]}),y!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:y})]})]})}function i7({client:e,initialRid:t,jobs:s,onDone:i,openSession:r,onGitHub:o,onClose:l}){const[u,d]=v.useState(""),h=r7(e,u),[m,p]=v.useState(null),[g,x]=v.useState(null),[N,j]=v.useState(!1),[y,k]=v.useState(null),[_,S]=v.useState(null);v.useEffect(()=>{e.connection.call("scripts/settings",{}).then(B=>x(B.cdkConfigured),()=>x(null))},[e]);const E=async B=>{j(!0),k(null);try{p(await e.connection.call("scripts/mirrorchyan/lookup",{rid:B}))}catch(R){p(null),k($e(R))}finally{j(!1)}};v.useEffect(()=>{t!==void 0&&E(t)},[t]);const O=async()=>{if(m!==null){j(!0),k(null);try{S(await e.connection.call("scripts/install",{mirrorchyan:m.rid}))}catch(B){k($e(B))}finally{j(!1)}}};if(_!==null&&m!==null){const B=s.get(_.scriptId);return n.jsx(hE,{client:e,repo:`Mirror酱 · ${m.rid}`,tag:m.version,asset:`${m.name??m.rid}(Mirror酱 完整包)`,job:(B==null?void 0:B.id)===_.jobId?B:void 0,onDone:()=>i(_.scriptId),openSession:r,onRetry:()=>S(null),onClose:l})}const P=u.trim(),H=/^[\w.-]{1,100}$/.test(P)&&!(h.items??[]).some(B=>B.rid.toLowerCase()===P.toLowerCase());return n.jsxs("section",{className:"card panel-card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"从 Mirror酱 安装"}),n.jsx("p",{className:"muted small",children:"按游戏名、工具名或资源 id 查找(查找和查询版本都不需要 CDK);下载需要在「设置 → 脚本安装」填写 CDK,以后的更新有增量包。"})]}),n.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:l,children:n.jsx(Q,{name:"close"})})]}),n.jsx("input",{className:"text-input plain","aria-label":"搜索 Mirror酱",value:u,onChange:B=>d(B.target.value),placeholder:"例如 原神、鸣潮、BetterGI、MAA",spellCheck:!1,autoFocus:!0}),n.jsx(a7,{results:h,selected:m==null?void 0:m.rid,disabled:N,onPick:B=>void E(B)}),H&&n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),n.jsxs("button",{className:"small-button",disabled:N,onClick:()=>void E(P),children:["按资源 id 查询 ",P]})]}),m!==null&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"install-file",children:[n.jsx(Q,{name:"package"}),n.jsx("span",{className:"asset-name",children:m.name??m.rid}),n.jsxs("span",{className:"badge",children:["Mirror酱 ",m.rid]}),n.jsxs("span",{className:"muted small",children:["最新 ",m.version]})]}),m.description!==void 0&&n.jsx("p",{className:"muted small mirror-desc",children:m.description}),g===!1&&n.jsx("div",{className:"notice info left small",children:n.jsxs("span",{children:["还没有填写 Mirror酱 CDK,没法从 Mirror酱 下载。",m.repo!==void 0?"也可以从 GitHub 安装,填了 CDK 后它的更新会走 Mirror酱。":""]})}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:m.repo===void 0?"":`GitHub:${m.repo}`}),n.jsx("span",{className:"spacer"}),m.repo!==void 0&&n.jsx("button",{className:"small-button",disabled:N,onClick:()=>o(m.repo),children:"从 GitHub 安装"}),n.jsxs("button",{className:"primary",onClick:()=>void O(),disabled:N||g===!1,children:["安装 ",m.version]})]})]}),y!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:y})]})]})}function r7(e,t){const[s,i]=v.useState({loading:!0});return v.useEffect(()=>{let r=!0;i(l=>({...l,loading:!0}));const o=setTimeout(()=>{e.connection.call("scripts/mirrorchyan/search",{query:t.trim()}).then(l=>{r&&i({items:l.items,from:l.from,loading:!1})}).catch(l=>{r&&i({error:$e(l),loading:!1})})},t.trim()===""?0:250);return()=>{r=!1,clearTimeout(o)}},[e,t]),s}function a7({results:e,selected:t,disabled:s,limit:i=8,onPick:r,pickLabel:o="选择"}){const[l,u]=v.useState(!1);if(e.error!==void 0)return n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:e.error})]});const d=e.items??[];if(d.length===0)return n.jsx("div",{className:"muted small mirror-empty",children:e.loading?"查找中…":"没有找到。可以换个说法(游戏简称、英文名),或直接输入资源 id。"});const h=l?d:d.slice(0,i);return n.jsxs(n.Fragment,{children:[e.from==="builtin"&&n.jsx("div",{className:"muted small mirror-empty",children:"读不到 Mirror酱 的项目列表,下面是已知的几个;也可以直接输入资源 id 查询。"}),n.jsx("ul",{className:"mirror-results",children:h.map(m=>n.jsxs("li",{className:m.rid===t?"active":"",children:[n.jsxs("div",{className:"mirror-result-main",children:[n.jsxs("span",{className:"mirror-result-name",children:[m.name,n.jsx("span",{className:"chip subtle",children:m.rid}),m.installed&&n.jsx("span",{className:"badge ok",children:"已在脚本库"})]}),m.description!==""&&n.jsx("span",{className:"muted small",children:m.description})]}),n.jsx("button",{className:"small-button",disabled:s,onClick:()=>r(m.rid),children:o})]},m.rid))}),!l&&d.length>i&&n.jsxs("button",{className:"link-button small",onClick:()=>u(!0),children:["还有 ",d.length-i," 个"]})]})}const Hj=["resolving","downloading","verifying","extracting","checking","done"];function hE({client:e,repo:t,tag:s,asset:i,size:r,job:o,onDone:l,openSession:u,onRetry:d,onClose:h}){const m=(o==null?void 0:o.phase)??"queued",p=m==="done"?o==null?void 0:o.setup:void 0,g=o===void 0||o.endedAt===void 0,x=o7(o==null?void 0:o.received),N=(o==null?void 0:o.total)??r,j=N!==void 0&&N>0&&(o==null?void 0:o.received)!==void 0?Math.min(1,o.received/N):void 0,y=v.useRef(-1),k=Hj.indexOf(m);k>y.current&&(y.current=k);const _=p!==void 0?"交给 agent 安装":m==="done"?"安装完成":m==="failed"?"安装失败":m==="cancelled"?"已取消安装":"正在安装",S=E=>m==="done"||E<y.current?"done":E===y.current?g?"active":"stopped":"todo";return n.jsxs("section",{className:"card panel-card install-progress","aria-live":"polite",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:_}),n.jsxs("p",{className:"muted small",children:[t," · ",s]})]}),n.jsx("button",{className:"icon-button","aria-label":"关闭",title:g?"关掉面板,安装在后台继续(左边列表里能看到进度)":"关闭",onClick:h,children:n.jsx(Q,{name:"close"})})]}),n.jsxs("div",{className:"install-file",children:[n.jsx(Q,{name:"package"}),n.jsx("span",{className:"asset-name",children:i}),r!==void 0&&n.jsx("span",{className:"muted small",children:Ta(r)})]}),n.jsx("ol",{className:"install-steps",children:Hj.slice(0,-1).map((E,O)=>{const P=S(O);return n.jsxs("li",{className:`install-step ${P}`,children:[n.jsx("span",{className:"install-step-mark",children:P==="done"?n.jsx(Q,{name:"check"}):P==="stopped"?n.jsx(Q,{name:"close"}):O+1}),n.jsx("span",{children:jc[E]})]},E)})}),g&&n.jsxs("div",{className:"install-bar",children:[n.jsx("div",{className:`progress ${m==="downloading"&&j!==void 0?"":"indeterminate"}`,"aria-hidden":"true",children:n.jsx("span",{style:m==="downloading"&&j!==void 0?{width:`${(j*100).toFixed(1)}%`}:void 0})}),n.jsxs("div",{className:"install-numbers muted small",children:[n.jsx("span",{children:o===void 0?"等待开始…":o.message??jc[m]}),m==="downloading"&&(o==null?void 0:o.received)!==void 0&&n.jsxs("span",{className:"install-bytes",children:[Ta(o.received),N!==void 0?` / ${Ta(N)}`:"",j!==void 0?` · ${Math.floor(j*100)}%`:"",x!==void 0?` · ${Ta(Math.round(x))}/s`:"",x!==void 0&&x>0&&N!==void 0?` · 还要 ${l7((N-o.received)/x)}`:""]})]})]}),(o==null?void 0:o.error)!==void 0&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:o.error})]}),p!==void 0&&n.jsxs("div",{className:"notice left",children:[n.jsx(Q,{name:"info"}),n.jsxs("span",{children:[o==null?void 0:o.message,"。它也在左边「等待安装」里:没配好模型时可以在那里自己安装。装好后脚本会出现在列表里。"]})]}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:g?"可以关掉这个面板,安装会在后台继续。":p!==void 0?`下载好了 ${(o==null?void 0:o.version)??s} 的安装程序。`:m==="done"?`已安装 ${(o==null?void 0:o.version)??s}。`:""}),n.jsx("span",{className:"spacer"}),g&&o!==void 0&&n.jsx("button",{className:"small-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:o.id}).catch(()=>{}),children:"取消安装"}),(m==="failed"||m==="cancelled")&&n.jsx("button",{className:"small-button",onClick:d,children:"重新选择"}),(p==null?void 0:p.sessionId)!==void 0&&n.jsx("button",{className:"primary small-button",onClick:()=>u(p.sessionId),children:"查看对话"}),m==="done"&&p===void 0&&n.jsx("button",{className:"primary small-button",onClick:l,children:"查看脚本"})]})]})}function o7(e){const t=v.useRef([]),[s,i]=v.useState(void 0);return v.useEffect(()=>{if(e===void 0)return;const r=Date.now(),o=[...t.current.filter(u=>r-u.at<=4e3&&u.bytes<=e),{at:r,bytes:e}];t.current=o;const l=o[0];r-l.at>=500&&i((e-l.bytes)/((r-l.at)/1e3))},[e]),s}function l7(e){return!Number.isFinite(e)||e<0?"—":e<60?`${Math.max(1,Math.round(e))} 秒`:`${Math.floor(e/60)} 分 ${Math.round(e%60)} 秒`}function c7({client:e,onImported:t,onClose:s}){const[i,r]=v.useState(""),[o,l]=v.useState(""),[u,d]=v.useState(!1),[h,m]=v.useState(null),p=async()=>{m(null);try{const x=await hh(e,{kind:"folder",title:"选择脚本所在的文件夹",defaultPath:i.trim().replace(/^"|"$/g,"")});x!==null&&r(x)}catch(x){m($e(x))}},g=async()=>{d(!0),m(null);try{const x=await e.connection.call("scripts/import",{path:i.trim().replace(/^"|"$/g,""),...o.trim()===""?{}:{name:o.trim()}});t(x.id)}catch(x){m($e(x)),d(!1)}};return n.jsxs("section",{className:"card panel-card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"导入本地项目"}),n.jsx("p",{className:"muted small",children:"登记电脑上已有的脚本目录,原地使用:不移动、不复制、不修改,移除时也不会删除。"})]}),n.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:s,children:n.jsx(Q,{name:"close"})})]}),n.jsxs("form",{className:"import-form",onSubmit:x=>{x.preventDefault(),g()},children:[n.jsx("label",{className:"field-label",htmlFor:"import-path",children:"目录路径"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:"import-path",className:"text-input plain",value:i,onChange:x=>r(x.target.value),placeholder:"例如 D:\\Games\\MAA",spellCheck:!1,disabled:u}),n.jsx("button",{className:"small-button",type:"button",disabled:u,onClick:()=>void p(),children:"选择文件夹…"})]}),n.jsx("label",{className:"field-label",htmlFor:"import-name",children:"显示名称(可选)"}),n.jsx("input",{id:"import-name",className:"text-input plain",value:o,onChange:x=>l(x.target.value),placeholder:"留空则按脚本包或目录名",disabled:u}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:"会按官方脚本包自动识别是哪个脚本。"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"primary",type:"submit",disabled:u||i.trim()==="",children:u?"导入中…":"导入"})]})]}),h!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:h})]})]})}function wg({client:e,job:t,compact:s=!1}){const i=t.endedAt===void 0,r=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 n.jsxs("div",{className:`job ${t.phase}${s?" compact":""}`,role:"status",children:[n.jsxs("div",{className:"job-line",children:[n.jsxs("span",{className:"job-phase",children:[o," · ",t.setup!==void 0&&t.phase==="done"?"已交给 agent 安装":jc[t.phase],t.version!==void 0&&t.phase==="done"?` ${t.version}`:""]}),r!==void 0&&i&&n.jsxs("span",{className:"job-bytes",children:[Ta(t.received??0)," / ",Ta(t.total??0)]}),i&&n.jsx("button",{className:"link-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:t.id}).catch(()=>{}),children:"取消"})]}),i&&n.jsx("div",{className:`progress ${r===void 0?"indeterminate":""}`,"aria-hidden":"true",children:n.jsx("span",{style:r===void 0?void 0:{width:`${(r*100).toFixed(1)}%`}})}),!s&&t.message!==void 0&&(i||t.setup!==void 0)&&n.jsx("div",{className:"job-message muted small",children:t.message}),t.error!==void 0&&n.jsx("div",{className:"job-error small",children:t.error})]})}const u7={install:"安装来源",pack:"脚本包",known:"已知项目",user:"你设置的"};function mE({client:e,script:t,disabled:s,act:i}){const[r,o]=v.useState(null),[l,u]=v.useState(""),[d,h]=v.useState(null),m=t.channels.github,p=t.channels.mirrorchyan,g=(y,k)=>i("channel",async()=>{await e.connection.call("scripts/source/set",k==="reset"?{id:t.id,reset:[y]}:y==="repo"?{id:t.id,repo:k}:{id:t.id,mirrorchyan:k}),o(null);const _=y==="repo"?"GitHub":"Mirror酱";return k===null?`已不再从 ${_} 更新`:k==="reset"?`${_} 更新渠道已恢复自动`:`${_} 更新渠道已设为 ${k}`}),x=()=>i("mirror-match",async()=>{const y=await e.connection.call("scripts/mirrorchyan/match",{id:t.id});return h({items:y.items,checked:!0}),y.items.length===0?`Mirror酱 上没有找到它${y.from==="builtin"?"(读不到 Mirror酱 的项目列表,只查了已知的)":""};知道资源 id 的话可以直接「设置」`:void 0}),N=(y,k)=>y==="repo"?/^[\w.-]+\/[\w.-]+$/.test(k):/^[\w.-]{1,100}$/.test(k),j=(y,k,_,S,E)=>n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:k}),n.jsx("dd",{children:r!==y?n.jsxs(n.Fragment,{children:[_!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{children:_.text}),n.jsxs("span",{className:"muted small",children:["(",u7[_.from],")"]})]}):n.jsx("span",{className:"muted small",children:S}),(_==null?void 0:_.from)!=="install"&&n.jsx("button",{className:"ghost small-button",disabled:s,onClick:()=>{u((_==null?void 0:_.text)??""),o(y)},children:_===void 0?"设置":"修改"}),y==="mirrorchyan"&&_===void 0&&n.jsx("button",{className:"ghost small-button",disabled:s,onClick:()=>void x(),children:"查询是否接入"})]}):n.jsxs("span",{className:"local-source-edit",children:[n.jsx("input",{className:"text-input plain","aria-label":`${k}更新渠道`,value:l,onChange:O=>u(O.target.value),placeholder:E,spellCheck:!1,autoFocus:!0}),n.jsx("button",{className:"primary small-button",disabled:s||!N(y,l.trim()),onClick:()=>void g(y,l.trim()),children:y==="mirrorchyan"?"查询并保存":"保存"}),n.jsx("button",{className:"small-button",disabled:s,onClick:()=>void g(y,"reset"),children:"恢复自动"}),_!==void 0&&n.jsx("button",{className:"small-button",disabled:s,onClick:()=>void g(y,null),children:"不用"}),n.jsx("button",{className:"ghost small-button",onClick:()=>o(null),children:"取消"})]})})]});return n.jsxs(n.Fragment,{children:[j("repo","GitHub",m===void 0?void 0:{text:m.repo,from:m.from},"未设置:填写它的 GitHub 仓库","owner/repo,例如 babalae/better-genshin-impact"),j("mirrorchyan","Mirror酱",p===void 0?void 0:{text:p.rid,from:p.from},"未设置:在 Mirror酱 发布的脚本填它的资源 id","资源 id,例如 BGI、MAA"),p===void 0&&d!==null&&d.items.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("dt",{}),n.jsxs("dd",{className:"mirror-matches",children:[n.jsx("span",{className:"muted small",children:"Mirror酱 上可能是它:"}),d.items.slice(0,5).map(y=>n.jsxs("span",{className:"mirror-match",children:[n.jsx("span",{children:y.name}),n.jsx("span",{className:"chip subtle",children:y.rid}),n.jsx("button",{className:"small-button",disabled:s,onClick:()=>void g("mirrorchyan",y.rid).then(()=>h(null)),children:"用这个"})]},y.rid))]})]})]})}function d7({client:e,script:t,disabled:s,busy:i,now:r,act:o}){const[l,u]=v.useState(!1),d=t.localVersion,h=t.update,m=t.channels.github!==void 0||t.channels.mirrorchyan!==void 0;return n.jsxs("div",{className:"local-update",children:[n.jsxs("dl",{className:"local-facts",children:[n.jsx("dt",{children:"当前版本"}),n.jsx("dd",{children:d!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"version-name",children:d.version}),n.jsx("span",{className:"muted small",children:d.from==="更新"?"(由 MultiGameAssistant 更新)":`(读自 ${d.from})`})]}):n.jsx("span",{className:"muted small",children:"认不出这个目录的版本:检查更新时会当作可以更新"})}),n.jsx(mE,{client:e,script:t,disabled:s,act:o})]}),l?n.jsxs("div",{className:"local-confirm",children:[n.jsxs("p",{className:"small",children:["将在 ",n.jsx("code",{children:t.dir})," 里更新到 ",h==null?void 0:h.latest,":被替换的程序文件先备份到工具目录(可以撤销),已有的配置文件不动。请先关闭这个脚本。"]}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>u(!1),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:s,onClick:()=>void o("update",async()=>(u(!1),(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0)),children:"确认更新"})]})]}):n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[h===void 0?"还没有检查过更新":h.available?`有新版本 ${h.latest}`:`已是最新(${h.latest})`,h!==void 0&&` · ${vt(h.checkedAt,r)}检查`]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:s||!m,onClick:()=>void o("check",async()=>{const p=await e.connection.call("scripts/checkUpdate",{id:t.id});return p.available?`发现新版本 ${p.latest}${p.current===void 0?"(认不出当前版本)":`,当前 ${p.current}`}`:"已是最新版本"}),children:i==="check"?"检查中…":"检查更新"}),n.jsx("button",{className:"primary small-button",disabled:s||(h==null?void 0:h.available)!==!0,onClick:()=>u(!0),children:"更新"})]}),t.undo!==void 0&&n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:["上次更新:",t.undo.from??"(未知版本)"," → ",t.undo.to," · ",vt(t.undo.at,r)]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:s,onClick:()=>void o("restore",async()=>{const p=await e.connection.call("scripts/restore",{id:t.id});return`已撤销,换回了更新前的文件${p.localVersion===void 0?"":`(${p.localVersion.version})`}`}),children:i==="restore"?"撤销中…":"撤销上次更新"})]})]})}function h7({client:e,script:t,openSession:s}){var A,I,z;const i=_e(e.connection.status),r=_e(e.capabilities),o=vn(6e4),[l,u]=v.useState([]),[d,h]=v.useState(0),[m,p]=v.useState(!1),[g,x]=v.useState(null),[N,j]=v.useState(null),[y,k]=v.useState([]),[_,S]=v.useState(!1);v.useEffect(()=>e.connection.on("packs/changed",()=>h(D=>D+1)),[e]),v.useEffect(()=>{if(i.state!=="open"||!r.has("packs"))return;let D=!0;return e.connection.call("packs/drafts",{scriptId:t.id}).then(V=>{D&&u(V.items)}).catch(()=>{}),()=>{D=!1}},[e,t.id,i.state,r,d]),v.useEffect(()=>{if(i.state!=="open"||!r.has("packs")||t.packId===void 0){k([]);return}let D=!0;return e.connection.call("packs/history",{packId:t.packId}).then(V=>{D&&k(V.items)}).catch(()=>{D&&k([])}),()=>{D=!1}},[e,t.packId,i.state,r,d]);const E=async D=>{p(!0),x(null);try{await D()}catch(V){x($e(V))}finally{p(!1)}},O=()=>E(async()=>{const{sessionId:D}=await e.connection.call("agents/home",{agentId:"scripts",focus:{scripts:[t.id]}});await e.connection.call("session/prompt",{sessionId:D,requestId:`analyze-${Date.now()}`,mode:"queue",text:`请按 script-analysis 技能分析脚本库里的「${t.name}」(id: ${t.id}),${t.packId===void 0?"为它生成":"检查并改进它的"}脚本包:先找到并读完这个项目自己的文档(目录里的说明、仓库 README、Wiki、文档站),再结合代码核对补全,实在没有文档才直接看代码。写好给我看的使用说明(每个任务和参数是什么、每个功能怎么开启、配置文件怎么设置、运行前检查什么、常见问题),给 agent 的备注写进 SKILL.md。用 pack_propose 保存(直接生效),docs 里写明依据的文档。`}),s(D)}),P=D=>E(async()=>{const{sessionId:V}=await e.connection.call("scripts/packReview",{id:t.id,decision:D});V!==void 0&&s(V)}),H=D=>E(async()=>{const{sessionId:V}=await e.connection.call("scripts/optimize",{id:t.id,decision:D});V!==void 0&&s(V)}),B=D=>E(async()=>{S(!1),await e.connection.call("packs/restore",{packId:t.packId,version:D.id}),S(!0)}),R=D=>`${D.builtin===!0?"官方脚本包":`${vt(D.at??o,o)}被替换`} · 任务:${D.tasks.map(V=>V.title).join("、")||"无"}`,M=l[0],F=y[0],L=(A=t.optimize)==null?void 0:A.due;return n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"脚本包"}),n.jsx("p",{className:"muted small",children:t.packId===void 0?"还没有脚本包:agent 还不知道怎么运行它。":`使用脚本包 ${t.packId}。`})]}),n.jsxs("span",{className:"key-actions",children:[t.packId!==void 0&&n.jsxs("button",{className:"small-button",disabled:m||i.state!=="open",onClick:()=>void H("run"),title:"用运行攒下的信息:重新总结脚本包、调「多久没动静算卡住」、把走通的步骤存成只给它用的技能",children:[n.jsx(Q,{name:"sparkles"}),"优化脚本"]}),n.jsxs("button",{className:"small-button",disabled:m||i.state!=="open",onClick:()=>void O(),children:[n.jsx(Q,{name:"sparkles"}),t.packId===void 0?"让 agent 分析":"让 agent 改进"]})]})]}),t.packReview!==void 0&&M===void 0&&n.jsxs("div",{className:"notice left pack-review",children:[n.jsx(Q,{name:"refresh"}),n.jsxs("span",{children:[t.name," 从 ",t.packReview.from??"旧版本"," 更新到了 ",t.packReview.to,",脚本包是按旧版本写的。要让 agent 先读这次的更新日志,再检查脚本包要不要改吗?"]}),n.jsxs("span",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:m,onClick:()=>void P("keep"),children:"不用改"}),n.jsx("button",{className:"primary small-button",disabled:m||i.state!=="open",onClick:()=>void P("check"),children:"让 agent 检查"})]})]}),L!==void 0&&t.packReview===void 0&&M===void 0&&n.jsxs("div",{className:"notice left pack-review",children:[n.jsx(Q,{name:"sparkles"}),n.jsxs("span",{children:[L==="updated"?`${t.name} 更新后已经跑通了。`:`${t.name} ${((I=t.optimize)==null?void 0:I.at)===void 0?"装好以来":"上次优化以来"}已经跑成功 ${((z=t.optimize)==null?void 0:z.runs)??0} 次。`,"要让 agent 用这些运行记录优化它吗:重新总结脚本包、调卡住时间、把走通的步骤存成技能。"]}),n.jsxs("span",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:m,onClick:()=>void H("keep"),children:"这次不用"}),n.jsx("button",{className:"primary small-button",disabled:m||i.state!=="open",onClick:()=>void H("run"),children:"优化脚本"})]})]}),F!==void 0&&n.jsxs("div",{className:"pack-history",children:[n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[F.builtin===!0?"现在用的是自己写的脚本包,可以换回":"上一版脚本包:",R(F)]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:m||i.state!=="open",title:"现在用的这一版会留在历史里,可以再恢复回来",onClick:()=>void B(F),children:F.builtin===!0?"恢复官方的":"恢复上一版"})]}),y.length>1&&n.jsxs("details",{className:"draft-docs",children:[n.jsxs("summary",{className:"muted small",children:["更早的版本(",y.length-1,")"]}),n.jsx("ul",{children:y.slice(1).map(D=>n.jsxs("li",{children:[R(D)," ",n.jsx("button",{className:"link-button",disabled:m||i.state!=="open",onClick:()=>void B(D),children:"恢复"})]},D.id))})]}),_&&n.jsx("p",{className:"muted small",children:"已恢复。刚才用的那一版留在历史里,可以再恢复回来。"})]}),M!==void 0&&n.jsxs("div",{className:"draft",children:[n.jsxs("div",{className:"draft-head",children:[n.jsx("span",{className:"badge warn",children:"待确认的草稿"}),n.jsxs("span",{className:"muted small",children:[vt(M.proposedAt,o),"提交 · 任务:",M.tasks.map(D=>D.title).join("、")||"无"]})]}),n.jsx("p",{className:"draft-summary",children:M.summary}),M.docs!==void 0&&M.docs.length>0&&n.jsxs("details",{className:"draft-docs",children:[n.jsxs("summary",{className:"muted small",children:["依据的文档(",M.docs.length,")"]}),n.jsx("ul",{children:M.docs.map(D=>n.jsxs("li",{children:[n.jsx("code",{children:D.source}),":",D.used]},D.source))})]}),M.noDocs!==void 0&&n.jsxs("p",{className:"muted small",children:["没有找到项目文档,按代码分析:",M.noDocs]}),M.current!==void 0&&n.jsxs("p",{className:"muted small",children:["接受后会替换当前的",M.current.builtin?"官方":"","脚本包(之前的版本会保留在历史里)。"]}),n.jsxs("div",{className:"segmented draft-tabs",children:[n.jsxs("label",{className:N==="manifest"?"active":"",children:[n.jsx("input",{type:"checkbox",checked:N==="manifest",onChange:()=>j(D=>D==="manifest"?null:"manifest")}),"adg.script.yaml"]}),n.jsxs("label",{className:N==="skill"?"active":"",children:[n.jsx("input",{type:"checkbox",checked:N==="skill",onChange:()=>j(D=>D==="skill"?null:"skill")}),"SKILL.md"]})]}),N!==null&&n.jsx("pre",{className:"draft-text",children:N==="manifest"?M.manifest:M.skill}),n.jsxs("div",{className:"key-actions",children:[M.sessionId!==void 0&&n.jsx("button",{className:"link-button",onClick:()=>s(M.sessionId),children:"查看分析过程"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:m,onClick:()=>void E(()=>e.connection.call("packs/reject",{packId:M.packId})),children:"拒绝"}),n.jsx("button",{className:"primary small-button",disabled:m,onClick:()=>void E(()=>e.connection.call("packs/accept",{packId:M.packId})),children:"接受并使用"})]})]}),g!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:g})]})]})}function m7({client:e,script:t}){const s=_e(e.connection.status),i=vn(15e3),[r,o]=v.useState(void 0),[l,u]=v.useState(0),[d,h]=v.useState(30),[m,p]=v.useState(null);v.useEffect(()=>e.connection.on("guard/changed",()=>u(N=>N+1)),[e]),v.useEffect(()=>{if(s.state!=="open")return;let N=!0;return e.connection.call("guard/grants",{}).then(j=>{N&&o(j.items.find(y=>y.scriptId===t.id))}).catch(()=>{}),()=>{N=!1}},[e,t.id,s.state,l]);const g=r!==void 0&&r.expiresAt>i?r:void 0,x=N=>{p(null),N().catch(j=>p($e(j)))};return n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"修改脚本文件"}),n.jsx("p",{className:"muted small",children:"默认禁止:agent 只能改脚本包声明的配置文件、只能用官方更新。确实需要改代码时,在这里临时允许。"})]}),g===void 0?n.jsx("span",{className:"badge ok",children:"受保护"}):n.jsx("span",{className:"badge warn",children:"已允许"})]}),g===void 0?n.jsxs("div",{className:"key-actions",children:[n.jsxs("label",{className:"check-label",children:["允许 agent 修改",n.jsx(Mt,{inline:!0,"aria-label":"允许多久",value:String(d),onChange:N=>h(Number(N)),options:[15,30,60,120].map(N=>({value:String(N),label:`${N} 分钟`}))})]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>x(()=>e.connection.call("guard/grant",{scriptId:t.id,minutes:d})),children:"临时允许"})]}):n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:["还剩约 ",Math.max(1,Math.round((g.expiresAt-i)/6e4))," 分钟"]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"danger-outline small-button",onClick:()=>x(()=>e.connection.call("guard/revoke",{scriptId:t.id})),children:"立即收回"})]}),m!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:m})]})]})}function f7({client:e,script:t}){const s=_e(e.connection.status),i=vn(6e4),r=d1(e,t.id),[o,l]=v.useState(void 0),[u,d]=v.useState(null),[h,m]=v.useState(0),[p,g]=v.useState(null),[x,N]=v.useState(null),[j,y]=v.useState(null),[k,_]=v.useState(!1),[S,E]=v.useState(null),[O,P]=v.useState(null),[H,B]=v.useState(null),R=(r==null?void 0:r.items.find(D=>D.id===o))??(r==null?void 0:r.items.find(D=>D.id===r.current));v.useEffect(()=>{g(null),y(null)},[R==null?void 0:R.id]),v.useEffect(()=>e.connection.on("runs/state",D=>{D.scriptId!==t.id||D.endedAt===void 0||(m(V=>V+1),B(V=>V===null||V.runId!==D.id?V:(E(D.state==="succeeded"?`修改已同步到「${V.profile}」`:D.state==="cancelled"?"已放弃这次修改,本地配置没变":`没能保存修改:${D.outcome??"脚本窗口异常退出"}`),null)))}),[e,t.id]);const M=async D=>{if(H!==null){B({...H,finishing:D});try{D==="done"?await e.connection.call("configs/done",{runId:H.runId}):await e.connection.call("runs/stop",{runId:H.runId})}catch(V){P($e(V)),B(null)}}};v.useEffect(()=>{if(s.state!=="open"||R===void 0)return;let D=!0;return e.connection.call("configs/status",{scriptId:t.id,profile:R.id}).then(V=>{D&&(d(V),P(null))}).catch(V=>{D&&P($e(V))}),()=>{D=!1}},[e,t.id,t.packId,s.state,h,R==null?void 0:R.id]);const F=async D=>{_(!0),P(null),E(null);try{const V=await D();typeof V=="string"&&E(V),m(U=>U+1)}catch(V){P($e(V))}finally{_(!1)}},L=((r==null?void 0:r.items.length)??0)>1,A=R!==void 0&&R.id===(r==null?void 0:r.current),I=(u==null?void 0:u.files.filter(D=>D.local))??[],z=u!==null&&u.profile.id===(R==null?void 0:R.id)?u:null;return n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"配置"}),n.jsx("p",{className:"muted small",children:"通过本应用运行时,用的是本地保存的配置;原项目里的配置不会被改动,你自己打开脚本时仍是它原来的设置。可以存几份(比如两个账号),运行和编排时选用哪一份。"})]}),n.jsxs("button",{className:"small-button",disabled:k||H!==null||s.state!=="open"||R===void 0,onClick:()=>void F(async()=>{const D=await e.connection.call("configs/open",{scriptId:t.id,profile:R.id});if(D.endedAt===void 0)B({runId:D.id,profile:R.name,finishing:null});else if(D.state!=="succeeded")throw new Error(D.outcome??"没能打开脚本的设置界面")}),children:[n.jsx(Q,{name:"settings"}),"打开脚本修改设置"]})]}),r!==null&&(L||((u==null?void 0:u.files.length)??0)>0)&&n.jsxs("div",{className:"profile-bar",children:[n.jsxs("div",{className:"profile-chips",role:"tablist","aria-label":"配置",children:[r.items.map(D=>n.jsxs("button",{role:"tab","aria-selected":D.id===(R==null?void 0:R.id),className:`profile-chip ${D.id===(R==null?void 0:R.id)?"active":""}`,onClick:()=>l(D.id),children:[D.name,D.id===r.current&&L&&n.jsx("span",{className:"profile-current",title:"不指定配置的运行都用它",children:"当前使用"})]},D.id)),n.jsx("button",{className:"ghost small-button",disabled:k,onClick:()=>N(D=>D===null?{name:"",source:"copy",dir:""}:null),children:"+ 另存一份"})]}),R!==void 0&&L&&j===null&&n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:A?"运行时没有指定配置就用这一份":"在编排或运行时选它才会用到"}),n.jsx("span",{className:"spacer"}),!A&&n.jsx("button",{className:"small-button",disabled:k,onClick:()=>void F(async()=>(await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:R.id,current:!0}),`现在默认使用「${R.name}」`)),children:"设为当前使用"}),n.jsx("button",{className:"ghost small-button",disabled:k,onClick:()=>y(R.name),children:"改名"}),R.id!=="default"&&(p==="remove"?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"muted small",children:"用了这份配置的编排步骤会运行失败"}),n.jsx("button",{className:"small-button",onClick:()=>g(null),children:"取消"}),n.jsx("button",{className:"danger-outline small-button",disabled:k,onClick:()=>void F(async()=>(await e.connection.call("configs/profiles/remove",{scriptId:t.id,profile:R.id}),g(null),l(void 0),`已删除「${R.name}」`)),children:"确认删除"})]}):n.jsx("button",{className:"ghost small-button",disabled:k,onClick:()=>g("remove"),children:"删除"}))]}),R!==void 0&&j!==null&&n.jsxs("div",{className:"key-input",children:[n.jsx("input",{className:"text-input plain","aria-label":"新名字",value:j,maxLength:30,autoFocus:!0,onChange:D=>y(D.target.value)}),n.jsx("button",{className:"small-button",onClick:()=>y(null),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:k||j.trim()==="",onClick:()=>void F(async()=>{await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:R.id,name:j.trim()}),y(null)}),children:"保存"})]}),x!==null&&R!==void 0&&n.jsxs("div",{className:"profile-save",children:[n.jsx("label",{className:"field-label",htmlFor:"profile-name",children:"新配置的名字"}),n.jsx("input",{id:"profile-name",className:"text-input plain",placeholder:"例如:小号、只清体力",value:x.name,maxLength:30,autoFocus:!0,onChange:D=>N({...x,name:D.target.value})}),n.jsxs("fieldset",{className:"asset-list",disabled:k,children:[n.jsx("legend",{className:"field-label",children:"内容从哪里来"}),[["copy",`复制「${R.name}」`,"复制后可以「打开脚本修改设置」单独改它"],["original","读取原项目现在的配置","在脚本自己的界面里设好了另一套设置时用"],["folder","从别的文件夹读取",`另一份同样的脚本,或存下来的配置;只读 ${(u==null?void 0:u.files.map(D=>D.file).join("、"))||"脚本包声明的配置文件"}`]].map(([D,V,U])=>n.jsxs("label",{className:`asset-option choice-option ${x.source===D?"active":""}`,children:[n.jsx("input",{type:"radio",name:"profile-source",value:D,checked:x.source===D,onChange:()=>N({...x,source:D})}),n.jsxs("span",{className:"choice-text",children:[n.jsx("span",{children:V}),n.jsx("span",{className:"muted small",children:U})]})]},D))]}),x.source==="folder"&&n.jsx("input",{className:"text-input plain","aria-label":"文件夹",placeholder:"文件夹的完整路径,例如 D:\\MAA2",value:x.dir,onChange:D=>N({...x,dir:D.target.value})}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>N(null),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:k||x.name.trim()===""||x.source==="folder"&&x.dir.trim()==="",onClick:()=>void F(async()=>{const D=x.source==="copy"?{kind:"copy",profile:R.id}:x.source==="original"?{kind:"original"}:{kind:"folder",dir:x.dir.trim()},V=await e.connection.call("configs/profiles/create",{scriptId:t.id,name:x.name.trim(),from:D});return N(null),l(V.profile.id),`已保存「${V.profile.name}」:${V.files.length>0?V.files.join("、"):"还没有配置文件"}`}),children:"保存"})]})]})]}),z!==null&&n.jsxs(n.Fragment,{children:[z.drift.length>0&&n.jsxs("div",{className:"notice warn-box left",children:[n.jsx(Q,{name:"info"}),n.jsxs("span",{children:["原项目的配置在导入后改过(",z.drift.join("、"),"),可能是在脚本自己的界面里改的。本应用仍按「",z.profile.name,"」运行;需要的话可以导入。"]})]}),n.jsx(La,{id:`config.files.${t.id}`,title:"配置文件",count:z.files.length,children:n.jsxs("ul",{className:"version-list",children:[z.files.map(D=>n.jsx(p7,{client:e,scriptId:t.id,profile:z.profile.id,file:D},`${z.profile.id}:${D.file}`)),z.files.length===0&&n.jsx("li",{className:"muted small",children:"脚本包没有声明配置文件"})]})}),n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[z.importedAt===void 0?"还没有导入":`${vt(z.importedAt,i)}${L?`存的「${z.profile.name}」`:"从原项目导入"}`,I.length>0&&" · ",I.length>0&&n.jsx("button",{className:"link-button",onClick:()=>{var D;return void((D=navigator.clipboard)==null?void 0:D.writeText(z.dir))},children:"复制本地配置目录"})]}),n.jsx("span",{className:"spacer"}),p!=="import"?n.jsx("button",{className:"small-button",disabled:k,onClick:()=>g("import"),children:"导入原项目设置"}):n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"muted small",children:["会用原项目当前的配置覆盖「",z.profile.name,"」"]}),n.jsx("button",{className:"small-button",onClick:()=>g(null),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:k,onClick:()=>void F(async()=>{const D=await e.connection.call("configs/import",{scriptId:t.id,profile:z.profile.id});return g(null),D.imported.length>0?`已导入到「${z.profile.name}」:${D.imported.join("、")}`:"原项目里还没有这些配置文件"}),children:"确认导入"})]})]})]}),S!==null&&n.jsx("div",{className:"notice info left small",children:S}),H!==null&&n.jsx("div",{className:"dialog-backdrop",children:n.jsxs("div",{className:"dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"config-edit-title",children:[n.jsxs("h3",{id:"config-edit-title",children:[n.jsx(Q,{name:"settings"}),"正在用脚本自己的界面修改设置"]}),n.jsxs("p",{children:[t.name," 的设置窗口已经打开,用的是本地配置「",H.profile,"」。在那个窗口里改好、保存后,回到这里点「我已手动改好」:脚本窗口会关闭,修改同步到「",H.profile,"」,之后的运行和编排都用它。"]}),n.jsx("p",{className:"muted small",children:"直接关掉脚本窗口也会保存。原项目里的配置不会被改动。"}),H.finishing!==null&&n.jsxs("p",{className:"dialog-progress",children:[n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),H.finishing==="done"?"正在关闭脚本窗口并保存修改…":"正在关闭脚本窗口,不保存…"]}),n.jsxs("div",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:H.finishing!==null,onClick:()=>void M("discard"),children:"放弃修改"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"primary small-button",disabled:H.finishing!==null,onClick:()=>void M("done"),children:H.finishing==="done"?"保存中…":"我已手动改好"})]})]})}),O!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:O})]})]})}function p7({client:e,scriptId:t,profile:s,file:i}){const[r,o]=v.useState(!1),[l,u]=v.useState(null),[d,h]=v.useState(null),m=()=>{o(p=>!p),!(l!==null||!i.local)&&e.connection.call("configs/read",{scriptId:t,file:i.file,profile:s}).then(u,p=>h($e(p)))};return n.jsxs("li",{className:`config-file ${r?"open":""}`,children:[n.jsxs("button",{type:"button",className:"config-file-head","aria-expanded":r,onClick:m,disabled:!i.local,title:i.local?"展开看本地配置的内容":"本地还没有这个文件",children:[n.jsx(Q,{name:"chevron",className:`fold-chevron ${r?"open":""}`}),n.jsx("span",{className:"version-name",children:i.file}),i.local?n.jsx("span",{className:"badge ok",children:"本地已保存"}):n.jsx("span",{className:"badge",children:"本地没有"}),i.changed&&n.jsx("span",{className:"badge warn",children:"原项目已改动"}),!i.original&&n.jsx("span",{className:"muted small",children:"原项目里没有"})]}),r&&(d!==null?n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:d})]}):l===null?n.jsx("div",{className:"muted small",children:"读取中…"}):n.jsxs("pre",{className:"config-preview",children:[l.content,l.truncated?`
|
|
247
|
-
…(太长,只显示前一部分)`:""]}))]})}function g7({client:e,scriptId:t,scriptName:s,openSession:i}){const r=_e(e.connection.status),[o,l]=v.useState(null),[u,d]=v.useState(""),[h,m]=v.useState(""),[p,g]=v.useState(""),[x,N]=v.useState(!1),[j,y]=v.useState(null),[k,_]=v.useState(!1),[S,E]=v.useState(null),[O,P]=v.useState(!1);v.useEffect(()=>{if(r.state!=="open")return;let z=!0;return e.connection.call("configs/launch",{scriptId:t}).then(D=>{z&&(l(D),d(D.settings.pcExe??""),m(D.settings.pcProcess??""),g(D.settings.androidPackage??""))}).catch(D=>{z&&y($e(D))}),()=>{z=!1}},[e,t,r.state]);const H=async z=>{N(!0),y(null),_(!1);try{l(await e.connection.call("configs/launch/set",{scriptId:t,...z})),_(!0),"pcExe"in z&&aE()}catch(D){y($e(D))}finally{N(!1)}},B=async z=>{d(z),await H({pcExe:z})},R=async()=>{P(!0),y(null),_(!1),E(null);try{const z=await e.connection.call("configs/launch/locate",{scriptId:t});E(z),z.candidates.length===1&&await B(z.candidates[0].path)}catch(z){y($e(z))}finally{P(!1)}},M=async()=>{y(null);try{const{sessionId:z}=await e.connection.call("agents/home",{agentId:"main",focus:{scripts:[t]}});await e.connection.call("session/prompt",{sessionId:z,requestId:`locate-${Date.now()}`,mode:"queue",text:`帮我找到「${s}」(脚本 id: ${t})要玩的 PC 游戏${(o==null?void 0:o.game.name)===void 0?"":`「${o.game.name}」`}装在哪里:先用 game_locate;没找到就在各个磁盘上搜索名为 ${(S==null?void 0:S.exe)??(o==null?void 0:o.game.pcProcess)??"游戏进程名"} 的程序(可以问我装在哪个盘)。找到后告诉我路径和你怎么确认的,再用 game_path_set 保存。`}),i(z)}catch(z){y($e(z))}},F=async()=>{y(null);try{const z=await hh(e,{kind:"file",title:"选择游戏程序",defaultPath:u.trim()===""?void 0:u.trim(),filterName:"程序",extensions:["exe"]});z!==null&&await B(z)}catch(z){y($e(z))}};if(o===null)return j===null?null:n.jsx("section",{className:"card",children:n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:j})]})});const{settings:L,game:A,uses:I}=o;return!I.adb&&!I.desktop?null:n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsxs("h3",{children:["启动游戏",A.name===void 0?"":`:${A.name}`]}),n.jsxs("p",{className:"muted small",children:["有的脚本不会自己打开游戏或模拟器。运行前,本应用会先启动模拟器(模拟器任务),再按这里的设置启动游戏;游戏已经开着、或脚本自己会启动时不会重复启动。",A.selfLaunch,"。"]})]})}),n.jsx("label",{className:"field-label",htmlFor:`launch-mode-${t}`,children:"运行前由谁启动游戏"}),n.jsx(Mt,{id:`launch-mode-${t}`,value:L.mode,disabled:x,onChange:z=>void H({mode:z}),options:[{value:"auto",label:"自动(推荐)",hint:"脚本自己不会启动游戏时,由本应用启动"},{value:"platform",label:"总是由本应用启动",hint:"游戏没开时先打开它"},{value:"off",label:"不启动",hint:"交给脚本或我自己"}]}),L.mode!=="off"&&I.adb&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:`launch-pkg-${t}`,children:"模拟器里的游戏包名(模拟器任务)"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:`launch-pkg-${t}`,className:"text-input plain",value:p,onChange:z=>g(z.target.value),placeholder:A.androidPackage??"例如 com.example.game(不填就不在模拟器里启动游戏)",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:x,onClick:()=>void H({androidPackage:p.trim()===""?null:p.trim()}),children:"保存"})]}),A.androidPackage!==void 0&&n.jsxs("p",{className:"muted small",children:["默认 ",A.androidPackage,";B 服、国际服等版本的包名不同时在这里改。"]})]}),L.mode!=="off"&&I.desktop&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:`launch-exe-${t}`,children:"PC 游戏程序位置(占用鼠标键盘的任务)"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:`launch-exe-${t}`,className:"text-input",value:u,onChange:z=>d(z.target.value),placeholder:"例如 D:\\Games\\Endfield\\Endfield.exe(也可以是游戏启动器)",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:x,onClick:()=>void H({pcExe:u.trim()===""?null:u.trim().replace(/^"|"$/g,"")}),children:"保存"})]}),n.jsxs("div",{className:"button-row",children:[n.jsx("button",{className:"small-button",disabled:x||O,onClick:()=>void R(),children:O?"正在查找…":"自动查找"}),n.jsx("button",{className:"small-button",disabled:x||O,onClick:()=>void F(),children:"选择文件…"}),n.jsx("button",{className:"link-button small",disabled:O,onClick:()=>void M(),children:"让 agent 找"})]}),S!==null&&S.exe===void 0&&n.jsx("p",{className:"muted small",children:"脚本包没有写游戏的进程名:先在下面填进程名,或用「选择文件…」/ 让 agent 找。"}),S!==null&&S.exe!==void 0&&S.candidates.length===0&&n.jsxs("p",{className:"muted small",children:["没找到 ",S.exe,"(查了正在运行的程序、以前运行过的程序、Windows 搜索、已安装程序、游戏启动器记下的目录、开始菜单和桌面快捷方式、各盘的常见游戏目录)。可以「选择文件…」,或「让 agent 找」在整个磁盘上搜。"]}),S!==null&&S.candidates.length===1&&n.jsxs("p",{className:"muted small",children:["找到并保存了:",S.candidates[0].path,"(",S.candidates[0].source,")"]}),S!==null&&S.candidates.length>1&&n.jsxs("div",{className:"candidate-list",children:[n.jsxs("span",{className:"muted small",children:["找到 ",S.candidates.length," 个,选一个:"]}),S.candidates.map(z=>n.jsxs("button",{className:`candidate ${L.pcExe===z.path?"chosen":""}`,disabled:x,onClick:()=>void B(z.path),children:[n.jsx("span",{className:"mono",children:z.path}),n.jsx("span",{className:"muted small",children:z.source})]},z.path))]}),n.jsx("label",{className:"field-label",htmlFor:`launch-proc-${t}`,children:"游戏进程名(判断游戏是否已经开着)"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:`launch-proc-${t}`,className:"text-input",value:h,onChange:z=>m(z.target.value),placeholder:A.pcProcess??"默认是上面程序的文件名",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:x,onClick:()=>void H({pcProcess:h.trim()===""?null:h.trim()}),children:"保存"})]}),n.jsx("p",{className:"muted small",children:"填的是启动器时,进程名要填游戏本身的(在任务管理器「详细信息」里看)。"})]}),k&&n.jsx("div",{className:"muted small",children:"已保存,下次运行生效。"}),j!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:j})]})]})}const x7=15*6e4;function v7({client:e,script:t,openSession:s}){const i=vn(3e4),[r,o]=v.useState(!1),[l,u]=v.useState(null),d=t.summary,h=(d==null?void 0:d.state)==="running"&&i-d.at<x7,m=(d==null?void 0:d.state)==="failed"||d==null?void 0:d.text,p=async()=>{o(!0),u(null);try{await e.connection.call("scripts/summarize",{id:t.id})}catch(g){u($e(g))}finally{o(!1)}};return n.jsxs("section",{className:"card script-summary",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"简介"}),n.jsx("p",{className:"muted small",children:h?"agent 正在看它的说明和文件…":d===void 0?"让 AI 看看它的说明(README)、文件和脚本包,用几句话说清楚它是什么、能做什么。":d.state==="failed"||d.state==="running"?"上次总结没有完成":`AI 总结 · ${vt(d.at,i)}`})]}),n.jsxs("div",{className:"key-actions",children:[(d==null?void 0:d.sessionId)!==void 0&&n.jsx("button",{className:"ghost small-button",onClick:()=>s(d.sessionId),children:h?"看看进度":"查看对话"}),n.jsxs("button",{className:`${d===void 0?"primary ":""}small-button`,disabled:r||h,onClick:()=>void p(),children:[n.jsx(Q,{name:"sparkles"}),h?"总结中…":d===void 0?"让 AI 总结":"重新总结"]})]})]}),m!==void 0&&n.jsx("p",{className:`summary-text ${h?"muted":""}`,children:m}),(d==null?void 0:d.state)==="failed"&&d.text!==void 0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:d.text})]}),l!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:l})]})]})}const y7={desktop:"占用鼠标键盘",adb:"用模拟器,不占鼠标",window:"后台操作游戏窗口",none:"不占用"};function b7(e){const t=/^(\d+)(s|m|h)$/.exec(e);return t===null?e:`约 ${t[1]} ${t[2]==="s"?"秒":t[2]==="m"?"分钟":"小时"}`}function Sg({items:e}){const t=e.filter(s=>s[1]!==void 0&&s[1]!=="");return t.length===0?null:n.jsx("div",{className:"guide-facts muted small",children:t.map(([s,i])=>n.jsxs("span",{children:[s,":",i]},s))})}function k7({client:e,script:t}){const s=_e(e.connection.status),[i,r]=v.useState(void 0),[o,l]=v.useState(null),[u,d]=v.useState(0),[h,m]=v.useState("tasks");if(v.useEffect(()=>e.connection.on("packs/changed",()=>d(N=>N+1)),[e]),v.useEffect(()=>{if(s.state!=="open"||t.packId===void 0)return;let N=!0;return e.connection.call("scripts/guide",{id:t.id}).then(j=>{N&&(r(j.guide),l(null))}).catch(j=>{N&&l($e(j))}),()=>{N=!1}},[e,t.id,t.packId,s.state,u]),t.packId===void 0||i===null)return null;const g=(i===void 0?[]:[["tasks",`任务与参数(${i.tasks.length})`,!0],["features",`功能开启(${i.features.length})`,i.features.length>0],["config","配置文件",i.config.length>0],["before","运行前",i.setup.length+i.checks.length>0],["problems",`常见问题(${i.troubleshooting.length})`,i.troubleshooting.length>0]]).filter(([,,N])=>N),x=g.some(([N])=>N===h)?h:"tasks";return n.jsxs("section",{className:"card script-guide",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:"使用说明"}),n.jsx("p",{className:"muted small",children:i===void 0?"读取中…":i.written?`脚本包 ${i.packId} 的说明${i.builtin?"(官方)":""}`:"这个脚本包还没有写使用说明,下面只有任务和运行时的临时修改;可以在「脚本包」里点「让 agent 改进」补上。"})]})}),o!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:o})]}),i!==void 0&&n.jsxs(n.Fragment,{children:[i.overview!==void 0&&n.jsx("p",{className:"guide-overview",children:i.overview}),g.length>1&&n.jsx("div",{className:"segmented guide-tabs",role:"tablist",children:g.map(([N,j])=>n.jsxs("label",{className:x===N?"active":"",children:[n.jsx("input",{type:"radio",name:`guide-${t.id}`,checked:x===N,onChange:()=>m(N)}),j]},N))}),x==="tasks"&&n.jsx(j7,{guide:i}),x==="features"&&n.jsx(N7,{guide:i}),x==="config"&&n.jsx(w7,{guide:i}),x==="before"&&n.jsx(S7,{guide:i}),x==="problems"&&n.jsx(_7,{guide:i})]})]})}function j7({guide:e}){return e.tasks.length===0?n.jsx("p",{className:"muted small",children:"脚本包没有声明任务。"}):n.jsx("ul",{className:"guide-list",children:e.tasks.map(t=>n.jsxs("li",{children:[n.jsxs("div",{className:"guide-item-head",children:[n.jsx("strong",{children:t.title}),n.jsx("span",{className:"chip",children:t.id}),n.jsx("span",{className:"badge",children:y7[t.input]}),t.expectedDuration!==void 0&&n.jsx("span",{className:"muted small",children:b7(t.expectedDuration)})]}),t.description!==void 0&&n.jsx("p",{children:t.description}),t.utterances.length>0&&n.jsxs("p",{className:"muted small",children:["可以这样说:",t.utterances.map(s=>`「${s}」`).join("")]}),t.params.length===0?n.jsx("p",{className:"muted small",children:"没有参数。"}):n.jsx("dl",{className:"guide-keys",children:t.params.map(s=>n.jsxs("div",{children:[n.jsx("dt",{children:n.jsx("code",{children:s.name})}),n.jsxs("dd",{children:[n.jsx("span",{children:s.description??"(没有说明)"}),n.jsx(Sg,{items:[["可选值",s.values],["默认",s.default??(s.values===void 0?"无,运行时必须填":void 0)]]})]})]},s.name))})]},t.id))})}function N7({guide:e}){return n.jsx("ul",{className:"guide-list",children:e.features.map(t=>n.jsxs("li",{children:[n.jsxs("div",{className:"guide-item-head",children:[n.jsx("strong",{children:t.title}),t.tasks.length>0&&n.jsxs("span",{className:"muted small",children:["任务:",t.tasks.join("、")]})]}),t.description!==void 0&&n.jsx("p",{children:t.description}),n.jsxs("p",{children:[n.jsx("span",{className:"guide-label",children:"怎么开启"}),t.enable]}),t.config.length>0&&n.jsx("div",{className:"guide-facts muted small",children:t.config.map(s=>n.jsxs("span",{children:["配置:",n.jsx("code",{children:s.file})," 里 ",n.jsx("code",{children:s.key})," 设为 ",n.jsx("code",{children:s.value})]},`${s.file}:${s.key}`))})]},t.title))})}function w7({guide:e}){return n.jsx("div",{className:"guide-files",children:e.config.map(t=>n.jsxs("div",{className:"guide-file",children:[n.jsx("div",{className:"guide-item-head",children:n.jsx("code",{className:"guide-file-name",children:t.file})}),t.about!==void 0&&n.jsx("p",{children:t.about}),t.keys.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"field-label",children:"重要的键"}),n.jsx("dl",{className:"guide-keys",children:t.keys.map(s=>n.jsxs("div",{children:[n.jsx("dt",{children:n.jsx("code",{children:s.key})}),n.jsxs("dd",{children:[n.jsx("span",{children:s.meaning}),n.jsx(Sg,{items:[["取值",s.values],["默认",s.default]]}),s.advice!==void 0&&n.jsxs("span",{className:"guide-advice",children:["建议:",s.advice]})]})]},s.key))})]}),t.changes.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"field-label",children:"运行时本应用临时修改的键(只改本应用用的那份配置,运行结束后还原)"}),n.jsx("dl",{className:"guide-keys",children:t.changes.map(s=>n.jsxs("div",{children:[n.jsx("dt",{children:n.jsx("code",{children:s.key})}),n.jsxs("dd",{children:[n.jsxs("span",{children:["设为 ",n.jsx("code",{children:s.value}),s.note===void 0?"":`:${s.note}`]}),n.jsx(Sg,{items:[["条件",s.when],["任务",s.tasks.join("、")]]})]})]},`${s.key}=${s.value}:${s.when??""}`))})]})]},t.file))})}function S7({guide:e}){return n.jsxs("div",{className:"guide-before",children:[e.setup.length>0&&n.jsxs("div",{children:[n.jsx("div",{className:"field-label",children:"第一次使用前"}),n.jsx("ol",{className:"guide-steps",children:e.setup.map((t,s)=>n.jsx("li",{children:t},s))})]}),e.checks.length>0&&n.jsxs("div",{children:[n.jsx("div",{className:"field-label",children:"每次运行前检查"}),n.jsx("ul",{className:"guide-steps checks",children:e.checks.map((t,s)=>n.jsx("li",{children:t},s))})]})]})}function _7({guide:e}){return n.jsx("ul",{className:"guide-list",children:e.troubleshooting.map((t,s)=>n.jsxs("li",{children:[n.jsx("strong",{children:t.problem}),t.cause!==void 0&&n.jsxs("p",{children:[n.jsx("span",{className:"guide-label",children:"原因"}),t.cause]}),n.jsxs("p",{children:[n.jsx("span",{className:"guide-label",children:"怎么办"}),t.fix]})]},s))})}const E7={stdio:"本地程序",http:"HTTP",sse:"SSE"};function C7({client:e,script:t}){const[s,i]=v.useState(null),[r,o]=v.useState(0),[l,u]=v.useState({}),[d,h]=v.useState(null),[m,p]=v.useState(null);if(v.useEffect(()=>e.connection.on("skills/changed",()=>o(j=>j+1)),[e]),v.useEffect(()=>e.connection.on("packs/changed",()=>o(j=>j+1)),[e]),v.useEffect(()=>{let j=!0;return e.connection.call("scripts/mcp",{id:t.id}).then(y=>{j&&i(y)}).catch(()=>{j&&i(null)}),()=>{j=!1}},[e,t.id,t.current,t.packId,r]),s===null||s.servers.length===0&&s.skills.length===0)return null;const g=async j=>{u(y=>({...y,[j]:"busy"}));try{const y=await e.connection.call("scripts/mcp/probe",{id:t.id,server:j});u(k=>({...k,[j]:y})),o(k=>k+1)}catch(y){u(k=>({...k,[j]:{ok:!1,error:$e(y)}}))}},x=async j=>{h((j==null?void 0:j[0])??"*"),p(null);try{const{imported:y,skipped:k}=await e.connection.call("scripts/skills/import",{id:t.id,...j===void 0?{}:{names:j}}),_=[...y.length===0?[]:[`已放进技能库:${y.map(S=>S.name).join("、")}`],...k.map(S=>`${S.skill} 没有导入:${S.reason}`)];p({text:_.join(";")||"没有可以导入的技能",error:y.length===0}),o(S=>S+1)}catch(y){p({text:$e(y),error:!0})}finally{h(null)}},N=s.skills.filter(j=>j.problem===void 0&&(j.imported===void 0||!j.imported.current&&!j.imported.changed));return n.jsxs("section",{className:"card script-mcp",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"MCP 与技能"}),n.jsxs("p",{className:"muted small",children:[s.servers.length>0?"这个脚本自带 MCP 服务:agent 可以直接调用它的工具来操控脚本(查状态、只跑某一项、改设置),不只是运行整个任务。":"",s.skills.length>0?"它还自带给 agent 的技能,放进技能库后,处理这个脚本时 agent 就会用上。":""]})]}),N.length>1&&n.jsx("div",{className:"key-actions",children:n.jsxs("button",{className:"small-button",disabled:d!==null,onClick:()=>void x(),children:[n.jsx(Q,{name:"download"}),"全部放进技能库"]})})]}),s.servers.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("h4",{className:"muted small",children:"MCP 服务"}),n.jsx("ul",{className:"version-list",children:s.servers.map(j=>{var k,_;const y=l[j.name];return n.jsxs("li",{className:"mcp-server",children:[n.jsxs("div",{className:"mcp-server-main",children:[n.jsx("span",{className:"version-name",children:j.name}),n.jsx("span",{className:"badge",children:E7[j.transport]??j.transport}),n.jsx("span",{className:`badge ${j.source==="pack"?"ok":""}`,title:j.file===void 0?void 0:`来自脚本的 ${j.file}`,children:j.source==="pack"?"脚本包已写明用法":"从脚本配置读到"}),j.connected&&n.jsx("span",{className:"badge ok",children:"已连接"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"ghost small-button",disabled:y==="busy"||j.problem!==void 0,title:j.trusted?void 0:"会启动或连接这个服务;之后 agent 用它时不再询问",onClick:()=>void g(j.name),children:y==="busy"?"连接中…":"测试连接"})]}),n.jsx("code",{className:"muted small mcp-target",children:j.target}),j.description!==void 0&&n.jsx("p",{className:"muted small",children:j.description}),j.needsRunning&&n.jsx("p",{className:"muted small",children:"要先打开脚本(并在它的设置里开启 MCP 服务)才能连上。"}),j.problem!==void 0&&n.jsxs("div",{className:"notice warn-note left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:j.problem})]}),y!==void 0&&y!=="busy"&&(y.ok?n.jsxs("p",{className:"small",children:[y.server===void 0?"":`${y.server.name} ${y.server.version} · `,((k=y.tools)==null?void 0:k.length)??0," 个工具",(((_=y.tools)==null?void 0:_.length)??0)>0?`:${y.tools.map(S=>S.title??S.name).join("、")}`:""]}):n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:y.error})]}))]},j.name)})}),s.note!==void 0&&s.servers.length===0&&n.jsx("p",{className:"muted small",children:s.note})]}),s.skills.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("h4",{className:"muted small",children:"自带的技能"}),n.jsx("ul",{className:"version-list",children:s.skills.map(j=>n.jsxs("li",{className:"mcp-skill",children:[n.jsxs("div",{className:"mcp-server-main",children:[n.jsx("span",{className:"version-name",children:j.name}),j.imported!==void 0&&n.jsxs("span",{className:"badge ok",children:["已在技能库",j.imported.name===j.name?"":`(${j.imported.name})`]}),j.imported!==void 0&&!j.imported.current&&n.jsx("span",{className:"badge warn",title:j.imported.changed?"技能库里的这份在这里改过,不会自动替换":void 0,children:"脚本里有新版"}),n.jsx("span",{className:"spacer"}),j.problem===void 0&&(j.imported===void 0||!j.imported.current)&&n.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void x([j.path]),children:d===j.path?"导入中…":j.imported===void 0?"放进技能库":"更新"})]}),j.description!==""&&n.jsx("p",{className:"muted small",children:j.description}),n.jsx("code",{className:"muted small mcp-target",children:j.path}),j.problem!==void 0&&n.jsxs("div",{className:"notice warn-note left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:j.problem})]})]},j.path))})]}),m!==null&&n.jsxs("div",{className:`notice ${m.error?"error":""} left small`,children:[n.jsx(Q,{name:m.error?"alert":"check"}),n.jsx("span",{children:m.text})]})]})}const A7={nsis:"NSIS",inno:"Inno Setup",kachina:"Kachina"};function fE({client:e,setup:t,openSession:s,onImported:i}){const[r,o]=v.useState(t.dir),[l,u]=v.useState(!1),[d,h]=v.useState(null),[m,p]=v.useState(null),[g,x]=v.useState(!1),N=t.agent,j=async(y,k)=>{h(y),p(null);try{await k()}catch(_){p($e(_))}finally{h(null)}};return n.jsxs("section",{className:"card setup-card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsxs("h3",{children:[t.update?"更新":"安装"," ",t.name," ",t.version]}),n.jsxs("p",{className:"muted small",children:["下载到的是 ",A7[t.kind]," 安装程序,不是压缩包:要运行它把文件装好,再导入装好的文件夹。"]})]})}),(N==null?void 0:N.state)==="running"&&n.jsxs("div",{className:"notice left",children:[n.jsx(Q,{name:"info"}),n.jsx("span",{children:"agent 正在安装。也可以不等它,按下面的步骤自己装。"}),n.jsx("button",{className:"link-button",onClick:()=>s(N.sessionId),children:"查看对话"})]}),(N==null?void 0:N.state)==="failed"&&n.jsxs("div",{className:"notice warn-box left",children:[n.jsx(Q,{name:"alert"}),n.jsxs("span",{children:["agent 没能装好:",N.reason??"原因不明","。可以按下面的步骤自己装,也可以之后再交给 agent。"]}),n.jsx("button",{className:"link-button",onClick:()=>s(N.sessionId),children:"查看对话"})]}),n.jsxs("ol",{className:"setup-steps",children:[n.jsx("li",{children:n.jsxs("div",{className:"setup-step",children:[n.jsx("span",{children:"打开安装程序,按它的提示装完。安装位置已经填好,保持不变;最后不用勾选「立即运行」。"}),n.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void j("open",async()=>{await e.connection.call("scripts/setup/open",{id:t.scriptId}),u(!0)}),children:d==="open"?"正在打开…":l?"再打开一次":"打开安装程序"})]})}),n.jsx("li",{children:n.jsxs("div",{className:"setup-step",children:[n.jsxs("span",{children:["装好后导入装好的文件夹。",t.update?"":"改了安装位置的话,填你选的文件夹。"]}),n.jsxs("form",{className:"setup-import",onSubmit:y=>{y.preventDefault(),j("import",async()=>{const k=await e.connection.call("scripts/import",{path:r.trim().replace(/^"|"$/g,""),id:t.scriptId});i(k.id)})},children:[n.jsx("input",{className:"text-input plain","aria-label":"装好的文件夹",value:r,onChange:y=>o(y.target.value),spellCheck:!1,disabled:d!==null}),n.jsx("button",{className:"primary small-button",type:"submit",disabled:d!==null||r.trim()==="",children:d==="import"?"导入中…":"装好了,导入"})]})]})})]}),m!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:m})]}),n.jsx("div",{className:"key-actions",children:g?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"muted small",children:"删除下载好的安装程序,什么都不装。"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>x(!1),children:"取消"}),n.jsx("button",{className:"danger small-button",disabled:d!==null,onClick:()=>void j("discard",async()=>{await e.connection.call("scripts/setup/discard",{id:t.scriptId})}),children:"确认删除"})]}):n.jsxs(n.Fragment,{children:[(N==null?void 0:N.state)!=="running"&&n.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void j("agent",async()=>{const{sessionId:y}=await e.connection.call("scripts/setup/agent",{id:t.scriptId});s(y)}),children:d==="agent"?"正在交给 agent…":"让 agent 安装"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"danger-outline small-button",disabled:d!==null,onClick:()=>x(!0),children:"不装了"})]})})]})}const $7={ok:["ok","满足"],missing:["warn","缺少"],outdated:["warn","版本过旧"],unknown:["warn","无法判断"],unsupported:["","暂不检测"]};function I7({client:e,script:t,skillUpdates:s=[],job:i,setup:r,onRemoved:o,openSession:l}){var H;const u=vn(6e4),[d,h]=v.useState(null),[m,p]=v.useState(null),[g,x]=v.useState(null),[N,j]=v.useState(!1),[y,k]=v.useState(!1),_=i!==void 0&&(i.endedAt===void 0||i.startedAt>=t.addedAt-1e3)?i:void 0,S=Aa(_),E=_e(e.capabilities),O=t.source.kind!=="local",P=async(B,R)=>{h(B),p(null),x(null);try{const M=await R();typeof M=="string"&&x(M)}catch(M){p($e(M))}finally{h(null)}};return n.jsxs("div",{className:"script-detail",children:[n.jsx("header",{className:"script-detail-head",children:n.jsxs("div",{children:[n.jsx("h2",{children:t.name}),n.jsxs("div",{className:"script-meta",children:[n.jsx("span",{className:"chip",children:t.id}),t.family!==void 0&&n.jsx("span",{className:"badge",children:vw[t.family]??t.family}),t.packId!==void 0?n.jsxs("span",{className:"badge ok",children:["脚本包 ",t.packId]}):n.jsx("span",{className:"badge warn",children:"无脚本包"}),t.channels.mirrorchyan!==void 0&&n.jsxs("span",{className:"badge",title:"填了 Mirror酱 CDK 后从 Mirror酱 更新(增量)",children:["Mirror酱 ",t.channels.mirrorchyan.rid]}),n.jsx("span",{className:"muted small",children:t.source.kind==="github"?`GitHub · ${t.source.repo}`:t.source.kind==="mirrorchyan"?`Mirror酱 · ${t.source.rid}`:"本地导入"})]})]})}),s.length>0&&n.jsx(T7,{client:e,skills:s}),_!==void 0&&n.jsx(wg,{client:e,job:_}),r!==void 0&&n.jsx(fE,{client:e,setup:r,openSession:l,onImported:()=>{}}),t.dir!==void 0&&n.jsx(v7,{client:e,script:t,openSession:l}),t.packId!==void 0&&n.jsx(k7,{client:e,script:t},`guide:${t.id}`),t.dir!==void 0&&n.jsx(C7,{client:e,script:t},`mcp:${t.id}`),n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"位置与版本"}),n.jsx("p",{className:"muted small",children:t.dir??"(无)"})]}),t.dir!==void 0&&n.jsxs("button",{className:"ghost small-button",onClick:()=>{var B;return void((B=navigator.clipboard)==null?void 0:B.writeText(t.dir))},children:[n.jsx(Q,{name:"copy"}),"复制路径"]})]}),O?n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"version-list",children:t.versions.map(B=>{var R;return n.jsxs("li",{className:B.current?"current":"",children:[n.jsx("span",{className:"version-name",children:B.version}),B.current&&n.jsx("span",{className:"badge ok",children:"当前"}),n.jsxs("span",{className:"muted small",children:[((R=B.asset)==null?void 0:R.name)??""," · ",vt(B.installedAt,u)]}),n.jsx("span",{className:"spacer"}),!B.current&&n.jsx("button",{className:"small-button",disabled:S||d!==null,onClick:()=>void P("rollback",async()=>(await e.connection.call("scripts/rollback",{id:t.id,version:B.version}),`已切换到 ${B.version}`)),children:"切换到此版本"})]},B.version)})}),n.jsx("dl",{className:"local-facts channel-facts",children:n.jsx(mE,{client:e,script:t,disabled:S||d!==null,act:P})}),n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[t.update===void 0?"还没有检查过更新":t.update.available?`有新版本 ${t.update.latest}`:`已是最新(${t.update.latest})`,t.update!==void 0&&` · ${vt(t.update.checkedAt,u)}检查`]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:S||d!==null,onClick:()=>void P("check",async()=>{const B=await e.connection.call("scripts/checkUpdate",{id:t.id});return B.available?`发现新版本 ${B.latest}`:"已是最新版本"}),children:d==="check"?"检查中…":"检查更新"}),n.jsx("button",{className:"primary small-button",disabled:S||d!==null||((H=t.update)==null?void 0:H.available)!==!0,onClick:()=>void P("update",async()=>(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0),children:"更新"})]})]}):n.jsx(d7,{client:e,script:t,disabled:S||d!==null,busy:d,now:u,act:P})]}),n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"运行环境"}),n.jsx("p",{className:"muted small",children:t.env===void 0?t.packId===void 0?"没有脚本包,暂时不知道它需要什么":"还没有检查":`${vt(t.env.checkedAt,u)}检查`})]}),n.jsx("button",{className:"small-button",disabled:S||d!==null,onClick:()=>void P("env",async()=>(await e.connection.call("scripts/envCheck",{id:t.id})).ok?"运行环境满足":"有依赖需要处理"),children:d==="env"?"检查中…":"重新检查"})]}),t.env!==void 0&&t.env.items.length===0&&n.jsx("div",{className:"muted small",children:"脚本包没有声明额外依赖。"}),t.env!==void 0&&t.env.items.length>0&&n.jsx("ul",{className:"env-list",children:t.env.items.map(B=>{const[R,M]=$7[B.status];return n.jsxs("li",{children:[n.jsxs("div",{className:"env-main",children:[n.jsx("span",{className:"env-label",children:B.label}),n.jsx("span",{className:`badge ${R}`,children:M}),B.found!==void 0&&n.jsx("span",{className:"muted small",children:B.found})]}),B.detail!==void 0&&n.jsx("div",{className:"muted small",children:B.detail}),B.fix!==void 0&&n.jsxs("div",{className:"env-fix",children:[n.jsx("span",{className:"muted small",children:B.fix.description}),B.fix.kind!=="manual"&&n.jsx("button",{className:"small-button",disabled:S||d!==null,onClick:()=>void P(`fix-${B.kind}`,async()=>{await e.connection.call("scripts/envFix",{id:t.id,kind:B.kind})}),children:B.fix.kind==="installer"?"安装(需要管理员)":"自动修复"})]})]},B.kind)})})]}),E.has("runs")&&t.dir!==void 0&&n.jsx(H5,{client:e,scriptId:t.id,packId:t.packId}),E.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&n.jsx(f7,{client:e,script:t}),E.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&n.jsx(g7,{client:e,scriptId:t.id,scriptName:t.name,openSession:l},t.id),E.has("packs")&&n.jsx(h7,{client:e,script:t,openSession:l}),t.probe!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:"目录概况"}),n.jsx("p",{className:"muted small",children:t.packId===void 0?"只是快速看一眼;启动方式、任务和配置的完整分析请用上面的「让 agent 分析」。":"导入时快速看到的文件;脚本怎么运行以脚本包为准。"})]})}),n.jsxs("div",{className:"probe-grid",children:[n.jsx("span",{className:"field-label",children:"可执行文件"}),n.jsx("div",{className:"chip-row",children:t.probe.executables.length===0?n.jsx("span",{className:"muted small",children:"未发现"}):t.probe.executables.map(B=>n.jsx("span",{className:"chip",children:B},B))}),n.jsx("span",{className:"field-label",children:"标志文件"}),n.jsx("div",{className:"chip-row",children:t.probe.markers.length===0?n.jsx("span",{className:"muted small",children:"未发现"}):t.probe.markers.map(B=>n.jsx("span",{className:"chip",children:B},B))})]})]}),E.has("guard")&&n.jsx(m7,{client:e,script:t}),n.jsx("section",{className:"card danger-zone",children:N?n.jsxs("div",{className:"key-actions",children:[O&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:y,onChange:B=>k(B.target.checked)}),"同时删除所有已安装版本"]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>j(!1),children:"取消"}),n.jsx("button",{className:"danger small-button",disabled:d!==null,onClick:()=>void P("remove",async()=>{await e.connection.call("scripts/remove",{id:t.id,deleteFiles:O&&y}),o()}),children:"确认移除"})]}):n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[O?"从脚本库移除;可选择同时删除已安装的文件。":"从脚本库移除;你的目录不会被删除。","agent 为它写的脚本包一起删掉,从技能库下载的保留。"]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"danger-outline small-button",disabled:S,onClick:()=>j(!0),children:"移除"})]})}),g!==null&&n.jsx("div",{className:"notice info",children:g}),m!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:m})]})]})}function T7({client:e,skills:t}){const[s,i]=v.useState(!1),[r,o]=v.useState(null),l=t.map(d=>{var p,g;const h=d.title??d.name,m=d.version===void 0||d.version===((p=d.installed)==null?void 0:p.version)?"":` ${((g=d.installed)==null?void 0:g.version)??""}→${d.version}`;return`${h}${m}${d.changes===void 0?"":`(${d.changes})`}`}).join("、"),u=async()=>{i(!0),o(null);try{for(const d of t)await e.connection.call("skillhub/update",{name:d.name})}catch(d){o($e(d))}finally{i(!1)}};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"notice info left small skill-update-note",children:[n.jsx(Q,{name:"info"}),n.jsxs("span",{children:["技能有新版:",l,"。更新后 agent 下次用这个脚本就按新版做。"]}),n.jsx("span",{className:"spacer"}),n.jsx("a",{href:`#/p/skills/${encodeURIComponent(`hub:${t[0].name}`)}`,children:"在技能库查看"}),n.jsx("button",{className:"small-button",disabled:s,onClick:()=>void u(),children:s?"更新中…":"更新技能"})]}),r!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:r})]})]})}function M7({client:e,openSession:t,arg:s}){const{data:i,error:r}=ah(e),o=xw(e),l=AO(e),[u,d]=v.useState(null),[h,m]=v.useState(null);v.useEffect(()=>{(s==null?void 0:s.startsWith("mirror:"))===!0&&m({kind:"mirror",rid:s.slice(7)})},[s]);const p=(i==null?void 0:i.scripts)??[],g=((i==null?void 0:i.packs)??[]).filter(E=>!E.installed&&E.repo!==void 0&&E.error===void 0),x=((i==null?void 0:i.packs)??[]).filter(E=>E.error!==void 0),N=((i==null?void 0:i.known)??[]).filter(E=>!E.installed),j=(i==null?void 0:i.setups)??[],y=j.filter(E=>!p.some(O=>O.id===E.scriptId)),k=h===null?y.find(E=>E.scriptId===u):void 0,_=u===null||p.some(E=>E.id===u)||k!==void 0?void 0:o.get(u),S=p.find(E=>E.id===u)??(h===null&&_===void 0&&k===void 0?p[0]:void 0);return n.jsxs("section",{className:"main scripts-page",children:[n.jsxs("header",{className:"page-header",children:[n.jsxs("div",{className:"breadcrumb",children:[n.jsx("span",{children:"脚本"}),n.jsx("span",{className:"breadcrumb-divider",children:"/"}),n.jsx("h1",{children:"脚本库"})]}),n.jsxs("div",{className:"page-actions",children:[n.jsxs("button",{className:"small-button",onClick:()=>m({kind:"import"}),children:[n.jsx(Q,{name:"paperclip"}),"导入本地项目"]}),n.jsxs("button",{className:"small-button",onClick:()=>m({kind:"mirror"}),children:[n.jsx(Q,{name:"plus"}),"从 Mirror酱 安装"]}),n.jsxs("button",{className:"primary small-button",onClick:()=>m({kind:"install"}),children:[n.jsx(Q,{name:"plus"}),"从 GitHub 安装"]})]})]}),n.jsxs("div",{className:"scripts-body",children:[n.jsxs("aside",{className:"scripts-list","aria-label":"脚本列表",children:[r!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:r})]}),i===null&&r===null&&n.jsx("div",{className:"muted small pad",children:"加载中…"}),i!==null&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"sidebar-label",children:["我的脚本(",p.length,")"]}),p.length===0&&![...o.values()].some(Aa)&&n.jsxs("div",{className:"sidebar-empty",children:[n.jsx(Q,{name:"package"}),n.jsx("span",{children:"还没有脚本"}),n.jsx("span",{children:"从下面的脚本包安装,或导入已有目录"})]}),p.map(E=>{var H,B;const O=o.get(E.id),P=((H=E.env)==null?void 0:H.items.filter(R=>R.status!=="ok"&&R.status!=="unsupported").length)??0;return n.jsxs("button",{className:`script-row ${E.id===(S==null?void 0:S.id)&&h===null?"active":""}`,onClick:()=>{d(E.id),m(null)},children:[n.jsx(oE,{client:e,iconKey:`script:${E.id}:${E.current??""}`,name:E.name,className:"script-avatar",load:()=>e.connection.call("scripts/icon",{id:E.id})}),n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:E.name}),n.jsxs("span",{className:"muted small",children:[cb(E,l).length>0&&n.jsx("span",{className:"skill-update-hint",title:"这个脚本的技能在技能库里有新版",children:"技能有新版 · "}),E.source.kind==="local"?"本地":E.current??"未安装",E.family===void 0?"":` · ${vw[E.family]??E.family}`]})]}),Aa(O)?n.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):j.some(R=>R.scriptId===E.id)?n.jsx("span",{className:"badge warn",children:"待安装"}):((B=E.update)==null?void 0:B.available)===!0?n.jsx("span",{className:"badge ok",children:"可更新"}):P>0?n.jsxs("span",{className:"badge warn",children:["环境 ",P]}):null]},E.id)}),y.length>0&&n.jsxs("div",{className:"sidebar-label",children:["等待安装(",y.length,")"]}),y.map(E=>{var O,P,H;return n.jsxs("button",{className:`script-row ${E===k?"active":""}`,onClick:()=>{d(E.scriptId),m(null)},children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:E.name}),n.jsxs("span",{className:"muted small",children:[E.version," · ",((O=E.agent)==null?void 0:O.state)==="running"?"agent 正在安装":((P=E.agent)==null?void 0:P.state)==="failed"?"agent 没能装好":"安装程序已下载"]})]}),((H=E.agent)==null?void 0:H.state)==="running"?n.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):n.jsx("span",{className:"badge warn",children:"待安装"})]},E.scriptId)}),[...o.values()].filter(E=>Aa(E)&&!p.some(O=>O.id===E.scriptId)).map(E=>n.jsxs("button",{className:`script-row ${u===E.scriptId&&h===null?"active":""}`,onClick:()=>{d(E.scriptId),m(null)},children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:E.scriptId}),n.jsxs("span",{className:"muted small",children:["正在安装 · ",jc[E.phase],E.total!==void 0&&E.received!==void 0&&E.total>0?` ${Math.floor(E.received/E.total*100)}%`:""]})]}),n.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"})]},E.id)),(g.length>0||N.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-label pack-label",children:"可安装的脚本包"}),g.map(E=>n.jsxs("div",{className:"pack-row",children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:E.name}),n.jsx("span",{className:"muted small",children:E.description??E.repo})]}),n.jsx("button",{className:"small-button",onClick:()=>m({kind:"install",repo:E.repo}),children:"安装"})]},E.id)),N.map(E=>n.jsxs("div",{className:"pack-row",children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:E.name}),n.jsx("span",{className:"muted small",children:[E.mirrorchyan===void 0?void 0:`Mirror酱 ${E.mirrorchyan}`,E.repo].filter(Boolean).join(" · ")})]}),n.jsx("button",{className:"small-button",onClick:()=>m(E.mirrorchyan!==void 0?{kind:"mirror",rid:E.mirrorchyan}:{kind:"install",repo:E.repo}),children:"安装"})]},E.id))]}),x.length>0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(Q,{name:"alert"}),n.jsxs("span",{children:[x.length," 个脚本包无法读取:",x.map(E=>E.id).join("、")]})]})]})]}),n.jsxs("div",{className:"scripts-detail",children:[(h==null?void 0:h.kind)==="install"&&n.jsx(s7,{client:e,jobs:o,...h.repo===void 0?{}:{initialRepo:h.repo},onClose:()=>m(null),onDone:E=>{d(E),m(null)},openSession:t},h.repo??"blank"),(h==null?void 0:h.kind)==="mirror"&&n.jsx(i7,{client:e,jobs:o,...h.rid===void 0?{}:{initialRid:h.rid},onClose:()=>m(null),onDone:E=>{d(E),m(null)},openSession:t,onGitHub:E=>m({kind:"install",repo:E})},h.rid??"blank"),(h==null?void 0:h.kind)==="import"&&n.jsx(c7,{client:e,onClose:()=>m(null),onImported:E=>{d(E),m(null)}}),h===null&&S!==void 0&&n.jsx(I7,{client:e,script:S,skillUpdates:cb(S,l),job:o.get(S.id),setup:j.find(E=>E.scriptId===S.id),onRemoved:()=>d(null),openSession:t},S.id),k!==void 0&&n.jsx(fE,{client:e,setup:k,openSession:t,onImported:E=>d(E)},k.scriptId),h===null&&S===void 0&&_!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:_.scriptId}),n.jsx("p",{className:"muted small",children:Aa(_)?"正在安装,装好后这里显示脚本的详情":"安装没有完成"})]})}),n.jsx(wg,{client:e,job:_})]}),h===null&&S===void 0&&_===void 0&&k===void 0&&i!==null&&n.jsxs("div",{className:"empty",children:[[...o.values()].filter(E=>Aa(E)&&!p.some(O=>O.id===E.scriptId)).map(E=>n.jsxs("div",{className:"pending-install",children:[n.jsx("strong",{children:E.scriptId}),n.jsx(wg,{client:e,job:E})]},E.id)),n.jsx("p",{children:"选择左侧的脚本查看详情,或安装一个新脚本。"})]}),i!==null&&n.jsxs("p",{className:"tools-dir muted small",children:["工具目录:",i.toolsDir]})]})]})]})}const R7={id:"scripts",title:"脚本库",milestone:"M1",requires:["scripts"],pages:[{id:"scripts",title:"脚本",icon:"package",order:10,agent:"scripts",component:M7}],settingsPages:[{id:"script-install",title:"脚本安装",order:10,component:n7}]},O7={id:"emulators",title:"模拟器",milestone:"M2",requires:["emulators"],settingsPages:[{id:"emulators",title:"模拟器",order:11,component:t7}]},dp="https://github.com/haaahhhis/MultiGameAssistant";function P7({client:e}){const[t,s]=v.useState(void 0),i=eS(e),r=t===null?i===void 0?void 0:i===!1?null:i.version:null;v.useEffect(()=>{var d;const l=(d=Vs())==null?void 0:d.appInfo;if(l===void 0){s(null);return}let u=!0;return l().then(h=>{u&&s(h)},()=>{u&&s(null)}),()=>{u=!1}},[]);const o=t===void 0?"…":t===null?r===void 0?"…":r===null?"在浏览器里打开(版本见桌面版)":`${r}(dsh 插件版)`:t.fromSource?`从源码运行(${t.arch})`:`${t.version??"未知版本"}(${t.arch}${t.commit===void 0?"":` · ${t.commit}`})`;return n.jsxs("div",{className:"settings-page about-page",children:[n.jsx("h2",{children:"关于"}),n.jsx("p",{children:"MultiGameAssistant(多游戏助手):让 agent 替你管好各个游戏的日常脚本。"}),n.jsx("section",{className:"card about-card",children:n.jsxs("dl",{className:"about-facts",children:[n.jsx("dt",{children:"版本"}),n.jsx("dd",{children:o}),n.jsx("dt",{children:"源代码"}),n.jsx("dd",{children:n.jsx("a",{href:dp,target:"_blank",rel:"noreferrer",children:dp.replace("https://","")})}),n.jsx("dt",{children:"许可证"}),n.jsx("dd",{children:n.jsx("a",{href:`${dp}/blob/main/LICENSE`,target:"_blank",rel:"noreferrer",children:"GNU AGPL-3.0-only"})})]})}),(t==null?void 0:t.fromSource)===!0?n.jsxs("section",{className:"card about-card",children:[n.jsx("h3",{children:"更新"}),n.jsx("p",{className:"muted",children:"从源码运行:在项目目录 git pull 后重新构建(pnpm install、pnpm build)。"})]}):t!=null?n.jsx(L7,{}):typeof r=="string"&&n.jsx(z7,{client:e}),n.jsxs("section",{className:"card about-card",children:[n.jsx("h3",{children:"许可证"}),n.jsx("p",{children:"Copyright (C) 2026 MultiGameAssistant contributors"}),n.jsx("p",{children:"本程序是自由软件:你可以按自由软件基金会发布的 GNU Affero 通用公共许可证第 3 版(AGPL-3.0-only)再分发和修改它。分发修改后的版本,或让别人通过网络使用修改后的版本时,要以同样的许可证提供它的完整源代码。"}),n.jsx("p",{children:"发布本程序是希望它有用,但不提供任何担保,也没有适销性或特定用途适用性的默示担保。详见许可证全文。"}),n.jsx("p",{className:"muted small",children:"附带的第三方组件(Electron、DeepSeek Harness 等)遵循各自的许可证,许可证文件在程序的安装目录里。本程序安装和调度的游戏脚本是各自独立的项目,不属于本程序。"})]})]})}function L7(){const{bridge:e,state:t}=ax();if(e===void 0||t===null)return null;const s=t==null?void 0:t.latest,i=t===void 0?"…":t.checking?"正在检查…":t.error!==void 0?t.error:s!==void 0?`有新版本 ${s.version}${s.prerelease?"(预发布版)":""}${s.version===t.skipped?",已跳过":""}`:t.checkedAt!==void 0?`已经是最新版本(${new Date(t.checkedAt).toLocaleString()} 检查)`:"还没有检查过";return n.jsxs("section",{className:"card about-card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"更新"}),n.jsx("p",{className:(t==null?void 0:t.error)!==void 0&&!t.checking?"error small":"muted small",children:i})]}),n.jsxs("button",{className:"small-button",disabled:t===void 0||t.checking,onClick:()=>void e.check(),children:[n.jsx(Q,{name:"refresh"}),"检查更新"]})]}),s!==void 0&&n.jsx("div",{className:"about-release-notes",children:n.jsx(ox,{notes:s.notes??[],notesUrl:s.notesUrl})}),t!==void 0&&n.jsx(lx,{bridge:e,state:t}),t!==void 0&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:t.auto,onChange:r=>void e.setAuto(r.target.checked)}),"自动检查更新(启动后和每隔几小时,从 GitHub Releases;",/-/.test(t.current)?"预发布版也会收到更新的预发布版":"只提示正式版",")"]})]})}function z7({client:e}){var r;const t=tS(e,!0),s=(r=t.result)==null?void 0:r.latest,i=t.checking?"正在检查…":t.error!==void 0?t.error:s!==void 0?`有新版本 ${s.version}${s.prerelease?"(预发布版)":""}`:t.result!==void 0?`已经是最新版本(${new Date(t.result.checkedAt).toLocaleString()} 检查)`:"还没有检查过";return n.jsxs("section",{className:"card about-card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"更新"}),n.jsx("p",{className:t.error!==void 0&&!t.checking?"error small":"muted small",children:i})]}),n.jsxs("button",{className:"small-button",disabled:t.checking,onClick:t.check,children:[n.jsx(Q,{name:"refresh"}),"检查更新"]})]}),s!==void 0&&!t.checking&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"about-release-notes",children:n.jsx(ox,{notes:s.notes??[],notesUrl:s.notesUrl})}),n.jsx(rS,{version:s.version,onNpm:s.onNpm})]})]})}const ic=e=>e.replace(/\/+$/,""),Zj=e=>{const t=ic(e);return t.endsWith("/v1")?t.slice(0,-3):t},pE=[{id:"openai-completions",title:"OpenAI 兼容",subtitle:"Chat Completions",hint:"绝大多数第三方网关和本地服务都用这种:OneAPI / NewAPI、OpenRouter、硅基流动、vLLM、Ollama、LM Studio 等。",placeholder:"https://api.example.com/v1",requestPath:e=>`${ic(e)}/chat/completions`,listPath:e=>`${ic(e)}/models`},{id:"openai-responses",title:"OpenAI Responses",subtitle:"Responses API",hint:"OpenAI 的新一代接口,支持推理摘要等能力;仅在服务方明确支持 /responses 时使用。",placeholder:"https://api.openai.com/v1",requestPath:e=>`${ic(e)}/responses`,listPath:e=>`${ic(e)}/models`},{id:"anthropic-messages",title:"Anthropic 兼容",subtitle:"Messages API",hint:"Claude 官方接口以及兼容 Anthropic 格式的网关。地址写到域名即可,末尾的 /v1 可有可无。",placeholder:"https://api.anthropic.com",requestPath:e=>`${Zj(e)}/v1/messages`,listPath:e=>`${Zj(e)}/v1/models`}];function _g(e){return pE.find(t=>t.id===e)}function D7(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,40)}function F7(e){return`${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}_API_KEY`}const U7=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function B7(e){try{const{protocol:t}=new URL(e);return t==="http:"||t==="https:"}catch{return!1}}function $a(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)}const gE=1e6,Vl=e=>(e.contextWindow??0)>=gE;function H7({client:e,profile:t,preset:s,taken:i,revision:r,readOnly:o,onDone:l}){var ee;const u=t===void 0,d=s===void 0||s.id===""?"":i.includes(s.id)?`${s.id}-2`:s.id,[h,m]=v.useState(()=>{var J;return((J=_g((t==null?void 0:t.api)??(s==null?void 0:s.api)))==null?void 0:J.id)??"openai-completions"}),[p,g]=v.useState((t==null?void 0:t.displayName)??((s==null?void 0:s.baseURL)===""?"":(s==null?void 0:s.name)??"")),[x,N]=v.useState((t==null?void 0:t.id)??d),[j,y]=v.useState(!u||d!==""),[k,_]=v.useState((t==null?void 0:t.baseURL)??(s==null?void 0:s.baseURL)??""),[S,E]=v.useState(""),[O,P]=v.useState((t==null?void 0:t.models)??[]),[H,B]=v.useState(!1),[R,M]=v.useState(null),F=_g(h),L=k.trim(),A=L!==""&&!B7(L),I=x!==""&&!U7.test(x),z=u&&i.includes(x),D=vE(S),V=(t==null?void 0:t.apiKeyRef)??(x===""?null:F7(x)),U=((ee=t==null?void 0:t.credential)==null?void 0:ee.configured)===!0,q=(t==null?void 0:t.credential)!==void 0&&!t.credential.writable,te=x===""?"请填写标识":I?"标识格式不正确":z?"这个标识已被占用":L===""?"请填写 Base URL":A?"Base URL 需要以 http:// 或 https:// 开头":D!==null?D:O.length===0?"至少需要一个模型:点击「拉取模型列表」或手动添加":null,G=J=>{g(J),j||N(D7(J))},K=async()=>{if(te===null){B(!0),M(null);try{await e.saveProvider({id:x,create:u,...p.trim()===""?{}:{displayName:p.trim()},api:h,baseURL:L,models:[...O],...S.trim()===""?{}:{apiKey:S.trim()},expectedRevision:r}),l()}catch(J){const re=J instanceof Error?J.message:String(J);M(/SETTINGS_CONFLICT|conflict/i.test(re)?"配置在别处被修改过了,请返回列表后重试。":re)}finally{B(!1)}}},Z=H||o;return n.jsxs("form",{className:"provider-editor",onSubmit:J=>{J.preventDefault(),K()},children:[n.jsxs("div",{className:"page-head",children:[n.jsx("h3",{children:u?s!==void 0&&s.baseURL!==""?`添加 ${s.name}`:"添加模型服务":`编辑「${t.displayName}」`}),n.jsx("button",{type:"button",className:"ghost",onClick:l,disabled:H,children:"返回"})]}),n.jsxs("section",{className:"card",children:[n.jsx("h3",{className:"field-title",children:"接口模式"}),n.jsx("div",{className:"mode-grid",role:"radiogroup","aria-label":"接口模式",children:pE.map(J=>n.jsxs("button",{type:"button",role:"radio","aria-checked":h===J.id,"aria-label":`${J.title}(${J.subtitle})`,className:`mode-option${h===J.id?" selected":""}`,onClick:()=>m(J.id),disabled:Z,children:[n.jsx("span",{className:"mode-title",children:J.title}),n.jsx("span",{className:"mode-subtitle",children:J.subtitle})]},J.id))}),n.jsx("div",{className:"muted small",children:F.hint})]}),n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"field-row",children:[n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"名称"}),n.jsx("input",{className:"text-input plain",value:p,onChange:J=>G(J.target.value),placeholder:"例如:我的中转站",disabled:Z})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"标识"}),n.jsx("input",{className:"text-input",value:x,onChange:J=>{N(J.target.value.trim()),y(!0)},placeholder:"my-gateway",disabled:Z||!u,spellCheck:!1})]})]}),n.jsx("div",{className:I||z?"error small":"muted small",children:I?"标识只能用小写字母、数字和单个连字符,并以字母开头。":z?"这个标识已被占用(可能是已有的提供方或 dsh 内置提供方)。":u?"用于区分提供方,保存后不能修改。":"标识创建后不能修改。"}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"Base URL"}),n.jsx("input",{className:"text-input",value:k,onChange:J=>_(J.target.value),placeholder:F.placeholder,disabled:Z,spellCheck:!1})]}),A?n.jsx("div",{className:"error small",children:"Base URL 需要以 http:// 或 https:// 开头。"}):L!==""&&n.jsxs("div",{className:"muted small endpoint-preview",children:["对话请求 ",n.jsxs("code",{children:["POST ",F.requestPath(L)]}),n.jsx("br",{}),"模型列表 ",n.jsxs("code",{children:["GET ",F.listPath(L)]})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"API Key"}),n.jsx("input",{className:"text-input",type:"password",value:S,onChange:J=>E(J.target.value),placeholder:q?"由启动环境变量提供,无法在此修改":U?"已配置,留空则保持不变":"粘贴 Key;本地服务不需要时可留空",autoComplete:"new-password",disabled:Z||q,spellCheck:!1})]}),D!==null?n.jsx("div",{className:"error small",children:D}):V!==null&&n.jsxs("div",{className:"muted small",children:["保存在 dsh 凭据 ",n.jsx("code",{children:V})," 中,界面不会再显示 Key 的内容。",(s==null?void 0:s.keyUrl)!==void 0&&n.jsxs(n.Fragment,{children:[" ",n.jsx("a",{href:s.keyUrl,target:"_blank",rel:"noopener noreferrer",children:"获取 Key ↗"})]})]}),(s==null?void 0:s.vision)!==void 0&&n.jsxs("div",{className:"muted small",children:["截图诊断、读游戏信息需要能看图的模型:",s.vision,"。"]})]}),n.jsx(Z7,{client:e,models:O,onChange:P,probe:{...t===void 0?{}:{provider:t.id},api:h,baseURL:L,apiKey:S.trim()},probeBlocked:L===""?"先填写 Base URL":A?"Base URL 无效":D,disabled:Z}),R!==null&&n.jsx("div",{className:"banner error",children:R}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:te}),n.jsx("span",{className:"spacer"}),n.jsx("button",{type:"button",onClick:l,disabled:H,children:"取消"}),n.jsx("button",{type:"submit",className:"primary",disabled:Z||te!==null,children:H?"保存中…":u?"创建":"保存"})]})]})}function Z7({client:e,models:t,onChange:s,probe:i,probeBlocked:r,disabled:o}){const[l,u]=v.useState(null),[d,h]=v.useState(""),[m,p]=v.useState(""),[g,x]=v.useState(!1),[N,j]=v.useState(null),y=v.useRef(null),k=v.useMemo(()=>new Set(t.map(M=>M.id)),[t]),_=async()=>{var F;(F=y.current)==null||F.abort();const M=new AbortController;y.current=M,x(!0),j(null);try{const L=await e.discoverModels({...i.provider===void 0?{}:{provider:i.provider},api:i.api,baseURL:i.baseURL,...i.apiKey===""?{}:{apiKey:i.apiKey}},M.signal);if(M.signal.aborted)return;u([...L].sort((A,I)=>A.id.localeCompare(I.id))),L.length===0&&j("接口返回了空的模型列表,可以手动添加模型 ID。")}catch(L){M.signal.aborted||j(L instanceof Error?L.message:String(L))}finally{y.current===M&&(y.current=null,x(!1))}},S=M=>{s(k.has(M.id)?t.filter(F=>F.id!==M.id):[...t,M])},E=M=>{s(t.map(F=>{if(F.id!==M)return F;if(F.efforts!==void 0&&F.efforts.length>0){const{efforts:L,...A}=F;return A}return{...F,efforts:["off","low","medium","high"]}}))},O=M=>{s(t.map(F=>{var L;return F.id!==M?F:{...F,input:((L=F.input)==null?void 0:L.includes("image"))===!0?["text"]:["text","image"]}}))},P=M=>{s(t.map(F=>{if(F.id!==M)return F;if(Vl(F)){const{contextWindow:L,...A}=F;return A}return{...F,contextWindow:gE}}))},H=v.useMemo(()=>{const M=d.trim().toLowerCase();return(l??[]).filter(F=>M===""||F.id.toLowerCase().includes(M)||(F.name??"").toLowerCase().includes(M))},[l,d]),B=M=>{if(M){const F=H.filter(L=>!k.has(L.id));s([...t,...F])}else{const F=new Set(H.map(L=>L.id));s(t.filter(L=>!F.has(L.id)))}},R=()=>{const M=m.split(/[\s,,]+/).map(F=>F.trim()).filter(F=>F!==""&&!k.has(F));M.length!==0&&(s([...t,...M.map(F=>(l==null?void 0:l.find(L=>L.id===F))??{id:F})]),p(""))};return n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"模型"}),n.jsxs("div",{className:"muted small",children:["已选 ",t.length," 个。只有选中的模型会出现在模型选择器里。能看图的模型点亮「图片」,否则 dsh 会拒绝发送图片;支持调思考强度的模型(如 GPT-5、o 系列、Claude、DeepSeek R 系列)点亮「思考」,对话里就能选强度;支持 1M 上下文的模型(如 gpt-4.1、Gemini)点亮「1M」,对话按 1M 计算、快满才压缩,模型本身不支持时别点亮,否则对话会超长出错。"]})]}),n.jsx("button",{type:"button",onClick:()=>void _(),disabled:o||g||r!==null,title:r??void 0,children:g?"拉取中…":l===null?"拉取模型列表":"重新拉取"})]}),N!==null&&n.jsx("div",{className:"error small",children:N}),t.length>0&&n.jsx("div",{className:"model-chips",children:t.map(M=>{var F,L,A,I,z,D;return n.jsxs("span",{className:"chip removable",children:[M.id,!Vl(M)&&$a(M.contextWindow)!==null&&n.jsxs("span",{className:"muted",children:[" · ",$a(M.contextWindow)]}),n.jsx("button",{type:"button",className:`chip-flag${((F=M.input)==null?void 0:F.includes("image"))===!0?" on":""}`,onClick:()=>O(M.id),disabled:o,"aria-pressed":((L=M.input)==null?void 0:L.includes("image"))===!0,title:((A=M.input)==null?void 0:A.includes("image"))===!0?"支持图片输入(点击关闭)":"不支持图片输入(点击开启)",children:"图片"}),n.jsx("button",{type:"button",className:`chip-flag${(((I=M.efforts)==null?void 0:I.length)??0)>0?" on":""}`,onClick:()=>E(M.id),disabled:o,"aria-pressed":(((z=M.efforts)==null?void 0:z.length)??0)>0,title:(((D=M.efforts)==null?void 0:D.length)??0)>0?`可选思考强度:${M.efforts.join(" / ")}(点击关闭)`:"没有声明思考强度(点击开启:不思考 / 低 / 中 / 高)",children:"思考"}),n.jsx("button",{type:"button",className:`chip-flag${Vl(M)?" on":""}`,onClick:()=>P(M.id),disabled:o,"aria-pressed":Vl(M),title:Vl(M)?"按 1M 上下文计算,快满时才压缩(点击关闭)":M.contextWindow!==void 0?`上下文 ${$a(M.contextWindow)}(点击改为 1M)`:"上下文大小未知,dsh 默认按 1M 计算(点击写明 1M)",children:"1M"}),n.jsx("button",{type:"button",className:"chip-x",onClick:()=>s(t.filter(V=>V.id!==M.id)),disabled:o,"aria-label":`移除 ${M.id}`,children:"×"})]},M.id)})}),l!==null&&l.length>0&&n.jsxs("div",{className:"candidates",children:[n.jsxs("div",{className:"candidates-bar",children:[n.jsx("input",{className:"text-input plain",value:d,onChange:M=>h(M.target.value),placeholder:`搜索 ${l.length} 个模型`}),n.jsxs("button",{type:"button",className:"small-button",onClick:()=>B(!0),disabled:o,children:["全选",d!==""?"筛选结果":""]}),n.jsx("button",{type:"button",className:"small-button",onClick:()=>B(!1),disabled:o,children:"全不选"})]}),n.jsxs("ul",{className:"candidate-list",children:[H.map(M=>{var F;return n.jsx("li",{children:n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:k.has(M.id),onChange:()=>S(M),disabled:o}),n.jsx("span",{className:"mono",children:M.id}),M.name!==void 0&&n.jsxs("span",{className:"muted",children:[" ",M.name]}),n.jsx("span",{className:"spacer"}),((F=M.input)==null?void 0:F.includes("image"))===!0&&n.jsx("span",{className:"badge",children:"图像"}),$a(M.contextWindow)!==null&&n.jsxs("span",{className:"muted small",children:[$a(M.contextWindow)," 上下文"]})]})},M.id)}),H.length===0&&n.jsx("li",{className:"muted small",children:"没有匹配的模型。"})]})]}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{className:"text-input plain-mono",value:m,onChange:M=>p(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),R())},placeholder:"手动添加模型 ID,多个用空格或逗号分隔",disabled:o,spellCheck:!1}),n.jsx("button",{type:"button",onClick:R,disabled:o||m.trim()==="",children:"添加"})]})]})}const W7=[{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:""}],hp=[{id:"deepseek-official",name:"DeepSeek",note:"内置,只需要填 Key",keyRef:$p,keyUrl:"https://platform.deepseek.com/api_keys"}];function V7({client:e}){const{catalog:t}=aa(e),[s,i]=v.useState(!1),[r,o]=v.useState(void 0),l=_e(e.providersRevision),u=_e(e.credentialRevision),d=_e(e.connection.status),[h,m]=v.useState(null),[p,g]=v.useState(null),[x,N]=v.useState(null),[j,y]=v.useState(null),k=v.useCallback(()=>{e.listProviders().then(S=>{m(S),g(null)}).catch(S=>g(S instanceof Error?S.message:String(S)))},[e]);if(v.useEffect(()=>{d.state==="open"&&k()},[k,l,u,d.state]),x!==null&&h!==null){const S=x==="new"?void 0:h.providers.find(E=>E.id===x);return n.jsx("section",{className:"providers-section",children:n.jsx(H7,{client:e,profile:S,preset:x==="new"?r:void 0,taken:h.taken,revision:h.revision,readOnly:!h.writable,onDone:()=>{N(null),o(void 0),k()}},x)})}if(s)return n.jsxs("section",{className:"providers-section",children:[n.jsxs("div",{className:"page-head",children:[n.jsx("h3",{children:"添加模型服务"}),n.jsx("button",{className:"ghost",onClick:()=>i(!1),children:"返回"})]}),n.jsxs("div",{className:"preset-grid",children:[hp.map(S=>n.jsxs("button",{className:"preset-option",onClick:()=>{var E;i(!1),(E=document.getElementById(`builtin-${S.id}`))==null||E.scrollIntoView({behavior:"smooth"})},children:[n.jsx("span",{className:"mode-title",children:S.name}),n.jsx("span",{className:"mode-subtitle",children:S.note})]},S.id)),W7.map(S=>n.jsxs("button",{className:"preset-option",disabled:h===null||!h.writable,onClick:()=>{o(S),i(!1),N("new")},children:[n.jsx("span",{className:"mode-title",children:S.name}),n.jsx("span",{className:"mode-subtitle",children:S.note})]},S.key))]})]});const _=new Set((h==null?void 0:h.providers.map(S=>S.id))??[]);return n.jsxs("section",{className:"providers-section",children:[n.jsxs("div",{className:"page-head",children:[n.jsx("h3",{children:"模型服务"}),n.jsx("button",{className:"primary",onClick:()=>i(!0),disabled:h===null,children:"+ 添加模型服务"})]}),n.jsx("p",{className:"muted",children:"每个服务填一次 Key,它的模型就会出现在输入框旁的模型选择器里。Claude、ChatGPT、Gemini、国内各家和本机的 Ollama 都可以接;需要看截图的功能请选能看图的模型。Key 保存在本机 dsh 的凭据文件里,界面不会再显示。"}),hp.map(S=>n.jsx(K7,{client:e,provider:S,catalog:t},S.id)),t==null?void 0:t.groups.filter(S=>!_.has(S.id)&&!hp.some(E=>E.id===S.id)).map(S=>n.jsxs("section",{className:"card provider-card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{className:"provider-title",children:[n.jsx("h3",{children:S.name}),n.jsx("div",{className:"muted small",children:n.jsx("code",{children:S.id})})]}),n.jsx("span",{className:"badge",children:"内置"})]}),n.jsx("div",{className:"model-chips",children:S.models.map(E=>n.jsx("span",{className:"chip",children:E.name},E.id))})]},S.id)),p!==null&&n.jsx("div",{className:"banner error",children:p}),j!==null&&n.jsx("div",{className:"success small",children:j}),h!==null&&!h.writable&&n.jsx("div",{className:"notice info left",children:"当前 profile 是只读的,无法在界面中修改提供方。"}),h===null&&p===null&&n.jsx("div",{className:"muted small",children:"读取中…"}),h==null?void 0:h.providers.map(S=>n.jsx(q7,{client:e,profile:S,revision:h.revision,readOnly:!h.writable,onEdit:()=>N(S.id),onRemoved:E=>{y(E?"已删除。它原本是新会话的默认模型,默认模型已恢复为 profile 自带的设置。":null),k()}},S.id))]})}function q7({client:e,profile:t,revision:s,readOnly:i,onEdit:r,onRemoved:o}){const[l,u]=v.useState(!1),[d,h]=v.useState(null),m=_g(t.api),p=async()=>{var x,N;const g=t.apiKeyRef!==void 0&&((x=t.credential)==null?void 0:x.source)==="file"?`
|
|
248
|
-
|
|
249
|
-
同时删除已保存的 Key(${t.apiKeyRef})。`:"";if(await Ms({title:`删除「${t.displayName}」?`,message:`使用它的会话需要换一个模型。${g}`,confirmLabel:"删除",danger:!0})){u(!0),h(null);try{const{defaultReset:j}=await e.removeProvider({id:t.id,removeKey:((N=t.credential)==null?void 0:N.source)==="file",expectedRevision:s});o(j)}catch(j){h(j instanceof Error?j.message:String(j))}finally{u(!1)}}};return n.jsxs("section",{className:"card provider-card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{className:"provider-title",children:[n.jsx("h3",{children:t.displayName}),n.jsxs("div",{className:"muted small",children:[n.jsx("code",{children:t.id}),t.baseURL!==void 0&&n.jsxs(n.Fragment,{children:[" · ",n.jsx("span",{className:"mono",children:t.baseURL})]})]})]}),n.jsxs("div",{className:"badges",children:[n.jsx("span",{className:"badge",children:m===void 0?t.api??"内置目录":`${m.title} · ${m.subtitle}`}),n.jsx(G7,{profile:t}),t.active?n.jsx("span",{className:"badge ok",children:"已生效"}):n.jsx("span",{className:"badge warn",title:t.error,children:"未生效"})]})]}),t.error!==void 0&&n.jsx("div",{className:"error small",children:t.error}),t.models.length>0?n.jsx("div",{className:"model-chips",children:t.models.map(g=>n.jsxs("span",{className:"chip",title:g.name??g.id,children:[g.id,$a(g.contextWindow)!==null&&n.jsxs("span",{className:"muted",children:[" · ",$a(g.contextWindow)]})]},g.id))}):n.jsx("div",{className:"muted small",children:"使用 dsh 内置的模型目录。"}),d!==null&&n.jsx("div",{className:"error small",children:d}),n.jsxs("div",{className:"key-actions",children:[!t.declared&&n.jsx("span",{className:"muted small",children:"这是 dsh 内置提供方的配置,请在 dsh 官方模型页面编辑。"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"danger-outline",onClick:()=>void p(),disabled:l||i,children:"删除"}),t.declared&&n.jsx("button",{onClick:r,disabled:l||i,children:"编辑"})]})]})}function G7({profile:e}){return e.apiKeyRef===void 0?n.jsx("span",{className:"badge",children:"无 Key"}):e.credential===void 0?n.jsxs("span",{className:"badge",children:["Key:",e.apiKeyRef]}):e.credential.configured?n.jsx("span",{className:"badge ok",title:e.apiKeyRef,children:"Key 已配置"}):n.jsx("span",{className:"badge warn",title:e.apiKeyRef,children:"Key 未配置"})}function K7({client:e,provider:t,catalog:s}){const{items:i}=gw(e,[t.keyRef]),r=(i==null?void 0:i[t.keyRef])??null,o=s==null?void 0:s.groups.find(u=>u.id===t.id),l=s==null?void 0:s.failures.find(u=>u.id===t.id);return n.jsxs("section",{className:"card provider-card",id:`builtin-${t.id}`,children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{className:"provider-title",children:[n.jsx("h3",{children:t.name}),n.jsxs("div",{className:"muted small",children:[n.jsx("code",{children:t.id})," · ",t.note]})]}),n.jsxs("div",{className:"badges",children:[n.jsx("span",{className:"badge",children:"内置"}),r===null?null:r.configured?n.jsx("span",{className:"badge ok",children:"Key 已配置"}):n.jsx("span",{className:"badge warn",children:"Key 未配置"})]})]}),o!==void 0&&o.models.length>0&&n.jsx("div",{className:"model-chips",children:o.models.map(u=>n.jsx("span",{className:"chip",title:u.description,children:u.name},u.id))}),l!==void 0&&n.jsx("div",{className:"error small",children:l.message}),n.jsx(sZ,{client:e,refName:t.keyRef,title:`${t.name} API Key`,description:"",helpUrl:t.keyUrl,info:r,bare:!0})]})}const gc="",rc=e=>e==null?gc:`${e.provider}/${e.model}`;function Wj(e){if(e===gc)return null;const[t,...s]=e.split("/");return{provider:t,model:s.join("/")}}function ql(e,t){var s,i;return((i=(s=e.groups.find(r=>r.id===t.provider))==null?void 0:s.models.find(r=>r.id===t.model))==null?void 0:i.name)??t.model}function fd(e,t){return[...t==null||e.groups.some(i=>i.id===t.provider&&i.models.some(r=>r.id===t.model))?[]:[{value:rc(t),label:`${t.provider} / ${t.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...e.groups.flatMap(i=>i.models.map(r=>({value:`${i.id}/${r.id}`,label:r.name,group:i.name})))]}function Y7({client:e}){const{catalog:t,error:s}=aa(e),i=_e(e.capabilities),r=_e(e.connection.status),o=$i(e),[l,u]=v.useState(null),[d,h]=v.useState(!1),[m,p]=v.useState(null),g=i.has("agent-models");v.useEffect(()=>{if(r.state!=="open"||!g)return;let _=!0;return e.connection.call("models/agentModels",{}).then(S=>{_&&u(S)}).catch(()=>{}),()=>{_=!1}},[e,r.state,g]),v.useEffect(()=>e.connection.on("models/agentModelsChanged",u),[e]);const x=async _=>{h(!0),p(null);try{p(await _())}catch(S){p({tone:"warn",text:S instanceof Error?S.message:String(S)})}finally{h(!1)}},N=_=>void x(async()=>{const S=Wj(_);return await e.connection.call("models/setDefault",S),{tone:"ok",text:`默认模型换成了 ${ql(t,S)}:助手和跟随默认的 agent 从下一句起用它。`}}),j=(_,S,E)=>void x(async()=>{const O=Wj(E),{warning:P}=await e.connection.call("models/setAgentModel",{..._===void 0?{}:{agentId:_.id},...S?{sub:!0}:{},model:O});if(u(R=>R===null?R:X7(R,_==null?void 0:_.id,S,O)),P!==void 0)return{tone:"warn",text:P};const H=O===null?void 0:ql(t,O);if(!S)return{tone:"ok",text:H===void 0?`「${_.name}」改回跟随默认模型,从下一句起生效。`:`「${_.name}」的对话从下一句起用 ${H}。`};const B=_===void 0?"没单独设的子 agent":`「${_.name}」新开的子 agent`;return{tone:"ok",text:H===void 0?`${B}改回跟随,正在干活的不受影响。`:`${B}用 ${H},正在干活的不受影响。`}}),y=[cn,...o.map(Ka)],k=t!==null&&(l!==null||!g);return n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:"每个 agent 用的模型"}),n.jsx("p",{className:"muted small",children:"「对话」是 agent 自己做判断、和你说话用的模型;「子 agent」是它派去干具体活(运行命令、截图点击、装脚本)用的模型,活多、看图多,可以选便宜些、能看图的。 没单独设的会跟着上一级:agent 跟默认模型,子 agent 跟「所有子 agent」,那里也没设就和开它的 agent 用同一个。先在下面的模型服务里填好 Key,这里才能选它的模型。"})]})}),s!==null&&n.jsx("div",{className:"error small",children:s}),!k&&s===null&&n.jsx("div",{className:"muted small",children:"读取中…"}),k&&n.jsxs("div",{className:"agent-models",role:"table","aria-label":"每个 agent 用的模型",children:[n.jsxs("div",{className:"agent-models-row head",role:"row",children:[n.jsx("span",{role:"columnheader",children:"agent"}),n.jsx("span",{role:"columnheader",children:"对话"}),g&&n.jsx("span",{role:"columnheader",children:"子 agent"})]}),g&&n.jsxs("div",{className:"agent-models-row all",role:"row",children:[n.jsxs("div",{className:"agent-models-name",role:"cell",children:[n.jsx("strong",{children:"所有子 agent"}),n.jsx("span",{className:"muted small",children:"下面没单独设子 agent 模型的,都用这个"})]}),n.jsx("div",{className:"agent-models-cell empty",role:"cell"}),n.jsxs("div",{className:"agent-models-cell",role:"cell",children:[n.jsx("span",{className:"agent-models-cell-label",children:"子 agent"}),n.jsx(Mt,{"aria-label":"所有子 agent 的模型",value:rc(l.subAgents),disabled:d,onChange:_=>j(void 0,!0,_),options:[{value:gc,label:"和开它的 agent 一样"},...fd(t,l.subAgents)]})]})]}),y.map(_=>{const S=_.id===cn.id,E=S?t.default:(l==null?void 0:l.agents[_.id])??null,O=E??t.default,P=(l==null?void 0:l.subAgentsOf[_.id])??null,H=(l==null?void 0:l.subAgents)==null?`和${_.name}一样(${ql(t,O)})`:`跟随上面(${ql(t,l.subAgents)})`;return n.jsxs("div",{className:"agent-models-row",role:"row",children:[n.jsxs("div",{className:"agent-models-name",role:"cell",children:[n.jsx("strong",{children:_.name}),n.jsx("span",{className:"muted small",children:S?"它用的就是默认模型":_.description})]}),n.jsxs("div",{className:"agent-models-cell",role:"cell",children:[n.jsx("span",{className:"agent-models-cell-label",children:"对话"}),S?n.jsx(Mt,{"aria-label":"默认模型(助手)",value:rc(E),disabled:d||!i.has("model-default"),onChange:N,options:fd(t,E)}):n.jsx(Mt,{"aria-label":`${_.name}的模型`,value:rc(E),disabled:d||!g,onChange:B=>j(_,!1,B),options:[{value:gc,label:`跟随默认(${ql(t,t.default)})`},...fd(t,E)]})]}),g&&n.jsxs("div",{className:"agent-models-cell",role:"cell",children:[n.jsx("span",{className:"agent-models-cell-label",children:"子 agent"}),n.jsx(Mt,{"aria-label":`${_.name}的子 agent 的模型`,value:rc(P),disabled:d,onChange:B=>j(_,!0,B),options:[{value:gc,label:H},...fd(t,P)]})]})]},_.id)})]}),t==null?void 0:t.failures.map(_=>n.jsxs("div",{className:"error small",children:[_.name,":",_.message]},_.id)),m!==null&&n.jsx("div",{className:m.tone==="ok"?"muted small":"error small",children:m.text})]})}function X7(e,t,s,i){const r=(o,l)=>{const{[l]:u,...d}=o;return i===null?d:{...d,[l]:i}};return s?t===void 0?{...e,subAgents:i}:{...e,subAgentsOf:r(e.subAgentsOf,t)}:{...e,agents:r(e.agents,t)}}const Vj=e=>`${e.provider}/${e.model}`;function Q7(e){const[t,...s]=e.split("/");return{provider:t,model:s.join("/")}}function J7(e,t){const s=e.groups.find(r=>r.id===t.provider),i=s==null?void 0:s.models.find(r=>r.id===t.model);return{service:(s==null?void 0:s.name)??t.provider,model:(i==null?void 0:i.name)??t.model,missing:i===void 0}}const eZ=[{sub:!1,key:"agents",title:"agent 的对话",hint:"助手和各个 agent 自己的对话"},{sub:!0,key:"subAgents",title:"子 agent",hint:"派去干具体活的子 agent"}];function tZ({client:e}){const{catalog:t}=aa(e),s=_e(e.connection.status),[i,r]=v.useState(null),[o,l]=v.useState(!1),[u,d]=v.useState(null);if(v.useEffect(()=>{if(s.state!=="open")return;let m=!0;return e.connection.call("models/agentModels",{}).then(p=>{m&&r(p.fallbacks??null)}).catch(()=>{}),()=>{m=!1}},[e,s.state]),v.useEffect(()=>e.connection.on("models/agentModelsChanged",m=>r(m.fallbacks??null)),[e]),i===null||t===null)return null;const h=async(m,p)=>{l(!0),d(null);const g=i;r({...i,[m?"subAgents":"agents"]:p});try{await e.connection.call("models/setFallbacks",{sub:m,models:p})}catch(x){r(g),d(x instanceof Error?x.message:String(x))}finally{l(!1)}};return n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:"备用模型"}),n.jsx("p",{className:"muted small",children:"模型报错用不了时(余额不足、Key 失效、模型下线、请求重试后仍超时或服务出错),agent 自动换成下面的下一个模型接着做,对话里会出现一张卡片,写明换到了哪个服务的哪个模型、因为什么;agent 自己也看得到这张卡片。 按顺序从出错的那个往下试,试过的不再试;网络断了、对话太长这类换模型也没用的错误不会切换。"})]})}),n.jsx("div",{className:"fallback-lists",children:eZ.map(({sub:m,key:p,title:g,hint:x})=>{const N=i[p],j=new Set(N.map(Vj)),y=t.groups.flatMap(_=>_.models.filter(S=>!j.has(`${_.id}/${S.id}`)).map(S=>({value:`${_.id}/${S.id}`,label:S.name,group:_.name}))),k=(_,S)=>{const E=[...N],[O]=E.splice(_,1);E.splice(S,0,O),h(m,E)};return n.jsxs("div",{className:"fallback-list",children:[n.jsxs("div",{className:"fallback-list-head",children:[n.jsx("strong",{children:g}),n.jsx("span",{className:"muted small",children:x})]}),N.length===0?n.jsx("div",{className:"muted small fallback-empty",children:"没有备用模型:出错就停下,等你处理。"}):n.jsx("ol",{children:N.map((_,S)=>{const E=J7(t,_);return n.jsxs("li",{className:E.missing?"missing":void 0,children:[n.jsx("span",{className:"fallback-order",children:S+1}),n.jsxs("span",{className:"fallback-name",children:[n.jsx("span",{children:E.model}),n.jsx("span",{className:"muted small",children:E.missing?"不可用:这个模型服务没有配好,会跳过":E.service})]}),n.jsxs("span",{className:"fallback-actions",children:[n.jsx("button",{className:"icon-button","aria-label":`把 ${E.model} 往前移`,title:"往前移",disabled:o||S===0,onClick:()=>k(S,S-1),children:n.jsx(Q,{name:"arrow"})}),n.jsx("button",{className:"icon-button down","aria-label":`把 ${E.model} 往后移`,title:"往后移",disabled:o||S===N.length-1,onClick:()=>k(S,S+1),children:n.jsx(Q,{name:"arrow"})}),n.jsx("button",{className:"icon-button","aria-label":`去掉 ${E.model}`,title:"去掉",disabled:o,onClick:()=>void h(m,N.filter((O,P)=>P!==S)),children:n.jsx(Q,{name:"close"})})]})]},Vj(_))})}),n.jsx(Mt,{"aria-label":`给${g}添加备用模型`,value:"",placeholder:y.length===0?"没有可以添加的模型":"添加备用模型…",disabled:o||y.length===0,options:y,onChange:_=>void h(m,[...N,Q7(_)])})]},p)})}),u!==null&&n.jsx("div",{className:"error small",children:u})]})}const xE={file:"dsh 凭据文件",env:"启动环境变量","project-env":"项目 .env 文件","user-env":"dsh 主目录 .env 文件"};function vE(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 nZ({client:e}){const t=_e(e.capabilities);return n.jsxs("div",{className:"settings-page",children:[n.jsx("h2",{children:"模型"}),n.jsx("p",{className:"muted",children:"agent 用哪个模型、接哪些模型服务都在这里。改了立即生效:agent 的对话从下一句起换过去,子 agent 在新开时用上。只想换一个对话的模型,在它输入框旁边换就行,不会改这里的设置。"}),n.jsx(Y7,{client:e}),t.has("agent-models")&&n.jsx(tZ,{client:e}),t.has("providers")&&n.jsx(V7,{client:e})]})}function sZ({client:e,refName:t,title:s,description:i,helpUrl:r,info:o,placeholder:l,bare:u=!1}){const[d,h]=v.useState(""),[m,p]=v.useState(!1),[g,x]=v.useState(!1),[N,j]=v.useState(null),y=vE(d),k=o!==null&&!o.writable,_=async()=>{if(!(d.trim()===""||y!==null)){x(!0),j(null);try{await e.setCredential(t,d.trim()),h(""),p(!1),j({tone:"ok",text:"已保存,立即生效。"})}catch(O){j({tone:"error",text:O instanceof Error?O.message:String(O)})}finally{x(!1)}}},S=async()=>{if(await Ms({title:`删除已保存的 ${s}?`,message:"删除后需要重新填写才能使用对应模型。",confirmLabel:"删除",danger:!0})){x(!0),j(null);try{await e.unsetCredential(t),j({tone:"ok",text:"已删除。"})}catch(O){j({tone:"error",text:O instanceof Error?O.message:String(O)})}finally{x(!1)}}},E=u?"div":"section";return n.jsxs(E,{className:u?"credential-inline":"card",children:[!u&&n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:s}),n.jsxs("div",{className:"muted small",children:[i," ",n.jsx("code",{children:t})]})]}),n.jsx(iZ,{info:o})]}),k?n.jsxs("div",{className:"notice info left",children:["当前 Key 来自",xE[o.source??""]??o.source,",优先级高于界面保存的值,因此这里无法修改。 如需在界面中管理,请先从启动 dsh 的环境中移除 ",n.jsx("code",{children:t})," 再重新启动。"]}):n.jsxs("form",{className:"key-form",onSubmit:O=>{O.preventDefault(),_()},children:[n.jsxs("div",{className:"key-input",children:[n.jsx("input",{type:m?"text":"password",value:d,onChange:O=>{h(O.target.value),j(null)},placeholder:(o==null?void 0:o.configured)===!0?"已配置。输入新的 Key 可替换":l??"粘贴你的 API Key(sk-…)",autoComplete:"off",spellCheck:!1,"aria-label":s,disabled:g}),n.jsx("button",{type:"button",className:"ghost",onClick:()=>p(O=>!O),disabled:d==="",children:m?"隐藏":"显示"})]}),y!==null&&n.jsx("div",{className:"error small",children:y}),n.jsxs("div",{className:"key-actions",children:[r!==void 0&&n.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"small",children:"获取 API Key ↗"}),n.jsx("span",{className:"spacer"}),(o==null?void 0:o.configured)===!0&&o.source==="file"&&n.jsx("button",{type:"button",className:"danger-outline",onClick:()=>void S(),disabled:g,children:"删除"}),n.jsx("button",{type:"submit",className:"primary",disabled:g||d.trim()===""||y!==null,children:g?"保存中…":(o==null?void 0:o.configured)===!0?"替换":"保存"})]})]}),N!==null&&n.jsx("div",{className:N.tone==="ok"?"success small":"error small",children:N.text})]})}function iZ({info:e}){return e===null?n.jsx("span",{className:"badge",children:"读取中…"}):e.configured?n.jsxs("span",{className:"badge ok",children:["已配置 · ",xE[e.source??""]??e.source??"未知来源"]}):n.jsx("span",{className:"badge warn",children:"未配置"})}const rZ=(e,t)=>e===null||t===null?e===t:e.provider===t.provider&&e.model===t.model,aZ=(e,t)=>e.auto===t.auto&&e.threshold===t.threshold&&rZ(e.summarizer,t.summarizer),Eg="\0",qj=e=>e===null?"":`${e.provider}${Eg}${e.model}`;function oZ({client:e}){var k;const t=_e(e.connection.status),[s,i]=v.useState(null),[r,o]=v.useState(null),[l,u]=v.useState(!1),[d,h]=v.useState(null),m=(k=Vs())==null?void 0:k.restartService,{catalog:p}=aa(e),g=_=>{if(_===null)return"对话自己的模型";const S=p==null?void 0:p.groups.find(O=>O.id===_.provider),E=S==null?void 0:S.models.find(O=>O.id===_.model);return E===void 0?`${_.provider} / ${_.model}`:`${S.name} · ${E.name}`};v.useEffect(()=>{if(d===null||s===null)return;if(d===s.settings.threshold){h(null);return}const _=setTimeout(()=>void x({...s.settings,threshold:d}).then(()=>h(null)),400);return()=>clearTimeout(_)},[d,s]),v.useEffect(()=>{if(t.state!=="open")return;let _=!0;return e.connection.call("compaction/get",{}).then(S=>{_&&i(S)}).catch(S=>{_&&o($e(S))}),()=>{_=!1}},[e,t.state]);const x=async _=>{if(!(!_.auto&&(s==null?void 0:s.settings.auto)===!0&&!await Ms({title:"关掉自动压缩?",message:"关掉后,对话超过模型的上下文长度时会直接出错,要手动压缩或开新对话才能继续。",confirmLabel:"关掉",danger:!0}))){u(!0),o(null);try{i(await e.connection.call("compaction/set",{settings:_}))}catch(S){o($e(S))}finally{u(!1)}}},N=async()=>{m===void 0||!await Ms({title:"现在重启 agent 服务?",message:"正在进行的对话和正在跑的脚本、流水线会被中断,大约需要半分钟。",confirmLabel:"重启",danger:!0,icon:"refresh"})||await m()},j=(s==null?void 0:s.settings.summarizer)??null,y=j!==null&&p!==null&&!p.groups.some(_=>_.id===j.provider&&_.models.some(S=>S.id===j.model));return n.jsxs("div",{className:"settings-page compaction-page",children:[n.jsx("h2",{children:"对话压缩"}),n.jsx("p",{children:"对话很长时,模型一次看不下全部内容。压缩会把较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:"}),n.jsxs("ul",{className:"compaction-costs",children:[n.jsxs("li",{children:[n.jsx("strong",{children:"会丢失记忆"}),":早先的细节(具体的命令和输出、日志、截图、你说过的原话)agent 不再记得;"]}),n.jsx("li",{children:"摘要可能漏掉或写错内容,而且不能撤销;"}),n.jsx("li",{children:"界面上的聊天记录还在,只是 agent 看不到了。"})]}),s!==null&&n.jsxs("section",{className:"card",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:s.settings.auto,disabled:l,onChange:_=>void x({...s.settings,auto:_.target.checked})}),"对话太长时自动压缩"]}),n.jsx("p",{className:"muted small",children:s.settings.auto?"关掉后不会自动压缩:对话超过模型的上下文长度时会出错,需要手动压缩或开新对话。":"已关闭:对话超过模型的上下文长度时会出错,需要手动压缩或开新对话。"}),n.jsxs("label",{className:"field compaction-threshold",children:[n.jsxs("span",{className:"field-title",children:["占满上下文的多少时压缩:",n.jsxs("strong",{children:[d??s.settings.threshold,"%"]}),(d??s.settings.threshold)===w2?"(默认)":""]}),n.jsx("input",{type:"range",min:nw,max:sw,step:5,value:d??s.settings.threshold,disabled:!s.settings.auto,"aria-label":"压缩阈值(百分比)",onChange:_=>h(Number(_.target.value))}),n.jsx("span",{className:"muted small",children:"调低:压缩得早,回复快、花费少,但记得的细节少;调高:记得的多,但更可能临时压缩一大段。100% 是到上下文快满时才压缩(会留出回复的空间)。"}),(d??s.settings.threshold)<S2&&s.settings.auto&&n.jsxs("span",{className:"notice warn-box left small compaction-warn",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:"这么低时,光是系统提示和工具说明就可能接近这个用量,几乎每一步都会压缩一次,每次都要调用模型写摘要。想让上下文保持很短,用下面的「低上下文模式」更合适。"})]})]}),n.jsxs("label",{className:"field compaction-summarizer",children:[n.jsx("span",{className:"field-title",children:"写摘要的模型"}),n.jsx(Mt,{"aria-label":"写摘要的模型",value:qj(s.settings.summarizer),disabled:l||p===null,onChange:_=>{const[S="",E=""]=_.split(Eg);x({...s.settings,summarizer:_===""?null:{provider:S,model:E}})},options:[{value:"",label:"和对话用同一个模型(默认)",hint:"能用上对话的提示缓存"},...((p==null?void 0:p.groups)??[]).flatMap(_=>_.models.map(S=>({value:`${_.id}${Eg}${S.id}`,label:S.name,hint:_.name}))),...y?[{value:qj(s.settings.summarizer),label:`${s.settings.summarizer.provider} / ${s.settings.summarizer.model}`,hint:"已不在模型列表里"}]:[]]}),n.jsx("span",{className:"muted small",children:"自动压缩、手动压缩和低上下文模式都由它读一遍要压缩的那段对话,写出摘要。默认用对话自己的模型,这段对话大多能命中它的提示缓存;换成别的模型时整段按没命中缓存计费,而且它的上下文要装得下这一段,装不下时压缩会失败。"}),y&&n.jsxs("span",{className:"notice warn-box left small compaction-warn",children:[n.jsx(Q,{name:"alert"}),n.jsxs("span",{children:["「",s.settings.summarizer.provider," / ",s.settings.summarizer.model,"」已经不在模型列表里了(服务被删掉或没有 Key),压缩会失败:换一个,或改回和对话用同一个模型。"]})]})]}),!aZ(s.settings,s.applied)&&n.jsxs("div",{className:"notice left",children:[n.jsx(Q,{name:"info"}),n.jsxs("span",{children:["改动要重启 agent 服务才生效(现在还是:",s.applied.auto?`自动压缩,${s.applied.threshold}%`:"不自动压缩",";摘要由",g(s.applied.summarizer),"写)。",m===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),m!==void 0&&n.jsx("button",{className:"small-button",onClick:()=>void N(),children:"重启 agent 服务"})]}),r!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:r})]})]}),s!==null&&n.jsxs("section",{className:"card",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:s.settings.lowContext,disabled:l,onChange:_=>void x({...s.settings,lowContext:_.target.checked})}),"低上下文模式"]}),n.jsx("p",{className:"muted small",children:"只保留最近 12 小时的对话,更早的在任务做完后压缩成摘要;对话安静超过 4 小时后再来新消息,会先把之前的内容压成摘要再开始,agent 从摘要起步、需要时再查原文。任务做完时,过长的工具输出(日志、运行记录)也会截成头尾。"}),n.jsxs("label",{className:"check-label compaction-archive",children:[n.jsx("input",{type:"checkbox",checked:s.settings.archiveDays!==null,disabled:l||!s.settings.lowContext,onChange:_=>void x({...s.settings,archiveDays:_.target.checked?7:null})}),"摘要也归档"]}),s.settings.archiveDays!==null&&n.jsxs("label",{className:"field compaction-archive-days",children:[n.jsx("span",{className:"field-title",children:"对话过了多久,它的摘要就移出上下文"}),n.jsx(Mt,{"aria-label":"多久以后归档",value:String(s.settings.archiveDays),disabled:l||!s.settings.lowContext,onChange:_=>void x({...s.settings,archiveDays:Number(_)}),options:[...new Set([...C2,s.settings.archiveDays])].sort((_,S)=>_-S).map(_=>({value:String(_),label:`${_} 天`}))})]}),n.jsx("p",{className:"muted small",children:s.settings.lowContext?"打开后,每一段较早的对话单独写一份摘要(攒到大约一天写一次,不会把摘要再压成摘要);对话过了上面的天数,它的摘要也移出上下文,只留一行说明。做过的事在「记忆」的日记里,agent 需要细节时会去查归档的摘要和原话。上下文最短,但 agent 要靠查才想得起来以前的事。":"要先打开低上下文模式。"})]}),s!==null&&n.jsxs("section",{className:"card",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:s.settings.ptcSubagents,disabled:l,onChange:_=>void x({...s.settings,ptcSubagents:_.target.checked})}),"子 agent 用代码调用工具"]}),n.jsx("p",{className:"muted small",children:"子 agent 写一小段程序来调用工具:等脚本跑完、翻日志、查运行记录都在程序里做,只把结果交回对话,不用每一步都把整段日志重新发给模型,用量少很多。关掉后子 agent 一次调用一个工具。各个 agent 自己的对话不受影响。不是「完全访问」时程序在沙箱里运行,如果子 agent 说代码执行环境起不来(Windows 文件权限挡住了),先关掉这个开关。"}),s.settings.ptcSubagents!==s.applied.ptcSubagents&&n.jsxs("div",{className:"notice left",children:[n.jsx(Q,{name:"info"}),n.jsxs("span",{children:["改动要重启 agent 服务才生效(现在还是:",s.applied.ptcSubagents?"用代码调用工具":"一次调用一个工具",")。",m===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),m!==void 0&&n.jsx("button",{className:"small-button",onClick:()=>void N(),children:"重启 agent 服务"})]})]}),n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"手动压缩"}),n.jsxs("p",{className:"muted small",children:["在对话框里输入 ",n.jsx("kbd",{children:"/压缩"}),",会先说明代价再确认。对话框旁边的小圆圈显示上下文用了多少,点开能看到各部分占多少。对话变慢、或报上下文超长时用;agent 正在工作时不能压缩。"]})]}),s===null&&r!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:r})]})]})}const Cg=[{kind:"core",title:"核心",hint:`你最在意的要求和偏好:每个 agent 每次都会带上,不会被挤掉;所有核心一共最多 ${Zg} 字,总是共享`},{kind:"profile",title:"资料",hint:"长期有效的事实和偏好"},{kind:"journal",title:"日记",hint:"某一天做过或决定的事"}],lZ={core:"核心",profile:"资料",journal:"日记"},Hr="",cZ=["周日","周一","周二","周三","周四","周五","周六"];function uZ(e){const t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function dZ(e){const[t,s,i]=e.split("-").map(Number),r=new Date(t,s-1,i),o=new Date,l=Math.round((new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime()-r.getTime())/864e5),u=`${t===o.getFullYear()?"":`${t}年`}${s}月${i}日 ${cZ[r.getDay()]}`;return l===0?`今天 · ${u}`:l===1?`昨天 · ${u}`:u}const xc=e=>e.kind==="journal"?e.createdAt:e.updatedAt,yE=(e,t)=>s=>{s.key==="Enter"&&(s.ctrlKey||s.metaKey)?(s.preventDefault(),e()):s.key==="Escape"&&(s.preventDefault(),t())};function hZ({client:e}){var D,V;const t=_e(e.connection.status),s=$i(e),[i,r]=v.useState(null),[o,l]=v.useState(0),[u,d]=v.useState(wa),[h,m]=v.useState(Hr),[p,g]=v.useState(""),[x,N]=v.useState(!1),[j,y]=v.useState(null);v.useEffect(()=>e.connection.on("memory/changed",()=>l(U=>U+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let U=!0;return e.connection.call("memory/list",{}).then(q=>{U&&(r(q.items),y(null))}).catch(q=>{U&&y($e(q))}),()=>{U=!1}},[e,t.state,o]);const k=v.useMemo(()=>[{id:cn.id,name:cn.name},...s.map(U=>({id:U.id,name:U.name}))],[s]),_=U=>{var q;return U===wa?"共享":U==="user"?"你":U==="auto"?"自动整理":((q=k.find(te=>te.id===U))==null?void 0:q.name)??U},S=p.trim().toLowerCase().split(/\s+/).filter(U=>U!==""),E=U=>(i??[]).filter(q=>q.scope===U).length,O=(i??[]).filter(U=>U.scope===u),P=(i??[]).filter(U=>U.kind==="core").reduce((U,q)=>U+q.text.length,0),H=O.filter(U=>(h===Hr||U.kind===h)&&S.every(q=>U.text.toLowerCase().includes(q))).sort((U,q)=>xc(q).localeCompare(xc(U))),B=H.filter(U=>U.kind==="core"),R=[];for(const U of H.filter(q=>q.kind!=="core")){const q=uZ(xc(U));((D=R.at(-1))==null?void 0:D.day)===q?R.at(-1).entries.push(U):R.push({day:q,entries:[U]})}const M=[{id:wa,name:"共享"},...k],F=((V=M.find(U=>U.id===u))==null?void 0:V.name)??u,L=u===wa,A=S.length>0||h!==Hr,I=async U=>{y(null);try{return await U(),l(q=>q+1),!0}catch(q){return y($e(q)),!1}},z=async(U,q)=>{const te=U==="core"?wa:u;return await I(()=>e.connection.call("memory/add",{kind:U,scope:te,text:q}))?(te!==u&&d(te),h!==Hr&&h!==U&&m(Hr),g(""),N(!1),!0):!1};return n.jsxs("div",{className:"settings-page memory-page",children:[n.jsx("h2",{children:"记忆"}),n.jsx("p",{children:"agent 在对话里记下的关于你的事,新开的对话也记得。「共享」的每个 agent 都看得到,其余的只有那个 agent 自己看得到。「核心」是你最在意的要求和偏好,每个 agent 每次都会带上,不会因为记得多了或时间久了被挤掉;只有你自己(或你明确让 agent 记)才会写进去。你也可以在这里记一条、改掉或删掉。密码、验证码、密钥不会被记下。怎么一步步做一件事是另一回事,存在「技能」里。"}),i!==null&&n.jsxs(n.Fragment,{children:[n.jsx(mZ,{client:e}),n.jsxs("section",{className:"card memory-browse",children:[n.jsxs("div",{className:"card-head memory-head",children:[n.jsxs("div",{className:"memory-whose",children:[n.jsx(Mt,{className:"scope-select","aria-label":"谁的记忆",value:u,onChange:d,options:M.map(U=>({value:U.id,label:U.id===wa?"共享的记忆":`「${U.name}」的记忆`,hint:E(U.id)===0?"还没有":`${E(U.id)} 条`,...U.id===wa?{}:{group:"一个 agent 自己的"}}))}),n.jsx("span",{className:"muted small",children:L?"每个 agent 都看得到":`只有「${F}」自己看得到`})]}),!x&&n.jsxs("button",{className:"small-button",onClick:()=>N(!0),children:[n.jsx(Q,{name:"plus"}),"记一条"]})]}),x&&n.jsx(fZ,{to:L?"共享":`「${F}」`,coreUsed:P,onAdd:z,onClose:()=>N(!1)}),j!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:j})]}),O.length>0&&n.jsxs("div",{className:"memory-filters",children:[n.jsx("div",{className:"memory-kinds",role:"radiogroup","aria-label":"种类",children:[{kind:Hr,title:"全部"},...Cg].map(U=>n.jsxs("button",{role:"radio","aria-checked":h===U.kind,className:`filter-chip ${h===U.kind?"active":""}`,onClick:()=>m(U.kind),children:[U.title,n.jsx("span",{className:"memory-kind-count",children:U.kind===Hr?O.length:O.filter(q=>q.kind===U.kind).length})]},U.kind))}),n.jsxs("label",{className:"memory-search",children:[n.jsx(Q,{name:"search"}),n.jsx("input",{className:"text-input plain",type:"search",placeholder:"搜索(空格分开几个词)",value:p,onChange:U=>g(U.target.value),"aria-label":"搜索记忆"})]})]}),B.length>0&&n.jsxs("div",{className:"memory-day memory-core",children:[n.jsx("h4",{className:"memory-day-title",children:n.jsxs("span",{children:["核心 · 每次都带上(",P," / ",Zg," 字)"]})}),n.jsx("ul",{className:"memory-list",children:B.map(U=>n.jsx(Gj,{entry:U,nameOf:_,onSave:q=>I(()=>e.connection.call("memory/update",{id:U.id,text:q})),onForget:()=>void Ms({title:"删掉这条核心记忆?",message:"之后 agent 就不会每次都带上它了,不能撤销。",quote:U.text,confirmLabel:"删掉",danger:!0}).then(q=>{q&&I(()=>e.connection.call("memory/remove",{id:U.id}))})},U.id))})]}),R.length===0&&B.length===0?n.jsxs("div",{className:"memory-empty",children:[n.jsx("p",{className:"muted",children:A?"没有找到。":`「${F}」还没有记忆。`}),A?n.jsx("button",{className:"link-button small",onClick:()=>{m(Hr),g("")},children:"清除筛选"}):n.jsx("p",{className:"muted small",children:"agent 干活时会自己记下,你也可以点「记一条」写给它。"})]}):R.map(U=>n.jsxs("div",{className:"memory-day",children:[n.jsx("h4",{className:"memory-day-title",children:n.jsx("span",{children:dZ(U.day)})}),n.jsx("ul",{className:"memory-list",children:U.entries.map(q=>n.jsx(Gj,{entry:q,nameOf:_,onSave:te=>I(()=>e.connection.call("memory/update",{id:q.id,text:te})),onForget:()=>void Ms({title:"忘掉这条记忆?",message:"之后 agent 就不记得了,不能撤销。",quote:q.text,confirmLabel:"忘掉",danger:!0}).then(te=>{te&&I(()=>e.connection.call("memory/remove",{id:q.id}))})},q.id))})]},U.day))]})]}),i===null&&j!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:j})]})]})}function mZ({client:e}){const t=_e(e.connection.status),{catalog:s}=aa(e),[i,r]=v.useState(null),[o,l]=v.useState(!1),[u,d]=v.useState(null);v.useEffect(()=>{if(t.state!=="open")return;let N=!0;return e.connection.call("memory/auto/get",{}).then(j=>{N&&(r(j),d(null))}).catch(j=>{N&&d($e(j))}),()=>{N=!1}},[e,t.state]);const h=async N=>{l(!0),d(null);try{const j=await e.connection.call("memory/auto/set",{auto:N.auto,model:N.model});r({...j,...(i==null?void 0:i.forced)===!0?{forced:!0}:{}})}catch(j){d($e(j))}finally{l(!1)}};if(i===null)return u===null?null:n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:u})]});const m=i.auto||i.forced===!0,p=i.model===null?"":`${i.model.provider}/${i.model.model}`,g=p===""||((s==null?void 0:s.groups.some(N=>N.models.some(j=>`${N.id}/${j.id}`===p)))??!1),x=N=>{const[j,...y]=N.split("/");h({...i,model:N===""?null:{provider:j,model:y.join("/")}})};return n.jsxs("section",{className:"card memory-auto",children:[n.jsxs("div",{className:"memory-auto-row",children:[n.jsxs("label",{className:"check-label memory-auto-check",children:[n.jsx("input",{type:"checkbox",checked:m,disabled:o||i.forced===!0,onChange:N=>void h({...i,auto:N.target.checked})}),n.jsxs("span",{className:"memory-auto-text",children:[n.jsx("strong",{children:"自动整理"}),n.jsxs("span",{className:"muted small",children:["对话停下几分钟后,自动把没记下的偏好和做过的事整理进记忆",i.forced===!0?"。低上下文模式开着,自动整理会一直开着。":""]})]})]}),m&&n.jsxs("label",{className:"field memory-auto-model",children:[n.jsx("span",{className:"field-title",children:"整理用的模型"}),s===null?n.jsx("span",{className:"muted small",children:"读取中…"}):n.jsx(Mt,{"aria-label":"整理用的模型",value:p,disabled:o,onChange:x,options:[{value:"",label:"和默认模型一样"},...g?[]:[{value:p,label:`${i.model.provider} / ${i.model.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...s.groups.flatMap(N=>N.models.map(j=>({value:`${N.id}/${j.id}`,label:j.name,group:N.name})))]})]})]}),u!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:u})]})]})}function fZ({to:e,coreUsed:t,onAdd:s,onClose:i}){var N;const[r,o]=v.useState(""),[l,u]=v.useState("profile"),[d,h]=v.useState(!1),m=Zg-t,p=l==="core"&&r.trim().length>m,g=!d&&r.trim()!==""&&!p,x=async()=>{g&&(h(!0),await s(l,r.trim()),h(!1))};return n.jsxs("div",{className:"memory-compose",children:[n.jsx("textarea",{className:"text-input plain",rows:3,maxLength:Wg,autoFocus:!0,"aria-label":"要记下的事",placeholder:"一句话写一件事,例如:日报只要告诉我有没有失败的;明日方舟只玩 B 服。",value:r,onChange:j=>o(j.target.value),onKeyDown:yE(()=>void x(),i)}),n.jsxs("div",{className:"memory-compose-foot",children:[n.jsx("div",{className:"segmented-control memory-kind",role:"radiogroup","aria-label":"种类",children:Cg.map(j=>n.jsx("button",{role:"radio","aria-checked":l===j.kind,className:l===j.kind?"active":"",onClick:()=>u(j.kind),children:j.title},j.kind))}),n.jsxs("span",{className:`small memory-compose-hint ${p?"warn-text":"muted"}`,children:[(N=Cg.find(j=>j.kind===l))==null?void 0:N.hint,l==="core"&&(p?`。核心只剩 ${Math.max(0,m)} 字了:先合并或删掉几条,或记成资料。`:`(还能写 ${m} 字)`)]}),n.jsxs("span",{className:"memory-compose-actions",children:[n.jsx("button",{disabled:d,onClick:i,children:"取消"}),n.jsx("button",{className:"primary",disabled:!g,onClick:()=>void x(),children:d?"记下中…":l==="core"?"记成核心":`记到${e}`})]})]})]})}function Gj({entry:e,nameOf:t,onSave:s,onForget:i}){const[r,o]=v.useState(null),[l,u]=v.useState(!1),d=!l&&r!==null&&r.trim()!=="",h=async()=>{d&&(u(!0),await s(r.trim())&&o(null),u(!1))};return n.jsxs("li",{className:`memory-row ${r===null?"":"editing"}`,children:[n.jsx("time",{className:"memory-time",dateTime:xc(e),title:e.kind==="journal"?"记下的时间":"最后更新的时间",children:new Date(xc(e)).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}),n.jsxs("div",{className:"memory-body",children:[r===null?n.jsx("div",{className:"memory-text",children:e.text}):n.jsx("textarea",{className:"text-input plain",rows:3,maxLength:Wg,value:r,onChange:m=>o(m.target.value),onKeyDown:yE(()=>void h(),()=>o(null)),"aria-label":"修改记忆",autoFocus:!0}),n.jsxs("div",{className:"memory-meta",children:[n.jsx("span",{className:`memory-kind-tag ${e.kind}`,children:lZ[e.kind]}),n.jsx("span",{className:"muted small",children:e.by==="user"?"你记的":e.by==="auto"?"自动整理出来的":`${t(e.by)}记的`}),r!==null&&n.jsxs("span",{className:"memory-edit-actions",children:[n.jsx("button",{className:"small-button",disabled:l,onClick:()=>o(null),children:"取消"}),n.jsx("button",{className:"small-button primary",disabled:!d,onClick:()=>void h(),children:l?"保存中…":"保存"})]})]})]}),r===null&&n.jsxs("span",{className:"memory-actions",children:[n.jsx("button",{className:"link-button small",onClick:()=>o(e.text),children:"修改"}),n.jsx("button",{className:"link-button small memory-forget",onClick:i,children:"忘掉"})]})]})}const Kj=[{policy:"default",label:"默认",hint:"跟着上面的模式走"},{policy:"allow",label:"允许",hint:"不问你,直接做"},{policy:"ask",label:"先问我",hint:"每次都先问你,「完全访问」时也问"},{policy:"deny",label:"不允许",hint:"agent 不能做,会告诉你被关掉了"}],pZ=[{value:"auto",label:"自动更新"},{value:"ask",label:"先问我"},{value:"off",label:"不自动更新"}],gZ=[{value:"act",label:"诊断并处理"},{value:"diagnose",label:"只诊断"},{value:"off",label:"不干预"}];function xZ({client:e,state:t,onState:s}){const i=_e(e.capabilities),[r,o]=v.useState(null),[l,u]=v.useState(null),[d,h]=v.useState(null),m=i.has("monitor"),p=i.has("scripts"),[g,x]=v.useState(null);v.useEffect(()=>{if(!p)return;let k=!0;return e.connection.call("scripts/settings",{}).then(_=>{k&&x(_.autoUpdate)}).catch(()=>{}),()=>{k=!1}},[e,p]),v.useEffect(()=>{if(!m)return;let k=!0;return e.connection.call("monitor/settings",{}).then(_=>{k&&h(_)}).catch(()=>{}),()=>{k=!1}},[e,m]);const N=async(k,_)=>{o(k),u(null);try{s(await e.connection.call("permissions/area/set",{area:k,policy:_}))}catch(S){u($e(S))}finally{o(null)}},j=async k=>{o("autoUpdate"),u(null);try{x((await e.connection.call("scripts/settings/set",{autoUpdate:k})).autoUpdate)}catch(_){u($e(_))}finally{o(null)}},y=async k=>{o("intervene"),u(null);try{h(await e.connection.call("monitor/settings/set",{intervene:k}))}catch(_){u($e(_))}finally{o(null)}};return n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:"按范围设置"}),n.jsxs("p",{className:"muted small",children:["agent 能自己做的事,一项一项决定:",Kj.map(k=>`「${k.label}」${k.hint}`).join(";"),"。"]})]})}),n.jsxs("div",{className:"area-list",children:[m&&d!==null&&n.jsxs("div",{className:"area-row",children:[n.jsxs("div",{className:"area-text",children:[n.jsx("strong",{children:"主动干预出问题的脚本"}),n.jsx("span",{className:"muted small",children:"脚本卡住、报错,自动处理解决不了时交给 agent:「诊断并处理」会暂停脚本、看屏幕、点击输入来解决;「只诊断」只说明原因由你决定。"})]}),n.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":"主动干预",children:gZ.map(k=>n.jsx("button",{role:"radio","aria-checked":d.intervene===k.value,className:d.intervene===k.value?"active":"",disabled:r!==null,onClick:()=>void y(k.value),children:k.label},k.value))})]}),p&&g!==null&&n.jsxs("div",{className:"area-row",children:[n.jsxs("div",{className:"area-text",children:[n.jsx("strong",{children:"脚本有新版本时"}),n.jsx("span",{className:"muted small",children:"运行前和每隔几小时检查一次:「自动更新」下次运行前先更新;「先问我」在聊天输入框上方提示,你点了才更新;「不自动更新」只在脚本页标出新版本。agent 也照这里来:只有「自动更新」时会自己决定更新。"})]}),n.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":"脚本有新版本时",children:pZ.map(k=>n.jsx("button",{role:"radio","aria-checked":g===k.value,className:g===k.value?"active":"",disabled:r!==null,onClick:()=>void j(k.value),children:k.label},k.value))})]}),a2.map(k=>{const _=t.areas[k.id]??"default";return n.jsxs("div",{className:"area-row",children:[n.jsxs("div",{className:"area-text",children:[n.jsx("strong",{children:k.title}),n.jsx("span",{className:"muted small",children:k.description})]}),n.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":k.title,children:Kj.map(S=>n.jsx("button",{role:"radio","aria-checked":_===S.policy,title:S.hint,className:`${_===S.policy?"active":""} ${S.policy}`,disabled:r!==null,onClick:()=>void N(k.id,S.policy),children:S.label},S.policy))})]},k.id)})]}),l!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:l})]})]})}const vZ=[{mode:"ask",title:"每次确认(推荐)",text:"agent 的命令在沙箱里运行;安装陌生仓库、操作屏幕、沙箱外的命令、修改脚本文件等,都先问你。"},{mode:"full",title:"完全访问",text:"不用沙箱,所有需要确认的操作都自动允许,也可以修改脚本文件:agent 想改什么就改什么,不再问你。"}];function yZ({client:e}){const t=_e(e.connection.status),s=vn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(!1),[u,d]=v.useState(null);v.useEffect(()=>e.connection.on("permissions/changed",m=>r(m)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let m=!0;return e.connection.call("permissions/get",{}).then(p=>{m&&r(p)}).catch(p=>{m&&d($e(p))}),()=>{m=!1}},[e,t.state]);const h=async m=>{if((i==null?void 0:i.mode)!==m&&!(m==="full"&&!await Ms({title:"打开「完全访问」?",icon:"shield",confirmLabel:"打开",danger:!0,message:`打开后,agent 可以不经确认运行任何命令、修改或删除任何文件(包括脚本文件)、操作屏幕、安装软件。
|
|
250
|
-
|
|
251
|
-
只在你信任当前模型、并且需要它自己完成整件事时打开。`}))){l(!0),d(null);try{r(await e.connection.call("permissions/set",{mode:m}))}catch(p){d($e(p))}finally{l(!1)}}};return n.jsxs("div",{className:"settings-page",children:[n.jsx("h2",{children:"权限"}),n.jsx("p",{children:"决定 agent 做事之前要不要先问你。对所有会话都有效,包括飞书里的对话、异常处理和流水线里的 agent 步骤。"}),n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"permission-options",role:"radiogroup","aria-label":"权限",children:vZ.map(m=>n.jsxs("button",{role:"radio","aria-checked":(i==null?void 0:i.mode)===m.mode,disabled:o||i===null,className:`permission-option ${m.mode} ${(i==null?void 0:i.mode)===m.mode?"active":""}`,onClick:()=>void h(m.mode),children:[n.jsx("span",{className:"permission-dot","aria-hidden":"true"}),n.jsxs("span",{className:"permission-text",children:[n.jsx("strong",{children:m.title}),n.jsx("span",{children:m.text})]})]},m.mode))}),(i==null?void 0:i.mode)==="full"&&n.jsxs("div",{className:"notice warn-note left small",children:[n.jsx(Q,{name:"alert"}),n.jsxs("span",{children:["完全访问一直开着,没有时间限制,直到你改回「每次确认」",i.since===void 0?"":`(${bZ(i.since,s)})`,"。agent 不会再请求确认;它仍然不会替你输入密码、验证码或付款。agent 之间可以互相交事情,这时也不会有人拦:比如读网页时读到的内容,可能经别的 agent 变成运行或安装。"]})]}),u!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:u})]})]}),i!==null&&n.jsx(xZ,{client:e,state:i,onState:r}),i!==null&&i.recent.length>0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"没问你就允许了的操作"}),n.jsxs("p",{className:"muted small",children:["因为「完全访问」或某个范围设成了「允许」。程序这次启动以来,最近 ",i.recent.length," 条。"]}),n.jsx("ul",{className:"version-list",children:i.recent.map((m,p)=>n.jsxs("li",{children:[n.jsx("span",{className:"badge",children:m.toolName}),n.jsx("span",{className:"permission-reason",children:m.reason??"(没有说明)"}),n.jsx("span",{className:"spacer"}),n.jsx("span",{className:"session-time",children:vt(m.at,s)})]},p))})]})]})}function bZ(e,t){const s=vt(e,t);return s==="刚刚"?"刚刚打开":/^\d+ (分钟|小时|天)$/.test(s)?`${s}前打开`:`${s} 打开`}const Ag=[{style:"default",title:"默认",note:"模型自己的说话方式",sample:""},{style:"concise",title:"简洁干练",note:"先说结论,少寒暄",sample:"日常跑完了,3 个成功 1 个失败:MAA 刷理智没体力了。"},{style:"patient",title:"耐心细致",note:"每一步讲清楚为什么",sample:"我先帮你看了 MAA 的日志,失败是因为理智不够——这不是脚本坏了,等理智恢复再跑就行。"},{style:"lively",title:"活泼可爱",note:"轻松,带点语气词和表情",sample:"搞定啦~日常都跑完了!就是理智又见底了 (。•́︿•̀。)"},{style:"buddy",title:"游戏搭子",note:"像一起玩的老朋友",sample:"日常清完了,理智又被榨干了哈哈,活动商店还差两样,明天接着肝。"},{style:"butler",title:"稳重管家",note:"礼貌周到,主动汇报",sample:"今日日常已完成。另有一项需要您决定:活动商店剩余两件,是否明日继续兑换?"}],mp=[{style:"plain",title:"平实",text:"直接说事,不带人设和称呼:它们要读的是内容。推荐。"},{style:"same",title:"和对你一样",text:"人设也带到 agent 之间的往来里,你在「全部」里看到的就是这个语气。"}],fp="",Yj=e=>{var t;return((t=Ag.find(s=>s.style===e))==null?void 0:t.title)??e};function Xj(e){return e===void 0||e.style===void 0&&e.callUser===void 0&&e.custom===void 0&&e.peerStyle===void 0}const Qj=e=>{var t,s,i;return[e.style??"",((t=e.name)==null?void 0:t.trim())??"",((s=e.callUser)==null?void 0:s.trim())??"",((i=e.custom)==null?void 0:i.trim())??"",e.peerStyle??""]};function pd(e){const t=Object.entries(e.agents).map(([s,i])=>[s,Qj(i)]).filter(([,s])=>s.some(i=>i!=="")).sort(([s],[i])=>s.localeCompare(i));return JSON.stringify([Qj({...e.persona,peerStyle:e.persona.peerStyle??"plain"}),t])}function kZ({client:e}){var te,G,K,Z,ee;const t=_e(e.connection.status),s=$i(e),[i,r]=v.useState(null),[o,l]=v.useState(null),[u,d]=v.useState(fp),[h,m]=v.useState(!1),[p,g]=v.useState(null),[x,N]=v.useState(!1),j=J=>{const re={persona:J.persona,agents:J.agents};r(re),l(re)};if(v.useEffect(()=>{if(t.state!=="open")return;let J=!0;return e.connection.call("persona/get",{}).then(re=>{J&&j(re)}).catch(re=>{J&&g($e(re))}),()=>{J=!1}},[e,t.state]),o===null||i===null)return n.jsxs("div",{className:"settings-page persona-page",children:[n.jsx("h2",{children:"回复风格"}),p!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:p})]})]});const y=pd(o)!==pd(i),k=J=>{l(J),N(!1)},_=async()=>{m(!0),g(null);try{j(await e.connection.call("persona/set",o)),N(!0)}catch(J){g($e(J))}finally{m(!1)}},S=[{id:cn.id,name:cn.name},...s.map(J=>({id:J.id,name:J.name}))],E=u===fp,O=o.persona,P=E?void 0:o.agents[u],H=((te=S.find(J=>J.id===u))==null?void 0:te.name)??u,B=J=>k({...o,persona:{...O,...J}}),R=J=>{const re=Object.fromEntries(Object.entries({...P,...J}).filter(([,ie])=>ie!==void 0&&(typeof ie!="string"||ie.trim()!=="")));k({...o,agents:{...o.agents,[u]:re}})},M=E?B:R,F=E?O:tb(o,u),L=nb(F),A=new Set(nb(E?i.persona:tb(i,u)).split(`
|
|
252
|
-
`)),I=((G=Ag.find(J=>J.style===F.style))==null?void 0:G.sample)??"",z=E?O.style:P==null?void 0:P.style,D=E?O.peerStyle??"plain":P==null?void 0:P.peerStyle,V=(J,re)=>E?re:J===void 0||J===""?"留空:跟随统一(现在没有设置)":`留空:跟随统一(${J})`,U=E?pd({persona:O,agents:{}})!==pd({persona:{style:"default"},agents:{}}):!Xj(P),q=()=>k(E?{...o,persona:{style:"default"}}:{...o,agents:{...o.agents,[u]:(P==null?void 0:P.name)===void 0?{}:{name:P.name}}});return n.jsxs("div",{className:"settings-page persona-page",children:[n.jsx("h2",{children:"回复风格"}),n.jsx("p",{children:"agent 说话的方式和人设:可以统一设置,也可以给某个 agent 单独设置。软件里的对话、飞书里的回复、流水线里的 agent 步骤都算。只改说话方式:它们能做什么、该做什么、什么要问你,都不变。子 agent 不用设置,它们只把结果交回给开它们的 agent。"}),n.jsxs("section",{className:"card persona-board",children:[n.jsxs("header",{className:"persona-bar",children:[n.jsxs("label",{className:"persona-who",children:[n.jsx("span",{className:"field-title",children:"设置给"}),n.jsx(Mt,{className:"scope-select","aria-label":"设置给谁",value:u,onChange:d,options:[{value:fp,label:"所有 agent",hint:"统一设置"},...S.map(J=>{var ne;const re=o.agents[J.id],ie=(ne=re==null?void 0:re.name)==null?void 0:ne.trim();return{value:J.id,label:ie?`${J.name}(${ie})`:J.name,hint:Xj(re)?"跟随统一":"有单独设置",group:"只给一个 agent"}})]})]}),n.jsx("span",{className:`persona-state ${y?"dirty":""}`,role:"status",children:y?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"persona-dot"}),"有没保存的改动"]}):x?n.jsxs(n.Fragment,{children:[n.jsx(Q,{name:"check"}),"已保存,下一句回复开始生效"]}):null}),y&&n.jsx("button",{disabled:h,onClick:()=>k(i),children:"撤销"}),n.jsx("button",{className:"primary",disabled:h||!y,onClick:()=>void _(),children:h?"保存中…":"保存"})]}),p!==null&&n.jsxs("div",{className:"notice error left persona-error",children:[n.jsx(Q,{name:"alert"}),n.jsx("span",{children:p})]}),n.jsxs("div",{className:"persona-panes",children:[n.jsxs("div",{className:"persona-form",children:[n.jsxs("div",{className:"field",children:[n.jsx("span",{className:"field-title",children:"风格"}),n.jsxs("div",{className:"persona-tiles",role:"radiogroup","aria-label":"风格",children:[!E&&n.jsx(Jj,{wide:!0,title:"跟随统一",note:`现在是「${Yj(O.style)}」`,selected:z===void 0,onClick:()=>R({style:void 0})}),Ag.map(J=>n.jsx(Jj,{title:J.title,note:J.note,selected:z===J.style,onClick:()=>M({style:J.style})},J.style))]})]}),n.jsxs("div",{className:"persona-pair",children:[!E&&n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"它的名字(可选)"}),n.jsx("input",{className:"text-input plain",maxLength:20,placeholder:"例如:小助",value:(P==null?void 0:P.name)??"",onChange:J=>R({name:J.target.value}),title:"它自称时用这个名字;别的 agent 也会知道你这么叫它。"})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"怎么称呼你(可选)"}),n.jsx("input",{className:"text-input plain",maxLength:20,placeholder:V(O.callUser,"例如:博士、开拓者、指挥官"),value:(E?O.callUser:P==null?void 0:P.callUser)??"",onChange:J=>M({callUser:J.target.value})})]})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"其他要求(可选)"}),n.jsx("textarea",{className:"text-input plain persona-custom",rows:4,placeholder:V(O.custom,"例如:说话带一点罗德岛干员的口吻;汇报时先说有没有失败;不要用表情。"),value:(E?O.custom:P==null?void 0:P.custom)??"",onChange:J=>M({custom:J.target.value})})]}),n.jsxs("div",{className:"field",children:[n.jsx("span",{className:"field-title",children:"对其他 agent 说话"}),n.jsxs("div",{className:"segmented-control persona-peer",role:"radiogroup","aria-label":"对其他 agent 说话",children:[!E&&n.jsx("button",{role:"radio","aria-checked":D===void 0,className:D===void 0?"active":"",onClick:()=>R({peerStyle:void 0}),children:"跟随统一"}),mp.map(J=>n.jsx("button",{role:"radio","aria-checked":D===J.style,className:D===J.style?"active":"",onClick:()=>M({peerStyle:J.style}),children:J.title},J.style))]}),n.jsx("span",{className:"muted small",children:D===void 0?`和统一设置一样:${(K=mp.find(J=>J.style===(O.peerStyle??"plain")))==null?void 0:K.title}。`:(Z=mp.find(J=>J.style===D))==null?void 0:Z.text})]}),n.jsxs("div",{className:"persona-foot muted small",children:[n.jsx("span",{children:E?"没有单独设置的 agent 都按这里的来。":"没改的地方跟随「所有 agent」的设置。"}),U&&n.jsx("button",{className:"link-button small",onClick:q,children:E?"恢复默认":"全部改回跟随统一"})]})]}),n.jsx("aside",{className:"persona-preview","aria-label":"预览",children:n.jsxs("div",{className:"persona-preview-in",children:[n.jsxs("div",{className:"persona-preview-head",children:[n.jsx("strong",{children:"预览"}),n.jsx("span",{className:"muted small",children:y?"跟着左边的选择变,保存后生效":"现在生效的设置"})]}),n.jsxs("div",{className:"field",children:[n.jsx("span",{className:"field-title",children:"说出来大概这样"}),I===""?n.jsx("p",{className:"persona-sample none",children:"不加风格,按模型自己的说话方式。"}):n.jsxs("div",{className:"persona-sample",children:[n.jsx("span",{className:"persona-sample-who",children:((ee=F.name)==null?void 0:ee.trim())||(E?"agent":H)}),n.jsx("p",{children:I})]}),n.jsxs("span",{className:"muted small",children:["只是「",Yj(F.style),"」的示例;实际怎么说,模型照下面这段来。"]})]}),n.jsxs("div",{className:"field",children:[n.jsx("span",{className:"field-title",children:E?"加到 agent 提示词里的内容":`加到「${H}」提示词里的内容`}),L===""?n.jsx("p",{className:"persona-prompt empty-prompt",children:"什么都不加。"}):n.jsx("div",{className:"persona-prompt",children:L.split(`
|
|
253
|
-
`).map((J,re)=>n.jsx("div",{className:A.has(J)?"":"changed",children:J},re))})]})]})})]})]})]})}function Jj({title:e,note:t,selected:s,wide:i,onClick:r}){return n.jsxs("button",{role:"radio","aria-checked":s,className:`persona-tile ${s?"selected":""} ${i===!0?"wide":""}`,onClick:r,children:[n.jsxs("strong",{children:[e,s&&n.jsx(Q,{name:"check"})]}),n.jsx("span",{className:"muted small",children:t})]})}const jZ={id:"settings-credentials",title:"模型",requires:["credentials","models"],settingsPages:[{id:"api-keys",title:"模型",order:0,component:nZ}]},NZ={id:"permissions",title:"权限",requires:["permissions"],settingsPages:[{id:"permissions",title:"权限",order:1,component:yZ}]},wZ={id:"persona",title:"回复风格",requires:["persona"],settingsPages:[{id:"persona",title:"回复风格",order:2,component:kZ}]},SZ={id:"compaction",title:"对话压缩",requires:["compaction"],settingsPages:[{id:"compaction",title:"对话压缩",order:3,component:oZ}]},_Z={id:"memory",title:"记忆",requires:["memory"],settingsPages:[{id:"memory",title:"记忆",order:2.5,component:hZ}]},EZ={id:"about",title:"关于",requires:[],settingsPages:[{id:"about",title:"关于",order:100,component:P7}]};function CZ({client:e}){const t=_e(e.capabilities),s=_e(e.connection.server),[i,r]=v.useState(0);v.useEffect(()=>pw(()=>r(d=>d+1)),[]);const o=v.useMemo(()=>xO(t),[t,i]),l=o.filter(d=>d.missing.length===0),u=o.filter(d=>d.missing.length>0);return n.jsxs("div",{className:"settings-page",children:[n.jsx("h2",{children:"插件状态"}),n.jsx("p",{children:"界面插件只在后端提供了它需要的能力时启用。后端少装一个插件,对应的界面就自动隐藏。"}),n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"后端能力"}),n.jsx("p",{className:"muted small",children:s===null?"尚未连接":`${s.server.name} ${s.server.version}${s.server.dsh===void 0?"":` · dsh ${s.server.dsh}`}`}),n.jsxs("div",{className:"chip-row",children:[[...t].sort().map(d=>n.jsx("span",{className:"chip",children:d},d)),t.size===0&&n.jsx("span",{className:"muted small",children:"无"})]})]}),n.jsxs("section",{className:"card",children:[n.jsxs("h3",{children:["已启用(",l.length,")"]}),n.jsx("ul",{className:"plugin-list",children:l.map(({plugin:d})=>n.jsxs("li",{children:[n.jsx("span",{className:"plugin-name",children:d.title}),n.jsx("span",{className:"muted small",children:d.requires.length===0?"无需后端能力":d.requires.join(" · ")})]},d.id))})]}),u.length>0&&n.jsxs("section",{className:"card",children:[n.jsxs("h3",{children:["等待后端能力(",u.length,")"]}),n.jsx("ul",{className:"plugin-list",children:u.map(({plugin:d,missing:h})=>n.jsxs("li",{children:[n.jsxs("span",{className:"plugin-name",children:[d.title,d.milestone!==void 0&&n.jsx("span",{className:"chip subtle",children:d.milestone})]}),n.jsxs("span",{className:"muted small",children:["缺少:",h.join(" · ")]})]},d.id))})]})]})}const AZ={id:"plugin-status",title:"插件状态",requires:[],settingsPages:[{id:"plugins",title:"插件状态",order:90,component:CZ}]};function $Z(e,t,s){const i=new Array(e);return new Proxy(i,{get(r,o,l){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 h=r[d];if(!h){const m=t[d*2];h=r[d]={index:d,key:s(d),start:m,size:t[d*2+1],end:m+t[d*2+1],lane:0}}return h}}if(o==="length")return e}return Reflect.get(r,o,l)}})}function No(e,t,s){let i=s.initialDeps??[],r,o=!0;function l(){const u=e();return(u.length!==i.length||u.some((h,m)=>i[m]!==h))&&(i=u,r=t(...u),s!=null&&s.onChange&&!(o&&s.skipInitialOnChange)&&s.onChange(r),o=!1),r}return l.updateDeps=u=>{i=u},l}function eN(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const IZ=(e,t)=>Math.abs(e-t)<1.01,TZ=(e,t,s)=>{let i;return Object.assign(function(...r){e.clearTimeout(i),i=e.setTimeout(()=>t.apply(this,r),s)},{cancel:()=>{e.clearTimeout(i)}})};let Gl;const pp=()=>{if(Gl!==void 0)return Gl;if(typeof navigator>"u")return Gl=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Gl=!0;const e=navigator.maxTouchPoints;return Gl=navigator.platform==="MacIntel"&&e!==void 0&&e>0},tN=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},MZ=e=>e,RZ=e=>{const t=Math.max(e.startIndex-e.overscan,0),i=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(i);for(let o=0;o<i;o++)r[o]=t+o;return r},OZ=(e,t)=>{const s=e.scrollElement;if(!s)return;const i=e.targetWindow;if(!i)return;const r=l=>{const{width:u,height:d}=l;t({width:Math.round(u),height:Math.round(d)})};if(r(tN(s)),!i.ResizeObserver)return()=>{};const o=new i.ResizeObserver(l=>{const u=()=>{const d=l[0];if(d!=null&&d.borderBoxSize){const h=d.borderBoxSize[0];if(h){r({width:h.inlineSize,height:h.blockSize});return}}r(tN(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(s,{box:"border-box"}),()=>{o.unobserve(s)}},Qd={passive:!0},PZ=typeof window>"u"?!0:"onscrollend"in window,LZ=(e,t,s)=>{const i=e.scrollElement;if(!i)return;const r=e.targetWindow;if(!r)return;const o=e.options.useScrollendEvent&&PZ;let l=0;const u=o?null:TZ(r,()=>t(l,!1),e.options.isScrollingResetDelay),d=p=>()=>{l=s(i),u==null||u(),t(l,p)},h=d(!0),m=d(!1);return i.addEventListener("scroll",h,Qd),o&&i.addEventListener("scrollend",m,Qd),()=>{i.removeEventListener("scroll",h),o&&i.removeEventListener("scrollend",m),u==null||u.cancel()}},zZ=(e,t)=>LZ(e,t,s=>{const{horizontal:i,isRtl:r}=e.options;return i?s.scrollLeft*(r&&-1||1):s.scrollTop}),DZ=(e,t,s)=>{if(s.options.useCachedMeasurements){const i=s.indexFromElement(e),r=s.options.getItemKey(i);return s.itemSizeCache.get(r)??s.options.estimateSize(i)}if(t!=null&&t.borderBoxSize){const i=t.borderBoxSize[0];if(i)return Math.round(i[s.options.horizontal?"inlineSize":"blockSize"])}if(!t){const i=s.indexFromElement(e),r=s.options.getItemKey(i),o=s.itemSizeCache.get(r);if(o!==void 0)return o}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},FZ=(e,{adjustments:t=0,behavior:s},i)=>{var r,o;(o=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||o.call(r,{[i.options.horizontal?"left":"top"]:e+t,behavior:s})},UZ=FZ;class BZ{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 s,i,r;return((r=(i=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let s=null;const i=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(o=>{const l=()=>{const u=o.target,d=this.indexFromElement(u);if(!u.isConnected){this.observer.unobserve(u);for(const[h,m]of this.elementsCache)if(m===u){this.elementsCache.delete(h);break}return}this.isIndexInRange(d)&&this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(u,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),s=null},observe:r=>{var o;return(o=i())==null?void 0:o.observe(r,{box:"border-box"})},unobserve:r=>{var o;return(o=i())==null?void 0:o.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{var i,r;const o={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:MZ,rangeExtractor:RZ,onChange:()=>{},measureElement:DZ,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 s){const x=s[g];x!==void 0&&(o[g]=x)}const l=this.options;let u=null,d=null,h=!1;if(l!==void 0&&l.enabled&&o.enabled&&o.anchorTo==="end"&&this.scrollElement!==null){const g=l.count,x=o.count,N=this.getMeasurements(),j=g>0?((i=N[0])==null?void 0:i.key)??l.getItemKey(0):null,y=g>0?((r=N[g-1])==null?void 0:r.key)??l.getItemKey(g-1):null;if(x!==g||g>0&&x>0&&(o.getItemKey(0)!==j||o.getItemKey(x-1)!==y)){h=!0;const S=g>0?this.getVirtualItemForOffset(this.getScrollOffset())??N[0]:null;S&&(u=[S.key,this.getScrollOffset()-S.start]);const E=o.followOnAppend===!0?"auto":o.followOnAppend||null;E&&x>g&&this.isAtEnd(l.scrollEndThreshold)&&(g===0||o.getItemKey(x-1)!==y)&&(d=E)}}this.options=o,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let m=!1,p=0;if(u&&this.scrollOffset!==null){const[g,x]=u,N=this.getMeasurements(),{count:j,getItemKey:y}=this.options;let k=0;for(;k<j&&y(k)!==g;)k++;if(k<j){const _=N[k];if(_){const S=Math.max(0,_.start+x);S!==this.scrollOffset&&(p=S-this.scrollOffset,this.scrollOffset=S,m=!0)}}}(m||d)&&(this.pendingScrollAnchor=[m?u[0]:null,m?u[1]:0,d,p])},this.notify=s=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,s)},this.maybeNotify=No(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{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(s=>s()),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 s;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}if(this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.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,l)=>{if(l&&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=l?u===o?this.scrollDirection:u<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},u=()=>{this._iosTouching=!1,!(!pp()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",l,Qd),o.addEventListener("touchend",u,Qd),this.unsubs.push(()=>{o.removeEventListener("touchstart",l),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 r=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled){const[o,l,u,d]=r;o!==null&&!u&&(pp()&&(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 s=this.getScrollOffset(),i=this.getMaxScrollOffset();if(s<0||s>i)return;if(this._iosDeferredAdjustment<0&&s>=i-1){this._iosDeferredAdjustment=0;return}const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(s,{adjustments:this.scrollAdjustments+=r,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=No(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(s,i,r,o,l,u,d,h)=>(this.prevLanes!==void 0&&this.prevLanes!==u&&(this.lanesChangedFlag=!0),this.prevLanes=u,this.pendingMin=null,{count:s,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:l,lanes:u,laneAssignmentMode:d,gap:h}),{key:!1}),this.isIndexInRange=s=>s>=0&&s<this.options.count,this.getMeasurements=No(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:l,lanes:u,laneAssignmentMode:d,gap:h},m)=>{const p=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const k of this.laneAssignments.keys())k>=s&&this.laneAssignments.delete(k);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(k=>{this.itemSizeCache.set(k.key,k.size)}));const g=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1),u===1){const k=s*2;let _=this._flatMeasurements;if(!_||_.length<k){const O=new Float64Array(k);_&&g>0&&O.set(_.subarray(0,g*2)),_=O,this._flatMeasurements=_}let S;if(g===0)S=i+r;else{const O=g-1;S=_[O*2]+_[O*2+1]+h}for(let O=g;O<s;O++){const P=o(O),H=p.get(P),B=typeof H=="number"?H:this.options.estimateSize(O);_[O*2]=S,_[O*2+1]=B,S+=B+h}const E=$Z(s,_,o);return this.measurementsCache=E,E}const x=this.measurementsCache.slice(0,g),N=new Array(u).fill(void 0),j=new Float64Array(u);let y=0;for(let k=0;k<g;k++){const _=x[k];_&&(N[_.lane]===void 0&&y++,N[_.lane]=k,j[_.lane]=_.end)}for(let k=g;k<s;k++){const _=o(k),S=this.laneAssignments.get(k);let E,O;const P=d==="estimate"||p.has(_);if(S!==void 0&&this.options.lanes>1){E=S;const M=N[E],F=M!==void 0?x[M]:void 0;O=F?F.end+h:i+r}else if(y===u){let M=0,F=j[0],L=N[0];for(let A=1;A<u;A++){const I=j[A];(I<F||I===F&&N[A]<L)&&(M=A,F=I,L=N[A])}E=M,O=F+h,P&&this.laneAssignments.set(k,E)}else E=k%this.options.lanes,O=i+r,P&&this.laneAssignments.set(k,E);const H=p.get(_),B=typeof H=="number"?H:this.options.estimateSize(k),R=O+B;x[k]={index:k,start:O,size:B,end:R,key:_,lane:E},N[E]===void 0&&y++,N[E]=k,j[E]=R}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=No(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,i,r,o)=>s.length===0||i===0?(this.range=null,null):(this.range=ZZ(s,i,r,o,o===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=No(()=>{let s=null,i=null;const r=this.calculateRange();return r&&(s=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,i]},(s,i,r,o,l)=>o===null||l===null?[]:s({startIndex:o,endIndex:l,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const i=this.options.indexAttribute,r=s.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(r!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,r-o),u=Math.min(this.options.count-1,r+o);return s>=l&&s<=u}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((l,u)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(u))});return}const i=this.indexFromElement(s);if(!this.isIndexInRange(i))return;const r=this.options.getItemKey(i),o=this.elementsCache.get(r);o!==s&&(o&&this.observer.unobserve(o),this.observer.observe(s),this.elementsCache.set(r,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,i)=>{var r,o;if(!this.isIndexInRange(s))return;let l,u,d;const h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)d=this.options.getItemKey(s),u=h[s*2],l=h[s*2+1];else{const g=this.measurementsCache[s];if(!g)return;d=g.key,u=g.start,l=g.size}const m=this.itemSizeCache.get(d)??l,p=i-m;if(p!==0){const g=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,x=g?this.getTotalSize():0,N=this.getScrollOffset()+this.scrollAdjustments,y=!this.itemSizeCache.has(d)?u<N:u+m<=N&&this.scrollDirection!=="backward",k=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[s]??{index:s,key:d,start:u,size:l,end:u+l,lane:0},p,this):y);(this.pendingMin===null||s<this.pendingMin)&&(this.pendingMin=s),this.itemSizeCache.set(d,i),this.itemSizeCacheVersion++;let _=!1;g?_=this.applyScrollAdjustment(this.getTotalSize()-x):k&&(_=this.applyScrollAdjustment(p)),this.notify(_)}},this.getVirtualItems=No(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,i)=>{const r=[];for(let o=0,l=s.length;o<l;o++){const u=s[o],d=i[u];r.push(d)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const i=this.getMeasurements();if(i.length===0)return;const r=this._flatMeasurements,o=this.options.lanes===1&&r!=null,l=bE(0,i.length-1,o?u=>r[u*2]:u=>eN(i[u]).start,s);return eN(i[l])},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 s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.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=(s=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=s,this.getOffsetForAlignment=(s,i,r=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),l=this.getScrollOffset();i==="auto"&&(i=s>=l+o?"end":"start"),i==="center"?s+=(r-o)/2:i==="end"&&(s-=o);const u=this.getMaxScrollOffset();return Math.max(Math.min(u,s),0)},this.getOffsetForIndex=(s,i="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.getSize(),o=this.getScrollOffset(),l=this.measurementsCache[s];if(!l)return;if(i==="auto")if(l.end>=o+r-this.options.scrollPaddingEnd)i="end";else if(l.start<=o+this.options.scrollPaddingStart)i="start";else return[o,i];if(i==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),i];const u=i==="end"?l.end+this.options.scrollPaddingEnd:l.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(u,i,l.size),i]},this.scrollToOffset=(s,{align:i="start",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0;const o=this.getOffsetForAlignment(s,i),l=this.now();this.scrollState={index:null,align:i,behavior:r,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:i="auto",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0,s=Math.max(0,Math.min(s,this.options.count-1));const o=this.getOffsetForIndex(s,i);if(!o)return;const[l,u]=o,d=this.now();this.scrollState={index:s,align:u,behavior:r,startedAt:d,lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:i="auto"}={})=>{const r=this.getScrollOffset()+s,o=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:o,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:s="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:s});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:s})},this.getTotalSize=()=>{var s;const i=this.getMeasurements();let r;if(i.length===0)r=this.options.paddingStart;else if(this.options.lanes===1){const o=i.length-1,l=this._flatMeasurements;l!=null?r=l[o*2]+l[o*2+1]:r=((s=i[o])==null?void 0:s.end)??0}else{const o=Array(this.options.lanes).fill(null);let l=i.length-1;for(;l>=0&&o.some(u=>u===null);){const u=i[l];o[u.lane]===null&&(o[u.lane]=u.end),l--}r=Math.max(...o.filter(u=>u!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const s=[];if(this.itemSizeCache.size===0)return s;const i=this.getMeasurements();for(const r of i)r&&this.itemSizeCache.has(r.key)&&s.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return s},this._scrollToOffset=(s,{adjustments:i,behavior:r})=>{this._intendedScrollOffset=s+(i??0),this.options.scrollToFn(s,{behavior:r,adjustments:i},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,s){return t===0?!1:pp()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=t,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:s}),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 i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=i?i[0]:this.scrollState.lastTargetOffset,o=1,l=r!==this.scrollState.lastTargetOffset;if(!l&&IZ(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,l){const u=this.getSize()||600,d=Math.abs(r-this.getScrollOffset()),h=this.scrollState.behavior==="smooth"&&d>u;this.scrollState.lastTargetOffset=r,h||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}}const bE=(e,t,s,i)=>{for(;e<=t;){const r=(e+t)/2|0,o=s(r);if(o<i)e=r+1;else if(o>i)t=r-1;else return r}return e>0?e-1:0};function HZ(e,t,s){let i=0;for(;i<=t;){const r=(i+t)/2|0,o=e[r*2];if(o<s)i=r+1;else if(o>s)t=r-1;else return r}return i>0?i-1:0}function ZZ(e,t,s,i,r){const o=e.length-1;if(e.length<=i)return{startIndex:0,endIndex:o};if(i===1&&r!==null){const h=HZ(r,o,s);let m=h;const p=s+t;for(;m<o&&r[m*2]+r[m*2+1]<p;)m++;return{startIndex:h,endIndex:m}}let u=bE(0,o,h=>e[h].start,s),d=u;if(i===1)for(;d<o&&e[d].end<s+t;)d++;else if(i>1){const h=Array(i).fill(0);for(;d<o&&h.some(p=>p<s+t);){const p=e[d];h[p.lane]=p.end,d++}const m=Array(i).fill(s+t);for(;u>=0&&m.some(p=>p>=s);){const p=e[u];m[p.lane]=p.start,u--}u=Math.max(0,u-u%i),d=Math.min(o,d+(i-1-d%i))}return{startIndex:u,endIndex:d}}const gp=typeof document<"u"?v.useLayoutEffect:v.useEffect;function WZ({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:s="transform",...i}){const r=v.useReducer(m=>m+1,0)[1],o=v.useRef({enabled:t,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=s;const l=m=>{const p=o.current;if(!p.enabled||!p.container)return;const g=m.getTotalSize();if(g!==p.lastSize){p.lastSize=g;const x=m.options.horizontal?"width":"height";p.container.style[x]=`${g}px`}},u=m=>{const p=o.current;if(!p.enabled||!p.container)return;l(m);const g=!!m.options.horizontal,x=p.mode==="transform",N=g?"left":"top",j=m.options.scrollMargin,y=m.getVirtualItems();for(const k of y){const _=k.start-j,S=m.elementsCache.get(k.key);S&&p.lastPositions.get(S)!==_&&(p.lastPositions.set(S,_),x?S.style.transform=g?`translate3d(${_}px, 0, 0)`:`translate3d(0, ${_}px, 0)`:S.style[N]=`${_}px`)}},d={...i,onChange:(m,p)=>{var g;const x=o.current;let N=!0;if(x.enabled){u(m);const j=m.range,y=x.prevRange;N=!y||y.isScrolling!==m.isScrolling||y.startIndex!==(j==null?void 0:j.startIndex)||y.endIndex!==(j==null?void 0:j.endIndex),N&&(x.prevRange=j?{startIndex:j.startIndex,endIndex:j.endIndex,isScrolling:m.isScrolling}:null)}N&&(e&&p?qa.flushSync(r):r()),(g=i.onChange)==null||g.call(i,m,p)}},[h]=v.useState(()=>{const m=new BZ(d);return Object.assign(m,{containerRef:p=>{const g=o.current;if(g.container=p,g.lastSize=null,p&&g.enabled){const x=m.getTotalSize();g.lastSize=x;const N=m.options.horizontal?"width":"height";p.style[N]=`${x}px`}}})});return h.setOptions(d),gp(()=>h._didMount(),[]),gp(()=>(l(h),h._willUpdate())),gp(()=>{u(h)}),h}function VZ(e){return WZ({observeElementRect:OZ,observeElementOffset:zZ,scrollToFn:UZ,...e})}const _h={user:"用户",context:"上下文",system:"系统",assistant:"助手",attempt:"失败尝试",tool:"工具",compaction:"压缩"},kE={ok:"已完成",error:"失败",running:"运行中",interrupted:"已中断"},qZ={completed:"已完成",aborted:"已停止",error:"失败",blocked:"已阻止","max-tokens":"达到输出上限",interrupted:"已中断",forked:"已分叉"};function GZ(e){return e.turn===null?"轮次之间":`第 ${e.turn} 轮`}function KZ(e){return e.end===null?"进行中":e.reason===void 0?"":qZ[e.reason.kind]??e.reason.kind}function jE(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 vc(e){return e.end===null||e.end<e.start?void 0:e.end-e.start}function Jd(e){return e.kind==="assistant"?e.content.filter(t=>t.type==="tool-call").length:0}function YZ({record:e,totals:t,onClose:s}){const i=QZ(e,t),[r,o]=v.useState(i[0].id),l=i.find(u=>u.id===r)??i[0];return n.jsxs("aside",{className:"inspector","aria-label":"事件详情",children:[n.jsxs("header",{className:"inspector-head",children:[n.jsx("span",{className:`kind-badge kind-${e.kind}`,children:_h[e.kind]}),n.jsx("span",{className:"inspector-title",title:e.title,children:XZ(e)}),n.jsx("button",{className:"ghost icon",onClick:s,"aria-label":"关闭详情",children:n.jsx(Q,{name:"close"})})]}),n.jsx("nav",{className:"inspector-tabs",role:"tablist",children:i.map(u=>n.jsx("button",{role:"tab","aria-selected":u.id===l.id,className:u.id===l.id?"active":"",onClick:()=>o(u.id),children:u.label},u.id))}),n.jsx("div",{className:"inspector-body",children:l.render()})]})}function XZ(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 _h[e.kind]}}function QZ(e,t){switch(e.kind){case"assistant":return[{id:"summary",label:"概述",render:()=>n.jsx(JZ,{record:e})},{id:"raw",label:"原始输出",render:()=>n.jsx(xp,{content:e.content})},{id:"usage",label:"用量",render:()=>n.jsx(eW,{record:e,totals:t})},{id:"timing",label:"计时",render:()=>n.jsx(tW,{record:e})}];case"tool":return[{id:"summary",label:"概述",render:()=>n.jsx(Jr,{rows:[["状态",n.jsx(Ed,{record:e})],["工具",n.jsx("code",{children:e.name})],["调用 ID",n.jsx("code",{children:e.callId})],["开始时间",Yr(e.start)],["时长",e.end===null?"运行中":Zs(vc(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:()=>n.jsx("pre",{className:"payload",children:e.arguments===""?"未捕获参数":ux(e.arguments)})},{id:"result",label:"结果",render:()=>e.result===void 0?n.jsx("p",{className:"muted",children:"未捕获结果"}):n.jsx(xp,{content:e.result})}];case"user":case"context":return[{id:"summary",label:"概述",render:()=>n.jsxs(n.Fragment,{children:[n.jsx(Jr,{rows:[["来源",e.origin.human?"用户":e.origin.kind],["时间",Yr(e.start)],["附件",e.imageCount+e.fileCount===0?void 0:`图片 ×${e.imageCount} · 文件 ×${e.fileCount}`]]}),n.jsx("div",{className:"label",children:"预览"}),n.jsx(xp,{content:e.content})]})},{id:"raw",label:"原始内容",render:()=>n.jsx("pre",{className:"payload",children:JSON.stringify(e.content,null,2)})}];case"system":return[{id:"prompt",label:"系统提示词",render:()=>n.jsx("pre",{className:"payload",children:e.text})}];case"attempt":return[{id:"summary",label:"概述",render:()=>n.jsx(Jr,{rows:[["状态",n.jsx(Ed,{record:e})],["开始时间",Yr(e.start)],["时长",Zs(vc(e))],["错误",e.error===void 0?"尝试在没有输出的情况下结束":`${e.error.message}${e.error.code===void 0?"":` (${e.error.code})`}`]]})}];case"compaction":return[{id:"summary",label:"概述",render:()=>n.jsx(Jr,{rows:[["状态",n.jsx(Ed,{record:e})],["开始时间",Yr(e.start)],["时长",e.end===null?"运行中":Zs(vc(e))],["已压缩",e.shadowedTokenCount===void 0?void 0:`${Nn(e.shadowedTokenCount)} tok`],["输入 / 输出",e.usage===void 0?void 0:`${Nn(e.usage.inputTokens)} / ${Nn(e.usage.outputTokens)} tok`],["错误",e.error]]})}]}}function Ed({record:e}){return n.jsx("span",{className:`status-text status-${e.status}`,children:kE[e.status]})}function Jr({rows:e}){return n.jsx("dl",{className:"facts",children:e.filter(([,t])=>t!==void 0&&t!=="").map(([t,s])=>n.jsxs("div",{className:"fact",children:[n.jsx("dt",{children:t}),n.jsx("dd",{children:s})]},t))})}function JZ({record:e}){const t=e.request,s=e.content.filter(r=>r.type==="text").map(r=>r.type==="text"?r.text:"").join(""),i=e.content.filter(r=>r.type==="tool-call");return n.jsxs(n.Fragment,{children:[n.jsx(Jr,{rows:[["状态",n.jsx(Ed,{record:e})],["请求",`#${t.index}`],["提供方",t.provider],["模型",t.model],["推理强度",t.reasoningEffort],["可用工具",t.toolCount===void 0?void 0:String(t.toolCount)],["工具调用",i.length===0?void 0:String(i.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})`}`]]}),s.trim()!==""&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"label",children:"助手消息"}),n.jsx(Hs,{text:s,className:"inspector-markdown"})]}),s.trim()===""&&i.length>0&&n.jsx("p",{className:"muted small",children:"(仅工具调用)"}),i.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"label",children:"工具调用"}),n.jsx("ul",{className:"call-list",children:i.map(r=>n.jsxs("li",{children:[n.jsx("code",{children:r.name})," ",n.jsx("span",{className:"muted",children:r.arguments.slice(0,120)})]},r.callId))})]})]})}function xp({content:e}){return e.length===0?n.jsx("p",{className:"muted",children:"无内容"}):n.jsx("div",{className:"raw-blocks",children:e.map((t,s)=>{switch(t.type){case"reasoning":return n.jsxs("details",{className:"raw-block reasoning-block",children:[n.jsx("summary",{children:"思考"}),n.jsx(Hs,{text:t.text,className:"inspector-markdown"})]},s);case"text":return n.jsx("pre",{className:"payload",children:t.text},s);case"tool-call":return n.jsxs("div",{className:"raw-block",children:[n.jsxs("div",{className:"label",children:["工具调用 · ",n.jsx("code",{children:t.name})]}),n.jsx("pre",{className:"payload",children:ux(t.arguments)})]},s);case"image":return n.jsxs("div",{className:"raw-block muted small",children:["🖼 ",t.name??`图片 ${s+1}`," ",t.width!==void 0?`${t.width}×${t.height}`:""]},s);case"file":return n.jsxs("div",{className:"raw-block muted small",children:["📎 ",t.name??"文件"," ",t.size===void 0?"":`${Nn(t.size)}B`]},s);default:return n.jsxs("div",{className:"raw-block muted small",children:["[",t.kind,"]"]},s)}})})}function eW({record:e,totals:t}){const s=e.request.usage;return n.jsxs(n.Fragment,{children:[n.jsx("h4",{className:"usage-heading",children:"本次请求"}),s===void 0?n.jsx("p",{className:"muted",children:"未报告用量"}):n.jsx(Jr,{rows:[["输入(未缓存)",`${Nn(s.inputTokens)} tok`],["缓存读取",s.cacheReadTokens===void 0?void 0:`${Nn(s.cacheReadTokens)} tok`],["缓存写入",s.cacheWriteTokens===void 0?void 0:`${Nn(s.cacheWriteTokens)} tok`],["输入合计",`${Nn(jE(e))} tok`],["输出",`${Nn(s.outputTokens)} tok`],["其中推理",s.reasoningTokens===void 0?void 0:`${Nn(s.reasoningTokens)} tok`],["总计",s.totalTokens===void 0?void 0:`${Nn(s.totalTokens)} tok`]]}),n.jsx("h4",{className:"usage-heading",children:"已加载窗口累计"}),n.jsx(Jr,{rows:[["模型回复",String(t.requests)],["用量记录(含重试及压缩)",`${t.reportedUsage} 条已报告,${t.missingUsage} 条未知`],["输入(未缓存)",`${Nn(t.inputTokens)} tok`],["缓存读取",`${Nn(t.cacheReadTokens)} tok`],["输出",`${Nn(t.outputTokens)} tok`],["其中推理",`${Nn(t.reasoningTokens)} tok`]]})]})}function tW({record:e}){const[t,s]=v.useState(!1),i=e.request;return n.jsx(Jr,{rows:[["开始时间",n.jsx("button",{className:"link-button",onClick:()=>s(r=>!r),title:t?"显示本地时间":"显示 Unix 时间戳",children:t?String(e.start):Yr(e.start)})],["总时长",e.end===null?"运行中":Zs(vc(e))],["首 token 延迟",i.ttftMs===void 0?"不可用(步骤开始时间或首 token 不在已加载范围内)":Zs(i.ttftMs)],["生成",i.decodeMs===void 0?e.live?"运行中":"不可用":Zs(i.decodeMs)],["吞吐量",i.tokensPerSecond===void 0?i.usage===void 0?"用量不可用":"时长过短":`${i.tokensPerSecond.toFixed(1)} tok/s`],["工具调用",Jd(e)===0?void 0:String(Jd(e))],["计时来源",e.live?"会话时间戳(运行中)":"会话时间戳"]]})}const gd=14,nW=v.memo(function({model:t,mode:s,brush:i,selectedId:r,onBrush:o,onSelect:l}){const u=v.useMemo(()=>qz(t),[t]),d=v.useMemo(()=>vS.map((M,F)=>({...M,index:F})).filter(M=>M.id!=="compaction"||u.some(F=>F.lane===M.index)),[u]),h=new Map(d.map((M,F)=>[M.index,F])),m=t.span,[p,g]=v.useState(null),x=s==="actual"&&m!==null?sW(p,m):null,N=v.useRef(null),[j,y]=v.useState(null),k=v.useRef(null),_=t.records.length,S=(M,F)=>s==="equal"?_===0?0:M/_:x===null||x.end===x.start?0:(F-x.start)/(x.end-x.start),E=M=>{var L;const F=(L=N.current)==null?void 0:L.getBoundingClientRect();return F===void 0||F.width===0?0:Math.min(1,Math.max(0,(M-F.left)/F.width))},O=M=>{if(M.button===2&&x!==null&&m!==null&&(x.start>m.start||x.end<m.end)){k.current={x:M.clientX,view:x};return}if(M.button!==0)return;const F=E(M.clientX);y({x0:F,x1:F})},P=M=>{if(k.current!==null&&m!==null&&N.current!==null){const F=(M.clientX-k.current.x)/N.current.clientWidth,L=k.current.view.end-k.current.view.start;g(Yz(k.current.view,-F*L,m));return}j!==null&&y({...j,x1:E(M.clientX)})},H=()=>{if(k.current=null,j===null)return;const[M,F]=j.x0<j.x1?[j.x0,j.x1]:[j.x1,j.x0];if(y(null),!(F-M<.005)){if(s==="equal")o({mode:"equal",from:Math.floor(M*_),to:Math.max(Math.floor(M*_),Math.ceil(F*_)-1)});else if(x!==null){const L=x.end-x.start;o({mode:"actual",range:{start:x.start+M*L,end:x.start+F*L}})}}},B=M=>{if(s!=="actual"||x===null||m===null)return;const F=x.end-x.start;g(Kz(x,x.start+E(M.clientX)*F,M.deltaY>0?1.25:.8,m))};if(_===0||m===null)return n.jsx("div",{className:"overview empty-overview muted small",children:"无计时数据"});const R=i===null?null:i.mode==="equal"?s==="equal"?{left:i.from/_,right:(i.to+1)/_}:null:s==="actual"?{left:S(0,i.range.start),right:S(0,i.range.end)}:null;return n.jsxs("div",{className:"overview",onContextMenu:M=>{M.preventDefault(),k.current===null&&o(null)},children:[n.jsx("div",{className:"overview-lanes",children:d.map(M=>n.jsx("div",{className:"lane-label",style:{height:gd},children:iW(M.id)},M.id))}),n.jsxs("div",{className:"overview-track",ref:N,style:{height:d.length*(gd+2)},onMouseDown:O,onMouseMove:P,onMouseUp:H,onMouseLeave:H,onWheel:B,children:[u.map((M,F)=>{const L=h.get(M.lane)??0,A=S(F,M.start),I=s==="equal"?(F+1)/_:S(F,M.end);if(I<0||A>1)return null;const z=M.record,D=Math.max(0,Math.min(1,I)-Math.max(0,A)),V=s==="actual"&&M.firstTokenAt!==void 0&&M.end>M.start?(M.firstTokenAt-M.start)/(M.end-M.start):null;return n.jsx("div",{className:`bar kind-${z.kind} status-${z.status} ${M.instant&&s==="actual"?"instant":""} ${z.id===r?"selected":""}`,style:{left:`${Math.max(0,A)*100}%`,width:s==="equal"?`calc(${D*100}% - 1px)`:`max(2px, ${D*100}%)`,top:L*(gd+2),height:gd,...V===null?{}:{"--ttft":`${Math.min(100,Math.max(0,V*100))}%`}},title:rW(z,M.firstTokenAt),onMouseUp:U=>{j!==null&&Math.abs(j.x1-j.x0)<.005&&U.button===0&&l(z)}},z.id)}),R!==null&&n.jsx("div",{className:"brush",style:{left:`${Math.max(0,R.left)*100}%`,width:`${(Math.min(1,R.right)-Math.max(0,R.left))*100}%`}}),j!==null&&n.jsx("div",{className:"brush dragging",style:{left:`${Math.min(j.x0,j.x1)*100}%`,width:`${Math.abs(j.x1-j.x0)*100}%`}})]}),n.jsx("div",{className:"overview-scale muted",children:s==="actual"&&x!==null?n.jsxs(n.Fragment,{children:[n.jsx("span",{children:Yr(x.start)}),n.jsxs("span",{children:["总计 ",Zs(m.end-m.start),p!==null?" · 已缩放":""]}),n.jsx("span",{children:Yr(x.end)})]}):n.jsxs(n.Fragment,{children:[n.jsxs("span",{children:[_," 条记录(等宽)"]}),n.jsxs("span",{children:["总计 ",Zs(m.end-m.start)]}),n.jsx("span",{children:"拖动选择区间 · 右键清除"})]})})]})});function sW(e,t){if(e===null)return t;const s=Math.max(t.start,e.start),i=Math.min(t.end,e.end);return i>s?{start:s,end:i}:t}function iW(e){return e==="input"?"输入":e==="model"?"模型":e==="tool"?"工具":"压缩"}function rW(e,t){const s=[`${_h[e.kind]} · ${e.title}`,`开始于 ${Yr(e.start)}`];return e.end===null?s.push("进行中(只显示开始标记)"):s.push(`总计 ${Zs(e.end-e.start)}`),e.kind==="assistant"&&t!==void 0&&e.end!==null&&s.push(`首 token ${Zs(t-e.start)} · 解码 ${Zs(e.end-t)}`),s.join(`
|
|
254
|
-
`)}const aW=32,oW=34,lW=60;function cW({session:e,state:t}){const s=v.useMemo(()=>Fz(t.events,t.live,{now:Date.now()}),[t.events,t.live,t.version]),[i,r]=v.useState("equal"),[o,l]=v.useState(null),[u,d]=v.useState(""),[h,m]=v.useState(new Set),[p,g]=v.useState(!0),[x,N]=v.useState(null),j=s.records.find(M=>M.id===x)??null,y=v.useMemo(()=>uW(s,{brush:o,query:u,collapsed:h,showCalls:p}),[s,o,u,h,p]),k=v.useMemo(()=>y.flatMap(M=>M.type==="record"?[M.record]:[]),[y]),_=v.useRef(null),S=xS(lW),E=S.following,O=VZ({count:y.length,getScrollElement:()=>_.current,estimateSize:M=>{var F;return((F=y[M])==null?void 0:F.type)==="group"?oW:aW},getItemKey:M=>{var F;return((F=y[M])==null?void 0:F.key)??M},overscan:12});v.useLayoutEffect(()=>{E.current&&y.length>0&&O.scrollToIndex(y.length-1,{align:"end"})},[y.length,t.version,O]),v.useEffect(()=>{if(x===null)return;const M=y.findIndex(F=>F.type==="record"&&F.record.id===x);M!==-1&&O.scrollToIndex(M,{align:"auto"})},[x]);const P=M=>m(F=>{const L=new Set(F);return L.has(M)?L.delete(M):L.add(M),L}),H=s.groups.length>0&&s.groups.every(M=>h.has(M.key)),B=M=>{if(M.key!=="ArrowDown"&&M.key!=="ArrowUp"&&M.key!=="Escape")return;if(M.preventDefault(),M.key==="Escape"){N(null);return}const F=k.findIndex(A=>A.id===x),L=k[M.key==="ArrowDown"?Math.min(k.length-1,F+1):Math.max(0,F-1)];L!==void 0&&N(L.id)},R=s.totals;return n.jsxs("div",{className:"trajectory",children:[n.jsxs("div",{className:"traj-toolbar",role:"toolbar","aria-label":"轨迹工具栏",children:[n.jsxs("button",{className:`toggle ${i==="actual"?"on":""}`,onClick:()=>{r(M=>M==="equal"?"actual":"equal"),l(null)},title:i==="equal"?"使用实际时长":"使用等宽操作",children:["⏱ ",i==="equal"?"等宽":"实际时间"]}),n.jsxs("button",{className:"toggle",onClick:()=>m(H?new Set:new Set(s.groups.map(M=>M.key))),children:["⊟ ",H?"展开所有轮次":"收起所有轮次"]}),n.jsxs("button",{className:`toggle ${p?"":"on"}`,onClick:()=>g(M=>!M),children:["⊟ ",p?"收起所有调用":"展开所有调用"]}),n.jsx("input",{className:"traj-search",value:u,onChange:M=>d(M.target.value),placeholder:"搜索轨迹","aria-label":"搜索轨迹"}),n.jsxs("span",{className:"traj-totals muted small",title:"已加载窗口内的累计",children:[R.requests," 次请求 · 输入 ",Nn(R.inputTokens+R.cacheReadTokens+R.cacheWriteTokens)," · 输出 ",Nn(R.outputTokens)," · ",R.toolCalls," 次工具调用",R.errors>0?` · ${R.errors} 个错误`:""]})]}),n.jsx(nW,{model:s,mode:i,brush:o,selectedId:x,onBrush:l,onSelect:M=>N(M.id)}),o!==null&&n.jsxs("div",{className:"brush-note small",children:["已按时间区间筛选,显示 ",k.length," 条记录 ",n.jsx("button",{className:"link-button",onClick:()=>l(null),children:"清除"})]}),n.jsxs("div",{className:"traj-main",children:[n.jsxs("div",{className:"ledger",ref:_,onScroll:S.onScroll,onWheel:S.onWheel,tabIndex:0,onKeyDown:B,role:"grid","aria-label":"轨迹事件表",children:[n.jsxs("div",{className:"ledger-head",role:"row",children:[n.jsx("span",{}),n.jsx("span",{children:"类型"}),n.jsx("span",{children:"内容"}),n.jsx("span",{className:"num",children:"输入"}),n.jsx("span",{className:"num",children:"输出"}),n.jsx("span",{className:"num",children:"思考"}),n.jsx("span",{className:"num",children:"时间"}),n.jsx("span",{children:"模型"}),n.jsx("span",{className:"num",children:"工具"})]}),t.hasMore&&n.jsx("button",{className:"link-button load-older",disabled:t.loadingOlder,onClick:()=>void e.loadOlder(),children:t.loadingOlder?"正在加载更早的历史…":"加载更早的历史"}),y.length===0&&n.jsx("div",{className:"empty",children:t.status==="opening"?"正在加载轨迹…":u!==""?"没有匹配的记录":"还没有记录"}),n.jsx("div",{style:{height:O.getTotalSize(),position:"relative"},children:O.getVirtualItems().map(M=>{const F=y[M.index];return n.jsx("div",{className:"vrow",style:{transform:`translateY(${M.start}px)`,height:M.size},children:F.type==="group"?n.jsx(dW,{row:F,onToggle:()=>P(F.group.key)}):n.jsx(hW,{row:F,selected:F.record.id===x,onSelect:()=>N(L=>L===F.record.id?null:F.record.id)})},M.key)})})]}),j!==null&&n.jsx(YZ,{record:j,totals:s.totals,onClose:()=>N(null)},j.id)]})]})}function uW(e,t){const s=new Set;let i=e.records;if(t.brush!==null){const l=t.brush;i=l.mode==="equal"?i.slice(l.from,l.to+1):i.filter(u=>Gz(u,l.range))}for(const l of Xz(i,t.query))s.add(l.id);const r=t.brush!==null||t.query.trim()!=="",o=[];for(const l of e.groups){const u=l.records.filter(m=>s.has(m.id)&&(t.showCalls||m.kind!=="tool"));if(r&&u.length===0)continue;const d=t.collapsed.has(l.key);if(o.push({type:"group",key:`g:${l.key}`,group:l,collapsed:d,matches:u.length}),d)continue;let h=null;for(const m of u){const p=m.step!==null&&m.step!==h?m.step:null;m.step!==null&&(h=m.step),o.push({type:"record",key:m.id,record:m,stepStart:p})}}return o}const dW=v.memo(function({row:t,onToggle:s}){var u,d;const i=t.group,r=i.records.filter(h=>h.kind==="tool").length,o=i.end===null?null:i.end-i.start,l=KZ(i);return n.jsxs("button",{className:`group-row ${i.end===null?"open":""} reason-${((u=i.reason)==null?void 0:u.kind)??"none"}`,onClick:s,"aria-expanded":!t.collapsed,children:[n.jsx("span",{className:"chevron",children:t.collapsed?"▸":"▾"}),n.jsx("span",{className:"group-title",children:GZ(i)}),n.jsxs("span",{className:"muted small",children:[i.steps.length>0&&`${i.steps.length} 个步骤`,r>0&&` · ${r} 个工具调用`,o!==null&&` · ${Zs(o)}`,i.partialStart&&" · 开头在已加载范围之外"]}),l!==""&&n.jsx("span",{className:`group-reason reason-${i.end===null?"running":((d=i.reason)==null?void 0:d.kind)??"none"}`,children:l})]})}),hW=v.memo(function({row:t,selected:s,onSelect:i}){var u;const r=t.record,o=r.kind==="assistant",l=vc(r);return n.jsxs("div",{className:`record-row kind-${r.kind} status-${r.status} ${s?"selected":""} ${t.stepStart!==null?"step-start":""}`,onClick:i,role:"row","aria-selected":s,children:[n.jsx("span",{className:"gutter muted",children:t.stepStart!==null?`第 ${t.stepStart} 步`:""}),n.jsx("span",{children:n.jsx("span",{className:`kind-badge kind-${r.kind}`,children:o?`#${r.request.index}`:_h[r.kind]})}),n.jsxs("span",{className:"record-content",title:r.preview,children:[r.status==="running"&&n.jsx("span",{className:"running-dot"}),r.status==="error"&&n.jsxs("span",{className:"status-text status-error",children:[kE.error," · "]}),r.kind==="tool"?n.jsxs(n.Fragment,{children:[n.jsx("code",{className:"tool-name-inline",children:r.name})," ",n.jsx("span",{className:"muted",children:r.preview})]}):r.preview||n.jsx("span",{className:"muted",children:"(无内容)"})]}),n.jsx("span",{className:"num",children:o?Nn(jE(r)):""}),n.jsx("span",{className:"num",children:o&&r.request.usage!==void 0?Nn(r.request.usage.outputTokens):""}),n.jsx("span",{className:"num",children:o&&((u=r.request.usage)==null?void 0:u.reasoningTokens)!==void 0?Nn(r.request.usage.reasoningTokens):""}),n.jsx("span",{className:"num",children:r.status==="running"?"…":l!==void 0&&(o||r.kind==="tool"||r.kind==="compaction"||r.kind==="attempt")?Zs(l):""}),n.jsx("span",{className:"model-cell",children:o?r.request.model??"":""}),n.jsx("span",{className:"num",children:o&&Jd(r)>0?Jd(r):""})]})}),mW={id:"trajectory",title:"轨迹",requires:["sessions"],sessionViews:[{id:"trajectory",title:"轨迹",order:10,component:cW}]};a1();Vs()===void 0&&document.documentElement.classList.add("own-title-bar");mh&&document.documentElement.classList.add("in-dsh");Bn(I5);Bn(mW);Bn(jZ);Bn(NZ);Bn(wZ);Bn(_Z);Bn(SZ);Bn(EZ);Bn(AZ);Bn(R7);Bn(O7);Bn(Y5);Bn(X5);Bn($8);Bn(I8);Bn(D8);Bn(e7);for(const e of T5)Bn(e);const NE=aA.createRoot(document.getElementById("root"));function vp(e){const t=new aO({url:g5(e),clientInfo:{name:"adg-web",version:"0.1.0"}});t.start(),NE.render(n.jsxs(E5,{children:[n.jsx(v5,{client:t}),n.jsx(_5,{client:t}),n.jsx(bz,{}),n.jsx($5,{})]}))}const nN=mh?null:f5();mh?vp(null):nN===null?NE.render(n.jsx(j5,{onSubmit:e=>{p5(e),vp(e)}})):vp(nN);
|
|
255
|
-
//# sourceMappingURL=index-YiJ--jV1.js.map
|