dsh-multigameassistant 2.2.3 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,256 @@
1
+ var JC=Object.defineProperty;var iy=e=>{throw TypeError(e)};var eA=(e,t,s)=>t in e?JC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var mt=(e,t,s)=>eA(e,typeof t!="symbol"?t+"":t,s),Jm=(e,t,s)=>t.has(e)||iy("Cannot "+s);var ze=(e,t,s)=>(Jm(e,t,"read from private field"),s?s.call(e):t.get(e)),Ht=(e,t,s)=>t.has(e)?iy("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),Kt=(e,t,s,i)=>(Jm(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),bt=(e,t,s)=>(Jm(e,t,"access private method"),s);var ry=(e,t,s,i)=>({set _(r){Kt(e,t,r,s)},get _(){return ze(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 Tg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ef={exports:{}},Tl={},tf={exports:{}},kt={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var ay;function tA(){if(ay)return kt;ay=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=Symbol.iterator;function g(G){return G===null||typeof G!="object"?null:(G=p&&G[p]||G["@@iterator"],typeof G=="function"?G:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,b={};function j(G,K,Z){this.props=G,this.context=K,this.refs=b,this.updater=Z||x}j.prototype.isReactComponent={},j.prototype.setState=function(G,K){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,K,"setState")},j.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function w(){}w.prototype=j.prototype;function S(G,K,Z){this.props=G,this.context=K,this.refs=b,this.updater=Z||x}var _=S.prototype=new w;_.constructor=S,k(_,j.prototype),_.isPureReactComponent=!0;var E=Array.isArray,M=Object.prototype.hasOwnProperty,O={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function U(G,K,Z){var Y,Q={},ie=null,re=null;if(K!=null)for(Y in K.ref!==void 0&&(re=K.ref),K.key!==void 0&&(ie=""+K.key),K)M.call(K,Y)&&!B.hasOwnProperty(Y)&&(Q[Y]=K[Y]);var ne=arguments.length-2;if(ne===1)Q.children=Z;else if(1<ne){for(var fe=Array(ne),Ee=0;Ee<ne;Ee++)fe[Ee]=arguments[Ee+2];Q.children=fe}if(G&&G.defaultProps)for(Y in ne=G.defaultProps,ne)Q[Y]===void 0&&(Q[Y]=ne[Y]);return{$$typeof:e,type:G,key:ie,ref:re,props:Q,_owner:O.current}}function P(G,K){return{$$typeof:e,type:G.type,key:K,ref:G.ref,props:G.props,_owner:G._owner}}function R(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function z(G){var K={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(Z){return K[Z]})}var L=/\/+/g;function A(G,K){return typeof G=="object"&&G!==null&&G.key!=null?z(""+G.key):K.toString(36)}function T(G,K,Z,Y,Q){var ie=typeof G;(ie==="undefined"||ie==="boolean")&&(G=null);var re=!1;if(G===null)re=!0;else switch(ie){case"string":case"number":re=!0;break;case"object":switch(G.$$typeof){case e:case t:re=!0}}if(re)return re=G,Q=Q(re),G=Y===""?"."+A(re,0):Y,E(Q)?(Z="",G!=null&&(Z=G.replace(L,"$&/")+"/"),T(Q,K,Z,"",function(Ee){return Ee})):Q!=null&&(R(Q)&&(Q=P(Q,Z+(!Q.key||re&&re.key===Q.key?"":(""+Q.key).replace(L,"$&/")+"/")+G)),K.push(Q)),1;if(re=0,Y=Y===""?".":Y+":",E(G))for(var ne=0;ne<G.length;ne++){ie=G[ne];var fe=Y+A(ie,ne);re+=T(ie,K,Z,fe,Q)}else if(fe=g(G),typeof fe=="function")for(G=fe.call(G),ne=0;!(ie=G.next()).done;)ie=ie.value,fe=Y+A(ie,ne++),re+=T(ie,K,Z,fe,Q);else if(ie==="object")throw K=String(G),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.");return re}function H(G,K,Z){if(G==null)return G;var Y=[],Q=0;return T(G,Y,"","",function(ie){return K.call(Z,ie,Q++)}),Y}function F(G){if(G._status===-1){var K=G._result;K=K(),K.then(function(Z){(G._status===0||G._status===-1)&&(G._status=1,G._result=Z)},function(Z){(G._status===0||G._status===-1)&&(G._status=2,G._result=Z)}),G._status===-1&&(G._status=0,G._result=K)}if(G._status===1)return G._result.default;throw G._result}var V={current:null},D={transition:null},q={ReactCurrentDispatcher:V,ReactCurrentBatchConfig:D,ReactCurrentOwner:O};function te(){throw Error("act(...) is not supported in production builds of React.")}return kt.Children={map:H,forEach:function(G,K,Z){H(G,function(){K.apply(this,arguments)},Z)},count:function(G){var K=0;return H(G,function(){K++}),K},toArray:function(G){return H(G,function(K){return K})||[]},only:function(G){if(!R(G))throw Error("React.Children.only expected to receive a single React element child.");return G}},kt.Component=j,kt.Fragment=s,kt.Profiler=r,kt.PureComponent=S,kt.StrictMode=i,kt.Suspense=d,kt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,kt.act=te,kt.cloneElement=function(G,K,Z){if(G==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+G+".");var Y=k({},G.props),Q=G.key,ie=G.ref,re=G._owner;if(K!=null){if(K.ref!==void 0&&(ie=K.ref,re=O.current),K.key!==void 0&&(Q=""+K.key),G.type&&G.type.defaultProps)var ne=G.type.defaultProps;for(fe in K)M.call(K,fe)&&!B.hasOwnProperty(fe)&&(Y[fe]=K[fe]===void 0&&ne!==void 0?ne[fe]:K[fe])}var fe=arguments.length-2;if(fe===1)Y.children=Z;else if(1<fe){ne=Array(fe);for(var Ee=0;Ee<fe;Ee++)ne[Ee]=arguments[Ee+2];Y.children=ne}return{$$typeof:e,type:G.type,key:Q,ref:ie,props:Y,_owner:re}},kt.createContext=function(G){return G={$$typeof:l,_currentValue:G,_currentValue2:G,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},G.Provider={$$typeof:o,_context:G},G.Consumer=G},kt.createElement=U,kt.createFactory=function(G){var K=U.bind(null,G);return K.type=G,K},kt.createRef=function(){return{current:null}},kt.forwardRef=function(G){return{$$typeof:u,render:G}},kt.isValidElement=R,kt.lazy=function(G){return{$$typeof:m,_payload:{_status:-1,_result:G},_init:F}},kt.memo=function(G,K){return{$$typeof:h,type:G,compare:K===void 0?null:K}},kt.startTransition=function(G){var K=D.transition;D.transition={};try{G()}finally{D.transition=K}},kt.unstable_act=te,kt.useCallback=function(G,K){return V.current.useCallback(G,K)},kt.useContext=function(G){return V.current.useContext(G)},kt.useDebugValue=function(){},kt.useDeferredValue=function(G){return V.current.useDeferredValue(G)},kt.useEffect=function(G,K){return V.current.useEffect(G,K)},kt.useId=function(){return V.current.useId()},kt.useImperativeHandle=function(G,K,Z){return V.current.useImperativeHandle(G,K,Z)},kt.useInsertionEffect=function(G,K){return V.current.useInsertionEffect(G,K)},kt.useLayoutEffect=function(G,K){return V.current.useLayoutEffect(G,K)},kt.useMemo=function(G,K){return V.current.useMemo(G,K)},kt.useReducer=function(G,K,Z){return V.current.useReducer(G,K,Z)},kt.useRef=function(G){return V.current.useRef(G)},kt.useState=function(G){return V.current.useState(G)},kt.useSyncExternalStore=function(G,K,Z){return V.current.useSyncExternalStore(G,K,Z)},kt.useTransition=function(){return V.current.useTransition()},kt.version="18.3.1",kt}var oy;function zc(){return oy||(oy=1,tf.exports=tA()),tf.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 ly;function nA(){if(ly)return Tl;ly=1;var e=zc(),t=Symbol.for("react.element"),s=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function l(u,d,h){var m,p={},g=null,x=null;h!==void 0&&(g=""+h),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(x=d.ref);for(m in d)i.call(d,m)&&!o.hasOwnProperty(m)&&(p[m]=d[m]);if(u&&u.defaultProps)for(m in d=u.defaultProps,d)p[m]===void 0&&(p[m]=d[m]);return{$$typeof:t,type:u,key:g,ref:x,props:p,_owner:r.current}}return Tl.Fragment=s,Tl.jsx=l,Tl.jsxs=l,Tl}var cy;function sA(){return cy||(cy=1,ef.exports=nA()),ef.exports}var n=sA(),qu={},nf={exports:{}},Cs={},sf={exports:{}},rf={};/**
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 uy;function iA(){return uy||(uy=1,(function(e){function t(D,q){var te=D.length;D.push(q);e:for(;0<te;){var G=te-1>>>1,K=D[G];if(0<r(K,q))D[G]=q,D[te]=K,te=G;else break e}}function s(D){return D.length===0?null:D[0]}function i(D){if(D.length===0)return null;var q=D[0],te=D.pop();if(te!==q){D[0]=te;e:for(var G=0,K=D.length,Z=K>>>1;G<Z;){var Y=2*(G+1)-1,Q=D[Y],ie=Y+1,re=D[ie];if(0>r(Q,te))ie<K&&0>r(re,Q)?(D[G]=re,D[ie]=te,G=ie):(D[G]=Q,D[Y]=te,G=Y);else if(ie<K&&0>r(re,te))D[G]=re,D[ie]=te,G=ie;else break e}}return q}function r(D,q){var te=D.sortIndex-q.sortIndex;return te!==0?te:D.id-q.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,u=l.now();e.unstable_now=function(){return l.now()-u}}var d=[],h=[],m=1,p=null,g=3,x=!1,k=!1,b=!1,j=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(D){for(var q=s(h);q!==null;){if(q.callback===null)i(h);else if(q.startTime<=D)i(h),q.sortIndex=q.expirationTime,t(d,q);else break;q=s(h)}}function E(D){if(b=!1,_(D),!k)if(s(d)!==null)k=!0,F(M);else{var q=s(h);q!==null&&V(E,q.startTime-D)}}function M(D,q){k=!1,b&&(b=!1,w(U),U=-1),x=!0;var te=g;try{for(_(q),p=s(d);p!==null&&(!(p.expirationTime>q)||D&&!z());){var G=p.callback;if(typeof G=="function"){p.callback=null,g=p.priorityLevel;var K=G(p.expirationTime<=q);q=e.unstable_now(),typeof K=="function"?p.callback=K:p===s(d)&&i(d),_(q)}else i(d);p=s(d)}if(p!==null)var Z=!0;else{var Y=s(h);Y!==null&&V(E,Y.startTime-q),Z=!1}return Z}finally{p=null,g=te,x=!1}}var O=!1,B=null,U=-1,P=5,R=-1;function z(){return!(e.unstable_now()-R<P)}function L(){if(B!==null){var D=e.unstable_now();R=D;var q=!0;try{q=B(!0,D)}finally{q?A():(O=!1,B=null)}}else O=!1}var A;if(typeof S=="function")A=function(){S(L)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,H=T.port2;T.port1.onmessage=L,A=function(){H.postMessage(null)}}else A=function(){j(L,0)};function F(D){B=D,O||(O=!0,A())}function V(D,q){U=j(function(){D(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(D){D.callback=null},e.unstable_continueExecution=function(){k||x||(k=!0,F(M))},e.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<D?Math.floor(1e3/D):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return s(d)},e.unstable_next=function(D){switch(g){case 1:case 2:case 3:var q=3;break;default:q=g}var te=g;g=q;try{return D()}finally{g=te}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(D,q){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var te=g;g=D;try{return q()}finally{g=te}},e.unstable_scheduleCallback=function(D,q,te){var G=e.unstable_now();switch(typeof te=="object"&&te!==null?(te=te.delay,te=typeof te=="number"&&0<te?G+te:G):te=G,D){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=te+K,D={id:m++,callback:q,priorityLevel:D,startTime:te,expirationTime:K,sortIndex:-1},te>G?(D.sortIndex=te,t(h,D),s(d)===null&&D===s(h)&&(b?(w(U),U=-1):b=!0,V(E,te-G))):(D.sortIndex=K,t(d,D),k||x||(k=!0,F(M))),D},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(D){var q=g;return function(){var te=g;g=q;try{return D.apply(this,arguments)}finally{g=te}}}})(rf)),rf}var dy;function rA(){return dy||(dy=1,sf.exports=iA()),sf.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 hy;function aA(){if(hy)return Cs;hy=1;var e=zc(),t=rA();function s(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,f=1;f<arguments.length;f++)c+="&args[]="+encodeURIComponent(arguments[f]);return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,r={};function o(a,c){l(a,c),l(a+"Capture",c)}function l(a,c){for(r[a]=c,a=0;a<c.length;a++)i.add(c[a])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,m={},p={};function g(a){return d.call(p,a)?!0:d.call(m,a)?!1:h.test(a)?p[a]=!0:(m[a]=!0,!1)}function x(a,c,f,y){if(f!==null&&f.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return y?!1:f!==null?!f.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function k(a,c,f,y){if(c===null||typeof c>"u"||x(a,c,f,y))return!0;if(y)return!1;if(f!==null)switch(f.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function b(a,c,f,y,C,$,W){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=y,this.attributeNamespace=C,this.mustUseProperty=f,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 b(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 b(c,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){j[a]=new b(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){j[a]=new b(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 b(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){j[a]=new b(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){j[a]=new b(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){j[a]=new b(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){j[a]=new b(a,5,!1,a.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function S(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(w,S);j[c]=new b(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(w,S);j[c]=new b(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(w,S);j[c]=new b(c,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){j[a]=new b(a,1,!1,a.toLowerCase(),null,!1,!1)}),j.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){j[a]=new b(a,1,!1,a.toLowerCase(),null,!0,!0)});function _(a,c,f,y){var C=j.hasOwnProperty(c)?j[c]:null;(C!==null?C.type!==0:y||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(k(c,f,C,y)&&(f=null),y||C===null?g(c)&&(f===null?a.removeAttribute(c):a.setAttribute(c,""+f)):C.mustUseProperty?a[C.propertyName]=f===null?C.type===3?!1:"":f:(c=C.attributeName,y=C.attributeNamespace,f===null?a.removeAttribute(c):(C=C.type,f=C===3||C===4&&f===!0?"":""+f,y?a.setAttributeNS(y,c,f):a.setAttribute(c,f))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,M=Symbol.for("react.element"),O=Symbol.for("react.portal"),B=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),R=Symbol.for("react.provider"),z=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),D=Symbol.iterator;function q(a){return a===null||typeof a!="object"?null:(a=D&&a[D]||a["@@iterator"],typeof a=="function"?a:null)}var te=Object.assign,G;function K(a){if(G===void 0)try{throw Error()}catch(f){var c=f.stack.trim().match(/\n( *(at )?)/);G=c&&c[1]||""}return`
34
+ `+G+a}var Z=!1;function Y(a,c){if(!a||Z)return"";Z=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(ye){var y=ye}Reflect.construct(a,[],c)}else{try{c.call()}catch(ye){y=ye}a.call(c.prototype)}else{try{throw Error()}catch(ye){y=ye}a()}}catch(ye){if(ye&&y&&typeof ye.stack=="string"){for(var C=ye.stack.split(`
35
+ `),$=y.stack.split(`
36
+ `),W=C.length-1,se=$.length-1;1<=W&&0<=se&&C[W]!==$[se];)se--;for(;1<=W&&0<=se;W--,se--)if(C[W]!==$[se]){if(W!==1||se!==1)do if(W--,se--,0>se||C[W]!==$[se]){var le=`
37
+ `+C[W].replace(" at new "," at ");return a.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",a.displayName)),le}while(1<=W&&0<=se);break}}}finally{Z=!1,Error.prepareStackTrace=f}return(a=a?a.displayName||a.name:"")?K(a):""}function Q(a){switch(a.tag){case 5:return K(a.type);case 16:return K("Lazy");case 13:return K("Suspense");case 19:return K("SuspenseList");case 0:case 2:case 15:return a=Y(a.type,!1),a;case 11:return a=Y(a.type.render,!1),a;case 1:return a=Y(a.type,!0),a;default:return""}}function ie(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case B:return"Fragment";case O:return"Portal";case P:return"Profiler";case U:return"StrictMode";case A:return"Suspense";case T:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case z:return(a.displayName||"Context")+".Consumer";case R:return(a._context.displayName||"Context")+".Provider";case L:var c=a.render;return a=a.displayName,a||(a=c.displayName||c.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case H:return c=a.displayName||null,c!==null?c:ie(a.type)||"Memo";case F:c=a._payload,a=a._init;try{return ie(a(c))}catch{}}return null}function re(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 ie(c);case 8:return c===U?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function ne(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function fe(a){var c=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function Ee(a){var c=fe(a)?"checked":"value",f=Object.getOwnPropertyDescriptor(a.constructor.prototype,c),y=""+a[c];if(!a.hasOwnProperty(c)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var C=f.get,$=f.set;return Object.defineProperty(a,c,{configurable:!0,get:function(){return C.call(this)},set:function(W){y=""+W,$.call(this,W)}}),Object.defineProperty(a,c,{enumerable:f.enumerable}),{getValue:function(){return y},setValue:function(W){y=""+W},stopTracking:function(){a._valueTracker=null,delete a[c]}}}}function Ue(a){a._valueTracker||(a._valueTracker=Ee(a))}function Te(a){if(!a)return!1;var c=a._valueTracker;if(!c)return!0;var f=c.getValue(),y="";return a&&(y=fe(a)?a.checked?"true":"false":a.value),a=y,a!==f?(c.setValue(a),!0):!1}function pe(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 be(a,c){var f=c.checked;return te({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f??a._wrapperState.initialChecked})}function De(a,c){var f=c.defaultValue==null?"":c.defaultValue,y=c.checked!=null?c.checked:c.defaultChecked;f=ne(c.value!=null?c.value:f),a._wrapperState={initialChecked:y,initialValue:f,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function Re(a,c){c=c.checked,c!=null&&_(a,"checked",c,!1)}function ae(a,c){Re(a,c);var f=ne(c.value),y=c.type;if(f!=null)y==="number"?(f===0&&a.value===""||a.value!=f)&&(a.value=""+f):a.value!==""+f&&(a.value=""+f);else if(y==="submit"||y==="reset"){a.removeAttribute("value");return}c.hasOwnProperty("value")?ut(a,c.type,f):c.hasOwnProperty("defaultValue")&&ut(a,c.type,ne(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(a.defaultChecked=!!c.defaultChecked)}function Fe(a,c,f){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,f||c===a.value||(a.value=c),a.defaultValue=c}f=a.name,f!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,f!==""&&(a.name=f)}function ut(a,c,f){(c!=="number"||pe(a.ownerDocument)!==a)&&(f==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+f&&(a.defaultValue=""+f))}var gt=Array.isArray;function Rt(a,c,f,y){if(a=a.options,c){c={};for(var C=0;C<f.length;C++)c["$"+f[C]]=!0;for(f=0;f<a.length;f++)C=c.hasOwnProperty("$"+a[f].value),a[f].selected!==C&&(a[f].selected=C),C&&y&&(a[f].defaultSelected=!0)}else{for(f=""+ne(f),c=null,C=0;C<a.length;C++){if(a[C].value===f){a[C].selected=!0,y&&(a[C].defaultSelected=!0);return}c!==null||a[C].disabled||(c=a[C])}c!==null&&(c.selected=!0)}}function En(a,c){if(c.dangerouslySetInnerHTML!=null)throw Error(s(91));return te({},c,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function rt(a,c){var f=c.value;if(f==null){if(f=c.children,c=c.defaultValue,f!=null){if(c!=null)throw Error(s(92));if(gt(f)){if(1<f.length)throw Error(s(93));f=f[0]}c=f}c==null&&(c=""),f=c}a._wrapperState={initialValue:ne(f)}}function Pt(a,c){var f=ne(c.value),y=ne(c.defaultValue);f!=null&&(f=""+f,f!==a.value&&(a.value=f),c.defaultValue==null&&a.defaultValue!==f&&(a.defaultValue=f)),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,f,y,C){MSApp.execUnsafeLocalFunction(function(){return a(c,f,y,C)})}:a})(function(a,c){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=c;else{for(Ut=Ut||document.createElement("div"),Ut.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=Ut.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;c.firstChild;)a.appendChild(c.firstChild)}});function mn(a,c){if(c){var f=a.firstChild;if(f&&f===a.lastChild&&f.nodeType===3){f.nodeValue=c;return}}a.textContent=c}var Hn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Gs=["Webkit","ms","Moz","O"];Object.keys(Hn).forEach(function(a){Gs.forEach(function(c){c=c+a.charAt(0).toUpperCase()+a.substring(1),Hn[c]=Hn[a]})});function ps(a,c,f){return c==null||typeof c=="boolean"||c===""?"":f||typeof c!="number"||c===0||Hn.hasOwnProperty(a)&&Hn[a]?(""+c).trim():c+"px"}function rs(a,c){a=a.style;for(var f in c)if(c.hasOwnProperty(f)){var y=f.indexOf("--")===0,C=ps(f,c[f],y);f==="float"&&(f="cssFloat"),y?a.setProperty(f,C):a[f]=C}}var gs=te({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Cn(a,c){if(c){if(gs[a]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(s(137,a));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(s(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(s(61))}if(c.style!=null&&typeof c.style!="object")throw Error(s(62))}}function as(a,c){if(a.indexOf("-")===-1)return typeof c.is=="string";switch(a){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Kn=null;function Zn(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var An=null,Yn=null,On=null;function ce(a){if(a=xl(a)){if(typeof An!="function")throw Error(s(280));var c=a.stateNode;c&&(c=lu(c),An(a.stateNode,a.type,c))}}function J(a){Yn?On?On.push(a):On=[a]:Yn=a}function me(){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 He(){}var dt=!1;function Nt(a,c,f){if(dt)return a(c,f);dt=!0;try{return we(a,c,f)}finally{dt=!1,(Yn!==null||On!==null)&&(He(),me())}}function Ze(a,c){var f=a.stateNode;if(f===null)return null;var y=lu(f);if(y===null)return null;f=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(f&&typeof f!="function")throw Error(s(231,c,typeof f));return f}var Be=!1;if(u)try{var Xe={};Object.defineProperty(Xe,"passive",{get:function(){Be=!0}}),window.addEventListener("test",Xe,Xe),window.removeEventListener("test",Xe,Xe)}catch{Be=!1}function yt(a,c,f,y,C,$,W,se,le){var ye=Array.prototype.slice.call(arguments,3);try{c.apply(f,ye)}catch($e){this.onError($e)}}var St=!1,Xn=null,xs=!1,ui=null,yr={onError:function(a){St=!0,Xn=a}};function di(a,c,f,y,C,$,W,se,le){St=!1,Xn=null,yt.apply(yr,arguments)}function br(a,c,f,y,C,$,W,se,le){if(di.apply(this,arguments),St){if(St){var ye=Xn;St=!1,Xn=null}else throw Error(s(198));xs||(xs=!0,ui=ye)}}function Qn(a){var c=a,f=a;if(a.alternate)for(;c.return;)c=c.return;else{a=c;do c=a,(c.flags&4098)!==0&&(f=c.return),a=c.return;while(a)}return c.tag===3?f:null}function Gi(a){if(a.tag===13){var c=a.memoizedState;if(c===null&&(a=a.alternate,a!==null&&(c=a.memoizedState)),c!==null)return c.dehydrated}return null}function vs(a){if(Qn(a)!==a)throw Error(s(188))}function Mi(a){var c=a.alternate;if(!c){if(c=Qn(a),c===null)throw Error(s(188));return c!==a?null:a}for(var f=a,y=c;;){var C=f.return;if(C===null)break;var $=C.alternate;if($===null){if(y=C.return,y!==null){f=y;continue}break}if(C.child===$.child){for($=C.child;$;){if($===f)return vs(C),a;if($===y)return vs(C),c;$=$.sibling}throw Error(s(188))}if(f.return!==y.return)f=C,y=$;else{for(var W=!1,se=C.child;se;){if(se===f){W=!0,f=C,y=$;break}if(se===y){W=!0,y=C,f=$;break}se=se.sibling}if(!W){for(se=$.child;se;){if(se===f){W=!0,f=$,y=C;break}if(se===y){W=!0,y=$,f=C;break}se=se.sibling}if(!W)throw Error(s(189))}}if(f.alternate!==y)throw Error(s(190))}if(f.tag!==3)throw Error(s(188));return f.stateNode.current===f?a:c}function kr(a){return a=Mi(a),a!==null?zt(a):null}function zt(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var c=zt(a);if(c!==null)return c;a=a.sibling}return null}var Os=t.unstable_scheduleCallback,os=t.unstable_cancelCallback,Ki=t.unstable_shouldYield,hi=t.unstable_requestPaint,Dt=t.unstable_now,jr=t.unstable_getCurrentPriorityLevel,Yi=t.unstable_ImmediatePriority,mi=t.unstable_UserBlockingPriority,Ri=t.unstable_NormalPriority,Oe=t.unstable_LowPriority,qe=t.unstable_IdlePriority,ht=null,ft=null;function Ot(a){if(ft&&typeof ft.onCommitFiberRoot=="function")try{ft.onCommitFiberRoot(ht,a,void 0,(a.current.flags&128)===128)}catch{}}var Ft=Math.clz32?Math.clz32:fn,Jn=Math.log,Ks=Math.LN2;function fn(a){return a>>>=0,a===0?32:31-(Jn(a)/Ks|0)|0}var $n=64,Ys=4194304;function Xs(a){switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function ys(a,c){var f=a.pendingLanes;if(f===0)return 0;var y=0,C=a.suspendedLanes,$=a.pingedLanes,W=f&268435455;if(W!==0){var se=W&~C;se!==0?y=Xs(se):($&=W,$!==0&&(y=Xs($)))}else W=f&~C,W!==0?y=Xs(W):$!==0&&(y=Xs($));if(y===0)return 0;if(c!==0&&c!==y&&(c&C)===0&&(C=y&-y,$=c&-c,C>=$||C===16&&($&4194240)!==0))return c;if((y&4)!==0&&(y|=f&16),c=a.entangledLanes,c!==0)for(a=a.entanglements,c&=y;0<c;)f=31-Ft(c),C=1<<f,y|=a[f],c&=~C;return y}function la(a,c){switch(a){case 1:case 2:case 4:return c+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Nr(a,c){for(var f=a.suspendedLanes,y=a.pingedLanes,C=a.expirationTimes,$=a.pendingLanes;0<$;){var W=31-Ft($),se=1<<W,le=C[W];le===-1?((se&f)===0||(se&y)!==0)&&(C[W]=la(se,c)):le<=c&&(a.expiredLanes|=se),$&=~se}}function Oi(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function wr(){var a=$n;return $n<<=1,($n&4194240)===0&&($n=64),a}function ls(a){for(var c=[],f=0;31>f;f++)c.push(a);return c}function bs(a,c,f){a.pendingLanes|=c,c!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,c=31-Ft(c),a[c]=f}function In(a,c){var f=a.pendingLanes&~c;a.pendingLanes=c,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=c,a.mutableReadLanes&=c,a.entangledLanes&=c,c=a.entanglements;var y=a.eventTimes;for(a=a.expirationTimes;0<f;){var C=31-Ft(f),$=1<<C;c[C]=0,y[C]=-1,a[C]=-1,f&=~$}}function Qs(a,c){var f=a.entangledLanes|=c;for(a=a.entanglements;f;){var y=31-Ft(f),C=1<<y;C&c|a[y]&c&&(a[y]|=c),f&=~C}}var wt=0;function at(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var ks,Bt,pt,Xi,cs,Qi=!1,fi=[],Pe=null,We=null,ot=null,jt=new Map,Vt=new Map,yn=[],rl="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function ca(a,c){switch(a){case"focusin":case"focusout":Pe=null;break;case"dragenter":case"dragleave":We=null;break;case"mouseover":case"mouseout":ot=null;break;case"pointerover":case"pointerout":jt.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vt.delete(c.pointerId)}}function Ji(a,c,f,y,C,$){return a===null||a.nativeEvent!==$?(a={blockedOn:c,domEventName:f,eventSystemFlags:y,nativeEvent:$,targetContainers:[C]},c!==null&&(c=xl(c),c!==null&&Bt(c)),a):(a.eventSystemFlags|=y,c=a.targetContainers,C!==null&&c.indexOf(C)===-1&&c.push(C),a)}function ua(a,c,f,y,C){switch(c){case"focusin":return Pe=Ji(Pe,a,c,f,y,C),!0;case"dragenter":return We=Ji(We,a,c,f,y,C),!0;case"mouseover":return ot=Ji(ot,a,c,f,y,C),!0;case"pointerover":var $=C.pointerId;return jt.set($,Ji(jt.get($)||null,a,c,f,y,C)),!0;case"gotpointercapture":return $=C.pointerId,Vt.set($,Ji(Vt.get($)||null,a,c,f,y,C)),!0}return!1}function Ya(a){var c=da(a.target);if(c!==null){var f=Qn(c);if(f!==null){if(c=f.tag,c===13){if(c=Gi(f),c!==null){a.blockedOn=c,cs(a.priority,function(){pt(f)});return}}else if(c===3&&f.stateNode.current.memoizedState.isDehydrated){a.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}a.blockedOn=null}function _e(a){if(a.blockedOn!==null)return!1;for(var c=a.targetContainers;0<c.length;){var f=Pn(a.domEventName,a.eventSystemFlags,c[0],a.nativeEvent);if(f===null){f=a.nativeEvent;var y=new f.constructor(f.type,f);Kn=y,f.target.dispatchEvent(y),Kn=null}else return c=xl(f),c!==null&&Bt(c),a.blockedOn=f,!1;c.shift()}return!0}function X(a,c,f){_e(a)&&f.delete(c)}function de(){Qi=!1,Pe!==null&&_e(Pe)&&(Pe=null),We!==null&&_e(We)&&(We=null),ot!==null&&_e(ot)&&(ot=null),jt.forEach(X),Vt.forEach(X)}function je(a,c){a.blockedOn===c&&(a.blockedOn=null,Qi||(Qi=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,de)))}function Ne(a){function c(C){return je(C,a)}if(0<fi.length){je(fi[0],a);for(var f=1;f<fi.length;f++){var y=fi[f];y.blockedOn===a&&(y.blockedOn=null)}}for(Pe!==null&&je(Pe,a),We!==null&&je(We,a),ot!==null&&je(ot,a),jt.forEach(c),Vt.forEach(c),f=0;f<yn.length;f++)y=yn[f],y.blockedOn===a&&(y.blockedOn=null);for(;0<yn.length&&(f=yn[0],f.blockedOn===null);)Ya(f),f.blockedOn===null&&yn.shift()}var Ye=E.ReactCurrentBatchConfig,nt=!0;function xt(a,c,f,y){var C=wt,$=Ye.transition;Ye.transition=null;try{wt=1,js(a,c,f,y)}finally{wt=C,Ye.transition=$}}function pn(a,c,f,y){var C=wt,$=Ye.transition;Ye.transition=null;try{wt=4,js(a,c,f,y)}finally{wt=C,Ye.transition=$}}function js(a,c,f,y){if(nt){var C=Pn(a,c,f,y);if(C===null)Hh(a,c,y,bn,f),ca(a,y);else if(ua(C,a,c,f,y))y.stopPropagation();else if(ca(a,y),c&4&&-1<rl.indexOf(a)){for(;C!==null;){var $=xl(C);if($!==null&&ks($),$=Pn(a,c,f,y),$===null&&Hh(a,c,y,bn,f),$===C)break;C=$}C!==null&&y.stopPropagation()}else Hh(a,c,y,null,f)}}var bn=null;function Pn(a,c,f,y){if(bn=null,a=Zn(y),a=da(a),a!==null)if(c=Qn(a),c===null)a=null;else if(f=c.tag,f===13){if(a=Gi(c),a!==null)return a;a=null}else if(f===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;a=null}else c!==a&&(a=null);return bn=a,null}function er(a){switch(a){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(jr()){case Yi:return 1;case mi:return 4;case Ri:case Oe:return 16;case qe:return 536870912;default:return 16}default:return 16}}var an=null,Xa=null,Xc=null;function Wx(){if(Xc)return Xc;var a,c=Xa,f=c.length,y,C="value"in an?an.value:an.textContent,$=C.length;for(a=0;a<f&&c[a]===C[a];a++);var W=f-a;for(y=1;y<=W&&c[f-y]===C[$-y];y++);return Xc=C.slice(a,1<y?1-y:void 0)}function Qc(a){var c=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&c===13&&(a=13)):a=c,a===10&&(a=13),32<=a||a===13?a:0}function Jc(){return!0}function Vx(){return!1}function Ps(a){function c(f,y,C,$,W){this._reactName=f,this._targetInst=C,this.type=y,this.nativeEvent=$,this.target=W,this.currentTarget=null;for(var se in a)a.hasOwnProperty(se)&&(f=a[se],this[se]=f?f($):$[se]);return this.isDefaultPrevented=($.defaultPrevented!=null?$.defaultPrevented:$.returnValue===!1)?Jc:Vx,this.isPropagationStopped=Vx,this}return te(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=Jc)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=Jc)},persist:function(){},isPersistent:Jc}),c}var Qa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ch=Ps(Qa),al=te({},Qa,{view:0,detail:0}),_E=Ps(al),Ah,$h,ol,eu=te({},al,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Th,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"?(Ah=a.screenX-ol.screenX,$h=a.screenY-ol.screenY):$h=Ah=0,ol=a),Ah)},movementY:function(a){return"movementY"in a?a.movementY:$h}}),qx=Ps(eu),EE=te({},eu,{dataTransfer:0}),CE=Ps(EE),AE=te({},al,{relatedTarget:0}),Ih=Ps(AE),$E=te({},Qa,{animationName:0,elapsedTime:0,pseudoElement:0}),IE=Ps($E),TE=te({},Qa,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),ME=Ps(TE),RE=te({},Qa,{data:0}),Gx=Ps(RE),OE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},PE={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"},LE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function zE(a){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(a):(a=LE[a])?!!c[a]:!1}function Th(){return zE}var DE=te({},al,{key:function(a){if(a.key){var c=OE[a.key]||a.key;if(c!=="Unidentified")return c}return a.type==="keypress"?(a=Qc(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?PE[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Th,charCode:function(a){return a.type==="keypress"?Qc(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Qc(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),FE=Ps(DE),UE=te({},eu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Kx=Ps(UE),BE=te({},al,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Th}),HE=Ps(BE),ZE=te({},Qa,{propertyName:0,elapsedTime:0,pseudoElement:0}),WE=Ps(ZE),VE=te({},eu,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),qE=Ps(VE),GE=[9,13,27,32],Mh=u&&"CompositionEvent"in window,ll=null;u&&"documentMode"in document&&(ll=document.documentMode);var KE=u&&"TextEvent"in window&&!ll,Yx=u&&(!Mh||ll&&8<ll&&11>=ll),Xx=" ",Qx=!1;function Jx(a,c){switch(a){case"keyup":return GE.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ev(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Ja=!1;function YE(a,c){switch(a){case"compositionend":return ev(c);case"keypress":return c.which!==32?null:(Qx=!0,Xx);case"textInput":return a=c.data,a===Xx&&Qx?null:a;default:return null}}function XE(a,c){if(Ja)return a==="compositionend"||!Mh&&Jx(a,c)?(a=Wx(),Xc=Xa=an=null,Ja=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return Yx&&c.locale!=="ko"?null:c.data;default:return null}}var QE={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 tv(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c==="input"?!!QE[a.type]:c==="textarea"}function nv(a,c,f,y){J(y),c=ru(c,"onChange"),0<c.length&&(f=new Ch("onChange","change",null,f,y),a.push({event:f,listeners:c}))}var cl=null,ul=null;function JE(a){bv(a,0)}function tu(a){var c=io(a);if(Te(c))return a}function eC(a,c){if(a==="change")return c}var sv=!1;if(u){var Rh;if(u){var Oh="oninput"in document;if(!Oh){var iv=document.createElement("div");iv.setAttribute("oninput","return;"),Oh=typeof iv.oninput=="function"}Rh=Oh}else Rh=!1;sv=Rh&&(!document.documentMode||9<document.documentMode)}function rv(){cl&&(cl.detachEvent("onpropertychange",av),ul=cl=null)}function av(a){if(a.propertyName==="value"&&tu(ul)){var c=[];nv(c,ul,a,Zn(a)),Nt(JE,c)}}function tC(a,c,f){a==="focusin"?(rv(),cl=c,ul=f,cl.attachEvent("onpropertychange",av)):a==="focusout"&&rv()}function nC(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return tu(ul)}function sC(a,c){if(a==="click")return tu(c)}function iC(a,c){if(a==="input"||a==="change")return tu(c)}function rC(a,c){return a===c&&(a!==0||1/a===1/c)||a!==a&&c!==c}var pi=typeof Object.is=="function"?Object.is:rC;function dl(a,c){if(pi(a,c))return!0;if(typeof a!="object"||a===null||typeof c!="object"||c===null)return!1;var f=Object.keys(a),y=Object.keys(c);if(f.length!==y.length)return!1;for(y=0;y<f.length;y++){var C=f[y];if(!d.call(c,C)||!pi(a[C],c[C]))return!1}return!0}function ov(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function lv(a,c){var f=ov(a);a=0;for(var y;f;){if(f.nodeType===3){if(y=a+f.textContent.length,a<=c&&y>=c)return{node:f,offset:c-a};a=y}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=ov(f)}}function cv(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?cv(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function uv(){for(var a=window,c=pe();c instanceof a.HTMLIFrameElement;){try{var f=typeof c.contentWindow.location.href=="string"}catch{f=!1}if(f)a=c.contentWindow;else break;c=pe(a.document)}return c}function Ph(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 aC(a){var c=uv(),f=a.focusedElem,y=a.selectionRange;if(c!==f&&f&&f.ownerDocument&&cv(f.ownerDocument.documentElement,f)){if(y!==null&&Ph(f)){if(c=y.start,a=y.end,a===void 0&&(a=c),"selectionStart"in f)f.selectionStart=c,f.selectionEnd=Math.min(a,f.value.length);else if(a=(c=f.ownerDocument||document)&&c.defaultView||window,a.getSelection){a=a.getSelection();var C=f.textContent.length,$=Math.min(y.start,C);y=y.end===void 0?$:Math.min(y.end,C),!a.extend&&$>y&&(C=y,y=$,$=C),C=lv(f,$);var W=lv(f,y);C&&W&&(a.rangeCount!==1||a.anchorNode!==C.node||a.anchorOffset!==C.offset||a.focusNode!==W.node||a.focusOffset!==W.offset)&&(c=c.createRange(),c.setStart(C.node,C.offset),a.removeAllRanges(),$>y?(a.addRange(c),a.extend(W.node,W.offset)):(c.setEnd(W.node,W.offset),a.addRange(c)))}}for(c=[],a=f;a=a.parentNode;)a.nodeType===1&&c.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof f.focus=="function"&&f.focus(),f=0;f<c.length;f++)a=c[f],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var oC=u&&"documentMode"in document&&11>=document.documentMode,eo=null,Lh=null,hl=null,zh=!1;function dv(a,c,f){var y=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;zh||eo==null||eo!==pe(y)||(y=eo,"selectionStart"in y&&Ph(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=ru(Lh,"onSelect"),0<y.length&&(c=new Ch("onSelect","select",null,c,f),a.push({event:c,listeners:y}),c.target=eo)))}function nu(a,c){var f={};return f[a.toLowerCase()]=c.toLowerCase(),f["Webkit"+a]="webkit"+c,f["Moz"+a]="moz"+c,f}var to={animationend:nu("Animation","AnimationEnd"),animationiteration:nu("Animation","AnimationIteration"),animationstart:nu("Animation","AnimationStart"),transitionend:nu("Transition","TransitionEnd")},Dh={},hv={};u&&(hv=document.createElement("div").style,"AnimationEvent"in window||(delete to.animationend.animation,delete to.animationiteration.animation,delete to.animationstart.animation),"TransitionEvent"in window||delete to.transitionend.transition);function su(a){if(Dh[a])return Dh[a];if(!to[a])return a;var c=to[a],f;for(f in c)if(c.hasOwnProperty(f)&&f in hv)return Dh[a]=c[f];return a}var mv=su("animationend"),fv=su("animationiteration"),pv=su("animationstart"),gv=su("transitionend"),xv=new Map,vv="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Sr(a,c){xv.set(a,c),o(c,[a])}for(var Fh=0;Fh<vv.length;Fh++){var Uh=vv[Fh],lC=Uh.toLowerCase(),cC=Uh[0].toUpperCase()+Uh.slice(1);Sr(lC,"on"+cC)}Sr(mv,"onAnimationEnd"),Sr(fv,"onAnimationIteration"),Sr(pv,"onAnimationStart"),Sr("dblclick","onDoubleClick"),Sr("focusin","onFocus"),Sr("focusout","onBlur"),Sr(gv,"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(" "),uC=new Set("cancel close invalid load scroll toggle".split(" ").concat(ml));function yv(a,c,f){var y=a.type||"unknown-event";a.currentTarget=f,br(y,c,void 0,a),a.currentTarget=null}function bv(a,c){c=(c&4)!==0;for(var f=0;f<a.length;f++){var y=a[f],C=y.event;y=y.listeners;e:{var $=void 0;if(c)for(var W=y.length-1;0<=W;W--){var se=y[W],le=se.instance,ye=se.currentTarget;if(se=se.listener,le!==$&&C.isPropagationStopped())break e;yv(C,se,ye),$=le}else for(W=0;W<y.length;W++){if(se=y[W],le=se.instance,ye=se.currentTarget,se=se.listener,le!==$&&C.isPropagationStopped())break e;yv(C,se,ye),$=le}}}if(xs)throw a=ui,xs=!1,ui=null,a}function qt(a,c){var f=c[Kh];f===void 0&&(f=c[Kh]=new Set);var y=a+"__bubble";f.has(y)||(kv(c,a,2,!1),f.add(y))}function Bh(a,c,f){var y=0;c&&(y|=4),kv(f,a,y,c)}var iu="_reactListening"+Math.random().toString(36).slice(2);function fl(a){if(!a[iu]){a[iu]=!0,i.forEach(function(f){f!=="selectionchange"&&(uC.has(f)||Bh(f,!1,a),Bh(f,!0,a))});var c=a.nodeType===9?a:a.ownerDocument;c===null||c[iu]||(c[iu]=!0,Bh("selectionchange",!1,c))}}function kv(a,c,f,y){switch(er(c)){case 1:var C=xt;break;case 4:C=pn;break;default:C=js}f=C.bind(null,c,f,a),C=void 0,!Be||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(C=!0),y?C!==void 0?a.addEventListener(c,f,{capture:!0,passive:C}):a.addEventListener(c,f,!0):C!==void 0?a.addEventListener(c,f,{passive:C}):a.addEventListener(c,f,!1)}function Hh(a,c,f,y,C){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 se=y.stateNode.containerInfo;if(se===C||se.nodeType===8&&se.parentNode===C)break;if(W===4)for(W=y.return;W!==null;){var le=W.tag;if((le===3||le===4)&&(le=W.stateNode.containerInfo,le===C||le.nodeType===8&&le.parentNode===C))return;W=W.return}for(;se!==null;){if(W=da(se),W===null)return;if(le=W.tag,le===5||le===6){y=$=W;continue e}se=se.parentNode}}y=y.return}Nt(function(){var ye=$,$e=Zn(f),Me=[];e:{var Ae=xv.get(a);if(Ae!==void 0){var Ve=Ch,Ke=a;switch(a){case"keypress":if(Qc(f)===0)break e;case"keydown":case"keyup":Ve=FE;break;case"focusin":Ke="focus",Ve=Ih;break;case"focusout":Ke="blur",Ve=Ih;break;case"beforeblur":case"afterblur":Ve=Ih;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ve=qx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ve=CE;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ve=HE;break;case mv:case fv:case pv:Ve=IE;break;case gv:Ve=WE;break;case"scroll":Ve=_E;break;case"wheel":Ve=qE;break;case"copy":case"cut":case"paste":Ve=ME;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ve=Kx}var Qe=(c&4)!==0,gn=!Qe&&a==="scroll",ge=Qe?Ae!==null?Ae+"Capture":null:Ae;Qe=[];for(var he=ye,xe;he!==null;){xe=he;var Le=xe.stateNode;if(xe.tag===5&&Le!==null&&(xe=Le,ge!==null&&(Le=Ze(he,ge),Le!=null&&Qe.push(pl(he,Le,xe)))),gn)break;he=he.return}0<Qe.length&&(Ae=new Ve(Ae,Ke,null,f,$e),Me.push({event:Ae,listeners:Qe}))}}if((c&7)===0){e:{if(Ae=a==="mouseover"||a==="pointerover",Ve=a==="mouseout"||a==="pointerout",Ae&&f!==Kn&&(Ke=f.relatedTarget||f.fromElement)&&(da(Ke)||Ke[tr]))break e;if((Ve||Ae)&&(Ae=$e.window===$e?$e:(Ae=$e.ownerDocument)?Ae.defaultView||Ae.parentWindow:window,Ve?(Ke=f.relatedTarget||f.toElement,Ve=ye,Ke=Ke?da(Ke):null,Ke!==null&&(gn=Qn(Ke),Ke!==gn||Ke.tag!==5&&Ke.tag!==6)&&(Ke=null)):(Ve=null,Ke=ye),Ve!==Ke)){if(Qe=qx,Le="onMouseLeave",ge="onMouseEnter",he="mouse",(a==="pointerout"||a==="pointerover")&&(Qe=Kx,Le="onPointerLeave",ge="onPointerEnter",he="pointer"),gn=Ve==null?Ae:io(Ve),xe=Ke==null?Ae:io(Ke),Ae=new Qe(Le,he+"leave",Ve,f,$e),Ae.target=gn,Ae.relatedTarget=xe,Le=null,da($e)===ye&&(Qe=new Qe(ge,he+"enter",Ke,f,$e),Qe.target=xe,Qe.relatedTarget=gn,Le=Qe),gn=Le,Ve&&Ke)t:{for(Qe=Ve,ge=Ke,he=0,xe=Qe;xe;xe=no(xe))he++;for(xe=0,Le=ge;Le;Le=no(Le))xe++;for(;0<he-xe;)Qe=no(Qe),he--;for(;0<xe-he;)ge=no(ge),xe--;for(;he--;){if(Qe===ge||ge!==null&&Qe===ge.alternate)break t;Qe=no(Qe),ge=no(ge)}Qe=null}else Qe=null;Ve!==null&&jv(Me,Ae,Ve,Qe,!1),Ke!==null&&gn!==null&&jv(Me,gn,Ke,Qe,!0)}}e:{if(Ae=ye?io(ye):window,Ve=Ae.nodeName&&Ae.nodeName.toLowerCase(),Ve==="select"||Ve==="input"&&Ae.type==="file")var Je=eC;else if(tv(Ae))if(sv)Je=iC;else{Je=nC;var st=tC}else(Ve=Ae.nodeName)&&Ve.toLowerCase()==="input"&&(Ae.type==="checkbox"||Ae.type==="radio")&&(Je=sC);if(Je&&(Je=Je(a,ye))){nv(Me,Je,f,$e);break e}st&&st(a,Ae,ye),a==="focusout"&&(st=Ae._wrapperState)&&st.controlled&&Ae.type==="number"&&ut(Ae,"number",Ae.value)}switch(st=ye?io(ye):window,a){case"focusin":(tv(st)||st.contentEditable==="true")&&(eo=st,Lh=ye,hl=null);break;case"focusout":hl=Lh=eo=null;break;case"mousedown":zh=!0;break;case"contextmenu":case"mouseup":case"dragend":zh=!1,dv(Me,f,$e);break;case"selectionchange":if(oC)break;case"keydown":case"keyup":dv(Me,f,$e)}var it;if(Mh)e:{switch(a){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else Ja?Jx(a,f)&&(lt="onCompositionEnd"):a==="keydown"&&f.keyCode===229&&(lt="onCompositionStart");lt&&(Yx&&f.locale!=="ko"&&(Ja||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&Ja&&(it=Wx()):(an=$e,Xa="value"in an?an.value:an.textContent,Ja=!0)),st=ru(ye,lt),0<st.length&&(lt=new Gx(lt,a,null,f,$e),Me.push({event:lt,listeners:st}),it?lt.data=it:(it=ev(f),it!==null&&(lt.data=it)))),(it=KE?YE(a,f):XE(a,f))&&(ye=ru(ye,"onBeforeInput"),0<ye.length&&($e=new Gx("onBeforeInput","beforeinput",null,f,$e),Me.push({event:$e,listeners:ye}),$e.data=it))}bv(Me,c)})}function pl(a,c,f){return{instance:a,listener:c,currentTarget:f}}function ru(a,c){for(var f=c+"Capture",y=[];a!==null;){var C=a,$=C.stateNode;C.tag===5&&$!==null&&(C=$,$=Ze(a,f),$!=null&&y.unshift(pl(a,$,C)),$=Ze(a,c),$!=null&&y.push(pl(a,$,C))),a=a.return}return y}function no(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function jv(a,c,f,y,C){for(var $=c._reactName,W=[];f!==null&&f!==y;){var se=f,le=se.alternate,ye=se.stateNode;if(le!==null&&le===y)break;se.tag===5&&ye!==null&&(se=ye,C?(le=Ze(f,$),le!=null&&W.unshift(pl(f,le,se))):C||(le=Ze(f,$),le!=null&&W.push(pl(f,le,se)))),f=f.return}W.length!==0&&a.push({event:c,listeners:W})}var dC=/\r\n?/g,hC=/\u0000|\uFFFD/g;function Nv(a){return(typeof a=="string"?a:""+a).replace(dC,`
38
+ `).replace(hC,"")}function au(a,c,f){if(c=Nv(c),Nv(a)!==c&&f)throw Error(s(425))}function ou(){}var Zh=null,Wh=null;function Vh(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 qh=typeof setTimeout=="function"?setTimeout:void 0,mC=typeof clearTimeout=="function"?clearTimeout:void 0,wv=typeof Promise=="function"?Promise:void 0,fC=typeof queueMicrotask=="function"?queueMicrotask:typeof wv<"u"?function(a){return wv.resolve(null).then(a).catch(pC)}:qh;function pC(a){setTimeout(function(){throw a})}function Gh(a,c){var f=c,y=0;do{var C=f.nextSibling;if(a.removeChild(f),C&&C.nodeType===8)if(f=C.data,f==="/$"){if(y===0){a.removeChild(C),Ne(c);return}y--}else f!=="$"&&f!=="$?"&&f!=="$!"||y++;f=C}while(f);Ne(c)}function _r(a){for(;a!=null;a=a.nextSibling){var c=a.nodeType;if(c===1||c===3)break;if(c===8){if(c=a.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return a}function Sv(a){a=a.previousSibling;for(var c=0;a;){if(a.nodeType===8){var f=a.data;if(f==="$"||f==="$!"||f==="$?"){if(c===0)return a;c--}else f==="/$"&&c++}a=a.previousSibling}return null}var so=Math.random().toString(36).slice(2),Pi="__reactFiber$"+so,gl="__reactProps$"+so,tr="__reactContainer$"+so,Kh="__reactEvents$"+so,gC="__reactListeners$"+so,xC="__reactHandles$"+so;function da(a){var c=a[Pi];if(c)return c;for(var f=a.parentNode;f;){if(c=f[tr]||f[Pi]){if(f=c.alternate,c.child!==null||f!==null&&f.child!==null)for(a=Sv(a);a!==null;){if(f=a[Pi])return f;a=Sv(a)}return c}a=f,f=a.parentNode}return null}function xl(a){return a=a[Pi]||a[tr],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function io(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(s(33))}function lu(a){return a[gl]||null}var Yh=[],ro=-1;function Er(a){return{current:a}}function Gt(a){0>ro||(a.current=Yh[ro],Yh[ro]=null,ro--)}function Wt(a,c){ro++,Yh[ro]=a.current,a.current=c}var Cr={},es=Er(Cr),Ns=Er(!1),ha=Cr;function ao(a,c){var f=a.type.contextTypes;if(!f)return Cr;var y=a.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===c)return y.__reactInternalMemoizedMaskedChildContext;var C={},$;for($ in f)C[$]=c[$];return y&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=c,a.__reactInternalMemoizedMaskedChildContext=C),C}function ws(a){return a=a.childContextTypes,a!=null}function cu(){Gt(Ns),Gt(es)}function _v(a,c,f){if(es.current!==Cr)throw Error(s(168));Wt(es,c),Wt(Ns,f)}function Ev(a,c,f){var y=a.stateNode;if(c=c.childContextTypes,typeof y.getChildContext!="function")return f;y=y.getChildContext();for(var C in y)if(!(C in c))throw Error(s(108,re(a)||"Unknown",C));return te({},f,y)}function uu(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||Cr,ha=es.current,Wt(es,a),Wt(Ns,Ns.current),!0}function Cv(a,c,f){var y=a.stateNode;if(!y)throw Error(s(169));f?(a=Ev(a,c,ha),y.__reactInternalMemoizedMergedChildContext=a,Gt(Ns),Gt(es),Wt(es,a)):Gt(Ns),Wt(Ns,f)}var nr=null,du=!1,Xh=!1;function Av(a){nr===null?nr=[a]:nr.push(a)}function vC(a){du=!0,Av(a)}function Ar(){if(!Xh&&nr!==null){Xh=!0;var a=0,c=wt;try{var f=nr;for(wt=1;a<f.length;a++){var y=f[a];do y=y(!0);while(y!==null)}nr=null,du=!1}catch(C){throw nr!==null&&(nr=nr.slice(a+1)),Os(Yi,Ar),C}finally{wt=c,Xh=!1}}return null}var oo=[],lo=0,hu=null,mu=0,Js=[],ei=0,ma=null,sr=1,ir="";function fa(a,c){oo[lo++]=mu,oo[lo++]=hu,hu=a,mu=c}function $v(a,c,f){Js[ei++]=sr,Js[ei++]=ir,Js[ei++]=ma,ma=a;var y=sr;a=ir;var C=32-Ft(y)-1;y&=~(1<<C),f+=1;var $=32-Ft(c)+C;if(30<$){var W=C-C%5;$=(y&(1<<W)-1).toString(32),y>>=W,C-=W,sr=1<<32-Ft(c)+C|f<<C|y,ir=$+a}else sr=1<<$|f<<C|y,ir=a}function Qh(a){a.return!==null&&(fa(a,1),$v(a,1,0))}function Jh(a){for(;a===hu;)hu=oo[--lo],oo[lo]=null,mu=oo[--lo],oo[lo]=null;for(;a===ma;)ma=Js[--ei],Js[ei]=null,ir=Js[--ei],Js[ei]=null,sr=Js[--ei],Js[ei]=null}var Ls=null,zs=null,Jt=!1,gi=null;function Iv(a,c){var f=ii(5,null,null,0);f.elementType="DELETED",f.stateNode=c,f.return=a,c=a.deletions,c===null?(a.deletions=[f],a.flags|=16):c.push(f)}function Tv(a,c){switch(a.tag){case 5:var f=a.type;return c=c.nodeType!==1||f.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(a.stateNode=c,Ls=a,zs=_r(c.firstChild),!0):!1;case 6:return c=a.pendingProps===""||c.nodeType!==3?null:c,c!==null?(a.stateNode=c,Ls=a,zs=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(f=ma!==null?{id:sr,overflow:ir}:null,a.memoizedState={dehydrated:c,treeContext:f,retryLane:1073741824},f=ii(18,null,null,0),f.stateNode=c,f.return=a,a.child=f,Ls=a,zs=null,!0):!1;default:return!1}}function em(a){return(a.mode&1)!==0&&(a.flags&128)===0}function tm(a){if(Jt){var c=zs;if(c){var f=c;if(!Tv(a,c)){if(em(a))throw Error(s(418));c=_r(f.nextSibling);var y=Ls;c&&Tv(a,c)?Iv(y,f):(a.flags=a.flags&-4097|2,Jt=!1,Ls=a)}}else{if(em(a))throw Error(s(418));a.flags=a.flags&-4097|2,Jt=!1,Ls=a}}}function Mv(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Ls=a}function fu(a){if(a!==Ls)return!1;if(!Jt)return Mv(a),Jt=!0,!1;var c;if((c=a.tag!==3)&&!(c=a.tag!==5)&&(c=a.type,c=c!=="head"&&c!=="body"&&!Vh(a.type,a.memoizedProps)),c&&(c=zs)){if(em(a))throw Rv(),Error(s(418));for(;c;)Iv(a,c),c=_r(c.nextSibling)}if(Mv(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(s(317));e:{for(a=a.nextSibling,c=0;a;){if(a.nodeType===8){var f=a.data;if(f==="/$"){if(c===0){zs=_r(a.nextSibling);break e}c--}else f!=="$"&&f!=="$!"&&f!=="$?"||c++}a=a.nextSibling}zs=null}}else zs=Ls?_r(a.stateNode.nextSibling):null;return!0}function Rv(){for(var a=zs;a;)a=_r(a.nextSibling)}function co(){zs=Ls=null,Jt=!1}function nm(a){gi===null?gi=[a]:gi.push(a)}var yC=E.ReactCurrentBatchConfig;function vl(a,c,f){if(a=f.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(f._owner){if(f=f._owner,f){if(f.tag!==1)throw Error(s(309));var y=f.stateNode}if(!y)throw Error(s(147,a));var C=y,$=""+a;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===$?c.ref:(c=function(W){var se=C.refs;W===null?delete se[$]:se[$]=W},c._stringRef=$,c)}if(typeof a!="string")throw Error(s(284));if(!f._owner)throw Error(s(290,a))}return a}function pu(a,c){throw a=Object.prototype.toString.call(c),Error(s(31,a==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":a))}function Ov(a){var c=a._init;return c(a._payload)}function Pv(a){function c(ge,he){if(a){var xe=ge.deletions;xe===null?(ge.deletions=[he],ge.flags|=16):xe.push(he)}}function f(ge,he){if(!a)return null;for(;he!==null;)c(ge,he),he=he.sibling;return null}function y(ge,he){for(ge=new Map;he!==null;)he.key!==null?ge.set(he.key,he):ge.set(he.index,he),he=he.sibling;return ge}function C(ge,he){return ge=Lr(ge,he),ge.index=0,ge.sibling=null,ge}function $(ge,he,xe){return ge.index=xe,a?(xe=ge.alternate,xe!==null?(xe=xe.index,xe<he?(ge.flags|=2,he):xe):(ge.flags|=2,he)):(ge.flags|=1048576,he)}function W(ge){return a&&ge.alternate===null&&(ge.flags|=2),ge}function se(ge,he,xe,Le){return he===null||he.tag!==6?(he=qm(xe,ge.mode,Le),he.return=ge,he):(he=C(he,xe),he.return=ge,he)}function le(ge,he,xe,Le){var Je=xe.type;return Je===B?$e(ge,he,xe.props.children,Le,xe.key):he!==null&&(he.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===F&&Ov(Je)===he.type)?(Le=C(he,xe.props),Le.ref=vl(ge,he,xe),Le.return=ge,Le):(Le=Du(xe.type,xe.key,xe.props,null,ge.mode,Le),Le.ref=vl(ge,he,xe),Le.return=ge,Le)}function ye(ge,he,xe,Le){return he===null||he.tag!==4||he.stateNode.containerInfo!==xe.containerInfo||he.stateNode.implementation!==xe.implementation?(he=Gm(xe,ge.mode,Le),he.return=ge,he):(he=C(he,xe.children||[]),he.return=ge,he)}function $e(ge,he,xe,Le,Je){return he===null||he.tag!==7?(he=ja(xe,ge.mode,Le,Je),he.return=ge,he):(he=C(he,xe),he.return=ge,he)}function Me(ge,he,xe){if(typeof he=="string"&&he!==""||typeof he=="number")return he=qm(""+he,ge.mode,xe),he.return=ge,he;if(typeof he=="object"&&he!==null){switch(he.$$typeof){case M:return xe=Du(he.type,he.key,he.props,null,ge.mode,xe),xe.ref=vl(ge,null,he),xe.return=ge,xe;case O:return he=Gm(he,ge.mode,xe),he.return=ge,he;case F:var Le=he._init;return Me(ge,Le(he._payload),xe)}if(gt(he)||q(he))return he=ja(he,ge.mode,xe,null),he.return=ge,he;pu(ge,he)}return null}function Ae(ge,he,xe,Le){var Je=he!==null?he.key:null;if(typeof xe=="string"&&xe!==""||typeof xe=="number")return Je!==null?null:se(ge,he,""+xe,Le);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case M:return xe.key===Je?le(ge,he,xe,Le):null;case O:return xe.key===Je?ye(ge,he,xe,Le):null;case F:return Je=xe._init,Ae(ge,he,Je(xe._payload),Le)}if(gt(xe)||q(xe))return Je!==null?null:$e(ge,he,xe,Le,null);pu(ge,xe)}return null}function Ve(ge,he,xe,Le,Je){if(typeof Le=="string"&&Le!==""||typeof Le=="number")return ge=ge.get(xe)||null,se(he,ge,""+Le,Je);if(typeof Le=="object"&&Le!==null){switch(Le.$$typeof){case M:return ge=ge.get(Le.key===null?xe:Le.key)||null,le(he,ge,Le,Je);case O:return ge=ge.get(Le.key===null?xe:Le.key)||null,ye(he,ge,Le,Je);case F:var st=Le._init;return Ve(ge,he,xe,st(Le._payload),Je)}if(gt(Le)||q(Le))return ge=ge.get(xe)||null,$e(he,ge,Le,Je,null);pu(he,Le)}return null}function Ke(ge,he,xe,Le){for(var Je=null,st=null,it=he,lt=he=0,Dn=null;it!==null&&lt<xe.length;lt++){it.index>lt?(Dn=it,it=null):Dn=it.sibling;var $t=Ae(ge,it,xe[lt],Le);if($t===null){it===null&&(it=Dn);break}a&&it&&$t.alternate===null&&c(ge,it),he=$($t,he,lt),st===null?Je=$t:st.sibling=$t,st=$t,it=Dn}if(lt===xe.length)return f(ge,it),Jt&&fa(ge,lt),Je;if(it===null){for(;lt<xe.length;lt++)it=Me(ge,xe[lt],Le),it!==null&&(he=$(it,he,lt),st===null?Je=it:st.sibling=it,st=it);return Jt&&fa(ge,lt),Je}for(it=y(ge,it);lt<xe.length;lt++)Dn=Ve(it,ge,lt,xe[lt],Le),Dn!==null&&(a&&Dn.alternate!==null&&it.delete(Dn.key===null?lt:Dn.key),he=$(Dn,he,lt),st===null?Je=Dn:st.sibling=Dn,st=Dn);return a&&it.forEach(function(zr){return c(ge,zr)}),Jt&&fa(ge,lt),Je}function Qe(ge,he,xe,Le){var Je=q(xe);if(typeof Je!="function")throw Error(s(150));if(xe=Je.call(xe),xe==null)throw Error(s(151));for(var st=Je=null,it=he,lt=he=0,Dn=null,$t=xe.next();it!==null&&!$t.done;lt++,$t=xe.next()){it.index>lt?(Dn=it,it=null):Dn=it.sibling;var zr=Ae(ge,it,$t.value,Le);if(zr===null){it===null&&(it=Dn);break}a&&it&&zr.alternate===null&&c(ge,it),he=$(zr,he,lt),st===null?Je=zr:st.sibling=zr,st=zr,it=Dn}if($t.done)return f(ge,it),Jt&&fa(ge,lt),Je;if(it===null){for(;!$t.done;lt++,$t=xe.next())$t=Me(ge,$t.value,Le),$t!==null&&(he=$($t,he,lt),st===null?Je=$t:st.sibling=$t,st=$t);return Jt&&fa(ge,lt),Je}for(it=y(ge,it);!$t.done;lt++,$t=xe.next())$t=Ve(it,ge,lt,$t.value,Le),$t!==null&&(a&&$t.alternate!==null&&it.delete($t.key===null?lt:$t.key),he=$($t,he,lt),st===null?Je=$t:st.sibling=$t,st=$t);return a&&it.forEach(function(QC){return c(ge,QC)}),Jt&&fa(ge,lt),Je}function gn(ge,he,xe,Le){if(typeof xe=="object"&&xe!==null&&xe.type===B&&xe.key===null&&(xe=xe.props.children),typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case M:e:{for(var Je=xe.key,st=he;st!==null;){if(st.key===Je){if(Je=xe.type,Je===B){if(st.tag===7){f(ge,st.sibling),he=C(st,xe.props.children),he.return=ge,ge=he;break e}}else if(st.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===F&&Ov(Je)===st.type){f(ge,st.sibling),he=C(st,xe.props),he.ref=vl(ge,st,xe),he.return=ge,ge=he;break e}f(ge,st);break}else c(ge,st);st=st.sibling}xe.type===B?(he=ja(xe.props.children,ge.mode,Le,xe.key),he.return=ge,ge=he):(Le=Du(xe.type,xe.key,xe.props,null,ge.mode,Le),Le.ref=vl(ge,he,xe),Le.return=ge,ge=Le)}return W(ge);case O:e:{for(st=xe.key;he!==null;){if(he.key===st)if(he.tag===4&&he.stateNode.containerInfo===xe.containerInfo&&he.stateNode.implementation===xe.implementation){f(ge,he.sibling),he=C(he,xe.children||[]),he.return=ge,ge=he;break e}else{f(ge,he);break}else c(ge,he);he=he.sibling}he=Gm(xe,ge.mode,Le),he.return=ge,ge=he}return W(ge);case F:return st=xe._init,gn(ge,he,st(xe._payload),Le)}if(gt(xe))return Ke(ge,he,xe,Le);if(q(xe))return Qe(ge,he,xe,Le);pu(ge,xe)}return typeof xe=="string"&&xe!==""||typeof xe=="number"?(xe=""+xe,he!==null&&he.tag===6?(f(ge,he.sibling),he=C(he,xe),he.return=ge,ge=he):(f(ge,he),he=qm(xe,ge.mode,Le),he.return=ge,ge=he),W(ge)):f(ge,he)}return gn}var uo=Pv(!0),Lv=Pv(!1),gu=Er(null),xu=null,ho=null,sm=null;function im(){sm=ho=xu=null}function rm(a){var c=gu.current;Gt(gu),a._currentValue=c}function am(a,c,f){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===f)break;a=a.return}}function mo(a,c){xu=a,sm=ho=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&c)!==0&&(Ss=!0),a.firstContext=null)}function ti(a){var c=a._currentValue;if(sm!==a)if(a={context:a,memoizedValue:c,next:null},ho===null){if(xu===null)throw Error(s(308));ho=a,xu.dependencies={lanes:0,firstContext:a}}else ho=ho.next=a;return c}var pa=null;function om(a){pa===null?pa=[a]:pa.push(a)}function zv(a,c,f,y){var C=c.interleaved;return C===null?(f.next=f,om(c)):(f.next=C.next,C.next=f),c.interleaved=f,rr(a,y)}function rr(a,c){a.lanes|=c;var f=a.alternate;for(f!==null&&(f.lanes|=c),f=a,a=a.return;a!==null;)a.childLanes|=c,f=a.alternate,f!==null&&(f.childLanes|=c),f=a,a=a.return;return f.tag===3?f.stateNode:null}var $r=!1;function lm(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Dv(a,c){a=a.updateQueue,c.updateQueue===a&&(c.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function ar(a,c){return{eventTime:a,lane:c,tag:0,payload:null,callback:null,next:null}}function Ir(a,c,f){var y=a.updateQueue;if(y===null)return null;if(y=y.shared,(Et&2)!==0){var C=y.pending;return C===null?c.next=c:(c.next=C.next,C.next=c),y.pending=c,rr(a,f)}return C=y.interleaved,C===null?(c.next=c,om(y)):(c.next=C.next,C.next=c),y.interleaved=c,rr(a,f)}function vu(a,c,f){if(c=c.updateQueue,c!==null&&(c=c.shared,(f&4194240)!==0)){var y=c.lanes;y&=a.pendingLanes,f|=y,c.lanes=f,Qs(a,f)}}function Fv(a,c){var f=a.updateQueue,y=a.alternate;if(y!==null&&(y=y.updateQueue,f===y)){var C=null,$=null;if(f=f.firstBaseUpdate,f!==null){do{var W={eventTime:f.eventTime,lane:f.lane,tag:f.tag,payload:f.payload,callback:f.callback,next:null};$===null?C=$=W:$=$.next=W,f=f.next}while(f!==null);$===null?C=$=c:$=$.next=c}else C=$=c;f={baseState:y.baseState,firstBaseUpdate:C,lastBaseUpdate:$,shared:y.shared,effects:y.effects},a.updateQueue=f;return}a=f.lastBaseUpdate,a===null?f.firstBaseUpdate=c:a.next=c,f.lastBaseUpdate=c}function yu(a,c,f,y){var C=a.updateQueue;$r=!1;var $=C.firstBaseUpdate,W=C.lastBaseUpdate,se=C.shared.pending;if(se!==null){C.shared.pending=null;var le=se,ye=le.next;le.next=null,W===null?$=ye:W.next=ye,W=le;var $e=a.alternate;$e!==null&&($e=$e.updateQueue,se=$e.lastBaseUpdate,se!==W&&(se===null?$e.firstBaseUpdate=ye:se.next=ye,$e.lastBaseUpdate=le))}if($!==null){var Me=C.baseState;W=0,$e=ye=le=null,se=$;do{var Ae=se.lane,Ve=se.eventTime;if((y&Ae)===Ae){$e!==null&&($e=$e.next={eventTime:Ve,lane:0,tag:se.tag,payload:se.payload,callback:se.callback,next:null});e:{var Ke=a,Qe=se;switch(Ae=c,Ve=f,Qe.tag){case 1:if(Ke=Qe.payload,typeof Ke=="function"){Me=Ke.call(Ve,Me,Ae);break e}Me=Ke;break e;case 3:Ke.flags=Ke.flags&-65537|128;case 0:if(Ke=Qe.payload,Ae=typeof Ke=="function"?Ke.call(Ve,Me,Ae):Ke,Ae==null)break e;Me=te({},Me,Ae);break e;case 2:$r=!0}}se.callback!==null&&se.lane!==0&&(a.flags|=64,Ae=C.effects,Ae===null?C.effects=[se]:Ae.push(se))}else Ve={eventTime:Ve,lane:Ae,tag:se.tag,payload:se.payload,callback:se.callback,next:null},$e===null?(ye=$e=Ve,le=Me):$e=$e.next=Ve,W|=Ae;if(se=se.next,se===null){if(se=C.shared.pending,se===null)break;Ae=se,se=Ae.next,Ae.next=null,C.lastBaseUpdate=Ae,C.shared.pending=null}}while(!0);if($e===null&&(le=Me),C.baseState=le,C.firstBaseUpdate=ye,C.lastBaseUpdate=$e,c=C.shared.interleaved,c!==null){C=c;do W|=C.lane,C=C.next;while(C!==c)}else $===null&&(C.shared.lanes=0);va|=W,a.lanes=W,a.memoizedState=Me}}function Uv(a,c,f){if(a=c.effects,c.effects=null,a!==null)for(c=0;c<a.length;c++){var y=a[c],C=y.callback;if(C!==null){if(y.callback=null,y=f,typeof C!="function")throw Error(s(191,C));C.call(y)}}}var yl={},Li=Er(yl),bl=Er(yl),kl=Er(yl);function ga(a){if(a===yl)throw Error(s(174));return a}function cm(a,c){switch(Wt(kl,c),Wt(bl,a),Wt(Li,yl),a=c.nodeType,a){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:Qt(null,"");break;default:a=a===8?c.parentNode:c,c=a.namespaceURI||null,a=a.tagName,c=Qt(c,a)}Gt(Li),Wt(Li,c)}function fo(){Gt(Li),Gt(bl),Gt(kl)}function Bv(a){ga(kl.current);var c=ga(Li.current),f=Qt(c,a.type);c!==f&&(Wt(bl,a),Wt(Li,f))}function um(a){bl.current===a&&(Gt(Li),Gt(bl))}var on=Er(0);function bu(a){for(var c=a;c!==null;){if(c.tag===13){var f=c.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||f.data==="$?"||f.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var dm=[];function hm(){for(var a=0;a<dm.length;a++)dm[a]._workInProgressVersionPrimary=null;dm.length=0}var ku=E.ReactCurrentDispatcher,mm=E.ReactCurrentBatchConfig,xa=0,ln=null,Tn=null,Ln=null,ju=!1,jl=!1,Nl=0,bC=0;function ts(){throw Error(s(321))}function fm(a,c){if(c===null)return!1;for(var f=0;f<c.length&&f<a.length;f++)if(!pi(a[f],c[f]))return!1;return!0}function pm(a,c,f,y,C,$){if(xa=$,ln=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,ku.current=a===null||a.memoizedState===null?wC:SC,a=f(y,C),jl){$=0;do{if(jl=!1,Nl=0,25<=$)throw Error(s(301));$+=1,Ln=Tn=null,c.updateQueue=null,ku.current=_C,a=f(y,C)}while(jl)}if(ku.current=Su,c=Tn!==null&&Tn.next!==null,xa=0,Ln=Tn=ln=null,ju=!1,c)throw Error(s(300));return a}function gm(){var a=Nl!==0;return Nl=0,a}function zi(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ln===null?ln.memoizedState=Ln=a:Ln=Ln.next=a,Ln}function ni(){if(Tn===null){var a=ln.alternate;a=a!==null?a.memoizedState:null}else a=Tn.next;var c=Ln===null?ln.memoizedState:Ln.next;if(c!==null)Ln=c,Tn=a;else{if(a===null)throw Error(s(310));Tn=a,a={memoizedState:Tn.memoizedState,baseState:Tn.baseState,baseQueue:Tn.baseQueue,queue:Tn.queue,next:null},Ln===null?ln.memoizedState=Ln=a:Ln=Ln.next=a}return Ln}function wl(a,c){return typeof c=="function"?c(a):c}function xm(a){var c=ni(),f=c.queue;if(f===null)throw Error(s(311));f.lastRenderedReducer=a;var y=Tn,C=y.baseQueue,$=f.pending;if($!==null){if(C!==null){var W=C.next;C.next=$.next,$.next=W}y.baseQueue=C=$,f.pending=null}if(C!==null){$=C.next,y=y.baseState;var se=W=null,le=null,ye=$;do{var $e=ye.lane;if((xa&$e)===$e)le!==null&&(le=le.next={lane:0,action:ye.action,hasEagerState:ye.hasEagerState,eagerState:ye.eagerState,next:null}),y=ye.hasEagerState?ye.eagerState:a(y,ye.action);else{var Me={lane:$e,action:ye.action,hasEagerState:ye.hasEagerState,eagerState:ye.eagerState,next:null};le===null?(se=le=Me,W=y):le=le.next=Me,ln.lanes|=$e,va|=$e}ye=ye.next}while(ye!==null&&ye!==$);le===null?W=y:le.next=se,pi(y,c.memoizedState)||(Ss=!0),c.memoizedState=y,c.baseState=W,c.baseQueue=le,f.lastRenderedState=y}if(a=f.interleaved,a!==null){C=a;do $=C.lane,ln.lanes|=$,va|=$,C=C.next;while(C!==a)}else C===null&&(f.lanes=0);return[c.memoizedState,f.dispatch]}function vm(a){var c=ni(),f=c.queue;if(f===null)throw Error(s(311));f.lastRenderedReducer=a;var y=f.dispatch,C=f.pending,$=c.memoizedState;if(C!==null){f.pending=null;var W=C=C.next;do $=a($,W.action),W=W.next;while(W!==C);pi($,c.memoizedState)||(Ss=!0),c.memoizedState=$,c.baseQueue===null&&(c.baseState=$),f.lastRenderedState=$}return[$,y]}function Hv(){}function Zv(a,c){var f=ln,y=ni(),C=c(),$=!pi(y.memoizedState,C);if($&&(y.memoizedState=C,Ss=!0),y=y.queue,ym(qv.bind(null,f,y,a),[a]),y.getSnapshot!==c||$||Ln!==null&&Ln.memoizedState.tag&1){if(f.flags|=2048,Sl(9,Vv.bind(null,f,y,C,c),void 0,null),zn===null)throw Error(s(349));(xa&30)!==0||Wv(f,c,C)}return C}function Wv(a,c,f){a.flags|=16384,a={getSnapshot:c,value:f},c=ln.updateQueue,c===null?(c={lastEffect:null,stores:null},ln.updateQueue=c,c.stores=[a]):(f=c.stores,f===null?c.stores=[a]:f.push(a))}function Vv(a,c,f,y){c.value=f,c.getSnapshot=y,Gv(c)&&Kv(a)}function qv(a,c,f){return f(function(){Gv(c)&&Kv(a)})}function Gv(a){var c=a.getSnapshot;a=a.value;try{var f=c();return!pi(a,f)}catch{return!0}}function Kv(a){var c=rr(a,1);c!==null&&bi(c,a,1,-1)}function Yv(a){var c=zi();return typeof a=="function"&&(a=a()),c.memoizedState=c.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:wl,lastRenderedState:a},c.queue=a,a=a.dispatch=NC.bind(null,ln,a),[c.memoizedState,a]}function Sl(a,c,f,y){return a={tag:a,create:c,destroy:f,deps:y,next:null},c=ln.updateQueue,c===null?(c={lastEffect:null,stores:null},ln.updateQueue=c,c.lastEffect=a.next=a):(f=c.lastEffect,f===null?c.lastEffect=a.next=a:(y=f.next,f.next=a,a.next=y,c.lastEffect=a)),a}function Xv(){return ni().memoizedState}function Nu(a,c,f,y){var C=zi();ln.flags|=a,C.memoizedState=Sl(1|c,f,void 0,y===void 0?null:y)}function wu(a,c,f,y){var C=ni();y=y===void 0?null:y;var $=void 0;if(Tn!==null){var W=Tn.memoizedState;if($=W.destroy,y!==null&&fm(y,W.deps)){C.memoizedState=Sl(c,f,$,y);return}}ln.flags|=a,C.memoizedState=Sl(1|c,f,$,y)}function Qv(a,c){return Nu(8390656,8,a,c)}function ym(a,c){return wu(2048,8,a,c)}function Jv(a,c){return wu(4,2,a,c)}function e0(a,c){return wu(4,4,a,c)}function t0(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 n0(a,c,f){return f=f!=null?f.concat([a]):null,wu(4,4,t0.bind(null,c,a),f)}function bm(){}function s0(a,c){var f=ni();c=c===void 0?null:c;var y=f.memoizedState;return y!==null&&c!==null&&fm(c,y[1])?y[0]:(f.memoizedState=[a,c],a)}function i0(a,c){var f=ni();c=c===void 0?null:c;var y=f.memoizedState;return y!==null&&c!==null&&fm(c,y[1])?y[0]:(a=a(),f.memoizedState=[a,c],a)}function r0(a,c,f){return(xa&21)===0?(a.baseState&&(a.baseState=!1,Ss=!0),a.memoizedState=f):(pi(f,c)||(f=wr(),ln.lanes|=f,va|=f,a.baseState=!0),c)}function kC(a,c){var f=wt;wt=f!==0&&4>f?f:4,a(!0);var y=mm.transition;mm.transition={};try{a(!1),c()}finally{wt=f,mm.transition=y}}function a0(){return ni().memoizedState}function jC(a,c,f){var y=Or(a);if(f={lane:y,action:f,hasEagerState:!1,eagerState:null,next:null},o0(a))l0(c,f);else if(f=zv(a,c,f,y),f!==null){var C=ds();bi(f,a,y,C),c0(f,c,y)}}function NC(a,c,f){var y=Or(a),C={lane:y,action:f,hasEagerState:!1,eagerState:null,next:null};if(o0(a))l0(c,C);else{var $=a.alternate;if(a.lanes===0&&($===null||$.lanes===0)&&($=c.lastRenderedReducer,$!==null))try{var W=c.lastRenderedState,se=$(W,f);if(C.hasEagerState=!0,C.eagerState=se,pi(se,W)){var le=c.interleaved;le===null?(C.next=C,om(c)):(C.next=le.next,le.next=C),c.interleaved=C;return}}catch{}finally{}f=zv(a,c,C,y),f!==null&&(C=ds(),bi(f,a,y,C),c0(f,c,y))}}function o0(a){var c=a.alternate;return a===ln||c!==null&&c===ln}function l0(a,c){jl=ju=!0;var f=a.pending;f===null?c.next=c:(c.next=f.next,f.next=c),a.pending=c}function c0(a,c,f){if((f&4194240)!==0){var y=c.lanes;y&=a.pendingLanes,f|=y,c.lanes=f,Qs(a,f)}}var Su={readContext:ti,useCallback:ts,useContext:ts,useEffect:ts,useImperativeHandle:ts,useInsertionEffect:ts,useLayoutEffect:ts,useMemo:ts,useReducer:ts,useRef:ts,useState:ts,useDebugValue:ts,useDeferredValue:ts,useTransition:ts,useMutableSource:ts,useSyncExternalStore:ts,useId:ts,unstable_isNewReconciler:!1},wC={readContext:ti,useCallback:function(a,c){return zi().memoizedState=[a,c===void 0?null:c],a},useContext:ti,useEffect:Qv,useImperativeHandle:function(a,c,f){return f=f!=null?f.concat([a]):null,Nu(4194308,4,t0.bind(null,c,a),f)},useLayoutEffect:function(a,c){return Nu(4194308,4,a,c)},useInsertionEffect:function(a,c){return Nu(4,2,a,c)},useMemo:function(a,c){var f=zi();return c=c===void 0?null:c,a=a(),f.memoizedState=[a,c],a},useReducer:function(a,c,f){var y=zi();return c=f!==void 0?f(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=jC.bind(null,ln,a),[y.memoizedState,a]},useRef:function(a){var c=zi();return a={current:a},c.memoizedState=a},useState:Yv,useDebugValue:bm,useDeferredValue:function(a){return zi().memoizedState=a},useTransition:function(){var a=Yv(!1),c=a[0];return a=kC.bind(null,a[1]),zi().memoizedState=a,[c,a]},useMutableSource:function(){},useSyncExternalStore:function(a,c,f){var y=ln,C=zi();if(Jt){if(f===void 0)throw Error(s(407));f=f()}else{if(f=c(),zn===null)throw Error(s(349));(xa&30)!==0||Wv(y,c,f)}C.memoizedState=f;var $={value:f,getSnapshot:c};return C.queue=$,Qv(qv.bind(null,y,$,a),[a]),y.flags|=2048,Sl(9,Vv.bind(null,y,$,f,c),void 0,null),f},useId:function(){var a=zi(),c=zn.identifierPrefix;if(Jt){var f=ir,y=sr;f=(y&~(1<<32-Ft(y)-1)).toString(32)+f,c=":"+c+"R"+f,f=Nl++,0<f&&(c+="H"+f.toString(32)),c+=":"}else f=bC++,c=":"+c+"r"+f.toString(32)+":";return a.memoizedState=c},unstable_isNewReconciler:!1},SC={readContext:ti,useCallback:s0,useContext:ti,useEffect:ym,useImperativeHandle:n0,useInsertionEffect:Jv,useLayoutEffect:e0,useMemo:i0,useReducer:xm,useRef:Xv,useState:function(){return xm(wl)},useDebugValue:bm,useDeferredValue:function(a){var c=ni();return r0(c,Tn.memoizedState,a)},useTransition:function(){var a=xm(wl)[0],c=ni().memoizedState;return[a,c]},useMutableSource:Hv,useSyncExternalStore:Zv,useId:a0,unstable_isNewReconciler:!1},_C={readContext:ti,useCallback:s0,useContext:ti,useEffect:ym,useImperativeHandle:n0,useInsertionEffect:Jv,useLayoutEffect:e0,useMemo:i0,useReducer:vm,useRef:Xv,useState:function(){return vm(wl)},useDebugValue:bm,useDeferredValue:function(a){var c=ni();return Tn===null?c.memoizedState=a:r0(c,Tn.memoizedState,a)},useTransition:function(){var a=vm(wl)[0],c=ni().memoizedState;return[a,c]},useMutableSource:Hv,useSyncExternalStore:Zv,useId:a0,unstable_isNewReconciler:!1};function xi(a,c){if(a&&a.defaultProps){c=te({},c),a=a.defaultProps;for(var f in a)c[f]===void 0&&(c[f]=a[f]);return c}return c}function km(a,c,f,y){c=a.memoizedState,f=f(y,c),f=f==null?c:te({},c,f),a.memoizedState=f,a.lanes===0&&(a.updateQueue.baseState=f)}var _u={isMounted:function(a){return(a=a._reactInternals)?Qn(a)===a:!1},enqueueSetState:function(a,c,f){a=a._reactInternals;var y=ds(),C=Or(a),$=ar(y,C);$.payload=c,f!=null&&($.callback=f),c=Ir(a,$,C),c!==null&&(bi(c,a,C,y),vu(c,a,C))},enqueueReplaceState:function(a,c,f){a=a._reactInternals;var y=ds(),C=Or(a),$=ar(y,C);$.tag=1,$.payload=c,f!=null&&($.callback=f),c=Ir(a,$,C),c!==null&&(bi(c,a,C,y),vu(c,a,C))},enqueueForceUpdate:function(a,c){a=a._reactInternals;var f=ds(),y=Or(a),C=ar(f,y);C.tag=2,c!=null&&(C.callback=c),c=Ir(a,C,y),c!==null&&(bi(c,a,y,f),vu(c,a,y))}};function u0(a,c,f,y,C,$,W){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(y,$,W):c.prototype&&c.prototype.isPureReactComponent?!dl(f,y)||!dl(C,$):!0}function d0(a,c,f){var y=!1,C=Cr,$=c.contextType;return typeof $=="object"&&$!==null?$=ti($):(C=ws(c)?ha:es.current,y=c.contextTypes,$=(y=y!=null)?ao(a,C):Cr),c=new c(f,$),a.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=_u,a.stateNode=c,c._reactInternals=a,y&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=C,a.__reactInternalMemoizedMaskedChildContext=$),c}function h0(a,c,f,y){a=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(f,y),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(f,y),c.state!==a&&_u.enqueueReplaceState(c,c.state,null)}function jm(a,c,f,y){var C=a.stateNode;C.props=f,C.state=a.memoizedState,C.refs={},lm(a);var $=c.contextType;typeof $=="object"&&$!==null?C.context=ti($):($=ws(c)?ha:es.current,C.context=ao(a,$)),C.state=a.memoizedState,$=c.getDerivedStateFromProps,typeof $=="function"&&(km(a,c,$,f),C.state=a.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(c=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),c!==C.state&&_u.enqueueReplaceState(C,C.state,null),yu(a,f,C,y),C.state=a.memoizedState),typeof C.componentDidMount=="function"&&(a.flags|=4194308)}function po(a,c){try{var f="",y=c;do f+=Q(y),y=y.return;while(y);var C=f}catch($){C=`
39
+ Error generating stack: `+$.message+`
40
+ `+$.stack}return{value:a,source:c,stack:C,digest:null}}function Nm(a,c,f){return{value:a,source:null,stack:f??null,digest:c??null}}function wm(a,c){try{console.error(c.value)}catch(f){setTimeout(function(){throw f})}}var EC=typeof WeakMap=="function"?WeakMap:Map;function m0(a,c,f){f=ar(-1,f),f.tag=3,f.payload={element:null};var y=c.value;return f.callback=function(){Mu||(Mu=!0,Dm=y),wm(a,c)},f}function f0(a,c,f){f=ar(-1,f),f.tag=3;var y=a.type.getDerivedStateFromError;if(typeof y=="function"){var C=c.value;f.payload=function(){return y(C)},f.callback=function(){wm(a,c)}}var $=a.stateNode;return $!==null&&typeof $.componentDidCatch=="function"&&(f.callback=function(){wm(a,c),typeof y!="function"&&(Mr===null?Mr=new Set([this]):Mr.add(this));var W=c.stack;this.componentDidCatch(c.value,{componentStack:W!==null?W:""})}),f}function p0(a,c,f){var y=a.pingCache;if(y===null){y=a.pingCache=new EC;var C=new Set;y.set(c,C)}else C=y.get(c),C===void 0&&(C=new Set,y.set(c,C));C.has(f)||(C.add(f),a=UC.bind(null,a,c,f),c.then(a,a))}function g0(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 x0(a,c,f,y,C){return(a.mode&1)===0?(a===c?a.flags|=65536:(a.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(c=ar(-1,1),c.tag=2,Ir(f,c,1))),f.lanes|=1),a):(a.flags|=65536,a.lanes=C,a)}var CC=E.ReactCurrentOwner,Ss=!1;function us(a,c,f,y){c.child=a===null?Lv(c,null,f,y):uo(c,a.child,f,y)}function v0(a,c,f,y,C){f=f.render;var $=c.ref;return mo(c,C),y=pm(a,c,f,y,$,C),f=gm(),a!==null&&!Ss?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~C,or(a,c,C)):(Jt&&f&&Qh(c),c.flags|=1,us(a,c,y,C),c.child)}function y0(a,c,f,y,C){if(a===null){var $=f.type;return typeof $=="function"&&!Vm($)&&$.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0?(c.tag=15,c.type=$,b0(a,c,$,y,C)):(a=Du(f.type,null,y,c,c.mode,C),a.ref=c.ref,a.return=c,c.child=a)}if($=a.child,(a.lanes&C)===0){var W=$.memoizedProps;if(f=f.compare,f=f!==null?f:dl,f(W,y)&&a.ref===c.ref)return or(a,c,C)}return c.flags|=1,a=Lr($,y),a.ref=c.ref,a.return=c,c.child=a}function b0(a,c,f,y,C){if(a!==null){var $=a.memoizedProps;if(dl($,y)&&a.ref===c.ref)if(Ss=!1,c.pendingProps=y=$,(a.lanes&C)!==0)(a.flags&131072)!==0&&(Ss=!0);else return c.lanes=a.lanes,or(a,c,C)}return Sm(a,c,f,y,C)}function k0(a,c,f){var y=c.pendingProps,C=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(xo,Ds),Ds|=f;else{if((f&1073741824)===0)return a=$!==null?$.baseLanes|f:f,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:a,cachePool:null,transitions:null},c.updateQueue=null,Wt(xo,Ds),Ds|=a,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=$!==null?$.baseLanes:f,Wt(xo,Ds),Ds|=y}else $!==null?(y=$.baseLanes|f,c.memoizedState=null):y=f,Wt(xo,Ds),Ds|=y;return us(a,c,C,f),c.child}function j0(a,c){var f=c.ref;(a===null&&f!==null||a!==null&&a.ref!==f)&&(c.flags|=512,c.flags|=2097152)}function Sm(a,c,f,y,C){var $=ws(f)?ha:es.current;return $=ao(c,$),mo(c,C),f=pm(a,c,f,y,$,C),y=gm(),a!==null&&!Ss?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~C,or(a,c,C)):(Jt&&y&&Qh(c),c.flags|=1,us(a,c,f,C),c.child)}function N0(a,c,f,y,C){if(ws(f)){var $=!0;uu(c)}else $=!1;if(mo(c,C),c.stateNode===null)Cu(a,c),d0(c,f,y),jm(c,f,y,C),y=!0;else if(a===null){var W=c.stateNode,se=c.memoizedProps;W.props=se;var le=W.context,ye=f.contextType;typeof ye=="object"&&ye!==null?ye=ti(ye):(ye=ws(f)?ha:es.current,ye=ao(c,ye));var $e=f.getDerivedStateFromProps,Me=typeof $e=="function"||typeof W.getSnapshotBeforeUpdate=="function";Me||typeof W.UNSAFE_componentWillReceiveProps!="function"&&typeof W.componentWillReceiveProps!="function"||(se!==y||le!==ye)&&h0(c,W,y,ye),$r=!1;var Ae=c.memoizedState;W.state=Ae,yu(c,y,W,C),le=c.memoizedState,se!==y||Ae!==le||Ns.current||$r?(typeof $e=="function"&&(km(c,f,$e,y),le=c.memoizedState),(se=$r||u0(c,f,se,y,Ae,le,ye))?(Me||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=le),W.props=y,W.state=le,W.context=ye,y=se):(typeof W.componentDidMount=="function"&&(c.flags|=4194308),y=!1)}else{W=c.stateNode,Dv(a,c),se=c.memoizedProps,ye=c.type===c.elementType?se:xi(c.type,se),W.props=ye,Me=c.pendingProps,Ae=W.context,le=f.contextType,typeof le=="object"&&le!==null?le=ti(le):(le=ws(f)?ha:es.current,le=ao(c,le));var Ve=f.getDerivedStateFromProps;($e=typeof Ve=="function"||typeof W.getSnapshotBeforeUpdate=="function")||typeof W.UNSAFE_componentWillReceiveProps!="function"&&typeof W.componentWillReceiveProps!="function"||(se!==Me||Ae!==le)&&h0(c,W,y,le),$r=!1,Ae=c.memoizedState,W.state=Ae,yu(c,y,W,C);var Ke=c.memoizedState;se!==Me||Ae!==Ke||Ns.current||$r?(typeof Ve=="function"&&(km(c,f,Ve,y),Ke=c.memoizedState),(ye=$r||u0(c,f,ye,y,Ae,Ke,le)||!1)?($e||typeof W.UNSAFE_componentWillUpdate!="function"&&typeof W.componentWillUpdate!="function"||(typeof W.componentWillUpdate=="function"&&W.componentWillUpdate(y,Ke,le),typeof W.UNSAFE_componentWillUpdate=="function"&&W.UNSAFE_componentWillUpdate(y,Ke,le)),typeof W.componentDidUpdate=="function"&&(c.flags|=4),typeof W.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof W.componentDidUpdate!="function"||se===a.memoizedProps&&Ae===a.memoizedState||(c.flags|=4),typeof W.getSnapshotBeforeUpdate!="function"||se===a.memoizedProps&&Ae===a.memoizedState||(c.flags|=1024),c.memoizedProps=y,c.memoizedState=Ke),W.props=y,W.state=Ke,W.context=le,y=ye):(typeof W.componentDidUpdate!="function"||se===a.memoizedProps&&Ae===a.memoizedState||(c.flags|=4),typeof W.getSnapshotBeforeUpdate!="function"||se===a.memoizedProps&&Ae===a.memoizedState||(c.flags|=1024),y=!1)}return _m(a,c,f,y,$,C)}function _m(a,c,f,y,C,$){j0(a,c);var W=(c.flags&128)!==0;if(!y&&!W)return C&&Cv(c,f,!1),or(a,c,$);y=c.stateNode,CC.current=c;var se=W&&typeof f.getDerivedStateFromError!="function"?null:y.render();return c.flags|=1,a!==null&&W?(c.child=uo(c,a.child,null,$),c.child=uo(c,null,se,$)):us(a,c,se,$),c.memoizedState=y.state,C&&Cv(c,f,!0),c.child}function w0(a){var c=a.stateNode;c.pendingContext?_v(a,c.pendingContext,c.pendingContext!==c.context):c.context&&_v(a,c.context,!1),cm(a,c.containerInfo)}function S0(a,c,f,y,C){return co(),nm(C),c.flags|=256,us(a,c,f,y),c.child}var Em={dehydrated:null,treeContext:null,retryLane:0};function Cm(a){return{baseLanes:a,cachePool:null,transitions:null}}function _0(a,c,f){var y=c.pendingProps,C=on.current,$=!1,W=(c.flags&128)!==0,se;if((se=W)||(se=a!==null&&a.memoizedState===null?!1:(C&2)!==0),se?($=!0,c.flags&=-129):(a===null||a.memoizedState!==null)&&(C|=1),Wt(on,C&1),a===null)return tm(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):$=Fu(W,y,0,null),a=ja(a,y,f,null),$.return=c,a.return=c,$.sibling=a,c.child=$,c.child.memoizedState=Cm(f),c.memoizedState=Em,a):Am(c,W));if(C=a.memoizedState,C!==null&&(se=C.dehydrated,se!==null))return AC(a,c,W,y,se,C,f);if($){$=y.fallback,W=c.mode,C=a.child,se=C.sibling;var le={mode:"hidden",children:y.children};return(W&1)===0&&c.child!==C?(y=c.child,y.childLanes=0,y.pendingProps=le,c.deletions=null):(y=Lr(C,le),y.subtreeFlags=C.subtreeFlags&14680064),se!==null?$=Lr(se,$):($=ja($,W,f,null),$.flags|=2),$.return=c,y.return=c,y.sibling=$,c.child=y,y=$,$=c.child,W=a.child.memoizedState,W=W===null?Cm(f):{baseLanes:W.baseLanes|f,cachePool:null,transitions:W.transitions},$.memoizedState=W,$.childLanes=a.childLanes&~f,c.memoizedState=Em,y}return $=a.child,a=$.sibling,y=Lr($,{mode:"visible",children:y.children}),(c.mode&1)===0&&(y.lanes=f),y.return=c,y.sibling=null,a!==null&&(f=c.deletions,f===null?(c.deletions=[a],c.flags|=16):f.push(a)),c.child=y,c.memoizedState=null,y}function Am(a,c){return c=Fu({mode:"visible",children:c},a.mode,0,null),c.return=a,a.child=c}function Eu(a,c,f,y){return y!==null&&nm(y),uo(c,a.child,null,f),a=Am(c,c.pendingProps.children),a.flags|=2,c.memoizedState=null,a}function AC(a,c,f,y,C,$,W){if(f)return c.flags&256?(c.flags&=-257,y=Nm(Error(s(422))),Eu(a,c,W,y)):c.memoizedState!==null?(c.child=a.child,c.flags|=128,null):($=y.fallback,C=c.mode,y=Fu({mode:"visible",children:y.children},C,0,null),$=ja($,C,W,null),$.flags|=2,y.return=c,$.return=c,y.sibling=$,c.child=y,(c.mode&1)!==0&&uo(c,a.child,null,W),c.child.memoizedState=Cm(W),c.memoizedState=Em,$);if((c.mode&1)===0)return Eu(a,c,W,null);if(C.data==="$!"){if(y=C.nextSibling&&C.nextSibling.dataset,y)var se=y.dgst;return y=se,$=Error(s(419)),y=Nm($,y,void 0),Eu(a,c,W,y)}if(se=(W&a.childLanes)!==0,Ss||se){if(y=zn,y!==null){switch(W&-W){case 4:C=2;break;case 16:C=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:C=32;break;case 536870912:C=268435456;break;default:C=0}C=(C&(y.suspendedLanes|W))!==0?0:C,C!==0&&C!==$.retryLane&&($.retryLane=C,rr(a,C),bi(y,a,C,-1))}return Wm(),y=Nm(Error(s(421))),Eu(a,c,W,y)}return C.data==="$?"?(c.flags|=128,c.child=a.child,c=BC.bind(null,a),C._reactRetry=c,null):(a=$.treeContext,zs=_r(C.nextSibling),Ls=c,Jt=!0,gi=null,a!==null&&(Js[ei++]=sr,Js[ei++]=ir,Js[ei++]=ma,sr=a.id,ir=a.overflow,ma=c),c=Am(c,y.children),c.flags|=4096,c)}function E0(a,c,f){a.lanes|=c;var y=a.alternate;y!==null&&(y.lanes|=c),am(a.return,c,f)}function $m(a,c,f,y,C){var $=a.memoizedState;$===null?a.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:y,tail:f,tailMode:C}:($.isBackwards=c,$.rendering=null,$.renderingStartTime=0,$.last=y,$.tail=f,$.tailMode=C)}function C0(a,c,f){var y=c.pendingProps,C=y.revealOrder,$=y.tail;if(us(a,c,y.children,f),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&&E0(a,f,c);else if(a.tag===19)E0(a,f,c);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===c)break e;for(;a.sibling===null;){if(a.return===null||a.return===c)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}y&=1}if(Wt(on,y),(c.mode&1)===0)c.memoizedState=null;else switch(C){case"forwards":for(f=c.child,C=null;f!==null;)a=f.alternate,a!==null&&bu(a)===null&&(C=f),f=f.sibling;f=C,f===null?(C=c.child,c.child=null):(C=f.sibling,f.sibling=null),$m(c,!1,C,f,$);break;case"backwards":for(f=null,C=c.child,c.child=null;C!==null;){if(a=C.alternate,a!==null&&bu(a)===null){c.child=C;break}a=C.sibling,C.sibling=f,f=C,C=a}$m(c,!0,f,null,$);break;case"together":$m(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function Cu(a,c){(c.mode&1)===0&&a!==null&&(a.alternate=null,c.alternate=null,c.flags|=2)}function or(a,c,f){if(a!==null&&(c.dependencies=a.dependencies),va|=c.lanes,(f&c.childLanes)===0)return null;if(a!==null&&c.child!==a.child)throw Error(s(153));if(c.child!==null){for(a=c.child,f=Lr(a,a.pendingProps),c.child=f,f.return=c;a.sibling!==null;)a=a.sibling,f=f.sibling=Lr(a,a.pendingProps),f.return=c;f.sibling=null}return c.child}function $C(a,c,f){switch(c.tag){case 3:w0(c),co();break;case 5:Bv(c);break;case 1:ws(c.type)&&uu(c);break;case 4:cm(c,c.stateNode.containerInfo);break;case 10:var y=c.type._context,C=c.memoizedProps.value;Wt(gu,y._currentValue),y._currentValue=C;break;case 13:if(y=c.memoizedState,y!==null)return y.dehydrated!==null?(Wt(on,on.current&1),c.flags|=128,null):(f&c.child.childLanes)!==0?_0(a,c,f):(Wt(on,on.current&1),a=or(a,c,f),a!==null?a.sibling:null);Wt(on,on.current&1);break;case 19:if(y=(f&c.childLanes)!==0,(a.flags&128)!==0){if(y)return C0(a,c,f);c.flags|=128}if(C=c.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),Wt(on,on.current),y)break;return null;case 22:case 23:return c.lanes=0,k0(a,c,f)}return or(a,c,f)}var A0,Im,$0,I0;A0=function(a,c){for(var f=c.child;f!==null;){if(f.tag===5||f.tag===6)a.appendChild(f.stateNode);else if(f.tag!==4&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===c)break;for(;f.sibling===null;){if(f.return===null||f.return===c)return;f=f.return}f.sibling.return=f.return,f=f.sibling}},Im=function(){},$0=function(a,c,f,y){var C=a.memoizedProps;if(C!==y){a=c.stateNode,ga(Li.current);var $=null;switch(f){case"input":C=be(a,C),y=be(a,y),$=[];break;case"select":C=te({},C,{value:void 0}),y=te({},y,{value:void 0}),$=[];break;case"textarea":C=En(a,C),y=En(a,y),$=[];break;default:typeof C.onClick!="function"&&typeof y.onClick=="function"&&(a.onclick=ou)}Cn(f,y);var W;f=null;for(ye in C)if(!y.hasOwnProperty(ye)&&C.hasOwnProperty(ye)&&C[ye]!=null)if(ye==="style"){var se=C[ye];for(W in se)se.hasOwnProperty(W)&&(f||(f={}),f[W]="")}else ye!=="dangerouslySetInnerHTML"&&ye!=="children"&&ye!=="suppressContentEditableWarning"&&ye!=="suppressHydrationWarning"&&ye!=="autoFocus"&&(r.hasOwnProperty(ye)?$||($=[]):($=$||[]).push(ye,null));for(ye in y){var le=y[ye];if(se=C!=null?C[ye]:void 0,y.hasOwnProperty(ye)&&le!==se&&(le!=null||se!=null))if(ye==="style")if(se){for(W in se)!se.hasOwnProperty(W)||le&&le.hasOwnProperty(W)||(f||(f={}),f[W]="");for(W in le)le.hasOwnProperty(W)&&se[W]!==le[W]&&(f||(f={}),f[W]=le[W])}else f||($||($=[]),$.push(ye,f)),f=le;else ye==="dangerouslySetInnerHTML"?(le=le?le.__html:void 0,se=se?se.__html:void 0,le!=null&&se!==le&&($=$||[]).push(ye,le)):ye==="children"?typeof le!="string"&&typeof le!="number"||($=$||[]).push(ye,""+le):ye!=="suppressContentEditableWarning"&&ye!=="suppressHydrationWarning"&&(r.hasOwnProperty(ye)?(le!=null&&ye==="onScroll"&&qt("scroll",a),$||se===le||($=[])):($=$||[]).push(ye,le))}f&&($=$||[]).push("style",f);var ye=$;(c.updateQueue=ye)&&(c.flags|=4)}},I0=function(a,c,f,y){f!==y&&(c.flags|=4)};function _l(a,c){if(!Jt)switch(a.tailMode){case"hidden":c=a.tail;for(var f=null;c!==null;)c.alternate!==null&&(f=c),c=c.sibling;f===null?a.tail=null:f.sibling=null;break;case"collapsed":f=a.tail;for(var y=null;f!==null;)f.alternate!==null&&(y=f),f=f.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,f=0,y=0;if(c)for(var C=a.child;C!==null;)f|=C.lanes|C.childLanes,y|=C.subtreeFlags&14680064,y|=C.flags&14680064,C.return=a,C=C.sibling;else for(C=a.child;C!==null;)f|=C.lanes|C.childLanes,y|=C.subtreeFlags,y|=C.flags,C.return=a,C=C.sibling;return a.subtreeFlags|=y,a.childLanes=f,c}function IC(a,c,f){var y=c.pendingProps;switch(Jh(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ns(c),null;case 1:return ws(c.type)&&cu(),ns(c),null;case 3:return y=c.stateNode,fo(),Gt(Ns),Gt(es),hm(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(a===null||a.child===null)&&(fu(c)?c.flags|=4:a===null||a.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,gi!==null&&(Bm(gi),gi=null))),Im(a,c),ns(c),null;case 5:um(c);var C=ga(kl.current);if(f=c.type,a!==null&&c.stateNode!=null)$0(a,c,f,y,C),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=ga(Li.current),fu(c)){y=c.stateNode,f=c.type;var $=c.memoizedProps;switch(y[Pi]=c,y[gl]=$,a=(c.mode&1)!==0,f){case"dialog":qt("cancel",y),qt("close",y);break;case"iframe":case"object":case"embed":qt("load",y);break;case"video":case"audio":for(C=0;C<ml.length;C++)qt(ml[C],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":De(y,$),qt("invalid",y);break;case"select":y._wrapperState={wasMultiple:!!$.multiple},qt("invalid",y);break;case"textarea":rt(y,$),qt("invalid",y)}Cn(f,$),C=null;for(var W in $)if($.hasOwnProperty(W)){var se=$[W];W==="children"?typeof se=="string"?y.textContent!==se&&($.suppressHydrationWarning!==!0&&au(y.textContent,se,a),C=["children",se]):typeof se=="number"&&y.textContent!==""+se&&($.suppressHydrationWarning!==!0&&au(y.textContent,se,a),C=["children",""+se]):r.hasOwnProperty(W)&&se!=null&&W==="onScroll"&&qt("scroll",y)}switch(f){case"input":Ue(y),Fe(y,$,!0);break;case"textarea":Ue(y),rn(y);break;case"select":case"option":break;default:typeof $.onClick=="function"&&(y.onclick=ou)}y=C,c.updateQueue=y,y!==null&&(c.flags|=4)}else{W=C.nodeType===9?C:C.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=Zt(f)),a==="http://www.w3.org/1999/xhtml"?f==="script"?(a=W.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof y.is=="string"?a=W.createElement(f,{is:y.is}):(a=W.createElement(f),f==="select"&&(W=a,y.multiple?W.multiple=!0:y.size&&(W.size=y.size))):a=W.createElementNS(a,f),a[Pi]=c,a[gl]=y,A0(a,c,!1,!1),c.stateNode=a;e:{switch(W=as(f,y),f){case"dialog":qt("cancel",a),qt("close",a),C=y;break;case"iframe":case"object":case"embed":qt("load",a),C=y;break;case"video":case"audio":for(C=0;C<ml.length;C++)qt(ml[C],a);C=y;break;case"source":qt("error",a),C=y;break;case"img":case"image":case"link":qt("error",a),qt("load",a),C=y;break;case"details":qt("toggle",a),C=y;break;case"input":De(a,y),C=be(a,y),qt("invalid",a);break;case"option":C=y;break;case"select":a._wrapperState={wasMultiple:!!y.multiple},C=te({},y,{value:void 0}),qt("invalid",a);break;case"textarea":rt(a,y),C=En(a,y),qt("invalid",a);break;default:C=y}Cn(f,C),se=C;for($ in se)if(se.hasOwnProperty($)){var le=se[$];$==="style"?rs(a,le):$==="dangerouslySetInnerHTML"?(le=le?le.__html:void 0,le!=null&&Rn(a,le)):$==="children"?typeof le=="string"?(f!=="textarea"||le!=="")&&mn(a,le):typeof le=="number"&&mn(a,""+le):$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&$!=="autoFocus"&&(r.hasOwnProperty($)?le!=null&&$==="onScroll"&&qt("scroll",a):le!=null&&_(a,$,le,W))}switch(f){case"input":Ue(a),Fe(a,y,!1);break;case"textarea":Ue(a),rn(a);break;case"option":y.value!=null&&a.setAttribute("value",""+ne(y.value));break;case"select":a.multiple=!!y.multiple,$=y.value,$!=null?Rt(a,!!y.multiple,$,!1):y.defaultValue!=null&&Rt(a,!!y.multiple,y.defaultValue,!0);break;default:typeof C.onClick=="function"&&(a.onclick=ou)}switch(f){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)I0(a,c,a.memoizedProps,y);else{if(typeof y!="string"&&c.stateNode===null)throw Error(s(166));if(f=ga(kl.current),ga(Li.current),fu(c)){if(y=c.stateNode,f=c.memoizedProps,y[Pi]=c,($=y.nodeValue!==f)&&(a=Ls,a!==null))switch(a.tag){case 3:au(y.nodeValue,f,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&au(y.nodeValue,f,(a.mode&1)!==0)}$&&(c.flags|=4)}else y=(f.nodeType===9?f:f.ownerDocument).createTextNode(y),y[Pi]=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)Rv(),co(),c.flags|=98560,$=!1;else if($=fu(c),y!==null&&y.dehydrated!==null){if(a===null){if(!$)throw Error(s(318));if($=c.memoizedState,$=$!==null?$.dehydrated:null,!$)throw Error(s(317));$[Pi]=c}else co(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;ns(c),$=!1}else gi!==null&&(Bm(gi),gi=null),$=!0;if(!$)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=f,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):Wm())),c.updateQueue!==null&&(c.flags|=4),ns(c),null);case 4:return fo(),Im(a,c),a===null&&fl(c.stateNode.containerInfo),ns(c),null;case 10:return rm(c.type._context),ns(c),null;case 17:return ws(c.type)&&cu(),ns(c),null;case 19:if(Gt(on),$=c.memoizedState,$===null)return ns(c),null;if(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=bu(a),W!==null){for(c.flags|=128,_l($,!1),y=W.updateQueue,y!==null&&(c.updateQueue=y,c.flags|=4),c.subtreeFlags=0,y=f,f=c.child;f!==null;)$=f,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}),f=f.sibling;return Wt(on,on.current&1|2),c.child}a=a.sibling}$.tail!==null&&Dt()>vo&&(c.flags|=128,y=!0,_l($,!1),c.lanes=4194304)}else{if(!y)if(a=bu(W),a!==null){if(c.flags|=128,y=!0,f=a.updateQueue,f!==null&&(c.updateQueue=f,c.flags|=4),_l($,!0),$.tail===null&&$.tailMode==="hidden"&&!W.alternate&&!Jt)return ns(c),null}else 2*Dt()-$.renderingStartTime>vo&&f!==1073741824&&(c.flags|=128,y=!0,_l($,!1),c.lanes=4194304);$.isBackwards?(W.sibling=c.child,c.child=W):(f=$.last,f!==null?f.sibling=W:c.child=W,$.last=W)}return $.tail!==null?(c=$.tail,$.rendering=c,$.tail=c.sibling,$.renderingStartTime=Dt(),c.sibling=null,f=on.current,Wt(on,y?f&1|2:f&1),c):(ns(c),null);case 22:case 23:return Zm(),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 TC(a,c){switch(Jh(c),c.tag){case 1:return ws(c.type)&&cu(),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return fo(),Gt(Ns),Gt(es),hm(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 5:return um(c),null;case 13:if(Gt(on),a=c.memoizedState,a!==null&&a.dehydrated!==null){if(c.alternate===null)throw Error(s(340));co()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 19:return Gt(on),null;case 4:return fo(),null;case 10:return rm(c.type._context),null;case 22:case 23:return Zm(),null;case 24:return null;default:return null}}var Au=!1,ss=!1,MC=typeof WeakSet=="function"?WeakSet:Set,Ge=null;function go(a,c){var f=a.ref;if(f!==null)if(typeof f=="function")try{f(null)}catch(y){hn(a,c,y)}else f.current=null}function Tm(a,c,f){try{f()}catch(y){hn(a,c,y)}}var T0=!1;function RC(a,c){if(Zh=nt,a=uv(),Ph(a)){if("selectionStart"in a)var f={start:a.selectionStart,end:a.selectionEnd};else e:{f=(f=a.ownerDocument)&&f.defaultView||window;var y=f.getSelection&&f.getSelection();if(y&&y.rangeCount!==0){f=y.anchorNode;var C=y.anchorOffset,$=y.focusNode;y=y.focusOffset;try{f.nodeType,$.nodeType}catch{f=null;break e}var W=0,se=-1,le=-1,ye=0,$e=0,Me=a,Ae=null;t:for(;;){for(var Ve;Me!==f||C!==0&&Me.nodeType!==3||(se=W+C),Me!==$||y!==0&&Me.nodeType!==3||(le=W+y),Me.nodeType===3&&(W+=Me.nodeValue.length),(Ve=Me.firstChild)!==null;)Ae=Me,Me=Ve;for(;;){if(Me===a)break t;if(Ae===f&&++ye===C&&(se=W),Ae===$&&++$e===y&&(le=W),(Ve=Me.nextSibling)!==null)break;Me=Ae,Ae=Me.parentNode}Me=Ve}f=se===-1||le===-1?null:{start:se,end:le}}else f=null}f=f||{start:0,end:0}}else f=null;for(Wh={focusedElem:a,selectionRange:f},nt=!1,Ge=c;Ge!==null;)if(c=Ge,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,Ge=a;else for(;Ge!==null;){c=Ge;try{var Ke=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(Ke!==null){var Qe=Ke.memoizedProps,gn=Ke.memoizedState,ge=c.stateNode,he=ge.getSnapshotBeforeUpdate(c.elementType===c.type?Qe:xi(c.type,Qe),gn);ge.__reactInternalSnapshotBeforeUpdate=he}break;case 3:var xe=c.stateNode.containerInfo;xe.nodeType===1?xe.textContent="":xe.nodeType===9&&xe.documentElement&&xe.removeChild(xe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(s(163))}}catch(Le){hn(c,c.return,Le)}if(a=c.sibling,a!==null){a.return=c.return,Ge=a;break}Ge=c.return}return Ke=T0,T0=!1,Ke}function El(a,c,f){var y=c.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var C=y=y.next;do{if((C.tag&a)===a){var $=C.destroy;C.destroy=void 0,$!==void 0&&Tm(c,f,$)}C=C.next}while(C!==y)}}function $u(a,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var f=c=c.next;do{if((f.tag&a)===a){var y=f.create;f.destroy=y()}f=f.next}while(f!==c)}}function Mm(a){var c=a.ref;if(c!==null){var f=a.stateNode;switch(a.tag){case 5:a=f;break;default:a=f}typeof c=="function"?c(a):c.current=a}}function M0(a){var c=a.alternate;c!==null&&(a.alternate=null,M0(c)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(c=a.stateNode,c!==null&&(delete c[Pi],delete c[gl],delete c[Kh],delete c[gC],delete c[xC])),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 R0(a){return a.tag===5||a.tag===3||a.tag===4}function O0(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||R0(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 Rm(a,c,f){var y=a.tag;if(y===5||y===6)a=a.stateNode,c?f.nodeType===8?f.parentNode.insertBefore(a,c):f.insertBefore(a,c):(f.nodeType===8?(c=f.parentNode,c.insertBefore(a,f)):(c=f,c.appendChild(a)),f=f._reactRootContainer,f!=null||c.onclick!==null||(c.onclick=ou));else if(y!==4&&(a=a.child,a!==null))for(Rm(a,c,f),a=a.sibling;a!==null;)Rm(a,c,f),a=a.sibling}function Om(a,c,f){var y=a.tag;if(y===5||y===6)a=a.stateNode,c?f.insertBefore(a,c):f.appendChild(a);else if(y!==4&&(a=a.child,a!==null))for(Om(a,c,f),a=a.sibling;a!==null;)Om(a,c,f),a=a.sibling}var Wn=null,vi=!1;function Tr(a,c,f){for(f=f.child;f!==null;)P0(a,c,f),f=f.sibling}function P0(a,c,f){if(ft&&typeof ft.onCommitFiberUnmount=="function")try{ft.onCommitFiberUnmount(ht,f)}catch{}switch(f.tag){case 5:ss||go(f,c);case 6:var y=Wn,C=vi;Wn=null,Tr(a,c,f),Wn=y,vi=C,Wn!==null&&(vi?(a=Wn,f=f.stateNode,a.nodeType===8?a.parentNode.removeChild(f):a.removeChild(f)):Wn.removeChild(f.stateNode));break;case 18:Wn!==null&&(vi?(a=Wn,f=f.stateNode,a.nodeType===8?Gh(a.parentNode,f):a.nodeType===1&&Gh(a,f),Ne(a)):Gh(Wn,f.stateNode));break;case 4:y=Wn,C=vi,Wn=f.stateNode.containerInfo,vi=!0,Tr(a,c,f),Wn=y,vi=C;break;case 0:case 11:case 14:case 15:if(!ss&&(y=f.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){C=y=y.next;do{var $=C,W=$.destroy;$=$.tag,W!==void 0&&(($&2)!==0||($&4)!==0)&&Tm(f,c,W),C=C.next}while(C!==y)}Tr(a,c,f);break;case 1:if(!ss&&(go(f,c),y=f.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=f.memoizedProps,y.state=f.memoizedState,y.componentWillUnmount()}catch(se){hn(f,c,se)}Tr(a,c,f);break;case 21:Tr(a,c,f);break;case 22:f.mode&1?(ss=(y=ss)||f.memoizedState!==null,Tr(a,c,f),ss=y):Tr(a,c,f);break;default:Tr(a,c,f)}}function L0(a){var c=a.updateQueue;if(c!==null){a.updateQueue=null;var f=a.stateNode;f===null&&(f=a.stateNode=new MC),c.forEach(function(y){var C=HC.bind(null,a,y);f.has(y)||(f.add(y),y.then(C,C))})}}function yi(a,c){var f=c.deletions;if(f!==null)for(var y=0;y<f.length;y++){var C=f[y];try{var $=a,W=c,se=W;e:for(;se!==null;){switch(se.tag){case 5:Wn=se.stateNode,vi=!1;break e;case 3:Wn=se.stateNode.containerInfo,vi=!0;break e;case 4:Wn=se.stateNode.containerInfo,vi=!0;break e}se=se.return}if(Wn===null)throw Error(s(160));P0($,W,C),Wn=null,vi=!1;var le=C.alternate;le!==null&&(le.return=null),C.return=null}catch(ye){hn(C,c,ye)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)z0(c,a),c=c.sibling}function z0(a,c){var f=a.alternate,y=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(yi(c,a),Di(a),y&4){try{El(3,a,a.return),$u(3,a)}catch(Qe){hn(a,a.return,Qe)}try{El(5,a,a.return)}catch(Qe){hn(a,a.return,Qe)}}break;case 1:yi(c,a),Di(a),y&512&&f!==null&&go(f,f.return);break;case 5:if(yi(c,a),Di(a),y&512&&f!==null&&go(f,f.return),a.flags&32){var C=a.stateNode;try{mn(C,"")}catch(Qe){hn(a,a.return,Qe)}}if(y&4&&(C=a.stateNode,C!=null)){var $=a.memoizedProps,W=f!==null?f.memoizedProps:$,se=a.type,le=a.updateQueue;if(a.updateQueue=null,le!==null)try{se==="input"&&$.type==="radio"&&$.name!=null&&Re(C,$),as(se,W);var ye=as(se,$);for(W=0;W<le.length;W+=2){var $e=le[W],Me=le[W+1];$e==="style"?rs(C,Me):$e==="dangerouslySetInnerHTML"?Rn(C,Me):$e==="children"?mn(C,Me):_(C,$e,Me,ye)}switch(se){case"input":ae(C,$);break;case"textarea":Pt(C,$);break;case"select":var Ae=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!$.multiple;var Ve=$.value;Ve!=null?Rt(C,!!$.multiple,Ve,!1):Ae!==!!$.multiple&&($.defaultValue!=null?Rt(C,!!$.multiple,$.defaultValue,!0):Rt(C,!!$.multiple,$.multiple?[]:"",!1))}C[gl]=$}catch(Qe){hn(a,a.return,Qe)}}break;case 6:if(yi(c,a),Di(a),y&4){if(a.stateNode===null)throw Error(s(162));C=a.stateNode,$=a.memoizedProps;try{C.nodeValue=$}catch(Qe){hn(a,a.return,Qe)}}break;case 3:if(yi(c,a),Di(a),y&4&&f!==null&&f.memoizedState.isDehydrated)try{Ne(c.containerInfo)}catch(Qe){hn(a,a.return,Qe)}break;case 4:yi(c,a),Di(a);break;case 13:yi(c,a),Di(a),C=a.child,C.flags&8192&&($=C.memoizedState!==null,C.stateNode.isHidden=$,!$||C.alternate!==null&&C.alternate.memoizedState!==null||(zm=Dt())),y&4&&L0(a);break;case 22:if($e=f!==null&&f.memoizedState!==null,a.mode&1?(ss=(ye=ss)||$e,yi(c,a),ss=ye):yi(c,a),Di(a),y&8192){if(ye=a.memoizedState!==null,(a.stateNode.isHidden=ye)&&!$e&&(a.mode&1)!==0)for(Ge=a,$e=a.child;$e!==null;){for(Me=Ge=$e;Ge!==null;){switch(Ae=Ge,Ve=Ae.child,Ae.tag){case 0:case 11:case 14:case 15:El(4,Ae,Ae.return);break;case 1:go(Ae,Ae.return);var Ke=Ae.stateNode;if(typeof Ke.componentWillUnmount=="function"){y=Ae,f=Ae.return;try{c=y,Ke.props=c.memoizedProps,Ke.state=c.memoizedState,Ke.componentWillUnmount()}catch(Qe){hn(y,f,Qe)}}break;case 5:go(Ae,Ae.return);break;case 22:if(Ae.memoizedState!==null){U0(Me);continue}}Ve!==null?(Ve.return=Ae,Ge=Ve):U0(Me)}$e=$e.sibling}e:for($e=null,Me=a;;){if(Me.tag===5){if($e===null){$e=Me;try{C=Me.stateNode,ye?($=C.style,typeof $.setProperty=="function"?$.setProperty("display","none","important"):$.display="none"):(se=Me.stateNode,le=Me.memoizedProps.style,W=le!=null&&le.hasOwnProperty("display")?le.display:null,se.style.display=ps("display",W))}catch(Qe){hn(a,a.return,Qe)}}}else if(Me.tag===6){if($e===null)try{Me.stateNode.nodeValue=ye?"":Me.memoizedProps}catch(Qe){hn(a,a.return,Qe)}}else if((Me.tag!==22&&Me.tag!==23||Me.memoizedState===null||Me===a)&&Me.child!==null){Me.child.return=Me,Me=Me.child;continue}if(Me===a)break e;for(;Me.sibling===null;){if(Me.return===null||Me.return===a)break e;$e===Me&&($e=null),Me=Me.return}$e===Me&&($e=null),Me.sibling.return=Me.return,Me=Me.sibling}}break;case 19:yi(c,a),Di(a),y&4&&L0(a);break;case 21:break;default:yi(c,a),Di(a)}}function Di(a){var c=a.flags;if(c&2){try{e:{for(var f=a.return;f!==null;){if(R0(f)){var y=f;break e}f=f.return}throw Error(s(160))}switch(y.tag){case 5:var C=y.stateNode;y.flags&32&&(mn(C,""),y.flags&=-33);var $=O0(a);Om(a,$,C);break;case 3:case 4:var W=y.stateNode.containerInfo,se=O0(a);Rm(a,se,W);break;default:throw Error(s(161))}}catch(le){hn(a,a.return,le)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function OC(a,c,f){Ge=a,D0(a)}function D0(a,c,f){for(var y=(a.mode&1)!==0;Ge!==null;){var C=Ge,$=C.child;if(C.tag===22&&y){var W=C.memoizedState!==null||Au;if(!W){var se=C.alternate,le=se!==null&&se.memoizedState!==null||ss;se=Au;var ye=ss;if(Au=W,(ss=le)&&!ye)for(Ge=C;Ge!==null;)W=Ge,le=W.child,W.tag===22&&W.memoizedState!==null?B0(C):le!==null?(le.return=W,Ge=le):B0(C);for(;$!==null;)Ge=$,D0($),$=$.sibling;Ge=C,Au=se,ss=ye}F0(a)}else(C.subtreeFlags&8772)!==0&&$!==null?($.return=C,Ge=$):F0(a)}}function F0(a){for(;Ge!==null;){var c=Ge;if((c.flags&8772)!==0){var f=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:ss||$u(5,c);break;case 1:var y=c.stateNode;if(c.flags&4&&!ss)if(f===null)y.componentDidMount();else{var C=c.elementType===c.type?f.memoizedProps:xi(c.type,f.memoizedProps);y.componentDidUpdate(C,f.memoizedState,y.__reactInternalSnapshotBeforeUpdate)}var $=c.updateQueue;$!==null&&Uv(c,$,y);break;case 3:var W=c.updateQueue;if(W!==null){if(f=null,c.child!==null)switch(c.child.tag){case 5:f=c.child.stateNode;break;case 1:f=c.child.stateNode}Uv(c,W,f)}break;case 5:var se=c.stateNode;if(f===null&&c.flags&4){f=se;var le=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":le.autoFocus&&f.focus();break;case"img":le.src&&(f.src=le.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var ye=c.alternate;if(ye!==null){var $e=ye.memoizedState;if($e!==null){var Me=$e.dehydrated;Me!==null&&Ne(Me)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(s(163))}ss||c.flags&512&&Mm(c)}catch(Ae){hn(c,c.return,Ae)}}if(c===a){Ge=null;break}if(f=c.sibling,f!==null){f.return=c.return,Ge=f;break}Ge=c.return}}function U0(a){for(;Ge!==null;){var c=Ge;if(c===a){Ge=null;break}var f=c.sibling;if(f!==null){f.return=c.return,Ge=f;break}Ge=c.return}}function B0(a){for(;Ge!==null;){var c=Ge;try{switch(c.tag){case 0:case 11:case 15:var f=c.return;try{$u(4,c)}catch(le){hn(c,f,le)}break;case 1:var y=c.stateNode;if(typeof y.componentDidMount=="function"){var C=c.return;try{y.componentDidMount()}catch(le){hn(c,C,le)}}var $=c.return;try{Mm(c)}catch(le){hn(c,$,le)}break;case 5:var W=c.return;try{Mm(c)}catch(le){hn(c,W,le)}}}catch(le){hn(c,c.return,le)}if(c===a){Ge=null;break}var se=c.sibling;if(se!==null){se.return=c.return,Ge=se;break}Ge=c.return}}var PC=Math.ceil,Iu=E.ReactCurrentDispatcher,Pm=E.ReactCurrentOwner,si=E.ReactCurrentBatchConfig,Et=0,zn=null,kn=null,Vn=0,Ds=0,xo=Er(0),Mn=0,Cl=null,va=0,Tu=0,Lm=0,Al=null,_s=null,zm=0,vo=1/0,lr=null,Mu=!1,Dm=null,Mr=null,Ru=!1,Rr=null,Ou=0,$l=0,Fm=null,Pu=-1,Lu=0;function ds(){return(Et&6)!==0?Dt():Pu!==-1?Pu:Pu=Dt()}function Or(a){return(a.mode&1)===0?1:(Et&2)!==0&&Vn!==0?Vn&-Vn:yC.transition!==null?(Lu===0&&(Lu=wr()),Lu):(a=wt,a!==0||(a=window.event,a=a===void 0?16:er(a.type)),a)}function bi(a,c,f,y){if(50<$l)throw $l=0,Fm=null,Error(s(185));bs(a,f,y),((Et&2)===0||a!==zn)&&(a===zn&&((Et&2)===0&&(Tu|=f),Mn===4&&Pr(a,Vn)),Es(a,y),f===1&&Et===0&&(c.mode&1)===0&&(vo=Dt()+500,du&&Ar()))}function Es(a,c){var f=a.callbackNode;Nr(a,c);var y=ys(a,a===zn?Vn:0);if(y===0)f!==null&&os(f),a.callbackNode=null,a.callbackPriority=0;else if(c=y&-y,a.callbackPriority!==c){if(f!=null&&os(f),c===1)a.tag===0?vC(Z0.bind(null,a)):Av(Z0.bind(null,a)),fC(function(){(Et&6)===0&&Ar()}),f=null;else{switch(at(y)){case 1:f=Yi;break;case 4:f=mi;break;case 16:f=Ri;break;case 536870912:f=qe;break;default:f=Ri}f=Q0(f,H0.bind(null,a))}a.callbackPriority=c,a.callbackNode=f}}function H0(a,c){if(Pu=-1,Lu=0,(Et&6)!==0)throw Error(s(327));var f=a.callbackNode;if(yo()&&a.callbackNode!==f)return null;var y=ys(a,a===zn?Vn:0);if(y===0)return null;if((y&30)!==0||(y&a.expiredLanes)!==0||c)c=zu(a,y);else{c=y;var C=Et;Et|=2;var $=V0();(zn!==a||Vn!==c)&&(lr=null,vo=Dt()+500,ba(a,c));do try{DC();break}catch(se){W0(a,se)}while(!0);im(),Iu.current=$,Et=C,kn!==null?c=0:(zn=null,Vn=0,c=Mn)}if(c!==0){if(c===2&&(C=Oi(a),C!==0&&(y=C,c=Um(a,C))),c===1)throw f=Cl,ba(a,0),Pr(a,y),Es(a,Dt()),f;if(c===6)Pr(a,y);else{if(C=a.current.alternate,(y&30)===0&&!LC(C)&&(c=zu(a,y),c===2&&($=Oi(a),$!==0&&(y=$,c=Um(a,$))),c===1))throw f=Cl,ba(a,0),Pr(a,y),Es(a,Dt()),f;switch(a.finishedWork=C,a.finishedLanes=y,c){case 0:case 1:throw Error(s(345));case 2:ka(a,_s,lr);break;case 3:if(Pr(a,y),(y&130023424)===y&&(c=zm+500-Dt(),10<c)){if(ys(a,0)!==0)break;if(C=a.suspendedLanes,(C&y)!==y){ds(),a.pingedLanes|=a.suspendedLanes&C;break}a.timeoutHandle=qh(ka.bind(null,a,_s,lr),c);break}ka(a,_s,lr);break;case 4:if(Pr(a,y),(y&4194240)===y)break;for(c=a.eventTimes,C=-1;0<y;){var W=31-Ft(y);$=1<<W,W=c[W],W>C&&(C=W),y&=~$}if(y=C,y=Dt()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*PC(y/1960))-y,10<y){a.timeoutHandle=qh(ka.bind(null,a,_s,lr),y);break}ka(a,_s,lr);break;case 5:ka(a,_s,lr);break;default:throw Error(s(329))}}}return Es(a,Dt()),a.callbackNode===f?H0.bind(null,a):null}function Um(a,c){var f=Al;return a.current.memoizedState.isDehydrated&&(ba(a,c).flags|=256),a=zu(a,c),a!==2&&(c=_s,_s=f,c!==null&&Bm(c)),a}function Bm(a){_s===null?_s=a:_s.push.apply(_s,a)}function LC(a){for(var c=a;;){if(c.flags&16384){var f=c.updateQueue;if(f!==null&&(f=f.stores,f!==null))for(var y=0;y<f.length;y++){var C=f[y],$=C.getSnapshot;C=C.value;try{if(!pi($(),C))return!1}catch{return!1}}}if(f=c.child,c.subtreeFlags&16384&&f!==null)f.return=c,c=f;else{if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function Pr(a,c){for(c&=~Lm,c&=~Tu,a.suspendedLanes|=c,a.pingedLanes&=~c,a=a.expirationTimes;0<c;){var f=31-Ft(c),y=1<<f;a[f]=-1,c&=~y}}function Z0(a){if((Et&6)!==0)throw Error(s(327));yo();var c=ys(a,0);if((c&1)===0)return Es(a,Dt()),null;var f=zu(a,c);if(a.tag!==0&&f===2){var y=Oi(a);y!==0&&(c=y,f=Um(a,y))}if(f===1)throw f=Cl,ba(a,0),Pr(a,c),Es(a,Dt()),f;if(f===6)throw Error(s(345));return a.finishedWork=a.current.alternate,a.finishedLanes=c,ka(a,_s,lr),Es(a,Dt()),null}function Hm(a,c){var f=Et;Et|=1;try{return a(c)}finally{Et=f,Et===0&&(vo=Dt()+500,du&&Ar())}}function ya(a){Rr!==null&&Rr.tag===0&&(Et&6)===0&&yo();var c=Et;Et|=1;var f=si.transition,y=wt;try{if(si.transition=null,wt=1,a)return a()}finally{wt=y,si.transition=f,Et=c,(Et&6)===0&&Ar()}}function Zm(){Ds=xo.current,Gt(xo)}function ba(a,c){a.finishedWork=null,a.finishedLanes=0;var f=a.timeoutHandle;if(f!==-1&&(a.timeoutHandle=-1,mC(f)),kn!==null)for(f=kn.return;f!==null;){var y=f;switch(Jh(y),y.tag){case 1:y=y.type.childContextTypes,y!=null&&cu();break;case 3:fo(),Gt(Ns),Gt(es),hm();break;case 5:um(y);break;case 4:fo();break;case 13:Gt(on);break;case 19:Gt(on);break;case 10:rm(y.type._context);break;case 22:case 23:Zm()}f=f.return}if(zn=a,kn=a=Lr(a.current,null),Vn=Ds=c,Mn=0,Cl=null,Lm=Tu=va=0,_s=Al=null,pa!==null){for(c=0;c<pa.length;c++)if(f=pa[c],y=f.interleaved,y!==null){f.interleaved=null;var C=y.next,$=f.pending;if($!==null){var W=$.next;$.next=C,y.next=W}f.pending=y}pa=null}return a}function W0(a,c){do{var f=kn;try{if(im(),ku.current=Su,ju){for(var y=ln.memoizedState;y!==null;){var C=y.queue;C!==null&&(C.pending=null),y=y.next}ju=!1}if(xa=0,Ln=Tn=ln=null,jl=!1,Nl=0,Pm.current=null,f===null||f.return===null){Mn=1,Cl=c,kn=null;break}e:{var $=a,W=f.return,se=f,le=c;if(c=Vn,se.flags|=32768,le!==null&&typeof le=="object"&&typeof le.then=="function"){var ye=le,$e=se,Me=$e.tag;if(($e.mode&1)===0&&(Me===0||Me===11||Me===15)){var Ae=$e.alternate;Ae?($e.updateQueue=Ae.updateQueue,$e.memoizedState=Ae.memoizedState,$e.lanes=Ae.lanes):($e.updateQueue=null,$e.memoizedState=null)}var Ve=g0(W);if(Ve!==null){Ve.flags&=-257,x0(Ve,W,se,$,c),Ve.mode&1&&p0($,ye,c),c=Ve,le=ye;var Ke=c.updateQueue;if(Ke===null){var Qe=new Set;Qe.add(le),c.updateQueue=Qe}else Ke.add(le);break e}else{if((c&1)===0){p0($,ye,c),Wm();break e}le=Error(s(426))}}else if(Jt&&se.mode&1){var gn=g0(W);if(gn!==null){(gn.flags&65536)===0&&(gn.flags|=256),x0(gn,W,se,$,c),nm(po(le,se));break e}}$=le=po(le,se),Mn!==4&&(Mn=2),Al===null?Al=[$]:Al.push($),$=W;do{switch($.tag){case 3:$.flags|=65536,c&=-c,$.lanes|=c;var ge=m0($,le,c);Fv($,ge);break e;case 1:se=le;var he=$.type,xe=$.stateNode;if(($.flags&128)===0&&(typeof he.getDerivedStateFromError=="function"||xe!==null&&typeof xe.componentDidCatch=="function"&&(Mr===null||!Mr.has(xe)))){$.flags|=65536,c&=-c,$.lanes|=c;var Le=f0($,se,c);Fv($,Le);break e}}$=$.return}while($!==null)}G0(f)}catch(Je){c=Je,kn===f&&f!==null&&(kn=f=f.return);continue}break}while(!0)}function V0(){var a=Iu.current;return Iu.current=Su,a===null?Su:a}function Wm(){(Mn===0||Mn===3||Mn===2)&&(Mn=4),zn===null||(va&268435455)===0&&(Tu&268435455)===0||Pr(zn,Vn)}function zu(a,c){var f=Et;Et|=2;var y=V0();(zn!==a||Vn!==c)&&(lr=null,ba(a,c));do try{zC();break}catch(C){W0(a,C)}while(!0);if(im(),Et=f,Iu.current=y,kn!==null)throw Error(s(261));return zn=null,Vn=0,Mn}function zC(){for(;kn!==null;)q0(kn)}function DC(){for(;kn!==null&&!Ki();)q0(kn)}function q0(a){var c=X0(a.alternate,a,Ds);a.memoizedProps=a.pendingProps,c===null?G0(a):kn=c,Pm.current=null}function G0(a){var c=a;do{var f=c.alternate;if(a=c.return,(c.flags&32768)===0){if(f=IC(f,c,Ds),f!==null){kn=f;return}}else{if(f=TC(f,c),f!==null){f.flags&=32767,kn=f;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{Mn=6,kn=null;return}}if(c=c.sibling,c!==null){kn=c;return}kn=c=a}while(c!==null);Mn===0&&(Mn=5)}function ka(a,c,f){var y=wt,C=si.transition;try{si.transition=null,wt=1,FC(a,c,f,y)}finally{si.transition=C,wt=y}return null}function FC(a,c,f,y){do yo();while(Rr!==null);if((Et&6)!==0)throw Error(s(327));f=a.finishedWork;var C=a.finishedLanes;if(f===null)return null;if(a.finishedWork=null,a.finishedLanes=0,f===a.current)throw Error(s(177));a.callbackNode=null,a.callbackPriority=0;var $=f.lanes|f.childLanes;if(In(a,$),a===zn&&(kn=zn=null,Vn=0),(f.subtreeFlags&2064)===0&&(f.flags&2064)===0||Ru||(Ru=!0,Q0(Ri,function(){return yo(),null})),$=(f.flags&15990)!==0,(f.subtreeFlags&15990)!==0||$){$=si.transition,si.transition=null;var W=wt;wt=1;var se=Et;Et|=4,Pm.current=null,RC(a,f),z0(f,a),aC(Wh),nt=!!Zh,Wh=Zh=null,a.current=f,OC(f),hi(),Et=se,wt=W,si.transition=$}else a.current=f;if(Ru&&(Ru=!1,Rr=a,Ou=C),$=a.pendingLanes,$===0&&(Mr=null),Ot(f.stateNode),Es(a,Dt()),c!==null)for(y=a.onRecoverableError,f=0;f<c.length;f++)C=c[f],y(C.value,{componentStack:C.stack,digest:C.digest});if(Mu)throw Mu=!1,a=Dm,Dm=null,a;return(Ou&1)!==0&&a.tag!==0&&yo(),$=a.pendingLanes,($&1)!==0?a===Fm?$l++:($l=0,Fm=a):$l=0,Ar(),null}function yo(){if(Rr!==null){var a=at(Ou),c=si.transition,f=wt;try{if(si.transition=null,wt=16>a?16:a,Rr===null)var y=!1;else{if(a=Rr,Rr=null,Ou=0,(Et&6)!==0)throw Error(s(331));var C=Et;for(Et|=4,Ge=a.current;Ge!==null;){var $=Ge,W=$.child;if((Ge.flags&16)!==0){var se=$.deletions;if(se!==null){for(var le=0;le<se.length;le++){var ye=se[le];for(Ge=ye;Ge!==null;){var $e=Ge;switch($e.tag){case 0:case 11:case 15:El(8,$e,$)}var Me=$e.child;if(Me!==null)Me.return=$e,Ge=Me;else for(;Ge!==null;){$e=Ge;var Ae=$e.sibling,Ve=$e.return;if(M0($e),$e===ye){Ge=null;break}if(Ae!==null){Ae.return=Ve,Ge=Ae;break}Ge=Ve}}}var Ke=$.alternate;if(Ke!==null){var Qe=Ke.child;if(Qe!==null){Ke.child=null;do{var gn=Qe.sibling;Qe.sibling=null,Qe=gn}while(Qe!==null)}}Ge=$}}if(($.subtreeFlags&2064)!==0&&W!==null)W.return=$,Ge=W;else e:for(;Ge!==null;){if($=Ge,($.flags&2048)!==0)switch($.tag){case 0:case 11:case 15:El(9,$,$.return)}var ge=$.sibling;if(ge!==null){ge.return=$.return,Ge=ge;break e}Ge=$.return}}var he=a.current;for(Ge=he;Ge!==null;){W=Ge;var xe=W.child;if((W.subtreeFlags&2064)!==0&&xe!==null)xe.return=W,Ge=xe;else e:for(W=he;Ge!==null;){if(se=Ge,(se.flags&2048)!==0)try{switch(se.tag){case 0:case 11:case 15:$u(9,se)}}catch(Je){hn(se,se.return,Je)}if(se===W){Ge=null;break e}var Le=se.sibling;if(Le!==null){Le.return=se.return,Ge=Le;break e}Ge=se.return}}if(Et=C,Ar(),ft&&typeof ft.onPostCommitFiberRoot=="function")try{ft.onPostCommitFiberRoot(ht,a)}catch{}y=!0}return y}finally{wt=f,si.transition=c}}return!1}function K0(a,c,f){c=po(f,c),c=m0(a,c,1),a=Ir(a,c,1),c=ds(),a!==null&&(bs(a,1,c),Es(a,c))}function hn(a,c,f){if(a.tag===3)K0(a,a,f);else for(;c!==null;){if(c.tag===3){K0(c,a,f);break}else if(c.tag===1){var y=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(Mr===null||!Mr.has(y))){a=po(f,a),a=f0(c,a,1),c=Ir(c,a,1),a=ds(),c!==null&&(bs(c,1,a),Es(c,a));break}}c=c.return}}function UC(a,c,f){var y=a.pingCache;y!==null&&y.delete(c),c=ds(),a.pingedLanes|=a.suspendedLanes&f,zn===a&&(Vn&f)===f&&(Mn===4||Mn===3&&(Vn&130023424)===Vn&&500>Dt()-zm?ba(a,0):Lm|=f),Es(a,c)}function Y0(a,c){c===0&&((a.mode&1)===0?c=1:(c=Ys,Ys<<=1,(Ys&130023424)===0&&(Ys=4194304)));var f=ds();a=rr(a,c),a!==null&&(bs(a,c,f),Es(a,f))}function BC(a){var c=a.memoizedState,f=0;c!==null&&(f=c.retryLane),Y0(a,f)}function HC(a,c){var f=0;switch(a.tag){case 13:var y=a.stateNode,C=a.memoizedState;C!==null&&(f=C.retryLane);break;case 19:y=a.stateNode;break;default:throw Error(s(314))}y!==null&&y.delete(c),Y0(a,f)}var X0;X0=function(a,c,f){if(a!==null)if(a.memoizedProps!==c.pendingProps||Ns.current)Ss=!0;else{if((a.lanes&f)===0&&(c.flags&128)===0)return Ss=!1,$C(a,c,f);Ss=(a.flags&131072)!==0}else Ss=!1,Jt&&(c.flags&1048576)!==0&&$v(c,mu,c.index);switch(c.lanes=0,c.tag){case 2:var y=c.type;Cu(a,c),a=c.pendingProps;var C=ao(c,es.current);mo(c,f),C=pm(null,c,y,a,C,f);var $=gm();return c.flags|=1,typeof C=="object"&&C!==null&&typeof C.render=="function"&&C.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,ws(y)?($=!0,uu(c)):$=!1,c.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,lm(c),C.updater=_u,c.stateNode=C,C._reactInternals=c,jm(c,y,a,f),c=_m(null,c,y,!0,$,f)):(c.tag=0,Jt&&$&&Qh(c),us(null,c,C,f),c=c.child),c;case 16:y=c.elementType;e:{switch(Cu(a,c),a=c.pendingProps,C=y._init,y=C(y._payload),c.type=y,C=c.tag=WC(y),a=xi(y,a),C){case 0:c=Sm(null,c,y,a,f);break e;case 1:c=N0(null,c,y,a,f);break e;case 11:c=v0(null,c,y,a,f);break e;case 14:c=y0(null,c,y,xi(y.type,a),f);break e}throw Error(s(306,y,""))}return c;case 0:return y=c.type,C=c.pendingProps,C=c.elementType===y?C:xi(y,C),Sm(a,c,y,C,f);case 1:return y=c.type,C=c.pendingProps,C=c.elementType===y?C:xi(y,C),N0(a,c,y,C,f);case 3:e:{if(w0(c),a===null)throw Error(s(387));y=c.pendingProps,$=c.memoizedState,C=$.element,Dv(a,c),yu(c,y,null,f);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){C=po(Error(s(423)),c),c=S0(a,c,y,f,C);break e}else if(y!==C){C=po(Error(s(424)),c),c=S0(a,c,y,f,C);break e}else for(zs=_r(c.stateNode.containerInfo.firstChild),Ls=c,Jt=!0,gi=null,f=Lv(c,null,y,f),c.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(co(),y===C){c=or(a,c,f);break e}us(a,c,y,f)}c=c.child}return c;case 5:return Bv(c),a===null&&tm(c),y=c.type,C=c.pendingProps,$=a!==null?a.memoizedProps:null,W=C.children,Vh(y,C)?W=null:$!==null&&Vh(y,$)&&(c.flags|=32),j0(a,c),us(a,c,W,f),c.child;case 6:return a===null&&tm(c),null;case 13:return _0(a,c,f);case 4:return cm(c,c.stateNode.containerInfo),y=c.pendingProps,a===null?c.child=uo(c,null,y,f):us(a,c,y,f),c.child;case 11:return y=c.type,C=c.pendingProps,C=c.elementType===y?C:xi(y,C),v0(a,c,y,C,f);case 7:return us(a,c,c.pendingProps,f),c.child;case 8:return us(a,c,c.pendingProps.children,f),c.child;case 12:return us(a,c,c.pendingProps.children,f),c.child;case 10:e:{if(y=c.type._context,C=c.pendingProps,$=c.memoizedProps,W=C.value,Wt(gu,y._currentValue),y._currentValue=W,$!==null)if(pi($.value,W)){if($.children===C.children&&!Ns.current){c=or(a,c,f);break e}}else for($=c.child,$!==null&&($.return=c);$!==null;){var se=$.dependencies;if(se!==null){W=$.child;for(var le=se.firstContext;le!==null;){if(le.context===y){if($.tag===1){le=ar(-1,f&-f),le.tag=2;var ye=$.updateQueue;if(ye!==null){ye=ye.shared;var $e=ye.pending;$e===null?le.next=le:(le.next=$e.next,$e.next=le),ye.pending=le}}$.lanes|=f,le=$.alternate,le!==null&&(le.lanes|=f),am($.return,f,c),se.lanes|=f;break}le=le.next}}else if($.tag===10)W=$.type===c.type?null:$.child;else if($.tag===18){if(W=$.return,W===null)throw Error(s(341));W.lanes|=f,se=W.alternate,se!==null&&(se.lanes|=f),am(W,f,c),W=$.sibling}else W=$.child;if(W!==null)W.return=$;else for(W=$;W!==null;){if(W===c){W=null;break}if($=W.sibling,$!==null){$.return=W.return,W=$;break}W=W.return}$=W}us(a,c,C.children,f),c=c.child}return c;case 9:return C=c.type,y=c.pendingProps.children,mo(c,f),C=ti(C),y=y(C),c.flags|=1,us(a,c,y,f),c.child;case 14:return y=c.type,C=xi(y,c.pendingProps),C=xi(y.type,C),y0(a,c,y,C,f);case 15:return b0(a,c,c.type,c.pendingProps,f);case 17:return y=c.type,C=c.pendingProps,C=c.elementType===y?C:xi(y,C),Cu(a,c),c.tag=1,ws(y)?(a=!0,uu(c)):a=!1,mo(c,f),d0(c,y,C),jm(c,y,C,f),_m(null,c,y,!0,a,f);case 19:return C0(a,c,f);case 22:return k0(a,c,f)}throw Error(s(156,c.tag))};function Q0(a,c){return Os(a,c)}function ZC(a,c,f,y){this.tag=a,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ii(a,c,f,y){return new ZC(a,c,f,y)}function Vm(a){return a=a.prototype,!(!a||!a.isReactComponent)}function WC(a){if(typeof a=="function")return Vm(a)?1:0;if(a!=null){if(a=a.$$typeof,a===L)return 11;if(a===H)return 14}return 2}function Lr(a,c){var f=a.alternate;return f===null?(f=ii(a.tag,c,a.key,a.mode),f.elementType=a.elementType,f.type=a.type,f.stateNode=a.stateNode,f.alternate=a,a.alternate=f):(f.pendingProps=c,f.type=a.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=a.flags&14680064,f.childLanes=a.childLanes,f.lanes=a.lanes,f.child=a.child,f.memoizedProps=a.memoizedProps,f.memoizedState=a.memoizedState,f.updateQueue=a.updateQueue,c=a.dependencies,f.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},f.sibling=a.sibling,f.index=a.index,f.ref=a.ref,f}function Du(a,c,f,y,C,$){var W=2;if(y=a,typeof a=="function")Vm(a)&&(W=1);else if(typeof a=="string")W=5;else e:switch(a){case B:return ja(f.children,C,$,c);case U:W=8,C|=8;break;case P:return a=ii(12,f,c,C|2),a.elementType=P,a.lanes=$,a;case A:return a=ii(13,f,c,C),a.elementType=A,a.lanes=$,a;case T:return a=ii(19,f,c,C),a.elementType=T,a.lanes=$,a;case V:return Fu(f,C,$,c);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case R:W=10;break e;case z:W=9;break e;case L:W=11;break e;case H:W=14;break e;case F:W=16,y=null;break e}throw Error(s(130,a==null?a:typeof a,""))}return c=ii(W,f,c,C),c.elementType=a,c.type=y,c.lanes=$,c}function ja(a,c,f,y){return a=ii(7,a,y,c),a.lanes=f,a}function Fu(a,c,f,y){return a=ii(22,a,y,c),a.elementType=V,a.lanes=f,a.stateNode={isHidden:!1},a}function qm(a,c,f){return a=ii(6,a,null,c),a.lanes=f,a}function Gm(a,c,f){return c=ii(4,a.children!==null?a.children:[],a.key,c),c.lanes=f,c.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},c}function VC(a,c,f,y,C){this.tag=c,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ls(0),this.expirationTimes=ls(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ls(0),this.identifierPrefix=y,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function Km(a,c,f,y,C,$,W,se,le){return a=new VC(a,c,f,se,le),c===1?(c=1,$===!0&&(c|=8)):c=0,$=ii(3,null,null,c),a.current=$,$.stateNode=a,$.memoizedState={element:y,isDehydrated:f,cache:null,transitions:null,pendingSuspenseBoundaries:null},lm($),a}function qC(a,c,f){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:y==null?null:""+y,children:a,containerInfo:c,implementation:f}}function J0(a){if(!a)return Cr;a=a._reactInternals;e:{if(Qn(a)!==a||a.tag!==1)throw Error(s(170));var c=a;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(ws(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(s(171))}if(a.tag===1){var f=a.type;if(ws(f))return Ev(a,f,c)}return c}function ey(a,c,f,y,C,$,W,se,le){return a=Km(f,y,!0,a,C,$,W,se,le),a.context=J0(null),f=a.current,y=ds(),C=Or(f),$=ar(y,C),$.callback=c??null,Ir(f,$,C),a.current.lanes=C,bs(a,C,y),Es(a,y),a}function Uu(a,c,f,y){var C=c.current,$=ds(),W=Or(C);return f=J0(f),c.context===null?c.context=f:c.pendingContext=f,c=ar($,W),c.payload={element:a},y=y===void 0?null:y,y!==null&&(c.callback=y),a=Ir(C,c,W),a!==null&&(bi(a,C,W,$),vu(a,C,W)),W}function Bu(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function ty(a,c){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var f=a.retryLane;a.retryLane=f!==0&&f<c?f:c}}function Ym(a,c){ty(a,c),(a=a.alternate)&&ty(a,c)}function GC(){return null}var ny=typeof reportError=="function"?reportError:function(a){console.error(a)};function Xm(a){this._internalRoot=a}Hu.prototype.render=Xm.prototype.render=function(a){var c=this._internalRoot;if(c===null)throw Error(s(409));Uu(a,c,null,null)},Hu.prototype.unmount=Xm.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var c=a.containerInfo;ya(function(){Uu(null,a,null,null)}),c[tr]=null}};function Hu(a){this._internalRoot=a}Hu.prototype.unstable_scheduleHydration=function(a){if(a){var c=Xi();a={blockedOn:null,target:a,priority:c};for(var f=0;f<yn.length&&c!==0&&c<yn[f].priority;f++);yn.splice(f,0,a),f===0&&Ya(a)}};function Qm(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Zu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function sy(){}function KC(a,c,f,y,C){if(C){if(typeof y=="function"){var $=y;y=function(){var ye=Bu(W);$.call(ye)}}var W=ey(c,y,a,0,null,!1,!1,"",sy);return a._reactRootContainer=W,a[tr]=W.current,fl(a.nodeType===8?a.parentNode:a),ya(),W}for(;C=a.lastChild;)a.removeChild(C);if(typeof y=="function"){var se=y;y=function(){var ye=Bu(le);se.call(ye)}}var le=Km(a,0,!1,null,null,!1,!1,"",sy);return a._reactRootContainer=le,a[tr]=le.current,fl(a.nodeType===8?a.parentNode:a),ya(function(){Uu(c,le,f,y)}),le}function Wu(a,c,f,y,C){var $=f._reactRootContainer;if($){var W=$;if(typeof C=="function"){var se=C;C=function(){var le=Bu(W);se.call(le)}}Uu(c,W,a,C)}else W=KC(f,c,a,C,y);return Bu(W)}ks=function(a){switch(a.tag){case 3:var c=a.stateNode;if(c.current.memoizedState.isDehydrated){var f=Xs(c.pendingLanes);f!==0&&(Qs(c,f|1),Es(c,Dt()),(Et&6)===0&&(vo=Dt()+500,Ar()))}break;case 13:ya(function(){var y=rr(a,1);if(y!==null){var C=ds();bi(y,a,1,C)}}),Ym(a,1)}},Bt=function(a){if(a.tag===13){var c=rr(a,134217728);if(c!==null){var f=ds();bi(c,a,134217728,f)}Ym(a,134217728)}},pt=function(a){if(a.tag===13){var c=Or(a),f=rr(a,c);if(f!==null){var y=ds();bi(f,a,c,y)}Ym(a,c)}},Xi=function(){return wt},cs=function(a,c){var f=wt;try{return wt=a,c()}finally{wt=f}},An=function(a,c,f){switch(c){case"input":if(ae(a,f),c=f.name,f.type==="radio"&&c!=null){for(f=a;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<f.length;c++){var y=f[c];if(y!==a&&y.form===a.form){var C=lu(y);if(!C)throw Error(s(90));Te(y),ae(y,C)}}}break;case"textarea":Pt(a,f);break;case"select":c=f.value,c!=null&&Rt(a,!!f.multiple,c,!1)}},we=Hm,He=ya;var YC={usingClientEntryPoint:!1,Events:[xl,io,lu,J,me,Hm]},Il={findFiberByHostInstance:da,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},XC={bundleType:Il.bundleType,version:Il.version,rendererPackageName:Il.rendererPackageName,rendererConfig:Il.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=kr(a),a===null?null:a.stateNode},findFiberByHostInstance:Il.findFiberByHostInstance||GC,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Vu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vu.isDisabled&&Vu.supportsFiber)try{ht=Vu.inject(XC),ft=Vu}catch{}}return Cs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=YC,Cs.createPortal=function(a,c){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Qm(c))throw Error(s(200));return qC(a,c,null,f)},Cs.createRoot=function(a,c){if(!Qm(a))throw Error(s(299));var f=!1,y="",C=ny;return c!=null&&(c.unstable_strictMode===!0&&(f=!0),c.identifierPrefix!==void 0&&(y=c.identifierPrefix),c.onRecoverableError!==void 0&&(C=c.onRecoverableError)),c=Km(a,1,!1,null,null,f,!1,y,C),a[tr]=c.current,fl(a.nodeType===8?a.parentNode:a),new Xm(c)},Cs.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var c=a._reactInternals;if(c===void 0)throw typeof a.render=="function"?Error(s(188)):(a=Object.keys(a).join(","),Error(s(268,a)));return a=kr(c),a=a===null?null:a.stateNode,a},Cs.flushSync=function(a){return ya(a)},Cs.hydrate=function(a,c,f){if(!Zu(c))throw Error(s(200));return Wu(null,a,c,!0,f)},Cs.hydrateRoot=function(a,c,f){if(!Qm(a))throw Error(s(405));var y=f!=null&&f.hydratedSources||null,C=!1,$="",W=ny;if(f!=null&&(f.unstable_strictMode===!0&&(C=!0),f.identifierPrefix!==void 0&&($=f.identifierPrefix),f.onRecoverableError!==void 0&&(W=f.onRecoverableError)),c=ey(c,null,a,1,f??null,C,!1,$,W),a[tr]=c.current,fl(a),y)for(a=0;a<y.length;a++)f=y[a],C=f._getVersion,C=C(f._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[f,C]:c.mutableSourceEagerHydrationData.push(f,C);return new Hu(c)},Cs.render=function(a,c,f){if(!Zu(c))throw Error(s(200));return Wu(null,a,c,!1,f)},Cs.unmountComponentAtNode=function(a){if(!Zu(a))throw Error(s(40));return a._reactRootContainer?(ya(function(){Wu(null,null,a,!1,function(){a._reactRootContainer=null,a[tr]=null})}),!0):!1},Cs.unstable_batchedUpdates=Hm,Cs.unstable_renderSubtreeIntoContainer=function(a,c,f,y){if(!Zu(f))throw Error(s(200));if(a==null||a._reactInternals===void 0)throw Error(s(38));return Wu(a,c,f,!1,y)},Cs.version="18.3.1-next-f1338f8080-20240426",Cs}var my;function rN(){if(my)return nf.exports;my=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(),nf.exports=aA(),nf.exports}var fy;function oA(){if(fy)return qu;fy=1;var e=rN();return qu.createRoot=e.createRoot,qu.hydrateRoot=e.hydrateRoot,qu}var lA=oA(),Vr,Po,Lo;class Bi{constructor(t){Ht(this,Vr);Ht(this,Po,new Set);Ht(this,Lo,!1);mt(this,"get",()=>ze(this,Vr));mt(this,"subscribe",t=>(ze(this,Po).add(t),()=>{ze(this,Po).delete(t)}));Kt(this,Vr,t)}set(t){const s=typeof t=="function"?t(ze(this,Vr)):t;Object.is(s,ze(this,Vr))||(Kt(this,Vr,s),!ze(this,Lo)&&(Kt(this,Lo,!0),queueMicrotask(()=>{Kt(this,Lo,!1);for(const i of[...ze(this,Po)])i()})))}}Vr=new WeakMap,Po=new WeakMap,Lo=new WeakMap;var py;function ke(e,t,s){function i(u,d){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:d,constr:l,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,d);const h=l.prototype,m=Object.keys(h);for(let p=0;p<m.length;p++){const g=m[p];g in u||(u[g]=h[g].bind(u))}}const r=(s==null?void 0:s.Parent)??Object;class o extends r{}Object.defineProperty(o,"name",{value:e});function l(u){var d;const h=s!=null&&s.Parent?new o:this;i(h,u),(d=h._zod).deferred??(d.deferred=[]);for(const m of h._zod.deferred)m();return h}return Object.defineProperty(l,"init",{value:i}),Object.defineProperty(l,Symbol.hasInstance,{value:u=>{var d,h;return s!=null&&s.Parent&&u instanceof s.Parent?!0:(h=(d=u==null?void 0:u._zod)==null?void 0:d.traits)==null?void 0:h.has(e)}}),Object.defineProperty(l,"name",{value:e}),l}class Ao extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class aN extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(py=globalThis).__zod_globalConfig??(py.__zod_globalConfig={});const Mg=globalThis.__zod_globalConfig;function gr(e){return Mg}function oN(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 bp(e,t){return typeof t=="bigint"?t.toString():t}function th(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Rg(e){return e==null}function Og(e){const t=e.startsWith("^")?1:0,s=e.endsWith("$")?e.length-1:e.length;return e.slice(t,s)}function cA(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 gy=Symbol("evaluating");function Lt(e,t,s){let i;Object.defineProperty(e,t,{get(){if(i!==gy)return i===void 0&&(i=gy,i=s()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Va(e,t,s){Object.defineProperty(e,t,{value:s,writable:!0,enumerable:!0,configurable:!0})}function sa(...e){const t={};for(const s of e){const i=Object.getOwnPropertyDescriptors(s);Object.assign(t,i)}return Object.defineProperties({},t)}function xy(e){return JSON.stringify(e)}function uA(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const lN="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function yc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const dA=th(()=>{var e;if(Mg.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Ho(e){if(yc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const s=t.prototype;return!(yc(s)===!1||Object.prototype.hasOwnProperty.call(s,"isPrototypeOf")===!1)}function cN(e){return Ho(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const hA=new Set(["string","number","symbol"]);function Zo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ia(e,t,s){const i=new e._zod.constr(t??e._zod.def);return(!t||s!=null&&s.parent)&&(i._zod.parent=e),i}function et(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function mA(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const fA={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 pA(e,t){const s=e._zod.def,i=s.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=sa(e._zod.def,{get shape(){const l={};for(const u in t){if(!(u in s.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(l[u]=s.shape[u])}return Va(this,"shape",l),l},checks:[]});return ia(e,o)}function gA(e,t){const s=e._zod.def,i=s.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=sa(e._zod.def,{get shape(){const l={...e._zod.def.shape};for(const u in t){if(!(u in s.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&delete l[u]}return Va(this,"shape",l),l},checks:[]});return ia(e,o)}function xA(e,t){if(!Ho(t))throw new Error("Invalid input to extend: expected a plain object");const s=e._zod.def.checks;if(s&&s.length>0){const o=e._zod.def.shape;for(const l in t)if(Object.getOwnPropertyDescriptor(o,l)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=sa(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Va(this,"shape",o),o}});return ia(e,r)}function vA(e,t){if(!Ho(t))throw new Error("Invalid input to safeExtend: expected a plain object");const s=sa(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Va(this,"shape",i),i}});return ia(e,s)}function yA(e,t){var i;if((i=e._zod.def.checks)!=null&&i.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const s=sa(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Va(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ia(e,s)}function bA(e,t,s){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const l=sa(t._zod.def,{get shape(){const u=t._zod.def.shape,d={...u};if(s)for(const h in s){if(!(h in u))throw new Error(`Unrecognized key: "${h}"`);s[h]&&(d[h]=e?new e({type:"optional",innerType:u[h]}):u[h])}else for(const h in u)d[h]=e?new e({type:"optional",innerType:u[h]}):u[h];return Va(this,"shape",d),d},checks:[]});return ia(t,l)}function kA(e,t,s){const i=sa(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(s)for(const l in s){if(!(l in o))throw new Error(`Unrecognized key: "${l}"`);s[l]&&(o[l]=new e({type:"nonoptional",innerType:r[l]}))}else for(const l in r)o[l]=new e({type:"nonoptional",innerType:r[l]});return Va(this,"shape",o),o}});return ia(t,i)}function _o(e,t=0){var s;if(e.aborted===!0)return!0;for(let i=t;i<e.issues.length;i++)if(((s=e.issues[i])==null?void 0:s.continue)!==!0)return!0;return!1}function jA(e,t=0){var s;if(e.aborted===!0)return!0;for(let i=t;i<e.issues.length;i++)if(((s=e.issues[i])==null?void 0:s.continue)===!1)return!0;return!1}function Eo(e,t){return t.map(s=>{var i;return(i=s).path??(i.path=[]),s.path.unshift(e),s})}function Gu(e){return typeof e=="string"?e:e==null?void 0:e.message}function xr(e,t,s){var d,h,m,p,g,x;const i=e.message?e.message:Gu((m=(h=(d=e.inst)==null?void 0:d._zod.def)==null?void 0:h.error)==null?void 0:m.call(h,e))??Gu((p=t==null?void 0:t.error)==null?void 0:p.call(t,e))??Gu((g=s.customError)==null?void 0:g.call(s,e))??Gu((x=s.localeError)==null?void 0:x.call(s,e))??"Invalid input",{inst:r,continue:o,input:l,...u}=e;return u.path??(u.path=[]),u.message=i,t!=null&&t.reportInput&&(u.input=l),u}function Pg(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function bc(...e){const[t,s,i]=e;return typeof t=="string"?{message:t,code:"custom",input:s,inst:i}:{...t}}const uN=(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,bp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},dN=ke("$ZodError",uN),hN=ke("$ZodError",uN,{Parent:Error});function NA(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 wA(e,t=s=>s.message){const s={_errors:[]},i=(r,o=[])=>{for(const l of r.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>i({issues:u},[...o,...l.path]));else if(l.code==="invalid_key")i({issues:l.issues},[...o,...l.path]);else if(l.code==="invalid_element")i({issues:l.issues},[...o,...l.path]);else{const u=[...o,...l.path];if(u.length===0)s._errors.push(t(l));else{let d=s,h=0;for(;h<u.length;){const m=u[h];h===u.length-1?(d[m]=d[m]||{_errors:[]},d[m]._errors.push(t(l))):d[m]=d[m]||{_errors:[]},d=d[m],h++}}}};return i(e),s}const Lg=e=>(t,s,i,r)=>{const o=i?{...i,async:!1}:{async:!1},l=t._zod.run({value:s,issues:[]},o);if(l instanceof Promise)throw new Ao;if(l.issues.length){const u=new((r==null?void 0:r.Err)??e)(l.issues.map(d=>xr(d,o,gr())));throw lN(u,r==null?void 0:r.callee),u}return l.value},zg=e=>async(t,s,i,r)=>{const o=i?{...i,async:!0}:{async:!0};let l=t._zod.run({value:s,issues:[]},o);if(l instanceof Promise&&(l=await l),l.issues.length){const u=new((r==null?void 0:r.Err)??e)(l.issues.map(d=>xr(d,o,gr())));throw lN(u,r==null?void 0:r.callee),u}return l.value},nh=e=>(t,s,i)=>{const r=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:s,issues:[]},r);if(o instanceof Promise)throw new Ao;return o.issues.length?{success:!1,error:new(e??dN)(o.issues.map(l=>xr(l,r,gr())))}:{success:!0,data:o.value}},SA=nh(hN),sh=e=>async(t,s,i)=>{const r=i?{...i,async:!0}:{async:!0};let o=t._zod.run({value:s,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(l=>xr(l,r,gr())))}:{success:!0,data:o.value}},_A=sh(hN),EA=e=>(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Lg(e)(t,s,r)},CA=e=>(t,s,i)=>Lg(e)(t,s,i),AA=e=>async(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return zg(e)(t,s,r)},$A=e=>async(t,s,i)=>zg(e)(t,s,i),IA=e=>(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return nh(e)(t,s,r)},TA=e=>(t,s,i)=>nh(e)(t,s,i),MA=e=>async(t,s,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return sh(e)(t,s,r)},RA=e=>async(t,s,i)=>sh(e)(t,s,i),OA=/^[cC][0-9a-z]{6,}$/,PA=/^[0-9a-z]+$/,LA=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,zA=/^[0-9a-vA-V]{20}$/,DA=/^[A-Za-z0-9]{27}$/,FA=/^[a-zA-Z0-9_-]{21}$/,UA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,BA=/^([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})$/,vy=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)$/,HA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ZA="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function WA(){return new RegExp(ZA,"u")}const VA=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,qA=/^(([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}|:))$/,GA=/^((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])$/,KA=/^(([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])$/,YA=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,mN=/^[A-Za-z0-9_-]*$/,XA=/^https?$/,QA=/^\+[1-9]\d{6,14}$/,fN="(?:(?:\\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])))",JA=new RegExp(`^${fN}$`);function pN(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 e$(e){return new RegExp(`^${pN(e)}$`)}function t$(e){const t=pN({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(`^${fN}T(?:${i})$`)}const n$=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}$`)},s$=/^-?\d+$/,gN=/^-?\d+(?:\.\d+)?$/,i$=/^(?:true|false)$/i,r$=/^null$/i,a$=/^[^A-Z]*$/,o$=/^[^a-z]*$/,Rs=ke("$ZodCheck",(e,t)=>{var s;e._zod??(e._zod={}),e._zod.def=t,(s=e._zod).onattach??(s.onattach=[])}),xN={number:"number",bigint:"bigint",object:"date"},vN=ke("$ZodCheckLessThan",(e,t)=>{Rs.init(e,t);const s=xN[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})}}),yN=ke("$ZodCheckGreaterThan",(e,t)=>{Rs.init(e,t);const s=xN[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})}}),l$=ke("$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):cA(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})}}),c$=ke("$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]=fA[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=s$)}),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})}}),u$=ke("$ZodCheckMaxLength",(e,t)=>{var s;Rs.init(e,t),(s=e._zod.def).when??(s.when=i=>{const r=i.value;return!Rg(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=Pg(r);i.issues.push({origin:l,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),d$=ke("$ZodCheckMinLength",(e,t)=>{var s;Rs.init(e,t),(s=e._zod.def).when??(s.when=i=>{const r=i.value;return!Rg(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=Pg(r);i.issues.push({origin:l,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),h$=ke("$ZodCheckLengthEquals",(e,t)=>{var s;Rs.init(e,t),(s=e._zod.def).when??(s.when=i=>{const r=i.value;return!Rg(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=Pg(r),u=o>t.length;i.issues.push({origin:l,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),ih=ke("$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=()=>{})}),m$=ke("$ZodCheckRegex",(e,t)=>{ih.init(e,t),e._zod.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:"regex",input:s.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),f$=ke("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=a$),ih.init(e,t)}),p$=ke("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=o$),ih.init(e,t)}),g$=ke("$ZodCheckIncludes",(e,t)=>{Rs.init(e,t);const s=Zo(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${s}`:s);t.pattern=i,e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),x$=ke("$ZodCheckStartsWith",(e,t)=>{Rs.init(e,t);const s=new RegExp(`^${Zo(t.prefix)}.*`);t.pattern??(t.pattern=s),e._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(s)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),v$=ke("$ZodCheckEndsWith",(e,t)=>{Rs.init(e,t);const s=new RegExp(`.*${Zo(t.suffix)}$`);t.pattern??(t.pattern=s),e._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(s)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}}),y$=ke("$ZodCheckOverwrite",(e,t)=>{Rs.init(e,t),e._zod.check=s=>{s.value=t.tx(s.value)}});class b${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 k$={major:4,minor:4,patch:3},tn=ke("$ZodType",(e,t)=>{var r;var s;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=k$;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const o of i)for(const l of o._zod.onattach)l(e);if(i.length===0)(s=e._zod).deferred??(s.deferred=[]),(r=e._zod.deferred)==null||r.push(()=>{e._zod.run=e._zod.parse});else{const o=(u,d,h)=>{let m=_o(u),p;for(const g of d){if(g._zod.def.when){if(jA(u)||!g._zod.def.when(u))continue}else if(m)continue;const x=u.issues.length,k=g._zod.check(u);if(k instanceof Promise&&(h==null?void 0:h.async)===!1)throw new Ao;if(p||k instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await k,u.issues.length!==x&&(m||(m=_o(u,x)))});else{if(u.issues.length===x)continue;m||(m=_o(u,x))}}return p?p.then(()=>u):u},l=(u,d,h)=>{if(_o(u))return u.aborted=!0,u;const m=o(d,i,h);if(m instanceof Promise){if(h.async===!1)throw new Ao;return m.then(p=>e._zod.parse(p,h))}return e._zod.parse(m,h)};e._zod.run=(u,d)=>{if(d.skipChecks)return e._zod.parse(u,d);if(d.direction==="backward"){const m=e._zod.parse({value:u.value,issues:[]},{...d,skipChecks:!0});return m instanceof Promise?m.then(p=>l(p,u,d)):l(m,u,d)}const h=e._zod.parse(u,d);if(h instanceof Promise){if(d.async===!1)throw new Ao;return h.then(m=>o(m,i,d))}return o(h,i,d)}}Lt(e,"~standard",()=>({validate:o=>{var l;try{const u=SA(e,o);return u.success?{value:u.data}:{issues:(l=u.error)==null?void 0:l.issues}}catch{return _A(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}))}),Dg=ke("$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()??n$(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=ke("$ZodStringFormat",(e,t)=>{ih.init(e,t),Dg.init(e,t)}),j$=ke("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=BA),nn.init(e,t)}),N$=ke("$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=vy(i))}else t.pattern??(t.pattern=vy());nn.init(e,t)}),w$=ke("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=HA),nn.init(e,t)}),S$=ke("$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)===XA.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})}}}),_$=ke("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=WA()),nn.init(e,t)}),E$=ke("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=FA),nn.init(e,t)}),C$=ke("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=OA),nn.init(e,t)}),A$=ke("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=PA),nn.init(e,t)}),$$=ke("$ZodULID",(e,t)=>{t.pattern??(t.pattern=LA),nn.init(e,t)}),I$=ke("$ZodXID",(e,t)=>{t.pattern??(t.pattern=zA),nn.init(e,t)}),T$=ke("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=DA),nn.init(e,t)}),M$=ke("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=t$(t)),nn.init(e,t)}),R$=ke("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=JA),nn.init(e,t)}),O$=ke("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=e$(t)),nn.init(e,t)}),P$=ke("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=UA),nn.init(e,t)}),L$=ke("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=VA),nn.init(e,t),e._zod.bag.format="ipv4"}),z$=ke("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=qA),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})}}}),D$=ke("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=GA),nn.init(e,t)}),F$=ke("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=KA),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 bN(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const U$=ke("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=YA),nn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=s=>{bN(s.value)||s.issues.push({code:"invalid_format",format:"base64",input:s.value,inst:e,continue:!t.abort})}});function B$(e){if(!mN.test(e))return!1;const t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),s=t.padEnd(Math.ceil(t.length/4)*4,"=");return bN(s)}const H$=ke("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=mN),nn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=s=>{B$(s.value)||s.issues.push({code:"invalid_format",format:"base64url",input:s.value,inst:e,continue:!t.abort})}}),Z$=ke("$ZodE164",(e,t)=>{t.pattern??(t.pattern=QA),nn.init(e,t)});function W$(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 V$=ke("$ZodJWT",(e,t)=>{nn.init(e,t),e._zod.check=s=>{W$(s.value,t.alg)||s.issues.push({code:"invalid_format",format:"jwt",input:s.value,inst:e,continue:!t.abort})}}),kN=ke("$ZodNumber",(e,t)=>{tn.init(e,t),e._zod.pattern=e._zod.bag.pattern??gN,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}}),q$=ke("$ZodNumberFormat",(e,t)=>{c$.init(e,t),kN.init(e,t)}),G$=ke("$ZodBoolean",(e,t)=>{tn.init(e,t),e._zod.pattern=i$,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}}),K$=ke("$ZodNull",(e,t)=>{tn.init(e,t),e._zod.pattern=r$,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}}),Y$=ke("$ZodUnknown",(e,t)=>{tn.init(e,t),e._zod.parse=s=>s}),X$=ke("$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 yy(e,t,s){e.issues.length&&t.issues.push(...Eo(s,e.issues)),t.value[s]=e.value}const Q$=ke("$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=>yy(h,s,l))):yy(d,s,l)}return o.length?Promise.all(o).then(()=>s):s}});function Cd(e,t,s,i,r,o){const l=s in i;if(e.issues.length){if(r&&o&&!l)return;t.issues.push(...Eo(s,e.issues))}if(!l&&!r){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[s]});return}e.value===void 0?l&&(t.value[s]=void 0):t.value[s]=e.value}function jN(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=mA(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function NN(e,t,s,i,r,o){const l=[],u=r.keySet,d=r.catchall._zod,h=d.def.type,m=d.optin==="optional",p=d.optout==="optional";for(const g in t){if(g==="__proto__"||u.has(g))continue;if(h==="never"){l.push(g);continue}const x=d.run({value:t[g],issues:[]},i);x instanceof Promise?e.push(x.then(k=>Cd(k,s,g,t,m,p))):Cd(x,s,g,t,m,p)}return l.length&&s.issues.push({code:"unrecognized_keys",keys:l,input:t,inst:o}),e.length?Promise.all(e).then(()=>s):s}const J$=ke("$ZodObject",(e,t)=>{tn.init(e,t);const s=Object.getOwnPropertyDescriptor(t,"shape");if(!(s!=null&&s.get)){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...u};return Object.defineProperty(t,"shape",{value:d}),d}})}const i=th(()=>jN(t));Lt(e._zod,"propValues",()=>{const u=t.shape,d={};for(const h in u){const m=u[h]._zod;if(m.values){d[h]??(d[h]=new Set);for(const p of m.values)d[h].add(p)}}return d});const r=yc,o=t.catchall;let l;e._zod.parse=(u,d)=>{l??(l=i.value);const h=u.value;if(!r(h))return u.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),u;u.value={};const m=[],p=l.shape;for(const g of l.keys){const x=p[g],k=x._zod.optin==="optional",b=x._zod.optout==="optional",j=x._zod.run({value:h[g],issues:[]},d);j instanceof Promise?m.push(j.then(w=>Cd(w,u,g,h,k,b))):Cd(j,u,g,h,k,b)}return o?NN(m,h,u,d,i.value,e):m.length?Promise.all(m).then(()=>u):u}}),eI=ke("$ZodObjectJIT",(e,t)=>{J$.init(e,t);const s=e._zod.parse,i=th(()=>jN(t)),r=g=>{var _,E;const x=new b$(["shape","payload","ctx"]),k=i.value,b=M=>{const O=xy(M);return`shape[${O}]._zod.run({ value: input[${O}], issues: [] }, ctx)`};x.write("const input = payload.value;");const j=Object.create(null);let w=0;for(const M of k.keys)j[M]=`key_${w++}`;x.write("const newResult = {};");for(const M of k.keys){const O=j[M],B=xy(M),U=g[M],P=((_=U==null?void 0:U._zod)==null?void 0:_.optin)==="optional",R=((E=U==null?void 0:U._zod)==null?void 0:E.optout)==="optional";x.write(`const ${O} = ${b(M)};`),P&&R?x.write(`
43
+ if (${O}.issues.length) {
44
+ if (${B} in input) {
45
+ payload.issues = payload.issues.concat(${O}.issues.map(iss => ({
46
+ ...iss,
47
+ path: iss.path ? [${B}, ...iss.path] : [${B}]
48
+ })));
49
+ }
50
+ }
51
+
52
+ if (${O}.value === undefined) {
53
+ if (${B} in input) {
54
+ newResult[${B}] = undefined;
55
+ }
56
+ } else {
57
+ newResult[${B}] = ${O}.value;
58
+ }
59
+
60
+ `):P?x.write(`
61
+ if (${O}.issues.length) {
62
+ payload.issues = payload.issues.concat(${O}.issues.map(iss => ({
63
+ ...iss,
64
+ path: iss.path ? [${B}, ...iss.path] : [${B}]
65
+ })));
66
+ }
67
+
68
+ if (${O}.value === undefined) {
69
+ if (${B} in input) {
70
+ newResult[${B}] = undefined;
71
+ }
72
+ } else {
73
+ newResult[${B}] = ${O}.value;
74
+ }
75
+
76
+ `):x.write(`
77
+ const ${O}_present = ${B} in input;
78
+ if (${O}.issues.length) {
79
+ payload.issues = payload.issues.concat(${O}.issues.map(iss => ({
80
+ ...iss,
81
+ path: iss.path ? [${B}, ...iss.path] : [${B}]
82
+ })));
83
+ }
84
+ if (!${O}_present && !${O}.issues.length) {
85
+ payload.issues.push({
86
+ code: "invalid_type",
87
+ expected: "nonoptional",
88
+ input: undefined,
89
+ path: [${B}]
90
+ });
91
+ }
92
+
93
+ if (${O}_present) {
94
+ if (${O}.value === undefined) {
95
+ newResult[${B}] = undefined;
96
+ } else {
97
+ newResult[${B}] = ${O}.value;
98
+ }
99
+ }
100
+
101
+ `)}x.write("payload.value = newResult;"),x.write("return payload;");const S=x.compile();return(M,O)=>S(g,M,O)};let o;const l=yc,u=!Mg.jitless,h=u&&dA.value,m=t.catchall;let p;e._zod.parse=(g,x)=>{p??(p=i.value);const k=g.value;return l(k)?u&&h&&(x==null?void 0:x.async)===!1&&x.jitless!==!0?(o||(o=r(t.shape)),g=o(g,x),m?NN([],k,g,x,p,e):g):s(g,x):(g.issues.push({expected:"object",code:"invalid_type",input:k,inst:e}),g)}});function by(e,t,s,i){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const r=e.filter(o=>!_o(o));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:s,errors:e.map(o=>o.issues.map(l=>xr(l,i,gr())))}),t)}const wN=ke("$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=>Og(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=>by(u,i,e,r)):by(l,i,e,r)}}),tI=ke("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,wN.init(e,t);const s=e._zod.parse;Lt(e._zod,"propValues",()=>{const r={};for(const o of t.options){const l=o._zod.propValues;if(!l||Object.keys(l).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[u,d]of Object.entries(l)){r[u]||(r[u]=new Set);for(const h of d)r[u].add(h)}}return r});const i=th(()=>{var l;const r=t.options,o=new Map;for(const u of r){const d=(l=u._zod.propValues)==null?void 0:l[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const h of d){if(o.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);o.set(h,u)}}return o});e._zod.parse=(r,o)=>{const l=r.value;if(!yc(l))return r.issues.push({code:"invalid_type",expected:"object",input:l,inst:e}),r;const u=i.value.get(l==null?void 0:l[t.discriminator]);return u?u._zod.run(r,o):t.unionFallback||o.direction==="backward"?s(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()),input:l,path:[t.discriminator],inst:e}),r)}}),nI=ke("$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])=>ky(s,d,h)):ky(s,o,l)}});function kp(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ho(e)&&Ho(t)){const s=Object.keys(t),i=Object.keys(e).filter(o=>s.indexOf(o)!==-1),r={...e,...t};for(const o of i){const l=kp(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=kp(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 ky(e,t,s){const i=new Map;let r;for(const u of t.issues)if(u.code==="unrecognized_keys"){r??(r=u);for(const d of u.keys)i.has(d)||i.set(d,{}),i.get(d).l=!0}else e.issues.push(u);for(const u of s.issues)if(u.code==="unrecognized_keys")for(const d of u.keys)i.has(d)||i.set(d,{}),i.get(d).r=!0;else e.issues.push(u);const o=[...i].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(o.length&&r&&e.issues.push({...r,keys:o}),_o(e))return e;const l=kp(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 sI=ke("$ZodRecord",(e,t)=>{tn.init(e,t),e._zod.parse=(s,i)=>{const r=s.value;if(!Ho(r))return s.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),s;const o=[],l=t.keyType._zod.values;if(l){s.value={};const u=new Set;for(const h of l)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){u.add(typeof h=="number"?h.toString():h);const m=t.keyType._zod.run({value:h,issues:[]},i);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(m.issues.length){s.issues.push({code:"invalid_key",origin:"record",issues:m.issues.map(x=>xr(x,i,gr())),input:h,path:[h],inst:e});continue}const p=m.value,g=t.valueType._zod.run({value:r[h],issues:[]},i);g instanceof Promise?o.push(g.then(x=>{x.issues.length&&s.issues.push(...Eo(h,x.issues)),s.value[p]=x.value})):(g.issues.length&&s.issues.push(...Eo(h,g.issues)),s.value[p]=g.value)}let d;for(const h in r)u.has(h)||(d=d??[],d.push(h));d&&d.length>0&&s.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:d})}else{s.value={};for(const u of Reflect.ownKeys(r)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(r,u))continue;let d=t.keyType._zod.run({value:u,issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&gN.test(u)&&d.issues.length){const p=t.keyType._zod.run({value:Number(u),issues:[]},i);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(d=p)}if(d.issues.length){t.mode==="loose"?s.value[u]=r[u]:s.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(p=>xr(p,i,gr())),input:u,path:[u],inst:e});continue}const m=t.valueType._zod.run({value:r[u],issues:[]},i);m instanceof Promise?o.push(m.then(p=>{p.issues.length&&s.issues.push(...Eo(u,p.issues)),s.value[d.value]=p.value})):(m.issues.length&&s.issues.push(...Eo(u,m.issues)),s.value[d.value]=m.value)}}return o.length?Promise.all(o).then(()=>s):s}}),iI=ke("$ZodEnum",(e,t)=>{tn.init(e,t);const s=oN(t.entries),i=new Set(s);e._zod.values=i,e._zod.pattern=new RegExp(`^(${s.filter(r=>hA.has(typeof r)).map(r=>typeof r=="string"?Zo(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const l=r.value;return i.has(l)||r.issues.push({code:"invalid_value",values:s,input:l,inst:e}),r}}),rI=ke("$ZodLiteral",(e,t)=>{if(tn.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const s=new Set(t.values);e._zod.values=s,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?Zo(i):i?Zo(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,r)=>{const o=i.value;return s.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),aI=ke("$ZodTransform",(e,t)=>{tn.init(e,t),e._zod.optin="optional",e._zod.parse=(s,i)=>{if(i.direction==="backward")throw new aN(e.constructor.name);const r=t.transform(s.value,s);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(l=>(s.value=l,s.fallback=!0,s));if(r instanceof Promise)throw new Ao;return s.value=r,s.fallback=!0,s}});function jy(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const SN=ke("$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(`^(${Og(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=>jy(l,r)):jy(o,r)}return s.value===void 0?s:t.innerType._zod.run(s,i)}}),oI=ke("$ZodExactOptional",(e,t)=>{SN.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)}),lI=ke("$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(`^(${Og(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)}),cI=ke("$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=>Ny(o,t)):Ny(r,t)}});function Ny(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const uI=ke("$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))}),dI=ke("$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=>wy(o,e)):wy(r,e)}});function wy(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 hI=ke("$ZodCatch",(e,t)=>{tn.init(e,t),e._zod.optin="optional",Lt(e._zod,"optout",()=>t.innerType._zod.optout),Lt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(s,i)=>{if(i.direction==="backward")return t.innerType._zod.run(s,i);const r=t.innerType._zod.run(s,i);return r instanceof Promise?r.then(o=>(s.value=o.value,o.issues.length&&(s.value=t.catchValue({...s,error:{issues:o.issues.map(l=>xr(l,i,gr()))},input:s.value}),s.issues=[],s.fallback=!0),s)):(s.value=r.value,r.issues.length&&(s.value=t.catchValue({...s,error:{issues:r.issues.map(o=>xr(o,i,gr()))},input:s.value}),s.issues=[],s.fallback=!0),s)}}),mI=ke("$ZodPipe",(e,t)=>{tn.init(e,t),Lt(e._zod,"values",()=>t.in._zod.values),Lt(e._zod,"optin",()=>t.in._zod.optin),Lt(e._zod,"optout",()=>t.out._zod.optout),Lt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(s,i)=>{if(i.direction==="backward"){const o=t.out._zod.run(s,i);return o instanceof Promise?o.then(l=>Ku(l,t.in,i)):Ku(o,t.in,i)}const r=t.in._zod.run(s,i);return r instanceof Promise?r.then(o=>Ku(o,t.out,i)):Ku(r,t.out,i)}});function Ku(e,t,s){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},s)}const fI=ke("$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(Sy):Sy(r)}});function Sy(e){return e.value=Object.freeze(e.value),e}const pI=ke("$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=>_y(o,s,i,e));_y(r,s,i,e)}});function _y(e,t,s,i){if(!e){const r={code:"custom",input:s,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),t.issues.push(bc(r))}}var Ey;class gI{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 xI(){return new gI}(Ey=globalThis).__zod_globalRegistry??(Ey.__zod_globalRegistry=xI());const Kl=globalThis.__zod_globalRegistry;function vI(e,t){return new e({type:"string",...et(t)})}function yI(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...et(t)})}function Cy(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...et(t)})}function bI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...et(t)})}function kI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...et(t)})}function jI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...et(t)})}function NI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...et(t)})}function _N(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...et(t)})}function wI(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...et(t)})}function SI(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...et(t)})}function _I(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...et(t)})}function EI(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...et(t)})}function CI(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...et(t)})}function AI(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...et(t)})}function $I(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...et(t)})}function II(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...et(t)})}function TI(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...et(t)})}function MI(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...et(t)})}function RI(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...et(t)})}function OI(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...et(t)})}function PI(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...et(t)})}function LI(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...et(t)})}function zI(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...et(t)})}function DI(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...et(t)})}function FI(e,t){return new e({type:"string",format:"date",check:"string_format",...et(t)})}function UI(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...et(t)})}function BI(e,t){return new e({type:"string",format:"duration",check:"string_format",...et(t)})}function HI(e,t){return new e({type:"number",checks:[],...et(t)})}function ZI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...et(t)})}function WI(e,t){return new e({type:"boolean",...et(t)})}function VI(e,t){return new e({type:"null",...et(t)})}function qI(e){return new e({type:"unknown"})}function GI(e,t){return new e({type:"never",...et(t)})}function Ay(e,t){return new vN({check:"less_than",...et(t),value:e,inclusive:!1})}function af(e,t){return new vN({check:"less_than",...et(t),value:e,inclusive:!0})}function $y(e,t){return new yN({check:"greater_than",...et(t),value:e,inclusive:!1})}function of(e,t){return new yN({check:"greater_than",...et(t),value:e,inclusive:!0})}function Iy(e,t){return new l$({check:"multiple_of",...et(t),value:e})}function EN(e,t){return new u$({check:"max_length",...et(t),maximum:e})}function Ad(e,t){return new d$({check:"min_length",...et(t),minimum:e})}function CN(e,t){return new h$({check:"length_equals",...et(t),length:e})}function KI(e,t){return new m$({check:"string_format",format:"regex",...et(t),pattern:e})}function YI(e){return new f$({check:"string_format",format:"lowercase",...et(e)})}function XI(e){return new p$({check:"string_format",format:"uppercase",...et(e)})}function QI(e,t){return new g$({check:"string_format",format:"includes",...et(t),includes:e})}function JI(e,t){return new x$({check:"string_format",format:"starts_with",...et(t),prefix:e})}function eT(e,t){return new v$({check:"string_format",format:"ends_with",...et(t),suffix:e})}function il(e){return new y$({check:"overwrite",tx:e})}function tT(e){return il(t=>t.normalize(e))}function nT(){return il(e=>e.trim())}function sT(){return il(e=>e.toLowerCase())}function iT(){return il(e=>e.toUpperCase())}function rT(){return il(e=>uA(e))}function aT(e,t,s){return new e({type:"array",element:t,...et(s)})}function oT(e,t,s){return new e({type:"custom",check:"custom",fn:t,...et(s)})}function lT(e,t){const s=cT(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(bc(r,i.value,s._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=i.value),o.inst??(o.inst=s),o.continue??(o.continue=!s._zod.def.abort),i.issues.push(bc(o))}},e(i.value,i)),t);return s}function cT(e,t){const s=new Rs({check:"custom",...et(t)});return s._zod.check=e,s}function AN(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??Kl,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function Sn(e,t,s={path:[],schemaPath:[]}){var m,p;var i;const r=e._zod.def,o=t.seen.get(e);if(o)return o.count++,s.schemaPath.includes(e)&&(o.cycle=s.path),o.schema;const l={schema:{},count:1,cycle:void 0,path:s.path};t.seen.set(e,l);const u=(p=(m=e._zod).toJSONSchema)==null?void 0:p.call(m);if(u)l.schema=u;else{const g={...s,schemaPath:[...s.schemaPath,e],path:s.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,l.schema,g);else{const k=l.schema,b=t.processors[r.type];if(!b)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);b(e,t,k,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 $N(e,t){var l,u,d,h;const s=e.seen.get(t);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const m of e.seen.entries()){const p=(l=e.metadataRegistry.get(m[0]))==null?void 0:l.id;if(p){const g=i.get(p);if(g&&g!==m[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(p,m[0])}}const r=m=>{var b;const p=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const j=(b=e.external.registry.get(m[0]))==null?void 0:b.id,w=e.external.uri??(_=>_);if(j)return{ref:w(j)};const S=m[1].defId??m[1].schema.id??`schema${e.counter++}`;return m[1].defId=S,{defId:S,ref:`${w("__shared")}#/${p}/${S}`}}if(m[1]===s)return{ref:"#"};const x=`#/${p}/`,k=m[1].schema.id??`__schema${e.counter++}`;return{defId:k,ref:x+k}},o=m=>{if(m[1].schema.$ref)return;const p=m[1],{ref:g,defId:x}=r(m);p.def={...p.schema},x&&(p.defId=x);const k=p.schema;for(const b in k)delete k[b];k.$ref=g};if(e.cycles==="throw")for(const m of e.seen.entries()){const p=m[1];if(p.cycle)throw new Error(`Cycle detected: #/${(u=p.cycle)==null?void 0:u.join("/")}/<root>
102
+
103
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const m of e.seen.entries()){const p=m[1];if(t===m[0]){o(m);continue}if(e.external){const x=(d=e.external.registry.get(m[0]))==null?void 0:d.id;if(t!==m[0]&&x){o(m);continue}}if((h=e.metadataRegistry.get(m[0]))==null?void 0:h.id){o(m);continue}if(p.cycle){o(m);continue}if(p.count>1&&e.reused==="ref"){o(m);continue}}}function IN(e,t){var u,d,h,m;const s=e.seen.get(t);if(!s)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=p=>{const g=e.seen.get(p);if(g.ref===null)return;const x=g.def??g.schema,k={...x},b=g.ref;if(g.ref=null,b){i(b);const w=e.seen.get(b),S=w.schema;if(S.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(x.allOf=x.allOf??[],x.allOf.push(S)):Object.assign(x,S),Object.assign(x,k),p._zod.parent===b)for(const E in x)E==="$ref"||E==="allOf"||E in k||delete x[E];if(S.$ref&&w.def)for(const E in x)E==="$ref"||E==="allOf"||E in w.def&&JSON.stringify(x[E])===JSON.stringify(w.def[E])&&delete x[E]}const j=p._zod.parent;if(j&&j!==b){i(j);const w=e.seen.get(j);if(w!=null&&w.schema.$ref&&(x.$ref=w.schema.$ref,w.def))for(const S in x)S==="$ref"||S==="allOf"||S in w.def&&JSON.stringify(x[S])===JSON.stringify(w.def[S])&&delete x[S]}e.override({zodSchema:p,jsonSchema:x,path:g.path??[]})};for(const p of[...e.seen.entries()].reverse())i(p[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,(u=e.external)!=null&&u.uri){const p=(d=e.external.registry.get(t))==null?void 0:d.id;if(!p)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(p)}Object.assign(r,s.def??s.schema);const o=(h=e.metadataRegistry.get(t))==null?void 0:h.id;o!==void 0&&r.id===o&&delete r.id;const l=((m=e.external)==null?void 0:m.defs)??{};for(const p of e.seen.entries()){const g=p[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,l[g.defId]=g.def)}e.external||Object.keys(l).length>0&&(e.target==="draft-2020-12"?r.$defs=l:r.definitions=l);try{const p=JSON.parse(JSON.stringify(r));return Object.defineProperty(p,"~standard",{value:{...t["~standard"],jsonSchema:{input:$d(t,"input",e.processors),output:$d(t,"output",e.processors)}},enumerable:!1,writable:!1}),p}catch{throw new Error("Error converting schema to JSON.")}}function hs(e,t){const s=t??{seen:new Set};if(s.seen.has(e))return!1;s.seen.add(e);const i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return hs(i.element,s);if(i.type==="set")return hs(i.valueType,s);if(i.type==="lazy")return hs(i.getter(),s);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return hs(i.innerType,s);if(i.type==="intersection")return hs(i.left,s)||hs(i.right,s);if(i.type==="record"||i.type==="map")return hs(i.keyType,s)||hs(i.valueType,s);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:hs(i.in,s)||hs(i.out,s);if(i.type==="object"){for(const r in i.shape)if(hs(i.shape[r],s))return!0;return!1}if(i.type==="union"){for(const r of i.options)if(hs(r,s))return!0;return!1}if(i.type==="tuple"){for(const r of i.items)if(hs(r,s))return!0;return!!(i.rest&&hs(i.rest,s))}return!1}const uT=(e,t={})=>s=>{const i=AN({...s,processors:t});return Sn(e,i),$N(i,e),IN(i,e)},$d=(e,t,s={})=>i=>{const{libraryOptions:r,target:o}=i??{},l=AN({...r??{},target:o,io:t,processors:s});return Sn(e,l),$N(l,e),IN(l,e)},dT={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},hT=(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=dT[u]??u,r.format===""&&delete r.format,u==="time"&&delete r.format),h&&(r.contentEncoding=h),d&&d.size>0){const m=[...d];m.length===1?r.pattern=m[0].source:m.length>1&&(r.allOf=[...m.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},mT=(e,t,s,i)=>{const r=s,{minimum:o,maximum:l,format:u,multipleOf:d,exclusiveMaximum:h,exclusiveMinimum:m}=e._zod.bag;typeof u=="string"&&u.includes("int")?r.type="integer":r.type="number";const p=typeof m=="number"&&m>=(o??Number.NEGATIVE_INFINITY),g=typeof h=="number"&&h<=(l??Number.POSITIVE_INFINITY),x=t.target==="draft-04"||t.target==="openapi-3.0";p?x?(r.minimum=m,r.exclusiveMinimum=!0):r.exclusiveMinimum=m:typeof o=="number"&&(r.minimum=o),g?x?(r.maximum=h,r.exclusiveMaximum=!0):r.exclusiveMaximum=h:typeof l=="number"&&(r.maximum=l),typeof d=="number"&&(r.multipleOf=d)},fT=(e,t,s,i)=>{s.type="boolean"},pT=(e,t,s,i)=>{t.target==="openapi-3.0"?(s.type="string",s.nullable=!0,s.enum=[null]):s.type="null"},gT=(e,t,s,i)=>{s.not={}},xT=(e,t,s,i)=>{},vT=(e,t,s,i)=>{const r=e._zod.def,o=oN(r.entries);o.every(l=>typeof l=="number")&&(s.type="number"),o.every(l=>typeof l=="string")&&(s.type="string"),s.enum=o},yT=(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},bT=(e,t,s,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},kT=(e,t,s,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},jT=(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"]})},NT=(e,t,s,i)=>{var h;const r=s,o=e._zod.def;r.type="object",r.properties={};const l=o.shape;for(const m in l)r.properties[m]=Sn(l[m],t,{...i,path:[...i.path,"properties",m]});const u=new Set(Object.keys(l)),d=new Set([...u].filter(m=>{const p=o.shape[m]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));d.size>0&&(r.required=Array.from(d)),((h=o.catchall)==null?void 0:h._zod.def.type)==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=Sn(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},wT=(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},ST=(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},_T=(e,t,s,i)=>{const r=s,o=e._zod.def;r.type="object";const l=o.keyType,u=l._zod.bag,d=u==null?void 0:u.patterns;if(o.mode==="loose"&&d&&d.size>0){const m=Sn(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(const p of d)r.patternProperties[p.source]=m}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=Sn(o.keyType,t,{...i,path:[...i.path,"propertyNames"]})),r.additionalProperties=Sn(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]});const h=l._zod.values;if(h){const m=[...h].filter(p=>typeof p=="string"||typeof p=="number");m.length>0&&(r.required=m)}},ET=(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"}]},CT=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType},AT=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,s.default=JSON.parse(JSON.stringify(r.defaultValue))},$T=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,t.io==="input"&&(s._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},IT=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType;let l;try{l=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}s.default=l},TT=(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},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,s.readOnly=!0},TN=(e,t,s,i)=>{const r=e._zod.def;Sn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType},RT=ke("ZodISODateTime",(e,t)=>{M$.init(e,t),dn.init(e,t)});function OT(e){return DI(RT,e)}const PT=ke("ZodISODate",(e,t)=>{R$.init(e,t),dn.init(e,t)});function LT(e){return FI(PT,e)}const zT=ke("ZodISOTime",(e,t)=>{O$.init(e,t),dn.init(e,t)});function DT(e){return UI(zT,e)}const FT=ke("ZodISODuration",(e,t)=>{P$.init(e,t),dn.init(e,t)});function UT(e){return BI(FT,e)}const BT=(e,t)=>{dN.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:s=>wA(e,s)},flatten:{value:s=>NA(e,s)},addIssue:{value:s=>{e.issues.push(s),e.message=JSON.stringify(e.issues,bp,2)}},addIssues:{value:s=>{e.issues.push(...s),e.message=JSON.stringify(e.issues,bp,2)}},isEmpty:{get(){return e.issues.length===0}}})},ci=ke("ZodError",BT,{Parent:Error}),HT=Lg(ci),ZT=zg(ci),WT=nh(ci),VT=sh(ci),qT=EA(ci),GT=CA(ci),KT=AA(ci),YT=$A(ci),XT=IA(ci),QT=TA(ci),JT=MA(ci),eM=RA(ci),Ty=new WeakMap;function Dc(e,t,s){const i=Object.getPrototypeOf(e);let r=Ty.get(i);if(r||(r=new Set,Ty.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=ke("ZodType",(e,t)=>(tn.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:$d(e,"input"),output:$d(e,"output")}}),e.toJSONSchema=uT(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(s,i)=>HT(e,s,i,{callee:e.parse}),e.safeParse=(s,i)=>WT(e,s,i),e.parseAsync=async(s,i)=>ZT(e,s,i,{callee:e.parseAsync}),e.safeParseAsync=async(s,i)=>VT(e,s,i),e.spa=e.safeParseAsync,e.encode=(s,i)=>qT(e,s,i),e.decode=(s,i)=>GT(e,s,i),e.encodeAsync=async(s,i)=>KT(e,s,i),e.decodeAsync=async(s,i)=>YT(e,s,i),e.safeEncode=(s,i)=>XT(e,s,i),e.safeDecode=(s,i)=>QT(e,s,i),e.safeEncodeAsync=async(s,i)=>JT(e,s,i),e.safeDecodeAsync=async(s,i)=>eM(e,s,i),Dc(e,"ZodType",{check(...s){const i=this.def;return this.clone(sa(i,{checks:[...i.checks??[],...s.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...s){return this.check(...s)},clone(s,i){return ia(this,s,i)},brand(){return this},register(s,i){return s.add(this,i),this},refine(s,i){return this.check(qM(s,i))},superRefine(s,i){return this.check(GM(s,i))},overwrite(s){return this.check(il(s))},optional(){return Py(this)},exactOptional(){return RM(this)},nullable(){return Ly(this)},nullish(){return Py(Ly(this))},nonoptional(s){return FM(this,s)},array(){return ue(this)},or(s){return Wo([this,s])},and(s){return AM(this,s)},transform(s){return zy(this,TM(s))},default(s){return LM(this,s)},prefault(s){return DM(this,s)},catch(s){return BM(this,s)},pipe(s){return zy(this,s)},readonly(){return WM(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)),MN=ke("_ZodString",(e,t)=>{Dg.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(i,r,o)=>hT(e,i,r);const s=e._zod.bag;e.format=s.format??null,e.minLength=s.minimum??null,e.maxLength=s.maximum??null,Dc(e,"_ZodString",{regex(...i){return this.check(KI(...i))},includes(...i){return this.check(QI(...i))},startsWith(...i){return this.check(JI(...i))},endsWith(...i){return this.check(eT(...i))},min(...i){return this.check(Ad(...i))},max(...i){return this.check(EN(...i))},length(...i){return this.check(CN(...i))},nonempty(...i){return this.check(Ad(1,...i))},lowercase(i){return this.check(YI(i))},uppercase(i){return this.check(XI(i))},trim(){return this.check(nT())},normalize(...i){return this.check(tT(...i))},toLowerCase(){return this.check(sT())},toUpperCase(){return this.check(iT())},slugify(){return this.check(rT())}})}),tM=ke("ZodString",(e,t)=>{Dg.init(e,t),MN.init(e,t),e.email=s=>e.check(yI(nM,s)),e.url=s=>e.check(_N(RN,s)),e.jwt=s=>e.check(zI(xM,s)),e.emoji=s=>e.check(wI(sM,s)),e.guid=s=>e.check(Cy(My,s)),e.uuid=s=>e.check(bI(Yu,s)),e.uuidv4=s=>e.check(kI(Yu,s)),e.uuidv6=s=>e.check(jI(Yu,s)),e.uuidv7=s=>e.check(NI(Yu,s)),e.nanoid=s=>e.check(SI(iM,s)),e.guid=s=>e.check(Cy(My,s)),e.cuid=s=>e.check(_I(rM,s)),e.cuid2=s=>e.check(EI(aM,s)),e.ulid=s=>e.check(CI(oM,s)),e.base64=s=>e.check(OI(fM,s)),e.base64url=s=>e.check(PI(pM,s)),e.xid=s=>e.check(AI(lM,s)),e.ksuid=s=>e.check($I(cM,s)),e.ipv4=s=>e.check(II(uM,s)),e.ipv6=s=>e.check(TI(dM,s)),e.cidrv4=s=>e.check(MI(hM,s)),e.cidrv6=s=>e.check(RI(mM,s)),e.e164=s=>e.check(LI(gM,s)),e.datetime=s=>e.check(OT(s)),e.date=s=>e.check(LT(s)),e.time=s=>e.check(DT(s)),e.duration=s=>e.check(UT(s))});function N(e){return vI(tM,e)}const dn=ke("ZodStringFormat",(e,t)=>{nn.init(e,t),MN.init(e,t)}),nM=ke("ZodEmail",(e,t)=>{w$.init(e,t),dn.init(e,t)}),My=ke("ZodGUID",(e,t)=>{j$.init(e,t),dn.init(e,t)}),Yu=ke("ZodUUID",(e,t)=>{N$.init(e,t),dn.init(e,t)}),RN=ke("ZodURL",(e,t)=>{S$.init(e,t),dn.init(e,t)});function Id(e){return _N(RN,e)}const sM=ke("ZodEmoji",(e,t)=>{_$.init(e,t),dn.init(e,t)}),iM=ke("ZodNanoID",(e,t)=>{E$.init(e,t),dn.init(e,t)}),rM=ke("ZodCUID",(e,t)=>{C$.init(e,t),dn.init(e,t)}),aM=ke("ZodCUID2",(e,t)=>{A$.init(e,t),dn.init(e,t)}),oM=ke("ZodULID",(e,t)=>{$$.init(e,t),dn.init(e,t)}),lM=ke("ZodXID",(e,t)=>{I$.init(e,t),dn.init(e,t)}),cM=ke("ZodKSUID",(e,t)=>{T$.init(e,t),dn.init(e,t)}),uM=ke("ZodIPv4",(e,t)=>{L$.init(e,t),dn.init(e,t)}),dM=ke("ZodIPv6",(e,t)=>{z$.init(e,t),dn.init(e,t)}),hM=ke("ZodCIDRv4",(e,t)=>{D$.init(e,t),dn.init(e,t)}),mM=ke("ZodCIDRv6",(e,t)=>{F$.init(e,t),dn.init(e,t)}),fM=ke("ZodBase64",(e,t)=>{U$.init(e,t),dn.init(e,t)}),pM=ke("ZodBase64URL",(e,t)=>{H$.init(e,t),dn.init(e,t)}),gM=ke("ZodE164",(e,t)=>{Z$.init(e,t),dn.init(e,t)}),xM=ke("ZodJWT",(e,t)=>{V$.init(e,t),dn.init(e,t)}),ON=ke("ZodNumber",(e,t)=>{kN.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(i,r,o)=>mT(e,i,r),Dc(e,"ZodNumber",{gt(i,r){return this.check($y(i,r))},gte(i,r){return this.check(of(i,r))},min(i,r){return this.check(of(i,r))},lt(i,r){return this.check(Ay(i,r))},lte(i,r){return this.check(af(i,r))},max(i,r){return this.check(af(i,r))},int(i){return this.check(Ry(i))},safe(i){return this.check(Ry(i))},positive(i){return this.check($y(0,i))},nonnegative(i){return this.check(of(0,i))},negative(i){return this.check(Ay(0,i))},nonpositive(i){return this.check(af(0,i))},multipleOf(i,r){return this.check(Iy(i,r))},step(i,r){return this.check(Iy(i,r))},finite(){return this}});const s=e._zod.bag;e.minValue=Math.max(s.minimum??Number.NEGATIVE_INFINITY,s.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(s.maximum??Number.POSITIVE_INFINITY,s.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(s.format??"").includes("int")||Number.isSafeInteger(s.multipleOf??.5),e.isFinite=!0,e.format=s.format??null});function oe(e){return HI(ON,e)}const vM=ke("ZodNumberFormat",(e,t)=>{q$.init(e,t),ON.init(e,t)});function Ry(e){return ZI(vM,e)}const yM=ke("ZodBoolean",(e,t)=>{G$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>fT(e,s,i)});function ve(e){return WI(yM,e)}const bM=ke("ZodNull",(e,t)=>{K$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>pT(e,s,i)});function kM(e){return VI(bM,e)}const jM=ke("ZodUnknown",(e,t)=>{Y$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>xT()});function jp(){return qI(jM)}const NM=ke("ZodNever",(e,t)=>{X$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>gT(e,s,i)});function wM(e){return GI(NM,e)}const SM=ke("ZodArray",(e,t)=>{Q$.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>jT(e,s,i,r),e.element=t.element,Dc(e,"ZodArray",{min(s,i){return this.check(Ad(s,i))},nonempty(s){return this.check(Ad(1,s))},max(s,i){return this.check(EN(s,i))},length(s,i){return this.check(CN(s,i))},unwrap(){return this.element}})});function ue(e,t){return aT(SM,e,t)}const _M=ke("ZodObject",(e,t)=>{eI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>NT(e,s,i,r),Lt(e,"shape",()=>t.shape),Dc(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:jp()})},loose(){return this.clone({...this._zod.def,catchall:jp()})},strict(){return this.clone({...this._zod.def,catchall:wM()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(s){return xA(this,s)},safeExtend(s){return vA(this,s)},merge(s){return yA(this,s)},pick(s){return pA(this,s)},omit(s){return gA(this,s)},partial(...s){return bA(LN,this,s[0])},required(...s){return kA(zN,this,s[0])}})});function I(e,t){const s={type:"object",shape:e??{},...et(t)};return new _M(s)}const PN=ke("ZodUnion",(e,t)=>{wN.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>wT(e,s,i,r),e.options=t.options});function Wo(e,t){return new PN({type:"union",options:e,...et(t)})}const EM=ke("ZodDiscriminatedUnion",(e,t)=>{PN.init(e,t),tI.init(e,t)});function ra(e,t,s){return new EM({type:"union",options:t,discriminator:e,...et(s)})}const CM=ke("ZodIntersection",(e,t)=>{nI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>ST(e,s,i,r)});function AM(e,t){return new CM({type:"intersection",left:e,right:t})}const Oy=ke("ZodRecord",(e,t)=>{sI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>_T(e,s,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ws(e,t,s){return!t||!t._zod?new Oy({type:"record",keyType:N(),valueType:e,...et(t)}):new Oy({type:"record",keyType:e,valueType:t,...et(s)})}const Np=ke("ZodEnum",(e,t)=>{iI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(i,r,o)=>vT(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 Np({...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 Np({...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 Np({type:"enum",entries:s,...et(t)})}const $M=ke("ZodLiteral",(e,t)=>{rI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>yT(e,s,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ct(e,t){return new $M({type:"literal",values:Array.isArray(e)?e:[e],...et(t)})}const IM=ke("ZodTransform",(e,t)=>{aI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>kT(e,s),e._zod.parse=(s,i)=>{if(i.direction==="backward")throw new aN(e.constructor.name);s.addIssue=o=>{if(typeof o=="string")s.issues.push(bc(o,s.value,t));else{const l=o;l.fatal&&(l.continue=!1),l.code??(l.code="custom"),l.input??(l.input=s.value),l.inst??(l.inst=e),s.issues.push(bc(l))}};const r=t.transform(s.value,s);return r instanceof Promise?r.then(o=>(s.value=o,s.fallback=!0,s)):(s.value=r,s.fallback=!0,s)}});function TM(e){return new IM({type:"transform",transform:e})}const LN=ke("ZodOptional",(e,t)=>{SN.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>TN(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function Py(e){return new LN({type:"optional",innerType:e})}const MM=ke("ZodExactOptional",(e,t)=>{oI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>TN(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function RM(e){return new MM({type:"optional",innerType:e})}const OM=ke("ZodNullable",(e,t)=>{lI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>ET(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function Ly(e){return new OM({type:"nullable",innerType:e})}const PM=ke("ZodDefault",(e,t)=>{cI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>AT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function LM(e,t){return new PM({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():cN(t)}})}const zM=ke("ZodPrefault",(e,t)=>{uI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>$T(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function DM(e,t){return new zM({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():cN(t)}})}const zN=ke("ZodNonOptional",(e,t)=>{dI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>CT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType});function FM(e,t){return new zN({type:"nonoptional",innerType:e,...et(t)})}const UM=ke("ZodCatch",(e,t)=>{hI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>IT(e,s,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function BM(e,t){return new UM({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const HM=ke("ZodPipe",(e,t)=>{mI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>TT(e,s,i,r),e.in=t.in,e.out=t.out});function zy(e,t){return new HM({type:"pipe",in:e,out:t})}const ZM=ke("ZodReadonly",(e,t)=>{fI.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 WM(e){return new ZM({type:"readonly",innerType:e})}const VM=ke("ZodCustom",(e,t)=>{pI.init(e,t),sn.init(e,t),e._zod.processJSONSchema=(s,i,r)=>bT(e,s)});function qM(e,t={}){return oT(VM,e,t)}function GM(e,t){return lT(e,t)}const lf=ra("type",[I({type:ct("text"),text:N()}),I({type:ct("reasoning"),text:N()}),I({type:ct("image"),name:N().optional(),mediaType:N().optional(),width:oe().optional(),height:oe().optional(),attachmentId:N().optional(),bytes:oe().optional()}),I({type:ct("file"),name:N().optional(),size:oe().optional(),mediaType:N().optional()}),I({type:ct("tool-call"),callId:N(),name:N(),arguments:N()}),I({type:ct("other"),kind:N()})]),cf=I({inputTokens:oe(),outputTokens:oe(),totalTokens:oe().optional(),cacheReadTokens:oe().optional(),cacheWriteTokens:oe().optional(),reasoningTokens:oe().optional()}),Dy=I({firstChunkAt:oe().optional(),firstTokenAt:oe().optional(),lastChunkAt:oe().optional(),tokenChunks:oe()}),Fy=I({message:N(),code:N().optional()}),KM=I({kind:N(),message:N().optional()}),Uy=I({provider:N(),providerName:N(),model:N(),modelName:N()}),YM=I({from:Uy,to:Uy,reason:N(),error:N(),code:N(),sub:ve().optional()}),XM="adg-model-fallback",QM=I({kind:N(),human:ve(),summary:N().optional(),fallback:YM.optional(),childId:N().optional()}),Fn={seq:oe(),time:oe()},wp=ra("type",[I({...Fn,type:ct("turn/start"),turn:oe()}),I({...Fn,type:ct("turn/end"),turn:oe(),reason:KM}),I({...Fn,type:ct("step/start"),turn:oe(),step:oe()}),I({...Fn,type:ct("step/end"),turn:oe(),step:oe()}),I({...Fn,type:ct("user/message"),messageId:N(),content:ue(lf),origin:QM,requestId:N().optional(),replacesHistory:ve().optional()}),I({...Fn,type:ct("system/message"),turn:oe(),step:oe(),text:N()}),I({...Fn,type:ct("assistant/message"),turn:oe(),step:oe(),messageId:N(),content:ue(lf),timing:Dy,usage:cf.optional(),interrupted:ve().optional(),provider:N().optional(),model:N().optional()}),I({...Fn,type:ct("assistant/attempt"),usage:cf.optional(),turn:oe(),step:oe(),timing:Dy,error:Fy.optional()}),I({...Fn,type:ct("tool/call"),turn:oe(),step:oe(),callId:N(),name:N(),arguments:N()}),I({...Fn,type:ct("tool/result"),turn:oe(),step:oe(),callId:N(),isError:ve(),content:ue(lf),error:Fy.optional()}),I({...Fn,type:ct("request/header"),provider:N().optional(),model:N().optional(),reasoningEffort:N().optional(),toolNames:ue(N()),reason:N()}),I({...Fn,type:ct("compaction/start"),compactionId:N(),turn:oe().nullable()}),I({...Fn,type:ct("compaction/summary"),compactionId:N(),shadowedTokenCount:oe(),provider:N().optional(),model:N().optional(),usage:cf.optional()}),I({...Fn,type:ct("compaction/end"),compactionId:N(),turn:oe().nullable(),error:N().optional()}),I({...Fn,type:ct("approval/asked"),approvalId:N(),toolName:N(),callId:N().optional(),reason:N().optional()}),I({...Fn,type:ct("approval/decided"),approvalId:N(),outcome:N()}),I({...Fn,type:ct("session/title"),title:N()}),I({...Fn,type:ct("unknown"),upstreamType:N(),data:jp()})]),DN=ra("type",[I({type:ct("start"),attemptId:N(),turn:oe(),step:oe(),afterSeq:oe()}),I({type:ct("delta"),attemptId:N(),time:oe(),kind:Ie(["text","reasoning","tool-args"]),index:oe(),text:N(),callId:N().optional(),toolName:N().optional()}),I({type:ct("end"),attemptId:N(),outcome:Ie(["committed","abandoned"]),seq:oe().optional()})]),JM=I({attemptId:N(),turn:oe(),step:oe(),afterSeq:oe(),deltas:ue(DN.options[1])}),eR=I({index:oe().int().min(0),name:N(),running:ve(),ready:ve(),adb:N().optional()}),tR=I({kind:Ie(["mumu"]),name:N(),manager:N(),version:N().optional(),instances:ue(eR),error:N().optional()}),nR=I({package:N(),label:N().optional(),client:N().optional(),reason:N(),score:oe(),icon:I({mediaType:N(),data:N()}).optional()}),FN=I({mumuManager:N().optional(),instance:oe().int().min(0).max(63),manualAddress:N().regex(/^[\w.-]+:\d{1,5}$/).optional(),adbPath:N().optional(),autoStart:ve(),bootTimeoutSeconds:oe().int().min(30).max(900)});I({providers:ue(tR),settings:FN,selection:I({label:N(),address:N().optional(),problem:N().optional()})});I({refresh:ve().optional()}),I({index:oe().int().min(0).optional()}),I({address:N(),label:N()}),I({index:oe().int().min(0).optional()}),I({}),FN.partial().extend({mumuManager:N().nullable().optional(),manualAddress:N().regex(/^[\w.-]+:\d{1,5}$/).nullable().optional(),adbPath:N().nullable().optional()});I({});const Fg=Ie(["maafw-pi","cli","gui-config","generic-process","visual"]),_t=N().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/,"use lowercase letters, digits, dot, dash or underscore (max 64)"),ac=N().trim().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,"use owner/repo"),uf=N().trim().regex(/^[A-Za-z0-9_.-]{1,100}$/,"use the resource id, e.g. MAA or BGI"),sR=ra("kind",[I({kind:ct("github"),repo:N()}),I({kind:ct("mirrorchyan"),rid:N(),platform:ve(),os:ve().optional(),arch:ve().optional()}),I({kind:ct("local"),path:N()})]),iR=I({version:N(),dir:N(),installedAt:oe(),asset:I({name:N(),size:oe()}).optional(),current:ve()}),rR=Ie(["ok","missing","outdated","unknown","unsupported"]),aR=I({kind:N(),label:N(),required:N().optional(),status:rR,found:N().optional(),detail:N().optional(),fix:I({kind:Ie(["auto","installer","manual"]),description:N(),needsAdmin:ve()}).optional()}),oR=I({checkedAt:oe(),ok:ve(),items:ue(aR)}),lR=I({executables:ue(N()),markers:ue(N()),family:Fg.optional()}),By=Ie(["install","pack","known","user"]),cR=I({github:I({repo:N(),from:By}).optional(),mirrorchyan:I({rid:N(),from:By}).optional()}),uR=I({version:N(),from:N()}),dR=I({state:Ie(["running","done","failed"]),at:oe(),text:N().optional(),sessionId:N().optional()}),hR=I({id:N(),name:N(),source:sR,packId:N().optional(),family:Fg.optional(),current:N().optional(),dir:N().optional(),versions:ue(iR),env:oR.optional(),probe:lR.optional(),update:I({latest:N(),available:ve(),checkedAt:oe()}).optional(),channels:cR,known:N().optional(),localVersion:uR.optional(),undo:I({from:N().optional(),to:N(),at:oe()}).optional(),jobId:N().optional(),addedAt:oe(),summary:dR.optional(),packReview:I({from:N().optional(),to:N()}).optional(),optimize:I({runs:oe(),at:oe().optional(),due:Ie(["runs","updated"]).optional()}).optional()}),mR=I({id:N(),name:N(),description:N().optional(),repo:N().optional(),mirrorchyan:N().optional(),family:Fg.optional(),builtin:ve(),installed:ve(),own:ve().optional(),error:N().optional()}),fR=I({packId:N(),name:N(),builtin:ve(),written:ve(),overview:N().optional(),tasks:ue(I({id:N(),title:N(),description:N().optional(),utterances:ue(N()),input:Ie(["desktop","window","adb","none"]),expectedDuration:N().optional(),params:ue(I({name:N(),type:Ie(["string","integer","number","boolean"]),description:N().optional(),default:N().optional(),values:N().optional()}))})),setup:ue(N()),checks:ue(N()),features:ue(I({title:N(),description:N().optional(),enable:N(),config:ue(I({file:N(),key:N(),value:N()})),tasks:ue(N())})),config:ue(I({file:N(),about:N().optional(),keys:ue(I({key:N(),meaning:N(),values:N().optional(),default:N().optional(),advice:N().optional()})),changes:ue(I({key:N(),value:N(),note:N().optional(),when:N().optional(),tasks:ue(N())}))})),troubleshooting:ue(I({problem:N(),cause:N().optional(),fix:N()}))});I({rid:N(),version:N(),platform:ve(),os:ve().optional(),arch:ve().optional(),name:N().optional(),description:N().optional(),repo:N().optional()});const Sp=I({rid:N(),name:N(),description:N(),repo:N().optional(),url:N().optional(),installed:ve(),known:ve()}),pR=I({id:N(),name:N(),repo:N().optional(),mirrorchyan:N().optional(),installed:ve()}),gR=I({name:N(),size:oe(),downloadUrl:N(),digest:N().optional()}),xR=I({tag:N(),name:N(),prerelease:ve(),publishedAt:N().optional(),url:N().optional(),assets:ue(gR),suggestedAsset:N().optional(),notes:N().optional()}),vR=Ie(["queued","resolving","downloading","verifying","extracting","checking","running","done","failed","cancelled"]),yR=I({sessionId:N(),taskId:N().optional(),state:Ie(["running","failed"]),reason:N().optional()}),bR=I({scriptId:N(),name:N(),kind:Ie(["nsis","inno","kachina"]),version:N(),dir:N(),update:ve(),at:oe(),agent:yR.optional()}),kR=I({id:N(),kind:Ie(["install","update","env-fix"]),scriptId:N(),phase:vR,message:N().optional(),received:oe().optional(),total:oe().optional(),version:N().optional(),error:N().optional(),setup:I({kind:Ie(["nsis","inno","kachina"]),dir:N(),sessionId:N().optional()}).optional(),startedAt:oe(),endedAt:oe().optional()}),jR=Ie(["auto","ask","off"]),Hy=I({apiBase:Id({protocol:/^https?$/}),downloadMirror:N().trim().max(300),mirrorFallback:ve(),tokenRef:N().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),keepVersions:oe().int().min(1).max(10),includePrereleases:ve(),cdkRef:N().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),autoUpdate:jR});I({});const NR=I({name:N(),source:Ie(["pack","discovered"]),transport:Ie(["stdio","http","sse"]),target:N(),file:N().optional(),needsRunning:ve(),description:N().optional(),problem:N().optional(),trusted:ve(),connected:ve()}),wR=I({name:N(),description:N(),path:N(),problem:N().optional(),imported:I({name:N(),current:ve(),changed:ve()}).optional()});I({id:_t});I({scripts:ue(hR),packs:ue(mR),known:ue(pR),setups:ue(bR).default([]),toolsDir:N()}),I({guide:fR.nullable()}),I({icon:I({mediaType:N(),data:N()}).optional()}),I({query:N().trim().min(1).max(200)}),I({items:ue(I({repo:N(),description:N().optional(),stars:oe(),packId:N().optional()}))}),I({repo:ac,limit:oe().int().min(1).max(30).optional()}),I({repo:N(),packId:N().optional(),releases:ue(xR)}),I({repo:ac.optional(),mirrorchyan:uf.optional(),tag:N().min(1).max(200).optional(),asset:N().min(1).max(300).optional(),branch:N().min(1).max(200).optional(),id:_t.optional()}).refine(e=>e.repo===void 0!=(e.mirrorchyan===void 0),"give either repo or mirrorchyan"),I({jobId:N(),scriptId:N()}),I({current:N().optional(),latest:N(),available:ve()}),I({jobId:N().optional(),upToDate:ve()}),I({id:_t,repo:ac.nullable().optional(),mirrorchyan:uf.nullable().optional(),reset:ue(Ie(["repo","mirrorchyan"])).optional()}),I({items:ue(Sp.extend({by:Ie(["repo","name"])})),from:Ie(["mirrorchyan","builtin"])}),I({rid:uf}),I({query:N().trim().max(100)}),I({items:ue(Sp),from:Ie(["mirrorchyan","builtin"]),fetchedAt:oe().optional()}),I({id:N(),decision:Ie(["check","keep"])}),I({sessionId:N().optional()}),I({id:_t,version:N().optional()}),I({dir:N()}),I({sessionId:N()}),I({path:N().trim().min(1).max(1e3),id:_t.optional(),name:N().trim().min(1).max(100).optional(),packId:_t.optional()}),I({id:_t,decision:Ie(["run","keep"])}),I({sessionId:N().optional()}),I({id:_t}),I({sessionId:N()}),I({id:_t,deleteFiles:ve().optional()}),I({id:N().min(1)}),I({servers:ue(NR),usage:N().optional(),note:N().optional(),skills:ue(wR)}),I({id:_t,server:N().min(1).max(32)}),I({ok:ve(),tools:ue(I({name:N(),title:N().optional(),description:N().optional()})).optional(),server:I({name:N(),version:N()}).optional(),error:N().optional()}),I({id:_t,names:ue(N().min(1).max(200)).max(50).optional()}),I({imported:ue(I({skill:N(),name:N(),replaced:ve()})),skipped:ue(I({skill:N(),reason:N()}))}),I({id:_t,kind:N().min(1).max(64)}),I({jobId:N()}),I({items:ue(kR)}),I({jobId:N()}),Hy.extend({tokenConfigured:ve(),cdkConfigured:ve()}),I({ok:ve(),message:N(),expiresAt:oe().optional()}),Hy.partial();I({id:N().optional()});const SR=I({packId:N(),scriptId:N(),proposedAt:oe(),sessionId:N().optional(),summary:N(),docs:ue(I({source:N(),used:N()})).optional(),noDocs:N().optional(),manifest:N(),skill:N(),current:I({manifest:N(),skill:N().optional(),builtin:ve()}).optional(),tasks:ue(I({id:N(),title:N()}))}),_R=I({id:N(),at:oe().optional(),builtin:ve().optional(),tasks:ue(I({id:N(),title:N()}))});I({packId:_t}),I({items:ue(_R)}),I({packId:_t,version:N().min(1).max(64)}),I({}),I({scriptId:_t.optional()}),I({items:ue(SR)}),I({packId:_t}),I({packId:N(),dir:N()}),I({packId:_t}),I({});I({packId:N().optional()});const ER=I({scriptId:N(),dir:N(),grantedAt:oe(),expiresAt:oe()});I({}),I({items:ue(ER),blocked:oe()}),I({scriptId:_t,minutes:oe().int().min(1).max(240)}),I({scriptId:_t}),I({});I({}),I({toolName:N(),target:N(),sessionId:N().optional(),at:oe()});const CR=Ie(["error","warning","failed","stalled","overtime"]),AR=I({at:oe(),action:Ie(["reconnect-adb","restart","stop","screenshot","notify","resolve","intervene"]),by:Ie(["rule","user","agent"]),ok:ve(),detail:N()}),$R=I({id:N(),runId:N(),scriptId:N(),scriptName:N(),taskId:N(),taskTitle:N(),kind:CR,severity:Ie(["warning","error"]),tag:N(),title:N(),detail:N(),lines:ue(N()),status:Ie(["open","resolved"]),resolution:N().optional(),createdAt:oe(),updatedAt:oe(),steps:ue(AR),screenshot:ve()}),IR=I({seconds:oe().int().min(5).max(24*3600),by:Ie(["learned","agent","user"]),note:N().max(300).optional(),samples:ue(oe().min(0)).max(10).default([]),at:oe()}),TR=I({defaultStallSeconds:oe().int().min(0).max(24*3600),scriptStall:Ws(N(),IR),notifyWarnings:ve(),screenshot:ve(),intervene:Ie(["off","diagnose","act"]),interventionsPerDay:oe().int().min(0).max(200)});I({status:Ie(["open","all"]).optional(),runId:N().optional(),limit:oe().int().min(1).max(500).optional()}),I({items:ue($R)}),I({incidentId:N(),action:Ie(["stop","retry","resolve","resume"])}),I({incidentId:N()}),I({mime:ct("image/png"),data:N()}),I({}),TR.partial();const MR="ADG_FEISHU_APP_SECRET",RR="ADG_QQBOT_APP_SECRET",_p=I({id:N(),label:N(),ok:ve().nullable(),detail:N().optional()}),OR=I({id:N(),name:N(),state:Ie(["off","connecting","ready","error"]),detail:N().optional(),recipients:oe().int().min(0),checks:ue(_p)}),PR=I({openId:N().min(1),name:N().optional(),addedAt:oe()}),LR=I({enabled:ve(),appId:N().optional(),domain:Ie(["feishu","lark"]),allowedUsers:ue(PR),chatId:N().optional(),otherApprovals:ve()}),zR=I({openId:N(),at:oe(),text:N()});I({settings:LR,secretConfigured:ve(),pending:ue(zR)});const DR=I({openId:N().min(1),name:N().optional(),addedAt:oe()}),FR=I({enabled:ve(),appId:N().optional(),allowedUsers:ue(DR)}),UR=I({openId:N(),at:oe(),text:N()});I({settings:FR,secretConfigured:ve(),pending:ue(UR)});const UN=I({id:N(),title:N(),text:N(),severity:Ie(["info","success","warning","error"]),at:oe(),actions:ue(I({id:N(),label:N(),style:Ie(["primary","danger","default"]).optional()})),channels:ue(N()),image:ve().optional(),done:N().optional(),acted:I({by:N(),label:N(),result:N(),at:oe()}).optional()});I({}),I({channels:ue(OR)}),I({}),I({items:ue(I({sessionId:N(),channel:N(),user:N()}))}),I({}),I({items:ue(UN)}),I({noticeId:N(),actionId:N()}),I({result:N()}),I({channel:N().optional()}),I({sent:ue(N()),failed:ue(I({channel:N(),error:N()}))}),I({}),I({enabled:ve().optional(),appId:N().trim().regex(/^cli_[0-9a-fA-F]{16}$/,"App ID 是 cli_ 加 16 位字母数字,在「凭证与基础信息」里复制").nullable().optional(),domain:Ie(["feishu","lark"]).optional(),chatId:N().trim().regex(/^oc_[A-Za-z0-9]+$/,"群 ID 以 oc_ 开头").nullable().optional(),otherApprovals:ve().optional()}),I({openId:N().trim().regex(/^ou_[A-Za-z0-9]+$/,"open_id 以 ou_ 开头"),name:N().max(40).optional()}),I({openId:N()}),I({}),I({checks:ue(_p)}),I({}),I({enabled:ve().optional(),appId:N().trim().regex(/^\d{6,20}$/,"AppID 是一串数字,在 QQ 开放平台「开发设置」里复制").nullable().optional()}),I({openId:N().trim().regex(/^[0-9A-Za-z_-]{8,64}$/,"user_openid 是一串字母数字(机器人回复你的那条消息里有)"),name:N().max(40).optional()}),I({openId:N()}),I({}),I({checks:ue(_p)});I({}),I({item:UN});const Ia=N().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,"小写字母、数字和短横线").max(64),kc=N().regex(/^[A-Za-z0-9_-]{1,40}$/),Ug=N().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"时间写成 HH:MM,例如 04:30"),BN=I({retries:oe().int().min(0).max(5).default(0),then:Ie(["continue","stop"]).default("continue")}),Na={id:kc,title:N().max(60).optional(),position:I({x:oe(),y:oe()}).optional(),onFailure:BN.optional(),waitForAll:ve().optional()},BR=ra("kind",[I({...Na,kind:ct("script-task"),scriptId:_t,taskId:N().min(1).max(64),params:Ws(N(),Wo([N(),oe(),ve()])).default({}),profile:N().min(1).max(64).optional()}),I({...Na,kind:ct("agent"),prompt:N().min(1).max(4e3)}),I({...Na,kind:ct("wait"),minutes:oe().int().min(1).max(1440).optional(),until:Ug.optional()}).refine(e=>e.minutes===void 0!=(e.until===void 0),"等待节点写分钟数或时间其中一个"),I({...Na,kind:ct("notify"),text:N().min(1).max(2e3)}),I({...Na,kind:ct("gate"),text:N().min(1).max(2e3)}),I({...Na,kind:ct("start")}),I({...Na,kind:ct("end")})]);function Wi(e){return e.kind==="start"||e.kind==="end"}function HR(e){const t=e.nodes.some(g=>g.kind==="start"),s=e.nodes.some(g=>g.kind==="end");if(t&&s)return e;const i=e.nodes.filter(g=>!Wi(g)),r=new Set(e.nodes.map(g=>g.id)),o=g=>{let x=g;for(let k=2;r.has(x);k++)x=`${g}${k}`;return r.add(x),x},l=i.filter(g=>g.position!==void 0).map(g=>g.position),u=Math.min(...l.map(g=>g.x)),d=Math.max(...l.map(g=>g.x)),h=l.length===0?40:Math.round(l.reduce((g,x)=>g+x.y,0)/l.length),m=[...e.nodes],p=[...e.edges];if(!t){const g=o("start");m.unshift({id:g,kind:"start",...l.length===0?{}:{position:{x:u-240,y:h}}});for(const x of i)e.edges.some(k=>k.to===x.id)||p.push({from:g,to:x.id,when:"success"})}if(!s){const g=o("end");m.push({id:g,kind:"end",...l.length===0?{}:{position:{x:d+300,y:h}}});for(const x of i)e.edges.some(k=>k.from===x.id)||p.push({from:x.id,to:g,when:"always"})}return{...e,nodes:m,edges:p}}const ZR=I({from:kc,to:kc,when:Ie(["success","failure","always"]).default("success")}),Bg=I({enabled:ve().default(!1),times:ue(Ug).max(12).default([]),days:ue(oe().int().min(0).max(6)).max(7).default([]),catchUpMinutes:oe().int().min(0).max(720).default(10),after:Ia.optional()}),WR=["日","一","二","三","四","五","六"],VR=[1,2,3,4,5,6,0];function Hg(e){return e.enabled?e.times.length===0?e.after===void 0?"没有设时间":`「${e.after}」跑完后`:`${e.days.length===0||e.days.length===7?"每天":`每周${VR.filter(s=>e.days.includes(s)).map(s=>WR[s]).join("、")}`} ${[...e.times].sort().join("、")}`:"已暂停"}I({kind:Ie(["task","reminder"]),id:N().optional(),by:N(),agent:N(),title:N(),when:N(),changed:ve()});const HN=Ie(["none","sleep","hibernate","shutdown"]),df=I({id:Ia,name:N().min(1).max(60),description:N().max(500).optional(),nodes:ue(BR).max(60),edges:ue(ZR).max(200).default([]),onFailure:BN.default({retries:0,then:"continue"}),schedule:Bg.default({enabled:!1,times:[],days:[],catchUpMinutes:10}),stopEmulatorAfter:ve().default(!1),closeGameAfter:ve().default(!1),powerAfter:HN.default("none"),draft:ve().optional(),createdAt:oe().optional(),updatedAt:oe().optional()}),qR=I({level:Ie(["error","warning","info"]),nodeId:N().optional(),message:N()}),GR=I({ok:ve(),issues:ue(qR),serialized:ue(I({a:N(),b:N(),resource:N()})),estimateMinutes:oe().optional()}),KR=Ie(["pending","waiting","running","succeeded","failed","skipped","cancelled"]),YR=I({state:KR,detail:N().optional(),repair:I({runId:N(),state:Ie(["succeeded","failed","cancelled"]),at:oe()}).optional(),runIds:ue(N()),attempts:oe().int().min(0),startedAt:oe().optional(),endedAt:oe().optional()}),ZN=I({kind:Ie(["manual","schedule","autostart","agent","after"]),detail:N().optional()}),WN=I({id:N(),pipelineId:N(),pipelineName:N(),trigger:ZN,from:N().optional(),state:Ie(["running","succeeded","failed","cancelled"]),stopping:N().optional(),nodes:Ws(N(),YR),startedAt:oe(),endedAt:oe().optional(),outcome:N().optional()}),XR=I({id:N(),name:N(),description:N().optional(),nodes:oe(),draft:ve(),schedule:Bg,updatedAt:oe().optional(),lastRun:WN.pick({id:!0,state:!0,startedAt:!0,endedAt:!0}).optional()}),Yl=N().regex(/^task-[a-z0-9]{4,24}$/),Zy=I({id:Yl,agent:N().min(1).max(64),title:N().trim().min(1).max(60),prompt:N().trim().min(1).max(4e3),schedule:Bg,createdAt:oe().optional(),updatedAt:oe().optional()}),Wy=I({id:N(),taskId:N(),trigger:ZN,state:Ie(["running","done","failed"]),outcome:N().optional(),startedAt:oe(),endedAt:oe().optional()}),VN=I({autostart:ve(),autostartPipelines:ue(Ia),autostartDelaySeconds:oe().int().min(0).max(1800),skipIfRanToday:ve(),firstStartOnly:ve().default(!1),wakeToRun:ve().default(!1),powerCountdownSeconds:oe().int().min(10).max(600).default(60)}),qN={agent:N().optional()},QR=I({pipelineId:N(),pipelineName:N(),...qN,slot:N(),at:oe(),outcome:Ie(["fired","missed","skipped","failed"]),detail:N().optional()}),JR=I({awake:ve(),pending:I({action:HN.exclude(["none"]),pipelineName:N(),at:oe().optional()}).optional()});I({settings:VN,autostart:I({available:ve(),registered:ve(),detail:N().optional()}),autostarted:ve(),wake:I({available:ve(),registered:ve(),next:oe().optional(),detail:N().optional()}),power:JR,upcoming:ue(I({pipelineId:N(),pipelineName:N(),at:oe(),...qN})),history:ue(QR)});I({}),I({items:ue(XR)}),I({id:Ia}),I({pipeline:df}),I({pipeline:df,check:GR}),I({id:Ia}),I({}),I({pipeline:df}),I({id:Ia,from:kc.optional()}),I({runId:N()}),I({}),I({pipelineId:Ia.optional(),limit:oe().int().min(1).max(100).optional()}),I({items:ue(WN)}),I({runId:N(),nodeId:kc,decision:Ie(["continue","stop"])}),I({}),I({}),VN.partial(),I({}),I({}),I({agent:N().optional()}),I({items:ue(Zy.extend({lastRun:Wy.optional()}))}),I({task:Zy.extend({id:Yl.optional()})}),I({id:Yl}),I({}),I({id:Yl}),I({id:Yl}),I({items:ue(Wy)});I({}),I({}),I({});const e2=Ie(["running","resolved","retried","gave-up","taken-over","timeout","failed"]),t2=I({id:N(),incidentId:N().optional(),runId:N().optional(),title:N(),mode:Ie(["diagnose","act"]),state:e2,sessionId:N().optional(),paused:ve(),summary:N().optional(),startedAt:oe(),endedAt:oe().optional()});I({limit:oe().int().min(1).max(100).optional()}),I({items:ue(t2)}),I({id:N()}),I({id:N(),then:Ie(["resume","restart","stop"])});const GN=I({id:N(),game:N(),title:N(),kind:Ie(["update","notice","news"]),publishedAt:oe().optional(),version:N().optional(),summary:N().optional(),url:N().optional(),cover:N().optional(),lasting:ve().optional(),source:I({id:N(),name:N()}),at:oe()}),n2=ue(ra("type",[I({type:ct("text"),text:N()}),I({type:ct("image"),url:Id({protocol:/^https$/})})]));GN.extend({article:n2.optional()});const Vy=I({id:N(),game:N(),name:N(),startsAt:oe().optional(),endsAt:oe().optional(),shopEndsAt:oe().optional(),url:N().optional(),kind:N().optional(),description:N().optional(),cover:N().optional(),site:I({source:N(),name:N(),at:oe()}).optional(),sources:ue(I({id:N(),name:N(),at:oe(),web:ve(),url:N().optional(),startsAt:oe().optional(),endsAt:oe().optional(),shopEndsAt:oe().optional(),cover:N().optional()})).optional(),chosen:N().optional(),shown:I({cover:N().optional(),startsAt:N().optional(),endsAt:N().optional()}).optional(),screen:I({at:oe(),remaining:N().optional(),endsAt:oe().optional(),evidence:ve(),image:N().optional(),sessionId:N().optional()}).optional(),todo:ue(N()),done:ue(N()),progress:N().optional(),finished:I({at:oe()}).optional(),mismatch:N().optional(),own:I({at:oe(),fields:ue(Ie(["name","startsAt","endsAt","kind","description","url","cover"])),startsAt:oe().optional(),endsAt:oe().optional(),cover:N().optional()}).optional()}),$o="@own",oc="@screen",s2=112e5,qy=I({mediaType:Ie(["image/png","image/jpeg","image/gif","image/webp","image/avif"]),data:N().min(1).max(s2).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix")}),i2=/^own:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,r2=/^shot:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,a2=I({id:N(),name:N(),homepage:N().optional(),auto:ve(),added:ve().optional()}),Gy=I({state:Ie(["queued","running","done","partial","failed","cancelled"]),at:oe(),sessionId:N().optional(),taskId:N().optional(),scope:N().optional(),remainingUrls:ue(N()).optional(),summary:N().optional()}),KN=I({id:N(),name:N(),period:Ie(["daily","weekly","event"]),description:N().optional(),from:N(),links:ue(N()),done:I({at:oe(),by:Ie(["log","task","agent","user"]),detail:N().optional(),script:N().optional(),runId:N().optional()}).optional(),resetsAt:oe().optional(),activities:ue(N()).optional()}),o2=I({id:N(),name:N(),aliases:ue(N()),scripts:ue(N()),timezone:N(),screen:I({target:Ie(["emulator","window"]),window:N().optional()}).optional(),sources:ue(a2),builtin:ve(),art:N().optional(),banner:N().optional(),followed:ve().optional(),sra:ue(N()).optional(),own:ve().optional(),single:ve().optional(),version:I({name:N(),title:N().optional(),startsAt:oe().optional(),endsAt:oe().optional(),cover:N().optional(),source:N(),at:oe()}).optional(),pools:ue(I({name:N(),type:N().optional(),startsAt:oe().optional(),endsAt:oe(),cover:N().optional(),up:ue(N())})).optional(),routines:ue(KN).optional(),hiddenRoutines:oe().optional(),resets:I({daily:oe(),weekly:oe()}).optional(),refreshed:I({at:oe(),ok:ve(),count:oe(),detail:N().optional()}).optional(),reading:Gy.optional(),webReading:Gy.optional()}),Ky=I({report:I({enabled:ve(),at:Ug,games:ue(N()),soonDays:oe().int().min(1).max(30),ai:ve()}),followed:ue(N()),hidden:ue(N()).optional()}),l2=I({lastSentAt:oe().optional(),lastDay:N().optional(),lastResult:N().optional(),lastText:N().optional(),next:oe().optional()});I({}),I({games:ue(o2),activities:ue(Vy),notices:ue(GN).default([]),settings:Ky,report:l2}),I({game:N(),noticeId:N()}),I({game:N().optional()}),I({results:ue(I({game:N(),ok:ve(),count:oe(),notices:oe().optional(),detail:N().optional()}))}),I({game:N(),how:Ie(["screen","web"]).optional(),source:N().optional()}),I({sessionId:N()}),I({taskId:N()}),I({cancelled:ve()}),I({}),I({title:N(),text:N()}),I({}),I({channels:ue(N()),text:N()}),I({report:Ky.shape.report.partial().optional()}),I({activityId:N()}),I({mediaType:N(),data:N()}),I({url:N().refine(e=>i2.test(e)||r2.test(e)||/^https?:\/\/\S+$/.test(e),"不是图片地址")}),I({mediaType:N(),data:N()}),I({game:N().min(1)}),I({icon:I({mediaType:N(),data:N()}).optional()}),I({scriptId:N().min(1)}),I({device:N(),installed:oe().int(),candidates:ue(nR)}),I({package:N().min(1)}),I({label:N().optional(),icon:I({mediaType:N(),data:N()}).optional()}),I({name:N().trim().min(1).max(60)}),I({game:N()}),I({game:N()}),I({}),I({game:N()}),I({sessionId:N()}),I({game:N()}),I({items:ue(Sp),from:Ie(["mirrorchyan","builtin"])}),I({game:N(),url:N().url().refine(e=>/^https?:\/\//.test(e),"只能是 http 或 https 网址"),name:N().max(30).optional()}),I({source:N(),sessionId:N()}),I({game:N(),source:N()}),I({}),I({}),I({games:ue(I({sra:N(),name:N(),followed:ve(),pack:N().optional()}))}),I({sra:N(),follow:ve()}),I({}),I({game:N(),routine:N(),done:ve()}),I({}),I({game:N(),name:N().trim().min(1).max(40),period:Ie(["daily","weekly"])}),I({routine:KN}),I({game:N(),routine:N().optional(),restore:ve().optional()}),I({}),I({activityId:N(),todo:ue(N().min(1).max(80)).max(30).optional(),done:ue(N().min(1).max(80)).max(30).optional(),finished:ve().optional()}),I({game:N().min(1),image:qy.optional(),path:N().trim().min(1).max(1e3).optional()}).refine(e=>e.image===void 0||e.path===void 0,"图片和路径只能给一个"),I({banner:N().optional()}),I({game:N(),activityId:N().optional(),name:N().trim().min(1).max(60).nullable().optional(),startsAt:oe().nullable().optional(),endsAt:oe().nullable().optional(),kind:N().trim().max(20).nullable().optional(),description:N().trim().max(500).nullable().optional(),url:N().trim().refine(e=>e===""||/^https?:\/\/\S+$/.test(e),"只能是 http 或 https 网址").nullable().optional(),cover:kM().optional(),image:qy.optional(),todo:ue(N().min(1).max(80)).max(30).optional()}),I({activityId:N(),source:N().nullable()}),I({activityId:N()}),I({activity:Vy.optional()}),I({activityId:N()}),I({});I({game:N().optional()});const YN=Ie(["ask","full"]),XN=Ie(["default","allow","ask","deny"]),c2=[{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}];I({mode:YN,since:oe().optional(),areas:Ws(N(),XN).default({}),recent:ue(I({at:oe(),sessionId:N(),toolName:N(),reason:N().optional()}))});I({}),I({mode:YN}),I({area:N(),policy:XN});const u2=I({label:N(),description:N().optional()}),d2=I({id:N(),question:N(),detail:N().optional(),header:N().optional(),options:ue(u2).optional(),multiSelect:ve().optional()});I({questionId:N(),sessionId:N(),callId:N().optional(),questions:ue(d2)});const QN=I({id:N(),selected:ue(N()),custom:N().optional()}),h2=Ie(["answered","cancelled","unavailable"]);I({questionId:N(),answers:ue(QN)}),I({});I({questionId:N(),outcome:h2,answers:ue(QN).optional()});const m2=I({pid:oe().int(),label:N(),dataDir:N().optional(),startedAt:oe(),warnings:ue(N())});I({others:ue(m2)});I({});const Zg=I({scripts:ue(N()).optional(),games:ue(N()).optional()}),Yy=I({name:N(),description:N(),whenToUse:N().optional(),source:N(),provider:N(),path:N().optional(),modelInvocable:ve(),userInvocable:ve(),owner:Zg.optional(),removable:ve().optional(),kind:Ie(["script-pack","game-pack"]).optional(),pack:N().optional(),ownPack:ve().optional()}),JN=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Ep=48;I({}),I({skills:ue(Yy)}),I({name:N()}),Yy.extend({content:N()}),I({name:N().regex(JN).max(Ep),description:N().trim().min(10).max(400),content:N().trim().min(20).max(2e4),scripts:ue(N().min(1).max(64)).max(20).optional(),games:ue(N().min(1).max(64)).max(20).optional(),replace:ve().optional()}),I({name:N(),replaced:ve()}),I({sessionId:N()}),Zg.required(),I({name:N()}),I({});I({}),I({sessionId:N(),scripts:ue(N()),games:ue(N())});const hf=I({repo:ac,branch:N().trim().min(1).max(100).regex(/^[\w./-]+$/)}),Xy=I({name:N(),description:N(),title:N().optional(),kind:Ie(["game","script","general"]),pack:Ie(["script","game"]).optional(),game:N().optional(),sra:ue(N()).optional(),default:ve().optional(),games:ue(N()),scripts:ue(N()),repo:N(),author:N().optional(),path:N(),hash:N(),version:N().optional(),changes:N().optional(),requires:N().optional(),history:ue(I({version:N(),changes:N().optional()})).optional(),installed:I({at:oe(),update:ve(),version:N().optional(),previous:I({version:N().optional(),at:oe()}).optional(),held:ve().optional()}).optional(),incompatible:N().optional(),blocked:N().optional()}),Xu=I({name:N().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});I({refresh:ve().optional()}),I({items:ue(Xy),repos:ue(hf),errors:ue(N()),fetchedAt:oe().optional()}),I({content:N()}),Xu.extend({description:N().trim().min(10).max(400),content:N().trim().min(20).max(2e4)}),I({}),Xu.extend({repo:ac.optional()}),I({state:Ie(["current","updated"]),item:Xy}),Xu.extend({version:N().min(1).max(40)}),I({}),Xu.extend({owner:Zg.nullable()}),I({}),I({repos:ue(hf).min(1).max(10)}),I({repos:ue(hf)});I({});const Wg="你",ew="(不用告诉用户)",Qy=e=>e.replace(/[^\p{Script=Han}a-zA-Z0-9]/gu,"");function f2(e){return Qy(e)===Qy(ew)}const p2="(你这一轮的最后一段回复会作为结论交回去。在那之前要让对方知道的,用 agent_message 的 update 说,马上送到,说几次都行;交回结论以后还有话,同样发到这条线索:你的普通回复对方看不到。)",g2="(做完后你这一轮的最后一段回复会原样交回去:把结论写在那里。)",x2=/^(这件事的线索是 (\S+):做的过程中要问清楚什么,用 agent_message 问,thread 填它;不要猜。)$/,v2=/^(你和.{1,20}之前的来往,/,y2=")";function tw(e){var m;const[t="",...s]=e.split(`
104
+ `),i=/^(你在软件里点的:(.*))$/.exec(t),r=i===null?/^(([^():]{1,20})交给你的事:(.*))$/.exec(t):null;if(i===null&&r===null)return;const o=s[0]===p2||s[0]===g2,l=o?s.slice(1):s,u=(m=x2.exec(l[0]??""))==null?void 0:m[1],d=u===void 0?l:l.slice(1),h=v2.test(d[0]??"")?d.indexOf(y2):-1;return{by:i!==null?Wg: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 nw(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 sw(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 b2(e){return e.replace(/\s+/g," ").replace(/[()]/g,t=>t==="("?"(":")").trim()}const Jy=/\n\n(这是你在线索 \S+ 上定的提醒:[^)]*)$/;function eb(e){const t=/^\[SCHEDULE REMINDER\]\n[\s\S]*?^reminder_prompt_json: (.*)$/m.exec(e);if(t!==null)return[j2(t[1]).replace(Jy,"")];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(Jy,"")).filter(r=>r!=="")}catch{return[]}}function k2(e){return e.length===0?"定时提醒":`定时提醒:${e.map(t=>b2(t)).join(";")}`}function j2(e){try{const t=JSON.parse(e);return typeof t=="string"?t:e}catch{return e}}const N2=Ie(["default","concise","patient","lively","buddy","butler"]),w2=Ie(["plain","same"]),iw=I({style:N2,callUser:N().max(20).optional(),custom:N().optional(),peerStyle:w2.optional()}),S2=iw.partial().extend({name:N().max(20).optional()}),_2=I({persona:iw,agents:Ws(N(),S2)});_2.extend({prompt:N(),prompts:Ws(N(),N())});const tb={default:"",concise:"回答简短直接:先给结论,再给必要的细节;少寒暄,不用表情。",patient:"耐心、讲清楚:每一步说明为什么这么做,用对方听得懂的话,像教一个刚接触的人。",lively:"语气轻松活泼,可以用一点语气词和表情,但信息要准确、不啰嗦。",buddy:"像一起玩游戏的老朋友那样说话:熟悉游戏里的说法,可以适当吐槽和鼓励,但不夸张、不油腻。",butler:"像一位稳重周到的管家:礼貌、条理清楚,主动汇报进度和需要对方决定的事。"};function nb(e,t){const s=Object.entries(e.agents[t]??{}).filter(([,i])=>i!==void 0);return{...e.persona,...Object.fromEntries(s)}}function sb(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()}」。`),tb[e.style]!==""&&t.push(tb[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(`软件约定的固定写法(比如「${ew}」这一句、线索编号、工具的参数)一字不差照写,不加语气词和表情。`),["# 回复风格",...t,"这些只影响你说话的方式,不改变做事的规则:确认、安全限制和不能做的事都照旧;在飞书里回复也一样。"].join(`
114
+ `))}I({});const E2=80,rw=5,aw=100,C2=30,A2=1,$2=365,I2=[3,7,14,30],Cp=I({auto:ve(),threshold:oe().int().min(rw).max(aw),lowContext:ve(),archiveDays:oe().int().min(A2).max($2).nullable().default(null),ptcSubagents:ve().default(!0),summarizer:I({provider:N().min(1).max(200),model:N().min(1).max(200),maxTokens:oe().int().positive().optional()}).nullable().default(null)});I({settings:Cp,applied:Cp});I({}),I({settings:Cp});const wa="shared",Ap=Ie(["profile","journal","core"]),Vg=2e3,T2=I({agent:N(),sessionId:N(),seq:oe().int().min(0)}),qg=600,mf=I({id:N(),kind:Ap,scope:N(),text:N(),createdAt:N(),updatedAt:N(),by:N(),source:T2.optional()}),M2=I({auto:ve(),model:I({provider:N(),model:N(),reasoningEffort:N().optional()}).nullable()}),ib=N().trim().min(1).max(qg);I({}),I({items:ue(mf)}),I({kind:Ap,scope:N().min(1).max(64),text:ib}),I({item:mf}),I({id:N(),text:ib,kind:Ap.optional(),scope:N().min(1).max(64).optional()}),I({item:mf}),I({}),M2.extend({forced:ve().optional()}),I({id:N()}),I({removed:ve()});I({});const R2=Ie(["starting","running","stopping","succeeded","failed","cancelled"]),O2=I({type:Ie(["string","integer","number","boolean"]),default:Wo([N(),oe(),ve()]).optional(),enum:ue(Wo([N(),oe()])).optional(),description:N().optional(),choices:ue(I({value:N(),label:N(),detail:N().optional()})).optional(),canCreate:ve().optional()}),P2=I({mode:Ie(["auto","platform","off"]),pcLaunch:Ie(["program","maaend"]).optional(),pcRegion:Ie(["CN","Global","Bilibili","TapTap","Steam","Epic"]).optional(),pcExe:N().optional(),pcProcess:N().optional(),androidPackage:N().optional()});I({settings:P2,game:I({name:N().optional(),androidPackage:N().optional(),pcProcess:N().optional(),selfLaunch:N()}),uses:I({adb:ve(),desktop:ve()})});const L2=I({id:N(),title:N(),description:N().optional(),utterances:ue(N()),params:Ws(N(),O2),input:Ie(["desktop","window","adb","none"]),account:N().optional(),expectedDuration:N().optional()}),Fi=N().trim().min(1).max(64),$p=I({id:N(),name:N(),createdAt:oe().optional()}),ow=I({current:N(),items:ue($p)}),z2=I({id:N(),scriptId:N(),scriptName:N(),taskId:N(),taskTitle:N(),params:Ws(N(),Wo([N(),oe(),ve()])),state:R2,outcome:N().optional(),startedAt:oe(),endedAt:oe().optional(),exitCode:oe().optional(),command:ue(N()),resources:ue(N()),tags:ue(N()),warnings:ue(N()),kind:Ie(["task","settings"]),retryOf:N().optional(),halted:ve().optional(),profile:N().optional(),profileName:N().optional()}),lw=I({at:oe(),source:N(),text:N(),level:Ie(["info","progress","done","warning","error"]).optional(),tag:N().optional()});I({scriptId:_t,profile:Fi.optional()}),I({tasks:ue(L2),runnable:ve(),problem:N().optional()}),I({scriptId:_t,taskId:N().min(1).max(64),params:Ws(N(),Wo([N(),oe(),ve()])).optional(),profile:Fi.optional()}),I({runId:N()}),I({}),I({scriptId:_t.optional()}),I({items:ue(z2)}),I({runId:N(),limit:oe().int().min(1).max(2e3).optional()}),I({lines:ue(lw)}),I({scriptId:_t}),I({scriptId:_t,name:N().trim().min(1).max(30),from:ra("kind",[I({kind:ct("copy"),profile:Fi}),I({kind:ct("original")}),I({kind:ct("folder"),dir:N().trim().min(1).max(500)})])}),I({profile:$p,files:ue(N()),list:ow}),I({scriptId:_t,profile:Fi,name:N().trim().min(1).max(30).optional(),current:ct(!0).optional()}),I({scriptId:_t,profile:Fi}),I({scriptId:_t,profile:Fi.optional()}),I({importedAt:oe().optional(),dir:N(),profile:$p,files:ue(I({file:N(),local:ve(),original:ve(),changed:ve()})),drift:ue(N())}),I({scriptId:_t,file:N().min(1),profile:Fi.optional()}),I({file:N(),content:N(),truncated:ve()}),I({scriptId:_t,profile:Fi.optional()}),I({imported:ue(N())}),I({scriptId:_t,profile:Fi.optional()}),I({runId:N()}),I({}),I({scriptId:_t,taskId:N().min(1),param:N().min(1),name:N().trim().min(1).max(40),profile:Fi.optional()}),I({value:N()}),I({scriptId:_t}),I({scriptId:_t,mode:Ie(["auto","platform","off"]).optional(),pcLaunch:Ie(["program","maaend"]).nullable().optional(),pcRegion:Ie(["CN","Global","Bilibili","TapTap","Steam","Epic"]).nullable().optional(),pcExe:N().trim().nullable().optional(),pcProcess:N().trim().nullable().optional(),androidPackage:N().trim().regex(/^[A-Za-z][\w]*(\.[A-Za-z_][\w]*)+$/,"安卓包名像 com.example.game").nullable().optional()}),I({scriptId:_t}),I({exe:N().optional(),candidates:ue(I({path:N(),source:N()}))});I({scriptId:N(),list:ow}),I({runId:N(),lines:ue(lw)});const D2=1,ff=N().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"credential names use letters, digits and underscores"),cw=I({configured:ve(),source:N().optional(),writable:ve()}),Ip="DEEPSEEK_API_KEY",F2=I({id:N(),version:oe().int().positive()}),uw=I({id:N(),title:N().nullable(),updatedAt:oe(),running:ve(),blank:ve(),live:ve(),cwd:N().optional(),parentId:N().optional(),origin:Ie(["subagent"]).optional(),role:N().optional(),requestedBy:N().optional(),home:N().optional()}),dw=I({id:N(),name:N(),description:N(),order:oe()}),hw=I({id:N(),requestId:N().optional(),text:N(),images:oe().int().optional(),placement:Ie(["next-turn","next-step","taken"])}),mw=I({contextWindow:oe().int().positive(),usedTokens:oe().int().nonnegative(),breakdown:I({systemTokens:oe().int().nonnegative(),toolsTokens:oe().int().nonnegative(),messageTokens:oe().int().nonnegative()}).optional()}),U2=I({id:N(),createdAt:oe(),cwd:N().optional(),parentId:N().optional(),agentPreset:N().optional()}),li=I({provider:N(),model:N(),reasoningEffort:N().optional()}),B2=I({agents:ue(li),subAgents:ue(li)});I({agents:Ws(N(),li),subAgents:li.nullable(),subAgentsOf:Ws(N(),li),fallbacks:B2.optional()});const H2=I({from:N(),kind:Ie(["question","answer","update","done"]),text:N(),at:oe()}),Tp=I({id:N(),messages:ue(H2).optional(),chain:ue(N()).optional(),parent:N().optional(),fromSession:N(),callId:N().optional(),by:N(),to:N(),toSession:N(),isolated:ve().optional(),ownerSession:N().optional(),title:N(),task:N(),expecting:N().optional(),state:Ie(["running","waiting","done","failed"]),reply:N().optional(),startedAt:oe(),endedAt:oe().optional()}),Z2=I({id:N(),agent:N(),sessionId:N(),title:N(),prompt:N(),rule:N(),repeats:ve(),next:oe()});I({default:li,groups:ue(I({id:N(),name:N(),models:ue(I({id:N(),name:N(),description:N().optional(),efforts:ue(I({id:N(),name:N()})),defaultEffort:N().optional()}))})),failures:ue(I({id:N(),name:N(),message:N()}))});const W2=I({lastUsed:li.nullable(),next:li.nullable()}),pf=Ie(["openai-completions","openai-responses","anthropic-messages"]),V2=N().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"use lowercase letters, digits and single hyphens, starting with a letter"),Mp=I({id:N().min(1),name:N().optional(),contextWindow:oe().int().positive().optional(),maxTokens:oe().int().positive().optional(),input:ue(Ie(["text","image"])).optional(),efforts:ue(N().min(1)).optional()}),q2=I({id:N(),displayName:N(),api:N().optional(),baseURL:N().optional(),models:ue(Mp),apiKeyRef:N().optional(),credential:cw.optional(),declared:ve(),active:ve(),error:N().optional()}),G2=I({available:ve(),balances:ue(I({currency:N(),total:N(),granted:N(),toppedUp:N()}))}),Rp=35e5,K2=I({mediaType:Ie(["image/png","image/jpeg","image/gif","image/webp"]),data:N().min(1).max(Rp).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix"),name:N().max(200).optional()}),Y2=I({version:N(),title:N().optional(),publishedAt:N().optional(),url:N(),body:N()});I({});I({accepted:ct(!0)});I({protocolVersion:oe().int(),client:I({name:N(),version:N()})}),I({protocolVersion:oe().int(),server:I({name:N(),version:N(),dsh:N().optional()}),capabilities:ue(F2)}),I({items:ue(uw)}),I({cwd:N().optional(),focus:I({scripts:ue(N()).optional(),games:ue(N()).optional()}).optional(),role:N().optional()}),I({sessionId:N()}),I({sessionIds:ue(N()).max(60)}),I({items:ue(I({sessionId:N(),text:N().nullable()}))}),I({items:ue(dw)}),I({agentId:N(),focus:I({scripts:ue(N()).optional(),games:ue(N()).optional()}).optional()}),I({sessionId:N()}),I({sessionId:N()}),I({items:ue(Tp)}),I({sessionId:N()}),I({a:N(),b:N()}),I({items:ue(Tp)}),I({id:N()}),I({agent:N().optional()}),I({items:ue(Z2)}),I({id:N()}),I({}),I({sessionId:N(),title:N().min(1)}),I({title:N()}),I({sessionId:N(),maxMessages:oe().int().positive().optional()}),I({subscriptionId:N(),header:U2,cursor:oe(),events:ue(wp),hasMore:ve(),title:N().nullable(),live:JM.nullable(),queue:ue(hw).optional(),context:mw.optional()}),I({subscriptionId:N()}),I({sessionId:N(),throughSeq:oe(),beforeSeq:oe(),maxMessages:oe().int().positive().optional()}),I({events:ue(wp),hasMore:ve()}),I({sessionId:N(),requestId:N(),text:N(),mode:Ie(["queue","steer"]),images:ue(K2).max(4).optional()}).refine(e=>{var t;return e.text.trim()!==""||(((t=e.images)==null?void 0:t.length)??0)>0},"消息是空的"),I({sessionId:N()}),I({sessionId:N()}),I({compacted:ve(),message:N()}),I({sessionId:N(),itemId:N(),action:Ie(["steer","remove"])}),I({attachmentId:N(),mediaType:N(),bytes:oe(),width:oe(),height:oe()}),I({mediaType:N(),data:N()}),I({path:N().min(1)}),I({mediaType:N(),data:N(),path:N()}),I({kind:Ie(["file","folder"]),title:N().max(200).optional(),defaultPath:N().max(1e3).optional(),filterName:N().max(60).optional(),extensions:ue(N().regex(/^\w+$/)).max(20).optional()}),I({path:N().optional()}),I({sessionIds:ue(N())}),I({sessionId:N()}),I({sessionIds:ue(N())}),I({sessionId:N()}),I({sessionIds:ue(N())}),I({agentId:N().optional(),sub:ve().optional(),model:li.nullable()}),I({warning:N().optional()}),I({sub:ve(),models:ue(li)}),li.extend({sessionId:N()}),I({selected:li}),I({sessionId:N()}),I({approvalId:N(),decision:Ie(["allow-once","reject"])}),I({refs:ue(ff).min(1).max(64)}),I({items:Ws(N(),cw)}),I({ref:ff,value:N().min(1).max(4096)}),I({ref:ff}),I({edition:Ie(["plugin","other"]),version:N().optional()}),I({current:N(),latest:I({version:N(),prerelease:ve(),notesUrl:N(),onNpm:ve().optional(),notes:ue(Y2).optional()}).optional(),checkedAt:oe()}),I({providers:ue(q2),revision:oe(),writable:ve(),protocols:ue(pf),taken:ue(N())}),I({provider:N().optional(),baseURL:Id({protocol:/^https?$/}).optional(),api:pf.optional(),apiKey:N().min(1).max(4096).optional()}),I({models:ue(Mp)}),I({provider:N().min(1)}),I({balance:G2.nullable()}),I({id:V2,create:ve(),displayName:N().max(80).optional(),api:pf,baseURL:Id({protocol:/^https?$/}),models:ue(Mp).min(1),apiKey:N().min(1).max(4096).optional(),expectedRevision:oe().optional()}),I({revision:oe(),apiKeyRef:N().optional()}),I({id:N().min(1),removeKey:ve().optional(),expectedRevision:oe().optional()}),I({revision:oe(),defaultReset:ve()});ra("kind",[I({kind:ct("upsert"),item:uw.partial().extend({id:N()})}),I({kind:ct("removed"),sessionId:N()})]);I({approvalId:N(),sessionId:N(),toolName:N(),callId:N().optional(),reason:N().optional(),displayReason:Ws(N(),N()).optional()});I({subscriptionId:N(),event:wp}),I({subscriptionId:N(),frame:DN}),I({subscriptionId:N(),reason:N()}),I({sessionId:N(),title:N().nullable()}),I({sessionId:N(),message:N()}),I({sessionId:N(),items:ue(hw)}),I({sessionId:N(),context:mw.nullable()}),I({approvalId:N(),outcome:N()}),I({ref:N()}),I({sessionIds:ue(N())}),I({items:ue(dw)}),I({item:Tp}),I({}),I({}),W2.extend({sessionId:N()});const Qu={InternalError:-32603,NotInitialized:-32002};class Ml extends Error{constructor(s,i,r){super(i);mt(this,"code");mt(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 X2(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 Gg(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 fw=["把这次走通的做法保存成技能(用 skill_save),让下次同样的事可以直接照着做、少调用模型。要求:","- 只写最后成功的路径,不写失败的尝试和闲聊;","- 写清楚适用场景(用户会怎么说)、一步一步的操作(用到的工具、命令、路径、参数照实写,会变的写成「把 X 换成…」)、怎样算成功、注意事项和踩过的坑;","- 名字用简短的英文小写加短横线,description 一两句话说清楚做什么、什么时候用;","- 分到对应的游戏和脚本:只有用某个脚本时才用得上的(它的配置、报错、日志),scripts 填脚本 id;和游戏本身有关、换个脚本也用得上的(游戏里的操作、界面、活动、机制),games 填游戏 id(用 game_list 查);和哪个游戏都无关才当通用技能;","- 保存后告诉我技能名,以及以后我说什么时会用到它。"].join(`
116
+ `);function Q2(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 写明依据);都对就不改;"," 日常周常(routines,游戏页「日常 · 周常」靠它们自动勾选):原来有的照原样保留;每一项的 log 用运行日志里它真正做完时的原文写(例如「完成任务: 基建换班」「每日实训已完成」「本周剿灭已完成,跳过剿灭」),看不出单项、只有任务成功能证明的写 tasks;开始、跳过不了、失败的行不要写成完成。常见问题写在 guide.troubleshooting 下,写在别处会被丢掉;","2. 改善监控时间:monitor_stall_check 看它正常运行时日志的节奏,按建议值和你看日志的判断用 monitor_stall_set 设它多久没新日志算卡住,note 写明依据(例如「战斗中最长 70 秒不输出」);","3. 把做过的步骤总结成技能,分到对应的游戏和脚本:运行和处理这个脚本时反复用到、已经走通的做法(常见报错怎么处理、怎么确认跑完、配置怎么改)用 skill_save 存成技能,scripts 填这个脚本的 id,只给它用;其中和游戏本身有关、别的脚本也用得上的(游戏里的操作、界面、活动、机制)单独存,games 填它玩的游戏 id(game_list 查),不填 scripts;已有的技能就合并更新(replace),不要重复存,没有值得存的就不存;","4. 不要运行脚本、不要改它的配置;最后用几句话告诉我:脚本包改了什么(已经直接生效)、哪些日常周常能自动勾选、卡住时间设成多少、存了或更新了哪些技能。"].join(`
117
+ `)}const Kg=[{name:"技能",aliases:["skill"],title:"把刚才走通的做法存成技能,下次少调用模型",expand:()=>fw},{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=>Q2(e)},{name:"压缩",aliases:["compact"],title:"压缩这个对话:较早的部分换成摘要,agent 会忘掉其中的细节",expand:()=>"",local:"compact"}];function J2(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=Kg.find(o=>o.local!==void 0&&(o.name===t||o.aliases.includes(t))))==null?void 0:r.local}function eO(e,t){return`使用技能「${e}」:先用 skill 工具加载它,再按它的说明做${t===""?"。":`:${t}`}`}function tO(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=Kg.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
+ ${eO(u.name,o)}`}function nO(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 sO(e,t,s=!1){const i=/^\/(\S*)$/.exec(e);if(i===null)return[];const r=i[1].toLowerCase(),o=Kg.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 iO=new Set(["issues","pulls","wiki","actions","discussions","blob","commits","commit","compare","security","pulse","graphs","network","settings","projects","stargazers","forks","watchers","tags","branches"]);function rO(e){var k,b;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 m=h[1].replace(/\.git$/i,"");if(!/^[A-Za-z0-9_.-]+$/.test(m))return;const p=`${h[0]}/${m}`,[g,...x]=h.slice(2);if(g==="releases")return x[0]==="tag"&&x[1]!==void 0?{repo:p,tag:r(x.slice(1).join("/"))}:x[0]==="download"&&x.length>=3?{repo:p,tag:r(x.slice(1,-1).join("/")),asset:r(x.at(-1))}:{repo:p};if(g==="tree"&&x.length>0)return{repo:p,branch:r(x[0])};if(g==="archive"){const j=x.join("/").replace(/\.(zip|tar\.gz)$/i,""),w=(k=/^refs\/tags\/(.+)$/.exec(j))==null?void 0:k[1];if(w!==void 0)return{repo:p,tag:r(w)};const S=(b=/^refs\/heads\/(.+)$/.exec(j))==null?void 0:b[1];return S!==void 0?{repo:p,branch:r(S)}:{repo:p,tag:r(j)}}return g===void 0||iO.has(g)?{repo:p}:{repo:p}}const rb=1;var hr,As,qr,Pa,eh,ki,zo,Do,Rc,xn,Op,Pp,Lp,pw,gw,zp,Dp;class aO{constructor(t){Ht(this,xn);mt(this,"status",new Bi({state:"idle",attempt:0}));mt(this,"server",new Bi(null));Ht(this,hr);Ht(this,As,null);Ht(this,qr,!1);Ht(this,Pa,0);Ht(this,eh,1);Ht(this,ki,new Map);Ht(this,zo,new Map);Ht(this,Do,new Set);Ht(this,Rc);Kt(this,hr,t)}get generation(){return ze(this,Pa)}get ready(){return ze(this,qr)}start(){this.status.get().state!=="idle"&&this.status.get().state!=="stopped"||bt(this,xn,Lp).call(this)}stop(){clearTimeout(ze(this,Rc)),this.status.set({state:"stopped",attempt:0});const t=ze(this,As);Kt(this,As,null),bt(this,xn,zp).call(this,"connection stopped"),t==null||t.close(1e3,"client stopped")}on(t,s){let i=ze(this,zo).get(t);return i===void 0&&ze(this,zo).set(t,i=new Set),i.add(s),()=>{i.delete(s)}}onReady(t){return ze(this,Do).add(t),ze(this,qr)&&queueMicrotask(()=>t(ze(this,Pa))),()=>{ze(this,Do).delete(t)}}call(t,s,i){return!ze(this,qr)&&t!=="initialize"?Promise.reject(new Ml(Qu.NotInitialized,"not connected to the gateway")):bt(this,xn,Op).call(this,t,s,i)}}hr=new WeakMap,As=new WeakMap,qr=new WeakMap,Pa=new WeakMap,eh=new WeakMap,ki=new WeakMap,zo=new WeakMap,Do=new WeakMap,Rc=new WeakMap,xn=new WeakSet,Op=function(t,s,i){const r=ze(this,As);if(r===null||r.readyState!==rb)return Promise.reject(new Ml(Qu.NotInitialized,"not connected to the gateway"));if((i==null?void 0:i.aborted)===!0)return Promise.reject(i.reason??new Error("aborted"));const o=ry(this,eh)._++;return new Promise((l,u)=>{const d=ze(this,hr).callTimeoutMs??6e4,h=d>0?setTimeout(()=>{var g;(g=ze(this,ki).get(o))==null||g.reject(new Ml(Qu.InternalError,`${t} timed out`))},d):void 0,m=()=>{var g;ze(this,ki).has(o)&&(bt(this,xn,Pp).call(this,{jsonrpc:"2.0",method:"$/cancelRequest",params:{id:o}}),(g=ze(this,ki).get(o))==null||g.reject((i==null?void 0:i.reason)instanceof Error?i.reason:new Error("aborted")))};i==null||i.addEventListener("abort",m,{once:!0});const p=()=>{clearTimeout(h),i==null||i.removeEventListener("abort",m),ze(this,ki).delete(o)};ze(this,ki).set(o,{resolve:g=>{p(),l(g)},reject:g=>{p(),u(g)},cleanup:p}),bt(this,xn,Pp).call(this,{jsonrpc:"2.0",id:o,method:t,params:s})})},Pp=function(t){var s;((s=ze(this,As))==null?void 0:s.readyState)===rb&&ze(this,As).send(JSON.stringify(t))},Lp=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=(ze(this,hr).createSocket??(i=>new WebSocket(i)))(ze(this,hr).url)}catch(i){bt(this,xn,Dp).call(this,i instanceof Error?i.message:String(i));return}Kt(this,As,s),s.addEventListener("open",()=>{ze(this,As)===s&&bt(this,xn,pw).call(this,s)}),s.addEventListener("message",i=>{ze(this,As)===s&&bt(this,xn,gw).call(this,String(i.data))}),s.addEventListener("close",i=>{if(ze(this,As)!==s)return;Kt(this,As,null),bt(this,xn,zp).call(this,"connection lost");const r=typeof i.reason=="string"&&i.reason!==""?i.reason:`closed (${i.code??"?"})`;bt(this,xn,Dp).call(this,r)}),s.addEventListener("error",()=>{})},pw=async function(t){try{const s=await bt(this,xn,Op).call(this,"initialize",{protocolVersion:D2,client:ze(this,hr).clientInfo});if(ze(this,As)!==t)return;Kt(this,qr,!0),Kt(this,Pa,ze(this,Pa)+1),this.server.set(s),this.status.set({state:"open",attempt:0});for(const i of[...ze(this,Do)])i(ze(this,Pa))}catch(s){t.close(4e3,s instanceof Error?s.message:"initialize failed")}},gw=function(t){let s;try{s=JSON.parse(t)}catch{return}const i=X2(s);if(i==="response"){const r=ze(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[...ze(this,zo).get(s.method)??[]])try{r(s.params)}catch(o){console.error(`notification handler for ${s.method} failed`,o)}},zp=function(t){Kt(this,qr,!1);for(const s of[...ze(this,ki).values()])s.reject(new Ml(Qu.InternalError,t));ze(this,ki).clear()},Dp=function(t){if(this.status.get().state==="stopped")return;const s=this.status.get().attempt+1,{initial:i,max:r}=ze(this,hr).backoffMs??{initial:500,max:1e4},o=Math.min(r,i*2**Math.min(s-1,10))*(.8+Math.random()*.4);this.status.set({state:"reconnecting",attempt:s,error:t}),Kt(this,Rc,setTimeout(()=>bt(this,xn,Lp).call(this),o))};const oO={status:"opening",header:null,title:null,events:[],cursor:-1,hasMore:!1,loadingOlder:!1,live:null,pending:[],queue:[],context:null,running:!1,version:0,error:null};var $s,Oc,Fo,Uo,mr,Gr,Pc,Lc,Yt,Fp,vd,is;class lO{constructor(t,s,i){Ht(this,Yt);mt(this,"id");mt(this,"state",new Bi(oO));Ht(this,$s);Ht(this,Oc);Ht(this,Fo,null);Ht(this,Uo,-1);Ht(this,mr,!1);Ht(this,Gr,null);Ht(this,Pc);Ht(this,Lc);this.id=t,Kt(this,$s,s),Kt(this,Oc,i),Kt(this,Pc,s.onReady(r=>{r!==ze(this,Uo)&&bt(this,Yt,Fp).call(this,r)}))}get subscriptionId(){return ze(this,Fo)}async prompt(t,s="queue",i=[]){const r=crypto.randomUUID(),o={requestId:r,text:t,mode:s,sentAt:Date.now(),...i.length===0?{}:{images:i.length}};bt(this,Yt,is).call(this,l=>({...l,pending:[...l.pending,o]}));try{await ze(this,$s).call("session/prompt",{sessionId:this.id,requestId:r,text:t,mode:s,...i.length===0?{}:{images:[...i]}})}catch(l){const u=l instanceof Error?l.message:String(l);throw bt(this,Yt,is).call(this,d=>({...d,pending:d.pending.map(h=>h.requestId===r?{...h,failed:u}:h)})),l}}dismissPending(t){bt(this,Yt,is).call(this,s=>({...s,pending:s.pending.filter(i=>i.requestId!==t)}))}async updateQueue(t,s){await ze(this,$s).call("session/queue/update",{sessionId:this.id,itemId:t,action:s})}async cancel(){await ze(this,$s).call("session/cancel",{sessionId:this.id})}async compact(){return ze(this,$s).call("session/compact",{sessionId:this.id})}async loadOlder(){const t=this.state.get(),s=t.events[0];if(!(!t.hasMore||t.loadingOlder||s===void 0)){bt(this,Yt,is).call(this,i=>({...i,loadingOlder:!0}));try{const i=await ze(this,$s).call("session/history",{sessionId:this.id,throughSeq:t.cursor,beforeSeq:s.seq});bt(this,Yt,is).call(this,r=>{var u;const o=((u=r.events[0])==null?void 0:u.seq)??Number.POSITIVE_INFINITY,l=i.events.filter(d=>d.seq<o);return{...r,events:[...l,...r.events],hasMore:i.hasMore,loadingOlder:!1}})}catch(i){bt(this,Yt,is).call(this,r=>({...r,loadingOlder:!1,error:i instanceof Error?i.message:String(i)}))}}}close(){if(ze(this,mr))return;Kt(this,mr,!0),clearTimeout(ze(this,Lc)),ze(this,Pc).call(this);const t=ze(this,Fo);bt(this,Yt,vd).call(this,null),t!==null&&ze(this,$s).ready&&ze(this,$s).call("session/close",{subscriptionId:t}).catch(()=>{}),bt(this,Yt,is).call(this,s=>({...s,status:"closed"}))}receiveEvent(t){bt(this,Yt,is).call(this,s=>{const i=s.events.at(-1);if(i!==void 0&&t.seq<=i.seq)return s;let r=s.pending;t.type==="user/message"&&t.requestId!==void 0&&(r=r.filter(d=>d.requestId!==t.requestId));let o=s.live;(t.type==="assistant/message"||t.type==="assistant/attempt")&&o!==null&&o.turn===t.turn&&o.step===t.step&&(o=null);const l=t.type==="session/title"?t.title:s.title,u=[...s.events,t];return{...s,events:u,pending:r,live:o,title:l,running:gf(u,o)}})}receiveLive(t){bt(this,Yt,is).call(this,s=>{var i;switch(t.type){case"start":{const r={attemptId:t.attemptId,turn:t.turn,step:t.step,afterSeq:t.afterSeq,deltas:[]};return{...s,live:r,running:!0}}case"delta":{const r=s.live;return r===null||r.attemptId!==t.attemptId?s:(r.deltas.push(t),{...s,live:{...r}})}case"end":return((i=s.live)==null?void 0:i.attemptId)!==t.attemptId?s:{...s,live:null,running:gf(s.events,null)}}})}receiveClosed(t){bt(this,Yt,vd).call(this,null),!ze(this,mr)&&(bt(this,Yt,is).call(this,s=>({...s,status:"error",error:`stream ended: ${t}`})),Kt(this,Lc,setTimeout(()=>{!ze(this,mr)&&ze(this,$s).ready&&bt(this,Yt,Fp).call(this,ze(this,Uo))},1e3)))}receiveQueue(t){bt(this,Yt,is).call(this,s=>({...s,queue:t,pending:ab(s.pending,t)}))}receiveContext(t){bt(this,Yt,is).call(this,s=>({...s,context:t}))}receiveTitle(t){bt(this,Yt,is).call(this,s=>s.title===t?s:{...s,title:t})}}$s=new WeakMap,Oc=new WeakMap,Fo=new WeakMap,Uo=new WeakMap,mr=new WeakMap,Gr=new WeakMap,Pc=new WeakMap,Lc=new WeakMap,Yt=new WeakSet,Fp=async function(t){if(!ze(this,mr))return ze(this,Gr)!==null?ze(this,Gr):(Kt(this,Uo,t),Kt(this,Gr,(async()=>{try{const s=await ze(this,$s).call("session/open",{sessionId:this.id});if(ze(this,mr)){ze(this,$s).call("session/close",{subscriptionId:s.subscriptionId}).catch(()=>{});return}bt(this,Yt,vd).call(this,s.subscriptionId);const i=s.live===null?null:{...s.live,deltas:[...s.live.deltas]};bt(this,Yt,is).call(this,r=>{const o=new Set(s.events.flatMap(l=>l.type==="user/message"&&l.requestId!==void 0?[l.requestId]:[]));return{...r,status:"open",header:s.header,title:s.title,events:s.events,cursor:s.cursor,hasMore:s.hasMore,live:i,pending:ab(r.pending.filter(l=>!o.has(l.requestId)),s.queue??[]),queue:s.queue??[],context:s.context??r.context,running:gf(s.events,i),loadingOlder:!1,error:null}})}catch(s){bt(this,Yt,is).call(this,i=>({...i,status:"error",error:s instanceof Error?s.message:String(s)}))}finally{Kt(this,Gr,null)}})()),ze(this,Gr))},vd=function(t){Kt(this,Fo,t),ze(this,Oc).bindSubscription(this,t)},is=function(t){this.state.set(s=>{const i=t(s);return i===s?s:{...i,version:s.version+1}})};function ab(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 gf(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 ob=(e,t)=>t.updatedAt-e.updatedAt;var Us,Hi,Bo,pr,yd,Up;class cO{constructor(t){Ht(this,pr);mt(this,"connection");mt(this,"sessions",new Bi({items:[],loaded:!1,error:null}));mt(this,"approvals",new Bi([]));mt(this,"questions",new Bi([]));mt(this,"capabilities",new Bi(new Set));mt(this,"credentialRevision",new Bi(0));mt(this,"providersRevision",new Bi(0));mt(this,"sessionModels",new Bi(new Map));Ht(this,Us,new Map);Ht(this,Hi,new Map);Ht(this,Bo,!1);this.connection=new aO({...t,clientInfo:t.clientInfo??{name:"adg-client",version:"0.1.0"}});const s=this.connection;s.onReady(()=>{var i;this.capabilities.set(new Set(((i=s.server.get())==null?void 0:i.capabilities.map(r=>r.id))??[])),this.approvals.set([]),this.questions.set([]),this.refreshSessions()}),s.on("sessions/changed",i=>{if(i.kind==="removed"){if(this.sessions.get().items.some(o=>o.id===i.sessionId&&o.origin==="subagent")){this.sessions.set(o=>({...o,items:o.items.map(l=>l.id===i.sessionId?{...l,running:!1,live:!1}:l)})),bt(this,pr,Up).call(this);return}this.sessions.set(o=>({...o,items:o.items.filter(l=>l.id!==i.sessionId)}));return}if(!this.sessions.get().items.some(o=>o.id===i.item.id)){bt(this,pr,Up).call(this);return}this.sessions.set(o=>({...o,items:o.items.map(l=>l.id===i.item.id?{...l,...uO(i.item)}:l).sort(ob)}))}),s.on("session/title",({sessionId:i,title:r})=>{var o;(o=ze(this,Us).get(i))==null||o.handle.receiveTitle(r)}),s.on("session/queue",({sessionId:i,items:r})=>{var o;(o=ze(this,Us).get(i))==null||o.handle.receiveQueue(r)}),s.on("session/context",({sessionId:i,context:r})=>{var o;(o=ze(this,Us).get(i))==null||o.handle.receiveContext(r)}),s.on("session/event",({subscriptionId:i,event:r})=>{var o;return(o=ze(this,Hi).get(i))==null?void 0:o.receiveEvent(r)}),s.on("session/live",({subscriptionId:i,frame:r})=>{var o;return(o=ze(this,Hi).get(i))==null?void 0:o.receiveLive(r)}),s.on("session/closed",({subscriptionId:i,reason:r})=>{const o=ze(this,Hi).get(i);o!==void 0&&o.subscriptionId===i&&o.receiveClosed(r)}),s.on("approval/requested",i=>{this.approvals.set(r=>r.some(o=>o.approvalId===i.approvalId)?r:[...r,i])}),s.on("approval/resolved",({approvalId:i})=>{this.approvals.set(r=>r.filter(o=>o.approvalId!==i))}),s.on("question/requested",i=>{this.questions.set(r=>r.some(o=>o.questionId===i.questionId)?r:[...r,i])}),s.on("question/resolved",({questionId:i})=>{this.questions.set(r=>r.filter(o=>o.questionId!==i))}),s.on("credentials/changed",()=>this.credentialRevision.set(i=>i+1)),s.on("providers/changed",()=>this.providersRevision.set(i=>i+1)),s.on("session/model",({sessionId:i,lastUsed:r,next:o})=>bt(this,pr,yd).call(this,i,{lastUsed:r,next:o}))}async describeCredentials(t){const{items:s}=await this.connection.call("credentials/describe",{refs:[...t]});return s}async setCredential(t,s){await this.connection.call("credentials/set",{ref:t,value:s}),this.credentialRevision.set(i=>i+1)}async unsetCredential(t){await this.connection.call("credentials/unset",{ref:t}),this.credentialRevision.set(s=>s+1)}start(){this.connection.start()}stop(){for(const{handle:t}of ze(this,Us).values())t.close();ze(this,Us).clear(),ze(this,Hi).clear(),this.connection.stop()}has(t){return this.capabilities.get().has(t)}async refreshSessions(){try{const{items:t}=await this.connection.call("sessions/list",{});this.sessions.set({items:[...t].sort(ob),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=ze(this,Us).get(t))==null||r.handle.receiveTitle(i.title)}modelCatalog(){return this.connection.call("models/catalog",{})}async sessionModel(t){const s=await this.connection.call("session/model",{sessionId:t});return bt(this,pr,yd).call(this,t,s),s}async selectModel(t,s){var o;const{selected:i}=await this.connection.call("session/selectModel",{sessionId:t,...s}),r=((o=this.sessionModels.get().get(t))==null?void 0:o.lastUsed)??null;return bt(this,pr,yd).call(this,t,{lastUsed:r,next:i}),i}listProviders(){return this.connection.call("providers/list",{})}async discoverModels(t,s){const{models:i}=await this.connection.call("providers/discover",t,s);return i}async providerBalance(t){const{balance:s}=await this.connection.call("providers/balance",{provider:t});return s}async saveProvider(t){const s=await this.connection.call("providers/save",t);return this.providersRevision.set(i=>i+1),t.apiKey!==void 0&&this.credentialRevision.set(i=>i+1),s}async removeProvider(t){const s=await this.connection.call("providers/remove",t);return this.providersRevision.set(i=>i+1),t.removeKey===!0&&this.credentialRevision.set(i=>i+1),s}async respondApproval(t,s){await this.connection.call("approval/respond",{approvalId:t,decision:s}),this.approvals.set(i=>i.filter(r=>r.approvalId!==t))}async answerQuestion(t,s){await this.connection.call("question/respond",{questionId:t,answers:[...s]}),this.questions.set(i=>i.filter(r=>r.questionId!==t))}openSession(t){const s=ze(this,Us).get(t);if(s!==void 0)return s.refs+=1,s.handle;const i=new lO(t,this.connection,{bindSubscription:(r,o)=>{for(const[l,u]of ze(this,Hi))u===r&&ze(this,Hi).delete(l);o!==null&&ze(this,Hi).set(o,r)}});return ze(this,Us).set(t,{handle:i,refs:1}),i}release(t){const s=ze(this,Us).get(t.id);s===void 0||s.handle!==t||(s.refs-=1,!(s.refs>0)&&(ze(this,Us).delete(t.id),t.close()))}}Us=new WeakMap,Hi=new WeakMap,Bo=new WeakMap,pr=new WeakSet,yd=function(t,s){this.sessionModels.set(i=>new Map(i).set(t,s))},Up=function(){ze(this,Bo)||(Kt(this,Bo,!0),setTimeout(()=>{Kt(this,Bo,!1),this.refreshSessions()},150))};function uO(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const xf=(e,t)=>e.map(s=>s.type===t?s.text:"").join(""),vf=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}}]:[]),dO=e=>e.map(t=>t.type==="text"?t.text:t.type==="image"?"[image]":t.type==="file"?`[file ${t.name??""}]`:"").join(""),xw="model-selection",hO="run_code",mO="ptc-mode";function fO(e){return(e==null?void 0:e.kind)==="context"&&e.title===xw}function rh(e,t,s=[],i=[]){var b,j,w;const r=[],o=new Map;let l;const u=new Set,d=new Set,h=(S,_)=>{d.has(S)||(d.add(S),r.push({kind:"context",id:"dispatch:"+S,childId:S,title:"adg-task-dispatched",summary:_,text:""}))},m=new Map,p=new Map;let g=!1,x;for(const S of e)switch(S.type){case"unknown":{if(S.upstreamType!=="agent/inbox/spliced")break;const _=S.data;if(!Array.isArray(_==null?void 0:_.inserted))break;for(const E of _.inserted){const M=E==null?void 0:E.source;(M==null?void 0:M.kind)==="adg-task-dispatched"&&typeof M.childId=="string"&&M.childId&&typeof M.summary=="string"&&h(M.childId,M.summary)}break}case"user/message":{if(S.origin.kind==="adg-task-dispatched"&&S.origin.childId&&S.origin.summary!==void 0){h(S.origin.childId,S.origin.summary);break}const _=xf(S.content,"text");if(S.origin.human)r.push({kind:"user",id:`u:${S.seq}`,text:_,time:S.time,images:S.content.filter(E=>E.type==="image").length,imageRefs:vf(S.content),files:S.content.filter(E=>E.type==="file").length});else if(S.origin.kind===XM&&S.origin.fallback!==void 0){fO(r.at(-1))&&r.pop();const E=r.at(-1);(E==null?void 0:E.kind)==="notice"&&E.tone==="error"&&r.pop(),r.push({kind:"fallback",id:`f:${S.seq}`,notice:S.origin.fallback,time:S.time})}else if(!(S.origin.kind===xw&&((b=r.at(-1))==null?void 0:b.kind)==="fallback")){if(eb(_)!==void 0)r.push({kind:"context",id:`c:${S.seq}`,title:"定时提醒",summary:k2(eb(_)),text:_,startsTurn:!0});else if(S.replacesHistory===!0)x!==void 0&&r.splice(r.indexOf(x),1),x=void 0,g=!0,r.push({kind:"context",id:`c:${S.seq}`,title:"较早的对话已压缩成摘要(agent 只记得摘要里的内容)",summary:"",text:_});else if(S.origin.summary!==void 0)r.push({kind:"context",id:`c:${S.seq}`,title:S.origin.kind,summary:S.origin.summary,text:_});else if(S.origin.kind===mO&&l!==void 0){const E=vf(S.content).filter(M=>{var O;return((O=l.images)==null?void 0:O.some(B=>B.attachmentId===M.attachmentId))!==!0});E.length>0&&(l.images=[...l.images??[],...E])}}break}case"assistant/message":{u.add(`${S.turn}:${S.step}`);const _=xf(S.content,"text"),E=xf(S.content,"reasoning");(_.trim()!==""||E.trim()!=="")&&r.push({kind:"assistant",id:`a:${S.seq}`,text:_,reasoning:E,live:!1,interrupted:S.interrupted===!0,time:S.time,turn:S.turn,...S.model===void 0?{}:{model:S.model}});break}case"tool/call":{const _={kind:"tool",id:`t:${S.callId}`,callId:S.callId,name:S.name,arguments:S.arguments,status:"running",time:S.time},E=m.get(S.callId);E!==void 0&&(_.approval=E),o.set(S.callId,_),r.push(_),S.name===hO&&(l=_);break}case"tool/result":{const _=o.get(S.callId);if(_===void 0)break;_.result=dO(S.content);const E=vf(S.content);E.length>0&&(_.images=E),_.status=S.isError?"error":"ok",S.error!==void 0&&(_.error=S.error.message);break}case"approval/asked":if(S.callId!==void 0){p.set(S.approvalId,S.callId),m.set(S.callId,"asked");const _=o.get(S.callId);_!==void 0&&(_.approval="asked")}break;case"approval/decided":{const _=p.get(S.approvalId);if(_===void 0)break;m.set(_,S.outcome);const E=o.get(_);E!==void 0&&(E.approval=S.outcome);break}case"turn/end":for(const _ of o.values())_.status==="running"&&(_.status="interrupted");S.reason.kind==="error"?r.push({kind:"notice",id:`e:${S.seq}`,tone:"error",text:S.reason.message??"这一轮出错了"}):S.reason.kind==="aborted"?r.push({kind:"notice",id:`e:${S.seq}`,tone:"info",text:"已停止"}):S.reason.kind==="max-tokens"&&r.push({kind:"notice",id:`e:${S.seq}`,tone:"info",text:"回复太长,达到了输出上限"});break;case"compaction/start":g=!1,x=void 0;break;case"compaction/end":{S.error!==void 0?r.push({kind:"notice",id:`k:${S.seq}`,tone:"error",text:`压缩对话历史失败:${S.error}`}):g||(x={kind:"notice",id:`k:${S.seq}`,tone:"info",text:"对话太长,较早的内容已压缩成摘要"},r.push(x)),g=!1;break}}if(t!==null&&!u.has(`${t.turn}:${t.step}`)){let S="",_="";for(const E of t.deltas)E.kind==="text"?S+=E.text:E.kind==="reasoning"&&(_+=E.text);r.push({kind:"assistant",id:`live:${t.attemptId}`,text:S,reasoning:_,live:!0,interrupted:!1,turn:t.turn,time:((j=t.deltas[0])==null?void 0:j.time)??Date.now()})}const k=new Set(e.flatMap(S=>S.type==="user/message"?[S.messageId]:[]));for(const S of i)S.placement!=="taken"||k.has(S.id)||r.push({kind:"user",id:`q:${S.id}`,text:S.text,images:S.images??0,imageRefs:[],files:0,time:((w=e.at(-1))==null?void 0:w.time)??Date.now(),pending:{requestId:S.requestId??S.id}});for(const S of s)r.push({kind:"user",id:`p:${S.requestId}`,text:S.text,images:S.images??0,imageRefs:[],files:0,time:S.sentAt,pending:{requestId:S.requestId,...S.failed===void 0?{}:{failed:S.failed}}});return r}var v=zc();const pO=Tg(v);var qa=rN();function gO(e,t){return e.filter(s=>{var i;return((i=s.available)==null?void 0:i.call(s,t))??!0})}const Kr=new Map,Td=new Set;function Bn(e){if(Kr.has(e.id))throw new Error(`UI plugin "${e.id}" is already registered`);Kr.set(e.id,e);for(const t of Td)t();return()=>{if(Kr.get(e.id)===e){Kr.delete(e.id);for(const t of Td)t()}}}function vw(e){return Td.add(e),()=>{Td.delete(e)}}function xO(e){return[...Kr.values()].filter(t=>t.requires.every(s=>e.has(s))).flatMap(t=>t.sessionViews??[]).sort((t,s)=>t.order-s.order)}function vO(e){return[...Kr.values()].filter(t=>t.requires.every(s=>e.has(s))).flatMap(t=>t.settingsPages??[]).sort((t,s)=>t.order-s.order)}function yO(e){return[...Kr.values()].filter(t=>t.requires.every(s=>e.has(s))).flatMap(t=>t.pages??[]).sort((t,s)=>t.order-s.order)}function bO(e){return[...Kr.values()].map(t=>({plugin:t,missing:t.requires.filter(s=>!e.has(s))}))}function Se(e){return v.useSyncExternalStore(e.subscribe,e.get,e.get)}function Fc(e,t){const[s,i]=v.useState(null);return v.useEffect(()=>{const r=e.openSession(t);return i(r),()=>e.release(r)},[e,t]),s!==null&&s.id===t?s:null}function kO(e){const t=Se(e.capabilities),s=Yg();return v.useMemo(()=>xO(t),[t,s])}function jO(e){const t=Se(e.capabilities),s=Yg();return v.useMemo(()=>vO(t),[t,s])}function NO(e){const t=Se(e.capabilities),s=Yg();return v.useMemo(()=>yO(t),[t,s])}function Yg(){const[e,t]=v.useState(0);return v.useEffect(()=>vw(()=>t(s=>s+1)),[]),e}function yw(e,t){const s=Se(e.credentialRevision),i=Se(e.connection.status),r=Se(e.capabilities),o=t.join(`
127
+ `),[l,u]=v.useState({items:null,error:null});return v.useEffect(()=>{if(i.state!=="open"||!r.has("credentials")||o==="")return;let d=!0;return e.describeCredentials(o.split(`
128
+ `)).then(h=>{d&&u({items:h,error:null})}).catch(h=>{d&&u(m=>({...m,error:h instanceof Error?h.message:String(h)}))}),()=>{d=!1}},[e,o,s,i.state,r]),l}function aa(e){const t=Se(e.credentialRevision),s=Se(e.providersRevision),i=Se(e.connection.status),r=Se(e.capabilities),[o,l]=v.useState({catalog:null,error:null});return v.useEffect(()=>{if(i.state!=="open"||!r.has("models"))return;let u=!0;return e.modelCatalog().then(d=>{u&&l({catalog:d,error:null})}).catch(d=>{u&&l(h=>({...h,error:d instanceof Error?d.message:String(d)}))}),()=>{u=!1}},[e,t,s,i.state,r]),o}function vn(e){const[t,s]=v.useState(()=>Date.now());return v.useEffect(()=>{const i=setInterval(()=>s(Date.now()),e);return()=>clearInterval(i)},[e]),t}function wO(e){const t=Se(e.connection.status),s=Se(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 SO={plus:"M12 5v14M5 12h14",chat:"M6 4.5h12A3.5 3.5 0 0 1 21.5 8v6.5A3.5 3.5 0 0 1 18 18h-5.2l-4.3 3.2a.6.6 0 0 1-1-.5V18H6a3.5 3.5 0 0 1-3.5-3.5V8A3.5 3.5 0 0 1 6 4.5ZM8 11.25h.01M12 11.25h.01M16 11.25h.01",settings:"M4 7h9m4 0h3M4 17h3m4 0h9M13 4v6M7 14v6",arrow:"M12 19V5m-6 6 6-6 6 6",activity:"M3 12h4l3-8 4 16 3-8h4",layers:"m12 3 9 5-9 5-9-5 9-5Zm-9 9 9 5 9-5M3 16l9 5 9-5",sparkles:"m12 3 2.5 6.5L21 12l-6.5 2.5L12 21l-2.5-6.5L3 12l6.5-2.5L12 3Z",close:"m6 6 12 12M6 18 18 6",gauge:"M12 14l4-4M3.5 15a8.5 8.5 0 1 1 17 0M6.5 19h11",popout:"M14 4h6v6M20 4l-8.5 8.5M18 14v4.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 4 18.5v-11A1.5 1.5 0 0 1 5.5 6H10",search:"M11 17.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13ZM20 20l-4-4",check:"m5 12.5 4.5 4.5L19 7.5",pencil:"M4 20h4L18.5 9.5a2.1 2.1 0 0 0-4-4L4 16v4ZM13.5 6.5l4 4",copy:"M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2ZM16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2",eye:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7ZM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z","eye-off":"M3 3l18 18M10.6 5.1A10 10 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-3.1 3.9M6.6 6.6A17 17 0 0 0 2 12s3.5 7 10 7a10 10 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2",chevron:"m9 6 6 6-6 6","chevron-down":"m6 9 6 6 6-6",back:"M19 12H5M11 6l-6 6 6 6",shield:"M12 3 4 6v6c0 4.5 3.4 8 8 9 4.6-1 8-4.5 8-9V6l-8-3ZM12 9v4M12 16.5v.01",terminal:"M4 17l6-6-6-6M12 19h8",image:"M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1ZM4 16l5-5 4 4 2-2 5 5M15 9.5v.01",paperclip:"m20 11.5-8.2 8.2a5 5 0 0 1-7-7l8.5-8.5a3.3 3.3 0 0 1 4.7 4.7l-8.5 8.5a1.7 1.7 0 0 1-2.4-2.4l7.8-7.8",info:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM12 11v5M12 7.5v.01",key:"M8 19a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM11 12l8-8M16 7l2 2M14 9l2 2",sidebar:"M6.5 4.5h11a3 3 0 0 1 3 3v9a3 3 0 0 1-3 3h-11a3 3 0 0 1-3-3v-9a3 3 0 0 1 3-3ZM9.5 4.5v15",alert:"M10.27 4.5a2 2 0 0 1 3.46 0l7.36 12.75A2 2 0 0 1 19.36 20.25H4.64a2 2 0 0 1-1.73-3L10.27 4.5ZM12 9.5v4.25M12 16.75v.01",package:"M11 3.3a2 2 0 0 1 2 0l6.5 3.75a2 2 0 0 1 1 1.73v6.44a2 2 0 0 1-1 1.73L13 20.7a2 2 0 0 1-2 0l-6.5-3.75a2 2 0 0 1-1-1.73V8.78a2 2 0 0 1 1-1.73L11 3.3ZM3.8 7.7 12 12.4l8.2-4.7M12 12.4v8.5",flow:"M5.5 3.75h2.5a1.75 1.75 0 0 1 1.75 1.75V8A1.75 1.75 0 0 1 8 9.75H5.5A1.75 1.75 0 0 1 3.75 8V5.5A1.75 1.75 0 0 1 5.5 3.75ZM16 3.75h2.5a1.75 1.75 0 0 1 1.75 1.75V8a1.75 1.75 0 0 1-1.75 1.75H16A1.75 1.75 0 0 1 14.25 8V5.5A1.75 1.75 0 0 1 16 3.75ZM16 14.25h2.5a1.75 1.75 0 0 1 1.75 1.75v2.5a1.75 1.75 0 0 1-1.75 1.75H16a1.75 1.75 0 0 1-1.75-1.75V16A1.75 1.75 0 0 1 16 14.25ZM9.75 6.75h4.5M17.25 9.75v4.5M6.75 9.75v5a2.5 2.5 0 0 0 2.5 2.5h5",monitor:"M5.5 4h13A2.5 2.5 0 0 1 21 6.5v7a2.5 2.5 0 0 1-2.5 2.5h-13A2.5 2.5 0 0 1 3 13.5v-7A2.5 2.5 0 0 1 5.5 4ZM9 20h6M12 16v4M6.75 10.25h2.5l1.5-2.75 2.5 5.25 1.5-2.5h2.5",gamepad:"M7.75 6.5h8.5a5 5 0 0 1 4.93 5.83l-.72 4.27a2.6 2.6 0 0 1-4.45 1.37L14.25 16h-4.5l-1.76 1.97a2.6 2.6 0 0 1-4.45-1.37l-.72-4.27A5 5 0 0 1 7.75 6.5ZM8.25 9.75v3.5M6.5 11.5H10M15.25 10.75v.01M17.25 12.75v.01",plug:"M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0V8ZM12 17v4",home:"M4 11 12 4l8 7M6 9.5V20h12V9.5",archive:"M4 5h16v4H4zM5.5 9v10h13V9M10 13h4",refresh:"M20 11a8 8 0 0 0-14.3-4.9L4 8M4 4v4h4M4 13a8 8 0 0 0 14.3 4.9L20 16M20 20v-4h-4",calendar:"M6.5 5h11A2.5 2.5 0 0 1 20 7.5v10a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 4 17.5v-10A2.5 2.5 0 0 1 6.5 5ZM4 10h16M8.5 3v4M15.5 3v4M8.5 13.5h.01M12 13.5h.01M15.5 13.5h.01M8.5 16.75h.01M12 16.75h.01",reply:"m9.5 5.25-5.75 5.5 5.75 5.5M4.5 10.75h8.25A6.75 6.75 0 0 1 19.5 17.5v1.25",send:"M20.5 3.5 10 14M20.5 3.5 14 20.5l-4-6.5-6.5-4 17-6.5Z",power:"M12 3.5v8M7.2 6.5a7 7 0 1 0 9.6 0",download:"M12 4v11M7 10.5l5 5 5-5M5 20h14",compress:"M12 3v6M9 6l3 3 3-3M12 21v-6M9 18l3-3 3 3M4 12h16",globe:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM3.5 9h17M3.5 15h17M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9c-2.5-2.5-3.5-5.5-3.5-9s1-6.5 3.5-9Z",list:"M9 6h11M9 12h11M9 18h11M4.5 6v.01M4.5 12v.01M4.5 18v.01",clock:"M12 20.5a8.5 8.5 0 1 0 0-17 8.5 8.5 0 0 0 0 17ZM12 7.5V12l3 2",timeline:"M4.75 5h7.5a1.75 1.75 0 0 1 0 3.5h-7.5a1.75 1.75 0 0 1 0-3.5ZM9.75 10.25h9.5a1.75 1.75 0 0 1 0 3.5h-9.5a1.75 1.75 0 0 1 0-3.5ZM6.75 15.5h6.5a1.75 1.75 0 0 1 0 3.5h-6.5a1.75 1.75 0 0 1 0-3.5Z",more:"M5.5 12h.01M12 12h.01M18.5 12h.01",library:"M6.5 9h11A2.5 2.5 0 0 1 20 11.5v6a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 4 17.5v-6A2.5 2.5 0 0 1 6.5 9ZM6.5 6h11M8.5 3.25h7M10.75 12.25v4.5l3.75-2.25-3.75-2.25Z",swap:"M7 4.5 4 7.5l3 3M4 7.5h12.5M17 13.5l3 3-3 3M20 16.5H7.5",blank:""},lb={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:[lb[e]!==void 0&&n.jsx("path",{className:"ui-icon-fill",d:lb[e],fill:"currentColor",stroke:"none"}),n.jsx("path",{d:SO[e]})]})}function _O(){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 Xg({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 cb="adg.otherCopies.seen";function EO(e){const t=Se(e.connection.status),i=Se(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 CO({client:e}){const t=EO(e),s=JSON.stringify(t.map(l=>[l.pid,l.warnings])),[i,r]=v.useState(()=>{try{return localStorage.getItem(cb)}catch{return null}});if(t.length===0||i===s)return null;const o=()=>{try{localStorage.setItem(cb,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 AO={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function $O(e){const t=Se(e.connection.status),i=Se(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 IO({client:e,pending:t}){const s=vn(1e3),[i,r]=v.useState(!1),[o,l]=v.useState(null),u=AO[t.action],d=async()=>{r(!0),l(null);try{await e.connection.call("schedule/power/cancel",{})}catch(m){l(m instanceof Error?m.message:String(m))}finally{r(!1)}},h=t.at===void 0?void 0:Math.max(0,Math.ceil((t.at-s)/1e3));return n.jsxs("div",{className:"approval-card power-card",role:"alertdialog","aria-label":`即将${u}`,children:[n.jsxs("div",{className:"approval-head",children:[n.jsx(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 ah(e){const t=Se(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 bw(e){const t=Se(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 Ta(e){return e<1024?`${e} B`:e<1024**2?`${(e/1024).toFixed(0)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}const jc={queued:"排队中",resolving:"读取发布信息",downloading:"下载中",verifying:"校验中",extracting:"解压中",checking:"检查环境",running:"处理中",done:"完成",failed:"失败",cancelled:"已取消"},kw={"maafw-pi":"MaaFramework",cli:"命令行","gui-config":"配置驱动 GUI","generic-process":"通用程序",visual:"界面操作"};function Aa(e){return e!==void 0&&e.endedAt===void 0}function TO(e){const t=Se(e.connection.status),i=Se(e.capabilities).has("skillhub"),[r,o]=v.useState([]),[l,u]=v.useState(0);return v.useEffect(()=>e.connection.on("skillhub/changed",()=>u(d=>d+1)),[e]),v.useEffect(()=>{if(t.state!=="open"||!i)return;let d=!0;return e.connection.call("skillhub/list",{}).then(h=>{d&&o(h.items.filter(m=>{var p;return((p=m.installed)==null?void 0:p.update)===!0&&m.incompatible===void 0}))}).catch(()=>{}),()=>{d=!1}},[e,t.state,i,l]),r}function ub(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 jw="adg.scriptUpdate.later",db=9e3;function hb(){try{return JSON.parse(localStorage.getItem(jw)??"{}")}catch{return{}}}function MO({client:e}){return Se(e.capabilities).has("scripts")?n.jsx(PO,{client:e}):null}function RO({client:e}){return Se(e.capabilities).has("scripts")?n.jsx(OO,{client:e}):null}function OO({client:e}){const{data:t}=ah(e),s=bw(e),[i,r]=v.useState(null),[o,l]=v.useState(hb),[u,d]=v.useState(new Map);if(v.useEffect(()=>{if(t===null)return;let g=!0;return e.connection.call("scripts/settings",{}).then(x=>{g&&r(x.autoUpdate)}).catch(()=>{}),()=>{g=!1}},[e,t]),t===null||i!=="ask")return null;const h=t.scripts.filter(g=>{var x;return((x=g.update)==null?void 0:x.available)===!0&&o[g.id]!==g.update.latest});if(h.length===0)return null;const m=(g,x)=>{const k={...hb(),[g]:x};try{localStorage.setItem(jw,JSON.stringify(k))}catch{}l(k)},p=g=>{d(x=>{const k=new Map(x);return k.delete(g),k}),e.connection.call("scripts/update",{id:g}).catch(x=>d(k=>new Map(k).set(g,Ce(x))))};return h.map(g=>{var w;const x=s.get(g.id),k=Aa(x),b=g.source.kind==="local"?(w=g.localVersion)==null?void 0:w.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,"(当前 ",b??"认不出的版本","),要现在更新吗?",j!==void 0&&n.jsxs("span",{className:"error",children:[" 没有更新成功:",j]})]}),k?n.jsxs("span",{className:"script-update-progress muted",children:[n.jsx("span",{className:"spinner"}),x.message??jc[x.phase],"…"]}):n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"ghost small-button",title:"有更新的版本时再问",onClick:()=>m(g.id,g.update.latest),children:"以后再说"}),n.jsx("button",{type:"button",className:"primary small-button",onClick:()=>p(g.id),children:"更新"})]})]},g.id)})}function 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(LO,{done:o,onClose:()=>r(o.job.id)},o.job.id))}function LO({done:e,onClose:t}){const[s,i]=v.useState(!1);v.useEffect(()=>{if(s)return;const u=setTimeout(t,db);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:`${db}ms`}})]})}function Vs(){return window.adgDesktop}/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */function mb(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 zO(e){if(Array.isArray(e))return e}function DO(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var i,r,o,l,u=[],d=!0,h=!1;try{if(o=(s=s.call(e)).next,t!==0)for(;!(d=(i=o.call(s)).done)&&(u.push(i.value),u.length!==t);d=!0);}catch(m){h=!0,r=m}finally{try{if(!d&&s.return!=null&&(l=s.return(),Object(l)!==l))return}finally{if(h)throw r}}return u}}function FO(){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 UO(e,t){return zO(e)||DO(e,t)||BO(e,t)||FO()}function BO(e,t){if(e){if(typeof e=="string")return mb(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)?mb(e,t):void 0}}const Nw=Object.entries,fb=Object.setPrototypeOf,HO=Object.isFrozen,ww=Object.getPrototypeOf,Sw=Object.getOwnPropertyDescriptor;let Un=Object.freeze,Gn=Object.seal,wo=Object.create,_w=typeof Reflect<"u"&&Reflect,Bp=_w.apply,Hp=_w.construct;Un||(Un=function(t){return t});Gn||(Gn=function(t){return t});Bp||(Bp=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)});Hp||(Hp=function(t){for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;r<s;r++)i[r-1]=arguments[r];return new t(...i)});const cr=en(Array.prototype.forEach),ZO=en(Array.prototype.lastIndexOf),pb=en(Array.prototype.pop),Rl=en(Array.prototype.push),WO=en(Array.prototype.slice),VO=en(Array.prototype.splice),Io=Array.isArray,yf=Ew(Set),bf=en(Set.prototype.add),Ol=en(Set.prototype.has),_a=en(String.prototype.toLowerCase),kf=en(String.prototype.toString),gb=en(String.prototype.match),Pl=en(String.prototype.replace),xb=en(String.prototype.indexOf),qO=en(String.prototype.trim),GO=en(Number.prototype.toString),KO=en(Boolean.prototype.toString),vb=typeof BigInt>"u"?null:en(BigInt.prototype.toString),yb=typeof Symbol>"u"?null:en(Symbol.prototype.toString),Is=en(Object.prototype.hasOwnProperty),Ll=en(Object.prototype.toString),qn=en(RegExp.prototype.test),ur=Ew(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 Bp(e,t,i)}}function Ew(e){return function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return Hp(e,s)}}function Ct(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_a;if(fb&&fb(e,null),!Io(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){const o=s(r);o!==r&&(HO(t)||(t[i]=o),r=o)}e[r]=!0}return e}function YO(e){for(let t=0;t<e.length;t++)Is(e,t)||(e[t]=null);return e}function Fs(e){const t=wo(null);for(const i of Nw(e)){var s=UO(i,2);const r=s[0],o=s[1];Is(e,r)&&(Io(o)?t[r]=YO(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=Fs(o):t[r]=o)}return t}function XO(e){switch(typeof e){case"string":return e;case"number":return GO(e);case"boolean":return KO(e);case"bigint":return vb?vb(e):"0";case"symbol":return yb?yb(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=Sw(e,t);if(i){if(i.get)return en(i.get);if(typeof i.value=="function")return en(i.value)}e=ww(e)}function s(){return null}return s}function QO(e,t){for(;e!==null;){const s=Sw(e,t);if(s)return s.get?en(s.get):null;e=ww(e)}return null}function JO(e){try{return qn(e,""),!0}catch{return!1}}const bb=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"]),jf=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"]),Nf=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"]),eP=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"]),wf=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"]),tP=Un(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),kb=Un(["#text"]),jb=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"]),Sf=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"]),Nb=Un(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ju=Un(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),nP=Gn(/{{[\w\W]*|^[\w\W]*}}/g),sP=Gn(/<%[\w\W]*|^[\w\W]*%>/g),iP=Gn(/\${[\w\W]*/g),rP=Gn(/^data-[\-\w.\u00B7-\uFFFF]+$/),aP=Gn(/^aria-[\-\w]+$/),wb=Gn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),oP=Gn(/^(?:\w+script|data):/i),lP=Gn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),cP=Gn(/^html$/i),uP=Gn(/^[a-z][.\w]*(-[.\w]+)+$/i),_f=Gn(/<[/\w!]/g),Sb=Gn(/<[/\w]/g),dP=Gn(/<\/no(script|embed|frames)/i),_b=Gn(/\/>/i),jn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},hP=Un(Ct({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),mP=function(){return typeof window>"u"?null:window},fP=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}},Eb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Dr=function(t,s,i,r){return Is(t,s)&&Io(t[s])?Ct(r.base?Fs(r.base):{},t[s],r.transform):i},Ef=function(t,s,i){const r=Is(t,s)?t[s]:void 0;return r&&typeof r=="object"?Fs(r):i()};function Cw(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mP();const t=_e=>Cw(_e);if(t.version="3.4.17",t.removed=[],!e||!e.document||e.document.nodeType!==jn.document||!e.Element)return t.isSupported=!1,t;let s=e.document;const i=s,r=i.currentScript;e.DocumentFragment;const o=e.HTMLTemplateElement,l=e.Node,u=e.Element,d=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,m=e.trustedTypes,p=u.prototype,g=ri(p,"cloneNode"),x=ri(p,"remove"),k=ri(p,"removeAttributeNode"),b=ri(p,"nextSibling"),j=ri(p,"childNodes"),w=ri(p,"parentNode"),S=ri(p,"shadowRoot"),_=ri(p,"attributes"),E=l&&l.prototype?ri(l.prototype,"nodeType"):null,M=l&&l.prototype?ri(l.prototype,"nodeName"):null,O=l&&l.prototype?ri(l.prototype,"ownerDocument"):null,B=function(X){return E?E(X):X.nodeType},U=function(X){return M?M(X):X.nodeName},P=QO(p,"namespaceURI"),R=function(X){return P?P(X):X.namespaceURI};if(typeof o=="function"){const _e=s.createElement("template");_e.content&&_e.content.ownerDocument&&(s=_e.content.ownerDocument)}let z,L="",A,T=!1,H=0;const F=function(){if(H>0)throw ur('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},V=function(X){F(),H++;try{return z.createHTML(X)}finally{H--}},D=function(X){F(),H++;try{return z.createScriptURL(X)}finally{H--}},q=function(){return T||(A=fP(m,r),T=!0),A},te=s,G=te.implementation,K=te.createNodeIterator,Z=te.createDocumentFragment,Y=te.getElementsByTagName,Q=i.importNode;let ie=Eb();t.isSupported=typeof Nw=="function"&&typeof w=="function"&&G&&G.createHTMLDocument!==void 0;const re=nP,ne=sP,fe=iP,Ee=rP,Ue=aP,Te=oP,pe=lP,be=uP;let De=wb,Re=null;const ae=Ct({},[...bb,...jf,...Nf,...wf,...kb]);let Fe=null;const ut=Ct({},[...jb,...Sf,...Nb,...Ju]);let gt=Object.seal(wo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Rt=null,En=null;const rt=Object.seal(wo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Pt=!0,rn=!0,Zt=!1,Qt=!0,Ut=!1,Rn=!0,mn=!1,Hn=!1,Gs=null,ps=null,rs=!1,gs=!1,Cn=!1,as=!1,Kn=!0,Zn=!1;const An="user-content-";let Yn=!0,On=!1,ce=null,J={},me=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 He=null;const dt=Ct({},["audio","video","img","source","image","track"]);let Nt=null;const Ze=Ct({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Be="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",yt="http://www.w3.org/1999/xhtml";let St=yt,Xn=!1,xs=null;const ui=Ct({},[Be,Xe,yt],kf),yr=Un(["mi","mo","mn","ms","mtext"]);let di=Ct({},yr);const br=Un(["annotation-xml"]);let Qn=Ct({},br);const Gi=Ct({},["title","style","font","a","script"]);let vs=null;const Mi=["application/xhtml+xml","text/html"],kr="text/html";let zt=null,Os=null;const os=s.createElement("form"),Ki=function(X){return X instanceof RegExp||X instanceof Function},hi=function(){let X=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Os&&Os===X)return;(!X||typeof X!="object")&&(X={}),X=Fs(X),vs=Mi.indexOf(X.PARSER_MEDIA_TYPE)===-1?kr:X.PARSER_MEDIA_TYPE,zt=vs==="application/xhtml+xml"?kf:_a,Re=Dr(X,"ALLOWED_TAGS",ae,{transform:zt}),Fe=Dr(X,"ALLOWED_ATTR",ut,{transform:zt}),xs=Dr(X,"ALLOWED_NAMESPACES",ui,{transform:kf}),Nt=Dr(X,"ADD_URI_SAFE_ATTR",Ze,{transform:zt,base:Ze}),He=Dr(X,"ADD_DATA_URI_TAGS",dt,{transform:zt,base:dt}),me=Dr(X,"FORBID_CONTENTS",we,{transform:zt}),Rt=Dr(X,"FORBID_TAGS",Fs({}),{transform:zt}),En=Dr(X,"FORBID_ATTR",Fs({}),{transform:zt}),J=Is(X,"USE_PROFILES")?X.USE_PROFILES&&typeof X.USE_PROFILES=="object"?Fs(X.USE_PROFILES):X.USE_PROFILES:!1,Pt=X.ALLOW_ARIA_ATTR!==!1,rn=X.ALLOW_DATA_ATTR!==!1,Zt=X.ALLOW_UNKNOWN_PROTOCOLS||!1,Qt=X.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ut=X.SAFE_FOR_TEMPLATES||!1,Rn=X.SAFE_FOR_XML!==!1,mn=X.WHOLE_DOCUMENT||!1,gs=X.RETURN_DOM||!1,Cn=X.RETURN_DOM_FRAGMENT||!1,as=X.RETURN_TRUSTED_TYPE||!1,rs=X.FORCE_BODY||!1,Kn=X.SANITIZE_DOM!==!1,Zn=X.SANITIZE_NAMED_PROPS||!1,Yn=X.KEEP_CONTENT!==!1,On=X.IN_PLACE||!1,De=JO(X.ALLOWED_URI_REGEXP)?X.ALLOWED_URI_REGEXP:wb,St=typeof X.NAMESPACE=="string"?X.NAMESPACE:yt,di=Ef(X,"MATHML_TEXT_INTEGRATION_POINTS",()=>Ct({},yr)),Qn=Ef(X,"HTML_INTEGRATION_POINTS",()=>Ct({},br));const de=Ef(X,"CUSTOM_ELEMENT_HANDLING",()=>wo(null));if(gt=wo(null),Is(de,"tagNameCheck")&&Ki(de.tagNameCheck)&&(gt.tagNameCheck=de.tagNameCheck),Is(de,"attributeNameCheck")&&Ki(de.attributeNameCheck)&&(gt.attributeNameCheck=de.attributeNameCheck),Is(de,"allowCustomizedBuiltInElements")&&typeof de.allowCustomizedBuiltInElements=="boolean"&&(gt.allowCustomizedBuiltInElements=de.allowCustomizedBuiltInElements),Gn(gt),Ut&&(rn=!1),Cn&&(gs=!0),J&&(Re=Ct({},kb),Fe=wo(null),J.html===!0&&(Ct(Re,bb),Ct(Fe,jb)),J.svg===!0&&(Ct(Re,jf),Ct(Fe,Sf),Ct(Fe,Ju)),J.svgFilters===!0&&(Ct(Re,Nf),Ct(Fe,Sf),Ct(Fe,Ju)),J.mathMl===!0&&(Ct(Re,wf),Ct(Fe,Nb),Ct(Fe,Ju))),rt.tagCheck=null,rt.attributeCheck=null,Is(X,"ADD_TAGS")&&(typeof X.ADD_TAGS=="function"?rt.tagCheck=X.ADD_TAGS:Io(X.ADD_TAGS)&&(Re===ae&&(Re=Fs(Re)),Ct(Re,X.ADD_TAGS,zt))),Is(X,"ADD_ATTR")&&(typeof X.ADD_ATTR=="function"?rt.attributeCheck=X.ADD_ATTR:Io(X.ADD_ATTR)&&(Fe===ut&&(Fe=Fs(Fe)),Ct(Fe,X.ADD_ATTR,zt))),Is(X,"ADD_FORBID_CONTENTS")&&Io(X.ADD_FORBID_CONTENTS)&&(me===we&&(me=Fs(me)),Ct(me,X.ADD_FORBID_CONTENTS,zt)),Yn&&(Re["#text"]=!0),mn&&Ct(Re,["html","head","body"]),Re.table&&(Ct(Re,["tbody"]),delete Rt.tbody),X.TRUSTED_TYPES_POLICY){if(typeof X.TRUSTED_TYPES_POLICY.createHTML!="function")throw ur('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof X.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ur('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const je=z;z=X.TRUSTED_TYPES_POLICY;try{L=V("")}catch(Ne){throw z=je,Ne}}else X.TRUSTED_TYPES_POLICY===null?(z=void 0,L=""):(z===void 0&&(z=q()),z&&typeof L=="string"&&(L=V("")));Un&&Un(X),Os=X},Dt=Ct({},[...jf,...Nf,...eP]),jr=Ct({},[...wf,...tP]),Yi=function(X,de,je){return de.namespaceURI===yt?X==="svg":de.namespaceURI===Be?X==="svg"&&(je==="annotation-xml"||di[je]):!!Dt[X]},mi=function(X,de,je){return de.namespaceURI===yt?X==="math":de.namespaceURI===Xe?X==="math"&&Qn[je]:!!jr[X]},Ri=function(X,de,je){return de.namespaceURI===Xe&&!Qn[je]||de.namespaceURI===Be&&!di[je]?!1:!jr[X]&&(Gi[X]||!Dt[X])},Oe=function(X){const de=R(X),je=_a(U(X)),Ne=w(X);let Ye,nt;return Ne&&B(Ne)===jn.element?(Ye={namespaceURI:R(Ne)},nt=_a(U(Ne))):(Ye={namespaceURI:St},nt="template"),xs[de]?de===Xe?Yi(je,Ye,nt):de===Be?mi(je,Ye,nt):de===yt?Ri(je,Ye,nt):!!(vs==="application/xhtml+xml"&&xs[de]):!1},qe=function(X){Rl(t.removed,{element:X});try{w(X).removeChild(X)}catch{if(x(X),!w(X))throw ur("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ht=function(X,de,je){try{k(X,de)}catch{try{X.removeAttribute(je)}catch{}}},ft=function(X){Ks(X);const de=j(X);de&&cr(WO(de),Ne=>{try{x(Ne)}catch{}});const je=B(X)===jn.element?_(X):null;if(je)for(let Ne=je.length-1;Ne>=0;--Ne){const Ye=je[Ne],nt=Ye&&Ye.name;typeof nt=="string"&&ht(X,Ye,nt)}},Ot=function(X,de,je){if(!je)try{je=de.getAttributeNode(X)}catch{je=null}Rl(t.removed,{attribute:je||null,from:de});try{je?k(de,je):de.removeAttribute(X)}catch{try{de.removeAttribute(X)}catch{}}if(X==="is")if(gs||Cn)try{qe(de)}catch{}else try{de.setAttribute(X,"")}catch{}},Ft=function(X){const de=_(X);if(de)for(let je=de.length-1;je>=0;--je){const Ne=de[je],Ye=Ne&&Ne.name;typeof Ye!="string"||Fe[zt(Ye)]||ht(X,Ne,Ye)}},Jn=function(X,de){let je=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const Ne=[X];for(;Ne.length>0;){const Ye=Ne.pop();if(de(Ye)===!1)continue;if(je&&B(Ye)===jn.element){const xt=S(Ye);ks(xt)&&Ne.push(xt)}const nt=j(Ye);if(nt)for(let xt=nt.length-1;xt>=0;--xt)Ne.push(nt[xt])}},Ks=function(X){Jn(X,de=>{B(de)===jn.element&&Ft(de)})},fn=function(X){const de=[];return Jn(X,je=>{de.push(je)},!0),de},$n=function(X,de){const je=yf();cr(fn(X),Ne=>{B(Ne)===jn.element&&bf(je,Ne)}),cr(de,Ne=>{B(Ne)===jn.element&&!Ol(je,Ne)&&Ft(Ne)})},Ys=function(X,de){let je=!1;return cr(t.removed,Ne=>{Ne.element&&(je=je||Ne.element===X,Ks(Ne.element))}),$n(X,de),je},Xs=8,ys=function(X,de){const je=ce;let Ne=null;const Ye=()=>(Ne||(Ne=yf(),cr(de,nt=>{bf(Ne,nt)})),Ne);for(let nt=0;;nt++){const xt=fn(X),pn=[X];let js=!1;if(cr(xt,bn=>{B(bn)===jn.documentFragment?Rl(pn,bn):!js&&!Ol(je,bn)&&(js=Ol(Ye(),bn))}),!js)return;if(nt>=Xs)throw ur("the tree kept changing during in-place sanitization; refusing to return it");cr(pn,(bn,Pn)=>{la(bn,Pn>0,X,Ye())})}},la=function(X,de,je,Ne){const Ye=bs(X);let nt;for(;nt=Ye.nextNode();)!Ol(Ne,nt)||Ol(ce,nt)||(de&&pt(ie.uponSanitizeShadowNode,nt,null),We(nt,je),Ji(nt,je),ks(nt.content)&&ua(nt.content))},Nr=function(X){ce&&bf(ce,X)},Oi=function(X,de){return Rn?X==="patchsrc"?!0:X==="for"&&de!=="label"&&de!=="output":!1},wr=function(X){Rn&&Jn(X,de=>{const je=B(de);if(je===jn.processingInstruction||je===jn.comment&&qn(Sb,de.data)){try{x(de)}catch{}return!1}if(je===jn.element){const Ne=de,Ye=zt(U(de));try{Ne.hasAttribute&&Ne.hasAttribute("patchsrc")&&Ne.removeAttribute("patchsrc"),Ne.hasAttribute&&Ne.hasAttribute("for")&&Oi("for",Ye)&&Ne.removeAttribute("for")}catch{}}return!0})},ls=function(X){let de=null,je=null;if(rs)X="<remove></remove>"+X;else{const nt=gb(X,/^[\r\n\t ]+/);je=nt&&nt[0]}vs==="application/xhtml+xml"&&St===yt&&(X='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+X+"</body></html>");const Ne=z?V(X):X;if(St===yt)try{de=new h().parseFromString(Ne,vs)}catch{}if(!de||!de.documentElement){de=G.createDocument(St,"template",null);try{de.documentElement.innerHTML=Xn?L:Ne}catch{}}const Ye=de.body||de.documentElement;return X&&je&&Ye.insertBefore(s.createTextNode(je),Ye.childNodes[0]||null),St===yt?Y.call(de,mn?"html":"body")[0]:mn?de.documentElement:Ye},bs=function(X){const de=O?O(X):X.ownerDocument;return K.call(de||X,X,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},In=function(X){return X=Pl(X,re," "),X=Pl(X,ne," "),X=Pl(X,fe," "),X},Qs=function(X){var de;wt(X);const je=(de=X.querySelectorAll)===null||de===void 0?void 0:de.call(X,"template");je&&cr(je,Ne=>{ks(Ne.content)&&Qs(Ne.content)})},wt=function(X){X.normalize();const de=O?O(X):X.ownerDocument,je=K.call(de||X,X,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(X){const de=M?M(X):null;return typeof de!="string"||zt(de)!=="form"?!1:typeof X.nodeName!="string"||typeof X.textContent!="string"||typeof X.removeChild!="function"||X.attributes!==_(X)||typeof X.removeAttribute!="function"||typeof X.removeAttributeNode!="function"||typeof X.getAttributeNode!="function"||typeof X.setAttribute!="function"||typeof X.namespaceURI!="string"||typeof X.insertBefore!="function"||typeof X.hasChildNodes!="function"||X.nodeType!==E(X)||X.childNodes!==j(X)},ks=function(X){if(!E||typeof X!="object"||X===null)return!1;try{return E(X)===jn.documentFragment}catch{return!1}},Bt=function(X){if(!E||typeof X!="object"||X===null)return!1;try{return typeof E(X)=="number"}catch{return!1}};function pt(_e,X,de){_e.length!==0&&cr(_e,je=>{je.call(t,X,de,Os)})}const Xi=function(X,de){return!!(Rn&&X.hasChildNodes()&&!Bt(X.firstElementChild)&&qn(_f,X.textContent)&&qn(_f,X.innerHTML)||Rn&&hP[de]&&B(X)===jn.element&&R(X)===yt&&(Bt(X.firstElementChild)||typeof X.textContent=="string"&&qn(_f,X.textContent))||X.nodeType===jn.processingInstruction||Rn&&X.nodeType===jn.comment&&qn(Sb,X.data))},cs=function(X,de){if(X instanceof RegExp)return qn(X,de);if(X instanceof Function){for(var je=arguments.length,Ne=new Array(je>2?je-2:0),Ye=2;Ye<je;Ye++)Ne[Ye-2]=arguments[Ye];return!!X(de,...Ne)}return!1},Qi=function(X,de,je){if(!Rt[de]&&Vt(de)&&cs(gt.tagNameCheck,de))return!1;if(Yn&&!me[de]&&!me[_a(de)]){const Ne=w(X),Ye=j(X);if(Ye&&Ne){const nt=Ye.length;for(let xt=nt-1;xt>=0;--xt){const pn=X===je?g(Ye[xt],!0):Ye[xt];Ne.insertBefore(pn,b(X))}}}return qe(X),!0},fi=function(X,de,je,Ne){return X.length===0?de:de===je||de===Ne?Fs(de):de},Pe=function(X,de){return X===de||w(X)!==null?!1:(On&&Ks(X),!0)},We=function(X,de){if(Nr(X),pt(ie.beforeSanitizeElements,X,null),Pe(X,de))return!0;if(at(X))return qe(X),!0;const je=zt(U(X));if(Re=fi(ie.uponSanitizeElement,Re,ae,Gs),pt(ie.uponSanitizeElement,X,{tagName:je,allowedTags:Re}),Pe(X,de))return!0;if(Xi(X,je))return qe(X),!0;if(Rt[je]||!(rt.tagCheck instanceof Function&&rt.tagCheck(je))&&!Re[je]){const Ne=Qi(X,je,de);return Ne===!1&&(pt(ie.afterSanitizeElements,X,null),Pe(X,de))?!0:Ne}if(B(X)===jn.element&&!Oe(X)||(je==="noscript"||je==="noembed"||je==="noframes")&&qn(dP,X.innerHTML))return qe(X),!0;if(Ut&&X.nodeType===jn.text){const Ne=In(X.textContent);X.textContent!==Ne&&(Rl(t.removed,{element:X.cloneNode()}),X.textContent=Ne)}return pt(ie.afterSanitizeElements,X,null),Pe(X,de)},ot=function(X,de,je){if(En[de]||Oi(de,X)||Kn&&(de==="id"||de==="name")&&(je in s||je in os))return!1;const Ne=Fe[de]||rt.attributeCheck instanceof Function&&rt.attributeCheck(de,X);return rn&&qn(Ee,de)||Pt&&qn(Ue,de)?!0:Ne?Nt[de]||qn(De,Pl(je,pe,""))||(de==="src"||de==="xlink:href"||de==="href")&&X!=="script"&&xb(je,"data:")===0&&He[X]||Zt&&!qn(Te,Pl(je,pe,""))?!0:!je:Vt(X)&&cs(gt.tagNameCheck,X)&&cs(gt.attributeNameCheck,de,X)||de==="is"&&gt.allowCustomizedBuiltInElements&&cs(gt.tagNameCheck,je)},jt=Ct({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Vt=function(X){return!jt[_a(X)]&&qn(be,X)},yn=function(X,de,je,Ne){if(z&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!je)switch(m.getAttributeType(X,de)){case"TrustedHTML":return V(Ne);case"TrustedScriptURL":return D(Ne)}return Ne},rl=function(X,de,je,Ne){try{return je?X.setAttributeNS(je,de,Ne):X.setAttribute(de,Ne),at(X)?(qe(X),!1):!0}catch{return Ot(de,X),!1}},ca=function(X,de){return Rn&&qn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,de)?!0:_a(X)==="attributename"&&gb(de,"href")!==null},Ji=function(X,de){if(pt(ie.beforeSanitizeAttributes,X,null),Pe(X,de))return;const je=X.attributes;if(!je||at(X))return;Fe=fi(ie.uponSanitizeAttribute,Fe,ut,ps);const Ne={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Fe,forceKeepAttr:void 0};let Ye=je.length;const nt=zt(X.nodeName);for(;Ye--;){const xt=je[Ye],pn=xt.name,js=xt.namespaceURI,bn=xt.value,Pn=zt(pn),er=bn;let an=pn==="value"?er:qO(er),Xa=!1;if(Ne.attrName=Pn,Ne.attrValue=an,Ne.keepAttr=!0,Ne.forceKeepAttr=void 0,pt(ie.uponSanitizeAttribute,X,Ne),an=Ne.attrValue,Zn&&(Pn==="id"||Pn==="name")&&xb(an,An)!==0&&(Ot(pn,X,xt),an=An+an,Xa=!0),ca(pn,an)){Ot(pn,X,xt);continue}if(!Ne.forceKeepAttr){if(!Ne.keepAttr){Ot(pn,X,xt);continue}if(!Qt&&qn(_b,an)){Ot(pn,X,xt);continue}if(Ut&&(an=In(an)),!ot(nt,Pn,an)){Ot(pn,X,xt);continue}an=yn(nt,Pn,js,an),an!==er&&rl(X,pn,js,an)&&Xa&&pb(t.removed)}}pt(ie.afterSanitizeAttributes,X,null),Pe(X,de)},ua=function(X){let de=null;const je=bs(X);for(pt(ie.beforeSanitizeShadowDOM,X,null);de=je.nextNode();)if(pt(ie.uponSanitizeShadowNode,de,null),We(de,X),Ji(de,X),ks(de.content)&&ua(de.content),B(de)===jn.element){const Ne=S(de);ks(Ne)&&(Ya(Ne),ua(Ne))}Ut&&wt(X),pt(ie.afterSanitizeShadowDOM,X,null)},Ya=function(X){const de=[{node:X,shadow:null}];for(;de.length>0;){const je=de.pop();if(je.shadow){ua(je.shadow);continue}const Ne=je.node,Ye=B(Ne)===jn.element,nt=j(Ne);if(nt)for(let xt=nt.length-1;xt>=0;--xt)de.push({node:nt[xt],shadow:null});if(Ye){const xt=M?M(Ne):null;if(typeof xt=="string"&&zt(xt)==="template"){const pn=Ne.content;ks(pn)&&de.push({node:pn,shadow:null})}}if(Ye){const xt=S(Ne);ks(xt)&&de.push({node:null,shadow:xt},{node:xt,shadow:null})}}};return t.sanitize=function(_e){let X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},de=null,je=null,Ne=null,Ye=null;if(Xn=!_e,Xn&&(_e="<!-->"),typeof _e!="string"&&!Bt(_e)&&(_e=XO(_e),typeof _e!="string"))throw ur("dirty is not a string, aborting");if(!t.isSupported)return _e;Hn?(Re=Gs,Fe=ps):hi(X),(ie.uponSanitizeElement.length>0||ie.uponSanitizeAttribute.length>0)&&(Re=Fs(Re)),ie.uponSanitizeAttribute.length>0&&(Fe=Fs(Fe)),t.removed=[];const nt=On&&typeof _e!="string"&&Bt(_e);let xt=[];const pn=ce;if(nt){wr(_e);const Pn=U(_e);if(typeof Pn=="string"){const er=zt(Pn);if(!Re[er]||Rt[er])throw ft(_e),ur("root node is forbidden and cannot be sanitized in-place")}if(at(_e))throw ft(_e),ur("root node is clobbered and cannot be sanitized in-place");xt=fn(_e),ce=yf()}else if(Bt(_e))de=ls("<!---->"),je=de.ownerDocument.importNode(_e,!0),je.nodeType===jn.element&&je.nodeName==="BODY"||je.nodeName==="HTML"?de=je:de.appendChild(je),Ya(de);else{if(!gs&&!Ut&&!mn&&_e.indexOf("<")===-1)return z&&as?V(_e):_e;if(de=ls(_e),!de)return gs?null:as?L:""}de&&rs&&qe(de.firstChild);const js=nt?_e:de;try{nt&&Ya(_e);const Pn=bs(js);for(;Ne=Pn.nextNode();)We(Ne,js),Ji(Ne,js),ks(Ne.content)&&ua(Ne.content);nt&&ys(_e,xt)}catch(Pn){throw nt&&(ft(_e),Ys(_e,xt)),Pn}finally{ce=pn}if(nt){if(Ys(_e,xt))throw ur("a node selected for removal could not be safely returned; refusing to sanitize in place");return Ut&&Qs(_e),_e}if(gs){if(Ut&&Qs(de),Cn)for(Ye=Z.call(de.ownerDocument);de.firstChild;)Ye.appendChild(de.firstChild);else Ye=de;return(Fe.shadowroot||Fe.shadowrootmode)&&(Ye=Q.call(i,Ye,!0)),Ye}let bn=mn?de.outerHTML:de.innerHTML;return mn&&Re["!doctype"]&&de.ownerDocument&&de.ownerDocument.doctype&&de.ownerDocument.doctype.name&&qn(cP,de.ownerDocument.doctype.name)&&(bn="<!DOCTYPE "+de.ownerDocument.doctype.name+`>
130
+ `+bn),Ut&&(bn=In(bn)),z&&as?V(bn):bn},t.setConfig=function(){let _e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hi(_e),Hn=!0,Gs=Re,ps=Fe},t.clearConfig=function(){Os=null,Hn=!1,Gs=null,ps=null,z=A,L=""},t.isValidAttribute=function(_e,X,de){Os||hi({});const je=zt(_e),Ne=zt(X);return typeof de=="string"&&(ca(X,de)||!Qt&&qn(_b,de))?!1:ot(je,Ne,de)},t.addHook=function(_e,X){typeof X=="function"&&Is(ie,_e)&&Rl(ie[_e],X)},t.removeHook=function(_e,X){if(Is(ie,_e)){if(X!==void 0){const de=ZO(ie[_e],X);return de===-1?void 0:VO(ie[_e],de,1)[0]}return pb(ie[_e])}},t.removeHooks=function(_e){Is(ie,_e)&&(ie[_e]=[])},t.removeAllHooks=function(){ie=Eb()},t}var Qg=Cw();function Jg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ga=Jg();function Aw(e){Ga=e}var lc={exec:()=>null};function It(e,t=""){let s=typeof e=="string"?e:e.source,i={replace:(r,o)=>{let l=typeof o=="string"?o:o.source;return l=l.replace(fs.caret,"$1"),s=s.replace(r,l),i},getRegex:()=>new RegExp(s,t)};return i}var pP=(()=>{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")},gP=/^(?:[ \t]*(?:\n|$))+/,xP=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,vP=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Uc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,yP=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ex=/(?:[*+-]|\d{1,9}[.)])/,$w=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Iw=It($w).replace(/bull/g,ex).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(),bP=It($w).replace(/bull/g,ex).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(),tx=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,kP=/^[^\n]+/,nx=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,jP=It(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",nx).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),NP=It(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ex).getRegex(),oh="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",sx=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,wP=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",sx).replace("tag",oh).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Tw=It(tx).replace("hr",Uc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",oh).getRegex(),SP=It(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Tw).getRegex(),ix={blockquote:SP,code:xP,def:jP,fences:vP,heading:yP,hr:Uc,html:wP,lheading:Iw,list:NP,newline:gP,paragraph:Tw,table:lc,text:kP},Cb=It("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Uc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",oh).getRegex(),_P={...ix,lheading:bP,table:Cb,paragraph:It(tx).replace("hr",Uc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Cb).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",oh).getRegex()},EP={...ix,html:It(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",sx).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(tx).replace("hr",Uc).replace("heading",` *#{1,6} *[^
131
+ ]`).replace("lheading",Iw).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},CP=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,AP=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Mw=/^( {2,}|\\)\n(?!\s*$)/,$P=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,lh=/[\p{P}\p{S}]/u,rx=/[\s\p{P}\p{S}]/u,Rw=/[^\s\p{P}\p{S}]/u,IP=It(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,rx).getRegex(),Ow=/(?!~)[\p{P}\p{S}]/u,TP=/(?!~)[\s\p{P}\p{S}]/u,MP=/(?:[^\s\p{P}\p{S}]|~)/u,RP=It(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",pP?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Pw=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,OP=It(Pw,"u").replace(/punct/g,lh).getRegex(),PP=It(Pw,"u").replace(/punct/g,Ow).getRegex(),Lw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",LP=It(Lw,"gu").replace(/notPunctSpace/g,Rw).replace(/punctSpace/g,rx).replace(/punct/g,lh).getRegex(),zP=It(Lw,"gu").replace(/notPunctSpace/g,MP).replace(/punctSpace/g,TP).replace(/punct/g,Ow).getRegex(),DP=It("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Rw).replace(/punctSpace/g,rx).replace(/punct/g,lh).getRegex(),FP=It(/\\(punct)/,"gu").replace(/punct/g,lh).getRegex(),UP=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(),BP=It(sx).replace("(?:-->|$)","-->").getRegex(),HP=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",BP).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Md=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,ZP=It(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Md).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),zw=It(/^!?\[(label)\]\[(ref)\]/).replace("label",Md).replace("ref",nx).getRegex(),Dw=It(/^!?\[(ref)\](?:\[\])?/).replace("ref",nx).getRegex(),WP=It("reflink|nolink(?!\\()","g").replace("reflink",zw).replace("nolink",Dw).getRegex(),Ab=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ax={_backpedal:lc,anyPunctuation:FP,autolink:UP,blockSkip:RP,br:Mw,code:AP,del:lc,emStrongLDelim:OP,emStrongRDelimAst:LP,emStrongRDelimUnd:DP,escape:CP,link:ZP,nolink:Dw,punctuation:IP,reflink:zw,reflinkSearch:WP,tag:HP,text:$P,url:lc},VP={...ax,link:It(/^!?\[(label)\]\((.*?)\)/).replace("label",Md).getRegex(),reflink:It(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Md).getRegex()},Zp={...ax,emStrongRDelimAst:zP,emStrongLDelim:PP,url:It(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ab).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",Ab).getRegex()},qP={...Zp,br:It(Mw).replace("{2,}","*").getRegex(),text:It(Zp.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ed={normal:ix,gfm:_P,pedantic:EP},zl={normal:ax,gfm:Zp,breaks:qP,pedantic:VP},GP={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},$b=e=>GP[e];function Ui(e,t){if(t){if(fs.escapeTest.test(e))return e.replace(fs.escapeReplace,$b)}else if(fs.escapeTestNoEncode.test(e))return e.replace(fs.escapeReplaceNoEncode,$b);return e}function Ib(e){try{e=encodeURI(e).replace(fs.percentDecode,"%")}catch{return null}return e}function Tb(e,t){var o;let s=e.replace(fs.findPipe,(l,u,d)=>{let h=!1,m=u;for(;--m>=0&&d[m]==="\\";)h=!h;return h?"|":" |"}),i=s.split(fs.splitPipe),r=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(fs.slashPipe,"|");return i}function Dl(e,t,s){let i=e.length;if(i===0)return"";let r=0;for(;r<i&&e.charAt(i-r-1)===t;)r++;return e.slice(0,i-r)}function KP(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 Mb(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 YP(e,t,s){let i=e.match(s.other.indentCodeCompensation);if(i===null)return t;let r=i[1];return t.split(`
132
+ `).map(o=>{let l=o.match(s.other.beginningSpace);if(l===null)return o;let[u]=l;return u.length>=r.length?o.slice(r.length):o}).join(`
133
+ `)}var Rd=class{constructor(e){mt(this,"options");mt(this,"rules");mt(this,"lexer");this.options=e||Ga}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let s=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?s:Dl(s,`
134
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let s=t[0],i=YP(s,t[3]||"",this.rules);return{type:"code",raw:s,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let s=t[2].trim();if(this.rules.other.endingHash.test(s)){let i=Dl(s,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(s=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Dl(t[0],`
135
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let s=Dl(t[0],`
136
+ `).split(`
137
+ `),i="",r="",o=[];for(;s.length>0;){let l=!1,u=[],d;for(d=0;d<s.length;d++)if(this.rules.other.blockquoteStart.test(s[d]))u.push(s[d]),l=!0;else if(!l)u.push(s[d]);else break;s=s.slice(d);let h=u.join(`
138
+ `),m=h.replace(this.rules.other.blockquoteSetextReplace,`
139
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
140
+ ${h}`:h,r=r?`${r}
141
+ ${m}`:m;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(m,o,!0),this.lexer.state.top=p,s.length===0)break;let g=o.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let x=g,k=x.raw+`
142
+ `+s.join(`
143
+ `),b=this.blockquote(k);o[o.length-1]=b,i=i.substring(0,i.length-x.raw.length)+b.raw,r=r.substring(0,r.length-x.text.length)+b.text;break}else if((g==null?void 0:g.type)==="list"){let x=g,k=x.raw+`
144
+ `+s.join(`
145
+ `),b=this.list(k);o[o.length-1]=b,i=i.substring(0,i.length-g.raw.length)+b.raw,r=r.substring(0,r.length-x.raw.length)+b.raw,s=k.substring(o.at(-1).raw.length).split(`
146
+ `);continue}}return{type:"blockquote",raw:i,tokens:o,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),i=s.length>1,r={type:"list",raw:"",ordered:i,start:i?+s.slice(0,-1):"",loose:!1,items:[]};s=i?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=i?s:"[*+-]");let o=this.rules.other.listItemRegex(s),l=!1;for(;e;){let d=!1,h="",m="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let p=t[2].split(`
147
+ `,1)[0].replace(this.rules.other.listReplaceTabs,w=>" ".repeat(3*w.length)),g=e.split(`
148
+ `,1)[0],x=!p.trim(),k=0;if(this.options.pedantic?(k=2,m=p.trimStart()):x?k=t[1].length+1:(k=t[2].search(this.rules.other.nonSpaceChar),k=k>4?1:k,m=p.slice(k),k+=t[1].length),x&&this.rules.other.blankLine.test(g)&&(h+=g+`
149
+ `,e=e.substring(g.length+1),d=!0),!d){let w=this.rules.other.nextBulletRegex(k),S=this.rules.other.hrRegex(k),_=this.rules.other.fencesBeginRegex(k),E=this.rules.other.headingBeginRegex(k),M=this.rules.other.htmlBeginRegex(k);for(;e;){let O=e.split(`
150
+ `,1)[0],B;if(g=O,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),B=g):B=g.replace(this.rules.other.tabCharGlobal," "),_.test(g)||E.test(g)||M.test(g)||w.test(g)||S.test(g))break;if(B.search(this.rules.other.nonSpaceChar)>=k||!g.trim())m+=`
151
+ `+B.slice(k);else{if(x||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(p)||E.test(p)||S.test(p))break;m+=`
152
+ `+g}!x&&!g.trim()&&(x=!0),h+=O+`
153
+ `,e=e.substring(O.length+1),p=B.slice(k)}}r.loose||(l?r.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(l=!0));let b=null,j;this.options.gfm&&(b=this.rules.other.listIsTask.exec(m),b&&(j=b[0]!=="[ ] ",m=m.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:h,task:!!b,checked:j,loose:!1,text:m,tokens:[]}),r.raw+=h}let u=r.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let d=0;d<r.items.length;d++)if(this.lexer.state.top=!1,r.items[d].tokens=this.lexer.blockTokens(r.items[d].text,[]),!r.loose){let h=r.items[d].tokens.filter(p=>p.type==="space"),m=h.length>0&&h.some(p=>this.rules.other.anyLine.test(p.raw));r.loose=m}if(r.loose)for(let d=0;d<r.items.length;d++)r.items[d].loose=!0;return r}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let s=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:s,raw:t[0],href:i,title:r}}}table(e){var l;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let s=Tb(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(Tb(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=KP(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)),Mb(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 Mb(s,r,s[0],this.lexer,this.rules)}}emStrong(e,t,s=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!s||this.rules.inline.punctuation.exec(s))){let r=[...i[0]].length-1,o,l,u=r,d=0,h=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*e.length+r);(i=h.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(l=[...o].length,i[3]||i[4]){u+=l;continue}else if((i[5]||i[6])&&r%3&&!((r+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);let m=[...i[0]][0].length,p=e.slice(0,r+i.index+m+l);if(Math.min(r,l)%2){let x=p.slice(1,-1);return{type:"em",raw:p,text:x,tokens:this.lexer.inlineTokens(x)}}let g=p.slice(2,-2);return{type:"strong",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let s=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(s),r=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return i&&r&&(s=s.substring(1,s.length-1)),{type:"codespan",raw:t[0],text:s}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let s,i;return t[2]==="@"?(s=t[1],i="mailto:"+s):(s=t[1],i=s),{type:"link",raw:t[0],text:s,href:i,tokens:[{type:"text",raw:s,text:s}]}}}url(e){var s;let t;if(t=this.rules.inline.url.exec(e)){let i,r;if(t[2]==="@")i=t[0],r="mailto:"+i;else{let o;do o=t[0],t[0]=((s=this.rules.inline._backpedal.exec(t[0]))==null?void 0:s[0])??"";while(o!==t[0]);i=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:i,href:r,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let s=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:s}}}},Ni=class Wp{constructor(t){mt(this,"tokens");mt(this,"options");mt(this,"state");mt(this,"tokenizer");mt(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ga,this.options.tokenizer=this.options.tokenizer||new Rd,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let s={other:fs,block:ed.normal,inline:zl.normal};this.options.pedantic?(s.block=ed.pedantic,s.inline=zl.pedantic):this.options.gfm&&(s.block=ed.gfm,this.options.breaks?s.inline=zl.breaks:s.inline=zl.gfm),this.tokenizer.rules=s}static get rules(){return{block:ed,inline:zl}}static lex(t,s){return new Wp(s).lex(t)}static lexInline(t,s){return new Wp(s).inlineTokens(t)}lex(t){t=t.replace(fs.carriageReturn,`
156
+ `),this.blockTokens(t,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){let i=this.inlineQueue[s];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,s=[],i=!1){var r,o,l;for(this.options.pedantic&&(t=t.replace(fs.tabCharGlobal," ").replace(fs.spaceLine,""));t;){let u;if((o=(r=this.options.extensions)==null?void 0:r.block)!=null&&o.some(h=>(u=h.call({lexer:this},t,s))?(t=t.substring(u.raw.length),s.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let h=s.at(-1);u.raw.length===1&&h!==void 0?h.raw+=`
157
+ `:s.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let h=s.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
158
+ `)?"":`
159
+ `)+u.raw,h.text+=`
160
+ `+u.text,this.inlineQueue.at(-1).src=h.text):s.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let h=s.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
161
+ `)?"":`
162
+ `)+u.raw,h.text+=`
163
+ `+u.raw,this.inlineQueue.at(-1).src=h.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},s.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),s.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),s.push(u);continue}let d=t;if((l=this.options.extensions)!=null&&l.startBlock){let h=1/0,m=t.slice(1),p;this.options.extensions.startBlock.forEach(g=>{p=g.call({lexer:this},m),typeof p=="number"&&p>=0&&(h=Math.min(h,p))}),h<1/0&&h>=0&&(d=t.substring(0,h+1))}if(this.state.top&&(u=this.tokenizer.paragraph(d))){let h=s.at(-1);i&&(h==null?void 0:h.type)==="paragraph"?(h.raw+=(h.raw.endsWith(`
164
+ `)?"":`
165
+ `)+u.raw,h.text+=`
166
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):s.push(u),i=d.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let h=s.at(-1);(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
167
+ `)?"":`
168
+ `)+u.raw,h.text+=`
169
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):s.push(u);continue}if(t){let h="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return this.state.top=!0,s}inline(t,s=[]){return this.inlineQueue.push({src:t,tokens:s}),s}inlineTokens(t,s=[]){var d,h,m,p,g;let i=t,r=null;if(this.tokens.links){let x=Object.keys(this.tokens.links);if(x.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)x.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,r.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)o=r[2]?r[2].length:0,i=i.slice(0,r.index+o)+"["+"a".repeat(r[0].length-o-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((h=(d=this.options.hooks)==null?void 0:d.emStrongMask)==null?void 0:h.call({lexer:this},i))??i;let l=!1,u="";for(;t;){l||(u=""),l=!1;let x;if((p=(m=this.options.extensions)==null?void 0:m.inline)!=null&&p.some(b=>(x=b.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 b=s.at(-1);x.type==="text"&&(b==null?void 0:b.type)==="text"?(b.raw+=x.raw,b.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 k=t;if((g=this.options.extensions)!=null&&g.startInline){let b=1/0,j=t.slice(1),w;this.options.extensions.startInline.forEach(S=>{w=S.call({lexer:this},j),typeof w=="number"&&w>=0&&(b=Math.min(b,w))}),b<1/0&&b>=0&&(k=t.substring(0,b+1))}if(x=this.tokenizer.inlineText(k)){t=t.substring(x.raw.length),x.raw.slice(-1)!=="_"&&(u=x.raw.slice(-1)),l=!0;let b=s.at(-1);(b==null?void 0:b.type)==="text"?(b.raw+=x.raw,b.text+=x.text):s.push(x);continue}if(t){let b="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(b);break}else throw new Error(b)}}return s}},Od=class{constructor(e){mt(this,"options");mt(this,"parser");this.options=e||Ga}space(e){return""}code({text:e,lang:t,escaped:s}){var o;let i=(o=(t||"").match(fs.notSpaceStart))==null?void 0:o[0],r=e.replace(fs.endingNewline,"")+`
170
+ `;return i?'<pre><code class="language-'+Ui(i)+'">'+(s?r:Ui(r,!0))+`</code></pre>
171
+ `:"<pre><code>"+(s?r:Ui(r,!0))+`</code></pre>
172
+ `}blockquote({tokens:e}){return`<blockquote>
173
+ ${this.parser.parse(e)}</blockquote>
174
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
175
+ `}hr(e){return`<hr>
176
+ `}list(e){let t=e.ordered,s=e.start,i="";for(let l=0;l<e.items.length;l++){let u=e.items[l];i+=this.listitem(u)}let r=t?"ol":"ul",o=t&&s!==1?' start="'+s+'"':"";return"<"+r+o+`>
177
+ `+i+"</"+r+`>
178
+ `}listitem(e){var s;let t="";if(e.task){let i=this.checkbox({checked:!!e.checked});e.loose?((s=e.tokens[0])==null?void 0:s.type)==="paragraph"?(e.tokens[0].text=i+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=i+" "+Ui(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:i+" ",text:i+" ",escaped:!0}):t+=i+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
179
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
180
+ `}table(e){let t="",s="";for(let r=0;r<e.header.length;r++)s+=this.tablecell(e.header[r]);t+=this.tablerow({text:s});let i="";for(let r=0;r<e.rows.length;r++){let o=e.rows[r];s="";for(let l=0;l<o.length;l++)s+=this.tablecell(o[l]);i+=this.tablerow({text:s})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
181
+ <thead>
182
+ `+t+`</thead>
183
+ `+i+`</table>
184
+ `}tablerow({text:e}){return`<tr>
185
+ ${e}</tr>
186
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),s=e.header?"th":"td";return(e.align?`<${s} align="${e.align}">`:`<${s}>`)+t+`</${s}>
187
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Ui(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:s}){let i=this.parser.parseInline(s),r=Ib(e);if(r===null)return i;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+Ui(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:s,tokens:i}){i&&(s=this.parser.parseInline(i,this.parser.textRenderer));let r=Ib(e);if(r===null)return Ui(s);e=r;let o=`<img src="${e}" alt="${s}"`;return t&&(o+=` title="${Ui(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ui(e.text)}},ox=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 Vp{constructor(t){mt(this,"options");mt(this,"renderer");mt(this,"textRenderer");this.options=t||Ga,this.options.renderer=this.options.renderer||new Od,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ox}static parse(t,s){return new Vp(s).parse(t)}static parseInline(t,s){return new Vp(s).parseInline(t)}parse(t,s=!0){var r,o;let i="";for(let l=0;l<t.length;l++){let u=t[l];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[u.type]){let h=u,m=this.options.extensions.renderers[h.type].call({parser:this},h);if(m!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(h.type)){i+=m||"";continue}}let d=u;switch(d.type){case"space":{i+=this.renderer.space(d);continue}case"hr":{i+=this.renderer.hr(d);continue}case"heading":{i+=this.renderer.heading(d);continue}case"code":{i+=this.renderer.code(d);continue}case"table":{i+=this.renderer.table(d);continue}case"blockquote":{i+=this.renderer.blockquote(d);continue}case"list":{i+=this.renderer.list(d);continue}case"html":{i+=this.renderer.html(d);continue}case"def":{i+=this.renderer.def(d);continue}case"paragraph":{i+=this.renderer.paragraph(d);continue}case"text":{let h=d,m=this.renderer.text(h);for(;l+1<t.length&&t[l+1].type==="text";)h=t[++l],m+=`
188
+ `+this.renderer.text(h);s?i+=this.renderer.paragraph({type:"paragraph",raw:m,text:m,tokens:[{type:"text",raw:m,text:m,escaped:!0}]}):i+=m;continue}default:{let h='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return i}parseInline(t,s=this.renderer){var r,o;let i="";for(let l=0;l<t.length;l++){let u=t[l];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[u.type]){let h=this.options.extensions.renderers[u.type].call({parser:this},u);if(h!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(u.type)){i+=h||"";continue}}let d=u;switch(d.type){case"escape":{i+=s.text(d);break}case"html":{i+=s.html(d);break}case"link":{i+=s.link(d);break}case"image":{i+=s.image(d);break}case"strong":{i+=s.strong(d);break}case"em":{i+=s.em(d);break}case"codespan":{i+=s.codespan(d);break}case"br":{i+=s.br(d);break}case"del":{i+=s.del(d);break}case"text":{i+=s.text(d);break}default:{let h='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return i}},xd,Xl=(xd=class{constructor(e){mt(this,"options");mt(this,"block");this.options=e||Ga}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ni.lex:Ni.lexInline}provideParser(){return this.block?wi.parse:wi.parseInline}},mt(xd,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),mt(xd,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),xd),XP=class{constructor(...e){mt(this,"defaults",Jg());mt(this,"options",this.setOptions);mt(this,"parse",this.parseMarkdown(!0));mt(this,"parseInline",this.parseMarkdown(!1));mt(this,"Parser",wi);mt(this,"Renderer",Od);mt(this,"TextRenderer",ox);mt(this,"Lexer",Ni);mt(this,"Tokenizer",Rd);mt(this,"Hooks",Xl);this.use(...e)}walkTokens(e,t){var i,r;let s=[];for(let o of e)switch(s=s.concat(t.call(this,o)),o.type){case"table":{let l=o;for(let u of l.header)s=s.concat(this.walkTokens(u.tokens,t));for(let u of l.rows)for(let d of u)s=s.concat(this.walkTokens(d.tokens,t));break}case"list":{let l=o;s=s.concat(this.walkTokens(l.items,t));break}default:{let l=o;(r=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&r[l.type]?this.defaults.extensions.childTokens[l.type].forEach(u=>{let d=l[u].flat(1/0);s=s.concat(this.walkTokens(d,t))}):l.tokens&&(s=s.concat(this.walkTokens(l.tokens,t)))}}return s}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(s=>{let i={...s};if(i.async=this.defaults.async||i.async||!1,s.extensions&&(s.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let o=t.renderers[r.name];o?t.renderers[r.name]=function(...l){let u=r.renderer.apply(this,l);return u===!1&&(u=o.apply(this,l)),u}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),i.extensions=t),s.renderer){let r=this.defaults.renderer||new Od(this.defaults);for(let o in s.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let l=o,u=s.renderer[l],d=r[l];r[l]=(...h)=>{let m=u.apply(r,h);return m===!1&&(m=d.apply(r,h)),m||""}}i.renderer=r}if(s.tokenizer){let r=this.defaults.tokenizer||new Rd(this.defaults);for(let o in s.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let l=o,u=s.tokenizer[l],d=r[l];r[l]=(...h)=>{let m=u.apply(r,h);return m===!1&&(m=d.apply(r,h)),m}}i.tokenizer=r}if(s.hooks){let r=this.defaults.hooks||new Xl;for(let o in s.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let l=o,u=s.hooks[l],d=r[l];Xl.passThroughHooks.has(o)?r[l]=h=>{if(this.defaults.async&&Xl.passThroughHooksRespectAsync.has(o))return(async()=>{let p=await u.call(r,h);return d.call(r,p)})();let m=u.call(r,h);return d.call(r,m)}:r[l]=(...h)=>{if(this.defaults.async)return(async()=>{let p=await u.apply(r,h);return p===!1&&(p=await d.apply(r,h)),p})();let m=u.apply(r,h);return m===!1&&(m=d.apply(r,h)),m}}i.hooks=r}if(s.walkTokens){let r=this.defaults.walkTokens,o=s.walkTokens;i.walkTokens=function(l){let u=[];return u.push(o.call(this,l)),r&&(u=u.concat(r.call(this,l))),u}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ni.lex(e,t??this.defaults)}parser(e,t){return wi.parse(e,t??this.defaults)}parseMarkdown(e){return(t,s)=>{let i={...s},r={...this.defaults,...i},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let l=r.hooks?await r.hooks.preprocess(t):t,u=await(r.hooks?await r.hooks.provideLexer():e?Ni.lex:Ni.lexInline)(l,r),d=r.hooks?await r.hooks.processAllTokens(u):u;r.walkTokens&&await Promise.all(this.walkTokens(d,r.walkTokens));let h=await(r.hooks?await r.hooks.provideParser():e?wi.parse:wi.parseInline)(d,r);return r.hooks?await r.hooks.postprocess(h):h})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let l=(r.hooks?r.hooks.provideLexer():e?Ni.lex:Ni.lexInline)(t,r);r.hooks&&(l=r.hooks.processAllTokens(l)),r.walkTokens&&this.walkTokens(l,r.walkTokens);let u=(r.hooks?r.hooks.provideParser():e?wi.parse:wi.parseInline)(l,r);return r.hooks&&(u=r.hooks.postprocess(u)),u}catch(l){return o(l)}}}onError(e,t){return s=>{if(s.message+=`
189
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Ui(s.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(s);throw s}}},Fa=new XP;function Tt(e,t){return Fa.parse(e,t)}Tt.options=Tt.setOptions=function(e){return Fa.setOptions(e),Tt.defaults=Fa.defaults,Aw(Tt.defaults),Tt};Tt.getDefaults=Jg;Tt.defaults=Ga;Tt.use=function(...e){return Fa.use(...e),Tt.defaults=Fa.defaults,Aw(Tt.defaults),Tt};Tt.walkTokens=function(e,t){return Fa.walkTokens(e,t)};Tt.parseInline=Fa.parseInline;Tt.Parser=wi;Tt.parser=wi.parse;Tt.Renderer=Od;Tt.TextRenderer=ox;Tt.Lexer=Ni;Tt.lexer=Ni.lex;Tt.Tokenizer=Rd;Tt.Hooks=Xl;Tt.parse=Tt;Tt.options;Tt.setOptions;Tt.use;Tt.walkTokens;Tt.parseInline;wi.parse;Ni.lex;const Rb=["#ff3b30","#ffcc00","#34c759","#0a84ff","#000000","#ffffff"],QP=[["rect","框"],["arrow","箭头"],["line","直线"],["pen","画笔"]],Ob=[[2,"细"],[4,"中"],[7,"粗"]],JP=.05,Pb=16,Lb=44;function ch({src:e,width:t,height:s,name:i,onClose:r}){const[o,l]=v.useState({src:e,width:t,height:s}),{src:u,width:d,height:h}=o,m=v.useRef(null),p=v.useRef(null),[g,x]=v.useState(()=>eL(t,s)),[k,b]=v.useState({scale:1,x:0,y:0}),[j,w]=v.useState(!1),[S,_]=v.useState("rect"),[E,M]=v.useState(Rb[0]),[O,B]=v.useState(Ob[0][0]),[U,P]=v.useState([]),[R,z]=v.useState(null),[L,A]=v.useState(!0),[T,H]=v.useState(null),F=v.useRef(null),V=v.useRef(null),D=v.useCallback(()=>{var De;const pe=(De=m.current)==null?void 0:De.getBoundingClientRect();if(pe===void 0||pe.width===0)return;const be=Math.min(Pb,(pe.width-24)/d,(pe.height-24)/h);b({scale:be,x:(pe.width-d*be)/2,y:(pe.height-h*be)/2})},[d,h]);v.useLayoutEffect(D,[D]),v.useEffect(()=>{const pe=m.current;if(pe===null||typeof ResizeObserver>"u")return;const be=new ResizeObserver(()=>D());return be.observe(pe),()=>be.disconnect()},[D]);const q=(pe,be,De)=>{var ut;const Re=(ut=m.current)==null?void 0:ut.getBoundingClientRect();if(Re===void 0)return;const ae=be??Re.width/2,Fe=De??Re.height/2;b(gt=>{const Rt=Math.min(Pb,Math.max(JP,gt.scale*pe)),En=Rt/gt.scale;return{scale:Rt,x:ae-(ae-gt.x)*En,y:Fe-(Fe-gt.y)*En}})},te=()=>{var be;const pe=(be=m.current)==null?void 0:be.getBoundingClientRect();pe!==void 0&&b({scale:1,x:(pe.width-d)/2,y:(pe.height-h)/2})};v.useEffect(()=>{const pe=m.current;if(pe===null)return;const be=De=>{De.preventDefault();const Re=pe.getBoundingClientRect();q(Math.exp(-De.deltaY*.0015),De.clientX-Re.left,De.clientY-Re.top)};return pe.addEventListener("wheel",be,{passive:!1}),()=>pe.removeEventListener("wheel",be)});const G=pe=>{H(pe),setTimeout(()=>H(be=>be===pe?null:be),1800)},K=v.useCallback(async(pe,be=0)=>{const De=new Image;De.src=u,await De.decode();const Re=document.createElement("canvas");Re.width=d,Re.height=h;const ae=Re.getContext("2d");ae.drawImage(De,0,0,d,h);for(const gt of pe)sL(ae,gt);if(be===0)return Re;const Fe=document.createElement("canvas");Fe.width=h,Fe.height=d;const ut=Fe.getContext("2d");return ut.translate(h/2,d/2),ut.rotate(be),ut.drawImage(Re,-d/2,-h/2),Fe},[u,d,h]),Z=v.useCallback(async pe=>{try{const be=await K(pe),De=await new Promise((Re,ae)=>be.toBlob(Fe=>Fe===null?ae(new Error("没能生成图片")):Re(Fe),"image/png"));try{await navigator.clipboard.write([new ClipboardItem({"image/png":De})])}catch(Re){const ae=Vs();if((ae==null?void 0:ae.copyImage)===void 0)throw Re;await ae.copyImage(be.toDataURL("image/png"))}G(pe.length>0?"已复制(带标注)":"已复制")}catch(be){G(`复制失败:${be instanceof Error?be.message:String(be)}`)}},[K]),Y=async()=>{const pe=await K(U),be=document.createElement("a");be.href=pe.toDataURL("image/png"),be.download=`${i.replace(/[\\/:*?"<>|]/g,"_").replace(/\.\w+$/,"")}${U.length>0?"-标注":""}.png`,be.click()},Q=async()=>{const pe=await K(U,Math.PI/2);P([]),l({src:pe.toDataURL("image/png"),width:pe.width,height:pe.height})},ie=()=>P(pe=>pe.slice(0,-1));v.useEffect(()=>{const pe=be=>{if(!(p.current===null||!p.current.contains(document.activeElement))){if(be.key==="Escape"){R!==null?(z(null),F.current=null):j?w(!1):r();return}if((be.ctrlKey||be.metaKey)&&be.key.toLowerCase()==="z"){be.preventDefault(),ie();return}if((be.ctrlKey||be.metaKey)&&be.key.toLowerCase()==="c"){be.preventDefault(),Z(U);return}be.key==="0"&&D(),(be.key==="+"||be.key==="=")&&q(1.25),be.key==="-"&&q(.8)}};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)});const re=pe=>{const be=m.current.getBoundingClientRect(),De=(pe.clientX-be.left-k.x)/k.scale,Re=(pe.clientY-be.top-k.y)/k.scale;return[Math.max(0,Math.min(d,De)),Math.max(0,Math.min(h,Re))]},ne=pe=>{if(pe.button!==0&&pe.button!==1)return;if(pe.currentTarget.setPointerCapture(pe.pointerId),!j||pe.button===1){F.current={kind:"pan",sx:pe.clientX,sy:pe.clientY,ox:k.x,oy:k.y};return}const[be,De]=re(pe),Re=O/k.scale;F.current={kind:"mark"},z(S==="pen"?{kind:"pen",points:[[be,De]],color:E,width:Re}:{kind:S,x1:be,y1:De,x2:be,y2:De,color:E,width:Re})},fe=pe=>{const be=F.current;if(be===null)return;if(be.kind==="pan"){b(ae=>({...ae,x:be.ox+pe.clientX-be.sx,y:be.oy+pe.clientY-be.sy}));return}const[De,Re]=re(pe);z(ae=>ae===null?ae:ae.kind==="pen"?{...ae,points:[...ae.points,[De,Re]]}:{...ae,x2:De,y2:Re})},Ee=()=>{const pe=F.current;if(F.current=null,(pe==null?void 0:pe.kind)!=="mark"||R===null||(z(null),(R.kind==="pen"?R.points.length>2?99:0:Math.hypot(R.x2-R.x1,R.y2-R.y1)*k.scale)<4))return;const De=[...U,R];P(De),L&&Z(De)},Ue=pe=>{if(pe.target.closest("button")!==null)return;pe.currentTarget.setPointerCapture(pe.pointerId),V.current={sx:pe.clientX,sy:pe.clientY,ox:g.x,oy:g.y};const be=p.current;be!==null&&x(De=>({...De,w:be.offsetWidth,h:be.offsetHeight}))},Te=pe=>{const be=V.current;be!==null&&x(De=>({...De,x:Math.max(-De.w+120,Math.min(window.innerWidth-120,be.ox+pe.clientX-be.sx)),y:Math.max(0,Math.min(window.innerHeight-40,be.oy+pe.clientY-be.sy))}))};return v.useEffect(()=>{var pe;(pe=p.current)==null||pe.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:Ue,onPointerMove:Te,onPointerUp:()=>{V.current=null},onDoubleClick:D,children:[n.jsx("span",{className:"viewer-name",children:i}),n.jsxs("span",{className:"viewer-dim",children:[d,"×",h]}),n.jsx("button",{className:"viewer-icon",onClick:r,title:"关闭(Esc)","aria-label":"关闭",children:"✕"})]}),n.jsxs("div",{ref:m,className:`viewer-stage ${j?"marking":""}`,onPointerDown:ne,onPointerMove:fe,onPointerUp:Ee,onPointerCancel:Ee,children:[n.jsxs("div",{className:"viewer-canvas",style:{width:d,height:h,transform:`translate(${k.x}px, ${k.y}px) scale(${k.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:[...U,...R===null?[]:[R]].map((pe,be)=>n.jsx(nL,{mark:pe},be))})]}),T!==null&&n.jsx("div",{className:"viewer-toast",role:"status",children:T})]}),j&&n.jsxs("div",{className:"viewer-marks",children:[n.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"标注工具",children:QP.map(([pe,be])=>n.jsx("button",{role:"radio","aria-checked":S===pe,className:`viewer-icon ${S===pe?"active":""}`,title:be,onClick:()=>_(pe),children:n.jsx(tL,{tool:pe})},pe))}),n.jsx("span",{className:"viewer-sep"}),n.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"粗细",children:Ob.map(([pe,be])=>n.jsx("button",{role:"radio","aria-checked":O===pe,className:`viewer-icon ${O===pe?"active":""}`,title:be,onClick:()=>B(pe),children:n.jsx("span",{className:"width-dot",style:{width:pe+3,height:pe+3}})},pe))}),n.jsx("span",{className:"viewer-sep"}),n.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"颜色",children:Rb.map(pe=>n.jsx("button",{role:"radio","aria-checked":E===pe,"aria-label":pe,className:`swatch ${E===pe?"active":""}`,style:{background:pe},onClick:()=>M(pe)},pe))}),n.jsx("span",{className:"viewer-sep"}),n.jsx("button",{className:"viewer-icon",disabled:U.length===0,onClick:ie,title:"撤销(Ctrl+Z)",children:"↶"}),n.jsxs("label",{className:"viewer-check",title:"每画完一笔就把带标注的图片复制到剪贴板",children:[n.jsx("input",{type:"checkbox",checked:L,onChange:pe=>A(pe.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:D,title:"适应窗口(0)",children:[Math.round(k.scale*100),"%"]}),n.jsx("button",{className:"viewer-icon",onClick:()=>q(1.25),title:"放大",children:"+"}),n.jsx("button",{className:"viewer-icon",onClick:te,title:"原始大小",children:"1:1"}),n.jsx("span",{className:"viewer-sep"}),n.jsx("button",{className:"viewer-icon",onClick:()=>void Q(),title:"旋转",children:"⟳"}),n.jsx("button",{className:`viewer-icon ${j?"active":""}`,onClick:()=>w(pe=>!pe),title:"标注:画框、箭头、直线",children:"✎"}),n.jsx("button",{className:"viewer-icon",onClick:()=>void Z(U),title:"复制(Ctrl+C)",children:"⧉"}),n.jsx("button",{className:"viewer-icon",onClick:()=>void Y(),title:"保存",children:"⤓"})]})]}),document.body)}function eL(e,t){const s=Math.round(window.innerWidth*.7),i=Math.round(window.innerHeight*.78)-Lb*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+Lb*2);return{x:Math.round((window.innerWidth-o)/2),y:Math.max(16,Math.round((window.innerHeight-l)/2)),w:o,h:l}}function tL({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 Fw(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 nL({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"?Fw(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 sL(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]=Fw(t);e.moveTo(s[0],s[1]),e.lineTo(t.x2,t.y2),e.lineTo(i[0],i[1])}e.stroke()}const uh=v.createContext(null),Cf=new Map;function iL(e,t){let s=Cf.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(()=>Cf.delete(t.attachmentId)),Cf.set(t.attachmentId,s)}return s}function Uw({image:e}){const t=v.useContext(uh),[s,i]=v.useState(null),[r,o]=v.useState(null),[l,u]=v.useState(!1),d=(t==null?void 0:t.capabilities.get().has("attachments"))===!0;v.useEffect(()=>{if(t===null||!d)return;let m=!0;return iL(t,e).then(p=>{m&&i(p)},p=>{m&&o(p instanceof Error?p.message:String(p))}),()=>{m=!1}},[t,d,e]);const h=e.name??`${e.width}×${e.height} 图片`;return d?r!==null?n.jsxs("span",{className:"stored-image missing",children:[h,"没能加载:",r]}):s===null?n.jsx("span",{className:"stored-image loading",style:{width:e.width+2,aspectRatio:`${e.width+2} / ${e.height+2}`}}):n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"stored-image",onClick:()=>u(!0),title:"点击放大、标注、复制",children:n.jsx("img",{src:s,alt:h,width:e.width,height:e.height})}),l&&n.jsx(ch,{src:s,width:e.width,height:e.height,name:e.name??"screenshot.png",onClose:()=>u(!1)})]}):n.jsxs("span",{className:"stored-image missing",children:[h,"(当前后端不支持显示图片)"]})}var Af,zb;function rL(){if(zb)return Af;zb=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(me=>{const we=J[me],He=typeof we;(He==="object"||He==="function")&&!Object.isFrozen(we)&&e(we)}),J}class t{constructor(me){me.data===void 0&&(me.data={}),this.data=me.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,...me){const we=Object.create(null);for(const He in J)we[He]=J[He];return me.forEach(function(He){for(const dt in He)we[dt]=He[dt]}),we}const r="</span>",o=J=>!!J.scope,l=(J,{prefix:me})=>{if(J.startsWith("language:"))return J.replace("language:","language-");if(J.includes(".")){const we=J.split(".");return[`${me}${we.shift()}`,...we.map((He,dt)=>`${He}${"_".repeat(dt+1)}`)].join(" ")}return`${me}${J}`};class u{constructor(me,we){this.buffer="",this.classPrefix=we.classPrefix,me.walk(this)}addText(me){this.buffer+=s(me)}openNode(me){if(!o(me))return;const we=l(me.scope,{prefix:this.classPrefix});this.span(we)}closeNode(me){o(me)&&(this.buffer+=r)}value(){return this.buffer}span(me){this.buffer+=`<span class="${me}">`}}const d=(J={})=>{const me={children:[]};return Object.assign(me,J),me};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(me){this.top.children.push(me)}openNode(me){const we=d({scope:me});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(me){return this.constructor._walk(me,this.rootNode)}static _walk(me,we){return typeof we=="string"?me.addText(we):we.children&&(me.openNode(we),we.children.forEach(He=>this._walk(me,He)),me.closeNode(we)),me}static _collapse(me){typeof me!="string"&&me.children&&(me.children.every(we=>typeof we=="string")?me.children=[me.children.join("")]:me.children.forEach(we=>{h._collapse(we)}))}}class m extends h{constructor(me){super(),this.options=me}addText(me){me!==""&&this.add(me)}startScope(me){this.openNode(me)}endScope(){this.closeNode()}__addSublanguage(me,we){const He=me.root;we&&(He.scope=`language:${we}`),this.add(He)}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 b("(?=",J,")")}function x(J){return b("(?:",J,")*")}function k(J){return b("(?:",J,")?")}function b(...J){return J.map(we=>p(we)).join("")}function j(J){const me=J[J.length-1];return typeof me=="object"&&me.constructor===Object?(J.splice(J.length-1,1),me):{}}function w(...J){return"("+(j(J).capture?"":"?:")+J.map(He=>p(He)).join("|")+")"}function S(J){return new RegExp(J.toString()+"|").exec("").length-1}function _(J,me){const we=J&&J.exec(me);return we&&we.index===0}const E=new RegExp(w(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function M(J,{joinWith:me}){let we=0;return J.map(He=>{we+=1;const dt=we;let Nt=p(He),Ze="";for(;Nt.length>0;){const Be=E.exec(Nt);if(!Be){Ze+=Nt;break}Ze+=Nt.substring(0,Be.index),Nt=Nt.substring(Be.index+Be[0].length),Be[0][0]==="\\"&&Be[1]?Ze+="\\"+String(Number(Be[1])+dt):(Ze+=Be[0],(Be[0]==="("||/^\(\?[<']/.test(Be[0]))&&we++)}return Ze}).map(He=>`(${He})`).join(me)}const O=/\b\B/,B="[a-zA-Z]\\w*",U="[a-zA-Z_]\\w*",P="\\b\\d+(\\.\\d+)?",R="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",z="\\b(0b[01]+)",L="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",A=(J={})=>{const me=/^#![ ]*\//;return J.binary&&(J.begin=b(me,/.*\b/,J.binary,/\b.*/)),i({scope:"meta",begin:me,end:/$/,relevance:0,"on:begin":(we,He)=>{we.index!==0&&He.ignoreMatch()}},J)},T={begin:"\\\\[\\s\\S]",relevance:0},H={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[T]},F={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[T]},V={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},D=function(J,me,we={}){const He=i({scope:"comment",begin:J,end:me,contains:[]},we);He.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 dt=w("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return He.contains.push({begin:b(/[ ]+/,"(",dt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),He},q=D("//","$"),te=D("/\\*","\\*/"),G=D("#","$"),K={scope:"number",begin:P,relevance:0},Z={scope:"number",begin:R,relevance:0},Y={scope:"number",begin:z,relevance:0},Q={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[T,{begin:/\[/,end:/\]/,relevance:0,contains:[T]}]},ie={scope:"title",begin:B,relevance:0},re={scope:"title",begin:U,relevance:0},ne={begin:"\\.\\s*"+U,relevance:0};var Ee=Object.freeze({__proto__:null,APOS_STRING_MODE:H,BACKSLASH_ESCAPE:T,BINARY_NUMBER_MODE:Y,BINARY_NUMBER_RE:z,COMMENT:D,C_BLOCK_COMMENT_MODE:te,C_LINE_COMMENT_MODE:q,C_NUMBER_MODE:Z,C_NUMBER_RE:R,END_SAME_AS_BEGIN:function(J){return Object.assign(J,{"on:begin":(me,we)=>{we.data._beginMatch=me[1]},"on:end":(me,we)=>{we.data._beginMatch!==me[1]&&we.ignoreMatch()}})},HASH_COMMENT_MODE:G,IDENT_RE:B,MATCH_NOTHING_RE:O,METHOD_GUARD:ne,NUMBER_MODE:K,NUMBER_RE:P,PHRASAL_WORDS_MODE:V,QUOTE_STRING_MODE:F,REGEXP_MODE:Q,RE_STARTERS_RE:L,SHEBANG:A,TITLE_MODE:ie,UNDERSCORE_IDENT_RE:U,UNDERSCORE_TITLE_MODE:re});function Ue(J,me){J.input[J.index-1]==="."&&me.ignoreMatch()}function Te(J,me){J.className!==void 0&&(J.scope=J.className,delete J.className)}function pe(J,me){me&&J.beginKeywords&&(J.begin="\\b("+J.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",J.__beforeBegin=Ue,J.keywords=J.keywords||J.beginKeywords,delete J.beginKeywords,J.relevance===void 0&&(J.relevance=0))}function be(J,me){Array.isArray(J.illegal)&&(J.illegal=w(...J.illegal))}function De(J,me){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,me){J.relevance===void 0&&(J.relevance=1)}const ae=(J,me)=>{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(He=>{delete J[He]}),J.keywords=we.keywords,J.begin=b(we.beforeMatch,g(we.begin)),J.starts={relevance:0,contains:[Object.assign(we,{endsParent:!0})]},J.relevance=0,delete we.beforeMatch},Fe=["of","and","for","in","not","or","if","then","parent","list","value"],ut="keyword";function gt(J,me,we=ut){const He=Object.create(null);return typeof J=="string"?dt(we,J.split(" ")):Array.isArray(J)?dt(we,J):Object.keys(J).forEach(function(Nt){Object.assign(He,gt(J[Nt],me,Nt))}),He;function dt(Nt,Ze){me&&(Ze=Ze.map(Be=>Be.toLowerCase())),Ze.forEach(function(Be){const Xe=Be.split("|");He[Xe[0]]=[Nt,Rt(Xe[0],Xe[1])]})}}function Rt(J,me){return me?Number(me):En(J)?0:1}function En(J){return Fe.includes(J.toLowerCase())}const rt={},Pt=J=>{console.error(J)},rn=(J,...me)=>{console.log(`WARN: ${J}`,...me)},Zt=(J,me)=>{rt[`${J}/${me}`]||(console.log(`Deprecated as of ${J}. ${me}`),rt[`${J}/${me}`]=!0)},Qt=new Error;function Ut(J,me,{key:we}){let He=0;const dt=J[we],Nt={},Ze={};for(let Be=1;Be<=me.length;Be++)Ze[Be+He]=dt[Be],Nt[Be+He]=!0,He+=S(me[Be-1]);J[we]=Ze,J[we]._emit=Nt,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=M(J.begin,{joinWith:""})}}function mn(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=M(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),mn(J)}function ps(J){function me(Ze,Be){return new RegExp(p(Ze),"m"+(J.case_insensitive?"i":"")+(J.unicodeRegex?"u":"")+(Be?"g":""))}class we{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Be,Xe){Xe.position=this.position++,this.matchIndexes[this.matchAt]=Xe,this.regexes.push([Xe,Be]),this.matchAt+=S(Be)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Be=this.regexes.map(Xe=>Xe[1]);this.matcherRe=me(M(Be,{joinWith:"|"}),!0),this.lastIndex=0}exec(Be){this.matcherRe.lastIndex=this.lastIndex;const Xe=this.matcherRe.exec(Be);if(!Xe)return null;const yt=Xe.findIndex((Xn,xs)=>xs>0&&Xn!==void 0),St=this.matchIndexes[yt];return Xe.splice(0,yt),Object.assign(Xe,St)}}class He{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Be){if(this.multiRegexes[Be])return this.multiRegexes[Be];const Xe=new we;return this.rules.slice(Be).forEach(([yt,St])=>Xe.addRule(yt,St)),Xe.compile(),this.multiRegexes[Be]=Xe,Xe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Be,Xe){this.rules.push([Be,Xe]),Xe.type==="begin"&&this.count++}exec(Be){const Xe=this.getMatcher(this.regexIndex);Xe.lastIndex=this.lastIndex;let yt=Xe.exec(Be);if(this.resumingScanAtSamePosition()&&!(yt&&yt.index===this.lastIndex)){const St=this.getMatcher(0);St.lastIndex=this.lastIndex+1,yt=St.exec(Be)}return yt&&(this.regexIndex+=yt.position+1,this.regexIndex===this.count&&this.considerAll()),yt}}function dt(Ze){const Be=new He;return Ze.contains.forEach(Xe=>Be.addRule(Xe.begin,{rule:Xe,type:"begin"})),Ze.terminatorEnd&&Be.addRule(Ze.terminatorEnd,{type:"end"}),Ze.illegal&&Be.addRule(Ze.illegal,{type:"illegal"}),Be}function Nt(Ze,Be){const Xe=Ze;if(Ze.isCompiled)return Xe;[Te,De,Gs,ae].forEach(St=>St(Ze,Be)),J.compilerExtensions.forEach(St=>St(Ze,Be)),Ze.__beforeBegin=null,[pe,be,Re].forEach(St=>St(Ze,Be)),Ze.isCompiled=!0;let yt=null;return typeof Ze.keywords=="object"&&Ze.keywords.$pattern&&(Ze.keywords=Object.assign({},Ze.keywords),yt=Ze.keywords.$pattern,delete Ze.keywords.$pattern),yt=yt||/\w+/,Ze.keywords&&(Ze.keywords=gt(Ze.keywords,J.case_insensitive)),Xe.keywordPatternRe=me(yt,!0),Be&&(Ze.begin||(Ze.begin=/\B|\b/),Xe.beginRe=me(Xe.begin),!Ze.end&&!Ze.endsWithParent&&(Ze.end=/\B|\b/),Ze.end&&(Xe.endRe=me(Xe.end)),Xe.terminatorEnd=p(Xe.end)||"",Ze.endsWithParent&&Be.terminatorEnd&&(Xe.terminatorEnd+=(Ze.end?"|":"")+Be.terminatorEnd)),Ze.illegal&&(Xe.illegalRe=me(Ze.illegal)),Ze.contains||(Ze.contains=[]),Ze.contains=[].concat(...Ze.contains.map(function(St){return gs(St==="self"?Ze:St)})),Ze.contains.forEach(function(St){Nt(St,Xe)}),Ze.starts&&Nt(Ze.starts,Be),Xe.matcher=dt(Xe),Xe}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||{}),Nt(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(me){return i(J,{variants:null},me)})),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(me,we){super(me),this.name="HTMLInjectionError",this.html=we}}const Kn=s,Zn=i,An=Symbol("nomatch"),Yn=7,On=function(J){const me=Object.create(null),we=Object.create(null),He=[];let dt=!0;const Nt="Could not find the language '{}', did you forget to load/include a language module?",Ze={disableAutodetect:!0,name:"Plain text",contains:[]};let Be={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:m};function Xe(Oe){return Be.noHighlightRe.test(Oe)}function yt(Oe){let qe=Oe.className+" ";qe+=Oe.parentNode?Oe.parentNode.className:"";const ht=Be.languageDetectRe.exec(qe);if(ht){const ft=os(ht[1]);return ft||(rn(Nt.replace("{}",ht[1])),rn("Falling back to no-highlight mode for this block.",Oe)),ft?ht[1]:"no-highlight"}return qe.split(/\s+/).find(ft=>Xe(ft)||os(ft))}function St(Oe,qe,ht){let ft="",Ot="";typeof qe=="object"?(ft=Oe,ht=qe.ignoreIllegals,Ot=qe.language):(Zt("10.7.0","highlight(lang, code, ...args) has been deprecated."),Zt("10.7.0",`Please use highlight(code, options) instead.
190
+ https://github.com/highlightjs/highlight.js/issues/2277`),Ot=Oe,ft=qe),ht===void 0&&(ht=!0);const Ft={code:ft,language:Ot};mi("before:highlight",Ft);const Jn=Ft.result?Ft.result:Xn(Ft.language,Ft.code,ht);return Jn.code=Ft.code,mi("after:highlight",Jn),Jn}function Xn(Oe,qe,ht,ft){const Ot=Object.create(null);function Ft(Pe,We){return Pe.keywords[We]}function Jn(){if(!at.keywords){Bt.addText(pt);return}let Pe=0;at.keywordPatternRe.lastIndex=0;let We=at.keywordPatternRe.exec(pt),ot="";for(;We;){ot+=pt.substring(Pe,We.index);const jt=In.case_insensitive?We[0].toLowerCase():We[0],Vt=Ft(at,jt);if(Vt){const[yn,rl]=Vt;if(Bt.addText(ot),ot="",Ot[jt]=(Ot[jt]||0)+1,Ot[jt]<=Yn&&(Xi+=rl),yn.startsWith("_"))ot+=We[0];else{const ca=In.classNameAliases[yn]||yn;$n(We[0],ca)}}else ot+=We[0];Pe=at.keywordPatternRe.lastIndex,We=at.keywordPatternRe.exec(pt)}ot+=pt.substring(Pe),Bt.addText(ot)}function Ks(){if(pt==="")return;let Pe=null;if(typeof at.subLanguage=="string"){if(!me[at.subLanguage]){Bt.addText(pt);return}Pe=Xn(at.subLanguage,pt,!0,ks[at.subLanguage]),ks[at.subLanguage]=Pe._top}else Pe=ui(pt,at.subLanguage.length?at.subLanguage:null);at.relevance>0&&(Xi+=Pe.relevance),Bt.__addSublanguage(Pe._emitter,Pe.language)}function fn(){at.subLanguage!=null?Ks():Jn(),pt=""}function $n(Pe,We){Pe!==""&&(Bt.startScope(We),Bt.addText(Pe),Bt.endScope())}function Ys(Pe,We){let ot=1;const jt=We.length-1;for(;ot<=jt;){if(!Pe._emit[ot]){ot++;continue}const Vt=In.classNameAliases[Pe[ot]]||Pe[ot],yn=We[ot];Vt?$n(yn,Vt):(pt=yn,Jn(),pt=""),ot++}}function Xs(Pe,We){return Pe.scope&&typeof Pe.scope=="string"&&Bt.openNode(In.classNameAliases[Pe.scope]||Pe.scope),Pe.beginScope&&(Pe.beginScope._wrap?($n(pt,In.classNameAliases[Pe.beginScope._wrap]||Pe.beginScope._wrap),pt=""):Pe.beginScope._multi&&(Ys(Pe.beginScope,We),pt="")),at=Object.create(Pe,{parent:{value:at}}),at}function ys(Pe,We,ot){let jt=_(Pe.endRe,ot);if(jt){if(Pe["on:end"]){const Vt=new t(Pe);Pe["on:end"](We,Vt),Vt.isMatchIgnored&&(jt=!1)}if(jt){for(;Pe.endsParent&&Pe.parent;)Pe=Pe.parent;return Pe}}if(Pe.endsWithParent)return ys(Pe.parent,We,ot)}function la(Pe){return at.matcher.regexIndex===0?(pt+=Pe[0],1):(fi=!0,0)}function Nr(Pe){const We=Pe[0],ot=Pe.rule,jt=new t(ot),Vt=[ot.__beforeBegin,ot["on:begin"]];for(const yn of Vt)if(yn&&(yn(Pe,jt),jt.isMatchIgnored))return la(We);return ot.skip?pt+=We:(ot.excludeBegin&&(pt+=We),fn(),!ot.returnBegin&&!ot.excludeBegin&&(pt=We)),Xs(ot,Pe),ot.returnBegin?0:We.length}function Oi(Pe){const We=Pe[0],ot=qe.substring(Pe.index),jt=ys(at,Pe,ot);if(!jt)return An;const Vt=at;at.endScope&&at.endScope._wrap?(fn(),$n(We,at.endScope._wrap)):at.endScope&&at.endScope._multi?(fn(),Ys(at.endScope,Pe)):Vt.skip?pt+=We:(Vt.returnEnd||Vt.excludeEnd||(pt+=We),fn(),Vt.excludeEnd&&(pt=We));do at.scope&&Bt.closeNode(),!at.skip&&!at.subLanguage&&(Xi+=at.relevance),at=at.parent;while(at!==jt.parent);return jt.starts&&Xs(jt.starts,Pe),Vt.returnEnd?0:We.length}function wr(){const Pe=[];for(let We=at;We!==In;We=We.parent)We.scope&&Pe.unshift(We.scope);Pe.forEach(We=>Bt.openNode(We))}let ls={};function bs(Pe,We){const ot=We&&We[0];if(pt+=Pe,ot==null)return fn(),0;if(ls.type==="begin"&&We.type==="end"&&ls.index===We.index&&ot===""){if(pt+=qe.slice(We.index,We.index+1),!dt){const jt=new Error(`0 width match regex (${Oe})`);throw jt.languageName=Oe,jt.badRule=ls.rule,jt}return 1}if(ls=We,We.type==="begin")return Nr(We);if(We.type==="illegal"&&!ht){const jt=new Error('Illegal lexeme "'+ot+'" for mode "'+(at.scope||"<unnamed>")+'"');throw jt.mode=at,jt}else if(We.type==="end"){const jt=Oi(We);if(jt!==An)return jt}if(We.type==="illegal"&&ot==="")return We.index===qe.length||(pt+=`
191
+ `),1;if(Qi>1e5&&Qi>We.index*3)throw new Error("potential infinite loop, way more iterations than matches");return pt+=ot,ot.length}const In=os(Oe);if(!In)throw Pt(Nt.replace("{}",Oe)),new Error('Unknown language: "'+Oe+'"');const Qs=ps(In);let wt="",at=ft||Qs;const ks={},Bt=new Be.__emitter(Be);wr();let pt="",Xi=0,cs=0,Qi=0,fi=!1;try{if(In.__emitTokens)In.__emitTokens(qe,Bt);else{for(at.matcher.considerAll();;){Qi++,fi?fi=!1:at.matcher.considerAll(),at.matcher.lastIndex=cs;const Pe=at.matcher.exec(qe);if(!Pe)break;const We=qe.substring(cs,Pe.index),ot=bs(We,Pe);cs=Pe.index+ot}bs(qe.substring(cs))}return Bt.finalize(),wt=Bt.toHTML(),{language:Oe,value:wt,relevance:Xi,illegal:!1,_emitter:Bt,_top:at}}catch(Pe){if(Pe.message&&Pe.message.includes("Illegal"))return{language:Oe,value:Kn(qe),illegal:!0,relevance:0,_illegalBy:{message:Pe.message,index:cs,context:qe.slice(cs-100,cs+100),mode:Pe.mode,resultSoFar:wt},_emitter:Bt};if(dt)return{language:Oe,value:Kn(qe),illegal:!1,relevance:0,errorRaised:Pe,_emitter:Bt,_top:at};throw Pe}}function xs(Oe){const qe={value:Kn(Oe),illegal:!1,relevance:0,_top:Ze,_emitter:new Be.__emitter(Be)};return qe._emitter.addText(Oe),qe}function ui(Oe,qe){qe=qe||Be.languages||Object.keys(me);const ht=xs(Oe),ft=qe.filter(os).filter(hi).map(fn=>Xn(fn,Oe,!1));ft.unshift(ht);const Ot=ft.sort((fn,$n)=>{if(fn.relevance!==$n.relevance)return $n.relevance-fn.relevance;if(fn.language&&$n.language){if(os(fn.language).supersetOf===$n.language)return 1;if(os($n.language).supersetOf===fn.language)return-1}return 0}),[Ft,Jn]=Ot,Ks=Ft;return Ks.secondBest=Jn,Ks}function yr(Oe,qe,ht){const ft=qe&&we[qe]||ht;Oe.classList.add("hljs"),Oe.classList.add(`language-${ft}`)}function di(Oe){let qe=null;const ht=yt(Oe);if(Xe(ht))return;if(mi("before:highlightElement",{el:Oe,language:ht}),Oe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Oe);return}if(Oe.children.length>0&&(Be.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(Oe)),Be.throwUnescapedHTML))throw new as("One of your code blocks includes unescaped HTML.",Oe.innerHTML);qe=Oe;const ft=qe.textContent,Ot=ht?St(ft,{language:ht,ignoreIllegals:!0}):ui(ft);Oe.innerHTML=Ot.value,Oe.dataset.highlighted="yes",yr(Oe,ht,Ot.language),Oe.result={language:Ot.language,re:Ot.relevance,relevance:Ot.relevance},Ot.secondBest&&(Oe.secondBest={language:Ot.secondBest.language,relevance:Ot.secondBest.relevance}),mi("after:highlightElement",{el:Oe,result:Ot,text:ft})}function br(Oe){Be=Zn(Be,Oe)}const Qn=()=>{Mi(),Zt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Gi(){Mi(),Zt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let vs=!1;function Mi(){function Oe(){Mi()}if(document.readyState==="loading"){vs||window.addEventListener("DOMContentLoaded",Oe,!1),vs=!0;return}document.querySelectorAll(Be.cssSelector).forEach(di)}function kr(Oe,qe){let ht=null;try{ht=qe(J)}catch(ft){if(Pt("Language definition for '{}' could not be registered.".replace("{}",Oe)),dt)Pt(ft);else throw ft;ht=Ze}ht.name||(ht.name=Oe),me[Oe]=ht,ht.rawDefinition=qe.bind(null,J),ht.aliases&&Ki(ht.aliases,{languageName:Oe})}function zt(Oe){delete me[Oe];for(const qe of Object.keys(we))we[qe]===Oe&&delete we[qe]}function Os(){return Object.keys(me)}function os(Oe){return Oe=(Oe||"").toLowerCase(),me[Oe]||me[we[Oe]]}function Ki(Oe,{languageName:qe}){typeof Oe=="string"&&(Oe=[Oe]),Oe.forEach(ht=>{we[ht.toLowerCase()]=qe})}function hi(Oe){const qe=os(Oe);return qe&&!qe.disableAutodetect}function Dt(Oe){Oe["before:highlightBlock"]&&!Oe["before:highlightElement"]&&(Oe["before:highlightElement"]=qe=>{Oe["before:highlightBlock"](Object.assign({block:qe.el},qe))}),Oe["after:highlightBlock"]&&!Oe["after:highlightElement"]&&(Oe["after:highlightElement"]=qe=>{Oe["after:highlightBlock"](Object.assign({block:qe.el},qe))})}function jr(Oe){Dt(Oe),He.push(Oe)}function Yi(Oe){const qe=He.indexOf(Oe);qe!==-1&&He.splice(qe,1)}function mi(Oe,qe){const ht=Oe;He.forEach(function(ft){ft[ht]&&ft[ht](qe)})}function Ri(Oe){return Zt("10.7.0","highlightBlock will be removed entirely in v12.0"),Zt("10.7.0","Please use highlightElement now."),di(Oe)}Object.assign(J,{highlight:St,highlightAuto:ui,highlightAll:Mi,highlightElement:di,highlightBlock:Ri,configure:br,initHighlighting:Qn,initHighlightingOnLoad:Gi,registerLanguage:kr,unregisterLanguage:zt,listLanguages:Os,getLanguage:os,registerAliases:Ki,autoDetection:hi,inherit:Zn,addPlugin:jr,removePlugin:Yi}),J.debugMode=function(){dt=!1},J.safeMode=function(){dt=!0},J.versionString=Cn,J.regex={concat:b,lookahead:g,either:w,optional:k,anyNumberOfTimes:x};for(const Oe in Ee)typeof Ee[Oe]=="object"&&e(Ee[Oe]);return Object.assign(J,Ee),J},ce=On({});return ce.newInstance=()=>On({}),Af=ce,ce.HighlightJS=ce,ce.default=ce,Af}var aL=rL();const Ci=Tg(aL);function oL(e){const t=e.regex,s={},i={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[s]}]};Object.assign(s,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},i]});const r={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},o=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),l={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},u={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,s,r]};r.contains.push(u);const d={match:/\\"/},h={className:"string",begin:/'/,end:/'/},m={match:/\\'/},p={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,s]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],x=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),k={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},b=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],j=["true","false"],w={match:/(\/[a-z._-]+)+/},S=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],_=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],E=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],M=["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:b,literal:j,built_in:[...S,..._,"set","shopt",...E,...M]},contains:[x,e.SHEBANG(),k,p,o,l,w,u,d,h,m,s]}}const lL=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_-]*/}}),cL=["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"],uL=["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"],dL=[...cL,...uL],hL=["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(),mL=["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(),fL=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),pL=["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 gL(e){const t=e.regex,s=lL(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:":("+mL.join("|")+")"},{begin:":(:)?("+fL.join("|")+")"}]},s.CSS_VARIABLE,{className:"attribute",begin:"\\b("+pL.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:hL.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,s.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+dL.join("|")+")\\b"}]}}function xL(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 vL(e){const o={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:o,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\b0[bB](_?[01])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:o,illegal:/["']/}]}]}}var So="[0-9](_*[0-9])*",td=`\\.(${So})`,nd="[0-9a-fA-F](_*[0-9a-fA-F])*",Db={className:"number",variants:[{begin:`(\\b(${So})((${td})|\\.)?|(${td}))[eE][+-]?(${So})[fFdD]?\\b`},{begin:`\\b(${So})((${td})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${td})[fFdD]?\\b`},{begin:`\\b(${So})[fFdD]\\b`},{begin:`\\b0[xX]((${nd})\\.?|(${nd})?\\.(${nd}))[pP][+-]?(${So})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${nd})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Bw(e,t,s){return s===-1?"":e.replace(t,i=>Bw(e,t,s-1))}function yL(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=Bw("(?:\\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"]}]},k={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:[k,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,Db,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},Db,x]}}const Fb="[A-Za-z$_][0-9A-Za-z$_]*",bL=["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"],kL=["true","false","null","undefined","NaN","Infinity"],Hw=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Zw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Ww=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],jL=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],NL=[].concat(Ww,Hw,Zw);function wL(e){const t=e.regex,s=(D,{after:q})=>{const te="</"+D[0].slice(1);return D.input.indexOf(te,q)!==-1},i=Fb,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(D,q)=>{const te=D[0].length+D.index,G=D.input[te];if(G==="<"||G===","){q.ignoreMatch();return}G===">"&&(s(D,{after:te})||q.ignoreMatch());let K;const Z=D.input.substring(te);if(K=Z.match(/^\s*=/)){q.ignoreMatch();return}if((K=Z.match(/^\s+extends\s+/))&&K.index===0){q.ignoreMatch();return}}},u={$pattern:Fb,keyword:bL,literal:kL,built_in:NL,"variable.language":jL},d="[0-9](_?[0-9])*",h=`\\.(${d})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${m})((${h})|\\.)?|(${h}))[eE][+-]?(${d})\\b`},{begin:`\\b(${m})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},k={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},j={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},S={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]},_=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,k,b,j,{match:/\$\d+/},p];g.contains=_.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(_)});const E=[].concat(S,g.contains),M=E.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(E)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:M},B={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"}}]},U={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Hw,...Zw]}},P={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},R={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function L(D){return t.concat("(?!",D.join("|"),")")}const A={match:t.concat(/\b/,L([...Ww,"super","import","await"].map(D=>`${D}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},T={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},H={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},O]},F="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",V={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(F)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:U},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),P,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,k,b,j,S,{match:/\$\d+/},p,U,{scope:"attr",match:i+t.lookahead(":"),relevance:0},V,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[S,e.REGEXP_MODE,{className:"function",begin:F,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:M}]}]},{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"]}]}]},R,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},T,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},A,z,B,H,{match:/\$[(.]/}]}}const SL="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",_L={scope:"number",match:SL,relevance:0};function EL(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,_L,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function CL(e){const t=e.regex,s={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},i={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},r={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},o={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,d={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,u,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},m={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=e.inherit(h,{contains:[]}),g=e.inherit(m,{contains:[]});h.contains.push(g),m.contains.push(p);let x=[s,d];return[h,m,p,g].forEach(w=>{w.contains=w.contains.concat(x)}),x=x.concat(h,m),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:x},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:x}]}]},s,o,i,h,m,{className:"quote",begin:"^>\\s+",contains:x,end:"$"},r,d,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function AL(e){const t=e.regex,s=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),i=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],u={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:i,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},d={className:"meta",begin:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},m={begin:/\{\{/,relevance:0},p={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,d,m,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d,m,h]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,m,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,m,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",x=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,k=`\\b|${i.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${x}))[eE][+-]?(${g})[jJ]?(?=${k})`},{begin:`(${x})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${k})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${k})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${k})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${k})`},{begin:`\\b(${g})[jJ](?=${k})`}]},j={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},w={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",d,b,p,e.HASH_COMMENT_MODE]}]};return h.contains=[p,b,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[d,b,{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:[w]},{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:[b,w,p]}]}}function $L(e){const t=e.regex,s=/(r#)?/,i=t.concat(s,e.UNDERSCORE_IDENT_RE),r=t.concat(s,e.IDENT_RE),o={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,r,t.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",u=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],d=["true","false","Some","None","Ok","Err"],h=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],m=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:m,keyword:u,literal:d,built_in:h},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,i],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,i],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,i,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,i],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,i],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:h,type:m}},{scope:"punctuation",begin:"->"},o]}}function IL(e){const t=e.regex,s=e.COMMENT("--","$"),i={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},r={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],l=["double precision","large object","with timezone","without timezone"],u=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],d=["add","asc","collation","desc","final","first","last","view"],h=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],m=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],p=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],g=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],x=m,k=[...h,...d].filter(M=>!m.includes(M)),b={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},j={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},w={match:t.concat(/\b/,t.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function S(M){return t.concat(/\b/,t.either(...M.map(O=>O.replace(/\s+/,"\\s+"))),/\b/)}const _={scope:"keyword",match:S(g),relevance:0};function E(M,{exceptions:O,when:B}={}){const U=B;return O=O||[],M.map(P=>P.match(/\|\d+$/)||O.includes(P)?P:U(P)?`${P}|0`:P)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:E(k,{when:M=>M.length<3}),literal:o,type:u,built_in:p},contains:[{scope:"type",match:S(l)},_,w,b,i,r,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,s,j]}}const Pd="[A-Za-z$_][0-9A-Za-z$_]*",Vw=["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"],qw=["true","false","null","undefined","NaN","Infinity"],Gw=["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"],Kw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Yw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Xw=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],Qw=[].concat(Yw,Gw,Kw);function TL(e){const t=e.regex,s=(D,{after:q})=>{const te="</"+D[0].slice(1);return D.input.indexOf(te,q)!==-1},i=Pd,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(D,q)=>{const te=D[0].length+D.index,G=D.input[te];if(G==="<"||G===","){q.ignoreMatch();return}G===">"&&(s(D,{after:te})||q.ignoreMatch());let K;const Z=D.input.substring(te);if(K=Z.match(/^\s*=/)){q.ignoreMatch();return}if((K=Z.match(/^\s+extends\s+/))&&K.index===0){q.ignoreMatch();return}}},u={$pattern:Pd,keyword:Vw,literal:qw,built_in:Qw,"variable.language":Xw},d="[0-9](_?[0-9])*",h=`\\.(${d})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${m})((${h})|\\.)?|(${h}))[eE][+-]?(${d})\\b`},{begin:`\\b(${m})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},k={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},b={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},j={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},S={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]},_=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,k,b,j,{match:/\$\d+/},p];g.contains=_.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(_)});const E=[].concat(S,g.contains),M=E.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(E)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:M},B={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"}}]},U={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Gw,...Kw]}},P={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},R={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function L(D){return t.concat("(?!",D.join("|"),")")}const A={match:t.concat(/\b/,L([...Yw,"super","import","await"].map(D=>`${D}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},T={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},H={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},O]},F="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",V={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(F)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:U},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),P,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,k,b,j,S,{match:/\$\d+/},p,U,{scope:"attr",match:i+t.lookahead(":"),relevance:0},V,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[S,e.REGEXP_MODE,{className:"function",begin:F,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:M}]}]},{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"]}]}]},R,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},T,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},A,z,B,H,{match:/\$[(.]/}]}}function ML(e){const t=e.regex,s=TL(e),i=Pd,r=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:r},contains:[s.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},d=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],h={$pattern:Pd,keyword:Vw.concat(d),literal:qw,built_in:Qw.concat(r),"variable.language":Xw},m={className:"meta",begin:"@"+i},p=(b,j,w)=>{const S=b.contains.findIndex(_=>_.label===j);if(S===-1)throw new Error("can not find mode to replace");b.contains.splice(S,1,w)};Object.assign(s.keywords,h),s.exports.PARAMS_CONTAINS.push(m);const g=s.contains.find(b=>b.scope==="attr"),x=Object.assign({},g,{match:t.concat(i,t.lookahead(/\s*\?:/))});s.exports.PARAMS_CONTAINS.push([s.exports.CLASS_REFERENCE,g,x]),s.contains=s.contains.concat([m,o,l,x]),p(s,"shebang",e.SHEBANG()),p(s,"use_strict",u);const k=s.contains.find(b=>b.label==="func.def");return k.relevance=0,Object.assign(s,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),s}function RL(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 OL(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},k={begin:/\{/,end:/\}/,contains:[x],illegal:"\\n",relevance:0},b={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},k,b,o,l],w=[...j];return w.pop(),w.push(u),x.contains=w,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:j}}for(const[e,t]of Object.entries({bash:oL,css:gL,diff:xL,go:vL,java:yL,javascript:wL,json:EL,markdown:CL,python:AL,rust:$L,sql:IL,typescript:ML,xml:RL,yaml:OL}))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 Ub=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:Ub(e);return`<div class="code-block"><div class="code-head"><span class="code-lang">${Ub(s===""?"text":s)}</span><button type="button" class="code-copy" data-copy="">复制</button></div><pre><code class="hljs">${r}</code></pre></div>`}}});function Jw(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 Bb=/\.(png|jpe?g|gif|webp|bmp)$/i,PL=/^(#|\?|\/\/|[a-z][a-z0-9+.-]*:)/i;function Hb(e){const t=e.trim(),s=Jw(t);if(s!==void 0)return s;if(!(t===""||PL.test(t)))return t}Qg.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=Hb(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=Jw(t);if(s!==void 0){e.removeAttribute("href"),e.setAttribute("data-local-path",s),e.setAttribute("title",s),e.classList.add("local-path"),Bb.test(s)&&e.setAttribute("data-image-preview",s);return}const i=Hb(t);i!==void 0&&Bb.test(i)&&(e.removeAttribute("href"),e.setAttribute("data-image-preview",i),e.setAttribute("title",i),e.classList.add("local-path"))});Qg.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 LL(e){var o;const t=e.dataset.localPath;if(t===void 0)return;const s=l=>{e.dataset.note=l,setTimeout(()=>{delete e.dataset.note},2200)},i=Vs();if((i==null?void 0:i.openPath)!==void 0){i.openPath(t).then(l=>s(l==="missing"?"找不到这个文件":l==="revealed"?"已在文件夹中显示":"已打开"),()=>s("打不开"));return}(((o=navigator.clipboard)==null?void 0:o.writeText(t))??Promise.reject(new Error("no clipboard"))).then(()=>s("浏览器里打不开本地文件,路径已复制"),()=>s(tS(t)?"浏览器里打不开本地文件,路径已复制":t))}function zL(e){var o;const t=e.target.closest("a[data-local-path]");if(t!==null){e.preventDefault(),LL(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)};eS(i.innerText).then(r)}function eS(e){var s;return(((s=navigator.clipboard)==null?void 0:s.writeText(e))??Promise.reject(new Error("no clipboard"))).then(()=>!0,()=>tS(e))}function tS(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 $f=new Map;function DL(e,t){let s=$f.get(t);return s===void 0&&(s=e.connection.call("attachments/file",{path:t}).then(i=>`data:${i.mediaType};base64,${i.data}`),s.catch(()=>$f.delete(t)),$f.set(t,s)),s}function FL(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"),DL(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(()=>Qg.sanitize(Tt.parse(t,{async:!1})),[t]),r=v.useContext(uh),o=v.useRef(null),[l,u]=v.useState(null);v.useEffect(()=>o.current===null?void 0:FL(o.current,r),[i,r]);const d=h=>{const m=h.target,p=m.closest("a[data-image-preview]:not([data-local-path])"),g=m instanceof HTMLImageElement&&m.classList.contains("md-image")&&m.src!==""?m:(p==null?void 0:p.nextElementSibling)instanceof HTMLImageElement&&p.nextElementSibling.src!==""?p.nextElementSibling:null;if(g!==null){h.preventDefault();const x=g.dataset.localImage??"";u({src:g.src,width:g.naturalWidth,height:g.naturalHeight,name:x.split(/[\\/]/).pop()||"image.png"});return}zL(h)};return n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:o,className:`markdown ${s??""}`,onClick:d,dangerouslySetInnerHTML:{__html:i}}),l!==null&&n.jsx(ch,{src:l.src,width:l.width,height:l.height,name:l.name,onClose:()=>u(null)})]})}),Wb="adg.update.later",UL=360*6e4,nS="https://github.com/haaahhhis/MultiGameAssistant/releases",If="dsh-multigameassistant";function lx(){var i;const e=(i=Vs())==null?void 0:i.updates,[t,s]=v.useState(e===void 0?null:void 0);return v.useEffect(()=>{if(e===void 0)return;let r=!0;e.state().then(l=>{r&&s(l)},()=>{r&&s(null)});const o=e.onChange(l=>{r&&s(l)});return()=>{r=!1,o()}},[e]),{bridge:e,state:t}}const Vb=new WeakMap;function BL(e){let t=Vb.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,UL)),()=>{--o===0&&l!==void 0&&(clearInterval(l),l=void 0)}}},Vb.set(e,t),t}function sS(e){const t=Se(e.capabilities),s=Se(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 iS(e,t){const s=BL(e),i=v.useSyncExternalStore(s.subscribe,s.get);return v.useEffect(()=>t?s.watch():void 0,[s,t]),{...i,check:s.check}}function rS(e){var l;const{bridge:t,state:s}=lx(),i=sS(e),r=iS(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||nS,notes:o.notes??[],...o.onNpm===void 0?{}:{onNpm:o.onNpm}}}function HL(e,t=3){var r,o,l;const s=((r=e[0])==null?void 0:r.body)??"",i=[];for(const u of s.split(`
192
+ `)){const d=(o=/^\s*[-*]\s+(.+)$/.exec(u))==null?void 0:o[1];if(d===void 0)continue;const m=(((l=/^\*\*(.+?)\*\*/.exec(d))==null?void 0:l[1])??d).replace(/\*\*|`|\[([^\]]*)\]\([^)]*\)/g,(p,g)=>g??"").replace(/[::。]\s*$/,"").trim();if(m!==""&&!i.includes(m)&&i.push(m.length>40?`${m.slice(0,40)}…`:m),i.length>=t)break}return i}function ZL(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 cx({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:ZL(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 aS=!1;const qp=new Set,Gp=e=>{aS=e;for(const t of qp)t()},WL=e=>(qp.add(e),()=>{qp.delete(e)});function oS(){Gp(!0)}function VL({client:e}){const t=v.useSyncExternalStore(WL,()=>aS),s=rS(e);if(v.useEffect(()=>{if(!t)return;const r=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),Gp(!1))};return document.addEventListener("keydown",r,!0),()=>document.removeEventListener("keydown",r,!0)},[t]),!t||s===null)return null;const i=()=>Gp(!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(cx,{notes:s.notes,notesUrl:s.notesUrl})}),s.kind==="desktop"?n.jsx(ux,{bridge:s.bridge,state:s.state,extra:n.jsx("button",{className:"ghost small-button",onClick:()=>{s.bridge.skip(s.version),i()},children:"跳过这个版本"})}):n.jsx(lS,{version:s.version,onNpm:s.onNpm})]})})}function Tf(e){return e>=1024*1024?`${Math.round(e/1024/1024)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function ux({bridge:e,state:t,extra:s}){var m;const[i,r]=v.useState(null),[o,l]=v.useState(!1),u=t.latest;if(u===void 0)return null;const d=((m=t.download)==null?void 0:m.version)===u.version?t.download:void 0,h=p=>{r(null),p().catch(g=>r(g instanceof Error?g.message.replace(/^Error invoking remote method '[^']+': (Error: )?/,""):String(g)))};return n.jsxs("div",{className:"update-actions",children:[(d==null?void 0:d.state)==="downloading"&&n.jsxs("div",{className:"update-progress",children:[n.jsx("div",{className:"progress",role:"progressbar","aria-label":"下载进度","aria-valuemin":0,"aria-valuemax":d.total,"aria-valuenow":d.received,children:n.jsx("span",{style:{width:`${d.total>0?Math.min(100,d.received/d.total*100):0}%`}})}),n.jsxs("small",{className:"muted",children:["正在下载 ",Tf(d.received)," / ",Tf(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"?"正在下载…":`下载更新(${Tf(u.size)})`})]})]})}function lS({version:e,onNpm:t}){const s=`${nS}/download/v${e}/${If}.tgz`;return n.jsxs("div",{className:"plugin-update",children:[t!==!1&&n.jsxs("p",{children:["在 dsh 的「Plugins」→「Add plugin」里再填一次 ",n.jsx(Mf,{text:If})," 安装(命令行的 dsh:",n.jsx(Mf,{text:`dsh plugin add ${If}`}),")。",t===void 0&&"没连上 npm,不知道那边有没有这个版本;装完版本没变的话,用下面的链接。"]}),t!==!0&&n.jsxs("p",{children:[t===!1&&"npm 上还没有这个版本(要等发布者批准)。","在「Add plugin」里填这个链接安装:",n.jsx(Mf,{text:s})]}),n.jsx("p",{className:"muted small",children:"装好后刷新这个页面。你的数据、脚本和定时任务都在 dsh 的数据目录里,重新安装不会丢。"})]})}function Mf({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 qL(){var d;const{bridge:e,state:t}=lx(),[s,i]=v.useState(()=>{try{return sessionStorage.getItem(Wb)}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(Wb,r.version)}catch{}i(r.version)},u=HL(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(ux,{bridge:e,state:t,extra:n.jsxs(n.Fragment,{children:[n.jsx("button",{className:"ghost small-button",onClick:oS,children:"更新介绍"}),!o&&n.jsx("button",{className:"ghost small-button",onClick:()=>void e.skip(r.version),children:"跳过这个版本"})]})})]})}function GL({client:e,isHere:t,onSelect:s}){var m;const i=Se(e.approvals),r=Se(e.questions),o=(m=$O(e))==null?void 0:m.pending,l=i.filter(p=>t(p.sessionId)),u=r.filter(p=>t(p.sessionId)),d=[...i,...r].filter(p=>!t(p.sessionId)),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(IO,{client:e,pending:o}),u.map(p=>n.jsx(YL,{client:e,request:p},p.questionId)),l.map(p=>n.jsx(KL,{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(MO,{client:e}),n.jsx(CO,{client:e}),n.jsx(qL,{})]})}function KL({client:e,request:t}){var d,h,m;const[s,i]=v.useState(!1),[r,o]=v.useState(null),l=((d=t.displayReason)==null?void 0:d.zh)??((h=t.displayReason)==null?void 0:h["zh-CN"])??((m=t.displayReason)==null?void 0:m.en)??t.reason,u=async p=>{i(!0);try{await e.respondApproval(t.approvalId,p)}catch(g){o(g instanceof Error?g.message:String(g)),i(!1)}};return n.jsxs("div",{className:"approval-card",role:"alertdialog","aria-label":"需要审批",children:[n.jsxs("div",{className:"approval-head",children:[n.jsx(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 YL({client:e,request:t}){var b;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&&(((b=t.questions[0].options)==null?void 0:b.length)??0)>0,h=j=>s[j]??{selected:[],custom:""},m=async j=>{o(!0),u(null);try{await e.answerQuestion(t.questionId,j)}catch(w){u(w instanceof Error?w.message:String(w)),o(!1)}},p=(j,w)=>{if(d)return void m([{id:j.id,selected:[w]}]);i(S=>{const _=S[j.id]??{selected:[],custom:""},E=j.multiSelect===!0?_.selected.includes(w)?_.selected.filter(M=>M!==w):[..._.selected,w]:_.selected.includes(w)?[]:[w];return{...S,[j.id]:{..._,selected:E}}})},g=(j,w)=>i(S=>({...S,[j.id]:{...S[j.id]??{selected:[]},custom:w}})),x=()=>t.questions.map(j=>{const{selected:w,custom:S}=h(j.id),_=S.trim();return{id:j.id,selected:_!==""&&j.multiSelect!==!0?[]:w,..._===""?{}:{custom:_}}}),k=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 w,S;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}),(((w=j.options)==null?void 0:w.length)??0)>0&&n.jsx("div",{className:"question-options",role:j.multiSelect===!0?"group":"radiogroup",children:j.options.map(_=>{const E=h(j.id).selected.includes(_.label);return n.jsxs("button",{className:`question-option${E?" on":""}`,disabled:r,role:j.multiSelect===!0?"checkbox":"radio","aria-checked":E,onClick:()=>p(j,_.label),children:[n.jsx("span",{className:"question-option-label",children:_.label}),_.description!==void 0&&n.jsx("span",{className:"question-option-desc",children:_.description})]},_.label)})}),n.jsx("input",{className:"text-input question-custom",value:h(j.id).custom,disabled:r,placeholder:(((S=j.options)==null?void 0:S.length)??0)>0?"或者直接写你的回答":"写下你的回答",onChange:_=>g(j,_.target.value),onKeyDown:_=>{_.key==="Enter"&&!_.nativeEvent.isComposing&&k&&m(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 m(t.questions.map(j=>({id:j.id,selected:[]}))),children:"跳过"}),n.jsx("button",{className:"inverse",disabled:r||!k,onClick:()=>void m(x()),children:"回答"})]})]})}const wn="main";function Kp(e,t){const s=new Set;let i=e;for(;i.parentId&&!s.has(i.id);){s.add(i.id);const r=t.get(i.parentId);if(!r)break;i=r}return i}const XL={intervene:"alert",games:"gamepad",scripts:"package",pipelines:"flow"},cn={id:wn,name:"助手",description:"和你对话、替你安排;飞书里的消息也到这里",icon:"chat"};function Ka(e){return{id:e.id,name:e.name,description:e.description,icon:XL[e.id]??"sparkles"}}function $i(e){const t=Se(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 cS(e,t){return e.role!==void 0&&t.some(s=>s.id===e.role)?e.role:wn}function dx(e,t){const s=Se(e.connection.status),[i,r]=v.useState(new Map),o=v.useRef(new Map),l=d=>`${d.updatedAt}${d.running?"+":""}`,u=t.map(d=>`${d.id}@${l(d)}`).join(",");return v.useEffect(()=>{if(s.state!=="open")return;const d=t.filter(h=>o.current.get(h.id)!==l(h)).slice(0,60);if(d.length!==0){for(const h of d)o.current.set(h.id,l(h));e.connection.call("sessions/lastReplies",{sessionIds:d.map(h=>h.id)}).then(h=>{r(m=>{const p=new Map(m);for(const g of h.items)p.set(g.sessionId,g.text);return p})}).catch(()=>{for(const h of d)o.current.delete(h.id)})}},[e,s.state,u]),i}const uS="adg.agentSeen";function QL(){try{const e=JSON.parse(localStorage.getItem(uS)??"{}");return e!==null&&typeof e=="object"?e:{}}catch{return{}}}function JL(){const[e,t]=v.useState(QL);return{seen:e,markSeen:(i,r)=>{t(o=>{if((o[i]??0)>=r)return o;const l={...o,[i]:r};try{localStorage.setItem(uS,JSON.stringify(l))}catch{}return l})}}}function dS(e,t){const s=Se(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 ez(e,t){const s=Se(e.connection.status),i=Se(e.capabilities),[r,o]=v.useState([]);return v.useEffect(()=>{if(s.state!=="open"||!i.has("agents"))return;let l=!0;return e.connection.call("handoffs/list",{sessionId:t}).then(u=>{l&&o(u.items)}).catch(()=>{}),()=>{l=!1}},[e,t,s.state,i]),v.useEffect(()=>e.connection.on("handoffs/changed",({item:l})=>{l.fromSession!==t&&l.toSession!==t||o(u=>[...u.filter(d=>d.id!==l.id),l])}),[e,t]),r}function tz(e,t){const s=Se(e.sessions),i=v.useMemo(()=>new Map(s.items.map(g=>[g.id,g])),[s.items]),r=Se(e.approvals),o=Se(e.questions),l=$i(e),{seen:u,markSeen:d}=JL(),h=v.useMemo(()=>[cn,...l.map(Ka)],[l]),m=v.useMemo(()=>{var x;const g=new Map(h.map(k=>[k.id,[]]));for(const k of s.items){if(k.blank||!k.home&&k.origin!=="subagent")continue;const b=k.home??Kp(k,i).home;b&&((x=g.get(b))==null||x.push(k))}for(const k of g.values())k.sort((b,j)=>j.updatedAt-b.updatedAt);return g},[s.items,i,h]);v.useEffect(()=>{var g,x;if(s.loaded)for(const k of h){const b=(x=(g=m.get(k.id))==null?void 0:g[0])==null?void 0:x.updatedAt;b!==void 0&&(k.id===t||u[k.id]===void 0)&&d(k.id,b)}},[s.loaded,m,t]);const p=g=>{const x=i.get(g);return x&&Kp(x,i).home};return h.map(g=>{const x=m.get(g.id)??[],k=x[0];return{agent:g,running:x.filter(b=>b.running).length,unread:g.id!==t&&k!==void 0&&k.updatedAt>(u[g.id]??1/0),waiting:[...r,...o].filter(b=>p(b.sessionId)===g.id).length,last:x.find(b=>b.home===g.id)??k}})}function vt(e,t){const s=Math.max(0,Math.round((t-e)/1e3));return s<60?"刚刚":s<3600?`${Math.floor(s/60)} 分钟前`:s<86400?`${Math.floor(s/3600)} 小时前`:s<86400*7?`${Math.floor(s/86400)} 天前`:new Date(e).toLocaleDateString(void 0,{month:"numeric",day:"numeric"})}function nz({client:e,pages:t,current:s,onAgent:i,onPage:r,onSchedule:o,onSettings:l,width:u,onWidth:d,slot:h}){const m=Se(e.connection.status),p=Se(e.capabilities),g=tz(e,s.kind==="agent"?s.id:void 0),x=rS(e),k=u>=To,b=g.find(R=>R.agent.id===wn),j=g.filter(R=>R.agent.id!==wn),w=t.filter(R=>R.order<0),S=s.kind==="page"?w.find(R=>R.id===s.id):void 0,[_,...E]=w,M=s.kind==="agent"&&s.id===wn,O=dx(e,k?g.flatMap(R=>R.last===void 0?[]:[{id:R.last.id,updatedAt:R.last.updatedAt,running:R.last.running}]):[]),B=R=>R.last===void 0?void 0:O.get(R.last.id)??void 0,U=R=>n.jsx(Ql,{icon:R.icon,label:R.title,active:s.kind==="page"&&s.id===R.id,onClick:()=>r(R.id)},R.id),P=R=>n.jsx(az,{state:R,wide:k,reply:B(R),active:s.kind==="agent"&&s.id===R.agent.id,onClick:()=>i(R.agent.id)},R.agent.id);return n.jsxs("nav",{className:`rail${k?" wide":""}`,"aria-label":"功能区",children:[n.jsx("div",{className:"rail-top",children:b!==void 0&&(_===void 0?P(b):n.jsx(oz,{state:b,page:_,wide:k,reply:B(b),showingPage:(S==null?void 0:S.id)===_.id,active:M||(S==null?void 0:S.id)===_.id,onClick:()=>M?r(_.id):i(wn)}))}),n.jsx("span",{className:"rail-divider",role:"separator"}),S!==void 0?n.jsx("div",{className:"rail-items rail-slot",ref:h,"aria-label":S.title}):n.jsxs("div",{className:"rail-items",children:[j.map(P),t.filter(R=>R.order>=0).map(U)]}),n.jsxs("div",{className:"rail-footer",children:[x!==null&&n.jsx(Ql,{icon:"download",label:"更新",title:`MultiGameAssistant ${x.version} 可以更新了:点开看更新了什么`,active:!1,onClick:oS,dot:!0}),(b===void 0?w:E).map(U),p.has("pipelines")&&n.jsx(Ql,{icon:"clock",label:"定时",title:"所有 agent 的定时任务、提醒和按时运行的流水线:在这里新建和修改",active:s.kind==="schedule",onClick:o}),n.jsx(Ql,{icon:"settings",label:"设置",active:s.kind==="settings",onClick:l}),m.state!=="open"&&n.jsxs("span",{className:`rail-connection ${m.state}`,role:"status",title:Kb(m.state,m.attempt,m.error),children:[n.jsx("span",{className:"conn-dot"}),n.jsx("span",{className:"sr-only",children:Kb(m.state,m.attempt,m.error)})]})]}),n.jsx(rz,{width:u,onWidth:d}),n.jsx(VL,{client:e})]})}const To=150,Ma=68,sz=360,qb="adg.railWidth";function iz(){const[e,t]=v.useState(()=>{try{return Gb(Number(localStorage.getItem(qb)??Ma))}catch{return Ma}});return v.useEffect(()=>{const s=setTimeout(()=>{try{localStorage.setItem(qb,String(e))}catch{}},200);return()=>clearTimeout(s)},[e]),[e,s=>t(Gb(s))]}function Gb(e){if(!Number.isFinite(e))return Ma;const t=Math.min(sz,Math.max(Ma,Math.round(e)));return t<To?t<(Ma+To)/2?Ma:To:t}function rz({width:e,onWidth:t}){const s=v.useRef(null),i=l=>{l.preventDefault(),s.current={x:l.clientX,width:e},l.currentTarget.setPointerCapture(l.pointerId)},r=l=>{s.current!==null&&t(s.current.width+l.clientX-s.current.x)},o=()=>{s.current=null};return n.jsx("div",{className:"rail-resizer",role:"separator","aria-orientation":"vertical","aria-label":"调整侧边栏宽度",title:"拖动调整宽度;双击展开或收起",onPointerDown:i,onPointerMove:r,onPointerUp:o,onPointerCancel:o,onDoubleClick:()=>t(e>=To?Ma:220)})}function az({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 oz({state:e,page:t,wide:s,reply:i,showingPage:r,active:o,onClick:l}){const{agent:u,running:d,unread:h,waiting:m}=e,p=r?{name:t.title,icon:t.icon,className:`page-${t.id}`}:{name:u.name,icon:u.icon,className:`agent-${u.id}`},g=r?{name:u.name,icon:u.icon,className:`agent-${u.id}`}:{name:t.title,icon:t.icon,className:`page-${t.id}`},x=r?"各个游戏的活动和日程":d>0?"正在处理…":(i==null?void 0:i.replace(/\s+/g," ").trim())||u.description,k=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:k,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}),m>0?n.jsx("span",{className:"rail-badge","aria-label":`助手有 ${m} 个等你处理`,children:m}):h&&n.jsx("span",{className:"rail-unread",role:"img","aria-label":"助手有新结果"})]})}function Ql({icon:e,label:t,title:s=t,active:i,onClick:r,disabled:o=!1,dot:l=!1}){return n.jsxs("button",{className:`rail-item ${i?"active":""} ${l?"rail-new":""}`,"aria-current":i?"page":void 0,onClick:r,title:s,disabled:o,children:[n.jsx(ee,{name:e}),n.jsx("span",{className:"rail-label",children:t}),l&&n.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新版本"})]})}function Kb(e,t,s){const i=e==="open"?"已连接 agent":e==="connecting"?"正在连接…":e==="reconnecting"?`重连中(第 ${t} 次)`:"未连接";return s===void 0?i:`${i}:${s}`}const hS=v.createContext(null),lz=v.createContext(!1);function cz({bridge:e,onClose:t}){const[s,i]=v.useState(null),[r,o]=v.useState(null),l=v.useRef(null),u=v.useRef(null),[d,h]=v.useState(""),[m,p]=v.useState(!1),[g,x]=v.useState(null),k=v.useRef(null),b=v.useRef(null),j=v.useRef(!1),w=v.useRef(0),S=s==null?void 0:s.tabs.find(D=>D.id===s.shown);v.useEffect(()=>{m||h((S==null?void 0:S.url)==="about:blank"?"":(S==null?void 0:S.url)??"")},[S==null?void 0:S.url,m]),v.useEffect(()=>{let D=!0;e.state().then(G=>{D&&G!==null&&i(G)});const q=e.onChange(i),te=e.onFrame(G=>{createImageBitmap(new Blob([G.data],{type:"image/jpeg"})).then(K=>{var Z;if(!D)return K.close();(Z=u.current)==null||Z.close(),u.current=K,_(),o(Y=>(Y==null?void 0:Y.width)===G.width&&Y.height===G.height?Y:{width:G.width,height:G.height})},()=>{})});return()=>{var G;D=!1,q(),te(),(G=u.current)==null||G.close(),u.current=null}},[e]),v.useEffect(()=>{const D=k.current;if(D===null)return;const q=()=>{const{width:G,height:K}=D.getBoundingClientRect();e.show(G>50&&K>50?{width:Math.floor(G),height:Math.floor(K)}:null)},te=new ResizeObserver(q);return te.observe(D),q(),()=>{te.disconnect(),e.show(null)}},[e]);function _(){var te;const D=l.current,q=u.current;D===null||q===null||((D.width!==q.width||D.height!==q.height)&&(D.width=q.width,D.height=q.height),(te=D.getContext("2d"))==null||te.drawImage(q,0,0))}v.useEffect(_,[r]);const E=D=>{x(null),D.catch(q=>x(q instanceof Error?q.message:String(q)))},M=D=>{const q=D.currentTarget.getBoundingClientRect(),te=r===null?1:r.width/q.width,G=r===null?1:r.height/q.height;return{x:Math.round((D.clientX-q.left)*te),y:Math.round((D.clientY-q.top)*G)}},O=D=>[D.shiftKey&&"shift",D.ctrlKey&&"control",D.altKey&&"alt",D.metaKey&&"meta"].filter(q=>q!==!1),B=D=>D===1?"middle":D===2?"right":"left",U=D=>e.input(D),P=D=>{var q;D.preventDefault(),(q=b.current)==null||q.focus(),U({type:"mouseDown",...M(D),button:B(D.button),clickCount:D.detail,modifiers:O(D)})},R=D=>U({type:"mouseUp",...M(D),button:B(D.button),clickCount:D.detail,modifiers:O(D)}),z=D=>{const q=Date.now();D.buttons===0&&q-w.current<50||(w.current=q,U({type:"mouseMove",...M(D),modifiers:O(D)}))},L=D=>U({type:"mouseWheel",...M(D),deltaX:-D.deltaX,deltaY:-D.deltaY,canScroll:!0,modifiers:O(D)}),A=D=>{if(j.current||D.nativeEvent.isComposing)return;const q={Enter:"Enter",Backspace:"Backspace",Tab:"Tab",Escape:"Escape",Delete:"Delete",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right"},te=(D.ctrlKey||D.metaKey||D.altKey)&&D.key.length===1,G=q[D.key]??(te?D.key.toUpperCase():void 0);if(G===void 0)return;D.preventDefault();const K=O(D);U({type:"keyDown",keyCode:G,modifiers:K}),G==="Enter"&&U({type:"char",keyCode:"\r",modifiers:K}),U({type:"keyUp",keyCode:G,modifiers:K})},T=()=>{const D=b.current;if(D===null||D.value==="")return;const q=D.value;D.value="",e.text(q)},H=()=>{const D=d.trim();D!==""&&(p(!1),E(e.navigate({url:D,...S===void 0?{newTab:!0}:{}})))},F=s!==null&&Date.now()-s.agentAt<5e3,[,V]=v.useState(0);return v.useEffect(()=>{if(!F||s===null)return;const D=setTimeout(()=>V(q=>q+1),s.agentAt+5e3-Date.now()+50);return()=>clearTimeout(D)},[F,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:(S==null?void 0:S.canGoBack)!==!0,onClick:()=>E(e.navigate({action:"back"})),children:n.jsx(ee,{name:"back"})}),n.jsx("button",{type:"button",className:"icon-button",title:"前进","aria-label":"前进",disabled:(S==null?void 0:S.canGoForward)!==!0,onClick:()=>E(e.navigate({action:"forward"})),children:n.jsx(ee,{name:"chevron"})}),n.jsx("button",{type:"button",className:"icon-button",title:"刷新","aria-label":"刷新",disabled:S===void 0,onClick:()=>E(e.navigate({action:"reload"})),children:n.jsx(ee,{name:"refresh"})}),n.jsx("input",{className:"text-input browser-address",value:d,placeholder:"输入网址,回车打开","aria-label":"网址",onFocus:D=>{p(!0),D.target.select()},onBlur:()=>p(!1),onChange:D=>h(D.target.value),onKeyDown:D=>{D.key==="Enter"&&!D.nativeEvent.isComposing&&H(),D.key==="Escape"&&D.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(D=>n.jsxs("span",{className:`browser-tab${D.id===s.shown?" active":""}`,children:[n.jsxs("button",{type:"button",role:"tab","aria-selected":D.id===s.shown,title:D.url,onClick:()=>E(e.select(D.id)),children:[D.loading&&n.jsx("span",{className:"pill-dot"}),D.title===""?D.url:D.title]}),n.jsx("button",{type:"button",className:"browser-tab-close",title:"关闭标签页","aria-label":`关闭 ${D.title}`,onClick:()=>E(e.close(D.id)),children:n.jsx(ee,{name:"close"})})]},D.id)),n.jsx("button",{type:"button",className:"browser-tab-new",title:"新标签页","aria-label":"新标签页",onClick:()=>{h(""),E(e.navigate({url:"about:blank",newTab:!0}))},children:n.jsx(ee,{name:"plus"})})]}),F&&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:k,children:[S===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":S.title,onMouseDown:P,onMouseUp:R,onMouseMove:z,onWheel:L,onContextMenu:D=>D.preventDefault()}),n.jsx("textarea",{ref:b,className:"browser-typing","aria-label":"在页面里输入",tabIndex:-1,onKeyDown:A,onCompositionStart:()=>{j.current=!0},onCompositionEnd:()=>{j.current=!1,T()},onInput:()=>{j.current||T()}})]})]})}const Ld="adg.draft.",Yb=60,Yp=new Map;function mS(e){try{const t=localStorage.getItem(Ld+e);if(t===null)return"";const s=JSON.parse(t);return typeof s.text=="string"?s.text:""}catch{return""}}function uz(e,t){try{if(t.trim()===""){localStorage.removeItem(Ld+e);return}localStorage.setItem(Ld+e,JSON.stringify({text:t,at:Date.now()})),mz()}catch{}}function dz(e){return Yp.get(e)??[]}function hz(e,t){t.length===0?Yp.delete(e):Yp.set(e,[...t])}function mz(){const e=[];for(let t=0;t<localStorage.length;t++){const s=localStorage.key(t);if(!(s===null||!s.startsWith(Ld)))try{e.push({key:s,at:Number(JSON.parse(localStorage.getItem(s)??"{}").at)||0})}catch{e.push({key:s,at:0})}}if(!(e.length<=Yb))for(const t of e.sort((s,i)=>s.at-i.at).slice(0,e.length-Yb))localStorage.removeItem(t.key)}function fz({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 eS(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"})})}function Rf(e,t){if(!t)return e;const s=t.text.replace(/\r\n?/g,`
193
+ `).split(`
194
+ `).map(i=>"> "+i);return`引用${t.author}消息(${t.id})
195
+ ${s.join(`
196
+ `)}
197
+
198
+ ${e}`}function cc(e){const t=/^引用(用户|助手)消息(([au]:\d+))\n/.exec(e),s=t?e.indexOf(`
199
+
200
+ `,t[0].length):-1;if(t&&s>=0){const i=e.slice(t[0].length,s).split(`
201
+ `);if(i.every(r=>r.startsWith("> "))){const r=t[1]==="用户"?"用户":"助手";return{body:e.slice(s+2),quote:{author:r,id:t[2],text:i.map(o=>o.slice(2)).join(`
202
+ `)}}}}return{body:e,quote:null}}const Nc=v.createContext(null);function pz({sessionId:e,children:t}){const[s,i]=v.useState(()=>cc(mS(e)).quote);return n.jsx(Nc.Provider,{value:{quote:s,select:i},children:t})}function fS({quote:e,onRemove:t}){return n.jsxs("div",{className:"message-quote",children:[n.jsxs("blockquote",{children:[n.jsxs("strong",{children:["回复",e.author]}),n.jsx("span",{title:e.text,children:e.text})]}),t&&n.jsx("button",{type:"button",className:"msg-action","aria-label":"取消引用",title:"取消引用",onClick:t,children:n.jsx(ee,{name:"close"})})]})}function Of({text:e,author:t,id:s,canReply:i=!0}){const r=v.useContext(Nc);return n.jsxs("div",{className:"msg-actions",children:[n.jsx(fz,{text:e}),r&&i&&n.jsx("button",{type:"button",className:"msg-action","aria-label":"引用回复",title:"引用回复,可先选中一句话",onMouseDown:o=>o.preventDefault(),onClick:o=>{var h;const l=(h=o.currentTarget.closest(".message-line"))==null?void 0:h.querySelector("[data-reply-text]"),u=window.getSelection(),d=u&&(l!=null&&l.contains(u.anchorNode))&&l.contains(u.focusNode)?u.toString().trim():"";r.select({id:s,author:t,text:d||e})},children:n.jsx(ee,{name:"reply"})})]})}const gz={off:"不思考",none:"不思考",minimal:"最少",low:"低",medium:"中",high:"高",xhigh:"很高",max:"最大"},Xb=(e,t)=>gz[e]??(t!==void 0&&t!==e?t:e);function pS(e,t){return(t==null?void 0:t.next)??(t==null?void 0:t.lastUsed)??(e==null?void 0:e.default)??null}function xz(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 vz({client:e,sessionId:t,disabled:s,value:i,onChange:r}){var L;const{catalog:o,error:l}=aa(e),u=Se(e.sessionModels),d=Se(e.connection.status),[h,m]=v.useState(!1),[p,g]=v.useState(null),[x,k]=v.useState(!1),[b,j]=v.useState(""),w=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=H=>{w.current!==null&&!w.current.contains(H.target)&&k(!1)},T=H=>{H.key==="Escape"&&k(!1)};return document.addEventListener("mousedown",A),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",T)}},[x]);const S=t===void 0?void 0:u.get(t),_=t===void 0?i??(o==null?void 0:o.default)??null:pS(o,S),E=xz(o,_),M=_!==null&&o!==null&&E===void 0,O=async A=>{if(g(null),t===void 0){r==null||r(A);return}m(!0);try{await e.selectModel(t,A)}catch(T){g(T instanceof Error?T.message:String(T))}finally{m(!1)}},B=(A,T)=>{const H=(_==null?void 0:_.reasoningEffort)!==void 0&&T.efforts.some(F=>F.id===_.reasoningEffort)?_.reasoningEffort:T.defaultEffort;O({provider:A,model:T.id,...H===void 0?{}:{reasoningEffort:H}}),T.efforts.length===0&&k(!1)},U=v.useMemo(()=>{const A=b.trim().toLowerCase();return((o==null?void 0:o.groups)??[]).map(T=>({...T,models:T.models.filter(H=>A===""||H.id.toLowerCase().includes(A)||H.name.toLowerCase().includes(A)||T.name.toLowerCase().includes(A))})).filter(T=>T.models.length>0)},[o,b]),P=[p,l,...(o==null?void 0:o.failures.map(A=>`${A.name}:${A.message}`))??[]].filter(Boolean);if(o===null)return null;const R=(_==null?void 0:_.reasoningEffort)??(E==null?void 0:E.defaultEffort),z=(L=E==null?void 0:E.efforts.find(A=>A.id===R))==null?void 0:L.name;return n.jsxs("div",{className:`model-picker${p!==null?" has-error":""}`,ref:w,children:[n.jsxs("button",{type:"button",className:"model-trigger","aria-haspopup":"dialog","aria-expanded":x,disabled:s||h,title:P.length>0?P.join(`
203
+ `):"选择模型和思考强度",onClick:()=>k(A=>!A),children:[n.jsx("span",{className:`model-dot ${M?"off":""}`}),n.jsx("span",{className:"model-name",children:(E==null?void 0:E.name)??(_===null?"选择模型":`${_.model}(不可用)`)}),R!==void 0&&E!==void 0&&E.efforts.length>0&&n.jsx("span",{className:"model-effort",children:Xb(R,z)}),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:b,onChange:A=>j(A.target.value)}),n.jsxs("div",{className:"model-list",role:"listbox","aria-label":"模型",children:[U.length===0&&n.jsx("div",{className:"muted small pad",children:"没有匹配的模型"}),U.map(A=>n.jsxs("div",{className:"model-group",children:[n.jsx("div",{className:"model-group-name",children:A.name}),A.models.map(T=>{const H=(_==null?void 0:_.provider)===A.id&&_.model===T.id;return n.jsxs("button",{type:"button",role:"option","aria-selected":H,className:`model-option ${H?"active":""}`,onClick:()=>B(A.id,T),children:[n.jsxs("span",{className:"model-option-main",children:[n.jsx("span",{children:T.name}),T.name!==T.id&&n.jsx("span",{className:"muted small",children:T.id})]}),T.efforts.length>0&&n.jsx("span",{className:"model-tag",children:"思考"}),H&&n.jsx(ee,{name:"check"})]},T.id)})]},A.id))]}),E!==void 0&&_!==null&&n.jsxs("div",{className:"model-efforts",children:[n.jsx("span",{className:"field-label",children:"思考强度"}),E.efforts.length===0?n.jsx("span",{className:"muted small",children:"这个模型没有可选的思考强度(在「设置 → 模型」里给模型打开「思考」)"}):n.jsx("div",{className:"segmented-control",role:"radiogroup","aria-label":"思考强度",children:E.efforts.map(A=>n.jsx("button",{type:"button",role:"radio","aria-checked":R===A.id,className:R===A.id?"active":"",onClick:()=>void O({provider:_.provider,model:_.model,reasoningEffort:A.id}),children:Xb(A.id,A.name)},A.id))})]}),P.length>0&&n.jsx("div",{className:"error small model-problems",children:P.join(";")})]})]})}let Jl=[],yz=1;const Xp=new Set,Qb=()=>{for(const e of Xp)e()},bz=e=>(Xp.add(e),()=>{Xp.delete(e)}),kz=()=>Jl[0];function jz(e,t){return new Promise(s=>{const i=yz++;Jl=[...Jl,{...e,id:i,single:t,settle:r=>{Jl=Jl.filter(o=>o.id!==i),Qb(),s(r)}}],Qb()})}function Ms(e){return jz(e,!1)}function Nz(){const e=v.useSyncExternalStore(bz,kz);return e===void 0?null:n.jsx(wz,{pending:e},e.id)}function wz({pending:e}){const{title:t,message:s,quote:i,confirmLabel:r="确定",cancelLabel:o="取消",danger:l=!1,icon:u,single:d,settle:h}=e,m=v.useRef(null),p=v.useRef(null),g=v.useRef(null),x=`confirm-title-${e.id}`,k=`confirm-body-${e.id}`;return v.useEffect(()=>{var j;const b=document.activeElement;return(j=(l&&!d?g:p).current)==null||j.focus({preventScroll:!0}),()=>{b instanceof HTMLElement&&b.isConnected&&b.focus({preventScroll:!0})}},[l,d]),v.useEffect(()=>{const b=j=>{if(j.key==="Escape"){j.preventDefault(),j.stopPropagation(),h(!1);return}if(j.key!=="Tab"||m.current===null)return;const w=[...m.current.querySelectorAll("button:not(:disabled)")],S=w.indexOf(document.activeElement);j.preventDefault();const _=w[(S+(j.shiftKey?-1:1)+w.length)%w.length];_==null||_.focus()};return document.addEventListener("keydown",b,!0),()=>document.removeEventListener("keydown",b,!0)},[h]),n.jsx("div",{className:"dialog-backdrop confirm-backdrop",onPointerDown:b=>{b.target===b.currentTarget&&h(!1)},children:n.jsxs("div",{ref:m,className:`dialog confirm-dialog ${l?"danger":""}`,role:d?"dialog":"alertdialog","aria-modal":"true","aria-labelledby":x,"aria-describedby":s===void 0&&i===void 0?void 0:k,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:k,className:"confirm-body",children:[typeof s=="string"?n.jsx(Sz,{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 Sz({text:e}){return n.jsx(n.Fragment,{children:e.split(/\n\s*\n/).map((t,s)=>{const i=t.split(`
204
+ `).filter(r=>r.trim()!=="");return i.length>0&&i.every(r=>r.startsWith("· "))?n.jsx("ul",{children:i.map((r,o)=>n.jsx("li",{children:r.slice(2)},o))},s):n.jsx("p",{children:t},s)})})}function _z(e,t){return t.find(s=>s.scripts.includes(e.packId??e.id)||s.scripts.includes(e.id))}function zd(e,t){const s=e.toLowerCase();return t.find(i=>[i.id,i.name,...i.aliases].some(r=>r.toLowerCase()===s))}function gS(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)):_z(o,s);i.push({script:o===void 0?{id:r,name:r}:{id:o.id,name:o.name},...l===void 0?{}:{game:{id:l.id,name:l.name}}})}if(i.length===0)for(const r of new Set((e==null?void 0:e.games)??[])){const o=zd(r,s);i.push({game:o===void 0?{id:r,name:r}:{id:o.id,name:o.name}})}return i}function xS(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 Pf=[];function Ez(e){const t=Se(e.capabilities),s=t.has("skills"),i=t.has("scripts"),r=t.has("games"),[o,l]=v.useState(Pf),[u,d]=v.useState(0);return v.useEffect(()=>e.connection.on("skills/changed",()=>d(h=>h+1)),[e]),v.useEffect(()=>{if(!s)return;let h=!0;const m=i?e.connection.call("scripts/list",{}).then(g=>g.scripts,()=>[]):Promise.resolve([]),p=r?e.connection.call("games/list",{}).then(g=>g.games,()=>[]):Promise.resolve([]);return Promise.all([e.connection.call("skills/list",{}),m,p]).then(([g,x,k])=>{Pf=g.skills.filter(b=>b.userInvocable).map(b=>{const j=[...new Set(gS(b.owner,x,k).map(xS))].join("、");return{name:b.name,description:b.description,...j===""?{}:{group:j}}}),h&&l(Pf)},()=>{}),()=>{h=!1}},[e,s,i,r,u]),o}const Lf=e=>e.kind==="command"?"命令":e.group??"通用技能";function vS({client:e,text:t,setText:s,area:i,submit:r,placement:o="above",inSession:l=!1}){const u=Ez(e),[d,h]=v.useState(0),[m,p]=v.useState(!1),g=m?[]:sO(t,u,l),x=t.split(/\s/)[0];v.useEffect(()=>{h(0),p(!1)},[x]);const k=Math.min(d,Math.max(0,g.length-1)),b=_=>{var E;s(`/${_.name} `),p(!0),(E=i.current)==null||E.focus()},j=_=>{var E;if(r!==void 0&&_.kind==="command"&&_.arg===void 0){s(""),r(`/${_.name}`),(E=i.current)==null||E.focus();return}b(_)},w=_=>{if(g.length===0||_.nativeEvent.isComposing)return!1;if(_.key==="ArrowDown"||_.key==="ArrowUp")return _.preventDefault(),h((k+(_.key==="ArrowDown"?1:g.length-1))%g.length),!0;if(_.key==="Tab"||_.key==="Enter"&&!_.shiftKey){_.preventDefault();const E=g[k];return _.key==="Tab"?b(E):j(E),!0}return _.key==="Escape"?(_.preventDefault(),p(!0),!0):!1};return{menu:g.length===0?null:n.jsx(Cz,{options:g,active:k,placement:o,onHover:h,onChoose:j}),onKeyDown:w,expand:_=>tO(_,u)}}function Cz({options:e,active:t,placement:s,onHover:i,onChoose:r}){const o=v.useRef(null),[l,u]=v.useState(0);v.useLayoutEffect(()=>{var m;const h=(m=o.current)==null?void 0:m.querySelector(`[data-index="${t}"]`);h==null||o.current===null||(h.scrollIntoView({block:"nearest"}),u(h.offsetTop-o.current.scrollTop))},[t,e]);const d=e[t];return n.jsxs("div",{className:`slash-pop ${s}`,children:[n.jsx("div",{ref:o,className:"slash-list",role:"listbox","aria-label":"命令和技能",onScroll:()=>{var m;const h=(m=o.current)==null?void 0:m.querySelector(`[data-index="${t}"]`);h!=null&&o.current!==null&&u(h.offsetTop-o.current.scrollTop)},children:e.map((h,m)=>n.jsxs("div",{children:[(m===0||Lf(e[m-1])!==Lf(h))&&n.jsx("div",{className:"slash-group",children:Lf(h)}),n.jsx("button",{type:"button",role:"option","data-index":m,"aria-selected":m===t,className:`slash-item ${m===t?"active":""}`,onMouseEnter:()=>i(m),onMouseDown:p=>p.preventDefault(),onClick:()=>r(h),children:h.name})]},`${h.kind}:${h.name}`))}),d!==void 0&&n.jsxs("div",{className:"slash-tip",style:{top:l},role:"tooltip",children:[d.kind==="skill"&&n.jsx("span",{className:"slash-tip-kind",children:d.group===void 0?"技能":`${d.group} 的技能`}),d.description,d.kind==="command"&&d.arg!==void 0&&n.jsxs("span",{className:"slash-tip-arg",children:["后面可以接:",d.arg]}),d.kind==="skill"&&n.jsx("span",{className:"slash-tip-arg",children:"后面写要它做的事"})]})]})}const Qp=5.5,Jb=2*Math.PI*Qp,ek=[{key:"systemTokens",label:"系统提示词",tone:"system"},{key:"toolsTokens",label:"工具定义",tone:"tools"},{key:"messageTokens",label:"对话消息",tone:"messages"}];function zf(e){return e>=1e6?`${tk(e/1e6)}M`:e>=1e3?`${tk(e/1e3)}k`:String(Math.round(e))}const tk=e=>e>=100?Math.round(e).toString():e.toFixed(1).replace(/\.0$/,"");function Az({context:e}){const[t,s]=v.useState(!1),i=v.useRef(null);if(v.useEffect(()=>{if(!t)return;const m=g=>{var x;(x=i.current)!=null&&x.contains(g.target)||s(!1)},p=g=>{g.key==="Escape"&&s(!1)};return document.addEventListener("pointerdown",m),document.addEventListener("keydown",p),()=>{document.removeEventListener("pointerdown",m),document.removeEventListener("keydown",p)}},[t]),e===null)return null;const r=Math.min(100,Math.round(e.usedTokens/e.contextWindow*100)),o=r>=90?"high":r>=70?"raised":"normal",l=e.breakdown,u=l===void 0?0:l.systemTokens+l.toolsTokens+l.messageTokens,d=l===void 0||u===0?[{key:"total",tone:"messages",width:r}]:ek.map(m=>({key:m.key,tone:m.tone,width:r*l[m.key]/u})).filter(m=>m.width>0),h=`上下文已用 ${r}%`;return n.jsxs("span",{ref:i,className:`context-meter ${o}`,children:[n.jsxs("button",{type:"button",className:"context-trigger",title:h,"aria-label":h,"aria-haspopup":"dialog","aria-expanded":t,onClick:()=>s(!t),children:[n.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[n.jsx("circle",{className:"context-track",cx:"7",cy:"7",r:Qp}),n.jsx("circle",{className:"context-fill",cx:"7",cy:"7",r:Qp,strokeDasharray:`${Jb*r/100} ${Jb}`,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:["~",zf(e.usedTokens)," / ",zf(e.contextWindow)]})]}),n.jsx("div",{className:"context-bar",children:d.map(m=>n.jsx("span",{className:`context-segment ${m.tone}`,style:{width:`${m.width}%`}},m.key))}),l!==void 0&&n.jsx("dl",{className:"context-rows",children:ek.map(m=>n.jsxs("div",{children:[n.jsxs("dt",{children:[n.jsx("span",{className:`context-swatch ${m.tone}`,"aria-hidden":"true"}),m.label]}),n.jsxs("dd",{children:["~",zf(l[m.key])]})]},m.key))}),n.jsxs("p",{className:"context-tip",children:["快满时会自动压缩(「设置 → 对话压缩」)。也可以输入 ",n.jsx("kbd",{children:"/压缩"})," 手动压缩:较早的部分换成摘要,agent 会忘掉其中的细节。"]})]})]})}const $z=6e4,Iz={CNY:"¥",USD:"$"},bd=(e,t)=>{const s=Iz[e];return s===void 0?`${t} ${e}`:`${s}${t}`};function Tz({balances:e}){const t=e.filter(s=>Number(s.total)!==0);return(t.length>0?t:e.slice(0,1)).map(s=>bd(s.currency,s.total)).join(" / ")}function Mz(e){return`DeepSeek 账户余额 ${e.balances.map(s=>`${bd(s.currency,s.total)}(充值 ${bd(s.currency,s.toppedUp)},赠送 ${bd(s.currency,s.granted)})`).join("、")}${e.available?"":"。余额不足,调用模型会失败"}`}function Rz({client:e,sessionId:t,running:s}){var p;const{catalog:i}=aa(e),r=Se(e.sessionModels).get(t),o=((p=pS(i,r))==null?void 0:p.provider)??null,l=Se(e.credentialRevision),u=Se(e.connection.status),d=Se(e.capabilities),[h,m]=v.useState(null);return v.useEffect(()=>{if(o===null||u.state!=="open"||!d.has("providers"))return;let g=!0;const x=()=>e.providerBalance(o).then(b=>{g&&m({provider:o,balance:b,error:null})},b=>{g&&m({provider:o,balance:null,error:b instanceof Error?b.message:String(b)})});x();const k=s?setInterval(()=>void x(),$z):void 0;return()=>{g=!1,clearInterval(k)}},[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:Mz(h.balance),children:Tz(h.balance)})}function Oz({client:e,session:t,running:s,disabled:i,initialPrompt:r,onInitialSent:o,reminder:l}){const u=Se(e.capabilities),{queue:d,context:h}=Se(t.state),m=d.filter(K=>K.placement!=="taken"),p=v.useContext(Nc),g=(p==null?void 0:p.quote)??null,[x,k]=v.useState(()=>cc(mS(t.id)).body),[b,j]=v.useState(!0),[w,S]=v.useState(null),[_,E]=v.useState(null),M=v.useRef(null),O=v.useRef(null),B=v.useRef(!1),[U,P]=v.useState(()=>dz(t.id));v.useEffect(()=>uz(t.id,Rf(x,g)),[t.id,x,g]),v.useEffect(()=>{var K;g&&((K=M.current)==null||K.focus())},[g]),v.useEffect(()=>hz(t.id,U),[t.id,U]);const R=wO(e),[z,L]=v.useState(!1),A=async K=>{const Z=K.filter(Q=>Q.type.startsWith("image/"));if(Z.length===0)return;S(null);const Y=Fl-U.length;if(Y<=0){S(`一条消息最多 ${Fl} 张图片`);return}try{const Q=await Promise.all(Z.slice(0,Y).map(zz));P(ie=>[...ie,...Q].slice(0,Fl)),Z.length>Y&&S(`一条消息最多 ${Fl} 张图片,多的没有加上`)}catch(Q){S(`图片没能加上:${Q instanceof Error?Q.message:String(Q)}`)}},T=K=>{const Z=[...K.clipboardData.items].filter(Y=>Y.kind==="file"&&Y.type.startsWith("image/")).map(Y=>Y.getAsFile()).filter(Y=>Y!==null);Z.length!==0&&(K.preventDefault(),A(Z))},H=K=>{L(!1),K.dataTransfer.files.length!==0&&(K.preventDefault(),A([...K.dataTransfer.files]))};v.useEffect(()=>{var K;r===void 0||B.current||i||(B.current=!0,t.prompt(r,"queue").catch(Z=>S(Z instanceof Error?Z.message:String(Z))),o==null||o(),(K=M.current)==null||K.focus())},[r,i,t,o]);const F=K=>J2(K)!=="compact"?!1:(k(""),S(null),s?(S("agent 正在工作,等它停下再压缩"),!0):(Ms({title:"压缩这个对话?",message:Pz,confirmLabel:"压缩",danger:!0}).then(Z=>{Z&&(E("正在压缩对话:模型在写摘要,可能要一两分钟…"),t.compact().then(Y=>E(Y.message),Y=>{E(null),S(Y instanceof Error?Y.message:String(Y))}))}),!0)),V=vS({client:e,text:x,setText:k,area:M,inSession:!0,submit:K=>{i||F(K)||(S(null),p==null||p.select(null),t.prompt(Rf(V.expand(K),g),s&&b?"steer":"queue").catch(Z=>S(Z instanceof Error?Z.message:String(Z))))}}),D=()=>{var Y;if(!i&&U.length===0&&F(x))return;const K=V.expand(x);if(!K.trim()&&U.length===0||i)return;const Z=U.map(({url:Q,...ie})=>ie);k(""),P([]),S(null),p==null||p.select(null),t.prompt(Rf(K,g),s&&b?"steer":"queue",Z).catch(Q=>S(Q instanceof Error?Q.message:String(Q))),(Y=M.current)==null||Y.focus()},q=K=>{V.onKeyDown(K)||K.key==="Enter"&&!K.shiftKey&&!K.nativeEvent.isComposing&&(K.preventDefault(),D())},te=K=>{t.updateQueue(K.id,"remove").then(()=>{if(x.trim()===""&&!g&&K.text!==""){const Z=cc(K.text);k(Z.body),p==null||p.select(Z.quote)}},Z=>S(Z instanceof Error?Z.message:String(Z)))},G=K=>{t.updateQueue(K.id,"steer").catch(Z=>S(Z instanceof Error?Z.message:String(Z)))};return n.jsxs("div",{className:"composer",children:[w!==null&&n.jsx("div",{className:"error small composer-error",children:w}),m.length>0&&n.jsx("div",{className:"queue","aria-label":"等待发送的消息",children:m.map(K=>n.jsxs("div",{className:"queue-item",children:[n.jsx("span",{className:`queue-tag ${K.placement}`,children:K.placement==="next-step"?"插入中":"排队中"}),n.jsxs("span",{className:"queue-text",title:K.text,children:[cc(K.text).body||"(图片)",K.images!==void 0&&n.jsxs("span",{className:"muted",children:[" · ",K.images," 张图片"]})]}),n.jsx("span",{className:"queue-when muted",children:K.placement==="next-step"?"这一步做完就交给 agent":"这一轮结束后发送"}),K.placement==="next-turn"&&s&&n.jsx("button",{type:"button",className:"small-button",title:"不等这一轮结束,现在就交给 agent",onClick:()=>G(K),children:"现在插入"}),n.jsx("button",{type:"button",className:"small-button",title:"撤回这条消息",onClick:()=>te(K),children:"撤回"})]},K.id))}),l,_!==null&&n.jsxs("div",{className:"composer-note small",role:"status",children:[n.jsx("span",{children:_}),n.jsx("button",{type:"button",className:"ghost small-button",onClick:()=>E(null),children:"知道了"})]}),n.jsxs("div",{className:"slash-anchor",children:[V.menu,n.jsxs("div",{className:`composer-box ${z?"dragging":""}`,onDragOver:K=>{[...K.dataTransfer.items].some(Z=>Z.kind==="file")&&(K.preventDefault(),L(!0))},onDragLeave:()=>L(!1),onDrop:H,children:[g&&n.jsx(fS,{quote:g,onRemove:()=>{var K;p==null||p.select(null),(K=M.current)==null||K.focus()}}),U.length>0&&n.jsx("div",{className:"composer-images",children:U.map((K,Z)=>n.jsxs("span",{className:"composer-image",children:[n.jsx("img",{src:K.url,alt:K.name??`图片 ${Z+1}`}),n.jsx("button",{type:"button","aria-label":"移除这张图片",onClick:()=>P(Y=>Y.filter((Q,ie)=>ie!==Z)),children:"✕"})]},Z))}),n.jsx("textarea",{onPaste:T,ref:M,"aria-label":"消息内容",value:x,onChange:K=>k(K.target.value),onKeyDown:q,rows:Math.min(8,Math.max(2,x.split(`
205
+ `).length)),placeholder:i?"未连接到 agent":s?b?"运行中:发出去会插进这一轮,改主意了直接说":"运行中:消息会排队到下一轮":"继续追问,或描述下一步要做的事",disabled:i}),n.jsxs("div",{className:"composer-actions",children:[u.has("models")&&n.jsx(vz,{client:e,sessionId:t.id,disabled:i}),n.jsx("button",{type:"button",className:"attach-button",title:"添加图片(也可以直接粘贴或拖进来)","aria-label":"添加图片",disabled:i||U.length>=Fl,onClick:()=>{var K;return(K=O.current)==null?void 0:K.click()},children:n.jsx(ee,{name:"image"})}),n.jsx("input",{ref:O,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:K=>{A([...K.target.files??[]]),K.target.value=""}}),R==="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(Rz,{client:e,sessionId:t.id,running:s}),n.jsx(Az,{context:h}),s&&n.jsxs("label",{className:"steer-toggle",title:"这一步做完 agent 就会看到;不勾选就等这一轮结束再发",children:[n.jsx("input",{type:"checkbox",checked:b,onChange:K=>j(K.target.checked)}),"插入当前轮次"]}),s&&n.jsxs("button",{className:"stop-button",onClick:()=>void t.cancel().catch(K=>S(String(K))),disabled:i,children:[n.jsx(_O,{}),"停止"]}),n.jsx("button",{className:"send-button","aria-label":"发送",title:"发送(Enter)",onClick:D,disabled:i||x.trim()===""&&U.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 Pz=["压缩会把这个对话较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:","","· 会丢失记忆:早先的细节 agent 不再记得(具体的命令和输出、日志、截图、你说过的原话);","· 摘要可能漏掉或写错内容;","· 不能撤销。界面上的聊天记录还在,但 agent 看不到了。","","对话很长、回复变慢或报上下文超长时再压缩。"].join(`
206
+ `),Fl=4,Lz=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function zz(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(Lz.has(e.type)&&i.length<=Rp)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<=Rp)return{mediaType:"image/jpeg",data:h,name:s.replace(/\.\w+$/,".jpg"),url:d}}throw new Error("图片太大")}const Jp=v.createContext(null);function nk({label:e,tone:t="running"}){return n.jsxs("div",{className:`thinking tone-${t}`,role:"status",children:[t==="waiting"?n.jsx(ee,{name:"clock"}):n.jsxs("span",{className:"dot-pulse","aria-hidden":!0,children:[n.jsx("i",{}),n.jsx("i",{}),n.jsx("i",{})]}),e]})}const Dz={web_fetch:"正在读取网页",web_search:"正在搜索网页",read:"正在读取文件",write:"正在写入文件",edit:"正在编辑文件",run_code:"正在运行代码",game_activities:"正在核对游戏活动",game_notice:"正在保存公告",game_record:"正在保存活动",agent_threads:"正在查看任务进度",agent_message:"正在发送任务消息",script_runs:"正在查看脚本运行状态"};function yS(e){if(e.approval==="asked")return"等待你批准操作";if(e.name==="ask_user_question")return"等待你回答问题";if(e.name==="run_code")try{const{title:t}=JSON.parse(e.arguments);if(typeof t=="string"&&t.trim())return t.trim()}catch{}return Dz[e.name]??`正在调用 ${e.name}`}function Fz(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<Uz?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 Uz=400;function bS(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 Bz=160;function uc(e,t=Bz){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 sk(e,t="text"){return e.filter(s=>s.type===t).map(s=>s.text).join("")}function ec(e){const t=uc(sk(e));if(t!=="")return t;const s=uc(sk(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 Hz(e,t=null,s={}){var O,B,U,P,R,z,L;const i=[],r=new Map,o=[],l=new Map,u=new Map,d=new Map;let h=null,m=null,p=null,g=0,x=0;const k=(A,T)=>{let H=r.get(A);return H===void 0&&(H=Df(`t:${A}`,A,T,!0),r.set(A,H),i.push(H)),m=null,H},b=(A,T)=>h!==null?h:(m===null&&(m=Df(`b:${T}`,null,A,!1),i.push(m)),m),j=(A,T,H,F)=>{let V=A.steps.get(H);return V===void 0&&(V={turn:T,step:H,start:F,startKnown:!1,end:null,records:[],retries:0},A.steps.set(H,V),A.stepOrder.push(H)),V},w=(A,T,H)=>{A.records.push(H),T==null||T.records.push(H),o.push(H)},S=A=>(A.requestIndex??(A.requestIndex=++g),A.requestIndex),_=new Set;for(const A of e)switch(x=Math.max(x,A.time),A.type){case"turn/start":{const T=Df(`t:${A.turn}`,A.turn,A.time,!1);r.set(A.turn,T),i.push(T),h=T,m=null;break}case"turn/end":{const T=k(A.turn,A.time);T.end=A.time,T.reason=A.reason;for(const H of T.steps.values())H.end??(H.end=A.time);for(const H of l.values())H.turn===A.turn&&H.status==="running"&&(H.status="interrupted",H.end=A.time);h===T&&(h=null);break}case"step/start":{const T=k(A.turn,A.time),H=j(T,A.turn,A.step,A.time);H.start=A.time,H.startKnown=!0;break}case"step/end":{const T=k(A.turn,A.time);j(T,A.turn,A.step,A.time).end=A.time;break}case"user/message":{const T=b(A.time,A.seq);w(T,null,Zz(A,T.turn));break}case"system/message":{if(A.text.trim()==="")break;const T=k(A.turn,A.time),H=j(T,A.turn,A.step,A.time),F={kind:"system",id:`system:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:A.time,end:A.time,status:"ok",title:"System prompt",preview:uc(A.text),text:A.text};w(T,H,F);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 T=k(A.turn,A.time),H=j(T,A.turn,A.step,A.time);Ff(H,A.timing.firstTokenAt),H.retries+=1,A.error!==void 0&&(H.lastRetryError=A.error);const F={...A.usage===void 0?{}:{usage:A.usage},kind:"attempt",id:`attempt:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:A.timing.firstChunkAt??H.start,end:A.timing.lastChunkAt??A.time,status:"error",title:"Failed attempt",preview:((O=A.error)==null?void 0:O.message)??"attempt ended without output",...A.error===void 0?{}:{error:A.error}};w(T,H,F);break}case"assistant/message":{const T=k(A.turn,A.time),H=j(T,A.turn,A.step,A.time);Ff(H,A.timing.firstTokenAt),_.add(`${A.turn}:${A.step}`);const F=A.timing.firstTokenAt,V=A.timing.lastChunkAt,D=F!==void 0&&V!==void 0?V-F:void 0,q=A.model??(p==null?void 0:p.model),te=A.provider??(p==null?void 0:p.provider),G={kind:"assistant",id:`assistant:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:H.start,end:V??A.time,status:A.interrupted===!0?"interrupted":"ok",title:q===void 0?"Assistant":`Assistant · ${q}`,preview:ec(A.content),content:A.content,live:!1,interrupted:A.interrupted===!0,request:rk({index:S(H),provider:te,model:q,reasoningEffort:p==null?void 0:p.reasoningEffort,toolCount:p==null?void 0:p.toolCount,ttftMs:ik(H),decodeMs:D,tokensPerSecond:Wz((B=A.usage)==null?void 0:B.outputTokens,D),usage:A.usage,retries:H.retries,lastRetryError:H.lastRetryError})};w(T,H,G);break}case"tool/call":{const T=k(A.turn,A.time),H=j(T,A.turn,A.step,A.time),F=d.get(A.callId),V={kind:"tool",id:`tool:${A.callId}`,seq:A.seq,turn:A.turn,step:A.step,start:A.time,end:null,status:T.end===null?"running":"interrupted",title:A.name,preview:uc(A.arguments),name:A.name,callId:A.callId,arguments:A.arguments,isError:!1,...F===void 0?{}:{approval:{approvalId:F}}};l.set(A.callId,V),w(T,H,V);break}case"tool/result":{const T=l.get(A.callId);if(T===void 0){const F=k(A.turn,A.time),V=j(F,A.turn,A.step,A.time),D={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}};w(F,V,D);break}T.end=A.time,T.result=A.content,T.isError=A.isError,T.status=A.isError?"error":"ok",A.error!==void 0&&(T.error=A.error);const H=ec(A.content);H!==""&&(T.preview=`${uc(T.arguments,80)} ⇒ ${H}`);break}case"approval/asked":{if(A.callId===void 0)break;d.set(A.callId,A.approvalId);const T=l.get(A.callId);T!==void 0&&(T.approval={approvalId:A.approvalId,...A.reason===void 0?{}:{reason:A.reason}});break}case"approval/decided":{for(const T of l.values())((U=T.approval)==null?void 0:U.approvalId)===A.approvalId&&(T.approval={...T.approval,outcome:A.outcome});break}case"compaction/start":{const T=A.turn===null?b(A.time,A.seq):k(A.turn,A.time),H={kind:"compaction",id:`compaction:${A.compactionId}`,seq:A.seq,turn:T.turn,step:null,start:A.time,end:null,status:"running",title:"Compaction",preview:"summarizing history…",compactionId:A.compactionId};u.set(A.compactionId,H),w(T,null,H);break}case"compaction/summary":{const T=u.get(A.compactionId);if(T===void 0)break;T.shadowedTokenCount=A.shadowedTokenCount,A.usage!==void 0&&(T.usage=A.usage),T.preview=`${A.shadowedTokenCount.toLocaleString("en-US")} tokens summarized`;break}case"compaction/end":{const T=u.get(A.compactionId);if(T===void 0)break;T.end=A.time,T.status=A.error===void 0?"ok":"error",A.error!==void 0&&(T.error=A.error,T.preview=A.error);break}}if(t!==null&&!_.has(`${t.turn}:${t.step}`)){const A=k(t.turn,((P=t.deltas[0])==null?void 0:P.time)??s.now??x),T=j(A,t.turn,t.step,((R=t.deltas[0])==null?void 0:R.time)??s.now??x),H=(z=t.deltas.find(q=>q.text!==""||q.toolName!==void 0))==null?void 0:z.time;Ff(T,H);const F=Vz(t.deltas),V=(L=t.deltas.at(-1))==null?void 0:L.time;V!==void 0&&(x=Math.max(x,V));const D={kind:"assistant",id:`live:${t.attemptId}`,seq:t.afterSeq,turn:t.turn,step:t.step,start:T.start,end:null,status:"running",title:(p==null?void 0:p.model)===void 0?"Assistant":`Assistant · ${p.model}`,preview:ec(F)||"waiting for output…",content:F,live:!0,interrupted:!1,request:rk({index:S(T),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:ik(T),retries:T.retries,lastRetryError:T.lastRetryError})};w(A,T,D)}const E=i.map(A=>({key:A.key,turn:A.turn,start:A.start,end:A.end,partialStart:A.partialStart,...A.reason===void 0?{}:{reason:A.reason},steps:A.stepOrder.map(T=>{const H=A.steps.get(T);return{turn:H.turn,step:H.step,start:H.start,end:H.end,records:H.records}}),records:A.records})),M=s.now??x;return{groups:E,records:o,totals:qz(o),span:Gz(o,M)}}function Df(e,t,s,i){return{key:e,turn:t,start:s,end:null,partialStart:i,steps:new Map,stepOrder:[],records:[]}}function Zz(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 Ff(e,t){t!==void 0&&(e.firstTokenAt===void 0||t<e.firstTokenAt)&&(e.firstTokenAt=t)}function ik(e){if(!e.startKnown||e.firstTokenAt===void 0)return;const t=e.firstTokenAt-e.start;return t>=0?t:void 0}function Wz(e,t){if(!(e===void 0||t===void 0||t<=0))return e/(t/1e3)}function Vz(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 qz(e){const t={requests:0,reportedUsage:0,missingUsage:0,toolCalls:0,errors:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,reasoningTokens:0};for(const s of e){s.status==="error"&&(t.errors+=1),s.kind==="tool"&&(t.toolCalls+=1);const i=s.kind==="assistant"?s.request.usage:s.kind==="compaction"||s.kind==="attempt"?s.usage:void 0;if(s.kind==="assistant"&&(t.requests+=1),i===void 0){(s.kind==="assistant"||s.kind==="attempt"||s.kind==="compaction"&&s.shadowedTokenCount!==void 0)&&t.missingUsage++;continue}t.reportedUsage++,t.inputTokens+=i.inputTokens,t.outputTokens+=i.outputTokens,t.cacheReadTokens+=i.cacheReadTokens??0,t.cacheWriteTokens+=i.cacheWriteTokens??0,t.reasoningTokens+=i.reasoningTokens??0}return t}function Gz(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 rk(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const kS=[{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"}],Kz=new Map(kS.flatMap((e,t)=>e.kinds.map(s=>[s,t])));function Yz(e){return e.records.map(t=>{const s=t.end===null||t.end<=t.start,i={record:t,lane:Kz.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 Xz(e,t){const s=e.end??e.start;return e.start<=t.end&&s>=t.start}function Qz(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 Jz(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 eD(e,t){const s=t.trim().toLowerCase();return s===""?e:e.filter(i=>i.title.toLowerCase().includes(s)||i.preview.toLowerCase().includes(s)?!0:i.kind==="tool"?i.arguments.toLowerCase().includes(s):!1)}function Zs(e){if(e==null||!Number.isFinite(e))return"—";if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?2:1)} s`;const s=Math.floor(t/60);return s<60?`${s}m ${String(Math.floor(t%60)).padStart(2,"0")}s`:`${Math.floor(s/60)}h ${String(s%60).padStart(2,"0")}m`}function Nn(e){return e==null?"—":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(e<1e4?2:1)}k`:`${(e/1e6).toFixed(2)}M`}function Yr(e){const t=new Date(e),s=(i,r=2)=>String(i).padStart(r,"0");return`${s(t.getHours())}:${s(t.getMinutes())}:${s(t.getSeconds())}.${s(t.getMilliseconds(),3)}`}function hx(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const tD=5*6e4,jS=["周日","周一","周二","周三","周四","周五","周六"],Dd=e=>{const t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()},tc=e=>`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`;function nD(e,t=Date.now()){const s=new Date(e),i=Math.round((Dd(t)-Dd(e))/864e5);return i<=0?tc(s):i===1?`昨天 ${tc(s)}`:i<7?`${jS[s.getDay()]} ${tc(s)}`:`${s.getFullYear()===new Date(t).getFullYear()?"":`${s.getFullYear()}年`}${s.getMonth()+1}月${s.getDate()}日 ${tc(s)}`}function NS(e,t){return e===void 0?!1:t===void 0||e-t>=tD||Dd(e)!==Dd(t)}function sD(e){const t=new Date(e);return`${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日${jS[t.getDay()]} ${tc(t)}`}function wS({at:e}){return n.jsxs("div",{className:"time-divider",children:[n.jsx("span",{className:"time-short",children:nD(e)}),n.jsx("span",{className:"time-full","aria-hidden":!0,children:sD(e)})]})}const eg="agent_delegate",SS=v.createContext([]),Vo=v.createContext(cn.name);function Bc(e){return`#/h/${encodeURIComponent(e.id)}`}function iD(e){try{const t=JSON.parse(e);return{agent:String(t.agent??""),task:String(t.task??"")}}catch{return{agent:"",task:e}}}function na(e,t){const i=$i(e).find(r=>r.name===t||r.id===t);return i===void 0?t===cn.name||t===cn.id?cn:void 0:Ka(i)}const dh={running:{label:"进行中",tone:"running"},waiting:{label:"等待答复",tone:"waiting"},done:{label:"交回了",tone:"ok"},failed:{label:"没做成",tone:"failed"}};function Hc({from:e,to:t,avatar:s,title:i,state:r,href:o}){const l=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`agent-avatar small agent-${(s==null?void 0:s.id)??"unknown"}`,children:n.jsx(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 mx(e){var t;if(e.state==="failed"&&e.endedAt!==void 0){const s=(t=e.messages)==null?void 0:t.filter(i=>i.at>e.endedAt);if(s!=null&&s.some(i=>i.kind==="done"))return{label:"已补交结论",tone:"ok"};if(s!=null&&s.length)return{label:"结束后有新消息",tone:"asked"}}return dh[e.state]}function rD({client:e,item:t,handOffs:s}){const{agent:i,task:r}=v.useMemo(()=>iD(t.arguments),[t.arguments]),o=na(e,i),l=v.useContext(Vo),u=s.find(p=>p.callId===t.callId),d=t.status==="error"||t.status==="interrupted",h=t.status==="running"?{label:"正在派发",tone:"running"}:{label:"已派发",tone:"ok"},m=d?dh.failed:u?mx(u):h;return n.jsxs("div",{className:"delegation",children:[n.jsx(Hc,{from:l,to:(o==null?void 0:o.name)??i,avatar:o,title:(u==null?void 0:u.title)??r.split(`
207
+ `)[0]??"",state:m,href:u===void 0?void 0:Bc(u)}),d&&n.jsxs("div",{className:"delegation-failed",children:[n.jsx(ee,{name:"alert"}),t.result??t.error??"没有交出去"]})]})}function aD({client:e,handOff:t}){const s=na(e,t.to);return n.jsx("div",{className:"delegation app-handoff",children:n.jsx(Hc,{from:t.by,to:(s==null?void 0:s.name)??t.to,avatar:s,title:t.title,state:mx(t),href:Bc(t)})})}function oD({client:e,note:t,handOffs:s}){const i=na(e,t.agent),r=v.useContext(Vo),o=s.filter(u=>u.state!=="running"&&u.title===t.title&&(u.to===(i==null?void 0:i.id)||u.to===t.agent)).at(-1),l=o!==void 0?Bc(o):i!==void 0?`#/a/${encodeURIComponent(i.id)}`:void 0;return n.jsx("div",{className:"delegation relay-line",children:n.jsx(Hc,{from:t.agent,to:r,avatar:i,title:t.title,state:t.ok?dh.done:{label:"没有做完",tone:"failed"},href:l})})}function lD({client:e,note:t,handOffs:s}){const i=na(e,t.from),r=v.useContext(Vo),o=s.find(l=>l.id===t.thread);return n.jsx("div",{className:"delegation task-line",children:n.jsx(Hc,{from:t.from,to:r,avatar:i,title:t.text.split(`
208
+ `)[0]??t.title,state:{label:_S[t.kind],tone:t.kind==="question"?"asked":"ok"},href:o===void 0?void 0:Bc(o)})})}function cD({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===Wg?n.jsxs("div",{className:"msg user delegated",children:[n.jsx("div",{className:"msg-from",children:"你在软件里点的"}),n.jsx("div",{className:"bubble",children:n.jsxs("details",{className:"task-note",children:[n.jsx("summary",{children:t.title}),n.jsx("div",{className:"task-note-body",children:t.body})]})})]}):o!==void 0?n.jsx("div",{className:"delegation task-line",children:n.jsx(Hc,{from:t.by,to:(u==null?void 0:u.name)??o.to,avatar:l,title:t.title,state:mx(o),href:Bc(o)})}):n.jsxs("div",{className:"delegation task-line",children:[n.jsxs("button",{className:"exchange-line",onClick:()=>r(d=>!d),"aria-expanded":i,title:i?"收起":"看交给了什么",children:[n.jsx("span",{className:`agent-avatar small agent-${(l==null?void 0:l.id)??"unknown"}`,children:n.jsx(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 uD({client:e,handOff:t,name:s}){const i=Se(e.sessions).items.find(d=>d.id===t.toSession),r=dx(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 dD(e,t){const s=Se(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 hD(e,t){var h,m;const s=(h=t==null?void 0:t.chain)==null?void 0:h.at(-2),i=(m=t==null?void 0:t.chain)==null?void 0:m.at(-1),[r,o]=v.useState([]),[l,u]=v.useState(!1);return v.useEffect(()=>{if(t===null)return;if(s===void 0||i===void 0){u(!0);return}let p=!0;return e.connection.call("handoffs/between",{a:s,b:i}).then(g=>{p&&(o(g.items),u(!0))},()=>{p&&u(!0)}),()=>{p=!1}},[e,s,i,t===null]),v.useEffect(()=>e.connection.on("handoffs/changed",({item:p})=>{var k,b;const g=(k=p.chain)==null?void 0:k.at(-2),x=(b=p.chain)==null?void 0:b.at(-1);(g===s&&x===i||g===i&&x===s)&&o(j=>j.some(w=>w.id===p.id)?j.map(w=>w.id===p.id?p:w):[...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 mD(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(QD,{client:e,session:o.toSession,from:o.startedAt,to:o.endedAt,onOpen:i})}),(o.messages??[]).forEach((h,m)=>{const p=o.endedAt!==void 0&&h.at>o.endedAt;h.kind==="done"&&!p||r.push({kind:"said",key:`${o.id}:${m}`,thread:o.id,at:h.at,who:s(h.from),kindOf:h.kind,body:n.jsxs(n.Fragment,{children:[p&&n.jsx("div",{className:"muted small",children:h.kind==="done"?"任务结束后补交的结论":"任务结束后收到的消息"}),n.jsx(Hs,{text:h.text})]})})}),o.state!=="running"&&o.state!=="waiting"?r.push({kind:"said",key:`${o.id}:reply`,thread:o.id,at:o.endedAt??o.startedAt,who:u,failed:o.state==="failed",body:n.jsxs(n.Fragment,{children:[n.jsx(Hs,{text:o.reply??(o.state==="failed"?"没有做完":"它没有留下回复")}),o.state==="failed"&&o.reply!==void 0&&n.jsx("div",{className:"muted small",children:"(该轮未完成)"})]})}):r.push({kind:"said",key:`${o.id}:now`,thread:o.id,at:Number.MAX_SAFE_INTEGER,who:u,body:o.state==="waiting"?n.jsxs("div",{className:"delegation-now",children:[n.jsx("span",{className:"tool-spinner",role:"img","aria-label":"等回答"}),n.jsxs("span",{children:["等",l,"回答"]})]}):n.jsx(uD,{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 fD({client:e,id:t,onClose:s}){const{item:i,error:r}=dD(e,t),[o,l]=v.useState(null),u=$i(e),d=na(e,(i==null?void 0:i.by)??""),h=na(e,(i==null?void 0:i.to)??""),{threads:m,ready:p}=hD(e,i),g=XD(e,m),x=O=>{var B;return((B=u.find(U=>U.id===O))==null?void 0:B.name)??(O===cn.id?cn.name:O)},k=O=>{const B=u.find(U=>U.name===O||U.id===O);return B===void 0?O===cn.name||O===cn.id?cn:void 0:Ka(B)},b=i===null?[]:mD(e,m,x,l),j=v.useRef(null),w=v.useRef(!1);if(v.useLayoutEffect(()=>{const O=j.current;if(w.current||O===null||i===null||!p)return;w.current=!0;const B=O.querySelector(`[data-thread="${CSS.escape(i.id)}"]`);O.scrollTop=B===null?O.scrollHeight:O.scrollTop+B.getBoundingClientRect().top-O.getBoundingClientRect().top-12},[i,m,p]),v.useEffect(()=>{const O=B=>{B.key==="Escape"&&o===null&&s()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[s,o]),i===null)return n.jsx("section",{className:"main empty exchange-page",children:r??"正在打开…"});const S=(h==null?void 0:h.name)??i.to,_=dh[i.state],E=[];let M;for(const O of b){const B=O.at===Number.MAX_SAFE_INTEGER?void 0:O.at;if(B!==void 0&&NS(B,M)&&E.push(n.jsx(wS,{at:B},`t:${O.key}`)),B!==void 0&&(M=B),O.kind==="aside"){E.push(n.jsx("div",{className:"exchange-aside","data-thread":O.thread,children:O.body},O.key));continue}const U=k(O.who);E.push(n.jsxs("div",{className:`exchange-msg ${O.failed===!0?"failed":""}`,"data-thread":O.thread,children:[n.jsxs("div",{className:"exchange-msg-head",children:[n.jsx("span",{className:`agent-avatar small agent-${(U==null?void 0:U.id)??"unknown"}`,children:n.jsx(ee,{name:(U==null?void 0:U.icon)??"sparkles"})}),n.jsx("strong",{children:O.kindOf===void 0||O.kindOf==="done"?O.who:`${O.who} · ${_S[O.kindOf]}`})]}),n.jsx("div",{className:"exchange-msg-body",children:O.body})]},O.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:S})]}),n.jsxs("div",{className:"session-meta",children:[n.jsx("span",{className:`delegation-state tone-${_.tone}`,children:_.label}),n.jsx("span",{children:i.title}),n.jsx("span",{children:new Date(i.startedAt).toLocaleString()})]})]})}),n.jsx("div",{className:"view",children:n.jsx(xx.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(qS,{tasks:g,labels:pD,current:o==null?void 0:o.id,onOpen:l})}),n.jsx("div",{className:"chat",ref:j,children:n.jsx("div",{className:"chat-inner",children:E})}),o!==null&&n.jsx(vx,{client:e,task:o,parent:S,trail:i.by===S?[]:[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 pD=new Map,_S={question:"问",answer:"答",update:"说",done:"结论"},gD=3,xD=/^(编排|游戏信息|干预)[::]/,ak="adg:skill-offer:off",ok=e=>`adg:skill-offer:${e}`;function lk(e){try{return localStorage.getItem(e)}catch{return null}}function ck(e,t){try{localStorage.setItem(e,t)}catch{}}function vD(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<gD||((r=s.at(-1))==null?void 0:r.kind)!=="assistant"))return e[t].id}function yD({session:e,title:t,items:s}){const i=vD(s),[r,o]=v.useState(()=>lk(ak)==="1"),[l,u]=v.useState(()=>lk(ok(e.id))),[d,h]=v.useState(!1);if(i===void 0||r||l===i||t!==null&&xD.test(t))return null;const m=()=>{ck(ok(e.id),i),u(i)},p=async()=>{h(!0);try{await e.prompt(fw),m()}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:()=>{ck(ak,"1"),o(!0)},children:"不再提示"}),n.jsx("button",{className:"small-button",disabled:d,onClick:m,children:"这次不用"}),n.jsx("button",{className:"small-button primary",disabled:d,onClick:()=>void p(),children:"存成技能"})]})]})}function bD(e,t){const s=Se(e.connection.status),i=Se(e.capabilities),[r,o]=v.useState(null),l=t&&i.has("notify");return v.useEffect(()=>{if(!l||s.state!=="open")return;let u=!0;return e.connection.call("notify/notices",{}).then(d=>{u&&o(d.items)},()=>{u&&o(d=>d??[])}),()=>{u=!1}},[e,l,s.state]),v.useEffect(()=>{if(l)return e.connection.on("notify/notice",({item:u})=>o(d=>d===null?d:d.findIndex(m=>m.id===u.id)<0?[...d,u]:d.map(m=>m.id===u.id?u:m)))},[e,l]),l?r:kD}const kD=[];function jD(e,t,s,i){const r=t.filter(h=>h.at>=s);if(r.length===0)return[...e];const o=new Array(e.length);let l=1/0;for(let h=e.length-1;h>=0;h--){const m=e[h];"time"in m&&typeof m.time=="number"&&(l=m.time),o[h]=l}const u=[];let d=0;for(e.forEach((h,m)=>{if(i(h))for(;d<r.length&&r[d].at<o[m];)u.push(uk(r[d++]));u.push(h)});d<r.length;)u.push(uk(r[d++]));return u}function uk(e){return{kind:"sent",id:`sent:${e.id}`,notice:e}}const ND={info:"send",success:"check",warning:"alert",error:"alert"};function wD({client:e,notice:t}){const[s,i]=v.useState(null),[r,o]=v.useState(null),l=t.acted===void 0&&t.done===void 0&&t.actions.length>0,u=h=>{i(h),o(null),e.connection.call("notify/act",{noticeId:t.id,actionId:h}).catch(m=>o(Ce(m))).finally(()=>i(null))},d=new Date(t.at).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});return n.jsxs("div",{className:`sent-notice ${t.severity}`,children:[n.jsxs("div",{className:"sent-notice-head",children:[n.jsx(ee,{name:ND[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 SD=80,_D=[];function ES({client:e,session:t,state:s,readOnly:i}){var be,De,Re;const r=v.useMemo(()=>rh(s.events,s.live,s.pending,s.queue),[s.events,s.live,s.pending,s.queue,s.version]),o=v.useMemo(()=>r.filter(ae=>!zS(ae)),[r]),l=v.useMemo(()=>OS(s.events),[s.events]),u=v.useMemo(()=>LS(r,l,s.events),[r,l,s.events]),d=v.useMemo(()=>ZS(r,l),[r,l]),h=WS(e,t.id),m=$i(e),p=Se(e.sessions).items.find(ae=>ae.id===t.id),g=p===void 0?wn:cS(p,m),x=dS(e,wn),k=bD(e,p!==void 0?p.home===wn:x.sessionId===t.id),[b,j]=v.useState(!1),w=b||(s.status==="open"?k!==null:s.status!=="opening");w&&!b&&j(!0);const S=w&&k!==null?k:_D,_=s.hasMore?((be=s.events[0])==null?void 0:be.time)??0:0,E=v.useMemo(()=>ID(jD(o,S,_,AS)),[o,S,_]),M=v.useContext(gx),O=v.useContext(Vo),B=v.useContext(Nc),U=M!==null?O:((De=m.find(ae=>ae.id===g))==null?void 0:De.name)??cn.name,[P,R]=GD((p==null?void 0:p.role)??wn),z=M===null?P:3,L=v.useMemo(()=>$D(E,z),[E,z]),A=v.useMemo(()=>{let ae;return L.map(Fe=>{const ut=CD(Fe),gt=NS(ut,ae)?ut:void 0;return ut!==void 0&&(ae=ut),gt})},[L]),[T,H]=v.useState(null),F=v.useContext(Jp),V=w&&M===null&&F===null?n.jsx(qS,{tasks:h,labels:d,current:T==null?void 0:T.id,onOpen:H}):null,D=w&&M===null&&(s.running||h.length>0||E.some(ae=>CS(ae)>1)||o.some(ae=>ae.kind==="assistant"&&ae.reasoning.trim()!=="")),q=ez(e,t.id),te=q.filter(ae=>ae.fromSession===t.id&&ae.callId===void 0&&(ae.state==="running"||ae.state==="waiting")),G=z===1,K=s.events.findLast(ae=>ae.type==="turn/start"),Z=s.running?o.findLast(ae=>ae.kind==="tool"&&ae.status==="running"&&ae.time>=((K==null?void 0:K.time)??0)):void 0,Y=h.some(ae=>ae.running)||q.some(ae=>ae.state==="running"||ae.state==="waiting"),Q=o.at(-1),ie=s.running&&s.events.some(ae=>ae.type==="user/message"&&ae.origin.kind==="subagent-settled"&&ae.seq>((K==null?void 0:K.seq)??0));let re;s.running&&(Z?Z.name!==wc&&Z.name!==eg&&(re=yS(Z)):!Y&&!((Q==null?void 0:Q.kind)==="assistant"&&Q.live&&Q.text.trim())&&(re=ie?"正在汇总子任务结果":"正在处理请求"));const ne=v.useRef(null),fe=bS(SD),Ee=fe.following,Ue=ae=>{fe.onScroll(ae),ae.currentTarget.scrollTop<40&&s.hasMore&&!s.loadingOlder&&t.loadOlder()};v.useLayoutEffect(()=>{const ae=ne.current;ae!==null&&Ee.current&&(ae.scrollTop=ae.scrollHeight)},[o,S,w]),Fz(ne,Ee);const Te=(Re=s.events[0])==null?void 0:Re.seq,pe=v.useRef(0);return v.useLayoutEffect(()=>{const ae=ne.current;ae!==null&&(pe.current!==0&&!Ee.current&&(ae.scrollTop+=ae.scrollHeight-pe.current),pe.current=ae.scrollHeight)},[Te]),n.jsx(Nc.Provider,{value:i?null:B,children:n.jsx(uh.Provider,{value:e,children:n.jsx(SS.Provider,{value:q,children:n.jsx(Vo.Provider,{value:U,children:n.jsx(xx.Provider,{value:(F==null?void 0:F.openTask)??H,children:n.jsx(px.Provider,{value:u,children:n.jsx(PS.Provider,{value:l,children:n.jsxs("div",{className:`chat-split ${T===null?"":"with-pane"}`,children:[(D||V!==null)&&n.jsxs("div",{className:"chat-corner",children:[V,D&&n.jsx(YD,{detail:P,onChange:R})]}),n.jsx("div",{className:"chat",ref:ne,onScroll:Ue,onWheel:fe.onWheel,children:n.jsxs("div",{className:"chat-inner",children:[w&&s.hasMore&&n.jsx("button",{className:"link-button load-older",disabled:s.loadingOlder,onClick:()=>void t.loadOlder(),children:s.loadingOlder?"加载中…":"加载更早的消息"}),!w&&n.jsx("div",{className:"empty",children:"正在打开会话…"}),w&&s.status!=="opening"&&o.length===0&&n.jsxs("div",{className:"empty chat-empty",children:[n.jsx(Xg,{size:"lg"}),n.jsx("h2",{children:"今天,先从哪个游戏开始?"}),n.jsxs("p",{children:["问问哪些活动快结束、新版本有什么,或者让它把今天的日常清掉。",n.jsx("br",{}),"在下方写下来就行。"]})]}),w&&L.map((ae,Fe)=>n.jsx(AD,{at:A[Fe],children:ae.kind==="sent"?n.jsx(wD,{client:e,notice:ae.item.notice},ae.item.id):ae.kind==="tools"?n.jsx(Ul,{name:U,header:ae.header,children:n.jsx(IS,{tools:ae.tools})},ae.id):ae.kind==="delegation"?n.jsx(Ul,{name:U,header:ae.header,children:n.jsx(rD,{client:e,item:ae.item,handOffs:q})},ae.item.id):ae.kind==="subtask"?n.jsx(Ul,{name:U,header:ae.header,children:n.jsx(tg,{client:e,work:ae.item,detailed:!G})},ae.item.id):ae.kind==="process"?n.jsx(Ul,{name:U,header:ae.header,children:n.jsx(zD,{items:ae.items,active:s.running&&Fe===L.length-1,onDismiss:ut=>t.dismissPending(ut)})},ae.id):n.jsx(Ul,{name:U,header:ae.header,children:n.jsx($S,{item:ae.item,showReasoning:!G,onDismiss:ut=>t.dismissPending(ut)})},ae.item.id)},ED(ae))),w&&te.map(ae=>n.jsx(aD,{client:e,handOff:ae},ae.id)),w&&(Z==null?void 0:Z.name)!==wc&&h.filter(ae=>ae.running&&!d.has(ae.id)).map(ae=>n.jsx(tg,{client:e,work:{id:ae.id,label:qo(ae.title??"")||"子任务"},detailed:!G},ae.id)),w&&!s.running&&s.queue.length>0&&n.jsx(nk,{label:`${s.queue.length} 条消息排队中`,tone:"waiting"}),w&&re&&n.jsx(nk,{label:re,tone:(Z==null?void 0:Z.approval)==="asked"||(Z==null?void 0:Z.name)==="ask_user_question"?"waiting":"running"}),w&&i!==!0&&!s.running&&s.queue.length===0&&n.jsx(yD,{session:t,title:s.title,items:o})]})}),T!==null&&F===null&&n.jsx(vx,{client:e,task:T,parent:U,trail:g===wn?[]:[cn.name],onClose:()=>H(null)},T.id)]})})})})})})})})}function ED(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 AD({at:e,children:t}){return n.jsxs(n.Fragment,{children:[e!==void 0&&n.jsx(wS,{at:e}),t]})}function CS(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=tw(e.item.text);return sw(e.item.text)!==void 0||nw(e.item.text)!==void 0||t!==void 0&&t.by!==Wg?2:1}}}function $D(e,t){if(t>1)return e;const s=[];let i=null;for(const r of e)r.kind==="sent"?s.push(r):CS(r)>1&&r.kind!=="subtask"&&r.kind!=="delegation"||r.kind==="item"&&r.item.kind==="assistant"&&!r.item.text.trim()&&!r.item.interrupted?i=r.header??i:r.kind==="item"&&r.item.kind==="user"?(i=null,s.push(r)):i!==null&&r.header===null&&!(r.kind==="item"&&(r.item.kind==="notice"||r.item.kind==="context"||r.item.kind==="fallback"))?(s.push({...r,header:i}),i=null):s.push(r);return s}function ID(e){const t=[];let s=0;for(let i=0;i<=e.length;i++){const r=e[i];r!==void 0&&r.kind!=="sent"&&!AS(r)||(TD(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 AS(e){return e.kind==="user"||e.kind==="context"&&e.startsTurn===!0}function TD(e,t){let s=!1;const i=e.find(p=>p.kind==="assistant"&&p.model!==void 0),r=()=>s?null:(s=!0,{model:(i==null?void 0:i.kind)==="assistant"?i.model:void 0}),o=p=>{if(p.kind==="tool"&&p.name===eg)t.push({kind:"delegation",item:p,header:r()});else if(p.kind==="tool"&&p.name===wc)t.push({kind:"subtask",item:p,header:r()});else if(p.kind==="tool"){const g=t.at(-1);(g==null?void 0:g.kind)==="tools"?t[t.length-1]={...g,tools:[...g.tools,p]}:t.push({kind:"tools",id:`tools-${p.id}`,tools:[p],header:r()})}else t.push({kind:"item",item:p,header:p.kind==="assistant"?r():null})};let l=[];const u=()=>{if(l.some(p=>p.kind==="tool"))t.push({kind:"process",id:`process-${l[0].id}`,items:l,header:r()});else for(const p of l)o(p);l=[]};let d=e.length;for(let p=e.length-1;p>=0;p--){const g=e[p];if(g.kind==="assistant"&&g.text.trim()!==""){d=p;break}}const h=new Set,m=new Map;e.forEach((p,g)=>{p.kind==="assistant"&&p.turn!==void 0&&p.text.trim()!==""&&m.set(p.turn,g)});for(const p of m.values())p<d&&h.add(p);for(let p=0;p<d;p++){const g=e[p];h.has(p)||g.kind==="notice"||g.kind==="context"||g.kind==="fallback"||g.kind==="tool"&&(g.approval==="asked"||g.name===eg||g.name===wc)?(u(),o(g)):l.push(g)}u();for(let p=d;p<e.length;p++)o(e[p])}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(Xg,{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 MD({text:e}){const t=nO(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 RD=/^(这条消息来自([^。)]+)。[^\n]*)\n/,OD=/^(距离这个对话的上一条消息已经过了[^\n]*)\n/;function PD(e){const t=RD.exec(e),s=(t===null?e:e.slice(t[0].length)).replace(OD,"");return t===null?{text:s}:{text:s,channel:t[1]}}const $S=v.memo(function({item:t,onDismiss:s,showReasoning:i=!0}){var u;const r=v.useContext(uh),o=v.useContext(SS),l=v.useContext(gx);switch(t.kind){case"user":{if(l!==null)return n.jsxs("div",{className:"msg user delegated",children:[n.jsxs("div",{className:"msg-from",children:[l,"交给的事"]}),n.jsxs("div",{className:"message-line",children:[n.jsx("div",{className:"bubble",children:n.jsx(Hs,{text:qo(t.text)})}),n.jsx(Of,{author:"助手",id:t.id,text:qo(t.text),canReply:!1})]})]});const d=t.pending===void 0?sw(t.text):void 0;if(d!==void 0&&r!==null)return n.jsx(oD,{client:r,note:d,handOffs:o});const h=t.pending===void 0?nw(t.text):void 0;if(h!==void 0&&r!==null)return n.jsx(lD,{client:r,note:h,handOffs:o});const m=t.pending===void 0?tw(t.text):void 0;if(m!==void 0&&r!==null)return n.jsx(cD,{client:r,note:m,handOffs:o});const p=PD(t.text),{body:g,quote:x}=cc(p.text);return n.jsxs("div",{className:`msg user ${t.pending===void 0?"":"pending"}`,children:[p.channel!==void 0&&n.jsxs("div",{className:"msg-from",children:["来自",p.channel]}),n.jsxs("div",{className:"message-line",children:[n.jsxs("div",{className:"bubble",children:[x&&n.jsx(fS,{quote:x}),n.jsx("div",{"data-reply-text":!0,children:n.jsx(MD,{text:g})}),t.imageRefs.length>0&&n.jsx("div",{className:"chat-images",children:t.imageRefs.map(k=>n.jsx(Uw,{image:k},k.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," 个文件"]})]})]}),g.trim()&&n.jsx(Of,{author:"用户",id:t.id,text:g,canReply:t.pending===void 0})]}),((u=t.pending)==null?void 0:u.failed)!==void 0&&n.jsxs("div",{className:"send-failed",children:["发送失败:",t.pending.failed,n.jsx("button",{className:"link-button",onClick:()=>s(t.pending.requestId),children:"移除"})]})]})}case"assistant":return!t.live&&f2(t.text)?n.jsxs("div",{className:"quiet-reply",children:[n.jsx(ee,{name:"check"}),"看过了,没有要告诉你的"]}):n.jsxs("div",{className:`msg assistant ${t.live?"live":""}`,children:[i&&t.reasoning.trim()!==""&&n.jsxs("details",{className:"reasoning",open:t.live&&t.text==="",children:[n.jsxs("summary",{children:[n.jsx(ee,{name:"chevron"}),t.live&&t.text===""?n.jsx("span",{className:"shimmer",children:"正在思考…"}):"思考过程"]}),n.jsx(Hs,{text:t.reasoning})]}),t.text!==""&&n.jsxs("div",{className:"message-line",children:[n.jsx("div",{"data-reply-text":!0,children:n.jsx(Hs,{text:t.text})}),!t.live&&t.text.trim()&&n.jsx(Of,{author:"助手",id:t.id,text:t.text})]}),t.live&&n.jsx("span",{className:"cursor"}),t.interrupted&&n.jsx("div",{className:"muted small",children:"(已中断)"})]});case"tool":return n.jsx(IS,{tools:[t]});case"context":return r&&"childId"in t&&typeof t.childId=="string"?n.jsx(tg,{client:r,work:{id:t.childId,label:t.summary},detailed:i}):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]});case"fallback":return n.jsx(LD,{item:t})}});function LD({item:e}){const{from:t,to:s,reason:i,error:r,code:o,sub:l}=e.notice,u=d=>n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"fallback-provider",children:d.providerName}),n.jsx("span",{className:"fallback-model",children:d.modelName})]});return n.jsxs("div",{className:"fallback-card",role:"status",children:[n.jsxs("div",{className:"fallback-head",children:[n.jsx(ee,{name:"swap"}),n.jsx("strong",{children:l===!0?"子 agent 已切换到备用模型":"已切换到备用模型"}),n.jsx("span",{className:"fallback-reason",children:i})]}),n.jsxs("div",{className:"fallback-routes",children:[n.jsx("span",{className:"fallback-route from",children:u(t)}),n.jsx(ee,{name:"arrow",className:"fallback-arrow"}),n.jsx("span",{className:"fallback-route to",children:u(s)})]}),n.jsxs("details",{className:"fallback-error",children:[n.jsx("summary",{children:"报错原文"}),n.jsx("pre",{children:r.trim()===""?o:`${r}
209
+ (${o})`})]}),n.jsxs("div",{className:"fallback-foot muted small",children:["这个对话接下来用 ",s.modelName,",可以在输入框旁的模型选择里换回来;备用顺序在 设置 → 模型 里改。"]})]})}function zD({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?DD(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(MS,{item:h},h.id):n.jsx("div",{className:"process-note",children:n.jsx($S,{item:h,onDismiss:s})},h.id))]})}function DD(e){return e.kind==="tool"?`${e.name} ${Gg(e.arguments)}`.trim():e.kind==="assistant"?e.text.trim().split(`
210
+ `)[0]||"正在思考…":""}function IS({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(MS,{item:l},l.id))]})}const TS={running:"运行中",ok:"完成",error:"失败",interrupted:"已中断"};function MS({item:e}){const[t,s]=v.useState(!1),i=v.useMemo(()=>Gg(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(FD,{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:UD(e.approval)}),n.jsx("span",{className:"tool-status",children:TS[e.status]})]}),e.images!==void 0&&n.jsx("div",{className:"chat-images tool-images",children:e.images.map(r=>n.jsx(Uw,{image:r},r.attachmentId))}),t&&n.jsxs("div",{className:"tool-body",children:[n.jsx("div",{className:"label",children:"参数"}),n.jsx("pre",{children:hx(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 FD({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":TS[e]??e,children:n.jsx(ee,{name:"info"})})}function UD(e){switch(e){case"asked":return"等待审批";case"allowed-once":return"已允许";case"rejected":return"已拒绝";case"cancelled":return"已撤回";default:return e}}const wc="subagent",RS=/started subagent (\S+)/;function OS(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 PS=v.createContext(new Map);function fx(e,t){if(e!==void 0)return t.get(e)??(/^agent-\d+$/.test(e)?void 0:e)}const BD=/\s*Your (?:parent agent\b|final answe)[\s\S]*$/;function qo(e){return e.replace(BD,"")}const HD=/^Background subagent (\S+) (finished|was stopped)?/;function LS(e,t,s=[]){const i=new Map;for(const r of e){if(!zS(r))continue;const o=HD.exec(r.summary);if(o===null)continue;const l=fx(o[1],t);l!==void 0&&i.set(l,o[2]==="finished"?Ko:o[2]==="was stopped"?dk:hk)}for(const r of s){if(r.type!=="unknown"||r.upstreamType!=="agent/inbox/spliced")continue;const o=r.data;for(const l of(o==null?void 0:o.inserted)??[]){const u=l.source;if((u==null?void 0:u.kind)!=="subagent-settled"||!u.senderSessionId||!u.stopReason)continue;const d=u.stopReason==="completed"?Ko:["aborted","interrupted"].includes(u.stopReason)?dk:hk;i.set(u.senderSessionId,{...d,at:r.time})}}return i}function zS(e){return e.kind==="context"&&e.title==="subagent-settled"}const px=v.createContext(new Map),gx=v.createContext(null),xx=v.createContext(()=>{});function DS(e){try{const t=JSON.parse(e);return{description:String(t.description??""),prompt:String(t.prompt??"")}}catch{return{description:"",prompt:e}}}function FS(e,t){return Se(e.sessions).items.find(s=>s.id===t)}const Go={label:"进行中",tone:"running"},Ko={label:"完成",tone:"ok"},dk={label:"已停止",tone:"failed"},hk={label:"没做成",tone:"failed"};function US(e){const t=Se(e.state);return{tools:v.useMemo(()=>rh(t.events,t.live,t.pending).filter(i=>i.kind==="tool"),[t.events,t.live,t.pending,t.version]),events:t.events}}function ZD({handle:e,label:t}){const{tools:s,events:i}=US(e),r=i.findLast(u=>u.type==="turn/start"),o=s.findLast(u=>u.status==="running"&&u.time>=((r==null?void 0:r.time)??0)),l=o&&yS(o);return l&&l!==t?n.jsx("span",{title:l,children:l}):Go.label}function BS({client:e,id:t,label:s}){const i=Fc(e,t);return i?n.jsx(ZD,{handle:i,label:s}):Go.label}function WD({client:e,id:t,running:s}){const i=Fc(e,t);return i?n.jsx(VD,{handle:i,running:s}):n.jsx("div",{className:"subtask-steps muted small",children:"正在打开…"})}function VD({handle:e,running:t}){const{tools:s}=US(e);if(s.length===0)return n.jsx("div",{className:"subtask-steps muted small",children:t?"正在开始…":"没有用工具"});const i=t?s.slice(-4):s;return n.jsx("ol",{className:"subtask-steps",children:i.map(r=>n.jsxs("li",{className:r.status==="error"?"failed":"",children:[r.status==="running"?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(ee,{name:r.status==="error"?"alert":"check"}),n.jsx("span",{className:"subtask-step-name",children:r.name}),n.jsx("span",{className:"subtask-step-args",children:Gg(r.arguments)})]},r.id))})}function HS({label:e,title:t,state:s,action:i,onOpen:r}){return n.jsxs("button",{type:"button",className:`exchange-line subtask-line tone-${s.tone}`,disabled:!r,title:t,onClick:r,children:[n.jsx(ee,{name:"flow"}),n.jsx("span",{className:"exchange-who",children:"子任务"}),n.jsx("span",{className:"exchange-title",children:e}),n.jsxs("span",{className:`delegation-state tone-${s.tone}`,"aria-live":"polite",children:[s.tone==="running"&&n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),n.jsx("span",{className:"subtask-activity",children:i??s.label})]}),r&&n.jsx(ee,{name:"chevron",className:"exchange-open"})]})}function tg({client:e,work:t,detailed:s=!1}){var O;const i=v.useContext(PS),r=v.useContext(px),o=v.useContext(xx),l="kind"in t?t:void 0,u=l&&DS(l.arguments),d="kind"in t?fx((O=RS.exec(t.result??""))==null?void 0:O[1],i):t.id,h=("label"in t?t.label:(u==null?void 0:u.description)||(u==null?void 0:u.prompt.split(`
211
+ `)[0]))||"子任务",m=FS(e,d),p=Se(e.approvals).some(B=>B.sessionId===d),g=Se(e.questions).some(B=>B.sessionId===d),x=d?r.get(d):void 0,k=(l==null?void 0:l.status)==="error"||(l==null?void 0:l.status)==="interrupted",b=x&&(!(m!=null&&m.running)||x.at!==void 0&&m.updatedAt<=x.at);let j;k?j={label:l.status==="error"?"派发失败":"派发已中断",tone:"failed"}:b?j=x:p||g?j={label:p?"等待你批准操作":"等待你回答问题",tone:"waiting"}:m!=null&&m.running?j=Go:m&&!m.blank?j=Ko:j={label:d?"已派发":"正在派发子任务",tone:"running"};const w=!!(m!=null&&m.running)&&!b&&!k,S=dx(e,s&&m&&!w&&!k?[m]:[]),_=d&&S.get(d),[E,M]=v.useState(!1);return n.jsxs("div",{className:"delegation task-line",children:[n.jsx(HS,{label:h,title:(u==null?void 0:u.prompt)||h,state:j,onOpen:d?()=>o({id:d,label:h}):void 0,action:m&&j===Go?n.jsx(BS,{client:e,id:m.id,label:h}):void 0}),k&&n.jsxs("div",{className:"delegation-failed",children:[n.jsx(ee,{name:"alert"}),l.result||l.error||j.label]}),s&&d&&(w||E)&&n.jsx(WD,{client:e,id:d,running:w}),s&&_&&n.jsx("div",{className:"subtask-answer",children:n.jsx(Hs,{text:_})}),s&&!w&&!k&&d&&n.jsxs("button",{className:"link-button subtask-fold","aria-expanded":E,onClick:()=>M(B=>!B),children:[n.jsx(ee,{name:E?"chevron-down":"chevron"}),E?"收起步骤":"看步骤"]})]})}function vx({client:e,task:t,parent:s,trail:i,onClose:r}){const o=Fc(e,t.id),l=FS(e,t.id),[u,d]=v.useState(null),h=(l==null?void 0:l.running)===!0,m=()=>e.connection.call("subagents/stop",{sessionId:t.id}).then(()=>d(null),p=>d(p instanceof Error?p.message:String(p)));return n.jsxs("aside",{className:"subagent-pane","aria-label":`子任务:${t.label}`,children:[n.jsxs("header",{className:"subagent-pane-head",children:[n.jsxs("div",{className:"subagent-trail",children:[[...i,s].map((p,g)=>n.jsxs("span",{children:[p,n.jsx("span",{className:"subagent-trail-sep",children:"›"})]},g)),n.jsx("strong",{title:t.label,children:t.label})]}),h&&n.jsxs("button",{className:"small-button",onClick:()=>void m(),children:[n.jsx(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(qD,{client:e,handle:o,parent:s})})]})}function qD({client:e,handle:t,parent:s}){const i=Se(t.state);return n.jsx(gx.Provider,{value:s,children:n.jsx(Vo.Provider,{value:`${s}的子 agent`,children:n.jsx(ES,{client:e,session:t,state:i,readOnly:!0})})})}const mk="adg.chatDetail.";function GD(e){const t=()=>{try{return Number(localStorage.getItem(mk+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(mk+e,String(o))}catch{}}]}const KD=[{level:1,label:"汇报",hint:"只看它和你说的话"},{level:3,label:"全部",hint:"加上 agent 之间的往来和子任务的步骤、答案"}];function YD({detail:e,onChange:t}){return n.jsx("div",{className:"chat-detail segmented-control",role:"radiogroup","aria-label":"显示多少",children:KD.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 ZS(e,t){var i;const s=new Map;for(const r of e){if(r.kind==="context"&&"childId"in r&&typeof r.childId=="string"&&s.set(r.childId,r.summary),r.kind!=="tool"||r.name!==wc)continue;const o=fx((i=RS.exec(r.result??""))==null?void 0:i[1],t);if(o===void 0)continue;const{description:l,prompt:u}=DS(r.arguments),d=l!==""?l:u.split(`
212
+ `)[0]??"";s.set(o,d||"子任务")}return s}function WS(e,t){const s=Se(e.sessions).items;return v.useMemo(()=>s.filter(i=>i.origin==="subagent"&&i.parentId===t),[s,t])}function VS(e,t,s,i){return e.origin==="subagent"&&e.parentId===t&&e.updatedAt>=s&&(i===void 0||e.updatedAt<=i+2e3)}function XD(e,t){const s=Se(e.sessions).items;return v.useMemo(()=>s.filter(i=>t.some(r=>VS(i,r.toSession,r.startedAt,r.endedAt))),[s,t])}const Uf=30;function qS({tasks:e,labels:t,current:s,onOpen:i}){const r=v.useContext(px),[o,l]=v.useState(!1),u=v.useRef(null),d=vn(6e4);v.useEffect(()=>{if(!o)return;const b=w=>{var S;(S=u.current)!=null&&S.contains(w.target)||l(!1)},j=w=>{w.key==="Escape"&&l(!1)};return document.addEventListener("pointerdown",b),document.addEventListener("keydown",j),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("keydown",j)}},[o]);const h=[...e].sort((b,j)=>j.updatedAt-b.updatedAt),m=h.filter(b=>b.running),p=h.filter(b=>!b.running);if(e.length===0)return null;const g=b=>t.get(b.id)??(qo(b.title??"")||"子任务"),x=b=>{const j=b.running?Go:r.get(b.id)??Ko,w=g(b);return n.jsx("li",{children:n.jsxs("button",{className:`subtask-tracker-row ${b.id===s?"active":""}`,title:w,onClick:()=>{l(!1),i({id:b.id,label:w})},children:[b.running?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(ee,{name:j===Ko?"check":"alert",className:`tone-${j.tone}`}),n.jsx("span",{className:"subtask-tracker-label",children:w}),n.jsx("span",{className:`delegation-state tone-${j.tone}`,children:b.running?j.label:`${j.label} · ${vt(b.updatedAt,d)}`}),n.jsx(ee,{name:"chevron",className:"exchange-open"})]})},b.id)},k=m.length>0?`${m.length} 个子任务在跑`:"子任务";return n.jsxs("div",{ref:u,className:"subtask-tracker",children:[n.jsxs("button",{type:"button",className:`subtask-tracker-toggle ${m.length>0?"tone-running":""}`,"aria-haspopup":"dialog","aria-expanded":o,title:`进行中 ${m.length} 个,已结束 ${p.length} 个;点开看每一个的窗口`,onClick:()=>l(b=>!b),children:[m.length>0?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(ee,{name:"flow"}),n.jsx("span",{children:k}),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:m.length})]}),m.length===0?n.jsx("p",{className:"muted small subtask-tracker-empty",children:"现在没有在跑的子任务"}):n.jsx("ul",{children:m.map(x)})]}),p.length>0&&n.jsxs("section",{children:[n.jsxs("div",{className:"subtask-tracker-head",children:["已结束",n.jsx("span",{className:"skills-count",children:p.length})]}),n.jsx("ul",{children:p.slice(0,Uf).map(x)}),p.length>Uf&&n.jsxs("p",{className:"muted small subtask-tracker-empty",children:["更早的 ",p.length-Uf," 个在对话里"]})]})]})]})}function QD({client:e,session:t,from:s,to:i,onOpen:r}){const o=Se(e.sessions).items.filter(l=>VS(l,t,s,i));return o.length===0?null:n.jsx("div",{className:"delegation thread-subtasks",children:o.map(l=>{const u=qo(l.title??"")||"子任务",d=l.running?Go:Ko;return n.jsx(HS,{label:u,title:u,state:d,onOpen:()=>r({id:l.id,label:u}),action:l.running?n.jsx(BS,{client:e,id:l.id,label:u}):void 0},l.id)})})}const GS=[{id:"tasks",icon:"list",title:"子任务",hint:"子任务:正在做和做完的,点开看每一个的对话"},{id:"commands",icon:"terminal",title:"命令",hint:"命令:这个对话和它的子任务运行的命令和程序"},{id:"browser",icon:"globe",title:"浏览器",hint:"内置浏览器:看 agent 操作网页,也可以自己接手"}];function fk({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 JD={label:"进行中",tone:"running"},pk={label:"完成",tone:"ok"};function KS(e,t){return t.get(e.id)??(qo(e.title??"")||"子任务")}function e3({tasks:e,labels:t,settled:s,onOpen:i}){const r=vn(6e4),o=[...e].sort((h,m)=>m.updatedAt-h.updatedAt),l=o.filter(h=>h.running),u=o.filter(h=>!h.running),d=h=>{const m=h.running?JD:s.get(h.id)??pk,p=KS(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:m===pk?"check":"alert",className:`tone-${m.tone}`}),n.jsx("span",{className:"subtask-tracker-label",children:p}),n.jsx("span",{className:`delegation-state tone-${m.tone}`,children:h.running?m.label:`${m.label} · ${vt(h.updatedAt,r)}`}),n.jsx(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 t3=new Set(["pwsh","bash","run_code"]);function n3(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 YS(e){return e.filter(t=>t.kind==="tool"&&t3.has(t.name))}function s3({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,Bf),[s]);return n.jsxs("div",{className:"side-list commands",children:[r.map(o=>n.jsx(i3,{client:e,task:o,label:KS(o,i)},o.id)),n.jsx(yx,{title:"这个对话",running:!1,commands:t,empty:"这个对话自己没有运行命令(命令多由子任务运行)"}),s.length>Bf&&n.jsxs("p",{className:"muted small side-note",children:["更早的 ",s.length-Bf," 个子任务的命令在它们的对话里(子任务面板)"]})]})}const Bf=8;function i3({client:e,task:t,label:s}){const i=Fc(e,t.id);return i===null?n.jsx(yx,{title:s,running:t.running,commands:[],empty:"正在打开…"}):n.jsx(r3,{handle:i,label:s,running:t.running})}function r3({handle:e,label:t,running:s}){const i=Se(e.state),r=v.useMemo(()=>YS(rh(i.events,i.live,i.pending)),[i.events,i.live,i.pending,i.version]);return r.length===0&&!s?null:n.jsx(yx,{title:t,running:s,commands:r,empty:"还没有运行命令"})}function yx({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(a3,{item:u},u.id))}))]})}function a3({item:e}){const{text:t,description:s,program:i}=n3(e),[r,o]=v.useState(e.status==="error"),l=vn(e.status==="running"?1e3:6e4),u=(e.result??e.error??"").trimEnd();return n.jsxs("li",{className:`command-row status-${e.status}`,children:[n.jsxs("div",{className:"command-row-head",children:[e.status==="running"?n.jsx("span",{className:"tool-spinner","aria-hidden":!0}):n.jsx(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))} 秒`:vt(e.time,l)})]}),n.jsxs("pre",{className:"command-text",children:[n.jsx("span",{className:"command-prompt",children:i?"ts":e.name==="bash"?"$":"PS>"}),t]}),u!==""&&n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"link-button command-output-toggle",onClick:()=>o(!r),children:r?"收起输出":"看输出"}),r&&n.jsx("pre",{className:"command-output",children:u.length>gk?`…
213
+ ${u.slice(-gk)}`:u})]})]})}const gk=6e3,Hf=new Map;function XS(e,t){let s=Hf.get(t);return s===void 0&&(s=e.connection.call("games/image",{url:t}).then(i=>`data:${i.mediaType};base64,${i.data}`),s.catch(()=>Hf.delete(t)),Hf.set(t,s)),s}function QS(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 XS(e,l).catch(()=>{});if(u!==void 0){o&&i(u);return}}})(),()=>{o=!1}},[e,r.join(`
214
+ `)]),s}function oa(e,t){const[s,i]=v.useState(void 0);return v.useEffect(()=>{if(i(void 0),t===void 0)return;let r=!0;return XS(e,t).then(o=>{r&&i(o)},()=>{}),()=>{r=!1}},[e,t]),s}const bx=["image/png","image/jpeg","image/gif","image/webp","image/avif"],o3=8*1024*1024;function ng(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 l3(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 xk(e,t){return e===void 0?"":new Date(e+ng(e,t)).toISOString().slice(0,16)}function vk(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-ng(i-ng(i,t),t)}function JS(e){return new Promise((t,s)=>{if(!bx.includes(e.type)){s(new Error("只支持 png、jpg、gif、webp、avif 图片"));return}if(e.size>o3){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 kx({client:e,game:t,activity:s,onDone:i,onCancel:r}){var R;const o=t.timezone,l={name:(s==null?void 0:s.name)??"",kind:(s==null?void 0:s.kind)??"",startsAt:xk(s==null?void 0:s.startsAt,o),endsAt:xk(s==null?void 0:s.endsAt,o),url:(s==null?void 0:s.url)??"",description:(s==null?void 0:s.description)??""},[u,d]=v.useState(l),[h,m]=v.useState(null),[p,g]=v.useState(!1),[x,k]=v.useState(!1),[b,j]=v.useState(null),w=v.useRef(null),S=((R=s==null?void 0:s.own)==null?void 0:R.fields.includes("cover"))===!0,_=oa(e,p||s==null?void 0:s.cover),E=(h==null?void 0:h.src)??_,M=s!==void 0&&(s.sources!==void 0||s.screen!==void 0);v.useEffect(()=>{j(null)},[u]);const O=z=>L=>d(A=>({...A,[z]:L.target.value})),B=z=>{z!==void 0&&JS(z).then(L=>{m(L),g(!1)},L=>j(Ce(L)))},U=z=>{const L=[...z.clipboardData.files].find(A=>A.type.startsWith("image/"));L!==void 0&&(z.preventDefault(),B(L))},P=async()=>{if(u.name.trim()===""){j("活动要有名字");return}const z=u.startsAt===""?null:vk(u.startsAt,o)??null,L=u.endsAt===""?null:vk(u.endsAt,o)??null;if(z!==null&&L!==null&&L<=z){j("结束时间要晚于开始时间");return}const A=F=>s===void 0||u[F]!==l[F],T=F=>A(F)?{[F]:u[F].trim()===""?null:u[F].trim()}:{},H={game:t.id,...s===void 0?{}:{activityId:s.id},...T("name"),...T("kind"),...T("url"),...T("description"),...A("startsAt")?{startsAt:z}:{},...A("endsAt")?{endsAt:L}:{},...h!==null?{image:h.image}:p?{cover:null}:{}};k(!0),j(null);try{i(await e.connection.call("games/activity/save",H))}catch(F){j(Ce(F))}finally{k(!1)}};return n.jsxs("form",{className:"activity-editor",onSubmit:z=>{z.preventDefault(),P()},onPaste:U,onKeyDown:z=>{z.key==="Escape"&&r()},children:[n.jsxs("div",{className:"activity-editor-head",children:[n.jsx("strong",{children:s===void 0?`添加${t.name}的活动`:"编辑活动"}),M&&n.jsx("span",{className:"muted small",children:"你改的内容比数据站优先,刷新不会改掉;没改的照来源走。"})]}),n.jsxs("div",{className:"activity-editor-body",children:[n.jsxs("div",{className:"activity-editor-image",children:[n.jsx("button",{type:"button",className:`activity-image-pick ${E===void 0?"empty":""}`,onClick:()=>{var z;return(z=w.current)==null?void 0:z.click()},title:"选一张图片(也可以直接粘贴)",children:E!==void 0?n.jsx("img",{src:E,alt:""}):n.jsxs(n.Fragment,{children:[n.jsx(ee,{name:"image"}),n.jsx("span",{children:"选图片"}),n.jsx("small",{children:"或粘贴"})]})}),n.jsx("input",{ref:w,type:"file",accept:bx.join(","),hidden:!0,onChange:z=>{var L;B((L=z.target.files)==null?void 0:L[0]),z.target.value=""}}),n.jsxs("div",{className:"activity-image-tools",children:[n.jsx("span",{className:"muted small",children:E===void 0?"点上面选图,或直接粘贴":"点图片换一张,或直接粘贴"}),(h!==null||S&&!p)&&n.jsx("button",{type:"button",className:"link-button small muted",onClick:()=>{m(null),S&&g(!0)},children:h!==null?"不用这张":M?"用回来源的图":"去掉图片"})]})]}),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:O("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:O("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:O("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:O("endsAt")})]})]}),n.jsxs("span",{className:"muted small",children:["时间按游戏服务器时间(",l3(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:O("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:O("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:"取消"}),b!==null&&n.jsx("span",{className:"tone-error small",children:b})]})]})}async function hh(e,t){const s=Vs();if(s!==void 0){const{kind:r,...o}=t;return s.pickFile({...o,folder:r==="folder"})}const{path:i}=await e.connection.call("files/pick",{kind:t.kind,...t.title===void 0?{}:{title:t.title},...t.defaultPath===void 0||t.defaultPath===""?{}:{defaultPath:t.defaultPath},...t.filterName===void 0?{}:{filterName:t.filterName},...t.extensions===void 0?{}:{extensions:t.extensions}});return i??null}const c3={update:"版本更新",notice:"公告",news:"资讯"};function e1({notice:e,now:t}){const s=e.publishedAt===void 0?void 0:t-e.publishedAt;return n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"badge","data-notice-kind":e.kind,children:c3[e.kind]}),e.version&&n.jsx("span",{className:"notice-version",children:e.version}),e.lasting&&n.jsx("span",{className:"badge",title:"长期有效的公告",children:"长期"}),s!==void 0&&s>=0&&s<3*864e5&&n.jsx("span",{className:"badge ok",children:"新"})]})}function yk({client:e,url:t,title:s}){const i=oa(e,t);return i?n.jsx("img",{src:i,alt:s+" 配图"}):null}function u3({client:e,notice:t,now:s,color:i,onClose:r}){var j,w;const[o,l]=v.useState(),[u,d]=v.useState(!1),[h,m]=v.useState(0);v.useEffect(()=>{let S=!0;return d(!1),e.connection.call("games/notice/detail",{game:t.game,noticeId:t.id}).then(_=>{S&&l(_)},()=>{S&&d(!0)}),()=>{S=!1}},[e,t.game,t.id,h]);const p=((j=o==null?void 0:o.summary)==null?void 0:j.trim())||((w=t.summary)==null?void 0:w.trim()),g=o==null?void 0:o.article,x=(o==null?void 0:o.cover)??t.cover,k=t.url&&/^https?:\/\//i.test(t.url)?t.url:void 0,b=t.publishedAt&&new Date(t.publishedAt).toLocaleDateString("zh-CN");return n.jsxs(dc,{label:t.title,color:i,onClose:r,className:"notice-dialog",children:[n.jsxs("header",{className:"dialog-head",children:[n.jsxs("div",{className:"dialog-title",children:[n.jsx("h3",{children:t.title}),n.jsxs("div",{className:"dialog-meta",children:[n.jsx(e1,{notice:t,now:s}),n.jsx("span",{children:[t.source.name,b].filter(Boolean).join(" · ")})]})]}),k&&n.jsx("a",{className:"small-button notice-original",href:k,target:"_blank",rel:"noreferrer",children:"查看原文"}),n.jsx("button",{className:"dialog-close","aria-label":"关闭",onClick:r,children:n.jsx(ee,{name:"close"})})]}),n.jsxs("article",{className:"notice-article",children:[p&&n.jsxs("section",{className:"notice-abstract",children:[n.jsx("h4",{children:"摘要"}),n.jsx("p",{children:p})]}),x&&!(g!=null&&g.some(S=>S.type==="image"&&S.url===x))&&n.jsx(yk,{client:e,url:x,title:t.title},x),g!=null&&g.length?g.map((S,_)=>S.type==="image"?n.jsx(yk,{client:e,url:S.url,title:t.title},_+S.url):n.jsx("p",{children:S.text},_)):n.jsxs("p",{className:"muted small",role:"status",children:[u?"正文暂时无法加载。":o?"这条记录尚未收录正文。":"正在读取正文…",u&&n.jsx("button",{className:"link-button small",onClick:()=>m(S=>S+1),children:"重试"})]})]})]})}const ai=864e5,bk={name:"名字",startsAt:"开始时间",endsAt:"结束时间",kind:"类型",description:"说明",url:"页面",cover:"图片"},Zf=2,d3=28,Xr=["#3b82c4","#c0567d","#2f9e7a","#c98a1b","#7a62d6","#d2643c","#4d9a3c","#2a93a8","#a86bb8","#8a7a3a"],kk="adg:games:overview:shown",jk="adg:games:overview:mode";function Nk(e,t){try{const s=localStorage.getItem(e);return s===null?t:JSON.parse(s)}catch{return t}}function wk(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 h3(e,t){return new Date(e).toLocaleDateString("zh-CN",{timeZone:t,month:"numeric",day:"numeric"})}function kd(e,t){const s=e-t;return s<=0?"已结束":s<ai?`${Math.max(1,Math.floor(s/36e5))} 小时`:`${Math.floor(s/ai)} 天`}function m3({client:e,games:t,activities:s,now:i,soonDays:r,onOpenGame:o,onChanged:l}){const[u,d]=v.useState(()=>Nk(kk,null)),[h,m]=v.useState(()=>Nk(jk,"time")),[p,g]=v.useState(null);v.useEffect(()=>wk(kk,u),[u]),v.useEffect(()=>wk(jk,h),[h]);const x=v.useMemo(()=>new Map(t.map((L,A)=>[L.id,Xr[A%Xr.length]])),[t]),k=L=>u===null||u.includes(L),b=L=>d(A=>{const T=A??t.map(F=>F.id),H=T.includes(L)?T.filter(F=>F!==L):[...T,L];return H.length===t.length?null:H}),j=new Date(i-Zf*ai).setHours(0,0,0,0),w=j+(Zf+d3)*ai,S=L=>Math.min(100,Math.max(0,(L-j)/(w-j)*100)),_=s.filter(L=>k(L.game)&&(L.endsAt===void 0||Math.max(L.endsAt,L.shopEndsAt??0)>i)),E=(L,A)=>(L.endsAt??1/0)-(A.endsAt??1/0)||L.name.localeCompare(A.name),M=_.filter(L=>(L.startsAt??0)<=i),O=_.filter(L=>L.startsAt!==void 0&&L.startsAt>i).sort((L,A)=>L.startsAt-A.startsAt),B=[];if(h==="time"){const L=j+(Zf+7)*ai,A=M.filter(F=>F.endsAt!==void 0&&F.endsAt-i<r*ai).sort(E),T=M.filter(F=>!A.includes(F)&&F.endsAt!==void 0&&F.endsAt<L).sort(E),H=M.filter(F=>!A.includes(F)&&!T.includes(F)).sort(E);B.push({key:"soon",title:"快结束",hint:`${r} 天内`,rows:A},{key:"week",title:"本周内结束",rows:T},{key:"later",title:"之后结束",rows:H},{key:"upcoming",title:"即将开始",rows:O})}else for(const L of t){if(!k(L.id))continue;const A=[...M.filter(T=>T.game===L.id).sort(E),...O.filter(T=>T.game===L.id)];B.push({key:L.id,title:L.name,rows:A,game:L})}const U=M.reduce((L,A)=>{const T=ms(A);return{...L,[T.state]:L[T.state]+1}},{finished:0,partial:0,unknown:0}),P=M.filter(L=>L.endsAt!==void 0&&L.endsAt-i<r*ai&&ms(L).state!=="finished").length,R=[];for(let L=j;L<=w;L+=ai){const A=Math.round((L-new Date(i).setHours(0,0,0,0))/ai);R.push({at:L,...A>0&&A%7===0?{label:h3(L,Intl.DateTimeFormat().resolvedOptions().timeZone)}:{}})}const z=L=>s.filter(A=>A.game===L&&(A.startsAt??0)<=i&&(A.endsAt===void 0||Math.max(A.endsAt,A.shopEndsAt??0)>i));return n.jsxs("div",{className:"games-overview",children:[n.jsx("div",{className:"game-tiles",role:"group","aria-label":"各游戏",children:t.map(L=>{const A=z(L.id);return n.jsx(f3,{client:e,game:L,color:x.get(L.id)??Xr[0],now:i,shown:k(L.id),running:A.length,soon:A.filter(T=>T.endsAt!==void 0&&T.endsAt-i<r*ai&&ms(T).state!=="finished").length,covers:A.map(T=>T.cover).filter(T=>(T==null?void 0:T.startsWith("shot:"))!==!0).slice(0,6),onOpen:()=>o(L.id),onToggle:()=>b(L.id)},L.id)})}),n.jsxs("section",{className:"card games-overview-board",children:[n.jsxs("div",{className:"ov-toolbar",children:[n.jsxs("div",{className:"ov-stats",children:[n.jsx(Bl,{value:M.length,label:"进行中"}),n.jsx(Bl,{value:P,label:"快结束未做完",tone:P>0?"warn":void 0}),n.jsx(Bl,{value:U.finished,label:"做完"}),n.jsx(Bl,{value:U.partial,label:"做了一部分"}),n.jsx(Bl,{value:U.unknown,label:"没记录"})]}),n.jsxs("div",{className:"segmented-control ov-mode",role:"group","aria-label":"排序",children:[n.jsx("button",{className:h==="time"?"active":"","aria-pressed":h==="time",onClick:()=>m("time"),children:"按时间"}),n.jsx("button",{className:h==="game"?"active":"","aria-pressed":h==="game",onClick:()=>m("game"),children:"按游戏"})]})]}),n.jsxs("div",{className:"ov-grid",children:[n.jsx("div",{className:"ov-lines","aria-hidden":"true",children:R.filter(L=>L.label!==void 0).map(L=>n.jsx("i",{style:{left:`${S(L.at)}%`}},L.at))}),n.jsxs("div",{className:"ov-row ov-axis","aria-hidden":"true",children:[n.jsx("div",{className:"ov-label"}),n.jsxs("div",{className:"ov-track",children:[R.map(L=>n.jsx("span",{className:`ov-tick ${L.label!==void 0?"major":""}`,style:{left:`${S(L.at)}%`},children:L.label!==void 0&&n.jsx("em",{children:L.label})},L.at)),n.jsx("span",{className:"ov-today-label",style:{left:`${S(i)}%`},children:"今天"})]}),n.jsx("div",{className:"ov-side"})]}),B.every(L=>L.rows.length===0)&&n.jsxs("div",{className:"empty",children:[n.jsx(ee,{name:"timeline"}),n.jsx("p",{children:t.length===0?"没有游戏。":"显示的游戏现在没有活动。点「刷新全部」读取,或点上面游戏卡片的眼睛多显示几个。"})]}),B.filter(L=>L.rows.length>0).map(L=>{var A;return n.jsxs("div",{className:`ov-section ${L.key==="soon"?"warn":""} ${L.game!==void 0?"by-game":""}`,style:L.game===void 0?void 0:{"--game":x.get(L.game.id)},children:[n.jsxs("div",{className:"ov-section-title",children:[L.game!==void 0&&n.jsx("span",{className:"game-dot"}),n.jsx("span",{className:"ov-section-name",children:L.title}),n.jsx("span",{className:"ov-section-count",children:L.rows.length}),L.hint!==void 0&&n.jsx("span",{className:"muted small",children:L.hint}),((A=L.game)==null?void 0:A.version)!==void 0&&n.jsxs("span",{className:"muted small ov-section-version",children:[L.game.version.name,L.game.version.title===void 0?"":`「${L.game.version.title}」`]}),L.game!==void 0&&n.jsxs("button",{className:"link-button small ov-section-open",onClick:()=>o(L.game.id),children:["打开",n.jsx(ee,{name:"chevron"})]})]}),L.rows.map(T=>{const H=t.find(F=>F.id===T.game);return n.jsx(p3,{client:e,activity:T,game:H,color:x.get(T.game)??Xr[0],showGame:h==="time",now:i,soonDays:r,x:S,open:p===T.id,onToggle:()=>g(F=>F===T.id?null:T.id),onOpenGame:()=>o(T.game),onChanged:l},T.id)})]},L.key)}),n.jsx("div",{className:"ov-today",style:{left:`calc(var(--ov-label) + (100% - var(--ov-label) - var(--ov-side)) * ${S(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 f3({client:e,game:t,color:s,covers:i,now:r,running:o,soon:l,shown:u,onOpen:d,onToggle:h}){const m=t.version,p=QS(e,[t.banner,m==null?void 0:m.cover,t.art,...i]),g=(m==null?void 0:m.endsAt)!==void 0&&m.endsAt>r?` · 还剩 ${kd(m.endsAt,r)}`:"";return n.jsxs("article",{className:`game-tile ${p===void 0?"no-art":""} ${u?"":"off"}`,style:{"--game":s},children:[p!==void 0&&n.jsx("img",{className:"game-tile-art",src:p,alt:""}),n.jsx("span",{className:"game-tile-shade"}),n.jsxs("button",{className:"game-tile-open",title:`打开${t.name}`,onClick:d,children:[n.jsxs("span",{className:"game-tile-name",children:[n.jsx("span",{className:"game-dot"}),t.name]}),n.jsx("span",{className:"game-tile-version",children:m===void 0?"没有版本信息":`${m.name}${m.title===void 0?"":`「${m.title}」`}${g}`}),n.jsxs("span",{className:"game-tile-counts",children:[n.jsxs("span",{children:[n.jsx("b",{children:o})," 进行中"]}),l>0&&n.jsxs("span",{className:"soon",children:[n.jsx("b",{children:l})," 快结束"]})]})]}),n.jsx("button",{className:"game-tile-eye","aria-pressed":u,"aria-label":`在时间线上显示${t.name}`,title:u?"在时间线上隐藏":"在时间线上显示",onClick:h,children:n.jsx(ee,{name:u?"eye":"eye-off"})})]})}function p3({client:e,activity:t,game:s,color:i,showGame:r,now:o,soonDays:l,x:u,open:d,onToggle:h,onOpenGame:m,onChanged:p}){const g=ms(t),x=(t.startsAt??0)<=o,k=t.endsAt,b=x&&k!==void 0&&k-o<l*ai&&g.state!=="finished",j=u(t.startsAt??o-30*ai),w=k===void 0?100:u(k),S=t.shopEndsAt===void 0||k===void 0||t.shopEndsAt<=k?void 0:u(t.shopEndsAt),_=oa(e,t.cover);return n.jsxs("div",{className:`ov-item ${d?"open":""}`,style:{"--game":i},children:[n.jsxs("button",{className:`ov-row ${b?"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:_!==void 0&&n.jsx("img",{src:_,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":""} ${k===void 0||w>=100?"cut-right":""}`,style:{left:`${j}%`,width:`${Math.max(1.2,w-j)}%`},children:g.total>0&&n.jsx("span",{className:"ov-bar-done",style:{width:`${g.done/g.total*100}%`}})}),S!==void 0&&n.jsx("span",{className:"ov-shop",style:{left:`${w}%`,width:`${Math.max(.6,S-w)}%`},title:"之后只开商店"})]}),n.jsxs("div",{className:"ov-side",children:[n.jsx("span",{className:`ov-left ${b?"tone-warn":""}`,children:x?k===void 0?"时间未知":k<=o&&t.shopEndsAt!==void 0?`商店 ${kd(t.shopEndsAt,o)}`:kd(k,o):`${kd(t.startsAt,o)}后开始`}),n.jsx(jx,{progress:g})]})]}),d&&n.jsx(x3,{client:e,activity:t,game:s,onOpenGame:m,onChanged:p})]})}function jx({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 g3({activity:e,game:t,chosen:s,onChoose:i}){const r=vn(6e4),o=e.sources??(e.site===void 0?[]:[{id:e.site.source,name:e.site.name,at:e.site.at,web:!1,startsAt:void 0,endsAt:void 0,cover:void 0}]);if(o.length===0&&e.screen===void 0&&e.own===void 0)return null;const l=(t==null?void 0:t.timezone)??"Asia/Shanghai",u=x=>new Date(x).toLocaleString("zh-CN",{timeZone:l,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),d=x=>`${x.startsAt===void 0&&x.endsAt===void 0?"没有时间":`${x.startsAt===void 0?"?":u(x.startsAt)} – ${x.endsAt===void 0?"?":u(x.endsAt)}`},${x.cover===void 0?"没有图片":"有图片"}`,h=x=>i(s===x?null:x),m=o.length===0&&e.screen===void 0,p=e.own!==void 0&&(e.own.startsAt!==void 0||e.own.endsAt!==void 0||e.own.cover!==void 0),g=e.screen!==void 0&&(e.screen.endsAt!==void 0||e.screen.image!==void 0);return n.jsxs("div",{className:"activity-sources",children:[n.jsx("span",{className:"muted small",children:"来源"}),o.map(x=>{var k;return n.jsxs("button",{className:`fact-chip ${x.web?"web":"site"} ${s===x.id?"on":""}`,"aria-pressed":s===x.id,title:`${d(x)}。点一下用它的图片和时间`,onClick:()=>h(x.id),children:[x.name,n.jsxs("small",{children:[x.web?"网页":"数据站"," · ",vt(x.at,r)]}),o.length>1&&((k=e.shown)==null?void 0:k.endsAt)===x.id&&n.jsx("small",{className:"fact-main",children:"时间以它为准"})]},x.id)}),e.screen!==void 0&&n.jsxs("button",{className:`fact-chip screen ${s===oc?"on":""}`,"aria-pressed":s===oc,disabled:!g,title:`agent 进游戏看到的。${d({endsAt:e.screen.endsAt,cover:e.screen.image})}`,onClick:()=>h(oc),children:["游戏画面",n.jsxs("small",{children:["agent 看过 · ",vt(e.screen.at,r)]})]}),e.own!==void 0&&n.jsxs("button",{className:`fact-chip own ${s===$o?"on":""}`,"aria-pressed":s===$o,disabled:!p||m,title:m?"你自己添加的活动":`你改过:${e.own.fields.map(x=>bk[x]).join("、")};比来源优先,刷新不会改掉`,onClick:()=>h($o),children:[m?"我添加的":"我改过",n.jsxs("small",{children:[m?"":`${e.own.fields.map(x=>bk[x]).join("、")} · `,vt(e.own.at,r)]})]}),s!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>i(null),children:"恢复默认"})]})}function x3({client:e,activity:t,game:s,onOpenGame:i,onChanged:r,openSession:o}){var T,H;const[l,u]=v.useState(null),[d,h]=v.useState(!1),[m,p]=v.useState(""),[g,x]=v.useState(!1),[k,b]=v.useState(null),[j,w]=v.useState(void 0);v.useEffect(()=>w(void 0),[t]);const S=j??t,[_,E]=v.useState(void 0);v.useEffect(()=>E(void 0),[S.chosen]);const M=F=>{E(F),b(null),e.connection.call("games/activity/source",{activityId:S.id,source:F}).then(V=>{w(V),r()},V=>{E(void 0),b(Ce(V))})},O=(s==null?void 0:s.timezone)??"Asia/Shanghai",B=F=>new Date(F).toLocaleString("zh-CN",{timeZone:O,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),U=async F=>{x(!0),b(null);try{await e.connection.call("games/activity/progress",{activityId:S.id,...F}),r()}catch(V){b(Ce(V))}finally{x(!1)}},P=F=>void U({todo:S.todo.filter(V=>V!==F),done:[...S.done,F]}),R=F=>void U({todo:[...S.todo,F],done:S.done.filter(V=>V!==F)}),z=()=>{const F=m.trim();F===""||S.todo.includes(F)||S.done.includes(F)||(p(""),U({todo:[...S.todo,F]}))},L=S.sources!==void 0||S.screen!==void 0,A=()=>{x(!0),b(null),e.connection.call("games/activity/reset",{activityId:S.id}).then(r,F=>b(Ce(F))).finally(()=>x(!1))};return d&&s!==void 0?n.jsx("div",{className:"ov-detail",children:n.jsx(kx,{client:e,game:s,activity:S,onDone:()=>{h(!1),r()},onCancel:()=>h(!1)})}):n.jsxs("div",{className:"ov-detail",children:[S.description!==void 0&&n.jsx("p",{className:"ov-description",children:S.description}),n.jsxs("div",{className:"activity-dates muted small",children:[S.startsAt!==void 0&&n.jsxs("span",{children:[B(S.startsAt)," 开始"]}),S.endsAt!==void 0&&n.jsxs("span",{children:[B(S.endsAt)," 结束"]}),S.shopEndsAt!==void 0&&n.jsxs("span",{children:["商店开到 ",B(S.shopEndsAt)]})]}),n.jsx(g3,{activity:S,game:s,chosen:_!==void 0?_??void 0:S.chosen,onChoose:M}),n.jsxs("div",{className:"ov-checklist",role:"list","aria-label":"要做的事",children:[S.todo.map(F=>n.jsxs("label",{className:"ov-check",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!1,disabled:g,onChange:()=>P(F)}),F]},`t${F}`)),S.done.map(F=>n.jsxs("label",{className:"ov-check done",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!0,disabled:g,onChange:()=>R(F)}),F]},`d${F}`)),S.todo.length+S.done.length===0&&n.jsx("p",{className:"muted small",children:"还没有要做的事。自己加几项(例如「活动商店换完」「剧情通关」),或者在游戏页让 agent 进游戏读一次。"})]}),n.jsxs("div",{className:"ov-add",children:[n.jsx("input",{className:"text-input plain",value:m,maxLength:80,placeholder:"加一项要做的事,回车添加",disabled:g,onChange:F=>p(F.target.value),onKeyDown:F=>{F.key==="Enter"&&z()}}),n.jsxs("button",{className:"small-button",disabled:g||m.trim()==="",onClick:z,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:S.finished!==void 0,disabled:g,onChange:F=>void U({finished:F.target.checked})}),"这个活动我做完了"]}),n.jsx("span",{className:"spacer"}),((T=S.screen)==null?void 0:T.evidence)===!0&&n.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:S.id}).then(F=>{const V=`data:${F.mediaType};base64,${F.data}`,D=new Image;D.onload=()=>u({src:V,width:D.naturalWidth,height:D.naturalHeight}),D.src=V},F=>b(Ce(F))),children:"看游戏截图"}),((H=S.screen)==null?void 0:H.sessionId)!==void 0&&o!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>o(S.screen.sessionId),children:"agent 的对话"}),S.url!==void 0&&n.jsx("a",{className:"link-button small",href:S.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"}),"编辑"]}),S.own!==void 0&&L&&n.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:g,onClick:A,children:"恢复来源的内容"}),n.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:g,onClick:()=>void e.connection.call("games/activity/remove",{activityId:S.id}).then(r,F=>b(Ce(F))),children:"从日历去掉"})]}),k!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:k})]}),l!==null&&n.jsx(ch,{src:l.src,width:l.width,height:l.height,name:`${S.name}.png`,onClose:()=>u(null)})]})}function v3({client:e,onChanged:t,onCreate:s}){const[i,r]=v.useState(null),[o,l]=v.useState(""),[u,d]=v.useState(null),[h,m]=v.useState(null),[p,g]=v.useState(0);v.useEffect(()=>{let k=!0;return e.connection.call("games/catalog",{}).then(b=>{k&&r(b.games)}).catch(b=>{k&&m(Ce(b))}),()=>{k=!1}},[e,p]);const x=async(k,b)=>{d(k.sra),m(null),r(j=>(j==null?void 0:j.map(w=>w.sra===k.sra?{...w,followed:b}:w))??j);try{await e.connection.call("games/follow",{sra:k.sra,follow:b}),t()}catch(j){m(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(k=>n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:k.followed,disabled:u===k.sra,onChange:b=>void x(k,b.target.checked)}),k.name,u===k.sra?"…":""]},k.sra))}),s!==void 0&&n.jsxs("form",{className:"discover-row",onSubmit:k=>{k.preventDefault();const b=o.trim();b!==""&&(s(b),l(""))},children:[n.jsx("span",{className:"field-title",children:"列表里没有?"}),n.jsx("input",{className:"text-input plain",value:o,maxLength:60,placeholder:"输入游戏名,例如:重返未来:1999",onChange:k=>l(k.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})]})]})}function y3(e,t){const s=new Date(e),i=s.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1});return new Date(t).toDateString()===s.toDateString()?i:`${s.toLocaleDateString("zh-CN",{weekday:"short"})} ${i}`}function b3(e,t){const s=y3(e.at,t);return e.by==="user"?`${s} 我勾的`:e.by==="agent"?`${s} agent 记的${e.detail===void 0?"":`:${e.detail}`}`:e.by==="task"?`${s} ${e.script??"脚本"}「${e.detail??"任务"}」运行成功`:`${s} ${e.script??"脚本"} 日志:${e.detail??""}`}function k3({client:e,game:t,now:s,onChanged:i}){var _,E;const[r,o]=v.useState(null),[l,u]=v.useState(null),[d,h]=v.useState(null),[m,p]=v.useState(""),g=(t.routines??[]).filter(M=>M.period!=="event"),x=[{period:"daily",title:"日常",resetsAt:(_=t.resets)==null?void 0:_.daily,rows:g.filter(M=>M.period==="daily")},{period:"weekly",title:"周常",resetsAt:(E=t.resets)==null?void 0:E.weekly,rows:g.filter(M=>M.period==="weekly")}],k=g.filter(M=>M.done!==void 0).length,b=async(M,O)=>{o(M),u(null);try{await O(),i()}catch(B){u(Ce(B))}finally{o(null)}},j=M=>b(M.id,()=>e.connection.call("games/routine/set",{game:t.id,routine:M.id,done:M.done===void 0})),w=M=>b(M.id,()=>e.connection.call("games/routine/remove",{game:t.id,routine:M.id})),S=M=>{const O=m.trim();if(O===""){h(null);return}b("add",async()=>{await e.connection.call("games/routine/add",{game:t.id,name:O,period:M}),p(""),h(null)})};return n.jsxs("section",{className:"game-section routines","aria-label":"日常与周常",children:[n.jsxs("div",{className:"game-section-head",children:[n.jsx("h3",{children:"日常 · 周常"}),g.length>0&&n.jsxs("span",{className:"count",title:"这一期做完的",children:[k,"/",g.length]}),n.jsx("span",{className:"spacer"}),(t.hiddenRoutines??0)>0&&n.jsxs("button",{className:"link-button small",disabled:r!==null,onClick:()=>void b("restore",()=>e.connection.call("games/routine/remove",{game:t.id,restore:!0})),children:["显示隐藏的 ",t.hiddenRoutines," 项"]})]}),n.jsx("div",{className:"routine-columns",children:x.map(M=>n.jsxs("div",{className:"routine-col",children:[n.jsxs("div",{className:"routine-col-head",children:[n.jsx("span",{className:"routine-col-title",children:M.title}),M.resetsAt!==void 0&&n.jsxs("span",{className:"muted small",title:new Date(M.resetsAt).toLocaleString("zh-CN",{hour12:!1}),children:[mh(M.resetsAt,s),"后重置"]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"icon-button",title:`自己加一项${M.title}`,"aria-label":`添加${M.title}`,"aria-pressed":d===M.period,onClick:()=>{h(O=>O===M.period?null:M.period),p("")},children:n.jsx(ee,{name:"plus"})})]}),M.rows.length===0&&d!==M.period&&n.jsxs("p",{className:"muted small routine-empty",children:[M.period==="daily"?"还没有日常。":"还没有周常。","玩它的脚本包写了的会自动列出来;也可以点「+」自己加。"]}),n.jsx("ul",{className:"routine-list",children:M.rows.map(O=>n.jsxs("li",{className:`routine-row ${O.done!==void 0?"done":""}`,children:[n.jsxs("label",{className:"routine-check",children:[n.jsx("input",{type:"checkbox","aria-label":O.name,checked:O.done!==void 0,disabled:r!==null,onChange:()=>void j(O)}),n.jsxs("span",{className:"routine-text",children:[n.jsx("span",{className:"routine-name",children:O.name}),n.jsx("span",{className:"routine-meta muted small",title:[O.description,...O.links].filter(Boolean).join(`
215
+ `),children:O.done!==void 0?b3(O.done,s):O.links.length>0?`自动:${O.links[0]}${O.links.length>1?` 等 ${O.links.length} 处`:""}`:O.description??"手动勾选"})]})]}),n.jsx("button",{className:"icon-button routine-remove",title:O.from==="own"?"删除这一项":"不在这里显示(脚本包、游戏包里的可以再显示回来)","aria-label":`移除${O.name}`,disabled:r!==null,onClick:()=>void w(O),children:n.jsx(ee,{name:"close"})})]},O.id))}),d===M.period&&n.jsxs("form",{className:"routine-add",onSubmit:O=>{O.preventDefault(),S(M.period)},children:[n.jsx("input",{className:"text-input plain",autoFocus:!0,maxLength:40,value:m,placeholder:M.period==="daily"?"例如:每日委托":"例如:周本",disabled:r!==null,onChange:O=>p(O.target.value),onKeyDown:O=>{O.key==="Escape"&&h(null)}}),n.jsx("button",{className:"small-button primary",type:"submit",disabled:r!==null||m.trim()==="",children:"添加"})]})]},M.period))}),l!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:l})]})]})}const ea=864e5,Ra=36e5,sg=6e4,Sk=5;function mh(e,t){const s=e-t;return s<=0?"已结束":s>=ea?`${Math.floor(s/ea)} 天 ${Math.floor(s%ea/Ra)} 时`:`${Math.floor(s/Ra)} 时 ${Math.floor(s%Ra/sg)} 分`}function j3(e){return e<=0?{value:"0",unit:"时",rest:""}:e>=ea?{value:String(Math.floor(e/ea)),unit:"天",rest:`${Math.floor(e%ea/Ra)} 时`}:e>=Ra?{value:String(Math.floor(e/Ra)),unit:"时",rest:`${Math.floor(e%Ra/sg)} 分`}:{value:String(Math.max(1,Math.floor(e/sg))),unit:"分",rest:""}}function ig(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 Nx(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 N3({client:e,game:t,activities:s,notices:i,color:r,now:o,soonDays:l,busy:u,open:d,adding:h,onOpen:m,onAdd:p,onRefresh:g,onRead:x,onReadWeb:k,onCancelReading:b,onDiscover:j,onRemove:w,onChanged:S,openSession:_,openScripts:E}){var fe,Ee,Ue,Te,pe,be,De,Re;const[M,O]=v.useState(!1),[B,U]=v.useState(!1),[P,R]=v.useState(null),z=i.find(ae=>ae.id===P),L=s.filter(ae=>Math.max(ae.endsAt??1/0,ae.shopEndsAt??0)>o),A=(ae,Fe)=>(ae.endsAt??1/0)-(Fe.endsAt??1/0),T=new Set((t.routines??[]).flatMap(ae=>ae.activities??[])),H=L.filter(ae=>T.has(ae.id)).sort((ae,Fe)=>+((Fe.startsAt??0)<=o)-+((ae.startsAt??0)<=o)||A(ae,Fe)),F=L.filter(ae=>(ae.startsAt??0)<=o&&!T.has(ae.id)).sort(A),V=L.filter(ae=>ae.startsAt!==void 0&&ae.startsAt>o&&!T.has(ae.id)).sort((ae,Fe)=>ae.startsAt-Fe.startsAt),D=F.filter(ae=>ms(ae).state!=="finished"&&(ae.endsAt??1/0)-o<l*ea),q=t.sources.some(ae=>ae.auto),te={partial:0,unknown:1,finished:2},G=F.filter(ae=>!D.includes(ae)&&ms(ae).state!=="finished").sort((ae,Fe)=>te[ms(ae).state]-te[ms(Fe).state]||A(ae,Fe)),K=F.filter(ae=>ms(ae).state==="finished"),Z=[{key:"soon",title:"需要关注",hint:`${l} 天内结束,还没做完`,rows:D,tone:"warn"},{key:"ongoing",title:"进行中",hint:"做了一部分的在前",rows:G},{key:"upcoming",title:"即将开始",hint:"按开始时间",rows:V},{key:"cycles",title:"周期玩法",hint:"每期做一次,做完会勾上",rows:H,tone:"cycle"}],Y=ae=>n.jsx("div",{className:"schedule-item",children:n.jsx($3,{client:e,activity:ae,game:t,now:o,soonDays:l,onClick:()=>m(ae.id),expanded:d===ae.id})},ae.id),Q=t.single===!0,ie=i.find(ae=>ae.kind==="update"),re=ie??[...i].sort((ae,Fe)=>(Fe.publishedAt??Fe.at)-(ae.publishedAt??ae.at))[0],ne=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:q?"每天自动读官方公告":"让 agent 上网查"}),n.jsx("button",{className:"icon-button",title:"让 agent 上网查最新的公告和更新","aria-label":"让 agent 查公告",disabled:u!==null||((fe=t.webReading)==null?void 0:fe.state)==="running"||((Ee=t.webReading)==null?void 0:Ee.state)==="queued",onClick:()=>k(),children:n.jsx(ee,{name:"search"})}),q&&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:(B?i:i.slice(0,Sk)).map(ae=>n.jsx(I3,{client:e,notice:ae,now:o,onOpen:()=>R(ae.id)},ae.id))}),z&&n.jsx(u3,{client:e,notice:z,now:o,color:r,onClose:()=>R(null)},z.id),i.length>Sk&&n.jsx("button",{className:"link-button small notice-more",onClick:()=>U(ae=>!ae),children:B?"收起":`展开全部 ${i.length} 条`})]}):null;return n.jsxs("div",{className:"game-view",style:{"--game":r},children:[n.jsx(w3,{client:e,game:t,now:o,update:re,covers:[ie==null?void 0:ie.cover,...i.map(ae=>ae.cover),...F.map(ae=>ae.cover).filter(ae=>(ae==null?void 0:ae.startsWith("shot:"))!==!0)],onChanged:S}),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||((Ue=t.webReading)==null?void 0:Ue.state)==="running"||((Te=t.webReading)==null?void 0:Te.state)==="queued",onClick:j,children:[n.jsx(ee,{name:"search"}),((pe=t.webReading)==null?void 0:pe.state)==="running"||((be=t.webReading)==null?void 0:be.state)==="queued"?"agent 正在找…":"让 agent 去找"]})]}),(((De=t.pools)==null?void 0:De.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(ae=>n.jsx(T3,{client:e,pool:ae,game:t,now:o},`${ae.name}-${ae.endsAt}`))})]}),!Q&&n.jsx(k3,{client:e,game:t,now:o,onChanged:S}),Q&&ne,!Q||L.length>0||K.length>0?n.jsxs("section",{className:"game-section game-events","aria-label":"活动日程",children:[n.jsxs("div",{className:"game-section-head",children:[n.jsx("h3",{children:"活动日程"}),n.jsx("span",{className:"count",children:L.length}),n.jsx("span",{className:"spacer"}),n.jsx("span",{className:"muted small",children:((Re=t.sources.find(ae=>ae.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:q?"刷新数据站(不用模型)":"这个游戏没有能自动读的数据站",disabled:u!==null||!q,onClick:g,children:n.jsx(ee,{name:"refresh"})})]}),L.length===0&&n.jsx("p",{className:"muted small schedule-empty",children:q?"还没有活动。点右上角刷新,或点「+」自己添加。":"这个游戏没有能自动读的数据站:让 agent 进游戏读一次,或点「+」自己添加。"}),Z.filter(ae=>ae.rows.length>0).map(ae=>n.jsxs("section",{className:`schedule-group ${ae.tone??""}`,children:[n.jsxs("div",{className:"schedule-group-title",children:[n.jsx("span",{children:ae.title}),n.jsx("span",{className:"count",children:ae.rows.length}),n.jsx("span",{className:"muted small",children:ae.hint})]}),n.jsx("div",{className:"schedule-grid",children:ae.rows.map(Y)})]},ae.key)),K.length>0&&n.jsxs("section",{className:"schedule-group done",children:[n.jsxs("button",{className:"schedule-group-title toggle","aria-expanded":M,onClick:()=>O(ae=>!ae),children:[n.jsx("span",{children:"已做完"}),n.jsx("span",{className:"count",children:K.length}),n.jsx("span",{className:"muted small",children:M?"收起":"展开"}),n.jsx(ee,{name:"chevron-down",className:`chevron-icon ${M?"open":""}`})]}),M&&n.jsx("div",{className:"schedule-grid",children:K.map(Y)})]})]}):n.jsxs("p",{className:"muted small single-no-events",children:["单机游戏没有限时活动。有要记的事(限时折扣、联动)可以",n.jsx("button",{className:"link-button small",onClick:p,children:"自己加一个"}),"。"]}),!Q&&ne]}),n.jsxs("aside",{className:"game-side",children:[n.jsx(E3,{game:t,single:Q,running:F,soon:D,now:o,busy:u,onRead:x,onReadWeb:k,onCancelReading:b,onRemove:w,openSession:_}),n.jsx("section",{className:"card game-runs-card",children:n.jsx(A3,{client:e,game:t,now:o,openScripts:E})}),n.jsxs("section",{className:"card game-sources-card",children:[n.jsx("h3",{children:"数据来源"}),n.jsxs("div",{className:"game-sources",children:[t.sources.map(ae=>{var Fe,ut;return n.jsxs("span",{className:`source-chip ${ae.auto?"auto":"agent"}`,children:[ae.auto?n.jsxs("span",{className:"source-name",title:"每天自动读取(不用模型)",children:[n.jsx("span",{className:"source-dot auto"}),ae.name]}):n.jsxs("button",{className:"source-name",disabled:u!==null||((Fe=t.webReading)==null?void 0:Fe.state)==="running"||((ut=t.webReading)==null?void 0:ut.state)==="queued",title:"让 agent 读这个来源,把活动记进日历",onClick:()=>k(ae.id),children:[n.jsx("span",{className:"source-dot"}),ae.name,n.jsx("span",{className:"source-action",children:"agent 读"})]}),ae.homepage!==void 0&&n.jsx("a",{className:"source-open",href:ae.homepage,target:"_blank",rel:"noreferrer",title:"在浏览器里打开","aria-label":`打开${ae.name}`,children:n.jsx(ee,{name:"popout"})}),ae.added===!0&&n.jsx("button",{className:"source-open",title:"不再读这个网址","aria-label":`删除${ae.name}`,onClick:()=>void e.connection.call("games/source/remove",{game:t.id,source:ae.id}).then(S,()=>{}),children:n.jsx(ee,{name:"close"})})]},ae.id)}),n.jsx(_3,{client:e,game:t,onAdded:S})]}),t.refreshed!==void 0&&n.jsxs("span",{className:"muted small",children:[vt(t.refreshed.at,o),"刷新"]}),t.refreshed!==void 0&&!t.refreshed.ok&&n.jsxs("span",{className:"tone-error small",children:["上次没读到:",t.refreshed.detail]})]})]})]})]})}function w3({client:e,game:t,now:s,update:i,covers:r,onChanged:o}){const l=t.version,u=QS(e,[t.banner,l==null?void 0:l.cover,t.art,...r]),d=(l==null?void 0:l.startsAt)!==void 0&&l.endsAt!==void 0?l.endsAt-l.startsAt:void 0,h=d===void 0||d<=0?void 0:Math.min(1,Math.max(0,(s-l.startsAt)/d)),m=p=>new Date(p).toLocaleDateString("zh-CN",{timeZone:t.timezone,month:"numeric",day:"numeric"});return n.jsxs("section",{className:`version-hero ${u===void 0?"no-art":""} ${t.banner!==void 0?"custom":""}`,children:[u!==void 0&&n.jsx("img",{className:"version-art",src:u,alt:""},t.banner??"default"),n.jsx("div",{className:"version-shade"}),n.jsx(S3,{client:e,game:t,onChanged:o}),n.jsxs("div",{className:"version-caption",children:[n.jsxs("span",{className:"version-kicker",children:[t.name,l!==void 0?n.jsxs(n.Fragment,{children:[" · ",n.jsx("b",{children:l.name})," 版本"]}):(i==null?void 0:i.version)!==void 0?n.jsxs(n.Fragment,{children:[" · 最新 ",n.jsx("b",{children:i.version})]}):""]}),n.jsx("h2",{children:(l==null?void 0:l.title)??t.name})]}),n.jsxs("div",{className:"version-strip",children:[l===void 0&&i!==void 0&&n.jsxs("span",{className:"small version-none version-update",title:i.title,children:[i.kind==="update"?"最新更新":"近期公告",":",i.title,i.publishedAt===void 0?"":` · ${vt(i.publishedAt,s)}`]}),l===void 0&&i===void 0&&n.jsx("span",{className:"small version-none",children:t.single===!0?t.sources.some(p=>p.auto)?"还没有更新公告:点「公告与更新」右上角刷新":"还没有更新公告:点「公告与更新」右上角让 agent 查":t.sources.length===0?"还没有数据来源":t.sources.some(p=>p.auto)?"还没有版本信息:点「活动日程」右上角刷新":"这个游戏的数据站不提供版本信息"}),l!==void 0&&h!==void 0&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"version-end",children:m(l.startsAt)}),n.jsxs("div",{className:"version-track",role:"meter","aria-label":"版本进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h*100),children:[n.jsx("span",{className:"version-fill",style:{width:`${h*100}%`}}),n.jsx("span",{className:"version-now",style:{left:`${h*100}%`}})]}),n.jsx("span",{className:"version-end",children:m(l.endsAt)})]}),(l==null?void 0:l.endsAt)!==void 0&&n.jsx("span",{className:"version-remaining",children:l.endsAt>s?n.jsxs(n.Fragment,{children:["还剩 ",n.jsx("strong",{children:mh(l.endsAt,s)})]}):"本版本已结束"})]})]})}function S3({client:e,game:t,onChanged:s}){const i=v.useRef(null),[r,o]=v.useState(!1),[l,u]=v.useState(null),d=async m=>{u(null);try{const p=await m();if(p===null)return;o(!0),await e.connection.call("games/banner/set",{game:t.id,...p}),s()}catch(p){u(Ce(p))}finally{o(!1)}},h=()=>{var m;if(Vs()===void 0){(m=i.current)==null||m.click();return}d(async()=>{const p=await hh(e,{kind:"file",title:"选择横幅背景图片",filterName:"图片",extensions:["png","jpg","jpeg","gif","webp","avif"]});return p===null?null:{path:p}})};return n.jsxs("div",{className:`version-tools ${l!==null?"has-error":""}`,children:[l!==null&&n.jsx("span",{className:"version-tools-error",role:"alert",title:l,children:l}),t.banner!==void 0&&n.jsx("button",{className:"version-tool",disabled:r,title:"不用自己的图片,换回版本的图",onClick:()=>void d(async()=>({})),children:"恢复默认"}),n.jsxs("button",{className:"version-tool",disabled:r,title:"选一张本地图片作为这个游戏横幅的背景",onClick:h,children:[n.jsx(ee,{name:"image"}),r?"保存中…":"换背景"]}),n.jsx("input",{ref:i,type:"file",accept:bx.join(","),hidden:!0,onChange:m=>{var g;const p=(g=m.target.files)==null?void 0:g[0];m.target.value="",p!==void 0&&d(async()=>({image:(await JS(p)).image}))}})]})}function _3({client:e,game:t,onAdded:s}){const[i,r]=v.useState(!1),[o,l]=v.useState(""),[u,d]=v.useState(!1),[h,m]=v.useState(null);if(!i)return n.jsxs("button",{className:"source-add",onClick:()=>r(!0),title:"添加一个关于这个游戏的网页,agent 会去读它",children:[n.jsx(ee,{name:"plus"}),"添加网址"]});const p=async()=>{const g=o.trim();if(g!==""){d(!0),m(null);try{await e.connection.call("games/source/add",{game:t.id,url:/^https?:\/\//.test(g)?g:`https://${g}`}),l(""),r(!1),s()}catch(x){m(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),m(null)},children:"取消"}),h!==null&&n.jsx("span",{className:"tone-error small",children:h})]})}function E3({game:e,single:t,running:s,soon:i,now:r,busy:o,onRead:l,onReadWeb:u,onCancelReading:d,onRemove:h,openSession:m}){var j,w,S,_;const p=s.map(ms),g=p.filter(E=>E.state==="finished").length,x=p.filter(E=>E.state==="partial").length,k=p.filter(E=>E.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":`已做完 ${g} 个,做了一部分 ${x} 个,没记录 ${k} 个`,children:[g>0&&n.jsx("span",{className:"done",style:{flexGrow:g}}),x>0&&n.jsx("span",{className:"partial",style:{flexGrow:x}}),k>0&&n.jsx("span",{className:"unknown",style:{flexGrow:k}})]}),n.jsxs("ul",{className:"status-legend",children:[n.jsxs("li",{children:[n.jsx("i",{className:"done"}),"已做完",n.jsx("b",{children:g})]}),n.jsxs("li",{children:[n.jsx("i",{className:"partial"}),"做了一部分",n.jsx("b",{children:x})]}),n.jsxs("li",{children:[n.jsx("i",{className:"unknown"}),"没记录",n.jsx("b",{children:k})]})]}),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"||(b==null?void 0:b.state)==="queued",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||((j=e.webReading)==null?void 0:j.state)==="running"||((w=e.webReading)==null?void 0:w.state)==="queued",title:t?"agent 读官方的更新日志、Steam 新闻和公告,记下版本更新和长期公告":"agent 读官网公告、Wiki 等插件不能自己读的来源,把活动记进日历",onClick:()=>u(),children:[n.jsx(ee,{name:"search"}),((S=e.webReading)==null?void 0:S.state)==="running"||((_=e.webReading)==null?void 0:_.state)==="queued"?"agent 正在查…":t?"让 agent 查最新公告":"让 agent 上网查活动"]}),n.jsx("button",{className:"small-button",disabled:o!==null,title:e.own===!0?"删掉这个游戏和它的活动(你或 agent 加的)":e.followed===!0?"不再关注,游戏页上不再显示":"游戏页上不再显示;它的游戏包和脚本包不删",onClick:h,children:e.own===!0?"删除这个游戏":"不再显示"})]}),b!==void 0&&n.jsx(_k,{cancel:d,what:"进游戏",reading:b,now:r,openSession:m}),e.webReading!==void 0&&n.jsx(_k,{cancel:d,what:"上网查",reading:e.webReading,now:r,openSession:m})]})}function _k({what:e,reading:t,now:s,openSession:i,cancel:r}){var l,u;const o=(l=t.summary)==null?void 0:l.replace(/[*_`#>]+/g,"").replace(/\s+/g," ").trim();return n.jsxs("div",{className:`reading ${t.state}`,children:[n.jsxs("div",{className:"reading-head",children:[n.jsx("span",{className:`badge ${t.state==="done"?"ok":t.state==="failed"?"warn":""}`,children:t.state==="queued"?"等待执行":t.state==="partial"?"部分完成":t.state==="cancelled"?"已取消":t.state==="running"?`正在${e}`:t.state==="done"?`上次${e}`:`${e}没完成`}),n.jsx("span",{className:"muted small",children:vt(t.at,s)}),n.jsx("span",{className:"spacer"}),t.taskId!==void 0&&(t.state==="running"||t.state==="queued")&&n.jsx("button",{className:"link-button small",onClick:()=>r(t.taskId),children:"取消探查"}),t.sessionId!==void 0&&n.jsxs("button",{className:"link-button small reading-open",onClick:()=>i(t.sessionId),children:["查看对话",n.jsx(ee,{name:"chevron"})]})]}),!!((u=t.remainingUrls)!=null&&u.length)&&t.state!=="running"&&t.state!=="queued"&&n.jsxs("div",{className:"muted small",children:["剩余 ",t.remainingUrls.length," 个链接,再次按相同来源查活动将从这里继续。"]}),o!==void 0&&o!==""&&n.jsx("p",{className:"reading-summary",title:o,children:o})]})}function C3({client:e,game:t}){const s=Se(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=Se(e.capabilities),o=Se(e.connection.status),[l,u]=v.useState(null),[d,h]=v.useState([]),[m,p]=v.useState(0),[g,x]=v.useState(null),[k,b]=v.useState(null),j=r.has("pipelines");v.useEffect(()=>e.connection.on("pipelines/changed",()=>p(_=>_+1)),[e]),v.useEffect(()=>e.connection.on("pipelines/run",_=>{_.state!=="running"&&p(E=>E+1)}),[e]),v.useEffect(()=>{if(o.state!=="open"||!j||t.scripts.length===0){u([]);return}let _=!0;return(async()=>{const{items:E}=await e.connection.call("pipelines/list",{}),O=(await Promise.all(E.filter(U=>!U.draft).map(async U=>({summary:U,pipeline:await e.connection.call("pipelines/get",{id:U.id})})))).filter(({pipeline:U})=>U.nodes.some(P=>P.kind==="script-task"&&t.scripts.includes(P.scriptId))),B=r.has("schedule")?await e.connection.call("schedule/status",{}).catch(()=>{}):void 0;_&&(u(O),h((B==null?void 0:B.upcoming)??[]))})().catch(E=>{_&&b(Ce(E))}),()=>{_=!1}},[e,o.state,j,t.id,t.scripts.join(","),m]);const w=async _=>{x(_),b(null);try{await e.connection.call("pipelines/run",{id:_}),p(E=>E+1)}catch(E){b(Ce(E))}finally{x(null)}},S={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(C3,{client:e,game:t}),t.scripts.length>0&&n.jsxs("p",{className:"muted small",children:["玩它的脚本:",t.scripts.map((_,E)=>n.jsxs("span",{children:[E>0?"、":"",n.jsx("button",{className:"link-button",onClick:i,children:_})]},_))]}),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:_})=>{var O,B;const E=d.filter(U=>U.pipelineId===_.id).map(U=>U.at).sort((U,P)=>U-P)[0],M=_.lastRun;return n.jsxs("li",{children:[n.jsx("a",{className:"run-name",href:`#/p/pipelines/${encodeURIComponent(_.id)}`,children:_.name}),n.jsx("span",{className:"muted small",children:E!==void 0?`下次 ${new Date(E).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"})}`:_.schedule.enabled?"定时已开":"没有定时"}),M!==void 0&&n.jsxs("span",{className:`badge ${((O=S[M.state])==null?void 0:O[0])??""}`,title:new Date(M.startedAt).toLocaleString("zh-CN",{hour12:!1}),children:[((B=S[M.state])==null?void 0:B[1])??M.state," · ",vt(M.endedAt??M.startedAt,s)]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:g!==null||(M==null?void 0:M.state)==="running",onClick:()=>void w(_.id),children:(M==null?void 0:M.state)==="running"?"运行中…":g===_.id?"启动中…":"运行"})]},_.id)})}),k!==null&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:k})]})]})}function t1(e,t,s){const i=(e.startsAt??0)<=t,r=i&&e.endsAt!==void 0&&e.endsAt<=t,o=r?e.shopEndsAt:e.endsAt,l=i&&o!==void 0&&o-t<s*ea&&ms(e).state!=="finished";return{started:i,shopOnly:r,end:o,soon:l,target:i?o:e.startsAt}}function n1({activity:e,art:t,now:s,soonDays:i}){var k;const{started:r,shopOnly:o,end:l,soon:u,target:d}=t1(e,s,i),h=e.startsAt!==void 0&&l!==void 0?l-e.startsAt:void 0,m=h===void 0||h<=0||!r?void 0:Math.min(1,Math.max(0,(s-e.startsAt)/h)),p=ms(e).state==="finished"?["done","已做完"]:r?o?["shop","商店开放"]:["live","进行中"]:["upcoming","即将开始"],g=d===void 0?{value:"",unit:"",rest:""}:j3(d-s),x=((k=e.cover)==null?void 0:k.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?"剩余":"距开始"}${mh(d,s)}`,children:[d===void 0?n.jsx("b",{children:"?"}):n.jsxs(n.Fragment,{children:[n.jsx("b",{children:g.value}),n.jsx("small",{children:g.unit}),g.rest!==""&&n.jsx("em",{children:g.rest})]}),n.jsx("i",{children:r?o?"商店":"剩余":"后开始"})]}),m!==void 0&&n.jsx("span",{className:"sched-elapsed",style:{width:`${m*100}%`}})]})}function $3({client:e,activity:t,game:s,now:i,soonDays:r,onClick:o,expanded:l}){var b,j,w,S;const u=oa(e,t.cover),d=ms(t),{started:h,shopOnly:m,end:p,soon:g}=t1(t,i,r),x=Nx(s.timezone,i),k=t.chosen===void 0?void 0:t.chosen===$o?"我设的":t.chosen===oc?"游戏画面":(j=(b=t.sources)==null?void 0:b.find(_=>_.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(n1,{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?`${ig(t.startsAt,s.timezone)} 开始 · ${x}`:p!==void 0?`${ig(p,s.timezone)} ${m?"商店关闭":"结束"} · ${x}`:`结束时间未知${((w=t.screen)==null?void 0:w.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}),k!==void 0&&n.jsxs("span",{className:"sched-kind",title:`你选了用「${k}」的图片和时间`,children:["用 ",k]}),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?"我添加的":"我改过"}),((S=t.sources)==null?void 0:S.some(_=>_.web))===!0&&n.jsx("span",{className:"sched-kind",title:`来源:${t.sources.map(_=>_.name).join("、")}`,children:t.sources.every(_=>_.web)?"网页读到":"数据站 + 网页"})]}),n.jsx(jx,{progress:d})]})]})]})}function I3({client:e,notice:t,now:s,onOpen:i}){const r=oa(e,t.cover);return n.jsx("li",{className:`notice-row ${t.lasting===!0?"lasting":""}`,children:n.jsxs("button",{className:"notice-open","aria-label":t.title,"aria-haspopup":"dialog",onClick:i,children:[r!==void 0&&n.jsx("img",{className:"notice-art",src:r,alt:"",loading:"lazy"}),n.jsxs("span",{className:"notice-body",children:[n.jsxs("span",{className:"notice-meta",children:[n.jsx(e1,{notice:t,now:s}),n.jsx("span",{className:"spacer"}),t.publishedAt!==void 0&&n.jsx("span",{className:"muted small",title:new Date(t.publishedAt).toLocaleString("zh-CN",{hour12:!1}),children:new Date(t.publishedAt).toLocaleDateString("zh-CN")})]}),n.jsx("span",{className:"notice-title",children:t.title}),t.summary!==void 0&&n.jsx("span",{className:"notice-summary",children:t.summary}),n.jsx("span",{className:"muted small notice-source",children:t.source.name})]})]})})}function T3({client:e,pool:t,game:s,now:i}){const r=oa(e,t.cover),o=(t.startsAt??0)<=i;return n.jsxs("article",{className:"pool-card",children:[n.jsx("div",{className:"pool-art",children:r===void 0?n.jsx(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:mh(o?t.endsAt:t.startsAt,i)})]}),n.jsxs("span",{className:"muted small",children:[ig(t.endsAt,s.timezone)," 结束 (",Nx(s.timezone,i),")"]})]})]})}function M3(e,t){return v.useMemo(()=>new Map(e.map((s,i)=>[s.id,t[i%t.length]])),[e,t])}function dc({color:e,label:t,onClose:s,className:i="",children:r}){const o=v.useRef(null),l=()=>{var u;return((u=o.current)==null?void 0:u.querySelector("form.activity-editor"))!==null};return v.useEffect(()=>{var d;const u=document.activeElement;return(d=o.current)==null||d.focus({preventScroll:!0}),()=>{u instanceof HTMLElement&&u.isConnected&&u.focus({preventScroll:!0})}},[]),v.useEffect(()=>{const u=d=>{if(document.querySelector(".image-viewer")!==null||(d.key==="Escape"&&!l()&&s(),d.key!=="Tab"||o.current===null))return;const h=[...o.current.querySelectorAll("a[href], button:not(:disabled), input:not(:disabled):not([hidden]), textarea:not(:disabled)")],m=h[0],p=h[h.length-1],g=document.activeElement;m===void 0||p===void 0||(d.shiftKey&&(g===m||g===o.current)?(d.preventDefault(),p.focus()):!d.shiftKey&&g===p&&(d.preventDefault(),m.focus()))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[s]),n.jsx("div",{className:"activity-scrim",onPointerDown:u=>{u.target===u.currentTarget&&!l()&&s()},children:n.jsx("div",{ref:o,className:`activity-dialog ${i}`,role:"dialog","aria-modal":"true","aria-label":t,tabIndex:-1,style:{"--game":e},children:r})})}function R3(e,t){const s=u=>vt(u,t),i=e.sources??[],r=e.own,o=u=>u.startsAt!==void 0||u.endsAt!==void 0||u.cover!==void 0,l=u=>({id:u.id,name:u.name,note:`${u.web?"网页":"数据站"} · ${s(u.at)}`,title:u.web?"agent 在网页上读到的;刷新数据站不会删掉它":"数据站,每次刷新更新",startsAt:u.startsAt,endsAt:u.endsAt,shopEndsAt:u.shopEndsAt,cover:u.cover,blank:!o(u)&&u.shopEndsAt===void 0});return[{id:$o,name:"我设的",note:r===void 0?"":s(r.at),title:"你自己填的:刷新不会改掉",startsAt:r==null?void 0:r.startsAt,endsAt:r==null?void 0:r.endsAt,cover:r==null?void 0:r.cover,blank:r===void 0||!o(r)},...i.filter(u=>!u.web).map(l),...i.filter(u=>u.web).map(l),...e.screen===void 0?[]:[{id:oc,name:"游戏画面",note:`agent 看过 · ${s(e.screen.at)}`,title:"agent 进游戏看到的剩余时间和截图",endsAt:e.screen.endsAt,cover:e.screen.image,blank:e.screen.endsAt===void 0&&e.screen.image===void 0}]]}function O3(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 P3({client:e,url:t}){const s=oa(e,t);return n.jsx("span",{className:`source-thumb ${t===void 0?"none":""}`,children:s!==void 0?n.jsx("img",{src:s,alt:"",decoding:"async"}):t===void 0?"无图":null})}function L3({client:e,activity:t,game:s,now:i,soonDays:r,onClose:o,onChanged:l,openSession:u}){var Y,Q,ie;const[d,h]=v.useState(null),[m,p]=v.useState(!1),[g,x]=v.useState(""),[k,b]=v.useState(!1),[j,w]=v.useState(null),[S,_]=v.useState(void 0);v.useEffect(()=>_(void 0),[t]);const E=S??t,[M,O]=v.useState(void 0);v.useEffect(()=>O(void 0),[E.chosen]);const B=M!==void 0?M??void 0:E.chosen,U=oa(e,E.cover),P=v.useRef(void 0);U!==void 0&&(P.current=U);const R=E.cover===void 0?void 0:U??P.current,z=(s==null?void 0:s.timezone)??"Asia/Shanghai",L=re=>new Date(re).toLocaleString("zh-CN",{timeZone:z,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),A=R3(E,i),T=E.shopEndsAt!==void 0||A.some(re=>re.shopEndsAt!==void 0),H=E.sources!==void 0||E.screen!==void 0,F=(re,ne)=>{b(!0),w(null),re.then(()=>{l(),ne==null||ne()},fe=>w(Ce(fe))).finally(()=>b(!1))},V=re=>F(e.connection.call("games/activity/progress",{activityId:E.id,...re})),D=re=>V({todo:E.todo.filter(ne=>ne!==re),done:[...E.done,re]}),q=re=>V({todo:[...E.todo,re],done:E.done.filter(ne=>ne!==re)}),te=()=>{const re=g.trim();re===""||E.todo.includes(re)||E.done.includes(re)||(x(""),V({todo:[...E.todo,re]}))},G=re=>{O(re),w(null),e.connection.call("games/activity/source",{activityId:E.id,source:re}).then(ne=>{_(ne),l()},ne=>{O(void 0),w(Ce(ne))})},K=(re,ne)=>{const fe=new Image;fe.onload=()=>h({src:re,width:fe.naturalWidth,height:fe.naturalHeight,name:ne}),fe.src=re},Z=()=>{b(!0),w(null),e.connection.call("games/activity/reset",{activityId:E.id}).then(re=>{l(),re.activity===void 0&&o()},re=>w(Ce(re))).finally(()=>b(!1))};return m&&s!==void 0?n.jsx("div",{className:"dialog-form",children:n.jsx(kx,{client:e,game:s,activity:E,onDone:()=>{p(!1),l()},onCancel:()=>p(!1)})}):n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:"dialog-head",children:[n.jsxs("div",{className:"dialog-title",children:[n.jsx("h3",{title:E.name,children:E.name}),n.jsxs("div",{className:"dialog-meta",children:[n.jsxs("span",{className:"dialog-game",children:[n.jsx("span",{className:"game-dot"}),(s==null?void 0:s.name)??E.game]}),E.kind!==void 0&&n.jsx("span",{className:"sched-kind",children:E.kind})]})]}),n.jsx(jx,{progress:ms(E)}),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:R===void 0,title:R===void 0?void 0:"看大图","aria-label":"看大图",onClick:()=>{R!==void 0&&K(R,`${E.name}.png`)},children:n.jsx(n1,{activity:E,art:R,now:i,soonDays:r})}),n.jsxs("div",{className:"dialog-facts",children:[n.jsxs("dl",{className:"dialog-dates",children:[n.jsxs("div",{children:[n.jsx("dt",{children:"开始"}),n.jsx("dd",{children:E.startsAt===void 0?"未知":L(E.startsAt)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:"结束"}),n.jsx("dd",{children:E.endsAt===void 0?"未知":L(E.endsAt)})]}),T&&n.jsxs("div",{className:"wide",children:[n.jsx("dt",{children:"商店开到"}),n.jsx("dd",{children:E.shopEndsAt===void 0?"—":L(E.shopEndsAt)})]})]}),n.jsxs("span",{className:"muted small",children:[Nx(z,i),",游戏服务器时间",((Y=E.screen)==null?void 0:Y.remaining)===void 0?"":`;游戏里显示「${E.screen.remaining}」`]}),E.description!==void 0&&n.jsx("p",{className:"ov-description",children:E.description})]})]}),n.jsxs("div",{className:"dialog-col main",children:[n.jsxs("section",{className:"dialog-section","aria-label":"信息来源",children:[n.jsxs("div",{className:"dialog-section-head",children:[n.jsx("h4",{children:"信息来源"}),n.jsx("span",{className:"spacer"}),B!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>G(null),children:"恢复默认"})]}),n.jsx("div",{className:"source-rows",children:A.map(re=>{const ne=re.id===$o,fe=B===re.id;return n.jsxs("button",{className:`source-row ${fe?"on":""}`,"aria-pressed":fe,disabled:re.blank&&!ne,title:re.title,onClick:()=>{re.blank&&ne?p(!0):G(fe?null:re.id)},children:[n.jsx(P3,{client:e,url:re.cover}),n.jsxs("span",{className:"source-row-main",children:[n.jsxs("span",{className:"source-row-name",children:[n.jsx("b",{children:re.name}),fe&&n.jsx(ee,{name:"check"}),re.note!==""&&n.jsx("small",{children:re.note})]}),re.blank?n.jsx("span",{className:"source-row-dates muted",children:ne?"还没填,点这里设置图片和时间":"没有时间和图片"}):n.jsxs("span",{className:"source-row-dates",children:[n.jsx("span",{children:re.startsAt===void 0&&re.endsAt===void 0?"没有时间":`${re.startsAt===void 0?"?":L(re.startsAt)} – ${re.endsAt===void 0?"?":L(re.endsAt)}`}),re.shopEndsAt!==void 0&&n.jsxs("em",{children:["商店到 ",L(re.shopEndsAt)]})]})]}),n.jsx("span",{className:"source-row-uses",children:O3(E,re.id).map(Ee=>n.jsx("i",{children:Ee},Ee))})]},re.id)})}),n.jsx("p",{className:"muted small dialog-hint",children:"默认图片按 我设的 › 数据站和网页 › 游戏截图 显示。点一个来源,图片和时间就用它的;它没有的还按默认。"})]}),n.jsxs("section",{className:"dialog-section","aria-label":"要做的事",children:[n.jsxs("div",{className:"dialog-section-head",children:[n.jsx("h4",{children:"要做的事"}),E.todo.length+E.done.length>0&&n.jsxs("span",{className:"count",children:[E.done.length,"/",E.todo.length+E.done.length]})]}),n.jsxs("div",{className:"ov-checklist",role:"list",children:[E.todo.map(re=>n.jsxs("label",{className:"ov-check",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!1,disabled:k,onChange:()=>D(re)}),re]},`t${re}`)),E.done.map(re=>n.jsxs("label",{className:"ov-check done",role:"listitem",children:[n.jsx("input",{type:"checkbox",checked:!0,disabled:k,onChange:()=>q(re)}),re]},`d${re}`)),E.todo.length+E.done.length===0&&n.jsx("p",{className:"muted small",children:"还没有要做的事。自己加几项(例如「活动商店换完」),或者让 agent 进游戏读一次。"})]}),n.jsxs("div",{className:"ov-add",children:[n.jsx("input",{className:"text-input plain",value:g,maxLength:80,placeholder:"加一项,回车添加",disabled:k,onChange:re=>x(re.target.value),onKeyDown:re=>{re.key==="Enter"&&te()}}),n.jsxs("button",{className:"small-button",disabled:k||g.trim()==="",onClick:te,children:[n.jsx(ee,{name:"plus"}),"添加"]})]})]}),n.jsxs("div",{className:"dialog-section dialog-links",children:[E.url!==void 0&&n.jsx("a",{className:"link-button small",href:E.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),((Q=E.screen)==null?void 0:Q.evidence)===!0&&n.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:E.id}).then(re=>K(`data:${re.mediaType};base64,${re.data}`,`${E.name}-截图.png`),re=>w(Ce(re))),children:"看游戏截图"}),((ie=E.screen)==null?void 0:ie.sessionId)!==void 0&&u!==void 0&&n.jsx("button",{className:"link-button small",onClick:()=>u(E.screen.sessionId),children:"agent 的对话"}),n.jsx("span",{className:"spacer"}),E.own!==void 0&&H&&n.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:k,onClick:Z,children:"清除我设的"}),n.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:k,onClick:()=>F(e.connection.call("games/activity/remove",{activityId:E.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:E.finished!==void 0,disabled:k,onChange:re=>V({finished:re.target.checked})}),"这个活动我做完了"]}),n.jsx("span",{className:"spacer"}),s!==void 0&&n.jsxs("button",{className:"small-button",disabled:k,onClick:()=>p(!0),children:[n.jsx(ee,{name:"pencil"}),"编辑"]})]}),d!==null&&n.jsx(ch,{src:d.src,width:d.width,height:d.height,name:d.name,onClose:()=>h(null)})]})}const s1="adg:pack-offer:declined",Wf=new Set,z3={game:"游戏包",script:"脚本包",skill:"技能"};function i1(){try{return new Set(JSON.parse(localStorage.getItem(s1)??"[]"))}catch{return new Set}}function Ek(e){if(e.length!==0)try{localStorage.setItem(s1,JSON.stringify([...new Set([...i1(),...e])]))}catch{}}const oi=e=>e.trim().toLowerCase();function D3(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 r1({client:e,target:t,label:s,onInstalled:i}){const r=Se(e.capabilities),o=Se(e.connection.status),[l,u]=v.useState([]),[d,h]=v.useState(new Set),[m,p]=v.useState(null),[g,x]=v.useState(null),k=JSON.stringify(t),b=r.has("skillhub")&&o.state==="open";if(v.useEffect(()=>{var O;if(u([]),!b||t.games.length+(((O=t.scripts)==null?void 0:O.length)??0)===0)return;let M=!0;return e.connection.call("skillhub/list",{}).then(B=>{if(!M)return;const U=i1(),P=D3(B.items,t).filter(z=>z.installed===void 0&&z.blocked===void 0&&z.incompatible===void 0&&!U.has(z.name)&&!Wf.has(z.name)),R=z=>z.pack==="game"?0:z.pack==="script"?1:2;P.sort((z,L)=>R(z)-R(L)),u(P),h(new Set(P.filter(z=>z.default===!0||z.pack==="game").map(z=>z.name))),x(null)},()=>{}),()=>{M=!1}},[e,b,k]),l.length===0)return null;const j=()=>{for(const M of l)Wf.add(M.name);u([])},w=()=>{Ek(l.map(M=>M.name)),j()},S=async()=>{x(null);const M=l.filter(B=>d.has(B.name)),O=[];for(const B of M){p(B.name);try{await e.connection.call("skillhub/install",{name:B.name,repo:B.repo})}catch(U){x(`「${B.title??B.name}」没装上:${Ce(U)}`),p(null),O.length>0&&(i==null||i(O));return}B.pack==="game"&&B.game!==void 0&&O.push(B.game),u(U=>U.filter(P=>P.name!==B.name))}Ek(l.filter(B=>!d.has(B.name)).map(B=>B.name));for(const B of l)Wf.add(B.name);p(null),u([]),O.length>0&&(i==null||i(O))},_=(M,O)=>h(B=>{const U=new Set(B);return O?U.add(M):U.delete(M),U}),E=l.filter(M=>d.has(M.name)).length;return n.jsxs(dc,{color:"var(--accent)",label:`安装${s}的包`,onClose:m===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:m!==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(M=>n.jsx("li",{children:n.jsxs("label",{className:"pack-offer-item",children:[n.jsx("input",{type:"checkbox",checked:d.has(M.name),disabled:m!==null,onChange:O=>_(M.name,O.target.checked)}),n.jsxs("span",{className:"pack-offer-text",children:[n.jsxs("span",{className:"pack-offer-name",children:[M.title??M.name,n.jsx("span",{className:"pack-offer-kind",children:z3[M.pack??"skill"]}),m===M.name&&n.jsx("span",{className:"muted small",children:"正在下载…"})]}),n.jsx("span",{className:"muted small",children:M.description})]})]})},M.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:m!==null,onClick:w,children:"不用了"}),n.jsx("button",{className:"small-button primary",disabled:m!==null||E===0,onClick:()=>void S(),children:m!==null?"正在安装…":`安装 ${E} 个`})]})]})}function F3({client:e,sessionId:t}){const s=Se(e.capabilities),[i,r]=v.useState({scripts:[],games:[]}),[o,l]=v.useState([]),u=s.has("skills");v.useEffect(()=>{if(r({scripts:[],games:[]}),!u)return;let p=!0;e.connection.call("skills/focus",{sessionId:t}).then(x=>{p&&r(x)},()=>{});const g=e.connection.on("skills/focused",x=>{x.sessionId===t&&r({scripts:x.scripts,games:x.games})});return()=>{p=!1,g()}},[e,t,u]);const d=i.games.length>0&&s.has("games");v.useEffect(()=>{if(!d)return;let p=!0;return e.connection.call("games/list",{}).then(g=>{p&&l(g.games)},()=>{}),()=>{p=!1}},[e,d,i]);const h=v.useMemo(()=>({games:i.games.map(p=>o.find(g=>g.id===p||oi(g.name)===oi(p)||g.aliases.some(x=>oi(x)===oi(p)))??{id:p,name:p,aliases:[]}),scripts:i.scripts}),[i,o]),m=[...h.games.map(p=>`「${p.name}」`),...(h.scripts??[]).map(p=>`「${p}」`)].join("");return n.jsx(r1,{client:e,target:h,label:m})}function U3({client:e,sessionId:t,reminder:s,initialPrompt:i,onInitialSent:r,child:o}){const l=Fc(e,t);return l===null?n.jsx("div",{className:"main empty",children:"正在打开会话…"}):n.jsx(pz,{sessionId:l.id,children:n.jsx(B3,{client:e,session:l,reminder:s,initialPrompt:i,onInitialSent:r,child:o})},l.id)}function B3({client:e,session:t,reminder:s,initialPrompt:i,onInitialSent:r,child:o}){const l=Se(t.state),u=Se(e.connection.status),d=$i(e),h=Se(e.sessions).items.find(A=>A.id===t.id),m=h===void 0?wn:cS(h,d),p=d.find(A=>A.id===m),g=p===void 0?cn:Ka(p),x=gO(kO(e),l),[k,b]=v.useState(()=>G3()),j=x.find(A=>A.id===k)??x[0];v.useEffect(()=>K3(k),[k]);const w=Z3(),S=w.openTask;v.useEffect(()=>{o&&S({id:o,label:"子任务"})},[o,S]);const _=WS(e,t.id),E=_.filter(A=>A.running).length,M=w.panel==="tasks"||w.panel==="commands",O=v.useMemo(()=>M?rh(l.events,l.live,l.pending):H3,[M,l.events,l.live,l.pending,l.version]),B=v.useMemo(()=>OS(l.events),[l.events]),U=v.useMemo(()=>ZS(O,B),[O,B]),P=v.useMemo(()=>LS(O,B),[O,B]),R=v.useMemo(()=>YS(O),[O]),z=v.useMemo(()=>({openTask:w.openTask}),[w.openTask]),L=n.jsxs("div",{className:"title-tools in-title-bar",role:"toolbar","aria-label":"侧栏",children:[GS.filter(A=>A.id!=="browser"||w.bridge!==void 0).map(A=>{const T=w.panel===A.id,H=A.id==="tasks"&&E>0?`子任务:${E} 个进行中`:A.id==="browser"&&w.working?"agent 正在操作内置浏览器":A.hint;return n.jsxs("button",{type:"button",className:`side-icon${T?" active":""}`,"aria-pressed":T,"aria-label":A.title,title:H,onClick:()=>w.setPanel(T?null:A.id),children:[n.jsx(ee,{name:A.icon}),A.id==="tasks"&&E>0&&n.jsx("span",{className:"side-icon-badge",children:E}),A.id==="browser"&&w.working&&n.jsx("span",{className:"side-icon-dot"})]},A.id)}),n.jsx(q3,{views:x,onSelect:b})]});return n.jsxs("section",{className:"main",children:[qa.createPortal(L,document.body),l.error!==null&&n.jsx("div",{className:"banner error",children:l.error}),n.jsxs("div",{className:`session-body${w.panel!==null?" with-side":""}`,children:[n.jsxs("div",{className:"session-column",children:[n.jsxs("div",{className:"view",children:[j!==void 0&&x[0]!==void 0&&j.id!==x[0].id&&n.jsxs("div",{className:"view-back",children:[n.jsxs("button",{type:"button",className:"small-button",onClick:()=>b(x[0].id),children:[n.jsx(ee,{name:"back"}),"返回",x[0].title]}),n.jsx("span",{className:"view-back-title",children:j.title})]}),j===void 0?n.jsx("div",{className:"empty",children:"当前连接没有提供可用的视图插件。"}):n.jsx(Jp.Provider,{value:z,children:n.jsx(j.component,{client:e,session:t,state:l})})]}),n.jsx(Oz,{client:e,session:t,running:l.running,disabled:u.state!=="open",initialPrompt:i,onInitialSent:r,reminder:s}),n.jsx(F3,{client:e,sessionId:t.id})]}),w.panel!==null&&n.jsx("div",{className:`side-slot side-${w.panel}`,children:w.panel==="browser"&&w.bridge!==void 0?n.jsx(cz,{bridge:w.bridge,onClose:()=>w.setPanel(null)}):w.panel==="tasks"&&w.task!==null?n.jsx(Jp.Provider,{value:z,children:n.jsx(vx,{client:e,task:w.task,parent:g.name,trail:m===wn?[]:[cn.name],onClose:()=>w.openTask(null)},w.task.id)}):w.panel==="tasks"?n.jsx(fk,{title:"子任务",onClose:()=>w.setPanel(null),children:n.jsx(e3,{tasks:_,labels:U,settled:P,onOpen:w.openTask})}):n.jsx(fk,{title:"命令",onClose:()=>w.setPanel(null),children:n.jsx(s3,{client:e,own:R,tasks:_,labels:U})})})]})]})}const H3=[];function Z3(){var k;const e=(k=Vs())==null?void 0:k.browser,[t,s]=v.useState(()=>V3()),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=b=>{u.current==="browser"&&b!=="browser"&&(l.current=Date.now()),s(b),o(null),Ak(b)},h=v.useMemo(()=>b=>{o(b),b!==null&&(s("tasks"),Ak("tasks"))},[]),[m,p]=v.useState(0);v.useEffect(()=>{if(e===void 0)return;let b;return e.onChange(j=>{const w=b!==void 0&&j.agentAt>b;b=j.agentAt,p(j.agentAt),w&&u.current===null&&Date.now()-l.current>W3&&s("browser")})},[e]);const g=Date.now()-m<Ck,[,x]=v.useState(0);return v.useEffect(()=>{if(!g)return;const b=setTimeout(()=>x(j=>j+1),m+Ck-Date.now()+50);return()=>clearTimeout(b)},[g,m]),{bridge:e,panel:i,setPanel:d,task:i==="tasks"?r:null,openTask:h,working:g}}const a1="adg.sidePanel",W3=3*6e4,Ck=5e3;function V3(){try{const e=localStorage.getItem(a1);return e===null?localStorage.getItem("adg.browserPanel")==="1"?"browser":null:GS.some(t=>t.id===e)?e:null}catch{return null}}function Ak(e){try{localStorage.setItem(a1,e??"")}catch{}}function q3({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 o1="adg.sessionTab";function G3(){try{return localStorage.getItem(o1)??"chat"}catch{return"chat"}}function K3(e){try{localStorage.setItem(o1,e)}catch{}}const l1="adg.theme",rg=new Set;let hc=Y3();function Y3(){try{const e=localStorage.getItem(l1);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function c1(){var e,t;hc==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=hc,(t=(e=Vs())==null?void 0:e.setTheme)==null||t.call(e,hc).catch(()=>{})}function X3(e){hc=e;try{localStorage.setItem(l1,e)}catch{}c1();for(const t of rg)t()}function u1(){return v.useSyncExternalStore(e=>(rg.add(e),()=>rg.delete(e)),()=>hc)}const Q3={"api-keys":"key",permissions:"shield",plugins:"plug","script-install":"package",emulators:"monitor",schedule:"calendar",feishu:"send",compaction:"compress",memory:"archive",about:"info"},J3=[["light","浅色"],["dark","深色"],["system","跟随系统"]];function e5({client:e,onClose:t,section:s,onSection:i}){const r=jO(e),o=u1(),[l,u]=v.useState(null),d=l??s??null,h=p=>{u(p),i==null||i(p)},m=r.find(p=>p.id===d)??r[0];return n.jsxs(n.Fragment,{children:[n.jsxs("aside",{className:"sidebar settings-sidebar",children:[n.jsxs("button",{className:"nav-item back-link",onClick:t,children:[n.jsx(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===(m==null?void 0:m.id)?"active":""}`,"aria-current":p.id===(m==null?void 0:m.id)?"page":void 0,onClick:()=>h(p.id),children:[n.jsx(ee,{name:Q3[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:J3.map(([p,g])=>n.jsx("button",{role:"radio","aria-checked":o===p,className:o===p?"active":"",onClick:()=>X3(p),children:g},p))})]})]}),n.jsx("section",{className:"main settings",children:n.jsx("div",{className:"settings-content",children:m===void 0?n.jsx("div",{className:"empty",children:"当前连接没有提供可配置的项目。"}):n.jsx(m.component,{client:e})})})]})}const t5=["日","一","二","三","四","五","六"],n5=[1,2,3,4,5,6,0],Vf=[1,2,3,4,5],qf=[0,6],s5={[wn]:[{title:"早上说说今天要做什么",prompt:"看看今天有哪些活动快结束、哪些日常还没做,整理成几句话告诉我。"}],games:[{title:"看三天内结束的活动",prompt:"查各个游戏今天和三天内结束的活动,列出名字、所属游戏和剩余时间;已经做完的不用列。"},{title:"看新版本和公告",prompt:"看各个游戏最近一天的新版本、维护和重要公告,有变化的用一两句话说明,没有就说没有。"}],scripts:[{title:"检查脚本有没有新版本",prompt:"检查已安装的脚本有没有新版本,有的话说明更新了什么;先不要安装。"}],intervene:[{title:"汇总夜里的异常",prompt:"汇总最近 12 小时运行里出过的异常:哪些已经自动处理了,哪些还要我管、该怎么做。"}],pipelines:[{title:"检查流水线跑得怎么样",prompt:"看看各条流水线最近一次运行是否成功,失败的说明卡在哪一步、可能的原因。"}]};function Mo(e,t){if(!e.enabled)return;const s=new Date(t);s.setHours(0,0,0,0);for(let i=0;i<8;i++,s.setDate(s.getDate()+1)){if(e.days.length>0&&!e.days.includes(s.getDay()))continue;const r=e.times.map(o=>{const[l,u]=o.split(":").map(Number);return new Date(s.getFullYear(),s.getMonth(),s.getDate(),l,u).getTime()}).filter(o=>o>t).sort((o,l)=>o-l);if(r[0]!==void 0)return r[0]}}const Zc=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"});function i5(e){const t=Se(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 r5(e){const t=Se(e.connection.status),s=Se(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 a5(e){const t=Se(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 o5(e){const t=Se(e.connection.status),s=Se(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 d1(e){const t=$i(e);return v.useMemo(()=>[cn,...t.map(Ka)],[t])}function mc({agent:e,size:t="small"}){return n.jsx("span",{className:`agent-avatar ${t} agent-${(e==null?void 0:e.id)??"unknown"}`,children:n.jsx(ee,{name:(e==null?void 0:e.icon)??"sparkles"})})}function l5({client:e,focus:t,agent:s}){const i=d1(e),{items:r,error:o}=i5(e),l=r5(e),u=a5(e),d=o5(e),h=vn(3e4),[m,p]=v.useState(s??null),[g,x]=v.useState(null),[k,b]=v.useState(void 0),j=v.useRef(null),w=v.useRef(void 0),S=u.filter(P=>P.schedule.enabled&&P.draft!==!0),_=(d==null?void 0:d.schedule.enabled)===!0?d:null,E=new Map(i.map(P=>[P.id,0]));for(const P of r??[])E.set(P.agent,(E.get(P.agent)??0)+1);for(const P of l)E.set(P.agent,(E.get(P.agent)??0)+1);E.set("pipelines",(E.get("pipelines")??0)+S.length),_!==null&&E.set("games",(E.get("games")??0)+1);const M=[...E.values()].reduce((P,R)=>P+R,0),O=i.filter(P=>m===null||P.id===m);v.useEffect(()=>{s!==void 0&&p(s)},[s]),v.useEffect(()=>{var R,z;if(t===void 0||w.current===t)return;const P=((R=r==null?void 0:r.find(L=>L.id===t))==null?void 0:R.agent)??((z=l.find(L=>L.id===t))==null?void 0:z.agent);P!==void 0&&(w.current=t,p(L=>L===null||L===P?L:null),b(t))},[t,r,l]),v.useEffect(()=>{var z;if(k===void 0)return;const P=(z=j.current)==null?void 0:z.querySelector(`[data-schedule-id="${CSS.escape(k)}"]`);if(P==null)return;P.scrollIntoView({block:"center",behavior:"smooth"});const R=setTimeout(()=>b(void 0),2600);return()=>clearTimeout(R)},[k]);const B=v.useMemo(()=>[..._===null?[]:[{key:"daily-report",agent:"games",title:"每日日报",at:Mo(_.schedule,h)}],...(r??[]).map(P=>({key:P.id,agent:P.agent,title:P.title,at:Mo(P.schedule,h)})),...S.map(P=>({key:P.id,agent:"pipelines",title:`流水线「${P.name}」`,at:Mo(P.schedule,h)})),...l.map(P=>({key:P.id,agent:P.agent,title:`提醒:${P.title}`,at:P.next}))].filter(P=>P.at!==void 0&&(m===null||P.agent===m)).sort((P,R)=>P.at-R.at).slice(0,8),[r,l,S,_,h,m]),U=P=>{var R;x({kind:"new",agent:P}),(R=j.current)==null||R.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:"定时任务"}),M>0&&n.jsx("span",{className:"tab-count",children:M})]}),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:()=>U(m??wn),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($k,{client:e,agents:i,task:{agent:g.agent},onDone:()=>x(null)}),n.jsxs("div",{className:"schedule-filter",role:"group","aria-label":"只看谁的",children:[n.jsxs("button",{className:`agent-chip ${m===null?"on":""}`,"aria-pressed":m===null,onClick:()=>p(null),children:["全部",n.jsx("span",{className:"tab-count",children:M})]}),i.map(P=>n.jsxs("button",{className:`agent-chip ${m===P.id?"on":""}`,"aria-pressed":m===P.id,onClick:()=>p(m===P.id?null:P.id),children:[n.jsx(mc,{agent:P}),P.name,n.jsx("span",{className:"tab-count",children:E.get(P.id)??0})]},P.id))]}),n.jsxs("section",{className:"schedule-group",children:[n.jsx("h3",{children:"接下来"}),B.length===0&&n.jsx("p",{className:"muted small",children:"一周内没有要按时做的事。"}),n.jsx("ol",{className:"schedule-timeline",children:B.map(P=>{const R=i.find(z=>z.id===P.agent);return n.jsxs("li",{children:[n.jsx("span",{className:"schedule-when",children:Zc(P.at)}),n.jsx(mc,{agent:R}),n.jsx("span",{className:"schedule-who",children:(R==null?void 0:R.name)??"?"}),n.jsx("span",{className:"schedule-what",children:P.title})]},`${P.key}@${P.at}`)})})]}),O.map(P=>{const R=(r??[]).filter(H=>H.agent===P.id),z=l.filter(H=>H.agent===P.id),L=P.id==="pipelines"?S:[],A=P.id==="games"?_:null,T=R.length===0&&z.length===0&&L.length===0&&A===null;return T&&m!==P.id?null:n.jsxs("section",{className:"schedule-group",children:[n.jsxs("h3",{className:"schedule-agent",children:[n.jsx(mc,{agent:P}),P.name,n.jsx("span",{className:"tab-count",children:R.length+z.length+L.length+(A===null?0:1)}),n.jsx("span",{className:"spacer"}),n.jsxs("button",{className:"link-button",onClick:()=>U(P.id),children:[n.jsx(ee,{name:"plus"}),"给",P.name,"新建"]})]}),T&&n.jsxs("div",{className:"empty-card muted",children:[P.name,"还没有定时任务。"]}),A!==null&&n.jsx(c5,{report:A,now:h}),R.map(H=>(g==null?void 0:g.kind)==="edit"&&g.id===H.id?n.jsx($k,{client:e,agents:i,task:H,onDone:()=>x(null)},H.id):n.jsx(m5,{client:e,task:H,now:h,lit:k===H.id,onEdit:()=>x({kind:"edit",id:H.id})},H.id)),z.length>0&&n.jsxs("p",{className:"muted small schedule-sub",children:[P.name,"在对话里自己设的提醒:你让它「几点提醒我…」时设的,到点它在对话里接着做。要改时间,直接跟它说。"]}),z.map(H=>n.jsx(d5,{client:e,reminder:H,now:h,lit:k===H.id},H.id)),L.map(H=>n.jsx(u5,{pipeline:H,now:h},H.id))]},P.id)}),r!==null&&M===0&&g===null&&m===null&&n.jsx("div",{className:"empty-card muted",children:"还没有定时任务。点「新建定时任务」,选一个 agent、写下到点要它做的事。"})]})]})}function c5({report:e,now:t}){const s=Mo(e.schedule,t);return n.jsxs("a",{className:"task-card pipeline-line",href:"#/p/daily-report",title:"在游戏的「日报」里设置",children:[n.jsx(ee,{name:"send"}),n.jsx("span",{className:"task-title",children:"每日日报"}),n.jsxs("span",{className:"muted small",children:[Hg(e.schedule),s===void 0?"":` · 下次 ${Zc(s)}`," · 发到飞书"]}),n.jsx("span",{className:"muted small daily-report-where",children:"在游戏的「日报」里设置"}),n.jsx(ee,{name:"chevron"})]})}function u5({pipeline:e,now:t}){const s=Mo(e.schedule,t);return n.jsxs("a",{className:"task-card pipeline-line",href:`#/p/pipelines/${encodeURIComponent(e.id)}`,children:[n.jsx(ee,{name:"flow"}),n.jsx("span",{className:"task-title",children:e.name}),n.jsxs("span",{className:"muted small",children:[Hg(e.schedule),s===void 0?"":` · 下次 ${Zc(s)}`]}),n.jsx(ee,{name:"chevron"})]})}function d5({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?"下次 ":"",Zc(t.next),t.next>s?`(${h5(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 h5(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 m5({client:e,task:t,now:s,lit:i,onEdit:r}){const[o,l]=v.useState(null),u=Mo(t.schedule,s),d=t.lastRun,h=g=>{l(null),e.connection.call(g,{id:t.id}).catch(x=>l(Ce(x)))},m=()=>{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:[Hg(t.schedule),u===void 0?"":` · 下次 ${Zc(u)}`]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>h("tasks/run"),disabled:(d==null?void 0:d.state)==="running",title:"现在就交给它做一次",children:(d==null?void 0:d.state)==="running"?"在做":"立即运行"}),n.jsx("button",{className:"small-button",onClick:m,children:t.schedule.enabled?"暂停":"开启"}),n.jsx("button",{className:"icon-button",onClick:r,title:"修改","aria-label":"修改",children:n.jsx(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"?"正在做":`${vt(d.endedAt??d.startedAt,s)}${d.state==="done"?"做完":"没做成"}`,d.outcome===void 0?"":`:${d.outcome.split(`
216
+ `)[0]}`]})]}),o!==null&&n.jsx("div",{className:"error small",children:o})]})}function $k({client:e,agents:t,task:s,onDone:i}){var O,B;const[r,o]=v.useState(s.agent),[l,u]=v.useState(s.title??""),[d,h]=v.useState(s.prompt??""),[m,p]=v.useState((((O=s.schedule)==null?void 0:O.times)??["09:00"]).join(", ")),[g,x]=v.useState(((B=s.schedule)==null?void 0:B.days)??[]),[k,b]=v.useState(!1),[j,w]=v.useState(null),S=t.find(U=>U.id===r)??cn,_=s5[r]??[],E=(U,P)=>U.length===P.length&&U.every(R=>P.includes(R)),M=async()=>{var U,P;b(!0),w(null);try{const R=m.split(/[,,、\s]+/).filter(z=>z!=="").map(z=>/^\d:\d\d$/.test(z)?`0${z}`:z);await e.connection.call("tasks/save",{task:{...s.id===void 0?{}:{id:s.id},agent:r,title:l,prompt:d,schedule:{enabled:((U=s.schedule)==null?void 0:U.enabled)??!0,times:R,days:[...g],catchUpMinutes:((P=s.schedule)==null?void 0:P.catchUpMinutes)??10}}}),i()}catch(R){w(Ce(R))}finally{b(!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(U=>n.jsxs("button",{type:"button",role:"radio","aria-checked":U.id===r,className:`agent-pick-item ${U.id===r?"on":""}`,onClick:()=>o(U.id),title:U.description,children:[n.jsx(mc,{agent:U,size:""}),n.jsxs("span",{className:"agent-pick-text",children:[n.jsx("span",{className:"agent-pick-name",children:U.name}),n.jsx("span",{className:"agent-pick-desc",children:U.description})]})]},U.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:["要",S.name,"做什么"]}),_.length>0&&n.jsxs("div",{className:"task-examples",children:[n.jsx("span",{className:"muted small",children:"可以从这里开始:"}),_.map(U=>n.jsx("button",{type:"button",className:"example-chip",onClick:()=>{u(U.title),h(U.prompt)},children:U.title},U.title))]}),n.jsxs("label",{className:"field-label",children:["名字",n.jsx("input",{className:"text-input plain",value:l,maxLength:60,onChange:U=>u(U.target.value),placeholder:"例如:看今天结束的活动"})]}),n.jsxs("label",{className:"field-label",children:["交给它的话",n.jsx("textarea",{className:"text-input plain",rows:3,value:d,maxLength:4e3,onChange:U=>h(U.target.value),placeholder:"写完整:要做什么、要交回什么"})]})]}),n.jsxs("div",{className:"task-form-step",children:[n.jsx("span",{className:"task-form-label",children:"什么时候"}),n.jsxs("div",{className:"task-form-row",children:[n.jsxs("label",{className:"field-label",children:["时间",n.jsx("input",{className:"text-input plain-mono",value:m,onChange:U=>p(U.target.value),placeholder:"09:00, 21:30"})]}),n.jsxs("div",{className:"field-label",children:["星期",n.jsxs("div",{className:"day-chips",children:[n.jsx("button",{type:"button",className:`day-preset ${g.length===0?"on":""}`,"aria-pressed":g.length===0,onClick:()=>x([]),children:"每天"}),n.jsx("button",{type:"button",className:`day-preset ${E(g,Vf)?"on":""}`,"aria-pressed":E(g,Vf),onClick:()=>x(Vf),children:"工作日"}),n.jsx("button",{type:"button",className:`day-preset ${E(g,qf)?"on":""}`,"aria-pressed":E(g,qf),onClick:()=>x(qf),children:"周末"}),n.jsx("span",{className:"day-chips-gap"}),n5.map(U=>n.jsx("button",{type:"button",className:`day-chip ${g.includes(U)?"on":""}`,"aria-pressed":g.includes(U),onClick:()=>x(g.includes(U)?g.filter(P=>P!==U):[...g,U]),children:t5[U]},U))]})]})]})]}),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:k,children:"取消"}),n.jsx("button",{className:"small-button primary",onClick:()=>void M(),disabled:k||l.trim()===""||d.trim()==="",children:s.id===void 0?`交给${S.name}`:"保存"})]})]})}function f5({client:e,onOpen:t}){const s=d1(e),[i,r]=v.useState([]),o=v.useRef(0);if(v.useEffect(()=>e.connection.on("schedule/agentSet",u=>{const d=o.current++;r(h=>[...h.slice(-2),{...u,key:d}]),setTimeout(()=>r(h=>h.filter(m=>m.key!==d)),2e4)}),[e]),i.length===0)return null;const l=u=>r(d=>d.filter(h=>h.key!==u));return n.jsx("div",{className:"schedule-notices","aria-live":"polite",children:i.map(u=>{const d=s.find(p=>p.id===u.by),h=s.find(p=>p.id===u.agent),m=u.kind==="task"?u.changed?"改了一个定时任务":"设了一个定时任务":"设了一个提醒";return n.jsxs("div",{className:"schedule-notice",role:"status",children:[n.jsx(mc,{agent:d,size:""}),n.jsxs("div",{className:"schedule-notice-text",children:[n.jsxs("span",{className:"schedule-notice-head",children:[(d==null?void 0:d.name)??"agent",m]}),n.jsx("span",{className:"schedule-notice-title",children:u.title}),n.jsxs("span",{className:"muted small",children:[u.kind==="task"&&u.agent!==u.by?`交给${(h==null?void 0:h.name)??u.agent}`:"",u.kind==="task"&&u.agent!==u.by&&u.when!==""?" · ":"",u.when]}),n.jsx("span",{className:"schedule-notice-actions",children:n.jsxs("button",{className:"small-button primary",onClick:()=>{l(u.key),t(u.id)},children:[n.jsx(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 p5=["切换到 dsh 官方界面:DeepSeek Harness 自带的原版界面,没有 MultiGameAssistant 的脚本、编排、游戏等功能。","","· 它是另一个独立的 dsh:聊天记录、设置和模型密钥都和这里分开,第一次用要在那边重新填模型密钥;","· 第一次切换要启动它,可能要等一会儿;","· 这边的定时任务和脚本在后台照常运行。","","点标题栏左上角的「返回 MultiGameAssistant」切回来。"].join(`
217
+ `),h1="adg.officialIntro";function g5(){var l;const e=(l=Vs())==null?void 0:l.uiMode,[t,s]=v.useState(null);if(v.useEffect(()=>{if(e===void 0)return;let u=!0;e.state().then(h=>{u&&s(h)},()=>{});const d=e.onChange(s);return()=>{u=!1,d()}},[e]),e===void 0||t===null)return null;const i=t.mode==="official",r=()=>{if(i){e.set("adg");return}const u=()=>{v5(),e.set("official")};if(x5()){u();return}Ms({title:"切换到 dsh 官方界面?",message:p5,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 x5(){try{return localStorage.getItem(h1)==="1"}catch{return!1}}function v5(){try{localStorage.setItem(h1,"1")}catch{}}const ag="adg.token",fh=/^\/adg(\/|$)/.test(location.pathname);function y5(){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 b5(){const e=new URL(location.href),t=e.searchParams.get("token");if(t!==null&&t!==""){try{sessionStorage.setItem(ag,t)}catch{}return e.searchParams.delete("token"),history.replaceState(history.state,"",e),t}let s=null;try{s=sessionStorage.getItem(ag)}catch{}return s??null}function k5(e){try{sessionStorage.setItem(ag,e)}catch{}}function j5(e){if(fh){const s=new URL(y5()??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 Ik(){if(location.hash==="#/settings")return{kind:"settings"};const e=/^#\/settings\/(.+)$/.exec(location.hash);if(e!==null)return{kind:"settings",section:decodeURIComponent(e[1])};if(location.hash==="#/p/games/report")return{kind:"page",id:"daily-report"};const t=/^#\/p\/([^/]+)(?:\/(.+))?$/.exec(location.hash);if(t!==null)return{kind:"page",id:decodeURIComponent(t[1]),...t[2]===void 0?{}:{arg:decodeURIComponent(t[2])}};if(location.hash==="#/chat")return{kind:"home"};if(location.hash==="#/schedule")return{kind:"schedule"};const s=/^#\/schedule\/(.+)$/.exec(location.hash);if(s!==null)return{kind:"schedule",focus:decodeURIComponent(s[1])};const i=/^#\/a\/(.+)\/schedule$/.exec(location.hash);if(i!==null)return{kind:"schedule",agent:decodeURIComponent(i[1])};const r=/^#\/h\/(.+)$/.exec(location.hash);if(r!==null)return{kind:"handoff",id:decodeURIComponent(r[1])};const o=/^#\/a\/([^/]+)\/task\/([^/]+)$/.exec(location.hash);if(o)return{kind:"agent",id:decodeURIComponent(o[1]),child:decodeURIComponent(o[2])};const l=/^#\/a\/(.+)\/(history)$/.exec(location.hash);if(l!==null)return{kind:"agent",id:decodeURIComponent(l[1])};const u=/^#\/a\/(.+)$/.exec(location.hash);if(u!==null)return{kind:"agent",id:decodeURIComponent(u[1])};const d=/^#\/s\/(.+)$/.exec(location.hash);return d===null?{kind:"start"}:{kind:"session",id:decodeURIComponent(d[1])}}function N5(e,t="push"){const s=e.kind==="session"?`#/s/${encodeURIComponent(e.id)}`:e.kind==="agent"?`#/a/${encodeURIComponent(e.id)}${e.child===void 0?"":`/task/${encodeURIComponent(e.child)}`}`:e.kind==="handoff"?`#/h/${encodeURIComponent(e.id)}`:e.kind==="schedule"?e.focus===void 0?"#/schedule":`#/schedule/${encodeURIComponent(e.focus)}`:e.kind==="page"?`#/p/${encodeURIComponent(e.id)}${e.arg===void 0?"":`/${encodeURIComponent(e.arg)}`}`:e.kind==="settings"?e.section===void 0?"#/settings":`#/settings/${encodeURIComponent(e.section)}`:e.kind==="home"?"#/chat":"";if(location.hash===s)return;const i=`${location.pathname}${location.search}${s}`;t==="replace"?history.replaceState(history.state,"",i):history.pushState(null,"",i)}const Gf="games";function w5({client:e}){const[t,s]=v.useState(()=>Ik()),[i,r]=iz(),[o,l]=v.useState(null),u=Se(e.sessions),d=NO(e),h=Se(e.connection.status),m=$i(e),p=v.useRef(!1),g=v.useRef(null);v.useEffect(()=>{N5(t,p.current?"replace":"push"),p.current=!1,t.kind!=="handoff"&&(g.current=t)},[t]);const x=t.kind==="handoff"?t:null,k=g.current,b=x===null?t:k!==null&&k.kind!=="settings"?k:{kind:"agent",id:wn};v.useEffect(()=>{const V=()=>s(Ik());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 D=setTimeout(V,8e3);return()=>clearTimeout(D)},[t,u]);const w=V=>{const D=u.items.find(te=>te.id===V);if(D===void 0)return;const q=Kp(D,new Map(u.items.map(te=>[te.id,te])));return q.home??q.role??wn};v.useEffect(()=>{if(t.kind!=="session")return;const V=u.items.find(D=>D.id===t.id);V&&(p.current=!0,s({kind:"agent",id:w(V.id),...V.origin==="subagent"?{child:V.id}:{}}))},[t,u]),v.useEffect(()=>{t.kind!=="start"||h.state!=="open"||(p.current=!0,s(d.some(V=>V.id===Gf)?{kind:"page",id:Gf}:{kind:"home"}))},[t,h.state,d]);const S=V=>s({kind:"session",id:V}),_=V=>s({kind:"settings",...V===void 0?{}:{section:V}}),E=V=>s({kind:"page",id:V}),M=b.kind==="start"?{kind:"page",id:Gf}:b,O=M.kind==="page"?d.find(V=>V.id===M.id):void 0,B=V=>V.agent===void 0?void 0:m.some(D=>D.id===V.agent)?V.agent:wn,U=O===void 0?void 0:B(O),P=V=>s({kind:"agent",id:V}),R=()=>P(wn),z=n.jsxs(n.Fragment,{children:[n.jsx(E5,{client:e,onSettings:()=>_("api-keys")}),n.jsx(RO,{client:e})]}),L=b.kind==="home"?wn:b.kind==="agent"?b.id:U,A=(V,D)=>s(D==="chat"?{kind:"agent",id:V}:{kind:"page",id:D}),T=b.kind==="settings"?{kind:"settings"}:b.kind==="schedule"?{kind:"schedule"}:L!==void 0?{kind:"agent",id:L}:M.kind==="page"?{kind:"page",id:M.id}:{kind:"none"},H=O===void 0?null:n.jsx(O.component,{client:e,openSession:S,openSettings:_,openPage:E,arg:M.kind==="page"?M.arg:void 0},O.id),F=L===void 0?null:n.jsx(S5,{client:e,agentId:L,pages:d.filter(V=>B(V)===L),current:M.kind==="page"?M.id:"chat",onTab:V=>A(L,V)});return n.jsx(hS.Provider,{value:o,children:n.jsx(lz.Provider,{value:i>=To,children:n.jsxs("div",{className:`app ${b.kind==="settings"?"with-sidebar":""}`,style:{"--rail-width":`${i}px`},children:[n.jsx(nz,{client:e,pages:d.filter(V=>V.agent===void 0),current:T,onAgent:P,onPage:E,onSchedule:()=>s({kind:"schedule"}),onSettings:()=>_(),width:i,onWidth:r,slot:l}),b.kind==="settings"&&n.jsx(e5,{client:e,onClose:R,section:b.section,onSection:V=>s({kind:"settings",section:V})}),b.kind!=="settings"&&n.jsxs("div",{className:`app-main ${x===null?"":"under-exchange"}`,children:[M.kind==="page"&&U===void 0&&(H??n.jsx("section",{className:"main empty",children:h.state==="open"?"当前连接没有提供这个功能。":"正在连接…"})),L!==void 0&&n.jsxs("div",{className:"agent-area",children:[F,U!==void 0?H:n.jsx(_5,{client:e,agentId:L,onMain:R,child:b.kind==="agent"?b.child:void 0,reminder:z},L)]}),b.kind==="schedule"&&n.jsx(l5,{client:e,focus:b.focus,agent:b.agent}),b.kind==="session"&&n.jsx("section",{className:"main empty",children:"正在打开助手对话…"}),x!==null&&n.jsx(fD,{client:e,id:x.id,onClose:()=>s(b)},x.id)]}),n.jsx(GL,{client:e,isHere:V=>L!==void 0&&w(V)===L,onSelect:S}),n.jsx(f5,{client:e,onOpen:V=>s({kind:"schedule",...V===void 0?{}:{focus:V}})}),n.jsx(g5,{})]})})})}function S5({client:e,agentId:t,pages:s,current:i,onTab:r}){const l=$i(e).find(m=>m.id===t),u=l===void 0?cn:Ka(l),d=[{id:"chat",title:"对话",icon:"chat"},...[...s].sort((m,p)=>m.order-p.order).map(m=>({id:m.id,title:m.title,icon:m.icon}))];if(d.length===1)return null;const h=n.jsx("nav",{className:"agent-tabs in-title-bar",role:"tablist","aria-label":u.name,children:d.map(m=>n.jsxs("button",{role:"tab","aria-selected":m.id===i,className:m.id===i?"active":"",onClick:()=>r(m.id),children:[n.jsx(ee,{name:m.icon}),m.title]},m.id))});return qa.createPortal(h,document.body)}function _5({client:e,agentId:t,onMain:s,child:i,reminder:r}){const{sessionId:o,error:l}=dS(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(U3,{client:e,sessionId:o,child:i,reminder:r},o)}function E5({client:e,onSettings:t}){var o;const{items:s}=yw(e,[Ip]),{catalog:i}=aa(e),r=(i==null?void 0:i.groups.some(l=>l.id!=="deepseek-official"&&l.models.length>0))??!1;return((o=s==null?void 0:s[Ip])==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 C5({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(Xg,{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 A5=["准备环境","启动服务","载入界面","连接 agent"],$5=8e3,I5=400;function T5({client:e}){const t=Se(e.connection.status),s=Se(e.sessions),[i,r]=v.useState("shown"),[o,l]=v.useState(!1),u=t.state==="open"&&s.loaded;if(v.useEffect(()=>{const m=setTimeout(()=>l(!0),$5);return()=>clearTimeout(m)},[]),v.useEffect(()=>{u&&r(m=>m==="shown"?"leaving":m)},[u]),v.useEffect(()=>{if(i!=="leaving")return;const m=setTimeout(()=>r("gone"),I5);return()=>clearTimeout(m)},[i]),i==="gone")return null;const d=t.state==="open"?"正在读取对话":t.state==="reconnecting"?`连不上 agent,正在重试(第 ${t.attempt} 次)`:t.state==="connecting"?"正在连接 agent":"没有连上 agent",h=o?t.error!==void 0?`连接出错:${t.error}`:"比平时慢一些,agent 服务可能还在启动。":"";return n.jsxs("div",{className:`boot${i==="leaving"?" leaving":""}`,"aria-hidden":i==="leaving",children:[n.jsxs("div",{className:"boot-center",children:[n.jsxs("div",{className:"boot-mark","aria-hidden":"true",children:[n.jsxs("svg",{className:"boot-orbit",viewBox:"0 0 132 132",children:[n.jsx("circle",{className:"track",cx:"66",cy:"66",r:"62"}),n.jsx("circle",{className:"comet",cx:"66",cy:"66",r:"62"})]}),n.jsx("span",{className:"boot-tile",children:n.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9.5 8.3v7.4l6.2-3.7-6.2-3.7Z"}),n.jsx("path",{className:"loop",d:"M4 12a8 8 0 0 1 14.5-4.7M20 12a8 8 0 0 1-14.5 4.7"})]})})]}),n.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),n.jsx("p",{className:"boot-stage",role:"status","aria-live":"polite",children:n.jsx("span",{children:d})}),n.jsx("ol",{className:"boot-steps",children:A5.map((m,p)=>n.jsxs("li",{className:p<3?"done":"now",children:[n.jsx("i",{}),n.jsx("span",{children:m})]},m))}),n.jsx("p",{className:`boot-hint${h!==""?" shown":""}`,children:h}),o&&n.jsx("button",{type:"button",className:"boot-skip",onClick:()=>r("leaving"),children:"先进入界面"})]}),n.jsx("p",{className:"boot-foot",children:"日常交给 agent · 在本机运行"})]})}class M5 extends v.Component{constructor(){super(...arguments);mt(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}
218
+
219
+ ${(s.stack??"").split(`
220
+ `).slice(1,8).join(`
221
+ `)}`;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 R5=450,sd=6,Hl=8,Kf="data-tip";function O5(){return Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--title-bar"))||0}function P5(){const[e,t]=v.useState(null),s=v.useRef(null),[i,r]=v.useState(null);return v.useEffect(()=>{let o=null,l;const u=()=>{if(window.clearTimeout(l),l=void 0,o!==null){const m=o.getAttribute(Kf);o.removeAttribute(Kf),m!==null&&!o.hasAttribute("title")&&o.setAttribute("title",m)}o=null,t(null)},d=m=>{var x,k,b,j;if(m.pointerType==="touch")return;if(o!==null&&o.contains(m.target)){const w=(k=(x=m.target).closest)==null?void 0:k.call(x,"[title]");if(w==null||!o.contains(w))return}const p=((j=(b=m.target)==null?void 0:b.closest)==null?void 0:j.call(b,"[title]"))??null;if(p===o||(u(),p===null))return;const g=p.getAttribute("title")??"";g.trim()!==""&&(o=p,p.setAttribute(Kf,g),p.removeAttribute("title"),l=window.setTimeout(()=>{o===p&&p.isConnected&&t({text:g,anchor:p.getBoundingClientRect(),side:p.closest(".rail")!==null?"right":"auto"})},R5))},h=m=>{if(o===null)return;const p=m.relatedTarget;(p===null||!o.contains(p))&&u()};return document.addEventListener("pointerover",d,!0),document.addEventListener("pointerout",h,!0),document.addEventListener("pointerdown",u,!0),document.addEventListener("keydown",u,!0),window.addEventListener("scroll",u,!0),window.addEventListener("blur",u),()=>{u(),document.removeEventListener("pointerover",d,!0),document.removeEventListener("pointerout",h,!0),document.removeEventListener("pointerdown",u,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("scroll",u,!0),window.removeEventListener("blur",u)}},[]),v.useLayoutEffect(()=>{if(e===null||s.current===null){r(null);return}const{width:o,height:l}=s.current.getBoundingClientRect(),u=e.anchor,d=p=>Math.max(Hl,Math.min(p,window.innerHeight-l-Hl));if(e.side==="right"){r({left:u.right+sd,top:d(u.top+u.height/2-l/2),side:"right"});return}const h=u.top-sd-l<Hl+O5(),m=Math.max(Hl,Math.min(u.left+u.width/2-o/2,window.innerWidth-o-Hl));r({left:m,top:h?u.bottom+sd:u.top-sd-l,side:h?"below":"above"})},[e]),e===null?null:qa.createPortal(n.jsx("div",{ref:s,className:`app-tooltip ${(i==null?void 0:i.side)??""}`,role:"tooltip",style:i===null?{left:0,top:0,visibility:"hidden"}:{left:i.left,top:i.top},children:e.text}),document.body)}const L5={id:"chat",title:"对话",requires:["sessions","chat"],sessionViews:[{id:"chat",title:"对话",order:0,component:ES}]},z5=[],Yf=320,id=4;function Mt({value:e,options:t,onChange:s,id:i,disabled:r,placeholder:o="请选择",inline:l,className:u,...d}){const h=v.useId(),m=v.useRef(null),p=v.useRef(null),[g,x]=v.useState(!1),[k,b]=v.useState(-1),[j,w]=v.useState({}),S=t.findIndex(z=>z.value===e),_=S===-1?void 0:t[S],E=z=>t[z]!==void 0&&t[z].disabled!==!0,M=(z,L)=>{for(let A=z+L;A>=0&&A<t.length;A+=L)if(E(A))return A;return z},O=(z=S)=>{r!==!0&&(b(E(z)?z:M(-1,1)),x(!0))},B=(z=!0)=>{var L;x(!1),z&&((L=m.current)==null||L.focus())},U=z=>{E(z)&&(t[z].value!==e&&s(t[z].value),B())};v.useLayoutEffect(()=>{if(!g)return;const z=()=>{var V,D;const L=(V=m.current)==null?void 0:V.getBoundingClientRect();if(L===void 0)return;const A=window.innerHeight-L.bottom-id-8,T=L.top-id-8,H=A<Math.min(Yf,((D=p.current)==null?void 0:D.scrollHeight)??Yf)&&T>A,F=Math.max(L.width,180);w({left:Math.max(8,Math.min(L.left,window.innerWidth-F-8)),minWidth:F,maxWidth:Math.max(F,Math.min(520,window.innerWidth-16)),maxHeight:Math.min(Yf,H?T:A),...H?{bottom:window.innerHeight-L.top+id}:{top:L.bottom+id}})};return z(),window.addEventListener("resize",z),window.addEventListener("scroll",z,!0),()=>{window.removeEventListener("resize",z),window.removeEventListener("scroll",z,!0)}},[g]),v.useEffect(()=>{var L;if(!g)return;(L=p.current)==null||L.focus({preventScroll:!0});const z=A=>{var H,F;const T=A.target;!((H=p.current)!=null&&H.contains(T))&&!((F=m.current)!=null&&F.contains(T))&&B(!1)};return document.addEventListener("pointerdown",z,!0),()=>document.removeEventListener("pointerdown",z,!0)},[g]),v.useEffect(()=>{var z,L;g&&k>=0&&((L=(z=p.current)==null?void 0:z.querySelector(`[data-index="${k}"]`))==null||L.scrollIntoView({block:"nearest"}))},[g,k]);const P=z=>{(z.key==="ArrowDown"||z.key==="ArrowUp"||z.key==="Enter"||z.key===" ")&&(z.preventDefault(),O())},R=z=>{const A={ArrowDown:()=>b(T=>M(T,1)),ArrowUp:()=>b(T=>M(T,-1)),Home:()=>b(M(-1,1)),End:()=>b(M(t.length,-1)),Enter:()=>U(k)," ":()=>U(k),Escape:()=>B(),Tab:()=>B()}[z.key];if(A!==void 0){z.key!=="Tab"&&z.preventDefault(),A();return}if(z.key.length===1&&!z.ctrlKey&&!z.metaKey&&!z.altKey){const T=z.key.toLowerCase();for(let H=1;H<=t.length;H++){const F=(k+H)%t.length;if(E(F)&&t[F].label.toLowerCase().startsWith(T)){b(F);break}}}};return n.jsxs(n.Fragment,{children:[n.jsx("button",{ref:m,id:i,type:"button",disabled:r,className:`select-trigger text-input plain ${l===!0?"inline":""} ${g?"open":""} ${u??""}`,"aria-haspopup":"listbox","aria-expanded":g,"aria-controls":g?h:void 0,"aria-label":d["aria-label"],onClick:()=>g?B():O(),onKeyDown:P,children:n.jsx("span",{className:`select-value ${_===void 0?"placeholder":""}`,children:(_==null?void 0:_.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":k>=0?`${h}-${k}`:void 0,onKeyDown:R,children:[t.map((z,L)=>{var A;return n.jsxs("li",{role:"presentation",children:[z.group!==void 0&&z.group!==((A=t[L-1])==null?void 0:A.group)&&n.jsx("div",{className:"select-group",children:z.group}),n.jsxs("div",{id:`${h}-${L}`,"data-index":L,role:"option","aria-selected":L===S,"aria-disabled":z.disabled===!0,className:`select-option ${L===k?"active":""} ${L===S?"selected":""} ${z.disabled===!0?"disabled":""}`,onPointerMove:()=>{E(L)&&L!==k&&b(L)},onClick:()=>U(L),children:[n.jsxs("span",{className:"select-text",children:[n.jsx("span",{children:z.label}),z.hint!==void 0&&n.jsx("span",{className:"select-hint",children:z.hint})]}),L===S&&n.jsx(ee,{name:"check",className:"select-check"})]})]},`${z.group??""}\0${z.value}`)}),t.length===0&&n.jsx("li",{role:"presentation",className:"select-empty",children:"没有可选的"})]}),document.body)]})}const D5={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function F5({client:e}){const t=Se(e.connection.status),s=vn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(null),[u,d]=v.useState(0),[h,m]=v.useState(null),[p,g]=v.useState(null),[x,k]=v.useState(null),[b,j]=v.useState(""),[w,S]=v.useState(""),[_,E]=v.useState(""),[M,O]=v.useState(""),[B,U]=v.useState({});v.useEffect(()=>e.connection.on("notify/changed",()=>d(H=>H+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let H=!0;return e.connection.call("feishu/settings",{}).then(F=>{H&&(r(F),j(V=>V===""?F.settings.appId??"":V),E(V=>V===""?F.settings.chatId??"":V))}).catch(F=>{H&&g(Ce(F))}),e.connection.call("notify/status",{}).then(F=>{H&&l(F.channels.find(V=>V.id==="feishu")??null)}).catch(()=>{}),()=>{H=!1}},[e,t.state,u]);const P=async(H,F,V)=>{m(H),g(null),k(null);try{const D=await F();D!==null&&typeof D=="object"&&"settings"in D&&r(D),V!==void 0&&k(V),d(q=>q+1)}catch(D){g(Ce(D))}finally{m(null)}},R=()=>P("credentials",async()=>(w.trim()!==""&&await e.setCredential(MR,w.trim()),S(""),e.connection.call("feishu/settings/set",{appId:b.trim()===""?null:b.trim(),enabled:!0})),"已保存,正在连接…"),z=()=>P("test",async()=>{const H=await e.connection.call("notify/test",{channel:"feishu"});if(H.failed.length>0)throw new Error(H.failed.map(F=>F.error).join(";"))},"测试消息已发送,去飞书看看"),L=i==null?void 0:i.settings,[A,T]=D5[(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:T})]}),o!==null&&o.checks.length>0&&n.jsx("ul",{className:"check-list",children:o.checks.map(H=>n.jsxs("li",{className:H.ok===!0?"ok":H.ok===!1?"failed":"",children:[n.jsx("span",{className:"check-mark",children:H.ok===!0?"✓":H.ok===!1?"✗":"…"}),n.jsx("span",{children:H.label}),H.detail!==void 0&&n.jsx("span",{className:"muted small",children:H.detail})]},H.id))}),n.jsxs("div",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void P("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 z(),children:"发送测试消息"}),L!==void 0&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:L.enabled,disabled:h!==null,onChange:H=>void P("enable",()=>e.connection.call("feishu/settings/set",{enabled:H.target.checked}))}),"启用飞书"]})]})]}),L!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"应用凭证"}),n.jsx("label",{className:"field-label",htmlFor:"feishu-domain",children:"平台"}),n.jsx(Mt,{id:"feishu-domain",value:L.domain,disabled:h!==null,onChange:H=>void P("domain",()=>e.connection.call("feishu/settings/set",{domain:H})),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:b,onChange:H=>j(H.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:w,onChange:H=>S(H.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||b.trim()==="",onClick:()=>void R(),children:h==="credentials"?"保存中…":"保存并连接"})]})]}),L!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"允许的用户"}),n.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令、按卡片上的按钮;通知也发给他们。"}),L.allowedUsers.length===0&&n.jsx("div",{className:"muted small",children:"还没有。给机器人发一条消息,它会出现在下面的「待允许」里。"}),n.jsx("ul",{className:"version-list",children:L.allowedUsers.map(H=>n.jsxs("li",{children:[n.jsx("span",{children:H.name??"(未命名)"}),n.jsx("span",{className:"muted small",children:H.openId}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void P(`rm-${H.openId}`,()=>e.connection.call("feishu/users/remove",{openId:H.openId})),children:"移除"})]},H.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(H=>n.jsxs("li",{children:[n.jsx("span",{className:"muted small",children:H.openId}),n.jsxs("span",{className:"muted small",children:["「",H.text,"」 · ",vt(H.at,s)]}),n.jsx("span",{className:"spacer"}),n.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:B[H.openId]??"",onChange:F=>U(V=>({...V,[H.openId]:F.target.value}))}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void P(`dismiss-${H.openId}`,()=>e.connection.call("feishu/users/remove",{openId:H.openId})),children:"忽略"}),n.jsx("button",{className:"primary small-button",disabled:h!==null,onClick:()=>void P(`allow-${H.openId}`,()=>{var F;return e.connection.call("feishu/users/allow",{openId:H.openId,...(F=B[H.openId])!=null&&F.trim()?{name:B[H.openId].trim()}:{}})}),children:"允许"})]},H.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:M,onChange:H=>O(H.target.value),placeholder:"ou_xxxxxxxx",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:h!==null||M.trim()==="",onClick:()=>void P("manual",async()=>{const H=await e.connection.call("feishu/users/allow",{openId:M.trim()});return O(""),H}),children:"添加"})]})]}),L!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"通知"}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:L.otherApprovals,disabled:h!==null,onChange:H=>void P("approvals",()=>e.connection.call("feishu/settings/set",{otherApprovals:H.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:_,onChange:H=>E(H.target.value),placeholder:"oc_xxxxxxxx",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void P("chat",()=>e.connection.call("feishu/settings/set",{chatId:_.trim()===""?null:_.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 U5={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function B5({client:e}){const t=Se(e.connection.status),s=vn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(null),[u,d]=v.useState(0),[h,m]=v.useState(null),[p,g]=v.useState(null),[x,k]=v.useState(null),[b,j]=v.useState(""),[w,S]=v.useState(""),[_,E]=v.useState(""),[M,O]=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(T=>{A&&(r(T),j(H=>H===""?T.settings.appId??"":H))}).catch(T=>{A&&g(Ce(T))}),e.connection.call("notify/status",{}).then(T=>{A&&l(T.channels.find(H=>H.id==="qq")??null)}).catch(()=>{}),()=>{A=!1}},[e,t.state,u]);const B=async(A,T,H)=>{m(A),g(null),k(null);try{const F=await T();F!==null&&typeof F=="object"&&"settings"in F&&r(F),H!==void 0&&k(H),d(V=>V+1)}catch(F){g(Ce(F))}finally{m(null)}},U=()=>B("credentials",async()=>(w.trim()!==""&&await e.setCredential(RR,w.trim()),S(""),e.connection.call("qqbot/settings/set",{appId:b.trim()===""?null:b.trim(),enabled:!0})),"已保存,正在连接…"),P=()=>B("test",async()=>{const A=await e.connection.call("notify/test",{channel:"qq"});if(A.failed.length>0)throw new Error(A.failed.map(T=>T.error).join(";"))},"测试消息已发送,去 QQ 看看"),R=i==null?void 0:i.settings,[z,L]=U5[(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 ${z}`,children:L})]}),o!==null&&o.checks.length>0&&n.jsx("ul",{className:"check-list",children:o.checks.map(A=>n.jsxs("li",{className:A.ok===!0?"ok":A.ok===!1?"failed":"",children:[n.jsx("span",{className:"check-mark",children:A.ok===!0?"✓":A.ok===!1?"✗":"…"}),n.jsx("span",{children:A.label}),A.detail!==void 0&&n.jsx("span",{className:"muted small",children:A.detail})]},A.id))}),n.jsxs("div",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void B("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 P(),children:"发送测试消息"}),R!==void 0&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:R.enabled,disabled:h!==null,onChange:A=>void B("enable",()=>e.connection.call("qqbot/settings/set",{enabled:A.target.checked}))}),"启用 QQ 机器人"]})]})]}),R!==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:b,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:w,onChange:A=>S(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||b.trim()==="",onClick:()=>void U(),children:h==="credentials"?"保存中…":"保存并连接"})]})]}),R!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"允许的用户"}),n.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令;通知和与助手的对话也发给他们。"}),R.allowedUsers.length===0&&n.jsx("div",{className:"muted small",children:"还没有。在 QQ 里给机器人发一条消息,它会出现在下面的「待允许」里。"}),n.jsx("ul",{className:"version-list",children:R.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 B(`rm-${A.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:A.openId})),children:"移除"})]},A.openId))}),((i==null?void 0:i.pending.length)??0)>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),n.jsx("ul",{className:"version-list",children:i.pending.map(A=>n.jsxs("li",{children:[n.jsx("span",{className:"muted small",children:A.openId}),n.jsxs("span",{className:"muted small",children:["「",A.text,"」 · ",vt(A.at,s)]}),n.jsx("span",{className:"spacer"}),n.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:M[A.openId]??"",onChange:T=>O(H=>({...H,[A.openId]:T.target.value}))}),n.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void B(`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 B(`allow-${A.openId}`,()=>{var T;return e.connection.call("qqbot/users/allow",{openId:A.openId,...(T=M[A.openId])!=null&&T.trim()?{name:M[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:_,onChange:A=>E(A.target.value),placeholder:"机器人回复你的那条消息里有",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:h!==null||_.trim()==="",onClick:()=>void B("manual",async()=>{const A=await e.connection.call("qqbot/users/allow",{openId:_.trim()});return E(""),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 H5=[{id:"feishu",title:"飞书",capability:"feishu",component:F5},{id:"qq",title:"QQ 机器人",capability:"qqbot",component:B5}];function Z5({client:e}){var l;const t=Se(e.capabilities),s=H5.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 W5=(e,t)=>{try{const s=localStorage.getItem(`adg.fold.${e}`);return s===null?t:s==="1"}catch{return t}};function V5(e,t=!0){const[s,i]=v.useState(()=>W5(e,t));return[s,()=>i(o=>{try{localStorage.setItem(`adg.fold.${e}`,o?"0":"1")}catch{}return!o})]}function q5({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 La({id:e,title:t,count:s,initial:i=!0,children:r,className:o=""}){const[l,u]=V5(e,i);return n.jsxs("div",{className:`fold ${o}`,children:[n.jsx(q5,{open:l,onToggle:u,...s===void 0?{}:{count:s},children:t}),l&&r]})}function m1({client:e,scriptId:t,taskId:s,name:i,spec:r,value:o,onChange:l,onCreated:u,profile:d}){const[h,m]=v.useState(null),[p,g]=v.useState(null),[x,k]=v.useState(!1),b=async()=>{const w=(p==null?void 0:p.trim())??"";if(w!==""){m(null),k(!0);try{const{value:S}=await e.connection.call("runs/choices/create",{scriptId:t,taskId:s,param:i,name:w,...d===void 0?{}:{profile:d}});g(null),u==null||u(),l(S)}catch(S){m(Ce(S))}finally{k(!1)}}};let j;if(r.choices!==void 0){const w=r.choices.some(S=>S.value===o);j=n.jsx(Mt,{"aria-label":i,value:w?o:"",placeholder:r.choices.length===0?"本地配置里还没有,先新建或在脚本里建一个":"请选择",onChange:S=>{S==="\0new"?g(_=>_??"MultiGameAssistant"):l(S)},options:[...r.choices.map(S=>({value:S.value,label:S.label,...S.detail===void 0?{}:{hint:S.detail}})),...r.canCreate===!0?[{value:"\0new",label:"+ 新建…"}]:[]]})}else r.type==="boolean"?j=n.jsx(Mt,{"aria-label":i,value:o,onChange:l,options:[{value:"true",label:"是"},{value:"false",label:"否"}]}):r.enum!==void 0?j=n.jsx(Mt,{"aria-label":i,value:o,onChange:l,options:r.enum.map(w=>({value:String(w),label:String(w)}))}):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:w=>l(w.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:w=>g(w.target.value),onKeyDown:w=>{w.key==="Enter"?(w.preventDefault(),b()):w.key==="Escape"&&g(null)}}),n.jsx("button",{type:"button",className:"primary small-button",disabled:x||p.trim()==="",onClick:()=>void b(),children:x?"新建中…":"新建"}),n.jsx("button",{type:"button",className:"small-button",disabled:x,onClick:()=>{g(null),m(null)},children:"取消"}),n.jsx("span",{className:"muted small",children:"复制一个现有的同类项,只存在本应用的本地配置里,原项目不变"})]}),h!==null&&n.jsx("span",{className:"error small",children:h})]})}function f1(e,t,s=!0){const i=Se(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 p1({list:e,value:t,onChange:s,id:i,label:r="配置"}){if(e===null||e.items.length<2)return null;const o=e.items.find(u=>u.id===e.current),l=t!==void 0&&!e.items.some(u=>u.id===t);return n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:i,children:r}),n.jsx(Mt,{id:i,value:t??"",onChange:u=>s(u===""?void 0:u),options:[{value:"",label:"跟随当前使用的",hint:`现在是「${(o==null?void 0:o.name)??"默认"}」`},...e.items.map(u=>({value:u.id,label:u.name})),...l?[{value:t,label:"已删除的配置",disabled:!0}]:[]]}),l&&n.jsx("span",{className:"muted small",children:"这份配置已经删了,运行时会失败;请重新选一份。"})]})}const wx={starting:["","启动中"],running:["","运行中"],stopping:["warn","停止中"],succeeded:["ok","成功"],failed:["warn","失败"],cancelled:["","已停止"]},G5={desktop:"占用鼠标键盘",window:"后台窗口",adb:"模拟器",none:"不占用"};function K5({client:e,scriptId:t,packId:s}){const i=Se(e.connection.status),r=vn(3e4),[o,l]=v.useState(null),[u,d]=v.useState([]),[h,m]=v.useState(""),[p,g]=v.useState({}),[x,k]=v.useState(!1),[b,j]=v.useState(null),[w,S]=v.useState(null),[_,E]=v.useState(0),M=f1(e,t,s!==void 0),[O,B]=v.useState(void 0);v.useEffect(()=>{if(i.state!=="open")return;let L=!0;return e.connection.call("runs/tasks",{scriptId:t,...O===void 0?{}:{profile:O}}).then(A=>{L&&(l(A),m(T=>{var H;return T===""?((H=A.tasks[0])==null?void 0:H.id)??"":T}))}).catch(A=>{L&&j(Ce(A))}),e.connection.call("runs/list",{scriptId:t}).then(A=>{L&&d(A.items)}).catch(()=>{}),()=>{L=!1}},[e,t,s,i.state,_,O,M==null?void 0:M.current]),v.useEffect(()=>e.connection.on("runs/state",L=>{L.scriptId===t&&d(A=>[L,...A.filter(T=>T.id!==L.id)].sort((T,H)=>H.startedAt-T.startedAt))}),[e,t]);const U=o==null?void 0:o.tasks.find(L=>L.id===h);v.useEffect(()=>{U!==void 0&&g(Object.fromEntries(Object.entries(U.params).map(([L,A])=>{var T;return[L,A.default!==void 0?String(A.default):((T=A.choices)==null?void 0:T.length)===1?A.choices[0].value:""]})))},[U==null?void 0:U.id]);const P=u.find(L=>L.endedAt===void 0),R=u.find(L=>{var A;return L.id===(w??(P==null?void 0:P.id)??((A=u[0])==null?void 0:A.id))}),z=async()=>{if(U!==void 0){k(!0),j(null);try{const L={};for(const[T,H]of Object.entries(U.params)){const F=p[T]??"";F!==""&&(L[T]=H.type==="boolean"?F==="true":H.type==="integer"||H.type==="number"?Number(F):F)}const A=await e.connection.call("runs/start",{scriptId:t,taskId:U.id,params:L,...O===void 0?{}:{profile:O}});S(A.id),A.state==="failed"&&j(A.outcome??"运行失败")}catch(L){j(Ce(L))}finally{k(!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&&b===null&&n.jsx("div",{className:"muted small",children:"加载中…"}),o!==null&&!o.runnable&&n.jsx("div",{className:"notice info left small",children:o.problem}),o!==null&&o.tasks.length>0&&n.jsxs("div",{className:"run-form",children:[n.jsx("label",{className:"field-label",htmlFor:"task-select",children:"任务"}),n.jsx(Mt,{id:"task-select",value:h,onChange:m,options:o.tasks.map(L=>({value:L.id,label:L.title,hint:L.id}))}),U!==void 0&&n.jsxs("div",{className:"task-facts muted small",children:[n.jsx("span",{className:"badge",children:G5[U.input]}),U.account!==void 0&&n.jsxs("span",{className:"badge",children:["账号 ",U.account]}),U.expectedDuration!==void 0&&n.jsxs("span",{children:["约 ",U.expectedDuration]}),U.description!==void 0&&n.jsx("span",{children:U.description})]}),n.jsx(p1,{id:"run-profile",list:M,value:O,onChange:B}),U!==void 0&&Object.entries(U.params).map(([L,A])=>n.jsx(m1,{client:e,scriptId:t,taskId:U.id,name:L,spec:A,profile:O,value:p[L]??"",onChange:T=>g(H=>({...H,[L]:T})),onCreated:()=>E(T=>T+1)},L)),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),P!==void 0&&n.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:P.id}).catch(L=>j(Ce(L))),children:"停止当前运行"}),n.jsxs("button",{className:"primary small-button",disabled:x||!o.runnable||P!==void 0,onClick:()=>void z(),children:[n.jsx(ee,{name:"arrow"}),x?"启动中…":"运行"]})]})]}),b!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:b})]}),u.length>0&&n.jsxs(La,{id:"scripts.recent-runs",title:"最近运行",count:Math.min(u.length,6),className:"run-history",children:[u.slice(0,6).map(L=>{const[A,T]=wx[L.state];return n.jsxs("button",{className:`run-row ${L.id===(R==null?void 0:R.id)?"active":""}`,"aria-expanded":L.id===(R==null?void 0:R.id),onClick:()=>S(H=>H===L.id||H===null&&L.id===(R==null?void 0:R.id)?"":L.id),children:[n.jsx("span",{className:`badge ${A}`,children:T}),n.jsxs("span",{className:"run-title",children:[L.taskTitle,L.profileName!==void 0&&((M==null?void 0:M.items.length)??0)>1&&n.jsxs("span",{className:"muted small",children:[" · ",L.profileName]})]}),n.jsx("span",{className:"muted small run-outcome",children:L.outcome??L.resources.join(" · ")}),n.jsx("span",{className:"session-time",children:vt(L.startedAt,r)})]},L.id)}),R!==void 0&&n.jsx(g1,{client:e,run:R},R.id)]})]})}function g1({client:e,run:t}){const[s,i]=v.useState([]),r=v.useRef(null);v.useEffect(()=>{let h=!0;e.connection.call("runs/logs",{runId:t.id,limit:500}).then(p=>{h&&i(p.lines)}).catch(()=>{});const m=e.connection.on("runs/log",p=>{p.runId===t.id&&i(g=>[...g,...p.lines].slice(-1e3))});return()=>{h=!1,m()}},[e,t.id]),v.useEffect(()=>{const h=r.current;h!==null&&(h.scrollTop=h.scrollHeight)},[s.length]);const o=v.useMemo(()=>t.warnings,[t.warnings]),[l,u]=v.useState(null),d=async()=>{let h=s;try{h=(await e.connection.call("runs/logs",{runId:t.id,limit:2e3})).lines}catch{}const m=[`${t.scriptName} · ${t.taskTitle}(${t.id})${t.outcome===void 0?"":` — ${t.outcome}`}`,...h.map(g=>`${new Date(g.at).toLocaleTimeString("zh-CN",{hour12:!1})} [${g.source==="adg"?"平台":g.source}]${g.level===void 0?"":` [${g.level}]`} ${g.text}`)].join(`
222
+ `),p=await Y5(m);u(p?`已复制 ${h.length} 行`:"复制失败"),setTimeout(()=>u(null),1800)};return n.jsxs("div",{className:"run-log-wrap",children:[o.map(h=>n.jsxs("div",{className:"notice info left small",children:[n.jsx(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,m)=>n.jsxs("div",{className:`log-line ${h.level===void 0?"":`lv-${h.level}`} ${h.source==="adg"?"adg":""}`,children:[n.jsx("span",{className:"log-time",children:new Date(h.at).toLocaleTimeString()}),n.jsx("span",{className:"log-source",children:h.source==="adg"?"平台":h.source}),n.jsx("span",{className:"log-text",children:h.text})]},m))]})]})}async function Y5(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 x1=v.createContext({byIncident:new Map,openSession:()=>{}}),X5={running:"agent 正在处理",resolved:"agent 已处理",retried:"agent 处理后重新运行","gave-up":"agent 处理不了","taken-over":"你接管了",timeout:"agent 超时",failed:"agent 没能开始"},Q5={error:"出错",warning:"警告",failed:"失败",stalled:"卡住",overtime:"超时"};function J5({client:e,openSettings:t,openSession:s}){const i=Se(e.connection.status),r=vn(3e4),[o,l]=v.useState([]),[u,d]=v.useState([]),[h,m]=v.useState(null),[p,g]=v.useState(!1),[x,k]=v.useState(null),[b,j]=v.useState([]),w=Se(e.capabilities);v.useEffect(()=>{if(i.state!=="open"||!w.has("intervene"))return;let P=!0;return e.connection.call("intervene/list",{limit:100}).then(R=>{P&&j(R.items)}).catch(()=>{}),()=>{P=!1}},[e,i.state,w]),v.useEffect(()=>e.connection.on("intervene/changed",P=>{j(R=>[P,...R.filter(z=>z.id!==P.id)])}),[e]);const S=v.useMemo(()=>{const P=new Map;for(const R of[...b].sort((z,L)=>z.startedAt-L.startedAt))R.incidentId!==void 0&&P.set(R.incidentId,R);return{byIncident:P,openSession:s}},[b,s]);v.useEffect(()=>{if(i.state!=="open")return;let P=!0;return e.connection.call("runs/list",{}).then(R=>{P&&l(R.items)}).catch(R=>{P&&k(Ce(R))}),e.connection.call("monitor/incidents",{status:"all",limit:200}).then(R=>{P&&d(R.items)}).catch(()=>{}),()=>{P=!1}},[e,i.state]),v.useEffect(()=>e.connection.on("runs/state",P=>{l(R=>[P,...R.filter(z=>z.id!==P.id)].sort((z,L)=>L.startedAt-z.startedAt))}),[e]),v.useEffect(()=>e.connection.on("monitor/incident",P=>{d(R=>[P,...R.filter(z=>z.id!==P.id)].sort((z,L)=>L.createdAt-z.createdAt))}),[e]);const _=o.filter(P=>P.endedAt===void 0),E=o.filter(P=>P.endedAt!==void 0).slice(0,30),M=u.filter(P=>P.status==="open"),O=o.find(P=>{var R,z;return P.id===(h??((R=_[0])==null?void 0:R.id)??((z=o[0])==null?void 0:z.id))}),B=v.useMemo(()=>{const P=new Map;for(const R of M)P.set(R.runId,(P.get(R.runId)??0)+1);return P},[M]),U=P=>{const[R,z]=wx[P.state],L=B.get(P.id)??0;return n.jsxs("button",{className:`script-row ${P.id===(O==null?void 0:O.id)?"active":""}`,onClick:()=>m(P.id),children:[n.jsxs("span",{className:"script-row-main",children:[n.jsxs("span",{className:"script-row-name",children:[P.scriptName," · ",P.taskTitle]}),n.jsxs("span",{className:"muted small",children:[P.kind==="settings"?"设置会话 · ":"",vt(P.startedAt,r),P.retryOf===void 0?"":" · 重新运行"]})]}),L>0?n.jsxs("span",{className:"badge warn",children:["异常 ",L]}):n.jsx("span",{className:`badge ${R}`,children:z})]},P.id)};return n.jsx(x1.Provider,{value:S,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(P=>!P),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(La,{id:"monitor.active",title:"正在运行",count:_.length,className:"list-fold",children:[_.length===0&&n.jsx("div",{className:"muted small pad",children:"没有正在运行的任务"}),_.map(U)]}),E.length>0&&n.jsx(La,{id:"monitor.recent",title:"最近",count:E.length,className:"list-fold",children:E.map(U)})]}),n.jsx("div",{className:"scripts-detail",children:n.jsxs("div",{className:"script-detail",children:[p&&n.jsx(t4,{client:e}),M.length>0&&n.jsx("section",{className:"card",children:n.jsxs(La,{id:"monitor.open-incidents",title:n.jsxs("h3",{children:["待处理的异常(",M.length,")"]}),className:"card-fold",children:[n.jsx("p",{className:"muted small",children:"脚本包里写了自动处理的(如重连模拟器、重新运行)会先自动处理;处理不了的才推送到飞书。"}),n.jsx("div",{className:"incident-list",children:M.map(P=>n.jsx(v1,{client:e,incident:P,now:r,onOpen:()=>m(P.runId)},P.id))})]})}),O===void 0&&M.length===0&&n.jsxs("div",{className:"empty",children:[n.jsx(ee,{name:"monitor"}),n.jsx("p",{children:"还没有运行记录。在「脚本」页运行一个任务,或对 agent 说「跑一下方舟日常」。"})]}),O!==void 0&&n.jsx(e4,{client:e,run:O,incidents:u.filter(P=>P.runId===O.id),now:r,openRun:m})]})})]})]})})}function e4({client:e,run:t,incidents:s,now:i,openRun:r}){const[o,l]=wx[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(La,{id:"monitor.run-log",title:"日志",children:n.jsx(g1,{client:e,run:t},t.id)}),s.length>0&&n.jsx(La,{id:"monitor.run-incidents",title:"这次运行的异常",count:s.length,children:n.jsx("div",{className:"incident-list",children:s.map(h=>n.jsx(v1,{client:e,incident:h,now:i},h.id))})})]})}function v1({client:e,incident:t,now:s,onOpen:i}){const{byIncident:r,openSession:o}=v.useContext(x1),l=r.get(t.id),[u,d]=v.useState(!1),[h,m]=v.useState(null),[p,g]=v.useState(null),x=async()=>{if(l!==void 0){d(!0),m(null);try{await e.connection.call("intervene/takeover",{id:l.id})}catch(j){m(Ce(j))}finally{d(!1)}}},k=async j=>{d(!0),m(null);try{await e.connection.call("monitor/act",{incidentId:t.id,action:j})}catch(w){m(Ce(w))}finally{d(!1)}},b=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){m(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:Q5[t.kind]}),i===void 0?n.jsx("span",{className:"incident-title",children:t.title}):n.jsx("button",{className:"link-button incident-title",onClick:i,children:t.title}),n.jsx("span",{className:"session-time",children:vt(t.createdAt,s)})]}),n.jsx("div",{className:"incident-detail",children:t.detail}),t.steps.length>0&&n.jsx("ul",{className:"incident-steps",children:t.steps.filter(j=>(l==null?void 0:l.summary)===void 0||l.state==="running"||!j.detail.endsWith(l.summary)).map((j,w)=>n.jsxs("li",{className:j.ok?"ok":"failed",children:[j.ok?"✓":"✗"," ",j.detail]},w))}),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:[X5[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 b(),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 k("resume"),children:"继续"}),n.jsx("button",{className:"danger-outline small-button",disabled:u,onClick:()=>void k("stop"),children:"停止"}),n.jsx("button",{className:"small-button",disabled:u,onClick:()=>void k("retry"),children:"重试"}),n.jsx("button",{className:"small-button",disabled:u,onClick:()=>void k("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 t4({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(m=>r(Ce(m))),l=((d=ah(e).data)==null?void 0:d.scripts)??[],u=Object.entries((t==null?void 0:t.scriptStall)??{}).sort(([h],[m])=>h.localeCompare(m));return n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"监控设置"}),t!==null&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:"stall-seconds",children:"多少秒没有新日志算卡住、交给干预(默认值;0 = 不检测)"}),n.jsx("input",{id:"stall-seconds",className:"text-input plain",type:"number",min:0,max:86400,defaultValue:t.defaultStallSeconds,onBlur:h=>void o({defaultStallSeconds:Math.max(0,Math.min(86400,Math.round(Number(h.target.value)||0)))})}),n.jsx("p",{className:"muted small",children:"每个脚本会从自己跑成功的记录里学:卡住时间取最近几次里最长安静时间的 1.5 倍(不低于上面的默认值);agent 看过日志节奏后也会替它调。"}),u.length>0&&n.jsx("ul",{className:"stall-list",children:u.map(([h,m])=>{var p;return n.jsxs("li",{children:[n.jsx("span",{children:((p=l.find(g=>g.id===h))==null?void 0:p.name)??h}),n.jsxs("span",{className:"muted small",children:[m.seconds," 秒 · ",m.by==="learned"?"学到的":m.by==="agent"?"agent 设的":"你设的",m.note===void 0?"":`:${m.note}`]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"link-button small",onClick:()=>{const{[h]:g,...x}=t.scriptStall;o({scriptStall:x})},children:"恢复自动"})]},h)})}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:t.screenshot,onChange:h=>void o({screenshot:h.target.checked})}),"出错时截图(模拟器画面或桌面)并随通知发送"]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:t.notifyWarnings,onChange:h=>void o({notifyWarnings:h.target.checked})}),"警告也推送(默认只推送出错、失败、卡住)"]}),n.jsx("label",{className:"field-label",htmlFor:"intervene-mode",children:"自动处理解决不了的问题,先交给 agent(需要能看图的模型)"}),n.jsx(Mt,{id:"intervene-mode",value:t.intervene,onChange:h=>void o({intervene:h}),options:[{value:"act",label:"诊断并处理(推荐)",hint:"暂停脚本,agent 看屏幕、点击和输入来解决"},{value:"diagnose",label:"只诊断",hint:"agent 看截图说明原因,由你决定"},{value:"off",label:"关闭",hint:"直接通知我"}]}),n.jsx("label",{className:"field-label",htmlFor:"intervene-cap",children:"每天最多交给 agent 几次(控制模型费用)"}),n.jsx("input",{id:"intervene-cap",className:"text-input plain",type:"number",min:0,max:200,defaultValue:t.interventionsPerDay,onBlur:h=>void o({interventionsPerDay:Math.max(0,Math.min(200,Math.round(Number(h.target.value)||0)))})})]}),i!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:i})]})]})}const n4={id:"runs",title:"运行监控",milestone:"M3",requires:["runs","monitor"],pages:[{id:"runs",title:"运行",icon:"monitor",order:30,agent:"intervene",component:J5}]},s4={id:"feishu",title:"远程连接",milestone:"M3",requires:["notify","credentials"],settingsPages:[{id:"feishu",title:"远程连接",order:12,component:Z5}]};function _n(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let s=0,i;s<e.length;s++)(i=_n(e[s]))!==""&&(t+=(t&&" ")+i);else for(let s in e)e[s]&&(t+=(t&&" ")+s);return t}var i4={value:()=>{}};function ph(){for(var e=0,t=arguments.length,s={},i;e<t;++e){if(!(i=arguments[e]+"")||i in s||/[\s.]/.test(i))throw new Error("illegal type: "+i);s[i]=[]}return new jd(s)}function jd(e){this._=e}function r4(e,t){return e.trim().split(/^|\s+/).map(function(s){var i="",r=s.indexOf(".");if(r>=0&&(i=s.slice(r+1),s=s.slice(0,r)),s&&!t.hasOwnProperty(s))throw new Error("unknown type: "+s);return{type:s,name:i}})}jd.prototype=ph.prototype={constructor:jd,on:function(e,t){var s=this._,i=r4(e+"",s),r,o=-1,l=i.length;if(arguments.length<2){for(;++o<l;)if((r=(e=i[o]).type)&&(r=a4(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]=Tk(s[r],e.name,t);else if(t==null)for(r in s)s[r]=Tk(s[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var s in t)e[s]=t[s].slice();return new jd(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var s=new Array(r),i=0,r,o;i<r;++i)s[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],i=0,r=o.length;i<r;++i)o[i].value.apply(t,s)},apply:function(e,t,s){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,s)}};function a4(e,t){for(var s=0,i=e.length,r;s<i;++s)if((r=e[s]).name===t)return r.value}function Tk(e,t,s){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=i4,e=e.slice(0,i).concat(e.slice(i+1));break}return s!=null&&e.push({name:t,value:s}),e}var og="http://www.w3.org/1999/xhtml";const Mk={svg:"http://www.w3.org/2000/svg",xhtml:og,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function gh(e){var t=e+="",s=t.indexOf(":");return s>=0&&(t=e.slice(0,s))!=="xmlns"&&(e=e.slice(s+1)),Mk.hasOwnProperty(t)?{space:Mk[t],local:e}:e}function o4(e){return function(){var t=this.ownerDocument,s=this.namespaceURI;return s===og&&t.documentElement.namespaceURI===og?t.createElement(e):t.createElementNS(s,e)}}function l4(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function y1(e){var t=gh(e);return(t.local?l4:o4)(t)}function c4(){}function Sx(e){return e==null?c4:function(){return this.querySelector(e)}}function u4(e){typeof e!="function"&&(e=Sx(e));for(var t=this._groups,s=t.length,i=new Array(s),r=0;r<s;++r)for(var o=t[r],l=o.length,u=i[r]=new Array(l),d,h,m=0;m<l;++m)(d=o[m])&&(h=e.call(d,d.__data__,m,o))&&("__data__"in d&&(h.__data__=d.__data__),u[m]=h);return new qs(i,this._parents)}function d4(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function h4(){return[]}function b1(e){return e==null?h4:function(){return this.querySelectorAll(e)}}function m4(e){return function(){return d4(e.apply(this,arguments))}}function f4(e){typeof e=="function"?e=m4(e):e=b1(e);for(var t=this._groups,s=t.length,i=[],r=[],o=0;o<s;++o)for(var l=t[o],u=l.length,d,h=0;h<u;++h)(d=l[h])&&(i.push(e.call(d,d.__data__,h,l)),r.push(d));return new qs(i,r)}function k1(e){return function(){return this.matches(e)}}function j1(e){return function(t){return t.matches(e)}}var p4=Array.prototype.find;function g4(e){return function(){return p4.call(this.children,e)}}function x4(){return this.firstElementChild}function v4(e){return this.select(e==null?x4:g4(typeof e=="function"?e:j1(e)))}var y4=Array.prototype.filter;function b4(){return Array.from(this.children)}function k4(e){return function(){return y4.call(this.children,e)}}function j4(e){return this.selectAll(e==null?b4:k4(typeof e=="function"?e:j1(e)))}function N4(e){typeof e!="function"&&(e=k1(e));for(var t=this._groups,s=t.length,i=new Array(s),r=0;r<s;++r)for(var o=t[r],l=o.length,u=i[r]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new qs(i,this._parents)}function N1(e){return new Array(e.length)}function w4(){return new qs(this._enter||this._groups.map(N1),this._parents)}function Fd(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Fd.prototype={constructor:Fd,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function S4(e){return function(){return e}}function _4(e,t,s,i,r,o){for(var l=0,u,d=t.length,h=o.length;l<h;++l)(u=t[l])?(u.__data__=o[l],i[l]=u):s[l]=new Fd(e,o[l]);for(;l<d;++l)(u=t[l])&&(r[l]=u)}function E4(e,t,s,i,r,o,l){var u,d,h=new Map,m=t.length,p=o.length,g=new Array(m),x;for(u=0;u<m;++u)(d=t[u])&&(g[u]=x=l.call(d,d.__data__,u,t)+"",h.has(x)?r[u]=d:h.set(x,d));for(u=0;u<p;++u)x=l.call(e,o[u],u,o)+"",(d=h.get(x))?(i[u]=d,d.__data__=o[u],h.delete(x)):s[u]=new Fd(e,o[u]);for(u=0;u<m;++u)(d=t[u])&&h.get(g[u])===d&&(r[u]=d)}function C4(e){return e.__data__}function A4(e,t){if(!arguments.length)return Array.from(this,C4);var s=t?E4:_4,i=this._parents,r=this._groups;typeof e!="function"&&(e=S4(e));for(var o=r.length,l=new Array(o),u=new Array(o),d=new Array(o),h=0;h<o;++h){var m=i[h],p=r[h],g=p.length,x=$4(e.call(m,m&&m.__data__,h,i)),k=x.length,b=u[h]=new Array(k),j=l[h]=new Array(k),w=d[h]=new Array(g);s(m,p,b,j,w,x,t);for(var S=0,_=0,E,M;S<k;++S)if(E=b[S]){for(S>=_&&(_=S+1);!(M=j[_])&&++_<k;);E._next=M||null}}return l=new qs(l,i),l._enter=u,l._exit=d,l}function $4(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function I4(){return new qs(this._exit||this._groups.map(N1),this._parents)}function T4(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],m=i[d],p=h.length,g=u[d]=new Array(p),x,k=0;k<p;++k)(x=h[k]||m[k])&&(g[k]=x);for(;d<r;++d)u[d]=s[d];return new qs(u,this._parents)}function R4(){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 O4(e){e||(e=P4);function t(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var s=this._groups,i=s.length,r=new Array(i),o=0;o<i;++o){for(var l=s[o],u=l.length,d=r[o]=new Array(u),h,m=0;m<u;++m)(h=l[m])&&(d[m]=h);d.sort(t)}return new qs(r,this._parents).order()}function P4(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function L4(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function z4(){return Array.from(this)}function D4(){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 F4(){let e=0;for(const t of this)++e;return e}function U4(){return!this.node()}function B4(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 H4(e){return function(){this.removeAttribute(e)}}function Z4(e){return function(){this.removeAttributeNS(e.space,e.local)}}function W4(e,t){return function(){this.setAttribute(e,t)}}function V4(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function q4(e,t){return function(){var s=t.apply(this,arguments);s==null?this.removeAttribute(e):this.setAttribute(e,s)}}function G4(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 K4(e,t){var s=gh(e);if(arguments.length<2){var i=this.node();return s.local?i.getAttributeNS(s.space,s.local):i.getAttribute(s)}return this.each((t==null?s.local?Z4:H4:typeof t=="function"?s.local?G4:q4:s.local?V4:W4)(s,t))}function w1(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Y4(e){return function(){this.style.removeProperty(e)}}function X4(e,t,s){return function(){this.style.setProperty(e,t,s)}}function Q4(e,t,s){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,s)}}function J4(e,t,s){return arguments.length>1?this.each((t==null?Y4:typeof t=="function"?Q4:X4)(e,t,s??"")):Yo(this.node(),e)}function Yo(e,t){return e.style.getPropertyValue(t)||w1(e).getComputedStyle(e,null).getPropertyValue(t)}function eF(e){return function(){delete this[e]}}function tF(e,t){return function(){this[e]=t}}function nF(e,t){return function(){var s=t.apply(this,arguments);s==null?delete this[e]:this[e]=s}}function sF(e,t){return arguments.length>1?this.each((t==null?eF:typeof t=="function"?nF:tF)(e,t)):this.node()[e]}function S1(e){return e.trim().split(/^|\s+/)}function _x(e){return e.classList||new _1(e)}function _1(e){this._node=e,this._names=S1(e.getAttribute("class")||"")}_1.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 E1(e,t){for(var s=_x(e),i=-1,r=t.length;++i<r;)s.add(t[i])}function C1(e,t){for(var s=_x(e),i=-1,r=t.length;++i<r;)s.remove(t[i])}function iF(e){return function(){E1(this,e)}}function rF(e){return function(){C1(this,e)}}function aF(e,t){return function(){(t.apply(this,arguments)?E1:C1)(this,e)}}function oF(e,t){var s=S1(e+"");if(arguments.length<2){for(var i=_x(this.node()),r=-1,o=s.length;++r<o;)if(!i.contains(s[r]))return!1;return!0}return this.each((typeof t=="function"?aF:t?iF:rF)(s,t))}function lF(){this.textContent=""}function cF(e){return function(){this.textContent=e}}function uF(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function dF(e){return arguments.length?this.each(e==null?lF:(typeof e=="function"?uF:cF)(e)):this.node().textContent}function hF(){this.innerHTML=""}function mF(e){return function(){this.innerHTML=e}}function fF(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function pF(e){return arguments.length?this.each(e==null?hF:(typeof e=="function"?fF:mF)(e)):this.node().innerHTML}function gF(){this.nextSibling&&this.parentNode.appendChild(this)}function xF(){return this.each(gF)}function vF(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function yF(){return this.each(vF)}function bF(e){var t=typeof e=="function"?e:y1(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function kF(){return null}function jF(e,t){var s=typeof e=="function"?e:y1(e),i=t==null?kF:typeof t=="function"?t:Sx(t);return this.select(function(){return this.insertBefore(s.apply(this,arguments),i.apply(this,arguments)||null)})}function NF(){var e=this.parentNode;e&&e.removeChild(this)}function wF(){return this.each(NF)}function SF(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _F(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function EF(e){return this.select(e?_F:SF)}function CF(e){return arguments.length?this.property("__data__",e):this.node().__data__}function AF(e){return function(t){e.call(this,t,this.__data__)}}function $F(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 IF(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 TF(e,t,s){return function(){var i=this.__on,r,o=AF(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=$F(e+""),r,o=i.length,l;if(arguments.length<2){var u=this.node().__on;if(u){for(var d=0,h=u.length,m;d<h;++d)for(r=0,m=u[d];r<o;++r)if((l=i[r]).type===m.type&&l.name===m.name)return m.value}return}for(u=t?TF:IF,r=0;r<o;++r)this.each(u(i[r],t,s));return this}function A1(e,t,s){var i=w1(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 RF(e,t){return function(){return A1(this,e,t)}}function OF(e,t){return function(){return A1(this,e,t.apply(this,arguments))}}function PF(e,t){return this.each((typeof t=="function"?OF:RF)(e,t))}function*LF(){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 $1=[null];function qs(e,t){this._groups=e,this._parents=t}function Wc(){return new qs([[document.documentElement]],$1)}function zF(){return this}qs.prototype=Wc.prototype={constructor:qs,select:u4,selectAll:f4,selectChild:v4,selectChildren:j4,filter:N4,data:A4,enter:w4,exit:I4,join:T4,merge:M4,selection:zF,order:R4,sort:O4,call:L4,nodes:z4,node:D4,size:F4,empty:U4,each:B4,attr:K4,style:J4,property:sF,classed:oF,text:dF,html:pF,raise:xF,lower:yF,append:bF,insert:jF,remove:wF,clone:EF,datum:CF,on:MF,dispatch:PF,[Symbol.iterator]:LF};function Bs(e){return typeof e=="string"?new qs([[document.querySelector(e)]],[document.documentElement]):new qs([[e]],$1)}function DF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ji(e,t){if(e=DF(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 FF={passive:!1},Sc={capture:!0,passive:!1};function Xf(e){e.stopImmediatePropagation()}function Ro(e){e.preventDefault(),e.stopImmediatePropagation()}function I1(e){var t=e.document.documentElement,s=Bs(e).on("dragstart.drag",Ro,Sc);"onselectstart"in t?s.on("selectstart.drag",Ro,Sc):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function T1(e,t){var s=e.document.documentElement,i=Bs(e).on("dragstart.drag",null);t&&(i.on("click.drag",Ro,Sc),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in s?i.on("selectstart.drag",null):(s.style.MozUserSelect=s.__noselect,delete s.__noselect)}const rd=e=>()=>e;function lg(e,{sourceEvent:t,subject:s,target:i,identifier:r,active:o,x:l,y:u,dx:d,dy:h,dispatch:m}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:m}})}lg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function UF(e){return!e.ctrlKey&&!e.button}function BF(){return this.parentNode}function HF(e,t){return t??{x:e.x,y:e.y}}function ZF(){return navigator.maxTouchPoints||"ontouchstart"in this}function M1(){var e=UF,t=BF,s=HF,i=ZF,r={},o=ph("start","drag","end"),l=0,u,d,h,m,p=0;function g(E){E.on("mousedown.drag",x).filter(i).on("touchstart.drag",j).on("touchmove.drag",w,FF).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(E,M){if(!(m||!e.call(this,E,M))){var O=_(this,t.call(this,E,M),E,M,"mouse");O&&(Bs(E.view).on("mousemove.drag",k,Sc).on("mouseup.drag",b,Sc),I1(E.view),Xf(E),h=!1,u=E.clientX,d=E.clientY,O("start",E))}}function k(E){if(Ro(E),!h){var M=E.clientX-u,O=E.clientY-d;h=M*M+O*O>p}r.mouse("drag",E)}function b(E){Bs(E.view).on("mousemove.drag mouseup.drag",null),T1(E.view,h),Ro(E),r.mouse("end",E)}function j(E,M){if(e.call(this,E,M)){var O=E.changedTouches,B=t.call(this,E,M),U=O.length,P,R;for(P=0;P<U;++P)(R=_(this,B,E,M,O[P].identifier,O[P]))&&(Xf(E),R("start",E,O[P]))}}function w(E){var M=E.changedTouches,O=M.length,B,U;for(B=0;B<O;++B)(U=r[M[B].identifier])&&(Ro(E),U("drag",E,M[B]))}function S(E){var M=E.changedTouches,O=M.length,B,U;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),B=0;B<O;++B)(U=r[M[B].identifier])&&(Xf(E),U("end",E,M[B]))}function _(E,M,O,B,U,P){var R=o.copy(),z=ji(P||O,M),L,A,T;if((T=s.call(E,new lg("beforestart",{sourceEvent:O,target:g,identifier:U,active:l,x:z[0],y:z[1],dx:0,dy:0,dispatch:R}),B))!=null)return L=T.x-z[0]||0,A=T.y-z[1]||0,function H(F,V,D){var q=z,te;switch(F){case"start":r[U]=H,te=l++;break;case"end":delete r[U],--l;case"drag":z=ji(D||V,M),te=l;break}R.call(F,E,new lg(F,{sourceEvent:V,subject:T,target:g,identifier:U,active:te,x:z[0]+L,y:z[1]+A,dx:z[0]-q[0],dy:z[1]-q[1],dispatch:R}),B)}}return g.filter=function(E){return arguments.length?(e=typeof E=="function"?E:rd(!!E),g):e},g.container=function(E){return arguments.length?(t=typeof E=="function"?E:rd(E),g):t},g.subject=function(E){return arguments.length?(s=typeof E=="function"?E:rd(E),g):s},g.touchable=function(E){return arguments.length?(i=typeof E=="function"?E:rd(!!E),g):i},g.on=function(){var E=o.on.apply(o,arguments);return E===o?g:E},g.clickDistance=function(E){return arguments.length?(p=(E=+E)*E,g):Math.sqrt(p)},g}function Ex(e,t,s){e.prototype=t.prototype=s,s.constructor=e}function R1(e,t){var s=Object.create(e.prototype);for(var i in t)s[i]=t[i];return s}function Vc(){}var _c=.7,Ud=1/_c,Oo="\\s*([+-]?\\d+)\\s*",Ec="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Vi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",WF=/^#([0-9a-f]{3,8})$/,VF=new RegExp(`^rgb\\(${Oo},${Oo},${Oo}\\)$`),qF=new RegExp(`^rgb\\(${Vi},${Vi},${Vi}\\)$`),GF=new RegExp(`^rgba\\(${Oo},${Oo},${Oo},${Ec}\\)$`),KF=new RegExp(`^rgba\\(${Vi},${Vi},${Vi},${Ec}\\)$`),YF=new RegExp(`^hsl\\(${Ec},${Vi},${Vi}\\)$`),XF=new RegExp(`^hsla\\(${Ec},${Vi},${Vi},${Ec}\\)$`),Rk={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};Ex(Vc,Ua,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ok,formatHex:Ok,formatHex8:QF,formatHsl:JF,formatRgb:Pk,toString:Pk});function Ok(){return this.rgb().formatHex()}function QF(){return this.rgb().formatHex8()}function JF(){return O1(this).formatHsl()}function Pk(){return this.rgb().formatRgb()}function Ua(e){var t,s;return e=(e+"").trim().toLowerCase(),(t=WF.exec(e))?(s=t[1].length,t=parseInt(t[1],16),s===6?Lk(t):s===3?new Ts(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):s===8?ad(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):s===4?ad(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=VF.exec(e))?new Ts(t[1],t[2],t[3],1):(t=qF.exec(e))?new Ts(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=GF.exec(e))?ad(t[1],t[2],t[3],t[4]):(t=KF.exec(e))?ad(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=YF.exec(e))?Fk(t[1],t[2]/100,t[3]/100,1):(t=XF.exec(e))?Fk(t[1],t[2]/100,t[3]/100,t[4]):Rk.hasOwnProperty(e)?Lk(Rk[e]):e==="transparent"?new Ts(NaN,NaN,NaN,0):null}function Lk(e){return new Ts(e>>16&255,e>>8&255,e&255,1)}function ad(e,t,s,i){return i<=0&&(e=t=s=NaN),new Ts(e,t,s,i)}function e6(e){return e instanceof Vc||(e=Ua(e)),e?(e=e.rgb(),new Ts(e.r,e.g,e.b,e.opacity)):new Ts}function cg(e,t,s,i){return arguments.length===1?e6(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}Ex(Ts,cg,R1(Vc,{brighter(e){return e=e==null?Ud:Math.pow(Ud,e),new Ts(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?_c:Math.pow(_c,e),new Ts(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ts(za(this.r),za(this.g),za(this.b),Bd(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:zk,formatHex:zk,formatHex8:t6,formatRgb:Dk,toString:Dk}));function zk(){return`#${Oa(this.r)}${Oa(this.g)}${Oa(this.b)}`}function t6(){return`#${Oa(this.r)}${Oa(this.g)}${Oa(this.b)}${Oa((isNaN(this.opacity)?1:this.opacity)*255)}`}function Dk(){const e=Bd(this.opacity);return`${e===1?"rgb(":"rgba("}${za(this.r)}, ${za(this.g)}, ${za(this.b)}${e===1?")":`, ${e})`}`}function Bd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function za(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Oa(e){return e=za(e),(e<16?"0":"")+e.toString(16)}function Fk(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 O1(e){if(e instanceof Si)return new Si(e.h,e.s,e.l,e.opacity);if(e instanceof Vc||(e=Ua(e)),!e)return new Si;if(e instanceof Si)return e;e=e.rgb();var t=e.r/255,s=e.g/255,i=e.b/255,r=Math.min(t,s,i),o=Math.max(t,s,i),l=NaN,u=o-r,d=(o+r)/2;return u?(t===o?l=(s-i)/u+(s<i)*6:s===o?l=(i-t)/u+2:l=(t-s)/u+4,u/=d<.5?o+r:2-o-r,l*=60):u=d>0&&d<1?0:l,new Si(l,u,d,e.opacity)}function n6(e,t,s,i){return arguments.length===1?O1(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}Ex(Si,n6,R1(Vc,{brighter(e){return e=e==null?Ud:Math.pow(Ud,e),new Si(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?_c:Math.pow(_c,e),new Si(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,s=this.l,i=s+(s<.5?s:1-s)*t,r=2*s-i;return new Ts(Qf(e>=240?e-240:e+120,r,i),Qf(e,r,i),Qf(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new Si(Uk(this.h),od(this.s),od(this.l),Bd(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Bd(this.opacity);return`${e===1?"hsl(":"hsla("}${Uk(this.h)}, ${od(this.s)*100}%, ${od(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Uk(e){return e=(e||0)%360,e<0?e+360:e}function od(e){return Math.max(0,Math.min(1,e||0))}function Qf(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 Cx=e=>()=>e;function s6(e,t){return function(s){return e+s*t}}function i6(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 r6(e){return(e=+e)==1?P1:function(t,s){return s-t?i6(t,s,e):Cx(isNaN(t)?s:t)}}function P1(e,t){var s=t-e;return s?s6(e,s):Cx(isNaN(e)?t:e)}const Hd=(function e(t){var s=r6(t);function i(r,o){var l=s((r=cg(r)).r,(o=cg(o)).r),u=s(r.g,o.g),d=s(r.b,o.b),h=P1(r.opacity,o.opacity);return function(m){return r.r=l(m),r.g=u(m),r.b=d(m),r.opacity=h(m),r+""}}return i.gamma=e,i})(1);function a6(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 o6(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function l6(e,t){var s=t?t.length:0,i=e?Math.min(s,e.length):0,r=new Array(i),o=new Array(s),l;for(l=0;l<i;++l)r[l]=fc(e[l],t[l]);for(;l<s;++l)o[l]=t[l];return function(u){for(l=0;l<i;++l)o[l]=r[l](u);return o}}function c6(e,t){var s=new Date;return e=+e,t=+t,function(i){return s.setTime(e*(1-i)+t*i),s}}function Zi(e,t){return e=+e,t=+t,function(s){return e*(1-s)+t*s}}function u6(e,t){var s={},i={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?s[r]=fc(e[r],t[r]):i[r]=t[r];return function(o){for(r in s)i[r]=s[r](o);return i}}var ug=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Jf=new RegExp(ug.source,"g");function d6(e){return function(){return e}}function h6(e){return function(t){return e(t)+""}}function L1(e,t){var s=ug.lastIndex=Jf.lastIndex=0,i,r,o,l=-1,u=[],d=[];for(e=e+"",t=t+"";(i=ug.exec(e))&&(r=Jf.exec(t));)(o=r.index)>s&&(o=t.slice(s,o),u[l]?u[l]+=o:u[++l]=o),(i=i[0])===(r=r[0])?u[l]?u[l]+=r:u[++l]=r:(u[++l]=null,d.push({i:l,x:Zi(i,r)})),s=Jf.lastIndex;return s<t.length&&(o=t.slice(s),u[l]?u[l]+=o:u[++l]=o),u.length<2?d[0]?h6(d[0].x):d6(t):(t=d.length,function(h){for(var m=0,p;m<t;++m)u[(p=d[m]).i]=p.x(h);return u.join("")})}function fc(e,t){var s=typeof t,i;return t==null||s==="boolean"?Cx(t):(s==="number"?Zi:s==="string"?(i=Ua(t))?(t=i,Hd):L1:t instanceof Ua?Hd:t instanceof Date?c6:o6(t)?a6:Array.isArray(t)?l6:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?u6:Zi)(e,t)}var Bk=180/Math.PI,dg={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function z1(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)*Bk,skewX:Math.atan(d)*Bk,scaleX:l,scaleY:u}}var ld;function m6(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?dg:z1(t.a,t.b,t.c,t.d,t.e,t.f)}function f6(e){return e==null||(ld||(ld=document.createElementNS("http://www.w3.org/2000/svg","g")),ld.setAttribute("transform",e),!(e=ld.transform.baseVal.consolidate()))?dg:(e=e.matrix,z1(e.a,e.b,e.c,e.d,e.e,e.f))}function D1(e,t,s,i){function r(h){return h.length?h.pop()+" ":""}function o(h,m,p,g,x,k){if(h!==p||m!==g){var b=x.push("translate(",null,t,null,s);k.push({i:b-4,x:Zi(h,p)},{i:b-2,x:Zi(m,g)})}else(p||g)&&x.push("translate("+p+t+g+s)}function l(h,m,p,g){h!==m?(h-m>180?m+=360:m-h>180&&(h+=360),g.push({i:p.push(r(p)+"rotate(",null,i)-2,x:Zi(h,m)})):m&&p.push(r(p)+"rotate("+m+i)}function u(h,m,p,g){h!==m?g.push({i:p.push(r(p)+"skewX(",null,i)-2,x:Zi(h,m)}):m&&p.push(r(p)+"skewX("+m+i)}function d(h,m,p,g,x,k){if(h!==p||m!==g){var b=x.push(r(x)+"scale(",null,",",null,")");k.push({i:b-4,x:Zi(h,p)},{i:b-2,x:Zi(m,g)})}else(p!==1||g!==1)&&x.push(r(x)+"scale("+p+","+g+")")}return function(h,m){var p=[],g=[];return h=e(h),m=e(m),o(h.translateX,h.translateY,m.translateX,m.translateY,p,g),l(h.rotate,m.rotate,p,g),u(h.skewX,m.skewX,p,g),d(h.scaleX,h.scaleY,m.scaleX,m.scaleY,p,g),h=m=null,function(x){for(var k=-1,b=g.length,j;++k<b;)p[(j=g[k]).i]=j.x(x);return p.join("")}}}var p6=D1(m6,"px, ","px)","deg)"),g6=D1(f6,", ",")",")"),x6=1e-12;function Hk(e){return((e=Math.exp(e))+1/e)/2}function v6(e){return((e=Math.exp(e))-1/e)/2}function y6(e){return((e=Math.exp(2*e))-1)/(e+1)}const Nd=(function e(t,s,i){function r(o,l){var u=o[0],d=o[1],h=o[2],m=l[0],p=l[1],g=l[2],x=m-u,k=p-d,b=x*x+k*k,j,w;if(b<x6)w=Math.log(g/h)/t,j=function(B){return[u+B*x,d+B*k,h*Math.exp(t*B*w)]};else{var S=Math.sqrt(b),_=(g*g-h*h+i*b)/(2*h*s*S),E=(g*g-h*h-i*b)/(2*g*s*S),M=Math.log(Math.sqrt(_*_+1)-_),O=Math.log(Math.sqrt(E*E+1)-E);w=(O-M)/t,j=function(B){var U=B*w,P=Hk(M),R=h/(s*S)*(P*y6(t*U+M)-v6(M));return[u+R*x,d+R*k,h*P/Hk(t*U+M)]}}return j.duration=w*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,F1=1e3,Zd,sc,Wd=0,Ba=0,xh=0,Cc=typeof performance=="object"&&performance.now?performance:Date,U1=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ax(){return Ba||(U1(b6),Ba=Cc.now()+xh)}function b6(){Ba=0}function Vd(){this._call=this._time=this._next=null}Vd.prototype=B1.prototype={constructor:Vd,restart:function(e,t,s){if(typeof e!="function")throw new TypeError("callback is not a function");s=(s==null?Ax():+s)+(t==null?0:+t),!this._next&&sc!==this&&(sc?sc._next=this:Zd=this,sc=this),this._call=e,this._time=s,hg()},stop:function(){this._call&&(this._call=null,this._time=1/0,hg())}};function B1(e,t,s){var i=new Vd;return i.restart(e,t,s),i}function k6(){Ax(),++Xo;for(var e=Zd,t;e;)(t=Ba-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Xo}function Zk(){Ba=(Wd=Cc.now())+xh,Xo=nc=0;try{k6()}finally{Xo=0,N6(),Ba=0}}function j6(){var e=Cc.now(),t=e-Wd;t>F1&&(xh-=t,Wd=e)}function N6(){for(var e,t=Zd,s,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(s=t._next,t._next=null,t=e?e._next=s:Zd=s);sc=e,hg(i)}function hg(e){if(!Xo){nc&&(nc=clearTimeout(nc));var t=e-Ba;t>24?(e<1/0&&(nc=setTimeout(Zk,e-Cc.now()-xh)),Zl&&(Zl=clearInterval(Zl))):(Zl||(Wd=Cc.now(),Zl=setInterval(j6,F1)),Xo=1,U1(Zk))}}function Wk(e,t,s){var i=new Vd;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,s),i}var w6=ph("start","end","cancel","interrupt"),S6=[],H1=0,Vk=1,mg=2,wd=3,qk=4,fg=5,Sd=6;function vh(e,t,s,i,r,o){var l=e.__transition;if(!l)e.__transition={};else if(s in l)return;_6(e,s,{name:t,index:i,group:r,on:w6,tween:S6,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:H1})}function $x(e,t){var s=Ii(e,t);if(s.state>H1)throw new Error("too late; already scheduled");return s}function qi(e,t){var s=Ii(e,t);if(s.state>wd)throw new Error("too late; already running");return s}function Ii(e,t){var s=e.__transition;if(!s||!(s=s[t]))throw new Error("transition not found");return s}function _6(e,t,s){var i=e.__transition,r;i[t]=s,s.timer=B1(o,0,s.time);function o(h){s.state=Vk,s.timer.restart(l,s.delay,s.time),s.delay<=h&&l(h-s.delay)}function l(h){var m,p,g,x;if(s.state!==Vk)return d();for(m in i)if(x=i[m],x.name===s.name){if(x.state===wd)return Wk(l);x.state===qk?(x.state=Sd,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete i[m]):+m<t&&(x.state=Sd,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete i[m])}if(Wk(function(){s.state===wd&&(s.state=qk,s.timer.restart(u,s.delay,s.time),u(h))}),s.state=mg,s.on.call("start",e,e.__data__,s.index,s.group),s.state===mg){for(s.state=wd,r=new Array(g=s.tween.length),m=0,p=-1;m<g;++m)(x=s.tween[m].value.call(e,e.__data__,s.index,s.group))&&(r[++p]=x);r.length=p+1}}function u(h){for(var m=h<s.duration?s.ease.call(null,h/s.duration):(s.timer.restart(d),s.state=fg,1),p=-1,g=r.length;++p<g;)r[p].call(e,m);s.state===fg&&(s.on.call("end",e,e.__data__,s.index,s.group),d())}function d(){s.state=Sd,s.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function _d(e,t){var s=e.__transition,i,r,o=!0,l;if(s){t=t==null?null:t+"";for(l in s){if((i=s[l]).name!==t){o=!1;continue}r=i.state>mg&&i.state<fg,i.state=Sd,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete s[l]}o&&delete e.__transition}}function E6(e){return this.each(function(){_d(this,e)})}function C6(e,t){var s,i;return function(){var r=qi(this,e),o=r.tween;if(o!==s){i=s=o;for(var l=0,u=i.length;l<u;++l)if(i[l].name===t){i=i.slice(),i.splice(l,1);break}}r.tween=i}}function A6(e,t,s){var i,r;if(typeof s!="function")throw new Error;return function(){var o=qi(this,e),l=o.tween;if(l!==i){r=(i=l).slice();for(var u={name:t,value:s},d=0,h=r.length;d<h;++d)if(r[d].name===t){r[d]=u;break}d===h&&r.push(u)}o.tween=r}}function $6(e,t){var s=this._id;if(e+="",arguments.length<2){for(var i=Ii(this.node(),s).tween,r=0,o=i.length,l;r<o;++r)if((l=i[r]).name===e)return l.value;return null}return this.each((t==null?C6:A6)(s,e,t))}function Ix(e,t,s){var i=e._id;return e.each(function(){var r=qi(this,i);(r.value||(r.value={}))[t]=s.apply(this,arguments)}),function(r){return Ii(r,i).value[t]}}function Z1(e,t){var s;return(typeof t=="number"?Zi:t instanceof Ua?Hd:(s=Ua(t))?(t=s,Hd):L1)(e,t)}function I6(e){return function(){this.removeAttribute(e)}}function T6(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 R6(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 O6(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 P6(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 L6(e,t){var s=gh(e),i=s==="transform"?g6:Z1;return this.attrTween(e,typeof t=="function"?(s.local?P6:O6)(s,i,Ix(this,"attr."+e,t)):t==null?(s.local?T6:I6)(s):(s.local?R6:M6)(s,i,t))}function z6(e,t){return function(s){this.setAttribute(e,t.call(this,s))}}function D6(e,t){return function(s){this.setAttributeNS(e.space,e.local,t.call(this,s))}}function F6(e,t){var s,i;function r(){var o=t.apply(this,arguments);return o!==i&&(s=(i=o)&&D6(e,o)),s}return r._value=t,r}function U6(e,t){var s,i;function r(){var o=t.apply(this,arguments);return o!==i&&(s=(i=o)&&z6(e,o)),s}return r._value=t,r}function B6(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=gh(e);return this.tween(s,(i.local?F6:U6)(i,t))}function H6(e,t){return function(){$x(this,e).delay=+t.apply(this,arguments)}}function Z6(e,t){return t=+t,function(){$x(this,e).delay=t}}function W6(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?H6:Z6)(t,e)):Ii(this.node(),t).delay}function V6(e,t){return function(){qi(this,e).duration=+t.apply(this,arguments)}}function q6(e,t){return t=+t,function(){qi(this,e).duration=t}}function G6(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?V6:q6)(t,e)):Ii(this.node(),t).duration}function K6(e,t){if(typeof t!="function")throw new Error;return function(){qi(this,e).ease=t}}function Y6(e){var t=this._id;return arguments.length?this.each(K6(t,e)):Ii(this.node(),t).ease}function X6(e,t){return function(){var s=t.apply(this,arguments);if(typeof s!="function")throw new Error;qi(this,e).ease=s}}function Q6(e){if(typeof e!="function")throw new Error;return this.each(X6(this._id,e))}function J6(e){typeof e!="function"&&(e=k1(e));for(var t=this._groups,s=t.length,i=new Array(s),r=0;r<s;++r)for(var o=t[r],l=o.length,u=i[r]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new vr(i,this._parents,this._name,this._id)}function eU(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,s=e._groups,i=t.length,r=s.length,o=Math.min(i,r),l=new Array(i),u=0;u<o;++u)for(var d=t[u],h=s[u],m=d.length,p=l[u]=new Array(m),g,x=0;x<m;++x)(g=d[x]||h[x])&&(p[x]=g);for(;u<i;++u)l[u]=t[u];return new vr(l,this._parents,this._name,this._id)}function tU(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 nU(e,t,s){var i,r,o=tU(t)?$x:qi;return function(){var l=o(this,e),u=l.on;u!==i&&(r=(i=u).copy()).on(t,s),l.on=r}}function sU(e,t){var s=this._id;return arguments.length<2?Ii(this.node(),s).on.on(e):this.each(nU(s,e,t))}function iU(e){return function(){var t=this.parentNode;for(var s in this.__transition)if(+s!==e)return;t&&t.removeChild(this)}}function rU(){return this.on("end.remove",iU(this._id))}function aU(e){var t=this._name,s=this._id;typeof e!="function"&&(e=Sx(e));for(var i=this._groups,r=i.length,o=new Array(r),l=0;l<r;++l)for(var u=i[l],d=u.length,h=o[l]=new Array(d),m,p,g=0;g<d;++g)(m=u[g])&&(p=e.call(m,m.__data__,g,u))&&("__data__"in m&&(p.__data__=m.__data__),h[g]=p,vh(h[g],t,s,g,h,Ii(m,s)));return new vr(o,this._parents,t,s)}function oU(e){var t=this._name,s=this._id;typeof e!="function"&&(e=b1(e));for(var i=this._groups,r=i.length,o=[],l=[],u=0;u<r;++u)for(var d=i[u],h=d.length,m,p=0;p<h;++p)if(m=d[p]){for(var g=e.call(m,m.__data__,p,d),x,k=Ii(m,s),b=0,j=g.length;b<j;++b)(x=g[b])&&vh(x,t,s,b,g,k);o.push(g),l.push(m)}return new vr(o,l,t,s)}var lU=Wc.prototype.constructor;function cU(){return new lU(this._groups,this._parents)}function uU(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 W1(e){return function(){this.style.removeProperty(e)}}function dU(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 hU(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 mU(e,t){var s,i,r,o="style."+t,l="end."+o,u;return function(){var d=qi(this,e),h=d.on,m=d.value[o]==null?u||(u=W1(t)):void 0;(h!==s||r!==m)&&(i=(s=h).copy()).on(l,r=m),d.on=i}}function fU(e,t,s){var i=(e+="")=="transform"?p6:Z1;return t==null?this.styleTween(e,uU(e,i)).on("end.style."+e,W1(e)):typeof t=="function"?this.styleTween(e,hU(e,i,Ix(this,"style."+e,t))).each(mU(this._id,e)):this.styleTween(e,dU(e,i,t),s).on("end.style."+e,null)}function pU(e,t,s){return function(i){this.style.setProperty(e,t.call(this,i),s)}}function gU(e,t,s){var i,r;function o(){var l=t.apply(this,arguments);return l!==r&&(i=(r=l)&&pU(e,l,s)),i}return o._value=t,o}function xU(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,gU(e,t,s??""))}function vU(e){return function(){this.textContent=e}}function yU(e){return function(){var t=e(this);this.textContent=t??""}}function bU(e){return this.tween("text",typeof e=="function"?yU(Ix(this,"text",e)):vU(e==null?"":e+""))}function kU(e){return function(t){this.textContent=e.call(this,t)}}function jU(e){var t,s;function i(){var r=e.apply(this,arguments);return r!==s&&(t=(s=r)&&kU(r)),t}return i._value=e,i}function NU(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,jU(e))}function wU(){for(var e=this._name,t=this._id,s=V1(),i=this._groups,r=i.length,o=0;o<r;++o)for(var l=i[o],u=l.length,d,h=0;h<u;++h)if(d=l[h]){var m=Ii(d,t);vh(d,e,s,h,l,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new vr(i,this._parents,e,s)}function SU(){var e,t,s=this,i=s._id,r=s.size();return new Promise(function(o,l){var u={value:l},d={value:function(){--r===0&&o()}};s.each(function(){var h=qi(this,i),m=h.on;m!==e&&(t=(e=m).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(d)),h.on=t}),r===0&&o()})}var _U=0;function vr(e,t,s,i){this._groups=e,this._parents=t,this._name=s,this._id=i}function V1(){return++_U}var dr=Wc.prototype;vr.prototype={constructor:vr,select:aU,selectAll:oU,selectChild:dr.selectChild,selectChildren:dr.selectChildren,filter:J6,merge:eU,selection:cU,transition:wU,call:dr.call,nodes:dr.nodes,node:dr.node,size:dr.size,empty:dr.empty,each:dr.each,on:sU,attr:L6,attrTween:B6,style:fU,styleTween:xU,text:bU,textTween:NU,remove:rU,tween:$6,delay:W6,duration:G6,ease:Y6,easeVarying:Q6,end:SU,[Symbol.iterator]:dr[Symbol.iterator]};function EU(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var CU={time:null,delay:0,duration:250,ease:EU};function AU(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 $U(e){var t,s;e instanceof vr?(t=e._id,e=e._name):(t=V1(),(s=CU).time=Ax(),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])&&vh(d,e,t,h,l,s||AU(d,t));return new vr(i,this._parents,e,t)}Wc.prototype.interrupt=E6;Wc.prototype.transition=$U;const cd=e=>()=>e;function IU(e,{sourceEvent:t,target:s,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function fr(e,t,s){this.k=e,this.x=t,this.y=s}fr.prototype={constructor:fr,scale:function(e){return e===1?this:new fr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new fr(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var yh=new fr(1,0,0);q1.prototype=fr.prototype;function q1(e){for(;!e.__zoom;)if(!(e=e.parentNode))return yh;return e.__zoom}function ep(e){e.stopImmediatePropagation()}function Wl(e){e.preventDefault(),e.stopImmediatePropagation()}function TU(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 Gk(){return this.__zoom||yh}function RU(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function OU(){return navigator.maxTouchPoints||"ontouchstart"in this}function PU(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 G1(){var e=TU,t=MU,s=PU,i=RU,r=OU,o=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],u=250,d=Nd,h=ph("start","zoom","end"),m,p,g,x=500,k=150,b=0,j=10;function w(T){T.property("__zoom",Gk).on("wheel.zoom",U,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",R).filter(r).on("touchstart.zoom",z).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(T,H,F,V){var D=T.selection?T.selection():T;D.property("__zoom",Gk),T!==D?M(T,H,F,V):D.interrupt().each(function(){O(this,arguments).event(V).start().zoom(null,typeof H=="function"?H.apply(this,arguments):H).end()})},w.scaleBy=function(T,H,F,V){w.scaleTo(T,function(){var D=this.__zoom.k,q=typeof H=="function"?H.apply(this,arguments):H;return D*q},F,V)},w.scaleTo=function(T,H,F,V){w.transform(T,function(){var D=t.apply(this,arguments),q=this.__zoom,te=F==null?E(D):typeof F=="function"?F.apply(this,arguments):F,G=q.invert(te),K=typeof H=="function"?H.apply(this,arguments):H;return s(_(S(q,K),te,G),D,l)},F,V)},w.translateBy=function(T,H,F,V){w.transform(T,function(){return s(this.__zoom.translate(typeof H=="function"?H.apply(this,arguments):H,typeof F=="function"?F.apply(this,arguments):F),t.apply(this,arguments),l)},null,V)},w.translateTo=function(T,H,F,V,D){w.transform(T,function(){var q=t.apply(this,arguments),te=this.__zoom,G=V==null?E(q):typeof V=="function"?V.apply(this,arguments):V;return s(yh.translate(G[0],G[1]).scale(te.k).translate(typeof H=="function"?-H.apply(this,arguments):-H,typeof F=="function"?-F.apply(this,arguments):-F),q,l)},V,D)};function S(T,H){return H=Math.max(o[0],Math.min(o[1],H)),H===T.k?T:new fr(H,T.x,T.y)}function _(T,H,F){var V=H[0]-F[0]*T.k,D=H[1]-F[1]*T.k;return V===T.x&&D===T.y?T:new fr(T.k,V,D)}function E(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function M(T,H,F,V){T.on("start.zoom",function(){O(this,arguments).event(V).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(V).end()}).tween("zoom",function(){var D=this,q=arguments,te=O(D,q).event(V),G=t.apply(D,q),K=F==null?E(G):typeof F=="function"?F.apply(D,q):F,Z=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),Y=D.__zoom,Q=typeof H=="function"?H.apply(D,q):H,ie=d(Y.invert(K).concat(Z/Y.k),Q.invert(K).concat(Z/Q.k));return function(re){if(re===1)re=Q;else{var ne=ie(re),fe=Z/ne[2];re=new fr(fe,K[0]-ne[0]*fe,K[1]-ne[1]*fe)}te.zoom(null,re)}})}function O(T,H,F){return!F&&T.__zooming||new B(T,H)}function B(T,H){this.that=T,this.args=H,this.active=0,this.sourceEvent=null,this.extent=t.apply(T,H),this.taps=0}B.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,H){return this.mouse&&T!=="mouse"&&(this.mouse[1]=H.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=H.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=H.invert(this.touch1[0])),this.that.__zoom=H,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var H=Bs(this.that).datum();h.call(T,this.that,new IU(T,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:h}),H)}};function U(T,...H){if(!e.apply(this,arguments))return;var F=O(this,H).event(T),V=this.__zoom,D=Math.max(o[0],Math.min(o[1],V.k*Math.pow(2,i.apply(this,arguments)))),q=ji(T);if(F.wheel)(F.mouse[0][0]!==q[0]||F.mouse[0][1]!==q[1])&&(F.mouse[1]=V.invert(F.mouse[0]=q)),clearTimeout(F.wheel);else{if(V.k===D)return;F.mouse=[q,V.invert(q)],_d(this),F.start()}Wl(T),F.wheel=setTimeout(te,k),F.zoom("mouse",s(_(S(V,D),F.mouse[0],F.mouse[1]),F.extent,l));function te(){F.wheel=null,F.end()}}function P(T,...H){if(g||!e.apply(this,arguments))return;var F=T.currentTarget,V=O(this,H,!0).event(T),D=Bs(T.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",Z,!0),q=ji(T,F),te=T.clientX,G=T.clientY;I1(T.view),ep(T),V.mouse=[q,this.__zoom.invert(q)],_d(this),V.start();function K(Y){if(Wl(Y),!V.moved){var Q=Y.clientX-te,ie=Y.clientY-G;V.moved=Q*Q+ie*ie>b}V.event(Y).zoom("mouse",s(_(V.that.__zoom,V.mouse[0]=ji(Y,F),V.mouse[1]),V.extent,l))}function Z(Y){D.on("mousemove.zoom mouseup.zoom",null),T1(Y.view,V.moved),Wl(Y),V.event(Y).end()}}function R(T,...H){if(e.apply(this,arguments)){var F=this.__zoom,V=ji(T.changedTouches?T.changedTouches[0]:T,this),D=F.invert(V),q=F.k*(T.shiftKey?.5:2),te=s(_(S(F,q),V,D),t.apply(this,H),l);Wl(T),u>0?Bs(this).transition().duration(u).call(M,te,V,T):Bs(this).call(w.transform,te,V,T)}}function z(T,...H){if(e.apply(this,arguments)){var F=T.touches,V=F.length,D=O(this,H,T.changedTouches.length===V).event(T),q,te,G,K;for(ep(T),te=0;te<V;++te)G=F[te],K=ji(G,this),K=[K,this.__zoom.invert(K),G.identifier],D.touch0?!D.touch1&&D.touch0[2]!==K[2]&&(D.touch1=K,D.taps=0):(D.touch0=K,q=!0,D.taps=1+!!m);m&&(m=clearTimeout(m)),q&&(D.taps<2&&(p=K[0],m=setTimeout(function(){m=null},x)),_d(this),D.start())}}function L(T,...H){if(this.__zooming){var F=O(this,H).event(T),V=T.changedTouches,D=V.length,q,te,G,K;for(Wl(T),q=0;q<D;++q)te=V[q],G=ji(te,this),F.touch0&&F.touch0[2]===te.identifier?F.touch0[0]=G:F.touch1&&F.touch1[2]===te.identifier&&(F.touch1[0]=G);if(te=F.that.__zoom,F.touch1){var Z=F.touch0[0],Y=F.touch0[1],Q=F.touch1[0],ie=F.touch1[1],re=(re=Q[0]-Z[0])*re+(re=Q[1]-Z[1])*re,ne=(ne=ie[0]-Y[0])*ne+(ne=ie[1]-Y[1])*ne;te=S(te,Math.sqrt(re/ne)),G=[(Z[0]+Q[0])/2,(Z[1]+Q[1])/2],K=[(Y[0]+ie[0])/2,(Y[1]+ie[1])/2]}else if(F.touch0)G=F.touch0[0],K=F.touch0[1];else return;F.zoom("touch",s(_(te,G,K),F.extent,l))}}function A(T,...H){if(this.__zooming){var F=O(this,H).event(T),V=T.changedTouches,D=V.length,q,te;for(ep(T),g&&clearTimeout(g),g=setTimeout(function(){g=null},x),q=0;q<D;++q)te=V[q],F.touch0&&F.touch0[2]===te.identifier?delete F.touch0:F.touch1&&F.touch1[2]===te.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(te=ji(te,this),Math.hypot(p[0]-te[0],p[1]-te[1])<j)){var G=Bs(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return w.wheelDelta=function(T){return arguments.length?(i=typeof T=="function"?T:cd(+T),w):i},w.filter=function(T){return arguments.length?(e=typeof T=="function"?T:cd(!!T),w):e},w.touchable=function(T){return arguments.length?(r=typeof T=="function"?T:cd(!!T),w):r},w.extent=function(T){return arguments.length?(t=typeof T=="function"?T:cd([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),w):t},w.scaleExtent=function(T){return arguments.length?(o[0]=+T[0],o[1]=+T[1],w):[o[0],o[1]]},w.translateExtent=function(T){return arguments.length?(l[0][0]=+T[0][0],l[1][0]=+T[1][0],l[0][1]=+T[0][1],l[1][1]=+T[1][1],w):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},w.constrain=function(T){return arguments.length?(s=T,w):s},w.duration=function(T){return arguments.length?(u=+T,w):u},w.interpolate=function(T){return arguments.length?(d=T,w):d},w.on=function(){var T=h.on.apply(h,arguments);return T===h?w:T},w.clickDistance=function(T){return arguments.length?(b=(T=+T)*T,w):Math.sqrt(b)},w.tapDistance=function(T){return arguments.length?(j=+T,w):j},w}const Ai={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:s,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Ac=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],K1=["Enter"," ","Escape"],Y1={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:s})=>`Moved selected node ${e}. New position, x: ${t}, y: ${s}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Qo;(function(e){e.Strict="strict",e.Loose="loose"})(Qo||(Qo={}));var Da;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Da||(Da={}));var $c;(function(e){e.Partial="partial",e.Full="full"})($c||($c={}));const X1={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Wr;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Wr||(Wr={}));var qd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(qd||(qd={}));var tt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(tt||(tt={}));const Kk={[tt.Left]:tt.Right,[tt.Right]:tt.Left,[tt.Top]:tt.Bottom,[tt.Bottom]:tt.Top},Q1=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,LU=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Tx=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),qc=(e,t=[0,0])=>{const{width:s,height:i}=Ti(e),r=e.origin??t,o=s*r[0],l=i*r[1];return{x:e.position.x-o,y:e.position.y-l}},zU=(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):Tx(o)?o:t.nodeLookup.get(o.id)),u?(s=!0,bh(r,Gd(u,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return s?kh(i):{x:0,y:0,width:0,height:0}},Gc=(e,t={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(s=bh(s,Gd(r)),i=!0)}),i?kh(s):{x:0,y:0,width:0,height:0}},Mx=(e,t,[s,i,r]=[0,0,1],o=!1,l=!1)=>{const u=(t.x-s)/r,d=(t.y-i)/r,h=t.width/r,m=t.height/r,p=[];for(const g of e.values()){const{measured:x,selectable:k=!0,hidden:b=!1}=g;if(l&&!k||b)continue;const j=x.width??g.width??g.initialWidth??0,w=x.height??g.height??g.initialHeight??0,{x:S,y:_}=g.internals.positionAbsolute,E=n_(u,d,h,m,S,_,j,w),M=j*w,O=o&&E>0;(!g.internals.handleBounds||O||E>=M||g.dragging)&&p.push(g)}return p},DU=(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 FU(e,t){const s=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let o;if(t!=null&&t.includeHiddenNodes){const{width:l,height:u}=Ti(r);o=l>0&&u>0}else o=!!(r.measured.width&&r.measured.height&&!r.hidden);o&&(!i||i.has(r.id))&&s.set(r.id,r)}),s}async function UU({nodes:e,width:t,height:s,panZoom:i,minZoom:r,maxZoom:o},l){if(e.size===0)return!0;const u=FU(e,l),d=Gc(u),h=Ox(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 J1({nodeId:e,nextPosition:t,nodeLookup:s,nodeOrigin:i=[0,0],nodeExtent:r,onError:o}){const l=s.get(e),u=l.parentId?s.get(l.parentId):void 0,{x:d,y:h}=u?u.internals.positionAbsolute:{x:0,y:0},m=l.origin??i;let p=l.extent||r;if(l.extent==="parent"&&!l.expandParent)if(!u)o==null||o("005",Ai.error005());else{const{width:x,height:k}=Ti(u);x&&k&&(p=[[d,h],[d+x,h+k]])}else u&&Za(l.extent)&&(p=[[l.extent[0][0]+d,l.extent[0][1]+h],[l.extent[1][0]+d,l.extent[1][1]+h]]);const g=Za(p)?Ha(t,p,l.measured):t;return(l.measured.width===void 0||l.measured.height===void 0)&&(o==null||o("015",Ai.error015())),{position:{x:g.x-d+(l.measured.width??0)*m[0],y:g.y-h+(l.measured.height??0)*m[1]},positionAbsolute:g}}async function BU({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),k=!x&&g.parentId&&l.find(b=>b.id===g.parentId);(x||k)&&l.push(g)}const u=new Set(t.map(g=>g.id)),d=i.filter(g=>g.deletable!==!1),m=DU(l,d);for(const g of d)u.has(g.id)&&!m.find(k=>k.id===g.id)&&m.push(g);if(!r)return{edges:m,nodes:l};const p=await r({nodes:l,edges:m});return typeof p=="boolean"?p?{edges:m,nodes:l}:{edges:[],nodes:[]}:p}const Jo=(e,t=0,s=1)=>Math.min(Math.max(e,t),s),Ha=(e={x:0,y:0},t,s)=>({x:Jo(e.x,t[0][0],t[1][0]-((s==null?void 0:s.width)??0)),y:Jo(e.y,t[0][1],t[1][1]-((s==null?void 0:s.height)??0))});function e_(e,t,s){const{width:i,height:r}=Ti(s),{x:o,y:l}=s.internals.positionAbsolute;return Ha(e,[[o,l],[o+i,l+r]],t)}const Yk=(e,t,s)=>e<t?Jo(Math.abs(e-t),1,t)/t:e>s?-Jo(Math.abs(e-s),1,t)/t:0,Rx=(e,t,s=15,i=40)=>{const r=Yk(e.x,i,t.width-i)*s,o=Yk(e.y,i,t.height-i)*s;return[r,o]},bh=(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)}),pg=({x:e,y:t,width:s,height:i})=>({x:e,y:t,x2:e+s,y2:t+i}),kh=({x:e,y:t,x2:s,y2:i})=>({x:e,y:t,width:s-e,height:i-t}),Ic=(e,t=[0,0])=>{var r,o;const{x:s,y:i}=Tx(e)?e.internals.positionAbsolute:qc(e,t);return{x:s,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},Gd=(e,t=[0,0])=>{var r,o;const{x:s,y:i}=Tx(e)?e.internals.positionAbsolute:qc(e,t);return{x:s,y:i,x2:s+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},t_=(e,t)=>kh(bh(pg(e),pg(t))),n_=(e,t,s,i,r,o,l,u)=>{const d=Math.max(0,Math.min(e+s,r+l)-Math.max(e,r)),h=Math.max(0,Math.min(t+i,o+u)-Math.max(t,o));return Math.ceil(d*h)},Kd=(e,t)=>n_(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Xk=e=>_i(e.width)&&_i(e.height)&&_i(e.x)&&_i(e.y),_i=e=>!isNaN(e)&&isFinite(e),s_=(e,t)=>(s,i)=>{},Kc=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Yc=({x:e,y:t},[s,i,r],o=!1,l=[1,1])=>{const u={x:(e-s)/r,y:(t-i)/r};return o?Kc(u,l):u},el=({x:e,y:t},[s,i,r])=>({x:e*r+s,y:t*r+i});function bo(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(s)}if(typeof e=="string"&&e.endsWith("%")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(t*s*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function HU(e,t,s){if(typeof e=="string"||typeof e=="number"){const i=bo(e,s),r=bo(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=bo(e.top??e.y??0,s),r=bo(e.bottom??e.y??0,s),o=bo(e.left??e.x??0,t),l=bo(e.right??e.x??0,t);return{top:i,right:l,bottom:r,left:o,x:o+l,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ZU(e,t,s,i,r,o){const{x:l,y:u}=el(e,[t,s,i]),{x:d,y:h}=el({x:e.x+e.width,y:e.y+e.height},[t,s,i]),m=r-d,p=o-h;return{left:Math.floor(l),top:Math.floor(u),right:Math.floor(m),bottom:Math.floor(p)}}const Ox=(e,t,s,i,r,o)=>{const l=HU(o,t,s),u=(t-l.x)/e.width,d=(s-l.y)/e.height,h=Math.min(u,d),m=Jo(h,i,r),p=e.x+e.width/2,g=e.y+e.height/2,x=t/2-p*m,k=s/2-g*m,b=ZU(e,x,k,m,t,s),j={left:Math.min(b.left-l.left,0),top:Math.min(b.top-l.top,0),right:Math.min(b.right-l.right,0),bottom:Math.min(b.bottom-l.bottom,0)};return{x:x-j.left+j.right,y:k-j.top+j.bottom,zoom:m}},Tc=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Za(e){return e!=null&&e!=="parent"}function Ti(e){var t,s;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((s=e.measured)==null?void 0:s.height)??e.height??e.initialHeight??0}}function i_(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 r_(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 Qk(e,t){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}function WU(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function VU(e){return{...Y1,...e||{}}}function a_(e){return e===null?null:e?"valid":"invalid"}function pc(e,{snapGrid:t=[0,0],snapToGrid:s=!1,transform:i,containerBounds:r}){const{x:o,y:l}=Ei(e),u=Yc({x:o-((r==null?void 0:r.left)??0),y:l-((r==null?void 0:r.top)??0)},i),{x:d,y:h}=s?Kc(u,t):u;return{xSnapped:d,ySnapped:h,...u}}const Px=e=>({width:e.offsetWidth,height:e.offsetHeight}),o_=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},qU=["INPUT","SELECT","TEXTAREA"];function l_(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:qU.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const c_=e=>"clientX"in e,Ei=(e,t)=>{var o,l;const s=c_(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)}},Jk=(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,...Px(l)}})};function u_({sourceX:e,sourceY:t,targetX:s,targetY:i,sourceControlX:r,sourceControlY:o,targetControlX:l,targetControlY:u}){const d=e*.125+r*.375+l*.375+s*.125,h=t*.125+o*.375+u*.375+i*.125,m=Math.abs(d-e),p=Math.abs(h-t);return[d,h,m,p]}function ud(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ej({pos:e,x1:t,y1:s,x2:i,y2:r,c:o}){switch(e){case tt.Left:return[t-ud(t-i,o),s];case tt.Right:return[t+ud(i-t,o),s];case tt.Top:return[t,s-ud(s-r,o)];case tt.Bottom:return[t,s+ud(r-s,o)]}}function d_({sourceX:e,sourceY:t,sourcePosition:s=tt.Bottom,targetX:i,targetY:r,targetPosition:o=tt.Top,curvature:l=.25}){const[u,d]=ej({pos:s,x1:e,y1:t,x2:i,y2:r,c:l}),[h,m]=ej({pos:o,x1:i,y1:r,x2:e,y2:t,c:l}),[p,g,x,k]=u_({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:u,sourceControlY:d,targetControlX:h,targetControlY:m});return[`M${e},${t} C${u},${d} ${h},${m} ${i},${r}`,p,g,x,k]}function h_({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 GU({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 KU({sourceNode:e,targetNode:t,width:s,height:i,transform:r}){const o=bh(Gd(e),Gd(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const l={x:-r[0]/r[2],y:-r[1]/r[2],width:s/r[2],height:i/r[2]};return Kd(l,kh(o))>0}const YU=({source:e,sourceHandle:t,target:s,targetHandle:i})=>`xy-edge__${e}${t||""}-${s}${i||""}`,XU=(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)),QU=(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||YU;let r;return Q1(e)?r={...e}:r={...e,id:i(e)},XU(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function m_({sourceX:e,sourceY:t,targetX:s,targetY:i}){const[r,o,l,u]=h_({sourceX:e,sourceY:t,targetX:s,targetY:i});return[`M ${e},${t}L ${s},${i}`,r,o,l,u]}const tj={[tt.Left]:{x:-1,y:0},[tt.Right]:{x:1,y:0},[tt.Top]:{x:0,y:-1},[tt.Bottom]:{x:0,y:1}},JU=({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},nj=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function eB({source:e,sourcePosition:t=tt.Bottom,target:s,targetPosition:i=tt.Top,center:r,offset:o,stepPosition:l}){const u=tj[t],d=tj[i],h={x:e.x+u.x*o,y:e.y+u.y*o},m={x:s.x+d.x*o,y:s.y+d.y*o},p=JU({source:h,sourcePosition:t,target:m}),g=p.x!==0?"x":"y",x=p[g];let k=[],b,j;const w={x:0,y:0},S={x:0,y:0},[,,_,E]=h_({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(u[g]*d[g]===-1){g==="x"?(b=r.x??h.x+(m.x-h.x)*l,j=r.y??(h.y+m.y)/2):(b=r.x??(h.x+m.x)/2,j=r.y??h.y+(m.y-h.y)*l);const U=[{x:b,y:h.y},{x:b,y:m.y}],P=[{x:h.x,y:j},{x:m.x,y:j}];u[g]===x?k=g==="x"?U:P:k=g==="x"?P:U}else{const U=[{x:h.x,y:m.y}],P=[{x:m.x,y:h.y}];if(g==="x"?k=u.x===x?P:U:k=u.y===x?U:P,t===i){const T=Math.abs(e[g]-s[g]);if(T<=o){const H=Math.min(o-1,o-T);u[g]===x?w[g]=(h[g]>e[g]?-1:1)*H:S[g]=(m[g]>s[g]?-1:1)*H}}if(t!==i){const T=g==="x"?"y":"x",H=u[g]===d[T],F=h[T]>m[T],V=h[T]<m[T];(u[g]===1&&(!H&&F||H&&V)||u[g]!==1&&(!H&&V||H&&F))&&(k=g==="x"?U:P)}const R={x:h.x+w.x,y:h.y+w.y},z={x:m.x+S.x,y:m.y+S.y},L=Math.max(Math.abs(R.x-k[0].x),Math.abs(z.x-k[0].x)),A=Math.max(Math.abs(R.y-k[0].y),Math.abs(z.y-k[0].y));L>=A?(b=(R.x+z.x)/2,j=k[0].y):(b=k[0].x,j=(R.y+z.y)/2)}const M={x:h.x+w.x,y:h.y+w.y},O={x:m.x+S.x,y:m.y+S.y};return[[e,...M.x!==k[0].x||M.y!==k[0].y?[M]:[],...k,...O.x!==k[k.length-1].x||O.y!==k[k.length-1].y?[O]:[],s],b,j,_,E]}function tB(e,t,s,i){const r=Math.min(nj(e,t)/2,nj(t,s)/2,i),{x:o,y:l}=t;if(e.x===o&&o===s.x||e.y===l&&l===s.y)return`L${o} ${l}`;if(e.y===l){const h=e.x<s.x?-1:1,m=e.y<s.y?1:-1;return`L ${o+r*h},${l}Q ${o},${l} ${o},${l+r*m}`}const u=e.x<s.x?1:-1,d=e.y<s.y?-1:1;return`L ${o},${l+r*d}Q ${o},${l} ${o+r*u},${l}`}function gg({sourceX:e,sourceY:t,sourcePosition:s=tt.Bottom,targetX:i,targetY:r,targetPosition:o=tt.Top,borderRadius:l=5,centerX:u,centerY:d,offset:h=20,stepPosition:m=.5}){const[p,g,x,k,b]=eB({source:{x:e,y:t},sourcePosition:s,target:{x:i,y:r},targetPosition:o,center:{x:u,y:d},offset:h,stepPosition:m});let j=`M${p[0].x} ${p[0].y}`;for(let w=1;w<p.length-1;w++)j+=tB(p[w-1],p[w],p[w+1],l);return j+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[j,g,x,k,b]}function sj(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function nB(e){var p;const{sourceNode:t,targetNode:s}=e;if(!sj(t)||!sj(s))return null;const i=t.internals.handleBounds||ij(t.handles),r=s.internals.handleBounds||ij(s.handles),o=rj((i==null?void 0:i.source)??[],e.sourceHandle),l=rj(e.connectionMode===Qo.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!o||!l)return(p=e.onError)==null||p.call(e,"008",Ai.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const u=(o==null?void 0:o.position)||tt.Bottom,d=(l==null?void 0:l.position)||tt.Top,h=Wa(t,o,u),m=Wa(s,l,d);return{sourceX:h.x,sourceY:h.y,targetX:m.x,targetY:m.y,sourcePosition:u,targetPosition:d}}function ij(e){if(!e)return null;const t=[],s=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&s.push(i);return{source:t,target:s}}function Wa(e,t,s=tt.Left,i=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:l,height:u}=t??Ti(e);if(i)return{x:r+l/2,y:o+u/2};switch((t==null?void 0:t.position)??s){case tt.Top:return{x:r+l/2,y:o};case tt.Right:return{x:r+l,y:o+u/2};case tt.Bottom:return{x:r+l/2,y:o+u};case tt.Left:return{x:r,y:o+u/2}}}function rj(e,t){return e&&(t?e.find(s=>s.id===t):e[0])||null}function xg(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function sB(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=xg(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 f_=1e3,iB=10,Lx={nodeOrigin:[0,0],nodeExtent:Ac,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},rB={...Lx,checkEquality:!0};function zx(e,t){const s={...e};for(const i in t)t[i]!==void 0&&(s[i]=t[i]);return s}function aB(e,t,s){const i=zx(Lx,s);for(const r of e.values())if(r.parentId)Fx(r,e,t,i);else{const o=qc(r,i.nodeOrigin),l=Za(r.extent)?r.extent:i.nodeExtent,u=Ha(o,l,Ti(r));r.internals.positionAbsolute=u}}function oB(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 Dx(e){return e==="manual"}function vg(e,t,s,i={}){var m,p;const r=zx(rB,i),o={i:0},l=new Map(t),u=r!=null&&r.elevateNodesOnSelect&&!Dx(r.zIndexMode)?f_: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 k=qc(g,r.nodeOrigin),b=Za(g.extent)?g.extent:r.nodeExtent,j=Ha(k,b,Ti(g));x={...r.defaults,...g,measured:{width:(m=g.measured)==null?void 0:m.width,height:(p=g.measured)==null?void 0:p.height},internals:{positionAbsolute:j,handleBounds:oB(g,x),z:p_(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&&Fx(x,t,s,i,o),h||(h=g.selected??!1)}return{nodesInitialized:d,hasSelectedNodes:h}}function lB(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 Fx(e,t,s,i,r){const{elevateNodesOnSelect:o,nodeOrigin:l,nodeExtent:u,zIndexMode:d}=zx(Lx,i),h=e.parentId,m=t.get(h);if(!m){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}lB(e,s),r&&!m.parentId&&m.internals.rootParentIndex===void 0&&d==="auto"&&(m.internals.rootParentIndex=++r.i,m.internals.z=m.internals.z+r.i*iB),r&&m.internals.rootParentIndex!==void 0&&(r.i=m.internals.rootParentIndex);const p=o&&!Dx(d)?f_:0,{x:g,y:x,z:k}=cB(e,m,l,u,p,d),{positionAbsolute:b}=e.internals,j=g!==b.x||x!==b.y;(j||k!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:j?{x:g,y:x}:b,z:k}})}function p_(e,t,s){const i=_i(e.zIndex)?e.zIndex:0;return Dx(s)?i:i+(e.selected?t:0)}function cB(e,t,s,i,r,o){const{x:l,y:u}=t.internals.positionAbsolute,d=Ti(e),h=qc(e,s),m=Za(e.extent)?Ha(h,e.extent,d):h;let p=Ha({x:l+m.x,y:u+m.y},i,d);e.extent==="parent"&&(p=e_(p,d,t));const g=p_(e,r,o),x=t.internals.z??0;return{x:p.x,y:p.y,z:x>=g?x+1:g}}function Ux(e,t,s,i=[0,0]){var l;const r=[],o=new Map;for(const u of e){const d=t.get(u.parentId);if(!d)continue;const h=((l=o.get(u.parentId))==null?void 0:l.expandedRect)??Ic(d),m=t_(h,u.rect);o.set(u.parentId,{expandedRect:m,parent:d})}return o.size>0&&o.forEach(({expandedRect:u,parent:d},h)=>{var _;const m=d.internals.positionAbsolute,p=Ti(d),g=d.origin??i,x=u.x<m.x?Math.round(Math.abs(m.x-u.x)):0,k=u.y<m.y?Math.round(Math.abs(m.y-u.y)):0,b=Math.max(p.width,Math.round(u.width)),j=Math.max(p.height,Math.round(u.height)),w=(b-p.width)*g[0],S=(j-p.height)*g[1];(x>0||k>0||w||S)&&(r.push({id:h,type:"position",position:{x:d.position.x-x+w,y:d.position.y-k+S}}),(_=s.get(h))==null||_.forEach(E=>{e.some(M=>M.id===E.id)||r.push({id:E.id,type:"position",position:{x:E.position.x+x,y:E.position.y+k}})})),(p.width<u.width||p.height<u.height||x||k)&&r.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:b+(x?g[0]*x-w:0),height:j+(k?g[1]*k-S:0)}})}),r}function uB(e,t,s,i,r,o,l){const u=i==null?void 0:i.querySelector(".xyflow__viewport");let d=!1;if(!u)return{changes:[],updatedInternals:d};const h=[],m=window.getComputedStyle(u),{m22:p}=new window.DOMMatrixReadOnly(m.transform),g=[];for(const x of e.values()){const k=t.get(x.id);if(!k)continue;if(k.hidden){t.set(k.id,{...k,internals:{...k.internals,handleBounds:void 0}}),d=!0;continue}const b=Px(x.nodeElement),j=k.measured.width!==b.width||k.measured.height!==b.height;if(!!(b.width&&b.height&&(j||!k.internals.handleBounds||x.force))){const S=x.nodeElement.getBoundingClientRect(),_=Za(k.extent)?k.extent:o;let{positionAbsolute:E}=k.internals;if(k.parentId&&k.extent==="parent"){const O=t.get(k.parentId);O&&(E=e_(E,b,O))}else _&&(E=Ha(E,_,b));const M={...k,measured:b,internals:{...k.internals,positionAbsolute:E,handleBounds:{source:Jk("source",x.nodeElement,S,p,k.id),target:Jk("target",x.nodeElement,S,p,k.id)}}};t.set(k.id,M),k.parentId&&Fx(M,t,s,{nodeOrigin:r,zIndexMode:l}),d=!0,j&&(h.push({id:k.id,type:"dimensions",dimensions:b}),k.expandParent&&k.parentId&&g.push({id:k.id,parentId:k.parentId,rect:Ic(M,r)}))}}if(g.length>0){const x=Ux(g,t,s,r);h.push(...x)}return{changes:h,updatedInternals:d}}async function dB({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 aj(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 g_(e,t,s){e.clear(),t.clear();for(const i of s){const{source:r,target:o,sourceHandle:l=null,targetHandle:u=null}=i,d={edgeId:i.id,source:r,target:o,sourceHandle:l,targetHandle:u},h=`${r}-${l}--${o}-${u}`,m=`${o}-${u}--${r}-${l}`;aj("source",d,m,e,r,l),aj("target",d,h,e,o,u),t.set(i.id,i)}}function x_(e,t){if(!e.parentId)return!1;const s=t.get(e.parentId);return s?s.selected?!0:x_(s,t):!1}function oj(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 hB(e,t,s,i){const r=new Map;for(const[o,l]of e)if((l.selected||l.id===i)&&(!l.parentId||!x_(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 tp({nodeId:e,dragItems:t,nodeLookup:s,dragging:i=!0}){var l,u,d;const r=[];for(const[h,m]of t){const p=(l=s.get(h))==null?void 0:l.internals.userNode;p&&r.push({...p,position:m.position,dragging:i})}if(!e)return[r[0],r];const o=(u=s.get(e))==null?void 0:u.internals.userNode;return[o?{...o,position:((d=t.get(e))==null?void 0:d.position)||o.position,dragging:i}:r[0],r]}function mB({dragItems:e,snapGrid:t,x:s,y:i}){const r=e.values().next().value;if(!r)return null;const o={x:s-r.distance.x,y:i-r.distance.y},l=Kc(o,t);return{x:l.x-o.x,y:l.y-o.y}}function fB({onNodeMouseDown:e,getStoreItems:t,onDragStart:s,onDrag:i,onDragStop:r}){let o={x:null,y:null},l=0,u=new Map,d=!1,h={x:0,y:0},m=null,p=!1,g=null,x=!1,k=!1,b=null;function j({noDragClassName:S,handleSelector:_,domNode:E,isSelectable:M,nodeId:O,nodeClickDistance:B=0}){g=Bs(E);function U({x:L,y:A}){const{nodeLookup:T,nodeExtent:H,snapGrid:F,snapToGrid:V,nodeOrigin:D,onNodeDrag:q,onSelectionDrag:te,onError:G,updateNodePositions:K}=t();o={x:L,y:A};let Z=!1;const Y=u.size>1,Q=Y&&H?pg(Gc(u)):null,ie=Y&&V?mB({dragItems:u,snapGrid:F,x:L,y:A}):null;for(const[re,ne]of u){if(!T.has(re))continue;let fe={x:L-ne.distance.x,y:A-ne.distance.y};V&&(fe=ie?{x:Math.round(fe.x+ie.x),y:Math.round(fe.y+ie.y)}:Kc(fe,F));let Ee=null;if(Y&&H&&!ne.extent&&Q){const{positionAbsolute:pe}=ne.internals,be=pe.x-Q.x+H[0][0],De=pe.x+ne.measured.width-Q.x2+H[1][0],Re=pe.y-Q.y+H[0][1],ae=pe.y+ne.measured.height-Q.y2+H[1][1];Ee=[[be,Re],[De,ae]]}const{position:Ue,positionAbsolute:Te}=J1({nodeId:re,nextPosition:fe,nodeLookup:T,nodeExtent:Ee||H,nodeOrigin:D,onError:G});Z=Z||ne.position.x!==Ue.x||ne.position.y!==Ue.y,ne.position=Ue,ne.internals.positionAbsolute=Te}if(k=k||Z,!!Z&&(K(u,!0),b&&(i||q||!O&&te))){const[re,ne]=tp({nodeId:O,dragItems:u,nodeLookup:T});i==null||i(b,u,re,ne),q==null||q(b,re,ne),O||te==null||te(b,ne)}}async function P(){if(!m)return;const{transform:L,panBy:A,autoPanSpeed:T,autoPanOnNodeDrag:H}=t();if(!H){d=!1,cancelAnimationFrame(l);return}const[F,V]=Rx(h,m,T);(F!==0||V!==0)&&(o.x=(o.x??0)-F/L[2],o.y=(o.y??0)-V/L[2],await A({x:F,y:V})&&U(o)),l=requestAnimationFrame(P)}function R(L){var Y;const{nodeLookup:A,multiSelectionActive:T,nodesDraggable:H,transform:F,snapGrid:V,snapToGrid:D,selectNodesOnDrag:q,onNodeDragStart:te,onSelectionDragStart:G,unselectNodesAndEdges:K}=t();p=!0,(!q||!M)&&!T&&O&&((Y=A.get(O))!=null&&Y.selected||K()),M&&q&&O&&(e==null||e(O));const Z=pc(L.sourceEvent,{transform:F,snapGrid:V,snapToGrid:D,containerBounds:m});if(o=Z,u=hB(A,H,Z,O),u.size>0&&(s||te||!O&&G)){const[Q,ie]=tp({nodeId:O,dragItems:u,nodeLookup:A});s==null||s(L.sourceEvent,u,Q,ie),te==null||te(L.sourceEvent,Q,ie),O||G==null||G(L.sourceEvent,ie)}}const z=M1().clickDistance(B).on("start",L=>{const{domNode:A,nodeDragThreshold:T,transform:H,snapGrid:F,snapToGrid:V}=t();m=(A==null?void 0:A.getBoundingClientRect())||null,x=!1,k=!1,b=L.sourceEvent,T===0&&R(L),o=pc(L.sourceEvent,{transform:H,snapGrid:F,snapToGrid:V,containerBounds:m}),h=Ei(L.sourceEvent,m)}).on("drag",L=>{const{autoPanOnNodeDrag:A,transform:T,snapGrid:H,snapToGrid:F,nodeDragThreshold:V,nodeLookup:D}=t(),q=pc(L.sourceEvent,{transform:T,snapGrid:H,snapToGrid:F,containerBounds:m});if(b=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||O&&!D.has(O))&&(x=!0),!x){if(!d&&A&&p&&(d=!0,P()),!p){const te=Ei(L.sourceEvent,m),G=te.x-h.x,K=te.y-h.y;Math.sqrt(G*G+K*K)>V&&R(L)}(o.x!==q.xSnapped||o.y!==q.ySnapped)&&u&&p&&(h=Ei(L.sourceEvent,m),U(q))}}).on("end",L=>{if(!p||x){x&&u.size>0&&t().updateNodePositions(u,!1);return}if(d=!1,p=!1,cancelAnimationFrame(l),u.size>0){const{nodeLookup:A,updateNodePositions:T,onNodeDragStop:H,onSelectionDragStop:F}=t();if(k&&(T(u,!1),k=!1),r||H||!O&&F){const[V,D]=tp({nodeId:O,dragItems:u,nodeLookup:A,dragging:!1});r==null||r(L.sourceEvent,u,V,D),H==null||H(L.sourceEvent,V,D),O||F==null||F(L.sourceEvent,D)}}}).filter(L=>{const A=L.target;return!L.button&&(!S||!oj(A,`.${S}`,E))&&(!_||oj(A,_,E))});g.call(z)}function w(){g==null||g.on(".drag",null)}return{update:j,destroy:w}}function pB(e,t,s){const i=[],r={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const o of t.values())Kd(r,Ic(o))>0&&i.push(o);return i}const gB=250;function xB(e,t,s,i){var u,d;let r=[],o=1/0;const l=pB(e,s,t+gB);for(const h of l){const m=[...((u=h.internals.handleBounds)==null?void 0:u.source)??[],...((d=h.internals.handleBounds)==null?void 0:d.target)??[]];for(const p of m){if(i.nodeId===p.nodeId&&i.type===p.type&&i.id===p.id)continue;const{x:g,y:x}=Wa(h,p,p.position,!0),k=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(x-e.y,2));k>t||(k<o?(r=[{...p,x:g,y:x}],o=k):k===o&&r.push({...p,x:g,y:x}))}}if(!r.length)return null;if(r.length>1){const h=i.type==="source"?"target":"source";return r.find(m=>m.type===h)??r[0]}return r[0]}function v_(e,t,s,i,r,o=!1){var h,m,p;const l=i.get(e);if(!l)return null;const u=r==="strict"?(h=l.internals.handleBounds)==null?void 0:h[t]:[...((m=l.internals.handleBounds)==null?void 0:m.source)??[],...((p=l.internals.handleBounds)==null?void 0:p.target)??[]],d=(s?u==null?void 0:u.find(g=>g.id===s):u==null?void 0:u[0])??null;return d&&o?{...d,...Wa(l,d,d.position,!0)}:d}function y_(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function vB(e,t){let s=null;return t?s=!0:e&&!t&&(s=!1),s}const b_=()=>!0;function yB(e,{connectionMode:t,connectionRadius:s,handleId:i,nodeId:r,edgeUpdaterType:o,isTarget:l,domNode:u,nodeLookup:d,lib:h,autoPanOnConnect:m,flowId:p,panBy:g,cancelConnection:x,onConnectStart:k,onConnect:b,onConnectEnd:j,isValidConnection:w=b_,onReconnectEnd:S,updateConnection:_,getTransform:E,getFromHandle:M,autoPanSpeed:O,dragThreshold:B=1,handleDomNode:U}){const P=o_(e.target);let R=0,z;const{x:L,y:A}=Ei(e),T=y_(o,U),H=u==null?void 0:u.getBoundingClientRect();let F=!1;if(!H||!T)return;const V=v_(r,T,i,d,t);if(!V)return;let D=Ei(e,H),q=!1,te=null,G=!1,K=null;function Z(){if(!m||!H)return;const[Ue,Te]=Rx(D,H,O);g({x:Ue,y:Te}),R=requestAnimationFrame(Z)}const Y={...V,nodeId:r,type:T,position:V.position},Q=d.get(r);let re={inProgress:!0,isValid:null,from:Wa(Q,Y,tt.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:Q,to:D,toHandle:null,toPosition:Kk[Y.position],toNode:null,pointer:D};function ne(){F=!0,_(re),k==null||k(e,{nodeId:r,handleId:i,handleType:T})}B===0&&ne();function fe(Ue){if(!F){const{x:ae,y:Fe}=Ei(Ue),ut=ae-L,gt=Fe-A;if(!(ut*ut+gt*gt>B*B))return;ne()}if(!M()||!Y){Ee(Ue);return}const Te=E();D=Ei(Ue,H),z=xB(Yc(D,Te,!1,[1,1]),s,d,Y),q||(Z(),q=!0);const pe=k_(Ue,{handle:z,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:l?"target":"source",isValidConnection:w,doc:P,lib:h,flowId:p,nodeLookup:d});K=pe.handleDomNode,te=pe.connection,G=vB(!!z,pe.isValid);const be=d.get(r),De=be?Wa(be,Y,tt.Left,!0):re.from,Re={...re,from:De,isValid:G,to:pe.toHandle&&G?el({x:pe.toHandle.x,y:pe.toHandle.y},Te):D,toHandle:pe.toHandle,toPosition:G&&pe.toHandle?pe.toHandle.position:Kk[Y.position],toNode:pe.toHandle?d.get(pe.toHandle.nodeId):null,pointer:D};_(Re),re=Re}function Ee(Ue){if(!("touches"in Ue&&Ue.touches.length>0)){if(F){(z||K)&&te&&G&&(b==null||b(te));const{inProgress:Te,...pe}=re,be={...pe,toPosition:re.toHandle?re.toPosition:null};j==null||j(Ue,be),o&&(S==null||S(Ue,be))}x(),cancelAnimationFrame(R),q=!1,G=!1,te=null,K=null,P.removeEventListener("mousemove",fe),P.removeEventListener("mouseup",Ee),P.removeEventListener("touchmove",fe),P.removeEventListener("touchend",Ee)}}P.addEventListener("mousemove",fe),P.addEventListener("mouseup",Ee),P.addEventListener("touchmove",fe),P.addEventListener("touchend",Ee)}function k_(e,{handle:t,connectionMode:s,fromNodeId:i,fromHandleId:r,fromType:o,doc:l,lib:u,flowId:d,isValidConnection:h=b_,nodeLookup:m}){const p=o==="target",g=t?l.querySelector(`.${u}-flow__handle[data-id="${d}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x,y:k}=Ei(e),b=l.elementFromPoint(x,k),j=b!=null&&b.classList.contains(`${u}-flow__handle`)?b:g,w={handleDomNode:j,isValid:!1,connection:null,toHandle:null};if(j){const S=y_(void 0,j),_=j.getAttribute("data-nodeid"),E=j.getAttribute("data-handleid"),M=j.classList.contains("connectable"),O=j.classList.contains("connectableend");if(!_||!S)return w;const B={source:p?_:i,sourceHandle:p?E:r,target:p?i:_,targetHandle:p?r:E};w.connection=B;const P=M&&O&&(s===Qo.Strict?p&&S==="source"||!p&&S==="target":_!==i||E!==r);w.isValid=P&&h(B),w.toHandle=v_(_,S,E,m,s,!0)}return w}const yg={onPointerDown:yB,isValid:k_};function bB({domNode:e,panZoom:t,getTransform:s,getViewScale:i}){const r=Bs(e);function o({translateExtent:u,width:d,height:h,zoomStep:m=1,pannable:p=!0,zoomable:g=!0,inversePan:x=!1}){const k=_=>{if(_.sourceEvent.type!=="wheel"||!t)return;const E=s(),M=_.sourceEvent.ctrlKey&&Tc()?10:1,O=-_.sourceEvent.deltaY*(_.sourceEvent.deltaMode===1?.05:_.sourceEvent.deltaMode?1:.002)*m,B=E[2]*Math.pow(2,O*M);t.scaleTo(B)};let b=[0,0];const j=_=>{(_.sourceEvent.type==="mousedown"||_.sourceEvent.type==="touchstart")&&(b=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY])},w=_=>{const E=s();if(_.sourceEvent.type!=="mousemove"&&_.sourceEvent.type!=="touchmove"||!t)return;const M=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY],O=[M[0]-b[0],M[1]-b[1]];b=M;const B=i()*Math.max(E[2],Math.log(E[2]))*(x?-1:1),U={x:E[0]-O[0]*B,y:E[1]-O[1]*B},P=[[0,0],[d,h]];t.setViewportConstrained({x:U.x,y:U.y,zoom:E[2]},P,u)},S=G1().on("start",j).on("zoom",p?w:null).on("zoom.wheel",g?k:null);r.call(S,{})}function l(){r.on("zoom",null)}return{update:o,destroy:l,pointer:ji}}const jh=e=>({x:e.x,y:e.y,zoom:e.k}),np=({x:e,y:t,zoom:s})=>yh.translate(e,t).scale(s),Zr=(e,t)=>e.target.closest(`.${t}`),j_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),kB=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,sp=(e,t=0,s=kB,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(s).on("end",i):e},N_=e=>{const t=e.ctrlKey&&Tc()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function jB({zoomPanValues:e,noWheelClassName:t,d3Selection:s,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:o,zoomOnPinch:l,onPanZoomStart:u,onPanZoom:d,onPanZoomEnd:h}){return m=>{if(Zr(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const p=s.property("__zoom").k||1;if(m.ctrlKey&&l){const j=ji(m),w=N_(m),S=p*Math.pow(2,w);i.scaleTo(s,S,j,m);return}const g=m.deltaMode===1?20:1;let x=r===Da.Vertical?0:m.deltaX*g,k=r===Da.Horizontal?0:m.deltaY*g;!Tc()&&m.shiftKey&&r!==Da.Vertical&&(x=m.deltaY*g,k=0),i.translateBy(s,-(x/p)*o,-(k/p)*o,{internal:!0});const b=jh(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?d==null||d(m,b):(e.isPanScrolling=!0,u==null||u(m,b)),e.panScrollTimeout=setTimeout(()=>{h==null||h(m,b),e.isPanScrolling=!1},150)}}function NB({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:s}){return function(i,r){const o=i.type==="wheel",l=!t&&o&&!i.ctrlKey,u=Zr(i,e);if(i.ctrlKey&&o&&u&&i.preventDefault(),l||u)return null;i.preventDefault(),s.call(this,i,r)}}function wB({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:s}){return i=>{var o,l,u;if((o=i.sourceEvent)!=null&&o.internal)return;const r=jh(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 SB({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:s,onTransformChange:i,onPanZoom:r}){return o=>{var l,u;e.usedRightMouseButton=!!(s&&j_(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,jh(o.transform)))}}function _B({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&&j_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&l.sourceEvent&&o(l.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const d=jh(l.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(l.sourceEvent,d)},s?150:0)}}}function EB({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:s,zoomOnPinch:i,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:l,userSelectionActive:u,noWheelClassName:d,noPanClassName:h,lib:m,connectionInProgress:p}){return g=>{var w;const x=t||s,k=i&&g.ctrlKey,b=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(Zr(g,`${m}-flow__node`)||Zr(g,`${m}-flow__edge`)||Zr(g,`${m}-flow__selection`)||Zr(g,`${m}-flow__nodesselection`)))return!0;if(!r&&!x&&!o&&!l&&!i||u||p&&!b||Zr(g,d)&&b||Zr(g,h)&&(!b||o&&b&&!t)||!i&&g.ctrlKey&&b)return!1;if(!i&&g.type==="touchstart"&&((w=g.touches)==null?void 0:w.length)>1)return g.preventDefault(),!1;if(!x&&!o&&!k&&b||!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||b||e)&&j}}function CB({domNode:e,minZoom:t,maxZoom:s,translateExtent:i,viewport:r,onPanZoom:o,onPanZoomStart:l,onPanZoomEnd:u,onDraggingChange:d}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=e.getBoundingClientRect();let p=[[0,0],[m.width,m.height]];const g=typeof ResizeObserver<"u"?new ResizeObserver(A=>{const T=A[0];T&&(p=[[0,0],[T.contentRect.width,T.contentRect.height]])}):null;g==null||g.observe(e);const x=G1().extent(()=>p).scaleExtent([t,s]).translateExtent(i),k=Bs(e).call(x);E({x:r.x,y:r.y,zoom:Jo(r.zoom,t,s)},[[0,0],[m.width,m.height]],i);const b=k.on("wheel.zoom"),j=k.on("dblclick.zoom");x.wheelDelta(N_);async function w(A,T){return k?new Promise(H=>{x==null||x.interpolate((T==null?void 0:T.interpolate)==="linear"?fc:Nd).transform(sp(k,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>H(!0)),A)}):!1}function S({noWheelClassName:A,noPanClassName:T,onPaneContextMenu:H,userSelectionActive:F,panOnScroll:V,panOnDrag:D,panOnScrollMode:q,panOnScrollSpeed:te,preventScrolling:G,zoomOnPinch:K,zoomOnScroll:Z,zoomOnDoubleClick:Y,panActivationKeyPressed:Q=!1,zoomActivationKeyPressed:ie,lib:re,onTransformChange:ne,connectionInProgress:fe,paneClickDistance:Ee,selectionOnDrag:Ue}){F&&!h.isZoomingOrPanning&&_();const Te=V&&!ie&&!F;x.clickDistance(Ue?1/0:!_i(Ee)||Ee<0?0:Ee);const pe=Te?jB({zoomPanValues:h,noWheelClassName:A,d3Selection:k,d3Zoom:x,panOnScrollMode:q,panOnScrollSpeed:te,zoomOnPinch:K,onPanZoomStart:l,onPanZoom:o,onPanZoomEnd:u}):NB({noWheelClassName:A,preventScrolling:G,d3ZoomHandler:b});k.on("wheel.zoom",pe,{passive:!1});const be=wB({zoomPanValues:h,onDraggingChange:d,onPanZoomStart:l});x.on("start",be);const De=SB({zoomPanValues:h,panOnDrag:D,onPaneContextMenu:!!H,onPanZoom:o,onTransformChange:ne});x.on("zoom",De);const Re=_B({zoomPanValues:h,panOnDrag:D,panOnScroll:V,onPaneContextMenu:H,onPanZoomEnd:u,onDraggingChange:d});x.on("end",Re);const ae=EB({panActivationKeyPressed:Q,zoomActivationKeyPressed:ie,panOnDrag:D,zoomOnScroll:Z,panOnScroll:V,zoomOnDoubleClick:Y,zoomOnPinch:K,userSelectionActive:F,noPanClassName:T,noWheelClassName:A,lib:re,connectionInProgress:fe});x.filter(ae),Y?k.on("dblclick.zoom",j):k.on("dblclick.zoom",null)}function _(){x.on("zoom",null)}async function E(A,T,H){const F=np(A),V=x==null?void 0:x.constrain()(F,T,H);return V&&await w(V),V}async function M(A,T){const H=np(A);return await w(H,T),H}function O(A){if(k){const T=np(A),H=k.property("__zoom");(H.k!==A.zoom||H.x!==A.x||H.y!==A.y)&&(x==null||x.transform(k,T,null,{sync:!0}))}}function B(){const A=k?q1(k.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}async function U(A,T){return k?new Promise(H=>{x==null||x.interpolate((T==null?void 0:T.interpolate)==="linear"?fc:Nd).scaleTo(sp(k,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>H(!0)),A)}):!1}async function P(A,T){return k?new Promise(H=>{x==null||x.interpolate((T==null?void 0:T.interpolate)==="linear"?fc:Nd).scaleBy(sp(k,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>H(!0)),A)}):!1}function R(A){x==null||x.scaleExtent(A)}function z(A){x==null||x.translateExtent(A)}function L(A){const T=!_i(A)||A<0?0:A;x==null||x.clickDistance(T)}return{update:S,destroy:_,setViewport:M,setViewportConstrained:E,getViewport:B,scaleTo:U,scaleBy:P,setScaleExtent:R,setTranslateExtent:z,syncViewport:O,setClickDistance:L}}var tl;(function(e){e.Line="line",e.Handle="handle"})(tl||(tl={}));function AB({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 lj(e){const t=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:s,affectsX:i,affectsY:r}}function Fr(e,t){return Math.max(0,t-e)}function Ur(e,t){return Math.max(0,e-t)}function dd(e,t,s){return Math.max(0,t-e,e-s)}function cj(e,t){return e?!t:t}function $B(e,t,s,i,r,o,l,u){let{affectsX:d,affectsY:h}=t;const{isHorizontal:m,isVertical:p}=t,g=m&&p,{xSnapped:x,ySnapped:k}=s,{minWidth:b,maxWidth:j,minHeight:w,maxHeight:S}=i,{x:_,y:E,width:M,height:O,aspectRatio:B}=e;let U=Math.floor(m?x-e.pointerX:0),P=Math.floor(p?k-e.pointerY:0);const R=M+(d?-U:U),z=O+(h?-P:P),L=-o[0]*M,A=-o[1]*O;let T=dd(R,b,j),H=dd(z,w,S);if(l){let D=0,q=0;d&&U<0?D=Fr(_+U+L,l[0][0]):!d&&U>0&&(D=Ur(_+R+L,l[1][0])),h&&P<0?q=Fr(E+P+A,l[0][1]):!h&&P>0&&(q=Ur(E+z+A,l[1][1])),T=Math.max(T,D),H=Math.max(H,q)}if(u){let D=0,q=0;d&&U>0?D=Ur(_+U,u[0][0]):!d&&U<0&&(D=Fr(_+R,u[1][0])),h&&P>0?q=Ur(E+P,u[0][1]):!h&&P<0&&(q=Fr(E+z,u[1][1])),T=Math.max(T,D),H=Math.max(H,q)}if(r){if(m){const D=dd(R/B,w,S)*B;if(T=Math.max(T,D),l){let q=0;!d&&!h||d&&!h&&g?q=Ur(E+A+R/B,l[1][1])*B:q=Fr(E+A+(d?U:-U)/B,l[0][1])*B,T=Math.max(T,q)}if(u){let q=0;!d&&!h||d&&!h&&g?q=Fr(E+R/B,u[1][1])*B:q=Ur(E+(d?U:-U)/B,u[0][1])*B,T=Math.max(T,q)}}if(p){const D=dd(z*B,b,j)/B;if(H=Math.max(H,D),l){let q=0;!d&&!h||h&&!d&&g?q=Ur(_+z*B+L,l[1][0])/B:q=Fr(_+(h?P:-P)*B+L,l[0][0])/B,H=Math.max(H,q)}if(u){let q=0;!d&&!h||h&&!d&&g?q=Fr(_+z*B,u[1][0])/B:q=Ur(_+(h?P:-P)*B,u[0][0])/B,H=Math.max(H,q)}}}P=P+(P<0?H:-H),U=U+(U<0?T:-T),r&&(g?R>z*B?P=(cj(d,h)?-U:U)/B:U=(cj(d,h)?-P:P)*B:m?(P=U/B,h=d):(U=P*B,d=h));const F=d?_+U:_,V=h?E+P:E;return{width:M+(d?-U:U),height:O+(h?-P:P),x:o[0]*U*(d?-1:1)+F,y:o[1]*P*(h?-1:1)+V}}const w_={width:0,height:0,x:0,y:0},IB={...w_,pointerX:0,pointerY:0,aspectRatio:1};function TB(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:lj("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function u({controlPosition:h,boundaries:m,keepAspectRatio:p,resizeDirection:g,onResizeStart:x,onResize:k,onResizeEnd:b,shouldResize:j}){let w={...w_},S={...IB};l={boundaries:m,resizeDirection:g,keepAspectRatio:p,controlDirection:lj(h)};let _,E=null,M=[],O,B,U,P=!1;const R=M1().on("start",z=>{const{nodeLookup:L,transform:A,snapGrid:T,snapToGrid:H,nodeOrigin:F,paneDomNode:V}=s();if(_=L.get(t),!_)return;E=(V==null?void 0:V.getBoundingClientRect())??null;const{xSnapped:D,ySnapped:q}=pc(z.sourceEvent,{transform:A,snapGrid:T,snapToGrid:H,containerBounds:E});w={width:_.measured.width??0,height:_.measured.height??0,x:_.position.x??0,y:_.position.y??0},S={...w,pointerX:D,pointerY:q,aspectRatio:w.width/w.height},O=void 0,B=Za(_.extent)?_.extent:void 0,_.parentId&&(_.extent==="parent"||_.expandParent)&&(O=L.get(_.parentId)),O&&_.extent==="parent"&&(B=[[0,0],[O.measured.width,O.measured.height]]),M=[],U=void 0;for(const[te,G]of L)if(G.parentId===t&&(M.push({id:te,position:{...G.position},extent:G.extent}),G.extent==="parent"||G.expandParent)){const K=TB(G,_,G.origin??F);U?U=[[Math.min(K[0][0],U[0][0]),Math.min(K[0][1],U[0][1])],[Math.max(K[1][0],U[1][0]),Math.max(K[1][1],U[1][1])]]:U=K}x==null||x(z,{...w})}).on("drag",z=>{const{transform:L,snapGrid:A,snapToGrid:T,nodeOrigin:H}=s(),F=pc(z.sourceEvent,{transform:L,snapGrid:A,snapToGrid:T,containerBounds:E}),V=[];if(!_)return;const{x:D,y:q,width:te,height:G}=w,K={},Z=_.origin??H,{width:Y,height:Q,x:ie,y:re}=$B(S,l.controlDirection,F,l.boundaries,l.keepAspectRatio,Z,B,U),ne=Y!==te,fe=Q!==G,Ee=ie!==D&&ne,Ue=re!==q&&fe;if(!Ee&&!Ue&&!ne&&!fe)return;if((Ee||Ue||Z[0]===1||Z[1]===1)&&(K.x=Ee?ie:w.x,K.y=Ue?re:w.y,w.x=K.x,w.y=K.y,M.length>0)){const De=ie-D,Re=re-q;for(const ae of M)ae.position={x:ae.position.x-De+Z[0]*(Y-te),y:ae.position.y-Re+Z[1]*(Q-G)},V.push(ae)}if((ne||fe)&&(K.width=ne&&(!l.resizeDirection||l.resizeDirection==="horizontal")?Y:w.width,K.height=fe&&(!l.resizeDirection||l.resizeDirection==="vertical")?Q:w.height,w.width=K.width,w.height=K.height),O&&_.expandParent){const De=Z[0]*(K.width??0);K.x&&K.x<De&&(w.x=De,S.x=S.x-(K.x-De));const Re=Z[1]*(K.height??0);K.y&&K.y<Re&&(w.y=Re,S.y=S.y-(K.y-Re))}const Te=AB({width:w.width,prevWidth:te,height:w.height,prevHeight:G,affectsX:l.controlDirection.affectsX,affectsY:l.controlDirection.affectsY}),pe={...w,direction:Te};(j==null?void 0:j(z,pe))!==!1&&(P=!0,k==null||k(z,pe),i(K,V))}).on("end",z=>{P&&(b==null||b(z,{...w}),r==null||r({...w}),P=!1)});o.call(R)}function d(){o.on(".drag",null)}return{update:u,destroy:d}}var ip={exports:{}},rp={},ap={exports:{}},op={};/**
223
+ * @license React
224
+ * use-sync-external-store-shim.production.js
225
+ *
226
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
227
+ *
228
+ * This source code is licensed under the MIT license found in the
229
+ * LICENSE file in the root directory of this source tree.
230
+ */var uj;function RB(){if(uj)return op;uj=1;var e=zc();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var s=typeof Object.is=="function"?Object.is:t,i=e.useState,r=e.useEffect,o=e.useLayoutEffect,l=e.useDebugValue;function u(p,g){var x=g(),k=i({inst:{value:x,getSnapshot:g}}),b=k[0].inst,j=k[1];return o(function(){b.value=x,b.getSnapshot=g,d(b)&&j({inst:b})},[p,x,g]),r(function(){return d(b)&&j({inst:b}),p(function(){d(b)&&j({inst:b})})},[p]),l(x),x}function d(p){var g=p.getSnapshot;p=p.value;try{var x=g();return!s(p,x)}catch{return!0}}function h(p,g){return g()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return op.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,op}var dj;function OB(){return dj||(dj=1,ap.exports=RB()),ap.exports}/**
231
+ * @license React
232
+ * use-sync-external-store-shim/with-selector.production.js
233
+ *
234
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
235
+ *
236
+ * This source code is licensed under the MIT license found in the
237
+ * LICENSE file in the root directory of this source tree.
238
+ */var hj;function PB(){if(hj)return rp;hj=1;var e=zc(),t=OB();function s(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var i=typeof Object.is=="function"?Object.is:s,r=t.useSyncExternalStore,o=e.useRef,l=e.useEffect,u=e.useMemo,d=e.useDebugValue;return rp.useSyncExternalStoreWithSelector=function(h,m,p,g,x){var k=o(null);if(k.current===null){var b={hasValue:!1,value:null};k.current=b}else b=k.current;k=u(function(){function w(O){if(!S){if(S=!0,_=O,O=g(O),x!==void 0&&b.hasValue){var B=b.value;if(x(B,O))return E=B}return E=O}if(B=E,i(_,O))return B;var U=g(O);return x!==void 0&&x(B,U)?(_=O,B):(_=O,E=U)}var S=!1,_,E,M=p===void 0?null:p;return[function(){return w(m())},M===null?void 0:function(){return w(M())}]},[m,p,g,x]);var j=r(h,k[0],k[1]);return l(function(){b.hasValue=!0,b.value=j},[j]),d(j),j},rp}var mj;function LB(){return mj||(mj=1,ip.exports=PB()),ip.exports}var zB=LB();const DB=Tg(zB),FB={},fj=e=>{let t;const s=new Set,i=(m,p)=>{const g=typeof m=="function"?m(t):m;if(!Object.is(g,t)){const x=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),s.forEach(k=>k(t,x))}},r=()=>t,d={setState:i,getState:r,getInitialState:()=>h,subscribe:m=>(s.add(m),()=>s.delete(m)),destroy:()=>{(FB?"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},UB=e=>e?fj(e):fj,{useDebugValue:BB}=pO,{useSyncExternalStoreWithSelector:HB}=DB,ZB=e=>e;function S_(e,t=ZB,s){const i=HB(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,s);return BB(i),i}const pj=(e,t)=>{const s=UB(e),i=(r,o=t)=>S_(s,r,o);return Object.assign(i,s),i},WB=(e,t)=>e?pj(e,t):pj;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 Nh=v.createContext(null),VB=Nh.Provider,__=Ai.error001("react");function At(e,t){const s=v.useContext(Nh);if(s===null)throw new Error(__);return S_(s,e,t)}function Xt(){const e=v.useContext(Nh);if(e===null)throw new Error(__);return v.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const gj={display:"none"},qB={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},E_="react-flow__node-desc",C_="react-flow__edge-desc",GB="react-flow__aria-live",KB=e=>e.ariaLiveMessage,YB=e=>e.ariaLabelConfig;function XB({rfId:e}){const t=At(KB);return n.jsx("div",{id:`${GB}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:qB,children:t})}function QB({rfId:e,disableKeyboardA11y:t}){const s=At(YB);return n.jsxs(n.Fragment,{children:[n.jsx("div",{id:`${E_}-${e}`,style:gj,children:t?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),n.jsx("div",{id:`${C_}-${e}`,style:gj,children:s["edge.a11yDescription.default"]}),!t&&n.jsx(XB,{rfId:e})]})}const wh=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})});wh.displayName="Panel";const xj="https://reactflow.dev?utm_source=attribution";function JB({proOptions:e,position:t="bottom-right"}){return v.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:n.jsx(wh,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${xj}`,children:n.jsx("a",{href:xj,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const eH=e=>{const t=[],s=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&s.push(i);return{selectedNodes:t,selectedEdges:s}},hd=e=>e.id;function tH(e,t){return un(e.selectedNodes.map(hd),t.selectedNodes.map(hd))&&un(e.selectedEdges.map(hd),t.selectedEdges.map(hd))}function nH({onSelectionChange:e}){const t=Xt(),{selectedNodes:s,selectedEdges:i}=At(eH,tH);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 sH=e=>!!e.onSelectionChangeHandlers;function iH({onSelectionChange:e}){const t=At(sH);return e||t?n.jsx(nH,{onSelectionChange:e}):null}const A_=[0,0],rH={x:0,y:0,zoom:1},aH=["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"],vj=[...aH,"rfId"],oH=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}),yj={translateExtent:Ac,nodeOrigin:A_,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function lH(e){const{setNodes:t,setEdges:s,setMinZoom:i,setMaxZoom:r,setTranslateExtent:o,setNodeExtent:l,reset:u,setDefaultNodesAndEdges:d}=At(oH,un),h=Xt();v.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{m.current=yj,u()}),[]);const m=v.useRef(yj);return v.useEffect(()=>{for(const p of vj){const g=e[p],x=m.current[p];g!==x&&(typeof e[p]>"u"||(p==="nodes"?t(g):p==="edges"?s(g):p==="minZoom"?i(g):p==="maxZoom"?r(g):p==="translateExtent"?o(g):p==="nodeExtent"?l(g):p==="ariaLabelConfig"?h.setState({ariaLabelConfig:VU(g)}):p==="fitView"?h.setState({fitViewQueued:g}):p==="fitViewOptions"?h.setState({fitViewOptions:g}):h.setState({[p]:g})))}m.current=e},vj.map(p=>e[p])),null}function bj(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function cH(e){var i;const[t,s]=v.useState(e==="system"?null:e);return v.useEffect(()=>{if(e!=="system"){s(e);return}const r=bj(),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=bj())!=null&&i.matches?"dark":"light"}const kj=typeof document<"u"?document:null;function Mc(e=null,t={target:kj,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,`
239
+ `).replace(`
240
+
241
+ `,`
242
+ +`).split(`
243
+ `)),m=h.reduce((p,g)=>p.concat(...g),[]);return[h,m]}return[[],[]]},[e]);return v.useEffect(()=>{const d=(t==null?void 0:t.target)??kj,h=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=x=>{var j,w;if(r.current=x.ctrlKey||x.metaKey||x.shiftKey||x.altKey,(!r.current||r.current&&!h)&&l_(x))return!1;const b=Nj(x.code,u);if(o.current.add(x[b]),jj(l,o.current,!1)){const S=((w=(j=x.composedPath)==null?void 0:j.call(x))==null?void 0:w[0])||x.target,_=(S==null?void 0:S.nodeName)==="BUTTON"||(S==null?void 0:S.nodeName)==="A";t.preventDefault!==!1&&(r.current||!_)&&x.preventDefault(),i(!0)}},p=x=>{const k=Nj(x.code,u);jj(l,o.current,!0)?(i(!1),o.current.clear()):o.current.delete(x[k]),x.key==="Meta"&&o.current.clear(),r.current=!1},g=()=>{o.current.clear(),i(!1)};return d==null||d.addEventListener("keydown",m),d==null||d.addEventListener("keyup",p),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{d==null||d.removeEventListener("keydown",m),d==null||d.removeEventListener("keyup",p),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,i]),s}function jj(e,t,s){return e.filter(i=>s||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function Nj(e,t){return t.includes(e)?"code":"key"}const uH=()=>{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=Ox(t,i,r,o,l,(s==null?void 0:s.padding)??.1);return u?(await u.setViewport(d,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),!0):!1},screenToFlowPosition:(t,s={})=>{const{transform:i,snapGrid:r,snapToGrid:o,domNode:l}=e.getState();if(!l)return t;const{x:u,y:d}=l.getBoundingClientRect(),h={x:t.x-u,y:t.y-d},m=s.snapGrid??r,p=s.snapToGrid??o;return Yc(h,i,p,m)},flowToScreenPosition:t=>{const{transform:s,domNode:i}=e.getState();if(!i)return t;const{x:r,y:o}=i.getBoundingClientRect(),l=el(t,s);return{x:l.x+r,y:l.y+o}}}),[])};function $_(e,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)dH(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 dH(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 hH(e,t){return $_(e,t)}function mH(e,t){return $_(e,t)}function Ea(e,t){return{id:e,type:"select",selected:t}}function Co(e,t=new Set,s=!1){const i=[];for(const[r,o]of e){const l=t.has(r);!(o.selected===void 0&&!l)&&o.selected!==l&&(s&&(o.selected=l),i.push(Ea(o.id,l)))}return i}function wj({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 Sj(e){return{id:e.id,type:"remove"}}const fH=s_();function pH(e,t,s={}){return QU(e,t,{...s,onError:s.onError??fH})}const _j=e=>LU(e),gH=e=>Q1(e);function I_(e){return v.forwardRef(e)}const T_=typeof window<"u"?v.useLayoutEffect:v.useEffect;function Ej(e){const[t,s]=v.useState(BigInt(0)),[i]=v.useState(()=>xH(()=>s(r=>r+BigInt(1))));return T_(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function xH(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:s=>{t.push(s),e()}}}const M_=v.createContext(null);function vH({children:e}){const t=Xt(),s=v.useCallback(u=>{const{nodes:d=[],setNodes:h,hasDefaultNodes:m,onNodesChange:p,nodeLookup:g,fitViewQueued:x,onNodesChangeMiddlewareMap:k}=t.getState();let b=d;for(const w of u)b=typeof w=="function"?w(b):w;let j=wj({items:b,lookup:g});for(const w of k.values())j=w(j);m&&h(b),j.length>0?p==null||p(j):x&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:S,setNodes:_}=t.getState();w&&_(S)})},[]),i=Ej(s),r=v.useCallback(u=>{const{edges:d=[],setEdges:h,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:g}=t.getState();let x=d;for(const k of u)x=typeof k=="function"?k(x):k;m?h(x):p&&p(wj({items:x,lookup:g}))},[]),o=Ej(r),l=v.useMemo(()=>({nodeQueue:i,edgeQueue:o}),[]);return n.jsx(M_.Provider,{value:l,children:e})}function yH(){const e=v.useContext(M_);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const bH=e=>!!e.panZoom;function Bx(){const e=uH(),t=Xt(),s=yH(),i=At(bH),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 w,S;const{nodeLookup:g,nodeOrigin:x}=t.getState(),k=_j(p)?p:g.get(p.id),b=k.parentId?r_(k.position,k.measured,k.parentId,g,x):k.position,j={...k,position:b,width:((w=k.measured)==null?void 0:w.width)??k.width,height:((S=k.measured)==null?void 0:S.height)??k.height};return Ic(j)},h=(p,g,x={replace:!1})=>{l(k=>k.map(b=>{if(b.id===p){const j=typeof g=="function"?g(b):g;return x.replace&&_j(j)?j:{...b,...j}}return b}))},m=(p,g,x={replace:!1})=>{u(k=>k.map(b=>{if(b.id===p){const j=typeof g=="function"?g(b):g;return x.replace&&gH(j)?j:{...b,...j}}return b}))};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(),[k,b,j]=x;return{nodes:p.map(w=>({...w})),edges:g.map(w=>({...w})),viewport:{x:k,y:b,zoom:j}}},deleteElements:async({nodes:p=[],edges:g=[]})=>{const{nodes:x,edges:k,onNodesDelete:b,onEdgesDelete:j,triggerNodeChanges:w,triggerEdgeChanges:S,onDelete:_,onBeforeDelete:E}=t.getState(),{nodes:M,edges:O}=await BU({nodesToRemove:p,edgesToRemove:g,nodes:x,edges:k,onBeforeDelete:E}),B=O.length>0,U=M.length>0;if(B){const P=O.map(Sj);j==null||j(O),S(P)}if(U){const P=M.map(Sj);b==null||b(M),w(P)}return(U||B)&&(_==null||_({nodes:M,edges:O})),{deletedNodes:M,deletedEdges:O}},getIntersectingNodes:(p,g=!0,x)=>{const k=Xk(p),b=k?p:d(p),j=x!==void 0;return b?(x||t.getState().nodes).filter(w=>{const S=t.getState().nodeLookup.get(w.id);if(S&&!k&&(w.id===p.id||!S.internals.positionAbsolute))return!1;const _=Ic(j?w:S),E=Kd(_,b);return g&&E>0||E>=_.width*_.height||E>=b.width*b.height}):[]},isNodeIntersecting:(p,g,x=!0)=>{const b=Xk(p)?p:d(p);if(!b)return!1;const j=Kd(b,g);return x&&j>0||j>=g.width*g.height||j>=b.width*b.height},updateNode:h,updateNodeData:(p,g,x={replace:!1})=>{h(p,k=>{const b=typeof g=="function"?g(k):g;return x.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},x)},updateEdge:m,updateEdgeData:(p,g,x={replace:!1})=>{m(p,k=>{const b=typeof g=="function"?g(k):g;return x.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},x)},getNodesBounds:p=>{const{nodeLookup:g,nodeOrigin:x}=t.getState();return zU(p,{nodeLookup:g,nodeOrigin:x})},getHandleConnections:({type:p,id:g,nodeId:x})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${x}-${p}${g?`-${g}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:p,handleId:g,nodeId:x})=>{var k;return Array.from(((k=t.getState().connectionLookup.get(`${x}${p?g?`-${p}-${g}`:`-${p}`:""}`))==null?void 0:k.values())??[])},fitView:async p=>{const g=t.getState().fitViewResolver??WU();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 Cj=e=>e.selected,kH=typeof window<"u"?window:void 0;function jH({deleteKeyCode:e,multiSelectionKeyCode:t}){const s=Xt(),{deleteElements:i}=Bx(),r=Mc(e,{actInsideInputWithModifier:!1}),o=Mc(t,{target:kH});v.useEffect(()=>{if(r){const{edges:l,nodes:u}=s.getState();i({nodes:u.filter(Cj),edges:l.filter(Cj)}),s.setState({nodesSelectionActive:!1})}},[r]),v.useEffect(()=>{s.setState({multiSelectionActive:o})},[o])}function NH(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=Px(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 Sh={position:"absolute",width:"100%",height:"100%",top:0,left:0},wH=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function SH({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panActivationKeyPressed:r,panOnScrollSpeed:o=.5,panOnScrollMode:l=Da.Free,zoomOnDoubleClick:u=!0,panOnDrag:d=!0,defaultViewport:h,translateExtent:m,minZoom:p,maxZoom:g,zoomActivationKeyCode:x,preventScrolling:k=!0,children:b,noWheelClassName:j,noPanClassName:w,onViewportChange:S,isControlledViewport:_,paneClickDistance:E,selectionOnDrag:M}){const O=Xt(),B=v.useRef(null),{userSelectionActive:U,lib:P,connectionInProgress:R}=At(wH,un),z=Mc(x),L=v.useRef();NH(B);const A=v.useCallback(T=>{S==null||S({x:T[0],y:T[1],zoom:T[2]}),_||O.setState({transform:T})},[S,_]);return v.useEffect(()=>{if(B.current){L.current=CB({domNode:B.current,minZoom:p,maxZoom:g,translateExtent:m,viewport:h,onDraggingChange:V=>O.setState(D=>D.paneDragging===V?D:{paneDragging:V}),onPanZoomStart:(V,D)=>{const{onViewportChangeStart:q,onMoveStart:te}=O.getState();te==null||te(V,D),q==null||q(D)},onPanZoom:(V,D)=>{const{onViewportChange:q,onMove:te}=O.getState();te==null||te(V,D),q==null||q(D)},onPanZoomEnd:(V,D)=>{const{onViewportChangeEnd:q,onMoveEnd:te}=O.getState();te==null||te(V,D),q==null||q(D)}});const{x:T,y:H,zoom:F}=L.current.getViewport();return O.setState({panZoom:L.current,transform:[T,H,F],domNode:B.current.closest(".react-flow")}),()=>{var V;(V=L.current)==null||V.destroy()}}},[]),v.useEffect(()=>{var T;(T=L.current)==null||T.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:s,panOnScroll:i,panActivationKeyPressed:r,panOnScrollSpeed:o,panOnScrollMode:l,zoomOnDoubleClick:u,panOnDrag:d,zoomActivationKeyPressed:z,preventScrolling:k,noPanClassName:w,userSelectionActive:U,noWheelClassName:j,lib:P,onTransformChange:A,connectionInProgress:R,selectionOnDrag:M,paneClickDistance:E})},[e,t,s,i,r,o,l,u,d,z,k,w,U,j,P,A,R,M,E]),n.jsx("div",{className:"react-flow__renderer",ref:B,style:Sh,children:b})}const _H=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function EH(){const{userSelectionActive:e,userSelectionRect:t}=At(_H,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 lp=(e,t)=>s=>{s.target===t.current&&(e==null||e(s))},CH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function AH({isSelecting:e,selectionKeyPressed:t,selectionMode:s=$c.Full,panOnDrag:i,autoPanOnSelection:r,paneClickDistance:o,selectionOnDrag:l,onSelectionStart:u,onSelectionEnd:d,onPaneClick:h,onPaneContextMenu:m,onPaneScroll:p,onPaneMouseEnter:g,onPaneMouseMove:x,onPaneMouseLeave:k,children:b}){const j=v.useRef(0),w=Xt(),{userSelectionActive:S,elementsSelectable:_,dragging:E,panBy:M,autoPanSpeed:O}=At(CH,un),B=_&&(e||S),U=v.useRef(null),P=v.useRef(),R=v.useRef(new Set),z=v.useRef(new Set),L=v.useRef(!1),A=v.useRef(!1),T=v.useRef({x:0,y:0}),H=v.useRef(!1),F=ne=>{if(A.current||L.current||w.getState().connection.inProgress){A.current=!1,L.current=!1;return}h==null||h(ne),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},V=ne=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){ne.preventDefault();return}m==null||m(ne)},D=p?ne=>p(ne):void 0,q=ne=>{A.current&&(ne.stopPropagation(),A.current=!1)},te=ne=>{var ae,Fe;if(ne.pointerType==="touch"&&i!==!1&&!t)return;const{domNode:fe,transform:Ee}=w.getState();if(P.current=fe==null?void 0:fe.getBoundingClientRect(),!P.current)return;const Ue=ne.target===U.current;if(!Ue&&!!ne.target.closest(".nokey")||!e||!(l&&Ue||t)||ne.button!==0||!ne.isPrimary)return;(Fe=(ae=ne.target)==null?void 0:ae.setPointerCapture)==null||Fe.call(ae,ne.pointerId),A.current=!1;const{x:be,y:De}=Ei(ne.nativeEvent,P.current),Re=Yc({x:be,y:De},Ee);w.setState({userSelectionRect:{width:0,height:0,startX:Re.x,startY:Re.y,x:be,y:De}}),Ue||(ne.stopPropagation(),ne.preventDefault())};function G(ne,fe){const{userSelectionRect:Ee}=w.getState();if(!Ee)return;const{transform:Ue,nodeLookup:Te,edgeLookup:pe,connectionLookup:be,triggerNodeChanges:De,triggerEdgeChanges:Re,defaultEdgeOptions:ae}=w.getState(),Fe={x:Ee.startX,y:Ee.startY},{x:ut,y:gt}=el(Fe,Ue),Rt={startX:Fe.x,startY:Fe.y,x:ne<ut?ne:ut,y:fe<gt?fe:gt,width:Math.abs(ne-ut),height:Math.abs(fe-gt)},En=R.current,rt=z.current;R.current=new Set(Mx(Te,Rt,Ue,s===$c.Partial,!0).map(rn=>rn.id)),z.current=new Set;const Pt=(ae==null?void 0:ae.selectable)??!0;for(const rn of R.current){const Zt=be.get(rn);if(Zt)for(const{edgeId:Qt}of Zt.values()){const Ut=pe.get(Qt);Ut&&(Ut.selectable??Pt)&&z.current.add(Qt)}}if(!Qk(En,R.current)){const rn=Co(Te,R.current,!0);De(rn)}if(!Qk(rt,z.current)){const rn=Co(pe,z.current);Re(rn)}w.setState({userSelectionRect:Rt,userSelectionActive:!0,nodesSelectionActive:!1})}function K(){if(!r||!P.current)return;const[ne,fe]=Rx(T.current,P.current,O);M({x:ne,y:fe}).then(Ee=>{if(!A.current||!Ee){j.current=requestAnimationFrame(K);return}const{x:Ue,y:Te}=T.current;G(Ue,Te),j.current=requestAnimationFrame(K)})}const Z=()=>{cancelAnimationFrame(j.current),j.current=0,H.current=!1};v.useEffect(()=>()=>Z(),[]);const Y=ne=>{const{userSelectionRect:fe,transform:Ee,resetSelectedElements:Ue}=w.getState();if(!P.current||!fe)return;const{x:Te,y:pe}=Ei(ne.nativeEvent,P.current);T.current={x:Te,y:pe};const be=el({x:fe.startX,y:fe.startY},Ee);if(!A.current){const De=t?0:o;if(Math.hypot(Te-be.x,pe-be.y)<=De)return;Ue(),u==null||u(ne)}A.current=!0,H.current||(K(),H.current=!0),G(Te,pe)},Q=ne=>{var fe,Ee;if(!B){ne.target===U.current&&w.getState().connection.inProgress&&(L.current=!0);return}ne.button===0&&((Ee=(fe=ne.target)==null?void 0:fe.releasePointerCapture)==null||Ee.call(fe,ne.pointerId),!S&&ne.target===U.current&&w.getState().userSelectionRect&&(F==null||F(ne)),w.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(d==null||d(ne),w.setState({nodesSelectionActive:R.current.size>0})),Z())},ie=ne=>{var fe,Ee;(Ee=(fe=ne.target)==null?void 0:fe.releasePointerCapture)==null||Ee.call(fe,ne.pointerId),Z()},re=i===!0||Array.isArray(i)&&i.includes(0);return n.jsxs("div",{className:_n(["react-flow__pane",{draggable:re,dragging:E,selection:e}]),onClick:B?void 0:lp(F,U),onContextMenu:lp(V,U),onWheel:lp(D,U),onPointerEnter:B?void 0:g,onPointerMove:B?Y:x,onPointerUp:Q,onPointerCancel:B?ie:void 0,onPointerDownCapture:B?te:void 0,onClickCapture:B?q:void 0,onPointerLeave:k,ref:U,style:Sh,children:[b,n.jsx(EH,{})]})}function bg({id:e,store:t,unselect:s=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:o,multiSelectionActive:l,nodeLookup:u,onError:d}=t.getState(),h=u.get(e);if(!h){d==null||d("012",Ai.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(s||h.selected&&l)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var m;return(m=i==null?void 0:i.current)==null?void 0:m.blur()})):r([e])}function R_({nodeRef:e,disabled:t=!1,noDragClassName:s,handleSelector:i,nodeId:r,isSelectable:o,nodeClickDistance:l}){const u=Xt(),[d,h]=v.useState(!1),m=v.useRef();return v.useEffect(()=>{if(!t)return m.current=fB({getStoreItems:()=>u.getState(),onNodeMouseDown:p=>{bg({id:p,store:u,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}}),()=>{var p;(p=m.current)==null||p.destroy(),m.current=void 0}},[t,u,e]),v.useEffect(()=>{t||!e.current||!m.current||m.current.update({noDragClassName:s,handleSelector:i,domNode:e.current,isSelectable:o,nodeId:r,nodeClickDistance:l})},[s,i,t,o,e,r,l]),d}const $H=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function O_(){const e=Xt();return v.useCallback(s=>{const{nodeExtent:i,snapToGrid:r,snapGrid:o,nodesDraggable:l,onError:u,updateNodePositions:d,nodeLookup:h,nodeOrigin:m}=e.getState(),p=new Map,g=$H(l),x=r?o[0]:5,k=r?o[1]:5,b=s.direction.x*x*s.factor,j=s.direction.y*k*s.factor;for(const[,w]of h){if(!g(w))continue;let S={x:w.internals.positionAbsolute.x+b,y:w.internals.positionAbsolute.y+j};r&&(S=Kc(S,o));const{position:_,positionAbsolute:E}=J1({nodeId:w.id,nextPosition:S,nodeLookup:h,nodeExtent:i,nodeOrigin:m,onError:u});w.position=_,w.internals.positionAbsolute=E,p.set(w.id,w)}d(p)},[])}const Hx=v.createContext(null),IH=Hx.Provider;Hx.Consumer;const P_=()=>v.useContext(Hx),TH=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),L_=v.createContext(null);function MH({children:e}){const t=At(TH,un);return n.jsx(L_.Provider,{value:t,children:e})}function RH(){const e=v.useContext(L_);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const OH={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},PH=(e,t,s)=>i=>{const{connectionClickStartHandle:r,connectionMode:o,connection:l}=i,{fromHandle:u,toHandle:d,isValid:h}=l;if(!u&&!r)return OH;const m=(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.type)===s;return{connectingFrom:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===s,connectingTo:m,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===s,isPossibleEndHandle:o===Qo.Strict?(u==null?void 0:u.type)!==s:e!==(u==null?void 0:u.nodeId)||t!==(u==null?void 0:u.id),connectionInProcess:!!u,clickConnectionInProcess:!!r,valid:m&&h}};function LH({type:e="source",position:t=tt.Top,isValidConnection:s,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:o=!0,id:l,onConnect:u,children:d,className:h,onMouseDown:m,onTouchStart:p,...g},x){var H,F;const k=l||null,b=e==="target",j=Xt(),w=P_(),{connectOnClick:S,noPanClassName:_,rfId:E}=RH(),{connectingFrom:M,connectingTo:O,clickConnecting:B,isPossibleEndHandle:U,connectionInProcess:P,clickConnectionInProcess:R,valid:z}=At(PH(w,k,e),un);w||(F=(H=j.getState()).onError)==null||F.call(H,"010",Ai.error010());const L=V=>{const{defaultEdgeOptions:D,onConnect:q,hasDefaultEdges:te}=j.getState(),G={...D,...V};if(te){const{edges:K,setEdges:Z,onError:Y}=j.getState();Z(pH(G,K,{onError:Y}))}q==null||q(G),u==null||u(G)},A=V=>{if(!w)return;const D=c_(V.nativeEvent);if(r&&(D&&V.button===0||!D)){const q=j.getState();yg.onPointerDown(V.nativeEvent,{handleDomNode:V.currentTarget,autoPanOnConnect:q.autoPanOnConnect,connectionMode:q.connectionMode,connectionRadius:q.connectionRadius,domNode:q.domNode,nodeLookup:q.nodeLookup,lib:q.lib,isTarget:b,handleId:k,nodeId:w,flowId:q.rfId,panBy:q.panBy,cancelConnection:q.cancelConnection,onConnectStart:q.onConnectStart,onConnectEnd:(...te)=>{var G,K;return(K=(G=j.getState()).onConnectEnd)==null?void 0:K.call(G,...te)},updateConnection:q.updateConnection,onConnect:L,isValidConnection:s||((...te)=>{var G,K;return((K=(G=j.getState()).isValidConnection)==null?void 0:K.call(G,...te))??!0}),getTransform:()=>j.getState().transform,getFromHandle:()=>j.getState().connection.fromHandle,autoPanSpeed:q.autoPanSpeed,dragThreshold:q.connectionDragThreshold})}D?m==null||m(V):p==null||p(V)},T=V=>{const{onClickConnectStart:D,onClickConnectEnd:q,connectionClickStartHandle:te,connectionMode:G,isValidConnection:K,lib:Z,rfId:Y,nodeLookup:Q,connection:ie}=j.getState();if(!w||!te&&!r)return;if(!te){D==null||D(V.nativeEvent,{nodeId:w,handleId:k,handleType:e}),j.setState({connectionClickStartHandle:{nodeId:w,type:e,id:k}});return}const re=o_(V.target),ne=s||K,{connection:fe,isValid:Ee}=yg.isValid(V.nativeEvent,{handle:{nodeId:w,id:k,type:e},connectionMode:G,fromNodeId:te.nodeId,fromHandleId:te.id||null,fromType:te.type,isValidConnection:ne,flowId:Y,doc:re,lib:Z,nodeLookup:Q});Ee&&fe&&L(fe);const Ue=structuredClone(ie);delete Ue.inProgress,Ue.toPosition=Ue.toHandle?Ue.toHandle.position:null,q==null||q(V,Ue),j.setState({connectionClickStartHandle:null})};return n.jsx("div",{"data-handleid":k,"data-nodeid":w,"data-handlepos":t,"data-id":`${E}-${w}-${k}-${e}`,className:_n(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",_,h,{source:!b,target:b,connectable:i,connectablestart:r,connectableend:o,clickconnecting:B,connectingfrom:M,connectingto:O,valid:z,connectionindicator:i&&(!P||U)&&(P||R?o:r)}]),onMouseDown:A,onTouchStart:A,onClick:S?T:void 0,ref:x,...g,children:d})}const Qr=v.memo(I_(LH));function zH({data:e,isConnectable:t,sourcePosition:s=tt.Bottom}){return n.jsxs(n.Fragment,{children:[e==null?void 0:e.label,n.jsx(Qr,{type:"source",position:s,isConnectable:t})]})}function DH({data:e,isConnectable:t,targetPosition:s=tt.Top,sourcePosition:i=tt.Bottom}){return n.jsxs(n.Fragment,{children:[n.jsx(Qr,{type:"target",position:s,isConnectable:t}),e==null?void 0:e.label,n.jsx(Qr,{type:"source",position:i,isConnectable:t})]})}function FH(){return null}function UH({data:e,isConnectable:t,targetPosition:s=tt.Top}){return n.jsxs(n.Fragment,{children:[n.jsx(Qr,{type:"target",position:s,isConnectable:t}),e==null?void 0:e.label]})}const Yd={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Aj={input:zH,default:DH,output:UH,group:FH};function BH(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 HH=e=>{const{width:t,height:s,x:i,y:r}=Gc(e.nodeLookup,{filter:o=>!!o.selected});return{width:_i(t)?t:null,height:_i(s)?s:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${r}px)`}};function ZH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:s}){const i=Xt(),{width:r,height:o,transformString:l,userSelectionActive:u}=At(HH,un),d=O_(),h=v.useRef(null);v.useEffect(()=>{var x;s||(x=h.current)==null||x.focus({preventScroll:!0})},[s]);const m=!u&&r!==null&&o!==null;if(R_({nodeRef:h,disabled:!m}),!m)return null;const p=e?x=>{const k=i.getState().nodes.filter(b=>b.selected);e(x,k)}:void 0,g=x=>{Object.prototype.hasOwnProperty.call(Yd,x.key)&&(x.preventDefault(),d({direction:Yd[x.key],factor:x.shiftKey?4:1}))};return n.jsx("div",{className:_n(["react-flow__nodesselection","react-flow__container",t]),style:{transform:l},children:n.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:s?void 0:-1,onKeyDown:s?void 0:g,style:{width:r,height:o}})})}const $j=typeof window<"u"?window:void 0,WH=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function z_({children:e,onPaneClick:t,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:l,paneClickDistance:u,deleteKeyCode:d,selectionKeyCode:h,selectionOnDrag:m,selectionMode:p,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:k,panActivationKeyCode:b,zoomActivationKeyCode:j,elementsSelectable:w,zoomOnScroll:S,zoomOnPinch:_,panOnScroll:E,panOnScrollSpeed:M,panOnScrollMode:O,zoomOnDoubleClick:B,panOnDrag:U,autoPanOnSelection:P,defaultViewport:R,translateExtent:z,minZoom:L,maxZoom:A,preventScrolling:T,onSelectionContextMenu:H,noWheelClassName:F,noPanClassName:V,disableKeyboardA11y:D,onViewportChange:q,isControlledViewport:te}){const{nodesSelectionActive:G,userSelectionActive:K}=At(WH,un),Z=Mc(h,{target:$j}),Y=Mc(b,{target:$j}),Q=Y||U,ie=Y||E,re=m&&Q!==!0,ne=Z||K||re;return jH({deleteKeyCode:d,multiSelectionKeyCode:k}),n.jsx(SH,{onPaneContextMenu:o,elementsSelectable:w,zoomOnScroll:S,zoomOnPinch:_,panOnScroll:ie,panActivationKeyPressed:Y,panOnScrollSpeed:M,panOnScrollMode:O,zoomOnDoubleClick:B,panOnDrag:!Z&&Q,defaultViewport:R,translateExtent:z,minZoom:L,maxZoom:A,zoomActivationKeyCode:j,preventScrolling:T,noWheelClassName:F,noPanClassName:V,onViewportChange:q,isControlledViewport:te,paneClickDistance:u,selectionOnDrag:re,children:n.jsxs(AH,{onSelectionStart:g,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:s,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:l,panOnDrag:Q,autoPanOnSelection:P,isSelecting:!!ne,selectionMode:p,selectionKeyPressed:Z,paneClickDistance:u,selectionOnDrag:re,children:[e,G&&n.jsx(ZH,{onSelectionContextMenu:H,noPanClassName:V,disableKeyboardA11y:D})]})})}z_.displayName="FlowRenderer";const VH=v.memo(z_),qH=e=>t=>e?Mx(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 GH(e){return At(v.useCallback(qH(e),[e]),un)}const KH=e=>e.updateNodeInternals;function YH(){const e=At(KH),[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 XH({node:e,nodeType:t,hasDimensions:s,resizeObserver:i}){const r=Xt(),o=v.useRef(null),l=v.useRef(null),u=v.useRef(e.sourcePosition),d=v.useRef(e.targetPosition),h=v.useRef(t),m=s&&!!e.internals.handleBounds;return v.useEffect(()=>{o.current&&!e.hidden&&(!m||l.current!==o.current)&&(l.current&&(i==null||i.unobserve(l.current)),i==null||i.observe(o.current),l.current=o.current)},[m,e.hidden]),v.useEffect(()=>()=>{l.current&&(i==null||i.unobserve(l.current),l.current=null)},[]),v.useEffect(()=>{if(o.current){const p=h.current!==t,g=u.current!==e.sourcePosition,x=d.current!==e.targetPosition;(p||g||x)&&(h.current=t,u.current=e.sourcePosition,d.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function QH({id:e,onClick:t,onMouseEnter:s,onMouseMove:i,onMouseLeave:r,onContextMenu:o,onDoubleClick:l,nodesDraggable:u,elementsSelectable:d,nodesConnectable:h,nodesFocusable:m,resizeObserver:p,noDragClassName:g,noPanClassName:x,disableKeyboardA11y:k,rfId:b,nodeTypes:j,nodeClickDistance:w,onError:S}){const{node:_,internals:E,isParent:M}=At(ne=>{const fe=ne.nodeLookup.get(e),Ee=ne.parentLookup.has(e);return{node:fe,internals:fe.internals,isParent:Ee}},un);let O=_.type||"default",B=(j==null?void 0:j[O])||Aj[O];B===void 0&&(S==null||S("003",Ai.error003(O)),O="default",B=(j==null?void 0:j.default)||Aj.default);const U=!!(_.draggable||u&&typeof _.draggable>"u"),P=!!(_.selectable||d&&typeof _.selectable>"u"),R=!!(_.connectable||h&&typeof _.connectable>"u"),z=!!(_.focusable||m&&typeof _.focusable>"u"),L=Xt(),A=i_(_),T=XH({node:_,nodeType:O,hasDimensions:A,resizeObserver:p}),H=R_({nodeRef:T,disabled:_.hidden||!U,noDragClassName:g,handleSelector:_.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:w}),F=O_();if(_.hidden)return null;const V=Ti(_),D=BH(_),q=P||U||t||s||i||r,te=s?ne=>s(ne,{...E.userNode}):void 0,G=i?ne=>i(ne,{...E.userNode}):void 0,K=r?ne=>r(ne,{...E.userNode}):void 0,Z=o?ne=>o(ne,{...E.userNode}):void 0,Y=l?ne=>l(ne,{...E.userNode}):void 0,Q=ne=>{const{selectNodesOnDrag:fe,nodeDragThreshold:Ee}=L.getState();P&&(!fe||!U||Ee>0)&&bg({id:e,store:L,nodeRef:T}),t&&t(ne,{...E.userNode})},ie=ne=>{if(!(l_(ne.nativeEvent)||k)){if(K1.includes(ne.key)&&P){const fe=ne.key==="Escape";bg({id:e,store:L,unselect:fe,nodeRef:T})}else if(U&&_.selected&&Object.prototype.hasOwnProperty.call(Yd,ne.key)){ne.preventDefault();const{ariaLabelConfig:fe}=L.getState();L.setState({ariaLiveMessage:fe["node.a11yDescription.ariaLiveMessage"]({direction:ne.key.replace("Arrow","").toLowerCase(),x:~~E.positionAbsolute.x,y:~~E.positionAbsolute.y})}),F({direction:Yd[ne.key],factor:ne.shiftKey?4:1})}}},re=()=>{var be;if(k||!((be=T.current)!=null&&be.matches(":focus-visible")))return;const{transform:ne,width:fe,height:Ee,autoPanOnNodeFocus:Ue,setCenter:Te}=L.getState();if(!Ue)return;Mx(new Map([[e,_]]),{x:0,y:0,width:fe,height:Ee},ne,!0).length>0||Te(_.position.x+V.width/2,_.position.y+V.height/2,{zoom:ne[2]})};return n.jsx("div",{className:_n(["react-flow__node",`react-flow__node-${O}`,{[x]:U},_.className,{selected:_.selected,selectable:P,parent:M,draggable:U,dragging:H}]),ref:T,style:{zIndex:E.z,transform:`translate(${E.positionAbsolute.x}px,${E.positionAbsolute.y}px)`,pointerEvents:q?"all":"none",visibility:A?"visible":"hidden",..._.style,...D},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:te,onMouseMove:G,onMouseLeave:K,onContextMenu:Z,onClick:Q,onDoubleClick:Y,onKeyDown:z?ie:void 0,tabIndex:z?0:void 0,onFocus:z?re:void 0,role:_.ariaRole??(z?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${E_}-${b}`,"aria-label":_.ariaLabel,..._.domAttributes,children:n.jsx(IH,{value:e,children:n.jsx(B,{id:e,data:_.data,type:O,positionAbsoluteX:E.positionAbsolute.x,positionAbsoluteY:E.positionAbsolute.y,selected:_.selected??!1,selectable:P,draggable:U,deletable:_.deletable??!0,isConnectable:R,sourcePosition:_.sourcePosition,targetPosition:_.targetPosition,dragging:H,dragHandle:_.dragHandle,zIndex:E.z,parentId:_.parentId,...V})})})}var JH=v.memo(QH);const e9=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function D_(e){const{nodesConnectable:t,nodesFocusable:s,elementsSelectable:i,onError:r}=At(e9,un),o=GH(e.onlyRenderVisibleElements),l=YH();return n.jsx("div",{className:"react-flow__nodes",style:Sh,children:o.map(u=>n.jsx(JH,{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))})}D_.displayName="NodeRenderer";const t9=v.memo(D_);function n9(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&&KU({sourceNode:o,targetNode:l,width:s.width,height:s.height,transform:s.transform})&&i.push(r.id)}return i},[e]),un)}const s9=({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"})},i9=({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"})},Ij={[qd.Arrow]:s9,[qd.ArrowClosed]:i9};function r9(e){const t=Xt();return v.useMemo(()=>{var r,o;return Object.prototype.hasOwnProperty.call(Ij,e)?Ij[e]:((o=(r=t.getState()).onError)==null||o.call(r,"009",Ai.error009(e)),null)},[e])}const a9=({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=r9(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},F_=({defaultColor:e,rfId:t})=>{const s=At(o=>o.edges),i=At(o=>o.defaultEdgeOptions),r=v.useMemo(()=>sB(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(a9,{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};F_.displayName="MarkerDefinitions";var o9=v.memo(F_);function U_({x:e,y:t,label:s,labelStyle:i,labelShowBg:r=!0,labelBgStyle:o,labelBgPadding:l=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...m}){const[p,g]=v.useState({x:1,y:0,width:0,height:0}),x=_n(["react-flow__edge-textwrapper",h]),k=v.useRef(null);return v.useEffect(()=>{if(k.current){const b=k.current.getBBox();g({x:b.x,y:b.y,width:b.width,height:b.height})}},[s]),s?n.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:x,visibility:p.width?"visible":"hidden",...m,children:[r&&n.jsx("rect",{width:p.width+2*l[0],x:-l[0],y:-l[1],height:p.height+2*l[1],className:"react-flow__edge-textbg",style:o,rx:u,ry:u}),n.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:k,style:i,children:s}),d]}):null}U_.displayName="EdgeText";const l9=v.memo(U_);function _h({path:e,labelX:t,labelY:s,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,interactionWidth:h=20,...m}){return n.jsxs(n.Fragment,{children:[n.jsx("path",{...m,d:e,fill:"none",className:_n(["react-flow__edge-path",m.className])}),h?n.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,i&&_i(t)&&_i(s)?n.jsx(l9,{x:t,y:s,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d}):null]})}function Tj({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 B_({sourceX:e,sourceY:t,sourcePosition:s=tt.Bottom,targetX:i,targetY:r,targetPosition:o=tt.Top}){const[l,u]=Tj({pos:s,x1:e,y1:t,x2:i,y2:r}),[d,h]=Tj({pos:o,x1:i,y1:r,x2:e,y2:t}),[m,p,g,x]=u_({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:l,sourceControlY:u,targetControlX:d,targetControlY:h});return[`M${e},${t} C${l},${u} ${d},${h} ${i},${r}`,m,p,g,x]}function H_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,sourcePosition:l,targetPosition:u,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:k,markerEnd:b,markerStart:j,interactionWidth:w})=>{const[S,_,E]=B_({sourceX:s,sourceY:i,sourcePosition:l,targetX:r,targetY:o,targetPosition:u}),M=e.isInternal?void 0:t;return n.jsx(_h,{id:M,path:S,labelX:_,labelY:E,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:k,markerEnd:b,markerStart:j,interactionWidth:w})})}const c9=H_({isInternal:!1}),Z_=H_({isInternal:!0});c9.displayName="SimpleBezierEdge";Z_.displayName="SimpleBezierEdgeInternal";function W_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:g,sourcePosition:x=tt.Bottom,targetPosition:k=tt.Top,markerEnd:b,markerStart:j,pathOptions:w,interactionWidth:S})=>{const[_,E,M]=gg({sourceX:s,sourceY:i,sourcePosition:x,targetX:r,targetY:o,targetPosition:k,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),O=e.isInternal?void 0:t;return n.jsx(_h,{id:O,path:_,labelX:E,labelY:M,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:b,markerStart:j,interactionWidth:S})})}const V_=W_({isInternal:!1}),q_=W_({isInternal:!0});V_.displayName="SmoothStepEdge";q_.displayName="SmoothStepEdgeInternal";function G_(e){return v.memo(({id:t,...s})=>{var r;const i=e.isInternal?void 0:t;return n.jsx(V_,{...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 u9=G_({isInternal:!1}),K_=G_({isInternal:!0});u9.displayName="StepEdge";K_.displayName="StepEdgeInternal";function Y_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:x,markerStart:k,interactionWidth:b})=>{const[j,w,S]=m_({sourceX:s,sourceY:i,targetX:r,targetY:o}),_=e.isInternal?void 0:t;return n.jsx(_h,{id:_,path:j,labelX:w,labelY:S,label:l,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:p,style:g,markerEnd:x,markerStart:k,interactionWidth:b})})}const d9=Y_({isInternal:!1}),X_=Y_({isInternal:!0});d9.displayName="StraightEdge";X_.displayName="StraightEdgeInternal";function Q_(e){return v.memo(({id:t,sourceX:s,sourceY:i,targetX:r,targetY:o,sourcePosition:l=tt.Bottom,targetPosition:u=tt.Top,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:k,markerEnd:b,markerStart:j,pathOptions:w,interactionWidth:S})=>{const[_,E,M]=d_({sourceX:s,sourceY:i,sourcePosition:l,targetX:r,targetY:o,targetPosition:u,curvature:w==null?void 0:w.curvature}),O=e.isInternal?void 0:t;return n.jsx(_h,{id:O,path:_,labelX:E,labelY:M,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:k,markerEnd:b,markerStart:j,interactionWidth:S})})}const h9=Q_({isInternal:!1}),J_=Q_({isInternal:!0});h9.displayName="BezierEdge";J_.displayName="BezierEdgeInternal";const Mj={default:J_,straight:X_,step:K_,smoothstep:q_,simplebezier:Z_},Rj={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},m9=(e,t,s)=>s===tt.Left?e-t:s===tt.Right?e+t:e,f9=(e,t,s)=>s===tt.Top?e-t:s===tt.Bottom?e+t:e,Oj="react-flow__edgeupdater";function Pj({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([Oj,`${Oj}-${u}`]),cx:m9(t,i,e),cy:f9(s,i,e),r:i,stroke:"transparent",fill:"transparent"})}function p9({isReconnectable:e,reconnectRadius:t,edge:s,sourceX:i,sourceY:r,targetX:o,targetY:l,sourcePosition:u,targetPosition:d,onReconnect:h,onReconnectStart:m,onReconnectEnd:p,setReconnecting:g,setUpdateHover:x}){const k=Xt(),b=(E,M)=>{if(E.button!==0)return;const{autoPanOnConnect:O,domNode:B,connectionMode:U,connectionRadius:P,lib:R,onConnectStart:z,cancelConnection:L,nodeLookup:A,rfId:T,panBy:H,updateConnection:F}=k.getState(),V=M.type==="target",D=(G,K)=>{g(!1),p==null||p(G,s,M.type,K)},q=G=>h==null?void 0:h(s,G),te=(G,K)=>{g(!0),m==null||m(E,s,M.type),z==null||z(G,K)};yg.onPointerDown(E.nativeEvent,{autoPanOnConnect:O,connectionMode:U,connectionRadius:P,domNode:B,handleId:M.id,nodeId:M.nodeId,nodeLookup:A,isTarget:V,edgeUpdaterType:M.type,lib:R,flowId:T,cancelConnection:L,panBy:H,isValidConnection:(...G)=>{var K,Z;return((Z=(K=k.getState()).isValidConnection)==null?void 0:Z.call(K,...G))??!0},onConnect:q,onConnectStart:te,onConnectEnd:(...G)=>{var K,Z;return(Z=(K=k.getState()).onConnectEnd)==null?void 0:Z.call(K,...G)},onReconnectEnd:D,updateConnection:F,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:E.currentTarget})},j=E=>b(E,{nodeId:s.target,id:s.targetHandle??null,type:"target"}),w=E=>b(E,{nodeId:s.source,id:s.sourceHandle??null,type:"source"}),S=()=>x(!0),_=()=>x(!1);return n.jsxs(n.Fragment,{children:[(e===!0||e==="source")&&n.jsx(Pj,{position:u,centerX:i,centerY:r,radius:t,onMouseDown:j,onMouseEnter:S,onMouseOut:_,type:"source"}),(e===!0||e==="target")&&n.jsx(Pj,{position:d,centerX:o,centerY:l,radius:t,onMouseDown:w,onMouseEnter:S,onMouseOut:_,type:"target"})]})}function g9({id:e,edgesFocusable:t,edgesReconnectable:s,elementsSelectable:i,onClick:r,onDoubleClick:o,onContextMenu:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,reconnectRadius:m,onReconnect:p,onReconnectStart:g,onReconnectEnd:x,rfId:k,edgeTypes:b,noPanClassName:j,onError:w,disableKeyboardA11y:S}){let _=At(Te=>Te.edgeLookup.get(e));const E=At(Te=>Te.defaultEdgeOptions);_=E?{...E,..._}:_;let M=_.type||"default",O=(b==null?void 0:b[M])||Mj[M];O===void 0&&(w==null||w("011",Ai.error011(M)),M="default",O=(b==null?void 0:b.default)||Mj.default);const B=!!(_.focusable||t&&typeof _.focusable>"u"),U=typeof p<"u"&&(_.reconnectable||s&&typeof _.reconnectable>"u"),P=!!(_.selectable||i&&typeof _.selectable>"u"),R=v.useRef(null),[z,L]=v.useState(!1),[A,T]=v.useState(!1),H=Xt(),{zIndex:F=_.zIndex,sourceX:V,sourceY:D,targetX:q,targetY:te,sourcePosition:G,targetPosition:K}=At(v.useCallback(Te=>{const pe=Te.nodeLookup.get(_.source),be=Te.nodeLookup.get(_.target);if(!pe||!be)return Rj;const De=nB({id:e,sourceNode:pe,targetNode:be,sourceHandle:_.sourceHandle||null,targetHandle:_.targetHandle||null,connectionMode:Te.connectionMode,onError:w}),Re=GU({selected:_.selected,zIndex:_.zIndex,sourceNode:pe,targetNode:be,elevateOnSelect:Te.elevateEdgesOnSelect,zIndexMode:Te.zIndexMode});return{...De||Rj,zIndex:Re}},[_.source,_.target,_.sourceHandle,_.targetHandle,_.selected,_.zIndex,w]),un),Z=v.useMemo(()=>_.markerStart?`url('#${xg(_.markerStart,k)}')`:void 0,[_.markerStart,k]),Y=v.useMemo(()=>_.markerEnd?`url('#${xg(_.markerEnd,k)}')`:void 0,[_.markerEnd,k]);if(_.hidden||V===null||D===null||q===null||te===null)return null;const Q=Te=>{var Re;const{addSelectedEdges:pe,unselectNodesAndEdges:be,multiSelectionActive:De}=H.getState();P&&(H.setState({nodesSelectionActive:!1}),_.selected&&De?(be({nodes:[],edges:[_]}),(Re=R.current)==null||Re.blur()):pe([e])),r&&r(Te,_)},ie=o?Te=>{o(Te,{..._})}:void 0,re=l?Te=>{l(Te,{..._})}:void 0,ne=u?Te=>{u(Te,{..._})}:void 0,fe=d?Te=>{d(Te,{..._})}:void 0,Ee=h?Te=>{h(Te,{..._})}:void 0,Ue=Te=>{var pe;if(!S&&K1.includes(Te.key)&&P){const{unselectNodesAndEdges:be,addSelectedEdges:De}=H.getState();Te.key==="Escape"?((pe=R.current)==null||pe.blur(),be({edges:[_]})):De([e])}};return n.jsx("svg",{style:{zIndex:F},children:n.jsxs("g",{className:_n(["react-flow__edge",`react-flow__edge-${M}`,_.className,j,{selected:_.selected,animated:_.animated,inactive:!P&&!r,updating:z,selectable:P}]),onClick:Q,onDoubleClick:ie,onContextMenu:re,onMouseEnter:ne,onMouseMove:fe,onMouseLeave:Ee,onKeyDown:B?Ue:void 0,tabIndex:B?0:void 0,role:_.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":_.ariaLabel===null?void 0:_.ariaLabel||`Edge from ${_.source} to ${_.target}`,"aria-describedby":B?`${C_}-${k}`:void 0,ref:R,..._.domAttributes,children:[!A&&n.jsx(O,{id:e,source:_.source,target:_.target,type:_.type,selected:_.selected,animated:_.animated,selectable:P,deletable:_.deletable??!0,label:_.label,labelStyle:_.labelStyle,labelShowBg:_.labelShowBg,labelBgStyle:_.labelBgStyle,labelBgPadding:_.labelBgPadding,labelBgBorderRadius:_.labelBgBorderRadius,sourceX:V,sourceY:D,targetX:q,targetY:te,sourcePosition:G,targetPosition:K,data:_.data,style:_.style,sourceHandleId:_.sourceHandle,targetHandleId:_.targetHandle,markerStart:Z,markerEnd:Y,pathOptions:"pathOptions"in _?_.pathOptions:void 0,interactionWidth:_.interactionWidth}),U&&n.jsx(p9,{edge:_,isReconnectable:U,reconnectRadius:m,onReconnect:p,onReconnectStart:g,onReconnectEnd:x,sourceX:V,sourceY:D,targetX:q,targetY:te,sourcePosition:G,targetPosition:K,setUpdateHover:L,setReconnecting:T})]})})}var x9=v.memo(g9);const v9=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function eE({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:s,edgeTypes:i,noPanClassName:r,onReconnect:o,onEdgeContextMenu:l,onEdgeMouseEnter:u,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:g,onReconnectStart:x,onReconnectEnd:k,disableKeyboardA11y:b}){const{edgesFocusable:j,edgesReconnectable:w,elementsSelectable:S,onError:_}=At(v9,un),E=n9(t);return n.jsxs("div",{className:"react-flow__edges",children:[n.jsx(o9,{defaultColor:e,rfId:s}),E.map(M=>n.jsx(x9,{id:M,edgesFocusable:j,edgesReconnectable:w,elementsSelectable:S,noPanClassName:r,onReconnect:o,onContextMenu:l,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,onClick:m,reconnectRadius:p,onDoubleClick:g,onReconnectStart:x,onReconnectEnd:k,rfId:s,onError:_,edgeTypes:i,disableKeyboardA11y:b},M))]})}eE.displayName="EdgeRenderer";const y9=v.memo(eE),Lj=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function b9({children:e}){const t=Xt(),s=v.useRef(null),[i]=v.useState(()=>t.getState().transform);return T_(()=>{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=Lj(l)))};return o(),t.subscribe(o)},[t]),n.jsx("div",{ref:s,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Lj(i)},children:e})}function k9(e){const t=Bx(),s=v.useRef(!1);v.useEffect(()=>{!s.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),s.current=!0)},[e,t.viewportInitialized])}const j9=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function N9(e){const t=At(j9),s=Xt();return v.useEffect(()=>{e&&(t==null||t(e),s.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function w9(e){return e.connection.inProgress?{...e.connection,to:Yc(e.connection.to,e.transform)}:{...e.connection}}function S9(e){return w9}function _9(e){const t=S9();return At(t,un)}const E9=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function C9({containerStyle:e,style:t,type:s,component:i}){const{nodesConnectable:r,width:o,height:l,isValid:u,inProgress:d}=At(E9,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",a_(u)]),children:n.jsx(tE,{style:t,type:s,CustomComponent:i,isValid:u})})})}const tE=({style:e,type:t=Wr.Bezier,CustomComponent:s,isValid:i})=>{const{inProgress:r,from:o,fromNode:l,fromHandle:u,fromPosition:d,to:h,toNode:m,toHandle:p,toPosition:g,pointer:x}=_9();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:a_(i),toNode:m,toHandle:p,pointer:x});let k="";const b={sourceX:o.x,sourceY:o.y,sourcePosition:d,targetX:h.x,targetY:h.y,targetPosition:g};switch(t){case Wr.Bezier:[k]=d_(b);break;case Wr.SimpleBezier:[k]=B_(b);break;case Wr.Step:[k]=gg({...b,borderRadius:0});break;case Wr.SmoothStep:[k]=gg(b);break;default:[k]=m_(b)}return n.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:e})};tE.displayName="ConnectionLine";const A9={};function zj(e=A9){v.useRef(e),Xt(),v.useEffect(()=>{},[e])}function $9(){Xt(),v.useRef(!1),v.useEffect(()=>{},[])}function nE({nodeTypes:e,edgeTypes:t,onInit:s,onNodeClick:i,onEdgeClick:r,onNodeDoubleClick:o,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:g,onSelectionEnd:x,connectionLineType:k,connectionLineStyle:b,connectionLineComponent:j,connectionLineContainerStyle:w,selectionKeyCode:S,selectionOnDrag:_,selectionMode:E,multiSelectionKeyCode:M,panActivationKeyCode:O,zoomActivationKeyCode:B,deleteKeyCode:U,onlyRenderVisibleElements:P,elementsSelectable:R,defaultViewport:z,translateExtent:L,minZoom:A,maxZoom:T,preventScrolling:H,defaultMarkerColor:F,zoomOnScroll:V,zoomOnPinch:D,panOnScroll:q,panOnScrollSpeed:te,panOnScrollMode:G,zoomOnDoubleClick:K,panOnDrag:Z,autoPanOnSelection:Y,onPaneClick:Q,onPaneMouseEnter:ie,onPaneMouseMove:re,onPaneMouseLeave:ne,onPaneScroll:fe,onPaneContextMenu:Ee,paneClickDistance:Ue,nodeClickDistance:Te,onEdgeContextMenu:pe,onEdgeMouseEnter:be,onEdgeMouseMove:De,onEdgeMouseLeave:Re,reconnectRadius:ae,onReconnect:Fe,onReconnectStart:ut,onReconnectEnd:gt,noDragClassName:Rt,noWheelClassName:En,noPanClassName:rt,disableKeyboardA11y:Pt,nodeExtent:rn,rfId:Zt,viewport:Qt,onViewportChange:Ut,nodesDraggable:Rn}){return zj(e),zj(t),$9(),k9(s),N9(Qt),n.jsx(VH,{onPaneClick:Q,onPaneMouseEnter:ie,onPaneMouseMove:re,onPaneMouseLeave:ne,onPaneContextMenu:Ee,onPaneScroll:fe,paneClickDistance:Ue,deleteKeyCode:U,selectionKeyCode:S,selectionOnDrag:_,selectionMode:E,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:M,panActivationKeyCode:O,zoomActivationKeyCode:B,elementsSelectable:R,zoomOnScroll:V,zoomOnPinch:D,zoomOnDoubleClick:K,panOnScroll:q,panOnScrollSpeed:te,panOnScrollMode:G,panOnDrag:Z,autoPanOnSelection:Y,defaultViewport:z,translateExtent:L,minZoom:A,maxZoom:T,onSelectionContextMenu:p,preventScrolling:H,noDragClassName:Rt,noWheelClassName:En,noPanClassName:rt,disableKeyboardA11y:Pt,onViewportChange:Ut,isControlledViewport:!!Qt,children:n.jsxs(b9,{children:[n.jsx(y9,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:l,onReconnect:Fe,onReconnectStart:ut,onReconnectEnd:gt,onlyRenderVisibleElements:P,onEdgeContextMenu:pe,onEdgeMouseEnter:be,onEdgeMouseMove:De,onEdgeMouseLeave:Re,reconnectRadius:ae,defaultMarkerColor:F,noPanClassName:rt,disableKeyboardA11y:Pt,rfId:Zt}),n.jsx(C9,{style:b,type:k,component:j,containerStyle:w}),n.jsx("div",{className:"react-flow__edgelabel-renderer"}),n.jsx(t9,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:o,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,nodeClickDistance:Te,onlyRenderVisibleElements:P,noPanClassName:rt,noDragClassName:Rt,disableKeyboardA11y:Pt,nodeExtent:rn,rfId:Zt,nodesDraggable:Rn}),n.jsx("div",{className:"react-flow__viewport-portal"})]})})}nE.displayName="GraphView";const I9=v.memo(nE),T9=s_(),Dj=({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,width:r,height:o,fitView:l,fitViewOptions:u,minZoom:d=.5,maxZoom:h=2,nodeOrigin:m,nodeExtent:p,zIndexMode:g="basic"}={})=>{const x=new Map,k=new Map,b=new Map,j=new Map,w=i??t??[],S=s??e??[],_=m??[0,0],E=p??Ac;g_(b,j,w);const{nodesInitialized:M}=vg(S,x,k,{nodeOrigin:_,nodeExtent:E,zIndexMode:g});let O=[0,0,1];if(l&&r&&o){const B=Gc(x,{filter:z=>!!((z.width||z.initialWidth)&&(z.height||z.initialHeight))}),{x:U,y:P,zoom:R}=Ox(B,r,o,d,h,(u==null?void 0:u.padding)??.1);O=[U,P,R]}return{rfId:"1",width:r??0,height:o??0,transform:O,nodes:S,nodesInitialized:M,nodeLookup:x,parentLookup:k,edges:w,edgeLookup:j,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:s!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:d,maxZoom:h,translateExtent:Ac,nodeExtent:E,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Qo.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:_,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:{...X1},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:T9,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Y1,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:m,nodeExtent:p,zIndexMode:g})=>WB((x,k)=>{async function b(){const{nodeLookup:j,panZoom:w,fitViewOptions:S,fitViewResolver:_,width:E,height:M,minZoom:O,maxZoom:B}=k();w&&(await UU({nodes:j,width:E,height:M,panZoom:w,minZoom:O,maxZoom:B},S),_==null||_.resolve(!0),x({fitViewResolver:null}))}return{...Dj({nodes:e,edges:t,width:r,height:o,fitView:l,fitViewOptions:u,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:p,defaultNodes:s,defaultEdges:i,zIndexMode:g}),setNodes:j=>{const{nodeLookup:w,parentLookup:S,nodeOrigin:_,nodeExtent:E,elevateNodesOnSelect:M,fitViewQueued:O,zIndexMode:B,nodesSelectionActive:U}=k(),{nodesInitialized:P,hasSelectedNodes:R}=vg(j,w,S,{nodeOrigin:_,nodeExtent:E,elevateNodesOnSelect:M,checkEquality:!0,zIndexMode:B}),z=U&&R;O&&P?(b(),x({nodes:j,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:z})):x({nodes:j,nodesInitialized:P,nodesSelectionActive:z})},setEdges:j=>{const{connectionLookup:w,edgeLookup:S}=k();g_(w,S,j),x({edges:j})},setDefaultNodesAndEdges:(j,w)=>{if(j){const{setNodes:S}=k();S(j),x({hasDefaultNodes:!0})}if(w){const{setEdges:S}=k();S(w),x({hasDefaultEdges:!0})}},updateNodeInternals:j=>{const{triggerNodeChanges:w,nodeLookup:S,parentLookup:_,domNode:E,nodeOrigin:M,nodeExtent:O,debug:B,fitViewQueued:U,zIndexMode:P}=k(),{changes:R,updatedInternals:z}=uB(j,S,_,E,M,O,P);z&&(aB(S,_,{nodeOrigin:M,nodeExtent:O,zIndexMode:P}),U?(b(),x({fitViewQueued:!1,fitViewOptions:void 0})):x({}),(R==null?void 0:R.length)>0&&(B&&console.log("React Flow: trigger node changes",R),w==null||w(R)))},updateNodePositions:(j,w=!1)=>{const S=[];let _=[];const{nodeLookup:E,triggerNodeChanges:M,connection:O,updateConnection:B,onNodesChangeMiddlewareMap:U}=k();for(const[P,R]of j){const z=E.get(P),L=!!(z!=null&&z.expandParent&&(z!=null&&z.parentId)&&(R!=null&&R.position)),A={id:P,type:"position",position:L?{x:Math.max(0,R.position.x),y:Math.max(0,R.position.y)}:R.position,dragging:w};if(z&&O.inProgress&&O.fromNode.id===z.id){const T=Wa(z,O.fromHandle,tt.Left,!0);B({...O,from:T})}L&&z.parentId&&S.push({id:P,parentId:z.parentId,rect:{...R.internals.positionAbsolute,width:R.measured.width??0,height:R.measured.height??0}}),_.push(A)}if(S.length>0){const{parentLookup:P,nodeOrigin:R}=k(),z=Ux(S,E,P,R);_.push(...z)}for(const P of U.values())_=P(_);M(_)},triggerNodeChanges:j=>{const{onNodesChange:w,setNodes:S,nodes:_,hasDefaultNodes:E,debug:M}=k();if(j!=null&&j.length){if(E){const O=hH(j,_);S(O)}M&&console.log("React Flow: trigger node changes",j),w==null||w(j)}},triggerEdgeChanges:j=>{const{onEdgesChange:w,setEdges:S,edges:_,hasDefaultEdges:E,debug:M}=k();if(j!=null&&j.length){if(E){const O=mH(j,_);S(O)}M&&console.log("React Flow: trigger edge changes",j),w==null||w(j)}},addSelectedNodes:j=>{const{multiSelectionActive:w,edgeLookup:S,nodeLookup:_,triggerNodeChanges:E,triggerEdgeChanges:M}=k();if(w){const O=j.map(B=>Ea(B,!0));E(O);return}E(Co(_,new Set([...j]),!0)),M(Co(S))},addSelectedEdges:j=>{const{multiSelectionActive:w,edgeLookup:S,nodeLookup:_,triggerNodeChanges:E,triggerEdgeChanges:M}=k();if(w){const O=j.map(B=>Ea(B,!0));M(O);return}M(Co(S,new Set([...j]))),E(Co(_,new Set,!0))},unselectNodesAndEdges:({nodes:j,edges:w}={})=>{const{edges:S,nodes:_,nodeLookup:E,triggerNodeChanges:M,triggerEdgeChanges:O}=k(),B=j||_,U=w||S,P=[];for(const z of B){if(!z.selected)continue;const L=E.get(z.id);L&&(L.selected=!1),P.push(Ea(z.id,!1))}const R=[];for(const z of U)z.selected&&R.push(Ea(z.id,!1));M(P),O(R)},setMinZoom:j=>{const{panZoom:w,maxZoom:S}=k();w==null||w.setScaleExtent([j,S]),x({minZoom:j})},setMaxZoom:j=>{const{panZoom:w,minZoom:S}=k();w==null||w.setScaleExtent([S,j]),x({maxZoom:j})},setTranslateExtent:j=>{var w;(w=k().panZoom)==null||w.setTranslateExtent(j),x({translateExtent:j})},resetSelectedElements:()=>{const{edges:j,nodes:w,triggerNodeChanges:S,triggerEdgeChanges:_,elementsSelectable:E}=k();if(!E)return;const M=w.reduce((B,U)=>U.selected?[...B,Ea(U.id,!1)]:B,[]),O=j.reduce((B,U)=>U.selected?[...B,Ea(U.id,!1)]:B,[]);S(M),_(O)},setNodeExtent:j=>{const{nodes:w,nodeLookup:S,parentLookup:_,nodeOrigin:E,elevateNodesOnSelect:M,nodeExtent:O,zIndexMode:B}=k();j[0][0]===O[0][0]&&j[0][1]===O[0][1]&&j[1][0]===O[1][0]&&j[1][1]===O[1][1]||(vg(w,S,_,{nodeOrigin:E,nodeExtent:j,elevateNodesOnSelect:M,checkEquality:!1,zIndexMode:B}),x({nodeExtent:j}))},panBy:j=>{const{transform:w,width:S,height:_,panZoom:E,translateExtent:M}=k();return dB({delta:j,panZoom:E,transform:w,translateExtent:M,width:S,height:_})},setCenter:async(j,w,S)=>{const{width:_,height:E,maxZoom:M,panZoom:O}=k();if(!O)return!1;const B=typeof(S==null?void 0:S.zoom)<"u"?S.zoom:M;return await O.setViewport({x:_/2-j*B,y:E/2-w*B,zoom:B},{duration:S==null?void 0:S.duration,ease:S==null?void 0:S.ease,interpolate:S==null?void 0:S.interpolate}),!0},cancelConnection:()=>{x({connection:{...X1}})},updateConnection:j=>{x({connection:j})},reset:()=>x({...Dj()})}},Object.is);function R9({initialNodes:e,initialEdges:t,defaultNodes:s,defaultEdges:i,initialWidth:r,initialHeight:o,initialMinZoom:l,initialMaxZoom:u,initialFitViewOptions:d,fitView:h,nodeOrigin:m,nodeExtent:p,zIndexMode:g,children:x}){const[k]=v.useState(()=>M9({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,width:r,height:o,fitView:h,minZoom:l,maxZoom:u,fitViewOptions:d,nodeOrigin:m,nodeExtent:p,zIndexMode:g}));return n.jsx(VB,{value:k,children:n.jsx(vH,{children:n.jsx(MH,{children:x})})})}function O9({children:e,nodes:t,edges:s,defaultNodes:i,defaultEdges:r,width:o,height:l,fitView:u,fitViewOptions:d,minZoom:h,maxZoom:m,nodeOrigin:p,nodeExtent:g,zIndexMode:x}){return v.useContext(Nh)?n.jsx(n.Fragment,{children:e}):n.jsx(R9,{initialNodes:t,initialEdges:s,defaultNodes:i,defaultEdges:r,initialWidth:o,initialHeight:l,fitView:u,initialFitViewOptions:d,initialMinZoom:h,initialMaxZoom:m,nodeOrigin:p,nodeExtent:g,zIndexMode:x,children:e})}const P9={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function L9({nodes:e,edges:t,defaultNodes:s,defaultEdges:i,className:r,nodeTypes:o,edgeTypes:l,onNodeClick:u,onEdgeClick:d,onInit:h,onMove:m,onMoveStart:p,onMoveEnd:g,onConnect:x,onConnectStart:k,onConnectEnd:b,onClickConnectStart:j,onClickConnectEnd:w,onNodeMouseEnter:S,onNodeMouseMove:_,onNodeMouseLeave:E,onNodeContextMenu:M,onNodeDoubleClick:O,onNodeDragStart:B,onNodeDrag:U,onNodeDragStop:P,onNodesDelete:R,onEdgesDelete:z,onDelete:L,onSelectionChange:A,onSelectionDragStart:T,onSelectionDrag:H,onSelectionDragStop:F,onSelectionContextMenu:V,onSelectionStart:D,onSelectionEnd:q,onBeforeDelete:te,connectionMode:G,connectionLineType:K=Wr.Bezier,connectionLineStyle:Z,connectionLineComponent:Y,connectionLineContainerStyle:Q,deleteKeyCode:ie="Backspace",selectionKeyCode:re="Shift",selectionOnDrag:ne=!1,selectionMode:fe=$c.Full,panActivationKeyCode:Ee="Space",multiSelectionKeyCode:Ue=Tc()?"Meta":"Control",zoomActivationKeyCode:Te=Tc()?"Meta":"Control",snapToGrid:pe,snapGrid:be,onlyRenderVisibleElements:De=!1,selectNodesOnDrag:Re,nodesDraggable:ae,autoPanOnNodeFocus:Fe,nodesConnectable:ut,nodesFocusable:gt,nodeOrigin:Rt=A_,edgesFocusable:En,edgesReconnectable:rt,elementsSelectable:Pt=!0,defaultViewport:rn=rH,minZoom:Zt=.5,maxZoom:Qt=2,translateExtent:Ut=Ac,preventScrolling:Rn=!0,nodeExtent:mn,defaultMarkerColor:Hn="#b1b1b7",zoomOnScroll:Gs=!0,zoomOnPinch:ps=!0,panOnScroll:rs=!1,panOnScrollSpeed:gs=.5,panOnScrollMode:Cn=Da.Free,zoomOnDoubleClick:as=!0,panOnDrag:Kn=!0,onPaneClick:Zn,onPaneMouseEnter:An,onPaneMouseMove:Yn,onPaneMouseLeave:On,onPaneScroll:ce,onPaneContextMenu:J,paneClickDistance:me=1,nodeClickDistance:we=0,children:He,onReconnect:dt,onReconnectStart:Nt,onReconnectEnd:Ze,onEdgeContextMenu:Be,onEdgeDoubleClick:Xe,onEdgeMouseEnter:yt,onEdgeMouseMove:St,onEdgeMouseLeave:Xn,reconnectRadius:xs=10,onNodesChange:ui,onEdgesChange:yr,noDragClassName:di="nodrag",noWheelClassName:br="nowheel",noPanClassName:Qn="nopan",fitView:Gi,fitViewOptions:vs,connectOnClick:Mi,attributionPosition:kr,proOptions:zt,defaultEdgeOptions:Os,elevateNodesOnSelect:os=!0,elevateEdgesOnSelect:Ki=!1,disableKeyboardA11y:hi=!1,autoPanOnConnect:Dt,autoPanOnNodeDrag:jr,autoPanOnSelection:Yi=!0,autoPanSpeed:mi,connectionRadius:Ri,isValidConnection:Oe,onError:qe,style:ht,id:ft,nodeDragThreshold:Ot,connectionDragThreshold:Ft,viewport:Jn,onViewportChange:Ks,width:fn,height:$n,colorMode:Ys="light",debug:Xs,onScroll:ys,ariaLabelConfig:la,zIndexMode:Nr="basic",...Oi},wr){const ls=ft||"1",bs=cH(Ys),In=v.useCallback(Qs=>{Qs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),ys==null||ys(Qs)},[ys]);return n.jsx("div",{"data-testid":"rf__wrapper",...Oi,onScroll:In,style:{...ht,...P9},ref:wr,className:_n(["react-flow",r,bs]),id:ft,role:"application",children:n.jsxs(O9,{nodes:e,edges:t,width:fn,height:$n,fitView:Gi,fitViewOptions:vs,minZoom:Zt,maxZoom:Qt,nodeOrigin:Rt,nodeExtent:mn,zIndexMode:Nr,children:[n.jsx(lH,{nodes:e,edges:t,defaultNodes:s,defaultEdges:i,onConnect:x,onConnectStart:k,onConnectEnd:b,onClickConnectStart:j,onClickConnectEnd:w,nodesDraggable:ae,autoPanOnNodeFocus:Fe,nodesConnectable:ut,nodesFocusable:gt,edgesFocusable:En,edgesReconnectable:rt,elementsSelectable:Pt,elevateNodesOnSelect:os,elevateEdgesOnSelect:Ki,minZoom:Zt,maxZoom:Qt,nodeExtent:mn,onNodesChange:ui,onEdgesChange:yr,snapToGrid:pe,snapGrid:be,connectionMode:G,translateExtent:Ut,connectOnClick:Mi,defaultEdgeOptions:Os,fitView:Gi,fitViewOptions:vs,onNodesDelete:R,onEdgesDelete:z,onDelete:L,onNodeDragStart:B,onNodeDrag:U,onNodeDragStop:P,onSelectionDrag:H,onSelectionDragStart:T,onSelectionDragStop:F,onMove:m,onMoveStart:p,onMoveEnd:g,noPanClassName:Qn,nodeOrigin:Rt,rfId:ls,autoPanOnConnect:Dt,autoPanOnNodeDrag:jr,autoPanSpeed:mi,onError:qe,connectionRadius:Ri,isValidConnection:Oe,selectNodesOnDrag:Re,nodeDragThreshold:Ot,connectionDragThreshold:Ft,onBeforeDelete:te,debug:Xs,ariaLabelConfig:la,zIndexMode:Nr}),n.jsx(I9,{onInit:h,onNodeClick:u,onEdgeClick:d,onNodeMouseEnter:S,onNodeMouseMove:_,onNodeMouseLeave:E,onNodeContextMenu:M,onNodeDoubleClick:O,nodeTypes:o,edgeTypes:l,connectionLineType:K,connectionLineStyle:Z,connectionLineComponent:Y,connectionLineContainerStyle:Q,selectionKeyCode:re,selectionOnDrag:ne,selectionMode:fe,deleteKeyCode:ie,multiSelectionKeyCode:Ue,panActivationKeyCode:Ee,zoomActivationKeyCode:Te,onlyRenderVisibleElements:De,defaultViewport:rn,translateExtent:Ut,minZoom:Zt,maxZoom:Qt,preventScrolling:Rn,zoomOnScroll:Gs,zoomOnPinch:ps,zoomOnDoubleClick:as,panOnScroll:rs,panOnScrollSpeed:gs,panOnScrollMode:Cn,panOnDrag:Kn,autoPanOnSelection:Yi,onPaneClick:Zn,onPaneMouseEnter:An,onPaneMouseMove:Yn,onPaneMouseLeave:On,onPaneScroll:ce,onPaneContextMenu:J,paneClickDistance:me,nodeClickDistance:we,onSelectionContextMenu:V,onSelectionStart:D,onSelectionEnd:q,onReconnect:dt,onReconnectStart:Nt,onReconnectEnd:Ze,onEdgeContextMenu:Be,onEdgeDoubleClick:Xe,onEdgeMouseEnter:yt,onEdgeMouseMove:St,onEdgeMouseLeave:Xn,reconnectRadius:xs,defaultMarkerColor:Hn,noDragClassName:di,noWheelClassName:br,noPanClassName:Qn,rfId:ls,disableKeyboardA11y:hi,nodeExtent:mn,viewport:Jn,onViewportChange:Ks,nodesDraggable:ae}),n.jsx(iH,{onSelectionChange:A}),He,n.jsx(JB,{proOptions:zt,position:kr}),n.jsx(QB,{rfId:ls,disableKeyboardA11y:hi})]})})}var z9=I_(L9);function D9({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 F9({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 U9={[ta.Dots]:1,[ta.Lines]:1,[ta.Cross]:6},B9=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function sE({id:e,variant:t=ta.Dots,gap:s=20,size:i,lineWidth:r=1,offset:o=0,color:l,bgColor:u,style:d,className:h,patternClassName:m}){const p=v.useRef(null),{transform:g,patternId:x}=At(B9,un),k=i||U9[t],b=t===ta.Dots,j=t===ta.Cross,w=Array.isArray(s)?s:[s,s],S=[w[0]*g[2]||1,w[1]*g[2]||1],_=k*g[2],E=Array.isArray(o)?o:[o,o],M=j?[_,_]:S,O=[E[0]*g[2]+M[0]/2,E[1]*g[2]+M[1]/2],B=`${x}${e||""}`;return n.jsxs("svg",{className:_n(["react-flow__background",h]),style:{...d,...Sh,"--xy-background-color-props":u,"--xy-background-pattern-color-props":l},ref:p,"data-testid":"rf__background",children:[n.jsx("pattern",{id:B,x:g[0]%S[0],y:g[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${O[0]},-${O[1]})`,children:b?n.jsx(F9,{radius:_/2,className:m}):n.jsx(D9,{dimensions:M,lineWidth:r,variant:t,className:m})}),n.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}sE.displayName="Background";const H9=v.memo(sE);function Z9(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:n.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function W9(){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 V9(){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 q9(){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 G9(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:n.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function md({children:e,className:t,...s}){return n.jsx("button",{type:"button",className:_n(["react-flow__controls-button",t]),...s,children:e})}const K9=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function iE({style:e,showZoom:t=!0,showFitView:s=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:o,onZoomOut:l,onFitView:u,onInteractiveChange:d,className:h,children:m,position:p="bottom-left",orientation:g="vertical","aria-label":x}){const k=Xt(),{isInteractive:b,minZoomReached:j,maxZoomReached:w,ariaLabelConfig:S}=At(K9,un),{zoomIn:_,zoomOut:E,fitView:M}=Bx(),O=()=>{_(),o==null||o()},B=()=>{E(),l==null||l()},U=()=>{M(r),u==null||u()},P=()=>{k.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),d==null||d(!b)},R=g==="horizontal"?"horizontal":"vertical";return n.jsxs(wh,{className:_n(["react-flow__controls",R,h]),position:p,style:e,"data-testid":"rf__controls","aria-label":x??S["controls.ariaLabel"],children:[t&&n.jsxs(n.Fragment,{children:[n.jsx(md,{onClick:O,className:"react-flow__controls-zoomin",title:S["controls.zoomIn.ariaLabel"],"aria-label":S["controls.zoomIn.ariaLabel"],disabled:w,children:n.jsx(Z9,{})}),n.jsx(md,{onClick:B,className:"react-flow__controls-zoomout",title:S["controls.zoomOut.ariaLabel"],"aria-label":S["controls.zoomOut.ariaLabel"],disabled:j,children:n.jsx(W9,{})})]}),s&&n.jsx(md,{className:"react-flow__controls-fitview",onClick:U,title:S["controls.fitView.ariaLabel"],"aria-label":S["controls.fitView.ariaLabel"],children:n.jsx(V9,{})}),i&&n.jsx(md,{className:"react-flow__controls-interactive",onClick:P,title:S["controls.interactive.ariaLabel"],"aria-label":S["controls.interactive.ariaLabel"],children:b?n.jsx(G9,{}):n.jsx(q9,{})}),m]})}iE.displayName="Controls";const Y9=v.memo(iE);function X9({id:e,x:t,y:s,width:i,height:r,style:o,color:l,strokeColor:u,strokeWidth:d,className:h,borderRadius:m,shapeRendering:p,selected:g,onClick:x}){const{background:k,backgroundColor:b}=o||{},j=l||k||b;return n.jsx("rect",{className:_n(["react-flow__minimap-node",{selected:g},h]),x:t,y:s,rx:m,ry:m,width:i,height:r,style:{fill:j,stroke:u,strokeWidth:d},shapeRendering:p,onClick:x?w=>x(w,e):void 0})}const Q9=v.memo(X9),J9=e=>e.nodes.map(t=>t.id),cp=e=>e instanceof Function?e:()=>e;function e8({nodeStrokeColor:e,nodeColor:t,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:o=Q9,onClick:l}){const u=At(J9,un),d=cp(t),h=cp(e),m=cp(s),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return n.jsx(n.Fragment,{children:u.map(g=>n.jsx(n8,{id:g,nodeColorFunc:d,nodeStrokeColorFunc:h,nodeClassNameFunc:m,nodeBorderRadius:i,nodeStrokeWidth:r,NodeComponent:o,onClick:l,shapeRendering:p},g))})}function t8({id:e,nodeColorFunc:t,nodeStrokeColorFunc:s,nodeClassNameFunc:i,nodeBorderRadius:r,nodeStrokeWidth:o,shapeRendering:l,NodeComponent:u,onClick:d}){const{node:h,x:m,y:p,width:g,height:x}=At(k=>{const b=k.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const j=b.internals.userNode,{x:w,y:S}=b.internals.positionAbsolute,{width:_,height:E}=Ti(j);return{node:j,x:w,y:S,width:_,height:E}},un);return!h||h.hidden||!i_(h)?null:n.jsx(u,{x:m,y:p,width:g,height:x,style:h.style,selected:!!h.selected,className:i(h),color:t(h),borderRadius:r,strokeColor:s(h),strokeWidth:o,shapeRendering:l,onClick:d,id:h.id})}const n8=v.memo(t8);var s8=v.memo(e8);const i8=200,r8=150,a8=e=>!e.hidden,o8=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?t_(Gc(e.nodeLookup,{filter:a8}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Fj=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,l8=(e,t)=>Fj(e.viewBB,t.viewBB)&&Fj(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,c8="react-flow__minimap-desc";function rE({style:e,className:t,nodeStrokeColor:s,nodeColor:i,nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:l,nodeComponent:u,bgColor:d,maskColor:h,maskStrokeColor:m,maskStrokeWidth:p,position:g="bottom-right",onClick:x,onNodeClick:k,pannable:b=!1,zoomable:j=!1,ariaLabel:w,inversePan:S,zoomStep:_=1,offsetScale:E=5}){const M=Xt(),O=v.useRef(null),{boundingRect:B,panZoom:U,viewBB:P,rfId:R,translateExtent:z,flowWidth:L,flowHeight:A,ariaLabelConfig:T}=At(o8,l8),H=(e==null?void 0:e.width)??i8,F=(e==null?void 0:e.height)??r8,V=B.width/H,D=B.height/F,q=Math.max(V,D),te=q*H,G=q*F,K=E*q,Z=B.x-(te-B.width)/2-K,Y=B.y-(G-B.height)/2-K,Q=te+K*2,ie=G+K*2,re=`${c8}-${R}`,ne=v.useRef(0),fe=v.useRef();ne.current=q,v.useEffect(()=>{const be=M.getState().panZoom;if(O.current&&be)return fe.current=bB({domNode:O.current,panZoom:be,getTransform:()=>M.getState().transform,getViewScale:()=>ne.current}),()=>{var De;(De=fe.current)==null||De.destroy()}},[U]),v.useEffect(()=>{var be;(be=fe.current)==null||be.update({translateExtent:z,width:L,height:A,inversePan:S,pannable:b,zoomStep:_,zoomable:j})},[b,j,S,_,z,L,A]);const Ee=x?be=>{var ae;const[De,Re]=((ae=fe.current)==null?void 0:ae.pointer(be))||[0,0];x(be,{x:De,y:Re})}:void 0,Ue=v.useCallback((be,De)=>{const Re=M.getState().nodeLookup.get(De).internals.userNode;k==null||k(be,Re)},[k]),Te=k?Ue:void 0,pe=w??T["minimap.ariaLabel"];return n.jsx(wh,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*q:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-width-props":typeof l=="number"?l:void 0},className:_n(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:n.jsxs("svg",{width:H,height:F,viewBox:`${Z} ${Y} ${Q} ${ie}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":re,ref:O,onClick:Ee,children:[pe&&n.jsx("title",{id:re,children:pe}),n.jsx(s8,{onClick:Te,nodeColor:i,nodeStrokeColor:s,nodeBorderRadius:o,nodeClassName:r,nodeStrokeWidth:l,nodeComponent:u}),n.jsx("path",{className:"react-flow__minimap-mask",d:`M${Z-K},${Y-K}h${Q+K*2}v${ie+K*2}h${-Q-K*2}z
244
+ M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}rE.displayName="MiniMap";v.memo(rE);const u8=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,d8={[tl.Line]:"right",[tl.Handle]:"bottom-right"};function h8({nodeId:e,position:t,variant:s=tl.Handle,className:i,style:r=void 0,children:o,color:l,minWidth:u=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:g,autoScale:x=!0,shouldResize:k,onResizeStart:b,onResize:j,onResizeEnd:w}){const S=P_(),_=typeof e=="string"?e:S,E=Xt(),M=v.useRef(null),O=s===tl.Handle,B=At(v.useCallback(u8(O&&x),[O,x]),un),U=v.useRef(null),P=t??d8[s];v.useEffect(()=>{if(!(!M.current||!_))return U.current||(U.current=MB({domNode:M.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:z,transform:L,snapGrid:A,snapToGrid:T,nodeOrigin:H,domNode:F}=E.getState();return{nodeLookup:z,transform:L,snapGrid:A,snapToGrid:T,nodeOrigin:H,paneDomNode:F}},onChange:(z,L)=>{const{triggerNodeChanges:A,nodeLookup:T,parentLookup:H,nodeOrigin:F}=E.getState(),V=[],D={x:z.x,y:z.y},q=T.get(_);if(q&&q.expandParent&&q.parentId){const te=q.origin??F,G=z.width??q.measured.width??0,K=z.height??q.measured.height??0,Z={id:q.id,parentId:q.parentId,rect:{width:G,height:K,...r_({x:z.x??q.position.x,y:z.y??q.position.y},{width:G,height:K},q.parentId,T,te)}},Y=Ux([Z],T,H,F);V.push(...Y),D.x=z.x?Math.max(te[0]*G,z.x):void 0,D.y=z.y?Math.max(te[1]*K,z.y):void 0}if(D.x!==void 0&&D.y!==void 0){const te={id:_,type:"position",position:{...D}};V.push(te)}if(z.width!==void 0&&z.height!==void 0){const G={id:_,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:z.width,height:z.height}};V.push(G)}for(const te of L){const G={...te,type:"position"};V.push(G)}A(V)},onEnd:({width:z,height:L})=>{const A={id:_,type:"dimensions",resizing:!1,dimensions:{width:z,height:L}};E.getState().triggerNodeChanges([A])}})),U.current.update({controlPosition:P,boundaries:{minWidth:u,minHeight:d,maxWidth:h,maxHeight:m},keepAspectRatio:p,resizeDirection:g,onResizeStart:b,onResize:j,onResizeEnd:w,shouldResize:k}),()=>{var z;(z=U.current)==null||z.destroy()}},[P,u,d,h,m,p,b,j,w,k]);const R=P.split("-");return n.jsx("div",{className:_n(["react-flow__resize-control","nodrag",...R,s,i]),ref:M,style:{...r,scale:B,...l&&{[O?"backgroundColor":"borderColor"]:l}},children:o})}v.memo(h8);function m8(e,t=0){const s=Se(e.connection.status),[i,r]=v.useState([]);return v.useEffect(()=>{if(s.state!=="open")return;let o=!0;return(async()=>{const{scripts:l}=await e.connection.call("scripts/list",{}),u=[];for(const d of l){if(d.packId===void 0)continue;const h=await e.connection.call("runs/tasks",{scriptId:d.id}).catch(()=>{});if(h===void 0||h.tasks.length===0)continue;const m=await e.connection.call("configs/profiles",{scriptId:d.id}).catch(()=>{});u.push({scriptId:d.id,scriptName:d.name,tasks:h.tasks,profiles:m})}o&&r(u)})().catch(()=>{}),()=>{o=!1}},[e,s.state,t]),v.useEffect(()=>e.connection.on("configs/profiles/changed",o=>{r(l=>l.map(u=>u.scriptId===o.scriptId?{...u,profiles:o.list}:u))}),[e]),i}const aE=[0,1,2,3,4,5].map(e=>({value:String(e),label:e===0?"不重试":`重试 ${e} 次`})),oE=[{value:"continue",label:"然后继续其他分支"},{value:"stop",label:"然后停止流水线"}],nl={"script-task":"脚本任务",agent:"agent 步骤",wait:"控制节点",notify:"发消息",gate:"人工确认",start:"开始",end:"结束"},kg={pending:"待运行",waiting:"等待中",running:"运行中",succeeded:"成功",failed:"失败",skipped:"跳过",cancelled:"取消"},f8={success:"成功后",failure:"失败后",always:"结束后"},up={desktop:"鼠标键盘",adb:"模拟器",window:"后台窗口",none:""};function p8({data:e,selected:t}){var i,r,o,l;const s=(i=e.state)==null?void 0:i.state;return Wi(e.node)?n.jsxs("div",{className:`step-node marker ${e.node.kind} ${s??""} ${t?"selected":""}`,children:[e.node.kind==="end"&&n.jsx(Qr,{type:"target",position:tt.Left}),n.jsx("span",{children:nl[e.node.kind]}),e.node.kind==="end"&&s!==void 0&&s!=="pending"&&n.jsx("span",{className:`step-state ${s}`,children:((r=e.state)==null?void 0:r.detail)??kg[s]}),e.node.kind==="start"&&n.jsx(Qr,{type:"source",position:tt.Right})]}):n.jsxs("div",{className:`step-node ${s??""} ${t?"selected":""} ${e.issue!==void 0?"has-issue":""}`,children:[n.jsx(Qr,{type:"target",position:tt.Left}),n.jsxs("div",{className:"step-kind",children:[n.jsx("span",{children:nl[e.node.kind]}),e.input!==""&&n.jsx("span",{className:"badge",children:e.input}),e.node.waitForAll===!0&&n.jsx("span",{className:"badge",title:"等前面的节点全部结束再开始",children:"等全部"}),s!==void 0&&n.jsxs("span",{className:`step-state ${s}`,children:[kg[s],(((o=e.state)==null?void 0:o.attempts)??0)>1?` · 第 ${e.state.attempts} 次`:""]})]}),n.jsx("div",{className:"step-title",children:e.label}),e.sub!==""&&n.jsx("div",{className:"step-sub",children:e.sub}),((l=e.state)==null?void 0:l.detail)!==void 0&&e.state.detail!==""&&n.jsx("div",{className:"step-detail",children:e.state.detail}),e.issue!==void 0&&e.state===void 0&&n.jsx("div",{className:"step-detail issue",children:e.issue}),n.jsx(Qr,{type:"source",position:tt.Right})]})}const g8={step:p8};function x8(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 v8=0;const ko=(e,t,s=new Set)=>{for(;;){const i=`${e}${++v8}`;if(!s.has(i)&&!t.nodes.some(r=>r.id===i))return i}};function y8(e,t){return e.nodes.every(s=>s.position!==void 0)?e:{...e,nodes:e.nodes.map(s=>s.position!==void 0||!t.has(s.id)?s:{...s,position:t.get(s.id)})}}let Br=null;const b8=e=>e instanceof HTMLElement&&e.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]')!==null;function k8({client:e,pipeline:t,onChange:s,run:i,check:r,runFrom:o,idle:l}){var G,K;const u=u1(),[d,h]=v.useState(0),m=m8(e,d),[p,g]=v.useState([]),x=p.length===1?p[0]:null,k=Z=>g(Z===null?[]:[Z]),[b,j]=v.useState(null),w=v.useRef(null),[S,_]=v.useState({}),E=v.useCallback(Z=>{var Y,Q;if(Z.kind==="script-task"){const ie=m.find(Ee=>Ee.scriptId===Z.scriptId),re=ie==null?void 0:ie.tasks.find(Ee=>Ee.id===Z.taskId),ne=Object.entries(Z.params).map(([Ee,Ue])=>`${Ee}=${String(Ue)}`).join(" "),fe=Z.profile===void 0?void 0:((Q=(Y=ie==null?void 0:ie.profiles)==null?void 0:Y.items.find(Ee=>Ee.id===Z.profile))==null?void 0:Q.name)??"已删除的配置";return{label:Z.title??`${(ie==null?void 0:ie.scriptName)??Z.scriptId} · ${(re==null?void 0:re.title)??Z.taskId}`,sub:[fe===void 0?"":`配置:${fe}`,ne].filter(Boolean).join(" · "),input:up[(re==null?void 0:re.input)??"none"]??""}}return Z.kind==="wait"?{label:Z.title??(Z.minutes!==void 0?`等 ${Z.minutes} 分钟`:`等到 ${Z.until}`),sub:"",input:""}:Z.kind==="agent"?{label:Z.title??"agent 步骤",sub:Z.prompt.slice(0,40),input:""}:Wi(Z)?{label:nl[Z.kind],sub:"",input:""}:{label:Z.title??nl[Z.kind],sub:Z.text.slice(0,40),input:""}},[m]),M=v.useMemo(()=>x8(t),[t]),O=v.useMemo(()=>t.nodes.map(Z=>{var Y;return{id:Z.id,type:"step",position:M.get(Z.id),selected:p.includes(Z.id),...S[Z.id]===void 0?{}:{measured:S[Z.id]},data:{node:Z,...E(Z),state:i==null?void 0:i.nodes[Z.id],issue:(Y=r==null?void 0:r.issues.find(Q=>Q.nodeId===Z.id&&Q.level==="error"))==null?void 0:Y.message}}}),[t,M,E,i,r,p,S]),B=v.useMemo(()=>t.edges.map((Z,Y)=>{var Q;return{id:`e${Y}`,source:Z.from,target:Z.to,label:f8[Z.when],selected:Y===b,animated:((Q=i==null?void 0:i.nodes[Z.from])==null?void 0:Q.state)==="running",className:`edge-${Z.when}`}}),[t.edges,b,i]),U=v.useRef({past:[],future:[],at:0}),P=v.useCallback((Z,Y)=>{const Q=U.current,ie=Date.now();(Y===void 0||Y!==Q.group||ie-Q.at>1e3)&&(Q.past=[...Q.past.slice(-99),{nodes:t.nodes,edges:t.edges}]),Q.future=[],Q.group=Y,Q.at=ie,s(y8(Z,M))},[t,M,s]),R=Z=>{const Y=U.current,Q=Z==="past"?"future":"past",ie=Y[Z].pop();ie!==void 0&&(Y[Q].push({nodes:t.nodes,edges:t.edges}),Y.group=void 0,s({...t,...ie}),g(re=>re.filter(ne=>ie.nodes.some(fe=>fe.id===ne))),j(null))},z=v.useCallback(Z=>{let Y=t,Q;const ie={},re=new Map;for(const ne of Z)if(ne.type==="dimensions"&&ne.dimensions!==void 0)ie[ne.id]=ne.dimensions;else if(ne.type==="select")re.set(ne.id,ne.selected);else if(ne.type==="position"&&ne.position!==void 0)Y={...Y,nodes:Y.nodes.map(fe=>fe.id===ne.id?{...fe,position:{x:Math.round(ne.position.x),y:Math.round(ne.position.y)}}:fe)},Q="move";else if(ne.type==="remove"){if(Y.nodes.some(fe=>fe.id===ne.id&&Wi(fe)))continue;Y={...Y,nodes:Y.nodes.filter(fe=>fe.id!==ne.id),edges:Y.edges.filter(fe=>fe.from!==ne.id&&fe.to!==ne.id)},re.set(ne.id,!1),Q=void 0}Object.keys(ie).length>0&&_(ne=>({...ne,...ie})),re.size>0&&(g(ne=>[...ne.filter(fe=>re.get(fe)!==!1),...[...re].filter(([fe,Ee])=>Ee&&!ne.includes(fe)).map(([fe])=>fe)]),[...re.values()].some(Boolean)&&j(null)),Y!==t&&P(Y,Q)},[t,P]),L=v.useCallback(Z=>{var Q;if(Z.source===Z.target||t.edges.some(ie=>ie.from===Z.source&&ie.to===Z.target))return;const Y=t.nodes.find(ie=>ie.id===Z.target);(Y==null?void 0:Y.kind)==="start"||((Q=t.nodes.find(ie=>ie.id===Z.source))==null?void 0:Q.kind)==="end"||P({...t,edges:[...t.edges,{from:Z.source,to:Z.target,when:(Y==null?void 0:Y.kind)==="end"?"always":"success"}]})},[t,P]),A=()=>{const Z=t.nodes.filter(Q=>p.includes(Q.id)&&!Wi(Q));if(Z.length===0)return!1;const Y=new Set(Z.map(Q=>Q.id));return Br={nodes:Z.map(Q=>({...Q,position:M.get(Q.id)??{x:40,y:40}})),edges:t.edges.filter(Q=>Y.has(Q.from)&&Y.has(Q.to)),pasted:0},!0},T=()=>{if(Br===null||t.nodes.length+Br.nodes.length>60)return;const Z=++Br.pasted,Y=new Map;for(const re of Br.nodes)Y.set(re.id,ko(re.id.replace(/\d+$/,"")||"step",t,new Set(Y.values())));const Q=Br.nodes.map(re=>{var ne,fe;return{...re,id:Y.get(re.id),position:{x:(((ne=re.position)==null?void 0:ne.x)??40)+40*Z,y:(((fe=re.position)==null?void 0:fe.y)??40)+120*Z}}}),ie=Br.edges.map(re=>({...re,from:Y.get(re.from),to:Y.get(re.to)}));P({...t,nodes:[...t.nodes,...Q],edges:[...t.edges,...ie]}),g(Q.map(re=>re.id)),j(null)},H=()=>{const Z=new Set(t.nodes.filter(Y=>p.includes(Y.id)&&!Wi(Y)).map(Y=>Y.id));Z.size!==0&&(P({...t,nodes:t.nodes.filter(Y=>!Z.has(Y.id)),edges:t.edges.filter(Y=>!Z.has(Y.from)&&!Z.has(Y.to))}),g([]))},F=v.useRef(()=>{});F.current=Z=>{var Q;if(!(Z.ctrlKey||Z.metaKey)||Z.altKey||b8(Z.target)||w.current===null||w.current.offsetParent===null)return;const Y=Z.key.toLowerCase();Y==="z"&&!Z.shiftKey?(Z.preventDefault(),R("past")):Y==="y"||Y==="z"&&Z.shiftKey?(Z.preventDefault(),R("future")):Y==="c"?(((Q=window.getSelection())==null?void 0:Q.toString())??"")===""&&A()&&Z.preventDefault():Y==="v"&&Br!==null&&(Z.preventDefault(),T())},v.useEffect(()=>{const Z=Y=>F.current(Y);return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[]);const V=Z=>{const Y=t.nodes.find(Te=>Te.kind==="start"),Q=t.nodes.find(Te=>Te.kind==="end"),ie=t.nodes.find(Te=>Te.id===x&&Te.kind!=="end")??Y,re=ie===void 0?void 0:M.get(ie.id),ne=[...M.entries()].filter(([Te])=>Te!==(Q==null?void 0:Q.id)).map(([,Te])=>Te),fe=re===void 0?Math.max(0,...ne.map(Te=>Te.x))+280:re.x+280;let Ee=(re==null?void 0:re.y)??40;for(;ne.some(Te=>Math.abs(Te.x-fe)<200&&Math.abs(Te.y-Ee)<100);)Ee+=130;const Ue=[...t.nodes.map(Te=>{var pe,be;return Te.kind==="end"?{...Te,position:{x:Math.max(((pe=M.get(Te.id))==null?void 0:pe.x)??0,fe+300),y:((be=M.get(Te.id))==null?void 0:be.y)??Ee}}:Te}),{...Z,position:{x:fe,y:Ee}}];P({...t,nodes:Ue}),k(Z.id),j(null)},D=t.nodes.find(Z=>Z.id===x),q=b===null?void 0:t.edges[b],te=Z=>P({...t,nodes:t.nodes.map(Y=>Y.id===Z.id?Z:Y)},`node:${Z.id}`);return n.jsxs("div",{className:"pipeline-editor",ref:w,children:[n.jsxs("div",{className:"pipeline-palette","aria-label":"节点",children:[n.jsx("div",{className:"sidebar-label",children:"脚本任务"}),m.length===0&&n.jsx("div",{className:"muted small pad",children:"脚本库里还没有带脚本包的脚本"}),m.map(Z=>n.jsxs("details",{className:"palette-group",open:m.length<=3,children:[n.jsx("summary",{children:Z.scriptName}),Z.tasks.map(Y=>n.jsxs("button",{className:"palette-item",title:Y.description??Y.title,onClick:()=>V({id:ko(Z.scriptId.replace(/[^A-Za-z0-9_-]/g,"").slice(0,20)||"task",t),kind:"script-task",scriptId:Z.scriptId,taskId:Y.id,params:{}}),children:[n.jsx("span",{children:Y.title}),up[Y.input]!==""&&n.jsx("span",{className:"badge",children:up[Y.input]})]},Y.id))]},Z.scriptId)),n.jsx("div",{className:"sidebar-label pack-label",children:"其他步骤"}),n.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("agent",t),kind:"agent",prompt:"检查活动还剩几天,快结束的提醒我"}),children:"agent 步骤"}),n.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("wait",t),kind:"wait",minutes:10}),children:"控制节点"}),n.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("notify",t),kind:"notify",text:`${t.name}跑完了`}),children:"发消息"}),n.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("gate",t),kind:"gate",text:"确认后继续"}),children:"人工确认"}),n.jsx("p",{className:"muted small pad",children:"从节点右边的圆点拖到另一个节点左边,表示「这个完成后再运行那个」。没有连线的节点会同时开始;需要同一资源的会自动排队。"})]}),n.jsxs("div",{className:"pipeline-canvas",children:[n.jsxs(z9,{nodes:O,edges:B,nodeTypes:g8,onNodesChange:z,onConnect:L,onNodeClick:()=>j(null),onEdgeClick:(Z,Y)=>{j(Number(Y.id.slice(1))),k(null)},onPaneClick:()=>{k(null),j(null)},deleteKeyCode:["Delete","Backspace"],colorMode:u,fitView:!0,fitViewOptions:{maxZoom:1,padding:.2},proOptions:{hideAttribution:!0},children:[n.jsx(H9,{gap:20}),n.jsx(Y9,{showInteractive:!1})]}),!t.nodes.some(Z=>!Wi(Z))&&n.jsx("div",{className:"canvas-hint",children:"从左边点一个任务加到画布上,再从节点右边的圆点拖到下一个节点,连成先后顺序"})]}),n.jsxs("aside",{className:"pipeline-inspector",children:[D!==void 0&&n.jsx(N8,{client:e,node:D,pipeline:t,run:i,scripts:m,onChange:te,onTasksChanged:()=>h(Z=>Z+1),runFrom:o,onRemove:H}),q!==void 0&&n.jsxs("section",{className:"inspector-section",children:[n.jsx("h4",{children:"连线"}),n.jsxs("p",{className:"muted small",children:["「",((G=t.nodes.find(Z=>Z.id===q.from))==null?void 0:G.title)??q.from,"」→「",((K=t.nodes.find(Z=>Z.id===q.to))==null?void 0:K.title)??q.to,"」"]}),n.jsx("label",{className:"field-label",htmlFor:"edge-when",children:"什么时候运行下一步"}),n.jsx(Mt,{id:"edge-when",value:q.when,onChange:Z=>P({...t,edges:t.edges.map((Y,Q)=>Q===b?{...Y,when:Z}:Y)}),options:[{value:"success",label:"上一步成功后"},{value:"failure",label:"上一步失败后"},{value:"always",label:"上一步结束后",hint:"不管成败"}]}),n.jsx("button",{className:"danger-outline small-button",onClick:()=>{P({...t,edges:t.edges.filter((Z,Y)=>Y!==b)}),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:H,children:"删除这些节点"})]}),D===void 0&&q===void 0&&p.length<=1&&(l??n.jsx("p",{className:"muted small pad",children:"点一个节点或连线来修改。选中后按 Delete 也能删除,Ctrl+C / Ctrl+V 复制粘贴,Ctrl+Z 撤销。"})),(D!==void 0||q!==void 0||p.length>1)&&l!==void 0&&n.jsx("button",{className:"link-button small back-to-pipeline",onClick:()=>{k(null),j(null)},children:"← 流水线设置"})]})]})}function j8({client:e,value:t,onChange:s}){const i=v.useRef(null),r=vS({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 N8({client:e,node:t,pipeline:s,run:i,scripts:r,onChange:o,onRemove:l,onTasksChanged:u,runFrom:d}){var k,b;const[h,m]=v.useState(null),p=i==null?void 0:i.nodes[t.id],g=t.kind==="script-task"?(k=r.find(j=>j.scriptId===t.scriptId))==null?void 0:k.tasks.find(j=>j.id===t.taskId):void 0,x=t.onFailure;return Wi(t)?n.jsxs("section",{className:"inspector-section",children:[n.jsx("h4",{children:nl[t.kind]}),n.jsx("p",{className:"muted small",children:t.kind==="start"?"流水线从这里开始。从它连出去的步骤最先运行(没有连线的步骤也会一开始就运行)。":"所有步骤都结束后到这里,不管成败;连到它的线只是为了看得清楚。"}),(p==null?void 0:p.detail)!==void 0&&n.jsx("div",{className:"muted small",children:p.detail})]}):n.jsxs("section",{className:"inspector-section",children:[n.jsx("h4",{children:nl[t.kind]}),n.jsx("label",{className:"field-label",htmlFor:"node-title",children:"名称(可选)"}),n.jsx("input",{id:"node-title",className:"text-input plain",value:t.title??"",maxLength:60,onChange:j=>{const{title:w,...S}=t;o(j.target.value===""?S:{...S,title:j.target.value})}}),t.kind==="script-task"&&n.jsx(p1,{id:"node-profile",label:"用哪份配置",list:((b=r.find(j=>j.scriptId===t.scriptId))==null?void 0:b.profiles)??null,value:t.profile,onChange:j=>{const{profile:w,...S}=t;o(j===void 0?S:{...S,profile:j})}}),t.kind==="script-task"&&g!==void 0&&Object.entries(g.params).map(([j,w])=>n.jsx(m1,{client:e,scriptId:t.scriptId,taskId:t.taskId,name:j,spec:w,profile:t.profile,value:String(t.params[j]??(w.type==="boolean"?w.default??!1:"")),onCreated:u,onChange:S=>{const{[j]:_,...E}=t.params,M=w.type==="boolean"?S==="true":w.type==="integer"||w.type==="number"?Number(S):S;o({...t,params:S===""?E:{...E,[j]:M}})}},j)),t.kind==="agent"&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:"node-prompt",children:"让 agent 做什么"}),n.jsx(j8,{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(Mt,{"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:w,...S}=t;o(j.target.checked?{...S,waitForAll:!0}:S)}}),"等前面的节点全部结束再开始"]}),n.jsx("p",{className:"muted small",children:"不只等连进来的线:画布上不在它后面的节点(其他分支也算)都结束了(成功、失败、跳过都算)才开始。用来让并行的几条分支汇合。"}),t.kind!=="gate"&&t.kind!=="notify"&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:"node-retries",children:"失败时"}),n.jsxs("div",{className:"select-stack",children:[n.jsx(Mt,{id:"node-retries","aria-label":"重试次数",value:x===void 0?"inherit":String(x.retries),options:[{value:"inherit",label:"按流水线的设置"},...aE],onChange:j=>{const{onFailure:w,...S}=t;if(j==="inherit")return o(S);o({...S,onFailure:{retries:Number(j),then:(x==null?void 0:x.then)??s.onFailure.then}})}}),n.jsx(Mt,{"aria-label":"仍失败时",disabled:x===void 0,value:(x??s.onFailure).then,options:oE,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:[kg[p.state],p.attempts>1?` · 第 ${p.attempts} 次`:""]}),p.detail!==void 0&&n.jsx("div",{className:"muted small",children:p.detail}),p.repair&&n.jsxs("div",{className:"small",children:["后续补偿",p.repair.state==="succeeded"?"成功":"未成功"," · ",p.repair.runId]}),p.runIds.length>0&&n.jsxs("div",{className:"muted small",children:["脚本运行:",p.runIds.join("、"),"(在「运行」页看日志)"]}),t.kind==="gate"&&p.state==="running"&&i!==void 0&&n.jsxs("div",{className:"key-actions",children:[n.jsx("button",{className:"primary small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:i.id,nodeId:t.id,decision:"continue"}).catch(j=>m(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=>m(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 Xd={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]},w8=()=>({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"}),S8=(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")},lE="adg.pipelines.last",_8=()=>{try{return localStorage.getItem(lE)}catch{return null}},E8=e=>{try{localStorage.setItem(lE,e)}catch{}};function C8({client:e,openSettings:t,arg:s}){const i=Se(e.connection.status),r=vn(3e4),[o,l]=v.useState(null),[u,d]=v.useState(null),[h,m]=v.useState(null),[p,g]=v.useState(""),[x,k]=v.useState([]),[b,j]=v.useState(null),[w,S]=v.useState(null),[_,E]=v.useState(null),[M,O]=v.useState(null),[B,U]=v.useState(0);v.useEffect(()=>e.connection.on("pipelines/changed",()=>U(ie=>ie+1)),[e]);const P=Se(e.capabilities),[R,z]=v.useState(null),[L,A]=v.useState(0);v.useEffect(()=>e.connection.on("schedule/changed",()=>A(ie=>ie+1)),[e]),v.useEffect(()=>{if(i.state!=="open"||!P.has("schedule"))return;let ie=!0;return e.connection.call("schedule/status",{}).then(re=>{ie&&z(re.settings)}).catch(()=>{}),()=>{ie=!1}},[e,i.state,P,L]);const T=async ie=>{try{z((await e.connection.call("schedule/settings/set",ie)).settings)}catch(re){O(Ce(re))}};v.useEffect(()=>{s!==void 0&&d(s)},[s]),v.useEffect(()=>{if(i.state!=="open")return;let ie=!0;return e.connection.call("pipelines/list",{}).then(re=>{if(!ie)return;const ne=[...re.items].sort(S8);l(ne);const fe=_8();d(Ee=>{var Ue,Te;return Ee??((Ue=ne.find(pe=>pe.id===fe))==null?void 0:Ue.id)??((Te=ne[0])==null?void 0:Te.id)??null})}).catch(re=>{ie&&O(Ce(re))}),()=>{ie=!1}},[e,i.state,B]),v.useEffect(()=>{if(u===null||i.state!=="open"||(h==null?void 0:h.id)===u&&(o!=null&&o.every(re=>re.id!==u)))return;let ie=!0;return e.connection.call("pipelines/get",{id:u}).then(re=>{if(!ie)return;const ne=HR(re);E8(ne.id),m(ne),g(JSON.stringify(ne)),S(null)}).catch(()=>{}),e.connection.call("pipelines/runs",{pipelineId:u,limit:10}).then(re=>{ie&&k(re.items)}).catch(()=>{}),j(null),()=>{ie=!1}},[e,u,i.state,B]),v.useEffect(()=>e.connection.on("pipelines/run",ie=>{ie.pipelineId===u&&k(re=>[ie,...re.filter(ne=>ne.id!==ie.id)].sort((ne,fe)=>fe.startedAt-ne.startedAt).slice(0,10))}),[e,u]);const H=h!==null&&JSON.stringify(h)!==p,F=h!==null&&o!==null&&o.every(ie=>ie.id!==h.id),V=x.find(ie=>{var re;return ie.id===(b??((re=x[0])==null?void 0:re.id))}),D=x.find(ie=>ie.state==="running"),q=D!==void 0&&(D.stopping!==void 0||_==="cancel");v.useEffect(()=>{if(h===null||!h.nodes.some(re=>!Wi(re))){S(null);return}const ie=setTimeout(()=>{e.connection.call("pipelines/check",{pipeline:h}).then(S).catch(()=>{})},400);return()=>clearTimeout(ie)},[e,h]);const te=async(ie,re)=>{E(ie),O(null);try{await re()}catch(ne){O(Ce(ne))}finally{E(null)}},G=()=>te("save",async()=>{if(h===null)return;const ie=await e.connection.call("pipelines/save",{pipeline:h});m(ie.pipeline),g(JSON.stringify(ie.pipeline)),S(ie.check),d(ie.pipeline.id)}),K=ie=>te("run",async()=>{if(h===null)return;(H||F)&&await G();const re=await e.connection.call("pipelines/run",{id:h.id,...ie===void 0?{}:{from:ie}});j(re.id)}),Z=()=>te("remove",async()=>{h!==null&&(F||await e.connection.call("pipelines/remove",{id:h.id}),m(null),d(null))}),Y=v.useCallback(ie=>m(ie),[]),Q=()=>{const ie=w8();m(ie),g(""),d(ie.id),k([]),S(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(I8,{list:o??[],current:h,isNew:F,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:Q,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:ie=>m({...h,name:ie.target.value})}),h.draft===!0&&n.jsx("span",{className:"badge warn",title:"agent 生成的草稿:保存后才会按定时运行",children:"agent 草稿"}),H&&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}),"正在停止…"]}):D!==void 0?n.jsx("button",{className:"danger-outline small-button",disabled:_!==null,onClick:()=>void te("cancel",()=>e.connection.call("pipelines/cancel",{runId:D.id})),children:"取消运行"}):n.jsxs("button",{className:"small-button",disabled:_!==null||!h.nodes.some(ie=>!Wi(ie))||(w==null?void 0:w.ok)===!1,onClick:()=>void K(),children:[n.jsx(ee,{name:"arrow"}),"运行"]}),n.jsx("button",{className:"primary small-button",disabled:_!==null||!H&&!F&&h.draft!==!0,onClick:()=>void G(),children:_==="save"?"保存中…":h.draft===!0&&!H?"确认并保存":"保存"}),n.jsx("button",{className:"small-button",disabled:_!==null||D!==void 0,onClick:()=>void Ms({title:`删除流水线「${h.name}」?`,message:"它的步骤和定时都会删掉,不能撤销。",confirmLabel:"删除",danger:!0}).then(ie=>{ie&&Z()}),children:"删除"})]}),q&&n.jsxs("div",{className:"notice info left small pipeline-stopping",role:"status",children:[n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),n.jsxs("span",{children:["已收到停止指令。",D.stopping??"正在通知正在运行的步骤…"]})]}),M!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:M})]}),n.jsx(k8,{client:e,pipeline:h,onChange:Y,run:V,check:w,runFrom:D!==void 0||_!==null||(w==null?void 0:w.ok)===!1?void 0:ie=>void K(ie),idle:n.jsx(T8,{pipeline:h,check:w,runs:x,shownRun:V==null?void 0:V.id,onShowRun:j,others:o??[],onChange:Y,now:r,startup:R,onStartup:ie=>void T(ie)})},h.id)]})})]})}function A8({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 $8({runs:e,shown:t,onShow:s,now:i}){if(e.length===0)return n.jsx("section",{className:"side-pane",children:n.jsx("p",{className:"muted small",children:"还没有运行过。"})});const r={manual:"手动",schedule:"定时",autostart:"启动时",agent:"agent",after:"接续"};return n.jsxs("section",{className:"side-pane",children:[n.jsx("div",{className:"run-history",children:e.map(o=>n.jsxs("button",{className:`run-row ${o.id===t?"active":""}`,onClick:()=>s(o.id),children:[n.jsx("span",{className:`badge ${Xd[o.state][0]}`,children:Xd[o.state][1]}),n.jsx("span",{className:"run-title",children:r[o.trigger.kind]??o.trigger.kind}),n.jsx("span",{className:"muted small run-outcome",children:o.outcome??"…"}),n.jsx("span",{className:"session-time",children:vt(o.startedAt,i)})]},o.id))}),n.jsx("p",{className:"muted small",children:"选中一次运行,画布上的节点会显示它的状态;点节点看详情和对应的脚本运行。"})]})}function I8({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?"":` · ${vt(d.lastRun.startedAt,i)}`]})]}),d.draft?n.jsx("span",{className:"badge warn",children:"草稿"}):d.lastRun!==void 0?n.jsx("span",{className:`badge ${Xd[d.lastRun.state][0]}`,children:Xd[d.lastRun.state][1]}):null]},d.id)),e.length===0&&n.jsx("div",{className:"muted small pad",children:"还没有保存的流水线"})]})]})}function T8({pipeline:e,check:t,runs:s,shownRun:i,onShowRun:r,others:o,onChange:l,now:u,startup:d,onStartup:h}){const[m,p]=v.useState(s.some(x=>x.state==="running")?"runs":"check"),g=(t==null?void 0:t.issues.filter(x=>x.level==="error").length)??0;return n.jsxs("div",{className:"pipeline-side",children:[n.jsxs("nav",{className:"tabs side-tabs",role:"tablist","aria-label":"流水线",children:[n.jsxs("button",{role:"tab","aria-selected":m==="check",className:m==="check"?"active":"",onClick:()=>p("check"),children:["检查",g>0?` · ${g}`:""]}),n.jsx("button",{role:"tab","aria-selected":m==="runs",className:m==="runs"?"active":"",onClick:()=>p("runs"),children:"运行记录"}),n.jsx("button",{role:"tab","aria-selected":m==="schedule",className:m==="schedule"?"active":"",onClick:()=>p("schedule"),children:"定时与失败"})]}),m==="check"&&(t===null?n.jsx("p",{className:"muted small pad",children:"加上步骤后会自动检查。"}):n.jsx(A8,{check:t,pipeline:e})),m==="runs"&&n.jsx($8,{runs:s,shown:i,onShow:r,now:u}),m==="schedule"&&n.jsx(R8,{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=["日","一","二","三","四","五","六"],Uj={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function R8({pipeline:e,others:t,onChange:s,startup:i,onStartup:r}){const o=(i==null?void 0:i.autostartPipelines.includes(e.id))===!0,l=e.schedule,[u,d]=v.useState(l.times.join(","));v.useEffect(()=>d(l.times.join(",")),[e.id]);const h=g=>s({...e,schedule:{...l,...g}}),m=v.useMemo(()=>u.split(/[,,\s]+/).map(g=>g.trim()).filter(Boolean).map(g=>/^\d:\d\d$/.test(g)?`0${g}`:g),[u]),p=m.filter(g=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(g));return n.jsxs("section",{className:"side-pane",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:l.enabled,onChange:g=>h({enabled:g.target.checked})}),"按定时自动运行",e.draft===!0?"(草稿要先保存)":""]}),n.jsx("label",{className:"field-label",htmlFor:"pl-times",children:"时间(24 小时制,多个用逗号分开)"}),n.jsx("input",{id:"pl-times",className:"text-input",value:u,placeholder:"04:30,16:30",onChange:g=>d(g.target.value),onBlur:()=>{p.length===0&&h({times:[...new Set(m)].sort()})}}),p.length>0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(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(k=>k!==x):[...l.days,x].sort()}),children:["周",g]},g)),n.jsx("span",{className:"muted small",children:l.days.length===0?"不选=每天":""})]}),i!==null&&n.jsxs("div",{className:"startup-box",children:[n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:o,disabled:e.draft===!0,onChange:g=>r({autostartPipelines:g.target.checked?[...i.autostartPipelines,e.id]:i.autostartPipelines.filter(x=>x!==e.id)})}),"软件启动时运行",e.draft===!0?"(草稿要先保存)":""]}),o&&n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"check-label sub",children:[n.jsx("input",{type:"checkbox",checked:i.firstStartOnly,onChange:g=>r({firstStartOnly:g.target.checked})}),"只在每天第一次启动时运行(每天从 4:00 算起)"]}),n.jsxs("label",{className:"check-label sub",children:[n.jsx("input",{type:"checkbox",checked:i.skipIfRanToday,onChange:g=>r({skipIfRanToday:g.target.checked})}),"今天(4:00 起)已经成功运行过就跳过"]}),n.jsxs("p",{className:"muted small",children:["打开桌面版(自己打开或开机自启)后",i.autostart?`开机自启时等 ${i.autostartDelaySeconds} 秒、自己打开时等 10 秒`:"等 10 秒","再运行;dsh 崩溃后自动重启不算。和游戏一样,每天从 4:00 算起:凌晨 2 点启动还算前一天。这两项对所有「软件启动时运行」的流水线生效。"]})]})]}),n.jsx("label",{className:"field-label",htmlFor:"pl-catchup",children:"错过多少分钟以内还补跑(睡眠、刚开机)"}),n.jsx("input",{id:"pl-catchup",className:"text-input plain",type:"number",min:0,max:720,value:l.catchUpMinutes,onChange:g=>h({catchUpMinutes:Math.max(0,Math.min(720,Math.round(Number(g.target.value)||0)))})}),n.jsx("label",{className:"field-label",htmlFor:"pl-after",children:"另一条流水线成功后接着运行"}),n.jsx(Mt,{id:"pl-after",value:l.after??"",onChange:g=>{const{after:x,...k}=l;s({...e,schedule:g===""?k:{...k,after:g}})},options:[{value:"",label:"不接续"},...t.filter(g=>g.id!==e.id).map(g=>({value:g.id,label:g.name}))]}),n.jsx("label",{className:"field-label",htmlFor:"pl-fail",children:"节点失败时(节点自己没设置时)"}),n.jsxs("div",{className:"select-stack",children:[n.jsx(Mt,{id:"pl-fail","aria-label":"重试次数",value:String(e.onFailure.retries),options:aE,onChange:g=>s({...e,onFailure:{...e.onFailure,retries:Number(g)}})}),n.jsx(Mt,{"aria-label":"仍失败时",value:e.onFailure.then,options:oE,onChange:g=>s({...e,onFailure:{...e.onFailure,then:g}})})]}),n.jsx("div",{className:"field-label",children:"结束后"}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:e.closeGameAfter,onChange:g=>s({...e,closeGameAfter:g.target.checked})}),"关闭游戏(任务玩过的电脑游戏和模拟器里的游戏)"]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:e.stopEmulatorAfter,onChange:g=>s({...e,stopEmulatorAfter:g.target.checked})}),"关闭模拟器"]}),n.jsx("label",{className:"field-label",htmlFor:"pl-power",children:"然后电脑"}),n.jsx(Mt,{id:"pl-power",value:e.powerAfter,onChange:g=>s({...e,powerAfter:g}),options:[{value:"none",label:"保持开着"},{value:"sleep",label:"睡眠"},{value:"hibernate",label:"休眠",hint:"断电也不丢失进度,唤醒比睡眠慢"},{value:"shutdown",label:"关机"}]}),e.powerAfter!=="none"&&n.jsxs("p",{className:"muted small",children:["等其他任务都结束后先倒计时",i===null?"":` ${i.powerCountdownSeconds} 秒`,",界面和飞书里都可以取消;15 分钟内还有定时任务就不",Uj[e.powerAfter],"。在这里手动点运行、或运行被取消时不会",Uj[e.powerAfter],"。",e.powerAfter==="shutdown"?"关机会强制关闭所有程序。":"想让电脑按时醒来跑定时任务,在「设置 → 定时与自启」打开定时唤醒。"]})]})}const Bj=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"}),Hj={fired:["ok","已运行"],missed:["warn","错过"],skipped:["","跳过"],failed:["warn","没能运行"]};function O8({client:e}){const t=Se(e.connection.status),s=vn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(0),[u,d]=v.useState(!1),[h,m]=v.useState(null);v.useEffect(()=>e.connection.on("schedule/changed",()=>l(x=>x+1)),[e]),v.useEffect(()=>e.connection.on("pipelines/changed",()=>l(x=>x+1)),[e]),v.useEffect(()=>e.connection.on("schedule/power",x=>r(k=>k===null?k:{...k,power:x})),[e]),v.useEffect(()=>{if(t.state!=="open")return;let x=!0;return e.connection.call("schedule/status",{}).then(k=>{x&&r(k)}).catch(k=>{x&&m(Ce(k))}),()=>{x=!1}},[e,t.state,o]);const p=async x=>{d(!0),m(null);try{r(await e.connection.call("schedule/settings/set",x))}catch(k){m(Ce(k))}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 任务计划程序中注册,下次在 ${Bj(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,k)=>n.jsxs("li",{children:[n.jsx("span",{className:"version-name",children:Bj(x.at)}),n.jsx("span",{children:x.pipelineName})]},k))})]}),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,k)=>{var b,j;return n.jsxs("li",{children:[n.jsx("span",{className:`badge ${((b=Hj[x.outcome])==null?void 0:b[0])??""}`,children:((j=Hj[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:vt(x.at,s)})]},k)})})]}),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 P8={id:"pipelines",title:"编排",milestone:"M4",requires:["pipelines","scripts","runs"],pages:[{id:"pipelines",title:"编排",icon:"flow",order:20,agent:"pipelines",component:C8}]},L8={id:"schedule",title:"定时与自启",milestone:"M4",requires:["schedule","pipelines"],settingsPages:[{id:"schedule",title:"定时与自启",order:9,component:O8}]},Ca=new Map;let jg=0;const Ng=new Set;function z8(e,t){let s=Ca.get(e);if(s===void 0){s=t().then(r=>r.icon===void 0?null:`data:${r.icon.mediaType};base64,${r.icon.data}`);const i=s;s.then(r=>{r===null&&Ca.get(e)===i&&Ca.delete(e)},()=>{Ca.get(e)===i&&Ca.delete(e)}),Ca.set(e,s)}return s}function wg(){Ca.clear(),jg++;for(const e of Ng)e()}const dp=new Map;function D8(e){let t=dp.get(e);if(t===void 0){const i=["games/changed","scripts/changed","packs/changed"].map(r=>e.connection.on(r,wg));t={count:0,off:()=>{for(const r of i)r()}},dp.set(e,t)}t.count++;const s=t;return()=>{--s.count===0&&(s.off(),dp.delete(e))}}function cE({client:e,iconKey:t,load:s,name:i,className:r=""}){const o=Se(e.connection.status),[l,u]=v.useState(null),[d,h]=v.useState(jg);return v.useEffect(()=>{const m=()=>h(jg);return Ng.add(m),()=>{Ng.delete(m)}},[]),v.useEffect(()=>D8(e),[e]),v.useEffect(()=>{if(o.state!=="open")return;let m=!0;return z8(t,s).then(p=>{m&&u(p)},()=>{}),()=>{m=!1}},[t,o.state,d]),n.jsx("span",{className:`program-avatar${l===null?"":" with-icon"} ${r}`,children:l===null?[...i][0]??"?":n.jsx("img",{src:l,alt:"",draggable:!1,onError:()=>u(null)})})}function F8({client:e,game:t,className:s=""}){return n.jsx(cE,{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 U8=864e5;function B8({client:e,openSession:t,openPage:s,arg:i}){const r=Se(e.connection.status),o=vn(3e4),[l,u]=v.useState(null),[d,h]=v.useState(0),[m,p]=v.useState(i??""),[g,x]=v.useState(null),[k,b]=v.useState(null),[j,w]=v.useState(null),[S,_]=v.useState(!1),[E,M]=v.useState(null),O=v.useCallback(()=>M(null),[]),B=v.useCallback(()=>_(!1),[]);v.useEffect(()=>{i!==void 0&&p(i)},[i]),v.useEffect(()=>e.connection.on("games/changed",()=>h(Z=>Z+1)),[e]),v.useEffect(()=>{if(r.state!=="open")return;let Z=!0;return e.connection.call("games/list",{}).then(Y=>{Z&&u(Y)}).catch(Y=>{Z&&b(Ce(Y))}),()=>{Z=!1}},[e,r.state,d]);const U=(l==null?void 0:l.games)??[],P=M3(U,Xr),R=U.find(Z=>Z.id===m),z=R===void 0,L=Z=>{p(Z),M(null),w(null),b(null)},A=async(Z,Y)=>{x(Z),b(null),w(null);try{const Q=await Y();typeof Q=="string"&&w(Q)}catch(Q){b(Ce(Q))}finally{x(null),h(Q=>Q+1)}},T=Z=>A(`refresh:${Z??""}`,async()=>{const{results:Y}=await e.connection.call("games/refresh",Z===void 0?{}:{game:Z}),Q=ne=>{var fe;return((fe=U.find(Ee=>Ee.id===ne))==null?void 0:fe.name)??ne},ie=ne=>{var fe;return((fe=U.find(Ee=>Ee.id===ne))==null?void 0:fe.sources.some(Ee=>Ee.auto))===!0},re=Y.filter(ne=>ie(ne.game)&&!ne.ok);if(re.length>0)throw new Error(re.map(ne=>`${Q(ne.game)}没读到:${ne.detail??"未知原因"}`).join(";"));return Z===void 0?`刷新完成:${Y.filter(ne=>ie(ne.game)).map(ne=>`${Q(ne.game)} ${[...ne.count>0||ne.notices===void 0?[`${ne.count} 个活动`]:[],...ne.notices===void 0?[]:[`${ne.notices} 条公告`]].join("、")}`).join(";")}`:void 0}),H=Z=>A("create",async()=>{const{game:Y}=await e.connection.call("games/create",{name:Z});p(Y)}),F=Z=>{const Y=R;A("installed",async()=>{let Q;for(const ie of Z)Q??(Q=(await e.connection.call("games/create",{name:ie})).game);Q!==void 0&&(Y!==void 0&&Y.own===!0&&Y.sources.length===0&&Y.id!==Q&&await e.connection.call("games/remove",{game:Y.id}),p(Q))})},V=async Z=>{Z.own===!0&&!await Ms({title:`删除${Z.name}?`,message:`会删掉${Z.name}和它的活动记录(你自己记的也一起删)。脚本、脚本包和技能不受影响;以后可以在「更多游戏」里按名字再加回来。`,confirmLabel:"删除",danger:!0})||await A(`remove:${Z.id}`,async()=>(await e.connection.call("games/remove",{game:Z.id}),p(""),Z.own===!0?`已删除${Z.name}`:`${Z.name}不再显示:在「更多游戏」里勾上或按名字添加就回来`))},D=Z=>{const Y=((l==null?void 0:l.activities)??[]).filter(re=>re.game===Z.id&&(re.startsAt??0)<=o&&Math.max(re.endsAt??1/0,re.shopEndsAt??0)>o),Q=Y.filter(re=>ms(re).state!=="finished"&&re.endsAt!==void 0&&re.endsAt>o&&re.endsAt-o<((l==null?void 0:l.settings.report.soonDays)??3)*U8).length,ie=`${Y.length} 个进行中${Z.refreshed===void 0?"":` · ${vt(Z.refreshed.at,o)}刷新`}${Z.followed===!0?" · 关注的游戏":""}`;return{mine:Y,soon:Q,title:ie}},q=v.useContext(hS),te=q===null?null:n.jsxs("div",{className:"rail-games",role:"tablist","aria-label":"游戏",children:[n.jsxs("button",{role:"tab","aria-selected":z,className:`rail-item rail-game rail-overview ${z?"active":""}`,title:"全部活动:所有游戏的活动排在一条时间线上",onClick:()=>L(""),children:[n.jsx("span",{className:"rail-avatar overview-avatar",children:n.jsx(ee,{name:"timeline"})}),n.jsx("span",{className:"rail-label",children:"全部活动"})]}),U.map(Z=>{const{soon:Y,title:Q}=D(Z);return n.jsxs("button",{role:"tab","aria-selected":(R==null?void 0:R.id)===Z.id,className:`rail-item rail-game ${(R==null?void 0:R.id)===Z.id?"active":""}`,style:{"--game":P.get(Z.id)},title:`${Z.name}:${Q}`,onClick:()=>L(Z.id),children:[n.jsx(F8,{client:e,game:Z}),n.jsx("span",{className:"rail-label",children:Z.name}),Y>0&&n.jsx("span",{className:"rail-badge",title:`${Y} 个快结束还没做完`,children:Y})]},Z.id)}),n.jsx(Ql,{icon:"plus",label:"更多游戏",title:"选择游戏页上显示哪些游戏,或按名字添加",active:S,onClick:()=>_(!0)})]}),G=(R==null?void 0:R.name)??"全部活动",K=Z=>{const{mine:Y,soon:Q}=D(Z);return n.jsxs("button",{role:"tab","aria-selected":(R==null?void 0:R.id)===Z.id,className:`game-tab ${(R==null?void 0:R.id)===Z.id?"active":""}`,style:{"--game":P.get(Z.id)},title:`${Y.length} 个进行中${Z.refreshed===void 0?"":` · ${vt(Z.refreshed.at,o)}刷新`}${Z.followed===!0?" · 关注的游戏":""}`,onClick:()=>L(Z.id),children:[n.jsx("span",{className:"game-dot"}),Z.name,Q>0&&n.jsx("span",{className:"game-tab-badge",title:`${Q} 个快结束还没做完`,children:Q})]},Z.id)};return n.jsxs("section",{className:"main games-page",children:[q!==null&&te!==null&&qa.createPortal(te,q),n.jsxs("header",{className:"page-header games-header",children:[n.jsx("div",{className:"breadcrumb",children:n.jsx("h1",{children:q===null?"游戏":G})}),q===null?n.jsxs("nav",{className:"game-tabs",role:"tablist","aria-label":"游戏",children:[n.jsxs("button",{role:"tab","aria-selected":z,className:`game-tab ${z?"active":""}`,onClick:()=>L(""),children:[n.jsx(ee,{name:"timeline"}),"全部活动"]}),n.jsx("span",{className:"game-tabs-divider"}),U.map(K),n.jsxs("button",{className:`game-tab add ${S?"active":""}`,"aria-haspopup":"dialog",title:"选择游戏页上显示哪些游戏,或按名字添加",onClick:()=>_(!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||U.length===0,onClick:()=>void T(),children:[n.jsx(ee,{name:"refresh"}),g==="refresh:"?"刷新中…":"刷新全部"]})})]}),n.jsxs("div",{className:"games-body",children:[k!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:k})]}),j!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(ee,{name:"info"}),n.jsx("span",{children:j})]}),l!==null&&U.length===0&&n.jsxs("div",{className:"empty",children:[n.jsx(ee,{name:"gamepad"}),n.jsx("p",{children:"没有游戏。点「更多游戏」勾选几个,或按名字添加。"})]}),l!==null&&z&&U.length>0&&n.jsx(m3,{client:e,games:U,activities:l.activities,now:o,soonDays:l.settings.report.soonDays,onOpenGame:L,onChanged:()=>h(Z=>Z+1)}),l!==null&&R!==void 0&&n.jsx(N3,{client:e,game:R,activities:l.activities.filter(Z=>Z.game===R.id),notices:(l.notices??[]).filter(Z=>Z.game===R.id),color:P.get(R.id)??Xr[0],now:o,soonDays:l.settings.report.soonDays,busy:g,open:(E==null?void 0:E.kind)==="activity"?E.id:null,adding:(E==null?void 0:E.kind)==="add",onOpen:Z=>M({kind:"activity",id:Z}),onAdd:()=>M({kind:"add",game:R.id}),onRefresh:()=>void T(R.id),onRead:()=>void A(`read:${R.id}`,async()=>{const{sessionId:Z}=await e.connection.call("games/read",{game:R.id});t(Z)}),onReadWeb:Z=>void A(`read-web:${R.id}`,async()=>{const{sessionId:Y}=await e.connection.call("games/read",{game:R.id,how:"web",...Z===void 0?{}:{source:Z}});t(Y)}),onCancelReading:Z=>void A(`cancel:${Z}`,async()=>{await e.connection.call("games/read/cancel",{taskId:Z}),h(Y=>Y+1)}),onDiscover:()=>void A(`discover:${R.id}`,async()=>(await e.connection.call("games/discover",{game:R.id}),`agent 正在找${R.name}的活动来源,找到后这个页面会更新`)),onRemove:()=>void V(R),onChanged:()=>h(Z=>Z+1),openSession:t,openScripts:()=>s("scripts")},R.id)]}),S&&n.jsxs(dc,{color:"var(--accent)",label:"更多游戏",onClose:B,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:B,children:n.jsx(ee,{name:"close"})})]}),n.jsx("div",{className:"dialog-form catalog-dialog-body",children:n.jsx(v3,{client:e,onChanged:()=>h(Z=>Z+1),onCreate:Z=>{B(),H(Z)}})})]}),R!==void 0&&!S&&n.jsx(r1,{client:e,target:{games:[{id:R.id,name:R.name,aliases:R.aliases,...R.sra===void 0?{}:{sra:R.sra}}]},label:`「${R.name}」`,onInstalled:F}),l!==null&&E!==null&&(()=>{const Z=()=>h(Q=>Q+1);if(E.kind==="add"){const Q=U.find(ie=>ie.id===E.game);return Q===void 0?null:n.jsx(dc,{color:P.get(Q.id)??Xr[0],label:"添加活动",onClose:O,children:n.jsx("div",{className:"dialog-form",children:n.jsx(kx,{client:e,game:Q,onCancel:O,onDone:ie=>{M({kind:"activity",id:ie.id,saved:ie}),Z()}})})})}const Y=l.activities.find(Q=>Q.id===E.id)??E.saved;return Y===void 0?null:n.jsx(dc,{color:P.get(Y.game)??Xr[0],label:`${Y.name}的详情`,onClose:O,children:n.jsx(L3,{client:e,activity:Y,game:U.find(Q=>Q.id===Y.game),now:o,soonDays:l.settings.report.soonDays,onClose:O,onChanged:Z,openSession:t},Y.id)})})()]})}function H8({client:e,openSettings:t}){const s=Se(e.connection.status),i=vn(3e4),[r,o]=v.useState(null),[l,u]=v.useState(0),[d,h]=v.useState(null);return v.useEffect(()=>e.connection.on("games/changed",()=>u(m=>m+1)),[e]),v.useEffect(()=>{if(s.state!=="open")return;let m=!0;return e.connection.call("games/list",{}).then(p=>{m&&(o(p),h(null))}).catch(p=>{m&&h(Ce(p))}),()=>{m=!1}},[e,s.state,l]),n.jsxs("section",{className:"main games-page",children:[n.jsx("header",{className:"page-header games-header",children:n.jsx("div",{className:"breadcrumb",children:n.jsx("h1",{children:"日报"})})}),n.jsxs("div",{className:"games-body",children:[d!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:d})]}),r!==null&&n.jsx(Z8,{client:e,data:r,games:r.games,now:i,openSettings:t,onChanged:()=>u(m=>m+1)})]})]})}function Z8({client:e,data:t,games:s,now:i,openSettings:r,onChanged:o}){const l=t.settings.report,[u,d]=v.useState(null),[h,m]=v.useState(!1),[p,g]=v.useState(null),[x,k]=v.useState(null);v.useEffect(()=>{let w=!0;return e.connection.call("games/report/preview",{}).then(S=>{w&&d(S)}).catch(()=>{}),()=>{w=!1}},[e,t]);const b=async w=>{m(!0),g(null);try{await e.connection.call("games/settings/set",{report:w}),o()}catch(S){g(Ce(S))}finally{m(!1)}},j=async()=>{m(!0),g(null),k(null);try{const{channels:w}=await e.connection.call("games/report/send",{});k(w.length===0?"没有发出去:还没有设置好的聊天渠道。":`已发到${w.join("、")}。`),o()}catch(w){g(Ce(w))}finally{m(!1)}};return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"每日日报"}),n.jsx("p",{className:"muted small",children:"每天先读一遍数据站,再把各游戏的活动、剩余天数和没做完的事发到飞书。进度来自 agent 最近一次进游戏读取(可以在编排里加一个 agent 节点,日常跑完后读一次)。"})]}),n.jsx("span",{className:`badge ${l.enabled?"ok":""}`,children:l.enabled?"已开启":"未开启"})]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:l.enabled,disabled:h,onChange:w=>void b({enabled:w.target.checked})}),"每天定时发送"]}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:l.ai,disabled:h,onChange:w=>void b({ai:w.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:w=>{/^\d{2}:\d{2}$/.test(w.target.value)&&w.target.value!==l.at&&b({at:w.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:w=>{const S=Math.max(1,Math.min(30,Math.round(Number(w.target.value)||3)));S!==l.soonDays&&b({soonDays:S})}},l.soonDays)]})]}),n.jsx("div",{className:"field-title",children:"包括的游戏(都不选就是全部)"}),n.jsx("div",{className:"chip-row",children:s.map(w=>{const S=l.games.includes(w.id);return n.jsx("button",{className:`chip chip-button ${S?"active":""}`,disabled:h,onClick:()=>void b({games:S?l.games.filter(_=>_!==w.id):[...l.games,w.id]}),children:w.name},w.id)})}),n.jsxs("p",{className:"muted small",children:[t.report.lastSentAt===void 0?"还没发过。":`上次:${vt(t.report.lastSentAt,i)}。`,t.report.lastResult===void 0?"":` ${t.report.lastResult}。`,l.enabled&&t.report.next!==void 0&&` 下一次:${new Date(t.report.next).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}。`," ",n.jsx("button",{className:"link-button",onClick:()=>r("feishu"),children:"远程连接"})]}),p!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(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}),`
245
+
246
+ `,u.text]})]}),t.report.lastText!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:"上次发出的"}),t.report.lastSentAt!==void 0&&n.jsx("p",{className:"muted small",children:vt(t.report.lastSentAt,i)})]})}),n.jsx("div",{className:"report-preview",children:t.report.lastText})]})]})}const W8={id:"games",title:"游戏看板",milestone:"M6",requires:["games"],pages:[{id:"games",title:"游戏",icon:"library",order:-10,component:B8},{id:"daily-report",title:"日报",icon:"send",order:10,agent:"games",component:H8}]},sl="MultiGameAssistant",uE=e=>e.pack==="script"?"脚本包":e.pack==="game"?"游戏包":"技能",Sg=e=>e.author??e.repo.split("/")[0]??e.repo;function V8(e,t,s){const i=x=>e.find(k=>k.pack==="script"&&k.name===x),r=x=>{var b,j;if(x.pack==="game")return x.game??x.games[0];if(x.games[0]!==void 0)return x.games[0];const k=x.pack==="script"?x.name:x.scripts[0];if(k!==void 0)return((b=i(k))==null?void 0:b.games[0])??((j=t.find(w=>w.scripts.includes(k)))==null?void 0:j.id)},o=x=>x.pack==="script"?x.name:x.pack==="game"?void 0:x.scripts[0],l=x=>{var k,b;return((k=t.find(j=>j.id===x))==null?void 0:k.name)??((b=e.find(j=>j.pack==="game"&&j.game===x))==null?void 0:b.title)??x},u=x=>{var k,b;return((k=i(x))==null?void 0:k.title)??((b=s.find(j=>j.id===x||j.packId===x))==null?void 0:b.name)??x},d=x=>{const k=t.findIndex(b=>b.id===x);return k<0?t.length:k},h=x=>s.some(k=>k.id===x||k.packId===x),m=x=>x.pack==="game"?0:x.pack==="script"?1:2,p=(x,k)=>{const b=new Map;for(const j of x)b.set(k(j),[...b.get(k(j))??[],j]);return b},g=p(e,x=>r(x)??"");return[...g.keys()].sort((x,k)=>+(x==="")-+(k==="")||d(x)-d(k)||l(x).localeCompare(l(k))).map(x=>{const k=p(g.get(x),b=>o(b)??"");return{key:x,name:x===""?"通用":l(x),children:[...k.keys()].sort((b,j)=>+(j==="")-+(b==="")||Number(h(j))-Number(h(b))||u(b).localeCompare(u(j))).map(b=>{const j=p(k.get(b),Sg);return{key:b,name:b===""?x===""?"不分脚本":"游戏本身":u(b),children:[...j.keys()].sort((w,S)=>+(S===sl)-+(w===sl)||w.localeCompare(S)).map(w=>({key:w,name:w,children:[...j.get(w)].sort((S,_)=>m(S)-m(_)||(S.title??S.name).localeCompare(_.title??_.name))}))}})}})}function q8({tree:e,selected:t,searching:s,folded:i,onFold:r,onPick:o}){return n.jsx(n.Fragment,{children:e.map(l=>{const u=`hub:${l.key||":general"}`,d=s||!i.has(u),h=l.children.reduce((m,p)=>m+p.children.reduce((g,x)=>g+x.children.length,0),0);return n.jsxs("div",{className:`skills-group ${d?"":"folded"}`,children:[n.jsx("div",{className:"skills-section-head",children:n.jsxs("button",{className:"skills-fold","aria-expanded":d,onClick:()=>r(u),children:[n.jsx(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(m=>n.jsxs("div",{className:"skills-sub hub-sub",children:[n.jsxs("div",{className:"hub-script-label",children:[n.jsx(ee,{name:m.key===""?"gamepad":"package"}),m.name]}),m.children.map(p=>n.jsxs("div",{className:"hub-author-block",children:[n.jsxs("div",{className:"hub-author-label",children:[p.name,p.name===sl&&n.jsx("span",{className:"hub-official",children:"官方"})]}),p.children.map(g=>{var x;return n.jsxs("button",{className:`script-row skill-row ${t===g.name?"active":""}`,title:g.installed!==void 0?"已下载":void 0,onClick:()=>o(g.name),children:[n.jsxs("span",{className:"script-row-main",children:[n.jsxs("span",{className:"skill-row-name-line",children:[n.jsx("span",{className:"script-row-name",children:g.title??g.name}),g.installed!==void 0&&n.jsx("span",{className:"skill-row-from",children:"已下载"})]}),n.jsx("span",{className:"muted small skills-row-desc",children:g.description})]}),n.jsx("span",{className:`skill-row-tag ${g.pack===void 0?"subtle":""}`,children:uE(g)}),((x=g.installed)==null?void 0:x.update)===!0&&g.incompatible===void 0&&n.jsx("span",{className:"skill-dot",title:"有新版"})]},`${g.repo}/${g.name}`)})]},p.key))]},m.key||":own"))]},u)})})}function G8({client:e,item:t,where:s,busy:i,now:r,act:o,onOpen:l}){const[u,d]=v.useState(null),h=t.installed,m=[...t.version===void 0?[]:[{version:t.version,changes:t.changes,latest:!0}],...(t.history??[]).map(_=>({..._,latest:!1}))],[p,g]=v.useState((h==null?void 0:h.version)??t.version??""),x=m.find(_=>_.version===p),k=t.blocked===void 0&&t.incompatible===void 0,b=_=>i===`${_}:${t.name}`;v.useEffect(()=>{let _=!0;return d(null),e.connection.call("skillhub/preview",{name:t.name}).then(E=>{_&&d(E.content.replace(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/,""))},()=>{_&&d("")}),()=>{_=!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 现在就能用"}`)),w=()=>void o(`update:${t.name}`,async()=>(await e.connection.call("skillhub/update",{name:t.name})).state==="updated"?`${t.title??t.name} 已更新`:"已是最新"),S=()=>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"}),uE(t)," · 作者 ",Sg(t),Sg(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}),m.length>1&&n.jsxs("span",{className:"badge",title:m.map(_=>_.version).join("、"),children:["共 ",m.length," 个版本"]}),h!==void 0&&n.jsxs("span",{className:"badge ok",title:`${vt(h.at,r)}下载`,children:["已下载",h.version===void 0||h.version===t.version?"":` ${h.version}`]}),(h==null?void 0:h.update)===!0&&t.incompatible===void 0&&n.jsx("span",{className:"badge warn",children:"有新版"})]})]}),n.jsxs("div",{className:"skill-buttons",children:[h===void 0&&k&&n.jsxs("button",{className:"small-button primary",disabled:i!==null,onClick:j,children:[n.jsx(ee,{name:"download"}),b("install")?"下载中…":"下载"]}),(h==null?void 0:h.update)===!0&&t.incompatible===void 0&&n.jsx("button",{className:"small-button primary",disabled:i!==null,onClick:w,children:b("update")?"更新中…":"更新"}),h!==void 0&&n.jsx("button",{className:"small-button",onClick:()=>l(t.name),children:"在技能列表里查看"})]})]}),n.jsx("p",{className:"skill-desc",children:t.description}),n.jsxs("div",{className:"skill-notes",children:[t.changes!==void 0&&(h===void 0||h.update)&&n.jsxs("p",{className:"small hub-changes",children:[t.version===void 0?"":`${t.version}:`,t.changes]}),t.incompatible!==void 0&&n.jsx("p",{className:"small hub-incompatible",children:t.incompatible}),t.blocked!==void 0&&n.jsxs("p",{className:"muted small",children:[t.blocked,",没有下载(以你已有的为准)"]})]}),m.length>1&&k&&n.jsxs("div",{className:"skill-versions",children:[n.jsxs("span",{className:"field-label",children:["版本(技能库留着的每一版都能",h===void 0?"下载":"换",")"]}),n.jsxs("div",{className:"skill-versions-row",children:[n.jsx(Mt,{className:"skill-version-select",value:p,onChange:g,disabled:i!==null,"aria-label":"版本",options:m.map(_=>({value:_.version,label:`${_.version}${_.latest?"(最新)":""}${_.version===(h==null?void 0:h.version)?"(正在用)":""}`,..._.changes===void 0?{}:{hint:_.changes}}))}),n.jsx("button",{className:"small-button",disabled:i!==null||p===(h==null?void 0:h.version),onClick:S,children:b("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 K8({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(`
247
+ `)),l=v.useMemo(()=>r.split(/\r?\n/).map(d=>d.trim()).filter(Boolean).map(d=>{const[h,m]=d.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("@");return{repo:h??"",branch:m??"main"}}),[r]),u=l.length>0&&l.every(d=>/^[\w.-]+\/[\w.-]+$/.test(d.repo)&&/^[\w./-]+$/.test(d.branch));return n.jsxs("article",{className:"card skill-card",children:[n.jsx("div",{className:"skill-title",children:n.jsx("h2",{children:"技能仓库"})}),n.jsxs("p",{className:"muted small",children:["脚本包、游戏包和技能从这些 GitHub 仓库下载(整个仓库打包下载,不用装 git,走「设置 → 脚本安装」的下载镜像),一天最多读一次。只有默认仓库 ",sl,"/skills 的脚本包当作官方的;别的仓库里的会让 agent 照着做,只加你信得过的。"]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-label",children:"一行一个 owner/repo,可以写 @分支;前面的同名的优先"}),n.jsx("textarea",{className:"text-input plain skill-content-input",rows:4,value:r,onChange:d=>o(d.target.value),spellCheck:!1})]}),n.jsxs("div",{className:"skill-actions",children:[n.jsx("button",{className:"link-button small",disabled:t,onClick:()=>o(`${sl}/skills`),children:"恢复默认"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:t,onClick:i,children:"取消"}),n.jsx("button",{className:"small-button primary",disabled:t||!u,onClick:()=>s(l),children:"保存"})]})]})}const Zx=[{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:"软件自带、维持基本功能的技能:受保护,不能改,随软件更新"}],Y8=Object.fromEntries(Zx.map(e=>[e.id,e.label])),X8=new Set(["script-pack","skill"]),dE=e=>{var t,s;return((t=e.skill)==null?void 0:t.removable)===!0||((s=e.skill)==null?void 0:s.ownPack)===!0};function Q8(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 hE="adg:skills:folded-kinds";function J8(){try{return new Set(JSON.parse(localStorage.getItem(hE)??"[]"))}catch{return new Set}}function e7(e){try{localStorage.setItem(hE,JSON.stringify([...e]))}catch{}}const Sa="",jo=":general";function t7({client:e,arg:t}){var On;const s=Se(e.connection.status),i=Se(e.capabilities),r=vn(6e4),[o,l]=v.useState(null),[u,d]=v.useState(null),[h,m]=v.useState(""),[p,g]=v.useState(Sa),[x,k]=v.useState((t==null?void 0:t.startsWith("hub"))===!0?"hub":"mine"),[b,j]=v.useState((t==null?void 0:t.startsWith("hub:"))===!0?t.slice(4):""),[w,S]=v.useState(""),[_,E]=v.useState(!1),[M,O]=v.useState(t===void 0||t.startsWith("hub")?"":t),[B,U]=v.useState(null),[P,R]=v.useState(null),[z,L]=v.useState(null),[A,T]=v.useState(null),[H,F]=v.useState(0),[V,D]=v.useState(0),[q,te]=v.useState(!1),[G,K]=v.useState(null),[Z,Y]=v.useState(!1),[Q,ie]=v.useState(J8),re=ce=>ie(J=>{const me=new Set(J);return me.delete(ce)||me.add(ce),e7(me),me}),ne=((On=ah(e).data)==null?void 0:On.scripts)??[],[fe,Ee]=v.useState([]),Ue=i.has("skillhub");v.useEffect(()=>{t!==void 0&&(t.startsWith("hub")?(k("hub"),t.startsWith("hub:")&&j(t.slice(4))):(k("mine"),O(t)),K(null))},[t]),v.useEffect(()=>e.connection.on("skills/changed",()=>F(ce=>ce+1)),[e]),v.useEffect(()=>e.connection.on("skillhub/changed",()=>D(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&&Ee(J.games)},()=>{}),()=>{ce=!1}},[e,s.state,i,V]),v.useEffect(()=>{if(s.state!=="open")return;let ce=!0;return e.connection.call("skills/list",{}).then(J=>{ce&&l(J.skills)},J=>{ce&&R(Ce(J))}),()=>{ce=!1}},[e,s.state,H]);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"||!Ue)return;let ce=!0;return e.connection.call("skillhub/list",{}).then(J=>{ce&&d(J)},J=>{ce&&R(Ce(J))}),()=>{ce=!1}},[e,s.state,Ue,V]);const pe=v.useMemo(()=>{const ce=(u==null?void 0:u.items)??[];return(o??[]).map(J=>{const me=J.source==="hub"?ce.find(we=>we.name===J.name&&we.installed!==void 0):void 0;return{name:J.name,title:(me==null?void 0:me.title)??J.name,description:J.description,category:Q8(J,me),skill:J,...me===void 0?{}:{hub:me},...J.owner===void 0?{}:{owner:J.owner}}})},[o,u]),be=ce=>gS(ce.owner,ne,fe),De=ce=>[...new Set(be(ce).map(xS))].join("、"),Re=ce=>{var He,dt,Nt,Ze,Be,Xe;const J=(He=be(ce).find(yt=>yt.game!==void 0))==null?void 0:He.game;if(J!==void 0)return J;const me=((dt=ce.hub)==null?void 0:dt.game)??((Nt=ce.hub)==null?void 0:Nt.games[0])??((Be=(Ze=ce.owner)==null?void 0:Ze.games)==null?void 0:Be[0]);if(me===void 0)return;const we=zd(me,fe);return we!==void 0?{id:we.id,name:we.name}:{id:me,name:((Xe=((u==null?void 0:u.items)??[]).find(yt=>yt.pack==="game"&&yt.game===me))==null?void 0:Xe.title)??me}},ae=ce=>{const J=new Map;for(const we of ce){const He=Re(we)??{id:jo,name:"通用"},dt=J.get(He.id)??{...He,items:[]};dt.items.push(we),J.set(He.id,dt)}const me=we=>{const He=fe.findIndex(dt=>dt.id===we);return He<0?fe.length:He};return[...J.values()].sort((we,He)=>+(we.id===jo)-+(He.id===jo)||me(we.id)-me(He.id)||we.name.localeCompare(He.name))},Fe=h.trim().toLowerCase(),ut=v.useMemo(()=>pe.filter(ce=>{var me,we;if(Fe!==""&&!`${ce.name} ${ce.title} ${ce.description} ${((me=ce.skill)==null?void 0:me.whenToUse)??""}`.toLowerCase().includes(Fe))return!1;if(p===Sa)return!0;const J=be(ce);return p===jo?J.length===0:J.some(He=>{var dt;return((dt=He.game)==null?void 0:dt.id)===p})||((we=ce.hub)==null?void 0:we.game)===p}),[pe,Fe,p,ne,fe]),Rt=v.useMemo(()=>Zx.map(ce=>({...ce,items:ut.filter(J=>J.category===ce.id).sort((J,me)=>J.title.localeCompare(me.title))})).filter(ce=>ce.items.length>0||ce.id==="skill"&&Fe===""&&p===Sa),[ut,Fe,p]).map(ce=>({...ce,groups:X8.has(ce.id)?ae(ce.items):void 0})),En=Rt.flatMap(ce=>{var J;return((J=ce.groups)==null?void 0:J.flatMap(me=>me.items))??ce.items}),rt=ut.find(ce=>ce.name===M)??En[0];v.useEffect(()=>{if(Y(!1),te(!1),rt===void 0){U(null);return}let ce=!0;const J=rt.name;return e.connection.call("skills/get",{name:J}).then(me=>me.content).then(me=>{ce&&U({name:J,text:me})},me=>{ce&&(U({name:J,text:""}),R(Ce(me)))}),()=>{ce=!1}},[e,rt==null?void 0:rt.name,H,V]);const Pt=async(ce,J)=>{T(ce),R(null),L(null);try{const me=await J();typeof me=="string"&&L(me),F(we=>we+1),D(we=>we+1)}catch(me){R(Ce(me))}finally{T(null)}},rn=ce=>{K(null),L(null),R(null),O(ce)},Zt=ce=>{k(ce),K(null),L(null),R(null)},Qt=ce=>Pt(`remove:${ce.name}`,async()=>{var me,we;const J=((me=ce.skill)==null?void 0:me.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}),O(""),`已删除 ${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,He;const me=await e.connection.call("skillhub/version",{name:ce.name,version:J});return`${ce.title} 换成了 ${((we=me.installed)==null?void 0:we.version)??J}${J===((He=ce.hub)==null?void 0:He.version)?"(最新)":":技能库再有更新的版本时会再提示"}`}),mn=ce=>Pt(`rollback:${ce.name}`,async()=>{var me;const J=await e.connection.call("skillhub/rollback",{name:ce.name});return`${ce.title} 已回退${((me=J.installed)==null?void 0:me.version)===void 0?"":`到 ${J.installed.version}`};技能库再有新版本时会再提示`}),Hn=()=>({name:"",description:"",content:"",scripts:[],games:p!==Sa&&p!==jo?[p]:[]}),Gs=ce=>{var J,me;return n.jsxs(n.Fragment,{children:[((me=(J=ce.hub)==null?void 0:J.installed)==null?void 0:me.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 ${G===null&&(rt==null?void 0:rt.name)===ce.name?"active":""}`,title:ce.hub!==void 0?`从技能库下载的(作者 ${ce.hub.author??ce.hub.repo})`:dE(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:De(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"&&Ue||G!==null,Cn=w.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(()=>V8(as,fe,ne),[as,fe,ne]),Zn=Kn.flatMap(ce=>ce.children.flatMap(J=>J.children.flatMap(me=>me.children))),An=Zn.find(ce=>ce.name===b)??Zn[0],Yn=ce=>{for(const J of Kn)for(const me of J.children)if(me.children.some(we=>we.children.some(He=>He.name===ce)))return J.key===""?me.key===""?"":me.name:me.key===""?J.name:`${J.name} · ${me.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"&&Ue?Zt("mine"):K(null),children:[n.jsx(ee,{name:"back"}),"返回"]}),n.jsx("h1",{children:x==="hub"&&Ue?"技能库":G===null?"技能":G.original===void 0?"新建技能":`编辑 ${G.original}`})]}),n.jsx("div",{className:"page-actions",children:x==="mine"||!Ue?G===null&&n.jsxs(n.Fragment,{children:[Ue&&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:()=>K(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?"":`${vt(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 ${_?"active":""}`,"aria-expanded":_,onClick:()=>E(ce=>!ce),children:"仓库"})]})})]}),x==="hub"&&Ue?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:w,onChange:ce=>S(ce.target.value),placeholder:"搜索游戏、脚本、作者或技能","aria-label":"搜索技能库"})]})}),u===null&&P===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(q8,{tree:Kn,selected:_||An==null?void 0:An.name,searching:Cn!=="",folded:Q,onFold:re,onPick:ce=>{j(ce),E(!1),L(null),R(null)}})]}),n.jsx("div",{className:"scripts-detail",children:n.jsxs("div",{className:"script-detail",children:[P!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:P})]}),z!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(ee,{name:"check"}),n.jsx("span",{children:z})]}),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)),_&&u!==null?n.jsx(K8,{repos:u.repos,disabled:A!==null,onCancel:()=>E(!1),onSave:ce=>void Pt("repos",async()=>(await e.connection.call("skillhub/repos/set",{repos:ce}),E(!1),await Te(!0),"已保存,按新的仓库读取"))}):An!==void 0?n.jsx(G8,{client:e,item:An,where:Yn(An.name),busy:A,now:r,act:Pt,onOpen:ce=>{Zt("mine"),O(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=>m(ce.target.value),placeholder:"搜索脚本包、游戏包和技能","aria-label":"搜索"})]}),fe.length>0&&n.jsx(Mt,{className:"skills-filter",value:p,onChange:g,"aria-label":"只看一个游戏的",options:[{value:Sa,label:"所有游戏"},...fe.map(ce=>({value:ce.id,label:ce.name})),{value:jo,label:"通用",hint:"不分游戏的技能"}]})]}),(o===null||Ue&&u===null)&&P===null&&n.jsx("p",{className:"muted small pad",children:"正在读取…"}),o!==null&&Fe!==""&&n.jsx("p",{className:"muted small skills-found",children:ut.length===0?"没有匹配的。":`找到 ${ut.length} 个`}),Rt.map(ce=>{var we;const J=Fe!==""||p!==Sa,me=J||!Q.has(ce.id);return n.jsxs("div",{className:`skills-group ${me?"":"folded"}`,children:[n.jsxs("div",{className:"skills-section-head",title:ce.hint,children:[n.jsxs("button",{className:"skills-fold","aria-expanded":me,onClick:()=>re(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:()=>K(Hn()),children:n.jsx(ee,{name:"plus"})})]}),me&&ce.items.length===0&&n.jsx("p",{className:"muted small skills-empty",children:ce.id==="skill"?"agent 做成一件事后会提议存成技能;也可以自己写一个,或在「技能库」里下载。":"没有"}),me&&ce.groups===void 0&&ce.items.map(ps),me&&((we=ce.groups)==null?void 0:we.map(He=>{const dt=`${ce.id}/${He.id}`,Nt=J||!Q.has(dt);return n.jsxs("div",{className:`skills-sub ${Nt?"":"folded"}`,children:[n.jsxs("button",{className:"skills-sub-head","aria-expanded":Nt,onClick:()=>re(dt),children:[n.jsx(ee,{name:"chevron-down",className:"skills-chevron"}),n.jsx("span",{className:"skills-group-name",children:He.name}),n.jsx("span",{className:"skills-count",children:He.items.length})]}),Nt&&He.items.map(ps)]},dt)}))]},ce.id)})]}),n.jsx("div",{className:"scripts-detail",children:n.jsxs("div",{className:"script-detail",children:[P!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:P})]}),z!==null&&n.jsxs("div",{className:"notice info left small",children:[n.jsx(ee,{name:"check"}),n.jsx("span",{children:z})]}),G!==null?n.jsx(i7,{client:e,draft:G,scripts:ne,games:fe,onCancel:()=>K(null),onSaved:ce=>{K(null),O(ce),R(null),L(G.original===void 0?"已保存,agent 现在就能用":"已保存"),F(J=>J+1)}}):rt===void 0?o!==null&&n.jsxs("div",{className:"skills-blank",children:[n.jsx(ee,{name:"sparkles"}),n.jsx("strong",{children:Fe===""&&p===Sa?"还没有技能":"没有匹配的"}),n.jsx("span",{className:"muted small",children:"agent 做成一件事后会提议存成技能;也可以自己写一个。"}),n.jsxs("button",{className:"small-button primary",disabled:s.state!=="open",onClick:()=>K(Hn()),children:[n.jsx(ee,{name:"plus"}),"新建技能"]})]}):n.jsx(n7,{entry:rt,where:De(rt),content:(B==null?void 0:B.name)===rt.name?B.text:void 0,busy:A,copied:q,moving:Z,now:r,onCopy:()=>{var ce;(ce=navigator.clipboard)==null||ce.writeText(`/${rt.name} `).then(()=>te(!0),()=>{})},onUpdate:()=>void Ut(rt),onVersion:ce=>void Rn(rt,ce),onRollback:()=>void mn(rt),onRemove:()=>void Qt(rt),onEdit:()=>{var ce,J;return K({original:rt.name,...rt.hub===void 0?{}:{hub:!0},name:rt.name,description:rt.description,content:(B==null?void 0:B.name)===rt.name?B.text.trim():"",scripts:[...((ce=rt.owner)==null?void 0:ce.scripts)??[]],games:[...((J=rt.owner)==null?void 0:J.games)??[]]})},onMove:()=>Y(ce=>!ce),move:Z&&rt.skill!==void 0?n.jsx(r7,{client:e,skill:rt.skill,content:(B==null?void 0:B.name)===rt.name?B.text:void 0,scripts:ne,games:fe,onCancel:()=>Y(!1),onMoved:()=>{Y(!1),R(null),F(ce=>ce+1),D(ce=>ce+1)}}):null},rt.name)]})})]})]})}function n7({entry:e,where:t,content:s,busy:i,copied:r,moving:o,now:l,onCopy:u,onUpdate:d,onVersion:h,onRollback:m,onRemove:p,onEdit:g,onMove:x,move:k}){var R,z,L;const{skill:b,hub:j}=e,w=j==null?void 0:j.installed,S=(b==null?void 0:b.removable)===!0||w!==void 0,_=j===void 0?void 0:s7(j),E=Zx.find(A=>A.id===e.category).icon,M=A=>i===`${A}:${e.name}`,O=j===void 0?[]:[...j.version===void 0?[]:[{version:j.version,changes:j.changes,latest:!0}],...(j.history??[]).map(A=>({...A,latest:!1}))],[B,U]=v.useState((w==null?void 0:w.version)??(j==null?void 0:j.version)??""),P=O.find(A=>A.version===B);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:E}),Y8[e.category],j!==void 0?` · 从技能库下载的 · 作者 ${j.author??j.repo}`:dE(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:(z=(R=e.owner)==null?void 0:R.scripts)!=null&&z.length?"package":"gamepad"}),"只给 ",t," 用"]}),(b==null?void 0:b.modelInvocable)===!0&&n.jsx("span",{className:"badge ok",title:"agent 遇到相关的事会自己读它",children:"agent 自动使用"}),_!==void 0&&n.jsx("span",{className:"badge",title:(w==null?void 0:w.at)===void 0?void 0:`${vt(w.at,l)}下载`,children:_}),(w==null?void 0:w.update)===!0&&(j==null?void 0:j.incompatible)===void 0&&n.jsx("span",{className:"badge ok",children:"有新版"}),(w==null?void 0:w.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:[(w==null?void 0:w.update)===!0&&(j==null?void 0:j.incompatible)===void 0&&n.jsx("button",{className:"small-button primary",disabled:i!==null,onClick:d,children:M("update")?"更新中…":"更新"}),(w==null?void 0:w.held)===!0&&(j==null?void 0:j.incompatible)===void 0&&n.jsx("button",{className:"small-button",title:"回退过的那个新版本,再换回去",disabled:i!==null,onClick:d,children:M("update")?"更新中…":"重新更新"}),(w==null?void 0:w.previous)!==void 0&&n.jsx("button",{className:"small-button",title:`换回上一个版本${w.previous.version===void 0?"":` ${w.previous.version}`}(${vt(w.previous.at,l)}下载的)`,disabled:i!==null,onClick:m,children:M("rollback")?"回退中…":"回退"}),(b==null?void 0:b.userInvocable)===!0&&n.jsxs("button",{className:"small-button",onClick:u,title:"复制后粘贴到对话框,后面写要它做的事",children:[n.jsx(ee,{name:r?"check":"copy"}),r?"已复制":`/${e.name}`]}),S&&n.jsxs("button",{className:"small-button",disabled:s===void 0,onClick:g,children:[n.jsx(ee,{name:"pencil"}),"编辑"]}),S&&n.jsxs("button",{className:"small-button","aria-expanded":o,onClick:x,title:"放错了游戏或脚本时,换到对的那个",children:[n.jsx(ee,{name:"gamepad"}),"更换游戏和脚本"]}),(S||(b==null?void 0:b.ownPack)===!0)&&n.jsx("button",{className:"small-button danger-outline",disabled:i!==null,onClick:p,children:M("remove")?"删除中…":"删除"}),(b==null?void 0:b.path)!==void 0&&((L=Vs())==null?void 0:L.openPath)!==void 0&&n.jsx("button",{className:"icon-button skill-folder",title:`打开所在文件夹:${b.path}`,"aria-label":"打开所在文件夹",onClick:()=>{var A,T;return void((T=(A=Vs())==null?void 0:A.openPath)==null?void 0:T.call(A,b.path.replace(/[\\/][^\\/]+$/,"")))},children:n.jsx(ee,{name:"layers"})})]})]}),k,n.jsx("p",{className:"skill-desc",children:e.description}),(b==null?void 0:b.whenToUse)!==void 0&&n.jsxs("p",{className:"muted small",children:["什么时候用:",b.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:"核心技能维持软件的基本功能,受保护,不能改和删,随软件更新。"}),w!==void 0&&n.jsx("p",{className:"muted small",children:"从技能库下载的:可以改,但技能库更新它时会整个换成新版本,这里改的不保留(被换掉的那版可以回退)。要一直留着的做法,另存成自己的技能。"}),(j==null?void 0:j.changes)!==void 0&&(w==null?void 0:w.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]})]}),w!==void 0&&O.length>1&&n.jsxs("div",{className:"skill-versions",children:[n.jsx("label",{className:"field-label",htmlFor:"skill-version",children:"版本(技能库留着的每一版都能换,往前往后都行)"}),n.jsxs("div",{className:"skill-versions-row",children:[n.jsx(Mt,{id:"skill-version",className:"skill-version-select",value:B,disabled:i!==null,onChange:U,"aria-label":"版本",options:O.map(A=>({value:A.version,label:`${A.version}${A.latest?"(最新)":""}${A.version===w.version?"(正在用)":""}`,...A.changes===void 0?{}:{hint:A.changes}}))}),n.jsx("button",{className:"small-button",disabled:i!==null||B===w.version,onClick:()=>h(B),children:M("version")?"切换中…":"换成这个版本"})]}),(P==null?void 0:P.changes)!==void 0&&n.jsxs("span",{className:"muted small",children:[P.version,":",P.changes]}),P!==void 0&&!P.latest&&B!==w.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})]}),(b==null?void 0:b.path)!==void 0&&n.jsx("code",{className:"muted small skill-path",title:b.path,children:b.path})]})}function s7(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 i7({client:e,draft:t,scripts:s,games:i,onCancel:r,onSaved:o}){const[l,u]=v.useState(t),[d,h]=v.useState(!1),[m,p]=v.useState(null);v.useEffect(()=>{u(t),p(null)},[t]);const g=t.original!==void 0,x=JN.test(l.name)&&l.name.length<=Ep,k=x&&l.description.trim().length>=10&&l.content.trim().length>=20,b=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:Ep,autoFocus:!g,onChange:j=>u(w=>({...w,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(mE,{scripts:s,games:i,value:l,onChange:j=>u(w=>({...w,...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(w=>({...w,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(w=>({...w,content:j.target.value}))})]}),m!==null&&n.jsx("p",{className:"error small",children:m}),n.jsxs("div",{className:"skill-actions",children:[n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:d,onClick:r,children:"取消"}),n.jsx("button",{className:"small-button primary",disabled:d||!k,onClick:()=>void b(),children:d?"保存中…":"保存"})]})]})}function mE({scripts:e,games:t,value:s,onChange:i}){const[r]=v.useState(s),o=[...new Set([...r.scripts,...s.scripts])].filter(m=>!e.some(p=>p.id===m)),l=[...new Set([...r.games,...s.games])].filter(m=>zd(m,t)===void 0),u=(m,p)=>{var g;return m===p||((g=zd(m,t))==null?void 0:g.id)===p},d=m=>i({...s,scripts:s.scripts.includes(m)?s.scripts.filter(p=>p!==m):[...s.scripts,m]}),h=m=>i({...s,games:s.games.some(p=>u(p,m))?s.games.filter(p=>!u(p,m)):[...s.games,m]});return n.jsxs(n.Fragment,{children:[(t.length>0||l.length>0)&&n.jsxs("fieldset",{className:"field skill-owners",children:[n.jsx("legend",{className:"field-label",children:"给哪个游戏用(和游戏本身有关、换个脚本也用得上的:游戏里的操作、界面、活动、机制)"}),n.jsxs("div",{className:"skill-owner-list",children:[t.map(m=>n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:s.games.some(p=>u(p,m.id)),onChange:()=>h(m.id)}),m.name]},m.id)),l.map(m=>n.jsxs("label",{className:"check-label",title:"游戏页上没有这个游戏",children:[n.jsx("input",{type:"checkbox",checked:s.games.includes(m),onChange:()=>h(m)}),m]},m))]})]}),n.jsxs("fieldset",{className:"field skill-owners",children:[n.jsx("legend",{className:"field-label",children:"给哪个脚本用(只在用这个脚本时才用得上的做法:它的配置、报错、日志)"}),e.length===0&&o.length===0&&n.jsx("span",{className:"muted small",children:"还没有装脚本。"}),n.jsxs("div",{className:"skill-owner-list",children:[e.map(m=>n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:s.scripts.includes(m.id),onChange:()=>d(m.id)}),m.name]},m.id)),o.map(m=>n.jsxs("label",{className:"check-label",title:"这个脚本不在脚本库里(删掉了,或是脚本包 id)",children:[n.jsx("input",{type:"checkbox",checked:s.scripts.includes(m),onChange:()=>d(m)}),m]},m))]})]}),n.jsx("p",{className:"muted small",children:"游戏和脚本都不选就是通用技能,所有对话都能用。"})]})}function r7({client:e,skill:t,content:s,scripts:i,games:r,onCancel:o,onMoved:l}){var b,j;const[u,d]=v.useState({scripts:[...((b=t.owner)==null?void 0:b.scripts)??[]],games:[...((j=t.owner)==null?void 0:j.games)??[]]}),[h,m]=v.useState(!1),[p,g]=v.useState(null),x=t.source==="hub",k=async w=>{m(!0),g(null);try{if(x)await e.connection.call("skillhub/owner",{name:t.name,owner:w});else{if(s===void 0||w===null)return;await e.connection.call("skills/save",{name:t.name,description:t.description,content:s,replace:!0,...w.scripts.length===0?{}:{scripts:w.scripts},...w.games.length===0?{}:{games:w.games}})}l()}catch(S){g(Ce(S))}finally{m(!1)}};return n.jsxs("div",{className:"skill-move",role:"group","aria-label":"更换游戏和脚本",children:[n.jsx(mE,{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 k(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 k(u),children:h?"保存中…":"保存"})]})]})}const a7={id:"skills",title:"技能",requires:["skills"],pages:[{id:"skills",title:"技能",icon:"sparkles",order:50,agent:"scripts",component:t7}]};function o7({client:e}){const t=Se(e.connection.status),[s,i]=v.useState(null),[r,o]=v.useState(0),[l,u]=v.useState(null),[d,h]=v.useState(null),[m,p]=v.useState(""),[g,x]=v.useState("");v.useEffect(()=>e.connection.on("emulators/changed",()=>o(j=>j+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let j=!0;return e.connection.call("emulators/status",{refresh:r===0}).then(w=>{j&&(i(w),p(w.settings.manualAddress??""),x(w.settings.adbPath??""))}).catch(w=>{j&&h(Ce(w))}),()=>{j=!1}},[e,t.state,r]);const k=async(j,w)=>{u(j),h(null);try{await w(),o(S=>S+1)}catch(S){h(Ce(S))}finally{u(null)}},b=j=>k("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 k("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(w=>n.jsxs("li",{className:w.index===s.settings.instance?"current":"",children:[n.jsx("span",{className:"version-name",children:w.index}),n.jsx("span",{children:w.name}),n.jsx("span",{className:`badge ${w.ready?"ok":""}`,children:w.ready?"已启动":w.running?"启动中":"未运行"}),w.adb!==void 0&&n.jsx("span",{className:"muted small",children:w.adb}),n.jsx("span",{className:"spacer"}),w.index!==s.settings.instance&&n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void b({instance:w.index}),children:"任务用这个"}),w.ready?n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void k(`stop-${w.index}`,()=>e.connection.call("emulators/stop",{index:w.index})),children:"关闭"}):n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void k(`start-${w.index}`,()=>e.connection.call("emulators/start",{index:w.index})),children:l===`start-${w.index}`?"启动中…":"启动"})]},w.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 b({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:m,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 b({manualAddress:m.trim()===""?null:m.trim()}),children:"保存"})]}),n.jsx("label",{className:"field-label",htmlFor:"adb-path",children:"adb.exe 位置(可选,出错时重连模拟器、截图用;默认用 MuMu 自带的)"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:"adb-path",className:"text-input plain",value:g,onChange:j=>x(j.target.value),placeholder:"例如 D:\\platform-tools\\adb.exe",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void b({adbPath:g.trim()===""?null:g.trim()}),children:"保存"}),n.jsx("button",{className:"small-button",disabled:l!==null,onClick:()=>void hh(e,{kind:"file",title:"选择 adb.exe",defaultPath:g.trim(),filterName:"程序",extensions:["exe"]}).then(j=>{j!==null&&(x(j),b({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 b({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 l7({client:e}){const t=Se(e.connection.status),[s,i]=v.useState(null),[r,o]=v.useState(null),[l,u]=v.useState(""),[d,h]=v.useState(""),[m,p]=v.useState(null),[g,x]=v.useState(!1),[k,b]=v.useState(null),[j,w]=v.useState(null),S=()=>e.connection.call("scripts/settings",{}).then(O=>{i(O),o(O)}).catch(O=>w(Ce(O)));if(v.useEffect(()=>{t.state==="open"&&S()},[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 _=(O,B)=>o({...r,[O]:B}),E=async()=>{x(!0),w(null),b(null);try{const{tokenConfigured:O,cdkConfigured:B,...U}=s,P=Object.fromEntries(Object.entries(r).filter(([R,z])=>U[R]!==z));Object.keys(P).length>0&&await e.connection.call("scripts/settings/set",P),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(""),M()),await S(),b("已保存,下一次安装起生效")}catch(O){w(Ce(O))}finally{x(!1)}},M=async()=>{p("checking");try{p(await e.connection.call("scripts/mirrorchyan/check",{}))}catch(O){p({ok:!1,message:Ce(O)})}};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:O=>_("downloadMirror",O.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:O=>_("mirrorFallback",O.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:O=>h(O.target.value),placeholder:s.cdkConfigured?"已配置;输入新值可替换":"在 Mirror酱 购买后得到的 CDK",autoComplete:"off"}),s.cdkConfigured?n.jsx("span",{className:"badge ok",children:"已配置"}):n.jsx("span",{className:"badge",children:"未配置"}),s.cdkConfigured&&n.jsx("button",{className:"small-button",disabled:m==="checking",onClick:()=>void M(),children:m==="checking"?"检查中…":"检查"})]}),m!==null&&m!=="checking"&&n.jsx("p",{className:"small",style:{color:m.ok?"var(--ok)":"var(--error)"},children:m.message}),n.jsxs("p",{className:"muted small",children:["保存在 dsh 的凭据文件里(",r.cdkRef,"),界面和日志里都不会显示它。"]})]}),n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"GitHub 访问"}),n.jsx("label",{className:"field-label",htmlFor:"gh-token",children:"GitHub Token(可选)"}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{id:"gh-token",className:"text-input",type:"password",value:l,onChange:O=>u(O.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:O=>_("apiBase",O.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:O=>_("keepVersions",Math.max(1,Math.min(10,Number(O.target.value)||1)))}),n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:r.includePrereleases,onChange:O=>_("includePrereleases",O.target.checked)}),"没有正式版时使用预发布版本"]})]}),n.jsxs("div",{className:"key-actions",children:[k!==null&&n.jsx("span",{className:"muted small",children:k}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"primary",disabled:g,onClick:()=>void E(),children:g?"保存中…":"保存"})]}),j!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:j})]})]})}function c7({client:e,initialRepo:t,jobs:s,onDone:i,openSession:r,onClose:o}){const[l,u]=v.useState(t??""),[d,h]=v.useState(null),[m,p]=v.useState(""),[g,x]=v.useState(""),[k,b]=v.useState(!1),[j,w]=v.useState(null),[S,_]=v.useState(null),E=async(P=l)=>{var z;const R=rO(P);if(R===void 0){w("请输入 owner/repo,或粘贴 GitHub 上的仓库、发布或文件链接");return}b(!0),w(null);try{const L=await e.connection.call("scripts/releases",{repo:R.repo,limit:10});u(R.repo),h({...L,branch:R.branch});const A=L.releases.find(H=>H.tag===R.tag),T=A??L.releases.find(H=>!H.prerelease)??L.releases[0];p((T==null?void 0:T.tag)??""),x(((z=T==null?void 0:T.assets.find(H=>H.name===R.asset))==null?void 0:z.name)??(T==null?void 0:T.suggestedAsset)??""),R.tag!==void 0&&A===void 0&&L.releases.length>0&&w(`最近的发布里没有 ${R.tag},已改选最新版本`)}catch(L){h(null),w(Ce(L))}finally{b(!1)}};v.useEffect(()=>{t!==void 0&&E(t)},[t]);const M=d==null?void 0:d.releases.find(P=>P.tag===m),O=d!==null&&(d.branch!==void 0||d.releases.length===0),B=async()=>{if(d!==null){b(!0),w(null);try{const{jobId:P,scriptId:R}=await e.connection.call("scripts/install",{repo:d.repo,...d.branch===void 0?{}:{branch:d.branch}});_({jobId:P,scriptId:R,tag:d.branch===void 0?"默认分支":`${d.branch} 分支`,asset:"源码压缩包"})}catch(P){w(Ce(P))}finally{b(!1)}}},U=async()=>{var P;if(!(d===null||M===void 0||g==="")){b(!0),w(null);try{const{jobId:R,scriptId:z}=await e.connection.call("scripts/install",{repo:d.repo,tag:M.tag,asset:g});_({jobId:R,scriptId:z,tag:M.tag,asset:g,size:(P=M.assets.find(L=>L.name===g))==null?void 0:P.size})}catch(R){w(Ce(R))}finally{b(!1)}}};if(S!==null&&d!==null){const P=s.get(S.scriptId);return n.jsx(fE,{client:e,repo:d.repo,...S,job:(P==null?void 0:P.id)===S.jobId?P:void 0,onDone:()=>i(S.scriptId),openSession:r,onRetry:()=>_(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:P=>{P.preventDefault(),E()},children:[n.jsx("input",{className:"text-input plain","aria-label":"GitHub 仓库",value:l,onChange:P=>u(P.target.value),placeholder:"owner/repo 或 GitHub 链接,例如 MaaAssistantArknights/MaaAssistantArknights",spellCheck:!1,disabled:k}),n.jsx("button",{type:"submit",disabled:k||l.trim()==="",children:k&&d===null?"读取中…":"读取发布"})]}),O&&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 B(),disabled:k,children:["安装",d.branch===void 0?"源码":` ${d.branch} 分支`]})]}),d!==null&&d.releases.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs("label",{className:"field-label",htmlFor:"release-select",children:["版本",d.packId!==void 0&&n.jsxs("span",{className:"chip subtle",children:["官方脚本包 ",d.packId]})]}),n.jsx(Mt,{id:"release-select",value:m,disabled:k,onChange:P=>{var R;p(P),x(((R=d.releases.find(z=>z.tag===P))==null?void 0:R.suggestedAsset)??"")},options:d.releases.map(P=>({value:P.tag,label:`${P.tag}${P.prerelease?"(预发布)":""}`,...P.publishedAt===void 0?{}:{hint:`${P.publishedAt.slice(0,10)} 发布`}}))}),M!==void 0&&n.jsxs("fieldset",{className:"asset-list",disabled:k,children:[n.jsx("legend",{className:"field-label",children:"下载文件"}),M.assets.length===0&&n.jsx("div",{className:"muted small",children:"这个版本没有可下载的文件"}),[...M.assets].sort((P,R)=>+(R.name===M.suggestedAsset)-+(P.name===M.suggestedAsset)).map(P=>n.jsxs("label",{className:`asset-option ${P.name===g?"active":""}`,children:[n.jsx("input",{type:"radio",name:"asset",value:P.name,checked:P.name===g,onChange:()=>x(P.name)}),n.jsx("span",{className:"asset-name",children:P.name}),P.name===M.suggestedAsset&&n.jsx("span",{className:"badge ok",children:"推荐"}),n.jsx("span",{className:"muted small",children:Ta(P.size)})]},P.name))]}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:(M==null?void 0:M.suggestedAsset)===void 0?"没有自动匹配到适合本机的文件,请手动选择。":"已按本机(Windows x64)选好文件。"}),n.jsx("span",{className:"spacer"}),n.jsxs("button",{className:"primary",onClick:()=>void U(),disabled:k||g==="",children:["安装 ",M==null?void 0:M.tag]})]})]}),j!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:j})]})]})}function u7({client:e,initialRid:t,jobs:s,onDone:i,openSession:r,onGitHub:o,onClose:l}){const[u,d]=v.useState(""),h=d7(e,u),[m,p]=v.useState(null),[g,x]=v.useState(null),[k,b]=v.useState(!1),[j,w]=v.useState(null),[S,_]=v.useState(null);v.useEffect(()=>{e.connection.call("scripts/settings",{}).then(U=>x(U.cdkConfigured),()=>x(null))},[e]);const E=async U=>{b(!0),w(null);try{p(await e.connection.call("scripts/mirrorchyan/lookup",{rid:U}))}catch(P){p(null),w(Ce(P))}finally{b(!1)}};v.useEffect(()=>{t!==void 0&&E(t)},[t]);const M=async()=>{if(m!==null){b(!0),w(null);try{_(await e.connection.call("scripts/install",{mirrorchyan:m.rid}))}catch(U){w(Ce(U))}finally{b(!1)}}};if(S!==null&&m!==null){const U=s.get(S.scriptId);return n.jsx(fE,{client:e,repo:`Mirror酱 · ${m.rid}`,tag:m.version,asset:`${m.name??m.rid}(Mirror酱 完整包)`,job:(U==null?void 0:U.id)===S.jobId?U:void 0,onDone:()=>i(S.scriptId),openSession:r,onRetry:()=>_(null),onClose:l})}const O=u.trim(),B=/^[\w.-]{1,100}$/.test(O)&&!(h.items??[]).some(U=>U.rid.toLowerCase()===O.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:U=>d(U.target.value),placeholder:"例如 原神、鸣潮、BetterGI、MAA",spellCheck:!1,autoFocus:!0}),n.jsx(h7,{results:h,selected:m==null?void 0:m.rid,disabled:k,onPick:U=>void E(U)}),B&&n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),n.jsxs("button",{className:"small-button",disabled:k,onClick:()=>void E(O),children:["按资源 id 查询 ",O]})]}),m!==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:m.name??m.rid}),n.jsxs("span",{className:"badge",children:["Mirror酱 ",m.rid]}),n.jsxs("span",{className:"muted small",children:["最新 ",m.version]})]}),m.description!==void 0&&n.jsx("p",{className:"muted small mirror-desc",children:m.description}),g===!1&&n.jsx("div",{className:"notice info left small",children:n.jsxs("span",{children:["还没有填写 Mirror酱 CDK,没法从 Mirror酱 下载。",m.repo!==void 0?"也可以从 GitHub 安装,填了 CDK 后它的更新会走 Mirror酱。":""]})}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:m.repo===void 0?"":`GitHub:${m.repo}`}),n.jsx("span",{className:"spacer"}),m.repo!==void 0&&n.jsx("button",{className:"small-button",disabled:k,onClick:()=>o(m.repo),children:"从 GitHub 安装"}),n.jsxs("button",{className:"primary",onClick:()=>void M(),disabled:k||g===!1,children:["安装 ",m.version]})]})]}),j!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:j})]})]})}function d7(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 h7({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(m=>n.jsxs("li",{className:m.rid===t?"active":"",children:[n.jsxs("div",{className:"mirror-result-main",children:[n.jsxs("span",{className:"mirror-result-name",children:[m.name,n.jsx("span",{className:"chip subtle",children:m.rid}),m.installed&&n.jsx("span",{className:"badge ok",children:"已在脚本库"})]}),m.description!==""&&n.jsx("span",{className:"muted small",children:m.description})]}),n.jsx("button",{className:"small-button",disabled:s,onClick:()=>r(m.rid),children:o})]},m.rid))}),!l&&d.length>i&&n.jsxs("button",{className:"link-button small",onClick:()=>u(!0),children:["还有 ",d.length-i," 个"]})]})}const Zj=["resolving","downloading","verifying","extracting","checking","done"];function fE({client:e,repo:t,tag:s,asset:i,size:r,job:o,onDone:l,openSession:u,onRetry:d,onClose:h}){const m=(o==null?void 0:o.phase)??"queued",p=m==="done"?o==null?void 0:o.setup:void 0,g=o===void 0||o.endedAt===void 0,x=m7(o==null?void 0:o.received),k=(o==null?void 0:o.total)??r,b=k!==void 0&&k>0&&(o==null?void 0:o.received)!==void 0?Math.min(1,o.received/k):void 0,j=v.useRef(-1),w=Zj.indexOf(m);w>j.current&&(j.current=w);const S=p!==void 0?"交给 agent 安装":m==="done"?"安装完成":m==="failed"?"安装失败":m==="cancelled"?"已取消安装":"正在安装",_=E=>m==="done"||E<j.current?"done":E===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:S}),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:Ta(r)})]}),n.jsx("ol",{className:"install-steps",children:Zj.slice(0,-1).map((E,M)=>{const O=_(M);return n.jsxs("li",{className:`install-step ${O}`,children:[n.jsx("span",{className:"install-step-mark",children:O==="done"?n.jsx(ee,{name:"check"}):O==="stopped"?n.jsx(ee,{name:"close"}):M+1}),n.jsx("span",{children:jc[E]})]},E)})}),g&&n.jsxs("div",{className:"install-bar",children:[n.jsx("div",{className:`progress ${m==="downloading"&&b!==void 0?"":"indeterminate"}`,"aria-hidden":"true",children:n.jsx("span",{style:m==="downloading"&&b!==void 0?{width:`${(b*100).toFixed(1)}%`}:void 0})}),n.jsxs("div",{className:"install-numbers muted small",children:[n.jsx("span",{children:o===void 0?"等待开始…":o.message??jc[m]}),m==="downloading"&&(o==null?void 0:o.received)!==void 0&&n.jsxs("span",{className:"install-bytes",children:[Ta(o.received),k!==void 0?` / ${Ta(k)}`:"",b!==void 0?` · ${Math.floor(b*100)}%`:"",x!==void 0?` · ${Ta(Math.round(x))}/s`:"",x!==void 0&&x>0&&k!==void 0?` · 还要 ${f7((k-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} 的安装程序。`:m==="done"?`已安装 ${(o==null?void 0:o.version)??s}。`:""}),n.jsx("span",{className:"spacer"}),g&&o!==void 0&&n.jsx("button",{className:"small-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:o.id}).catch(()=>{}),children:"取消安装"}),(m==="failed"||m==="cancelled")&&n.jsx("button",{className:"small-button",onClick:d,children:"重新选择"}),(p==null?void 0:p.sessionId)!==void 0&&n.jsx("button",{className:"primary small-button",onClick:()=>u(p.sessionId),children:"查看对话"}),m==="done"&&p===void 0&&n.jsx("button",{className:"primary small-button",onClick:l,children:"查看脚本"})]})]})}function m7(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 f7(e){return!Number.isFinite(e)||e<0?"—":e<60?`${Math.max(1,Math.round(e))} 秒`:`${Math.floor(e/60)} 分 ${Math.round(e%60)} 秒`}function p7({client:e,onImported:t,onClose:s}){const[i,r]=v.useState(""),[o,l]=v.useState(""),[u,d]=v.useState(!1),[h,m]=v.useState(null),p=async()=>{m(null);try{const x=await hh(e,{kind:"folder",title:"选择脚本所在的文件夹",defaultPath:i.trim().replace(/^"|"$/g,"")});x!==null&&r(x)}catch(x){m(Ce(x))}},g=async()=>{d(!0),m(null);try{const x=await e.connection.call("scripts/import",{path:i.trim().replace(/^"|"$/g,""),...o.trim()===""?{}:{name:o.trim()}});t(x.id)}catch(x){m(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 _g({client:e,job:t,compact:s=!1}){const i=t.endedAt===void 0,r=t.total!==void 0&&t.total>0&&t.received!==void 0?Math.min(1,t.received/t.total):void 0,o=t.kind==="env-fix"?"修复环境":t.kind==="update"?"更新":"安装";return n.jsxs("div",{className:`job ${t.phase}${s?" compact":""}`,role:"status",children:[n.jsxs("div",{className:"job-line",children:[n.jsxs("span",{className:"job-phase",children:[o," · ",t.setup!==void 0&&t.phase==="done"?"已交给 agent 安装":jc[t.phase],t.version!==void 0&&t.phase==="done"?` ${t.version}`:""]}),r!==void 0&&i&&n.jsxs("span",{className:"job-bytes",children:[Ta(t.received??0)," / ",Ta(t.total??0)]}),i&&n.jsx("button",{className:"link-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:t.id}).catch(()=>{}),children:"取消"})]}),i&&n.jsx("div",{className:`progress ${r===void 0?"indeterminate":""}`,"aria-hidden":"true",children:n.jsx("span",{style:r===void 0?void 0:{width:`${(r*100).toFixed(1)}%`}})}),!s&&t.message!==void 0&&(i||t.setup!==void 0)&&n.jsx("div",{className:"job-message muted small",children:t.message}),t.error!==void 0&&n.jsx("div",{className:"job-error small",children:t.error})]})}const g7={install:"安装来源",pack:"脚本包",known:"已知项目",user:"你设置的"};function pE({client:e,script:t,disabled:s,act:i}){const[r,o]=v.useState(null),[l,u]=v.useState(""),[d,h]=v.useState(null),m=t.channels.github,p=t.channels.mirrorchyan,g=(j,w)=>i("channel",async()=>{await e.connection.call("scripts/source/set",w==="reset"?{id:t.id,reset:[j]}:j==="repo"?{id:t.id,repo:w}:{id:t.id,mirrorchyan:w}),o(null);const S=j==="repo"?"GitHub":"Mirror酱";return w===null?`已不再从 ${S} 更新`:w==="reset"?`${S} 更新渠道已恢复自动`:`${S} 更新渠道已设为 ${w}`}),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}),k=(j,w)=>j==="repo"?/^[\w.-]+\/[\w.-]+$/.test(w):/^[\w.-]{1,100}$/.test(w),b=(j,w,S,_,E)=>n.jsxs(n.Fragment,{children:[n.jsx("dt",{children:w}),n.jsx("dd",{children:r!==j?n.jsxs(n.Fragment,{children:[S!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{children:S.text}),n.jsxs("span",{className:"muted small",children:["(",g7[S.from],")"]})]}):n.jsx("span",{className:"muted small",children:_}),(S==null?void 0:S.from)!=="install"&&n.jsx("button",{className:"ghost small-button",disabled:s,onClick:()=>{u((S==null?void 0:S.text)??""),o(j)},children:S===void 0?"设置":"修改"}),j==="mirrorchyan"&&S===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":`${w}更新渠道`,value:l,onChange:M=>u(M.target.value),placeholder:E,spellCheck:!1,autoFocus:!0}),n.jsx("button",{className:"primary small-button",disabled:s||!k(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:"恢复自动"}),S!==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:[b("repo","GitHub",m===void 0?void 0:{text:m.repo,from:m.from},"未设置:填写它的 GitHub 仓库","owner/repo,例如 babalae/better-genshin-impact"),b("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 x7({client:e,script:t,disabled:s,busy:i,now:r,act:o}){const[l,u]=v.useState(!1),d=t.localVersion,h=t.update,m=t.channels.github!==void 0||t.channels.mirrorchyan!==void 0;return n.jsxs("div",{className:"local-update",children:[n.jsxs("dl",{className:"local-facts",children:[n.jsx("dt",{children:"当前版本"}),n.jsx("dd",{children:d!==void 0?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"version-name",children:d.version}),n.jsx("span",{className:"muted small",children:d.from==="更新"?"(由 MultiGameAssistant 更新)":`(读自 ${d.from})`})]}):n.jsx("span",{className:"muted small",children:"认不出这个目录的版本:检查更新时会当作可以更新"})}),n.jsx(pE,{client:e,script:t,disabled:s,act:o})]}),l?n.jsxs("div",{className:"local-confirm",children:[n.jsxs("p",{className:"small",children:["将在 ",n.jsx("code",{children:t.dir})," 里更新到 ",h==null?void 0:h.latest,":被替换的程序文件先备份到工具目录(可以撤销),已有的配置文件不动。请先关闭这个脚本。"]}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>u(!1),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:s,onClick:()=>void o("update",async()=>(u(!1),(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0)),children:"确认更新"})]})]}):n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[h===void 0?"还没有检查过更新":h.available?`有新版本 ${h.latest}`:`已是最新(${h.latest})`,h!==void 0&&` · ${vt(h.checkedAt,r)}检查`]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:s||!m,onClick:()=>void o("check",async()=>{const p=await e.connection.call("scripts/checkUpdate",{id:t.id});return p.available?`发现新版本 ${p.latest}${p.current===void 0?"(认不出当前版本)":`,当前 ${p.current}`}`:"已是最新版本"}),children:i==="check"?"检查中…":"检查更新"}),n.jsx("button",{className:"primary small-button",disabled:s||(h==null?void 0:h.available)!==!0,onClick:()=>u(!0),children:"更新"})]}),t.undo!==void 0&&n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:["上次更新:",t.undo.from??"(未知版本)"," → ",t.undo.to," · ",vt(t.undo.at,r)]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:s,onClick:()=>void o("restore",async()=>{const p=await e.connection.call("scripts/restore",{id:t.id});return`已撤销,换回了更新前的文件${p.localVersion===void 0?"":`(${p.localVersion.version})`}`}),children:i==="restore"?"撤销中…":"撤销上次更新"})]})]})}function v7({client:e,script:t,openSession:s}){var A,T,H;const i=Se(e.connection.status),r=Se(e.capabilities),o=vn(6e4),[l,u]=v.useState([]),[d,h]=v.useState(0),[m,p]=v.useState(!1),[g,x]=v.useState(null),[k,b]=v.useState(null),[j,w]=v.useState([]),[S,_]=v.useState(!1);v.useEffect(()=>e.connection.on("packs/changed",()=>h(F=>F+1)),[e]),v.useEffect(()=>{if(i.state!=="open"||!r.has("packs"))return;let F=!0;return e.connection.call("packs/drafts",{scriptId:t.id}).then(V=>{F&&u(V.items)}).catch(()=>{}),()=>{F=!1}},[e,t.id,i.state,r,d]),v.useEffect(()=>{if(i.state!=="open"||!r.has("packs")||t.packId===void 0){w([]);return}let F=!0;return e.connection.call("packs/history",{packId:t.packId}).then(V=>{F&&w(V.items)}).catch(()=>{F&&w([])}),()=>{F=!1}},[e,t.packId,i.state,r,d]);const E=async F=>{p(!0),x(null);try{await F()}catch(V){x(Ce(V))}finally{p(!1)}},M=()=>E(async()=>{const{sessionId:F}=await e.connection.call("agents/home",{agentId:"scripts",focus:{scripts:[t.id]}});await e.connection.call("session/prompt",{sessionId:F,requestId:`analyze-${Date.now()}`,mode:"queue",text:`请按 script-analysis 技能分析脚本库里的「${t.name}」(id: ${t.id}),为它生成脚本包:先找到并读完这个项目自己的文档(目录里的说明、仓库 README、Wiki、文档站),再结合代码核对补全,实在没有文档才直接看代码。写好给我看的使用说明(每个任务和参数是什么、每个功能怎么开启、配置文件怎么设置、运行前检查什么、常见问题),给 agent 的备注写进 SKILL.md。用 pack_propose 保存(直接生效),docs 里写明依据的文档。`}),s(F)}),O=F=>E(async()=>{const{sessionId:V}=await e.connection.call("scripts/packReview",{id:t.id,decision:F});V!==void 0&&s(V)}),B=F=>E(async()=>{const{sessionId:V}=await e.connection.call("scripts/optimize",{id:t.id,decision:F});V!==void 0&&s(V)}),U=F=>E(async()=>{_(!1),await e.connection.call("packs/restore",{packId:t.packId,version:F.id}),_(!0)}),P=F=>`${F.builtin===!0?"官方脚本包":`${vt(F.at??o,o)}被替换`} · 任务:${F.tasks.map(V=>V.title).join("、")||"无"}`,R=l[0],z=j[0],L=(A=t.optimize)==null?void 0:A.due;return n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"脚本包"}),n.jsx("p",{className:"muted small",children:t.packId===void 0?"还没有脚本包:agent 还不知道怎么运行它。":`使用脚本包 ${t.packId}。`})]}),n.jsxs("span",{className:"key-actions",children:[t.packId!==void 0&&n.jsxs("button",{className:"small-button",disabled:m||i.state!=="open",onClick:()=>void B("run"),title:"用运行攒下的信息:重新总结脚本包、调「多久没动静算卡住」、把走通的步骤存成只给它用的技能",children:[n.jsx(ee,{name:"sparkles"}),"优化脚本"]}),t.packId===void 0&&n.jsxs("button",{className:"small-button",disabled:m||i.state!=="open",onClick:()=>void M(),children:[n.jsx(ee,{name:"sparkles"}),"让 agent 分析"]})]})]}),t.packReview!==void 0&&R===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:m,onClick:()=>void O("keep"),children:"不用改"}),n.jsx("button",{className:"primary small-button",disabled:m||i.state!=="open",onClick:()=>void O("check"),children:"让 agent 检查"})]})]}),L!==void 0&&t.packReview===void 0&&R===void 0&&n.jsxs("div",{className:"notice left pack-review",children:[n.jsx(ee,{name:"sparkles"}),n.jsxs("span",{children:[L==="updated"?`${t.name} 更新后已经跑通了。`:`${t.name} ${((T=t.optimize)==null?void 0:T.at)===void 0?"装好以来":"上次优化以来"}已经跑成功 ${((H=t.optimize)==null?void 0:H.runs)??0} 次。`,"要让 agent 用这些运行记录优化它吗:重新总结脚本包、调卡住时间、把走通的步骤存成技能。"]}),n.jsxs("span",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:m,onClick:()=>void B("keep"),children:"这次不用"}),n.jsx("button",{className:"primary small-button",disabled:m||i.state!=="open",onClick:()=>void B("run"),children:"优化脚本"})]})]}),z!==void 0&&n.jsxs("div",{className:"pack-history",children:[n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[z.builtin===!0?"现在用的是自己写的脚本包,可以换回":"上一版脚本包:",P(z)]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:m||i.state!=="open",title:"现在用的这一版会留在历史里,可以再恢复回来",onClick:()=>void U(z),children:z.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(F=>n.jsxs("li",{children:[P(F)," ",n.jsx("button",{className:"link-button",disabled:m||i.state!=="open",onClick:()=>void U(F),children:"恢复"})]},F.id))})]}),S&&n.jsx("p",{className:"muted small",children:"已恢复。刚才用的那一版留在历史里,可以再恢复回来。"})]}),R!==void 0&&n.jsxs("div",{className:"draft",children:[n.jsxs("div",{className:"draft-head",children:[n.jsx("span",{className:"badge warn",children:"待确认的草稿"}),n.jsxs("span",{className:"muted small",children:[vt(R.proposedAt,o),"提交 · 任务:",R.tasks.map(F=>F.title).join("、")||"无"]})]}),n.jsx("p",{className:"draft-summary",children:R.summary}),R.docs!==void 0&&R.docs.length>0&&n.jsxs("details",{className:"draft-docs",children:[n.jsxs("summary",{className:"muted small",children:["依据的文档(",R.docs.length,")"]}),n.jsx("ul",{children:R.docs.map(F=>n.jsxs("li",{children:[n.jsx("code",{children:F.source}),":",F.used]},F.source))})]}),R.noDocs!==void 0&&n.jsxs("p",{className:"muted small",children:["没有找到项目文档,按代码分析:",R.noDocs]}),R.current!==void 0&&n.jsxs("p",{className:"muted small",children:["接受后会替换当前的",R.current.builtin?"官方":"","脚本包(之前的版本会保留在历史里)。"]}),n.jsxs("div",{className:"segmented draft-tabs",children:[n.jsxs("label",{className:k==="manifest"?"active":"",children:[n.jsx("input",{type:"checkbox",checked:k==="manifest",onChange:()=>b(F=>F==="manifest"?null:"manifest")}),"adg.script.yaml"]}),n.jsxs("label",{className:k==="skill"?"active":"",children:[n.jsx("input",{type:"checkbox",checked:k==="skill",onChange:()=>b(F=>F==="skill"?null:"skill")}),"SKILL.md"]})]}),k!==null&&n.jsx("pre",{className:"draft-text",children:k==="manifest"?R.manifest:R.skill}),n.jsxs("div",{className:"key-actions",children:[R.sessionId!==void 0&&n.jsx("button",{className:"link-button",onClick:()=>s(R.sessionId),children:"查看分析过程"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:m,onClick:()=>void E(()=>e.connection.call("packs/reject",{packId:R.packId})),children:"拒绝"}),n.jsx("button",{className:"primary small-button",disabled:m,onClick:()=>void E(()=>e.connection.call("packs/accept",{packId:R.packId})),children:"接受并使用"})]})]}),g!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:g})]})]})}function y7({client:e,script:t}){const s=Se(e.connection.status),i=vn(15e3),[r,o]=v.useState(void 0),[l,u]=v.useState(0),[d,h]=v.useState(30),[m,p]=v.useState(null);v.useEffect(()=>e.connection.on("guard/changed",()=>u(k=>k+1)),[e]),v.useEffect(()=>{if(s.state!=="open")return;let k=!0;return e.connection.call("guard/grants",{}).then(b=>{k&&o(b.items.find(j=>j.scriptId===t.id))}).catch(()=>{}),()=>{k=!1}},[e,t.id,s.state,l]);const g=r!==void 0&&r.expiresAt>i?r:void 0,x=k=>{p(null),k().catch(b=>p(Ce(b)))};return n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"修改脚本文件"}),n.jsx("p",{className:"muted small",children:"默认禁止:agent 只能改脚本包声明的配置文件、只能用官方更新。确实需要改代码时,在这里临时允许。"})]}),g===void 0?n.jsx("span",{className:"badge ok",children:"受保护"}):n.jsx("span",{className:"badge warn",children:"已允许"})]}),g===void 0?n.jsxs("div",{className:"key-actions",children:[n.jsxs("label",{className:"check-label",children:["允许 agent 修改",n.jsx(Mt,{inline:!0,"aria-label":"允许多久",value:String(d),onChange:k=>h(Number(k)),options:[15,30,60,120].map(k=>({value:String(k),label:`${k} 分钟`}))})]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>x(()=>e.connection.call("guard/grant",{scriptId:t.id,minutes:d})),children:"临时允许"})]}):n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:["还剩约 ",Math.max(1,Math.round((g.expiresAt-i)/6e4))," 分钟"]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"danger-outline small-button",onClick:()=>x(()=>e.connection.call("guard/revoke",{scriptId:t.id})),children:"立即收回"})]}),m!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:m})]})]})}function b7({client:e,script:t}){const s=Se(e.connection.status),i=vn(6e4),r=f1(e,t.id),[o,l]=v.useState(void 0),[u,d]=v.useState(null),[h,m]=v.useState(0),[p,g]=v.useState(null),[x,k]=v.useState(null),[b,j]=v.useState(null),[w,S]=v.useState(!1),[_,E]=v.useState(null),[M,O]=v.useState(null),[B,U]=v.useState(null),P=(r==null?void 0:r.items.find(F=>F.id===o))??(r==null?void 0:r.items.find(F=>F.id===r.current));v.useEffect(()=>{g(null),j(null)},[P==null?void 0:P.id]),v.useEffect(()=>e.connection.on("runs/state",F=>{F.scriptId!==t.id||F.endedAt===void 0||(m(V=>V+1),U(V=>V===null||V.runId!==F.id?V:(E(F.state==="succeeded"?`修改已同步到「${V.profile}」`:F.state==="cancelled"?"已放弃这次修改,本地配置没变":`没能保存修改:${F.outcome??"脚本窗口异常退出"}`),null)))}),[e,t.id]);const R=async F=>{if(B!==null){U({...B,finishing:F});try{F==="done"?await e.connection.call("configs/done",{runId:B.runId}):await e.connection.call("runs/stop",{runId:B.runId})}catch(V){O(Ce(V)),U(null)}}};v.useEffect(()=>{if(s.state!=="open"||P===void 0)return;let F=!0;return e.connection.call("configs/status",{scriptId:t.id,profile:P.id}).then(V=>{F&&(d(V),O(null))}).catch(V=>{F&&O(Ce(V))}),()=>{F=!1}},[e,t.id,t.packId,s.state,h,P==null?void 0:P.id]);const z=async F=>{S(!0),O(null),E(null);try{const V=await F();typeof V=="string"&&E(V),m(D=>D+1)}catch(V){O(Ce(V))}finally{S(!1)}},L=((r==null?void 0:r.items.length)??0)>1,A=P!==void 0&&P.id===(r==null?void 0:r.current),T=(u==null?void 0:u.files.filter(F=>F.local))??[],H=u!==null&&u.profile.id===(P==null?void 0:P.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:w||B!==null||s.state!=="open"||P===void 0,onClick:()=>void z(async()=>{const F=await e.connection.call("configs/open",{scriptId:t.id,profile:P.id});if(F.endedAt===void 0)U({runId:F.id,profile:P.name,finishing:null});else if(F.state!=="succeeded")throw new Error(F.outcome??"没能打开脚本的设置界面")}),children:[n.jsx(ee,{name:"settings"}),"打开脚本修改设置"]})]}),r!==null&&(L||((u==null?void 0:u.files.length)??0)>0)&&n.jsxs("div",{className:"profile-bar",children:[n.jsxs("div",{className:"profile-chips",role:"tablist","aria-label":"配置",children:[r.items.map(F=>n.jsxs("button",{role:"tab","aria-selected":F.id===(P==null?void 0:P.id),className:`profile-chip ${F.id===(P==null?void 0:P.id)?"active":""}`,onClick:()=>l(F.id),children:[F.name,F.id===r.current&&L&&n.jsx("span",{className:"profile-current",title:"不指定配置的运行都用它",children:"当前使用"})]},F.id)),n.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>k(F=>F===null?{name:"",source:"copy",dir:""}:null),children:"+ 另存一份"})]}),P!==void 0&&L&&b===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:w,onClick:()=>void z(async()=>(await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:P.id,current:!0}),`现在默认使用「${P.name}」`)),children:"设为当前使用"}),n.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>j(P.name),children:"改名"}),P.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:w,onClick:()=>void z(async()=>(await e.connection.call("configs/profiles/remove",{scriptId:t.id,profile:P.id}),g(null),l(void 0),`已删除「${P.name}」`)),children:"确认删除"})]}):n.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>g("remove"),children:"删除"}))]}),P!==void 0&&b!==null&&n.jsxs("div",{className:"key-input",children:[n.jsx("input",{className:"text-input plain","aria-label":"新名字",value:b,maxLength:30,autoFocus:!0,onChange:F=>j(F.target.value)}),n.jsx("button",{className:"small-button",onClick:()=>j(null),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:w||b.trim()==="",onClick:()=>void z(async()=>{await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:P.id,name:b.trim()}),j(null)}),children:"保存"})]}),x!==null&&P!==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:F=>k({...x,name:F.target.value})}),n.jsxs("fieldset",{className:"asset-list",disabled:w,children:[n.jsx("legend",{className:"field-label",children:"内容从哪里来"}),[["copy",`复制「${P.name}」`,"复制后可以「打开脚本修改设置」单独改它"],["original","读取原项目现在的配置","在脚本自己的界面里设好了另一套设置时用"],["folder","从别的文件夹读取",`另一份同样的脚本,或存下来的配置;只读 ${(u==null?void 0:u.files.map(F=>F.file).join("、"))||"脚本包声明的配置文件"}`]].map(([F,V,D])=>n.jsxs("label",{className:`asset-option choice-option ${x.source===F?"active":""}`,children:[n.jsx("input",{type:"radio",name:"profile-source",value:F,checked:x.source===F,onChange:()=>k({...x,source:F})}),n.jsxs("span",{className:"choice-text",children:[n.jsx("span",{children:V}),n.jsx("span",{className:"muted small",children:D})]})]},F))]}),x.source==="folder"&&n.jsx("input",{className:"text-input plain","aria-label":"文件夹",placeholder:"文件夹的完整路径,例如 D:\\MAA2",value:x.dir,onChange:F=>k({...x,dir:F.target.value})}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>k(null),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:w||x.name.trim()===""||x.source==="folder"&&x.dir.trim()==="",onClick:()=>void z(async()=>{const F=x.source==="copy"?{kind:"copy",profile:P.id}:x.source==="original"?{kind:"original"}:{kind:"folder",dir:x.dir.trim()},V=await e.connection.call("configs/profiles/create",{scriptId:t.id,name:x.name.trim(),from:F});return k(null),l(V.profile.id),`已保存「${V.profile.name}」:${V.files.length>0?V.files.join("、"):"还没有配置文件"}`}),children:"保存"})]})]})]}),H!==null&&n.jsxs(n.Fragment,{children:[H.drift.length>0&&n.jsxs("div",{className:"notice warn-box left",children:[n.jsx(ee,{name:"info"}),n.jsxs("span",{children:["原项目的配置在导入后改过(",H.drift.join("、"),"),可能是在脚本自己的界面里改的。本应用仍按「",H.profile.name,"」运行;需要的话可以导入。"]})]}),n.jsx(La,{id:`config.files.${t.id}`,title:"配置文件",count:H.files.length,children:n.jsxs("ul",{className:"version-list",children:[H.files.map(F=>n.jsx(k7,{client:e,scriptId:t.id,profile:H.profile.id,file:F},`${H.profile.id}:${F.file}`)),H.files.length===0&&n.jsx("li",{className:"muted small",children:"脚本包没有声明配置文件"})]})}),n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[H.importedAt===void 0?"还没有导入":`${vt(H.importedAt,i)}${L?`存的「${H.profile.name}」`:"从原项目导入"}`,T.length>0&&" · ",T.length>0&&n.jsx("button",{className:"link-button",onClick:()=>{var F;return void((F=navigator.clipboard)==null?void 0:F.writeText(H.dir))},children:"复制本地配置目录"})]}),n.jsx("span",{className:"spacer"}),p!=="import"?n.jsx("button",{className:"small-button",disabled:w,onClick:()=>g("import"),children:"导入原项目设置"}):n.jsxs(n.Fragment,{children:[n.jsxs("span",{className:"muted small",children:["会用原项目当前的配置覆盖「",H.profile.name,"」"]}),n.jsx("button",{className:"small-button",onClick:()=>g(null),children:"取消"}),n.jsx("button",{className:"primary small-button",disabled:w,onClick:()=>void z(async()=>{const F=await e.connection.call("configs/import",{scriptId:t.id,profile:H.profile.id});return g(null),F.imported.length>0?`已导入到「${H.profile.name}」:${F.imported.join("、")}`:"原项目里还没有这些配置文件"}),children:"确认导入"})]})]})]}),_!==null&&n.jsx("div",{className:"notice info left small",children:_}),B!==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," 的设置窗口已经打开,用的是本地配置「",B.profile,"」。在那个窗口里改好、保存后,回到这里点「我已手动改好」:脚本窗口会关闭,修改同步到「",B.profile,"」,之后的运行和编排都用它。"]}),n.jsx("p",{className:"muted small",children:"直接关掉脚本窗口也会保存。原项目里的配置不会被改动。"}),B.finishing!==null&&n.jsxs("p",{className:"dialog-progress",children:[n.jsx("span",{className:"tool-spinner","aria-hidden":!0}),B.finishing==="done"?"正在关闭脚本窗口并保存修改…":"正在关闭脚本窗口,不保存…"]}),n.jsxs("div",{className:"key-actions",children:[n.jsx("button",{className:"small-button",disabled:B.finishing!==null,onClick:()=>void R("discard"),children:"放弃修改"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"primary small-button",disabled:B.finishing!==null,onClick:()=>void R("done"),children:B.finishing==="done"?"保存中…":"我已手动改好"})]})]})}),M!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:M})]})]})}function k7({client:e,scriptId:t,profile:s,file:i}){const[r,o]=v.useState(!1),[l,u]=v.useState(null),[d,h]=v.useState(null),m=()=>{o(p=>!p),!(l!==null||!i.local)&&e.connection.call("configs/read",{scriptId:t,file:i.file,profile:s}).then(u,p=>h(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:m,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?`
248
+ …(太长,只显示前一部分)`:""]}))]})}const Wj=e=>`data:${e.mediaType};base64,${e.data}`;function j7({client:e,scriptId:t,scriptName:s,openSession:i}){const r=Se(e.connection.status),[o,l]=v.useState(null),[u,d]=v.useState(""),[h,m]=v.useState(""),[p,g]=v.useState(""),[x,k]=v.useState(!1),[b,j]=v.useState(null),[w,S]=v.useState(!1),[_,E]=v.useState(null),[M,O]=v.useState(!1),[B,U]=v.useState(null),[P,R]=v.useState(!1),[z,L]=v.useState(null);v.useEffect(()=>{if(r.state!=="open")return;let Y=!0;return e.connection.call("configs/launch",{scriptId:t}).then(Q=>{Y&&(l(Q),d(Q.settings.pcExe??""),m(Q.settings.pcProcess??""),g(Q.settings.androidPackage??""))}).catch(Q=>{Y&&j(Ce(Q))}),()=>{Y=!1}},[e,t,r.state]);const A=(o==null?void 0:o.settings.androidPackage)??(o==null?void 0:o.game.androidPackage);v.useEffect(()=>{if(r.state!=="open"||A===void 0){L(null);return}let Y=!0;return e.connection.call("games/android/app",{package:A}).then(Q=>{Y&&L(Q)},()=>{Y&&L(null)}),()=>{Y=!1}},[e,A,r.state,B]);const T=async Y=>{k(!0),j(null),S(!1);try{l(await e.connection.call("configs/launch/set",{scriptId:t,...Y})),S(!0),("pcExe"in Y||"androidPackage"in Y)&&wg()}catch(Q){j(Ce(Q))}finally{k(!1)}},H=async Y=>{d(Y),await T({pcExe:Y})},F=async()=>{O(!0),j(null),S(!1),E(null);try{const Y=await e.connection.call("configs/launch/locate",{scriptId:t});E(Y),Y.candidates.length===1&&await H(Y.candidates[0].path)}catch(Y){j(Ce(Y))}finally{O(!1)}},V=async Y=>{g(Y),await T({androidPackage:Y})},D=async()=>{R(!0),j(null),S(!1),U(null);try{const Y=await e.connection.call("games/android/locate",{scriptId:t});U(Y);const Q=Y.candidates.filter(ie=>ie.score>=80);Q.length===1&&Y.candidates.length===1&&await V(Q[0].package),wg()}catch(Y){j(Ce(Y))}finally{R(!1)}},q=async()=>{j(null);try{const{sessionId:Y}=await e.connection.call("agents/home",{agentId:"main",focus:{scripts:[t]}});await e.connection.call("session/prompt",{sessionId:Y,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;没找到就在各个磁盘上搜索名为 ${(_==null?void 0:_.exe)??(o==null?void 0:o.game.pcProcess)??"游戏进程名"} 的程序(可以问我装在哪个盘)。找到后告诉我路径和你怎么确认的,再用 game_path_set 保存。`}),i(Y)}catch(Y){j(Ce(Y))}},te=async()=>{j(null);try{const Y=await hh(e,{kind:"file",title:"选择游戏程序",defaultPath:u.trim()===""?void 0:u.trim(),filterName:"程序",extensions:["exe"]});Y!==null&&await H(Y)}catch(Y){j(Ce(Y))}};if(o===null)return b===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:b})]})});const{settings:G,game:K,uses:Z}=o;return!Z.adb&&!Z.desktop?null:n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsxs("h3",{children:["启动游戏",K.name===void 0?"":`:${K.name}`]}),n.jsxs("p",{className:"muted small",children:["有的脚本不会自己打开游戏或模拟器。运行前,本应用会先启动模拟器(模拟器任务),再按这里的设置启动游戏;游戏已经开着、或脚本自己会启动时不会重复启动。",K.selfLaunch,"。"]})]})}),n.jsx("label",{className:"field-label",htmlFor:`launch-mode-${t}`,children:"运行前由谁启动游戏"}),n.jsx(Mt,{id:`launch-mode-${t}`,value:G.mode,disabled:x,onChange:Y=>void T({mode:Y}),options:[{value:"auto",label:"自动(推荐)",hint:"脚本自己不会启动游戏时,由本应用启动"},{value:"platform",label:"总是由本应用启动",hint:"游戏没开时先打开它"},{value:"off",label:"不启动",hint:"交给脚本或我自己"}]}),G.mode!=="off"&&Z.adb&&n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"field-label",htmlFor:`launch-pkg-${t}`,children:"模拟器里的游戏包名(模拟器任务)"}),n.jsxs("div",{className:"key-input",children:[(z==null?void 0:z.icon)!==void 0&&n.jsx("img",{className:"app-icon",src:Wj(z.icon),alt:"",title:z.label,draggable:!1}),n.jsx("input",{id:`launch-pkg-${t}`,className:"text-input plain",value:p,onChange:Y=>g(Y.target.value),placeholder:K.androidPackage??"例如 com.example.game(不填就不在模拟器里启动游戏)",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:x,onClick:()=>void T({androidPackage:p.trim()===""?null:p.trim()}),children:"保存"})]}),(z==null?void 0:z.label)!==void 0&&n.jsxs("p",{className:"muted small",children:["模拟器里的「",z.label,"」",G.androidPackage===void 0?"(脚本包默认的包名)":""]}),n.jsxs("div",{className:"button-row",children:[n.jsx("button",{className:"small-button",disabled:x||P,onClick:()=>void D(),children:P?"正在查找…":"在模拟器里查找"}),K.androidPackage!==void 0&&n.jsxs("span",{className:"muted small",children:["默认 ",K.androidPackage,";装的是 B 服、国际服等其他版本时,查找一下或在上面改。"]})]}),P&&n.jsx("p",{className:"muted small",children:"模拟器没开时会先启动它,然后读出装了哪些应用(第一次要读每个应用的名字和图标,会慢一些)。"}),B!==null&&B.candidates.length===0&&n.jsxs("p",{className:"muted small",children:["模拟器(",B.device,")里装了 ",B.installed," 个应用,没有一个像",K.name??"这个游戏","。先在模拟器里装好游戏,或者直接填包名。"]}),B!==null&&B.candidates.length===1&&G.androidPackage===B.candidates[0].package&&n.jsxs("p",{className:"muted small",children:["在模拟器(",B.device,")里找到并保存了:",B.candidates[0].label??B.candidates[0].package,"(",B.candidates[0].client===void 0?"":`${B.candidates[0].client},`,B.candidates[0].package,")"]}),B!==null&&(B.candidates.length>1||B.candidates.length===1&&G.androidPackage!==B.candidates[0].package)&&n.jsxs("div",{className:"candidate-list",children:[n.jsxs("span",{className:"muted small",children:["在模拟器(",B.device,")里找到 ",B.candidates.length," 个,选你玩的那个:"]}),B.candidates.map(Y=>n.jsxs("button",{className:`candidate app-candidate ${G.androidPackage===Y.package?"chosen":""}`,disabled:x,onClick:()=>void V(Y.package),children:[Y.icon===void 0?n.jsx("span",{className:"app-icon blank",children:[...Y.label??Y.package][0]}):n.jsx("img",{className:"app-icon",src:Wj(Y.icon),alt:"",draggable:!1}),n.jsxs("span",{className:"app-candidate-text",children:[n.jsxs("span",{children:[Y.label??Y.package,Y.client===void 0?"":`(${Y.client})`]}),n.jsx("span",{className:"mono",children:Y.package}),n.jsx("span",{className:"muted small",children:Y.reason})]})]},Y.package))]})]}),G.mode!=="off"&&Z.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:Y=>d(Y.target.value),placeholder:"例如 D:\\Games\\Endfield\\Endfield.exe(也可以是游戏启动器)",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:x,onClick:()=>void T({pcExe:u.trim()===""?null:u.trim().replace(/^"|"$/g,"")}),children:"保存"})]}),n.jsxs("div",{className:"button-row",children:[n.jsx("button",{className:"small-button",disabled:x||M,onClick:()=>void F(),children:M?"正在查找…":"自动查找"}),n.jsx("button",{className:"small-button",disabled:x||M,onClick:()=>void te(),children:"选择文件…"}),n.jsx("button",{className:"link-button small",disabled:M,onClick:()=>void q(),children:"让 agent 找"})]}),_!==null&&_.exe===void 0&&n.jsx("p",{className:"muted small",children:"脚本包没有写游戏的进程名:先在下面填进程名,或用「选择文件…」/ 让 agent 找。"}),_!==null&&_.exe!==void 0&&_.candidates.length===0&&n.jsxs("p",{className:"muted small",children:["没找到 ",_.exe,"(查了正在运行的程序、以前运行过的程序、Windows 搜索、已安装程序、游戏启动器记下的目录、开始菜单和桌面快捷方式、各盘的常见游戏目录)。可以「选择文件…」,或「让 agent 找」在整个磁盘上搜。"]}),_!==null&&_.candidates.length===1&&n.jsxs("p",{className:"muted small",children:["找到并保存了:",_.candidates[0].path,"(",_.candidates[0].source,")"]}),_!==null&&_.candidates.length>1&&n.jsxs("div",{className:"candidate-list",children:[n.jsxs("span",{className:"muted small",children:["找到 ",_.candidates.length," 个,选一个:"]}),_.candidates.map(Y=>n.jsxs("button",{className:`candidate ${G.pcExe===Y.path?"chosen":""}`,disabled:x,onClick:()=>void H(Y.path),children:[n.jsx("span",{className:"mono",children:Y.path}),n.jsx("span",{className:"muted small",children:Y.source})]},Y.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:Y=>m(Y.target.value),placeholder:K.pcProcess??"默认是上面程序的文件名",spellCheck:!1}),n.jsx("button",{className:"small-button",disabled:x,onClick:()=>void T({pcProcess:h.trim()===""?null:h.trim()}),children:"保存"})]}),n.jsx("p",{className:"muted small",children:"填的是启动器时,进程名要填游戏本身的(在任务管理器「详细信息」里看)。"})]}),w&&n.jsx("div",{className:"muted small",children:"已保存,下次运行生效。"}),b!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:b})]})]})}const N7=15*6e4;function w7({client:e,script:t,openSession:s}){const i=vn(3e4),[r,o]=v.useState(!1),[l,u]=v.useState(null),d=t.summary,h=(d==null?void 0:d.state)==="running"&&i-d.at<N7,m=(d==null?void 0:d.state)==="failed"||d==null?void 0:d.text,p=async()=>{o(!0),u(null);try{await e.connection.call("scripts/summarize",{id:t.id})}catch(g){u(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 总结 · ${vt(d.at,i)}`})]}),n.jsxs("div",{className:"key-actions",children:[(d==null?void 0:d.sessionId)!==void 0&&n.jsx("button",{className:"ghost small-button",onClick:()=>s(d.sessionId),children:h?"看看进度":"查看对话"}),n.jsxs("button",{className:`${d===void 0?"primary ":""}small-button`,disabled:r||h,onClick:()=>void p(),children:[n.jsx(ee,{name:"sparkles"}),h?"总结中…":d===void 0?"让 AI 总结":"重新总结"]})]})]}),m!==void 0&&n.jsx("p",{className:`summary-text ${h?"muted":""}`,children:m}),(d==null?void 0:d.state)==="failed"&&d.text!==void 0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(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 S7={desktop:"占用鼠标键盘",adb:"用模拟器,不占鼠标",window:"后台操作游戏窗口",none:"不占用"};function _7(e){const t=/^(\d+)(s|m|h)$/.exec(e);return t===null?e:`约 ${t[1]} ${t[2]==="s"?"秒":t[2]==="m"?"分钟":"小时"}`}function Eg({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 E7({client:e,script:t}){const s=Se(e.connection.status),[i,r]=v.useState(void 0),[o,l]=v.useState(null),[u,d]=v.useState(0),[h,m]=v.useState("tasks");if(v.useEffect(()=>e.connection.on("packs/changed",()=>d(k=>k+1)),[e]),v.useEffect(()=>{if(s.state!=="open"||t.packId===void 0)return;let k=!0;return e.connection.call("scripts/guide",{id:t.id}).then(b=>{k&&(r(b.guide),l(null))}).catch(b=>{k&&l(Ce(b))}),()=>{k=!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(([,,k])=>k),x=g.some(([k])=>k===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(([k,b])=>n.jsxs("label",{className:x===k?"active":"",children:[n.jsx("input",{type:"radio",name:`guide-${t.id}`,checked:x===k,onChange:()=>m(k)}),b]},k))}),x==="tasks"&&n.jsx(C7,{guide:i}),x==="features"&&n.jsx(A7,{guide:i}),x==="config"&&n.jsx($7,{guide:i}),x==="before"&&n.jsx(I7,{guide:i}),x==="problems"&&n.jsx(T7,{guide:i})]})]})}function C7({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:S7[t.input]}),t.expectedDuration!==void 0&&n.jsx("span",{className:"muted small",children:_7(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(Eg,{items:[["可选值",s.values],["默认",s.default??(s.values===void 0?"无,运行时必须填":void 0)]]})]})]},s.name))})]},t.id))})}function A7({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 $7({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(Eg,{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(Eg,{items:[["条件",s.when],["任务",s.tasks.join("、")]]})]})]},`${s.key}=${s.value}:${s.when??""}`))})]})]},t.file))})}function I7({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 T7({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 R7({client:e,script:t}){const[s,i]=v.useState(null),[r,o]=v.useState(0),[l,u]=v.useState({}),[d,h]=v.useState(null),[m,p]=v.useState(null);if(v.useEffect(()=>e.connection.on("skills/changed",()=>o(b=>b+1)),[e]),v.useEffect(()=>e.connection.on("packs/changed",()=>o(b=>b+1)),[e]),v.useEffect(()=>{let b=!0;return e.connection.call("scripts/mcp",{id:t.id}).then(j=>{b&&i(j)}).catch(()=>{b&&i(null)}),()=>{b=!1}},[e,t.id,t.current,t.packId,r]),s===null||s.servers.length===0&&s.skills.length===0)return null;const g=async b=>{u(j=>({...j,[b]:"busy"}));try{const j=await e.connection.call("scripts/mcp/probe",{id:t.id,server:b});u(w=>({...w,[b]:j})),o(w=>w+1)}catch(j){u(w=>({...w,[b]:{ok:!1,error:Ce(j)}}))}},x=async b=>{h((b==null?void 0:b[0])??"*"),p(null);try{const{imported:j,skipped:w}=await e.connection.call("scripts/skills/import",{id:t.id,...b===void 0?{}:{names:b}}),S=[...j.length===0?[]:[`已放进技能库:${j.map(_=>_.name).join("、")}`],...w.map(_=>`${_.skill} 没有导入:${_.reason}`)];p({text:S.join(";")||"没有可以导入的技能",error:j.length===0}),o(_=>_+1)}catch(j){p({text:Ce(j),error:!0})}finally{h(null)}},k=s.skills.filter(b=>b.problem===void 0&&(b.imported===void 0||!b.imported.current&&!b.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 就会用上。":""]})]}),k.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(b=>{var w,S;const j=l[b.name];return n.jsxs("li",{className:"mcp-server",children:[n.jsxs("div",{className:"mcp-server-main",children:[n.jsx("span",{className:"version-name",children:b.name}),n.jsx("span",{className:"badge",children:M7[b.transport]??b.transport}),n.jsx("span",{className:`badge ${b.source==="pack"?"ok":""}`,title:b.file===void 0?void 0:`来自脚本的 ${b.file}`,children:b.source==="pack"?"脚本包已写明用法":"从脚本配置读到"}),b.connected&&n.jsx("span",{className:"badge ok",children:"已连接"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"ghost small-button",disabled:j==="busy"||b.problem!==void 0,title:b.trusted?void 0:"会启动或连接这个服务;之后 agent 用它时不再询问",onClick:()=>void g(b.name),children:j==="busy"?"连接中…":"测试连接"})]}),n.jsx("code",{className:"muted small mcp-target",children:b.target}),b.description!==void 0&&n.jsx("p",{className:"muted small",children:b.description}),b.needsRunning&&n.jsx("p",{className:"muted small",children:"要先打开脚本(并在它的设置里开启 MCP 服务)才能连上。"}),b.problem!==void 0&&n.jsxs("div",{className:"notice warn-note left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:b.problem})]}),j!==void 0&&j!=="busy"&&(j.ok?n.jsxs("p",{className:"small",children:[j.server===void 0?"":`${j.server.name} ${j.server.version} · `,((w=j.tools)==null?void 0:w.length)??0," 个工具",(((S=j.tools)==null?void 0:S.length)??0)>0?`:${j.tools.map(_=>_.title??_.name).join("、")}`:""]}):n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:j.error})]}))]},b.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(b=>n.jsxs("li",{className:"mcp-skill",children:[n.jsxs("div",{className:"mcp-server-main",children:[n.jsx("span",{className:"version-name",children:b.name}),b.imported!==void 0&&n.jsxs("span",{className:"badge ok",children:["已在技能库",b.imported.name===b.name?"":`(${b.imported.name})`]}),b.imported!==void 0&&!b.imported.current&&n.jsx("span",{className:"badge warn",title:b.imported.changed?"技能库里的这份在这里改过,不会自动替换":void 0,children:"脚本里有新版"}),n.jsx("span",{className:"spacer"}),b.problem===void 0&&(b.imported===void 0||!b.imported.current)&&n.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void x([b.path]),children:d===b.path?"导入中…":b.imported===void 0?"放进技能库":"更新"})]}),b.description!==""&&n.jsx("p",{className:"muted small",children:b.description}),n.jsx("code",{className:"muted small mcp-target",children:b.path}),b.problem!==void 0&&n.jsxs("div",{className:"notice warn-note left small",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:b.problem})]})]},b.path))})]}),m!==null&&n.jsxs("div",{className:`notice ${m.error?"error":""} left small`,children:[n.jsx(ee,{name:m.error?"alert":"check"}),n.jsx("span",{children:m.text})]})]})}const O7={nsis:"NSIS",inno:"Inno Setup",kachina:"Kachina"};function gE({client:e,setup:t,openSession:s,onImported:i}){const[r,o]=v.useState(t.dir),[l,u]=v.useState(!1),[d,h]=v.useState(null),[m,p]=v.useState(null),[g,x]=v.useState(!1),k=t.agent,b=async(j,w)=>{h(j),p(null);try{await w()}catch(S){p(Ce(S))}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:["下载到的是 ",O7[t.kind]," 安装程序,不是压缩包:要运行它把文件装好,再导入装好的文件夹。"]})]})}),(k==null?void 0:k.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(k.sessionId),children:"查看对话"})]}),(k==null?void 0:k.state)==="failed"&&n.jsxs("div",{className:"notice warn-box left",children:[n.jsx(ee,{name:"alert"}),n.jsxs("span",{children:["agent 没能装好:",k.reason??"原因不明","。可以按下面的步骤自己装,也可以之后再交给 agent。"]}),n.jsx("button",{className:"link-button",onClick:()=>s(k.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 b("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(),b("import",async()=>{const w=await e.connection.call("scripts/import",{path:r.trim().replace(/^"|"$/g,""),id:t.scriptId});i(w.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"?"导入中…":"装好了,导入"})]})]})})]}),m!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:m})]}),n.jsx("div",{className:"key-actions",children:g?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"muted small",children:"删除下载好的安装程序,什么都不装。"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>x(!1),children:"取消"}),n.jsx("button",{className:"danger small-button",disabled:d!==null,onClick:()=>void b("discard",async()=>{await e.connection.call("scripts/setup/discard",{id:t.scriptId})}),children:"确认删除"})]}):n.jsxs(n.Fragment,{children:[(k==null?void 0:k.state)!=="running"&&n.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void b("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 P7={ok:["ok","满足"],missing:["warn","缺少"],outdated:["warn","版本过旧"],unknown:["warn","无法判断"],unsupported:["","暂不检测"]};function L7({client:e,script:t,skillUpdates:s=[],job:i,setup:r,onRemoved:o,openSession:l}){var B;const u=vn(6e4),[d,h]=v.useState(null),[m,p]=v.useState(null),[g,x]=v.useState(null),[k,b]=v.useState(!1),[j,w]=v.useState(!1),S=i!==void 0&&(i.endedAt===void 0||i.startedAt>=t.addedAt-1e3)?i:void 0,_=Aa(S),E=Se(e.capabilities),M=t.source.kind!=="local",O=async(U,P)=>{h(U),p(null),x(null);try{const R=await P();typeof R=="string"&&x(R)}catch(R){p(Ce(R))}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:kw[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(z7,{client:e,skills:s}),S!==void 0&&n.jsx(_g,{client:e,job:S}),r!==void 0&&n.jsx(gE,{client:e,setup:r,openSession:l,onImported:()=>{}}),t.dir!==void 0&&n.jsx(w7,{client:e,script:t,openSession:l}),t.packId!==void 0&&n.jsx(E7,{client:e,script:t},`guide:${t.id}`),t.dir!==void 0&&n.jsx(R7,{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 U;return void((U=navigator.clipboard)==null?void 0:U.writeText(t.dir))},children:[n.jsx(ee,{name:"copy"}),"复制路径"]})]}),M?n.jsxs(n.Fragment,{children:[n.jsx("ul",{className:"version-list",children:t.versions.map(U=>{var P;return n.jsxs("li",{className:U.current?"current":"",children:[n.jsx("span",{className:"version-name",children:U.version}),U.current&&n.jsx("span",{className:"badge ok",children:"当前"}),n.jsxs("span",{className:"muted small",children:[((P=U.asset)==null?void 0:P.name)??""," · ",vt(U.installedAt,u)]}),n.jsx("span",{className:"spacer"}),!U.current&&n.jsx("button",{className:"small-button",disabled:_||d!==null,onClick:()=>void O("rollback",async()=>(await e.connection.call("scripts/rollback",{id:t.id,version:U.version}),`已切换到 ${U.version}`)),children:"切换到此版本"})]},U.version)})}),n.jsx("dl",{className:"local-facts channel-facts",children:n.jsx(pE,{client:e,script:t,disabled:_||d!==null,act:O})}),n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[t.update===void 0?"还没有检查过更新":t.update.available?`有新版本 ${t.update.latest}`:`已是最新(${t.update.latest})`,t.update!==void 0&&` · ${vt(t.update.checkedAt,u)}检查`]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",disabled:_||d!==null,onClick:()=>void O("check",async()=>{const U=await e.connection.call("scripts/checkUpdate",{id:t.id});return U.available?`发现新版本 ${U.latest}`:"已是最新版本"}),children:d==="check"?"检查中…":"检查更新"}),n.jsx("button",{className:"primary small-button",disabled:_||d!==null||((B=t.update)==null?void 0:B.available)!==!0,onClick:()=>void O("update",async()=>(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0),children:"更新"})]})]}):n.jsx(x7,{client:e,script:t,disabled:_||d!==null,busy:d,now:u,act:O})]}),n.jsxs("section",{className:"card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:"运行环境"}),n.jsx("p",{className:"muted small",children:t.env===void 0?t.packId===void 0?"没有脚本包,暂时不知道它需要什么":"还没有检查":`${vt(t.env.checkedAt,u)}检查`})]}),n.jsx("button",{className:"small-button",disabled:_||d!==null,onClick:()=>void O("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(U=>{const[P,R]=P7[U.status];return n.jsxs("li",{children:[n.jsxs("div",{className:"env-main",children:[n.jsx("span",{className:"env-label",children:U.label}),n.jsx("span",{className:`badge ${P}`,children:R}),U.found!==void 0&&n.jsx("span",{className:"muted small",children:U.found})]}),U.detail!==void 0&&n.jsx("div",{className:"muted small",children:U.detail}),U.fix!==void 0&&n.jsxs("div",{className:"env-fix",children:[n.jsx("span",{className:"muted small",children:U.fix.description}),U.fix.kind!=="manual"&&n.jsx("button",{className:"small-button",disabled:_||d!==null,onClick:()=>void O(`fix-${U.kind}`,async()=>{await e.connection.call("scripts/envFix",{id:t.id,kind:U.kind})}),children:U.fix.kind==="installer"?"安装(需要管理员)":"自动修复"})]})]},U.kind)})})]}),E.has("runs")&&t.dir!==void 0&&n.jsx(K5,{client:e,scriptId:t.id,packId:t.packId}),E.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&n.jsx(b7,{client:e,script:t}),E.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&n.jsx(j7,{client:e,scriptId:t.id,scriptName:t.name,openSession:l},t.id),E.has("packs")&&n.jsx(v7,{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(U=>n.jsx("span",{className:"chip",children:U},U))}),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(U=>n.jsx("span",{className:"chip",children:U},U))})]})]}),E.has("guard")&&n.jsx(y7,{client:e,script:t}),n.jsx("section",{className:"card danger-zone",children:k?n.jsxs("div",{className:"key-actions",children:[M&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:j,onChange:U=>w(U.target.checked)}),"同时删除所有已安装版本"]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"small-button",onClick:()=>b(!1),children:"取消"}),n.jsx("button",{className:"danger small-button",disabled:d!==null,onClick:()=>void O("remove",async()=>{await e.connection.call("scripts/remove",{id:t.id,deleteFiles:M&&j}),o()}),children:"确认移除"})]}):n.jsxs("div",{className:"key-actions",children:[n.jsxs("span",{className:"muted small",children:[M?"从脚本库移除;可选择同时删除已安装的文件。":"从脚本库移除;你的目录不会被删除。","agent 为它写的脚本包一起删掉,从技能库下载的保留。"]}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"danger-outline small-button",disabled:_,onClick:()=>b(!0),children:"移除"})]})}),g!==null&&n.jsx("div",{className:"notice info",children:g}),m!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:m})]})]})}function z7({client:e,skills:t}){const[s,i]=v.useState(!1),[r,o]=v.useState(null),l=t.map(d=>{var p,g;const h=d.title??d.name,m=d.version===void 0||d.version===((p=d.installed)==null?void 0:p.version)?"":` ${((g=d.installed)==null?void 0:g.version)??""}→${d.version}`;return`${h}${m}${d.changes===void 0?"":`(${d.changes})`}`}).join("、"),u=async()=>{i(!0),o(null);try{for(const d of t)await e.connection.call("skillhub/update",{name:d.name})}catch(d){o(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 D7({client:e,openSession:t,arg:s}){const{data:i,error:r}=ah(e),o=bw(e),l=TO(e),[u,d]=v.useState(null),[h,m]=v.useState(null);v.useEffect(()=>{(s==null?void 0:s.startsWith("mirror:"))===!0&&m({kind:"mirror",rid:s.slice(7)})},[s]);const p=(i==null?void 0:i.scripts)??[],g=((i==null?void 0:i.packs)??[]).filter(E=>!E.installed&&E.repo!==void 0&&E.error===void 0),x=((i==null?void 0:i.packs)??[]).filter(E=>E.error!==void 0),k=((i==null?void 0:i.known)??[]).filter(E=>!E.installed),b=(i==null?void 0:i.setups)??[],j=b.filter(E=>!p.some(M=>M.id===E.scriptId)),w=h===null?j.find(E=>E.scriptId===u):void 0,S=u===null||p.some(E=>E.id===u)||w!==void 0?void 0:o.get(u),_=p.find(E=>E.id===u)??(h===null&&S===void 0&&w===void 0?p[0]:void 0);return n.jsxs("section",{className:"main scripts-page",children:[n.jsxs("header",{className:"page-header",children:[n.jsxs("div",{className:"breadcrumb",children:[n.jsx("span",{children:"脚本"}),n.jsx("span",{className:"breadcrumb-divider",children:"/"}),n.jsx("h1",{children:"脚本库"})]}),n.jsxs("div",{className:"page-actions",children:[n.jsxs("button",{className:"small-button",onClick:()=>m({kind:"import"}),children:[n.jsx(ee,{name:"paperclip"}),"导入本地项目"]}),n.jsxs("button",{className:"small-button",onClick:()=>m({kind:"mirror"}),children:[n.jsx(ee,{name:"plus"}),"从 Mirror酱 安装"]}),n.jsxs("button",{className:"primary small-button",onClick:()=>m({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(Aa)&&n.jsxs("div",{className:"sidebar-empty",children:[n.jsx(ee,{name:"package"}),n.jsx("span",{children:"还没有脚本"}),n.jsx("span",{children:"从下面的脚本包安装,或导入已有目录"})]}),p.map(E=>{var B,U;const M=o.get(E.id),O=((B=E.env)==null?void 0:B.items.filter(P=>P.status!=="ok"&&P.status!=="unsupported").length)??0;return n.jsxs("button",{className:`script-row ${E.id===(_==null?void 0:_.id)&&h===null?"active":""}`,onClick:()=>{d(E.id),m(null)},children:[n.jsx(cE,{client:e,iconKey:`script:${E.id}:${E.current??""}`,name:E.name,className:"script-avatar",load:()=>e.connection.call("scripts/icon",{id:E.id})}),n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:E.name}),n.jsxs("span",{className:"muted small",children:[ub(E,l).length>0&&n.jsx("span",{className:"skill-update-hint",title:"这个脚本的技能在技能库里有新版",children:"技能有新版 · "}),E.source.kind==="local"?"本地":E.current??"未安装",E.family===void 0?"":` · ${kw[E.family]??E.family}`]})]}),Aa(M)?n.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):b.some(P=>P.scriptId===E.id)?n.jsx("span",{className:"badge warn",children:"待安装"}):((U=E.update)==null?void 0:U.available)===!0?n.jsx("span",{className:"badge ok",children:"可更新"}):O>0?n.jsxs("span",{className:"badge warn",children:["环境 ",O]}):null]},E.id)}),j.length>0&&n.jsxs("div",{className:"sidebar-label",children:["等待安装(",j.length,")"]}),j.map(E=>{var M,O,B;return n.jsxs("button",{className:`script-row ${E===w?"active":""}`,onClick:()=>{d(E.scriptId),m(null)},children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:E.name}),n.jsxs("span",{className:"muted small",children:[E.version," · ",((M=E.agent)==null?void 0:M.state)==="running"?"agent 正在安装":((O=E.agent)==null?void 0:O.state)==="failed"?"agent 没能装好":"安装程序已下载"]})]}),((B=E.agent)==null?void 0:B.state)==="running"?n.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):n.jsx("span",{className:"badge warn",children:"待安装"})]},E.scriptId)}),[...o.values()].filter(E=>Aa(E)&&!p.some(M=>M.id===E.scriptId)).map(E=>n.jsxs("button",{className:`script-row ${u===E.scriptId&&h===null?"active":""}`,onClick:()=>{d(E.scriptId),m(null)},children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:E.scriptId}),n.jsxs("span",{className:"muted small",children:["正在安装 · ",jc[E.phase],E.total!==void 0&&E.received!==void 0&&E.total>0?` ${Math.floor(E.received/E.total*100)}%`:""]})]}),n.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"})]},E.id)),(g.length>0||k.length>0)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"sidebar-label pack-label",children:"可安装的脚本包"}),g.map(E=>n.jsxs("div",{className:"pack-row",children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:E.name}),n.jsx("span",{className:"muted small",children:E.description??E.repo})]}),n.jsx("button",{className:"small-button",onClick:()=>m({kind:"install",repo:E.repo}),children:"安装"})]},E.id)),k.map(E=>n.jsxs("div",{className:"pack-row",children:[n.jsxs("span",{className:"script-row-main",children:[n.jsx("span",{className:"script-row-name",children:E.name}),n.jsx("span",{className:"muted small",children:[E.mirrorchyan===void 0?void 0:`Mirror酱 ${E.mirrorchyan}`,E.repo].filter(Boolean).join(" · ")})]}),n.jsx("button",{className:"small-button",onClick:()=>m(E.mirrorchyan!==void 0?{kind:"mirror",rid:E.mirrorchyan}:{kind:"install",repo:E.repo}),children:"安装"})]},E.id))]}),x.length>0&&n.jsxs("div",{className:"notice error left small",children:[n.jsx(ee,{name:"alert"}),n.jsxs("span",{children:[x.length," 个脚本包无法读取:",x.map(E=>E.id).join("、")]})]})]})]}),n.jsxs("div",{className:"scripts-detail",children:[(h==null?void 0:h.kind)==="install"&&n.jsx(c7,{client:e,jobs:o,...h.repo===void 0?{}:{initialRepo:h.repo},onClose:()=>m(null),onDone:E=>{d(E),m(null)},openSession:t},h.repo??"blank"),(h==null?void 0:h.kind)==="mirror"&&n.jsx(u7,{client:e,jobs:o,...h.rid===void 0?{}:{initialRid:h.rid},onClose:()=>m(null),onDone:E=>{d(E),m(null)},openSession:t,onGitHub:E=>m({kind:"install",repo:E})},h.rid??"blank"),(h==null?void 0:h.kind)==="import"&&n.jsx(p7,{client:e,onClose:()=>m(null),onImported:E=>{d(E),m(null)}}),h===null&&_!==void 0&&n.jsx(L7,{client:e,script:_,skillUpdates:ub(_,l),job:o.get(_.id),setup:b.find(E=>E.scriptId===_.id),onRemoved:()=>d(null),openSession:t},_.id),w!==void 0&&n.jsx(gE,{client:e,setup:w,openSession:t,onImported:E=>d(E)},w.scriptId),h===null&&_===void 0&&S!==void 0&&n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:S.scriptId}),n.jsx("p",{className:"muted small",children:Aa(S)?"正在安装,装好后这里显示脚本的详情":"安装没有完成"})]})}),n.jsx(_g,{client:e,job:S})]}),h===null&&_===void 0&&S===void 0&&w===void 0&&i!==null&&n.jsxs("div",{className:"empty",children:[[...o.values()].filter(E=>Aa(E)&&!p.some(M=>M.id===E.scriptId)).map(E=>n.jsxs("div",{className:"pending-install",children:[n.jsx("strong",{children:E.scriptId}),n.jsx(_g,{client:e,job:E})]},E.id)),n.jsx("p",{children:"选择左侧的脚本查看详情,或安装一个新脚本。"})]}),i!==null&&n.jsxs("p",{className:"tools-dir muted small",children:["工具目录:",i.toolsDir]})]})]})]})}const F7={id:"scripts",title:"脚本库",milestone:"M1",requires:["scripts"],pages:[{id:"scripts",title:"脚本",icon:"package",order:10,agent:"scripts",component:D7}],settingsPages:[{id:"script-install",title:"脚本安装",order:10,component:l7}]},U7={id:"emulators",title:"模拟器",milestone:"M2",requires:["emulators"],settingsPages:[{id:"emulators",title:"模拟器",order:11,component:o7}]},hp="https://github.com/haaahhhis/MultiGameAssistant";function B7({client:e}){const[t,s]=v.useState(void 0),i=sS(e),r=t===null?i===void 0?void 0:i===!1?null:i.version:null;v.useEffect(()=>{var d;const l=(d=Vs())==null?void 0:d.appInfo;if(l===void 0){s(null);return}let u=!0;return l().then(h=>{u&&s(h)},()=>{u&&s(null)}),()=>{u=!1}},[]);const o=t===void 0?"…":t===null?r===void 0?"…":r===null?"在浏览器里打开(版本见桌面版)":`${r}(dsh 插件版)`:t.fromSource?`从源码运行(${t.arch})`:`${t.version??"未知版本"}(${t.arch}${t.commit===void 0?"":` · ${t.commit}`})`;return n.jsxs("div",{className:"settings-page about-page",children:[n.jsx("h2",{children:"关于"}),n.jsx("p",{children:"MultiGameAssistant(多游戏助手):让 agent 替你管好各个游戏的日常脚本。"}),n.jsx("section",{className:"card about-card",children:n.jsxs("dl",{className:"about-facts",children:[n.jsx("dt",{children:"版本"}),n.jsx("dd",{children:o}),n.jsx("dt",{children:"源代码"}),n.jsx("dd",{children:n.jsx("a",{href:hp,target:"_blank",rel:"noreferrer",children:hp.replace("https://","")})}),n.jsx("dt",{children:"许可证"}),n.jsx("dd",{children:n.jsx("a",{href:`${hp}/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(H7,{}):typeof r=="string"&&n.jsx(Z7,{client:e}),n.jsxs("section",{className:"card about-card",children:[n.jsx("h3",{children:"许可证"}),n.jsx("p",{children:"Copyright (C) 2026 MultiGameAssistant contributors"}),n.jsx("p",{children:"本程序是自由软件:你可以按自由软件基金会发布的 GNU Affero 通用公共许可证第 3 版(AGPL-3.0-only)再分发和修改它。分发修改后的版本,或让别人通过网络使用修改后的版本时,要以同样的许可证提供它的完整源代码。"}),n.jsx("p",{children:"发布本程序是希望它有用,但不提供任何担保,也没有适销性或特定用途适用性的默示担保。详见许可证全文。"}),n.jsx("p",{className:"muted small",children:"附带的第三方组件(Electron、DeepSeek Harness 等)遵循各自的许可证,许可证文件在程序的安装目录里。本程序安装和调度的游戏脚本是各自独立的项目,不属于本程序。"})]})]})}function H7(){const{bridge:e,state:t}=lx();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(cx,{notes:s.notes??[],notesUrl:s.notesUrl})}),t!==void 0&&n.jsx(ux,{bridge:e,state:t}),t!==void 0&&n.jsxs("label",{className:"check-label",children:[n.jsx("input",{type:"checkbox",checked:t.auto,onChange:r=>void e.setAuto(r.target.checked)}),"自动检查更新(启动后和每隔几小时,从 GitHub Releases;",/-/.test(t.current)?"预发布版也会收到更新的预发布版":"只提示正式版",")"]})]})}function Z7({client:e}){var r;const t=iS(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(cx,{notes:s.notes??[],notesUrl:s.notesUrl})}),n.jsx(lS,{version:s.version,onNpm:s.onNpm})]})]})}const ic=e=>e.replace(/\/+$/,""),Vj=e=>{const t=ic(e);return t.endsWith("/v1")?t.slice(0,-3):t},xE=[{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=>`${Vj(e)}/v1/messages`,listPath:e=>`${Vj(e)}/v1/models`}];function Cg(e){return xE.find(t=>t.id===e)}function W7(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,40)}function V7(e){return`${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}_API_KEY`}const q7=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function G7(e){try{const{protocol:t}=new URL(e);return t==="http:"||t==="https:"}catch{return!1}}function $a(e){return e===void 0?null:e%1048576===0?`${e/1048576}M`:e>=1e6?`${+(e/1e6).toFixed(1)}M`:e%1024===0?`${e/1024}K`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}const vE=1e6,Vl=e=>(e.contextWindow??0)>=vE;function K7({client:e,profile:t,preset:s,taken:i,revision:r,readOnly:o,onDone:l}){var Y;const u=t===void 0,d=s===void 0||s.id===""?"":i.includes(s.id)?`${s.id}-2`:s.id,[h,m]=v.useState(()=>{var Q;return((Q=Cg((t==null?void 0:t.api)??(s==null?void 0:s.api)))==null?void 0:Q.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,k]=v.useState((t==null?void 0:t.id)??d),[b,j]=v.useState(!u||d!==""),[w,S]=v.useState((t==null?void 0:t.baseURL)??(s==null?void 0:s.baseURL)??""),[_,E]=v.useState(""),[M,O]=v.useState((t==null?void 0:t.models)??[]),[B,U]=v.useState(!1),[P,R]=v.useState(null),z=Cg(h),L=w.trim(),A=L!==""&&!G7(L),T=x!==""&&!q7.test(x),H=u&&i.includes(x),F=bE(_),V=(t==null?void 0:t.apiKeyRef)??(x===""?null:V7(x)),D=((Y=t==null?void 0:t.credential)==null?void 0:Y.configured)===!0,q=(t==null?void 0:t.credential)!==void 0&&!t.credential.writable,te=x===""?"请填写标识":T?"标识格式不正确":H?"这个标识已被占用":L===""?"请填写 Base URL":A?"Base URL 需要以 http:// 或 https:// 开头":F!==null?F:M.length===0?"至少需要一个模型:点击「拉取模型列表」或手动添加":null,G=Q=>{g(Q),b||k(W7(Q))},K=async()=>{if(te===null){U(!0),R(null);try{await e.saveProvider({id:x,create:u,...p.trim()===""?{}:{displayName:p.trim()},api:h,baseURL:L,models:[...M],..._.trim()===""?{}:{apiKey:_.trim()},expectedRevision:r}),l()}catch(Q){const ie=Q instanceof Error?Q.message:String(Q);R(/SETTINGS_CONFLICT|conflict/i.test(ie)?"配置在别处被修改过了,请返回列表后重试。":ie)}finally{U(!1)}}},Z=B||o;return n.jsxs("form",{className:"provider-editor",onSubmit:Q=>{Q.preventDefault(),K()},children:[n.jsxs("div",{className:"page-head",children:[n.jsx("h3",{children:u?s!==void 0&&s.baseURL!==""?`添加 ${s.name}`:"添加模型服务":`编辑「${t.displayName}」`}),n.jsx("button",{type:"button",className:"ghost",onClick:l,disabled:B,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:xE.map(Q=>n.jsxs("button",{type:"button",role:"radio","aria-checked":h===Q.id,"aria-label":`${Q.title}(${Q.subtitle})`,className:`mode-option${h===Q.id?" selected":""}`,onClick:()=>m(Q.id),disabled:Z,children:[n.jsx("span",{className:"mode-title",children:Q.title}),n.jsx("span",{className:"mode-subtitle",children:Q.subtitle})]},Q.id))}),n.jsx("div",{className:"muted small",children:z.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:Q=>G(Q.target.value),placeholder:"例如:我的中转站",disabled:Z})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"标识"}),n.jsx("input",{className:"text-input",value:x,onChange:Q=>{k(Q.target.value.trim()),j(!0)},placeholder:"my-gateway",disabled:Z||!u,spellCheck:!1})]})]}),n.jsx("div",{className:T||H?"error small":"muted small",children:T?"标识只能用小写字母、数字和单个连字符,并以字母开头。":H?"这个标识已被占用(可能是已有的提供方或 dsh 内置提供方)。":u?"用于区分提供方,保存后不能修改。":"标识创建后不能修改。"}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"Base URL"}),n.jsx("input",{className:"text-input",value:w,onChange:Q=>S(Q.target.value),placeholder:z.placeholder,disabled:Z,spellCheck:!1})]}),A?n.jsx("div",{className:"error small",children:"Base URL 需要以 http:// 或 https:// 开头。"}):L!==""&&n.jsxs("div",{className:"muted small endpoint-preview",children:["对话请求 ",n.jsxs("code",{children:["POST ",z.requestPath(L)]}),n.jsx("br",{}),"模型列表 ",n.jsxs("code",{children:["GET ",z.listPath(L)]})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"API Key"}),n.jsx("input",{className:"text-input",type:"password",value:_,onChange:Q=>E(Q.target.value),placeholder:q?"由启动环境变量提供,无法在此修改":D?"已配置,留空则保持不变":"粘贴 Key;本地服务不需要时可留空",autoComplete:"new-password",disabled:Z||q,spellCheck:!1})]}),F!==null?n.jsx("div",{className:"error small",children:F}):V!==null&&n.jsxs("div",{className:"muted small",children:["保存在 dsh 凭据 ",n.jsx("code",{children:V})," 中,界面不会再显示 Key 的内容。",(s==null?void 0:s.keyUrl)!==void 0&&n.jsxs(n.Fragment,{children:[" ",n.jsx("a",{href:s.keyUrl,target:"_blank",rel:"noopener noreferrer",children:"获取 Key ↗"})]})]}),(s==null?void 0:s.vision)!==void 0&&n.jsxs("div",{className:"muted small",children:["截图诊断、读游戏信息需要能看图的模型:",s.vision,"。"]})]}),n.jsx(Y7,{client:e,models:M,onChange:O,probe:{...t===void 0?{}:{provider:t.id},api:h,baseURL:L,apiKey:_.trim()},probeBlocked:L===""?"先填写 Base URL":A?"Base URL 无效":F,disabled:Z}),P!==null&&n.jsx("div",{className:"banner error",children:P}),n.jsxs("div",{className:"key-actions",children:[n.jsx("span",{className:"muted small",children:te}),n.jsx("span",{className:"spacer"}),n.jsx("button",{type:"button",onClick:l,disabled:B,children:"取消"}),n.jsx("button",{type:"submit",className:"primary",disabled:Z||te!==null,children:B?"保存中…":u?"创建":"保存"})]})]})}function Y7({client:e,models:t,onChange:s,probe:i,probeBlocked:r,disabled:o}){const[l,u]=v.useState(null),[d,h]=v.useState(""),[m,p]=v.useState(""),[g,x]=v.useState(!1),[k,b]=v.useState(null),j=v.useRef(null),w=v.useMemo(()=>new Set(t.map(R=>R.id)),[t]),S=async()=>{var z;(z=j.current)==null||z.abort();const R=new AbortController;j.current=R,x(!0),b(null);try{const L=await e.discoverModels({...i.provider===void 0?{}:{provider:i.provider},api:i.api,baseURL:i.baseURL,...i.apiKey===""?{}:{apiKey:i.apiKey}},R.signal);if(R.signal.aborted)return;u([...L].sort((A,T)=>A.id.localeCompare(T.id))),L.length===0&&b("接口返回了空的模型列表,可以手动添加模型 ID。")}catch(L){R.signal.aborted||b(L instanceof Error?L.message:String(L))}finally{j.current===R&&(j.current=null,x(!1))}},_=R=>{s(w.has(R.id)?t.filter(z=>z.id!==R.id):[...t,R])},E=R=>{s(t.map(z=>{if(z.id!==R)return z;if(z.efforts!==void 0&&z.efforts.length>0){const{efforts:L,...A}=z;return A}return{...z,efforts:["off","low","medium","high"]}}))},M=R=>{s(t.map(z=>{var L;return z.id!==R?z:{...z,input:((L=z.input)==null?void 0:L.includes("image"))===!0?["text"]:["text","image"]}}))},O=R=>{s(t.map(z=>{if(z.id!==R)return z;if(Vl(z)){const{contextWindow:L,...A}=z;return A}return{...z,contextWindow:vE}}))},B=v.useMemo(()=>{const R=d.trim().toLowerCase();return(l??[]).filter(z=>R===""||z.id.toLowerCase().includes(R)||(z.name??"").toLowerCase().includes(R))},[l,d]),U=R=>{if(R){const z=B.filter(L=>!w.has(L.id));s([...t,...z])}else{const z=new Set(B.map(L=>L.id));s(t.filter(L=>!z.has(L.id)))}},P=()=>{const R=m.split(/[\s,,]+/).map(z=>z.trim()).filter(z=>z!==""&&!w.has(z));R.length!==0&&(s([...t,...R.map(z=>(l==null?void 0:l.find(L=>L.id===z))??{id:z})]),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 S(),disabled:o||g||r!==null,title:r??void 0,children:g?"拉取中…":l===null?"拉取模型列表":"重新拉取"})]}),k!==null&&n.jsx("div",{className:"error small",children:k}),t.length>0&&n.jsx("div",{className:"model-chips",children:t.map(R=>{var z,L,A,T,H,F;return n.jsxs("span",{className:"chip removable",children:[R.id,!Vl(R)&&$a(R.contextWindow)!==null&&n.jsxs("span",{className:"muted",children:[" · ",$a(R.contextWindow)]}),n.jsx("button",{type:"button",className:`chip-flag${((z=R.input)==null?void 0:z.includes("image"))===!0?" on":""}`,onClick:()=>M(R.id),disabled:o,"aria-pressed":((L=R.input)==null?void 0:L.includes("image"))===!0,title:((A=R.input)==null?void 0:A.includes("image"))===!0?"支持图片输入(点击关闭)":"不支持图片输入(点击开启)",children:"图片"}),n.jsx("button",{type:"button",className:`chip-flag${(((T=R.efforts)==null?void 0:T.length)??0)>0?" on":""}`,onClick:()=>E(R.id),disabled:o,"aria-pressed":(((H=R.efforts)==null?void 0:H.length)??0)>0,title:(((F=R.efforts)==null?void 0:F.length)??0)>0?`可选思考强度:${R.efforts.join(" / ")}(点击关闭)`:"没有声明思考强度(点击开启:不思考 / 低 / 中 / 高)",children:"思考"}),n.jsx("button",{type:"button",className:`chip-flag${Vl(R)?" on":""}`,onClick:()=>O(R.id),disabled:o,"aria-pressed":Vl(R),title:Vl(R)?"按 1M 上下文计算,快满时才压缩(点击关闭)":R.contextWindow!==void 0?`上下文 ${$a(R.contextWindow)}(点击改为 1M)`:"上下文大小未知,dsh 默认按 1M 计算(点击写明 1M)",children:"1M"}),n.jsx("button",{type:"button",className:"chip-x",onClick:()=>s(t.filter(V=>V.id!==R.id)),disabled:o,"aria-label":`移除 ${R.id}`,children:"×"})]},R.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:R=>h(R.target.value),placeholder:`搜索 ${l.length} 个模型`}),n.jsxs("button",{type:"button",className:"small-button",onClick:()=>U(!0),disabled:o,children:["全选",d!==""?"筛选结果":""]}),n.jsx("button",{type:"button",className:"small-button",onClick:()=>U(!1),disabled:o,children:"全不选"})]}),n.jsxs("ul",{className:"candidate-list",children:[B.map(R=>{var z;return n.jsx("li",{children:n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:w.has(R.id),onChange:()=>_(R),disabled:o}),n.jsx("span",{className:"mono",children:R.id}),R.name!==void 0&&n.jsxs("span",{className:"muted",children:[" ",R.name]}),n.jsx("span",{className:"spacer"}),((z=R.input)==null?void 0:z.includes("image"))===!0&&n.jsx("span",{className:"badge",children:"图像"}),$a(R.contextWindow)!==null&&n.jsxs("span",{className:"muted small",children:[$a(R.contextWindow)," 上下文"]})]})},R.id)}),B.length===0&&n.jsx("li",{className:"muted small",children:"没有匹配的模型。"})]})]}),n.jsxs("div",{className:"key-input",children:[n.jsx("input",{className:"text-input plain-mono",value:m,onChange:R=>p(R.target.value),onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),P())},placeholder:"手动添加模型 ID,多个用空格或逗号分隔",disabled:o,spellCheck:!1}),n.jsx("button",{type:"button",onClick:P,disabled:o||m.trim()==="",children:"添加"})]})]})}const X7=[{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:""}],mp=[{id:"deepseek-official",name:"DeepSeek",note:"内置,只需要填 Key",keyRef:Ip,keyUrl:"https://platform.deepseek.com/api_keys"}];function Q7({client:e}){const{catalog:t}=aa(e),[s,i]=v.useState(!1),[r,o]=v.useState(void 0),l=Se(e.providersRevision),u=Se(e.credentialRevision),d=Se(e.connection.status),[h,m]=v.useState(null),[p,g]=v.useState(null),[x,k]=v.useState(null),[b,j]=v.useState(null),w=v.useCallback(()=>{e.listProviders().then(_=>{m(_),g(null)}).catch(_=>g(_ instanceof Error?_.message:String(_)))},[e]);if(v.useEffect(()=>{d.state==="open"&&w()},[w,l,u,d.state]),x!==null&&h!==null){const _=x==="new"?void 0:h.providers.find(E=>E.id===x);return n.jsx("section",{className:"providers-section",children:n.jsx(K7,{client:e,profile:_,preset:x==="new"?r:void 0,taken:h.taken,revision:h.revision,readOnly:!h.writable,onDone:()=>{k(null),o(void 0),w()}},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:[mp.map(_=>n.jsxs("button",{className:"preset-option",onClick:()=>{var E;i(!1),(E=document.getElementById(`builtin-${_.id}`))==null||E.scrollIntoView({behavior:"smooth"})},children:[n.jsx("span",{className:"mode-title",children:_.name}),n.jsx("span",{className:"mode-subtitle",children:_.note})]},_.id)),X7.map(_=>n.jsxs("button",{className:"preset-option",disabled:h===null||!h.writable,onClick:()=>{o(_),i(!1),k("new")},children:[n.jsx("span",{className:"mode-title",children:_.name}),n.jsx("span",{className:"mode-subtitle",children:_.note})]},_.key))]})]});const S=new Set((h==null?void 0:h.providers.map(_=>_.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 的凭据文件里,界面不会再显示。"}),mp.map(_=>n.jsx(tZ,{client:e,provider:_,catalog:t},_.id)),t==null?void 0:t.groups.filter(_=>!S.has(_.id)&&!mp.some(E=>E.id===_.id)).map(_=>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:_.name}),n.jsx("div",{className:"muted small",children:n.jsx("code",{children:_.id})})]}),n.jsx("span",{className:"badge",children:"内置"})]}),n.jsx("div",{className:"model-chips",children:_.models.map(E=>n.jsx("span",{className:"chip",children:E.name},E.id))})]},_.id)),p!==null&&n.jsx("div",{className:"banner error",children:p}),b!==null&&n.jsx("div",{className:"success small",children:b}),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(_=>n.jsx(J7,{client:e,profile:_,revision:h.revision,readOnly:!h.writable,onEdit:()=>k(_.id),onRemoved:E=>{j(E?"已删除。它原本是新会话的默认模型,默认模型已恢复为 profile 自带的设置。":null),w()}},_.id))]})}function J7({client:e,profile:t,revision:s,readOnly:i,onEdit:r,onRemoved:o}){const[l,u]=v.useState(!1),[d,h]=v.useState(null),m=Cg(t.api),p=async()=>{var x,k;const g=t.apiKeyRef!==void 0&&((x=t.credential)==null?void 0:x.source)==="file"?`
249
+
250
+ 同时删除已保存的 Key(${t.apiKeyRef})。`:"";if(await Ms({title:`删除「${t.displayName}」?`,message:`使用它的会话需要换一个模型。${g}`,confirmLabel:"删除",danger:!0})){u(!0),h(null);try{const{defaultReset:b}=await e.removeProvider({id:t.id,removeKey:((k=t.credential)==null?void 0:k.source)==="file",expectedRevision:s});o(b)}catch(b){h(b instanceof Error?b.message:String(b))}finally{u(!1)}}};return n.jsxs("section",{className:"card provider-card",children:[n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{className:"provider-title",children:[n.jsx("h3",{children:t.displayName}),n.jsxs("div",{className:"muted small",children:[n.jsx("code",{children:t.id}),t.baseURL!==void 0&&n.jsxs(n.Fragment,{children:[" · ",n.jsx("span",{className:"mono",children:t.baseURL})]})]})]}),n.jsxs("div",{className:"badges",children:[n.jsx("span",{className:"badge",children:m===void 0?t.api??"内置目录":`${m.title} · ${m.subtitle}`}),n.jsx(eZ,{profile:t}),t.active?n.jsx("span",{className:"badge ok",children:"已生效"}):n.jsx("span",{className:"badge warn",title:t.error,children:"未生效"})]})]}),t.error!==void 0&&n.jsx("div",{className:"error small",children:t.error}),t.models.length>0?n.jsx("div",{className:"model-chips",children:t.models.map(g=>n.jsxs("span",{className:"chip",title:g.name??g.id,children:[g.id,$a(g.contextWindow)!==null&&n.jsxs("span",{className:"muted",children:[" · ",$a(g.contextWindow)]})]},g.id))}):n.jsx("div",{className:"muted small",children:"使用 dsh 内置的模型目录。"}),d!==null&&n.jsx("div",{className:"error small",children:d}),n.jsxs("div",{className:"key-actions",children:[!t.declared&&n.jsx("span",{className:"muted small",children:"这是 dsh 内置提供方的配置,请在 dsh 官方模型页面编辑。"}),n.jsx("span",{className:"spacer"}),n.jsx("button",{className:"danger-outline",onClick:()=>void p(),disabled:l||i,children:"删除"}),t.declared&&n.jsx("button",{onClick:r,disabled:l||i,children:"编辑"})]})]})}function eZ({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 tZ({client:e,provider:t,catalog:s}){const{items:i}=yw(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(cZ,{client:e,refName:t.keyRef,title:`${t.name} API Key`,description:"",helpUrl:t.keyUrl,info:r,bare:!0})]})}const gc="",rc=e=>e==null?gc:`${e.provider}/${e.model}`;function qj(e){if(e===gc)return null;const[t,...s]=e.split("/");return{provider:t,model:s.join("/")}}function ql(e,t){var s,i;return((i=(s=e.groups.find(r=>r.id===t.provider))==null?void 0:s.models.find(r=>r.id===t.model))==null?void 0:i.name)??t.model}function fd(e,t){return[...t==null||e.groups.some(i=>i.id===t.provider&&i.models.some(r=>r.id===t.model))?[]:[{value:rc(t),label:`${t.provider} / ${t.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...e.groups.flatMap(i=>i.models.map(r=>({value:`${i.id}/${r.id}`,label:r.name,group:i.name})))]}function nZ({client:e}){const{catalog:t,error:s}=aa(e),i=Se(e.capabilities),r=Se(e.connection.status),o=$i(e),[l,u]=v.useState(null),[d,h]=v.useState(!1),[m,p]=v.useState(null),g=i.has("agent-models");v.useEffect(()=>{if(r.state!=="open"||!g)return;let S=!0;return e.connection.call("models/agentModels",{}).then(_=>{S&&u(_)}).catch(()=>{}),()=>{S=!1}},[e,r.state,g]),v.useEffect(()=>e.connection.on("models/agentModelsChanged",u),[e]);const x=async S=>{h(!0),p(null);try{p(await S())}catch(_){p({tone:"warn",text:_ instanceof Error?_.message:String(_)})}finally{h(!1)}},k=S=>void x(async()=>{const _=qj(S);return await e.connection.call("models/setDefault",_),{tone:"ok",text:`默认模型换成了 ${ql(t,_)}:助手和跟随默认的 agent 从下一句起用它。`}}),b=(S,_,E)=>void x(async()=>{const M=qj(E),{warning:O}=await e.connection.call("models/setAgentModel",{...S===void 0?{}:{agentId:S.id},..._?{sub:!0}:{},model:M});if(u(P=>P===null?P:sZ(P,S==null?void 0:S.id,_,M)),O!==void 0)return{tone:"warn",text:O};const B=M===null?void 0:ql(t,M);if(!_)return{tone:"ok",text:B===void 0?`「${S.name}」改回跟随默认模型,从下一句起生效。`:`「${S.name}」的对话从下一句起用 ${B}。`};const U=S===void 0?"没单独设的子 agent":`「${S.name}」新开的子 agent`;return{tone:"ok",text:B===void 0?`${U}改回跟随,正在干活的不受影响。`:`${U}用 ${B},正在干活的不受影响。`}}),j=[cn,...o.map(Ka)],w=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}),!w&&s===null&&n.jsx("div",{className:"muted small",children:"读取中…"}),w&&n.jsxs("div",{className:"agent-models",role:"table","aria-label":"每个 agent 用的模型",children:[n.jsxs("div",{className:"agent-models-row head",role:"row",children:[n.jsx("span",{role:"columnheader",children:"agent"}),n.jsx("span",{role:"columnheader",children:"对话"}),g&&n.jsx("span",{role:"columnheader",children:"子 agent"})]}),g&&n.jsxs("div",{className:"agent-models-row all",role:"row",children:[n.jsxs("div",{className:"agent-models-name",role:"cell",children:[n.jsx("strong",{children:"所有子 agent"}),n.jsx("span",{className:"muted small",children:"下面没单独设子 agent 模型的,都用这个"})]}),n.jsx("div",{className:"agent-models-cell empty",role:"cell"}),n.jsxs("div",{className:"agent-models-cell",role:"cell",children:[n.jsx("span",{className:"agent-models-cell-label",children:"子 agent"}),n.jsx(Mt,{"aria-label":"所有子 agent 的模型",value:rc(l.subAgents),disabled:d,onChange:S=>b(void 0,!0,S),options:[{value:gc,label:"和开它的 agent 一样"},...fd(t,l.subAgents)]})]})]}),j.map(S=>{const _=S.id===cn.id,E=_?t.default:(l==null?void 0:l.agents[S.id])??null,M=E??t.default,O=(l==null?void 0:l.subAgentsOf[S.id])??null,B=(l==null?void 0:l.subAgents)==null?`和${S.name}一样(${ql(t,M)})`:`跟随上面(${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:S.name}),n.jsx("span",{className:"muted small",children:_?"它用的就是默认模型":S.description})]}),n.jsxs("div",{className:"agent-models-cell",role:"cell",children:[n.jsx("span",{className:"agent-models-cell-label",children:"对话"}),_?n.jsx(Mt,{"aria-label":"默认模型(助手)",value:rc(E),disabled:d||!i.has("model-default"),onChange:k,options:fd(t,E)}):n.jsx(Mt,{"aria-label":`${S.name}的模型`,value:rc(E),disabled:d||!g,onChange:U=>b(S,!1,U),options:[{value:gc,label:`跟随默认(${ql(t,t.default)})`},...fd(t,E)]})]}),g&&n.jsxs("div",{className:"agent-models-cell",role:"cell",children:[n.jsx("span",{className:"agent-models-cell-label",children:"子 agent"}),n.jsx(Mt,{"aria-label":`${S.name}的子 agent 的模型`,value:rc(O),disabled:d,onChange:U=>b(S,!0,U),options:[{value:gc,label:B},...fd(t,O)]})]})]},S.id)})]}),t==null?void 0:t.failures.map(S=>n.jsxs("div",{className:"error small",children:[S.name,":",S.message]},S.id)),m!==null&&n.jsx("div",{className:m.tone==="ok"?"muted small":"error small",children:m.text})]})}function sZ(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 Gj=e=>`${e.provider}/${e.model}`;function iZ(e){const[t,...s]=e.split("/");return{provider:t,model:s.join("/")}}function rZ(e,t){const s=e.groups.find(r=>r.id===t.provider),i=s==null?void 0:s.models.find(r=>r.id===t.model);return{service:(s==null?void 0:s.name)??t.provider,model:(i==null?void 0:i.name)??t.model,missing:i===void 0}}const aZ=[{sub:!1,key:"agents",title:"agent 的对话",hint:"助手和各个 agent 自己的对话"},{sub:!0,key:"subAgents",title:"子 agent",hint:"派去干具体活的子 agent"}];function oZ({client:e}){const{catalog:t}=aa(e),s=Se(e.connection.status),[i,r]=v.useState(null),[o,l]=v.useState(!1),[u,d]=v.useState(null);if(v.useEffect(()=>{if(s.state!=="open")return;let m=!0;return e.connection.call("models/agentModels",{}).then(p=>{m&&r(p.fallbacks??null)}).catch(()=>{}),()=>{m=!1}},[e,s.state]),v.useEffect(()=>e.connection.on("models/agentModelsChanged",m=>r(m.fallbacks??null)),[e]),i===null||t===null)return null;const h=async(m,p)=>{l(!0),d(null);const g=i;r({...i,[m?"subAgents":"agents"]:p});try{await e.connection.call("models/setFallbacks",{sub:m,models:p})}catch(x){r(g),d(x instanceof Error?x.message:String(x))}finally{l(!1)}};return n.jsxs("section",{className:"card",children:[n.jsx("div",{className:"card-head",children:n.jsxs("div",{children:[n.jsx("h3",{children:"备用模型"}),n.jsx("p",{className:"muted small",children:"模型报错用不了时(余额不足、Key 失效、模型下线、请求重试后仍超时或服务出错),agent 自动换成下面的下一个模型接着做,对话里会出现一张卡片,写明换到了哪个服务的哪个模型、因为什么;agent 自己也看得到这张卡片。 按顺序从出错的那个往下试,试过的不再试;网络断了、对话太长这类换模型也没用的错误不会切换。"})]})}),n.jsx("div",{className:"fallback-lists",children:aZ.map(({sub:m,key:p,title:g,hint:x})=>{const k=i[p],b=new Set(k.map(Gj)),j=t.groups.flatMap(S=>S.models.filter(_=>!b.has(`${S.id}/${_.id}`)).map(_=>({value:`${S.id}/${_.id}`,label:_.name,group:S.name}))),w=(S,_)=>{const E=[...k],[M]=E.splice(S,1);E.splice(_,0,M),h(m,E)};return n.jsxs("div",{className:"fallback-list",children:[n.jsxs("div",{className:"fallback-list-head",children:[n.jsx("strong",{children:g}),n.jsx("span",{className:"muted small",children:x})]}),k.length===0?n.jsx("div",{className:"muted small fallback-empty",children:"没有备用模型:出错就停下,等你处理。"}):n.jsx("ol",{children:k.map((S,_)=>{const E=rZ(t,S);return n.jsxs("li",{className:E.missing?"missing":void 0,children:[n.jsx("span",{className:"fallback-order",children:_+1}),n.jsxs("span",{className:"fallback-name",children:[n.jsx("span",{children:E.model}),n.jsx("span",{className:"muted small",children:E.missing?"不可用:这个模型服务没有配好,会跳过":E.service})]}),n.jsxs("span",{className:"fallback-actions",children:[n.jsx("button",{className:"icon-button","aria-label":`把 ${E.model} 往前移`,title:"往前移",disabled:o||_===0,onClick:()=>w(_,_-1),children:n.jsx(ee,{name:"arrow"})}),n.jsx("button",{className:"icon-button down","aria-label":`把 ${E.model} 往后移`,title:"往后移",disabled:o||_===k.length-1,onClick:()=>w(_,_+1),children:n.jsx(ee,{name:"arrow"})}),n.jsx("button",{className:"icon-button","aria-label":`去掉 ${E.model}`,title:"去掉",disabled:o,onClick:()=>void h(m,k.filter((M,O)=>O!==_)),children:n.jsx(ee,{name:"close"})})]})]},Gj(S))})}),n.jsx(Mt,{"aria-label":`给${g}添加备用模型`,value:"",placeholder:j.length===0?"没有可以添加的模型":"添加备用模型…",disabled:o||j.length===0,options:j,onChange:S=>void h(m,[...k,iZ(S)])})]},p)})}),u!==null&&n.jsx("div",{className:"error small",children:u})]})}const yE={file:"dsh 凭据文件",env:"启动环境变量","project-env":"项目 .env 文件","user-env":"dsh 主目录 .env 文件"};function bE(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 lZ({client:e}){const t=Se(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(nZ,{client:e}),t.has("agent-models")&&n.jsx(oZ,{client:e}),t.has("providers")&&n.jsx(Q7,{client:e})]})}function cZ({client:e,refName:t,title:s,description:i,helpUrl:r,info:o,placeholder:l,bare:u=!1}){const[d,h]=v.useState(""),[m,p]=v.useState(!1),[g,x]=v.useState(!1),[k,b]=v.useState(null),j=bE(d),w=o!==null&&!o.writable,S=async()=>{if(!(d.trim()===""||j!==null)){x(!0),b(null);try{await e.setCredential(t,d.trim()),h(""),p(!1),b({tone:"ok",text:"已保存,立即生效。"})}catch(M){b({tone:"error",text:M instanceof Error?M.message:String(M)})}finally{x(!1)}}},_=async()=>{if(await Ms({title:`删除已保存的 ${s}?`,message:"删除后需要重新填写才能使用对应模型。",confirmLabel:"删除",danger:!0})){x(!0),b(null);try{await e.unsetCredential(t),b({tone:"ok",text:"已删除。"})}catch(M){b({tone:"error",text:M instanceof Error?M.message:String(M)})}finally{x(!1)}}},E=u?"div":"section";return n.jsxs(E,{className:u?"credential-inline":"card",children:[!u&&n.jsxs("div",{className:"card-head",children:[n.jsxs("div",{children:[n.jsx("h3",{children:s}),n.jsxs("div",{className:"muted small",children:[i," ",n.jsx("code",{children:t})]})]}),n.jsx(uZ,{info:o})]}),w?n.jsxs("div",{className:"notice info left",children:["当前 Key 来自",yE[o.source??""]??o.source,",优先级高于界面保存的值,因此这里无法修改。 如需在界面中管理,请先从启动 dsh 的环境中移除 ",n.jsx("code",{children:t})," 再重新启动。"]}):n.jsxs("form",{className:"key-form",onSubmit:M=>{M.preventDefault(),S()},children:[n.jsxs("div",{className:"key-input",children:[n.jsx("input",{type:m?"text":"password",value:d,onChange:M=>{h(M.target.value),b(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(M=>!M),disabled:d==="",children:m?"隐藏":"显示"})]}),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 _(),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?"替换":"保存"})]})]}),k!==null&&n.jsx("div",{className:k.tone==="ok"?"success small":"error small",children:k.text})]})}function uZ({info:e}){return e===null?n.jsx("span",{className:"badge",children:"读取中…"}):e.configured?n.jsxs("span",{className:"badge ok",children:["已配置 · ",yE[e.source??""]??e.source??"未知来源"]}):n.jsx("span",{className:"badge warn",children:"未配置"})}const dZ=(e,t)=>e===null||t===null?e===t:e.provider===t.provider&&e.model===t.model,hZ=(e,t)=>e.auto===t.auto&&e.threshold===t.threshold&&dZ(e.summarizer,t.summarizer),Ag="\0",Kj=e=>e===null?"":`${e.provider}${Ag}${e.model}`;function mZ({client:e}){var w;const t=Se(e.connection.status),[s,i]=v.useState(null),[r,o]=v.useState(null),[l,u]=v.useState(!1),[d,h]=v.useState(null),m=(w=Vs())==null?void 0:w.restartService,{catalog:p}=aa(e),g=S=>{if(S===null)return"对话自己的模型";const _=p==null?void 0:p.groups.find(M=>M.id===S.provider),E=_==null?void 0:_.models.find(M=>M.id===S.model);return E===void 0?`${S.provider} / ${S.model}`:`${_.name} · ${E.name}`};v.useEffect(()=>{if(d===null||s===null)return;if(d===s.settings.threshold){h(null);return}const S=setTimeout(()=>void x({...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 x=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()=>{m===void 0||!await Ms({title:"现在重启 agent 服务?",message:"正在进行的对话和正在跑的脚本、流水线会被中断,大约需要半分钟。",confirmLabel:"重启",danger:!0,icon:"refresh"})||await m()},b=(s==null?void 0:s.settings.summarizer)??null,j=b!==null&&p!==null&&!p.groups.some(S=>S.id===b.provider&&S.models.some(_=>_.id===b.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 x({...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)===E2?"(默认)":""]}),n.jsx("input",{type:"range",min:rw,max:aw,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(Mt,{"aria-label":"写摘要的模型",value:Kj(s.settings.summarizer),disabled:l||p===null,onChange:S=>{const[_="",E=""]=S.split(Ag);x({...s.settings,summarizer:S===""?null:{provider:_,model:E}})},options:[{value:"",label:"和对话用同一个模型(默认)",hint:"能用上对话的提示缓存"},...((p==null?void 0:p.groups)??[]).flatMap(S=>S.models.map(_=>({value:`${S.id}${Ag}${_.id}`,label:_.name,hint:S.name}))),...j?[{value:Kj(s.settings.summarizer),label:`${s.settings.summarizer.provider} / ${s.settings.summarizer.model}`,hint:"已不在模型列表里"}]:[]]}),n.jsx("span",{className:"muted small",children:"自动压缩、手动压缩和低上下文模式都由它读一遍要压缩的那段对话,写出摘要。默认用对话自己的模型,这段对话大多能命中它的提示缓存;换成别的模型时整段按没命中缓存计费,而且它的上下文要装得下这一段,装不下时压缩会失败。"}),j&&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),压缩会失败:换一个,或改回和对话用同一个模型。"]})]})]}),!hZ(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),"写)。",m===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),m!==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 x({...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 x({...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(Mt,{"aria-label":"多久以后归档",value:String(s.settings.archiveDays),disabled:l||!s.settings.lowContext,onChange:S=>void x({...s.settings,archiveDays:Number(S)}),options:[...new Set([...I2,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 x({...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?"用代码调用工具":"一次调用一个工具",")。",m===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),m!==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 正在工作时不能压缩。"]})]}),s===null&&r!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:r})]})]})}const $g=[{kind:"core",title:"核心",hint:`你最在意的要求和偏好:每个 agent 每次都会带上,不会被挤掉;所有核心一共最多 ${Vg} 字,总是共享`},{kind:"profile",title:"资料",hint:"长期有效的事实和偏好"},{kind:"journal",title:"日记",hint:"某一天做过或决定的事"}],fZ={core:"核心",profile:"资料",journal:"日记"},Hr="",pZ=["周日","周一","周二","周三","周四","周五","周六"];function gZ(e){const t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function xZ(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}日 ${pZ[r.getDay()]}`;return l===0?`今天 · ${u}`:l===1?`昨天 · ${u}`:u}const xc=e=>e.kind==="journal"?e.createdAt:e.updatedAt,kE=(e,t)=>s=>{s.key==="Enter"&&(s.ctrlKey||s.metaKey)?(s.preventDefault(),e()):s.key==="Escape"&&(s.preventDefault(),t())};function vZ({client:e}){var F,V;const t=Se(e.connection.status),s=$i(e),[i,r]=v.useState(null),[o,l]=v.useState(0),[u,d]=v.useState(wa),[h,m]=v.useState(Hr),[p,g]=v.useState(""),[x,k]=v.useState(!1),[b,j]=v.useState(null);v.useEffect(()=>e.connection.on("memory/changed",()=>l(D=>D+1)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let D=!0;return e.connection.call("memory/list",{}).then(q=>{D&&(r(q.items),j(null))}).catch(q=>{D&&j(Ce(q))}),()=>{D=!1}},[e,t.state,o]);const w=v.useMemo(()=>[{id:cn.id,name:cn.name},...s.map(D=>({id:D.id,name:D.name}))],[s]),S=D=>{var q;return D===wa?"共享":D==="user"?"你":D==="auto"?"自动整理":((q=w.find(te=>te.id===D))==null?void 0:q.name)??D},_=p.trim().toLowerCase().split(/\s+/).filter(D=>D!==""),E=D=>(i??[]).filter(q=>q.scope===D).length,M=(i??[]).filter(D=>D.scope===u),O=(i??[]).filter(D=>D.kind==="core").reduce((D,q)=>D+q.text.length,0),B=M.filter(D=>(h===Hr||D.kind===h)&&_.every(q=>D.text.toLowerCase().includes(q))).sort((D,q)=>xc(q).localeCompare(xc(D))),U=B.filter(D=>D.kind==="core"),P=[];for(const D of B.filter(q=>q.kind!=="core")){const q=gZ(xc(D));((F=P.at(-1))==null?void 0:F.day)===q?P.at(-1).entries.push(D):P.push({day:q,entries:[D]})}const R=[{id:wa,name:"共享"},...w],z=((V=R.find(D=>D.id===u))==null?void 0:V.name)??u,L=u===wa,A=_.length>0||h!==Hr,T=async D=>{j(null);try{return await D(),l(q=>q+1),!0}catch(q){return j(Ce(q)),!1}},H=async(D,q)=>{const te=D==="core"?wa:u;return await T(()=>e.connection.call("memory/add",{kind:D,scope:te,text:q}))?(te!==u&&d(te),h!==Hr&&h!==D&&m(Hr),g(""),k(!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(yZ,{client:e}),n.jsxs("section",{className:"card memory-browse",children:[n.jsxs("div",{className:"card-head memory-head",children:[n.jsxs("div",{className:"memory-whose",children:[n.jsx(Mt,{className:"scope-select","aria-label":"谁的记忆",value:u,onChange:d,options:R.map(D=>({value:D.id,label:D.id===wa?"共享的记忆":`「${D.name}」的记忆`,hint:E(D.id)===0?"还没有":`${E(D.id)} 条`,...D.id===wa?{}:{group:"一个 agent 自己的"}}))}),n.jsx("span",{className:"muted small",children:L?"每个 agent 都看得到":`只有「${z}」自己看得到`})]}),!x&&n.jsxs("button",{className:"small-button",onClick:()=>k(!0),children:[n.jsx(ee,{name:"plus"}),"记一条"]})]}),x&&n.jsx(bZ,{to:L?"共享":`「${z}」`,coreUsed:O,onAdd:H,onClose:()=>k(!1)}),b!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:b})]}),M.length>0&&n.jsxs("div",{className:"memory-filters",children:[n.jsx("div",{className:"memory-kinds",role:"radiogroup","aria-label":"种类",children:[{kind:Hr,title:"全部"},...$g].map(D=>n.jsxs("button",{role:"radio","aria-checked":h===D.kind,className:`filter-chip ${h===D.kind?"active":""}`,onClick:()=>m(D.kind),children:[D.title,n.jsx("span",{className:"memory-kind-count",children:D.kind===Hr?M.length:M.filter(q=>q.kind===D.kind).length})]},D.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:D=>g(D.target.value),"aria-label":"搜索记忆"})]})]}),U.length>0&&n.jsxs("div",{className:"memory-day memory-core",children:[n.jsx("h4",{className:"memory-day-title",children:n.jsxs("span",{children:["核心 · 每次都带上(",O," / ",Vg," 字)"]})}),n.jsx("ul",{className:"memory-list",children:U.map(D=>n.jsx(Yj,{entry:D,nameOf:S,onSave:q=>T(()=>e.connection.call("memory/update",{id:D.id,text:q})),onForget:()=>void Ms({title:"删掉这条核心记忆?",message:"之后 agent 就不会每次都带上它了,不能撤销。",quote:D.text,confirmLabel:"删掉",danger:!0}).then(q=>{q&&T(()=>e.connection.call("memory/remove",{id:D.id}))})},D.id))})]}),P.length===0&&U.length===0?n.jsxs("div",{className:"memory-empty",children:[n.jsx("p",{className:"muted",children:A?"没有找到。":`「${z}」还没有记忆。`}),A?n.jsx("button",{className:"link-button small",onClick:()=>{m(Hr),g("")},children:"清除筛选"}):n.jsx("p",{className:"muted small",children:"agent 干活时会自己记下,你也可以点「记一条」写给它。"})]}):P.map(D=>n.jsxs("div",{className:"memory-day",children:[n.jsx("h4",{className:"memory-day-title",children:n.jsx("span",{children:xZ(D.day)})}),n.jsx("ul",{className:"memory-list",children:D.entries.map(q=>n.jsx(Yj,{entry:q,nameOf:S,onSave:te=>T(()=>e.connection.call("memory/update",{id:q.id,text:te})),onForget:()=>void Ms({title:"忘掉这条记忆?",message:"之后 agent 就不记得了,不能撤销。",quote:q.text,confirmLabel:"忘掉",danger:!0}).then(te=>{te&&T(()=>e.connection.call("memory/remove",{id:q.id}))})},q.id))})]},D.day))]})]}),i===null&&b!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:b})]})]})}function yZ({client:e}){const t=Se(e.connection.status),{catalog:s}=aa(e),[i,r]=v.useState(null),[o,l]=v.useState(!1),[u,d]=v.useState(null);v.useEffect(()=>{if(t.state!=="open")return;let k=!0;return e.connection.call("memory/auto/get",{}).then(b=>{k&&(r(b),d(null))}).catch(b=>{k&&d(Ce(b))}),()=>{k=!1}},[e,t.state]);const h=async k=>{l(!0),d(null);try{const b=await e.connection.call("memory/auto/set",{auto:k.auto,model:k.model});r({...b,...(i==null?void 0:i.forced)===!0?{forced:!0}:{}})}catch(b){d(Ce(b))}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 m=i.auto||i.forced===!0,p=i.model===null?"":`${i.model.provider}/${i.model.model}`,g=p===""||((s==null?void 0:s.groups.some(k=>k.models.some(b=>`${k.id}/${b.id}`===p)))??!1),x=k=>{const[b,...j]=k.split("/");h({...i,model:k===""?null:{provider:b,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:m,disabled:o||i.forced===!0,onChange:k=>void h({...i,auto:k.target.checked})}),n.jsxs("span",{className:"memory-auto-text",children:[n.jsx("strong",{children:"自动整理"}),n.jsxs("span",{className:"muted small",children:["对话停下几分钟后,自动把没记下的偏好和做过的事整理进记忆",i.forced===!0?"。低上下文模式开着,自动整理会一直开着。":""]})]})]}),m&&n.jsxs("label",{className:"field memory-auto-model",children:[n.jsx("span",{className:"field-title",children:"整理用的模型"}),s===null?n.jsx("span",{className:"muted small",children:"读取中…"}):n.jsx(Mt,{"aria-label":"整理用的模型",value:p,disabled:o,onChange:x,options:[{value:"",label:"和默认模型一样"},...g?[]:[{value:p,label:`${i.model.provider} / ${i.model.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...s.groups.flatMap(k=>k.models.map(b=>({value:`${k.id}/${b.id}`,label:b.name,group:k.name})))]})]})]}),u!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:u})]})]})}function bZ({to:e,coreUsed:t,onAdd:s,onClose:i}){var k;const[r,o]=v.useState(""),[l,u]=v.useState("profile"),[d,h]=v.useState(!1),m=Vg-t,p=l==="core"&&r.trim().length>m,g=!d&&r.trim()!==""&&!p,x=async()=>{g&&(h(!0),await s(l,r.trim()),h(!1))};return n.jsxs("div",{className:"memory-compose",children:[n.jsx("textarea",{className:"text-input plain",rows:3,maxLength:qg,autoFocus:!0,"aria-label":"要记下的事",placeholder:"一句话写一件事,例如:日报只要告诉我有没有失败的;明日方舟只玩 B 服。",value:r,onChange:b=>o(b.target.value),onKeyDown:kE(()=>void x(),i)}),n.jsxs("div",{className:"memory-compose-foot",children:[n.jsx("div",{className:"segmented-control memory-kind",role:"radiogroup","aria-label":"种类",children:$g.map(b=>n.jsx("button",{role:"radio","aria-checked":l===b.kind,className:l===b.kind?"active":"",onClick:()=>u(b.kind),children:b.title},b.kind))}),n.jsxs("span",{className:`small memory-compose-hint ${p?"warn-text":"muted"}`,children:[(k=$g.find(b=>b.kind===l))==null?void 0:k.hint,l==="core"&&(p?`。核心只剩 ${Math.max(0,m)} 字了:先合并或删掉几条,或记成资料。`:`(还能写 ${m} 字)`)]}),n.jsxs("span",{className:"memory-compose-actions",children:[n.jsx("button",{disabled:d,onClick:i,children:"取消"}),n.jsx("button",{className:"primary",disabled:!g,onClick:()=>void x(),children:d?"记下中…":l==="core"?"记成核心":`记到${e}`})]})]})]})}function Yj({entry:e,nameOf:t,onSave:s,onForget:i}){const[r,o]=v.useState(null),[l,u]=v.useState(!1),d=!l&&r!==null&&r.trim()!=="",h=async()=>{d&&(u(!0),await s(r.trim())&&o(null),u(!1))};return n.jsxs("li",{className:`memory-row ${r===null?"":"editing"}`,children:[n.jsx("time",{className:"memory-time",dateTime:xc(e),title:e.kind==="journal"?"记下的时间":"最后更新的时间",children:new Date(xc(e)).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}),n.jsxs("div",{className:"memory-body",children:[r===null?n.jsx("div",{className:"memory-text",children:e.text}):n.jsx("textarea",{className:"text-input plain",rows:3,maxLength:qg,value:r,onChange:m=>o(m.target.value),onKeyDown:kE(()=>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:fZ[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 Xj=[{policy:"default",label:"默认",hint:"跟着上面的模式走"},{policy:"allow",label:"允许",hint:"不问你,直接做"},{policy:"ask",label:"先问我",hint:"每次都先问你,「完全访问」时也问"},{policy:"deny",label:"不允许",hint:"agent 不能做,会告诉你被关掉了"}],kZ=[{value:"auto",label:"自动更新"},{value:"ask",label:"先问我"},{value:"off",label:"不自动更新"}],jZ=[{value:"act",label:"诊断并处理"},{value:"diagnose",label:"只诊断"},{value:"off",label:"不干预"}];function NZ({client:e,state:t,onState:s}){const i=Se(e.capabilities),[r,o]=v.useState(null),[l,u]=v.useState(null),[d,h]=v.useState(null),m=i.has("monitor"),p=i.has("scripts"),[g,x]=v.useState(null);v.useEffect(()=>{if(!p)return;let w=!0;return e.connection.call("scripts/settings",{}).then(S=>{w&&x(S.autoUpdate)}).catch(()=>{}),()=>{w=!1}},[e,p]),v.useEffect(()=>{if(!m)return;let w=!0;return e.connection.call("monitor/settings",{}).then(S=>{w&&h(S)}).catch(()=>{}),()=>{w=!1}},[e,m]);const k=async(w,S)=>{o(w),u(null);try{s(await e.connection.call("permissions/area/set",{area:w,policy:S}))}catch(_){u(Ce(_))}finally{o(null)}},b=async w=>{o("autoUpdate"),u(null);try{x((await e.connection.call("scripts/settings/set",{autoUpdate:w})).autoUpdate)}catch(S){u(Ce(S))}finally{o(null)}},j=async w=>{o("intervene"),u(null);try{h(await e.connection.call("monitor/settings/set",{intervene:w}))}catch(S){u(Ce(S))}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 能自己做的事,一项一项决定:",Xj.map(w=>`「${w.label}」${w.hint}`).join(";"),"。"]})]})}),n.jsxs("div",{className:"area-list",children:[m&&d!==null&&n.jsxs("div",{className:"area-row",children:[n.jsxs("div",{className:"area-text",children:[n.jsx("strong",{children:"主动干预出问题的脚本"}),n.jsx("span",{className:"muted small",children:"脚本卡住、报错,自动处理解决不了时交给 agent:「诊断并处理」会暂停脚本、看屏幕、点击输入来解决;「只诊断」只说明原因由你决定。"})]}),n.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":"主动干预",children:jZ.map(w=>n.jsx("button",{role:"radio","aria-checked":d.intervene===w.value,className:d.intervene===w.value?"active":"",disabled:r!==null,onClick:()=>void j(w.value),children:w.label},w.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:kZ.map(w=>n.jsx("button",{role:"radio","aria-checked":g===w.value,className:g===w.value?"active":"",disabled:r!==null,onClick:()=>void b(w.value),children:w.label},w.value))})]}),c2.map(w=>{const S=t.areas[w.id]??"default";return n.jsxs("div",{className:"area-row",children:[n.jsxs("div",{className:"area-text",children:[n.jsx("strong",{children:w.title}),n.jsx("span",{className:"muted small",children:w.description})]}),n.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":w.title,children:Xj.map(_=>n.jsx("button",{role:"radio","aria-checked":S===_.policy,title:_.hint,className:`${S===_.policy?"active":""} ${_.policy}`,disabled:r!==null,onClick:()=>void k(w.id,_.policy),children:_.label},_.policy))})]},w.id)})]}),l!==null&&n.jsxs("div",{className:"notice error left",children:[n.jsx(ee,{name:"alert"}),n.jsx("span",{children:l})]})]})}const wZ=[{mode:"ask",title:"每次确认(推荐)",text:"agent 的命令在沙箱里运行;安装陌生仓库、操作屏幕、沙箱外的命令、修改脚本文件等,都先问你。"},{mode:"full",title:"完全访问",text:"不用沙箱,所有需要确认的操作都自动允许,也可以修改脚本文件:agent 想改什么就改什么,不再问你。本软件自己的程序、数据和设置仍然不能改。"}];function SZ({client:e}){const t=Se(e.connection.status),s=vn(3e4),[i,r]=v.useState(null),[o,l]=v.useState(!1),[u,d]=v.useState(null);v.useEffect(()=>e.connection.on("permissions/changed",m=>r(m)),[e]),v.useEffect(()=>{if(t.state!=="open")return;let m=!0;return e.connection.call("permissions/get",{}).then(p=>{m&&r(p)}).catch(p=>{m&&d(Ce(p))}),()=>{m=!1}},[e,t.state]);const h=async m=>{if((i==null?void 0:i.mode)!==m&&!(m==="full"&&!await Ms({title:"打开「完全访问」?",icon:"shield",confirmLabel:"打开",danger:!0,message:`打开后,agent 可以不经确认运行任何命令、修改或删除任何文件(包括脚本文件;本软件自己的程序、数据和设置除外)、操作屏幕、安装软件。
251
+
252
+ 只在你信任当前模型、并且需要它自己完成整件事时打开。`}))){l(!0),d(null);try{r(await e.connection.call("permissions/set",{mode:m}))}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:wZ.map(m=>n.jsxs("button",{role:"radio","aria-checked":(i==null?void 0:i.mode)===m.mode,disabled:o||i===null,className:`permission-option ${m.mode} ${(i==null?void 0:i.mode)===m.mode?"active":""}`,onClick:()=>void h(m.mode),children:[n.jsx("span",{className:"permission-dot","aria-hidden":"true"}),n.jsxs("span",{className:"permission-text",children:[n.jsx("strong",{children:m.title}),n.jsx("span",{children:m.text})]})]},m.mode))}),(i==null?void 0:i.mode)==="full"&&n.jsxs("div",{className:"notice warn-note left small",children:[n.jsx(ee,{name:"alert"}),n.jsxs("span",{children:["完全访问一直开着,没有时间限制,直到你改回「每次确认」",i.since===void 0?"":`(${_Z(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(NZ,{client:e,state:i,onState:r}),i!==null&&i.recent.length>0&&n.jsxs("section",{className:"card",children:[n.jsx("h3",{children:"没问你就允许了的操作"}),n.jsxs("p",{className:"muted small",children:["因为「完全访问」或某个范围设成了「允许」。程序这次启动以来,最近 ",i.recent.length," 条。"]}),n.jsx("ul",{className:"version-list",children:i.recent.map((m,p)=>n.jsxs("li",{children:[n.jsx("span",{className:"badge",children:m.toolName}),n.jsx("span",{className:"permission-reason",children:m.reason??"(没有说明)"}),n.jsx("span",{className:"spacer"}),n.jsx("span",{className:"session-time",children:vt(m.at,s)})]},p))})]})]})}function _Z(e,t){const s=vt(e,t);return s==="刚刚"?"刚刚打开":/^\d+ (分钟|小时|天)$/.test(s)?`${s}前打开`:`${s} 打开`}const Ig=[{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:"今日日常已完成。另有一项需要您决定:活动商店剩余两件,是否明日继续兑换?"}],fp=[{style:"plain",title:"平实",text:"直接说事,不带人设和称呼:它们要读的是内容。推荐。"},{style:"same",title:"和对你一样",text:"人设也带到 agent 之间的往来里,你在「全部」里看到的就是这个语气。"}],pp="",Qj=e=>{var t;return((t=Ig.find(s=>s.style===e))==null?void 0:t.title)??e};function Jj(e){return e===void 0||e.style===void 0&&e.callUser===void 0&&e.custom===void 0&&e.peerStyle===void 0}const eN=e=>{var t,s,i;return[e.style??"",((t=e.name)==null?void 0:t.trim())??"",((s=e.callUser)==null?void 0:s.trim())??"",((i=e.custom)==null?void 0:i.trim())??"",e.peerStyle??""]};function pd(e){const t=Object.entries(e.agents).map(([s,i])=>[s,eN(i)]).filter(([,s])=>s.some(i=>i!=="")).sort(([s],[i])=>s.localeCompare(i));return JSON.stringify([eN({...e.persona,peerStyle:e.persona.peerStyle??"plain"}),t])}function EZ({client:e}){var te,G,K,Z,Y;const t=Se(e.connection.status),s=$i(e),[i,r]=v.useState(null),[o,l]=v.useState(null),[u,d]=v.useState(pp),[h,m]=v.useState(!1),[p,g]=v.useState(null),[x,k]=v.useState(!1),b=Q=>{const ie={persona:Q.persona,agents:Q.agents};r(ie),l(ie)};if(v.useEffect(()=>{if(t.state!=="open")return;let Q=!0;return e.connection.call("persona/get",{}).then(ie=>{Q&&b(ie)}).catch(ie=>{Q&&g(Ce(ie))}),()=>{Q=!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=pd(o)!==pd(i),w=Q=>{l(Q),k(!1)},S=async()=>{m(!0),g(null);try{b(await e.connection.call("persona/set",o)),k(!0)}catch(Q){g(Ce(Q))}finally{m(!1)}},_=[{id:cn.id,name:cn.name},...s.map(Q=>({id:Q.id,name:Q.name}))],E=u===pp,M=o.persona,O=E?void 0:o.agents[u],B=((te=_.find(Q=>Q.id===u))==null?void 0:te.name)??u,U=Q=>w({...o,persona:{...M,...Q}}),P=Q=>{const ie=Object.fromEntries(Object.entries({...O,...Q}).filter(([,re])=>re!==void 0&&(typeof re!="string"||re.trim()!=="")));w({...o,agents:{...o.agents,[u]:ie}})},R=E?U:P,z=E?M:nb(o,u),L=sb(z),A=new Set(sb(E?i.persona:nb(i,u)).split(`
253
+ `)),T=((G=Ig.find(Q=>Q.style===z.style))==null?void 0:G.sample)??"",H=E?M.style:O==null?void 0:O.style,F=E?M.peerStyle??"plain":O==null?void 0:O.peerStyle,V=(Q,ie)=>E?ie:Q===void 0||Q===""?"留空:跟随统一(现在没有设置)":`留空:跟随统一(${Q})`,D=E?pd({persona:M,agents:{}})!==pd({persona:{style:"default"},agents:{}}):!Jj(O),q=()=>w(E?{...o,persona:{style:"default"}}:{...o,agents:{...o.agents,[u]:(O==null?void 0:O.name)===void 0?{}:{name:O.name}}});return n.jsxs("div",{className:"settings-page persona-page",children:[n.jsx("h2",{children:"回复风格"}),n.jsx("p",{children:"agent 说话的方式和人设:可以统一设置,也可以给某个 agent 单独设置。软件里的对话、飞书里的回复、流水线里的 agent 步骤都算。只改说话方式:它们能做什么、该做什么、什么要问你,都不变。子 agent 不用设置,它们只把结果交回给开它们的 agent。"}),n.jsxs("section",{className:"card persona-board",children:[n.jsxs("header",{className:"persona-bar",children:[n.jsxs("label",{className:"persona-who",children:[n.jsx("span",{className:"field-title",children:"设置给"}),n.jsx(Mt,{className:"scope-select","aria-label":"设置给谁",value:u,onChange:d,options:[{value:pp,label:"所有 agent",hint:"统一设置"},..._.map(Q=>{var ne;const ie=o.agents[Q.id],re=(ne=ie==null?void 0:ie.name)==null?void 0:ne.trim();return{value:Q.id,label:re?`${Q.name}(${re})`:Q.name,hint:Jj(ie)?"跟随统一":"有单独设置",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:()=>w(i),children:"撤销"}),n.jsx("button",{className:"primary",disabled:h||!j,onClick:()=>void S(),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:[!E&&n.jsx(tN,{wide:!0,title:"跟随统一",note:`现在是「${Qj(M.style)}」`,selected:H===void 0,onClick:()=>P({style:void 0})}),Ig.map(Q=>n.jsx(tN,{title:Q.title,note:Q.note,selected:H===Q.style,onClick:()=>R({style:Q.style})},Q.style))]})]}),n.jsxs("div",{className:"persona-pair",children:[!E&&n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"它的名字(可选)"}),n.jsx("input",{className:"text-input plain",maxLength:20,placeholder:"例如:小助",value:(O==null?void 0:O.name)??"",onChange:Q=>P({name:Q.target.value}),title:"它自称时用这个名字;别的 agent 也会知道你这么叫它。"})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"怎么称呼你(可选)"}),n.jsx("input",{className:"text-input plain",maxLength:20,placeholder:V(M.callUser,"例如:博士、开拓者、指挥官"),value:(E?M.callUser:O==null?void 0:O.callUser)??"",onChange:Q=>R({callUser:Q.target.value})})]})]}),n.jsxs("label",{className:"field",children:[n.jsx("span",{className:"field-title",children:"其他要求(可选)"}),n.jsx("textarea",{className:"text-input plain persona-custom",rows:4,placeholder:V(M.custom,"例如:说话带一点罗德岛干员的口吻;汇报时先说有没有失败;不要用表情。"),value:(E?M.custom:O==null?void 0:O.custom)??"",onChange:Q=>R({custom:Q.target.value})})]}),n.jsxs("div",{className:"field",children:[n.jsx("span",{className:"field-title",children:"对其他 agent 说话"}),n.jsxs("div",{className:"segmented-control persona-peer",role:"radiogroup","aria-label":"对其他 agent 说话",children:[!E&&n.jsx("button",{role:"radio","aria-checked":F===void 0,className:F===void 0?"active":"",onClick:()=>P({peerStyle:void 0}),children:"跟随统一"}),fp.map(Q=>n.jsx("button",{role:"radio","aria-checked":F===Q.style,className:F===Q.style?"active":"",onClick:()=>R({peerStyle:Q.style}),children:Q.title},Q.style))]}),n.jsx("span",{className:"muted small",children:F===void 0?`和统一设置一样:${(K=fp.find(Q=>Q.style===(M.peerStyle??"plain")))==null?void 0:K.title}。`:(Z=fp.find(Q=>Q.style===F))==null?void 0:Z.text})]}),n.jsxs("div",{className:"persona-foot muted small",children:[n.jsx("span",{children:E?"没有单独设置的 agent 都按这里的来。":"没改的地方跟随「所有 agent」的设置。"}),D&&n.jsx("button",{className:"link-button small",onClick:q,children:E?"恢复默认":"全部改回跟随统一"})]})]}),n.jsx("aside",{className:"persona-preview","aria-label":"预览",children:n.jsxs("div",{className:"persona-preview-in",children:[n.jsxs("div",{className:"persona-preview-head",children:[n.jsx("strong",{children:"预览"}),n.jsx("span",{className:"muted small",children:j?"跟着左边的选择变,保存后生效":"现在生效的设置"})]}),n.jsxs("div",{className:"field",children:[n.jsx("span",{className:"field-title",children:"说出来大概这样"}),T===""?n.jsx("p",{className:"persona-sample none",children:"不加风格,按模型自己的说话方式。"}):n.jsxs("div",{className:"persona-sample",children:[n.jsx("span",{className:"persona-sample-who",children:((Y=z.name)==null?void 0:Y.trim())||(E?"agent":B)}),n.jsx("p",{children:T})]}),n.jsxs("span",{className:"muted small",children:["只是「",Qj(z.style),"」的示例;实际怎么说,模型照下面这段来。"]})]}),n.jsxs("div",{className:"field",children:[n.jsx("span",{className:"field-title",children:E?"加到 agent 提示词里的内容":`加到「${B}」提示词里的内容`}),L===""?n.jsx("p",{className:"persona-prompt empty-prompt",children:"什么都不加。"}):n.jsx("div",{className:"persona-prompt",children:L.split(`
254
+ `).map((Q,ie)=>n.jsx("div",{className:A.has(Q)?"":"changed",children:Q},ie))})]})]})})]})]})]})}function tN({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 CZ={id:"settings-credentials",title:"模型",requires:["credentials","models"],settingsPages:[{id:"api-keys",title:"模型",order:0,component:lZ}]},AZ={id:"permissions",title:"权限",requires:["permissions"],settingsPages:[{id:"permissions",title:"权限",order:1,component:SZ}]},$Z={id:"persona",title:"回复风格",requires:["persona"],settingsPages:[{id:"persona",title:"回复风格",order:2,component:EZ}]},IZ={id:"compaction",title:"对话压缩",requires:["compaction"],settingsPages:[{id:"compaction",title:"对话压缩",order:3,component:mZ}]},TZ={id:"memory",title:"记忆",requires:["memory"],settingsPages:[{id:"memory",title:"记忆",order:2.5,component:vZ}]},MZ={id:"about",title:"关于",requires:[],settingsPages:[{id:"about",title:"关于",order:100,component:B7}]};function RZ({client:e}){const t=Se(e.capabilities),s=Se(e.connection.server),[i,r]=v.useState(0);v.useEffect(()=>vw(()=>r(d=>d+1)),[]);const o=v.useMemo(()=>bO(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 OZ={id:"plugin-status",title:"插件状态",requires:[],settingsPages:[{id:"plugins",title:"插件状态",order:90,component:RZ}]};function PZ(e,t,s){const i=new Array(e);return new Proxy(i,{get(r,o,l){if(typeof o=="string"){const u=o.charCodeAt(0);if(u>=48&&u<=57){const d=+o;if(Number.isInteger(d)&&d>=0&&d<e){let h=r[d];if(!h){const m=t[d*2];h=r[d]={index:d,key:s(d),start:m,size:t[d*2+1],end:m+t[d*2+1],lane:0}}return h}}if(o==="length")return e}return Reflect.get(r,o,l)}})}function No(e,t,s){let i=s.initialDeps??[],r,o=!0;function l(){const u=e();return(u.length!==i.length||u.some((h,m)=>i[m]!==h))&&(i=u,r=t(...u),s!=null&&s.onChange&&!(o&&s.skipInitialOnChange)&&s.onChange(r),o=!1),r}return l.updateDeps=u=>{i=u},l}function nN(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const LZ=(e,t)=>Math.abs(e-t)<1.01,zZ=(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 gp=()=>{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},sN=e=>{const{offsetWidth:t,offsetHeight:s}=e;return{width:t,height:s}},DZ=e=>e,FZ=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},UZ=(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(sN(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(sN(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(s,{box:"border-box"}),()=>{o.unobserve(s)}},Qd={passive:!0},BZ=typeof window>"u"?!0:"onscrollend"in window,HZ=(e,t,s)=>{const i=e.scrollElement;if(!i)return;const r=e.targetWindow;if(!r)return;const o=e.options.useScrollendEvent&&BZ;let l=0;const u=o?null:zZ(r,()=>t(l,!1),e.options.isScrollingResetDelay),d=p=>()=>{l=s(i),u==null||u(),t(l,p)},h=d(!0),m=d(!1);return i.addEventListener("scroll",h,Qd),o&&i.addEventListener("scrollend",m,Qd),()=>{i.removeEventListener("scroll",h),o&&i.removeEventListener("scrollend",m),u==null||u.cancel()}},ZZ=(e,t)=>HZ(e,t,s=>{const{horizontal:i,isRtl:r}=e.options;return i?s.scrollLeft*(r&&-1||1):s.scrollTop}),WZ=(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"]},VZ=(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})},qZ=VZ;class GZ{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var s,i,r;return((r=(i=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let s=null;const i=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(o=>{const l=()=>{const u=o.target,d=this.indexFromElement(u);if(!u.isConnected){this.observer.unobserve(u);for(const[h,m]of this.elementsCache)if(m===u){this.elementsCache.delete(h);break}return}this.isIndexInRange(d)&&this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(u,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),s=null},observe:r=>{var o;return(o=i())==null?void 0:o.observe(r,{box:"border-box"})},unobserve:r=>{var o;return(o=i())==null?void 0:o.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{var i,r;const o={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:DZ,rangeExtractor:FZ,onChange:()=>{},measureElement:WZ,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,k=this.getMeasurements(),b=g>0?((i=k[0])==null?void 0:i.key)??l.getItemKey(0):null,j=g>0?((r=k[g-1])==null?void 0:r.key)??l.getItemKey(g-1):null;if(x!==g||g>0&&x>0&&(o.getItemKey(0)!==b||o.getItemKey(x-1)!==j)){h=!0;const _=g>0?this.getVirtualItemForOffset(this.getScrollOffset())??k[0]:null;_&&(u=[_.key,this.getScrollOffset()-_.start]);const E=o.followOnAppend===!0?"auto":o.followOnAppend||null;E&&x>g&&this.isAtEnd(l.scrollEndThreshold)&&(g===0||o.getItemKey(x-1)!==j)&&(d=E)}}this.options=o,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let m=!1,p=0;if(u&&this.scrollOffset!==null){const[g,x]=u,k=this.getMeasurements(),{count:b,getItemKey:j}=this.options;let w=0;for(;w<b&&j(w)!==g;)w++;if(w<b){const S=k[w];if(S){const _=Math.max(0,S.start+x);_!==this.scrollOffset&&(p=_-this.scrollOffset,this.scrollOffset=_,m=!0)}}}(m||d)&&(this.pendingScrollAnchor=[m?u[0]:null,m?u[1]:0,d,p])},this.notify=s=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,s)},this.maybeNotify=No(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}if(this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,l)=>{if(l&&this._intendedScrollOffset===null&&o===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5&&(o=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const u=this.getScrollOffset();this.scrollDirection=l?u===o?this.scrollDirection:u<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},u=()=>{this._iosTouching=!1,!(!gp()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",l,Qd),o.addEventListener("touchend",u,Qd),this.unsubs.push(()=>{o.removeEventListener("touchstart",l),o.removeEventListener("touchend",u),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const r=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled){const[o,l,u,d]=r;o!==null&&!u&&(gp()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),u&&this.scrollToEnd({behavior:u})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const s=this.getScrollOffset(),i=this.getMaxScrollOffset();if(s<0||s>i)return;if(this._iosDeferredAdjustment<0&&s>=i-1){this._iosDeferredAdjustment=0;return}const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(s,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=No(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(s,i,r,o,l,u,d,h)=>(this.prevLanes!==void 0&&this.prevLanes!==u&&(this.lanesChangedFlag=!0),this.prevLanes=u,this.pendingMin=null,{count:s,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:l,lanes:u,laneAssignmentMode:d,gap:h}),{key:!1}),this.isIndexInRange=s=>s>=0&&s<this.options.count,this.getMeasurements=No(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:l,lanes:u,laneAssignmentMode:d,gap:h},m)=>{const p=this.itemSizeCache;if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const w of this.laneAssignments.keys())w>=s&&this.laneAssignments.delete(w);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(w=>{this.itemSizeCache.set(w.key,w.size)}));const g=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1),u===1){const w=s*2;let S=this._flatMeasurements;if(!S||S.length<w){const M=new Float64Array(w);S&&g>0&&M.set(S.subarray(0,g*2)),S=M,this._flatMeasurements=S}let _;if(g===0)_=i+r;else{const M=g-1;_=S[M*2]+S[M*2+1]+h}for(let M=g;M<s;M++){const O=o(M),B=p.get(O),U=typeof B=="number"?B:this.options.estimateSize(M);S[M*2]=_,S[M*2+1]=U,_+=U+h}const E=PZ(s,S,o);return this.measurementsCache=E,E}const x=this.measurementsCache.slice(0,g),k=new Array(u).fill(void 0),b=new Float64Array(u);let j=0;for(let w=0;w<g;w++){const S=x[w];S&&(k[S.lane]===void 0&&j++,k[S.lane]=w,b[S.lane]=S.end)}for(let w=g;w<s;w++){const S=o(w),_=this.laneAssignments.get(w);let E,M;const O=d==="estimate"||p.has(S);if(_!==void 0&&this.options.lanes>1){E=_;const R=k[E],z=R!==void 0?x[R]:void 0;M=z?z.end+h:i+r}else if(j===u){let R=0,z=b[0],L=k[0];for(let A=1;A<u;A++){const T=b[A];(T<z||T===z&&k[A]<L)&&(R=A,z=T,L=k[A])}E=R,M=z+h,O&&this.laneAssignments.set(w,E)}else E=w%this.options.lanes,M=i+r,O&&this.laneAssignments.set(w,E);const B=p.get(S),U=typeof B=="number"?B:this.options.estimateSize(w),P=M+U;x[w]={index:w,start:M,size:U,end:P,key:S,lane:E},k[E]===void 0&&j++,k[E]=w,b[E]=P}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=No(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,i,r,o)=>s.length===0||i===0?(this.range=null,null):(this.range=YZ(s,i,r,o,o===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=No(()=>{let s=null,i=null;const r=this.calculateRange();return r&&(s=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,i]},(s,i,r,o,l)=>o===null||l===null?[]:s({startIndex:o,endIndex:l,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const i=this.options.indexAttribute,r=s.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(r!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),l=Math.max(0,r-o),u=Math.min(this.options.count-1,r+o);return s>=l&&s<=u}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((l,u)=>{l.isConnected||(this.observer.unobserve(l),this.elementsCache.delete(u))});return}const i=this.indexFromElement(s);if(!this.isIndexInRange(i))return;const r=this.options.getItemKey(i),o=this.elementsCache.get(r);o!==s&&(o&&this.observer.unobserve(o),this.observer.observe(s),this.elementsCache.set(r,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,i)=>{var r,o;if(!this.isIndexInRange(s))return;let l,u,d;const h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)d=this.options.getItemKey(s),u=h[s*2],l=h[s*2+1];else{const g=this.measurementsCache[s];if(!g)return;d=g.key,u=g.start,l=g.size}const m=this.itemSizeCache.get(d)??l,p=i-m;if(p!==0){const g=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,x=g?this.getTotalSize():0,k=this.getScrollOffset()+this.scrollAdjustments,j=!this.itemSizeCache.has(d)?u<k:u+m<=k&&this.scrollDirection!=="backward",w=((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 S=!1;g?S=this.applyScrollAdjustment(this.getTotalSize()-x):w&&(S=this.applyScrollAdjustment(p)),this.notify(S)}},this.getVirtualItems=No(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,i)=>{const r=[];for(let o=0,l=s.length;o<l;o++){const u=s[o],d=i[u];r.push(d)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const i=this.getMeasurements();if(i.length===0)return;const r=this._flatMeasurements,o=this.options.lanes===1&&r!=null,l=jE(0,i.length-1,o?u=>r[u*2]:u=>nN(i[u]).start,s);return nN(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:gp()&&(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&&LZ(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 jE=(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 KZ(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 YZ(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=KZ(r,o,s);let m=h;const p=s+t;for(;m<o&&r[m*2]+r[m*2+1]<p;)m++;return{startIndex:h,endIndex:m}}let u=jE(0,o,h=>e[h].start,s),d=u;if(i===1)for(;d<o&&e[d].end<s+t;)d++;else if(i>1){const h=Array(i).fill(0);for(;d<o&&h.some(p=>p<s+t);){const p=e[d];h[p.lane]=p.end,d++}const m=Array(i).fill(s+t);for(;u>=0&&m.some(p=>p>=s);){const p=e[u];m[p.lane]=p.start,u--}u=Math.max(0,u-u%i),d=Math.min(o,d+(i-1-d%i))}return{startIndex:u,endIndex:d}}const xp=typeof document<"u"?v.useLayoutEffect:v.useEffect;function XZ({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:s="transform",...i}){const r=v.useReducer(m=>m+1,0)[1],o=v.useRef({enabled:t,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=s;const l=m=>{const p=o.current;if(!p.enabled||!p.container)return;const g=m.getTotalSize();if(g!==p.lastSize){p.lastSize=g;const x=m.options.horizontal?"width":"height";p.container.style[x]=`${g}px`}},u=m=>{const p=o.current;if(!p.enabled||!p.container)return;l(m);const g=!!m.options.horizontal,x=p.mode==="transform",k=g?"left":"top",b=m.options.scrollMargin,j=m.getVirtualItems();for(const w of j){const S=w.start-b,_=m.elementsCache.get(w.key);_&&p.lastPositions.get(_)!==S&&(p.lastPositions.set(_,S),x?_.style.transform=g?`translate3d(${S}px, 0, 0)`:`translate3d(0, ${S}px, 0)`:_.style[k]=`${S}px`)}},d={...i,onChange:(m,p)=>{var g;const x=o.current;let k=!0;if(x.enabled){u(m);const b=m.range,j=x.prevRange;k=!j||j.isScrolling!==m.isScrolling||j.startIndex!==(b==null?void 0:b.startIndex)||j.endIndex!==(b==null?void 0:b.endIndex),k&&(x.prevRange=b?{startIndex:b.startIndex,endIndex:b.endIndex,isScrolling:m.isScrolling}:null)}k&&(e&&p?qa.flushSync(r):r()),(g=i.onChange)==null||g.call(i,m,p)}},[h]=v.useState(()=>{const m=new GZ(d);return Object.assign(m,{containerRef:p=>{const g=o.current;if(g.container=p,g.lastSize=null,p&&g.enabled){const x=m.getTotalSize();g.lastSize=x;const k=m.options.horizontal?"width":"height";p.style[k]=`${x}px`}}})});return h.setOptions(d),xp(()=>h._didMount(),[]),xp(()=>(l(h),h._willUpdate())),xp(()=>{u(h)}),h}function QZ(e){return XZ({observeElementRect:UZ,observeElementOffset:ZZ,scrollToFn:qZ,...e})}const Eh={user:"用户",context:"上下文",system:"系统",assistant:"助手",attempt:"失败尝试",tool:"工具",compaction:"压缩"},NE={ok:"已完成",error:"失败",running:"运行中",interrupted:"已中断"},JZ={completed:"已完成",aborted:"已停止",error:"失败",blocked:"已阻止","max-tokens":"达到输出上限",interrupted:"已中断",forked:"已分叉"};function eW(e){return e.turn===null?"轮次之间":`第 ${e.turn} 轮`}function tW(e){return e.end===null?"进行中":e.reason===void 0?"":JZ[e.reason.kind]??e.reason.kind}function wE(e){if(e.kind!=="assistant"||e.request.usage===void 0)return;const t=e.request.usage;return t.inputTokens+(t.cacheReadTokens??0)+(t.cacheWriteTokens??0)}function vc(e){return e.end===null||e.end<e.start?void 0:e.end-e.start}function Jd(e){return e.kind==="assistant"?e.content.filter(t=>t.type==="tool-call").length:0}function nW({record:e,totals:t,onClose:s}){const i=iW(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:Eh[e.kind]}),n.jsx("span",{className:"inspector-title",title:e.title,children:sW(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 sW(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 Eh[e.kind]}}function iW(e,t){switch(e.kind){case"assistant":return[{id:"summary",label:"概述",render:()=>n.jsx(rW,{record:e})},{id:"raw",label:"原始输出",render:()=>n.jsx(vp,{content:e.content})},{id:"usage",label:"用量",render:()=>n.jsx(aW,{record:e,totals:t})},{id:"timing",label:"计时",render:()=>n.jsx(oW,{record:e})}];case"tool":return[{id:"summary",label:"概述",render:()=>n.jsx(Jr,{rows:[["状态",n.jsx(Ed,{record:e})],["工具",n.jsx("code",{children:e.name})],["调用 ID",n.jsx("code",{children:e.callId})],["开始时间",Yr(e.start)],["时长",e.end===null?"运行中":Zs(vc(e))],["审批",e.approval===void 0?"无需审批":e.approval.outcome??"等待中"],["错误",e.error===void 0?void 0:`${e.error.message}${e.error.code===void 0?"":` (${e.error.code})`}`]]})},{id:"payload",label:"参数",render:()=>n.jsx("pre",{className:"payload",children:e.arguments===""?"未捕获参数":hx(e.arguments)})},{id:"result",label:"结果",render:()=>e.result===void 0?n.jsx("p",{className:"muted",children:"未捕获结果"}):n.jsx(vp,{content:e.result})}];case"user":case"context":return[{id:"summary",label:"概述",render:()=>n.jsxs(n.Fragment,{children:[n.jsx(Jr,{rows:[["来源",e.origin.human?"用户":e.origin.kind],["时间",Yr(e.start)],["附件",e.imageCount+e.fileCount===0?void 0:`图片 ×${e.imageCount} · 文件 ×${e.fileCount}`]]}),n.jsx("div",{className:"label",children:"预览"}),n.jsx(vp,{content:e.content})]})},{id:"raw",label:"原始内容",render:()=>n.jsx("pre",{className:"payload",children:JSON.stringify(e.content,null,2)})}];case"system":return[{id:"prompt",label:"系统提示词",render:()=>n.jsx("pre",{className:"payload",children:e.text})}];case"attempt":return[{id:"summary",label:"概述",render:()=>n.jsx(Jr,{rows:[["状态",n.jsx(Ed,{record:e})],["开始时间",Yr(e.start)],["时长",Zs(vc(e))],["错误",e.error===void 0?"尝试在没有输出的情况下结束":`${e.error.message}${e.error.code===void 0?"":` (${e.error.code})`}`]]})}];case"compaction":return[{id:"summary",label:"概述",render:()=>n.jsx(Jr,{rows:[["状态",n.jsx(Ed,{record:e})],["开始时间",Yr(e.start)],["时长",e.end===null?"运行中":Zs(vc(e))],["已压缩",e.shadowedTokenCount===void 0?void 0:`${Nn(e.shadowedTokenCount)} tok`],["输入 / 输出",e.usage===void 0?void 0:`${Nn(e.usage.inputTokens)} / ${Nn(e.usage.outputTokens)} tok`],["错误",e.error]]})}]}}function Ed({record:e}){return n.jsx("span",{className:`status-text status-${e.status}`,children:NE[e.status]})}function Jr({rows:e}){return n.jsx("dl",{className:"facts",children:e.filter(([,t])=>t!==void 0&&t!=="").map(([t,s])=>n.jsxs("div",{className:"fact",children:[n.jsx("dt",{children:t}),n.jsx("dd",{children:s})]},t))})}function rW({record:e}){const t=e.request,s=e.content.filter(r=>r.type==="text").map(r=>r.type==="text"?r.text:"").join(""),i=e.content.filter(r=>r.type==="tool-call");return n.jsxs(n.Fragment,{children:[n.jsx(Jr,{rows:[["状态",n.jsx(Ed,{record:e})],["请求",`#${t.index}`],["提供方",t.provider],["模型",t.model],["推理强度",t.reasoningEffort],["可用工具",t.toolCount===void 0?void 0:String(t.toolCount)],["工具调用",i.length===0?void 0:String(i.length)],["重试",t.retries===0?void 0:String(t.retries)],["上次尝试错误",t.lastRetryError===void 0?void 0:`${t.lastRetryError.message}${t.lastRetryError.code===void 0?"":` (${t.lastRetryError.code})`}`]]}),s.trim()!==""&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"label",children:"助手消息"}),n.jsx(Hs,{text:s,className:"inspector-markdown"})]}),s.trim()===""&&i.length>0&&n.jsx("p",{className:"muted small",children:"(仅工具调用)"}),i.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"label",children:"工具调用"}),n.jsx("ul",{className:"call-list",children:i.map(r=>n.jsxs("li",{children:[n.jsx("code",{children:r.name})," ",n.jsx("span",{className:"muted",children:r.arguments.slice(0,120)})]},r.callId))})]})]})}function vp({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:hx(t.arguments)})]},s);case"image":return n.jsxs("div",{className:"raw-block muted small",children:["🖼 ",t.name??`图片 ${s+1}`," ",t.width!==void 0?`${t.width}×${t.height}`:""]},s);case"file":return n.jsxs("div",{className:"raw-block muted small",children:["📎 ",t.name??"文件"," ",t.size===void 0?"":`${Nn(t.size)}B`]},s);default:return n.jsxs("div",{className:"raw-block muted small",children:["[",t.kind,"]"]},s)}})})}function aW({record:e,totals:t}){const s=e.request.usage;return n.jsxs(n.Fragment,{children:[n.jsx("h4",{className:"usage-heading",children:"本次请求"}),s===void 0?n.jsx("p",{className:"muted",children:"未报告用量"}):n.jsx(Jr,{rows:[["输入(未缓存)",`${Nn(s.inputTokens)} tok`],["缓存读取",s.cacheReadTokens===void 0?void 0:`${Nn(s.cacheReadTokens)} tok`],["缓存写入",s.cacheWriteTokens===void 0?void 0:`${Nn(s.cacheWriteTokens)} tok`],["输入合计",`${Nn(wE(e))} tok`],["输出",`${Nn(s.outputTokens)} tok`],["其中推理",s.reasoningTokens===void 0?void 0:`${Nn(s.reasoningTokens)} tok`],["总计",s.totalTokens===void 0?void 0:`${Nn(s.totalTokens)} tok`]]}),n.jsx("h4",{className:"usage-heading",children:"已加载窗口累计"}),n.jsx(Jr,{rows:[["模型回复",String(t.requests)],["用量记录(含重试及压缩)",`${t.reportedUsage} 条已报告,${t.missingUsage} 条未知`],["输入(未缓存)",`${Nn(t.inputTokens)} tok`],["缓存读取",`${Nn(t.cacheReadTokens)} tok`],["输出",`${Nn(t.outputTokens)} tok`],["其中推理",`${Nn(t.reasoningTokens)} tok`]]})]})}function oW({record:e}){const[t,s]=v.useState(!1),i=e.request;return n.jsx(Jr,{rows:[["开始时间",n.jsx("button",{className:"link-button",onClick:()=>s(r=>!r),title:t?"显示本地时间":"显示 Unix 时间戳",children:t?String(e.start):Yr(e.start)})],["总时长",e.end===null?"运行中":Zs(vc(e))],["首 token 延迟",i.ttftMs===void 0?"不可用(步骤开始时间或首 token 不在已加载范围内)":Zs(i.ttftMs)],["生成",i.decodeMs===void 0?e.live?"运行中":"不可用":Zs(i.decodeMs)],["吞吐量",i.tokensPerSecond===void 0?i.usage===void 0?"用量不可用":"时长过短":`${i.tokensPerSecond.toFixed(1)} tok/s`],["工具调用",Jd(e)===0?void 0:String(Jd(e))],["计时来源",e.live?"会话时间戳(运行中)":"会话时间戳"]]})}const gd=14,lW=v.memo(function({model:t,mode:s,brush:i,selectedId:r,onBrush:o,onSelect:l}){const u=v.useMemo(()=>Yz(t),[t]),d=v.useMemo(()=>kS.map((R,z)=>({...R,index:z})).filter(R=>R.id!=="compaction"||u.some(z=>z.lane===R.index)),[u]),h=new Map(d.map((R,z)=>[R.index,z])),m=t.span,[p,g]=v.useState(null),x=s==="actual"&&m!==null?cW(p,m):null,k=v.useRef(null),[b,j]=v.useState(null),w=v.useRef(null),S=t.records.length,_=(R,z)=>s==="equal"?S===0?0:R/S:x===null||x.end===x.start?0:(z-x.start)/(x.end-x.start),E=R=>{var L;const z=(L=k.current)==null?void 0:L.getBoundingClientRect();return z===void 0||z.width===0?0:Math.min(1,Math.max(0,(R-z.left)/z.width))},M=R=>{if(R.button===2&&x!==null&&m!==null&&(x.start>m.start||x.end<m.end)){w.current={x:R.clientX,view:x};return}if(R.button!==0)return;const z=E(R.clientX);j({x0:z,x1:z})},O=R=>{if(w.current!==null&&m!==null&&k.current!==null){const z=(R.clientX-w.current.x)/k.current.clientWidth,L=w.current.view.end-w.current.view.start;g(Jz(w.current.view,-z*L,m));return}b!==null&&j({...b,x1:E(R.clientX)})},B=()=>{if(w.current=null,b===null)return;const[R,z]=b.x0<b.x1?[b.x0,b.x1]:[b.x1,b.x0];if(j(null),!(z-R<.005)){if(s==="equal")o({mode:"equal",from:Math.floor(R*S),to:Math.max(Math.floor(R*S),Math.ceil(z*S)-1)});else if(x!==null){const L=x.end-x.start;o({mode:"actual",range:{start:x.start+R*L,end:x.start+z*L}})}}},U=R=>{if(s!=="actual"||x===null||m===null)return;const z=x.end-x.start;g(Qz(x,x.start+E(R.clientX)*z,R.deltaY>0?1.25:.8,m))};if(S===0||m===null)return n.jsx("div",{className:"overview empty-overview muted small",children:"无计时数据"});const P=i===null?null:i.mode==="equal"?s==="equal"?{left:i.from/S,right:(i.to+1)/S}:null:s==="actual"?{left:_(0,i.range.start),right:_(0,i.range.end)}:null;return n.jsxs("div",{className:"overview",onContextMenu:R=>{R.preventDefault(),w.current===null&&o(null)},children:[n.jsx("div",{className:"overview-lanes",children:d.map(R=>n.jsx("div",{className:"lane-label",style:{height:gd},children:uW(R.id)},R.id))}),n.jsxs("div",{className:"overview-track",ref:k,style:{height:d.length*(gd+2)},onMouseDown:M,onMouseMove:O,onMouseUp:B,onMouseLeave:B,onWheel:U,children:[u.map((R,z)=>{const L=h.get(R.lane)??0,A=_(z,R.start),T=s==="equal"?(z+1)/S:_(z,R.end);if(T<0||A>1)return null;const H=R.record,F=Math.max(0,Math.min(1,T)-Math.max(0,A)),V=s==="actual"&&R.firstTokenAt!==void 0&&R.end>R.start?(R.firstTokenAt-R.start)/(R.end-R.start):null;return n.jsx("div",{className:`bar kind-${H.kind} status-${H.status} ${R.instant&&s==="actual"?"instant":""} ${H.id===r?"selected":""}`,style:{left:`${Math.max(0,A)*100}%`,width:s==="equal"?`calc(${F*100}% - 1px)`:`max(2px, ${F*100}%)`,top:L*(gd+2),height:gd,...V===null?{}:{"--ttft":`${Math.min(100,Math.max(0,V*100))}%`}},title:dW(H,R.firstTokenAt),onMouseUp:D=>{b!==null&&Math.abs(b.x1-b.x0)<.005&&D.button===0&&l(H)}},H.id)}),P!==null&&n.jsx("div",{className:"brush",style:{left:`${Math.max(0,P.left)*100}%`,width:`${(Math.min(1,P.right)-Math.max(0,P.left))*100}%`}}),b!==null&&n.jsx("div",{className:"brush dragging",style:{left:`${Math.min(b.x0,b.x1)*100}%`,width:`${Math.abs(b.x1-b.x0)*100}%`}})]}),n.jsx("div",{className:"overview-scale muted",children:s==="actual"&&x!==null?n.jsxs(n.Fragment,{children:[n.jsx("span",{children:Yr(x.start)}),n.jsxs("span",{children:["总计 ",Zs(m.end-m.start),p!==null?" · 已缩放":""]}),n.jsx("span",{children:Yr(x.end)})]}):n.jsxs(n.Fragment,{children:[n.jsxs("span",{children:[S," 条记录(等宽)"]}),n.jsxs("span",{children:["总计 ",Zs(m.end-m.start)]}),n.jsx("span",{children:"拖动选择区间 · 右键清除"})]})})]})});function cW(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 uW(e){return e==="input"?"输入":e==="model"?"模型":e==="tool"?"工具":"压缩"}function dW(e,t){const s=[`${Eh[e.kind]} · ${e.title}`,`开始于 ${Yr(e.start)}`];return e.end===null?s.push("进行中(只显示开始标记)"):s.push(`总计 ${Zs(e.end-e.start)}`),e.kind==="assistant"&&t!==void 0&&e.end!==null&&s.push(`首 token ${Zs(t-e.start)} · 解码 ${Zs(e.end-t)}`),s.join(`
255
+ `)}const hW=32,mW=34,fW=60;function pW({session:e,state:t}){const s=v.useMemo(()=>Hz(t.events,t.live,{now:Date.now()}),[t.events,t.live,t.version]),[i,r]=v.useState("equal"),[o,l]=v.useState(null),[u,d]=v.useState(""),[h,m]=v.useState(new Set),[p,g]=v.useState(!0),[x,k]=v.useState(null),b=s.records.find(R=>R.id===x)??null,j=v.useMemo(()=>gW(s,{brush:o,query:u,collapsed:h,showCalls:p}),[s,o,u,h,p]),w=v.useMemo(()=>j.flatMap(R=>R.type==="record"?[R.record]:[]),[j]),S=v.useRef(null),_=bS(fW),E=_.following,M=QZ({count:j.length,getScrollElement:()=>S.current,estimateSize:R=>{var z;return((z=j[R])==null?void 0:z.type)==="group"?mW:hW},getItemKey:R=>{var z;return((z=j[R])==null?void 0:z.key)??R},overscan:12});v.useLayoutEffect(()=>{E.current&&j.length>0&&M.scrollToIndex(j.length-1,{align:"end"})},[j.length,t.version,M]),v.useEffect(()=>{if(x===null)return;const R=j.findIndex(z=>z.type==="record"&&z.record.id===x);R!==-1&&M.scrollToIndex(R,{align:"auto"})},[x]);const O=R=>m(z=>{const L=new Set(z);return L.has(R)?L.delete(R):L.add(R),L}),B=s.groups.length>0&&s.groups.every(R=>h.has(R.key)),U=R=>{if(R.key!=="ArrowDown"&&R.key!=="ArrowUp"&&R.key!=="Escape")return;if(R.preventDefault(),R.key==="Escape"){k(null);return}const z=w.findIndex(A=>A.id===x),L=w[R.key==="ArrowDown"?Math.min(w.length-1,z+1):Math.max(0,z-1)];L!==void 0&&k(L.id)},P=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(R=>R==="equal"?"actual":"equal"),l(null)},title:i==="equal"?"使用实际时长":"使用等宽操作",children:["⏱ ",i==="equal"?"等宽":"实际时间"]}),n.jsxs("button",{className:"toggle",onClick:()=>m(B?new Set:new Set(s.groups.map(R=>R.key))),children:["⊟ ",B?"展开所有轮次":"收起所有轮次"]}),n.jsxs("button",{className:`toggle ${p?"":"on"}`,onClick:()=>g(R=>!R),children:["⊟ ",p?"收起所有调用":"展开所有调用"]}),n.jsx("input",{className:"traj-search",value:u,onChange:R=>d(R.target.value),placeholder:"搜索轨迹","aria-label":"搜索轨迹"}),n.jsxs("span",{className:"traj-totals muted small",title:"已加载窗口内的累计",children:[P.requests," 次请求 · 输入 ",Nn(P.inputTokens+P.cacheReadTokens+P.cacheWriteTokens)," · 输出 ",Nn(P.outputTokens)," · ",P.toolCalls," 次工具调用",P.errors>0?` · ${P.errors} 个错误`:""]})]}),n.jsx(lW,{model:s,mode:i,brush:o,selectedId:x,onBrush:l,onSelect:R=>k(R.id)}),o!==null&&n.jsxs("div",{className:"brush-note small",children:["已按时间区间筛选,显示 ",w.length," 条记录 ",n.jsx("button",{className:"link-button",onClick:()=>l(null),children:"清除"})]}),n.jsxs("div",{className:"traj-main",children:[n.jsxs("div",{className:"ledger",ref:S,onScroll:_.onScroll,onWheel:_.onWheel,tabIndex:0,onKeyDown:U,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:M.getTotalSize(),position:"relative"},children:M.getVirtualItems().map(R=>{const z=j[R.index];return n.jsx("div",{className:"vrow",style:{transform:`translateY(${R.start}px)`,height:R.size},children:z.type==="group"?n.jsx(xW,{row:z,onToggle:()=>O(z.group.key)}):n.jsx(vW,{row:z,selected:z.record.id===x,onSelect:()=>k(L=>L===z.record.id?null:z.record.id)})},R.key)})})]}),b!==null&&n.jsx(nW,{record:b,totals:s.totals,onClose:()=>k(null)},b.id)]})]})}function gW(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=>Xz(u,l.range))}for(const l of eD(i,t.query))s.add(l.id);const r=t.brush!==null||t.query.trim()!=="",o=[];for(const l of e.groups){const u=l.records.filter(m=>s.has(m.id)&&(t.showCalls||m.kind!=="tool"));if(r&&u.length===0)continue;const d=t.collapsed.has(l.key);if(o.push({type:"group",key:`g:${l.key}`,group:l,collapsed:d,matches:u.length}),d)continue;let h=null;for(const m of u){const p=m.step!==null&&m.step!==h?m.step:null;m.step!==null&&(h=m.step),o.push({type:"record",key:m.id,record:m,stepStart:p})}}return o}const xW=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=tW(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:eW(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})]})}),vW=v.memo(function({row:t,selected:s,onSelect:i}){var u;const r=t.record,o=r.kind==="assistant",l=vc(r);return n.jsxs("div",{className:`record-row kind-${r.kind} status-${r.status} ${s?"selected":""} ${t.stepStart!==null?"step-start":""}`,onClick:i,role:"row","aria-selected":s,children:[n.jsx("span",{className:"gutter muted",children:t.stepStart!==null?`第 ${t.stepStart} 步`:""}),n.jsx("span",{children:n.jsx("span",{className:`kind-badge kind-${r.kind}`,children:o?`#${r.request.index}`:Eh[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:[NE.error," · "]}),r.kind==="tool"?n.jsxs(n.Fragment,{children:[n.jsx("code",{className:"tool-name-inline",children:r.name})," ",n.jsx("span",{className:"muted",children:r.preview})]}):r.preview||n.jsx("span",{className:"muted",children:"(无内容)"})]}),n.jsx("span",{className:"num",children:o?Nn(wE(r)):""}),n.jsx("span",{className:"num",children:o&&r.request.usage!==void 0?Nn(r.request.usage.outputTokens):""}),n.jsx("span",{className:"num",children:o&&((u=r.request.usage)==null?void 0:u.reasoningTokens)!==void 0?Nn(r.request.usage.reasoningTokens):""}),n.jsx("span",{className:"num",children:r.status==="running"?"…":l!==void 0&&(o||r.kind==="tool"||r.kind==="compaction"||r.kind==="attempt")?Zs(l):""}),n.jsx("span",{className:"model-cell",children:o?r.request.model??"":""}),n.jsx("span",{className:"num",children:o&&Jd(r)>0?Jd(r):""})]})}),yW={id:"trajectory",title:"轨迹",requires:["sessions"],sessionViews:[{id:"trajectory",title:"轨迹",order:10,component:pW}]};c1();Vs()===void 0&&document.documentElement.classList.add("own-title-bar");fh&&document.documentElement.classList.add("in-dsh");Bn(L5);Bn(yW);Bn(CZ);Bn(AZ);Bn($Z);Bn(TZ);Bn(IZ);Bn(MZ);Bn(OZ);Bn(F7);Bn(U7);Bn(n4);Bn(s4);Bn(P8);Bn(L8);Bn(W8);Bn(a7);for(const e of z5)Bn(e);const SE=lA.createRoot(document.getElementById("root"));function yp(e){const t=new cO({url:j5(e),clientInfo:{name:"adg-web",version:"0.1.0"}});t.start(),SE.render(n.jsxs(M5,{children:[n.jsx(w5,{client:t}),n.jsx(T5,{client:t}),n.jsx(Nz,{}),n.jsx(P5,{})]}))}const iN=fh?null:b5();fh?yp(null):iN===null?SE.render(n.jsx(C5,{onSubmit:e=>{k5(e),yp(e)}})):yp(iN);
256
+ //# sourceMappingURL=index-mX8hPa2E.js.map