dsh-multigameassistant 2.1.1 → 2.2.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.
Files changed (45) hide show
  1. package/cordis.patch.yml +16 -1
  2. package/lib/analyzer.js +37 -81
  3. package/lib/browser.js +1 -1
  4. package/lib/{chunk-5PDYWE24.js → chunk-26JIEF6M.js} +153 -5
  5. package/lib/{chunk-SHTX4AGU.js → chunk-6DSSLS7I.js} +26 -0
  6. package/lib/{chunk-VOTN4IHB.js → chunk-EKTA4OYC.js} +3 -3
  7. package/lib/{chunk-UQLHGLMP.js → chunk-I4NHWXKH.js} +3 -3
  8. package/lib/{chunk-FBDVN6Q2.js → chunk-ICJLH3DP.js} +1 -1
  9. package/lib/chunk-J4QJC6UZ.js +22944 -0
  10. package/lib/chunk-J4QJC6UZ.js.LEGAL.txt +8 -0
  11. package/lib/{chunk-MQG5FLOG.js → chunk-KTOQFJ7R.js} +381 -36
  12. package/lib/{chunk-NM6H6WCQ.js → chunk-NEUZQ7TI.js} +237 -16
  13. package/lib/emulator.js +2 -2
  14. package/lib/feishu.js +5 -5
  15. package/lib/game-intel.js +454 -57
  16. package/lib/gateway.js +14 -6
  17. package/lib/guard.js +2 -2
  18. package/lib/intervene.js +8 -6
  19. package/lib/low-context.js +3 -3
  20. package/lib/monitor.js +4 -4
  21. package/lib/notify.js +5 -5
  22. package/lib/orchestrator.js +8 -8
  23. package/lib/qqbot.js +5 -5
  24. package/lib/runner.js +4 -4
  25. package/lib/scheduler.js +2 -2
  26. package/lib/script-registry.js +33 -3705
  27. package/lib/webapi-GDSF5EWP.js +2481 -0
  28. package/package.json +1 -1
  29. package/skills/game-intel.md +9 -1
  30. package/skills/script-analysis.md +30 -3
  31. package/skills/web-reading.md +7 -2
  32. package/web/assets/index-C5cMI4PK.css +1 -0
  33. package/web/assets/index-ClYIoZUR.js +244 -0
  34. package/web/assets/index-ClYIoZUR.js.map +1 -0
  35. package/web/index.html +2 -2
  36. package/lib/chunk-RFCFA5P5.js +0 -11
  37. package/lib/games/arknights/game.yaml +0 -36
  38. package/lib/games/endfield/game.yaml +0 -25
  39. package/lib/games/starrail/game.yaml +0 -33
  40. package/lib/packs/maa/adg.script.yaml +0 -220
  41. package/lib/packs/maaend/adg.script.yaml +0 -160
  42. package/lib/packs/march7th/adg.script.yaml +0 -216
  43. package/web/assets/index-CL3SeTW9.css +0 -1
  44. package/web/assets/index-GYwpGP3f.js +0 -244
  45. package/web/assets/index-GYwpGP3f.js.map +0 -1
@@ -0,0 +1,244 @@
1
+ var PC=Object.defineProperty;var ey=e=>{throw TypeError(e)};var LC=(e,t,s)=>t in e?PC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var dt=(e,t,s)=>LC(e,typeof t!="symbol"?t+"":t,s),Gm=(e,t,s)=>t.has(e)||ey("Cannot "+s);var Le=(e,t,s)=>(Gm(e,t,"read from private field"),s?s.call(e):t.get(e)),Ht=(e,t,s)=>t.has(e)?ey("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),Kt=(e,t,s,i)=>(Gm(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),yt=(e,t,s)=>(Gm(e,t,"access private method"),s);var ty=(e,t,s,i)=>({set _(r){Kt(e,t,r,s)},get _(){return Le(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 Km={exports:{}},Tl={},Ym={exports:{}},bt={};/**
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 ny;function zC(){if(ny)return bt;ny=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"),f=Symbol.for("react.lazy"),p=Symbol.iterator;function g(Z){return Z===null||typeof Z!="object"?null:(Z=p&&Z[p]||Z["@@iterator"],typeof Z=="function"?Z:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,k={};function j(Z,Q,G){this.props=Z,this.context=Q,this.refs=k,this.updater=G||x}j.prototype.isReactComponent={},j.prototype.setState=function(Z,Q){if(typeof Z!="object"&&typeof Z!="function"&&Z!=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,Z,Q,"setState")},j.prototype.forceUpdate=function(Z){this.updater.enqueueForceUpdate(this,Z,"forceUpdate")};function N(){}N.prototype=j.prototype;function C(Z,Q,G){this.props=Z,this.context=Q,this.refs=k,this.updater=G||x}var S=C.prototype=new N;S.constructor=C,b(S,j.prototype),S.isPureReactComponent=!0;var _=Array.isArray,z=Object.prototype.hasOwnProperty,P={current:null},H={key:!0,ref:!0,__self:!0,__source:!0};function B(Z,Q,G){var ne,te={},re=null,X=null;if(Q!=null)for(ne in Q.ref!==void 0&&(X=Q.ref),Q.key!==void 0&&(re=""+Q.key),Q)z.call(Q,ne)&&!H.hasOwnProperty(ne)&&(te[ne]=Q[ne]);var se=arguments.length-2;if(se===1)te.children=G;else if(1<se){for(var ae=Array(se),_e=0;_e<se;_e++)ae[_e]=arguments[_e+2];te.children=ae}if(Z&&Z.defaultProps)for(ne in se=Z.defaultProps,se)te[ne]===void 0&&(te[ne]=se[ne]);return{$$typeof:e,type:Z,key:re,ref:X,props:te,_owner:P.current}}function O(Z,Q){return{$$typeof:e,type:Z.type,key:Q,ref:Z.ref,props:Z.props,_owner:Z._owner}}function T(Z){return typeof Z=="object"&&Z!==null&&Z.$$typeof===e}function D(Z){var Q={"=":"=0",":":"=2"};return"$"+Z.replace(/[=:]/g,function(G){return Q[G]})}var U=/\/+/g;function A(Z,Q){return typeof Z=="object"&&Z!==null&&Z.key!=null?D(""+Z.key):Q.toString(36)}function I(Z,Q,G,ne,te){var re=typeof Z;(re==="undefined"||re==="boolean")&&(Z=null);var X=!1;if(Z===null)X=!0;else switch(re){case"string":case"number":X=!0;break;case"object":switch(Z.$$typeof){case e:case t:X=!0}}if(X)return X=Z,te=te(X),Z=ne===""?"."+A(X,0):ne,_(te)?(G="",Z!=null&&(G=Z.replace(U,"$&/")+"/"),I(te,Q,G,"",function(_e){return _e})):te!=null&&(T(te)&&(te=O(te,G+(!te.key||X&&X.key===te.key?"":(""+te.key).replace(U,"$&/")+"/")+Z)),Q.push(te)),1;if(X=0,ne=ne===""?".":ne+":",_(Z))for(var se=0;se<Z.length;se++){re=Z[se];var ae=ne+A(re,se);X+=I(re,Q,G,ae,te)}else if(ae=g(Z),typeof ae=="function")for(Z=ae.call(Z),se=0;!(re=Z.next()).done;)re=re.value,ae=ne+A(re,se++),X+=I(re,Q,G,ae,te);else if(re==="object")throw Q=String(Z),Error("Objects are not valid as a React child (found: "+(Q==="[object Object]"?"object with keys {"+Object.keys(Z).join(", ")+"}":Q)+"). If you meant to render a collection of children, use an array instead.");return X}function R(Z,Q,G){if(Z==null)return Z;var ne=[],te=0;return I(Z,ne,"","",function(re){return Q.call(G,re,te++)}),ne}function L(Z){if(Z._status===-1){var Q=Z._result;Q=Q(),Q.then(function(G){(Z._status===0||Z._status===-1)&&(Z._status=1,Z._result=G)},function(G){(Z._status===0||Z._status===-1)&&(Z._status=2,Z._result=G)}),Z._status===-1&&(Z._status=0,Z._result=Q)}if(Z._status===1)return Z._result.default;throw Z._result}var K={current:null},F={transition:null},q={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:F,ReactCurrentOwner:P};function V(){throw Error("act(...) is not supported in production builds of React.")}return bt.Children={map:R,forEach:function(Z,Q,G){R(Z,function(){Q.apply(this,arguments)},G)},count:function(Z){var Q=0;return R(Z,function(){Q++}),Q},toArray:function(Z){return R(Z,function(Q){return Q})||[]},only:function(Z){if(!T(Z))throw Error("React.Children.only expected to receive a single React element child.");return Z}},bt.Component=j,bt.Fragment=s,bt.Profiler=r,bt.PureComponent=C,bt.StrictMode=i,bt.Suspense=d,bt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,bt.act=V,bt.cloneElement=function(Z,Q,G){if(Z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+Z+".");var ne=b({},Z.props),te=Z.key,re=Z.ref,X=Z._owner;if(Q!=null){if(Q.ref!==void 0&&(re=Q.ref,X=P.current),Q.key!==void 0&&(te=""+Q.key),Z.type&&Z.type.defaultProps)var se=Z.type.defaultProps;for(ae in Q)z.call(Q,ae)&&!H.hasOwnProperty(ae)&&(ne[ae]=Q[ae]===void 0&&se!==void 0?se[ae]:Q[ae])}var ae=arguments.length-2;if(ae===1)ne.children=G;else if(1<ae){se=Array(ae);for(var _e=0;_e<ae;_e++)se[_e]=arguments[_e+2];ne.children=se}return{$$typeof:e,type:Z.type,key:te,ref:re,props:ne,_owner:X}},bt.createContext=function(Z){return Z={$$typeof:l,_currentValue:Z,_currentValue2:Z,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},Z.Provider={$$typeof:o,_context:Z},Z.Consumer=Z},bt.createElement=B,bt.createFactory=function(Z){var Q=B.bind(null,Z);return Q.type=Z,Q},bt.createRef=function(){return{current:null}},bt.forwardRef=function(Z){return{$$typeof:u,render:Z}},bt.isValidElement=T,bt.lazy=function(Z){return{$$typeof:f,_payload:{_status:-1,_result:Z},_init:L}},bt.memo=function(Z,Q){return{$$typeof:h,type:Z,compare:Q===void 0?null:Q}},bt.startTransition=function(Z){var Q=F.transition;F.transition={};try{Z()}finally{F.transition=Q}},bt.unstable_act=V,bt.useCallback=function(Z,Q){return K.current.useCallback(Z,Q)},bt.useContext=function(Z){return K.current.useContext(Z)},bt.useDebugValue=function(){},bt.useDeferredValue=function(Z){return K.current.useDeferredValue(Z)},bt.useEffect=function(Z,Q){return K.current.useEffect(Z,Q)},bt.useId=function(){return K.current.useId()},bt.useImperativeHandle=function(Z,Q,G){return K.current.useImperativeHandle(Z,Q,G)},bt.useInsertionEffect=function(Z,Q){return K.current.useInsertionEffect(Z,Q)},bt.useLayoutEffect=function(Z,Q){return K.current.useLayoutEffect(Z,Q)},bt.useMemo=function(Z,Q){return K.current.useMemo(Z,Q)},bt.useReducer=function(Z,Q,G){return K.current.useReducer(Z,Q,G)},bt.useRef=function(Z){return K.current.useRef(Z)},bt.useState=function(Z){return K.current.useState(Z)},bt.useSyncExternalStore=function(Z,Q,G){return K.current.useSyncExternalStore(Z,Q,G)},bt.useTransition=function(){return K.current.useTransition()},bt.version="18.3.1",bt}var sy;function Pc(){return sy||(sy=1,Ym.exports=zC()),Ym.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 iy;function DC(){if(iy)return Tl;iy=1;var e=Pc(),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 f,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(f in d)i.call(d,f)&&!o.hasOwnProperty(f)&&(p[f]=d[f]);if(u&&u.defaultProps)for(f in d=u.defaultProps,d)p[f]===void 0&&(p[f]=d[f]);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 ry;function FC(){return ry||(ry=1,Km.exports=DC()),Km.exports}var n=FC(),Zu={},Xm={exports:{}},Cs={},Qm={exports:{}},Jm={};/**
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 ay;function UC(){return ay||(ay=1,(function(e){function t(F,q){var V=F.length;F.push(q);e:for(;0<V;){var Z=V-1>>>1,Q=F[Z];if(0<r(Q,q))F[Z]=q,F[V]=Q,V=Z;else break e}}function s(F){return F.length===0?null:F[0]}function i(F){if(F.length===0)return null;var q=F[0],V=F.pop();if(V!==q){F[0]=V;e:for(var Z=0,Q=F.length,G=Q>>>1;Z<G;){var ne=2*(Z+1)-1,te=F[ne],re=ne+1,X=F[re];if(0>r(te,V))re<Q&&0>r(X,te)?(F[Z]=X,F[re]=V,Z=re):(F[Z]=te,F[ne]=V,Z=ne);else if(re<Q&&0>r(X,V))F[Z]=X,F[re]=V,Z=re;else break e}}return q}function r(F,q){var V=F.sortIndex-q.sortIndex;return V!==0?V:F.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=[],f=1,p=null,g=3,x=!1,b=!1,k=!1,j=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,C=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(F){for(var q=s(h);q!==null;){if(q.callback===null)i(h);else if(q.startTime<=F)i(h),q.sortIndex=q.expirationTime,t(d,q);else break;q=s(h)}}function _(F){if(k=!1,S(F),!b)if(s(d)!==null)b=!0,L(z);else{var q=s(h);q!==null&&K(_,q.startTime-F)}}function z(F,q){b=!1,k&&(k=!1,N(B),B=-1),x=!0;var V=g;try{for(S(q),p=s(d);p!==null&&(!(p.expirationTime>q)||F&&!D());){var Z=p.callback;if(typeof Z=="function"){p.callback=null,g=p.priorityLevel;var Q=Z(p.expirationTime<=q);q=e.unstable_now(),typeof Q=="function"?p.callback=Q:p===s(d)&&i(d),S(q)}else i(d);p=s(d)}if(p!==null)var G=!0;else{var ne=s(h);ne!==null&&K(_,ne.startTime-q),G=!1}return G}finally{p=null,g=V,x=!1}}var P=!1,H=null,B=-1,O=5,T=-1;function D(){return!(e.unstable_now()-T<O)}function U(){if(H!==null){var F=e.unstable_now();T=F;var q=!0;try{q=H(!0,F)}finally{q?A():(P=!1,H=null)}}else P=!1}var A;if(typeof C=="function")A=function(){C(U)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,R=I.port2;I.port1.onmessage=U,A=function(){R.postMessage(null)}}else A=function(){j(U,0)};function L(F){H=F,P||(P=!0,A())}function K(F,q){B=j(function(){F(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(F){F.callback=null},e.unstable_continueExecution=function(){b||x||(b=!0,L(z))},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return s(d)},e.unstable_next=function(F){switch(g){case 1:case 2:case 3:var q=3;break;default:q=g}var V=g;g=q;try{return F()}finally{g=V}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(F,q){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var V=g;g=F;try{return q()}finally{g=V}},e.unstable_scheduleCallback=function(F,q,V){var Z=e.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?Z+V:Z):V=Z,F){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=V+Q,F={id:f++,callback:q,priorityLevel:F,startTime:V,expirationTime:Q,sortIndex:-1},V>Z?(F.sortIndex=V,t(h,F),s(d)===null&&F===s(h)&&(k?(N(B),B=-1):k=!0,K(_,V-Z))):(F.sortIndex=Q,t(d,F),b||x||(b=!0,L(z))),F},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(F){var q=g;return function(){var V=g;g=q;try{return F.apply(this,arguments)}finally{g=V}}}})(Jm)),Jm}var oy;function BC(){return oy||(oy=1,Qm.exports=UC()),Qm.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 ly;function HC(){if(ly)return Cs;ly=1;var e=Pc(),t=BC();function s(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,m=1;m<arguments.length;m++)c+="&args[]="+encodeURIComponent(arguments[m]);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]*$/,f={},p={};function g(a){return d.call(p,a)?!0:d.call(f,a)?!1:h.test(a)?p[a]=!0:(f[a]=!0,!1)}function x(a,c,m,y){if(m!==null&&m.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return y?!1:m!==null?!m.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function b(a,c,m,y){if(c===null||typeof c>"u"||x(a,c,m,y))return!0;if(y)return!1;if(m!==null)switch(m.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 k(a,c,m,y,E,$,W){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=y,this.attributeNamespace=E,this.mustUseProperty=m,this.propertyName=a,this.type=c,this.sanitizeURL=$,this.removeEmptyString=W}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){j[a]=new k(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var c=a[0];j[c]=new k(c,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){j[a]=new k(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){j[a]=new k(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){j[a]=new k(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){j[a]=new k(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){j[a]=new k(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){j[a]=new k(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){j[a]=new k(a,5,!1,a.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function C(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(N,C);j[c]=new k(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(N,C);j[c]=new k(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(N,C);j[c]=new k(c,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){j[a]=new k(a,1,!1,a.toLowerCase(),null,!1,!1)}),j.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){j[a]=new k(a,1,!1,a.toLowerCase(),null,!0,!0)});function S(a,c,m,y){var E=j.hasOwnProperty(c)?j[c]:null;(E!==null?E.type!==0:y||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(b(c,m,E,y)&&(m=null),y||E===null?g(c)&&(m===null?a.removeAttribute(c):a.setAttribute(c,""+m)):E.mustUseProperty?a[E.propertyName]=m===null?E.type===3?!1:"":m:(c=E.attributeName,y=E.attributeNamespace,m===null?a.removeAttribute(c):(E=E.type,m=E===3||E===4&&m===!0?"":""+m,y?a.setAttributeNS(y,c,m):a.setAttribute(c,m))))}var _=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,z=Symbol.for("react.element"),P=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),T=Symbol.for("react.provider"),D=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),F=Symbol.iterator;function q(a){return a===null||typeof a!="object"?null:(a=F&&a[F]||a["@@iterator"],typeof a=="function"?a:null)}var V=Object.assign,Z;function Q(a){if(Z===void 0)try{throw Error()}catch(m){var c=m.stack.trim().match(/\n( *(at )?)/);Z=c&&c[1]||""}return`
34
+ `+Z+a}var G=!1;function ne(a,c){if(!a||G)return"";G=!0;var m=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(xe){var y=xe}Reflect.construct(a,[],c)}else{try{c.call()}catch(xe){y=xe}a.call(c.prototype)}else{try{throw Error()}catch(xe){y=xe}a()}}catch(xe){if(xe&&y&&typeof xe.stack=="string"){for(var E=xe.stack.split(`
35
+ `),$=y.stack.split(`
36
+ `),W=E.length-1,ie=$.length-1;1<=W&&0<=ie&&E[W]!==$[ie];)ie--;for(;1<=W&&0<=ie;W--,ie--)if(E[W]!==$[ie]){if(W!==1||ie!==1)do if(W--,ie--,0>ie||E[W]!==$[ie]){var oe=`
37
+ `+E[W].replace(" at new "," at ");return a.displayName&&oe.includes("<anonymous>")&&(oe=oe.replace("<anonymous>",a.displayName)),oe}while(1<=W&&0<=ie);break}}}finally{G=!1,Error.prepareStackTrace=m}return(a=a?a.displayName||a.name:"")?Q(a):""}function te(a){switch(a.tag){case 5:return Q(a.type);case 16:return Q("Lazy");case 13:return Q("Suspense");case 19:return Q("SuspenseList");case 0:case 2:case 15:return a=ne(a.type,!1),a;case 11:return a=ne(a.type.render,!1),a;case 1:return a=ne(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 O:return"Profiler";case B:return"StrictMode";case A:return"Suspense";case I:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case D:return(a.displayName||"Context")+".Consumer";case T:return(a._context.displayName||"Context")+".Provider";case U:var c=a.render;return a=a.displayName,a||(a=c.displayName||c.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case R:return c=a.displayName||null,c!==null?c:re(a.type)||"Memo";case L:c=a._payload,a=a._init;try{return re(a(c))}catch{}}return null}function X(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 se(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function ae(a){var c=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function _e(a){var c=ae(a)?"checked":"value",m=Object.getOwnPropertyDescriptor(a.constructor.prototype,c),y=""+a[c];if(!a.hasOwnProperty(c)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var E=m.get,$=m.set;return Object.defineProperty(a,c,{configurable:!0,get:function(){return E.call(this)},set:function(W){y=""+W,$.call(this,W)}}),Object.defineProperty(a,c,{enumerable:m.enumerable}),{getValue:function(){return y},setValue:function(W){y=""+W},stopTracking:function(){a._valueTracker=null,delete a[c]}}}}function ze(a){a._valueTracker||(a._valueTracker=_e(a))}function Te(a){if(!a)return!1;var c=a._valueTracker;if(!c)return!0;var m=c.getValue(),y="";return a&&(y=ae(a)?a.checked?"true":"false":a.value),a=y,a!==m?(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 ye(a,c){var m=c.checked;return V({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??a._wrapperState.initialChecked})}function Fe(a,c){var m=c.defaultValue==null?"":c.defaultValue,y=c.checked!=null?c.checked:c.defaultChecked;m=se(c.value!=null?c.value:m),a._wrapperState={initialChecked:y,initialValue:m,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function Re(a,c){c=c.checked,c!=null&&S(a,"checked",c,!1)}function Qe(a,c){Re(a,c);var m=se(c.value),y=c.type;if(m!=null)y==="number"?(m===0&&a.value===""||a.value!=m)&&(a.value=""+m):a.value!==""+m&&(a.value=""+m);else if(y==="submit"||y==="reset"){a.removeAttribute("value");return}c.hasOwnProperty("value")?_t(a,c.type,m):c.hasOwnProperty("defaultValue")&&_t(a,c.type,se(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(a.defaultChecked=!!c.defaultChecked)}function Ke(a,c,m){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var y=c.type;if(!(y!=="submit"&&y!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+a._wrapperState.initialValue,m||c===a.value||(a.value=c),a.defaultValue=c}m=a.name,m!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,m!==""&&(a.name=m)}function _t(a,c,m){(c!=="number"||fe(a.ownerDocument)!==a)&&(m==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+m&&(a.defaultValue=""+m))}var xt=Array.isArray;function Mt(a,c,m,y){if(a=a.options,c){c={};for(var E=0;E<m.length;E++)c["$"+m[E]]=!0;for(m=0;m<a.length;m++)E=c.hasOwnProperty("$"+a[m].value),a[m].selected!==E&&(a[m].selected=E),E&&y&&(a[m].defaultSelected=!0)}else{for(m=""+se(m),c=null,E=0;E<a.length;E++){if(a[E].value===m){a[E].selected=!0,y&&(a[E].defaultSelected=!0);return}c!==null||a[E].disabled||(c=a[E])}c!==null&&(c.selected=!0)}}function En(a,c){if(c.dangerouslySetInnerHTML!=null)throw Error(s(91));return V({},c,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function rt(a,c){var m=c.value;if(m==null){if(m=c.children,c=c.defaultValue,m!=null){if(c!=null)throw Error(s(92));if(xt(m)){if(1<m.length)throw Error(s(93));m=m[0]}c=m}c==null&&(c=""),m=c}a._wrapperState={initialValue:se(m)}}function Pt(a,c){var m=se(c.value),y=se(c.defaultValue);m!=null&&(m=""+m,m!==a.value&&(a.value=m),c.defaultValue==null&&a.defaultValue!==m&&(a.defaultValue=m)),y!=null&&(a.defaultValue=""+y)}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,m,y,E){MSApp.execUnsafeLocalFunction(function(){return a(c,m,y,E)})}: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 fn(a,c){if(c){var m=a.firstChild;if(m&&m===a.lastChild&&m.nodeType===3){m.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,m){return c==null||typeof c=="boolean"||c===""?"":m||typeof c!="number"||c===0||Hn.hasOwnProperty(a)&&Hn[a]?(""+c).trim():c+"px"}function rs(a,c){a=a.style;for(var m in c)if(c.hasOwnProperty(m)){var y=m.indexOf("--")===0,E=ps(m,c[m],y);m==="float"&&(m="cssFloat"),y?a.setProperty(m,E):a[m]=E}}var gs=V({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 ce(a){if(a=xl(a)){if(typeof An!="function")throw Error(s(280));var c=a.stateNode;c&&(c=ru(c),An(a.stateNode,a.type,c))}}function J(a){Yn?On?On.push(a):On=[a]:Yn=a}function he(){if(Yn){var a=Yn,c=On;if(On=Yn=null,ce(a),c)for(a=0;a<c.length;a++)ce(c[a])}}function we(a,c){return a(c)}function Ue(){}var ct=!1;function jt(a,c,m){if(ct)return a(c,m);ct=!0;try{return we(a,c,m)}finally{ct=!1,(Yn!==null||On!==null)&&(Ue(),he())}}function Be(a,c){var m=a.stateNode;if(m===null)return null;var y=ru(m);if(y===null)return null;m=y[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":(y=!y.disabled)||(a=a.type,y=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!y;break e;default:a=!1}if(a)return null;if(m&&typeof m!="function")throw Error(s(231,c,typeof m));return m}var De=!1;if(u)try{var Ye={};Object.defineProperty(Ye,"passive",{get:function(){De=!0}}),window.addEventListener("test",Ye,Ye),window.removeEventListener("test",Ye,Ye)}catch{De=!1}function vt(a,c,m,y,E,$,W,ie,oe){var xe=Array.prototype.slice.call(arguments,3);try{c.apply(m,xe)}catch(Ae){this.onError(Ae)}}var wt=!1,Xn=null,xs=!1,ui=null,br={onError:function(a){wt=!0,Xn=a}};function di(a,c,m,y,E,$,W,ie,oe){wt=!1,Xn=null,vt.apply(br,arguments)}function kr(a,c,m,y,E,$,W,ie,oe){if(di.apply(this,arguments),wt){if(wt){var xe=Xn;wt=!1,Xn=null}else throw Error(s(198));xs||(xs=!0,ui=xe)}}function Qn(a){var c=a,m=a;if(a.alternate)for(;c.return;)c=c.return;else{a=c;do c=a,(c.flags&4098)!==0&&(m=c.return),a=c.return;while(a)}return c.tag===3?m:null}function qi(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 Ti(a){var c=a.alternate;if(!c){if(c=Qn(a),c===null)throw Error(s(188));return c!==a?null:a}for(var m=a,y=c;;){var E=m.return;if(E===null)break;var $=E.alternate;if($===null){if(y=E.return,y!==null){m=y;continue}break}if(E.child===$.child){for($=E.child;$;){if($===m)return vs(E),a;if($===y)return vs(E),c;$=$.sibling}throw Error(s(188))}if(m.return!==y.return)m=E,y=$;else{for(var W=!1,ie=E.child;ie;){if(ie===m){W=!0,m=E,y=$;break}if(ie===y){W=!0,y=E,m=$;break}ie=ie.sibling}if(!W){for(ie=$.child;ie;){if(ie===m){W=!0,m=$,y=E;break}if(ie===y){W=!0,y=$,m=E;break}ie=ie.sibling}if(!W)throw Error(s(189))}}if(m.alternate!==y)throw Error(s(190))}if(m.tag!==3)throw Error(s(188));return m.stateNode.current===m?a:c}function jr(a){return a=Ti(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,Gi=t.unstable_shouldYield,hi=t.unstable_requestPaint,Dt=t.unstable_now,Nr=t.unstable_getCurrentPriorityLevel,Ki=t.unstable_ImmediatePriority,mi=t.unstable_UserBlockingPriority,Mi=t.unstable_NormalPriority,Me=t.unstable_LowPriority,We=t.unstable_IdlePriority,ut=null,mt=null;function Rt(a){if(mt&&typeof mt.onCommitFiberRoot=="function")try{mt.onCommitFiberRoot(ut,a,void 0,(a.current.flags&128)===128)}catch{}}var Ft=Math.clz32?Math.clz32:pn,Jn=Math.log,Ks=Math.LN2;function pn(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 m=a.pendingLanes;if(m===0)return 0;var y=0,E=a.suspendedLanes,$=a.pingedLanes,W=m&268435455;if(W!==0){var ie=W&~E;ie!==0?y=Xs(ie):($&=W,$!==0&&(y=Xs($)))}else W=m&~E,W!==0?y=Xs(W):$!==0&&(y=Xs($));if(y===0)return 0;if(c!==0&&c!==y&&(c&E)===0&&(E=y&-y,$=c&-c,E>=$||E===16&&($&4194240)!==0))return c;if((y&4)!==0&&(y|=m&16),c=a.entangledLanes,c!==0)for(a=a.entanglements,c&=y;0<c;)m=31-Ft(c),E=1<<m,y|=a[m],c&=~E;return y}function ra(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 wr(a,c){for(var m=a.suspendedLanes,y=a.pingedLanes,E=a.expirationTimes,$=a.pendingLanes;0<$;){var W=31-Ft($),ie=1<<W,oe=E[W];oe===-1?((ie&m)===0||(ie&y)!==0)&&(E[W]=ra(ie,c)):oe<=c&&(a.expiredLanes|=ie),$&=~ie}}function Ri(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function Sr(){var a=$n;return $n<<=1,($n&4194240)===0&&($n=64),a}function ls(a){for(var c=[],m=0;31>m;m++)c.push(a);return c}function bs(a,c,m){a.pendingLanes|=c,c!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,c=31-Ft(c),a[c]=m}function In(a,c){var m=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 y=a.eventTimes;for(a=a.expirationTimes;0<m;){var E=31-Ft(m),$=1<<E;c[E]=0,y[E]=-1,a[E]=-1,m&=~$}}function Qs(a,c){var m=a.entangledLanes|=c;for(a=a.entanglements;m;){var y=31-Ft(m),E=1<<y;E&c|a[y]&c&&(a[y]|=c),m&=~E}}var Nt=0;function at(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var ks,Bt,ft,Yi,cs,Xi=!1,fi=[],Oe=null,He=null,ot=null,kt=new Map,Vt=new Map,bn=[],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 aa(a,c){switch(a){case"focusin":case"focusout":Oe=null;break;case"dragenter":case"dragleave":He=null;break;case"mouseover":case"mouseout":ot=null;break;case"pointerover":case"pointerout":kt.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vt.delete(c.pointerId)}}function Qi(a,c,m,y,E,$){return a===null||a.nativeEvent!==$?(a={blockedOn:c,domEventName:m,eventSystemFlags:y,nativeEvent:$,targetContainers:[E]},c!==null&&(c=xl(c),c!==null&&Bt(c)),a):(a.eventSystemFlags|=y,c=a.targetContainers,E!==null&&c.indexOf(E)===-1&&c.push(E),a)}function oa(a,c,m,y,E){switch(c){case"focusin":return Oe=Qi(Oe,a,c,m,y,E),!0;case"dragenter":return He=Qi(He,a,c,m,y,E),!0;case"mouseover":return ot=Qi(ot,a,c,m,y,E),!0;case"pointerover":var $=E.pointerId;return kt.set($,Qi(kt.get($)||null,a,c,m,y,E)),!0;case"gotpointercapture":return $=E.pointerId,Vt.set($,Qi(Vt.get($)||null,a,c,m,y,E)),!0}return!1}function Qa(a){var c=la(a.target);if(c!==null){var m=Qn(c);if(m!==null){if(c=m.tag,c===13){if(c=qi(m),c!==null){a.blockedOn=c,cs(a.priority,function(){ft(m)});return}}else if(c===3&&m.stateNode.current.memoizedState.isDehydrated){a.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Se(a){if(a.blockedOn!==null)return!1;for(var c=a.targetContainers;0<c.length;){var m=Pn(a.domEventName,a.eventSystemFlags,c[0],a.nativeEvent);if(m===null){m=a.nativeEvent;var y=new m.constructor(m.type,m);Kn=y,m.target.dispatchEvent(y),Kn=null}else return c=xl(m),c!==null&&Bt(c),a.blockedOn=m,!1;c.shift()}return!0}function Y(a,c,m){Se(a)&&m.delete(c)}function ue(){Xi=!1,Oe!==null&&Se(Oe)&&(Oe=null),He!==null&&Se(He)&&(He=null),ot!==null&&Se(ot)&&(ot=null),kt.forEach(Y),Vt.forEach(Y)}function je(a,c){a.blockedOn===c&&(a.blockedOn=null,Xi||(Xi=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ue)))}function Ne(a){function c(E){return je(E,a)}if(0<fi.length){je(fi[0],a);for(var m=1;m<fi.length;m++){var y=fi[m];y.blockedOn===a&&(y.blockedOn=null)}}for(Oe!==null&&je(Oe,a),He!==null&&je(He,a),ot!==null&&je(ot,a),kt.forEach(c),Vt.forEach(c),m=0;m<bn.length;m++)y=bn[m],y.blockedOn===a&&(y.blockedOn=null);for(;0<bn.length&&(m=bn[0],m.blockedOn===null);)Qa(m),m.blockedOn===null&&bn.shift()}var Ge=_.ReactCurrentBatchConfig,nt=!0;function pt(a,c,m,y){var E=Nt,$=Ge.transition;Ge.transition=null;try{Nt=1,js(a,c,m,y)}finally{Nt=E,Ge.transition=$}}function gn(a,c,m,y){var E=Nt,$=Ge.transition;Ge.transition=null;try{Nt=4,js(a,c,m,y)}finally{Nt=E,Ge.transition=$}}function js(a,c,m,y){if(nt){var E=Pn(a,c,m,y);if(E===null)zh(a,c,y,kn,m),aa(a,y);else if(oa(E,a,c,m,y))y.stopPropagation();else if(aa(a,y),c&4&&-1<rl.indexOf(a)){for(;E!==null;){var $=xl(E);if($!==null&&ks($),$=Pn(a,c,m,y),$===null&&zh(a,c,y,kn,m),$===E)break;E=$}E!==null&&y.stopPropagation()}else zh(a,c,y,null,m)}}var kn=null;function Pn(a,c,m,y){if(kn=null,a=Zn(y),a=la(a),a!==null)if(c=Qn(a),c===null)a=null;else if(m=c.tag,m===13){if(a=qi(c),a!==null)return a;a=null}else if(m===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;a=null}else c!==a&&(a=null);return kn=a,null}function Ji(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(Nr()){case Ki:return 1;case mi:return 4;case Mi:case Me:return 16;case We:return 536870912;default:return 16}default:return 16}}var an=null,Ja=null,Gc=null;function Ux(){if(Gc)return Gc;var a,c=Ja,m=c.length,y,E="value"in an?an.value:an.textContent,$=E.length;for(a=0;a<m&&c[a]===E[a];a++);var W=m-a;for(y=1;y<=W&&c[m-y]===E[$-y];y++);return Gc=E.slice(a,1<y?1-y:void 0)}function Kc(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 Yc(){return!0}function Bx(){return!1}function Ps(a){function c(m,y,E,$,W){this._reactName=m,this._targetInst=E,this.type=y,this.nativeEvent=$,this.target=W,this.currentTarget=null;for(var ie in a)a.hasOwnProperty(ie)&&(m=a[ie],this[ie]=m?m($):$[ie]);return this.isDefaultPrevented=($.defaultPrevented!=null?$.defaultPrevented:$.returnValue===!1)?Yc:Bx,this.isPropagationStopped=Bx,this}return V(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=Yc)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=Yc)},persist:function(){},isPersistent:Yc}),c}var eo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Nh=Ps(eo),al=V({},eo,{view:0,detail:0}),cE=Ps(al),wh,Sh,ol,Xc=V({},al,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Eh,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"?(wh=a.screenX-ol.screenX,Sh=a.screenY-ol.screenY):Sh=wh=0,ol=a),wh)},movementY:function(a){return"movementY"in a?a.movementY:Sh}}),Hx=Ps(Xc),uE=V({},Xc,{dataTransfer:0}),dE=Ps(uE),hE=V({},al,{relatedTarget:0}),_h=Ps(hE),mE=V({},eo,{animationName:0,elapsedTime:0,pseudoElement:0}),fE=Ps(mE),pE=V({},eo,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),gE=Ps(pE),xE=V({},eo,{data:0}),Zx=Ps(xE),vE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yE={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"},bE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kE(a){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(a):(a=bE[a])?!!c[a]:!1}function Eh(){return kE}var jE=V({},al,{key:function(a){if(a.key){var c=vE[a.key]||a.key;if(c!=="Unidentified")return c}return a.type==="keypress"?(a=Kc(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?yE[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Eh,charCode:function(a){return a.type==="keypress"?Kc(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Kc(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),NE=Ps(jE),wE=V({},Xc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wx=Ps(wE),SE=V({},al,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Eh}),_E=Ps(SE),EE=V({},eo,{propertyName:0,elapsedTime:0,pseudoElement:0}),CE=Ps(EE),AE=V({},Xc,{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}),$E=Ps(AE),IE=[9,13,27,32],Ch=u&&"CompositionEvent"in window,ll=null;u&&"documentMode"in document&&(ll=document.documentMode);var TE=u&&"TextEvent"in window&&!ll,Vx=u&&(!Ch||ll&&8<ll&&11>=ll),qx=" ",Gx=!1;function Kx(a,c){switch(a){case"keyup":return IE.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yx(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var to=!1;function ME(a,c){switch(a){case"compositionend":return Yx(c);case"keypress":return c.which!==32?null:(Gx=!0,qx);case"textInput":return a=c.data,a===qx&&Gx?null:a;default:return null}}function RE(a,c){if(to)return a==="compositionend"||!Ch&&Kx(a,c)?(a=Ux(),Gc=Ja=an=null,to=!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 Vx&&c.locale!=="ko"?null:c.data;default:return null}}var OE={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 Xx(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c==="input"?!!OE[a.type]:c==="textarea"}function Qx(a,c,m,y){J(y),c=nu(c,"onChange"),0<c.length&&(m=new Nh("onChange","change",null,m,y),a.push({event:m,listeners:c}))}var cl=null,ul=null;function PE(a){gv(a,0)}function Qc(a){var c=ao(a);if(Te(c))return a}function LE(a,c){if(a==="change")return c}var Jx=!1;if(u){var Ah;if(u){var $h="oninput"in document;if(!$h){var ev=document.createElement("div");ev.setAttribute("oninput","return;"),$h=typeof ev.oninput=="function"}Ah=$h}else Ah=!1;Jx=Ah&&(!document.documentMode||9<document.documentMode)}function tv(){cl&&(cl.detachEvent("onpropertychange",nv),ul=cl=null)}function nv(a){if(a.propertyName==="value"&&Qc(ul)){var c=[];Qx(c,ul,a,Zn(a)),jt(PE,c)}}function zE(a,c,m){a==="focusin"?(tv(),cl=c,ul=m,cl.attachEvent("onpropertychange",nv)):a==="focusout"&&tv()}function DE(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Qc(ul)}function FE(a,c){if(a==="click")return Qc(c)}function UE(a,c){if(a==="input"||a==="change")return Qc(c)}function BE(a,c){return a===c&&(a!==0||1/a===1/c)||a!==a&&c!==c}var pi=typeof Object.is=="function"?Object.is:BE;function dl(a,c){if(pi(a,c))return!0;if(typeof a!="object"||a===null||typeof c!="object"||c===null)return!1;var m=Object.keys(a),y=Object.keys(c);if(m.length!==y.length)return!1;for(y=0;y<m.length;y++){var E=m[y];if(!d.call(c,E)||!pi(a[E],c[E]))return!1}return!0}function sv(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function iv(a,c){var m=sv(a);a=0;for(var y;m;){if(m.nodeType===3){if(y=a+m.textContent.length,a<=c&&y>=c)return{node:m,offset:c-a};a=y}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=sv(m)}}function rv(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?rv(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function av(){for(var a=window,c=fe();c instanceof a.HTMLIFrameElement;){try{var m=typeof c.contentWindow.location.href=="string"}catch{m=!1}if(m)a=c.contentWindow;else break;c=fe(a.document)}return c}function Ih(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 HE(a){var c=av(),m=a.focusedElem,y=a.selectionRange;if(c!==m&&m&&m.ownerDocument&&rv(m.ownerDocument.documentElement,m)){if(y!==null&&Ih(m)){if(c=y.start,a=y.end,a===void 0&&(a=c),"selectionStart"in m)m.selectionStart=c,m.selectionEnd=Math.min(a,m.value.length);else if(a=(c=m.ownerDocument||document)&&c.defaultView||window,a.getSelection){a=a.getSelection();var E=m.textContent.length,$=Math.min(y.start,E);y=y.end===void 0?$:Math.min(y.end,E),!a.extend&&$>y&&(E=y,y=$,$=E),E=iv(m,$);var W=iv(m,y);E&&W&&(a.rangeCount!==1||a.anchorNode!==E.node||a.anchorOffset!==E.offset||a.focusNode!==W.node||a.focusOffset!==W.offset)&&(c=c.createRange(),c.setStart(E.node,E.offset),a.removeAllRanges(),$>y?(a.addRange(c),a.extend(W.node,W.offset)):(c.setEnd(W.node,W.offset),a.addRange(c)))}}for(c=[],a=m;a=a.parentNode;)a.nodeType===1&&c.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<c.length;m++)a=c[m],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var ZE=u&&"documentMode"in document&&11>=document.documentMode,no=null,Th=null,hl=null,Mh=!1;function ov(a,c,m){var y=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;Mh||no==null||no!==fe(y)||(y=no,"selectionStart"in y&&Ih(y)?y={start:y.selectionStart,end:y.selectionEnd}:(y=(y.ownerDocument&&y.ownerDocument.defaultView||window).getSelection(),y={anchorNode:y.anchorNode,anchorOffset:y.anchorOffset,focusNode:y.focusNode,focusOffset:y.focusOffset}),hl&&dl(hl,y)||(hl=y,y=nu(Th,"onSelect"),0<y.length&&(c=new Nh("onSelect","select",null,c,m),a.push({event:c,listeners:y}),c.target=no)))}function Jc(a,c){var m={};return m[a.toLowerCase()]=c.toLowerCase(),m["Webkit"+a]="webkit"+c,m["Moz"+a]="moz"+c,m}var so={animationend:Jc("Animation","AnimationEnd"),animationiteration:Jc("Animation","AnimationIteration"),animationstart:Jc("Animation","AnimationStart"),transitionend:Jc("Transition","TransitionEnd")},Rh={},lv={};u&&(lv=document.createElement("div").style,"AnimationEvent"in window||(delete so.animationend.animation,delete so.animationiteration.animation,delete so.animationstart.animation),"TransitionEvent"in window||delete so.transitionend.transition);function eu(a){if(Rh[a])return Rh[a];if(!so[a])return a;var c=so[a],m;for(m in c)if(c.hasOwnProperty(m)&&m in lv)return Rh[a]=c[m];return a}var cv=eu("animationend"),uv=eu("animationiteration"),dv=eu("animationstart"),hv=eu("transitionend"),mv=new Map,fv="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 _r(a,c){mv.set(a,c),o(c,[a])}for(var Oh=0;Oh<fv.length;Oh++){var Ph=fv[Oh],WE=Ph.toLowerCase(),VE=Ph[0].toUpperCase()+Ph.slice(1);_r(WE,"on"+VE)}_r(cv,"onAnimationEnd"),_r(uv,"onAnimationIteration"),_r(dv,"onAnimationStart"),_r("dblclick","onDoubleClick"),_r("focusin","onFocus"),_r("focusout","onBlur"),_r(hv,"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(" "),qE=new Set("cancel close invalid load scroll toggle".split(" ").concat(ml));function pv(a,c,m){var y=a.type||"unknown-event";a.currentTarget=m,kr(y,c,void 0,a),a.currentTarget=null}function gv(a,c){c=(c&4)!==0;for(var m=0;m<a.length;m++){var y=a[m],E=y.event;y=y.listeners;e:{var $=void 0;if(c)for(var W=y.length-1;0<=W;W--){var ie=y[W],oe=ie.instance,xe=ie.currentTarget;if(ie=ie.listener,oe!==$&&E.isPropagationStopped())break e;pv(E,ie,xe),$=oe}else for(W=0;W<y.length;W++){if(ie=y[W],oe=ie.instance,xe=ie.currentTarget,ie=ie.listener,oe!==$&&E.isPropagationStopped())break e;pv(E,ie,xe),$=oe}}}if(xs)throw a=ui,xs=!1,ui=null,a}function qt(a,c){var m=c[Zh];m===void 0&&(m=c[Zh]=new Set);var y=a+"__bubble";m.has(y)||(xv(c,a,2,!1),m.add(y))}function Lh(a,c,m){var y=0;c&&(y|=4),xv(m,a,y,c)}var tu="_reactListening"+Math.random().toString(36).slice(2);function fl(a){if(!a[tu]){a[tu]=!0,i.forEach(function(m){m!=="selectionchange"&&(qE.has(m)||Lh(m,!1,a),Lh(m,!0,a))});var c=a.nodeType===9?a:a.ownerDocument;c===null||c[tu]||(c[tu]=!0,Lh("selectionchange",!1,c))}}function xv(a,c,m,y){switch(Ji(c)){case 1:var E=pt;break;case 4:E=gn;break;default:E=js}m=E.bind(null,c,m,a),E=void 0,!De||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(E=!0),y?E!==void 0?a.addEventListener(c,m,{capture:!0,passive:E}):a.addEventListener(c,m,!0):E!==void 0?a.addEventListener(c,m,{passive:E}):a.addEventListener(c,m,!1)}function zh(a,c,m,y,E){var $=y;if((c&1)===0&&(c&2)===0&&y!==null)e:for(;;){if(y===null)return;var W=y.tag;if(W===3||W===4){var ie=y.stateNode.containerInfo;if(ie===E||ie.nodeType===8&&ie.parentNode===E)break;if(W===4)for(W=y.return;W!==null;){var oe=W.tag;if((oe===3||oe===4)&&(oe=W.stateNode.containerInfo,oe===E||oe.nodeType===8&&oe.parentNode===E))return;W=W.return}for(;ie!==null;){if(W=la(ie),W===null)return;if(oe=W.tag,oe===5||oe===6){y=$=W;continue e}ie=ie.parentNode}}y=y.return}jt(function(){var xe=$,Ae=Zn(m),$e=[];e:{var Ee=mv.get(a);if(Ee!==void 0){var Ze=Nh,qe=a;switch(a){case"keypress":if(Kc(m)===0)break e;case"keydown":case"keyup":Ze=NE;break;case"focusin":qe="focus",Ze=_h;break;case"focusout":qe="blur",Ze=_h;break;case"beforeblur":case"afterblur":Ze=_h;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ze=Hx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ze=dE;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ze=_E;break;case cv:case uv:case dv:Ze=fE;break;case hv:Ze=CE;break;case"scroll":Ze=cE;break;case"wheel":Ze=$E;break;case"copy":case"cut":case"paste":Ze=gE;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ze=Wx}var Xe=(c&4)!==0,xn=!Xe&&a==="scroll",pe=Xe?Ee!==null?Ee+"Capture":null:Ee;Xe=[];for(var de=xe,ge;de!==null;){ge=de;var Pe=ge.stateNode;if(ge.tag===5&&Pe!==null&&(ge=Pe,pe!==null&&(Pe=Be(de,pe),Pe!=null&&Xe.push(pl(de,Pe,ge)))),xn)break;de=de.return}0<Xe.length&&(Ee=new Ze(Ee,qe,null,m,Ae),$e.push({event:Ee,listeners:Xe}))}}if((c&7)===0){e:{if(Ee=a==="mouseover"||a==="pointerover",Ze=a==="mouseout"||a==="pointerout",Ee&&m!==Kn&&(qe=m.relatedTarget||m.fromElement)&&(la(qe)||qe[er]))break e;if((Ze||Ee)&&(Ee=Ae.window===Ae?Ae:(Ee=Ae.ownerDocument)?Ee.defaultView||Ee.parentWindow:window,Ze?(qe=m.relatedTarget||m.toElement,Ze=xe,qe=qe?la(qe):null,qe!==null&&(xn=Qn(qe),qe!==xn||qe.tag!==5&&qe.tag!==6)&&(qe=null)):(Ze=null,qe=xe),Ze!==qe)){if(Xe=Hx,Pe="onMouseLeave",pe="onMouseEnter",de="mouse",(a==="pointerout"||a==="pointerover")&&(Xe=Wx,Pe="onPointerLeave",pe="onPointerEnter",de="pointer"),xn=Ze==null?Ee:ao(Ze),ge=qe==null?Ee:ao(qe),Ee=new Xe(Pe,de+"leave",Ze,m,Ae),Ee.target=xn,Ee.relatedTarget=ge,Pe=null,la(Ae)===xe&&(Xe=new Xe(pe,de+"enter",qe,m,Ae),Xe.target=ge,Xe.relatedTarget=xn,Pe=Xe),xn=Pe,Ze&&qe)t:{for(Xe=Ze,pe=qe,de=0,ge=Xe;ge;ge=io(ge))de++;for(ge=0,Pe=pe;Pe;Pe=io(Pe))ge++;for(;0<de-ge;)Xe=io(Xe),de--;for(;0<ge-de;)pe=io(pe),ge--;for(;de--;){if(Xe===pe||pe!==null&&Xe===pe.alternate)break t;Xe=io(Xe),pe=io(pe)}Xe=null}else Xe=null;Ze!==null&&vv($e,Ee,Ze,Xe,!1),qe!==null&&xn!==null&&vv($e,xn,qe,Xe,!0)}}e:{if(Ee=xe?ao(xe):window,Ze=Ee.nodeName&&Ee.nodeName.toLowerCase(),Ze==="select"||Ze==="input"&&Ee.type==="file")var Je=LE;else if(Xx(Ee))if(Jx)Je=UE;else{Je=DE;var st=zE}else(Ze=Ee.nodeName)&&Ze.toLowerCase()==="input"&&(Ee.type==="checkbox"||Ee.type==="radio")&&(Je=FE);if(Je&&(Je=Je(a,xe))){Qx($e,Je,m,Ae);break e}st&&st(a,Ee,xe),a==="focusout"&&(st=Ee._wrapperState)&&st.controlled&&Ee.type==="number"&&_t(Ee,"number",Ee.value)}switch(st=xe?ao(xe):window,a){case"focusin":(Xx(st)||st.contentEditable==="true")&&(no=st,Th=xe,hl=null);break;case"focusout":hl=Th=no=null;break;case"mousedown":Mh=!0;break;case"contextmenu":case"mouseup":case"dragend":Mh=!1,ov($e,m,Ae);break;case"selectionchange":if(ZE)break;case"keydown":case"keyup":ov($e,m,Ae)}var it;if(Ch)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 to?Kx(a,m)&&(lt="onCompositionEnd"):a==="keydown"&&m.keyCode===229&&(lt="onCompositionStart");lt&&(Vx&&m.locale!=="ko"&&(to||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&to&&(it=Ux()):(an=Ae,Ja="value"in an?an.value:an.textContent,to=!0)),st=nu(xe,lt),0<st.length&&(lt=new Zx(lt,a,null,m,Ae),$e.push({event:lt,listeners:st}),it?lt.data=it:(it=Yx(m),it!==null&&(lt.data=it)))),(it=TE?ME(a,m):RE(a,m))&&(xe=nu(xe,"onBeforeInput"),0<xe.length&&(Ae=new Zx("onBeforeInput","beforeinput",null,m,Ae),$e.push({event:Ae,listeners:xe}),Ae.data=it))}gv($e,c)})}function pl(a,c,m){return{instance:a,listener:c,currentTarget:m}}function nu(a,c){for(var m=c+"Capture",y=[];a!==null;){var E=a,$=E.stateNode;E.tag===5&&$!==null&&(E=$,$=Be(a,m),$!=null&&y.unshift(pl(a,$,E)),$=Be(a,c),$!=null&&y.push(pl(a,$,E))),a=a.return}return y}function io(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function vv(a,c,m,y,E){for(var $=c._reactName,W=[];m!==null&&m!==y;){var ie=m,oe=ie.alternate,xe=ie.stateNode;if(oe!==null&&oe===y)break;ie.tag===5&&xe!==null&&(ie=xe,E?(oe=Be(m,$),oe!=null&&W.unshift(pl(m,oe,ie))):E||(oe=Be(m,$),oe!=null&&W.push(pl(m,oe,ie)))),m=m.return}W.length!==0&&a.push({event:c,listeners:W})}var GE=/\r\n?/g,KE=/\u0000|\uFFFD/g;function yv(a){return(typeof a=="string"?a:""+a).replace(GE,`
38
+ `).replace(KE,"")}function su(a,c,m){if(c=yv(c),yv(a)!==c&&m)throw Error(s(425))}function iu(){}var Dh=null,Fh=null;function Uh(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 Bh=typeof setTimeout=="function"?setTimeout:void 0,YE=typeof clearTimeout=="function"?clearTimeout:void 0,bv=typeof Promise=="function"?Promise:void 0,XE=typeof queueMicrotask=="function"?queueMicrotask:typeof bv<"u"?function(a){return bv.resolve(null).then(a).catch(QE)}:Bh;function QE(a){setTimeout(function(){throw a})}function Hh(a,c){var m=c,y=0;do{var E=m.nextSibling;if(a.removeChild(m),E&&E.nodeType===8)if(m=E.data,m==="/$"){if(y===0){a.removeChild(E),Ne(c);return}y--}else m!=="$"&&m!=="$?"&&m!=="$!"||y++;m=E}while(m);Ne(c)}function Er(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 kv(a){a=a.previousSibling;for(var c=0;a;){if(a.nodeType===8){var m=a.data;if(m==="$"||m==="$!"||m==="$?"){if(c===0)return a;c--}else m==="/$"&&c++}a=a.previousSibling}return null}var ro=Math.random().toString(36).slice(2),Oi="__reactFiber$"+ro,gl="__reactProps$"+ro,er="__reactContainer$"+ro,Zh="__reactEvents$"+ro,JE="__reactListeners$"+ro,eC="__reactHandles$"+ro;function la(a){var c=a[Oi];if(c)return c;for(var m=a.parentNode;m;){if(c=m[er]||m[Oi]){if(m=c.alternate,c.child!==null||m!==null&&m.child!==null)for(a=kv(a);a!==null;){if(m=a[Oi])return m;a=kv(a)}return c}a=m,m=a.parentNode}return null}function xl(a){return a=a[Oi]||a[er],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function ao(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(s(33))}function ru(a){return a[gl]||null}var Wh=[],oo=-1;function Cr(a){return{current:a}}function Gt(a){0>oo||(a.current=Wh[oo],Wh[oo]=null,oo--)}function Wt(a,c){oo++,Wh[oo]=a.current,a.current=c}var Ar={},es=Cr(Ar),Ns=Cr(!1),ca=Ar;function lo(a,c){var m=a.type.contextTypes;if(!m)return Ar;var y=a.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===c)return y.__reactInternalMemoizedMaskedChildContext;var E={},$;for($ in m)E[$]=c[$];return y&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=c,a.__reactInternalMemoizedMaskedChildContext=E),E}function ws(a){return a=a.childContextTypes,a!=null}function au(){Gt(Ns),Gt(es)}function jv(a,c,m){if(es.current!==Ar)throw Error(s(168));Wt(es,c),Wt(Ns,m)}function Nv(a,c,m){var y=a.stateNode;if(c=c.childContextTypes,typeof y.getChildContext!="function")return m;y=y.getChildContext();for(var E in y)if(!(E in c))throw Error(s(108,X(a)||"Unknown",E));return V({},m,y)}function ou(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||Ar,ca=es.current,Wt(es,a),Wt(Ns,Ns.current),!0}function wv(a,c,m){var y=a.stateNode;if(!y)throw Error(s(169));m?(a=Nv(a,c,ca),y.__reactInternalMemoizedMergedChildContext=a,Gt(Ns),Gt(es),Wt(es,a)):Gt(Ns),Wt(Ns,m)}var tr=null,lu=!1,Vh=!1;function Sv(a){tr===null?tr=[a]:tr.push(a)}function tC(a){lu=!0,Sv(a)}function $r(){if(!Vh&&tr!==null){Vh=!0;var a=0,c=Nt;try{var m=tr;for(Nt=1;a<m.length;a++){var y=m[a];do y=y(!0);while(y!==null)}tr=null,lu=!1}catch(E){throw tr!==null&&(tr=tr.slice(a+1)),Os(Ki,$r),E}finally{Nt=c,Vh=!1}}return null}var co=[],uo=0,cu=null,uu=0,Js=[],ei=0,ua=null,nr=1,sr="";function da(a,c){co[uo++]=uu,co[uo++]=cu,cu=a,uu=c}function _v(a,c,m){Js[ei++]=nr,Js[ei++]=sr,Js[ei++]=ua,ua=a;var y=nr;a=sr;var E=32-Ft(y)-1;y&=~(1<<E),m+=1;var $=32-Ft(c)+E;if(30<$){var W=E-E%5;$=(y&(1<<W)-1).toString(32),y>>=W,E-=W,nr=1<<32-Ft(c)+E|m<<E|y,sr=$+a}else nr=1<<$|m<<E|y,sr=a}function qh(a){a.return!==null&&(da(a,1),_v(a,1,0))}function Gh(a){for(;a===cu;)cu=co[--uo],co[uo]=null,uu=co[--uo],co[uo]=null;for(;a===ua;)ua=Js[--ei],Js[ei]=null,sr=Js[--ei],Js[ei]=null,nr=Js[--ei],Js[ei]=null}var Ls=null,zs=null,Jt=!1,gi=null;function Ev(a,c){var m=ii(5,null,null,0);m.elementType="DELETED",m.stateNode=c,m.return=a,c=a.deletions,c===null?(a.deletions=[m],a.flags|=16):c.push(m)}function Cv(a,c){switch(a.tag){case 5:var m=a.type;return c=c.nodeType!==1||m.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(a.stateNode=c,Ls=a,zs=Er(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?(m=ua!==null?{id:nr,overflow:sr}:null,a.memoizedState={dehydrated:c,treeContext:m,retryLane:1073741824},m=ii(18,null,null,0),m.stateNode=c,m.return=a,a.child=m,Ls=a,zs=null,!0):!1;default:return!1}}function Kh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Yh(a){if(Jt){var c=zs;if(c){var m=c;if(!Cv(a,c)){if(Kh(a))throw Error(s(418));c=Er(m.nextSibling);var y=Ls;c&&Cv(a,c)?Ev(y,m):(a.flags=a.flags&-4097|2,Jt=!1,Ls=a)}}else{if(Kh(a))throw Error(s(418));a.flags=a.flags&-4097|2,Jt=!1,Ls=a}}}function Av(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Ls=a}function du(a){if(a!==Ls)return!1;if(!Jt)return Av(a),Jt=!0,!1;var c;if((c=a.tag!==3)&&!(c=a.tag!==5)&&(c=a.type,c=c!=="head"&&c!=="body"&&!Uh(a.type,a.memoizedProps)),c&&(c=zs)){if(Kh(a))throw $v(),Error(s(418));for(;c;)Ev(a,c),c=Er(c.nextSibling)}if(Av(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 m=a.data;if(m==="/$"){if(c===0){zs=Er(a.nextSibling);break e}c--}else m!=="$"&&m!=="$!"&&m!=="$?"||c++}a=a.nextSibling}zs=null}}else zs=Ls?Er(a.stateNode.nextSibling):null;return!0}function $v(){for(var a=zs;a;)a=Er(a.nextSibling)}function ho(){zs=Ls=null,Jt=!1}function Xh(a){gi===null?gi=[a]:gi.push(a)}var nC=_.ReactCurrentBatchConfig;function vl(a,c,m){if(a=m.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(s(309));var y=m.stateNode}if(!y)throw Error(s(147,a));var E=y,$=""+a;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===$?c.ref:(c=function(W){var ie=E.refs;W===null?delete ie[$]:ie[$]=W},c._stringRef=$,c)}if(typeof a!="string")throw Error(s(284));if(!m._owner)throw Error(s(290,a))}return a}function hu(a,c){throw a=Object.prototype.toString.call(c),Error(s(31,a==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":a))}function Iv(a){var c=a._init;return c(a._payload)}function Tv(a){function c(pe,de){if(a){var ge=pe.deletions;ge===null?(pe.deletions=[de],pe.flags|=16):ge.push(de)}}function m(pe,de){if(!a)return null;for(;de!==null;)c(pe,de),de=de.sibling;return null}function y(pe,de){for(pe=new Map;de!==null;)de.key!==null?pe.set(de.key,de):pe.set(de.index,de),de=de.sibling;return pe}function E(pe,de){return pe=zr(pe,de),pe.index=0,pe.sibling=null,pe}function $(pe,de,ge){return pe.index=ge,a?(ge=pe.alternate,ge!==null?(ge=ge.index,ge<de?(pe.flags|=2,de):ge):(pe.flags|=2,de)):(pe.flags|=1048576,de)}function W(pe){return a&&pe.alternate===null&&(pe.flags|=2),pe}function ie(pe,de,ge,Pe){return de===null||de.tag!==6?(de=Bm(ge,pe.mode,Pe),de.return=pe,de):(de=E(de,ge),de.return=pe,de)}function oe(pe,de,ge,Pe){var Je=ge.type;return Je===H?Ae(pe,de,ge.props.children,Pe,ge.key):de!==null&&(de.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===L&&Iv(Je)===de.type)?(Pe=E(de,ge.props),Pe.ref=vl(pe,de,ge),Pe.return=pe,Pe):(Pe=Pu(ge.type,ge.key,ge.props,null,pe.mode,Pe),Pe.ref=vl(pe,de,ge),Pe.return=pe,Pe)}function xe(pe,de,ge,Pe){return de===null||de.tag!==4||de.stateNode.containerInfo!==ge.containerInfo||de.stateNode.implementation!==ge.implementation?(de=Hm(ge,pe.mode,Pe),de.return=pe,de):(de=E(de,ge.children||[]),de.return=pe,de)}function Ae(pe,de,ge,Pe,Je){return de===null||de.tag!==7?(de=ya(ge,pe.mode,Pe,Je),de.return=pe,de):(de=E(de,ge),de.return=pe,de)}function $e(pe,de,ge){if(typeof de=="string"&&de!==""||typeof de=="number")return de=Bm(""+de,pe.mode,ge),de.return=pe,de;if(typeof de=="object"&&de!==null){switch(de.$$typeof){case z:return ge=Pu(de.type,de.key,de.props,null,pe.mode,ge),ge.ref=vl(pe,null,de),ge.return=pe,ge;case P:return de=Hm(de,pe.mode,ge),de.return=pe,de;case L:var Pe=de._init;return $e(pe,Pe(de._payload),ge)}if(xt(de)||q(de))return de=ya(de,pe.mode,ge,null),de.return=pe,de;hu(pe,de)}return null}function Ee(pe,de,ge,Pe){var Je=de!==null?de.key:null;if(typeof ge=="string"&&ge!==""||typeof ge=="number")return Je!==null?null:ie(pe,de,""+ge,Pe);if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case z:return ge.key===Je?oe(pe,de,ge,Pe):null;case P:return ge.key===Je?xe(pe,de,ge,Pe):null;case L:return Je=ge._init,Ee(pe,de,Je(ge._payload),Pe)}if(xt(ge)||q(ge))return Je!==null?null:Ae(pe,de,ge,Pe,null);hu(pe,ge)}return null}function Ze(pe,de,ge,Pe,Je){if(typeof Pe=="string"&&Pe!==""||typeof Pe=="number")return pe=pe.get(ge)||null,ie(de,pe,""+Pe,Je);if(typeof Pe=="object"&&Pe!==null){switch(Pe.$$typeof){case z:return pe=pe.get(Pe.key===null?ge:Pe.key)||null,oe(de,pe,Pe,Je);case P:return pe=pe.get(Pe.key===null?ge:Pe.key)||null,xe(de,pe,Pe,Je);case L:var st=Pe._init;return Ze(pe,de,ge,st(Pe._payload),Je)}if(xt(Pe)||q(Pe))return pe=pe.get(ge)||null,Ae(de,pe,Pe,Je,null);hu(de,Pe)}return null}function qe(pe,de,ge,Pe){for(var Je=null,st=null,it=de,lt=de=0,Dn=null;it!==null&&lt<ge.length;lt++){it.index>lt?(Dn=it,it=null):Dn=it.sibling;var $t=Ee(pe,it,ge[lt],Pe);if($t===null){it===null&&(it=Dn);break}a&&it&&$t.alternate===null&&c(pe,it),de=$($t,de,lt),st===null?Je=$t:st.sibling=$t,st=$t,it=Dn}if(lt===ge.length)return m(pe,it),Jt&&da(pe,lt),Je;if(it===null){for(;lt<ge.length;lt++)it=$e(pe,ge[lt],Pe),it!==null&&(de=$(it,de,lt),st===null?Je=it:st.sibling=it,st=it);return Jt&&da(pe,lt),Je}for(it=y(pe,it);lt<ge.length;lt++)Dn=Ze(it,pe,lt,ge[lt],Pe),Dn!==null&&(a&&Dn.alternate!==null&&it.delete(Dn.key===null?lt:Dn.key),de=$(Dn,de,lt),st===null?Je=Dn:st.sibling=Dn,st=Dn);return a&&it.forEach(function(Dr){return c(pe,Dr)}),Jt&&da(pe,lt),Je}function Xe(pe,de,ge,Pe){var Je=q(ge);if(typeof Je!="function")throw Error(s(150));if(ge=Je.call(ge),ge==null)throw Error(s(151));for(var st=Je=null,it=de,lt=de=0,Dn=null,$t=ge.next();it!==null&&!$t.done;lt++,$t=ge.next()){it.index>lt?(Dn=it,it=null):Dn=it.sibling;var Dr=Ee(pe,it,$t.value,Pe);if(Dr===null){it===null&&(it=Dn);break}a&&it&&Dr.alternate===null&&c(pe,it),de=$(Dr,de,lt),st===null?Je=Dr:st.sibling=Dr,st=Dr,it=Dn}if($t.done)return m(pe,it),Jt&&da(pe,lt),Je;if(it===null){for(;!$t.done;lt++,$t=ge.next())$t=$e(pe,$t.value,Pe),$t!==null&&(de=$($t,de,lt),st===null?Je=$t:st.sibling=$t,st=$t);return Jt&&da(pe,lt),Je}for(it=y(pe,it);!$t.done;lt++,$t=ge.next())$t=Ze(it,pe,lt,$t.value,Pe),$t!==null&&(a&&$t.alternate!==null&&it.delete($t.key===null?lt:$t.key),de=$($t,de,lt),st===null?Je=$t:st.sibling=$t,st=$t);return a&&it.forEach(function(OC){return c(pe,OC)}),Jt&&da(pe,lt),Je}function xn(pe,de,ge,Pe){if(typeof ge=="object"&&ge!==null&&ge.type===H&&ge.key===null&&(ge=ge.props.children),typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case z:e:{for(var Je=ge.key,st=de;st!==null;){if(st.key===Je){if(Je=ge.type,Je===H){if(st.tag===7){m(pe,st.sibling),de=E(st,ge.props.children),de.return=pe,pe=de;break e}}else if(st.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===L&&Iv(Je)===st.type){m(pe,st.sibling),de=E(st,ge.props),de.ref=vl(pe,st,ge),de.return=pe,pe=de;break e}m(pe,st);break}else c(pe,st);st=st.sibling}ge.type===H?(de=ya(ge.props.children,pe.mode,Pe,ge.key),de.return=pe,pe=de):(Pe=Pu(ge.type,ge.key,ge.props,null,pe.mode,Pe),Pe.ref=vl(pe,de,ge),Pe.return=pe,pe=Pe)}return W(pe);case P:e:{for(st=ge.key;de!==null;){if(de.key===st)if(de.tag===4&&de.stateNode.containerInfo===ge.containerInfo&&de.stateNode.implementation===ge.implementation){m(pe,de.sibling),de=E(de,ge.children||[]),de.return=pe,pe=de;break e}else{m(pe,de);break}else c(pe,de);de=de.sibling}de=Hm(ge,pe.mode,Pe),de.return=pe,pe=de}return W(pe);case L:return st=ge._init,xn(pe,de,st(ge._payload),Pe)}if(xt(ge))return qe(pe,de,ge,Pe);if(q(ge))return Xe(pe,de,ge,Pe);hu(pe,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"?(ge=""+ge,de!==null&&de.tag===6?(m(pe,de.sibling),de=E(de,ge),de.return=pe,pe=de):(m(pe,de),de=Bm(ge,pe.mode,Pe),de.return=pe,pe=de),W(pe)):m(pe,de)}return xn}var mo=Tv(!0),Mv=Tv(!1),mu=Cr(null),fu=null,fo=null,Qh=null;function Jh(){Qh=fo=fu=null}function em(a){var c=mu.current;Gt(mu),a._currentValue=c}function tm(a,c,m){for(;a!==null;){var y=a.alternate;if((a.childLanes&c)!==c?(a.childLanes|=c,y!==null&&(y.childLanes|=c)):y!==null&&(y.childLanes&c)!==c&&(y.childLanes|=c),a===m)break;a=a.return}}function po(a,c){fu=a,Qh=fo=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(Qh!==a)if(a={context:a,memoizedValue:c,next:null},fo===null){if(fu===null)throw Error(s(308));fo=a,fu.dependencies={lanes:0,firstContext:a}}else fo=fo.next=a;return c}var ha=null;function nm(a){ha===null?ha=[a]:ha.push(a)}function Rv(a,c,m,y){var E=c.interleaved;return E===null?(m.next=m,nm(c)):(m.next=E.next,E.next=m),c.interleaved=m,ir(a,y)}function ir(a,c){a.lanes|=c;var m=a.alternate;for(m!==null&&(m.lanes|=c),m=a,a=a.return;a!==null;)a.childLanes|=c,m=a.alternate,m!==null&&(m.childLanes|=c),m=a,a=a.return;return m.tag===3?m.stateNode:null}var Ir=!1;function sm(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ov(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 rr(a,c){return{eventTime:a,lane:c,tag:0,payload:null,callback:null,next:null}}function Tr(a,c,m){var y=a.updateQueue;if(y===null)return null;if(y=y.shared,(Et&2)!==0){var E=y.pending;return E===null?c.next=c:(c.next=E.next,E.next=c),y.pending=c,ir(a,m)}return E=y.interleaved,E===null?(c.next=c,nm(y)):(c.next=E.next,E.next=c),y.interleaved=c,ir(a,m)}function pu(a,c,m){if(c=c.updateQueue,c!==null&&(c=c.shared,(m&4194240)!==0)){var y=c.lanes;y&=a.pendingLanes,m|=y,c.lanes=m,Qs(a,m)}}function Pv(a,c){var m=a.updateQueue,y=a.alternate;if(y!==null&&(y=y.updateQueue,m===y)){var E=null,$=null;if(m=m.firstBaseUpdate,m!==null){do{var W={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};$===null?E=$=W:$=$.next=W,m=m.next}while(m!==null);$===null?E=$=c:$=$.next=c}else E=$=c;m={baseState:y.baseState,firstBaseUpdate:E,lastBaseUpdate:$,shared:y.shared,effects:y.effects},a.updateQueue=m;return}a=m.lastBaseUpdate,a===null?m.firstBaseUpdate=c:a.next=c,m.lastBaseUpdate=c}function gu(a,c,m,y){var E=a.updateQueue;Ir=!1;var $=E.firstBaseUpdate,W=E.lastBaseUpdate,ie=E.shared.pending;if(ie!==null){E.shared.pending=null;var oe=ie,xe=oe.next;oe.next=null,W===null?$=xe:W.next=xe,W=oe;var Ae=a.alternate;Ae!==null&&(Ae=Ae.updateQueue,ie=Ae.lastBaseUpdate,ie!==W&&(ie===null?Ae.firstBaseUpdate=xe:ie.next=xe,Ae.lastBaseUpdate=oe))}if($!==null){var $e=E.baseState;W=0,Ae=xe=oe=null,ie=$;do{var Ee=ie.lane,Ze=ie.eventTime;if((y&Ee)===Ee){Ae!==null&&(Ae=Ae.next={eventTime:Ze,lane:0,tag:ie.tag,payload:ie.payload,callback:ie.callback,next:null});e:{var qe=a,Xe=ie;switch(Ee=c,Ze=m,Xe.tag){case 1:if(qe=Xe.payload,typeof qe=="function"){$e=qe.call(Ze,$e,Ee);break e}$e=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=Xe.payload,Ee=typeof qe=="function"?qe.call(Ze,$e,Ee):qe,Ee==null)break e;$e=V({},$e,Ee);break e;case 2:Ir=!0}}ie.callback!==null&&ie.lane!==0&&(a.flags|=64,Ee=E.effects,Ee===null?E.effects=[ie]:Ee.push(ie))}else Ze={eventTime:Ze,lane:Ee,tag:ie.tag,payload:ie.payload,callback:ie.callback,next:null},Ae===null?(xe=Ae=Ze,oe=$e):Ae=Ae.next=Ze,W|=Ee;if(ie=ie.next,ie===null){if(ie=E.shared.pending,ie===null)break;Ee=ie,ie=Ee.next,Ee.next=null,E.lastBaseUpdate=Ee,E.shared.pending=null}}while(!0);if(Ae===null&&(oe=$e),E.baseState=oe,E.firstBaseUpdate=xe,E.lastBaseUpdate=Ae,c=E.shared.interleaved,c!==null){E=c;do W|=E.lane,E=E.next;while(E!==c)}else $===null&&(E.shared.lanes=0);pa|=W,a.lanes=W,a.memoizedState=$e}}function Lv(a,c,m){if(a=c.effects,c.effects=null,a!==null)for(c=0;c<a.length;c++){var y=a[c],E=y.callback;if(E!==null){if(y.callback=null,y=m,typeof E!="function")throw Error(s(191,E));E.call(y)}}}var yl={},Pi=Cr(yl),bl=Cr(yl),kl=Cr(yl);function ma(a){if(a===yl)throw Error(s(174));return a}function im(a,c){switch(Wt(kl,c),Wt(bl,a),Wt(Pi,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(Pi),Wt(Pi,c)}function go(){Gt(Pi),Gt(bl),Gt(kl)}function zv(a){ma(kl.current);var c=ma(Pi.current),m=Qt(c,a.type);c!==m&&(Wt(bl,a),Wt(Pi,m))}function rm(a){bl.current===a&&(Gt(Pi),Gt(bl))}var on=Cr(0);function xu(a){for(var c=a;c!==null;){if(c.tag===13){var m=c.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.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 am=[];function om(){for(var a=0;a<am.length;a++)am[a]._workInProgressVersionPrimary=null;am.length=0}var vu=_.ReactCurrentDispatcher,lm=_.ReactCurrentBatchConfig,fa=0,ln=null,Tn=null,Ln=null,yu=!1,jl=!1,Nl=0,sC=0;function ts(){throw Error(s(321))}function cm(a,c){if(c===null)return!1;for(var m=0;m<c.length&&m<a.length;m++)if(!pi(a[m],c[m]))return!1;return!0}function um(a,c,m,y,E,$){if(fa=$,ln=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,vu.current=a===null||a.memoizedState===null?oC:lC,a=m(y,E),jl){$=0;do{if(jl=!1,Nl=0,25<=$)throw Error(s(301));$+=1,Ln=Tn=null,c.updateQueue=null,vu.current=cC,a=m(y,E)}while(jl)}if(vu.current=ju,c=Tn!==null&&Tn.next!==null,fa=0,Ln=Tn=ln=null,yu=!1,c)throw Error(s(300));return a}function dm(){var a=Nl!==0;return Nl=0,a}function Li(){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 hm(a){var c=ni(),m=c.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=a;var y=Tn,E=y.baseQueue,$=m.pending;if($!==null){if(E!==null){var W=E.next;E.next=$.next,$.next=W}y.baseQueue=E=$,m.pending=null}if(E!==null){$=E.next,y=y.baseState;var ie=W=null,oe=null,xe=$;do{var Ae=xe.lane;if((fa&Ae)===Ae)oe!==null&&(oe=oe.next={lane:0,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null}),y=xe.hasEagerState?xe.eagerState:a(y,xe.action);else{var $e={lane:Ae,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null};oe===null?(ie=oe=$e,W=y):oe=oe.next=$e,ln.lanes|=Ae,pa|=Ae}xe=xe.next}while(xe!==null&&xe!==$);oe===null?W=y:oe.next=ie,pi(y,c.memoizedState)||(Ss=!0),c.memoizedState=y,c.baseState=W,c.baseQueue=oe,m.lastRenderedState=y}if(a=m.interleaved,a!==null){E=a;do $=E.lane,ln.lanes|=$,pa|=$,E=E.next;while(E!==a)}else E===null&&(m.lanes=0);return[c.memoizedState,m.dispatch]}function mm(a){var c=ni(),m=c.queue;if(m===null)throw Error(s(311));m.lastRenderedReducer=a;var y=m.dispatch,E=m.pending,$=c.memoizedState;if(E!==null){m.pending=null;var W=E=E.next;do $=a($,W.action),W=W.next;while(W!==E);pi($,c.memoizedState)||(Ss=!0),c.memoizedState=$,c.baseQueue===null&&(c.baseState=$),m.lastRenderedState=$}return[$,y]}function Dv(){}function Fv(a,c){var m=ln,y=ni(),E=c(),$=!pi(y.memoizedState,E);if($&&(y.memoizedState=E,Ss=!0),y=y.queue,fm(Hv.bind(null,m,y,a),[a]),y.getSnapshot!==c||$||Ln!==null&&Ln.memoizedState.tag&1){if(m.flags|=2048,Sl(9,Bv.bind(null,m,y,E,c),void 0,null),zn===null)throw Error(s(349));(fa&30)!==0||Uv(m,c,E)}return E}function Uv(a,c,m){a.flags|=16384,a={getSnapshot:c,value:m},c=ln.updateQueue,c===null?(c={lastEffect:null,stores:null},ln.updateQueue=c,c.stores=[a]):(m=c.stores,m===null?c.stores=[a]:m.push(a))}function Bv(a,c,m,y){c.value=m,c.getSnapshot=y,Zv(c)&&Wv(a)}function Hv(a,c,m){return m(function(){Zv(c)&&Wv(a)})}function Zv(a){var c=a.getSnapshot;a=a.value;try{var m=c();return!pi(a,m)}catch{return!0}}function Wv(a){var c=ir(a,1);c!==null&&bi(c,a,1,-1)}function Vv(a){var c=Li();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=aC.bind(null,ln,a),[c.memoizedState,a]}function Sl(a,c,m,y){return a={tag:a,create:c,destroy:m,deps:y,next:null},c=ln.updateQueue,c===null?(c={lastEffect:null,stores:null},ln.updateQueue=c,c.lastEffect=a.next=a):(m=c.lastEffect,m===null?c.lastEffect=a.next=a:(y=m.next,m.next=a,a.next=y,c.lastEffect=a)),a}function qv(){return ni().memoizedState}function bu(a,c,m,y){var E=Li();ln.flags|=a,E.memoizedState=Sl(1|c,m,void 0,y===void 0?null:y)}function ku(a,c,m,y){var E=ni();y=y===void 0?null:y;var $=void 0;if(Tn!==null){var W=Tn.memoizedState;if($=W.destroy,y!==null&&cm(y,W.deps)){E.memoizedState=Sl(c,m,$,y);return}}ln.flags|=a,E.memoizedState=Sl(1|c,m,$,y)}function Gv(a,c){return bu(8390656,8,a,c)}function fm(a,c){return ku(2048,8,a,c)}function Kv(a,c){return ku(4,2,a,c)}function Yv(a,c){return ku(4,4,a,c)}function Xv(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 Qv(a,c,m){return m=m!=null?m.concat([a]):null,ku(4,4,Xv.bind(null,c,a),m)}function pm(){}function Jv(a,c){var m=ni();c=c===void 0?null:c;var y=m.memoizedState;return y!==null&&c!==null&&cm(c,y[1])?y[0]:(m.memoizedState=[a,c],a)}function e0(a,c){var m=ni();c=c===void 0?null:c;var y=m.memoizedState;return y!==null&&c!==null&&cm(c,y[1])?y[0]:(a=a(),m.memoizedState=[a,c],a)}function t0(a,c,m){return(fa&21)===0?(a.baseState&&(a.baseState=!1,Ss=!0),a.memoizedState=m):(pi(m,c)||(m=Sr(),ln.lanes|=m,pa|=m,a.baseState=!0),c)}function iC(a,c){var m=Nt;Nt=m!==0&&4>m?m:4,a(!0);var y=lm.transition;lm.transition={};try{a(!1),c()}finally{Nt=m,lm.transition=y}}function n0(){return ni().memoizedState}function rC(a,c,m){var y=Pr(a);if(m={lane:y,action:m,hasEagerState:!1,eagerState:null,next:null},s0(a))i0(c,m);else if(m=Rv(a,c,m,y),m!==null){var E=ds();bi(m,a,y,E),r0(m,c,y)}}function aC(a,c,m){var y=Pr(a),E={lane:y,action:m,hasEagerState:!1,eagerState:null,next:null};if(s0(a))i0(c,E);else{var $=a.alternate;if(a.lanes===0&&($===null||$.lanes===0)&&($=c.lastRenderedReducer,$!==null))try{var W=c.lastRenderedState,ie=$(W,m);if(E.hasEagerState=!0,E.eagerState=ie,pi(ie,W)){var oe=c.interleaved;oe===null?(E.next=E,nm(c)):(E.next=oe.next,oe.next=E),c.interleaved=E;return}}catch{}finally{}m=Rv(a,c,E,y),m!==null&&(E=ds(),bi(m,a,y,E),r0(m,c,y))}}function s0(a){var c=a.alternate;return a===ln||c!==null&&c===ln}function i0(a,c){jl=yu=!0;var m=a.pending;m===null?c.next=c:(c.next=m.next,m.next=c),a.pending=c}function r0(a,c,m){if((m&4194240)!==0){var y=c.lanes;y&=a.pendingLanes,m|=y,c.lanes=m,Qs(a,m)}}var ju={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},oC={readContext:ti,useCallback:function(a,c){return Li().memoizedState=[a,c===void 0?null:c],a},useContext:ti,useEffect:Gv,useImperativeHandle:function(a,c,m){return m=m!=null?m.concat([a]):null,bu(4194308,4,Xv.bind(null,c,a),m)},useLayoutEffect:function(a,c){return bu(4194308,4,a,c)},useInsertionEffect:function(a,c){return bu(4,2,a,c)},useMemo:function(a,c){var m=Li();return c=c===void 0?null:c,a=a(),m.memoizedState=[a,c],a},useReducer:function(a,c,m){var y=Li();return c=m!==void 0?m(c):c,y.memoizedState=y.baseState=c,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:c},y.queue=a,a=a.dispatch=rC.bind(null,ln,a),[y.memoizedState,a]},useRef:function(a){var c=Li();return a={current:a},c.memoizedState=a},useState:Vv,useDebugValue:pm,useDeferredValue:function(a){return Li().memoizedState=a},useTransition:function(){var a=Vv(!1),c=a[0];return a=iC.bind(null,a[1]),Li().memoizedState=a,[c,a]},useMutableSource:function(){},useSyncExternalStore:function(a,c,m){var y=ln,E=Li();if(Jt){if(m===void 0)throw Error(s(407));m=m()}else{if(m=c(),zn===null)throw Error(s(349));(fa&30)!==0||Uv(y,c,m)}E.memoizedState=m;var $={value:m,getSnapshot:c};return E.queue=$,Gv(Hv.bind(null,y,$,a),[a]),y.flags|=2048,Sl(9,Bv.bind(null,y,$,m,c),void 0,null),m},useId:function(){var a=Li(),c=zn.identifierPrefix;if(Jt){var m=sr,y=nr;m=(y&~(1<<32-Ft(y)-1)).toString(32)+m,c=":"+c+"R"+m,m=Nl++,0<m&&(c+="H"+m.toString(32)),c+=":"}else m=sC++,c=":"+c+"r"+m.toString(32)+":";return a.memoizedState=c},unstable_isNewReconciler:!1},lC={readContext:ti,useCallback:Jv,useContext:ti,useEffect:fm,useImperativeHandle:Qv,useInsertionEffect:Kv,useLayoutEffect:Yv,useMemo:e0,useReducer:hm,useRef:qv,useState:function(){return hm(wl)},useDebugValue:pm,useDeferredValue:function(a){var c=ni();return t0(c,Tn.memoizedState,a)},useTransition:function(){var a=hm(wl)[0],c=ni().memoizedState;return[a,c]},useMutableSource:Dv,useSyncExternalStore:Fv,useId:n0,unstable_isNewReconciler:!1},cC={readContext:ti,useCallback:Jv,useContext:ti,useEffect:fm,useImperativeHandle:Qv,useInsertionEffect:Kv,useLayoutEffect:Yv,useMemo:e0,useReducer:mm,useRef:qv,useState:function(){return mm(wl)},useDebugValue:pm,useDeferredValue:function(a){var c=ni();return Tn===null?c.memoizedState=a:t0(c,Tn.memoizedState,a)},useTransition:function(){var a=mm(wl)[0],c=ni().memoizedState;return[a,c]},useMutableSource:Dv,useSyncExternalStore:Fv,useId:n0,unstable_isNewReconciler:!1};function xi(a,c){if(a&&a.defaultProps){c=V({},c),a=a.defaultProps;for(var m in a)c[m]===void 0&&(c[m]=a[m]);return c}return c}function gm(a,c,m,y){c=a.memoizedState,m=m(y,c),m=m==null?c:V({},c,m),a.memoizedState=m,a.lanes===0&&(a.updateQueue.baseState=m)}var Nu={isMounted:function(a){return(a=a._reactInternals)?Qn(a)===a:!1},enqueueSetState:function(a,c,m){a=a._reactInternals;var y=ds(),E=Pr(a),$=rr(y,E);$.payload=c,m!=null&&($.callback=m),c=Tr(a,$,E),c!==null&&(bi(c,a,E,y),pu(c,a,E))},enqueueReplaceState:function(a,c,m){a=a._reactInternals;var y=ds(),E=Pr(a),$=rr(y,E);$.tag=1,$.payload=c,m!=null&&($.callback=m),c=Tr(a,$,E),c!==null&&(bi(c,a,E,y),pu(c,a,E))},enqueueForceUpdate:function(a,c){a=a._reactInternals;var m=ds(),y=Pr(a),E=rr(m,y);E.tag=2,c!=null&&(E.callback=c),c=Tr(a,E,y),c!==null&&(bi(c,a,y,m),pu(c,a,y))}};function a0(a,c,m,y,E,$,W){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(y,$,W):c.prototype&&c.prototype.isPureReactComponent?!dl(m,y)||!dl(E,$):!0}function o0(a,c,m){var y=!1,E=Ar,$=c.contextType;return typeof $=="object"&&$!==null?$=ti($):(E=ws(c)?ca:es.current,y=c.contextTypes,$=(y=y!=null)?lo(a,E):Ar),c=new c(m,$),a.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=Nu,a.stateNode=c,c._reactInternals=a,y&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=E,a.__reactInternalMemoizedMaskedChildContext=$),c}function l0(a,c,m,y){a=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(m,y),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(m,y),c.state!==a&&Nu.enqueueReplaceState(c,c.state,null)}function xm(a,c,m,y){var E=a.stateNode;E.props=m,E.state=a.memoizedState,E.refs={},sm(a);var $=c.contextType;typeof $=="object"&&$!==null?E.context=ti($):($=ws(c)?ca:es.current,E.context=lo(a,$)),E.state=a.memoizedState,$=c.getDerivedStateFromProps,typeof $=="function"&&(gm(a,c,$,m),E.state=a.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(c=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),c!==E.state&&Nu.enqueueReplaceState(E,E.state,null),gu(a,m,E,y),E.state=a.memoizedState),typeof E.componentDidMount=="function"&&(a.flags|=4194308)}function xo(a,c){try{var m="",y=c;do m+=te(y),y=y.return;while(y);var E=m}catch($){E=`
39
+ Error generating stack: `+$.message+`
40
+ `+$.stack}return{value:a,source:c,stack:E,digest:null}}function vm(a,c,m){return{value:a,source:null,stack:m??null,digest:c??null}}function ym(a,c){try{console.error(c.value)}catch(m){setTimeout(function(){throw m})}}var uC=typeof WeakMap=="function"?WeakMap:Map;function c0(a,c,m){m=rr(-1,m),m.tag=3,m.payload={element:null};var y=c.value;return m.callback=function(){$u||($u=!0,Rm=y),ym(a,c)},m}function u0(a,c,m){m=rr(-1,m),m.tag=3;var y=a.type.getDerivedStateFromError;if(typeof y=="function"){var E=c.value;m.payload=function(){return y(E)},m.callback=function(){ym(a,c)}}var $=a.stateNode;return $!==null&&typeof $.componentDidCatch=="function"&&(m.callback=function(){ym(a,c),typeof y!="function"&&(Rr===null?Rr=new Set([this]):Rr.add(this));var W=c.stack;this.componentDidCatch(c.value,{componentStack:W!==null?W:""})}),m}function d0(a,c,m){var y=a.pingCache;if(y===null){y=a.pingCache=new uC;var E=new Set;y.set(c,E)}else E=y.get(c),E===void 0&&(E=new Set,y.set(c,E));E.has(m)||(E.add(m),a=wC.bind(null,a,c,m),c.then(a,a))}function h0(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 m0(a,c,m,y,E){return(a.mode&1)===0?(a===c?a.flags|=65536:(a.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(c=rr(-1,1),c.tag=2,Tr(m,c,1))),m.lanes|=1),a):(a.flags|=65536,a.lanes=E,a)}var dC=_.ReactCurrentOwner,Ss=!1;function us(a,c,m,y){c.child=a===null?Mv(c,null,m,y):mo(c,a.child,m,y)}function f0(a,c,m,y,E){m=m.render;var $=c.ref;return po(c,E),y=um(a,c,m,y,$,E),m=dm(),a!==null&&!Ss?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~E,ar(a,c,E)):(Jt&&m&&qh(c),c.flags|=1,us(a,c,y,E),c.child)}function p0(a,c,m,y,E){if(a===null){var $=m.type;return typeof $=="function"&&!Um($)&&$.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(c.tag=15,c.type=$,g0(a,c,$,y,E)):(a=Pu(m.type,null,y,c,c.mode,E),a.ref=c.ref,a.return=c,c.child=a)}if($=a.child,(a.lanes&E)===0){var W=$.memoizedProps;if(m=m.compare,m=m!==null?m:dl,m(W,y)&&a.ref===c.ref)return ar(a,c,E)}return c.flags|=1,a=zr($,y),a.ref=c.ref,a.return=c,c.child=a}function g0(a,c,m,y,E){if(a!==null){var $=a.memoizedProps;if(dl($,y)&&a.ref===c.ref)if(Ss=!1,c.pendingProps=y=$,(a.lanes&E)!==0)(a.flags&131072)!==0&&(Ss=!0);else return c.lanes=a.lanes,ar(a,c,E)}return bm(a,c,m,y,E)}function x0(a,c,m){var y=c.pendingProps,E=y.children,$=a!==null?a.memoizedState:null;if(y.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},Wt(yo,Ds),Ds|=m;else{if((m&1073741824)===0)return a=$!==null?$.baseLanes|m:m,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:a,cachePool:null,transitions:null},c.updateQueue=null,Wt(yo,Ds),Ds|=a,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=$!==null?$.baseLanes:m,Wt(yo,Ds),Ds|=y}else $!==null?(y=$.baseLanes|m,c.memoizedState=null):y=m,Wt(yo,Ds),Ds|=y;return us(a,c,E,m),c.child}function v0(a,c){var m=c.ref;(a===null&&m!==null||a!==null&&a.ref!==m)&&(c.flags|=512,c.flags|=2097152)}function bm(a,c,m,y,E){var $=ws(m)?ca:es.current;return $=lo(c,$),po(c,E),m=um(a,c,m,y,$,E),y=dm(),a!==null&&!Ss?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~E,ar(a,c,E)):(Jt&&y&&qh(c),c.flags|=1,us(a,c,m,E),c.child)}function y0(a,c,m,y,E){if(ws(m)){var $=!0;ou(c)}else $=!1;if(po(c,E),c.stateNode===null)Su(a,c),o0(c,m,y),xm(c,m,y,E),y=!0;else if(a===null){var W=c.stateNode,ie=c.memoizedProps;W.props=ie;var oe=W.context,xe=m.contextType;typeof xe=="object"&&xe!==null?xe=ti(xe):(xe=ws(m)?ca:es.current,xe=lo(c,xe));var Ae=m.getDerivedStateFromProps,$e=typeof Ae=="function"||typeof W.getSnapshotBeforeUpdate=="function";$e||typeof W.UNSAFE_componentWillReceiveProps!="function"&&typeof W.componentWillReceiveProps!="function"||(ie!==y||oe!==xe)&&l0(c,W,y,xe),Ir=!1;var Ee=c.memoizedState;W.state=Ee,gu(c,y,W,E),oe=c.memoizedState,ie!==y||Ee!==oe||Ns.current||Ir?(typeof Ae=="function"&&(gm(c,m,Ae,y),oe=c.memoizedState),(ie=Ir||a0(c,m,ie,y,Ee,oe,xe))?($e||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=y,c.memoizedState=oe),W.props=y,W.state=oe,W.context=xe,y=ie):(typeof W.componentDidMount=="function"&&(c.flags|=4194308),y=!1)}else{W=c.stateNode,Ov(a,c),ie=c.memoizedProps,xe=c.type===c.elementType?ie:xi(c.type,ie),W.props=xe,$e=c.pendingProps,Ee=W.context,oe=m.contextType,typeof oe=="object"&&oe!==null?oe=ti(oe):(oe=ws(m)?ca:es.current,oe=lo(c,oe));var Ze=m.getDerivedStateFromProps;(Ae=typeof Ze=="function"||typeof W.getSnapshotBeforeUpdate=="function")||typeof W.UNSAFE_componentWillReceiveProps!="function"&&typeof W.componentWillReceiveProps!="function"||(ie!==$e||Ee!==oe)&&l0(c,W,y,oe),Ir=!1,Ee=c.memoizedState,W.state=Ee,gu(c,y,W,E);var qe=c.memoizedState;ie!==$e||Ee!==qe||Ns.current||Ir?(typeof Ze=="function"&&(gm(c,m,Ze,y),qe=c.memoizedState),(xe=Ir||a0(c,m,xe,y,Ee,qe,oe)||!1)?(Ae||typeof W.UNSAFE_componentWillUpdate!="function"&&typeof W.componentWillUpdate!="function"||(typeof W.componentWillUpdate=="function"&&W.componentWillUpdate(y,qe,oe),typeof W.UNSAFE_componentWillUpdate=="function"&&W.UNSAFE_componentWillUpdate(y,qe,oe)),typeof W.componentDidUpdate=="function"&&(c.flags|=4),typeof W.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof W.componentDidUpdate!="function"||ie===a.memoizedProps&&Ee===a.memoizedState||(c.flags|=4),typeof W.getSnapshotBeforeUpdate!="function"||ie===a.memoizedProps&&Ee===a.memoizedState||(c.flags|=1024),c.memoizedProps=y,c.memoizedState=qe),W.props=y,W.state=qe,W.context=oe,y=xe):(typeof W.componentDidUpdate!="function"||ie===a.memoizedProps&&Ee===a.memoizedState||(c.flags|=4),typeof W.getSnapshotBeforeUpdate!="function"||ie===a.memoizedProps&&Ee===a.memoizedState||(c.flags|=1024),y=!1)}return km(a,c,m,y,$,E)}function km(a,c,m,y,E,$){v0(a,c);var W=(c.flags&128)!==0;if(!y&&!W)return E&&wv(c,m,!1),ar(a,c,$);y=c.stateNode,dC.current=c;var ie=W&&typeof m.getDerivedStateFromError!="function"?null:y.render();return c.flags|=1,a!==null&&W?(c.child=mo(c,a.child,null,$),c.child=mo(c,null,ie,$)):us(a,c,ie,$),c.memoizedState=y.state,E&&wv(c,m,!0),c.child}function b0(a){var c=a.stateNode;c.pendingContext?jv(a,c.pendingContext,c.pendingContext!==c.context):c.context&&jv(a,c.context,!1),im(a,c.containerInfo)}function k0(a,c,m,y,E){return ho(),Xh(E),c.flags|=256,us(a,c,m,y),c.child}var jm={dehydrated:null,treeContext:null,retryLane:0};function Nm(a){return{baseLanes:a,cachePool:null,transitions:null}}function j0(a,c,m){var y=c.pendingProps,E=on.current,$=!1,W=(c.flags&128)!==0,ie;if((ie=W)||(ie=a!==null&&a.memoizedState===null?!1:(E&2)!==0),ie?($=!0,c.flags&=-129):(a===null||a.memoizedState!==null)&&(E|=1),Wt(on,E&1),a===null)return Yh(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=y.children,a=y.fallback,$?(y=c.mode,$=c.child,W={mode:"hidden",children:W},(y&1)===0&&$!==null?($.childLanes=0,$.pendingProps=W):$=Lu(W,y,0,null),a=ya(a,y,m,null),$.return=c,a.return=c,$.sibling=a,c.child=$,c.child.memoizedState=Nm(m),c.memoizedState=jm,a):wm(c,W));if(E=a.memoizedState,E!==null&&(ie=E.dehydrated,ie!==null))return hC(a,c,W,y,ie,E,m);if($){$=y.fallback,W=c.mode,E=a.child,ie=E.sibling;var oe={mode:"hidden",children:y.children};return(W&1)===0&&c.child!==E?(y=c.child,y.childLanes=0,y.pendingProps=oe,c.deletions=null):(y=zr(E,oe),y.subtreeFlags=E.subtreeFlags&14680064),ie!==null?$=zr(ie,$):($=ya($,W,m,null),$.flags|=2),$.return=c,y.return=c,y.sibling=$,c.child=y,y=$,$=c.child,W=a.child.memoizedState,W=W===null?Nm(m):{baseLanes:W.baseLanes|m,cachePool:null,transitions:W.transitions},$.memoizedState=W,$.childLanes=a.childLanes&~m,c.memoizedState=jm,y}return $=a.child,a=$.sibling,y=zr($,{mode:"visible",children:y.children}),(c.mode&1)===0&&(y.lanes=m),y.return=c,y.sibling=null,a!==null&&(m=c.deletions,m===null?(c.deletions=[a],c.flags|=16):m.push(a)),c.child=y,c.memoizedState=null,y}function wm(a,c){return c=Lu({mode:"visible",children:c},a.mode,0,null),c.return=a,a.child=c}function wu(a,c,m,y){return y!==null&&Xh(y),mo(c,a.child,null,m),a=wm(c,c.pendingProps.children),a.flags|=2,c.memoizedState=null,a}function hC(a,c,m,y,E,$,W){if(m)return c.flags&256?(c.flags&=-257,y=vm(Error(s(422))),wu(a,c,W,y)):c.memoizedState!==null?(c.child=a.child,c.flags|=128,null):($=y.fallback,E=c.mode,y=Lu({mode:"visible",children:y.children},E,0,null),$=ya($,E,W,null),$.flags|=2,y.return=c,$.return=c,y.sibling=$,c.child=y,(c.mode&1)!==0&&mo(c,a.child,null,W),c.child.memoizedState=Nm(W),c.memoizedState=jm,$);if((c.mode&1)===0)return wu(a,c,W,null);if(E.data==="$!"){if(y=E.nextSibling&&E.nextSibling.dataset,y)var ie=y.dgst;return y=ie,$=Error(s(419)),y=vm($,y,void 0),wu(a,c,W,y)}if(ie=(W&a.childLanes)!==0,Ss||ie){if(y=zn,y!==null){switch(W&-W){case 4:E=2;break;case 16:E=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:E=32;break;case 536870912:E=268435456;break;default:E=0}E=(E&(y.suspendedLanes|W))!==0?0:E,E!==0&&E!==$.retryLane&&($.retryLane=E,ir(a,E),bi(y,a,E,-1))}return Fm(),y=vm(Error(s(421))),wu(a,c,W,y)}return E.data==="$?"?(c.flags|=128,c.child=a.child,c=SC.bind(null,a),E._reactRetry=c,null):(a=$.treeContext,zs=Er(E.nextSibling),Ls=c,Jt=!0,gi=null,a!==null&&(Js[ei++]=nr,Js[ei++]=sr,Js[ei++]=ua,nr=a.id,sr=a.overflow,ua=c),c=wm(c,y.children),c.flags|=4096,c)}function N0(a,c,m){a.lanes|=c;var y=a.alternate;y!==null&&(y.lanes|=c),tm(a.return,c,m)}function Sm(a,c,m,y,E){var $=a.memoizedState;$===null?a.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:y,tail:m,tailMode:E}:($.isBackwards=c,$.rendering=null,$.renderingStartTime=0,$.last=y,$.tail=m,$.tailMode=E)}function w0(a,c,m){var y=c.pendingProps,E=y.revealOrder,$=y.tail;if(us(a,c,y.children,m),y=on.current,(y&2)!==0)y=y&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&&N0(a,m,c);else if(a.tag===19)N0(a,m,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}y&=1}if(Wt(on,y),(c.mode&1)===0)c.memoizedState=null;else switch(E){case"forwards":for(m=c.child,E=null;m!==null;)a=m.alternate,a!==null&&xu(a)===null&&(E=m),m=m.sibling;m=E,m===null?(E=c.child,c.child=null):(E=m.sibling,m.sibling=null),Sm(c,!1,E,m,$);break;case"backwards":for(m=null,E=c.child,c.child=null;E!==null;){if(a=E.alternate,a!==null&&xu(a)===null){c.child=E;break}a=E.sibling,E.sibling=m,m=E,E=a}Sm(c,!0,m,null,$);break;case"together":Sm(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function Su(a,c){(c.mode&1)===0&&a!==null&&(a.alternate=null,c.alternate=null,c.flags|=2)}function ar(a,c,m){if(a!==null&&(c.dependencies=a.dependencies),pa|=c.lanes,(m&c.childLanes)===0)return null;if(a!==null&&c.child!==a.child)throw Error(s(153));if(c.child!==null){for(a=c.child,m=zr(a,a.pendingProps),c.child=m,m.return=c;a.sibling!==null;)a=a.sibling,m=m.sibling=zr(a,a.pendingProps),m.return=c;m.sibling=null}return c.child}function mC(a,c,m){switch(c.tag){case 3:b0(c),ho();break;case 5:zv(c);break;case 1:ws(c.type)&&ou(c);break;case 4:im(c,c.stateNode.containerInfo);break;case 10:var y=c.type._context,E=c.memoizedProps.value;Wt(mu,y._currentValue),y._currentValue=E;break;case 13:if(y=c.memoizedState,y!==null)return y.dehydrated!==null?(Wt(on,on.current&1),c.flags|=128,null):(m&c.child.childLanes)!==0?j0(a,c,m):(Wt(on,on.current&1),a=ar(a,c,m),a!==null?a.sibling:null);Wt(on,on.current&1);break;case 19:if(y=(m&c.childLanes)!==0,(a.flags&128)!==0){if(y)return w0(a,c,m);c.flags|=128}if(E=c.memoizedState,E!==null&&(E.rendering=null,E.tail=null,E.lastEffect=null),Wt(on,on.current),y)break;return null;case 22:case 23:return c.lanes=0,x0(a,c,m)}return ar(a,c,m)}var S0,_m,_0,E0;S0=function(a,c){for(var m=c.child;m!==null;){if(m.tag===5||m.tag===6)a.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===c)break;for(;m.sibling===null;){if(m.return===null||m.return===c)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},_m=function(){},_0=function(a,c,m,y){var E=a.memoizedProps;if(E!==y){a=c.stateNode,ma(Pi.current);var $=null;switch(m){case"input":E=ye(a,E),y=ye(a,y),$=[];break;case"select":E=V({},E,{value:void 0}),y=V({},y,{value:void 0}),$=[];break;case"textarea":E=En(a,E),y=En(a,y),$=[];break;default:typeof E.onClick!="function"&&typeof y.onClick=="function"&&(a.onclick=iu)}Cn(m,y);var W;m=null;for(xe in E)if(!y.hasOwnProperty(xe)&&E.hasOwnProperty(xe)&&E[xe]!=null)if(xe==="style"){var ie=E[xe];for(W in ie)ie.hasOwnProperty(W)&&(m||(m={}),m[W]="")}else xe!=="dangerouslySetInnerHTML"&&xe!=="children"&&xe!=="suppressContentEditableWarning"&&xe!=="suppressHydrationWarning"&&xe!=="autoFocus"&&(r.hasOwnProperty(xe)?$||($=[]):($=$||[]).push(xe,null));for(xe in y){var oe=y[xe];if(ie=E!=null?E[xe]:void 0,y.hasOwnProperty(xe)&&oe!==ie&&(oe!=null||ie!=null))if(xe==="style")if(ie){for(W in ie)!ie.hasOwnProperty(W)||oe&&oe.hasOwnProperty(W)||(m||(m={}),m[W]="");for(W in oe)oe.hasOwnProperty(W)&&ie[W]!==oe[W]&&(m||(m={}),m[W]=oe[W])}else m||($||($=[]),$.push(xe,m)),m=oe;else xe==="dangerouslySetInnerHTML"?(oe=oe?oe.__html:void 0,ie=ie?ie.__html:void 0,oe!=null&&ie!==oe&&($=$||[]).push(xe,oe)):xe==="children"?typeof oe!="string"&&typeof oe!="number"||($=$||[]).push(xe,""+oe):xe!=="suppressContentEditableWarning"&&xe!=="suppressHydrationWarning"&&(r.hasOwnProperty(xe)?(oe!=null&&xe==="onScroll"&&qt("scroll",a),$||ie===oe||($=[])):($=$||[]).push(xe,oe))}m&&($=$||[]).push("style",m);var xe=$;(c.updateQueue=xe)&&(c.flags|=4)}},E0=function(a,c,m,y){m!==y&&(c.flags|=4)};function _l(a,c){if(!Jt)switch(a.tailMode){case"hidden":c=a.tail;for(var m=null;c!==null;)c.alternate!==null&&(m=c),c=c.sibling;m===null?a.tail=null:m.sibling=null;break;case"collapsed":m=a.tail;for(var y=null;m!==null;)m.alternate!==null&&(y=m),m=m.sibling;y===null?c||a.tail===null?a.tail=null:a.tail.sibling=null:y.sibling=null}}function ns(a){var c=a.alternate!==null&&a.alternate.child===a.child,m=0,y=0;if(c)for(var E=a.child;E!==null;)m|=E.lanes|E.childLanes,y|=E.subtreeFlags&14680064,y|=E.flags&14680064,E.return=a,E=E.sibling;else for(E=a.child;E!==null;)m|=E.lanes|E.childLanes,y|=E.subtreeFlags,y|=E.flags,E.return=a,E=E.sibling;return a.subtreeFlags|=y,a.childLanes=m,c}function fC(a,c,m){var y=c.pendingProps;switch(Gh(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)&&au(),ns(c),null;case 3:return y=c.stateNode,go(),Gt(Ns),Gt(es),om(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(a===null||a.child===null)&&(du(c)?c.flags|=4:a===null||a.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,gi!==null&&(Lm(gi),gi=null))),_m(a,c),ns(c),null;case 5:rm(c);var E=ma(kl.current);if(m=c.type,a!==null&&c.stateNode!=null)_0(a,c,m,y,E),a.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!y){if(c.stateNode===null)throw Error(s(166));return ns(c),null}if(a=ma(Pi.current),du(c)){y=c.stateNode,m=c.type;var $=c.memoizedProps;switch(y[Oi]=c,y[gl]=$,a=(c.mode&1)!==0,m){case"dialog":qt("cancel",y),qt("close",y);break;case"iframe":case"object":case"embed":qt("load",y);break;case"video":case"audio":for(E=0;E<ml.length;E++)qt(ml[E],y);break;case"source":qt("error",y);break;case"img":case"image":case"link":qt("error",y),qt("load",y);break;case"details":qt("toggle",y);break;case"input":Fe(y,$),qt("invalid",y);break;case"select":y._wrapperState={wasMultiple:!!$.multiple},qt("invalid",y);break;case"textarea":rt(y,$),qt("invalid",y)}Cn(m,$),E=null;for(var W in $)if($.hasOwnProperty(W)){var ie=$[W];W==="children"?typeof ie=="string"?y.textContent!==ie&&($.suppressHydrationWarning!==!0&&su(y.textContent,ie,a),E=["children",ie]):typeof ie=="number"&&y.textContent!==""+ie&&($.suppressHydrationWarning!==!0&&su(y.textContent,ie,a),E=["children",""+ie]):r.hasOwnProperty(W)&&ie!=null&&W==="onScroll"&&qt("scroll",y)}switch(m){case"input":ze(y),Ke(y,$,!0);break;case"textarea":ze(y),rn(y);break;case"select":case"option":break;default:typeof $.onClick=="function"&&(y.onclick=iu)}y=E,c.updateQueue=y,y!==null&&(c.flags|=4)}else{W=E.nodeType===9?E:E.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=Zt(m)),a==="http://www.w3.org/1999/xhtml"?m==="script"?(a=W.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof y.is=="string"?a=W.createElement(m,{is:y.is}):(a=W.createElement(m),m==="select"&&(W=a,y.multiple?W.multiple=!0:y.size&&(W.size=y.size))):a=W.createElementNS(a,m),a[Oi]=c,a[gl]=y,S0(a,c,!1,!1),c.stateNode=a;e:{switch(W=as(m,y),m){case"dialog":qt("cancel",a),qt("close",a),E=y;break;case"iframe":case"object":case"embed":qt("load",a),E=y;break;case"video":case"audio":for(E=0;E<ml.length;E++)qt(ml[E],a);E=y;break;case"source":qt("error",a),E=y;break;case"img":case"image":case"link":qt("error",a),qt("load",a),E=y;break;case"details":qt("toggle",a),E=y;break;case"input":Fe(a,y),E=ye(a,y),qt("invalid",a);break;case"option":E=y;break;case"select":a._wrapperState={wasMultiple:!!y.multiple},E=V({},y,{value:void 0}),qt("invalid",a);break;case"textarea":rt(a,y),E=En(a,y),qt("invalid",a);break;default:E=y}Cn(m,E),ie=E;for($ in ie)if(ie.hasOwnProperty($)){var oe=ie[$];$==="style"?rs(a,oe):$==="dangerouslySetInnerHTML"?(oe=oe?oe.__html:void 0,oe!=null&&Rn(a,oe)):$==="children"?typeof oe=="string"?(m!=="textarea"||oe!=="")&&fn(a,oe):typeof oe=="number"&&fn(a,""+oe):$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&$!=="autoFocus"&&(r.hasOwnProperty($)?oe!=null&&$==="onScroll"&&qt("scroll",a):oe!=null&&S(a,$,oe,W))}switch(m){case"input":ze(a),Ke(a,y,!1);break;case"textarea":ze(a),rn(a);break;case"option":y.value!=null&&a.setAttribute("value",""+se(y.value));break;case"select":a.multiple=!!y.multiple,$=y.value,$!=null?Mt(a,!!y.multiple,$,!1):y.defaultValue!=null&&Mt(a,!!y.multiple,y.defaultValue,!0);break;default:typeof E.onClick=="function"&&(a.onclick=iu)}switch(m){case"button":case"input":case"select":case"textarea":y=!!y.autoFocus;break e;case"img":y=!0;break e;default:y=!1}}y&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return ns(c),null;case 6:if(a&&c.stateNode!=null)E0(a,c,a.memoizedProps,y);else{if(typeof y!="string"&&c.stateNode===null)throw Error(s(166));if(m=ma(kl.current),ma(Pi.current),du(c)){if(y=c.stateNode,m=c.memoizedProps,y[Oi]=c,($=y.nodeValue!==m)&&(a=Ls,a!==null))switch(a.tag){case 3:su(y.nodeValue,m,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&su(y.nodeValue,m,(a.mode&1)!==0)}$&&(c.flags|=4)}else y=(m.nodeType===9?m:m.ownerDocument).createTextNode(y),y[Oi]=c,c.stateNode=y}return ns(c),null;case 13:if(Gt(on),y=c.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(Jt&&zs!==null&&(c.mode&1)!==0&&(c.flags&128)===0)$v(),ho(),c.flags|=98560,$=!1;else if($=du(c),y!==null&&y.dehydrated!==null){if(a===null){if(!$)throw Error(s(318));if($=c.memoizedState,$=$!==null?$.dehydrated:null,!$)throw Error(s(317));$[Oi]=c}else ho(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;ns(c),$=!1}else gi!==null&&(Lm(gi),gi=null),$=!0;if(!$)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=m,c):(y=y!==null,y!==(a!==null&&a.memoizedState!==null)&&y&&(c.child.flags|=8192,(c.mode&1)!==0&&(a===null||(on.current&1)!==0?Mn===0&&(Mn=3):Fm())),c.updateQueue!==null&&(c.flags|=4),ns(c),null);case 4:return go(),_m(a,c),a===null&&fl(c.stateNode.containerInfo),ns(c),null;case 10:return em(c.type._context),ns(c),null;case 17:return ws(c.type)&&au(),ns(c),null;case 19:if(Gt(on),$=c.memoizedState,$===null)return ns(c),null;if(y=(c.flags&128)!==0,W=$.rendering,W===null)if(y)_l($,!1);else{if(Mn!==0||a!==null&&(a.flags&128)!==0)for(a=c.child;a!==null;){if(W=xu(a),W!==null){for(c.flags|=128,_l($,!1),y=W.updateQueue,y!==null&&(c.updateQueue=y,c.flags|=4),c.subtreeFlags=0,y=m,m=c.child;m!==null;)$=m,a=y,$.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}),m=m.sibling;return Wt(on,on.current&1|2),c.child}a=a.sibling}$.tail!==null&&Dt()>bo&&(c.flags|=128,y=!0,_l($,!1),c.lanes=4194304)}else{if(!y)if(a=xu(W),a!==null){if(c.flags|=128,y=!0,m=a.updateQueue,m!==null&&(c.updateQueue=m,c.flags|=4),_l($,!0),$.tail===null&&$.tailMode==="hidden"&&!W.alternate&&!Jt)return ns(c),null}else 2*Dt()-$.renderingStartTime>bo&&m!==1073741824&&(c.flags|=128,y=!0,_l($,!1),c.lanes=4194304);$.isBackwards?(W.sibling=c.child,c.child=W):(m=$.last,m!==null?m.sibling=W:c.child=W,$.last=W)}return $.tail!==null?(c=$.tail,$.rendering=c,$.tail=c.sibling,$.renderingStartTime=Dt(),c.sibling=null,m=on.current,Wt(on,y?m&1|2:m&1),c):(ns(c),null);case 22:case 23:return Dm(),y=c.memoizedState!==null,a!==null&&a.memoizedState!==null!==y&&(c.flags|=8192),y&&(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 pC(a,c){switch(Gh(c),c.tag){case 1:return ws(c.type)&&au(),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return go(),Gt(Ns),Gt(es),om(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 5:return rm(c),null;case 13:if(Gt(on),a=c.memoizedState,a!==null&&a.dehydrated!==null){if(c.alternate===null)throw Error(s(340));ho()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 19:return Gt(on),null;case 4:return go(),null;case 10:return em(c.type._context),null;case 22:case 23:return Dm(),null;case 24:return null;default:return null}}var _u=!1,ss=!1,gC=typeof WeakSet=="function"?WeakSet:Set,Ve=null;function vo(a,c){var m=a.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(y){hn(a,c,y)}else m.current=null}function Em(a,c,m){try{m()}catch(y){hn(a,c,y)}}var C0=!1;function xC(a,c){if(Dh=nt,a=av(),Ih(a)){if("selectionStart"in a)var m={start:a.selectionStart,end:a.selectionEnd};else e:{m=(m=a.ownerDocument)&&m.defaultView||window;var y=m.getSelection&&m.getSelection();if(y&&y.rangeCount!==0){m=y.anchorNode;var E=y.anchorOffset,$=y.focusNode;y=y.focusOffset;try{m.nodeType,$.nodeType}catch{m=null;break e}var W=0,ie=-1,oe=-1,xe=0,Ae=0,$e=a,Ee=null;t:for(;;){for(var Ze;$e!==m||E!==0&&$e.nodeType!==3||(ie=W+E),$e!==$||y!==0&&$e.nodeType!==3||(oe=W+y),$e.nodeType===3&&(W+=$e.nodeValue.length),(Ze=$e.firstChild)!==null;)Ee=$e,$e=Ze;for(;;){if($e===a)break t;if(Ee===m&&++xe===E&&(ie=W),Ee===$&&++Ae===y&&(oe=W),(Ze=$e.nextSibling)!==null)break;$e=Ee,Ee=$e.parentNode}$e=Ze}m=ie===-1||oe===-1?null:{start:ie,end:oe}}else m=null}m=m||{start:0,end:0}}else m=null;for(Fh={focusedElem:a,selectionRange:m},nt=!1,Ve=c;Ve!==null;)if(c=Ve,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,Ve=a;else for(;Ve!==null;){c=Ve;try{var qe=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(qe!==null){var Xe=qe.memoizedProps,xn=qe.memoizedState,pe=c.stateNode,de=pe.getSnapshotBeforeUpdate(c.elementType===c.type?Xe:xi(c.type,Xe),xn);pe.__reactInternalSnapshotBeforeUpdate=de}break;case 3:var ge=c.stateNode.containerInfo;ge.nodeType===1?ge.textContent="":ge.nodeType===9&&ge.documentElement&&ge.removeChild(ge.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(Pe){hn(c,c.return,Pe)}if(a=c.sibling,a!==null){a.return=c.return,Ve=a;break}Ve=c.return}return qe=C0,C0=!1,qe}function El(a,c,m){var y=c.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var E=y=y.next;do{if((E.tag&a)===a){var $=E.destroy;E.destroy=void 0,$!==void 0&&Em(c,m,$)}E=E.next}while(E!==y)}}function Eu(a,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var m=c=c.next;do{if((m.tag&a)===a){var y=m.create;m.destroy=y()}m=m.next}while(m!==c)}}function Cm(a){var c=a.ref;if(c!==null){var m=a.stateNode;switch(a.tag){case 5:a=m;break;default:a=m}typeof c=="function"?c(a):c.current=a}}function A0(a){var c=a.alternate;c!==null&&(a.alternate=null,A0(c)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(c=a.stateNode,c!==null&&(delete c[Oi],delete c[gl],delete c[Zh],delete c[JE],delete c[eC])),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 $0(a){return a.tag===5||a.tag===3||a.tag===4}function I0(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||$0(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 Am(a,c,m){var y=a.tag;if(y===5||y===6)a=a.stateNode,c?m.nodeType===8?m.parentNode.insertBefore(a,c):m.insertBefore(a,c):(m.nodeType===8?(c=m.parentNode,c.insertBefore(a,m)):(c=m,c.appendChild(a)),m=m._reactRootContainer,m!=null||c.onclick!==null||(c.onclick=iu));else if(y!==4&&(a=a.child,a!==null))for(Am(a,c,m),a=a.sibling;a!==null;)Am(a,c,m),a=a.sibling}function $m(a,c,m){var y=a.tag;if(y===5||y===6)a=a.stateNode,c?m.insertBefore(a,c):m.appendChild(a);else if(y!==4&&(a=a.child,a!==null))for($m(a,c,m),a=a.sibling;a!==null;)$m(a,c,m),a=a.sibling}var Wn=null,vi=!1;function Mr(a,c,m){for(m=m.child;m!==null;)T0(a,c,m),m=m.sibling}function T0(a,c,m){if(mt&&typeof mt.onCommitFiberUnmount=="function")try{mt.onCommitFiberUnmount(ut,m)}catch{}switch(m.tag){case 5:ss||vo(m,c);case 6:var y=Wn,E=vi;Wn=null,Mr(a,c,m),Wn=y,vi=E,Wn!==null&&(vi?(a=Wn,m=m.stateNode,a.nodeType===8?a.parentNode.removeChild(m):a.removeChild(m)):Wn.removeChild(m.stateNode));break;case 18:Wn!==null&&(vi?(a=Wn,m=m.stateNode,a.nodeType===8?Hh(a.parentNode,m):a.nodeType===1&&Hh(a,m),Ne(a)):Hh(Wn,m.stateNode));break;case 4:y=Wn,E=vi,Wn=m.stateNode.containerInfo,vi=!0,Mr(a,c,m),Wn=y,vi=E;break;case 0:case 11:case 14:case 15:if(!ss&&(y=m.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){E=y=y.next;do{var $=E,W=$.destroy;$=$.tag,W!==void 0&&(($&2)!==0||($&4)!==0)&&Em(m,c,W),E=E.next}while(E!==y)}Mr(a,c,m);break;case 1:if(!ss&&(vo(m,c),y=m.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=m.memoizedProps,y.state=m.memoizedState,y.componentWillUnmount()}catch(ie){hn(m,c,ie)}Mr(a,c,m);break;case 21:Mr(a,c,m);break;case 22:m.mode&1?(ss=(y=ss)||m.memoizedState!==null,Mr(a,c,m),ss=y):Mr(a,c,m);break;default:Mr(a,c,m)}}function M0(a){var c=a.updateQueue;if(c!==null){a.updateQueue=null;var m=a.stateNode;m===null&&(m=a.stateNode=new gC),c.forEach(function(y){var E=_C.bind(null,a,y);m.has(y)||(m.add(y),y.then(E,E))})}}function yi(a,c){var m=c.deletions;if(m!==null)for(var y=0;y<m.length;y++){var E=m[y];try{var $=a,W=c,ie=W;e:for(;ie!==null;){switch(ie.tag){case 5:Wn=ie.stateNode,vi=!1;break e;case 3:Wn=ie.stateNode.containerInfo,vi=!0;break e;case 4:Wn=ie.stateNode.containerInfo,vi=!0;break e}ie=ie.return}if(Wn===null)throw Error(s(160));T0($,W,E),Wn=null,vi=!1;var oe=E.alternate;oe!==null&&(oe.return=null),E.return=null}catch(xe){hn(E,c,xe)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)R0(c,a),c=c.sibling}function R0(a,c){var m=a.alternate,y=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(yi(c,a),zi(a),y&4){try{El(3,a,a.return),Eu(3,a)}catch(Xe){hn(a,a.return,Xe)}try{El(5,a,a.return)}catch(Xe){hn(a,a.return,Xe)}}break;case 1:yi(c,a),zi(a),y&512&&m!==null&&vo(m,m.return);break;case 5:if(yi(c,a),zi(a),y&512&&m!==null&&vo(m,m.return),a.flags&32){var E=a.stateNode;try{fn(E,"")}catch(Xe){hn(a,a.return,Xe)}}if(y&4&&(E=a.stateNode,E!=null)){var $=a.memoizedProps,W=m!==null?m.memoizedProps:$,ie=a.type,oe=a.updateQueue;if(a.updateQueue=null,oe!==null)try{ie==="input"&&$.type==="radio"&&$.name!=null&&Re(E,$),as(ie,W);var xe=as(ie,$);for(W=0;W<oe.length;W+=2){var Ae=oe[W],$e=oe[W+1];Ae==="style"?rs(E,$e):Ae==="dangerouslySetInnerHTML"?Rn(E,$e):Ae==="children"?fn(E,$e):S(E,Ae,$e,xe)}switch(ie){case"input":Qe(E,$);break;case"textarea":Pt(E,$);break;case"select":var Ee=E._wrapperState.wasMultiple;E._wrapperState.wasMultiple=!!$.multiple;var Ze=$.value;Ze!=null?Mt(E,!!$.multiple,Ze,!1):Ee!==!!$.multiple&&($.defaultValue!=null?Mt(E,!!$.multiple,$.defaultValue,!0):Mt(E,!!$.multiple,$.multiple?[]:"",!1))}E[gl]=$}catch(Xe){hn(a,a.return,Xe)}}break;case 6:if(yi(c,a),zi(a),y&4){if(a.stateNode===null)throw Error(s(162));E=a.stateNode,$=a.memoizedProps;try{E.nodeValue=$}catch(Xe){hn(a,a.return,Xe)}}break;case 3:if(yi(c,a),zi(a),y&4&&m!==null&&m.memoizedState.isDehydrated)try{Ne(c.containerInfo)}catch(Xe){hn(a,a.return,Xe)}break;case 4:yi(c,a),zi(a);break;case 13:yi(c,a),zi(a),E=a.child,E.flags&8192&&($=E.memoizedState!==null,E.stateNode.isHidden=$,!$||E.alternate!==null&&E.alternate.memoizedState!==null||(Mm=Dt())),y&4&&M0(a);break;case 22:if(Ae=m!==null&&m.memoizedState!==null,a.mode&1?(ss=(xe=ss)||Ae,yi(c,a),ss=xe):yi(c,a),zi(a),y&8192){if(xe=a.memoizedState!==null,(a.stateNode.isHidden=xe)&&!Ae&&(a.mode&1)!==0)for(Ve=a,Ae=a.child;Ae!==null;){for($e=Ve=Ae;Ve!==null;){switch(Ee=Ve,Ze=Ee.child,Ee.tag){case 0:case 11:case 14:case 15:El(4,Ee,Ee.return);break;case 1:vo(Ee,Ee.return);var qe=Ee.stateNode;if(typeof qe.componentWillUnmount=="function"){y=Ee,m=Ee.return;try{c=y,qe.props=c.memoizedProps,qe.state=c.memoizedState,qe.componentWillUnmount()}catch(Xe){hn(y,m,Xe)}}break;case 5:vo(Ee,Ee.return);break;case 22:if(Ee.memoizedState!==null){L0($e);continue}}Ze!==null?(Ze.return=Ee,Ve=Ze):L0($e)}Ae=Ae.sibling}e:for(Ae=null,$e=a;;){if($e.tag===5){if(Ae===null){Ae=$e;try{E=$e.stateNode,xe?($=E.style,typeof $.setProperty=="function"?$.setProperty("display","none","important"):$.display="none"):(ie=$e.stateNode,oe=$e.memoizedProps.style,W=oe!=null&&oe.hasOwnProperty("display")?oe.display:null,ie.style.display=ps("display",W))}catch(Xe){hn(a,a.return,Xe)}}}else if($e.tag===6){if(Ae===null)try{$e.stateNode.nodeValue=xe?"":$e.memoizedProps}catch(Xe){hn(a,a.return,Xe)}}else if(($e.tag!==22&&$e.tag!==23||$e.memoizedState===null||$e===a)&&$e.child!==null){$e.child.return=$e,$e=$e.child;continue}if($e===a)break e;for(;$e.sibling===null;){if($e.return===null||$e.return===a)break e;Ae===$e&&(Ae=null),$e=$e.return}Ae===$e&&(Ae=null),$e.sibling.return=$e.return,$e=$e.sibling}}break;case 19:yi(c,a),zi(a),y&4&&M0(a);break;case 21:break;default:yi(c,a),zi(a)}}function zi(a){var c=a.flags;if(c&2){try{e:{for(var m=a.return;m!==null;){if($0(m)){var y=m;break e}m=m.return}throw Error(s(160))}switch(y.tag){case 5:var E=y.stateNode;y.flags&32&&(fn(E,""),y.flags&=-33);var $=I0(a);$m(a,$,E);break;case 3:case 4:var W=y.stateNode.containerInfo,ie=I0(a);Am(a,ie,W);break;default:throw Error(s(161))}}catch(oe){hn(a,a.return,oe)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function vC(a,c,m){Ve=a,O0(a)}function O0(a,c,m){for(var y=(a.mode&1)!==0;Ve!==null;){var E=Ve,$=E.child;if(E.tag===22&&y){var W=E.memoizedState!==null||_u;if(!W){var ie=E.alternate,oe=ie!==null&&ie.memoizedState!==null||ss;ie=_u;var xe=ss;if(_u=W,(ss=oe)&&!xe)for(Ve=E;Ve!==null;)W=Ve,oe=W.child,W.tag===22&&W.memoizedState!==null?z0(E):oe!==null?(oe.return=W,Ve=oe):z0(E);for(;$!==null;)Ve=$,O0($),$=$.sibling;Ve=E,_u=ie,ss=xe}P0(a)}else(E.subtreeFlags&8772)!==0&&$!==null?($.return=E,Ve=$):P0(a)}}function P0(a){for(;Ve!==null;){var c=Ve;if((c.flags&8772)!==0){var m=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:ss||Eu(5,c);break;case 1:var y=c.stateNode;if(c.flags&4&&!ss)if(m===null)y.componentDidMount();else{var E=c.elementType===c.type?m.memoizedProps:xi(c.type,m.memoizedProps);y.componentDidUpdate(E,m.memoizedState,y.__reactInternalSnapshotBeforeUpdate)}var $=c.updateQueue;$!==null&&Lv(c,$,y);break;case 3:var W=c.updateQueue;if(W!==null){if(m=null,c.child!==null)switch(c.child.tag){case 5:m=c.child.stateNode;break;case 1:m=c.child.stateNode}Lv(c,W,m)}break;case 5:var ie=c.stateNode;if(m===null&&c.flags&4){m=ie;var oe=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":oe.autoFocus&&m.focus();break;case"img":oe.src&&(m.src=oe.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var xe=c.alternate;if(xe!==null){var Ae=xe.memoizedState;if(Ae!==null){var $e=Ae.dehydrated;$e!==null&&Ne($e)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}ss||c.flags&512&&Cm(c)}catch(Ee){hn(c,c.return,Ee)}}if(c===a){Ve=null;break}if(m=c.sibling,m!==null){m.return=c.return,Ve=m;break}Ve=c.return}}function L0(a){for(;Ve!==null;){var c=Ve;if(c===a){Ve=null;break}var m=c.sibling;if(m!==null){m.return=c.return,Ve=m;break}Ve=c.return}}function z0(a){for(;Ve!==null;){var c=Ve;try{switch(c.tag){case 0:case 11:case 15:var m=c.return;try{Eu(4,c)}catch(oe){hn(c,m,oe)}break;case 1:var y=c.stateNode;if(typeof y.componentDidMount=="function"){var E=c.return;try{y.componentDidMount()}catch(oe){hn(c,E,oe)}}var $=c.return;try{Cm(c)}catch(oe){hn(c,$,oe)}break;case 5:var W=c.return;try{Cm(c)}catch(oe){hn(c,W,oe)}}}catch(oe){hn(c,c.return,oe)}if(c===a){Ve=null;break}var ie=c.sibling;if(ie!==null){ie.return=c.return,Ve=ie;break}Ve=c.return}}var yC=Math.ceil,Cu=_.ReactCurrentDispatcher,Im=_.ReactCurrentOwner,si=_.ReactCurrentBatchConfig,Et=0,zn=null,jn=null,Vn=0,Ds=0,yo=Cr(0),Mn=0,Cl=null,pa=0,Au=0,Tm=0,Al=null,_s=null,Mm=0,bo=1/0,or=null,$u=!1,Rm=null,Rr=null,Iu=!1,Or=null,Tu=0,$l=0,Om=null,Mu=-1,Ru=0;function ds(){return(Et&6)!==0?Dt():Mu!==-1?Mu:Mu=Dt()}function Pr(a){return(a.mode&1)===0?1:(Et&2)!==0&&Vn!==0?Vn&-Vn:nC.transition!==null?(Ru===0&&(Ru=Sr()),Ru):(a=Nt,a!==0||(a=window.event,a=a===void 0?16:Ji(a.type)),a)}function bi(a,c,m,y){if(50<$l)throw $l=0,Om=null,Error(s(185));bs(a,m,y),((Et&2)===0||a!==zn)&&(a===zn&&((Et&2)===0&&(Au|=m),Mn===4&&Lr(a,Vn)),Es(a,y),m===1&&Et===0&&(c.mode&1)===0&&(bo=Dt()+500,lu&&$r()))}function Es(a,c){var m=a.callbackNode;wr(a,c);var y=ys(a,a===zn?Vn:0);if(y===0)m!==null&&os(m),a.callbackNode=null,a.callbackPriority=0;else if(c=y&-y,a.callbackPriority!==c){if(m!=null&&os(m),c===1)a.tag===0?tC(F0.bind(null,a)):Sv(F0.bind(null,a)),XE(function(){(Et&6)===0&&$r()}),m=null;else{switch(at(y)){case 1:m=Ki;break;case 4:m=mi;break;case 16:m=Mi;break;case 536870912:m=We;break;default:m=Mi}m=G0(m,D0.bind(null,a))}a.callbackPriority=c,a.callbackNode=m}}function D0(a,c){if(Mu=-1,Ru=0,(Et&6)!==0)throw Error(s(327));var m=a.callbackNode;if(ko()&&a.callbackNode!==m)return null;var y=ys(a,a===zn?Vn:0);if(y===0)return null;if((y&30)!==0||(y&a.expiredLanes)!==0||c)c=Ou(a,y);else{c=y;var E=Et;Et|=2;var $=B0();(zn!==a||Vn!==c)&&(or=null,bo=Dt()+500,xa(a,c));do try{jC();break}catch(ie){U0(a,ie)}while(!0);Jh(),Cu.current=$,Et=E,jn!==null?c=0:(zn=null,Vn=0,c=Mn)}if(c!==0){if(c===2&&(E=Ri(a),E!==0&&(y=E,c=Pm(a,E))),c===1)throw m=Cl,xa(a,0),Lr(a,y),Es(a,Dt()),m;if(c===6)Lr(a,y);else{if(E=a.current.alternate,(y&30)===0&&!bC(E)&&(c=Ou(a,y),c===2&&($=Ri(a),$!==0&&(y=$,c=Pm(a,$))),c===1))throw m=Cl,xa(a,0),Lr(a,y),Es(a,Dt()),m;switch(a.finishedWork=E,a.finishedLanes=y,c){case 0:case 1:throw Error(s(345));case 2:va(a,_s,or);break;case 3:if(Lr(a,y),(y&130023424)===y&&(c=Mm+500-Dt(),10<c)){if(ys(a,0)!==0)break;if(E=a.suspendedLanes,(E&y)!==y){ds(),a.pingedLanes|=a.suspendedLanes&E;break}a.timeoutHandle=Bh(va.bind(null,a,_s,or),c);break}va(a,_s,or);break;case 4:if(Lr(a,y),(y&4194240)===y)break;for(c=a.eventTimes,E=-1;0<y;){var W=31-Ft(y);$=1<<W,W=c[W],W>E&&(E=W),y&=~$}if(y=E,y=Dt()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*yC(y/1960))-y,10<y){a.timeoutHandle=Bh(va.bind(null,a,_s,or),y);break}va(a,_s,or);break;case 5:va(a,_s,or);break;default:throw Error(s(329))}}}return Es(a,Dt()),a.callbackNode===m?D0.bind(null,a):null}function Pm(a,c){var m=Al;return a.current.memoizedState.isDehydrated&&(xa(a,c).flags|=256),a=Ou(a,c),a!==2&&(c=_s,_s=m,c!==null&&Lm(c)),a}function Lm(a){_s===null?_s=a:_s.push.apply(_s,a)}function bC(a){for(var c=a;;){if(c.flags&16384){var m=c.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var y=0;y<m.length;y++){var E=m[y],$=E.getSnapshot;E=E.value;try{if(!pi($(),E))return!1}catch{return!1}}}if(m=c.child,c.subtreeFlags&16384&&m!==null)m.return=c,c=m;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 Lr(a,c){for(c&=~Tm,c&=~Au,a.suspendedLanes|=c,a.pingedLanes&=~c,a=a.expirationTimes;0<c;){var m=31-Ft(c),y=1<<m;a[m]=-1,c&=~y}}function F0(a){if((Et&6)!==0)throw Error(s(327));ko();var c=ys(a,0);if((c&1)===0)return Es(a,Dt()),null;var m=Ou(a,c);if(a.tag!==0&&m===2){var y=Ri(a);y!==0&&(c=y,m=Pm(a,y))}if(m===1)throw m=Cl,xa(a,0),Lr(a,c),Es(a,Dt()),m;if(m===6)throw Error(s(345));return a.finishedWork=a.current.alternate,a.finishedLanes=c,va(a,_s,or),Es(a,Dt()),null}function zm(a,c){var m=Et;Et|=1;try{return a(c)}finally{Et=m,Et===0&&(bo=Dt()+500,lu&&$r())}}function ga(a){Or!==null&&Or.tag===0&&(Et&6)===0&&ko();var c=Et;Et|=1;var m=si.transition,y=Nt;try{if(si.transition=null,Nt=1,a)return a()}finally{Nt=y,si.transition=m,Et=c,(Et&6)===0&&$r()}}function Dm(){Ds=yo.current,Gt(yo)}function xa(a,c){a.finishedWork=null,a.finishedLanes=0;var m=a.timeoutHandle;if(m!==-1&&(a.timeoutHandle=-1,YE(m)),jn!==null)for(m=jn.return;m!==null;){var y=m;switch(Gh(y),y.tag){case 1:y=y.type.childContextTypes,y!=null&&au();break;case 3:go(),Gt(Ns),Gt(es),om();break;case 5:rm(y);break;case 4:go();break;case 13:Gt(on);break;case 19:Gt(on);break;case 10:em(y.type._context);break;case 22:case 23:Dm()}m=m.return}if(zn=a,jn=a=zr(a.current,null),Vn=Ds=c,Mn=0,Cl=null,Tm=Au=pa=0,_s=Al=null,ha!==null){for(c=0;c<ha.length;c++)if(m=ha[c],y=m.interleaved,y!==null){m.interleaved=null;var E=y.next,$=m.pending;if($!==null){var W=$.next;$.next=E,y.next=W}m.pending=y}ha=null}return a}function U0(a,c){do{var m=jn;try{if(Jh(),vu.current=ju,yu){for(var y=ln.memoizedState;y!==null;){var E=y.queue;E!==null&&(E.pending=null),y=y.next}yu=!1}if(fa=0,Ln=Tn=ln=null,jl=!1,Nl=0,Im.current=null,m===null||m.return===null){Mn=1,Cl=c,jn=null;break}e:{var $=a,W=m.return,ie=m,oe=c;if(c=Vn,ie.flags|=32768,oe!==null&&typeof oe=="object"&&typeof oe.then=="function"){var xe=oe,Ae=ie,$e=Ae.tag;if((Ae.mode&1)===0&&($e===0||$e===11||$e===15)){var Ee=Ae.alternate;Ee?(Ae.updateQueue=Ee.updateQueue,Ae.memoizedState=Ee.memoizedState,Ae.lanes=Ee.lanes):(Ae.updateQueue=null,Ae.memoizedState=null)}var Ze=h0(W);if(Ze!==null){Ze.flags&=-257,m0(Ze,W,ie,$,c),Ze.mode&1&&d0($,xe,c),c=Ze,oe=xe;var qe=c.updateQueue;if(qe===null){var Xe=new Set;Xe.add(oe),c.updateQueue=Xe}else qe.add(oe);break e}else{if((c&1)===0){d0($,xe,c),Fm();break e}oe=Error(s(426))}}else if(Jt&&ie.mode&1){var xn=h0(W);if(xn!==null){(xn.flags&65536)===0&&(xn.flags|=256),m0(xn,W,ie,$,c),Xh(xo(oe,ie));break e}}$=oe=xo(oe,ie),Mn!==4&&(Mn=2),Al===null?Al=[$]:Al.push($),$=W;do{switch($.tag){case 3:$.flags|=65536,c&=-c,$.lanes|=c;var pe=c0($,oe,c);Pv($,pe);break e;case 1:ie=oe;var de=$.type,ge=$.stateNode;if(($.flags&128)===0&&(typeof de.getDerivedStateFromError=="function"||ge!==null&&typeof ge.componentDidCatch=="function"&&(Rr===null||!Rr.has(ge)))){$.flags|=65536,c&=-c,$.lanes|=c;var Pe=u0($,ie,c);Pv($,Pe);break e}}$=$.return}while($!==null)}Z0(m)}catch(Je){c=Je,jn===m&&m!==null&&(jn=m=m.return);continue}break}while(!0)}function B0(){var a=Cu.current;return Cu.current=ju,a===null?ju:a}function Fm(){(Mn===0||Mn===3||Mn===2)&&(Mn=4),zn===null||(pa&268435455)===0&&(Au&268435455)===0||Lr(zn,Vn)}function Ou(a,c){var m=Et;Et|=2;var y=B0();(zn!==a||Vn!==c)&&(or=null,xa(a,c));do try{kC();break}catch(E){U0(a,E)}while(!0);if(Jh(),Et=m,Cu.current=y,jn!==null)throw Error(s(261));return zn=null,Vn=0,Mn}function kC(){for(;jn!==null;)H0(jn)}function jC(){for(;jn!==null&&!Gi();)H0(jn)}function H0(a){var c=q0(a.alternate,a,Ds);a.memoizedProps=a.pendingProps,c===null?Z0(a):jn=c,Im.current=null}function Z0(a){var c=a;do{var m=c.alternate;if(a=c.return,(c.flags&32768)===0){if(m=fC(m,c,Ds),m!==null){jn=m;return}}else{if(m=pC(m,c),m!==null){m.flags&=32767,jn=m;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{Mn=6,jn=null;return}}if(c=c.sibling,c!==null){jn=c;return}jn=c=a}while(c!==null);Mn===0&&(Mn=5)}function va(a,c,m){var y=Nt,E=si.transition;try{si.transition=null,Nt=1,NC(a,c,m,y)}finally{si.transition=E,Nt=y}return null}function NC(a,c,m,y){do ko();while(Or!==null);if((Et&6)!==0)throw Error(s(327));m=a.finishedWork;var E=a.finishedLanes;if(m===null)return null;if(a.finishedWork=null,a.finishedLanes=0,m===a.current)throw Error(s(177));a.callbackNode=null,a.callbackPriority=0;var $=m.lanes|m.childLanes;if(In(a,$),a===zn&&(jn=zn=null,Vn=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||Iu||(Iu=!0,G0(Mi,function(){return ko(),null})),$=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||$){$=si.transition,si.transition=null;var W=Nt;Nt=1;var ie=Et;Et|=4,Im.current=null,xC(a,m),R0(m,a),HE(Fh),nt=!!Dh,Fh=Dh=null,a.current=m,vC(m),hi(),Et=ie,Nt=W,si.transition=$}else a.current=m;if(Iu&&(Iu=!1,Or=a,Tu=E),$=a.pendingLanes,$===0&&(Rr=null),Rt(m.stateNode),Es(a,Dt()),c!==null)for(y=a.onRecoverableError,m=0;m<c.length;m++)E=c[m],y(E.value,{componentStack:E.stack,digest:E.digest});if($u)throw $u=!1,a=Rm,Rm=null,a;return(Tu&1)!==0&&a.tag!==0&&ko(),$=a.pendingLanes,($&1)!==0?a===Om?$l++:($l=0,Om=a):$l=0,$r(),null}function ko(){if(Or!==null){var a=at(Tu),c=si.transition,m=Nt;try{if(si.transition=null,Nt=16>a?16:a,Or===null)var y=!1;else{if(a=Or,Or=null,Tu=0,(Et&6)!==0)throw Error(s(331));var E=Et;for(Et|=4,Ve=a.current;Ve!==null;){var $=Ve,W=$.child;if((Ve.flags&16)!==0){var ie=$.deletions;if(ie!==null){for(var oe=0;oe<ie.length;oe++){var xe=ie[oe];for(Ve=xe;Ve!==null;){var Ae=Ve;switch(Ae.tag){case 0:case 11:case 15:El(8,Ae,$)}var $e=Ae.child;if($e!==null)$e.return=Ae,Ve=$e;else for(;Ve!==null;){Ae=Ve;var Ee=Ae.sibling,Ze=Ae.return;if(A0(Ae),Ae===xe){Ve=null;break}if(Ee!==null){Ee.return=Ze,Ve=Ee;break}Ve=Ze}}}var qe=$.alternate;if(qe!==null){var Xe=qe.child;if(Xe!==null){qe.child=null;do{var xn=Xe.sibling;Xe.sibling=null,Xe=xn}while(Xe!==null)}}Ve=$}}if(($.subtreeFlags&2064)!==0&&W!==null)W.return=$,Ve=W;else e:for(;Ve!==null;){if($=Ve,($.flags&2048)!==0)switch($.tag){case 0:case 11:case 15:El(9,$,$.return)}var pe=$.sibling;if(pe!==null){pe.return=$.return,Ve=pe;break e}Ve=$.return}}var de=a.current;for(Ve=de;Ve!==null;){W=Ve;var ge=W.child;if((W.subtreeFlags&2064)!==0&&ge!==null)ge.return=W,Ve=ge;else e:for(W=de;Ve!==null;){if(ie=Ve,(ie.flags&2048)!==0)try{switch(ie.tag){case 0:case 11:case 15:Eu(9,ie)}}catch(Je){hn(ie,ie.return,Je)}if(ie===W){Ve=null;break e}var Pe=ie.sibling;if(Pe!==null){Pe.return=ie.return,Ve=Pe;break e}Ve=ie.return}}if(Et=E,$r(),mt&&typeof mt.onPostCommitFiberRoot=="function")try{mt.onPostCommitFiberRoot(ut,a)}catch{}y=!0}return y}finally{Nt=m,si.transition=c}}return!1}function W0(a,c,m){c=xo(m,c),c=c0(a,c,1),a=Tr(a,c,1),c=ds(),a!==null&&(bs(a,1,c),Es(a,c))}function hn(a,c,m){if(a.tag===3)W0(a,a,m);else for(;c!==null;){if(c.tag===3){W0(c,a,m);break}else if(c.tag===1){var y=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(Rr===null||!Rr.has(y))){a=xo(m,a),a=u0(c,a,1),c=Tr(c,a,1),a=ds(),c!==null&&(bs(c,1,a),Es(c,a));break}}c=c.return}}function wC(a,c,m){var y=a.pingCache;y!==null&&y.delete(c),c=ds(),a.pingedLanes|=a.suspendedLanes&m,zn===a&&(Vn&m)===m&&(Mn===4||Mn===3&&(Vn&130023424)===Vn&&500>Dt()-Mm?xa(a,0):Tm|=m),Es(a,c)}function V0(a,c){c===0&&((a.mode&1)===0?c=1:(c=Ys,Ys<<=1,(Ys&130023424)===0&&(Ys=4194304)));var m=ds();a=ir(a,c),a!==null&&(bs(a,c,m),Es(a,m))}function SC(a){var c=a.memoizedState,m=0;c!==null&&(m=c.retryLane),V0(a,m)}function _C(a,c){var m=0;switch(a.tag){case 13:var y=a.stateNode,E=a.memoizedState;E!==null&&(m=E.retryLane);break;case 19:y=a.stateNode;break;default:throw Error(s(314))}y!==null&&y.delete(c),V0(a,m)}var q0;q0=function(a,c,m){if(a!==null)if(a.memoizedProps!==c.pendingProps||Ns.current)Ss=!0;else{if((a.lanes&m)===0&&(c.flags&128)===0)return Ss=!1,mC(a,c,m);Ss=(a.flags&131072)!==0}else Ss=!1,Jt&&(c.flags&1048576)!==0&&_v(c,uu,c.index);switch(c.lanes=0,c.tag){case 2:var y=c.type;Su(a,c),a=c.pendingProps;var E=lo(c,es.current);po(c,m),E=um(null,c,y,a,E,m);var $=dm();return c.flags|=1,typeof E=="object"&&E!==null&&typeof E.render=="function"&&E.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,ws(y)?($=!0,ou(c)):$=!1,c.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,sm(c),E.updater=Nu,c.stateNode=E,E._reactInternals=c,xm(c,y,a,m),c=km(null,c,y,!0,$,m)):(c.tag=0,Jt&&$&&qh(c),us(null,c,E,m),c=c.child),c;case 16:y=c.elementType;e:{switch(Su(a,c),a=c.pendingProps,E=y._init,y=E(y._payload),c.type=y,E=c.tag=CC(y),a=xi(y,a),E){case 0:c=bm(null,c,y,a,m);break e;case 1:c=y0(null,c,y,a,m);break e;case 11:c=f0(null,c,y,a,m);break e;case 14:c=p0(null,c,y,xi(y.type,a),m);break e}throw Error(s(306,y,""))}return c;case 0:return y=c.type,E=c.pendingProps,E=c.elementType===y?E:xi(y,E),bm(a,c,y,E,m);case 1:return y=c.type,E=c.pendingProps,E=c.elementType===y?E:xi(y,E),y0(a,c,y,E,m);case 3:e:{if(b0(c),a===null)throw Error(s(387));y=c.pendingProps,$=c.memoizedState,E=$.element,Ov(a,c),gu(c,y,null,m);var W=c.memoizedState;if(y=W.element,$.isDehydrated)if($={element:y,isDehydrated:!1,cache:W.cache,pendingSuspenseBoundaries:W.pendingSuspenseBoundaries,transitions:W.transitions},c.updateQueue.baseState=$,c.memoizedState=$,c.flags&256){E=xo(Error(s(423)),c),c=k0(a,c,y,m,E);break e}else if(y!==E){E=xo(Error(s(424)),c),c=k0(a,c,y,m,E);break e}else for(zs=Er(c.stateNode.containerInfo.firstChild),Ls=c,Jt=!0,gi=null,m=Mv(c,null,y,m),c.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(ho(),y===E){c=ar(a,c,m);break e}us(a,c,y,m)}c=c.child}return c;case 5:return zv(c),a===null&&Yh(c),y=c.type,E=c.pendingProps,$=a!==null?a.memoizedProps:null,W=E.children,Uh(y,E)?W=null:$!==null&&Uh(y,$)&&(c.flags|=32),v0(a,c),us(a,c,W,m),c.child;case 6:return a===null&&Yh(c),null;case 13:return j0(a,c,m);case 4:return im(c,c.stateNode.containerInfo),y=c.pendingProps,a===null?c.child=mo(c,null,y,m):us(a,c,y,m),c.child;case 11:return y=c.type,E=c.pendingProps,E=c.elementType===y?E:xi(y,E),f0(a,c,y,E,m);case 7:return us(a,c,c.pendingProps,m),c.child;case 8:return us(a,c,c.pendingProps.children,m),c.child;case 12:return us(a,c,c.pendingProps.children,m),c.child;case 10:e:{if(y=c.type._context,E=c.pendingProps,$=c.memoizedProps,W=E.value,Wt(mu,y._currentValue),y._currentValue=W,$!==null)if(pi($.value,W)){if($.children===E.children&&!Ns.current){c=ar(a,c,m);break e}}else for($=c.child,$!==null&&($.return=c);$!==null;){var ie=$.dependencies;if(ie!==null){W=$.child;for(var oe=ie.firstContext;oe!==null;){if(oe.context===y){if($.tag===1){oe=rr(-1,m&-m),oe.tag=2;var xe=$.updateQueue;if(xe!==null){xe=xe.shared;var Ae=xe.pending;Ae===null?oe.next=oe:(oe.next=Ae.next,Ae.next=oe),xe.pending=oe}}$.lanes|=m,oe=$.alternate,oe!==null&&(oe.lanes|=m),tm($.return,m,c),ie.lanes|=m;break}oe=oe.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|=m,ie=W.alternate,ie!==null&&(ie.lanes|=m),tm(W,m,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,E.children,m),c=c.child}return c;case 9:return E=c.type,y=c.pendingProps.children,po(c,m),E=ti(E),y=y(E),c.flags|=1,us(a,c,y,m),c.child;case 14:return y=c.type,E=xi(y,c.pendingProps),E=xi(y.type,E),p0(a,c,y,E,m);case 15:return g0(a,c,c.type,c.pendingProps,m);case 17:return y=c.type,E=c.pendingProps,E=c.elementType===y?E:xi(y,E),Su(a,c),c.tag=1,ws(y)?(a=!0,ou(c)):a=!1,po(c,m),o0(c,y,E),xm(c,y,E,m),km(null,c,y,!0,a,m);case 19:return w0(a,c,m);case 22:return x0(a,c,m)}throw Error(s(156,c.tag))};function G0(a,c){return Os(a,c)}function EC(a,c,m,y){this.tag=a,this.key=m,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=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ii(a,c,m,y){return new EC(a,c,m,y)}function Um(a){return a=a.prototype,!(!a||!a.isReactComponent)}function CC(a){if(typeof a=="function")return Um(a)?1:0;if(a!=null){if(a=a.$$typeof,a===U)return 11;if(a===R)return 14}return 2}function zr(a,c){var m=a.alternate;return m===null?(m=ii(a.tag,c,a.key,a.mode),m.elementType=a.elementType,m.type=a.type,m.stateNode=a.stateNode,m.alternate=a,a.alternate=m):(m.pendingProps=c,m.type=a.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=a.flags&14680064,m.childLanes=a.childLanes,m.lanes=a.lanes,m.child=a.child,m.memoizedProps=a.memoizedProps,m.memoizedState=a.memoizedState,m.updateQueue=a.updateQueue,c=a.dependencies,m.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},m.sibling=a.sibling,m.index=a.index,m.ref=a.ref,m}function Pu(a,c,m,y,E,$){var W=2;if(y=a,typeof a=="function")Um(a)&&(W=1);else if(typeof a=="string")W=5;else e:switch(a){case H:return ya(m.children,E,$,c);case B:W=8,E|=8;break;case O:return a=ii(12,m,c,E|2),a.elementType=O,a.lanes=$,a;case A:return a=ii(13,m,c,E),a.elementType=A,a.lanes=$,a;case I:return a=ii(19,m,c,E),a.elementType=I,a.lanes=$,a;case K:return Lu(m,E,$,c);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case T:W=10;break e;case D:W=9;break e;case U:W=11;break e;case R:W=14;break e;case L:W=16,y=null;break e}throw Error(s(130,a==null?a:typeof a,""))}return c=ii(W,m,c,E),c.elementType=a,c.type=y,c.lanes=$,c}function ya(a,c,m,y){return a=ii(7,a,y,c),a.lanes=m,a}function Lu(a,c,m,y){return a=ii(22,a,y,c),a.elementType=K,a.lanes=m,a.stateNode={isHidden:!1},a}function Bm(a,c,m){return a=ii(6,a,null,c),a.lanes=m,a}function Hm(a,c,m){return c=ii(4,a.children!==null?a.children:[],a.key,c),c.lanes=m,c.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},c}function AC(a,c,m,y,E){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=y,this.onRecoverableError=E,this.mutableSourceEagerHydrationData=null}function Zm(a,c,m,y,E,$,W,ie,oe){return a=new AC(a,c,m,ie,oe),c===1?(c=1,$===!0&&(c|=8)):c=0,$=ii(3,null,null,c),a.current=$,$.stateNode=a,$.memoizedState={element:y,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},sm($),a}function $C(a,c,m){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:P,key:y==null?null:""+y,children:a,containerInfo:c,implementation:m}}function K0(a){if(!a)return Ar;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 m=a.type;if(ws(m))return Nv(a,m,c)}return c}function Y0(a,c,m,y,E,$,W,ie,oe){return a=Zm(m,y,!0,a,E,$,W,ie,oe),a.context=K0(null),m=a.current,y=ds(),E=Pr(m),$=rr(y,E),$.callback=c??null,Tr(m,$,E),a.current.lanes=E,bs(a,E,y),Es(a,y),a}function zu(a,c,m,y){var E=c.current,$=ds(),W=Pr(E);return m=K0(m),c.context===null?c.context=m:c.pendingContext=m,c=rr($,W),c.payload={element:a},y=y===void 0?null:y,y!==null&&(c.callback=y),a=Tr(E,c,W),a!==null&&(bi(a,E,W,$),pu(a,E,W)),W}function Du(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 X0(a,c){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var m=a.retryLane;a.retryLane=m!==0&&m<c?m:c}}function Wm(a,c){X0(a,c),(a=a.alternate)&&X0(a,c)}function IC(){return null}var Q0=typeof reportError=="function"?reportError:function(a){console.error(a)};function Vm(a){this._internalRoot=a}Fu.prototype.render=Vm.prototype.render=function(a){var c=this._internalRoot;if(c===null)throw Error(s(409));zu(a,c,null,null)},Fu.prototype.unmount=Vm.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var c=a.containerInfo;ga(function(){zu(null,a,null,null)}),c[er]=null}};function Fu(a){this._internalRoot=a}Fu.prototype.unstable_scheduleHydration=function(a){if(a){var c=Yi();a={blockedOn:null,target:a,priority:c};for(var m=0;m<bn.length&&c!==0&&c<bn[m].priority;m++);bn.splice(m,0,a),m===0&&Qa(a)}};function qm(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Uu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function J0(){}function TC(a,c,m,y,E){if(E){if(typeof y=="function"){var $=y;y=function(){var xe=Du(W);$.call(xe)}}var W=Y0(c,y,a,0,null,!1,!1,"",J0);return a._reactRootContainer=W,a[er]=W.current,fl(a.nodeType===8?a.parentNode:a),ga(),W}for(;E=a.lastChild;)a.removeChild(E);if(typeof y=="function"){var ie=y;y=function(){var xe=Du(oe);ie.call(xe)}}var oe=Zm(a,0,!1,null,null,!1,!1,"",J0);return a._reactRootContainer=oe,a[er]=oe.current,fl(a.nodeType===8?a.parentNode:a),ga(function(){zu(c,oe,m,y)}),oe}function Bu(a,c,m,y,E){var $=m._reactRootContainer;if($){var W=$;if(typeof E=="function"){var ie=E;E=function(){var oe=Du(W);ie.call(oe)}}zu(c,W,a,E)}else W=TC(m,c,a,E,y);return Du(W)}ks=function(a){switch(a.tag){case 3:var c=a.stateNode;if(c.current.memoizedState.isDehydrated){var m=Xs(c.pendingLanes);m!==0&&(Qs(c,m|1),Es(c,Dt()),(Et&6)===0&&(bo=Dt()+500,$r()))}break;case 13:ga(function(){var y=ir(a,1);if(y!==null){var E=ds();bi(y,a,1,E)}}),Wm(a,1)}},Bt=function(a){if(a.tag===13){var c=ir(a,134217728);if(c!==null){var m=ds();bi(c,a,134217728,m)}Wm(a,134217728)}},ft=function(a){if(a.tag===13){var c=Pr(a),m=ir(a,c);if(m!==null){var y=ds();bi(m,a,c,y)}Wm(a,c)}},Yi=function(){return Nt},cs=function(a,c){var m=Nt;try{return Nt=a,c()}finally{Nt=m}},An=function(a,c,m){switch(c){case"input":if(Qe(a,m),c=m.name,m.type==="radio"&&c!=null){for(m=a;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<m.length;c++){var y=m[c];if(y!==a&&y.form===a.form){var E=ru(y);if(!E)throw Error(s(90));Te(y),Qe(y,E)}}}break;case"textarea":Pt(a,m);break;case"select":c=m.value,c!=null&&Mt(a,!!m.multiple,c,!1)}},we=zm,Ue=ga;var MC={usingClientEntryPoint:!1,Events:[xl,ao,ru,J,he,zm]},Il={findFiberByHostInstance:la,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},RC={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:_.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=jr(a),a===null?null:a.stateNode},findFiberByHostInstance:Il.findFiberByHostInstance||IC,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 Hu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hu.isDisabled&&Hu.supportsFiber)try{ut=Hu.inject(RC),mt=Hu}catch{}}return Cs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=MC,Cs.createPortal=function(a,c){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!qm(c))throw Error(s(200));return $C(a,c,null,m)},Cs.createRoot=function(a,c){if(!qm(a))throw Error(s(299));var m=!1,y="",E=Q0;return c!=null&&(c.unstable_strictMode===!0&&(m=!0),c.identifierPrefix!==void 0&&(y=c.identifierPrefix),c.onRecoverableError!==void 0&&(E=c.onRecoverableError)),c=Zm(a,1,!1,null,null,m,!1,y,E),a[er]=c.current,fl(a.nodeType===8?a.parentNode:a),new Vm(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=jr(c),a=a===null?null:a.stateNode,a},Cs.flushSync=function(a){return ga(a)},Cs.hydrate=function(a,c,m){if(!Uu(c))throw Error(s(200));return Bu(null,a,c,!0,m)},Cs.hydrateRoot=function(a,c,m){if(!qm(a))throw Error(s(405));var y=m!=null&&m.hydratedSources||null,E=!1,$="",W=Q0;if(m!=null&&(m.unstable_strictMode===!0&&(E=!0),m.identifierPrefix!==void 0&&($=m.identifierPrefix),m.onRecoverableError!==void 0&&(W=m.onRecoverableError)),c=Y0(c,null,a,1,m??null,E,!1,$,W),a[er]=c.current,fl(a),y)for(a=0;a<y.length;a++)m=y[a],E=m._getVersion,E=E(m._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[m,E]:c.mutableSourceEagerHydrationData.push(m,E);return new Fu(c)},Cs.render=function(a,c,m){if(!Uu(c))throw Error(s(200));return Bu(null,a,c,!1,m)},Cs.unmountComponentAtNode=function(a){if(!Uu(a))throw Error(s(40));return a._reactRootContainer?(ga(function(){Bu(null,null,a,!1,function(){a._reactRootContainer=null,a[er]=null})}),!0):!1},Cs.unstable_batchedUpdates=zm,Cs.unstable_renderSubtreeIntoContainer=function(a,c,m,y){if(!Uu(m))throw Error(s(200));if(a==null||a._reactInternals===void 0)throw Error(s(38));return Bu(a,c,m,!1,y)},Cs.version="18.3.1-next-f1338f8080-20240426",Cs}var cy;function Gj(){if(cy)return Xm.exports;cy=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(),Xm.exports=HC(),Xm.exports}var uy;function ZC(){if(uy)return Zu;uy=1;var e=Gj();return Zu.createRoot=e.createRoot,Zu.hydrateRoot=e.hydrateRoot,Zu}var WC=ZC(),qr,Do,Fo;class Ui{constructor(t){Ht(this,qr);Ht(this,Do,new Set);Ht(this,Fo,!1);dt(this,"get",()=>Le(this,qr));dt(this,"subscribe",t=>(Le(this,Do).add(t),()=>{Le(this,Do).delete(t)}));Kt(this,qr,t)}set(t){const s=typeof t=="function"?t(Le(this,qr)):t;Object.is(s,Le(this,qr))||(Kt(this,qr,s),!Le(this,Fo)&&(Kt(this,Fo,!0),queueMicrotask(()=>{Kt(this,Fo,!1);for(const i of[...Le(this,Do)])i()})))}}qr=new WeakMap,Do=new WeakMap,Fo=new WeakMap;var dy;function be(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,f=Object.keys(h);for(let p=0;p<f.length;p++){const g=f[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 f of h._zod.deferred)f();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 To extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Kj extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(dy=globalThis).__zod_globalConfig??(dy.__zod_globalConfig={});const Eg=globalThis.__zod_globalConfig;function xr(e){return Eg}function Yj(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 fp(e,t){return typeof t=="bigint"?t.toString():t}function Qd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Cg(e){return e==null}function Ag(e){const t=e.startsWith("^")?1:0,s=e.endsWith("$")?e.length-1:e.length;return e.slice(t,s)}function VC(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 hy=Symbol("evaluating");function Lt(e,t,s){let i;Object.defineProperty(e,t,{get(){if(i!==hy)return i===void 0&&(i=hy,i=s()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Wa(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 my(e){return JSON.stringify(e)}function qC(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Xj="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function xc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const GC=Qd(()=>{var e;if(Eg.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 Vo(e){if(xc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const s=t.prototype;return!(xc(s)===!1||Object.prototype.hasOwnProperty.call(s,"isPrototypeOf")===!1)}function Qj(e){return Vo(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const KC=new Set(["string","number","symbol"]);function qo(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 YC(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const XC={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 QC(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 Wa(this,"shape",l),l},checks:[]});return ia(e,o)}function JC(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 Wa(this,"shape",l),l},checks:[]});return ia(e,o)}function eA(e,t){if(!Vo(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 Wa(this,"shape",o),o}});return ia(e,r)}function tA(e,t){if(!Vo(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 Wa(this,"shape",i),i}});return ia(e,s)}function nA(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 Wa(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ia(e,s)}function sA(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 Wa(this,"shape",d),d},checks:[]});return ia(t,l)}function iA(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 Wa(this,"shape",o),o}});return ia(t,i)}function Ao(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 rA(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 $o(e,t){return t.map(s=>{var i;return(i=s).path??(i.path=[]),s.path.unshift(e),s})}function Wu(e){return typeof e=="string"?e:e==null?void 0:e.message}function vr(e,t,s){var d,h,f,p,g,x;const i=e.message?e.message:Wu((f=(h=(d=e.inst)==null?void 0:d._zod.def)==null?void 0:h.error)==null?void 0:f.call(h,e))??Wu((p=t==null?void 0:t.error)==null?void 0:p.call(t,e))??Wu((g=s.customError)==null?void 0:g.call(s,e))??Wu((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 $g(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function vc(...e){const[t,s,i]=e;return typeof t=="string"?{message:t,code:"custom",input:s,inst:i}:{...t}}const Jj=(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,fp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},eN=be("$ZodError",Jj),tN=be("$ZodError",Jj,{Parent:Error});function aA(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 oA(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 f=u[h];h===u.length-1?(d[f]=d[f]||{_errors:[]},d[f]._errors.push(t(l))):d[f]=d[f]||{_errors:[]},d=d[f],h++}}}};return i(e),s}const Ig=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 To;if(l.issues.length){const u=new((r==null?void 0:r.Err)??e)(l.issues.map(d=>vr(d,o,xr())));throw Xj(u,r==null?void 0:r.callee),u}return l.value},Tg=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=>vr(d,o,xr())));throw Xj(u,r==null?void 0:r.callee),u}return l.value},Jd=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 To;return o.issues.length?{success:!1,error:new(e??eN)(o.issues.map(l=>vr(l,r,xr())))}:{success:!0,data:o.value}},lA=Jd(tN),eh=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=>vr(l,r,xr())))}:{success:!0,data:o.value}},cA=eh(tN),uA=e=>(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Ig(e)(t,s,r)},dA=e=>(t,s,i)=>Ig(e)(t,s,i),hA=e=>async(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Tg(e)(t,s,r)},mA=e=>async(t,s,i)=>Tg(e)(t,s,i),fA=e=>(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Jd(e)(t,s,r)},pA=e=>(t,s,i)=>Jd(e)(t,s,i),gA=e=>async(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return eh(e)(t,s,r)},xA=e=>async(t,s,i)=>eh(e)(t,s,i),vA=/^[cC][0-9a-z]{6,}$/,yA=/^[0-9a-z]+$/,bA=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,kA=/^[0-9a-vA-V]{20}$/,jA=/^[A-Za-z0-9]{27}$/,NA=/^[a-zA-Z0-9_-]{21}$/,wA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,SA=/^([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})$/,fy=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)$/,_A=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,EA="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function CA(){return new RegExp(EA,"u")}const AA=/^(?:(?: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])$/,$A=/^(([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}|:))$/,IA=/^((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])$/,TA=/^(([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])$/,MA=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,nN=/^[A-Za-z0-9_-]*$/,RA=/^https?$/,OA=/^\+[1-9]\d{6,14}$/,sN="(?:(?:\\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])))",PA=new RegExp(`^${sN}$`);function iN(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 LA(e){return new RegExp(`^${iN(e)}$`)}function zA(e){const t=iN({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(`^${sN}T(?:${i})$`)}const DA=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}$`)},FA=/^-?\d+$/,rN=/^-?\d+(?:\.\d+)?$/,UA=/^(?:true|false)$/i,BA=/^null$/i,HA=/^[^A-Z]*$/,ZA=/^[^a-z]*$/,Rs=be("$ZodCheck",(e,t)=>{var s;e._zod??(e._zod={}),e._zod.def=t,(s=e._zod).onattach??(s.onattach=[])}),aN={number:"number",bigint:"bigint",object:"date"},oN=be("$ZodCheckLessThan",(e,t)=>{Rs.init(e,t);const s=aN[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})}}),lN=be("$ZodCheckGreaterThan",(e,t)=>{Rs.init(e,t);const s=aN[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})}}),WA=be("$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):VC(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})}}),VA=be("$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]=XC[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=FA)}),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})}}),qA=be("$ZodCheckMaxLength",(e,t)=>{var s;Rs.init(e,t),(s=e._zod.def).when??(s.when=i=>{const r=i.value;return!Cg(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=$g(r);i.issues.push({origin:l,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),GA=be("$ZodCheckMinLength",(e,t)=>{var s;Rs.init(e,t),(s=e._zod.def).when??(s.when=i=>{const r=i.value;return!Cg(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=$g(r);i.issues.push({origin:l,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),KA=be("$ZodCheckLengthEquals",(e,t)=>{var s;Rs.init(e,t),(s=e._zod.def).when??(s.when=i=>{const r=i.value;return!Cg(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=$g(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})}}),th=be("$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=()=>{})}),YA=be("$ZodCheckRegex",(e,t)=>{th.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})}}),XA=be("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=HA),th.init(e,t)}),QA=be("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ZA),th.init(e,t)}),JA=be("$ZodCheckIncludes",(e,t)=>{Rs.init(e,t);const s=qo(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})}}),e$=be("$ZodCheckStartsWith",(e,t)=>{Rs.init(e,t);const s=new RegExp(`^${qo(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})}}),t$=be("$ZodCheckEndsWith",(e,t)=>{Rs.init(e,t);const s=new RegExp(`.*${qo(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})}}),n$=be("$ZodCheckOverwrite",(e,t)=>{Rs.init(e,t),e._zod.check=s=>{s.value=t.tx(s.value)}});class s${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 i$={major:4,minor:4,patch:3},tn=be("$ZodType",(e,t)=>{var r;var s;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=i$;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 f=Ao(u),p;for(const g of d){if(g._zod.def.when){if(rA(u)||!g._zod.def.when(u))continue}else if(f)continue;const x=u.issues.length,b=g._zod.check(u);if(b instanceof Promise&&(h==null?void 0:h.async)===!1)throw new To;if(p||b instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await b,u.issues.length!==x&&(f||(f=Ao(u,x)))});else{if(u.issues.length===x)continue;f||(f=Ao(u,x))}}return p?p.then(()=>u):u},l=(u,d,h)=>{if(Ao(u))return u.aborted=!0,u;const f=o(d,i,h);if(f instanceof Promise){if(h.async===!1)throw new To;return f.then(p=>e._zod.parse(p,h))}return e._zod.parse(f,h)};e._zod.run=(u,d)=>{if(d.skipChecks)return e._zod.parse(u,d);if(d.direction==="backward"){const f=e._zod.parse({value:u.value,issues:[]},{...d,skipChecks:!0});return f instanceof Promise?f.then(p=>l(p,u,d)):l(f,u,d)}const h=e._zod.parse(u,d);if(h instanceof Promise){if(d.async===!1)throw new To;return h.then(f=>o(f,i,d))}return o(h,i,d)}}Lt(e,"~standard",()=>({validate:o=>{var l;try{const u=lA(e,o);return u.success?{value:u.data}:{issues:(l=u.error)==null?void 0:l.issues}}catch{return cA(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}))}),Mg=be("$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()??DA(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=be("$ZodStringFormat",(e,t)=>{th.init(e,t),Mg.init(e,t)}),r$=be("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=SA),nn.init(e,t)}),a$=be("$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=fy(i))}else t.pattern??(t.pattern=fy());nn.init(e,t)}),o$=be("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=_A),nn.init(e,t)}),l$=be("$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)===RA.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})}}}),c$=be("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=CA()),nn.init(e,t)}),u$=be("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=NA),nn.init(e,t)}),d$=be("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=vA),nn.init(e,t)}),h$=be("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=yA),nn.init(e,t)}),m$=be("$ZodULID",(e,t)=>{t.pattern??(t.pattern=bA),nn.init(e,t)}),f$=be("$ZodXID",(e,t)=>{t.pattern??(t.pattern=kA),nn.init(e,t)}),p$=be("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=jA),nn.init(e,t)}),g$=be("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=zA(t)),nn.init(e,t)}),x$=be("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=PA),nn.init(e,t)}),v$=be("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=LA(t)),nn.init(e,t)}),y$=be("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=wA),nn.init(e,t)}),b$=be("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=AA),nn.init(e,t),e._zod.bag.format="ipv4"}),k$=be("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=$A),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})}}}),j$=be("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=IA),nn.init(e,t)}),N$=be("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=TA),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 cN(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const w$=be("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=MA),nn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=s=>{cN(s.value)||s.issues.push({code:"invalid_format",format:"base64",input:s.value,inst:e,continue:!t.abort})}});function S$(e){if(!nN.test(e))return!1;const t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),s=t.padEnd(Math.ceil(t.length/4)*4,"=");return cN(s)}const _$=be("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=nN),nn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=s=>{S$(s.value)||s.issues.push({code:"invalid_format",format:"base64url",input:s.value,inst:e,continue:!t.abort})}}),E$=be("$ZodE164",(e,t)=>{t.pattern??(t.pattern=OA),nn.init(e,t)});function C$(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 A$=be("$ZodJWT",(e,t)=>{nn.init(e,t),e._zod.check=s=>{C$(s.value,t.alg)||s.issues.push({code:"invalid_format",format:"jwt",input:s.value,inst:e,continue:!t.abort})}}),uN=be("$ZodNumber",(e,t)=>{tn.init(e,t),e._zod.pattern=e._zod.bag.pattern??rN,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}}),$$=be("$ZodNumberFormat",(e,t)=>{VA.init(e,t),uN.init(e,t)}),I$=be("$ZodBoolean",(e,t)=>{tn.init(e,t),e._zod.pattern=UA,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}}),T$=be("$ZodNull",(e,t)=>{tn.init(e,t),e._zod.pattern=BA,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}}),M$=be("$ZodUnknown",(e,t)=>{tn.init(e,t),e._zod.parse=s=>s}),R$=be("$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 py(e,t,s){e.issues.length&&t.issues.push(...$o(s,e.issues)),t.value[s]=e.value}const O$=be("$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=>py(h,s,l))):py(d,s,l)}return o.length?Promise.all(o).then(()=>s):s}});function _d(e,t,s,i,r,o){const l=s in i;if(e.issues.length){if(r&&o&&!l)return;t.issues.push(...$o(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 dN(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=YC(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function hN(e,t,s,i,r,o){const l=[],u=r.keySet,d=r.catchall._zod,h=d.def.type,f=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(b=>_d(b,s,g,t,f,p))):_d(x,s,g,t,f,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 P$=be("$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=Qd(()=>dN(t));Lt(e._zod,"propValues",()=>{const u=t.shape,d={};for(const h in u){const f=u[h]._zod;if(f.values){d[h]??(d[h]=new Set);for(const p of f.values)d[h].add(p)}}return d});const r=xc,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 f=[],p=l.shape;for(const g of l.keys){const x=p[g],b=x._zod.optin==="optional",k=x._zod.optout==="optional",j=x._zod.run({value:h[g],issues:[]},d);j instanceof Promise?f.push(j.then(N=>_d(N,u,g,h,b,k))):_d(j,u,g,h,b,k)}return o?hN(f,h,u,d,i.value,e):f.length?Promise.all(f).then(()=>u):u}}),L$=be("$ZodObjectJIT",(e,t)=>{P$.init(e,t);const s=e._zod.parse,i=Qd(()=>dN(t)),r=g=>{var S,_;const x=new s$(["shape","payload","ctx"]),b=i.value,k=z=>{const P=my(z);return`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`};x.write("const input = payload.value;");const j=Object.create(null);let N=0;for(const z of b.keys)j[z]=`key_${N++}`;x.write("const newResult = {};");for(const z of b.keys){const P=j[z],H=my(z),B=g[z],O=((S=B==null?void 0:B._zod)==null?void 0:S.optin)==="optional",T=((_=B==null?void 0:B._zod)==null?void 0:_.optout)==="optional";x.write(`const ${P} = ${k(z)};`),O&&T?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
+ `):O?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 C=x.compile();return(z,P)=>C(g,z,P)};let o;const l=xc,u=!Eg.jitless,h=u&&GC.value,f=t.catchall;let p;e._zod.parse=(g,x)=>{p??(p=i.value);const b=g.value;return l(b)?u&&h&&(x==null?void 0:x.async)===!1&&x.jitless!==!0?(o||(o=r(t.shape)),g=o(g,x),f?hN([],b,g,x,p,e):g):s(g,x):(g.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),g)}});function gy(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=>!Ao(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=>vr(l,i,xr())))}),t)}const mN=be("$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=>Ag(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=>gy(u,i,e,r)):gy(l,i,e,r)}}),z$=be("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,mN.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=Qd(()=>{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(!xc(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)}}),D$=be("$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])=>xy(s,d,h)):xy(s,o,l)}});function pp(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(Vo(e)&&Vo(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=pp(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=pp(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 xy(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}),Ao(e))return e;const l=pp(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 F$=be("$ZodRecord",(e,t)=>{tn.init(e,t),e._zod.parse=(s,i)=>{const r=s.value;if(!Vo(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 f=t.keyType._zod.run({value:h,issues:[]},i);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){s.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(x=>vr(x,i,xr())),input:h,path:[h],inst:e});continue}const p=f.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(...$o(h,x.issues)),s.value[p]=x.value})):(g.issues.length&&s.issues.push(...$o(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"&&rN.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=>vr(p,i,xr())),input:u,path:[u],inst:e});continue}const f=t.valueType._zod.run({value:r[u],issues:[]},i);f instanceof Promise?o.push(f.then(p=>{p.issues.length&&s.issues.push(...$o(u,p.issues)),s.value[d.value]=p.value})):(f.issues.length&&s.issues.push(...$o(u,f.issues)),s.value[d.value]=f.value)}}return o.length?Promise.all(o).then(()=>s):s}}),U$=be("$ZodEnum",(e,t)=>{tn.init(e,t);const s=Yj(t.entries),i=new Set(s);e._zod.values=i,e._zod.pattern=new RegExp(`^(${s.filter(r=>KC.has(typeof r)).map(r=>typeof r=="string"?qo(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}}),B$=be("$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"?qo(i):i?qo(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}}),H$=be("$ZodTransform",(e,t)=>{tn.init(e,t),e._zod.optin="optional",e._zod.parse=(s,i)=>{if(i.direction==="backward")throw new Kj(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 To;return s.value=r,s.fallback=!0,s}});function vy(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const fN=be("$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(`^(${Ag(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=>vy(l,r)):vy(o,r)}return s.value===void 0?s:t.innerType._zod.run(s,i)}}),Z$=be("$ZodExactOptional",(e,t)=>{fN.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)}),W$=be("$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(`^(${Ag(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)}),V$=be("$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=>yy(o,t)):yy(r,t)}});function yy(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const q$=be("$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))}),G$=be("$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=>by(o,e)):by(r,e)}});function by(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 K$=be("$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=>vr(l,i,xr()))},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=>vr(o,i,xr()))},input:s.value}),s.issues=[],s.fallback=!0),s)}}),Y$=be("$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=>Vu(l,t.in,i)):Vu(o,t.in,i)}const r=t.in._zod.run(s,i);return r instanceof Promise?r.then(o=>Vu(o,t.out,i)):Vu(r,t.out,i)}});function Vu(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 X$=be("$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(ky):ky(r)}});function ky(e){return e.value=Object.freeze(e.value),e}const Q$=be("$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=>jy(o,s,i,e));jy(r,s,i,e)}});function jy(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(vc(r))}}var Ny;class J${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 eI(){return new J$}(Ny=globalThis).__zod_globalRegistry??(Ny.__zod_globalRegistry=eI());const Kl=globalThis.__zod_globalRegistry;function tI(e,t){return new e({type:"string",...et(t)})}function nI(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...et(t)})}function wy(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...et(t)})}function sI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...et(t)})}function iI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...et(t)})}function rI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...et(t)})}function aI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...et(t)})}function pN(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...et(t)})}function oI(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...et(t)})}function lI(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...et(t)})}function cI(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...et(t)})}function uI(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...et(t)})}function dI(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...et(t)})}function hI(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...et(t)})}function mI(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...et(t)})}function fI(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...et(t)})}function pI(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...et(t)})}function gI(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...et(t)})}function xI(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...et(t)})}function vI(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...et(t)})}function yI(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...et(t)})}function bI(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...et(t)})}function kI(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...et(t)})}function jI(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...et(t)})}function NI(e,t){return new e({type:"string",format:"date",check:"string_format",...et(t)})}function wI(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...et(t)})}function SI(e,t){return new e({type:"string",format:"duration",check:"string_format",...et(t)})}function _I(e,t){return new e({type:"number",checks:[],...et(t)})}function EI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...et(t)})}function CI(e,t){return new e({type:"boolean",...et(t)})}function AI(e,t){return new e({type:"null",...et(t)})}function $I(e){return new e({type:"unknown"})}function II(e,t){return new e({type:"never",...et(t)})}function Sy(e,t){return new oN({check:"less_than",...et(t),value:e,inclusive:!1})}function ef(e,t){return new oN({check:"less_than",...et(t),value:e,inclusive:!0})}function _y(e,t){return new lN({check:"greater_than",...et(t),value:e,inclusive:!1})}function tf(e,t){return new lN({check:"greater_than",...et(t),value:e,inclusive:!0})}function Ey(e,t){return new WA({check:"multiple_of",...et(t),value:e})}function gN(e,t){return new qA({check:"max_length",...et(t),maximum:e})}function Ed(e,t){return new GA({check:"min_length",...et(t),minimum:e})}function xN(e,t){return new KA({check:"length_equals",...et(t),length:e})}function TI(e,t){return new YA({check:"string_format",format:"regex",...et(t),pattern:e})}function MI(e){return new XA({check:"string_format",format:"lowercase",...et(e)})}function RI(e){return new QA({check:"string_format",format:"uppercase",...et(e)})}function OI(e,t){return new JA({check:"string_format",format:"includes",...et(t),includes:e})}function PI(e,t){return new e$({check:"string_format",format:"starts_with",...et(t),prefix:e})}function LI(e,t){return new t$({check:"string_format",format:"ends_with",...et(t),suffix:e})}function il(e){return new n$({check:"overwrite",tx:e})}function zI(e){return il(t=>t.normalize(e))}function DI(){return il(e=>e.trim())}function FI(){return il(e=>e.toLowerCase())}function UI(){return il(e=>e.toUpperCase())}function BI(){return il(e=>qC(e))}function HI(e,t,s){return new e({type:"array",element:t,...et(s)})}function ZI(e,t,s){return new e({type:"custom",check:"custom",fn:t,...et(s)})}function WI(e,t){const s=VI(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(vc(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(vc(o))}},e(i.value,i)),t);return s}function VI(e,t){const s=new Rs({check:"custom",...et(t)});return s._zod.check=e,s}function vN(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 f,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=(f=e._zod).toJSONSchema)==null?void 0:p.call(f);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 b=l.schema,k=t.processors[r.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);k(e,t,b,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 yN(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 f of e.seen.entries()){const p=(l=e.metadataRegistry.get(f[0]))==null?void 0:l.id;if(p){const g=i.get(p);if(g&&g!==f[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,f[0])}}const r=f=>{var k;const p=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const j=(k=e.external.registry.get(f[0]))==null?void 0:k.id,N=e.external.uri??(S=>S);if(j)return{ref:N(j)};const C=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=C,{defId:C,ref:`${N("__shared")}#/${p}/${C}`}}if(f[1]===s)return{ref:"#"};const x=`#/${p}/`,b=f[1].schema.id??`__schema${e.counter++}`;return{defId:b,ref:x+b}},o=f=>{if(f[1].schema.$ref)return;const p=f[1],{ref:g,defId:x}=r(f);p.def={...p.schema},x&&(p.defId=x);const b=p.schema;for(const k in b)delete b[k];b.$ref=g};if(e.cycles==="throw")for(const f of e.seen.entries()){const p=f[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 f of e.seen.entries()){const p=f[1];if(t===f[0]){o(f);continue}if(e.external){const x=(d=e.external.registry.get(f[0]))==null?void 0:d.id;if(t!==f[0]&&x){o(f);continue}}if((h=e.metadataRegistry.get(f[0]))==null?void 0:h.id){o(f);continue}if(p.cycle){o(f);continue}if(p.count>1&&e.reused==="ref"){o(f);continue}}}function bN(e,t){var u,d,h,f;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,b={...x},k=g.ref;if(g.ref=null,k){i(k);const N=e.seen.get(k),C=N.schema;if(C.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(x.allOf=x.allOf??[],x.allOf.push(C)):Object.assign(x,C),Object.assign(x,b),p._zod.parent===k)for(const _ in x)_==="$ref"||_==="allOf"||_ in b||delete x[_];if(C.$ref&&N.def)for(const _ in x)_==="$ref"||_==="allOf"||_ in N.def&&JSON.stringify(x[_])===JSON.stringify(N.def[_])&&delete x[_]}const j=p._zod.parent;if(j&&j!==k){i(j);const N=e.seen.get(j);if(N!=null&&N.schema.$ref&&(x.$ref=N.schema.$ref,N.def))for(const C in x)C==="$ref"||C==="allOf"||C in N.def&&JSON.stringify(x[C])===JSON.stringify(N.def[C])&&delete x[C]}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=((f=e.external)==null?void 0:f.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:Cd(t,"input",e.processors),output:Cd(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 qI=(e,t={})=>s=>{const i=vN({...s,processors:t});return Sn(e,i),yN(i,e),bN(i,e)},Cd=(e,t,s={})=>i=>{const{libraryOptions:r,target:o}=i??{},l=vN({...r??{},target:o,io:t,processors:s});return Sn(e,l),yN(l,e),bN(l,e)},GI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},KI=(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=GI[u]??u,r.format===""&&delete r.format,u==="time"&&delete r.format),h&&(r.contentEncoding=h),d&&d.size>0){const f=[...d];f.length===1?r.pattern=f[0].source:f.length>1&&(r.allOf=[...f.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},YI=(e,t,s,i)=>{const r=s,{minimum:o,maximum:l,format:u,multipleOf:d,exclusiveMaximum:h,exclusiveMinimum:f}=e._zod.bag;typeof u=="string"&&u.includes("int")?r.type="integer":r.type="number";const p=typeof f=="number"&&f>=(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=f,r.exclusiveMinimum=!0):r.exclusiveMinimum=f: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)},XI=(e,t,s,i)=>{s.type="boolean"},QI=(e,t,s,i)=>{t.target==="openapi-3.0"?(s.type="string",s.nullable=!0,s.enum=[null]):s.type="null"},JI=(e,t,s,i)=>{s.not={}},eT=(e,t,s,i)=>{},tT=(e,t,s,i)=>{const r=e._zod.def,o=Yj(r.entries);o.every(l=>typeof l=="number")&&(s.type="number"),o.every(l=>typeof l=="string")&&(s.type="string"),s.enum=o},nT=(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},sT=(e,t,s,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},iT=(e,t,s,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},rT=(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"]})},aT=(e,t,s,i)=>{var h;const r=s,o=e._zod.def;r.type="object",r.properties={};const l=o.shape;for(const f in l)r.properties[f]=Sn(l[f],t,{...i,path:[...i.path,"properties",f]});const u=new Set(Object.keys(l)),d=new Set([...u].filter(f=>{const p=o.shape[f]._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)},oT=(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},lT=(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},cT=(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 f=Sn(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(const p of d)r.patternProperties[p.source]=f}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 f=[...h].filter(p=>typeof p=="string"||typeof p=="number");f.length>0&&(r.required=f)}},uT=(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"}]},dT=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType},hT=(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))},mT=(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)))},fT=(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},pT=(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},gT=(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},kN=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType},xT=be("ZodISODateTime",(e,t)=>{g$.init(e,t),dn.init(e,t)});function vT(e){return jI(xT,e)}const yT=be("ZodISODate",(e,t)=>{x$.init(e,t),dn.init(e,t)});function bT(e){return NI(yT,e)}const kT=be("ZodISOTime",(e,t)=>{v$.init(e,t),dn.init(e,t)});function jT(e){return wI(kT,e)}const NT=be("ZodISODuration",(e,t)=>{y$.init(e,t),dn.init(e,t)});function wT(e){return SI(NT,e)}const ST=(e,t)=>{eN.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:s=>oA(e,s)},flatten:{value:s=>aA(e,s)},addIssue:{value:s=>{e.issues.push(s),e.message=JSON.stringify(e.issues,fp,2)}},addIssues:{value:s=>{e.issues.push(...s),e.message=JSON.stringify(e.issues,fp,2)}},isEmpty:{get(){return e.issues.length===0}}})},ci=be("ZodError",ST,{Parent:Error}),_T=Ig(ci),ET=Tg(ci),CT=Jd(ci),AT=eh(ci),$T=uA(ci),IT=dA(ci),TT=hA(ci),MT=mA(ci),RT=fA(ci),OT=pA(ci),PT=gA(ci),LT=xA(ci),Cy=new WeakMap;function Lc(e,t,s){const i=Object.getPrototypeOf(e);let r=Cy.get(i);if(r||(r=new Set,Cy.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=be("ZodType",(e,t)=>(tn.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Cd(e,"input"),output:Cd(e,"output")}}),e.toJSONSchema=qI(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(s,i)=>_T(e,s,i,{callee:e.parse}),e.safeParse=(s,i)=>CT(e,s,i),e.parseAsync=async(s,i)=>ET(e,s,i,{callee:e.parseAsync}),e.safeParseAsync=async(s,i)=>AT(e,s,i),e.spa=e.safeParseAsync,e.encode=(s,i)=>$T(e,s,i),e.decode=(s,i)=>IT(e,s,i),e.encodeAsync=async(s,i)=>TT(e,s,i),e.decodeAsync=async(s,i)=>MT(e,s,i),e.safeEncode=(s,i)=>RT(e,s,i),e.safeDecode=(s,i)=>OT(e,s,i),e.safeEncodeAsync=async(s,i)=>PT(e,s,i),e.safeDecodeAsync=async(s,i)=>LT(e,s,i),Lc(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($M(s,i))},superRefine(s,i){return this.check(IM(s,i))},overwrite(s){return this.check(il(s))},optional(){return Ty(this)},exactOptional(){return xM(this)},nullable(){return My(this)},nullish(){return Ty(My(this))},nonoptional(s){return NM(this,s)},array(){return me(this)},or(s){return Go([this,s])},and(s){return hM(this,s)},transform(s){return Ry(this,pM(s))},default(s){return bM(this,s)},prefault(s){return jM(this,s)},catch(s){return SM(this,s)},pipe(s){return Ry(this,s)},readonly(){return CM(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)),jN=be("_ZodString",(e,t)=>{Mg.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(i,r,o)=>KI(e,i,r);const s=e._zod.bag;e.format=s.format??null,e.minLength=s.minimum??null,e.maxLength=s.maximum??null,Lc(e,"_ZodString",{regex(...i){return this.check(TI(...i))},includes(...i){return this.check(OI(...i))},startsWith(...i){return this.check(PI(...i))},endsWith(...i){return this.check(LI(...i))},min(...i){return this.check(Ed(...i))},max(...i){return this.check(gN(...i))},length(...i){return this.check(xN(...i))},nonempty(...i){return this.check(Ed(1,...i))},lowercase(i){return this.check(MI(i))},uppercase(i){return this.check(RI(i))},trim(){return this.check(DI())},normalize(...i){return this.check(zI(...i))},toLowerCase(){return this.check(FI())},toUpperCase(){return this.check(UI())},slugify(){return this.check(BI())}})}),zT=be("ZodString",(e,t)=>{Mg.init(e,t),jN.init(e,t),e.email=s=>e.check(nI(DT,s)),e.url=s=>e.check(pN(NN,s)),e.jwt=s=>e.check(kI(eM,s)),e.emoji=s=>e.check(oI(FT,s)),e.guid=s=>e.check(wy(Ay,s)),e.uuid=s=>e.check(sI(qu,s)),e.uuidv4=s=>e.check(iI(qu,s)),e.uuidv6=s=>e.check(rI(qu,s)),e.uuidv7=s=>e.check(aI(qu,s)),e.nanoid=s=>e.check(lI(UT,s)),e.guid=s=>e.check(wy(Ay,s)),e.cuid=s=>e.check(cI(BT,s)),e.cuid2=s=>e.check(uI(HT,s)),e.ulid=s=>e.check(dI(ZT,s)),e.base64=s=>e.check(vI(XT,s)),e.base64url=s=>e.check(yI(QT,s)),e.xid=s=>e.check(hI(WT,s)),e.ksuid=s=>e.check(mI(VT,s)),e.ipv4=s=>e.check(fI(qT,s)),e.ipv6=s=>e.check(pI(GT,s)),e.cidrv4=s=>e.check(gI(KT,s)),e.cidrv6=s=>e.check(xI(YT,s)),e.e164=s=>e.check(bI(JT,s)),e.datetime=s=>e.check(vT(s)),e.date=s=>e.check(bT(s)),e.time=s=>e.check(jT(s)),e.duration=s=>e.check(wT(s))});function w(e){return tI(zT,e)}const dn=be("ZodStringFormat",(e,t)=>{nn.init(e,t),jN.init(e,t)}),DT=be("ZodEmail",(e,t)=>{o$.init(e,t),dn.init(e,t)}),Ay=be("ZodGUID",(e,t)=>{r$.init(e,t),dn.init(e,t)}),qu=be("ZodUUID",(e,t)=>{a$.init(e,t),dn.init(e,t)}),NN=be("ZodURL",(e,t)=>{l$.init(e,t),dn.init(e,t)});function gp(e){return pN(NN,e)}const FT=be("ZodEmoji",(e,t)=>{c$.init(e,t),dn.init(e,t)}),UT=be("ZodNanoID",(e,t)=>{u$.init(e,t),dn.init(e,t)}),BT=be("ZodCUID",(e,t)=>{d$.init(e,t),dn.init(e,t)}),HT=be("ZodCUID2",(e,t)=>{h$.init(e,t),dn.init(e,t)}),ZT=be("ZodULID",(e,t)=>{m$.init(e,t),dn.init(e,t)}),WT=be("ZodXID",(e,t)=>{f$.init(e,t),dn.init(e,t)}),VT=be("ZodKSUID",(e,t)=>{p$.init(e,t),dn.init(e,t)}),qT=be("ZodIPv4",(e,t)=>{b$.init(e,t),dn.init(e,t)}),GT=be("ZodIPv6",(e,t)=>{k$.init(e,t),dn.init(e,t)}),KT=be("ZodCIDRv4",(e,t)=>{j$.init(e,t),dn.init(e,t)}),YT=be("ZodCIDRv6",(e,t)=>{N$.init(e,t),dn.init(e,t)}),XT=be("ZodBase64",(e,t)=>{w$.init(e,t),dn.init(e,t)}),QT=be("ZodBase64URL",(e,t)=>{_$.init(e,t),dn.init(e,t)}),JT=be("ZodE164",(e,t)=>{E$.init(e,t),dn.init(e,t)}),eM=be("ZodJWT",(e,t)=>{A$.init(e,t),dn.init(e,t)}),wN=be("ZodNumber",(e,t)=>{uN.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(i,r,o)=>YI(e,i,r),Lc(e,"ZodNumber",{gt(i,r){return this.check(_y(i,r))},gte(i,r){return this.check(tf(i,r))},min(i,r){return this.check(tf(i,r))},lt(i,r){return this.check(Sy(i,r))},lte(i,r){return this.check(ef(i,r))},max(i,r){return this.check(ef(i,r))},int(i){return this.check($y(i))},safe(i){return this.check($y(i))},positive(i){return this.check(_y(0,i))},nonnegative(i){return this.check(tf(0,i))},negative(i){return this.check(Sy(0,i))},nonpositive(i){return this.check(ef(0,i))},multipleOf(i,r){return this.check(Ey(i,r))},step(i,r){return this.check(Ey(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 le(e){return _I(wN,e)}const tM=be("ZodNumberFormat",(e,t)=>{$$.init(e,t),wN.init(e,t)});function $y(e){return EI(tM,e)}const nM=be("ZodBoolean",(e,t)=>{I$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>XI(e,s,i)});function ve(e){return CI(nM,e)}const sM=be("ZodNull",(e,t)=>{T$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>QI(e,s,i)});function iM(e){return AI(sM,e)}const rM=be("ZodUnknown",(e,t)=>{M$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>eT()});function xp(){return $I(rM)}const aM=be("ZodNever",(e,t)=>{R$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>JI(e,s,i)});function oM(e){return II(aM,e)}const lM=be("ZodArray",(e,t)=>{O$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>rT(e,s,i,r),e.element=t.element,Lc(e,"ZodArray",{min(s,i){return this.check(Ed(s,i))},nonempty(s){return this.check(Ed(1,s))},max(s,i){return this.check(gN(s,i))},length(s,i){return this.check(xN(s,i))},unwrap(){return this.element}})});function me(e,t){return HI(lM,e,t)}const cM=be("ZodObject",(e,t)=>{L$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>aT(e,s,i,r),Lt(e,"shape",()=>t.shape),Lc(e,"ZodObject",{keyof(){return Ie(Object.keys(this._zod.def.shape))},catchall(s){return this.clone({...this._zod.def,catchall:s})},passthrough(){return this.clone({...this._zod.def,catchall:xp()})},loose(){return this.clone({...this._zod.def,catchall:xp()})},strict(){return this.clone({...this._zod.def,catchall:oM()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(s){return eA(this,s)},safeExtend(s){return tA(this,s)},merge(s){return nA(this,s)},pick(s){return QC(this,s)},omit(s){return JC(this,s)},partial(...s){return sA(_N,this,s[0])},required(...s){return iA(EN,this,s[0])}})});function M(e,t){const s={type:"object",shape:e??{},...et(t)};return new cM(s)}const SN=be("ZodUnion",(e,t)=>{mN.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>oT(e,s,i,r),e.options=t.options});function Go(e,t){return new SN({type:"union",options:e,...et(t)})}const uM=be("ZodDiscriminatedUnion",(e,t)=>{SN.init(e,t),z$.init(e,t)});function Va(e,t,s){return new uM({type:"union",options:t,discriminator:e,...et(s)})}const dM=be("ZodIntersection",(e,t)=>{D$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>lT(e,s,i,r)});function hM(e,t){return new dM({type:"intersection",left:e,right:t})}const Iy=be("ZodRecord",(e,t)=>{F$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>cT(e,s,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ws(e,t,s){return!t||!t._zod?new Iy({type:"record",keyType:w(),valueType:e,...et(t)}):new Iy({type:"record",keyType:e,valueType:t,...et(s)})}const vp=be("ZodEnum",(e,t)=>{U$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(i,r,o)=>tT(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 vp({...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 vp({...t,checks:[],...et(r),entries:o})}});function Ie(e,t){const s=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new vp({type:"enum",entries:s,...et(t)})}const mM=be("ZodLiteral",(e,t)=>{B$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>nT(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 ht(e,t){return new mM({type:"literal",values:Array.isArray(e)?e:[e],...et(t)})}const fM=be("ZodTransform",(e,t)=>{H$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>iT(e,s),e._zod.parse=(s,i)=>{if(i.direction==="backward")throw new Kj(e.constructor.name);s.addIssue=o=>{if(typeof o=="string")s.issues.push(vc(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(vc(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 pM(e){return new fM({type:"transform",transform:e})}const _N=be("ZodOptional",(e,t)=>{fN.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>kN(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function Ty(e){return new _N({type:"optional",innerType:e})}const gM=be("ZodExactOptional",(e,t)=>{Z$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>kN(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function xM(e){return new gM({type:"optional",innerType:e})}const vM=be("ZodNullable",(e,t)=>{W$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>uT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function My(e){return new vM({type:"nullable",innerType:e})}const yM=be("ZodDefault",(e,t)=>{V$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>hT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function bM(e,t){return new yM({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Qj(t)}})}const kM=be("ZodPrefault",(e,t)=>{q$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>mT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function jM(e,t){return new kM({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Qj(t)}})}const EN=be("ZodNonOptional",(e,t)=>{G$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>dT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function NM(e,t){return new EN({type:"nonoptional",innerType:e,...et(t)})}const wM=be("ZodCatch",(e,t)=>{K$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>fT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function SM(e,t){return new wM({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const _M=be("ZodPipe",(e,t)=>{Y$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>pT(e,s,i,r),e.in=t.in,e.out=t.out});function Ry(e,t){return new _M({type:"pipe",in:e,out:t})}const EM=be("ZodReadonly",(e,t)=>{X$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>gT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function CM(e){return new EM({type:"readonly",innerType:e})}const AM=be("ZodCustom",(e,t)=>{Q$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>sT(e,s)});function $M(e,t={}){return ZI(AM,e,t)}function IM(e,t){return WI(e,t)}const nf=Va("type",[M({type:ht("text"),text:w()}),M({type:ht("reasoning"),text:w()}),M({type:ht("image"),name:w().optional(),mediaType:w().optional(),width:le().optional(),height:le().optional(),attachmentId:w().optional(),bytes:le().optional()}),M({type:ht("file"),name:w().optional(),size:le().optional(),mediaType:w().optional()}),M({type:ht("tool-call"),callId:w(),name:w(),arguments:w()}),M({type:ht("other"),kind:w()})]),Oy=M({inputTokens:le(),outputTokens:le(),totalTokens:le().optional(),cacheReadTokens:le().optional(),cacheWriteTokens:le().optional(),reasoningTokens:le().optional()}),Py=M({firstChunkAt:le().optional(),firstTokenAt:le().optional(),lastChunkAt:le().optional(),tokenChunks:le()}),Ly=M({message:w(),code:w().optional()}),TM=M({kind:w(),message:w().optional()}),MM=M({kind:w(),human:ve(),summary:w().optional()}),Fn={seq:le(),time:le()},yp=Va("type",[M({...Fn,type:ht("turn/start"),turn:le()}),M({...Fn,type:ht("turn/end"),turn:le(),reason:TM}),M({...Fn,type:ht("step/start"),turn:le(),step:le()}),M({...Fn,type:ht("step/end"),turn:le(),step:le()}),M({...Fn,type:ht("user/message"),messageId:w(),content:me(nf),origin:MM,requestId:w().optional(),replacesHistory:ve().optional()}),M({...Fn,type:ht("system/message"),turn:le(),step:le(),text:w()}),M({...Fn,type:ht("assistant/message"),turn:le(),step:le(),messageId:w(),content:me(nf),timing:Py,usage:Oy.optional(),interrupted:ve().optional(),provider:w().optional(),model:w().optional()}),M({...Fn,type:ht("assistant/attempt"),turn:le(),step:le(),timing:Py,error:Ly.optional()}),M({...Fn,type:ht("tool/call"),turn:le(),step:le(),callId:w(),name:w(),arguments:w()}),M({...Fn,type:ht("tool/result"),turn:le(),step:le(),callId:w(),isError:ve(),content:me(nf),error:Ly.optional()}),M({...Fn,type:ht("request/header"),provider:w().optional(),model:w().optional(),reasoningEffort:w().optional(),toolNames:me(w()),reason:w()}),M({...Fn,type:ht("compaction/start"),compactionId:w(),turn:le().nullable()}),M({...Fn,type:ht("compaction/summary"),compactionId:w(),shadowedTokenCount:le(),provider:w().optional(),model:w().optional(),usage:Oy.optional()}),M({...Fn,type:ht("compaction/end"),compactionId:w(),turn:le().nullable(),error:w().optional()}),M({...Fn,type:ht("approval/asked"),approvalId:w(),toolName:w(),callId:w().optional(),reason:w().optional()}),M({...Fn,type:ht("approval/decided"),approvalId:w(),outcome:w()}),M({...Fn,type:ht("session/title"),title:w()}),M({...Fn,type:ht("unknown"),upstreamType:w(),data:xp()})]),CN=Va("type",[M({type:ht("start"),attemptId:w(),turn:le(),step:le(),afterSeq:le()}),M({type:ht("delta"),attemptId:w(),time:le(),kind:Ie(["text","reasoning","tool-args"]),index:le(),text:w(),callId:w().optional(),toolName:w().optional()}),M({type:ht("end"),attemptId:w(),outcome:Ie(["committed","abandoned"]),seq:le().optional()})]),RM=M({attemptId:w(),turn:le(),step:le(),afterSeq:le(),deltas:me(CN.options[1])}),OM=M({index:le().int().min(0),name:w(),running:ve(),ready:ve(),adb:w().optional()}),PM=M({kind:Ie(["mumu"]),name:w(),manager:w(),version:w().optional(),instances:me(OM),error:w().optional()}),AN=M({mumuManager:w().optional(),instance:le().int().min(0).max(63),manualAddress:w().regex(/^[\w.-]+:\d{1,5}$/).optional(),adbPath:w().optional(),autoStart:ve(),bootTimeoutSeconds:le().int().min(30).max(900)});M({providers:me(PM),settings:AN,selection:M({label:w(),address:w().optional(),problem:w().optional()})});M({refresh:ve().optional()}),M({index:le().int().min(0).optional()}),M({address:w(),label:w()}),M({index:le().int().min(0).optional()}),M({}),AN.partial().extend({mumuManager:w().nullable().optional(),manualAddress:w().regex(/^[\w.-]+:\d{1,5}$/).nullable().optional(),adbPath:w().nullable().optional()});M({});const Rg=Ie(["maafw-pi","cli","gui-config","generic-process","visual"]),St=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"),sf=w().trim().regex(/^[A-Za-z0-9_.-]{1,100}$/,"use the resource id, e.g. MAA or BGI"),LM=Va("kind",[M({kind:ht("github"),repo:w()}),M({kind:ht("mirrorchyan"),rid:w(),platform:ve(),os:ve().optional(),arch:ve().optional()}),M({kind:ht("local"),path:w()})]),zM=M({version:w(),dir:w(),installedAt:le(),asset:M({name:w(),size:le()}).optional(),current:ve()}),DM=Ie(["ok","missing","outdated","unknown","unsupported"]),FM=M({kind:w(),label:w(),required:w().optional(),status:DM,found:w().optional(),detail:w().optional(),fix:M({kind:Ie(["auto","installer","manual"]),description:w(),needsAdmin:ve()}).optional()}),UM=M({checkedAt:le(),ok:ve(),items:me(FM)}),BM=M({executables:me(w()),markers:me(w()),family:Rg.optional()}),zy=Ie(["install","pack","known","user"]),HM=M({github:M({repo:w(),from:zy}).optional(),mirrorchyan:M({rid:w(),from:zy}).optional()}),ZM=M({version:w(),from:w()}),WM=M({state:Ie(["running","done","failed"]),at:le(),text:w().optional(),sessionId:w().optional()}),VM=M({id:w(),name:w(),source:LM,packId:w().optional(),family:Rg.optional(),current:w().optional(),dir:w().optional(),versions:me(zM),env:UM.optional(),probe:BM.optional(),update:M({latest:w(),available:ve(),checkedAt:le()}).optional(),channels:HM,known:w().optional(),localVersion:ZM.optional(),undo:M({from:w().optional(),to:w(),at:le()}).optional(),jobId:w().optional(),addedAt:le(),summary:WM.optional(),packReview:M({from:w().optional(),to:w()}).optional(),optimize:M({runs:le(),at:le().optional(),due:Ie(["runs","updated"]).optional()}).optional()}),qM=M({id:w(),name:w(),description:w().optional(),repo:w().optional(),mirrorchyan:w().optional(),family:Rg.optional(),builtin:ve(),installed:ve(),own:ve().optional(),error:w().optional()}),GM=M({packId:w(),name:w(),builtin:ve(),written:ve(),overview:w().optional(),tasks:me(M({id:w(),title:w(),description:w().optional(),utterances:me(w()),input:Ie(["desktop","window","adb","none"]),expectedDuration:w().optional(),params:me(M({name:w(),type:Ie(["string","integer","number","boolean"]),description:w().optional(),default:w().optional(),values:w().optional()}))})),setup:me(w()),checks:me(w()),features:me(M({title:w(),description:w().optional(),enable:w(),config:me(M({file:w(),key:w(),value:w()})),tasks:me(w())})),config:me(M({file:w(),about:w().optional(),keys:me(M({key:w(),meaning:w(),values:w().optional(),default:w().optional(),advice:w().optional()})),changes:me(M({key:w(),value:w(),note:w().optional(),when:w().optional(),tasks:me(w())}))})),troubleshooting:me(M({problem:w(),cause:w().optional(),fix:w()}))});M({rid:w(),version:w(),platform:ve(),os:ve().optional(),arch:ve().optional(),name:w().optional(),description:w().optional(),repo:w().optional()});const bp=M({rid:w(),name:w(),description:w(),repo:w().optional(),url:w().optional(),installed:ve(),known:ve()}),KM=M({id:w(),name:w(),repo:w().optional(),mirrorchyan:w().optional(),installed:ve()}),YM=M({name:w(),size:le(),downloadUrl:w(),digest:w().optional()}),XM=M({tag:w(),name:w(),prerelease:ve(),publishedAt:w().optional(),url:w().optional(),assets:me(YM),suggestedAsset:w().optional(),notes:w().optional()}),QM=Ie(["queued","resolving","downloading","verifying","extracting","checking","running","done","failed","cancelled"]),JM=M({sessionId:w(),state:Ie(["running","failed"]),reason:w().optional()}),eR=M({scriptId:w(),name:w(),kind:Ie(["nsis","inno","kachina"]),version:w(),dir:w(),update:ve(),at:le(),agent:JM.optional()}),tR=M({id:w(),kind:Ie(["install","update","env-fix"]),scriptId:w(),phase:QM,message:w().optional(),received:le().optional(),total:le().optional(),version:w().optional(),error:w().optional(),setup:M({kind:Ie(["nsis","inno","kachina"]),dir:w(),sessionId:w().optional()}).optional(),startedAt:le(),endedAt:le().optional()}),nR=Ie(["auto","ask","off"]),Dy=M({apiBase:gp({protocol:/^https?$/}),downloadMirror:w().trim().max(300),mirrorFallback:ve(),tokenRef:w().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),keepVersions:le().int().min(1).max(10),includePrereleases:ve(),cdkRef:w().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),autoUpdate:nR});M({});const sR=M({name:w(),source:Ie(["pack","discovered"]),transport:Ie(["stdio","http","sse"]),target:w(),file:w().optional(),needsRunning:ve(),description:w().optional(),problem:w().optional(),trusted:ve(),connected:ve()}),iR=M({name:w(),description:w(),path:w(),problem:w().optional(),imported:M({name:w(),current:ve(),changed:ve()}).optional()});M({id:St});M({scripts:me(VM),packs:me(qM),known:me(KM),setups:me(eR).default([]),toolsDir:w()}),M({guide:GM.nullable()}),M({icon:M({mediaType:w(),data:w()}).optional()}),M({query:w().trim().min(1).max(200)}),M({items:me(M({repo:w(),description:w().optional(),stars:le(),packId:w().optional()}))}),M({repo:ac,limit:le().int().min(1).max(30).optional()}),M({repo:w(),packId:w().optional(),releases:me(XM)}),M({repo:ac.optional(),mirrorchyan:sf.optional(),tag:w().min(1).max(200).optional(),asset:w().min(1).max(300).optional(),branch:w().min(1).max(200).optional(),id:St.optional()}).refine(e=>e.repo===void 0!=(e.mirrorchyan===void 0),"give either repo or mirrorchyan"),M({jobId:w(),scriptId:w()}),M({current:w().optional(),latest:w(),available:ve()}),M({jobId:w().optional(),upToDate:ve()}),M({id:St,repo:ac.nullable().optional(),mirrorchyan:sf.nullable().optional(),reset:me(Ie(["repo","mirrorchyan"])).optional()}),M({items:me(bp.extend({by:Ie(["repo","name"])})),from:Ie(["mirrorchyan","builtin"])}),M({rid:sf}),M({query:w().trim().max(100)}),M({items:me(bp),from:Ie(["mirrorchyan","builtin"]),fetchedAt:le().optional()}),M({id:w(),decision:Ie(["check","keep"])}),M({sessionId:w().optional()}),M({id:St,version:w().optional()}),M({dir:w()}),M({sessionId:w()}),M({path:w().trim().min(1).max(1e3),id:St.optional(),name:w().trim().min(1).max(100).optional(),packId:St.optional()}),M({id:St,decision:Ie(["run","keep"])}),M({sessionId:w().optional()}),M({id:St}),M({sessionId:w()}),M({id:St,deleteFiles:ve().optional()}),M({id:w().min(1)}),M({servers:me(sR),usage:w().optional(),note:w().optional(),skills:me(iR)}),M({id:St,server:w().min(1).max(32)}),M({ok:ve(),tools:me(M({name:w(),title:w().optional(),description:w().optional()})).optional(),server:M({name:w(),version:w()}).optional(),error:w().optional()}),M({id:St,names:me(w().min(1).max(200)).max(50).optional()}),M({imported:me(M({skill:w(),name:w(),replaced:ve()})),skipped:me(M({skill:w(),reason:w()}))}),M({id:St,kind:w().min(1).max(64)}),M({jobId:w()}),M({items:me(tR)}),M({jobId:w()}),Dy.extend({tokenConfigured:ve(),cdkConfigured:ve()}),M({ok:ve(),message:w(),expiresAt:le().optional()}),Dy.partial();M({id:w().optional()});const rR=M({packId:w(),scriptId:w(),proposedAt:le(),sessionId:w().optional(),summary:w(),docs:me(M({source:w(),used:w()})).optional(),noDocs:w().optional(),manifest:w(),skill:w(),current:M({manifest:w(),skill:w().optional(),builtin:ve()}).optional(),tasks:me(M({id:w(),title:w()}))}),aR=M({id:w(),at:le().optional(),builtin:ve().optional(),tasks:me(M({id:w(),title:w()}))});M({packId:St}),M({items:me(aR)}),M({packId:St,version:w().min(1).max(64)}),M({}),M({scriptId:St.optional()}),M({items:me(rR)}),M({packId:St}),M({packId:w(),dir:w()}),M({packId:St}),M({});M({packId:w().optional()});const oR=M({scriptId:w(),dir:w(),grantedAt:le(),expiresAt:le()});M({}),M({items:me(oR),blocked:le()}),M({scriptId:St,minutes:le().int().min(1).max(240)}),M({scriptId:St}),M({});M({}),M({toolName:w(),target:w(),sessionId:w().optional(),at:le()});const lR=Ie(["error","warning","failed","stalled","overtime"]),cR=M({at:le(),action:Ie(["reconnect-adb","restart","stop","screenshot","notify","resolve","intervene"]),by:Ie(["rule","user","agent"]),ok:ve(),detail:w()}),uR=M({id:w(),runId:w(),scriptId:w(),scriptName:w(),taskId:w(),taskTitle:w(),kind:lR,severity:Ie(["warning","error"]),tag:w(),title:w(),detail:w(),lines:me(w()),status:Ie(["open","resolved"]),resolution:w().optional(),createdAt:le(),updatedAt:le(),steps:me(cR),screenshot:ve()}),dR=M({seconds:le().int().min(5).max(24*3600),by:Ie(["learned","agent","user"]),note:w().max(300).optional(),samples:me(le().min(0)).max(10).default([]),at:le()}),hR=M({defaultStallSeconds:le().int().min(0).max(24*3600),scriptStall:Ws(w(),dR),notifyWarnings:ve(),screenshot:ve(),intervene:Ie(["off","diagnose","act"]),interventionsPerDay:le().int().min(0).max(200)});M({status:Ie(["open","all"]).optional(),runId:w().optional(),limit:le().int().min(1).max(500).optional()}),M({items:me(uR)}),M({incidentId:w(),action:Ie(["stop","retry","resolve","resume"])}),M({incidentId:w()}),M({mime:ht("image/png"),data:w()}),M({}),hR.partial();const mR="ADG_FEISHU_APP_SECRET",fR="ADG_QQBOT_APP_SECRET",kp=M({id:w(),label:w(),ok:ve().nullable(),detail:w().optional()}),pR=M({id:w(),name:w(),state:Ie(["off","connecting","ready","error"]),detail:w().optional(),recipients:le().int().min(0),checks:me(kp)}),gR=M({openId:w().min(1),name:w().optional(),addedAt:le()}),xR=M({enabled:ve(),appId:w().optional(),domain:Ie(["feishu","lark"]),allowedUsers:me(gR),chatId:w().optional(),otherApprovals:ve()}),vR=M({openId:w(),at:le(),text:w()});M({settings:xR,secretConfigured:ve(),pending:me(vR)});const yR=M({openId:w().min(1),name:w().optional(),addedAt:le()}),bR=M({enabled:ve(),appId:w().optional(),allowedUsers:me(yR)}),kR=M({openId:w(),at:le(),text:w()});M({settings:bR,secretConfigured:ve(),pending:me(kR)});const $N=M({id:w(),title:w(),text:w(),severity:Ie(["info","success","warning","error"]),at:le(),actions:me(M({id:w(),label:w(),style:Ie(["primary","danger","default"]).optional()})),channels:me(w()),image:ve().optional(),done:w().optional(),acted:M({by:w(),label:w(),result:w(),at:le()}).optional()});M({}),M({channels:me(pR)}),M({}),M({items:me(M({sessionId:w(),channel:w(),user:w()}))}),M({}),M({items:me($N)}),M({noticeId:w(),actionId:w()}),M({result:w()}),M({channel:w().optional()}),M({sent:me(w()),failed:me(M({channel:w(),error:w()}))}),M({}),M({enabled:ve().optional(),appId:w().trim().regex(/^cli_[0-9a-fA-F]{16}$/,"App ID 是 cli_ 加 16 位字母数字,在「凭证与基础信息」里复制").nullable().optional(),domain:Ie(["feishu","lark"]).optional(),chatId:w().trim().regex(/^oc_[A-Za-z0-9]+$/,"群 ID 以 oc_ 开头").nullable().optional(),otherApprovals:ve().optional()}),M({openId:w().trim().regex(/^ou_[A-Za-z0-9]+$/,"open_id 以 ou_ 开头"),name:w().max(40).optional()}),M({openId:w()}),M({}),M({checks:me(kp)}),M({}),M({enabled:ve().optional(),appId:w().trim().regex(/^\d{6,20}$/,"AppID 是一串数字,在 QQ 开放平台「开发设置」里复制").nullable().optional()}),M({openId:w().trim().regex(/^[0-9A-Za-z_-]{8,64}$/,"user_openid 是一串字母数字(机器人回复你的那条消息里有)"),name:w().max(40).optional()}),M({openId:w()}),M({}),M({checks:me(kp)});M({}),M({item:$N});const Ca=w().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,"小写字母、数字和短横线").max(64),yc=w().regex(/^[A-Za-z0-9_-]{1,40}$/),Og=w().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"时间写成 HH:MM,例如 04:30"),IN=M({retries:le().int().min(0).max(5).default(0),then:Ie(["continue","stop"]).default("continue")}),ba={id:yc,title:w().max(60).optional(),position:M({x:le(),y:le()}).optional(),onFailure:IN.optional(),waitForAll:ve().optional()},jR=Va("kind",[M({...ba,kind:ht("script-task"),scriptId:St,taskId:w().min(1).max(64),params:Ws(w(),Go([w(),le(),ve()])).default({}),profile:w().min(1).max(64).optional()}),M({...ba,kind:ht("agent"),prompt:w().min(1).max(4e3)}),M({...ba,kind:ht("wait"),minutes:le().int().min(1).max(1440).optional(),until:Og.optional()}).refine(e=>e.minutes===void 0!=(e.until===void 0),"等待节点写分钟数或时间其中一个"),M({...ba,kind:ht("notify"),text:w().min(1).max(2e3)}),M({...ba,kind:ht("gate"),text:w().min(1).max(2e3)}),M({...ba,kind:ht("start")}),M({...ba,kind:ht("end")})]);function Zi(e){return e.kind==="start"||e.kind==="end"}function NR(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=>!Zi(g)),r=new Set(e.nodes.map(g=>g.id)),o=g=>{let x=g;for(let b=2;r.has(x);b++)x=`${g}${b}`;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),f=[...e.nodes],p=[...e.edges];if(!t){const g=o("start");f.unshift({id:g,kind:"start",...l.length===0?{}:{position:{x:u-240,y:h}}});for(const x of i)e.edges.some(b=>b.to===x.id)||p.push({from:g,to:x.id,when:"success"})}if(!s){const g=o("end");f.push({id:g,kind:"end",...l.length===0?{}:{position:{x:d+300,y:h}}});for(const x of i)e.edges.some(b=>b.from===x.id)||p.push({from:x.id,to:g,when:"always"})}return{...e,nodes:f,edges:p}}const wR=M({from:yc,to:yc,when:Ie(["success","failure","always"]).default("success")}),Pg=M({enabled:ve().default(!1),times:me(Og).max(12).default([]),days:me(le().int().min(0).max(6)).max(7).default([]),catchUpMinutes:le().int().min(0).max(720).default(10),after:Ca.optional()}),SR=["日","一","二","三","四","五","六"],_R=[1,2,3,4,5,6,0];function Lg(e){return e.enabled?e.times.length===0?e.after===void 0?"没有设时间":`「${e.after}」跑完后`:`${e.days.length===0||e.days.length===7?"每天":`每周${_R.filter(s=>e.days.includes(s)).map(s=>SR[s]).join("、")}`} ${[...e.times].sort().join("、")}`:"已暂停"}M({kind:Ie(["task","reminder"]),id:w().optional(),by:w(),agent:w(),title:w(),when:w(),changed:ve()});const TN=Ie(["none","sleep","hibernate","shutdown"]),rf=M({id:Ca,name:w().min(1).max(60),description:w().max(500).optional(),nodes:me(jR).max(60),edges:me(wR).max(200).default([]),onFailure:IN.default({retries:0,then:"continue"}),schedule:Pg.default({enabled:!1,times:[],days:[],catchUpMinutes:10}),stopEmulatorAfter:ve().default(!1),closeGameAfter:ve().default(!1),powerAfter:TN.default("none"),draft:ve().optional(),createdAt:le().optional(),updatedAt:le().optional()}),ER=M({level:Ie(["error","warning","info"]),nodeId:w().optional(),message:w()}),CR=M({ok:ve(),issues:me(ER),serialized:me(M({a:w(),b:w(),resource:w()})),estimateMinutes:le().optional()}),AR=Ie(["pending","waiting","running","succeeded","failed","skipped","cancelled"]),$R=M({state:AR,detail:w().optional(),runIds:me(w()),attempts:le().int().min(0),startedAt:le().optional(),endedAt:le().optional()}),MN=M({kind:Ie(["manual","schedule","autostart","agent","after"]),detail:w().optional()}),RN=M({id:w(),pipelineId:w(),pipelineName:w(),trigger:MN,from:w().optional(),state:Ie(["running","succeeded","failed","cancelled"]),stopping:w().optional(),nodes:Ws(w(),$R),startedAt:le(),endedAt:le().optional(),outcome:w().optional()}),IR=M({id:w(),name:w(),description:w().optional(),nodes:le(),draft:ve(),schedule:Pg,updatedAt:le().optional(),lastRun:RN.pick({id:!0,state:!0,startedAt:!0,endedAt:!0}).optional()}),Yl=w().regex(/^task-[a-z0-9]{4,24}$/),Fy=M({id:Yl,agent:w().min(1).max(64),title:w().trim().min(1).max(60),prompt:w().trim().min(1).max(4e3),schedule:Pg,createdAt:le().optional(),updatedAt:le().optional()}),Uy=M({id:w(),taskId:w(),trigger:MN,state:Ie(["running","done","failed"]),outcome:w().optional(),startedAt:le(),endedAt:le().optional()}),ON=M({autostart:ve(),autostartPipelines:me(Ca),autostartDelaySeconds:le().int().min(0).max(1800),skipIfRanToday:ve(),firstStartOnly:ve().default(!1),wakeToRun:ve().default(!1),powerCountdownSeconds:le().int().min(10).max(600).default(60)}),PN={agent:w().optional()},TR=M({pipelineId:w(),pipelineName:w(),...PN,slot:w(),at:le(),outcome:Ie(["fired","missed","skipped","failed"]),detail:w().optional()}),MR=M({awake:ve(),pending:M({action:TN.exclude(["none"]),pipelineName:w(),at:le().optional()}).optional()});M({settings:ON,autostart:M({available:ve(),registered:ve(),detail:w().optional()}),autostarted:ve(),wake:M({available:ve(),registered:ve(),next:le().optional(),detail:w().optional()}),power:MR,upcoming:me(M({pipelineId:w(),pipelineName:w(),at:le(),...PN})),history:me(TR)});M({}),M({items:me(IR)}),M({id:Ca}),M({pipeline:rf}),M({pipeline:rf,check:CR}),M({id:Ca}),M({}),M({pipeline:rf}),M({id:Ca,from:yc.optional()}),M({runId:w()}),M({}),M({pipelineId:Ca.optional(),limit:le().int().min(1).max(100).optional()}),M({items:me(RN)}),M({runId:w(),nodeId:yc,decision:Ie(["continue","stop"])}),M({}),M({}),ON.partial(),M({}),M({}),M({agent:w().optional()}),M({items:me(Fy.extend({lastRun:Uy.optional()}))}),M({task:Fy.extend({id:Yl.optional()})}),M({id:Yl}),M({}),M({id:Yl}),M({id:Yl}),M({items:me(Uy)});M({}),M({}),M({});const RR=Ie(["running","resolved","retried","gave-up","taken-over","timeout","failed"]),OR=M({id:w(),incidentId:w().optional(),runId:w().optional(),title:w(),mode:Ie(["diagnose","act"]),state:RR,sessionId:w().optional(),paused:ve(),summary:w().optional(),startedAt:le(),endedAt:le().optional()});M({limit:le().int().min(1).max(100).optional()}),M({items:me(OR)}),M({id:w()}),M({id:w(),then:Ie(["resume","restart","stop"])});const PR=M({id:w(),game:w(),title:w(),kind:Ie(["update","notice","news"]),publishedAt:le().optional(),version:w().optional(),summary:w().optional(),url:w().optional(),cover:w().optional(),lasting:ve().optional(),source:M({id:w(),name:w()}),at:le()}),By=M({id:w(),game:w(),name:w(),startsAt:le().optional(),endsAt:le().optional(),shopEndsAt:le().optional(),url:w().optional(),kind:w().optional(),description:w().optional(),cover:w().optional(),site:M({source:w(),name:w(),at:le()}).optional(),sources:me(M({id:w(),name:w(),at:le(),web:ve(),startsAt:le().optional(),endsAt:le().optional(),shopEndsAt:le().optional(),cover:w().optional()})).optional(),chosen:w().optional(),shown:M({cover:w().optional(),startsAt:w().optional(),endsAt:w().optional()}).optional(),screen:M({at:le(),remaining:w().optional(),endsAt:le().optional(),evidence:ve(),image:w().optional(),sessionId:w().optional()}).optional(),todo:me(w()),done:me(w()),progress:w().optional(),finished:M({at:le()}).optional(),mismatch:w().optional(),own:M({at:le(),fields:me(Ie(["name","startsAt","endsAt","kind","description","url","cover"])),startsAt:le().optional(),endsAt:le().optional(),cover:w().optional()}).optional()}),Mo="@own",oc="@screen",LR=112e5,zR=M({mediaType:Ie(["image/png","image/jpeg","image/gif","image/webp","image/avif"]),data:w().min(1).max(LR).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix")}),DR=/^own:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,FR=/^shot:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,UR=M({id:w(),name:w(),homepage:w().optional(),auto:ve(),added:ve().optional()}),BR=M({id:w(),name:w(),aliases:me(w()),scripts:me(w()),timezone:w(),screen:M({target:Ie(["emulator","window"]),window:w().optional()}).optional(),sources:me(UR),builtin:ve(),art:w().optional(),followed:ve().optional(),sra:me(w()).optional(),own:ve().optional(),single:ve().optional(),version:M({name:w(),title:w().optional(),startsAt:le().optional(),endsAt:le().optional(),cover:w().optional(),source:w(),at:le()}).optional(),pools:me(M({name:w(),type:w().optional(),startsAt:le().optional(),endsAt:le(),cover:w().optional(),up:me(w())})).optional(),refreshed:M({at:le(),ok:ve(),count:le(),detail:w().optional()}).optional(),reading:M({state:Ie(["running","done","failed"]),at:le(),sessionId:w().optional(),summary:w().optional()}).optional(),webReading:M({state:Ie(["running","done","failed"]),at:le(),sessionId:w().optional(),summary:w().optional()}).optional()}),Hy=M({report:M({enabled:ve(),at:Og,games:me(w()),soonDays:le().int().min(1).max(30),ai:ve()}),followed:me(w()),hidden:me(w()).optional()}),HR=M({lastSentAt:le().optional(),lastDay:w().optional(),lastResult:w().optional(),lastText:w().optional(),next:le().optional()});M({}),M({games:me(BR),activities:me(By),notices:me(PR).default([]),settings:Hy,report:HR}),M({game:w().optional()}),M({results:me(M({game:w(),ok:ve(),count:le(),notices:le().optional(),detail:w().optional()}))}),M({game:w(),how:Ie(["screen","web"]).optional(),source:w().optional()}),M({sessionId:w()}),M({}),M({title:w(),text:w()}),M({}),M({channels:me(w()),text:w()}),M({report:Hy.shape.report.partial().optional()}),M({activityId:w()}),M({mediaType:w(),data:w()}),M({url:w().refine(e=>DR.test(e)||FR.test(e)||/^https?:\/\/\S+$/.test(e),"不是图片地址")}),M({mediaType:w(),data:w()}),M({game:w().min(1)}),M({icon:M({mediaType:w(),data:w()}).optional()}),M({name:w().trim().min(1).max(60)}),M({game:w()}),M({game:w()}),M({}),M({game:w()}),M({sessionId:w()}),M({game:w()}),M({items:me(bp),from:Ie(["mirrorchyan","builtin"])}),M({game:w(),url:w().url().refine(e=>/^https?:\/\//.test(e),"只能是 http 或 https 网址"),name:w().max(30).optional()}),M({source:w(),sessionId:w()}),M({game:w(),source:w()}),M({}),M({}),M({games:me(M({sra:w(),name:w(),followed:ve(),pack:w().optional()}))}),M({sra:w(),follow:ve()}),M({}),M({activityId:w(),todo:me(w().min(1).max(80)).max(30).optional(),done:me(w().min(1).max(80)).max(30).optional(),finished:ve().optional()}),M({game:w(),activityId:w().optional(),name:w().trim().min(1).max(60).nullable().optional(),startsAt:le().nullable().optional(),endsAt:le().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:iM().optional(),image:zR.optional(),todo:me(w().min(1).max(80)).max(30).optional()}),M({activityId:w(),source:w().nullable()}),M({activityId:w()}),M({activity:By.optional()}),M({activityId:w()}),M({});M({game:w().optional()});const LN=Ie(["ask","full"]),zN=Ie(["default","allow","ask","deny"]),ZR=[{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}];M({mode:LN,since:le().optional(),areas:Ws(w(),zN).default({}),recent:me(M({at:le(),sessionId:w(),toolName:w(),reason:w().optional()}))});M({}),M({mode:LN}),M({area:w(),policy:zN});const WR=M({label:w(),description:w().optional()}),VR=M({id:w(),question:w(),detail:w().optional(),header:w().optional(),options:me(WR).optional(),multiSelect:ve().optional()});M({questionId:w(),sessionId:w(),callId:w().optional(),questions:me(VR)});const DN=M({id:w(),selected:me(w()),custom:w().optional()}),qR=Ie(["answered","cancelled","unavailable"]);M({questionId:w(),answers:me(DN)}),M({});M({questionId:w(),outcome:qR,answers:me(DN).optional()});const GR=M({pid:le().int(),label:w(),dataDir:w().optional(),startedAt:le(),warnings:me(w())});M({others:me(GR)});M({});const zg=M({scripts:me(w()).optional(),games:me(w()).optional()}),Zy=M({name:w(),description:w(),whenToUse:w().optional(),source:w(),provider:w(),path:w().optional(),modelInvocable:ve(),userInvocable:ve(),owner:zg.optional(),removable:ve().optional(),kind:Ie(["script-pack","game-pack"]).optional(),pack:w().optional(),ownPack:ve().optional()}),FN=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,jp=48;M({}),M({skills:me(Zy)}),M({name:w()}),Zy.extend({content:w()}),M({name:w().regex(FN).max(jp),description:w().trim().min(10).max(400),content:w().trim().min(20).max(2e4),scripts:me(w().min(1).max(64)).max(20).optional(),games:me(w().min(1).max(64)).max(20).optional(),replace:ve().optional()}),M({name:w(),replaced:ve()}),M({sessionId:w()}),zg.required(),M({name:w()}),M({});M({}),M({sessionId:w(),scripts:me(w()),games:me(w())});const af=M({repo:ac,branch:w().trim().min(1).max(100).regex(/^[\w./-]+$/)}),Wy=M({name:w(),description:w(),title:w().optional(),kind:Ie(["game","script","general"]),pack:Ie(["script","game"]).optional(),game:w().optional(),sra:me(w()).optional(),default:ve().optional(),games:me(w()),scripts:me(w()),repo:w(),author:w().optional(),path:w(),hash:w(),version:w().optional(),changes:w().optional(),requires:w().optional(),history:me(M({version:w(),changes:w().optional()})).optional(),installed:M({at:le(),update:ve(),version:w().optional(),previous:M({version:w().optional(),at:le()}).optional(),held:ve().optional()}).optional(),incompatible:w().optional(),blocked:w().optional()}),Gu=M({name:w().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});M({refresh:ve().optional()}),M({items:me(Wy),repos:me(af),errors:me(w()),fetchedAt:le().optional()}),M({content:w()}),Gu.extend({description:w().trim().min(10).max(400),content:w().trim().min(20).max(2e4)}),M({}),Gu.extend({repo:ac.optional()}),M({state:Ie(["current","updated"]),item:Wy}),Gu.extend({version:w().min(1).max(40)}),M({}),Gu.extend({owner:zg.nullable()}),M({}),M({repos:me(af).min(1).max(10)}),M({repos:me(af)});M({});const Dg="你",UN="(不用告诉用户)",Vy=e=>e.replace(/[^\p{Script=Han}a-zA-Z0-9]/gu,"");function KR(e){return Vy(e)===Vy(UN)}const YR="(你这一轮的最后一段回复会作为结论交回去。在那之前要让对方知道的,用 agent_message 的 update 说,马上送到,说几次都行;交回结论以后还有话,同样发到这条线索:你的普通回复对方看不到。)",XR="(做完后你这一轮的最后一段回复会原样交回去:把结论写在那里。)",QR=/^(这件事的线索是 (\S+):做的过程中要问清楚什么,用 agent_message 问,thread 填它;不要猜。)$/,JR=/^(你和.{1,20}之前的来往,/,e2=")";function BN(e){var f;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]===YR||s[0]===XR,l=o?s.slice(1):s,u=(f=QR.exec(l[0]??""))==null?void 0:f[1],d=u===void 0?l:l.slice(1),h=JR.test(d[0]??"")?d.indexOf(e2):-1;return{by:i!==null?Dg: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 HN(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 ZN(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 t2(e){return e.replace(/\s+/g," ").replace(/[()]/g,t=>t==="("?"(":")").trim()}const qy=/\n\n(这是你在线索 \S+ 上定的提醒:[^)]*)$/;function Gy(e){const t=/^\[SCHEDULE REMINDER\]\n[\s\S]*?^reminder_prompt_json: (.*)$/m.exec(e);if(t!==null)return[s2(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 n2(e){return e.length===0?"定时提醒":`定时提醒:${e.map(t=>t2(t)).join(";")}`}function s2(e){try{const t=JSON.parse(e);return typeof t=="string"?t:e}catch{return e}}const i2=Ie(["default","concise","patient","lively","buddy","butler"]),r2=Ie(["plain","same"]),WN=M({style:i2,callUser:w().max(20).optional(),custom:w().optional(),peerStyle:r2.optional()}),a2=WN.partial().extend({name:w().max(20).optional()}),o2=M({persona:WN,agents:Ws(w(),a2)});o2.extend({prompt:w(),prompts:Ws(w(),w())});const Ky={default:"",concise:"回答简短直接:先给结论,再给必要的细节;少寒暄,不用表情。",patient:"耐心、讲清楚:每一步说明为什么这么做,用对方听得懂的话,像教一个刚接触的人。",lively:"语气轻松活泼,可以用一点语气词和表情,但信息要准确、不啰嗦。",buddy:"像一起玩游戏的老朋友那样说话:熟悉游戏里的说法,可以适当吐槽和鼓励,但不夸张、不油腻。",butler:"像一位稳重周到的管家:礼貌、条理清楚,主动汇报进度和需要对方决定的事。"};function Yy(e,t){const s=Object.entries(e.agents[t]??{}).filter(([,i])=>i!==void 0);return{...e.persona,...Object.fromEntries(s)}}function Xy(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()}」。`),Ky[e.style]!==""&&t.push(Ky[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(`软件约定的固定写法(比如「${UN}」这一句、线索编号、工具的参数)一字不差照写,不加语气词和表情。`),["# 回复风格",...t,"这些只影响你说话的方式,不改变做事的规则:确认、安全限制和不能做的事都照旧;在飞书里回复也一样。"].join(`
114
+ `))}M({});const l2=80,VN=5,qN=100,c2=30,u2=1,d2=365,h2=[3,7,14,30],Np=M({auto:ve(),threshold:le().int().min(VN).max(qN),lowContext:ve(),archiveDays:le().int().min(u2).max(d2).nullable().default(null),ptcSubagents:ve().default(!0),summarizer:M({provider:w().min(1).max(200),model:w().min(1).max(200),maxTokens:le().int().positive().optional()}).nullable().default(null)});M({settings:Np,applied:Np});M({}),M({settings:Np});const ka="shared",wp=Ie(["profile","journal","core"]),Fg=2e3,m2=M({agent:w(),sessionId:w(),seq:le().int().min(0)}),Ug=600,of=M({id:w(),kind:wp,scope:w(),text:w(),createdAt:w(),updatedAt:w(),by:w(),source:m2.optional()}),f2=M({auto:ve(),model:M({provider:w(),model:w(),reasoningEffort:w().optional()}).nullable()}),Qy=w().trim().min(1).max(Ug);M({}),M({items:me(of)}),M({kind:wp,scope:w().min(1).max(64),text:Qy}),M({item:of}),M({id:w(),text:Qy,kind:wp.optional(),scope:w().min(1).max(64).optional()}),M({item:of}),M({}),f2.extend({forced:ve().optional()}),M({id:w()}),M({removed:ve()});M({});const p2=Ie(["starting","running","stopping","succeeded","failed","cancelled"]),g2=M({type:Ie(["string","integer","number","boolean"]),default:Go([w(),le(),ve()]).optional(),enum:me(Go([w(),le()])).optional(),description:w().optional(),choices:me(M({value:w(),label:w(),detail:w().optional()})).optional(),canCreate:ve().optional()}),x2=M({mode:Ie(["auto","platform","off"]),pcLaunch:Ie(["program","maaend"]).optional(),pcRegion:Ie(["CN","Global","Bilibili","TapTap","Steam","Epic"]).optional(),pcExe:w().optional(),pcProcess:w().optional(),androidPackage:w().optional()});M({settings:x2,game:M({name:w().optional(),androidPackage:w().optional(),pcProcess:w().optional(),selfLaunch:w()}),uses:M({adb:ve(),desktop:ve()})});const v2=M({id:w(),title:w(),description:w().optional(),utterances:me(w()),params:Ws(w(),g2),input:Ie(["desktop","window","adb","none"]),account:w().optional(),expectedDuration:w().optional()}),Di=w().trim().min(1).max(64),Sp=M({id:w(),name:w(),createdAt:le().optional()}),GN=M({current:w(),items:me(Sp)}),y2=M({id:w(),scriptId:w(),scriptName:w(),taskId:w(),taskTitle:w(),params:Ws(w(),Go([w(),le(),ve()])),state:p2,outcome:w().optional(),startedAt:le(),endedAt:le().optional(),exitCode:le().optional(),command:me(w()),resources:me(w()),tags:me(w()),warnings:me(w()),kind:Ie(["task","settings"]),retryOf:w().optional(),halted:ve().optional(),profile:w().optional(),profileName:w().optional()}),KN=M({at:le(),source:w(),text:w(),level:Ie(["info","progress","done","warning","error"]).optional(),tag:w().optional()});M({scriptId:St,profile:Di.optional()}),M({tasks:me(v2),runnable:ve(),problem:w().optional()}),M({scriptId:St,taskId:w().min(1).max(64),params:Ws(w(),Go([w(),le(),ve()])).optional(),profile:Di.optional()}),M({runId:w()}),M({}),M({scriptId:St.optional()}),M({items:me(y2)}),M({runId:w(),limit:le().int().min(1).max(2e3).optional()}),M({lines:me(KN)}),M({scriptId:St}),M({scriptId:St,name:w().trim().min(1).max(30),from:Va("kind",[M({kind:ht("copy"),profile:Di}),M({kind:ht("original")}),M({kind:ht("folder"),dir:w().trim().min(1).max(500)})])}),M({profile:Sp,files:me(w()),list:GN}),M({scriptId:St,profile:Di,name:w().trim().min(1).max(30).optional(),current:ht(!0).optional()}),M({scriptId:St,profile:Di}),M({scriptId:St,profile:Di.optional()}),M({importedAt:le().optional(),dir:w(),profile:Sp,files:me(M({file:w(),local:ve(),original:ve(),changed:ve()})),drift:me(w())}),M({scriptId:St,file:w().min(1),profile:Di.optional()}),M({file:w(),content:w(),truncated:ve()}),M({scriptId:St,profile:Di.optional()}),M({imported:me(w())}),M({scriptId:St,profile:Di.optional()}),M({runId:w()}),M({}),M({scriptId:St,taskId:w().min(1),param:w().min(1),name:w().trim().min(1).max(40),profile:Di.optional()}),M({value:w()}),M({scriptId:St}),M({scriptId:St,mode:Ie(["auto","platform","off"]).optional(),pcLaunch:Ie(["program","maaend"]).nullable().optional(),pcRegion:Ie(["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()}),M({scriptId:St}),M({exe:w().optional(),candidates:me(M({path:w(),source:w()}))});M({scriptId:w(),list:GN}),M({runId:w(),lines:me(KN)});const b2=1,lf=w().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"credential names use letters, digits and underscores"),YN=M({configured:ve(),source:w().optional(),writable:ve()}),_p="DEEPSEEK_API_KEY",k2=M({id:w(),version:le().int().positive()}),XN=M({id:w(),title:w().nullable(),updatedAt:le(),running:ve(),blank:ve(),live:ve(),cwd:w().optional(),parentId:w().optional(),origin:Ie(["subagent"]).optional(),role:w().optional(),requestedBy:w().optional(),home:w().optional()}),QN=M({id:w(),name:w(),description:w(),order:le()}),JN=M({id:w(),requestId:w().optional(),text:w(),images:le().int().optional(),placement:Ie(["next-turn","next-step","taken"])}),ew=M({contextWindow:le().int().positive(),usedTokens:le().int().nonnegative(),breakdown:M({systemTokens:le().int().nonnegative(),toolsTokens:le().int().nonnegative(),messageTokens:le().int().nonnegative()}).optional()}),j2=M({id:w(),createdAt:le(),cwd:w().optional(),parentId:w().optional(),agentPreset:w().optional()}),fr=M({provider:w(),model:w(),reasoningEffort:w().optional()});M({agents:Ws(w(),fr),subAgents:fr.nullable(),subAgentsOf:Ws(w(),fr)});const N2=M({from:w(),kind:Ie(["question","answer","update","done"]),text:w(),at:le()}),Ep=M({id:w(),messages:me(N2).optional(),chain:me(w()).optional(),parent:w().optional(),fromSession:w(),callId:w().optional(),by:w(),to:w(),toSession:w(),title:w(),task:w(),expecting:w().optional(),state:Ie(["running","waiting","done","failed"]),reply:w().optional(),startedAt:le(),endedAt:le().optional()}),w2=M({id:w(),agent:w(),sessionId:w(),title:w(),prompt:w(),rule:w(),repeats:ve(),next:le()});M({default:fr,groups:me(M({id:w(),name:w(),models:me(M({id:w(),name:w(),description:w().optional(),efforts:me(M({id:w(),name:w()})),defaultEffort:w().optional()}))})),failures:me(M({id:w(),name:w(),message:w()}))});const S2=M({lastUsed:fr.nullable(),next:fr.nullable()}),cf=Ie(["openai-completions","openai-responses","anthropic-messages"]),_2=w().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"use lowercase letters, digits and single hyphens, starting with a letter"),Cp=M({id:w().min(1),name:w().optional(),contextWindow:le().int().positive().optional(),maxTokens:le().int().positive().optional(),input:me(Ie(["text","image"])).optional(),efforts:me(w().min(1)).optional()}),E2=M({id:w(),displayName:w(),api:w().optional(),baseURL:w().optional(),models:me(Cp),apiKeyRef:w().optional(),credential:YN.optional(),declared:ve(),active:ve(),error:w().optional()}),C2=M({available:ve(),balances:me(M({currency:w(),total:w(),granted:w(),toppedUp:w()}))}),Ap=35e5,A2=M({mediaType:Ie(["image/png","image/jpeg","image/gif","image/webp"]),data:w().min(1).max(Ap).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix"),name:w().max(200).optional()}),$2=M({version:w(),title:w().optional(),publishedAt:w().optional(),url:w(),body:w()});M({});M({accepted:ht(!0)});M({protocolVersion:le().int(),client:M({name:w(),version:w()})}),M({protocolVersion:le().int(),server:M({name:w(),version:w(),dsh:w().optional()}),capabilities:me(k2)}),M({items:me(XN)}),M({cwd:w().optional(),focus:M({scripts:me(w()).optional(),games:me(w()).optional()}).optional(),role:w().optional()}),M({sessionId:w()}),M({sessionIds:me(w()).max(60)}),M({items:me(M({sessionId:w(),text:w().nullable()}))}),M({items:me(QN)}),M({agentId:w(),focus:M({scripts:me(w()).optional(),games:me(w()).optional()}).optional()}),M({sessionId:w()}),M({sessionId:w()}),M({items:me(Ep)}),M({sessionId:w()}),M({a:w(),b:w()}),M({items:me(Ep)}),M({id:w()}),M({agent:w().optional()}),M({items:me(w2)}),M({id:w()}),M({}),M({sessionId:w(),title:w().min(1)}),M({title:w()}),M({sessionId:w(),maxMessages:le().int().positive().optional()}),M({subscriptionId:w(),header:j2,cursor:le(),events:me(yp),hasMore:ve(),title:w().nullable(),live:RM.nullable(),queue:me(JN).optional(),context:ew.optional()}),M({subscriptionId:w()}),M({sessionId:w(),throughSeq:le(),beforeSeq:le(),maxMessages:le().int().positive().optional()}),M({events:me(yp),hasMore:ve()}),M({sessionId:w(),requestId:w(),text:w(),mode:Ie(["queue","steer"]),images:me(A2).max(4).optional()}).refine(e=>{var t;return e.text.trim()!==""||(((t=e.images)==null?void 0:t.length)??0)>0},"消息是空的"),M({sessionId:w()}),M({sessionId:w()}),M({compacted:ve(),message:w()}),M({sessionId:w(),itemId:w(),action:Ie(["steer","remove"])}),M({attachmentId:w(),mediaType:w(),bytes:le(),width:le(),height:le()}),M({mediaType:w(),data:w()}),M({path:w().min(1)}),M({mediaType:w(),data:w(),path:w()}),M({kind:Ie(["file","folder"]),title:w().max(200).optional(),defaultPath:w().max(1e3).optional(),filterName:w().max(60).optional(),extensions:me(w().regex(/^\w+$/)).max(20).optional()}),M({path:w().optional()}),M({sessionIds:me(w())}),M({sessionId:w()}),M({sessionIds:me(w())}),M({sessionId:w()}),M({sessionIds:me(w())}),M({agentId:w().optional(),sub:ve().optional(),model:fr.nullable()}),M({warning:w().optional()}),fr.extend({sessionId:w()}),M({selected:fr}),M({sessionId:w()}),M({approvalId:w(),decision:Ie(["allow-once","reject"])}),M({refs:me(lf).min(1).max(64)}),M({items:Ws(w(),YN)}),M({ref:lf,value:w().min(1).max(4096)}),M({ref:lf}),M({edition:Ie(["plugin","other"]),version:w().optional()}),M({current:w(),latest:M({version:w(),prerelease:ve(),notesUrl:w(),onNpm:ve().optional(),notes:me($2).optional()}).optional(),checkedAt:le()}),M({providers:me(E2),revision:le(),writable:ve(),protocols:me(cf),taken:me(w())}),M({provider:w().optional(),baseURL:gp({protocol:/^https?$/}).optional(),api:cf.optional(),apiKey:w().min(1).max(4096).optional()}),M({models:me(Cp)}),M({provider:w().min(1)}),M({balance:C2.nullable()}),M({id:_2,create:ve(),displayName:w().max(80).optional(),api:cf,baseURL:gp({protocol:/^https?$/}),models:me(Cp).min(1),apiKey:w().min(1).max(4096).optional(),expectedRevision:le().optional()}),M({revision:le(),apiKeyRef:w().optional()}),M({id:w().min(1),removeKey:ve().optional(),expectedRevision:le().optional()}),M({revision:le(),defaultReset:ve()});Va("kind",[M({kind:ht("upsert"),item:XN.partial().extend({id:w()})}),M({kind:ht("removed"),sessionId:w()})]);M({approvalId:w(),sessionId:w(),toolName:w(),callId:w().optional(),reason:w().optional(),displayReason:Ws(w(),w()).optional()});M({subscriptionId:w(),event:yp}),M({subscriptionId:w(),frame:CN}),M({subscriptionId:w(),reason:w()}),M({sessionId:w(),title:w().nullable()}),M({sessionId:w(),message:w()}),M({sessionId:w(),items:me(JN)}),M({sessionId:w(),context:ew.nullable()}),M({approvalId:w(),outcome:w()}),M({ref:w()}),M({sessionIds:me(w())}),M({items:me(QN)}),M({item:Ep}),M({}),M({}),S2.extend({sessionId:w()});const Ku={InternalError:-32603,NotInitialized:-32002};class Ml extends Error{constructor(s,i,r){super(i);dt(this,"code");dt(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 I2(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 Bg(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 tw=["把这次走通的做法保存成技能(用 skill_save),让下次同样的事可以直接照着做、少调用模型。要求:","- 只写最后成功的路径,不写失败的尝试和闲聊;","- 写清楚适用场景(用户会怎么说)、一步一步的操作(用到的工具、命令、路径、参数照实写,会变的写成「把 X 换成…」)、怎样算成功、注意事项和踩过的坑;","- 名字用简短的英文小写加短横线,description 一两句话说清楚做什么、什么时候用;","- 分到对应的游戏和脚本:只有用某个脚本时才用得上的(它的配置、报错、日志),scripts 填脚本 id;和游戏本身有关、换个脚本也用得上的(游戏里的操作、界面、活动、机制),games 填游戏 id(用 game_list 查);和哪个游戏都无关才当通用技能;","- 保存后告诉我技能名,以及以后我说什么时会用到它。"].join(`
116
+ `);function T2(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 Hg=[{name:"技能",aliases:["skill"],title:"把刚才走通的做法存成技能,下次少调用模型",expand:()=>tw},{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=>T2(e)},{name:"压缩",aliases:["compact"],title:"压缩这个对话:较早的部分换成摘要,agent 会忘掉其中的细节",expand:()=>"",local:"compact"}];function M2(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=Hg.find(o=>o.local!==void 0&&(o.name===t||o.aliases.includes(t))))==null?void 0:r.local}function R2(e,t){return`使用技能「${e}」:先用 skill 工具加载它,再按它的说明做${t===""?"。":`:${t}`}`}function O2(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=Hg.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
+ ${R2(u.name,o)}`}function P2(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 L2(e,t,s=!1){const i=/^\/(\S*)$/.exec(e);if(i===null)return[];const r=i[1].toLowerCase(),o=Hg.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 z2=new Set(["issues","pulls","wiki","actions","discussions","blob","commits","commit","compare","security","pulse","graphs","network","settings","projects","stargazers","forks","watchers","tags","branches"]);function D2(e){var b,k;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=j=>{try{return decodeURIComponent(j)}catch{return j}},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 f=h[1].replace(/\.git$/i,"");if(!/^[A-Za-z0-9_.-]+$/.test(f))return;const p=`${h[0]}/${f}`,[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 j=x.join("/").replace(/\.(zip|tar\.gz)$/i,""),N=(b=/^refs\/tags\/(.+)$/.exec(j))==null?void 0:b[1];if(N!==void 0)return{repo:p,tag:r(N)};const C=(k=/^refs\/heads\/(.+)$/.exec(j))==null?void 0:k[1];return C!==void 0?{repo:p,branch:r(C)}:{repo:p,tag:r(j)}}return g===void 0||z2.has(g)?{repo:p}:{repo:p}}const Jy=1;var dr,As,Gr,Ma,Xd,ki,Uo,Bo,Tc,yn,$p,Ip,Tp,nw,sw,Mp,Rp;class F2{constructor(t){Ht(this,yn);dt(this,"status",new Ui({state:"idle",attempt:0}));dt(this,"server",new Ui(null));Ht(this,dr);Ht(this,As,null);Ht(this,Gr,!1);Ht(this,Ma,0);Ht(this,Xd,1);Ht(this,ki,new Map);Ht(this,Uo,new Map);Ht(this,Bo,new Set);Ht(this,Tc);Kt(this,dr,t)}get generation(){return Le(this,Ma)}get ready(){return Le(this,Gr)}start(){this.status.get().state!=="idle"&&this.status.get().state!=="stopped"||yt(this,yn,Tp).call(this)}stop(){clearTimeout(Le(this,Tc)),this.status.set({state:"stopped",attempt:0});const t=Le(this,As);Kt(this,As,null),yt(this,yn,Mp).call(this,"connection stopped"),t==null||t.close(1e3,"client stopped")}on(t,s){let i=Le(this,Uo).get(t);return i===void 0&&Le(this,Uo).set(t,i=new Set),i.add(s),()=>{i.delete(s)}}onReady(t){return Le(this,Bo).add(t),Le(this,Gr)&&queueMicrotask(()=>t(Le(this,Ma))),()=>{Le(this,Bo).delete(t)}}call(t,s,i){return!Le(this,Gr)&&t!=="initialize"?Promise.reject(new Ml(Ku.NotInitialized,"not connected to the gateway")):yt(this,yn,$p).call(this,t,s,i)}}dr=new WeakMap,As=new WeakMap,Gr=new WeakMap,Ma=new WeakMap,Xd=new WeakMap,ki=new WeakMap,Uo=new WeakMap,Bo=new WeakMap,Tc=new WeakMap,yn=new WeakSet,$p=function(t,s,i){const r=Le(this,As);if(r===null||r.readyState!==Jy)return Promise.reject(new Ml(Ku.NotInitialized,"not connected to the gateway"));if((i==null?void 0:i.aborted)===!0)return Promise.reject(i.reason??new Error("aborted"));const o=ty(this,Xd)._++;return new Promise((l,u)=>{const d=Le(this,dr).callTimeoutMs??6e4,h=d>0?setTimeout(()=>{var g;(g=Le(this,ki).get(o))==null||g.reject(new Ml(Ku.InternalError,`${t} timed out`))},d):void 0,f=()=>{var g;Le(this,ki).has(o)&&(yt(this,yn,Ip).call(this,{jsonrpc:"2.0",method:"$/cancelRequest",params:{id:o}}),(g=Le(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",f,{once:!0});const p=()=>{clearTimeout(h),i==null||i.removeEventListener("abort",f),Le(this,ki).delete(o)};Le(this,ki).set(o,{resolve:g=>{p(),l(g)},reject:g=>{p(),u(g)},cleanup:p}),yt(this,yn,Ip).call(this,{jsonrpc:"2.0",id:o,method:t,params:s})})},Ip=function(t){var s;((s=Le(this,As))==null?void 0:s.readyState)===Jy&&Le(this,As).send(JSON.stringify(t))},Tp=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=(Le(this,dr).createSocket??(i=>new WebSocket(i)))(Le(this,dr).url)}catch(i){yt(this,yn,Rp).call(this,i instanceof Error?i.message:String(i));return}Kt(this,As,s),s.addEventListener("open",()=>{Le(this,As)===s&&yt(this,yn,nw).call(this,s)}),s.addEventListener("message",i=>{Le(this,As)===s&&yt(this,yn,sw).call(this,String(i.data))}),s.addEventListener("close",i=>{if(Le(this,As)!==s)return;Kt(this,As,null),yt(this,yn,Mp).call(this,"connection lost");const r=typeof i.reason=="string"&&i.reason!==""?i.reason:`closed (${i.code??"?"})`;yt(this,yn,Rp).call(this,r)}),s.addEventListener("error",()=>{})},nw=async function(t){try{const s=await yt(this,yn,$p).call(this,"initialize",{protocolVersion:b2,client:Le(this,dr).clientInfo});if(Le(this,As)!==t)return;Kt(this,Gr,!0),Kt(this,Ma,Le(this,Ma)+1),this.server.set(s),this.status.set({state:"open",attempt:0});for(const i of[...Le(this,Bo)])i(Le(this,Ma))}catch(s){t.close(4e3,s instanceof Error?s.message:"initialize failed")}},sw=function(t){let s;try{s=JSON.parse(t)}catch{return}const i=I2(s);if(i==="response"){const r=Le(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[...Le(this,Uo).get(s.method)??[]])try{r(s.params)}catch(o){console.error(`notification handler for ${s.method} failed`,o)}},Mp=function(t){Kt(this,Gr,!1);for(const s of[...Le(this,ki).values()])s.reject(new Ml(Ku.InternalError,t));Le(this,ki).clear()},Rp=function(t){if(this.status.get().state==="stopped")return;const s=this.status.get().attempt+1,{initial:i,max:r}=Le(this,dr).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,Tc,setTimeout(()=>yt(this,yn,Tp).call(this),o))};const U2={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,Mc,Ho,Zo,hr,Kr,Rc,Oc,Yt,Op,pd,is;class B2{constructor(t,s,i){Ht(this,Yt);dt(this,"id");dt(this,"state",new Ui(U2));Ht(this,$s);Ht(this,Mc);Ht(this,Ho,null);Ht(this,Zo,-1);Ht(this,hr,!1);Ht(this,Kr,null);Ht(this,Rc);Ht(this,Oc);this.id=t,Kt(this,$s,s),Kt(this,Mc,i),Kt(this,Rc,s.onReady(r=>{r!==Le(this,Zo)&&yt(this,Yt,Op).call(this,r)}))}get subscriptionId(){return Le(this,Ho)}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}};yt(this,Yt,is).call(this,l=>({...l,pending:[...l.pending,o]}));try{await Le(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 yt(this,Yt,is).call(this,d=>({...d,pending:d.pending.map(h=>h.requestId===r?{...h,failed:u}:h)})),l}}dismissPending(t){yt(this,Yt,is).call(this,s=>({...s,pending:s.pending.filter(i=>i.requestId!==t)}))}async updateQueue(t,s){await Le(this,$s).call("session/queue/update",{sessionId:this.id,itemId:t,action:s})}async cancel(){await Le(this,$s).call("session/cancel",{sessionId:this.id})}async compact(){return Le(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)){yt(this,Yt,is).call(this,i=>({...i,loadingOlder:!0}));try{const i=await Le(this,$s).call("session/history",{sessionId:this.id,throughSeq:t.cursor,beforeSeq:s.seq});yt(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){yt(this,Yt,is).call(this,r=>({...r,loadingOlder:!1,error:i instanceof Error?i.message:String(i)}))}}}close(){if(Le(this,hr))return;Kt(this,hr,!0),clearTimeout(Le(this,Oc)),Le(this,Rc).call(this);const t=Le(this,Ho);yt(this,Yt,pd).call(this,null),t!==null&&Le(this,$s).ready&&Le(this,$s).call("session/close",{subscriptionId:t}).catch(()=>{}),yt(this,Yt,is).call(this,s=>({...s,status:"closed"}))}receiveEvent(t){yt(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:uf(u,o)}})}receiveLive(t){yt(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:uf(s.events,null)}}})}receiveClosed(t){yt(this,Yt,pd).call(this,null),!Le(this,hr)&&(yt(this,Yt,is).call(this,s=>({...s,status:"error",error:`stream ended: ${t}`})),Kt(this,Oc,setTimeout(()=>{!Le(this,hr)&&Le(this,$s).ready&&yt(this,Yt,Op).call(this,Le(this,Zo))},1e3)))}receiveQueue(t){yt(this,Yt,is).call(this,s=>({...s,queue:t,pending:eb(s.pending,t)}))}receiveContext(t){yt(this,Yt,is).call(this,s=>({...s,context:t}))}receiveTitle(t){yt(this,Yt,is).call(this,s=>s.title===t?s:{...s,title:t})}}$s=new WeakMap,Mc=new WeakMap,Ho=new WeakMap,Zo=new WeakMap,hr=new WeakMap,Kr=new WeakMap,Rc=new WeakMap,Oc=new WeakMap,Yt=new WeakSet,Op=async function(t){if(!Le(this,hr))return Le(this,Kr)!==null?Le(this,Kr):(Kt(this,Zo,t),Kt(this,Kr,(async()=>{try{const s=await Le(this,$s).call("session/open",{sessionId:this.id});if(Le(this,hr)){Le(this,$s).call("session/close",{subscriptionId:s.subscriptionId}).catch(()=>{});return}yt(this,Yt,pd).call(this,s.subscriptionId);const i=s.live===null?null:{...s.live,deltas:[...s.live.deltas]};yt(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:eb(r.pending.filter(l=>!o.has(l.requestId)),s.queue??[]),queue:s.queue??[],context:s.context??r.context,running:uf(s.events,i),loadingOlder:!1,error:null}})}catch(s){yt(this,Yt,is).call(this,i=>({...i,status:"error",error:s instanceof Error?s.message:String(s)}))}finally{Kt(this,Kr,null)}})()),Le(this,Kr))},pd=function(t){Kt(this,Ho,t),Le(this,Mc).bindSubscription(this,t)},is=function(t){this.state.set(s=>{const i=t(s);return i===s?s:{...i,version:s.version+1}})};function eb(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 uf(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 tb=(e,t)=>t.updatedAt-e.updatedAt;var Us,Bi,Wo,gr,gd,Pp;class H2{constructor(t){Ht(this,gr);dt(this,"connection");dt(this,"sessions",new Ui({items:[],loaded:!1,error:null}));dt(this,"approvals",new Ui([]));dt(this,"questions",new Ui([]));dt(this,"capabilities",new Ui(new Set));dt(this,"credentialRevision",new Ui(0));dt(this,"providersRevision",new Ui(0));dt(this,"sessionModels",new Ui(new Map));Ht(this,Us,new Map);Ht(this,Bi,new Map);Ht(this,Wo,!1);this.connection=new F2({...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)})),yt(this,gr,Pp).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)){yt(this,gr,Pp).call(this);return}this.sessions.set(o=>({...o,items:o.items.map(l=>l.id===i.item.id?{...l,...Z2(i.item)}:l).sort(tb)}))}),s.on("session/title",({sessionId:i,title:r})=>{var o;(o=Le(this,Us).get(i))==null||o.handle.receiveTitle(r)}),s.on("session/queue",({sessionId:i,items:r})=>{var o;(o=Le(this,Us).get(i))==null||o.handle.receiveQueue(r)}),s.on("session/context",({sessionId:i,context:r})=>{var o;(o=Le(this,Us).get(i))==null||o.handle.receiveContext(r)}),s.on("session/event",({subscriptionId:i,event:r})=>{var o;return(o=Le(this,Bi).get(i))==null?void 0:o.receiveEvent(r)}),s.on("session/live",({subscriptionId:i,frame:r})=>{var o;return(o=Le(this,Bi).get(i))==null?void 0:o.receiveLive(r)}),s.on("session/closed",({subscriptionId:i,reason:r})=>{const o=Le(this,Bi).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})=>yt(this,gr,gd).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 Le(this,Us).values())t.close();Le(this,Us).clear(),Le(this,Bi).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(tb),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=Le(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 yt(this,gr,gd).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 yt(this,gr,gd).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=Le(this,Us).get(t);if(s!==void 0)return s.refs+=1,s.handle;const i=new B2(t,this.connection,{bindSubscription:(r,o)=>{for(const[l,u]of Le(this,Bi))u===r&&Le(this,Bi).delete(l);o!==null&&Le(this,Bi).set(o,r)}});return Le(this,Us).set(t,{handle:i,refs:1}),i}release(t){const s=Le(this,Us).get(t.id);s===void 0||s.handle!==t||(s.refs-=1,!(s.refs>0)&&(Le(this,Us).delete(t.id),t.close()))}}Us=new WeakMap,Bi=new WeakMap,Wo=new WeakMap,gr=new WeakSet,gd=function(t,s){this.sessionModels.set(i=>new Map(i).set(t,s))},Pp=function(){Le(this,Wo)||(Kt(this,Wo,!0),setTimeout(()=>{Kt(this,Wo,!1),this.refreshSessions()},150))};function Z2(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const df=(e,t)=>e.map(s=>s.type===t?s.text:"").join(""),hf=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}}]:[]),W2=e=>e.map(t=>t.type==="text"?t.text:t.type==="image"?"[image]":t.type==="file"?`[file ${t.name??""}]`:"").join(""),V2="run_code",q2="ptc-mode";function nh(e,t,s=[],i=[]){var p,g;const r=[],o=new Map;let l;const u=new Set,d=new Map,h=new Map;for(const x of e)switch(x.type){case"user/message":{const b=df(x.content,"text");if(x.origin.human)r.push({kind:"user",id:`u:${x.seq}`,text:b,time:x.time,images:x.content.filter(k=>k.type==="image").length,imageRefs:hf(x.content),files:x.content.filter(k=>k.type==="file").length});else if(Gy(b)!==void 0)r.push({kind:"context",id:`c:${x.seq}`,title:"定时提醒",summary:n2(Gy(b)),text:b,startsTurn:!0});else if(x.replacesHistory===!0)r.push({kind:"context",id:`c:${x.seq}`,title:"较早的对话已压缩成摘要(agent 只记得摘要里的内容)",summary:"",text:b});else if(x.origin.summary!==void 0)r.push({kind:"context",id:`c:${x.seq}`,title:x.origin.kind,summary:x.origin.summary,text:b});else if(x.origin.kind===q2&&l!==void 0){const k=hf(x.content).filter(j=>{var N;return((N=l.images)==null?void 0:N.some(C=>C.attachmentId===j.attachmentId))!==!0});k.length>0&&(l.images=[...l.images??[],...k])}break}case"assistant/message":{u.add(`${x.turn}:${x.step}`);const b=df(x.content,"text"),k=df(x.content,"reasoning");(b.trim()!==""||k.trim()!=="")&&r.push({kind:"assistant",id:`a:${x.seq}`,text:b,reasoning:k,live:!1,interrupted:x.interrupted===!0,time:x.time,...x.model===void 0?{}:{model:x.model}});break}case"tool/call":{const b={kind:"tool",id:`t:${x.callId}`,callId:x.callId,name:x.name,arguments:x.arguments,status:"running",time:x.time},k=d.get(x.callId);k!==void 0&&(b.approval=k),o.set(x.callId,b),r.push(b),x.name===V2&&(l=b);break}case"tool/result":{const b=o.get(x.callId);if(b===void 0)break;b.result=W2(x.content);const k=hf(x.content);k.length>0&&(b.images=k),b.status=x.isError?"error":"ok",x.error!==void 0&&(b.error=x.error.message);break}case"approval/asked":if(x.callId!==void 0){h.set(x.approvalId,x.callId),d.set(x.callId,"asked");const b=o.get(x.callId);b!==void 0&&(b.approval="asked")}break;case"approval/decided":{const b=h.get(x.approvalId);if(b===void 0)break;d.set(b,x.outcome);const k=o.get(b);k!==void 0&&(k.approval=x.outcome);break}case"turn/end":for(const b of o.values())b.status==="running"&&(b.status="interrupted");x.reason.kind==="error"?r.push({kind:"notice",id:`e:${x.seq}`,tone:"error",text:x.reason.message??"这一轮出错了"}):x.reason.kind==="aborted"?r.push({kind:"notice",id:`e:${x.seq}`,tone:"info",text:"已停止"}):x.reason.kind==="max-tokens"&&r.push({kind:"notice",id:`e:${x.seq}`,tone:"info",text:"回复太长,达到了输出上限"});break;case"compaction/end":r.push({kind:"notice",id:`k:${x.seq}`,tone:x.error===void 0?"info":"error",text:x.error===void 0?"对话太长,较早的内容已压缩成摘要":`压缩对话历史失败:${x.error}`});break}if(t!==null&&!u.has(`${t.turn}:${t.step}`)){let x="",b="";for(const k of t.deltas)k.kind==="text"?x+=k.text:k.kind==="reasoning"&&(b+=k.text);r.push({kind:"assistant",id:`live:${t.attemptId}`,text:x,reasoning:b,live:!0,interrupted:!1,time:((p=t.deltas[0])==null?void 0:p.time)??Date.now()})}const f=new Set(e.flatMap(x=>x.type==="user/message"?[x.messageId]:[]));for(const x of i)x.placement!=="taken"||f.has(x.id)||r.push({kind:"user",id:`q:${x.id}`,text:x.text,images:x.images??0,imageRefs:[],files:0,time:((g=e.at(-1))==null?void 0:g.time)??Date.now(),pending:{requestId:x.requestId??x.id}});for(const x of s)r.push({kind:"user",id:`p:${x.requestId}`,text:x.text,images:x.images??0,imageRefs:[],files:0,time:x.sentAt,pending:{requestId:x.requestId,...x.failed===void 0?{}:{failed:x.failed}}});return r}var v=Pc();const G2=_g(v);var qa=Gj();function K2(e,t){return e.filter(s=>{var i;return((i=s.available)==null?void 0:i.call(s,t))??!0})}const Yr=new Map,Ad=new Set;function Bn(e){if(Yr.has(e.id))throw new Error(`UI plugin "${e.id}" is already registered`);Yr.set(e.id,e);for(const t of Ad)t();return()=>{if(Yr.get(e.id)===e){Yr.delete(e.id);for(const t of Ad)t()}}}function iw(e){return Ad.add(e),()=>{Ad.delete(e)}}function Y2(e){return[...Yr.values()].filter(t=>t.requires.every(s=>e.has(s))).flatMap(t=>t.sessionViews??[]).sort((t,s)=>t.order-s.order)}function X2(e){return[...Yr.values()].filter(t=>t.requires.every(s=>e.has(s))).flatMap(t=>t.settingsPages??[]).sort((t,s)=>t.order-s.order)}function Q2(e){return[...Yr.values()].filter(t=>t.requires.every(s=>e.has(s))).flatMap(t=>t.pages??[]).sort((t,s)=>t.order-s.order)}function J2(e){return[...Yr.values()].map(t=>({plugin:t,missing:t.requires.filter(s=>!e.has(s))}))}function ke(e){return v.useSyncExternalStore(e.subscribe,e.get,e.get)}function sh(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 eO(e){const t=ke(e.capabilities),s=Zg();return v.useMemo(()=>Y2(t),[t,s])}function tO(e){const t=ke(e.capabilities),s=Zg();return v.useMemo(()=>X2(t),[t,s])}function nO(e){const t=ke(e.capabilities),s=Zg();return v.useMemo(()=>Q2(t),[t,s])}function Zg(){const[e,t]=v.useState(0);return v.useEffect(()=>iw(()=>t(s=>s+1)),[]),e}function rw(e,t){const s=ke(e.credentialRevision),i=ke(e.connection.status),r=ke(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(f=>({...f,error:h instanceof Error?h.message:String(h)}))}),()=>{d=!1}},[e,o,s,i.state,r]),l}function Ga(e){const t=ke(e.credentialRevision),s=ke(e.providersRevision),i=ke(e.connection.status),r=ke(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 mn(e){const[t,s]=v.useState(()=>Date.now());return v.useEffect(()=>{const i=setInterval(()=>s(Date.now()),e);return()=>clearInterval(i)},[e]),t}function sO(e){const t=ke(e.connection.status),s=ke(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 iO={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",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:""},nb={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 ee({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:[nb[e]!==void 0&&n.jsx("path",{className:"ui-icon-fill",d:nb[e],fill:"currentColor",stroke:"none"}),n.jsx("path",{d:iO[e]})]})}function rO(){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 Wg({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 sb="adg.otherCopies.seen";function aO(e){const t=ke(e.connection.status),i=ke(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 oO({client:e}){const t=aO(e),s=JSON.stringify(t.map(l=>[l.pid,l.warnings])),[i,r]=v.useState(()=>{try{return localStorage.getItem(sb)}catch{return null}});if(t.length===0||i===s)return null;const o=()=>{try{localStorage.setItem(sb,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(ee,{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 lO={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function cO(e){const t=ke(e.connection.status),i=ke(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 uO({client:e,pending:t}){const s=mn(1e3),[i,r]=v.useState(!1),[o,l]=v.useState(null),u=lO[t.action],d=async()=>{r(!0),l(null);try{await e.connection.call("schedule/power/cancel",{})}catch(f){l(f instanceof Error?f.message:String(f))}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(ee,{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 ih(e){const t=ke(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:Ce(d)}))}),()=>{u=!1}},[e,t.state,r]),{...s,refresh:l}}function aw(e){const t=ke(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 Ce(e){return e instanceof Error?e.message:String(e)}function Aa(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 bc={queued:"排队中",resolving:"读取发布信息",downloading:"下载中",verifying:"校验中",extracting:"解压中",checking:"检查环境",running:"处理中",done:"完成",failed:"失败",cancelled:"已取消"},ow={"maafw-pi":"MaaFramework",cli:"命令行","gui-config":"配置驱动 GUI","generic-process":"通用程序",visual:"界面操作"};function _a(e){return e!==void 0&&e.endedAt===void 0}function dO(e){const t=ke(e.connection.status),i=ke(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(f=>{var p;return((p=f.installed)==null?void 0:p.update)===!0&&f.incompatible===void 0}))}).catch(()=>{}),()=>{d=!1}},[e,t.state,i,l]),r}function ib(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 lw="adg.scriptUpdate.later",rb=9e3;function ab(){try{return JSON.parse(localStorage.getItem(lw)??"{}")}catch{return{}}}function hO({client:e}){return ke(e.capabilities).has("scripts")?n.jsx(pO,{client:e}):null}function mO({client:e}){return ke(e.capabilities).has("scripts")?n.jsx(fO,{client:e}):null}function fO({client:e}){const{data:t}=ih(e),s=aw(e),[i,r]=v.useState(null),[o,l]=v.useState(ab),[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 f=(g,x)=>{const b={...ab(),[g]:x};try{localStorage.setItem(lw,JSON.stringify(b))}catch{}l(b)},p=g=>{d(x=>{const b=new Map(x);return b.delete(g),b}),e.connection.call("scripts/update",{id:g}).catch(x=>d(b=>new Map(b).set(g,Ce(x))))};return h.map(g=>{var N;const x=s.get(g.id),b=_a(x),k=g.source.kind==="local"?(N=g.localVersion)==null?void 0:N.version:g.current,j=u.get(g.id);return n.jsxs("div",{className:"reminder script-update-note",role:"status",children:[n.jsx(ee,{name:"download"}),n.jsxs("span",{children:[n.jsx("strong",{children:g.name})," 有新版本 ",g.update.latest,"(当前 ",k??"认不出的版本","),要现在更新吗?",j!==void 0&&n.jsxs("span",{className:"error",children:[" 没有更新成功:",j]})]}),b?n.jsxs("span",{className:"script-update-progress muted",children:[n.jsx("span",{className:"spinner"}),x.message??bc[x.phase],"…"]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"ghost small-button",title:"有更新的版本时再问",onClick:()=>f(g.id,g.update.latest),children:"以后再说"}),n.jsx("button",{type:"button",className:"primary small-button",onClick:()=>p(g.id),children:"更新"})]})]},g.id)})}function pO({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(gO,{done:o,onClose:()=>r(o.job.id)},o.job.id))}function gO({done:e,onClose:t}){const[s,i]=v.useState(!1);v.useEffect(()=>{if(s)return;const u=setTimeout(t,rb);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(ee,{name:"close"})})]}),!s&&n.jsx("span",{className:"done-timer",style:{animationDuration:`${rb}ms`}})]})}function li(){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 ob(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 xO(e){if(Array.isArray(e))return e}function vO(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(f){h=!0,r=f}finally{try{if(!d&&s.return!=null&&(l=s.return(),Object(l)!==l))return}finally{if(h)throw r}}return u}}function yO(){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 bO(e,t){return xO(e)||vO(e,t)||kO(e,t)||yO()}function kO(e,t){if(e){if(typeof e=="string")return ob(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)?ob(e,t):void 0}}const cw=Object.entries,lb=Object.setPrototypeOf,jO=Object.isFrozen,uw=Object.getPrototypeOf,dw=Object.getOwnPropertyDescriptor;let Un=Object.freeze,Gn=Object.seal,Eo=Object.create,hw=typeof Reflect<"u"&&Reflect,Lp=hw.apply,zp=hw.construct;Un||(Un=function(t){return t});Gn||(Gn=function(t){return t});Lp||(Lp=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)});zp||(zp=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 lr=en(Array.prototype.forEach),NO=en(Array.prototype.lastIndexOf),cb=en(Array.prototype.pop),Rl=en(Array.prototype.push),wO=en(Array.prototype.slice),SO=en(Array.prototype.splice),Ro=Array.isArray,mf=mw(Set),ff=en(Set.prototype.add),Ol=en(Set.prototype.has),Na=en(String.prototype.toLowerCase),pf=en(String.prototype.toString),ub=en(String.prototype.match),Pl=en(String.prototype.replace),db=en(String.prototype.indexOf),_O=en(String.prototype.trim),EO=en(Number.prototype.toString),CO=en(Boolean.prototype.toString),hb=typeof BigInt>"u"?null:en(BigInt.prototype.toString),mb=typeof Symbol>"u"?null:en(Symbol.prototype.toString),Is=en(Object.prototype.hasOwnProperty),Ll=en(Object.prototype.toString),qn=en(RegExp.prototype.test),cr=mw(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 Lp(e,t,i)}}function mw(e){return function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return zp(e,s)}}function Ct(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Na;if(lb&&lb(e,null),!Ro(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){const o=s(r);o!==r&&(jO(t)||(t[i]=o),r=o)}e[r]=!0}return e}function AO(e){for(let t=0;t<e.length;t++)Is(e,t)||(e[t]=null);return e}function Fs(e){const t=Eo(null);for(const i of cw(e)){var s=bO(i,2);const r=s[0],o=s[1];Is(e,r)&&(Ro(o)?t[r]=AO(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=Fs(o):t[r]=o)}return t}function $O(e){switch(typeof e){case"string":return e;case"number":return EO(e);case"boolean":return CO(e);case"bigint":return hb?hb(e):"0";case"symbol":return mb?mb(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=dw(e,t);if(i){if(i.get)return en(i.get);if(typeof i.value=="function")return en(i.value)}e=uw(e)}function s(){return null}return s}function IO(e,t){for(;e!==null;){const s=dw(e,t);if(s)return s.get?en(s.get):null;e=uw(e)}return null}function TO(e){try{return qn(e,""),!0}catch{return!1}}const fb=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"]),gf=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"]),xf=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"]),MO=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"]),vf=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"]),RO=Un(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),pb=Un(["#text"]),gb=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"]),yf=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"]),xb=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"]),Yu=Un(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),OO=Gn(/{{[\w\W]*|^[\w\W]*}}/g),PO=Gn(/<%[\w\W]*|^[\w\W]*%>/g),LO=Gn(/\${[\w\W]*/g),zO=Gn(/^data-[\-\w.\u00B7-\uFFFF]+$/),DO=Gn(/^aria-[\-\w]+$/),vb=Gn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),FO=Gn(/^(?:\w+script|data):/i),UO=Gn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),BO=Gn(/^html$/i),HO=Gn(/^[a-z][.\w]*(-[.\w]+)+$/i),bf=Gn(/<[/\w!]/g),yb=Gn(/<[/\w]/g),ZO=Gn(/<\/no(script|embed|frames)/i),bb=Gn(/\/>/i),Nn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},WO=Un(Ct({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),VO=function(){return typeof window>"u"?null:window},qO=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}},kb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Fr=function(t,s,i,r){return Is(t,s)&&Ro(t[s])?Ct(r.base?Fs(r.base):{},t[s],r.transform):i},kf=function(t,s,i){const r=Is(t,s)?t[s]:void 0;return r&&typeof r=="object"?Fs(r):i()};function fw(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:VO();const t=Se=>fw(Se);if(t.version="3.4.17",t.removed=[],!e||!e.document||e.document.nodeType!==Nn.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,f=e.trustedTypes,p=u.prototype,g=ri(p,"cloneNode"),x=ri(p,"remove"),b=ri(p,"removeAttributeNode"),k=ri(p,"nextSibling"),j=ri(p,"childNodes"),N=ri(p,"parentNode"),C=ri(p,"shadowRoot"),S=ri(p,"attributes"),_=l&&l.prototype?ri(l.prototype,"nodeType"):null,z=l&&l.prototype?ri(l.prototype,"nodeName"):null,P=l&&l.prototype?ri(l.prototype,"ownerDocument"):null,H=function(Y){return _?_(Y):Y.nodeType},B=function(Y){return z?z(Y):Y.nodeName},O=IO(p,"namespaceURI"),T=function(Y){return O?O(Y):Y.namespaceURI};if(typeof o=="function"){const Se=s.createElement("template");Se.content&&Se.content.ownerDocument&&(s=Se.content.ownerDocument)}let D,U="",A,I=!1,R=0;const L=function(){if(R>0)throw cr('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.')},K=function(Y){L(),R++;try{return D.createHTML(Y)}finally{R--}},F=function(Y){L(),R++;try{return D.createScriptURL(Y)}finally{R--}},q=function(){return I||(A=qO(f,r),I=!0),A},V=s,Z=V.implementation,Q=V.createNodeIterator,G=V.createDocumentFragment,ne=V.getElementsByTagName,te=i.importNode;let re=kb();t.isSupported=typeof cw=="function"&&typeof N=="function"&&Z&&Z.createHTMLDocument!==void 0;const X=OO,se=PO,ae=LO,_e=zO,ze=DO,Te=FO,fe=UO,ye=HO;let Fe=vb,Re=null;const Qe=Ct({},[...fb,...gf,...xf,...vf,...pb]);let Ke=null;const _t=Ct({},[...gb,...yf,...xb,...Yu]);let xt=Object.seal(Eo(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}})),Mt=null,En=null;const rt=Object.seal(Eo(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,fn=!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,ce=null,J={},he=null;const we=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 Ue=null;const ct=Ct({},["audio","video","img","source","image","track"]);let jt=null;const Be=Ct({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),De="http://www.w3.org/1998/Math/MathML",Ye="http://www.w3.org/2000/svg",vt="http://www.w3.org/1999/xhtml";let wt=vt,Xn=!1,xs=null;const ui=Ct({},[De,Ye,vt],pf),br=Un(["mi","mo","mn","ms","mtext"]);let di=Ct({},br);const kr=Un(["annotation-xml"]);let Qn=Ct({},kr);const qi=Ct({},["title","style","font","a","script"]);let vs=null;const Ti=["application/xhtml+xml","text/html"],jr="text/html";let zt=null,Os=null;const os=s.createElement("form"),Gi=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=Ti.indexOf(Y.PARSER_MEDIA_TYPE)===-1?jr:Y.PARSER_MEDIA_TYPE,zt=vs==="application/xhtml+xml"?pf:Na,Re=Fr(Y,"ALLOWED_TAGS",Qe,{transform:zt}),Ke=Fr(Y,"ALLOWED_ATTR",_t,{transform:zt}),xs=Fr(Y,"ALLOWED_NAMESPACES",ui,{transform:pf}),jt=Fr(Y,"ADD_URI_SAFE_ATTR",Be,{transform:zt,base:Be}),Ue=Fr(Y,"ADD_DATA_URI_TAGS",ct,{transform:zt,base:ct}),he=Fr(Y,"FORBID_CONTENTS",we,{transform:zt}),Mt=Fr(Y,"FORBID_TAGS",Fs({}),{transform:zt}),En=Fr(Y,"FORBID_ATTR",Fs({}),{transform:zt}),J=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,fn=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,Fe=TO(Y.ALLOWED_URI_REGEXP)?Y.ALLOWED_URI_REGEXP:vb,wt=typeof Y.NAMESPACE=="string"?Y.NAMESPACE:vt,di=kf(Y,"MATHML_TEXT_INTEGRATION_POINTS",()=>Ct({},br)),Qn=kf(Y,"HTML_INTEGRATION_POINTS",()=>Ct({},kr));const ue=kf(Y,"CUSTOM_ELEMENT_HANDLING",()=>Eo(null));if(xt=Eo(null),Is(ue,"tagNameCheck")&&Gi(ue.tagNameCheck)&&(xt.tagNameCheck=ue.tagNameCheck),Is(ue,"attributeNameCheck")&&Gi(ue.attributeNameCheck)&&(xt.attributeNameCheck=ue.attributeNameCheck),Is(ue,"allowCustomizedBuiltInElements")&&typeof ue.allowCustomizedBuiltInElements=="boolean"&&(xt.allowCustomizedBuiltInElements=ue.allowCustomizedBuiltInElements),Gn(xt),Ut&&(rn=!1),Cn&&(gs=!0),J&&(Re=Ct({},pb),Ke=Eo(null),J.html===!0&&(Ct(Re,fb),Ct(Ke,gb)),J.svg===!0&&(Ct(Re,gf),Ct(Ke,yf),Ct(Ke,Yu)),J.svgFilters===!0&&(Ct(Re,xf),Ct(Ke,yf),Ct(Ke,Yu)),J.mathMl===!0&&(Ct(Re,vf),Ct(Ke,xb),Ct(Ke,Yu))),rt.tagCheck=null,rt.attributeCheck=null,Is(Y,"ADD_TAGS")&&(typeof Y.ADD_TAGS=="function"?rt.tagCheck=Y.ADD_TAGS:Ro(Y.ADD_TAGS)&&(Re===Qe&&(Re=Fs(Re)),Ct(Re,Y.ADD_TAGS,zt))),Is(Y,"ADD_ATTR")&&(typeof Y.ADD_ATTR=="function"?rt.attributeCheck=Y.ADD_ATTR:Ro(Y.ADD_ATTR)&&(Ke===_t&&(Ke=Fs(Ke)),Ct(Ke,Y.ADD_ATTR,zt))),Is(Y,"ADD_FORBID_CONTENTS")&&Ro(Y.ADD_FORBID_CONTENTS)&&(he===we&&(he=Fs(he)),Ct(he,Y.ADD_FORBID_CONTENTS,zt)),Yn&&(Re["#text"]=!0),fn&&Ct(Re,["html","head","body"]),Re.table&&(Ct(Re,["tbody"]),delete Mt.tbody),Y.TRUSTED_TYPES_POLICY){if(typeof Y.TRUSTED_TYPES_POLICY.createHTML!="function")throw cr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof Y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const je=D;D=Y.TRUSTED_TYPES_POLICY;try{U=K("")}catch(Ne){throw D=je,Ne}}else Y.TRUSTED_TYPES_POLICY===null?(D=void 0,U=""):(D===void 0&&(D=q()),D&&typeof U=="string"&&(U=K("")));Un&&Un(Y),Os=Y},Dt=Ct({},[...gf,...xf,...MO]),Nr=Ct({},[...vf,...RO]),Ki=function(Y,ue,je){return ue.namespaceURI===vt?Y==="svg":ue.namespaceURI===De?Y==="svg"&&(je==="annotation-xml"||di[je]):!!Dt[Y]},mi=function(Y,ue,je){return ue.namespaceURI===vt?Y==="math":ue.namespaceURI===Ye?Y==="math"&&Qn[je]:!!Nr[Y]},Mi=function(Y,ue,je){return ue.namespaceURI===Ye&&!Qn[je]||ue.namespaceURI===De&&!di[je]?!1:!Nr[Y]&&(qi[Y]||!Dt[Y])},Me=function(Y){const ue=T(Y),je=Na(B(Y)),Ne=N(Y);let Ge,nt;return Ne&&H(Ne)===Nn.element?(Ge={namespaceURI:T(Ne)},nt=Na(B(Ne))):(Ge={namespaceURI:wt},nt="template"),xs[ue]?ue===Ye?Ki(je,Ge,nt):ue===De?mi(je,Ge,nt):ue===vt?Mi(je,Ge,nt):!!(vs==="application/xhtml+xml"&&xs[ue]):!1},We=function(Y){Rl(t.removed,{element:Y});try{N(Y).removeChild(Y)}catch{if(x(Y),!N(Y))throw cr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ut=function(Y,ue,je){try{b(Y,ue)}catch{try{Y.removeAttribute(je)}catch{}}},mt=function(Y){Ks(Y);const ue=j(Y);ue&&lr(wO(ue),Ne=>{try{x(Ne)}catch{}});const je=H(Y)===Nn.element?S(Y):null;if(je)for(let Ne=je.length-1;Ne>=0;--Ne){const Ge=je[Ne],nt=Ge&&Ge.name;typeof nt=="string"&&ut(Y,Ge,nt)}},Rt=function(Y,ue,je){if(!je)try{je=ue.getAttributeNode(Y)}catch{je=null}Rl(t.removed,{attribute:je||null,from:ue});try{je?b(ue,je):ue.removeAttribute(Y)}catch{try{ue.removeAttribute(Y)}catch{}}if(Y==="is")if(gs||Cn)try{We(ue)}catch{}else try{ue.setAttribute(Y,"")}catch{}},Ft=function(Y){const ue=S(Y);if(ue)for(let je=ue.length-1;je>=0;--je){const Ne=ue[je],Ge=Ne&&Ne.name;typeof Ge!="string"||Ke[zt(Ge)]||ut(Y,Ne,Ge)}},Jn=function(Y,ue){let je=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const Ne=[Y];for(;Ne.length>0;){const Ge=Ne.pop();if(ue(Ge)===!1)continue;if(je&&H(Ge)===Nn.element){const pt=C(Ge);ks(pt)&&Ne.push(pt)}const nt=j(Ge);if(nt)for(let pt=nt.length-1;pt>=0;--pt)Ne.push(nt[pt])}},Ks=function(Y){Jn(Y,ue=>{H(ue)===Nn.element&&Ft(ue)})},pn=function(Y){const ue=[];return Jn(Y,je=>{ue.push(je)},!0),ue},$n=function(Y,ue){const je=mf();lr(pn(Y),Ne=>{H(Ne)===Nn.element&&ff(je,Ne)}),lr(ue,Ne=>{H(Ne)===Nn.element&&!Ol(je,Ne)&&Ft(Ne)})},Ys=function(Y,ue){let je=!1;return lr(t.removed,Ne=>{Ne.element&&(je=je||Ne.element===Y,Ks(Ne.element))}),$n(Y,ue),je},Xs=8,ys=function(Y,ue){const je=ce;let Ne=null;const Ge=()=>(Ne||(Ne=mf(),lr(ue,nt=>{ff(Ne,nt)})),Ne);for(let nt=0;;nt++){const pt=pn(Y),gn=[Y];let js=!1;if(lr(pt,kn=>{H(kn)===Nn.documentFragment?Rl(gn,kn):!js&&!Ol(je,kn)&&(js=Ol(Ge(),kn))}),!js)return;if(nt>=Xs)throw cr("the tree kept changing during in-place sanitization; refusing to return it");lr(gn,(kn,Pn)=>{ra(kn,Pn>0,Y,Ge())})}},ra=function(Y,ue,je,Ne){const Ge=bs(Y);let nt;for(;nt=Ge.nextNode();)!Ol(Ne,nt)||Ol(ce,nt)||(ue&&ft(re.uponSanitizeShadowNode,nt,null),He(nt,je),Qi(nt,je),ks(nt.content)&&oa(nt.content))},wr=function(Y){ce&&ff(ce,Y)},Ri=function(Y,ue){return Rn?Y==="patchsrc"?!0:Y==="for"&&ue!=="label"&&ue!=="output":!1},Sr=function(Y){Rn&&Jn(Y,ue=>{const je=H(ue);if(je===Nn.processingInstruction||je===Nn.comment&&qn(yb,ue.data)){try{x(ue)}catch{}return!1}if(je===Nn.element){const Ne=ue,Ge=zt(B(ue));try{Ne.hasAttribute&&Ne.hasAttribute("patchsrc")&&Ne.removeAttribute("patchsrc"),Ne.hasAttribute&&Ne.hasAttribute("for")&&Ri("for",Ge)&&Ne.removeAttribute("for")}catch{}}return!0})},ls=function(Y){let ue=null,je=null;if(rs)Y="<remove></remove>"+Y;else{const nt=ub(Y,/^[\r\n\t ]+/);je=nt&&nt[0]}vs==="application/xhtml+xml"&&wt===vt&&(Y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+Y+"</body></html>");const Ne=D?K(Y):Y;if(wt===vt)try{ue=new h().parseFromString(Ne,vs)}catch{}if(!ue||!ue.documentElement){ue=Z.createDocument(wt,"template",null);try{ue.documentElement.innerHTML=Xn?U:Ne}catch{}}const Ge=ue.body||ue.documentElement;return Y&&je&&Ge.insertBefore(s.createTextNode(je),Ge.childNodes[0]||null),wt===vt?ne.call(ue,fn?"html":"body")[0]:fn?ue.documentElement:Ge},bs=function(Y){const ue=P?P(Y):Y.ownerDocument;return Q.call(ue||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,X," "),Y=Pl(Y,se," "),Y=Pl(Y,ae," "),Y},Qs=function(Y){var ue;Nt(Y);const je=(ue=Y.querySelectorAll)===null||ue===void 0?void 0:ue.call(Y,"template");je&&lr(je,Ne=>{ks(Ne.content)&&Qs(Ne.content)})},Nt=function(Y){Y.normalize();const ue=P?P(Y):Y.ownerDocument,je=Q.call(ue||Y,Y,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let Ne=je.nextNode();for(;Ne;)Ne.data=In(Ne.data),Ne=je.nextNode()},at=function(Y){const ue=z?z(Y):null;return typeof ue!="string"||zt(ue)!=="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!==_(Y)||Y.childNodes!==j(Y)},ks=function(Y){if(!_||typeof Y!="object"||Y===null)return!1;try{return _(Y)===Nn.documentFragment}catch{return!1}},Bt=function(Y){if(!_||typeof Y!="object"||Y===null)return!1;try{return typeof _(Y)=="number"}catch{return!1}};function ft(Se,Y,ue){Se.length!==0&&lr(Se,je=>{je.call(t,Y,ue,Os)})}const Yi=function(Y,ue){return!!(Rn&&Y.hasChildNodes()&&!Bt(Y.firstElementChild)&&qn(bf,Y.textContent)&&qn(bf,Y.innerHTML)||Rn&&WO[ue]&&H(Y)===Nn.element&&T(Y)===vt&&(Bt(Y.firstElementChild)||typeof Y.textContent=="string"&&qn(bf,Y.textContent))||Y.nodeType===Nn.processingInstruction||Rn&&Y.nodeType===Nn.comment&&qn(yb,Y.data))},cs=function(Y,ue){if(Y instanceof RegExp)return qn(Y,ue);if(Y instanceof Function){for(var je=arguments.length,Ne=new Array(je>2?je-2:0),Ge=2;Ge<je;Ge++)Ne[Ge-2]=arguments[Ge];return!!Y(ue,...Ne)}return!1},Xi=function(Y,ue,je){if(!Mt[ue]&&Vt(ue)&&cs(xt.tagNameCheck,ue))return!1;if(Yn&&!he[ue]&&!he[Na(ue)]){const Ne=N(Y),Ge=j(Y);if(Ge&&Ne){const nt=Ge.length;for(let pt=nt-1;pt>=0;--pt){const gn=Y===je?g(Ge[pt],!0):Ge[pt];Ne.insertBefore(gn,k(Y))}}}return We(Y),!0},fi=function(Y,ue,je,Ne){return Y.length===0?ue:ue===je||ue===Ne?Fs(ue):ue},Oe=function(Y,ue){return Y===ue||N(Y)!==null?!1:(On&&Ks(Y),!0)},He=function(Y,ue){if(wr(Y),ft(re.beforeSanitizeElements,Y,null),Oe(Y,ue))return!0;if(at(Y))return We(Y),!0;const je=zt(B(Y));if(Re=fi(re.uponSanitizeElement,Re,Qe,Gs),ft(re.uponSanitizeElement,Y,{tagName:je,allowedTags:Re}),Oe(Y,ue))return!0;if(Yi(Y,je))return We(Y),!0;if(Mt[je]||!(rt.tagCheck instanceof Function&&rt.tagCheck(je))&&!Re[je]){const Ne=Xi(Y,je,ue);return Ne===!1&&(ft(re.afterSanitizeElements,Y,null),Oe(Y,ue))?!0:Ne}if(H(Y)===Nn.element&&!Me(Y)||(je==="noscript"||je==="noembed"||je==="noframes")&&qn(ZO,Y.innerHTML))return We(Y),!0;if(Ut&&Y.nodeType===Nn.text){const Ne=In(Y.textContent);Y.textContent!==Ne&&(Rl(t.removed,{element:Y.cloneNode()}),Y.textContent=Ne)}return ft(re.afterSanitizeElements,Y,null),Oe(Y,ue)},ot=function(Y,ue,je){if(En[ue]||Ri(ue,Y)||Kn&&(ue==="id"||ue==="name")&&(je in s||je in os))return!1;const Ne=Ke[ue]||rt.attributeCheck instanceof Function&&rt.attributeCheck(ue,Y);return rn&&qn(_e,ue)||Pt&&qn(ze,ue)?!0:Ne?jt[ue]||qn(Fe,Pl(je,fe,""))||(ue==="src"||ue==="xlink:href"||ue==="href")&&Y!=="script"&&db(je,"data:")===0&&Ue[Y]||Zt&&!qn(Te,Pl(je,fe,""))?!0:!je:Vt(Y)&&cs(xt.tagNameCheck,Y)&&cs(xt.attributeNameCheck,ue,Y)||ue==="is"&&xt.allowCustomizedBuiltInElements&&cs(xt.tagNameCheck,je)},kt=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!kt[Na(Y)]&&qn(ye,Y)},bn=function(Y,ue,je,Ne){if(D&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!je)switch(f.getAttributeType(Y,ue)){case"TrustedHTML":return K(Ne);case"TrustedScriptURL":return F(Ne)}return Ne},rl=function(Y,ue,je,Ne){try{return je?Y.setAttributeNS(je,ue,Ne):Y.setAttribute(ue,Ne),at(Y)?(We(Y),!1):!0}catch{return Rt(ue,Y),!1}},aa=function(Y,ue){return Rn&&qn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ue)?!0:Na(Y)==="attributename"&&ub(ue,"href")!==null},Qi=function(Y,ue){if(ft(re.beforeSanitizeAttributes,Y,null),Oe(Y,ue))return;const je=Y.attributes;if(!je||at(Y))return;Ke=fi(re.uponSanitizeAttribute,Ke,_t,ps);const Ne={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ke,forceKeepAttr:void 0};let Ge=je.length;const nt=zt(Y.nodeName);for(;Ge--;){const pt=je[Ge],gn=pt.name,js=pt.namespaceURI,kn=pt.value,Pn=zt(gn),Ji=kn;let an=gn==="value"?Ji:_O(Ji),Ja=!1;if(Ne.attrName=Pn,Ne.attrValue=an,Ne.keepAttr=!0,Ne.forceKeepAttr=void 0,ft(re.uponSanitizeAttribute,Y,Ne),an=Ne.attrValue,Zn&&(Pn==="id"||Pn==="name")&&db(an,An)!==0&&(Rt(gn,Y,pt),an=An+an,Ja=!0),aa(gn,an)){Rt(gn,Y,pt);continue}if(!Ne.forceKeepAttr){if(!Ne.keepAttr){Rt(gn,Y,pt);continue}if(!Qt&&qn(bb,an)){Rt(gn,Y,pt);continue}if(Ut&&(an=In(an)),!ot(nt,Pn,an)){Rt(gn,Y,pt);continue}an=bn(nt,Pn,js,an),an!==Ji&&rl(Y,gn,js,an)&&Ja&&cb(t.removed)}}ft(re.afterSanitizeAttributes,Y,null),Oe(Y,ue)},oa=function(Y){let ue=null;const je=bs(Y);for(ft(re.beforeSanitizeShadowDOM,Y,null);ue=je.nextNode();)if(ft(re.uponSanitizeShadowNode,ue,null),He(ue,Y),Qi(ue,Y),ks(ue.content)&&oa(ue.content),H(ue)===Nn.element){const Ne=C(ue);ks(Ne)&&(Qa(Ne),oa(Ne))}Ut&&Nt(Y),ft(re.afterSanitizeShadowDOM,Y,null)},Qa=function(Y){const ue=[{node:Y,shadow:null}];for(;ue.length>0;){const je=ue.pop();if(je.shadow){oa(je.shadow);continue}const Ne=je.node,Ge=H(Ne)===Nn.element,nt=j(Ne);if(nt)for(let pt=nt.length-1;pt>=0;--pt)ue.push({node:nt[pt],shadow:null});if(Ge){const pt=z?z(Ne):null;if(typeof pt=="string"&&zt(pt)==="template"){const gn=Ne.content;ks(gn)&&ue.push({node:gn,shadow:null})}}if(Ge){const pt=C(Ne);ks(pt)&&ue.push({node:null,shadow:pt},{node:pt,shadow:null})}}};return t.sanitize=function(Se){let Y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ue=null,je=null,Ne=null,Ge=null;if(Xn=!Se,Xn&&(Se="<!-->"),typeof Se!="string"&&!Bt(Se)&&(Se=$O(Se),typeof Se!="string"))throw cr("dirty is not a string, aborting");if(!t.isSupported)return Se;Hn?(Re=Gs,Ke=ps):hi(Y),(re.uponSanitizeElement.length>0||re.uponSanitizeAttribute.length>0)&&(Re=Fs(Re)),re.uponSanitizeAttribute.length>0&&(Ke=Fs(Ke)),t.removed=[];const nt=On&&typeof Se!="string"&&Bt(Se);let pt=[];const gn=ce;if(nt){Sr(Se);const Pn=B(Se);if(typeof Pn=="string"){const Ji=zt(Pn);if(!Re[Ji]||Mt[Ji])throw mt(Se),cr("root node is forbidden and cannot be sanitized in-place")}if(at(Se))throw mt(Se),cr("root node is clobbered and cannot be sanitized in-place");pt=pn(Se),ce=mf()}else if(Bt(Se))ue=ls("<!---->"),je=ue.ownerDocument.importNode(Se,!0),je.nodeType===Nn.element&&je.nodeName==="BODY"||je.nodeName==="HTML"?ue=je:ue.appendChild(je),Qa(ue);else{if(!gs&&!Ut&&!fn&&Se.indexOf("<")===-1)return D&&as?K(Se):Se;if(ue=ls(Se),!ue)return gs?null:as?U:""}ue&&rs&&We(ue.firstChild);const js=nt?Se:ue;try{nt&&Qa(Se);const Pn=bs(js);for(;Ne=Pn.nextNode();)He(Ne,js),Qi(Ne,js),ks(Ne.content)&&oa(Ne.content);nt&&ys(Se,pt)}catch(Pn){throw nt&&(mt(Se),Ys(Se,pt)),Pn}finally{ce=gn}if(nt){if(Ys(Se,pt))throw cr("a node selected for removal could not be safely returned; refusing to sanitize in place");return Ut&&Qs(Se),Se}if(gs){if(Ut&&Qs(ue),Cn)for(Ge=G.call(ue.ownerDocument);ue.firstChild;)Ge.appendChild(ue.firstChild);else Ge=ue;return(Ke.shadowroot||Ke.shadowrootmode)&&(Ge=te.call(i,Ge,!0)),Ge}let kn=fn?ue.outerHTML:ue.innerHTML;return fn&&Re["!doctype"]&&ue.ownerDocument&&ue.ownerDocument.doctype&&ue.ownerDocument.doctype.name&&qn(BO,ue.ownerDocument.doctype.name)&&(kn="<!DOCTYPE "+ue.ownerDocument.doctype.name+`>
130
+ `+kn),Ut&&(kn=In(kn)),D&&as?K(kn):kn},t.setConfig=function(){let Se=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hi(Se),Hn=!0,Gs=Re,ps=Ke},t.clearConfig=function(){Os=null,Hn=!1,Gs=null,ps=null,D=A,U=""},t.isValidAttribute=function(Se,Y,ue){Os||hi({});const je=zt(Se),Ne=zt(Y);return typeof ue=="string"&&(aa(Y,ue)||!Qt&&qn(bb,ue))?!1:ot(je,Ne,ue)},t.addHook=function(Se,Y){typeof Y=="function"&&Is(re,Se)&&Rl(re[Se],Y)},t.removeHook=function(Se,Y){if(Is(re,Se)){if(Y!==void 0){const ue=NO(re[Se],Y);return ue===-1?void 0:SO(re[Se],ue,1)[0]}return cb(re[Se])}},t.removeHooks=function(Se){Is(re,Se)&&(re[Se]=[])},t.removeAllHooks=function(){re=kb()},t}var Vg=fw();function qg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ka=qg();function pw(e){Ka=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 GO=(()=>{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")},KO=/^(?:[ \t]*(?:\n|$))+/,YO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,XO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,zc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,QO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Gg=/(?:[*+-]|\d{1,9}[.)])/,gw=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,xw=It(gw).replace(/bull/g,Gg).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(),JO=It(gw).replace(/bull/g,Gg).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(),Kg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,eP=/^[^\n]+/,Yg=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,tP=It(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Yg).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),nP=It(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Gg).getRegex(),rh="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",Xg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,sP=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",Xg).replace("tag",rh).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),vw=It(Kg).replace("hr",zc).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",rh).getRegex(),iP=It(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",vw).getRegex(),Qg={blockquote:iP,code:YO,def:tP,fences:XO,heading:QO,hr:zc,html:sP,lheading:xw,list:nP,newline:KO,paragraph:vw,table:lc,text:eP},jb=It("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",zc).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",rh).getRegex(),rP={...Qg,lheading:JO,table:jb,paragraph:It(Kg).replace("hr",zc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",jb).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",rh).getRegex()},aP={...Qg,html:It(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Xg).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(Kg).replace("hr",zc).replace("heading",` *#{1,6} *[^
131
+ ]`).replace("lheading",xw).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},oP=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,lP=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,yw=/^( {2,}|\\)\n(?!\s*$)/,cP=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ah=/[\p{P}\p{S}]/u,Jg=/[\s\p{P}\p{S}]/u,bw=/[^\s\p{P}\p{S}]/u,uP=It(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Jg).getRegex(),kw=/(?!~)[\p{P}\p{S}]/u,dP=/(?!~)[\s\p{P}\p{S}]/u,hP=/(?:[^\s\p{P}\p{S}]|~)/u,mP=It(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",GO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),jw=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,fP=It(jw,"u").replace(/punct/g,ah).getRegex(),pP=It(jw,"u").replace(/punct/g,kw).getRegex(),Nw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",gP=It(Nw,"gu").replace(/notPunctSpace/g,bw).replace(/punctSpace/g,Jg).replace(/punct/g,ah).getRegex(),xP=It(Nw,"gu").replace(/notPunctSpace/g,hP).replace(/punctSpace/g,dP).replace(/punct/g,kw).getRegex(),vP=It("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,bw).replace(/punctSpace/g,Jg).replace(/punct/g,ah).getRegex(),yP=It(/\\(punct)/,"gu").replace(/punct/g,ah).getRegex(),bP=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(),kP=It(Xg).replace("(?:-->|$)","-->").getRegex(),jP=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",kP).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),$d=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,NP=It(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",$d).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ww=It(/^!?\[(label)\]\[(ref)\]/).replace("label",$d).replace("ref",Yg).getRegex(),Sw=It(/^!?\[(ref)\](?:\[\])?/).replace("ref",Yg).getRegex(),wP=It("reflink|nolink(?!\\()","g").replace("reflink",ww).replace("nolink",Sw).getRegex(),Nb=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ex={_backpedal:lc,anyPunctuation:yP,autolink:bP,blockSkip:mP,br:yw,code:lP,del:lc,emStrongLDelim:fP,emStrongRDelimAst:gP,emStrongRDelimUnd:vP,escape:oP,link:NP,nolink:Sw,punctuation:uP,reflink:ww,reflinkSearch:wP,tag:jP,text:cP,url:lc},SP={...ex,link:It(/^!?\[(label)\]\((.*?)\)/).replace("label",$d).getRegex(),reflink:It(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",$d).getRegex()},Dp={...ex,emStrongRDelimAst:xP,emStrongLDelim:pP,url:It(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Nb).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",Nb).getRegex()},_P={...Dp,br:It(yw).replace("{2,}","*").getRegex(),text:It(Dp.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Xu={normal:Qg,gfm:rP,pedantic:aP},zl={normal:ex,gfm:Dp,breaks:_P,pedantic:SP},EP={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},wb=e=>EP[e];function Fi(e,t){if(t){if(fs.escapeTest.test(e))return e.replace(fs.escapeReplace,wb)}else if(fs.escapeTestNoEncode.test(e))return e.replace(fs.escapeReplaceNoEncode,wb);return e}function Sb(e){try{e=encodeURI(e).replace(fs.percentDecode,"%")}catch{return null}return e}function _b(e,t){var o;let s=e.replace(fs.findPipe,(l,u,d)=>{let h=!1,f=u;for(;--f>=0&&d[f]==="\\";)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 CP(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 Eb(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 AP(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 Id=class{constructor(e){dt(this,"options");dt(this,"rules");dt(this,"lexer");this.options=e||Ka}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=AP(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
+ `),f=h.replace(this.rules.other.blockquoteSetextReplace,`
139
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
140
+ ${h}`:h,r=r?`${r}
141
+ ${f}`:f;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,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,b=x.raw+`
142
+ `+s.join(`
143
+ `),k=this.blockquote(b);o[o.length-1]=k,i=i.substring(0,i.length-x.raw.length)+k.raw,r=r.substring(0,r.length-x.text.length)+k.text;break}else if((g==null?void 0:g.type)==="list"){let x=g,b=x.raw+`
144
+ `+s.join(`
145
+ `),k=this.list(b);o[o.length-1]=k,i=i.substring(0,i.length-g.raw.length)+k.raw,r=r.substring(0,r.length-x.raw.length)+k.raw,s=b.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="",f="";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,N=>" ".repeat(3*N.length)),g=e.split(`
148
+ `,1)[0],x=!p.trim(),b=0;if(this.options.pedantic?(b=2,f=p.trimStart()):x?b=t[1].length+1:(b=t[2].search(this.rules.other.nonSpaceChar),b=b>4?1:b,f=p.slice(b),b+=t[1].length),x&&this.rules.other.blankLine.test(g)&&(h+=g+`
149
+ `,e=e.substring(g.length+1),d=!0),!d){let N=this.rules.other.nextBulletRegex(b),C=this.rules.other.hrRegex(b),S=this.rules.other.fencesBeginRegex(b),_=this.rules.other.headingBeginRegex(b),z=this.rules.other.htmlBeginRegex(b);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)||_.test(g)||z.test(g)||N.test(g)||C.test(g))break;if(H.search(this.rules.other.nonSpaceChar)>=b||!g.trim())f+=`
151
+ `+H.slice(b);else{if(x||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(p)||_.test(p)||C.test(p))break;f+=`
152
+ `+g}!x&&!g.trim()&&(x=!0),h+=P+`
153
+ `,e=e.substring(P.length+1),p=H.slice(b)}}r.loose||(l?r.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(l=!0));let k=null,j;this.options.gfm&&(k=this.rules.other.listIsTask.exec(f),k&&(j=k[0]!=="[ ] ",f=f.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:h,task:!!k,checked:j,loose:!1,text:f,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"),f=h.length>0&&h.some(p=>this.rules.other.anyLine.test(p.raw));r.loose=f}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=_b(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(_b(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=CP(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)),Eb(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 Eb(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 f=[...i[0]][0].length,p=e.slice(0,r+i.index+f+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 Fp{constructor(t){dt(this,"tokens");dt(this,"options");dt(this,"state");dt(this,"tokenizer");dt(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ka,this.options.tokenizer=this.options.tokenizer||new Id,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:Xu.normal,inline:zl.normal};this.options.pedantic?(s.block=Xu.pedantic,s.inline=zl.pedantic):this.options.gfm&&(s.block=Xu.gfm,this.options.breaks?s.inline=zl.breaks:s.inline=zl.gfm),this.tokenizer.rules=s}static get rules(){return{block:Xu,inline:zl}}static lex(t,s){return new Fp(s).lex(t)}static lexInline(t,s){return new Fp(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,f=t.slice(1),p;this.options.extensions.startBlock.forEach(g=>{p=g.call({lexer:this},f),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,f,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=(f=this.options.extensions)==null?void 0:f.inline)!=null&&p.some(k=>(x=k.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 k=s.at(-1);x.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=x.raw,k.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 b=t;if((g=this.options.extensions)!=null&&g.startInline){let k=1/0,j=t.slice(1),N;this.options.extensions.startInline.forEach(C=>{N=C.call({lexer:this},j),typeof N=="number"&&N>=0&&(k=Math.min(k,N))}),k<1/0&&k>=0&&(b=t.substring(0,k+1))}if(x=this.tokenizer.inlineText(b)){t=t.substring(x.raw.length),x.raw.slice(-1)!=="_"&&(u=x.raw.slice(-1)),l=!0;let k=s.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=x.raw,k.text+=x.text):s.push(x);continue}if(t){let k="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return s}},Td=class{constructor(e){dt(this,"options");dt(this,"parser");this.options=e||Ka}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-'+Fi(i)+'">'+(s?r:Fi(r,!0))+`</code></pre>
171
+ `:"<pre><code>"+(s?r:Fi(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+" "+Fi(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>${Fi(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=Sb(e);if(r===null)return i;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+Fi(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=Sb(e);if(r===null)return Fi(s);e=r;let o=`<img src="${e}" alt="${s}"`;return t&&(o+=` title="${Fi(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Fi(e.text)}},tx=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 Up{constructor(t){dt(this,"options");dt(this,"renderer");dt(this,"textRenderer");this.options=t||Ka,this.options.renderer=this.options.renderer||new Td,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new tx}static parse(t,s){return new Up(s).parse(t)}static parseInline(t,s){return new Up(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,f=this.options.extensions.renderers[h.type].call({parser:this},h);if(f!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(h.type)){i+=f||"";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,f=this.renderer.text(h);for(;l+1<t.length&&t[l+1].type==="text";)h=t[++l],f+=`
188
+ `+this.renderer.text(h);s?i+=this.renderer.paragraph({type:"paragraph",raw:f,text:f,tokens:[{type:"text",raw:f,text:f,escaped:!0}]}):i+=f;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}},fd,Xl=(fd=class{constructor(e){dt(this,"options");dt(this,"block");this.options=e||Ka}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}},dt(fd,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),dt(fd,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),fd),$P=class{constructor(...e){dt(this,"defaults",qg());dt(this,"options",this.setOptions);dt(this,"parse",this.parseMarkdown(!0));dt(this,"parseInline",this.parseMarkdown(!1));dt(this,"Parser",wi);dt(this,"Renderer",Td);dt(this,"TextRenderer",tx);dt(this,"Lexer",Ni);dt(this,"Tokenizer",Id);dt(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 Td(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 f=u.apply(r,h);return f===!1&&(f=d.apply(r,h)),f||""}}i.renderer=r}if(s.tokenizer){let r=this.defaults.tokenizer||new Id(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 f=u.apply(r,h);return f===!1&&(f=d.apply(r,h)),f}}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 f=u.call(r,h);return d.call(r,f)}: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 f=u.apply(r,h);return f===!1&&(f=d.apply(r,h)),f}}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>"+Fi(s.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(s);throw s}}},za=new $P;function Tt(e,t){return za.parse(e,t)}Tt.options=Tt.setOptions=function(e){return za.setOptions(e),Tt.defaults=za.defaults,pw(Tt.defaults),Tt};Tt.getDefaults=qg;Tt.defaults=Ka;Tt.use=function(...e){return za.use(...e),Tt.defaults=za.defaults,pw(Tt.defaults),Tt};Tt.walkTokens=function(e,t){return za.walkTokens(e,t)};Tt.parseInline=za.parseInline;Tt.Parser=wi;Tt.parser=wi.parse;Tt.Renderer=Td;Tt.TextRenderer=tx;Tt.Lexer=Ni;Tt.lexer=Ni.lex;Tt.Tokenizer=Id;Tt.Hooks=Xl;Tt.parse=Tt;Tt.options;Tt.setOptions;Tt.use;Tt.walkTokens;Tt.parseInline;wi.parse;Ni.lex;const Cb=["#ff3b30","#ffcc00","#34c759","#0a84ff","#000000","#ffffff"],IP=[["rect","框"],["arrow","箭头"],["line","直线"],["pen","画笔"]],Ab=[[2,"细"],[4,"中"],[7,"粗"]],TP=.05,$b=16,Ib=44;function oh({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,f=v.useRef(null),p=v.useRef(null),[g,x]=v.useState(()=>MP(t,s)),[b,k]=v.useState({scale:1,x:0,y:0}),[j,N]=v.useState(!1),[C,S]=v.useState("rect"),[_,z]=v.useState(Cb[0]),[P,H]=v.useState(Ab[0][0]),[B,O]=v.useState([]),[T,D]=v.useState(null),[U,A]=v.useState(!0),[I,R]=v.useState(null),L=v.useRef(null),K=v.useRef(null),F=v.useCallback(()=>{var Fe;const fe=(Fe=f.current)==null?void 0:Fe.getBoundingClientRect();if(fe===void 0||fe.width===0)return;const ye=Math.min($b,(fe.width-24)/d,(fe.height-24)/h);k({scale:ye,x:(fe.width-d*ye)/2,y:(fe.height-h*ye)/2})},[d,h]);v.useLayoutEffect(F,[F]),v.useEffect(()=>{const fe=f.current;if(fe===null||typeof ResizeObserver>"u")return;const ye=new ResizeObserver(()=>F());return ye.observe(fe),()=>ye.disconnect()},[F]);const q=(fe,ye,Fe)=>{var _t;const Re=(_t=f.current)==null?void 0:_t.getBoundingClientRect();if(Re===void 0)return;const Qe=ye??Re.width/2,Ke=Fe??Re.height/2;k(xt=>{const Mt=Math.min($b,Math.max(TP,xt.scale*fe)),En=Mt/xt.scale;return{scale:Mt,x:Qe-(Qe-xt.x)*En,y:Ke-(Ke-xt.y)*En}})},V=()=>{var ye;const fe=(ye=f.current)==null?void 0:ye.getBoundingClientRect();fe!==void 0&&k({scale:1,x:(fe.width-d)/2,y:(fe.height-h)/2})};v.useEffect(()=>{const fe=f.current;if(fe===null)return;const ye=Fe=>{Fe.preventDefault();const Re=fe.getBoundingClientRect();q(Math.exp(-Fe.deltaY*.0015),Fe.clientX-Re.left,Fe.clientY-Re.top)};return fe.addEventListener("wheel",ye,{passive:!1}),()=>fe.removeEventListener("wheel",ye)});const Z=fe=>{R(fe),setTimeout(()=>R(ye=>ye===fe?null:ye),1800)},Q=v.useCallback(async(fe,ye=0)=>{const Fe=new Image;Fe.src=u,await Fe.decode();const Re=document.createElement("canvas");Re.width=d,Re.height=h;const Qe=Re.getContext("2d");Qe.drawImage(Fe,0,0,d,h);for(const xt of fe)PP(Qe,xt);if(ye===0)return Re;const Ke=document.createElement("canvas");Ke.width=h,Ke.height=d;const _t=Ke.getContext("2d");return _t.translate(h/2,d/2),_t.rotate(ye),_t.drawImage(Re,-d/2,-h/2),Ke},[u,d,h]),G=v.useCallback(async fe=>{try{const ye=await Q(fe),Fe=await new Promise((Re,Qe)=>ye.toBlob(Ke=>Ke===null?Qe(new Error("没能生成图片")):Re(Ke),"image/png"));try{await navigator.clipboard.write([new ClipboardItem({"image/png":Fe})])}catch(Re){const Qe=li();if((Qe==null?void 0:Qe.copyImage)===void 0)throw Re;await Qe.copyImage(ye.toDataURL("image/png"))}Z(fe.length>0?"已复制(带标注)":"已复制")}catch(ye){Z(`复制失败:${ye instanceof Error?ye.message:String(ye)}`)}},[Q]),ne=async()=>{const fe=await Q(B),ye=document.createElement("a");ye.href=fe.toDataURL("image/png"),ye.download=`${i.replace(/[\\/:*?"<>|]/g,"_").replace(/\.\w+$/,"")}${B.length>0?"-标注":""}.png`,ye.click()},te=async()=>{const fe=await Q(B,Math.PI/2);O([]),l({src:fe.toDataURL("image/png"),width:fe.width,height:fe.height})},re=()=>O(fe=>fe.slice(0,-1));v.useEffect(()=>{const fe=ye=>{if(!(p.current===null||!p.current.contains(document.activeElement))){if(ye.key==="Escape"){T!==null?(D(null),L.current=null):j?N(!1):r();return}if((ye.ctrlKey||ye.metaKey)&&ye.key.toLowerCase()==="z"){ye.preventDefault(),re();return}if((ye.ctrlKey||ye.metaKey)&&ye.key.toLowerCase()==="c"){ye.preventDefault(),G(B);return}ye.key==="0"&&F(),(ye.key==="+"||ye.key==="=")&&q(1.25),ye.key==="-"&&q(.8)}};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)});const X=fe=>{const ye=f.current.getBoundingClientRect(),Fe=(fe.clientX-ye.left-b.x)/b.scale,Re=(fe.clientY-ye.top-b.y)/b.scale;return[Math.max(0,Math.min(d,Fe)),Math.max(0,Math.min(h,Re))]},se=fe=>{if(fe.button!==0&&fe.button!==1)return;if(fe.currentTarget.setPointerCapture(fe.pointerId),!j||fe.button===1){L.current={kind:"pan",sx:fe.clientX,sy:fe.clientY,ox:b.x,oy:b.y};return}const[ye,Fe]=X(fe),Re=P/b.scale;L.current={kind:"mark"},D(C==="pen"?{kind:"pen",points:[[ye,Fe]],color:_,width:Re}:{kind:C,x1:ye,y1:Fe,x2:ye,y2:Fe,color:_,width:Re})},ae=fe=>{const ye=L.current;if(ye===null)return;if(ye.kind==="pan"){k(Qe=>({...Qe,x:ye.ox+fe.clientX-ye.sx,y:ye.oy+fe.clientY-ye.sy}));return}const[Fe,Re]=X(fe);D(Qe=>Qe===null?Qe:Qe.kind==="pen"?{...Qe,points:[...Qe.points,[Fe,Re]]}:{...Qe,x2:Fe,y2:Re})},_e=()=>{const fe=L.current;if(L.current=null,(fe==null?void 0:fe.kind)!=="mark"||T===null||(D(null),(T.kind==="pen"?T.points.length>2?99:0:Math.hypot(T.x2-T.x1,T.y2-T.y1)*b.scale)<4))return;const Fe=[...B,T];O(Fe),U&&G(Fe)},ze=fe=>{if(fe.target.closest("button")!==null)return;fe.currentTarget.setPointerCapture(fe.pointerId),K.current={sx:fe.clientX,sy:fe.clientY,ox:g.x,oy:g.y};const ye=p.current;ye!==null&&x(Fe=>({...Fe,w:ye.offsetWidth,h:ye.offsetHeight}))},Te=fe=>{const ye=K.current;ye!==null&&x(Fe=>({...Fe,x:Math.max(-Fe.w+120,Math.min(window.innerWidth-120,ye.ox+fe.clientX-ye.sx)),y:Math.max(0,Math.min(window.innerHeight-40,ye.oy+fe.clientY-ye.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:ze,onPointerMove:Te,onPointerUp:()=>{K.current=null},onDoubleClick:F,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:f,className:`viewer-stage ${j?"marking":""}`,onPointerDown:se,onPointerMove:ae,onPointerUp:_e,onPointerCancel:_e,children:[n.jsxs("div",{className:"viewer-canvas",style:{width:d,height:h,transform:`translate(${b.x}px, ${b.y}px) scale(${b.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,...T===null?[]:[T]].map((fe,ye)=>n.jsx(OP,{mark:fe},ye))})]}),I!==null&&n.jsx("div",{className:"viewer-toast",role:"status",children:I})]}),j&&n.jsxs("div",{className:"viewer-marks",children:[n.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"标注工具",children:IP.map(([fe,ye])=>n.jsx("button",{role:"radio","aria-checked":C===fe,className:`viewer-icon ${C===fe?"active":""}`,title:ye,onClick:()=>S(fe),children:n.jsx(RP,{tool:fe})},fe))}),n.jsx("span",{className:"viewer-sep"}),n.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"粗细",children:Ab.map(([fe,ye])=>n.jsx("button",{role:"radio","aria-checked":P===fe,className:`viewer-icon ${P===fe?"active":""}`,title:ye,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:Cb.map(fe=>n.jsx("button",{role:"radio","aria-checked":_===fe,"aria-label":fe,className:`swatch ${_===fe?"active":""}`,style:{background:fe},onClick:()=>z(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:U,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:F,title:"适应窗口(0)",children:[Math.round(b.scale*100),"%"]}),n.jsx("button",{className:"viewer-icon",onClick:()=>q(1.25),title:"放大",children:"+"}),n.jsx("button",{className:"viewer-icon",onClick:V,title:"原始大小",children:"1:1"}),n.jsx("span",{className:"viewer-sep"}),n.jsx("button",{className:"viewer-icon",onClick:()=>void te(),title:"旋转",children:"⟳"}),n.jsx("button",{className:`viewer-icon ${j?"active":""}`,onClick:()=>N(fe=>!fe),title:"标注:画框、箭头、直线",children:"✎"}),n.jsx("button",{className:"viewer-icon",onClick:()=>void G(B),title:"复制(Ctrl+C)",children:"⧉"}),n.jsx("button",{className:"viewer-icon",onClick:()=>void ne(),title:"保存",children:"⤓"})]})]}),document.body)}function MP(e,t){const s=Math.round(window.innerWidth*.7),i=Math.round(window.innerHeight*.78)-Ib*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+Ib*2);return{x:Math.round((window.innerWidth-o)/2),y:Math.max(16,Math.round((window.innerHeight-l)/2)),w:o,h:l}}function RP({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 _w(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 OP({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"?_w(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 PP(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]=_w(t);e.moveTo(s[0],s[1]),e.lineTo(t.x2,t.y2),e.lineTo(i[0],i[1])}e.stroke()}const lh=v.createContext(null),jf=new Map;function LP(e,t){let s=jf.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(()=>jf.delete(t.attachmentId)),jf.set(t.attachmentId,s)}return s}function Ew({image:e}){const t=v.useContext(lh),[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 f=!0;return LP(t,e).then(p=>{f&&i(p)},p=>{f&&o(p instanceof Error?p.message:String(p))}),()=>{f=!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(oh,{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 Nf,Tb;function zP(){if(Tb)return Nf;Tb=1;function e(J){return J instanceof Map?J.clear=J.delete=J.set=function(){throw new Error("map is read-only")}:J instanceof Set&&(J.add=J.clear=J.delete=function(){throw new Error("set is read-only")}),Object.freeze(J),Object.getOwnPropertyNames(J).forEach(he=>{const we=J[he],Ue=typeof we;(Ue==="object"||Ue==="function")&&!Object.isFrozen(we)&&e(we)}),J}class t{constructor(he){he.data===void 0&&(he.data={}),this.data=he.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function s(J){return J.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function i(J,...he){const we=Object.create(null);for(const Ue in J)we[Ue]=J[Ue];return he.forEach(function(Ue){for(const ct in Ue)we[ct]=Ue[ct]}),we}const r="</span>",o=J=>!!J.scope,l=(J,{prefix:he})=>{if(J.startsWith("language:"))return J.replace("language:","language-");if(J.includes(".")){const we=J.split(".");return[`${he}${we.shift()}`,...we.map((Ue,ct)=>`${Ue}${"_".repeat(ct+1)}`)].join(" ")}return`${he}${J}`};class u{constructor(he,we){this.buffer="",this.classPrefix=we.classPrefix,he.walk(this)}addText(he){this.buffer+=s(he)}openNode(he){if(!o(he))return;const we=l(he.scope,{prefix:this.classPrefix});this.span(we)}closeNode(he){o(he)&&(this.buffer+=r)}value(){return this.buffer}span(he){this.buffer+=`<span class="${he}">`}}const d=(J={})=>{const he={children:[]};return Object.assign(he,J),he};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(he){this.top.children.push(he)}openNode(he){const we=d({scope:he});this.add(we),this.stack.push(we)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(he){return this.constructor._walk(he,this.rootNode)}static _walk(he,we){return typeof we=="string"?he.addText(we):we.children&&(he.openNode(we),we.children.forEach(Ue=>this._walk(he,Ue)),he.closeNode(we)),he}static _collapse(he){typeof he!="string"&&he.children&&(he.children.every(we=>typeof we=="string")?he.children=[he.children.join("")]:he.children.forEach(we=>{h._collapse(we)}))}}class f extends h{constructor(he){super(),this.options=he}addText(he){he!==""&&this.add(he)}startScope(he){this.openNode(he)}endScope(){this.closeNode()}__addSublanguage(he,we){const Ue=he.root;we&&(Ue.scope=`language:${we}`),this.add(Ue)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function p(J){return J?typeof J=="string"?J:J.source:null}function g(J){return k("(?=",J,")")}function x(J){return k("(?:",J,")*")}function b(J){return k("(?:",J,")?")}function k(...J){return J.map(we=>p(we)).join("")}function j(J){const he=J[J.length-1];return typeof he=="object"&&he.constructor===Object?(J.splice(J.length-1,1),he):{}}function N(...J){return"("+(j(J).capture?"":"?:")+J.map(Ue=>p(Ue)).join("|")+")"}function C(J){return new RegExp(J.toString()+"|").exec("").length-1}function S(J,he){const we=J&&J.exec(he);return we&&we.index===0}const _=new RegExp(N(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function z(J,{joinWith:he}){let we=0;return J.map(Ue=>{we+=1;const ct=we;let jt=p(Ue),Be="";for(;jt.length>0;){const De=_.exec(jt);if(!De){Be+=jt;break}Be+=jt.substring(0,De.index),jt=jt.substring(De.index+De[0].length),De[0][0]==="\\"&&De[1]?Be+="\\"+String(Number(De[1])+ct):(Be+=De[0],(De[0]==="("||/^\(\?[<']/.test(De[0]))&&we++)}return Be}).map(Ue=>`(${Ue})`).join(he)}const P=/\b\B/,H="[a-zA-Z]\\w*",B="[a-zA-Z_]\\w*",O="\\b\\d+(\\.\\d+)?",T="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",D="\\b(0b[01]+)",U="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",A=(J={})=>{const he=/^#![ ]*\//;return J.binary&&(J.begin=k(he,/.*\b/,J.binary,/\b.*/)),i({scope:"meta",begin:he,end:/$/,relevance:0,"on:begin":(we,Ue)=>{we.index!==0&&Ue.ignoreMatch()}},J)},I={begin:"\\\\[\\s\\S]",relevance:0},R={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[I]},L={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[I]},K={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/},F=function(J,he,we={}){const Ue=i({scope:"comment",begin:J,end:he,contains:[]},we);Ue.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 ct=N("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 Ue.contains.push({begin:k(/[ ]+/,"(",ct,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ue},q=F("//","$"),V=F("/\\*","\\*/"),Z=F("#","$"),Q={scope:"number",begin:O,relevance:0},G={scope:"number",begin:T,relevance:0},ne={scope:"number",begin:D,relevance:0},te={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[I,{begin:/\[/,end:/\]/,relevance:0,contains:[I]}]},re={scope:"title",begin:H,relevance:0},X={scope:"title",begin:B,relevance:0},se={begin:"\\.\\s*"+B,relevance:0};var _e=Object.freeze({__proto__:null,APOS_STRING_MODE:R,BACKSLASH_ESCAPE:I,BINARY_NUMBER_MODE:ne,BINARY_NUMBER_RE:D,COMMENT:F,C_BLOCK_COMMENT_MODE:V,C_LINE_COMMENT_MODE:q,C_NUMBER_MODE:G,C_NUMBER_RE:T,END_SAME_AS_BEGIN:function(J){return Object.assign(J,{"on:begin":(he,we)=>{we.data._beginMatch=he[1]},"on:end":(he,we)=>{we.data._beginMatch!==he[1]&&we.ignoreMatch()}})},HASH_COMMENT_MODE:Z,IDENT_RE:H,MATCH_NOTHING_RE:P,METHOD_GUARD:se,NUMBER_MODE:Q,NUMBER_RE:O,PHRASAL_WORDS_MODE:K,QUOTE_STRING_MODE:L,REGEXP_MODE:te,RE_STARTERS_RE:U,SHEBANG:A,TITLE_MODE:re,UNDERSCORE_IDENT_RE:B,UNDERSCORE_TITLE_MODE:X});function ze(J,he){J.input[J.index-1]==="."&&he.ignoreMatch()}function Te(J,he){J.className!==void 0&&(J.scope=J.className,delete J.className)}function fe(J,he){he&&J.beginKeywords&&(J.begin="\\b("+J.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",J.__beforeBegin=ze,J.keywords=J.keywords||J.beginKeywords,delete J.beginKeywords,J.relevance===void 0&&(J.relevance=0))}function ye(J,he){Array.isArray(J.illegal)&&(J.illegal=N(...J.illegal))}function Fe(J,he){if(J.match){if(J.begin||J.end)throw new Error("begin & end are not supported with match");J.begin=J.match,delete J.match}}function Re(J,he){J.relevance===void 0&&(J.relevance=1)}const Qe=(J,he)=>{if(!J.beforeMatch)return;if(J.starts)throw new Error("beforeMatch cannot be used with starts");const we=Object.assign({},J);Object.keys(J).forEach(Ue=>{delete J[Ue]}),J.keywords=we.keywords,J.begin=k(we.beforeMatch,g(we.begin)),J.starts={relevance:0,contains:[Object.assign(we,{endsParent:!0})]},J.relevance=0,delete we.beforeMatch},Ke=["of","and","for","in","not","or","if","then","parent","list","value"],_t="keyword";function xt(J,he,we=_t){const Ue=Object.create(null);return typeof J=="string"?ct(we,J.split(" ")):Array.isArray(J)?ct(we,J):Object.keys(J).forEach(function(jt){Object.assign(Ue,xt(J[jt],he,jt))}),Ue;function ct(jt,Be){he&&(Be=Be.map(De=>De.toLowerCase())),Be.forEach(function(De){const Ye=De.split("|");Ue[Ye[0]]=[jt,Mt(Ye[0],Ye[1])]})}}function Mt(J,he){return he?Number(he):En(J)?0:1}function En(J){return Ke.includes(J.toLowerCase())}const rt={},Pt=J=>{console.error(J)},rn=(J,...he)=>{console.log(`WARN: ${J}`,...he)},Zt=(J,he)=>{rt[`${J}/${he}`]||(console.log(`Deprecated as of ${J}. ${he}`),rt[`${J}/${he}`]=!0)},Qt=new Error;function Ut(J,he,{key:we}){let Ue=0;const ct=J[we],jt={},Be={};for(let De=1;De<=he.length;De++)Be[De+Ue]=ct[De],jt[De+Ue]=!0,Ue+=C(he[De-1]);J[we]=Be,J[we]._emit=jt,J[we]._multi=!0}function Rn(J){if(Array.isArray(J.begin)){if(J.skip||J.excludeBegin||J.returnBegin)throw Pt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Qt;if(typeof J.beginScope!="object"||J.beginScope===null)throw Pt("beginScope must be object"),Qt;Ut(J,J.begin,{key:"beginScope"}),J.begin=z(J.begin,{joinWith:""})}}function fn(J){if(Array.isArray(J.end)){if(J.skip||J.excludeEnd||J.returnEnd)throw Pt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Qt;if(typeof J.endScope!="object"||J.endScope===null)throw Pt("endScope must be object"),Qt;Ut(J,J.end,{key:"endScope"}),J.end=z(J.end,{joinWith:""})}}function Hn(J){J.scope&&typeof J.scope=="object"&&J.scope!==null&&(J.beginScope=J.scope,delete J.scope)}function Gs(J){Hn(J),typeof J.beginScope=="string"&&(J.beginScope={_wrap:J.beginScope}),typeof J.endScope=="string"&&(J.endScope={_wrap:J.endScope}),Rn(J),fn(J)}function ps(J){function he(Be,De){return new RegExp(p(Be),"m"+(J.case_insensitive?"i":"")+(J.unicodeRegex?"u":"")+(De?"g":""))}class we{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(De,Ye){Ye.position=this.position++,this.matchIndexes[this.matchAt]=Ye,this.regexes.push([Ye,De]),this.matchAt+=C(De)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const De=this.regexes.map(Ye=>Ye[1]);this.matcherRe=he(z(De,{joinWith:"|"}),!0),this.lastIndex=0}exec(De){this.matcherRe.lastIndex=this.lastIndex;const Ye=this.matcherRe.exec(De);if(!Ye)return null;const vt=Ye.findIndex((Xn,xs)=>xs>0&&Xn!==void 0),wt=this.matchIndexes[vt];return Ye.splice(0,vt),Object.assign(Ye,wt)}}class Ue{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(De){if(this.multiRegexes[De])return this.multiRegexes[De];const Ye=new we;return this.rules.slice(De).forEach(([vt,wt])=>Ye.addRule(vt,wt)),Ye.compile(),this.multiRegexes[De]=Ye,Ye}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(De,Ye){this.rules.push([De,Ye]),Ye.type==="begin"&&this.count++}exec(De){const Ye=this.getMatcher(this.regexIndex);Ye.lastIndex=this.lastIndex;let vt=Ye.exec(De);if(this.resumingScanAtSamePosition()&&!(vt&&vt.index===this.lastIndex)){const wt=this.getMatcher(0);wt.lastIndex=this.lastIndex+1,vt=wt.exec(De)}return vt&&(this.regexIndex+=vt.position+1,this.regexIndex===this.count&&this.considerAll()),vt}}function ct(Be){const De=new Ue;return Be.contains.forEach(Ye=>De.addRule(Ye.begin,{rule:Ye,type:"begin"})),Be.terminatorEnd&&De.addRule(Be.terminatorEnd,{type:"end"}),Be.illegal&&De.addRule(Be.illegal,{type:"illegal"}),De}function jt(Be,De){const Ye=Be;if(Be.isCompiled)return Ye;[Te,Fe,Gs,Qe].forEach(wt=>wt(Be,De)),J.compilerExtensions.forEach(wt=>wt(Be,De)),Be.__beforeBegin=null,[fe,ye,Re].forEach(wt=>wt(Be,De)),Be.isCompiled=!0;let vt=null;return typeof Be.keywords=="object"&&Be.keywords.$pattern&&(Be.keywords=Object.assign({},Be.keywords),vt=Be.keywords.$pattern,delete Be.keywords.$pattern),vt=vt||/\w+/,Be.keywords&&(Be.keywords=xt(Be.keywords,J.case_insensitive)),Ye.keywordPatternRe=he(vt,!0),De&&(Be.begin||(Be.begin=/\B|\b/),Ye.beginRe=he(Ye.begin),!Be.end&&!Be.endsWithParent&&(Be.end=/\B|\b/),Be.end&&(Ye.endRe=he(Ye.end)),Ye.terminatorEnd=p(Ye.end)||"",Be.endsWithParent&&De.terminatorEnd&&(Ye.terminatorEnd+=(Be.end?"|":"")+De.terminatorEnd)),Be.illegal&&(Ye.illegalRe=he(Be.illegal)),Be.contains||(Be.contains=[]),Be.contains=[].concat(...Be.contains.map(function(wt){return gs(wt==="self"?Be:wt)})),Be.contains.forEach(function(wt){jt(wt,Ye)}),Be.starts&&jt(Be.starts,De),Ye.matcher=ct(Ye),Ye}if(J.compilerExtensions||(J.compilerExtensions=[]),J.contains&&J.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return J.classNameAliases=i(J.classNameAliases||{}),jt(J)}function rs(J){return J?J.endsWithParent||rs(J.starts):!1}function gs(J){return J.variants&&!J.cachedVariants&&(J.cachedVariants=J.variants.map(function(he){return i(J,{variants:null},he)})),J.cachedVariants?J.cachedVariants:rs(J)?i(J,{starts:J.starts?i(J.starts):null}):Object.isFrozen(J)?i(J):J}var Cn="11.12.0";class as extends Error{constructor(he,we){super(he),this.name="HTMLInjectionError",this.html=we}}const Kn=s,Zn=i,An=Symbol("nomatch"),Yn=7,On=function(J){const he=Object.create(null),we=Object.create(null),Ue=[];let ct=!0;const jt="Could not find the language '{}', did you forget to load/include a language module?",Be={disableAutodetect:!0,name:"Plain text",contains:[]};let De={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:f};function Ye(Me){return De.noHighlightRe.test(Me)}function vt(Me){let We=Me.className+" ";We+=Me.parentNode?Me.parentNode.className:"";const ut=De.languageDetectRe.exec(We);if(ut){const mt=os(ut[1]);return mt||(rn(jt.replace("{}",ut[1])),rn("Falling back to no-highlight mode for this block.",Me)),mt?ut[1]:"no-highlight"}return We.split(/\s+/).find(mt=>Ye(mt)||os(mt))}function wt(Me,We,ut){let mt="",Rt="";typeof We=="object"?(mt=Me,ut=We.ignoreIllegals,Rt=We.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`),Rt=Me,mt=We),ut===void 0&&(ut=!0);const Ft={code:mt,language:Rt};mi("before:highlight",Ft);const Jn=Ft.result?Ft.result:Xn(Ft.language,Ft.code,ut);return Jn.code=Ft.code,mi("after:highlight",Jn),Jn}function Xn(Me,We,ut,mt){const Rt=Object.create(null);function Ft(Oe,He){return Oe.keywords[He]}function Jn(){if(!at.keywords){Bt.addText(ft);return}let Oe=0;at.keywordPatternRe.lastIndex=0;let He=at.keywordPatternRe.exec(ft),ot="";for(;He;){ot+=ft.substring(Oe,He.index);const kt=In.case_insensitive?He[0].toLowerCase():He[0],Vt=Ft(at,kt);if(Vt){const[bn,rl]=Vt;if(Bt.addText(ot),ot="",Rt[kt]=(Rt[kt]||0)+1,Rt[kt]<=Yn&&(Yi+=rl),bn.startsWith("_"))ot+=He[0];else{const aa=In.classNameAliases[bn]||bn;$n(He[0],aa)}}else ot+=He[0];Oe=at.keywordPatternRe.lastIndex,He=at.keywordPatternRe.exec(ft)}ot+=ft.substring(Oe),Bt.addText(ot)}function Ks(){if(ft==="")return;let Oe=null;if(typeof at.subLanguage=="string"){if(!he[at.subLanguage]){Bt.addText(ft);return}Oe=Xn(at.subLanguage,ft,!0,ks[at.subLanguage]),ks[at.subLanguage]=Oe._top}else Oe=ui(ft,at.subLanguage.length?at.subLanguage:null);at.relevance>0&&(Yi+=Oe.relevance),Bt.__addSublanguage(Oe._emitter,Oe.language)}function pn(){at.subLanguage!=null?Ks():Jn(),ft=""}function $n(Oe,He){Oe!==""&&(Bt.startScope(He),Bt.addText(Oe),Bt.endScope())}function Ys(Oe,He){let ot=1;const kt=He.length-1;for(;ot<=kt;){if(!Oe._emit[ot]){ot++;continue}const Vt=In.classNameAliases[Oe[ot]]||Oe[ot],bn=He[ot];Vt?$n(bn,Vt):(ft=bn,Jn(),ft=""),ot++}}function Xs(Oe,He){return Oe.scope&&typeof Oe.scope=="string"&&Bt.openNode(In.classNameAliases[Oe.scope]||Oe.scope),Oe.beginScope&&(Oe.beginScope._wrap?($n(ft,In.classNameAliases[Oe.beginScope._wrap]||Oe.beginScope._wrap),ft=""):Oe.beginScope._multi&&(Ys(Oe.beginScope,He),ft="")),at=Object.create(Oe,{parent:{value:at}}),at}function ys(Oe,He,ot){let kt=S(Oe.endRe,ot);if(kt){if(Oe["on:end"]){const Vt=new t(Oe);Oe["on:end"](He,Vt),Vt.isMatchIgnored&&(kt=!1)}if(kt){for(;Oe.endsParent&&Oe.parent;)Oe=Oe.parent;return Oe}}if(Oe.endsWithParent)return ys(Oe.parent,He,ot)}function ra(Oe){return at.matcher.regexIndex===0?(ft+=Oe[0],1):(fi=!0,0)}function wr(Oe){const He=Oe[0],ot=Oe.rule,kt=new t(ot),Vt=[ot.__beforeBegin,ot["on:begin"]];for(const bn of Vt)if(bn&&(bn(Oe,kt),kt.isMatchIgnored))return ra(He);return ot.skip?ft+=He:(ot.excludeBegin&&(ft+=He),pn(),!ot.returnBegin&&!ot.excludeBegin&&(ft=He)),Xs(ot,Oe),ot.returnBegin?0:He.length}function Ri(Oe){const He=Oe[0],ot=We.substring(Oe.index),kt=ys(at,Oe,ot);if(!kt)return An;const Vt=at;at.endScope&&at.endScope._wrap?(pn(),$n(He,at.endScope._wrap)):at.endScope&&at.endScope._multi?(pn(),Ys(at.endScope,Oe)):Vt.skip?ft+=He:(Vt.returnEnd||Vt.excludeEnd||(ft+=He),pn(),Vt.excludeEnd&&(ft=He));do at.scope&&Bt.closeNode(),!at.skip&&!at.subLanguage&&(Yi+=at.relevance),at=at.parent;while(at!==kt.parent);return kt.starts&&Xs(kt.starts,Oe),Vt.returnEnd?0:He.length}function Sr(){const Oe=[];for(let He=at;He!==In;He=He.parent)He.scope&&Oe.unshift(He.scope);Oe.forEach(He=>Bt.openNode(He))}let ls={};function bs(Oe,He){const ot=He&&He[0];if(ft+=Oe,ot==null)return pn(),0;if(ls.type==="begin"&&He.type==="end"&&ls.index===He.index&&ot===""){if(ft+=We.slice(He.index,He.index+1),!ct){const kt=new Error(`0 width match regex (${Me})`);throw kt.languageName=Me,kt.badRule=ls.rule,kt}return 1}if(ls=He,He.type==="begin")return wr(He);if(He.type==="illegal"&&!ut){const kt=new Error('Illegal lexeme "'+ot+'" for mode "'+(at.scope||"<unnamed>")+'"');throw kt.mode=at,kt}else if(He.type==="end"){const kt=Ri(He);if(kt!==An)return kt}if(He.type==="illegal"&&ot==="")return He.index===We.length||(ft+=`
191
+ `),1;if(Xi>1e5&&Xi>He.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ft+=ot,ot.length}const In=os(Me);if(!In)throw Pt(jt.replace("{}",Me)),new Error('Unknown language: "'+Me+'"');const Qs=ps(In);let Nt="",at=mt||Qs;const ks={},Bt=new De.__emitter(De);Sr();let ft="",Yi=0,cs=0,Xi=0,fi=!1;try{if(In.__emitTokens)In.__emitTokens(We,Bt);else{for(at.matcher.considerAll();;){Xi++,fi?fi=!1:at.matcher.considerAll(),at.matcher.lastIndex=cs;const Oe=at.matcher.exec(We);if(!Oe)break;const He=We.substring(cs,Oe.index),ot=bs(He,Oe);cs=Oe.index+ot}bs(We.substring(cs))}return Bt.finalize(),Nt=Bt.toHTML(),{language:Me,value:Nt,relevance:Yi,illegal:!1,_emitter:Bt,_top:at}}catch(Oe){if(Oe.message&&Oe.message.includes("Illegal"))return{language:Me,value:Kn(We),illegal:!0,relevance:0,_illegalBy:{message:Oe.message,index:cs,context:We.slice(cs-100,cs+100),mode:Oe.mode,resultSoFar:Nt},_emitter:Bt};if(ct)return{language:Me,value:Kn(We),illegal:!1,relevance:0,errorRaised:Oe,_emitter:Bt,_top:at};throw Oe}}function xs(Me){const We={value:Kn(Me),illegal:!1,relevance:0,_top:Be,_emitter:new De.__emitter(De)};return We._emitter.addText(Me),We}function ui(Me,We){We=We||De.languages||Object.keys(he);const ut=xs(Me),mt=We.filter(os).filter(hi).map(pn=>Xn(pn,Me,!1));mt.unshift(ut);const Rt=mt.sort((pn,$n)=>{if(pn.relevance!==$n.relevance)return $n.relevance-pn.relevance;if(pn.language&&$n.language){if(os(pn.language).supersetOf===$n.language)return 1;if(os($n.language).supersetOf===pn.language)return-1}return 0}),[Ft,Jn]=Rt,Ks=Ft;return Ks.secondBest=Jn,Ks}function br(Me,We,ut){const mt=We&&we[We]||ut;Me.classList.add("hljs"),Me.classList.add(`language-${mt}`)}function di(Me){let We=null;const ut=vt(Me);if(Ye(ut))return;if(mi("before:highlightElement",{el:Me,language:ut}),Me.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Me);return}if(Me.children.length>0&&(De.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Me)),De.throwUnescapedHTML))throw new as("One of your code blocks includes unescaped HTML.",Me.innerHTML);We=Me;const mt=We.textContent,Rt=ut?wt(mt,{language:ut,ignoreIllegals:!0}):ui(mt);Me.innerHTML=Rt.value,Me.dataset.highlighted="yes",br(Me,ut,Rt.language),Me.result={language:Rt.language,re:Rt.relevance,relevance:Rt.relevance},Rt.secondBest&&(Me.secondBest={language:Rt.secondBest.language,relevance:Rt.secondBest.relevance}),mi("after:highlightElement",{el:Me,result:Rt,text:mt})}function kr(Me){De=Zn(De,Me)}const Qn=()=>{Ti(),Zt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function qi(){Ti(),Zt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let vs=!1;function Ti(){function Me(){Ti()}if(document.readyState==="loading"){vs||window.addEventListener("DOMContentLoaded",Me,!1),vs=!0;return}document.querySelectorAll(De.cssSelector).forEach(di)}function jr(Me,We){let ut=null;try{ut=We(J)}catch(mt){if(Pt("Language definition for '{}' could not be registered.".replace("{}",Me)),ct)Pt(mt);else throw mt;ut=Be}ut.name||(ut.name=Me),he[Me]=ut,ut.rawDefinition=We.bind(null,J),ut.aliases&&Gi(ut.aliases,{languageName:Me})}function zt(Me){delete he[Me];for(const We of Object.keys(we))we[We]===Me&&delete we[We]}function Os(){return Object.keys(he)}function os(Me){return Me=(Me||"").toLowerCase(),he[Me]||he[we[Me]]}function Gi(Me,{languageName:We}){typeof Me=="string"&&(Me=[Me]),Me.forEach(ut=>{we[ut.toLowerCase()]=We})}function hi(Me){const We=os(Me);return We&&!We.disableAutodetect}function Dt(Me){Me["before:highlightBlock"]&&!Me["before:highlightElement"]&&(Me["before:highlightElement"]=We=>{Me["before:highlightBlock"](Object.assign({block:We.el},We))}),Me["after:highlightBlock"]&&!Me["after:highlightElement"]&&(Me["after:highlightElement"]=We=>{Me["after:highlightBlock"](Object.assign({block:We.el},We))})}function Nr(Me){Dt(Me),Ue.push(Me)}function Ki(Me){const We=Ue.indexOf(Me);We!==-1&&Ue.splice(We,1)}function mi(Me,We){const ut=Me;Ue.forEach(function(mt){mt[ut]&&mt[ut](We)})}function Mi(Me){return Zt("10.7.0","highlightBlock will be removed entirely in v12.0"),Zt("10.7.0","Please use highlightElement now."),di(Me)}Object.assign(J,{highlight:wt,highlightAuto:ui,highlightAll:Ti,highlightElement:di,highlightBlock:Mi,configure:kr,initHighlighting:Qn,initHighlightingOnLoad:qi,registerLanguage:jr,unregisterLanguage:zt,listLanguages:Os,getLanguage:os,registerAliases:Gi,autoDetection:hi,inherit:Zn,addPlugin:Nr,removePlugin:Ki}),J.debugMode=function(){ct=!1},J.safeMode=function(){ct=!0},J.versionString=Cn,J.regex={concat:k,lookahead:g,either:N,optional:b,anyNumberOfTimes:x};for(const Me in _e)typeof _e[Me]=="object"&&e(_e[Me]);return Object.assign(J,_e),J},ce=On({});return ce.newInstance=()=>On({}),Nf=ce,ce.HighlightJS=ce,ce.default=ce,Nf}var DP=zP();const Ci=_g(DP);function FP(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:/'/},f={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}),b={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},k=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],j=["true","false"],N={match:/(\/[a-z._-]+)+/},C=["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"],_=["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"],z=["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:k,literal:j,built_in:[...C,...S,"set","shopt",..._,...z]},contains:[x,e.SHEBANG(),b,p,o,l,N,u,d,h,f,s]}}const UP=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_-]*/}}),BP=["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"],HP=["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"],ZP=[...BP,...HP],WP=["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(),VP=["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(),qP=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),GP=["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 KP(e){const t=e.regex,s=UP(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:":("+VP.join("|")+")"},{begin:":(:)?("+qP.join("|")+")"}]},s.CSS_VARIABLE,{className:"attribute",begin:"\\b("+GP.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:WP.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,s.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+ZP.join("|")+")\\b"}]}}function YP(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 XP(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 Co="[0-9](_*[0-9])*",Qu=`\\.(${Co})`,Ju="[0-9a-fA-F](_*[0-9a-fA-F])*",Mb={className:"number",variants:[{begin:`(\\b(${Co})((${Qu})|\\.)?|(${Qu}))[eE][+-]?(${Co})[fFdD]?\\b`},{begin:`\\b(${Co})((${Qu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Qu})[fFdD]?\\b`},{begin:`\\b(${Co})[fFdD]\\b`},{begin:`\\b0[xX]((${Ju})\\.?|(${Ju})?\\.(${Ju}))[pP][+-]?(${Co})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Ju})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Cw(e,t,s){return s===-1?"":e.replace(t,i=>Cw(e,t,s-1))}function QP(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=Cw("(?:\\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"]}]},b={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:[b,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,Mb,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},Mb,x]}}const Rb="[A-Za-z$_][0-9A-Za-z$_]*",JP=["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"],eL=["true","false","null","undefined","NaN","Infinity"],Aw=["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"],$w=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Iw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],tL=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],nL=[].concat(Iw,Aw,$w);function sL(e){const t=e.regex,s=(F,{after:q})=>{const V="</"+F[0].slice(1);return F.input.indexOf(V,q)!==-1},i=Rb,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,q)=>{const V=F[0].length+F.index,Z=F.input[V];if(Z==="<"||Z===","){q.ignoreMatch();return}Z===">"&&(s(F,{after:V})||q.ignoreMatch());let Q;const G=F.input.substring(V);if(Q=G.match(/^\s*=/)){q.ignoreMatch();return}if((Q=G.match(/^\s+extends\s+/))&&Q.index===0){q.ignoreMatch();return}}},u={$pattern:Rb,keyword:JP,literal:eL,built_in:nL,"variable.language":tL},d="[0-9](_?[0-9])*",h=`\\.(${d})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${f})((${h})|\\.)?|(${h}))[eE][+-]?(${d})\\b`},{begin:`\\b(${f})\\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"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},j={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},C={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,b,k,j,{match:/\$\d+/},p];g.contains=S.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(S)});const _=[].concat(C,g.contains),z=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(_)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:z},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:{_:[...Aw,...$w]}},O={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function U(F){return t.concat("(?!",F.join("|"),")")}const A={match:t.concat(/\b/,U([...Iw,"super","import","await"].map(F=>`${F}\\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},R={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},L="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",K={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(L)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:z,CLASS_REFERENCE:B},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),O,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,b,k,j,C,{match:/\$\d+/},p,B,{scope:"attr",match:i+t.lookahead(":"),relevance:0},K,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,e.REGEXP_MODE,{className:"function",begin:L,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:z}]}]},{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"]}]}]},T,{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,D,H,R,{match:/\$[(.]/}]}}const iL="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",rL={scope:"number",match:iL,relevance:0};function aL(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,rL,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function oL(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}/}]},f={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=e.inherit(h,{contains:[]}),g=e.inherit(f,{contains:[]});h.contains.push(g),f.contains.push(p);let x=[s,d];return[h,f,p,g].forEach(N=>{N.contains=N.contains.concat(x)}),x=x.concat(h,f),{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,f,{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 lL(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:/#/},f={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,f,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d,f,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,f,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,f,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",x=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,b=`\\b|${i.join("|")}`,k={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${x}))[eE][+-]?(${g})[jJ]?(?=${b})`},{begin:`(${x})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${b})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${b})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${b})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${b})`},{begin:`\\b(${g})[jJ](?=${b})`}]},j={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},N={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",d,k,p,e.HASH_COMMENT_MODE]}]};return h.contains=[p,k,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[d,k,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,j,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,s],scope:{1:"keyword",3:"title.function"},contains:[N]},{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:[k,N,p]}]}}function cL(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!"],f=["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:f,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:f}},{scope:"punctuation",begin:"->"},o]}}function uL(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"],f=["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=f,b=[...h,...d].filter(z=>!f.includes(z)),k={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},j={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},N={match:t.concat(/\b/,t.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function C(z){return t.concat(/\b/,t.either(...z.map(P=>P.replace(/\s+/,"\\s+"))),/\b/)}const S={scope:"keyword",match:C(g),relevance:0};function _(z,{exceptions:P,when:H}={}){const B=H;return P=P||[],z.map(O=>O.match(/\|\d+$/)||P.includes(O)?O:B(O)?`${O}|0`:O)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:_(b,{when:z=>z.length<3}),literal:o,type:u,built_in:p},contains:[{scope:"type",match:C(l)},S,N,k,i,r,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,s,j]}}const Md="[A-Za-z$_][0-9A-Za-z$_]*",Tw=["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"],Mw=["true","false","null","undefined","NaN","Infinity"],Rw=["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"],Ow=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Pw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Lw=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],zw=[].concat(Pw,Rw,Ow);function dL(e){const t=e.regex,s=(F,{after:q})=>{const V="</"+F[0].slice(1);return F.input.indexOf(V,q)!==-1},i=Md,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,q)=>{const V=F[0].length+F.index,Z=F.input[V];if(Z==="<"||Z===","){q.ignoreMatch();return}Z===">"&&(s(F,{after:V})||q.ignoreMatch());let Q;const G=F.input.substring(V);if(Q=G.match(/^\s*=/)){q.ignoreMatch();return}if((Q=G.match(/^\s+extends\s+/))&&Q.index===0){q.ignoreMatch();return}}},u={$pattern:Md,keyword:Tw,literal:Mw,built_in:zw,"variable.language":Lw},d="[0-9](_?[0-9])*",h=`\\.(${d})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${f})((${h})|\\.)?|(${h}))[eE][+-]?(${d})\\b`},{begin:`\\b(${f})\\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"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},j={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},C={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,b,k,j,{match:/\$\d+/},p];g.contains=S.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(S)});const _=[].concat(C,g.contains),z=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(_)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:z},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:{_:[...Rw,...Ow]}},O={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},T={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function U(F){return t.concat("(?!",F.join("|"),")")}const A={match:t.concat(/\b/,U([...Pw,"super","import","await"].map(F=>`${F}\\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},R={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},L="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",K={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(L)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:z,CLASS_REFERENCE:B},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),O,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,b,k,j,C,{match:/\$\d+/},p,B,{scope:"attr",match:i+t.lookahead(":"),relevance:0},K,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,e.REGEXP_MODE,{className:"function",begin:L,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:z}]}]},{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"]}]}]},T,{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,D,H,R,{match:/\$[(.]/}]}}function hL(e){const t=e.regex,s=dL(e),i=Md,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:Md,keyword:Tw.concat(d),literal:Mw,built_in:zw.concat(r),"variable.language":Lw},f={className:"meta",begin:"@"+i},p=(k,j,N)=>{const C=k.contains.findIndex(S=>S.label===j);if(C===-1)throw new Error("can not find mode to replace");k.contains.splice(C,1,N)};Object.assign(s.keywords,h),s.exports.PARAMS_CONTAINS.push(f);const g=s.contains.find(k=>k.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([f,o,l,x]),p(s,"shebang",e.SHEBANG()),p(s,"use_strict",u);const b=s.contains.find(k=>k.label==="func.def");return b.relevance=0,Object.assign(s,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),s}function mL(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 fL(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},b={begin:/\{/,end:/\}/,contains:[x],illegal:"\\n",relevance:0},k={begin:"\\[",end:"\\]",contains:[x],illegal:"\\n",relevance:0},j=[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},b,k,o,l],N=[...j];return N.pop(),N.push(u),x.contains=N,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:j}}for(const[e,t]of Object.entries({bash:FP,css:KP,diff:YP,go:XP,java:QP,javascript:sL,json:aL,markdown:oL,python:lL,rust:cL,sql:uL,typescript:hL,xml:mL,yaml:fL}))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 Ob=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");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:Ob(e);return`<div class="code-block"><div class="code-head"><span class="code-lang">${Ob(s===""?"text":s)}</span><button type="button" class="code-copy" data-copy="">复制</button></div><pre><code class="hljs">${r}</code></pre></div>`}}});function Dw(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 Pb=/\.(png|jpe?g|gif|webp|bmp)$/i,pL=/^(#|\?|\/\/|[a-z][a-z0-9+.-]*:)/i;function Lb(e){const t=e.trim(),s=Dw(t);if(s!==void 0)return s;if(!(t===""||pL.test(t)))return t}Vg.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=Lb(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=Dw(t);if(s!==void 0){e.removeAttribute("href"),e.setAttribute("data-local-path",s),e.setAttribute("title",s),e.classList.add("local-path"),Pb.test(s)&&e.setAttribute("data-image-preview",s);return}const i=Lb(t);i!==void 0&&Pb.test(i)&&(e.removeAttribute("href"),e.setAttribute("data-image-preview",i),e.setAttribute("title",i),e.classList.add("local-path"))});Vg.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 gL(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=li();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(Uw(t)?"浏览器里打不开本地文件,路径已复制":t))}function xL(e){var o;const t=e.target.closest("a[data-local-path]");if(t!==null){e.preventDefault(),gL(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)};Fw(i.innerText).then(r)}function Fw(e){var s;return(((s=navigator.clipboard)==null?void 0:s.writeText(e))??Promise.reject(new Error("no clipboard"))).then(()=>!0,()=>Uw(e))}function Uw(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 wf=new Map;function vL(e,t){let s=wf.get(t);return s===void 0&&(s=e.connection.call("attachments/file",{path:t}).then(i=>`data:${i.mediaType};base64,${i.data}`),s.catch(()=>wf.delete(t)),wf.set(t,s)),s}function yL(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(zb(u,"当前后端不支持显示图片"));return}l.classList.add("loading"),vL(t,u).then(d=>{s&&(l.src=d,l.classList.remove("loading"))},d=>{s&&l.replaceWith(zb(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 zb(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(()=>Vg.sanitize(Tt.parse(t,{async:!1})),[t]),r=v.useContext(lh),o=v.useRef(null),[l,u]=v.useState(null);v.useEffect(()=>o.current===null?void 0:yL(o.current,r),[i,r]);const d=h=>{const f=h.target,p=f.closest("a[data-image-preview]:not([data-local-path])"),g=f instanceof HTMLImageElement&&f.classList.contains("md-image")&&f.src!==""?f:(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}xL(h)};return n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:o,className:`markdown ${s??""}`,onClick:d,dangerouslySetInnerHTML:{__html:i}}),l!==null&&n.jsx(oh,{src:l.src,width:l.width,height:l.height,name:l.name,onClose:()=>u(null)})]})}),Db="adg.update.later",bL=360*6e4,Bw="https://github.com/haaahhhis/MultiGameAssistant/releases",Sf="dsh-multigameassistant";function nx(){var i;const e=(i=li())==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 Fb=new WeakMap;function kL(e){let t=Fb.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,bL)),()=>{--o===0&&l!==void 0&&(clearInterval(l),l=void 0)}}},Fb.set(e,t),t}function Hw(e){const t=ke(e.capabilities),s=ke(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 Zw(e,t){const s=kL(e),i=v.useSyncExternalStore(s.subscribe,s.get);return v.useEffect(()=>t?s.watch():void 0,[s,t]),{...i,check:s.check}}function Ww(e){var l;const{bridge:t,state:s}=nx(),i=Hw(e),r=Zw(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||Bw,notes:o.notes??[],...o.onNpm===void 0?{}:{onNpm:o.onNpm}}}function jL(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 f=(((l=/^\*\*(.+?)\*\*/.exec(d))==null?void 0:l[1])??d).replace(/\*\*|`|\[([^\]]*)\]\([^)]*\)/g,(p,g)=>g??"").replace(/[::。]\s*$/,"").trim();if(f!==""&&!i.includes(f)&&i.push(f.length>40?`${f.slice(0,40)}…`:f),i.length>=t)break}return i}function NL(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 sx({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:NL(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 Vw=!1;const Bp=new Set,Hp=e=>{Vw=e;for(const t of Bp)t()},wL=e=>(Bp.add(e),()=>{Bp.delete(e)});function qw(){Hp(!0)}function SL({client:e}){const t=v.useSyncExternalStore(wL,()=>Vw),s=Ww(e);if(v.useEffect(()=>{if(!t)return;const r=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),Hp(!1))};return document.addEventListener("keydown",r,!0),()=>document.removeEventListener("keydown",r,!0)},[t]),!t||s===null)return null;const i=()=>Hp(!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(ee,{name:"download"}),"MultiGameAssistant ",s.version," 可以更新了"]}),n.jsx("button",{className:"ghost icon-button","aria-label":"关闭",title:"关闭",onClick:i,children:n.jsx(ee,{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(sx,{notes:s.notes,notesUrl:s.notesUrl})}),s.kind==="desktop"?n.jsx(ix,{bridge:s.bridge,state:s.state,extra:n.jsx("button",{className:"ghost small-button",onClick:()=>{s.bridge.skip(s.version),i()},children:"跳过这个版本"})}):n.jsx(Gw,{version:s.version,onNpm:s.onNpm})]})})}function _f(e){return e>=1024*1024?`${Math.round(e/1024/1024)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function ix({bridge:e,state:t,extra:s}){var f;const[i,r]=v.useState(null),[o,l]=v.useState(!1),u=t.latest;if(u===void 0)return null;const d=((f=t.download)==null?void 0:f.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:["正在下载 ",_f(d.received)," / ",_f(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"?"正在下载…":`下载更新(${_f(u.size)})`})]})]})}function Gw({version:e,onNpm:t}){const s=`${Bw}/download/v${e}/${Sf}.tgz`;return n.jsxs("div",{className:"plugin-update",children:[t!==!1&&n.jsxs("p",{children:["在 dsh 的「Plugins」→「Add plugin」里再填一次 ",n.jsx(Ef,{text:Sf})," 安装(命令行的 dsh:",n.jsx(Ef,{text:`dsh plugin add ${Sf}`}),")。",t===void 0&&"没连上 npm,不知道那边有没有这个版本;装完版本没变的话,用下面的链接。"]}),t!==!0&&n.jsxs("p",{children:[t===!1&&"npm 上还没有这个版本(要等发布者批准)。","在「Add plugin」里填这个链接安装:",n.jsx(Ef,{text:s})]}),n.jsx("p",{className:"muted small",children:"装好后刷新这个页面。你的数据、脚本和定时任务都在 dsh 的数据目录里,重新安装不会丢。"})]})}function Ef({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(ee,{name:"check"}):n.jsx(ee,{name:"copy"})})]})}function _L(){var d;const{bridge:e,state:t}=nx(),[s,i]=v.useState(()=>{try{return sessionStorage.getItem(Db)}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(Db,r.version)}catch{}i(r.version)},u=jL(r.notes??[]);return n.jsxs("div",{className:"approval-card update-card",role:"status",children:[n.jsxs("div",{className:"approval-head",children:[n.jsx(ee,{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(ee,{name:"close"})})]}),u.length>0&&n.jsx("ul",{className:"update-highlights",children:u.map(h=>n.jsx("li",{children:h},h))}),n.jsx(ix,{bridge:e,state:t,extra:n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ghost small-button",onClick:qw,children:"更新介绍"}),!o&&n.jsx("button",{className:"ghost small-button",onClick:()=>void e.skip(r.version),children:"跳过这个版本"})]})})]})}function EL({client:e,sessionId:t,onSelect:s}){var f;const i=ke(e.approvals),r=ke(e.questions),o=(f=cO(e))==null?void 0:f.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(uO,{client:e,pending:o}),u.map(p=>n.jsx(AL,{client:e,request:p},p.questionId)),l.map(p=>n.jsx(CL,{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(ee,{name:"chevron"})]}),n.jsx(hO,{client:e}),n.jsx(oO,{client:e}),n.jsx(_L,{})]})}function CL({client:e,request:t}){var d,h,f;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"])??((f=t.displayReason)==null?void 0:f.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(ee,{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 AL({client:e,request:t}){var k;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&&(((k=t.questions[0].options)==null?void 0:k.length)??0)>0,h=j=>s[j]??{selected:[],custom:""},f=async j=>{o(!0),u(null);try{await e.answerQuestion(t.questionId,j)}catch(N){u(N instanceof Error?N.message:String(N)),o(!1)}},p=(j,N)=>{if(d)return void f([{id:j.id,selected:[N]}]);i(C=>{const S=C[j.id]??{selected:[],custom:""},_=j.multiSelect===!0?S.selected.includes(N)?S.selected.filter(z=>z!==N):[...S.selected,N]:S.selected.includes(N)?[]:[N];return{...C,[j.id]:{...S,selected:_}}})},g=(j,N)=>i(C=>({...C,[j.id]:{...C[j.id]??{selected:[]},custom:N}})),x=()=>t.questions.map(j=>{const{selected:N,custom:C}=h(j.id),S=C.trim();return{id:j.id,selected:S!==""&&j.multiSelect!==!0?[]:N,...S===""?{}:{custom:S}}}),b=t.questions.every(j=>h(j.id).selected.length>0||h(j.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(ee,{name:"chat"}),n.jsx("div",{className:"approval-text",children:n.jsx("div",{className:"approval-title",children:"agent 在问你"})})]}),t.questions.map(j=>{var N,C;return n.jsxs("div",{className:"question-item",children:[j.header!==void 0&&n.jsx("span",{className:"question-header",children:j.header}),n.jsx("div",{className:"question-text",children:j.question}),j.detail!==void 0&&n.jsx("div",{className:"question-detail",children:j.detail}),(((N=j.options)==null?void 0:N.length)??0)>0&&n.jsx("div",{className:"question-options",role:j.multiSelect===!0?"group":"radiogroup",children:j.options.map(S=>{const _=h(j.id).selected.includes(S.label);return n.jsxs("button",{className:`question-option${_?" on":""}`,disabled:r,role:j.multiSelect===!0?"checkbox":"radio","aria-checked":_,onClick:()=>p(j,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(j.id).custom,disabled:r,placeholder:(((C=j.options)==null?void 0:C.length)??0)>0?"或者直接写你的回答":"写下你的回答",onChange:S=>g(j,S.target.value),onKeyDown:S=>{S.key==="Enter"&&!S.nativeEvent.isComposing&&b&&f(x())}})]},j.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 f(t.questions.map(j=>({id:j.id,selected:[]}))),children:"跳过"}),n.jsx("button",{className:"inverse",disabled:r||!b,onClick:()=>void f(x()),children:"回答"})]})]})}const vn="main",$L={intervene:"alert",games:"gamepad",scripts:"package",pipelines:"flow"},cn={id:vn,name:"助手",description:"和你对话、替你安排;飞书里的消息也到这里",icon:"chat"};function Ya(e){return{id:e.id,name:e.name,description:e.description,icon:$L[e.id]??"sparkles"}}function qs(e){const t=ke(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 Da(e,t){return e.role!==void 0&&t.some(s=>s.id===e.role)?e.role:vn}function IL(e){return e==="你"?"你布置的":`来自${e}`}function rx(e,t){const s=ke(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(f=>{const p=new Map(f);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 Kw="adg.agentSeen";function TL(){try{const e=JSON.parse(localStorage.getItem(Kw)??"{}");return e!==null&&typeof e=="object"?e:{}}catch{return{}}}function ML(){const[e,t]=v.useState(TL);return{seen:e,markSeen:(i,r)=>{t(o=>{if((o[i]??0)>=r)return o;const l={...o,[i]:r};try{localStorage.setItem(Kw,JSON.stringify(l))}catch{}return l})}}}function Yw(e,t){const s=ke(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 RL(e,t){const s=ke(e.connection.status),i=ke(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}const OL={feishu:"飞书"},Cf=30;function Xw(e){const t=ke(e.connection.status),s=ke(e.capabilities),[i,r]=v.useState(new Set),o=s.has("archive");return v.useEffect(()=>{if(t.state!=="open"||!o)return;let l=!0;return e.connection.call("sessions/archived",{}).then(u=>{l&&r(new Set(u.sessionIds))}).catch(()=>{}),()=>{l=!1}},[e,t.state,o]),v.useEffect(()=>e.connection.on("sessions/archived",l=>r(new Set(l.sessionIds))),[e]),i}function PL(e,t){const s=ke(e.sessions),i=ke(e.approvals),r=ke(e.questions),o=qs(e),l=Xw(e),{seen:u,markSeen:d}=ML(),h=v.useMemo(()=>[cn,...o.map(Ya)],[o]),f=v.useMemo(()=>{var x;const g=new Map(h.map(b=>[b.id,[]]));for(const b of s.items)b.origin==="subagent"||b.blank||l.has(b.id)||(x=g.get(Da(b,o)))==null||x.push(b);for(const b of g.values())b.sort((k,j)=>j.updatedAt-k.updatedAt);return g},[s.items,l,h,o]);v.useEffect(()=>{var g,x;if(s.loaded)for(const b of h){const k=(x=(g=f.get(b.id))==null?void 0:g[0])==null?void 0:x.updatedAt;k!==void 0&&(b.id===t||u[b.id]===void 0)&&d(b.id,k)}},[s.loaded,f,t]);const p=g=>{const x=s.items.find(b=>b.id===g);return x===void 0?void 0:Da(x,o)};return h.map(g=>{const x=f.get(g.id)??[],b=x[0];return{agent:g,running:x.filter(k=>k.running).length,unread:g.id!==t&&b!==void 0&&b.updatedAt>(u[g.id]??1/0),waiting:[...i,...r].filter(k=>p(k.sessionId)===g.id).length,last:x.find(k=>k.home===g.id)??b}})}function LL(e,t){const s=ke(e.sessions),i=qs(e);return s.items.some(r=>r.origin!=="subagent"&&!r.blank&&r.home!==t&&Da(r,i)===t)}function zL({client:e,agentId:t,onSelect:s}){const i=ke(e.sessions),r=ke(e.connection.status),o=ke(e.capabilities),l=qs(e),u=Xw(e),d=mn(3e4),[h,f]=v.useState(null),[p,g]=v.useState(""),[x,b]=v.useState(!1),[k,j]=v.useState(!1),[N,C]=v.useState(new Map),[S,_]=v.useState(0),z=o.has("archive");v.useEffect(()=>e.connection.on("notify/changed",()=>_(R=>R+1)),[e]),v.useEffect(()=>{if(r.state!=="open"||!o.has("notify"))return;let R=!0;return e.connection.call("notify/conversations",{}).then(L=>{R&&C(new Map(L.items.map(K=>[K.sessionId,{channel:K.channel,user:K.user}])))}).catch(()=>{}),()=>{R=!1}},[e,r.state,o,S]);const P=R=>{const L=N.get(R.id);return L!==void 0?OL[L.channel]??L.channel:/^(飞书|feishu):/.test(R.title??"")?"飞书":void 0},H=p.trim().toLowerCase(),{earlier:B,archivedItems:O}=v.useMemo(()=>{const R=i.items.filter(L=>L.origin!=="subagent"&&!L.blank&&L.home!==t&&Da(L,l)===t&&(H===""||jo(L).toLowerCase().includes(H))).sort((L,K)=>K.updatedAt-L.updatedAt);return{earlier:R.filter(L=>!u.has(L.id)),archivedItems:R.filter(L=>u.has(L.id))}},[i.items,t,l,u,H]),[T,D]=v.useState(null),U=async()=>{const R=T;D(null);const L=(R==null?void 0:R.value.trim())??"",K=i.items.find(F=>F.id===(R==null?void 0:R.id));R===null||K===void 0||L===""||L===jo(K)||await e.renameSession(R.id,L).catch(F=>f(F instanceof Error?F.message:String(F)))},A=async(R,L)=>{f(null),await e.connection.call(L?"sessions/archive":"sessions/unarchive",{sessionId:R}).catch(K=>f(K instanceof Error?K.message:String(K)))},I=R=>{const L=P(R),K=u.has(R.id);return n.jsxs("div",{className:"session-row",children:[(T==null?void 0:T.id)===R.id?n.jsx("input",{className:"text-input session-rename",autoFocus:!0,value:T.value,maxLength:80,"aria-label":"会话名称",onFocus:F=>F.target.select(),onChange:F=>D({id:R.id,value:F.target.value}),onKeyDown:F=>{F.key==="Enter"&&!F.nativeEvent.isComposing&&U(),F.key==="Escape"&&D(null)},onBlur:()=>void U()}):n.jsxs("button",{className:"nav-item session-item",onClick:()=>s(R.id),onDoubleClick:()=>D({id:R.id,value:jo(R)}),title:"双击改名",children:[L!==void 0&&n.jsx("span",{className:"channel-badge",children:L}),n.jsx("span",{className:"nav-item-label",children:L!==void 0?jo(R).replace(/^(飞书|feishu):/,""):jo(R)}),R.running?n.jsx("span",{className:"run-dot",role:"img","aria-label":"运行中"}):n.jsx("span",{className:"session-time",children:gt(R.updatedAt,d)})]}),(T==null?void 0:T.id)!==R.id&&n.jsxs("span",{className:"session-row-actions",children:[n.jsx("button",{className:"session-action",title:"改名","aria-label":"改名",onClick:()=>D({id:R.id,value:jo(R)}),children:n.jsx(ee,{name:"pencil"})}),z&&!R.running&&n.jsx("button",{className:"session-action",title:K?"恢复":"归档:从列表里移走,之后可以在「已归档」里找回","aria-label":K?"恢复":"归档",onClick:()=>void A(R.id,!K),children:n.jsx(ee,{name:K?"back":"archive"})})]})]},R.id)};return n.jsx("section",{className:"main history-page",children:n.jsxs("div",{className:"history-body",children:[n.jsxs("label",{className:"sidebar-search",children:[n.jsx(ee,{name:"search"}),n.jsx("input",{"aria-label":"搜索以前的对话",placeholder:"搜索以前的对话",value:p,onChange:R=>g(R.target.value),onKeyDown:R=>{R.key==="Escape"&&g("")}})]}),h!==null&&n.jsx("div",{className:"error small",children:h}),n.jsxs("nav",{className:"session-list","aria-label":"以前的对话",children:[!i.loaded&&r.state==="open"&&n.jsx("div",{className:"muted small pad",children:"加载中…"}),i.loaded&&B.length===0&&n.jsxs("div",{className:"sidebar-empty",children:[n.jsx(ee,{name:H===""?"chat":"search"}),n.jsx("span",{children:H===""?"没有以前的对话":"没有匹配的对话"})]}),(k?B:B.slice(0,Cf)).map(I),!k&&B.length>Cf&&n.jsxs("button",{className:"nav-item more-sessions",onClick:()=>j(!0),children:["更多(",B.length-Cf,")"]}),z&&O.length>0&&n.jsxs("div",{className:"archive-entry",children:[n.jsxs("button",{className:"nav-item role-row",onClick:()=>b(R=>!R),"aria-expanded":x,children:[n.jsx(ee,{name:"archive"}),n.jsx("span",{className:"nav-item-label",children:"已归档"}),n.jsx("span",{className:"tab-count",children:O.length}),n.jsx(ee,{name:x?"chevron-down":"chevron",className:"role-chevron"})]}),x&&O.map(I)]})]})]})})}function jo(e){return e.title??(e.blank?"新会话":"未命名会话")}function gt(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 DL({client:e,pages:t,current:s,onAgent:i,onPage:r,onSchedule:o,onSettings:l,width:u,onWidth:d,slot:h}){const f=ke(e.connection.status),p=ke(e.capabilities),g=PL(e,s.kind==="agent"?s.id:void 0),x=Ww(e),b=u>=Oo,k=g.find(T=>T.agent.id===vn),j=g.filter(T=>T.agent.id!==vn),N=t.filter(T=>T.order<0),C=s.kind==="page"?N.find(T=>T.id===s.id):void 0,[S,..._]=N,z=s.kind==="agent"&&s.id===vn,P=rx(e,b?g.flatMap(T=>T.last===void 0?[]:[{id:T.last.id,updatedAt:T.last.updatedAt,running:T.last.running}]):[]),H=T=>T.last===void 0?void 0:P.get(T.last.id)??void 0,B=T=>n.jsx(Ql,{icon:T.icon,label:T.title,active:s.kind==="page"&&s.id===T.id,onClick:()=>r(T.id)},T.id),O=T=>n.jsx(HL,{state:T,wide:b,reply:H(T),active:s.kind==="agent"&&s.id===T.agent.id,onClick:()=>i(T.agent.id)},T.agent.id);return n.jsxs("nav",{className:`rail${b?" wide":""}`,"aria-label":"功能区",children:[n.jsx("div",{className:"rail-top",children:k!==void 0&&(S===void 0?O(k):n.jsx(ZL,{state:k,page:S,wide:b,reply:H(k),showingPage:(C==null?void 0:C.id)===S.id,active:z||(C==null?void 0:C.id)===S.id,onClick:()=>z?r(S.id):i(vn)}))}),n.jsx("span",{className:"rail-divider",role:"separator"}),C!==void 0?n.jsx("div",{className:"rail-items rail-slot",ref:h,"aria-label":C.title}):n.jsxs("div",{className:"rail-items",children:[j.map(O),t.filter(T=>T.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:qw,dot:!0}),(k===void 0?N:_).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}),f.state!=="open"&&n.jsxs("span",{className:`rail-connection ${f.state}`,role:"status",title:Hb(f.state,f.attempt,f.error),children:[n.jsx("span",{className:"conn-dot"}),n.jsx("span",{className:"sr-only",children:Hb(f.state,f.attempt,f.error)})]})]}),n.jsx(BL,{width:u,onWidth:d}),n.jsx(SL,{client:e})]})}const Oo=150,$a=68,FL=360,Ub="adg.railWidth";function UL(){const[e,t]=v.useState(()=>{try{return Bb(Number(localStorage.getItem(Ub)??$a))}catch{return $a}});return v.useEffect(()=>{const s=setTimeout(()=>{try{localStorage.setItem(Ub,String(e))}catch{}},200);return()=>clearTimeout(s)},[e]),[e,s=>t(Bb(s))]}function Bb(e){if(!Number.isFinite(e))return $a;const t=Math.min(FL,Math.max($a,Math.round(e)));return t<Oo?t<($a+Oo)/2?$a:Oo:t}function BL({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>=Oo?$a:220)})}function HL({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(ee,{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 ZL({state:e,page:t,wide:s,reply:i,showingPage:r,active:o,onClick:l}){const{agent:u,running:d,unread:h,waiting:f}=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,b=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:b,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(ee,{name:g.icon})}),n.jsxs("span",{className:`agent-avatar rail-avatar rail-switch-face ${p.className}`,children:[n.jsx(ee,{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(ee,{name:"swap"}),g.name]})]}),n.jsx("span",{className:"rail-preview",children:x})]}):n.jsx("span",{className:"rail-label",children:p.name}),f>0?n.jsx("span",{className:"rail-badge","aria-label":`助手有 ${f} 个等你处理`,children:f}):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(ee,{name:e}),n.jsx("span",{className:"rail-label",children:t}),l&&n.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新版本"})]})}function Hb(e,t,s){const i=e==="open"?"已连接 agent":e==="connecting"?"正在连接…":e==="reconnecting"?`重连中(第 ${t} 次)`:"未连接";return s===void 0?i:`${i}:${s}`}const Qw=v.createContext(null),WL=v.createContext(!1);function VL({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(""),[f,p]=v.useState(!1),[g,x]=v.useState(null),b=v.useRef(null),k=v.useRef(null),j=v.useRef(!1),N=v.useRef(0),C=s==null?void 0:s.tabs.find(F=>F.id===s.shown);v.useEffect(()=>{f||h((C==null?void 0:C.url)==="about:blank"?"":(C==null?void 0:C.url)??"")},[C==null?void 0:C.url,f]),v.useEffect(()=>{let F=!0;e.state().then(Z=>{F&&Z!==null&&i(Z)});const q=e.onChange(i),V=e.onFrame(Z=>{createImageBitmap(new Blob([Z.data],{type:"image/jpeg"})).then(Q=>{var G;if(!F)return Q.close();(G=u.current)==null||G.close(),u.current=Q,S(),o(ne=>(ne==null?void 0:ne.width)===Z.width&&ne.height===Z.height?ne:{width:Z.width,height:Z.height})},()=>{})});return()=>{var Z;F=!1,q(),V(),(Z=u.current)==null||Z.close(),u.current=null}},[e]),v.useEffect(()=>{const F=b.current;if(F===null)return;const q=()=>{const{width:Z,height:Q}=F.getBoundingClientRect();e.show(Z>50&&Q>50?{width:Math.floor(Z),height:Math.floor(Q)}:null)},V=new ResizeObserver(q);return V.observe(F),q(),()=>{V.disconnect(),e.show(null)}},[e]);function S(){var V;const F=l.current,q=u.current;F===null||q===null||((F.width!==q.width||F.height!==q.height)&&(F.width=q.width,F.height=q.height),(V=F.getContext("2d"))==null||V.drawImage(q,0,0))}v.useEffect(S,[r]);const _=F=>{x(null),F.catch(q=>x(q instanceof Error?q.message:String(q)))},z=F=>{const q=F.currentTarget.getBoundingClientRect(),V=r===null?1:r.width/q.width,Z=r===null?1:r.height/q.height;return{x:Math.round((F.clientX-q.left)*V),y:Math.round((F.clientY-q.top)*Z)}},P=F=>[F.shiftKey&&"shift",F.ctrlKey&&"control",F.altKey&&"alt",F.metaKey&&"meta"].filter(q=>q!==!1),H=F=>F===1?"middle":F===2?"right":"left",B=F=>e.input(F),O=F=>{var q;F.preventDefault(),(q=k.current)==null||q.focus(),B({type:"mouseDown",...z(F),button:H(F.button),clickCount:F.detail,modifiers:P(F)})},T=F=>B({type:"mouseUp",...z(F),button:H(F.button),clickCount:F.detail,modifiers:P(F)}),D=F=>{const q=Date.now();F.buttons===0&&q-N.current<50||(N.current=q,B({type:"mouseMove",...z(F),modifiers:P(F)}))},U=F=>B({type:"mouseWheel",...z(F),deltaX:-F.deltaX,deltaY:-F.deltaY,canScroll:!0,modifiers:P(F)}),A=F=>{if(j.current||F.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"},V=(F.ctrlKey||F.metaKey||F.altKey)&&F.key.length===1,Z=q[F.key]??(V?F.key.toUpperCase():void 0);if(Z===void 0)return;F.preventDefault();const Q=P(F);B({type:"keyDown",keyCode:Z,modifiers:Q}),Z==="Enter"&&B({type:"char",keyCode:"\r",modifiers:Q}),B({type:"keyUp",keyCode:Z,modifiers:Q})},I=()=>{const F=k.current;if(F===null||F.value==="")return;const q=F.value;F.value="",e.text(q)},R=()=>{const F=d.trim();F!==""&&(p(!1),_(e.navigate({url:F,...C===void 0?{newTab:!0}:{}})))},L=s!==null&&Date.now()-s.agentAt<5e3,[,K]=v.useState(0);return v.useEffect(()=>{if(!L||s===null)return;const F=setTimeout(()=>K(q=>q+1),s.agentAt+5e3-Date.now()+50);return()=>clearTimeout(F)},[L,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:(C==null?void 0:C.canGoBack)!==!0,onClick:()=>_(e.navigate({action:"back"})),children:n.jsx(ee,{name:"back"})}),n.jsx("button",{type:"button",className:"icon-button",title:"前进","aria-label":"前进",disabled:(C==null?void 0:C.canGoForward)!==!0,onClick:()=>_(e.navigate({action:"forward"})),children:n.jsx(ee,{name:"chevron"})}),n.jsx("button",{type:"button",className:"icon-button",title:"刷新","aria-label":"刷新",disabled:C===void 0,onClick:()=>_(e.navigate({action:"reload"})),children:n.jsx(ee,{name:"refresh"})}),n.jsx("input",{className:"text-input browser-address",value:d,placeholder:"输入网址,回车打开","aria-label":"网址",onFocus:F=>{p(!0),F.target.select()},onBlur:()=>p(!1),onChange:F=>h(F.target.value),onKeyDown:F=>{F.key==="Enter"&&!F.nativeEvent.isComposing&&R(),F.key==="Escape"&&F.target.blur()}}),n.jsx("button",{type:"button",className:"icon-button",title:"关闭浏览器面板(页面保留)","aria-label":"关闭浏览器面板",onClick:t,children:n.jsx(ee,{name:"close"})})]}),s!==null&&s.tabs.length>0&&n.jsxs("div",{className:"browser-tabs",role:"tablist","aria-label":"标签页",children:[s.tabs.map(F=>n.jsxs("span",{className:`browser-tab${F.id===s.shown?" active":""}`,children:[n.jsxs("button",{type:"button",role:"tab","aria-selected":F.id===s.shown,title:F.url,onClick:()=>_(e.select(F.id)),children:[F.loading&&n.jsx("span",{className:"pill-dot"}),F.title===""?F.url:F.title]}),n.jsx("button",{type:"button",className:"browser-tab-close",title:"关闭标签页","aria-label":`关闭 ${F.title}`,onClick:()=>_(e.close(F.id)),children:n.jsx(ee,{name:"close"})})]},F.id)),n.jsx("button",{type:"button",className:"browser-tab-new",title:"新标签页","aria-label":"新标签页",onClick:()=>{h(""),_(e.navigate({url:"about:blank",newTab:!0}))},children:n.jsx(ee,{name:"plus"})})]}),L&&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:b,children:[C===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":C.title,onMouseDown:O,onMouseUp:T,onMouseMove:D,onWheel:U,onContextMenu:F=>F.preventDefault()}),n.jsx("textarea",{ref:k,className:"browser-typing","aria-label":"在页面里输入",tabIndex:-1,onKeyDown:A,onCompositionStart:()=>{j.current=!0},onCompositionEnd:()=>{j.current=!1,I()},onInput:()=>{j.current||I()}})]})]})}const Rd="adg.draft.",Zb=60,Zp=new Map;function qL(e){try{const t=localStorage.getItem(Rd+e);if(t===null)return"";const s=JSON.parse(t);return typeof s.text=="string"?s.text:""}catch{return""}}function GL(e,t){try{if(t.trim()===""){localStorage.removeItem(Rd+e);return}localStorage.setItem(Rd+e,JSON.stringify({text:t,at:Date.now()})),XL()}catch{}}function KL(e){return Zp.get(e)??[]}function YL(e,t){t.length===0?Zp.delete(e):Zp.set(e,[...t])}function XL(){const e=[];for(let t=0;t<localStorage.length;t++){const s=localStorage.key(t);if(!(s===null||!s.startsWith(Rd)))try{e.push({key:s,at:Number(JSON.parse(localStorage.getItem(s)??"{}").at)||0})}catch{e.push({key:s,at:0})}}if(!(e.length<=Zb))for(const t of e.sort((s,i)=>s.at-i.at).slice(0,e.length-Zb))localStorage.removeItem(t.key)}const QL={off:"不思考",none:"不思考",minimal:"最少",low:"低",medium:"中",high:"高",xhigh:"很高",max:"最大"},Wb=(e,t)=>QL[e]??(t!==void 0&&t!==e?t:e);function Jw(e,t){return(t==null?void 0:t.next)??(t==null?void 0:t.lastUsed)??(e==null?void 0:e.default)??null}function JL(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 ez({client:e,sessionId:t,disabled:s,value:i,onChange:r}){var U;const{catalog:o,error:l}=Ga(e),u=ke(e.sessionModels),d=ke(e.connection.status),[h,f]=v.useState(!1),[p,g]=v.useState(null),[x,b]=v.useState(!1),[k,j]=v.useState(""),N=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=R=>{N.current!==null&&!N.current.contains(R.target)&&b(!1)},I=R=>{R.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",A),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",I)}},[x]);const C=t===void 0?void 0:u.get(t),S=t===void 0?i??(o==null?void 0:o.default)??null:Jw(o,C),_=JL(o,S),z=S!==null&&o!==null&&_===void 0,P=async A=>{if(g(null),t===void 0){r==null||r(A);return}f(!0);try{await e.selectModel(t,A)}catch(I){g(I instanceof Error?I.message:String(I))}finally{f(!1)}},H=(A,I)=>{const R=(S==null?void 0:S.reasoningEffort)!==void 0&&I.efforts.some(L=>L.id===S.reasoningEffort)?S.reasoningEffort:I.defaultEffort;P({provider:A,model:I.id,...R===void 0?{}:{reasoningEffort:R}}),I.efforts.length===0&&b(!1)},B=v.useMemo(()=>{const A=k.trim().toLowerCase();return((o==null?void 0:o.groups)??[]).map(I=>({...I,models:I.models.filter(R=>A===""||R.id.toLowerCase().includes(A)||R.name.toLowerCase().includes(A)||I.name.toLowerCase().includes(A))})).filter(I=>I.models.length>0)},[o,k]),O=[p,l,...(o==null?void 0:o.failures.map(A=>`${A.name}:${A.message}`))??[]].filter(Boolean);if(o===null)return null;const T=(S==null?void 0:S.reasoningEffort)??(_==null?void 0:_.defaultEffort),D=(U=_==null?void 0:_.efforts.find(A=>A.id===T))==null?void 0:U.name;return n.jsxs("div",{className:`model-picker${p!==null?" has-error":""}`,ref:N,children:[n.jsxs("button",{type:"button",className:"model-trigger","aria-haspopup":"dialog","aria-expanded":x,disabled:s||h,title:O.length>0?O.join(`
193
+ `):"选择模型和思考强度",onClick:()=>b(A=>!A),children:[n.jsx("span",{className:`model-dot ${z?"off":""}`}),n.jsx("span",{className:"model-name",children:(_==null?void 0:_.name)??(S===null?"选择模型":`${S.model}(不可用)`)}),T!==void 0&&_!==void 0&&_.efforts.length>0&&n.jsx("span",{className:"model-effort",children:Wb(T,D)}),n.jsx(ee,{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:k,onChange:A=>j(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 R=(S==null?void 0:S.provider)===A.id&&S.model===I.id;return n.jsxs("button",{type:"button",role:"option","aria-selected":R,className:`model-option ${R?"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:"思考"}),R&&n.jsx(ee,{name:"check"})]},I.id)})]},A.id))]}),_!==void 0&&S!==null&&n.jsxs("div",{className:"model-efforts",children:[n.jsx("span",{className:"field-label",children:"思考强度"}),_.efforts.length===0?n.jsx("span",{className:"muted small",children:"这个模型没有可选的思考强度(在「设置 → 模型」里给模型打开「思考」)"}):n.jsx("div",{className:"segmented-control",role:"radiogroup","aria-label":"思考强度",children:_.efforts.map(A=>n.jsx("button",{type:"button",role:"radio","aria-checked":T===A.id,className:T===A.id?"active":"",onClick:()=>void P({provider:S.provider,model:S.model,reasoningEffort:A.id}),children:Wb(A.id,A.name)},A.id))})]}),O.length>0&&n.jsx("div",{className:"error small model-problems",children:O.join(";")})]})]})}let Jl=[],tz=1;const Wp=new Set,Vb=()=>{for(const e of Wp)e()},nz=e=>(Wp.add(e),()=>{Wp.delete(e)}),sz=()=>Jl[0];function iz(e,t){return new Promise(s=>{const i=tz++;Jl=[...Jl,{...e,id:i,single:t,settle:r=>{Jl=Jl.filter(o=>o.id!==i),Vb(),s(r)}}],Vb()})}function Ms(e){return iz(e,!1)}function rz(){const e=v.useSyncExternalStore(nz,sz);return e===void 0?null:n.jsx(az,{pending:e},e.id)}function az({pending:e}){const{title:t,message:s,quote:i,confirmLabel:r="确定",cancelLabel:o="取消",danger:l=!1,icon:u,single:d,settle:h}=e,f=v.useRef(null),p=v.useRef(null),g=v.useRef(null),x=`confirm-title-${e.id}`,b=`confirm-body-${e.id}`;return v.useEffect(()=>{var j;const k=document.activeElement;return(j=(l&&!d?g:p).current)==null||j.focus({preventScroll:!0}),()=>{k instanceof HTMLElement&&k.isConnected&&k.focus({preventScroll:!0})}},[l,d]),v.useEffect(()=>{const k=j=>{if(j.key==="Escape"){j.preventDefault(),j.stopPropagation(),h(!1);return}if(j.key!=="Tab"||f.current===null)return;const N=[...f.current.querySelectorAll("button:not(:disabled)")],C=N.indexOf(document.activeElement);j.preventDefault();const S=N[(C+(j.shiftKey?-1:1)+N.length)%N.length];S==null||S.focus()};return document.addEventListener("keydown",k,!0),()=>document.removeEventListener("keydown",k,!0)},[h]),n.jsx("div",{className:"dialog-backdrop confirm-backdrop",onPointerDown:k=>{k.target===k.currentTarget&&h(!1)},children:n.jsxs("div",{ref:f,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:b,children:[n.jsxs("h3",{id:x,children:[(u!==void 0||l)&&n.jsx(ee,{name:u??"alert"}),t]}),(s!==void 0||i!==void 0)&&n.jsxs("div",{id:b,className:"confirm-body",children:[typeof s=="string"?n.jsx(oz,{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 oz({text:e}){return n.jsx(n.Fragment,{children:e.split(/\n\s*\n/).map((t,s)=>{const i=t.split(`
194
+ `).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 lz(e,t){return t.find(s=>s.scripts.includes(e.packId??e.id)||s.scripts.includes(e.id))}function Od(e,t){const s=e.toLowerCase();return t.find(i=>[i.id,i.name,...i.aliases].some(r=>r.toLowerCase()===s))}function eS(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)):lz(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=Od(r,s);i.push({game:o===void 0?{id:r,name:r}:{id:o.id,name:o.name}})}return i}function tS(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 Af=[];function cz(e){const t=ke(e.capabilities),s=t.has("skills"),i=t.has("scripts"),r=t.has("games"),[o,l]=v.useState(Af),[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 f=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",{}),f,p]).then(([g,x,b])=>{Af=g.skills.filter(k=>k.userInvocable).map(k=>{const j=[...new Set(eS(k.owner,x,b).map(tS))].join("、");return{name:k.name,description:k.description,...j===""?{}:{group:j}}}),h&&l(Af)},()=>{}),()=>{h=!1}},[e,s,i,r,u]),o}const $f=e=>e.kind==="command"?"命令":e.group??"通用技能";function nS({client:e,text:t,setText:s,area:i,submit:r,placement:o="above",inSession:l=!1}){const u=cz(e),[d,h]=v.useState(0),[f,p]=v.useState(!1),g=f?[]:L2(t,u,l),x=t.split(/\s/)[0];v.useEffect(()=>{h(0),p(!1)},[x]);const b=Math.min(d,Math.max(0,g.length-1)),k=S=>{var _;s(`/${S.name} `),p(!0),(_=i.current)==null||_.focus()},j=S=>{var _;if(r!==void 0&&S.kind==="command"&&S.arg===void 0){s(""),r(`/${S.name}`),(_=i.current)==null||_.focus();return}k(S)},N=S=>{if(g.length===0||S.nativeEvent.isComposing)return!1;if(S.key==="ArrowDown"||S.key==="ArrowUp")return S.preventDefault(),h((b+(S.key==="ArrowDown"?1:g.length-1))%g.length),!0;if(S.key==="Tab"||S.key==="Enter"&&!S.shiftKey){S.preventDefault();const _=g[b];return S.key==="Tab"?k(_):j(_),!0}return S.key==="Escape"?(S.preventDefault(),p(!0),!0):!1};return{menu:g.length===0?null:n.jsx(uz,{options:g,active:b,placement:o,onHover:h,onChoose:j}),onKeyDown:N,expand:S=>O2(S,u)}}function uz({options:e,active:t,placement:s,onHover:i,onChoose:r}){const o=v.useRef(null),[l,u]=v.useState(0);v.useLayoutEffect(()=>{var f;const h=(f=o.current)==null?void 0:f.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 f;const h=(f=o.current)==null?void 0:f.querySelector(`[data-index="${t}"]`);h!=null&&o.current!==null&&u(h.offsetTop-o.current.scrollTop)},children:e.map((h,f)=>n.jsxs("div",{children:[(f===0||$f(e[f-1])!==$f(h))&&n.jsx("div",{className:"slash-group",children:$f(h)}),n.jsx("button",{type:"button",role:"option","data-index":f,"aria-selected":f===t,className:`slash-item ${f===t?"active":""}`,onMouseEnter:()=>i(f),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 Vp=5.5,qb=2*Math.PI*Vp,Gb=[{key:"systemTokens",label:"系统提示词",tone:"system"},{key:"toolsTokens",label:"工具定义",tone:"tools"},{key:"messageTokens",label:"对话消息",tone:"messages"}];function If(e){return e>=1e6?`${Kb(e/1e6)}M`:e>=1e3?`${Kb(e/1e3)}k`:String(Math.round(e))}const Kb=e=>e>=100?Math.round(e).toString():e.toFixed(1).replace(/\.0$/,"");function dz({context:e}){const[t,s]=v.useState(!1),i=v.useRef(null);if(v.useEffect(()=>{if(!t)return;const f=g=>{var x;(x=i.current)!=null&&x.contains(g.target)||s(!1)},p=g=>{g.key==="Escape"&&s(!1)};return document.addEventListener("pointerdown",f),document.addEventListener("keydown",p),()=>{document.removeEventListener("pointerdown",f),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}]:Gb.map(f=>({key:f.key,tone:f.tone,width:r*l[f.key]/u})).filter(f=>f.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:Vp}),n.jsx("circle",{className:"context-fill",cx:"7",cy:"7",r:Vp,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:["~",If(e.usedTokens)," / ",If(e.contextWindow)]})]}),n.jsx("div",{className:"context-bar",children:d.map(f=>n.jsx("span",{className:`context-segment ${f.tone}`,style:{width:`${f.width}%`}},f.key))}),l!==void 0&&n.jsx("dl",{className:"context-rows",children:Gb.map(f=>n.jsxs("div",{children:[n.jsxs("dt",{children:[n.jsx("span",{className:`context-swatch ${f.tone}`,"aria-hidden":"true"}),f.label]}),n.jsxs("dd",{children:["~",If(l[f.key])]})]},f.key))}),n.jsxs("p",{className:"context-tip",children:["快满时会自动压缩(「设置 → 对话压缩」)。也可以输入 ",n.jsx("kbd",{children:"/压缩"})," 手动压缩:较早的部分换成摘要,agent 会忘掉其中的细节。"]})]})]})}const hz=6e4,mz={CNY:"¥",USD:"$"},xd=(e,t)=>{const s=mz[e];return s===void 0?`${t} ${e}`:`${s}${t}`};function fz({balances:e}){const t=e.filter(s=>Number(s.total)!==0);return(t.length>0?t:e.slice(0,1)).map(s=>xd(s.currency,s.total)).join(" / ")}function pz(e){return`DeepSeek 账户余额 ${e.balances.map(s=>`${xd(s.currency,s.total)}(充值 ${xd(s.currency,s.toppedUp)},赠送 ${xd(s.currency,s.granted)})`).join("、")}${e.available?"":"。余额不足,调用模型会失败"}`}function gz({client:e,sessionId:t,running:s}){var p;const{catalog:i}=Ga(e),r=ke(e.sessionModels).get(t),o=((p=Jw(i,r))==null?void 0:p.provider)??null,l=ke(e.credentialRevision),u=ke(e.connection.status),d=ke(e.capabilities),[h,f]=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(k=>{g&&f({provider:o,balance:k,error:null})},k=>{g&&f({provider:o,balance:null,error:k instanceof Error?k.message:String(k)})});x();const b=s?setInterval(()=>void x(),hz):void 0;return()=>{g=!1,clearInterval(b)}},[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:pz(h.balance),children:fz(h.balance)})}function xz({client:e,session:t,running:s,disabled:i,initialPrompt:r,onInitialSent:o,reminder:l}){const u=ke(e.capabilities),{queue:d,context:h}=ke(t.state),f=d.filter(V=>V.placement!=="taken"),[p,g]=v.useState(()=>qL(t.id)),[x,b]=v.useState(!0),[k,j]=v.useState(null),[N,C]=v.useState(null),S=v.useRef(null),_=v.useRef(null),z=v.useRef(!1),[P,H]=v.useState(()=>KL(t.id));v.useEffect(()=>GL(t.id,p),[t.id,p]),v.useEffect(()=>YL(t.id,P),[t.id,P]);const B=sO(e),[O,T]=v.useState(!1),D=async V=>{const Z=V.filter(G=>G.type.startsWith("image/"));if(Z.length===0)return;j(null);const Q=Fl-P.length;if(Q<=0){j(`一条消息最多 ${Fl} 张图片`);return}try{const G=await Promise.all(Z.slice(0,Q).map(bz));H(ne=>[...ne,...G].slice(0,Fl)),Z.length>Q&&j(`一条消息最多 ${Fl} 张图片,多的没有加上`)}catch(G){j(`图片没能加上:${G instanceof Error?G.message:String(G)}`)}},U=V=>{const Z=[...V.clipboardData.items].filter(Q=>Q.kind==="file"&&Q.type.startsWith("image/")).map(Q=>Q.getAsFile()).filter(Q=>Q!==null);Z.length!==0&&(V.preventDefault(),D(Z))},A=V=>{T(!1),V.dataTransfer.files.length!==0&&(V.preventDefault(),D([...V.dataTransfer.files]))};v.useEffect(()=>{var V;r===void 0||z.current||i||(z.current=!0,t.prompt(r,"queue").catch(Z=>j(Z instanceof Error?Z.message:String(Z))),o==null||o(),(V=S.current)==null||V.focus())},[r,i,t,o]);const I=V=>M2(V)!=="compact"?!1:(g(""),j(null),s?(j("agent 正在工作,等它停下再压缩"),!0):(Ms({title:"压缩这个对话?",message:vz,confirmLabel:"压缩",danger:!0}).then(Z=>{Z&&(C("正在压缩对话:模型在写摘要,可能要一两分钟…"),t.compact().then(Q=>C(Q.message),Q=>{C(null),j(Q instanceof Error?Q.message:String(Q))}))}),!0)),R=nS({client:e,text:p,setText:g,area:S,inSession:!0,submit:V=>{i||I(V)||(j(null),t.prompt(R.expand(V),s&&x?"steer":"queue").catch(Z=>j(Z instanceof Error?Z.message:String(Z))))}}),L=()=>{var Q;if(!i&&P.length===0&&I(p))return;const V=R.expand(p);if(V===""&&P.length===0||i)return;const Z=P.map(({url:G,...ne})=>ne);g(""),H([]),j(null),t.prompt(V,s&&x?"steer":"queue",Z).catch(G=>j(G instanceof Error?G.message:String(G))),(Q=S.current)==null||Q.focus()},K=V=>{R.onKeyDown(V)||V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing&&(V.preventDefault(),L())},F=V=>{t.updateQueue(V.id,"remove").then(()=>{p.trim()===""&&V.text!==""&&g(V.text)},Z=>j(Z instanceof Error?Z.message:String(Z)))},q=V=>{t.updateQueue(V.id,"steer").catch(Z=>j(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}),f.length>0&&n.jsx("div",{className:"queue","aria-label":"等待发送的消息",children:f.map(V=>n.jsxs("div",{className:"queue-item",children:[n.jsx("span",{className:`queue-tag ${V.placement}`,children:V.placement==="next-step"?"插入中":"排队中"}),n.jsxs("span",{className:"queue-text",title:V.text,children:[V.text===""?"(图片)":V.text,V.images!==void 0&&n.jsxs("span",{className:"muted",children:[" · ",V.images," 张图片"]})]}),n.jsx("span",{className:"queue-when muted",children:V.placement==="next-step"?"这一步做完就交给 agent":"这一轮结束后发送"}),V.placement==="next-turn"&&s&&n.jsx("button",{type:"button",className:"small-button",title:"不等这一轮结束,现在就交给 agent",onClick:()=>q(V),children:"现在插入"}),n.jsx("button",{type:"button",className:"small-button",title:"撤回这条消息",onClick:()=>F(V),children:"撤回"})]},V.id))}),l,N!==null&&n.jsxs("div",{className:"composer-note small",role:"status",children:[n.jsx("span",{children:N}),n.jsx("button",{type:"button",className:"ghost small-button",onClick:()=>C(null),children:"知道了"})]}),n.jsxs("div",{className:"slash-anchor",children:[R.menu,n.jsxs("div",{className:`composer-box ${O?"dragging":""}`,onDragOver:V=>{[...V.dataTransfer.items].some(Z=>Z.kind==="file")&&(V.preventDefault(),T(!0))},onDragLeave:()=>T(!1),onDrop:A,children:[P.length>0&&n.jsx("div",{className:"composer-images",children:P.map((V,Z)=>n.jsxs("span",{className:"composer-image",children:[n.jsx("img",{src:V.url,alt:V.name??`图片 ${Z+1}`}),n.jsx("button",{type:"button","aria-label":"移除这张图片",onClick:()=>H(Q=>Q.filter((G,ne)=>ne!==Z)),children:"✕"})]},Z))}),n.jsx("textarea",{onPaste:U,ref:S,"aria-label":"消息内容",value:p,onChange:V=>g(V.target.value),onKeyDown:K,rows:Math.min(8,Math.max(2,p.split(`
195
+ `).length)),placeholder:i?"未连接到 agent":s?x?"运行中:发出去会插进这一轮,改主意了直接说":"运行中:消息会排队到下一轮":"继续追问,或描述下一步要做的事",disabled:i}),n.jsxs("div",{className:"composer-actions",children:[u.has("models")&&n.jsx(ez,{client:e,sessionId:t.id,disabled:i}),n.jsx("button",{type:"button",className:"attach-button",title:"添加图片(也可以直接粘贴或拖进来)","aria-label":"添加图片",disabled:i||P.length>=Fl,onClick:()=>{var V;return(V=_.current)==null?void 0:V.click()},children:n.jsx(ee,{name:"image"})}),n.jsx("input",{ref:_,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:V=>{D([...V.target.files??[]]),V.target.value=""}}),B==="full"&&n.jsxs("button",{type:"button",className:"full-access-chip",title:"agent 做事不再请求确认,点这里修改",onClick:()=>{location.hash="#/settings/permissions"},children:[n.jsx(ee,{name:"alert"}),"完全访问"]}),n.jsx("span",{className:"spacer"}),n.jsx(gz,{client:e,sessionId:t.id,running:s}),n.jsx(dz,{context:h}),s&&n.jsxs("label",{className:"steer-toggle",title:"这一步做完 agent 就会看到;不勾选就等这一轮结束再发",children:[n.jsx("input",{type:"checkbox",checked:x,onChange:V=>b(V.target.checked)}),"插入当前轮次"]}),s&&n.jsxs("button",{className:"stop-button",onClick:()=>void t.cancel().catch(V=>j(String(V))),disabled:i,children:[n.jsx(rO,{}),"停止"]}),n.jsx("button",{className:"send-button","aria-label":"发送",title:"发送(Enter)",onClick:L,disabled:i||p.trim()===""&&P.length===0,children:n.jsx(ee,{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 vz=["压缩会把这个对话较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:","","· 会丢失记忆:早先的细节 agent 不再记得(具体的命令和输出、日志、截图、你说过的原话);","· 摘要可能漏掉或写错内容;","· 不能撤销。界面上的聊天记录还在,但 agent 看不到了。","","对话很长、回复变慢或报上下文超长时再压缩。"].join(`
196
+ `),Fl=4,yz=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function bz(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(yz.has(e.type)&&i.length<=Ap)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<=Ap)return{mediaType:"image/jpeg",data:h,name:s.replace(/\.\w+$/,".jpg"),url:d}}throw new Error("图片太大")}const qp=v.createContext(null);function kz(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<jz?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 jz=400;function sS(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 Nz=160;function cc(e,t=Nz){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 Yb(e,t="text"){return e.filter(s=>s.type===t).map(s=>s.text).join("")}function ec(e){const t=cc(Yb(e));if(t!=="")return t;const s=cc(Yb(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 wz(e,t=null,s={}){var P,H,B,O,T,D,U;const i=[],r=new Map,o=[],l=new Map,u=new Map,d=new Map;let h=null,f=null,p=null,g=0,x=0;const b=(A,I)=>{let R=r.get(A);return R===void 0&&(R=Tf(`t:${A}`,A,I,!0),r.set(A,R),i.push(R)),f=null,R},k=(A,I)=>h!==null?h:(f===null&&(f=Tf(`b:${I}`,null,A,!1),i.push(f)),f),j=(A,I,R,L)=>{let K=A.steps.get(R);return K===void 0&&(K={turn:I,step:R,start:L,startKnown:!1,end:null,records:[],retries:0},A.steps.set(R,K),A.stepOrder.push(R)),K},N=(A,I,R)=>{A.records.push(R),I==null||I.records.push(R),o.push(R)},C=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=Tf(`t:${A.turn}`,A.turn,A.time,!1);r.set(A.turn,I),i.push(I),h=I,f=null;break}case"turn/end":{const I=b(A.turn,A.time);I.end=A.time,I.reason=A.reason;for(const R of I.steps.values())R.end??(R.end=A.time);for(const R of l.values())R.turn===A.turn&&R.status==="running"&&(R.status="interrupted",R.end=A.time);h===I&&(h=null);break}case"step/start":{const I=b(A.turn,A.time),R=j(I,A.turn,A.step,A.time);R.start=A.time,R.startKnown=!0;break}case"step/end":{const I=b(A.turn,A.time);j(I,A.turn,A.step,A.time).end=A.time;break}case"user/message":{const I=k(A.time,A.seq);N(I,null,Sz(A,I.turn));break}case"system/message":{if(A.text.trim()==="")break;const I=b(A.turn,A.time),R=j(I,A.turn,A.step,A.time),L={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:cc(A.text),text:A.text};N(I,R,L);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=b(A.turn,A.time),R=j(I,A.turn,A.step,A.time);Mf(R,A.timing.firstTokenAt),R.retries+=1,A.error!==void 0&&(R.lastRetryError=A.error);const L={kind:"attempt",id:`attempt:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:A.timing.firstChunkAt??R.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}};N(I,R,L);break}case"assistant/message":{const I=b(A.turn,A.time),R=j(I,A.turn,A.step,A.time);Mf(R,A.timing.firstTokenAt),S.add(`${A.turn}:${A.step}`);const L=A.timing.firstTokenAt,K=A.timing.lastChunkAt,F=L!==void 0&&K!==void 0?K-L:void 0,q=A.model??(p==null?void 0:p.model),V=A.provider??(p==null?void 0:p.provider),Z={kind:"assistant",id:`assistant:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:R.start,end:K??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:Qb({index:C(R),provider:V,model:q,reasoningEffort:p==null?void 0:p.reasoningEffort,toolCount:p==null?void 0:p.toolCount,ttftMs:Xb(R),decodeMs:F,tokensPerSecond:_z((H=A.usage)==null?void 0:H.outputTokens,F),usage:A.usage,retries:R.retries,lastRetryError:R.lastRetryError})};N(I,R,Z);break}case"tool/call":{const I=b(A.turn,A.time),R=j(I,A.turn,A.step,A.time),L=d.get(A.callId),K={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:cc(A.arguments),name:A.name,callId:A.callId,arguments:A.arguments,isError:!1,...L===void 0?{}:{approval:{approvalId:L}}};l.set(A.callId,K),N(I,R,K);break}case"tool/result":{const I=l.get(A.callId);if(I===void 0){const L=b(A.turn,A.time),K=j(L,A.turn,A.step,A.time),F={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}};N(L,K,F);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 R=ec(A.content);R!==""&&(I.preview=`${cc(I.arguments,80)} ⇒ ${R}`);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?k(A.time,A.seq):b(A.turn,A.time),R={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,R),N(I,null,R);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=b(t.turn,((O=t.deltas[0])==null?void 0:O.time)??s.now??x),I=j(A,t.turn,t.step,((T=t.deltas[0])==null?void 0:T.time)??s.now??x),R=(D=t.deltas.find(q=>q.text!==""||q.toolName!==void 0))==null?void 0:D.time;Mf(I,R);const L=Ez(t.deltas),K=(U=t.deltas.at(-1))==null?void 0:U.time;K!==void 0&&(x=Math.max(x,K));const F={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(L)||"waiting for output…",content:L,live:!0,interrupted:!1,request:Qb({index:C(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:Xb(I),retries:I.retries,lastRetryError:I.lastRetryError})};N(A,I,F)}const _=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 R=A.steps.get(I);return{turn:R.turn,step:R.step,start:R.start,end:R.end,records:R.records}}),records:A.records})),z=s.now??x;return{groups:_,records:o,totals:Cz(o),span:Az(o,z)}}function Tf(e,t,s,i){return{key:e,turn:t,start:s,end:null,partialStart:i,steps:new Map,stepOrder:[],records:[]}}function Sz(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 Mf(e,t){t!==void 0&&(e.firstTokenAt===void 0||t<e.firstTokenAt)&&(e.firstTokenAt=t)}function Xb(e){if(!e.startKnown||e.firstTokenAt===void 0)return;const t=e.firstTokenAt-e.start;return t>=0?t:void 0}function _z(e,t){if(!(e===void 0||t===void 0||t<=0))return e/(t/1e3)}function Ez(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 Cz(e){const t={requests: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.usage:void 0;s.kind==="assistant"&&(t.requests+=1),i!==void 0&&(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 Az(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 Qb(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const iS=[{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"}],$z=new Map(iS.flatMap((e,t)=>e.kinds.map(s=>[s,t])));function Iz(e){return e.records.map(t=>{const s=t.end===null||t.end<=t.start,i={record:t,lane:$z.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 Tz(e,t){const s=e.end??e.start;return e.start<=t.end&&s>=t.start}function Mz(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 Rz(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 Oz(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 wn(e){return e==null?"—":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(e<1e4?2:1)}k`:`${(e/1e6).toFixed(2)}M`}function Xr(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 ax(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const Pz=5*6e4,rS=["周日","周一","周二","周三","周四","周五","周六"],Pd=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 Lz(e,t=Date.now()){const s=new Date(e),i=Math.round((Pd(t)-Pd(e))/864e5);return i<=0?tc(s):i===1?`昨天 ${tc(s)}`:i<7?`${rS[s.getDay()]} ${tc(s)}`:`${s.getFullYear()===new Date(t).getFullYear()?"":`${s.getFullYear()}年`}${s.getMonth()+1}月${s.getDate()}日 ${tc(s)}`}function aS(e,t){return e===void 0?!1:t===void 0||e-t>=Pz||Pd(e)!==Pd(t)}function zz(e){const t=new Date(e);return`${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日${rS[t.getDay()]} ${tc(t)}`}function oS({at:e}){return n.jsxs("div",{className:"time-divider",children:[n.jsx("span",{className:"time-short",children:Lz(e)}),n.jsx("span",{className:"time-full","aria-hidden":!0,children:zz(e)})]})}const Jb="agent_delegate",lS=v.createContext([]),Ko=v.createContext(cn.name);function Dc(e){return`#/h/${encodeURIComponent(e.id)}`}function Dz(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=qs(e).find(r=>r.name===t||r.id===t);return i===void 0?t===cn.name||t===cn.id?cn:void 0:Ya(i)}const Ra={running:{label:"进行中",tone:"running"},waiting:{label:"等回答",tone:"running"},done:{label:"交回了",tone:"ok"},failed:{label:"没做成",tone:"failed"}};function Fc({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(ee,{name:(s==null?void 0:s.icon)??"sparkles"})}),n.jsxs("span",{className:"exchange-who",children:[e,n.jsx(ee,{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(ee,{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 Fz({client:e,item:t,handOffs:s}){const{agent:i,task:r}=v.useMemo(()=>Dz(t.arguments),[t.arguments]),o=na(e,i),l=v.useContext(Ko),u=s.find(f=>f.callId===t.callId),d=t.status==="error"||t.status==="interrupted",h=d?Ra.failed:u===void 0?t.status==="running"?Ra.running:void 0:Ra[u.state];return n.jsxs("div",{className:"delegation",children:[n.jsx(Fc,{from:l,to:(o==null?void 0:o.name)??i,avatar:o,title:(u==null?void 0:u.title)??r.split(`
197
+ `)[0]??"",state:h,href:u===void 0?void 0:Dc(u)}),d&&n.jsxs("div",{className:"delegation-failed",children:[n.jsx(ee,{name:"alert"}),t.result??t.error??"没有交出去"]})]})}function Uz({client:e,handOff:t}){const s=na(e,t.to);return n.jsx("div",{className:"delegation app-handoff",children:n.jsx(Fc,{from:t.by,to:(s==null?void 0:s.name)??t.to,avatar:s,title:t.title,state:Ra[t.state],href:Dc(t)})})}function Bz({client:e,note:t,handOffs:s}){const i=na(e,t.agent),r=v.useContext(Ko),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?Dc(o):i!==void 0?`#/a/${encodeURIComponent(i.id)}`:void 0;return n.jsx("div",{className:"delegation relay-line",children:n.jsx(Fc,{from:t.agent,to:r,avatar:i,title:t.title,state:t.ok?Ra.done:{label:"没有做完",tone:"failed"},href:l})})}function Hz({client:e,note:t,handOffs:s}){const i=na(e,t.from),r=v.useContext(Ko),o=s.find(l=>l.id===t.thread);return n.jsx("div",{className:"delegation task-line",children:n.jsx(Fc,{from:t.from,to:r,avatar:i,title:t.text.split(`
198
+ `)[0]??t.title,state:{label:cS[t.kind],tone:t.kind==="question"?"asked":"ok"},href:o===void 0?void 0:Dc(o)})})}function Zz({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===Dg?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(Fc,{from:t.by,to:(u==null?void 0:u.name)??o.to,avatar:l,title:t.title,state:Ra[o.state],href:Dc(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(ee,{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(ee,{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 Wz({client:e,handOff:t,name:s}){const i=ke(e.sessions).items.find(d=>d.id===t.toSession),r=rx(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 Vz(e,t){const s=ke(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 qz(e,t){var h,f;const s=(h=t==null?void 0:t.chain)==null?void 0:h.at(-2),i=(f=t==null?void 0:t.chain)==null?void 0:f.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 b,k;const g=(b=p.chain)==null?void 0:b.at(-2),x=(k=p.chain)==null?void 0:k.at(-1);(g===s&&x===i||g===i&&x===s)&&o(j=>j.some(N=>N.id===p.id)?j.map(N=>N.id===p.id?p:N):[...j,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 Gz(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(MD,{client:e,session:o.toSession,from:o.startedAt,to:o.endedAt,onOpen:i})}),(o.messages??[]).forEach((h,f)=>{h.kind!=="done"&&r.push({kind:"said",key:`${o.id}:${f}`,thread:o.id,at:h.at,who:s(h.from),kindOf:h.kind,body: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(Wz,{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 Kz({client:e,id:t,onClose:s}){const{item:i,error:r}=Vz(e,t),[o,l]=v.useState(null),u=qs(e),d=na(e,(i==null?void 0:i.by)??""),h=na(e,(i==null?void 0:i.to)??""),{threads:f,ready:p}=qz(e,i),g=TD(e,f),x=P=>{var H;return((H=u.find(B=>B.id===P))==null?void 0:H.name)??(P===cn.id?cn.name:P)},b=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:Ya(H)},k=i===null?[]:Gz(e,f,x,l),j=v.useRef(null),N=v.useRef(!1);if(v.useLayoutEffect(()=>{const P=j.current;if(N.current||P===null||i===null||!p)return;N.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,f,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 C=(h==null?void 0:h.name)??i.to,S=Ra[i.state],_=[];let z;for(const P of k){const H=P.at===Number.MAX_SAFE_INTEGER?void 0:P.at;if(H!==void 0&&aS(H,z)&&_.push(n.jsx(oS,{at:H},`t:${P.key}`)),H!==void 0&&(z=H),P.kind==="aside"){_.push(n.jsx("div",{className:"exchange-aside","data-thread":P.thread,children:P.body},P.key));continue}const B=b(P.who);_.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(ee,{name:(B==null?void 0:B.icon)??"sparkles"})}),n.jsx("strong",{children:P.kindOf===void 0||P.kindOf==="done"?P.who:`${P.who} · ${cS[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(ee,{name:(d==null?void 0:d.icon)??"calendar"})}),n.jsx("span",{children:i.by}),n.jsx(ee,{name:"arrow",className:"delegation-arrow"}),n.jsx("span",{className:`agent-avatar small agent-${(h==null?void 0:h.id)??"unknown"}`,children:n.jsx(ee,{name:(h==null?void 0:h.icon)??"sparkles"})}),n.jsx("h1",{children:C})]}),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(ux.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(CS,{tasks:g,labels:Yz,current:o==null?void 0:o.id,onOpen:l})}),n.jsx("div",{className:"chat",ref:j,children:n.jsx("div",{className:"chat-inner",children:_})}),o!==null&&n.jsx(hx,{client:e,task:o,parent:C,trail:i.by===C?[]:[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(ee,{name:"close"}),"关闭"]})})]})}const Yz=new Map,cS={question:"问",answer:"答",update:"说",done:"结论"};function Rf({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 Fw(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(ee,{name:s==="copied"?"check":"copy"})})}const Xz=3,Qz=/^(编排|游戏信息|干预)[::]/,ek="adg:skill-offer:off",tk=e=>`adg:skill-offer:${e}`;function nk(e){try{return localStorage.getItem(e)}catch{return null}}function sk(e,t){try{localStorage.setItem(e,t)}catch{}}function Jz(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<Xz||((r=s.at(-1))==null?void 0:r.kind)!=="assistant"))return e[t].id}function eD({session:e,title:t,items:s}){const i=Jz(s),[r,o]=v.useState(()=>nk(ek)==="1"),[l,u]=v.useState(()=>nk(tk(e.id))),[d,h]=v.useState(!1);if(i===void 0||r||l===i||t!==null&&Qz.test(t))return null;const f=()=>{sk(tk(e.id),i),u(i)},p=async()=>{h(!0);try{await e.prompt(tw),f()}finally{h(!1)}};return n.jsxs("div",{className:"skill-offer",role:"region","aria-label":"存成技能",children:[n.jsx(ee,{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:()=>{sk(ek,"1"),o(!0)},children:"不再提示"}),n.jsx("button",{className:"small-button",disabled:d,onClick:f,children:"这次不用"}),n.jsx("button",{className:"small-button primary",disabled:d,onClick:()=>void p(),children:"存成技能"})]})]})}function tD(e,t){const s=ke(e.connection.status),i=ke(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(f=>f.id===u.id)<0?[...d,u]:d.map(f=>f.id===u.id?u:f)))},[e,l]),l?r:nD}const nD=[];function sD(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 f=e[h];"time"in f&&typeof f.time=="number"&&(l=f.time),o[h]=l}const u=[];let d=0;for(e.forEach((h,f)=>{if(i(h))for(;d<r.length&&r[d].at<o[f];)u.push(ik(r[d++]));u.push(h)});d<r.length;)u.push(ik(r[d++]));return u}function ik(e){return{kind:"sent",id:`sent:${e.id}`,notice:e}}const iD={info:"send",success:"check",warning:"alert",error:"alert"};function rD({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(f=>o(Ce(f))).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(ee,{name:iD[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(ee,{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(ee,{name:"check"}),t.done]}),r!==null&&n.jsx("div",{className:"error small",children:r})]})}const aD=80,oD=[];function uS({client:e,session:t,state:s,readOnly:i}){var re,X,se;const r=v.useMemo(()=>nh(s.events,s.live,s.pending,s.queue),[s.events,s.live,s.pending,s.queue,s.version]),o=v.useMemo(()=>r.filter(ae=>!kS(ae)),[r]),l=v.useMemo(()=>vS(s.events),[s.events]),u=v.useMemo(()=>bS(r,l),[r,l]),d=v.useMemo(()=>SS(r,l),[r,l]),h=_S(e,t.id),f=qs(e),p=ke(e.sessions).items.find(ae=>ae.id===t.id),g=p===void 0?vn:Da(p,f),x=Yw(e,vn),b=tD(e,p!==void 0?p.home===vn:x.sessionId===t.id),[k,j]=v.useState(!1),N=k||(s.status==="open"?b!==null:s.status!=="opening");N&&!k&&j(!0);const C=N&&b!==null?b:oD,S=s.hasMore?((re=s.events[0])==null?void 0:re.time)??0:0,_=v.useMemo(()=>hD(sD(o,C,S,hS)),[o,C,S]),z=v.useContext(cx),P=v.useContext(Ko),H=z!==null?P:((X=f.find(ae=>ae.id===g))==null?void 0:X.name)??cn.name,[B,O]=AD((p==null?void 0:p.role)??vn),T=z===null?B:3,D=v.useMemo(()=>dD(_,T),[_,T]),U=v.useMemo(()=>{let ae;return D.map(_e=>{const ze=cD(_e),Te=aS(ze,ae)?ze:void 0;return ze!==void 0&&(ae=ze),Te})},[D]),[A,I]=v.useState(null),R=v.useContext(qp),L=N&&z===null&&R===null?n.jsx(CS,{tasks:h,labels:d,current:A==null?void 0:A.id,onOpen:I}):null,K=N&&z===null&&_.some(ae=>dS(ae)>1),F=RL(e,t.id),q=F.filter(ae=>ae.fromSession===t.id&&ae.callId===void 0&&(ae.state==="running"||ae.state==="waiting")),V=v.useRef(null),Z=sS(aD),Q=Z.following,G=ae=>{Z.onScroll(ae),ae.currentTarget.scrollTop<40&&s.hasMore&&!s.loadingOlder&&t.loadOlder()};v.useLayoutEffect(()=>{const ae=V.current;ae!==null&&Q.current&&(ae.scrollTop=ae.scrollHeight)},[o,C,N]),kz(V,Q);const ne=(se=s.events[0])==null?void 0:se.seq,te=v.useRef(0);return v.useLayoutEffect(()=>{const ae=V.current;ae!==null&&(te.current!==0&&!Q.current&&(ae.scrollTop+=ae.scrollHeight-te.current),te.current=ae.scrollHeight)},[ne]),n.jsx(lh.Provider,{value:e,children:n.jsx(lS.Provider,{value:F,children:n.jsx(Ko.Provider,{value:H,children:n.jsx(ux.Provider,{value:(R==null?void 0:R.openTask)??I,children:n.jsx(lx.Provider,{value:u,children:n.jsx(yS.Provider,{value:l,children:n.jsxs("div",{className:`chat-split ${A===null?"":"with-pane"}`,children:[(K||L!==null)&&n.jsxs("div",{className:"chat-corner",children:[L,K&&n.jsx(ID,{detail:B,onChange:O})]}),n.jsx("div",{className:"chat",ref:V,onScroll:G,onWheel:Z.onWheel,children:n.jsxs("div",{className:"chat-inner",children:[N&&s.hasMore&&n.jsx("button",{className:"link-button load-older",disabled:s.loadingOlder,onClick:()=>void t.loadOlder(),children:s.loadingOlder?"加载中…":"加载更早的消息"}),!N&&n.jsx("div",{className:"empty",children:"正在打开会话…"}),N&&s.status!=="opening"&&o.length===0&&n.jsxs("div",{className:"empty chat-empty",children:[n.jsx(Wg,{size:"lg"}),n.jsx("h2",{children:"今天,先从哪个游戏开始?"}),n.jsxs("p",{children:["问问哪些活动快结束、新版本有什么,或者让它把今天的日常清掉。",n.jsx("br",{}),"在下方写下来就行。"]})]}),N&&D.map((ae,_e)=>n.jsx(uD,{at:U[_e],children:ae.kind==="sent"?n.jsx(rD,{client:e,notice:ae.item.notice},ae.item.id):ae.kind==="tools"?n.jsx(Ul,{name:H,header:ae.header,children:n.jsx(fS,{tools:ae.tools})},ae.id):ae.kind==="delegation"?n.jsx(Ul,{name:H,header:ae.header,children:n.jsx(Fz,{client:e,item:ae.item,handOffs:F})},ae.item.id):ae.kind==="subtask"?n.jsx(Ul,{name:H,header:ae.header,children:n.jsx(ED,{client:e,item:ae.item})},ae.item.id):ae.kind==="process"?n.jsx(Ul,{name:H,header:ae.header,children:n.jsx(vD,{items:ae.items,active:s.running&&_e===D.length-1,onDismiss:ze=>t.dismissPending(ze)})},ae.id):n.jsx(Ul,{name:H,header:ae.header,children:n.jsx(mS,{item:ae.item,onDismiss:ze=>t.dismissPending(ze)})},ae.item.id)},lD(ae))),N&&q.map(ae=>n.jsx(Uz,{client:e,handOff:ae},ae.id)),N&&s.running&&s.live===null&&n.jsxs("div",{className:"thinking",children:[n.jsxs("span",{className:"dot-pulse",children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]}),"正在处理…"]}),N&&i!==!0&&!s.running&&s.queue.length===0&&n.jsx(eD,{session:t,title:s.title,items:o})]})}),A!==null&&R===null&&n.jsx(hx,{client:e,task:A,parent:H,trail:g===vn?[]:[cn.name],onClose:()=>I(null)},A.id)]})})})})})})})}function lD(e){return e.kind==="sent"?e.item.id:e.kind==="tools"||e.kind==="process"?e.id:e.item.id}function cD(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 uD({at:e,children:t}){return n.jsxs(n.Fragment,{children:[e!==void 0&&n.jsx(oS,{at:e}),t]})}function dS(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=BN(e.item.text);return ZN(e.item.text)!==void 0||HN(e.item.text)!==void 0||t!==void 0&&t.by!==Dg?2:1}}}function dD(e,t){if(t>1)return e;const s=[];let i=null;for(const r of e)r.kind==="sent"?s.push(r):dS(r)>1?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"))?(s.push({...r,header:i}),i=null):s.push(r);return s}function hD(e){const t=[];let s=0;for(let i=0;i<=e.length;i++){const r=e[i];r!==void 0&&r.kind!=="sent"&&!hS(r)||(mD(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 hS(e){return e.kind==="user"||e.kind==="context"&&e.startsTurn===!0}function mD(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===Jb)t.push({kind:"delegation",item:h,header:r()});else if(h.kind==="tool"&&h.name===Gp)t.push({kind:"subtask",item:h,header:r()});else if(h.kind==="tool"){const f=t.at(-1);(f==null?void 0:f.kind)==="tools"?t[t.length-1]={...f,tools:[...f.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 f=e[h];if(f.kind==="assistant"&&f.text.trim()!==""){d=h;break}}for(let h=0;h<d;h++){const f=e[h];f.kind==="notice"||f.kind==="context"||f.kind==="tool"&&(f.approval==="asked"||f.name===Jb||f.name===Gp)?(u(),o(f)):l.push(f)}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(Wg,{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 fD({text:e}){const t=P2(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 pD=/^(这条消息来自([^。)]+)。[^\n]*)\n/,gD=/^(距离这个对话的上一条消息已经过了[^\n]*)\n/;function xD(e){const t=pD.exec(e),s=(t===null?e:e.slice(t[0].length)).replace(gD,"");return t===null?{text:s}:{text:s,channel:t[1]}}const mS=v.memo(function({item:t,onDismiss:s}){var l;const i=v.useContext(lh),r=v.useContext(lS),o=v.useContext(cx);switch(t.kind){case"user":{if(o!==null)return n.jsxs("div",{className:"msg user delegated",children:[n.jsxs("div",{className:"msg-from",children:[o,"交给的事"]}),n.jsx("div",{className:"bubble",children:n.jsx(Hs,{text:kc(t.text)})}),n.jsx("div",{className:"msg-actions",children:n.jsx(Rf,{text:kc(t.text)})})]});const u=t.pending===void 0?ZN(t.text):void 0;if(u!==void 0&&i!==null)return n.jsx(Bz,{client:i,note:u,handOffs:r});const d=t.pending===void 0?HN(t.text):void 0;if(d!==void 0&&i!==null)return n.jsx(Hz,{client:i,note:d,handOffs:r});const h=t.pending===void 0?BN(t.text):void 0;if(h!==void 0&&i!==null)return n.jsx(Zz,{client:i,note:h,handOffs:r});const f=xD(t.text);return n.jsxs("div",{className:`msg user ${t.pending===void 0?"":"pending"}`,children:[f.channel!==void 0&&n.jsxs("div",{className:"msg-from",children:["来自",f.channel]}),n.jsxs("div",{className:"bubble",children:[n.jsx(fD,{text:f.text}),t.imageRefs.length>0&&n.jsx("div",{className:"chat-images",children:t.imageRefs.map(p=>n.jsx(Ew,{image:p},p.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(ee,{name:"image"}),t.images-t.imageRefs.length," 张图片"]}),t.files>0&&n.jsxs("span",{children:[n.jsx(ee,{name:"paperclip"}),t.files," 个文件"]})]})]}),((l=t.pending)==null?void 0:l.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:"移除"})]}),f.text.trim()!==""&&n.jsx("div",{className:"msg-actions",children:n.jsx(Rf,{text:f.text})})]})}case"assistant":return!t.live&&KR(t.text)?n.jsxs("div",{className:"quiet-reply",children:[n.jsx(ee,{name:"check"}),"看过了,没有要告诉你的"]}):n.jsxs("div",{className:`msg assistant ${t.live?"live":""}`,children:[t.reasoning.trim()!==""&&n.jsxs("details",{className:"reasoning",open:t.live&&t.text==="",children:[n.jsxs("summary",{children:[n.jsx(ee,{name:"chevron"}),t.live&&t.text===""?n.jsx("span",{className:"shimmer",children:"正在思考…"}):"思考过程"]}),n.jsx(Hs,{text:t.reasoning})]}),t.text!==""&&n.jsx(Hs,{text:t.text}),t.live&&n.jsx("span",{className:"cursor"}),t.interrupted&&n.jsx("div",{className:"muted small",children:"(已中断)"}),!t.live&&t.text.trim()!==""&&n.jsx("div",{className:"msg-actions",children:n.jsx(Rf,{text:t.text})})]});case"tool":return n.jsx(fS,{tools:[t]});case"context":return n.jsxs("details",{className:"context-row",children:[n.jsxs("summary",{children:[n.jsx(ee,{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(ee,{name:"alert"}),t.text]})}});function vD({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?yD(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(ee,{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(ee,{name:"chevron-down",className:`chevron-icon ${l?"open":""}`})]}),l&&e.map(h=>h.kind==="tool"?n.jsx(gS,{item:h},h.id):n.jsx("div",{className:"process-note",children:n.jsx(mS,{item:h,onDismiss:s})},h.id))]})}function yD(e){return e.kind==="tool"?`${e.name} ${Bg(e.arguments)}`.trim():e.kind==="assistant"?e.text.trim().split(`
199
+ `)[0]||"正在思考…":""}function fS({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(ee,{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(ee,{name:"chevron-down",className:`chevron-icon ${o?"open":""}`})]}),o&&e.map(l=>n.jsx(gS,{item:l},l.id))]})}const pS={running:"运行中",ok:"完成",error:"失败",interrupted:"已中断"};function gS({item:e}){const[t,s]=v.useState(!1),i=v.useMemo(()=>Bg(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(bD,{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:kD(e.approval)}),n.jsx("span",{className:"tool-status",children:pS[e.status]})]}),e.images!==void 0&&n.jsx("div",{className:"chat-images tool-images",children:e.images.map(r=>n.jsx(Ew,{image:r},r.attachmentId))}),t&&n.jsxs("div",{className:"tool-body",children:[n.jsx("div",{className:"label",children:"参数"}),n.jsx("pre",{children:ax(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 bD({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(ee,{name:"check"})}):e==="error"?n.jsx("span",{className:"tool-icon error",role:"img","aria-label":"失败",children:n.jsx(ee,{name:"close"})}):n.jsx("span",{className:"tool-icon",role:"img","aria-label":pS[e]??e,children:n.jsx(ee,{name:"info"})})}function kD(e){switch(e){case"asked":return"等待审批";case"allowed-once":return"已允许";case"rejected":return"已拒绝";case"cancelled":return"已撤回";default:return e}}const Gp="subagent",xS=/started subagent (\S+)/;function vS(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 yS=v.createContext(new Map),ox=(e,t)=>e===void 0?void 0:t.get(e)??e,jD=/\s*Your (?:parent agent\b|final answe)[\s\S]*$/;function kc(e){return e.replace(jD,"")}const ND=/^Background subagent (\S+) (finished|was stopped)?/;function bS(e,t){const s=new Map;for(const i of e){if(!kS(i))continue;const r=ND.exec(i.summary);r!==null&&s.set(ox(r[1],t),r[2]==="finished"?jc:r[2]==="was stopped"?wD:wS)}return s}function kS(e){return e.kind==="context"&&e.title==="subagent-settled"}const lx=v.createContext(new Map),cx=v.createContext(null),ux=v.createContext(()=>{});function jS(e){try{const t=JSON.parse(e);return{description:String(t.description??""),prompt:String(t.prompt??"")}}catch{return{description:"",prompt:e}}}function NS(e,t){return ke(e.sessions).items.find(s=>s.id===t)}const dx={label:"进行中",tone:"running"},jc={label:"完成",tone:"ok"},wD={label:"已停止",tone:"failed"},wS={label:"没做成",tone:"failed"};function SD({client:e,id:t,running:s}){const i=sh(e,t);return i===null?n.jsx("div",{className:"subtask-steps muted small",children:"正在打开…"}):n.jsx(_D,{handle:i,running:s})}function _D({handle:e,running:t}){const s=ke(e.state),i=v.useMemo(()=>nh(s.events,s.live,s.pending).filter(o=>o.kind==="tool"),[s.events,s.live,s.pending,s.version]);if(i.length===0)return n.jsx("div",{className:"subtask-steps muted small",children:t?"正在开始…":"没有用工具"});const r=t?i.slice(-4):i;return n.jsx("ol",{className:"subtask-steps",children:r.map(o=>n.jsxs("li",{className:o.status==="error"?"failed":"",children:[o.status==="running"?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(ee,{name:o.status==="error"?"alert":"check"}),n.jsx("span",{className:"subtask-step-name",children:o.name}),n.jsx("span",{className:"subtask-step-args",children:Bg(o.arguments)})]},o.id))})}function ED({client:e,item:t}){var C;const s=v.useContext(ux),{description:i,prompt:r}=v.useMemo(()=>jS(t.arguments),[t.arguments]),o=ox((C=xS.exec(t.result??""))==null?void 0:C[1],v.useContext(yS)),l=NS(e,o),u=t.status==="error"||t.status==="interrupted",d=!u&&((l==null?void 0:l.running)??t.status==="running"),h=v.useContext(lx),f=u?wS:d?dx:(o===void 0?void 0:h.get(o))??jc,p=rx(e,l===void 0?[]:[{id:l.id,updatedAt:l.updatedAt,running:l.running}]),g=o===void 0?void 0:p.get(o),[x,b]=v.useState(!1),k=i!==""?i:r.split(`
200
+ `)[0]??"子任务",j=n.jsxs("span",{className:`delegation-state tone-${f.tone}`,children:[f.tone==="running"&&n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),f.label]}),N=o!==void 0&&(d||x);return n.jsxs("div",{className:`subtask tone-${f.tone}`,children:[n.jsxs("div",{className:"subtask-head",children:[n.jsx(ee,{name:"flow"}),n.jsx("strong",{className:"subtask-label",title:r,children:k}),j,o!==void 0&&n.jsx("button",{className:"link-button subtask-open",onClick:()=>s({id:o,label:k}),children:"看完整过程"})]}),u&&n.jsxs("div",{className:"delegation-failed",children:[n.jsx(ee,{name:"alert"}),t.result??t.error??"没有开起来"]}),N&&n.jsx(SD,{client:e,id:o,running:d}),!d&&g!=null&&g!==""&&n.jsx("div",{className:"subtask-answer",children:n.jsx(Hs,{text:g})}),!d&&o!==void 0&&n.jsxs("button",{className:"link-button subtask-fold","aria-expanded":x,onClick:()=>b(S=>!S),children:[n.jsx(ee,{name:x?"chevron-down":"chevron"}),x?"收起步骤":"看步骤"]})]})}function hx({client:e,task:t,parent:s,trail:i,onClose:r}){const o=sh(e,t.id),l=NS(e,t.id),[u,d]=v.useState(null),h=(l==null?void 0:l.running)===!0,f=()=>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 f(),children:[n.jsx(ee,{name:"close"}),"停止"]}),n.jsx("button",{className:"icon-button","aria-label":"关闭",title:"关闭",onClick:r,children:n.jsx(ee,{name:"close"})})]}),u!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{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(CD,{client:e,handle:o,parent:s})})]})}function CD({client:e,handle:t,parent:s}){const i=ke(t.state);return n.jsx(cx.Provider,{value:s,children:n.jsx(Ko.Provider,{value:`${s}的子 agent`,children:n.jsx(uS,{client:e,session:t,state:i,readOnly:!0})})})}const rk="adg.chatDetail.";function AD(e){const t=()=>{try{return Number(localStorage.getItem(rk+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(rk+e,String(o))}catch{}}]}const $D=[{level:1,label:"汇报",hint:"只看它和你说的话"},{level:3,label:"全部",hint:"加上 agent 之间的往来和子任务的步骤、答案"}];function ID({detail:e,onChange:t}){return n.jsx("div",{className:"chat-detail segmented-control",role:"radiogroup","aria-label":"显示多少",children:$D.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 SS(e,t){var i;const s=new Map;for(const r of e){if(r.kind!=="tool"||r.name!==Gp)continue;const o=ox((i=xS.exec(r.result??""))==null?void 0:i[1],t);if(o===void 0)continue;const{description:l,prompt:u}=jS(r.arguments),d=l!==""?l:u.split(`
201
+ `)[0]??"";d!==""&&s.set(o,d)}return s}function _S(e,t){const s=ke(e.sessions).items;return v.useMemo(()=>s.filter(i=>i.origin==="subagent"&&i.parentId===t),[s,t])}function ES(e,t,s,i){return e.origin==="subagent"&&e.parentId===t&&e.updatedAt>=s&&(i===void 0||e.updatedAt<=i+2e3)}function TD(e,t){const s=ke(e.sessions).items;return v.useMemo(()=>s.filter(i=>t.some(r=>ES(i,r.toSession,r.startedAt,r.endedAt))),[s,t])}const Of=30;function CS({tasks:e,labels:t,current:s,onOpen:i}){const r=v.useContext(lx),[o,l]=v.useState(!1),u=v.useRef(null),d=mn(6e4);v.useEffect(()=>{if(!o)return;const k=N=>{var C;(C=u.current)!=null&&C.contains(N.target)||l(!1)},j=N=>{N.key==="Escape"&&l(!1)};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",j),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",j)}},[o]);const h=[...e].sort((k,j)=>j.updatedAt-k.updatedAt),f=h.filter(k=>k.running),p=h.filter(k=>!k.running);if(e.length===0)return null;const g=k=>t.get(k.id)??(kc(k.title??"")||"子任务"),x=k=>{const j=k.running?dx:r.get(k.id)??jc,N=g(k);return n.jsx("li",{children:n.jsxs("button",{className:`subtask-tracker-row ${k.id===s?"active":""}`,title:N,onClick:()=>{l(!1),i({id:k.id,label:N})},children:[k.running?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(ee,{name:j===jc?"check":"alert",className:`tone-${j.tone}`}),n.jsx("span",{className:"subtask-tracker-label",children:N}),n.jsx("span",{className:`delegation-state tone-${j.tone}`,children:k.running?j.label:`${j.label} · ${gt(k.updatedAt,d)}`}),n.jsx(ee,{name:"chevron",className:"exchange-open"})]})},k.id)},b=f.length>0?`${f.length} 个子任务在跑`:"子任务";return n.jsxs("div",{ref:u,className:"subtask-tracker",children:[n.jsxs("button",{type:"button",className:`subtask-tracker-toggle ${f.length>0?"tone-running":""}`,"aria-haspopup":"dialog","aria-expanded":o,title:`进行中 ${f.length} 个,已结束 ${p.length} 个;点开看每一个的窗口`,onClick:()=>l(k=>!k),children:[f.length>0?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(ee,{name:"flow"}),n.jsx("span",{children:b}),p.length>0&&n.jsxs("span",{className:"subtask-tracker-ended",children:["已结束 ",p.length]}),n.jsx(ee,{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:f.length})]}),f.length===0?n.jsx("p",{className:"muted small subtask-tracker-empty",children:"现在没有在跑的子任务"}):n.jsx("ul",{children:f.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,Of).map(x)}),p.length>Of&&n.jsxs("p",{className:"muted small subtask-tracker-empty",children:["更早的 ",p.length-Of," 个在对话里"]})]})]})]})}function MD({client:e,session:t,from:s,to:i,onOpen:r}){const o=ke(e.sessions).items.filter(l=>ES(l,t,s,i));return o.length===0?null:n.jsx("div",{className:"delegation thread-subtasks",children:o.map(l=>{const u=kc(l.title??"")||"子任务",d=l.running?dx:jc;return n.jsxs("button",{className:`exchange-line subtask-line tone-${d.tone}`,onClick:()=>r({id:l.id,label:u}),children:[n.jsx(ee,{name:"flow"}),n.jsx("span",{className:"exchange-who",children:"子任务"}),n.jsx("span",{className:"exchange-title",children:u}),n.jsxs("span",{className:`delegation-state tone-${d.tone}`,children:[d.tone==="running"&&n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),d.label]}),n.jsx(ee,{name:"chevron",className:"exchange-open"})]},l.id)})})}const AS=[{id:"tasks",icon:"list",title:"子任务",hint:"子任务:正在做和做完的,点开看每一个的对话"},{id:"commands",icon:"terminal",title:"命令",hint:"命令:这个对话和它的子任务运行的命令和程序"},{id:"browser",icon:"globe",title:"浏览器",hint:"内置浏览器:看 agent 操作网页,也可以自己接手"}];function ak({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(ee,{name:"close"})})]}),n.jsx("div",{className:"side-panel-body",children:i})]})}const RD={label:"进行中",tone:"running"},ok={label:"完成",tone:"ok"};function $S(e,t){return t.get(e.id)??(kc(e.title??"")||"子任务")}function OD({tasks:e,labels:t,settled:s,onOpen:i}){const r=mn(6e4),o=[...e].sort((h,f)=>f.updatedAt-h.updatedAt),l=o.filter(h=>h.running),u=o.filter(h=>!h.running),d=h=>{const f=h.running?RD:s.get(h.id)??ok,p=$S(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(ee,{name:f===ok?"check":"alert",className:`tone-${f.tone}`}),n.jsx("span",{className:"subtask-tracker-label",children:p}),n.jsx("span",{className:`delegation-state tone-${f.tone}`,children:h.running?f.label:`${f.label} · ${gt(h.updatedAt,r)}`}),n.jsx(ee,{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 PD=new Set(["pwsh","bash","run_code"]);function LD(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 IS(e){return e.filter(t=>t.kind==="tool"&&PD.has(t.name))}function zD({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,Pf),[s]);return n.jsxs("div",{className:"side-list commands",children:[r.map(o=>n.jsx(DD,{client:e,task:o,label:$S(o,i)},o.id)),n.jsx(mx,{title:"这个对话",running:!1,commands:t,empty:"这个对话自己没有运行命令(命令多由子任务运行)"}),s.length>Pf&&n.jsxs("p",{className:"muted small side-note",children:["更早的 ",s.length-Pf," 个子任务的命令在它们的对话里(子任务面板)"]})]})}const Pf=8;function DD({client:e,task:t,label:s}){const i=sh(e,t.id);return i===null?n.jsx(mx,{title:s,running:t.running,commands:[],empty:"正在打开…"}):n.jsx(FD,{handle:i,label:s,running:t.running})}function FD({handle:e,label:t,running:s}){const i=ke(e.state),r=v.useMemo(()=>IS(nh(i.events,i.live,i.pending)),[i.events,i.live,i.pending,i.version]);return r.length===0&&!s?null:n.jsx(mx,{title:t,running:s,commands:r,empty:"还没有运行命令"})}function mx({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(ee,{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(UD,{item:u},u.id))}))]})}function UD({item:e}){const{text:t,description:s,program:i}=LD(e),[r,o]=v.useState(e.status==="error"),l=mn(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(ee,{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))} 秒`:gt(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>lk?`…
202
+ ${u.slice(-lk)}`:u})]})]})}const lk=6e3,Lf=new Map;function TS(e,t){let s=Lf.get(t);return s===void 0&&(s=e.connection.call("games/image",{url:t}).then(i=>`data:${i.mediaType};base64,${i.data}`),s.catch(()=>Lf.delete(t)),Lf.set(t,s)),s}function MS(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 TS(e,l).catch(()=>{});if(u!==void 0){o&&i(u);return}}})(),()=>{o=!1}},[e,r.join(`
203
+ `)]),s}function Xa(e,t){const[s,i]=v.useState(void 0);return v.useEffect(()=>{if(i(void 0),t===void 0)return;let r=!0;return TS(e,t).then(o=>{r&&i(o)},()=>{}),()=>{r=!1}},[e,t]),s}const RS=["image/png","image/jpeg","image/gif","image/webp","image/avif"],BD=8*1024*1024;function Kp(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 HD(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 ck(e,t){return e===void 0?"":new Date(e+Kp(e,t)).toISOString().slice(0,16)}function uk(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-Kp(i-Kp(i,t),t)}function ZD(e){return new Promise((t,s)=>{if(!RS.includes(e.type)){s(new Error("只支持 png、jpg、gif、webp、avif 图片"));return}if(e.size>BD){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 fx({client:e,game:t,activity:s,onDone:i,onCancel:r}){var T;const o=t.timezone,l={name:(s==null?void 0:s.name)??"",kind:(s==null?void 0:s.kind)??"",startsAt:ck(s==null?void 0:s.startsAt,o),endsAt:ck(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,f]=v.useState(null),[p,g]=v.useState(!1),[x,b]=v.useState(!1),[k,j]=v.useState(null),N=v.useRef(null),C=((T=s==null?void 0:s.own)==null?void 0:T.fields.includes("cover"))===!0,S=Xa(e,p||s==null?void 0:s.cover),_=(h==null?void 0:h.src)??S,z=s!==void 0&&(s.sources!==void 0||s.screen!==void 0);v.useEffect(()=>{j(null)},[u]);const P=D=>U=>d(A=>({...A,[D]:U.target.value})),H=D=>{D!==void 0&&ZD(D).then(U=>{f(U),g(!1)},U=>j(Ce(U)))},B=D=>{const U=[...D.clipboardData.files].find(A=>A.type.startsWith("image/"));U!==void 0&&(D.preventDefault(),H(U))},O=async()=>{if(u.name.trim()===""){j("活动要有名字");return}const D=u.startsAt===""?null:uk(u.startsAt,o)??null,U=u.endsAt===""?null:uk(u.endsAt,o)??null;if(D!==null&&U!==null&&U<=D){j("结束时间要晚于开始时间");return}const A=L=>s===void 0||u[L]!==l[L],I=L=>A(L)?{[L]:u[L].trim()===""?null:u[L].trim()}:{},R={game:t.id,...s===void 0?{}:{activityId:s.id},...I("name"),...I("kind"),...I("url"),...I("description"),...A("startsAt")?{startsAt:D}:{},...A("endsAt")?{endsAt:U}:{},...h!==null?{image:h.image}:p?{cover:null}:{}};b(!0),j(null);try{i(await e.connection.call("games/activity/save",R))}catch(L){j(Ce(L))}finally{b(!1)}};return n.jsxs("form",{className:"activity-editor",onSubmit:D=>{D.preventDefault(),O()},onPaste:B,onKeyDown:D=>{D.key==="Escape"&&r()},children:[n.jsxs("div",{className:"activity-editor-head",children:[n.jsx("strong",{children:s===void 0?`添加${t.name}的活动`:"编辑活动"}),z&&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 ${_===void 0?"empty":""}`,onClick:()=>{var D;return(D=N.current)==null?void 0:D.click()},title:"选一张图片(也可以直接粘贴)",children:_!==void 0?n.jsx("img",{src:_,alt:""}):n.jsxs(n.Fragment,{children:[n.jsx(ee,{name:"image"}),n.jsx("span",{children:"选图片"}),n.jsx("small",{children:"或粘贴"})]})}),n.jsx("input",{ref:N,type:"file",accept:RS.join(","),hidden:!0,onChange:D=>{var U;H((U=D.target.files)==null?void 0:U[0]),D.target.value=""}}),n.jsxs("div",{className:"activity-image-tools",children:[n.jsx("span",{className:"muted small",children:_===void 0?"点上面选图,或直接粘贴":"点图片换一张,或直接粘贴"}),(h!==null||C&&!p)&&n.jsx("button",{type:"button",className:"link-button small muted",onClick:()=>{f(null),C&&g(!0)},children:h!==null?"不用这张":z?"用回来源的图":"去掉图片"})]})]}),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:["时间按游戏服务器时间(",HD(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:"取消"}),k!==null&&n.jsx("span",{className:"tone-error small",children:k})]})]})}const ai=864e5,dk={name:"名字",startsAt:"开始时间",endsAt:"结束时间",kind:"类型",description:"说明",url:"页面",cover:"图片"},zf=2,WD=28,Qr=["#3b82c4","#c0567d","#2f9e7a","#c98a1b","#7a62d6","#d2643c","#4d9a3c","#2a93a8","#a86bb8","#8a7a3a"],hk="adg:games:overview:shown",mk="adg:games:overview:mode";function fk(e,t){try{const s=localStorage.getItem(e);return s===null?t:JSON.parse(s)}catch{return t}}function pk(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 VD(e,t){return new Date(e).toLocaleDateString("zh-CN",{timeZone:t,month:"numeric",day:"numeric"})}function vd(e,t){const s=e-t;return s<=0?"已结束":s<ai?`${Math.max(1,Math.floor(s/36e5))} 小时`:`${Math.floor(s/ai)} 天`}function qD({client:e,games:t,activities:s,now:i,soonDays:r,onOpenGame:o,onChanged:l}){const[u,d]=v.useState(()=>fk(hk,null)),[h,f]=v.useState(()=>fk(mk,"time")),[p,g]=v.useState(null);v.useEffect(()=>pk(hk,u),[u]),v.useEffect(()=>pk(mk,h),[h]);const x=v.useMemo(()=>new Map(t.map((U,A)=>[U.id,Qr[A%Qr.length]])),[t]),b=U=>u===null||u.includes(U),k=U=>d(A=>{const I=A??t.map(L=>L.id),R=I.includes(U)?I.filter(L=>L!==U):[...I,U];return R.length===t.length?null:R}),j=new Date(i-zf*ai).setHours(0,0,0,0),N=j+(zf+WD)*ai,C=U=>Math.min(100,Math.max(0,(U-j)/(N-j)*100)),S=s.filter(U=>b(U.game)&&(U.endsAt===void 0||Math.max(U.endsAt,U.shopEndsAt??0)>i)),_=(U,A)=>(U.endsAt??1/0)-(A.endsAt??1/0)||U.name.localeCompare(A.name),z=S.filter(U=>(U.startsAt??0)<=i),P=S.filter(U=>U.startsAt!==void 0&&U.startsAt>i).sort((U,A)=>U.startsAt-A.startsAt),H=[];if(h==="time"){const U=j+(zf+7)*ai,A=z.filter(L=>L.endsAt!==void 0&&L.endsAt-i<r*ai).sort(_),I=z.filter(L=>!A.includes(L)&&L.endsAt!==void 0&&L.endsAt<U).sort(_),R=z.filter(L=>!A.includes(L)&&!I.includes(L)).sort(_);H.push({key:"soon",title:"快结束",hint:`${r} 天内`,rows:A},{key:"week",title:"本周内结束",rows:I},{key:"later",title:"之后结束",rows:R},{key:"upcoming",title:"即将开始",rows:P})}else for(const U of t){if(!b(U.id))continue;const A=[...z.filter(I=>I.game===U.id).sort(_),...P.filter(I=>I.game===U.id)];H.push({key:U.id,title:U.name,rows:A,game:U})}const B=z.reduce((U,A)=>{const I=ms(A);return{...U,[I.state]:U[I.state]+1}},{finished:0,partial:0,unknown:0}),O=z.filter(U=>U.endsAt!==void 0&&U.endsAt-i<r*ai&&ms(U).state!=="finished").length,T=[];for(let U=j;U<=N;U+=ai){const A=Math.round((U-new Date(i).setHours(0,0,0,0))/ai);T.push({at:U,...A>0&&A%7===0?{label:VD(U,Intl.DateTimeFormat().resolvedOptions().timeZone)}:{}})}const D=U=>s.filter(A=>A.game===U&&(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(U=>{const A=D(U.id);return n.jsx(GD,{client:e,game:U,color:x.get(U.id)??Qr[0],now:i,shown:b(U.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(U.id),onToggle:()=>k(U.id)},U.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:z.length,label:"进行中"}),n.jsx(Bl,{value:O,label:"快结束未做完",tone:O>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:()=>f("time"),children:"按时间"}),n.jsx("button",{className:h==="game"?"active":"","aria-pressed":h==="game",onClick:()=>f("game"),children:"按游戏"})]})]}),n.jsxs("div",{className:"ov-grid",children:[n.jsx("div",{className:"ov-lines","aria-hidden":"true",children:T.filter(U=>U.label!==void 0).map(U=>n.jsx("i",{style:{left:`${C(U.at)}%`}},U.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:[T.map(U=>n.jsx("span",{className:`ov-tick ${U.label!==void 0?"major":""}`,style:{left:`${C(U.at)}%`},children:U.label!==void 0&&n.jsx("em",{children:U.label})},U.at)),n.jsx("span",{className:"ov-today-label",style:{left:`${C(i)}%`},children:"今天"})]}),n.jsx("div",{className:"ov-side"})]}),H.every(U=>U.rows.length===0)&&n.jsxs("div",{className:"empty",children:[n.jsx(ee,{name:"timeline"}),n.jsx("p",{children:t.length===0?"没有游戏。":"显示的游戏现在没有活动。点「刷新全部」读取,或点上面游戏卡片的眼睛多显示几个。"})]}),H.filter(U=>U.rows.length>0).map(U=>{var A;return n.jsxs("div",{className:`ov-section ${U.key==="soon"?"warn":""} ${U.game!==void 0?"by-game":""}`,style:U.game===void 0?void 0:{"--game":x.get(U.game.id)},children:[n.jsxs("div",{className:"ov-section-title",children:[U.game!==void 0&&n.jsx("span",{className:"game-dot"}),n.jsx("span",{className:"ov-section-name",children:U.title}),n.jsx("span",{className:"ov-section-count",children:U.rows.length}),U.hint!==void 0&&n.jsx("span",{className:"muted small",children:U.hint}),((A=U.game)==null?void 0:A.version)!==void 0&&n.jsxs("span",{className:"muted small ov-section-version",children:[U.game.version.name,U.game.version.title===void 0?"":`「${U.game.version.title}」`]}),U.game!==void 0&&n.jsxs("button",{className:"link-button small ov-section-open",onClick:()=>o(U.game.id),children:["打开",n.jsx(ee,{name:"chevron"})]})]}),U.rows.map(I=>{const R=t.find(L=>L.id===I.game);return n.jsx(KD,{client:e,activity:I,game:R,color:x.get(I.game)??Qr[0],showGame:h==="time",now:i,soonDays:r,x:C,open:p===I.id,onToggle:()=>g(L=>L===I.id?null:I.id),onOpenGame:()=>o(I.game),onChanged:l},I.id)})]},U.key)}),n.jsx("div",{className:"ov-today",style:{left:`calc(var(--ov-label) + (100% - var(--ov-label) - var(--ov-side)) * ${C(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 GD({client:e,game:t,color:s,covers:i,now:r,running:o,soon:l,shown:u,onOpen:d,onToggle:h}){const f=t.version,p=MS(e,[f==null?void 0:f.cover,t.art,...i]),g=(f==null?void 0:f.endsAt)!==void 0&&f.endsAt>r?` · 还剩 ${vd(f.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:f===void 0?"没有版本信息":`${f.name}${f.title===void 0?"":`「${f.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(ee,{name:u?"eye":"eye-off"})})]})}function KD({client:e,activity:t,game:s,color:i,showGame:r,now:o,soonDays:l,x:u,open:d,onToggle:h,onOpenGame:f,onChanged:p}){const g=ms(t),x=(t.startsAt??0)<=o,b=t.endsAt,k=x&&b!==void 0&&b-o<l*ai&&g.state!=="finished",j=u(t.startsAt??o-30*ai),N=b===void 0?100:u(b),C=t.shopEndsAt===void 0||b===void 0||t.shopEndsAt<=b?void 0:u(t.shopEndsAt),S=Xa(e,t.cover);return n.jsxs("div",{className:`ov-item ${d?"open":""}`,style:{"--game":i},children:[n.jsxs("button",{className:`ov-row ${k?"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"} ${j<=0?"cut-left":""} ${b===void 0||N>=100?"cut-right":""}`,style:{left:`${j}%`,width:`${Math.max(1.2,N-j)}%`},children:g.total>0&&n.jsx("span",{className:"ov-bar-done",style:{width:`${g.done/g.total*100}%`}})}),C!==void 0&&n.jsx("span",{className:"ov-shop",style:{left:`${N}%`,width:`${Math.max(.6,C-N)}%`},title:"之后只开商店"})]}),n.jsxs("div",{className:"ov-side",children:[n.jsx("span",{className:`ov-left ${k?"tone-warn":""}`,children:x?b===void 0?"时间未知":b<=o&&t.shopEndsAt!==void 0?`商店 ${vd(t.shopEndsAt,o)}`:vd(b,o):`${vd(t.startsAt,o)}后开始`}),n.jsx(px,{progress:g})]})]}),d&&n.jsx(XD,{client:e,activity:t,game:s,onOpenGame:f,onChanged:p})]})}function px({progress:e}){return e.state==="finished"?n.jsxs("span",{className:"ov-progress done",children:[n.jsx(ee,{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 YD({activity:e,game:t,chosen:s,onChoose:i}){const r=mn(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),f=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 b;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?"网页":"数据站"," · ",gt(x.at,r)]}),o.length>1&&((b=e.shown)==null?void 0:b.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 看过 · ",gt(e.screen.at,r)]})]}),e.own!==void 0&&n.jsxs("button",{className:`fact-chip own ${s===Mo?"on":""}`,"aria-pressed":s===Mo,disabled:!p||f,title:f?"你自己添加的活动":`你改过:${e.own.fields.map(x=>dk[x]).join("、")};比来源优先,刷新不会改掉`,onClick:()=>h(Mo),children:[f?"我添加的":"我改过",n.jsxs("small",{children:[f?"":`${e.own.fields.map(x=>dk[x]).join("、")} · `,gt(e.own.at,r)]})]}),s!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>i(null),children:"恢复默认"})]})}function XD({client:e,activity:t,game:s,onOpenGame:i,onChanged:r,openSession:o}){var I,R;const[l,u]=v.useState(null),[d,h]=v.useState(!1),[f,p]=v.useState(""),[g,x]=v.useState(!1),[b,k]=v.useState(null),[j,N]=v.useState(void 0);v.useEffect(()=>N(void 0),[t]);const C=j??t,[S,_]=v.useState(void 0);v.useEffect(()=>_(void 0),[C.chosen]);const z=L=>{_(L),k(null),e.connection.call("games/activity/source",{activityId:C.id,source:L}).then(K=>{N(K),r()},K=>{_(void 0),k(Ce(K))})},P=(s==null?void 0:s.timezone)??"Asia/Shanghai",H=L=>new Date(L).toLocaleString("zh-CN",{timeZone:P,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),B=async L=>{x(!0),k(null);try{await e.connection.call("games/activity/progress",{activityId:C.id,...L}),r()}catch(K){k(Ce(K))}finally{x(!1)}},O=L=>void B({todo:C.todo.filter(K=>K!==L),done:[...C.done,L]}),T=L=>void B({todo:[...C.todo,L],done:C.done.filter(K=>K!==L)}),D=()=>{const L=f.trim();L===""||C.todo.includes(L)||C.done.includes(L)||(p(""),B({todo:[...C.todo,L]}))},U=C.sources!==void 0||C.screen!==void 0,A=()=>{x(!0),k(null),e.connection.call("games/activity/reset",{activityId:C.id}).then(r,L=>k(Ce(L))).finally(()=>x(!1))};return d&&s!==void 0?n.jsx("div",{className:"ov-detail",children:n.jsx(fx,{client:e,game:s,activity:C,onDone:()=>{h(!1),r()},onCancel:()=>h(!1)})}):n.jsxs("div",{className:"ov-detail",children:[C.description!==void 0&&n.jsx("p",{className:"ov-description",children:C.description}),n.jsxs("div",{className:"activity-dates muted small",children:[C.startsAt!==void 0&&n.jsxs("span",{children:[H(C.startsAt)," 开始"]}),C.endsAt!==void 0&&n.jsxs("span",{children:[H(C.endsAt)," 结束"]}),C.shopEndsAt!==void 0&&n.jsxs("span",{children:["商店开到 ",H(C.shopEndsAt)]})]}),n.jsx(YD,{activity:C,game:s,chosen:S!==void 0?S??void 0:C.chosen,onChoose:z}),n.jsxs("div",{className:"ov-checklist",role:"list","aria-label":"要做的事",children:[C.todo.map(L=>n.jsxs("label",{className:"ov-check",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!1,disabled:g,onChange:()=>O(L)}),L]},`t${L}`)),C.done.map(L=>n.jsxs("label",{className:"ov-check done",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!0,disabled:g,onChange:()=>T(L)}),L]},`d${L}`)),C.todo.length+C.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:f,maxLength:80,placeholder:"加一项要做的事,回车添加",disabled:g,onChange:L=>p(L.target.value),onKeyDown:L=>{L.key==="Enter"&&D()}}),n.jsxs("button",{className:"small-button",disabled:g||f.trim()==="",onClick:D,children:[n.jsx(ee,{name:"plus"}),"添加"]})]}),n.jsxs("div",{className:"ov-detail-actions",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:C.finished!==void 0,disabled:g,onChange:L=>void B({finished:L.target.checked})}),"这个活动我做完了"]}),n.jsx("span",{className:"spacer"}),((I=C.screen)==null?void 0:I.evidence)===!0&&n.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:C.id}).then(L=>{const K=`data:${L.mediaType};base64,${L.data}`,F=new Image;F.onload=()=>u({src:K,width:F.naturalWidth,height:F.naturalHeight}),F.src=K},L=>k(Ce(L))),children:"看游戏截图"}),((R=C.screen)==null?void 0:R.sessionId)!==void 0&&o!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>o(C.screen.sessionId),children:"agent 的对话"}),C.url!==void 0&&n.jsx("a",{className:"link-button small",href:C.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(ee,{name:"pencil"}),"编辑"]}),C.own!==void 0&&U&&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:C.id}).then(r,L=>k(Ce(L))),children:"从日历去掉"})]}),b!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:b})]}),l!==null&&n.jsx(oh,{src:l.src,width:l.width,height:l.height,name:`${C.name}.png`,onClose:()=>u(null)})]})}function QD({client:e,onChanged:t,onCreate:s}){const[i,r]=v.useState(null),[o,l]=v.useState(""),[u,d]=v.useState(null),[h,f]=v.useState(null),[p,g]=v.useState(0);v.useEffect(()=>{let b=!0;return e.connection.call("games/catalog",{}).then(k=>{b&&r(k.games)}).catch(k=>{b&&f(Ce(k))}),()=>{b=!1}},[e,p]);const x=async(b,k)=>{d(b.sra),f(null),r(j=>(j==null?void 0:j.map(N=>N.sra===b.sra?{...N,followed:k}:N))??j);try{await e.connection.call("games/follow",{sra:b.sra,follow:k}),t()}catch(j){f(Ce(j))}finally{d(null),g(j=>j+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(b=>n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:b.followed,disabled:u===b.sra,onChange:k=>void x(b,k.target.checked)}),b.name,u===b.sra?"…":""]},b.sra))}),s!==void 0&&n.jsxs("form",{className:"discover-row",onSubmit:b=>{b.preventDefault();const k=o.trim();k!==""&&(s(k),l(""))},children:[n.jsx("span",{className:"field-title",children:"列表里没有?"}),n.jsx("input",{className:"text-input plain",value:o,maxLength:60,placeholder:"输入游戏名,例如:重返未来:1999",onChange:b=>l(b.target.value)}),n.jsxs("button",{className:"small-button primary",type:"submit",disabled:o.trim()==="",children:[n.jsx(ee,{name:"plus"}),"添加"]}),n.jsx("span",{className:"muted small",children:"先加一个空的游戏页,再在它的页面上让 agent 去找活动来源。"})]}),h!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:h})]})]})}const pr=864e5,Ia=36e5,Yp=6e4,gk=5,JD={update:"版本更新",notice:"公告",news:"资讯"};function gx(e,t){const s=e-t;return s<=0?"已结束":s>=pr?`${Math.floor(s/pr)} 天 ${Math.floor(s%pr/Ia)} 时`:`${Math.floor(s/Ia)} 时 ${Math.floor(s%Ia/Yp)} 分`}function e3(e){return e<=0?{value:"0",unit:"时",rest:""}:e>=pr?{value:String(Math.floor(e/pr)),unit:"天",rest:`${Math.floor(e%pr/Ia)} 时`}:e>=Ia?{value:String(Math.floor(e/Ia)),unit:"时",rest:`${Math.floor(e%Ia/Yp)} 分`}:{value:String(Math.max(1,Math.floor(e/Yp))),unit:"分",rest:""}}function Xp(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 xx(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 t3({client:e,game:t,activities:s,notices:i,color:r,now:o,soonDays:l,busy:u,open:d,adding:h,onOpen:f,onAdd:p,onRefresh:g,onRead:x,onReadWeb:b,onDiscover:k,onRemove:j,onChanged:N,openSession:C,openScripts:S}){var Q,G,ne,te,re;const[_,z]=v.useState(!1),[P,H]=v.useState(!1),B=s.filter(X=>Math.max(X.endsAt??1/0,X.shopEndsAt??0)>o),O=(X,se)=>(X.endsAt??1/0)-(se.endsAt??1/0),T=B.filter(X=>(X.startsAt??0)<=o).sort(O),D=B.filter(X=>X.startsAt!==void 0&&X.startsAt>o).sort((X,se)=>X.startsAt-se.startsAt),U=T.filter(X=>ms(X).state!=="finished"&&(X.endsAt??1/0)-o<l*pr),A=t.sources.some(X=>X.auto),I={partial:0,unknown:1,finished:2},R=T.filter(X=>!U.includes(X)&&ms(X).state!=="finished").sort((X,se)=>I[ms(X).state]-I[ms(se).state]||O(X,se)),L=T.filter(X=>ms(X).state==="finished"),K=[{key:"soon",title:"需要关注",hint:`${l} 天内结束,还没做完`,rows:U,tone:"warn"},{key:"ongoing",title:"进行中",hint:"做了一部分的在前",rows:R},{key:"upcoming",title:"即将开始",hint:"按开始时间",rows:D}],F=X=>n.jsx("div",{className:"schedule-item",children:n.jsx(o3,{client:e,activity:X,game:t,now:o,soonDays:l,onClick:()=>f(X.id),expanded:d===X.id})},X.id),q=t.single===!0,V=i.find(X=>X.kind==="update"),Z=i.length>0||q?n.jsxs("section",{className:"game-section game-notices","aria-label":"公告",children:[n.jsxs("div",{className:"game-section-head",children:[n.jsx("h3",{children:q?"公告与更新":"公告"}),n.jsx("span",{className:"count",children:i.length}),n.jsx("span",{className:"spacer"}),q&&n.jsx("span",{className:"muted small",children:A?"每天自动读官方公告":"让 agent 上网查"}),n.jsx("button",{className:"icon-button",title:"让 agent 上网查最新的公告和更新","aria-label":"让 agent 查公告",disabled:u!==null||((Q=t.webReading)==null?void 0:Q.state)==="running",onClick:()=>b(),children:n.jsx(ee,{name:"search"})}),A&&n.jsx("button",{className:"icon-button",title:"刷新数据站(不用模型)",disabled:u!==null,onClick:g,children:n.jsx(ee,{name:"refresh"})})]}),i.length===0&&n.jsx("p",{className:"muted small schedule-empty",children:"还没有公告。点右上角让 agent 上网查;在 Steam 上的游戏,加上 Steam 来源后每天自动读它的官方公告。"}),n.jsx("ul",{className:"notice-list",children:(P?i:i.slice(0,gk)).map(X=>n.jsx(l3,{client:e,notice:X,now:o},X.id))}),i.length>gk&&n.jsx("button",{className:"link-button small notice-more",onClick:()=>H(X=>!X),children:P?"收起":`展开全部 ${i.length} 条`})]}):null;return n.jsxs("div",{className:"game-view",style:{"--game":r},children:[n.jsx(n3,{client:e,game:t,now:o,update:V,covers:[V==null?void 0:V.cover,...T.map(X=>X.cover).filter(X=>(X==null?void 0:X.startsWith("shot:"))!==!0)]}),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||((G=t.webReading)==null?void 0:G.state)==="running",onClick:k,children:[n.jsx(ee,{name:"search"}),((ne=t.webReading)==null?void 0:ne.state)==="running"?"agent 正在找…":"让 agent 去找"]})]}),(((te=t.pools)==null?void 0:te.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(X=>n.jsx(c3,{client:e,pool:X,game:t,now:o},`${X.name}-${X.endsAt}`))})]}),q&&Z,!q||B.length>0||L.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:B.length}),n.jsx("span",{className:"spacer"}),n.jsx("span",{className:"muted small",children:((re=t.sources.find(X=>X.auto))==null?void 0:re.name)??"数据站"}),n.jsx("button",{className:"icon-button",title:"自己添加一个活动","aria-label":"添加活动","aria-pressed":h,onClick:p,children:n.jsx(ee,{name:"plus"})}),n.jsx("button",{className:"icon-button",title:A?"刷新数据站(不用模型)":"这个游戏没有能自动读的数据站",disabled:u!==null||!A,onClick:g,children:n.jsx(ee,{name:"refresh"})})]}),B.length===0&&n.jsx("p",{className:"muted small schedule-empty",children:A?"还没有活动。点右上角刷新,或点「+」自己添加。":"这个游戏没有能自动读的数据站:让 agent 进游戏读一次,或点「+」自己添加。"}),K.filter(X=>X.rows.length>0).map(X=>n.jsxs("section",{className:`schedule-group ${X.tone??""}`,children:[n.jsxs("div",{className:"schedule-group-title",children:[n.jsx("span",{children:X.title}),n.jsx("span",{className:"count",children:X.rows.length}),n.jsx("span",{className:"muted small",children:X.hint})]}),n.jsx("div",{className:"schedule-grid",children:X.rows.map(F)})]},X.key)),L.length>0&&n.jsxs("section",{className:"schedule-group done",children:[n.jsxs("button",{className:"schedule-group-title toggle","aria-expanded":_,onClick:()=>z(X=>!X),children:[n.jsx("span",{children:"已做完"}),n.jsx("span",{className:"count",children:L.length}),n.jsx("span",{className:"muted small",children:_?"收起":"展开"}),n.jsx(ee,{name:"chevron-down",className:`chevron-icon ${_?"open":""}`})]}),_&&n.jsx("div",{className:"schedule-grid",children:L.map(F)})]})]}):n.jsxs("p",{className:"muted small single-no-events",children:["单机游戏没有限时活动。有要记的事(限时折扣、联动)可以",n.jsx("button",{className:"link-button small",onClick:p,children:"自己加一个"}),"。"]}),!q&&Z]}),n.jsxs("aside",{className:"game-side",children:[n.jsx(i3,{game:t,single:q,running:T,soon:U,now:o,busy:u,onRead:x,onReadWeb:b,onRemove:j,openSession:C}),n.jsx("section",{className:"card game-runs-card",children:n.jsx(a3,{client:e,game:t,now:o,openScripts:S})}),n.jsxs("section",{className:"card game-sources-card",children:[n.jsx("h3",{children:"数据来源"}),n.jsxs("div",{className:"game-sources",children:[t.sources.map(X=>{var se;return n.jsxs("span",{className:`source-chip ${X.auto?"auto":"agent"}`,children:[X.auto?n.jsxs("span",{className:"source-name",title:"每天自动读取(不用模型)",children:[n.jsx("span",{className:"source-dot auto"}),X.name]}):n.jsxs("button",{className:"source-name",disabled:u!==null||((se=t.webReading)==null?void 0:se.state)==="running",title:"让 agent 读这个来源,把活动记进日历",onClick:()=>b(X.id),children:[n.jsx("span",{className:"source-dot"}),X.name,n.jsx("span",{className:"source-action",children:"agent 读"})]}),X.homepage!==void 0&&n.jsx("a",{className:"source-open",href:X.homepage,target:"_blank",rel:"noreferrer",title:"在浏览器里打开","aria-label":`打开${X.name}`,children:n.jsx(ee,{name:"popout"})}),X.added===!0&&n.jsx("button",{className:"source-open",title:"不再读这个网址","aria-label":`删除${X.name}`,onClick:()=>void e.connection.call("games/source/remove",{game:t.id,source:X.id}).then(N,()=>{}),children:n.jsx(ee,{name:"close"})})]},X.id)}),n.jsx(s3,{client:e,game:t,onAdded:N})]}),t.refreshed!==void 0&&n.jsxs("span",{className:"muted small",children:[gt(t.refreshed.at,o),"刷新"]}),t.refreshed!==void 0&&!t.refreshed.ok&&n.jsxs("span",{className:"tone-error small",children:["上次没读到:",t.refreshed.detail]})]})]})]})]})}function n3({client:e,game:t,now:s,update:i,covers:r}){const o=t.version,l=MS(e,[o==null?void 0:o.cover,t.art,...r]),u=(o==null?void 0:o.startsAt)!==void 0&&o.endsAt!==void 0?o.endsAt-o.startsAt:void 0,d=u===void 0||u<=0?void 0:Math.min(1,Math.max(0,(s-o.startsAt)/u)),h=f=>new Date(f).toLocaleDateString("zh-CN",{timeZone:t.timezone,month:"numeric",day:"numeric"});return n.jsxs("section",{className:`version-hero ${l===void 0?"no-art":""}`,children:[l!==void 0&&n.jsx("img",{className:"version-art",src:l,alt:""}),n.jsx("div",{className:"version-shade"}),n.jsxs("div",{className:"version-caption",children:[n.jsxs("span",{className:"version-kicker",children:[t.name,o!==void 0?n.jsxs(n.Fragment,{children:[" · ",n.jsx("b",{children:o.name})," 版本"]}):(i==null?void 0:i.version)!==void 0?n.jsxs(n.Fragment,{children:[" · 最新 ",n.jsx("b",{children:i.version})]}):""]}),n.jsx("h2",{children:(o==null?void 0:o.title)??t.name})]}),n.jsxs("div",{className:"version-strip",children:[o===void 0&&i!==void 0&&n.jsxs("span",{className:"small version-none version-update",title:i.title,children:["最新更新:",i.title,i.publishedAt===void 0?"":` · ${gt(i.publishedAt,s)}`]}),o===void 0&&i===void 0&&n.jsx("span",{className:"small version-none",children:t.single===!0?t.sources.some(f=>f.auto)?"还没有更新公告:点「公告与更新」右上角刷新":"还没有更新公告:点「公告与更新」右上角让 agent 查":t.sources.length===0?"还没有数据来源":t.sources.some(f=>f.auto)?"还没有版本信息:点「活动日程」右上角刷新":"这个游戏的数据站不提供版本信息"}),o!==void 0&&d!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"version-end",children:h(o.startsAt)}),n.jsxs("div",{className:"version-track",role:"meter","aria-label":"版本进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(d*100),children:[n.jsx("span",{className:"version-fill",style:{width:`${d*100}%`}}),n.jsx("span",{className:"version-now",style:{left:`${d*100}%`}})]}),n.jsx("span",{className:"version-end",children:h(o.endsAt)})]}),(o==null?void 0:o.endsAt)!==void 0&&n.jsx("span",{className:"version-remaining",children:o.endsAt>s?n.jsxs(n.Fragment,{children:["还剩 ",n.jsx("strong",{children:gx(o.endsAt,s)})]}):"本版本已结束"})]})]})}function s3({client:e,game:t,onAdded:s}){const[i,r]=v.useState(!1),[o,l]=v.useState(""),[u,d]=v.useState(!1),[h,f]=v.useState(null);if(!i)return n.jsxs("button",{className:"source-add",onClick:()=>r(!0),title:"添加一个关于这个游戏的网页,agent 会去读它",children:[n.jsx(ee,{name:"plus"}),"添加网址"]});const p=async()=>{const g=o.trim();if(g!==""){d(!0),f(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){f(Ce(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),f(null)},children:"取消"}),h!==null&&n.jsx("span",{className:"tone-error small",children:h})]})}function i3({game:e,single:t,running:s,soon:i,now:r,busy:o,onRead:l,onReadWeb:u,onRemove:d,openSession:h}){var k,j;const f=s.map(ms),p=f.filter(N=>N.state==="finished").length,g=f.filter(N=>N.state==="partial").length,x=f.filter(N=>N.state==="unknown").length,b=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":`已做完 ${p} 个,做了一部分 ${g} 个,没记录 ${x} 个`,children:[p>0&&n.jsx("span",{className:"done",style:{flexGrow:p}}),g>0&&n.jsx("span",{className:"partial",style:{flexGrow:g}}),x>0&&n.jsx("span",{className:"unknown",style:{flexGrow:x}})]}),n.jsxs("ul",{className:"status-legend",children:[n.jsxs("li",{children:[n.jsx("i",{className:"done"}),"已做完",n.jsx("b",{children:p})]}),n.jsxs("li",{children:[n.jsx("i",{className:"partial"}),"做了一部分",n.jsx("b",{children:g})]}),n.jsxs("li",{children:[n.jsx("i",{className:"unknown"}),"没记录",n.jsx("b",{children:x})]})]}),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||(b==null?void 0:b.state)==="running",title:"agent 会看游戏画面,进活动页读取剩余时间和没做完的事;只看不花东西",onClick:l,children:[n.jsx(ee,{name:"gamepad"}),(b==null?void 0:b.state)==="running"?"agent 正在读…":"让 agent 进游戏读取"]}),n.jsxs("button",{className:"small-button",disabled:o!==null||((k=e.webReading)==null?void 0:k.state)==="running",title:t?"agent 读官方的更新日志、Steam 新闻和公告,记下版本更新和长期公告":"agent 读官网公告、Wiki 等插件不能自己读的来源,把活动记进日历",onClick:()=>u(),children:[n.jsx(ee,{name:"search"}),((j=e.webReading)==null?void 0:j.state)==="running"?"agent 正在查…":t?"让 agent 查最新公告":"让 agent 上网查活动"]}),n.jsx("button",{className:"small-button",disabled:o!==null,title:e.own===!0?"删掉这个游戏和它的活动(你或 agent 加的)":e.followed===!0?"不再关注,游戏页上不再显示":"游戏页上不再显示;它的游戏包和脚本包不删",onClick:d,children:e.own===!0?"删除这个游戏":"不再显示"})]}),b!==void 0&&n.jsx(xk,{what:"进游戏",reading:b,now:r,openSession:h}),e.webReading!==void 0&&n.jsx(xk,{what:"上网查",reading:e.webReading,now:r,openSession:h})]})}function xk({what:e,reading:t,now:s,openSession:i}){var o;const r=(o=t.summary)==null?void 0:o.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==="running"?`正在${e}`:t.state==="done"?`上次${e}`:`${e}没完成`}),n.jsx("span",{className:"muted small",children:gt(t.at,s)}),n.jsx("span",{className:"spacer"}),t.sessionId!==void 0&&n.jsxs("button",{className:"link-button small reading-open",onClick:()=>i(t.sessionId),children:["查看对话",n.jsx(ee,{name:"chevron"})]})]}),r!==void 0&&r!==""&&n.jsx("p",{className:"reading-summary",title:r,children:r})]})}function r3({client:e,game:t}){const s=ke(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 a3({client:e,game:t,now:s,openScripts:i}){const r=ke(e.capabilities),o=ke(e.connection.status),[l,u]=v.useState(null),[d,h]=v.useState([]),[f,p]=v.useState(0),[g,x]=v.useState(null),[b,k]=v.useState(null),j=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(_=>_+1)}),[e]),v.useEffect(()=>{if(o.state!=="open"||!j||t.scripts.length===0){u([]);return}let S=!0;return(async()=>{const{items:_}=await e.connection.call("pipelines/list",{}),P=(await Promise.all(_.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(O=>O.kind==="script-task"&&t.scripts.includes(O.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(_=>{S&&k(Ce(_))}),()=>{S=!1}},[e,o.state,j,t.id,t.scripts.join(","),f]);const N=async S=>{x(S),k(null);try{await e.connection.call("pipelines/run",{id:S}),p(_=>_+1)}catch(_){k(Ce(_))}finally{x(null)}},C={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(r3,{client:e,game:t}),t.scripts.length>0&&n.jsxs("p",{className:"muted small",children:["玩它的脚本:",t.scripts.map((S,_)=>n.jsxs("span",{children:[_>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 _=d.filter(B=>B.pipelineId===S.id).map(B=>B.at).sort((B,O)=>B-O)[0],z=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:_!==void 0?`下次 ${new Date(_).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"})}`:S.schedule.enabled?"定时已开":"没有定时"}),z!==void 0&&n.jsxs("span",{className:`badge ${((P=C[z.state])==null?void 0:P[0])??""}`,title:new Date(z.startedAt).toLocaleString("zh-CN",{hour12:!1}),children:[((H=C[z.state])==null?void 0:H[1])??z.state," · ",gt(z.endedAt??z.startedAt,s)]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:g!==null||(z==null?void 0:z.state)==="running",onClick:()=>void N(S.id),children:(z==null?void 0:z.state)==="running"?"运行中…":g===S.id?"启动中…":"运行"})]},S.id)})}),b!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:b})]})]})}function OS(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*pr&&ms(e).state!=="finished";return{started:i,shopOnly:r,end:o,soon:l,target:i?o:e.startsAt}}function PS({activity:e,art:t,now:s,soonDays:i}){var b;const{started:r,shopOnly:o,end:l,soon:u,target:d}=OS(e,s,i),h=e.startsAt!==void 0&&l!==void 0?l-e.startsAt:void 0,f=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:""}:e3(d-s),x=((b=e.cover)==null?void 0:b.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?"剩余":"距开始"}${gx(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?"商店":"剩余":"后开始"})]}),f!==void 0&&n.jsx("span",{className:"sched-elapsed",style:{width:`${f*100}%`}})]})}function o3({client:e,activity:t,game:s,now:i,soonDays:r,onClick:o,expanded:l}){var k,j,N,C;const u=Xa(e,t.cover),d=ms(t),{started:h,shopOnly:f,end:p,soon:g}=OS(t,i,r),x=xx(s.timezone,i),b=t.chosen===void 0?void 0:t.chosen===Mo?"我设的":t.chosen===oc?"游戏画面":(j=(k=t.sources)==null?void 0:k.find(S=>S.id===t.chosen))==null?void 0:j.name;return n.jsxs("button",{className:`sched-card ${u===void 0?"no-art":""} ${g?"soon":""}`,onClick:o,"aria-expanded":l,children:[n.jsx(PS,{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?`${Xp(t.startsAt,s.timezone)} 开始 · ${x}`:p!==void 0?`${Xp(p,s.timezone)} ${f?"商店关闭":"结束"} · ${x}`:`结束时间未知${((N=t.screen)==null?void 0:N.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}),b!==void 0&&n.jsxs("span",{className:"sched-kind",title:`你选了用「${b}」的图片和时间`,children:["用 ",b]}),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?"我添加的":"我改过"}),((C=t.sources)==null?void 0:C.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(px,{progress:d})]})]})]})}function l3({client:e,notice:t,now:s}){const i=Xa(e,t.cover),r=t.url!==void 0&&/^https?:\/\//.test(t.url)?t.url:void 0,o=t.publishedAt!==void 0&&s-t.publishedAt>=0&&s-t.publishedAt<3*pr;return n.jsxs("li",{className:`notice-row ${t.lasting===!0?"lasting":""}`,children:[i!==void 0&&n.jsx("img",{className:"notice-art",src:i,alt:"",loading:"lazy"}),n.jsxs("div",{className:"notice-body",children:[n.jsxs("div",{className:"notice-meta",children:[n.jsx("span",{className:`notice-kind ${t.kind}`,children:JD[t.kind]}),t.lasting===!0&&n.jsx("span",{className:"notice-kind lasting",title:"长期有效的公告,一直排在前面",children:"长期"}),t.version!==void 0&&n.jsx("span",{className:"notice-version",children:t.version}),o&&n.jsx("span",{className:"badge ok",children:"新"}),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")})]}),r!==void 0?n.jsx("a",{className:"notice-title",href:r,target:"_blank",rel:"noreferrer",title:"在浏览器里打开",children:t.title}):n.jsx("span",{className:"notice-title",children:t.title}),t.summary!==void 0&&n.jsx("p",{className:"notice-summary",children:t.summary}),n.jsx("span",{className:"muted small notice-source",children:t.source.name})]})]})}function c3({client:e,pool:t,game:s,now:i}){const r=Xa(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(ee,{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:gx(o?t.endsAt:t.startsAt,i)})]}),n.jsxs("span",{className:"muted small",children:[Xp(t.endsAt,s.timezone)," 结束 (",xx(s.timezone,i),")"]})]})]})}function u3(e,t){return v.useMemo(()=>new Map(e.map((s,i)=>[s.id,t[i%t.length]])),[e,t])}function yd({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)")],f=h[0],p=h[h.length-1],g=document.activeElement;f===void 0||p===void 0||(d.shiftKey&&(g===f||g===o.current)?(d.preventDefault(),p.focus()):!d.shiftKey&&g===p&&(d.preventDefault(),f.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 d3(e,t){const s=u=>gt(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:Mo,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 h3(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 m3({client:e,url:t}){const s=Xa(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 f3({client:e,activity:t,game:s,now:i,soonDays:r,onClose:o,onChanged:l,openSession:u}){var ne,te,re;const[d,h]=v.useState(null),[f,p]=v.useState(!1),[g,x]=v.useState(""),[b,k]=v.useState(!1),[j,N]=v.useState(null),[C,S]=v.useState(void 0);v.useEffect(()=>S(void 0),[t]);const _=C??t,[z,P]=v.useState(void 0);v.useEffect(()=>P(void 0),[_.chosen]);const H=z!==void 0?z??void 0:_.chosen,B=Xa(e,_.cover),O=v.useRef(void 0);B!==void 0&&(O.current=B);const T=_.cover===void 0?void 0:B??O.current,D=(s==null?void 0:s.timezone)??"Asia/Shanghai",U=X=>new Date(X).toLocaleString("zh-CN",{timeZone:D,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),A=d3(_,i),I=_.shopEndsAt!==void 0||A.some(X=>X.shopEndsAt!==void 0),R=_.sources!==void 0||_.screen!==void 0,L=(X,se)=>{k(!0),N(null),X.then(()=>{l(),se==null||se()},ae=>N(Ce(ae))).finally(()=>k(!1))},K=X=>L(e.connection.call("games/activity/progress",{activityId:_.id,...X})),F=X=>K({todo:_.todo.filter(se=>se!==X),done:[..._.done,X]}),q=X=>K({todo:[..._.todo,X],done:_.done.filter(se=>se!==X)}),V=()=>{const X=g.trim();X===""||_.todo.includes(X)||_.done.includes(X)||(x(""),K({todo:[..._.todo,X]}))},Z=X=>{P(X),N(null),e.connection.call("games/activity/source",{activityId:_.id,source:X}).then(se=>{S(se),l()},se=>{P(void 0),N(Ce(se))})},Q=(X,se)=>{const ae=new Image;ae.onload=()=>h({src:X,width:ae.naturalWidth,height:ae.naturalHeight,name:se}),ae.src=X},G=()=>{k(!0),N(null),e.connection.call("games/activity/reset",{activityId:_.id}).then(X=>{l(),X.activity===void 0&&o()},X=>N(Ce(X))).finally(()=>k(!1))};return f&&s!==void 0?n.jsx("div",{className:"dialog-form",children:n.jsx(fx,{client:e,game:s,activity:_,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:_.name,children:_.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)??_.game]}),_.kind!==void 0&&n.jsx("span",{className:"sched-kind",children:_.kind})]})]}),n.jsx(px,{progress:ms(_)}),n.jsx("button",{className:"dialog-close","aria-label":"关闭详情",title:"关闭(Esc)",onClick:o,children:n.jsx(ee,{name:"close"})})]}),n.jsxs("div",{className:"dialog-cols",children:[n.jsxs("div",{className:"dialog-col side",children:[n.jsx("button",{className:"dialog-media",disabled:T===void 0,title:T===void 0?void 0:"看大图","aria-label":"看大图",onClick:()=>{T!==void 0&&Q(T,`${_.name}.png`)},children:n.jsx(PS,{activity:_,art:T,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:_.startsAt===void 0?"未知":U(_.startsAt)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:"结束"}),n.jsx("dd",{children:_.endsAt===void 0?"未知":U(_.endsAt)})]}),I&&n.jsxs("div",{className:"wide",children:[n.jsx("dt",{children:"商店开到"}),n.jsx("dd",{children:_.shopEndsAt===void 0?"—":U(_.shopEndsAt)})]})]}),n.jsxs("span",{className:"muted small",children:[xx(D,i),",游戏服务器时间",((ne=_.screen)==null?void 0:ne.remaining)===void 0?"":`;游戏里显示「${_.screen.remaining}」`]}),_.description!==void 0&&n.jsx("p",{className:"ov-description",children:_.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:()=>Z(null),children:"恢复默认"})]}),n.jsx("div",{className:"source-rows",children:A.map(X=>{const se=X.id===Mo,ae=H===X.id;return n.jsxs("button",{className:`source-row ${ae?"on":""}`,"aria-pressed":ae,disabled:X.blank&&!se,title:X.title,onClick:()=>{X.blank&&se?p(!0):Z(ae?null:X.id)},children:[n.jsx(m3,{client:e,url:X.cover}),n.jsxs("span",{className:"source-row-main",children:[n.jsxs("span",{className:"source-row-name",children:[n.jsx("b",{children:X.name}),ae&&n.jsx(ee,{name:"check"}),X.note!==""&&n.jsx("small",{children:X.note})]}),X.blank?n.jsx("span",{className:"source-row-dates muted",children:se?"还没填,点这里设置图片和时间":"没有时间和图片"}):n.jsxs("span",{className:"source-row-dates",children:[n.jsx("span",{children:X.startsAt===void 0&&X.endsAt===void 0?"没有时间":`${X.startsAt===void 0?"?":U(X.startsAt)} – ${X.endsAt===void 0?"?":U(X.endsAt)}`}),X.shopEndsAt!==void 0&&n.jsxs("em",{children:["商店到 ",U(X.shopEndsAt)]})]})]}),n.jsx("span",{className:"source-row-uses",children:h3(_,X.id).map(_e=>n.jsx("i",{children:_e},_e))})]},X.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:"要做的事"}),_.todo.length+_.done.length>0&&n.jsxs("span",{className:"count",children:[_.done.length,"/",_.todo.length+_.done.length]})]}),n.jsxs("div",{className:"ov-checklist",role:"list",children:[_.todo.map(X=>n.jsxs("label",{className:"ov-check",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!1,disabled:b,onChange:()=>F(X)}),X]},`t${X}`)),_.done.map(X=>n.jsxs("label",{className:"ov-check done",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!0,disabled:b,onChange:()=>q(X)}),X]},`d${X}`)),_.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:g,maxLength:80,placeholder:"加一项,回车添加",disabled:b,onChange:X=>x(X.target.value),onKeyDown:X=>{X.key==="Enter"&&V()}}),n.jsxs("button",{className:"small-button",disabled:b||g.trim()==="",onClick:V,children:[n.jsx(ee,{name:"plus"}),"添加"]})]})]}),n.jsxs("div",{className:"dialog-section dialog-links",children:[_.url!==void 0&&n.jsx("a",{className:"link-button small",href:_.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),((te=_.screen)==null?void 0:te.evidence)===!0&&n.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:_.id}).then(X=>Q(`data:${X.mediaType};base64,${X.data}`,`${_.name}-截图.png`),X=>N(Ce(X))),children:"看游戏截图"}),((re=_.screen)==null?void 0:re.sessionId)!==void 0&&u!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>u(_.screen.sessionId),children:"agent 的对话"}),n.jsx("span",{className:"spacer"}),_.own!==void 0&&R&&n.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:b,onClick:G,children:"清除我设的"}),n.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:b,onClick:()=>L(e.connection.call("games/activity/remove",{activityId:_.id}),o),children:"从日历去掉"})]}),j!==null&&n.jsx("div",{className:"dialog-section",children:n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:j})]})})]})]}),n.jsxs("footer",{className:"dialog-foot",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:_.finished!==void 0,disabled:b,onChange:X=>K({finished:X.target.checked})}),"这个活动我做完了"]}),n.jsx("span",{className:"spacer"}),s!==void 0&&n.jsxs("button",{className:"small-button",disabled:b,onClick:()=>p(!0),children:[n.jsx(ee,{name:"pencil"}),"编辑"]})]}),d!==null&&n.jsx(oh,{src:d.src,width:d.width,height:d.height,name:d.name,onClose:()=>h(null)})]})}const LS="adg:pack-offer:declined",Df=new Set,p3={game:"游戏包",script:"脚本包",skill:"技能"};function zS(){try{return new Set(JSON.parse(localStorage.getItem(LS)??"[]"))}catch{return new Set}}function vk(e){if(e.length!==0)try{localStorage.setItem(LS,JSON.stringify([...new Set([...zS(),...e])]))}catch{}}const oi=e=>e.trim().toLowerCase();function g3(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 DS({client:e,target:t,label:s,onInstalled:i}){const r=ke(e.capabilities),o=ke(e.connection.status),[l,u]=v.useState([]),[d,h]=v.useState(new Set),[f,p]=v.useState(null),[g,x]=v.useState(null),b=JSON.stringify(t),k=r.has("skillhub")&&o.state==="open";if(v.useEffect(()=>{var P;if(u([]),!k||t.games.length+(((P=t.scripts)==null?void 0:P.length)??0)===0)return;let z=!0;return e.connection.call("skillhub/list",{}).then(H=>{if(!z)return;const B=zS(),O=g3(H.items,t).filter(D=>D.installed===void 0&&D.blocked===void 0&&D.incompatible===void 0&&!B.has(D.name)&&!Df.has(D.name)),T=D=>D.pack==="game"?0:D.pack==="script"?1:2;O.sort((D,U)=>T(D)-T(U)),u(O),h(new Set(O.filter(D=>D.default===!0||D.pack==="game").map(D=>D.name))),x(null)},()=>{}),()=>{z=!1}},[e,k,b]),l.length===0)return null;const j=()=>{for(const z of l)Df.add(z.name);u([])},N=()=>{vk(l.map(z=>z.name)),j()},C=async()=>{x(null);const z=l.filter(H=>d.has(H.name)),P=[];for(const H of z){p(H.name);try{await e.connection.call("skillhub/install",{name:H.name,repo:H.repo})}catch(B){x(`「${H.title??H.name}」没装上:${Ce(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(O=>O.name!==H.name))}vk(l.filter(H=>!d.has(H.name)).map(H=>H.name));for(const H of l)Df.add(H.name);p(null),u([]),P.length>0&&(i==null||i(P))},S=(z,P)=>h(H=>{const B=new Set(H);return P?B.add(z):B.delete(z),B}),_=l.filter(z=>d.has(z.name)).length;return n.jsxs(yd,{color:"var(--accent)",label:`安装${s}的包`,onClose:f===null?j:()=>{},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:f!==null,onClick:j,children:n.jsx(ee,{name:"close"})})]}),n.jsxs("div",{className:"dialog-form pack-offer-body",children:[n.jsx("ul",{className:"pack-offer-list",children:l.map(z=>n.jsx("li",{children:n.jsxs("label",{className:"pack-offer-item",children:[n.jsx("input",{type:"checkbox",checked:d.has(z.name),disabled:f!==null,onChange:P=>S(z.name,P.target.checked)}),n.jsxs("span",{className:"pack-offer-text",children:[n.jsxs("span",{className:"pack-offer-name",children:[z.title??z.name,n.jsx("span",{className:"pack-offer-kind",children:p3[z.pack??"skill"]}),f===z.name&&n.jsx("span",{className:"muted small",children:"正在下载…"})]}),n.jsx("span",{className:"muted small",children:z.description})]})]})},z.name))}),g!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{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:f!==null,onClick:N,children:"不用了"}),n.jsx("button",{className:"small-button primary",disabled:f!==null||_===0,onClick:()=>void C(),children:f!==null?"正在安装…":`安装 ${_} 个`})]})]})}function x3({client:e,sessionId:t}){const s=ke(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]),f=[...h.games.map(p=>`「${p.name}」`),...(h.scripts??[]).map(p=>`「${p}」`)].join("");return n.jsx(DS,{client:e,target:h,label:f})}function Qp({client:e,sessionId:t,reminder:s,initialPrompt:i,onInitialSent:r,onAgent:o}){const l=sh(e,t);return l===null?n.jsx("div",{className:"main empty",children:"正在打开会话…"}):n.jsx(y3,{client:e,session:l,reminder:s,initialPrompt:i,onInitialSent:r,onAgent:o})}function v3(e,t){const[s,i]=v.useState(!1);return t&&!s&&i(!0),e!==void 0&&e.home===void 0&&e.blank!==!0&&!t&&!s}function y3({client:e,session:t,reminder:s,initialPrompt:i,onInitialSent:r,onAgent:o}){const l=ke(t.state),u=ke(e.connection.status),d=qs(e),h=ke(e.sessions).items.find(I=>I.id===t.id),f=h===void 0?vn:Da(h,d),p=d.find(I=>I.id===f),g=p===void 0?cn:Ya(p),x=(h==null?void 0:h.home)!==void 0,b=K2(eO(e),l),[k,j]=v.useState(()=>_3()),N=b.find(I=>I.id===k)??b[0];v.useEffect(()=>E3(k),[k]);const C=v3(h,l.running||l.queue.length>0||i!==void 0),S=k3(),_=_S(e,t.id),z=_.filter(I=>I.running).length,P=S.panel==="tasks"||S.panel==="commands",H=v.useMemo(()=>P?nh(l.events,l.live,l.pending):b3,[P,l.events,l.live,l.pending,l.version]),B=v.useMemo(()=>vS(l.events),[l.events]),O=v.useMemo(()=>SS(H,B),[H,B]),T=v.useMemo(()=>bS(H,B),[H,B]),D=v.useMemo(()=>IS(H),[H]),U=v.useMemo(()=>({openTask:S.openTask}),[S.openTask]),A=n.jsxs("div",{className:"title-tools in-title-bar",role:"toolbar","aria-label":"侧栏",children:[AS.filter(I=>I.id!=="browser"||S.bridge!==void 0).map(I=>{const R=S.panel===I.id,L=I.id==="tasks"&&z>0?`子任务:${z} 个进行中`:I.id==="browser"&&S.working?"agent 正在操作内置浏览器":I.hint;return n.jsxs("button",{type:"button",className:`side-icon${R?" active":""}`,"aria-pressed":R,"aria-label":I.title,title:L,onClick:()=>S.setPanel(R?null:I.id),children:[n.jsx(ee,{name:I.icon}),I.id==="tasks"&&z>0&&n.jsx("span",{className:"side-icon-badge",children:z}),I.id==="browser"&&S.working&&n.jsx("span",{className:"side-icon-dot"})]},I.id)}),n.jsx(S3,{views:b,onSelect:j})]});return n.jsxs("section",{className:"main",children:[!x&&n.jsx("div",{className:"session-bar",children:!x&&n.jsxs("div",{className:"breadcrumb session-crumb",children:[o!==void 0?n.jsx("button",{type:"button",className:"link-button breadcrumb-link",title:`回到「${g.name}」的对话`,onClick:()=>o(f),children:g.name}):n.jsx("span",{children:g.name}),n.jsx("span",{className:"breadcrumb-divider",children:"/"}),n.jsx(w3,{title:l.title,onRename:I=>e.renameSession(t.id,I)}),n.jsxs("span",{className:"session-crumb-note",children:["以前的对话",f!==vn&&(h==null?void 0:h.requestedBy)!==void 0?` · ${IL(h.requestedBy)}`:""]})]})}),qa.createPortal(A,document.body),l.error!==null&&n.jsx("div",{className:"banner error",children:l.error}),n.jsxs("div",{className:`session-body${S.panel!==null?" with-side":""}`,children:[n.jsxs("div",{className:"session-column",children:[n.jsxs("div",{className:"view",children:[N!==void 0&&b[0]!==void 0&&N.id!==b[0].id&&n.jsxs("div",{className:"view-back",children:[n.jsxs("button",{type:"button",className:"small-button",onClick:()=>j(b[0].id),children:[n.jsx(ee,{name:"back"}),"返回",b[0].title]}),n.jsx("span",{className:"view-back-title",children:N.title})]}),N===void 0?n.jsx("div",{className:"empty",children:"当前连接没有提供可用的视图插件。"}):n.jsx(qp.Provider,{value:U,children:n.jsx(N.component,{client:e,session:t,state:l,readOnly:C})})]}),C?n.jsxs("div",{className:"session-readonly",children:[n.jsx(ee,{name:"archive"}),n.jsx("span",{children:"这是以前的对话,只能查看,不能继续。"}),o!==void 0&&n.jsxs("button",{type:"button",className:"small-button",onClick:()=>o(f),children:["回到「",g.name,"」的对话"]})]}):n.jsxs(n.Fragment,{children:[n.jsx(xz,{client:e,session:t,running:l.running,disabled:u.state!=="open",initialPrompt:i,onInitialSent:r,reminder:s}),n.jsx(x3,{client:e,sessionId:t.id})]})]}),S.panel!==null&&n.jsx("div",{className:`side-slot side-${S.panel}`,children:S.panel==="browser"&&S.bridge!==void 0?n.jsx(VL,{bridge:S.bridge,onClose:()=>S.setPanel(null)}):S.panel==="tasks"&&S.task!==null?n.jsx(qp.Provider,{value:U,children:n.jsx(hx,{client:e,task:S.task,parent:g.name,trail:f===vn?[]:[cn.name],onClose:()=>S.openTask(null)},S.task.id)}):S.panel==="tasks"?n.jsx(ak,{title:"子任务",onClose:()=>S.setPanel(null),children:n.jsx(OD,{tasks:_,labels:O,settled:T,onOpen:S.openTask})}):n.jsx(ak,{title:"命令",onClose:()=>S.setPanel(null),children:n.jsx(zD,{client:e,own:D,tasks:_,labels:O})})})]})]})}const b3=[];function k3(){var b;const e=(b=li())==null?void 0:b.browser,[t,s]=v.useState(()=>N3()),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=k=>{u.current==="browser"&&k!=="browser"&&(l.current=Date.now()),s(k),o(null),bk(k)},h=v.useMemo(()=>k=>{o(k),k!==null&&(s("tasks"),bk("tasks"))},[]),[f,p]=v.useState(0);v.useEffect(()=>{if(e===void 0)return;let k;return e.onChange(j=>{const N=k!==void 0&&j.agentAt>k;k=j.agentAt,p(j.agentAt),N&&u.current===null&&Date.now()-l.current>j3&&s("browser")})},[e]);const g=Date.now()-f<yk,[,x]=v.useState(0);return v.useEffect(()=>{if(!g)return;const k=setTimeout(()=>x(j=>j+1),f+yk-Date.now()+50);return()=>clearTimeout(k)},[g,f]),{bridge:e,panel:i,setPanel:d,task:i==="tasks"?r:null,openTask:h,working:g}}const FS="adg.sidePanel",j3=3*6e4,yk=5e3;function N3(){try{const e=localStorage.getItem(FS);return e===null?localStorage.getItem("adg.browserPanel")==="1"?"browser":null:AS.some(t=>t.id===e)?e:null}catch{return null}}function bk(e){try{localStorage.setItem(FS,e??"")}catch{}}function w3({title:e,onRename:t}){const[s,i]=v.useState(null),[r,o]=v.useState(null),l=e??"新会话",u=async()=>{const d=(s==null?void 0:s.trim())??"";if(d===""||d===e){i(null);return}try{await t(d),i(null),o(null)}catch(h){o(h instanceof Error?h.message:String(h))}};return s!==null?n.jsxs("span",{className:"title-edit",children:[n.jsx("input",{className:"text-input",autoFocus:!0,value:s,maxLength:80,"aria-label":"会话名称",onChange:d=>i(d.target.value),onFocus:d=>d.target.select(),onKeyDown:d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&u(),d.key==="Escape"&&(i(null),o(null))},onBlur:()=>void u()}),r!==null&&n.jsx("span",{className:"error small",children:r})]}):n.jsxs("span",{className:"session-title",children:[n.jsx("h1",{title:"双击改名",onDoubleClick:()=>i(l),children:l}),n.jsx("button",{type:"button",className:"icon-button rename-button",title:"改名","aria-label":"给这个会话改名",onClick:()=>i(l),children:n.jsx(ee,{name:"pencil"})})]})}function S3({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(ee,{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(ee,{name:l.id==="trajectory"?"flow":"eye"}),l.title]},l.id))})]})}const US="adg.sessionTab";function _3(){try{return localStorage.getItem(US)??"chat"}catch{return"chat"}}function E3(e){try{localStorage.setItem(US,e)}catch{}}const BS="adg.theme",Jp=new Set;let uc=C3();function C3(){try{const e=localStorage.getItem(BS);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function HS(){var e,t;uc==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=uc,(t=(e=li())==null?void 0:e.setTheme)==null||t.call(e,uc).catch(()=>{})}function A3(e){uc=e;try{localStorage.setItem(BS,e)}catch{}HS();for(const t of Jp)t()}function ZS(){return v.useSyncExternalStore(e=>(Jp.add(e),()=>Jp.delete(e)),()=>uc)}const $3={"api-keys":"key",permissions:"shield",plugins:"plug","script-install":"package",emulators:"monitor",schedule:"calendar",feishu:"send",compaction:"compress",memory:"archive",about:"info"},I3=[["light","浅色"],["dark","深色"],["system","跟随系统"]];function T3({client:e,onClose:t,section:s,onSection:i}){const r=tO(e),o=ZS(),[l,u]=v.useState(null),d=l??s??null,h=p=>{u(p),i==null||i(p)},f=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(ee,{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===(f==null?void 0:f.id)?"active":""}`,"aria-current":p.id===(f==null?void 0:f.id)?"page":void 0,onClick:()=>h(p.id),children:[n.jsx(ee,{name:$3[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:I3.map(([p,g])=>n.jsx("button",{role:"radio","aria-checked":o===p,className:o===p?"active":"",onClick:()=>A3(p),children:g},p))})]})]}),n.jsx("section",{className:"main settings",children:n.jsx("div",{className:"settings-content",children:f===void 0?n.jsx("div",{className:"empty",children:"当前连接没有提供可配置的项目。"}):n.jsx(f.component,{client:e})})})]})}const WS="adg.showEarlierTab",eg=new Set;function M3(){try{return localStorage.getItem(WS)==="1"}catch{return!1}}let VS=M3();function R3(e){VS=e;try{localStorage.setItem(WS,e?"1":"0")}catch{}for(const t of eg)t()}function vx(){return v.useSyncExternalStore(e=>(eg.add(e),()=>{eg.delete(e)}),()=>VS)}const O3=["日","一","二","三","四","五","六"],P3=[1,2,3,4,5,6,0],Ff=[1,2,3,4,5],Uf=[0,6],L3={[vn]:[{title:"早上说说今天要做什么",prompt:"看看今天有哪些活动快结束、哪些日常还没做,整理成几句话告诉我。"}],games:[{title:"看三天内结束的活动",prompt:"查各个游戏今天和三天内结束的活动,列出名字、所属游戏和剩余时间;已经做完的不用列。"},{title:"看新版本和公告",prompt:"看各个游戏最近一天的新版本、维护和重要公告,有变化的用一两句话说明,没有就说没有。"}],scripts:[{title:"检查脚本有没有新版本",prompt:"检查已安装的脚本有没有新版本,有的话说明更新了什么;先不要安装。"}],intervene:[{title:"汇总夜里的异常",prompt:"汇总最近 12 小时运行里出过的异常:哪些已经自动处理了,哪些还要我管、该怎么做。"}],pipelines:[{title:"检查流水线跑得怎么样",prompt:"看看各条流水线最近一次运行是否成功,失败的说明卡在哪一步、可能的原因。"}]};function Po(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 Uc=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"});function z3(e){const t=ke(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:Ce(u)}))}),()=>{l=!1}},[e,t.state,s]),r}function D3(e){const t=ke(e.connection.status),s=ke(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 F3(e){const t=ke(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 U3(e){const t=ke(e.connection.status),s=ke(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 qS(e){const t=qs(e);return v.useMemo(()=>[cn,...t.map(Ya)],[t])}function dc({agent:e,size:t="small"}){return n.jsx("span",{className:`agent-avatar ${t} agent-${(e==null?void 0:e.id)??"unknown"}`,children:n.jsx(ee,{name:(e==null?void 0:e.icon)??"sparkles"})})}function B3({client:e,focus:t,agent:s}){const i=qS(e),{items:r,error:o}=z3(e),l=D3(e),u=F3(e),d=U3(e),h=mn(3e4),[f,p]=v.useState(s??null),[g,x]=v.useState(null),[b,k]=v.useState(void 0),j=v.useRef(null),N=v.useRef(void 0),C=u.filter(O=>O.schedule.enabled&&O.draft!==!0),S=(d==null?void 0:d.schedule.enabled)===!0?d:null,_=new Map(i.map(O=>[O.id,0]));for(const O of r??[])_.set(O.agent,(_.get(O.agent)??0)+1);for(const O of l)_.set(O.agent,(_.get(O.agent)??0)+1);_.set("pipelines",(_.get("pipelines")??0)+C.length),S!==null&&_.set("games",(_.get("games")??0)+1);const z=[..._.values()].reduce((O,T)=>O+T,0),P=i.filter(O=>f===null||O.id===f);v.useEffect(()=>{s!==void 0&&p(s)},[s]),v.useEffect(()=>{var T,D;if(t===void 0||N.current===t)return;const O=((T=r==null?void 0:r.find(U=>U.id===t))==null?void 0:T.agent)??((D=l.find(U=>U.id===t))==null?void 0:D.agent);O!==void 0&&(N.current=t,p(U=>U===null||U===O?U:null),k(t))},[t,r,l]),v.useEffect(()=>{var D;if(b===void 0)return;const O=(D=j.current)==null?void 0:D.querySelector(`[data-schedule-id="${CSS.escape(b)}"]`);if(O==null)return;O.scrollIntoView({block:"center",behavior:"smooth"});const T=setTimeout(()=>k(void 0),2600);return()=>clearTimeout(T)},[b]);const H=v.useMemo(()=>[...S===null?[]:[{key:"daily-report",agent:"games",title:"每日日报",at:Po(S.schedule,h)}],...(r??[]).map(O=>({key:O.id,agent:O.agent,title:O.title,at:Po(O.schedule,h)})),...C.map(O=>({key:O.id,agent:"pipelines",title:`流水线「${O.name}」`,at:Po(O.schedule,h)})),...l.map(O=>({key:O.id,agent:O.agent,title:`提醒:${O.title}`,at:O.next}))].filter(O=>O.at!==void 0&&(f===null||O.agent===f)).sort((O,T)=>O.at-T.at).slice(0,8),[r,l,C,S,h,f]),B=O=>{var T;x({kind:"new",agent:O}),(T=j.current)==null||T.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:"定时任务"}),z>0&&n.jsx("span",{className:"tab-count",children:z})]}),n.jsxs("div",{className:"page-actions",children:[n.jsxs("a",{className:"small-button",href:"#/settings/schedule",children:[n.jsx(ee,{name:"settings"}),"开机自启与唤醒"]}),n.jsxs("button",{className:"small-button primary",onClick:()=>B(f??vn),disabled:(g==null?void 0:g.kind)==="new",children:[n.jsx(ee,{name:"plus"}),"新建定时任务"]})]})]}),n.jsxs("div",{className:"schedule-body",ref:j,children:[n.jsx("p",{className:"muted small",children:"到点把一件事交给某个 agent,在它的对话里做;做完后要紧的由助手告诉你。所有 agent 的定时任务、它们在对话里自己设的提醒、按时运行的流水线和游戏的每日日报都在这里。要跑脚本的多步任务,用「编排」做成流水线。"}),o!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:o})]}),(g==null?void 0:g.kind)==="new"&&n.jsx(kk,{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 ${f===null?"on":""}`,"aria-pressed":f===null,onClick:()=>p(null),children:["全部",n.jsx("span",{className:"tab-count",children:z})]}),i.map(O=>n.jsxs("button",{className:`agent-chip ${f===O.id?"on":""}`,"aria-pressed":f===O.id,onClick:()=>p(f===O.id?null:O.id),children:[n.jsx(dc,{agent:O}),O.name,n.jsx("span",{className:"tab-count",children:_.get(O.id)??0})]},O.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(O=>{const T=i.find(D=>D.id===O.agent);return n.jsxs("li",{children:[n.jsx("span",{className:"schedule-when",children:Uc(O.at)}),n.jsx(dc,{agent:T}),n.jsx("span",{className:"schedule-who",children:(T==null?void 0:T.name)??"?"}),n.jsx("span",{className:"schedule-what",children:O.title})]},`${O.key}@${O.at}`)})})]}),P.map(O=>{const T=(r??[]).filter(R=>R.agent===O.id),D=l.filter(R=>R.agent===O.id),U=O.id==="pipelines"?C:[],A=O.id==="games"?S:null,I=T.length===0&&D.length===0&&U.length===0&&A===null;return I&&f!==O.id?null:n.jsxs("section",{className:"schedule-group",children:[n.jsxs("h3",{className:"schedule-agent",children:[n.jsx(dc,{agent:O}),O.name,n.jsx("span",{className:"tab-count",children:T.length+D.length+U.length+(A===null?0:1)}),n.jsx("span",{className:"spacer"}),n.jsxs("button",{className:"link-button",onClick:()=>B(O.id),children:[n.jsx(ee,{name:"plus"}),"给",O.name,"新建"]})]}),I&&n.jsxs("div",{className:"empty-card muted",children:[O.name,"还没有定时任务。"]}),A!==null&&n.jsx(H3,{report:A,now:h}),T.map(R=>(g==null?void 0:g.kind)==="edit"&&g.id===R.id?n.jsx(kk,{client:e,agents:i,task:R,onDone:()=>x(null)},R.id):n.jsx(q3,{client:e,task:R,now:h,lit:b===R.id,onEdit:()=>x({kind:"edit",id:R.id})},R.id)),D.length>0&&n.jsxs("p",{className:"muted small schedule-sub",children:[O.name,"在对话里自己设的提醒:你让它「几点提醒我…」时设的,到点它在对话里接着做。要改时间,直接跟它说。"]}),D.map(R=>n.jsx(W3,{client:e,reminder:R,now:h,lit:b===R.id},R.id)),U.map(R=>n.jsx(Z3,{pipeline:R,now:h},R.id))]},O.id)}),r!==null&&z===0&&g===null&&f===null&&n.jsx("div",{className:"empty-card muted",children:"还没有定时任务。点「新建定时任务」,选一个 agent、写下到点要它做的事。"})]})]})}function H3({report:e,now:t}){const s=Po(e.schedule,t);return n.jsxs("a",{className:"task-card pipeline-line",href:"#/p/daily-report",title:"在游戏的「日报」里设置",children:[n.jsx(ee,{name:"send"}),n.jsx("span",{className:"task-title",children:"每日日报"}),n.jsxs("span",{className:"muted small",children:[Lg(e.schedule),s===void 0?"":` · 下次 ${Uc(s)}`," · 发到飞书"]}),n.jsx("span",{className:"muted small daily-report-where",children:"在游戏的「日报」里设置"}),n.jsx(ee,{name:"chevron"})]})}function Z3({pipeline:e,now:t}){const s=Po(e.schedule,t);return n.jsxs("a",{className:"task-card pipeline-line",href:`#/p/pipelines/${encodeURIComponent(e.id)}`,children:[n.jsx(ee,{name:"flow"}),n.jsx("span",{className:"task-title",children:e.name}),n.jsxs("span",{className:"muted small",children:[Lg(e.schedule),s===void 0?"":` · 下次 ${Uc(s)}`]}),n.jsx(ee,{name:"chevron"})]})}function W3({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(Ce(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(ee,{name:"calendar"}),n.jsx("span",{className:"task-title",children:t.title}),n.jsxs("span",{className:"muted small",children:[t.rule==="一次"?"":`${t.rule} · `,t.repeats?"下次 ":"",Uc(t.next),t.next>s?`(${V3(t.next-s)}后)`:""]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"icon-button",onClick:()=>void l(),title:"删除这个提醒","aria-label":"删除",children:n.jsx(ee,{name:"close"})})]}),n.jsx("div",{className:"task-prompt",children:t.prompt}),r!==null&&n.jsx("div",{className:"error small",children:r})]})}function V3(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 q3({client:e,task:t,now:s,lit:i,onEdit:r}){const[o,l]=v.useState(null),u=Po(t.schedule,s),d=t.lastRun,h=g=>{l(null),e.connection.call(g,{id:t.id}).catch(x=>l(Ce(x)))},f=()=>{l(null),e.connection.call("tasks/save",{task:{...t,schedule:{...t.schedule,enabled:!t.schedule.enabled}}}).catch(g=>l(Ce(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:[Lg(t.schedule),u===void 0?"":` · 下次 ${Uc(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:f,children:t.schedule.enabled?"暂停":"开启"}),n.jsx("button",{className:"icon-button",onClick:r,title:"修改","aria-label":"修改",children:n.jsx(ee,{name:"pencil"})}),n.jsx("button",{className:"icon-button",onClick:()=>void p(),title:"删除","aria-label":"删除",children:n.jsx(ee,{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(ee,{name:d.state==="done"?"check":"alert"}),n.jsxs("span",{children:[d.state==="running"?"正在做":`${gt(d.endedAt??d.startedAt,s)}${d.state==="done"?"做完":"没做成"}`,d.outcome===void 0?"":`:${d.outcome.split(`
204
+ `)[0]}`]})]}),o!==null&&n.jsx("div",{className:"error small",children:o})]})}function kk({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??""),[f,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)??[]),[b,k]=v.useState(!1),[j,N]=v.useState(null),C=t.find(B=>B.id===r)??cn,S=L3[r]??[],_=(B,O)=>B.length===O.length&&B.every(T=>O.includes(T)),z=async()=>{var B,O;k(!0),N(null);try{const T=f.split(/[,,、\s]+/).filter(D=>D!=="").map(D=>/^\d:\d\d$/.test(D)?`0${D}`:D);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:T,days:[...g],catchUpMinutes:((O=s.schedule)==null?void 0:O.catchUpMinutes)??10}}}),i()}catch(T){N(Ce(T))}finally{k(!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(dc,{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:["要",C.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:f,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 ${_(g,Ff)?"on":""}`,"aria-pressed":_(g,Ff),onClick:()=>x(Ff),children:"工作日"}),n.jsx("button",{type:"button",className:`day-preset ${_(g,Uf)?"on":""}`,"aria-pressed":_(g,Uf),onClick:()=>x(Uf),children:"周末"}),n.jsx("span",{className:"day-chips-gap"}),P3.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(O=>O!==B):[...g,B]),children:O3[B]},B))]})]})]})]}),j!==null&&n.jsx("div",{className:"error small",children:j}),n.jsxs("div",{className:"task-form-actions",children:[n.jsx("button",{className:"small-button",onClick:i,disabled:b,children:"取消"}),n.jsx("button",{className:"small-button primary",onClick:()=>void z(),disabled:b||l.trim()===""||d.trim()==="",children:s.id===void 0?`交给${C.name}`:"保存"})]})]})}function G3({client:e,onOpen:t}){const s=qS(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(f=>f.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),f=u.kind==="task"?u.changed?"改了一个定时任务":"设了一个定时任务":"设了一个提醒";return n.jsxs("div",{className:"schedule-notice",role:"status",children:[n.jsx(dc,{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",f]}),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(ee,{name:"clock"}),"去定时任务看看"]})})]}),n.jsx("button",{className:"icon-button",onClick:()=>l(u.key),title:"知道了","aria-label":"关闭",children:n.jsx(ee,{name:"close"})})]},u.key)})})}const K3=["切换到 dsh 官方界面:DeepSeek Harness 自带的原版界面,没有 MultiGameAssistant 的脚本、编排、游戏等功能。","","· 它是另一个独立的 dsh:聊天记录、设置和模型密钥都和这里分开,第一次用要在那边重新填模型密钥;","· 第一次切换要启动它,可能要等一会儿;","· 这边的定时任务和脚本在后台照常运行。","","点标题栏左上角的「返回 MultiGameAssistant」切回来。"].join(`
205
+ `),GS="adg.officialIntro";function Y3(){var l;const e=(l=li())==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=()=>{Q3(),e.set("official")};if(X3()){u();return}Ms({title:"切换到 dsh 官方界面?",message:K3,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(ee,{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(ee,{name:"close"})})]})]})}function X3(){try{return localStorage.getItem(GS)==="1"}catch{return!1}}function Q3(){try{localStorage.setItem(GS,"1")}catch{}}const tg="adg.token",ch=/^\/adg(\/|$)/.test(location.pathname);function J3(){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 e5(){const e=new URL(location.href),t=e.searchParams.get("token");if(t!==null&&t!==""){try{sessionStorage.setItem(tg,t)}catch{}return e.searchParams.delete("token"),history.replaceState(history.state,"",e),t}let s=null;try{s=sessionStorage.getItem(tg)}catch{}return s??null}function t5(e){try{sessionStorage.setItem(tg,e)}catch{}}function n5(e){if(ch){const s=new URL(J3()??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 jk(){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\/(.+)\/(history)$/.exec(location.hash);if(o!==null)return{kind:"agent",id:decodeURIComponent(o[1]),tab:o[2]};const l=/^#\/a\/(.+)$/.exec(location.hash);if(l!==null)return{kind:"agent",id:decodeURIComponent(l[1])};const u=/^#\/s\/(.+)$/.exec(location.hash);return u===null?{kind:"start"}:{kind:"session",id:decodeURIComponent(u[1])}}function s5(e,t="push"){const s=e.kind==="session"?`#/s/${encodeURIComponent(e.id)}`:e.kind==="agent"?`#/a/${encodeURIComponent(e.id)}${e.tab===void 0?"":`/${e.tab}`}`:e.kind==="handoff"?`#/h/${encodeURIComponent(e.id)}`:e.kind==="schedule"?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 Bf="games";function i5({client:e}){const[t,s]=v.useState(()=>jk()),[i,r]=UL(),[o,l]=v.useState(null),u=ke(e.sessions),d=nO(e),h=ke(e.connection.status),f=qs(e),p=v.useRef(!1),g=v.useRef(null);v.useEffect(()=>{s5(t,p.current?"replace":"push"),p.current=!1,t.kind!=="handoff"&&(g.current=t)},[t]);const x=t.kind==="handoff"?t:null,b=g.current,k=x===null?t:b!==null&&b.kind!=="settings"?b:{kind:"agent",id:vn};v.useEffect(()=>{const V=()=>s(jk());return window.addEventListener("hashchange",V),()=>window.removeEventListener("hashchange",V)},[]);const j=v.useRef(new Set);v.useEffect(()=>{for(const Q of u.items)j.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(j.current.has(t.id)){V();return}const Z=setTimeout(V,8e3);return()=>clearTimeout(Z)},[t,u]),v.useEffect(()=>{var Z;if(t.kind!=="session")return;const V=(Z=u.items.find(Q=>Q.id===t.id))==null?void 0:Z.home;V===void 0||V!==vn&&!f.some(Q=>Q.id===V)||(p.current=!0,s({kind:"agent",id:V}))},[t,u,f]),v.useEffect(()=>{t.kind!=="start"||h.state!=="open"||(p.current=!0,s(d.some(V=>V.id===Bf)?{kind:"page",id:Bf}:{kind:"home"}))},[t,h.state,d]);const N=vx(),C=k.kind==="agent"&&(k.tab!=="history"||N)?k.tab:void 0,S=V=>s({kind:"session",id:V}),_=V=>s({kind:"settings",...V===void 0?{}:{section:V}}),z=V=>s({kind:"page",id:V}),P=k.kind==="session"?k.id:null,H=P===null?void 0:u.items.find(V=>V.id===P),B=k.kind==="start"?{kind:"page",id:Bf}:k,O=B.kind==="page"?d.find(V=>V.id===B.id):void 0,T=V=>V.agent===void 0?void 0:f.some(Z=>Z.id===V.agent)?V.agent:vn,D=O===void 0?void 0:T(O),U=V=>s({kind:"agent",id:V}),A=()=>U(vn),I=n.jsxs(n.Fragment,{children:[n.jsx(o5,{client:e,onSettings:()=>_("api-keys")}),n.jsx(mO,{client:e})]}),R=k.kind==="home"?vn:k.kind==="agent"?k.id:k.kind==="session"?H===void 0?void 0:Da(H,f):D,L=(V,Z)=>s(Z==="chat"?{kind:"agent",id:V}:Z==="history"?{kind:"agent",id:V,tab:Z}:{kind:"page",id:Z}),K=k.kind==="settings"?{kind:"settings"}:k.kind==="schedule"?{kind:"schedule"}:R!==void 0?{kind:"agent",id:R}:B.kind==="page"?{kind:"page",id:B.id}:{kind:"none"},F=O===void 0?null:n.jsx(O.component,{client:e,openSession:S,openSettings:_,openPage:z,arg:B.kind==="page"?B.arg:void 0},O.id),q=R===void 0?null:n.jsx(r5,{client:e,agentId:R,pages:d.filter(V=>T(V)===R),current:C!==void 0?C:k.kind==="session"?"history":B.kind==="page"?B.id:"chat",onTab:V=>L(R,V)});return n.jsx(Qw.Provider,{value:o,children:n.jsx(WL.Provider,{value:i>=Oo,children:n.jsxs("div",{className:`app ${k.kind==="settings"?"with-sidebar":""}`,style:{"--rail-width":`${i}px`},children:[n.jsx(DL,{client:e,pages:d.filter(V=>V.agent===void 0),current:K,onAgent:U,onPage:z,onSchedule:()=>s({kind:"schedule"}),onSettings:()=>_(),width:i,onWidth:r,slot:l}),k.kind==="settings"&&n.jsx(T3,{client:e,onClose:A,section:k.section,onSection:V=>s({kind:"settings",section:V})}),k.kind!=="settings"&&n.jsxs("div",{className:`app-main ${x===null?"":"under-exchange"}`,children:[B.kind==="page"&&D===void 0&&(F??n.jsx("section",{className:"main empty",children:h.state==="open"?"当前连接没有提供这个功能。":"正在连接…"})),R!==void 0&&n.jsxs("div",{className:"agent-area",children:[q,D!==void 0?F:k.kind==="agent"&&C==="history"?n.jsx(zL,{client:e,agentId:k.id,onSelect:S},k.id):k.kind==="session"?n.jsx(Qp,{client:e,sessionId:k.id,onAgent:U,reminder:I},k.id):n.jsx(a5,{client:e,agentId:R,onMain:A,onAgent:U,reminder:I},R)]}),k.kind==="schedule"&&n.jsx(B3,{client:e,focus:k.focus,agent:k.agent}),k.kind==="session"&&R===void 0&&n.jsx(Qp,{client:e,sessionId:k.id,onAgent:U,reminder:I},k.id),x!==null&&n.jsx(Kz,{client:e,id:x.id,onClose:()=>s(k)},x.id)]}),n.jsx(EL,{client:e,sessionId:P,onSelect:S}),n.jsx(G3,{client:e,onOpen:V=>s({kind:"schedule",...V===void 0?{}:{focus:V}})}),n.jsx(Y3,{})]})})})}function r5({client:e,agentId:t,pages:s,current:i,onTab:r}){const l=qs(e).find(g=>g.id===t),u=l===void 0?cn:Ya(l),d=LL(e,t),h=vx()&&(d||i==="history"),f=[{id:"chat",title:"对话",icon:"chat"},...[...s].sort((g,x)=>g.order-x.order).map(g=>({id:g.id,title:g.title,icon:g.icon})),...h?[{id:"history",title:"以前的对话",icon:"archive"}]:[]];if(f.length===1)return null;const p=n.jsx("nav",{className:"agent-tabs in-title-bar",role:"tablist","aria-label":u.name,children:f.map(g=>n.jsxs("button",{role:"tab","aria-selected":g.id===i,className:g.id===i?"active":"",onClick:()=>r(g.id),children:[n.jsx(ee,{name:g.icon}),g.title]},g.id))});return qa.createPortal(p,document.body)}function a5({client:e,agentId:t,onMain:s,onAgent:i,reminder:r}){const{sessionId:o,error:l}=Yw(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(Qp,{client:e,sessionId:o,onAgent:i,reminder:r},o)}function o5({client:e,onSettings:t}){var o;const{items:s}=rw(e,[_p]),{catalog:i}=Ga(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(ee,{name:"key"}),n.jsx("span",{children:"还没有可用的模型:请填写 DeepSeek API Key,或添加一个自定义 API(Claude、ChatGPT 等)。"}),n.jsx("button",{className:"primary small-button",onClick:t,children:"去设置"})]})}function l5({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(Wg,{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 c5=["准备环境","启动服务","载入界面","连接 agent"],u5=8e3,d5=400;function h5({client:e}){const t=ke(e.connection.status),s=ke(e.sessions),[i,r]=v.useState("shown"),[o,l]=v.useState(!1),u=t.state==="open"&&s.loaded;if(v.useEffect(()=>{const f=setTimeout(()=>l(!0),u5);return()=>clearTimeout(f)},[]),v.useEffect(()=>{u&&r(f=>f==="shown"?"leaving":f)},[u]),v.useEffect(()=>{if(i!=="leaving")return;const f=setTimeout(()=>r("gone"),d5);return()=>clearTimeout(f)},[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:c5.map((f,p)=>n.jsxs("li",{className:p<3?"done":"now",children:[n.jsx("i",{}),n.jsx("span",{children:f})]},f))}),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 m5 extends v.Component{constructor(){super(...arguments);dt(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}
206
+
207
+ ${(s.stack??"").split(`
208
+ `).slice(1,8).join(`
209
+ `)}`;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 f5=450,ed=6,Hl=8,Hf="data-tip";function p5(){return Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--title-bar"))||0}function g5(){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 f=o.getAttribute(Hf);o.removeAttribute(Hf),f!==null&&!o.hasAttribute("title")&&o.setAttribute("title",f)}o=null,t(null)},d=f=>{var x,b,k,j;if(f.pointerType==="touch")return;if(o!==null&&o.contains(f.target)){const N=(b=(x=f.target).closest)==null?void 0:b.call(x,"[title]");if(N==null||!o.contains(N))return}const p=((j=(k=f.target)==null?void 0:k.closest)==null?void 0:j.call(k,"[title]"))??null;if(p===o||(u(),p===null))return;const g=p.getAttribute("title")??"";g.trim()!==""&&(o=p,p.setAttribute(Hf,g),p.removeAttribute("title"),l=window.setTimeout(()=>{o===p&&p.isConnected&&t({text:g,anchor:p.getBoundingClientRect(),side:p.closest(".rail")!==null?"right":"auto"})},f5))},h=f=>{if(o===null)return;const p=f.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+ed,top:d(u.top+u.height/2-l/2),side:"right"});return}const h=u.top-ed-l<Hl+p5(),f=Math.max(Hl,Math.min(u.left+u.width/2-o/2,window.innerWidth-o-Hl));r({left:f,top:h?u.bottom+ed:u.top-ed-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 x5={id:"chat",title:"对话",requires:["sessions","chat"],sessionViews:[{id:"chat",title:"对话",order:0,component:uS}]},v5=[],Zf=320,td=4;function Ot({value:e,options:t,onChange:s,id:i,disabled:r,placeholder:o="请选择",inline:l,className:u,...d}){const h=v.useId(),f=v.useRef(null),p=v.useRef(null),[g,x]=v.useState(!1),[b,k]=v.useState(-1),[j,N]=v.useState({}),C=t.findIndex(D=>D.value===e),S=C===-1?void 0:t[C],_=D=>t[D]!==void 0&&t[D].disabled!==!0,z=(D,U)=>{for(let A=D+U;A>=0&&A<t.length;A+=U)if(_(A))return A;return D},P=(D=C)=>{r!==!0&&(k(_(D)?D:z(-1,1)),x(!0))},H=(D=!0)=>{var U;x(!1),D&&((U=f.current)==null||U.focus())},B=D=>{_(D)&&(t[D].value!==e&&s(t[D].value),H())};v.useLayoutEffect(()=>{if(!g)return;const D=()=>{var K,F;const U=(K=f.current)==null?void 0:K.getBoundingClientRect();if(U===void 0)return;const A=window.innerHeight-U.bottom-td-8,I=U.top-td-8,R=A<Math.min(Zf,((F=p.current)==null?void 0:F.scrollHeight)??Zf)&&I>A,L=Math.max(U.width,180);N({left:Math.max(8,Math.min(U.left,window.innerWidth-L-8)),minWidth:L,maxWidth:Math.max(L,Math.min(520,window.innerWidth-16)),maxHeight:Math.min(Zf,R?I:A),...R?{bottom:window.innerHeight-U.top+td}:{top:U.bottom+td}})};return D(),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0),()=>{window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[g]),v.useEffect(()=>{var U;if(!g)return;(U=p.current)==null||U.focus({preventScroll:!0});const D=A=>{var R,L;const I=A.target;!((R=p.current)!=null&&R.contains(I))&&!((L=f.current)!=null&&L.contains(I))&&H(!1)};return document.addEventListener("pointerdown",D,!0),()=>document.removeEventListener("pointerdown",D,!0)},[g]),v.useEffect(()=>{var D,U;g&&b>=0&&((U=(D=p.current)==null?void 0:D.querySelector(`[data-index="${b}"]`))==null||U.scrollIntoView({block:"nearest"}))},[g,b]);const O=D=>{(D.key==="ArrowDown"||D.key==="ArrowUp"||D.key==="Enter"||D.key===" ")&&(D.preventDefault(),P())},T=D=>{const A={ArrowDown:()=>k(I=>z(I,1)),ArrowUp:()=>k(I=>z(I,-1)),Home:()=>k(z(-1,1)),End:()=>k(z(t.length,-1)),Enter:()=>B(b)," ":()=>B(b),Escape:()=>H(),Tab:()=>H()}[D.key];if(A!==void 0){D.key!=="Tab"&&D.preventDefault(),A();return}if(D.key.length===1&&!D.ctrlKey&&!D.metaKey&&!D.altKey){const I=D.key.toLowerCase();for(let R=1;R<=t.length;R++){const L=(b+R)%t.length;if(_(L)&&t[L].label.toLowerCase().startsWith(I)){k(L);break}}}};return n.jsxs(n.Fragment,{children:[n.jsx("button",{ref:f,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:O,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:j,"aria-label":d["aria-label"],"aria-activedescendant":b>=0?`${h}-${b}`:void 0,onKeyDown:T,children:[t.map((D,U)=>{var A;return n.jsxs("li",{role:"presentation",children:[D.group!==void 0&&D.group!==((A=t[U-1])==null?void 0:A.group)&&n.jsx("div",{className:"select-group",children:D.group}),n.jsxs("div",{id:`${h}-${U}`,"data-index":U,role:"option","aria-selected":U===C,"aria-disabled":D.disabled===!0,className:`select-option ${U===b?"active":""} ${U===C?"selected":""} ${D.disabled===!0?"disabled":""}`,onPointerMove:()=>{_(U)&&U!==b&&k(U)},onClick:()=>B(U),children:[n.jsxs("span",{className:"select-text",children:[n.jsx("span",{children:D.label}),D.hint!==void 0&&n.jsx("span",{className:"select-hint",children:D.hint})]}),U===C&&n.jsx(ee,{name:"check",className:"select-check"})]})]},`${D.group??""}\0${D.value}`)}),t.length===0&&n.jsx("li",{role:"presentation",className:"select-empty",children:"没有可选的"})]}),document.body)]})}const y5={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function b5({client:e}){const t=ke(e.connection.status),s=mn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(null),[u,d]=v.useState(0),[h,f]=v.useState(null),[p,g]=v.useState(null),[x,b]=v.useState(null),[k,j]=v.useState(""),[N,C]=v.useState(""),[S,_]=v.useState(""),[z,P]=v.useState(""),[H,B]=v.useState({});v.useEffect(()=>e.connection.on("notify/changed",()=>d(R=>R+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let R=!0;return e.connection.call("feishu/settings",{}).then(L=>{R&&(r(L),j(K=>K===""?L.settings.appId??"":K),_(K=>K===""?L.settings.chatId??"":K))}).catch(L=>{R&&g(Ce(L))}),e.connection.call("notify/status",{}).then(L=>{R&&l(L.channels.find(K=>K.id==="feishu")??null)}).catch(()=>{}),()=>{R=!1}},[e,t.state,u]);const O=async(R,L,K)=>{f(R),g(null),b(null);try{const F=await L();F!==null&&typeof F=="object"&&"settings"in F&&r(F),K!==void 0&&b(K),d(q=>q+1)}catch(F){g(Ce(F))}finally{f(null)}},T=()=>O("credentials",async()=>(N.trim()!==""&&await e.setCredential(mR,N.trim()),C(""),e.connection.call("feishu/settings/set",{appId:k.trim()===""?null:k.trim(),enabled:!0})),"已保存,正在连接…"),D=()=>O("test",async()=>{const R=await e.connection.call("notify/test",{channel:"feishu"});if(R.failed.length>0)throw new Error(R.failed.map(L=>L.error).join(";"))},"测试消息已发送,去飞书看看"),U=i==null?void 0:i.settings,[A,I]=y5[(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(R=>n.jsxs("li",{className:R.ok===!0?"ok":R.ok===!1?"failed":"",children:[n.jsx("span",{className:"check-mark",children:R.ok===!0?"✓":R.ok===!1?"✗":"…"}),n.jsx("span",{children:R.label}),R.detail!==void 0&&n.jsx("span",{className:"muted small",children:R.detail})]},R.id))}),n.jsxs("div",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void O("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 D(),children:"发送测试消息"}),U!==void 0&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:U.enabled,disabled:h!==null,onChange:R=>void O("enable",()=>e.connection.call("feishu/settings/set",{enabled:R.target.checked}))}),"启用飞书"]})]})]}),U!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"应用凭证"}),n.jsx("label",{className:"field-label",htmlFor:"feishu-domain",children:"平台"}),n.jsx(Ot,{id:"feishu-domain",value:U.domain,disabled:h!==null,onChange:R=>void O("domain",()=>e.connection.call("feishu/settings/set",{domain:R})),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:k,onChange:R=>j(R.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:N,onChange:R=>C(R.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||k.trim()==="",onClick:()=>void T(),children:h==="credentials"?"保存中…":"保存并连接"})]})]}),U!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"允许的用户"}),n.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令、按卡片上的按钮;通知也发给他们。"}),U.allowedUsers.length===0&&n.jsx("div",{className:"muted small",children:"还没有。给机器人发一条消息,它会出现在下面的「待允许」里。"}),n.jsx("ul",{className:"version-list",children:U.allowedUsers.map(R=>n.jsxs("li",{children:[n.jsx("span",{children:R.name??"(未命名)"}),n.jsx("span",{className:"muted small",children:R.openId}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void O(`rm-${R.openId}`,()=>e.connection.call("feishu/users/remove",{openId:R.openId})),children:"移除"})]},R.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(R=>n.jsxs("li",{children:[n.jsx("span",{className:"muted small",children:R.openId}),n.jsxs("span",{className:"muted small",children:["「",R.text,"」 · ",gt(R.at,s)]}),n.jsx("span",{className:"spacer"}),n.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:H[R.openId]??"",onChange:L=>B(K=>({...K,[R.openId]:L.target.value}))}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void O(`dismiss-${R.openId}`,()=>e.connection.call("feishu/users/remove",{openId:R.openId})),children:"忽略"}),n.jsx("button",{className:"primary small-button",disabled:h!==null,onClick:()=>void O(`allow-${R.openId}`,()=>{var L;return e.connection.call("feishu/users/allow",{openId:R.openId,...(L=H[R.openId])!=null&&L.trim()?{name:H[R.openId].trim()}:{}})}),children:"允许"})]},R.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:z,onChange:R=>P(R.target.value),placeholder:"ou_xxxxxxxx",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:h!==null||z.trim()==="",onClick:()=>void O("manual",async()=>{const R=await e.connection.call("feishu/users/allow",{openId:z.trim()});return P(""),R}),children:"添加"})]})]}),U!==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:U.otherApprovals,disabled:h!==null,onChange:R=>void O("approvals",()=>e.connection.call("feishu/settings/set",{otherApprovals:R.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:R=>_(R.target.value),placeholder:"oc_xxxxxxxx",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void O("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(ee,{name:"check"}),n.jsx("span",{children:x})]}),p!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:p})]})]})}const k5={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function j5({client:e}){const t=ke(e.connection.status),s=mn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(null),[u,d]=v.useState(0),[h,f]=v.useState(null),[p,g]=v.useState(null),[x,b]=v.useState(null),[k,j]=v.useState(""),[N,C]=v.useState(""),[S,_]=v.useState(""),[z,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),j(R=>R===""?I.settings.appId??"":R))}).catch(I=>{A&&g(Ce(I))}),e.connection.call("notify/status",{}).then(I=>{A&&l(I.channels.find(R=>R.id==="qq")??null)}).catch(()=>{}),()=>{A=!1}},[e,t.state,u]);const H=async(A,I,R)=>{f(A),g(null),b(null);try{const L=await I();L!==null&&typeof L=="object"&&"settings"in L&&r(L),R!==void 0&&b(R),d(K=>K+1)}catch(L){g(Ce(L))}finally{f(null)}},B=()=>H("credentials",async()=>(N.trim()!==""&&await e.setCredential(fR,N.trim()),C(""),e.connection.call("qqbot/settings/set",{appId:k.trim()===""?null:k.trim(),enabled:!0})),"已保存,正在连接…"),O=()=>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 看看"),T=i==null?void 0:i.settings,[D,U]=k5[(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 ${D}`,children:U})]}),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 O(),children:"发送测试消息"}),T!==void 0&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:T.enabled,disabled:h!==null,onChange:A=>void H("enable",()=>e.connection.call("qqbot/settings/set",{enabled:A.target.checked}))}),"启用 QQ 机器人"]})]})]}),T!==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:k,onChange:A=>j(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:N,onChange:A=>C(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||k.trim()==="",onClick:()=>void B(),children:h==="credentials"?"保存中…":"保存并连接"})]})]}),T!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"允许的用户"}),n.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令;通知和与助手的对话也发给他们。"}),T.allowedUsers.length===0&&n.jsx("div",{className:"muted small",children:"还没有。在 QQ 里给机器人发一条消息,它会出现在下面的「待允许」里。"}),n.jsx("ul",{className:"version-list",children:T.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,"」 · ",gt(A.at,s)]}),n.jsx("span",{className:"spacer"}),n.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:z[A.openId]??"",onChange:I=>P(R=>({...R,[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=z[A.openId])!=null&&I.trim()?{name:z[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=>_(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 _(""),A}),children:"添加"})]})]}),x!==null&&n.jsxs("div",{className:"notice info left",children:[n.jsx(ee,{name:"check"}),n.jsx("span",{children:x})]}),p!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:p})]})]})}const N5=[{id:"feishu",title:"飞书",capability:"feishu",component:b5},{id:"qq",title:"QQ 机器人",capability:"qqbot",component:j5}];function w5({client:e}){var l;const t=ke(e.capabilities),s=N5.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 S5=(e,t)=>{try{const s=localStorage.getItem(`adg.fold.${e}`);return s===null?t:s==="1"}catch{return t}};function _5(e,t=!0){const[s,i]=v.useState(()=>S5(e,t));return[s,()=>i(o=>{try{localStorage.setItem(`adg.fold.${e}`,o?"0":"1")}catch{}return!o})]}function E5({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(ee,{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 Oa({id:e,title:t,count:s,initial:i=!0,children:r,className:o=""}){const[l,u]=_5(e,i);return n.jsxs("div",{className:`fold ${o}`,children:[n.jsx(E5,{open:l,onToggle:u,...s===void 0?{}:{count:s},children:t}),l&&r]})}function KS({client:e,scriptId:t,taskId:s,name:i,spec:r,value:o,onChange:l,onCreated:u,profile:d}){const[h,f]=v.useState(null),[p,g]=v.useState(null),[x,b]=v.useState(!1),k=async()=>{const N=(p==null?void 0:p.trim())??"";if(N!==""){f(null),b(!0);try{const{value:C}=await e.connection.call("runs/choices/create",{scriptId:t,taskId:s,param:i,name:N,...d===void 0?{}:{profile:d}});g(null),u==null||u(),l(C)}catch(C){f(Ce(C))}finally{b(!1)}}};let j;if(r.choices!==void 0){const N=r.choices.some(C=>C.value===o);j=n.jsx(Ot,{"aria-label":i,value:N?o:"",placeholder:r.choices.length===0?"本地配置里还没有,先新建或在脚本里建一个":"请选择",onChange:C=>{C==="\0new"?g(S=>S??"MultiGameAssistant"):l(C)},options:[...r.choices.map(C=>({value:C.value,label:C.label,...C.detail===void 0?{}:{hint:C.detail}})),...r.canCreate===!0?[{value:"\0new",label:"+ 新建…"}]:[]]})}else r.type==="boolean"?j=n.jsx(Ot,{"aria-label":i,value:o,onChange:l,options:[{value:"true",label:"是"},{value:"false",label:"否"}]}):r.enum!==void 0?j=n.jsx(Ot,{"aria-label":i,value:o,onChange:l,options:r.enum.map(N=>({value:String(N),label:String(N)}))}):j=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:N=>l(N.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}`]}),j,p!==null&&n.jsxs("span",{className:"param-new",children:[n.jsx("input",{className:"text-input plain",autoFocus:!0,value:p,"aria-label":"新项的名字",onChange:N=>g(N.target.value),onKeyDown:N=>{N.key==="Enter"?(N.preventDefault(),k()):N.key==="Escape"&&g(null)}}),n.jsx("button",{type:"button",className:"primary small-button",disabled:x||p.trim()==="",onClick:()=>void k(),children:x?"新建中…":"新建"}),n.jsx("button",{type:"button",className:"small-button",disabled:x,onClick:()=>{g(null),f(null)},children:"取消"}),n.jsx("span",{className:"muted small",children:"复制一个现有的同类项,只存在本应用的本地配置里,原项目不变"})]}),h!==null&&n.jsx("span",{className:"error small",children:h})]})}function YS(e,t,s=!0){const i=ke(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 XS({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(Ot,{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 yx={starting:["","启动中"],running:["","运行中"],stopping:["warn","停止中"],succeeded:["ok","成功"],failed:["warn","失败"],cancelled:["","已停止"]},C5={desktop:"占用鼠标键盘",window:"后台窗口",adb:"模拟器",none:"不占用"};function A5({client:e,scriptId:t,packId:s}){const i=ke(e.connection.status),r=mn(3e4),[o,l]=v.useState(null),[u,d]=v.useState([]),[h,f]=v.useState(""),[p,g]=v.useState({}),[x,b]=v.useState(!1),[k,j]=v.useState(null),[N,C]=v.useState(null),[S,_]=v.useState(0),z=YS(e,t,s!==void 0),[P,H]=v.useState(void 0);v.useEffect(()=>{if(i.state!=="open")return;let U=!0;return e.connection.call("runs/tasks",{scriptId:t,...P===void 0?{}:{profile:P}}).then(A=>{U&&(l(A),f(I=>{var R;return I===""?((R=A.tasks[0])==null?void 0:R.id)??"":I}))}).catch(A=>{U&&j(Ce(A))}),e.connection.call("runs/list",{scriptId:t}).then(A=>{U&&d(A.items)}).catch(()=>{}),()=>{U=!1}},[e,t,s,i.state,S,P,z==null?void 0:z.current]),v.useEffect(()=>e.connection.on("runs/state",U=>{U.scriptId===t&&d(A=>[U,...A.filter(I=>I.id!==U.id)].sort((I,R)=>R.startedAt-I.startedAt))}),[e,t]);const B=o==null?void 0:o.tasks.find(U=>U.id===h);v.useEffect(()=>{B!==void 0&&g(Object.fromEntries(Object.entries(B.params).map(([U,A])=>{var I;return[U,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 O=u.find(U=>U.endedAt===void 0),T=u.find(U=>{var A;return U.id===(N??(O==null?void 0:O.id)??((A=u[0])==null?void 0:A.id))}),D=async()=>{if(B!==void 0){b(!0),j(null);try{const U={};for(const[I,R]of Object.entries(B.params)){const L=p[I]??"";L!==""&&(U[I]=R.type==="boolean"?L==="true":R.type==="integer"||R.type==="number"?Number(L):L)}const A=await e.connection.call("runs/start",{scriptId:t,taskId:B.id,params:U,...P===void 0?{}:{profile:P}});C(A.id),A.state==="failed"&&j(A.outcome??"运行失败")}catch(U){j(Ce(U))}finally{b(!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&&k===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(Ot,{id:"task-select",value:h,onChange:f,options:o.tasks.map(U=>({value:U.id,label:U.title,hint:U.id}))}),B!==void 0&&n.jsxs("div",{className:"task-facts muted small",children:[n.jsx("span",{className:"badge",children:C5[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(XS,{id:"run-profile",list:z,value:P,onChange:H}),B!==void 0&&Object.entries(B.params).map(([U,A])=>n.jsx(KS,{client:e,scriptId:t,taskId:B.id,name:U,spec:A,profile:P,value:p[U]??"",onChange:I=>g(R=>({...R,[U]:I})),onCreated:()=>_(I=>I+1)},U)),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),O!==void 0&&n.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:O.id}).catch(U=>j(Ce(U))),children:"停止当前运行"}),n.jsxs("button",{className:"primary small-button",disabled:x||!o.runnable||O!==void 0,onClick:()=>void D(),children:[n.jsx(ee,{name:"arrow"}),x?"启动中…":"运行"]})]})]}),k!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:k})]}),u.length>0&&n.jsxs(Oa,{id:"scripts.recent-runs",title:"最近运行",count:Math.min(u.length,6),className:"run-history",children:[u.slice(0,6).map(U=>{const[A,I]=yx[U.state];return n.jsxs("button",{className:`run-row ${U.id===(T==null?void 0:T.id)?"active":""}`,"aria-expanded":U.id===(T==null?void 0:T.id),onClick:()=>C(R=>R===U.id||R===null&&U.id===(T==null?void 0:T.id)?"":U.id),children:[n.jsx("span",{className:`badge ${A}`,children:I}),n.jsxs("span",{className:"run-title",children:[U.taskTitle,U.profileName!==void 0&&((z==null?void 0:z.items.length)??0)>1&&n.jsxs("span",{className:"muted small",children:[" · ",U.profileName]})]}),n.jsx("span",{className:"muted small run-outcome",children:U.outcome??U.resources.join(" · ")}),n.jsx("span",{className:"session-time",children:gt(U.startedAt,r)})]},U.id)}),T!==void 0&&n.jsx(QS,{client:e,run:T},T.id)]})]})}function QS({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 f=e.connection.on("runs/log",p=>{p.runId===t.id&&i(g=>[...g,...p.lines].slice(-1e3))});return()=>{h=!1,f()}},[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 f=[`${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(`
210
+ `),p=await $5(f);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(ee,{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(ee,{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,f)=>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})]},f))]})]})}async function $5(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 JS=v.createContext({byIncident:new Map,openSession:()=>{}}),I5={running:"agent 正在处理",resolved:"agent 已处理",retried:"agent 处理后重新运行","gave-up":"agent 处理不了","taken-over":"你接管了",timeout:"agent 超时",failed:"agent 没能开始"},T5={error:"出错",warning:"警告",failed:"失败",stalled:"卡住",overtime:"超时"};function M5({client:e,openSettings:t,openSession:s}){const i=ke(e.connection.status),r=mn(3e4),[o,l]=v.useState([]),[u,d]=v.useState([]),[h,f]=v.useState(null),[p,g]=v.useState(!1),[x,b]=v.useState(null),[k,j]=v.useState([]),N=ke(e.capabilities);v.useEffect(()=>{if(i.state!=="open"||!N.has("intervene"))return;let O=!0;return e.connection.call("intervene/list",{limit:100}).then(T=>{O&&j(T.items)}).catch(()=>{}),()=>{O=!1}},[e,i.state,N]),v.useEffect(()=>e.connection.on("intervene/changed",O=>{j(T=>[O,...T.filter(D=>D.id!==O.id)])}),[e]);const C=v.useMemo(()=>{const O=new Map;for(const T of[...k].sort((D,U)=>D.startedAt-U.startedAt))T.incidentId!==void 0&&O.set(T.incidentId,T);return{byIncident:O,openSession:s}},[k,s]);v.useEffect(()=>{if(i.state!=="open")return;let O=!0;return e.connection.call("runs/list",{}).then(T=>{O&&l(T.items)}).catch(T=>{O&&b(Ce(T))}),e.connection.call("monitor/incidents",{status:"all",limit:200}).then(T=>{O&&d(T.items)}).catch(()=>{}),()=>{O=!1}},[e,i.state]),v.useEffect(()=>e.connection.on("runs/state",O=>{l(T=>[O,...T.filter(D=>D.id!==O.id)].sort((D,U)=>U.startedAt-D.startedAt))}),[e]),v.useEffect(()=>e.connection.on("monitor/incident",O=>{d(T=>[O,...T.filter(D=>D.id!==O.id)].sort((D,U)=>U.createdAt-D.createdAt))}),[e]);const S=o.filter(O=>O.endedAt===void 0),_=o.filter(O=>O.endedAt!==void 0).slice(0,30),z=u.filter(O=>O.status==="open"),P=o.find(O=>{var T,D;return O.id===(h??((T=S[0])==null?void 0:T.id)??((D=o[0])==null?void 0:D.id))}),H=v.useMemo(()=>{const O=new Map;for(const T of z)O.set(T.runId,(O.get(T.runId)??0)+1);return O},[z]),B=O=>{const[T,D]=yx[O.state],U=H.get(O.id)??0;return n.jsxs("button",{className:`script-row ${O.id===(P==null?void 0:P.id)?"active":""}`,onClick:()=>f(O.id),children:[n.jsxs("span",{className:"script-row-main",children:[n.jsxs("span",{className:"script-row-name",children:[O.scriptName," · ",O.taskTitle]}),n.jsxs("span",{className:"muted small",children:[O.kind==="settings"?"设置会话 · ":"",gt(O.startedAt,r),O.retryOf===void 0?"":" · 重新运行"]})]}),U>0?n.jsxs("span",{className:"badge warn",children:["异常 ",U]}):n.jsx("span",{className:`badge ${T}`,children:D})]},O.id)};return n.jsx(JS.Provider,{value:C,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(ee,{name:"plug"}),"消息通知"]}),n.jsxs("button",{className:`small-button ${p?"primary":""}`,onClick:()=>g(O=>!O),children:[n.jsx(ee,{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(ee,{name:"alert"}),n.jsx("span",{children:x})]}),n.jsxs(Oa,{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)]}),_.length>0&&n.jsx(Oa,{id:"monitor.recent",title:"最近",count:_.length,className:"list-fold",children:_.map(B)})]}),n.jsx("div",{className:"scripts-detail",children:n.jsxs("div",{className:"script-detail",children:[p&&n.jsx(O5,{client:e}),z.length>0&&n.jsx("section",{className:"card",children:n.jsxs(Oa,{id:"monitor.open-incidents",title:n.jsxs("h3",{children:["待处理的异常(",z.length,")"]}),className:"card-fold",children:[n.jsx("p",{className:"muted small",children:"脚本包里写了自动处理的(如重连模拟器、重新运行)会先自动处理;处理不了的才推送到飞书。"}),n.jsx("div",{className:"incident-list",children:z.map(O=>n.jsx(e1,{client:e,incident:O,now:r,onOpen:()=>f(O.runId)},O.id))})]})}),P===void 0&&z.length===0&&n.jsxs("div",{className:"empty",children:[n.jsx(ee,{name:"monitor"}),n.jsx("p",{children:"还没有运行记录。在「脚本」页运行一个任务,或对 agent 说「跑一下方舟日常」。"})]}),P!==void 0&&n.jsx(R5,{client:e,run:P,incidents:u.filter(O=>O.runId===P.id),now:r,openRun:f})]})})]})]})})}function R5({client:e,run:t,incidents:s,now:i,openRun:r}){const[o,l]=yx[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(Ce(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(ee,{name:"alert"}),n.jsx("span",{children:u})]}),n.jsx(Oa,{id:"monitor.run-log",title:"日志",children:n.jsx(QS,{client:e,run:t},t.id)}),s.length>0&&n.jsx(Oa,{id:"monitor.run-incidents",title:"这次运行的异常",count:s.length,children:n.jsx("div",{className:"incident-list",children:s.map(h=>n.jsx(e1,{client:e,incident:h,now:i},h.id))})})]})}function e1({client:e,incident:t,now:s,onOpen:i}){const{byIncident:r,openSession:o}=v.useContext(JS),l=r.get(t.id),[u,d]=v.useState(!1),[h,f]=v.useState(null),[p,g]=v.useState(null),x=async()=>{if(l!==void 0){d(!0),f(null);try{await e.connection.call("intervene/takeover",{id:l.id})}catch(j){f(Ce(j))}finally{d(!1)}}},b=async j=>{d(!0),f(null);try{await e.connection.call("monitor/act",{incidentId:t.id,action:j})}catch(N){f(Ce(N))}finally{d(!1)}},k=async()=>{if(p!==null)return g(null);try{const j=await e.connection.call("monitor/screenshot",{incidentId:t.id});g(`data:${j.mime};base64,${j.data}`)}catch(j){f(Ce(j))}};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:T5[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:gt(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(j=>(l==null?void 0:l.summary)===void 0||l.state==="running"||!j.detail.endsWith(l.summary)).map((j,N)=>n.jsxs("li",{className:j.ok?"ok":"failed",children:[j.ok?"✓":"✗"," ",j.detail]},N))}),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:[I5[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 k(),children:[n.jsx(ee,{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 b("resume"),children:"继续"}),n.jsx("button",{className:"danger-outline small-button",disabled:u,onClick:()=>void b("stop"),children:"停止"}),n.jsx("button",{className:"small-button",disabled:u,onClick:()=>void b("retry"),children:"重试"}),n.jsx("button",{className:"small-button",disabled:u,onClick:()=>void b("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(ee,{name:"alert"}),n.jsx("span",{children:h})]})]})}function O5({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(Ce(h)))},[e]);const o=h=>e.connection.call("monitor/settings/set",h).then(s).catch(f=>r(Ce(f))),l=((d=ih(e).data)==null?void 0:d.scripts)??[],u=Object.entries((t==null?void 0:t.scriptStall)??{}).sort(([h],[f])=>h.localeCompare(f));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,f])=>{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:[f.seconds," 秒 · ",f.by==="learned"?"学到的":f.by==="agent"?"agent 设的":"你设的",f.note===void 0?"":`:${f.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(Ot,{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(ee,{name:"alert"}),n.jsx("span",{children:i})]})]})}const P5={id:"runs",title:"运行监控",milestone:"M3",requires:["runs","monitor"],pages:[{id:"runs",title:"运行",icon:"monitor",order:30,agent:"intervene",component:M5}]},L5={id:"feishu",title:"远程连接",milestone:"M3",requires:["notify","credentials"],settingsPages:[{id:"feishu",title:"远程连接",order:12,component:w5}]};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 z5={value:()=>{}};function uh(){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 bd(s)}function bd(e){this._=e}function D5(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}})}bd.prototype=uh.prototype={constructor:bd,on:function(e,t){var s=this._,i=D5(e+"",s),r,o=-1,l=i.length;if(arguments.length<2){for(;++o<l;)if((r=(e=i[o]).type)&&(r=F5(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]=Nk(s[r],e.name,t);else if(t==null)for(r in s)s[r]=Nk(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 bd(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 F5(e,t){for(var s=0,i=e.length,r;s<i;++s)if((r=e[s]).name===t)return r.value}function Nk(e,t,s){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=z5,e=e.slice(0,i).concat(e.slice(i+1));break}return s!=null&&e.push({name:t,value:s}),e}var ng="http://www.w3.org/1999/xhtml";const wk={svg:"http://www.w3.org/2000/svg",xhtml:ng,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function dh(e){var t=e+="",s=t.indexOf(":");return s>=0&&(t=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),wk.hasOwnProperty(t)?{space:wk[t],local:e}:e}function U5(e){return function(){var t=this.ownerDocument,s=this.namespaceURI;return s===ng&&t.documentElement.namespaceURI===ng?t.createElement(e):t.createElementNS(s,e)}}function B5(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function t1(e){var t=dh(e);return(t.local?B5:U5)(t)}function H5(){}function bx(e){return e==null?H5:function(){return this.querySelector(e)}}function Z5(e){typeof e!="function"&&(e=bx(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,f=0;f<l;++f)(d=o[f])&&(h=e.call(d,d.__data__,f,o))&&("__data__"in d&&(h.__data__=d.__data__),u[f]=h);return new Vs(i,this._parents)}function W5(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function V5(){return[]}function n1(e){return e==null?V5:function(){return this.querySelectorAll(e)}}function q5(e){return function(){return W5(e.apply(this,arguments))}}function G5(e){typeof e=="function"?e=q5(e):e=n1(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 Vs(i,r)}function s1(e){return function(){return this.matches(e)}}function i1(e){return function(t){return t.matches(e)}}var K5=Array.prototype.find;function Y5(e){return function(){return K5.call(this.children,e)}}function X5(){return this.firstElementChild}function Q5(e){return this.select(e==null?X5:Y5(typeof e=="function"?e:i1(e)))}var J5=Array.prototype.filter;function e4(){return Array.from(this.children)}function t4(e){return function(){return J5.call(this.children,e)}}function n4(e){return this.selectAll(e==null?e4:t4(typeof e=="function"?e:i1(e)))}function s4(e){typeof e!="function"&&(e=s1(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 Vs(i,this._parents)}function r1(e){return new Array(e.length)}function i4(){return new Vs(this._enter||this._groups.map(r1),this._parents)}function Ld(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ld.prototype={constructor:Ld,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 r4(e){return function(){return e}}function a4(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 Ld(e,o[l]);for(;l<d;++l)(u=t[l])&&(r[l]=u)}function o4(e,t,s,i,r,o,l){var u,d,h=new Map,f=t.length,p=o.length,g=new Array(f),x;for(u=0;u<f;++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 Ld(e,o[u]);for(u=0;u<f;++u)(d=t[u])&&h.get(g[u])===d&&(r[u]=d)}function l4(e){return e.__data__}function c4(e,t){if(!arguments.length)return Array.from(this,l4);var s=t?o4:a4,i=this._parents,r=this._groups;typeof e!="function"&&(e=r4(e));for(var o=r.length,l=new Array(o),u=new Array(o),d=new Array(o),h=0;h<o;++h){var f=i[h],p=r[h],g=p.length,x=u4(e.call(f,f&&f.__data__,h,i)),b=x.length,k=u[h]=new Array(b),j=l[h]=new Array(b),N=d[h]=new Array(g);s(f,p,k,j,N,x,t);for(var C=0,S=0,_,z;C<b;++C)if(_=k[C]){for(C>=S&&(S=C+1);!(z=j[S])&&++S<b;);_._next=z||null}}return l=new Vs(l,i),l._enter=u,l._exit=d,l}function u4(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function d4(){return new Vs(this._exit||this._groups.map(r1),this._parents)}function h4(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 m4(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],f=i[d],p=h.length,g=u[d]=new Array(p),x,b=0;b<p;++b)(x=h[b]||f[b])&&(g[b]=x);for(;d<r;++d)u[d]=s[d];return new Vs(u,this._parents)}function f4(){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 p4(e){e||(e=g4);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,f=0;f<u;++f)(h=l[f])&&(d[f]=h);d.sort(t)}return new Vs(r,this._parents).order()}function g4(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function x4(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function v4(){return Array.from(this)}function y4(){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 b4(){let e=0;for(const t of this)++e;return e}function k4(){return!this.node()}function j4(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 N4(e){return function(){this.removeAttribute(e)}}function w4(e){return function(){this.removeAttributeNS(e.space,e.local)}}function S4(e,t){return function(){this.setAttribute(e,t)}}function _4(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function E4(e,t){return function(){var s=t.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function C4(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 A4(e,t){var s=dh(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?w4:N4:typeof t=="function"?s.local?C4:E4:s.local?_4:S4)(s,t))}function a1(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function $4(e){return function(){this.style.removeProperty(e)}}function I4(e,t,s){return function(){this.style.setProperty(e,t,s)}}function T4(e,t,s){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,s)}}function M4(e,t,s){return arguments.length>1?this.each((t==null?$4:typeof t=="function"?T4:I4)(e,t,s??"")):Yo(this.node(),e)}function Yo(e,t){return e.style.getPropertyValue(t)||a1(e).getComputedStyle(e,null).getPropertyValue(t)}function R4(e){return function(){delete this[e]}}function O4(e,t){return function(){this[e]=t}}function P4(e,t){return function(){var s=t.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function L4(e,t){return arguments.length>1?this.each((t==null?R4:typeof t=="function"?P4:O4)(e,t)):this.node()[e]}function o1(e){return e.trim().split(/^|\s+/)}function kx(e){return e.classList||new l1(e)}function l1(e){this._node=e,this._names=o1(e.getAttribute("class")||"")}l1.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 c1(e,t){for(var s=kx(e),i=-1,r=t.length;++i<r;)s.add(t[i])}function u1(e,t){for(var s=kx(e),i=-1,r=t.length;++i<r;)s.remove(t[i])}function z4(e){return function(){c1(this,e)}}function D4(e){return function(){u1(this,e)}}function F4(e,t){return function(){(t.apply(this,arguments)?c1:u1)(this,e)}}function U4(e,t){var s=o1(e+"");if(arguments.length<2){for(var i=kx(this.node()),r=-1,o=s.length;++r<o;)if(!i.contains(s[r]))return!1;return!0}return this.each((typeof t=="function"?F4:t?z4:D4)(s,t))}function B4(){this.textContent=""}function H4(e){return function(){this.textContent=e}}function Z4(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function W4(e){return arguments.length?this.each(e==null?B4:(typeof e=="function"?Z4:H4)(e)):this.node().textContent}function V4(){this.innerHTML=""}function q4(e){return function(){this.innerHTML=e}}function G4(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function K4(e){return arguments.length?this.each(e==null?V4:(typeof e=="function"?G4:q4)(e)):this.node().innerHTML}function Y4(){this.nextSibling&&this.parentNode.appendChild(this)}function X4(){return this.each(Y4)}function Q4(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function J4(){return this.each(Q4)}function eF(e){var t=typeof e=="function"?e:t1(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function tF(){return null}function nF(e,t){var s=typeof e=="function"?e:t1(e),i=t==null?tF:typeof t=="function"?t:bx(t);return this.select(function(){return this.insertBefore(s.apply(this,arguments),i.apply(this,arguments)||null)})}function sF(){var e=this.parentNode;e&&e.removeChild(this)}function iF(){return this.each(sF)}function rF(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function aF(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function oF(e){return this.select(e?aF:rF)}function lF(e){return arguments.length?this.property("__data__",e):this.node().__data__}function cF(e){return function(t){e.call(this,t,this.__data__)}}function uF(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 dF(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 hF(e,t,s){return function(){var i=this.__on,r,o=cF(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 mF(e,t,s){var i=uF(e+""),r,o=i.length,l;if(arguments.length<2){var u=this.node().__on;if(u){for(var d=0,h=u.length,f;d<h;++d)for(r=0,f=u[d];r<o;++r)if((l=i[r]).type===f.type&&l.name===f.name)return f.value}return}for(u=t?hF:dF,r=0;r<o;++r)this.each(u(i[r],t,s));return this}function d1(e,t,s){var i=a1(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 fF(e,t){return function(){return d1(this,e,t)}}function pF(e,t){return function(){return d1(this,e,t.apply(this,arguments))}}function gF(e,t){return this.each((typeof t=="function"?pF:fF)(e,t))}function*xF(){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 h1=[null];function Vs(e,t){this._groups=e,this._parents=t}function Bc(){return new Vs([[document.documentElement]],h1)}function vF(){return this}Vs.prototype=Bc.prototype={constructor:Vs,select:Z5,selectAll:G5,selectChild:Q5,selectChildren:n4,filter:s4,data:c4,enter:i4,exit:d4,join:h4,merge:m4,selection:vF,order:f4,sort:p4,call:x4,nodes:v4,node:y4,size:b4,empty:k4,each:j4,attr:A4,style:M4,property:L4,classed:U4,text:W4,html:K4,raise:X4,lower:J4,append:eF,insert:nF,remove:iF,clone:oF,datum:lF,on:mF,dispatch:gF,[Symbol.iterator]:xF};function Bs(e){return typeof e=="string"?new Vs([[document.querySelector(e)]],[document.documentElement]):new Vs([[e]],h1)}function yF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ji(e,t){if(e=yF(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 bF={passive:!1},Nc={capture:!0,passive:!1};function Wf(e){e.stopImmediatePropagation()}function Lo(e){e.preventDefault(),e.stopImmediatePropagation()}function m1(e){var t=e.document.documentElement,s=Bs(e).on("dragstart.drag",Lo,Nc);"onselectstart"in t?s.on("selectstart.drag",Lo,Nc):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function f1(e,t){var s=e.document.documentElement,i=Bs(e).on("dragstart.drag",null);t&&(i.on("click.drag",Lo,Nc),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 nd=e=>()=>e;function sg(e,{sourceEvent:t,subject:s,target:i,identifier:r,active:o,x:l,y:u,dx:d,dy:h,dispatch:f}){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:f}})}sg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function kF(e){return!e.ctrlKey&&!e.button}function jF(){return this.parentNode}function NF(e,t){return t??{x:e.x,y:e.y}}function wF(){return navigator.maxTouchPoints||"ontouchstart"in this}function p1(){var e=kF,t=jF,s=NF,i=wF,r={},o=uh("start","drag","end"),l=0,u,d,h,f,p=0;function g(_){_.on("mousedown.drag",x).filter(i).on("touchstart.drag",j).on("touchmove.drag",N,bF).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(_,z){if(!(f||!e.call(this,_,z))){var P=S(this,t.call(this,_,z),_,z,"mouse");P&&(Bs(_.view).on("mousemove.drag",b,Nc).on("mouseup.drag",k,Nc),m1(_.view),Wf(_),h=!1,u=_.clientX,d=_.clientY,P("start",_))}}function b(_){if(Lo(_),!h){var z=_.clientX-u,P=_.clientY-d;h=z*z+P*P>p}r.mouse("drag",_)}function k(_){Bs(_.view).on("mousemove.drag mouseup.drag",null),f1(_.view,h),Lo(_),r.mouse("end",_)}function j(_,z){if(e.call(this,_,z)){var P=_.changedTouches,H=t.call(this,_,z),B=P.length,O,T;for(O=0;O<B;++O)(T=S(this,H,_,z,P[O].identifier,P[O]))&&(Wf(_),T("start",_,P[O]))}}function N(_){var z=_.changedTouches,P=z.length,H,B;for(H=0;H<P;++H)(B=r[z[H].identifier])&&(Lo(_),B("drag",_,z[H]))}function C(_){var z=_.changedTouches,P=z.length,H,B;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),H=0;H<P;++H)(B=r[z[H].identifier])&&(Wf(_),B("end",_,z[H]))}function S(_,z,P,H,B,O){var T=o.copy(),D=ji(O||P,z),U,A,I;if((I=s.call(_,new sg("beforestart",{sourceEvent:P,target:g,identifier:B,active:l,x:D[0],y:D[1],dx:0,dy:0,dispatch:T}),H))!=null)return U=I.x-D[0]||0,A=I.y-D[1]||0,function R(L,K,F){var q=D,V;switch(L){case"start":r[B]=R,V=l++;break;case"end":delete r[B],--l;case"drag":D=ji(F||K,z),V=l;break}T.call(L,_,new sg(L,{sourceEvent:K,subject:I,target:g,identifier:B,active:V,x:D[0]+U,y:D[1]+A,dx:D[0]-q[0],dy:D[1]-q[1],dispatch:T}),H)}}return g.filter=function(_){return arguments.length?(e=typeof _=="function"?_:nd(!!_),g):e},g.container=function(_){return arguments.length?(t=typeof _=="function"?_:nd(_),g):t},g.subject=function(_){return arguments.length?(s=typeof _=="function"?_:nd(_),g):s},g.touchable=function(_){return arguments.length?(i=typeof _=="function"?_:nd(!!_),g):i},g.on=function(){var _=o.on.apply(o,arguments);return _===o?g:_},g.clickDistance=function(_){return arguments.length?(p=(_=+_)*_,g):Math.sqrt(p)},g}function jx(e,t,s){e.prototype=t.prototype=s,s.constructor=e}function g1(e,t){var s=Object.create(e.prototype);for(var i in t)s[i]=t[i];return s}function Hc(){}var wc=.7,zd=1/wc,zo="\\s*([+-]?\\d+)\\s*",Sc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Wi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",SF=/^#([0-9a-f]{3,8})$/,_F=new RegExp(`^rgb\\(${zo},${zo},${zo}\\)$`),EF=new RegExp(`^rgb\\(${Wi},${Wi},${Wi}\\)$`),CF=new RegExp(`^rgba\\(${zo},${zo},${zo},${Sc}\\)$`),AF=new RegExp(`^rgba\\(${Wi},${Wi},${Wi},${Sc}\\)$`),$F=new RegExp(`^hsl\\(${Sc},${Wi},${Wi}\\)$`),IF=new RegExp(`^hsla\\(${Sc},${Wi},${Wi},${Sc}\\)$`),Sk={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};jx(Hc,Fa,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:_k,formatHex:_k,formatHex8:TF,formatHsl:MF,formatRgb:Ek,toString:Ek});function _k(){return this.rgb().formatHex()}function TF(){return this.rgb().formatHex8()}function MF(){return x1(this).formatHsl()}function Ek(){return this.rgb().formatRgb()}function Fa(e){var t,s;return e=(e+"").trim().toLowerCase(),(t=SF.exec(e))?(s=t[1].length,t=parseInt(t[1],16),s===6?Ck(t):s===3?new Ts(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):s===8?sd(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):s===4?sd(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=_F.exec(e))?new Ts(t[1],t[2],t[3],1):(t=EF.exec(e))?new Ts(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=CF.exec(e))?sd(t[1],t[2],t[3],t[4]):(t=AF.exec(e))?sd(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=$F.exec(e))?Ik(t[1],t[2]/100,t[3]/100,1):(t=IF.exec(e))?Ik(t[1],t[2]/100,t[3]/100,t[4]):Sk.hasOwnProperty(e)?Ck(Sk[e]):e==="transparent"?new Ts(NaN,NaN,NaN,0):null}function Ck(e){return new Ts(e>>16&255,e>>8&255,e&255,1)}function sd(e,t,s,i){return i<=0&&(e=t=s=NaN),new Ts(e,t,s,i)}function RF(e){return e instanceof Hc||(e=Fa(e)),e?(e=e.rgb(),new Ts(e.r,e.g,e.b,e.opacity)):new Ts}function ig(e,t,s,i){return arguments.length===1?RF(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}jx(Ts,ig,g1(Hc,{brighter(e){return e=e==null?zd:Math.pow(zd,e),new Ts(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?wc:Math.pow(wc,e),new Ts(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ts(Pa(this.r),Pa(this.g),Pa(this.b),Dd(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:Ak,formatHex:Ak,formatHex8:OF,formatRgb:$k,toString:$k}));function Ak(){return`#${Ta(this.r)}${Ta(this.g)}${Ta(this.b)}`}function OF(){return`#${Ta(this.r)}${Ta(this.g)}${Ta(this.b)}${Ta((isNaN(this.opacity)?1:this.opacity)*255)}`}function $k(){const e=Dd(this.opacity);return`${e===1?"rgb(":"rgba("}${Pa(this.r)}, ${Pa(this.g)}, ${Pa(this.b)}${e===1?")":`, ${e})`}`}function Dd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Pa(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ta(e){return e=Pa(e),(e<16?"0":"")+e.toString(16)}function Ik(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 x1(e){if(e instanceof Si)return new Si(e.h,e.s,e.l,e.opacity);if(e instanceof Hc||(e=Fa(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 PF(e,t,s,i){return arguments.length===1?x1(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}jx(Si,PF,g1(Hc,{brighter(e){return e=e==null?zd:Math.pow(zd,e),new Si(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?wc:Math.pow(wc,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(Vf(e>=240?e-240:e+120,r,i),Vf(e,r,i),Vf(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new Si(Tk(this.h),id(this.s),id(this.l),Dd(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=Dd(this.opacity);return`${e===1?"hsl(":"hsla("}${Tk(this.h)}, ${id(this.s)*100}%, ${id(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Tk(e){return e=(e||0)%360,e<0?e+360:e}function id(e){return Math.max(0,Math.min(1,e||0))}function Vf(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 Nx=e=>()=>e;function LF(e,t){return function(s){return e+s*t}}function zF(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 DF(e){return(e=+e)==1?v1:function(t,s){return s-t?zF(t,s,e):Nx(isNaN(t)?s:t)}}function v1(e,t){var s=t-e;return s?LF(e,s):Nx(isNaN(e)?t:e)}const Fd=(function e(t){var s=DF(t);function i(r,o){var l=s((r=ig(r)).r,(o=ig(o)).r),u=s(r.g,o.g),d=s(r.b,o.b),h=v1(r.opacity,o.opacity);return function(f){return r.r=l(f),r.g=u(f),r.b=d(f),r.opacity=h(f),r+""}}return i.gamma=e,i})(1);function FF(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 UF(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function BF(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]=hc(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 HF(e,t){var s=new Date;return e=+e,t=+t,function(i){return s.setTime(e*(1-i)+t*i),s}}function Hi(e,t){return e=+e,t=+t,function(s){return e*(1-s)+t*s}}function ZF(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]=hc(e[r],t[r]):i[r]=t[r];return function(o){for(r in s)i[r]=s[r](o);return i}}var rg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,qf=new RegExp(rg.source,"g");function WF(e){return function(){return e}}function VF(e){return function(t){return e(t)+""}}function y1(e,t){var s=rg.lastIndex=qf.lastIndex=0,i,r,o,l=-1,u=[],d=[];for(e=e+"",t=t+"";(i=rg.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:Hi(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]?VF(d[0].x):WF(t):(t=d.length,function(h){for(var f=0,p;f<t;++f)u[(p=d[f]).i]=p.x(h);return u.join("")})}function hc(e,t){var s=typeof t,i;return t==null||s==="boolean"?Nx(t):(s==="number"?Hi:s==="string"?(i=Fa(t))?(t=i,Fd):y1:t instanceof Fa?Fd:t instanceof Date?HF:UF(t)?FF:Array.isArray(t)?BF:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?ZF:Hi)(e,t)}var Mk=180/Math.PI,ag={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function b1(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)*Mk,skewX:Math.atan(d)*Mk,scaleX:l,scaleY:u}}var rd;function qF(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ag:b1(t.a,t.b,t.c,t.d,t.e,t.f)}function GF(e){return e==null||(rd||(rd=document.createElementNS("http://www.w3.org/2000/svg","g")),rd.setAttribute("transform",e),!(e=rd.transform.baseVal.consolidate()))?ag:(e=e.matrix,b1(e.a,e.b,e.c,e.d,e.e,e.f))}function k1(e,t,s,i){function r(h){return h.length?h.pop()+" ":""}function o(h,f,p,g,x,b){if(h!==p||f!==g){var k=x.push("translate(",null,t,null,s);b.push({i:k-4,x:Hi(h,p)},{i:k-2,x:Hi(f,g)})}else(p||g)&&x.push("translate("+p+t+g+s)}function l(h,f,p,g){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),g.push({i:p.push(r(p)+"rotate(",null,i)-2,x:Hi(h,f)})):f&&p.push(r(p)+"rotate("+f+i)}function u(h,f,p,g){h!==f?g.push({i:p.push(r(p)+"skewX(",null,i)-2,x:Hi(h,f)}):f&&p.push(r(p)+"skewX("+f+i)}function d(h,f,p,g,x,b){if(h!==p||f!==g){var k=x.push(r(x)+"scale(",null,",",null,")");b.push({i:k-4,x:Hi(h,p)},{i:k-2,x:Hi(f,g)})}else(p!==1||g!==1)&&x.push(r(x)+"scale("+p+","+g+")")}return function(h,f){var p=[],g=[];return h=e(h),f=e(f),o(h.translateX,h.translateY,f.translateX,f.translateY,p,g),l(h.rotate,f.rotate,p,g),u(h.skewX,f.skewX,p,g),d(h.scaleX,h.scaleY,f.scaleX,f.scaleY,p,g),h=f=null,function(x){for(var b=-1,k=g.length,j;++b<k;)p[(j=g[b]).i]=j.x(x);return p.join("")}}}var KF=k1(qF,"px, ","px)","deg)"),YF=k1(GF,", ",")",")"),XF=1e-12;function Rk(e){return((e=Math.exp(e))+1/e)/2}function QF(e){return((e=Math.exp(e))-1/e)/2}function JF(e){return((e=Math.exp(2*e))-1)/(e+1)}const kd=(function e(t,s,i){function r(o,l){var u=o[0],d=o[1],h=o[2],f=l[0],p=l[1],g=l[2],x=f-u,b=p-d,k=x*x+b*b,j,N;if(k<XF)N=Math.log(g/h)/t,j=function(H){return[u+H*x,d+H*b,h*Math.exp(t*H*N)]};else{var C=Math.sqrt(k),S=(g*g-h*h+i*k)/(2*h*s*C),_=(g*g-h*h-i*k)/(2*g*s*C),z=Math.log(Math.sqrt(S*S+1)-S),P=Math.log(Math.sqrt(_*_+1)-_);N=(P-z)/t,j=function(H){var B=H*N,O=Rk(z),T=h/(s*C)*(O*JF(t*B+z)-QF(z));return[u+T*x,d+T*b,h*O/Rk(t*B+z)]}}return j.duration=N*1e3*t/Math.SQRT2,j}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,j1=1e3,Ud,sc,Bd=0,Ua=0,hh=0,_c=typeof performance=="object"&&performance.now?performance:Date,N1=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function wx(){return Ua||(N1(e6),Ua=_c.now()+hh)}function e6(){Ua=0}function Hd(){this._call=this._time=this._next=null}Hd.prototype=w1.prototype={constructor:Hd,restart:function(e,t,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?wx():+s)+(t==null?0:+t),!this._next&&sc!==this&&(sc?sc._next=this:Ud=this,sc=this),this._call=e,this._time=s,og()},stop:function(){this._call&&(this._call=null,this._time=1/0,og())}};function w1(e,t,s){var i=new Hd;return i.restart(e,t,s),i}function t6(){wx(),++Xo;for(var e=Ud,t;e;)(t=Ua-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Xo}function Ok(){Ua=(Bd=_c.now())+hh,Xo=nc=0;try{t6()}finally{Xo=0,s6(),Ua=0}}function n6(){var e=_c.now(),t=e-Bd;t>j1&&(hh-=t,Bd=e)}function s6(){for(var e,t=Ud,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:Ud=s);sc=e,og(i)}function og(e){if(!Xo){nc&&(nc=clearTimeout(nc));var t=e-Ua;t>24?(e<1/0&&(nc=setTimeout(Ok,e-_c.now()-hh)),Zl&&(Zl=clearInterval(Zl))):(Zl||(Bd=_c.now(),Zl=setInterval(n6,j1)),Xo=1,N1(Ok))}}function Pk(e,t,s){var i=new Hd;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,s),i}var i6=uh("start","end","cancel","interrupt"),r6=[],S1=0,Lk=1,lg=2,jd=3,zk=4,cg=5,Nd=6;function mh(e,t,s,i,r,o){var l=e.__transition;if(!l)e.__transition={};else if(s in l)return;a6(e,s,{name:t,index:i,group:r,on:i6,tween:r6,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:S1})}function Sx(e,t){var s=$i(e,t);if(s.state>S1)throw new Error("too late; already scheduled");return s}function Vi(e,t){var s=$i(e,t);if(s.state>jd)throw new Error("too late; already running");return s}function $i(e,t){var s=e.__transition;if(!s||!(s=s[t]))throw new Error("transition not found");return s}function a6(e,t,s){var i=e.__transition,r;i[t]=s,s.timer=w1(o,0,s.time);function o(h){s.state=Lk,s.timer.restart(l,s.delay,s.time),s.delay<=h&&l(h-s.delay)}function l(h){var f,p,g,x;if(s.state!==Lk)return d();for(f in i)if(x=i[f],x.name===s.name){if(x.state===jd)return Pk(l);x.state===zk?(x.state=Nd,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete i[f]):+f<t&&(x.state=Nd,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete i[f])}if(Pk(function(){s.state===jd&&(s.state=zk,s.timer.restart(u,s.delay,s.time),u(h))}),s.state=lg,s.on.call("start",e,e.__data__,s.index,s.group),s.state===lg){for(s.state=jd,r=new Array(g=s.tween.length),f=0,p=-1;f<g;++f)(x=s.tween[f].value.call(e,e.__data__,s.index,s.group))&&(r[++p]=x);r.length=p+1}}function u(h){for(var f=h<s.duration?s.ease.call(null,h/s.duration):(s.timer.restart(d),s.state=cg,1),p=-1,g=r.length;++p<g;)r[p].call(e,f);s.state===cg&&(s.on.call("end",e,e.__data__,s.index,s.group),d())}function d(){s.state=Nd,s.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function wd(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>lg&&i.state<cg,i.state=Nd,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete s[l]}o&&delete e.__transition}}function o6(e){return this.each(function(){wd(this,e)})}function l6(e,t){var s,i;return function(){var r=Vi(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 c6(e,t,s){var i,r;if(typeof s!="function")throw new Error;return function(){var o=Vi(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 u6(e,t){var s=this._id;if(e+="",arguments.length<2){for(var i=$i(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?l6:c6)(s,e,t))}function _x(e,t,s){var i=e._id;return e.each(function(){var r=Vi(this,i);(r.value||(r.value={}))[t]=s.apply(this,arguments)}),function(r){return $i(r,i).value[t]}}function _1(e,t){var s;return(typeof t=="number"?Hi:t instanceof Fa?Fd:(s=Fa(t))?(t=s,Fd):y1)(e,t)}function d6(e){return function(){this.removeAttribute(e)}}function h6(e){return function(){this.removeAttributeNS(e.space,e.local)}}function m6(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 f6(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 p6(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 g6(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 x6(e,t){var s=dh(e),i=s==="transform"?YF:_1;return this.attrTween(e,typeof t=="function"?(s.local?g6:p6)(s,i,_x(this,"attr."+e,t)):t==null?(s.local?h6:d6)(s):(s.local?f6:m6)(s,i,t))}function v6(e,t){return function(s){this.setAttribute(e,t.call(this,s))}}function y6(e,t){return function(s){this.setAttributeNS(e.space,e.local,t.call(this,s))}}function b6(e,t){var s,i;function r(){var o=t.apply(this,arguments);return o!==i&&(s=(i=o)&&y6(e,o)),s}return r._value=t,r}function k6(e,t){var s,i;function r(){var o=t.apply(this,arguments);return o!==i&&(s=(i=o)&&v6(e,o)),s}return r._value=t,r}function j6(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=dh(e);return this.tween(s,(i.local?b6:k6)(i,t))}function N6(e,t){return function(){Sx(this,e).delay=+t.apply(this,arguments)}}function w6(e,t){return t=+t,function(){Sx(this,e).delay=t}}function S6(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?N6:w6)(t,e)):$i(this.node(),t).delay}function _6(e,t){return function(){Vi(this,e).duration=+t.apply(this,arguments)}}function E6(e,t){return t=+t,function(){Vi(this,e).duration=t}}function C6(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?_6:E6)(t,e)):$i(this.node(),t).duration}function A6(e,t){if(typeof t!="function")throw new Error;return function(){Vi(this,e).ease=t}}function $6(e){var t=this._id;return arguments.length?this.each(A6(t,e)):$i(this.node(),t).ease}function I6(e,t){return function(){var s=t.apply(this,arguments);if(typeof s!="function")throw new Error;Vi(this,e).ease=s}}function T6(e){if(typeof e!="function")throw new Error;return this.each(I6(this._id,e))}function M6(e){typeof e!="function"&&(e=s1(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 yr(i,this._parents,this._name,this._id)}function R6(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],f=d.length,p=l[u]=new Array(f),g,x=0;x<f;++x)(g=d[x]||h[x])&&(p[x]=g);for(;u<i;++u)l[u]=t[u];return new yr(l,this._parents,this._name,this._id)}function O6(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 P6(e,t,s){var i,r,o=O6(t)?Sx:Vi;return function(){var l=o(this,e),u=l.on;u!==i&&(r=(i=u).copy()).on(t,s),l.on=r}}function L6(e,t){var s=this._id;return arguments.length<2?$i(this.node(),s).on.on(e):this.each(P6(s,e,t))}function z6(e){return function(){var t=this.parentNode;for(var s in this.__transition)if(+s!==e)return;t&&t.removeChild(this)}}function D6(){return this.on("end.remove",z6(this._id))}function F6(e){var t=this._name,s=this._id;typeof e!="function"&&(e=bx(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),f,p,g=0;g<d;++g)(f=u[g])&&(p=e.call(f,f.__data__,g,u))&&("__data__"in f&&(p.__data__=f.__data__),h[g]=p,mh(h[g],t,s,g,h,$i(f,s)));return new yr(o,this._parents,t,s)}function U6(e){var t=this._name,s=this._id;typeof e!="function"&&(e=n1(e));for(var i=this._groups,r=i.length,o=[],l=[],u=0;u<r;++u)for(var d=i[u],h=d.length,f,p=0;p<h;++p)if(f=d[p]){for(var g=e.call(f,f.__data__,p,d),x,b=$i(f,s),k=0,j=g.length;k<j;++k)(x=g[k])&&mh(x,t,s,k,g,b);o.push(g),l.push(f)}return new yr(o,l,t,s)}var B6=Bc.prototype.constructor;function H6(){return new B6(this._groups,this._parents)}function Z6(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 E1(e){return function(){this.style.removeProperty(e)}}function W6(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 V6(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 q6(e,t){var s,i,r,o="style."+t,l="end."+o,u;return function(){var d=Vi(this,e),h=d.on,f=d.value[o]==null?u||(u=E1(t)):void 0;(h!==s||r!==f)&&(i=(s=h).copy()).on(l,r=f),d.on=i}}function G6(e,t,s){var i=(e+="")=="transform"?KF:_1;return t==null?this.styleTween(e,Z6(e,i)).on("end.style."+e,E1(e)):typeof t=="function"?this.styleTween(e,V6(e,i,_x(this,"style."+e,t))).each(q6(this._id,e)):this.styleTween(e,W6(e,i,t),s).on("end.style."+e,null)}function K6(e,t,s){return function(i){this.style.setProperty(e,t.call(this,i),s)}}function Y6(e,t,s){var i,r;function o(){var l=t.apply(this,arguments);return l!==r&&(i=(r=l)&&K6(e,l,s)),i}return o._value=t,o}function X6(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,Y6(e,t,s??""))}function Q6(e){return function(){this.textContent=e}}function J6(e){return function(){var t=e(this);this.textContent=t??""}}function eU(e){return this.tween("text",typeof e=="function"?J6(_x(this,"text",e)):Q6(e==null?"":e+""))}function tU(e){return function(t){this.textContent=e.call(this,t)}}function nU(e){var t,s;function i(){var r=e.apply(this,arguments);return r!==s&&(t=(s=r)&&tU(r)),t}return i._value=e,i}function sU(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,nU(e))}function iU(){for(var e=this._name,t=this._id,s=C1(),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 f=$i(d,t);mh(d,e,s,h,l,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new yr(i,this._parents,e,s)}function rU(){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=Vi(this,i),f=h.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(d)),h.on=t}),r===0&&o()})}var aU=0;function yr(e,t,s,i){this._groups=e,this._parents=t,this._name=s,this._id=i}function C1(){return++aU}var ur=Bc.prototype;yr.prototype={constructor:yr,select:F6,selectAll:U6,selectChild:ur.selectChild,selectChildren:ur.selectChildren,filter:M6,merge:R6,selection:H6,transition:iU,call:ur.call,nodes:ur.nodes,node:ur.node,size:ur.size,empty:ur.empty,each:ur.each,on:L6,attr:x6,attrTween:j6,style:G6,styleTween:X6,text:eU,textTween:sU,remove:D6,tween:u6,delay:S6,duration:C6,ease:$6,easeVarying:T6,end:rU,[Symbol.iterator]:ur[Symbol.iterator]};function oU(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var lU={time:null,delay:0,duration:250,ease:oU};function cU(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 uU(e){var t,s;e instanceof yr?(t=e._id,e=e._name):(t=C1(),(s=lU).time=wx(),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])&&mh(d,e,t,h,l,s||cU(d,t));return new yr(i,this._parents,e,t)}Bc.prototype.interrupt=o6;Bc.prototype.transition=uU;const ad=e=>()=>e;function dU(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 mr(e,t,s){this.k=e,this.x=t,this.y=s}mr.prototype={constructor:mr,scale:function(e){return e===1?this:new mr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new mr(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 fh=new mr(1,0,0);A1.prototype=mr.prototype;function A1(e){for(;!e.__zoom;)if(!(e=e.parentNode))return fh;return e.__zoom}function Gf(e){e.stopImmediatePropagation()}function Wl(e){e.preventDefault(),e.stopImmediatePropagation()}function hU(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function mU(){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 Dk(){return this.__zoom||fh}function fU(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function pU(){return navigator.maxTouchPoints||"ontouchstart"in this}function gU(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 $1(){var e=hU,t=mU,s=gU,i=fU,r=pU,o=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],u=250,d=kd,h=uh("start","zoom","end"),f,p,g,x=500,b=150,k=0,j=10;function N(I){I.property("__zoom",Dk).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",T).filter(r).on("touchstart.zoom",D).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(I,R,L,K){var F=I.selection?I.selection():I;F.property("__zoom",Dk),I!==F?z(I,R,L,K):F.interrupt().each(function(){P(this,arguments).event(K).start().zoom(null,typeof R=="function"?R.apply(this,arguments):R).end()})},N.scaleBy=function(I,R,L,K){N.scaleTo(I,function(){var F=this.__zoom.k,q=typeof R=="function"?R.apply(this,arguments):R;return F*q},L,K)},N.scaleTo=function(I,R,L,K){N.transform(I,function(){var F=t.apply(this,arguments),q=this.__zoom,V=L==null?_(F):typeof L=="function"?L.apply(this,arguments):L,Z=q.invert(V),Q=typeof R=="function"?R.apply(this,arguments):R;return s(S(C(q,Q),V,Z),F,l)},L,K)},N.translateBy=function(I,R,L,K){N.transform(I,function(){return s(this.__zoom.translate(typeof R=="function"?R.apply(this,arguments):R,typeof L=="function"?L.apply(this,arguments):L),t.apply(this,arguments),l)},null,K)},N.translateTo=function(I,R,L,K,F){N.transform(I,function(){var q=t.apply(this,arguments),V=this.__zoom,Z=K==null?_(q):typeof K=="function"?K.apply(this,arguments):K;return s(fh.translate(Z[0],Z[1]).scale(V.k).translate(typeof R=="function"?-R.apply(this,arguments):-R,typeof L=="function"?-L.apply(this,arguments):-L),q,l)},K,F)};function C(I,R){return R=Math.max(o[0],Math.min(o[1],R)),R===I.k?I:new mr(R,I.x,I.y)}function S(I,R,L){var K=R[0]-L[0]*I.k,F=R[1]-L[1]*I.k;return K===I.x&&F===I.y?I:new mr(I.k,K,F)}function _(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function z(I,R,L,K){I.on("start.zoom",function(){P(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(K).end()}).tween("zoom",function(){var F=this,q=arguments,V=P(F,q).event(K),Z=t.apply(F,q),Q=L==null?_(Z):typeof L=="function"?L.apply(F,q):L,G=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),ne=F.__zoom,te=typeof R=="function"?R.apply(F,q):R,re=d(ne.invert(Q).concat(G/ne.k),te.invert(Q).concat(G/te.k));return function(X){if(X===1)X=te;else{var se=re(X),ae=G/se[2];X=new mr(ae,Q[0]-se[0]*ae,Q[1]-se[1]*ae)}V.zoom(null,X)}})}function P(I,R,L){return!L&&I.__zooming||new H(I,R)}function H(I,R){this.that=I,this.args=R,this.active=0,this.sourceEvent=null,this.extent=t.apply(I,R),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,R){return this.mouse&&I!=="mouse"&&(this.mouse[1]=R.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=R.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=R.invert(this.touch1[0])),this.that.__zoom=R,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var R=Bs(this.that).datum();h.call(I,this.that,new dU(I,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:h}),R)}};function B(I,...R){if(!e.apply(this,arguments))return;var L=P(this,R).event(I),K=this.__zoom,F=Math.max(o[0],Math.min(o[1],K.k*Math.pow(2,i.apply(this,arguments)))),q=ji(I);if(L.wheel)(L.mouse[0][0]!==q[0]||L.mouse[0][1]!==q[1])&&(L.mouse[1]=K.invert(L.mouse[0]=q)),clearTimeout(L.wheel);else{if(K.k===F)return;L.mouse=[q,K.invert(q)],wd(this),L.start()}Wl(I),L.wheel=setTimeout(V,b),L.zoom("mouse",s(S(C(K,F),L.mouse[0],L.mouse[1]),L.extent,l));function V(){L.wheel=null,L.end()}}function O(I,...R){if(g||!e.apply(this,arguments))return;var L=I.currentTarget,K=P(this,R,!0).event(I),F=Bs(I.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",G,!0),q=ji(I,L),V=I.clientX,Z=I.clientY;m1(I.view),Gf(I),K.mouse=[q,this.__zoom.invert(q)],wd(this),K.start();function Q(ne){if(Wl(ne),!K.moved){var te=ne.clientX-V,re=ne.clientY-Z;K.moved=te*te+re*re>k}K.event(ne).zoom("mouse",s(S(K.that.__zoom,K.mouse[0]=ji(ne,L),K.mouse[1]),K.extent,l))}function G(ne){F.on("mousemove.zoom mouseup.zoom",null),f1(ne.view,K.moved),Wl(ne),K.event(ne).end()}}function T(I,...R){if(e.apply(this,arguments)){var L=this.__zoom,K=ji(I.changedTouches?I.changedTouches[0]:I,this),F=L.invert(K),q=L.k*(I.shiftKey?.5:2),V=s(S(C(L,q),K,F),t.apply(this,R),l);Wl(I),u>0?Bs(this).transition().duration(u).call(z,V,K,I):Bs(this).call(N.transform,V,K,I)}}function D(I,...R){if(e.apply(this,arguments)){var L=I.touches,K=L.length,F=P(this,R,I.changedTouches.length===K).event(I),q,V,Z,Q;for(Gf(I),V=0;V<K;++V)Z=L[V],Q=ji(Z,this),Q=[Q,this.__zoom.invert(Q),Z.identifier],F.touch0?!F.touch1&&F.touch0[2]!==Q[2]&&(F.touch1=Q,F.taps=0):(F.touch0=Q,q=!0,F.taps=1+!!f);f&&(f=clearTimeout(f)),q&&(F.taps<2&&(p=Q[0],f=setTimeout(function(){f=null},x)),wd(this),F.start())}}function U(I,...R){if(this.__zooming){var L=P(this,R).event(I),K=I.changedTouches,F=K.length,q,V,Z,Q;for(Wl(I),q=0;q<F;++q)V=K[q],Z=ji(V,this),L.touch0&&L.touch0[2]===V.identifier?L.touch0[0]=Z:L.touch1&&L.touch1[2]===V.identifier&&(L.touch1[0]=Z);if(V=L.that.__zoom,L.touch1){var G=L.touch0[0],ne=L.touch0[1],te=L.touch1[0],re=L.touch1[1],X=(X=te[0]-G[0])*X+(X=te[1]-G[1])*X,se=(se=re[0]-ne[0])*se+(se=re[1]-ne[1])*se;V=C(V,Math.sqrt(X/se)),Z=[(G[0]+te[0])/2,(G[1]+te[1])/2],Q=[(ne[0]+re[0])/2,(ne[1]+re[1])/2]}else if(L.touch0)Z=L.touch0[0],Q=L.touch0[1];else return;L.zoom("touch",s(S(V,Z,Q),L.extent,l))}}function A(I,...R){if(this.__zooming){var L=P(this,R).event(I),K=I.changedTouches,F=K.length,q,V;for(Gf(I),g&&clearTimeout(g),g=setTimeout(function(){g=null},x),q=0;q<F;++q)V=K[q],L.touch0&&L.touch0[2]===V.identifier?delete L.touch0:L.touch1&&L.touch1[2]===V.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(V=ji(V,this),Math.hypot(p[0]-V[0],p[1]-V[1])<j)){var Z=Bs(this).on("dblclick.zoom");Z&&Z.apply(this,arguments)}}}return N.wheelDelta=function(I){return arguments.length?(i=typeof I=="function"?I:ad(+I),N):i},N.filter=function(I){return arguments.length?(e=typeof I=="function"?I:ad(!!I),N):e},N.touchable=function(I){return arguments.length?(r=typeof I=="function"?I:ad(!!I),N):r},N.extent=function(I){return arguments.length?(t=typeof I=="function"?I:ad([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),N):t},N.scaleExtent=function(I){return arguments.length?(o[0]=+I[0],o[1]=+I[1],N):[o[0],o[1]]},N.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],N):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},N.constrain=function(I){return arguments.length?(s=I,N):s},N.duration=function(I){return arguments.length?(u=+I,N):u},N.interpolate=function(I){return arguments.length?(d=I,N):d},N.on=function(){var I=h.on.apply(h,arguments);return I===h?N:I},N.clickDistance=function(I){return arguments.length?(k=(I=+I)*I,N):Math.sqrt(k)},N.tapDistance=function(I){return arguments.length?(j=+I,N):j},N}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.`},Ec=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],I1=["Enter"," ","Escape"],T1={"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 La;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(La||(La={}));var Cc;(function(e){e.Partial="partial",e.Full="full"})(Cc||(Cc={}));const M1={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Vr;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Vr||(Vr={}));var Zd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Zd||(Zd={}));var tt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(tt||(tt={}));const Fk={[tt.Left]:tt.Right,[tt.Right]:tt.Left,[tt.Top]:tt.Bottom,[tt.Bottom]:tt.Top},R1=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,xU=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Ex=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Zc=(e,t=[0,0])=>{const{width:s,height:i}=Ii(e),r=e.origin??t,o=s*r[0],l=i*r[1];return{x:e.position.x-o,y:e.position.y-l}},vU=(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):Ex(o)?o:t.nodeLookup.get(o.id)),u?(s=!0,ph(r,Wd(u,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return s?gh(i):{x:0,y:0,width:0,height:0}},Wc=(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=ph(s,Wd(r)),i=!0)}),i?gh(s):{x:0,y:0,width:0,height:0}},Cx=(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,f=t.height/r,p=[];for(const g of e.values()){const{measured:x,selectable:b=!0,hidden:k=!1}=g;if(l&&!b||k)continue;const j=x.width??g.width??g.initialWidth??0,N=x.height??g.height??g.initialHeight??0,{x:C,y:S}=g.internals.positionAbsolute,_=z1(u,d,h,f,C,S,j,N),z=j*N,P=o&&_>0;(!g.internals.handleBounds||P||_>=z||g.dragging)&&p.push(g)}return p},yU=(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 bU(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}=Ii(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 kU({nodes:e,width:t,height:s,panZoom:i,minZoom:r,maxZoom:o},l){if(e.size===0)return!0;const u=bU(e,l),d=Wc(u),h=$x(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 O1({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},f=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:b}=Ii(u);x&&b&&(p=[[d,h],[d+x,h+b]])}else u&&Ha(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=Ha(p)?Ba(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)*f[0],y:g.y-h+(l.measured.height??0)*f[1]},positionAbsolute:g}}async function jU({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),b=!x&&g.parentId&&l.find(k=>k.id===g.parentId);(x||b)&&l.push(g)}const u=new Set(t.map(g=>g.id)),d=i.filter(g=>g.deletable!==!1),f=yU(l,d);for(const g of d)u.has(g.id)&&!f.find(b=>b.id===g.id)&&f.push(g);if(!r)return{edges:f,nodes:l};const p=await r({nodes:l,edges:f});return typeof p=="boolean"?p?{edges:f,nodes:l}:{edges:[],nodes:[]}:p}const Jo=(e,t=0,s=1)=>Math.min(Math.max(e,t),s),Ba=(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 P1(e,t,s){const{width:i,height:r}=Ii(s),{x:o,y:l}=s.internals.positionAbsolute;return Ba(e,[[o,l],[o+i,l+r]],t)}const Uk=(e,t,s)=>e<t?Jo(Math.abs(e-t),1,t)/t:e>s?-Jo(Math.abs(e-s),1,t)/t:0,Ax=(e,t,s=15,i=40)=>{const r=Uk(e.x,i,t.width-i)*s,o=Uk(e.y,i,t.height-i)*s;return[r,o]},ph=(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)}),ug=({x:e,y:t,width:s,height:i})=>({x:e,y:t,x2:e+s,y2:t+i}),gh=({x:e,y:t,x2:s,y2:i})=>({x:e,y:t,width:s-e,height:i-t}),Ac=(e,t=[0,0])=>{var r,o;const{x:s,y:i}=Ex(e)?e.internals.positionAbsolute:Zc(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}},Wd=(e,t=[0,0])=>{var r,o;const{x:s,y:i}=Ex(e)?e.internals.positionAbsolute:Zc(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)}},L1=(e,t)=>gh(ph(ug(e),ug(t))),z1=(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)},Vd=(e,t)=>z1(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Bk=e=>_i(e.width)&&_i(e.height)&&_i(e.x)&&_i(e.y),_i=e=>!isNaN(e)&&isFinite(e),D1=(e,t)=>(s,i)=>{},Vc=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),qc=({x:e,y:t},[s,i,r],o=!1,l=[1,1])=>{const u={x:(e-s)/r,y:(t-i)/r};return o?Vc(u,l):u},el=({x:e,y:t},[s,i,r])=>({x:e*r+s,y:t*r+i});function No(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 NU(e,t,s){if(typeof e=="string"||typeof e=="number"){const i=No(e,s),r=No(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=No(e.top??e.y??0,s),r=No(e.bottom??e.y??0,s),o=No(e.left??e.x??0,t),l=No(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 wU(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]),f=r-d,p=o-h;return{left:Math.floor(l),top:Math.floor(u),right:Math.floor(f),bottom:Math.floor(p)}}const $x=(e,t,s,i,r,o)=>{const l=NU(o,t,s),u=(t-l.x)/e.width,d=(s-l.y)/e.height,h=Math.min(u,d),f=Jo(h,i,r),p=e.x+e.width/2,g=e.y+e.height/2,x=t/2-p*f,b=s/2-g*f,k=wU(e,x,b,f,t,s),j={left:Math.min(k.left-l.left,0),top:Math.min(k.top-l.top,0),right:Math.min(k.right-l.right,0),bottom:Math.min(k.bottom-l.bottom,0)};return{x:x-j.left+j.right,y:b-j.top+j.bottom,zoom:f}},$c=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ha(e){return e!=null&&e!=="parent"}function Ii(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 F1(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 U1(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 Hk(e,t){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}function SU(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function _U(e){return{...T1,...e||{}}}function B1(e){return e===null?null:e?"valid":"invalid"}function mc(e,{snapGrid:t=[0,0],snapToGrid:s=!1,transform:i,containerBounds:r}){const{x:o,y:l}=Ei(e),u=qc({x:o-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},i),{x:d,y:h}=s?Vc(u,t):u;return{xSnapped:d,ySnapped:h,...u}}const Ix=e=>({width:e.offsetWidth,height:e.offsetHeight}),H1=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},EU=["INPUT","SELECT","TEXTAREA"];function Z1(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:EU.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const W1=e=>"clientX"in e,Ei=(e,t)=>{var o,l;const s=W1(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)}},Zk=(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,...Ix(l)}})};function V1({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,f=Math.abs(d-e),p=Math.abs(h-t);return[d,h,f,p]}function od(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Wk({pos:e,x1:t,y1:s,x2:i,y2:r,c:o}){switch(e){case tt.Left:return[t-od(t-i,o),s];case tt.Right:return[t+od(i-t,o),s];case tt.Top:return[t,s-od(s-r,o)];case tt.Bottom:return[t,s+od(r-s,o)]}}function q1({sourceX:e,sourceY:t,sourcePosition:s=tt.Bottom,targetX:i,targetY:r,targetPosition:o=tt.Top,curvature:l=.25}){const[u,d]=Wk({pos:s,x1:e,y1:t,x2:i,y2:r,c:l}),[h,f]=Wk({pos:o,x1:i,y1:r,x2:e,y2:t,c:l}),[p,g,x,b]=V1({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:u,sourceControlY:d,targetControlX:h,targetControlY:f});return[`M${e},${t} C${u},${d} ${h},${f} ${i},${r}`,p,g,x,b]}function G1({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 CU({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 AU({sourceNode:e,targetNode:t,width:s,height:i,transform:r}){const o=ph(Wd(e),Wd(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 Vd(l,gh(o))>0}const $U=({source:e,sourceHandle:t,target:s,targetHandle:i})=>`xy-edge__${e}${t||""}-${s}${i||""}`,IU=(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)),TU=(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||$U;let r;return R1(e)?r={...e}:r={...e,id:i(e)},IU(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function K1({sourceX:e,sourceY:t,targetX:s,targetY:i}){const[r,o,l,u]=G1({sourceX:e,sourceY:t,targetX:s,targetY:i});return[`M ${e},${t}L ${s},${i}`,r,o,l,u]}const Vk={[tt.Left]:{x:-1,y:0},[tt.Right]:{x:1,y:0},[tt.Top]:{x:0,y:-1},[tt.Bottom]:{x:0,y:1}},MU=({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},qk=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function RU({source:e,sourcePosition:t=tt.Bottom,target:s,targetPosition:i=tt.Top,center:r,offset:o,stepPosition:l}){const u=Vk[t],d=Vk[i],h={x:e.x+u.x*o,y:e.y+u.y*o},f={x:s.x+d.x*o,y:s.y+d.y*o},p=MU({source:h,sourcePosition:t,target:f}),g=p.x!==0?"x":"y",x=p[g];let b=[],k,j;const N={x:0,y:0},C={x:0,y:0},[,,S,_]=G1({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(u[g]*d[g]===-1){g==="x"?(k=r.x??h.x+(f.x-h.x)*l,j=r.y??(h.y+f.y)/2):(k=r.x??(h.x+f.x)/2,j=r.y??h.y+(f.y-h.y)*l);const B=[{x:k,y:h.y},{x:k,y:f.y}],O=[{x:h.x,y:j},{x:f.x,y:j}];u[g]===x?b=g==="x"?B:O:b=g==="x"?O:B}else{const B=[{x:h.x,y:f.y}],O=[{x:f.x,y:h.y}];if(g==="x"?b=u.x===x?O:B:b=u.y===x?B:O,t===i){const I=Math.abs(e[g]-s[g]);if(I<=o){const R=Math.min(o-1,o-I);u[g]===x?N[g]=(h[g]>e[g]?-1:1)*R:C[g]=(f[g]>s[g]?-1:1)*R}}if(t!==i){const I=g==="x"?"y":"x",R=u[g]===d[I],L=h[I]>f[I],K=h[I]<f[I];(u[g]===1&&(!R&&L||R&&K)||u[g]!==1&&(!R&&K||R&&L))&&(b=g==="x"?B:O)}const T={x:h.x+N.x,y:h.y+N.y},D={x:f.x+C.x,y:f.y+C.y},U=Math.max(Math.abs(T.x-b[0].x),Math.abs(D.x-b[0].x)),A=Math.max(Math.abs(T.y-b[0].y),Math.abs(D.y-b[0].y));U>=A?(k=(T.x+D.x)/2,j=b[0].y):(k=b[0].x,j=(T.y+D.y)/2)}const z={x:h.x+N.x,y:h.y+N.y},P={x:f.x+C.x,y:f.y+C.y};return[[e,...z.x!==b[0].x||z.y!==b[0].y?[z]:[],...b,...P.x!==b[b.length-1].x||P.y!==b[b.length-1].y?[P]:[],s],k,j,S,_]}function OU(e,t,s,i){const r=Math.min(qk(e,t)/2,qk(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,f=e.y<s.y?1:-1;return`L ${o+r*h},${l}Q ${o},${l} ${o},${l+r*f}`}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 dg({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:f=.5}){const[p,g,x,b,k]=RU({source:{x:e,y:t},sourcePosition:s,target:{x:i,y:r},targetPosition:o,center:{x:u,y:d},offset:h,stepPosition:f});let j=`M${p[0].x} ${p[0].y}`;for(let N=1;N<p.length-1;N++)j+=OU(p[N-1],p[N],p[N+1],l);return j+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[j,g,x,b,k]}function Gk(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function PU(e){var p;const{sourceNode:t,targetNode:s}=e;if(!Gk(t)||!Gk(s))return null;const i=t.internals.handleBounds||Kk(t.handles),r=s.internals.handleBounds||Kk(s.handles),o=Yk((i==null?void 0:i.source)??[],e.sourceHandle),l=Yk(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=Za(t,o,u),f=Za(s,l,d);return{sourceX:h.x,sourceY:h.y,targetX:f.x,targetY:f.y,sourcePosition:u,targetPosition:d}}function Kk(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 Za(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??Ii(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 Yk(e,t){return e&&(t?e.find(s=>s.id===t):e[0])||null}function hg(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function LU(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=hg(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 Y1=1e3,zU=10,Tx={nodeOrigin:[0,0],nodeExtent:Ec,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},DU={...Tx,checkEquality:!0};function Mx(e,t){const s={...e};for(const i in t)t[i]!==void 0&&(s[i]=t[i]);return s}function FU(e,t,s){const i=Mx(Tx,s);for(const r of e.values())if(r.parentId)Ox(r,e,t,i);else{const o=Zc(r,i.nodeOrigin),l=Ha(r.extent)?r.extent:i.nodeExtent,u=Ba(o,l,Ii(r));r.internals.positionAbsolute=u}}function UU(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 Rx(e){return e==="manual"}function mg(e,t,s,i={}){var f,p;const r=Mx(DU,i),o={i:0},l=new Map(t),u=r!=null&&r.elevateNodesOnSelect&&!Rx(r.zIndexMode)?Y1: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 b=Zc(g,r.nodeOrigin),k=Ha(g.extent)?g.extent:r.nodeExtent,j=Ba(b,k,Ii(g));x={...r.defaults,...g,measured:{width:(f=g.measured)==null?void 0:f.width,height:(p=g.measured)==null?void 0:p.height},internals:{positionAbsolute:j,handleBounds:UU(g,x),z:X1(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&&Ox(x,t,s,i,o),h||(h=g.selected??!1)}return{nodesInitialized:d,hasSelectedNodes:h}}function BU(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 Ox(e,t,s,i,r){const{elevateNodesOnSelect:o,nodeOrigin:l,nodeExtent:u,zIndexMode:d}=Mx(Tx,i),h=e.parentId,f=t.get(h);if(!f){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}BU(e,s),r&&!f.parentId&&f.internals.rootParentIndex===void 0&&d==="auto"&&(f.internals.rootParentIndex=++r.i,f.internals.z=f.internals.z+r.i*zU),r&&f.internals.rootParentIndex!==void 0&&(r.i=f.internals.rootParentIndex);const p=o&&!Rx(d)?Y1:0,{x:g,y:x,z:b}=HU(e,f,l,u,p,d),{positionAbsolute:k}=e.internals,j=g!==k.x||x!==k.y;(j||b!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:j?{x:g,y:x}:k,z:b}})}function X1(e,t,s){const i=_i(e.zIndex)?e.zIndex:0;return Rx(s)?i:i+(e.selected?t:0)}function HU(e,t,s,i,r,o){const{x:l,y:u}=t.internals.positionAbsolute,d=Ii(e),h=Zc(e,s),f=Ha(e.extent)?Ba(h,e.extent,d):h;let p=Ba({x:l+f.x,y:u+f.y},i,d);e.extent==="parent"&&(p=P1(p,d,t));const g=X1(e,r,o),x=t.internals.z??0;return{x:p.x,y:p.y,z:x>=g?x+1:g}}function Px(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)??Ac(d),f=L1(h,u.rect);o.set(u.parentId,{expandedRect:f,parent:d})}return o.size>0&&o.forEach(({expandedRect:u,parent:d},h)=>{var S;const f=d.internals.positionAbsolute,p=Ii(d),g=d.origin??i,x=u.x<f.x?Math.round(Math.abs(f.x-u.x)):0,b=u.y<f.y?Math.round(Math.abs(f.y-u.y)):0,k=Math.max(p.width,Math.round(u.width)),j=Math.max(p.height,Math.round(u.height)),N=(k-p.width)*g[0],C=(j-p.height)*g[1];(x>0||b>0||N||C)&&(r.push({id:h,type:"position",position:{x:d.position.x-x+N,y:d.position.y-b+C}}),(S=s.get(h))==null||S.forEach(_=>{e.some(z=>z.id===_.id)||r.push({id:_.id,type:"position",position:{x:_.position.x+x,y:_.position.y+b}})})),(p.width<u.width||p.height<u.height||x||b)&&r.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:k+(x?g[0]*x-N:0),height:j+(b?g[1]*b-C:0)}})}),r}function ZU(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=[],f=window.getComputedStyle(u),{m22:p}=new window.DOMMatrixReadOnly(f.transform),g=[];for(const x of e.values()){const b=t.get(x.id);if(!b)continue;if(b.hidden){t.set(b.id,{...b,internals:{...b.internals,handleBounds:void 0}}),d=!0;continue}const k=Ix(x.nodeElement),j=b.measured.width!==k.width||b.measured.height!==k.height;if(!!(k.width&&k.height&&(j||!b.internals.handleBounds||x.force))){const C=x.nodeElement.getBoundingClientRect(),S=Ha(b.extent)?b.extent:o;let{positionAbsolute:_}=b.internals;if(b.parentId&&b.extent==="parent"){const P=t.get(b.parentId);P&&(_=P1(_,k,P))}else S&&(_=Ba(_,S,k));const z={...b,measured:k,internals:{...b.internals,positionAbsolute:_,handleBounds:{source:Zk("source",x.nodeElement,C,p,b.id),target:Zk("target",x.nodeElement,C,p,b.id)}}};t.set(b.id,z),b.parentId&&Ox(z,t,s,{nodeOrigin:r,zIndexMode:l}),d=!0,j&&(h.push({id:b.id,type:"dimensions",dimensions:k}),b.expandParent&&b.parentId&&g.push({id:b.id,parentId:b.parentId,rect:Ac(z,r)}))}}if(g.length>0){const x=Px(g,t,s,r);h.push(...x)}return{changes:h,updatedInternals:d}}async function WU({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 Xk(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 Q1(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}`,f=`${o}-${u}--${r}-${l}`;Xk("source",d,f,e,r,l),Xk("target",d,h,e,o,u),t.set(i.id,i)}}function J1(e,t){if(!e.parentId)return!1;const s=t.get(e.parentId);return s?s.selected?!0:J1(s,t):!1}function Qk(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 VU(e,t,s,i){const r=new Map;for(const[o,l]of e)if((l.selected||l.id===i)&&(!l.parentId||!J1(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 Kf({nodeId:e,dragItems:t,nodeLookup:s,dragging:i=!0}){var l,u,d;const r=[];for(const[h,f]of t){const p=(l=s.get(h))==null?void 0:l.internals.userNode;p&&r.push({...p,position:f.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 qU({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=Vc(o,t);return{x:l.x-o.x,y:l.y-o.y}}function GU({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},f=null,p=!1,g=null,x=!1,b=!1,k=null;function j({noDragClassName:C,handleSelector:S,domNode:_,isSelectable:z,nodeId:P,nodeClickDistance:H=0}){g=Bs(_);function B({x:U,y:A}){const{nodeLookup:I,nodeExtent:R,snapGrid:L,snapToGrid:K,nodeOrigin:F,onNodeDrag:q,onSelectionDrag:V,onError:Z,updateNodePositions:Q}=t();o={x:U,y:A};let G=!1;const ne=u.size>1,te=ne&&R?ug(Wc(u)):null,re=ne&&K?qU({dragItems:u,snapGrid:L,x:U,y:A}):null;for(const[X,se]of u){if(!I.has(X))continue;let ae={x:U-se.distance.x,y:A-se.distance.y};K&&(ae=re?{x:Math.round(ae.x+re.x),y:Math.round(ae.y+re.y)}:Vc(ae,L));let _e=null;if(ne&&R&&!se.extent&&te){const{positionAbsolute:fe}=se.internals,ye=fe.x-te.x+R[0][0],Fe=fe.x+se.measured.width-te.x2+R[1][0],Re=fe.y-te.y+R[0][1],Qe=fe.y+se.measured.height-te.y2+R[1][1];_e=[[ye,Re],[Fe,Qe]]}const{position:ze,positionAbsolute:Te}=O1({nodeId:X,nextPosition:ae,nodeLookup:I,nodeExtent:_e||R,nodeOrigin:F,onError:Z});G=G||se.position.x!==ze.x||se.position.y!==ze.y,se.position=ze,se.internals.positionAbsolute=Te}if(b=b||G,!!G&&(Q(u,!0),k&&(i||q||!P&&V))){const[X,se]=Kf({nodeId:P,dragItems:u,nodeLookup:I});i==null||i(k,u,X,se),q==null||q(k,X,se),P||V==null||V(k,se)}}async function O(){if(!f)return;const{transform:U,panBy:A,autoPanSpeed:I,autoPanOnNodeDrag:R}=t();if(!R){d=!1,cancelAnimationFrame(l);return}const[L,K]=Ax(h,f,I);(L!==0||K!==0)&&(o.x=(o.x??0)-L/U[2],o.y=(o.y??0)-K/U[2],await A({x:L,y:K})&&B(o)),l=requestAnimationFrame(O)}function T(U){var ne;const{nodeLookup:A,multiSelectionActive:I,nodesDraggable:R,transform:L,snapGrid:K,snapToGrid:F,selectNodesOnDrag:q,onNodeDragStart:V,onSelectionDragStart:Z,unselectNodesAndEdges:Q}=t();p=!0,(!q||!z)&&!I&&P&&((ne=A.get(P))!=null&&ne.selected||Q()),z&&q&&P&&(e==null||e(P));const G=mc(U.sourceEvent,{transform:L,snapGrid:K,snapToGrid:F,containerBounds:f});if(o=G,u=VU(A,R,G,P),u.size>0&&(s||V||!P&&Z)){const[te,re]=Kf({nodeId:P,dragItems:u,nodeLookup:A});s==null||s(U.sourceEvent,u,te,re),V==null||V(U.sourceEvent,te,re),P||Z==null||Z(U.sourceEvent,re)}}const D=p1().clickDistance(H).on("start",U=>{const{domNode:A,nodeDragThreshold:I,transform:R,snapGrid:L,snapToGrid:K}=t();f=(A==null?void 0:A.getBoundingClientRect())||null,x=!1,b=!1,k=U.sourceEvent,I===0&&T(U),o=mc(U.sourceEvent,{transform:R,snapGrid:L,snapToGrid:K,containerBounds:f}),h=Ei(U.sourceEvent,f)}).on("drag",U=>{const{autoPanOnNodeDrag:A,transform:I,snapGrid:R,snapToGrid:L,nodeDragThreshold:K,nodeLookup:F}=t(),q=mc(U.sourceEvent,{transform:I,snapGrid:R,snapToGrid:L,containerBounds:f});if(k=U.sourceEvent,(U.sourceEvent.type==="touchmove"&&U.sourceEvent.touches.length>1||P&&!F.has(P))&&(x=!0),!x){if(!d&&A&&p&&(d=!0,O()),!p){const V=Ei(U.sourceEvent,f),Z=V.x-h.x,Q=V.y-h.y;Math.sqrt(Z*Z+Q*Q)>K&&T(U)}(o.x!==q.xSnapped||o.y!==q.ySnapped)&&u&&p&&(h=Ei(U.sourceEvent,f),B(q))}}).on("end",U=>{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:R,onSelectionDragStop:L}=t();if(b&&(I(u,!1),b=!1),r||R||!P&&L){const[K,F]=Kf({nodeId:P,dragItems:u,nodeLookup:A,dragging:!1});r==null||r(U.sourceEvent,u,K,F),R==null||R(U.sourceEvent,K,F),P||L==null||L(U.sourceEvent,F)}}}).filter(U=>{const A=U.target;return!U.button&&(!C||!Qk(A,`.${C}`,_))&&(!S||Qk(A,S,_))});g.call(D)}function N(){g==null||g.on(".drag",null)}return{update:j,destroy:N}}function KU(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())Vd(r,Ac(o))>0&&i.push(o);return i}const YU=250;function XU(e,t,s,i){var u,d;let r=[],o=1/0;const l=KU(e,s,t+YU);for(const h of l){const f=[...((u=h.internals.handleBounds)==null?void 0:u.source)??[],...((d=h.internals.handleBounds)==null?void 0:d.target)??[]];for(const p of f){if(i.nodeId===p.nodeId&&i.type===p.type&&i.id===p.id)continue;const{x:g,y:x}=Za(h,p,p.position,!0),b=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(x-e.y,2));b>t||(b<o?(r=[{...p,x:g,y:x}],o=b):b===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(f=>f.type===h)??r[0]}return r[0]}function e_(e,t,s,i,r,o=!1){var h,f,p;const l=i.get(e);if(!l)return null;const u=r==="strict"?(h=l.internals.handleBounds)==null?void 0:h[t]:[...((f=l.internals.handleBounds)==null?void 0:f.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,...Za(l,d,d.position,!0)}:d}function t_(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function QU(e,t){let s=null;return t?s=!0:e&&!t&&(s=!1),s}const n_=()=>!0;function JU(e,{connectionMode:t,connectionRadius:s,handleId:i,nodeId:r,edgeUpdaterType:o,isTarget:l,domNode:u,nodeLookup:d,lib:h,autoPanOnConnect:f,flowId:p,panBy:g,cancelConnection:x,onConnectStart:b,onConnect:k,onConnectEnd:j,isValidConnection:N=n_,onReconnectEnd:C,updateConnection:S,getTransform:_,getFromHandle:z,autoPanSpeed:P,dragThreshold:H=1,handleDomNode:B}){const O=H1(e.target);let T=0,D;const{x:U,y:A}=Ei(e),I=t_(o,B),R=u==null?void 0:u.getBoundingClientRect();let L=!1;if(!R||!I)return;const K=e_(r,I,i,d,t);if(!K)return;let F=Ei(e,R),q=!1,V=null,Z=!1,Q=null;function G(){if(!f||!R)return;const[ze,Te]=Ax(F,R,P);g({x:ze,y:Te}),T=requestAnimationFrame(G)}const ne={...K,nodeId:r,type:I,position:K.position},te=d.get(r);let X={inProgress:!0,isValid:null,from:Za(te,ne,tt.Left,!0),fromHandle:ne,fromPosition:ne.position,fromNode:te,to:F,toHandle:null,toPosition:Fk[ne.position],toNode:null,pointer:F};function se(){L=!0,S(X),b==null||b(e,{nodeId:r,handleId:i,handleType:I})}H===0&&se();function ae(ze){if(!L){const{x:Qe,y:Ke}=Ei(ze),_t=Qe-U,xt=Ke-A;if(!(_t*_t+xt*xt>H*H))return;se()}if(!z()||!ne){_e(ze);return}const Te=_();F=Ei(ze,R),D=XU(qc(F,Te,!1,[1,1]),s,d,ne),q||(G(),q=!0);const fe=s_(ze,{handle:D,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:l?"target":"source",isValidConnection:N,doc:O,lib:h,flowId:p,nodeLookup:d});Q=fe.handleDomNode,V=fe.connection,Z=QU(!!D,fe.isValid);const ye=d.get(r),Fe=ye?Za(ye,ne,tt.Left,!0):X.from,Re={...X,from:Fe,isValid:Z,to:fe.toHandle&&Z?el({x:fe.toHandle.x,y:fe.toHandle.y},Te):F,toHandle:fe.toHandle,toPosition:Z&&fe.toHandle?fe.toHandle.position:Fk[ne.position],toNode:fe.toHandle?d.get(fe.toHandle.nodeId):null,pointer:F};S(Re),X=Re}function _e(ze){if(!("touches"in ze&&ze.touches.length>0)){if(L){(D||Q)&&V&&Z&&(k==null||k(V));const{inProgress:Te,...fe}=X,ye={...fe,toPosition:X.toHandle?X.toPosition:null};j==null||j(ze,ye),o&&(C==null||C(ze,ye))}x(),cancelAnimationFrame(T),q=!1,Z=!1,V=null,Q=null,O.removeEventListener("mousemove",ae),O.removeEventListener("mouseup",_e),O.removeEventListener("touchmove",ae),O.removeEventListener("touchend",_e)}}O.addEventListener("mousemove",ae),O.addEventListener("mouseup",_e),O.addEventListener("touchmove",ae),O.addEventListener("touchend",_e)}function s_(e,{handle:t,connectionMode:s,fromNodeId:i,fromHandleId:r,fromType:o,doc:l,lib:u,flowId:d,isValidConnection:h=n_,nodeLookup:f}){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:b}=Ei(e),k=l.elementFromPoint(x,b),j=k!=null&&k.classList.contains(`${u}-flow__handle`)?k:g,N={handleDomNode:j,isValid:!1,connection:null,toHandle:null};if(j){const C=t_(void 0,j),S=j.getAttribute("data-nodeid"),_=j.getAttribute("data-handleid"),z=j.classList.contains("connectable"),P=j.classList.contains("connectableend");if(!S||!C)return N;const H={source:p?S:i,sourceHandle:p?_:r,target:p?i:S,targetHandle:p?r:_};N.connection=H;const O=z&&P&&(s===Qo.Strict?p&&C==="source"||!p&&C==="target":S!==i||_!==r);N.isValid=O&&h(H),N.toHandle=e_(S,C,_,f,s,!0)}return N}const fg={onPointerDown:JU,isValid:s_};function eB({domNode:e,panZoom:t,getTransform:s,getViewScale:i}){const r=Bs(e);function o({translateExtent:u,width:d,height:h,zoomStep:f=1,pannable:p=!0,zoomable:g=!0,inversePan:x=!1}){const b=S=>{if(S.sourceEvent.type!=="wheel"||!t)return;const _=s(),z=S.sourceEvent.ctrlKey&&$c()?10:1,P=-S.sourceEvent.deltaY*(S.sourceEvent.deltaMode===1?.05:S.sourceEvent.deltaMode?1:.002)*f,H=_[2]*Math.pow(2,P*z);t.scaleTo(H)};let k=[0,0];const j=S=>{(S.sourceEvent.type==="mousedown"||S.sourceEvent.type==="touchstart")&&(k=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY])},N=S=>{const _=s();if(S.sourceEvent.type!=="mousemove"&&S.sourceEvent.type!=="touchmove"||!t)return;const z=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY],P=[z[0]-k[0],z[1]-k[1]];k=z;const H=i()*Math.max(_[2],Math.log(_[2]))*(x?-1:1),B={x:_[0]-P[0]*H,y:_[1]-P[1]*H},O=[[0,0],[d,h]];t.setViewportConstrained({x:B.x,y:B.y,zoom:_[2]},O,u)},C=$1().on("start",j).on("zoom",p?N:null).on("zoom.wheel",g?b:null);r.call(C,{})}function l(){r.on("zoom",null)}return{update:o,destroy:l,pointer:ji}}const xh=e=>({x:e.x,y:e.y,zoom:e.k}),Yf=({x:e,y:t,zoom:s})=>fh.translate(e,t).scale(s),Wr=(e,t)=>e.target.closest(`.${t}`),i_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),tB=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Xf=(e,t=0,s=tB,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(s).on("end",i):e},r_=e=>{const t=e.ctrlKey&&$c()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function nB({zoomPanValues:e,noWheelClassName:t,d3Selection:s,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:o,zoomOnPinch:l,onPanZoomStart:u,onPanZoom:d,onPanZoomEnd:h}){return f=>{if(Wr(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const p=s.property("__zoom").k||1;if(f.ctrlKey&&l){const j=ji(f),N=r_(f),C=p*Math.pow(2,N);i.scaleTo(s,C,j,f);return}const g=f.deltaMode===1?20:1;let x=r===La.Vertical?0:f.deltaX*g,b=r===La.Horizontal?0:f.deltaY*g;!$c()&&f.shiftKey&&r!==La.Vertical&&(x=f.deltaY*g,b=0),i.translateBy(s,-(x/p)*o,-(b/p)*o,{internal:!0});const k=xh(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?d==null||d(f,k):(e.isPanScrolling=!0,u==null||u(f,k)),e.panScrollTimeout=setTimeout(()=>{h==null||h(f,k),e.isPanScrolling=!1},150)}}function sB({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:s}){return function(i,r){const o=i.type==="wheel",l=!t&&o&&!i.ctrlKey,u=Wr(i,e);if(i.ctrlKey&&o&&u&&i.preventDefault(),l||u)return null;i.preventDefault(),s.call(this,i,r)}}function iB({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:s}){return i=>{var o,l,u;if((o=i.sourceEvent)!=null&&o.internal)return;const r=xh(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 rB({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:s,onTransformChange:i,onPanZoom:r}){return o=>{var l,u;e.usedRightMouseButton=!!(s&&i_(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,xh(o.transform)))}}function aB({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&&i_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&o(l.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const d=xh(l.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,d)},s?150:0)}}}function oB({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:s,zoomOnPinch:i,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:l,userSelectionActive:u,noWheelClassName:d,noPanClassName:h,lib:f,connectionInProgress:p}){return g=>{var N;const x=t||s,b=i&&g.ctrlKey,k=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(Wr(g,`${f}-flow__node`)||Wr(g,`${f}-flow__edge`)||Wr(g,`${f}-flow__selection`)||Wr(g,`${f}-flow__nodesselection`)))return!0;if(!r&&!x&&!o&&!l&&!i||u||p&&!k||Wr(g,d)&&k||Wr(g,h)&&(!k||o&&k&&!t)||!i&&g.ctrlKey&&k)return!1;if(!i&&g.type==="touchstart"&&((N=g.touches)==null?void 0:N.length)>1)return g.preventDefault(),!1;if(!x&&!o&&!b&&k||!r&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(r)&&!r.includes(g.button)&&g.type==="mousedown")return!1;const j=Array.isArray(r)&&r.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||k||e)&&j}}function lB({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},f=e.getBoundingClientRect();let p=[[0,0],[f.width,f.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=$1().extent(()=>p).scaleExtent([t,s]).translateExtent(i),b=Bs(e).call(x);_({x:r.x,y:r.y,zoom:Jo(r.zoom,t,s)},[[0,0],[f.width,f.height]],i);const k=b.on("wheel.zoom"),j=b.on("dblclick.zoom");x.wheelDelta(r_);async function N(A,I){return b?new Promise(R=>{x==null||x.interpolate((I==null?void 0:I.interpolate)==="linear"?hc:kd).transform(Xf(b,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>R(!0)),A)}):!1}function C({noWheelClassName:A,noPanClassName:I,onPaneContextMenu:R,userSelectionActive:L,panOnScroll:K,panOnDrag:F,panOnScrollMode:q,panOnScrollSpeed:V,preventScrolling:Z,zoomOnPinch:Q,zoomOnScroll:G,zoomOnDoubleClick:ne,panActivationKeyPressed:te=!1,zoomActivationKeyPressed:re,lib:X,onTransformChange:se,connectionInProgress:ae,paneClickDistance:_e,selectionOnDrag:ze}){L&&!h.isZoomingOrPanning&&S();const Te=K&&!re&&!L;x.clickDistance(ze?1/0:!_i(_e)||_e<0?0:_e);const fe=Te?nB({zoomPanValues:h,noWheelClassName:A,d3Selection:b,d3Zoom:x,panOnScrollMode:q,panOnScrollSpeed:V,zoomOnPinch:Q,onPanZoomStart:l,onPanZoom:o,onPanZoomEnd:u}):sB({noWheelClassName:A,preventScrolling:Z,d3ZoomHandler:k});b.on("wheel.zoom",fe,{passive:!1});const ye=iB({zoomPanValues:h,onDraggingChange:d,onPanZoomStart:l});x.on("start",ye);const Fe=rB({zoomPanValues:h,panOnDrag:F,onPaneContextMenu:!!R,onPanZoom:o,onTransformChange:se});x.on("zoom",Fe);const Re=aB({zoomPanValues:h,panOnDrag:F,panOnScroll:K,onPaneContextMenu:R,onPanZoomEnd:u,onDraggingChange:d});x.on("end",Re);const Qe=oB({panActivationKeyPressed:te,zoomActivationKeyPressed:re,panOnDrag:F,zoomOnScroll:G,panOnScroll:K,zoomOnDoubleClick:ne,zoomOnPinch:Q,userSelectionActive:L,noPanClassName:I,noWheelClassName:A,lib:X,connectionInProgress:ae});x.filter(Qe),ne?b.on("dblclick.zoom",j):b.on("dblclick.zoom",null)}function S(){x.on("zoom",null)}async function _(A,I,R){const L=Yf(A),K=x==null?void 0:x.constrain()(L,I,R);return K&&await N(K),K}async function z(A,I){const R=Yf(A);return await N(R,I),R}function P(A){if(b){const I=Yf(A),R=b.property("__zoom");(R.k!==A.zoom||R.x!==A.x||R.y!==A.y)&&(x==null||x.transform(b,I,null,{sync:!0}))}}function H(){const A=b?A1(b.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}async function B(A,I){return b?new Promise(R=>{x==null||x.interpolate((I==null?void 0:I.interpolate)==="linear"?hc:kd).scaleTo(Xf(b,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>R(!0)),A)}):!1}async function O(A,I){return b?new Promise(R=>{x==null||x.interpolate((I==null?void 0:I.interpolate)==="linear"?hc:kd).scaleBy(Xf(b,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>R(!0)),A)}):!1}function T(A){x==null||x.scaleExtent(A)}function D(A){x==null||x.translateExtent(A)}function U(A){const I=!_i(A)||A<0?0:A;x==null||x.clickDistance(I)}return{update:C,destroy:S,setViewport:z,setViewportConstrained:_,getViewport:H,scaleTo:B,scaleBy:O,setScaleExtent:T,setTranslateExtent:D,syncViewport:P,setClickDistance:U}}var tl;(function(e){e.Line="line",e.Handle="handle"})(tl||(tl={}));function cB({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 Jk(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 Ur(e,t){return Math.max(0,t-e)}function Br(e,t){return Math.max(0,e-t)}function ld(e,t,s){return Math.max(0,t-e,e-s)}function ej(e,t){return e?!t:t}function uB(e,t,s,i,r,o,l,u){let{affectsX:d,affectsY:h}=t;const{isHorizontal:f,isVertical:p}=t,g=f&&p,{xSnapped:x,ySnapped:b}=s,{minWidth:k,maxWidth:j,minHeight:N,maxHeight:C}=i,{x:S,y:_,width:z,height:P,aspectRatio:H}=e;let B=Math.floor(f?x-e.pointerX:0),O=Math.floor(p?b-e.pointerY:0);const T=z+(d?-B:B),D=P+(h?-O:O),U=-o[0]*z,A=-o[1]*P;let I=ld(T,k,j),R=ld(D,N,C);if(l){let F=0,q=0;d&&B<0?F=Ur(S+B+U,l[0][0]):!d&&B>0&&(F=Br(S+T+U,l[1][0])),h&&O<0?q=Ur(_+O+A,l[0][1]):!h&&O>0&&(q=Br(_+D+A,l[1][1])),I=Math.max(I,F),R=Math.max(R,q)}if(u){let F=0,q=0;d&&B>0?F=Br(S+B,u[0][0]):!d&&B<0&&(F=Ur(S+T,u[1][0])),h&&O>0?q=Br(_+O,u[0][1]):!h&&O<0&&(q=Ur(_+D,u[1][1])),I=Math.max(I,F),R=Math.max(R,q)}if(r){if(f){const F=ld(T/H,N,C)*H;if(I=Math.max(I,F),l){let q=0;!d&&!h||d&&!h&&g?q=Br(_+A+T/H,l[1][1])*H:q=Ur(_+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=Ur(_+T/H,u[1][1])*H:q=Br(_+(d?B:-B)/H,u[0][1])*H,I=Math.max(I,q)}}if(p){const F=ld(D*H,k,j)/H;if(R=Math.max(R,F),l){let q=0;!d&&!h||h&&!d&&g?q=Br(S+D*H+U,l[1][0])/H:q=Ur(S+(h?O:-O)*H+U,l[0][0])/H,R=Math.max(R,q)}if(u){let q=0;!d&&!h||h&&!d&&g?q=Ur(S+D*H,u[1][0])/H:q=Br(S+(h?O:-O)*H,u[0][0])/H,R=Math.max(R,q)}}}O=O+(O<0?R:-R),B=B+(B<0?I:-I),r&&(g?T>D*H?O=(ej(d,h)?-B:B)/H:B=(ej(d,h)?-O:O)*H:f?(O=B/H,h=d):(B=O*H,d=h));const L=d?S+B:S,K=h?_+O:_;return{width:z+(d?-B:B),height:P+(h?-O:O),x:o[0]*B*(d?-1:1)+L,y:o[1]*O*(h?-1:1)+K}}const a_={width:0,height:0,x:0,y:0},dB={...a_,pointerX:0,pointerY:0,aspectRatio:1};function hB(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 mB({domNode:e,nodeId:t,getStoreItems:s,onChange:i,onEnd:r}){const o=Bs(e);let l={controlDirection:Jk("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:f,keepAspectRatio:p,resizeDirection:g,onResizeStart:x,onResize:b,onResizeEnd:k,shouldResize:j}){let N={...a_},C={...dB};l={boundaries:f,resizeDirection:g,keepAspectRatio:p,controlDirection:Jk(h)};let S,_=null,z=[],P,H,B,O=!1;const T=p1().on("start",D=>{const{nodeLookup:U,transform:A,snapGrid:I,snapToGrid:R,nodeOrigin:L,paneDomNode:K}=s();if(S=U.get(t),!S)return;_=(K==null?void 0:K.getBoundingClientRect())??null;const{xSnapped:F,ySnapped:q}=mc(D.sourceEvent,{transform:A,snapGrid:I,snapToGrid:R,containerBounds:_});N={width:S.measured.width??0,height:S.measured.height??0,x:S.position.x??0,y:S.position.y??0},C={...N,pointerX:F,pointerY:q,aspectRatio:N.width/N.height},P=void 0,H=Ha(S.extent)?S.extent:void 0,S.parentId&&(S.extent==="parent"||S.expandParent)&&(P=U.get(S.parentId)),P&&S.extent==="parent"&&(H=[[0,0],[P.measured.width,P.measured.height]]),z=[],B=void 0;for(const[V,Z]of U)if(Z.parentId===t&&(z.push({id:V,position:{...Z.position},extent:Z.extent}),Z.extent==="parent"||Z.expandParent)){const Q=hB(Z,S,Z.origin??L);B?B=[[Math.min(Q[0][0],B[0][0]),Math.min(Q[0][1],B[0][1])],[Math.max(Q[1][0],B[1][0]),Math.max(Q[1][1],B[1][1])]]:B=Q}x==null||x(D,{...N})}).on("drag",D=>{const{transform:U,snapGrid:A,snapToGrid:I,nodeOrigin:R}=s(),L=mc(D.sourceEvent,{transform:U,snapGrid:A,snapToGrid:I,containerBounds:_}),K=[];if(!S)return;const{x:F,y:q,width:V,height:Z}=N,Q={},G=S.origin??R,{width:ne,height:te,x:re,y:X}=uB(C,l.controlDirection,L,l.boundaries,l.keepAspectRatio,G,H,B),se=ne!==V,ae=te!==Z,_e=re!==F&&se,ze=X!==q&&ae;if(!_e&&!ze&&!se&&!ae)return;if((_e||ze||G[0]===1||G[1]===1)&&(Q.x=_e?re:N.x,Q.y=ze?X:N.y,N.x=Q.x,N.y=Q.y,z.length>0)){const Fe=re-F,Re=X-q;for(const Qe of z)Qe.position={x:Qe.position.x-Fe+G[0]*(ne-V),y:Qe.position.y-Re+G[1]*(te-Z)},K.push(Qe)}if((se||ae)&&(Q.width=se&&(!l.resizeDirection||l.resizeDirection==="horizontal")?ne:N.width,Q.height=ae&&(!l.resizeDirection||l.resizeDirection==="vertical")?te:N.height,N.width=Q.width,N.height=Q.height),P&&S.expandParent){const Fe=G[0]*(Q.width??0);Q.x&&Q.x<Fe&&(N.x=Fe,C.x=C.x-(Q.x-Fe));const Re=G[1]*(Q.height??0);Q.y&&Q.y<Re&&(N.y=Re,C.y=C.y-(Q.y-Re))}const Te=cB({width:N.width,prevWidth:V,height:N.height,prevHeight:Z,affectsX:l.controlDirection.affectsX,affectsY:l.controlDirection.affectsY}),fe={...N,direction:Te};(j==null?void 0:j(D,fe))!==!1&&(O=!0,b==null||b(D,fe),i(Q,K))}).on("end",D=>{O&&(k==null||k(D,{...N}),r==null||r({...N}),O=!1)});o.call(T)}function d(){o.on(".drag",null)}return{update:u,destroy:d}}var Qf={exports:{}},Jf={},ep={exports:{}},tp={};/**
211
+ * @license React
212
+ * use-sync-external-store-shim.production.js
213
+ *
214
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
215
+ *
216
+ * This source code is licensed under the MIT license found in the
217
+ * LICENSE file in the root directory of this source tree.
218
+ */var tj;function fB(){if(tj)return tp;tj=1;var e=Pc();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(),b=i({inst:{value:x,getSnapshot:g}}),k=b[0].inst,j=b[1];return o(function(){k.value=x,k.getSnapshot=g,d(k)&&j({inst:k})},[p,x,g]),r(function(){return d(k)&&j({inst:k}),p(function(){d(k)&&j({inst:k})})},[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 f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return tp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,tp}var nj;function pB(){return nj||(nj=1,ep.exports=fB()),ep.exports}/**
219
+ * @license React
220
+ * use-sync-external-store-shim/with-selector.production.js
221
+ *
222
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
223
+ *
224
+ * This source code is licensed under the MIT license found in the
225
+ * LICENSE file in the root directory of this source tree.
226
+ */var sj;function gB(){if(sj)return Jf;sj=1;var e=Pc(),t=pB();function s(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}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 Jf.useSyncExternalStoreWithSelector=function(h,f,p,g,x){var b=o(null);if(b.current===null){var k={hasValue:!1,value:null};b.current=k}else k=b.current;b=u(function(){function N(P){if(!C){if(C=!0,S=P,P=g(P),x!==void 0&&k.hasValue){var H=k.value;if(x(H,P))return _=H}return _=P}if(H=_,i(S,P))return H;var B=g(P);return x!==void 0&&x(H,B)?(S=P,H):(S=P,_=B)}var C=!1,S,_,z=p===void 0?null:p;return[function(){return N(f())},z===null?void 0:function(){return N(z())}]},[f,p,g,x]);var j=r(h,b[0],b[1]);return l(function(){k.hasValue=!0,k.value=j},[j]),d(j),j},Jf}var ij;function xB(){return ij||(ij=1,Qf.exports=gB()),Qf.exports}var vB=xB();const yB=_g(vB),bB={},rj=e=>{let t;const s=new Set,i=(f,p)=>{const g=typeof f=="function"?f(t):f;if(!Object.is(g,t)){const x=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),s.forEach(b=>b(t,x))}},r=()=>t,d={setState:i,getState:r,getInitialState:()=>h,subscribe:f=>(s.add(f),()=>s.delete(f)),destroy:()=>{(bB?"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},kB=e=>e?rj(e):rj,{useDebugValue:jB}=G2,{useSyncExternalStoreWithSelector:NB}=yB,wB=e=>e;function o_(e,t=wB,s){const i=NB(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,s);return jB(i),i}const aj=(e,t)=>{const s=kB(e),i=(r,o=t)=>o_(s,r,o);return Object.assign(i,s),i},SB=(e,t)=>e?aj(e,t):aj;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 vh=v.createContext(null),_B=vh.Provider,l_=Ai.error001("react");function At(e,t){const s=v.useContext(vh);if(s===null)throw new Error(l_);return o_(s,e,t)}function Xt(){const e=v.useContext(vh);if(e===null)throw new Error(l_);return v.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const oj={display:"none"},EB={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},c_="react-flow__node-desc",u_="react-flow__edge-desc",CB="react-flow__aria-live",AB=e=>e.ariaLiveMessage,$B=e=>e.ariaLabelConfig;function IB({rfId:e}){const t=At(AB);return n.jsx("div",{id:`${CB}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:EB,children:t})}function TB({rfId:e,disableKeyboardA11y:t}){const s=At($B);return n.jsxs(n.Fragment,{children:[n.jsx("div",{id:`${c_}-${e}`,style:oj,children:t?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),n.jsx("div",{id:`${u_}-${e}`,style:oj,children:s["edge.a11yDescription.default"]}),!t&&n.jsx(IB,{rfId:e})]})}const yh=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})});yh.displayName="Panel";const lj="https://reactflow.dev?utm_source=attribution";function MB({proOptions:e,position:t="bottom-right"}){return v.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:n.jsx(yh,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${lj}`,children:n.jsx("a",{href:lj,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const RB=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}},cd=e=>e.id;function OB(e,t){return un(e.selectedNodes.map(cd),t.selectedNodes.map(cd))&&un(e.selectedEdges.map(cd),t.selectedEdges.map(cd))}function PB({onSelectionChange:e}){const t=Xt(),{selectedNodes:s,selectedEdges:i}=At(RB,OB);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 LB=e=>!!e.onSelectionChangeHandlers;function zB({onSelectionChange:e}){const t=At(LB);return e||t?n.jsx(PB,{onSelectionChange:e}):null}const d_=[0,0],DB={x:0,y:0,zoom:1},FB=["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"],cj=[...FB,"rfId"],UB=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}),uj={translateExtent:Ec,nodeOrigin:d_,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function BB(e){const{setNodes:t,setEdges:s,setMinZoom:i,setMaxZoom:r,setTranslateExtent:o,setNodeExtent:l,reset:u,setDefaultNodesAndEdges:d}=At(UB,un),h=Xt();v.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{f.current=uj,u()}),[]);const f=v.useRef(uj);return v.useEffect(()=>{for(const p of cj){const g=e[p],x=f.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:_U(g)}):p==="fitView"?h.setState({fitViewQueued:g}):p==="fitViewOptions"?h.setState({fitViewOptions:g}):h.setState({[p]:g})))}f.current=e},cj.map(p=>e[p])),null}function dj(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function HB(e){var i;const[t,s]=v.useState(e==="system"?null:e);return v.useEffect(()=>{if(e!=="system"){s(e);return}const r=dj(),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=dj())!=null&&i.matches?"dark":"light"}const hj=typeof document<"u"?document:null;function Ic(e=null,t={target:hj,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,`
227
+ `).replace(`
228
+
229
+ `,`
230
+ +`).split(`
231
+ `)),f=h.reduce((p,g)=>p.concat(...g),[]);return[h,f]}return[[],[]]},[e]);return v.useEffect(()=>{const d=(t==null?void 0:t.target)??hj,h=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=x=>{var j,N;if(r.current=x.ctrlKey||x.metaKey||x.shiftKey||x.altKey,(!r.current||r.current&&!h)&&Z1(x))return!1;const k=fj(x.code,u);if(o.current.add(x[k]),mj(l,o.current,!1)){const C=((N=(j=x.composedPath)==null?void 0:j.call(x))==null?void 0:N[0])||x.target,S=(C==null?void 0:C.nodeName)==="BUTTON"||(C==null?void 0:C.nodeName)==="A";t.preventDefault!==!1&&(r.current||!S)&&x.preventDefault(),i(!0)}},p=x=>{const b=fj(x.code,u);mj(l,o.current,!0)?(i(!1),o.current.clear()):o.current.delete(x[b]),x.key==="Meta"&&o.current.clear(),r.current=!1},g=()=>{o.current.clear(),i(!1)};return d==null||d.addEventListener("keydown",f),d==null||d.addEventListener("keyup",p),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{d==null||d.removeEventListener("keydown",f),d==null||d.removeEventListener("keyup",p),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,i]),s}function mj(e,t,s){return e.filter(i=>s||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function fj(e,t){return t.includes(e)?"code":"key"}const ZB=()=>{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=$x(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},f=s.snapGrid??r,p=s.snapToGrid??o;return qc(h,i,p,f)},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 h_(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)WB(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 WB(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 VB(e,t){return h_(e,t)}function qB(e,t){return h_(e,t)}function wa(e,t){return{id:e,type:"select",selected:t}}function Io(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(wa(o.id,l)))}return i}function pj({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 gj(e){return{id:e.id,type:"remove"}}const GB=D1();function KB(e,t,s={}){return TU(e,t,{...s,onError:s.onError??GB})}const xj=e=>xU(e),YB=e=>R1(e);function m_(e){return v.forwardRef(e)}const f_=typeof window<"u"?v.useLayoutEffect:v.useEffect;function vj(e){const[t,s]=v.useState(BigInt(0)),[i]=v.useState(()=>XB(()=>s(r=>r+BigInt(1))));return f_(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function XB(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:s=>{t.push(s),e()}}}const p_=v.createContext(null);function QB({children:e}){const t=Xt(),s=v.useCallback(u=>{const{nodes:d=[],setNodes:h,hasDefaultNodes:f,onNodesChange:p,nodeLookup:g,fitViewQueued:x,onNodesChangeMiddlewareMap:b}=t.getState();let k=d;for(const N of u)k=typeof N=="function"?N(k):N;let j=pj({items:k,lookup:g});for(const N of b.values())j=N(j);f&&h(k),j.length>0?p==null||p(j):x&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:C,setNodes:S}=t.getState();N&&S(C)})},[]),i=vj(s),r=v.useCallback(u=>{const{edges:d=[],setEdges:h,hasDefaultEdges:f,onEdgesChange:p,edgeLookup:g}=t.getState();let x=d;for(const b of u)x=typeof b=="function"?b(x):b;f?h(x):p&&p(pj({items:x,lookup:g}))},[]),o=vj(r),l=v.useMemo(()=>({nodeQueue:i,edgeQueue:o}),[]);return n.jsx(p_.Provider,{value:l,children:e})}function JB(){const e=v.useContext(p_);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const eH=e=>!!e.panZoom;function Lx(){const e=ZB(),t=Xt(),s=JB(),i=At(eH),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 N,C;const{nodeLookup:g,nodeOrigin:x}=t.getState(),b=xj(p)?p:g.get(p.id),k=b.parentId?U1(b.position,b.measured,b.parentId,g,x):b.position,j={...b,position:k,width:((N=b.measured)==null?void 0:N.width)??b.width,height:((C=b.measured)==null?void 0:C.height)??b.height};return Ac(j)},h=(p,g,x={replace:!1})=>{l(b=>b.map(k=>{if(k.id===p){const j=typeof g=="function"?g(k):g;return x.replace&&xj(j)?j:{...k,...j}}return k}))},f=(p,g,x={replace:!1})=>{u(b=>b.map(k=>{if(k.id===p){const j=typeof g=="function"?g(k):g;return x.replace&&YB(j)?j:{...k,...j}}return k}))};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(),[b,k,j]=x;return{nodes:p.map(N=>({...N})),edges:g.map(N=>({...N})),viewport:{x:b,y:k,zoom:j}}},deleteElements:async({nodes:p=[],edges:g=[]})=>{const{nodes:x,edges:b,onNodesDelete:k,onEdgesDelete:j,triggerNodeChanges:N,triggerEdgeChanges:C,onDelete:S,onBeforeDelete:_}=t.getState(),{nodes:z,edges:P}=await jU({nodesToRemove:p,edgesToRemove:g,nodes:x,edges:b,onBeforeDelete:_}),H=P.length>0,B=z.length>0;if(H){const O=P.map(gj);j==null||j(P),C(O)}if(B){const O=z.map(gj);k==null||k(z),N(O)}return(B||H)&&(S==null||S({nodes:z,edges:P})),{deletedNodes:z,deletedEdges:P}},getIntersectingNodes:(p,g=!0,x)=>{const b=Bk(p),k=b?p:d(p),j=x!==void 0;return k?(x||t.getState().nodes).filter(N=>{const C=t.getState().nodeLookup.get(N.id);if(C&&!b&&(N.id===p.id||!C.internals.positionAbsolute))return!1;const S=Ac(j?N:C),_=Vd(S,k);return g&&_>0||_>=S.width*S.height||_>=k.width*k.height}):[]},isNodeIntersecting:(p,g,x=!0)=>{const k=Bk(p)?p:d(p);if(!k)return!1;const j=Vd(k,g);return x&&j>0||j>=g.width*g.height||j>=k.width*k.height},updateNode:h,updateNodeData:(p,g,x={replace:!1})=>{h(p,b=>{const k=typeof g=="function"?g(b):g;return x.replace?{...b,data:k}:{...b,data:{...b.data,...k}}},x)},updateEdge:f,updateEdgeData:(p,g,x={replace:!1})=>{f(p,b=>{const k=typeof g=="function"?g(b):g;return x.replace?{...b,data:k}:{...b,data:{...b.data,...k}}},x)},getNodesBounds:p=>{const{nodeLookup:g,nodeOrigin:x}=t.getState();return vU(p,{nodeLookup:g,nodeOrigin:x})},getHandleConnections:({type:p,id:g,nodeId:x})=>{var b;return Array.from(((b=t.getState().connectionLookup.get(`${x}-${p}${g?`-${g}`:""}`))==null?void 0:b.values())??[])},getNodeConnections:({type:p,handleId:g,nodeId:x})=>{var b;return Array.from(((b=t.getState().connectionLookup.get(`${x}${p?g?`-${p}-${g}`:`-${p}`:""}`))==null?void 0:b.values())??[])},fitView:async p=>{const g=t.getState().fitViewResolver??SU();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 yj=e=>e.selected,tH=typeof window<"u"?window:void 0;function nH({deleteKeyCode:e,multiSelectionKeyCode:t}){const s=Xt(),{deleteElements:i}=Lx(),r=Ic(e,{actInsideInputWithModifier:!1}),o=Ic(t,{target:tH});v.useEffect(()=>{if(r){const{edges:l,nodes:u}=s.getState();i({nodes:u.filter(yj),edges:l.filter(yj)}),s.setState({nodesSelectionActive:!1})}},[r]),v.useEffect(()=>{s.setState({multiSelectionActive:o})},[o])}function sH(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=Ix(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 bh={position:"absolute",width:"100%",height:"100%",top:0,left:0},iH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function rH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panActivationKeyPressed:r,panOnScrollSpeed:o=.5,panOnScrollMode:l=La.Free,zoomOnDoubleClick:u=!0,panOnDrag:d=!0,defaultViewport:h,translateExtent:f,minZoom:p,maxZoom:g,zoomActivationKeyCode:x,preventScrolling:b=!0,children:k,noWheelClassName:j,noPanClassName:N,onViewportChange:C,isControlledViewport:S,paneClickDistance:_,selectionOnDrag:z}){const P=Xt(),H=v.useRef(null),{userSelectionActive:B,lib:O,connectionInProgress:T}=At(iH,un),D=Ic(x),U=v.useRef();sH(H);const A=v.useCallback(I=>{C==null||C({x:I[0],y:I[1],zoom:I[2]}),S||P.setState({transform:I})},[C,S]);return v.useEffect(()=>{if(H.current){U.current=lB({domNode:H.current,minZoom:p,maxZoom:g,translateExtent:f,viewport:h,onDraggingChange:K=>P.setState(F=>F.paneDragging===K?F:{paneDragging:K}),onPanZoomStart:(K,F)=>{const{onViewportChangeStart:q,onMoveStart:V}=P.getState();V==null||V(K,F),q==null||q(F)},onPanZoom:(K,F)=>{const{onViewportChange:q,onMove:V}=P.getState();V==null||V(K,F),q==null||q(F)},onPanZoomEnd:(K,F)=>{const{onViewportChangeEnd:q,onMoveEnd:V}=P.getState();V==null||V(K,F),q==null||q(F)}});const{x:I,y:R,zoom:L}=U.current.getViewport();return P.setState({panZoom:U.current,transform:[I,R,L],domNode:H.current.closest(".react-flow")}),()=>{var K;(K=U.current)==null||K.destroy()}}},[]),v.useEffect(()=>{var I;(I=U.current)==null||I.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:s,panOnScroll:i,panActivationKeyPressed:r,panOnScrollSpeed:o,panOnScrollMode:l,zoomOnDoubleClick:u,panOnDrag:d,zoomActivationKeyPressed:D,preventScrolling:b,noPanClassName:N,userSelectionActive:B,noWheelClassName:j,lib:O,onTransformChange:A,connectionInProgress:T,selectionOnDrag:z,paneClickDistance:_})},[e,t,s,i,r,o,l,u,d,D,b,N,B,j,O,A,T,z,_]),n.jsx("div",{className:"react-flow__renderer",ref:H,style:bh,children:k})}const aH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function oH(){const{userSelectionActive:e,userSelectionRect:t}=At(aH,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 np=(e,t)=>s=>{s.target===t.current&&(e==null||e(s))},lH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function cH({isSelecting:e,selectionKeyPressed:t,selectionMode:s=Cc.Full,panOnDrag:i,autoPanOnSelection:r,paneClickDistance:o,selectionOnDrag:l,onSelectionStart:u,onSelectionEnd:d,onPaneClick:h,onPaneContextMenu:f,onPaneScroll:p,onPaneMouseEnter:g,onPaneMouseMove:x,onPaneMouseLeave:b,children:k}){const j=v.useRef(0),N=Xt(),{userSelectionActive:C,elementsSelectable:S,dragging:_,panBy:z,autoPanSpeed:P}=At(lH,un),H=S&&(e||C),B=v.useRef(null),O=v.useRef(),T=v.useRef(new Set),D=v.useRef(new Set),U=v.useRef(!1),A=v.useRef(!1),I=v.useRef({x:0,y:0}),R=v.useRef(!1),L=se=>{if(A.current||U.current||N.getState().connection.inProgress){A.current=!1,U.current=!1;return}h==null||h(se),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},K=se=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){se.preventDefault();return}f==null||f(se)},F=p?se=>p(se):void 0,q=se=>{A.current&&(se.stopPropagation(),A.current=!1)},V=se=>{var Qe,Ke;if(se.pointerType==="touch"&&i!==!1&&!t)return;const{domNode:ae,transform:_e}=N.getState();if(O.current=ae==null?void 0:ae.getBoundingClientRect(),!O.current)return;const ze=se.target===B.current;if(!ze&&!!se.target.closest(".nokey")||!e||!(l&&ze||t)||se.button!==0||!se.isPrimary)return;(Ke=(Qe=se.target)==null?void 0:Qe.setPointerCapture)==null||Ke.call(Qe,se.pointerId),A.current=!1;const{x:ye,y:Fe}=Ei(se.nativeEvent,O.current),Re=qc({x:ye,y:Fe},_e);N.setState({userSelectionRect:{width:0,height:0,startX:Re.x,startY:Re.y,x:ye,y:Fe}}),ze||(se.stopPropagation(),se.preventDefault())};function Z(se,ae){const{userSelectionRect:_e}=N.getState();if(!_e)return;const{transform:ze,nodeLookup:Te,edgeLookup:fe,connectionLookup:ye,triggerNodeChanges:Fe,triggerEdgeChanges:Re,defaultEdgeOptions:Qe}=N.getState(),Ke={x:_e.startX,y:_e.startY},{x:_t,y:xt}=el(Ke,ze),Mt={startX:Ke.x,startY:Ke.y,x:se<_t?se:_t,y:ae<xt?ae:xt,width:Math.abs(se-_t),height:Math.abs(ae-xt)},En=T.current,rt=D.current;T.current=new Set(Cx(Te,Mt,ze,s===Cc.Partial,!0).map(rn=>rn.id)),D.current=new Set;const Pt=(Qe==null?void 0:Qe.selectable)??!0;for(const rn of T.current){const Zt=ye.get(rn);if(Zt)for(const{edgeId:Qt}of Zt.values()){const Ut=fe.get(Qt);Ut&&(Ut.selectable??Pt)&&D.current.add(Qt)}}if(!Hk(En,T.current)){const rn=Io(Te,T.current,!0);Fe(rn)}if(!Hk(rt,D.current)){const rn=Io(fe,D.current);Re(rn)}N.setState({userSelectionRect:Mt,userSelectionActive:!0,nodesSelectionActive:!1})}function Q(){if(!r||!O.current)return;const[se,ae]=Ax(I.current,O.current,P);z({x:se,y:ae}).then(_e=>{if(!A.current||!_e){j.current=requestAnimationFrame(Q);return}const{x:ze,y:Te}=I.current;Z(ze,Te),j.current=requestAnimationFrame(Q)})}const G=()=>{cancelAnimationFrame(j.current),j.current=0,R.current=!1};v.useEffect(()=>()=>G(),[]);const ne=se=>{const{userSelectionRect:ae,transform:_e,resetSelectedElements:ze}=N.getState();if(!O.current||!ae)return;const{x:Te,y:fe}=Ei(se.nativeEvent,O.current);I.current={x:Te,y:fe};const ye=el({x:ae.startX,y:ae.startY},_e);if(!A.current){const Fe=t?0:o;if(Math.hypot(Te-ye.x,fe-ye.y)<=Fe)return;ze(),u==null||u(se)}A.current=!0,R.current||(Q(),R.current=!0),Z(Te,fe)},te=se=>{var ae,_e;if(!H){se.target===B.current&&N.getState().connection.inProgress&&(U.current=!0);return}se.button===0&&((_e=(ae=se.target)==null?void 0:ae.releasePointerCapture)==null||_e.call(ae,se.pointerId),!C&&se.target===B.current&&N.getState().userSelectionRect&&(L==null||L(se)),N.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(d==null||d(se),N.setState({nodesSelectionActive:T.current.size>0})),G())},re=se=>{var ae,_e;(_e=(ae=se.target)==null?void 0:ae.releasePointerCapture)==null||_e.call(ae,se.pointerId),G()},X=i===!0||Array.isArray(i)&&i.includes(0);return n.jsxs("div",{className:_n(["react-flow__pane",{draggable:X,dragging:_,selection:e}]),onClick:H?void 0:np(L,B),onContextMenu:np(K,B),onWheel:np(F,B),onPointerEnter:H?void 0:g,onPointerMove:H?ne:x,onPointerUp:te,onPointerCancel:H?re:void 0,onPointerDownCapture:H?V:void 0,onClickCapture:H?q:void 0,onPointerLeave:b,ref:B,style:bh,children:[k,n.jsx(oH,{})]})}function pg({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 f;return(f=i==null?void 0:i.current)==null?void 0:f.blur()})):r([e])}function g_({nodeRef:e,disabled:t=!1,noDragClassName:s,handleSelector:i,nodeId:r,isSelectable:o,nodeClickDistance:l}){const u=Xt(),[d,h]=v.useState(!1),f=v.useRef();return v.useEffect(()=>{if(!t)return f.current=GU({getStoreItems:()=>u.getState(),onNodeMouseDown:p=>{pg({id:p,store:u,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}}),()=>{var p;(p=f.current)==null||p.destroy(),f.current=void 0}},[t,u,e]),v.useEffect(()=>{t||!e.current||!f.current||f.current.update({noDragClassName:s,handleSelector:i,domNode:e.current,isSelectable:o,nodeId:r,nodeClickDistance:l})},[s,i,t,o,e,r,l]),d}const uH=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function x_(){const e=Xt();return v.useCallback(s=>{const{nodeExtent:i,snapToGrid:r,snapGrid:o,nodesDraggable:l,onError:u,updateNodePositions:d,nodeLookup:h,nodeOrigin:f}=e.getState(),p=new Map,g=uH(l),x=r?o[0]:5,b=r?o[1]:5,k=s.direction.x*x*s.factor,j=s.direction.y*b*s.factor;for(const[,N]of h){if(!g(N))continue;let C={x:N.internals.positionAbsolute.x+k,y:N.internals.positionAbsolute.y+j};r&&(C=Vc(C,o));const{position:S,positionAbsolute:_}=O1({nodeId:N.id,nextPosition:C,nodeLookup:h,nodeExtent:i,nodeOrigin:f,onError:u});N.position=S,N.internals.positionAbsolute=_,p.set(N.id,N)}d(p)},[])}const zx=v.createContext(null),dH=zx.Provider;zx.Consumer;const v_=()=>v.useContext(zx),hH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),y_=v.createContext(null);function mH({children:e}){const t=At(hH,un);return n.jsx(y_.Provider,{value:t,children:e})}function fH(){const e=v.useContext(y_);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const pH={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},gH=(e,t,s)=>i=>{const{connectionClickStartHandle:r,connectionMode:o,connection:l}=i,{fromHandle:u,toHandle:d,isValid:h}=l;if(!u&&!r)return pH;const f=(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:f,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:f&&h}};function xH({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:f,onTouchStart:p,...g},x){var R,L;const b=l||null,k=e==="target",j=Xt(),N=v_(),{connectOnClick:C,noPanClassName:S,rfId:_}=fH(),{connectingFrom:z,connectingTo:P,clickConnecting:H,isPossibleEndHandle:B,connectionInProcess:O,clickConnectionInProcess:T,valid:D}=At(gH(N,b,e),un);N||(L=(R=j.getState()).onError)==null||L.call(R,"010",Ai.error010());const U=K=>{const{defaultEdgeOptions:F,onConnect:q,hasDefaultEdges:V}=j.getState(),Z={...F,...K};if(V){const{edges:Q,setEdges:G,onError:ne}=j.getState();G(KB(Z,Q,{onError:ne}))}q==null||q(Z),u==null||u(Z)},A=K=>{if(!N)return;const F=W1(K.nativeEvent);if(r&&(F&&K.button===0||!F)){const q=j.getState();fg.onPointerDown(K.nativeEvent,{handleDomNode:K.currentTarget,autoPanOnConnect:q.autoPanOnConnect,connectionMode:q.connectionMode,connectionRadius:q.connectionRadius,domNode:q.domNode,nodeLookup:q.nodeLookup,lib:q.lib,isTarget:k,handleId:b,nodeId:N,flowId:q.rfId,panBy:q.panBy,cancelConnection:q.cancelConnection,onConnectStart:q.onConnectStart,onConnectEnd:(...V)=>{var Z,Q;return(Q=(Z=j.getState()).onConnectEnd)==null?void 0:Q.call(Z,...V)},updateConnection:q.updateConnection,onConnect:U,isValidConnection:s||((...V)=>{var Z,Q;return((Q=(Z=j.getState()).isValidConnection)==null?void 0:Q.call(Z,...V))??!0}),getTransform:()=>j.getState().transform,getFromHandle:()=>j.getState().connection.fromHandle,autoPanSpeed:q.autoPanSpeed,dragThreshold:q.connectionDragThreshold})}F?f==null||f(K):p==null||p(K)},I=K=>{const{onClickConnectStart:F,onClickConnectEnd:q,connectionClickStartHandle:V,connectionMode:Z,isValidConnection:Q,lib:G,rfId:ne,nodeLookup:te,connection:re}=j.getState();if(!N||!V&&!r)return;if(!V){F==null||F(K.nativeEvent,{nodeId:N,handleId:b,handleType:e}),j.setState({connectionClickStartHandle:{nodeId:N,type:e,id:b}});return}const X=H1(K.target),se=s||Q,{connection:ae,isValid:_e}=fg.isValid(K.nativeEvent,{handle:{nodeId:N,id:b,type:e},connectionMode:Z,fromNodeId:V.nodeId,fromHandleId:V.id||null,fromType:V.type,isValidConnection:se,flowId:ne,doc:X,lib:G,nodeLookup:te});_e&&ae&&U(ae);const ze=structuredClone(re);delete ze.inProgress,ze.toPosition=ze.toHandle?ze.toHandle.position:null,q==null||q(K,ze),j.setState({connectionClickStartHandle:null})};return n.jsx("div",{"data-handleid":b,"data-nodeid":N,"data-handlepos":t,"data-id":`${_}-${N}-${b}-${e}`,className:_n(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,h,{source:!k,target:k,connectable:i,connectablestart:r,connectableend:o,clickconnecting:H,connectingfrom:z,connectingto:P,valid:D,connectionindicator:i&&(!O||B)&&(O||T?o:r)}]),onMouseDown:A,onTouchStart:A,onClick:C?I:void 0,ref:x,...g,children:d})}const Jr=v.memo(m_(xH));function vH({data:e,isConnectable:t,sourcePosition:s=tt.Bottom}){return n.jsxs(n.Fragment,{children:[e==null?void 0:e.label,n.jsx(Jr,{type:"source",position:s,isConnectable:t})]})}function yH({data:e,isConnectable:t,targetPosition:s=tt.Top,sourcePosition:i=tt.Bottom}){return n.jsxs(n.Fragment,{children:[n.jsx(Jr,{type:"target",position:s,isConnectable:t}),e==null?void 0:e.label,n.jsx(Jr,{type:"source",position:i,isConnectable:t})]})}function bH(){return null}function kH({data:e,isConnectable:t,targetPosition:s=tt.Top}){return n.jsxs(n.Fragment,{children:[n.jsx(Jr,{type:"target",position:s,isConnectable:t}),e==null?void 0:e.label]})}const qd={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},bj={input:vH,default:yH,output:kH,group:bH};function jH(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 NH=e=>{const{width:t,height:s,x:i,y:r}=Wc(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 wH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:s}){const i=Xt(),{width:r,height:o,transformString:l,userSelectionActive:u}=At(NH,un),d=x_(),h=v.useRef(null);v.useEffect(()=>{var x;s||(x=h.current)==null||x.focus({preventScroll:!0})},[s]);const f=!u&&r!==null&&o!==null;if(g_({nodeRef:h,disabled:!f}),!f)return null;const p=e?x=>{const b=i.getState().nodes.filter(k=>k.selected);e(x,b)}:void 0,g=x=>{Object.prototype.hasOwnProperty.call(qd,x.key)&&(x.preventDefault(),d({direction:qd[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 kj=typeof window<"u"?window:void 0,SH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function b_({children:e,onPaneClick:t,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:l,paneClickDistance:u,deleteKeyCode:d,selectionKeyCode:h,selectionOnDrag:f,selectionMode:p,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:b,panActivationKeyCode:k,zoomActivationKeyCode:j,elementsSelectable:N,zoomOnScroll:C,zoomOnPinch:S,panOnScroll:_,panOnScrollSpeed:z,panOnScrollMode:P,zoomOnDoubleClick:H,panOnDrag:B,autoPanOnSelection:O,defaultViewport:T,translateExtent:D,minZoom:U,maxZoom:A,preventScrolling:I,onSelectionContextMenu:R,noWheelClassName:L,noPanClassName:K,disableKeyboardA11y:F,onViewportChange:q,isControlledViewport:V}){const{nodesSelectionActive:Z,userSelectionActive:Q}=At(SH,un),G=Ic(h,{target:kj}),ne=Ic(k,{target:kj}),te=ne||B,re=ne||_,X=f&&te!==!0,se=G||Q||X;return nH({deleteKeyCode:d,multiSelectionKeyCode:b}),n.jsx(rH,{onPaneContextMenu:o,elementsSelectable:N,zoomOnScroll:C,zoomOnPinch:S,panOnScroll:re,panActivationKeyPressed:ne,panOnScrollSpeed:z,panOnScrollMode:P,zoomOnDoubleClick:H,panOnDrag:!G&&te,defaultViewport:T,translateExtent:D,minZoom:U,maxZoom:A,zoomActivationKeyCode:j,preventScrolling:I,noWheelClassName:L,noPanClassName:K,onViewportChange:q,isControlledViewport:V,paneClickDistance:u,selectionOnDrag:X,children:n.jsxs(cH,{onSelectionStart:g,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:l,panOnDrag:te,autoPanOnSelection:O,isSelecting:!!se,selectionMode:p,selectionKeyPressed:G,paneClickDistance:u,selectionOnDrag:X,children:[e,Z&&n.jsx(wH,{onSelectionContextMenu:R,noPanClassName:K,disableKeyboardA11y:F})]})})}b_.displayName="FlowRenderer";const _H=v.memo(b_),EH=e=>t=>e?Cx(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 CH(e){return At(v.useCallback(EH(e),[e]),un)}const AH=e=>e.updateNodeInternals;function $H(){const e=At(AH),[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 IH({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),f=s&&!!e.internals.handleBounds;return v.useEffect(()=>{o.current&&!e.hidden&&(!f||l.current!==o.current)&&(l.current&&(i==null||i.unobserve(l.current)),i==null||i.observe(o.current),l.current=o.current)},[f,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 TH({id:e,onClick:t,onMouseEnter:s,onMouseMove:i,onMouseLeave:r,onContextMenu:o,onDoubleClick:l,nodesDraggable:u,elementsSelectable:d,nodesConnectable:h,nodesFocusable:f,resizeObserver:p,noDragClassName:g,noPanClassName:x,disableKeyboardA11y:b,rfId:k,nodeTypes:j,nodeClickDistance:N,onError:C}){const{node:S,internals:_,isParent:z}=At(se=>{const ae=se.nodeLookup.get(e),_e=se.parentLookup.has(e);return{node:ae,internals:ae.internals,isParent:_e}},un);let P=S.type||"default",H=(j==null?void 0:j[P])||bj[P];H===void 0&&(C==null||C("003",Ai.error003(P)),P="default",H=(j==null?void 0:j.default)||bj.default);const B=!!(S.draggable||u&&typeof S.draggable>"u"),O=!!(S.selectable||d&&typeof S.selectable>"u"),T=!!(S.connectable||h&&typeof S.connectable>"u"),D=!!(S.focusable||f&&typeof S.focusable>"u"),U=Xt(),A=F1(S),I=IH({node:S,nodeType:P,hasDimensions:A,resizeObserver:p}),R=g_({nodeRef:I,disabled:S.hidden||!B,noDragClassName:g,handleSelector:S.dragHandle,nodeId:e,isSelectable:O,nodeClickDistance:N}),L=x_();if(S.hidden)return null;const K=Ii(S),F=jH(S),q=O||B||t||s||i||r,V=s?se=>s(se,{..._.userNode}):void 0,Z=i?se=>i(se,{..._.userNode}):void 0,Q=r?se=>r(se,{..._.userNode}):void 0,G=o?se=>o(se,{..._.userNode}):void 0,ne=l?se=>l(se,{..._.userNode}):void 0,te=se=>{const{selectNodesOnDrag:ae,nodeDragThreshold:_e}=U.getState();O&&(!ae||!B||_e>0)&&pg({id:e,store:U,nodeRef:I}),t&&t(se,{..._.userNode})},re=se=>{if(!(Z1(se.nativeEvent)||b)){if(I1.includes(se.key)&&O){const ae=se.key==="Escape";pg({id:e,store:U,unselect:ae,nodeRef:I})}else if(B&&S.selected&&Object.prototype.hasOwnProperty.call(qd,se.key)){se.preventDefault();const{ariaLabelConfig:ae}=U.getState();U.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:se.key.replace("Arrow","").toLowerCase(),x:~~_.positionAbsolute.x,y:~~_.positionAbsolute.y})}),L({direction:qd[se.key],factor:se.shiftKey?4:1})}}},X=()=>{var ye;if(b||!((ye=I.current)!=null&&ye.matches(":focus-visible")))return;const{transform:se,width:ae,height:_e,autoPanOnNodeFocus:ze,setCenter:Te}=U.getState();if(!ze)return;Cx(new Map([[e,S]]),{x:0,y:0,width:ae,height:_e},se,!0).length>0||Te(S.position.x+K.width/2,S.position.y+K.height/2,{zoom:se[2]})};return n.jsx("div",{className:_n(["react-flow__node",`react-flow__node-${P}`,{[x]:B},S.className,{selected:S.selected,selectable:O,parent:z,draggable:B,dragging:R}]),ref:I,style:{zIndex:_.z,transform:`translate(${_.positionAbsolute.x}px,${_.positionAbsolute.y}px)`,pointerEvents:q?"all":"none",visibility:A?"visible":"hidden",...S.style,...F},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:V,onMouseMove:Z,onMouseLeave:Q,onContextMenu:G,onClick:te,onDoubleClick:ne,onKeyDown:D?re:void 0,tabIndex:D?0:void 0,onFocus:D?X:void 0,role:S.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":b?void 0:`${c_}-${k}`,"aria-label":S.ariaLabel,...S.domAttributes,children:n.jsx(dH,{value:e,children:n.jsx(H,{id:e,data:S.data,type:P,positionAbsoluteX:_.positionAbsolute.x,positionAbsoluteY:_.positionAbsolute.y,selected:S.selected??!1,selectable:O,draggable:B,deletable:S.deletable??!0,isConnectable:T,sourcePosition:S.sourcePosition,targetPosition:S.targetPosition,dragging:R,dragHandle:S.dragHandle,zIndex:_.z,parentId:S.parentId,...K})})})}var MH=v.memo(TH);const RH=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function k_(e){const{nodesConnectable:t,nodesFocusable:s,elementsSelectable:i,onError:r}=At(RH,un),o=CH(e.onlyRenderVisibleElements),l=$H();return n.jsx("div",{className:"react-flow__nodes",style:bh,children:o.map(u=>n.jsx(MH,{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))})}k_.displayName="NodeRenderer";const OH=v.memo(k_);function PH(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&&AU({sourceNode:o,targetNode:l,width:s.width,height:s.height,transform:s.transform})&&i.push(r.id)}return i},[e]),un)}const LH=({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"})},zH=({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"})},jj={[Zd.Arrow]:LH,[Zd.ArrowClosed]:zH};function DH(e){const t=Xt();return v.useMemo(()=>{var r,o;return Object.prototype.hasOwnProperty.call(jj,e)?jj[e]:((o=(r=t.getState()).onError)==null||o.call(r,"009",Ai.error009(e)),null)},[e])}const FH=({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=DH(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},j_=({defaultColor:e,rfId:t})=>{const s=At(o=>o.edges),i=At(o=>o.defaultEdgeOptions),r=v.useMemo(()=>LU(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(FH,{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};j_.displayName="MarkerDefinitions";var UH=v.memo(j_);function N_({x:e,y:t,label:s,labelStyle:i,labelShowBg:r=!0,labelBgStyle:o,labelBgPadding:l=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...f}){const[p,g]=v.useState({x:1,y:0,width:0,height:0}),x=_n(["react-flow__edge-textwrapper",h]),b=v.useRef(null);return v.useEffect(()=>{if(b.current){const k=b.current.getBBox();g({x:k.x,y:k.y,width:k.width,height:k.height})}},[s]),s?n.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:x,visibility:p.width?"visible":"hidden",...f,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:b,style:i,children:s}),d]}):null}N_.displayName="EdgeText";const BH=v.memo(N_);function kh({path:e,labelX:t,labelY:s,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,interactionWidth:h=20,...f}){return n.jsxs(n.Fragment,{children:[n.jsx("path",{...f,d:e,fill:"none",className:_n(["react-flow__edge-path",f.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(BH,{x:t,y:s,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d}):null]})}function Nj({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 w_({sourceX:e,sourceY:t,sourcePosition:s=tt.Bottom,targetX:i,targetY:r,targetPosition:o=tt.Top}){const[l,u]=Nj({pos:s,x1:e,y1:t,x2:i,y2:r}),[d,h]=Nj({pos:o,x1:i,y1:r,x2:e,y2:t}),[f,p,g,x]=V1({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}`,f,p,g,x]}function S_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,sourcePosition:l,targetPosition:u,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:b,markerEnd:k,markerStart:j,interactionWidth:N})=>{const[C,S,_]=w_({sourceX:s,sourceY:i,sourcePosition:l,targetX:r,targetY:o,targetPosition:u}),z=e.isInternal?void 0:t;return n.jsx(kh,{id:z,path:C,labelX:S,labelY:_,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:b,markerEnd:k,markerStart:j,interactionWidth:N})})}const HH=S_({isInternal:!1}),__=S_({isInternal:!0});HH.displayName="SimpleBezierEdge";__.displayName="SimpleBezierEdgeInternal";function E_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,sourcePosition:x=tt.Bottom,targetPosition:b=tt.Top,markerEnd:k,markerStart:j,pathOptions:N,interactionWidth:C})=>{const[S,_,z]=dg({sourceX:s,sourceY:i,sourcePosition:x,targetX:r,targetY:o,targetPosition:b,borderRadius:N==null?void 0:N.borderRadius,offset:N==null?void 0:N.offset,stepPosition:N==null?void 0:N.stepPosition}),P=e.isInternal?void 0:t;return n.jsx(kh,{id:P,path:S,labelX:_,labelY:z,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:k,markerStart:j,interactionWidth:C})})}const C_=E_({isInternal:!1}),A_=E_({isInternal:!0});C_.displayName="SmoothStepEdge";A_.displayName="SmoothStepEdgeInternal";function $_(e){return v.memo(({id:t,...s})=>{var r;const i=e.isInternal?void 0:t;return n.jsx(C_,{...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 ZH=$_({isInternal:!1}),I_=$_({isInternal:!0});ZH.displayName="StepEdge";I_.displayName="StepEdgeInternal";function T_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:x,markerStart:b,interactionWidth:k})=>{const[j,N,C]=K1({sourceX:s,sourceY:i,targetX:r,targetY:o}),S=e.isInternal?void 0:t;return n.jsx(kh,{id:S,path:j,labelX:N,labelY:C,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:x,markerStart:b,interactionWidth:k})})}const WH=T_({isInternal:!1}),M_=T_({isInternal:!0});WH.displayName="StraightEdge";M_.displayName="StraightEdgeInternal";function R_(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:f,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:b,markerEnd:k,markerStart:j,pathOptions:N,interactionWidth:C})=>{const[S,_,z]=q1({sourceX:s,sourceY:i,sourcePosition:l,targetX:r,targetY:o,targetPosition:u,curvature:N==null?void 0:N.curvature}),P=e.isInternal?void 0:t;return n.jsx(kh,{id:P,path:S,labelX:_,labelY:z,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:b,markerEnd:k,markerStart:j,interactionWidth:C})})}const VH=R_({isInternal:!1}),O_=R_({isInternal:!0});VH.displayName="BezierEdge";O_.displayName="BezierEdgeInternal";const wj={default:O_,straight:M_,step:I_,smoothstep:A_,simplebezier:__},Sj={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},qH=(e,t,s)=>s===tt.Left?e-t:s===tt.Right?e+t:e,GH=(e,t,s)=>s===tt.Top?e-t:s===tt.Bottom?e+t:e,_j="react-flow__edgeupdater";function Ej({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([_j,`${_j}-${u}`]),cx:qH(t,i,e),cy:GH(s,i,e),r:i,stroke:"transparent",fill:"transparent"})}function KH({isReconnectable:e,reconnectRadius:t,edge:s,sourceX:i,sourceY:r,targetX:o,targetY:l,sourcePosition:u,targetPosition:d,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,setReconnecting:g,setUpdateHover:x}){const b=Xt(),k=(_,z)=>{if(_.button!==0)return;const{autoPanOnConnect:P,domNode:H,connectionMode:B,connectionRadius:O,lib:T,onConnectStart:D,cancelConnection:U,nodeLookup:A,rfId:I,panBy:R,updateConnection:L}=b.getState(),K=z.type==="target",F=(Z,Q)=>{g(!1),p==null||p(Z,s,z.type,Q)},q=Z=>h==null?void 0:h(s,Z),V=(Z,Q)=>{g(!0),f==null||f(_,s,z.type),D==null||D(Z,Q)};fg.onPointerDown(_.nativeEvent,{autoPanOnConnect:P,connectionMode:B,connectionRadius:O,domNode:H,handleId:z.id,nodeId:z.nodeId,nodeLookup:A,isTarget:K,edgeUpdaterType:z.type,lib:T,flowId:I,cancelConnection:U,panBy:R,isValidConnection:(...Z)=>{var Q,G;return((G=(Q=b.getState()).isValidConnection)==null?void 0:G.call(Q,...Z))??!0},onConnect:q,onConnectStart:V,onConnectEnd:(...Z)=>{var Q,G;return(G=(Q=b.getState()).onConnectEnd)==null?void 0:G.call(Q,...Z)},onReconnectEnd:F,updateConnection:L,getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,dragThreshold:b.getState().connectionDragThreshold,handleDomNode:_.currentTarget})},j=_=>k(_,{nodeId:s.target,id:s.targetHandle??null,type:"target"}),N=_=>k(_,{nodeId:s.source,id:s.sourceHandle??null,type:"source"}),C=()=>x(!0),S=()=>x(!1);return n.jsxs(n.Fragment,{children:[(e===!0||e==="source")&&n.jsx(Ej,{position:u,centerX:i,centerY:r,radius:t,onMouseDown:j,onMouseEnter:C,onMouseOut:S,type:"source"}),(e===!0||e==="target")&&n.jsx(Ej,{position:d,centerX:o,centerY:l,radius:t,onMouseDown:N,onMouseEnter:C,onMouseOut:S,type:"target"})]})}function YH({id:e,edgesFocusable:t,edgesReconnectable:s,elementsSelectable:i,onClick:r,onDoubleClick:o,onContextMenu:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,reconnectRadius:f,onReconnect:p,onReconnectStart:g,onReconnectEnd:x,rfId:b,edgeTypes:k,noPanClassName:j,onError:N,disableKeyboardA11y:C}){let S=At(Te=>Te.edgeLookup.get(e));const _=At(Te=>Te.defaultEdgeOptions);S=_?{..._,...S}:S;let z=S.type||"default",P=(k==null?void 0:k[z])||wj[z];P===void 0&&(N==null||N("011",Ai.error011(z)),z="default",P=(k==null?void 0:k.default)||wj.default);const H=!!(S.focusable||t&&typeof S.focusable>"u"),B=typeof p<"u"&&(S.reconnectable||s&&typeof S.reconnectable>"u"),O=!!(S.selectable||i&&typeof S.selectable>"u"),T=v.useRef(null),[D,U]=v.useState(!1),[A,I]=v.useState(!1),R=Xt(),{zIndex:L=S.zIndex,sourceX:K,sourceY:F,targetX:q,targetY:V,sourcePosition:Z,targetPosition:Q}=At(v.useCallback(Te=>{const fe=Te.nodeLookup.get(S.source),ye=Te.nodeLookup.get(S.target);if(!fe||!ye)return Sj;const Fe=PU({id:e,sourceNode:fe,targetNode:ye,sourceHandle:S.sourceHandle||null,targetHandle:S.targetHandle||null,connectionMode:Te.connectionMode,onError:N}),Re=CU({selected:S.selected,zIndex:S.zIndex,sourceNode:fe,targetNode:ye,elevateOnSelect:Te.elevateEdgesOnSelect,zIndexMode:Te.zIndexMode});return{...Fe||Sj,zIndex:Re}},[S.source,S.target,S.sourceHandle,S.targetHandle,S.selected,S.zIndex,N]),un),G=v.useMemo(()=>S.markerStart?`url('#${hg(S.markerStart,b)}')`:void 0,[S.markerStart,b]),ne=v.useMemo(()=>S.markerEnd?`url('#${hg(S.markerEnd,b)}')`:void 0,[S.markerEnd,b]);if(S.hidden||K===null||F===null||q===null||V===null)return null;const te=Te=>{var Re;const{addSelectedEdges:fe,unselectNodesAndEdges:ye,multiSelectionActive:Fe}=R.getState();O&&(R.setState({nodesSelectionActive:!1}),S.selected&&Fe?(ye({nodes:[],edges:[S]}),(Re=T.current)==null||Re.blur()):fe([e])),r&&r(Te,S)},re=o?Te=>{o(Te,{...S})}:void 0,X=l?Te=>{l(Te,{...S})}:void 0,se=u?Te=>{u(Te,{...S})}:void 0,ae=d?Te=>{d(Te,{...S})}:void 0,_e=h?Te=>{h(Te,{...S})}:void 0,ze=Te=>{var fe;if(!C&&I1.includes(Te.key)&&O){const{unselectNodesAndEdges:ye,addSelectedEdges:Fe}=R.getState();Te.key==="Escape"?((fe=T.current)==null||fe.blur(),ye({edges:[S]})):Fe([e])}};return n.jsx("svg",{style:{zIndex:L},children:n.jsxs("g",{className:_n(["react-flow__edge",`react-flow__edge-${z}`,S.className,j,{selected:S.selected,animated:S.animated,inactive:!O&&!r,updating:D,selectable:O}]),onClick:te,onDoubleClick:re,onContextMenu:X,onMouseEnter:se,onMouseMove:ae,onMouseLeave:_e,onKeyDown:H?ze: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?`${u_}-${b}`:void 0,ref:T,...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:O,deletable:S.deletable??!0,label:S.label,labelStyle:S.labelStyle,labelShowBg:S.labelShowBg,labelBgStyle:S.labelBgStyle,labelBgPadding:S.labelBgPadding,labelBgBorderRadius:S.labelBgBorderRadius,sourceX:K,sourceY:F,targetX:q,targetY:V,sourcePosition:Z,targetPosition:Q,data:S.data,style:S.style,sourceHandleId:S.sourceHandle,targetHandleId:S.targetHandle,markerStart:G,markerEnd:ne,pathOptions:"pathOptions"in S?S.pathOptions:void 0,interactionWidth:S.interactionWidth}),B&&n.jsx(KH,{edge:S,isReconnectable:B,reconnectRadius:f,onReconnect:p,onReconnectStart:g,onReconnectEnd:x,sourceX:K,sourceY:F,targetX:q,targetY:V,sourcePosition:Z,targetPosition:Q,setUpdateHover:U,setReconnecting:I})]})})}var XH=v.memo(YH);const QH=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function P_({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:s,edgeTypes:i,noPanClassName:r,onReconnect:o,onEdgeContextMenu:l,onEdgeMouseEnter:u,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:f,reconnectRadius:p,onEdgeDoubleClick:g,onReconnectStart:x,onReconnectEnd:b,disableKeyboardA11y:k}){const{edgesFocusable:j,edgesReconnectable:N,elementsSelectable:C,onError:S}=At(QH,un),_=PH(t);return n.jsxs("div",{className:"react-flow__edges",children:[n.jsx(UH,{defaultColor:e,rfId:s}),_.map(z=>n.jsx(XH,{id:z,edgesFocusable:j,edgesReconnectable:N,elementsSelectable:C,noPanClassName:r,onReconnect:o,onContextMenu:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,onClick:f,reconnectRadius:p,onDoubleClick:g,onReconnectStart:x,onReconnectEnd:b,rfId:s,onError:S,edgeTypes:i,disableKeyboardA11y:k},z))]})}P_.displayName="EdgeRenderer";const JH=v.memo(P_),Cj=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function e9({children:e}){const t=Xt(),s=v.useRef(null),[i]=v.useState(()=>t.getState().transform);return f_(()=>{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=Cj(l)))};return o(),t.subscribe(o)},[t]),n.jsx("div",{ref:s,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Cj(i)},children:e})}function t9(e){const t=Lx(),s=v.useRef(!1);v.useEffect(()=>{!s.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),s.current=!0)},[e,t.viewportInitialized])}const n9=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function s9(e){const t=At(n9),s=Xt();return v.useEffect(()=>{e&&(t==null||t(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function i9(e){return e.connection.inProgress?{...e.connection,to:qc(e.connection.to,e.transform)}:{...e.connection}}function r9(e){return i9}function a9(e){const t=r9();return At(t,un)}const o9=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function l9({containerStyle:e,style:t,type:s,component:i}){const{nodesConnectable:r,width:o,height:l,isValid:u,inProgress:d}=At(o9,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",B1(u)]),children:n.jsx(L_,{style:t,type:s,CustomComponent:i,isValid:u})})})}const L_=({style:e,type:t=Vr.Bezier,CustomComponent:s,isValid:i})=>{const{inProgress:r,from:o,fromNode:l,fromHandle:u,fromPosition:d,to:h,toNode:f,toHandle:p,toPosition:g,pointer:x}=a9();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:B1(i),toNode:f,toHandle:p,pointer:x});let b="";const k={sourceX:o.x,sourceY:o.y,sourcePosition:d,targetX:h.x,targetY:h.y,targetPosition:g};switch(t){case Vr.Bezier:[b]=q1(k);break;case Vr.SimpleBezier:[b]=w_(k);break;case Vr.Step:[b]=dg({...k,borderRadius:0});break;case Vr.SmoothStep:[b]=dg(k);break;default:[b]=K1(k)}return n.jsx("path",{d:b,fill:"none",className:"react-flow__connection-path",style:e})};L_.displayName="ConnectionLine";const c9={};function Aj(e=c9){v.useRef(e),Xt(),v.useEffect(()=>{},[e])}function u9(){Xt(),v.useRef(!1),v.useEffect(()=>{},[])}function z_({nodeTypes:e,edgeTypes:t,onInit:s,onNodeClick:i,onEdgeClick:r,onNodeDoubleClick:o,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:f,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:x,connectionLineType:b,connectionLineStyle:k,connectionLineComponent:j,connectionLineContainerStyle:N,selectionKeyCode:C,selectionOnDrag:S,selectionMode:_,multiSelectionKeyCode:z,panActivationKeyCode:P,zoomActivationKeyCode:H,deleteKeyCode:B,onlyRenderVisibleElements:O,elementsSelectable:T,defaultViewport:D,translateExtent:U,minZoom:A,maxZoom:I,preventScrolling:R,defaultMarkerColor:L,zoomOnScroll:K,zoomOnPinch:F,panOnScroll:q,panOnScrollSpeed:V,panOnScrollMode:Z,zoomOnDoubleClick:Q,panOnDrag:G,autoPanOnSelection:ne,onPaneClick:te,onPaneMouseEnter:re,onPaneMouseMove:X,onPaneMouseLeave:se,onPaneScroll:ae,onPaneContextMenu:_e,paneClickDistance:ze,nodeClickDistance:Te,onEdgeContextMenu:fe,onEdgeMouseEnter:ye,onEdgeMouseMove:Fe,onEdgeMouseLeave:Re,reconnectRadius:Qe,onReconnect:Ke,onReconnectStart:_t,onReconnectEnd:xt,noDragClassName:Mt,noWheelClassName:En,noPanClassName:rt,disableKeyboardA11y:Pt,nodeExtent:rn,rfId:Zt,viewport:Qt,onViewportChange:Ut,nodesDraggable:Rn}){return Aj(e),Aj(t),u9(),t9(s),s9(Qt),n.jsx(_H,{onPaneClick:te,onPaneMouseEnter:re,onPaneMouseMove:X,onPaneMouseLeave:se,onPaneContextMenu:_e,onPaneScroll:ae,paneClickDistance:ze,deleteKeyCode:B,selectionKeyCode:C,selectionOnDrag:S,selectionMode:_,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:z,panActivationKeyCode:P,zoomActivationKeyCode:H,elementsSelectable:T,zoomOnScroll:K,zoomOnPinch:F,zoomOnDoubleClick:Q,panOnScroll:q,panOnScrollSpeed:V,panOnScrollMode:Z,panOnDrag:G,autoPanOnSelection:ne,defaultViewport:D,translateExtent:U,minZoom:A,maxZoom:I,onSelectionContextMenu:p,preventScrolling:R,noDragClassName:Mt,noWheelClassName:En,noPanClassName:rt,disableKeyboardA11y:Pt,onViewportChange:Ut,isControlledViewport:!!Qt,children:n.jsxs(e9,{children:[n.jsx(JH,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:l,onReconnect:Ke,onReconnectStart:_t,onReconnectEnd:xt,onlyRenderVisibleElements:O,onEdgeContextMenu:fe,onEdgeMouseEnter:ye,onEdgeMouseMove:Fe,onEdgeMouseLeave:Re,reconnectRadius:Qe,defaultMarkerColor:L,noPanClassName:rt,disableKeyboardA11y:Pt,rfId:Zt}),n.jsx(l9,{style:k,type:b,component:j,containerStyle:N}),n.jsx("div",{className:"react-flow__edgelabel-renderer"}),n.jsx(OH,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:o,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:f,nodeClickDistance:Te,onlyRenderVisibleElements:O,noPanClassName:rt,noDragClassName:Mt,disableKeyboardA11y:Pt,nodeExtent:rn,rfId:Zt,nodesDraggable:Rn}),n.jsx("div",{className:"react-flow__viewport-portal"})]})})}z_.displayName="GraphView";const d9=v.memo(z_),h9=D1(),$j=({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,width:r,height:o,fitView:l,fitViewOptions:u,minZoom:d=.5,maxZoom:h=2,nodeOrigin:f,nodeExtent:p,zIndexMode:g="basic"}={})=>{const x=new Map,b=new Map,k=new Map,j=new Map,N=i??t??[],C=s??e??[],S=f??[0,0],_=p??Ec;Q1(k,j,N);const{nodesInitialized:z}=mg(C,x,b,{nodeOrigin:S,nodeExtent:_,zIndexMode:g});let P=[0,0,1];if(l&&r&&o){const H=Wc(x,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:B,y:O,zoom:T}=$x(H,r,o,d,h,(u==null?void 0:u.padding)??.1);P=[B,O,T]}return{rfId:"1",width:r??0,height:o??0,transform:P,nodes:C,nodesInitialized:z,nodeLookup:x,parentLookup:b,edges:N,edgeLookup:j,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:s!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:d,maxZoom:h,translateExtent:Ec,nodeExtent:_,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:{...M1},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:h9,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:T1,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}},m9=({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,width:r,height:o,fitView:l,fitViewOptions:u,minZoom:d,maxZoom:h,nodeOrigin:f,nodeExtent:p,zIndexMode:g})=>SB((x,b)=>{async function k(){const{nodeLookup:j,panZoom:N,fitViewOptions:C,fitViewResolver:S,width:_,height:z,minZoom:P,maxZoom:H}=b();N&&(await kU({nodes:j,width:_,height:z,panZoom:N,minZoom:P,maxZoom:H},C),S==null||S.resolve(!0),x({fitViewResolver:null}))}return{...$j({nodes:e,edges:t,width:r,height:o,fitView:l,fitViewOptions:u,minZoom:d,maxZoom:h,nodeOrigin:f,nodeExtent:p,defaultNodes:s,defaultEdges:i,zIndexMode:g}),setNodes:j=>{const{nodeLookup:N,parentLookup:C,nodeOrigin:S,nodeExtent:_,elevateNodesOnSelect:z,fitViewQueued:P,zIndexMode:H,nodesSelectionActive:B}=b(),{nodesInitialized:O,hasSelectedNodes:T}=mg(j,N,C,{nodeOrigin:S,nodeExtent:_,elevateNodesOnSelect:z,checkEquality:!0,zIndexMode:H}),D=B&&T;P&&O?(k(),x({nodes:j,nodesInitialized:O,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:D})):x({nodes:j,nodesInitialized:O,nodesSelectionActive:D})},setEdges:j=>{const{connectionLookup:N,edgeLookup:C}=b();Q1(N,C,j),x({edges:j})},setDefaultNodesAndEdges:(j,N)=>{if(j){const{setNodes:C}=b();C(j),x({hasDefaultNodes:!0})}if(N){const{setEdges:C}=b();C(N),x({hasDefaultEdges:!0})}},updateNodeInternals:j=>{const{triggerNodeChanges:N,nodeLookup:C,parentLookup:S,domNode:_,nodeOrigin:z,nodeExtent:P,debug:H,fitViewQueued:B,zIndexMode:O}=b(),{changes:T,updatedInternals:D}=ZU(j,C,S,_,z,P,O);D&&(FU(C,S,{nodeOrigin:z,nodeExtent:P,zIndexMode:O}),B?(k(),x({fitViewQueued:!1,fitViewOptions:void 0})):x({}),(T==null?void 0:T.length)>0&&(H&&console.log("React Flow: trigger node changes",T),N==null||N(T)))},updateNodePositions:(j,N=!1)=>{const C=[];let S=[];const{nodeLookup:_,triggerNodeChanges:z,connection:P,updateConnection:H,onNodesChangeMiddlewareMap:B}=b();for(const[O,T]of j){const D=_.get(O),U=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(T!=null&&T.position)),A={id:O,type:"position",position:U?{x:Math.max(0,T.position.x),y:Math.max(0,T.position.y)}:T.position,dragging:N};if(D&&P.inProgress&&P.fromNode.id===D.id){const I=Za(D,P.fromHandle,tt.Left,!0);H({...P,from:I})}U&&D.parentId&&C.push({id:O,parentId:D.parentId,rect:{...T.internals.positionAbsolute,width:T.measured.width??0,height:T.measured.height??0}}),S.push(A)}if(C.length>0){const{parentLookup:O,nodeOrigin:T}=b(),D=Px(C,_,O,T);S.push(...D)}for(const O of B.values())S=O(S);z(S)},triggerNodeChanges:j=>{const{onNodesChange:N,setNodes:C,nodes:S,hasDefaultNodes:_,debug:z}=b();if(j!=null&&j.length){if(_){const P=VB(j,S);C(P)}z&&console.log("React Flow: trigger node changes",j),N==null||N(j)}},triggerEdgeChanges:j=>{const{onEdgesChange:N,setEdges:C,edges:S,hasDefaultEdges:_,debug:z}=b();if(j!=null&&j.length){if(_){const P=qB(j,S);C(P)}z&&console.log("React Flow: trigger edge changes",j),N==null||N(j)}},addSelectedNodes:j=>{const{multiSelectionActive:N,edgeLookup:C,nodeLookup:S,triggerNodeChanges:_,triggerEdgeChanges:z}=b();if(N){const P=j.map(H=>wa(H,!0));_(P);return}_(Io(S,new Set([...j]),!0)),z(Io(C))},addSelectedEdges:j=>{const{multiSelectionActive:N,edgeLookup:C,nodeLookup:S,triggerNodeChanges:_,triggerEdgeChanges:z}=b();if(N){const P=j.map(H=>wa(H,!0));z(P);return}z(Io(C,new Set([...j]))),_(Io(S,new Set,!0))},unselectNodesAndEdges:({nodes:j,edges:N}={})=>{const{edges:C,nodes:S,nodeLookup:_,triggerNodeChanges:z,triggerEdgeChanges:P}=b(),H=j||S,B=N||C,O=[];for(const D of H){if(!D.selected)continue;const U=_.get(D.id);U&&(U.selected=!1),O.push(wa(D.id,!1))}const T=[];for(const D of B)D.selected&&T.push(wa(D.id,!1));z(O),P(T)},setMinZoom:j=>{const{panZoom:N,maxZoom:C}=b();N==null||N.setScaleExtent([j,C]),x({minZoom:j})},setMaxZoom:j=>{const{panZoom:N,minZoom:C}=b();N==null||N.setScaleExtent([C,j]),x({maxZoom:j})},setTranslateExtent:j=>{var N;(N=b().panZoom)==null||N.setTranslateExtent(j),x({translateExtent:j})},resetSelectedElements:()=>{const{edges:j,nodes:N,triggerNodeChanges:C,triggerEdgeChanges:S,elementsSelectable:_}=b();if(!_)return;const z=N.reduce((H,B)=>B.selected?[...H,wa(B.id,!1)]:H,[]),P=j.reduce((H,B)=>B.selected?[...H,wa(B.id,!1)]:H,[]);C(z),S(P)},setNodeExtent:j=>{const{nodes:N,nodeLookup:C,parentLookup:S,nodeOrigin:_,elevateNodesOnSelect:z,nodeExtent:P,zIndexMode:H}=b();j[0][0]===P[0][0]&&j[0][1]===P[0][1]&&j[1][0]===P[1][0]&&j[1][1]===P[1][1]||(mg(N,C,S,{nodeOrigin:_,nodeExtent:j,elevateNodesOnSelect:z,checkEquality:!1,zIndexMode:H}),x({nodeExtent:j}))},panBy:j=>{const{transform:N,width:C,height:S,panZoom:_,translateExtent:z}=b();return WU({delta:j,panZoom:_,transform:N,translateExtent:z,width:C,height:S})},setCenter:async(j,N,C)=>{const{width:S,height:_,maxZoom:z,panZoom:P}=b();if(!P)return!1;const H=typeof(C==null?void 0:C.zoom)<"u"?C.zoom:z;return await P.setViewport({x:S/2-j*H,y:_/2-N*H,zoom:H},{duration:C==null?void 0:C.duration,ease:C==null?void 0:C.ease,interpolate:C==null?void 0:C.interpolate}),!0},cancelConnection:()=>{x({connection:{...M1}})},updateConnection:j=>{x({connection:j})},reset:()=>x({...$j()})}},Object.is);function f9({initialNodes:e,initialEdges:t,defaultNodes:s,defaultEdges:i,initialWidth:r,initialHeight:o,initialMinZoom:l,initialMaxZoom:u,initialFitViewOptions:d,fitView:h,nodeOrigin:f,nodeExtent:p,zIndexMode:g,children:x}){const[b]=v.useState(()=>m9({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,width:r,height:o,fitView:h,minZoom:l,maxZoom:u,fitViewOptions:d,nodeOrigin:f,nodeExtent:p,zIndexMode:g}));return n.jsx(_B,{value:b,children:n.jsx(QB,{children:n.jsx(mH,{children:x})})})}function p9({children:e,nodes:t,edges:s,defaultNodes:i,defaultEdges:r,width:o,height:l,fitView:u,fitViewOptions:d,minZoom:h,maxZoom:f,nodeOrigin:p,nodeExtent:g,zIndexMode:x}){return v.useContext(vh)?n.jsx(n.Fragment,{children:e}):n.jsx(f9,{initialNodes:t,initialEdges:s,defaultNodes:i,defaultEdges:r,initialWidth:o,initialHeight:l,fitView:u,initialFitViewOptions:d,initialMinZoom:h,initialMaxZoom:f,nodeOrigin:p,nodeExtent:g,zIndexMode:x,children:e})}const g9={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function x9({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,className:r,nodeTypes:o,edgeTypes:l,onNodeClick:u,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onConnect:x,onConnectStart:b,onConnectEnd:k,onClickConnectStart:j,onClickConnectEnd:N,onNodeMouseEnter:C,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:z,onNodeDoubleClick:P,onNodeDragStart:H,onNodeDrag:B,onNodeDragStop:O,onNodesDelete:T,onEdgesDelete:D,onDelete:U,onSelectionChange:A,onSelectionDragStart:I,onSelectionDrag:R,onSelectionDragStop:L,onSelectionContextMenu:K,onSelectionStart:F,onSelectionEnd:q,onBeforeDelete:V,connectionMode:Z,connectionLineType:Q=Vr.Bezier,connectionLineStyle:G,connectionLineComponent:ne,connectionLineContainerStyle:te,deleteKeyCode:re="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:se=!1,selectionMode:ae=Cc.Full,panActivationKeyCode:_e="Space",multiSelectionKeyCode:ze=$c()?"Meta":"Control",zoomActivationKeyCode:Te=$c()?"Meta":"Control",snapToGrid:fe,snapGrid:ye,onlyRenderVisibleElements:Fe=!1,selectNodesOnDrag:Re,nodesDraggable:Qe,autoPanOnNodeFocus:Ke,nodesConnectable:_t,nodesFocusable:xt,nodeOrigin:Mt=d_,edgesFocusable:En,edgesReconnectable:rt,elementsSelectable:Pt=!0,defaultViewport:rn=DB,minZoom:Zt=.5,maxZoom:Qt=2,translateExtent:Ut=Ec,preventScrolling:Rn=!0,nodeExtent:fn,defaultMarkerColor:Hn="#b1b1b7",zoomOnScroll:Gs=!0,zoomOnPinch:ps=!0,panOnScroll:rs=!1,panOnScrollSpeed:gs=.5,panOnScrollMode:Cn=La.Free,zoomOnDoubleClick:as=!0,panOnDrag:Kn=!0,onPaneClick:Zn,onPaneMouseEnter:An,onPaneMouseMove:Yn,onPaneMouseLeave:On,onPaneScroll:ce,onPaneContextMenu:J,paneClickDistance:he=1,nodeClickDistance:we=0,children:Ue,onReconnect:ct,onReconnectStart:jt,onReconnectEnd:Be,onEdgeContextMenu:De,onEdgeDoubleClick:Ye,onEdgeMouseEnter:vt,onEdgeMouseMove:wt,onEdgeMouseLeave:Xn,reconnectRadius:xs=10,onNodesChange:ui,onEdgesChange:br,noDragClassName:di="nodrag",noWheelClassName:kr="nowheel",noPanClassName:Qn="nopan",fitView:qi,fitViewOptions:vs,connectOnClick:Ti,attributionPosition:jr,proOptions:zt,defaultEdgeOptions:Os,elevateNodesOnSelect:os=!0,elevateEdgesOnSelect:Gi=!1,disableKeyboardA11y:hi=!1,autoPanOnConnect:Dt,autoPanOnNodeDrag:Nr,autoPanOnSelection:Ki=!0,autoPanSpeed:mi,connectionRadius:Mi,isValidConnection:Me,onError:We,style:ut,id:mt,nodeDragThreshold:Rt,connectionDragThreshold:Ft,viewport:Jn,onViewportChange:Ks,width:pn,height:$n,colorMode:Ys="light",debug:Xs,onScroll:ys,ariaLabelConfig:ra,zIndexMode:wr="basic",...Ri},Sr){const ls=mt||"1",bs=HB(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",...Ri,onScroll:In,style:{...ut,...g9},ref:Sr,className:_n(["react-flow",r,bs]),id:mt,role:"application",children:n.jsxs(p9,{nodes:e,edges:t,width:pn,height:$n,fitView:qi,fitViewOptions:vs,minZoom:Zt,maxZoom:Qt,nodeOrigin:Mt,nodeExtent:fn,zIndexMode:wr,children:[n.jsx(BB,{nodes:e,edges:t,defaultNodes:s,defaultEdges:i,onConnect:x,onConnectStart:b,onConnectEnd:k,onClickConnectStart:j,onClickConnectEnd:N,nodesDraggable:Qe,autoPanOnNodeFocus:Ke,nodesConnectable:_t,nodesFocusable:xt,edgesFocusable:En,edgesReconnectable:rt,elementsSelectable:Pt,elevateNodesOnSelect:os,elevateEdgesOnSelect:Gi,minZoom:Zt,maxZoom:Qt,nodeExtent:fn,onNodesChange:ui,onEdgesChange:br,snapToGrid:fe,snapGrid:ye,connectionMode:Z,translateExtent:Ut,connectOnClick:Ti,defaultEdgeOptions:Os,fitView:qi,fitViewOptions:vs,onNodesDelete:T,onEdgesDelete:D,onDelete:U,onNodeDragStart:H,onNodeDrag:B,onNodeDragStop:O,onSelectionDrag:R,onSelectionDragStart:I,onSelectionDragStop:L,onMove:f,onMoveStart:p,onMoveEnd:g,noPanClassName:Qn,nodeOrigin:Mt,rfId:ls,autoPanOnConnect:Dt,autoPanOnNodeDrag:Nr,autoPanSpeed:mi,onError:We,connectionRadius:Mi,isValidConnection:Me,selectNodesOnDrag:Re,nodeDragThreshold:Rt,connectionDragThreshold:Ft,onBeforeDelete:V,debug:Xs,ariaLabelConfig:ra,zIndexMode:wr}),n.jsx(d9,{onInit:h,onNodeClick:u,onEdgeClick:d,onNodeMouseEnter:C,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:z,onNodeDoubleClick:P,nodeTypes:o,edgeTypes:l,connectionLineType:Q,connectionLineStyle:G,connectionLineComponent:ne,connectionLineContainerStyle:te,selectionKeyCode:X,selectionOnDrag:se,selectionMode:ae,deleteKeyCode:re,multiSelectionKeyCode:ze,panActivationKeyCode:_e,zoomActivationKeyCode:Te,onlyRenderVisibleElements:Fe,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:Ki,onPaneClick:Zn,onPaneMouseEnter:An,onPaneMouseMove:Yn,onPaneMouseLeave:On,onPaneScroll:ce,onPaneContextMenu:J,paneClickDistance:he,nodeClickDistance:we,onSelectionContextMenu:K,onSelectionStart:F,onSelectionEnd:q,onReconnect:ct,onReconnectStart:jt,onReconnectEnd:Be,onEdgeContextMenu:De,onEdgeDoubleClick:Ye,onEdgeMouseEnter:vt,onEdgeMouseMove:wt,onEdgeMouseLeave:Xn,reconnectRadius:xs,defaultMarkerColor:Hn,noDragClassName:di,noWheelClassName:kr,noPanClassName:Qn,rfId:ls,disableKeyboardA11y:hi,nodeExtent:fn,viewport:Jn,onViewportChange:Ks,nodesDraggable:Qe}),n.jsx(zB,{onSelectionChange:A}),Ue,n.jsx(MB,{proOptions:zt,position:jr}),n.jsx(TB,{rfId:ls,disableKeyboardA11y:hi})]})})}var v9=m_(x9);function y9({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 b9({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 k9={[ta.Dots]:1,[ta.Lines]:1,[ta.Cross]:6},j9=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function D_({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:f}){const p=v.useRef(null),{transform:g,patternId:x}=At(j9,un),b=i||k9[t],k=t===ta.Dots,j=t===ta.Cross,N=Array.isArray(s)?s:[s,s],C=[N[0]*g[2]||1,N[1]*g[2]||1],S=b*g[2],_=Array.isArray(o)?o:[o,o],z=j?[S,S]:C,P=[_[0]*g[2]+z[0]/2,_[1]*g[2]+z[1]/2],H=`${x}${e||""}`;return n.jsxs("svg",{className:_n(["react-flow__background",h]),style:{...d,...bh,"--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]%C[0],y:g[1]%C[1],width:C[0],height:C[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${P[0]},-${P[1]})`,children:k?n.jsx(b9,{radius:S/2,className:f}):n.jsx(y9,{dimensions:z,lineWidth:r,variant:t,className:f})}),n.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${H})`})]})}D_.displayName="Background";const N9=v.memo(D_);function w9(){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 S9(){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 _9(){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 E9(){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 C9(){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 ud({children:e,className:t,...s}){return n.jsx("button",{type:"button",className:_n(["react-flow__controls-button",t]),...s,children:e})}const A9=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function F_({style:e,showZoom:t=!0,showFitView:s=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:o,onZoomOut:l,onFitView:u,onInteractiveChange:d,className:h,children:f,position:p="bottom-left",orientation:g="vertical","aria-label":x}){const b=Xt(),{isInteractive:k,minZoomReached:j,maxZoomReached:N,ariaLabelConfig:C}=At(A9,un),{zoomIn:S,zoomOut:_,fitView:z}=Lx(),P=()=>{S(),o==null||o()},H=()=>{_(),l==null||l()},B=()=>{z(r),u==null||u()},O=()=>{b.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),d==null||d(!k)},T=g==="horizontal"?"horizontal":"vertical";return n.jsxs(yh,{className:_n(["react-flow__controls",T,h]),position:p,style:e,"data-testid":"rf__controls","aria-label":x??C["controls.ariaLabel"],children:[t&&n.jsxs(n.Fragment,{children:[n.jsx(ud,{onClick:P,className:"react-flow__controls-zoomin",title:C["controls.zoomIn.ariaLabel"],"aria-label":C["controls.zoomIn.ariaLabel"],disabled:N,children:n.jsx(w9,{})}),n.jsx(ud,{onClick:H,className:"react-flow__controls-zoomout",title:C["controls.zoomOut.ariaLabel"],"aria-label":C["controls.zoomOut.ariaLabel"],disabled:j,children:n.jsx(S9,{})})]}),s&&n.jsx(ud,{className:"react-flow__controls-fitview",onClick:B,title:C["controls.fitView.ariaLabel"],"aria-label":C["controls.fitView.ariaLabel"],children:n.jsx(_9,{})}),i&&n.jsx(ud,{className:"react-flow__controls-interactive",onClick:O,title:C["controls.interactive.ariaLabel"],"aria-label":C["controls.interactive.ariaLabel"],children:k?n.jsx(C9,{}):n.jsx(E9,{})}),f]})}F_.displayName="Controls";const $9=v.memo(F_);function I9({id:e,x:t,y:s,width:i,height:r,style:o,color:l,strokeColor:u,strokeWidth:d,className:h,borderRadius:f,shapeRendering:p,selected:g,onClick:x}){const{background:b,backgroundColor:k}=o||{},j=l||b||k;return n.jsx("rect",{className:_n(["react-flow__minimap-node",{selected:g},h]),x:t,y:s,rx:f,ry:f,width:i,height:r,style:{fill:j,stroke:u,strokeWidth:d},shapeRendering:p,onClick:x?N=>x(N,e):void 0})}const T9=v.memo(I9),M9=e=>e.nodes.map(t=>t.id),sp=e=>e instanceof Function?e:()=>e;function R9({nodeStrokeColor:e,nodeColor:t,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:o=T9,onClick:l}){const u=At(M9,un),d=sp(t),h=sp(e),f=sp(s),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return n.jsx(n.Fragment,{children:u.map(g=>n.jsx(P9,{id:g,nodeColorFunc:d,nodeStrokeColorFunc:h,nodeClassNameFunc:f,nodeBorderRadius:i,nodeStrokeWidth:r,NodeComponent:o,onClick:l,shapeRendering:p},g))})}function O9({id:e,nodeColorFunc:t,nodeStrokeColorFunc:s,nodeClassNameFunc:i,nodeBorderRadius:r,nodeStrokeWidth:o,shapeRendering:l,NodeComponent:u,onClick:d}){const{node:h,x:f,y:p,width:g,height:x}=At(b=>{const k=b.nodeLookup.get(e);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const j=k.internals.userNode,{x:N,y:C}=k.internals.positionAbsolute,{width:S,height:_}=Ii(j);return{node:j,x:N,y:C,width:S,height:_}},un);return!h||h.hidden||!F1(h)?null:n.jsx(u,{x:f,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 P9=v.memo(O9);var L9=v.memo(R9);const z9=200,D9=150,F9=e=>!e.hidden,U9=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?L1(Wc(e.nodeLookup,{filter:F9}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Ij=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,B9=(e,t)=>Ij(e.viewBB,t.viewBB)&&Ij(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,H9="react-flow__minimap-desc";function U_({style:e,className:t,nodeStrokeColor:s,nodeColor:i,nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:l,nodeComponent:u,bgColor:d,maskColor:h,maskStrokeColor:f,maskStrokeWidth:p,position:g="bottom-right",onClick:x,onNodeClick:b,pannable:k=!1,zoomable:j=!1,ariaLabel:N,inversePan:C,zoomStep:S=1,offsetScale:_=5}){const z=Xt(),P=v.useRef(null),{boundingRect:H,panZoom:B,viewBB:O,rfId:T,translateExtent:D,flowWidth:U,flowHeight:A,ariaLabelConfig:I}=At(U9,B9),R=(e==null?void 0:e.width)??z9,L=(e==null?void 0:e.height)??D9,K=H.width/R,F=H.height/L,q=Math.max(K,F),V=q*R,Z=q*L,Q=_*q,G=H.x-(V-H.width)/2-Q,ne=H.y-(Z-H.height)/2-Q,te=V+Q*2,re=Z+Q*2,X=`${H9}-${T}`,se=v.useRef(0),ae=v.useRef();se.current=q,v.useEffect(()=>{const ye=z.getState().panZoom;if(P.current&&ye)return ae.current=eB({domNode:P.current,panZoom:ye,getTransform:()=>z.getState().transform,getViewScale:()=>se.current}),()=>{var Fe;(Fe=ae.current)==null||Fe.destroy()}},[B]),v.useEffect(()=>{var ye;(ye=ae.current)==null||ye.update({translateExtent:D,width:U,height:A,inversePan:C,pannable:k,zoomStep:S,zoomable:j})},[k,j,C,S,D,U,A]);const _e=x?ye=>{var Qe;const[Fe,Re]=((Qe=ae.current)==null?void 0:Qe.pointer(ye))||[0,0];x(ye,{x:Fe,y:Re})}:void 0,ze=v.useCallback((ye,Fe)=>{const Re=z.getState().nodeLookup.get(Fe).internals.userNode;b==null||b(ye,Re)},[b]),Te=b?ze:void 0,fe=N??I["minimap.ariaLabel"];return n.jsx(yh,{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 f=="string"?f: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:R,height:L,viewBox:`${G} ${ne} ${te} ${re}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":X,ref:P,onClick:_e,children:[fe&&n.jsx("title",{id:X,children:fe}),n.jsx(L9,{onClick:Te,nodeColor:i,nodeStrokeColor:s,nodeBorderRadius:o,nodeClassName:r,nodeStrokeWidth:l,nodeComponent:u}),n.jsx("path",{className:"react-flow__minimap-mask",d:`M${G-Q},${ne-Q}h${te+Q*2}v${re+Q*2}h${-te-Q*2}z
232
+ M${O.x},${O.y}h${O.width}v${O.height}h${-O.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}U_.displayName="MiniMap";v.memo(U_);const Z9=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,W9={[tl.Line]:"right",[tl.Handle]:"bottom-right"};function V9({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:f=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:g,autoScale:x=!0,shouldResize:b,onResizeStart:k,onResize:j,onResizeEnd:N}){const C=v_(),S=typeof e=="string"?e:C,_=Xt(),z=v.useRef(null),P=s===tl.Handle,H=At(v.useCallback(Z9(P&&x),[P,x]),un),B=v.useRef(null),O=t??W9[s];v.useEffect(()=>{if(!(!z.current||!S))return B.current||(B.current=mB({domNode:z.current,nodeId:S,getStoreItems:()=>{const{nodeLookup:D,transform:U,snapGrid:A,snapToGrid:I,nodeOrigin:R,domNode:L}=_.getState();return{nodeLookup:D,transform:U,snapGrid:A,snapToGrid:I,nodeOrigin:R,paneDomNode:L}},onChange:(D,U)=>{const{triggerNodeChanges:A,nodeLookup:I,parentLookup:R,nodeOrigin:L}=_.getState(),K=[],F={x:D.x,y:D.y},q=I.get(S);if(q&&q.expandParent&&q.parentId){const V=q.origin??L,Z=D.width??q.measured.width??0,Q=D.height??q.measured.height??0,G={id:q.id,parentId:q.parentId,rect:{width:Z,height:Q,...U1({x:D.x??q.position.x,y:D.y??q.position.y},{width:Z,height:Q},q.parentId,I,V)}},ne=Px([G],I,R,L);K.push(...ne),F.x=D.x?Math.max(V[0]*Z,D.x):void 0,F.y=D.y?Math.max(V[1]*Q,D.y):void 0}if(F.x!==void 0&&F.y!==void 0){const V={id:S,type:"position",position:{...F}};K.push(V)}if(D.width!==void 0&&D.height!==void 0){const Z={id:S,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};K.push(Z)}for(const V of U){const Z={...V,type:"position"};K.push(Z)}A(K)},onEnd:({width:D,height:U})=>{const A={id:S,type:"dimensions",resizing:!1,dimensions:{width:D,height:U}};_.getState().triggerNodeChanges([A])}})),B.current.update({controlPosition:O,boundaries:{minWidth:u,minHeight:d,maxWidth:h,maxHeight:f},keepAspectRatio:p,resizeDirection:g,onResizeStart:k,onResize:j,onResizeEnd:N,shouldResize:b}),()=>{var D;(D=B.current)==null||D.destroy()}},[O,u,d,h,f,p,k,j,N,b]);const T=O.split("-");return n.jsx("div",{className:_n(["react-flow__resize-control","nodrag",...T,s,i]),ref:z,style:{...r,scale:H,...l&&{[P?"backgroundColor":"borderColor"]:l}},children:o})}v.memo(V9);function q9(e,t=0){const s=ke(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 f=await e.connection.call("configs/profiles",{scriptId:d.id}).catch(()=>{});u.push({scriptId:d.id,scriptName:d.name,tasks:h.tasks,profiles:f})}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 B_=[0,1,2,3,4,5].map(e=>({value:String(e),label:e===0?"不重试":`重试 ${e} 次`})),H_=[{value:"continue",label:"然后继续其他分支"},{value:"stop",label:"然后停止流水线"}],nl={"script-task":"脚本任务",agent:"agent 步骤",wait:"控制节点",notify:"发消息",gate:"人工确认",start:"开始",end:"结束"},gg={pending:"待运行",waiting:"等待中",running:"运行中",succeeded:"成功",failed:"失败",skipped:"跳过",cancelled:"取消"},G9={success:"成功后",failure:"失败后",always:"结束后"},ip={desktop:"鼠标键盘",adb:"模拟器",window:"后台窗口",none:""};function K9({data:e,selected:t}){var i,r,o,l;const s=(i=e.state)==null?void 0:i.state;return Zi(e.node)?n.jsxs("div",{className:`step-node marker ${e.node.kind} ${s??""} ${t?"selected":""}`,children:[e.node.kind==="end"&&n.jsx(Jr,{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)??gg[s]}),e.node.kind==="start"&&n.jsx(Jr,{type:"source",position:tt.Right})]}):n.jsxs("div",{className:`step-node ${s??""} ${t?"selected":""} ${e.issue!==void 0?"has-issue":""}`,children:[n.jsx(Jr,{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:[gg[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(Jr,{type:"source",position:tt.Right})]})}const Y9={step:K9};function X9(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 Q9=0;const wo=(e,t,s=new Set)=>{for(;;){const i=`${e}${++Q9}`;if(!s.has(i)&&!t.nodes.some(r=>r.id===i))return i}};function J9(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 Hr=null;const e8=e=>e instanceof HTMLElement&&e.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]')!==null;function t8({client:e,pipeline:t,onChange:s,run:i,check:r,runFrom:o,idle:l}){var Z,Q;const u=ZS(),[d,h]=v.useState(0),f=q9(e,d),[p,g]=v.useState([]),x=p.length===1?p[0]:null,b=G=>g(G===null?[]:[G]),[k,j]=v.useState(null),N=v.useRef(null),[C,S]=v.useState({}),_=v.useCallback(G=>{var ne,te;if(G.kind==="script-task"){const re=f.find(_e=>_e.scriptId===G.scriptId),X=re==null?void 0:re.tasks.find(_e=>_e.id===G.taskId),se=Object.entries(G.params).map(([_e,ze])=>`${_e}=${String(ze)}`).join(" "),ae=G.profile===void 0?void 0:((te=(ne=re==null?void 0:re.profiles)==null?void 0:ne.items.find(_e=>_e.id===G.profile))==null?void 0:te.name)??"已删除的配置";return{label:G.title??`${(re==null?void 0:re.scriptName)??G.scriptId} · ${(X==null?void 0:X.title)??G.taskId}`,sub:[ae===void 0?"":`配置:${ae}`,se].filter(Boolean).join(" · "),input:ip[(X==null?void 0:X.input)??"none"]??""}}return G.kind==="wait"?{label:G.title??(G.minutes!==void 0?`等 ${G.minutes} 分钟`:`等到 ${G.until}`),sub:"",input:""}:G.kind==="agent"?{label:G.title??"agent 步骤",sub:G.prompt.slice(0,40),input:""}:Zi(G)?{label:nl[G.kind],sub:"",input:""}:{label:G.title??nl[G.kind],sub:G.text.slice(0,40),input:""}},[f]),z=v.useMemo(()=>X9(t),[t]),P=v.useMemo(()=>t.nodes.map(G=>{var ne;return{id:G.id,type:"step",position:z.get(G.id),selected:p.includes(G.id),...C[G.id]===void 0?{}:{measured:C[G.id]},data:{node:G,..._(G),state:i==null?void 0:i.nodes[G.id],issue:(ne=r==null?void 0:r.issues.find(te=>te.nodeId===G.id&&te.level==="error"))==null?void 0:ne.message}}}),[t,z,_,i,r,p,C]),H=v.useMemo(()=>t.edges.map((G,ne)=>{var te;return{id:`e${ne}`,source:G.from,target:G.to,label:G9[G.when],selected:ne===k,animated:((te=i==null?void 0:i.nodes[G.from])==null?void 0:te.state)==="running",className:`edge-${G.when}`}}),[t.edges,k,i]),B=v.useRef({past:[],future:[],at:0}),O=v.useCallback((G,ne)=>{const te=B.current,re=Date.now();(ne===void 0||ne!==te.group||re-te.at>1e3)&&(te.past=[...te.past.slice(-99),{nodes:t.nodes,edges:t.edges}]),te.future=[],te.group=ne,te.at=re,s(J9(G,z))},[t,z,s]),T=G=>{const ne=B.current,te=G==="past"?"future":"past",re=ne[G].pop();re!==void 0&&(ne[te].push({nodes:t.nodes,edges:t.edges}),ne.group=void 0,s({...t,...re}),g(X=>X.filter(se=>re.nodes.some(ae=>ae.id===se))),j(null))},D=v.useCallback(G=>{let ne=t,te;const re={},X=new Map;for(const se of G)if(se.type==="dimensions"&&se.dimensions!==void 0)re[se.id]=se.dimensions;else if(se.type==="select")X.set(se.id,se.selected);else if(se.type==="position"&&se.position!==void 0)ne={...ne,nodes:ne.nodes.map(ae=>ae.id===se.id?{...ae,position:{x:Math.round(se.position.x),y:Math.round(se.position.y)}}:ae)},te="move";else if(se.type==="remove"){if(ne.nodes.some(ae=>ae.id===se.id&&Zi(ae)))continue;ne={...ne,nodes:ne.nodes.filter(ae=>ae.id!==se.id),edges:ne.edges.filter(ae=>ae.from!==se.id&&ae.to!==se.id)},X.set(se.id,!1),te=void 0}Object.keys(re).length>0&&S(se=>({...se,...re})),X.size>0&&(g(se=>[...se.filter(ae=>X.get(ae)!==!1),...[...X].filter(([ae,_e])=>_e&&!se.includes(ae)).map(([ae])=>ae)]),[...X.values()].some(Boolean)&&j(null)),ne!==t&&O(ne,te)},[t,O]),U=v.useCallback(G=>{var te;if(G.source===G.target||t.edges.some(re=>re.from===G.source&&re.to===G.target))return;const ne=t.nodes.find(re=>re.id===G.target);(ne==null?void 0:ne.kind)==="start"||((te=t.nodes.find(re=>re.id===G.source))==null?void 0:te.kind)==="end"||O({...t,edges:[...t.edges,{from:G.source,to:G.target,when:(ne==null?void 0:ne.kind)==="end"?"always":"success"}]})},[t,O]),A=()=>{const G=t.nodes.filter(te=>p.includes(te.id)&&!Zi(te));if(G.length===0)return!1;const ne=new Set(G.map(te=>te.id));return Hr={nodes:G.map(te=>({...te,position:z.get(te.id)??{x:40,y:40}})),edges:t.edges.filter(te=>ne.has(te.from)&&ne.has(te.to)),pasted:0},!0},I=()=>{if(Hr===null||t.nodes.length+Hr.nodes.length>60)return;const G=++Hr.pasted,ne=new Map;for(const X of Hr.nodes)ne.set(X.id,wo(X.id.replace(/\d+$/,"")||"step",t,new Set(ne.values())));const te=Hr.nodes.map(X=>{var se,ae;return{...X,id:ne.get(X.id),position:{x:(((se=X.position)==null?void 0:se.x)??40)+40*G,y:(((ae=X.position)==null?void 0:ae.y)??40)+120*G}}}),re=Hr.edges.map(X=>({...X,from:ne.get(X.from),to:ne.get(X.to)}));O({...t,nodes:[...t.nodes,...te],edges:[...t.edges,...re]}),g(te.map(X=>X.id)),j(null)},R=()=>{const G=new Set(t.nodes.filter(ne=>p.includes(ne.id)&&!Zi(ne)).map(ne=>ne.id));G.size!==0&&(O({...t,nodes:t.nodes.filter(ne=>!G.has(ne.id)),edges:t.edges.filter(ne=>!G.has(ne.from)&&!G.has(ne.to))}),g([]))},L=v.useRef(()=>{});L.current=G=>{var te;if(!(G.ctrlKey||G.metaKey)||G.altKey||e8(G.target)||N.current===null||N.current.offsetParent===null)return;const ne=G.key.toLowerCase();ne==="z"&&!G.shiftKey?(G.preventDefault(),T("past")):ne==="y"||ne==="z"&&G.shiftKey?(G.preventDefault(),T("future")):ne==="c"?(((te=window.getSelection())==null?void 0:te.toString())??"")===""&&A()&&G.preventDefault():ne==="v"&&Hr!==null&&(G.preventDefault(),I())},v.useEffect(()=>{const G=ne=>L.current(ne);return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[]);const K=G=>{const ne=t.nodes.find(Te=>Te.kind==="start"),te=t.nodes.find(Te=>Te.kind==="end"),re=t.nodes.find(Te=>Te.id===x&&Te.kind!=="end")??ne,X=re===void 0?void 0:z.get(re.id),se=[...z.entries()].filter(([Te])=>Te!==(te==null?void 0:te.id)).map(([,Te])=>Te),ae=X===void 0?Math.max(0,...se.map(Te=>Te.x))+280:X.x+280;let _e=(X==null?void 0:X.y)??40;for(;se.some(Te=>Math.abs(Te.x-ae)<200&&Math.abs(Te.y-_e)<100);)_e+=130;const ze=[...t.nodes.map(Te=>{var fe,ye;return Te.kind==="end"?{...Te,position:{x:Math.max(((fe=z.get(Te.id))==null?void 0:fe.x)??0,ae+300),y:((ye=z.get(Te.id))==null?void 0:ye.y)??_e}}:Te}),{...G,position:{x:ae,y:_e}}];O({...t,nodes:ze}),b(G.id),j(null)},F=t.nodes.find(G=>G.id===x),q=k===null?void 0:t.edges[k],V=G=>O({...t,nodes:t.nodes.map(ne=>ne.id===G.id?G:ne)},`node:${G.id}`);return n.jsxs("div",{className:"pipeline-editor",ref:N,children:[n.jsxs("div",{className:"pipeline-palette","aria-label":"节点",children:[n.jsx("div",{className:"sidebar-label",children:"脚本任务"}),f.length===0&&n.jsx("div",{className:"muted small pad",children:"脚本库里还没有带脚本包的脚本"}),f.map(G=>n.jsxs("details",{className:"palette-group",open:f.length<=3,children:[n.jsx("summary",{children:G.scriptName}),G.tasks.map(ne=>n.jsxs("button",{className:"palette-item",title:ne.description??ne.title,onClick:()=>K({id:wo(G.scriptId.replace(/[^A-Za-z0-9_-]/g,"").slice(0,20)||"task",t),kind:"script-task",scriptId:G.scriptId,taskId:ne.id,params:{}}),children:[n.jsx("span",{children:ne.title}),ip[ne.input]!==""&&n.jsx("span",{className:"badge",children:ip[ne.input]})]},ne.id))]},G.scriptId)),n.jsx("div",{className:"sidebar-label pack-label",children:"其他步骤"}),n.jsx("button",{className:"palette-item",onClick:()=>K({id:wo("agent",t),kind:"agent",prompt:"检查活动还剩几天,快结束的提醒我"}),children:"agent 步骤"}),n.jsx("button",{className:"palette-item",onClick:()=>K({id:wo("wait",t),kind:"wait",minutes:10}),children:"控制节点"}),n.jsx("button",{className:"palette-item",onClick:()=>K({id:wo("notify",t),kind:"notify",text:`${t.name}跑完了`}),children:"发消息"}),n.jsx("button",{className:"palette-item",onClick:()=>K({id:wo("gate",t),kind:"gate",text:"确认后继续"}),children:"人工确认"}),n.jsx("p",{className:"muted small pad",children:"从节点右边的圆点拖到另一个节点左边,表示「这个完成后再运行那个」。没有连线的节点会同时开始;需要同一资源的会自动排队。"})]}),n.jsxs("div",{className:"pipeline-canvas",children:[n.jsxs(v9,{nodes:P,edges:H,nodeTypes:Y9,onNodesChange:D,onConnect:U,onNodeClick:()=>j(null),onEdgeClick:(G,ne)=>{j(Number(ne.id.slice(1))),b(null)},onPaneClick:()=>{b(null),j(null)},deleteKeyCode:["Delete","Backspace"],colorMode:u,fitView:!0,fitViewOptions:{maxZoom:1,padding:.2},proOptions:{hideAttribution:!0},children:[n.jsx(N9,{gap:20}),n.jsx($9,{showInteractive:!1})]}),!t.nodes.some(G=>!Zi(G))&&n.jsx("div",{className:"canvas-hint",children:"从左边点一个任务加到画布上,再从节点右边的圆点拖到下一个节点,连成先后顺序"})]}),n.jsxs("aside",{className:"pipeline-inspector",children:[F!==void 0&&n.jsx(s8,{client:e,node:F,pipeline:t,run:i,scripts:f,onChange:V,onTasksChanged:()=>h(G=>G+1),runFrom:o,onRemove:R}),q!==void 0&&n.jsxs("section",{className:"inspector-section",children:[n.jsx("h4",{children:"连线"}),n.jsxs("p",{className:"muted small",children:["「",((Z=t.nodes.find(G=>G.id===q.from))==null?void 0:Z.title)??q.from,"」→「",((Q=t.nodes.find(G=>G.id===q.to))==null?void 0:Q.title)??q.to,"」"]}),n.jsx("label",{className:"field-label",htmlFor:"edge-when",children:"什么时候运行下一步"}),n.jsx(Ot,{id:"edge-when",value:q.when,onChange:G=>O({...t,edges:t.edges.map((ne,te)=>te===k?{...ne,when:G}:ne)}),options:[{value:"success",label:"上一步成功后"},{value:"failure",label:"上一步失败后"},{value:"always",label:"上一步结束后",hint:"不管成败"}]}),n.jsx("button",{className:"danger-outline small-button",onClick:()=>{O({...t,edges:t.edges.filter((G,ne)=>ne!==k)}),j(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:R,children:"删除这些节点"})]}),F===void 0&&q===void 0&&p.length<=1&&(l??n.jsx("p",{className:"muted small pad",children:"点一个节点或连线来修改。选中后按 Delete 也能删除,Ctrl+C / Ctrl+V 复制粘贴,Ctrl+Z 撤销。"})),(F!==void 0||q!==void 0||p.length>1)&&l!==void 0&&n.jsx("button",{className:"link-button small back-to-pipeline",onClick:()=>{b(null),j(null)},children:"← 流水线设置"})]})]})}function n8({client:e,value:t,onChange:s}){const i=v.useRef(null),r=nS({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 s8({client:e,node:t,pipeline:s,run:i,scripts:r,onChange:o,onRemove:l,onTasksChanged:u,runFrom:d}){var b,k;const[h,f]=v.useState(null),p=i==null?void 0:i.nodes[t.id],g=t.kind==="script-task"?(b=r.find(j=>j.scriptId===t.scriptId))==null?void 0:b.tasks.find(j=>j.id===t.taskId):void 0,x=t.onFailure;return Zi(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:j=>{const{title:N,...C}=t;o(j.target.value===""?C:{...C,title:j.target.value})}}),t.kind==="script-task"&&n.jsx(XS,{id:"node-profile",label:"用哪份配置",list:((k=r.find(j=>j.scriptId===t.scriptId))==null?void 0:k.profiles)??null,value:t.profile,onChange:j=>{const{profile:N,...C}=t;o(j===void 0?C:{...C,profile:j})}}),t.kind==="script-task"&&g!==void 0&&Object.entries(g.params).map(([j,N])=>n.jsx(KS,{client:e,scriptId:t.scriptId,taskId:t.taskId,name:j,spec:N,profile:t.profile,value:String(t.params[j]??(N.type==="boolean"?N.default??!1:"")),onCreated:u,onChange:C=>{const{[j]:S,..._}=t.params,z=N.type==="boolean"?C==="true":N.type==="integer"||N.type==="number"?Number(C):C;o({...t,params:C===""?_:{..._,[j]:z}})}},j)),t.kind==="agent"&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:"node-prompt",children:"让 agent 做什么"}),n.jsx(n8,{client:e,value:t.prompt,onChange:j=>o({...t,prompt:j})})]}),(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:j=>o({...t,text:j.target.value})})]}),t.kind==="wait"&&n.jsxs("div",{className:"key-input",children:[n.jsx(Ot,{"aria-label":"等待方式",value:t.minutes!==void 0?"minutes":"until",options:[{value:"minutes",label:"等几分钟"},{value:"until",label:"等到某个时间"}],onChange:j=>o(j==="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:j=>o({...t,minutes:Math.max(1,Math.min(1440,Math.round(Number(j.target.value)||1)))})}):n.jsx("input",{className:"text-input plain",type:"time",value:t.until,onChange:j=>o({...t,until:j.target.value})})]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:t.waitForAll===!0,onChange:j=>{const{waitForAll:N,...C}=t;o(j.target.checked?{...C,waitForAll:!0}:C)}}),"等前面的节点全部结束再开始"]}),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(Ot,{id:"node-retries","aria-label":"重试次数",value:x===void 0?"inherit":String(x.retries),options:[{value:"inherit",label:"按流水线的设置"},...B_],onChange:j=>{const{onFailure:N,...C}=t;if(j==="inherit")return o(C);o({...C,onFailure:{retries:Number(j),then:(x==null?void 0:x.then)??s.onFailure.then}})}}),n.jsx(Ot,{"aria-label":"仍失败时",disabled:x===void 0,value:(x??s.onFailure).then,options:H_,onChange:j=>o({...t,onFailure:{retries:(x==null?void 0:x.retries)??s.onFailure.retries,then:j}})})]}),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:[gg[p.state],p.attempts>1?` · 第 ${p.attempts} 次`:""]}),p.detail!==void 0&&n.jsx("div",{className:"muted small",children:p.detail}),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(j=>f(Ce(j))),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(j=>f(Ce(j))),children:"停止"})]})]}),h!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{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(ee,{name:"arrow"}),"从这里开始运行"]}),n.jsx("span",{className:"muted small",children:"这一步和它后面的会运行,前面的不运行(例如前面已经跑过了)"})]}),n.jsx("button",{className:"danger-outline small-button",onClick:l,children:"删除这个节点"})]})}const Gd={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]},i8=()=>({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"}),r8=(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")},Z_="adg.pipelines.last",a8=()=>{try{return localStorage.getItem(Z_)}catch{return null}},o8=e=>{try{localStorage.setItem(Z_,e)}catch{}};function l8({client:e,openSettings:t,arg:s}){const i=ke(e.connection.status),r=mn(3e4),[o,l]=v.useState(null),[u,d]=v.useState(null),[h,f]=v.useState(null),[p,g]=v.useState(""),[x,b]=v.useState([]),[k,j]=v.useState(null),[N,C]=v.useState(null),[S,_]=v.useState(null),[z,P]=v.useState(null),[H,B]=v.useState(0);v.useEffect(()=>e.connection.on("pipelines/changed",()=>B(re=>re+1)),[e]);const O=ke(e.capabilities),[T,D]=v.useState(null),[U,A]=v.useState(0);v.useEffect(()=>e.connection.on("schedule/changed",()=>A(re=>re+1)),[e]),v.useEffect(()=>{if(i.state!=="open"||!O.has("schedule"))return;let re=!0;return e.connection.call("schedule/status",{}).then(X=>{re&&D(X.settings)}).catch(()=>{}),()=>{re=!1}},[e,i.state,O,U]);const I=async re=>{try{D((await e.connection.call("schedule/settings/set",re)).settings)}catch(X){P(Ce(X))}};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(X=>{if(!re)return;const se=[...X.items].sort(r8);l(se);const ae=a8();d(_e=>{var ze,Te;return _e??((ze=se.find(fe=>fe.id===ae))==null?void 0:ze.id)??((Te=se[0])==null?void 0:Te.id)??null})}).catch(X=>{re&&P(Ce(X))}),()=>{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(X=>X.id!==u)))return;let re=!0;return e.connection.call("pipelines/get",{id:u}).then(X=>{if(!re)return;const se=NR(X);o8(se.id),f(se),g(JSON.stringify(se)),C(null)}).catch(()=>{}),e.connection.call("pipelines/runs",{pipelineId:u,limit:10}).then(X=>{re&&b(X.items)}).catch(()=>{}),j(null),()=>{re=!1}},[e,u,i.state,H]),v.useEffect(()=>e.connection.on("pipelines/run",re=>{re.pipelineId===u&&b(X=>[re,...X.filter(se=>se.id!==re.id)].sort((se,ae)=>ae.startedAt-se.startedAt).slice(0,10))}),[e,u]);const R=h!==null&&JSON.stringify(h)!==p,L=h!==null&&o!==null&&o.every(re=>re.id!==h.id),K=x.find(re=>{var X;return re.id===(k??((X=x[0])==null?void 0:X.id))}),F=x.find(re=>re.state==="running"),q=F!==void 0&&(F.stopping!==void 0||S==="cancel");v.useEffect(()=>{if(h===null||!h.nodes.some(X=>!Zi(X))){C(null);return}const re=setTimeout(()=>{e.connection.call("pipelines/check",{pipeline:h}).then(C).catch(()=>{})},400);return()=>clearTimeout(re)},[e,h]);const V=async(re,X)=>{_(re),P(null);try{await X()}catch(se){P(Ce(se))}finally{_(null)}},Z=()=>V("save",async()=>{if(h===null)return;const re=await e.connection.call("pipelines/save",{pipeline:h});f(re.pipeline),g(JSON.stringify(re.pipeline)),C(re.check),d(re.pipeline.id)}),Q=re=>V("run",async()=>{if(h===null)return;(R||L)&&await Z();const X=await e.connection.call("pipelines/run",{id:h.id,...re===void 0?{}:{from:re}});j(X.id)}),G=()=>V("remove",async()=>{h!==null&&(L||await e.connection.call("pipelines/remove",{id:h.id}),f(null),d(null))}),ne=v.useCallback(re=>f(re),[]),te=()=>{const re=i8();f(re),g(""),d(re.id),b([]),C(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(d8,{list:o??[],current:h,isNew:L,now:r,onPick:d}),n.jsxs("div",{className:"page-actions",children:[n.jsxs("button",{className:"small-button",onClick:()=>t("schedule"),children:[n.jsx(ee,{name:"settings"}),"定时与自启"]}),n.jsxs("button",{className:"primary small-button",onClick:te,children:[n.jsx(ee,{name:"plus"}),"新建流水线"]})]})]}),n.jsx("div",{className:"pipeline-main",children:h===null?n.jsxs("div",{className:"empty",children:[n.jsx(ee,{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=>f({...h,name:re.target.value})}),h.draft===!0&&n.jsx("span",{className:"badge warn",title:"agent 生成的草稿:保存后才会按定时运行",children:"agent 草稿"}),R&&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}),"正在停止…"]}):F!==void 0?n.jsx("button",{className:"danger-outline small-button",disabled:S!==null,onClick:()=>void V("cancel",()=>e.connection.call("pipelines/cancel",{runId:F.id})),children:"取消运行"}):n.jsxs("button",{className:"small-button",disabled:S!==null||!h.nodes.some(re=>!Zi(re))||(N==null?void 0:N.ok)===!1,onClick:()=>void Q(),children:[n.jsx(ee,{name:"arrow"}),"运行"]}),n.jsx("button",{className:"primary small-button",disabled:S!==null||!R&&!L&&h.draft!==!0,onClick:()=>void Z(),children:S==="save"?"保存中…":h.draft===!0&&!R?"确认并保存":"保存"}),n.jsx("button",{className:"small-button",disabled:S!==null||F!==void 0,onClick:()=>void Ms({title:`删除流水线「${h.name}」?`,message:"它的步骤和定时都会删掉,不能撤销。",confirmLabel:"删除",danger:!0}).then(re=>{re&&G()}),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:["已收到停止指令。",F.stopping??"正在通知正在运行的步骤…"]})]}),z!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:z})]}),n.jsx(t8,{client:e,pipeline:h,onChange:ne,run:K,check:N,runFrom:F!==void 0||S!==null||(N==null?void 0:N.ok)===!1?void 0:re=>void Q(re),idle:n.jsx(h8,{pipeline:h,check:N,runs:x,shownRun:K==null?void 0:K.id,onShowRun:j,others:o??[],onChange:ne,now:r,startup:T,onStartup:re=>void I(re)})},h.id)]})})]})}function c8({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 u8({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 ${Gd[o.state][0]}`,children:Gd[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:gt(o.startedAt,i)})]},o.id))}),n.jsx("p",{className:"muted small",children:"选中一次运行,画布上的节点会显示它的状态;点节点看详情和对应的脚本运行。"})]})}function d8({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(ee,{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(ee,{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?"":` · ${gt(d.lastRun.startedAt,i)}`]})]}),d.draft?n.jsx("span",{className:"badge warn",children:"草稿"}):d.lastRun!==void 0?n.jsx("span",{className:`badge ${Gd[d.lastRun.state][0]}`,children:Gd[d.lastRun.state][1]}):null]},d.id)),e.length===0&&n.jsx("div",{className:"muted small pad",children:"还没有保存的流水线"})]})]})}function h8({pipeline:e,check:t,runs:s,shownRun:i,onShowRun:r,others:o,onChange:l,now:u,startup:d,onStartup:h}){const[f,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":f==="check",className:f==="check"?"active":"",onClick:()=>p("check"),children:["检查",g>0?` · ${g}`:""]}),n.jsx("button",{role:"tab","aria-selected":f==="runs",className:f==="runs"?"active":"",onClick:()=>p("runs"),children:"运行记录"}),n.jsx("button",{role:"tab","aria-selected":f==="schedule",className:f==="schedule"?"active":"",onClick:()=>p("schedule"),children:"定时与失败"})]}),f==="check"&&(t===null?n.jsx("p",{className:"muted small pad",children:"加上步骤后会自动检查。"}):n.jsx(c8,{check:t,pipeline:e})),f==="runs"&&n.jsx(u8,{runs:s,shown:i,onShow:r,now:u}),f==="schedule"&&n.jsx(f8,{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 m8=["日","一","二","三","四","五","六"],Tj={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function f8({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}}),f=v.useMemo(()=>u.split(/[,,\s]+/).map(g=>g.trim()).filter(Boolean).map(g=>/^\d:\d\d$/.test(g)?`0${g}`:g),[u]),p=f.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(f)].sort()})}}),p.length>0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsxs("span",{children:["时间写成 HH:MM:",p.join("、")]})]}),n.jsxs("div",{className:"chip-row",role:"group","aria-label":"星期",children:[m8.map((g,x)=>n.jsxs("button",{className:`chip ${l.days.includes(x)?"active":""}`,onClick:()=>h({days:l.days.includes(x)?l.days.filter(b=>b!==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(Ot,{id:"pl-after",value:l.after??"",onChange:g=>{const{after:x,...b}=l;s({...e,schedule:g===""?b:{...b,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(Ot,{id:"pl-fail","aria-label":"重试次数",value:String(e.onFailure.retries),options:B_,onChange:g=>s({...e,onFailure:{...e.onFailure,retries:Number(g)}})}),n.jsx(Ot,{"aria-label":"仍失败时",value:e.onFailure.then,options:H_,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(Ot,{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 分钟内还有定时任务就不",Tj[e.powerAfter],"。在这里手动点运行、或运行被取消时不会",Tj[e.powerAfter],"。",e.powerAfter==="shutdown"?"关机会强制关闭所有程序。":"想让电脑按时醒来跑定时任务,在「设置 → 定时与自启」打开定时唤醒。"]})]})}const Mj=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"}),Rj={fired:["ok","已运行"],missed:["warn","错过"],skipped:["","跳过"],failed:["warn","没能运行"]};function p8({client:e}){const t=ke(e.connection.status),s=mn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(0),[u,d]=v.useState(!1),[h,f]=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(b=>b===null?b:{...b,power:x})),[e]),v.useEffect(()=>{if(t.state!=="open")return;let x=!0;return e.connection.call("schedule/status",{}).then(b=>{x&&r(b)}).catch(b=>{x&&f(Ce(b))}),()=>{x=!1}},[e,t.state,o]);const p=async x=>{d(!0),f(null);try{r(await e.connection.call("schedule/settings/set",x))}catch(b){f(Ce(b))}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(ee,{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(ee,{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 任务计划程序中注册,下次在 ${Mj(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,b)=>n.jsxs("li",{children:[n.jsx("span",{className:"version-name",children:Mj(x.at)}),n.jsx("span",{children:x.pipelineName})]},b))})]}),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,b)=>{var k,j;return n.jsxs("li",{children:[n.jsx("span",{className:`badge ${((k=Rj[x.outcome])==null?void 0:k[0])??""}`,children:((j=Rj[x.outcome])==null?void 0:j[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:gt(x.at,s)})]},b)})})]}),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(ee,{name:"alert"}),n.jsx("span",{children:h})]})]})}const g8={id:"pipelines",title:"编排",milestone:"M4",requires:["pipelines","scripts","runs"],pages:[{id:"pipelines",title:"编排",icon:"flow",order:20,agent:"pipelines",component:l8}]},x8={id:"schedule",title:"定时与自启",milestone:"M4",requires:["schedule","pipelines"],settingsPages:[{id:"schedule",title:"定时与自启",order:9,component:p8}]},Sa=new Map;let xg=0;const vg=new Set;function v8(e,t){let s=Sa.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&&Sa.get(e)===i&&Sa.delete(e)},()=>{Sa.get(e)===i&&Sa.delete(e)}),Sa.set(e,s)}return s}function W_(){Sa.clear(),xg++;for(const e of vg)e()}const rp=new Map;function y8(e){let t=rp.get(e);if(t===void 0){const i=["games/changed","scripts/changed","packs/changed"].map(r=>e.connection.on(r,W_));t={count:0,off:()=>{for(const r of i)r()}},rp.set(e,t)}t.count++;const s=t;return()=>{--s.count===0&&(s.off(),rp.delete(e))}}function V_({client:e,iconKey:t,load:s,name:i,className:r=""}){const o=ke(e.connection.status),[l,u]=v.useState(null),[d,h]=v.useState(xg);return v.useEffect(()=>{const f=()=>h(xg);return vg.add(f),()=>{vg.delete(f)}},[]),v.useEffect(()=>y8(e),[e]),v.useEffect(()=>{if(o.state!=="open")return;let f=!0;return v8(t,s).then(p=>{f&&u(p)},()=>{}),()=>{f=!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 b8({client:e,game:t,className:s=""}){return n.jsx(V_,{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 k8=864e5;function j8({client:e,openSession:t,openPage:s,arg:i}){const r=ke(e.connection.status),o=mn(3e4),[l,u]=v.useState(null),[d,h]=v.useState(0),[f,p]=v.useState(i??""),[g,x]=v.useState(null),[b,k]=v.useState(null),[j,N]=v.useState(null),[C,S]=v.useState(!1),[_,z]=v.useState(null),P=v.useCallback(()=>z(null),[]),H=v.useCallback(()=>S(!1),[]);v.useEffect(()=>{i!==void 0&&p(i)},[i]),v.useEffect(()=>e.connection.on("games/changed",()=>h(G=>G+1)),[e]),v.useEffect(()=>{if(r.state!=="open")return;let G=!0;return e.connection.call("games/list",{}).then(ne=>{G&&u(ne)}).catch(ne=>{G&&k(Ce(ne))}),()=>{G=!1}},[e,r.state,d]);const B=(l==null?void 0:l.games)??[],O=u3(B,Qr),T=B.find(G=>G.id===f),D=T===void 0,U=G=>{p(G),z(null),N(null),k(null)},A=async(G,ne)=>{x(G),k(null),N(null);try{const te=await ne();typeof te=="string"&&N(te)}catch(te){k(Ce(te))}finally{x(null),h(te=>te+1)}},I=G=>A(`refresh:${G??""}`,async()=>{const{results:ne}=await e.connection.call("games/refresh",G===void 0?{}:{game:G}),te=se=>{var ae;return((ae=B.find(_e=>_e.id===se))==null?void 0:ae.name)??se},re=se=>{var ae;return((ae=B.find(_e=>_e.id===se))==null?void 0:ae.sources.some(_e=>_e.auto))===!0},X=ne.filter(se=>re(se.game)&&!se.ok);if(X.length>0)throw new Error(X.map(se=>`${te(se.game)}没读到:${se.detail??"未知原因"}`).join(";"));return G===void 0?`刷新完成:${ne.filter(se=>re(se.game)).map(se=>`${te(se.game)} ${[...se.count>0||se.notices===void 0?[`${se.count} 个活动`]:[],...se.notices===void 0?[]:[`${se.notices} 条公告`]].join("、")}`).join(";")}`:void 0}),R=G=>A("create",async()=>{const{game:ne}=await e.connection.call("games/create",{name:G});p(ne)}),L=G=>{const ne=T;A("installed",async()=>{let te;for(const re of G)te??(te=(await e.connection.call("games/create",{name:re})).game);te!==void 0&&(ne!==void 0&&ne.own===!0&&ne.sources.length===0&&ne.id!==te&&await e.connection.call("games/remove",{game:ne.id}),p(te))})},K=async G=>{G.own===!0&&!await Ms({title:`删除${G.name}?`,message:`会删掉${G.name}和它的活动记录(你自己记的也一起删)。脚本、脚本包和技能不受影响;以后可以在「更多游戏」里按名字再加回来。`,confirmLabel:"删除",danger:!0})||await A(`remove:${G.id}`,async()=>(await e.connection.call("games/remove",{game:G.id}),p(""),G.own===!0?`已删除${G.name}`:`${G.name}不再显示:在「更多游戏」里勾上或按名字添加就回来`))},F=G=>{const ne=((l==null?void 0:l.activities)??[]).filter(X=>X.game===G.id&&(X.startsAt??0)<=o&&Math.max(X.endsAt??1/0,X.shopEndsAt??0)>o),te=ne.filter(X=>ms(X).state!=="finished"&&X.endsAt!==void 0&&X.endsAt>o&&X.endsAt-o<((l==null?void 0:l.settings.report.soonDays)??3)*k8).length,re=`${ne.length} 个进行中${G.refreshed===void 0?"":` · ${gt(G.refreshed.at,o)}刷新`}${G.followed===!0?" · 关注的游戏":""}`;return{mine:ne,soon:te,title:re}},q=v.useContext(Qw),V=q===null?null:n.jsxs("div",{className:"rail-games",role:"tablist","aria-label":"游戏",children:[n.jsxs("button",{role:"tab","aria-selected":D,className:`rail-item rail-game rail-overview ${D?"active":""}`,title:"全部活动:所有游戏的活动排在一条时间线上",onClick:()=>U(""),children:[n.jsx("span",{className:"rail-avatar overview-avatar",children:n.jsx(ee,{name:"timeline"})}),n.jsx("span",{className:"rail-label",children:"全部活动"})]}),B.map(G=>{const{soon:ne,title:te}=F(G);return n.jsxs("button",{role:"tab","aria-selected":(T==null?void 0:T.id)===G.id,className:`rail-item rail-game ${(T==null?void 0:T.id)===G.id?"active":""}`,style:{"--game":O.get(G.id)},title:`${G.name}:${te}`,onClick:()=>U(G.id),children:[n.jsx(b8,{client:e,game:G}),n.jsx("span",{className:"rail-label",children:G.name}),ne>0&&n.jsx("span",{className:"rail-badge",title:`${ne} 个快结束还没做完`,children:ne})]},G.id)}),n.jsx(Ql,{icon:"plus",label:"更多游戏",title:"选择游戏页上显示哪些游戏,或按名字添加",active:C,onClick:()=>S(!0)})]}),Z=(T==null?void 0:T.name)??"全部活动",Q=G=>{const{mine:ne,soon:te}=F(G);return n.jsxs("button",{role:"tab","aria-selected":(T==null?void 0:T.id)===G.id,className:`game-tab ${(T==null?void 0:T.id)===G.id?"active":""}`,style:{"--game":O.get(G.id)},title:`${ne.length} 个进行中${G.refreshed===void 0?"":` · ${gt(G.refreshed.at,o)}刷新`}${G.followed===!0?" · 关注的游戏":""}`,onClick:()=>U(G.id),children:[n.jsx("span",{className:"game-dot"}),G.name,te>0&&n.jsx("span",{className:"game-tab-badge",title:`${te} 个快结束还没做完`,children:te})]},G.id)};return n.jsxs("section",{className:"main games-page",children:[q!==null&&V!==null&&qa.createPortal(V,q),n.jsxs("header",{className:"page-header games-header",children:[n.jsx("div",{className:"breadcrumb",children:n.jsx("h1",{children:q===null?"游戏":Z})}),q===null?n.jsxs("nav",{className:"game-tabs",role:"tablist","aria-label":"游戏",children:[n.jsxs("button",{role:"tab","aria-selected":D,className:`game-tab ${D?"active":""}`,onClick:()=>U(""),children:[n.jsx(ee,{name:"timeline"}),"全部活动"]}),n.jsx("span",{className:"game-tabs-divider"}),B.map(Q),n.jsxs("button",{className:`game-tab add ${C?"active":""}`,"aria-haspopup":"dialog",title:"选择游戏页上显示哪些游戏,或按名字添加",onClick:()=>S(!0),children:[n.jsx(ee,{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(ee,{name:"refresh"}),g==="refresh:"?"刷新中…":"刷新全部"]})})]}),n.jsxs("div",{className:"games-body",children:[b!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:b})]}),j!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(ee,{name:"info"}),n.jsx("span",{children:j})]}),l!==null&&B.length===0&&n.jsxs("div",{className:"empty",children:[n.jsx(ee,{name:"gamepad"}),n.jsx("p",{children:"没有游戏。点「更多游戏」勾选几个,或按名字添加。"})]}),l!==null&&D&&B.length>0&&n.jsx(qD,{client:e,games:B,activities:l.activities,now:o,soonDays:l.settings.report.soonDays,onOpenGame:U,onChanged:()=>h(G=>G+1)}),l!==null&&T!==void 0&&n.jsx(t3,{client:e,game:T,activities:l.activities.filter(G=>G.game===T.id),notices:(l.notices??[]).filter(G=>G.game===T.id),color:O.get(T.id)??Qr[0],now:o,soonDays:l.settings.report.soonDays,busy:g,open:(_==null?void 0:_.kind)==="activity"?_.id:null,adding:(_==null?void 0:_.kind)==="add",onOpen:G=>z({kind:"activity",id:G}),onAdd:()=>z({kind:"add",game:T.id}),onRefresh:()=>void I(T.id),onRead:()=>void A(`read:${T.id}`,async()=>{const{sessionId:G}=await e.connection.call("games/read",{game:T.id});t(G)}),onReadWeb:G=>void A(`read-web:${T.id}`,async()=>{const{sessionId:ne}=await e.connection.call("games/read",{game:T.id,how:"web",...G===void 0?{}:{source:G}});t(ne)}),onDiscover:()=>void A(`discover:${T.id}`,async()=>(await e.connection.call("games/discover",{game:T.id}),`agent 正在找${T.name}的活动来源,找到后这个页面会更新`)),onRemove:()=>void K(T),onChanged:()=>h(G=>G+1),openSession:t,openScripts:()=>s("scripts")},T.id)]}),C&&n.jsxs(yd,{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(ee,{name:"close"})})]}),n.jsx("div",{className:"dialog-form catalog-dialog-body",children:n.jsx(QD,{client:e,onChanged:()=>h(G=>G+1),onCreate:G=>{H(),R(G)}})})]}),T!==void 0&&!C&&n.jsx(DS,{client:e,target:{games:[{id:T.id,name:T.name,aliases:T.aliases,...T.sra===void 0?{}:{sra:T.sra}}]},label:`「${T.name}」`,onInstalled:L}),l!==null&&_!==null&&(()=>{const G=()=>h(te=>te+1);if(_.kind==="add"){const te=B.find(re=>re.id===_.game);return te===void 0?null:n.jsx(yd,{color:O.get(te.id)??Qr[0],label:"添加活动",onClose:P,children:n.jsx("div",{className:"dialog-form",children:n.jsx(fx,{client:e,game:te,onCancel:P,onDone:re=>{z({kind:"activity",id:re.id,saved:re}),G()}})})})}const ne=l.activities.find(te=>te.id===_.id)??_.saved;return ne===void 0?null:n.jsx(yd,{color:O.get(ne.game)??Qr[0],label:`${ne.name}的详情`,onClose:P,children:n.jsx(f3,{client:e,activity:ne,game:B.find(te=>te.id===ne.game),now:o,soonDays:l.settings.report.soonDays,onClose:P,onChanged:G,openSession:t},ne.id)})})()]})}function N8({client:e,openSettings:t}){const s=ke(e.connection.status),i=mn(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(f=>f+1)),[e]),v.useEffect(()=>{if(s.state!=="open")return;let f=!0;return e.connection.call("games/list",{}).then(p=>{f&&(o(p),h(null))}).catch(p=>{f&&h(Ce(p))}),()=>{f=!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(ee,{name:"alert"}),n.jsx("span",{children:d})]}),r!==null&&n.jsx(w8,{client:e,data:r,games:r.games,now:i,openSettings:t,onChanged:()=>u(f=>f+1)})]})]})}function w8({client:e,data:t,games:s,now:i,openSettings:r,onChanged:o}){const l=t.settings.report,[u,d]=v.useState(null),[h,f]=v.useState(!1),[p,g]=v.useState(null),[x,b]=v.useState(null);v.useEffect(()=>{let N=!0;return e.connection.call("games/report/preview",{}).then(C=>{N&&d(C)}).catch(()=>{}),()=>{N=!1}},[e,t]);const k=async N=>{f(!0),g(null);try{await e.connection.call("games/settings/set",{report:N}),o()}catch(C){g(Ce(C))}finally{f(!1)}},j=async()=>{f(!0),g(null),b(null);try{const{channels:N}=await e.connection.call("games/report/send",{});b(N.length===0?"没有发出去:还没有设置好的聊天渠道。":`已发到${N.join("、")}。`),o()}catch(N){g(Ce(N))}finally{f(!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:N=>void k({enabled:N.target.checked})}),"每天定时发送"]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:l.ai,disabled:h,onChange:N=>void k({ai:N.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:N=>{/^\d{2}:\d{2}$/.test(N.target.value)&&N.target.value!==l.at&&k({at:N.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:N=>{const C=Math.max(1,Math.min(30,Math.round(Number(N.target.value)||3)));C!==l.soonDays&&k({soonDays:C})}},l.soonDays)]})]}),n.jsx("div",{className:"field-title",children:"包括的游戏(都不选就是全部)"}),n.jsx("div",{className:"chip-row",children:s.map(N=>{const C=l.games.includes(N.id);return n.jsx("button",{className:`chip chip-button ${C?"active":""}`,disabled:h,onClick:()=>void k({games:C?l.games.filter(S=>S!==N.id):[...l.games,N.id]}),children:N.name},N.id)})}),n.jsxs("p",{className:"muted small",children:[t.report.lastSentAt===void 0?"还没发过。":`上次:${gt(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(ee,{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 j(),children:[n.jsx(ee,{name:"send"}),h?"发送中…":"现在发送"]})]}),x!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(ee,{name:"info"}),n.jsx("span",{children:x})]}),u!==null&&n.jsxs("div",{className:"report-preview",children:[n.jsx("strong",{children:u.title}),`
233
+
234
+ `,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:gt(t.report.lastSentAt,i)})]})}),n.jsx("div",{className:"report-preview",children:t.report.lastText})]})]})}const S8={id:"games",title:"游戏看板",milestone:"M6",requires:["games"],pages:[{id:"games",title:"游戏",icon:"library",order:-10,component:j8},{id:"daily-report",title:"日报",icon:"send",order:10,agent:"games",component:N8}]},sl="MultiGameAssistant",q_=e=>e.pack==="script"?"脚本包":e.pack==="game"?"游戏包":"技能",yg=e=>e.author??e.repo.split("/")[0]??e.repo;function _8(e,t,s){const i=x=>e.find(b=>b.pack==="script"&&b.name===x),r=x=>{var k,j;if(x.pack==="game")return x.game??x.games[0];if(x.games[0]!==void 0)return x.games[0];const b=x.pack==="script"?x.name:x.scripts[0];if(b!==void 0)return((k=i(b))==null?void 0:k.games[0])??((j=t.find(N=>N.scripts.includes(b)))==null?void 0:j.id)},o=x=>x.pack==="script"?x.name:x.pack==="game"?void 0:x.scripts[0],l=x=>{var b,k;return((b=t.find(j=>j.id===x))==null?void 0:b.name)??((k=e.find(j=>j.pack==="game"&&j.game===x))==null?void 0:k.title)??x},u=x=>{var b,k;return((b=i(x))==null?void 0:b.title)??((k=s.find(j=>j.id===x||j.packId===x))==null?void 0:k.name)??x},d=x=>{const b=t.findIndex(k=>k.id===x);return b<0?t.length:b},h=x=>s.some(b=>b.id===x||b.packId===x),f=x=>x.pack==="game"?0:x.pack==="script"?1:2,p=(x,b)=>{const k=new Map;for(const j of x)k.set(b(j),[...k.get(b(j))??[],j]);return k},g=p(e,x=>r(x)??"");return[...g.keys()].sort((x,b)=>+(x==="")-+(b==="")||d(x)-d(b)||l(x).localeCompare(l(b))).map(x=>{const b=p(g.get(x),k=>o(k)??"");return{key:x,name:x===""?"通用":l(x),children:[...b.keys()].sort((k,j)=>+(j==="")-+(k==="")||Number(h(j))-Number(h(k))||u(k).localeCompare(u(j))).map(k=>{const j=p(b.get(k),yg);return{key:k,name:k===""?x===""?"不分脚本":"游戏本身":u(k),children:[...j.keys()].sort((N,C)=>+(C===sl)-+(N===sl)||N.localeCompare(C)).map(N=>({key:N,name:N,children:[...j.get(N)].sort((C,S)=>f(C)-f(S)||(C.title??C.name).localeCompare(S.title??S.name))}))}})}})}function E8({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((f,p)=>f+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(ee,{name:"chevron-down",className:"skills-chevron"}),n.jsx(ee,{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(f=>n.jsxs("div",{className:"skills-sub hub-sub",children:[n.jsxs("div",{className:"hub-script-label",children:[n.jsx(ee,{name:f.key===""?"gamepad":"package"}),f.name]}),f.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:q_(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))]},f.key||":own"))]},u)})})}function C8({client:e,item:t,where:s,busy:i,now:r,act:o,onOpen:l}){const[u,d]=v.useState(null),h=t.installed,f=[...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=f.find(S=>S.version===p),b=t.blocked===void 0&&t.incompatible===void 0,k=S=>i===`${S}:${t.name}`;v.useEffect(()=>{let S=!0;return d(null),e.connection.call("skillhub/preview",{name:t.name}).then(_=>{S&&d(_.content.replace(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/,""))},()=>{S&&d("")}),()=>{S=!1}},[e,t.name,t.hash]);const j=()=>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 现在就能用"}`)),N=()=>void o(`update:${t.name}`,async()=>(await e.connection.call("skillhub/update",{name:t.name})).state==="updated"?`${t.title??t.name} 已更新`:"已是最新"),C=()=>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(ee,{name:t.pack==="game"?"gamepad":t.pack==="script"?"package":"sparkles"}),q_(t)," · 作者 ",yg(t),yg(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(ee,{name:t.pack==="script"||t.scripts.length>0?"package":"gamepad"}),s]}),t.version!==void 0&&n.jsx("span",{className:"badge",children:t.version}),f.length>1&&n.jsxs("span",{className:"badge",title:f.map(S=>S.version).join("、"),children:["共 ",f.length," 个版本"]}),h!==void 0&&n.jsxs("span",{className:"badge ok",title:`${gt(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&&b&&n.jsxs("button",{className:"small-button primary",disabled:i!==null,onClick:j,children:[n.jsx(ee,{name:"download"}),k("install")?"下载中…":"下载"]}),(h==null?void 0:h.update)===!0&&t.incompatible===void 0&&n.jsx("button",{className:"small-button primary",disabled:i!==null,onClick:N,children:k("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,",没有下载(以你已有的为准)"]})]}),f.length>1&&b&&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(Ot,{className:"skill-version-select",value:p,onChange:g,disabled:i!==null,"aria-label":"版本",options:f.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:C,children:k("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 A8({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(`
235
+ `)),l=v.useMemo(()=>r.split(/\r?\n/).map(d=>d.trim()).filter(Boolean).map(d=>{const[h,f]=d.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("@");return{repo:h??"",branch:f??"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 Dx=[{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:"软件自带、维持基本功能的技能:受保护,不能改,随软件更新"}],$8=Object.fromEntries(Dx.map(e=>[e.id,e.label])),I8=new Set(["script-pack","skill"]),G_=e=>{var t,s;return((t=e.skill)==null?void 0:t.removable)===!0||((s=e.skill)==null?void 0:s.ownPack)===!0};function T8(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 K_="adg:skills:folded-kinds";function M8(){try{return new Set(JSON.parse(localStorage.getItem(K_)??"[]"))}catch{return new Set}}function R8(e){try{localStorage.setItem(K_,JSON.stringify([...e]))}catch{}}const ja="",So=":general";function O8({client:e,arg:t}){var On;const s=ke(e.connection.status),i=ke(e.capabilities),r=mn(6e4),[o,l]=v.useState(null),[u,d]=v.useState(null),[h,f]=v.useState(""),[p,g]=v.useState(ja),[x,b]=v.useState((t==null?void 0:t.startsWith("hub"))===!0?"hub":"mine"),[k,j]=v.useState((t==null?void 0:t.startsWith("hub:"))===!0?t.slice(4):""),[N,C]=v.useState(""),[S,_]=v.useState(!1),[z,P]=v.useState(t===void 0||t.startsWith("hub")?"":t),[H,B]=v.useState(null),[O,T]=v.useState(null),[D,U]=v.useState(null),[A,I]=v.useState(null),[R,L]=v.useState(0),[K,F]=v.useState(0),[q,V]=v.useState(!1),[Z,Q]=v.useState(null),[G,ne]=v.useState(!1),[te,re]=v.useState(M8),X=ce=>re(J=>{const he=new Set(J);return he.delete(ce)||he.add(ce),R8(he),he}),se=((On=ih(e).data)==null?void 0:On.scripts)??[],[ae,_e]=v.useState([]),ze=i.has("skillhub");v.useEffect(()=>{t!==void 0&&(t.startsWith("hub")?(b("hub"),t.startsWith("hub:")&&j(t.slice(4))):(b("mine"),P(t)),Q(null))},[t]),v.useEffect(()=>e.connection.on("skills/changed",()=>L(ce=>ce+1)),[e]),v.useEffect(()=>e.connection.on("skillhub/changed",()=>F(ce=>ce+1)),[e]),v.useEffect(()=>{if(s.state!=="open"||!i.has("games"))return;let ce=!0;return e.connection.call("games/list",{}).then(J=>{ce&&_e(J.games)},()=>{}),()=>{ce=!1}},[e,s.state,i,K]),v.useEffect(()=>{if(s.state!=="open")return;let ce=!0;return e.connection.call("skills/list",{}).then(J=>{ce&&l(J.skills)},J=>{ce&&T(Ce(J))}),()=>{ce=!1}},[e,s.state,R]);const Te=async(ce=!1)=>{const J=await e.connection.call("skillhub/list",ce?{refresh:!0}:{});return d(J),J};v.useEffect(()=>{if(s.state!=="open"||!ze)return;let ce=!0;return e.connection.call("skillhub/list",{}).then(J=>{ce&&d(J)},J=>{ce&&T(Ce(J))}),()=>{ce=!1}},[e,s.state,ze,K]);const fe=v.useMemo(()=>{const ce=(u==null?void 0:u.items)??[];return(o??[]).map(J=>{const he=J.source==="hub"?ce.find(we=>we.name===J.name&&we.installed!==void 0):void 0;return{name:J.name,title:(he==null?void 0:he.title)??J.name,description:J.description,category:T8(J,he),skill:J,...he===void 0?{}:{hub:he},...J.owner===void 0?{}:{owner:J.owner}}})},[o,u]),ye=ce=>eS(ce.owner,se,ae),Fe=ce=>[...new Set(ye(ce).map(tS))].join("、"),Re=ce=>{var Ue,ct,jt,Be,De,Ye;const J=(Ue=ye(ce).find(vt=>vt.game!==void 0))==null?void 0:Ue.game;if(J!==void 0)return J;const he=((ct=ce.hub)==null?void 0:ct.game)??((jt=ce.hub)==null?void 0:jt.games[0])??((De=(Be=ce.owner)==null?void 0:Be.games)==null?void 0:De[0]);if(he===void 0)return;const we=Od(he,ae);return we!==void 0?{id:we.id,name:we.name}:{id:he,name:((Ye=((u==null?void 0:u.items)??[]).find(vt=>vt.pack==="game"&&vt.game===he))==null?void 0:Ye.title)??he}},Qe=ce=>{const J=new Map;for(const we of ce){const Ue=Re(we)??{id:So,name:"通用"},ct=J.get(Ue.id)??{...Ue,items:[]};ct.items.push(we),J.set(Ue.id,ct)}const he=we=>{const Ue=ae.findIndex(ct=>ct.id===we);return Ue<0?ae.length:Ue};return[...J.values()].sort((we,Ue)=>+(we.id===So)-+(Ue.id===So)||he(we.id)-he(Ue.id)||we.name.localeCompare(Ue.name))},Ke=h.trim().toLowerCase(),_t=v.useMemo(()=>fe.filter(ce=>{var he,we;if(Ke!==""&&!`${ce.name} ${ce.title} ${ce.description} ${((he=ce.skill)==null?void 0:he.whenToUse)??""}`.toLowerCase().includes(Ke))return!1;if(p===ja)return!0;const J=ye(ce);return p===So?J.length===0:J.some(Ue=>{var ct;return((ct=Ue.game)==null?void 0:ct.id)===p})||((we=ce.hub)==null?void 0:we.game)===p}),[fe,Ke,p,se,ae]),Mt=v.useMemo(()=>Dx.map(ce=>({...ce,items:_t.filter(J=>J.category===ce.id).sort((J,he)=>J.title.localeCompare(he.title))})).filter(ce=>ce.items.length>0||ce.id==="skill"&&Ke===""&&p===ja),[_t,Ke,p]).map(ce=>({...ce,groups:I8.has(ce.id)?Qe(ce.items):void 0})),En=Mt.flatMap(ce=>{var J;return((J=ce.groups)==null?void 0:J.flatMap(he=>he.items))??ce.items}),rt=_t.find(ce=>ce.name===z)??En[0];v.useEffect(()=>{if(ne(!1),V(!1),rt===void 0){B(null);return}let ce=!0;const J=rt.name;return e.connection.call("skills/get",{name:J}).then(he=>he.content).then(he=>{ce&&B({name:J,text:he})},he=>{ce&&(B({name:J,text:""}),T(Ce(he)))}),()=>{ce=!1}},[e,rt==null?void 0:rt.name,R,K]);const Pt=async(ce,J)=>{I(ce),T(null),U(null);try{const he=await J();typeof he=="string"&&U(he),L(we=>we+1),F(we=>we+1)}catch(he){T(Ce(he))}finally{I(null)}},rn=ce=>{Q(null),U(null),T(null),P(ce)},Zt=ce=>{b(ce),Q(null),U(null),T(null)},Qt=ce=>Pt(`remove:${ce.name}`,async()=>{var he,we;const J=((he=ce.skill)==null?void 0:he.ownPack)===!0?{title:`删除脚本包「${ce.title}」?`,message:"这是 agent 为脚本写的脚本包:它的安装方式、任务和做法都会删掉,不能恢复(需要时让 agent 重新分析这个脚本)。用它的脚本保留,只是没有这些任务了。"}:ce.category==="script-pack"?{title:`删除脚本包「${ce.title}」?`,message:"脚本页不再有它的安装方式和任务说明,agent 也不再用它的做法;已经装好的脚本不会删。以后可以在「技能库」里再下载。"}:ce.category==="game-pack"?{title:`删除游戏包「${ce.title}」?`,message:"游戏页不再按它读这个游戏的活动(SRA 公共 API 有这个游戏的话,可以在「游戏 → 更多游戏」里勾上)。以后可以在「技能库」里再下载。"}:ce.hub!==void 0?{title:`删除技能「${ce.title}」?`,message:"它的文件夹会一起删掉,agent 以后就用不到它了。以后可以在「技能库」里再下载。"}:{title:`删除技能「${ce.name}」?`,message:"它的文件夹会一起删掉,agent 以后就用不到它了。"};if(await Ms({...J,confirmLabel:"删除",danger:!0}))return ce.hub!==void 0?await e.connection.call("skillhub/remove",{name:ce.name}):((we=ce.skill)==null?void 0:we.ownPack)===!0&&ce.skill.pack!==void 0?await e.connection.call("scripts/packs/remove",{id:ce.skill.pack}):await e.connection.call("skills/remove",{name:ce.name}),P(""),`已删除 ${ce.title}`}),Ut=ce=>Pt(`update:${ce.name}`,async()=>(await e.connection.call("skillhub/update",{name:ce.name})).state==="updated"?`${ce.title} 已更新`:"已是最新"),Rn=(ce,J)=>Pt(`version:${ce.name}`,async()=>{var we,Ue;const he=await e.connection.call("skillhub/version",{name:ce.name,version:J});return`${ce.title} 换成了 ${((we=he.installed)==null?void 0:we.version)??J}${J===((Ue=ce.hub)==null?void 0:Ue.version)?"(最新)":":技能库再有更新的版本时会再提示"}`}),fn=ce=>Pt(`rollback:${ce.name}`,async()=>{var he;const J=await e.connection.call("skillhub/rollback",{name:ce.name});return`${ce.title} 已回退${((he=J.installed)==null?void 0:he.version)===void 0?"":`到 ${J.installed.version}`};技能库再有新版本时会再提示`}),Hn=()=>({name:"",description:"",content:"",scripts:[],games:p!==ja&&p!==So?[p]:[]}),Gs=ce=>{var J,he;return n.jsxs(n.Fragment,{children:[((he=(J=ce.hub)==null?void 0:J.installed)==null?void 0:he.update)===!0&&ce.hub.incompatible===void 0&&n.jsx("span",{className:"skill-dot",title:"技能库有新版"}),ce.category==="core"&&n.jsx("span",{className:"skill-row-mark",title:"核心技能:受保护,不能改",children:n.jsx(ee,{name:"shield"})})]})},ps=ce=>n.jsxs("button",{className:`script-row skill-row ${Z===null&&(rt==null?void 0:rt.name)===ce.name?"active":""}`,title:ce.hub!==void 0?`从技能库下载的(作者 ${ce.hub.author??ce.hub.repo})`:G_(ce)?"你或 agent 写的":void 0,onClick:()=>rn(ce.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:ce.title}),ce.hub!==void 0&&n.jsx("span",{className:"skill-row-from",children:"下载"})]}),n.jsx("span",{className:"muted small skills-row-desc",children:Fe(ce)||ce.description})]}),Gs(ce)]},ce.name),rs=((u==null?void 0:u.items)??[]).filter(ce=>{var J;return((J=ce.installed)==null?void 0:J.update)===!0&&ce.incompatible===void 0}).length,gs=x==="hub"&&ze||Z!==null,Cn=N.trim().toLowerCase(),as=v.useMemo(()=>((u==null?void 0:u.items)??[]).filter(ce=>Cn===""||`${ce.name} ${ce.title??""} ${ce.description} ${ce.author??""}`.toLowerCase().includes(Cn)),[u,Cn]),Kn=v.useMemo(()=>_8(as,ae,se),[as,ae,se]),Zn=Kn.flatMap(ce=>ce.children.flatMap(J=>J.children.flatMap(he=>he.children))),An=Zn.find(ce=>ce.name===k)??Zn[0],Yn=ce=>{for(const J of Kn)for(const he of J.children)if(he.children.some(we=>we.children.some(Ue=>Ue.name===ce)))return J.key===""?he.key===""?"":he.name:he.key===""?J.name:`${J.name} · ${he.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"&&ze?Zt("mine"):Q(null),children:[n.jsx(ee,{name:"back"}),"返回"]}),n.jsx("h1",{children:x==="hub"&&ze?"技能库":Z===null?"技能":Z.original===void 0?"新建技能":`编辑 ${Z.original}`})]}),n.jsx("div",{className:"page-actions",children:x==="mine"||!ze?Z===null&&n.jsxs(n.Fragment,{children:[ze&&n.jsxs("button",{className:"small-button",title:"下载脚本包、游戏包和别人写的技能",onClick:()=>Zt("hub"),children:[n.jsx(ee,{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:()=>Q(Hn()),children:[n.jsx(ee,{name:"plus"}),"新建技能"]})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"muted small skills-fetched",children:(u==null?void 0:u.fetchedAt)===void 0?"":`${gt(u.fetchedAt,r)}读取`}),n.jsxs("button",{className:"small-button",disabled:A!==null,title:"现在读一次技能库,看有没有新版本",onClick:()=>void Pt("refresh",async()=>{await Te(!0)}),children:[n.jsx(ee,{name:"refresh"}),A==="refresh"?"读取中…":"检查更新"]}),n.jsx("button",{className:`small-button ${S?"active":""}`,"aria-expanded":S,onClick:()=>_(ce=>!ce),children:"仓库"})]})})]}),x==="hub"&&ze?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(ee,{name:"search"}),n.jsx("input",{className:"text-input",value:N,onChange:ce=>C(ce.target.value),placeholder:"搜索游戏、脚本、作者或技能","aria-label":"搜索技能库"})]})}),u===null&&O===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(E8,{tree:Kn,selected:S||An==null?void 0:An.name,searching:Cn!=="",folded:te,onFold:X,onPick:ce=>{j(ce),_(!1),U(null),T(null)}})]}),n.jsx("div",{className:"scripts-detail",children:n.jsxs("div",{className:"script-detail",children:[O!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:O})]}),D!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(ee,{name:"check"}),n.jsx("span",{children:D})]}),u==null?void 0:u.errors.map(ce=>n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsxs("span",{children:["技能库读不到:",ce,u.items.length>0?"(列出的是之前读到的)":""]})]},ce)),S&&u!==null?n.jsx(A8,{repos:u.repos,disabled:A!==null,onCancel:()=>_(!1),onSave:ce=>void Pt("repos",async()=>(await e.connection.call("skillhub/repos/set",{repos:ce}),_(!1),await Te(!0),"已保存,按新的仓库读取"))}):An!==void 0?n.jsx(C8,{client:e,item:An,where:Yn(An.name),busy:A,now:r,act:Pt,onOpen:ce=>{Zt("mine"),P(ce)}},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(ee,{name:"search"}),n.jsx("input",{className:"text-input",value:h,onChange:ce=>f(ce.target.value),placeholder:"搜索脚本包、游戏包和技能","aria-label":"搜索"})]}),ae.length>0&&n.jsx(Ot,{className:"skills-filter",value:p,onChange:g,"aria-label":"只看一个游戏的",options:[{value:ja,label:"所有游戏"},...ae.map(ce=>({value:ce.id,label:ce.name})),{value:So,label:"通用",hint:"不分游戏的技能"}]})]}),(o===null||ze&&u===null)&&O===null&&n.jsx("p",{className:"muted small pad",children:"正在读取…"}),o!==null&&Ke!==""&&n.jsx("p",{className:"muted small skills-found",children:_t.length===0?"没有匹配的。":`找到 ${_t.length} 个`}),Mt.map(ce=>{var we;const J=Ke!==""||p!==ja,he=J||!te.has(ce.id);return n.jsxs("div",{className:`skills-group ${he?"":"folded"}`,children:[n.jsxs("div",{className:"skills-section-head",title:ce.hint,children:[n.jsxs("button",{className:"skills-fold","aria-expanded":he,onClick:()=>X(ce.id),children:[n.jsx(ee,{name:"chevron-down",className:"skills-chevron"}),n.jsx(ee,{name:ce.icon,className:"skills-section-icon"}),n.jsx("span",{className:"skills-group-name",children:ce.label}),n.jsx("span",{className:"skills-count",children:ce.items.length})]}),ce.id==="skill"&&n.jsx("button",{className:"icon-button skills-add",title:"新建一个技能","aria-label":"新建技能",disabled:s.state!=="open",onClick:()=>Q(Hn()),children:n.jsx(ee,{name:"plus"})})]}),he&&ce.items.length===0&&n.jsx("p",{className:"muted small skills-empty",children:ce.id==="skill"?"agent 做成一件事后会提议存成技能;也可以自己写一个,或在「技能库」里下载。":"没有"}),he&&ce.groups===void 0&&ce.items.map(ps),he&&((we=ce.groups)==null?void 0:we.map(Ue=>{const ct=`${ce.id}/${Ue.id}`,jt=J||!te.has(ct);return n.jsxs("div",{className:`skills-sub ${jt?"":"folded"}`,children:[n.jsxs("button",{className:"skills-sub-head","aria-expanded":jt,onClick:()=>X(ct),children:[n.jsx(ee,{name:"chevron-down",className:"skills-chevron"}),n.jsx("span",{className:"skills-group-name",children:Ue.name}),n.jsx("span",{className:"skills-count",children:Ue.items.length})]}),jt&&Ue.items.map(ps)]},ct)}))]},ce.id)})]}),n.jsx("div",{className:"scripts-detail",children:n.jsxs("div",{className:"script-detail",children:[O!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:O})]}),D!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(ee,{name:"check"}),n.jsx("span",{children:D})]}),Z!==null?n.jsx(z8,{client:e,draft:Z,scripts:se,games:ae,onCancel:()=>Q(null),onSaved:ce=>{Q(null),P(ce),T(null),U(Z.original===void 0?"已保存,agent 现在就能用":"已保存"),L(J=>J+1)}}):rt===void 0?o!==null&&n.jsxs("div",{className:"skills-blank",children:[n.jsx(ee,{name:"sparkles"}),n.jsx("strong",{children:Ke===""&&p===ja?"还没有技能":"没有匹配的"}),n.jsx("span",{className:"muted small",children:"agent 做成一件事后会提议存成技能;也可以自己写一个。"}),n.jsxs("button",{className:"small-button primary",disabled:s.state!=="open",onClick:()=>Q(Hn()),children:[n.jsx(ee,{name:"plus"}),"新建技能"]})]}):n.jsx(P8,{entry:rt,where:Fe(rt),content:(H==null?void 0:H.name)===rt.name?H.text:void 0,busy:A,copied:q,moving:G,now:r,onCopy:()=>{var ce;(ce=navigator.clipboard)==null||ce.writeText(`/${rt.name} `).then(()=>V(!0),()=>{})},onUpdate:()=>void Ut(rt),onVersion:ce=>void Rn(rt,ce),onRollback:()=>void fn(rt),onRemove:()=>void Qt(rt),onEdit:()=>{var ce,J;return Q({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:[...((ce=rt.owner)==null?void 0:ce.scripts)??[]],games:[...((J=rt.owner)==null?void 0:J.games)??[]]})},onMove:()=>ne(ce=>!ce),move:G&&rt.skill!==void 0?n.jsx(D8,{client:e,skill:rt.skill,content:(H==null?void 0:H.name)===rt.name?H.text:void 0,scripts:se,games:ae,onCancel:()=>ne(!1),onMoved:()=>{ne(!1),T(null),L(ce=>ce+1),F(ce=>ce+1)}}):null},rt.name)]})})]})]})}function P8({entry:e,where:t,content:s,busy:i,copied:r,moving:o,now:l,onCopy:u,onUpdate:d,onVersion:h,onRollback:f,onRemove:p,onEdit:g,onMove:x,move:b}){var T,D,U;const{skill:k,hub:j}=e,N=j==null?void 0:j.installed,C=(k==null?void 0:k.removable)===!0||N!==void 0,S=j===void 0?void 0:L8(j),_=Dx.find(A=>A.id===e.category).icon,z=A=>i===`${A}:${e.name}`,P=j===void 0?[]:[...j.version===void 0?[]:[{version:j.version,changes:j.changes,latest:!0}],...(j.history??[]).map(A=>({...A,latest:!1}))],[H,B]=v.useState((N==null?void 0:N.version)??(j==null?void 0:j.version)??""),O=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(ee,{name:_}),$8[e.category],j!==void 0?` · 从技能库下载的 · 作者 ${j.author??j.repo}`:G_(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(ee,{name:"layers"}),"通用"]}):n.jsxs("span",{className:"badge warn",title:"技能隔离:只有在处理这些游戏或脚本的对话里,agent 才看得到、用得了它",children:[n.jsx(ee,{name:(D=(T=e.owner)==null?void 0:T.scripts)!=null&&D.length?"package":"gamepad"}),"只给 ",t," 用"]}),(k==null?void 0:k.modelInvocable)===!0&&n.jsx("span",{className:"badge ok",title:"agent 遇到相关的事会自己读它",children:"agent 自动使用"}),S!==void 0&&n.jsx("span",{className:"badge",title:(N==null?void 0:N.at)===void 0?void 0:`${gt(N.at,l)}下载`,children:S}),(N==null?void 0:N.update)===!0&&(j==null?void 0:j.incompatible)===void 0&&n.jsx("span",{className:"badge ok",children:"有新版"}),(N==null?void 0:N.held)===!0&&n.jsx("span",{className:"badge",title:"回退过:技能库再有更新的版本才会提示",children:"已回退"}),e.category==="core"&&n.jsxs("span",{className:"badge",children:[n.jsx(ee,{name:"shield"}),"受保护"]})]})]}),n.jsxs("div",{className:"skill-buttons",children:[(N==null?void 0:N.update)===!0&&(j==null?void 0:j.incompatible)===void 0&&n.jsx("button",{className:"small-button primary",disabled:i!==null,onClick:d,children:z("update")?"更新中…":"更新"}),(N==null?void 0:N.held)===!0&&(j==null?void 0:j.incompatible)===void 0&&n.jsx("button",{className:"small-button",title:"回退过的那个新版本,再换回去",disabled:i!==null,onClick:d,children:z("update")?"更新中…":"重新更新"}),(N==null?void 0:N.previous)!==void 0&&n.jsx("button",{className:"small-button",title:`换回上一个版本${N.previous.version===void 0?"":` ${N.previous.version}`}(${gt(N.previous.at,l)}下载的)`,disabled:i!==null,onClick:f,children:z("rollback")?"回退中…":"回退"}),(k==null?void 0:k.userInvocable)===!0&&n.jsxs("button",{className:"small-button",onClick:u,title:"复制后粘贴到对话框,后面写要它做的事",children:[n.jsx(ee,{name:r?"check":"copy"}),r?"已复制":`/${e.name}`]}),C&&n.jsxs("button",{className:"small-button",disabled:s===void 0,onClick:g,children:[n.jsx(ee,{name:"pencil"}),"编辑"]}),C&&n.jsxs("button",{className:"small-button","aria-expanded":o,onClick:x,title:"放错了游戏或脚本时,换到对的那个",children:[n.jsx(ee,{name:"gamepad"}),"更换游戏和脚本"]}),(C||(k==null?void 0:k.ownPack)===!0)&&n.jsx("button",{className:"small-button danger-outline",disabled:i!==null,onClick:p,children:z("remove")?"删除中…":"删除"}),(k==null?void 0:k.path)!==void 0&&((U=li())==null?void 0:U.openPath)!==void 0&&n.jsx("button",{className:"icon-button skill-folder",title:`打开所在文件夹:${k.path}`,"aria-label":"打开所在文件夹",onClick:()=>{var A,I;return void((I=(A=li())==null?void 0:A.openPath)==null?void 0:I.call(A,k.path.replace(/[\\/][^\\/]+$/,"")))},children:n.jsx(ee,{name:"layers"})})]})]}),b,n.jsx("p",{className:"skill-desc",children:e.description}),(k==null?void 0:k.whenToUse)!==void 0&&n.jsxs("p",{className:"muted small",children:["什么时候用:",k.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:"核心技能维持软件的基本功能,受保护,不能改和删,随软件更新。"}),N!==void 0&&n.jsx("p",{className:"muted small",children:"从技能库下载的:可以改,但技能库更新它时会整个换成新版本,这里改的不保留(被换掉的那版可以回退)。要一直留着的做法,另存成自己的技能。"}),(j==null?void 0:j.changes)!==void 0&&(N==null?void 0:N.update)===!0&&n.jsxs("p",{className:"small hub-changes",children:[j.version===void 0?"":`${j.version}:`,j.changes]}),(j==null?void 0:j.incompatible)!==void 0&&n.jsxs("p",{className:"small hub-incompatible",children:["新版",j.incompatible]})]}),N!==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(Ot,{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===N.version?"(正在用)":""}`,...A.changes===void 0?{}:{hint:A.changes}}))}),n.jsx("button",{className:"small-button",disabled:i!==null||H===N.version,onClick:()=>h(H),children:z("version")?"切换中…":"换成这个版本"})]}),(O==null?void 0:O.changes)!==void 0&&n.jsxs("span",{className:"muted small",children:[O.version,":",O.changes]}),O!==void 0&&!O.latest&&H!==N.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})]}),(k==null?void 0:k.path)!==void 0&&n.jsx("code",{className:"muted small skill-path",title:k.path,children:k.path})]})}function L8(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 z8({client:e,draft:t,scripts:s,games:i,onCancel:r,onSaved:o}){const[l,u]=v.useState(t),[d,h]=v.useState(!1),[f,p]=v.useState(null);v.useEffect(()=>{u(t),p(null)},[t]);const g=t.original!==void 0,x=FN.test(l.name)&&l.name.length<=jp,b=x&&l.description.trim().length>=10&&l.content.trim().length>=20,k=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(j){p(Ce(j))}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:jp,autoFocus:!g,onChange:j=>u(N=>({...N,name:j.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(Y_,{scripts:s,games:i,value:l,onChange:j=>u(N=>({...N,...j}))}),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:j=>u(N=>({...N,description:j.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:j=>u(N=>({...N,content:j.target.value}))})]}),f!==null&&n.jsx("p",{className:"error small",children:f}),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||!b,onClick:()=>void k(),children:d?"保存中…":"保存"})]})]})}function Y_({scripts:e,games:t,value:s,onChange:i}){const[r]=v.useState(s),o=[...new Set([...r.scripts,...s.scripts])].filter(f=>!e.some(p=>p.id===f)),l=[...new Set([...r.games,...s.games])].filter(f=>Od(f,t)===void 0),u=(f,p)=>{var g;return f===p||((g=Od(f,t))==null?void 0:g.id)===p},d=f=>i({...s,scripts:s.scripts.includes(f)?s.scripts.filter(p=>p!==f):[...s.scripts,f]}),h=f=>i({...s,games:s.games.some(p=>u(p,f))?s.games.filter(p=>!u(p,f)):[...s.games,f]});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(f=>n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:s.games.some(p=>u(p,f.id)),onChange:()=>h(f.id)}),f.name]},f.id)),l.map(f=>n.jsxs("label",{className:"check-label",title:"游戏页上没有这个游戏",children:[n.jsx("input",{type:"checkbox",checked:s.games.includes(f),onChange:()=>h(f)}),f]},f))]})]}),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(f=>n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:s.scripts.includes(f.id),onChange:()=>d(f.id)}),f.name]},f.id)),o.map(f=>n.jsxs("label",{className:"check-label",title:"这个脚本不在脚本库里(删掉了,或是脚本包 id)",children:[n.jsx("input",{type:"checkbox",checked:s.scripts.includes(f),onChange:()=>d(f)}),f]},f))]})]}),n.jsx("p",{className:"muted small",children:"游戏和脚本都不选就是通用技能,所有对话都能用。"})]})}function D8({client:e,skill:t,content:s,scripts:i,games:r,onCancel:o,onMoved:l}){var k,j;const[u,d]=v.useState({scripts:[...((k=t.owner)==null?void 0:k.scripts)??[]],games:[...((j=t.owner)==null?void 0:j.games)??[]]}),[h,f]=v.useState(!1),[p,g]=v.useState(null),x=t.source==="hub",b=async N=>{f(!0),g(null);try{if(x)await e.connection.call("skillhub/owner",{name:t.name,owner:N});else{if(s===void 0||N===null)return;await e.connection.call("skills/save",{name:t.name,description:t.description,content:s,replace:!0,...N.scripts.length===0?{}:{scripts:N.scripts},...N.games.length===0?{}:{games:N.games}})}l()}catch(C){g(Ce(C))}finally{f(!1)}};return n.jsxs("div",{className:"skill-move",role:"group","aria-label":"更换游戏和脚本",children:[n.jsx(Y_,{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 b(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 b(u),children:h?"保存中…":"保存"})]})]})}const F8={id:"skills",title:"技能",requires:["skills"],pages:[{id:"skills",title:"技能",icon:"sparkles",order:50,agent:"scripts",component:O8}]};async function Fx(e,t){const s=li();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}function U8({client:e}){const t=ke(e.connection.status),[s,i]=v.useState(null),[r,o]=v.useState(0),[l,u]=v.useState(null),[d,h]=v.useState(null),[f,p]=v.useState(""),[g,x]=v.useState("");v.useEffect(()=>e.connection.on("emulators/changed",()=>o(j=>j+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let j=!0;return e.connection.call("emulators/status",{refresh:r===0}).then(N=>{j&&(i(N),p(N.settings.manualAddress??""),x(N.settings.adbPath??""))}).catch(N=>{j&&h(Ce(N))}),()=>{j=!1}},[e,t.state,r]);const b=async(j,N)=>{u(j),h(null);try{await N(),o(C=>C+1)}catch(C){h(Ce(C))}finally{u(null)}},k=j=>b("settings",()=>e.connection.call("emulators/settings/set",j));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 b("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(ee,{name:"info"}),n.jsxs("span",{children:[s.selection.problem,"。可以对 agent 说「安装 MuMu 模拟器」,或在下面填写手动 ADB 地址。"]})]})]}),s==null?void 0:s.providers.map(j=>n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsxs("h3",{children:[j.name,j.version===void 0?"":` ${j.version}`]}),n.jsx("p",{className:"muted small",children:j.manager})]}),s.settings.mumuManager===j.manager&&n.jsx("span",{className:"badge ok",children:"已指定"})]}),j.error!==void 0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:j.error})]}),n.jsx("ul",{className:"version-list",children:j.instances.map(N=>n.jsxs("li",{className:N.index===s.settings.instance?"current":"",children:[n.jsx("span",{className:"version-name",children:N.index}),n.jsx("span",{children:N.name}),n.jsx("span",{className:`badge ${N.ready?"ok":""}`,children:N.ready?"已启动":N.running?"启动中":"未运行"}),N.adb!==void 0&&n.jsx("span",{className:"muted small",children:N.adb}),n.jsx("span",{className:"spacer"}),N.index!==s.settings.instance&&n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void k({instance:N.index}),children:"任务用这个"}),N.ready?n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void b(`stop-${N.index}`,()=>e.connection.call("emulators/stop",{index:N.index})),children:"关闭"}):n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void b(`start-${N.index}`,()=>e.connection.call("emulators/start",{index:N.index})),children:l===`start-${N.index}`?"启动中…":"启动"})]},N.index))})]},j.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:j=>void k({autoStart:j.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:f,onChange:j=>p(j.target.value),placeholder:"例如 127.0.0.1:5555;填写后不再管理 MuMu",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void k({manualAddress:f.trim()===""?null:f.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:j=>x(j.target.value),placeholder:"例如 D:\\platform-tools\\adb.exe",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void k({adbPath:g.trim()===""?null:g.trim()}),children:"保存"}),n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void Fx(e,{kind:"file",title:"选择 adb.exe",defaultPath:g.trim(),filterName:"程序",extensions:["exe"]}).then(j=>{j!==null&&(x(j),k({adbPath:j}))},j=>h(Ce(j))),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:j=>void k({bootTimeoutSeconds:Math.max(30,Math.min(900,Number(j.target.value)||180))})})]}),d!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:d})]})]})}function B8({client:e}){const t=ke(e.connection.status),[s,i]=v.useState(null),[r,o]=v.useState(null),[l,u]=v.useState(""),[d,h]=v.useState(""),[f,p]=v.useState(null),[g,x]=v.useState(!1),[b,k]=v.useState(null),[j,N]=v.useState(null),C=()=>e.connection.call("scripts/settings",{}).then(P=>{i(P),o(P)}).catch(P=>N(Ce(P)));if(v.useEffect(()=>{t.state==="open"&&C()},[e,t.state]),r===null||s===null)return n.jsxs("div",{className:"settings-page",children:[n.jsx("h2",{children:"脚本安装"}),j===null?n.jsx("p",{children:"加载中…"}):n.jsx("div",{className:"notice error left",children:j})]});const S=(P,H)=>o({...r,[P]:H}),_=async()=>{x(!0),N(null),k(null);try{const{tokenConfigured:P,cdkConfigured:H,...B}=s,O=Object.fromEntries(Object.entries(r).filter(([T,D])=>B[T]!==D));Object.keys(O).length>0&&await e.connection.call("scripts/settings/set",O),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(""),z()),await C(),k("已保存,下一次安装起生效")}catch(P){N(Ce(P))}finally{x(!1)}},z=async()=>{p("checking");try{p(await e.connection.call("scripts/mirrorchyan/check",{}))}catch(P){p({ok:!1,message:Ce(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:f==="checking",onClick:()=>void z(),children:f==="checking"?"检查中…":"检查"})]}),f!==null&&f!=="checking"&&n.jsx("p",{className:"small",style:{color:f.ok?"var(--ok)":"var(--error)"},children:f.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:[b!==null&&n.jsx("span",{className:"muted small",children:b}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"primary",disabled:g,onClick:()=>void _(),children:g?"保存中…":"保存"})]}),j!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:j})]})]})}function H8({client:e,initialRepo:t,jobs:s,onDone:i,openSession:r,onClose:o}){const[l,u]=v.useState(t??""),[d,h]=v.useState(null),[f,p]=v.useState(""),[g,x]=v.useState(""),[b,k]=v.useState(!1),[j,N]=v.useState(null),[C,S]=v.useState(null),_=async(O=l)=>{var D;const T=D2(O);if(T===void 0){N("请输入 owner/repo,或粘贴 GitHub 上的仓库、发布或文件链接");return}k(!0),N(null);try{const U=await e.connection.call("scripts/releases",{repo:T.repo,limit:10});u(T.repo),h({...U,branch:T.branch});const A=U.releases.find(R=>R.tag===T.tag),I=A??U.releases.find(R=>!R.prerelease)??U.releases[0];p((I==null?void 0:I.tag)??""),x(((D=I==null?void 0:I.assets.find(R=>R.name===T.asset))==null?void 0:D.name)??(I==null?void 0:I.suggestedAsset)??""),T.tag!==void 0&&A===void 0&&U.releases.length>0&&N(`最近的发布里没有 ${T.tag},已改选最新版本`)}catch(U){h(null),N(Ce(U))}finally{k(!1)}};v.useEffect(()=>{t!==void 0&&_(t)},[t]);const z=d==null?void 0:d.releases.find(O=>O.tag===f),P=d!==null&&(d.branch!==void 0||d.releases.length===0),H=async()=>{if(d!==null){k(!0),N(null);try{const{jobId:O,scriptId:T}=await e.connection.call("scripts/install",{repo:d.repo,...d.branch===void 0?{}:{branch:d.branch}});S({jobId:O,scriptId:T,tag:d.branch===void 0?"默认分支":`${d.branch} 分支`,asset:"源码压缩包"})}catch(O){N(Ce(O))}finally{k(!1)}}},B=async()=>{var O;if(!(d===null||z===void 0||g==="")){k(!0),N(null);try{const{jobId:T,scriptId:D}=await e.connection.call("scripts/install",{repo:d.repo,tag:z.tag,asset:g});S({jobId:T,scriptId:D,tag:z.tag,asset:g,size:(O=z.assets.find(U=>U.name===g))==null?void 0:O.size})}catch(T){N(Ce(T))}finally{k(!1)}}};if(C!==null&&d!==null){const O=s.get(C.scriptId);return n.jsx(X_,{client:e,repo:d.repo,...C,job:(O==null?void 0:O.id)===C.jobId?O:void 0,onDone:()=>i(C.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(ee,{name:"close"})})]}),n.jsxs("form",{className:"field-row",onSubmit:O=>{O.preventDefault(),_()},children:[n.jsx("input",{className:"text-input plain","aria-label":"GitHub 仓库",value:l,onChange:O=>u(O.target.value),placeholder:"owner/repo 或 GitHub 链接,例如 MaaAssistantArknights/MaaAssistantArknights",spellCheck:!1,disabled:b}),n.jsx("button",{type:"submit",disabled:b||l.trim()==="",children:b&&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:b,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(Ot,{id:"release-select",value:f,disabled:b,onChange:O=>{var T;p(O),x(((T=d.releases.find(D=>D.tag===O))==null?void 0:T.suggestedAsset)??"")},options:d.releases.map(O=>({value:O.tag,label:`${O.tag}${O.prerelease?"(预发布)":""}`,...O.publishedAt===void 0?{}:{hint:`${O.publishedAt.slice(0,10)} 发布`}}))}),z!==void 0&&n.jsxs("fieldset",{className:"asset-list",disabled:b,children:[n.jsx("legend",{className:"field-label",children:"下载文件"}),z.assets.length===0&&n.jsx("div",{className:"muted small",children:"这个版本没有可下载的文件"}),[...z.assets].sort((O,T)=>+(T.name===z.suggestedAsset)-+(O.name===z.suggestedAsset)).map(O=>n.jsxs("label",{className:`asset-option ${O.name===g?"active":""}`,children:[n.jsx("input",{type:"radio",name:"asset",value:O.name,checked:O.name===g,onChange:()=>x(O.name)}),n.jsx("span",{className:"asset-name",children:O.name}),O.name===z.suggestedAsset&&n.jsx("span",{className:"badge ok",children:"推荐"}),n.jsx("span",{className:"muted small",children:Aa(O.size)})]},O.name))]}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:(z==null?void 0:z.suggestedAsset)===void 0?"没有自动匹配到适合本机的文件,请手动选择。":"已按本机(Windows x64)选好文件。"}),n.jsx("span",{className:"spacer"}),n.jsxs("button",{className:"primary",onClick:()=>void B(),disabled:b||g==="",children:["安装 ",z==null?void 0:z.tag]})]})]}),j!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:j})]})]})}function Z8({client:e,initialRid:t,jobs:s,onDone:i,openSession:r,onGitHub:o,onClose:l}){const[u,d]=v.useState(""),h=W8(e,u),[f,p]=v.useState(null),[g,x]=v.useState(null),[b,k]=v.useState(!1),[j,N]=v.useState(null),[C,S]=v.useState(null);v.useEffect(()=>{e.connection.call("scripts/settings",{}).then(B=>x(B.cdkConfigured),()=>x(null))},[e]);const _=async B=>{k(!0),N(null);try{p(await e.connection.call("scripts/mirrorchyan/lookup",{rid:B}))}catch(O){p(null),N(Ce(O))}finally{k(!1)}};v.useEffect(()=>{t!==void 0&&_(t)},[t]);const z=async()=>{if(f!==null){k(!0),N(null);try{S(await e.connection.call("scripts/install",{mirrorchyan:f.rid}))}catch(B){N(Ce(B))}finally{k(!1)}}};if(C!==null&&f!==null){const B=s.get(C.scriptId);return n.jsx(X_,{client:e,repo:`Mirror酱 · ${f.rid}`,tag:f.version,asset:`${f.name??f.rid}(Mirror酱 完整包)`,job:(B==null?void 0:B.id)===C.jobId?B:void 0,onDone:()=>i(C.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(ee,{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(V8,{results:h,selected:f==null?void 0:f.rid,disabled:b,onPick:B=>void _(B)}),H&&n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),n.jsxs("button",{className:"small-button",disabled:b,onClick:()=>void _(P),children:["按资源 id 查询 ",P]})]}),f!==null&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"install-file",children:[n.jsx(ee,{name:"package"}),n.jsx("span",{className:"asset-name",children:f.name??f.rid}),n.jsxs("span",{className:"badge",children:["Mirror酱 ",f.rid]}),n.jsxs("span",{className:"muted small",children:["最新 ",f.version]})]}),f.description!==void 0&&n.jsx("p",{className:"muted small mirror-desc",children:f.description}),g===!1&&n.jsx("div",{className:"notice info left small",children:n.jsxs("span",{children:["还没有填写 Mirror酱 CDK,没法从 Mirror酱 下载。",f.repo!==void 0?"也可以从 GitHub 安装,填了 CDK 后它的更新会走 Mirror酱。":""]})}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:f.repo===void 0?"":`GitHub:${f.repo}`}),n.jsx("span",{className:"spacer"}),f.repo!==void 0&&n.jsx("button",{className:"small-button",disabled:b,onClick:()=>o(f.repo),children:"从 GitHub 安装"}),n.jsxs("button",{className:"primary",onClick:()=>void z(),disabled:b||g===!1,children:["安装 ",f.version]})]})]}),j!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:j})]})]})}function W8(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:Ce(l),loading:!1})})},t.trim()===""?0:250);return()=>{r=!1,clearTimeout(o)}},[e,t]),s}function V8({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(ee,{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(f=>n.jsxs("li",{className:f.rid===t?"active":"",children:[n.jsxs("div",{className:"mirror-result-main",children:[n.jsxs("span",{className:"mirror-result-name",children:[f.name,n.jsx("span",{className:"chip subtle",children:f.rid}),f.installed&&n.jsx("span",{className:"badge ok",children:"已在脚本库"})]}),f.description!==""&&n.jsx("span",{className:"muted small",children:f.description})]}),n.jsx("button",{className:"small-button",disabled:s,onClick:()=>r(f.rid),children:o})]},f.rid))}),!l&&d.length>i&&n.jsxs("button",{className:"link-button small",onClick:()=>u(!0),children:["还有 ",d.length-i," 个"]})]})}const Oj=["resolving","downloading","verifying","extracting","checking","done"];function X_({client:e,repo:t,tag:s,asset:i,size:r,job:o,onDone:l,openSession:u,onRetry:d,onClose:h}){const f=(o==null?void 0:o.phase)??"queued",p=f==="done"?o==null?void 0:o.setup:void 0,g=o===void 0||o.endedAt===void 0,x=q8(o==null?void 0:o.received),b=(o==null?void 0:o.total)??r,k=b!==void 0&&b>0&&(o==null?void 0:o.received)!==void 0?Math.min(1,o.received/b):void 0,j=v.useRef(-1),N=Oj.indexOf(f);N>j.current&&(j.current=N);const C=p!==void 0?"交给 agent 安装":f==="done"?"安装完成":f==="failed"?"安装失败":f==="cancelled"?"已取消安装":"正在安装",S=_=>f==="done"||_<j.current?"done":_===j.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:C}),n.jsxs("p",{className:"muted small",children:[t," · ",s]})]}),n.jsx("button",{className:"icon-button","aria-label":"关闭",title:g?"关掉面板,安装在后台继续(左边列表里能看到进度)":"关闭",onClick:h,children:n.jsx(ee,{name:"close"})})]}),n.jsxs("div",{className:"install-file",children:[n.jsx(ee,{name:"package"}),n.jsx("span",{className:"asset-name",children:i}),r!==void 0&&n.jsx("span",{className:"muted small",children:Aa(r)})]}),n.jsx("ol",{className:"install-steps",children:Oj.slice(0,-1).map((_,z)=>{const P=S(z);return n.jsxs("li",{className:`install-step ${P}`,children:[n.jsx("span",{className:"install-step-mark",children:P==="done"?n.jsx(ee,{name:"check"}):P==="stopped"?n.jsx(ee,{name:"close"}):z+1}),n.jsx("span",{children:bc[_]})]},_)})}),g&&n.jsxs("div",{className:"install-bar",children:[n.jsx("div",{className:`progress ${f==="downloading"&&k!==void 0?"":"indeterminate"}`,"aria-hidden":"true",children:n.jsx("span",{style:f==="downloading"&&k!==void 0?{width:`${(k*100).toFixed(1)}%`}:void 0})}),n.jsxs("div",{className:"install-numbers muted small",children:[n.jsx("span",{children:o===void 0?"等待开始…":o.message??bc[f]}),f==="downloading"&&(o==null?void 0:o.received)!==void 0&&n.jsxs("span",{className:"install-bytes",children:[Aa(o.received),b!==void 0?` / ${Aa(b)}`:"",k!==void 0?` · ${Math.floor(k*100)}%`:"",x!==void 0?` · ${Aa(Math.round(x))}/s`:"",x!==void 0&&x>0&&b!==void 0?` · 还要 ${G8((b-o.received)/x)}`:""]})]})]}),(o==null?void 0:o.error)!==void 0&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:o.error})]}),p!==void 0&&n.jsxs("div",{className:"notice left",children:[n.jsx(ee,{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} 的安装程序。`:f==="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:"取消安装"}),(f==="failed"||f==="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:"查看对话"}),f==="done"&&p===void 0&&n.jsx("button",{className:"primary small-button",onClick:l,children:"查看脚本"})]})]})}function q8(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 G8(e){return!Number.isFinite(e)||e<0?"—":e<60?`${Math.max(1,Math.round(e))} 秒`:`${Math.floor(e/60)} 分 ${Math.round(e%60)} 秒`}function K8({client:e,onImported:t,onClose:s}){const[i,r]=v.useState(""),[o,l]=v.useState(""),[u,d]=v.useState(!1),[h,f]=v.useState(null),p=async()=>{f(null);try{const x=await Fx(e,{kind:"folder",title:"选择脚本所在的文件夹",defaultPath:i.trim().replace(/^"|"$/g,"")});x!==null&&r(x)}catch(x){f(Ce(x))}},g=async()=>{d(!0),f(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){f(Ce(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(ee,{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(ee,{name:"alert"}),n.jsx("span",{children:h})]})]})}function bg({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 安装":bc[t.phase],t.version!==void 0&&t.phase==="done"?` ${t.version}`:""]}),r!==void 0&&i&&n.jsxs("span",{className:"job-bytes",children:[Aa(t.received??0)," / ",Aa(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 Y8={install:"安装来源",pack:"脚本包",known:"已知项目",user:"你设置的"};function Q_({client:e,script:t,disabled:s,act:i}){const[r,o]=v.useState(null),[l,u]=v.useState(""),[d,h]=v.useState(null),f=t.channels.github,p=t.channels.mirrorchyan,g=(j,N)=>i("channel",async()=>{await e.connection.call("scripts/source/set",N==="reset"?{id:t.id,reset:[j]}:j==="repo"?{id:t.id,repo:N}:{id:t.id,mirrorchyan:N}),o(null);const C=j==="repo"?"GitHub":"Mirror酱";return N===null?`已不再从 ${C} 更新`:N==="reset"?`${C} 更新渠道已恢复自动`:`${C} 更新渠道已设为 ${N}`}),x=()=>i("mirror-match",async()=>{const j=await e.connection.call("scripts/mirrorchyan/match",{id:t.id});return h({items:j.items,checked:!0}),j.items.length===0?`Mirror酱 上没有找到它${j.from==="builtin"?"(读不到 Mirror酱 的项目列表,只查了已知的)":""};知道资源 id 的话可以直接「设置」`:void 0}),b=(j,N)=>j==="repo"?/^[\w.-]+\/[\w.-]+$/.test(N):/^[\w.-]{1,100}$/.test(N),k=(j,N,C,S,_)=>n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:N}),n.jsx("dd",{children:r!==j?n.jsxs(n.Fragment,{children:[C!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{children:C.text}),n.jsxs("span",{className:"muted small",children:["(",Y8[C.from],")"]})]}):n.jsx("span",{className:"muted small",children:S}),(C==null?void 0:C.from)!=="install"&&n.jsx("button",{className:"ghost small-button",disabled:s,onClick:()=>{u((C==null?void 0:C.text)??""),o(j)},children:C===void 0?"设置":"修改"}),j==="mirrorchyan"&&C===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":`${N}更新渠道`,value:l,onChange:z=>u(z.target.value),placeholder:_,spellCheck:!1,autoFocus:!0}),n.jsx("button",{className:"primary small-button",disabled:s||!b(j,l.trim()),onClick:()=>void g(j,l.trim()),children:j==="mirrorchyan"?"查询并保存":"保存"}),n.jsx("button",{className:"small-button",disabled:s,onClick:()=>void g(j,"reset"),children:"恢复自动"}),C!==void 0&&n.jsx("button",{className:"small-button",disabled:s,onClick:()=>void g(j,null),children:"不用"}),n.jsx("button",{className:"ghost small-button",onClick:()=>o(null),children:"取消"})]})})]});return n.jsxs(n.Fragment,{children:[k("repo","GitHub",f===void 0?void 0:{text:f.repo,from:f.from},"未设置:填写它的 GitHub 仓库","owner/repo,例如 babalae/better-genshin-impact"),k("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(j=>n.jsxs("span",{className:"mirror-match",children:[n.jsx("span",{children:j.name}),n.jsx("span",{className:"chip subtle",children:j.rid}),n.jsx("button",{className:"small-button",disabled:s,onClick:()=>void g("mirrorchyan",j.rid).then(()=>h(null)),children:"用这个"})]},j.rid))]})]})]})}function X8({client:e,script:t,disabled:s,busy:i,now:r,act:o}){const[l,u]=v.useState(!1),d=t.localVersion,h=t.update,f=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(Q_,{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&&` · ${gt(h.checkedAt,r)}检查`]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:s||!f,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," · ",gt(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 Q8({client:e,script:t,openSession:s}){var A,I,R;const i=ke(e.connection.status),r=ke(e.capabilities),o=mn(6e4),[l,u]=v.useState([]),[d,h]=v.useState(0),[f,p]=v.useState(!1),[g,x]=v.useState(null),[b,k]=v.useState(null),[j,N]=v.useState([]),[C,S]=v.useState(!1);v.useEffect(()=>e.connection.on("packs/changed",()=>h(L=>L+1)),[e]),v.useEffect(()=>{if(i.state!=="open"||!r.has("packs"))return;let L=!0;return e.connection.call("packs/drafts",{scriptId:t.id}).then(K=>{L&&u(K.items)}).catch(()=>{}),()=>{L=!1}},[e,t.id,i.state,r,d]),v.useEffect(()=>{if(i.state!=="open"||!r.has("packs")||t.packId===void 0){N([]);return}let L=!0;return e.connection.call("packs/history",{packId:t.packId}).then(K=>{L&&N(K.items)}).catch(()=>{L&&N([])}),()=>{L=!1}},[e,t.packId,i.state,r,d]);const _=async L=>{p(!0),x(null);try{await L()}catch(K){x(Ce(K))}finally{p(!1)}},z=()=>_(async()=>{const{sessionId:L}=await e.connection.call("agents/home",{agentId:"scripts",focus:{scripts:[t.id]}});await e.connection.call("session/prompt",{sessionId:L,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(L)}),P=L=>_(async()=>{const{sessionId:K}=await e.connection.call("scripts/packReview",{id:t.id,decision:L});K!==void 0&&s(K)}),H=L=>_(async()=>{const{sessionId:K}=await e.connection.call("scripts/optimize",{id:t.id,decision:L});K!==void 0&&s(K)}),B=L=>_(async()=>{S(!1),await e.connection.call("packs/restore",{packId:t.packId,version:L.id}),S(!0)}),O=L=>`${L.builtin===!0?"官方脚本包":`${gt(L.at??o,o)}被替换`} · 任务:${L.tasks.map(K=>K.title).join("、")||"无"}`,T=l[0],D=j[0],U=(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:f||i.state!=="open",onClick:()=>void H("run"),title:"用运行攒下的信息:重新总结脚本包、调「多久没动静算卡住」、把走通的步骤存成只给它用的技能",children:[n.jsx(ee,{name:"sparkles"}),"优化脚本"]}),n.jsxs("button",{className:"small-button",disabled:f||i.state!=="open",onClick:()=>void z(),children:[n.jsx(ee,{name:"sparkles"}),t.packId===void 0?"让 agent 分析":"让 agent 改进"]})]})]}),t.packReview!==void 0&&T===void 0&&n.jsxs("div",{className:"notice left pack-review",children:[n.jsx(ee,{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:f,onClick:()=>void P("keep"),children:"不用改"}),n.jsx("button",{className:"primary small-button",disabled:f||i.state!=="open",onClick:()=>void P("check"),children:"让 agent 检查"})]})]}),U!==void 0&&t.packReview===void 0&&T===void 0&&n.jsxs("div",{className:"notice left pack-review",children:[n.jsx(ee,{name:"sparkles"}),n.jsxs("span",{children:[U==="updated"?`${t.name} 更新后已经跑通了。`:`${t.name} ${((I=t.optimize)==null?void 0:I.at)===void 0?"装好以来":"上次优化以来"}已经跑成功 ${((R=t.optimize)==null?void 0:R.runs)??0} 次。`,"要让 agent 用这些运行记录优化它吗:重新总结脚本包、调卡住时间、把走通的步骤存成技能。"]}),n.jsxs("span",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:f,onClick:()=>void H("keep"),children:"这次不用"}),n.jsx("button",{className:"primary small-button",disabled:f||i.state!=="open",onClick:()=>void H("run"),children:"优化脚本"})]})]}),D!==void 0&&n.jsxs("div",{className:"pack-history",children:[n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[D.builtin===!0?"现在用的是自己写的脚本包,可以换回":"上一版脚本包:",O(D)]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:f||i.state!=="open",title:"现在用的这一版会留在历史里,可以再恢复回来",onClick:()=>void B(D),children:D.builtin===!0?"恢复官方的":"恢复上一版"})]}),j.length>1&&n.jsxs("details",{className:"draft-docs",children:[n.jsxs("summary",{className:"muted small",children:["更早的版本(",j.length-1,")"]}),n.jsx("ul",{children:j.slice(1).map(L=>n.jsxs("li",{children:[O(L)," ",n.jsx("button",{className:"link-button",disabled:f||i.state!=="open",onClick:()=>void B(L),children:"恢复"})]},L.id))})]}),C&&n.jsx("p",{className:"muted small",children:"已恢复。刚才用的那一版留在历史里,可以再恢复回来。"})]}),T!==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:[gt(T.proposedAt,o),"提交 · 任务:",T.tasks.map(L=>L.title).join("、")||"无"]})]}),n.jsx("p",{className:"draft-summary",children:T.summary}),T.docs!==void 0&&T.docs.length>0&&n.jsxs("details",{className:"draft-docs",children:[n.jsxs("summary",{className:"muted small",children:["依据的文档(",T.docs.length,")"]}),n.jsx("ul",{children:T.docs.map(L=>n.jsxs("li",{children:[n.jsx("code",{children:L.source}),":",L.used]},L.source))})]}),T.noDocs!==void 0&&n.jsxs("p",{className:"muted small",children:["没有找到项目文档,按代码分析:",T.noDocs]}),T.current!==void 0&&n.jsxs("p",{className:"muted small",children:["接受后会替换当前的",T.current.builtin?"官方":"","脚本包(之前的版本会保留在历史里)。"]}),n.jsxs("div",{className:"segmented draft-tabs",children:[n.jsxs("label",{className:b==="manifest"?"active":"",children:[n.jsx("input",{type:"checkbox",checked:b==="manifest",onChange:()=>k(L=>L==="manifest"?null:"manifest")}),"adg.script.yaml"]}),n.jsxs("label",{className:b==="skill"?"active":"",children:[n.jsx("input",{type:"checkbox",checked:b==="skill",onChange:()=>k(L=>L==="skill"?null:"skill")}),"SKILL.md"]})]}),b!==null&&n.jsx("pre",{className:"draft-text",children:b==="manifest"?T.manifest:T.skill}),n.jsxs("div",{className:"key-actions",children:[T.sessionId!==void 0&&n.jsx("button",{className:"link-button",onClick:()=>s(T.sessionId),children:"查看分析过程"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:f,onClick:()=>void _(()=>e.connection.call("packs/reject",{packId:T.packId})),children:"拒绝"}),n.jsx("button",{className:"primary small-button",disabled:f,onClick:()=>void _(()=>e.connection.call("packs/accept",{packId:T.packId})),children:"接受并使用"})]})]}),g!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:g})]})]})}function J8({client:e,script:t}){const s=ke(e.connection.status),i=mn(15e3),[r,o]=v.useState(void 0),[l,u]=v.useState(0),[d,h]=v.useState(30),[f,p]=v.useState(null);v.useEffect(()=>e.connection.on("guard/changed",()=>u(b=>b+1)),[e]),v.useEffect(()=>{if(s.state!=="open")return;let b=!0;return e.connection.call("guard/grants",{}).then(k=>{b&&o(k.items.find(j=>j.scriptId===t.id))}).catch(()=>{}),()=>{b=!1}},[e,t.id,s.state,l]);const g=r!==void 0&&r.expiresAt>i?r:void 0,x=b=>{p(null),b().catch(k=>p(Ce(k)))};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(Ot,{inline:!0,"aria-label":"允许多久",value:String(d),onChange:b=>h(Number(b)),options:[15,30,60,120].map(b=>({value:String(b),label:`${b} 分钟`}))})]}),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:"立即收回"})]}),f!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:f})]})]})}function e7({client:e,script:t}){const s=ke(e.connection.status),i=mn(6e4),r=YS(e,t.id),[o,l]=v.useState(void 0),[u,d]=v.useState(null),[h,f]=v.useState(0),[p,g]=v.useState(null),[x,b]=v.useState(null),[k,j]=v.useState(null),[N,C]=v.useState(!1),[S,_]=v.useState(null),[z,P]=v.useState(null),[H,B]=v.useState(null),O=(r==null?void 0:r.items.find(L=>L.id===o))??(r==null?void 0:r.items.find(L=>L.id===r.current));v.useEffect(()=>{g(null),j(null)},[O==null?void 0:O.id]),v.useEffect(()=>e.connection.on("runs/state",L=>{L.scriptId!==t.id||L.endedAt===void 0||(f(K=>K+1),B(K=>K===null||K.runId!==L.id?K:(_(L.state==="succeeded"?`修改已同步到「${K.profile}」`:L.state==="cancelled"?"已放弃这次修改,本地配置没变":`没能保存修改:${L.outcome??"脚本窗口异常退出"}`),null)))}),[e,t.id]);const T=async L=>{if(H!==null){B({...H,finishing:L});try{L==="done"?await e.connection.call("configs/done",{runId:H.runId}):await e.connection.call("runs/stop",{runId:H.runId})}catch(K){P(Ce(K)),B(null)}}};v.useEffect(()=>{if(s.state!=="open"||O===void 0)return;let L=!0;return e.connection.call("configs/status",{scriptId:t.id,profile:O.id}).then(K=>{L&&(d(K),P(null))}).catch(K=>{L&&P(Ce(K))}),()=>{L=!1}},[e,t.id,t.packId,s.state,h,O==null?void 0:O.id]);const D=async L=>{C(!0),P(null),_(null);try{const K=await L();typeof K=="string"&&_(K),f(F=>F+1)}catch(K){P(Ce(K))}finally{C(!1)}},U=((r==null?void 0:r.items.length)??0)>1,A=O!==void 0&&O.id===(r==null?void 0:r.current),I=(u==null?void 0:u.files.filter(L=>L.local))??[],R=u!==null&&u.profile.id===(O==null?void 0:O.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:N||H!==null||s.state!=="open"||O===void 0,onClick:()=>void D(async()=>{const L=await e.connection.call("configs/open",{scriptId:t.id,profile:O.id});if(L.endedAt===void 0)B({runId:L.id,profile:O.name,finishing:null});else if(L.state!=="succeeded")throw new Error(L.outcome??"没能打开脚本的设置界面")}),children:[n.jsx(ee,{name:"settings"}),"打开脚本修改设置"]})]}),r!==null&&(U||((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(L=>n.jsxs("button",{role:"tab","aria-selected":L.id===(O==null?void 0:O.id),className:`profile-chip ${L.id===(O==null?void 0:O.id)?"active":""}`,onClick:()=>l(L.id),children:[L.name,L.id===r.current&&U&&n.jsx("span",{className:"profile-current",title:"不指定配置的运行都用它",children:"当前使用"})]},L.id)),n.jsx("button",{className:"ghost small-button",disabled:N,onClick:()=>b(L=>L===null?{name:"",source:"copy",dir:""}:null),children:"+ 另存一份"})]}),O!==void 0&&U&&k===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:N,onClick:()=>void D(async()=>(await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:O.id,current:!0}),`现在默认使用「${O.name}」`)),children:"设为当前使用"}),n.jsx("button",{className:"ghost small-button",disabled:N,onClick:()=>j(O.name),children:"改名"}),O.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:N,onClick:()=>void D(async()=>(await e.connection.call("configs/profiles/remove",{scriptId:t.id,profile:O.id}),g(null),l(void 0),`已删除「${O.name}」`)),children:"确认删除"})]}):n.jsx("button",{className:"ghost small-button",disabled:N,onClick:()=>g("remove"),children:"删除"}))]}),O!==void 0&&k!==null&&n.jsxs("div",{className:"key-input",children:[n.jsx("input",{className:"text-input plain","aria-label":"新名字",value:k,maxLength:30,autoFocus:!0,onChange:L=>j(L.target.value)}),n.jsx("button",{className:"small-button",onClick:()=>j(null),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:N||k.trim()==="",onClick:()=>void D(async()=>{await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:O.id,name:k.trim()}),j(null)}),children:"保存"})]}),x!==null&&O!==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:L=>b({...x,name:L.target.value})}),n.jsxs("fieldset",{className:"asset-list",disabled:N,children:[n.jsx("legend",{className:"field-label",children:"内容从哪里来"}),[["copy",`复制「${O.name}」`,"复制后可以「打开脚本修改设置」单独改它"],["original","读取原项目现在的配置","在脚本自己的界面里设好了另一套设置时用"],["folder","从别的文件夹读取",`另一份同样的脚本,或存下来的配置;只读 ${(u==null?void 0:u.files.map(L=>L.file).join("、"))||"脚本包声明的配置文件"}`]].map(([L,K,F])=>n.jsxs("label",{className:`asset-option choice-option ${x.source===L?"active":""}`,children:[n.jsx("input",{type:"radio",name:"profile-source",value:L,checked:x.source===L,onChange:()=>b({...x,source:L})}),n.jsxs("span",{className:"choice-text",children:[n.jsx("span",{children:K}),n.jsx("span",{className:"muted small",children:F})]})]},L))]}),x.source==="folder"&&n.jsx("input",{className:"text-input plain","aria-label":"文件夹",placeholder:"文件夹的完整路径,例如 D:\\MAA2",value:x.dir,onChange:L=>b({...x,dir:L.target.value})}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>b(null),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:N||x.name.trim()===""||x.source==="folder"&&x.dir.trim()==="",onClick:()=>void D(async()=>{const L=x.source==="copy"?{kind:"copy",profile:O.id}:x.source==="original"?{kind:"original"}:{kind:"folder",dir:x.dir.trim()},K=await e.connection.call("configs/profiles/create",{scriptId:t.id,name:x.name.trim(),from:L});return b(null),l(K.profile.id),`已保存「${K.profile.name}」:${K.files.length>0?K.files.join("、"):"还没有配置文件"}`}),children:"保存"})]})]})]}),R!==null&&n.jsxs(n.Fragment,{children:[R.drift.length>0&&n.jsxs("div",{className:"notice warn-box left",children:[n.jsx(ee,{name:"info"}),n.jsxs("span",{children:["原项目的配置在导入后改过(",R.drift.join("、"),"),可能是在脚本自己的界面里改的。本应用仍按「",R.profile.name,"」运行;需要的话可以导入。"]})]}),n.jsx(Oa,{id:`config.files.${t.id}`,title:"配置文件",count:R.files.length,children:n.jsxs("ul",{className:"version-list",children:[R.files.map(L=>n.jsx(t7,{client:e,scriptId:t.id,profile:R.profile.id,file:L},`${R.profile.id}:${L.file}`)),R.files.length===0&&n.jsx("li",{className:"muted small",children:"脚本包没有声明配置文件"})]})}),n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[R.importedAt===void 0?"还没有导入":`${gt(R.importedAt,i)}${U?`存的「${R.profile.name}」`:"从原项目导入"}`,I.length>0&&" · ",I.length>0&&n.jsx("button",{className:"link-button",onClick:()=>{var L;return void((L=navigator.clipboard)==null?void 0:L.writeText(R.dir))},children:"复制本地配置目录"})]}),n.jsx("span",{className:"spacer"}),p!=="import"?n.jsx("button",{className:"small-button",disabled:N,onClick:()=>g("import"),children:"导入原项目设置"}):n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"muted small",children:["会用原项目当前的配置覆盖「",R.profile.name,"」"]}),n.jsx("button",{className:"small-button",onClick:()=>g(null),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:N,onClick:()=>void D(async()=>{const L=await e.connection.call("configs/import",{scriptId:t.id,profile:R.profile.id});return g(null),L.imported.length>0?`已导入到「${R.profile.name}」:${L.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(ee,{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 T("discard"),children:"放弃修改"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"primary small-button",disabled:H.finishing!==null,onClick:()=>void T("done"),children:H.finishing==="done"?"保存中…":"我已手动改好"})]})]})}),z!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:z})]})]})}function t7({client:e,scriptId:t,profile:s,file:i}){const[r,o]=v.useState(!1),[l,u]=v.useState(null),[d,h]=v.useState(null),f=()=>{o(p=>!p),!(l!==null||!i.local)&&e.connection.call("configs/read",{scriptId:t,file:i.file,profile:s}).then(u,p=>h(Ce(p)))};return n.jsxs("li",{className:`config-file ${r?"open":""}`,children:[n.jsxs("button",{type:"button",className:"config-file-head","aria-expanded":r,onClick:f,disabled:!i.local,title:i.local?"展开看本地配置的内容":"本地还没有这个文件",children:[n.jsx(ee,{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(ee,{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?`
236
+ …(太长,只显示前一部分)`:""]}))]})}function n7({client:e,scriptId:t,scriptName:s,openSession:i}){const r=ke(e.connection.status),[o,l]=v.useState(null),[u,d]=v.useState(""),[h,f]=v.useState(""),[p,g]=v.useState(""),[x,b]=v.useState(!1),[k,j]=v.useState(null),[N,C]=v.useState(!1),[S,_]=v.useState(null),[z,P]=v.useState(!1);v.useEffect(()=>{if(r.state!=="open")return;let R=!0;return e.connection.call("configs/launch",{scriptId:t}).then(L=>{R&&(l(L),d(L.settings.pcExe??""),f(L.settings.pcProcess??""),g(L.settings.androidPackage??""))}).catch(L=>{R&&j(Ce(L))}),()=>{R=!1}},[e,t,r.state]);const H=async R=>{b(!0),j(null),C(!1);try{l(await e.connection.call("configs/launch/set",{scriptId:t,...R})),C(!0),"pcExe"in R&&W_()}catch(L){j(Ce(L))}finally{b(!1)}},B=async R=>{d(R),await H({pcExe:R})},O=async()=>{P(!0),j(null),C(!1),_(null);try{const R=await e.connection.call("configs/launch/locate",{scriptId:t});_(R),R.candidates.length===1&&await B(R.candidates[0].path)}catch(R){j(Ce(R))}finally{P(!1)}},T=async()=>{j(null);try{const{sessionId:R}=await e.connection.call("agents/home",{agentId:"main",focus:{scripts:[t]}});await e.connection.call("session/prompt",{sessionId:R,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(R)}catch(R){j(Ce(R))}},D=async()=>{j(null);try{const R=await Fx(e,{kind:"file",title:"选择游戏程序",defaultPath:u.trim()===""?void 0:u.trim(),filterName:"程序",extensions:["exe"]});R!==null&&await B(R)}catch(R){j(Ce(R))}};if(o===null)return k===null?null:n.jsx("section",{className:"card",children:n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:k})]})});const{settings:U,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(Ot,{id:`launch-mode-${t}`,value:U.mode,disabled:x,onChange:R=>void H({mode:R}),options:[{value:"auto",label:"自动(推荐)",hint:"脚本自己不会启动游戏时,由本应用启动"},{value:"platform",label:"总是由本应用启动",hint:"游戏没开时先打开它"},{value:"off",label:"不启动",hint:"交给脚本或我自己"}]}),U.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:R=>g(R.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 服、国际服等版本的包名不同时在这里改。"]})]}),U.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:R=>d(R.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||z,onClick:()=>void O(),children:z?"正在查找…":"自动查找"}),n.jsx("button",{className:"small-button",disabled:x||z,onClick:()=>void D(),children:"选择文件…"}),n.jsx("button",{className:"link-button small",disabled:z,onClick:()=>void T(),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(R=>n.jsxs("button",{className:`candidate ${U.pcExe===R.path?"chosen":""}`,disabled:x,onClick:()=>void B(R.path),children:[n.jsx("span",{className:"mono",children:R.path}),n.jsx("span",{className:"muted small",children:R.source})]},R.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:R=>f(R.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:"填的是启动器时,进程名要填游戏本身的(在任务管理器「详细信息」里看)。"})]}),N&&n.jsx("div",{className:"muted small",children:"已保存,下次运行生效。"}),k!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:k})]})]})}const s7=15*6e4;function i7({client:e,script:t,openSession:s}){const i=mn(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<s7,f=(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(Ce(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 总结 · ${gt(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(ee,{name:"sparkles"}),h?"总结中…":d===void 0?"让 AI 总结":"重新总结"]})]})]}),f!==void 0&&n.jsx("p",{className:`summary-text ${h?"muted":""}`,children:f}),(d==null?void 0:d.state)==="failed"&&d.text!==void 0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:d.text})]}),l!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:l})]})]})}const r7={desktop:"占用鼠标键盘",adb:"用模拟器,不占鼠标",window:"后台操作游戏窗口",none:"不占用"};function a7(e){const t=/^(\d+)(s|m|h)$/.exec(e);return t===null?e:`约 ${t[1]} ${t[2]==="s"?"秒":t[2]==="m"?"分钟":"小时"}`}function kg({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 o7({client:e,script:t}){const s=ke(e.connection.status),[i,r]=v.useState(void 0),[o,l]=v.useState(null),[u,d]=v.useState(0),[h,f]=v.useState("tasks");if(v.useEffect(()=>e.connection.on("packs/changed",()=>d(b=>b+1)),[e]),v.useEffect(()=>{if(s.state!=="open"||t.packId===void 0)return;let b=!0;return e.connection.call("scripts/guide",{id:t.id}).then(k=>{b&&(r(k.guide),l(null))}).catch(k=>{b&&l(Ce(k))}),()=>{b=!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(([,,b])=>b),x=g.some(([b])=>b===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(ee,{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(([b,k])=>n.jsxs("label",{className:x===b?"active":"",children:[n.jsx("input",{type:"radio",name:`guide-${t.id}`,checked:x===b,onChange:()=>f(b)}),k]},b))}),x==="tasks"&&n.jsx(l7,{guide:i}),x==="features"&&n.jsx(c7,{guide:i}),x==="config"&&n.jsx(u7,{guide:i}),x==="before"&&n.jsx(d7,{guide:i}),x==="problems"&&n.jsx(h7,{guide:i})]})]})}function l7({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:r7[t.input]}),t.expectedDuration!==void 0&&n.jsx("span",{className:"muted small",children:a7(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(kg,{items:[["可选值",s.values],["默认",s.default??(s.values===void 0?"无,运行时必须填":void 0)]]})]})]},s.name))})]},t.id))})}function c7({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 u7({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(kg,{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(kg,{items:[["条件",s.when],["任务",s.tasks.join("、")]]})]})]},`${s.key}=${s.value}:${s.when??""}`))})]})]},t.file))})}function d7({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 h7({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 m7={stdio:"本地程序",http:"HTTP",sse:"SSE"};function f7({client:e,script:t}){const[s,i]=v.useState(null),[r,o]=v.useState(0),[l,u]=v.useState({}),[d,h]=v.useState(null),[f,p]=v.useState(null);if(v.useEffect(()=>e.connection.on("skills/changed",()=>o(k=>k+1)),[e]),v.useEffect(()=>e.connection.on("packs/changed",()=>o(k=>k+1)),[e]),v.useEffect(()=>{let k=!0;return e.connection.call("scripts/mcp",{id:t.id}).then(j=>{k&&i(j)}).catch(()=>{k&&i(null)}),()=>{k=!1}},[e,t.id,t.current,t.packId,r]),s===null||s.servers.length===0&&s.skills.length===0)return null;const g=async k=>{u(j=>({...j,[k]:"busy"}));try{const j=await e.connection.call("scripts/mcp/probe",{id:t.id,server:k});u(N=>({...N,[k]:j})),o(N=>N+1)}catch(j){u(N=>({...N,[k]:{ok:!1,error:Ce(j)}}))}},x=async k=>{h((k==null?void 0:k[0])??"*"),p(null);try{const{imported:j,skipped:N}=await e.connection.call("scripts/skills/import",{id:t.id,...k===void 0?{}:{names:k}}),C=[...j.length===0?[]:[`已放进技能库:${j.map(S=>S.name).join("、")}`],...N.map(S=>`${S.skill} 没有导入:${S.reason}`)];p({text:C.join(";")||"没有可以导入的技能",error:j.length===0}),o(S=>S+1)}catch(j){p({text:Ce(j),error:!0})}finally{h(null)}},b=s.skills.filter(k=>k.problem===void 0&&(k.imported===void 0||!k.imported.current&&!k.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 就会用上。":""]})]}),b.length>1&&n.jsx("div",{className:"key-actions",children:n.jsxs("button",{className:"small-button",disabled:d!==null,onClick:()=>void x(),children:[n.jsx(ee,{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(k=>{var N,C;const j=l[k.name];return n.jsxs("li",{className:"mcp-server",children:[n.jsxs("div",{className:"mcp-server-main",children:[n.jsx("span",{className:"version-name",children:k.name}),n.jsx("span",{className:"badge",children:m7[k.transport]??k.transport}),n.jsx("span",{className:`badge ${k.source==="pack"?"ok":""}`,title:k.file===void 0?void 0:`来自脚本的 ${k.file}`,children:k.source==="pack"?"脚本包已写明用法":"从脚本配置读到"}),k.connected&&n.jsx("span",{className:"badge ok",children:"已连接"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"ghost small-button",disabled:j==="busy"||k.problem!==void 0,title:k.trusted?void 0:"会启动或连接这个服务;之后 agent 用它时不再询问",onClick:()=>void g(k.name),children:j==="busy"?"连接中…":"测试连接"})]}),n.jsx("code",{className:"muted small mcp-target",children:k.target}),k.description!==void 0&&n.jsx("p",{className:"muted small",children:k.description}),k.needsRunning&&n.jsx("p",{className:"muted small",children:"要先打开脚本(并在它的设置里开启 MCP 服务)才能连上。"}),k.problem!==void 0&&n.jsxs("div",{className:"notice warn-note left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:k.problem})]}),j!==void 0&&j!=="busy"&&(j.ok?n.jsxs("p",{className:"small",children:[j.server===void 0?"":`${j.server.name} ${j.server.version} · `,((N=j.tools)==null?void 0:N.length)??0," 个工具",(((C=j.tools)==null?void 0:C.length)??0)>0?`:${j.tools.map(S=>S.title??S.name).join("、")}`:""]}):n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:j.error})]}))]},k.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(k=>n.jsxs("li",{className:"mcp-skill",children:[n.jsxs("div",{className:"mcp-server-main",children:[n.jsx("span",{className:"version-name",children:k.name}),k.imported!==void 0&&n.jsxs("span",{className:"badge ok",children:["已在技能库",k.imported.name===k.name?"":`(${k.imported.name})`]}),k.imported!==void 0&&!k.imported.current&&n.jsx("span",{className:"badge warn",title:k.imported.changed?"技能库里的这份在这里改过,不会自动替换":void 0,children:"脚本里有新版"}),n.jsx("span",{className:"spacer"}),k.problem===void 0&&(k.imported===void 0||!k.imported.current)&&n.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void x([k.path]),children:d===k.path?"导入中…":k.imported===void 0?"放进技能库":"更新"})]}),k.description!==""&&n.jsx("p",{className:"muted small",children:k.description}),n.jsx("code",{className:"muted small mcp-target",children:k.path}),k.problem!==void 0&&n.jsxs("div",{className:"notice warn-note left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:k.problem})]})]},k.path))})]}),f!==null&&n.jsxs("div",{className:`notice ${f.error?"error":""} left small`,children:[n.jsx(ee,{name:f.error?"alert":"check"}),n.jsx("span",{children:f.text})]})]})}const p7={nsis:"NSIS",inno:"Inno Setup",kachina:"Kachina"};function J_({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),[f,p]=v.useState(null),[g,x]=v.useState(!1),b=t.agent,k=async(j,N)=>{h(j),p(null);try{await N()}catch(C){p(Ce(C))}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:["下载到的是 ",p7[t.kind]," 安装程序,不是压缩包:要运行它把文件装好,再导入装好的文件夹。"]})]})}),(b==null?void 0:b.state)==="running"&&n.jsxs("div",{className:"notice left",children:[n.jsx(ee,{name:"info"}),n.jsx("span",{children:"agent 正在安装。也可以不等它,按下面的步骤自己装。"}),n.jsx("button",{className:"link-button",onClick:()=>s(b.sessionId),children:"查看对话"})]}),(b==null?void 0:b.state)==="failed"&&n.jsxs("div",{className:"notice warn-box left",children:[n.jsx(ee,{name:"alert"}),n.jsxs("span",{children:["agent 没能装好:",b.reason??"原因不明","。可以按下面的步骤自己装,也可以之后再交给 agent。"]}),n.jsx("button",{className:"link-button",onClick:()=>s(b.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 k("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:j=>{j.preventDefault(),k("import",async()=>{const N=await e.connection.call("scripts/import",{path:r.trim().replace(/^"|"$/g,""),id:t.scriptId});i(N.id)})},children:[n.jsx("input",{className:"text-input plain","aria-label":"装好的文件夹",value:r,onChange:j=>o(j.target.value),spellCheck:!1,disabled:d!==null}),n.jsx("button",{className:"primary small-button",type:"submit",disabled:d!==null||r.trim()==="",children:d==="import"?"导入中…":"装好了,导入"})]})]})})]}),f!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:f})]}),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 k("discard",async()=>{await e.connection.call("scripts/setup/discard",{id:t.scriptId})}),children:"确认删除"})]}):n.jsxs(n.Fragment,{children:[(b==null?void 0:b.state)!=="running"&&n.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void k("agent",async()=>{const{sessionId:j}=await e.connection.call("scripts/setup/agent",{id:t.scriptId});s(j)}),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 g7={ok:["ok","满足"],missing:["warn","缺少"],outdated:["warn","版本过旧"],unknown:["warn","无法判断"],unsupported:["","暂不检测"]};function x7({client:e,script:t,skillUpdates:s=[],job:i,setup:r,onRemoved:o,openSession:l}){var H;const u=mn(6e4),[d,h]=v.useState(null),[f,p]=v.useState(null),[g,x]=v.useState(null),[b,k]=v.useState(!1),[j,N]=v.useState(!1),C=i!==void 0&&(i.endedAt===void 0||i.startedAt>=t.addedAt-1e3)?i:void 0,S=_a(C),_=ke(e.capabilities),z=t.source.kind!=="local",P=async(B,O)=>{h(B),p(null),x(null);try{const T=await O();typeof T=="string"&&x(T)}catch(T){p(Ce(T))}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:ow[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(v7,{client:e,skills:s}),C!==void 0&&n.jsx(bg,{client:e,job:C}),r!==void 0&&n.jsx(J_,{client:e,setup:r,openSession:l,onImported:()=>{}}),t.dir!==void 0&&n.jsx(i7,{client:e,script:t,openSession:l}),t.packId!==void 0&&n.jsx(o7,{client:e,script:t},`guide:${t.id}`),t.dir!==void 0&&n.jsx(f7,{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(ee,{name:"copy"}),"复制路径"]})]}),z?n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"version-list",children:t.versions.map(B=>{var O;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:[((O=B.asset)==null?void 0:O.name)??""," · ",gt(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(Q_,{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&&` · ${gt(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(X8,{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?"没有脚本包,暂时不知道它需要什么":"还没有检查":`${gt(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[O,T]=g7[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 ${O}`,children:T}),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)})})]}),_.has("runs")&&t.dir!==void 0&&n.jsx(A5,{client:e,scriptId:t.id,packId:t.packId}),_.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&n.jsx(e7,{client:e,script:t}),_.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&n.jsx(n7,{client:e,scriptId:t.id,scriptName:t.name,openSession:l},t.id),_.has("packs")&&n.jsx(Q8,{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))})]})]}),_.has("guard")&&n.jsx(J8,{client:e,script:t}),n.jsx("section",{className:"card danger-zone",children:b?n.jsxs("div",{className:"key-actions",children:[z&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:j,onChange:B=>N(B.target.checked)}),"同时删除所有已安装版本"]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>k(!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:z&&j}),o()}),children:"确认移除"})]}):n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[z?"从脚本库移除;可选择同时删除已安装的文件。":"从脚本库移除;你的目录不会被删除。","agent 为它写的脚本包一起删掉,从技能库下载的保留。"]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"danger-outline small-button",disabled:S,onClick:()=>k(!0),children:"移除"})]})}),g!==null&&n.jsx("div",{className:"notice info",children:g}),f!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:f})]})]})}function v7({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,f=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}${f}${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(Ce(d))}finally{i(!1)}};return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"notice info left small skill-update-note",children:[n.jsx(ee,{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(ee,{name:"alert"}),n.jsx("span",{children:r})]})]})}function y7({client:e,openSession:t,arg:s}){const{data:i,error:r}=ih(e),o=aw(e),l=dO(e),[u,d]=v.useState(null),[h,f]=v.useState(null);v.useEffect(()=>{(s==null?void 0:s.startsWith("mirror:"))===!0&&f({kind:"mirror",rid:s.slice(7)})},[s]);const p=(i==null?void 0:i.scripts)??[],g=((i==null?void 0:i.packs)??[]).filter(_=>!_.installed&&_.repo!==void 0&&_.error===void 0),x=((i==null?void 0:i.packs)??[]).filter(_=>_.error!==void 0),b=((i==null?void 0:i.known)??[]).filter(_=>!_.installed),k=(i==null?void 0:i.setups)??[],j=k.filter(_=>!p.some(z=>z.id===_.scriptId)),N=h===null?j.find(_=>_.scriptId===u):void 0,C=u===null||p.some(_=>_.id===u)||N!==void 0?void 0:o.get(u),S=p.find(_=>_.id===u)??(h===null&&C===void 0&&N===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:()=>f({kind:"import"}),children:[n.jsx(ee,{name:"paperclip"}),"导入本地项目"]}),n.jsxs("button",{className:"small-button",onClick:()=>f({kind:"mirror"}),children:[n.jsx(ee,{name:"plus"}),"从 Mirror酱 安装"]}),n.jsxs("button",{className:"primary small-button",onClick:()=>f({kind:"install"}),children:[n.jsx(ee,{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(ee,{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(_a)&&n.jsxs("div",{className:"sidebar-empty",children:[n.jsx(ee,{name:"package"}),n.jsx("span",{children:"还没有脚本"}),n.jsx("span",{children:"从下面的脚本包安装,或导入已有目录"})]}),p.map(_=>{var H,B;const z=o.get(_.id),P=((H=_.env)==null?void 0:H.items.filter(O=>O.status!=="ok"&&O.status!=="unsupported").length)??0;return n.jsxs("button",{className:`script-row ${_.id===(S==null?void 0:S.id)&&h===null?"active":""}`,onClick:()=>{d(_.id),f(null)},children:[n.jsx(V_,{client:e,iconKey:`script:${_.id}:${_.current??""}`,name:_.name,className:"script-avatar",load:()=>e.connection.call("scripts/icon",{id:_.id})}),n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:_.name}),n.jsxs("span",{className:"muted small",children:[ib(_,l).length>0&&n.jsx("span",{className:"skill-update-hint",title:"这个脚本的技能在技能库里有新版",children:"技能有新版 · "}),_.source.kind==="local"?"本地":_.current??"未安装",_.family===void 0?"":` · ${ow[_.family]??_.family}`]})]}),_a(z)?n.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):k.some(O=>O.scriptId===_.id)?n.jsx("span",{className:"badge warn",children:"待安装"}):((B=_.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]},_.id)}),j.length>0&&n.jsxs("div",{className:"sidebar-label",children:["等待安装(",j.length,")"]}),j.map(_=>{var z,P,H;return n.jsxs("button",{className:`script-row ${_===N?"active":""}`,onClick:()=>{d(_.scriptId),f(null)},children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:_.name}),n.jsxs("span",{className:"muted small",children:[_.version," · ",((z=_.agent)==null?void 0:z.state)==="running"?"agent 正在安装":((P=_.agent)==null?void 0:P.state)==="failed"?"agent 没能装好":"安装程序已下载"]})]}),((H=_.agent)==null?void 0:H.state)==="running"?n.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):n.jsx("span",{className:"badge warn",children:"待安装"})]},_.scriptId)}),[...o.values()].filter(_=>_a(_)&&!p.some(z=>z.id===_.scriptId)).map(_=>n.jsxs("button",{className:`script-row ${u===_.scriptId&&h===null?"active":""}`,onClick:()=>{d(_.scriptId),f(null)},children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:_.scriptId}),n.jsxs("span",{className:"muted small",children:["正在安装 · ",bc[_.phase],_.total!==void 0&&_.received!==void 0&&_.total>0?` ${Math.floor(_.received/_.total*100)}%`:""]})]}),n.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"})]},_.id)),(g.length>0||b.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-label pack-label",children:"可安装的脚本包"}),g.map(_=>n.jsxs("div",{className:"pack-row",children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:_.name}),n.jsx("span",{className:"muted small",children:_.description??_.repo})]}),n.jsx("button",{className:"small-button",onClick:()=>f({kind:"install",repo:_.repo}),children:"安装"})]},_.id)),b.map(_=>n.jsxs("div",{className:"pack-row",children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:_.name}),n.jsx("span",{className:"muted small",children:[_.mirrorchyan===void 0?void 0:`Mirror酱 ${_.mirrorchyan}`,_.repo].filter(Boolean).join(" · ")})]}),n.jsx("button",{className:"small-button",onClick:()=>f(_.mirrorchyan!==void 0?{kind:"mirror",rid:_.mirrorchyan}:{kind:"install",repo:_.repo}),children:"安装"})]},_.id))]}),x.length>0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsxs("span",{children:[x.length," 个脚本包无法读取:",x.map(_=>_.id).join("、")]})]})]})]}),n.jsxs("div",{className:"scripts-detail",children:[(h==null?void 0:h.kind)==="install"&&n.jsx(H8,{client:e,jobs:o,...h.repo===void 0?{}:{initialRepo:h.repo},onClose:()=>f(null),onDone:_=>{d(_),f(null)},openSession:t},h.repo??"blank"),(h==null?void 0:h.kind)==="mirror"&&n.jsx(Z8,{client:e,jobs:o,...h.rid===void 0?{}:{initialRid:h.rid},onClose:()=>f(null),onDone:_=>{d(_),f(null)},openSession:t,onGitHub:_=>f({kind:"install",repo:_})},h.rid??"blank"),(h==null?void 0:h.kind)==="import"&&n.jsx(K8,{client:e,onClose:()=>f(null),onImported:_=>{d(_),f(null)}}),h===null&&S!==void 0&&n.jsx(x7,{client:e,script:S,skillUpdates:ib(S,l),job:o.get(S.id),setup:k.find(_=>_.scriptId===S.id),onRemoved:()=>d(null),openSession:t},S.id),N!==void 0&&n.jsx(J_,{client:e,setup:N,openSession:t,onImported:_=>d(_)},N.scriptId),h===null&&S===void 0&&C!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:C.scriptId}),n.jsx("p",{className:"muted small",children:_a(C)?"正在安装,装好后这里显示脚本的详情":"安装没有完成"})]})}),n.jsx(bg,{client:e,job:C})]}),h===null&&S===void 0&&C===void 0&&N===void 0&&i!==null&&n.jsxs("div",{className:"empty",children:[[...o.values()].filter(_=>_a(_)&&!p.some(z=>z.id===_.scriptId)).map(_=>n.jsxs("div",{className:"pending-install",children:[n.jsx("strong",{children:_.scriptId}),n.jsx(bg,{client:e,job:_})]},_.id)),n.jsx("p",{children:"选择左侧的脚本查看详情,或安装一个新脚本。"})]}),i!==null&&n.jsxs("p",{className:"tools-dir muted small",children:["工具目录:",i.toolsDir]})]})]})]})}const b7={id:"scripts",title:"脚本库",milestone:"M1",requires:["scripts"],pages:[{id:"scripts",title:"脚本",icon:"package",order:10,agent:"scripts",component:y7}],settingsPages:[{id:"script-install",title:"脚本安装",order:10,component:B8}]},k7={id:"emulators",title:"模拟器",milestone:"M2",requires:["emulators"],settingsPages:[{id:"emulators",title:"模拟器",order:11,component:U8}]},ap="https://github.com/haaahhhis/MultiGameAssistant";function j7({client:e}){const[t,s]=v.useState(void 0),i=Hw(e),r=t===null?i===void 0?void 0:i===!1?null:i.version:null;v.useEffect(()=>{var d;const l=(d=li())==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:ap,target:"_blank",rel:"noreferrer",children:ap.replace("https://","")})}),n.jsx("dt",{children:"许可证"}),n.jsx("dd",{children:n.jsx("a",{href:`${ap}/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(N7,{}):typeof r=="string"&&n.jsx(w7,{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 N7(){const{bridge:e,state:t}=nx();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(ee,{name:"refresh"}),"检查更新"]})]}),s!==void 0&&n.jsx("div",{className:"about-release-notes",children:n.jsx(sx,{notes:s.notes??[],notesUrl:s.notesUrl})}),t!==void 0&&n.jsx(ix,{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 w7({client:e}){var r;const t=Zw(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(ee,{name:"refresh"}),"检查更新"]})]}),s!==void 0&&!t.checking&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"about-release-notes",children:n.jsx(sx,{notes:s.notes??[],notesUrl:s.notesUrl})}),n.jsx(Gw,{version:s.version,onNpm:s.onNpm})]})]})}const ic=e=>e.replace(/\/+$/,""),Pj=e=>{const t=ic(e);return t.endsWith("/v1")?t.slice(0,-3):t},eE=[{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=>`${Pj(e)}/v1/messages`,listPath:e=>`${Pj(e)}/v1/models`}];function jg(e){return eE.find(t=>t.id===e)}function S7(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,40)}function _7(e){return`${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}_API_KEY`}const E7=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function C7(e){try{const{protocol:t}=new URL(e);return t==="http:"||t==="https:"}catch{return!1}}function Ea(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 tE=1e6,Vl=e=>(e.contextWindow??0)>=tE;function A7({client:e,profile:t,preset:s,taken:i,revision:r,readOnly:o,onDone:l}){var ne;const u=t===void 0,d=s===void 0||s.id===""?"":i.includes(s.id)?`${s.id}-2`:s.id,[h,f]=v.useState(()=>{var te;return((te=jg((t==null?void 0:t.api)??(s==null?void 0:s.api)))==null?void 0:te.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,b]=v.useState((t==null?void 0:t.id)??d),[k,j]=v.useState(!u||d!==""),[N,C]=v.useState((t==null?void 0:t.baseURL)??(s==null?void 0:s.baseURL)??""),[S,_]=v.useState(""),[z,P]=v.useState((t==null?void 0:t.models)??[]),[H,B]=v.useState(!1),[O,T]=v.useState(null),D=jg(h),U=N.trim(),A=U!==""&&!C7(U),I=x!==""&&!E7.test(x),R=u&&i.includes(x),L=sE(S),K=(t==null?void 0:t.apiKeyRef)??(x===""?null:_7(x)),F=((ne=t==null?void 0:t.credential)==null?void 0:ne.configured)===!0,q=(t==null?void 0:t.credential)!==void 0&&!t.credential.writable,V=x===""?"请填写标识":I?"标识格式不正确":R?"这个标识已被占用":U===""?"请填写 Base URL":A?"Base URL 需要以 http:// 或 https:// 开头":L!==null?L:z.length===0?"至少需要一个模型:点击「拉取模型列表」或手动添加":null,Z=te=>{g(te),k||b(S7(te))},Q=async()=>{if(V===null){B(!0),T(null);try{await e.saveProvider({id:x,create:u,...p.trim()===""?{}:{displayName:p.trim()},api:h,baseURL:U,models:[...z],...S.trim()===""?{}:{apiKey:S.trim()},expectedRevision:r}),l()}catch(te){const re=te instanceof Error?te.message:String(te);T(/SETTINGS_CONFLICT|conflict/i.test(re)?"配置在别处被修改过了,请返回列表后重试。":re)}finally{B(!1)}}},G=H||o;return n.jsxs("form",{className:"provider-editor",onSubmit:te=>{te.preventDefault(),Q()},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:eE.map(te=>n.jsxs("button",{type:"button",role:"radio","aria-checked":h===te.id,"aria-label":`${te.title}(${te.subtitle})`,className:`mode-option${h===te.id?" selected":""}`,onClick:()=>f(te.id),disabled:G,children:[n.jsx("span",{className:"mode-title",children:te.title}),n.jsx("span",{className:"mode-subtitle",children:te.subtitle})]},te.id))}),n.jsx("div",{className:"muted small",children:D.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:te=>Z(te.target.value),placeholder:"例如:我的中转站",disabled:G})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"标识"}),n.jsx("input",{className:"text-input",value:x,onChange:te=>{b(te.target.value.trim()),j(!0)},placeholder:"my-gateway",disabled:G||!u,spellCheck:!1})]})]}),n.jsx("div",{className:I||R?"error small":"muted small",children:I?"标识只能用小写字母、数字和单个连字符,并以字母开头。":R?"这个标识已被占用(可能是已有的提供方或 dsh 内置提供方)。":u?"用于区分提供方,保存后不能修改。":"标识创建后不能修改。"}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"Base URL"}),n.jsx("input",{className:"text-input",value:N,onChange:te=>C(te.target.value),placeholder:D.placeholder,disabled:G,spellCheck:!1})]}),A?n.jsx("div",{className:"error small",children:"Base URL 需要以 http:// 或 https:// 开头。"}):U!==""&&n.jsxs("div",{className:"muted small endpoint-preview",children:["对话请求 ",n.jsxs("code",{children:["POST ",D.requestPath(U)]}),n.jsx("br",{}),"模型列表 ",n.jsxs("code",{children:["GET ",D.listPath(U)]})]}),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:te=>_(te.target.value),placeholder:q?"由启动环境变量提供,无法在此修改":F?"已配置,留空则保持不变":"粘贴 Key;本地服务不需要时可留空",autoComplete:"new-password",disabled:G||q,spellCheck:!1})]}),L!==null?n.jsx("div",{className:"error small",children:L}):K!==null&&n.jsxs("div",{className:"muted small",children:["保存在 dsh 凭据 ",n.jsx("code",{children:K})," 中,界面不会再显示 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($7,{client:e,models:z,onChange:P,probe:{...t===void 0?{}:{provider:t.id},api:h,baseURL:U,apiKey:S.trim()},probeBlocked:U===""?"先填写 Base URL":A?"Base URL 无效":L,disabled:G}),O!==null&&n.jsx("div",{className:"banner error",children:O}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:V}),n.jsx("span",{className:"spacer"}),n.jsx("button",{type:"button",onClick:l,disabled:H,children:"取消"}),n.jsx("button",{type:"submit",className:"primary",disabled:G||V!==null,children:H?"保存中…":u?"创建":"保存"})]})]})}function $7({client:e,models:t,onChange:s,probe:i,probeBlocked:r,disabled:o}){const[l,u]=v.useState(null),[d,h]=v.useState(""),[f,p]=v.useState(""),[g,x]=v.useState(!1),[b,k]=v.useState(null),j=v.useRef(null),N=v.useMemo(()=>new Set(t.map(T=>T.id)),[t]),C=async()=>{var D;(D=j.current)==null||D.abort();const T=new AbortController;j.current=T,x(!0),k(null);try{const U=await e.discoverModels({...i.provider===void 0?{}:{provider:i.provider},api:i.api,baseURL:i.baseURL,...i.apiKey===""?{}:{apiKey:i.apiKey}},T.signal);if(T.signal.aborted)return;u([...U].sort((A,I)=>A.id.localeCompare(I.id))),U.length===0&&k("接口返回了空的模型列表,可以手动添加模型 ID。")}catch(U){T.signal.aborted||k(U instanceof Error?U.message:String(U))}finally{j.current===T&&(j.current=null,x(!1))}},S=T=>{s(N.has(T.id)?t.filter(D=>D.id!==T.id):[...t,T])},_=T=>{s(t.map(D=>{if(D.id!==T)return D;if(D.efforts!==void 0&&D.efforts.length>0){const{efforts:U,...A}=D;return A}return{...D,efforts:["off","low","medium","high"]}}))},z=T=>{s(t.map(D=>{var U;return D.id!==T?D:{...D,input:((U=D.input)==null?void 0:U.includes("image"))===!0?["text"]:["text","image"]}}))},P=T=>{s(t.map(D=>{if(D.id!==T)return D;if(Vl(D)){const{contextWindow:U,...A}=D;return A}return{...D,contextWindow:tE}}))},H=v.useMemo(()=>{const T=d.trim().toLowerCase();return(l??[]).filter(D=>T===""||D.id.toLowerCase().includes(T)||(D.name??"").toLowerCase().includes(T))},[l,d]),B=T=>{if(T){const D=H.filter(U=>!N.has(U.id));s([...t,...D])}else{const D=new Set(H.map(U=>U.id));s(t.filter(U=>!D.has(U.id)))}},O=()=>{const T=f.split(/[\s,,]+/).map(D=>D.trim()).filter(D=>D!==""&&!N.has(D));T.length!==0&&(s([...t,...T.map(D=>(l==null?void 0:l.find(U=>U.id===D))??{id:D})]),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 C(),disabled:o||g||r!==null,title:r??void 0,children:g?"拉取中…":l===null?"拉取模型列表":"重新拉取"})]}),b!==null&&n.jsx("div",{className:"error small",children:b}),t.length>0&&n.jsx("div",{className:"model-chips",children:t.map(T=>{var D,U,A,I,R,L;return n.jsxs("span",{className:"chip removable",children:[T.id,!Vl(T)&&Ea(T.contextWindow)!==null&&n.jsxs("span",{className:"muted",children:[" · ",Ea(T.contextWindow)]}),n.jsx("button",{type:"button",className:`chip-flag${((D=T.input)==null?void 0:D.includes("image"))===!0?" on":""}`,onClick:()=>z(T.id),disabled:o,"aria-pressed":((U=T.input)==null?void 0:U.includes("image"))===!0,title:((A=T.input)==null?void 0:A.includes("image"))===!0?"支持图片输入(点击关闭)":"不支持图片输入(点击开启)",children:"图片"}),n.jsx("button",{type:"button",className:`chip-flag${(((I=T.efforts)==null?void 0:I.length)??0)>0?" on":""}`,onClick:()=>_(T.id),disabled:o,"aria-pressed":(((R=T.efforts)==null?void 0:R.length)??0)>0,title:(((L=T.efforts)==null?void 0:L.length)??0)>0?`可选思考强度:${T.efforts.join(" / ")}(点击关闭)`:"没有声明思考强度(点击开启:不思考 / 低 / 中 / 高)",children:"思考"}),n.jsx("button",{type:"button",className:`chip-flag${Vl(T)?" on":""}`,onClick:()=>P(T.id),disabled:o,"aria-pressed":Vl(T),title:Vl(T)?"按 1M 上下文计算,快满时才压缩(点击关闭)":T.contextWindow!==void 0?`上下文 ${Ea(T.contextWindow)}(点击改为 1M)`:"上下文大小未知,dsh 默认按 1M 计算(点击写明 1M)",children:"1M"}),n.jsx("button",{type:"button",className:"chip-x",onClick:()=>s(t.filter(K=>K.id!==T.id)),disabled:o,"aria-label":`移除 ${T.id}`,children:"×"})]},T.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:T=>h(T.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(T=>{var D;return n.jsx("li",{children:n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:N.has(T.id),onChange:()=>S(T),disabled:o}),n.jsx("span",{className:"mono",children:T.id}),T.name!==void 0&&n.jsxs("span",{className:"muted",children:[" ",T.name]}),n.jsx("span",{className:"spacer"}),((D=T.input)==null?void 0:D.includes("image"))===!0&&n.jsx("span",{className:"badge",children:"图像"}),Ea(T.contextWindow)!==null&&n.jsxs("span",{className:"muted small",children:[Ea(T.contextWindow)," 上下文"]})]})},T.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:f,onChange:T=>p(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),O())},placeholder:"手动添加模型 ID,多个用空格或逗号分隔",disabled:o,spellCheck:!1}),n.jsx("button",{type:"button",onClick:O,disabled:o||f.trim()==="",children:"添加"})]})]})}const I7=[{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:""}],op=[{id:"deepseek-official",name:"DeepSeek",note:"内置,只需要填 Key",keyRef:_p,keyUrl:"https://platform.deepseek.com/api_keys"}];function T7({client:e}){const{catalog:t}=Ga(e),[s,i]=v.useState(!1),[r,o]=v.useState(void 0),l=ke(e.providersRevision),u=ke(e.credentialRevision),d=ke(e.connection.status),[h,f]=v.useState(null),[p,g]=v.useState(null),[x,b]=v.useState(null),[k,j]=v.useState(null),N=v.useCallback(()=>{e.listProviders().then(S=>{f(S),g(null)}).catch(S=>g(S instanceof Error?S.message:String(S)))},[e]);if(v.useEffect(()=>{d.state==="open"&&N()},[N,l,u,d.state]),x!==null&&h!==null){const S=x==="new"?void 0:h.providers.find(_=>_.id===x);return n.jsx("section",{className:"providers-section",children:n.jsx(A7,{client:e,profile:S,preset:x==="new"?r:void 0,taken:h.taken,revision:h.revision,readOnly:!h.writable,onDone:()=>{b(null),o(void 0),N()}},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:[op.map(S=>n.jsxs("button",{className:"preset-option",onClick:()=>{var _;i(!1),(_=document.getElementById(`builtin-${S.id}`))==null||_.scrollIntoView({behavior:"smooth"})},children:[n.jsx("span",{className:"mode-title",children:S.name}),n.jsx("span",{className:"mode-subtitle",children:S.note})]},S.id)),I7.map(S=>n.jsxs("button",{className:"preset-option",disabled:h===null||!h.writable,onClick:()=>{o(S),i(!1),b("new")},children:[n.jsx("span",{className:"mode-title",children:S.name}),n.jsx("span",{className:"mode-subtitle",children:S.note})]},S.key))]})]});const C=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 的凭据文件里,界面不会再显示。"}),op.map(S=>n.jsx(O7,{client:e,provider:S,catalog:t},S.id)),t==null?void 0:t.groups.filter(S=>!C.has(S.id)&&!op.some(_=>_.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(_=>n.jsx("span",{className:"chip",children:_.name},_.id))})]},S.id)),p!==null&&n.jsx("div",{className:"banner error",children:p}),k!==null&&n.jsx("div",{className:"success small",children:k}),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(M7,{client:e,profile:S,revision:h.revision,readOnly:!h.writable,onEdit:()=>b(S.id),onRemoved:_=>{j(_?"已删除。它原本是新会话的默认模型,默认模型已恢复为 profile 自带的设置。":null),N()}},S.id))]})}function M7({client:e,profile:t,revision:s,readOnly:i,onEdit:r,onRemoved:o}){const[l,u]=v.useState(!1),[d,h]=v.useState(null),f=jg(t.api),p=async()=>{var x,b;const g=t.apiKeyRef!==void 0&&((x=t.credential)==null?void 0:x.source)==="file"?`
237
+
238
+ 同时删除已保存的 Key(${t.apiKeyRef})。`:"";if(await Ms({title:`删除「${t.displayName}」?`,message:`使用它的会话需要换一个模型。${g}`,confirmLabel:"删除",danger:!0})){u(!0),h(null);try{const{defaultReset:k}=await e.removeProvider({id:t.id,removeKey:((b=t.credential)==null?void 0:b.source)==="file",expectedRevision:s});o(k)}catch(k){h(k instanceof Error?k.message:String(k))}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:f===void 0?t.api??"内置目录":`${f.title} · ${f.subtitle}`}),n.jsx(R7,{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,Ea(g.contextWindow)!==null&&n.jsxs("span",{className:"muted",children:[" · ",Ea(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 R7({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 O7({client:e,provider:t,catalog:s}){const{items:i}=rw(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(D7,{client:e,refName:t.keyRef,title:`${t.name} API Key`,description:"",helpUrl:t.keyUrl,info:r,bare:!0})]})}const fc="",rc=e=>e==null?fc:`${e.provider}/${e.model}`;function Lj(e){if(e===fc)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 dd(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 P7({client:e}){const{catalog:t,error:s}=Ga(e),i=ke(e.capabilities),r=ke(e.connection.status),o=qs(e),[l,u]=v.useState(null),[d,h]=v.useState(!1),[f,p]=v.useState(null),g=i.has("agent-models");v.useEffect(()=>{if(r.state!=="open"||!g)return;let C=!0;return e.connection.call("models/agentModels",{}).then(S=>{C&&u(S)}).catch(()=>{}),()=>{C=!1}},[e,r.state,g]),v.useEffect(()=>e.connection.on("models/agentModelsChanged",u),[e]);const x=async C=>{h(!0),p(null);try{p(await C())}catch(S){p({tone:"warn",text:S instanceof Error?S.message:String(S)})}finally{h(!1)}},b=C=>void x(async()=>{const S=Lj(C);return await e.connection.call("models/setDefault",S),{tone:"ok",text:`默认模型换成了 ${ql(t,S)}:助手和跟随默认的 agent 从下一句起用它。`}}),k=(C,S,_)=>void x(async()=>{const z=Lj(_),{warning:P}=await e.connection.call("models/setAgentModel",{...C===void 0?{}:{agentId:C.id},...S?{sub:!0}:{},model:z});if(u(O=>O===null?O:L7(O,C==null?void 0:C.id,S,z)),P!==void 0)return{tone:"warn",text:P};const H=z===null?void 0:ql(t,z);if(!S)return{tone:"ok",text:H===void 0?`「${C.name}」改回跟随默认模型,从下一句起生效。`:`「${C.name}」的对话从下一句起用 ${H}。`};const B=C===void 0?"没单独设的子 agent":`「${C.name}」新开的子 agent`;return{tone:"ok",text:H===void 0?`${B}改回跟随,正在干活的不受影响。`:`${B}用 ${H},正在干活的不受影响。`}}),j=[cn,...o.map(Ya)],N=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}),!N&&s===null&&n.jsx("div",{className:"muted small",children:"读取中…"}),N&&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(Ot,{"aria-label":"所有子 agent 的模型",value:rc(l.subAgents),disabled:d,onChange:C=>k(void 0,!0,C),options:[{value:fc,label:"和开它的 agent 一样"},...dd(t,l.subAgents)]})]})]}),j.map(C=>{const S=C.id===cn.id,_=S?t.default:(l==null?void 0:l.agents[C.id])??null,z=_??t.default,P=(l==null?void 0:l.subAgentsOf[C.id])??null,H=(l==null?void 0:l.subAgents)==null?`和${C.name}一样(${ql(t,z)})`:`跟随上面(${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:C.name}),n.jsx("span",{className:"muted small",children:S?"它用的就是默认模型":C.description})]}),n.jsxs("div",{className:"agent-models-cell",role:"cell",children:[n.jsx("span",{className:"agent-models-cell-label",children:"对话"}),S?n.jsx(Ot,{"aria-label":"默认模型(助手)",value:rc(_),disabled:d||!i.has("model-default"),onChange:b,options:dd(t,_)}):n.jsx(Ot,{"aria-label":`${C.name}的模型`,value:rc(_),disabled:d||!g,onChange:B=>k(C,!1,B),options:[{value:fc,label:`跟随默认(${ql(t,t.default)})`},...dd(t,_)]})]}),g&&n.jsxs("div",{className:"agent-models-cell",role:"cell",children:[n.jsx("span",{className:"agent-models-cell-label",children:"子 agent"}),n.jsx(Ot,{"aria-label":`${C.name}的子 agent 的模型`,value:rc(P),disabled:d,onChange:B=>k(C,!0,B),options:[{value:fc,label:H},...dd(t,P)]})]})]},C.id)})]}),t==null?void 0:t.failures.map(C=>n.jsxs("div",{className:"error small",children:[C.name,":",C.message]},C.id)),f!==null&&n.jsx("div",{className:f.tone==="ok"?"muted small":"error small",children:f.text})]})}function L7(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 nE={file:"dsh 凭据文件",env:"启动环境变量","project-env":"项目 .env 文件","user-env":"dsh 主目录 .env 文件"};function sE(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 z7({client:e}){const t=ke(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(P7,{client:e}),t.has("providers")&&n.jsx(T7,{client:e})]})}function D7({client:e,refName:t,title:s,description:i,helpUrl:r,info:o,placeholder:l,bare:u=!1}){const[d,h]=v.useState(""),[f,p]=v.useState(!1),[g,x]=v.useState(!1),[b,k]=v.useState(null),j=sE(d),N=o!==null&&!o.writable,C=async()=>{if(!(d.trim()===""||j!==null)){x(!0),k(null);try{await e.setCredential(t,d.trim()),h(""),p(!1),k({tone:"ok",text:"已保存,立即生效。"})}catch(z){k({tone:"error",text:z instanceof Error?z.message:String(z)})}finally{x(!1)}}},S=async()=>{if(await Ms({title:`删除已保存的 ${s}?`,message:"删除后需要重新填写才能使用对应模型。",confirmLabel:"删除",danger:!0})){x(!0),k(null);try{await e.unsetCredential(t),k({tone:"ok",text:"已删除。"})}catch(z){k({tone:"error",text:z instanceof Error?z.message:String(z)})}finally{x(!1)}}},_=u?"div":"section";return n.jsxs(_,{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(F7,{info:o})]}),N?n.jsxs("div",{className:"notice info left",children:["当前 Key 来自",nE[o.source??""]??o.source,",优先级高于界面保存的值,因此这里无法修改。 如需在界面中管理,请先从启动 dsh 的环境中移除 ",n.jsx("code",{children:t})," 再重新启动。"]}):n.jsxs("form",{className:"key-form",onSubmit:z=>{z.preventDefault(),C()},children:[n.jsxs("div",{className:"key-input",children:[n.jsx("input",{type:f?"text":"password",value:d,onChange:z=>{h(z.target.value),k(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(z=>!z),disabled:d==="",children:f?"隐藏":"显示"})]}),j!==null&&n.jsx("div",{className:"error small",children:j}),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()===""||j!==null,children:g?"保存中…":(o==null?void 0:o.configured)===!0?"替换":"保存"})]})]}),b!==null&&n.jsx("div",{className:b.tone==="ok"?"success small":"error small",children:b.text})]})}function F7({info:e}){return e===null?n.jsx("span",{className:"badge",children:"读取中…"}):e.configured?n.jsxs("span",{className:"badge ok",children:["已配置 · ",nE[e.source??""]??e.source??"未知来源"]}):n.jsx("span",{className:"badge warn",children:"未配置"})}const U7=(e,t)=>e===null||t===null?e===t:e.provider===t.provider&&e.model===t.model,B7=(e,t)=>e.auto===t.auto&&e.threshold===t.threshold&&U7(e.summarizer,t.summarizer),Ng="\0",zj=e=>e===null?"":`${e.provider}${Ng}${e.model}`;function H7({client:e}){var C;const t=ke(e.connection.status),[s,i]=v.useState(null),[r,o]=v.useState(null),[l,u]=v.useState(!1),[d,h]=v.useState(null),f=(C=li())==null?void 0:C.restartService,{catalog:p}=Ga(e),g=S=>{if(S===null)return"对话自己的模型";const _=p==null?void 0:p.groups.find(P=>P.id===S.provider),z=_==null?void 0:_.models.find(P=>P.id===S.model);return z===void 0?`${S.provider} / ${S.model}`:`${_.name} · ${z.name}`},x=vx();v.useEffect(()=>{if(d===null||s===null)return;if(d===s.settings.threshold){h(null);return}const S=setTimeout(()=>void b({...s.settings,threshold:d}).then(()=>h(null)),400);return()=>clearTimeout(S)},[d,s]),v.useEffect(()=>{if(t.state!=="open")return;let S=!0;return e.connection.call("compaction/get",{}).then(_=>{S&&i(_)}).catch(_=>{S&&o(Ce(_))}),()=>{S=!1}},[e,t.state]);const b=async S=>{if(!(!S.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:S}))}catch(_){o(Ce(_))}finally{u(!1)}}},k=async()=>{f===void 0||!await Ms({title:"现在重启 agent 服务?",message:"正在进行的对话和正在跑的脚本、流水线会被中断,大约需要半分钟。",confirmLabel:"重启",danger:!0,icon:"refresh"})||await f()},j=(s==null?void 0:s.settings.summarizer)??null,N=j!==null&&p!==null&&!p.groups.some(S=>S.id===j.provider&&S.models.some(_=>_.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:S=>void b({...s.settings,auto:S.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)===l2?"(默认)":""]}),n.jsx("input",{type:"range",min:VN,max:qN,step:5,value:d??s.settings.threshold,disabled:!s.settings.auto,"aria-label":"压缩阈值(百分比)",onChange:S=>h(Number(S.target.value))}),n.jsx("span",{className:"muted small",children:"调低:压缩得早,回复快、花费少,但记得的细节少;调高:记得的多,但更可能临时压缩一大段。100% 是到上下文快满时才压缩(会留出回复的空间)。"}),(d??s.settings.threshold)<c2&&s.settings.auto&&n.jsxs("span",{className:"notice warn-box left small compaction-warn",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:"这么低时,光是系统提示和工具说明就可能接近这个用量,几乎每一步都会压缩一次,每次都要调用模型写摘要。想让上下文保持很短,用下面的「低上下文模式」更合适。"})]})]}),n.jsxs("label",{className:"field compaction-summarizer",children:[n.jsx("span",{className:"field-title",children:"写摘要的模型"}),n.jsx(Ot,{"aria-label":"写摘要的模型",value:zj(s.settings.summarizer),disabled:l||p===null,onChange:S=>{const[_="",z=""]=S.split(Ng);b({...s.settings,summarizer:S===""?null:{provider:_,model:z}})},options:[{value:"",label:"和对话用同一个模型(默认)",hint:"能用上对话的提示缓存"},...((p==null?void 0:p.groups)??[]).flatMap(S=>S.models.map(_=>({value:`${S.id}${Ng}${_.id}`,label:_.name,hint:S.name}))),...N?[{value:zj(s.settings.summarizer),label:`${s.settings.summarizer.provider} / ${s.settings.summarizer.model}`,hint:"已不在模型列表里"}]:[]]}),n.jsx("span",{className:"muted small",children:"自动压缩、手动压缩和低上下文模式都由它读一遍要压缩的那段对话,写出摘要。默认用对话自己的模型,这段对话大多能命中它的提示缓存;换成别的模型时整段按没命中缓存计费,而且它的上下文要装得下这一段,装不下时压缩会失败。"}),N&&n.jsxs("span",{className:"notice warn-box left small compaction-warn",children:[n.jsx(ee,{name:"alert"}),n.jsxs("span",{children:["「",s.settings.summarizer.provider," / ",s.settings.summarizer.model,"」已经不在模型列表里了(服务被删掉或没有 Key),压缩会失败:换一个,或改回和对话用同一个模型。"]})]})]}),!B7(s.settings,s.applied)&&n.jsxs("div",{className:"notice left",children:[n.jsx(ee,{name:"info"}),n.jsxs("span",{children:["改动要重启 agent 服务才生效(现在还是:",s.applied.auto?`自动压缩,${s.applied.threshold}%`:"不自动压缩",";摘要由",g(s.applied.summarizer),"写)。",f===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),f!==void 0&&n.jsx("button",{className:"small-button",onClick:()=>void k(),children:"重启 agent 服务"})]}),r!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{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:S=>void b({...s.settings,lowContext:S.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:S=>void b({...s.settings,archiveDays:S.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(Ot,{"aria-label":"多久以后归档",value:String(s.settings.archiveDays),disabled:l||!s.settings.lowContext,onChange:S=>void b({...s.settings,archiveDays:Number(S)}),options:[...new Set([...h2,s.settings.archiveDays])].sort((S,_)=>S-_).map(S=>({value:String(S),label:`${S} 天`}))})]}),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:S=>void b({...s.settings,ptcSubagents:S.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(ee,{name:"info"}),n.jsxs("span",{children:["改动要重启 agent 服务才生效(现在还是:",s.applied.ptcSubagents?"用代码调用工具":"一次调用一个工具",")。",f===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),f!==void 0&&n.jsx("button",{className:"small-button",onClick:()=>void k(),children:"重启 agent 服务"})]})]}),n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"手动压缩"}),n.jsxs("p",{className:"muted small",children:["在对话框里输入 ",n.jsx("kbd",{children:"/压缩"}),",会先说明代价再确认。对话框旁边的小圆圈显示上下文用了多少,点开能看到各部分占多少。对话变慢、或报上下文超长时用;agent 正在工作时不能压缩。"]})]}),n.jsxs("section",{className:"card",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:x,onChange:S=>R3(S.target.checked)}),"显示「以前的对话」"]}),n.jsx("p",{className:"muted small",children:"在各个 agent 的顶部多一个「以前的对话」按钮,能翻看开新对话之前的聊天。默认不显示;关着时对话记录也不会删除。打开后,没有以前的对话的 agent 也不显示这个按钮。"})]}),s===null&&r!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:r})]})]})}const wg=[{kind:"core",title:"核心",hint:`你最在意的要求和偏好:每个 agent 每次都会带上,不会被挤掉;所有核心一共最多 ${Fg} 字,总是共享`},{kind:"profile",title:"资料",hint:"长期有效的事实和偏好"},{kind:"journal",title:"日记",hint:"某一天做过或决定的事"}],Z7={core:"核心",profile:"资料",journal:"日记"},Zr="",W7=["周日","周一","周二","周三","周四","周五","周六"];function V7(e){const t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function q7(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}日 ${W7[r.getDay()]}`;return l===0?`今天 · ${u}`:l===1?`昨天 · ${u}`:u}const pc=e=>e.kind==="journal"?e.createdAt:e.updatedAt,iE=(e,t)=>s=>{s.key==="Enter"&&(s.ctrlKey||s.metaKey)?(s.preventDefault(),e()):s.key==="Escape"&&(s.preventDefault(),t())};function G7({client:e}){var L,K;const t=ke(e.connection.status),s=qs(e),[i,r]=v.useState(null),[o,l]=v.useState(0),[u,d]=v.useState(ka),[h,f]=v.useState(Zr),[p,g]=v.useState(""),[x,b]=v.useState(!1),[k,j]=v.useState(null);v.useEffect(()=>e.connection.on("memory/changed",()=>l(F=>F+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let F=!0;return e.connection.call("memory/list",{}).then(q=>{F&&(r(q.items),j(null))}).catch(q=>{F&&j(Ce(q))}),()=>{F=!1}},[e,t.state,o]);const N=v.useMemo(()=>[{id:cn.id,name:cn.name},...s.map(F=>({id:F.id,name:F.name}))],[s]),C=F=>{var q;return F===ka?"共享":F==="user"?"你":F==="auto"?"自动整理":((q=N.find(V=>V.id===F))==null?void 0:q.name)??F},S=p.trim().toLowerCase().split(/\s+/).filter(F=>F!==""),_=F=>(i??[]).filter(q=>q.scope===F).length,z=(i??[]).filter(F=>F.scope===u),P=(i??[]).filter(F=>F.kind==="core").reduce((F,q)=>F+q.text.length,0),H=z.filter(F=>(h===Zr||F.kind===h)&&S.every(q=>F.text.toLowerCase().includes(q))).sort((F,q)=>pc(q).localeCompare(pc(F))),B=H.filter(F=>F.kind==="core"),O=[];for(const F of H.filter(q=>q.kind!=="core")){const q=V7(pc(F));((L=O.at(-1))==null?void 0:L.day)===q?O.at(-1).entries.push(F):O.push({day:q,entries:[F]})}const T=[{id:ka,name:"共享"},...N],D=((K=T.find(F=>F.id===u))==null?void 0:K.name)??u,U=u===ka,A=S.length>0||h!==Zr,I=async F=>{j(null);try{return await F(),l(q=>q+1),!0}catch(q){return j(Ce(q)),!1}},R=async(F,q)=>{const V=F==="core"?ka:u;return await I(()=>e.connection.call("memory/add",{kind:F,scope:V,text:q}))?(V!==u&&d(V),h!==Zr&&h!==F&&f(Zr),g(""),b(!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(K7,{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(Ot,{className:"scope-select","aria-label":"谁的记忆",value:u,onChange:d,options:T.map(F=>({value:F.id,label:F.id===ka?"共享的记忆":`「${F.name}」的记忆`,hint:_(F.id)===0?"还没有":`${_(F.id)} 条`,...F.id===ka?{}:{group:"一个 agent 自己的"}}))}),n.jsx("span",{className:"muted small",children:U?"每个 agent 都看得到":`只有「${D}」自己看得到`})]}),!x&&n.jsxs("button",{className:"small-button",onClick:()=>b(!0),children:[n.jsx(ee,{name:"plus"}),"记一条"]})]}),x&&n.jsx(Y7,{to:U?"共享":`「${D}」`,coreUsed:P,onAdd:R,onClose:()=>b(!1)}),k!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:k})]}),z.length>0&&n.jsxs("div",{className:"memory-filters",children:[n.jsx("div",{className:"memory-kinds",role:"radiogroup","aria-label":"种类",children:[{kind:Zr,title:"全部"},...wg].map(F=>n.jsxs("button",{role:"radio","aria-checked":h===F.kind,className:`filter-chip ${h===F.kind?"active":""}`,onClick:()=>f(F.kind),children:[F.title,n.jsx("span",{className:"memory-kind-count",children:F.kind===Zr?z.length:z.filter(q=>q.kind===F.kind).length})]},F.kind))}),n.jsxs("label",{className:"memory-search",children:[n.jsx(ee,{name:"search"}),n.jsx("input",{className:"text-input plain",type:"search",placeholder:"搜索(空格分开几个词)",value:p,onChange:F=>g(F.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," / ",Fg," 字)"]})}),n.jsx("ul",{className:"memory-list",children:B.map(F=>n.jsx(Dj,{entry:F,nameOf:C,onSave:q=>I(()=>e.connection.call("memory/update",{id:F.id,text:q})),onForget:()=>void Ms({title:"删掉这条核心记忆?",message:"之后 agent 就不会每次都带上它了,不能撤销。",quote:F.text,confirmLabel:"删掉",danger:!0}).then(q=>{q&&I(()=>e.connection.call("memory/remove",{id:F.id}))})},F.id))})]}),O.length===0&&B.length===0?n.jsxs("div",{className:"memory-empty",children:[n.jsx("p",{className:"muted",children:A?"没有找到。":`「${D}」还没有记忆。`}),A?n.jsx("button",{className:"link-button small",onClick:()=>{f(Zr),g("")},children:"清除筛选"}):n.jsx("p",{className:"muted small",children:"agent 干活时会自己记下,你也可以点「记一条」写给它。"})]}):O.map(F=>n.jsxs("div",{className:"memory-day",children:[n.jsx("h4",{className:"memory-day-title",children:n.jsx("span",{children:q7(F.day)})}),n.jsx("ul",{className:"memory-list",children:F.entries.map(q=>n.jsx(Dj,{entry:q,nameOf:C,onSave:V=>I(()=>e.connection.call("memory/update",{id:q.id,text:V})),onForget:()=>void Ms({title:"忘掉这条记忆?",message:"之后 agent 就不记得了,不能撤销。",quote:q.text,confirmLabel:"忘掉",danger:!0}).then(V=>{V&&I(()=>e.connection.call("memory/remove",{id:q.id}))})},q.id))})]},F.day))]})]}),i===null&&k!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:k})]})]})}function K7({client:e}){const t=ke(e.connection.status),{catalog:s}=Ga(e),[i,r]=v.useState(null),[o,l]=v.useState(!1),[u,d]=v.useState(null);v.useEffect(()=>{if(t.state!=="open")return;let b=!0;return e.connection.call("memory/auto/get",{}).then(k=>{b&&(r(k),d(null))}).catch(k=>{b&&d(Ce(k))}),()=>{b=!1}},[e,t.state]);const h=async b=>{l(!0),d(null);try{const k=await e.connection.call("memory/auto/set",{auto:b.auto,model:b.model});r({...k,...(i==null?void 0:i.forced)===!0?{forced:!0}:{}})}catch(k){d(Ce(k))}finally{l(!1)}};if(i===null)return u===null?null:n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:u})]});const f=i.auto||i.forced===!0,p=i.model===null?"":`${i.model.provider}/${i.model.model}`,g=p===""||((s==null?void 0:s.groups.some(b=>b.models.some(k=>`${b.id}/${k.id}`===p)))??!1),x=b=>{const[k,...j]=b.split("/");h({...i,model:b===""?null:{provider:k,model:j.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:f,disabled:o||i.forced===!0,onChange:b=>void h({...i,auto:b.target.checked})}),n.jsxs("span",{className:"memory-auto-text",children:[n.jsx("strong",{children:"自动整理"}),n.jsxs("span",{className:"muted small",children:["对话停下几分钟后,自动把没记下的偏好和做过的事整理进记忆",i.forced===!0?"。低上下文模式开着,自动整理会一直开着。":""]})]})]}),f&&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(Ot,{"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(b=>b.models.map(k=>({value:`${b.id}/${k.id}`,label:k.name,group:b.name})))]})]})]}),u!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:u})]})]})}function Y7({to:e,coreUsed:t,onAdd:s,onClose:i}){var b;const[r,o]=v.useState(""),[l,u]=v.useState("profile"),[d,h]=v.useState(!1),f=Fg-t,p=l==="core"&&r.trim().length>f,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:Ug,autoFocus:!0,"aria-label":"要记下的事",placeholder:"一句话写一件事,例如:日报只要告诉我有没有失败的;明日方舟只玩 B 服。",value:r,onChange:k=>o(k.target.value),onKeyDown:iE(()=>void x(),i)}),n.jsxs("div",{className:"memory-compose-foot",children:[n.jsx("div",{className:"segmented-control memory-kind",role:"radiogroup","aria-label":"种类",children:wg.map(k=>n.jsx("button",{role:"radio","aria-checked":l===k.kind,className:l===k.kind?"active":"",onClick:()=>u(k.kind),children:k.title},k.kind))}),n.jsxs("span",{className:`small memory-compose-hint ${p?"warn-text":"muted"}`,children:[(b=wg.find(k=>k.kind===l))==null?void 0:b.hint,l==="core"&&(p?`。核心只剩 ${Math.max(0,f)} 字了:先合并或删掉几条,或记成资料。`:`(还能写 ${f} 字)`)]}),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 Dj({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:pc(e),title:e.kind==="journal"?"记下的时间":"最后更新的时间",children:new Date(pc(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:Ug,value:r,onChange:f=>o(f.target.value),onKeyDown:iE(()=>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:Z7[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 Fj=[{policy:"default",label:"默认",hint:"跟着上面的模式走"},{policy:"allow",label:"允许",hint:"不问你,直接做"},{policy:"ask",label:"先问我",hint:"每次都先问你,「完全访问」时也问"},{policy:"deny",label:"不允许",hint:"agent 不能做,会告诉你被关掉了"}],X7=[{value:"auto",label:"自动更新"},{value:"ask",label:"先问我"},{value:"off",label:"不自动更新"}],Q7=[{value:"act",label:"诊断并处理"},{value:"diagnose",label:"只诊断"},{value:"off",label:"不干预"}];function J7({client:e,state:t,onState:s}){const i=ke(e.capabilities),[r,o]=v.useState(null),[l,u]=v.useState(null),[d,h]=v.useState(null),f=i.has("monitor"),p=i.has("scripts"),[g,x]=v.useState(null);v.useEffect(()=>{if(!p)return;let N=!0;return e.connection.call("scripts/settings",{}).then(C=>{N&&x(C.autoUpdate)}).catch(()=>{}),()=>{N=!1}},[e,p]),v.useEffect(()=>{if(!f)return;let N=!0;return e.connection.call("monitor/settings",{}).then(C=>{N&&h(C)}).catch(()=>{}),()=>{N=!1}},[e,f]);const b=async(N,C)=>{o(N),u(null);try{s(await e.connection.call("permissions/area/set",{area:N,policy:C}))}catch(S){u(Ce(S))}finally{o(null)}},k=async N=>{o("autoUpdate"),u(null);try{x((await e.connection.call("scripts/settings/set",{autoUpdate:N})).autoUpdate)}catch(C){u(Ce(C))}finally{o(null)}},j=async N=>{o("intervene"),u(null);try{h(await e.connection.call("monitor/settings/set",{intervene:N}))}catch(C){u(Ce(C))}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 能自己做的事,一项一项决定:",Fj.map(N=>`「${N.label}」${N.hint}`).join(";"),"。"]})]})}),n.jsxs("div",{className:"area-list",children:[f&&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:Q7.map(N=>n.jsx("button",{role:"radio","aria-checked":d.intervene===N.value,className:d.intervene===N.value?"active":"",disabled:r!==null,onClick:()=>void j(N.value),children:N.label},N.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:X7.map(N=>n.jsx("button",{role:"radio","aria-checked":g===N.value,className:g===N.value?"active":"",disabled:r!==null,onClick:()=>void k(N.value),children:N.label},N.value))})]}),ZR.map(N=>{const C=t.areas[N.id]??"default";return n.jsxs("div",{className:"area-row",children:[n.jsxs("div",{className:"area-text",children:[n.jsx("strong",{children:N.title}),n.jsx("span",{className:"muted small",children:N.description})]}),n.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":N.title,children:Fj.map(S=>n.jsx("button",{role:"radio","aria-checked":C===S.policy,title:S.hint,className:`${C===S.policy?"active":""} ${S.policy}`,disabled:r!==null,onClick:()=>void b(N.id,S.policy),children:S.label},S.policy))})]},N.id)})]}),l!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:l})]})]})}const eZ=[{mode:"ask",title:"每次确认(推荐)",text:"agent 的命令在沙箱里运行;安装陌生仓库、操作屏幕、沙箱外的命令、修改脚本文件等,都先问你。"},{mode:"full",title:"完全访问",text:"不用沙箱,所有需要确认的操作都自动允许,也可以修改脚本文件:agent 想改什么就改什么,不再问你。"}];function tZ({client:e}){const t=ke(e.connection.status),s=mn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(!1),[u,d]=v.useState(null);v.useEffect(()=>e.connection.on("permissions/changed",f=>r(f)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let f=!0;return e.connection.call("permissions/get",{}).then(p=>{f&&r(p)}).catch(p=>{f&&d(Ce(p))}),()=>{f=!1}},[e,t.state]);const h=async f=>{if((i==null?void 0:i.mode)!==f&&!(f==="full"&&!await Ms({title:"打开「完全访问」?",icon:"shield",confirmLabel:"打开",danger:!0,message:`打开后,agent 可以不经确认运行任何命令、修改或删除任何文件(包括脚本文件)、操作屏幕、安装软件。
239
+
240
+ 只在你信任当前模型、并且需要它自己完成整件事时打开。`}))){l(!0),d(null);try{r(await e.connection.call("permissions/set",{mode:f}))}catch(p){d(Ce(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:eZ.map(f=>n.jsxs("button",{role:"radio","aria-checked":(i==null?void 0:i.mode)===f.mode,disabled:o||i===null,className:`permission-option ${f.mode} ${(i==null?void 0:i.mode)===f.mode?"active":""}`,onClick:()=>void h(f.mode),children:[n.jsx("span",{className:"permission-dot","aria-hidden":"true"}),n.jsxs("span",{className:"permission-text",children:[n.jsx("strong",{children:f.title}),n.jsx("span",{children:f.text})]})]},f.mode))}),(i==null?void 0:i.mode)==="full"&&n.jsxs("div",{className:"notice warn-note left small",children:[n.jsx(ee,{name:"alert"}),n.jsxs("span",{children:["完全访问一直开着,没有时间限制,直到你改回「每次确认」",i.since===void 0?"":`(${nZ(i.since,s)})`,"。agent 不会再请求确认;它仍然不会替你输入密码、验证码或付款。agent 之间可以互相交事情,这时也不会有人拦:比如读网页时读到的内容,可能经别的 agent 变成运行或安装。"]})]}),u!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:u})]})]}),i!==null&&n.jsx(J7,{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((f,p)=>n.jsxs("li",{children:[n.jsx("span",{className:"badge",children:f.toolName}),n.jsx("span",{className:"permission-reason",children:f.reason??"(没有说明)"}),n.jsx("span",{className:"spacer"}),n.jsx("span",{className:"session-time",children:gt(f.at,s)})]},p))})]})]})}function nZ(e,t){const s=gt(e,t);return s==="刚刚"?"刚刚打开":/^\d+ (分钟|小时|天)$/.test(s)?`${s}前打开`:`${s} 打开`}const Sg=[{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:"今日日常已完成。另有一项需要您决定:活动商店剩余两件,是否明日继续兑换?"}],lp=[{style:"plain",title:"平实",text:"直接说事,不带人设和称呼:它们要读的是内容。推荐。"},{style:"same",title:"和对你一样",text:"人设也带到 agent 之间的往来里,你在「全部」里看到的就是这个语气。"}],cp="",Uj=e=>{var t;return((t=Sg.find(s=>s.style===e))==null?void 0:t.title)??e};function Bj(e){return e===void 0||e.style===void 0&&e.callUser===void 0&&e.custom===void 0&&e.peerStyle===void 0}const Hj=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 hd(e){const t=Object.entries(e.agents).map(([s,i])=>[s,Hj(i)]).filter(([,s])=>s.some(i=>i!=="")).sort(([s],[i])=>s.localeCompare(i));return JSON.stringify([Hj({...e.persona,peerStyle:e.persona.peerStyle??"plain"}),t])}function sZ({client:e}){var V,Z,Q,G,ne;const t=ke(e.connection.status),s=qs(e),[i,r]=v.useState(null),[o,l]=v.useState(null),[u,d]=v.useState(cp),[h,f]=v.useState(!1),[p,g]=v.useState(null),[x,b]=v.useState(!1),k=te=>{const re={persona:te.persona,agents:te.agents};r(re),l(re)};if(v.useEffect(()=>{if(t.state!=="open")return;let te=!0;return e.connection.call("persona/get",{}).then(re=>{te&&k(re)}).catch(re=>{te&&g(Ce(re))}),()=>{te=!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(ee,{name:"alert"}),n.jsx("span",{children:p})]})]});const j=hd(o)!==hd(i),N=te=>{l(te),b(!1)},C=async()=>{f(!0),g(null);try{k(await e.connection.call("persona/set",o)),b(!0)}catch(te){g(Ce(te))}finally{f(!1)}},S=[{id:cn.id,name:cn.name},...s.map(te=>({id:te.id,name:te.name}))],_=u===cp,z=o.persona,P=_?void 0:o.agents[u],H=((V=S.find(te=>te.id===u))==null?void 0:V.name)??u,B=te=>N({...o,persona:{...z,...te}}),O=te=>{const re=Object.fromEntries(Object.entries({...P,...te}).filter(([,X])=>X!==void 0&&(typeof X!="string"||X.trim()!=="")));N({...o,agents:{...o.agents,[u]:re}})},T=_?B:O,D=_?z:Yy(o,u),U=Xy(D),A=new Set(Xy(_?i.persona:Yy(i,u)).split(`
241
+ `)),I=((Z=Sg.find(te=>te.style===D.style))==null?void 0:Z.sample)??"",R=_?z.style:P==null?void 0:P.style,L=_?z.peerStyle??"plain":P==null?void 0:P.peerStyle,K=(te,re)=>_?re:te===void 0||te===""?"留空:跟随统一(现在没有设置)":`留空:跟随统一(${te})`,F=_?hd({persona:z,agents:{}})!==hd({persona:{style:"default"},agents:{}}):!Bj(P),q=()=>N(_?{...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(Ot,{className:"scope-select","aria-label":"设置给谁",value:u,onChange:d,options:[{value:cp,label:"所有 agent",hint:"统一设置"},...S.map(te=>{var se;const re=o.agents[te.id],X=(se=re==null?void 0:re.name)==null?void 0:se.trim();return{value:te.id,label:X?`${te.name}(${X})`:te.name,hint:Bj(re)?"跟随统一":"有单独设置",group:"只给一个 agent"}})]})]}),n.jsx("span",{className:`persona-state ${j?"dirty":""}`,role:"status",children:j?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"persona-dot"}),"有没保存的改动"]}):x?n.jsxs(n.Fragment,{children:[n.jsx(ee,{name:"check"}),"已保存,下一句回复开始生效"]}):null}),j&&n.jsx("button",{disabled:h,onClick:()=>N(i),children:"撤销"}),n.jsx("button",{className:"primary",disabled:h||!j,onClick:()=>void C(),children:h?"保存中…":"保存"})]}),p!==null&&n.jsxs("div",{className:"notice error left persona-error",children:[n.jsx(ee,{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:[!_&&n.jsx(Zj,{wide:!0,title:"跟随统一",note:`现在是「${Uj(z.style)}」`,selected:R===void 0,onClick:()=>O({style:void 0})}),Sg.map(te=>n.jsx(Zj,{title:te.title,note:te.note,selected:R===te.style,onClick:()=>T({style:te.style})},te.style))]})]}),n.jsxs("div",{className:"persona-pair",children:[!_&&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:te=>O({name:te.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:K(z.callUser,"例如:博士、开拓者、指挥官"),value:(_?z.callUser:P==null?void 0:P.callUser)??"",onChange:te=>T({callUser:te.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:K(z.custom,"例如:说话带一点罗德岛干员的口吻;汇报时先说有没有失败;不要用表情。"),value:(_?z.custom:P==null?void 0:P.custom)??"",onChange:te=>T({custom:te.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:[!_&&n.jsx("button",{role:"radio","aria-checked":L===void 0,className:L===void 0?"active":"",onClick:()=>O({peerStyle:void 0}),children:"跟随统一"}),lp.map(te=>n.jsx("button",{role:"radio","aria-checked":L===te.style,className:L===te.style?"active":"",onClick:()=>T({peerStyle:te.style}),children:te.title},te.style))]}),n.jsx("span",{className:"muted small",children:L===void 0?`和统一设置一样:${(Q=lp.find(te=>te.style===(z.peerStyle??"plain")))==null?void 0:Q.title}。`:(G=lp.find(te=>te.style===L))==null?void 0:G.text})]}),n.jsxs("div",{className:"persona-foot muted small",children:[n.jsx("span",{children:_?"没有单独设置的 agent 都按这里的来。":"没改的地方跟随「所有 agent」的设置。"}),F&&n.jsx("button",{className:"link-button small",onClick:q,children:_?"恢复默认":"全部改回跟随统一"})]})]}),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:j?"跟着左边的选择变,保存后生效":"现在生效的设置"})]}),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:((ne=D.name)==null?void 0:ne.trim())||(_?"agent":H)}),n.jsx("p",{children:I})]}),n.jsxs("span",{className:"muted small",children:["只是「",Uj(D.style),"」的示例;实际怎么说,模型照下面这段来。"]})]}),n.jsxs("div",{className:"field",children:[n.jsx("span",{className:"field-title",children:_?"加到 agent 提示词里的内容":`加到「${H}」提示词里的内容`}),U===""?n.jsx("p",{className:"persona-prompt empty-prompt",children:"什么都不加。"}):n.jsx("div",{className:"persona-prompt",children:U.split(`
242
+ `).map((te,re)=>n.jsx("div",{className:A.has(te)?"":"changed",children:te},re))})]})]})})]})]})]})}function Zj({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(ee,{name:"check"})]}),n.jsx("span",{className:"muted small",children:t})]})}const iZ={id:"settings-credentials",title:"模型",requires:["credentials","models"],settingsPages:[{id:"api-keys",title:"模型",order:0,component:z7}]},rZ={id:"permissions",title:"权限",requires:["permissions"],settingsPages:[{id:"permissions",title:"权限",order:1,component:tZ}]},aZ={id:"persona",title:"回复风格",requires:["persona"],settingsPages:[{id:"persona",title:"回复风格",order:2,component:sZ}]},oZ={id:"compaction",title:"对话压缩",requires:["compaction"],settingsPages:[{id:"compaction",title:"对话压缩",order:3,component:H7}]},lZ={id:"memory",title:"记忆",requires:["memory"],settingsPages:[{id:"memory",title:"记忆",order:2.5,component:G7}]},cZ={id:"about",title:"关于",requires:[],settingsPages:[{id:"about",title:"关于",order:100,component:j7}]};function uZ({client:e}){const t=ke(e.capabilities),s=ke(e.connection.server),[i,r]=v.useState(0);v.useEffect(()=>iw(()=>r(d=>d+1)),[]);const o=v.useMemo(()=>J2(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 dZ={id:"plugin-status",title:"插件状态",requires:[],settingsPages:[{id:"plugins",title:"插件状态",order:90,component:uZ}]};function hZ(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 f=t[d*2];h=r[d]={index:d,key:s(d),start:f,size:t[d*2+1],end:f+t[d*2+1],lane:0}}return h}}if(o==="length")return e}return Reflect.get(r,o,l)}})}function _o(e,t,s){let i=s.initialDeps??[],r,o=!0;function l(){const u=e();return(u.length!==i.length||u.some((h,f)=>i[f]!==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 Wj(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const mZ=(e,t)=>Math.abs(e-t)<1.01,fZ=(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 up=()=>{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},Vj=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},pZ=e=>e,gZ=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},xZ=(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(Vj(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(Vj(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(s,{box:"border-box"}),()=>{o.unobserve(s)}},Kd={passive:!0},vZ=typeof window>"u"?!0:"onscrollend"in window,yZ=(e,t,s)=>{const i=e.scrollElement;if(!i)return;const r=e.targetWindow;if(!r)return;const o=e.options.useScrollendEvent&&vZ;let l=0;const u=o?null:fZ(r,()=>t(l,!1),e.options.isScrollingResetDelay),d=p=>()=>{l=s(i),u==null||u(),t(l,p)},h=d(!0),f=d(!1);return i.addEventListener("scroll",h,Kd),o&&i.addEventListener("scrollend",f,Kd),()=>{i.removeEventListener("scroll",h),o&&i.removeEventListener("scrollend",f),u==null||u.cancel()}},bZ=(e,t)=>yZ(e,t,s=>{const{horizontal:i,isRtl:r}=e.options;return i?s.scrollLeft*(r&&-1||1):s.scrollTop}),kZ=(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"]},jZ=(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})},NZ=jZ;class wZ{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,f]of this.elementsCache)if(f===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:pZ,rangeExtractor:gZ,onChange:()=>{},measureElement:kZ,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,b=this.getMeasurements(),k=g>0?((i=b[0])==null?void 0:i.key)??l.getItemKey(0):null,j=g>0?((r=b[g-1])==null?void 0:r.key)??l.getItemKey(g-1):null;if(x!==g||g>0&&x>0&&(o.getItemKey(0)!==k||o.getItemKey(x-1)!==j)){h=!0;const S=g>0?this.getVirtualItemForOffset(this.getScrollOffset())??b[0]:null;S&&(u=[S.key,this.getScrollOffset()-S.start]);const _=o.followOnAppend===!0?"auto":o.followOnAppend||null;_&&x>g&&this.isAtEnd(l.scrollEndThreshold)&&(g===0||o.getItemKey(x-1)!==j)&&(d=_)}}this.options=o,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,p=0;if(u&&this.scrollOffset!==null){const[g,x]=u,b=this.getMeasurements(),{count:k,getItemKey:j}=this.options;let N=0;for(;N<k&&j(N)!==g;)N++;if(N<k){const C=b[N];if(C){const S=Math.max(0,C.start+x);S!==this.scrollOffset&&(p=S-this.scrollOffset,this.scrollOffset=S,f=!0)}}}(f||d)&&(this.pendingScrollAnchor=[f?u[0]:null,f?u[1]:0,d,p])},this.notify=s=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,s)},this.maybeNotify=_o(()=>(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,!(!up()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",l,Kd),o.addEventListener("touchend",u,Kd),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&&(up()&&(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=_o(()=>[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=_o(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:l,lanes:u,laneAssignmentMode:d,gap:h},f)=>{const p=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const N of this.laneAssignments.keys())N>=s&&this.laneAssignments.delete(N);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(N=>{this.itemSizeCache.set(N.key,N.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 N=s*2;let C=this._flatMeasurements;if(!C||C.length<N){const z=new Float64Array(N);C&&g>0&&z.set(C.subarray(0,g*2)),C=z,this._flatMeasurements=C}let S;if(g===0)S=i+r;else{const z=g-1;S=C[z*2]+C[z*2+1]+h}for(let z=g;z<s;z++){const P=o(z),H=p.get(P),B=typeof H=="number"?H:this.options.estimateSize(z);C[z*2]=S,C[z*2+1]=B,S+=B+h}const _=hZ(s,C,o);return this.measurementsCache=_,_}const x=this.measurementsCache.slice(0,g),b=new Array(u).fill(void 0),k=new Float64Array(u);let j=0;for(let N=0;N<g;N++){const C=x[N];C&&(b[C.lane]===void 0&&j++,b[C.lane]=N,k[C.lane]=C.end)}for(let N=g;N<s;N++){const C=o(N),S=this.laneAssignments.get(N);let _,z;const P=d==="estimate"||p.has(C);if(S!==void 0&&this.options.lanes>1){_=S;const T=b[_],D=T!==void 0?x[T]:void 0;z=D?D.end+h:i+r}else if(j===u){let T=0,D=k[0],U=b[0];for(let A=1;A<u;A++){const I=k[A];(I<D||I===D&&b[A]<U)&&(T=A,D=I,U=b[A])}_=T,z=D+h,P&&this.laneAssignments.set(N,_)}else _=N%this.options.lanes,z=i+r,P&&this.laneAssignments.set(N,_);const H=p.get(C),B=typeof H=="number"?H:this.options.estimateSize(N),O=z+B;x[N]={index:N,start:z,size:B,end:O,key:C,lane:_},b[_]===void 0&&j++,b[_]=N,k[_]=O}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=_o(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,i,r,o)=>s.length===0||i===0?(this.range=null,null):(this.range=_Z(s,i,r,o,o===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=_o(()=>{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 f=this.itemSizeCache.get(d)??l,p=i-f;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,b=this.getScrollOffset()+this.scrollAdjustments,j=!this.itemSizeCache.has(d)?u<b:u+f<=b&&this.scrollDirection!=="backward",N=((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):j);(this.pendingMin===null||s<this.pendingMin)&&(this.pendingMin=s),this.itemSizeCache.set(d,i),this.itemSizeCacheVersion++;let C=!1;g?C=this.applyScrollAdjustment(this.getTotalSize()-x):N&&(C=this.applyScrollAdjustment(p)),this.notify(C)}},this.getVirtualItems=_o(()=>[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=rE(0,i.length-1,o?u=>r[u*2]:u=>Wj(i[u]).start,s);return Wj(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:up()&&(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&&mZ(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 rE=(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 SZ(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 _Z(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=SZ(r,o,s);let f=h;const p=s+t;for(;f<o&&r[f*2]+r[f*2+1]<p;)f++;return{startIndex:h,endIndex:f}}let u=rE(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 f=Array(i).fill(s+t);for(;u>=0&&f.some(p=>p>=s);){const p=e[u];f[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 dp=typeof document<"u"?v.useLayoutEffect:v.useEffect;function EZ({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:s="transform",...i}){const r=v.useReducer(f=>f+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=f=>{const p=o.current;if(!p.enabled||!p.container)return;const g=f.getTotalSize();if(g!==p.lastSize){p.lastSize=g;const x=f.options.horizontal?"width":"height";p.container.style[x]=`${g}px`}},u=f=>{const p=o.current;if(!p.enabled||!p.container)return;l(f);const g=!!f.options.horizontal,x=p.mode==="transform",b=g?"left":"top",k=f.options.scrollMargin,j=f.getVirtualItems();for(const N of j){const C=N.start-k,S=f.elementsCache.get(N.key);S&&p.lastPositions.get(S)!==C&&(p.lastPositions.set(S,C),x?S.style.transform=g?`translate3d(${C}px, 0, 0)`:`translate3d(0, ${C}px, 0)`:S.style[b]=`${C}px`)}},d={...i,onChange:(f,p)=>{var g;const x=o.current;let b=!0;if(x.enabled){u(f);const k=f.range,j=x.prevRange;b=!j||j.isScrolling!==f.isScrolling||j.startIndex!==(k==null?void 0:k.startIndex)||j.endIndex!==(k==null?void 0:k.endIndex),b&&(x.prevRange=k?{startIndex:k.startIndex,endIndex:k.endIndex,isScrolling:f.isScrolling}:null)}b&&(e&&p?qa.flushSync(r):r()),(g=i.onChange)==null||g.call(i,f,p)}},[h]=v.useState(()=>{const f=new wZ(d);return Object.assign(f,{containerRef:p=>{const g=o.current;if(g.container=p,g.lastSize=null,p&&g.enabled){const x=f.getTotalSize();g.lastSize=x;const b=f.options.horizontal?"width":"height";p.style[b]=`${x}px`}}})});return h.setOptions(d),dp(()=>h._didMount(),[]),dp(()=>(l(h),h._willUpdate())),dp(()=>{u(h)}),h}function CZ(e){return EZ({observeElementRect:xZ,observeElementOffset:bZ,scrollToFn:NZ,...e})}const jh={user:"用户",context:"上下文",system:"系统",assistant:"助手",attempt:"失败尝试",tool:"工具",compaction:"压缩"},aE={ok:"已完成",error:"失败",running:"运行中",interrupted:"已中断"},AZ={completed:"已完成",aborted:"已停止",error:"失败",blocked:"已阻止","max-tokens":"达到输出上限",interrupted:"已中断",forked:"已分叉"};function $Z(e){return e.turn===null?"轮次之间":`第 ${e.turn} 轮`}function IZ(e){return e.end===null?"进行中":e.reason===void 0?"":AZ[e.reason.kind]??e.reason.kind}function oE(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 gc(e){return e.end===null||e.end<e.start?void 0:e.end-e.start}function Yd(e){return e.kind==="assistant"?e.content.filter(t=>t.type==="tool-call").length:0}function TZ({record:e,totals:t,onClose:s}){const i=RZ(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:jh[e.kind]}),n.jsx("span",{className:"inspector-title",title:e.title,children:MZ(e)}),n.jsx("button",{className:"ghost icon",onClick:s,"aria-label":"关闭详情",children:n.jsx(ee,{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 MZ(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 jh[e.kind]}}function RZ(e,t){switch(e.kind){case"assistant":return[{id:"summary",label:"概述",render:()=>n.jsx(OZ,{record:e})},{id:"raw",label:"原始输出",render:()=>n.jsx(hp,{content:e.content})},{id:"usage",label:"用量",render:()=>n.jsx(PZ,{record:e,totals:t})},{id:"timing",label:"计时",render:()=>n.jsx(LZ,{record:e})}];case"tool":return[{id:"summary",label:"概述",render:()=>n.jsx(ea,{rows:[["状态",n.jsx(Sd,{record:e})],["工具",n.jsx("code",{children:e.name})],["调用 ID",n.jsx("code",{children:e.callId})],["开始时间",Xr(e.start)],["时长",e.end===null?"运行中":Zs(gc(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===""?"未捕获参数":ax(e.arguments)})},{id:"result",label:"结果",render:()=>e.result===void 0?n.jsx("p",{className:"muted",children:"未捕获结果"}):n.jsx(hp,{content:e.result})}];case"user":case"context":return[{id:"summary",label:"概述",render:()=>n.jsxs(n.Fragment,{children:[n.jsx(ea,{rows:[["来源",e.origin.human?"用户":e.origin.kind],["时间",Xr(e.start)],["附件",e.imageCount+e.fileCount===0?void 0:`图片 ×${e.imageCount} · 文件 ×${e.fileCount}`]]}),n.jsx("div",{className:"label",children:"预览"}),n.jsx(hp,{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(ea,{rows:[["状态",n.jsx(Sd,{record:e})],["开始时间",Xr(e.start)],["时长",Zs(gc(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(ea,{rows:[["状态",n.jsx(Sd,{record:e})],["开始时间",Xr(e.start)],["时长",e.end===null?"运行中":Zs(gc(e))],["已压缩",e.shadowedTokenCount===void 0?void 0:`${wn(e.shadowedTokenCount)} tok`],["输入 / 输出",e.usage===void 0?void 0:`${wn(e.usage.inputTokens)} / ${wn(e.usage.outputTokens)} tok`],["错误",e.error]]})}]}}function Sd({record:e}){return n.jsx("span",{className:`status-text status-${e.status}`,children:aE[e.status]})}function ea({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 OZ({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(ea,{rows:[["状态",n.jsx(Sd,{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 hp({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:ax(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?"":`${wn(t.size)}B`]},s);default:return n.jsxs("div",{className:"raw-block muted small",children:["[",t.kind,"]"]},s)}})})}function PZ({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(ea,{rows:[["输入(未缓存)",`${wn(s.inputTokens)} tok`],["缓存读取",s.cacheReadTokens===void 0?void 0:`${wn(s.cacheReadTokens)} tok`],["缓存写入",s.cacheWriteTokens===void 0?void 0:`${wn(s.cacheWriteTokens)} tok`],["输入合计",`${wn(oE(e))} tok`],["输出",`${wn(s.outputTokens)} tok`],["其中推理",s.reasoningTokens===void 0?void 0:`${wn(s.reasoningTokens)} tok`],["总计",s.totalTokens===void 0?void 0:`${wn(s.totalTokens)} tok`]]}),n.jsx("h4",{className:"usage-heading",children:"已加载窗口累计"}),n.jsx(ea,{rows:[["请求数",String(t.requests)],["输入(未缓存)",`${wn(t.inputTokens)} tok`],["缓存读取",`${wn(t.cacheReadTokens)} tok`],["输出",`${wn(t.outputTokens)} tok`],["其中推理",`${wn(t.reasoningTokens)} tok`]]})]})}function LZ({record:e}){const[t,s]=v.useState(!1),i=e.request;return n.jsx(ea,{rows:[["开始时间",n.jsx("button",{className:"link-button",onClick:()=>s(r=>!r),title:t?"显示本地时间":"显示 Unix 时间戳",children:t?String(e.start):Xr(e.start)})],["总时长",e.end===null?"运行中":Zs(gc(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`],["工具调用",Yd(e)===0?void 0:String(Yd(e))],["计时来源",e.live?"会话时间戳(运行中)":"会话时间戳"]]})}const md=14,zZ=v.memo(function({model:t,mode:s,brush:i,selectedId:r,onBrush:o,onSelect:l}){const u=v.useMemo(()=>Iz(t),[t]),d=v.useMemo(()=>iS.map((T,D)=>({...T,index:D})).filter(T=>T.id!=="compaction"||u.some(D=>D.lane===T.index)),[u]),h=new Map(d.map((T,D)=>[T.index,D])),f=t.span,[p,g]=v.useState(null),x=s==="actual"&&f!==null?DZ(p,f):null,b=v.useRef(null),[k,j]=v.useState(null),N=v.useRef(null),C=t.records.length,S=(T,D)=>s==="equal"?C===0?0:T/C:x===null||x.end===x.start?0:(D-x.start)/(x.end-x.start),_=T=>{var U;const D=(U=b.current)==null?void 0:U.getBoundingClientRect();return D===void 0||D.width===0?0:Math.min(1,Math.max(0,(T-D.left)/D.width))},z=T=>{if(T.button===2&&x!==null&&f!==null&&(x.start>f.start||x.end<f.end)){N.current={x:T.clientX,view:x};return}if(T.button!==0)return;const D=_(T.clientX);j({x0:D,x1:D})},P=T=>{if(N.current!==null&&f!==null&&b.current!==null){const D=(T.clientX-N.current.x)/b.current.clientWidth,U=N.current.view.end-N.current.view.start;g(Rz(N.current.view,-D*U,f));return}k!==null&&j({...k,x1:_(T.clientX)})},H=()=>{if(N.current=null,k===null)return;const[T,D]=k.x0<k.x1?[k.x0,k.x1]:[k.x1,k.x0];if(j(null),!(D-T<.005)){if(s==="equal")o({mode:"equal",from:Math.floor(T*C),to:Math.max(Math.floor(T*C),Math.ceil(D*C)-1)});else if(x!==null){const U=x.end-x.start;o({mode:"actual",range:{start:x.start+T*U,end:x.start+D*U}})}}},B=T=>{if(s!=="actual"||x===null||f===null)return;const D=x.end-x.start;g(Mz(x,x.start+_(T.clientX)*D,T.deltaY>0?1.25:.8,f))};if(C===0||f===null)return n.jsx("div",{className:"overview empty-overview muted small",children:"无计时数据"});const O=i===null?null:i.mode==="equal"?s==="equal"?{left:i.from/C,right:(i.to+1)/C}:null:s==="actual"?{left:S(0,i.range.start),right:S(0,i.range.end)}:null;return n.jsxs("div",{className:"overview",onContextMenu:T=>{T.preventDefault(),N.current===null&&o(null)},children:[n.jsx("div",{className:"overview-lanes",children:d.map(T=>n.jsx("div",{className:"lane-label",style:{height:md},children:FZ(T.id)},T.id))}),n.jsxs("div",{className:"overview-track",ref:b,style:{height:d.length*(md+2)},onMouseDown:z,onMouseMove:P,onMouseUp:H,onMouseLeave:H,onWheel:B,children:[u.map((T,D)=>{const U=h.get(T.lane)??0,A=S(D,T.start),I=s==="equal"?(D+1)/C:S(D,T.end);if(I<0||A>1)return null;const R=T.record,L=Math.max(0,Math.min(1,I)-Math.max(0,A)),K=s==="actual"&&T.firstTokenAt!==void 0&&T.end>T.start?(T.firstTokenAt-T.start)/(T.end-T.start):null;return n.jsx("div",{className:`bar kind-${R.kind} status-${R.status} ${T.instant&&s==="actual"?"instant":""} ${R.id===r?"selected":""}`,style:{left:`${Math.max(0,A)*100}%`,width:s==="equal"?`calc(${L*100}% - 1px)`:`max(2px, ${L*100}%)`,top:U*(md+2),height:md,...K===null?{}:{"--ttft":`${Math.min(100,Math.max(0,K*100))}%`}},title:UZ(R,T.firstTokenAt),onMouseUp:F=>{k!==null&&Math.abs(k.x1-k.x0)<.005&&F.button===0&&l(R)}},R.id)}),O!==null&&n.jsx("div",{className:"brush",style:{left:`${Math.max(0,O.left)*100}%`,width:`${(Math.min(1,O.right)-Math.max(0,O.left))*100}%`}}),k!==null&&n.jsx("div",{className:"brush dragging",style:{left:`${Math.min(k.x0,k.x1)*100}%`,width:`${Math.abs(k.x1-k.x0)*100}%`}})]}),n.jsx("div",{className:"overview-scale muted",children:s==="actual"&&x!==null?n.jsxs(n.Fragment,{children:[n.jsx("span",{children:Xr(x.start)}),n.jsxs("span",{children:["总计 ",Zs(f.end-f.start),p!==null?" · 已缩放":""]}),n.jsx("span",{children:Xr(x.end)})]}):n.jsxs(n.Fragment,{children:[n.jsxs("span",{children:[C," 条记录(等宽)"]}),n.jsxs("span",{children:["总计 ",Zs(f.end-f.start)]}),n.jsx("span",{children:"拖动选择区间 · 右键清除"})]})})]})});function DZ(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 FZ(e){return e==="input"?"输入":e==="model"?"模型":e==="tool"?"工具":"压缩"}function UZ(e,t){const s=[`${jh[e.kind]} · ${e.title}`,`开始于 ${Xr(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(`
243
+ `)}const BZ=32,HZ=34,ZZ=60;function WZ({session:e,state:t}){const s=v.useMemo(()=>wz(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,f]=v.useState(new Set),[p,g]=v.useState(!0),[x,b]=v.useState(null),k=s.records.find(T=>T.id===x)??null,j=v.useMemo(()=>VZ(s,{brush:o,query:u,collapsed:h,showCalls:p}),[s,o,u,h,p]),N=v.useMemo(()=>j.flatMap(T=>T.type==="record"?[T.record]:[]),[j]),C=v.useRef(null),S=sS(ZZ),_=S.following,z=CZ({count:j.length,getScrollElement:()=>C.current,estimateSize:T=>{var D;return((D=j[T])==null?void 0:D.type)==="group"?HZ:BZ},getItemKey:T=>{var D;return((D=j[T])==null?void 0:D.key)??T},overscan:12});v.useLayoutEffect(()=>{_.current&&j.length>0&&z.scrollToIndex(j.length-1,{align:"end"})},[j.length,t.version,z]),v.useEffect(()=>{if(x===null)return;const T=j.findIndex(D=>D.type==="record"&&D.record.id===x);T!==-1&&z.scrollToIndex(T,{align:"auto"})},[x]);const P=T=>f(D=>{const U=new Set(D);return U.has(T)?U.delete(T):U.add(T),U}),H=s.groups.length>0&&s.groups.every(T=>h.has(T.key)),B=T=>{if(T.key!=="ArrowDown"&&T.key!=="ArrowUp"&&T.key!=="Escape")return;if(T.preventDefault(),T.key==="Escape"){b(null);return}const D=N.findIndex(A=>A.id===x),U=N[T.key==="ArrowDown"?Math.min(N.length-1,D+1):Math.max(0,D-1)];U!==void 0&&b(U.id)},O=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(T=>T==="equal"?"actual":"equal"),l(null)},title:i==="equal"?"使用实际时长":"使用等宽操作",children:["⏱ ",i==="equal"?"等宽":"实际时间"]}),n.jsxs("button",{className:"toggle",onClick:()=>f(H?new Set:new Set(s.groups.map(T=>T.key))),children:["⊟ ",H?"展开所有轮次":"收起所有轮次"]}),n.jsxs("button",{className:`toggle ${p?"":"on"}`,onClick:()=>g(T=>!T),children:["⊟ ",p?"收起所有调用":"展开所有调用"]}),n.jsx("input",{className:"traj-search",value:u,onChange:T=>d(T.target.value),placeholder:"搜索轨迹","aria-label":"搜索轨迹"}),n.jsxs("span",{className:"traj-totals muted small",title:"已加载窗口内的累计",children:[O.requests," 次请求 · 输入 ",wn(O.inputTokens+O.cacheReadTokens+O.cacheWriteTokens)," · 输出 ",wn(O.outputTokens)," · ",O.toolCalls," 次工具调用",O.errors>0?` · ${O.errors} 个错误`:""]})]}),n.jsx(zZ,{model:s,mode:i,brush:o,selectedId:x,onBrush:l,onSelect:T=>b(T.id)}),o!==null&&n.jsxs("div",{className:"brush-note small",children:["已按时间区间筛选,显示 ",N.length," 条记录 ",n.jsx("button",{className:"link-button",onClick:()=>l(null),children:"清除"})]}),n.jsxs("div",{className:"traj-main",children:[n.jsxs("div",{className:"ledger",ref:C,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?"正在加载更早的历史…":"加载更早的历史"}),j.length===0&&n.jsx("div",{className:"empty",children:t.status==="opening"?"正在加载轨迹…":u!==""?"没有匹配的记录":"还没有记录"}),n.jsx("div",{style:{height:z.getTotalSize(),position:"relative"},children:z.getVirtualItems().map(T=>{const D=j[T.index];return n.jsx("div",{className:"vrow",style:{transform:`translateY(${T.start}px)`,height:T.size},children:D.type==="group"?n.jsx(qZ,{row:D,onToggle:()=>P(D.group.key)}):n.jsx(GZ,{row:D,selected:D.record.id===x,onSelect:()=>b(U=>U===D.record.id?null:D.record.id)})},T.key)})})]}),k!==null&&n.jsx(TZ,{record:k,totals:s.totals,onClose:()=>b(null)},k.id)]})]})}function VZ(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=>Tz(u,l.range))}for(const l of Oz(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(f=>s.has(f.id)&&(t.showCalls||f.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 f of u){const p=f.step!==null&&f.step!==h?f.step:null;f.step!==null&&(h=f.step),o.push({type:"record",key:f.id,record:f,stepStart:p})}}return o}const qZ=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=IZ(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:$Z(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})]})}),GZ=v.memo(function({row:t,selected:s,onSelect:i}){var u;const r=t.record,o=r.kind==="assistant",l=gc(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}`:jh[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:[aE.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?wn(oE(r)):""}),n.jsx("span",{className:"num",children:o&&r.request.usage!==void 0?wn(r.request.usage.outputTokens):""}),n.jsx("span",{className:"num",children:o&&((u=r.request.usage)==null?void 0:u.reasoningTokens)!==void 0?wn(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&&Yd(r)>0?Yd(r):""})]})}),KZ={id:"trajectory",title:"轨迹",requires:["sessions"],sessionViews:[{id:"trajectory",title:"轨迹",order:10,component:WZ}]};HS();li()===void 0&&document.documentElement.classList.add("own-title-bar");ch&&document.documentElement.classList.add("in-dsh");Bn(x5);Bn(KZ);Bn(iZ);Bn(rZ);Bn(aZ);Bn(lZ);Bn(oZ);Bn(cZ);Bn(dZ);Bn(b7);Bn(k7);Bn(P5);Bn(L5);Bn(g8);Bn(x8);Bn(S8);Bn(F8);for(const e of v5)Bn(e);const lE=WC.createRoot(document.getElementById("root"));function mp(e){const t=new H2({url:n5(e),clientInfo:{name:"adg-web",version:"0.1.0"}});t.start(),lE.render(n.jsxs(m5,{children:[n.jsx(i5,{client:t}),n.jsx(h5,{client:t}),n.jsx(rz,{}),n.jsx(g5,{})]}))}const qj=ch?null:e5();ch?mp(null):qj===null?lE.render(n.jsx(l5,{onSubmit:e=>{t5(e),mp(e)}})):mp(qj);
244
+ //# sourceMappingURL=index-ClYIoZUR.js.map