dsh-multigameassistant 2.0.3 → 2.0.5

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,242 @@
1
+ var P1=Object.defineProperty;var g0=e=>{throw TypeError(e)};var z1=(e,t,n)=>t in e?P1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ut=(e,t,n)=>z1(e,typeof t!="symbol"?t+"":t,n),Ef=(e,t,n)=>t.has(e)||g0("Cannot "+n);var ze=(e,t,n)=>(Ef(e,t,"read from private field"),n?n.call(e):t.get(e)),Lt=(e,t,n)=>t.has(e)?g0("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Zt=(e,t,n,i)=>(Ef(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),xt=(e,t,n)=>(Ef(e,t,"access private method"),n);var x0=(e,t,n,i)=>({set _(r){Zt(e,t,r,n)},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 c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&i(c)}).observe(document,{childList:!0,subtree:!0});function n(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=n(r);fetch(r.href,o)}})();function Gp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Cf={exports:{}},wl={},Af={exports:{}},pt={};/**
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 v0;function L1(){if(v0)return pt;v0=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.iterator;function p(q){return q===null||typeof q!="object"?null:(q=g&&q[g]||q["@@iterator"],typeof q=="function"?q:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,S={};function N(q,X,Y){this.props=q,this.context=X,this.refs=S,this.updater=Y||x}N.prototype.isReactComponent={},N.prototype.setState=function(q,X){if(typeof q!="object"&&typeof q!="function"&&q!=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,q,X,"setState")},N.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function k(){}k.prototype=N.prototype;function E(q,X,Y){this.props=q,this.context=X,this.refs=S,this.updater=Y||x}var j=E.prototype=new k;j.constructor=E,y(j,N.prototype),j.isPureReactComponent=!0;var A=Array.isArray,P=Object.prototype.hasOwnProperty,L={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function V(q,X,Y){var re,ee={},se=null,ne=null;if(X!=null)for(re in X.ref!==void 0&&(ne=X.ref),X.key!==void 0&&(se=""+X.key),X)P.call(X,re)&&!B.hasOwnProperty(re)&&(ee[re]=X[re]);var ie=arguments.length-2;if(ie===1)ee.children=Y;else if(1<ie){for(var pe=Array(ie),Ce=0;Ce<ie;Ce++)pe[Ce]=arguments[Ce+2];ee.children=pe}if(q&&q.defaultProps)for(re in ie=q.defaultProps,ie)ee[re]===void 0&&(ee[re]=ie[re]);return{$$typeof:e,type:q,key:se,ref:ne,props:ee,_owner:L.current}}function M(q,X){return{$$typeof:e,type:q.type,key:X,ref:q.ref,props:q.props,_owner:q._owner}}function z(q){return typeof q=="object"&&q!==null&&q.$$typeof===e}function D(q){var X={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(Y){return X[Y]})}var U=/\/+/g;function I(q,X){return typeof q=="object"&&q!==null&&q.key!=null?D(""+q.key):X.toString(36)}function T(q,X,Y,re,ee){var se=typeof q;(se==="undefined"||se==="boolean")&&(q=null);var ne=!1;if(q===null)ne=!0;else switch(se){case"string":case"number":ne=!0;break;case"object":switch(q.$$typeof){case e:case t:ne=!0}}if(ne)return ne=q,ee=ee(ne),q=re===""?"."+I(ne,0):re,A(ee)?(Y="",q!=null&&(Y=q.replace(U,"$&/")+"/"),T(ee,X,Y,"",function(Ce){return Ce})):ee!=null&&(z(ee)&&(ee=M(ee,Y+(!ee.key||ne&&ne.key===ee.key?"":(""+ee.key).replace(U,"$&/")+"/")+q)),X.push(ee)),1;if(ne=0,re=re===""?".":re+":",A(q))for(var ie=0;ie<q.length;ie++){se=q[ie];var pe=re+I(se,ie);ne+=T(se,X,Y,pe,ee)}else if(pe=p(q),typeof pe=="function")for(q=pe.call(q),ie=0;!(se=q.next()).done;)se=se.value,pe=re+I(se,ie++),ne+=T(se,X,Y,pe,ee);else if(se==="object")throw X=String(q),Error("Objects are not valid as a React child (found: "+(X==="[object Object]"?"object with keys {"+Object.keys(q).join(", ")+"}":X)+"). If you meant to render a collection of children, use an array instead.");return ne}function O(q,X,Y){if(q==null)return q;var re=[],ee=0;return T(q,re,"","",function(se){return X.call(Y,se,ee++)}),re}function $(q){if(q._status===-1){var X=q._result;X=X(),X.then(function(Y){(q._status===0||q._status===-1)&&(q._status=1,q._result=Y)},function(Y){(q._status===0||q._status===-1)&&(q._status=2,q._result=Y)}),q._status===-1&&(q._status=0,q._result=X)}if(q._status===1)return q._result.default;throw q._result}var F={current:null},H={transition:null},Z={ReactCurrentDispatcher:F,ReactCurrentBatchConfig:H,ReactCurrentOwner:L};function G(){throw Error("act(...) is not supported in production builds of React.")}return pt.Children={map:O,forEach:function(q,X,Y){O(q,function(){X.apply(this,arguments)},Y)},count:function(q){var X=0;return O(q,function(){X++}),X},toArray:function(q){return O(q,function(X){return X})||[]},only:function(q){if(!z(q))throw Error("React.Children.only expected to receive a single React element child.");return q}},pt.Component=N,pt.Fragment=n,pt.Profiler=r,pt.PureComponent=E,pt.StrictMode=i,pt.Suspense=d,pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Z,pt.act=G,pt.cloneElement=function(q,X,Y){if(q==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+q+".");var re=y({},q.props),ee=q.key,se=q.ref,ne=q._owner;if(X!=null){if(X.ref!==void 0&&(se=X.ref,ne=L.current),X.key!==void 0&&(ee=""+X.key),q.type&&q.type.defaultProps)var ie=q.type.defaultProps;for(pe in X)P.call(X,pe)&&!B.hasOwnProperty(pe)&&(re[pe]=X[pe]===void 0&&ie!==void 0?ie[pe]:X[pe])}var pe=arguments.length-2;if(pe===1)re.children=Y;else if(1<pe){ie=Array(pe);for(var Ce=0;Ce<pe;Ce++)ie[Ce]=arguments[Ce+2];re.children=ie}return{$$typeof:e,type:q.type,key:ee,ref:se,props:re,_owner:ne}},pt.createContext=function(q){return q={$$typeof:c,_currentValue:q,_currentValue2:q,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},q.Provider={$$typeof:o,_context:q},q.Consumer=q},pt.createElement=V,pt.createFactory=function(q){var X=V.bind(null,q);return X.type=q,X},pt.createRef=function(){return{current:null}},pt.forwardRef=function(q){return{$$typeof:u,render:q}},pt.isValidElement=z,pt.lazy=function(q){return{$$typeof:m,_payload:{_status:-1,_result:q},_init:$}},pt.memo=function(q,X){return{$$typeof:h,type:q,compare:X===void 0?null:X}},pt.startTransition=function(q){var X=H.transition;H.transition={};try{q()}finally{H.transition=X}},pt.unstable_act=G,pt.useCallback=function(q,X){return F.current.useCallback(q,X)},pt.useContext=function(q){return F.current.useContext(q)},pt.useDebugValue=function(){},pt.useDeferredValue=function(q){return F.current.useDeferredValue(q)},pt.useEffect=function(q,X){return F.current.useEffect(q,X)},pt.useId=function(){return F.current.useId()},pt.useImperativeHandle=function(q,X,Y){return F.current.useImperativeHandle(q,X,Y)},pt.useInsertionEffect=function(q,X){return F.current.useInsertionEffect(q,X)},pt.useLayoutEffect=function(q,X){return F.current.useLayoutEffect(q,X)},pt.useMemo=function(q,X){return F.current.useMemo(q,X)},pt.useReducer=function(q,X,Y){return F.current.useReducer(q,X,Y)},pt.useRef=function(q){return F.current.useRef(q)},pt.useState=function(q){return F.current.useState(q)},pt.useSyncExternalStore=function(q,X,Y){return F.current.useSyncExternalStore(q,X,Y)},pt.useTransition=function(){return F.current.useTransition()},pt.version="18.3.1",pt}var y0;function vc(){return y0||(y0=1,Af.exports=L1()),Af.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 b0;function D1(){if(b0)return wl;b0=1;var e=vc(),t=Symbol.for("react.element"),n=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 c(u,d,h){var m,g={},p=null,x=null;h!==void 0&&(p=""+h),d.key!==void 0&&(p=""+d.key),d.ref!==void 0&&(x=d.ref);for(m in d)i.call(d,m)&&!o.hasOwnProperty(m)&&(g[m]=d[m]);if(u&&u.defaultProps)for(m in d=u.defaultProps,d)g[m]===void 0&&(g[m]=d[m]);return{$$typeof:t,type:u,key:p,ref:x,props:g,_owner:r.current}}return wl.Fragment=n,wl.jsx=c,wl.jsxs=c,wl}var k0;function F1(){return k0||(k0=1,Cf.exports=D1()),Cf.exports}var s=F1(),_u={},If={exports:{}},ys={},Tf={exports:{}},$f={};/**
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 N0;function U1(){return N0||(N0=1,(function(e){function t(H,Z){var G=H.length;H.push(Z);e:for(;0<G;){var q=G-1>>>1,X=H[q];if(0<r(X,Z))H[q]=Z,H[G]=X,G=q;else break e}}function n(H){return H.length===0?null:H[0]}function i(H){if(H.length===0)return null;var Z=H[0],G=H.pop();if(G!==Z){H[0]=G;e:for(var q=0,X=H.length,Y=X>>>1;q<Y;){var re=2*(q+1)-1,ee=H[re],se=re+1,ne=H[se];if(0>r(ee,G))se<X&&0>r(ne,ee)?(H[q]=ne,H[se]=G,q=se):(H[q]=ee,H[re]=G,q=re);else if(se<X&&0>r(ne,G))H[q]=ne,H[se]=G,q=se;else break e}}return Z}function r(H,Z){var G=H.sortIndex-Z.sortIndex;return G!==0?G:H.id-Z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var d=[],h=[],m=1,g=null,p=3,x=!1,y=!1,S=!1,N=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function j(H){for(var Z=n(h);Z!==null;){if(Z.callback===null)i(h);else if(Z.startTime<=H)i(h),Z.sortIndex=Z.expirationTime,t(d,Z);else break;Z=n(h)}}function A(H){if(S=!1,j(H),!y)if(n(d)!==null)y=!0,$(P);else{var Z=n(h);Z!==null&&F(A,Z.startTime-H)}}function P(H,Z){y=!1,S&&(S=!1,k(V),V=-1),x=!0;var G=p;try{for(j(Z),g=n(d);g!==null&&(!(g.expirationTime>Z)||H&&!D());){var q=g.callback;if(typeof q=="function"){g.callback=null,p=g.priorityLevel;var X=q(g.expirationTime<=Z);Z=e.unstable_now(),typeof X=="function"?g.callback=X:g===n(d)&&i(d),j(Z)}else i(d);g=n(d)}if(g!==null)var Y=!0;else{var re=n(h);re!==null&&F(A,re.startTime-Z),Y=!1}return Y}finally{g=null,p=G,x=!1}}var L=!1,B=null,V=-1,M=5,z=-1;function D(){return!(e.unstable_now()-z<M)}function U(){if(B!==null){var H=e.unstable_now();z=H;var Z=!0;try{Z=B(!0,H)}finally{Z?I():(L=!1,B=null)}}else L=!1}var I;if(typeof E=="function")I=function(){E(U)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,O=T.port2;T.port1.onmessage=U,I=function(){O.postMessage(null)}}else I=function(){N(U,0)};function $(H){B=H,L||(L=!0,I())}function F(H,Z){V=N(function(){H(e.unstable_now())},Z)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(H){H.callback=null},e.unstable_continueExecution=function(){y||x||(y=!0,$(P))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(H){switch(p){case 1:case 2:case 3:var Z=3;break;default:Z=p}var G=p;p=Z;try{return H()}finally{p=G}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,Z){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var G=p;p=H;try{return Z()}finally{p=G}},e.unstable_scheduleCallback=function(H,Z,G){var q=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?q+G:q):G=q,H){case 1:var X=-1;break;case 2:X=250;break;case 5:X=1073741823;break;case 4:X=1e4;break;default:X=5e3}return X=G+X,H={id:m++,callback:Z,priorityLevel:H,startTime:G,expirationTime:X,sortIndex:-1},G>q?(H.sortIndex=G,t(h,H),n(d)===null&&H===n(h)&&(S?(k(V),V=-1):S=!0,F(A,G-q))):(H.sortIndex=X,t(d,H),y||x||(y=!0,$(P))),H},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(H){var Z=p;return function(){var G=p;p=Z;try{return H.apply(this,arguments)}finally{p=G}}}})($f)),$f}var j0;function B1(){return j0||(j0=1,Tf.exports=U1()),Tf.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 w0;function H1(){if(w0)return ys;w0=1;var e=vc(),t=B1();function n(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,f=1;f<arguments.length;f++)l+="&args[]="+encodeURIComponent(arguments[f]);return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,r={};function o(a,l){c(a,l),c(a+"Capture",l)}function c(a,l){for(r[a]=l,a=0;a<l.length;a++)i.add(l[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={},g={};function p(a){return d.call(g,a)?!0:d.call(m,a)?!1:h.test(a)?g[a]=!0:(m[a]=!0,!1)}function x(a,l,f,v){if(f!==null&&f.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return v?!1:f!==null?!f.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function y(a,l,f,v){if(l===null||typeof l>"u"||x(a,l,f,v))return!0;if(v)return!1;if(f!==null)switch(f.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function S(a,l,f,v,_,C,W){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=v,this.attributeNamespace=_,this.mustUseProperty=f,this.propertyName=a,this.type=l,this.sanitizeURL=C,this.removeEmptyString=W}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){N[a]=new S(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];N[l]=new S(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){N[a]=new S(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){N[a]=new S(a,2,!1,a,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){N[a]=new S(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){N[a]=new S(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){N[a]=new S(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){N[a]=new S(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){N[a]=new S(a,5,!1,a.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function E(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var l=a.replace(k,E);N[l]=new S(l,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var l=a.replace(k,E);N[l]=new S(l,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var l=a.replace(k,E);N[l]=new S(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){N[a]=new S(a,1,!1,a.toLowerCase(),null,!1,!1)}),N.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){N[a]=new S(a,1,!1,a.toLowerCase(),null,!0,!0)});function j(a,l,f,v){var _=N.hasOwnProperty(l)?N[l]:null;(_!==null?_.type!==0:v||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(y(l,f,_,v)&&(f=null),v||_===null?p(l)&&(f===null?a.removeAttribute(l):a.setAttribute(l,""+f)):_.mustUseProperty?a[_.propertyName]=f===null?_.type===3?!1:"":f:(l=_.attributeName,v=_.attributeNamespace,f===null?a.removeAttribute(l):(_=_.type,f=_===3||_===4&&f===!0?"":""+f,v?a.setAttributeNS(v,l,f):a.setAttribute(l,f))))}var A=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,P=Symbol.for("react.element"),L=Symbol.for("react.portal"),B=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),z=Symbol.for("react.provider"),D=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),F=Symbol.for("react.offscreen"),H=Symbol.iterator;function Z(a){return a===null||typeof a!="object"?null:(a=H&&a[H]||a["@@iterator"],typeof a=="function"?a:null)}var G=Object.assign,q;function X(a){if(q===void 0)try{throw Error()}catch(f){var l=f.stack.trim().match(/\n( *(at )?)/);q=l&&l[1]||""}return`
34
+ `+q+a}var Y=!1;function re(a,l){if(!a||Y)return"";Y=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ge){var v=ge}Reflect.construct(a,[],l)}else{try{l.call()}catch(ge){v=ge}a.call(l.prototype)}else{try{throw Error()}catch(ge){v=ge}a()}}catch(ge){if(ge&&v&&typeof ge.stack=="string"){for(var _=ge.stack.split(`
35
+ `),C=v.stack.split(`
36
+ `),W=_.length-1,Q=C.length-1;1<=W&&0<=Q&&_[W]!==C[Q];)Q--;for(;1<=W&&0<=Q;W--,Q--)if(_[W]!==C[Q]){if(W!==1||Q!==1)do if(W--,Q--,0>Q||_[W]!==C[Q]){var ae=`
37
+ `+_[W].replace(" at new "," at ");return a.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",a.displayName)),ae}while(1<=W&&0<=Q);break}}}finally{Y=!1,Error.prepareStackTrace=f}return(a=a?a.displayName||a.name:"")?X(a):""}function ee(a){switch(a.tag){case 5:return X(a.type);case 16:return X("Lazy");case 13:return X("Suspense");case 19:return X("SuspenseList");case 0:case 2:case 15:return a=re(a.type,!1),a;case 11:return a=re(a.type.render,!1),a;case 1:return a=re(a.type,!0),a;default:return""}}function se(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 L:return"Portal";case M:return"Profiler";case V:return"StrictMode";case I:return"Suspense";case T:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case D:return(a.displayName||"Context")+".Consumer";case z:return(a._context.displayName||"Context")+".Provider";case U:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case O:return l=a.displayName||null,l!==null?l:se(a.type)||"Memo";case $:l=a._payload,a=a._init;try{return se(a(l))}catch{}}return null}function ne(a){var l=a.type;switch(a.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=l.render,a=a.displayName||a.name||"",l.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return se(l);case 8:return l===V?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function ie(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function pe(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function Ce(a){var l=pe(a)?"checked":"value",f=Object.getOwnPropertyDescriptor(a.constructor.prototype,l),v=""+a[l];if(!a.hasOwnProperty(l)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var _=f.get,C=f.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return _.call(this)},set:function(W){v=""+W,C.call(this,W)}}),Object.defineProperty(a,l,{enumerable:f.enumerable}),{getValue:function(){return v},setValue:function(W){v=""+W},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function fe(a){a._valueTracker||(a._valueTracker=Ce(a))}function ve(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var f=l.getValue(),v="";return a&&(v=pe(a)?a.checked?"true":"false":a.value),a=v,a!==f?(l.setValue(a),!0):!1}function ue(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 xe(a,l){var f=l.checked;return G({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f??a._wrapperState.initialChecked})}function De(a,l){var f=l.defaultValue==null?"":l.defaultValue,v=l.checked!=null?l.checked:l.defaultChecked;f=ie(l.value!=null?l.value:f),a._wrapperState={initialChecked:v,initialValue:f,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Me(a,l){l=l.checked,l!=null&&j(a,"checked",l,!1)}function Ge(a,l){Me(a,l);var f=ie(l.value),v=l.type;if(f!=null)v==="number"?(f===0&&a.value===""||a.value!=f)&&(a.value=""+f):a.value!==""+f&&(a.value=""+f);else if(v==="submit"||v==="reset"){a.removeAttribute("value");return}l.hasOwnProperty("value")?tt(a,l.type,f):l.hasOwnProperty("defaultValue")&&tt(a,l.type,ie(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(a.defaultChecked=!!l.defaultChecked)}function Te(a,l,f){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var v=l.type;if(!(v!=="submit"&&v!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+a._wrapperState.initialValue,f||l===a.value||(a.value=l),a.defaultValue=l}f=a.name,f!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,f!==""&&(a.name=f)}function tt(a,l,f){(l!=="number"||ue(a.ownerDocument)!==a)&&(f==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+f&&(a.defaultValue=""+f))}var et=Array.isArray;function St(a,l,f,v){if(a=a.options,l){l={};for(var _=0;_<f.length;_++)l["$"+f[_]]=!0;for(f=0;f<a.length;f++)_=l.hasOwnProperty("$"+a[f].value),a[f].selected!==_&&(a[f].selected=_),_&&v&&(a[f].defaultSelected=!0)}else{for(f=""+ie(f),l=null,_=0;_<a.length;_++){if(a[_].value===f){a[_].selected=!0,v&&(a[_].defaultSelected=!0);return}l!==null||a[_].disabled||(l=a[_])}l!==null&&(l.selected=!0)}}function zn(a,l){if(l.dangerouslySetInnerHTML!=null)throw Error(n(91));return G({},l,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function rn(a,l){var f=l.value;if(f==null){if(f=l.children,l=l.defaultValue,f!=null){if(l!=null)throw Error(n(92));if(et(f)){if(1<f.length)throw Error(n(93));f=f[0]}l=f}l==null&&(l=""),f=l}a._wrapperState={initialValue:ie(f)}}function cn(a,l){var f=ie(l.value),v=ie(l.defaultValue);f!=null&&(f=""+f,f!==a.value&&(a.value=f),l.defaultValue==null&&a.defaultValue!==f&&(a.defaultValue=f)),v!=null&&(a.defaultValue=""+v)}function un(a){var l=a.textContent;l===a._wrapperState.initialValue&&l!==""&&l!==null&&(a.value=l)}function an(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 on(a,l){return a==null||a==="http://www.w3.org/1999/xhtml"?an(l):a==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var Ft,Bn=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,f,v,_){MSApp.execUnsafeLocalFunction(function(){return a(l,f,v,_)})}:a})(function(a,l){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=l;else{for(Ft=Ft||document.createElement("div"),Ft.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=Ft.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}});function jn(a,l){if(l){var f=a.firstChild;if(f&&f===a.lastChild&&f.nodeType===3){f.nodeValue=l;return}}a.textContent=l}var Ss={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},Ii=["Webkit","ms","Moz","O"];Object.keys(Ss).forEach(function(a){Ii.forEach(function(l){l=l+a.charAt(0).toUpperCase()+a.substring(1),Ss[l]=Ss[a]})});function ni(a,l,f){return l==null||typeof l=="boolean"||l===""?"":f||typeof l!="number"||l===0||Ss.hasOwnProperty(a)&&Ss[a]?(""+l).trim():l+"px"}function si(a,l){a=a.style;for(var f in l)if(l.hasOwnProperty(f)){var v=f.indexOf("--")===0,_=ni(f,l[f],v);f==="float"&&(f="cssFloat"),v?a.setProperty(f,_):a[f]=_}}var zs=G({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 Ls(a,l){if(l){if(zs[a]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(n(137,a));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(n(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(n(61))}if(l.style!=null&&typeof l.style!="object")throw Error(n(62))}}function Ds(a,l){if(a.indexOf("-")===-1)return typeof l.is=="string";switch(a){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Fs=null;function ii(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var ri=null,os=null,Xn=null;function wn(a){if(a=cl(a)){if(typeof ri!="function")throw Error(n(280));var l=a.stateNode;l&&(l=Uc(l),ri(a.stateNode,a.type,l))}}function te(a){os?Xn?Xn.push(a):Xn=[a]:os=a}function ye(){if(os){var a=os,l=Xn;if(Xn=os=null,wn(a),l)for(a=0;a<l.length;a++)wn(l[a])}}function Le(a,l){return a(l)}function st(){}var It=!1;function $t(a,l,f){if(It)return a(l,f);It=!0;try{return Le(a,l,f)}finally{It=!1,(os!==null||Xn!==null)&&(st(),ye())}}function Ue(a,l){var f=a.stateNode;if(f===null)return null;var v=Uc(f);if(v===null)return null;f=v[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(v=!v.disabled)||(a=a.type,v=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!v;break e;default:a=!1}if(a)return null;if(f&&typeof f!="function")throw Error(n(231,l,typeof f));return f}var Fe=!1;if(u)try{var Xe={};Object.defineProperty(Xe,"passive",{get:function(){Fe=!0}}),window.addEventListener("test",Xe,Xe),window.removeEventListener("test",Xe,Xe)}catch{Fe=!1}function bt(a,l,f,v,_,C,W,Q,ae){var ge=Array.prototype.slice.call(arguments,3);try{l.apply(f,ge)}catch(Ee){this.onError(Ee)}}var yt=!1,Hn=null,ls=!1,ai=null,gr={onError:function(a){yt=!0,Hn=a}};function oi(a,l,f,v,_,C,W,Q,ae){yt=!1,Hn=null,bt.apply(gr,arguments)}function xr(a,l,f,v,_,C,W,Q,ae){if(oi.apply(this,arguments),yt){if(yt){var ge=Hn;yt=!1,Hn=null}else throw Error(n(198));ls||(ls=!0,ai=ge)}}function Zn(a){var l=a,f=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(f=l.return),a=l.return;while(a)}return l.tag===3?f:null}function Vi(a){if(a.tag===13){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function cs(a){if(Zn(a)!==a)throw Error(n(188))}function Ti(a){var l=a.alternate;if(!l){if(l=Zn(a),l===null)throw Error(n(188));return l!==a?null:a}for(var f=a,v=l;;){var _=f.return;if(_===null)break;var C=_.alternate;if(C===null){if(v=_.return,v!==null){f=v;continue}break}if(_.child===C.child){for(C=_.child;C;){if(C===f)return cs(_),a;if(C===v)return cs(_),l;C=C.sibling}throw Error(n(188))}if(f.return!==v.return)f=_,v=C;else{for(var W=!1,Q=_.child;Q;){if(Q===f){W=!0,f=_,v=C;break}if(Q===v){W=!0,v=_,f=C;break}Q=Q.sibling}if(!W){for(Q=C.child;Q;){if(Q===f){W=!0,f=C,v=_;break}if(Q===v){W=!0,v=C,f=_;break}Q=Q.sibling}if(!W)throw Error(n(189))}}if(f.alternate!==v)throw Error(n(190))}if(f.tag!==3)throw Error(n(188));return f.stateNode.current===f?a:l}function vr(a){return a=Ti(a),a!==null?Rt(a):null}function Rt(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var l=Rt(a);if(l!==null)return l;a=a.sibling}return null}var _s=t.unstable_scheduleCallback,Qn=t.unstable_cancelCallback,qi=t.unstable_shouldYield,li=t.unstable_requestPaint,Ot=t.unstable_now,yr=t.unstable_getCurrentPriorityLevel,Gi=t.unstable_ImmediatePriority,ci=t.unstable_UserBlockingPriority,$i=t.unstable_NormalPriority,$e=t.unstable_LowPriority,Ze=t.unstable_IdlePriority,ct=null,ht=null;function Tt(a){if(ht&&typeof ht.onCommitFiberRoot=="function")try{ht.onCommitFiberRoot(ct,a,void 0,(a.current.flags&128)===128)}catch{}}var Pt=Math.clz32?Math.clz32:dn,Wn=Math.log,Us=Math.LN2;function dn(a){return a>>>=0,a===0?32:31-(Wn(a)/Us|0)|0}var Sn=64,Bs=4194304;function Hs(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 us(a,l){var f=a.pendingLanes;if(f===0)return 0;var v=0,_=a.suspendedLanes,C=a.pingedLanes,W=f&268435455;if(W!==0){var Q=W&~_;Q!==0?v=Hs(Q):(C&=W,C!==0&&(v=Hs(C)))}else W=f&~_,W!==0?v=Hs(W):C!==0&&(v=Hs(C));if(v===0)return 0;if(l!==0&&l!==v&&(l&_)===0&&(_=v&-v,C=l&-l,_>=C||_===16&&(C&4194240)!==0))return l;if((v&4)!==0&&(v|=f&16),l=a.entangledLanes,l!==0)for(a=a.entanglements,l&=v;0<l;)f=31-Pt(l),_=1<<f,v|=a[f],l&=~_;return v}function sa(a,l){switch(a){case 1:case 2:case 4:return l+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function br(a,l){for(var f=a.suspendedLanes,v=a.pingedLanes,_=a.expirationTimes,C=a.pendingLanes;0<C;){var W=31-Pt(C),Q=1<<W,ae=_[W];ae===-1?((Q&f)===0||(Q&v)!==0)&&(_[W]=sa(Q,l)):ae<=l&&(a.expiredLanes|=Q),C&=~Q}}function Mi(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function kr(){var a=Sn;return Sn<<=1,(Sn&4194240)===0&&(Sn=64),a}function Jn(a){for(var l=[],f=0;31>f;f++)l.push(a);return l}function ds(a,l,f){a.pendingLanes|=l,l!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,l=31-Pt(l),a[l]=f}function _n(a,l){var f=a.pendingLanes&~l;a.pendingLanes=l,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=l,a.mutableReadLanes&=l,a.entangledLanes&=l,l=a.entanglements;var v=a.eventTimes;for(a=a.expirationTimes;0<f;){var _=31-Pt(f),C=1<<_;l[_]=0,v[_]=-1,a[_]=-1,f&=~C}}function Zs(a,l){var f=a.entangledLanes|=l;for(a=a.entanglements;f;){var v=31-Pt(f),_=1<<v;_&l|a[v]&l&&(a[v]|=l),f&=~_}}var vt=0;function at(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var hs,zt,ft,Ki,es,Yi=!1,ui=[],Re=null,Be=null,ot=null,gt=new Map,Ut=new Map,pn=[],Xo="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 ia(a,l){switch(a){case"focusin":case"focusout":Re=null;break;case"dragenter":case"dragleave":Be=null;break;case"mouseover":case"mouseout":ot=null;break;case"pointerover":case"pointerout":gt.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ut.delete(l.pointerId)}}function Xi(a,l,f,v,_,C){return a===null||a.nativeEvent!==C?(a={blockedOn:l,domEventName:f,eventSystemFlags:v,nativeEvent:C,targetContainers:[_]},l!==null&&(l=cl(l),l!==null&&zt(l)),a):(a.eventSystemFlags|=v,l=a.targetContainers,_!==null&&l.indexOf(_)===-1&&l.push(_),a)}function ra(a,l,f,v,_){switch(l){case"focusin":return Re=Xi(Re,a,l,f,v,_),!0;case"dragenter":return Be=Xi(Be,a,l,f,v,_),!0;case"mouseover":return ot=Xi(ot,a,l,f,v,_),!0;case"pointerover":var C=_.pointerId;return gt.set(C,Xi(gt.get(C)||null,a,l,f,v,_)),!0;case"gotpointercapture":return C=_.pointerId,Ut.set(C,Xi(Ut.get(C)||null,a,l,f,v,_)),!0}return!1}function Za(a){var l=aa(a.target);if(l!==null){var f=Zn(l);if(f!==null){if(l=f.tag,l===13){if(l=Vi(f),l!==null){a.blockedOn=l,es(a.priority,function(){ft(f)});return}}else if(l===3&&f.stateNode.current.memoizedState.isDehydrated){a.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Se(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var f=In(a.domEventName,a.eventSystemFlags,l[0],a.nativeEvent);if(f===null){f=a.nativeEvent;var v=new f.constructor(f.type,f);Fs=v,f.target.dispatchEvent(v),Fs=null}else return l=cl(f),l!==null&&zt(l),a.blockedOn=f,!1;l.shift()}return!0}function K(a,l,f){Se(a)&&f.delete(l)}function le(){Yi=!1,Re!==null&&Se(Re)&&(Re=null),Be!==null&&Se(Be)&&(Be=null),ot!==null&&Se(ot)&&(ot=null),gt.forEach(K),Ut.forEach(K)}function Ne(a,l){a.blockedOn===l&&(a.blockedOn=null,Yi||(Yi=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,le)))}function je(a){function l(_){return Ne(_,a)}if(0<ui.length){Ne(ui[0],a);for(var f=1;f<ui.length;f++){var v=ui[f];v.blockedOn===a&&(v.blockedOn=null)}}for(Re!==null&&Ne(Re,a),Be!==null&&Ne(Be,a),ot!==null&&Ne(ot,a),gt.forEach(l),Ut.forEach(l),f=0;f<pn.length;f++)v=pn[f],v.blockedOn===a&&(v.blockedOn=null);for(;0<pn.length&&(f=pn[0],f.blockedOn===null);)Za(f),f.blockedOn===null&&pn.shift()}var qe=A.ReactCurrentBatchConfig,nt=!0;function mt(a,l,f,v){var _=vt,C=qe.transition;qe.transition=null;try{vt=1,fs(a,l,f,v)}finally{vt=_,qe.transition=C}}function hn(a,l,f,v){var _=vt,C=qe.transition;qe.transition=null;try{vt=4,fs(a,l,f,v)}finally{vt=_,qe.transition=C}}function fs(a,l,f,v){if(nt){var _=In(a,l,f,v);if(_===null)gh(a,l,v,gn,f),ia(a,v);else if(ra(_,a,l,f,v))v.stopPropagation();else if(ia(a,v),l&4&&-1<Xo.indexOf(a)){for(;_!==null;){var C=cl(_);if(C!==null&&hs(C),C=In(a,l,f,v),C===null&&gh(a,l,v,gn,f),C===_)break;_=C}_!==null&&v.stopPropagation()}else gh(a,l,v,null,f)}}var gn=null;function In(a,l,f,v){if(gn=null,a=ii(v),a=aa(a),a!==null)if(l=Zn(a),l===null)a=null;else if(f=l.tag,f===13){if(a=Vi(l),a!==null)return a;a=null}else if(f===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null);return gn=a,null}function Qi(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(yr()){case Gi:return 1;case ci:return 4;case $i:case $e:return 16;case Ze:return 536870912;default:return 16}default:return 16}}var Jt=null,Wa=null,Ic=null;function sx(){if(Ic)return Ic;var a,l=Wa,f=l.length,v,_="value"in Jt?Jt.value:Jt.textContent,C=_.length;for(a=0;a<f&&l[a]===_[a];a++);var W=f-a;for(v=1;v<=W&&l[f-v]===_[C-v];v++);return Ic=_.slice(a,1<v?1-v:void 0)}function Tc(a){var l=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&l===13&&(a=13)):a=l,a===10&&(a=13),32<=a||a===13?a:0}function $c(){return!0}function ix(){return!1}function Es(a){function l(f,v,_,C,W){this._reactName=f,this._targetInst=_,this.type=v,this.nativeEvent=C,this.target=W,this.currentTarget=null;for(var Q in a)a.hasOwnProperty(Q)&&(f=a[Q],this[Q]=f?f(C):C[Q]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?$c:ix,this.isPropagationStopped=ix,this}return G(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=$c)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=$c)},persist:function(){},isPersistent:$c}),l}var Va={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},th=Es(Va),Qo=G({},Va,{view:0,detail:0}),cE=Es(Qo),nh,sh,Jo,Mc=G({},Qo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:rh,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!==Jo&&(Jo&&a.type==="mousemove"?(nh=a.screenX-Jo.screenX,sh=a.screenY-Jo.screenY):sh=nh=0,Jo=a),nh)},movementY:function(a){return"movementY"in a?a.movementY:sh}}),rx=Es(Mc),uE=G({},Mc,{dataTransfer:0}),dE=Es(uE),hE=G({},Qo,{relatedTarget:0}),ih=Es(hE),fE=G({},Va,{animationName:0,elapsedTime:0,pseudoElement:0}),mE=Es(fE),pE=G({},Va,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),gE=Es(pE),xE=G({},Va,{data:0}),ax=Es(xE),vE={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yE={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},bE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kE(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=bE[a])?!!l[a]:!1}function rh(){return kE}var NE=G({},Qo,{key:function(a){if(a.key){var l=vE[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=Tc(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?yE[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:rh,charCode:function(a){return a.type==="keypress"?Tc(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Tc(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),jE=Es(NE),wE=G({},Mc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ox=Es(wE),SE=G({},Qo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:rh}),_E=Es(SE),EE=G({},Va,{propertyName:0,elapsedTime:0,pseudoElement:0}),CE=Es(EE),AE=G({},Mc,{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}),IE=Es(AE),TE=[9,13,27,32],ah=u&&"CompositionEvent"in window,el=null;u&&"documentMode"in document&&(el=document.documentMode);var $E=u&&"TextEvent"in window&&!el,lx=u&&(!ah||el&&8<el&&11>=el),cx=" ",ux=!1;function dx(a,l){switch(a){case"keyup":return TE.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function hx(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var qa=!1;function ME(a,l){switch(a){case"compositionend":return hx(l);case"keypress":return l.which!==32?null:(ux=!0,cx);case"textInput":return a=l.data,a===cx&&ux?null:a;default:return null}}function RE(a,l){if(qa)return a==="compositionend"||!ah&&dx(a,l)?(a=sx(),Ic=Wa=Jt=null,qa=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return lx&&l.locale!=="ko"?null:l.data;default:return null}}var OE={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function fx(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!OE[a.type]:l==="textarea"}function mx(a,l,f,v){te(v),l=Lc(l,"onChange"),0<l.length&&(f=new th("onChange","change",null,f,v),a.push({event:f,listeners:l}))}var tl=null,nl=null;function PE(a){$x(a,0)}function Rc(a){var l=Qa(a);if(ve(l))return a}function zE(a,l){if(a==="change")return l}var px=!1;if(u){var oh;if(u){var lh="oninput"in document;if(!lh){var gx=document.createElement("div");gx.setAttribute("oninput","return;"),lh=typeof gx.oninput=="function"}oh=lh}else oh=!1;px=oh&&(!document.documentMode||9<document.documentMode)}function xx(){tl&&(tl.detachEvent("onpropertychange",vx),nl=tl=null)}function vx(a){if(a.propertyName==="value"&&Rc(nl)){var l=[];mx(l,nl,a,ii(a)),$t(PE,l)}}function LE(a,l,f){a==="focusin"?(xx(),tl=l,nl=f,tl.attachEvent("onpropertychange",vx)):a==="focusout"&&xx()}function DE(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Rc(nl)}function FE(a,l){if(a==="click")return Rc(l)}function UE(a,l){if(a==="input"||a==="change")return Rc(l)}function BE(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var di=typeof Object.is=="function"?Object.is:BE;function sl(a,l){if(di(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var f=Object.keys(a),v=Object.keys(l);if(f.length!==v.length)return!1;for(v=0;v<f.length;v++){var _=f[v];if(!d.call(l,_)||!di(a[_],l[_]))return!1}return!0}function yx(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function bx(a,l){var f=yx(a);a=0;for(var v;f;){if(f.nodeType===3){if(v=a+f.textContent.length,a<=l&&v>=l)return{node:f,offset:l-a};a=v}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=yx(f)}}function kx(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?kx(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function Nx(){for(var a=window,l=ue();l instanceof a.HTMLIFrameElement;){try{var f=typeof l.contentWindow.location.href=="string"}catch{f=!1}if(f)a=l.contentWindow;else break;l=ue(a.document)}return l}function ch(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l&&(l==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||l==="textarea"||a.contentEditable==="true")}function HE(a){var l=Nx(),f=a.focusedElem,v=a.selectionRange;if(l!==f&&f&&f.ownerDocument&&kx(f.ownerDocument.documentElement,f)){if(v!==null&&ch(f)){if(l=v.start,a=v.end,a===void 0&&(a=l),"selectionStart"in f)f.selectionStart=l,f.selectionEnd=Math.min(a,f.value.length);else if(a=(l=f.ownerDocument||document)&&l.defaultView||window,a.getSelection){a=a.getSelection();var _=f.textContent.length,C=Math.min(v.start,_);v=v.end===void 0?C:Math.min(v.end,_),!a.extend&&C>v&&(_=v,v=C,C=_),_=bx(f,C);var W=bx(f,v);_&&W&&(a.rangeCount!==1||a.anchorNode!==_.node||a.anchorOffset!==_.offset||a.focusNode!==W.node||a.focusOffset!==W.offset)&&(l=l.createRange(),l.setStart(_.node,_.offset),a.removeAllRanges(),C>v?(a.addRange(l),a.extend(W.node,W.offset)):(l.setEnd(W.node,W.offset),a.addRange(l)))}}for(l=[],a=f;a=a.parentNode;)a.nodeType===1&&l.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof f.focus=="function"&&f.focus(),f=0;f<l.length;f++)a=l[f],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var ZE=u&&"documentMode"in document&&11>=document.documentMode,Ga=null,uh=null,il=null,dh=!1;function jx(a,l,f){var v=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;dh||Ga==null||Ga!==ue(v)||(v=Ga,"selectionStart"in v&&ch(v)?v={start:v.selectionStart,end:v.selectionEnd}:(v=(v.ownerDocument&&v.ownerDocument.defaultView||window).getSelection(),v={anchorNode:v.anchorNode,anchorOffset:v.anchorOffset,focusNode:v.focusNode,focusOffset:v.focusOffset}),il&&sl(il,v)||(il=v,v=Lc(uh,"onSelect"),0<v.length&&(l=new th("onSelect","select",null,l,f),a.push({event:l,listeners:v}),l.target=Ga)))}function Oc(a,l){var f={};return f[a.toLowerCase()]=l.toLowerCase(),f["Webkit"+a]="webkit"+l,f["Moz"+a]="moz"+l,f}var Ka={animationend:Oc("Animation","AnimationEnd"),animationiteration:Oc("Animation","AnimationIteration"),animationstart:Oc("Animation","AnimationStart"),transitionend:Oc("Transition","TransitionEnd")},hh={},wx={};u&&(wx=document.createElement("div").style,"AnimationEvent"in window||(delete Ka.animationend.animation,delete Ka.animationiteration.animation,delete Ka.animationstart.animation),"TransitionEvent"in window||delete Ka.transitionend.transition);function Pc(a){if(hh[a])return hh[a];if(!Ka[a])return a;var l=Ka[a],f;for(f in l)if(l.hasOwnProperty(f)&&f in wx)return hh[a]=l[f];return a}var Sx=Pc("animationend"),_x=Pc("animationiteration"),Ex=Pc("animationstart"),Cx=Pc("transitionend"),Ax=new Map,Ix="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 Nr(a,l){Ax.set(a,l),o(l,[a])}for(var fh=0;fh<Ix.length;fh++){var mh=Ix[fh],WE=mh.toLowerCase(),VE=mh[0].toUpperCase()+mh.slice(1);Nr(WE,"on"+VE)}Nr(Sx,"onAnimationEnd"),Nr(_x,"onAnimationIteration"),Nr(Ex,"onAnimationStart"),Nr("dblclick","onDoubleClick"),Nr("focusin","onFocus"),Nr("focusout","onBlur"),Nr(Cx,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var rl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),qE=new Set("cancel close invalid load scroll toggle".split(" ").concat(rl));function Tx(a,l,f){var v=a.type||"unknown-event";a.currentTarget=f,xr(v,l,void 0,a),a.currentTarget=null}function $x(a,l){l=(l&4)!==0;for(var f=0;f<a.length;f++){var v=a[f],_=v.event;v=v.listeners;e:{var C=void 0;if(l)for(var W=v.length-1;0<=W;W--){var Q=v[W],ae=Q.instance,ge=Q.currentTarget;if(Q=Q.listener,ae!==C&&_.isPropagationStopped())break e;Tx(_,Q,ge),C=ae}else for(W=0;W<v.length;W++){if(Q=v[W],ae=Q.instance,ge=Q.currentTarget,Q=Q.listener,ae!==C&&_.isPropagationStopped())break e;Tx(_,Q,ge),C=ae}}}if(ls)throw a=ai,ls=!1,ai=null,a}function Bt(a,l){var f=l[Nh];f===void 0&&(f=l[Nh]=new Set);var v=a+"__bubble";f.has(v)||(Mx(l,a,2,!1),f.add(v))}function ph(a,l,f){var v=0;l&&(v|=4),Mx(f,a,v,l)}var zc="_reactListening"+Math.random().toString(36).slice(2);function al(a){if(!a[zc]){a[zc]=!0,i.forEach(function(f){f!=="selectionchange"&&(qE.has(f)||ph(f,!1,a),ph(f,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[zc]||(l[zc]=!0,ph("selectionchange",!1,l))}}function Mx(a,l,f,v){switch(Qi(l)){case 1:var _=mt;break;case 4:_=hn;break;default:_=fs}f=_.bind(null,l,f,a),_=void 0,!Fe||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(_=!0),v?_!==void 0?a.addEventListener(l,f,{capture:!0,passive:_}):a.addEventListener(l,f,!0):_!==void 0?a.addEventListener(l,f,{passive:_}):a.addEventListener(l,f,!1)}function gh(a,l,f,v,_){var C=v;if((l&1)===0&&(l&2)===0&&v!==null)e:for(;;){if(v===null)return;var W=v.tag;if(W===3||W===4){var Q=v.stateNode.containerInfo;if(Q===_||Q.nodeType===8&&Q.parentNode===_)break;if(W===4)for(W=v.return;W!==null;){var ae=W.tag;if((ae===3||ae===4)&&(ae=W.stateNode.containerInfo,ae===_||ae.nodeType===8&&ae.parentNode===_))return;W=W.return}for(;Q!==null;){if(W=aa(Q),W===null)return;if(ae=W.tag,ae===5||ae===6){v=C=W;continue e}Q=Q.parentNode}}v=v.return}$t(function(){var ge=C,Ee=ii(f),Ae=[];e:{var _e=Ax.get(a);if(_e!==void 0){var He=th,Ve=a;switch(a){case"keypress":if(Tc(f)===0)break e;case"keydown":case"keyup":He=jE;break;case"focusin":Ve="focus",He=ih;break;case"focusout":Ve="blur",He=ih;break;case"beforeblur":case"afterblur":He=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":He=rx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=dE;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=_E;break;case Sx:case _x:case Ex:He=mE;break;case Cx:He=CE;break;case"scroll":He=cE;break;case"wheel":He=IE;break;case"copy":case"cut":case"paste":He=gE;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=ox}var Ke=(l&4)!==0,fn=!Ke&&a==="scroll",he=Ke?_e!==null?_e+"Capture":null:_e;Ke=[];for(var ce=ge,me;ce!==null;){me=ce;var Oe=me.stateNode;if(me.tag===5&&Oe!==null&&(me=Oe,he!==null&&(Oe=Ue(ce,he),Oe!=null&&Ke.push(ol(ce,Oe,me)))),fn)break;ce=ce.return}0<Ke.length&&(_e=new He(_e,Ve,null,f,Ee),Ae.push({event:_e,listeners:Ke}))}}if((l&7)===0){e:{if(_e=a==="mouseover"||a==="pointerover",He=a==="mouseout"||a==="pointerout",_e&&f!==Fs&&(Ve=f.relatedTarget||f.fromElement)&&(aa(Ve)||Ve[Ji]))break e;if((He||_e)&&(_e=Ee.window===Ee?Ee:(_e=Ee.ownerDocument)?_e.defaultView||_e.parentWindow:window,He?(Ve=f.relatedTarget||f.toElement,He=ge,Ve=Ve?aa(Ve):null,Ve!==null&&(fn=Zn(Ve),Ve!==fn||Ve.tag!==5&&Ve.tag!==6)&&(Ve=null)):(He=null,Ve=ge),He!==Ve)){if(Ke=rx,Oe="onMouseLeave",he="onMouseEnter",ce="mouse",(a==="pointerout"||a==="pointerover")&&(Ke=ox,Oe="onPointerLeave",he="onPointerEnter",ce="pointer"),fn=He==null?_e:Qa(He),me=Ve==null?_e:Qa(Ve),_e=new Ke(Oe,ce+"leave",He,f,Ee),_e.target=fn,_e.relatedTarget=me,Oe=null,aa(Ee)===ge&&(Ke=new Ke(he,ce+"enter",Ve,f,Ee),Ke.target=me,Ke.relatedTarget=fn,Oe=Ke),fn=Oe,He&&Ve)t:{for(Ke=He,he=Ve,ce=0,me=Ke;me;me=Ya(me))ce++;for(me=0,Oe=he;Oe;Oe=Ya(Oe))me++;for(;0<ce-me;)Ke=Ya(Ke),ce--;for(;0<me-ce;)he=Ya(he),me--;for(;ce--;){if(Ke===he||he!==null&&Ke===he.alternate)break t;Ke=Ya(Ke),he=Ya(he)}Ke=null}else Ke=null;He!==null&&Rx(Ae,_e,He,Ke,!1),Ve!==null&&fn!==null&&Rx(Ae,fn,Ve,Ke,!0)}}e:{if(_e=ge?Qa(ge):window,He=_e.nodeName&&_e.nodeName.toLowerCase(),He==="select"||He==="input"&&_e.type==="file")var Ye=zE;else if(fx(_e))if(px)Ye=UE;else{Ye=DE;var it=LE}else(He=_e.nodeName)&&He.toLowerCase()==="input"&&(_e.type==="checkbox"||_e.type==="radio")&&(Ye=FE);if(Ye&&(Ye=Ye(a,ge))){mx(Ae,Ye,f,Ee);break e}it&&it(a,_e,ge),a==="focusout"&&(it=_e._wrapperState)&&it.controlled&&_e.type==="number"&&tt(_e,"number",_e.value)}switch(it=ge?Qa(ge):window,a){case"focusin":(fx(it)||it.contentEditable==="true")&&(Ga=it,uh=ge,il=null);break;case"focusout":il=uh=Ga=null;break;case"mousedown":dh=!0;break;case"contextmenu":case"mouseup":case"dragend":dh=!1,jx(Ae,f,Ee);break;case"selectionchange":if(ZE)break;case"keydown":case"keyup":jx(Ae,f,Ee)}var rt;if(ah)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 qa?dx(a,f)&&(lt="onCompositionEnd"):a==="keydown"&&f.keyCode===229&&(lt="onCompositionStart");lt&&(lx&&f.locale!=="ko"&&(qa||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&qa&&(rt=sx()):(Jt=Ee,Wa="value"in Jt?Jt.value:Jt.textContent,qa=!0)),it=Lc(ge,lt),0<it.length&&(lt=new ax(lt,a,null,f,Ee),Ae.push({event:lt,listeners:it}),rt?lt.data=rt:(rt=hx(f),rt!==null&&(lt.data=rt)))),(rt=$E?ME(a,f):RE(a,f))&&(ge=Lc(ge,"onBeforeInput"),0<ge.length&&(Ee=new ax("onBeforeInput","beforeinput",null,f,Ee),Ae.push({event:Ee,listeners:ge}),Ee.data=rt))}$x(Ae,l)})}function ol(a,l,f){return{instance:a,listener:l,currentTarget:f}}function Lc(a,l){for(var f=l+"Capture",v=[];a!==null;){var _=a,C=_.stateNode;_.tag===5&&C!==null&&(_=C,C=Ue(a,f),C!=null&&v.unshift(ol(a,C,_)),C=Ue(a,l),C!=null&&v.push(ol(a,C,_))),a=a.return}return v}function Ya(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function Rx(a,l,f,v,_){for(var C=l._reactName,W=[];f!==null&&f!==v;){var Q=f,ae=Q.alternate,ge=Q.stateNode;if(ae!==null&&ae===v)break;Q.tag===5&&ge!==null&&(Q=ge,_?(ae=Ue(f,C),ae!=null&&W.unshift(ol(f,ae,Q))):_||(ae=Ue(f,C),ae!=null&&W.push(ol(f,ae,Q)))),f=f.return}W.length!==0&&a.push({event:l,listeners:W})}var GE=/\r\n?/g,KE=/\u0000|\uFFFD/g;function Ox(a){return(typeof a=="string"?a:""+a).replace(GE,`
38
+ `).replace(KE,"")}function Dc(a,l,f){if(l=Ox(l),Ox(a)!==l&&f)throw Error(n(425))}function Fc(){}var xh=null,vh=null;function yh(a,l){return a==="textarea"||a==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var bh=typeof setTimeout=="function"?setTimeout:void 0,YE=typeof clearTimeout=="function"?clearTimeout:void 0,Px=typeof Promise=="function"?Promise:void 0,XE=typeof queueMicrotask=="function"?queueMicrotask:typeof Px<"u"?function(a){return Px.resolve(null).then(a).catch(QE)}:bh;function QE(a){setTimeout(function(){throw a})}function kh(a,l){var f=l,v=0;do{var _=f.nextSibling;if(a.removeChild(f),_&&_.nodeType===8)if(f=_.data,f==="/$"){if(v===0){a.removeChild(_),je(l);return}v--}else f!=="$"&&f!=="$?"&&f!=="$!"||v++;f=_}while(f);je(l)}function jr(a){for(;a!=null;a=a.nextSibling){var l=a.nodeType;if(l===1||l===3)break;if(l===8){if(l=a.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return a}function zx(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var f=a.data;if(f==="$"||f==="$!"||f==="$?"){if(l===0)return a;l--}else f==="/$"&&l++}a=a.previousSibling}return null}var Xa=Math.random().toString(36).slice(2),Ri="__reactFiber$"+Xa,ll="__reactProps$"+Xa,Ji="__reactContainer$"+Xa,Nh="__reactEvents$"+Xa,JE="__reactListeners$"+Xa,e1="__reactHandles$"+Xa;function aa(a){var l=a[Ri];if(l)return l;for(var f=a.parentNode;f;){if(l=f[Ji]||f[Ri]){if(f=l.alternate,l.child!==null||f!==null&&f.child!==null)for(a=zx(a);a!==null;){if(f=a[Ri])return f;a=zx(a)}return l}a=f,f=a.parentNode}return null}function cl(a){return a=a[Ri]||a[Ji],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function Qa(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function Uc(a){return a[ll]||null}var jh=[],Ja=-1;function wr(a){return{current:a}}function Ht(a){0>Ja||(a.current=jh[Ja],jh[Ja]=null,Ja--)}function Dt(a,l){Ja++,jh[Ja]=a.current,a.current=l}var Sr={},Vn=wr(Sr),ms=wr(!1),oa=Sr;function eo(a,l){var f=a.type.contextTypes;if(!f)return Sr;var v=a.stateNode;if(v&&v.__reactInternalMemoizedUnmaskedChildContext===l)return v.__reactInternalMemoizedMaskedChildContext;var _={},C;for(C in f)_[C]=l[C];return v&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=l,a.__reactInternalMemoizedMaskedChildContext=_),_}function ps(a){return a=a.childContextTypes,a!=null}function Bc(){Ht(ms),Ht(Vn)}function Lx(a,l,f){if(Vn.current!==Sr)throw Error(n(168));Dt(Vn,l),Dt(ms,f)}function Dx(a,l,f){var v=a.stateNode;if(l=l.childContextTypes,typeof v.getChildContext!="function")return f;v=v.getChildContext();for(var _ in v)if(!(_ in l))throw Error(n(108,ne(a)||"Unknown",_));return G({},f,v)}function Hc(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||Sr,oa=Vn.current,Dt(Vn,a),Dt(ms,ms.current),!0}function Fx(a,l,f){var v=a.stateNode;if(!v)throw Error(n(169));f?(a=Dx(a,l,oa),v.__reactInternalMemoizedMergedChildContext=a,Ht(ms),Ht(Vn),Dt(Vn,a)):Ht(ms),Dt(ms,f)}var er=null,Zc=!1,wh=!1;function Ux(a){er===null?er=[a]:er.push(a)}function t1(a){Zc=!0,Ux(a)}function _r(){if(!wh&&er!==null){wh=!0;var a=0,l=vt;try{var f=er;for(vt=1;a<f.length;a++){var v=f[a];do v=v(!0);while(v!==null)}er=null,Zc=!1}catch(_){throw er!==null&&(er=er.slice(a+1)),_s(Gi,_r),_}finally{vt=l,wh=!1}}return null}var to=[],no=0,Wc=null,Vc=0,Ws=[],Vs=0,la=null,tr=1,nr="";function ca(a,l){to[no++]=Vc,to[no++]=Wc,Wc=a,Vc=l}function Bx(a,l,f){Ws[Vs++]=tr,Ws[Vs++]=nr,Ws[Vs++]=la,la=a;var v=tr;a=nr;var _=32-Pt(v)-1;v&=~(1<<_),f+=1;var C=32-Pt(l)+_;if(30<C){var W=_-_%5;C=(v&(1<<W)-1).toString(32),v>>=W,_-=W,tr=1<<32-Pt(l)+_|f<<_|v,nr=C+a}else tr=1<<C|f<<_|v,nr=a}function Sh(a){a.return!==null&&(ca(a,1),Bx(a,1,0))}function _h(a){for(;a===Wc;)Wc=to[--no],to[no]=null,Vc=to[--no],to[no]=null;for(;a===la;)la=Ws[--Vs],Ws[Vs]=null,nr=Ws[--Vs],Ws[Vs]=null,tr=Ws[--Vs],Ws[Vs]=null}var Cs=null,As=null,Gt=!1,hi=null;function Hx(a,l){var f=Ys(5,null,null,0);f.elementType="DELETED",f.stateNode=l,f.return=a,l=a.deletions,l===null?(a.deletions=[f],a.flags|=16):l.push(f)}function Zx(a,l){switch(a.tag){case 5:var f=a.type;return l=l.nodeType!==1||f.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(a.stateNode=l,Cs=a,As=jr(l.firstChild),!0):!1;case 6:return l=a.pendingProps===""||l.nodeType!==3?null:l,l!==null?(a.stateNode=l,Cs=a,As=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(f=la!==null?{id:tr,overflow:nr}:null,a.memoizedState={dehydrated:l,treeContext:f,retryLane:1073741824},f=Ys(18,null,null,0),f.stateNode=l,f.return=a,a.child=f,Cs=a,As=null,!0):!1;default:return!1}}function Eh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Ch(a){if(Gt){var l=As;if(l){var f=l;if(!Zx(a,l)){if(Eh(a))throw Error(n(418));l=jr(f.nextSibling);var v=Cs;l&&Zx(a,l)?Hx(v,f):(a.flags=a.flags&-4097|2,Gt=!1,Cs=a)}}else{if(Eh(a))throw Error(n(418));a.flags=a.flags&-4097|2,Gt=!1,Cs=a}}}function Wx(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Cs=a}function qc(a){if(a!==Cs)return!1;if(!Gt)return Wx(a),Gt=!0,!1;var l;if((l=a.tag!==3)&&!(l=a.tag!==5)&&(l=a.type,l=l!=="head"&&l!=="body"&&!yh(a.type,a.memoizedProps)),l&&(l=As)){if(Eh(a))throw Vx(),Error(n(418));for(;l;)Hx(a,l),l=jr(l.nextSibling)}if(Wx(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));e:{for(a=a.nextSibling,l=0;a;){if(a.nodeType===8){var f=a.data;if(f==="/$"){if(l===0){As=jr(a.nextSibling);break e}l--}else f!=="$"&&f!=="$!"&&f!=="$?"||l++}a=a.nextSibling}As=null}}else As=Cs?jr(a.stateNode.nextSibling):null;return!0}function Vx(){for(var a=As;a;)a=jr(a.nextSibling)}function so(){As=Cs=null,Gt=!1}function Ah(a){hi===null?hi=[a]:hi.push(a)}var n1=A.ReactCurrentBatchConfig;function ul(a,l,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(n(309));var v=f.stateNode}if(!v)throw Error(n(147,a));var _=v,C=""+a;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===C?l.ref:(l=function(W){var Q=_.refs;W===null?delete Q[C]:Q[C]=W},l._stringRef=C,l)}if(typeof a!="string")throw Error(n(284));if(!f._owner)throw Error(n(290,a))}return a}function Gc(a,l){throw a=Object.prototype.toString.call(l),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a))}function qx(a){var l=a._init;return l(a._payload)}function Gx(a){function l(he,ce){if(a){var me=he.deletions;me===null?(he.deletions=[ce],he.flags|=16):me.push(ce)}}function f(he,ce){if(!a)return null;for(;ce!==null;)l(he,ce),ce=ce.sibling;return null}function v(he,ce){for(he=new Map;ce!==null;)ce.key!==null?he.set(ce.key,ce):he.set(ce.index,ce),ce=ce.sibling;return he}function _(he,ce){return he=Rr(he,ce),he.index=0,he.sibling=null,he}function C(he,ce,me){return he.index=me,a?(me=he.alternate,me!==null?(me=me.index,me<ce?(he.flags|=2,ce):me):(he.flags|=2,ce)):(he.flags|=1048576,ce)}function W(he){return a&&he.alternate===null&&(he.flags|=2),he}function Q(he,ce,me,Oe){return ce===null||ce.tag!==6?(ce=kf(me,he.mode,Oe),ce.return=he,ce):(ce=_(ce,me),ce.return=he,ce)}function ae(he,ce,me,Oe){var Ye=me.type;return Ye===B?Ee(he,ce,me.props.children,Oe,me.key):ce!==null&&(ce.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===$&&qx(Ye)===ce.type)?(Oe=_(ce,me.props),Oe.ref=ul(he,ce,me),Oe.return=he,Oe):(Oe=vu(me.type,me.key,me.props,null,he.mode,Oe),Oe.ref=ul(he,ce,me),Oe.return=he,Oe)}function ge(he,ce,me,Oe){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==me.containerInfo||ce.stateNode.implementation!==me.implementation?(ce=Nf(me,he.mode,Oe),ce.return=he,ce):(ce=_(ce,me.children||[]),ce.return=he,ce)}function Ee(he,ce,me,Oe,Ye){return ce===null||ce.tag!==7?(ce=xa(me,he.mode,Oe,Ye),ce.return=he,ce):(ce=_(ce,me),ce.return=he,ce)}function Ae(he,ce,me){if(typeof ce=="string"&&ce!==""||typeof ce=="number")return ce=kf(""+ce,he.mode,me),ce.return=he,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case P:return me=vu(ce.type,ce.key,ce.props,null,he.mode,me),me.ref=ul(he,null,ce),me.return=he,me;case L:return ce=Nf(ce,he.mode,me),ce.return=he,ce;case $:var Oe=ce._init;return Ae(he,Oe(ce._payload),me)}if(et(ce)||Z(ce))return ce=xa(ce,he.mode,me,null),ce.return=he,ce;Gc(he,ce)}return null}function _e(he,ce,me,Oe){var Ye=ce!==null?ce.key:null;if(typeof me=="string"&&me!==""||typeof me=="number")return Ye!==null?null:Q(he,ce,""+me,Oe);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case P:return me.key===Ye?ae(he,ce,me,Oe):null;case L:return me.key===Ye?ge(he,ce,me,Oe):null;case $:return Ye=me._init,_e(he,ce,Ye(me._payload),Oe)}if(et(me)||Z(me))return Ye!==null?null:Ee(he,ce,me,Oe,null);Gc(he,me)}return null}function He(he,ce,me,Oe,Ye){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number")return he=he.get(me)||null,Q(ce,he,""+Oe,Ye);if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case P:return he=he.get(Oe.key===null?me:Oe.key)||null,ae(ce,he,Oe,Ye);case L:return he=he.get(Oe.key===null?me:Oe.key)||null,ge(ce,he,Oe,Ye);case $:var it=Oe._init;return He(he,ce,me,it(Oe._payload),Ye)}if(et(Oe)||Z(Oe))return he=he.get(me)||null,Ee(ce,he,Oe,Ye,null);Gc(ce,Oe)}return null}function Ve(he,ce,me,Oe){for(var Ye=null,it=null,rt=ce,lt=ce=0,Mn=null;rt!==null&&lt<me.length;lt++){rt.index>lt?(Mn=rt,rt=null):Mn=rt.sibling;var _t=_e(he,rt,me[lt],Oe);if(_t===null){rt===null&&(rt=Mn);break}a&&rt&&_t.alternate===null&&l(he,rt),ce=C(_t,ce,lt),it===null?Ye=_t:it.sibling=_t,it=_t,rt=Mn}if(lt===me.length)return f(he,rt),Gt&&ca(he,lt),Ye;if(rt===null){for(;lt<me.length;lt++)rt=Ae(he,me[lt],Oe),rt!==null&&(ce=C(rt,ce,lt),it===null?Ye=rt:it.sibling=rt,it=rt);return Gt&&ca(he,lt),Ye}for(rt=v(he,rt);lt<me.length;lt++)Mn=He(rt,he,lt,me[lt],Oe),Mn!==null&&(a&&Mn.alternate!==null&&rt.delete(Mn.key===null?lt:Mn.key),ce=C(Mn,ce,lt),it===null?Ye=Mn:it.sibling=Mn,it=Mn);return a&&rt.forEach(function(Or){return l(he,Or)}),Gt&&ca(he,lt),Ye}function Ke(he,ce,me,Oe){var Ye=Z(me);if(typeof Ye!="function")throw Error(n(150));if(me=Ye.call(me),me==null)throw Error(n(151));for(var it=Ye=null,rt=ce,lt=ce=0,Mn=null,_t=me.next();rt!==null&&!_t.done;lt++,_t=me.next()){rt.index>lt?(Mn=rt,rt=null):Mn=rt.sibling;var Or=_e(he,rt,_t.value,Oe);if(Or===null){rt===null&&(rt=Mn);break}a&&rt&&Or.alternate===null&&l(he,rt),ce=C(Or,ce,lt),it===null?Ye=Or:it.sibling=Or,it=Or,rt=Mn}if(_t.done)return f(he,rt),Gt&&ca(he,lt),Ye;if(rt===null){for(;!_t.done;lt++,_t=me.next())_t=Ae(he,_t.value,Oe),_t!==null&&(ce=C(_t,ce,lt),it===null?Ye=_t:it.sibling=_t,it=_t);return Gt&&ca(he,lt),Ye}for(rt=v(he,rt);!_t.done;lt++,_t=me.next())_t=He(rt,he,lt,_t.value,Oe),_t!==null&&(a&&_t.alternate!==null&&rt.delete(_t.key===null?lt:_t.key),ce=C(_t,ce,lt),it===null?Ye=_t:it.sibling=_t,it=_t);return a&&rt.forEach(function(O1){return l(he,O1)}),Gt&&ca(he,lt),Ye}function fn(he,ce,me,Oe){if(typeof me=="object"&&me!==null&&me.type===B&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case P:e:{for(var Ye=me.key,it=ce;it!==null;){if(it.key===Ye){if(Ye=me.type,Ye===B){if(it.tag===7){f(he,it.sibling),ce=_(it,me.props.children),ce.return=he,he=ce;break e}}else if(it.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===$&&qx(Ye)===it.type){f(he,it.sibling),ce=_(it,me.props),ce.ref=ul(he,it,me),ce.return=he,he=ce;break e}f(he,it);break}else l(he,it);it=it.sibling}me.type===B?(ce=xa(me.props.children,he.mode,Oe,me.key),ce.return=he,he=ce):(Oe=vu(me.type,me.key,me.props,null,he.mode,Oe),Oe.ref=ul(he,ce,me),Oe.return=he,he=Oe)}return W(he);case L:e:{for(it=me.key;ce!==null;){if(ce.key===it)if(ce.tag===4&&ce.stateNode.containerInfo===me.containerInfo&&ce.stateNode.implementation===me.implementation){f(he,ce.sibling),ce=_(ce,me.children||[]),ce.return=he,he=ce;break e}else{f(he,ce);break}else l(he,ce);ce=ce.sibling}ce=Nf(me,he.mode,Oe),ce.return=he,he=ce}return W(he);case $:return it=me._init,fn(he,ce,it(me._payload),Oe)}if(et(me))return Ve(he,ce,me,Oe);if(Z(me))return Ke(he,ce,me,Oe);Gc(he,me)}return typeof me=="string"&&me!==""||typeof me=="number"?(me=""+me,ce!==null&&ce.tag===6?(f(he,ce.sibling),ce=_(ce,me),ce.return=he,he=ce):(f(he,ce),ce=kf(me,he.mode,Oe),ce.return=he,he=ce),W(he)):f(he,ce)}return fn}var io=Gx(!0),Kx=Gx(!1),Kc=wr(null),Yc=null,ro=null,Ih=null;function Th(){Ih=ro=Yc=null}function $h(a){var l=Kc.current;Ht(Kc),a._currentValue=l}function Mh(a,l,f){for(;a!==null;){var v=a.alternate;if((a.childLanes&l)!==l?(a.childLanes|=l,v!==null&&(v.childLanes|=l)):v!==null&&(v.childLanes&l)!==l&&(v.childLanes|=l),a===f)break;a=a.return}}function ao(a,l){Yc=a,Ih=ro=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&l)!==0&&(gs=!0),a.firstContext=null)}function qs(a){var l=a._currentValue;if(Ih!==a)if(a={context:a,memoizedValue:l,next:null},ro===null){if(Yc===null)throw Error(n(308));ro=a,Yc.dependencies={lanes:0,firstContext:a}}else ro=ro.next=a;return l}var ua=null;function Rh(a){ua===null?ua=[a]:ua.push(a)}function Yx(a,l,f,v){var _=l.interleaved;return _===null?(f.next=f,Rh(l)):(f.next=_.next,_.next=f),l.interleaved=f,sr(a,v)}function sr(a,l){a.lanes|=l;var f=a.alternate;for(f!==null&&(f.lanes|=l),f=a,a=a.return;a!==null;)a.childLanes|=l,f=a.alternate,f!==null&&(f.childLanes|=l),f=a,a=a.return;return f.tag===3?f.stateNode:null}var Er=!1;function Oh(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xx(a,l){a=a.updateQueue,l.updateQueue===a&&(l.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function ir(a,l){return{eventTime:a,lane:l,tag:0,payload:null,callback:null,next:null}}function Cr(a,l,f){var v=a.updateQueue;if(v===null)return null;if(v=v.shared,(kt&2)!==0){var _=v.pending;return _===null?l.next=l:(l.next=_.next,_.next=l),v.pending=l,sr(a,f)}return _=v.interleaved,_===null?(l.next=l,Rh(v)):(l.next=_.next,_.next=l),v.interleaved=l,sr(a,f)}function Xc(a,l,f){if(l=l.updateQueue,l!==null&&(l=l.shared,(f&4194240)!==0)){var v=l.lanes;v&=a.pendingLanes,f|=v,l.lanes=f,Zs(a,f)}}function Qx(a,l){var f=a.updateQueue,v=a.alternate;if(v!==null&&(v=v.updateQueue,f===v)){var _=null,C=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};C===null?_=C=W:C=C.next=W,f=f.next}while(f!==null);C===null?_=C=l:C=C.next=l}else _=C=l;f={baseState:v.baseState,firstBaseUpdate:_,lastBaseUpdate:C,shared:v.shared,effects:v.effects},a.updateQueue=f;return}a=f.lastBaseUpdate,a===null?f.firstBaseUpdate=l:a.next=l,f.lastBaseUpdate=l}function Qc(a,l,f,v){var _=a.updateQueue;Er=!1;var C=_.firstBaseUpdate,W=_.lastBaseUpdate,Q=_.shared.pending;if(Q!==null){_.shared.pending=null;var ae=Q,ge=ae.next;ae.next=null,W===null?C=ge:W.next=ge,W=ae;var Ee=a.alternate;Ee!==null&&(Ee=Ee.updateQueue,Q=Ee.lastBaseUpdate,Q!==W&&(Q===null?Ee.firstBaseUpdate=ge:Q.next=ge,Ee.lastBaseUpdate=ae))}if(C!==null){var Ae=_.baseState;W=0,Ee=ge=ae=null,Q=C;do{var _e=Q.lane,He=Q.eventTime;if((v&_e)===_e){Ee!==null&&(Ee=Ee.next={eventTime:He,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var Ve=a,Ke=Q;switch(_e=l,He=f,Ke.tag){case 1:if(Ve=Ke.payload,typeof Ve=="function"){Ae=Ve.call(He,Ae,_e);break e}Ae=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=Ke.payload,_e=typeof Ve=="function"?Ve.call(He,Ae,_e):Ve,_e==null)break e;Ae=G({},Ae,_e);break e;case 2:Er=!0}}Q.callback!==null&&Q.lane!==0&&(a.flags|=64,_e=_.effects,_e===null?_.effects=[Q]:_e.push(Q))}else He={eventTime:He,lane:_e,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},Ee===null?(ge=Ee=He,ae=Ae):Ee=Ee.next=He,W|=_e;if(Q=Q.next,Q===null){if(Q=_.shared.pending,Q===null)break;_e=Q,Q=_e.next,_e.next=null,_.lastBaseUpdate=_e,_.shared.pending=null}}while(!0);if(Ee===null&&(ae=Ae),_.baseState=ae,_.firstBaseUpdate=ge,_.lastBaseUpdate=Ee,l=_.shared.interleaved,l!==null){_=l;do W|=_.lane,_=_.next;while(_!==l)}else C===null&&(_.shared.lanes=0);fa|=W,a.lanes=W,a.memoizedState=Ae}}function Jx(a,l,f){if(a=l.effects,l.effects=null,a!==null)for(l=0;l<a.length;l++){var v=a[l],_=v.callback;if(_!==null){if(v.callback=null,v=f,typeof _!="function")throw Error(n(191,_));_.call(v)}}}var dl={},Oi=wr(dl),hl=wr(dl),fl=wr(dl);function da(a){if(a===dl)throw Error(n(174));return a}function Ph(a,l){switch(Dt(fl,l),Dt(hl,a),Dt(Oi,dl),a=l.nodeType,a){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:on(null,"");break;default:a=a===8?l.parentNode:l,l=a.namespaceURI||null,a=a.tagName,l=on(l,a)}Ht(Oi),Dt(Oi,l)}function oo(){Ht(Oi),Ht(hl),Ht(fl)}function ev(a){da(fl.current);var l=da(Oi.current),f=on(l,a.type);l!==f&&(Dt(hl,a),Dt(Oi,f))}function zh(a){hl.current===a&&(Ht(Oi),Ht(hl))}var en=wr(0);function Jc(a){for(var l=a;l!==null;){if(l.tag===13){var f=l.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||f.data==="$?"||f.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var Lh=[];function Dh(){for(var a=0;a<Lh.length;a++)Lh[a]._workInProgressVersionPrimary=null;Lh.length=0}var eu=A.ReactCurrentDispatcher,Fh=A.ReactCurrentBatchConfig,ha=0,tn=null,En=null,Tn=null,tu=!1,ml=!1,pl=0,s1=0;function qn(){throw Error(n(321))}function Uh(a,l){if(l===null)return!1;for(var f=0;f<l.length&&f<a.length;f++)if(!di(a[f],l[f]))return!1;return!0}function Bh(a,l,f,v,_,C){if(ha=C,tn=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,eu.current=a===null||a.memoizedState===null?o1:l1,a=f(v,_),ml){C=0;do{if(ml=!1,pl=0,25<=C)throw Error(n(301));C+=1,Tn=En=null,l.updateQueue=null,eu.current=c1,a=f(v,_)}while(ml)}if(eu.current=iu,l=En!==null&&En.next!==null,ha=0,Tn=En=tn=null,tu=!1,l)throw Error(n(300));return a}function Hh(){var a=pl!==0;return pl=0,a}function Pi(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Tn===null?tn.memoizedState=Tn=a:Tn=Tn.next=a,Tn}function Gs(){if(En===null){var a=tn.alternate;a=a!==null?a.memoizedState:null}else a=En.next;var l=Tn===null?tn.memoizedState:Tn.next;if(l!==null)Tn=l,En=a;else{if(a===null)throw Error(n(310));En=a,a={memoizedState:En.memoizedState,baseState:En.baseState,baseQueue:En.baseQueue,queue:En.queue,next:null},Tn===null?tn.memoizedState=Tn=a:Tn=Tn.next=a}return Tn}function gl(a,l){return typeof l=="function"?l(a):l}function Zh(a){var l=Gs(),f=l.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=a;var v=En,_=v.baseQueue,C=f.pending;if(C!==null){if(_!==null){var W=_.next;_.next=C.next,C.next=W}v.baseQueue=_=C,f.pending=null}if(_!==null){C=_.next,v=v.baseState;var Q=W=null,ae=null,ge=C;do{var Ee=ge.lane;if((ha&Ee)===Ee)ae!==null&&(ae=ae.next={lane:0,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null}),v=ge.hasEagerState?ge.eagerState:a(v,ge.action);else{var Ae={lane:Ee,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null};ae===null?(Q=ae=Ae,W=v):ae=ae.next=Ae,tn.lanes|=Ee,fa|=Ee}ge=ge.next}while(ge!==null&&ge!==C);ae===null?W=v:ae.next=Q,di(v,l.memoizedState)||(gs=!0),l.memoizedState=v,l.baseState=W,l.baseQueue=ae,f.lastRenderedState=v}if(a=f.interleaved,a!==null){_=a;do C=_.lane,tn.lanes|=C,fa|=C,_=_.next;while(_!==a)}else _===null&&(f.lanes=0);return[l.memoizedState,f.dispatch]}function Wh(a){var l=Gs(),f=l.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=a;var v=f.dispatch,_=f.pending,C=l.memoizedState;if(_!==null){f.pending=null;var W=_=_.next;do C=a(C,W.action),W=W.next;while(W!==_);di(C,l.memoizedState)||(gs=!0),l.memoizedState=C,l.baseQueue===null&&(l.baseState=C),f.lastRenderedState=C}return[C,v]}function tv(){}function nv(a,l){var f=tn,v=Gs(),_=l(),C=!di(v.memoizedState,_);if(C&&(v.memoizedState=_,gs=!0),v=v.queue,Vh(rv.bind(null,f,v,a),[a]),v.getSnapshot!==l||C||Tn!==null&&Tn.memoizedState.tag&1){if(f.flags|=2048,xl(9,iv.bind(null,f,v,_,l),void 0,null),$n===null)throw Error(n(349));(ha&30)!==0||sv(f,l,_)}return _}function sv(a,l,f){a.flags|=16384,a={getSnapshot:l,value:f},l=tn.updateQueue,l===null?(l={lastEffect:null,stores:null},tn.updateQueue=l,l.stores=[a]):(f=l.stores,f===null?l.stores=[a]:f.push(a))}function iv(a,l,f,v){l.value=f,l.getSnapshot=v,av(l)&&ov(a)}function rv(a,l,f){return f(function(){av(l)&&ov(a)})}function av(a){var l=a.getSnapshot;a=a.value;try{var f=l();return!di(a,f)}catch{return!0}}function ov(a){var l=sr(a,1);l!==null&&gi(l,a,1,-1)}function lv(a){var l=Pi();return typeof a=="function"&&(a=a()),l.memoizedState=l.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:gl,lastRenderedState:a},l.queue=a,a=a.dispatch=a1.bind(null,tn,a),[l.memoizedState,a]}function xl(a,l,f,v){return a={tag:a,create:l,destroy:f,deps:v,next:null},l=tn.updateQueue,l===null?(l={lastEffect:null,stores:null},tn.updateQueue=l,l.lastEffect=a.next=a):(f=l.lastEffect,f===null?l.lastEffect=a.next=a:(v=f.next,f.next=a,a.next=v,l.lastEffect=a)),a}function cv(){return Gs().memoizedState}function nu(a,l,f,v){var _=Pi();tn.flags|=a,_.memoizedState=xl(1|l,f,void 0,v===void 0?null:v)}function su(a,l,f,v){var _=Gs();v=v===void 0?null:v;var C=void 0;if(En!==null){var W=En.memoizedState;if(C=W.destroy,v!==null&&Uh(v,W.deps)){_.memoizedState=xl(l,f,C,v);return}}tn.flags|=a,_.memoizedState=xl(1|l,f,C,v)}function uv(a,l){return nu(8390656,8,a,l)}function Vh(a,l){return su(2048,8,a,l)}function dv(a,l){return su(4,2,a,l)}function hv(a,l){return su(4,4,a,l)}function fv(a,l){if(typeof l=="function")return a=a(),l(a),function(){l(null)};if(l!=null)return a=a(),l.current=a,function(){l.current=null}}function mv(a,l,f){return f=f!=null?f.concat([a]):null,su(4,4,fv.bind(null,l,a),f)}function qh(){}function pv(a,l){var f=Gs();l=l===void 0?null:l;var v=f.memoizedState;return v!==null&&l!==null&&Uh(l,v[1])?v[0]:(f.memoizedState=[a,l],a)}function gv(a,l){var f=Gs();l=l===void 0?null:l;var v=f.memoizedState;return v!==null&&l!==null&&Uh(l,v[1])?v[0]:(a=a(),f.memoizedState=[a,l],a)}function xv(a,l,f){return(ha&21)===0?(a.baseState&&(a.baseState=!1,gs=!0),a.memoizedState=f):(di(f,l)||(f=kr(),tn.lanes|=f,fa|=f,a.baseState=!0),l)}function i1(a,l){var f=vt;vt=f!==0&&4>f?f:4,a(!0);var v=Fh.transition;Fh.transition={};try{a(!1),l()}finally{vt=f,Fh.transition=v}}function vv(){return Gs().memoizedState}function r1(a,l,f){var v=$r(a);if(f={lane:v,action:f,hasEagerState:!1,eagerState:null,next:null},yv(a))bv(l,f);else if(f=Yx(a,l,f,v),f!==null){var _=ns();gi(f,a,v,_),kv(f,l,v)}}function a1(a,l,f){var v=$r(a),_={lane:v,action:f,hasEagerState:!1,eagerState:null,next:null};if(yv(a))bv(l,_);else{var C=a.alternate;if(a.lanes===0&&(C===null||C.lanes===0)&&(C=l.lastRenderedReducer,C!==null))try{var W=l.lastRenderedState,Q=C(W,f);if(_.hasEagerState=!0,_.eagerState=Q,di(Q,W)){var ae=l.interleaved;ae===null?(_.next=_,Rh(l)):(_.next=ae.next,ae.next=_),l.interleaved=_;return}}catch{}finally{}f=Yx(a,l,_,v),f!==null&&(_=ns(),gi(f,a,v,_),kv(f,l,v))}}function yv(a){var l=a.alternate;return a===tn||l!==null&&l===tn}function bv(a,l){ml=tu=!0;var f=a.pending;f===null?l.next=l:(l.next=f.next,f.next=l),a.pending=l}function kv(a,l,f){if((f&4194240)!==0){var v=l.lanes;v&=a.pendingLanes,f|=v,l.lanes=f,Zs(a,f)}}var iu={readContext:qs,useCallback:qn,useContext:qn,useEffect:qn,useImperativeHandle:qn,useInsertionEffect:qn,useLayoutEffect:qn,useMemo:qn,useReducer:qn,useRef:qn,useState:qn,useDebugValue:qn,useDeferredValue:qn,useTransition:qn,useMutableSource:qn,useSyncExternalStore:qn,useId:qn,unstable_isNewReconciler:!1},o1={readContext:qs,useCallback:function(a,l){return Pi().memoizedState=[a,l===void 0?null:l],a},useContext:qs,useEffect:uv,useImperativeHandle:function(a,l,f){return f=f!=null?f.concat([a]):null,nu(4194308,4,fv.bind(null,l,a),f)},useLayoutEffect:function(a,l){return nu(4194308,4,a,l)},useInsertionEffect:function(a,l){return nu(4,2,a,l)},useMemo:function(a,l){var f=Pi();return l=l===void 0?null:l,a=a(),f.memoizedState=[a,l],a},useReducer:function(a,l,f){var v=Pi();return l=f!==void 0?f(l):l,v.memoizedState=v.baseState=l,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:l},v.queue=a,a=a.dispatch=r1.bind(null,tn,a),[v.memoizedState,a]},useRef:function(a){var l=Pi();return a={current:a},l.memoizedState=a},useState:lv,useDebugValue:qh,useDeferredValue:function(a){return Pi().memoizedState=a},useTransition:function(){var a=lv(!1),l=a[0];return a=i1.bind(null,a[1]),Pi().memoizedState=a,[l,a]},useMutableSource:function(){},useSyncExternalStore:function(a,l,f){var v=tn,_=Pi();if(Gt){if(f===void 0)throw Error(n(407));f=f()}else{if(f=l(),$n===null)throw Error(n(349));(ha&30)!==0||sv(v,l,f)}_.memoizedState=f;var C={value:f,getSnapshot:l};return _.queue=C,uv(rv.bind(null,v,C,a),[a]),v.flags|=2048,xl(9,iv.bind(null,v,C,f,l),void 0,null),f},useId:function(){var a=Pi(),l=$n.identifierPrefix;if(Gt){var f=nr,v=tr;f=(v&~(1<<32-Pt(v)-1)).toString(32)+f,l=":"+l+"R"+f,f=pl++,0<f&&(l+="H"+f.toString(32)),l+=":"}else f=s1++,l=":"+l+"r"+f.toString(32)+":";return a.memoizedState=l},unstable_isNewReconciler:!1},l1={readContext:qs,useCallback:pv,useContext:qs,useEffect:Vh,useImperativeHandle:mv,useInsertionEffect:dv,useLayoutEffect:hv,useMemo:gv,useReducer:Zh,useRef:cv,useState:function(){return Zh(gl)},useDebugValue:qh,useDeferredValue:function(a){var l=Gs();return xv(l,En.memoizedState,a)},useTransition:function(){var a=Zh(gl)[0],l=Gs().memoizedState;return[a,l]},useMutableSource:tv,useSyncExternalStore:nv,useId:vv,unstable_isNewReconciler:!1},c1={readContext:qs,useCallback:pv,useContext:qs,useEffect:Vh,useImperativeHandle:mv,useInsertionEffect:dv,useLayoutEffect:hv,useMemo:gv,useReducer:Wh,useRef:cv,useState:function(){return Wh(gl)},useDebugValue:qh,useDeferredValue:function(a){var l=Gs();return En===null?l.memoizedState=a:xv(l,En.memoizedState,a)},useTransition:function(){var a=Wh(gl)[0],l=Gs().memoizedState;return[a,l]},useMutableSource:tv,useSyncExternalStore:nv,useId:vv,unstable_isNewReconciler:!1};function fi(a,l){if(a&&a.defaultProps){l=G({},l),a=a.defaultProps;for(var f in a)l[f]===void 0&&(l[f]=a[f]);return l}return l}function Gh(a,l,f,v){l=a.memoizedState,f=f(v,l),f=f==null?l:G({},l,f),a.memoizedState=f,a.lanes===0&&(a.updateQueue.baseState=f)}var ru={isMounted:function(a){return(a=a._reactInternals)?Zn(a)===a:!1},enqueueSetState:function(a,l,f){a=a._reactInternals;var v=ns(),_=$r(a),C=ir(v,_);C.payload=l,f!=null&&(C.callback=f),l=Cr(a,C,_),l!==null&&(gi(l,a,_,v),Xc(l,a,_))},enqueueReplaceState:function(a,l,f){a=a._reactInternals;var v=ns(),_=$r(a),C=ir(v,_);C.tag=1,C.payload=l,f!=null&&(C.callback=f),l=Cr(a,C,_),l!==null&&(gi(l,a,_,v),Xc(l,a,_))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var f=ns(),v=$r(a),_=ir(f,v);_.tag=2,l!=null&&(_.callback=l),l=Cr(a,_,v),l!==null&&(gi(l,a,v,f),Xc(l,a,v))}};function Nv(a,l,f,v,_,C,W){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(v,C,W):l.prototype&&l.prototype.isPureReactComponent?!sl(f,v)||!sl(_,C):!0}function jv(a,l,f){var v=!1,_=Sr,C=l.contextType;return typeof C=="object"&&C!==null?C=qs(C):(_=ps(l)?oa:Vn.current,v=l.contextTypes,C=(v=v!=null)?eo(a,_):Sr),l=new l(f,C),a.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=ru,a.stateNode=l,l._reactInternals=a,v&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=_,a.__reactInternalMemoizedMaskedChildContext=C),l}function wv(a,l,f,v){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(f,v),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(f,v),l.state!==a&&ru.enqueueReplaceState(l,l.state,null)}function Kh(a,l,f,v){var _=a.stateNode;_.props=f,_.state=a.memoizedState,_.refs={},Oh(a);var C=l.contextType;typeof C=="object"&&C!==null?_.context=qs(C):(C=ps(l)?oa:Vn.current,_.context=eo(a,C)),_.state=a.memoizedState,C=l.getDerivedStateFromProps,typeof C=="function"&&(Gh(a,l,C,f),_.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof _.getSnapshotBeforeUpdate=="function"||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(l=_.state,typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount(),l!==_.state&&ru.enqueueReplaceState(_,_.state,null),Qc(a,f,_,v),_.state=a.memoizedState),typeof _.componentDidMount=="function"&&(a.flags|=4194308)}function lo(a,l){try{var f="",v=l;do f+=ee(v),v=v.return;while(v);var _=f}catch(C){_=`
39
+ Error generating stack: `+C.message+`
40
+ `+C.stack}return{value:a,source:l,stack:_,digest:null}}function Yh(a,l,f){return{value:a,source:null,stack:f??null,digest:l??null}}function Xh(a,l){try{console.error(l.value)}catch(f){setTimeout(function(){throw f})}}var u1=typeof WeakMap=="function"?WeakMap:Map;function Sv(a,l,f){f=ir(-1,f),f.tag=3,f.payload={element:null};var v=l.value;return f.callback=function(){hu||(hu=!0,ff=v),Xh(a,l)},f}function _v(a,l,f){f=ir(-1,f),f.tag=3;var v=a.type.getDerivedStateFromError;if(typeof v=="function"){var _=l.value;f.payload=function(){return v(_)},f.callback=function(){Xh(a,l)}}var C=a.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(f.callback=function(){Xh(a,l),typeof v!="function"&&(Ir===null?Ir=new Set([this]):Ir.add(this));var W=l.stack;this.componentDidCatch(l.value,{componentStack:W!==null?W:""})}),f}function Ev(a,l,f){var v=a.pingCache;if(v===null){v=a.pingCache=new u1;var _=new Set;v.set(l,_)}else _=v.get(l),_===void 0&&(_=new Set,v.set(l,_));_.has(f)||(_.add(f),a=w1.bind(null,a,l,f),l.then(a,a))}function Cv(a){do{var l;if((l=a.tag===13)&&(l=a.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return a;a=a.return}while(a!==null);return null}function Av(a,l,f,v,_){return(a.mode&1)===0?(a===l?a.flags|=65536:(a.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(l=ir(-1,1),l.tag=2,Cr(f,l,1))),f.lanes|=1),a):(a.flags|=65536,a.lanes=_,a)}var d1=A.ReactCurrentOwner,gs=!1;function ts(a,l,f,v){l.child=a===null?Kx(l,null,f,v):io(l,a.child,f,v)}function Iv(a,l,f,v,_){f=f.render;var C=l.ref;return ao(l,_),v=Bh(a,l,f,v,C,_),f=Hh(),a!==null&&!gs?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~_,rr(a,l,_)):(Gt&&f&&Sh(l),l.flags|=1,ts(a,l,v,_),l.child)}function Tv(a,l,f,v,_){if(a===null){var C=f.type;return typeof C=="function"&&!bf(C)&&C.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0?(l.tag=15,l.type=C,$v(a,l,C,v,_)):(a=vu(f.type,null,v,l,l.mode,_),a.ref=l.ref,a.return=l,l.child=a)}if(C=a.child,(a.lanes&_)===0){var W=C.memoizedProps;if(f=f.compare,f=f!==null?f:sl,f(W,v)&&a.ref===l.ref)return rr(a,l,_)}return l.flags|=1,a=Rr(C,v),a.ref=l.ref,a.return=l,l.child=a}function $v(a,l,f,v,_){if(a!==null){var C=a.memoizedProps;if(sl(C,v)&&a.ref===l.ref)if(gs=!1,l.pendingProps=v=C,(a.lanes&_)!==0)(a.flags&131072)!==0&&(gs=!0);else return l.lanes=a.lanes,rr(a,l,_)}return Qh(a,l,f,v,_)}function Mv(a,l,f){var v=l.pendingProps,_=v.children,C=a!==null?a.memoizedState:null;if(v.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Dt(uo,Is),Is|=f;else{if((f&1073741824)===0)return a=C!==null?C.baseLanes|f:f,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:a,cachePool:null,transitions:null},l.updateQueue=null,Dt(uo,Is),Is|=a,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},v=C!==null?C.baseLanes:f,Dt(uo,Is),Is|=v}else C!==null?(v=C.baseLanes|f,l.memoizedState=null):v=f,Dt(uo,Is),Is|=v;return ts(a,l,_,f),l.child}function Rv(a,l){var f=l.ref;(a===null&&f!==null||a!==null&&a.ref!==f)&&(l.flags|=512,l.flags|=2097152)}function Qh(a,l,f,v,_){var C=ps(f)?oa:Vn.current;return C=eo(l,C),ao(l,_),f=Bh(a,l,f,v,C,_),v=Hh(),a!==null&&!gs?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~_,rr(a,l,_)):(Gt&&v&&Sh(l),l.flags|=1,ts(a,l,f,_),l.child)}function Ov(a,l,f,v,_){if(ps(f)){var C=!0;Hc(l)}else C=!1;if(ao(l,_),l.stateNode===null)ou(a,l),jv(l,f,v),Kh(l,f,v,_),v=!0;else if(a===null){var W=l.stateNode,Q=l.memoizedProps;W.props=Q;var ae=W.context,ge=f.contextType;typeof ge=="object"&&ge!==null?ge=qs(ge):(ge=ps(f)?oa:Vn.current,ge=eo(l,ge));var Ee=f.getDerivedStateFromProps,Ae=typeof Ee=="function"||typeof W.getSnapshotBeforeUpdate=="function";Ae||typeof W.UNSAFE_componentWillReceiveProps!="function"&&typeof W.componentWillReceiveProps!="function"||(Q!==v||ae!==ge)&&wv(l,W,v,ge),Er=!1;var _e=l.memoizedState;W.state=_e,Qc(l,v,W,_),ae=l.memoizedState,Q!==v||_e!==ae||ms.current||Er?(typeof Ee=="function"&&(Gh(l,f,Ee,v),ae=l.memoizedState),(Q=Er||Nv(l,f,Q,v,_e,ae,ge))?(Ae||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"&&(l.flags|=4194308)):(typeof W.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=v,l.memoizedState=ae),W.props=v,W.state=ae,W.context=ge,v=Q):(typeof W.componentDidMount=="function"&&(l.flags|=4194308),v=!1)}else{W=l.stateNode,Xx(a,l),Q=l.memoizedProps,ge=l.type===l.elementType?Q:fi(l.type,Q),W.props=ge,Ae=l.pendingProps,_e=W.context,ae=f.contextType,typeof ae=="object"&&ae!==null?ae=qs(ae):(ae=ps(f)?oa:Vn.current,ae=eo(l,ae));var He=f.getDerivedStateFromProps;(Ee=typeof He=="function"||typeof W.getSnapshotBeforeUpdate=="function")||typeof W.UNSAFE_componentWillReceiveProps!="function"&&typeof W.componentWillReceiveProps!="function"||(Q!==Ae||_e!==ae)&&wv(l,W,v,ae),Er=!1,_e=l.memoizedState,W.state=_e,Qc(l,v,W,_);var Ve=l.memoizedState;Q!==Ae||_e!==Ve||ms.current||Er?(typeof He=="function"&&(Gh(l,f,He,v),Ve=l.memoizedState),(ge=Er||Nv(l,f,ge,v,_e,Ve,ae)||!1)?(Ee||typeof W.UNSAFE_componentWillUpdate!="function"&&typeof W.componentWillUpdate!="function"||(typeof W.componentWillUpdate=="function"&&W.componentWillUpdate(v,Ve,ae),typeof W.UNSAFE_componentWillUpdate=="function"&&W.UNSAFE_componentWillUpdate(v,Ve,ae)),typeof W.componentDidUpdate=="function"&&(l.flags|=4),typeof W.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof W.componentDidUpdate!="function"||Q===a.memoizedProps&&_e===a.memoizedState||(l.flags|=4),typeof W.getSnapshotBeforeUpdate!="function"||Q===a.memoizedProps&&_e===a.memoizedState||(l.flags|=1024),l.memoizedProps=v,l.memoizedState=Ve),W.props=v,W.state=Ve,W.context=ae,v=ge):(typeof W.componentDidUpdate!="function"||Q===a.memoizedProps&&_e===a.memoizedState||(l.flags|=4),typeof W.getSnapshotBeforeUpdate!="function"||Q===a.memoizedProps&&_e===a.memoizedState||(l.flags|=1024),v=!1)}return Jh(a,l,f,v,C,_)}function Jh(a,l,f,v,_,C){Rv(a,l);var W=(l.flags&128)!==0;if(!v&&!W)return _&&Fx(l,f,!1),rr(a,l,C);v=l.stateNode,d1.current=l;var Q=W&&typeof f.getDerivedStateFromError!="function"?null:v.render();return l.flags|=1,a!==null&&W?(l.child=io(l,a.child,null,C),l.child=io(l,null,Q,C)):ts(a,l,Q,C),l.memoizedState=v.state,_&&Fx(l,f,!0),l.child}function Pv(a){var l=a.stateNode;l.pendingContext?Lx(a,l.pendingContext,l.pendingContext!==l.context):l.context&&Lx(a,l.context,!1),Ph(a,l.containerInfo)}function zv(a,l,f,v,_){return so(),Ah(_),l.flags|=256,ts(a,l,f,v),l.child}var ef={dehydrated:null,treeContext:null,retryLane:0};function tf(a){return{baseLanes:a,cachePool:null,transitions:null}}function Lv(a,l,f){var v=l.pendingProps,_=en.current,C=!1,W=(l.flags&128)!==0,Q;if((Q=W)||(Q=a!==null&&a.memoizedState===null?!1:(_&2)!==0),Q?(C=!0,l.flags&=-129):(a===null||a.memoizedState!==null)&&(_|=1),Dt(en,_&1),a===null)return Ch(l),a=l.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((l.mode&1)===0?l.lanes=1:a.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(W=v.children,a=v.fallback,C?(v=l.mode,C=l.child,W={mode:"hidden",children:W},(v&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=W):C=yu(W,v,0,null),a=xa(a,v,f,null),C.return=l,a.return=l,C.sibling=a,l.child=C,l.child.memoizedState=tf(f),l.memoizedState=ef,a):nf(l,W));if(_=a.memoizedState,_!==null&&(Q=_.dehydrated,Q!==null))return h1(a,l,W,v,Q,_,f);if(C){C=v.fallback,W=l.mode,_=a.child,Q=_.sibling;var ae={mode:"hidden",children:v.children};return(W&1)===0&&l.child!==_?(v=l.child,v.childLanes=0,v.pendingProps=ae,l.deletions=null):(v=Rr(_,ae),v.subtreeFlags=_.subtreeFlags&14680064),Q!==null?C=Rr(Q,C):(C=xa(C,W,f,null),C.flags|=2),C.return=l,v.return=l,v.sibling=C,l.child=v,v=C,C=l.child,W=a.child.memoizedState,W=W===null?tf(f):{baseLanes:W.baseLanes|f,cachePool:null,transitions:W.transitions},C.memoizedState=W,C.childLanes=a.childLanes&~f,l.memoizedState=ef,v}return C=a.child,a=C.sibling,v=Rr(C,{mode:"visible",children:v.children}),(l.mode&1)===0&&(v.lanes=f),v.return=l,v.sibling=null,a!==null&&(f=l.deletions,f===null?(l.deletions=[a],l.flags|=16):f.push(a)),l.child=v,l.memoizedState=null,v}function nf(a,l){return l=yu({mode:"visible",children:l},a.mode,0,null),l.return=a,a.child=l}function au(a,l,f,v){return v!==null&&Ah(v),io(l,a.child,null,f),a=nf(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function h1(a,l,f,v,_,C,W){if(f)return l.flags&256?(l.flags&=-257,v=Yh(Error(n(422))),au(a,l,W,v)):l.memoizedState!==null?(l.child=a.child,l.flags|=128,null):(C=v.fallback,_=l.mode,v=yu({mode:"visible",children:v.children},_,0,null),C=xa(C,_,W,null),C.flags|=2,v.return=l,C.return=l,v.sibling=C,l.child=v,(l.mode&1)!==0&&io(l,a.child,null,W),l.child.memoizedState=tf(W),l.memoizedState=ef,C);if((l.mode&1)===0)return au(a,l,W,null);if(_.data==="$!"){if(v=_.nextSibling&&_.nextSibling.dataset,v)var Q=v.dgst;return v=Q,C=Error(n(419)),v=Yh(C,v,void 0),au(a,l,W,v)}if(Q=(W&a.childLanes)!==0,gs||Q){if(v=$n,v!==null){switch(W&-W){case 4:_=2;break;case 16:_=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:_=32;break;case 536870912:_=268435456;break;default:_=0}_=(_&(v.suspendedLanes|W))!==0?0:_,_!==0&&_!==C.retryLane&&(C.retryLane=_,sr(a,_),gi(v,a,_,-1))}return yf(),v=Yh(Error(n(421))),au(a,l,W,v)}return _.data==="$?"?(l.flags|=128,l.child=a.child,l=S1.bind(null,a),_._reactRetry=l,null):(a=C.treeContext,As=jr(_.nextSibling),Cs=l,Gt=!0,hi=null,a!==null&&(Ws[Vs++]=tr,Ws[Vs++]=nr,Ws[Vs++]=la,tr=a.id,nr=a.overflow,la=l),l=nf(l,v.children),l.flags|=4096,l)}function Dv(a,l,f){a.lanes|=l;var v=a.alternate;v!==null&&(v.lanes|=l),Mh(a.return,l,f)}function sf(a,l,f,v,_){var C=a.memoizedState;C===null?a.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:v,tail:f,tailMode:_}:(C.isBackwards=l,C.rendering=null,C.renderingStartTime=0,C.last=v,C.tail=f,C.tailMode=_)}function Fv(a,l,f){var v=l.pendingProps,_=v.revealOrder,C=v.tail;if(ts(a,l,v.children,f),v=en.current,(v&2)!==0)v=v&1|2,l.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=l.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&Dv(a,f,l);else if(a.tag===19)Dv(a,f,l);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===l)break e;for(;a.sibling===null;){if(a.return===null||a.return===l)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}v&=1}if(Dt(en,v),(l.mode&1)===0)l.memoizedState=null;else switch(_){case"forwards":for(f=l.child,_=null;f!==null;)a=f.alternate,a!==null&&Jc(a)===null&&(_=f),f=f.sibling;f=_,f===null?(_=l.child,l.child=null):(_=f.sibling,f.sibling=null),sf(l,!1,_,f,C);break;case"backwards":for(f=null,_=l.child,l.child=null;_!==null;){if(a=_.alternate,a!==null&&Jc(a)===null){l.child=_;break}a=_.sibling,_.sibling=f,f=_,_=a}sf(l,!0,f,null,C);break;case"together":sf(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function ou(a,l){(l.mode&1)===0&&a!==null&&(a.alternate=null,l.alternate=null,l.flags|=2)}function rr(a,l,f){if(a!==null&&(l.dependencies=a.dependencies),fa|=l.lanes,(f&l.childLanes)===0)return null;if(a!==null&&l.child!==a.child)throw Error(n(153));if(l.child!==null){for(a=l.child,f=Rr(a,a.pendingProps),l.child=f,f.return=l;a.sibling!==null;)a=a.sibling,f=f.sibling=Rr(a,a.pendingProps),f.return=l;f.sibling=null}return l.child}function f1(a,l,f){switch(l.tag){case 3:Pv(l),so();break;case 5:ev(l);break;case 1:ps(l.type)&&Hc(l);break;case 4:Ph(l,l.stateNode.containerInfo);break;case 10:var v=l.type._context,_=l.memoizedProps.value;Dt(Kc,v._currentValue),v._currentValue=_;break;case 13:if(v=l.memoizedState,v!==null)return v.dehydrated!==null?(Dt(en,en.current&1),l.flags|=128,null):(f&l.child.childLanes)!==0?Lv(a,l,f):(Dt(en,en.current&1),a=rr(a,l,f),a!==null?a.sibling:null);Dt(en,en.current&1);break;case 19:if(v=(f&l.childLanes)!==0,(a.flags&128)!==0){if(v)return Fv(a,l,f);l.flags|=128}if(_=l.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),Dt(en,en.current),v)break;return null;case 22:case 23:return l.lanes=0,Mv(a,l,f)}return rr(a,l,f)}var Uv,rf,Bv,Hv;Uv=function(a,l){for(var f=l.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===l)break;for(;f.sibling===null;){if(f.return===null||f.return===l)return;f=f.return}f.sibling.return=f.return,f=f.sibling}},rf=function(){},Bv=function(a,l,f,v){var _=a.memoizedProps;if(_!==v){a=l.stateNode,da(Oi.current);var C=null;switch(f){case"input":_=xe(a,_),v=xe(a,v),C=[];break;case"select":_=G({},_,{value:void 0}),v=G({},v,{value:void 0}),C=[];break;case"textarea":_=zn(a,_),v=zn(a,v),C=[];break;default:typeof _.onClick!="function"&&typeof v.onClick=="function"&&(a.onclick=Fc)}Ls(f,v);var W;f=null;for(ge in _)if(!v.hasOwnProperty(ge)&&_.hasOwnProperty(ge)&&_[ge]!=null)if(ge==="style"){var Q=_[ge];for(W in Q)Q.hasOwnProperty(W)&&(f||(f={}),f[W]="")}else ge!=="dangerouslySetInnerHTML"&&ge!=="children"&&ge!=="suppressContentEditableWarning"&&ge!=="suppressHydrationWarning"&&ge!=="autoFocus"&&(r.hasOwnProperty(ge)?C||(C=[]):(C=C||[]).push(ge,null));for(ge in v){var ae=v[ge];if(Q=_!=null?_[ge]:void 0,v.hasOwnProperty(ge)&&ae!==Q&&(ae!=null||Q!=null))if(ge==="style")if(Q){for(W in Q)!Q.hasOwnProperty(W)||ae&&ae.hasOwnProperty(W)||(f||(f={}),f[W]="");for(W in ae)ae.hasOwnProperty(W)&&Q[W]!==ae[W]&&(f||(f={}),f[W]=ae[W])}else f||(C||(C=[]),C.push(ge,f)),f=ae;else ge==="dangerouslySetInnerHTML"?(ae=ae?ae.__html:void 0,Q=Q?Q.__html:void 0,ae!=null&&Q!==ae&&(C=C||[]).push(ge,ae)):ge==="children"?typeof ae!="string"&&typeof ae!="number"||(C=C||[]).push(ge,""+ae):ge!=="suppressContentEditableWarning"&&ge!=="suppressHydrationWarning"&&(r.hasOwnProperty(ge)?(ae!=null&&ge==="onScroll"&&Bt("scroll",a),C||Q===ae||(C=[])):(C=C||[]).push(ge,ae))}f&&(C=C||[]).push("style",f);var ge=C;(l.updateQueue=ge)&&(l.flags|=4)}},Hv=function(a,l,f,v){f!==v&&(l.flags|=4)};function vl(a,l){if(!Gt)switch(a.tailMode){case"hidden":l=a.tail;for(var f=null;l!==null;)l.alternate!==null&&(f=l),l=l.sibling;f===null?a.tail=null:f.sibling=null;break;case"collapsed":f=a.tail;for(var v=null;f!==null;)f.alternate!==null&&(v=f),f=f.sibling;v===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:v.sibling=null}}function Gn(a){var l=a.alternate!==null&&a.alternate.child===a.child,f=0,v=0;if(l)for(var _=a.child;_!==null;)f|=_.lanes|_.childLanes,v|=_.subtreeFlags&14680064,v|=_.flags&14680064,_.return=a,_=_.sibling;else for(_=a.child;_!==null;)f|=_.lanes|_.childLanes,v|=_.subtreeFlags,v|=_.flags,_.return=a,_=_.sibling;return a.subtreeFlags|=v,a.childLanes=f,l}function m1(a,l,f){var v=l.pendingProps;switch(_h(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gn(l),null;case 1:return ps(l.type)&&Bc(),Gn(l),null;case 3:return v=l.stateNode,oo(),Ht(ms),Ht(Vn),Dh(),v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),(a===null||a.child===null)&&(qc(l)?l.flags|=4:a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,hi!==null&&(gf(hi),hi=null))),rf(a,l),Gn(l),null;case 5:zh(l);var _=da(fl.current);if(f=l.type,a!==null&&l.stateNode!=null)Bv(a,l,f,v,_),a.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!v){if(l.stateNode===null)throw Error(n(166));return Gn(l),null}if(a=da(Oi.current),qc(l)){v=l.stateNode,f=l.type;var C=l.memoizedProps;switch(v[Ri]=l,v[ll]=C,a=(l.mode&1)!==0,f){case"dialog":Bt("cancel",v),Bt("close",v);break;case"iframe":case"object":case"embed":Bt("load",v);break;case"video":case"audio":for(_=0;_<rl.length;_++)Bt(rl[_],v);break;case"source":Bt("error",v);break;case"img":case"image":case"link":Bt("error",v),Bt("load",v);break;case"details":Bt("toggle",v);break;case"input":De(v,C),Bt("invalid",v);break;case"select":v._wrapperState={wasMultiple:!!C.multiple},Bt("invalid",v);break;case"textarea":rn(v,C),Bt("invalid",v)}Ls(f,C),_=null;for(var W in C)if(C.hasOwnProperty(W)){var Q=C[W];W==="children"?typeof Q=="string"?v.textContent!==Q&&(C.suppressHydrationWarning!==!0&&Dc(v.textContent,Q,a),_=["children",Q]):typeof Q=="number"&&v.textContent!==""+Q&&(C.suppressHydrationWarning!==!0&&Dc(v.textContent,Q,a),_=["children",""+Q]):r.hasOwnProperty(W)&&Q!=null&&W==="onScroll"&&Bt("scroll",v)}switch(f){case"input":fe(v),Te(v,C,!0);break;case"textarea":fe(v),un(v);break;case"select":case"option":break;default:typeof C.onClick=="function"&&(v.onclick=Fc)}v=_,l.updateQueue=v,v!==null&&(l.flags|=4)}else{W=_.nodeType===9?_:_.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=an(f)),a==="http://www.w3.org/1999/xhtml"?f==="script"?(a=W.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof v.is=="string"?a=W.createElement(f,{is:v.is}):(a=W.createElement(f),f==="select"&&(W=a,v.multiple?W.multiple=!0:v.size&&(W.size=v.size))):a=W.createElementNS(a,f),a[Ri]=l,a[ll]=v,Uv(a,l,!1,!1),l.stateNode=a;e:{switch(W=Ds(f,v),f){case"dialog":Bt("cancel",a),Bt("close",a),_=v;break;case"iframe":case"object":case"embed":Bt("load",a),_=v;break;case"video":case"audio":for(_=0;_<rl.length;_++)Bt(rl[_],a);_=v;break;case"source":Bt("error",a),_=v;break;case"img":case"image":case"link":Bt("error",a),Bt("load",a),_=v;break;case"details":Bt("toggle",a),_=v;break;case"input":De(a,v),_=xe(a,v),Bt("invalid",a);break;case"option":_=v;break;case"select":a._wrapperState={wasMultiple:!!v.multiple},_=G({},v,{value:void 0}),Bt("invalid",a);break;case"textarea":rn(a,v),_=zn(a,v),Bt("invalid",a);break;default:_=v}Ls(f,_),Q=_;for(C in Q)if(Q.hasOwnProperty(C)){var ae=Q[C];C==="style"?si(a,ae):C==="dangerouslySetInnerHTML"?(ae=ae?ae.__html:void 0,ae!=null&&Bn(a,ae)):C==="children"?typeof ae=="string"?(f!=="textarea"||ae!=="")&&jn(a,ae):typeof ae=="number"&&jn(a,""+ae):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(r.hasOwnProperty(C)?ae!=null&&C==="onScroll"&&Bt("scroll",a):ae!=null&&j(a,C,ae,W))}switch(f){case"input":fe(a),Te(a,v,!1);break;case"textarea":fe(a),un(a);break;case"option":v.value!=null&&a.setAttribute("value",""+ie(v.value));break;case"select":a.multiple=!!v.multiple,C=v.value,C!=null?St(a,!!v.multiple,C,!1):v.defaultValue!=null&&St(a,!!v.multiple,v.defaultValue,!0);break;default:typeof _.onClick=="function"&&(a.onclick=Fc)}switch(f){case"button":case"input":case"select":case"textarea":v=!!v.autoFocus;break e;case"img":v=!0;break e;default:v=!1}}v&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return Gn(l),null;case 6:if(a&&l.stateNode!=null)Hv(a,l,a.memoizedProps,v);else{if(typeof v!="string"&&l.stateNode===null)throw Error(n(166));if(f=da(fl.current),da(Oi.current),qc(l)){if(v=l.stateNode,f=l.memoizedProps,v[Ri]=l,(C=v.nodeValue!==f)&&(a=Cs,a!==null))switch(a.tag){case 3:Dc(v.nodeValue,f,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Dc(v.nodeValue,f,(a.mode&1)!==0)}C&&(l.flags|=4)}else v=(f.nodeType===9?f:f.ownerDocument).createTextNode(v),v[Ri]=l,l.stateNode=v}return Gn(l),null;case 13:if(Ht(en),v=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(Gt&&As!==null&&(l.mode&1)!==0&&(l.flags&128)===0)Vx(),so(),l.flags|=98560,C=!1;else if(C=qc(l),v!==null&&v.dehydrated!==null){if(a===null){if(!C)throw Error(n(318));if(C=l.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(n(317));C[Ri]=l}else so(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Gn(l),C=!1}else hi!==null&&(gf(hi),hi=null),C=!0;if(!C)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=f,l):(v=v!==null,v!==(a!==null&&a.memoizedState!==null)&&v&&(l.child.flags|=8192,(l.mode&1)!==0&&(a===null||(en.current&1)!==0?Cn===0&&(Cn=3):yf())),l.updateQueue!==null&&(l.flags|=4),Gn(l),null);case 4:return oo(),rf(a,l),a===null&&al(l.stateNode.containerInfo),Gn(l),null;case 10:return $h(l.type._context),Gn(l),null;case 17:return ps(l.type)&&Bc(),Gn(l),null;case 19:if(Ht(en),C=l.memoizedState,C===null)return Gn(l),null;if(v=(l.flags&128)!==0,W=C.rendering,W===null)if(v)vl(C,!1);else{if(Cn!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(W=Jc(a),W!==null){for(l.flags|=128,vl(C,!1),v=W.updateQueue,v!==null&&(l.updateQueue=v,l.flags|=4),l.subtreeFlags=0,v=f,f=l.child;f!==null;)C=f,a=v,C.flags&=14680066,W=C.alternate,W===null?(C.childLanes=0,C.lanes=a,C.child=null,C.subtreeFlags=0,C.memoizedProps=null,C.memoizedState=null,C.updateQueue=null,C.dependencies=null,C.stateNode=null):(C.childLanes=W.childLanes,C.lanes=W.lanes,C.child=W.child,C.subtreeFlags=0,C.deletions=null,C.memoizedProps=W.memoizedProps,C.memoizedState=W.memoizedState,C.updateQueue=W.updateQueue,C.type=W.type,a=W.dependencies,C.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),f=f.sibling;return Dt(en,en.current&1|2),l.child}a=a.sibling}C.tail!==null&&Ot()>ho&&(l.flags|=128,v=!0,vl(C,!1),l.lanes=4194304)}else{if(!v)if(a=Jc(W),a!==null){if(l.flags|=128,v=!0,f=a.updateQueue,f!==null&&(l.updateQueue=f,l.flags|=4),vl(C,!0),C.tail===null&&C.tailMode==="hidden"&&!W.alternate&&!Gt)return Gn(l),null}else 2*Ot()-C.renderingStartTime>ho&&f!==1073741824&&(l.flags|=128,v=!0,vl(C,!1),l.lanes=4194304);C.isBackwards?(W.sibling=l.child,l.child=W):(f=C.last,f!==null?f.sibling=W:l.child=W,C.last=W)}return C.tail!==null?(l=C.tail,C.rendering=l,C.tail=l.sibling,C.renderingStartTime=Ot(),l.sibling=null,f=en.current,Dt(en,v?f&1|2:f&1),l):(Gn(l),null);case 22:case 23:return vf(),v=l.memoizedState!==null,a!==null&&a.memoizedState!==null!==v&&(l.flags|=8192),v&&(l.mode&1)!==0?(Is&1073741824)!==0&&(Gn(l),l.subtreeFlags&6&&(l.flags|=8192)):Gn(l),null;case 24:return null;case 25:return null}throw Error(n(156,l.tag))}function p1(a,l){switch(_h(l),l.tag){case 1:return ps(l.type)&&Bc(),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return oo(),Ht(ms),Ht(Vn),Dh(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 5:return zh(l),null;case 13:if(Ht(en),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(n(340));so()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return Ht(en),null;case 4:return oo(),null;case 10:return $h(l.type._context),null;case 22:case 23:return vf(),null;case 24:return null;default:return null}}var lu=!1,Kn=!1,g1=typeof WeakSet=="function"?WeakSet:Set,We=null;function co(a,l){var f=a.ref;if(f!==null)if(typeof f=="function")try{f(null)}catch(v){ln(a,l,v)}else f.current=null}function af(a,l,f){try{f()}catch(v){ln(a,l,v)}}var Zv=!1;function x1(a,l){if(xh=nt,a=Nx(),ch(a)){if("selectionStart"in a)var f={start:a.selectionStart,end:a.selectionEnd};else e:{f=(f=a.ownerDocument)&&f.defaultView||window;var v=f.getSelection&&f.getSelection();if(v&&v.rangeCount!==0){f=v.anchorNode;var _=v.anchorOffset,C=v.focusNode;v=v.focusOffset;try{f.nodeType,C.nodeType}catch{f=null;break e}var W=0,Q=-1,ae=-1,ge=0,Ee=0,Ae=a,_e=null;t:for(;;){for(var He;Ae!==f||_!==0&&Ae.nodeType!==3||(Q=W+_),Ae!==C||v!==0&&Ae.nodeType!==3||(ae=W+v),Ae.nodeType===3&&(W+=Ae.nodeValue.length),(He=Ae.firstChild)!==null;)_e=Ae,Ae=He;for(;;){if(Ae===a)break t;if(_e===f&&++ge===_&&(Q=W),_e===C&&++Ee===v&&(ae=W),(He=Ae.nextSibling)!==null)break;Ae=_e,_e=Ae.parentNode}Ae=He}f=Q===-1||ae===-1?null:{start:Q,end:ae}}else f=null}f=f||{start:0,end:0}}else f=null;for(vh={focusedElem:a,selectionRange:f},nt=!1,We=l;We!==null;)if(l=We,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,We=a;else for(;We!==null;){l=We;try{var Ve=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Ve!==null){var Ke=Ve.memoizedProps,fn=Ve.memoizedState,he=l.stateNode,ce=he.getSnapshotBeforeUpdate(l.elementType===l.type?Ke:fi(l.type,Ke),fn);he.__reactInternalSnapshotBeforeUpdate=ce}break;case 3:var me=l.stateNode.containerInfo;me.nodeType===1?me.textContent="":me.nodeType===9&&me.documentElement&&me.removeChild(me.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Oe){ln(l,l.return,Oe)}if(a=l.sibling,a!==null){a.return=l.return,We=a;break}We=l.return}return Ve=Zv,Zv=!1,Ve}function yl(a,l,f){var v=l.updateQueue;if(v=v!==null?v.lastEffect:null,v!==null){var _=v=v.next;do{if((_.tag&a)===a){var C=_.destroy;_.destroy=void 0,C!==void 0&&af(l,f,C)}_=_.next}while(_!==v)}}function cu(a,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&a)===a){var v=f.create;f.destroy=v()}f=f.next}while(f!==l)}}function of(a){var l=a.ref;if(l!==null){var f=a.stateNode;switch(a.tag){case 5:a=f;break;default:a=f}typeof l=="function"?l(a):l.current=a}}function Wv(a){var l=a.alternate;l!==null&&(a.alternate=null,Wv(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&(delete l[Ri],delete l[ll],delete l[Nh],delete l[JE],delete l[e1])),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 Vv(a){return a.tag===5||a.tag===3||a.tag===4}function qv(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||Vv(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 lf(a,l,f){var v=a.tag;if(v===5||v===6)a=a.stateNode,l?f.nodeType===8?f.parentNode.insertBefore(a,l):f.insertBefore(a,l):(f.nodeType===8?(l=f.parentNode,l.insertBefore(a,f)):(l=f,l.appendChild(a)),f=f._reactRootContainer,f!=null||l.onclick!==null||(l.onclick=Fc));else if(v!==4&&(a=a.child,a!==null))for(lf(a,l,f),a=a.sibling;a!==null;)lf(a,l,f),a=a.sibling}function cf(a,l,f){var v=a.tag;if(v===5||v===6)a=a.stateNode,l?f.insertBefore(a,l):f.appendChild(a);else if(v!==4&&(a=a.child,a!==null))for(cf(a,l,f),a=a.sibling;a!==null;)cf(a,l,f),a=a.sibling}var Ln=null,mi=!1;function Ar(a,l,f){for(f=f.child;f!==null;)Gv(a,l,f),f=f.sibling}function Gv(a,l,f){if(ht&&typeof ht.onCommitFiberUnmount=="function")try{ht.onCommitFiberUnmount(ct,f)}catch{}switch(f.tag){case 5:Kn||co(f,l);case 6:var v=Ln,_=mi;Ln=null,Ar(a,l,f),Ln=v,mi=_,Ln!==null&&(mi?(a=Ln,f=f.stateNode,a.nodeType===8?a.parentNode.removeChild(f):a.removeChild(f)):Ln.removeChild(f.stateNode));break;case 18:Ln!==null&&(mi?(a=Ln,f=f.stateNode,a.nodeType===8?kh(a.parentNode,f):a.nodeType===1&&kh(a,f),je(a)):kh(Ln,f.stateNode));break;case 4:v=Ln,_=mi,Ln=f.stateNode.containerInfo,mi=!0,Ar(a,l,f),Ln=v,mi=_;break;case 0:case 11:case 14:case 15:if(!Kn&&(v=f.updateQueue,v!==null&&(v=v.lastEffect,v!==null))){_=v=v.next;do{var C=_,W=C.destroy;C=C.tag,W!==void 0&&((C&2)!==0||(C&4)!==0)&&af(f,l,W),_=_.next}while(_!==v)}Ar(a,l,f);break;case 1:if(!Kn&&(co(f,l),v=f.stateNode,typeof v.componentWillUnmount=="function"))try{v.props=f.memoizedProps,v.state=f.memoizedState,v.componentWillUnmount()}catch(Q){ln(f,l,Q)}Ar(a,l,f);break;case 21:Ar(a,l,f);break;case 22:f.mode&1?(Kn=(v=Kn)||f.memoizedState!==null,Ar(a,l,f),Kn=v):Ar(a,l,f);break;default:Ar(a,l,f)}}function Kv(a){var l=a.updateQueue;if(l!==null){a.updateQueue=null;var f=a.stateNode;f===null&&(f=a.stateNode=new g1),l.forEach(function(v){var _=_1.bind(null,a,v);f.has(v)||(f.add(v),v.then(_,_))})}}function pi(a,l){var f=l.deletions;if(f!==null)for(var v=0;v<f.length;v++){var _=f[v];try{var C=a,W=l,Q=W;e:for(;Q!==null;){switch(Q.tag){case 5:Ln=Q.stateNode,mi=!1;break e;case 3:Ln=Q.stateNode.containerInfo,mi=!0;break e;case 4:Ln=Q.stateNode.containerInfo,mi=!0;break e}Q=Q.return}if(Ln===null)throw Error(n(160));Gv(C,W,_),Ln=null,mi=!1;var ae=_.alternate;ae!==null&&(ae.return=null),_.return=null}catch(ge){ln(_,l,ge)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)Yv(l,a),l=l.sibling}function Yv(a,l){var f=a.alternate,v=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(pi(l,a),zi(a),v&4){try{yl(3,a,a.return),cu(3,a)}catch(Ke){ln(a,a.return,Ke)}try{yl(5,a,a.return)}catch(Ke){ln(a,a.return,Ke)}}break;case 1:pi(l,a),zi(a),v&512&&f!==null&&co(f,f.return);break;case 5:if(pi(l,a),zi(a),v&512&&f!==null&&co(f,f.return),a.flags&32){var _=a.stateNode;try{jn(_,"")}catch(Ke){ln(a,a.return,Ke)}}if(v&4&&(_=a.stateNode,_!=null)){var C=a.memoizedProps,W=f!==null?f.memoizedProps:C,Q=a.type,ae=a.updateQueue;if(a.updateQueue=null,ae!==null)try{Q==="input"&&C.type==="radio"&&C.name!=null&&Me(_,C),Ds(Q,W);var ge=Ds(Q,C);for(W=0;W<ae.length;W+=2){var Ee=ae[W],Ae=ae[W+1];Ee==="style"?si(_,Ae):Ee==="dangerouslySetInnerHTML"?Bn(_,Ae):Ee==="children"?jn(_,Ae):j(_,Ee,Ae,ge)}switch(Q){case"input":Ge(_,C);break;case"textarea":cn(_,C);break;case"select":var _e=_._wrapperState.wasMultiple;_._wrapperState.wasMultiple=!!C.multiple;var He=C.value;He!=null?St(_,!!C.multiple,He,!1):_e!==!!C.multiple&&(C.defaultValue!=null?St(_,!!C.multiple,C.defaultValue,!0):St(_,!!C.multiple,C.multiple?[]:"",!1))}_[ll]=C}catch(Ke){ln(a,a.return,Ke)}}break;case 6:if(pi(l,a),zi(a),v&4){if(a.stateNode===null)throw Error(n(162));_=a.stateNode,C=a.memoizedProps;try{_.nodeValue=C}catch(Ke){ln(a,a.return,Ke)}}break;case 3:if(pi(l,a),zi(a),v&4&&f!==null&&f.memoizedState.isDehydrated)try{je(l.containerInfo)}catch(Ke){ln(a,a.return,Ke)}break;case 4:pi(l,a),zi(a);break;case 13:pi(l,a),zi(a),_=a.child,_.flags&8192&&(C=_.memoizedState!==null,_.stateNode.isHidden=C,!C||_.alternate!==null&&_.alternate.memoizedState!==null||(hf=Ot())),v&4&&Kv(a);break;case 22:if(Ee=f!==null&&f.memoizedState!==null,a.mode&1?(Kn=(ge=Kn)||Ee,pi(l,a),Kn=ge):pi(l,a),zi(a),v&8192){if(ge=a.memoizedState!==null,(a.stateNode.isHidden=ge)&&!Ee&&(a.mode&1)!==0)for(We=a,Ee=a.child;Ee!==null;){for(Ae=We=Ee;We!==null;){switch(_e=We,He=_e.child,_e.tag){case 0:case 11:case 14:case 15:yl(4,_e,_e.return);break;case 1:co(_e,_e.return);var Ve=_e.stateNode;if(typeof Ve.componentWillUnmount=="function"){v=_e,f=_e.return;try{l=v,Ve.props=l.memoizedProps,Ve.state=l.memoizedState,Ve.componentWillUnmount()}catch(Ke){ln(v,f,Ke)}}break;case 5:co(_e,_e.return);break;case 22:if(_e.memoizedState!==null){Jv(Ae);continue}}He!==null?(He.return=_e,We=He):Jv(Ae)}Ee=Ee.sibling}e:for(Ee=null,Ae=a;;){if(Ae.tag===5){if(Ee===null){Ee=Ae;try{_=Ae.stateNode,ge?(C=_.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none"):(Q=Ae.stateNode,ae=Ae.memoizedProps.style,W=ae!=null&&ae.hasOwnProperty("display")?ae.display:null,Q.style.display=ni("display",W))}catch(Ke){ln(a,a.return,Ke)}}}else if(Ae.tag===6){if(Ee===null)try{Ae.stateNode.nodeValue=ge?"":Ae.memoizedProps}catch(Ke){ln(a,a.return,Ke)}}else if((Ae.tag!==22&&Ae.tag!==23||Ae.memoizedState===null||Ae===a)&&Ae.child!==null){Ae.child.return=Ae,Ae=Ae.child;continue}if(Ae===a)break e;for(;Ae.sibling===null;){if(Ae.return===null||Ae.return===a)break e;Ee===Ae&&(Ee=null),Ae=Ae.return}Ee===Ae&&(Ee=null),Ae.sibling.return=Ae.return,Ae=Ae.sibling}}break;case 19:pi(l,a),zi(a),v&4&&Kv(a);break;case 21:break;default:pi(l,a),zi(a)}}function zi(a){var l=a.flags;if(l&2){try{e:{for(var f=a.return;f!==null;){if(Vv(f)){var v=f;break e}f=f.return}throw Error(n(160))}switch(v.tag){case 5:var _=v.stateNode;v.flags&32&&(jn(_,""),v.flags&=-33);var C=qv(a);cf(a,C,_);break;case 3:case 4:var W=v.stateNode.containerInfo,Q=qv(a);lf(a,Q,W);break;default:throw Error(n(161))}}catch(ae){ln(a,a.return,ae)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function v1(a,l,f){We=a,Xv(a)}function Xv(a,l,f){for(var v=(a.mode&1)!==0;We!==null;){var _=We,C=_.child;if(_.tag===22&&v){var W=_.memoizedState!==null||lu;if(!W){var Q=_.alternate,ae=Q!==null&&Q.memoizedState!==null||Kn;Q=lu;var ge=Kn;if(lu=W,(Kn=ae)&&!ge)for(We=_;We!==null;)W=We,ae=W.child,W.tag===22&&W.memoizedState!==null?e0(_):ae!==null?(ae.return=W,We=ae):e0(_);for(;C!==null;)We=C,Xv(C),C=C.sibling;We=_,lu=Q,Kn=ge}Qv(a)}else(_.subtreeFlags&8772)!==0&&C!==null?(C.return=_,We=C):Qv(a)}}function Qv(a){for(;We!==null;){var l=We;if((l.flags&8772)!==0){var f=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Kn||cu(5,l);break;case 1:var v=l.stateNode;if(l.flags&4&&!Kn)if(f===null)v.componentDidMount();else{var _=l.elementType===l.type?f.memoizedProps:fi(l.type,f.memoizedProps);v.componentDidUpdate(_,f.memoizedState,v.__reactInternalSnapshotBeforeUpdate)}var C=l.updateQueue;C!==null&&Jx(l,C,v);break;case 3:var W=l.updateQueue;if(W!==null){if(f=null,l.child!==null)switch(l.child.tag){case 5:f=l.child.stateNode;break;case 1:f=l.child.stateNode}Jx(l,W,f)}break;case 5:var Q=l.stateNode;if(f===null&&l.flags&4){f=Q;var ae=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":ae.autoFocus&&f.focus();break;case"img":ae.src&&(f.src=ae.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ge=l.alternate;if(ge!==null){var Ee=ge.memoizedState;if(Ee!==null){var Ae=Ee.dehydrated;Ae!==null&&je(Ae)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Kn||l.flags&512&&of(l)}catch(_e){ln(l,l.return,_e)}}if(l===a){We=null;break}if(f=l.sibling,f!==null){f.return=l.return,We=f;break}We=l.return}}function Jv(a){for(;We!==null;){var l=We;if(l===a){We=null;break}var f=l.sibling;if(f!==null){f.return=l.return,We=f;break}We=l.return}}function e0(a){for(;We!==null;){var l=We;try{switch(l.tag){case 0:case 11:case 15:var f=l.return;try{cu(4,l)}catch(ae){ln(l,f,ae)}break;case 1:var v=l.stateNode;if(typeof v.componentDidMount=="function"){var _=l.return;try{v.componentDidMount()}catch(ae){ln(l,_,ae)}}var C=l.return;try{of(l)}catch(ae){ln(l,C,ae)}break;case 5:var W=l.return;try{of(l)}catch(ae){ln(l,W,ae)}}}catch(ae){ln(l,l.return,ae)}if(l===a){We=null;break}var Q=l.sibling;if(Q!==null){Q.return=l.return,We=Q;break}We=l.return}}var y1=Math.ceil,uu=A.ReactCurrentDispatcher,uf=A.ReactCurrentOwner,Ks=A.ReactCurrentBatchConfig,kt=0,$n=null,xn=null,Dn=0,Is=0,uo=wr(0),Cn=0,bl=null,fa=0,du=0,df=0,kl=null,xs=null,hf=0,ho=1/0,ar=null,hu=!1,ff=null,Ir=null,fu=!1,Tr=null,mu=0,Nl=0,mf=null,pu=-1,gu=0;function ns(){return(kt&6)!==0?Ot():pu!==-1?pu:pu=Ot()}function $r(a){return(a.mode&1)===0?1:(kt&2)!==0&&Dn!==0?Dn&-Dn:n1.transition!==null?(gu===0&&(gu=kr()),gu):(a=vt,a!==0||(a=window.event,a=a===void 0?16:Qi(a.type)),a)}function gi(a,l,f,v){if(50<Nl)throw Nl=0,mf=null,Error(n(185));ds(a,f,v),((kt&2)===0||a!==$n)&&(a===$n&&((kt&2)===0&&(du|=f),Cn===4&&Mr(a,Dn)),vs(a,v),f===1&&kt===0&&(l.mode&1)===0&&(ho=Ot()+500,Zc&&_r()))}function vs(a,l){var f=a.callbackNode;br(a,l);var v=us(a,a===$n?Dn:0);if(v===0)f!==null&&Qn(f),a.callbackNode=null,a.callbackPriority=0;else if(l=v&-v,a.callbackPriority!==l){if(f!=null&&Qn(f),l===1)a.tag===0?t1(n0.bind(null,a)):Ux(n0.bind(null,a)),XE(function(){(kt&6)===0&&_r()}),f=null;else{switch(at(v)){case 1:f=Gi;break;case 4:f=ci;break;case 16:f=$i;break;case 536870912:f=Ze;break;default:f=$i}f=u0(f,t0.bind(null,a))}a.callbackPriority=l,a.callbackNode=f}}function t0(a,l){if(pu=-1,gu=0,(kt&6)!==0)throw Error(n(327));var f=a.callbackNode;if(fo()&&a.callbackNode!==f)return null;var v=us(a,a===$n?Dn:0);if(v===0)return null;if((v&30)!==0||(v&a.expiredLanes)!==0||l)l=xu(a,v);else{l=v;var _=kt;kt|=2;var C=i0();($n!==a||Dn!==l)&&(ar=null,ho=Ot()+500,pa(a,l));do try{N1();break}catch(Q){s0(a,Q)}while(!0);Th(),uu.current=C,kt=_,xn!==null?l=0:($n=null,Dn=0,l=Cn)}if(l!==0){if(l===2&&(_=Mi(a),_!==0&&(v=_,l=pf(a,_))),l===1)throw f=bl,pa(a,0),Mr(a,v),vs(a,Ot()),f;if(l===6)Mr(a,v);else{if(_=a.current.alternate,(v&30)===0&&!b1(_)&&(l=xu(a,v),l===2&&(C=Mi(a),C!==0&&(v=C,l=pf(a,C))),l===1))throw f=bl,pa(a,0),Mr(a,v),vs(a,Ot()),f;switch(a.finishedWork=_,a.finishedLanes=v,l){case 0:case 1:throw Error(n(345));case 2:ga(a,xs,ar);break;case 3:if(Mr(a,v),(v&130023424)===v&&(l=hf+500-Ot(),10<l)){if(us(a,0)!==0)break;if(_=a.suspendedLanes,(_&v)!==v){ns(),a.pingedLanes|=a.suspendedLanes&_;break}a.timeoutHandle=bh(ga.bind(null,a,xs,ar),l);break}ga(a,xs,ar);break;case 4:if(Mr(a,v),(v&4194240)===v)break;for(l=a.eventTimes,_=-1;0<v;){var W=31-Pt(v);C=1<<W,W=l[W],W>_&&(_=W),v&=~C}if(v=_,v=Ot()-v,v=(120>v?120:480>v?480:1080>v?1080:1920>v?1920:3e3>v?3e3:4320>v?4320:1960*y1(v/1960))-v,10<v){a.timeoutHandle=bh(ga.bind(null,a,xs,ar),v);break}ga(a,xs,ar);break;case 5:ga(a,xs,ar);break;default:throw Error(n(329))}}}return vs(a,Ot()),a.callbackNode===f?t0.bind(null,a):null}function pf(a,l){var f=kl;return a.current.memoizedState.isDehydrated&&(pa(a,l).flags|=256),a=xu(a,l),a!==2&&(l=xs,xs=f,l!==null&&gf(l)),a}function gf(a){xs===null?xs=a:xs.push.apply(xs,a)}function b1(a){for(var l=a;;){if(l.flags&16384){var f=l.updateQueue;if(f!==null&&(f=f.stores,f!==null))for(var v=0;v<f.length;v++){var _=f[v],C=_.getSnapshot;_=_.value;try{if(!di(C(),_))return!1}catch{return!1}}}if(f=l.child,l.subtreeFlags&16384&&f!==null)f.return=l,l=f;else{if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Mr(a,l){for(l&=~df,l&=~du,a.suspendedLanes|=l,a.pingedLanes&=~l,a=a.expirationTimes;0<l;){var f=31-Pt(l),v=1<<f;a[f]=-1,l&=~v}}function n0(a){if((kt&6)!==0)throw Error(n(327));fo();var l=us(a,0);if((l&1)===0)return vs(a,Ot()),null;var f=xu(a,l);if(a.tag!==0&&f===2){var v=Mi(a);v!==0&&(l=v,f=pf(a,v))}if(f===1)throw f=bl,pa(a,0),Mr(a,l),vs(a,Ot()),f;if(f===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=l,ga(a,xs,ar),vs(a,Ot()),null}function xf(a,l){var f=kt;kt|=1;try{return a(l)}finally{kt=f,kt===0&&(ho=Ot()+500,Zc&&_r())}}function ma(a){Tr!==null&&Tr.tag===0&&(kt&6)===0&&fo();var l=kt;kt|=1;var f=Ks.transition,v=vt;try{if(Ks.transition=null,vt=1,a)return a()}finally{vt=v,Ks.transition=f,kt=l,(kt&6)===0&&_r()}}function vf(){Is=uo.current,Ht(uo)}function pa(a,l){a.finishedWork=null,a.finishedLanes=0;var f=a.timeoutHandle;if(f!==-1&&(a.timeoutHandle=-1,YE(f)),xn!==null)for(f=xn.return;f!==null;){var v=f;switch(_h(v),v.tag){case 1:v=v.type.childContextTypes,v!=null&&Bc();break;case 3:oo(),Ht(ms),Ht(Vn),Dh();break;case 5:zh(v);break;case 4:oo();break;case 13:Ht(en);break;case 19:Ht(en);break;case 10:$h(v.type._context);break;case 22:case 23:vf()}f=f.return}if($n=a,xn=a=Rr(a.current,null),Dn=Is=l,Cn=0,bl=null,df=du=fa=0,xs=kl=null,ua!==null){for(l=0;l<ua.length;l++)if(f=ua[l],v=f.interleaved,v!==null){f.interleaved=null;var _=v.next,C=f.pending;if(C!==null){var W=C.next;C.next=_,v.next=W}f.pending=v}ua=null}return a}function s0(a,l){do{var f=xn;try{if(Th(),eu.current=iu,tu){for(var v=tn.memoizedState;v!==null;){var _=v.queue;_!==null&&(_.pending=null),v=v.next}tu=!1}if(ha=0,Tn=En=tn=null,ml=!1,pl=0,uf.current=null,f===null||f.return===null){Cn=1,bl=l,xn=null;break}e:{var C=a,W=f.return,Q=f,ae=l;if(l=Dn,Q.flags|=32768,ae!==null&&typeof ae=="object"&&typeof ae.then=="function"){var ge=ae,Ee=Q,Ae=Ee.tag;if((Ee.mode&1)===0&&(Ae===0||Ae===11||Ae===15)){var _e=Ee.alternate;_e?(Ee.updateQueue=_e.updateQueue,Ee.memoizedState=_e.memoizedState,Ee.lanes=_e.lanes):(Ee.updateQueue=null,Ee.memoizedState=null)}var He=Cv(W);if(He!==null){He.flags&=-257,Av(He,W,Q,C,l),He.mode&1&&Ev(C,ge,l),l=He,ae=ge;var Ve=l.updateQueue;if(Ve===null){var Ke=new Set;Ke.add(ae),l.updateQueue=Ke}else Ve.add(ae);break e}else{if((l&1)===0){Ev(C,ge,l),yf();break e}ae=Error(n(426))}}else if(Gt&&Q.mode&1){var fn=Cv(W);if(fn!==null){(fn.flags&65536)===0&&(fn.flags|=256),Av(fn,W,Q,C,l),Ah(lo(ae,Q));break e}}C=ae=lo(ae,Q),Cn!==4&&(Cn=2),kl===null?kl=[C]:kl.push(C),C=W;do{switch(C.tag){case 3:C.flags|=65536,l&=-l,C.lanes|=l;var he=Sv(C,ae,l);Qx(C,he);break e;case 1:Q=ae;var ce=C.type,me=C.stateNode;if((C.flags&128)===0&&(typeof ce.getDerivedStateFromError=="function"||me!==null&&typeof me.componentDidCatch=="function"&&(Ir===null||!Ir.has(me)))){C.flags|=65536,l&=-l,C.lanes|=l;var Oe=_v(C,Q,l);Qx(C,Oe);break e}}C=C.return}while(C!==null)}a0(f)}catch(Ye){l=Ye,xn===f&&f!==null&&(xn=f=f.return);continue}break}while(!0)}function i0(){var a=uu.current;return uu.current=iu,a===null?iu:a}function yf(){(Cn===0||Cn===3||Cn===2)&&(Cn=4),$n===null||(fa&268435455)===0&&(du&268435455)===0||Mr($n,Dn)}function xu(a,l){var f=kt;kt|=2;var v=i0();($n!==a||Dn!==l)&&(ar=null,pa(a,l));do try{k1();break}catch(_){s0(a,_)}while(!0);if(Th(),kt=f,uu.current=v,xn!==null)throw Error(n(261));return $n=null,Dn=0,Cn}function k1(){for(;xn!==null;)r0(xn)}function N1(){for(;xn!==null&&!qi();)r0(xn)}function r0(a){var l=c0(a.alternate,a,Is);a.memoizedProps=a.pendingProps,l===null?a0(a):xn=l,uf.current=null}function a0(a){var l=a;do{var f=l.alternate;if(a=l.return,(l.flags&32768)===0){if(f=m1(f,l,Is),f!==null){xn=f;return}}else{if(f=p1(f,l),f!==null){f.flags&=32767,xn=f;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{Cn=6,xn=null;return}}if(l=l.sibling,l!==null){xn=l;return}xn=l=a}while(l!==null);Cn===0&&(Cn=5)}function ga(a,l,f){var v=vt,_=Ks.transition;try{Ks.transition=null,vt=1,j1(a,l,f,v)}finally{Ks.transition=_,vt=v}return null}function j1(a,l,f,v){do fo();while(Tr!==null);if((kt&6)!==0)throw Error(n(327));f=a.finishedWork;var _=a.finishedLanes;if(f===null)return null;if(a.finishedWork=null,a.finishedLanes=0,f===a.current)throw Error(n(177));a.callbackNode=null,a.callbackPriority=0;var C=f.lanes|f.childLanes;if(_n(a,C),a===$n&&(xn=$n=null,Dn=0),(f.subtreeFlags&2064)===0&&(f.flags&2064)===0||fu||(fu=!0,u0($i,function(){return fo(),null})),C=(f.flags&15990)!==0,(f.subtreeFlags&15990)!==0||C){C=Ks.transition,Ks.transition=null;var W=vt;vt=1;var Q=kt;kt|=4,uf.current=null,x1(a,f),Yv(f,a),HE(vh),nt=!!xh,vh=xh=null,a.current=f,v1(f),li(),kt=Q,vt=W,Ks.transition=C}else a.current=f;if(fu&&(fu=!1,Tr=a,mu=_),C=a.pendingLanes,C===0&&(Ir=null),Tt(f.stateNode),vs(a,Ot()),l!==null)for(v=a.onRecoverableError,f=0;f<l.length;f++)_=l[f],v(_.value,{componentStack:_.stack,digest:_.digest});if(hu)throw hu=!1,a=ff,ff=null,a;return(mu&1)!==0&&a.tag!==0&&fo(),C=a.pendingLanes,(C&1)!==0?a===mf?Nl++:(Nl=0,mf=a):Nl=0,_r(),null}function fo(){if(Tr!==null){var a=at(mu),l=Ks.transition,f=vt;try{if(Ks.transition=null,vt=16>a?16:a,Tr===null)var v=!1;else{if(a=Tr,Tr=null,mu=0,(kt&6)!==0)throw Error(n(331));var _=kt;for(kt|=4,We=a.current;We!==null;){var C=We,W=C.child;if((We.flags&16)!==0){var Q=C.deletions;if(Q!==null){for(var ae=0;ae<Q.length;ae++){var ge=Q[ae];for(We=ge;We!==null;){var Ee=We;switch(Ee.tag){case 0:case 11:case 15:yl(8,Ee,C)}var Ae=Ee.child;if(Ae!==null)Ae.return=Ee,We=Ae;else for(;We!==null;){Ee=We;var _e=Ee.sibling,He=Ee.return;if(Wv(Ee),Ee===ge){We=null;break}if(_e!==null){_e.return=He,We=_e;break}We=He}}}var Ve=C.alternate;if(Ve!==null){var Ke=Ve.child;if(Ke!==null){Ve.child=null;do{var fn=Ke.sibling;Ke.sibling=null,Ke=fn}while(Ke!==null)}}We=C}}if((C.subtreeFlags&2064)!==0&&W!==null)W.return=C,We=W;else e:for(;We!==null;){if(C=We,(C.flags&2048)!==0)switch(C.tag){case 0:case 11:case 15:yl(9,C,C.return)}var he=C.sibling;if(he!==null){he.return=C.return,We=he;break e}We=C.return}}var ce=a.current;for(We=ce;We!==null;){W=We;var me=W.child;if((W.subtreeFlags&2064)!==0&&me!==null)me.return=W,We=me;else e:for(W=ce;We!==null;){if(Q=We,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:cu(9,Q)}}catch(Ye){ln(Q,Q.return,Ye)}if(Q===W){We=null;break e}var Oe=Q.sibling;if(Oe!==null){Oe.return=Q.return,We=Oe;break e}We=Q.return}}if(kt=_,_r(),ht&&typeof ht.onPostCommitFiberRoot=="function")try{ht.onPostCommitFiberRoot(ct,a)}catch{}v=!0}return v}finally{vt=f,Ks.transition=l}}return!1}function o0(a,l,f){l=lo(f,l),l=Sv(a,l,1),a=Cr(a,l,1),l=ns(),a!==null&&(ds(a,1,l),vs(a,l))}function ln(a,l,f){if(a.tag===3)o0(a,a,f);else for(;l!==null;){if(l.tag===3){o0(l,a,f);break}else if(l.tag===1){var v=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof v.componentDidCatch=="function"&&(Ir===null||!Ir.has(v))){a=lo(f,a),a=_v(l,a,1),l=Cr(l,a,1),a=ns(),l!==null&&(ds(l,1,a),vs(l,a));break}}l=l.return}}function w1(a,l,f){var v=a.pingCache;v!==null&&v.delete(l),l=ns(),a.pingedLanes|=a.suspendedLanes&f,$n===a&&(Dn&f)===f&&(Cn===4||Cn===3&&(Dn&130023424)===Dn&&500>Ot()-hf?pa(a,0):df|=f),vs(a,l)}function l0(a,l){l===0&&((a.mode&1)===0?l=1:(l=Bs,Bs<<=1,(Bs&130023424)===0&&(Bs=4194304)));var f=ns();a=sr(a,l),a!==null&&(ds(a,l,f),vs(a,f))}function S1(a){var l=a.memoizedState,f=0;l!==null&&(f=l.retryLane),l0(a,f)}function _1(a,l){var f=0;switch(a.tag){case 13:var v=a.stateNode,_=a.memoizedState;_!==null&&(f=_.retryLane);break;case 19:v=a.stateNode;break;default:throw Error(n(314))}v!==null&&v.delete(l),l0(a,f)}var c0;c0=function(a,l,f){if(a!==null)if(a.memoizedProps!==l.pendingProps||ms.current)gs=!0;else{if((a.lanes&f)===0&&(l.flags&128)===0)return gs=!1,f1(a,l,f);gs=(a.flags&131072)!==0}else gs=!1,Gt&&(l.flags&1048576)!==0&&Bx(l,Vc,l.index);switch(l.lanes=0,l.tag){case 2:var v=l.type;ou(a,l),a=l.pendingProps;var _=eo(l,Vn.current);ao(l,f),_=Bh(null,l,v,a,_,f);var C=Hh();return l.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,ps(v)?(C=!0,Hc(l)):C=!1,l.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,Oh(l),_.updater=ru,l.stateNode=_,_._reactInternals=l,Kh(l,v,a,f),l=Jh(null,l,v,!0,C,f)):(l.tag=0,Gt&&C&&Sh(l),ts(null,l,_,f),l=l.child),l;case 16:v=l.elementType;e:{switch(ou(a,l),a=l.pendingProps,_=v._init,v=_(v._payload),l.type=v,_=l.tag=C1(v),a=fi(v,a),_){case 0:l=Qh(null,l,v,a,f);break e;case 1:l=Ov(null,l,v,a,f);break e;case 11:l=Iv(null,l,v,a,f);break e;case 14:l=Tv(null,l,v,fi(v.type,a),f);break e}throw Error(n(306,v,""))}return l;case 0:return v=l.type,_=l.pendingProps,_=l.elementType===v?_:fi(v,_),Qh(a,l,v,_,f);case 1:return v=l.type,_=l.pendingProps,_=l.elementType===v?_:fi(v,_),Ov(a,l,v,_,f);case 3:e:{if(Pv(l),a===null)throw Error(n(387));v=l.pendingProps,C=l.memoizedState,_=C.element,Xx(a,l),Qc(l,v,null,f);var W=l.memoizedState;if(v=W.element,C.isDehydrated)if(C={element:v,isDehydrated:!1,cache:W.cache,pendingSuspenseBoundaries:W.pendingSuspenseBoundaries,transitions:W.transitions},l.updateQueue.baseState=C,l.memoizedState=C,l.flags&256){_=lo(Error(n(423)),l),l=zv(a,l,v,f,_);break e}else if(v!==_){_=lo(Error(n(424)),l),l=zv(a,l,v,f,_);break e}else for(As=jr(l.stateNode.containerInfo.firstChild),Cs=l,Gt=!0,hi=null,f=Kx(l,null,v,f),l.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(so(),v===_){l=rr(a,l,f);break e}ts(a,l,v,f)}l=l.child}return l;case 5:return ev(l),a===null&&Ch(l),v=l.type,_=l.pendingProps,C=a!==null?a.memoizedProps:null,W=_.children,yh(v,_)?W=null:C!==null&&yh(v,C)&&(l.flags|=32),Rv(a,l),ts(a,l,W,f),l.child;case 6:return a===null&&Ch(l),null;case 13:return Lv(a,l,f);case 4:return Ph(l,l.stateNode.containerInfo),v=l.pendingProps,a===null?l.child=io(l,null,v,f):ts(a,l,v,f),l.child;case 11:return v=l.type,_=l.pendingProps,_=l.elementType===v?_:fi(v,_),Iv(a,l,v,_,f);case 7:return ts(a,l,l.pendingProps,f),l.child;case 8:return ts(a,l,l.pendingProps.children,f),l.child;case 12:return ts(a,l,l.pendingProps.children,f),l.child;case 10:e:{if(v=l.type._context,_=l.pendingProps,C=l.memoizedProps,W=_.value,Dt(Kc,v._currentValue),v._currentValue=W,C!==null)if(di(C.value,W)){if(C.children===_.children&&!ms.current){l=rr(a,l,f);break e}}else for(C=l.child,C!==null&&(C.return=l);C!==null;){var Q=C.dependencies;if(Q!==null){W=C.child;for(var ae=Q.firstContext;ae!==null;){if(ae.context===v){if(C.tag===1){ae=ir(-1,f&-f),ae.tag=2;var ge=C.updateQueue;if(ge!==null){ge=ge.shared;var Ee=ge.pending;Ee===null?ae.next=ae:(ae.next=Ee.next,Ee.next=ae),ge.pending=ae}}C.lanes|=f,ae=C.alternate,ae!==null&&(ae.lanes|=f),Mh(C.return,f,l),Q.lanes|=f;break}ae=ae.next}}else if(C.tag===10)W=C.type===l.type?null:C.child;else if(C.tag===18){if(W=C.return,W===null)throw Error(n(341));W.lanes|=f,Q=W.alternate,Q!==null&&(Q.lanes|=f),Mh(W,f,l),W=C.sibling}else W=C.child;if(W!==null)W.return=C;else for(W=C;W!==null;){if(W===l){W=null;break}if(C=W.sibling,C!==null){C.return=W.return,W=C;break}W=W.return}C=W}ts(a,l,_.children,f),l=l.child}return l;case 9:return _=l.type,v=l.pendingProps.children,ao(l,f),_=qs(_),v=v(_),l.flags|=1,ts(a,l,v,f),l.child;case 14:return v=l.type,_=fi(v,l.pendingProps),_=fi(v.type,_),Tv(a,l,v,_,f);case 15:return $v(a,l,l.type,l.pendingProps,f);case 17:return v=l.type,_=l.pendingProps,_=l.elementType===v?_:fi(v,_),ou(a,l),l.tag=1,ps(v)?(a=!0,Hc(l)):a=!1,ao(l,f),jv(l,v,_),Kh(l,v,_,f),Jh(null,l,v,!0,a,f);case 19:return Fv(a,l,f);case 22:return Mv(a,l,f)}throw Error(n(156,l.tag))};function u0(a,l){return _s(a,l)}function E1(a,l,f,v){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=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=v,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ys(a,l,f,v){return new E1(a,l,f,v)}function bf(a){return a=a.prototype,!(!a||!a.isReactComponent)}function C1(a){if(typeof a=="function")return bf(a)?1:0;if(a!=null){if(a=a.$$typeof,a===U)return 11;if(a===O)return 14}return 2}function Rr(a,l){var f=a.alternate;return f===null?(f=Ys(a.tag,l,a.key,a.mode),f.elementType=a.elementType,f.type=a.type,f.stateNode=a.stateNode,f.alternate=a,a.alternate=f):(f.pendingProps=l,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,l=a.dependencies,f.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},f.sibling=a.sibling,f.index=a.index,f.ref=a.ref,f}function vu(a,l,f,v,_,C){var W=2;if(v=a,typeof a=="function")bf(a)&&(W=1);else if(typeof a=="string")W=5;else e:switch(a){case B:return xa(f.children,_,C,l);case V:W=8,_|=8;break;case M:return a=Ys(12,f,l,_|2),a.elementType=M,a.lanes=C,a;case I:return a=Ys(13,f,l,_),a.elementType=I,a.lanes=C,a;case T:return a=Ys(19,f,l,_),a.elementType=T,a.lanes=C,a;case F:return yu(f,_,C,l);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case z:W=10;break e;case D:W=9;break e;case U:W=11;break e;case O:W=14;break e;case $:W=16,v=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return l=Ys(W,f,l,_),l.elementType=a,l.type=v,l.lanes=C,l}function xa(a,l,f,v){return a=Ys(7,a,v,l),a.lanes=f,a}function yu(a,l,f,v){return a=Ys(22,a,v,l),a.elementType=F,a.lanes=f,a.stateNode={isHidden:!1},a}function kf(a,l,f){return a=Ys(6,a,null,l),a.lanes=f,a}function Nf(a,l,f){return l=Ys(4,a.children!==null?a.children:[],a.key,l),l.lanes=f,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}function A1(a,l,f,v,_){this.tag=l,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Jn(0),this.expirationTimes=Jn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Jn(0),this.identifierPrefix=v,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function jf(a,l,f,v,_,C,W,Q,ae){return a=new A1(a,l,f,Q,ae),l===1?(l=1,C===!0&&(l|=8)):l=0,C=Ys(3,null,null,l),a.current=C,C.stateNode=a,C.memoizedState={element:v,isDehydrated:f,cache:null,transitions:null,pendingSuspenseBoundaries:null},Oh(C),a}function I1(a,l,f){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:L,key:v==null?null:""+v,children:a,containerInfo:l,implementation:f}}function d0(a){if(!a)return Sr;a=a._reactInternals;e:{if(Zn(a)!==a||a.tag!==1)throw Error(n(170));var l=a;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(ps(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(n(171))}if(a.tag===1){var f=a.type;if(ps(f))return Dx(a,f,l)}return l}function h0(a,l,f,v,_,C,W,Q,ae){return a=jf(f,v,!0,a,_,C,W,Q,ae),a.context=d0(null),f=a.current,v=ns(),_=$r(f),C=ir(v,_),C.callback=l??null,Cr(f,C,_),a.current.lanes=_,ds(a,_,v),vs(a,v),a}function bu(a,l,f,v){var _=l.current,C=ns(),W=$r(_);return f=d0(f),l.context===null?l.context=f:l.pendingContext=f,l=ir(C,W),l.payload={element:a},v=v===void 0?null:v,v!==null&&(l.callback=v),a=Cr(_,l,W),a!==null&&(gi(a,_,W,C),Xc(a,_,W)),W}function ku(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 f0(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var f=a.retryLane;a.retryLane=f!==0&&f<l?f:l}}function wf(a,l){f0(a,l),(a=a.alternate)&&f0(a,l)}function T1(){return null}var m0=typeof reportError=="function"?reportError:function(a){console.error(a)};function Sf(a){this._internalRoot=a}Nu.prototype.render=Sf.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(n(409));bu(a,l,null,null)},Nu.prototype.unmount=Sf.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;ma(function(){bu(null,a,null,null)}),l[Ji]=null}};function Nu(a){this._internalRoot=a}Nu.prototype.unstable_scheduleHydration=function(a){if(a){var l=Ki();a={blockedOn:null,target:a,priority:l};for(var f=0;f<pn.length&&l!==0&&l<pn[f].priority;f++);pn.splice(f,0,a),f===0&&Za(a)}};function _f(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function ju(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function p0(){}function $1(a,l,f,v,_){if(_){if(typeof v=="function"){var C=v;v=function(){var ge=ku(W);C.call(ge)}}var W=h0(l,v,a,0,null,!1,!1,"",p0);return a._reactRootContainer=W,a[Ji]=W.current,al(a.nodeType===8?a.parentNode:a),ma(),W}for(;_=a.lastChild;)a.removeChild(_);if(typeof v=="function"){var Q=v;v=function(){var ge=ku(ae);Q.call(ge)}}var ae=jf(a,0,!1,null,null,!1,!1,"",p0);return a._reactRootContainer=ae,a[Ji]=ae.current,al(a.nodeType===8?a.parentNode:a),ma(function(){bu(l,ae,f,v)}),ae}function wu(a,l,f,v,_){var C=f._reactRootContainer;if(C){var W=C;if(typeof _=="function"){var Q=_;_=function(){var ae=ku(W);Q.call(ae)}}bu(l,W,a,_)}else W=$1(f,l,a,_,v);return ku(W)}hs=function(a){switch(a.tag){case 3:var l=a.stateNode;if(l.current.memoizedState.isDehydrated){var f=Hs(l.pendingLanes);f!==0&&(Zs(l,f|1),vs(l,Ot()),(kt&6)===0&&(ho=Ot()+500,_r()))}break;case 13:ma(function(){var v=sr(a,1);if(v!==null){var _=ns();gi(v,a,1,_)}}),wf(a,1)}},zt=function(a){if(a.tag===13){var l=sr(a,134217728);if(l!==null){var f=ns();gi(l,a,134217728,f)}wf(a,134217728)}},ft=function(a){if(a.tag===13){var l=$r(a),f=sr(a,l);if(f!==null){var v=ns();gi(f,a,l,v)}wf(a,l)}},Ki=function(){return vt},es=function(a,l){var f=vt;try{return vt=a,l()}finally{vt=f}},ri=function(a,l,f){switch(l){case"input":if(Ge(a,f),l=f.name,f.type==="radio"&&l!=null){for(f=a;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<f.length;l++){var v=f[l];if(v!==a&&v.form===a.form){var _=Uc(v);if(!_)throw Error(n(90));ve(v),Ge(v,_)}}}break;case"textarea":cn(a,f);break;case"select":l=f.value,l!=null&&St(a,!!f.multiple,l,!1)}},Le=xf,st=ma;var M1={usingClientEntryPoint:!1,Events:[cl,Qa,Uc,te,ye,xf]},jl={findFiberByHostInstance:aa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},R1={bundleType:jl.bundleType,version:jl.version,rendererPackageName:jl.rendererPackageName,rendererConfig:jl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:A.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=vr(a),a===null?null:a.stateNode},findFiberByHostInstance:jl.findFiberByHostInstance||T1,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 Su=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Su.isDisabled&&Su.supportsFiber)try{ct=Su.inject(R1),ht=Su}catch{}}return ys.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=M1,ys.createPortal=function(a,l){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!_f(l))throw Error(n(200));return I1(a,l,null,f)},ys.createRoot=function(a,l){if(!_f(a))throw Error(n(299));var f=!1,v="",_=m0;return l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(_=l.onRecoverableError)),l=jf(a,1,!1,null,null,f,!1,v,_),a[Ji]=l.current,al(a.nodeType===8?a.parentNode:a),new Sf(l)},ys.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var l=a._reactInternals;if(l===void 0)throw typeof a.render=="function"?Error(n(188)):(a=Object.keys(a).join(","),Error(n(268,a)));return a=vr(l),a=a===null?null:a.stateNode,a},ys.flushSync=function(a){return ma(a)},ys.hydrate=function(a,l,f){if(!ju(l))throw Error(n(200));return wu(null,a,l,!0,f)},ys.hydrateRoot=function(a,l,f){if(!_f(a))throw Error(n(405));var v=f!=null&&f.hydratedSources||null,_=!1,C="",W=m0;if(f!=null&&(f.unstable_strictMode===!0&&(_=!0),f.identifierPrefix!==void 0&&(C=f.identifierPrefix),f.onRecoverableError!==void 0&&(W=f.onRecoverableError)),l=h0(l,null,a,1,f??null,_,!1,C,W),a[Ji]=l.current,al(a),v)for(a=0;a<v.length;a++)f=v[a],_=f._getVersion,_=_(f._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[f,_]:l.mutableSourceEagerHydrationData.push(f,_);return new Nu(l)},ys.render=function(a,l,f){if(!ju(l))throw Error(n(200));return wu(null,a,l,!1,f)},ys.unmountComponentAtNode=function(a){if(!ju(a))throw Error(n(40));return a._reactRootContainer?(ma(function(){wu(null,null,a,!1,function(){a._reactRootContainer=null,a[Ji]=null})}),!0):!1},ys.unstable_batchedUpdates=xf,ys.unstable_renderSubtreeIntoContainer=function(a,l,f,v){if(!ju(f))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return wu(a,l,f,!1,v)},ys.version="18.3.1-next-f1338f8080-20240426",ys}var S0;function Yk(){if(S0)return If.exports;S0=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(),If.exports=H1(),If.exports}var _0;function Z1(){if(_0)return _u;_0=1;var e=Yk();return _u.createRoot=e.createRoot,_u.hydrateRoot=e.hydrateRoot,_u}var W1=Z1(),Hr,Io,To;class Fi{constructor(t){Lt(this,Hr);Lt(this,Io,new Set);Lt(this,To,!1);ut(this,"get",()=>ze(this,Hr));ut(this,"subscribe",t=>(ze(this,Io).add(t),()=>{ze(this,Io).delete(t)}));Zt(this,Hr,t)}set(t){const n=typeof t=="function"?t(ze(this,Hr)):t;Object.is(n,ze(this,Hr))||(Zt(this,Hr,n),!ze(this,To)&&(Zt(this,To,!0),queueMicrotask(()=>{Zt(this,To,!1);for(const i of[...ze(this,Io)])i()})))}}Hr=new WeakMap,Io=new WeakMap,To=new WeakMap;var E0;function ke(e,t,n){function i(u,d){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:d,constr:c,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,d);const h=c.prototype,m=Object.keys(h);for(let g=0;g<m.length;g++){const p=m[g];p in u||(u[p]=h[p].bind(u))}}const r=(n==null?void 0:n.Parent)??Object;class o extends r{}Object.defineProperty(o,"name",{value:e});function c(u){var d;const h=n!=null&&n.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(c,"init",{value:i}),Object.defineProperty(c,Symbol.hasInstance,{value:u=>{var d,h;return n!=null&&n.Parent&&u instanceof n.Parent?!0:(h=(d=u==null?void 0:u._zod)==null?void 0:d.traits)==null?void 0:h.has(e)}}),Object.defineProperty(c,"name",{value:e}),c}class wo extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Xk extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(E0=globalThis).__zod_globalConfig??(E0.__zod_globalConfig={});const Kp=globalThis.__zod_globalConfig;function fr(e){return Kp}function Qk(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 Fm(e,t){return typeof t=="bigint"?t.toString():t}function $d(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Yp(e){return e==null}function Xp(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function V1(e,t){const n=e/t,i=Math.round(n),r=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-i)<r?0:n-i}const C0=Symbol("evaluating");function Mt(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==C0)return i===void 0&&(i=C0,i=n()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Fa(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ta(...e){const t={};for(const n of e){const i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function A0(e){return JSON.stringify(e)}function q1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Jk="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function tc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const G1=$d(()=>{var e;if(Kp.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 zo(e){if(tc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(tc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function eN(e){return zo(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const K1=new Set(["string","number","symbol"]);function Lo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function na(e,t,n){const i=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(i._zod.parent=e),i}function Qe(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 Y1(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const X1={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 Q1(e,t){const n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=ta(e._zod.def,{get shape(){const c={};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n.shape[u])}return Fa(this,"shape",c),c},checks:[]});return na(e,o)}function J1(e,t){const n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=ta(e._zod.def,{get shape(){const c={...e._zod.def.shape};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&delete c[u]}return Fa(this,"shape",c),c},checks:[]});return na(e,o)}function eC(e,t){if(!zo(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=e._zod.def.shape;for(const c in t)if(Object.getOwnPropertyDescriptor(o,c)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=ta(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Fa(this,"shape",o),o}});return na(e,r)}function tC(e,t){if(!zo(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ta(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Fa(this,"shape",i),i}});return na(e,n)}function nC(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 n=ta(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Fa(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return na(e,n)}function sC(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const c=ta(t._zod.def,{get shape(){const u=t._zod.def.shape,d={...u};if(n)for(const h in n){if(!(h in u))throw new Error(`Unrecognized key: "${h}"`);n[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 Fa(this,"shape",d),d},checks:[]});return na(t,c)}function iC(e,t,n){const i=ta(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(o[c]=new e({type:"nonoptional",innerType:r[c]}))}else for(const c in r)o[c]=new e({type:"nonoptional",innerType:r[c]});return Fa(this,"shape",o),o}});return na(t,i)}function bo(e,t=0){var n;if(e.aborted===!0)return!0;for(let i=t;i<e.issues.length;i++)if(((n=e.issues[i])==null?void 0:n.continue)!==!0)return!0;return!1}function rC(e,t=0){var n;if(e.aborted===!0)return!0;for(let i=t;i<e.issues.length;i++)if(((n=e.issues[i])==null?void 0:n.continue)===!1)return!0;return!1}function ko(e,t){return t.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Eu(e){return typeof e=="string"?e:e==null?void 0:e.message}function mr(e,t,n){var d,h,m,g,p,x;const i=e.message?e.message:Eu((m=(h=(d=e.inst)==null?void 0:d._zod.def)==null?void 0:h.error)==null?void 0:m.call(h,e))??Eu((g=t==null?void 0:t.error)==null?void 0:g.call(t,e))??Eu((p=n.customError)==null?void 0:p.call(n,e))??Eu((x=n.localeError)==null?void 0:x.call(n,e))??"Invalid input",{inst:r,continue:o,input:c,...u}=e;return u.path??(u.path=[]),u.message=i,t!=null&&t.reportInput&&(u.input=c),u}function Qp(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function nc(...e){const[t,n,i]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:i}:{...t}}const tN=(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,Fm,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},nN=ke("$ZodError",tN),sN=ke("$ZodError",tN,{Parent:Error});function aC(e,t=n=>n.message){const n={},i=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):i.push(t(r));return{formErrors:i,fieldErrors:n}}function oC(e,t=n=>n.message){const n={_errors:[]},i=(r,o=[])=>{for(const c of r.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>i({issues:u},[...o,...c.path]));else if(c.code==="invalid_key")i({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")i({issues:c.issues},[...o,...c.path]);else{const u=[...o,...c.path];if(u.length===0)n._errors.push(t(c));else{let d=n,h=0;for(;h<u.length;){const m=u[h];h===u.length-1?(d[m]=d[m]||{_errors:[]},d[m]._errors.push(t(c))):d[m]=d[m]||{_errors:[]},d=d[m],h++}}}};return i(e),n}const Jp=e=>(t,n,i,r)=>{const o=i?{...i,async:!1}:{async:!1},c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise)throw new wo;if(c.issues.length){const u=new((r==null?void 0:r.Err)??e)(c.issues.map(d=>mr(d,o,fr())));throw Jk(u,r==null?void 0:r.callee),u}return c.value},eg=e=>async(t,n,i,r)=>{const o=i?{...i,async:!0}:{async:!0};let c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((r==null?void 0:r.Err)??e)(c.issues.map(d=>mr(d,o,fr())));throw Jk(u,r==null?void 0:r.callee),u}return c.value},Md=e=>(t,n,i)=>{const r=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise)throw new wo;return o.issues.length?{success:!1,error:new(e??nN)(o.issues.map(c=>mr(c,r,fr())))}:{success:!0,data:o.value}},lC=Md(sN),Rd=e=>async(t,n,i)=>{const r=i?{...i,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(c=>mr(c,r,fr())))}:{success:!0,data:o.value}},cC=Rd(sN),uC=e=>(t,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Jp(e)(t,n,r)},dC=e=>(t,n,i)=>Jp(e)(t,n,i),hC=e=>async(t,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return eg(e)(t,n,r)},fC=e=>async(t,n,i)=>eg(e)(t,n,i),mC=e=>(t,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Md(e)(t,n,r)},pC=e=>(t,n,i)=>Md(e)(t,n,i),gC=e=>async(t,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Rd(e)(t,n,r)},xC=e=>async(t,n,i)=>Rd(e)(t,n,i),vC=/^[cC][0-9a-z]{6,}$/,yC=/^[0-9a-z]+$/,bC=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,kC=/^[0-9a-vA-V]{20}$/,NC=/^[A-Za-z0-9]{27}$/,jC=/^[a-zA-Z0-9_-]{21}$/,wC=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,SC=/^([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})$/,I0=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)$/,_C=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,EC="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function CC(){return new RegExp(EC,"u")}const AC=/^(?:(?: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])$/,IC=/^(([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}|:))$/,TC=/^((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])$/,$C=/^(([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])$/,MC=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,iN=/^[A-Za-z0-9_-]*$/,RC=/^https?$/,OC=/^\+[1-9]\d{6,14}$/,rN="(?:(?:\\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])))",PC=new RegExp(`^${rN}$`);function aN(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 zC(e){return new RegExp(`^${aN(e)}$`)}function LC(e){const t=aN({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${t}(?:${n.join("|")})`;return new RegExp(`^${rN}T(?:${i})$`)}const DC=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}$`)},FC=/^-?\d+$/,oN=/^-?\d+(?:\.\d+)?$/,UC=/^(?:true|false)$/i,BC=/^null$/i,HC=/^[^A-Z]*$/,ZC=/^[^a-z]*$/,ws=ke("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),lN={number:"number",bigint:"bigint",object:"date"},cN=ke("$ZodCheckLessThan",(e,t)=>{ws.init(e,t);const n=lN[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:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uN=ke("$ZodCheckGreaterThan",(e,t)=>{ws.init(e,t);const n=lN[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:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),WC=ke("$ZodCheckMultipleOf",(e,t)=>{ws.init(e,t),e._zod.onattach.push(n=>{var i;(i=n._zod.bag).multipleOf??(i.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):V1(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),VC=ke("$ZodCheckNumberFormat",(e,t)=>{var c;ws.init(e,t),t.format=t.format||"float64";const n=(c=t.format)==null?void 0:c.includes("int"),i=n?"int":"number",[r,o]=X1[t.format];e._zod.onattach.push(u=>{const d=u._zod.bag;d.format=t.format,d.minimum=r,d.maximum=o,n&&(d.pattern=FC)}),e._zod.check=u=>{const d=u.value;if(n){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})}}),qC=ke("$ZodCheckMaxLength",(e,t)=>{var n;ws.init(e,t),(n=e._zod.def).when??(n.when=i=>{const r=i.value;return!Yp(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 c=Qp(r);i.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),GC=ke("$ZodCheckMinLength",(e,t)=>{var n;ws.init(e,t),(n=e._zod.def).when??(n.when=i=>{const r=i.value;return!Yp(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 c=Qp(r);i.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),KC=ke("$ZodCheckLengthEquals",(e,t)=>{var n;ws.init(e,t),(n=e._zod.def).when??(n.when=i=>{const r=i.value;return!Yp(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 c=Qp(r),u=o>t.length;i.issues.push({origin:c,...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})}}),Od=ke("$ZodCheckStringFormat",(e,t)=>{var n,i;ws.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?(n=e._zod).check??(n.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=()=>{})}),YC=ke("$ZodCheckRegex",(e,t)=>{Od.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),XC=ke("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=HC),Od.init(e,t)}),QC=ke("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ZC),Od.init(e,t)}),JC=ke("$ZodCheckIncludes",(e,t)=>{ws.init(e,t);const n=Lo(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);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})}}),eA=ke("$ZodCheckStartsWith",(e,t)=>{ws.init(e,t);const n=new RegExp(`^${Lo(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),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})}}),tA=ke("$ZodCheckEndsWith",(e,t)=>{ws.init(e,t);const n=new RegExp(`.*${Lo(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),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})}}),nA=ke("$ZodCheckOverwrite",(e,t)=>{ws.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class sA{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(c=>c),r=Math.min(...i.map(c=>c.length-c.trimStart().length)),o=i.map(c=>c.slice(r)).map(c=>" ".repeat(this.indent*2)+c);for(const c of o)this.content.push(c)}compile(){const t=Function,n=this==null?void 0:this.args,r=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new t(...n,r.join(`
42
+ `))}}const iA={major:4,minor:4,patch:3},Yt=ke("$ZodType",(e,t)=>{var r;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=iA;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const o of i)for(const c of o._zod.onattach)c(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),(r=e._zod.deferred)==null||r.push(()=>{e._zod.run=e._zod.parse});else{const o=(u,d,h)=>{let m=bo(u),g;for(const p of d){if(p._zod.def.when){if(rC(u)||!p._zod.def.when(u))continue}else if(m)continue;const x=u.issues.length,y=p._zod.check(u);if(y instanceof Promise&&(h==null?void 0:h.async)===!1)throw new wo;if(g||y instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await y,u.issues.length!==x&&(m||(m=bo(u,x)))});else{if(u.issues.length===x)continue;m||(m=bo(u,x))}}return g?g.then(()=>u):u},c=(u,d,h)=>{if(bo(u))return u.aborted=!0,u;const m=o(d,i,h);if(m instanceof Promise){if(h.async===!1)throw new wo;return m.then(g=>e._zod.parse(g,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(g=>c(g,u,d)):c(m,u,d)}const h=e._zod.parse(u,d);if(h instanceof Promise){if(d.async===!1)throw new wo;return h.then(m=>o(m,i,d))}return o(h,i,d)}}Mt(e,"~standard",()=>({validate:o=>{var c;try{const u=lC(e,o);return u.success?{value:u.data}:{issues:(c=u.error)==null?void 0:c.issues}}catch{return cC(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}))}),tg=ke("$ZodString",(e,t)=>{var n;Yt.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??DC(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}}),Xt=ke("$ZodStringFormat",(e,t)=>{Od.init(e,t),tg.init(e,t)}),rA=ke("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=SC),Xt.init(e,t)}),aA=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=I0(i))}else t.pattern??(t.pattern=I0());Xt.init(e,t)}),oA=ke("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=_C),Xt.init(e,t)}),lA=ke("$ZodURL",(e,t)=>{Xt.init(e,t),e._zod.check=n=>{var i;try{const r=n.value.trim();if(!t.normalize&&((i=t.protocol)==null?void 0:i.source)===RC.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),cA=ke("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=CC()),Xt.init(e,t)}),uA=ke("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=jC),Xt.init(e,t)}),dA=ke("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=vC),Xt.init(e,t)}),hA=ke("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=yC),Xt.init(e,t)}),fA=ke("$ZodULID",(e,t)=>{t.pattern??(t.pattern=bC),Xt.init(e,t)}),mA=ke("$ZodXID",(e,t)=>{t.pattern??(t.pattern=kC),Xt.init(e,t)}),pA=ke("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=NC),Xt.init(e,t)}),gA=ke("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=LC(t)),Xt.init(e,t)}),xA=ke("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=PC),Xt.init(e,t)}),vA=ke("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=zC(t)),Xt.init(e,t)}),yA=ke("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=wC),Xt.init(e,t)}),bA=ke("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=AC),Xt.init(e,t),e._zod.bag.format="ipv4"}),kA=ke("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=IC),Xt.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),NA=ke("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=TC),Xt.init(e,t)}),jA=ke("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=$C),Xt.init(e,t),e._zod.check=n=>{const i=n.value.split("/");try{if(i.length!==2)throw new Error;const[r,o]=i;if(!o)throw new Error;const c=Number(o);if(`${c}`!==o)throw new Error;if(c<0||c>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function dN(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const wA=ke("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=MC),Xt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{dN(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function SA(e){if(!iN.test(e))return!1;const t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return dN(n)}const _A=ke("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=iN),Xt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{SA(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),EA=ke("$ZodE164",(e,t)=>{t.pattern??(t.pattern=OC),Xt.init(e,t)});function CA(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[i]=n;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 AA=ke("$ZodJWT",(e,t)=>{Xt.init(e,t),e._zod.check=n=>{CA(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),hN=ke("$ZodNumber",(e,t)=>{Yt.init(e,t),e._zod.pattern=e._zod.bag.pattern??oN,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const o=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...o?{received:o}:{}}),n}}),IA=ke("$ZodNumberFormat",(e,t)=>{VC.init(e,t),hN.init(e,t)}),TA=ke("$ZodBoolean",(e,t)=>{Yt.init(e,t),e._zod.pattern=UC,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),$A=ke("$ZodNull",(e,t)=>{Yt.init(e,t),e._zod.pattern=BC,e._zod.values=new Set([null]),e._zod.parse=(n,i)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),MA=ke("$ZodUnknown",(e,t)=>{Yt.init(e,t),e._zod.parse=n=>n}),RA=ke("$ZodNever",(e,t)=>{Yt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function T0(e,t,n){e.issues.length&&t.issues.push(...ko(n,e.issues)),t.value[n]=e.value}const OA=ke("$ZodArray",(e,t)=>{Yt.init(e,t),e._zod.parse=(n,i)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const o=[];for(let c=0;c<r.length;c++){const u=r[c],d=t.element._zod.run({value:u,issues:[]},i);d instanceof Promise?o.push(d.then(h=>T0(h,n,c))):T0(d,n,c)}return o.length?Promise.all(o).then(()=>n):n}});function ad(e,t,n,i,r,o){const c=n in i;if(e.issues.length){if(r&&o&&!c)return;t.issues.push(...ko(n,e.issues))}if(!c&&!r){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?c&&(t.value[n]=void 0):t.value[n]=e.value}function fN(e){var i,r,o,c;const t=Object.keys(e.shape);for(const u of t)if(!((c=(o=(r=(i=e.shape)==null?void 0:i[u])==null?void 0:r._zod)==null?void 0:o.traits)!=null&&c.has("$ZodType")))throw new Error(`Invalid element at key "${u}": expected a Zod schema`);const n=Y1(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function mN(e,t,n,i,r,o){const c=[],u=r.keySet,d=r.catchall._zod,h=d.def.type,m=d.optin==="optional",g=d.optout==="optional";for(const p in t){if(p==="__proto__"||u.has(p))continue;if(h==="never"){c.push(p);continue}const x=d.run({value:t[p],issues:[]},i);x instanceof Promise?e.push(x.then(y=>ad(y,n,p,t,m,g))):ad(x,n,p,t,m,g)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const PA=ke("$ZodObject",(e,t)=>{Yt.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...u};return Object.defineProperty(t,"shape",{value:d}),d}})}const i=$d(()=>fN(t));Mt(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 g of m.values)d[h].add(g)}}return d});const r=tc,o=t.catchall;let c;e._zod.parse=(u,d)=>{c??(c=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=[],g=c.shape;for(const p of c.keys){const x=g[p],y=x._zod.optin==="optional",S=x._zod.optout==="optional",N=x._zod.run({value:h[p],issues:[]},d);N instanceof Promise?m.push(N.then(k=>ad(k,u,p,h,y,S))):ad(N,u,p,h,y,S)}return o?mN(m,h,u,d,i.value,e):m.length?Promise.all(m).then(()=>u):u}}),zA=ke("$ZodObjectJIT",(e,t)=>{PA.init(e,t);const n=e._zod.parse,i=$d(()=>fN(t)),r=p=>{var j,A;const x=new sA(["shape","payload","ctx"]),y=i.value,S=P=>{const L=A0(P);return`shape[${L}]._zod.run({ value: input[${L}], issues: [] }, ctx)`};x.write("const input = payload.value;");const N=Object.create(null);let k=0;for(const P of y.keys)N[P]=`key_${k++}`;x.write("const newResult = {};");for(const P of y.keys){const L=N[P],B=A0(P),V=p[P],M=((j=V==null?void 0:V._zod)==null?void 0:j.optin)==="optional",z=((A=V==null?void 0:V._zod)==null?void 0:A.optout)==="optional";x.write(`const ${L} = ${S(P)};`),M&&z?x.write(`
43
+ if (${L}.issues.length) {
44
+ if (${B} in input) {
45
+ payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
46
+ ...iss,
47
+ path: iss.path ? [${B}, ...iss.path] : [${B}]
48
+ })));
49
+ }
50
+ }
51
+
52
+ if (${L}.value === undefined) {
53
+ if (${B} in input) {
54
+ newResult[${B}] = undefined;
55
+ }
56
+ } else {
57
+ newResult[${B}] = ${L}.value;
58
+ }
59
+
60
+ `):M?x.write(`
61
+ if (${L}.issues.length) {
62
+ payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
63
+ ...iss,
64
+ path: iss.path ? [${B}, ...iss.path] : [${B}]
65
+ })));
66
+ }
67
+
68
+ if (${L}.value === undefined) {
69
+ if (${B} in input) {
70
+ newResult[${B}] = undefined;
71
+ }
72
+ } else {
73
+ newResult[${B}] = ${L}.value;
74
+ }
75
+
76
+ `):x.write(`
77
+ const ${L}_present = ${B} in input;
78
+ if (${L}.issues.length) {
79
+ payload.issues = payload.issues.concat(${L}.issues.map(iss => ({
80
+ ...iss,
81
+ path: iss.path ? [${B}, ...iss.path] : [${B}]
82
+ })));
83
+ }
84
+ if (!${L}_present && !${L}.issues.length) {
85
+ payload.issues.push({
86
+ code: "invalid_type",
87
+ expected: "nonoptional",
88
+ input: undefined,
89
+ path: [${B}]
90
+ });
91
+ }
92
+
93
+ if (${L}_present) {
94
+ if (${L}.value === undefined) {
95
+ newResult[${B}] = undefined;
96
+ } else {
97
+ newResult[${B}] = ${L}.value;
98
+ }
99
+ }
100
+
101
+ `)}x.write("payload.value = newResult;"),x.write("return payload;");const E=x.compile();return(P,L)=>E(p,P,L)};let o;const c=tc,u=!Kp.jitless,h=u&&G1.value,m=t.catchall;let g;e._zod.parse=(p,x)=>{g??(g=i.value);const y=p.value;return c(y)?u&&h&&(x==null?void 0:x.async)===!1&&x.jitless!==!0?(o||(o=r(t.shape)),p=o(p,x),m?mN([],y,p,x,g,e):p):n(p,x):(p.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),p)}});function $0(e,t,n,i){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const r=e.filter(o=>!bo(o));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(c=>mr(c,i,fr())))}),t)}const pN=ke("$ZodUnion",(e,t)=>{Yt.init(e,t),Mt(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Mt(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Mt(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Mt(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=>Xp(r.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let o=!1;const c=[];for(const u of t.options){const d=u._zod.run({value:i.value,issues:[]},r);if(d instanceof Promise)c.push(d),o=!0;else{if(d.issues.length===0)return d;c.push(d)}}return o?Promise.all(c).then(u=>$0(u,i,e,r)):$0(c,i,e,r)}}),LA=ke("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,pN.init(e,t);const n=e._zod.parse;Mt(e._zod,"propValues",()=>{const r={};for(const o of t.options){const c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[u,d]of Object.entries(c)){r[u]||(r[u]=new Set);for(const h of d)r[u].add(h)}}return r});const i=$d(()=>{var c;const r=t.options,o=new Map;for(const u of r){const d=(c=u._zod.propValues)==null?void 0:c[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const 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 c=r.value;if(!tc(c))return r.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),r;const u=i.value.get(c==null?void 0:c[t.discriminator]);return u?u._zod.run(r,o):t.unionFallback||o.direction==="backward"?n(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()),input:c,path:[t.discriminator],inst:e}),r)}}),DA=ke("$ZodIntersection",(e,t)=>{Yt.init(e,t),e._zod.parse=(n,i)=>{const r=n.value,o=t.left._zod.run({value:r,issues:[]},i),c=t.right._zod.run({value:r,issues:[]},i);return o instanceof Promise||c instanceof Promise?Promise.all([o,c]).then(([d,h])=>M0(n,d,h)):M0(n,o,c)}});function Um(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(zo(e)&&zo(t)){const n=Object.keys(t),i=Object.keys(e).filter(o=>n.indexOf(o)!==-1),r={...e,...t};for(const o of i){const c=Um(e[o],t[o]);if(!c.valid)return{valid:!1,mergeErrorPath:[o,...c.mergeErrorPath]};r[o]=c.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;i<e.length;i++){const r=e[i],o=t[i],c=Um(r,o);if(!c.valid)return{valid:!1,mergeErrorPath:[i,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function M0(e,t,n){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 n.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}),bo(e))return e;const c=Um(t.value,n.value);if(!c.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`);return e.value=c.data,e}const FA=ke("$ZodRecord",(e,t)=>{Yt.init(e,t),e._zod.parse=(n,i)=>{const r=n.value;if(!zo(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const o=[],c=t.keyType._zod.values;if(c){n.value={};const u=new Set;for(const h of c)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){n.issues.push({code:"invalid_key",origin:"record",issues:m.issues.map(x=>mr(x,i,fr())),input:h,path:[h],inst:e});continue}const g=m.value,p=t.valueType._zod.run({value:r[h],issues:[]},i);p instanceof Promise?o.push(p.then(x=>{x.issues.length&&n.issues.push(...ko(h,x.issues)),n.value[g]=x.value})):(p.issues.length&&n.issues.push(...ko(h,p.issues)),n.value[g]=p.value)}let d;for(const h in r)u.has(h)||(d=d??[],d.push(h));d&&d.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:d})}else{n.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"&&oN.test(u)&&d.issues.length){const g=t.keyType._zod.run({value:Number(u),issues:[]},i);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(d=g)}if(d.issues.length){t.mode==="loose"?n.value[u]=r[u]:n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(g=>mr(g,i,fr())),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(g=>{g.issues.length&&n.issues.push(...ko(u,g.issues)),n.value[d.value]=g.value})):(m.issues.length&&n.issues.push(...ko(u,m.issues)),n.value[d.value]=m.value)}}return o.length?Promise.all(o).then(()=>n):n}}),UA=ke("$ZodEnum",(e,t)=>{Yt.init(e,t);const n=Qk(t.entries),i=new Set(n);e._zod.values=i,e._zod.pattern=new RegExp(`^(${n.filter(r=>K1.has(typeof r)).map(r=>typeof r=="string"?Lo(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const c=r.value;return i.has(c)||r.issues.push({code:"invalid_value",values:n,input:c,inst:e}),r}}),BA=ke("$ZodLiteral",(e,t)=>{if(Yt.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?Lo(i):i?Lo(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,r)=>{const o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),HA=ke("$ZodTransform",(e,t)=>{Yt.init(e,t),e._zod.optin="optional",e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Xk(e.constructor.name);const r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(c=>(n.value=c,n.fallback=!0,n));if(r instanceof Promise)throw new wo;return n.value=r,n.fallback=!0,n}});function R0(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const gN=ke("$ZodOptional",(e,t)=>{Yt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Mt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Mt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Xp(n.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(t.innerType._zod.optin==="optional"){const r=n.value,o=t.innerType._zod.run(n,i);return o instanceof Promise?o.then(c=>R0(c,r)):R0(o,r)}return n.value===void 0?n:t.innerType._zod.run(n,i)}}),ZA=ke("$ZodExactOptional",(e,t)=>{gN.init(e,t),Mt(e._zod,"values",()=>t.innerType._zod.values),Mt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),WA=ke("$ZodNullable",(e,t)=>{Yt.init(e,t),Mt(e._zod,"optin",()=>t.innerType._zod.optin),Mt(e._zod,"optout",()=>t.innerType._zod.optout),Mt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Xp(n.source)}|null)$`):void 0}),Mt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>n.value===null?n:t.innerType._zod.run(n,i)}),VA=ke("$ZodDefault",(e,t)=>{Yt.init(e,t),e._zod.optin="optional",Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>O0(o,t)):O0(r,t)}});function O0(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const qA=ke("$ZodPrefault",(e,t)=>{Yt.init(e,t),e._zod.optin="optional",Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,i))}),GA=ke("$ZodNonOptional",(e,t)=>{Yt.init(e,t),Mt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,i)=>{const r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>P0(o,e)):P0(r,e)}});function P0(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 KA=ke("$ZodCatch",(e,t)=>{Yt.init(e,t),e._zod.optin="optional",Mt(e._zod,"optout",()=>t.innerType._zod.optout),Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);const r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(c=>mr(c,i,fr()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(o=>mr(o,i,fr()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),YA=ke("$ZodPipe",(e,t)=>{Yt.init(e,t),Mt(e._zod,"values",()=>t.in._zod.values),Mt(e._zod,"optin",()=>t.in._zod.optin),Mt(e._zod,"optout",()=>t.out._zod.optout),Mt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){const o=t.out._zod.run(n,i);return o instanceof Promise?o.then(c=>Cu(c,t.in,i)):Cu(o,t.in,i)}const r=t.in._zod.run(n,i);return r instanceof Promise?r.then(o=>Cu(o,t.out,i)):Cu(r,t.out,i)}});function Cu(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const XA=ke("$ZodReadonly",(e,t)=>{Yt.init(e,t),Mt(e._zod,"propValues",()=>t.innerType._zod.propValues),Mt(e._zod,"values",()=>t.innerType._zod.values),Mt(e._zod,"optin",()=>{var n,i;return(i=(n=t.innerType)==null?void 0:n._zod)==null?void 0:i.optin}),Mt(e._zod,"optout",()=>{var n,i;return(i=(n=t.innerType)==null?void 0:n._zod)==null?void 0:i.optout}),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);const r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(z0):z0(r)}});function z0(e){return e.value=Object.freeze(e.value),e}const QA=ke("$ZodCustom",(e,t)=>{ws.init(e,t),Yt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=n=>{const i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then(o=>L0(o,n,i,e));L0(r,n,i,e)}});function L0(e,t,n,i){if(!e){const r={code:"custom",input:n,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(nc(r))}}var D0;class JA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const i=n[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 n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const i={...this.get(n)??{}};delete i.id;const r={...i,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function eI(){return new JA}(D0=globalThis).__zod_globalRegistry??(D0.__zod_globalRegistry=eI());const Ll=globalThis.__zod_globalRegistry;function tI(e,t){return new e({type:"string",...Qe(t)})}function nI(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Qe(t)})}function F0(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Qe(t)})}function sI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Qe(t)})}function iI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Qe(t)})}function rI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Qe(t)})}function aI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Qe(t)})}function xN(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Qe(t)})}function oI(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Qe(t)})}function lI(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Qe(t)})}function cI(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Qe(t)})}function uI(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Qe(t)})}function dI(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Qe(t)})}function hI(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Qe(t)})}function fI(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Qe(t)})}function mI(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Qe(t)})}function pI(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Qe(t)})}function gI(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Qe(t)})}function xI(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Qe(t)})}function vI(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Qe(t)})}function yI(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Qe(t)})}function bI(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Qe(t)})}function kI(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Qe(t)})}function NI(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Qe(t)})}function jI(e,t){return new e({type:"string",format:"date",check:"string_format",...Qe(t)})}function wI(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Qe(t)})}function SI(e,t){return new e({type:"string",format:"duration",check:"string_format",...Qe(t)})}function _I(e,t){return new e({type:"number",checks:[],...Qe(t)})}function EI(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Qe(t)})}function CI(e,t){return new e({type:"boolean",...Qe(t)})}function AI(e,t){return new e({type:"null",...Qe(t)})}function II(e){return new e({type:"unknown"})}function TI(e,t){return new e({type:"never",...Qe(t)})}function U0(e,t){return new cN({check:"less_than",...Qe(t),value:e,inclusive:!1})}function Mf(e,t){return new cN({check:"less_than",...Qe(t),value:e,inclusive:!0})}function B0(e,t){return new uN({check:"greater_than",...Qe(t),value:e,inclusive:!1})}function Rf(e,t){return new uN({check:"greater_than",...Qe(t),value:e,inclusive:!0})}function H0(e,t){return new WC({check:"multiple_of",...Qe(t),value:e})}function vN(e,t){return new qC({check:"max_length",...Qe(t),maximum:e})}function od(e,t){return new GC({check:"min_length",...Qe(t),minimum:e})}function yN(e,t){return new KC({check:"length_equals",...Qe(t),length:e})}function $I(e,t){return new YC({check:"string_format",format:"regex",...Qe(t),pattern:e})}function MI(e){return new XC({check:"string_format",format:"lowercase",...Qe(e)})}function RI(e){return new QC({check:"string_format",format:"uppercase",...Qe(e)})}function OI(e,t){return new JC({check:"string_format",format:"includes",...Qe(t),includes:e})}function PI(e,t){return new eA({check:"string_format",format:"starts_with",...Qe(t),prefix:e})}function zI(e,t){return new tA({check:"string_format",format:"ends_with",...Qe(t),suffix:e})}function Go(e){return new nA({check:"overwrite",tx:e})}function LI(e){return Go(t=>t.normalize(e))}function DI(){return Go(e=>e.trim())}function FI(){return Go(e=>e.toLowerCase())}function UI(){return Go(e=>e.toUpperCase())}function BI(){return Go(e=>q1(e))}function HI(e,t,n){return new e({type:"array",element:t,...Qe(n)})}function ZI(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Qe(n)})}function WI(e,t){const n=VI(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(nc(r,i.value,n._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=n),o.continue??(o.continue=!n._zod.def.abort),i.issues.push(nc(o))}},e(i.value,i)),t);return n}function VI(e,t){const n=new ws({check:"custom",...Qe(t)});return n._zod.check=e,n}function bN(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)??Ll,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 kn(e,t,n={path:[],schemaPath:[]}){var m,g;var i;const r=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const c={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,c);const u=(g=(m=e._zod).toJSONSchema)==null?void 0:g.call(m);if(u)c.schema=u;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,p);else{const y=c.schema,S=t.processors[r.type];if(!S)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);S(e,t,y,p)}const x=e._zod.parent;x&&(c.ref||(c.ref=x),kn(x,t,p),t.seen.get(x).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Object.assign(c.schema,d),t.io==="input"&&ss(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&"_prefault"in c.schema&&((i=c.schema).default??(i.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function kN(e,t){var c,u,d,h;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const m of e.seen.entries()){const g=(c=e.metadataRegistry.get(m[0]))==null?void 0:c.id;if(g){const p=i.get(g);if(p&&p!==m[0])throw new Error(`Duplicate schema id "${g}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(g,m[0])}}const r=m=>{var S;const g=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const N=(S=e.external.registry.get(m[0]))==null?void 0:S.id,k=e.external.uri??(j=>j);if(N)return{ref:k(N)};const E=m[1].defId??m[1].schema.id??`schema${e.counter++}`;return m[1].defId=E,{defId:E,ref:`${k("__shared")}#/${g}/${E}`}}if(m[1]===n)return{ref:"#"};const x=`#/${g}/`,y=m[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:x+y}},o=m=>{if(m[1].schema.$ref)return;const g=m[1],{ref:p,defId:x}=r(m);g.def={...g.schema},x&&(g.defId=x);const y=g.schema;for(const S in y)delete y[S];y.$ref=p};if(e.cycles==="throw")for(const m of e.seen.entries()){const g=m[1];if(g.cycle)throw new Error(`Cycle detected: #/${(u=g.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 g=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(g.cycle){o(m);continue}if(g.count>1&&e.reused==="ref"){o(m);continue}}}function NN(e,t){var u,d,h,m;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=g=>{const p=e.seen.get(g);if(p.ref===null)return;const x=p.def??p.schema,y={...x},S=p.ref;if(p.ref=null,S){i(S);const k=e.seen.get(S),E=k.schema;if(E.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(x.allOf=x.allOf??[],x.allOf.push(E)):Object.assign(x,E),Object.assign(x,y),g._zod.parent===S)for(const A in x)A==="$ref"||A==="allOf"||A in y||delete x[A];if(E.$ref&&k.def)for(const A in x)A==="$ref"||A==="allOf"||A in k.def&&JSON.stringify(x[A])===JSON.stringify(k.def[A])&&delete x[A]}const N=g._zod.parent;if(N&&N!==S){i(N);const k=e.seen.get(N);if(k!=null&&k.schema.$ref&&(x.$ref=k.schema.$ref,k.def))for(const E in x)E==="$ref"||E==="allOf"||E in k.def&&JSON.stringify(x[E])===JSON.stringify(k.def[E])&&delete x[E]}e.override({zodSchema:g,jsonSchema:x,path:p.path??[]})};for(const g of[...e.seen.entries()].reverse())i(g[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 g=(d=e.external.registry.get(t))==null?void 0:d.id;if(!g)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(g)}Object.assign(r,n.def??n.schema);const o=(h=e.metadataRegistry.get(t))==null?void 0:h.id;o!==void 0&&r.id===o&&delete r.id;const c=((m=e.external)==null?void 0:m.defs)??{};for(const g of e.seen.entries()){const p=g[1];p.def&&p.defId&&(p.def.id===p.defId&&delete p.def.id,c[p.defId]=p.def)}e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?r.$defs=c:r.definitions=c);try{const g=JSON.parse(JSON.stringify(r));return Object.defineProperty(g,"~standard",{value:{...t["~standard"],jsonSchema:{input:ld(t,"input",e.processors),output:ld(t,"output",e.processors)}},enumerable:!1,writable:!1}),g}catch{throw new Error("Error converting schema to JSON.")}}function ss(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return ss(i.element,n);if(i.type==="set")return ss(i.valueType,n);if(i.type==="lazy")return ss(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return ss(i.innerType,n);if(i.type==="intersection")return ss(i.left,n)||ss(i.right,n);if(i.type==="record"||i.type==="map")return ss(i.keyType,n)||ss(i.valueType,n);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ss(i.in,n)||ss(i.out,n);if(i.type==="object"){for(const r in i.shape)if(ss(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(const r of i.options)if(ss(r,n))return!0;return!1}if(i.type==="tuple"){for(const r of i.items)if(ss(r,n))return!0;return!!(i.rest&&ss(i.rest,n))}return!1}const qI=(e,t={})=>n=>{const i=bN({...n,processors:t});return kn(e,i),kN(i,e),NN(i,e)},ld=(e,t,n={})=>i=>{const{libraryOptions:r,target:o}=i??{},c=bN({...r??{},target:o,io:t,processors:n});return kn(e,c),kN(c,e),NN(c,e)},GI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},KI=(e,t,n,i)=>{const r=n;r.type="string";const{minimum:o,maximum:c,format:u,patterns:d,contentEncoding:h}=e._zod.bag;if(typeof o=="number"&&(r.minLength=o),typeof c=="number"&&(r.maxLength=c),u&&(r.format=GI[u]??u,r.format===""&&delete r.format,u==="time"&&delete r.format),h&&(r.contentEncoding=h),d&&d.size>0){const m=[...d];m.length===1?r.pattern=m[0].source:m.length>1&&(r.allOf=[...m.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},YI=(e,t,n,i)=>{const r=n,{minimum:o,maximum:c,format:u,multipleOf:d,exclusiveMaximum:h,exclusiveMinimum:m}=e._zod.bag;typeof u=="string"&&u.includes("int")?r.type="integer":r.type="number";const g=typeof m=="number"&&m>=(o??Number.NEGATIVE_INFINITY),p=typeof h=="number"&&h<=(c??Number.POSITIVE_INFINITY),x=t.target==="draft-04"||t.target==="openapi-3.0";g?x?(r.minimum=m,r.exclusiveMinimum=!0):r.exclusiveMinimum=m:typeof o=="number"&&(r.minimum=o),p?x?(r.maximum=h,r.exclusiveMaximum=!0):r.exclusiveMaximum=h:typeof c=="number"&&(r.maximum=c),typeof d=="number"&&(r.multipleOf=d)},XI=(e,t,n,i)=>{n.type="boolean"},QI=(e,t,n,i)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},JI=(e,t,n,i)=>{n.not={}},eT=(e,t,n,i)=>{},tT=(e,t,n,i)=>{const r=e._zod.def,o=Qk(r.entries);o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),n.enum=o},nT=(e,t,n,i)=>{const r=e._zod.def,o=[];for(const c of r.values)if(c===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof c=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(c))}else o.push(c);if(o.length!==0)if(o.length===1){const c=o[0];n.type=c===null?"null":typeof c,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[c]:n.const=c}else o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),o.every(c=>typeof c=="boolean")&&(n.type="boolean"),o.every(c=>c===null)&&(n.type="null"),n.enum=o},sT=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},iT=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},rT=(e,t,n,i)=>{const r=n,o=e._zod.def,{minimum:c,maximum:u}=e._zod.bag;typeof c=="number"&&(r.minItems=c),typeof u=="number"&&(r.maxItems=u),r.type="array",r.items=kn(o.element,t,{...i,path:[...i.path,"items"]})},aT=(e,t,n,i)=>{var h;const r=n,o=e._zod.def;r.type="object",r.properties={};const c=o.shape;for(const m in c)r.properties[m]=kn(c[m],t,{...i,path:[...i.path,"properties",m]});const u=new Set(Object.keys(c)),d=new Set([...u].filter(m=>{const g=o.shape[m]._zod;return t.io==="input"?g.optin===void 0:g.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=kn(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},oT=(e,t,n,i)=>{const r=e._zod.def,o=r.inclusive===!1,c=r.options.map((u,d)=>kn(u,t,{...i,path:[...i.path,o?"oneOf":"anyOf",d]}));o?n.oneOf=c:n.anyOf=c},lT=(e,t,n,i)=>{const r=e._zod.def,o=kn(r.left,t,{...i,path:[...i.path,"allOf",0]}),c=kn(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(c)?c.allOf:[c]];n.allOf=d},cT=(e,t,n,i)=>{const r=n,o=e._zod.def;r.type="object";const c=o.keyType,u=c._zod.bag,d=u==null?void 0:u.patterns;if(o.mode==="loose"&&d&&d.size>0){const m=kn(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(const g of d)r.patternProperties[g.source]=m}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=kn(o.keyType,t,{...i,path:[...i.path,"propertyNames"]})),r.additionalProperties=kn(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]});const h=c._zod.values;if(h){const m=[...h].filter(g=>typeof g=="string"||typeof g=="number");m.length>0&&(r.required=m)}},uT=(e,t,n,i)=>{const r=e._zod.def,o=kn(r.innerType,t,i),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=r.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},dT=(e,t,n,i)=>{const r=e._zod.def;kn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType},hT=(e,t,n,i)=>{const r=e._zod.def;kn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},fT=(e,t,n,i)=>{const r=e._zod.def;kn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},mT=(e,t,n,i)=>{const r=e._zod.def;kn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType;let c;try{c=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=c},pT=(e,t,n,i)=>{const r=e._zod.def,o=r.in._zod.traits.has("$ZodTransform"),c=t.io==="input"?o?r.out:r.in:r.out;kn(c,t,i);const u=t.seen.get(e);u.ref=c},gT=(e,t,n,i)=>{const r=e._zod.def;kn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,n.readOnly=!0},jN=(e,t,n,i)=>{const r=e._zod.def;kn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType},xT=ke("ZodISODateTime",(e,t)=>{gA.init(e,t),sn.init(e,t)});function vT(e){return NI(xT,e)}const yT=ke("ZodISODate",(e,t)=>{xA.init(e,t),sn.init(e,t)});function bT(e){return jI(yT,e)}const kT=ke("ZodISOTime",(e,t)=>{vA.init(e,t),sn.init(e,t)});function NT(e){return wI(kT,e)}const jT=ke("ZodISODuration",(e,t)=>{yA.init(e,t),sn.init(e,t)});function wT(e){return SI(jT,e)}const ST=(e,t)=>{nN.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>oC(e,n)},flatten:{value:n=>aC(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Fm,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Fm,2)}},isEmpty:{get(){return e.issues.length===0}}})},ei=ke("ZodError",ST,{Parent:Error}),_T=Jp(ei),ET=eg(ei),CT=Md(ei),AT=Rd(ei),IT=uC(ei),TT=dC(ei),$T=hC(ei),MT=fC(ei),RT=mC(ei),OT=pC(ei),PT=gC(ei),zT=xC(ei),Z0=new WeakMap;function yc(e,t,n){const i=Object.getPrototypeOf(e);let r=Z0.get(i);if(r||(r=new Set,Z0.set(i,r)),!r.has(t)){r.add(t);for(const o in n){const c=n[o];Object.defineProperty(i,o,{configurable:!0,enumerable:!1,get(){const u=c.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:u}),u},set(u){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:u})}})}}}const Qt=ke("ZodType",(e,t)=>(Yt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ld(e,"input"),output:ld(e,"output")}}),e.toJSONSchema=qI(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,i)=>_T(e,n,i,{callee:e.parse}),e.safeParse=(n,i)=>CT(e,n,i),e.parseAsync=async(n,i)=>ET(e,n,i,{callee:e.parseAsync}),e.safeParseAsync=async(n,i)=>AT(e,n,i),e.spa=e.safeParseAsync,e.encode=(n,i)=>IT(e,n,i),e.decode=(n,i)=>TT(e,n,i),e.encodeAsync=async(n,i)=>$T(e,n,i),e.decodeAsync=async(n,i)=>MT(e,n,i),e.safeEncode=(n,i)=>RT(e,n,i),e.safeDecode=(n,i)=>OT(e,n,i),e.safeEncodeAsync=async(n,i)=>PT(e,n,i),e.safeDecodeAsync=async(n,i)=>zT(e,n,i),yc(e,"ZodType",{check(...n){const i=this.def;return this.clone(ta(i,{checks:[...i.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,i){return na(this,n,i)},brand(){return this},register(n,i){return n.add(this,i),this},refine(n,i){return this.check(I$(n,i))},superRefine(n,i){return this.check(T$(n,i))},overwrite(n){return this.check(Go(n))},optional(){return G0(this)},exactOptional(){return x$(this)},nullable(){return K0(this)},nullish(){return G0(K0(this))},nonoptional(n){return j$(this,n)},array(){return de(this)},or(n){return Do([this,n])},and(n){return h$(this,n)},transform(n){return Y0(this,p$(n))},default(n){return b$(this,n)},prefault(n){return N$(this,n)},catch(n){return S$(this,n)},pipe(n){return Y0(this,n)},readonly(){return C$(this)},describe(n){const i=this.clone();return Ll.add(i,{description:n}),i},meta(...n){if(n.length===0)return Ll.get(this);const i=this.clone();return Ll.add(i,n[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=Ll.get(e))==null?void 0:n.description},configurable:!0}),e)),wN=ke("_ZodString",(e,t)=>{tg.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(i,r,o)=>KI(e,i,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,yc(e,"_ZodString",{regex(...i){return this.check($I(...i))},includes(...i){return this.check(OI(...i))},startsWith(...i){return this.check(PI(...i))},endsWith(...i){return this.check(zI(...i))},min(...i){return this.check(od(...i))},max(...i){return this.check(vN(...i))},length(...i){return this.check(yN(...i))},nonempty(...i){return this.check(od(1,...i))},lowercase(i){return this.check(MI(i))},uppercase(i){return this.check(RI(i))},trim(){return this.check(DI())},normalize(...i){return this.check(LI(...i))},toLowerCase(){return this.check(FI())},toUpperCase(){return this.check(UI())},slugify(){return this.check(BI())}})}),LT=ke("ZodString",(e,t)=>{tg.init(e,t),wN.init(e,t),e.email=n=>e.check(nI(DT,n)),e.url=n=>e.check(xN(SN,n)),e.jwt=n=>e.check(kI(e$,n)),e.emoji=n=>e.check(oI(FT,n)),e.guid=n=>e.check(F0(W0,n)),e.uuid=n=>e.check(sI(Au,n)),e.uuidv4=n=>e.check(iI(Au,n)),e.uuidv6=n=>e.check(rI(Au,n)),e.uuidv7=n=>e.check(aI(Au,n)),e.nanoid=n=>e.check(lI(UT,n)),e.guid=n=>e.check(F0(W0,n)),e.cuid=n=>e.check(cI(BT,n)),e.cuid2=n=>e.check(uI(HT,n)),e.ulid=n=>e.check(dI(ZT,n)),e.base64=n=>e.check(vI(XT,n)),e.base64url=n=>e.check(yI(QT,n)),e.xid=n=>e.check(hI(WT,n)),e.ksuid=n=>e.check(fI(VT,n)),e.ipv4=n=>e.check(mI(qT,n)),e.ipv6=n=>e.check(pI(GT,n)),e.cidrv4=n=>e.check(gI(KT,n)),e.cidrv6=n=>e.check(xI(YT,n)),e.e164=n=>e.check(bI(JT,n)),e.datetime=n=>e.check(vT(n)),e.date=n=>e.check(bT(n)),e.time=n=>e.check(NT(n)),e.duration=n=>e.check(wT(n))});function w(e){return tI(LT,e)}const sn=ke("ZodStringFormat",(e,t)=>{Xt.init(e,t),wN.init(e,t)}),DT=ke("ZodEmail",(e,t)=>{oA.init(e,t),sn.init(e,t)}),W0=ke("ZodGUID",(e,t)=>{rA.init(e,t),sn.init(e,t)}),Au=ke("ZodUUID",(e,t)=>{aA.init(e,t),sn.init(e,t)}),SN=ke("ZodURL",(e,t)=>{lA.init(e,t),sn.init(e,t)});function Bm(e){return xN(SN,e)}const FT=ke("ZodEmoji",(e,t)=>{cA.init(e,t),sn.init(e,t)}),UT=ke("ZodNanoID",(e,t)=>{uA.init(e,t),sn.init(e,t)}),BT=ke("ZodCUID",(e,t)=>{dA.init(e,t),sn.init(e,t)}),HT=ke("ZodCUID2",(e,t)=>{hA.init(e,t),sn.init(e,t)}),ZT=ke("ZodULID",(e,t)=>{fA.init(e,t),sn.init(e,t)}),WT=ke("ZodXID",(e,t)=>{mA.init(e,t),sn.init(e,t)}),VT=ke("ZodKSUID",(e,t)=>{pA.init(e,t),sn.init(e,t)}),qT=ke("ZodIPv4",(e,t)=>{bA.init(e,t),sn.init(e,t)}),GT=ke("ZodIPv6",(e,t)=>{kA.init(e,t),sn.init(e,t)}),KT=ke("ZodCIDRv4",(e,t)=>{NA.init(e,t),sn.init(e,t)}),YT=ke("ZodCIDRv6",(e,t)=>{jA.init(e,t),sn.init(e,t)}),XT=ke("ZodBase64",(e,t)=>{wA.init(e,t),sn.init(e,t)}),QT=ke("ZodBase64URL",(e,t)=>{_A.init(e,t),sn.init(e,t)}),JT=ke("ZodE164",(e,t)=>{EA.init(e,t),sn.init(e,t)}),e$=ke("ZodJWT",(e,t)=>{AA.init(e,t),sn.init(e,t)}),_N=ke("ZodNumber",(e,t)=>{hN.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(i,r,o)=>YI(e,i,r),yc(e,"ZodNumber",{gt(i,r){return this.check(B0(i,r))},gte(i,r){return this.check(Rf(i,r))},min(i,r){return this.check(Rf(i,r))},lt(i,r){return this.check(U0(i,r))},lte(i,r){return this.check(Mf(i,r))},max(i,r){return this.check(Mf(i,r))},int(i){return this.check(V0(i))},safe(i){return this.check(V0(i))},positive(i){return this.check(B0(0,i))},nonnegative(i){return this.check(Rf(0,i))},negative(i){return this.check(U0(0,i))},nonpositive(i){return this.check(Mf(0,i))},multipleOf(i,r){return this.check(H0(i,r))},step(i,r){return this.check(H0(i,r))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function oe(e){return _I(_N,e)}const t$=ke("ZodNumberFormat",(e,t)=>{IA.init(e,t),_N.init(e,t)});function V0(e){return EI(t$,e)}const n$=ke("ZodBoolean",(e,t)=>{TA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>XI(e,n,i)});function be(e){return CI(n$,e)}const s$=ke("ZodNull",(e,t)=>{$A.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>QI(e,n,i)});function i$(e){return AI(s$,e)}const r$=ke("ZodUnknown",(e,t)=>{MA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>eT()});function Hm(){return II(r$)}const a$=ke("ZodNever",(e,t)=>{RA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>JI(e,n,i)});function o$(e){return TI(a$,e)}const l$=ke("ZodArray",(e,t)=>{OA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>rT(e,n,i,r),e.element=t.element,yc(e,"ZodArray",{min(n,i){return this.check(od(n,i))},nonempty(n){return this.check(od(1,n))},max(n,i){return this.check(vN(n,i))},length(n,i){return this.check(yN(n,i))},unwrap(){return this.element}})});function de(e,t){return HI(l$,e,t)}const c$=ke("ZodObject",(e,t)=>{zA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>aT(e,n,i,r),Mt(e,"shape",()=>t.shape),yc(e,"ZodObject",{keyof(){return Pe(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:Hm()})},loose(){return this.clone({...this._zod.def,catchall:Hm()})},strict(){return this.clone({...this._zod.def,catchall:o$()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return eC(this,n)},safeExtend(n){return tC(this,n)},merge(n){return nC(this,n)},pick(n){return Q1(this,n)},omit(n){return J1(this,n)},partial(...n){return sC(CN,this,n[0])},required(...n){return iC(AN,this,n[0])}})});function R(e,t){const n={type:"object",shape:e??{},...Qe(t)};return new c$(n)}const EN=ke("ZodUnion",(e,t)=>{pN.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>oT(e,n,i,r),e.options=t.options});function Do(e,t){return new EN({type:"union",options:e,...Qe(t)})}const u$=ke("ZodDiscriminatedUnion",(e,t)=>{EN.init(e,t),LA.init(e,t)});function Ua(e,t,n){return new u$({type:"union",options:t,discriminator:e,...Qe(n)})}const d$=ke("ZodIntersection",(e,t)=>{DA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>lT(e,n,i,r)});function h$(e,t){return new d$({type:"intersection",left:e,right:t})}const q0=ke("ZodRecord",(e,t)=>{FA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>cT(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ei(e,t,n){return!t||!t._zod?new q0({type:"record",keyType:w(),valueType:e,...Qe(t)}):new q0({type:"record",keyType:e,valueType:t,...Qe(n)})}const Zm=ke("ZodEnum",(e,t)=>{UA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(i,r,o)=>tT(e,i,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{const o={};for(const c of i)if(n.has(c))o[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new Zm({...t,checks:[],...Qe(r),entries:o})},e.exclude=(i,r)=>{const o={...t.entries};for(const c of i)if(n.has(c))delete o[c];else throw new Error(`Key ${c} not found in enum`);return new Zm({...t,checks:[],...Qe(r),entries:o})}});function Pe(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Zm({type:"enum",entries:n,...Qe(t)})}const f$=ke("ZodLiteral",(e,t)=>{BA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>nT(e,n,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 dt(e,t){return new f$({type:"literal",values:Array.isArray(e)?e:[e],...Qe(t)})}const m$=ke("ZodTransform",(e,t)=>{HA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>iT(e,n),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Xk(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(nc(o,n.value,t));else{const c=o;c.fatal&&(c.continue=!1),c.code??(c.code="custom"),c.input??(c.input=n.value),c.inst??(c.inst=e),n.issues.push(nc(c))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(o=>(n.value=o,n.fallback=!0,n)):(n.value=r,n.fallback=!0,n)}});function p$(e){return new m$({type:"transform",transform:e})}const CN=ke("ZodOptional",(e,t)=>{gN.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jN(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function G0(e){return new CN({type:"optional",innerType:e})}const g$=ke("ZodExactOptional",(e,t)=>{ZA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jN(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function x$(e){return new g$({type:"optional",innerType:e})}const v$=ke("ZodNullable",(e,t)=>{WA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>uT(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function K0(e){return new v$({type:"nullable",innerType:e})}const y$=ke("ZodDefault",(e,t)=>{VA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>hT(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function b$(e,t){return new y$({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():eN(t)}})}const k$=ke("ZodPrefault",(e,t)=>{qA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fT(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function N$(e,t){return new k$({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():eN(t)}})}const AN=ke("ZodNonOptional",(e,t)=>{GA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>dT(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function j$(e,t){return new AN({type:"nonoptional",innerType:e,...Qe(t)})}const w$=ke("ZodCatch",(e,t)=>{KA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mT(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function S$(e,t){return new w$({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const _$=ke("ZodPipe",(e,t)=>{YA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>pT(e,n,i,r),e.in=t.in,e.out=t.out});function Y0(e,t){return new _$({type:"pipe",in:e,out:t})}const E$=ke("ZodReadonly",(e,t)=>{XA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gT(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function C$(e){return new E$({type:"readonly",innerType:e})}const A$=ke("ZodCustom",(e,t)=>{QA.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>sT(e,n)});function I$(e,t={}){return ZI(A$,e,t)}function T$(e,t){return WI(e,t)}const Of=Ua("type",[R({type:dt("text"),text:w()}),R({type:dt("reasoning"),text:w()}),R({type:dt("image"),name:w().optional(),mediaType:w().optional(),width:oe().optional(),height:oe().optional(),attachmentId:w().optional(),bytes:oe().optional()}),R({type:dt("file"),name:w().optional(),size:oe().optional(),mediaType:w().optional()}),R({type:dt("tool-call"),callId:w(),name:w(),arguments:w()}),R({type:dt("other"),kind:w()})]),X0=R({inputTokens:oe(),outputTokens:oe(),totalTokens:oe().optional(),cacheReadTokens:oe().optional(),cacheWriteTokens:oe().optional(),reasoningTokens:oe().optional()}),Q0=R({firstChunkAt:oe().optional(),firstTokenAt:oe().optional(),lastChunkAt:oe().optional(),tokenChunks:oe()}),J0=R({message:w(),code:w().optional()}),$$=R({kind:w(),message:w().optional()}),M$=R({kind:w(),human:be(),summary:w().optional()}),Rn={seq:oe(),time:oe()},Wm=Ua("type",[R({...Rn,type:dt("turn/start"),turn:oe()}),R({...Rn,type:dt("turn/end"),turn:oe(),reason:$$}),R({...Rn,type:dt("step/start"),turn:oe(),step:oe()}),R({...Rn,type:dt("step/end"),turn:oe(),step:oe()}),R({...Rn,type:dt("user/message"),messageId:w(),content:de(Of),origin:M$,requestId:w().optional(),replacesHistory:be().optional()}),R({...Rn,type:dt("system/message"),turn:oe(),step:oe(),text:w()}),R({...Rn,type:dt("assistant/message"),turn:oe(),step:oe(),messageId:w(),content:de(Of),timing:Q0,usage:X0.optional(),interrupted:be().optional(),provider:w().optional(),model:w().optional()}),R({...Rn,type:dt("assistant/attempt"),turn:oe(),step:oe(),timing:Q0,error:J0.optional()}),R({...Rn,type:dt("tool/call"),turn:oe(),step:oe(),callId:w(),name:w(),arguments:w()}),R({...Rn,type:dt("tool/result"),turn:oe(),step:oe(),callId:w(),isError:be(),content:de(Of),error:J0.optional()}),R({...Rn,type:dt("request/header"),provider:w().optional(),model:w().optional(),reasoningEffort:w().optional(),toolNames:de(w()),reason:w()}),R({...Rn,type:dt("compaction/start"),compactionId:w(),turn:oe().nullable()}),R({...Rn,type:dt("compaction/summary"),compactionId:w(),shadowedTokenCount:oe(),provider:w().optional(),model:w().optional(),usage:X0.optional()}),R({...Rn,type:dt("compaction/end"),compactionId:w(),turn:oe().nullable(),error:w().optional()}),R({...Rn,type:dt("approval/asked"),approvalId:w(),toolName:w(),callId:w().optional(),reason:w().optional()}),R({...Rn,type:dt("approval/decided"),approvalId:w(),outcome:w()}),R({...Rn,type:dt("session/title"),title:w()}),R({...Rn,type:dt("unknown"),upstreamType:w(),data:Hm()})]),IN=Ua("type",[R({type:dt("start"),attemptId:w(),turn:oe(),step:oe(),afterSeq:oe()}),R({type:dt("delta"),attemptId:w(),time:oe(),kind:Pe(["text","reasoning","tool-args"]),index:oe(),text:w(),callId:w().optional(),toolName:w().optional()}),R({type:dt("end"),attemptId:w(),outcome:Pe(["committed","abandoned"]),seq:oe().optional()})]),R$=R({attemptId:w(),turn:oe(),step:oe(),afterSeq:oe(),deltas:de(IN.options[1])}),O$=R({index:oe().int().min(0),name:w(),running:be(),ready:be(),adb:w().optional()}),P$=R({kind:Pe(["mumu"]),name:w(),manager:w(),version:w().optional(),instances:de(O$),error:w().optional()}),TN=R({mumuManager:w().optional(),instance:oe().int().min(0).max(63),manualAddress:w().regex(/^[\w.-]+:\d{1,5}$/).optional(),adbPath:w().optional(),autoStart:be(),bootTimeoutSeconds:oe().int().min(30).max(900)});R({providers:de(P$),settings:TN,selection:R({label:w(),address:w().optional(),problem:w().optional()})});R({refresh:be().optional()}),R({index:oe().int().min(0).optional()}),R({address:w(),label:w()}),R({index:oe().int().min(0).optional()}),R({}),TN.partial().extend({mumuManager:w().nullable().optional(),manualAddress:w().regex(/^[\w.-]+:\d{1,5}$/).nullable().optional(),adbPath:w().nullable().optional()});R({});const ng=Pe(["maafw-pi","cli","gui-config","generic-process","visual"]),jt=w().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/,"use lowercase letters, digits, dot, dash or underscore (max 64)"),Vl=w().trim().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,"use owner/repo"),Pf=w().trim().regex(/^[A-Za-z0-9_.-]{1,100}$/,"use the resource id, e.g. MAA or BGI"),z$=Ua("kind",[R({kind:dt("github"),repo:w()}),R({kind:dt("mirrorchyan"),rid:w(),platform:be(),os:be().optional(),arch:be().optional()}),R({kind:dt("local"),path:w()})]),L$=R({version:w(),dir:w(),installedAt:oe(),asset:R({name:w(),size:oe()}).optional(),current:be()}),D$=Pe(["ok","missing","outdated","unknown","unsupported"]),F$=R({kind:w(),label:w(),required:w().optional(),status:D$,found:w().optional(),detail:w().optional(),fix:R({kind:Pe(["auto","installer","manual"]),description:w(),needsAdmin:be()}).optional()}),U$=R({checkedAt:oe(),ok:be(),items:de(F$)}),B$=R({executables:de(w()),markers:de(w()),family:ng.optional()}),ey=Pe(["install","pack","known","user"]),H$=R({github:R({repo:w(),from:ey}).optional(),mirrorchyan:R({rid:w(),from:ey}).optional()}),Z$=R({version:w(),from:w()}),W$=R({state:Pe(["running","done","failed"]),at:oe(),text:w().optional(),sessionId:w().optional()}),V$=R({id:w(),name:w(),source:z$,packId:w().optional(),family:ng.optional(),current:w().optional(),dir:w().optional(),versions:de(L$),env:U$.optional(),probe:B$.optional(),update:R({latest:w(),available:be(),checkedAt:oe()}).optional(),channels:H$,known:w().optional(),localVersion:Z$.optional(),undo:R({from:w().optional(),to:w(),at:oe()}).optional(),jobId:w().optional(),addedAt:oe(),summary:W$.optional(),packReview:R({from:w().optional(),to:w()}).optional(),optimize:R({runs:oe(),at:oe().optional(),due:Pe(["runs","updated"]).optional()}).optional()}),q$=R({id:w(),name:w(),description:w().optional(),repo:w().optional(),mirrorchyan:w().optional(),family:ng.optional(),builtin:be(),installed:be(),error:w().optional()}),G$=R({packId:w(),name:w(),builtin:be(),written:be(),overview:w().optional(),tasks:de(R({id:w(),title:w(),description:w().optional(),utterances:de(w()),input:Pe(["desktop","window","adb","none"]),expectedDuration:w().optional(),params:de(R({name:w(),type:Pe(["string","integer","number","boolean"]),description:w().optional(),default:w().optional(),values:w().optional()}))})),setup:de(w()),checks:de(w()),features:de(R({title:w(),description:w().optional(),enable:w(),config:de(R({file:w(),key:w(),value:w()})),tasks:de(w())})),config:de(R({file:w(),about:w().optional(),keys:de(R({key:w(),meaning:w(),values:w().optional(),default:w().optional(),advice:w().optional()})),changes:de(R({key:w(),value:w(),note:w().optional(),when:w().optional(),tasks:de(w())}))})),troubleshooting:de(R({problem:w(),cause:w().optional(),fix:w()}))});R({rid:w(),version:w(),platform:be(),os:be().optional(),arch:be().optional(),name:w().optional(),description:w().optional(),repo:w().optional()});const Vm=R({rid:w(),name:w(),description:w(),repo:w().optional(),url:w().optional(),installed:be(),known:be()}),K$=R({id:w(),name:w(),repo:w().optional(),mirrorchyan:w().optional(),installed:be()}),Y$=R({name:w(),size:oe(),downloadUrl:w(),digest:w().optional()}),X$=R({tag:w(),name:w(),prerelease:be(),publishedAt:w().optional(),url:w().optional(),assets:de(Y$),suggestedAsset:w().optional(),notes:w().optional()}),Q$=Pe(["queued","resolving","downloading","verifying","extracting","checking","running","done","failed","cancelled"]),J$=R({sessionId:w(),state:Pe(["running","failed"]),reason:w().optional()}),eM=R({scriptId:w(),name:w(),kind:Pe(["nsis","inno","kachina"]),version:w(),dir:w(),update:be(),at:oe(),agent:J$.optional()}),tM=R({id:w(),kind:Pe(["install","update","env-fix"]),scriptId:w(),phase:Q$,message:w().optional(),received:oe().optional(),total:oe().optional(),version:w().optional(),error:w().optional(),setup:R({kind:Pe(["nsis","inno","kachina"]),dir:w(),sessionId:w().optional()}).optional(),startedAt:oe(),endedAt:oe().optional()}),nM=Pe(["auto","ask","off"]),ty=R({apiBase:Bm({protocol:/^https?$/}),downloadMirror:w().trim().max(300),mirrorFallback:be(),tokenRef:w().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),keepVersions:oe().int().min(1).max(10),includePrereleases:be(),cdkRef:w().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),autoUpdate:nM});R({});R({id:jt});R({scripts:de(V$),packs:de(q$),known:de(K$),setups:de(eM).default([]),toolsDir:w()}),R({guide:G$.nullable()}),R({query:w().trim().min(1).max(200)}),R({items:de(R({repo:w(),description:w().optional(),stars:oe(),packId:w().optional()}))}),R({repo:Vl,limit:oe().int().min(1).max(30).optional()}),R({repo:w(),packId:w().optional(),releases:de(X$)}),R({repo:Vl.optional(),mirrorchyan:Pf.optional(),tag:w().min(1).max(200).optional(),asset:w().min(1).max(300).optional(),branch:w().min(1).max(200).optional(),id:jt.optional()}).refine(e=>e.repo===void 0!=(e.mirrorchyan===void 0),"give either repo or mirrorchyan"),R({jobId:w(),scriptId:w()}),R({current:w().optional(),latest:w(),available:be()}),R({jobId:w().optional(),upToDate:be()}),R({id:jt,repo:Vl.nullable().optional(),mirrorchyan:Pf.nullable().optional(),reset:de(Pe(["repo","mirrorchyan"])).optional()}),R({items:de(Vm.extend({by:Pe(["repo","name"])})),from:Pe(["mirrorchyan","builtin"])}),R({rid:Pf}),R({query:w().trim().max(100)}),R({items:de(Vm),from:Pe(["mirrorchyan","builtin"]),fetchedAt:oe().optional()}),R({id:w(),decision:Pe(["check","keep"])}),R({sessionId:w().optional()}),R({id:jt,version:w().optional()}),R({dir:w()}),R({sessionId:w()}),R({path:w().trim().min(1).max(1e3),id:jt.optional(),name:w().trim().min(1).max(100).optional(),packId:jt.optional()}),R({id:jt,decision:Pe(["run","keep"])}),R({sessionId:w().optional()}),R({id:jt}),R({sessionId:w()}),R({id:jt,deleteFiles:be().optional()}),R({id:jt,kind:w().min(1).max(64)}),R({jobId:w()}),R({items:de(tM)}),R({jobId:w()}),ty.extend({tokenConfigured:be(),cdkConfigured:be()}),R({ok:be(),message:w(),expiresAt:oe().optional()}),ty.partial();R({id:w().optional()});const sM=R({packId:w(),scriptId:w(),proposedAt:oe(),sessionId:w().optional(),summary:w(),docs:de(R({source:w(),used:w()})).optional(),noDocs:w().optional(),manifest:w(),skill:w(),current:R({manifest:w(),skill:w().optional(),builtin:be()}).optional(),tasks:de(R({id:w(),title:w()}))}),iM=R({id:w(),at:oe().optional(),builtin:be().optional(),tasks:de(R({id:w(),title:w()}))});R({packId:jt}),R({items:de(iM)}),R({packId:jt,version:w().min(1).max(64)}),R({}),R({scriptId:jt.optional()}),R({items:de(sM)}),R({packId:jt}),R({packId:w(),dir:w()}),R({packId:jt}),R({});R({packId:w().optional()});const rM=R({scriptId:w(),dir:w(),grantedAt:oe(),expiresAt:oe()});R({}),R({items:de(rM),blocked:oe()}),R({scriptId:jt,minutes:oe().int().min(1).max(240)}),R({scriptId:jt}),R({});R({}),R({toolName:w(),target:w(),sessionId:w().optional(),at:oe()});const aM=Pe(["error","warning","failed","stalled","overtime"]),oM=R({at:oe(),action:Pe(["reconnect-adb","restart","stop","screenshot","notify","resolve","intervene"]),by:Pe(["rule","user","agent"]),ok:be(),detail:w()}),lM=R({id:w(),runId:w(),scriptId:w(),scriptName:w(),taskId:w(),taskTitle:w(),kind:aM,severity:Pe(["warning","error"]),tag:w(),title:w(),detail:w(),lines:de(w()),status:Pe(["open","resolved"]),resolution:w().optional(),createdAt:oe(),updatedAt:oe(),steps:de(oM),screenshot:be()}),cM=R({seconds:oe().int().min(5).max(24*3600),by:Pe(["learned","agent","user"]),note:w().max(300).optional(),samples:de(oe().min(0)).max(10).default([]),at:oe()}),uM=R({defaultStallSeconds:oe().int().min(0).max(24*3600),scriptStall:Ei(w(),cM),notifyWarnings:be(),screenshot:be(),intervene:Pe(["off","diagnose","act"]),interventionsPerDay:oe().int().min(0).max(200)});R({status:Pe(["open","all"]).optional(),runId:w().optional(),limit:oe().int().min(1).max(500).optional()}),R({items:de(lM)}),R({incidentId:w(),action:Pe(["stop","retry","resolve","resume"])}),R({incidentId:w()}),R({mime:dt("image/png"),data:w()}),R({}),uM.partial();const dM="ADG_FEISHU_APP_SECRET",hM="ADG_QQBOT_APP_SECRET",qm=R({id:w(),label:w(),ok:be().nullable(),detail:w().optional()}),fM=R({id:w(),name:w(),state:Pe(["off","connecting","ready","error"]),detail:w().optional(),recipients:oe().int().min(0),checks:de(qm)}),mM=R({openId:w().min(1),name:w().optional(),addedAt:oe()}),pM=R({enabled:be(),appId:w().optional(),domain:Pe(["feishu","lark"]),allowedUsers:de(mM),chatId:w().optional(),otherApprovals:be()}),gM=R({openId:w(),at:oe(),text:w()});R({settings:pM,secretConfigured:be(),pending:de(gM)});const xM=R({openId:w().min(1),name:w().optional(),addedAt:oe()}),vM=R({enabled:be(),appId:w().optional(),allowedUsers:de(xM)}),yM=R({openId:w(),at:oe(),text:w()});R({settings:vM,secretConfigured:be(),pending:de(yM)});const $N=R({id:w(),title:w(),text:w(),severity:Pe(["info","success","warning","error"]),at:oe(),actions:de(R({id:w(),label:w(),style:Pe(["primary","danger","default"]).optional()})),channels:de(w()),image:be().optional(),done:w().optional(),acted:R({by:w(),label:w(),result:w(),at:oe()}).optional()});R({}),R({channels:de(fM)}),R({}),R({items:de(R({sessionId:w(),channel:w(),user:w()}))}),R({}),R({items:de($N)}),R({noticeId:w(),actionId:w()}),R({result:w()}),R({channel:w().optional()}),R({sent:de(w()),failed:de(R({channel:w(),error:w()}))}),R({}),R({enabled:be().optional(),appId:w().trim().regex(/^cli_[0-9a-fA-F]{16}$/,"App ID 是 cli_ 加 16 位字母数字,在「凭证与基础信息」里复制").nullable().optional(),domain:Pe(["feishu","lark"]).optional(),chatId:w().trim().regex(/^oc_[A-Za-z0-9]+$/,"群 ID 以 oc_ 开头").nullable().optional(),otherApprovals:be().optional()}),R({openId:w().trim().regex(/^ou_[A-Za-z0-9]+$/,"open_id 以 ou_ 开头"),name:w().max(40).optional()}),R({openId:w()}),R({}),R({checks:de(qm)}),R({}),R({enabled:be().optional(),appId:w().trim().regex(/^\d{6,20}$/,"AppID 是一串数字,在 QQ 开放平台「开发设置」里复制").nullable().optional()}),R({openId:w().trim().regex(/^[0-9A-Za-z_-]{8,64}$/,"user_openid 是一串字母数字(机器人回复你的那条消息里有)"),name:w().max(40).optional()}),R({openId:w()}),R({}),R({checks:de(qm)});R({}),R({item:$N});const ja=w().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,"小写字母、数字和短横线").max(64),sc=w().regex(/^[A-Za-z0-9_-]{1,40}$/),sg=w().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"时间写成 HH:MM,例如 04:30"),MN=R({retries:oe().int().min(0).max(5).default(0),then:Pe(["continue","stop"]).default("continue")}),va={id:sc,title:w().max(60).optional(),position:R({x:oe(),y:oe()}).optional(),onFailure:MN.optional(),waitForAll:be().optional()},bM=Ua("kind",[R({...va,kind:dt("script-task"),scriptId:jt,taskId:w().min(1).max(64),params:Ei(w(),Do([w(),oe(),be()])).default({}),profile:w().min(1).max(64).optional()}),R({...va,kind:dt("agent"),prompt:w().min(1).max(4e3)}),R({...va,kind:dt("wait"),minutes:oe().int().min(1).max(1440).optional(),until:sg.optional()}).refine(e=>e.minutes===void 0!=(e.until===void 0),"等待节点写分钟数或时间其中一个"),R({...va,kind:dt("notify"),text:w().min(1).max(2e3)}),R({...va,kind:dt("gate"),text:w().min(1).max(2e3)}),R({...va,kind:dt("start")}),R({...va,kind:dt("end")})]);function Hi(e){return e.kind==="start"||e.kind==="end"}function kM(e){const t=e.nodes.some(p=>p.kind==="start"),n=e.nodes.some(p=>p.kind==="end");if(t&&n)return e;const i=e.nodes.filter(p=>!Hi(p)),r=new Set(e.nodes.map(p=>p.id)),o=p=>{let x=p;for(let y=2;r.has(x);y++)x=`${p}${y}`;return r.add(x),x},c=i.filter(p=>p.position!==void 0).map(p=>p.position),u=Math.min(...c.map(p=>p.x)),d=Math.max(...c.map(p=>p.x)),h=c.length===0?40:Math.round(c.reduce((p,x)=>p+x.y,0)/c.length),m=[...e.nodes],g=[...e.edges];if(!t){const p=o("start");m.unshift({id:p,kind:"start",...c.length===0?{}:{position:{x:u-240,y:h}}});for(const x of i)e.edges.some(y=>y.to===x.id)||g.push({from:p,to:x.id,when:"success"})}if(!n){const p=o("end");m.push({id:p,kind:"end",...c.length===0?{}:{position:{x:d+300,y:h}}});for(const x of i)e.edges.some(y=>y.from===x.id)||g.push({from:x.id,to:p,when:"always"})}return{...e,nodes:m,edges:g}}const NM=R({from:sc,to:sc,when:Pe(["success","failure","always"]).default("success")}),ig=R({enabled:be().default(!1),times:de(sg).max(12).default([]),days:de(oe().int().min(0).max(6)).max(7).default([]),catchUpMinutes:oe().int().min(0).max(720).default(10),after:ja.optional()}),RN=Pe(["none","sleep","hibernate","shutdown"]),zf=R({id:ja,name:w().min(1).max(60),description:w().max(500).optional(),nodes:de(bM).max(60),edges:de(NM).max(200).default([]),onFailure:MN.default({retries:0,then:"continue"}),schedule:ig.default({enabled:!1,times:[],days:[],catchUpMinutes:10}),stopEmulatorAfter:be().default(!1),closeGameAfter:be().default(!1),powerAfter:RN.default("none"),draft:be().optional(),createdAt:oe().optional(),updatedAt:oe().optional()}),jM=R({level:Pe(["error","warning","info"]),nodeId:w().optional(),message:w()}),wM=R({ok:be(),issues:de(jM),serialized:de(R({a:w(),b:w(),resource:w()})),estimateMinutes:oe().optional()}),SM=Pe(["pending","waiting","running","succeeded","failed","skipped","cancelled"]),_M=R({state:SM,detail:w().optional(),runIds:de(w()),attempts:oe().int().min(0),startedAt:oe().optional(),endedAt:oe().optional()}),ON=R({kind:Pe(["manual","schedule","autostart","agent","after"]),detail:w().optional()}),PN=R({id:w(),pipelineId:w(),pipelineName:w(),trigger:ON,from:w().optional(),state:Pe(["running","succeeded","failed","cancelled"]),stopping:w().optional(),nodes:Ei(w(),_M),startedAt:oe(),endedAt:oe().optional(),outcome:w().optional()}),EM=R({id:w(),name:w(),description:w().optional(),nodes:oe(),draft:be(),schedule:ig,updatedAt:oe().optional(),lastRun:PN.pick({id:!0,state:!0,startedAt:!0,endedAt:!0}).optional()}),Dl=w().regex(/^task-[a-z0-9]{4,24}$/),ny=R({id:Dl,agent:w().min(1).max(64),title:w().trim().min(1).max(60),prompt:w().trim().min(1).max(4e3),schedule:ig,createdAt:oe().optional(),updatedAt:oe().optional()}),sy=R({id:w(),taskId:w(),trigger:ON,state:Pe(["running","done","failed"]),outcome:w().optional(),startedAt:oe(),endedAt:oe().optional()}),zN=R({autostart:be(),autostartPipelines:de(ja),autostartDelaySeconds:oe().int().min(0).max(1800),skipIfRanToday:be(),firstStartOnly:be().default(!1),wakeToRun:be().default(!1),powerCountdownSeconds:oe().int().min(10).max(600).default(60)}),LN={agent:w().optional()},CM=R({pipelineId:w(),pipelineName:w(),...LN,slot:w(),at:oe(),outcome:Pe(["fired","missed","skipped","failed"]),detail:w().optional()}),AM=R({awake:be(),pending:R({action:RN.exclude(["none"]),pipelineName:w(),at:oe().optional()}).optional()});R({settings:zN,autostart:R({available:be(),registered:be(),detail:w().optional()}),autostarted:be(),wake:R({available:be(),registered:be(),next:oe().optional(),detail:w().optional()}),power:AM,upcoming:de(R({pipelineId:w(),pipelineName:w(),at:oe(),...LN})),history:de(CM)});R({}),R({items:de(EM)}),R({id:ja}),R({pipeline:zf}),R({pipeline:zf,check:wM}),R({id:ja}),R({}),R({pipeline:zf}),R({id:ja,from:sc.optional()}),R({runId:w()}),R({}),R({pipelineId:ja.optional(),limit:oe().int().min(1).max(100).optional()}),R({items:de(PN)}),R({runId:w(),nodeId:sc,decision:Pe(["continue","stop"])}),R({}),R({}),zN.partial(),R({}),R({}),R({agent:w().optional()}),R({items:de(ny.extend({lastRun:sy.optional()}))}),R({task:ny.extend({id:Dl.optional()})}),R({id:Dl}),R({}),R({id:Dl}),R({id:Dl}),R({items:de(sy)});R({}),R({}),R({});const IM=Pe(["running","resolved","retried","gave-up","taken-over","timeout","failed"]),TM=R({id:w(),incidentId:w().optional(),runId:w().optional(),title:w(),mode:Pe(["diagnose","act"]),state:IM,sessionId:w().optional(),paused:be(),summary:w().optional(),startedAt:oe(),endedAt:oe().optional()});R({limit:oe().int().min(1).max(100).optional()}),R({items:de(TM)}),R({id:w()}),R({id:w(),then:Pe(["resume","restart","stop"])});const iy=R({id:w(),game:w(),name:w(),startsAt:oe().optional(),endsAt:oe().optional(),shopEndsAt:oe().optional(),url:w().optional(),kind:w().optional(),description:w().optional(),cover:w().optional(),site:R({source:w(),name:w(),at:oe()}).optional(),sources:de(R({id:w(),name:w(),at:oe(),web:be(),startsAt:oe().optional(),endsAt:oe().optional(),shopEndsAt:oe().optional(),cover:w().optional()})).optional(),chosen:w().optional(),shown:R({cover:w().optional(),startsAt:w().optional(),endsAt:w().optional()}).optional(),screen:R({at:oe(),remaining:w().optional(),endsAt:oe().optional(),evidence:be(),image:w().optional(),sessionId:w().optional()}).optional(),todo:de(w()),done:de(w()),progress:w().optional(),finished:R({at:oe()}).optional(),mismatch:w().optional(),own:R({at:oe(),fields:de(Pe(["name","startsAt","endsAt","kind","description","url","cover"])),startsAt:oe().optional(),endsAt:oe().optional(),cover:w().optional()}).optional()}),So="@own",ql="@screen",$M=112e5,MM=R({mediaType:Pe(["image/png","image/jpeg","image/gif","image/webp","image/avif"]),data:w().min(1).max($M).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix")}),RM=/^own:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,OM=/^shot:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,PM=R({id:w(),name:w(),homepage:w().optional(),auto:be(),added:be().optional()}),zM=R({id:w(),name:w(),aliases:de(w()),scripts:de(w()),timezone:w(),screen:R({target:Pe(["emulator","window"]),window:w().optional()}).optional(),sources:de(PM),builtin:be(),art:w().optional(),followed:be().optional(),version:R({name:w(),title:w().optional(),startsAt:oe().optional(),endsAt:oe().optional(),cover:w().optional(),source:w(),at:oe()}).optional(),pools:de(R({name:w(),type:w().optional(),startsAt:oe().optional(),endsAt:oe(),cover:w().optional(),up:de(w())})).optional(),refreshed:R({at:oe(),ok:be(),count:oe(),detail:w().optional()}).optional(),reading:R({state:Pe(["running","done","failed"]),at:oe(),sessionId:w().optional(),summary:w().optional()}).optional(),webReading:R({state:Pe(["running","done","failed"]),at:oe(),sessionId:w().optional(),summary:w().optional()}).optional()}),ry=R({report:R({enabled:be(),at:sg,games:de(w()),soonDays:oe().int().min(1).max(30),ai:be()}),followed:de(w())}),LM=R({lastSentAt:oe().optional(),lastDay:w().optional(),lastResult:w().optional(),lastText:w().optional(),next:oe().optional()});R({}),R({games:de(zM),activities:de(iy),settings:ry,report:LM}),R({game:w().optional()}),R({results:de(R({game:w(),ok:be(),count:oe(),detail:w().optional()}))}),R({game:w(),how:Pe(["screen","web"]).optional(),source:w().optional()}),R({sessionId:w()}),R({}),R({title:w(),text:w()}),R({}),R({channels:de(w()),text:w()}),R({report:ry.shape.report.partial().optional()}),R({activityId:w()}),R({mediaType:w(),data:w()}),R({url:w().refine(e=>RM.test(e)||OM.test(e)||/^https?:\/\/\S+$/.test(e),"不是图片地址")}),R({mediaType:w(),data:w()}),R({name:w().min(1).max(60)}),R({sessionId:w()}),R({game:w()}),R({items:de(Vm),from:Pe(["mirrorchyan","builtin"])}),R({game:w(),url:w().url().refine(e=>/^https?:\/\//.test(e),"只能是 http 或 https 网址"),name:w().max(30).optional()}),R({source:w(),sessionId:w()}),R({game:w(),source:w()}),R({}),R({}),R({games:de(R({sra:w(),name:w(),followed:be(),pack:w().optional()}))}),R({sra:w(),follow:be()}),R({}),R({activityId:w(),todo:de(w().min(1).max(80)).max(30).optional(),done:de(w().min(1).max(80)).max(30).optional(),finished:be().optional()}),R({game:w(),activityId:w().optional(),name:w().trim().min(1).max(60).nullable().optional(),startsAt:oe().nullable().optional(),endsAt:oe().nullable().optional(),kind:w().trim().max(20).nullable().optional(),description:w().trim().max(500).nullable().optional(),url:w().trim().refine(e=>e===""||/^https?:\/\/\S+$/.test(e),"只能是 http 或 https 网址").nullable().optional(),cover:i$().optional(),image:MM.optional(),todo:de(w().min(1).max(80)).max(30).optional()}),R({activityId:w(),source:w().nullable()}),R({activityId:w()}),R({activity:iy.optional()}),R({activityId:w()}),R({});R({game:w().optional()});const DN=Pe(["ask","full"]),FN=Pe(["default","allow","ask","deny"]),DM=[{id:"pipelines-edit",title:"编辑流水线和定时",description:"起草流水线,「编排」直接修改、保存流水线(pipeline_save),设定时间(schedule_set),以及 dsh 自己的定时任务。",tools:["pipeline_draft","pipeline_save","schedule_set","schedule_create","schedule_update","schedule_delete"]},{id:"run",title:"运行流水线和脚本",description:"启动、停止流水线和脚本任务。",tools:["pipeline_run","script_run","script_stop"]},{id:"scripts-config",title:"改脚本配置",description:"修改脚本的配置副本、导入配置、新建选项、打开脚本自己的设置界面、设置游戏位置。",tools:["script_config_set","script_config_import","script_choice_create","script_settings","game_path_set"]},{id:"scripts-install",title:"安装、更新、删除脚本",description:"从 GitHub 安装、更新、回滚、删除脚本,运行脚本的安装程序,导入本地脚本,修复运行环境,写、改脚本包(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"]},{id:"web",title:"上网查资料",description:"读网页、搜索。",tools:["web_fetch","web_search"]},{id:"shell",title:"运行命令、改文件",description:"dsh 自带的命令行和文件编辑。只在它请求确认时按这里的设置处理(沙箱里的普通命令不会请求)。",tools:["pwsh","bash","edit","write"],approvalOnly:!0}];R({mode:DN,since:oe().optional(),areas:Ei(w(),FN).default({}),recent:de(R({at:oe(),sessionId:w(),toolName:w(),reason:w().optional()}))});R({}),R({mode:DN}),R({area:w(),policy:FN});const FM=R({label:w(),description:w().optional()}),UM=R({id:w(),question:w(),detail:w().optional(),header:w().optional(),options:de(FM).optional(),multiSelect:be().optional()});R({questionId:w(),sessionId:w(),callId:w().optional(),questions:de(UM)});const UN=R({id:w(),selected:de(w()),custom:w().optional()}),BM=Pe(["answered","cancelled","unavailable"]);R({questionId:w(),answers:de(UN)}),R({});R({questionId:w(),outcome:BM,answers:de(UN).optional()});const HM=R({pid:oe().int(),label:w(),dataDir:w().optional(),startedAt:oe(),warnings:de(w())});R({others:de(HM)});R({});const BN=R({scripts:de(w()).optional(),games:de(w()).optional()}),ay=R({name:w(),description:w(),whenToUse:w().optional(),source:w(),provider:w(),path:w().optional(),modelInvocable:be(),userInvocable:be(),owner:BN.optional(),removable:be().optional()}),HN=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Gm=48;R({}),R({skills:de(ay)}),R({name:w()}),ay.extend({content:w()}),R({name:w().regex(HN).max(Gm),description:w().trim().min(10).max(400),content:w().trim().min(20).max(2e4),scripts:de(w().min(1).max(64)).max(20).optional(),games:de(w().min(1).max(64)).max(20).optional(),replace:be().optional()}),R({name:w(),replaced:be()}),R({name:w()}),R({});R({});const Lf=R({repo:Vl,branch:w().trim().min(1).max(100).regex(/^[\w./-]+$/)}),oy=R({name:w(),description:w(),title:w().optional(),kind:Pe(["game","script","general"]),games:de(w()),scripts:de(w()),repo:w(),path:w(),hash:w(),installed:R({at:oe(),modified:be(),update:be()}).optional(),blocked:w().optional()}),Df=R({name:w().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});R({refresh:be().optional()}),R({items:de(oy),repos:de(Lf),errors:de(w()),fetchedAt:oe().optional()}),Df.extend({repo:Vl.optional()}),Df.extend({resolve:Pe(["keep","replace","merge"]).optional()}),R({state:Pe(["current","updated","kept","conflict","merging"]),item:oy,backup:w().optional(),sessionId:w().optional()}),R({mine:w(),theirs:w()}),R({}),Df.extend({owner:BN.nullable()}),R({}),R({repos:de(Lf).min(1).max(10)}),R({repos:de(Lf)});R({});const rg="你",ZN="(不用告诉用户)",ly=e=>e.replace(/[^\p{Script=Han}a-zA-Z0-9]/gu,"");function ZM(e){return ly(e)===ly(ZN)}const WM="(你这一轮的最后一段回复会作为结论交回去。在那之前要让对方知道的,用 agent_message 的 update 说,马上送到,说几次都行;交回结论以后还有话,同样发到这条线索:你的普通回复对方看不到。)",VM="(做完后你这一轮的最后一段回复会原样交回去:把结论写在那里。)",qM=/^(这件事的线索是 (\S+):做的过程中要问清楚什么,用 agent_message 问,thread 填它;不要猜。)$/,GM=/^(你和.{1,20}之前的来往,/,KM=")";function WN(e){var m;const[t="",...n]=e.split(`
104
+ `),i=/^(你在软件里点的:(.*))$/.exec(t),r=i===null?/^(([^():]{1,20})交给你的事:(.*))$/.exec(t):null;if(i===null&&r===null)return;const o=n[0]===WM||n[0]===VM,c=o?n.slice(1):n,u=(m=qM.exec(c[0]??""))==null?void 0:m[1],d=u===void 0?c:c.slice(1),h=GM.test(d[0]??"")?d.indexOf(KM):-1;return{by:i!==null?rg: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 VN(e){const[t="",...n]=e.split(`
106
+ `),i=/^(「([^」]+)」在线索 (\S+) 里(问你|回答了你|告诉你):(.*))$/.exec(t);if(i===null)return;const r=n.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 qN(e){const[t="",...n]=e.split(`
110
+ `),i=/^(「([^」]+)」(交回了|没有做完)([^()]{1,20}?)交给它的事:(.*))$/.exec(t);if(i===null)return;const r=n.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 YM(e){return e.replace(/\s+/g," ").replace(/[()]/g,t=>t==="("?"(":")").trim()}const cy=/\n\n(这是你在线索 \S+ 上定的提醒:[^)]*)$/;function uy(e){const t=/^\[SCHEDULE REMINDER\]\n[\s\S]*?^reminder_prompt_json: (.*)$/m.exec(e);if(t!==null)return[QM(t[1]).replace(cy,"")];const n=/^\[SCHEDULE REMINDER BATCH\]\n[\s\S]*?^reminders_json: (.*)$/m.exec(e);if(n!==null)try{return JSON.parse(n[1]).map(r=>String(r.reminder_prompt??"").replace(cy,"")).filter(r=>r!=="")}catch{return[]}}function XM(e){return e.length===0?"定时提醒":`定时提醒:${e.map(t=>YM(t)).join(";")}`}function QM(e){try{const t=JSON.parse(e);return typeof t=="string"?t:e}catch{return e}}const JM=Pe(["default","concise","patient","lively","buddy","butler"]),eR=Pe(["plain","same"]),GN=R({style:JM,callUser:w().max(20).optional(),custom:w().optional(),peerStyle:eR.optional()}),tR=GN.partial().extend({name:w().max(20).optional()}),nR=R({persona:GN,agents:Ei(w(),tR)});nR.extend({prompt:w(),prompts:Ei(w(),w())});const dy={default:"",concise:"回答简短直接:先给结论,再给必要的细节;少寒暄,不用表情。",patient:"耐心、讲清楚:每一步说明为什么这么做,用对方听得懂的话,像教一个刚接触的人。",lively:"语气轻松活泼,可以用一点语气词和表情,但信息要准确、不啰嗦。",buddy:"像一起玩游戏的老朋友那样说话:熟悉游戏里的说法,可以适当吐槽和鼓励,但不夸张、不油腻。",butler:"像一位稳重周到的管家:礼貌、条理清楚,主动汇报进度和需要对方决定的事。"};function hy(e,t){const n=Object.entries(e.agents[t]??{}).filter(([,i])=>i!==void 0);return{...e.persona,...Object.fromEntries(n)}}function fy(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()}」。`),dy[e.style]!==""&&t.push(dy[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(`软件约定的固定写法(比如「${ZN}」这一句、线索编号、工具的参数)一字不差照写,不加语气词和表情。`),["# 回复风格",...t,"这些只影响你说话的方式,不改变做事的规则:确认、安全限制和不能做的事都照旧;在飞书里回复也一样。"].join(`
114
+ `))}R({});const sR=80,KN=5,YN=100,iR=30,rR=1,aR=365,oR=[3,7,14,30],Km=R({auto:be(),threshold:oe().int().min(KN).max(YN),lowContext:be(),archiveDays:oe().int().min(rR).max(aR).nullable().default(null)});R({settings:Km,applied:Km});R({}),R({settings:Km});const ya="shared",Ym=Pe(["profile","journal","core"]),ag=2e3,lR=R({agent:w(),sessionId:w(),seq:oe().int().min(0)}),og=600,Ff=R({id:w(),kind:Ym,scope:w(),text:w(),createdAt:w(),updatedAt:w(),by:w(),source:lR.optional()}),cR=R({auto:be(),model:R({provider:w(),model:w(),reasoningEffort:w().optional()}).nullable()}),my=w().trim().min(1).max(og);R({}),R({items:de(Ff)}),R({kind:Ym,scope:w().min(1).max(64),text:my}),R({item:Ff}),R({id:w(),text:my,kind:Ym.optional(),scope:w().min(1).max(64).optional()}),R({item:Ff}),R({}),cR.extend({forced:be().optional()}),R({id:w()}),R({removed:be()});R({});const uR=Pe(["starting","running","stopping","succeeded","failed","cancelled"]),dR=R({type:Pe(["string","integer","number","boolean"]),default:Do([w(),oe(),be()]).optional(),enum:de(Do([w(),oe()])).optional(),description:w().optional(),choices:de(R({value:w(),label:w(),detail:w().optional()})).optional(),canCreate:be().optional()}),hR=R({mode:Pe(["auto","platform","off"]),pcLaunch:Pe(["program","maaend"]).optional(),pcRegion:Pe(["CN","Global","Bilibili","TapTap","Steam","Epic"]).optional(),pcExe:w().optional(),pcProcess:w().optional(),androidPackage:w().optional()});R({settings:hR,game:R({name:w().optional(),androidPackage:w().optional(),pcProcess:w().optional(),selfLaunch:w()}),uses:R({adb:be(),desktop:be()})});const fR=R({id:w(),title:w(),description:w().optional(),utterances:de(w()),params:Ei(w(),dR),input:Pe(["desktop","window","adb","none"]),account:w().optional(),expectedDuration:w().optional()}),Li=w().trim().min(1).max(64),Xm=R({id:w(),name:w(),createdAt:oe().optional()}),XN=R({current:w(),items:de(Xm)}),mR=R({id:w(),scriptId:w(),scriptName:w(),taskId:w(),taskTitle:w(),params:Ei(w(),Do([w(),oe(),be()])),state:uR,outcome:w().optional(),startedAt:oe(),endedAt:oe().optional(),exitCode:oe().optional(),command:de(w()),resources:de(w()),tags:de(w()),warnings:de(w()),kind:Pe(["task","settings"]),retryOf:w().optional(),halted:be().optional(),profile:w().optional(),profileName:w().optional()}),QN=R({at:oe(),source:w(),text:w(),level:Pe(["info","progress","done","warning","error"]).optional(),tag:w().optional()});R({scriptId:jt,profile:Li.optional()}),R({tasks:de(fR),runnable:be(),problem:w().optional()}),R({scriptId:jt,taskId:w().min(1).max(64),params:Ei(w(),Do([w(),oe(),be()])).optional(),profile:Li.optional()}),R({runId:w()}),R({}),R({scriptId:jt.optional()}),R({items:de(mR)}),R({runId:w(),limit:oe().int().min(1).max(2e3).optional()}),R({lines:de(QN)}),R({scriptId:jt}),R({scriptId:jt,name:w().trim().min(1).max(30),from:Ua("kind",[R({kind:dt("copy"),profile:Li}),R({kind:dt("original")}),R({kind:dt("folder"),dir:w().trim().min(1).max(500)})])}),R({profile:Xm,files:de(w()),list:XN}),R({scriptId:jt,profile:Li,name:w().trim().min(1).max(30).optional(),current:dt(!0).optional()}),R({scriptId:jt,profile:Li}),R({scriptId:jt,profile:Li.optional()}),R({importedAt:oe().optional(),dir:w(),profile:Xm,files:de(R({file:w(),local:be(),original:be(),changed:be()})),drift:de(w())}),R({scriptId:jt,file:w().min(1),profile:Li.optional()}),R({file:w(),content:w(),truncated:be()}),R({scriptId:jt,profile:Li.optional()}),R({imported:de(w())}),R({scriptId:jt,profile:Li.optional()}),R({runId:w()}),R({}),R({scriptId:jt,taskId:w().min(1),param:w().min(1),name:w().trim().min(1).max(40),profile:Li.optional()}),R({value:w()}),R({scriptId:jt}),R({scriptId:jt,mode:Pe(["auto","platform","off"]).optional(),pcLaunch:Pe(["program","maaend"]).nullable().optional(),pcRegion:Pe(["CN","Global","Bilibili","TapTap","Steam","Epic"]).nullable().optional(),pcExe:w().trim().nullable().optional(),pcProcess:w().trim().nullable().optional(),androidPackage:w().trim().regex(/^[A-Za-z][\w]*(\.[A-Za-z_][\w]*)+$/,"安卓包名像 com.example.game").nullable().optional()}),R({scriptId:jt}),R({exe:w().optional(),candidates:de(R({path:w(),source:w()}))});R({scriptId:w(),list:XN}),R({runId:w(),lines:de(QN)});const pR=1,Uf=w().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"credential names use letters, digits and underscores"),JN=R({configured:be(),source:w().optional(),writable:be()}),Qm="DEEPSEEK_API_KEY",gR=R({id:w(),version:oe().int().positive()}),ej=R({id:w(),title:w().nullable(),updatedAt:oe(),running:be(),blank:be(),live:be(),cwd:w().optional(),parentId:w().optional(),origin:Pe(["subagent"]).optional(),role:w().optional(),requestedBy:w().optional(),home:w().optional()}),tj=R({id:w(),name:w(),description:w(),order:oe()}),nj=R({id:w(),requestId:w().optional(),text:w(),images:oe().int().optional(),placement:Pe(["next-turn","next-step"])}),sj=R({contextWindow:oe().int().positive(),usedTokens:oe().int().nonnegative(),breakdown:R({systemTokens:oe().int().nonnegative(),toolsTokens:oe().int().nonnegative(),messageTokens:oe().int().nonnegative()}).optional()}),xR=R({id:w(),createdAt:oe(),cwd:w().optional(),parentId:w().optional(),agentPreset:w().optional()}),wa=R({provider:w(),model:w(),reasoningEffort:w().optional()}),vR=R({from:w(),kind:Pe(["question","answer","update","done"]),text:w(),at:oe()}),Jm=R({id:w(),messages:de(vR).optional(),chain:de(w()).optional(),parent:w().optional(),fromSession:w(),callId:w().optional(),by:w(),to:w(),toSession:w(),title:w(),task:w(),expecting:w().optional(),state:Pe(["running","waiting","done","failed"]),reply:w().optional(),startedAt:oe(),endedAt:oe().optional()}),yR=R({id:w(),agent:w(),sessionId:w(),title:w(),prompt:w(),rule:w(),repeats:be(),next:oe()});R({default:wa,groups:de(R({id:w(),name:w(),models:de(R({id:w(),name:w(),description:w().optional(),efforts:de(R({id:w(),name:w()})),defaultEffort:w().optional()}))})),failures:de(R({id:w(),name:w(),message:w()}))});const bR=R({lastUsed:wa.nullable(),next:wa.nullable()}),Bf=Pe(["openai-completions","openai-responses","anthropic-messages"]),kR=w().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"use lowercase letters, digits and single hyphens, starting with a letter"),ep=R({id:w().min(1),name:w().optional(),contextWindow:oe().int().positive().optional(),maxTokens:oe().int().positive().optional(),input:de(Pe(["text","image"])).optional(),efforts:de(w().min(1)).optional()}),NR=R({id:w(),displayName:w(),api:w().optional(),baseURL:w().optional(),models:de(ep),apiKeyRef:w().optional(),credential:JN.optional(),declared:be(),active:be(),error:w().optional()}),jR=R({available:be(),balances:de(R({currency:w(),total:w(),granted:w(),toppedUp:w()}))}),tp=35e5,wR=R({mediaType:Pe(["image/png","image/jpeg","image/gif","image/webp"]),data:w().min(1).max(tp).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix"),name:w().max(200).optional()}),SR=R({version:w(),title:w().optional(),publishedAt:w().optional(),url:w(),body:w()});R({});R({accepted:dt(!0)});R({protocolVersion:oe().int(),client:R({name:w(),version:w()})}),R({protocolVersion:oe().int(),server:R({name:w(),version:w(),dsh:w().optional()}),capabilities:de(gR)}),R({items:de(ej)}),R({cwd:w().optional(),focus:R({scripts:de(w()).optional(),games:de(w()).optional()}).optional(),role:w().optional()}),R({sessionId:w()}),R({sessionIds:de(w()).max(60)}),R({items:de(R({sessionId:w(),text:w().nullable()}))}),R({items:de(tj)}),R({agentId:w()}),R({sessionId:w()}),R({sessionId:w()}),R({items:de(Jm)}),R({sessionId:w()}),R({a:w(),b:w()}),R({items:de(Jm)}),R({id:w()}),R({agent:w().optional()}),R({items:de(yR)}),R({id:w()}),R({}),R({sessionId:w(),title:w().min(1)}),R({title:w()}),R({sessionId:w(),maxMessages:oe().int().positive().optional()}),R({subscriptionId:w(),header:xR,cursor:oe(),events:de(Wm),hasMore:be(),title:w().nullable(),live:R$.nullable(),queue:de(nj).optional(),context:sj.optional()}),R({subscriptionId:w()}),R({sessionId:w(),throughSeq:oe(),beforeSeq:oe(),maxMessages:oe().int().positive().optional()}),R({events:de(Wm),hasMore:be()}),R({sessionId:w(),requestId:w(),text:w(),mode:Pe(["queue","steer"]),images:de(wR).max(4).optional()}).refine(e=>{var t;return e.text.trim()!==""||(((t=e.images)==null?void 0:t.length)??0)>0},"消息是空的"),R({sessionId:w()}),R({sessionId:w()}),R({compacted:be(),message:w()}),R({sessionId:w(),itemId:w(),action:Pe(["steer","remove"])}),R({attachmentId:w(),mediaType:w(),bytes:oe(),width:oe(),height:oe()}),R({mediaType:w(),data:w()}),R({sessionIds:de(w())}),R({sessionId:w()}),R({sessionIds:de(w())}),R({sessionId:w()}),R({sessionIds:de(w())}),R({model:wa.nullable()}),R({model:wa.nullable()}),R({warning:w().optional()}),wa.extend({sessionId:w()}),R({selected:wa}),R({sessionId:w()}),R({approvalId:w(),decision:Pe(["allow-once","reject"])}),R({refs:de(Uf).min(1).max(64)}),R({items:Ei(w(),JN)}),R({ref:Uf,value:w().min(1).max(4096)}),R({ref:Uf}),R({edition:Pe(["plugin","other"]),version:w().optional()}),R({current:w(),latest:R({version:w(),prerelease:be(),notesUrl:w(),onNpm:be().optional(),notes:de(SR).optional()}).optional(),checkedAt:oe()}),R({providers:de(NR),revision:oe(),writable:be(),protocols:de(Bf),taken:de(w())}),R({provider:w().optional(),baseURL:Bm({protocol:/^https?$/}).optional(),api:Bf.optional(),apiKey:w().min(1).max(4096).optional()}),R({models:de(ep)}),R({provider:w().min(1)}),R({balance:jR.nullable()}),R({id:kR,create:be(),displayName:w().max(80).optional(),api:Bf,baseURL:Bm({protocol:/^https?$/}),models:de(ep).min(1),apiKey:w().min(1).max(4096).optional(),expectedRevision:oe().optional()}),R({revision:oe(),apiKeyRef:w().optional()}),R({id:w().min(1),removeKey:be().optional(),expectedRevision:oe().optional()}),R({revision:oe(),defaultReset:be()});Ua("kind",[R({kind:dt("upsert"),item:ej.partial().extend({id:w()})}),R({kind:dt("removed"),sessionId:w()})]);R({approvalId:w(),sessionId:w(),toolName:w(),callId:w().optional(),reason:w().optional(),displayReason:Ei(w(),w()).optional()});R({subscriptionId:w(),event:Wm}),R({subscriptionId:w(),frame:IN}),R({subscriptionId:w(),reason:w()}),R({sessionId:w(),title:w().nullable()}),R({sessionId:w(),message:w()}),R({sessionId:w(),items:de(nj)}),R({sessionId:w(),context:sj.nullable()}),R({approvalId:w(),outcome:w()}),R({ref:w()}),R({sessionIds:de(w())}),R({items:de(tj)}),R({item:Jm}),R({}),R({}),bR.extend({sessionId:w()});const Iu={InternalError:-32603,NotInitialized:-32002};class Sl extends Error{constructor(n,i,r){super(i);ut(this,"code");ut(this,"data");this.name="RpcError",this.code=n,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 _R(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 lg(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 n=Object.values(t).find(i=>typeof i=="string");return typeof n=="string"?n.slice(0,160):""}catch{return e.slice(0,160)}}const ij=["把这次走通的做法保存成技能(用 skill_save),让下次同样的事可以直接照着做、少调用模型。要求:","- 只写最后成功的路径,不写失败的尝试和闲聊;","- 写清楚适用场景(用户会怎么说)、一步一步的操作(用到的工具、命令、路径、参数照实写,会变的写成「把 X 换成…」)、怎样算成功、注意事项和踩过的坑;","- 名字用简短的英文小写加短横线,description 一两句话说清楚做什么、什么时候用;","- 分到对应的游戏和脚本:只有用某个脚本时才用得上的(它的配置、报错、日志),scripts 填脚本 id;和游戏本身有关、换个脚本也用得上的(游戏里的操作、界面、活动、机制),games 填游戏 id(用 game_list 查);和哪个游戏都无关才当通用技能;","- 保存后告诉我技能名,以及以后我说什么时会用到它。"].join(`
116
+ `);function ER(e,t,n){return[`优化脚本${e===""?":最近运行过的脚本(script_runs 看最近一周跑过哪些,一个一个来)":`「${e}」`}。把这段时间运行攒下的信息用起来,一次做完下面几件事:`,"1. 重新总结脚本包:script_tasks、script_help 看它现在有哪些任务和参数,script_runs、script_run_log 看最近的运行(成功的看正常流程和用时,失败的看原因);更新过版本就先用 script_changelog 读更新日志。对照它的脚本包,任务、参数、配置文件、完成和出错的日志文字、预计用时有不对或缺的,或者使用说明(guide:功能怎么开启、配置怎么设、运行前检查、常见问题)缺了、过时了、能用运行里遇到的报错补上的,用原来的脚本包 id 调用 pack_propose 保存(直接生效;summary 写明依据);都对就不改;","2. 改善监控时间:monitor_stall_check 看它正常运行时日志的节奏,按建议值和你看日志的判断用 monitor_stall_set 设它多久没新日志算卡住,note 写明依据(例如「战斗中最长 70 秒不输出」);","3. 把做过的步骤总结成技能,分到对应的游戏和脚本:运行和处理这个脚本时反复用到、已经走通的做法(常见报错怎么处理、怎么确认跑完、配置怎么改)用 skill_save 存成技能,scripts 填这个脚本的 id,只给它用;其中和游戏本身有关、别的脚本也用得上的(游戏里的操作、界面、活动、机制)单独存,games 填它玩的游戏 id(game_list 查),不填 scripts;已有的技能就合并更新(replace),不要重复存,没有值得存的就不存;","4. 不要运行脚本、不要改它的配置;最后用几句话告诉我:脚本包改了什么(已经直接生效)、卡住时间设成多少、存了或更新了哪些技能。"].join(`
117
+ `)}const cg=[{name:"技能",aliases:["skill"],title:"把刚才走通的做法存成技能,下次少调用模型",expand:()=>ij},{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=>ER(e)},{name:"压缩",aliases:["compact"],title:"压缩这个对话:较早的部分换成摘要,agent 会忘掉其中的细节",expand:()=>"",local:"compact"}];function CR(e){var n,i,r;const t=(i=(n=/^\/(\S+)/.exec(e.trim()))==null?void 0:n[1])==null?void 0:i.toLowerCase();return t===void 0||(r=cg.find(o=>o.local!==void 0&&(o.name===t||o.aliases.includes(t))))==null?void 0:r.local}function AR(e,t){return`使用技能「${e}」:先用 skill 工具加载它,再按它的说明做${t===""?"。":`:${t}`}`}function IR(e,t){const n=e.trim(),i=/^\/(\S+)(?:\s+([\s\S]*))?$/.exec(n);if(i===null)return n;const r=i[1],o=(i[2]??"").trim(),c=cg.find(d=>d.name===r.toLowerCase()||d.aliases.includes(r.toLowerCase()));if((c==null?void 0:c.local)!==void 0)return n;if(c!==void 0)return`${n}
121
+
122
+ ${c.expand(o)}`;const u=t.find(d=>d.name===r);return u===void 0?n:`${n}
123
+
124
+ ${AR(u.name,o)}`}function TR(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 $R(e,t,n=!1){const i=/^\/(\S*)$/.exec(e);if(i===null)return[];const r=i[1].toLowerCase(),o=cg.filter(d=>(n||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})),c=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??"")||c(d.name)-c(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 MR=new Set(["issues","pulls","wiki","actions","discussions","blob","commits","commit","compare","security","pulse","graphs","network","settings","projects","stargazers","forks","watchers","tags","branches"]);function RR(e){var y,S;const t=e.trim().replace(/^<|>$/g,""),n=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/.exec(t);if(n!==null&&!t.includes(":"))return{repo:`${n[1]}/${n[2]}`};const 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=N=>{try{return decodeURIComponent(N)}catch{return N}},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 c=/api\.github\.com\/repos\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)/i.exec(t);if(c!==null)return{repo:`${c[1]}/${c[2]}`};const u=t.toLowerCase().lastIndexOf("github.com/");if(u===-1)return;const 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 g=`${h[0]}/${m}`,[p,...x]=h.slice(2);if(p==="releases")return x[0]==="tag"&&x[1]!==void 0?{repo:g,tag:r(x.slice(1).join("/"))}:x[0]==="download"&&x.length>=3?{repo:g,tag:r(x.slice(1,-1).join("/")),asset:r(x.at(-1))}:{repo:g};if(p==="tree"&&x.length>0)return{repo:g,branch:r(x[0])};if(p==="archive"){const N=x.join("/").replace(/\.(zip|tar\.gz)$/i,""),k=(y=/^refs\/tags\/(.+)$/.exec(N))==null?void 0:y[1];if(k!==void 0)return{repo:g,tag:r(k)};const E=(S=/^refs\/heads\/(.+)$/.exec(N))==null?void 0:S[1];return E!==void 0?{repo:g,branch:r(E)}:{repo:g,tag:r(N)}}return p===void 0||MR.has(p)?{repo:g}:{repo:g}}const py=1;var ur,bs,Zr,Ca,Td,xi,$o,Mo,mc,mn,np,sp,ip,rj,aj,rp,ap;class OR{constructor(t){Lt(this,mn);ut(this,"status",new Fi({state:"idle",attempt:0}));ut(this,"server",new Fi(null));Lt(this,ur);Lt(this,bs,null);Lt(this,Zr,!1);Lt(this,Ca,0);Lt(this,Td,1);Lt(this,xi,new Map);Lt(this,$o,new Map);Lt(this,Mo,new Set);Lt(this,mc);Zt(this,ur,t)}get generation(){return ze(this,Ca)}get ready(){return ze(this,Zr)}start(){this.status.get().state!=="idle"&&this.status.get().state!=="stopped"||xt(this,mn,ip).call(this)}stop(){clearTimeout(ze(this,mc)),this.status.set({state:"stopped",attempt:0});const t=ze(this,bs);Zt(this,bs,null),xt(this,mn,rp).call(this,"connection stopped"),t==null||t.close(1e3,"client stopped")}on(t,n){let i=ze(this,$o).get(t);return i===void 0&&ze(this,$o).set(t,i=new Set),i.add(n),()=>{i.delete(n)}}onReady(t){return ze(this,Mo).add(t),ze(this,Zr)&&queueMicrotask(()=>t(ze(this,Ca))),()=>{ze(this,Mo).delete(t)}}call(t,n,i){return!ze(this,Zr)&&t!=="initialize"?Promise.reject(new Sl(Iu.NotInitialized,"not connected to the gateway")):xt(this,mn,np).call(this,t,n,i)}}ur=new WeakMap,bs=new WeakMap,Zr=new WeakMap,Ca=new WeakMap,Td=new WeakMap,xi=new WeakMap,$o=new WeakMap,Mo=new WeakMap,mc=new WeakMap,mn=new WeakSet,np=function(t,n,i){const r=ze(this,bs);if(r===null||r.readyState!==py)return Promise.reject(new Sl(Iu.NotInitialized,"not connected to the gateway"));if((i==null?void 0:i.aborted)===!0)return Promise.reject(i.reason??new Error("aborted"));const o=x0(this,Td)._++;return new Promise((c,u)=>{const d=ze(this,ur).callTimeoutMs??6e4,h=d>0?setTimeout(()=>{var p;(p=ze(this,xi).get(o))==null||p.reject(new Sl(Iu.InternalError,`${t} timed out`))},d):void 0,m=()=>{var p;ze(this,xi).has(o)&&(xt(this,mn,sp).call(this,{jsonrpc:"2.0",method:"$/cancelRequest",params:{id:o}}),(p=ze(this,xi).get(o))==null||p.reject((i==null?void 0:i.reason)instanceof Error?i.reason:new Error("aborted")))};i==null||i.addEventListener("abort",m,{once:!0});const g=()=>{clearTimeout(h),i==null||i.removeEventListener("abort",m),ze(this,xi).delete(o)};ze(this,xi).set(o,{resolve:p=>{g(),c(p)},reject:p=>{g(),u(p)},cleanup:g}),xt(this,mn,sp).call(this,{jsonrpc:"2.0",id:o,method:t,params:n})})},sp=function(t){var n;((n=ze(this,bs))==null?void 0:n.readyState)===py&&ze(this,bs).send(JSON.stringify(t))},ip=function(){const t=this.status.get();this.status.set({state:t.attempt===0?"connecting":"reconnecting",attempt:t.attempt,...t.error===void 0?{}:{error:t.error}});let n;try{n=(ze(this,ur).createSocket??(i=>new WebSocket(i)))(ze(this,ur).url)}catch(i){xt(this,mn,ap).call(this,i instanceof Error?i.message:String(i));return}Zt(this,bs,n),n.addEventListener("open",()=>{ze(this,bs)===n&&xt(this,mn,rj).call(this,n)}),n.addEventListener("message",i=>{ze(this,bs)===n&&xt(this,mn,aj).call(this,String(i.data))}),n.addEventListener("close",i=>{if(ze(this,bs)!==n)return;Zt(this,bs,null),xt(this,mn,rp).call(this,"connection lost");const r=typeof i.reason=="string"&&i.reason!==""?i.reason:`closed (${i.code??"?"})`;xt(this,mn,ap).call(this,r)}),n.addEventListener("error",()=>{})},rj=async function(t){try{const n=await xt(this,mn,np).call(this,"initialize",{protocolVersion:pR,client:ze(this,ur).clientInfo});if(ze(this,bs)!==t)return;Zt(this,Zr,!0),Zt(this,Ca,ze(this,Ca)+1),this.server.set(n),this.status.set({state:"open",attempt:0});for(const i of[...ze(this,Mo)])i(ze(this,Ca))}catch(n){t.close(4e3,n instanceof Error?n.message:"initialize failed")}},aj=function(t){let n;try{n=JSON.parse(t)}catch{return}const i=_R(n);if(i==="response"){const r=ze(this,xi).get(n.id);if(r===void 0)return;"error"in n?r.reject(new Sl(n.error.code,n.error.message,n.error.data)):r.resolve(n.result)}else if(i==="notification")for(const r of[...ze(this,$o).get(n.method)??[]])try{r(n.params)}catch(o){console.error(`notification handler for ${n.method} failed`,o)}},rp=function(t){Zt(this,Zr,!1);for(const n of[...ze(this,xi).values()])n.reject(new Sl(Iu.InternalError,t));ze(this,xi).clear()},ap=function(t){if(this.status.get().state==="stopped")return;const n=this.status.get().attempt+1,{initial:i,max:r}=ze(this,ur).backoffMs??{initial:500,max:1e4},o=Math.min(r,i*2**Math.min(n-1,10))*(.8+Math.random()*.4);this.status.set({state:"reconnecting",attempt:n,error:t}),Zt(this,mc,setTimeout(()=>xt(this,mn,ip).call(this),o))};const PR={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 ks,pc,Ro,Oo,dr,Wr,gc,xc,Wt,op,Ku,Yn;class zR{constructor(t,n,i){Lt(this,Wt);ut(this,"id");ut(this,"state",new Fi(PR));Lt(this,ks);Lt(this,pc);Lt(this,Ro,null);Lt(this,Oo,-1);Lt(this,dr,!1);Lt(this,Wr,null);Lt(this,gc);Lt(this,xc);this.id=t,Zt(this,ks,n),Zt(this,pc,i),Zt(this,gc,n.onReady(r=>{r!==ze(this,Oo)&&xt(this,Wt,op).call(this,r)}))}get subscriptionId(){return ze(this,Ro)}async prompt(t,n="queue",i=[]){const r=crypto.randomUUID(),o={requestId:r,text:t,mode:n,sentAt:Date.now(),...i.length===0?{}:{images:i.length}};xt(this,Wt,Yn).call(this,c=>({...c,pending:[...c.pending,o]}));try{await ze(this,ks).call("session/prompt",{sessionId:this.id,requestId:r,text:t,mode:n,...i.length===0?{}:{images:[...i]}})}catch(c){const u=c instanceof Error?c.message:String(c);throw xt(this,Wt,Yn).call(this,d=>({...d,pending:d.pending.map(h=>h.requestId===r?{...h,failed:u}:h)})),c}}dismissPending(t){xt(this,Wt,Yn).call(this,n=>({...n,pending:n.pending.filter(i=>i.requestId!==t)}))}async updateQueue(t,n){await ze(this,ks).call("session/queue/update",{sessionId:this.id,itemId:t,action:n})}async cancel(){await ze(this,ks).call("session/cancel",{sessionId:this.id})}async compact(){return ze(this,ks).call("session/compact",{sessionId:this.id})}async loadOlder(){const t=this.state.get(),n=t.events[0];if(!(!t.hasMore||t.loadingOlder||n===void 0)){xt(this,Wt,Yn).call(this,i=>({...i,loadingOlder:!0}));try{const i=await ze(this,ks).call("session/history",{sessionId:this.id,throughSeq:t.cursor,beforeSeq:n.seq});xt(this,Wt,Yn).call(this,r=>{var u;const o=((u=r.events[0])==null?void 0:u.seq)??Number.POSITIVE_INFINITY,c=i.events.filter(d=>d.seq<o);return{...r,events:[...c,...r.events],hasMore:i.hasMore,loadingOlder:!1}})}catch(i){xt(this,Wt,Yn).call(this,r=>({...r,loadingOlder:!1,error:i instanceof Error?i.message:String(i)}))}}}close(){if(ze(this,dr))return;Zt(this,dr,!0),clearTimeout(ze(this,xc)),ze(this,gc).call(this);const t=ze(this,Ro);xt(this,Wt,Ku).call(this,null),t!==null&&ze(this,ks).ready&&ze(this,ks).call("session/close",{subscriptionId:t}).catch(()=>{}),xt(this,Wt,Yn).call(this,n=>({...n,status:"closed"}))}receiveEvent(t){xt(this,Wt,Yn).call(this,n=>{const i=n.events.at(-1);if(i!==void 0&&t.seq<=i.seq)return n;let r=n.pending;t.type==="user/message"&&t.requestId!==void 0&&(r=r.filter(d=>d.requestId!==t.requestId));let o=n.live;(t.type==="assistant/message"||t.type==="assistant/attempt")&&o!==null&&o.turn===t.turn&&o.step===t.step&&(o=null);const c=t.type==="session/title"?t.title:n.title,u=[...n.events,t];return{...n,events:u,pending:r,live:o,title:c,running:Hf(u,o)}})}receiveLive(t){xt(this,Wt,Yn).call(this,n=>{var i;switch(t.type){case"start":{const r={attemptId:t.attemptId,turn:t.turn,step:t.step,afterSeq:t.afterSeq,deltas:[]};return{...n,live:r,running:!0}}case"delta":{const r=n.live;return r===null||r.attemptId!==t.attemptId?n:(r.deltas.push(t),{...n,live:{...r}})}case"end":return((i=n.live)==null?void 0:i.attemptId)!==t.attemptId?n:{...n,live:null,running:Hf(n.events,null)}}})}receiveClosed(t){xt(this,Wt,Ku).call(this,null),!ze(this,dr)&&(xt(this,Wt,Yn).call(this,n=>({...n,status:"error",error:`stream ended: ${t}`})),Zt(this,xc,setTimeout(()=>{!ze(this,dr)&&ze(this,ks).ready&&xt(this,Wt,op).call(this,ze(this,Oo))},1e3)))}receiveQueue(t){xt(this,Wt,Yn).call(this,n=>({...n,queue:t,pending:gy(n.pending,t)}))}receiveContext(t){xt(this,Wt,Yn).call(this,n=>({...n,context:t}))}receiveTitle(t){xt(this,Wt,Yn).call(this,n=>n.title===t?n:{...n,title:t})}}ks=new WeakMap,pc=new WeakMap,Ro=new WeakMap,Oo=new WeakMap,dr=new WeakMap,Wr=new WeakMap,gc=new WeakMap,xc=new WeakMap,Wt=new WeakSet,op=async function(t){if(!ze(this,dr))return ze(this,Wr)!==null?ze(this,Wr):(Zt(this,Oo,t),Zt(this,Wr,(async()=>{try{const n=await ze(this,ks).call("session/open",{sessionId:this.id});if(ze(this,dr)){ze(this,ks).call("session/close",{subscriptionId:n.subscriptionId}).catch(()=>{});return}xt(this,Wt,Ku).call(this,n.subscriptionId);const i=n.live===null?null:{...n.live,deltas:[...n.live.deltas]};xt(this,Wt,Yn).call(this,r=>{const o=new Set(n.events.flatMap(c=>c.type==="user/message"&&c.requestId!==void 0?[c.requestId]:[]));return{...r,status:"open",header:n.header,title:n.title,events:n.events,cursor:n.cursor,hasMore:n.hasMore,live:i,pending:gy(r.pending.filter(c=>!o.has(c.requestId)),n.queue??[]),queue:n.queue??[],context:n.context??r.context,running:Hf(n.events,i),loadingOlder:!1,error:null}})}catch(n){xt(this,Wt,Yn).call(this,i=>({...i,status:"error",error:n instanceof Error?n.message:String(n)}))}finally{Zt(this,Wr,null)}})()),ze(this,Wr))},Ku=function(t){Zt(this,Ro,t),ze(this,pc).bindSubscription(this,t)},Yn=function(t){this.state.set(n=>{const i=t(n);return i===n?n:{...i,version:n.version+1}})};function gy(e,t){const n=new Set(t.flatMap(i=>i.requestId===void 0?[]:[i.requestId]));return n.size===0?e:e.filter(i=>!n.has(i.requestId))}function Hf(e,t){if(t!==null)return!0;for(let n=e.length-1;n>=0;n-=1){const i=e[n];if(i.type==="turn/end")return!1;if(i.type==="turn/start")return!0}return!1}const xy=(e,t)=>t.updatedAt-e.updatedAt;var $s,Ui,Po,Jr,Yu,oj;class LR{constructor(t){Lt(this,Jr);ut(this,"connection");ut(this,"sessions",new Fi({items:[],loaded:!1,error:null}));ut(this,"approvals",new Fi([]));ut(this,"questions",new Fi([]));ut(this,"capabilities",new Fi(new Set));ut(this,"credentialRevision",new Fi(0));ut(this,"providersRevision",new Fi(0));ut(this,"sessionModels",new Fi(new Map));Lt(this,$s,new Map);Lt(this,Ui,new Map);Lt(this,Po,!1);this.connection=new OR({...t,clientInfo:t.clientInfo??{name:"adg-client",version:"0.1.0"}});const n=this.connection;n.onReady(()=>{var i;this.capabilities.set(new Set(((i=n.server.get())==null?void 0:i.capabilities.map(r=>r.id))??[])),this.approvals.set([]),this.questions.set([]),this.refreshSessions()}),n.on("sessions/changed",i=>{if(i.kind==="removed"){this.sessions.set(o=>({...o,items:o.items.filter(c=>c.id!==i.sessionId)}));return}if(!this.sessions.get().items.some(o=>o.id===i.item.id)){xt(this,Jr,oj).call(this);return}this.sessions.set(o=>({...o,items:o.items.map(c=>c.id===i.item.id?{...c,...DR(i.item)}:c).sort(xy)}))}),n.on("session/title",({sessionId:i,title:r})=>{var o;(o=ze(this,$s).get(i))==null||o.handle.receiveTitle(r)}),n.on("session/queue",({sessionId:i,items:r})=>{var o;(o=ze(this,$s).get(i))==null||o.handle.receiveQueue(r)}),n.on("session/context",({sessionId:i,context:r})=>{var o;(o=ze(this,$s).get(i))==null||o.handle.receiveContext(r)}),n.on("session/event",({subscriptionId:i,event:r})=>{var o;return(o=ze(this,Ui).get(i))==null?void 0:o.receiveEvent(r)}),n.on("session/live",({subscriptionId:i,frame:r})=>{var o;return(o=ze(this,Ui).get(i))==null?void 0:o.receiveLive(r)}),n.on("session/closed",({subscriptionId:i,reason:r})=>{const o=ze(this,Ui).get(i);o!==void 0&&o.subscriptionId===i&&o.receiveClosed(r)}),n.on("approval/requested",i=>{this.approvals.set(r=>r.some(o=>o.approvalId===i.approvalId)?r:[...r,i])}),n.on("approval/resolved",({approvalId:i})=>{this.approvals.set(r=>r.filter(o=>o.approvalId!==i))}),n.on("question/requested",i=>{this.questions.set(r=>r.some(o=>o.questionId===i.questionId)?r:[...r,i])}),n.on("question/resolved",({questionId:i})=>{this.questions.set(r=>r.filter(o=>o.questionId!==i))}),n.on("credentials/changed",()=>this.credentialRevision.set(i=>i+1)),n.on("providers/changed",()=>this.providersRevision.set(i=>i+1)),n.on("session/model",({sessionId:i,lastUsed:r,next:o})=>xt(this,Jr,Yu).call(this,i,{lastUsed:r,next:o}))}async describeCredentials(t){const{items:n}=await this.connection.call("credentials/describe",{refs:[...t]});return n}async setCredential(t,n){await this.connection.call("credentials/set",{ref:t,value:n}),this.credentialRevision.set(i=>i+1)}async unsetCredential(t){await this.connection.call("credentials/unset",{ref:t}),this.credentialRevision.set(n=>n+1)}start(){this.connection.start()}stop(){for(const{handle:t}of ze(this,$s).values())t.close();ze(this,$s).clear(),ze(this,Ui).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(xy),loaded:!0,error:null})}catch(t){this.sessions.set(n=>({...n,error:t instanceof Error?t.message:String(t)}))}}async createSession(t,n={}){const{sessionId:i}=await this.connection.call("sessions/create",{...t===void 0?{}:{cwd:t},...n.role===void 0?{}:{role:n.role}});return await this.refreshSessions(),i}async renameSession(t,n){var r;const i=await this.connection.call("sessions/rename",{sessionId:t,title:n});this.sessions.set(o=>({...o,items:o.items.map(c=>c.id===t?{...c,title:i.title}:c)})),(r=ze(this,$s).get(t))==null||r.handle.receiveTitle(i.title)}modelCatalog(){return this.connection.call("models/catalog",{})}async sessionModel(t){const n=await this.connection.call("session/model",{sessionId:t});return xt(this,Jr,Yu).call(this,t,n),n}async selectModel(t,n){var o;const{selected:i}=await this.connection.call("session/selectModel",{sessionId:t,...n}),r=((o=this.sessionModels.get().get(t))==null?void 0:o.lastUsed)??null;return xt(this,Jr,Yu).call(this,t,{lastUsed:r,next:i}),i}listProviders(){return this.connection.call("providers/list",{})}async discoverModels(t,n){const{models:i}=await this.connection.call("providers/discover",t,n);return i}async providerBalance(t){const{balance:n}=await this.connection.call("providers/balance",{provider:t});return n}async saveProvider(t){const n=await this.connection.call("providers/save",t);return this.providersRevision.set(i=>i+1),t.apiKey!==void 0&&this.credentialRevision.set(i=>i+1),n}async removeProvider(t){const n=await this.connection.call("providers/remove",t);return this.providersRevision.set(i=>i+1),t.removeKey===!0&&this.credentialRevision.set(i=>i+1),n}async respondApproval(t,n){await this.connection.call("approval/respond",{approvalId:t,decision:n}),this.approvals.set(i=>i.filter(r=>r.approvalId!==t))}async answerQuestion(t,n){await this.connection.call("question/respond",{questionId:t,answers:[...n]}),this.questions.set(i=>i.filter(r=>r.questionId!==t))}openSession(t){const n=ze(this,$s).get(t);if(n!==void 0)return n.refs+=1,n.handle;const i=new zR(t,this.connection,{bindSubscription:(r,o)=>{for(const[c,u]of ze(this,Ui))u===r&&ze(this,Ui).delete(c);o!==null&&ze(this,Ui).set(o,r)}});return ze(this,$s).set(t,{handle:i,refs:1}),i}release(t){const n=ze(this,$s).get(t.id);n===void 0||n.handle!==t||(n.refs-=1,!(n.refs>0)&&(ze(this,$s).delete(t.id),t.close()))}}$s=new WeakMap,Ui=new WeakMap,Po=new WeakMap,Jr=new WeakSet,Yu=function(t,n){this.sessionModels.set(i=>new Map(i).set(t,n))},oj=function(){ze(this,Po)||(Zt(this,Po,!0),setTimeout(()=>{Zt(this,Po,!1),this.refreshSessions()},150))};function DR(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const Zf=(e,t)=>e.map(n=>n.type===t?n.text:"").join(""),vy=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}}]:[]),FR=e=>e.map(t=>t.type==="text"?t.text:t.type==="image"?"[image]":t.type==="file"?`[file ${t.name??""}]`:"").join("");function lj(e,t,n=[]){var d;const i=[],r=new Map,o=new Set,c=new Map,u=new Map;for(const h of e)switch(h.type){case"user/message":{const m=Zf(h.content,"text");h.origin.human?i.push({kind:"user",id:`u:${h.seq}`,text:m,time:h.time,images:h.content.filter(g=>g.type==="image").length,imageRefs:vy(h.content),files:h.content.filter(g=>g.type==="file").length}):uy(m)!==void 0?i.push({kind:"context",id:`c:${h.seq}`,title:"定时提醒",summary:XM(uy(m)),text:m,startsTurn:!0}):h.replacesHistory===!0?i.push({kind:"context",id:`c:${h.seq}`,title:"较早的对话已压缩成摘要(agent 只记得摘要里的内容)",summary:"",text:m}):h.origin.summary!==void 0&&i.push({kind:"context",id:`c:${h.seq}`,title:h.origin.kind,summary:h.origin.summary,text:m});break}case"assistant/message":{o.add(`${h.turn}:${h.step}`);const m=Zf(h.content,"text"),g=Zf(h.content,"reasoning");(m.trim()!==""||g.trim()!=="")&&i.push({kind:"assistant",id:`a:${h.seq}`,text:m,reasoning:g,live:!1,interrupted:h.interrupted===!0,time:h.time,...h.model===void 0?{}:{model:h.model}});break}case"tool/call":{const m={kind:"tool",id:`t:${h.callId}`,callId:h.callId,name:h.name,arguments:h.arguments,status:"running",time:h.time},g=c.get(h.callId);g!==void 0&&(m.approval=g),r.set(h.callId,m),i.push(m);break}case"tool/result":{const m=r.get(h.callId);if(m===void 0)break;m.result=FR(h.content);const g=vy(h.content);g.length>0&&(m.images=g),m.status=h.isError?"error":"ok",h.error!==void 0&&(m.error=h.error.message);break}case"approval/asked":if(h.callId!==void 0){u.set(h.approvalId,h.callId),c.set(h.callId,"asked");const m=r.get(h.callId);m!==void 0&&(m.approval="asked")}break;case"approval/decided":{const m=u.get(h.approvalId);if(m===void 0)break;c.set(m,h.outcome);const g=r.get(m);g!==void 0&&(g.approval=h.outcome);break}case"turn/end":for(const m of r.values())m.status==="running"&&(m.status="interrupted");h.reason.kind==="error"?i.push({kind:"notice",id:`e:${h.seq}`,tone:"error",text:h.reason.message??"这一轮出错了"}):h.reason.kind==="aborted"?i.push({kind:"notice",id:`e:${h.seq}`,tone:"info",text:"已停止"}):h.reason.kind==="max-tokens"&&i.push({kind:"notice",id:`e:${h.seq}`,tone:"info",text:"回复太长,达到了输出上限"});break;case"compaction/end":i.push({kind:"notice",id:`k:${h.seq}`,tone:h.error===void 0?"info":"error",text:h.error===void 0?"对话太长,较早的内容已压缩成摘要":`压缩对话历史失败:${h.error}`});break}if(t!==null&&!o.has(`${t.turn}:${t.step}`)){let h="",m="";for(const g of t.deltas)g.kind==="text"?h+=g.text:g.kind==="reasoning"&&(m+=g.text);i.push({kind:"assistant",id:`live:${t.attemptId}`,text:h,reasoning:m,live:!0,interrupted:!1,time:((d=t.deltas[0])==null?void 0:d.time)??Date.now()})}for(const h of n)i.push({kind:"user",id:`p:${h.requestId}`,text:h.text,images:h.images??0,imageRefs:[],files:0,time:h.sentAt,pending:{requestId:h.requestId,...h.failed===void 0?{}:{failed:h.failed}}});return i}var b=vc();const UR=Gp(b);function BR(e,t){return e.filter(n=>{var i;return((i=n.available)==null?void 0:i.call(n,t))??!0})}const Vr=new Map,cd=new Set;function Pn(e){if(Vr.has(e.id))throw new Error(`UI plugin "${e.id}" is already registered`);Vr.set(e.id,e);for(const t of cd)t();return()=>{if(Vr.get(e.id)===e){Vr.delete(e.id);for(const t of cd)t()}}}function cj(e){return cd.add(e),()=>{cd.delete(e)}}function HR(e){return[...Vr.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.sessionViews??[]).sort((t,n)=>t.order-n.order)}function ZR(e){return[...Vr.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.settingsPages??[]).sort((t,n)=>t.order-n.order)}function WR(e){return[...Vr.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.pages??[]).sort((t,n)=>t.order-n.order)}function VR(e){return[...Vr.values()].map(t=>({plugin:t,missing:t.requires.filter(n=>!e.has(n))}))}function we(e){return b.useSyncExternalStore(e.subscribe,e.get,e.get)}function Pd(e,t){const[n,i]=b.useState(null);return b.useEffect(()=>{const r=e.openSession(t);return i(r),()=>e.release(r)},[e,t]),n!==null&&n.id===t?n:null}function uj(e){const t=we(e.capabilities),n=ug();return b.useMemo(()=>HR(t),[t,n])}function qR(e){const t=we(e.capabilities),n=ug();return b.useMemo(()=>ZR(t),[t,n])}function GR(e){const t=we(e.capabilities),n=ug();return b.useMemo(()=>WR(t),[t,n])}function ug(){const[e,t]=b.useState(0);return b.useEffect(()=>cj(()=>t(n=>n+1)),[]),e}function dj(e,t){const n=we(e.credentialRevision),i=we(e.connection.status),r=we(e.capabilities),o=t.join(`
127
+ `),[c,u]=b.useState({items:null,error:null});return b.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,n,i.state,r]),c}function Ba(e){const t=we(e.credentialRevision),n=we(e.providersRevision),i=we(e.connection.status),r=we(e.capabilities),[o,c]=b.useState({catalog:null,error:null});return b.useEffect(()=>{if(i.state!=="open"||!r.has("models"))return;let u=!0;return e.modelCatalog().then(d=>{u&&c({catalog:d,error:null})}).catch(d=>{u&&c(h=>({...h,error:d instanceof Error?d.message:String(d)}))}),()=>{u=!1}},[e,t,n,i.state,r]),o}function An(e){const[t,n]=b.useState(()=>Date.now());return b.useEffect(()=>{const i=setInterval(()=>n(Date.now()),e);return()=>clearInterval(i)},[e]),t}function KR(e){const t=we(e.connection.status),n=we(e.capabilities),[i,r]=b.useState(void 0);return b.useEffect(()=>e.connection.on("permissions/changed",o=>r(o.mode)),[e]),b.useEffect(()=>{if(t.state!=="open"||!n.has("permissions"))return;let o=!0;return e.connection.call("permissions/get",{}).then(c=>{o&&r(c.mode)}).catch(()=>{}),()=>{o=!1}},[e,t.state,n]),i}const YR={plus:"M12 5v14M5 12h14",chat:"M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5Z",settings:"M4 7h9m4 0h3M4 17h3m4 0h9M13 4v6M7 14v6",arrow:"M12 19V5m-6 6 6-6 6 6",activity:"M3 12h4l3-8 4 16 3-8h4",layers:"m12 3 9 5-9 5-9-5 9-5Zm-9 9 9 5 9-5M3 16l9 5 9-5",sparkles:"m12 3 2.5 6.5L21 12l-6.5 2.5L12 21l-2.5-6.5L3 12l6.5-2.5L12 3Z",close:"m6 6 12 12M6 18 18 6",gauge:"M12 14l4-4M3.5 15a8.5 8.5 0 1 1 17 0M6.5 19h11",popout:"M14 4h6v6M20 4l-8.5 8.5M18 14v4.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 4 18.5v-11A1.5 1.5 0 0 1 5.5 6H10",search:"M11 17.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13ZM20 20l-4-4",check:"m5 12.5 4.5 4.5L19 7.5",pencil:"M4 20h4L18.5 9.5a2.1 2.1 0 0 0-4-4L4 16v4ZM13.5 6.5l4 4",copy:"M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2ZM16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2",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:"M12 4 2.5 20h19L12 4ZM12 10v4M12 17v.01",package:"m12 3 8 4.5v9L12 21l-8-4.5v-9L12 3Zm0 9 8-4.5M12 12v9M12 12 4 7.5",flow:"M5 4h4v4H5zM15 16h4v4h-4zM15 4h4v4h-4zM9 6h6M17 8v8M7 8v6a2 2 0 0 0 2 2h6",monitor:"M4 5h16v11H4zM9 20h6M12 16v4M7 12l2.5-3 2.5 2 3-4 2 2",gamepad:"M7 9v4M5 11h4M15 10.5v.01M17.5 12.5v.01M6.5 6h11a4 4 0 0 1 4 4.4l-.6 5.3a2.6 2.6 0 0 1-4.5 1.4L14.5 15h-5l-1.9 2.1a2.6 2.6 0 0 1-4.5-1.4l-.6-5.3A4 4 0 0 1 6.5 6Z",plug:"M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0V8ZM12 17v4",home:"M4 11 12 4l8 7M6 9.5V20h12V9.5",archive:"M4 5h16v4H4zM5.5 9v10h13V9M10 13h4",refresh:"M20 11a8 8 0 0 0-14.3-4.9L4 8M4 4v4h4M4 13a8 8 0 0 0 14.3 4.9L20 16M20 20v-4h-4",calendar:"M5 5.5h14a1 1 0 0 1 1 1V19a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6.5a1 1 0 0 1 1-1ZM4 10h16M8 3.5v4M16 3.5v4M8 14h2M14 14h2M8 17h2",send:"M20.5 3.5 10 14M20.5 3.5 14 20.5l-4-6.5-6.5-4 17-6.5Z",power:"M12 3.5v8M7.2 6.5a7 7 0 1 0 9.6 0",download:"M12 4v11M7 10.5l5 5 5-5M5 20h14",compress:"M12 3v6M9 6l3 3 3-3M12 21v-6M9 18l3-3 3 3M4 12h16"};function J({name:e,className:t=""}){return s.jsx("svg",{className:`ui-icon ${t}`,width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:YR[e]})})}function XR(){return s.jsx("svg",{className:"ui-icon stop-glyph",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"3",fill:"currentColor"})})}function zd({size:e="md"}){return s.jsx("span",{className:`adg-mark ${e}`,"aria-hidden":"true",children:s.jsxs("svg",{className:"ui-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M9 7.5v9l7.5-4.5L9 7.5Z"}),s.jsx("path",{d:"M4 12a8 8 0 0 1 14.5-4.7M20 12a8 8 0 0 1-14.5 4.7"})]})})}const yy="adg.otherCopies.seen";function QR(e){const t=we(e.connection.status),i=we(e.capabilities).has("instances"),[r,o]=b.useState([]);return b.useEffect(()=>e.connection.on("instances/changed",c=>o(c.others)),[e]),b.useEffect(()=>{if(t.state!=="open"||!i){o([]);return}let c=!0;return e.connection.call("instances/others",{}).then(u=>{c&&o(u.others)}).catch(()=>{}),()=>{c=!1}},[e,t.state,i]),r}function JR({client:e}){const t=QR(e),n=JSON.stringify(t.map(c=>[c.pid,c.warnings])),[i,r]=b.useState(()=>{try{return localStorage.getItem(yy)}catch{return null}});if(t.length===0||i===n)return null;const o=()=>{try{localStorage.setItem(yy,n)}catch{}r(n)};return s.jsxs("div",{className:"approval-card other-copies",role:"status",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(J,{name:"alert"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("span",{className:"approval-title",children:t.length===1?"另一个多游戏助手也开着":`另外 ${t.length} 个多游戏助手也开着`}),s.jsx("span",{className:"approval-tool",children:t.map(c=>c.label).join("、")})]})]}),s.jsx("ul",{className:"other-copies-list",children:[...new Set(t.flatMap(c=>c.warnings))].map(c=>s.jsx("li",{children:c},c))}),s.jsx("div",{className:"approval-actions",children:s.jsx("button",{onClick:o,children:"知道了"})})]})}const eO={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function tO(e){const t=we(e.connection.status),i=we(e.capabilities).has("schedule"),[r,o]=b.useState(void 0);return b.useEffect(()=>e.connection.on("schedule/power",o),[e]),b.useEffect(()=>{if(t.state!=="open"||!i){o(void 0);return}let c=!0;return e.connection.call("schedule/power",{}).then(u=>{c&&o(u)}).catch(()=>{}),()=>{c=!1}},[e,t.state,i]),r}function nO({client:e,pending:t}){const n=An(1e3),[i,r]=b.useState(!1),[o,c]=b.useState(null),u=eO[t.action],d=async()=>{r(!0),c(null);try{await e.connection.call("schedule/power/cancel",{})}catch(m){c(m instanceof Error?m.message:String(m))}finally{r(!1)}},h=t.at===void 0?void 0:Math.max(0,Math.ceil((t.at-n)/1e3));return s.jsxs("div",{className:"approval-card power-card",role:"alertdialog","aria-label":`即将${u}`,children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(J,{name:"power"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("div",{className:"approval-title",children:h===void 0?`其他任务结束后${u}`:`${h} 秒后${u}`}),s.jsxs("span",{className:"approval-tool",children:["「",t.pipelineName,"」设置了结束后",u]})]})]}),t.action==="shutdown"&&h!==void 0&&s.jsx("div",{className:"approval-reason",children:"关机会强制关闭所有程序,没保存的内容会丢失。"}),o!==null&&s.jsx("div",{className:"error small",children:o}),s.jsx("div",{className:"approval-actions",children:s.jsxs("button",{className:"inverse",disabled:i,onClick:()=>void d(),children:["取消",u]})})]})}function Ld(e){const t=we(e.connection.status),[n,i]=b.useState({data:null,error:null}),[r,o]=b.useState(0),c=b.useCallback(()=>o(u=>u+1),[]);return b.useEffect(()=>e.connection.on("scripts/changed",()=>c()),[e,c]),b.useEffect(()=>{if(t.state!=="open")return;let u=!0;return e.connection.call("scripts/list",{}).then(d=>{u&&i({data:d,error:null})}).catch(d=>{u&&i(h=>({...h,error:Ie(d)}))}),()=>{u=!1}},[e,t.state,r]),{...n,refresh:c}}function hj(e){const t=we(e.connection.status),[n,i]=b.useState(new Map);return b.useEffect(()=>e.connection.on("scripts/job",r=>{i(o=>{const c=o.get(r.scriptId);return c!==void 0&&c.id!==r.id&&c.startedAt>r.startedAt?o:new Map(o).set(r.scriptId,r)})}),[e]),b.useEffect(()=>{if(t.state!=="open")return;let r=!0;return e.connection.call("scripts/jobs",{}).then(({items:o})=>{if(!r)return;const c=new Map;for(const u of[...o].sort((d,h)=>d.startedAt-h.startedAt))c.set(u.scriptId,u);i(c)}).catch(()=>{}),()=>{r=!1}},[e,t.state]),n}function Ie(e){return e instanceof Error?e.message:String(e)}function Sa(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 ic={queued:"排队中",resolving:"读取发布信息",downloading:"下载中",verifying:"校验中",extracting:"解压中",checking:"检查环境",running:"处理中",done:"完成",failed:"失败",cancelled:"已取消"},fj={"maafw-pi":"MaaFramework",cli:"命令行","gui-config":"配置驱动 GUI","generic-process":"通用程序",visual:"界面操作"};function Na(e){return e!==void 0&&e.endedAt===void 0}const mj="adg.scriptUpdate.later",by=9e3;function ky(){try{return JSON.parse(localStorage.getItem(mj)??"{}")}catch{return{}}}function sO({client:e}){return we(e.capabilities).has("scripts")?s.jsx(aO,{client:e}):null}function iO({client:e}){return we(e.capabilities).has("scripts")?s.jsx(rO,{client:e}):null}function rO({client:e}){const{data:t}=Ld(e),n=hj(e),[i,r]=b.useState(null),[o,c]=b.useState(ky),[u,d]=b.useState(new Map);if(b.useEffect(()=>{if(t===null)return;let p=!0;return e.connection.call("scripts/settings",{}).then(x=>{p&&r(x.autoUpdate)}).catch(()=>{}),()=>{p=!1}},[e,t]),t===null||i!=="ask")return null;const h=t.scripts.filter(p=>{var x;return((x=p.update)==null?void 0:x.available)===!0&&o[p.id]!==p.update.latest});if(h.length===0)return null;const m=(p,x)=>{const y={...ky(),[p]:x};try{localStorage.setItem(mj,JSON.stringify(y))}catch{}c(y)},g=p=>{d(x=>{const y=new Map(x);return y.delete(p),y}),e.connection.call("scripts/update",{id:p}).catch(x=>d(y=>new Map(y).set(p,Ie(x))))};return h.map(p=>{var k;const x=n.get(p.id),y=Na(x),S=p.source.kind==="local"?(k=p.localVersion)==null?void 0:k.version:p.current,N=u.get(p.id);return s.jsxs("div",{className:"reminder script-update-note",role:"status",children:[s.jsx(J,{name:"download"}),s.jsxs("span",{children:[s.jsx("strong",{children:p.name})," 有新版本 ",p.update.latest,"(当前 ",S??"认不出的版本","),要现在更新吗?",N!==void 0&&s.jsxs("span",{className:"error",children:[" 没有更新成功:",N]})]}),y?s.jsxs("span",{className:"script-update-progress muted",children:[s.jsx("span",{className:"spinner"}),x.message??ic[x.phase],"…"]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"ghost small-button",title:"有更新的版本时再问",onClick:()=>m(p.id,p.update.latest),children:"以后再说"}),s.jsx("button",{type:"button",className:"primary small-button",onClick:()=>g(p.id),children:"更新"})]})]},p.id)})}function aO({client:e}){const[t,n]=b.useState([]),i=b.useRef(new Set);b.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(c=>c.name,()=>o.scriptId).then(c=>n(u=>[...u,{job:o,name:c}])))}),[e]);const r=o=>n(c=>c.filter(u=>u.job.id!==o));return t.map(o=>s.jsx(oO,{done:o,onClose:()=>r(o.job.id)},o.job.id))}function oO({done:e,onClose:t}){const[n,i]=b.useState(!1);b.useEffect(()=>{if(n)return;const u=setTimeout(t,by);return()=>clearTimeout(u)},[n,t]);const{job:r,name:o}=e,c=r.kind==="update";return s.jsxs("div",{className:"approval-card done-card",role:"status",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[s.jsxs("div",{className:"approval-head",children:[s.jsx("span",{className:"done-badge","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 24 24",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M7.5 12.5l3 3 6-6.5"})]})}),s.jsxs("div",{className:"approval-text",children:[s.jsx("span",{className:"approval-title",children:c?"更新成功":"安装成功"}),s.jsxs("span",{className:"done-line",children:[o,r.version===void 0?"":c?` 已更新到 ${r.version}`:` ${r.version} 已装好`]})]}),s.jsx("button",{className:"ghost icon-button update-close","aria-label":"关闭",onClick:t,children:s.jsx(J,{name:"close"})})]}),!n&&s.jsx("span",{className:"done-timer",style:{animationDuration:`${by}ms`}})]})}function wi(){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 Ny(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function lO(e){if(Array.isArray(e))return e}function cO(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,r,o,c,u=[],d=!0,h=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(d=(i=o.call(n)).done)&&(u.push(i.value),u.length!==t);d=!0);}catch(m){h=!0,r=m}finally{try{if(!d&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(h)throw r}}return u}}function uO(){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 dO(e,t){return lO(e)||cO(e,t)||hO(e,t)||uO()}function hO(e,t){if(e){if(typeof e=="string")return Ny(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ny(e,t):void 0}}const pj=Object.entries,jy=Object.setPrototypeOf,fO=Object.isFrozen,gj=Object.getPrototypeOf,xj=Object.getOwnPropertyDescriptor;let On=Object.freeze,Un=Object.seal,vo=Object.create,vj=typeof Reflect<"u"&&Reflect,lp=vj.apply,cp=vj.construct;On||(On=function(t){return t});Un||(Un=function(t){return t});lp||(lp=function(t,n){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(n,r)});cp||(cp=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return new t(...i)});const or=Kt(Array.prototype.forEach),mO=Kt(Array.prototype.lastIndexOf),wy=Kt(Array.prototype.pop),_l=Kt(Array.prototype.push),pO=Kt(Array.prototype.slice),gO=Kt(Array.prototype.splice),_o=Array.isArray,Wf=yj(Set),Vf=Kt(Set.prototype.add),El=Kt(Set.prototype.has),ba=Kt(String.prototype.toLowerCase),qf=Kt(String.prototype.toString),Sy=Kt(String.prototype.match),Cl=Kt(String.prototype.replace),_y=Kt(String.prototype.indexOf),xO=Kt(String.prototype.trim),vO=Kt(Number.prototype.toString),yO=Kt(Boolean.prototype.toString),Ey=typeof BigInt>"u"?null:Kt(BigInt.prototype.toString),Cy=typeof Symbol>"u"?null:Kt(Symbol.prototype.toString),Ns=Kt(Object.prototype.hasOwnProperty),Al=Kt(Object.prototype.toString),Fn=Kt(RegExp.prototype.test),lr=yj(TypeError);function Kt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return lp(e,t,i)}}function yj(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return cp(e,n)}}function Nt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ba;if(jy&&jy(e,null),!_o(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){const o=n(r);o!==r&&(fO(t)||(t[i]=o),r=o)}e[r]=!0}return e}function bO(e){for(let t=0;t<e.length;t++)Ns(e,t)||(e[t]=null);return e}function Ts(e){const t=vo(null);for(const i of pj(e)){var n=dO(i,2);const r=n[0],o=n[1];Ns(e,r)&&(_o(o)?t[r]=bO(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=Ts(o):t[r]=o)}return t}function kO(e){switch(typeof e){case"string":return e;case"number":return vO(e);case"boolean":return yO(e);case"bigint":return Ey?Ey(e):"0";case"symbol":return Cy?Cy(e):"Symbol()";case"undefined":return Al(e);case"function":case"object":{if(e===null)return Al(e);const t=e,n=Xs(t,"toString");if(typeof n=="function"){const i=n(t);return typeof i=="string"?i:Al(i)}return Al(e)}default:return Al(e)}}function Xs(e,t){for(;e!==null;){const i=xj(e,t);if(i){if(i.get)return Kt(i.get);if(typeof i.value=="function")return Kt(i.value)}e=gj(e)}function n(){return null}return n}function NO(e,t){for(;e!==null;){const n=xj(e,t);if(n)return n.get?Kt(n.get):null;e=gj(e)}return null}function jO(e){try{return Fn(e,""),!0}catch{return!1}}const Ay=On(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Gf=On(["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"]),Kf=On(["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"]),wO=On(["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"]),Yf=On(["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"]),SO=On(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Iy=On(["#text"]),Ty=On(["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"]),Xf=On(["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"]),$y=On(["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"]),Tu=On(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),_O=Un(/{{[\w\W]*|^[\w\W]*}}/g),EO=Un(/<%[\w\W]*|^[\w\W]*%>/g),CO=Un(/\${[\w\W]*/g),AO=Un(/^data-[\-\w.\u00B7-\uFFFF]+$/),IO=Un(/^aria-[\-\w]+$/),My=Un(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),TO=Un(/^(?:\w+script|data):/i),$O=Un(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),MO=Un(/^html$/i),RO=Un(/^[a-z][.\w]*(-[.\w]+)+$/i),Qf=Un(/<[/\w!]/g),Ry=Un(/<[/\w]/g),OO=Un(/<\/no(script|embed|frames)/i),Oy=Un(/\/>/i),vn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},PO=On(Nt({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),zO=function(){return typeof window>"u"?null:window},LO=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(i=n.getAttribute(r));const o="dompurify"+(i?"#"+i:"");try{return t.createPolicy(o,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Py=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Pr=function(t,n,i,r){return Ns(t,n)&&_o(t[n])?Nt(r.base?Ts(r.base):{},t[n],r.transform):i},Jf=function(t,n,i){const r=Ns(t,n)?t[n]:void 0;return r&&typeof r=="object"?Ts(r):i()};function bj(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:zO();const t=Se=>bj(Se);if(t.version="3.4.17",t.removed=[],!e||!e.document||e.document.nodeType!==vn.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const i=n,r=i.currentScript;e.DocumentFragment;const o=e.HTMLTemplateElement,c=e.Node,u=e.Element,d=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,m=e.trustedTypes,g=u.prototype,p=Xs(g,"cloneNode"),x=Xs(g,"remove"),y=Xs(g,"removeAttributeNode"),S=Xs(g,"nextSibling"),N=Xs(g,"childNodes"),k=Xs(g,"parentNode"),E=Xs(g,"shadowRoot"),j=Xs(g,"attributes"),A=c&&c.prototype?Xs(c.prototype,"nodeType"):null,P=c&&c.prototype?Xs(c.prototype,"nodeName"):null,L=c&&c.prototype?Xs(c.prototype,"ownerDocument"):null,B=function(K){return A?A(K):K.nodeType},V=function(K){return P?P(K):K.nodeName},M=NO(g,"namespaceURI"),z=function(K){return M?M(K):K.namespaceURI};if(typeof o=="function"){const Se=n.createElement("template");Se.content&&Se.content.ownerDocument&&(n=Se.content.ownerDocument)}let D,U="",I,T=!1,O=0;const $=function(){if(O>0)throw lr('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.')},F=function(K){$(),O++;try{return D.createHTML(K)}finally{O--}},H=function(K){$(),O++;try{return D.createScriptURL(K)}finally{O--}},Z=function(){return T||(I=LO(m,r),T=!0),I},G=n,q=G.implementation,X=G.createNodeIterator,Y=G.createDocumentFragment,re=G.getElementsByTagName,ee=i.importNode;let se=Py();t.isSupported=typeof pj=="function"&&typeof k=="function"&&q&&q.createHTMLDocument!==void 0;const ne=_O,ie=EO,pe=CO,Ce=AO,fe=IO,ve=TO,ue=$O,xe=RO;let De=My,Me=null;const Ge=Nt({},[...Ay,...Gf,...Kf,...Yf,...Iy]);let Te=null;const tt=Nt({},[...Ty,...Xf,...$y,...Tu]);let et=Object.seal(vo(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}})),St=null,zn=null;const rn=Object.seal(vo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let cn=!0,un=!0,an=!1,on=!0,Ft=!1,Bn=!0,jn=!1,Ss=!1,Ii=null,ni=null,si=!1,zs=!1,Ls=!1,Ds=!1,Fs=!0,ii=!1;const ri="user-content-";let os=!0,Xn=!1,wn=null,te={},ye=null;const Le=Nt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let st=null;const It=Nt({},["audio","video","img","source","image","track"]);let $t=null;const Ue=Nt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Fe="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",bt="http://www.w3.org/1999/xhtml";let yt=bt,Hn=!1,ls=null;const ai=Nt({},[Fe,Xe,bt],qf),gr=On(["mi","mo","mn","ms","mtext"]);let oi=Nt({},gr);const xr=On(["annotation-xml"]);let Zn=Nt({},xr);const Vi=Nt({},["title","style","font","a","script"]);let cs=null;const Ti=["application/xhtml+xml","text/html"],vr="text/html";let Rt=null,_s=null;const Qn=n.createElement("form"),qi=function(K){return K instanceof RegExp||K instanceof Function},li=function(){let K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(_s&&_s===K)return;(!K||typeof K!="object")&&(K={}),K=Ts(K),cs=Ti.indexOf(K.PARSER_MEDIA_TYPE)===-1?vr:K.PARSER_MEDIA_TYPE,Rt=cs==="application/xhtml+xml"?qf:ba,Me=Pr(K,"ALLOWED_TAGS",Ge,{transform:Rt}),Te=Pr(K,"ALLOWED_ATTR",tt,{transform:Rt}),ls=Pr(K,"ALLOWED_NAMESPACES",ai,{transform:qf}),$t=Pr(K,"ADD_URI_SAFE_ATTR",Ue,{transform:Rt,base:Ue}),st=Pr(K,"ADD_DATA_URI_TAGS",It,{transform:Rt,base:It}),ye=Pr(K,"FORBID_CONTENTS",Le,{transform:Rt}),St=Pr(K,"FORBID_TAGS",Ts({}),{transform:Rt}),zn=Pr(K,"FORBID_ATTR",Ts({}),{transform:Rt}),te=Ns(K,"USE_PROFILES")?K.USE_PROFILES&&typeof K.USE_PROFILES=="object"?Ts(K.USE_PROFILES):K.USE_PROFILES:!1,cn=K.ALLOW_ARIA_ATTR!==!1,un=K.ALLOW_DATA_ATTR!==!1,an=K.ALLOW_UNKNOWN_PROTOCOLS||!1,on=K.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ft=K.SAFE_FOR_TEMPLATES||!1,Bn=K.SAFE_FOR_XML!==!1,jn=K.WHOLE_DOCUMENT||!1,zs=K.RETURN_DOM||!1,Ls=K.RETURN_DOM_FRAGMENT||!1,Ds=K.RETURN_TRUSTED_TYPE||!1,si=K.FORCE_BODY||!1,Fs=K.SANITIZE_DOM!==!1,ii=K.SANITIZE_NAMED_PROPS||!1,os=K.KEEP_CONTENT!==!1,Xn=K.IN_PLACE||!1,De=jO(K.ALLOWED_URI_REGEXP)?K.ALLOWED_URI_REGEXP:My,yt=typeof K.NAMESPACE=="string"?K.NAMESPACE:bt,oi=Jf(K,"MATHML_TEXT_INTEGRATION_POINTS",()=>Nt({},gr)),Zn=Jf(K,"HTML_INTEGRATION_POINTS",()=>Nt({},xr));const le=Jf(K,"CUSTOM_ELEMENT_HANDLING",()=>vo(null));if(et=vo(null),Ns(le,"tagNameCheck")&&qi(le.tagNameCheck)&&(et.tagNameCheck=le.tagNameCheck),Ns(le,"attributeNameCheck")&&qi(le.attributeNameCheck)&&(et.attributeNameCheck=le.attributeNameCheck),Ns(le,"allowCustomizedBuiltInElements")&&typeof le.allowCustomizedBuiltInElements=="boolean"&&(et.allowCustomizedBuiltInElements=le.allowCustomizedBuiltInElements),Un(et),Ft&&(un=!1),Ls&&(zs=!0),te&&(Me=Nt({},Iy),Te=vo(null),te.html===!0&&(Nt(Me,Ay),Nt(Te,Ty)),te.svg===!0&&(Nt(Me,Gf),Nt(Te,Xf),Nt(Te,Tu)),te.svgFilters===!0&&(Nt(Me,Kf),Nt(Te,Xf),Nt(Te,Tu)),te.mathMl===!0&&(Nt(Me,Yf),Nt(Te,$y),Nt(Te,Tu))),rn.tagCheck=null,rn.attributeCheck=null,Ns(K,"ADD_TAGS")&&(typeof K.ADD_TAGS=="function"?rn.tagCheck=K.ADD_TAGS:_o(K.ADD_TAGS)&&(Me===Ge&&(Me=Ts(Me)),Nt(Me,K.ADD_TAGS,Rt))),Ns(K,"ADD_ATTR")&&(typeof K.ADD_ATTR=="function"?rn.attributeCheck=K.ADD_ATTR:_o(K.ADD_ATTR)&&(Te===tt&&(Te=Ts(Te)),Nt(Te,K.ADD_ATTR,Rt))),Ns(K,"ADD_FORBID_CONTENTS")&&_o(K.ADD_FORBID_CONTENTS)&&(ye===Le&&(ye=Ts(ye)),Nt(ye,K.ADD_FORBID_CONTENTS,Rt)),os&&(Me["#text"]=!0),jn&&Nt(Me,["html","head","body"]),Me.table&&(Nt(Me,["tbody"]),delete St.tbody),K.TRUSTED_TYPES_POLICY){if(typeof K.TRUSTED_TYPES_POLICY.createHTML!="function")throw lr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof K.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw lr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const Ne=D;D=K.TRUSTED_TYPES_POLICY;try{U=F("")}catch(je){throw D=Ne,je}}else K.TRUSTED_TYPES_POLICY===null?(D=void 0,U=""):(D===void 0&&(D=Z()),D&&typeof U=="string"&&(U=F("")));On&&On(K),_s=K},Ot=Nt({},[...Gf,...Kf,...wO]),yr=Nt({},[...Yf,...SO]),Gi=function(K,le,Ne){return le.namespaceURI===bt?K==="svg":le.namespaceURI===Fe?K==="svg"&&(Ne==="annotation-xml"||oi[Ne]):!!Ot[K]},ci=function(K,le,Ne){return le.namespaceURI===bt?K==="math":le.namespaceURI===Xe?K==="math"&&Zn[Ne]:!!yr[K]},$i=function(K,le,Ne){return le.namespaceURI===Xe&&!Zn[Ne]||le.namespaceURI===Fe&&!oi[Ne]?!1:!yr[K]&&(Vi[K]||!Ot[K])},$e=function(K){const le=z(K),Ne=ba(V(K)),je=k(K);let qe,nt;return je&&B(je)===vn.element?(qe={namespaceURI:z(je)},nt=ba(V(je))):(qe={namespaceURI:yt},nt="template"),ls[le]?le===Xe?Gi(Ne,qe,nt):le===Fe?ci(Ne,qe,nt):le===bt?$i(Ne,qe,nt):!!(cs==="application/xhtml+xml"&&ls[le]):!1},Ze=function(K){_l(t.removed,{element:K});try{k(K).removeChild(K)}catch{if(x(K),!k(K))throw lr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ct=function(K,le,Ne){try{y(K,le)}catch{try{K.removeAttribute(Ne)}catch{}}},ht=function(K){Us(K);const le=N(K);le&&or(pO(le),je=>{try{x(je)}catch{}});const Ne=B(K)===vn.element?j(K):null;if(Ne)for(let je=Ne.length-1;je>=0;--je){const qe=Ne[je],nt=qe&&qe.name;typeof nt=="string"&&ct(K,qe,nt)}},Tt=function(K,le,Ne){if(!Ne)try{Ne=le.getAttributeNode(K)}catch{Ne=null}_l(t.removed,{attribute:Ne||null,from:le});try{Ne?y(le,Ne):le.removeAttribute(K)}catch{try{le.removeAttribute(K)}catch{}}if(K==="is")if(zs||Ls)try{Ze(le)}catch{}else try{le.setAttribute(K,"")}catch{}},Pt=function(K){const le=j(K);if(le)for(let Ne=le.length-1;Ne>=0;--Ne){const je=le[Ne],qe=je&&je.name;typeof qe!="string"||Te[Rt(qe)]||ct(K,je,qe)}},Wn=function(K,le){let Ne=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const je=[K];for(;je.length>0;){const qe=je.pop();if(le(qe)===!1)continue;if(Ne&&B(qe)===vn.element){const mt=E(qe);hs(mt)&&je.push(mt)}const nt=N(qe);if(nt)for(let mt=nt.length-1;mt>=0;--mt)je.push(nt[mt])}},Us=function(K){Wn(K,le=>{B(le)===vn.element&&Pt(le)})},dn=function(K){const le=[];return Wn(K,Ne=>{le.push(Ne)},!0),le},Sn=function(K,le){const Ne=Wf();or(dn(K),je=>{B(je)===vn.element&&Vf(Ne,je)}),or(le,je=>{B(je)===vn.element&&!El(Ne,je)&&Pt(je)})},Bs=function(K,le){let Ne=!1;return or(t.removed,je=>{je.element&&(Ne=Ne||je.element===K,Us(je.element))}),Sn(K,le),Ne},Hs=8,us=function(K,le){const Ne=wn;let je=null;const qe=()=>(je||(je=Wf(),or(le,nt=>{Vf(je,nt)})),je);for(let nt=0;;nt++){const mt=dn(K),hn=[K];let fs=!1;if(or(mt,gn=>{B(gn)===vn.documentFragment?_l(hn,gn):!fs&&!El(Ne,gn)&&(fs=El(qe(),gn))}),!fs)return;if(nt>=Hs)throw lr("the tree kept changing during in-place sanitization; refusing to return it");or(hn,(gn,In)=>{sa(gn,In>0,K,qe())})}},sa=function(K,le,Ne,je){const qe=ds(K);let nt;for(;nt=qe.nextNode();)!El(je,nt)||El(wn,nt)||(le&&ft(se.uponSanitizeShadowNode,nt,null),Be(nt,Ne),Xi(nt,Ne),hs(nt.content)&&ra(nt.content))},br=function(K){wn&&Vf(wn,K)},Mi=function(K,le){return Bn?K==="patchsrc"?!0:K==="for"&&le!=="label"&&le!=="output":!1},kr=function(K){Bn&&Wn(K,le=>{const Ne=B(le);if(Ne===vn.processingInstruction||Ne===vn.comment&&Fn(Ry,le.data)){try{x(le)}catch{}return!1}if(Ne===vn.element){const je=le,qe=Rt(V(le));try{je.hasAttribute&&je.hasAttribute("patchsrc")&&je.removeAttribute("patchsrc"),je.hasAttribute&&je.hasAttribute("for")&&Mi("for",qe)&&je.removeAttribute("for")}catch{}}return!0})},Jn=function(K){let le=null,Ne=null;if(si)K="<remove></remove>"+K;else{const nt=Sy(K,/^[\r\n\t ]+/);Ne=nt&&nt[0]}cs==="application/xhtml+xml"&&yt===bt&&(K='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+K+"</body></html>");const je=D?F(K):K;if(yt===bt)try{le=new h().parseFromString(je,cs)}catch{}if(!le||!le.documentElement){le=q.createDocument(yt,"template",null);try{le.documentElement.innerHTML=Hn?U:je}catch{}}const qe=le.body||le.documentElement;return K&&Ne&&qe.insertBefore(n.createTextNode(Ne),qe.childNodes[0]||null),yt===bt?re.call(le,jn?"html":"body")[0]:jn?le.documentElement:qe},ds=function(K){const le=L?L(K):K.ownerDocument;return X.call(le||K,K,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},_n=function(K){return K=Cl(K,ne," "),K=Cl(K,ie," "),K=Cl(K,pe," "),K},Zs=function(K){var le;vt(K);const Ne=(le=K.querySelectorAll)===null||le===void 0?void 0:le.call(K,"template");Ne&&or(Ne,je=>{hs(je.content)&&Zs(je.content)})},vt=function(K){K.normalize();const le=L?L(K):K.ownerDocument,Ne=X.call(le||K,K,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let je=Ne.nextNode();for(;je;)je.data=_n(je.data),je=Ne.nextNode()},at=function(K){const le=P?P(K):null;return typeof le!="string"||Rt(le)!=="form"?!1:typeof K.nodeName!="string"||typeof K.textContent!="string"||typeof K.removeChild!="function"||K.attributes!==j(K)||typeof K.removeAttribute!="function"||typeof K.removeAttributeNode!="function"||typeof K.getAttributeNode!="function"||typeof K.setAttribute!="function"||typeof K.namespaceURI!="string"||typeof K.insertBefore!="function"||typeof K.hasChildNodes!="function"||K.nodeType!==A(K)||K.childNodes!==N(K)},hs=function(K){if(!A||typeof K!="object"||K===null)return!1;try{return A(K)===vn.documentFragment}catch{return!1}},zt=function(K){if(!A||typeof K!="object"||K===null)return!1;try{return typeof A(K)=="number"}catch{return!1}};function ft(Se,K,le){Se.length!==0&&or(Se,Ne=>{Ne.call(t,K,le,_s)})}const Ki=function(K,le){return!!(Bn&&K.hasChildNodes()&&!zt(K.firstElementChild)&&Fn(Qf,K.textContent)&&Fn(Qf,K.innerHTML)||Bn&&PO[le]&&B(K)===vn.element&&z(K)===bt&&(zt(K.firstElementChild)||typeof K.textContent=="string"&&Fn(Qf,K.textContent))||K.nodeType===vn.processingInstruction||Bn&&K.nodeType===vn.comment&&Fn(Ry,K.data))},es=function(K,le){if(K instanceof RegExp)return Fn(K,le);if(K instanceof Function){for(var Ne=arguments.length,je=new Array(Ne>2?Ne-2:0),qe=2;qe<Ne;qe++)je[qe-2]=arguments[qe];return!!K(le,...je)}return!1},Yi=function(K,le,Ne){if(!St[le]&&Ut(le)&&es(et.tagNameCheck,le))return!1;if(os&&!ye[le]&&!ye[ba(le)]){const je=k(K),qe=N(K);if(qe&&je){const nt=qe.length;for(let mt=nt-1;mt>=0;--mt){const hn=K===Ne?p(qe[mt],!0):qe[mt];je.insertBefore(hn,S(K))}}}return Ze(K),!0},ui=function(K,le,Ne,je){return K.length===0?le:le===Ne||le===je?Ts(le):le},Re=function(K,le){return K===le||k(K)!==null?!1:(Xn&&Us(K),!0)},Be=function(K,le){if(br(K),ft(se.beforeSanitizeElements,K,null),Re(K,le))return!0;if(at(K))return Ze(K),!0;const Ne=Rt(V(K));if(Me=ui(se.uponSanitizeElement,Me,Ge,Ii),ft(se.uponSanitizeElement,K,{tagName:Ne,allowedTags:Me}),Re(K,le))return!0;if(Ki(K,Ne))return Ze(K),!0;if(St[Ne]||!(rn.tagCheck instanceof Function&&rn.tagCheck(Ne))&&!Me[Ne]){const je=Yi(K,Ne,le);return je===!1&&(ft(se.afterSanitizeElements,K,null),Re(K,le))?!0:je}if(B(K)===vn.element&&!$e(K)||(Ne==="noscript"||Ne==="noembed"||Ne==="noframes")&&Fn(OO,K.innerHTML))return Ze(K),!0;if(Ft&&K.nodeType===vn.text){const je=_n(K.textContent);K.textContent!==je&&(_l(t.removed,{element:K.cloneNode()}),K.textContent=je)}return ft(se.afterSanitizeElements,K,null),Re(K,le)},ot=function(K,le,Ne){if(zn[le]||Mi(le,K)||Fs&&(le==="id"||le==="name")&&(Ne in n||Ne in Qn))return!1;const je=Te[le]||rn.attributeCheck instanceof Function&&rn.attributeCheck(le,K);return un&&Fn(Ce,le)||cn&&Fn(fe,le)?!0:je?$t[le]||Fn(De,Cl(Ne,ue,""))||(le==="src"||le==="xlink:href"||le==="href")&&K!=="script"&&_y(Ne,"data:")===0&&st[K]||an&&!Fn(ve,Cl(Ne,ue,""))?!0:!Ne:Ut(K)&&es(et.tagNameCheck,K)&&es(et.attributeNameCheck,le,K)||le==="is"&&et.allowCustomizedBuiltInElements&&es(et.tagNameCheck,Ne)},gt=Nt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Ut=function(K){return!gt[ba(K)]&&Fn(xe,K)},pn=function(K,le,Ne,je){if(D&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ne)switch(m.getAttributeType(K,le)){case"TrustedHTML":return F(je);case"TrustedScriptURL":return H(je)}return je},Xo=function(K,le,Ne,je){try{return Ne?K.setAttributeNS(Ne,le,je):K.setAttribute(le,je),at(K)?(Ze(K),!1):!0}catch{return Tt(le,K),!1}},ia=function(K,le){return Bn&&Fn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,le)?!0:ba(K)==="attributename"&&Sy(le,"href")!==null},Xi=function(K,le){if(ft(se.beforeSanitizeAttributes,K,null),Re(K,le))return;const Ne=K.attributes;if(!Ne||at(K))return;Te=ui(se.uponSanitizeAttribute,Te,tt,ni);const je={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Te,forceKeepAttr:void 0};let qe=Ne.length;const nt=Rt(K.nodeName);for(;qe--;){const mt=Ne[qe],hn=mt.name,fs=mt.namespaceURI,gn=mt.value,In=Rt(hn),Qi=gn;let Jt=hn==="value"?Qi:xO(Qi),Wa=!1;if(je.attrName=In,je.attrValue=Jt,je.keepAttr=!0,je.forceKeepAttr=void 0,ft(se.uponSanitizeAttribute,K,je),Jt=je.attrValue,ii&&(In==="id"||In==="name")&&_y(Jt,ri)!==0&&(Tt(hn,K,mt),Jt=ri+Jt,Wa=!0),ia(hn,Jt)){Tt(hn,K,mt);continue}if(!je.forceKeepAttr){if(!je.keepAttr){Tt(hn,K,mt);continue}if(!on&&Fn(Oy,Jt)){Tt(hn,K,mt);continue}if(Ft&&(Jt=_n(Jt)),!ot(nt,In,Jt)){Tt(hn,K,mt);continue}Jt=pn(nt,In,fs,Jt),Jt!==Qi&&Xo(K,hn,fs,Jt)&&Wa&&wy(t.removed)}}ft(se.afterSanitizeAttributes,K,null),Re(K,le)},ra=function(K){let le=null;const Ne=ds(K);for(ft(se.beforeSanitizeShadowDOM,K,null);le=Ne.nextNode();)if(ft(se.uponSanitizeShadowNode,le,null),Be(le,K),Xi(le,K),hs(le.content)&&ra(le.content),B(le)===vn.element){const je=E(le);hs(je)&&(Za(je),ra(je))}Ft&&vt(K),ft(se.afterSanitizeShadowDOM,K,null)},Za=function(K){const le=[{node:K,shadow:null}];for(;le.length>0;){const Ne=le.pop();if(Ne.shadow){ra(Ne.shadow);continue}const je=Ne.node,qe=B(je)===vn.element,nt=N(je);if(nt)for(let mt=nt.length-1;mt>=0;--mt)le.push({node:nt[mt],shadow:null});if(qe){const mt=P?P(je):null;if(typeof mt=="string"&&Rt(mt)==="template"){const hn=je.content;hs(hn)&&le.push({node:hn,shadow:null})}}if(qe){const mt=E(je);hs(mt)&&le.push({node:null,shadow:mt},{node:mt,shadow:null})}}};return t.sanitize=function(Se){let K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},le=null,Ne=null,je=null,qe=null;if(Hn=!Se,Hn&&(Se="<!-->"),typeof Se!="string"&&!zt(Se)&&(Se=kO(Se),typeof Se!="string"))throw lr("dirty is not a string, aborting");if(!t.isSupported)return Se;Ss?(Me=Ii,Te=ni):li(K),(se.uponSanitizeElement.length>0||se.uponSanitizeAttribute.length>0)&&(Me=Ts(Me)),se.uponSanitizeAttribute.length>0&&(Te=Ts(Te)),t.removed=[];const nt=Xn&&typeof Se!="string"&&zt(Se);let mt=[];const hn=wn;if(nt){kr(Se);const In=V(Se);if(typeof In=="string"){const Qi=Rt(In);if(!Me[Qi]||St[Qi])throw ht(Se),lr("root node is forbidden and cannot be sanitized in-place")}if(at(Se))throw ht(Se),lr("root node is clobbered and cannot be sanitized in-place");mt=dn(Se),wn=Wf()}else if(zt(Se))le=Jn("<!---->"),Ne=le.ownerDocument.importNode(Se,!0),Ne.nodeType===vn.element&&Ne.nodeName==="BODY"||Ne.nodeName==="HTML"?le=Ne:le.appendChild(Ne),Za(le);else{if(!zs&&!Ft&&!jn&&Se.indexOf("<")===-1)return D&&Ds?F(Se):Se;if(le=Jn(Se),!le)return zs?null:Ds?U:""}le&&si&&Ze(le.firstChild);const fs=nt?Se:le;try{nt&&Za(Se);const In=ds(fs);for(;je=In.nextNode();)Be(je,fs),Xi(je,fs),hs(je.content)&&ra(je.content);nt&&us(Se,mt)}catch(In){throw nt&&(ht(Se),Bs(Se,mt)),In}finally{wn=hn}if(nt){if(Bs(Se,mt))throw lr("a node selected for removal could not be safely returned; refusing to sanitize in place");return Ft&&Zs(Se),Se}if(zs){if(Ft&&Zs(le),Ls)for(qe=Y.call(le.ownerDocument);le.firstChild;)qe.appendChild(le.firstChild);else qe=le;return(Te.shadowroot||Te.shadowrootmode)&&(qe=ee.call(i,qe,!0)),qe}let gn=jn?le.outerHTML:le.innerHTML;return jn&&Me["!doctype"]&&le.ownerDocument&&le.ownerDocument.doctype&&le.ownerDocument.doctype.name&&Fn(MO,le.ownerDocument.doctype.name)&&(gn="<!DOCTYPE "+le.ownerDocument.doctype.name+`>
130
+ `+gn),Ft&&(gn=_n(gn)),D&&Ds?F(gn):gn},t.setConfig=function(){let Se=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};li(Se),Ss=!0,Ii=Me,ni=Te},t.clearConfig=function(){_s=null,Ss=!1,Ii=null,ni=null,D=I,U=""},t.isValidAttribute=function(Se,K,le){_s||li({});const Ne=Rt(Se),je=Rt(K);return typeof le=="string"&&(ia(K,le)||!on&&Fn(Oy,le))?!1:ot(Ne,je,le)},t.addHook=function(Se,K){typeof K=="function"&&Ns(se,Se)&&_l(se[Se],K)},t.removeHook=function(Se,K){if(Ns(se,Se)){if(K!==void 0){const le=mO(se[Se],K);return le===-1?void 0:gO(se[Se],le,1)[0]}return wy(se[Se])}},t.removeHooks=function(Se){Ns(se,Se)&&(se[Se]=[])},t.removeAllHooks=function(){se=Py()},t}var dg=bj();function hg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ha=hg();function kj(e){Ha=e}var Gl={exec:()=>null};function Ct(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(r,o)=>{let c=typeof o=="string"?o:o.source;return c=c.replace(as.caret,"$1"),n=n.replace(r,c),i},getRegex:()=>new RegExp(n,t)};return i}var DO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),as={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")},FO=/^(?:[ \t]*(?:\n|$))+/,UO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,BO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,bc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,HO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,fg=/(?:[*+-]|\d{1,9}[.)])/,Nj=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,jj=Ct(Nj).replace(/bull/g,fg).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(),ZO=Ct(Nj).replace(/bull/g,fg).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(),mg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,WO=/^[^\n]+/,pg=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,VO=Ct(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",pg).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),qO=Ct(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,fg).getRegex(),Dd="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",gg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,GO=Ct("^ {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",gg).replace("tag",Dd).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),wj=Ct(mg).replace("hr",bc).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",Dd).getRegex(),KO=Ct(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",wj).getRegex(),xg={blockquote:KO,code:UO,def:VO,fences:BO,heading:HO,hr:bc,html:GO,lheading:jj,list:qO,newline:FO,paragraph:wj,table:Gl,text:WO},zy=Ct("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",bc).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",Dd).getRegex(),YO={...xg,lheading:ZO,table:zy,paragraph:Ct(mg).replace("hr",bc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",zy).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",Dd).getRegex()},XO={...xg,html:Ct(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",gg).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:Gl,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ct(mg).replace("hr",bc).replace("heading",` *#{1,6} *[^
131
+ ]`).replace("lheading",jj).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},QO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,JO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Sj=/^( {2,}|\\)\n(?!\s*$)/,e2=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Fd=/[\p{P}\p{S}]/u,vg=/[\s\p{P}\p{S}]/u,_j=/[^\s\p{P}\p{S}]/u,t2=Ct(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,vg).getRegex(),Ej=/(?!~)[\p{P}\p{S}]/u,n2=/(?!~)[\s\p{P}\p{S}]/u,s2=/(?:[^\s\p{P}\p{S}]|~)/u,i2=Ct(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",DO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Cj=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,r2=Ct(Cj,"u").replace(/punct/g,Fd).getRegex(),a2=Ct(Cj,"u").replace(/punct/g,Ej).getRegex(),Aj="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",o2=Ct(Aj,"gu").replace(/notPunctSpace/g,_j).replace(/punctSpace/g,vg).replace(/punct/g,Fd).getRegex(),l2=Ct(Aj,"gu").replace(/notPunctSpace/g,s2).replace(/punctSpace/g,n2).replace(/punct/g,Ej).getRegex(),c2=Ct("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,_j).replace(/punctSpace/g,vg).replace(/punct/g,Fd).getRegex(),u2=Ct(/\\(punct)/,"gu").replace(/punct/g,Fd).getRegex(),d2=Ct(/^<(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(),h2=Ct(gg).replace("(?:-->|$)","-->").getRegex(),f2=Ct("^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",h2).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ud=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,m2=Ct(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",ud).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ij=Ct(/^!?\[(label)\]\[(ref)\]/).replace("label",ud).replace("ref",pg).getRegex(),Tj=Ct(/^!?\[(ref)\](?:\[\])?/).replace("ref",pg).getRegex(),p2=Ct("reflink|nolink(?!\\()","g").replace("reflink",Ij).replace("nolink",Tj).getRegex(),Ly=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,yg={_backpedal:Gl,anyPunctuation:u2,autolink:d2,blockSkip:i2,br:Sj,code:JO,del:Gl,emStrongLDelim:r2,emStrongRDelimAst:o2,emStrongRDelimUnd:c2,escape:QO,link:m2,nolink:Tj,punctuation:t2,reflink:Ij,reflinkSearch:p2,tag:f2,text:e2,url:Gl},g2={...yg,link:Ct(/^!?\[(label)\]\((.*?)\)/).replace("label",ud).getRegex(),reflink:Ct(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ud).getRegex()},up={...yg,emStrongRDelimAst:l2,emStrongLDelim:a2,url:Ct(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ly).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:Ct(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ly).getRegex()},x2={...up,br:Ct(Sj).replace("{2,}","*").getRegex(),text:Ct(up.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},$u={normal:xg,gfm:YO,pedantic:XO},Il={normal:yg,gfm:up,breaks:x2,pedantic:g2},v2={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Dy=e=>v2[e];function Di(e,t){if(t){if(as.escapeTest.test(e))return e.replace(as.escapeReplace,Dy)}else if(as.escapeTestNoEncode.test(e))return e.replace(as.escapeReplaceNoEncode,Dy);return e}function Fy(e){try{e=encodeURI(e).replace(as.percentDecode,"%")}catch{return null}return e}function Uy(e,t){var o;let n=e.replace(as.findPipe,(c,u,d)=>{let h=!1,m=u;for(;--m>=0&&d[m]==="\\";)h=!h;return h?"|":" |"}),i=n.split(as.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(as.slashPipe,"|");return i}function Tl(e,t,n){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 y2(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}function By(e,t,n,i,r){let o=t.href,c=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:n,href:o,title:c,text:u,tokens:i.inlineTokens(u)};return i.state.inLink=!1,d}function b2(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let r=i[1];return t.split(`
132
+ `).map(o=>{let c=o.match(n.other.beginningSpace);if(c===null)return o;let[u]=c;return u.length>=r.length?o.slice(r.length):o}).join(`
133
+ `)}var dd=class{constructor(e){ut(this,"options");ut(this,"rules");ut(this,"lexer");this.options=e||Ha}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Tl(n,`
134
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=b2(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:i}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let i=Tl(n,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(n=i.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Tl(t[0],`
135
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Tl(t[0],`
136
+ `).split(`
137
+ `),i="",r="",o=[];for(;n.length>0;){let c=!1,u=[],d;for(d=0;d<n.length;d++)if(this.rules.other.blockquoteStart.test(n[d]))u.push(n[d]),c=!0;else if(!c)u.push(n[d]);else break;n=n.slice(d);let 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 g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(m,o,!0),this.lexer.state.top=g,n.length===0)break;let p=o.at(-1);if((p==null?void 0:p.type)==="code")break;if((p==null?void 0:p.type)==="blockquote"){let x=p,y=x.raw+`
142
+ `+n.join(`
143
+ `),S=this.blockquote(y);o[o.length-1]=S,i=i.substring(0,i.length-x.raw.length)+S.raw,r=r.substring(0,r.length-x.text.length)+S.text;break}else if((p==null?void 0:p.type)==="list"){let x=p,y=x.raw+`
144
+ `+n.join(`
145
+ `),S=this.list(y);o[o.length-1]=S,i=i.substring(0,i.length-p.raw.length)+S.raw,r=r.substring(0,r.length-x.raw.length)+S.raw,n=y.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 n=t[1].trim(),i=n.length>1,r={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let o=this.rules.other.listItemRegex(n),c=!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 g=t[2].split(`
147
+ `,1)[0].replace(this.rules.other.listReplaceTabs,k=>" ".repeat(3*k.length)),p=e.split(`
148
+ `,1)[0],x=!g.trim(),y=0;if(this.options.pedantic?(y=2,m=g.trimStart()):x?y=t[1].length+1:(y=t[2].search(this.rules.other.nonSpaceChar),y=y>4?1:y,m=g.slice(y),y+=t[1].length),x&&this.rules.other.blankLine.test(p)&&(h+=p+`
149
+ `,e=e.substring(p.length+1),d=!0),!d){let k=this.rules.other.nextBulletRegex(y),E=this.rules.other.hrRegex(y),j=this.rules.other.fencesBeginRegex(y),A=this.rules.other.headingBeginRegex(y),P=this.rules.other.htmlBeginRegex(y);for(;e;){let L=e.split(`
150
+ `,1)[0],B;if(p=L,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),B=p):B=p.replace(this.rules.other.tabCharGlobal," "),j.test(p)||A.test(p)||P.test(p)||k.test(p)||E.test(p))break;if(B.search(this.rules.other.nonSpaceChar)>=y||!p.trim())m+=`
151
+ `+B.slice(y);else{if(x||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||j.test(g)||A.test(g)||E.test(g))break;m+=`
152
+ `+p}!x&&!p.trim()&&(x=!0),h+=L+`
153
+ `,e=e.substring(L.length+1),g=B.slice(y)}}r.loose||(c?r.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(c=!0));let S=null,N;this.options.gfm&&(S=this.rules.other.listIsTask.exec(m),S&&(N=S[0]!=="[ ] ",m=m.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:h,task:!!S,checked:N,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(g=>g.type==="space"),m=h.length>0&&h.some(g=>this.rules.other.anyLine.test(g.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 n=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:n,raw:t[0],href:i,title:r}}}table(e){var c;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Uy(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=(c=t[3])!=null&&c.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
154
+ `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.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<n.length;u++)o.header.push({text:n[u],tokens:this.lexer.inline(n[u]),header:!0,align:o.align[u]});for(let u of r)o.rows.push(Uy(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 n=t[1].charAt(t[1].length-1)===`
155
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=Tl(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=y2(t[2],"()");if(o===-2)return;if(o>-1){let c=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let 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(n)?i=i.slice(1):i=i.slice(1,-1)),By(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 n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[i.toLowerCase()];if(!r){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return By(n,r,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){let r=[...i[0]].length-1,o,c,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(c=[...o].length,i[3]||i[4]){u+=c;continue}else if((i[5]||i[6])&&r%3&&!((r+c)%3)){d+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);let m=[...i[0]][0].length,g=e.slice(0,r+i.index+m+c);if(Math.min(r,c)%2){let x=g.slice(1,-1);return{type:"em",raw:g,text:x,tokens:this.lexer.inlineTokens(x)}}let p=g.slice(2,-2);return{type:"strong",raw:g,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return i&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,i;return t[2]==="@"?(n=t[1],i="mailto:"+n):(n=t[1],i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;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]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[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 n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},yi=class dp{constructor(t){ut(this,"tokens");ut(this,"options");ut(this,"state");ut(this,"tokenizer");ut(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ha,this.options.tokenizer=this.options.tokenizer||new dd,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:as,block:$u.normal,inline:Il.normal};this.options.pedantic?(n.block=$u.pedantic,n.inline=Il.pedantic):this.options.gfm&&(n.block=$u.gfm,this.options.breaks?n.inline=Il.breaks:n.inline=Il.gfm),this.tokenizer.rules=n}static get rules(){return{block:$u,inline:Il}}static lex(t,n){return new dp(n).lex(t)}static lexInline(t,n){return new dp(n).inlineTokens(t)}lex(t){t=t.replace(as.carriageReturn,`
156
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let i=this.inlineQueue[n];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],i=!1){var r,o,c;for(this.options.pedantic&&(t=t.replace(as.tabCharGlobal," ").replace(as.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,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let h=n.at(-1);u.raw.length===1&&h!==void 0?h.raw+=`
157
+ `:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let h=n.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):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let h=n.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},n.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let d=t;if((c=this.options.extensions)!=null&&c.startBlock){let h=1/0,m=t.slice(1),g;this.options.extensions.startBlock.forEach(p=>{g=p.call({lexer:this},m),typeof g=="number"&&g>=0&&(h=Math.min(h,g))}),h<1/0&&h>=0&&(d=t.substring(0,h+1))}if(this.state.top&&(u=this.tokenizer.paragraph(d))){let h=n.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):n.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=n.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):n.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,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var d,h,m,g,p;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 c=!1,u="";for(;t;){c||(u=""),c=!1;let x;if((g=(m=this.options.extensions)==null?void 0:m.inline)!=null&&g.some(S=>(x=S.call({lexer:this},t,n))?(t=t.substring(x.raw.length),n.push(x),!0):!1))continue;if(x=this.tokenizer.escape(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.tag(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.link(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(x.raw.length);let S=n.at(-1);x.type==="text"&&(S==null?void 0:S.type)==="text"?(S.raw+=x.raw,S.text+=x.text):n.push(x);continue}if(x=this.tokenizer.emStrong(t,i,u)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.codespan(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.br(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.del(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.autolink(t)){t=t.substring(x.raw.length),n.push(x);continue}if(!this.state.inLink&&(x=this.tokenizer.url(t))){t=t.substring(x.raw.length),n.push(x);continue}let y=t;if((p=this.options.extensions)!=null&&p.startInline){let S=1/0,N=t.slice(1),k;this.options.extensions.startInline.forEach(E=>{k=E.call({lexer:this},N),typeof k=="number"&&k>=0&&(S=Math.min(S,k))}),S<1/0&&S>=0&&(y=t.substring(0,S+1))}if(x=this.tokenizer.inlineText(y)){t=t.substring(x.raw.length),x.raw.slice(-1)!=="_"&&(u=x.raw.slice(-1)),c=!0;let S=n.at(-1);(S==null?void 0:S.type)==="text"?(S.raw+=x.raw,S.text+=x.text):n.push(x);continue}if(t){let S="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(S);break}else throw new Error(S)}}return n}},hd=class{constructor(e){ut(this,"options");ut(this,"parser");this.options=e||Ha}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(as.notSpaceStart))==null?void 0:o[0],r=e.replace(as.endingNewline,"")+`
170
+ `;return i?'<pre><code class="language-'+Di(i)+'">'+(n?r:Di(r,!0))+`</code></pre>
171
+ `:"<pre><code>"+(n?r:Di(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,n=e.start,i="";for(let c=0;c<e.items.length;c++){let u=e.items[c];i+=this.listitem(u)}let r=t?"ol":"ul",o=t&&n!==1?' start="'+n+'"':"";return"<"+r+o+`>
177
+ `+i+"</"+r+`>
178
+ `}listitem(e){var n;let t="";if(e.task){let i=this.checkbox({checked:!!e.checked});e.loose?((n=e.tokens[0])==null?void 0:n.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+" "+Di(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="",n="";for(let r=0;r<e.header.length;r++)n+=this.tablecell(e.header[r]);t+=this.tablerow({text:n});let i="";for(let r=0;r<e.rows.length;r++){let o=e.rows[r];n="";for(let c=0;c<o.length;c++)n+=this.tablecell(o[c]);i+=this.tablerow({text:n})}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),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
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>${Di(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),r=Fy(e);if(r===null)return i;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+Di(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let r=Fy(e);if(r===null)return Di(n);e=r;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Di(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Di(e.text)}},bg=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""}},bi=class hp{constructor(t){ut(this,"options");ut(this,"renderer");ut(this,"textRenderer");this.options=t||Ha,this.options.renderer=this.options.renderer||new hd,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new bg}static parse(t,n){return new hp(n).parse(t)}static parseInline(t,n){return new hp(n).parseInline(t)}parse(t,n=!0){var r,o;let i="";for(let c=0;c<t.length;c++){let u=t[c];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(;c+1<t.length&&t[c+1].type==="text";)h=t[++c],m+=`
188
+ `+this.renderer.text(h);n?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,n=this.renderer){var r,o;let i="";for(let c=0;c<t.length;c++){let u=t[c];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+=n.text(d);break}case"html":{i+=n.html(d);break}case"link":{i+=n.link(d);break}case"image":{i+=n.image(d);break}case"strong":{i+=n.strong(d);break}case"em":{i+=n.em(d);break}case"codespan":{i+=n.codespan(d);break}case"br":{i+=n.br(d);break}case"del":{i+=n.del(d);break}case"text":{i+=n.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}},Gu,Fl=(Gu=class{constructor(e){ut(this,"options");ut(this,"block");this.options=e||Ha}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?yi.lex:yi.lexInline}provideParser(){return this.block?bi.parse:bi.parseInline}},ut(Gu,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ut(Gu,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Gu),k2=class{constructor(...e){ut(this,"defaults",hg());ut(this,"options",this.setOptions);ut(this,"parse",this.parseMarkdown(!0));ut(this,"parseInline",this.parseMarkdown(!1));ut(this,"Parser",bi);ut(this,"Renderer",hd);ut(this,"TextRenderer",bg);ut(this,"Lexer",yi);ut(this,"Tokenizer",dd);ut(this,"Hooks",Fl);this.use(...e)}walkTokens(e,t){var i,r;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let c=o;for(let u of c.header)n=n.concat(this.walkTokens(u.tokens,t));for(let u of c.rows)for(let d of u)n=n.concat(this.walkTokens(d.tokens,t));break}case"list":{let c=o;n=n.concat(this.walkTokens(c.items,t));break}default:{let c=o;(r=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&r[c.type]?this.defaults.extensions.childTokens[c.type].forEach(u=>{let d=c[u].flat(1/0);n=n.concat(this.walkTokens(d,t))}):c.tokens&&(n=n.concat(this.walkTokens(c.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.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(...c){let u=r.renderer.apply(this,c);return u===!1&&(u=o.apply(this,c)),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),n.renderer){let r=this.defaults.renderer||new hd(this.defaults);for(let o in n.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let c=o,u=n.renderer[c],d=r[c];r[c]=(...h)=>{let m=u.apply(r,h);return m===!1&&(m=d.apply(r,h)),m||""}}i.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new dd(this.defaults);for(let o in n.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let c=o,u=n.tokenizer[c],d=r[c];r[c]=(...h)=>{let m=u.apply(r,h);return m===!1&&(m=d.apply(r,h)),m}}i.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new Fl;for(let o in n.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let c=o,u=n.hooks[c],d=r[c];Fl.passThroughHooks.has(o)?r[c]=h=>{if(this.defaults.async&&Fl.passThroughHooksRespectAsync.has(o))return(async()=>{let g=await u.call(r,h);return d.call(r,g)})();let m=u.call(r,h);return d.call(r,m)}:r[c]=(...h)=>{if(this.defaults.async)return(async()=>{let g=await u.apply(r,h);return g===!1&&(g=await d.apply(r,h)),g})();let m=u.apply(r,h);return m===!1&&(m=d.apply(r,h)),m}}i.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(c){let u=[];return u.push(o.call(this,c)),r&&(u=u.concat(r.call(this,c))),u}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return yi.lex(e,t??this.defaults)}parser(e,t){return bi.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},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 c=r.hooks?await r.hooks.preprocess(t):t,u=await(r.hooks?await r.hooks.provideLexer():e?yi.lex:yi.lexInline)(c,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?bi.parse:bi.parseInline)(d,r);return r.hooks?await r.hooks.postprocess(h):h})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let c=(r.hooks?r.hooks.provideLexer():e?yi.lex:yi.lexInline)(t,r);r.hooks&&(c=r.hooks.processAllTokens(c)),r.walkTokens&&this.walkTokens(c,r.walkTokens);let u=(r.hooks?r.hooks.provideParser():e?bi.parse:bi.parseInline)(c,r);return r.hooks&&(u=r.hooks.postprocess(u)),u}catch(c){return o(c)}}}onError(e,t){return n=>{if(n.message+=`
189
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Di(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},Ma=new k2;function At(e,t){return Ma.parse(e,t)}At.options=At.setOptions=function(e){return Ma.setOptions(e),At.defaults=Ma.defaults,kj(At.defaults),At};At.getDefaults=hg;At.defaults=Ha;At.use=function(...e){return Ma.use(...e),At.defaults=Ma.defaults,kj(At.defaults),At};At.walkTokens=function(e,t){return Ma.walkTokens(e,t)};At.parseInline=Ma.parseInline;At.Parser=bi;At.parser=bi.parse;At.Renderer=hd;At.TextRenderer=bg;At.Lexer=yi;At.lexer=yi.lex;At.Tokenizer=dd;At.Hooks=Fl;At.parse=At;At.options;At.setOptions;At.use;At.walkTokens;At.parseInline;bi.parse;yi.lex;var em,Hy;function N2(){if(Hy)return em;Hy=1;function e(te){return te instanceof Map?te.clear=te.delete=te.set=function(){throw new Error("map is read-only")}:te instanceof Set&&(te.add=te.clear=te.delete=function(){throw new Error("set is read-only")}),Object.freeze(te),Object.getOwnPropertyNames(te).forEach(ye=>{const Le=te[ye],st=typeof Le;(st==="object"||st==="function")&&!Object.isFrozen(Le)&&e(Le)}),te}class t{constructor(ye){ye.data===void 0&&(ye.data={}),this.data=ye.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(te){return te.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function i(te,...ye){const Le=Object.create(null);for(const st in te)Le[st]=te[st];return ye.forEach(function(st){for(const It in st)Le[It]=st[It]}),Le}const r="</span>",o=te=>!!te.scope,c=(te,{prefix:ye})=>{if(te.startsWith("language:"))return te.replace("language:","language-");if(te.includes(".")){const Le=te.split(".");return[`${ye}${Le.shift()}`,...Le.map((st,It)=>`${st}${"_".repeat(It+1)}`)].join(" ")}return`${ye}${te}`};class u{constructor(ye,Le){this.buffer="",this.classPrefix=Le.classPrefix,ye.walk(this)}addText(ye){this.buffer+=n(ye)}openNode(ye){if(!o(ye))return;const Le=c(ye.scope,{prefix:this.classPrefix});this.span(Le)}closeNode(ye){o(ye)&&(this.buffer+=r)}value(){return this.buffer}span(ye){this.buffer+=`<span class="${ye}">`}}const d=(te={})=>{const ye={children:[]};return Object.assign(ye,te),ye};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(ye){this.top.children.push(ye)}openNode(ye){const Le=d({scope:ye});this.add(Le),this.stack.push(Le)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ye){return this.constructor._walk(ye,this.rootNode)}static _walk(ye,Le){return typeof Le=="string"?ye.addText(Le):Le.children&&(ye.openNode(Le),Le.children.forEach(st=>this._walk(ye,st)),ye.closeNode(Le)),ye}static _collapse(ye){typeof ye!="string"&&ye.children&&(ye.children.every(Le=>typeof Le=="string")?ye.children=[ye.children.join("")]:ye.children.forEach(Le=>{h._collapse(Le)}))}}class m extends h{constructor(ye){super(),this.options=ye}addText(ye){ye!==""&&this.add(ye)}startScope(ye){this.openNode(ye)}endScope(){this.closeNode()}__addSublanguage(ye,Le){const st=ye.root;Le&&(st.scope=`language:${Le}`),this.add(st)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(te){return te?typeof te=="string"?te:te.source:null}function p(te){return S("(?=",te,")")}function x(te){return S("(?:",te,")*")}function y(te){return S("(?:",te,")?")}function S(...te){return te.map(Le=>g(Le)).join("")}function N(te){const ye=te[te.length-1];return typeof ye=="object"&&ye.constructor===Object?(te.splice(te.length-1,1),ye):{}}function k(...te){return"("+(N(te).capture?"":"?:")+te.map(st=>g(st)).join("|")+")"}function E(te){return new RegExp(te.toString()+"|").exec("").length-1}function j(te,ye){const Le=te&&te.exec(ye);return Le&&Le.index===0}const A=new RegExp(k(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function P(te,{joinWith:ye}){let Le=0;return te.map(st=>{Le+=1;const It=Le;let $t=g(st),Ue="";for(;$t.length>0;){const Fe=A.exec($t);if(!Fe){Ue+=$t;break}Ue+=$t.substring(0,Fe.index),$t=$t.substring(Fe.index+Fe[0].length),Fe[0][0]==="\\"&&Fe[1]?Ue+="\\"+String(Number(Fe[1])+It):(Ue+=Fe[0],(Fe[0]==="("||/^\(\?[<']/.test(Fe[0]))&&Le++)}return Ue}).map(st=>`(${st})`).join(ye)}const L=/\b\B/,B="[a-zA-Z]\\w*",V="[a-zA-Z_]\\w*",M="\\b\\d+(\\.\\d+)?",z="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",D="\\b(0b[01]+)",U="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",I=(te={})=>{const ye=/^#![ ]*\//;return te.binary&&(te.begin=S(ye,/.*\b/,te.binary,/\b.*/)),i({scope:"meta",begin:ye,end:/$/,relevance:0,"on:begin":(Le,st)=>{Le.index!==0&&st.ignoreMatch()}},te)},T={begin:"\\\\[\\s\\S]",relevance:0},O={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[T]},$={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[T]},F={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},H=function(te,ye,Le={}){const st=i({scope:"comment",begin:te,end:ye,contains:[]},Le);st.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const It=k("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return st.contains.push({begin:S(/[ ]+/,"(",It,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),st},Z=H("//","$"),G=H("/\\*","\\*/"),q=H("#","$"),X={scope:"number",begin:M,relevance:0},Y={scope:"number",begin:z,relevance:0},re={scope:"number",begin:D,relevance:0},ee={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[T,{begin:/\[/,end:/\]/,relevance:0,contains:[T]}]},se={scope:"title",begin:B,relevance:0},ne={scope:"title",begin:V,relevance:0},ie={begin:"\\.\\s*"+V,relevance:0};var Ce=Object.freeze({__proto__:null,APOS_STRING_MODE:O,BACKSLASH_ESCAPE:T,BINARY_NUMBER_MODE:re,BINARY_NUMBER_RE:D,COMMENT:H,C_BLOCK_COMMENT_MODE:G,C_LINE_COMMENT_MODE:Z,C_NUMBER_MODE:Y,C_NUMBER_RE:z,END_SAME_AS_BEGIN:function(te){return Object.assign(te,{"on:begin":(ye,Le)=>{Le.data._beginMatch=ye[1]},"on:end":(ye,Le)=>{Le.data._beginMatch!==ye[1]&&Le.ignoreMatch()}})},HASH_COMMENT_MODE:q,IDENT_RE:B,MATCH_NOTHING_RE:L,METHOD_GUARD:ie,NUMBER_MODE:X,NUMBER_RE:M,PHRASAL_WORDS_MODE:F,QUOTE_STRING_MODE:$,REGEXP_MODE:ee,RE_STARTERS_RE:U,SHEBANG:I,TITLE_MODE:se,UNDERSCORE_IDENT_RE:V,UNDERSCORE_TITLE_MODE:ne});function fe(te,ye){te.input[te.index-1]==="."&&ye.ignoreMatch()}function ve(te,ye){te.className!==void 0&&(te.scope=te.className,delete te.className)}function ue(te,ye){ye&&te.beginKeywords&&(te.begin="\\b("+te.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",te.__beforeBegin=fe,te.keywords=te.keywords||te.beginKeywords,delete te.beginKeywords,te.relevance===void 0&&(te.relevance=0))}function xe(te,ye){Array.isArray(te.illegal)&&(te.illegal=k(...te.illegal))}function De(te,ye){if(te.match){if(te.begin||te.end)throw new Error("begin & end are not supported with match");te.begin=te.match,delete te.match}}function Me(te,ye){te.relevance===void 0&&(te.relevance=1)}const Ge=(te,ye)=>{if(!te.beforeMatch)return;if(te.starts)throw new Error("beforeMatch cannot be used with starts");const Le=Object.assign({},te);Object.keys(te).forEach(st=>{delete te[st]}),te.keywords=Le.keywords,te.begin=S(Le.beforeMatch,p(Le.begin)),te.starts={relevance:0,contains:[Object.assign(Le,{endsParent:!0})]},te.relevance=0,delete Le.beforeMatch},Te=["of","and","for","in","not","or","if","then","parent","list","value"],tt="keyword";function et(te,ye,Le=tt){const st=Object.create(null);return typeof te=="string"?It(Le,te.split(" ")):Array.isArray(te)?It(Le,te):Object.keys(te).forEach(function($t){Object.assign(st,et(te[$t],ye,$t))}),st;function It($t,Ue){ye&&(Ue=Ue.map(Fe=>Fe.toLowerCase())),Ue.forEach(function(Fe){const Xe=Fe.split("|");st[Xe[0]]=[$t,St(Xe[0],Xe[1])]})}}function St(te,ye){return ye?Number(ye):zn(te)?0:1}function zn(te){return Te.includes(te.toLowerCase())}const rn={},cn=te=>{console.error(te)},un=(te,...ye)=>{console.log(`WARN: ${te}`,...ye)},an=(te,ye)=>{rn[`${te}/${ye}`]||(console.log(`Deprecated as of ${te}. ${ye}`),rn[`${te}/${ye}`]=!0)},on=new Error;function Ft(te,ye,{key:Le}){let st=0;const It=te[Le],$t={},Ue={};for(let Fe=1;Fe<=ye.length;Fe++)Ue[Fe+st]=It[Fe],$t[Fe+st]=!0,st+=E(ye[Fe-1]);te[Le]=Ue,te[Le]._emit=$t,te[Le]._multi=!0}function Bn(te){if(Array.isArray(te.begin)){if(te.skip||te.excludeBegin||te.returnBegin)throw cn("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),on;if(typeof te.beginScope!="object"||te.beginScope===null)throw cn("beginScope must be object"),on;Ft(te,te.begin,{key:"beginScope"}),te.begin=P(te.begin,{joinWith:""})}}function jn(te){if(Array.isArray(te.end)){if(te.skip||te.excludeEnd||te.returnEnd)throw cn("skip, excludeEnd, returnEnd not compatible with endScope: {}"),on;if(typeof te.endScope!="object"||te.endScope===null)throw cn("endScope must be object"),on;Ft(te,te.end,{key:"endScope"}),te.end=P(te.end,{joinWith:""})}}function Ss(te){te.scope&&typeof te.scope=="object"&&te.scope!==null&&(te.beginScope=te.scope,delete te.scope)}function Ii(te){Ss(te),typeof te.beginScope=="string"&&(te.beginScope={_wrap:te.beginScope}),typeof te.endScope=="string"&&(te.endScope={_wrap:te.endScope}),Bn(te),jn(te)}function ni(te){function ye(Ue,Fe){return new RegExp(g(Ue),"m"+(te.case_insensitive?"i":"")+(te.unicodeRegex?"u":"")+(Fe?"g":""))}class Le{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Fe,Xe){Xe.position=this.position++,this.matchIndexes[this.matchAt]=Xe,this.regexes.push([Xe,Fe]),this.matchAt+=E(Fe)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Fe=this.regexes.map(Xe=>Xe[1]);this.matcherRe=ye(P(Fe,{joinWith:"|"}),!0),this.lastIndex=0}exec(Fe){this.matcherRe.lastIndex=this.lastIndex;const Xe=this.matcherRe.exec(Fe);if(!Xe)return null;const bt=Xe.findIndex((Hn,ls)=>ls>0&&Hn!==void 0),yt=this.matchIndexes[bt];return Xe.splice(0,bt),Object.assign(Xe,yt)}}class st{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Fe){if(this.multiRegexes[Fe])return this.multiRegexes[Fe];const Xe=new Le;return this.rules.slice(Fe).forEach(([bt,yt])=>Xe.addRule(bt,yt)),Xe.compile(),this.multiRegexes[Fe]=Xe,Xe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Fe,Xe){this.rules.push([Fe,Xe]),Xe.type==="begin"&&this.count++}exec(Fe){const Xe=this.getMatcher(this.regexIndex);Xe.lastIndex=this.lastIndex;let bt=Xe.exec(Fe);if(this.resumingScanAtSamePosition()&&!(bt&&bt.index===this.lastIndex)){const yt=this.getMatcher(0);yt.lastIndex=this.lastIndex+1,bt=yt.exec(Fe)}return bt&&(this.regexIndex+=bt.position+1,this.regexIndex===this.count&&this.considerAll()),bt}}function It(Ue){const Fe=new st;return Ue.contains.forEach(Xe=>Fe.addRule(Xe.begin,{rule:Xe,type:"begin"})),Ue.terminatorEnd&&Fe.addRule(Ue.terminatorEnd,{type:"end"}),Ue.illegal&&Fe.addRule(Ue.illegal,{type:"illegal"}),Fe}function $t(Ue,Fe){const Xe=Ue;if(Ue.isCompiled)return Xe;[ve,De,Ii,Ge].forEach(yt=>yt(Ue,Fe)),te.compilerExtensions.forEach(yt=>yt(Ue,Fe)),Ue.__beforeBegin=null,[ue,xe,Me].forEach(yt=>yt(Ue,Fe)),Ue.isCompiled=!0;let bt=null;return typeof Ue.keywords=="object"&&Ue.keywords.$pattern&&(Ue.keywords=Object.assign({},Ue.keywords),bt=Ue.keywords.$pattern,delete Ue.keywords.$pattern),bt=bt||/\w+/,Ue.keywords&&(Ue.keywords=et(Ue.keywords,te.case_insensitive)),Xe.keywordPatternRe=ye(bt,!0),Fe&&(Ue.begin||(Ue.begin=/\B|\b/),Xe.beginRe=ye(Xe.begin),!Ue.end&&!Ue.endsWithParent&&(Ue.end=/\B|\b/),Ue.end&&(Xe.endRe=ye(Xe.end)),Xe.terminatorEnd=g(Xe.end)||"",Ue.endsWithParent&&Fe.terminatorEnd&&(Xe.terminatorEnd+=(Ue.end?"|":"")+Fe.terminatorEnd)),Ue.illegal&&(Xe.illegalRe=ye(Ue.illegal)),Ue.contains||(Ue.contains=[]),Ue.contains=[].concat(...Ue.contains.map(function(yt){return zs(yt==="self"?Ue:yt)})),Ue.contains.forEach(function(yt){$t(yt,Xe)}),Ue.starts&&$t(Ue.starts,Fe),Xe.matcher=It(Xe),Xe}if(te.compilerExtensions||(te.compilerExtensions=[]),te.contains&&te.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return te.classNameAliases=i(te.classNameAliases||{}),$t(te)}function si(te){return te?te.endsWithParent||si(te.starts):!1}function zs(te){return te.variants&&!te.cachedVariants&&(te.cachedVariants=te.variants.map(function(ye){return i(te,{variants:null},ye)})),te.cachedVariants?te.cachedVariants:si(te)?i(te,{starts:te.starts?i(te.starts):null}):Object.isFrozen(te)?i(te):te}var Ls="11.12.0";class Ds extends Error{constructor(ye,Le){super(ye),this.name="HTMLInjectionError",this.html=Le}}const Fs=n,ii=i,ri=Symbol("nomatch"),os=7,Xn=function(te){const ye=Object.create(null),Le=Object.create(null),st=[];let It=!0;const $t="Could not find the language '{}', did you forget to load/include a language module?",Ue={disableAutodetect:!0,name:"Plain text",contains:[]};let Fe={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($e){return Fe.noHighlightRe.test($e)}function bt($e){let Ze=$e.className+" ";Ze+=$e.parentNode?$e.parentNode.className:"";const ct=Fe.languageDetectRe.exec(Ze);if(ct){const ht=Qn(ct[1]);return ht||(un($t.replace("{}",ct[1])),un("Falling back to no-highlight mode for this block.",$e)),ht?ct[1]:"no-highlight"}return Ze.split(/\s+/).find(ht=>Xe(ht)||Qn(ht))}function yt($e,Ze,ct){let ht="",Tt="";typeof Ze=="object"?(ht=$e,ct=Ze.ignoreIllegals,Tt=Ze.language):(an("10.7.0","highlight(lang, code, ...args) has been deprecated."),an("10.7.0",`Please use highlight(code, options) instead.
190
+ https://github.com/highlightjs/highlight.js/issues/2277`),Tt=$e,ht=Ze),ct===void 0&&(ct=!0);const Pt={code:ht,language:Tt};ci("before:highlight",Pt);const Wn=Pt.result?Pt.result:Hn(Pt.language,Pt.code,ct);return Wn.code=Pt.code,ci("after:highlight",Wn),Wn}function Hn($e,Ze,ct,ht){const Tt=Object.create(null);function Pt(Re,Be){return Re.keywords[Be]}function Wn(){if(!at.keywords){zt.addText(ft);return}let Re=0;at.keywordPatternRe.lastIndex=0;let Be=at.keywordPatternRe.exec(ft),ot="";for(;Be;){ot+=ft.substring(Re,Be.index);const gt=_n.case_insensitive?Be[0].toLowerCase():Be[0],Ut=Pt(at,gt);if(Ut){const[pn,Xo]=Ut;if(zt.addText(ot),ot="",Tt[gt]=(Tt[gt]||0)+1,Tt[gt]<=os&&(Ki+=Xo),pn.startsWith("_"))ot+=Be[0];else{const ia=_n.classNameAliases[pn]||pn;Sn(Be[0],ia)}}else ot+=Be[0];Re=at.keywordPatternRe.lastIndex,Be=at.keywordPatternRe.exec(ft)}ot+=ft.substring(Re),zt.addText(ot)}function Us(){if(ft==="")return;let Re=null;if(typeof at.subLanguage=="string"){if(!ye[at.subLanguage]){zt.addText(ft);return}Re=Hn(at.subLanguage,ft,!0,hs[at.subLanguage]),hs[at.subLanguage]=Re._top}else Re=ai(ft,at.subLanguage.length?at.subLanguage:null);at.relevance>0&&(Ki+=Re.relevance),zt.__addSublanguage(Re._emitter,Re.language)}function dn(){at.subLanguage!=null?Us():Wn(),ft=""}function Sn(Re,Be){Re!==""&&(zt.startScope(Be),zt.addText(Re),zt.endScope())}function Bs(Re,Be){let ot=1;const gt=Be.length-1;for(;ot<=gt;){if(!Re._emit[ot]){ot++;continue}const Ut=_n.classNameAliases[Re[ot]]||Re[ot],pn=Be[ot];Ut?Sn(pn,Ut):(ft=pn,Wn(),ft=""),ot++}}function Hs(Re,Be){return Re.scope&&typeof Re.scope=="string"&&zt.openNode(_n.classNameAliases[Re.scope]||Re.scope),Re.beginScope&&(Re.beginScope._wrap?(Sn(ft,_n.classNameAliases[Re.beginScope._wrap]||Re.beginScope._wrap),ft=""):Re.beginScope._multi&&(Bs(Re.beginScope,Be),ft="")),at=Object.create(Re,{parent:{value:at}}),at}function us(Re,Be,ot){let gt=j(Re.endRe,ot);if(gt){if(Re["on:end"]){const Ut=new t(Re);Re["on:end"](Be,Ut),Ut.isMatchIgnored&&(gt=!1)}if(gt){for(;Re.endsParent&&Re.parent;)Re=Re.parent;return Re}}if(Re.endsWithParent)return us(Re.parent,Be,ot)}function sa(Re){return at.matcher.regexIndex===0?(ft+=Re[0],1):(ui=!0,0)}function br(Re){const Be=Re[0],ot=Re.rule,gt=new t(ot),Ut=[ot.__beforeBegin,ot["on:begin"]];for(const pn of Ut)if(pn&&(pn(Re,gt),gt.isMatchIgnored))return sa(Be);return ot.skip?ft+=Be:(ot.excludeBegin&&(ft+=Be),dn(),!ot.returnBegin&&!ot.excludeBegin&&(ft=Be)),Hs(ot,Re),ot.returnBegin?0:Be.length}function Mi(Re){const Be=Re[0],ot=Ze.substring(Re.index),gt=us(at,Re,ot);if(!gt)return ri;const Ut=at;at.endScope&&at.endScope._wrap?(dn(),Sn(Be,at.endScope._wrap)):at.endScope&&at.endScope._multi?(dn(),Bs(at.endScope,Re)):Ut.skip?ft+=Be:(Ut.returnEnd||Ut.excludeEnd||(ft+=Be),dn(),Ut.excludeEnd&&(ft=Be));do at.scope&&zt.closeNode(),!at.skip&&!at.subLanguage&&(Ki+=at.relevance),at=at.parent;while(at!==gt.parent);return gt.starts&&Hs(gt.starts,Re),Ut.returnEnd?0:Be.length}function kr(){const Re=[];for(let Be=at;Be!==_n;Be=Be.parent)Be.scope&&Re.unshift(Be.scope);Re.forEach(Be=>zt.openNode(Be))}let Jn={};function ds(Re,Be){const ot=Be&&Be[0];if(ft+=Re,ot==null)return dn(),0;if(Jn.type==="begin"&&Be.type==="end"&&Jn.index===Be.index&&ot===""){if(ft+=Ze.slice(Be.index,Be.index+1),!It){const gt=new Error(`0 width match regex (${$e})`);throw gt.languageName=$e,gt.badRule=Jn.rule,gt}return 1}if(Jn=Be,Be.type==="begin")return br(Be);if(Be.type==="illegal"&&!ct){const gt=new Error('Illegal lexeme "'+ot+'" for mode "'+(at.scope||"<unnamed>")+'"');throw gt.mode=at,gt}else if(Be.type==="end"){const gt=Mi(Be);if(gt!==ri)return gt}if(Be.type==="illegal"&&ot==="")return Be.index===Ze.length||(ft+=`
191
+ `),1;if(Yi>1e5&&Yi>Be.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ft+=ot,ot.length}const _n=Qn($e);if(!_n)throw cn($t.replace("{}",$e)),new Error('Unknown language: "'+$e+'"');const Zs=ni(_n);let vt="",at=ht||Zs;const hs={},zt=new Fe.__emitter(Fe);kr();let ft="",Ki=0,es=0,Yi=0,ui=!1;try{if(_n.__emitTokens)_n.__emitTokens(Ze,zt);else{for(at.matcher.considerAll();;){Yi++,ui?ui=!1:at.matcher.considerAll(),at.matcher.lastIndex=es;const Re=at.matcher.exec(Ze);if(!Re)break;const Be=Ze.substring(es,Re.index),ot=ds(Be,Re);es=Re.index+ot}ds(Ze.substring(es))}return zt.finalize(),vt=zt.toHTML(),{language:$e,value:vt,relevance:Ki,illegal:!1,_emitter:zt,_top:at}}catch(Re){if(Re.message&&Re.message.includes("Illegal"))return{language:$e,value:Fs(Ze),illegal:!0,relevance:0,_illegalBy:{message:Re.message,index:es,context:Ze.slice(es-100,es+100),mode:Re.mode,resultSoFar:vt},_emitter:zt};if(It)return{language:$e,value:Fs(Ze),illegal:!1,relevance:0,errorRaised:Re,_emitter:zt,_top:at};throw Re}}function ls($e){const Ze={value:Fs($e),illegal:!1,relevance:0,_top:Ue,_emitter:new Fe.__emitter(Fe)};return Ze._emitter.addText($e),Ze}function ai($e,Ze){Ze=Ze||Fe.languages||Object.keys(ye);const ct=ls($e),ht=Ze.filter(Qn).filter(li).map(dn=>Hn(dn,$e,!1));ht.unshift(ct);const Tt=ht.sort((dn,Sn)=>{if(dn.relevance!==Sn.relevance)return Sn.relevance-dn.relevance;if(dn.language&&Sn.language){if(Qn(dn.language).supersetOf===Sn.language)return 1;if(Qn(Sn.language).supersetOf===dn.language)return-1}return 0}),[Pt,Wn]=Tt,Us=Pt;return Us.secondBest=Wn,Us}function gr($e,Ze,ct){const ht=Ze&&Le[Ze]||ct;$e.classList.add("hljs"),$e.classList.add(`language-${ht}`)}function oi($e){let Ze=null;const ct=bt($e);if(Xe(ct))return;if(ci("before:highlightElement",{el:$e,language:ct}),$e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",$e);return}if($e.children.length>0&&(Fe.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($e)),Fe.throwUnescapedHTML))throw new Ds("One of your code blocks includes unescaped HTML.",$e.innerHTML);Ze=$e;const ht=Ze.textContent,Tt=ct?yt(ht,{language:ct,ignoreIllegals:!0}):ai(ht);$e.innerHTML=Tt.value,$e.dataset.highlighted="yes",gr($e,ct,Tt.language),$e.result={language:Tt.language,re:Tt.relevance,relevance:Tt.relevance},Tt.secondBest&&($e.secondBest={language:Tt.secondBest.language,relevance:Tt.secondBest.relevance}),ci("after:highlightElement",{el:$e,result:Tt,text:ht})}function xr($e){Fe=ii(Fe,$e)}const Zn=()=>{Ti(),an("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Vi(){Ti(),an("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let cs=!1;function Ti(){function $e(){Ti()}if(document.readyState==="loading"){cs||window.addEventListener("DOMContentLoaded",$e,!1),cs=!0;return}document.querySelectorAll(Fe.cssSelector).forEach(oi)}function vr($e,Ze){let ct=null;try{ct=Ze(te)}catch(ht){if(cn("Language definition for '{}' could not be registered.".replace("{}",$e)),It)cn(ht);else throw ht;ct=Ue}ct.name||(ct.name=$e),ye[$e]=ct,ct.rawDefinition=Ze.bind(null,te),ct.aliases&&qi(ct.aliases,{languageName:$e})}function Rt($e){delete ye[$e];for(const Ze of Object.keys(Le))Le[Ze]===$e&&delete Le[Ze]}function _s(){return Object.keys(ye)}function Qn($e){return $e=($e||"").toLowerCase(),ye[$e]||ye[Le[$e]]}function qi($e,{languageName:Ze}){typeof $e=="string"&&($e=[$e]),$e.forEach(ct=>{Le[ct.toLowerCase()]=Ze})}function li($e){const Ze=Qn($e);return Ze&&!Ze.disableAutodetect}function Ot($e){$e["before:highlightBlock"]&&!$e["before:highlightElement"]&&($e["before:highlightElement"]=Ze=>{$e["before:highlightBlock"](Object.assign({block:Ze.el},Ze))}),$e["after:highlightBlock"]&&!$e["after:highlightElement"]&&($e["after:highlightElement"]=Ze=>{$e["after:highlightBlock"](Object.assign({block:Ze.el},Ze))})}function yr($e){Ot($e),st.push($e)}function Gi($e){const Ze=st.indexOf($e);Ze!==-1&&st.splice(Ze,1)}function ci($e,Ze){const ct=$e;st.forEach(function(ht){ht[ct]&&ht[ct](Ze)})}function $i($e){return an("10.7.0","highlightBlock will be removed entirely in v12.0"),an("10.7.0","Please use highlightElement now."),oi($e)}Object.assign(te,{highlight:yt,highlightAuto:ai,highlightAll:Ti,highlightElement:oi,highlightBlock:$i,configure:xr,initHighlighting:Zn,initHighlightingOnLoad:Vi,registerLanguage:vr,unregisterLanguage:Rt,listLanguages:_s,getLanguage:Qn,registerAliases:qi,autoDetection:li,inherit:ii,addPlugin:yr,removePlugin:Gi}),te.debugMode=function(){It=!1},te.safeMode=function(){It=!0},te.versionString=Ls,te.regex={concat:S,lookahead:p,either:k,optional:y,anyNumberOfTimes:x};for(const $e in Ce)typeof Ce[$e]=="object"&&e(Ce[$e]);return Object.assign(te,Ce),te},wn=Xn({});return wn.newInstance=()=>Xn({}),em=wn,wn.HighlightJS=wn,wn.default=wn,em}var j2=N2();const Si=Gp(j2);function w2(e){const t=e.regex,n={},i={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{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"}}),c={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},u={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,r]};r.contains.push(u);const d={match:/\\"/},h={className:"string",begin:/'/,end:/'/},m={match:/\\'/},g={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},p=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],x=e.SHEBANG({binary:`(${p.join("|")})`,relevance:10}),y={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},S=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],N=["true","false"],k={match:/(\/[a-z._-]+)+/},E=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],j=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],A=["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"],P=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:S,literal:N,built_in:[...E,...j,"set","shopt",...A,...P]},contains:[x,e.SHEBANG(),y,g,o,c,k,u,d,h,m,n]}}const S2=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_-]*/}}),_2=["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"],E2=["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"],C2=[..._2,...E2],A2=["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(),I2=["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(),T2=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),$2=["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 M2(e){const t=e.regex,n=S2(e),i={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},r="and or not only",o=/@-?\w[\w]*(-\w+)*/,c="[a-zA-Z-][a-zA-Z0-9_-]*",u=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,i,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+c,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+I2.join("|")+")"},{begin:":(:)?("+T2.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+$2.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...u,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...u,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:o},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:r,attribute:A2.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+C2.join("|")+")\\b"}]}}function R2(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 O2(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 yo="[0-9](_*[0-9])*",Mu=`\\.(${yo})`,Ru="[0-9a-fA-F](_*[0-9a-fA-F])*",Zy={className:"number",variants:[{begin:`(\\b(${yo})((${Mu})|\\.)?|(${Mu}))[eE][+-]?(${yo})[fFdD]?\\b`},{begin:`\\b(${yo})((${Mu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Mu})[fFdD]?\\b`},{begin:`\\b(${yo})[fFdD]\\b`},{begin:`\\b0[xX]((${Ru})\\.?|(${Ru})?\\.(${Ru}))[pP][+-]?(${yo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Ru})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function $j(e,t,n){return n===-1?"":e.replace(t,i=>$j(e,t,n-1))}function P2(e){const t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",i="(?:(?:\\s*\\[\\s*])+)?",r=n+"<@@@>"+i,c="(?:"+("\\?(?:\\s+(?:extends|super)\\s+"+r+")?")+"|"+r+")",u=$j("(?:\\s*<\\s*"+c+"(?:\\s*,\\s*"+c+")*\\s*>)?",/<@@@>/g,2),p={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:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},y={className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:p,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{beginKeywords:"new throw return else yield assert",relevance:0},{begin:[n,t.concat(u,i,/\s+/),n,i,/\s*/,/=(?!=)/],className:{1:"type",3:"variable",6:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{begin:[n,t.concat(u,i,/\s+/),n,/\s*(?=\()/],className:{1:"type",3:"title.function"},keywords:p,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[x,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,Zy,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},Zy,x]}}const Wy="[A-Za-z$_][0-9A-Za-z$_]*",z2=["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"],L2=["true","false","null","undefined","NaN","Infinity"],Mj=["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"],Rj=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Oj=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],D2=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],F2=[].concat(Oj,Mj,Rj);function U2(e){const t=e.regex,n=(H,{after:Z})=>{const G="</"+H[0].slice(1);return H.input.indexOf(G,Z)!==-1},i=Wy,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,Z)=>{const G=H[0].length+H.index,q=H.input[G];if(q==="<"||q===","){Z.ignoreMatch();return}q===">"&&(n(H,{after:G})||Z.ignoreMatch());let X;const Y=H.input.substring(G);if(X=Y.match(/^\s*=/)){Z.ignoreMatch();return}if((X=Y.match(/^\s+extends\s+/))&&X.index===0){Z.ignoreMatch();return}}},u={$pattern:Wy,keyword:z2,literal:L2,built_in:F2,"variable.language":D2},d="[0-9](_?[0-9])*",h=`\\.(${d})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={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},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"css"}},S={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},N={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,p]},E={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]},j=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,y,S,N,{match:/\$\d+/},g];p.contains=j.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(j)});const A=[].concat(E,p.contains),P=A.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(A)}]),L={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:P},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"}}]},V={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:{_:[...Mj,...Rj]}},M={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[L],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function U(H){return t.concat("(?!",H.join("|"),")")}const I={match:t.concat(/\b/,U([...Oj,"super","import","await"].map(H=>`${H}\\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},O={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},L]},$="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",F={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead($)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[L]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:P,CLASS_REFERENCE:V},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),M,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,y,S,N,E,{match:/\$\d+/},g,V,{scope:"attr",match:i+t.lookahead(":"),relevance:0},F,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,e.REGEXP_MODE,{className:"function",begin:$,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:P}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:o},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[L,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:[L]},I,D,B,O,{match:/\$[(.]/}]}}const B2="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",H2={scope:"number",match:B2,relevance:0};function Z2(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={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,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,H2,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function W2(e){const t=e.regex,n={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},c={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,d={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,u,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},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}]},g=e.inherit(h,{contains:[]}),p=e.inherit(m,{contains:[]});h.contains.push(p),m.contains.push(g);let x=[n,d];return[h,m,g,p].forEach(k=>{k.contains=k.contains.concat(x)}),x=x.concat(h,m),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:x},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:x}]}]},n,o,i,h,m,{className:"quote",begin:"^>\\s+",contains:x,end:"$"},r,d,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function V2(e){const t=e.regex,n=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},g={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]},p="[0-9](_?[0-9])*",x=`(\\b(${p}))?\\.(${p})|\\b(${p})\\.`,y=`\\b|${i.join("|")}`,S={className:"number",relevance:0,variants:[{begin:`(\\b(${p})|(${x}))[eE][+-]?(${p})[jJ]?(?=${y})`},{begin:`(${x})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${y})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${y})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${y})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${y})`},{begin:`\\b(${p})[jJ](?=${y})`}]},N={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},k={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",d,S,g,e.HASH_COMMENT_MODE]}]};return h.contains=[g,S,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[d,S,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,N,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[k]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[S,k,g]}]}}function q2(e){const t=e.regex,n=/(r#)?/,i=t.concat(n,e.UNDERSCORE_IDENT_RE),r=t.concat(n,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*\(/))},c="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",u=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],d=["true","false","Some","None","Ok","Err"],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_]+)"+c},{begin:"\\b0o([0-7_]+)"+c},{begin:"\\b0x([A-Fa-f0-9_]+)"+c},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+c}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,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 G2(e){const t=e.regex,n=e.COMMENT("--","$"),i={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},r={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],c=["double precision","large object","with timezone","without timezone"],u=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],d=["add","asc","collation","desc","final","first","last","view"],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"],g=["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"],p=["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,y=[...h,...d].filter(P=>!m.includes(P)),S={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},N={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},k={match:t.concat(/\b/,t.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function E(P){return t.concat(/\b/,t.either(...P.map(L=>L.replace(/\s+/,"\\s+"))),/\b/)}const j={scope:"keyword",match:E(p),relevance:0};function A(P,{exceptions:L,when:B}={}){const V=B;return L=L||[],P.map(M=>M.match(/\|\d+$/)||L.includes(M)?M:V(M)?`${M}|0`:M)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:A(y,{when:P=>P.length<3}),literal:o,type:u,built_in:g},contains:[{scope:"type",match:E(c)},j,k,S,i,r,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,N]}}const fd="[A-Za-z$_][0-9A-Za-z$_]*",Pj=["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"],zj=["true","false","null","undefined","NaN","Infinity"],Lj=["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"],Dj=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Fj=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Uj=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],Bj=[].concat(Fj,Lj,Dj);function K2(e){const t=e.regex,n=(H,{after:Z})=>{const G="</"+H[0].slice(1);return H.input.indexOf(G,Z)!==-1},i=fd,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,Z)=>{const G=H[0].length+H.index,q=H.input[G];if(q==="<"||q===","){Z.ignoreMatch();return}q===">"&&(n(H,{after:G})||Z.ignoreMatch());let X;const Y=H.input.substring(G);if(X=Y.match(/^\s*=/)){Z.ignoreMatch();return}if((X=Y.match(/^\s+extends\s+/))&&X.index===0){Z.ignoreMatch();return}}},u={$pattern:fd,keyword:Pj,literal:zj,built_in:Bj,"variable.language":Uj},d="[0-9](_?[0-9])*",h=`\\.(${d})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={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},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"css"}},S={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},N={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,p]},E={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]},j=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,y,S,N,{match:/\$\d+/},g];p.contains=j.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(j)});const A=[].concat(E,p.contains),P=A.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(A)}]),L={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:P},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"}}]},V={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:{_:[...Lj,...Dj]}},M={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[L],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function U(H){return t.concat("(?!",H.join("|"),")")}const I={match:t.concat(/\b/,U([...Fj,"super","import","await"].map(H=>`${H}\\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},O={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},L]},$="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",F={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead($)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[L]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:P,CLASS_REFERENCE:V},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),M,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,y,S,N,E,{match:/\$\d+/},g,V,{scope:"attr",match:i+t.lookahead(":"),relevance:0},F,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,e.REGEXP_MODE,{className:"function",begin:$,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:P}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.end},{match:o},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[L,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:[L]},I,D,B,O,{match:/\$[(.]/}]}}function Y2(e){const t=e.regex,n=K2(e),i=fd,r=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},c={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:r},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},d=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],h={$pattern:fd,keyword:Pj.concat(d),literal:zj,built_in:Bj.concat(r),"variable.language":Uj},m={className:"meta",begin:"@"+i},g=(S,N,k)=>{const E=S.contains.findIndex(j=>j.label===N);if(E===-1)throw new Error("can not find mode to replace");S.contains.splice(E,1,k)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(m);const p=n.contains.find(S=>S.scope==="attr"),x=Object.assign({},p,{match:t.concat(i,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,p,x]),n.contains=n.contains.concat([m,o,c,x]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",u);const y=n.contains.find(S=>S.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function X2(e){const t=e.regex,n=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/}]},c=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,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,c,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(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:h}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Q2(e){const t="true false yes no null",n="[\\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}]},c={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,r]},u=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),p={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},y={begin:/\{/,end:/\}/,contains:[x],illegal:"\\n",relevance:0},S={begin:"\\[",end:"\\]",contains:[x],illegal:"\\n",relevance:0},N=[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+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},p,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,S,o,c],k=[...N];return k.pop(),k.push(u),x.contains=k,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:N}}for(const[e,t]of Object.entries({bash:w2,css:M2,diff:R2,go:O2,java:P2,javascript:U2,json:Z2,markdown:W2,python:V2,rust:q2,sql:G2,typescript:Y2,xml:X2,yaml:Q2}))Si.registerLanguage(e,t);Si.registerAliases(["sh","shell","zsh","console"],{languageName:"bash"});Si.registerAliases(["ts","tsx","mts","cts"],{languageName:"typescript"});Si.registerAliases(["js","jsx","mjs","cjs"],{languageName:"javascript"});Si.registerAliases(["html","svg","vue"],{languageName:"xml"});Si.registerAliases(["py"],{languageName:"python"});Si.registerAliases(["yml"],{languageName:"yaml"});Si.registerAliases(["rs"],{languageName:"rust"});Si.registerAliases(["md"],{languageName:"markdown"});const Vy=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");At.setOptions({gfm:!0,breaks:!1});At.use({renderer:{code({text:e,lang:t}){const n=(t??"").trim().split(/\s+/)[0]??"",r=n!==""&&Si.getLanguage(n)!==void 0?Si.highlight(e,{language:n,ignoreIllegals:!0}).value:Vy(e);return`<div class="code-block"><div class="code-head"><span class="code-lang">${Vy(n===""?"text":n)}</span><button type="button" class="code-copy" data-copy="">复制</button></div><pre><code class="hljs">${r}</code></pre></div>`}}});function J2(e){let t=e.trim();if(/^file:/i.test(t)){try{t=decodeURIComponent(t.replace(/^file:\/{2,3}/i,""))}catch{return}/^[A-Za-z]:/.test(t)===!1&&/^[^/]+\//.test(t)&&(t=`//${t}`)}const n=/^\/([A-Za-z])\/(.*)$/.exec(t);if(n!==null&&(t=`${n[1].toUpperCase()}:/${n[2]}`),!(!/^[A-Za-z]:[\\/]/.test(t)&&!/^(\\\\|\/\/)[^\\/]/.test(t)))return t.replace(/\//g,"\\").replace(/[#?].*$/,"")}dg.addHook("beforeSanitizeAttributes",e=>{if(e.tagName!=="A")return;const t=J2(e.getAttribute("href")??"");t!==void 0&&(e.removeAttribute("href"),e.setAttribute("data-local-path",t),e.setAttribute("title",t),e.classList.add("local-path"))});dg.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 eP(e){var o;const t=e.dataset.localPath;if(t===void 0)return;const n=c=>{e.dataset.note=c,setTimeout(()=>{delete e.dataset.note},2200)},i=wi();if((i==null?void 0:i.openPath)!==void 0){i.openPath(t).then(c=>n(c==="missing"?"找不到这个文件":c==="revealed"?"已在文件夹中显示":"已打开"),()=>n("打不开"));return}(((o=navigator.clipboard)==null?void 0:o.writeText(t))??Promise.reject(new Error("no clipboard"))).then(()=>n("浏览器里打不开本地文件,路径已复制"),()=>n(Hj(t)?"浏览器里打不开本地文件,路径已复制":t))}function tP(e){var u,d;const t=e.target.closest("a[data-local-path]");if(t!==null){e.preventDefault(),eP(t);return}const n=e.target.closest("button[data-copy]"),i=(u=n==null?void 0:n.closest(".code-block"))==null?void 0:u.querySelector("pre");if(n==null||i==null)return;const r=i.innerText,o=h=>{n.textContent=h?"已复制":"复制失败",n.classList.toggle("copied",h),setTimeout(()=>{n.textContent="复制",n.classList.remove("copied")},1600)};(((d=navigator.clipboard)==null?void 0:d.writeText(r))??Promise.reject(new Error("no clipboard"))).then(()=>o(!0),()=>o(Hj(r)))}function Hj(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 Js=b.memo(function({text:t,className:n}){const i=b.useMemo(()=>dg.sanitize(At.parse(t,{async:!1})),[t]);return s.jsx("div",{className:`markdown ${n??""}`,onClick:tP,dangerouslySetInnerHTML:{__html:i}})}),qy="adg.update.later",nP=360*6e4,Zj="https://github.com/haaahhhis/MultiGameAssistant/releases",tm="dsh-multigameassistant";function kg(){var i;const e=(i=wi())==null?void 0:i.updates,[t,n]=b.useState(e===void 0?null:void 0);return b.useEffect(()=>{if(e===void 0)return;let r=!0;e.state().then(c=>{r&&n(c)},()=>{r&&n(null)});const o=e.onChange(c=>{r&&n(c)});return()=>{r=!1,o()}},[e]),{bridge:e,state:t}}const Gy=new WeakMap;function sP(e){let t=Gy.get(e);if(t!==void 0)return t;let n={checking:!1};const i=new Set,r=d=>{n=d;for(const h of i)h()};let o=0,c;const u=()=>{n.checking||(r({...n,checking:!0}),e.connection.call("about/checkUpdate",{}).then(d=>r({checking:!1,result:d}),d=>r({checking:!1,...n.result===void 0?{}:{result:n.result},error:d instanceof Error?d.message:String(d)})))};return t={get:()=>n,subscribe(d){return i.add(d),()=>{i.delete(d)}},check:u,watch(){return o++===0&&(n.result===void 0&&!n.checking&&u(),c=setInterval(u,nP)),()=>{--o===0&&c!==void 0&&(clearInterval(c),c=void 0)}}},Gy.set(e,t),t}function Wj(e){const t=we(e.capabilities),n=we(e.connection.status),i=t.has("about"),[r,o]=b.useState(void 0);if(b.useEffect(()=>{if(n.state!=="open")return;if(!i){o(null);return}let c=!0;return e.connection.call("about/info",{}).then(u=>{c&&o(u)},()=>{c&&o(null)}),()=>{c=!1}},[e,i,n.state]),r!==void 0)return(r==null?void 0:r.edition)==="plugin"&&r.version!==void 0?{version:r.version}:!1}function Vj(e,t){const n=sP(e),i=b.useSyncExternalStore(n.subscribe,n.get);return b.useEffect(()=>t?n.watch():void 0,[n,t]),{...i,check:n.check}}function qj(e){var c;const{bridge:t,state:n}=kg(),i=Wj(e),r=Vj(e,t===void 0&&i!==!1&&i!==void 0);if(t!==void 0){const u=n==null?void 0:n.latest;return n==null||u===void 0||u.version===n.skipped?null:{kind:"desktop",current:n.current,version:u.version,prerelease:u.prerelease,notesUrl:u.notesUrl,notes:u.notes??[],bridge:t,state:n}}const o=(c=r.result)==null?void 0:c.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||Zj,notes:o.notes??[],...o.onNpm===void 0?{}:{onNpm:o.onNpm}}}function iP(e,t=3){var r,o,c;const n=((r=e[0])==null?void 0:r.body)??"",i=[];for(const u of n.split(`
192
+ `)){const d=(o=/^\s*[-*]\s+(.+)$/.exec(u))==null?void 0:o[1];if(d===void 0)continue;const m=(((c=/^\*\*(.+?)\*\*/.exec(d))==null?void 0:c[1])??d).replace(/\*\*|`|\[([^\]]*)\]\([^)]*\)/g,(g,p)=>p??"").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 rP(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 Ng({notes:e,notesUrl:t}){return e.length===0?s.jsxs("p",{className:"muted small",children:["发布页没有写这次的更新说明。",s.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:"在 GitHub 上看"})]}):s.jsx("div",{className:"release-notes",children:e.map(n=>s.jsxs("section",{className:"release-note",children:[s.jsxs("div",{className:"release-note-head",children:[s.jsx("strong",{children:n.title!==void 0&&n.title!==`v${n.version}`?n.title:`版本 ${n.version}`}),s.jsx("span",{className:"muted small",children:rP(n.publishedAt)}),n.url!==""&&s.jsx("a",{className:"small",href:n.url,target:"_blank",rel:"noreferrer",children:"发布页"})]}),n.body===""?s.jsx("p",{className:"muted small",children:"这个版本没有写更新说明。"}):s.jsx(Js,{className:"release-note-body",text:n.body})]},n.version))})}let Gj=!1;const fp=new Set,mp=e=>{Gj=e;for(const t of fp)t()},aP=e=>(fp.add(e),()=>{fp.delete(e)});function Kj(){mp(!0)}function oP({client:e}){const t=b.useSyncExternalStore(aP,()=>Gj),n=qj(e);if(b.useEffect(()=>{if(!t)return;const r=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),mp(!1))};return document.addEventListener("keydown",r,!0),()=>document.removeEventListener("keydown",r,!0)},[t]),!t||n===null)return null;const i=()=>mp(!1);return s.jsx("div",{className:"dialog-backdrop",onPointerDown:r=>{r.target===r.currentTarget&&i()},children:s.jsxs("div",{className:"dialog update-notes-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"update-notes-title",children:[s.jsxs("div",{className:"update-notes-head",children:[s.jsxs("h3",{id:"update-notes-title",children:[s.jsx(J,{name:"download"}),"MultiGameAssistant ",n.version," 可以更新了"]}),s.jsx("button",{className:"ghost icon-button","aria-label":"关闭",title:"关闭",onClick:i,children:s.jsx(J,{name:"close"})})]}),s.jsxs("p",{className:"muted small",children:["当前版本 ",n.current,n.prerelease?" · 新版本是预发布版":"",n.notes.length>1?` · 更新后会带上下面 ${n.notes.length} 个版本的改动`:""]}),s.jsx("div",{className:"update-notes-body",children:s.jsx(Ng,{notes:n.notes,notesUrl:n.notesUrl})}),n.kind==="desktop"?s.jsx(jg,{bridge:n.bridge,state:n.state,extra:s.jsx("button",{className:"ghost small-button",onClick:()=>{n.bridge.skip(n.version),i()},children:"跳过这个版本"})}):s.jsx(Yj,{version:n.version,onNpm:n.onNpm})]})})}function nm(e){return e>=1024*1024?`${Math.round(e/1024/1024)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function jg({bridge:e,state:t,extra:n}){var m;const[i,r]=b.useState(null),[o,c]=b.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=g=>{r(null),g().catch(p=>r(p instanceof Error?p.message.replace(/^Error invoking remote method '[^']+': (Error: )?/,""):String(p)))};return s.jsxs("div",{className:"update-actions",children:[(d==null?void 0:d.state)==="downloading"&&s.jsxs("div",{className:"update-progress",children:[s.jsx("div",{className:"progress",role:"progressbar","aria-label":"下载进度","aria-valuemin":0,"aria-valuemax":d.total,"aria-valuenow":d.received,children:s.jsx("span",{style:{width:`${d.total>0?Math.min(100,d.received/d.total*100):0}%`}})}),s.jsxs("small",{className:"muted",children:["正在下载 ",nm(d.received)," / ",nm(d.total)]})]}),(d==null?void 0:d.state)==="ready"&&s.jsx("p",{className:"muted small",children:"安装时程序会退出,正在跑的脚本会被中断;装好后自动重新打开,数据和定时任务都在。"}),(d==null?void 0:d.state)==="failed"&&s.jsx("p",{className:"error small",children:d.error}),i!==null&&s.jsx("p",{className:"error small",children:i}),s.jsxs("div",{className:"update-buttons",children:[n,(d==null?void 0:d.state)==="ready"?s.jsx("button",{className:"primary small-button",disabled:o,onClick:()=>{c(!0),h(()=>e.install().finally(()=>c(!1)))},children:o?"正在启动安装…":"退出并安装"}):s.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"?"正在下载…":`下载更新(${nm(u.size)})`})]})]})}function Yj({version:e,onNpm:t}){const n=`${Zj}/download/v${e}/${tm}.tgz`;return s.jsxs("div",{className:"plugin-update",children:[t!==!1&&s.jsxs("p",{children:["在 dsh 的「Plugins」→「Add plugin」里再填一次 ",s.jsx(sm,{text:tm})," 安装(命令行的 dsh:",s.jsx(sm,{text:`dsh plugin add ${tm}`}),")。",t===void 0&&"没连上 npm,不知道那边有没有这个版本;装完版本没变的话,用下面的链接。"]}),t!==!0&&s.jsxs("p",{children:[t===!1&&"npm 上还没有这个版本(要等发布者批准)。","在「Add plugin」里填这个链接安装:",s.jsx(sm,{text:n})]}),s.jsx("p",{className:"muted small",children:"装好后刷新这个页面。你的数据、脚本和定时任务都在 dsh 的数据目录里,重新安装不会丢。"})]})}function sm({text:e}){const[t,n]=b.useState(!1),i=()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1500)},()=>{})};return s.jsxs("span",{className:"copy-code",children:[s.jsx("code",{children:e}),s.jsx("button",{type:"button",className:"link-button",onClick:i,title:"复制",children:t?s.jsx(J,{name:"check"}):s.jsx(J,{name:"copy"})})]})}function lP(){var d;const{bridge:e,state:t}=kg(),[n,i]=b.useState(()=>{try{return sessionStorage.getItem(qy)}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===n))return null;const c=()=>{try{sessionStorage.setItem(qy,r.version)}catch{}i(r.version)},u=iP(r.notes??[]);return s.jsxs("div",{className:"approval-card update-card",role:"status",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(J,{name:"download"}),s.jsxs("div",{className:"approval-text",children:[s.jsxs("span",{className:"approval-title",children:["MultiGameAssistant ",r.version," 可以更新了"]}),s.jsxs("span",{className:"approval-tool",children:["当前 ",t.current,r.prerelease?" · 预发布版":""]})]}),!o&&s.jsx("button",{className:"ghost icon-button update-close","aria-label":"稍后提醒",title:"稍后(下次启动再提醒)",onClick:c,children:s.jsx(J,{name:"close"})})]}),u.length>0&&s.jsx("ul",{className:"update-highlights",children:u.map(h=>s.jsx("li",{children:h},h))}),s.jsx(jg,{bridge:e,state:t,extra:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ghost small-button",onClick:Kj,children:"更新介绍"}),!o&&s.jsx("button",{className:"ghost small-button",onClick:()=>void e.skip(r.version),children:"跳过这个版本"})]})})]})}function cP({client:e,sessionId:t,onSelect:n}){var m;const i=we(e.approvals),r=we(e.questions),o=(m=tO(e))==null?void 0:m.pending,c=i.filter(g=>g.sessionId===t),u=r.filter(g=>g.sessionId===t),d=[...i,...r].filter(g=>g.sessionId!==t),h=d.some(g=>"approvalId"in g)?d.some(g=>"questionId"in g)?"审批或回答":"审批":"回答";return s.jsxs("div",{className:"approval-dock",children:[o!==void 0&&s.jsx(nO,{client:e,pending:o}),u.map(g=>s.jsx(dP,{client:e,request:g},g.questionId)),c.map(g=>s.jsx(uP,{client:e,request:g},g.approvalId)),d.length>0&&s.jsxs("button",{className:"approval-elsewhere",onClick:()=>n(d[0].sessionId),children:[s.jsx("span",{className:"approval-dot"}),"另有 ",new Set(d.map(g=>g.sessionId)).size," 个会话在等你",h,s.jsx(J,{name:"chevron"})]}),s.jsx(sO,{client:e}),s.jsx(JR,{client:e}),s.jsx(lP,{})]})}function uP({client:e,request:t}){var d,h,m;const[n,i]=b.useState(!1),[r,o]=b.useState(null),c=((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 g=>{i(!0);try{await e.respondApproval(t.approvalId,g)}catch(p){o(p instanceof Error?p.message:String(p)),i(!1)}};return s.jsxs("div",{className:"approval-card",role:"alertdialog","aria-label":"需要审批",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(J,{name:"shield"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("div",{className:"approval-title",children:"需要你的批准"}),s.jsx("code",{className:"approval-tool",children:t.toolName})]})]}),c!==void 0&&s.jsx("div",{className:"approval-reason",children:c}),r!==null&&s.jsx("div",{className:"error small",children:r}),s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{disabled:n,onClick:()=>void u("reject"),children:"拒绝"}),s.jsx("button",{className:"inverse",disabled:n,onClick:()=>void u("allow-once"),children:"允许本次"})]})]})}function dP({client:e,request:t}){var S;const[n,i]=b.useState({}),[r,o]=b.useState(!1),[c,u]=b.useState(null),d=t.questions.length===1&&t.questions[0].multiSelect!==!0&&(((S=t.questions[0].options)==null?void 0:S.length)??0)>0,h=N=>n[N]??{selected:[],custom:""},m=async N=>{o(!0),u(null);try{await e.answerQuestion(t.questionId,N)}catch(k){u(k instanceof Error?k.message:String(k)),o(!1)}},g=(N,k)=>{if(d)return void m([{id:N.id,selected:[k]}]);i(E=>{const j=E[N.id]??{selected:[],custom:""},A=N.multiSelect===!0?j.selected.includes(k)?j.selected.filter(P=>P!==k):[...j.selected,k]:j.selected.includes(k)?[]:[k];return{...E,[N.id]:{...j,selected:A}}})},p=(N,k)=>i(E=>({...E,[N.id]:{...E[N.id]??{selected:[]},custom:k}})),x=()=>t.questions.map(N=>{const{selected:k,custom:E}=h(N.id),j=E.trim();return{id:N.id,selected:j!==""&&N.multiSelect!==!0?[]:k,...j===""?{}:{custom:j}}}),y=t.questions.every(N=>h(N.id).selected.length>0||h(N.id).custom.trim()!=="");return s.jsxs("div",{className:"approval-card question-card",role:"alertdialog","aria-label":"agent 在问你",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(J,{name:"chat"}),s.jsx("div",{className:"approval-text",children:s.jsx("div",{className:"approval-title",children:"agent 在问你"})})]}),t.questions.map(N=>{var k,E;return s.jsxs("div",{className:"question-item",children:[N.header!==void 0&&s.jsx("span",{className:"question-header",children:N.header}),s.jsx("div",{className:"question-text",children:N.question}),N.detail!==void 0&&s.jsx("div",{className:"question-detail",children:N.detail}),(((k=N.options)==null?void 0:k.length)??0)>0&&s.jsx("div",{className:"question-options",role:N.multiSelect===!0?"group":"radiogroup",children:N.options.map(j=>{const A=h(N.id).selected.includes(j.label);return s.jsxs("button",{className:`question-option${A?" on":""}`,disabled:r,role:N.multiSelect===!0?"checkbox":"radio","aria-checked":A,onClick:()=>g(N,j.label),children:[s.jsx("span",{className:"question-option-label",children:j.label}),j.description!==void 0&&s.jsx("span",{className:"question-option-desc",children:j.description})]},j.label)})}),s.jsx("input",{className:"text-input question-custom",value:h(N.id).custom,disabled:r,placeholder:(((E=N.options)==null?void 0:E.length)??0)>0?"或者直接写你的回答":"写下你的回答",onChange:j=>p(N,j.target.value),onKeyDown:j=>{j.key==="Enter"&&!j.nativeEvent.isComposing&&y&&m(x())}})]},N.id)}),c!==null&&s.jsx("div",{className:"error small",children:c}),s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{disabled:r,onClick:()=>void m(t.questions.map(N=>({id:N.id,selected:[]}))),children:"跳过"}),s.jsx("button",{className:"inverse",disabled:r||!y,onClick:()=>void m(x()),children:"回答"})]})]})}const is="main",hP={intervene:"alert",games:"gamepad",scripts:"package",pipelines:"flow"},bn={id:is,name:"助手",description:"和你对话、替你安排;飞书里的消息也到这里",icon:"chat"};function Ko(e){return{id:e.id,name:e.name,description:e.description,icon:hP[e.id]??"sparkles"}}function ti(e){const t=we(e.connection.status),[n,i]=b.useState([]);return b.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]),b.useEffect(()=>e.connection.on("roles/changed",r=>i(r.items)),[e]),n}function Ra(e,t){return e.role!==void 0&&t.some(n=>n.id===e.role)?e.role:is}function fP(e){return e==="你"?"你布置的":`来自${e}`}function Xj(e,t){const n=we(e.connection.status),[i,r]=b.useState(new Map),o=b.useRef(new Map),c=d=>`${d.updatedAt}${d.running?"+":""}`,u=t.map(d=>`${d.id}@${c(d)}`).join(",");return b.useEffect(()=>{if(n.state!=="open")return;const d=t.filter(h=>o.current.get(h.id)!==c(h)).slice(0,60);if(d.length!==0){for(const h of d)o.current.set(h.id,c(h));e.connection.call("sessions/lastReplies",{sessionIds:d.map(h=>h.id)}).then(h=>{r(m=>{const g=new Map(m);for(const p of h.items)g.set(p.sessionId,p.text);return g})}).catch(()=>{for(const h of d)o.current.delete(h.id)})}},[e,n.state,u]),i}const Qj="adg.agentSeen";function mP(){try{const e=JSON.parse(localStorage.getItem(Qj)??"{}");return e!==null&&typeof e=="object"?e:{}}catch{return{}}}function pP(){const[e,t]=b.useState(mP);return{seen:e,markSeen:(i,r)=>{t(o=>{if((o[i]??0)>=r)return o;const c={...o,[i]:r};try{localStorage.setItem(Qj,JSON.stringify(c))}catch{}return c})}}}function Jj(e,t){const n=we(e.connection.status),[i,r]=b.useState({agentId:t,sessionId:null,error:null});return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return e.connection.call("agents/home",{agentId:t}).then(c=>{o&&r({agentId:t,sessionId:c.sessionId,error:null})},c=>{o&&r({agentId:t,sessionId:null,error:c instanceof Error?c.message:String(c)})}),()=>{o=!1}},[e,t,n.state]),i.agentId===t?i:{sessionId:null,error:null}}function gP(e,t){const n=we(e.connection.status),i=we(e.capabilities),[r,o]=b.useState([]);return b.useEffect(()=>{if(n.state!=="open"||!i.has("agents"))return;let c=!0;return e.connection.call("handoffs/list",{sessionId:t}).then(u=>{c&&o(u.items)}).catch(()=>{}),()=>{c=!1}},[e,t,n.state,i]),b.useEffect(()=>e.connection.on("handoffs/changed",({item:c})=>{c.fromSession!==t&&c.toSession!==t||o(u=>[...u.filter(d=>d.id!==c.id),c])}),[e,t]),r}const xP={feishu:"飞书"},im=30;function ew(e){const t=we(e.connection.status),n=we(e.capabilities),[i,r]=b.useState(new Set),o=n.has("archive");return b.useEffect(()=>{if(t.state!=="open"||!o)return;let c=!0;return e.connection.call("sessions/archived",{}).then(u=>{c&&r(new Set(u.sessionIds))}).catch(()=>{}),()=>{c=!1}},[e,t.state,o]),b.useEffect(()=>e.connection.on("sessions/archived",c=>r(new Set(c.sessionIds))),[e]),i}function vP(e,t){const n=we(e.sessions),i=we(e.approvals),r=we(e.questions),o=ti(e),c=ew(e),{seen:u,markSeen:d}=pP(),h=b.useMemo(()=>[bn,...o.map(Ko)],[o]),m=b.useMemo(()=>{var x;const p=new Map(h.map(y=>[y.id,[]]));for(const y of n.items)y.origin==="subagent"||y.blank||c.has(y.id)||(x=p.get(Ra(y,o)))==null||x.push(y);for(const y of p.values())y.sort((S,N)=>N.updatedAt-S.updatedAt);return p},[n.items,c,h,o]);b.useEffect(()=>{var p,x;if(n.loaded)for(const y of h){const S=(x=(p=m.get(y.id))==null?void 0:p[0])==null?void 0:x.updatedAt;S!==void 0&&(y.id===t||u[y.id]===void 0)&&d(y.id,S)}},[n.loaded,m,t]);const g=p=>{const x=n.items.find(y=>y.id===p);return x===void 0?void 0:Ra(x,o)};return h.map(p=>{const x=m.get(p.id)??[],y=x[0];return{agent:p,running:x.filter(S=>S.running).length,unread:p.id!==t&&y!==void 0&&y.updatedAt>(u[p.id]??1/0),waiting:[...i,...r].filter(S=>g(S.sessionId)===p.id).length}})}function yP(e,t){const n=we(e.sessions),i=ti(e);return n.items.some(r=>r.origin!=="subagent"&&!r.blank&&r.home!==t&&Ra(r,i)===t)}function bP({client:e,agentId:t,onSelect:n}){const i=we(e.sessions),r=we(e.connection.status),o=we(e.capabilities),c=ti(e),u=ew(e),d=An(3e4),[h,m]=b.useState(null),[g,p]=b.useState(""),[x,y]=b.useState(!1),[S,N]=b.useState(!1),[k,E]=b.useState(new Map),[j,A]=b.useState(0),P=o.has("archive");b.useEffect(()=>e.connection.on("notify/changed",()=>A(O=>O+1)),[e]),b.useEffect(()=>{if(r.state!=="open"||!o.has("notify"))return;let O=!0;return e.connection.call("notify/conversations",{}).then($=>{O&&E(new Map($.items.map(F=>[F.sessionId,{channel:F.channel,user:F.user}])))}).catch(()=>{}),()=>{O=!1}},[e,r.state,o,j]);const L=O=>{const $=k.get(O.id);return $!==void 0?xP[$.channel]??$.channel:/^(飞书|feishu):/.test(O.title??"")?"飞书":void 0},B=g.trim().toLowerCase(),{earlier:V,archivedItems:M}=b.useMemo(()=>{const O=i.items.filter($=>$.origin!=="subagent"&&!$.blank&&$.home!==t&&Ra($,c)===t&&(B===""||mo($).toLowerCase().includes(B))).sort(($,F)=>F.updatedAt-$.updatedAt);return{earlier:O.filter($=>!u.has($.id)),archivedItems:O.filter($=>u.has($.id))}},[i.items,t,c,u,B]),[z,D]=b.useState(null),U=async()=>{const O=z;D(null);const $=(O==null?void 0:O.value.trim())??"",F=i.items.find(H=>H.id===(O==null?void 0:O.id));O===null||F===void 0||$===""||$===mo(F)||await e.renameSession(O.id,$).catch(H=>m(H instanceof Error?H.message:String(H)))},I=async(O,$)=>{m(null),await e.connection.call($?"sessions/archive":"sessions/unarchive",{sessionId:O}).catch(F=>m(F instanceof Error?F.message:String(F)))},T=O=>{const $=L(O),F=u.has(O.id);return s.jsxs("div",{className:"session-row",children:[(z==null?void 0:z.id)===O.id?s.jsx("input",{className:"text-input session-rename",autoFocus:!0,value:z.value,maxLength:80,"aria-label":"会话名称",onFocus:H=>H.target.select(),onChange:H=>D({id:O.id,value:H.target.value}),onKeyDown:H=>{H.key==="Enter"&&!H.nativeEvent.isComposing&&U(),H.key==="Escape"&&D(null)},onBlur:()=>void U()}):s.jsxs("button",{className:"nav-item session-item",onClick:()=>n(O.id),onDoubleClick:()=>D({id:O.id,value:mo(O)}),title:"双击改名",children:[$!==void 0&&s.jsx("span",{className:"channel-badge",children:$}),s.jsx("span",{className:"nav-item-label",children:$!==void 0?mo(O).replace(/^(飞书|feishu):/,""):mo(O)}),O.running?s.jsx("span",{className:"run-dot",role:"img","aria-label":"运行中"}):s.jsx("span",{className:"session-time",children:Et(O.updatedAt,d)})]}),(z==null?void 0:z.id)!==O.id&&s.jsxs("span",{className:"session-row-actions",children:[s.jsx("button",{className:"session-action",title:"改名","aria-label":"改名",onClick:()=>D({id:O.id,value:mo(O)}),children:s.jsx(J,{name:"pencil"})}),P&&!O.running&&s.jsx("button",{className:"session-action",title:F?"恢复":"归档:从列表里移走,之后可以在「已归档」里找回","aria-label":F?"恢复":"归档",onClick:()=>void I(O.id,!F),children:s.jsx(J,{name:F?"back":"archive"})})]})]},O.id)};return s.jsx("section",{className:"main history-page",children:s.jsxs("div",{className:"history-body",children:[s.jsxs("label",{className:"sidebar-search",children:[s.jsx(J,{name:"search"}),s.jsx("input",{"aria-label":"搜索以前的对话",placeholder:"搜索以前的对话",value:g,onChange:O=>p(O.target.value),onKeyDown:O=>{O.key==="Escape"&&p("")}})]}),h!==null&&s.jsx("div",{className:"error small",children:h}),s.jsxs("nav",{className:"session-list","aria-label":"以前的对话",children:[!i.loaded&&r.state==="open"&&s.jsx("div",{className:"muted small pad",children:"加载中…"}),i.loaded&&V.length===0&&s.jsxs("div",{className:"sidebar-empty",children:[s.jsx(J,{name:B===""?"chat":"search"}),s.jsx("span",{children:B===""?"没有以前的对话":"没有匹配的对话"})]}),(S?V:V.slice(0,im)).map(T),!S&&V.length>im&&s.jsxs("button",{className:"nav-item more-sessions",onClick:()=>N(!0),children:["更多(",V.length-im,")"]}),P&&M.length>0&&s.jsxs("div",{className:"archive-entry",children:[s.jsxs("button",{className:"nav-item role-row",onClick:()=>y(O=>!O),"aria-expanded":x,children:[s.jsx(J,{name:"archive"}),s.jsx("span",{className:"nav-item-label",children:"已归档"}),s.jsx("span",{className:"tab-count",children:M.length}),s.jsx(J,{name:x?"chevron-down":"chevron",className:"role-chevron"})]}),x&&M.map(T)]})]})]})})}function mo(e){return e.title??(e.blank?"新会话":"未命名会话")}function Et(e,t){const n=Math.max(0,Math.round((t-e)/1e3));return n<60?"刚刚":n<3600?`${Math.floor(n/60)} 分钟前`:n<86400?`${Math.floor(n/3600)} 小时前`:n<86400*7?`${Math.floor(n/86400)} 天前`:new Date(e).toLocaleDateString(void 0,{month:"numeric",day:"numeric"})}function kP({client:e,pages:t,current:n,onAgent:i,onPage:r,onSchedule:o,onSettings:c}){const u=we(e.connection.status),d=we(e.capabilities),h=vP(e,n.kind==="agent"?n.id:void 0),m=qj(e),g=p=>s.jsx(Ou,{icon:p.icon,label:p.title,active:n.kind==="page"&&n.id===p.id,onClick:()=>r(p.id)},p.id);return s.jsxs("nav",{className:"rail","aria-label":"功能区",children:[s.jsx("button",{className:"rail-brand",onClick:()=>{var p;return i(((p=h[0])==null?void 0:p.agent.id)??"")},title:"MultiGameAssistant",children:s.jsx(zd,{})}),s.jsxs("div",{className:"rail-items",children:[t.filter(p=>p.order<0).map(g),s.jsx("span",{className:"rail-divider",role:"separator"}),h.map(p=>s.jsx(NP,{state:p,active:n.kind==="agent"&&n.id===p.agent.id,onClick:()=>i(p.agent.id)},p.agent.id)),t.filter(p=>p.order>=0).map(g)]}),s.jsxs("div",{className:"rail-footer",children:[m!==null&&s.jsx(Ou,{icon:"download",label:"更新",title:`MultiGameAssistant ${m.version} 可以更新了:点开看更新了什么`,active:!1,onClick:Kj,dot:!0}),d.has("pipelines")&&s.jsx(Ou,{icon:"calendar",label:"定时",title:"每个 agent 的定时任务,和按时运行的流水线",active:n.kind==="schedule",onClick:o}),s.jsx(Ou,{icon:"settings",label:"设置",active:n.kind==="settings",onClick:c}),s.jsxs("span",{className:`rail-connection ${u.state}`,role:"status",title:Ky(u.state,u.attempt,u.error),children:[s.jsx("span",{className:"conn-dot"}),s.jsx("span",{className:"sr-only",children:Ky(u.state,u.attempt,u.error)})]})]}),s.jsx(oP,{client:e})]})}function NP({state:e,active:t,onClick:n}){const{agent:i,running:r,unread:o,waiting:c}=e;return s.jsxs("button",{className:`rail-item rail-agent ${t?"active":""}`,"aria-current":t?"page":void 0,onClick:n,title:`${i.name}:${i.description}${r>0?`(进行中${r>1?` ${r}`:""})`:""}`,children:[s.jsxs("span",{className:`agent-avatar rail-avatar agent-${i.id}`,children:[s.jsx(J,{name:i.icon}),r>0&&s.jsx("span",{className:"agent-busy",role:"img","aria-label":`${r} 个正在运行`})]}),s.jsx("span",{className:`rail-label ${o?"unread":""}`,children:i.name}),c>0?s.jsx("span",{className:"rail-badge","aria-label":`${c} 个等你处理`,children:c}):o&&s.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新结果"})]})}function Ou({icon:e,label:t,title:n=t,active:i,onClick:r,disabled:o=!1,dot:c=!1}){return s.jsxs("button",{className:`rail-item ${i?"active":""} ${c?"rail-new":""}`,"aria-current":i?"page":void 0,onClick:r,title:n,disabled:o,children:[s.jsx(J,{name:e}),s.jsx("span",{className:"rail-label",children:t}),c&&s.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新版本"})]})}function Ky(e,t,n){const i=e==="open"?"已连接 agent":e==="connecting"?"正在连接…":e==="reconnecting"?`重连中(第 ${t} 次)`:"未连接";return n===void 0?i:`${i}:${n}`}const pp="adg.token",wg=/^\/adg(\/|$)/.test(location.pathname);function jP(){var e;for(const t of[window,window.parent])try{const n=(e=t.__DSH_TRANSPORT__)==null?void 0:e.streamBaseUrl;if(typeof n=="string"&&n!=="")return n}catch{}}function tw(){const e=new URL(location.href),t=e.searchParams.get("token");if(t!==null&&t!==""){try{sessionStorage.setItem(pp,t)}catch{}return e.searchParams.delete("token"),history.replaceState(history.state,"",e),t}try{return sessionStorage.getItem(pp)}catch{return null}}function wP(e){try{sessionStorage.setItem(pp,e)}catch{}}function SP(e){if(wg){const n=new URL(jP()??location.origin);return`${n.protocol==="https:"?"wss":"ws"}://${n.host}/adg/rpc`}return`${location.protocol==="https:"?"wss":"ws"}://${location.host}/rpc?token=${encodeURIComponent(e??"")}`}function Yy(){if(location.hash==="#/settings")return{kind:"settings"};const e=/^#\/settings\/(.+)$/.exec(location.hash);if(e!==null)return{kind:"settings",section:decodeURIComponent(e[1])};const t=/^#\/w\/([^/]+)\/(.+)$/.exec(location.hash);if(t!==null)return{kind:"window",view:decodeURIComponent(t[1]),sessionId:decodeURIComponent(t[2])};const n=/^#\/p\/([^/]+)(?:\/(.+))?$/.exec(location.hash);if(n!==null)return{kind:"page",id:decodeURIComponent(n[1]),...n[2]===void 0?{}:{arg:decodeURIComponent(n[2])}};if(location.hash==="#/chat")return{kind:"home"};if(location.hash==="#/schedule")return{kind:"schedule"};const i=/^#\/h\/(.+)$/.exec(location.hash);if(i!==null)return{kind:"handoff",id:decodeURIComponent(i[1])};const r=/^#\/a\/(.+)\/(schedule|history)$/.exec(location.hash);if(r!==null)return{kind:"agent",id:decodeURIComponent(r[1]),tab:r[2]};const o=/^#\/a\/(.+)$/.exec(location.hash);if(o!==null)return{kind:"agent",id:decodeURIComponent(o[1])};const c=/^#\/s\/(.+)$/.exec(location.hash);return c===null?{kind:"start"}:{kind:"session",id:decodeURIComponent(c[1])}}function _P(e,t="push"){const n=e.kind==="window"?`#/w/${encodeURIComponent(e.view)}/${encodeURIComponent(e.sessionId)}`:e.kind==="session"?`#/s/${encodeURIComponent(e.id)}`:e.kind==="agent"?`#/a/${encodeURIComponent(e.id)}${e.tab===void 0?"":`/${e.tab}`}`:e.kind==="handoff"?`#/h/${encodeURIComponent(e.id)}`:e.kind==="schedule"?"#/schedule":e.kind==="page"?`#/p/${encodeURIComponent(e.id)}${e.arg===void 0?"":`/${encodeURIComponent(e.arg)}`}`:e.kind==="settings"?e.section===void 0?"#/settings":`#/settings/${encodeURIComponent(e.section)}`:e.kind==="home"?"#/chat":"";if(location.hash===n)return;const i=`${location.pathname}${location.search}${n}`;t==="replace"?history.replaceState(history.state,"",i):history.pushState(null,"",i)}function EP(e,t){const n=new URL(location.href),i=tw();return i!==null&&n.searchParams.set("token",i),n.hash=`#/w/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n.href}const md="adg.draft.",Xy=60,gp=new Map;function CP(e){try{const t=localStorage.getItem(md+e);if(t===null)return"";const n=JSON.parse(t);return typeof n.text=="string"?n.text:""}catch{return""}}function AP(e,t){try{if(t.trim()===""){localStorage.removeItem(md+e);return}localStorage.setItem(md+e,JSON.stringify({text:t,at:Date.now()})),$P()}catch{}}function IP(e){return gp.get(e)??[]}function TP(e,t){t.length===0?gp.delete(e):gp.set(e,[...t])}function $P(){const e=[];for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(!(n===null||!n.startsWith(md)))try{e.push({key:n,at:Number(JSON.parse(localStorage.getItem(n)??"{}").at)||0})}catch{e.push({key:n,at:0})}}if(!(e.length<=Xy))for(const t of e.sort((n,i)=>n.at-i.at).slice(0,e.length-Xy))localStorage.removeItem(t.key)}const MP={off:"不思考",none:"不思考",minimal:"最少",low:"低",medium:"中",high:"高",xhigh:"很高",max:"最大"},Qy=(e,t)=>MP[e]??(t!==void 0&&t!==e?t:e);function nw(e,t){return(t==null?void 0:t.next)??(t==null?void 0:t.lastUsed)??(e==null?void 0:e.default)??null}function RP(e,t){var n;if(!(e===null||t===null))return(n=e.groups.find(i=>i.id===t.provider))==null?void 0:n.models.find(i=>i.id===t.model)}function OP({client:e,sessionId:t,disabled:n,value:i,onChange:r}){var U;const{catalog:o,error:c}=Ba(e),u=we(e.sessionModels),d=we(e.connection.status),[h,m]=b.useState(!1),[g,p]=b.useState(null),[x,y]=b.useState(!1),[S,N]=b.useState(""),k=b.useRef(null);b.useEffect(()=>{d.state!=="open"||t===void 0||e.sessionModel(t).catch(()=>{})},[e,t,d.state]),b.useEffect(()=>{if(!x)return;const I=O=>{k.current!==null&&!k.current.contains(O.target)&&y(!1)},T=O=>{O.key==="Escape"&&y(!1)};return document.addEventListener("mousedown",I),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",I),document.removeEventListener("keydown",T)}},[x]);const E=t===void 0?void 0:u.get(t),j=t===void 0?i??(o==null?void 0:o.default)??null:nw(o,E),A=RP(o,j),P=j!==null&&o!==null&&A===void 0,L=async I=>{if(p(null),t===void 0){r==null||r(I);return}m(!0);try{await e.selectModel(t,I)}catch(T){p(T instanceof Error?T.message:String(T))}finally{m(!1)}},B=(I,T)=>{const O=(j==null?void 0:j.reasoningEffort)!==void 0&&T.efforts.some($=>$.id===j.reasoningEffort)?j.reasoningEffort:T.defaultEffort;L({provider:I,model:T.id,...O===void 0?{}:{reasoningEffort:O}}),T.efforts.length===0&&y(!1)},V=b.useMemo(()=>{const I=S.trim().toLowerCase();return((o==null?void 0:o.groups)??[]).map(T=>({...T,models:T.models.filter(O=>I===""||O.id.toLowerCase().includes(I)||O.name.toLowerCase().includes(I)||T.name.toLowerCase().includes(I))})).filter(T=>T.models.length>0)},[o,S]),M=[g,c,...(o==null?void 0:o.failures.map(I=>`${I.name}:${I.message}`))??[]].filter(Boolean);if(o===null)return null;const z=(j==null?void 0:j.reasoningEffort)??(A==null?void 0:A.defaultEffort),D=(U=A==null?void 0:A.efforts.find(I=>I.id===z))==null?void 0:U.name;return s.jsxs("div",{className:`model-picker${g!==null?" has-error":""}`,ref:k,children:[s.jsxs("button",{type:"button",className:"model-trigger","aria-haspopup":"dialog","aria-expanded":x,disabled:n||h,title:M.length>0?M.join(`
193
+ `):"选择模型和思考强度",onClick:()=>y(I=>!I),children:[s.jsx("span",{className:`model-dot ${P?"off":""}`}),s.jsx("span",{className:"model-name",children:(A==null?void 0:A.name)??(j===null?"选择模型":`${j.model}(不可用)`)}),z!==void 0&&A!==void 0&&A.efforts.length>0&&s.jsx("span",{className:"model-effort",children:Qy(z,D)}),s.jsx(J,{name:"chevron-down"})]}),x&&s.jsxs("div",{className:"model-panel",role:"dialog","aria-label":"选择模型",children:[s.jsx("input",{className:"text-input plain model-search",autoFocus:!0,placeholder:"搜索模型",value:S,onChange:I=>N(I.target.value)}),s.jsxs("div",{className:"model-list",role:"listbox","aria-label":"模型",children:[V.length===0&&s.jsx("div",{className:"muted small pad",children:"没有匹配的模型"}),V.map(I=>s.jsxs("div",{className:"model-group",children:[s.jsx("div",{className:"model-group-name",children:I.name}),I.models.map(T=>{const O=(j==null?void 0:j.provider)===I.id&&j.model===T.id;return s.jsxs("button",{type:"button",role:"option","aria-selected":O,className:`model-option ${O?"active":""}`,onClick:()=>B(I.id,T),children:[s.jsxs("span",{className:"model-option-main",children:[s.jsx("span",{children:T.name}),T.name!==T.id&&s.jsx("span",{className:"muted small",children:T.id})]}),T.efforts.length>0&&s.jsx("span",{className:"model-tag",children:"思考"}),O&&s.jsx(J,{name:"check"})]},T.id)})]},I.id))]}),A!==void 0&&j!==null&&s.jsxs("div",{className:"model-efforts",children:[s.jsx("span",{className:"field-label",children:"思考强度"}),A.efforts.length===0?s.jsx("span",{className:"muted small",children:"这个模型没有可选的思考强度(在「设置 → 模型」里给模型打开「思考」)"}):s.jsx("div",{className:"segmented-control",role:"radiogroup","aria-label":"思考强度",children:A.efforts.map(I=>s.jsx("button",{type:"button",role:"radio","aria-checked":z===I.id,className:z===I.id?"active":"",onClick:()=>void L({provider:j.provider,model:j.model,reasoningEffort:I.id}),children:Qy(I.id,I.name)},I.id))})]}),M.length>0&&s.jsx("div",{className:"error small model-problems",children:M.join(";")})]})]})}let Ul=[],PP=1;const xp=new Set,Jy=()=>{for(const e of xp)e()},zP=e=>(xp.add(e),()=>{xp.delete(e)}),LP=()=>Ul[0];function DP(e,t){return new Promise(n=>{const i=PP++;Ul=[...Ul,{...e,id:i,single:t,settle:r=>{Ul=Ul.filter(o=>o.id!==i),Jy(),n(r)}}],Jy()})}function Os(e){return DP(e,!1)}function FP(){const e=b.useSyncExternalStore(zP,LP);return e===void 0?null:s.jsx(UP,{pending:e},e.id)}function UP({pending:e}){const{title:t,message:n,quote:i,confirmLabel:r="确定",cancelLabel:o="取消",danger:c=!1,icon:u,single:d,settle:h}=e,m=b.useRef(null),g=b.useRef(null),p=b.useRef(null),x=`confirm-title-${e.id}`,y=`confirm-body-${e.id}`;return b.useEffect(()=>{var N;const S=document.activeElement;return(N=(c&&!d?p:g).current)==null||N.focus({preventScroll:!0}),()=>{S instanceof HTMLElement&&S.isConnected&&S.focus({preventScroll:!0})}},[c,d]),b.useEffect(()=>{const S=N=>{if(N.key==="Escape"){N.preventDefault(),N.stopPropagation(),h(!1);return}if(N.key!=="Tab"||m.current===null)return;const k=[...m.current.querySelectorAll("button:not(:disabled)")],E=k.indexOf(document.activeElement);N.preventDefault();const j=k[(E+(N.shiftKey?-1:1)+k.length)%k.length];j==null||j.focus()};return document.addEventListener("keydown",S,!0),()=>document.removeEventListener("keydown",S,!0)},[h]),s.jsx("div",{className:"dialog-backdrop confirm-backdrop",onPointerDown:S=>{S.target===S.currentTarget&&h(!1)},children:s.jsxs("div",{ref:m,className:`dialog confirm-dialog ${c?"danger":""}`,role:d?"dialog":"alertdialog","aria-modal":"true","aria-labelledby":x,"aria-describedby":n===void 0&&i===void 0?void 0:y,children:[s.jsxs("h3",{id:x,children:[(u!==void 0||c)&&s.jsx(J,{name:u??"alert"}),t]}),(n!==void 0||i!==void 0)&&s.jsxs("div",{id:y,className:"confirm-body",children:[typeof n=="string"?s.jsx(BP,{text:n}):n,i!==void 0&&s.jsx("blockquote",{className:"confirm-quote",children:i})]}),s.jsxs("div",{className:"confirm-actions",children:[!d&&s.jsx("button",{ref:p,type:"button",onClick:()=>h(!1),children:o}),s.jsx("button",{ref:g,type:"button",className:c?"danger":"primary",onClick:()=>h(!0),children:r})]})]})})}function BP({text:e}){return s.jsx(s.Fragment,{children:e.split(/\n\s*\n/).map((t,n)=>{const i=t.split(`
194
+ `).filter(r=>r.trim()!=="");return i.length>0&&i.every(r=>r.startsWith("· "))?s.jsx("ul",{children:i.map((r,o)=>s.jsx("li",{children:r.slice(2)},o))},n):s.jsx("p",{children:t},n)})})}function sw(e,t){return t.find(n=>n.scripts.includes(e.packId??e.id)||n.scripts.includes(e.id))}function vp(e,t){const n=e.toLowerCase();return t.find(i=>[i.id,i.name,...i.aliases].some(r=>r.toLowerCase()===n))}function yp(e,t,n){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),c=o===void 0?n.find(u=>u.scripts.includes(r)):sw(o,n);i.push({script:o===void 0?{id:r,name:r}:{id:o.id,name:o.name},...c===void 0?{}:{game:{id:c.id,name:c.name}}})}if(i.length===0)for(const r of new Set((e==null?void 0:e.games)??[])){const o=vp(r,n);i.push({game:o===void 0?{id:r,name:r}:{id:o.id,name:o.name}})}return i}function iw(e){var t,n;return[(t=e.game)==null?void 0:t.name,(n=e.script)==null?void 0:n.name].filter(i=>i!==void 0).join(" · ")}let rm=[];function HP(e){const t=we(e.capabilities),n=t.has("skills"),i=t.has("scripts"),r=t.has("games"),[o,c]=b.useState(rm),[u,d]=b.useState(0);return b.useEffect(()=>e.connection.on("skills/changed",()=>d(h=>h+1)),[e]),b.useEffect(()=>{if(!n)return;let h=!0;const m=i?e.connection.call("scripts/list",{}).then(p=>p.scripts,()=>[]):Promise.resolve([]),g=r?e.connection.call("games/list",{}).then(p=>p.games,()=>[]):Promise.resolve([]);return Promise.all([e.connection.call("skills/list",{}),m,g]).then(([p,x,y])=>{rm=p.skills.filter(S=>S.userInvocable).map(S=>{const N=[...new Set(yp(S.owner,x,y).map(iw))].join("、");return{name:S.name,description:S.description,...N===""?{}:{group:N}}}),h&&c(rm)},()=>{}),()=>{h=!1}},[e,n,i,r,u]),o}const am=e=>e.kind==="command"?"命令":e.group??"通用技能";function rw({client:e,text:t,setText:n,area:i,submit:r,placement:o="above",inSession:c=!1}){const u=HP(e),[d,h]=b.useState(0),[m,g]=b.useState(!1),p=m?[]:$R(t,u,c),x=t.split(/\s/)[0];b.useEffect(()=>{h(0),g(!1)},[x]);const y=Math.min(d,Math.max(0,p.length-1)),S=j=>{var A;n(`/${j.name} `),g(!0),(A=i.current)==null||A.focus()},N=j=>{var A;if(r!==void 0&&j.kind==="command"&&j.arg===void 0){n(""),r(`/${j.name}`),(A=i.current)==null||A.focus();return}S(j)},k=j=>{if(p.length===0||j.nativeEvent.isComposing)return!1;if(j.key==="ArrowDown"||j.key==="ArrowUp")return j.preventDefault(),h((y+(j.key==="ArrowDown"?1:p.length-1))%p.length),!0;if(j.key==="Tab"||j.key==="Enter"&&!j.shiftKey){j.preventDefault();const A=p[y];return j.key==="Tab"?S(A):N(A),!0}return j.key==="Escape"?(j.preventDefault(),g(!0),!0):!1};return{menu:p.length===0?null:s.jsx(ZP,{options:p,active:y,placement:o,onHover:h,onChoose:N}),onKeyDown:k,expand:j=>IR(j,u)}}function ZP({options:e,active:t,placement:n,onHover:i,onChoose:r}){const o=b.useRef(null),[c,u]=b.useState(0);b.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 s.jsxs("div",{className:`slash-pop ${n}`,children:[s.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)=>s.jsxs("div",{children:[(m===0||am(e[m-1])!==am(h))&&s.jsx("div",{className:"slash-group",children:am(h)}),s.jsx("button",{type:"button",role:"option","data-index":m,"aria-selected":m===t,className:`slash-item ${m===t?"active":""}`,onMouseEnter:()=>i(m),onMouseDown:g=>g.preventDefault(),onClick:()=>r(h),children:h.name})]},`${h.kind}:${h.name}`))}),d!==void 0&&s.jsxs("div",{className:"slash-tip",style:{top:c},role:"tooltip",children:[d.kind==="skill"&&s.jsx("span",{className:"slash-tip-kind",children:d.group===void 0?"技能":`${d.group} 的技能`}),d.description,d.kind==="command"&&d.arg!==void 0&&s.jsxs("span",{className:"slash-tip-arg",children:["后面可以接:",d.arg]}),d.kind==="skill"&&s.jsx("span",{className:"slash-tip-arg",children:"后面写要它做的事"})]})]})}const bp=5.5,eb=2*Math.PI*bp,tb=[{key:"systemTokens",label:"系统提示词",tone:"system"},{key:"toolsTokens",label:"工具定义",tone:"tools"},{key:"messageTokens",label:"对话消息",tone:"messages"}];function om(e){return e>=1e6?`${nb(e/1e6)}M`:e>=1e3?`${nb(e/1e3)}k`:String(Math.round(e))}const nb=e=>e>=100?Math.round(e).toString():e.toFixed(1).replace(/\.0$/,"");function WP({context:e}){const[t,n]=b.useState(!1),i=b.useRef(null);if(b.useEffect(()=>{if(!t)return;const m=p=>{var x;(x=i.current)!=null&&x.contains(p.target)||n(!1)},g=p=>{p.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",m),document.addEventListener("keydown",g),()=>{document.removeEventListener("pointerdown",m),document.removeEventListener("keydown",g)}},[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",c=e.breakdown,u=c===void 0?0:c.systemTokens+c.toolsTokens+c.messageTokens,d=c===void 0||u===0?[{key:"total",tone:"messages",width:r}]:tb.map(m=>({key:m.key,tone:m.tone,width:r*c[m.key]/u})).filter(m=>m.width>0),h=`上下文已用 ${r}%`;return s.jsxs("span",{ref:i,className:`context-meter ${o}`,children:[s.jsxs("button",{type:"button",className:"context-trigger",title:h,"aria-label":h,"aria-haspopup":"dialog","aria-expanded":t,onClick:()=>n(!t),children:[s.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[s.jsx("circle",{className:"context-track",cx:"7",cy:"7",r:bp}),s.jsx("circle",{className:"context-fill",cx:"7",cy:"7",r:bp,strokeDasharray:`${eb*r/100} ${eb}`,transform:"rotate(-90 7 7)"})]}),s.jsxs("span",{children:[r,"%"]})]}),t&&s.jsxs("div",{className:"context-panel",role:"dialog","aria-label":"上下文用量",children:[s.jsxs("div",{className:"context-head",children:[s.jsxs("span",{children:["上下文已用 ",s.jsxs("strong",{children:[r,"%"]})]}),s.jsxs("span",{className:"context-figures",children:["~",om(e.usedTokens)," / ",om(e.contextWindow)]})]}),s.jsx("div",{className:"context-bar",children:d.map(m=>s.jsx("span",{className:`context-segment ${m.tone}`,style:{width:`${m.width}%`}},m.key))}),c!==void 0&&s.jsx("dl",{className:"context-rows",children:tb.map(m=>s.jsxs("div",{children:[s.jsxs("dt",{children:[s.jsx("span",{className:`context-swatch ${m.tone}`,"aria-hidden":"true"}),m.label]}),s.jsxs("dd",{children:["~",om(c[m.key])]})]},m.key))}),s.jsxs("p",{className:"context-tip",children:["快满时会自动压缩(「设置 → 对话压缩」)。也可以输入 ",s.jsx("kbd",{children:"/压缩"})," 手动压缩:较早的部分换成摘要,agent 会忘掉其中的细节。"]})]})]})}const VP=6e4,qP={CNY:"¥",USD:"$"},Xu=(e,t)=>{const n=qP[e];return n===void 0?`${t} ${e}`:`${n}${t}`};function GP({balances:e}){const t=e.filter(n=>Number(n.total)!==0);return(t.length>0?t:e.slice(0,1)).map(n=>Xu(n.currency,n.total)).join(" / ")}function KP(e){return`DeepSeek 账户余额 ${e.balances.map(n=>`${Xu(n.currency,n.total)}(充值 ${Xu(n.currency,n.toppedUp)},赠送 ${Xu(n.currency,n.granted)})`).join("、")}${e.available?"":"。余额不足,调用模型会失败"}`}function YP({client:e,sessionId:t,running:n}){var g;const{catalog:i}=Ba(e),r=we(e.sessionModels).get(t),o=((g=nw(i,r))==null?void 0:g.provider)??null,c=we(e.credentialRevision),u=we(e.connection.status),d=we(e.capabilities),[h,m]=b.useState(null);return b.useEffect(()=>{if(o===null||u.state!=="open"||!d.has("providers"))return;let p=!0;const x=()=>e.providerBalance(o).then(S=>{p&&m({provider:o,balance:S,error:null})},S=>{p&&m({provider:o,balance:null,error:S instanceof Error?S.message:String(S)})});x();const y=n?setInterval(()=>void x(),VP):void 0;return()=>{p=!1,clearInterval(y)}},[e,o,c,u.state,d,n]),h===null||h.provider!==o?null:h.error!==null?s.jsx("span",{className:"balance-chip failed",title:h.error,children:"余额 ?"}):h.balance===null||h.balance.balances.length===0?null:s.jsx("span",{className:`balance-chip ${h.balance.available?"":"low"}`,title:KP(h.balance),children:GP(h.balance)})}function XP({client:e,session:t,running:n,disabled:i,initialPrompt:r,onInitialSent:o,reminder:c}){const u=we(e.capabilities),{queue:d,context:h}=we(t.state),[m,g]=b.useState(()=>CP(t.id)),[p,x]=b.useState(!0),[y,S]=b.useState(null),[N,k]=b.useState(null),E=b.useRef(null),j=b.useRef(null),A=b.useRef(!1),[P,L]=b.useState(()=>IP(t.id));b.useEffect(()=>AP(t.id,m),[t.id,m]),b.useEffect(()=>TP(t.id,P),[t.id,P]);const B=KR(e),[V,M]=b.useState(!1),z=async Z=>{const G=Z.filter(X=>X.type.startsWith("image/"));if(G.length===0)return;S(null);const q=$l-P.length;if(q<=0){S(`一条消息最多 ${$l} 张图片`);return}try{const X=await Promise.all(G.slice(0,q).map(ez));L(Y=>[...Y,...X].slice(0,$l)),G.length>q&&S(`一条消息最多 ${$l} 张图片,多的没有加上`)}catch(X){S(`图片没能加上:${X instanceof Error?X.message:String(X)}`)}},D=Z=>{const G=[...Z.clipboardData.items].filter(q=>q.kind==="file"&&q.type.startsWith("image/")).map(q=>q.getAsFile()).filter(q=>q!==null);G.length!==0&&(Z.preventDefault(),z(G))},U=Z=>{M(!1),Z.dataTransfer.files.length!==0&&(Z.preventDefault(),z([...Z.dataTransfer.files]))};b.useEffect(()=>{var Z;r===void 0||A.current||i||(A.current=!0,t.prompt(r,"queue").catch(G=>S(G instanceof Error?G.message:String(G))),o==null||o(),(Z=E.current)==null||Z.focus())},[r,i,t,o]);const I=Z=>CR(Z)!=="compact"?!1:(g(""),S(null),n?(S("agent 正在工作,等它停下再压缩"),!0):(Os({title:"压缩这个对话?",message:QP,confirmLabel:"压缩",danger:!0}).then(G=>{G&&(k("正在压缩对话:模型在写摘要,可能要一两分钟…"),t.compact().then(q=>k(q.message),q=>{k(null),S(q instanceof Error?q.message:String(q))}))}),!0)),T=rw({client:e,text:m,setText:g,area:E,inSession:!0,submit:Z=>{i||I(Z)||(S(null),t.prompt(T.expand(Z),n&&p?"steer":"queue").catch(G=>S(G instanceof Error?G.message:String(G))))}}),O=()=>{var q;if(!i&&P.length===0&&I(m))return;const Z=T.expand(m);if(Z===""&&P.length===0||i)return;const G=P.map(({url:X,...Y})=>Y);g(""),L([]),S(null),t.prompt(Z,n&&p?"steer":"queue",G).catch(X=>S(X instanceof Error?X.message:String(X))),(q=E.current)==null||q.focus()},$=Z=>{T.onKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.nativeEvent.isComposing&&(Z.preventDefault(),O())},F=Z=>{t.updateQueue(Z.id,"remove").then(()=>{m.trim()===""&&Z.text!==""&&g(Z.text)},G=>S(G instanceof Error?G.message:String(G)))},H=Z=>{t.updateQueue(Z.id,"steer").catch(G=>S(G instanceof Error?G.message:String(G)))};return s.jsxs("div",{className:"composer",children:[y!==null&&s.jsx("div",{className:"error small composer-error",children:y}),d.length>0&&s.jsx("div",{className:"queue","aria-label":"等待发送的消息",children:d.map(Z=>s.jsxs("div",{className:"queue-item",children:[s.jsx("span",{className:`queue-tag ${Z.placement}`,children:Z.placement==="next-step"?"插入中":"排队中"}),s.jsxs("span",{className:"queue-text",title:Z.text,children:[Z.text===""?"(图片)":Z.text,Z.images!==void 0&&s.jsxs("span",{className:"muted",children:[" · ",Z.images," 张图片"]})]}),s.jsx("span",{className:"queue-when muted",children:Z.placement==="next-step"?"这一步做完就交给 agent":"这一轮结束后发送"}),Z.placement==="next-turn"&&n&&s.jsx("button",{type:"button",className:"small-button",title:"不等这一轮结束,现在就交给 agent",onClick:()=>H(Z),children:"现在插入"}),s.jsx("button",{type:"button",className:"small-button",title:"撤回这条消息",onClick:()=>F(Z),children:"撤回"})]},Z.id))}),c,N!==null&&s.jsxs("div",{className:"composer-note small",role:"status",children:[s.jsx("span",{children:N}),s.jsx("button",{type:"button",className:"ghost small-button",onClick:()=>k(null),children:"知道了"})]}),s.jsxs("div",{className:"slash-anchor",children:[T.menu,s.jsxs("div",{className:`composer-box ${V?"dragging":""}`,onDragOver:Z=>{[...Z.dataTransfer.items].some(G=>G.kind==="file")&&(Z.preventDefault(),M(!0))},onDragLeave:()=>M(!1),onDrop:U,children:[P.length>0&&s.jsx("div",{className:"composer-images",children:P.map((Z,G)=>s.jsxs("span",{className:"composer-image",children:[s.jsx("img",{src:Z.url,alt:Z.name??`图片 ${G+1}`}),s.jsx("button",{type:"button","aria-label":"移除这张图片",onClick:()=>L(q=>q.filter((X,Y)=>Y!==G)),children:"✕"})]},G))}),s.jsx("textarea",{onPaste:D,ref:E,"aria-label":"消息内容",value:m,onChange:Z=>g(Z.target.value),onKeyDown:$,rows:Math.min(8,Math.max(2,m.split(`
195
+ `).length)),placeholder:i?"未连接到 agent":n?p?"运行中:发出去会插进这一轮,改主意了直接说":"运行中:消息会排队到下一轮":"继续追问,或描述下一步要做的事",disabled:i}),s.jsxs("div",{className:"composer-actions",children:[u.has("models")&&s.jsx(OP,{client:e,sessionId:t.id,disabled:i}),s.jsx("button",{type:"button",className:"attach-button",title:"添加图片(也可以直接粘贴或拖进来)","aria-label":"添加图片",disabled:i||P.length>=$l,onClick:()=>{var Z;return(Z=j.current)==null?void 0:Z.click()},children:s.jsx(J,{name:"image"})}),s.jsx("input",{ref:j,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:Z=>{z([...Z.target.files??[]]),Z.target.value=""}}),B==="full"&&s.jsxs("button",{type:"button",className:"full-access-chip",title:"agent 做事不再请求确认,点这里修改",onClick:()=>{location.hash="#/settings/permissions"},children:[s.jsx(J,{name:"alert"}),"完全访问"]}),s.jsx("span",{className:"spacer"}),s.jsx(YP,{client:e,sessionId:t.id,running:n}),s.jsx(WP,{context:h}),n&&s.jsxs("label",{className:"steer-toggle",title:"这一步做完 agent 就会看到;不勾选就等这一轮结束再发",children:[s.jsx("input",{type:"checkbox",checked:p,onChange:Z=>x(Z.target.checked)}),"插入当前轮次"]}),n&&s.jsxs("button",{className:"stop-button",onClick:()=>void t.cancel().catch(Z=>S(String(Z))),disabled:i,children:[s.jsx(XR,{}),"停止"]}),s.jsx("button",{className:"send-button","aria-label":"发送",title:"发送(Enter)",onClick:O,disabled:i||m.trim()===""&&P.length===0,children:s.jsx(J,{name:"arrow"})})]})]})]}),s.jsxs("div",{className:"composer-hint",children:[s.jsxs("span",{children:[s.jsx("kbd",{children:"/"})," 命令和技能"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"Enter"})," 发送"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"Shift+Enter"})," 换行"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"Ctrl+V"})," 粘贴图片"]})]})]})}const QP=["压缩会把这个对话较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:","","· 会丢失记忆:早先的细节 agent 不再记得(具体的命令和输出、日志、截图、你说过的原话);","· 摘要可能漏掉或写错内容;","· 不能撤销。界面上的聊天记录还在,但 agent 看不到了。","","对话很长、回复变慢或报上下文超长时再压缩。"].join(`
196
+ `),$l=4,JP=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function ez(e){const t=await new Promise((o,c)=>{const u=new FileReader;u.onload=()=>o(String(u.result)),u.onerror=()=>c(u.error??new Error("读取失败")),u.readAsDataURL(e)}),n=e.name===""||e.name==="image.png"?`粘贴的图片.${e.type.split("/")[1]??"png"}`:e.name,i=t.slice(t.indexOf(",")+1);if(JP.has(e.type)&&i.length<=tp)return{mediaType:e.type,data:i,name:n,url:t};const r=new Image;r.src=t,await r.decode();for(let o=2560;o>=640;o=Math.round(o*.75)){const c=Math.min(1,o/Math.max(r.naturalWidth,r.naturalHeight)),u=document.createElement("canvas");u.width=Math.max(1,Math.round(r.naturalWidth*c)),u.height=Math.max(1,Math.round(r.naturalHeight*c)),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<=tp)return{mediaType:"image/jpeg",data:h,name:n.replace(/\.\w+$/,".jpg"),url:d}}throw new Error("图片太大")}function kp({client:e,sessionId:t,reminder:n,initialPrompt:i,onInitialSent:r,onAgent:o}){const c=Pd(e,t);return c===null?s.jsx("div",{className:"main empty",children:"正在打开会话…"}):s.jsx(tz,{client:e,session:c,reminder:n,initialPrompt:i,onInitialSent:r,onAgent:o})}function aw(e,t){const[n,i]=b.useState(!1);return t&&!n&&i(!0),e!==void 0&&e.home===void 0&&e.blank!==!0&&!t&&!n}function tz({client:e,session:t,reminder:n,initialPrompt:i,onInitialSent:r,onAgent:o}){const c=we(t.state),u=we(e.connection.status),d=ti(e),h=we(e.sessions).items.find(j=>j.id===t.id),m=h===void 0?is:Ra(h,d),g=d.find(j=>j.id===m),p=g===void 0?bn:Ko(g),x=(h==null?void 0:h.home)!==void 0,y=BR(uj(e),c),[S,N]=b.useState(()=>rz()),k=y.find(j=>j.id===S)??y[0];b.useEffect(()=>az(S),[S]);const E=aw(h,c.running||c.queue.length>0||i!==void 0);return s.jsxs("section",{className:"main",children:[s.jsxs("header",{className:"session-header",children:[s.jsxs("div",{className:"session-heading",children:[x?s.jsxs("div",{className:"breadcrumb agent-heading",children:[s.jsx("span",{className:`agent-avatar small agent-${p.id}`,children:s.jsx(J,{name:p.icon})}),s.jsx("h1",{children:p.name})]}):s.jsxs("div",{className:"breadcrumb",children:[o!==void 0?s.jsx("button",{type:"button",className:"link-button breadcrumb-link",title:`回到「${p.name}」的对话`,onClick:()=>o(m),children:p.name}):s.jsx("span",{children:p.name}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx(iz,{title:c.title,onRename:j=>e.renameSession(t.id,j)})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx(ow,{running:c.running}),x?s.jsx("span",{children:p.description}):s.jsx("span",{children:"以前的对话"}),!x&&m!==is&&(h==null?void 0:h.requestedBy)!==void 0&&s.jsx("span",{children:fP(h.requestedBy)})]})]}),s.jsxs("div",{className:"session-actions",children:[s.jsx("nav",{className:"tabs",role:"tablist","aria-label":"会话视图",children:y.map(j=>s.jsx("button",{role:"tab","aria-selected":j.id===(k==null?void 0:k.id),className:j.id===(k==null?void 0:k.id)?"active":"",onClick:()=>N(j.id),children:j.title},j.id))}),k!==void 0&&s.jsx("button",{className:"icon-button popout-button",title:`在新窗口打开「${k.title}」`,"aria-label":`在新窗口打开「${k.title}」`,onClick:()=>window.open(EP(k.id,t.id),`dsh-${k.id}-${t.id}`),children:s.jsx(J,{name:"popout"})})]})]}),c.error!==null&&s.jsx("div",{className:"banner error",children:c.error}),s.jsx("div",{className:"view",children:k===void 0?s.jsx("div",{className:"empty",children:"当前连接没有提供可用的视图插件。"}):s.jsx(k.component,{client:e,session:t,state:c,readOnly:E})}),E?s.jsxs("div",{className:"session-readonly",children:[s.jsx(J,{name:"archive"}),s.jsx("span",{children:"这是以前的对话,只能查看,不能继续。"}),o!==void 0&&s.jsxs("button",{type:"button",className:"small-button",onClick:()=>o(m),children:["回到「",p.name,"」的对话"]})]}):s.jsx(s.Fragment,{children:s.jsx(XP,{client:e,session:t,running:c.running,disabled:u.state!=="open",initialPrompt:i,onInitialSent:r,reminder:n})})]})}function nz({client:e,viewId:t,sessionId:n}){const i=Pd(e,n),r=uj(e),o=we(e.connection.status),c=r.find(u=>u.id===t);return i===null||c===void 0?s.jsx("div",{className:"popped",children:s.jsx("section",{className:"main empty",children:o.state==="open"&&c===void 0?"当前连接没有提供这个视图。":"正在打开…"})}):s.jsx(sz,{client:e,session:i,view:c})}function sz({client:e,session:t,view:n}){const i=we(t.state),r=we(e.sessions).items.find(c=>c.id===t.id),o=aw(r,i.running||i.queue.length>0);return b.useEffect(()=>{document.title=`${n.title} · ${i.title??"会话"}`},[n.title,i.title]),s.jsx("div",{className:"popped",children:s.jsxs("section",{className:"main",children:[s.jsx("header",{className:"session-header",children:s.jsxs("div",{className:"session-heading",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:n.title}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:i.title??"新会话"})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx(ow,{running:i.running}),s.jsx("span",{children:"与主窗口同步更新"})]})]})}),i.error!==null&&s.jsx("div",{className:"banner error",children:i.error}),s.jsx("div",{className:"view",children:s.jsx(n.component,{client:e,session:t,state:i,readOnly:o})})]})})}function iz({title:e,onRename:t}){const[n,i]=b.useState(null),[r,o]=b.useState(null),c=e??"新会话",u=async()=>{const d=(n==null?void 0:n.trim())??"";if(d===""||d===e){i(null);return}try{await t(d),i(null),o(null)}catch(h){o(h instanceof Error?h.message:String(h))}};return n!==null?s.jsxs("span",{className:"title-edit",children:[s.jsx("input",{className:"text-input",autoFocus:!0,value:n,maxLength:80,"aria-label":"会话名称",onChange:d=>i(d.target.value),onFocus:d=>d.target.select(),onKeyDown:d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&u(),d.key==="Escape"&&(i(null),o(null))},onBlur:()=>void u()}),r!==null&&s.jsx("span",{className:"error small",children:r})]}):s.jsxs("span",{className:"session-title",children:[s.jsx("h1",{title:"双击改名",onDoubleClick:()=>i(c),children:c}),s.jsx("button",{type:"button",className:"icon-button rename-button",title:"改名","aria-label":"给这个会话改名",onClick:()=>i(c),children:s.jsx(J,{name:"pencil"})})]})}function ow({running:e}){return e?s.jsxs("span",{className:"status-pill running",children:[s.jsx("span",{className:"pill-dot"}),"运行中"]}):s.jsx("span",{className:"status-pill",children:"空闲"})}const lw="adg.sessionTab";function rz(){try{return localStorage.getItem(lw)??"chat"}catch{return"chat"}}function az(e){try{localStorage.setItem(lw,e)}catch{}}const cw="adg.showEarlier",Np=new Set;function oz(){try{return localStorage.getItem(cw)!=="0"}catch{return!0}}let uw=oz();function lz(e){uw=e;try{localStorage.setItem(cw,e?"1":"0")}catch{}for(const t of Np)t()}function Sg(){return b.useSyncExternalStore(e=>(Np.add(e),()=>{Np.delete(e)}),()=>uw)}const dw="adg.theme",jp=new Set;let Kl=cz();function cz(){try{const e=localStorage.getItem(dw);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function hw(){var e,t;Kl==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=Kl,(t=(e=wi())==null?void 0:e.setTheme)==null||t.call(e,Kl).catch(()=>{})}function uz(e){Kl=e;try{localStorage.setItem(dw,e)}catch{}hw();for(const t of jp)t()}function fw(){return b.useSyncExternalStore(e=>(jp.add(e),()=>jp.delete(e)),()=>Kl)}const dz={"api-keys":"key",permissions:"shield",plugins:"plug","script-install":"package",emulators:"monitor",schedule:"calendar",feishu:"send",compaction:"compress",memory:"archive",about:"info"},hz=[["light","浅色"],["dark","深色"],["system","跟随系统"]];function fz({client:e,onClose:t,section:n,onSection:i}){const r=qR(e),o=fw(),c=Sg(),[u,d]=b.useState(null),h=u??n??null,m=p=>{d(p),i==null||i(p)},g=r.find(p=>p.id===h)??r[0];return s.jsxs(s.Fragment,{children:[s.jsxs("aside",{className:"sidebar settings-sidebar",children:[s.jsxs("button",{className:"nav-item back-link",onClick:t,children:[s.jsx(J,{name:"back"}),s.jsx("span",{className:"nav-item-label",children:"返回"})]}),s.jsx("h1",{className:"settings-title",children:"设置"}),s.jsxs("nav",{className:"page-list","aria-label":"设置分类",children:[s.jsx("div",{className:"sidebar-label",children:"偏好设置"}),r.map(p=>s.jsxs("button",{className:`nav-item ${p.id===(g==null?void 0:g.id)?"active":""}`,"aria-current":p.id===(g==null?void 0:g.id)?"page":void 0,onClick:()=>m(p.id),children:[s.jsx(J,{name:dz[p.id]??"settings"}),s.jsx("span",{className:"nav-item-label",children:p.title})]},p.id))]}),s.jsxs("div",{className:"page-list",children:[s.jsx("div",{className:"sidebar-label",id:"theme-label",children:"外观"}),s.jsx("div",{className:"segmented-control",role:"radiogroup","aria-labelledby":"theme-label",children:hz.map(([p,x])=>s.jsx("button",{role:"radio","aria-checked":o===p,className:o===p?"active":"",onClick:()=>uz(p),children:x},p))}),s.jsxs("label",{className:"check-label settings-toggle",title:"关了之后不显示这个按钮;对话记录不会删除。没有以前的对话时,开着也不显示",children:[s.jsx("input",{type:"checkbox",checked:c,onChange:p=>lz(p.target.checked)}),"显示「以前的对话」"]})]})]}),s.jsx("section",{className:"main settings",children:s.jsx("div",{className:"settings-content",children:g===void 0?s.jsx("div",{className:"empty",children:"当前连接没有提供可配置的项目。"}):s.jsx(g.component,{client:e})})})]})}var Ud=Yk();const lm=320,Pu=4;function Vt({value:e,options:t,onChange:n,id:i,disabled:r,placeholder:o="请选择",inline:c,className:u,...d}){const h=b.useId(),m=b.useRef(null),g=b.useRef(null),[p,x]=b.useState(!1),[y,S]=b.useState(-1),[N,k]=b.useState({}),E=t.findIndex(D=>D.value===e),j=E===-1?void 0:t[E],A=D=>t[D]!==void 0&&t[D].disabled!==!0,P=(D,U)=>{for(let I=D+U;I>=0&&I<t.length;I+=U)if(A(I))return I;return D},L=(D=E)=>{r!==!0&&(S(A(D)?D:P(-1,1)),x(!0))},B=(D=!0)=>{var U;x(!1),D&&((U=m.current)==null||U.focus())},V=D=>{A(D)&&(t[D].value!==e&&n(t[D].value),B())};b.useLayoutEffect(()=>{if(!p)return;const D=()=>{var F,H;const U=(F=m.current)==null?void 0:F.getBoundingClientRect();if(U===void 0)return;const I=window.innerHeight-U.bottom-Pu-8,T=U.top-Pu-8,O=I<Math.min(lm,((H=g.current)==null?void 0:H.scrollHeight)??lm)&&T>I,$=Math.max(U.width,180);k({left:Math.max(8,Math.min(U.left,window.innerWidth-$-8)),minWidth:$,maxWidth:Math.max($,Math.min(520,window.innerWidth-16)),maxHeight:Math.min(lm,O?T:I),...O?{bottom:window.innerHeight-U.top+Pu}:{top:U.bottom+Pu}})};return D(),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0),()=>{window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[p]),b.useEffect(()=>{var U;if(!p)return;(U=g.current)==null||U.focus({preventScroll:!0});const D=I=>{var O,$;const T=I.target;!((O=g.current)!=null&&O.contains(T))&&!(($=m.current)!=null&&$.contains(T))&&B(!1)};return document.addEventListener("pointerdown",D,!0),()=>document.removeEventListener("pointerdown",D,!0)},[p]),b.useEffect(()=>{var D,U;p&&y>=0&&((U=(D=g.current)==null?void 0:D.querySelector(`[data-index="${y}"]`))==null||U.scrollIntoView({block:"nearest"}))},[p,y]);const M=D=>{(D.key==="ArrowDown"||D.key==="ArrowUp"||D.key==="Enter"||D.key===" ")&&(D.preventDefault(),L())},z=D=>{const I={ArrowDown:()=>S(T=>P(T,1)),ArrowUp:()=>S(T=>P(T,-1)),Home:()=>S(P(-1,1)),End:()=>S(P(t.length,-1)),Enter:()=>V(y)," ":()=>V(y),Escape:()=>B(),Tab:()=>B()}[D.key];if(I!==void 0){D.key!=="Tab"&&D.preventDefault(),I();return}if(D.key.length===1&&!D.ctrlKey&&!D.metaKey&&!D.altKey){const T=D.key.toLowerCase();for(let O=1;O<=t.length;O++){const $=(y+O)%t.length;if(A($)&&t[$].label.toLowerCase().startsWith(T)){S($);break}}}};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:m,id:i,type:"button",disabled:r,className:`select-trigger text-input plain ${c===!0?"inline":""} ${p?"open":""} ${u??""}`,"aria-haspopup":"listbox","aria-expanded":p,"aria-controls":p?h:void 0,"aria-label":d["aria-label"],onClick:()=>p?B():L(),onKeyDown:M,children:s.jsx("span",{className:`select-value ${j===void 0?"placeholder":""}`,children:(j==null?void 0:j.label)??o})}),p&&Ud.createPortal(s.jsxs("ul",{ref:g,id:h,role:"listbox",tabIndex:-1,className:"select-list",style:N,"aria-label":d["aria-label"],"aria-activedescendant":y>=0?`${h}-${y}`:void 0,onKeyDown:z,children:[t.map((D,U)=>{var I;return s.jsxs("li",{role:"presentation",children:[D.group!==void 0&&D.group!==((I=t[U-1])==null?void 0:I.group)&&s.jsx("div",{className:"select-group",children:D.group}),s.jsxs("div",{id:`${h}-${U}`,"data-index":U,role:"option","aria-selected":U===E,"aria-disabled":D.disabled===!0,className:`select-option ${U===y?"active":""} ${U===E?"selected":""} ${D.disabled===!0?"disabled":""}`,onPointerMove:()=>{A(U)&&U!==y&&S(U)},onClick:()=>V(U),children:[s.jsxs("span",{className:"select-text",children:[s.jsx("span",{children:D.label}),D.hint!==void 0&&s.jsx("span",{className:"select-hint",children:D.hint})]}),U===E&&s.jsx(J,{name:"check",className:"select-check"})]})]},`${D.group??""}\0${D.value}`)}),t.length===0&&s.jsx("li",{role:"presentation",className:"select-empty",children:"没有可选的"})]}),document.body)]})}const mw=["日","一","二","三","四","五","六"],pw=[1,2,3,4,5,6,0];function _g(e){return e.enabled?e.times.length===0?e.after===void 0?"没有设时间":`「${e.after}」跑完后`:`${e.days.length===0||e.days.length===7?"每天":`每周${pw.filter(n=>e.days.includes(n)).map(n=>mw[n]).join("、")}`} ${[...e.times].sort().join("、")}`:"已暂停"}function Eo(e,t){if(!e.enabled)return;const n=new Date(t);n.setHours(0,0,0,0);for(let i=0;i<8;i++,n.setDate(n.getDate()+1)){if(e.days.length>0&&!e.days.includes(n.getDay()))continue;const r=e.times.map(o=>{const[c,u]=o.split(":").map(Number);return new Date(n.getFullYear(),n.getMonth(),n.getDate(),c,u).getTime()}).filter(o=>o>t).sort((o,c)=>o-c);if(r[0]!==void 0)return r[0]}}const kc=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"});function gw(e,t){const n=we(e.connection.status),[i,r]=b.useState(0),[o,c]=b.useState({items:null,error:null});return b.useEffect(()=>e.connection.on("tasks/changed",()=>r(u=>u+1)),[e]),b.useEffect(()=>{if(n.state!=="open")return;let u=!0;return e.connection.call("tasks/list",t===void 0?{}:{agent:t}).then(d=>{u&&c({items:d.items,error:null})},d=>{u&&c(h=>({...h,error:Ie(d)}))}),()=>{u=!1}},[e,t,n.state,i]),o}function xw(e,t){const n=we(e.connection.status),i=we(e.capabilities),[r,o]=b.useState(0),[c,u]=b.useState([]);return b.useEffect(()=>e.connection.on("reminders/changed",()=>o(d=>d+1)),[e]),b.useEffect(()=>{if(n.state!=="open"||!i.has("agents"))return;let d=!0;return e.connection.call("reminders/list",t===void 0?{}:{agent:t}).then(h=>{d&&u(h.items)}).catch(()=>{}),()=>{d=!1}},[e,t,n.state,i,r]),c}function vw(e){const t=we(e.connection.status),[n,i]=b.useState(0),[r,o]=b.useState([]);return b.useEffect(()=>e.connection.on("pipelines/changed",()=>i(c=>c+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let c=!0;return e.connection.call("pipelines/list",{}).then(u=>{c&&o(u.items)}).catch(()=>{}),()=>{c=!1}},[e,t.state,n]),r}function yw(e){const t=we(e.connection.status),n=we(e.capabilities),[i,r]=b.useState(null);return b.useEffect(()=>{if(t.state!=="open"||!n.has("games"))return;let o=!0;return e.connection.call("games/list",{}).then(c=>{o&&r({schedule:{enabled:c.settings.report.enabled,times:[c.settings.report.at],days:[],catchUpMinutes:0},next:c.report.next})}).catch(()=>{}),()=>{o=!1}},[e,t.state,n]),i}function bw({report:e,now:t}){const n=Eo(e.schedule,t);return s.jsxs("a",{className:"task-card pipeline-line",href:"#/p/games/report",title:"在游戏页的「日报」里设置",children:[s.jsx(J,{name:"send"}),s.jsx("span",{className:"task-title",children:"每日日报"}),s.jsxs("span",{className:"muted small",children:[_g(e.schedule),n===void 0?"":` · 下次 ${kc(n)}`," · 发到飞书"]}),s.jsx(J,{name:"chevron"})]})}function kw(e){const t=ti(e);return b.useMemo(()=>[bn,...t.map(Ko)],[t])}function mz({client:e,agentId:t}){const n=kw(e),i=n.find(x=>x.id===t)??bn,{items:r,error:o}=gw(e,t),c=xw(e,t),u=vw(e),d=yw(e),h=An(3e4),[m,g]=b.useState(null),p=u.filter(x=>x.schedule.enabled&&x.draft!==!0);return s.jsxs("section",{className:"main scripts-page agent-schedule",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:i.name}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"定时任务"})]}),s.jsx("div",{className:"page-actions",children:s.jsxs("button",{className:"small-button primary",onClick:()=>g("new"),disabled:m!==null,children:[s.jsx(J,{name:"plus"}),"新建定时任务"]})})]}),s.jsxs("div",{className:"schedule-body",children:[s.jsxs("p",{className:"muted small",children:["到点把一段话交给",i.name,"去做,在它的对话里做。",t===is?"":"做完后,要紧的由助手告诉你。","要跑脚本的多步任务,用「编排」做成流水线。"]}),o!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:o})]}),m==="new"&&s.jsx(wp,{client:e,agents:n,task:{agent:t},onDone:()=>g(null)}),t==="games"&&d!==null&&s.jsx(bw,{report:d,now:h}),r!==null&&r.length===0&&c.length===0&&m===null&&s.jsxs("div",{className:"empty-card muted",children:[i.name,"还没有定时任务。"]}),r==null?void 0:r.map(x=>m!=="new"&&(m==null?void 0:m.id)===x.id?s.jsx(wp,{client:e,agents:n,task:x,onDone:()=>g(null)},x.id):s.jsx(ww,{client:e,task:x,now:h,onEdit:()=>g(x)},x.id)),c.length>0&&s.jsxs("section",{className:"schedule-group",children:[s.jsxs("h3",{children:[i.name,"在对话里设的提醒"]}),s.jsx("p",{className:"muted small",children:"你在对话里让它「几点提醒我…」时它自己设的。到点后它在对话里接着做,回复也会同步到飞书和 QQ。"}),c.map(x=>s.jsx(jw,{client:e,reminder:x,now:h},x.id))]}),t==="pipelines"&&s.jsxs("section",{className:"schedule-group",children:[s.jsx("h3",{children:"按时运行的流水线"}),p.length===0&&s.jsx("p",{className:"muted small",children:"没有开着定时的流水线。"}),p.map(x=>s.jsx(Nw,{pipeline:x,now:h},x.id))]})]})]})}function pz({client:e,onAgent:t}){const n=kw(e),{items:i,error:r}=gw(e),o=xw(e),c=vw(e),u=yw(e),d=An(3e4),[h,m]=b.useState(!1),g=n.find(y=>y.id==="pipelines"),p=n.find(y=>y.id==="games"),x=b.useMemo(()=>[...u===null?[]:[{key:"daily-report",agent:p,title:"每日日报",at:Eo(u.schedule,d)}],...(i??[]).map(y=>({key:y.id,agent:n.find(S=>S.id===y.agent),title:y.title,at:Eo(y.schedule,d)})),...c.filter(y=>y.draft!==!0).map(y=>({key:y.id,agent:g,title:`流水线「${y.name}」`,at:Eo(y.schedule,d)})),...o.map(y=>({key:y.id,agent:n.find(S=>S.id===y.agent),title:`提醒:${y.title}`,at:y.next}))].filter(y=>y.at!==void 0).sort((y,S)=>y.at-S.at).slice(0,8),[i,o,c,n,g,p,u,d]);return s.jsxs("section",{className:"main scripts-page agent-schedule",children:[s.jsxs("header",{className:"page-header",children:[s.jsx("div",{className:"breadcrumb",children:s.jsx("h1",{children:"定时任务"})}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("a",{className:"small-button",href:"#/settings/schedule",children:[s.jsx(J,{name:"settings"}),"开机自启与唤醒"]}),s.jsxs("button",{className:"small-button primary",onClick:()=>m(!0),disabled:h,children:[s.jsx(J,{name:"plus"}),"新建定时任务"]})]})]}),s.jsxs("div",{className:"schedule-body",children:[r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:r})]}),h&&s.jsx(wp,{client:e,agents:n,task:{agent:is},chooseAgent:!0,onDone:()=>m(!1)}),s.jsxs("section",{className:"schedule-group",children:[s.jsx("h3",{children:"接下来"}),x.length===0&&s.jsx("p",{className:"muted small",children:"一周内没有要按时做的事。"}),s.jsx("ol",{className:"schedule-timeline",children:x.map(y=>{var S,N,k;return s.jsxs("li",{children:[s.jsx("span",{className:"schedule-when",children:kc(y.at)}),s.jsx("span",{className:`agent-avatar small agent-${((S=y.agent)==null?void 0:S.id)??"unknown"}`,children:s.jsx(J,{name:((N=y.agent)==null?void 0:N.icon)??"sparkles"})}),s.jsx("span",{className:"schedule-who",children:((k=y.agent)==null?void 0:k.name)??"?"}),s.jsx("span",{className:"schedule-what",children:y.title})]},`${y.key}@${y.at}`)})})]}),n.map(y=>{const S=(i??[]).filter(j=>j.agent===y.id),N=o.filter(j=>j.agent===y.id),k=y.id==="pipelines"?c.filter(j=>j.schedule.enabled&&j.draft!==!0):[],E=y.id==="games"&&(u==null?void 0:u.schedule.enabled)===!0?u:null;return S.length===0&&N.length===0&&k.length===0&&E===null?null:s.jsxs("section",{className:"schedule-group",children:[s.jsxs("h3",{className:"schedule-agent",children:[s.jsx("span",{className:`agent-avatar small agent-${y.id}`,children:s.jsx(J,{name:y.icon})}),y.name,s.jsx("span",{className:"tab-count",children:S.length+N.length+k.length+(E===null?0:1)}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"link-button",onClick:()=>t(y.id),children:"管理"})]}),E!==null&&s.jsx(bw,{report:E,now:d}),S.map(j=>s.jsx(ww,{client:e,task:j,now:d},j.id)),N.map(j=>s.jsx(jw,{client:e,reminder:j,now:d},j.id)),k.map(j=>s.jsx(Nw,{pipeline:j,now:d},j.id))]},y.id)})]})]})}function Nw({pipeline:e,now:t}){const n=Eo(e.schedule,t);return s.jsxs("a",{className:"task-card pipeline-line",href:`#/p/pipelines/${encodeURIComponent(e.id)}`,children:[s.jsx(J,{name:"flow"}),s.jsx("span",{className:"task-title",children:e.name}),s.jsxs("span",{className:"muted small",children:[_g(e.schedule),n===void 0?"":` · 下次 ${kc(n)}`]}),s.jsx(J,{name:"chevron"})]})}function jw({client:e,reminder:t,now:n}){const[i,r]=b.useState(null),o=async()=>{await Os({title:"删除这个提醒?",message:"agent 到时候就不会再被叫起来做这件事。要改时间,直接在对话里跟它说。",quote:t.title,confirmLabel:"删除",danger:!0})&&(r(null),e.connection.call("reminders/remove",{id:t.id}).catch(c=>r(Ie(c))))};return s.jsxs("div",{className:"task-card reminder-card",children:[s.jsxs("div",{className:"task-card-head",children:[s.jsx(J,{name:"calendar"}),s.jsx("span",{className:"task-title",children:t.title}),s.jsxs("span",{className:"muted small",children:[t.rule==="一次"?"":`${t.rule} · `,t.repeats?"下次 ":"",kc(t.next),t.next>n?`(${gz(t.next-n)}后)`:""]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"icon-button",onClick:()=>void o(),title:"删除这个提醒","aria-label":"删除",children:s.jsx(J,{name:"close"})})]}),s.jsx("div",{className:"task-prompt",children:t.prompt}),i!==null&&s.jsx("div",{className:"error small",children:i})]})}function gz(e){const t=Math.max(1,Math.round(e/6e4));if(t<60)return`${t} 分钟`;const n=Math.round(t/60);return n<48?`${n} 小时`:`${Math.round(n/24)} 天`}function ww({client:e,task:t,now:n,onEdit:i}){const[r,o]=b.useState(null),c=Eo(t.schedule,n),u=t.lastRun,d=m=>{o(null),e.connection.call(m,{id:t.id}).catch(g=>o(Ie(g)))},h=()=>{o(null),e.connection.call("tasks/save",{task:{...t,schedule:{...t.schedule,enabled:!t.schedule.enabled}}}).catch(m=>o(Ie(m)))};return s.jsxs("div",{className:`task-card ${t.schedule.enabled?"":"paused"}`,children:[s.jsxs("div",{className:"task-card-head",children:[s.jsx("span",{className:"task-title",children:t.title}),s.jsxs("span",{className:"muted small",children:[_g(t.schedule),c===void 0?"":` · 下次 ${kc(c)}`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>d("tasks/run"),disabled:(u==null?void 0:u.state)==="running",title:"现在就交给它做一次",children:(u==null?void 0:u.state)==="running"?"在做":"立即运行"}),s.jsx("button",{className:"small-button",onClick:h,children:t.schedule.enabled?"暂停":"开启"}),i!==void 0&&s.jsx("button",{className:"icon-button",onClick:i,title:"修改","aria-label":"修改",children:s.jsx(J,{name:"pencil"})}),i!==void 0&&s.jsx("button",{className:"icon-button",onClick:()=>void Os({title:"删除这个定时任务?",message:"删掉后到点不会再交给 agent 做,不能撤销。",quote:t.title,confirmLabel:"删除",danger:!0}).then(m=>{m&&d("tasks/remove")}),title:"删除","aria-label":"删除",children:s.jsx(J,{name:"close"})})]}),s.jsx("div",{className:"task-prompt",children:t.prompt}),u!==void 0&&s.jsxs("div",{className:`task-run tone-${u.state==="done"?"ok":u.state==="failed"?"failed":"running"}`,children:[u.state==="running"?s.jsx("span",{className:"tool-spinner","aria-hidden":!0}):s.jsx(J,{name:u.state==="done"?"check":"alert"}),s.jsxs("span",{children:[u.state==="running"?"正在做":`${Et(u.endedAt??u.startedAt,n)}${u.state==="done"?"做完":"没做成"}`,u.outcome===void 0?"":`:${u.outcome.split(`
197
+ `)[0]}`]})]}),r!==null&&s.jsx("div",{className:"error small",children:r})]})}function wp({client:e,agents:t,task:n,chooseAgent:i=!1,onDone:r}){var A,P;const[o,c]=b.useState(n.agent),[u,d]=b.useState(n.title??""),[h,m]=b.useState(n.prompt??""),[g,p]=b.useState((((A=n.schedule)==null?void 0:A.times)??["09:00"]).join(", ")),[x,y]=b.useState(((P=n.schedule)==null?void 0:P.days)??[]),[S,N]=b.useState(!1),[k,E]=b.useState(null),j=async()=>{var L,B;N(!0),E(null);try{const V=g.split(/[,,、\s]+/).filter(M=>M!=="").map(M=>/^\d:\d\d$/.test(M)?`0${M}`:M);await e.connection.call("tasks/save",{task:{...n.id===void 0?{}:{id:n.id},agent:o,title:u,prompt:h,schedule:{enabled:((L=n.schedule)==null?void 0:L.enabled)??!0,times:V,days:[...x],catchUpMinutes:((B=n.schedule)==null?void 0:B.catchUpMinutes)??10}}}),r()}catch(V){E(Ie(V))}finally{N(!1)}};return s.jsxs("div",{className:"task-card task-form",children:[i&&s.jsxs("div",{className:"field-label",children:["交给谁",s.jsx(Vt,{"aria-label":"交给谁",value:o,onChange:c,options:t.map(L=>({value:L.id,label:L.name}))})]}),s.jsxs("label",{className:"field-label",children:["名字",s.jsx("input",{className:"text-input plain",value:u,maxLength:60,onChange:L=>d(L.target.value),placeholder:"例如:看今天结束的活动"})]}),s.jsxs("label",{className:"field-label",children:["交给它的话",s.jsx("textarea",{className:"text-input plain",rows:3,value:h,maxLength:4e3,onChange:L=>m(L.target.value),placeholder:"写完整:要做什么、要交回什么"})]}),s.jsxs("div",{className:"task-form-row",children:[s.jsxs("label",{className:"field-label",children:["时间",s.jsx("input",{className:"text-input plain-mono",value:g,onChange:L=>p(L.target.value),placeholder:"09:00, 21:30"})]}),s.jsxs("div",{className:"field-label",children:["星期",s.jsxs("div",{className:"day-chips",children:[pw.map(L=>s.jsx("button",{type:"button",className:`day-chip ${x.includes(L)?"on":""}`,"aria-pressed":x.includes(L),onClick:()=>y(x.includes(L)?x.filter(B=>B!==L):[...x,L]),children:mw[L]},L)),s.jsx("span",{className:"muted small",children:x.length===0?"不选就是每天":""})]})]})]}),k!==null&&s.jsx("div",{className:"error small",children:k}),s.jsxs("div",{className:"task-form-actions",children:[s.jsx("button",{className:"small-button",onClick:r,disabled:S,children:"取消"}),s.jsx("button",{className:"small-button primary",onClick:()=>void j(),disabled:S||u.trim()===""||h.trim()==="",children:"保存"})]})]})}const xz=5*6e4,Sw=["周日","周一","周二","周三","周四","周五","周六"],pd=e=>{const t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()},Qu=e=>`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`;function vz(e,t=Date.now()){const n=new Date(e),i=Math.round((pd(t)-pd(e))/864e5);return i===0?Qu(n):i===1?`昨天 ${Qu(n)}`:`${n.getFullYear()===new Date(t).getFullYear()?"":`${n.getFullYear()}年`}${n.getMonth()+1}月${n.getDate()}日${Sw[n.getDay()]} ${Qu(n)}`}function gd(e){const t=new Date(e);return`${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日${Sw[t.getDay()]} ${Qu(t)}:${String(t.getSeconds()).padStart(2,"0")}`}function _w(e,t){return e===void 0?!1:t===void 0||e-t>=xz||pd(e)!==pd(t)}function Ew({at:e}){return s.jsx("div",{className:"time-divider",title:gd(e),children:s.jsx("span",{children:vz(e)})})}function yz(e,t){b.useLayoutEffect(()=>{const n=e.current;if(n===null||typeof ResizeObserver>"u")return;let i=-1/0;const r=()=>{i=performance.now()},o=new ResizeObserver(()=>{!t.current||n.scrollHeight-n.scrollTop-n.clientHeight<=2||(performance.now()-i<bz?t.current=!1:n.scrollTop=n.scrollHeight)});o.observe(n);for(const c of n.children)o.observe(c);return n.addEventListener("pointerdown",r,!0),n.addEventListener("keydown",r,!0),()=>{o.disconnect(),n.removeEventListener("pointerdown",r,!0),n.removeEventListener("keydown",r,!0)}},[e,t])}const bz=400;function Cw(e){const t=b.useRef(!0),n=b.useRef(0);return{following:t,onScroll:i=>{const r=i.currentTarget,o=r.scrollHeight-r.scrollTop-r.clientHeight,c=r.scrollTop<n.current-1;n.current=r.scrollTop,o<=2?t.current=!0:c?t.current=!1:o<e&&(t.current=!0)},onWheel:i=>{i.deltaY<0&&(t.current=!1)}}}const kz=160;function Yl(e,t=kz){var i;const n=((i=e.split(/\r?\n/).find(r=>r.trim()!==""))==null?void 0:i.trim())??"";return n.length>t?`${n.slice(0,t-1)}…`:n}function sb(e,t="text"){return e.filter(n=>n.type===t).map(n=>n.text).join("")}function Bl(e){const t=Yl(sb(e));if(t!=="")return t;const n=Yl(sb(e,"reasoning"));if(n!=="")return n;const i=e.filter(c=>c.type==="tool-call").map(c=>c.name);if(i.length>0)return`→ ${i.join(", ")}`;const r=e.filter(c=>c.type==="image").length,o=e.filter(c=>c.type==="file").length;return[r>0?`${r} image(s)`:"",o>0?`${o} file(s)`:""].filter(Boolean).join(" · ")}function Nz(e,t=null,n={}){var L,B,V,M,z,D,U;const i=[],r=new Map,o=[],c=new Map,u=new Map,d=new Map;let h=null,m=null,g=null,p=0,x=0;const y=(I,T)=>{let O=r.get(I);return O===void 0&&(O=cm(`t:${I}`,I,T,!0),r.set(I,O),i.push(O)),m=null,O},S=(I,T)=>h!==null?h:(m===null&&(m=cm(`b:${T}`,null,I,!1),i.push(m)),m),N=(I,T,O,$)=>{let F=I.steps.get(O);return F===void 0&&(F={turn:T,step:O,start:$,startKnown:!1,end:null,records:[],retries:0},I.steps.set(O,F),I.stepOrder.push(O)),F},k=(I,T,O)=>{I.records.push(O),T==null||T.records.push(O),o.push(O)},E=I=>(I.requestIndex??(I.requestIndex=++p),I.requestIndex),j=new Set;for(const I of e)switch(x=Math.max(x,I.time),I.type){case"turn/start":{const T=cm(`t:${I.turn}`,I.turn,I.time,!1);r.set(I.turn,T),i.push(T),h=T,m=null;break}case"turn/end":{const T=y(I.turn,I.time);T.end=I.time,T.reason=I.reason;for(const O of T.steps.values())O.end??(O.end=I.time);for(const O of c.values())O.turn===I.turn&&O.status==="running"&&(O.status="interrupted",O.end=I.time);h===T&&(h=null);break}case"step/start":{const T=y(I.turn,I.time),O=N(T,I.turn,I.step,I.time);O.start=I.time,O.startKnown=!0;break}case"step/end":{const T=y(I.turn,I.time);N(T,I.turn,I.step,I.time).end=I.time;break}case"user/message":{const T=S(I.time,I.seq);k(T,null,jz(I,T.turn));break}case"system/message":{if(I.text.trim()==="")break;const T=y(I.turn,I.time),O=N(T,I.turn,I.step,I.time),$={kind:"system",id:`system:${I.seq}`,seq:I.seq,turn:I.turn,step:I.step,start:I.time,end:I.time,status:"ok",title:"System prompt",preview:Yl(I.text),text:I.text};k(T,O,$);break}case"request/header":{g={...I.provider===void 0?{}:{provider:I.provider},...I.model===void 0?{}:{model:I.model},...I.reasoningEffort===void 0?{}:{reasoningEffort:I.reasoningEffort},toolCount:I.toolNames.length};break}case"assistant/attempt":{const T=y(I.turn,I.time),O=N(T,I.turn,I.step,I.time);um(O,I.timing.firstTokenAt),O.retries+=1,I.error!==void 0&&(O.lastRetryError=I.error);const $={kind:"attempt",id:`attempt:${I.seq}`,seq:I.seq,turn:I.turn,step:I.step,start:I.timing.firstChunkAt??O.start,end:I.timing.lastChunkAt??I.time,status:"error",title:"Failed attempt",preview:((L=I.error)==null?void 0:L.message)??"attempt ended without output",...I.error===void 0?{}:{error:I.error}};k(T,O,$);break}case"assistant/message":{const T=y(I.turn,I.time),O=N(T,I.turn,I.step,I.time);um(O,I.timing.firstTokenAt),j.add(`${I.turn}:${I.step}`);const $=I.timing.firstTokenAt,F=I.timing.lastChunkAt,H=$!==void 0&&F!==void 0?F-$:void 0,Z=I.model??(g==null?void 0:g.model),G=I.provider??(g==null?void 0:g.provider),q={kind:"assistant",id:`assistant:${I.seq}`,seq:I.seq,turn:I.turn,step:I.step,start:O.start,end:F??I.time,status:I.interrupted===!0?"interrupted":"ok",title:Z===void 0?"Assistant":`Assistant · ${Z}`,preview:Bl(I.content),content:I.content,live:!1,interrupted:I.interrupted===!0,request:rb({index:E(O),provider:G,model:Z,reasoningEffort:g==null?void 0:g.reasoningEffort,toolCount:g==null?void 0:g.toolCount,ttftMs:ib(O),decodeMs:H,tokensPerSecond:wz((B=I.usage)==null?void 0:B.outputTokens,H),usage:I.usage,retries:O.retries,lastRetryError:O.lastRetryError})};k(T,O,q);break}case"tool/call":{const T=y(I.turn,I.time),O=N(T,I.turn,I.step,I.time),$=d.get(I.callId),F={kind:"tool",id:`tool:${I.callId}`,seq:I.seq,turn:I.turn,step:I.step,start:I.time,end:null,status:T.end===null?"running":"interrupted",title:I.name,preview:Yl(I.arguments),name:I.name,callId:I.callId,arguments:I.arguments,isError:!1,...$===void 0?{}:{approval:{approvalId:$}}};c.set(I.callId,F),k(T,O,F);break}case"tool/result":{const T=c.get(I.callId);if(T===void 0){const $=y(I.turn,I.time),F=N($,I.turn,I.step,I.time),H={kind:"tool",id:`tool:${I.callId}`,seq:I.seq,turn:I.turn,step:I.step,start:I.time,end:I.time,status:I.isError?"error":"ok",title:"tool result",preview:Bl(I.content),name:"tool result",callId:I.callId,arguments:"",result:I.content,isError:I.isError,...I.error===void 0?{}:{error:I.error}};k($,F,H);break}T.end=I.time,T.result=I.content,T.isError=I.isError,T.status=I.isError?"error":"ok",I.error!==void 0&&(T.error=I.error);const O=Bl(I.content);O!==""&&(T.preview=`${Yl(T.arguments,80)} ⇒ ${O}`);break}case"approval/asked":{if(I.callId===void 0)break;d.set(I.callId,I.approvalId);const T=c.get(I.callId);T!==void 0&&(T.approval={approvalId:I.approvalId,...I.reason===void 0?{}:{reason:I.reason}});break}case"approval/decided":{for(const T of c.values())((V=T.approval)==null?void 0:V.approvalId)===I.approvalId&&(T.approval={...T.approval,outcome:I.outcome});break}case"compaction/start":{const T=I.turn===null?S(I.time,I.seq):y(I.turn,I.time),O={kind:"compaction",id:`compaction:${I.compactionId}`,seq:I.seq,turn:T.turn,step:null,start:I.time,end:null,status:"running",title:"Compaction",preview:"summarizing history…",compactionId:I.compactionId};u.set(I.compactionId,O),k(T,null,O);break}case"compaction/summary":{const T=u.get(I.compactionId);if(T===void 0)break;T.shadowedTokenCount=I.shadowedTokenCount,I.usage!==void 0&&(T.usage=I.usage),T.preview=`${I.shadowedTokenCount.toLocaleString("en-US")} tokens summarized`;break}case"compaction/end":{const T=u.get(I.compactionId);if(T===void 0)break;T.end=I.time,T.status=I.error===void 0?"ok":"error",I.error!==void 0&&(T.error=I.error,T.preview=I.error);break}}if(t!==null&&!j.has(`${t.turn}:${t.step}`)){const I=y(t.turn,((M=t.deltas[0])==null?void 0:M.time)??n.now??x),T=N(I,t.turn,t.step,((z=t.deltas[0])==null?void 0:z.time)??n.now??x),O=(D=t.deltas.find(Z=>Z.text!==""||Z.toolName!==void 0))==null?void 0:D.time;um(T,O);const $=Sz(t.deltas),F=(U=t.deltas.at(-1))==null?void 0:U.time;F!==void 0&&(x=Math.max(x,F));const H={kind:"assistant",id:`live:${t.attemptId}`,seq:t.afterSeq,turn:t.turn,step:t.step,start:T.start,end:null,status:"running",title:(g==null?void 0:g.model)===void 0?"Assistant":`Assistant · ${g.model}`,preview:Bl($)||"waiting for output…",content:$,live:!0,interrupted:!1,request:rb({index:E(T),provider:g==null?void 0:g.provider,model:g==null?void 0:g.model,reasoningEffort:g==null?void 0:g.reasoningEffort,toolCount:g==null?void 0:g.toolCount,ttftMs:ib(T),retries:T.retries,lastRetryError:T.lastRetryError})};k(I,T,H)}const A=i.map(I=>({key:I.key,turn:I.turn,start:I.start,end:I.end,partialStart:I.partialStart,...I.reason===void 0?{}:{reason:I.reason},steps:I.stepOrder.map(T=>{const O=I.steps.get(T);return{turn:O.turn,step:O.step,start:O.start,end:O.end,records:O.records}}),records:I.records})),P=n.now??x;return{groups:A,records:o,totals:_z(o),span:Ez(o,P)}}function cm(e,t,n,i){return{key:e,turn:t,start:n,end:null,partialStart:i,steps:new Map,stepOrder:[],records:[]}}function jz(e,t){const n=e.origin.human,i=n?"user":"context",r=e.content.filter(u=>u.type==="image").length,o=e.content.filter(u=>u.type==="file").length,c=n?"User":e.replacesHistory===!0?"Compacted history":`Context · ${e.origin.kind}`;return{kind:i,id:`user:${e.seq}`,seq:e.seq,turn:t,step:null,start:e.time,end:e.time,status:"ok",title:c,preview:e.origin.summary??Bl(e.content),content:e.content,origin:e.origin,imageCount:r,fileCount:o}}function um(e,t){t!==void 0&&(e.firstTokenAt===void 0||t<e.firstTokenAt)&&(e.firstTokenAt=t)}function ib(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 Sz(e){const t=new Map;for(const n of e){const i=t.get(n.index);if(n.kind==="tool-args"){const r=(i==null?void 0:i.type)==="tool-call"?i:void 0;t.set(n.index,{type:"tool-call",callId:n.callId??(r==null?void 0:r.callId)??"",name:n.toolName??(r==null?void 0:r.name)??"",arguments:((r==null?void 0:r.arguments)??"")+n.text})}else{const r=n.kind==="text"?"text":"reasoning",o=(i==null?void 0:i.type)===r?i.text:"";t.set(n.index,{type:r,text:o+n.text})}}return[...t.entries()].sort((n,i)=>n[0]-i[0]).map(([,n])=>n)}function _z(e){const t={requests:0,toolCalls:0,errors:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,reasoningTokens:0};for(const n of e){n.status==="error"&&(t.errors+=1),n.kind==="tool"&&(t.toolCalls+=1);const i=n.kind==="assistant"?n.request.usage:n.kind==="compaction"?n.usage:void 0;n.kind==="assistant"&&(t.requests+=1),i!==void 0&&(t.inputTokens+=i.inputTokens,t.outputTokens+=i.outputTokens,t.cacheReadTokens+=i.cacheReadTokens??0,t.cacheWriteTokens+=i.cacheWriteTokens??0,t.reasoningTokens+=i.reasoningTokens??0)}return t}function Ez(e,t){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const r of e)n=Math.min(n,r.start),i=Math.max(i,r.end??Math.max(r.start,t));return Number.isFinite(n)?{start:n,end:Math.max(n,i)}:null}function rb(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const Aw=[{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"}],Cz=new Map(Aw.flatMap((e,t)=>e.kinds.map(n=>[n,t])));function Az(e){return e.records.map(t=>{const n=t.end===null||t.end<=t.start,i={record:t,lane:Cz.get(t.kind)??0,start:t.start,end:t.end===null?t.start:Math.max(t.start,t.end),instant:n};return t.kind==="assistant"&&t.request.ttftMs!==void 0&&t.end!==null?{...i,firstTokenAt:t.start+t.request.ttftMs}:i})}function Iz(e,t){const n=e.end??e.start;return e.start<=t.end&&n>=t.start}function Tz(e,t,n,i){const o=Math.max(10,(e.end-e.start)*n),c=e.end===e.start?.5:(t-e.start)/(e.end-e.start);let u=t-o*c,d=u+o;return d-u>=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 $z(e,t,n){const i=e.end-e.start,r=Math.min(Math.max(n.start,e.start+t),n.end-i);return{start:r,end:r+i}}function Mz(e,t){const n=t.trim().toLowerCase();return n===""?e:e.filter(i=>i.title.toLowerCase().includes(n)||i.preview.toLowerCase().includes(n)?!0:i.kind==="tool"?i.arguments.toLowerCase().includes(n):!1)}function Rs(e){if(e==null||!Number.isFinite(e))return"—";if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?2:1)} s`;const n=Math.floor(t/60);return n<60?`${n}m ${String(Math.floor(t%60)).padStart(2,"0")}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,"0")}m`}function yn(e){return e==null?"—":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(e<1e4?2:1)}k`:`${(e/1e6).toFixed(2)}M`}function qr(e){const t=new Date(e),n=(i,r=2)=>String(i).padStart(r,"0");return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}.${n(t.getMilliseconds(),3)}`}function Eg(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const ab=["#ff3b30","#ffcc00","#34c759","#0a84ff","#000000","#ffffff"],Rz=[["rect","框"],["arrow","箭头"],["line","直线"],["pen","画笔"]],ob=[[2,"细"],[4,"中"],[7,"粗"]],Oz=.05,lb=16,cb=44;function Cg({src:e,width:t,height:n,name:i,onClose:r}){const[o,c]=b.useState({src:e,width:t,height:n}),{src:u,width:d,height:h}=o,m=b.useRef(null),g=b.useRef(null),[p,x]=b.useState(()=>Pz(t,n)),[y,S]=b.useState({scale:1,x:0,y:0}),[N,k]=b.useState(!1),[E,j]=b.useState("rect"),[A,P]=b.useState(ab[0]),[L,B]=b.useState(ob[0][0]),[V,M]=b.useState([]),[z,D]=b.useState(null),[U,I]=b.useState(!0),[T,O]=b.useState(null),$=b.useRef(null),F=b.useRef(null),H=b.useCallback(()=>{var De;const ue=(De=m.current)==null?void 0:De.getBoundingClientRect();if(ue===void 0||ue.width===0)return;const xe=Math.min(lb,(ue.width-24)/d,(ue.height-24)/h);S({scale:xe,x:(ue.width-d*xe)/2,y:(ue.height-h*xe)/2})},[d,h]);b.useLayoutEffect(H,[H]),b.useEffect(()=>{const ue=m.current;if(ue===null||typeof ResizeObserver>"u")return;const xe=new ResizeObserver(()=>H());return xe.observe(ue),()=>xe.disconnect()},[H]);const Z=(ue,xe,De)=>{var tt;const Me=(tt=m.current)==null?void 0:tt.getBoundingClientRect();if(Me===void 0)return;const Ge=xe??Me.width/2,Te=De??Me.height/2;S(et=>{const St=Math.min(lb,Math.max(Oz,et.scale*ue)),zn=St/et.scale;return{scale:St,x:Ge-(Ge-et.x)*zn,y:Te-(Te-et.y)*zn}})},G=()=>{var xe;const ue=(xe=m.current)==null?void 0:xe.getBoundingClientRect();ue!==void 0&&S({scale:1,x:(ue.width-d)/2,y:(ue.height-h)/2})};b.useEffect(()=>{const ue=m.current;if(ue===null)return;const xe=De=>{De.preventDefault();const Me=ue.getBoundingClientRect();Z(Math.exp(-De.deltaY*.0015),De.clientX-Me.left,De.clientY-Me.top)};return ue.addEventListener("wheel",xe,{passive:!1}),()=>ue.removeEventListener("wheel",xe)});const q=ue=>{O(ue),setTimeout(()=>O(xe=>xe===ue?null:xe),1800)},X=b.useCallback(async(ue,xe=0)=>{const De=new Image;De.src=u,await De.decode();const Me=document.createElement("canvas");Me.width=d,Me.height=h;const Ge=Me.getContext("2d");Ge.drawImage(De,0,0,d,h);for(const et of ue)Dz(Ge,et);if(xe===0)return Me;const Te=document.createElement("canvas");Te.width=h,Te.height=d;const tt=Te.getContext("2d");return tt.translate(h/2,d/2),tt.rotate(xe),tt.drawImage(Me,-d/2,-h/2),Te},[u,d,h]),Y=b.useCallback(async ue=>{try{const xe=await X(ue),De=await new Promise((Me,Ge)=>xe.toBlob(Te=>Te===null?Ge(new Error("没能生成图片")):Me(Te),"image/png"));try{await navigator.clipboard.write([new ClipboardItem({"image/png":De})])}catch(Me){const Ge=wi();if((Ge==null?void 0:Ge.copyImage)===void 0)throw Me;await Ge.copyImage(xe.toDataURL("image/png"))}q(ue.length>0?"已复制(带标注)":"已复制")}catch(xe){q(`复制失败:${xe instanceof Error?xe.message:String(xe)}`)}},[X]),re=async()=>{const ue=await X(V),xe=document.createElement("a");xe.href=ue.toDataURL("image/png"),xe.download=`${i.replace(/[\\/:*?"<>|]/g,"_").replace(/\.\w+$/,"")}${V.length>0?"-标注":""}.png`,xe.click()},ee=async()=>{const ue=await X(V,Math.PI/2);M([]),c({src:ue.toDataURL("image/png"),width:ue.width,height:ue.height})},se=()=>M(ue=>ue.slice(0,-1));b.useEffect(()=>{const ue=xe=>{if(!(g.current===null||!g.current.contains(document.activeElement))){if(xe.key==="Escape"){z!==null?(D(null),$.current=null):N?k(!1):r();return}if((xe.ctrlKey||xe.metaKey)&&xe.key.toLowerCase()==="z"){xe.preventDefault(),se();return}if((xe.ctrlKey||xe.metaKey)&&xe.key.toLowerCase()==="c"){xe.preventDefault(),Y(V);return}xe.key==="0"&&H(),(xe.key==="+"||xe.key==="=")&&Z(1.25),xe.key==="-"&&Z(.8)}};return window.addEventListener("keydown",ue),()=>window.removeEventListener("keydown",ue)});const ne=ue=>{const xe=m.current.getBoundingClientRect(),De=(ue.clientX-xe.left-y.x)/y.scale,Me=(ue.clientY-xe.top-y.y)/y.scale;return[Math.max(0,Math.min(d,De)),Math.max(0,Math.min(h,Me))]},ie=ue=>{if(ue.button!==0&&ue.button!==1)return;if(ue.currentTarget.setPointerCapture(ue.pointerId),!N||ue.button===1){$.current={kind:"pan",sx:ue.clientX,sy:ue.clientY,ox:y.x,oy:y.y};return}const[xe,De]=ne(ue),Me=L/y.scale;$.current={kind:"mark"},D(E==="pen"?{kind:"pen",points:[[xe,De]],color:A,width:Me}:{kind:E,x1:xe,y1:De,x2:xe,y2:De,color:A,width:Me})},pe=ue=>{const xe=$.current;if(xe===null)return;if(xe.kind==="pan"){S(Ge=>({...Ge,x:xe.ox+ue.clientX-xe.sx,y:xe.oy+ue.clientY-xe.sy}));return}const[De,Me]=ne(ue);D(Ge=>Ge===null?Ge:Ge.kind==="pen"?{...Ge,points:[...Ge.points,[De,Me]]}:{...Ge,x2:De,y2:Me})},Ce=()=>{const ue=$.current;if($.current=null,(ue==null?void 0:ue.kind)!=="mark"||z===null||(D(null),(z.kind==="pen"?z.points.length>2?99:0:Math.hypot(z.x2-z.x1,z.y2-z.y1)*y.scale)<4))return;const De=[...V,z];M(De),U&&Y(De)},fe=ue=>{if(ue.target.closest("button")!==null)return;ue.currentTarget.setPointerCapture(ue.pointerId),F.current={sx:ue.clientX,sy:ue.clientY,ox:p.x,oy:p.y};const xe=g.current;xe!==null&&x(De=>({...De,w:xe.offsetWidth,h:xe.offsetHeight}))},ve=ue=>{const xe=F.current;xe!==null&&x(De=>({...De,x:Math.max(-De.w+120,Math.min(window.innerWidth-120,xe.ox+ue.clientX-xe.sx)),y:Math.max(0,Math.min(window.innerHeight-40,xe.oy+ue.clientY-xe.sy))}))};return b.useEffect(()=>{var ue;(ue=g.current)==null||ue.focus()},[]),Ud.createPortal(s.jsxs("div",{ref:g,className:"image-viewer",role:"dialog","aria-label":i,tabIndex:-1,style:{left:p.x,top:p.y,width:p.w,height:p.h},children:[s.jsxs("div",{className:"viewer-title",onPointerDown:fe,onPointerMove:ve,onPointerUp:()=>{F.current=null},onDoubleClick:H,children:[s.jsx("span",{className:"viewer-name",children:i}),s.jsxs("span",{className:"viewer-dim",children:[d,"×",h]}),s.jsx("button",{className:"viewer-icon",onClick:r,title:"关闭(Esc)","aria-label":"关闭",children:"✕"})]}),s.jsxs("div",{ref:m,className:`viewer-stage ${N?"marking":""}`,onPointerDown:ie,onPointerMove:pe,onPointerUp:Ce,onPointerCancel:Ce,children:[s.jsxs("div",{className:"viewer-canvas",style:{width:d,height:h,transform:`translate(${y.x}px, ${y.y}px) scale(${y.scale})`},children:[s.jsx("img",{src:u,alt:i,width:d,height:h,draggable:!1}),s.jsx("svg",{viewBox:`0 0 ${d} ${h}`,width:d,height:h,"aria-hidden":"true",children:[...V,...z===null?[]:[z]].map((ue,xe)=>s.jsx(Lz,{mark:ue},xe))})]}),T!==null&&s.jsx("div",{className:"viewer-toast",role:"status",children:T})]}),N&&s.jsxs("div",{className:"viewer-marks",children:[s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"标注工具",children:Rz.map(([ue,xe])=>s.jsx("button",{role:"radio","aria-checked":E===ue,className:`viewer-icon ${E===ue?"active":""}`,title:xe,onClick:()=>j(ue),children:s.jsx(zz,{tool:ue})},ue))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"粗细",children:ob.map(([ue,xe])=>s.jsx("button",{role:"radio","aria-checked":L===ue,className:`viewer-icon ${L===ue?"active":""}`,title:xe,onClick:()=>B(ue),children:s.jsx("span",{className:"width-dot",style:{width:ue+3,height:ue+3}})},ue))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"颜色",children:ab.map(ue=>s.jsx("button",{role:"radio","aria-checked":A===ue,"aria-label":ue,className:`swatch ${A===ue?"active":""}`,style:{background:ue},onClick:()=>P(ue)},ue))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("button",{className:"viewer-icon",disabled:V.length===0,onClick:se,title:"撤销(Ctrl+Z)",children:"↶"}),s.jsxs("label",{className:"viewer-check",title:"每画完一笔就把带标注的图片复制到剪贴板",children:[s.jsx("input",{type:"checkbox",checked:U,onChange:ue=>I(ue.target.checked)}),"自动复制"]})]}),s.jsxs("div",{className:"viewer-bar",children:[s.jsx("button",{className:"viewer-icon",onClick:()=>Z(.8),title:"缩小",children:"-"}),s.jsxs("button",{className:"viewer-zoom",onClick:H,title:"适应窗口(0)",children:[Math.round(y.scale*100),"%"]}),s.jsx("button",{className:"viewer-icon",onClick:()=>Z(1.25),title:"放大",children:"+"}),s.jsx("button",{className:"viewer-icon",onClick:G,title:"原始大小",children:"1:1"}),s.jsx("span",{className:"viewer-sep"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void ee(),title:"旋转",children:"⟳"}),s.jsx("button",{className:`viewer-icon ${N?"active":""}`,onClick:()=>k(ue=>!ue),title:"标注:画框、箭头、直线",children:"✎"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void Y(V),title:"复制(Ctrl+C)",children:"⧉"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void re(),title:"保存",children:"⤓"})]})]}),document.body)}function Pz(e,t){const n=Math.round(window.innerWidth*.7),i=Math.round(window.innerHeight*.78)-cb*2,r=Math.min(1,n/e,i/t),o=Math.max(420,Math.round(e*r)+24),c=Math.max(300,Math.round(t*r)+24+cb*2);return{x:Math.round((window.innerWidth-o)/2),y:Math.max(16,Math.round((window.innerHeight-c)/2)),w:o,h:c}}function zz({tool:e}){const t={rect:"M5 6h14v12H5z",arrow:"M5 19 19 5M10 5h9v9",line:"M5 19 19 5",pen:"M4 20c3-1 4-5 7-8s6-6 9-8"}[e];return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:t})})}function Iw(e){const t=Math.atan2(e.y2-e.y1,e.x2-e.x1),n=e.width*4.5;return[-.5,.5].map(i=>[e.x2-n*Math.cos(t+i),e.y2-n*Math.sin(t+i)])}function Lz({mark:e}){const t={stroke:e.color,strokeWidth:e.width,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};if(e.kind==="pen")return s.jsx("polyline",{...t,points:e.points.map(i=>i.join(",")).join(" ")});if(e.kind==="rect")return s.jsx("rect",{...t,x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)});const n=e.kind==="arrow"?Iw(e):[];return s.jsxs("g",{...t,children:[s.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}),n.length>0&&s.jsx("polyline",{points:`${n[0][0]},${n[0][1]} ${e.x2},${e.y2} ${n[1][0]},${n[1][1]}`})]})}function Dz(e,t){if(e.strokeStyle=t.color,e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round",e.beginPath(),t.kind==="pen")t.points.forEach(([n,i],r)=>r===0?e.moveTo(n,i):e.lineTo(n,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[n,i]=Iw(t);e.moveTo(n[0],n[1]),e.lineTo(t.x2,t.y2),e.lineTo(i[0],i[1])}e.stroke()}const Ag=b.createContext(null),dm=new Map;function Fz(e,t){let n=dm.get(t.attachmentId);if(n===void 0){const{attachmentId:i,mediaType:r,bytes:o,width:c,height:u}=t;n=e.connection.call("attachments/image",{attachmentId:i,mediaType:r,bytes:o,width:c,height:u}).then(d=>`data:${d.mediaType};base64,${d.data}`),n.catch(()=>dm.delete(t.attachmentId)),dm.set(t.attachmentId,n)}return n}function Tw({image:e}){const t=b.useContext(Ag),[n,i]=b.useState(null),[r,o]=b.useState(null),[c,u]=b.useState(!1),d=(t==null?void 0:t.capabilities.get().has("attachments"))===!0;b.useEffect(()=>{if(t===null||!d)return;let m=!0;return Fz(t,e).then(g=>{m&&i(g)},g=>{m&&o(g instanceof Error?g.message:String(g))}),()=>{m=!1}},[t,d,e]);const h=e.name??`${e.width}×${e.height} 图片`;return d?r!==null?s.jsxs("span",{className:"stored-image missing",children:[h,"没能加载:",r]}):n===null?s.jsx("span",{className:"stored-image loading",style:{width:e.width+2,aspectRatio:`${e.width+2} / ${e.height+2}`}}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"stored-image",onClick:()=>u(!0),title:"点击放大、标注、复制",children:s.jsx("img",{src:n,alt:h,width:e.width,height:e.height})}),c&&s.jsx(Cg,{src:n,width:e.width,height:e.height,name:e.name??"screenshot.png",onClose:()=>u(!1)})]}):s.jsxs("span",{className:"stored-image missing",children:[h,"(当前后端不支持显示图片)"]})}const Uz=3,Bz=/^(编排|游戏信息|干预)[::]/,ub="adg:skill-offer:off",db=e=>`adg:skill-offer:${e}`;function hb(e){try{return localStorage.getItem(e)}catch{return null}}function fb(e,t){try{localStorage.setItem(e,t)}catch{}}function Hz(e){var r;let t=e.length-1;for(;t>=0&&e[t].kind!=="user";)t--;if(t<0)return;const n=e.slice(t+1),i=n.filter(o=>o.kind==="tool");if(!i.some(o=>o.name==="skill"||o.name==="skill_save"||o.status!=="ok")&&!n.some(o=>o.kind==="notice"&&o.tone==="error")&&!n.some(o=>o.kind==="context")&&!(i.length<Uz||((r=n.at(-1))==null?void 0:r.kind)!=="assistant"))return e[t].id}function Zz({session:e,title:t,items:n}){const i=Hz(n),[r,o]=b.useState(()=>hb(ub)==="1"),[c,u]=b.useState(()=>hb(db(e.id))),[d,h]=b.useState(!1);if(i===void 0||r||c===i||t!==null&&Bz.test(t))return null;const m=()=>{fb(db(e.id),i),u(i)},g=async()=>{h(!0);try{await e.prompt(ij),m()}finally{h(!1)}};return s.jsxs("div",{className:"skill-offer",role:"region","aria-label":"存成技能",children:[s.jsx(J,{name:"sparkles"}),s.jsxs("div",{className:"skill-offer-text",children:[s.jsx("strong",{children:"要把这次的做法存成技能吗?"}),s.jsx("span",{children:"agent 会把刚才走通的步骤浓缩成一份技能;下次做同样的事直接照着做,不用重新摸索,少调用模型。"})]}),s.jsxs("div",{className:"skill-offer-actions",children:[s.jsx("button",{className:"link-button small",onClick:()=>{fb(ub,"1"),o(!0)},children:"不再提示"}),s.jsx("button",{className:"small-button",disabled:d,onClick:m,children:"这次不用"}),s.jsx("button",{className:"small-button primary",disabled:d,onClick:()=>void g(),children:"存成技能"})]})]})}function Wz(e,t){const n=we(e.connection.status),i=we(e.capabilities),[r,o]=b.useState(null),c=t&&i.has("notify");return b.useEffect(()=>{if(!c||n.state!=="open")return;let u=!0;return e.connection.call("notify/notices",{}).then(d=>{u&&o(d.items)},()=>{u&&o(d=>d??[])}),()=>{u=!1}},[e,c,n.state]),b.useEffect(()=>{if(c)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,c]),c?r:Vz}const Vz=[];function qz(e,t,n,i){const r=t.filter(h=>h.at>=n);if(r.length===0)return[...e];const o=new Array(e.length);let c=1/0;for(let h=e.length-1;h>=0;h--){const m=e[h];"time"in m&&typeof m.time=="number"&&(c=m.time),o[h]=c}const u=[];let d=0;for(e.forEach((h,m)=>{if(i(h))for(;d<r.length&&r[d].at<o[m];)u.push(mb(r[d++]));u.push(h)});d<r.length;)u.push(mb(r[d++]));return u}function mb(e){return{kind:"sent",id:`sent:${e.id}`,notice:e}}const Gz={info:"send",success:"check",warning:"alert",error:"alert"};function Kz({client:e,notice:t}){const[n,i]=b.useState(null),[r,o]=b.useState(null),c=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(Ie(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 s.jsxs("div",{className:`sent-notice ${t.severity}`,children:[s.jsxs("div",{className:"sent-notice-head",children:[s.jsx(J,{name:Gz[t.severity]}),s.jsx("span",{className:"sent-notice-title",children:t.title}),s.jsx("span",{className:"spacer"}),s.jsxs("span",{className:"muted small",children:[t.channels.length>0?`发到${t.channels.join("、")}`:"只在软件里"," · ",d]})]}),s.jsx("div",{className:"sent-notice-text",children:t.text}),t.image===!0&&s.jsx("div",{className:"muted small",children:"(附了一张截图,在聊天软件里看)"}),c&&s.jsxs("div",{className:"sent-notice-actions",children:[t.actions.map(h=>s.jsx("button",{className:`small-button ${h.style==="primary"?"primary":h.style==="danger"?"danger-outline":""}`,disabled:n!==null,onClick:()=>u(h.id),children:n===h.id?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),h.label]}):h.label},h.id)),s.jsx("span",{className:"muted small",children:"也可以直接跟助手说"})]}),t.acted!==void 0&&s.jsxs("div",{className:"sent-notice-result",children:[s.jsx(J,{name:"check"}),t.acted.by,"选了「",t.acted.label,"」——",t.acted.result]}),t.acted===void 0&&t.done!==void 0&&s.jsxs("div",{className:"sent-notice-result",children:[s.jsx(J,{name:"check"}),t.done]}),r!==null&&s.jsx("div",{className:"error small",children:r})]})}const Yz=80,Xz=[];function $w({client:e,session:t,state:n,readOnly:i}){var G,q,X;const r=b.useMemo(()=>lj(n.events,n.live,n.pending),[n.events,n.live,n.pending,n.version]),o=b.useMemo(()=>r.filter(Y=>!Fw(Y)),[r]),c=b.useMemo(()=>pL(r),[r]),u=ti(e),d=we(e.sessions).items.find(Y=>Y.id===t.id),h=d===void 0?is:Ra(d,u),m=Jj(e,is),g=Wz(e,d!==void 0?d.home===is:m.sessionId===t.id),[p,x]=b.useState(!1),y=p||(n.status==="open"?g!==null:n.status!=="opening");y&&!p&&x(!0);const S=y&&g!==null?g:Xz,N=n.hasMore?((G=n.events[0])==null?void 0:G.time)??0:0,k=b.useMemo(()=>nL(qz(o,S,N,Rw)),[o,S,N]),E=b.useContext(Ig),j=b.useContext(Fo),A=E!==null?j:((q=u.find(Y=>Y.id===h))==null?void 0:q.name)??bn.name,[P,L]=NL((d==null?void 0:d.role)??is),B=E===null?P:3,V=b.useMemo(()=>tL(k,B),[k,B]),M=b.useMemo(()=>{let Y;return V.map(re=>{const ee=Jz(re),se=_w(ee,Y)?ee:void 0;return ee!==void 0&&(Y=ee),se})},[V]),[z,D]=b.useState(null),U=gP(e,t.id),I=U.filter(Y=>Y.fromSession===t.id&&Y.callId===void 0&&(Y.state==="running"||Y.state==="waiting")),T=b.useRef(null),O=Cw(Yz),$=O.following,F=Y=>{O.onScroll(Y),Y.currentTarget.scrollTop<40&&n.hasMore&&!n.loadingOlder&&t.loadOlder()};b.useLayoutEffect(()=>{const Y=T.current;Y!==null&&$.current&&(Y.scrollTop=Y.scrollHeight)},[o,S,y]),yz(T,$);const H=(X=n.events[0])==null?void 0:X.seq,Z=b.useRef(0);return b.useLayoutEffect(()=>{const Y=T.current;Y!==null&&(Z.current!==0&&!$.current&&(Y.scrollTop+=Y.scrollHeight-Z.current),Z.current=Y.scrollHeight)},[H]),s.jsx(Ag.Provider,{value:e,children:s.jsx(Vw.Provider,{value:U,children:s.jsx(Fo.Provider,{value:A,children:s.jsx(Tg.Provider,{value:D,children:s.jsx(Uw.Provider,{value:c,children:s.jsxs("div",{className:`chat-split ${z===null?"":"with-pane"}`,children:[y&&E===null&&k.some(Y=>Mw(Y)>1)&&s.jsx(wL,{detail:P,onChange:L}),s.jsx("div",{className:"chat",ref:T,onScroll:F,onWheel:O.onWheel,children:s.jsxs("div",{className:"chat-inner",children:[y&&n.hasMore&&s.jsx("button",{className:"link-button load-older",disabled:n.loadingOlder,onClick:()=>void t.loadOlder(),children:n.loadingOlder?"加载中…":"加载更早的消息"}),!y&&s.jsx("div",{className:"empty",children:"正在打开会话…"}),y&&n.status!=="opening"&&o.length===0&&s.jsxs("div",{className:"empty chat-empty",children:[s.jsx(zd,{size:"lg"}),s.jsx("h2",{children:"今天,我们一起完成什么?"}),s.jsxs("p",{children:["一个问题、一段代码,或一个还不成熟的想法。",s.jsx("br",{}),"在下方写下来,让对话开始。"]})]}),y&&V.map((Y,re)=>s.jsx(eL,{at:M[re],children:Y.kind==="sent"?s.jsx(Kz,{client:e,notice:Y.item.notice},Y.item.id):Y.kind==="tools"?s.jsx(Ml,{name:A,header:Y.header,children:s.jsx(Pw,{tools:Y.tools})},Y.id):Y.kind==="delegation"?s.jsx(Ml,{name:A,header:Y.header,children:s.jsx(EL,{client:e,item:Y.item,handOffs:U})},Y.item.id):Y.kind==="subtask"?s.jsx(Ml,{name:A,header:Y.header,children:s.jsx(bL,{client:e,item:Y.item,compact:B<3})},Y.item.id):Y.kind==="process"?s.jsx(Ml,{name:A,header:Y.header,children:s.jsx(lL,{items:Y.items,active:n.running&&re===V.length-1,onDismiss:ee=>t.dismissPending(ee)})},Y.id):s.jsx(Ml,{name:A,header:Y.header,children:s.jsx(Ow,{item:Y.item,onDismiss:ee=>t.dismissPending(ee)})},Y.item.id)},Qz(Y))),y&&I.map(Y=>s.jsx(CL,{client:e,handOff:Y},Y.id)),y&&n.running&&n.live===null&&s.jsxs("div",{className:"thinking",children:[s.jsxs("span",{className:"dot-pulse",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}),"正在处理…"]}),y&&i!==!0&&!n.running&&n.queue.length===0&&s.jsx(Zz,{session:t,title:n.title,items:o})]})}),z!==null&&s.jsx(Ww,{client:e,task:z,parent:A,trail:h===is?[]:[bn.name],onClose:()=>D(null)},z.id)]})})})})})})}function Qz(e){return e.kind==="sent"?e.item.id:e.kind==="tools"||e.kind==="process"?e.id:e.item.id}function Jz(e){var n;const t=i=>"time"in i?i.time:void 0;switch(e.kind){case"sent":return e.item.notice.at;case"tools":return(n=e.tools[0])==null?void 0:n.time;case"process":return e.items.map(t).find(i=>i!==void 0);default:return t(e.item)}}function eL({at:e,children:t}){return s.jsxs(s.Fragment,{children:[e!==void 0&&s.jsx(Ew,{at:e}),t]})}function Mw(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=WN(e.item.text);return qN(e.item.text)!==void 0||VN(e.item.text)!==void 0||t!==void 0&&t.by!==rg?2:1}}}function tL(e,t){if(t>1)return e;const n=[];let i=null;for(const r of e)r.kind==="sent"?n.push(r):Mw(r)>1?i=r.header??i:r.kind==="item"&&r.item.kind==="user"?(i=null,n.push(r)):i!==null&&r.header===null&&!(r.kind==="item"&&(r.item.kind==="notice"||r.item.kind==="context"))?(n.push({...r,header:i}),i=null):n.push(r);return n}function nL(e){const t=[];let n=0;for(let i=0;i<=e.length;i++){const r=e[i];r!==void 0&&r.kind!=="sent"&&!Rw(r)||(sL(e.slice(n,i),t),r!==void 0&&t.push(r.kind==="sent"?{kind:"sent",item:r}:{kind:"item",item:r,header:null}),n=i+1)}return t}function Rw(e){return e.kind==="user"||e.kind==="context"&&e.startsTurn===!0}function sL(e,t){let n=!1;const i=e.find(h=>h.kind==="assistant"&&h.model!==void 0),r=()=>n?null:(n=!0,{model:(i==null?void 0:i.kind)==="assistant"?i.model:void 0}),o=h=>{if(h.kind==="tool"&&h.name===xb)t.push({kind:"delegation",item:h,header:r()});else if(h.kind==="tool"&&h.name===pb)t.push({kind:"subtask",item:h,header:r()});else if(h.kind==="tool"){const m=t.at(-1);(m==null?void 0:m.kind)==="tools"?t[t.length-1]={...m,tools:[...m.tools,h]}:t.push({kind:"tools",id:`tools-${h.id}`,tools:[h],header:r()})}else t.push({kind:"item",item:h,header:h.kind==="assistant"?r():null})};let c=[];const u=()=>{if(c.some(h=>h.kind==="tool"))t.push({kind:"process",id:`process-${c[0].id}`,items:c,header:r()});else for(const h of c)o(h);c=[]};let d=e.length;for(let h=e.length-1;h>=0;h--){const m=e[h];if(m.kind==="assistant"&&m.text.trim()!==""){d=h;break}}for(let h=0;h<d;h++){const m=e[h];m.kind==="notice"||m.kind==="context"||m.kind==="tool"&&(m.approval==="asked"||m.name===xb||m.name===pb)?(u(),o(m)):c.push(m)}u();for(let h=d;h<e.length;h++)o(e[h])}function Ml({name:e,header:t,children:n}){return t===null?s.jsx(s.Fragment,{children:n}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"turn-header",children:[s.jsx(zd,{size:"sm"}),s.jsx("span",{className:"turn-name",children:e}),t.model!==void 0&&s.jsx("span",{className:"turn-model",children:t.model})]}),n]})}function iL({text:e}){const t=TR(e);return t===void 0?s.jsx(s.Fragment,{children:e}):s.jsxs(s.Fragment,{children:[t.typed,s.jsxs("details",{className:"slash-expansion",children:[s.jsx("summary",{children:"发给 agent 的完整指令"}),t.expansion]})]})}const rL=/^(这条消息来自([^。)]+)。[^\n]*)\n/,aL=/^(距离这个对话的上一条消息已经过了[^\n]*)\n/;function oL(e){const t=rL.exec(e),n=(t===null?e:e.slice(t[0].length)).replace(aL,"");return t===null?{text:n}:{text:n,channel:t[1]}}const Ow=b.memo(function({item:t,onDismiss:n}){var c;const i=b.useContext(Ag),r=b.useContext(Vw),o=b.useContext(Ig);switch(t.kind){case"user":{if(o!==null)return s.jsxs("div",{className:"msg user delegated",children:[s.jsxs("div",{className:"msg-from",children:[o,"交给的事"]}),s.jsx("div",{className:"bubble",children:s.jsx(Js,{text:Dw(t.text)})})]});const u=t.pending===void 0?qN(t.text):void 0;if(u!==void 0&&i!==null)return s.jsx(AL,{client:i,note:u,handOffs:r});const d=t.pending===void 0?VN(t.text):void 0;if(d!==void 0&&i!==null)return s.jsx(IL,{client:i,note:d,handOffs:r});const h=t.pending===void 0?WN(t.text):void 0;if(h!==void 0&&i!==null)return s.jsx(TL,{client:i,note:h,handOffs:r});const m=oL(t.text);return s.jsxs("div",{className:`msg user ${t.pending===void 0?"":"pending"}`,title:gd(t.time),children:[m.channel!==void 0&&s.jsxs("div",{className:"msg-from",children:["来自",m.channel]}),s.jsxs("div",{className:"bubble",children:[s.jsx(iL,{text:m.text}),t.imageRefs.length>0&&s.jsx("div",{className:"chat-images",children:t.imageRefs.map(g=>s.jsx(Tw,{image:g},g.attachmentId))}),(t.images>t.imageRefs.length||t.files>0)&&s.jsxs("div",{className:"attachments",children:[t.images>t.imageRefs.length&&s.jsxs("span",{children:[s.jsx(J,{name:"image"}),t.images-t.imageRefs.length," 张图片"]}),t.files>0&&s.jsxs("span",{children:[s.jsx(J,{name:"paperclip"}),t.files," 个文件"]})]})]}),((c=t.pending)==null?void 0:c.failed)!==void 0&&s.jsxs("div",{className:"send-failed",children:["发送失败:",t.pending.failed,s.jsx("button",{className:"link-button",onClick:()=>n(t.pending.requestId),children:"移除"})]})]})}case"assistant":return!t.live&&ZM(t.text)?s.jsxs("div",{className:"quiet-reply",children:[s.jsx(J,{name:"check"}),"看过了,没有要告诉你的"]}):s.jsxs("div",{className:`msg assistant ${t.live?"live":""}`,title:t.live?void 0:gd(t.time),children:[t.reasoning.trim()!==""&&s.jsxs("details",{className:"reasoning",open:t.live&&t.text==="",children:[s.jsxs("summary",{children:[s.jsx(J,{name:"chevron"}),t.live&&t.text===""?s.jsx("span",{className:"shimmer",children:"正在思考…"}):"思考过程"]}),s.jsx(Js,{text:t.reasoning})]}),t.text!==""&&s.jsx(Js,{text:t.text}),t.live&&s.jsx("span",{className:"cursor"}),t.interrupted&&s.jsx("div",{className:"muted small",children:"(已中断)"})]});case"tool":return s.jsx(Pw,{tools:[t]});case"context":return s.jsxs("details",{className:"context-row",children:[s.jsxs("summary",{children:[s.jsx(J,{name:"info"}),t.summary!==""?t.summary:t.title]}),s.jsx("pre",{children:t.text})]});case"notice":return s.jsxs("div",{className:`notice ${t.tone}`,children:[t.tone==="error"&&s.jsx(J,{name:"alert"}),t.text]})}});function lL({items:e,active:t,onDismiss:n}){const i=e.filter(h=>h.kind==="tool"),r=i.filter(h=>h.status==="running").length,o=i.filter(h=>h.status==="error").length,[c,u]=b.useState(!1),d=t&&!c?cL(e.at(-1)):void 0;return s.jsxs("div",{className:"tool-group process-group",children:[s.jsxs("button",{className:"tool-group-head",onClick:()=>u(!c),"aria-expanded":c,children:[s.jsx(J,{name:"terminal"}),s.jsx("span",{className:"tool-group-title",children:`执行了 ${i.length} 个步骤`}),d!==void 0&&d!==""&&s.jsx("span",{className:"process-now",children:d}),s.jsxs("span",{className:"tool-group-meta",children:[r>0&&s.jsxs("span",{className:"tone-running",children:[r," 个进行中"]}),o>0&&s.jsxs("span",{className:"tone-failed",children:[o," 个失败"]})]}),s.jsx(J,{name:"chevron-down",className:`chevron-icon ${c?"open":""}`})]}),c&&e.map(h=>h.kind==="tool"?s.jsx(Lw,{item:h},h.id):s.jsx("div",{className:"process-note",children:s.jsx(Ow,{item:h,onDismiss:n})},h.id))]})}function cL(e){return e.kind==="tool"?`${e.name} ${lg(e.arguments)}`.trim():e.kind==="assistant"?e.text.trim().split(`
198
+ `)[0]||"正在思考…":""}function Pw({tools:e}){const t=e.filter(c=>c.status==="running").length,n=e.filter(c=>c.status==="error").length,[i,r]=b.useState(null),o=i??(t>0||n>0||e.length<=4);return s.jsxs("div",{className:"tool-group",children:[s.jsxs("button",{className:"tool-group-head",onClick:()=>r(!o),"aria-expanded":o,children:[s.jsx(J,{name:"terminal"}),s.jsx("span",{className:"tool-group-title",children:e.length===1?"执行了 1 个步骤":`执行了 ${e.length} 个步骤`}),s.jsxs("span",{className:"tool-group-meta",children:[t>0&&s.jsxs("span",{className:"tone-running",children:[t," 个进行中"]}),n>0&&s.jsxs("span",{className:"tone-failed",children:[n," 个失败"]})]}),s.jsx(J,{name:"chevron-down",className:`chevron-icon ${o?"open":""}`})]}),o&&e.map(c=>s.jsx(Lw,{item:c},c.id))]})}const zw={running:"运行中",ok:"完成",error:"失败",interrupted:"已中断"};function Lw({item:e}){const[t,n]=b.useState(!1),i=b.useMemo(()=>lg(e.arguments),[e.arguments]);return b.useEffect(()=>{e.status==="error"&&n(!0)},[e.status]),s.jsxs("div",{className:`tool ${e.status}`,children:[s.jsxs("button",{className:"tool-head",onClick:()=>n(r=>!r),"aria-expanded":t,children:[s.jsx(uL,{status:e.status}),s.jsx("span",{className:"tool-name",children:e.name}),s.jsx("span",{className:"tool-summary",children:i}),e.approval!==void 0&&s.jsx("span",{className:`badge approval-${e.approval}`,children:dL(e.approval)}),s.jsx("span",{className:"tool-status",children:zw[e.status]})]}),e.images!==void 0&&s.jsx("div",{className:"chat-images tool-images",children:e.images.map(r=>s.jsx(Tw,{image:r},r.attachmentId))}),t&&s.jsxs("div",{className:"tool-body",children:[s.jsx("div",{className:"label",children:"参数"}),s.jsx("pre",{children:Eg(e.arguments)}),e.result!==void 0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"label",children:["结果",e.error!==void 0?` · ${e.error}`:""]}),s.jsx("pre",{children:e.result})]})]})]})}function uL({status:e}){return e==="running"?s.jsx("span",{className:"tool-spinner",role:"img","aria-label":"运行中"}):e==="ok"?s.jsx("span",{className:"tool-icon ok",role:"img","aria-label":"完成",children:s.jsx(J,{name:"check"})}):e==="error"?s.jsx("span",{className:"tool-icon error",role:"img","aria-label":"失败",children:s.jsx(J,{name:"close"})}):s.jsx("span",{className:"tool-icon",role:"img","aria-label":zw[e]??e,children:s.jsx(J,{name:"info"})})}function dL(e){switch(e){case"asked":return"等待审批";case"allowed-once":return"已允许";case"rejected":return"已拒绝";case"cancelled":return"已撤回";default:return e}}const pb="subagent",hL=/started subagent (\S+)/,fL=/\s*Your parent agent\b[\s\S]*$/;function Dw(e){return e.replace(fL,"")}const mL=/^Background subagent (\S+) (finished|was stopped)?/;function pL(e){const t=new Map;for(const n of e){if(!Fw(n))continue;const i=mL.exec(n.summary);i!==null&&t.set(i[1],i[2]==="finished"?$g:i[2]==="was stopped"?xL:Zw)}return t}function Fw(e){return e.kind==="context"&&e.title==="subagent-settled"}const Uw=b.createContext(new Map),Ig=b.createContext(null),Tg=b.createContext(()=>{});function gL(e){try{const t=JSON.parse(e);return{description:String(t.description??""),prompt:String(t.prompt??"")}}catch{return{description:"",prompt:e}}}function Bw(e,t){return we(e.sessions).items.find(n=>n.id===t)}const Hw={label:"进行中",tone:"running"},$g={label:"完成",tone:"ok"},xL={label:"已停止",tone:"failed"},Zw={label:"没做成",tone:"failed"};function vL({client:e,id:t,running:n}){const i=Pd(e,t);return i===null?s.jsx("div",{className:"subtask-steps muted small",children:"正在打开…"}):s.jsx(yL,{handle:i,running:n})}function yL({handle:e,running:t}){const n=we(e.state),i=b.useMemo(()=>lj(n.events,n.live,n.pending).filter(o=>o.kind==="tool"),[n.events,n.live,n.pending,n.version]);if(i.length===0)return s.jsx("div",{className:"subtask-steps muted small",children:t?"正在开始…":"没有用工具"});const r=t?i.slice(-4):i;return s.jsx("ol",{className:"subtask-steps",children:r.map(o=>s.jsxs("li",{className:o.status==="error"?"failed":"",children:[o.status==="running"?s.jsx("span",{className:"tool-spinner","aria-hidden":!0}):s.jsx(J,{name:o.status==="error"?"alert":"check"}),s.jsx("span",{className:"subtask-step-name",children:o.name}),s.jsx("span",{className:"subtask-step-args",children:lg(o.arguments)})]},o.id))})}function bL({client:e,item:t,compact:n}){var j;const i=b.useContext(Tg),{description:r,prompt:o}=b.useMemo(()=>gL(t.arguments),[t.arguments]),c=(j=hL.exec(t.result??""))==null?void 0:j[1],u=Bw(e,c),d=t.status==="error"||t.status==="interrupted",h=!d&&((u==null?void 0:u.running)??t.status==="running"),m=b.useContext(Uw),g=d?Zw:h?Hw:(c===void 0?void 0:m.get(c))??$g,p=Xj(e,u===void 0?[]:[{id:u.id,updatedAt:u.updatedAt,running:u.running}]),x=c===void 0?void 0:p.get(c),[y,S]=b.useState(!1),N=r!==""?r:o.split(`
199
+ `)[0]??"子任务",k=s.jsxs("span",{className:`delegation-state tone-${g.tone}`,children:[g.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),g.label]});if(n)return s.jsxs("div",{className:"delegation task-line",children:[s.jsxs("button",{className:`exchange-line subtask-line tone-${g.tone}`,disabled:c===void 0,title:o,onClick:()=>{c!==void 0&&i({id:c,label:N})},children:[s.jsx(J,{name:"flow"}),s.jsx("span",{className:"exchange-who",children:"子任务"}),s.jsx("span",{className:"exchange-title",children:N}),k,c!==void 0&&s.jsx(J,{name:"chevron",className:"exchange-open"})]}),d&&s.jsxs("div",{className:"delegation-failed",children:[s.jsx(J,{name:"alert"}),t.result??t.error??"没有开起来"]})]});const E=c!==void 0&&(h||y);return s.jsxs("div",{className:`subtask tone-${g.tone}`,children:[s.jsxs("div",{className:"subtask-head",children:[s.jsx(J,{name:"flow"}),s.jsx("strong",{className:"subtask-label",title:o,children:N}),k,c!==void 0&&s.jsx("button",{className:"link-button subtask-open",onClick:()=>i({id:c,label:N}),children:"看完整过程"})]}),d&&s.jsxs("div",{className:"delegation-failed",children:[s.jsx(J,{name:"alert"}),t.result??t.error??"没有开起来"]}),E&&s.jsx(vL,{client:e,id:c,running:h}),!h&&x!=null&&x!==""&&s.jsx("div",{className:"subtask-answer",children:s.jsx(Js,{text:x})}),!h&&c!==void 0&&s.jsxs("button",{className:"link-button subtask-fold","aria-expanded":y,onClick:()=>S(A=>!A),children:[s.jsx(J,{name:y?"chevron-down":"chevron"}),y?"收起步骤":"看步骤"]})]})}function Ww({client:e,task:t,parent:n,trail:i,onClose:r}){const o=Pd(e,t.id),c=Bw(e,t.id),[u,d]=b.useState(null),h=(c==null?void 0:c.running)===!0,m=()=>e.connection.call("subagents/stop",{sessionId:t.id}).then(()=>d(null),g=>d(g instanceof Error?g.message:String(g)));return s.jsxs("aside",{className:"subagent-pane","aria-label":`子任务:${t.label}`,children:[s.jsxs("header",{className:"subagent-pane-head",children:[s.jsxs("div",{className:"subagent-trail",children:[[...i,n].map((g,p)=>s.jsxs("span",{children:[g,s.jsx("span",{className:"subagent-trail-sep",children:"›"})]},p)),s.jsx("strong",{title:t.label,children:t.label})]}),h&&s.jsxs("button",{className:"small-button",onClick:()=>void m(),children:[s.jsx(J,{name:"close"}),"停止"]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",title:"关闭",onClick:r,children:s.jsx(J,{name:"close"})})]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:u})]}),s.jsx("div",{className:"subagent-pane-body",children:o===null?s.jsx("div",{className:"empty",children:"正在打开…"}):s.jsx(kL,{client:e,handle:o,parent:n})})]})}function kL({client:e,handle:t,parent:n}){const i=we(t.state);return s.jsx(Ig.Provider,{value:n,children:s.jsx(Fo.Provider,{value:`${n}的子 agent`,children:s.jsx($w,{client:e,session:t,state:i,readOnly:!0})})})}const gb="adg.chatDetail.";function NL(e){const t=()=>{try{const o=Number(localStorage.getItem(gb+e));return o===1||o===3?o:2}catch{return 2}},[n,i]=b.useState(()=>({agentId:e,detail:t()}));return[n.agentId===e?n.detail:t(),o=>{i({agentId:e,detail:o});try{localStorage.setItem(gb+e,String(o))}catch{}}]}const jL=[{level:1,label:"汇报",hint:"只看它和你说的话"},{level:2,label:"协作",hint:"加上 agent 之间的往来,子任务一行"},{level:3,label:"全部",hint:"子任务也展开:步骤和答案"}];function wL({detail:e,onChange:t}){return s.jsx("div",{className:"chat-detail segmented-control",role:"radiogroup","aria-label":"显示多少",children:jL.map(n=>s.jsx("button",{role:"radio","aria-checked":e===n.level,className:e===n.level?"active":"",title:n.hint,onClick:()=>t(n.level),children:n.label},n.level))})}function SL({client:e,session:t,from:n,to:i,onOpen:r}){const o=we(e.sessions).items.filter(c=>c.origin==="subagent"&&c.parentId===t&&c.updatedAt>=n&&(i===void 0||c.updatedAt<=i+2e3));return o.length===0?null:s.jsx("div",{className:"delegation thread-subtasks",children:o.map(c=>{const u=Dw(c.title??"")||"子任务",d=c.running?Hw:$g;return s.jsxs("button",{className:`exchange-line subtask-line tone-${d.tone}`,onClick:()=>r({id:c.id,label:u}),children:[s.jsx(J,{name:"flow"}),s.jsx("span",{className:"exchange-who",children:"子任务"}),s.jsx("span",{className:"exchange-title",children:u}),s.jsxs("span",{className:`delegation-state tone-${d.tone}`,children:[d.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),d.label]}),s.jsx(J,{name:"chevron",className:"exchange-open"})]},c.id)})})}const xb="agent_delegate",Vw=b.createContext([]),Fo=b.createContext(bn.name);function Nc(e){return`#/h/${encodeURIComponent(e.id)}`}function _L(e){try{const t=JSON.parse(e);return{agent:String(t.agent??""),task:String(t.task??"")}}catch{return{agent:"",task:e}}}function ea(e,t){const i=ti(e).find(r=>r.name===t||r.id===t);return i===void 0?t===bn.name||t===bn.id?bn:void 0:Ko(i)}const Aa={running:{label:"进行中",tone:"running"},waiting:{label:"等回答",tone:"running"},done:{label:"交回了",tone:"ok"},failed:{label:"没做成",tone:"failed"}};function jc({from:e,to:t,avatar:n,title:i,state:r,href:o}){const c=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`agent-avatar small agent-${(n==null?void 0:n.id)??"unknown"}`,children:s.jsx(J,{name:(n==null?void 0:n.icon)??"sparkles"})}),s.jsxs("span",{className:"exchange-who",children:[e,s.jsx(J,{name:"arrow",className:"delegation-arrow"}),s.jsx("strong",{children:t})]}),s.jsx("span",{className:"exchange-title",title:i,children:i}),r!==void 0&&s.jsxs("span",{className:`delegation-state tone-${r.tone}`,children:[r.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),r.label]}),o!==void 0&&s.jsx(J,{name:"chevron",className:"exchange-open"})]});return o===void 0?s.jsx("div",{className:`exchange-line tone-${(r==null?void 0:r.tone)??""}`,children:c}):s.jsx("a",{className:`exchange-line tone-${(r==null?void 0:r.tone)??""}`,href:o,title:"看它们说了什么",children:c})}function EL({client:e,item:t,handOffs:n}){const{agent:i,task:r}=b.useMemo(()=>_L(t.arguments),[t.arguments]),o=ea(e,i),c=b.useContext(Fo),u=n.find(m=>m.callId===t.callId),d=t.status==="error"||t.status==="interrupted",h=d?Aa.failed:u===void 0?t.status==="running"?Aa.running:void 0:Aa[u.state];return s.jsxs("div",{className:"delegation",children:[s.jsx(jc,{from:c,to:(o==null?void 0:o.name)??i,avatar:o,title:(u==null?void 0:u.title)??r.split(`
200
+ `)[0]??"",state:h,href:u===void 0?void 0:Nc(u)}),d&&s.jsxs("div",{className:"delegation-failed",children:[s.jsx(J,{name:"alert"}),t.result??t.error??"没有交出去"]})]})}function CL({client:e,handOff:t}){const n=ea(e,t.to);return s.jsx("div",{className:"delegation app-handoff",children:s.jsx(jc,{from:t.by,to:(n==null?void 0:n.name)??t.to,avatar:n,title:t.title,state:Aa[t.state],href:Nc(t)})})}function AL({client:e,note:t,handOffs:n}){const i=ea(e,t.agent),r=b.useContext(Fo),o=n.filter(u=>u.state!=="running"&&u.title===t.title&&(u.to===(i==null?void 0:i.id)||u.to===t.agent)).at(-1),c=o!==void 0?Nc(o):i!==void 0?`#/a/${encodeURIComponent(i.id)}`:void 0;return s.jsx("div",{className:"delegation relay-line",children:s.jsx(jc,{from:t.agent,to:r,avatar:i,title:t.title,state:t.ok?Aa.done:{label:"没有做完",tone:"failed"},href:c})})}function IL({client:e,note:t,handOffs:n}){const i=ea(e,t.from),r=b.useContext(Fo),o=n.find(c=>c.id===t.thread);return s.jsx("div",{className:"delegation task-line",children:s.jsx(jc,{from:t.from,to:r,avatar:i,title:t.text.split(`
201
+ `)[0]??t.title,state:{label:qw[t.kind],tone:t.kind==="question"?"asked":"ok"},href:o===void 0?void 0:Nc(o)})})}function TL({client:e,note:t,handOffs:n}){const[i,r]=b.useState(!1),o=n.filter(d=>d.by===t.by&&d.title===t.title).at(-1),c=ea(e,t.by),u=ea(e,(o==null?void 0:o.to)??"");return t.by===rg?s.jsxs("div",{className:"msg user delegated",children:[s.jsx("div",{className:"msg-from",children:"你在软件里点的"}),s.jsx("div",{className:"bubble",children:s.jsxs("details",{className:"task-note",children:[s.jsx("summary",{children:t.title}),s.jsx("div",{className:"task-note-body",children:t.body})]})})]}):o!==void 0?s.jsx("div",{className:"delegation task-line",children:s.jsx(jc,{from:t.by,to:(u==null?void 0:u.name)??o.to,avatar:c,title:t.title,state:Aa[o.state],href:Nc(o)})}):s.jsxs("div",{className:"delegation task-line",children:[s.jsxs("button",{className:"exchange-line",onClick:()=>r(d=>!d),"aria-expanded":i,title:i?"收起":"看交给了什么",children:[s.jsx("span",{className:`agent-avatar small agent-${(c==null?void 0:c.id)??"unknown"}`,children:s.jsx(J,{name:(c==null?void 0:c.icon)??"calendar"})}),s.jsxs("span",{className:"exchange-who",children:[t.by,"交给的事"]}),s.jsx("span",{className:"exchange-title",title:t.title,children:t.title}),s.jsx(J,{name:i?"chevron-down":"chevron",className:"exchange-open"})]}),i&&s.jsx("div",{className:"exchange-msg-body task-unfolded",children:s.jsx(Js,{text:t.body})})]})}function $L({client:e,handOff:t,name:n}){const i=we(e.sessions).items.find(d=>d.id===t.toSession),r=Xj(e,i===void 0?[]:[{id:i.id,updatedAt:i.updatedAt,running:i.running}]),o=i===void 0?void 0:r.get(i.id),c=b.useRef(void 0);c.current===void 0&&o!==void 0&&(c.current=o);const u=o!=null&&o!==""&&o!==c.current?o:void 0;return s.jsxs("div",{className:"delegation-now",children:[s.jsx("span",{className:"tool-spinner",role:"img","aria-label":"进行中"}),s.jsx("span",{children:(i==null?void 0:i.running)===!0?u??`${n} 正在做…`:`排在 ${n} 手上的事后面`})]})}function ML(e,t){const n=we(e.connection.status),[i,r]=b.useState({item:null,error:null});return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return e.connection.call("handoffs/get",{id:t}).then(c=>{o&&r({item:c,error:null})},c=>{o&&r({item:null,error:c instanceof Error?c.message:String(c)})}),()=>{o=!1}},[e,t,n.state]),b.useEffect(()=>e.connection.on("handoffs/changed",({item:o})=>{o.id===t&&r({item:o,error:null})}),[e,t]),i}function RL(e,t){var h,m;const n=(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]=b.useState([]),[c,u]=b.useState(!1);return b.useEffect(()=>{if(t===null)return;if(n===void 0||i===void 0){u(!0);return}let g=!0;return e.connection.call("handoffs/between",{a:n,b:i}).then(p=>{g&&(o(p.items),u(!0))},()=>{g&&u(!0)}),()=>{g=!1}},[e,n,i,t===null]),b.useEffect(()=>e.connection.on("handoffs/changed",({item:g})=>{var y,S;const p=(y=g.chain)==null?void 0:y.at(-2),x=(S=g.chain)==null?void 0:S.at(-1);(p===n&&x===i||p===i&&x===n)&&o(N=>N.some(k=>k.id===g.id)?N.map(k=>k.id===g.id?g:k):[...N,g])}),[e,n,i]),t===null?{threads:[],ready:!1}:{threads:[...r.some(g=>g.id===t.id)?r:[...r,t]].sort((g,p)=>g.startedAt-p.startedAt),ready:c}}function OL(e,t,n,i){const r=[];for(const o of t){const c=n(o.by),u=n(o.to);r.push({kind:"said",key:`${o.id}:task`,thread:o.id,at:o.startedAt,who:c,body:s.jsxs(s.Fragment,{children:[s.jsx(Js,{text:o.task}),o.expecting!==void 0&&s.jsxs("div",{className:"delegation-expecting",children:["要交回:",o.expecting]})]})}),r.push({kind:"aside",key:`${o.id}:subtasks`,thread:o.id,at:o.startedAt+1,body:s.jsx(SL,{client:e,session:o.toSession,from:o.startedAt,to:o.endedAt,onOpen:i})}),(o.messages??[]).forEach((h,m)=>{h.kind!=="done"&&r.push({kind:"said",key:`${o.id}:${m}`,thread:o.id,at:h.at,who:n(h.from),kindOf:h.kind,body:s.jsx(Js,{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:s.jsxs(s.Fragment,{children:[s.jsx(Js,{text:o.reply??(o.state==="failed"?"没有做完":"它没有留下回复")}),o.state==="failed"&&o.reply!==void 0&&s.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"?s.jsxs("div",{className:"delegation-now",children:[s.jsx("span",{className:"tool-spinner",role:"img","aria-label":"等回答"}),s.jsxs("span",{children:["等",c,"回答"]})]}):s.jsx($L,{client:e,handOff:o,name:u})})}return r.map((o,c)=>[o,c]).sort(([o,c],[u,d])=>o.at-u.at||c-d).map(([o])=>o)}function PL({client:e,id:t,onClose:n}){const{item:i,error:r}=ML(e,t),[o,c]=b.useState(null),u=ti(e),d=ea(e,(i==null?void 0:i.by)??""),h=ea(e,(i==null?void 0:i.to)??""),{threads:m,ready:g}=RL(e,i),p=P=>{var L;return((L=u.find(B=>B.id===P))==null?void 0:L.name)??(P===bn.id?bn.name:P)},x=P=>{const L=u.find(B=>B.name===P||B.id===P);return L===void 0?P===bn.name||P===bn.id?bn:void 0:Ko(L)},y=i===null?[]:OL(e,m,p,c),S=b.useRef(null),N=b.useRef(!1);if(b.useLayoutEffect(()=>{const P=S.current;if(N.current||P===null||i===null||!g)return;N.current=!0;const L=P.querySelector(`[data-thread="${CSS.escape(i.id)}"]`);P.scrollTop=L===null?P.scrollHeight:P.scrollTop+L.getBoundingClientRect().top-P.getBoundingClientRect().top-12},[i,m,g]),b.useEffect(()=>{const P=L=>{L.key==="Escape"&&o===null&&n()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[n,o]),i===null)return s.jsx("section",{className:"main empty exchange-page",children:r??"正在打开…"});const k=(h==null?void 0:h.name)??i.to,E=Aa[i.state],j=[];let A;for(const P of y){const L=P.at===Number.MAX_SAFE_INTEGER?void 0:P.at;if(L!==void 0&&_w(L,A)&&j.push(s.jsx(Ew,{at:L},`t:${P.key}`)),L!==void 0&&(A=L),P.kind==="aside"){j.push(s.jsx("div",{className:"exchange-aside","data-thread":P.thread,children:P.body},P.key));continue}const B=x(P.who);j.push(s.jsxs("div",{className:`exchange-msg ${P.failed===!0?"failed":""}`,"data-thread":P.thread,title:L===void 0?void 0:gd(L),children:[s.jsxs("div",{className:"exchange-msg-head",children:[s.jsx("span",{className:`agent-avatar small agent-${(B==null?void 0:B.id)??"unknown"}`,children:s.jsx(J,{name:(B==null?void 0:B.icon)??"sparkles"})}),s.jsx("strong",{children:P.kindOf===void 0||P.kindOf==="done"?P.who:`${P.who} · ${qw[P.kindOf]}`})]}),s.jsx("div",{className:"exchange-msg-body",children:P.body})]},P.key))}return s.jsxs("section",{className:"main exchange-page",children:[s.jsx("header",{className:"session-header",children:s.jsxs("div",{className:"session-heading",children:[s.jsxs("div",{className:"breadcrumb agent-heading",children:[s.jsx("span",{className:`agent-avatar small agent-${(d==null?void 0:d.id)??"unknown"}`,children:s.jsx(J,{name:(d==null?void 0:d.icon)??"calendar"})}),s.jsx("span",{children:i.by}),s.jsx(J,{name:"arrow",className:"delegation-arrow"}),s.jsx("span",{className:`agent-avatar small agent-${(h==null?void 0:h.id)??"unknown"}`,children:s.jsx(J,{name:(h==null?void 0:h.icon)??"sparkles"})}),s.jsx("h1",{children:k})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx("span",{className:`delegation-state tone-${E.tone}`,children:E.label}),s.jsx("span",{children:i.title}),s.jsx("span",{children:new Date(i.startedAt).toLocaleString()})]})]})}),s.jsx("div",{className:"view",children:s.jsx(Tg.Provider,{value:c,children:s.jsxs("div",{className:`chat-split ${o===null?"":"with-pane"}`,children:[s.jsx("div",{className:"chat",ref:S,children:s.jsx("div",{className:"chat-inner",children:j})}),o!==null&&s.jsx(Ww,{client:e,task:o,parent:k,trail:i.by===k?[]:[i.by],onClose:()=>c(null)},o.id)]})})}),s.jsx("footer",{className:"exchange-footer",children:s.jsxs("button",{className:"small-button",onClick:n,children:[s.jsx(J,{name:"close"}),"关闭"]})})]})}const qw={question:"问",answer:"答",update:"说",done:"结论"},zL=["切换到 dsh 官方界面:DeepSeek Harness 自带的原版界面,没有 MultiGameAssistant 的脚本、编排、游戏等功能。","","· 它是另一个独立的 dsh:聊天记录、设置和模型密钥都和这里分开,第一次用要在那边重新填模型密钥;","· 第一次切换要启动它,可能要等一会儿;","· 这边的定时任务和脚本在后台照常运行。","","点标题栏左上角的「返回 MultiGameAssistant」切回来。"].join(`
202
+ `),Gw="adg.officialIntro";function LL(){var c;const e=(c=wi())==null?void 0:c.uiMode,[t,n]=b.useState(null);if(b.useEffect(()=>{if(e===void 0)return;let u=!0;e.state().then(h=>{u&&n(h)},()=>{});const d=e.onChange(n);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=()=>{FL(),e.set("official")};if(DL()){u();return}Os({title:"切换到 dsh 官方界面?",message:zL,confirmLabel:"切换",icon:"popout"}).then(d=>{d&&u()})},o=t.starting?"正在启动官方界面…":i?"返回 MultiGameAssistant":"dsh 官方界面";return s.jsxs("div",{className:"ui-switch",children:[s.jsxs("button",{type:"button",className:`ui-switch-button ${i?"active":""}`,disabled:t.starting,onClick:r,title:i?"切回 MultiGameAssistant 的界面":"切换到 DeepSeek Harness 自带的界面(聊天记录分开)",children:[s.jsx(J,{name:i?"back":"layers"}),s.jsx("span",{children:o})]}),t.error!==void 0&&s.jsxs("span",{className:"ui-switch-error",role:"alert",title:t.error,children:[s.jsx("span",{children:t.error}),s.jsx("button",{type:"button",className:"icon-button","aria-label":"关闭",onClick:()=>void e.set("adg"),children:s.jsx(J,{name:"close"})})]})]})}function DL(){try{return localStorage.getItem(Gw)==="1"}catch{return!1}}function FL(){try{localStorage.setItem(Gw,"1")}catch{}}const hm="games";function UL({client:e}){const[t,n]=b.useState(()=>Yy()),i=we(e.sessions),r=GR(e),o=we(e.connection.status),c=ti(e),u=b.useRef(!1),d=b.useRef(null);b.useEffect(()=>{_P(t,u.current?"replace":"push"),u.current=!1,t.kind!=="handoff"&&t.kind!=="window"&&(d.current=t)},[t]);const h=t.kind==="handoff"?t:null,m=d.current,g=h===null?t:m!==null&&m.kind!=="settings"?m:{kind:"agent",id:is};b.useEffect(()=>{const $=()=>n(Yy());return window.addEventListener("hashchange",$),()=>window.removeEventListener("hashchange",$)},[]);const p=b.useRef(new Set);b.useEffect(()=>{for(const H of i.items)p.current.add(H.id);if(t.kind!=="session"||!i.loaded||i.items.some(H=>H.id===t.id))return;const $=()=>{u.current=!0,n(H=>H.kind==="session"&&H.id===t.id?{kind:"home"}:H)};if(p.current.has(t.id)){$();return}const F=setTimeout($,8e3);return()=>clearTimeout(F)},[t,i]),b.useEffect(()=>{t.kind!=="start"||o.state!=="open"||(u.current=!0,n(r.some($=>$.id===hm)?{kind:"page",id:hm}:{kind:"home"}))},[t,o.state,r]);const x=Sg(),y=g.kind==="agent"&&(g.tab!=="history"||x)?g.tab:void 0,S=$=>n({kind:"session",id:$}),N=$=>n({kind:"settings",...$===void 0?{}:{section:$}}),k=$=>n({kind:"page",id:$}),E=g.kind==="session"?g.id:null,j=E===null?void 0:i.items.find($=>$.id===E),A=g.kind==="start"?{kind:"page",id:hm}:g,P=A.kind==="page"?r.find($=>$.id===A.id):void 0,L=$=>$.agent===void 0?void 0:c.some(F=>F.id===$.agent)?$.agent:is,B=P===void 0?void 0:L(P),V=$=>n({kind:"agent",id:$}),M=()=>V(is),z=s.jsxs(s.Fragment,{children:[s.jsx(ZL,{client:e,onSettings:()=>N("api-keys")}),s.jsx(iO,{client:e})]}),D=g.kind==="home"?is:g.kind==="agent"?g.id:g.kind==="session"?j===void 0?void 0:Ra(j,c):B,U=($,F)=>n(F==="chat"?{kind:"agent",id:$}:F==="schedule"||F==="history"?{kind:"agent",id:$,tab:F}:{kind:"page",id:F});if(t.kind==="window")return s.jsx(nz,{client:e,viewId:t.view,sessionId:t.sessionId});const I=g.kind==="settings"?{kind:"settings"}:g.kind==="schedule"?{kind:"schedule"}:D!==void 0?{kind:"agent",id:D}:A.kind==="page"?{kind:"page",id:A.id}:{kind:"none"},T=P===void 0?null:s.jsx(P.component,{client:e,openSession:S,openSettings:N,openPage:k,arg:A.kind==="page"?A.arg:void 0},P.id),O=D===void 0?null:s.jsx(BL,{client:e,agentId:D,pages:r.filter($=>L($)===D),current:y!==void 0?y:g.kind==="session"?"history":A.kind==="page"?A.id:"chat",onTab:$=>U(D,$)});return s.jsxs("div",{className:`app ${g.kind==="settings"?"with-sidebar":""}`,children:[s.jsx(kP,{client:e,pages:r.filter($=>$.agent===void 0),current:I,onAgent:V,onPage:k,onSchedule:()=>n({kind:"schedule"}),onSettings:()=>N()}),g.kind==="settings"&&s.jsx(fz,{client:e,onClose:M,section:g.section,onSection:$=>n({kind:"settings",section:$})}),g.kind!=="settings"&&s.jsxs("div",{className:`app-main ${h===null?"":"under-exchange"}`,children:[A.kind==="page"&&B===void 0&&(T??s.jsx("section",{className:"main empty",children:o.state==="open"?"当前连接没有提供这个功能。":"正在连接…"})),D!==void 0&&s.jsxs("div",{className:"agent-area",children:[O,B!==void 0?T:g.kind==="agent"&&y==="schedule"?s.jsx(mz,{client:e,agentId:g.id},g.id):g.kind==="agent"&&y==="history"?s.jsx(bP,{client:e,agentId:g.id,onSelect:S},g.id):g.kind==="session"?s.jsx(kp,{client:e,sessionId:g.id,onAgent:V,reminder:z},g.id):s.jsx(HL,{client:e,agentId:D,onMain:M,onAgent:V,reminder:z},D)]}),g.kind==="schedule"&&s.jsx(pz,{client:e,onAgent:$=>n({kind:"agent",id:$,tab:"schedule"})}),g.kind==="session"&&D===void 0&&s.jsx(kp,{client:e,sessionId:g.id,onAgent:V,reminder:z},g.id),h!==null&&s.jsx(PL,{client:e,id:h.id,onClose:()=>n(g)},h.id)]}),s.jsx(cP,{client:e,sessionId:E,onSelect:S}),s.jsx(LL,{})]})}function BL({client:e,agentId:t,pages:n,current:i,onTab:r}){const o=ti(e),c=we(e.capabilities),u=o.find(p=>p.id===t),d=u===void 0?bn:Ko(u),h=yP(e,t),m=Sg()&&(h||i==="history"),g=[{id:"chat",title:"对话",icon:"chat"},...c.has("pipelines")?[{id:"schedule",title:"定时",icon:"calendar"}]:[],...[...n].sort((p,x)=>p.order-x.order).map(p=>({id:p.id,title:p.title,icon:p.icon})),...m?[{id:"history",title:"以前的对话",icon:"archive"}]:[]];return g.length===1?null:s.jsx("nav",{className:"agent-tabs",role:"tablist","aria-label":d.name,children:g.map(p=>s.jsxs("button",{role:"tab","aria-selected":p.id===i,className:p.id===i?"active":"",onClick:()=>r(p.id),children:[s.jsx(J,{name:p.icon}),p.title]},p.id))})}function HL({client:e,agentId:t,onMain:n,onAgent:i,reminder:r}){const{sessionId:o,error:c}=Jj(e,t);return c!==null?s.jsx("section",{className:"main empty",children:s.jsxs("span",{children:[c,s.jsx("button",{className:"link-button",onClick:n,children:"回到助手"})]})}):o===null?s.jsx("section",{className:"main empty",children:"正在打开…"}):s.jsx(kp,{client:e,sessionId:o,onAgent:i,reminder:r},o)}function ZL({client:e,onSettings:t}){var o;const{items:n}=dj(e,[Qm]),{catalog:i}=Ba(e),r=(i==null?void 0:i.groups.some(c=>c.id!=="deepseek-official"&&c.models.length>0))??!1;return((o=n==null?void 0:n[Qm])==null?void 0:o.configured)!==!1||r?null:s.jsxs("div",{className:"reminder",children:[s.jsx(J,{name:"key"}),s.jsx("span",{children:"还没有可用的模型:请填写 DeepSeek API Key,或添加一个自定义 API(Claude、ChatGPT 等)。"}),s.jsx("button",{className:"primary small-button",onClick:t,children:"去设置"})]})}function WL({onSubmit:e}){const[t,n]=b.useState("");return s.jsx("div",{className:"token-prompt",children:s.jsxs("form",{onSubmit:i=>{i.preventDefault(),t.trim()!==""&&e(t.trim())},children:[s.jsx(zd,{size:"lg"}),s.jsxs("div",{className:"token-heading",children:[s.jsx("p",{className:"eyebrow",children:"MULTI GAME ASSISTANT"}),s.jsx("h1",{children:"连接 agent"}),s.jsxs("p",{className:"muted",children:["输入后端启动时打印的连接 token(",s.jsx("code",{children:"adg gateway: …?token="})," 后面的部分)。"]})]}),s.jsx("label",{className:"field-label",htmlFor:"adg-token",children:"连接 Token"}),s.jsx("input",{id:"adg-token",className:"text-input",autoFocus:!0,value:t,onChange:i=>n(i.target.value),placeholder:"粘贴连接 token"}),s.jsx("button",{className:"primary",type:"submit",disabled:t.trim()==="",children:"连接"})]})})}const VL=["准备环境","启动服务","载入界面","连接 agent"],qL=8e3,GL=400;function KL({client:e}){const t=we(e.connection.status),n=we(e.sessions),[i,r]=b.useState("shown"),[o,c]=b.useState(!1),u=t.state==="open"&&n.loaded;if(b.useEffect(()=>{const m=setTimeout(()=>c(!0),qL);return()=>clearTimeout(m)},[]),b.useEffect(()=>{u&&r(m=>m==="shown"?"leaving":m)},[u]),b.useEffect(()=>{if(i!=="leaving")return;const m=setTimeout(()=>r("gone"),GL);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 s.jsxs("div",{className:`boot${i==="leaving"?" leaving":""}`,"aria-hidden":i==="leaving",children:[s.jsxs("div",{className:"boot-center",children:[s.jsxs("div",{className:"boot-mark","aria-hidden":"true",children:[s.jsxs("svg",{className:"boot-orbit",viewBox:"0 0 132 132",children:[s.jsx("circle",{className:"track",cx:"66",cy:"66",r:"62"}),s.jsx("circle",{className:"comet",cx:"66",cy:"66",r:"62"})]}),s.jsx("span",{className:"boot-tile",children:s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M9.5 8.3v7.4l6.2-3.7-6.2-3.7Z"}),s.jsx("path",{className:"loop",d:"M4 12a8 8 0 0 1 14.5-4.7M20 12a8 8 0 0 1-14.5 4.7"})]})})]}),s.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),s.jsx("p",{className:"boot-stage",role:"status","aria-live":"polite",children:s.jsx("span",{children:d})}),s.jsx("ol",{className:"boot-steps",children:VL.map((m,g)=>s.jsxs("li",{className:g<3?"done":"now",children:[s.jsx("i",{}),s.jsx("span",{children:m})]},m))}),s.jsx("p",{className:`boot-hint${h!==""?" shown":""}`,children:h}),o&&s.jsx("button",{type:"button",className:"boot-skip",onClick:()=>r("leaving"),children:"先进入界面"})]}),s.jsx("p",{className:"boot-foot",children:"日常交给 agent · 在本机运行"})]})}class YL extends b.Component{constructor(){super(...arguments);ut(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n instanceof Error?n:new Error(String(n))}}componentDidCatch(n,i){console.error(`界面出错:${n instanceof Error?n.stack??n.message:String(n)}${i.componentStack??""}`)}render(){const{error:n}=this.state;if(n===null)return this.props.children;const i=`${n.message}
203
+
204
+ ${(n.stack??"").split(`
205
+ `).slice(1,8).join(`
206
+ `)}`;return s.jsx("div",{className:"boot failed",children:s.jsxs("div",{className:"boot-center",children:[s.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),s.jsx("p",{className:"boot-stage",role:"alert",children:s.jsx("span",{children:"界面出错了"})}),s.jsx("div",{className:"boot-detail",children:s.jsx("pre",{tabIndex:0,children:i})}),s.jsxs("div",{className:"boot-actions",children:[s.jsx("button",{type:"button",className:"primary",onClick:()=>location.reload(),children:"重新载入"}),s.jsx("button",{type:"button",onClick:()=>{var r;return void((r=navigator.clipboard)==null?void 0:r.writeText(i))},children:"复制错误信息"})]})]})})}}const XL=450,fm=6,mm=8,pm="data-tip";function QL(){const[e,t]=b.useState(null),n=b.useRef(null),[i,r]=b.useState(null);return b.useEffect(()=>{let o=null,c;const u=()=>{if(window.clearTimeout(c),c=void 0,o!==null){const m=o.getAttribute(pm);o.removeAttribute(pm),m!==null&&!o.hasAttribute("title")&&o.setAttribute("title",m)}o=null,t(null)},d=m=>{var x,y,S,N;if(m.pointerType==="touch")return;if(o!==null&&o.contains(m.target)){const k=(y=(x=m.target).closest)==null?void 0:y.call(x,"[title]");if(k==null||!o.contains(k))return}const g=((N=(S=m.target)==null?void 0:S.closest)==null?void 0:N.call(S,"[title]"))??null;if(g===o||(u(),g===null))return;const p=g.getAttribute("title")??"";p.trim()!==""&&(o=g,g.setAttribute(pm,p),g.removeAttribute("title"),c=window.setTimeout(()=>{o===g&&g.isConnected&&t({text:p,anchor:g.getBoundingClientRect()})},XL))},h=m=>{if(o===null)return;const g=m.relatedTarget;(g===null||!o.contains(g))&&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)}},[]),b.useLayoutEffect(()=>{if(e===null||n.current===null){r(null);return}const{width:o,height:c}=n.current.getBoundingClientRect(),u=e.anchor,d=u.top-fm-c<mm,h=Math.max(mm,Math.min(u.left+u.width/2-o/2,window.innerWidth-o-mm));r({left:h,top:d?u.bottom+fm:u.top-fm-c,below:d})},[e]),e===null?null:Ud.createPortal(s.jsx("div",{ref:n,className:`app-tooltip ${(i==null?void 0:i.below)===!0?"below":""}`,role:"tooltip",style:i===null?{left:0,top:0,visibility:"hidden"}:{left:i.left,top:i.top},children:e.text}),document.body)}const JL={id:"chat",title:"对话",requires:["sessions","chat"],sessionViews:[{id:"chat",title:"对话",order:0,component:$w}]},eD=[],tD={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function nD({client:e}){const t=we(e.connection.status),n=An(3e4),[i,r]=b.useState(null),[o,c]=b.useState(null),[u,d]=b.useState(0),[h,m]=b.useState(null),[g,p]=b.useState(null),[x,y]=b.useState(null),[S,N]=b.useState(""),[k,E]=b.useState(""),[j,A]=b.useState(""),[P,L]=b.useState(""),[B,V]=b.useState({});b.useEffect(()=>e.connection.on("notify/changed",()=>d(O=>O+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let O=!0;return e.connection.call("feishu/settings",{}).then($=>{O&&(r($),N(F=>F===""?$.settings.appId??"":F),A(F=>F===""?$.settings.chatId??"":F))}).catch($=>{O&&p(Ie($))}),e.connection.call("notify/status",{}).then($=>{O&&c($.channels.find(F=>F.id==="feishu")??null)}).catch(()=>{}),()=>{O=!1}},[e,t.state,u]);const M=async(O,$,F)=>{m(O),p(null),y(null);try{const H=await $();H!==null&&typeof H=="object"&&"settings"in H&&r(H),F!==void 0&&y(F),d(Z=>Z+1)}catch(H){p(Ie(H))}finally{m(null)}},z=()=>M("credentials",async()=>(k.trim()!==""&&await e.setCredential(dM,k.trim()),E(""),e.connection.call("feishu/settings/set",{appId:S.trim()===""?null:S.trim(),enabled:!0})),"已保存,正在连接…"),D=()=>M("test",async()=>{const O=await e.connection.call("notify/test",{channel:"feishu"});if(O.failed.length>0)throw new Error(O.failed.map($=>$.error).join(";"))},"测试消息已发送,去飞书看看"),U=i==null?void 0:i.settings,[I,T]=tD[(o==null?void 0:o.state)??"off"];return s.jsxs("div",{className:"remote-section",children:[s.jsx("p",{className:"muted",children:"脚本出问题的通知带截图和「停止 / 重试 / 忽略」按钮;agent 需要你确认的操作也会发成卡片,在飞书或这里先回答的生效。"}),s.jsxs("details",{className:"card guide",children:[s.jsx("summary",{children:s.jsx("strong",{children:"第一次使用:在飞书开放平台创建应用(约 5 分钟)"})}),s.jsxs("ol",{className:"guide-steps",children:[s.jsxs("li",{children:["打开 ",s.jsx("a",{href:"https://open.feishu.cn/app",target:"_blank",rel:"noreferrer",children:"open.feishu.cn/app"}),"(国际版 Lark 用 open.larksuite.com/app),「创建企业自建应用」。"]}),s.jsx("li",{children:"「添加应用能力」→ 添加「机器人」。"}),s.jsxs("li",{children:["「权限管理」开通:",s.jsx("code",{children:"im:message"}),"(获取与发送单聊、群组消息)、",s.jsx("code",{children:"im:message:send_as_bot"}),"、",s.jsx("code",{children:"im:message.p2p_msg:readonly"}),"(读取用户发给机器人的单聊消息)、",s.jsx("code",{children:"im:message.group_at_msg:readonly"}),"(接收群聊中 @ 机器人的消息,可选)、",s.jsx("code",{children:"im:resource"}),"(上传截图)。"]}),s.jsxs("li",{children:["「事件与回调」→「事件配置」:订阅方式选",s.jsx("strong",{children:"使用长连接接收事件"}),",添加事件 ",s.jsx("code",{children:"im.message.receive_v1"}),"(接收消息)。"]}),s.jsxs("li",{children:["「事件与回调」→「回调配置」:订阅方式同样选",s.jsx("strong",{children:"使用长连接接收回调"}),",添加回调 ",s.jsx("code",{children:"card.action.trigger"}),"(卡片回传交互)。"]}),s.jsx("li",{children:"「版本管理与发布」创建版本并发布,可用范围包含你自己。权限或事件改过以后都要重新发布才生效。"}),s.jsx("li",{children:"把「凭证与基础信息」里的 App ID 和 App Secret 填到下面;保存后在飞书里搜索机器人名字,给它发一条消息,再回到这里「允许」自己。"})]}),s.jsx("p",{className:"muted small",children:"先保存凭证再配置长连接:飞书要求应用在线时才能保存「长连接」订阅方式。"})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"连接"}),s.jsx("p",{className:"muted small",children:(o==null?void 0:o.detail)??((o==null?void 0:o.state)==="ready"?`通知会发给 ${o.recipients} 个接收方`:"…")})]}),s.jsx("span",{className:`badge ${I}`,children:T})]}),o!==null&&o.checks.length>0&&s.jsx("ul",{className:"check-list",children:o.checks.map(O=>s.jsxs("li",{className:O.ok===!0?"ok":O.ok===!1?"failed":"",children:[s.jsx("span",{className:"check-mark",children:O.ok===!0?"✓":O.ok===!1?"✗":"…"}),s.jsx("span",{children:O.label}),O.detail!==void 0&&s.jsx("span",{className:"muted small",children:O.detail})]},O.id))}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void M("check",()=>e.connection.call("feishu/check",{})),children:h==="check"?"检查中…":"重新检查"}),s.jsx("button",{className:"small-button",disabled:h!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void D(),children:"发送测试消息"}),U!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:U.enabled,disabled:h!==null,onChange:O=>void M("enable",()=>e.connection.call("feishu/settings/set",{enabled:O.target.checked}))}),"启用飞书"]})]})]}),U!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"应用凭证"}),s.jsx("label",{className:"field-label",htmlFor:"feishu-domain",children:"平台"}),s.jsx(Vt,{id:"feishu-domain",value:U.domain,disabled:h!==null,onChange:O=>void M("domain",()=>e.connection.call("feishu/settings/set",{domain:O})),options:[{value:"feishu",label:"飞书",hint:"open.feishu.cn"},{value:"lark",label:"Lark 国际版",hint:"open.larksuite.com"}]}),s.jsx("label",{className:"field-label",htmlFor:"feishu-app-id",children:"App ID"}),s.jsx("input",{id:"feishu-app-id",className:"text-input",value:S,onChange:O=>N(O.target.value),placeholder:"cli_xxxxxxxx",spellCheck:!1}),s.jsxs("label",{className:"field-label",htmlFor:"feishu-secret",children:["App Secret ",(i==null?void 0:i.secretConfigured)===!0&&s.jsx("span",{className:"badge ok",children:"已保存"})]}),s.jsx("input",{id:"feishu-secret",className:"text-input",type:"password",value:k,onChange:O=>E(O.target.value),placeholder:(i==null?void 0:i.secretConfigured)===!0?"留空则保持不变":"在「凭证与基础信息」里复制",spellCheck:!1,autoComplete:"off"}),s.jsx("p",{className:"muted small",children:"App Secret 存在本机的 dsh 凭据里,不会再显示出来。"}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:h!==null||S.trim()==="",onClick:()=>void z(),children:h==="credentials"?"保存中…":"保存并连接"})]})]}),U!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"允许的用户"}),s.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令、按卡片上的按钮;通知也发给他们。"}),U.allowedUsers.length===0&&s.jsx("div",{className:"muted small",children:"还没有。给机器人发一条消息,它会出现在下面的「待允许」里。"}),s.jsx("ul",{className:"version-list",children:U.allowedUsers.map(O=>s.jsxs("li",{children:[s.jsx("span",{children:O.name??"(未命名)"}),s.jsx("span",{className:"muted small",children:O.openId}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void M(`rm-${O.openId}`,()=>e.connection.call("feishu/users/remove",{openId:O.openId})),children:"移除"})]},O.openId))}),((i==null?void 0:i.pending.length)??0)>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),s.jsx("ul",{className:"version-list",children:i.pending.map(O=>s.jsxs("li",{children:[s.jsx("span",{className:"muted small",children:O.openId}),s.jsxs("span",{className:"muted small",children:["「",O.text,"」 · ",Et(O.at,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:B[O.openId]??"",onChange:$=>V(F=>({...F,[O.openId]:$.target.value}))}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void M(`dismiss-${O.openId}`,()=>e.connection.call("feishu/users/remove",{openId:O.openId})),children:"忽略"}),s.jsx("button",{className:"primary small-button",disabled:h!==null,onClick:()=>void M(`allow-${O.openId}`,()=>{var $;return e.connection.call("feishu/users/allow",{openId:O.openId,...($=B[O.openId])!=null&&$.trim()?{name:B[O.openId].trim()}:{}})}),children:"允许"})]},O.openId))})]}),s.jsx("label",{className:"field-label",htmlFor:"feishu-manual",children:"手动添加 open_id"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"feishu-manual",className:"text-input",value:P,onChange:O=>L(O.target.value),placeholder:"ou_xxxxxxxx",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:h!==null||P.trim()==="",onClick:()=>void M("manual",async()=>{const O=await e.connection.call("feishu/users/allow",{openId:P.trim()});return L(""),O}),children:"添加"})]})]}),U!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"通知"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:U.otherApprovals,disabled:h!==null,onChange:O=>void M("approvals",()=>e.connection.call("feishu/settings/set",{otherApprovals:O.target.checked}))}),"软件里的会话(对话、定时运行、游戏读取)需要确认或 agent 提问时也发到飞书"]}),s.jsx("p",{className:"muted small",children:"在飞书里和 agent 的对话需要确认、或 agent 有问题问你时,只发给发消息的那个人(直接回复文字也算回答);软件里的会话默认只在界面里问。两边都能回答,先回答的生效。"}),s.jsx("label",{className:"field-label",htmlFor:"feishu-chat",children:"同时发到群(可选,填群 ID,机器人需要在群里)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"feishu-chat",className:"text-input",value:j,onChange:O=>A(O.target.value),placeholder:"oc_xxxxxxxx",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void M("chat",()=>e.connection.call("feishu/settings/set",{chatId:j.trim()===""?null:j.trim()})),children:"保存"})]})]}),x!==null&&s.jsxs("div",{className:"notice info left",children:[s.jsx(J,{name:"check"}),s.jsx("span",{children:x})]}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:g})]})]})}const sD={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function iD({client:e}){const t=we(e.connection.status),n=An(3e4),[i,r]=b.useState(null),[o,c]=b.useState(null),[u,d]=b.useState(0),[h,m]=b.useState(null),[g,p]=b.useState(null),[x,y]=b.useState(null),[S,N]=b.useState(""),[k,E]=b.useState(""),[j,A]=b.useState(""),[P,L]=b.useState({});b.useEffect(()=>e.connection.on("notify/changed",()=>d(I=>I+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let I=!0;return e.connection.call("qqbot/settings",{}).then(T=>{I&&(r(T),N(O=>O===""?T.settings.appId??"":O))}).catch(T=>{I&&p(Ie(T))}),e.connection.call("notify/status",{}).then(T=>{I&&c(T.channels.find(O=>O.id==="qq")??null)}).catch(()=>{}),()=>{I=!1}},[e,t.state,u]);const B=async(I,T,O)=>{m(I),p(null),y(null);try{const $=await T();$!==null&&typeof $=="object"&&"settings"in $&&r($),O!==void 0&&y(O),d(F=>F+1)}catch($){p(Ie($))}finally{m(null)}},V=()=>B("credentials",async()=>(k.trim()!==""&&await e.setCredential(hM,k.trim()),E(""),e.connection.call("qqbot/settings/set",{appId:S.trim()===""?null:S.trim(),enabled:!0})),"已保存,正在连接…"),M=()=>B("test",async()=>{const I=await e.connection.call("notify/test",{channel:"qq"});if(I.failed.length>0)throw new Error(I.failed.map(T=>T.error).join(";"))},"测试消息已发送,去 QQ 看看"),z=i==null?void 0:i.settings,[D,U]=sD[(o==null?void 0:o.state)??"off"];return s.jsxs("div",{className:"remote-section",children:[s.jsx("p",{className:"muted",children:"QQ 官方机器人:在 QQ 里和它单聊。消息用 markdown 显示;通知、需要你确认的操作和助手问你的问题下面有按钮,点一下就是回复,也可以直接打字。机器人没有按钮权限时会改成文字,告诉你回复什么。"}),s.jsxs("details",{className:"card guide",children:[s.jsx("summary",{children:s.jsx("strong",{children:"第一次使用:在 QQ 开放平台创建机器人(约 10 分钟)"})}),s.jsxs("ol",{className:"guide-steps",children:[s.jsxs("li",{children:["打开 ",s.jsx("a",{href:"https://bot.q.qq.com/open",target:"_blank",rel:"noreferrer",children:"QQ 开放平台"}),",用 QQ 扫码登录,创建一个机器人。"]}),s.jsxs("li",{children:["在机器人的「开发设置」里复制 ",s.jsx("strong",{children:"AppID"})," 和 ",s.jsx("strong",{children:"AppSecret"}),",填到下面。"]}),s.jsxs("li",{children:["「功能配置」里开启",s.jsx("strong",{children:"单聊"}),"(消息走 WebSocket,不用填回调地址)。还在沙箱阶段的机器人,要把自己的 QQ 加进「沙箱配置」的测试成员。"]}),s.jsx("li",{children:"保存后用手机 QQ 找到机器人(资料卡或沙箱二维码),给它发一条消息,再回到这里「允许」自己。"})]}),s.jsx("p",{className:"muted small",children:"机器人发给你的不是回复的消息(同步的对话、通知)算「主动消息」:在机器人资料卡里要开着「允许主动发送」。"})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"连接"}),s.jsx("p",{className:"muted small",children:(o==null?void 0:o.detail)??((o==null?void 0:o.state)==="ready"?`通知和对话会发给 ${o.recipients} 个人`:"…")})]}),s.jsx("span",{className:`badge ${D}`,children:U})]}),o!==null&&o.checks.length>0&&s.jsx("ul",{className:"check-list",children:o.checks.map(I=>s.jsxs("li",{className:I.ok===!0?"ok":I.ok===!1?"failed":"",children:[s.jsx("span",{className:"check-mark",children:I.ok===!0?"✓":I.ok===!1?"✗":"…"}),s.jsx("span",{children:I.label}),I.detail!==void 0&&s.jsx("span",{className:"muted small",children:I.detail})]},I.id))}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void B("check",()=>e.connection.call("qqbot/check",{})),children:h==="check"?"检查中…":"重新检查"}),s.jsx("button",{className:"small-button",disabled:h!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void M(),children:"发送测试消息"}),z!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:z.enabled,disabled:h!==null,onChange:I=>void B("enable",()=>e.connection.call("qqbot/settings/set",{enabled:I.target.checked}))}),"启用 QQ 机器人"]})]})]}),z!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"机器人凭证"}),s.jsx("label",{className:"field-label",htmlFor:"qq-app-id",children:"AppID"}),s.jsx("input",{id:"qq-app-id",className:"text-input",value:S,onChange:I=>N(I.target.value),placeholder:"102xxxxxx",spellCheck:!1,inputMode:"numeric"}),s.jsxs("label",{className:"field-label",htmlFor:"qq-secret",children:["AppSecret ",(i==null?void 0:i.secretConfigured)===!0&&s.jsx("span",{className:"badge ok",children:"已保存"})]}),s.jsx("input",{id:"qq-secret",className:"text-input",type:"password",value:k,onChange:I=>E(I.target.value),placeholder:(i==null?void 0:i.secretConfigured)===!0?"留空则保持不变":"在「开发设置」里复制",spellCheck:!1,autoComplete:"off"}),s.jsx("p",{className:"muted small",children:"AppSecret 存在本机的 dsh 凭据里,不会再显示出来。"}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:h!==null||S.trim()==="",onClick:()=>void V(),children:h==="credentials"?"保存中…":"保存并连接"})]})]}),z!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"允许的用户"}),s.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令;通知和与助手的对话也发给他们。"}),z.allowedUsers.length===0&&s.jsx("div",{className:"muted small",children:"还没有。在 QQ 里给机器人发一条消息,它会出现在下面的「待允许」里。"}),s.jsx("ul",{className:"version-list",children:z.allowedUsers.map(I=>s.jsxs("li",{children:[s.jsx("span",{children:I.name??"(未命名)"}),s.jsx("span",{className:"muted small",children:I.openId}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void B(`rm-${I.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:I.openId})),children:"移除"})]},I.openId))}),((i==null?void 0:i.pending.length)??0)>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),s.jsx("ul",{className:"version-list",children:i.pending.map(I=>s.jsxs("li",{children:[s.jsx("span",{className:"muted small",children:I.openId}),s.jsxs("span",{className:"muted small",children:["「",I.text,"」 · ",Et(I.at,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:P[I.openId]??"",onChange:T=>L(O=>({...O,[I.openId]:T.target.value}))}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void B(`dismiss-${I.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:I.openId})),children:"忽略"}),s.jsx("button",{className:"primary small-button",disabled:h!==null,onClick:()=>void B(`allow-${I.openId}`,()=>{var T;return e.connection.call("qqbot/users/allow",{openId:I.openId,...(T=P[I.openId])!=null&&T.trim()?{name:P[I.openId].trim()}:{}})}),children:"允许"})]},I.openId))})]}),s.jsx("label",{className:"field-label",htmlFor:"qq-manual",children:"手动添加 user_openid"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"qq-manual",className:"text-input",value:j,onChange:I=>A(I.target.value),placeholder:"机器人回复你的那条消息里有",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:h!==null||j.trim()==="",onClick:()=>void B("manual",async()=>{const I=await e.connection.call("qqbot/users/allow",{openId:j.trim()});return A(""),I}),children:"添加"})]})]}),x!==null&&s.jsxs("div",{className:"notice info left",children:[s.jsx(J,{name:"check"}),s.jsx("span",{children:x})]}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:g})]})]})}const rD=[{id:"feishu",title:"飞书",capability:"feishu",component:nD},{id:"qq",title:"QQ 机器人",capability:"qqbot",component:iD}];function aD({client:e}){var c;const t=we(e.capabilities),n=rD.filter(u=>t.has(u.capability)),[i,r]=b.useState(((c=n[0])==null?void 0:c.id)??"feishu"),o=n.find(u=>u.id===i)??n[0];return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"远程连接"}),s.jsx("p",{children:"不在电脑前也能用:在飞书或 QQ 里和助手说话。和助手的对话两边完全一样——在软件里说的、在聊天软件里说的、助手和其他 agent 之间的往来、助手的回复,都会同步过去;脚本出问题的通知也发到那里,在聊天软件里点按钮或直接回复就能处理。"}),n.length>1&&s.jsx("nav",{className:"agent-tabs remote-tabs",role:"tablist","aria-label":"远程连接方式",children:n.map(u=>s.jsx("button",{role:"tab","aria-selected":u.id===(o==null?void 0:o.id),className:u.id===(o==null?void 0:o.id)?"active":"",onClick:()=>r(u.id),children:u.title},u.id))}),o===void 0?s.jsx("p",{className:"muted",children:"当前连接没有提供远程连接。"}):s.jsx(o.component,{client:e},o.id)]})}const oD=(e,t)=>{try{const n=localStorage.getItem(`adg.fold.${e}`);return n===null?t:n==="1"}catch{return t}};function lD(e,t=!0){const[n,i]=b.useState(()=>oD(e,t));return[n,()=>i(o=>{try{localStorage.setItem(`adg.fold.${e}`,o?"0":"1")}catch{}return!o})]}function cD({open:e,onToggle:t,children:n,count:i,className:r=""}){return s.jsxs("button",{type:"button",className:`fold-head ${r}`,"aria-expanded":e,onClick:t,children:[s.jsx(J,{name:"chevron",className:`fold-chevron ${e?"open":""}`}),s.jsx("span",{className:"fold-title",children:n}),i!==void 0&&s.jsx("span",{className:"fold-count",children:i})]})}function Ia({id:e,title:t,count:n,initial:i=!0,children:r,className:o=""}){const[c,u]=lD(e,i);return s.jsxs("div",{className:`fold ${o}`,children:[s.jsx(cD,{open:c,onToggle:u,...n===void 0?{}:{count:n},children:t}),c&&r]})}function Kw({client:e,scriptId:t,taskId:n,name:i,spec:r,value:o,onChange:c,onCreated:u,profile:d}){const[h,m]=b.useState(null),[g,p]=b.useState(null),[x,y]=b.useState(!1),S=async()=>{const k=(g==null?void 0:g.trim())??"";if(k!==""){m(null),y(!0);try{const{value:E}=await e.connection.call("runs/choices/create",{scriptId:t,taskId:n,param:i,name:k,...d===void 0?{}:{profile:d}});p(null),u==null||u(),c(E)}catch(E){m(Ie(E))}finally{y(!1)}}};let N;if(r.choices!==void 0){const k=r.choices.some(E=>E.value===o);N=s.jsx(Vt,{"aria-label":i,value:k?o:"",placeholder:r.choices.length===0?"本地配置里还没有,先新建或在脚本里建一个":"请选择",onChange:E=>{E==="\0new"?p(j=>j??"MultiGameAssistant"):c(E)},options:[...r.choices.map(E=>({value:E.value,label:E.label,...E.detail===void 0?{}:{hint:E.detail}})),...r.canCreate===!0?[{value:"\0new",label:"+ 新建…"}]:[]]})}else r.type==="boolean"?N=s.jsx(Vt,{"aria-label":i,value:o,onChange:c,options:[{value:"true",label:"是"},{value:"false",label:"否"}]}):r.enum!==void 0?N=s.jsx(Vt,{"aria-label":i,value:o,onChange:c,options:r.enum.map(k=>({value:String(k),label:String(k)}))}):N=s.jsx("input",{className:"text-input plain","aria-label":i,value:o,placeholder:r.default===void 0?"必填":String(r.default),inputMode:r.type==="string"?"text":"numeric",onChange:k=>c(k.target.value)});return s.jsxs("div",{className:"param-row",role:"group","aria-label":i,children:[s.jsxs("span",{className:"field-label",children:[i,r.description===void 0?"":` · ${r.description}`]}),N,g!==null&&s.jsxs("span",{className:"param-new",children:[s.jsx("input",{className:"text-input plain",autoFocus:!0,value:g,"aria-label":"新项的名字",onChange:k=>p(k.target.value),onKeyDown:k=>{k.key==="Enter"?(k.preventDefault(),S()):k.key==="Escape"&&p(null)}}),s.jsx("button",{type:"button",className:"primary small-button",disabled:x||g.trim()==="",onClick:()=>void S(),children:x?"新建中…":"新建"}),s.jsx("button",{type:"button",className:"small-button",disabled:x,onClick:()=>{p(null),m(null)},children:"取消"}),s.jsx("span",{className:"muted small",children:"复制一个现有的同类项,只存在本应用的本地配置里,原项目不变"})]}),h!==null&&s.jsx("span",{className:"error small",children:h})]})}function Yw(e,t,n=!0){const i=we(e.connection.status),[r,o]=b.useState(null);return b.useEffect(()=>{if(o(null),t===void 0||!n||i.state!=="open")return;let c=!0;e.connection.call("configs/profiles",{scriptId:t}).then(d=>{c&&o(d)},()=>{});const u=e.connection.on("configs/profiles/changed",d=>{d.scriptId===t&&o(d.list)});return()=>{c=!1,u()}},[e,t,n,i.state]),r}function Xw({list:e,value:t,onChange:n,id:i,label:r="配置"}){if(e===null||e.items.length<2)return null;const o=e.items.find(u=>u.id===e.current),c=t!==void 0&&!e.items.some(u=>u.id===t);return s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:i,children:r}),s.jsx(Vt,{id:i,value:t??"",onChange:u=>n(u===""?void 0:u),options:[{value:"",label:"跟随当前使用的",hint:`现在是「${(o==null?void 0:o.name)??"默认"}」`},...e.items.map(u=>({value:u.id,label:u.name})),...c?[{value:t,label:"已删除的配置",disabled:!0}]:[]]}),c&&s.jsx("span",{className:"muted small",children:"这份配置已经删了,运行时会失败;请重新选一份。"})]})}const Mg={starting:["","启动中"],running:["","运行中"],stopping:["warn","停止中"],succeeded:["ok","成功"],failed:["warn","失败"],cancelled:["","已停止"]},uD={desktop:"占用鼠标键盘",window:"后台窗口",adb:"模拟器",none:"不占用"};function dD({client:e,scriptId:t,packId:n}){const i=we(e.connection.status),r=An(3e4),[o,c]=b.useState(null),[u,d]=b.useState([]),[h,m]=b.useState(""),[g,p]=b.useState({}),[x,y]=b.useState(!1),[S,N]=b.useState(null),[k,E]=b.useState(null),[j,A]=b.useState(0),P=Yw(e,t,n!==void 0),[L,B]=b.useState(void 0);b.useEffect(()=>{if(i.state!=="open")return;let U=!0;return e.connection.call("runs/tasks",{scriptId:t,...L===void 0?{}:{profile:L}}).then(I=>{U&&(c(I),m(T=>{var O;return T===""?((O=I.tasks[0])==null?void 0:O.id)??"":T}))}).catch(I=>{U&&N(Ie(I))}),e.connection.call("runs/list",{scriptId:t}).then(I=>{U&&d(I.items)}).catch(()=>{}),()=>{U=!1}},[e,t,n,i.state,j,L,P==null?void 0:P.current]),b.useEffect(()=>e.connection.on("runs/state",U=>{U.scriptId===t&&d(I=>[U,...I.filter(T=>T.id!==U.id)].sort((T,O)=>O.startedAt-T.startedAt))}),[e,t]);const V=o==null?void 0:o.tasks.find(U=>U.id===h);b.useEffect(()=>{V!==void 0&&p(Object.fromEntries(Object.entries(V.params).map(([U,I])=>{var T;return[U,I.default!==void 0?String(I.default):((T=I.choices)==null?void 0:T.length)===1?I.choices[0].value:""]})))},[V==null?void 0:V.id]);const M=u.find(U=>U.endedAt===void 0),z=u.find(U=>{var I;return U.id===(k??(M==null?void 0:M.id)??((I=u[0])==null?void 0:I.id))}),D=async()=>{if(V!==void 0){y(!0),N(null);try{const U={};for(const[T,O]of Object.entries(V.params)){const $=g[T]??"";$!==""&&(U[T]=O.type==="boolean"?$==="true":O.type==="integer"||O.type==="number"?Number($):$)}const I=await e.connection.call("runs/start",{scriptId:t,taskId:V.id,params:U,...L===void 0?{}:{profile:L}});E(I.id),I.state==="failed"&&N(I.outcome??"运行失败")}catch(U){N(Ie(U))}finally{y(!1)}}};return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"任务"}),s.jsx("p",{className:"muted small",children:"按脚本包运行,使用本地配置;原项目的配置在运行结束后会还原。"})]})}),o===null&&S===null&&s.jsx("div",{className:"muted small",children:"加载中…"}),o!==null&&!o.runnable&&s.jsx("div",{className:"notice info left small",children:o.problem}),o!==null&&o.tasks.length>0&&s.jsxs("div",{className:"run-form",children:[s.jsx("label",{className:"field-label",htmlFor:"task-select",children:"任务"}),s.jsx(Vt,{id:"task-select",value:h,onChange:m,options:o.tasks.map(U=>({value:U.id,label:U.title,hint:U.id}))}),V!==void 0&&s.jsxs("div",{className:"task-facts muted small",children:[s.jsx("span",{className:"badge",children:uD[V.input]}),V.account!==void 0&&s.jsxs("span",{className:"badge",children:["账号 ",V.account]}),V.expectedDuration!==void 0&&s.jsxs("span",{children:["约 ",V.expectedDuration]}),V.description!==void 0&&s.jsx("span",{children:V.description})]}),s.jsx(Xw,{id:"run-profile",list:P,value:L,onChange:B}),V!==void 0&&Object.entries(V.params).map(([U,I])=>s.jsx(Kw,{client:e,scriptId:t,taskId:V.id,name:U,spec:I,profile:L,value:g[U]??"",onChange:T=>p(O=>({...O,[U]:T})),onCreated:()=>A(T=>T+1)},U)),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),M!==void 0&&s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:M.id}).catch(U=>N(Ie(U))),children:"停止当前运行"}),s.jsxs("button",{className:"primary small-button",disabled:x||!o.runnable||M!==void 0,onClick:()=>void D(),children:[s.jsx(J,{name:"arrow"}),x?"启动中…":"运行"]})]})]}),S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:S})]}),u.length>0&&s.jsxs(Ia,{id:"scripts.recent-runs",title:"最近运行",count:Math.min(u.length,6),className:"run-history",children:[u.slice(0,6).map(U=>{const[I,T]=Mg[U.state];return s.jsxs("button",{className:`run-row ${U.id===(z==null?void 0:z.id)?"active":""}`,"aria-expanded":U.id===(z==null?void 0:z.id),onClick:()=>E(O=>O===U.id||O===null&&U.id===(z==null?void 0:z.id)?"":U.id),children:[s.jsx("span",{className:`badge ${I}`,children:T}),s.jsxs("span",{className:"run-title",children:[U.taskTitle,U.profileName!==void 0&&((P==null?void 0:P.items.length)??0)>1&&s.jsxs("span",{className:"muted small",children:[" · ",U.profileName]})]}),s.jsx("span",{className:"muted small run-outcome",children:U.outcome??U.resources.join(" · ")}),s.jsx("span",{className:"session-time",children:Et(U.startedAt,r)})]},U.id)}),z!==void 0&&s.jsx(Qw,{client:e,run:z},z.id)]})]})}function Qw({client:e,run:t}){const[n,i]=b.useState([]),r=b.useRef(null);b.useEffect(()=>{let h=!0;e.connection.call("runs/logs",{runId:t.id,limit:500}).then(g=>{h&&i(g.lines)}).catch(()=>{});const m=e.connection.on("runs/log",g=>{g.runId===t.id&&i(p=>[...p,...g.lines].slice(-1e3))});return()=>{h=!1,m()}},[e,t.id]),b.useEffect(()=>{const h=r.current;h!==null&&(h.scrollTop=h.scrollHeight)},[n.length]);const o=b.useMemo(()=>t.warnings,[t.warnings]),[c,u]=b.useState(null),d=async()=>{let h=n;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(p=>`${new Date(p.at).toLocaleTimeString("zh-CN",{hour12:!1})} [${p.source==="adg"?"平台":p.source}]${p.level===void 0?"":` [${p.level}]`} ${p.text}`)].join(`
207
+ `),g=await hD(m);u(g?`已复制 ${h.length} 行`:"复制失败"),setTimeout(()=>u(null),1800)};return s.jsxs("div",{className:"run-log-wrap",children:[o.map(h=>s.jsxs("div",{className:"notice info left small",children:[s.jsx(J,{name:"info"}),s.jsx("span",{children:h})]},h)),s.jsxs("div",{className:"run-log-bar",children:[s.jsxs("span",{className:"muted small",children:[n.length," 行",n.length>=1e3?"(只显示最近的)":""]}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{type:"button",className:"small-button",disabled:n.length===0,onClick:()=>void d(),title:"复制整次运行的日志(最多 2000 行),方便发给别人或 agent",children:[s.jsx(J,{name:"copy"}),c??"复制日志"]})]}),s.jsxs("div",{className:"run-log",ref:r,role:"log","aria-label":"运行日志",children:[n.length===0&&s.jsx("div",{className:"muted small",children:"还没有日志"}),n.map((h,m)=>s.jsxs("div",{className:`log-line ${h.level===void 0?"":`lv-${h.level}`} ${h.source==="adg"?"adg":""}`,children:[s.jsx("span",{className:"log-time",children:new Date(h.at).toLocaleTimeString()}),s.jsx("span",{className:"log-source",children:h.source==="adg"?"平台":h.source}),s.jsx("span",{className:"log-text",children:h.text})]},m))]})]})}async function hD(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 Jw=b.createContext({byIncident:new Map,openSession:()=>{}}),fD={running:"agent 正在处理",resolved:"agent 已处理",retried:"agent 处理后重新运行","gave-up":"agent 处理不了","taken-over":"你接管了",timeout:"agent 超时",failed:"agent 没能开始"},mD={error:"出错",warning:"警告",failed:"失败",stalled:"卡住",overtime:"超时"};function pD({client:e,openSettings:t,openSession:n}){const i=we(e.connection.status),r=An(3e4),[o,c]=b.useState([]),[u,d]=b.useState([]),[h,m]=b.useState(null),[g,p]=b.useState(!1),[x,y]=b.useState(null),[S,N]=b.useState([]),k=we(e.capabilities);b.useEffect(()=>{if(i.state!=="open"||!k.has("intervene"))return;let M=!0;return e.connection.call("intervene/list",{limit:100}).then(z=>{M&&N(z.items)}).catch(()=>{}),()=>{M=!1}},[e,i.state,k]),b.useEffect(()=>e.connection.on("intervene/changed",M=>{N(z=>[M,...z.filter(D=>D.id!==M.id)])}),[e]);const E=b.useMemo(()=>{const M=new Map;for(const z of[...S].sort((D,U)=>D.startedAt-U.startedAt))z.incidentId!==void 0&&M.set(z.incidentId,z);return{byIncident:M,openSession:n}},[S,n]);b.useEffect(()=>{if(i.state!=="open")return;let M=!0;return e.connection.call("runs/list",{}).then(z=>{M&&c(z.items)}).catch(z=>{M&&y(Ie(z))}),e.connection.call("monitor/incidents",{status:"all",limit:200}).then(z=>{M&&d(z.items)}).catch(()=>{}),()=>{M=!1}},[e,i.state]),b.useEffect(()=>e.connection.on("runs/state",M=>{c(z=>[M,...z.filter(D=>D.id!==M.id)].sort((D,U)=>U.startedAt-D.startedAt))}),[e]),b.useEffect(()=>e.connection.on("monitor/incident",M=>{d(z=>[M,...z.filter(D=>D.id!==M.id)].sort((D,U)=>U.createdAt-D.createdAt))}),[e]);const j=o.filter(M=>M.endedAt===void 0),A=o.filter(M=>M.endedAt!==void 0).slice(0,30),P=u.filter(M=>M.status==="open"),L=o.find(M=>{var z,D;return M.id===(h??((z=j[0])==null?void 0:z.id)??((D=o[0])==null?void 0:D.id))}),B=b.useMemo(()=>{const M=new Map;for(const z of P)M.set(z.runId,(M.get(z.runId)??0)+1);return M},[P]),V=M=>{const[z,D]=Mg[M.state],U=B.get(M.id)??0;return s.jsxs("button",{className:`script-row ${M.id===(L==null?void 0:L.id)?"active":""}`,onClick:()=>m(M.id),children:[s.jsxs("span",{className:"script-row-main",children:[s.jsxs("span",{className:"script-row-name",children:[M.scriptName," · ",M.taskTitle]}),s.jsxs("span",{className:"muted small",children:[M.kind==="settings"?"设置会话 · ":"",Et(M.startedAt,r),M.retryOf===void 0?"":" · 重新运行"]})]}),U>0?s.jsxs("span",{className:"badge warn",children:["异常 ",U]}):s.jsx("span",{className:`badge ${z}`,children:D})]},M.id)};return s.jsx(Jw.Provider,{value:E,children:s.jsxs("section",{className:"main scripts-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"运行"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"运行监控"})]}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>t("feishu"),children:[s.jsx(J,{name:"plug"}),"消息通知"]}),s.jsxs("button",{className:`small-button ${g?"primary":""}`,onClick:()=>p(M=>!M),children:[s.jsx(J,{name:"settings"}),"监控设置"]})]})]}),s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"运行列表",children:[x!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:x})]}),s.jsxs(Ia,{id:"monitor.active",title:"正在运行",count:j.length,className:"list-fold",children:[j.length===0&&s.jsx("div",{className:"muted small pad",children:"没有正在运行的任务"}),j.map(V)]}),A.length>0&&s.jsx(Ia,{id:"monitor.recent",title:"最近",count:A.length,className:"list-fold",children:A.map(V)})]}),s.jsx("div",{className:"scripts-detail",children:s.jsxs("div",{className:"script-detail",children:[g&&s.jsx(xD,{client:e}),P.length>0&&s.jsx("section",{className:"card",children:s.jsxs(Ia,{id:"monitor.open-incidents",title:s.jsxs("h3",{children:["待处理的异常(",P.length,")"]}),className:"card-fold",children:[s.jsx("p",{className:"muted small",children:"脚本包里写了自动处理的(如重连模拟器、重新运行)会先自动处理;处理不了的才推送到飞书。"}),s.jsx("div",{className:"incident-list",children:P.map(M=>s.jsx(eS,{client:e,incident:M,now:r,onOpen:()=>m(M.runId)},M.id))})]})}),L===void 0&&P.length===0&&s.jsxs("div",{className:"empty",children:[s.jsx(J,{name:"monitor"}),s.jsx("p",{children:"还没有运行记录。在「脚本」页运行一个任务,或对 agent 说「跑一下方舟日常」。"})]}),L!==void 0&&s.jsx(gD,{client:e,run:L,incidents:u.filter(M=>M.runId===L.id),now:r,openRun:m})]})})]})]})})}function gD({client:e,run:t,incidents:n,now:i,openRun:r}){const[o,c]=Mg[t.state],[u,d]=b.useState(null);return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsxs("h3",{children:[t.scriptName," · ",t.taskTitle]}),s.jsxs("p",{className:"muted small",children:[new Date(t.startedAt).toLocaleString("zh-CN",{hour12:!1}),t.endedAt===void 0?"":` → ${new Date(t.endedAt).toLocaleTimeString("zh-CN",{hour12:!1})}`,t.resources.length>0?` · ${t.resources.join(" · ")}`:""]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:`badge ${o}`,children:c}),t.endedAt===void 0&&s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:t.id}).catch(h=>d(Ie(h))),children:"停止"})]})]}),t.outcome!==void 0&&s.jsxs("div",{className:"muted small",children:["结果:",t.outcome]}),t.retryOf!==void 0&&s.jsxs("button",{className:"link-button small",onClick:()=>r(t.retryOf),children:["这是 ",t.retryOf," 的重新运行"]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:u})]}),s.jsx(Ia,{id:"monitor.run-log",title:"日志",children:s.jsx(Qw,{client:e,run:t},t.id)}),n.length>0&&s.jsx(Ia,{id:"monitor.run-incidents",title:"这次运行的异常",count:n.length,children:s.jsx("div",{className:"incident-list",children:n.map(h=>s.jsx(eS,{client:e,incident:h,now:i},h.id))})})]})}function eS({client:e,incident:t,now:n,onOpen:i}){const{byIncident:r,openSession:o}=b.useContext(Jw),c=r.get(t.id),[u,d]=b.useState(!1),[h,m]=b.useState(null),[g,p]=b.useState(null),x=async()=>{if(c!==void 0){d(!0),m(null);try{await e.connection.call("intervene/takeover",{id:c.id})}catch(N){m(Ie(N))}finally{d(!1)}}},y=async N=>{d(!0),m(null);try{await e.connection.call("monitor/act",{incidentId:t.id,action:N})}catch(k){m(Ie(k))}finally{d(!1)}},S=async()=>{if(g!==null)return p(null);try{const N=await e.connection.call("monitor/screenshot",{incidentId:t.id});p(`data:${N.mime};base64,${N.data}`)}catch(N){m(Ie(N))}};return s.jsxs("div",{className:`incident ${t.severity} ${t.status}`,children:[s.jsxs("div",{className:"incident-head",children:[s.jsx("span",{className:`badge ${t.severity==="error"?"warn":""}`,children:mD[t.kind]}),i===void 0?s.jsx("span",{className:"incident-title",children:t.title}):s.jsx("button",{className:"link-button incident-title",onClick:i,children:t.title}),s.jsx("span",{className:"session-time",children:Et(t.createdAt,n)})]}),s.jsx("div",{className:"incident-detail",children:t.detail}),t.steps.length>0&&s.jsx("ul",{className:"incident-steps",children:t.steps.filter(N=>(c==null?void 0:c.summary)===void 0||c.state==="running"||!N.detail.endsWith(c.summary)).map((N,k)=>s.jsxs("li",{className:N.ok?"ok":"failed",children:[N.ok?"✓":"✗"," ",N.detail]},k))}),t.status==="resolved"&&s.jsxs("div",{className:"muted small",children:["已处理:",t.resolution]}),c!==void 0&&s.jsxs("div",{className:`agent-line ${c.state}`,children:[s.jsxs("span",{className:"badge",children:[fD[c.state],c.mode==="diagnose"?"(只诊断)":""]}),c.summary!==void 0&&s.jsx("span",{className:"small",children:c.summary}),c.paused&&s.jsx("span",{className:"badge warn",children:"脚本暂停中"}),s.jsx("span",{className:"spacer"}),c.sessionId!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>o(c.sessionId),children:"看 agent 的处理过程"}),c.state==="running"&&s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void x(),children:"我来接管"})]}),t.status==="open"&&s.jsxs("div",{className:"key-actions",children:[t.screenshot&&s.jsxs("button",{className:"small-button",onClick:()=>void S(),children:[s.jsx(J,{name:"image"}),g===null?"截图":"收起截图"]}),s.jsx("span",{className:"spacer"}),(c==null?void 0:c.paused)===!0&&s.jsx("button",{className:"primary small-button",disabled:u,onClick:()=>void y("resume"),children:"继续"}),s.jsx("button",{className:"danger-outline small-button",disabled:u,onClick:()=>void y("stop"),children:"停止"}),s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void y("retry"),children:"重试"}),s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void y("resolve"),children:"忽略"})]}),g!==null&&s.jsx("img",{className:"incident-shot",src:g,alt:"异常时的截图"}),h!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:h})]})]})}function xD({client:e}){var d;const[t,n]=b.useState(null),[i,r]=b.useState(null);b.useEffect(()=>{e.connection.call("monitor/settings",{}).then(n).catch(h=>r(Ie(h)))},[e]);const o=h=>e.connection.call("monitor/settings/set",h).then(n).catch(m=>r(Ie(m))),c=((d=Ld(e).data)==null?void 0:d.scripts)??[],u=Object.entries((t==null?void 0:t.scriptStall)??{}).sort(([h],[m])=>h.localeCompare(m));return s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"监控设置"}),t!==null&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"stall-seconds",children:"多少秒没有新日志算卡住、交给干预(默认值;0 = 不检测)"}),s.jsx("input",{id:"stall-seconds",className:"text-input plain",type:"number",min:0,max:86400,defaultValue:t.defaultStallSeconds,onBlur:h=>void o({defaultStallSeconds:Math.max(0,Math.min(86400,Math.round(Number(h.target.value)||0)))})}),s.jsx("p",{className:"muted small",children:"每个脚本会从自己跑成功的记录里学:卡住时间取最近几次里最长安静时间的 1.5 倍(不低于上面的默认值);agent 看过日志节奏后也会替它调。"}),u.length>0&&s.jsx("ul",{className:"stall-list",children:u.map(([h,m])=>{var g;return s.jsxs("li",{children:[s.jsx("span",{children:((g=c.find(p=>p.id===h))==null?void 0:g.name)??h}),s.jsxs("span",{className:"muted small",children:[m.seconds," 秒 · ",m.by==="learned"?"学到的":m.by==="agent"?"agent 设的":"你设的",m.note===void 0?"":`:${m.note}`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"link-button small",onClick:()=>{const{[h]:p,...x}=t.scriptStall;o({scriptStall:x})},children:"恢复自动"})]},h)})}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.screenshot,onChange:h=>void o({screenshot:h.target.checked})}),"出错时截图(模拟器画面或桌面)并随通知发送"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.notifyWarnings,onChange:h=>void o({notifyWarnings:h.target.checked})}),"警告也推送(默认只推送出错、失败、卡住)"]}),s.jsx("label",{className:"field-label",htmlFor:"intervene-mode",children:"自动处理解决不了的问题,先交给 agent(需要能看图的模型)"}),s.jsx(Vt,{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:"直接通知我"}]}),s.jsx("label",{className:"field-label",htmlFor:"intervene-cap",children:"每天最多交给 agent 几次(控制模型费用)"}),s.jsx("input",{id:"intervene-cap",className:"text-input plain",type:"number",min:0,max:200,defaultValue:t.interventionsPerDay,onBlur:h=>void o({interventionsPerDay:Math.max(0,Math.min(200,Math.round(Number(h.target.value)||0)))})})]}),i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:i})]})]})}const vD={id:"runs",title:"运行监控",milestone:"M3",requires:["runs","monitor"],pages:[{id:"runs",title:"运行",icon:"monitor",order:30,agent:"intervene",component:pD}]},yD={id:"feishu",title:"远程连接",milestone:"M3",requires:["notify","credentials"],settingsPages:[{id:"feishu",title:"远程连接",order:12,component:aD}]};function Nn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n<e.length;n++)(i=Nn(e[n]))!==""&&(t+=(t&&" ")+i);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var bD={value:()=>{}};function Bd(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new Ju(n)}function Ju(e){this._=e}function kD(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}Ju.prototype=Bd.prototype={constructor:Ju,on:function(e,t){var n=this._,i=kD(e+"",n),r,o=-1,c=i.length;if(arguments.length<2){for(;++o<c;)if((r=(e=i[o]).type)&&(r=ND(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<c;)if(r=(e=i[o]).type)n[r]=vb(n[r],e.name,t);else if(t==null)for(r in n)n[r]=vb(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ju(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,o;i<r;++i)n[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,n)},apply:function(e,t,n){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,n)}};function ND(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function vb(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=bD,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var Sp="http://www.w3.org/1999/xhtml";const yb={svg:"http://www.w3.org/2000/svg",xhtml:Sp,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Hd(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),yb.hasOwnProperty(t)?{space:yb[t],local:e}:e}function jD(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Sp&&t.documentElement.namespaceURI===Sp?t.createElement(e):t.createElementNS(n,e)}}function wD(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function tS(e){var t=Hd(e);return(t.local?wD:jD)(t)}function SD(){}function Rg(e){return e==null?SD:function(){return this.querySelector(e)}}function _D(e){typeof e!="function"&&(e=Rg(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o=t[r],c=o.length,u=i[r]=new Array(c),d,h,m=0;m<c;++m)(d=o[m])&&(h=e.call(d,d.__data__,m,o))&&("__data__"in d&&(h.__data__=d.__data__),u[m]=h);return new Ps(i,this._parents)}function ED(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function CD(){return[]}function nS(e){return e==null?CD:function(){return this.querySelectorAll(e)}}function AD(e){return function(){return ED(e.apply(this,arguments))}}function ID(e){typeof e=="function"?e=AD(e):e=nS(e);for(var t=this._groups,n=t.length,i=[],r=[],o=0;o<n;++o)for(var c=t[o],u=c.length,d,h=0;h<u;++h)(d=c[h])&&(i.push(e.call(d,d.__data__,h,c)),r.push(d));return new Ps(i,r)}function sS(e){return function(){return this.matches(e)}}function iS(e){return function(t){return t.matches(e)}}var TD=Array.prototype.find;function $D(e){return function(){return TD.call(this.children,e)}}function MD(){return this.firstElementChild}function RD(e){return this.select(e==null?MD:$D(typeof e=="function"?e:iS(e)))}var OD=Array.prototype.filter;function PD(){return Array.from(this.children)}function zD(e){return function(){return OD.call(this.children,e)}}function LD(e){return this.selectAll(e==null?PD:zD(typeof e=="function"?e:iS(e)))}function DD(e){typeof e!="function"&&(e=sS(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o=t[r],c=o.length,u=i[r]=[],d,h=0;h<c;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new Ps(i,this._parents)}function rS(e){return new Array(e.length)}function FD(){return new Ps(this._enter||this._groups.map(rS),this._parents)}function xd(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}xd.prototype={constructor:xd,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 UD(e){return function(){return e}}function BD(e,t,n,i,r,o){for(var c=0,u,d=t.length,h=o.length;c<h;++c)(u=t[c])?(u.__data__=o[c],i[c]=u):n[c]=new xd(e,o[c]);for(;c<d;++c)(u=t[c])&&(r[c]=u)}function HD(e,t,n,i,r,o,c){var u,d,h=new Map,m=t.length,g=o.length,p=new Array(m),x;for(u=0;u<m;++u)(d=t[u])&&(p[u]=x=c.call(d,d.__data__,u,t)+"",h.has(x)?r[u]=d:h.set(x,d));for(u=0;u<g;++u)x=c.call(e,o[u],u,o)+"",(d=h.get(x))?(i[u]=d,d.__data__=o[u],h.delete(x)):n[u]=new xd(e,o[u]);for(u=0;u<m;++u)(d=t[u])&&h.get(p[u])===d&&(r[u]=d)}function ZD(e){return e.__data__}function WD(e,t){if(!arguments.length)return Array.from(this,ZD);var n=t?HD:BD,i=this._parents,r=this._groups;typeof e!="function"&&(e=UD(e));for(var o=r.length,c=new Array(o),u=new Array(o),d=new Array(o),h=0;h<o;++h){var m=i[h],g=r[h],p=g.length,x=VD(e.call(m,m&&m.__data__,h,i)),y=x.length,S=u[h]=new Array(y),N=c[h]=new Array(y),k=d[h]=new Array(p);n(m,g,S,N,k,x,t);for(var E=0,j=0,A,P;E<y;++E)if(A=S[E]){for(E>=j&&(j=E+1);!(P=N[j])&&++j<y;);A._next=P||null}}return c=new Ps(c,i),c._enter=u,c._exit=d,c}function VD(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function qD(){return new Ps(this._exit||this._groups.map(rS),this._parents)}function GD(e,t,n){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())),n==null?o.remove():n(o),i&&r?i.merge(r).order():r}function KD(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,o=i.length,c=Math.min(r,o),u=new Array(r),d=0;d<c;++d)for(var h=n[d],m=i[d],g=h.length,p=u[d]=new Array(g),x,y=0;y<g;++y)(x=h[y]||m[y])&&(p[y]=x);for(;d<r;++d)u[d]=n[d];return new Ps(u,this._parents)}function YD(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],r=i.length-1,o=i[r],c;--r>=0;)(c=i[r])&&(o&&c.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(c,o),o=c);return this}function XD(e){e||(e=QD);function t(g,p){return g&&p?e(g.__data__,p.__data__):!g-!p}for(var n=this._groups,i=n.length,r=new Array(i),o=0;o<i;++o){for(var c=n[o],u=c.length,d=r[o]=new Array(u),h,m=0;m<u;++m)(h=c[m])&&(d[m]=h);d.sort(t)}return new Ps(r,this._parents).order()}function QD(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function JD(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function e3(){return Array.from(this)}function t3(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,o=i.length;r<o;++r){var c=i[r];if(c)return c}return null}function n3(){let e=0;for(const t of this)++e;return e}function s3(){return!this.node()}function i3(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r=t[n],o=0,c=r.length,u;o<c;++o)(u=r[o])&&e.call(u,u.__data__,o,r);return this}function r3(e){return function(){this.removeAttribute(e)}}function a3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function o3(e,t){return function(){this.setAttribute(e,t)}}function l3(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function c3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function u3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function d3(e,t){var n=Hd(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?a3:r3:typeof t=="function"?n.local?u3:c3:n.local?l3:o3)(n,t))}function aS(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function h3(e){return function(){this.style.removeProperty(e)}}function f3(e,t,n){return function(){this.style.setProperty(e,t,n)}}function m3(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function p3(e,t,n){return arguments.length>1?this.each((t==null?h3:typeof t=="function"?m3:f3)(e,t,n??"")):Uo(this.node(),e)}function Uo(e,t){return e.style.getPropertyValue(t)||aS(e).getComputedStyle(e,null).getPropertyValue(t)}function g3(e){return function(){delete this[e]}}function x3(e,t){return function(){this[e]=t}}function v3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function y3(e,t){return arguments.length>1?this.each((t==null?g3:typeof t=="function"?v3:x3)(e,t)):this.node()[e]}function oS(e){return e.trim().split(/^|\s+/)}function Og(e){return e.classList||new lS(e)}function lS(e){this._node=e,this._names=oS(e.getAttribute("class")||"")}lS.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 cS(e,t){for(var n=Og(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function uS(e,t){for(var n=Og(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function b3(e){return function(){cS(this,e)}}function k3(e){return function(){uS(this,e)}}function N3(e,t){return function(){(t.apply(this,arguments)?cS:uS)(this,e)}}function j3(e,t){var n=oS(e+"");if(arguments.length<2){for(var i=Og(this.node()),r=-1,o=n.length;++r<o;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?N3:t?b3:k3)(n,t))}function w3(){this.textContent=""}function S3(e){return function(){this.textContent=e}}function _3(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function E3(e){return arguments.length?this.each(e==null?w3:(typeof e=="function"?_3:S3)(e)):this.node().textContent}function C3(){this.innerHTML=""}function A3(e){return function(){this.innerHTML=e}}function I3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function T3(e){return arguments.length?this.each(e==null?C3:(typeof e=="function"?I3:A3)(e)):this.node().innerHTML}function $3(){this.nextSibling&&this.parentNode.appendChild(this)}function M3(){return this.each($3)}function R3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function O3(){return this.each(R3)}function P3(e){var t=typeof e=="function"?e:tS(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function z3(){return null}function L3(e,t){var n=typeof e=="function"?e:tS(e),i=t==null?z3:typeof t=="function"?t:Rg(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function D3(){var e=this.parentNode;e&&e.removeChild(this)}function F3(){return this.each(D3)}function U3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function B3(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function H3(e){return this.select(e?B3:U3)}function Z3(e){return arguments.length?this.property("__data__",e):this.node().__data__}function W3(e){return function(t){e.call(this,t,this.__data__)}}function V3(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function q3(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,o;n<r;++n)o=t[n],(!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 G3(e,t,n){return function(){var i=this.__on,r,o=W3(t);if(i){for(var c=0,u=i.length;c<u;++c)if((r=i[c]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),r.value=t;return}}this.addEventListener(e.type,o,n),r={type:e.type,name:e.name,value:t,listener:o,options:n},i?i.push(r):this.__on=[r]}}function K3(e,t,n){var i=V3(e+""),r,o=i.length,c;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((c=i[r]).type===m.type&&c.name===m.name)return m.value}return}for(u=t?G3:q3,r=0;r<o;++r)this.each(u(i[r],t,n));return this}function dS(e,t,n){var i=aS(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Y3(e,t){return function(){return dS(this,e,t)}}function X3(e,t){return function(){return dS(this,e,t.apply(this,arguments))}}function Q3(e,t){return this.each((typeof t=="function"?X3:Y3)(e,t))}function*J3(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,o=i.length,c;r<o;++r)(c=i[r])&&(yield c)}var hS=[null];function Ps(e,t){this._groups=e,this._parents=t}function wc(){return new Ps([[document.documentElement]],hS)}function e4(){return this}Ps.prototype=wc.prototype={constructor:Ps,select:_D,selectAll:ID,selectChild:RD,selectChildren:LD,filter:DD,data:WD,enter:FD,exit:qD,join:GD,merge:KD,selection:e4,order:YD,sort:XD,call:JD,nodes:e3,node:t3,size:n3,empty:s3,each:i3,attr:d3,style:p3,property:y3,classed:j3,text:E3,html:T3,raise:M3,lower:O3,append:P3,insert:L3,remove:F3,clone:H3,datum:Z3,on:K3,dispatch:Q3,[Symbol.iterator]:J3};function Ms(e){return typeof e=="string"?new Ps([[document.querySelector(e)]],[document.documentElement]):new Ps([[e]],hS)}function t4(e){let t;for(;t=e.sourceEvent;)e=t;return e}function vi(e,t){if(e=t4(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.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 n4={passive:!1},rc={capture:!0,passive:!1};function gm(e){e.stopImmediatePropagation()}function Co(e){e.preventDefault(),e.stopImmediatePropagation()}function fS(e){var t=e.document.documentElement,n=Ms(e).on("dragstart.drag",Co,rc);"onselectstart"in t?n.on("selectstart.drag",Co,rc):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function mS(e,t){var n=e.document.documentElement,i=Ms(e).on("dragstart.drag",null);t&&(i.on("click.drag",Co,rc),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const zu=e=>()=>e;function _p(e,{sourceEvent:t,subject:n,target:i,identifier:r,active:o,x:c,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:n,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:c,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}})}_p.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function s4(e){return!e.ctrlKey&&!e.button}function i4(){return this.parentNode}function r4(e,t){return t??{x:e.x,y:e.y}}function a4(){return navigator.maxTouchPoints||"ontouchstart"in this}function pS(){var e=s4,t=i4,n=r4,i=a4,r={},o=Bd("start","drag","end"),c=0,u,d,h,m,g=0;function p(A){A.on("mousedown.drag",x).filter(i).on("touchstart.drag",N).on("touchmove.drag",k,n4).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(A,P){if(!(m||!e.call(this,A,P))){var L=j(this,t.call(this,A,P),A,P,"mouse");L&&(Ms(A.view).on("mousemove.drag",y,rc).on("mouseup.drag",S,rc),fS(A.view),gm(A),h=!1,u=A.clientX,d=A.clientY,L("start",A))}}function y(A){if(Co(A),!h){var P=A.clientX-u,L=A.clientY-d;h=P*P+L*L>g}r.mouse("drag",A)}function S(A){Ms(A.view).on("mousemove.drag mouseup.drag",null),mS(A.view,h),Co(A),r.mouse("end",A)}function N(A,P){if(e.call(this,A,P)){var L=A.changedTouches,B=t.call(this,A,P),V=L.length,M,z;for(M=0;M<V;++M)(z=j(this,B,A,P,L[M].identifier,L[M]))&&(gm(A),z("start",A,L[M]))}}function k(A){var P=A.changedTouches,L=P.length,B,V;for(B=0;B<L;++B)(V=r[P[B].identifier])&&(Co(A),V("drag",A,P[B]))}function E(A){var P=A.changedTouches,L=P.length,B,V;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),B=0;B<L;++B)(V=r[P[B].identifier])&&(gm(A),V("end",A,P[B]))}function j(A,P,L,B,V,M){var z=o.copy(),D=vi(M||L,P),U,I,T;if((T=n.call(A,new _p("beforestart",{sourceEvent:L,target:p,identifier:V,active:c,x:D[0],y:D[1],dx:0,dy:0,dispatch:z}),B))!=null)return U=T.x-D[0]||0,I=T.y-D[1]||0,function O($,F,H){var Z=D,G;switch($){case"start":r[V]=O,G=c++;break;case"end":delete r[V],--c;case"drag":D=vi(H||F,P),G=c;break}z.call($,A,new _p($,{sourceEvent:F,subject:T,target:p,identifier:V,active:G,x:D[0]+U,y:D[1]+I,dx:D[0]-Z[0],dy:D[1]-Z[1],dispatch:z}),B)}}return p.filter=function(A){return arguments.length?(e=typeof A=="function"?A:zu(!!A),p):e},p.container=function(A){return arguments.length?(t=typeof A=="function"?A:zu(A),p):t},p.subject=function(A){return arguments.length?(n=typeof A=="function"?A:zu(A),p):n},p.touchable=function(A){return arguments.length?(i=typeof A=="function"?A:zu(!!A),p):i},p.on=function(){var A=o.on.apply(o,arguments);return A===o?p:A},p.clickDistance=function(A){return arguments.length?(g=(A=+A)*A,p):Math.sqrt(g)},p}function Pg(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function gS(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function Sc(){}var ac=.7,vd=1/ac,Ao="\\s*([+-]?\\d+)\\s*",oc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Zi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",o4=/^#([0-9a-f]{3,8})$/,l4=new RegExp(`^rgb\\(${Ao},${Ao},${Ao}\\)$`),c4=new RegExp(`^rgb\\(${Zi},${Zi},${Zi}\\)$`),u4=new RegExp(`^rgba\\(${Ao},${Ao},${Ao},${oc}\\)$`),d4=new RegExp(`^rgba\\(${Zi},${Zi},${Zi},${oc}\\)$`),h4=new RegExp(`^hsl\\(${oc},${Zi},${Zi}\\)$`),f4=new RegExp(`^hsla\\(${oc},${Zi},${Zi},${oc}\\)$`),bb={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};Pg(Sc,Oa,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:kb,formatHex:kb,formatHex8:m4,formatHsl:p4,formatRgb:Nb,toString:Nb});function kb(){return this.rgb().formatHex()}function m4(){return this.rgb().formatHex8()}function p4(){return xS(this).formatHsl()}function Nb(){return this.rgb().formatRgb()}function Oa(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=o4.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?jb(t):n===3?new js(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Lu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Lu(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=l4.exec(e))?new js(t[1],t[2],t[3],1):(t=c4.exec(e))?new js(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=u4.exec(e))?Lu(t[1],t[2],t[3],t[4]):(t=d4.exec(e))?Lu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=h4.exec(e))?_b(t[1],t[2]/100,t[3]/100,1):(t=f4.exec(e))?_b(t[1],t[2]/100,t[3]/100,t[4]):bb.hasOwnProperty(e)?jb(bb[e]):e==="transparent"?new js(NaN,NaN,NaN,0):null}function jb(e){return new js(e>>16&255,e>>8&255,e&255,1)}function Lu(e,t,n,i){return i<=0&&(e=t=n=NaN),new js(e,t,n,i)}function g4(e){return e instanceof Sc||(e=Oa(e)),e?(e=e.rgb(),new js(e.r,e.g,e.b,e.opacity)):new js}function Ep(e,t,n,i){return arguments.length===1?g4(e):new js(e,t,n,i??1)}function js(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}Pg(js,Ep,gS(Sc,{brighter(e){return e=e==null?vd:Math.pow(vd,e),new js(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ac:Math.pow(ac,e),new js(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new js(Ta(this.r),Ta(this.g),Ta(this.b),yd(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:wb,formatHex:wb,formatHex8:x4,formatRgb:Sb,toString:Sb}));function wb(){return`#${_a(this.r)}${_a(this.g)}${_a(this.b)}`}function x4(){return`#${_a(this.r)}${_a(this.g)}${_a(this.b)}${_a((isNaN(this.opacity)?1:this.opacity)*255)}`}function Sb(){const e=yd(this.opacity);return`${e===1?"rgb(":"rgba("}${Ta(this.r)}, ${Ta(this.g)}, ${Ta(this.b)}${e===1?")":`, ${e})`}`}function yd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ta(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function _a(e){return e=Ta(e),(e<16?"0":"")+e.toString(16)}function _b(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ki(e,t,n,i)}function xS(e){if(e instanceof ki)return new ki(e.h,e.s,e.l,e.opacity);if(e instanceof Sc||(e=Oa(e)),!e)return new ki;if(e instanceof ki)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),o=Math.max(t,n,i),c=NaN,u=o-r,d=(o+r)/2;return u?(t===o?c=(n-i)/u+(n<i)*6:n===o?c=(i-t)/u+2:c=(t-n)/u+4,u/=d<.5?o+r:2-o-r,c*=60):u=d>0&&d<1?0:c,new ki(c,u,d,e.opacity)}function v4(e,t,n,i){return arguments.length===1?xS(e):new ki(e,t,n,i??1)}function ki(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}Pg(ki,v4,gS(Sc,{brighter(e){return e=e==null?vd:Math.pow(vd,e),new ki(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ac:Math.pow(ac,e),new ki(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new js(xm(e>=240?e-240:e+120,r,i),xm(e,r,i),xm(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new ki(Eb(this.h),Du(this.s),Du(this.l),yd(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=yd(this.opacity);return`${e===1?"hsl(":"hsla("}${Eb(this.h)}, ${Du(this.s)*100}%, ${Du(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Eb(e){return e=(e||0)%360,e<0?e+360:e}function Du(e){return Math.max(0,Math.min(1,e||0))}function xm(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const zg=e=>()=>e;function y4(e,t){return function(n){return e+n*t}}function b4(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function k4(e){return(e=+e)==1?vS:function(t,n){return n-t?b4(t,n,e):zg(isNaN(t)?n:t)}}function vS(e,t){var n=t-e;return n?y4(e,n):zg(isNaN(e)?t:e)}const bd=(function e(t){var n=k4(t);function i(r,o){var c=n((r=Ep(r)).r,(o=Ep(o)).r),u=n(r.g,o.g),d=n(r.b,o.b),h=vS(r.opacity,o.opacity);return function(m){return r.r=c(m),r.g=u(m),r.b=d(m),r.opacity=h(m),r+""}}return i.gamma=e,i})(1);function N4(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(o){for(r=0;r<n;++r)i[r]=e[r]*(1-o)+t[r]*o;return i}}function j4(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function w4(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,r=new Array(i),o=new Array(n),c;for(c=0;c<i;++c)r[c]=Xl(e[c],t[c]);for(;c<n;++c)o[c]=t[c];return function(u){for(c=0;c<i;++c)o[c]=r[c](u);return o}}function S4(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function Bi(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function _4(e,t){var n={},i={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=Xl(e[r],t[r]):i[r]=t[r];return function(o){for(r in n)i[r]=n[r](o);return i}}var Cp=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,vm=new RegExp(Cp.source,"g");function E4(e){return function(){return e}}function C4(e){return function(t){return e(t)+""}}function yS(e,t){var n=Cp.lastIndex=vm.lastIndex=0,i,r,o,c=-1,u=[],d=[];for(e=e+"",t=t+"";(i=Cp.exec(e))&&(r=vm.exec(t));)(o=r.index)>n&&(o=t.slice(n,o),u[c]?u[c]+=o:u[++c]=o),(i=i[0])===(r=r[0])?u[c]?u[c]+=r:u[++c]=r:(u[++c]=null,d.push({i:c,x:Bi(i,r)})),n=vm.lastIndex;return n<t.length&&(o=t.slice(n),u[c]?u[c]+=o:u[++c]=o),u.length<2?d[0]?C4(d[0].x):E4(t):(t=d.length,function(h){for(var m=0,g;m<t;++m)u[(g=d[m]).i]=g.x(h);return u.join("")})}function Xl(e,t){var n=typeof t,i;return t==null||n==="boolean"?zg(t):(n==="number"?Bi:n==="string"?(i=Oa(t))?(t=i,bd):yS:t instanceof Oa?bd:t instanceof Date?S4:j4(t)?N4:Array.isArray(t)?w4:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?_4:Bi)(e,t)}var Cb=180/Math.PI,Ap={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function bS(e,t,n,i,r,o){var c,u,d;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(d=e*n+t*i)&&(n-=e*d,i-=t*d),(u=Math.sqrt(n*n+i*i))&&(n/=u,i/=u,d/=u),e*i<t*n&&(e=-e,t=-t,d=-d,c=-c),{translateX:r,translateY:o,rotate:Math.atan2(t,e)*Cb,skewX:Math.atan(d)*Cb,scaleX:c,scaleY:u}}var Fu;function A4(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ap:bS(t.a,t.b,t.c,t.d,t.e,t.f)}function I4(e){return e==null||(Fu||(Fu=document.createElementNS("http://www.w3.org/2000/svg","g")),Fu.setAttribute("transform",e),!(e=Fu.transform.baseVal.consolidate()))?Ap:(e=e.matrix,bS(e.a,e.b,e.c,e.d,e.e,e.f))}function kS(e,t,n,i){function r(h){return h.length?h.pop()+" ":""}function o(h,m,g,p,x,y){if(h!==g||m!==p){var S=x.push("translate(",null,t,null,n);y.push({i:S-4,x:Bi(h,g)},{i:S-2,x:Bi(m,p)})}else(g||p)&&x.push("translate("+g+t+p+n)}function c(h,m,g,p){h!==m?(h-m>180?m+=360:m-h>180&&(h+=360),p.push({i:g.push(r(g)+"rotate(",null,i)-2,x:Bi(h,m)})):m&&g.push(r(g)+"rotate("+m+i)}function u(h,m,g,p){h!==m?p.push({i:g.push(r(g)+"skewX(",null,i)-2,x:Bi(h,m)}):m&&g.push(r(g)+"skewX("+m+i)}function d(h,m,g,p,x,y){if(h!==g||m!==p){var S=x.push(r(x)+"scale(",null,",",null,")");y.push({i:S-4,x:Bi(h,g)},{i:S-2,x:Bi(m,p)})}else(g!==1||p!==1)&&x.push(r(x)+"scale("+g+","+p+")")}return function(h,m){var g=[],p=[];return h=e(h),m=e(m),o(h.translateX,h.translateY,m.translateX,m.translateY,g,p),c(h.rotate,m.rotate,g,p),u(h.skewX,m.skewX,g,p),d(h.scaleX,h.scaleY,m.scaleX,m.scaleY,g,p),h=m=null,function(x){for(var y=-1,S=p.length,N;++y<S;)g[(N=p[y]).i]=N.x(x);return g.join("")}}}var T4=kS(A4,"px, ","px)","deg)"),$4=kS(I4,", ",")",")"),M4=1e-12;function Ab(e){return((e=Math.exp(e))+1/e)/2}function R4(e){return((e=Math.exp(e))-1/e)/2}function O4(e){return((e=Math.exp(2*e))-1)/(e+1)}const ed=(function e(t,n,i){function r(o,c){var u=o[0],d=o[1],h=o[2],m=c[0],g=c[1],p=c[2],x=m-u,y=g-d,S=x*x+y*y,N,k;if(S<M4)k=Math.log(p/h)/t,N=function(B){return[u+B*x,d+B*y,h*Math.exp(t*B*k)]};else{var E=Math.sqrt(S),j=(p*p-h*h+i*S)/(2*h*n*E),A=(p*p-h*h-i*S)/(2*p*n*E),P=Math.log(Math.sqrt(j*j+1)-j),L=Math.log(Math.sqrt(A*A+1)-A);k=(L-P)/t,N=function(B){var V=B*k,M=Ab(P),z=h/(n*E)*(M*O4(t*V+P)-R4(P));return[u+z*x,d+z*y,h*M/Ab(t*V+P)]}}return N.duration=k*1e3*t/Math.SQRT2,N}return r.rho=function(o){var c=Math.max(.001,+o),u=c*c,d=u*u;return e(c,u,d)},r})(Math.SQRT2,2,4);var Bo=0,Hl=0,Rl=0,NS=1e3,kd,Zl,Nd=0,Pa=0,Zd=0,lc=typeof performance=="object"&&performance.now?performance:Date,jS=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Lg(){return Pa||(jS(P4),Pa=lc.now()+Zd)}function P4(){Pa=0}function jd(){this._call=this._time=this._next=null}jd.prototype=wS.prototype={constructor:jd,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Lg():+n)+(t==null?0:+t),!this._next&&Zl!==this&&(Zl?Zl._next=this:kd=this,Zl=this),this._call=e,this._time=n,Ip()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ip())}};function wS(e,t,n){var i=new jd;return i.restart(e,t,n),i}function z4(){Lg(),++Bo;for(var e=kd,t;e;)(t=Pa-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Bo}function Ib(){Pa=(Nd=lc.now())+Zd,Bo=Hl=0;try{z4()}finally{Bo=0,D4(),Pa=0}}function L4(){var e=lc.now(),t=e-Nd;t>NS&&(Zd-=t,Nd=e)}function D4(){for(var e,t=kd,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:kd=n);Zl=e,Ip(i)}function Ip(e){if(!Bo){Hl&&(Hl=clearTimeout(Hl));var t=e-Pa;t>24?(e<1/0&&(Hl=setTimeout(Ib,e-lc.now()-Zd)),Rl&&(Rl=clearInterval(Rl))):(Rl||(Nd=lc.now(),Rl=setInterval(L4,NS)),Bo=1,jS(Ib))}}function Tb(e,t,n){var i=new jd;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var F4=Bd("start","end","cancel","interrupt"),U4=[],SS=0,$b=1,Tp=2,td=3,Mb=4,$p=5,nd=6;function Wd(e,t,n,i,r,o){var c=e.__transition;if(!c)e.__transition={};else if(n in c)return;B4(e,n,{name:t,index:i,group:r,on:F4,tween:U4,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:SS})}function Dg(e,t){var n=Ci(e,t);if(n.state>SS)throw new Error("too late; already scheduled");return n}function Wi(e,t){var n=Ci(e,t);if(n.state>td)throw new Error("too late; already running");return n}function Ci(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function B4(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=wS(o,0,n.time);function o(h){n.state=$b,n.timer.restart(c,n.delay,n.time),n.delay<=h&&c(h-n.delay)}function c(h){var m,g,p,x;if(n.state!==$b)return d();for(m in i)if(x=i[m],x.name===n.name){if(x.state===td)return Tb(c);x.state===Mb?(x.state=nd,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete i[m]):+m<t&&(x.state=nd,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete i[m])}if(Tb(function(){n.state===td&&(n.state=Mb,n.timer.restart(u,n.delay,n.time),u(h))}),n.state=Tp,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Tp){for(n.state=td,r=new Array(p=n.tween.length),m=0,g=-1;m<p;++m)(x=n.tween[m].value.call(e,e.__data__,n.index,n.group))&&(r[++g]=x);r.length=g+1}}function u(h){for(var m=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(d),n.state=$p,1),g=-1,p=r.length;++g<p;)r[g].call(e,m);n.state===$p&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=nd,n.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function sd(e,t){var n=e.__transition,i,r,o=!0,c;if(n){t=t==null?null:t+"";for(c in n){if((i=n[c]).name!==t){o=!1;continue}r=i.state>Tp&&i.state<$p,i.state=nd,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[c]}o&&delete e.__transition}}function H4(e){return this.each(function(){sd(this,e)})}function Z4(e,t){var n,i;return function(){var r=Wi(this,e),o=r.tween;if(o!==n){i=n=o;for(var c=0,u=i.length;c<u;++c)if(i[c].name===t){i=i.slice(),i.splice(c,1);break}}r.tween=i}}function W4(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var o=Wi(this,e),c=o.tween;if(c!==i){r=(i=c).slice();for(var u={name:t,value:n},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 V4(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=Ci(this.node(),n).tween,r=0,o=i.length,c;r<o;++r)if((c=i[r]).name===e)return c.value;return null}return this.each((t==null?Z4:W4)(n,e,t))}function Fg(e,t,n){var i=e._id;return e.each(function(){var r=Wi(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Ci(r,i).value[t]}}function _S(e,t){var n;return(typeof t=="number"?Bi:t instanceof Oa?bd:(n=Oa(t))?(t=n,bd):yS)(e,t)}function q4(e){return function(){this.removeAttribute(e)}}function G4(e){return function(){this.removeAttributeNS(e.space,e.local)}}function K4(e,t,n){var i,r=n+"",o;return function(){var c=this.getAttribute(e);return c===r?null:c===i?o:o=t(i=c,n)}}function Y4(e,t,n){var i,r=n+"",o;return function(){var c=this.getAttributeNS(e.space,e.local);return c===r?null:c===i?o:o=t(i=c,n)}}function X4(e,t,n){var i,r,o;return function(){var c,u=n(this),d;return u==null?void this.removeAttribute(e):(c=this.getAttribute(e),d=u+"",c===d?null:c===i&&d===r?o:(r=d,o=t(i=c,u)))}}function Q4(e,t,n){var i,r,o;return function(){var c,u=n(this),d;return u==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),d=u+"",c===d?null:c===i&&d===r?o:(r=d,o=t(i=c,u)))}}function J4(e,t){var n=Hd(e),i=n==="transform"?$4:_S;return this.attrTween(e,typeof t=="function"?(n.local?Q4:X4)(n,i,Fg(this,"attr."+e,t)):t==null?(n.local?G4:q4)(n):(n.local?Y4:K4)(n,i,t))}function eF(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function tF(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function nF(e,t){var n,i;function r(){var o=t.apply(this,arguments);return o!==i&&(n=(i=o)&&tF(e,o)),n}return r._value=t,r}function sF(e,t){var n,i;function r(){var o=t.apply(this,arguments);return o!==i&&(n=(i=o)&&eF(e,o)),n}return r._value=t,r}function iF(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var i=Hd(e);return this.tween(n,(i.local?nF:sF)(i,t))}function rF(e,t){return function(){Dg(this,e).delay=+t.apply(this,arguments)}}function aF(e,t){return t=+t,function(){Dg(this,e).delay=t}}function oF(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?rF:aF)(t,e)):Ci(this.node(),t).delay}function lF(e,t){return function(){Wi(this,e).duration=+t.apply(this,arguments)}}function cF(e,t){return t=+t,function(){Wi(this,e).duration=t}}function uF(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?lF:cF)(t,e)):Ci(this.node(),t).duration}function dF(e,t){if(typeof t!="function")throw new Error;return function(){Wi(this,e).ease=t}}function hF(e){var t=this._id;return arguments.length?this.each(dF(t,e)):Ci(this.node(),t).ease}function fF(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Wi(this,e).ease=n}}function mF(e){if(typeof e!="function")throw new Error;return this.each(fF(this._id,e))}function pF(e){typeof e!="function"&&(e=sS(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o=t[r],c=o.length,u=i[r]=[],d,h=0;h<c;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new pr(i,this._parents,this._name,this._id)}function gF(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,o=Math.min(i,r),c=new Array(i),u=0;u<o;++u)for(var d=t[u],h=n[u],m=d.length,g=c[u]=new Array(m),p,x=0;x<m;++x)(p=d[x]||h[x])&&(g[x]=p);for(;u<i;++u)c[u]=t[u];return new pr(c,this._parents,this._name,this._id)}function xF(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function vF(e,t,n){var i,r,o=xF(t)?Dg:Wi;return function(){var c=o(this,e),u=c.on;u!==i&&(r=(i=u).copy()).on(t,n),c.on=r}}function yF(e,t){var n=this._id;return arguments.length<2?Ci(this.node(),n).on.on(e):this.each(vF(n,e,t))}function bF(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function kF(){return this.on("end.remove",bF(this._id))}function NF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Rg(e));for(var i=this._groups,r=i.length,o=new Array(r),c=0;c<r;++c)for(var u=i[c],d=u.length,h=o[c]=new Array(d),m,g,p=0;p<d;++p)(m=u[p])&&(g=e.call(m,m.__data__,p,u))&&("__data__"in m&&(g.__data__=m.__data__),h[p]=g,Wd(h[p],t,n,p,h,Ci(m,n)));return new pr(o,this._parents,t,n)}function jF(e){var t=this._name,n=this._id;typeof e!="function"&&(e=nS(e));for(var i=this._groups,r=i.length,o=[],c=[],u=0;u<r;++u)for(var d=i[u],h=d.length,m,g=0;g<h;++g)if(m=d[g]){for(var p=e.call(m,m.__data__,g,d),x,y=Ci(m,n),S=0,N=p.length;S<N;++S)(x=p[S])&&Wd(x,t,n,S,p,y);o.push(p),c.push(m)}return new pr(o,c,t,n)}var wF=wc.prototype.constructor;function SF(){return new wF(this._groups,this._parents)}function _F(e,t){var n,i,r;return function(){var o=Uo(this,e),c=(this.style.removeProperty(e),Uo(this,e));return o===c?null:o===n&&c===i?r:r=t(n=o,i=c)}}function ES(e){return function(){this.style.removeProperty(e)}}function EF(e,t,n){var i,r=n+"",o;return function(){var c=Uo(this,e);return c===r?null:c===i?o:o=t(i=c,n)}}function CF(e,t,n){var i,r,o;return function(){var c=Uo(this,e),u=n(this),d=u+"";return u==null&&(d=u=(this.style.removeProperty(e),Uo(this,e))),c===d?null:c===i&&d===r?o:(r=d,o=t(i=c,u))}}function AF(e,t){var n,i,r,o="style."+t,c="end."+o,u;return function(){var d=Wi(this,e),h=d.on,m=d.value[o]==null?u||(u=ES(t)):void 0;(h!==n||r!==m)&&(i=(n=h).copy()).on(c,r=m),d.on=i}}function IF(e,t,n){var i=(e+="")=="transform"?T4:_S;return t==null?this.styleTween(e,_F(e,i)).on("end.style."+e,ES(e)):typeof t=="function"?this.styleTween(e,CF(e,i,Fg(this,"style."+e,t))).each(AF(this._id,e)):this.styleTween(e,EF(e,i,t),n).on("end.style."+e,null)}function TF(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function $F(e,t,n){var i,r;function o(){var c=t.apply(this,arguments);return c!==r&&(i=(r=c)&&TF(e,c,n)),i}return o._value=t,o}function MF(e,t,n){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,$F(e,t,n??""))}function RF(e){return function(){this.textContent=e}}function OF(e){return function(){var t=e(this);this.textContent=t??""}}function PF(e){return this.tween("text",typeof e=="function"?OF(Fg(this,"text",e)):RF(e==null?"":e+""))}function zF(e){return function(t){this.textContent=e.call(this,t)}}function LF(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&zF(r)),t}return i._value=e,i}function DF(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,LF(e))}function FF(){for(var e=this._name,t=this._id,n=CS(),i=this._groups,r=i.length,o=0;o<r;++o)for(var c=i[o],u=c.length,d,h=0;h<u;++h)if(d=c[h]){var m=Ci(d,t);Wd(d,e,n,h,c,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new pr(i,this._parents,e,n)}function UF(){var e,t,n=this,i=n._id,r=n.size();return new Promise(function(o,c){var u={value:c},d={value:function(){--r===0&&o()}};n.each(function(){var h=Wi(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 BF=0;function pr(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function CS(){return++BF}var cr=wc.prototype;pr.prototype={constructor:pr,select:NF,selectAll:jF,selectChild:cr.selectChild,selectChildren:cr.selectChildren,filter:pF,merge:gF,selection:SF,transition:FF,call:cr.call,nodes:cr.nodes,node:cr.node,size:cr.size,empty:cr.empty,each:cr.each,on:yF,attr:J4,attrTween:iF,style:IF,styleTween:MF,text:PF,textTween:DF,remove:kF,tween:V4,delay:oF,duration:uF,ease:hF,easeVarying:mF,end:UF,[Symbol.iterator]:cr[Symbol.iterator]};function HF(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ZF={time:null,delay:0,duration:250,ease:HF};function WF(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function VF(e){var t,n;e instanceof pr?(t=e._id,e=e._name):(t=CS(),(n=ZF).time=Lg(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,o=0;o<r;++o)for(var c=i[o],u=c.length,d,h=0;h<u;++h)(d=c[h])&&Wd(d,e,t,h,c,n||WF(d,t));return new pr(i,this._parents,e,t)}wc.prototype.interrupt=H4;wc.prototype.transition=VF;const Uu=e=>()=>e;function qF(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function hr(e,t,n){this.k=e,this.x=t,this.y=n}hr.prototype={constructor:hr,scale:function(e){return e===1?this:new hr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new hr(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 Vd=new hr(1,0,0);AS.prototype=hr.prototype;function AS(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Vd;return e.__zoom}function ym(e){e.stopImmediatePropagation()}function Ol(e){e.preventDefault(),e.stopImmediatePropagation()}function GF(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function KF(){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 Rb(){return this.__zoom||Vd}function YF(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function XF(){return navigator.maxTouchPoints||"ontouchstart"in this}function QF(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],c=e.invertY(t[1][1])-n[1][1];return e.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),c>o?(o+c)/2:Math.min(0,o)||Math.max(0,c))}function IS(){var e=GF,t=KF,n=QF,i=YF,r=XF,o=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,d=ed,h=Bd("start","zoom","end"),m,g,p,x=500,y=150,S=0,N=10;function k(T){T.property("__zoom",Rb).on("wheel.zoom",V,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",z).filter(r).on("touchstart.zoom",D).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",I).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}k.transform=function(T,O,$,F){var H=T.selection?T.selection():T;H.property("__zoom",Rb),T!==H?P(T,O,$,F):H.interrupt().each(function(){L(this,arguments).event(F).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},k.scaleBy=function(T,O,$,F){k.scaleTo(T,function(){var H=this.__zoom.k,Z=typeof O=="function"?O.apply(this,arguments):O;return H*Z},$,F)},k.scaleTo=function(T,O,$,F){k.transform(T,function(){var H=t.apply(this,arguments),Z=this.__zoom,G=$==null?A(H):typeof $=="function"?$.apply(this,arguments):$,q=Z.invert(G),X=typeof O=="function"?O.apply(this,arguments):O;return n(j(E(Z,X),G,q),H,c)},$,F)},k.translateBy=function(T,O,$,F){k.transform(T,function(){return n(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof $=="function"?$.apply(this,arguments):$),t.apply(this,arguments),c)},null,F)},k.translateTo=function(T,O,$,F,H){k.transform(T,function(){var Z=t.apply(this,arguments),G=this.__zoom,q=F==null?A(Z):typeof F=="function"?F.apply(this,arguments):F;return n(Vd.translate(q[0],q[1]).scale(G.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof $=="function"?-$.apply(this,arguments):-$),Z,c)},F,H)};function E(T,O){return O=Math.max(o[0],Math.min(o[1],O)),O===T.k?T:new hr(O,T.x,T.y)}function j(T,O,$){var F=O[0]-$[0]*T.k,H=O[1]-$[1]*T.k;return F===T.x&&H===T.y?T:new hr(T.k,F,H)}function A(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function P(T,O,$,F){T.on("start.zoom",function(){L(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){L(this,arguments).event(F).end()}).tween("zoom",function(){var H=this,Z=arguments,G=L(H,Z).event(F),q=t.apply(H,Z),X=$==null?A(q):typeof $=="function"?$.apply(H,Z):$,Y=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),re=H.__zoom,ee=typeof O=="function"?O.apply(H,Z):O,se=d(re.invert(X).concat(Y/re.k),ee.invert(X).concat(Y/ee.k));return function(ne){if(ne===1)ne=ee;else{var ie=se(ne),pe=Y/ie[2];ne=new hr(pe,X[0]-ie[0]*pe,X[1]-ie[1]*pe)}G.zoom(null,ne)}})}function L(T,O,$){return!$&&T.__zooming||new B(T,O)}function B(T,O){this.that=T,this.args=O,this.active=0,this.sourceEvent=null,this.extent=t.apply(T,O),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,O){return this.mouse&&T!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var O=Ms(this.that).datum();h.call(T,this.that,new qF(T,{sourceEvent:this.sourceEvent,target:k,transform:this.that.__zoom,dispatch:h}),O)}};function V(T,...O){if(!e.apply(this,arguments))return;var $=L(this,O).event(T),F=this.__zoom,H=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,i.apply(this,arguments)))),Z=vi(T);if($.wheel)($.mouse[0][0]!==Z[0]||$.mouse[0][1]!==Z[1])&&($.mouse[1]=F.invert($.mouse[0]=Z)),clearTimeout($.wheel);else{if(F.k===H)return;$.mouse=[Z,F.invert(Z)],sd(this),$.start()}Ol(T),$.wheel=setTimeout(G,y),$.zoom("mouse",n(j(E(F,H),$.mouse[0],$.mouse[1]),$.extent,c));function G(){$.wheel=null,$.end()}}function M(T,...O){if(p||!e.apply(this,arguments))return;var $=T.currentTarget,F=L(this,O,!0).event(T),H=Ms(T.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",Y,!0),Z=vi(T,$),G=T.clientX,q=T.clientY;fS(T.view),ym(T),F.mouse=[Z,this.__zoom.invert(Z)],sd(this),F.start();function X(re){if(Ol(re),!F.moved){var ee=re.clientX-G,se=re.clientY-q;F.moved=ee*ee+se*se>S}F.event(re).zoom("mouse",n(j(F.that.__zoom,F.mouse[0]=vi(re,$),F.mouse[1]),F.extent,c))}function Y(re){H.on("mousemove.zoom mouseup.zoom",null),mS(re.view,F.moved),Ol(re),F.event(re).end()}}function z(T,...O){if(e.apply(this,arguments)){var $=this.__zoom,F=vi(T.changedTouches?T.changedTouches[0]:T,this),H=$.invert(F),Z=$.k*(T.shiftKey?.5:2),G=n(j(E($,Z),F,H),t.apply(this,O),c);Ol(T),u>0?Ms(this).transition().duration(u).call(P,G,F,T):Ms(this).call(k.transform,G,F,T)}}function D(T,...O){if(e.apply(this,arguments)){var $=T.touches,F=$.length,H=L(this,O,T.changedTouches.length===F).event(T),Z,G,q,X;for(ym(T),G=0;G<F;++G)q=$[G],X=vi(q,this),X=[X,this.__zoom.invert(X),q.identifier],H.touch0?!H.touch1&&H.touch0[2]!==X[2]&&(H.touch1=X,H.taps=0):(H.touch0=X,Z=!0,H.taps=1+!!m);m&&(m=clearTimeout(m)),Z&&(H.taps<2&&(g=X[0],m=setTimeout(function(){m=null},x)),sd(this),H.start())}}function U(T,...O){if(this.__zooming){var $=L(this,O).event(T),F=T.changedTouches,H=F.length,Z,G,q,X;for(Ol(T),Z=0;Z<H;++Z)G=F[Z],q=vi(G,this),$.touch0&&$.touch0[2]===G.identifier?$.touch0[0]=q:$.touch1&&$.touch1[2]===G.identifier&&($.touch1[0]=q);if(G=$.that.__zoom,$.touch1){var Y=$.touch0[0],re=$.touch0[1],ee=$.touch1[0],se=$.touch1[1],ne=(ne=ee[0]-Y[0])*ne+(ne=ee[1]-Y[1])*ne,ie=(ie=se[0]-re[0])*ie+(ie=se[1]-re[1])*ie;G=E(G,Math.sqrt(ne/ie)),q=[(Y[0]+ee[0])/2,(Y[1]+ee[1])/2],X=[(re[0]+se[0])/2,(re[1]+se[1])/2]}else if($.touch0)q=$.touch0[0],X=$.touch0[1];else return;$.zoom("touch",n(j(G,q,X),$.extent,c))}}function I(T,...O){if(this.__zooming){var $=L(this,O).event(T),F=T.changedTouches,H=F.length,Z,G;for(ym(T),p&&clearTimeout(p),p=setTimeout(function(){p=null},x),Z=0;Z<H;++Z)G=F[Z],$.touch0&&$.touch0[2]===G.identifier?delete $.touch0:$.touch1&&$.touch1[2]===G.identifier&&delete $.touch1;if($.touch1&&!$.touch0&&($.touch0=$.touch1,delete $.touch1),$.touch0)$.touch0[1]=this.__zoom.invert($.touch0[0]);else if($.end(),$.taps===2&&(G=vi(G,this),Math.hypot(g[0]-G[0],g[1]-G[1])<N)){var q=Ms(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return k.wheelDelta=function(T){return arguments.length?(i=typeof T=="function"?T:Uu(+T),k):i},k.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Uu(!!T),k):e},k.touchable=function(T){return arguments.length?(r=typeof T=="function"?T:Uu(!!T),k):r},k.extent=function(T){return arguments.length?(t=typeof T=="function"?T:Uu([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),k):t},k.scaleExtent=function(T){return arguments.length?(o[0]=+T[0],o[1]=+T[1],k):[o[0],o[1]]},k.translateExtent=function(T){return arguments.length?(c[0][0]=+T[0][0],c[1][0]=+T[1][0],c[0][1]=+T[0][1],c[1][1]=+T[1][1],k):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},k.constrain=function(T){return arguments.length?(n=T,k):n},k.duration=function(T){return arguments.length?(u=+T,k):u},k.interpolate=function(T){return arguments.length?(d=T,k):d},k.on=function(){var T=h.on.apply(h,arguments);return T===h?k:T},k.clickDistance=function(T){return arguments.length?(S=(T=+T)*T,k):Math.sqrt(S)},k.tapDistance=function(T){return arguments.length?(N=+T,k):N},k}const _i={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n: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.`},cc=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],TS=["Enter"," ","Escape"],$S={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Ho;(function(e){e.Strict="strict",e.Loose="loose"})(Ho||(Ho={}));var $a;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})($a||($a={}));var uc;(function(e){e.Partial="partial",e.Full="full"})(uc||(uc={}));const MS={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Br;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Br||(Br={}));var wd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(wd||(wd={}));var Je;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Je||(Je={}));const Ob={[Je.Left]:Je.Right,[Je.Right]:Je.Left,[Je.Top]:Je.Bottom,[Je.Bottom]:Je.Top},RS=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,JF=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Ug=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),_c=(e,t=[0,0])=>{const{width:n,height:i}=Ai(e),r=e.origin??t,o=n*r[0],c=i*r[1];return{x:e.position.x-o,y:e.position.y-c}},eU=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const i=e.reduce((r,o)=>{const c=typeof o=="string";let u=!t.nodeLookup&&!c?o:void 0;return t.nodeLookup&&(u=c?t.nodeLookup.get(o):Ug(o)?o:t.nodeLookup.get(o.id)),u?(n=!0,qd(r,Sd(u,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Gd(i):{x:0,y:0,width:0,height:0}},Ec=(e,t={})=>{let n={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))&&(n=qd(n,Sd(r)),i=!0)}),i?Gd(n):{x:0,y:0,width:0,height:0}},Bg=(e,t,[n,i,r]=[0,0,1],o=!1,c=!1)=>{const u=(t.x-n)/r,d=(t.y-i)/r,h=t.width/r,m=t.height/r,g=[];for(const p of e.values()){const{measured:x,selectable:y=!0,hidden:S=!1}=p;if(c&&!y||S)continue;const N=x.width??p.width??p.initialWidth??0,k=x.height??p.height??p.initialHeight??0,{x:E,y:j}=p.internals.positionAbsolute,A=LS(u,d,h,m,E,j,N,k),P=N*k,L=o&&A>0;(!p.internals.handleBounds||L||A>=P||p.dragging)&&g.push(p)}return g},tU=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function nU(e,t){const n=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:c,height:u}=Ai(r);o=c>0&&u>0}else o=!!(r.measured.width&&r.measured.height&&!r.hidden);o&&(!i||i.has(r.id))&&n.set(r.id,r)}),n}async function sU({nodes:e,width:t,height:n,panZoom:i,minZoom:r,maxZoom:o},c){if(e.size===0)return!0;const u=nU(e,c),d=Ec(u),h=Zg(d,t,n,(c==null?void 0:c.minZoom)??r,(c==null?void 0:c.maxZoom)??o,(c==null?void 0:c.padding)??.1);return await i.setViewport(h,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function OS({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:r,onError:o}){const c=n.get(e),u=c.parentId?n.get(c.parentId):void 0,{x:d,y:h}=u?u.internals.positionAbsolute:{x:0,y:0},m=c.origin??i;let g=c.extent||r;if(c.extent==="parent"&&!c.expandParent)if(!u)o==null||o("005",_i.error005());else{const{width:x,height:y}=Ai(u);x&&y&&(g=[[d,h],[d+x,h+y]])}else u&&La(c.extent)&&(g=[[c.extent[0][0]+d,c.extent[0][1]+h],[c.extent[1][0]+d,c.extent[1][1]+h]]);const p=La(g)?za(t,g,c.measured):t;return(c.measured.width===void 0||c.measured.height===void 0)&&(o==null||o("015",_i.error015())),{position:{x:p.x-d+(c.measured.width??0)*m[0],y:p.y-h+(c.measured.height??0)*m[1]},positionAbsolute:p}}async function iU({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:r}){const o=new Set(e.map(p=>p.id)),c=[];for(const p of n){if(p.deletable===!1)continue;const x=o.has(p.id),y=!x&&p.parentId&&c.find(S=>S.id===p.parentId);(x||y)&&c.push(p)}const u=new Set(t.map(p=>p.id)),d=i.filter(p=>p.deletable!==!1),m=tU(c,d);for(const p of d)u.has(p.id)&&!m.find(y=>y.id===p.id)&&m.push(p);if(!r)return{edges:m,nodes:c};const g=await r({nodes:c,edges:m});return typeof g=="boolean"?g?{edges:m,nodes:c}:{edges:[],nodes:[]}:g}const Zo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),za=(e={x:0,y:0},t,n)=>({x:Zo(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Zo(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function PS(e,t,n){const{width:i,height:r}=Ai(n),{x:o,y:c}=n.internals.positionAbsolute;return za(e,[[o,c],[o+i,c+r]],t)}const Pb=(e,t,n)=>e<t?Zo(Math.abs(e-t),1,t)/t:e>n?-Zo(Math.abs(e-n),1,t)/t:0,Hg=(e,t,n=15,i=40)=>{const r=Pb(e.x,i,t.width-i)*n,o=Pb(e.y,i,t.height-i)*n;return[r,o]},qd=(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)}),Mp=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),Gd=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),dc=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=Ug(e)?e.internals.positionAbsolute:_c(e,t);return{x:n,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}},Sd=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=Ug(e)?e.internals.positionAbsolute:_c(e,t);return{x:n,y:i,x2:n+(((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)}},zS=(e,t)=>Gd(qd(Mp(e),Mp(t))),LS=(e,t,n,i,r,o,c,u)=>{const d=Math.max(0,Math.min(e+n,r+c)-Math.max(e,r)),h=Math.max(0,Math.min(t+i,o+u)-Math.max(t,o));return Math.ceil(d*h)},_d=(e,t)=>LS(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),zb=e=>Ni(e.width)&&Ni(e.height)&&Ni(e.x)&&Ni(e.y),Ni=e=>!isNaN(e)&&isFinite(e),DS=(e,t)=>(n,i)=>{},Cc=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ac=({x:e,y:t},[n,i,r],o=!1,c=[1,1])=>{const u={x:(e-n)/r,y:(t-i)/r};return o?Cc(u,c):u},Wo=({x:e,y:t},[n,i,r])=>({x:e*r+n,y:t*r+i});function po(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function rU(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=po(e,n),r=po(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=po(e.top??e.y??0,n),r=po(e.bottom??e.y??0,n),o=po(e.left??e.x??0,t),c=po(e.right??e.x??0,t);return{top:i,right:c,bottom:r,left:o,x:o+c,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function aU(e,t,n,i,r,o){const{x:c,y:u}=Wo(e,[t,n,i]),{x:d,y:h}=Wo({x:e.x+e.width,y:e.y+e.height},[t,n,i]),m=r-d,g=o-h;return{left:Math.floor(c),top:Math.floor(u),right:Math.floor(m),bottom:Math.floor(g)}}const Zg=(e,t,n,i,r,o)=>{const c=rU(o,t,n),u=(t-c.x)/e.width,d=(n-c.y)/e.height,h=Math.min(u,d),m=Zo(h,i,r),g=e.x+e.width/2,p=e.y+e.height/2,x=t/2-g*m,y=n/2-p*m,S=aU(e,x,y,m,t,n),N={left:Math.min(S.left-c.left,0),top:Math.min(S.top-c.top,0),right:Math.min(S.right-c.right,0),bottom:Math.min(S.bottom-c.bottom,0)};return{x:x-N.left+N.right,y:y-N.top+N.bottom,zoom:m}},hc=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function La(e){return e!=null&&e!=="parent"}function Ai(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function FS(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function US(e,t={width:0,height:0},n,i,r){const o={...e},c=i.get(n);if(c){const u=c.origin||r;o.x+=c.internals.positionAbsolute.x-(t.width??0)*u[0],o.y+=c.internals.positionAbsolute.y-(t.height??0)*u[1]}return o}function Lb(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function oU(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function lU(e){return{...$S,...e||{}}}function BS(e){return e===null?null:e?"valid":"invalid"}function Ql(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:r}){const{x:o,y:c}=ji(e),u=Ac({x:o-((r==null?void 0:r.left)??0),y:c-((r==null?void 0:r.top)??0)},i),{x:d,y:h}=n?Cc(u,t):u;return{xSnapped:d,ySnapped:h,...u}}const Wg=e=>({width:e.offsetWidth,height:e.offsetHeight}),HS=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},cU=["INPUT","SELECT","TEXTAREA"];function ZS(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:cU.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const WS=e=>"clientX"in e,ji=(e,t)=>{var o,c;const n=WS(e),i=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,r=n?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},Db=(e,t,n,i,r)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(c=>{const u=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:r,position:c.getAttribute("data-handlepos"),x:(u.left-n.left)/i,y:(u.top-n.top)/i,...Wg(c)}})};function VS({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:r,sourceControlY:o,targetControlX:c,targetControlY:u}){const d=e*.125+r*.375+c*.375+n*.125,h=t*.125+o*.375+u*.375+i*.125,m=Math.abs(d-e),g=Math.abs(h-t);return[d,h,m,g]}function Bu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Fb({pos:e,x1:t,y1:n,x2:i,y2:r,c:o}){switch(e){case Je.Left:return[t-Bu(t-i,o),n];case Je.Right:return[t+Bu(i-t,o),n];case Je.Top:return[t,n-Bu(n-r,o)];case Je.Bottom:return[t,n+Bu(r-n,o)]}}function qS({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:r,targetPosition:o=Je.Top,curvature:c=.25}){const[u,d]=Fb({pos:n,x1:e,y1:t,x2:i,y2:r,c}),[h,m]=Fb({pos:o,x1:i,y1:r,x2:e,y2:t,c}),[g,p,x,y]=VS({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}`,g,p,x,y]}function GS({sourceX:e,sourceY:t,targetX:n,targetY:i}){const r=Math.abs(n-e)/2,o=n<e?n+r:n-r,c=Math.abs(i-t)/2,u=i<t?i+c:i-c;return[o,u,r,c]}function uU({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:r=!1,zIndexMode:o="basic"}){if(o==="manual")return i;const c=r&&n?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 c+u}function dU({sourceNode:e,targetNode:t,width:n,height:i,transform:r}){const o=qd(Sd(e),Sd(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const c={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:i/r[2]};return _d(c,Gd(o))>0}const hU=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,fU=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),mU=(e,t,n={})=>{var o;if(!e.source||!e.target)return(o=n.onError)==null||o.call(n,"006",_i.error006()),t;const i=n.getEdgeId||hU;let r;return RS(e)?r={...e}:r={...e,id:i(e)},fU(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function KS({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[r,o,c,u]=GS({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,r,o,c,u]}const Ub={[Je.Left]:{x:-1,y:0},[Je.Right]:{x:1,y:0},[Je.Top]:{x:0,y:-1},[Je.Bottom]:{x:0,y:1}},pU=({source:e,sourcePosition:t=Je.Bottom,target:n})=>t===Je.Left||t===Je.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Bb=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function gU({source:e,sourcePosition:t=Je.Bottom,target:n,targetPosition:i=Je.Top,center:r,offset:o,stepPosition:c}){const u=Ub[t],d=Ub[i],h={x:e.x+u.x*o,y:e.y+u.y*o},m={x:n.x+d.x*o,y:n.y+d.y*o},g=pU({source:h,sourcePosition:t,target:m}),p=g.x!==0?"x":"y",x=g[p];let y=[],S,N;const k={x:0,y:0},E={x:0,y:0},[,,j,A]=GS({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(u[p]*d[p]===-1){p==="x"?(S=r.x??h.x+(m.x-h.x)*c,N=r.y??(h.y+m.y)/2):(S=r.x??(h.x+m.x)/2,N=r.y??h.y+(m.y-h.y)*c);const V=[{x:S,y:h.y},{x:S,y:m.y}],M=[{x:h.x,y:N},{x:m.x,y:N}];u[p]===x?y=p==="x"?V:M:y=p==="x"?M:V}else{const V=[{x:h.x,y:m.y}],M=[{x:m.x,y:h.y}];if(p==="x"?y=u.x===x?M:V:y=u.y===x?V:M,t===i){const T=Math.abs(e[p]-n[p]);if(T<=o){const O=Math.min(o-1,o-T);u[p]===x?k[p]=(h[p]>e[p]?-1:1)*O:E[p]=(m[p]>n[p]?-1:1)*O}}if(t!==i){const T=p==="x"?"y":"x",O=u[p]===d[T],$=h[T]>m[T],F=h[T]<m[T];(u[p]===1&&(!O&&$||O&&F)||u[p]!==1&&(!O&&F||O&&$))&&(y=p==="x"?V:M)}const z={x:h.x+k.x,y:h.y+k.y},D={x:m.x+E.x,y:m.y+E.y},U=Math.max(Math.abs(z.x-y[0].x),Math.abs(D.x-y[0].x)),I=Math.max(Math.abs(z.y-y[0].y),Math.abs(D.y-y[0].y));U>=I?(S=(z.x+D.x)/2,N=y[0].y):(S=y[0].x,N=(z.y+D.y)/2)}const P={x:h.x+k.x,y:h.y+k.y},L={x:m.x+E.x,y:m.y+E.y};return[[e,...P.x!==y[0].x||P.y!==y[0].y?[P]:[],...y,...L.x!==y[y.length-1].x||L.y!==y[y.length-1].y?[L]:[],n],S,N,j,A]}function xU(e,t,n,i){const r=Math.min(Bb(e,t)/2,Bb(t,n)/2,i),{x:o,y:c}=t;if(e.x===o&&o===n.x||e.y===c&&c===n.y)return`L${o} ${c}`;if(e.y===c){const h=e.x<n.x?-1:1,m=e.y<n.y?1:-1;return`L ${o+r*h},${c}Q ${o},${c} ${o},${c+r*m}`}const u=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${c+r*d}Q ${o},${c} ${o+r*u},${c}`}function Rp({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:r,targetPosition:o=Je.Top,borderRadius:c=5,centerX:u,centerY:d,offset:h=20,stepPosition:m=.5}){const[g,p,x,y,S]=gU({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:r},targetPosition:o,center:{x:u,y:d},offset:h,stepPosition:m});let N=`M${g[0].x} ${g[0].y}`;for(let k=1;k<g.length-1;k++)N+=xU(g[k-1],g[k],g[k+1],c);return N+=`L${g[g.length-1].x} ${g[g.length-1].y}`,[N,p,x,y,S]}function Hb(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function vU(e){var g;const{sourceNode:t,targetNode:n}=e;if(!Hb(t)||!Hb(n))return null;const i=t.internals.handleBounds||Zb(t.handles),r=n.internals.handleBounds||Zb(n.handles),o=Wb((i==null?void 0:i.source)??[],e.sourceHandle),c=Wb(e.connectionMode===Ho.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!o||!c)return(g=e.onError)==null||g.call(e,"008",_i.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const u=(o==null?void 0:o.position)||Je.Bottom,d=(c==null?void 0:c.position)||Je.Top,h=Da(t,o,u),m=Da(n,c,d);return{sourceX:h.x,sourceY:h.y,targetX:m.x,targetY:m.y,sourcePosition:u,targetPosition:d}}function Zb(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function Da(e,t,n=Je.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:c,height:u}=t??Ai(e);if(i)return{x:r+c/2,y:o+u/2};switch((t==null?void 0:t.position)??n){case Je.Top:return{x:r+c/2,y:o};case Je.Right:return{x:r+c,y:o+u/2};case Je.Bottom:return{x:r+c/2,y:o+u};case Je.Left:return{x:r,y:o+u/2}}}function Wb(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Op(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function yU(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:r}){const o=new Set;return e.reduce((c,u)=>([u.markerStart||i,u.markerEnd||r].forEach(d=>{if(d&&typeof d=="object"){const h=Op(d,t);o.has(h)||(c.push({id:h,color:d.color||n,...d}),o.add(h))}}),c),[]).sort((c,u)=>c.id.localeCompare(u.id))}const YS=1e3,bU=10,Vg={nodeOrigin:[0,0],nodeExtent:cc,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},kU={...Vg,checkEquality:!0};function qg(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function NU(e,t,n){const i=qg(Vg,n);for(const r of e.values())if(r.parentId)Kg(r,e,t,i);else{const o=_c(r,i.nodeOrigin),c=La(r.extent)?r.extent:i.nodeExtent,u=za(o,c,Ai(r));r.internals.positionAbsolute=u}}function jU(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],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"?n.push(o):r.type==="target"&&i.push(o)}return{source:n,target:i}}function Gg(e){return e==="manual"}function Pp(e,t,n,i={}){var m,g;const r=qg(kU,i),o={i:0},c=new Map(t),u=r!=null&&r.elevateNodesOnSelect&&!Gg(r.zIndexMode)?YS:0;let d=e.length>0,h=!1;t.clear(),n.clear();for(const p of e){let x=c.get(p.id);if(r.checkEquality&&p===(x==null?void 0:x.internals.userNode))t.set(p.id,x);else{const y=_c(p,r.nodeOrigin),S=La(p.extent)?p.extent:r.nodeExtent,N=za(y,S,Ai(p));x={...r.defaults,...p,measured:{width:(m=p.measured)==null?void 0:m.width,height:(g=p.measured)==null?void 0:g.height},internals:{positionAbsolute:N,handleBounds:jU(p,x),z:XS(p,u,r.zIndexMode),userNode:p}},t.set(p.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(d=!1),p.parentId&&Kg(x,t,n,i,o),h||(h=p.selected??!1)}return{nodesInitialized:d,hasSelectedNodes:h}}function wU(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Kg(e,t,n,i,r){const{elevateNodesOnSelect:o,nodeOrigin:c,nodeExtent:u,zIndexMode:d}=qg(Vg,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}wU(e,n),r&&!m.parentId&&m.internals.rootParentIndex===void 0&&d==="auto"&&(m.internals.rootParentIndex=++r.i,m.internals.z=m.internals.z+r.i*bU),r&&m.internals.rootParentIndex!==void 0&&(r.i=m.internals.rootParentIndex);const g=o&&!Gg(d)?YS:0,{x:p,y:x,z:y}=SU(e,m,c,u,g,d),{positionAbsolute:S}=e.internals,N=p!==S.x||x!==S.y;(N||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:N?{x:p,y:x}:S,z:y}})}function XS(e,t,n){const i=Ni(e.zIndex)?e.zIndex:0;return Gg(n)?i:i+(e.selected?t:0)}function SU(e,t,n,i,r,o){const{x:c,y:u}=t.internals.positionAbsolute,d=Ai(e),h=_c(e,n),m=La(e.extent)?za(h,e.extent,d):h;let g=za({x:c+m.x,y:u+m.y},i,d);e.extent==="parent"&&(g=PS(g,d,t));const p=XS(e,r,o),x=t.internals.z??0;return{x:g.x,y:g.y,z:x>=p?x+1:p}}function Yg(e,t,n,i=[0,0]){var c;const r=[],o=new Map;for(const u of e){const d=t.get(u.parentId);if(!d)continue;const h=((c=o.get(u.parentId))==null?void 0:c.expandedRect)??dc(d),m=zS(h,u.rect);o.set(u.parentId,{expandedRect:m,parent:d})}return o.size>0&&o.forEach(({expandedRect:u,parent:d},h)=>{var j;const m=d.internals.positionAbsolute,g=Ai(d),p=d.origin??i,x=u.x<m.x?Math.round(Math.abs(m.x-u.x)):0,y=u.y<m.y?Math.round(Math.abs(m.y-u.y)):0,S=Math.max(g.width,Math.round(u.width)),N=Math.max(g.height,Math.round(u.height)),k=(S-g.width)*p[0],E=(N-g.height)*p[1];(x>0||y>0||k||E)&&(r.push({id:h,type:"position",position:{x:d.position.x-x+k,y:d.position.y-y+E}}),(j=n.get(h))==null||j.forEach(A=>{e.some(P=>P.id===A.id)||r.push({id:A.id,type:"position",position:{x:A.position.x+x,y:A.position.y+y}})})),(g.width<u.width||g.height<u.height||x||y)&&r.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:S+(x?p[0]*x-k:0),height:N+(y?p[1]*y-E:0)}})}),r}function _U(e,t,n,i,r,o,c){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:g}=new window.DOMMatrixReadOnly(m.transform),p=[];for(const x of e.values()){const y=t.get(x.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),d=!0;continue}const S=Wg(x.nodeElement),N=y.measured.width!==S.width||y.measured.height!==S.height;if(!!(S.width&&S.height&&(N||!y.internals.handleBounds||x.force))){const E=x.nodeElement.getBoundingClientRect(),j=La(y.extent)?y.extent:o;let{positionAbsolute:A}=y.internals;if(y.parentId&&y.extent==="parent"){const L=t.get(y.parentId);L&&(A=PS(A,S,L))}else j&&(A=za(A,j,S));const P={...y,measured:S,internals:{...y.internals,positionAbsolute:A,handleBounds:{source:Db("source",x.nodeElement,E,g,y.id),target:Db("target",x.nodeElement,E,g,y.id)}}};t.set(y.id,P),y.parentId&&Kg(P,t,n,{nodeOrigin:r,zIndexMode:c}),d=!0,N&&(h.push({id:y.id,type:"dimensions",dimensions:S}),y.expandParent&&y.parentId&&p.push({id:y.id,parentId:y.parentId,rect:dc(P,r)}))}}if(p.length>0){const x=Yg(p,t,n,r);h.push(...x)}return{changes:h,updatedInternals:d}}async function EU({delta:e,panZoom:t,transform:n,translateExtent:i,width:r,height:o}){if(!t||!e.x&&!e.y)return!1;const c=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,o]],i);return!!c&&(c.x!==n[0]||c.y!==n[1]||c.k!==n[2])}function Vb(e,t,n,i,r,o){let c=r;const u=i.get(c)||new Map;i.set(c,u.set(n,t)),c=`${r}-${e}`;const d=i.get(c)||new Map;if(i.set(c,d.set(n,t)),o){c=`${r}-${e}-${o}`;const h=i.get(c)||new Map;i.set(c,h.set(n,t))}}function QS(e,t,n){e.clear(),t.clear();for(const i of n){const{source:r,target:o,sourceHandle:c=null,targetHandle:u=null}=i,d={edgeId:i.id,source:r,target:o,sourceHandle:c,targetHandle:u},h=`${r}-${c}--${o}-${u}`,m=`${o}-${u}--${r}-${c}`;Vb("source",d,m,e,r,c),Vb("target",d,h,e,o,u),t.set(i.id,i)}}function JS(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:JS(n,t):!1}function qb(e,t,n){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function CU(e,t,n,i){const r=new Map;for(const[o,c]of e)if((c.selected||c.id===i)&&(!c.parentId||!JS(c,e))&&(c.draggable||t&&typeof c.draggable>"u")){const u=e.get(o);u&&r.set(o,{id:o,position:u.position||{x:0,y:0},distance:{x:n.x-u.internals.positionAbsolute.x,y:n.y-u.internals.positionAbsolute.y},extent:u.extent,parentId:u.parentId,origin:u.origin,expandParent:u.expandParent,internals:{positionAbsolute:u.internals.positionAbsolute||{x:0,y:0}},measured:{width:u.measured.width??0,height:u.measured.height??0}})}return r}function bm({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var c,u,d;const r=[];for(const[h,m]of t){const g=(c=n.get(h))==null?void 0:c.internals.userNode;g&&r.push({...g,position:m.position,dragging:i})}if(!e)return[r[0],r];const o=(u=n.get(e))==null?void 0:u.internals.userNode;return[o?{...o,position:((d=t.get(e))==null?void 0:d.position)||o.position,dragging:i}:r[0],r]}function AU({dragItems:e,snapGrid:t,x:n,y:i}){const r=e.values().next().value;if(!r)return null;const o={x:n-r.distance.x,y:i-r.distance.y},c=Cc(o,t);return{x:c.x-o.x,y:c.y-o.y}}function IU({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:r}){let o={x:null,y:null},c=0,u=new Map,d=!1,h={x:0,y:0},m=null,g=!1,p=null,x=!1,y=!1,S=null;function N({noDragClassName:E,handleSelector:j,domNode:A,isSelectable:P,nodeId:L,nodeClickDistance:B=0}){p=Ms(A);function V({x:U,y:I}){const{nodeLookup:T,nodeExtent:O,snapGrid:$,snapToGrid:F,nodeOrigin:H,onNodeDrag:Z,onSelectionDrag:G,onError:q,updateNodePositions:X}=t();o={x:U,y:I};let Y=!1;const re=u.size>1,ee=re&&O?Mp(Ec(u)):null,se=re&&F?AU({dragItems:u,snapGrid:$,x:U,y:I}):null;for(const[ne,ie]of u){if(!T.has(ne))continue;let pe={x:U-ie.distance.x,y:I-ie.distance.y};F&&(pe=se?{x:Math.round(pe.x+se.x),y:Math.round(pe.y+se.y)}:Cc(pe,$));let Ce=null;if(re&&O&&!ie.extent&&ee){const{positionAbsolute:ue}=ie.internals,xe=ue.x-ee.x+O[0][0],De=ue.x+ie.measured.width-ee.x2+O[1][0],Me=ue.y-ee.y+O[0][1],Ge=ue.y+ie.measured.height-ee.y2+O[1][1];Ce=[[xe,Me],[De,Ge]]}const{position:fe,positionAbsolute:ve}=OS({nodeId:ne,nextPosition:pe,nodeLookup:T,nodeExtent:Ce||O,nodeOrigin:H,onError:q});Y=Y||ie.position.x!==fe.x||ie.position.y!==fe.y,ie.position=fe,ie.internals.positionAbsolute=ve}if(y=y||Y,!!Y&&(X(u,!0),S&&(i||Z||!L&&G))){const[ne,ie]=bm({nodeId:L,dragItems:u,nodeLookup:T});i==null||i(S,u,ne,ie),Z==null||Z(S,ne,ie),L||G==null||G(S,ie)}}async function M(){if(!m)return;const{transform:U,panBy:I,autoPanSpeed:T,autoPanOnNodeDrag:O}=t();if(!O){d=!1,cancelAnimationFrame(c);return}const[$,F]=Hg(h,m,T);($!==0||F!==0)&&(o.x=(o.x??0)-$/U[2],o.y=(o.y??0)-F/U[2],await I({x:$,y:F})&&V(o)),c=requestAnimationFrame(M)}function z(U){var re;const{nodeLookup:I,multiSelectionActive:T,nodesDraggable:O,transform:$,snapGrid:F,snapToGrid:H,selectNodesOnDrag:Z,onNodeDragStart:G,onSelectionDragStart:q,unselectNodesAndEdges:X}=t();g=!0,(!Z||!P)&&!T&&L&&((re=I.get(L))!=null&&re.selected||X()),P&&Z&&L&&(e==null||e(L));const Y=Ql(U.sourceEvent,{transform:$,snapGrid:F,snapToGrid:H,containerBounds:m});if(o=Y,u=CU(I,O,Y,L),u.size>0&&(n||G||!L&&q)){const[ee,se]=bm({nodeId:L,dragItems:u,nodeLookup:I});n==null||n(U.sourceEvent,u,ee,se),G==null||G(U.sourceEvent,ee,se),L||q==null||q(U.sourceEvent,se)}}const D=pS().clickDistance(B).on("start",U=>{const{domNode:I,nodeDragThreshold:T,transform:O,snapGrid:$,snapToGrid:F}=t();m=(I==null?void 0:I.getBoundingClientRect())||null,x=!1,y=!1,S=U.sourceEvent,T===0&&z(U),o=Ql(U.sourceEvent,{transform:O,snapGrid:$,snapToGrid:F,containerBounds:m}),h=ji(U.sourceEvent,m)}).on("drag",U=>{const{autoPanOnNodeDrag:I,transform:T,snapGrid:O,snapToGrid:$,nodeDragThreshold:F,nodeLookup:H}=t(),Z=Ql(U.sourceEvent,{transform:T,snapGrid:O,snapToGrid:$,containerBounds:m});if(S=U.sourceEvent,(U.sourceEvent.type==="touchmove"&&U.sourceEvent.touches.length>1||L&&!H.has(L))&&(x=!0),!x){if(!d&&I&&g&&(d=!0,M()),!g){const G=ji(U.sourceEvent,m),q=G.x-h.x,X=G.y-h.y;Math.sqrt(q*q+X*X)>F&&z(U)}(o.x!==Z.xSnapped||o.y!==Z.ySnapped)&&u&&g&&(h=ji(U.sourceEvent,m),V(Z))}}).on("end",U=>{if(!g||x){x&&u.size>0&&t().updateNodePositions(u,!1);return}if(d=!1,g=!1,cancelAnimationFrame(c),u.size>0){const{nodeLookup:I,updateNodePositions:T,onNodeDragStop:O,onSelectionDragStop:$}=t();if(y&&(T(u,!1),y=!1),r||O||!L&&$){const[F,H]=bm({nodeId:L,dragItems:u,nodeLookup:I,dragging:!1});r==null||r(U.sourceEvent,u,F,H),O==null||O(U.sourceEvent,F,H),L||$==null||$(U.sourceEvent,H)}}}).filter(U=>{const I=U.target;return!U.button&&(!E||!qb(I,`.${E}`,A))&&(!j||qb(I,j,A))});p.call(D)}function k(){p==null||p.on(".drag",null)}return{update:N,destroy:k}}function TU(e,t,n){const i=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())_d(r,dc(o))>0&&i.push(o);return i}const $U=250;function MU(e,t,n,i){var u,d;let r=[],o=1/0;const c=TU(e,n,t+$U);for(const h of c){const m=[...((u=h.internals.handleBounds)==null?void 0:u.source)??[],...((d=h.internals.handleBounds)==null?void 0:d.target)??[]];for(const g of m){if(i.nodeId===g.nodeId&&i.type===g.type&&i.id===g.id)continue;const{x:p,y:x}=Da(h,g,g.position,!0),y=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(x-e.y,2));y>t||(y<o?(r=[{...g,x:p,y:x}],o=y):y===o&&r.push({...g,x:p,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 e_(e,t,n,i,r,o=!1){var h,m,g;const c=i.get(e);if(!c)return null;const u=r==="strict"?(h=c.internals.handleBounds)==null?void 0:h[t]:[...((m=c.internals.handleBounds)==null?void 0:m.source)??[],...((g=c.internals.handleBounds)==null?void 0:g.target)??[]],d=(n?u==null?void 0:u.find(p=>p.id===n):u==null?void 0:u[0])??null;return d&&o?{...d,...Da(c,d,d.position,!0)}:d}function t_(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function RU(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const n_=()=>!0;function OU(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:r,edgeUpdaterType:o,isTarget:c,domNode:u,nodeLookup:d,lib:h,autoPanOnConnect:m,flowId:g,panBy:p,cancelConnection:x,onConnectStart:y,onConnect:S,onConnectEnd:N,isValidConnection:k=n_,onReconnectEnd:E,updateConnection:j,getTransform:A,getFromHandle:P,autoPanSpeed:L,dragThreshold:B=1,handleDomNode:V}){const M=HS(e.target);let z=0,D;const{x:U,y:I}=ji(e),T=t_(o,V),O=u==null?void 0:u.getBoundingClientRect();let $=!1;if(!O||!T)return;const F=e_(r,T,i,d,t);if(!F)return;let H=ji(e,O),Z=!1,G=null,q=!1,X=null;function Y(){if(!m||!O)return;const[fe,ve]=Hg(H,O,L);p({x:fe,y:ve}),z=requestAnimationFrame(Y)}const re={...F,nodeId:r,type:T,position:F.position},ee=d.get(r);let ne={inProgress:!0,isValid:null,from:Da(ee,re,Je.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ee,to:H,toHandle:null,toPosition:Ob[re.position],toNode:null,pointer:H};function ie(){$=!0,j(ne),y==null||y(e,{nodeId:r,handleId:i,handleType:T})}B===0&&ie();function pe(fe){if(!$){const{x:Ge,y:Te}=ji(fe),tt=Ge-U,et=Te-I;if(!(tt*tt+et*et>B*B))return;ie()}if(!P()||!re){Ce(fe);return}const ve=A();H=ji(fe,O),D=MU(Ac(H,ve,!1,[1,1]),n,d,re),Z||(Y(),Z=!0);const ue=s_(fe,{handle:D,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:c?"target":"source",isValidConnection:k,doc:M,lib:h,flowId:g,nodeLookup:d});X=ue.handleDomNode,G=ue.connection,q=RU(!!D,ue.isValid);const xe=d.get(r),De=xe?Da(xe,re,Je.Left,!0):ne.from,Me={...ne,from:De,isValid:q,to:ue.toHandle&&q?Wo({x:ue.toHandle.x,y:ue.toHandle.y},ve):H,toHandle:ue.toHandle,toPosition:q&&ue.toHandle?ue.toHandle.position:Ob[re.position],toNode:ue.toHandle?d.get(ue.toHandle.nodeId):null,pointer:H};j(Me),ne=Me}function Ce(fe){if(!("touches"in fe&&fe.touches.length>0)){if($){(D||X)&&G&&q&&(S==null||S(G));const{inProgress:ve,...ue}=ne,xe={...ue,toPosition:ne.toHandle?ne.toPosition:null};N==null||N(fe,xe),o&&(E==null||E(fe,xe))}x(),cancelAnimationFrame(z),Z=!1,q=!1,G=null,X=null,M.removeEventListener("mousemove",pe),M.removeEventListener("mouseup",Ce),M.removeEventListener("touchmove",pe),M.removeEventListener("touchend",Ce)}}M.addEventListener("mousemove",pe),M.addEventListener("mouseup",Ce),M.addEventListener("touchmove",pe),M.addEventListener("touchend",Ce)}function s_(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:o,doc:c,lib:u,flowId:d,isValidConnection:h=n_,nodeLookup:m}){const g=o==="target",p=t?c.querySelector(`.${u}-flow__handle[data-id="${d}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x,y}=ji(e),S=c.elementFromPoint(x,y),N=S!=null&&S.classList.contains(`${u}-flow__handle`)?S:p,k={handleDomNode:N,isValid:!1,connection:null,toHandle:null};if(N){const E=t_(void 0,N),j=N.getAttribute("data-nodeid"),A=N.getAttribute("data-handleid"),P=N.classList.contains("connectable"),L=N.classList.contains("connectableend");if(!j||!E)return k;const B={source:g?j:i,sourceHandle:g?A:r,target:g?i:j,targetHandle:g?r:A};k.connection=B;const M=P&&L&&(n===Ho.Strict?g&&E==="source"||!g&&E==="target":j!==i||A!==r);k.isValid=M&&h(B),k.toHandle=e_(j,E,A,m,n,!0)}return k}const zp={onPointerDown:OU,isValid:s_};function PU({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const r=Ms(e);function o({translateExtent:u,width:d,height:h,zoomStep:m=1,pannable:g=!0,zoomable:p=!0,inversePan:x=!1}){const y=j=>{if(j.sourceEvent.type!=="wheel"||!t)return;const A=n(),P=j.sourceEvent.ctrlKey&&hc()?10:1,L=-j.sourceEvent.deltaY*(j.sourceEvent.deltaMode===1?.05:j.sourceEvent.deltaMode?1:.002)*m,B=A[2]*Math.pow(2,L*P);t.scaleTo(B)};let S=[0,0];const N=j=>{(j.sourceEvent.type==="mousedown"||j.sourceEvent.type==="touchstart")&&(S=[j.sourceEvent.clientX??j.sourceEvent.touches[0].clientX,j.sourceEvent.clientY??j.sourceEvent.touches[0].clientY])},k=j=>{const A=n();if(j.sourceEvent.type!=="mousemove"&&j.sourceEvent.type!=="touchmove"||!t)return;const P=[j.sourceEvent.clientX??j.sourceEvent.touches[0].clientX,j.sourceEvent.clientY??j.sourceEvent.touches[0].clientY],L=[P[0]-S[0],P[1]-S[1]];S=P;const B=i()*Math.max(A[2],Math.log(A[2]))*(x?-1:1),V={x:A[0]-L[0]*B,y:A[1]-L[1]*B},M=[[0,0],[d,h]];t.setViewportConstrained({x:V.x,y:V.y,zoom:A[2]},M,u)},E=IS().on("start",N).on("zoom",g?k:null).on("zoom.wheel",p?y:null);r.call(E,{})}function c(){r.on("zoom",null)}return{update:o,destroy:c,pointer:vi}}const Kd=e=>({x:e.x,y:e.y,zoom:e.k}),km=({x:e,y:t,zoom:n})=>Vd.translate(e,t).scale(n),Ur=(e,t)=>e.target.closest(`.${t}`),i_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),zU=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Nm=(e,t=0,n=zU,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(n).on("end",i):e},r_=e=>{const t=e.ctrlKey&&hc()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function LU({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:o,zoomOnPinch:c,onPanZoomStart:u,onPanZoom:d,onPanZoomEnd:h}){return m=>{if(Ur(m,t))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const g=n.property("__zoom").k||1;if(m.ctrlKey&&c){const N=vi(m),k=r_(m),E=g*Math.pow(2,k);i.scaleTo(n,E,N,m);return}const p=m.deltaMode===1?20:1;let x=r===$a.Vertical?0:m.deltaX*p,y=r===$a.Horizontal?0:m.deltaY*p;!hc()&&m.shiftKey&&r!==$a.Vertical&&(x=m.deltaY*p,y=0),i.translateBy(n,-(x/g)*o,-(y/g)*o,{internal:!0});const S=Kd(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?d==null||d(m,S):(e.isPanScrolling=!0,u==null||u(m,S)),e.panScrollTimeout=setTimeout(()=>{h==null||h(m,S),e.isPanScrolling=!1},150)}}function DU({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,r){const o=i.type==="wheel",c=!t&&o&&!i.ctrlKey,u=Ur(i,e);if(i.ctrlKey&&o&&u&&i.preventDefault(),c||u)return null;i.preventDefault(),n.call(this,i,r)}}function FU({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var o,c,u;if((o=i.sourceEvent)!=null&&o.internal)return;const r=Kd(i.transform);e.mouseButton=((c=i.sourceEvent)==null?void 0:c.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((u=i.sourceEvent)==null?void 0:u.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,r))}}function UU({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:r}){return o=>{var c,u;e.usedRightMouseButton=!!(n&&i_(t,e.mouseButton??0)),(c=o.sourceEvent)!=null&&c.sync||i([o.transform.x,o.transform.y,o.transform.k]),r&&!((u=o.sourceEvent)!=null&&u.internal)&&(r==null||r(o.sourceEvent,Kd(o.transform)))}}function BU({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:o}){return c=>{var u;if(!((u=c.sourceEvent)!=null&&u.internal)&&(e.isZoomingOrPanning=!1,o&&i_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&o(c.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const d=Kd(c.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(c.sourceEvent,d)},n?150:0)}}}function HU({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:i,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:c,userSelectionActive:u,noWheelClassName:d,noPanClassName:h,lib:m,connectionInProgress:g}){return p=>{var k;const x=t||n,y=i&&p.ctrlKey,S=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(Ur(p,`${m}-flow__node`)||Ur(p,`${m}-flow__edge`)||Ur(p,`${m}-flow__selection`)||Ur(p,`${m}-flow__nodesselection`)))return!0;if(!r&&!x&&!o&&!c&&!i||u||g&&!S||Ur(p,d)&&S||Ur(p,h)&&(!S||o&&S&&!t)||!i&&p.ctrlKey&&S)return!1;if(!i&&p.type==="touchstart"&&((k=p.touches)==null?void 0:k.length)>1)return p.preventDefault(),!1;if(!x&&!o&&!y&&S||!r&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(r)&&!r.includes(p.button)&&p.type==="mousedown")return!1;const N=Array.isArray(r)&&r.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||S||e)&&N}}function ZU({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:r,onPanZoom:o,onPanZoomStart:c,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 g=[[0,0],[m.width,m.height]];const p=typeof ResizeObserver<"u"?new ResizeObserver(I=>{const T=I[0];T&&(g=[[0,0],[T.contentRect.width,T.contentRect.height]])}):null;p==null||p.observe(e);const x=IS().extent(()=>g).scaleExtent([t,n]).translateExtent(i),y=Ms(e).call(x);A({x:r.x,y:r.y,zoom:Zo(r.zoom,t,n)},[[0,0],[m.width,m.height]],i);const S=y.on("wheel.zoom"),N=y.on("dblclick.zoom");x.wheelDelta(r_);async function k(I,T){return y?new Promise(O=>{x==null||x.interpolate((T==null?void 0:T.interpolate)==="linear"?Xl:ed).transform(Nm(y,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>O(!0)),I)}):!1}function E({noWheelClassName:I,noPanClassName:T,onPaneContextMenu:O,userSelectionActive:$,panOnScroll:F,panOnDrag:H,panOnScrollMode:Z,panOnScrollSpeed:G,preventScrolling:q,zoomOnPinch:X,zoomOnScroll:Y,zoomOnDoubleClick:re,panActivationKeyPressed:ee=!1,zoomActivationKeyPressed:se,lib:ne,onTransformChange:ie,connectionInProgress:pe,paneClickDistance:Ce,selectionOnDrag:fe}){$&&!h.isZoomingOrPanning&&j();const ve=F&&!se&&!$;x.clickDistance(fe?1/0:!Ni(Ce)||Ce<0?0:Ce);const ue=ve?LU({zoomPanValues:h,noWheelClassName:I,d3Selection:y,d3Zoom:x,panOnScrollMode:Z,panOnScrollSpeed:G,zoomOnPinch:X,onPanZoomStart:c,onPanZoom:o,onPanZoomEnd:u}):DU({noWheelClassName:I,preventScrolling:q,d3ZoomHandler:S});y.on("wheel.zoom",ue,{passive:!1});const xe=FU({zoomPanValues:h,onDraggingChange:d,onPanZoomStart:c});x.on("start",xe);const De=UU({zoomPanValues:h,panOnDrag:H,onPaneContextMenu:!!O,onPanZoom:o,onTransformChange:ie});x.on("zoom",De);const Me=BU({zoomPanValues:h,panOnDrag:H,panOnScroll:F,onPaneContextMenu:O,onPanZoomEnd:u,onDraggingChange:d});x.on("end",Me);const Ge=HU({panActivationKeyPressed:ee,zoomActivationKeyPressed:se,panOnDrag:H,zoomOnScroll:Y,panOnScroll:F,zoomOnDoubleClick:re,zoomOnPinch:X,userSelectionActive:$,noPanClassName:T,noWheelClassName:I,lib:ne,connectionInProgress:pe});x.filter(Ge),re?y.on("dblclick.zoom",N):y.on("dblclick.zoom",null)}function j(){x.on("zoom",null)}async function A(I,T,O){const $=km(I),F=x==null?void 0:x.constrain()($,T,O);return F&&await k(F),F}async function P(I,T){const O=km(I);return await k(O,T),O}function L(I){if(y){const T=km(I),O=y.property("__zoom");(O.k!==I.zoom||O.x!==I.x||O.y!==I.y)&&(x==null||x.transform(y,T,null,{sync:!0}))}}function B(){const I=y?AS(y.node()):{x:0,y:0,k:1};return{x:I.x,y:I.y,zoom:I.k}}async function V(I,T){return y?new Promise(O=>{x==null||x.interpolate((T==null?void 0:T.interpolate)==="linear"?Xl:ed).scaleTo(Nm(y,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>O(!0)),I)}):!1}async function M(I,T){return y?new Promise(O=>{x==null||x.interpolate((T==null?void 0:T.interpolate)==="linear"?Xl:ed).scaleBy(Nm(y,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>O(!0)),I)}):!1}function z(I){x==null||x.scaleExtent(I)}function D(I){x==null||x.translateExtent(I)}function U(I){const T=!Ni(I)||I<0?0:I;x==null||x.clickDistance(T)}return{update:E,destroy:j,setViewport:P,setViewportConstrained:A,getViewport:B,scaleTo:V,scaleBy:M,setScaleExtent:z,setTranslateExtent:D,syncViewport:L,setClickDistance:U}}var Vo;(function(e){e.Line="line",e.Handle="handle"})(Vo||(Vo={}));function WU({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:o}){const c=e-t,u=n-i,d=[c>0?1:c<0?-1:0,u>0?1:u<0?-1:0];return c&&r&&(d[0]=d[0]*-1),u&&o&&(d[1]=d[1]*-1),d}function Gb(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:r}}function zr(e,t){return Math.max(0,t-e)}function Lr(e,t){return Math.max(0,e-t)}function Hu(e,t,n){return Math.max(0,t-e,e-n)}function Kb(e,t){return e?!t:t}function VU(e,t,n,i,r,o,c,u){let{affectsX:d,affectsY:h}=t;const{isHorizontal:m,isVertical:g}=t,p=m&&g,{xSnapped:x,ySnapped:y}=n,{minWidth:S,maxWidth:N,minHeight:k,maxHeight:E}=i,{x:j,y:A,width:P,height:L,aspectRatio:B}=e;let V=Math.floor(m?x-e.pointerX:0),M=Math.floor(g?y-e.pointerY:0);const z=P+(d?-V:V),D=L+(h?-M:M),U=-o[0]*P,I=-o[1]*L;let T=Hu(z,S,N),O=Hu(D,k,E);if(c){let H=0,Z=0;d&&V<0?H=zr(j+V+U,c[0][0]):!d&&V>0&&(H=Lr(j+z+U,c[1][0])),h&&M<0?Z=zr(A+M+I,c[0][1]):!h&&M>0&&(Z=Lr(A+D+I,c[1][1])),T=Math.max(T,H),O=Math.max(O,Z)}if(u){let H=0,Z=0;d&&V>0?H=Lr(j+V,u[0][0]):!d&&V<0&&(H=zr(j+z,u[1][0])),h&&M>0?Z=Lr(A+M,u[0][1]):!h&&M<0&&(Z=zr(A+D,u[1][1])),T=Math.max(T,H),O=Math.max(O,Z)}if(r){if(m){const H=Hu(z/B,k,E)*B;if(T=Math.max(T,H),c){let Z=0;!d&&!h||d&&!h&&p?Z=Lr(A+I+z/B,c[1][1])*B:Z=zr(A+I+(d?V:-V)/B,c[0][1])*B,T=Math.max(T,Z)}if(u){let Z=0;!d&&!h||d&&!h&&p?Z=zr(A+z/B,u[1][1])*B:Z=Lr(A+(d?V:-V)/B,u[0][1])*B,T=Math.max(T,Z)}}if(g){const H=Hu(D*B,S,N)/B;if(O=Math.max(O,H),c){let Z=0;!d&&!h||h&&!d&&p?Z=Lr(j+D*B+U,c[1][0])/B:Z=zr(j+(h?M:-M)*B+U,c[0][0])/B,O=Math.max(O,Z)}if(u){let Z=0;!d&&!h||h&&!d&&p?Z=zr(j+D*B,u[1][0])/B:Z=Lr(j+(h?M:-M)*B,u[0][0])/B,O=Math.max(O,Z)}}}M=M+(M<0?O:-O),V=V+(V<0?T:-T),r&&(p?z>D*B?M=(Kb(d,h)?-V:V)/B:V=(Kb(d,h)?-M:M)*B:m?(M=V/B,h=d):(V=M*B,d=h));const $=d?j+V:j,F=h?A+M:A;return{width:P+(d?-V:V),height:L+(h?-M:M),x:o[0]*V*(d?-1:1)+$,y:o[1]*M*(h?-1:1)+F}}const a_={width:0,height:0,x:0,y:0},qU={...a_,pointerX:0,pointerY:0,aspectRatio:1};function GU(e,t,n){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,o=e.measured.width??0,c=e.measured.height??0,u=n[0]*o,d=n[1]*c;return[[i-u,r-d],[i+o-u,r+c-d]]}function KU({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){const o=Ms(e);let c={controlDirection:Gb("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:g,resizeDirection:p,onResizeStart:x,onResize:y,onResizeEnd:S,shouldResize:N}){let k={...a_},E={...qU};c={boundaries:m,resizeDirection:p,keepAspectRatio:g,controlDirection:Gb(h)};let j,A=null,P=[],L,B,V,M=!1;const z=pS().on("start",D=>{const{nodeLookup:U,transform:I,snapGrid:T,snapToGrid:O,nodeOrigin:$,paneDomNode:F}=n();if(j=U.get(t),!j)return;A=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:H,ySnapped:Z}=Ql(D.sourceEvent,{transform:I,snapGrid:T,snapToGrid:O,containerBounds:A});k={width:j.measured.width??0,height:j.measured.height??0,x:j.position.x??0,y:j.position.y??0},E={...k,pointerX:H,pointerY:Z,aspectRatio:k.width/k.height},L=void 0,B=La(j.extent)?j.extent:void 0,j.parentId&&(j.extent==="parent"||j.expandParent)&&(L=U.get(j.parentId)),L&&j.extent==="parent"&&(B=[[0,0],[L.measured.width,L.measured.height]]),P=[],V=void 0;for(const[G,q]of U)if(q.parentId===t&&(P.push({id:G,position:{...q.position},extent:q.extent}),q.extent==="parent"||q.expandParent)){const X=GU(q,j,q.origin??$);V?V=[[Math.min(X[0][0],V[0][0]),Math.min(X[0][1],V[0][1])],[Math.max(X[1][0],V[1][0]),Math.max(X[1][1],V[1][1])]]:V=X}x==null||x(D,{...k})}).on("drag",D=>{const{transform:U,snapGrid:I,snapToGrid:T,nodeOrigin:O}=n(),$=Ql(D.sourceEvent,{transform:U,snapGrid:I,snapToGrid:T,containerBounds:A}),F=[];if(!j)return;const{x:H,y:Z,width:G,height:q}=k,X={},Y=j.origin??O,{width:re,height:ee,x:se,y:ne}=VU(E,c.controlDirection,$,c.boundaries,c.keepAspectRatio,Y,B,V),ie=re!==G,pe=ee!==q,Ce=se!==H&&ie,fe=ne!==Z&&pe;if(!Ce&&!fe&&!ie&&!pe)return;if((Ce||fe||Y[0]===1||Y[1]===1)&&(X.x=Ce?se:k.x,X.y=fe?ne:k.y,k.x=X.x,k.y=X.y,P.length>0)){const De=se-H,Me=ne-Z;for(const Ge of P)Ge.position={x:Ge.position.x-De+Y[0]*(re-G),y:Ge.position.y-Me+Y[1]*(ee-q)},F.push(Ge)}if((ie||pe)&&(X.width=ie&&(!c.resizeDirection||c.resizeDirection==="horizontal")?re:k.width,X.height=pe&&(!c.resizeDirection||c.resizeDirection==="vertical")?ee:k.height,k.width=X.width,k.height=X.height),L&&j.expandParent){const De=Y[0]*(X.width??0);X.x&&X.x<De&&(k.x=De,E.x=E.x-(X.x-De));const Me=Y[1]*(X.height??0);X.y&&X.y<Me&&(k.y=Me,E.y=E.y-(X.y-Me))}const ve=WU({width:k.width,prevWidth:G,height:k.height,prevHeight:q,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),ue={...k,direction:ve};(N==null?void 0:N(D,ue))!==!1&&(M=!0,y==null||y(D,ue),i(X,F))}).on("end",D=>{M&&(S==null||S(D,{...k}),r==null||r({...k}),M=!1)});o.call(z)}function d(){o.on(".drag",null)}return{update:u,destroy:d}}var jm={exports:{}},wm={},Sm={exports:{}},_m={};/**
208
+ * @license React
209
+ * use-sync-external-store-shim.production.js
210
+ *
211
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
212
+ *
213
+ * This source code is licensed under the MIT license found in the
214
+ * LICENSE file in the root directory of this source tree.
215
+ */var Yb;function YU(){if(Yb)return _m;Yb=1;var e=vc();function t(g,p){return g===p&&(g!==0||1/g===1/p)||g!==g&&p!==p}var n=typeof Object.is=="function"?Object.is:t,i=e.useState,r=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function u(g,p){var x=p(),y=i({inst:{value:x,getSnapshot:p}}),S=y[0].inst,N=y[1];return o(function(){S.value=x,S.getSnapshot=p,d(S)&&N({inst:S})},[g,x,p]),r(function(){return d(S)&&N({inst:S}),g(function(){d(S)&&N({inst:S})})},[g]),c(x),x}function d(g){var p=g.getSnapshot;g=g.value;try{var x=p();return!n(g,x)}catch{return!0}}function h(g,p){return p()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return _m.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,_m}var Xb;function XU(){return Xb||(Xb=1,Sm.exports=YU()),Sm.exports}/**
216
+ * @license React
217
+ * use-sync-external-store-shim/with-selector.production.js
218
+ *
219
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
220
+ *
221
+ * This source code is licensed under the MIT license found in the
222
+ * LICENSE file in the root directory of this source tree.
223
+ */var Qb;function QU(){if(Qb)return wm;Qb=1;var e=vc(),t=XU();function n(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}var i=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,u=e.useMemo,d=e.useDebugValue;return wm.useSyncExternalStoreWithSelector=function(h,m,g,p,x){var y=o(null);if(y.current===null){var S={hasValue:!1,value:null};y.current=S}else S=y.current;y=u(function(){function k(L){if(!E){if(E=!0,j=L,L=p(L),x!==void 0&&S.hasValue){var B=S.value;if(x(B,L))return A=B}return A=L}if(B=A,i(j,L))return B;var V=p(L);return x!==void 0&&x(B,V)?(j=L,B):(j=L,A=V)}var E=!1,j,A,P=g===void 0?null:g;return[function(){return k(m())},P===null?void 0:function(){return k(P())}]},[m,g,p,x]);var N=r(h,y[0],y[1]);return c(function(){S.hasValue=!0,S.value=N},[N]),d(N),N},wm}var Jb;function JU(){return Jb||(Jb=1,jm.exports=QU()),jm.exports}var e6=JU();const t6=Gp(e6),n6={},ek=e=>{let t;const n=new Set,i=(m,g)=>{const p=typeof m=="function"?m(t):m;if(!Object.is(p,t)){const x=t;t=g??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(y=>y(t,x))}},r=()=>t,d={setState:i,getState:r,getInitialState:()=>h,subscribe:m=>(n.add(m),()=>n.delete(m)),destroy:()=>{(n6?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},h=t=e(i,r,d);return d},s6=e=>e?ek(e):ek,{useDebugValue:i6}=UR,{useSyncExternalStoreWithSelector:r6}=t6,a6=e=>e;function o_(e,t=a6,n){const i=r6(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return i6(i),i}const tk=(e,t)=>{const n=s6(e),i=(r,o=t)=>o_(n,r,o);return Object.assign(i,n),i},o6=(e,t)=>e?tk(e,t):tk;function nn(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 n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||!Object.is(e[i],t[i]))return!1;return!0}const Yd=b.createContext(null),l6=Yd.Provider,l_=_i.error001("react");function wt(e,t){const n=b.useContext(Yd);if(n===null)throw new Error(l_);return o_(n,e,t)}function qt(){const e=b.useContext(Yd);if(e===null)throw new Error(l_);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const nk={display:"none"},c6={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},c_="react-flow__node-desc",u_="react-flow__edge-desc",u6="react-flow__aria-live",d6=e=>e.ariaLiveMessage,h6=e=>e.ariaLabelConfig;function f6({rfId:e}){const t=wt(d6);return s.jsx("div",{id:`${u6}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:c6,children:t})}function m6({rfId:e,disableKeyboardA11y:t}){const n=wt(h6);return s.jsxs(s.Fragment,{children:[s.jsx("div",{id:`${c_}-${e}`,style:nk,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),s.jsx("div",{id:`${u_}-${e}`,style:nk,children:n["edge.a11yDescription.default"]}),!t&&s.jsx(f6,{rfId:e})]})}const Xd=b.forwardRef(({position:e="top-left",children:t,className:n,style:i,...r},o)=>{const c=`${e}`.split("-");return s.jsx("div",{className:Nn(["react-flow__panel",n,...c]),style:i,ref:o,...r,children:t})});Xd.displayName="Panel";const sk="https://reactflow.dev?utm_source=attribution";function p6({proOptions:e,position:t="bottom-right"}){return b.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:s.jsx(Xd,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${sk}`,children:s.jsx("a",{href:sk,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const g6=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},Zu=e=>e.id;function x6(e,t){return nn(e.selectedNodes.map(Zu),t.selectedNodes.map(Zu))&&nn(e.selectedEdges.map(Zu),t.selectedEdges.map(Zu))}function v6({onSelectionChange:e}){const t=qt(),{selectedNodes:n,selectedEdges:i}=wt(g6,x6);return b.useEffect(()=>{const r={nodes:n,edges:i};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(o=>o(r))},[n,i,e]),null}const y6=e=>!!e.onSelectionChangeHandlers;function b6({onSelectionChange:e}){const t=wt(y6);return e||t?s.jsx(v6,{onSelectionChange:e}):null}const d_=[0,0],k6={x:0,y:0,zoom:1},N6=["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"],ik=[...N6,"rfId"],j6=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}),rk={translateExtent:cc,nodeOrigin:d_,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function w6(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:r,setTranslateExtent:o,setNodeExtent:c,reset:u,setDefaultNodesAndEdges:d}=wt(j6,nn),h=qt();b.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{m.current=rk,u()}),[]);const m=b.useRef(rk);return b.useEffect(()=>{for(const g of ik){const p=e[g],x=m.current[g];p!==x&&(typeof e[g]>"u"||(g==="nodes"?t(p):g==="edges"?n(p):g==="minZoom"?i(p):g==="maxZoom"?r(p):g==="translateExtent"?o(p):g==="nodeExtent"?c(p):g==="ariaLabelConfig"?h.setState({ariaLabelConfig:lU(p)}):g==="fitView"?h.setState({fitViewQueued:p}):g==="fitViewOptions"?h.setState({fitViewOptions:p}):h.setState({[g]:p})))}m.current=e},ik.map(g=>e[g])),null}function ak(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function S6(e){var i;const[t,n]=b.useState(e==="system"?null:e);return b.useEffect(()=>{if(e!=="system"){n(e);return}const r=ak(),o=()=>n(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=ak())!=null&&i.matches?"dark":"light"}const ok=typeof document<"u"?document:null;function fc(e=null,t={target:ok,actInsideInputWithModifier:!0}){const[n,i]=b.useState(!1),r=b.useRef(!1),o=b.useRef(new Set([])),[c,u]=b.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(g=>typeof g=="string").map(g=>g.replace(/\+/g,`
224
+ `).replace(`
225
+
226
+ `,`
227
+ +`).split(`
228
+ `)),m=h.reduce((g,p)=>g.concat(...p),[]);return[h,m]}return[[],[]]},[e]);return b.useEffect(()=>{const d=(t==null?void 0:t.target)??ok,h=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=x=>{var N,k;if(r.current=x.ctrlKey||x.metaKey||x.shiftKey||x.altKey,(!r.current||r.current&&!h)&&ZS(x))return!1;const S=ck(x.code,u);if(o.current.add(x[S]),lk(c,o.current,!1)){const E=((k=(N=x.composedPath)==null?void 0:N.call(x))==null?void 0:k[0])||x.target,j=(E==null?void 0:E.nodeName)==="BUTTON"||(E==null?void 0:E.nodeName)==="A";t.preventDefault!==!1&&(r.current||!j)&&x.preventDefault(),i(!0)}},g=x=>{const y=ck(x.code,u);lk(c,o.current,!0)?(i(!1),o.current.clear()):o.current.delete(x[y]),x.key==="Meta"&&o.current.clear(),r.current=!1},p=()=>{o.current.clear(),i(!1)};return d==null||d.addEventListener("keydown",m),d==null||d.addEventListener("keyup",g),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{d==null||d.removeEventListener("keydown",m),d==null||d.removeEventListener("keyup",g),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,i]),n}function lk(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function ck(e,t){return t.includes(e)?"code":"key"}const _6=()=>{const e=qt();return b.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,r,o],panZoom:c}=e.getState();return c?(await c.setViewport({x:t.x??i,y:t.y??r,zoom:t.zoom??o},n),!0):!1},getViewport:()=>{const[t,n,i]=e.getState().transform;return{x:t,y:n,zoom:i}},setCenter:async(t,n,i)=>e.getState().setCenter(t,n,i),fitBounds:async(t,n)=>{const{width:i,height:r,minZoom:o,maxZoom:c,panZoom:u}=e.getState(),d=Zg(t,i,r,o,c,(n==null?void 0:n.padding)??.1);return u?(await u.setViewport(d,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:i,snapGrid:r,snapToGrid:o,domNode:c}=e.getState();if(!c)return t;const{x:u,y:d}=c.getBoundingClientRect(),h={x:t.x-u,y:t.y-d},m=n.snapGrid??r,g=n.snapToGrid??o;return Ac(h,i,g,m)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:r,y:o}=i.getBoundingClientRect(),c=Wo(t,n);return{x:c.x+r,y:c.y+o}}}),[])};function h_(e,t){const n=[],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 c=i.get(o.id);c?c.push(o):i.set(o.id,[o])}for(const o of t){const c=i.get(o.id);if(!c){n.push(o);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){n.push({...c[0].item});continue}const u={...o};for(const d of c)E6(d,u);n.push(u)}return r.length&&r.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function E6(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 C6(e,t){return h_(e,t)}function A6(e,t){return h_(e,t)}function ka(e,t){return{id:e,type:"select",selected:t}}function No(e,t=new Set,n=!1){const i=[];for(const[r,o]of e){const c=t.has(r);!(o.selected===void 0&&!c)&&o.selected!==c&&(n&&(o.selected=c),i.push(ka(o.id,c)))}return i}function uk({items:e=[],lookup:t}){var r;const n=[],i=new Map(e.map(o=>[o.id,o]));for(const[o,c]of e.entries()){const u=t.get(c.id),d=((r=u==null?void 0:u.internals)==null?void 0:r.userNode)??u;d!==void 0&&d!==c&&n.push({id:c.id,item:c,type:"replace"}),d===void 0&&n.push({item:c,type:"add",index:o})}for(const[o]of t)i.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function dk(e){return{id:e.id,type:"remove"}}const I6=DS();function T6(e,t,n={}){return mU(e,t,{...n,onError:n.onError??I6})}const hk=e=>JF(e),$6=e=>RS(e);function f_(e){return b.forwardRef(e)}const m_=typeof window<"u"?b.useLayoutEffect:b.useEffect;function fk(e){const[t,n]=b.useState(BigInt(0)),[i]=b.useState(()=>M6(()=>n(r=>r+BigInt(1))));return m_(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function M6(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const p_=b.createContext(null);function R6({children:e}){const t=qt(),n=b.useCallback(u=>{const{nodes:d=[],setNodes:h,hasDefaultNodes:m,onNodesChange:g,nodeLookup:p,fitViewQueued:x,onNodesChangeMiddlewareMap:y}=t.getState();let S=d;for(const k of u)S=typeof k=="function"?k(S):k;let N=uk({items:S,lookup:p});for(const k of y.values())N=k(N);m&&h(S),N.length>0?g==null||g(N):x&&window.requestAnimationFrame(()=>{const{fitViewQueued:k,nodes:E,setNodes:j}=t.getState();k&&j(E)})},[]),i=fk(n),r=b.useCallback(u=>{const{edges:d=[],setEdges:h,hasDefaultEdges:m,onEdgesChange:g,edgeLookup:p}=t.getState();let x=d;for(const y of u)x=typeof y=="function"?y(x):y;m?h(x):g&&g(uk({items:x,lookup:p}))},[]),o=fk(r),c=b.useMemo(()=>({nodeQueue:i,edgeQueue:o}),[]);return s.jsx(p_.Provider,{value:c,children:e})}function O6(){const e=b.useContext(p_);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const P6=e=>!!e.panZoom;function Xg(){const e=_6(),t=qt(),n=O6(),i=wt(P6),r=b.useMemo(()=>{const o=g=>t.getState().nodeLookup.get(g),c=g=>{n.nodeQueue.push(g)},u=g=>{n.edgeQueue.push(g)},d=g=>{var k,E;const{nodeLookup:p,nodeOrigin:x}=t.getState(),y=hk(g)?g:p.get(g.id),S=y.parentId?US(y.position,y.measured,y.parentId,p,x):y.position,N={...y,position:S,width:((k=y.measured)==null?void 0:k.width)??y.width,height:((E=y.measured)==null?void 0:E.height)??y.height};return dc(N)},h=(g,p,x={replace:!1})=>{c(y=>y.map(S=>{if(S.id===g){const N=typeof p=="function"?p(S):p;return x.replace&&hk(N)?N:{...S,...N}}return S}))},m=(g,p,x={replace:!1})=>{u(y=>y.map(S=>{if(S.id===g){const N=typeof p=="function"?p(S):p;return x.replace&&$6(N)?N:{...S,...N}}return S}))};return{getNodes:()=>t.getState().nodes.map(g=>({...g})),getNode:g=>{var p;return(p=o(g))==null?void 0:p.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:g=[]}=t.getState();return g.map(p=>({...p}))},getEdge:g=>t.getState().edgeLookup.get(g),setNodes:c,setEdges:u,addNodes:g=>{const p=Array.isArray(g)?g:[g];n.nodeQueue.push(x=>[...x,...p])},addEdges:g=>{const p=Array.isArray(g)?g:[g];n.edgeQueue.push(x=>[...x,...p])},toObject:()=>{const{nodes:g=[],edges:p=[],transform:x}=t.getState(),[y,S,N]=x;return{nodes:g.map(k=>({...k})),edges:p.map(k=>({...k})),viewport:{x:y,y:S,zoom:N}}},deleteElements:async({nodes:g=[],edges:p=[]})=>{const{nodes:x,edges:y,onNodesDelete:S,onEdgesDelete:N,triggerNodeChanges:k,triggerEdgeChanges:E,onDelete:j,onBeforeDelete:A}=t.getState(),{nodes:P,edges:L}=await iU({nodesToRemove:g,edgesToRemove:p,nodes:x,edges:y,onBeforeDelete:A}),B=L.length>0,V=P.length>0;if(B){const M=L.map(dk);N==null||N(L),E(M)}if(V){const M=P.map(dk);S==null||S(P),k(M)}return(V||B)&&(j==null||j({nodes:P,edges:L})),{deletedNodes:P,deletedEdges:L}},getIntersectingNodes:(g,p=!0,x)=>{const y=zb(g),S=y?g:d(g),N=x!==void 0;return S?(x||t.getState().nodes).filter(k=>{const E=t.getState().nodeLookup.get(k.id);if(E&&!y&&(k.id===g.id||!E.internals.positionAbsolute))return!1;const j=dc(N?k:E),A=_d(j,S);return p&&A>0||A>=j.width*j.height||A>=S.width*S.height}):[]},isNodeIntersecting:(g,p,x=!0)=>{const S=zb(g)?g:d(g);if(!S)return!1;const N=_d(S,p);return x&&N>0||N>=p.width*p.height||N>=S.width*S.height},updateNode:h,updateNodeData:(g,p,x={replace:!1})=>{h(g,y=>{const S=typeof p=="function"?p(y):p;return x.replace?{...y,data:S}:{...y,data:{...y.data,...S}}},x)},updateEdge:m,updateEdgeData:(g,p,x={replace:!1})=>{m(g,y=>{const S=typeof p=="function"?p(y):p;return x.replace?{...y,data:S}:{...y,data:{...y.data,...S}}},x)},getNodesBounds:g=>{const{nodeLookup:p,nodeOrigin:x}=t.getState();return eU(g,{nodeLookup:p,nodeOrigin:x})},getHandleConnections:({type:g,id:p,nodeId:x})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${x}-${g}${p?`-${p}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:g,handleId:p,nodeId:x})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${x}${g?p?`-${g}-${p}`:`-${g}`:""}`))==null?void 0:y.values())??[])},fitView:async g=>{const p=t.getState().fitViewResolver??oU();return t.setState({fitViewQueued:!0,fitViewOptions:g,fitViewResolver:p}),n.nodeQueue.push(x=>[...x]),p.promise}}},[]);return b.useMemo(()=>({...r,...e,viewportInitialized:i}),[i])}const mk=e=>e.selected,z6=typeof window<"u"?window:void 0;function L6({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=qt(),{deleteElements:i}=Xg(),r=fc(e,{actInsideInputWithModifier:!1}),o=fc(t,{target:z6});b.useEffect(()=>{if(r){const{edges:c,nodes:u}=n.getState();i({nodes:u.filter(mk),edges:c.filter(mk)}),n.setState({nodesSelectionActive:!1})}},[r]),b.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function D6(e){const t=qt();b.useEffect(()=>{const n=()=>{var r,o,c,u;if(!e.current||!(((o=(r=e.current).checkVisibility)==null?void 0:o.call(r))??!0))return!1;const i=Wg(e.current);(i.height===0||i.width===0)&&((u=(c=t.getState()).onError)==null||u.call(c,"004",_i.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){n(),window.addEventListener("resize",n);const i=new ResizeObserver(()=>n());return i.observe(e.current),()=>{window.removeEventListener("resize",n),i&&e.current&&i.unobserve(e.current)}}},[])}const Qd={position:"absolute",width:"100%",height:"100%",top:0,left:0},F6=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function U6({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panActivationKeyPressed:r,panOnScrollSpeed:o=.5,panOnScrollMode:c=$a.Free,zoomOnDoubleClick:u=!0,panOnDrag:d=!0,defaultViewport:h,translateExtent:m,minZoom:g,maxZoom:p,zoomActivationKeyCode:x,preventScrolling:y=!0,children:S,noWheelClassName:N,noPanClassName:k,onViewportChange:E,isControlledViewport:j,paneClickDistance:A,selectionOnDrag:P}){const L=qt(),B=b.useRef(null),{userSelectionActive:V,lib:M,connectionInProgress:z}=wt(F6,nn),D=fc(x),U=b.useRef();D6(B);const I=b.useCallback(T=>{E==null||E({x:T[0],y:T[1],zoom:T[2]}),j||L.setState({transform:T})},[E,j]);return b.useEffect(()=>{if(B.current){U.current=ZU({domNode:B.current,minZoom:g,maxZoom:p,translateExtent:m,viewport:h,onDraggingChange:F=>L.setState(H=>H.paneDragging===F?H:{paneDragging:F}),onPanZoomStart:(F,H)=>{const{onViewportChangeStart:Z,onMoveStart:G}=L.getState();G==null||G(F,H),Z==null||Z(H)},onPanZoom:(F,H)=>{const{onViewportChange:Z,onMove:G}=L.getState();G==null||G(F,H),Z==null||Z(H)},onPanZoomEnd:(F,H)=>{const{onViewportChangeEnd:Z,onMoveEnd:G}=L.getState();G==null||G(F,H),Z==null||Z(H)}});const{x:T,y:O,zoom:$}=U.current.getViewport();return L.setState({panZoom:U.current,transform:[T,O,$],domNode:B.current.closest(".react-flow")}),()=>{var F;(F=U.current)==null||F.destroy()}}},[]),b.useEffect(()=>{var T;(T=U.current)==null||T.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panActivationKeyPressed:r,panOnScrollSpeed:o,panOnScrollMode:c,zoomOnDoubleClick:u,panOnDrag:d,zoomActivationKeyPressed:D,preventScrolling:y,noPanClassName:k,userSelectionActive:V,noWheelClassName:N,lib:M,onTransformChange:I,connectionInProgress:z,selectionOnDrag:P,paneClickDistance:A})},[e,t,n,i,r,o,c,u,d,D,y,k,V,N,M,I,z,P,A]),s.jsx("div",{className:"react-flow__renderer",ref:B,style:Qd,children:S})}const B6=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function H6(){const{userSelectionActive:e,userSelectionRect:t}=wt(B6,nn);return e&&t?s.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Em=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Z6=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function W6({isSelecting:e,selectionKeyPressed:t,selectionMode:n=uc.Full,panOnDrag:i,autoPanOnSelection:r,paneClickDistance:o,selectionOnDrag:c,onSelectionStart:u,onSelectionEnd:d,onPaneClick:h,onPaneContextMenu:m,onPaneScroll:g,onPaneMouseEnter:p,onPaneMouseMove:x,onPaneMouseLeave:y,children:S}){const N=b.useRef(0),k=qt(),{userSelectionActive:E,elementsSelectable:j,dragging:A,panBy:P,autoPanSpeed:L}=wt(Z6,nn),B=j&&(e||E),V=b.useRef(null),M=b.useRef(),z=b.useRef(new Set),D=b.useRef(new Set),U=b.useRef(!1),I=b.useRef(!1),T=b.useRef({x:0,y:0}),O=b.useRef(!1),$=ie=>{if(I.current||U.current||k.getState().connection.inProgress){I.current=!1,U.current=!1;return}h==null||h(ie),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},F=ie=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){ie.preventDefault();return}m==null||m(ie)},H=g?ie=>g(ie):void 0,Z=ie=>{I.current&&(ie.stopPropagation(),I.current=!1)},G=ie=>{var Ge,Te;if(ie.pointerType==="touch"&&i!==!1&&!t)return;const{domNode:pe,transform:Ce}=k.getState();if(M.current=pe==null?void 0:pe.getBoundingClientRect(),!M.current)return;const fe=ie.target===V.current;if(!fe&&!!ie.target.closest(".nokey")||!e||!(c&&fe||t)||ie.button!==0||!ie.isPrimary)return;(Te=(Ge=ie.target)==null?void 0:Ge.setPointerCapture)==null||Te.call(Ge,ie.pointerId),I.current=!1;const{x:xe,y:De}=ji(ie.nativeEvent,M.current),Me=Ac({x:xe,y:De},Ce);k.setState({userSelectionRect:{width:0,height:0,startX:Me.x,startY:Me.y,x:xe,y:De}}),fe||(ie.stopPropagation(),ie.preventDefault())};function q(ie,pe){const{userSelectionRect:Ce}=k.getState();if(!Ce)return;const{transform:fe,nodeLookup:ve,edgeLookup:ue,connectionLookup:xe,triggerNodeChanges:De,triggerEdgeChanges:Me,defaultEdgeOptions:Ge}=k.getState(),Te={x:Ce.startX,y:Ce.startY},{x:tt,y:et}=Wo(Te,fe),St={startX:Te.x,startY:Te.y,x:ie<tt?ie:tt,y:pe<et?pe:et,width:Math.abs(ie-tt),height:Math.abs(pe-et)},zn=z.current,rn=D.current;z.current=new Set(Bg(ve,St,fe,n===uc.Partial,!0).map(un=>un.id)),D.current=new Set;const cn=(Ge==null?void 0:Ge.selectable)??!0;for(const un of z.current){const an=xe.get(un);if(an)for(const{edgeId:on}of an.values()){const Ft=ue.get(on);Ft&&(Ft.selectable??cn)&&D.current.add(on)}}if(!Lb(zn,z.current)){const un=No(ve,z.current,!0);De(un)}if(!Lb(rn,D.current)){const un=No(ue,D.current);Me(un)}k.setState({userSelectionRect:St,userSelectionActive:!0,nodesSelectionActive:!1})}function X(){if(!r||!M.current)return;const[ie,pe]=Hg(T.current,M.current,L);P({x:ie,y:pe}).then(Ce=>{if(!I.current||!Ce){N.current=requestAnimationFrame(X);return}const{x:fe,y:ve}=T.current;q(fe,ve),N.current=requestAnimationFrame(X)})}const Y=()=>{cancelAnimationFrame(N.current),N.current=0,O.current=!1};b.useEffect(()=>()=>Y(),[]);const re=ie=>{const{userSelectionRect:pe,transform:Ce,resetSelectedElements:fe}=k.getState();if(!M.current||!pe)return;const{x:ve,y:ue}=ji(ie.nativeEvent,M.current);T.current={x:ve,y:ue};const xe=Wo({x:pe.startX,y:pe.startY},Ce);if(!I.current){const De=t?0:o;if(Math.hypot(ve-xe.x,ue-xe.y)<=De)return;fe(),u==null||u(ie)}I.current=!0,O.current||(X(),O.current=!0),q(ve,ue)},ee=ie=>{var pe,Ce;if(!B){ie.target===V.current&&k.getState().connection.inProgress&&(U.current=!0);return}ie.button===0&&((Ce=(pe=ie.target)==null?void 0:pe.releasePointerCapture)==null||Ce.call(pe,ie.pointerId),!E&&ie.target===V.current&&k.getState().userSelectionRect&&($==null||$(ie)),k.setState({userSelectionActive:!1,userSelectionRect:null}),I.current&&(d==null||d(ie),k.setState({nodesSelectionActive:z.current.size>0})),Y())},se=ie=>{var pe,Ce;(Ce=(pe=ie.target)==null?void 0:pe.releasePointerCapture)==null||Ce.call(pe,ie.pointerId),Y()},ne=i===!0||Array.isArray(i)&&i.includes(0);return s.jsxs("div",{className:Nn(["react-flow__pane",{draggable:ne,dragging:A,selection:e}]),onClick:B?void 0:Em($,V),onContextMenu:Em(F,V),onWheel:Em(H,V),onPointerEnter:B?void 0:p,onPointerMove:B?re:x,onPointerUp:ee,onPointerCancel:B?se:void 0,onPointerDownCapture:B?G:void 0,onClickCapture:B?Z:void 0,onPointerLeave:y,ref:V,style:Qd,children:[S,s.jsx(H6,{})]})}function Lp({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:o,multiSelectionActive:c,nodeLookup:u,onError:d}=t.getState(),h=u.get(e);if(!h){d==null||d("012",_i.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&c)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var m;return(m=i==null?void 0:i.current)==null?void 0:m.blur()})):r([e])}function g_({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:r,isSelectable:o,nodeClickDistance:c}){const u=qt(),[d,h]=b.useState(!1),m=b.useRef();return b.useEffect(()=>{if(!t)return m.current=IU({getStoreItems:()=>u.getState(),onNodeMouseDown:g=>{Lp({id:g,store:u,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}}),()=>{var g;(g=m.current)==null||g.destroy(),m.current=void 0}},[t,u,e]),b.useEffect(()=>{t||!e.current||!m.current||m.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:o,nodeId:r,nodeClickDistance:c})},[n,i,t,o,e,r,c]),d}const V6=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function x_(){const e=qt();return b.useCallback(n=>{const{nodeExtent:i,snapToGrid:r,snapGrid:o,nodesDraggable:c,onError:u,updateNodePositions:d,nodeLookup:h,nodeOrigin:m}=e.getState(),g=new Map,p=V6(c),x=r?o[0]:5,y=r?o[1]:5,S=n.direction.x*x*n.factor,N=n.direction.y*y*n.factor;for(const[,k]of h){if(!p(k))continue;let E={x:k.internals.positionAbsolute.x+S,y:k.internals.positionAbsolute.y+N};r&&(E=Cc(E,o));const{position:j,positionAbsolute:A}=OS({nodeId:k.id,nextPosition:E,nodeLookup:h,nodeExtent:i,nodeOrigin:m,onError:u});k.position=j,k.internals.positionAbsolute=A,g.set(k.id,k)}d(g)},[])}const Qg=b.createContext(null),q6=Qg.Provider;Qg.Consumer;const v_=()=>b.useContext(Qg),G6=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),y_=b.createContext(null);function K6({children:e}){const t=wt(G6,nn);return s.jsx(y_.Provider,{value:t,children:e})}function Y6(){const e=b.useContext(y_);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const X6={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Q6=(e,t,n)=>i=>{const{connectionClickStartHandle:r,connectionMode:o,connection:c}=i,{fromHandle:u,toHandle:d,isValid:h}=c;if(!u&&!r)return X6;const m=(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.type)===n;return{connectingFrom:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n,connectingTo:m,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:o===Ho.Strict?(u==null?void 0:u.type)!==n:e!==(u==null?void 0:u.nodeId)||t!==(u==null?void 0:u.id),connectionInProcess:!!u,clickConnectionInProcess:!!r,valid:m&&h}};function J6({type:e="source",position:t=Je.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:o=!0,id:c,onConnect:u,children:d,className:h,onMouseDown:m,onTouchStart:g,...p},x){var O,$;const y=c||null,S=e==="target",N=qt(),k=v_(),{connectOnClick:E,noPanClassName:j,rfId:A}=Y6(),{connectingFrom:P,connectingTo:L,clickConnecting:B,isPossibleEndHandle:V,connectionInProcess:M,clickConnectionInProcess:z,valid:D}=wt(Q6(k,y,e),nn);k||($=(O=N.getState()).onError)==null||$.call(O,"010",_i.error010());const U=F=>{const{defaultEdgeOptions:H,onConnect:Z,hasDefaultEdges:G}=N.getState(),q={...H,...F};if(G){const{edges:X,setEdges:Y,onError:re}=N.getState();Y(T6(q,X,{onError:re}))}Z==null||Z(q),u==null||u(q)},I=F=>{if(!k)return;const H=WS(F.nativeEvent);if(r&&(H&&F.button===0||!H)){const Z=N.getState();zp.onPointerDown(F.nativeEvent,{handleDomNode:F.currentTarget,autoPanOnConnect:Z.autoPanOnConnect,connectionMode:Z.connectionMode,connectionRadius:Z.connectionRadius,domNode:Z.domNode,nodeLookup:Z.nodeLookup,lib:Z.lib,isTarget:S,handleId:y,nodeId:k,flowId:Z.rfId,panBy:Z.panBy,cancelConnection:Z.cancelConnection,onConnectStart:Z.onConnectStart,onConnectEnd:(...G)=>{var q,X;return(X=(q=N.getState()).onConnectEnd)==null?void 0:X.call(q,...G)},updateConnection:Z.updateConnection,onConnect:U,isValidConnection:n||((...G)=>{var q,X;return((X=(q=N.getState()).isValidConnection)==null?void 0:X.call(q,...G))??!0}),getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,autoPanSpeed:Z.autoPanSpeed,dragThreshold:Z.connectionDragThreshold})}H?m==null||m(F):g==null||g(F)},T=F=>{const{onClickConnectStart:H,onClickConnectEnd:Z,connectionClickStartHandle:G,connectionMode:q,isValidConnection:X,lib:Y,rfId:re,nodeLookup:ee,connection:se}=N.getState();if(!k||!G&&!r)return;if(!G){H==null||H(F.nativeEvent,{nodeId:k,handleId:y,handleType:e}),N.setState({connectionClickStartHandle:{nodeId:k,type:e,id:y}});return}const ne=HS(F.target),ie=n||X,{connection:pe,isValid:Ce}=zp.isValid(F.nativeEvent,{handle:{nodeId:k,id:y,type:e},connectionMode:q,fromNodeId:G.nodeId,fromHandleId:G.id||null,fromType:G.type,isValidConnection:ie,flowId:re,doc:ne,lib:Y,nodeLookup:ee});Ce&&pe&&U(pe);const fe=structuredClone(se);delete fe.inProgress,fe.toPosition=fe.toHandle?fe.toHandle.position:null,Z==null||Z(F,fe),N.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":y,"data-nodeid":k,"data-handlepos":t,"data-id":`${A}-${k}-${y}-${e}`,className:Nn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",j,h,{source:!S,target:S,connectable:i,connectablestart:r,connectableend:o,clickconnecting:B,connectingfrom:P,connectingto:L,valid:D,connectionindicator:i&&(!M||V)&&(M||z?o:r)}]),onMouseDown:I,onTouchStart:I,onClick:E?T:void 0,ref:x,...p,children:d})}const Gr=b.memo(f_(J6));function eB({data:e,isConnectable:t,sourcePosition:n=Je.Bottom}){return s.jsxs(s.Fragment,{children:[e==null?void 0:e.label,s.jsx(Gr,{type:"source",position:n,isConnectable:t})]})}function tB({data:e,isConnectable:t,targetPosition:n=Je.Top,sourcePosition:i=Je.Bottom}){return s.jsxs(s.Fragment,{children:[s.jsx(Gr,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,s.jsx(Gr,{type:"source",position:i,isConnectable:t})]})}function nB(){return null}function sB({data:e,isConnectable:t,targetPosition:n=Je.Top}){return s.jsxs(s.Fragment,{children:[s.jsx(Gr,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Ed={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},pk={input:eB,default:tB,output:sB,group:nB};function iB(e){var t,n,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??((n=e.style)==null?void 0:n.height)}:{width:e.width??((i=e.style)==null?void 0:i.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const rB=e=>{const{width:t,height:n,x:i,y:r}=Ec(e.nodeLookup,{filter:o=>!!o.selected});return{width:Ni(t)?t:null,height:Ni(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${r}px)`}};function aB({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const i=qt(),{width:r,height:o,transformString:c,userSelectionActive:u}=wt(rB,nn),d=x_(),h=b.useRef(null);b.useEffect(()=>{var x;n||(x=h.current)==null||x.focus({preventScroll:!0})},[n]);const m=!u&&r!==null&&o!==null;if(g_({nodeRef:h,disabled:!m}),!m)return null;const g=e?x=>{const y=i.getState().nodes.filter(S=>S.selected);e(x,y)}:void 0,p=x=>{Object.prototype.hasOwnProperty.call(Ed,x.key)&&(x.preventDefault(),d({direction:Ed[x.key],factor:x.shiftKey?4:1}))};return s.jsx("div",{className:Nn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c},children:s.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:r,height:o}})})}const gk=typeof window<"u"?window:void 0,oB=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function b_({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:c,paneClickDistance:u,deleteKeyCode:d,selectionKeyCode:h,selectionOnDrag:m,selectionMode:g,onSelectionStart:p,onSelectionEnd:x,multiSelectionKeyCode:y,panActivationKeyCode:S,zoomActivationKeyCode:N,elementsSelectable:k,zoomOnScroll:E,zoomOnPinch:j,panOnScroll:A,panOnScrollSpeed:P,panOnScrollMode:L,zoomOnDoubleClick:B,panOnDrag:V,autoPanOnSelection:M,defaultViewport:z,translateExtent:D,minZoom:U,maxZoom:I,preventScrolling:T,onSelectionContextMenu:O,noWheelClassName:$,noPanClassName:F,disableKeyboardA11y:H,onViewportChange:Z,isControlledViewport:G}){const{nodesSelectionActive:q,userSelectionActive:X}=wt(oB,nn),Y=fc(h,{target:gk}),re=fc(S,{target:gk}),ee=re||V,se=re||A,ne=m&&ee!==!0,ie=Y||X||ne;return L6({deleteKeyCode:d,multiSelectionKeyCode:y}),s.jsx(U6,{onPaneContextMenu:o,elementsSelectable:k,zoomOnScroll:E,zoomOnPinch:j,panOnScroll:se,panActivationKeyPressed:re,panOnScrollSpeed:P,panOnScrollMode:L,zoomOnDoubleClick:B,panOnDrag:!Y&&ee,defaultViewport:z,translateExtent:D,minZoom:U,maxZoom:I,zoomActivationKeyCode:N,preventScrolling:T,noWheelClassName:$,noPanClassName:F,onViewportChange:Z,isControlledViewport:G,paneClickDistance:u,selectionOnDrag:ne,children:s.jsxs(W6,{onSelectionStart:p,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:c,panOnDrag:ee,autoPanOnSelection:M,isSelecting:!!ie,selectionMode:g,selectionKeyPressed:Y,paneClickDistance:u,selectionOnDrag:ne,children:[e,q&&s.jsx(aB,{onSelectionContextMenu:O,noPanClassName:F,disableKeyboardA11y:H})]})})}b_.displayName="FlowRenderer";const lB=b.memo(b_),cB=e=>t=>e?Bg(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function uB(e){return wt(b.useCallback(cB(e),[e]),nn)}const dB=e=>e.updateNodeInternals;function hB(){const e=wt(dB),[t]=b.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(r=>{const o=r.target.getAttribute("data-id");i.set(o,{id:o,nodeElement:r.target,force:!0})}),e(i)}));return b.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function fB({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const r=qt(),o=b.useRef(null),c=b.useRef(null),u=b.useRef(e.sourcePosition),d=b.useRef(e.targetPosition),h=b.useRef(t),m=n&&!!e.internals.handleBounds;return b.useEffect(()=>{o.current&&!e.hidden&&(!m||c.current!==o.current)&&(c.current&&(i==null||i.unobserve(c.current)),i==null||i.observe(o.current),c.current=o.current)},[m,e.hidden]),b.useEffect(()=>()=>{c.current&&(i==null||i.unobserve(c.current),c.current=null)},[]),b.useEffect(()=>{if(o.current){const g=h.current!==t,p=u.current!==e.sourcePosition,x=d.current!==e.targetPosition;(g||p||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 mB({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:r,onContextMenu:o,onDoubleClick:c,nodesDraggable:u,elementsSelectable:d,nodesConnectable:h,nodesFocusable:m,resizeObserver:g,noDragClassName:p,noPanClassName:x,disableKeyboardA11y:y,rfId:S,nodeTypes:N,nodeClickDistance:k,onError:E}){const{node:j,internals:A,isParent:P}=wt(ie=>{const pe=ie.nodeLookup.get(e),Ce=ie.parentLookup.has(e);return{node:pe,internals:pe.internals,isParent:Ce}},nn);let L=j.type||"default",B=(N==null?void 0:N[L])||pk[L];B===void 0&&(E==null||E("003",_i.error003(L)),L="default",B=(N==null?void 0:N.default)||pk.default);const V=!!(j.draggable||u&&typeof j.draggable>"u"),M=!!(j.selectable||d&&typeof j.selectable>"u"),z=!!(j.connectable||h&&typeof j.connectable>"u"),D=!!(j.focusable||m&&typeof j.focusable>"u"),U=qt(),I=FS(j),T=fB({node:j,nodeType:L,hasDimensions:I,resizeObserver:g}),O=g_({nodeRef:T,disabled:j.hidden||!V,noDragClassName:p,handleSelector:j.dragHandle,nodeId:e,isSelectable:M,nodeClickDistance:k}),$=x_();if(j.hidden)return null;const F=Ai(j),H=iB(j),Z=M||V||t||n||i||r,G=n?ie=>n(ie,{...A.userNode}):void 0,q=i?ie=>i(ie,{...A.userNode}):void 0,X=r?ie=>r(ie,{...A.userNode}):void 0,Y=o?ie=>o(ie,{...A.userNode}):void 0,re=c?ie=>c(ie,{...A.userNode}):void 0,ee=ie=>{const{selectNodesOnDrag:pe,nodeDragThreshold:Ce}=U.getState();M&&(!pe||!V||Ce>0)&&Lp({id:e,store:U,nodeRef:T}),t&&t(ie,{...A.userNode})},se=ie=>{if(!(ZS(ie.nativeEvent)||y)){if(TS.includes(ie.key)&&M){const pe=ie.key==="Escape";Lp({id:e,store:U,unselect:pe,nodeRef:T})}else if(V&&j.selected&&Object.prototype.hasOwnProperty.call(Ed,ie.key)){ie.preventDefault();const{ariaLabelConfig:pe}=U.getState();U.setState({ariaLiveMessage:pe["node.a11yDescription.ariaLiveMessage"]({direction:ie.key.replace("Arrow","").toLowerCase(),x:~~A.positionAbsolute.x,y:~~A.positionAbsolute.y})}),$({direction:Ed[ie.key],factor:ie.shiftKey?4:1})}}},ne=()=>{var xe;if(y||!((xe=T.current)!=null&&xe.matches(":focus-visible")))return;const{transform:ie,width:pe,height:Ce,autoPanOnNodeFocus:fe,setCenter:ve}=U.getState();if(!fe)return;Bg(new Map([[e,j]]),{x:0,y:0,width:pe,height:Ce},ie,!0).length>0||ve(j.position.x+F.width/2,j.position.y+F.height/2,{zoom:ie[2]})};return s.jsx("div",{className:Nn(["react-flow__node",`react-flow__node-${L}`,{[x]:V},j.className,{selected:j.selected,selectable:M,parent:P,draggable:V,dragging:O}]),ref:T,style:{zIndex:A.z,transform:`translate(${A.positionAbsolute.x}px,${A.positionAbsolute.y}px)`,pointerEvents:Z?"all":"none",visibility:I?"visible":"hidden",...j.style,...H},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:G,onMouseMove:q,onMouseLeave:X,onContextMenu:Y,onClick:ee,onDoubleClick:re,onKeyDown:D?se:void 0,tabIndex:D?0:void 0,onFocus:D?ne:void 0,role:j.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${c_}-${S}`,"aria-label":j.ariaLabel,...j.domAttributes,children:s.jsx(q6,{value:e,children:s.jsx(B,{id:e,data:j.data,type:L,positionAbsoluteX:A.positionAbsolute.x,positionAbsoluteY:A.positionAbsolute.y,selected:j.selected??!1,selectable:M,draggable:V,deletable:j.deletable??!0,isConnectable:z,sourcePosition:j.sourcePosition,targetPosition:j.targetPosition,dragging:O,dragHandle:j.dragHandle,zIndex:A.z,parentId:j.parentId,...F})})})}var pB=b.memo(mB);const gB=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function k_(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:i,onError:r}=wt(gB,nn),o=uB(e.onlyRenderVisibleElements),c=hB();return s.jsx("div",{className:"react-flow__nodes",style:Qd,children:o.map(u=>s.jsx(pB,{id:u,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:r},u))})}k_.displayName="NodeRenderer";const xB=b.memo(k_);function vB(e){return wt(b.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const i=[];if(n.width&&n.height)for(const r of n.edges){const o=n.nodeLookup.get(r.source),c=n.nodeLookup.get(r.target);o&&c&&dU({sourceNode:o,targetNode:c,width:n.width,height:n.height,transform:n.transform})&&i.push(r.id)}return i},[e]),nn)}const yB=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return s.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},bB=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return s.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},xk={[wd.Arrow]:yB,[wd.ArrowClosed]:bB};function kB(e){const t=qt();return b.useMemo(()=>{var r,o;return Object.prototype.hasOwnProperty.call(xk,e)?xk[e]:((o=(r=t.getState()).onError)==null||o.call(r,"009",_i.error009(e)),null)},[e])}const NB=({id:e,type:t,color:n,width:i=12.5,height:r=12.5,markerUnits:o="strokeWidth",strokeWidth:c,orient:u="auto-start-reverse"})=>{const d=kB(t);return d?s.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:s.jsx(d,{color:n,strokeWidth:c})}):null},N_=({defaultColor:e,rfId:t})=>{const n=wt(o=>o.edges),i=wt(o=>o.defaultEdgeOptions),r=b.useMemo(()=>yU(n,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[n,i,t,e]);return r.length?s.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:s.jsx("defs",{children:r.map(o=>s.jsx(NB,{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};N_.displayName="MarkerDefinitions";var jB=b.memo(N_);function j_({x:e,y:t,label:n,labelStyle:i,labelShowBg:r=!0,labelBgStyle:o,labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...m}){const[g,p]=b.useState({x:1,y:0,width:0,height:0}),x=Nn(["react-flow__edge-textwrapper",h]),y=b.useRef(null);return b.useEffect(()=>{if(y.current){const S=y.current.getBBox();p({x:S.x,y:S.y,width:S.width,height:S.height})}},[n]),n?s.jsxs("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:x,visibility:g.width?"visible":"hidden",...m,children:[r&&s.jsx("rect",{width:g.width+2*c[0],x:-c[0],y:-c[1],height:g.height+2*c[1],className:"react-flow__edge-textbg",style:o,rx:u,ry:u}),s.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:y,style:i,children:n}),d]}):null}j_.displayName="EdgeText";const wB=b.memo(j_);function Jd({path:e,labelX:t,labelY:n,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,interactionWidth:h=20,...m}){return s.jsxs(s.Fragment,{children:[s.jsx("path",{...m,d:e,fill:"none",className:Nn(["react-flow__edge-path",m.className])}),h?s.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,i&&Ni(t)&&Ni(n)?s.jsx(wB,{x:t,y:n,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d}):null]})}function vk({pos:e,x1:t,y1:n,x2:i,y2:r}){return e===Je.Left||e===Je.Right?[.5*(t+i),n]:[t,.5*(n+r)]}function w_({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:r,targetPosition:o=Je.Top}){const[c,u]=vk({pos:n,x1:e,y1:t,x2:i,y2:r}),[d,h]=vk({pos:o,x1:i,y1:r,x2:e,y2:t}),[m,g,p,x]=VS({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:c,sourceControlY:u,targetControlX:d,targetControlY:h});return[`M${e},${t} C${c},${u} ${d},${h} ${i},${r}`,m,g,p,x]}function S_(e){return b.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,sourcePosition:c,targetPosition:u,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:x,style:y,markerEnd:S,markerStart:N,interactionWidth:k})=>{const[E,j,A]=w_({sourceX:n,sourceY:i,sourcePosition:c,targetX:r,targetY:o,targetPosition:u}),P=e.isInternal?void 0:t;return s.jsx(Jd,{id:P,path:E,labelX:j,labelY:A,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:x,style:y,markerEnd:S,markerStart:N,interactionWidth:k})})}const SB=S_({isInternal:!1}),__=S_({isInternal:!0});SB.displayName="SimpleBezierEdge";__.displayName="SimpleBezierEdgeInternal";function E_(e){return b.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:g,style:p,sourcePosition:x=Je.Bottom,targetPosition:y=Je.Top,markerEnd:S,markerStart:N,pathOptions:k,interactionWidth:E})=>{const[j,A,P]=Rp({sourceX:n,sourceY:i,sourcePosition:x,targetX:r,targetY:o,targetPosition:y,borderRadius:k==null?void 0:k.borderRadius,offset:k==null?void 0:k.offset,stepPosition:k==null?void 0:k.stepPosition}),L=e.isInternal?void 0:t;return s.jsx(Jd,{id:L,path:j,labelX:A,labelY:P,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:g,style:p,markerEnd:S,markerStart:N,interactionWidth:E})})}const C_=E_({isInternal:!1}),A_=E_({isInternal:!0});C_.displayName="SmoothStepEdge";A_.displayName="SmoothStepEdgeInternal";function I_(e){return b.memo(({id:t,...n})=>{var r;const i=e.isInternal?void 0:t;return s.jsx(C_,{...n,id:i,pathOptions:b.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const _B=I_({isInternal:!1}),T_=I_({isInternal:!0});_B.displayName="StepEdge";T_.displayName="StepEdgeInternal";function $_(e){return b.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:g,style:p,markerEnd:x,markerStart:y,interactionWidth:S})=>{const[N,k,E]=KS({sourceX:n,sourceY:i,targetX:r,targetY:o}),j=e.isInternal?void 0:t;return s.jsx(Jd,{id:j,path:N,labelX:k,labelY:E,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:g,style:p,markerEnd:x,markerStart:y,interactionWidth:S})})}const EB=$_({isInternal:!1}),M_=$_({isInternal:!0});EB.displayName="StraightEdge";M_.displayName="StraightEdgeInternal";function R_(e){return b.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,sourcePosition:c=Je.Bottom,targetPosition:u=Je.Top,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:x,style:y,markerEnd:S,markerStart:N,pathOptions:k,interactionWidth:E})=>{const[j,A,P]=qS({sourceX:n,sourceY:i,sourcePosition:c,targetX:r,targetY:o,targetPosition:u,curvature:k==null?void 0:k.curvature}),L=e.isInternal?void 0:t;return s.jsx(Jd,{id:L,path:j,labelX:A,labelY:P,label:d,labelStyle:h,labelShowBg:m,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:x,style:y,markerEnd:S,markerStart:N,interactionWidth:E})})}const CB=R_({isInternal:!1}),O_=R_({isInternal:!0});CB.displayName="BezierEdge";O_.displayName="BezierEdgeInternal";const yk={default:O_,straight:M_,step:T_,smoothstep:A_,simplebezier:__},bk={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},AB=(e,t,n)=>n===Je.Left?e-t:n===Je.Right?e+t:e,IB=(e,t,n)=>n===Je.Top?e-t:n===Je.Bottom?e+t:e,kk="react-flow__edgeupdater";function Nk({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:r,onMouseEnter:o,onMouseOut:c,type:u}){return s.jsx("circle",{onMouseDown:r,onMouseEnter:o,onMouseOut:c,className:Nn([kk,`${kk}-${u}`]),cx:AB(t,i,e),cy:IB(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function TB({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:r,targetX:o,targetY:c,sourcePosition:u,targetPosition:d,onReconnect:h,onReconnectStart:m,onReconnectEnd:g,setReconnecting:p,setUpdateHover:x}){const y=qt(),S=(A,P)=>{if(A.button!==0)return;const{autoPanOnConnect:L,domNode:B,connectionMode:V,connectionRadius:M,lib:z,onConnectStart:D,cancelConnection:U,nodeLookup:I,rfId:T,panBy:O,updateConnection:$}=y.getState(),F=P.type==="target",H=(q,X)=>{p(!1),g==null||g(q,n,P.type,X)},Z=q=>h==null?void 0:h(n,q),G=(q,X)=>{p(!0),m==null||m(A,n,P.type),D==null||D(q,X)};zp.onPointerDown(A.nativeEvent,{autoPanOnConnect:L,connectionMode:V,connectionRadius:M,domNode:B,handleId:P.id,nodeId:P.nodeId,nodeLookup:I,isTarget:F,edgeUpdaterType:P.type,lib:z,flowId:T,cancelConnection:U,panBy:O,isValidConnection:(...q)=>{var X,Y;return((Y=(X=y.getState()).isValidConnection)==null?void 0:Y.call(X,...q))??!0},onConnect:Z,onConnectStart:G,onConnectEnd:(...q)=>{var X,Y;return(Y=(X=y.getState()).onConnectEnd)==null?void 0:Y.call(X,...q)},onReconnectEnd:H,updateConnection:$,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:A.currentTarget})},N=A=>S(A,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),k=A=>S(A,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),E=()=>x(!0),j=()=>x(!1);return s.jsxs(s.Fragment,{children:[(e===!0||e==="source")&&s.jsx(Nk,{position:u,centerX:i,centerY:r,radius:t,onMouseDown:N,onMouseEnter:E,onMouseOut:j,type:"source"}),(e===!0||e==="target")&&s.jsx(Nk,{position:d,centerX:o,centerY:c,radius:t,onMouseDown:k,onMouseEnter:E,onMouseOut:j,type:"target"})]})}function $B({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:r,onDoubleClick:o,onContextMenu:c,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,reconnectRadius:m,onReconnect:g,onReconnectStart:p,onReconnectEnd:x,rfId:y,edgeTypes:S,noPanClassName:N,onError:k,disableKeyboardA11y:E}){let j=wt(ve=>ve.edgeLookup.get(e));const A=wt(ve=>ve.defaultEdgeOptions);j=A?{...A,...j}:j;let P=j.type||"default",L=(S==null?void 0:S[P])||yk[P];L===void 0&&(k==null||k("011",_i.error011(P)),P="default",L=(S==null?void 0:S.default)||yk.default);const B=!!(j.focusable||t&&typeof j.focusable>"u"),V=typeof g<"u"&&(j.reconnectable||n&&typeof j.reconnectable>"u"),M=!!(j.selectable||i&&typeof j.selectable>"u"),z=b.useRef(null),[D,U]=b.useState(!1),[I,T]=b.useState(!1),O=qt(),{zIndex:$=j.zIndex,sourceX:F,sourceY:H,targetX:Z,targetY:G,sourcePosition:q,targetPosition:X}=wt(b.useCallback(ve=>{const ue=ve.nodeLookup.get(j.source),xe=ve.nodeLookup.get(j.target);if(!ue||!xe)return bk;const De=vU({id:e,sourceNode:ue,targetNode:xe,sourceHandle:j.sourceHandle||null,targetHandle:j.targetHandle||null,connectionMode:ve.connectionMode,onError:k}),Me=uU({selected:j.selected,zIndex:j.zIndex,sourceNode:ue,targetNode:xe,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...De||bk,zIndex:Me}},[j.source,j.target,j.sourceHandle,j.targetHandle,j.selected,j.zIndex,k]),nn),Y=b.useMemo(()=>j.markerStart?`url('#${Op(j.markerStart,y)}')`:void 0,[j.markerStart,y]),re=b.useMemo(()=>j.markerEnd?`url('#${Op(j.markerEnd,y)}')`:void 0,[j.markerEnd,y]);if(j.hidden||F===null||H===null||Z===null||G===null)return null;const ee=ve=>{var Me;const{addSelectedEdges:ue,unselectNodesAndEdges:xe,multiSelectionActive:De}=O.getState();M&&(O.setState({nodesSelectionActive:!1}),j.selected&&De?(xe({nodes:[],edges:[j]}),(Me=z.current)==null||Me.blur()):ue([e])),r&&r(ve,j)},se=o?ve=>{o(ve,{...j})}:void 0,ne=c?ve=>{c(ve,{...j})}:void 0,ie=u?ve=>{u(ve,{...j})}:void 0,pe=d?ve=>{d(ve,{...j})}:void 0,Ce=h?ve=>{h(ve,{...j})}:void 0,fe=ve=>{var ue;if(!E&&TS.includes(ve.key)&&M){const{unselectNodesAndEdges:xe,addSelectedEdges:De}=O.getState();ve.key==="Escape"?((ue=z.current)==null||ue.blur(),xe({edges:[j]})):De([e])}};return s.jsx("svg",{style:{zIndex:$},children:s.jsxs("g",{className:Nn(["react-flow__edge",`react-flow__edge-${P}`,j.className,N,{selected:j.selected,animated:j.animated,inactive:!M&&!r,updating:D,selectable:M}]),onClick:ee,onDoubleClick:se,onContextMenu:ne,onMouseEnter:ie,onMouseMove:pe,onMouseLeave:Ce,onKeyDown:B?fe:void 0,tabIndex:B?0:void 0,role:j.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":j.ariaLabel===null?void 0:j.ariaLabel||`Edge from ${j.source} to ${j.target}`,"aria-describedby":B?`${u_}-${y}`:void 0,ref:z,...j.domAttributes,children:[!I&&s.jsx(L,{id:e,source:j.source,target:j.target,type:j.type,selected:j.selected,animated:j.animated,selectable:M,deletable:j.deletable??!0,label:j.label,labelStyle:j.labelStyle,labelShowBg:j.labelShowBg,labelBgStyle:j.labelBgStyle,labelBgPadding:j.labelBgPadding,labelBgBorderRadius:j.labelBgBorderRadius,sourceX:F,sourceY:H,targetX:Z,targetY:G,sourcePosition:q,targetPosition:X,data:j.data,style:j.style,sourceHandleId:j.sourceHandle,targetHandleId:j.targetHandle,markerStart:Y,markerEnd:re,pathOptions:"pathOptions"in j?j.pathOptions:void 0,interactionWidth:j.interactionWidth}),V&&s.jsx(TB,{edge:j,isReconnectable:V,reconnectRadius:m,onReconnect:g,onReconnectStart:p,onReconnectEnd:x,sourceX:F,sourceY:H,targetX:Z,targetY:G,sourcePosition:q,targetPosition:X,setUpdateHover:U,setReconnecting:T})]})})}var MB=b.memo($B);const RB=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function P_({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:r,onReconnect:o,onEdgeContextMenu:c,onEdgeMouseEnter:u,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:m,reconnectRadius:g,onEdgeDoubleClick:p,onReconnectStart:x,onReconnectEnd:y,disableKeyboardA11y:S}){const{edgesFocusable:N,edgesReconnectable:k,elementsSelectable:E,onError:j}=wt(RB,nn),A=vB(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(jB,{defaultColor:e,rfId:n}),A.map(P=>s.jsx(MB,{id:P,edgesFocusable:N,edgesReconnectable:k,elementsSelectable:E,noPanClassName:r,onReconnect:o,onContextMenu:c,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,onClick:m,reconnectRadius:g,onDoubleClick:p,onReconnectStart:x,onReconnectEnd:y,rfId:n,onError:j,edgeTypes:i,disableKeyboardA11y:S},P))]})}P_.displayName="EdgeRenderer";const OB=b.memo(P_),jk=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function PB({children:e}){const t=qt(),n=b.useRef(null),[i]=b.useState(()=>t.getState().transform);return m_(()=>{let r=null;const o=()=>{const c=t.getState().transform;r&&c[0]===r[0]&&c[1]===r[1]&&c[2]===r[2]||(r=c,n.current&&(n.current.style.transform=jk(c)))};return o(),t.subscribe(o)},[t]),s.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:jk(i)},children:e})}function zB(e){const t=Xg(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const LB=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function DB(e){const t=wt(LB),n=qt();return b.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function FB(e){return e.connection.inProgress?{...e.connection,to:Ac(e.connection.to,e.transform)}:{...e.connection}}function UB(e){return FB}function BB(e){const t=UB();return wt(t,nn)}const HB=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function ZB({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:r,width:o,height:c,isValid:u,inProgress:d}=wt(HB,nn);return!(o&&r&&d)?null:s.jsx("svg",{style:e,width:o,height:c,className:"react-flow__connectionline react-flow__container",children:s.jsx("g",{className:Nn(["react-flow__connection",BS(u)]),children:s.jsx(z_,{style:t,type:n,CustomComponent:i,isValid:u})})})}const z_=({style:e,type:t=Br.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:r,from:o,fromNode:c,fromHandle:u,fromPosition:d,to:h,toNode:m,toHandle:g,toPosition:p,pointer:x}=BB();if(!r)return;if(n)return s.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:c,fromHandle:u,fromX:o.x,fromY:o.y,toX:h.x,toY:h.y,fromPosition:d,toPosition:p,connectionStatus:BS(i),toNode:m,toHandle:g,pointer:x});let y="";const S={sourceX:o.x,sourceY:o.y,sourcePosition:d,targetX:h.x,targetY:h.y,targetPosition:p};switch(t){case Br.Bezier:[y]=qS(S);break;case Br.SimpleBezier:[y]=w_(S);break;case Br.Step:[y]=Rp({...S,borderRadius:0});break;case Br.SmoothStep:[y]=Rp(S);break;default:[y]=KS(S)}return s.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};z_.displayName="ConnectionLine";const WB={};function wk(e=WB){b.useRef(e),qt(),b.useEffect(()=>{},[e])}function VB(){qt(),b.useRef(!1),b.useEffect(()=>{},[])}function L_({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:r,onNodeDoubleClick:o,onEdgeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,onSelectionContextMenu:g,onSelectionStart:p,onSelectionEnd:x,connectionLineType:y,connectionLineStyle:S,connectionLineComponent:N,connectionLineContainerStyle:k,selectionKeyCode:E,selectionOnDrag:j,selectionMode:A,multiSelectionKeyCode:P,panActivationKeyCode:L,zoomActivationKeyCode:B,deleteKeyCode:V,onlyRenderVisibleElements:M,elementsSelectable:z,defaultViewport:D,translateExtent:U,minZoom:I,maxZoom:T,preventScrolling:O,defaultMarkerColor:$,zoomOnScroll:F,zoomOnPinch:H,panOnScroll:Z,panOnScrollSpeed:G,panOnScrollMode:q,zoomOnDoubleClick:X,panOnDrag:Y,autoPanOnSelection:re,onPaneClick:ee,onPaneMouseEnter:se,onPaneMouseMove:ne,onPaneMouseLeave:ie,onPaneScroll:pe,onPaneContextMenu:Ce,paneClickDistance:fe,nodeClickDistance:ve,onEdgeContextMenu:ue,onEdgeMouseEnter:xe,onEdgeMouseMove:De,onEdgeMouseLeave:Me,reconnectRadius:Ge,onReconnect:Te,onReconnectStart:tt,onReconnectEnd:et,noDragClassName:St,noWheelClassName:zn,noPanClassName:rn,disableKeyboardA11y:cn,nodeExtent:un,rfId:an,viewport:on,onViewportChange:Ft,nodesDraggable:Bn}){return wk(e),wk(t),VB(),zB(n),DB(on),s.jsx(lB,{onPaneClick:ee,onPaneMouseEnter:se,onPaneMouseMove:ne,onPaneMouseLeave:ie,onPaneContextMenu:Ce,onPaneScroll:pe,paneClickDistance:fe,deleteKeyCode:V,selectionKeyCode:E,selectionOnDrag:j,selectionMode:A,onSelectionStart:p,onSelectionEnd:x,multiSelectionKeyCode:P,panActivationKeyCode:L,zoomActivationKeyCode:B,elementsSelectable:z,zoomOnScroll:F,zoomOnPinch:H,zoomOnDoubleClick:X,panOnScroll:Z,panOnScrollSpeed:G,panOnScrollMode:q,panOnDrag:Y,autoPanOnSelection:re,defaultViewport:D,translateExtent:U,minZoom:I,maxZoom:T,onSelectionContextMenu:g,preventScrolling:O,noDragClassName:St,noWheelClassName:zn,noPanClassName:rn,disableKeyboardA11y:cn,onViewportChange:Ft,isControlledViewport:!!on,children:s.jsxs(PB,{children:[s.jsx(OB,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:c,onReconnect:Te,onReconnectStart:tt,onReconnectEnd:et,onlyRenderVisibleElements:M,onEdgeContextMenu:ue,onEdgeMouseEnter:xe,onEdgeMouseMove:De,onEdgeMouseLeave:Me,reconnectRadius:Ge,defaultMarkerColor:$,noPanClassName:rn,disableKeyboardA11y:cn,rfId:an}),s.jsx(ZB,{style:S,type:y,component:N,containerStyle:k}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(xB,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:o,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:m,nodeClickDistance:ve,onlyRenderVisibleElements:M,noPanClassName:rn,noDragClassName:St,disableKeyboardA11y:cn,nodeExtent:un,rfId:an,nodesDraggable:Bn}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}L_.displayName="GraphView";const qB=b.memo(L_),GB=DS(),Sk=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:c,fitViewOptions:u,minZoom:d=.5,maxZoom:h=2,nodeOrigin:m,nodeExtent:g,zIndexMode:p="basic"}={})=>{const x=new Map,y=new Map,S=new Map,N=new Map,k=i??t??[],E=n??e??[],j=m??[0,0],A=g??cc;QS(S,N,k);const{nodesInitialized:P}=Pp(E,x,y,{nodeOrigin:j,nodeExtent:A,zIndexMode:p});let L=[0,0,1];if(c&&r&&o){const B=Ec(x,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:V,y:M,zoom:z}=Zg(B,r,o,d,h,(u==null?void 0:u.padding)??.1);L=[V,M,z]}return{rfId:"1",width:r??0,height:o??0,transform:L,nodes:E,nodesInitialized:P,nodeLookup:x,parentLookup:y,edges:k,edgeLookup:N,connectionLookup:S,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:d,maxZoom:h,translateExtent:cc,nodeExtent:A,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ho.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:j,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:u,fitViewResolver:null,connection:{...MS},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:GB,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:$S,zIndexMode:p,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}},KB=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:c,fitViewOptions:u,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:g,zIndexMode:p})=>o6((x,y)=>{async function S(){const{nodeLookup:N,panZoom:k,fitViewOptions:E,fitViewResolver:j,width:A,height:P,minZoom:L,maxZoom:B}=y();k&&(await sU({nodes:N,width:A,height:P,panZoom:k,minZoom:L,maxZoom:B},E),j==null||j.resolve(!0),x({fitViewResolver:null}))}return{...Sk({nodes:e,edges:t,width:r,height:o,fitView:c,fitViewOptions:u,minZoom:d,maxZoom:h,nodeOrigin:m,nodeExtent:g,defaultNodes:n,defaultEdges:i,zIndexMode:p}),setNodes:N=>{const{nodeLookup:k,parentLookup:E,nodeOrigin:j,nodeExtent:A,elevateNodesOnSelect:P,fitViewQueued:L,zIndexMode:B,nodesSelectionActive:V}=y(),{nodesInitialized:M,hasSelectedNodes:z}=Pp(N,k,E,{nodeOrigin:j,nodeExtent:A,elevateNodesOnSelect:P,checkEquality:!0,zIndexMode:B}),D=V&&z;L&&M?(S(),x({nodes:N,nodesInitialized:M,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:D})):x({nodes:N,nodesInitialized:M,nodesSelectionActive:D})},setEdges:N=>{const{connectionLookup:k,edgeLookup:E}=y();QS(k,E,N),x({edges:N})},setDefaultNodesAndEdges:(N,k)=>{if(N){const{setNodes:E}=y();E(N),x({hasDefaultNodes:!0})}if(k){const{setEdges:E}=y();E(k),x({hasDefaultEdges:!0})}},updateNodeInternals:N=>{const{triggerNodeChanges:k,nodeLookup:E,parentLookup:j,domNode:A,nodeOrigin:P,nodeExtent:L,debug:B,fitViewQueued:V,zIndexMode:M}=y(),{changes:z,updatedInternals:D}=_U(N,E,j,A,P,L,M);D&&(NU(E,j,{nodeOrigin:P,nodeExtent:L,zIndexMode:M}),V?(S(),x({fitViewQueued:!1,fitViewOptions:void 0})):x({}),(z==null?void 0:z.length)>0&&(B&&console.log("React Flow: trigger node changes",z),k==null||k(z)))},updateNodePositions:(N,k=!1)=>{const E=[];let j=[];const{nodeLookup:A,triggerNodeChanges:P,connection:L,updateConnection:B,onNodesChangeMiddlewareMap:V}=y();for(const[M,z]of N){const D=A.get(M),U=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(z!=null&&z.position)),I={id:M,type:"position",position:U?{x:Math.max(0,z.position.x),y:Math.max(0,z.position.y)}:z.position,dragging:k};if(D&&L.inProgress&&L.fromNode.id===D.id){const T=Da(D,L.fromHandle,Je.Left,!0);B({...L,from:T})}U&&D.parentId&&E.push({id:M,parentId:D.parentId,rect:{...z.internals.positionAbsolute,width:z.measured.width??0,height:z.measured.height??0}}),j.push(I)}if(E.length>0){const{parentLookup:M,nodeOrigin:z}=y(),D=Yg(E,A,M,z);j.push(...D)}for(const M of V.values())j=M(j);P(j)},triggerNodeChanges:N=>{const{onNodesChange:k,setNodes:E,nodes:j,hasDefaultNodes:A,debug:P}=y();if(N!=null&&N.length){if(A){const L=C6(N,j);E(L)}P&&console.log("React Flow: trigger node changes",N),k==null||k(N)}},triggerEdgeChanges:N=>{const{onEdgesChange:k,setEdges:E,edges:j,hasDefaultEdges:A,debug:P}=y();if(N!=null&&N.length){if(A){const L=A6(N,j);E(L)}P&&console.log("React Flow: trigger edge changes",N),k==null||k(N)}},addSelectedNodes:N=>{const{multiSelectionActive:k,edgeLookup:E,nodeLookup:j,triggerNodeChanges:A,triggerEdgeChanges:P}=y();if(k){const L=N.map(B=>ka(B,!0));A(L);return}A(No(j,new Set([...N]),!0)),P(No(E))},addSelectedEdges:N=>{const{multiSelectionActive:k,edgeLookup:E,nodeLookup:j,triggerNodeChanges:A,triggerEdgeChanges:P}=y();if(k){const L=N.map(B=>ka(B,!0));P(L);return}P(No(E,new Set([...N]))),A(No(j,new Set,!0))},unselectNodesAndEdges:({nodes:N,edges:k}={})=>{const{edges:E,nodes:j,nodeLookup:A,triggerNodeChanges:P,triggerEdgeChanges:L}=y(),B=N||j,V=k||E,M=[];for(const D of B){if(!D.selected)continue;const U=A.get(D.id);U&&(U.selected=!1),M.push(ka(D.id,!1))}const z=[];for(const D of V)D.selected&&z.push(ka(D.id,!1));P(M),L(z)},setMinZoom:N=>{const{panZoom:k,maxZoom:E}=y();k==null||k.setScaleExtent([N,E]),x({minZoom:N})},setMaxZoom:N=>{const{panZoom:k,minZoom:E}=y();k==null||k.setScaleExtent([E,N]),x({maxZoom:N})},setTranslateExtent:N=>{var k;(k=y().panZoom)==null||k.setTranslateExtent(N),x({translateExtent:N})},resetSelectedElements:()=>{const{edges:N,nodes:k,triggerNodeChanges:E,triggerEdgeChanges:j,elementsSelectable:A}=y();if(!A)return;const P=k.reduce((B,V)=>V.selected?[...B,ka(V.id,!1)]:B,[]),L=N.reduce((B,V)=>V.selected?[...B,ka(V.id,!1)]:B,[]);E(P),j(L)},setNodeExtent:N=>{const{nodes:k,nodeLookup:E,parentLookup:j,nodeOrigin:A,elevateNodesOnSelect:P,nodeExtent:L,zIndexMode:B}=y();N[0][0]===L[0][0]&&N[0][1]===L[0][1]&&N[1][0]===L[1][0]&&N[1][1]===L[1][1]||(Pp(k,E,j,{nodeOrigin:A,nodeExtent:N,elevateNodesOnSelect:P,checkEquality:!1,zIndexMode:B}),x({nodeExtent:N}))},panBy:N=>{const{transform:k,width:E,height:j,panZoom:A,translateExtent:P}=y();return EU({delta:N,panZoom:A,transform:k,translateExtent:P,width:E,height:j})},setCenter:async(N,k,E)=>{const{width:j,height:A,maxZoom:P,panZoom:L}=y();if(!L)return!1;const B=typeof(E==null?void 0:E.zoom)<"u"?E.zoom:P;return await L.setViewport({x:j/2-N*B,y:A/2-k*B,zoom:B},{duration:E==null?void 0:E.duration,ease:E==null?void 0:E.ease,interpolate:E==null?void 0:E.interpolate}),!0},cancelConnection:()=>{x({connection:{...MS}})},updateConnection:N=>{x({connection:N})},reset:()=>x({...Sk()})}},Object.is);function YB({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:r,initialHeight:o,initialMinZoom:c,initialMaxZoom:u,initialFitViewOptions:d,fitView:h,nodeOrigin:m,nodeExtent:g,zIndexMode:p,children:x}){const[y]=b.useState(()=>KB({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:h,minZoom:c,maxZoom:u,fitViewOptions:d,nodeOrigin:m,nodeExtent:g,zIndexMode:p}));return s.jsx(l6,{value:y,children:s.jsx(R6,{children:s.jsx(K6,{children:x})})})}function XB({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:r,width:o,height:c,fitView:u,fitViewOptions:d,minZoom:h,maxZoom:m,nodeOrigin:g,nodeExtent:p,zIndexMode:x}){return b.useContext(Yd)?s.jsx(s.Fragment,{children:e}):s.jsx(YB,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:r,initialWidth:o,initialHeight:c,fitView:u,initialFitViewOptions:d,initialMinZoom:h,initialMaxZoom:m,nodeOrigin:g,nodeExtent:p,zIndexMode:x,children:e})}const QB={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function JB({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:r,nodeTypes:o,edgeTypes:c,onNodeClick:u,onEdgeClick:d,onInit:h,onMove:m,onMoveStart:g,onMoveEnd:p,onConnect:x,onConnectStart:y,onConnectEnd:S,onClickConnectStart:N,onClickConnectEnd:k,onNodeMouseEnter:E,onNodeMouseMove:j,onNodeMouseLeave:A,onNodeContextMenu:P,onNodeDoubleClick:L,onNodeDragStart:B,onNodeDrag:V,onNodeDragStop:M,onNodesDelete:z,onEdgesDelete:D,onDelete:U,onSelectionChange:I,onSelectionDragStart:T,onSelectionDrag:O,onSelectionDragStop:$,onSelectionContextMenu:F,onSelectionStart:H,onSelectionEnd:Z,onBeforeDelete:G,connectionMode:q,connectionLineType:X=Br.Bezier,connectionLineStyle:Y,connectionLineComponent:re,connectionLineContainerStyle:ee,deleteKeyCode:se="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:ie=!1,selectionMode:pe=uc.Full,panActivationKeyCode:Ce="Space",multiSelectionKeyCode:fe=hc()?"Meta":"Control",zoomActivationKeyCode:ve=hc()?"Meta":"Control",snapToGrid:ue,snapGrid:xe,onlyRenderVisibleElements:De=!1,selectNodesOnDrag:Me,nodesDraggable:Ge,autoPanOnNodeFocus:Te,nodesConnectable:tt,nodesFocusable:et,nodeOrigin:St=d_,edgesFocusable:zn,edgesReconnectable:rn,elementsSelectable:cn=!0,defaultViewport:un=k6,minZoom:an=.5,maxZoom:on=2,translateExtent:Ft=cc,preventScrolling:Bn=!0,nodeExtent:jn,defaultMarkerColor:Ss="#b1b1b7",zoomOnScroll:Ii=!0,zoomOnPinch:ni=!0,panOnScroll:si=!1,panOnScrollSpeed:zs=.5,panOnScrollMode:Ls=$a.Free,zoomOnDoubleClick:Ds=!0,panOnDrag:Fs=!0,onPaneClick:ii,onPaneMouseEnter:ri,onPaneMouseMove:os,onPaneMouseLeave:Xn,onPaneScroll:wn,onPaneContextMenu:te,paneClickDistance:ye=1,nodeClickDistance:Le=0,children:st,onReconnect:It,onReconnectStart:$t,onReconnectEnd:Ue,onEdgeContextMenu:Fe,onEdgeDoubleClick:Xe,onEdgeMouseEnter:bt,onEdgeMouseMove:yt,onEdgeMouseLeave:Hn,reconnectRadius:ls=10,onNodesChange:ai,onEdgesChange:gr,noDragClassName:oi="nodrag",noWheelClassName:xr="nowheel",noPanClassName:Zn="nopan",fitView:Vi,fitViewOptions:cs,connectOnClick:Ti,attributionPosition:vr,proOptions:Rt,defaultEdgeOptions:_s,elevateNodesOnSelect:Qn=!0,elevateEdgesOnSelect:qi=!1,disableKeyboardA11y:li=!1,autoPanOnConnect:Ot,autoPanOnNodeDrag:yr,autoPanOnSelection:Gi=!0,autoPanSpeed:ci,connectionRadius:$i,isValidConnection:$e,onError:Ze,style:ct,id:ht,nodeDragThreshold:Tt,connectionDragThreshold:Pt,viewport:Wn,onViewportChange:Us,width:dn,height:Sn,colorMode:Bs="light",debug:Hs,onScroll:us,ariaLabelConfig:sa,zIndexMode:br="basic",...Mi},kr){const Jn=ht||"1",ds=S6(Bs),_n=b.useCallback(Zs=>{Zs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),us==null||us(Zs)},[us]);return s.jsx("div",{"data-testid":"rf__wrapper",...Mi,onScroll:_n,style:{...ct,...QB},ref:kr,className:Nn(["react-flow",r,ds]),id:ht,role:"application",children:s.jsxs(XB,{nodes:e,edges:t,width:dn,height:Sn,fitView:Vi,fitViewOptions:cs,minZoom:an,maxZoom:on,nodeOrigin:St,nodeExtent:jn,zIndexMode:br,children:[s.jsx(w6,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:x,onConnectStart:y,onConnectEnd:S,onClickConnectStart:N,onClickConnectEnd:k,nodesDraggable:Ge,autoPanOnNodeFocus:Te,nodesConnectable:tt,nodesFocusable:et,edgesFocusable:zn,edgesReconnectable:rn,elementsSelectable:cn,elevateNodesOnSelect:Qn,elevateEdgesOnSelect:qi,minZoom:an,maxZoom:on,nodeExtent:jn,onNodesChange:ai,onEdgesChange:gr,snapToGrid:ue,snapGrid:xe,connectionMode:q,translateExtent:Ft,connectOnClick:Ti,defaultEdgeOptions:_s,fitView:Vi,fitViewOptions:cs,onNodesDelete:z,onEdgesDelete:D,onDelete:U,onNodeDragStart:B,onNodeDrag:V,onNodeDragStop:M,onSelectionDrag:O,onSelectionDragStart:T,onSelectionDragStop:$,onMove:m,onMoveStart:g,onMoveEnd:p,noPanClassName:Zn,nodeOrigin:St,rfId:Jn,autoPanOnConnect:Ot,autoPanOnNodeDrag:yr,autoPanSpeed:ci,onError:Ze,connectionRadius:$i,isValidConnection:$e,selectNodesOnDrag:Me,nodeDragThreshold:Tt,connectionDragThreshold:Pt,onBeforeDelete:G,debug:Hs,ariaLabelConfig:sa,zIndexMode:br}),s.jsx(qB,{onInit:h,onNodeClick:u,onEdgeClick:d,onNodeMouseEnter:E,onNodeMouseMove:j,onNodeMouseLeave:A,onNodeContextMenu:P,onNodeDoubleClick:L,nodeTypes:o,edgeTypes:c,connectionLineType:X,connectionLineStyle:Y,connectionLineComponent:re,connectionLineContainerStyle:ee,selectionKeyCode:ne,selectionOnDrag:ie,selectionMode:pe,deleteKeyCode:se,multiSelectionKeyCode:fe,panActivationKeyCode:Ce,zoomActivationKeyCode:ve,onlyRenderVisibleElements:De,defaultViewport:un,translateExtent:Ft,minZoom:an,maxZoom:on,preventScrolling:Bn,zoomOnScroll:Ii,zoomOnPinch:ni,zoomOnDoubleClick:Ds,panOnScroll:si,panOnScrollSpeed:zs,panOnScrollMode:Ls,panOnDrag:Fs,autoPanOnSelection:Gi,onPaneClick:ii,onPaneMouseEnter:ri,onPaneMouseMove:os,onPaneMouseLeave:Xn,onPaneScroll:wn,onPaneContextMenu:te,paneClickDistance:ye,nodeClickDistance:Le,onSelectionContextMenu:F,onSelectionStart:H,onSelectionEnd:Z,onReconnect:It,onReconnectStart:$t,onReconnectEnd:Ue,onEdgeContextMenu:Fe,onEdgeDoubleClick:Xe,onEdgeMouseEnter:bt,onEdgeMouseMove:yt,onEdgeMouseLeave:Hn,reconnectRadius:ls,defaultMarkerColor:Ss,noDragClassName:oi,noWheelClassName:xr,noPanClassName:Zn,rfId:Jn,disableKeyboardA11y:li,nodeExtent:jn,viewport:Wn,onViewportChange:Us,nodesDraggable:Ge}),s.jsx(b6,{onSelectionChange:I}),st,s.jsx(p6,{proOptions:Rt,position:vr}),s.jsx(m6,{rfId:Jn,disableKeyboardA11y:li})]})})}var e5=f_(JB);function t5({dimensions:e,lineWidth:t,variant:n,className:i}){return s.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Nn(["react-flow__background-pattern",n,i])})}function n5({radius:e,className:t}){return s.jsx("circle",{cx:e,cy:e,r:e,className:Nn(["react-flow__background-pattern","dots",t])})}var Xr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Xr||(Xr={}));const s5={[Xr.Dots]:1,[Xr.Lines]:1,[Xr.Cross]:6},i5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function D_({id:e,variant:t=Xr.Dots,gap:n=20,size:i,lineWidth:r=1,offset:o=0,color:c,bgColor:u,style:d,className:h,patternClassName:m}){const g=b.useRef(null),{transform:p,patternId:x}=wt(i5,nn),y=i||s5[t],S=t===Xr.Dots,N=t===Xr.Cross,k=Array.isArray(n)?n:[n,n],E=[k[0]*p[2]||1,k[1]*p[2]||1],j=y*p[2],A=Array.isArray(o)?o:[o,o],P=N?[j,j]:E,L=[A[0]*p[2]+P[0]/2,A[1]*p[2]+P[1]/2],B=`${x}${e||""}`;return s.jsxs("svg",{className:Nn(["react-flow__background",h]),style:{...d,...Qd,"--xy-background-color-props":u,"--xy-background-pattern-color-props":c},ref:g,"data-testid":"rf__background",children:[s.jsx("pattern",{id:B,x:p[0]%E[0],y:p[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${L[0]},-${L[1]})`,children:S?s.jsx(n5,{radius:j/2,className:m}):s.jsx(t5,{dimensions:P,lineWidth:r,variant:t,className:m})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}D_.displayName="Background";const r5=b.memo(D_);function a5(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:s.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function o5(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:s.jsx("path",{d:"M0 0h32v4.2H0z"})})}function l5(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:s.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function c5(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function u5(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Wu({children:e,className:t,...n}){return s.jsx("button",{type:"button",className:Nn(["react-flow__controls-button",t]),...n,children:e})}const d5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function F_({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:o,onZoomOut:c,onFitView:u,onInteractiveChange:d,className:h,children:m,position:g="bottom-left",orientation:p="vertical","aria-label":x}){const y=qt(),{isInteractive:S,minZoomReached:N,maxZoomReached:k,ariaLabelConfig:E}=wt(d5,nn),{zoomIn:j,zoomOut:A,fitView:P}=Xg(),L=()=>{j(),o==null||o()},B=()=>{A(),c==null||c()},V=()=>{P(r),u==null||u()},M=()=>{y.setState({nodesDraggable:!S,nodesConnectable:!S,elementsSelectable:!S}),d==null||d(!S)},z=p==="horizontal"?"horizontal":"vertical";return s.jsxs(Xd,{className:Nn(["react-flow__controls",z,h]),position:g,style:e,"data-testid":"rf__controls","aria-label":x??E["controls.ariaLabel"],children:[t&&s.jsxs(s.Fragment,{children:[s.jsx(Wu,{onClick:L,className:"react-flow__controls-zoomin",title:E["controls.zoomIn.ariaLabel"],"aria-label":E["controls.zoomIn.ariaLabel"],disabled:k,children:s.jsx(a5,{})}),s.jsx(Wu,{onClick:B,className:"react-flow__controls-zoomout",title:E["controls.zoomOut.ariaLabel"],"aria-label":E["controls.zoomOut.ariaLabel"],disabled:N,children:s.jsx(o5,{})})]}),n&&s.jsx(Wu,{className:"react-flow__controls-fitview",onClick:V,title:E["controls.fitView.ariaLabel"],"aria-label":E["controls.fitView.ariaLabel"],children:s.jsx(l5,{})}),i&&s.jsx(Wu,{className:"react-flow__controls-interactive",onClick:M,title:E["controls.interactive.ariaLabel"],"aria-label":E["controls.interactive.ariaLabel"],children:S?s.jsx(u5,{}):s.jsx(c5,{})}),m]})}F_.displayName="Controls";const h5=b.memo(F_);function f5({id:e,x:t,y:n,width:i,height:r,style:o,color:c,strokeColor:u,strokeWidth:d,className:h,borderRadius:m,shapeRendering:g,selected:p,onClick:x}){const{background:y,backgroundColor:S}=o||{},N=c||y||S;return s.jsx("rect",{className:Nn(["react-flow__minimap-node",{selected:p},h]),x:t,y:n,rx:m,ry:m,width:i,height:r,style:{fill:N,stroke:u,strokeWidth:d},shapeRendering:g,onClick:x?k=>x(k,e):void 0})}const m5=b.memo(f5),p5=e=>e.nodes.map(t=>t.id),Cm=e=>e instanceof Function?e:()=>e;function g5({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:o=m5,onClick:c}){const u=wt(p5,nn),d=Cm(t),h=Cm(e),m=Cm(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return s.jsx(s.Fragment,{children:u.map(p=>s.jsx(v5,{id:p,nodeColorFunc:d,nodeStrokeColorFunc:h,nodeClassNameFunc:m,nodeBorderRadius:i,nodeStrokeWidth:r,NodeComponent:o,onClick:c,shapeRendering:g},p))})}function x5({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:r,nodeStrokeWidth:o,shapeRendering:c,NodeComponent:u,onClick:d}){const{node:h,x:m,y:g,width:p,height:x}=wt(y=>{const S=y.nodeLookup.get(e);if(!S)return{node:void 0,x:0,y:0,width:0,height:0};const N=S.internals.userNode,{x:k,y:E}=S.internals.positionAbsolute,{width:j,height:A}=Ai(N);return{node:N,x:k,y:E,width:j,height:A}},nn);return!h||h.hidden||!FS(h)?null:s.jsx(u,{x:m,y:g,width:p,height:x,style:h.style,selected:!!h.selected,className:i(h),color:t(h),borderRadius:r,strokeColor:n(h),strokeWidth:o,shapeRendering:c,onClick:d,id:h.id})}const v5=b.memo(x5);var y5=b.memo(g5);const b5=200,k5=150,N5=e=>!e.hidden,j5=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};let n=!1;for(const i of e.nodeLookup.values())if(!i.hidden){n=!0;break}return{viewBB:t,boundingRect:n?zS(Ec(e.nodeLookup,{filter:N5}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},_k=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,w5=(e,t)=>_k(e.viewBB,t.viewBB)&&_k(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,S5="react-flow__minimap-desc";function U_({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:c,nodeComponent:u,bgColor:d,maskColor:h,maskStrokeColor:m,maskStrokeWidth:g,position:p="bottom-right",onClick:x,onNodeClick:y,pannable:S=!1,zoomable:N=!1,ariaLabel:k,inversePan:E,zoomStep:j=1,offsetScale:A=5}){const P=qt(),L=b.useRef(null),{boundingRect:B,panZoom:V,viewBB:M,rfId:z,translateExtent:D,flowWidth:U,flowHeight:I,ariaLabelConfig:T}=wt(j5,w5),O=(e==null?void 0:e.width)??b5,$=(e==null?void 0:e.height)??k5,F=B.width/O,H=B.height/$,Z=Math.max(F,H),G=Z*O,q=Z*$,X=A*Z,Y=B.x-(G-B.width)/2-X,re=B.y-(q-B.height)/2-X,ee=G+X*2,se=q+X*2,ne=`${S5}-${z}`,ie=b.useRef(0),pe=b.useRef();ie.current=Z,b.useEffect(()=>{const xe=P.getState().panZoom;if(L.current&&xe)return pe.current=PU({domNode:L.current,panZoom:xe,getTransform:()=>P.getState().transform,getViewScale:()=>ie.current}),()=>{var De;(De=pe.current)==null||De.destroy()}},[V]),b.useEffect(()=>{var xe;(xe=pe.current)==null||xe.update({translateExtent:D,width:U,height:I,inversePan:E,pannable:S,zoomStep:j,zoomable:N})},[S,N,E,j,D,U,I]);const Ce=x?xe=>{var Ge;const[De,Me]=((Ge=pe.current)==null?void 0:Ge.pointer(xe))||[0,0];x(xe,{x:De,y:Me})}:void 0,fe=b.useCallback((xe,De)=>{const Me=P.getState().nodeLookup.get(De).internals.userNode;y==null||y(xe,Me)},[y]),ve=y?fe:void 0,ue=k??T["minimap.ariaLabel"];return s.jsx(Xd,{position:p,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 g=="number"?g*Z:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:Nn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:s.jsxs("svg",{width:O,height:$,viewBox:`${Y} ${re} ${ee} ${se}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:L,onClick:Ce,children:[ue&&s.jsx("title",{id:ne,children:ue}),s.jsx(y5,{onClick:ve,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:r,nodeStrokeWidth:c,nodeComponent:u}),s.jsx("path",{className:"react-flow__minimap-mask",d:`M${Y-X},${re-X}h${ee+X*2}v${se+X*2}h${-ee-X*2}z
229
+ M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}U_.displayName="MiniMap";b.memo(U_);const _5=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,E5={[Vo.Line]:"right",[Vo.Handle]:"bottom-right"};function C5({nodeId:e,position:t,variant:n=Vo.Handle,className:i,style:r=void 0,children:o,color:c,minWidth:u=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:g=!1,resizeDirection:p,autoScale:x=!0,shouldResize:y,onResizeStart:S,onResize:N,onResizeEnd:k}){const E=v_(),j=typeof e=="string"?e:E,A=qt(),P=b.useRef(null),L=n===Vo.Handle,B=wt(b.useCallback(_5(L&&x),[L,x]),nn),V=b.useRef(null),M=t??E5[n];b.useEffect(()=>{if(!(!P.current||!j))return V.current||(V.current=KU({domNode:P.current,nodeId:j,getStoreItems:()=>{const{nodeLookup:D,transform:U,snapGrid:I,snapToGrid:T,nodeOrigin:O,domNode:$}=A.getState();return{nodeLookup:D,transform:U,snapGrid:I,snapToGrid:T,nodeOrigin:O,paneDomNode:$}},onChange:(D,U)=>{const{triggerNodeChanges:I,nodeLookup:T,parentLookup:O,nodeOrigin:$}=A.getState(),F=[],H={x:D.x,y:D.y},Z=T.get(j);if(Z&&Z.expandParent&&Z.parentId){const G=Z.origin??$,q=D.width??Z.measured.width??0,X=D.height??Z.measured.height??0,Y={id:Z.id,parentId:Z.parentId,rect:{width:q,height:X,...US({x:D.x??Z.position.x,y:D.y??Z.position.y},{width:q,height:X},Z.parentId,T,G)}},re=Yg([Y],T,O,$);F.push(...re),H.x=D.x?Math.max(G[0]*q,D.x):void 0,H.y=D.y?Math.max(G[1]*X,D.y):void 0}if(H.x!==void 0&&H.y!==void 0){const G={id:j,type:"position",position:{...H}};F.push(G)}if(D.width!==void 0&&D.height!==void 0){const q={id:j,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};F.push(q)}for(const G of U){const q={...G,type:"position"};F.push(q)}I(F)},onEnd:({width:D,height:U})=>{const I={id:j,type:"dimensions",resizing:!1,dimensions:{width:D,height:U}};A.getState().triggerNodeChanges([I])}})),V.current.update({controlPosition:M,boundaries:{minWidth:u,minHeight:d,maxWidth:h,maxHeight:m},keepAspectRatio:g,resizeDirection:p,onResizeStart:S,onResize:N,onResizeEnd:k,shouldResize:y}),()=>{var D;(D=V.current)==null||D.destroy()}},[M,u,d,h,m,g,S,N,k,y]);const z=M.split("-");return s.jsx("div",{className:Nn(["react-flow__resize-control","nodrag",...z,n,i]),ref:P,style:{...r,scale:B,...c&&{[L?"backgroundColor":"borderColor"]:c}},children:o})}b.memo(C5);function A5(e,t=0){const n=we(e.connection.status),[i,r]=b.useState([]);return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return(async()=>{const{scripts:c}=await e.connection.call("scripts/list",{}),u=[];for(const d of c){if(d.packId===void 0)continue;const 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,n.state,t]),b.useEffect(()=>e.connection.on("configs/profiles/changed",o=>{r(c=>c.map(u=>u.scriptId===o.scriptId?{...u,profiles:o.list}:u))}),[e]),i}const B_=[0,1,2,3,4,5].map(e=>({value:String(e),label:e===0?"不重试":`重试 ${e} 次`})),H_=[{value:"continue",label:"然后继续其他分支"},{value:"stop",label:"然后停止流水线"}],qo={"script-task":"脚本任务",agent:"agent 步骤",wait:"控制节点",notify:"发消息",gate:"人工确认",start:"开始",end:"结束"},Dp={pending:"待运行",waiting:"等待中",running:"运行中",succeeded:"成功",failed:"失败",skipped:"跳过",cancelled:"取消"},I5={success:"成功后",failure:"失败后",always:"结束后"},Am={desktop:"鼠标键盘",adb:"模拟器",window:"后台窗口",none:""};function T5({data:e,selected:t}){var i,r,o,c;const n=(i=e.state)==null?void 0:i.state;return Hi(e.node)?s.jsxs("div",{className:`step-node marker ${e.node.kind} ${n??""} ${t?"selected":""}`,children:[e.node.kind==="end"&&s.jsx(Gr,{type:"target",position:Je.Left}),s.jsx("span",{children:qo[e.node.kind]}),e.node.kind==="end"&&n!==void 0&&n!=="pending"&&s.jsx("span",{className:`step-state ${n}`,children:((r=e.state)==null?void 0:r.detail)??Dp[n]}),e.node.kind==="start"&&s.jsx(Gr,{type:"source",position:Je.Right})]}):s.jsxs("div",{className:`step-node ${n??""} ${t?"selected":""} ${e.issue!==void 0?"has-issue":""}`,children:[s.jsx(Gr,{type:"target",position:Je.Left}),s.jsxs("div",{className:"step-kind",children:[s.jsx("span",{children:qo[e.node.kind]}),e.input!==""&&s.jsx("span",{className:"badge",children:e.input}),e.node.waitForAll===!0&&s.jsx("span",{className:"badge",title:"等前面的节点全部结束再开始",children:"等全部"}),n!==void 0&&s.jsxs("span",{className:`step-state ${n}`,children:[Dp[n],(((o=e.state)==null?void 0:o.attempts)??0)>1?` · 第 ${e.state.attempts} 次`:""]})]}),s.jsx("div",{className:"step-title",children:e.label}),e.sub!==""&&s.jsx("div",{className:"step-sub",children:e.sub}),((c=e.state)==null?void 0:c.detail)!==void 0&&e.state.detail!==""&&s.jsx("div",{className:"step-detail",children:e.state.detail}),e.issue!==void 0&&e.state===void 0&&s.jsx("div",{className:"step-detail issue",children:e.issue}),s.jsx(Gr,{type:"source",position:Je.Right})]})}const $5={step:T5};function M5(e){const t=new Map,n=(o,c)=>{if(t.has(o))return t.get(o);if(c.has(o))return 0;c.add(o);const u=e.edges.filter(h=>h.to===o).map(h=>n(h.from,c)+1),d=Math.max(0,...u);return t.set(o,d),d};for(const o of e.nodes)n(o.id,new Set);const 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 c=t.get(o.id)??0,u=i.get(c)??0;i.set(c,u+1),r.set(o.id,{x:40+c*280,y:40+u*130})}return r}let R5=0;const go=(e,t,n=new Set)=>{for(;;){const i=`${e}${++R5}`;if(!n.has(i)&&!t.nodes.some(r=>r.id===i))return i}};function O5(e,t){return e.nodes.every(n=>n.position!==void 0)?e:{...e,nodes:e.nodes.map(n=>n.position!==void 0||!t.has(n.id)?n:{...n,position:t.get(n.id)})}}let Dr=null;const P5=e=>e instanceof HTMLElement&&e.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]')!==null;function z5({client:e,pipeline:t,onChange:n,run:i,check:r,runFrom:o,idle:c}){var q,X;const u=fw(),[d,h]=b.useState(0),m=A5(e,d),[g,p]=b.useState([]),x=g.length===1?g[0]:null,y=Y=>p(Y===null?[]:[Y]),[S,N]=b.useState(null),k=b.useRef(null),[E,j]=b.useState({}),A=b.useCallback(Y=>{var re,ee;if(Y.kind==="script-task"){const se=m.find(Ce=>Ce.scriptId===Y.scriptId),ne=se==null?void 0:se.tasks.find(Ce=>Ce.id===Y.taskId),ie=Object.entries(Y.params).map(([Ce,fe])=>`${Ce}=${String(fe)}`).join(" "),pe=Y.profile===void 0?void 0:((ee=(re=se==null?void 0:se.profiles)==null?void 0:re.items.find(Ce=>Ce.id===Y.profile))==null?void 0:ee.name)??"已删除的配置";return{label:Y.title??`${(se==null?void 0:se.scriptName)??Y.scriptId} · ${(ne==null?void 0:ne.title)??Y.taskId}`,sub:[pe===void 0?"":`配置:${pe}`,ie].filter(Boolean).join(" · "),input:Am[(ne==null?void 0:ne.input)??"none"]??""}}return Y.kind==="wait"?{label:Y.title??(Y.minutes!==void 0?`等 ${Y.minutes} 分钟`:`等到 ${Y.until}`),sub:"",input:""}:Y.kind==="agent"?{label:Y.title??"agent 步骤",sub:Y.prompt.slice(0,40),input:""}:Hi(Y)?{label:qo[Y.kind],sub:"",input:""}:{label:Y.title??qo[Y.kind],sub:Y.text.slice(0,40),input:""}},[m]),P=b.useMemo(()=>M5(t),[t]),L=b.useMemo(()=>t.nodes.map(Y=>{var re;return{id:Y.id,type:"step",position:P.get(Y.id),selected:g.includes(Y.id),...E[Y.id]===void 0?{}:{measured:E[Y.id]},data:{node:Y,...A(Y),state:i==null?void 0:i.nodes[Y.id],issue:(re=r==null?void 0:r.issues.find(ee=>ee.nodeId===Y.id&&ee.level==="error"))==null?void 0:re.message}}}),[t,P,A,i,r,g,E]),B=b.useMemo(()=>t.edges.map((Y,re)=>{var ee;return{id:`e${re}`,source:Y.from,target:Y.to,label:I5[Y.when],selected:re===S,animated:((ee=i==null?void 0:i.nodes[Y.from])==null?void 0:ee.state)==="running",className:`edge-${Y.when}`}}),[t.edges,S,i]),V=b.useRef({past:[],future:[],at:0}),M=b.useCallback((Y,re)=>{const ee=V.current,se=Date.now();(re===void 0||re!==ee.group||se-ee.at>1e3)&&(ee.past=[...ee.past.slice(-99),{nodes:t.nodes,edges:t.edges}]),ee.future=[],ee.group=re,ee.at=se,n(O5(Y,P))},[t,P,n]),z=Y=>{const re=V.current,ee=Y==="past"?"future":"past",se=re[Y].pop();se!==void 0&&(re[ee].push({nodes:t.nodes,edges:t.edges}),re.group=void 0,n({...t,...se}),p(ne=>ne.filter(ie=>se.nodes.some(pe=>pe.id===ie))),N(null))},D=b.useCallback(Y=>{let re=t,ee;const se={},ne=new Map;for(const ie of Y)if(ie.type==="dimensions"&&ie.dimensions!==void 0)se[ie.id]=ie.dimensions;else if(ie.type==="select")ne.set(ie.id,ie.selected);else if(ie.type==="position"&&ie.position!==void 0)re={...re,nodes:re.nodes.map(pe=>pe.id===ie.id?{...pe,position:{x:Math.round(ie.position.x),y:Math.round(ie.position.y)}}:pe)},ee="move";else if(ie.type==="remove"){if(re.nodes.some(pe=>pe.id===ie.id&&Hi(pe)))continue;re={...re,nodes:re.nodes.filter(pe=>pe.id!==ie.id),edges:re.edges.filter(pe=>pe.from!==ie.id&&pe.to!==ie.id)},ne.set(ie.id,!1),ee=void 0}Object.keys(se).length>0&&j(ie=>({...ie,...se})),ne.size>0&&(p(ie=>[...ie.filter(pe=>ne.get(pe)!==!1),...[...ne].filter(([pe,Ce])=>Ce&&!ie.includes(pe)).map(([pe])=>pe)]),[...ne.values()].some(Boolean)&&N(null)),re!==t&&M(re,ee)},[t,M]),U=b.useCallback(Y=>{var ee;if(Y.source===Y.target||t.edges.some(se=>se.from===Y.source&&se.to===Y.target))return;const re=t.nodes.find(se=>se.id===Y.target);(re==null?void 0:re.kind)==="start"||((ee=t.nodes.find(se=>se.id===Y.source))==null?void 0:ee.kind)==="end"||M({...t,edges:[...t.edges,{from:Y.source,to:Y.target,when:(re==null?void 0:re.kind)==="end"?"always":"success"}]})},[t,M]),I=()=>{const Y=t.nodes.filter(ee=>g.includes(ee.id)&&!Hi(ee));if(Y.length===0)return!1;const re=new Set(Y.map(ee=>ee.id));return Dr={nodes:Y.map(ee=>({...ee,position:P.get(ee.id)??{x:40,y:40}})),edges:t.edges.filter(ee=>re.has(ee.from)&&re.has(ee.to)),pasted:0},!0},T=()=>{if(Dr===null||t.nodes.length+Dr.nodes.length>60)return;const Y=++Dr.pasted,re=new Map;for(const ne of Dr.nodes)re.set(ne.id,go(ne.id.replace(/\d+$/,"")||"step",t,new Set(re.values())));const ee=Dr.nodes.map(ne=>{var ie,pe;return{...ne,id:re.get(ne.id),position:{x:(((ie=ne.position)==null?void 0:ie.x)??40)+40*Y,y:(((pe=ne.position)==null?void 0:pe.y)??40)+120*Y}}}),se=Dr.edges.map(ne=>({...ne,from:re.get(ne.from),to:re.get(ne.to)}));M({...t,nodes:[...t.nodes,...ee],edges:[...t.edges,...se]}),p(ee.map(ne=>ne.id)),N(null)},O=()=>{const Y=new Set(t.nodes.filter(re=>g.includes(re.id)&&!Hi(re)).map(re=>re.id));Y.size!==0&&(M({...t,nodes:t.nodes.filter(re=>!Y.has(re.id)),edges:t.edges.filter(re=>!Y.has(re.from)&&!Y.has(re.to))}),p([]))},$=b.useRef(()=>{});$.current=Y=>{var ee;if(!(Y.ctrlKey||Y.metaKey)||Y.altKey||P5(Y.target)||k.current===null||k.current.offsetParent===null)return;const re=Y.key.toLowerCase();re==="z"&&!Y.shiftKey?(Y.preventDefault(),z("past")):re==="y"||re==="z"&&Y.shiftKey?(Y.preventDefault(),z("future")):re==="c"?(((ee=window.getSelection())==null?void 0:ee.toString())??"")===""&&I()&&Y.preventDefault():re==="v"&&Dr!==null&&(Y.preventDefault(),T())},b.useEffect(()=>{const Y=re=>$.current(re);return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[]);const F=Y=>{const re=t.nodes.find(ve=>ve.kind==="start"),ee=t.nodes.find(ve=>ve.kind==="end"),se=t.nodes.find(ve=>ve.id===x&&ve.kind!=="end")??re,ne=se===void 0?void 0:P.get(se.id),ie=[...P.entries()].filter(([ve])=>ve!==(ee==null?void 0:ee.id)).map(([,ve])=>ve),pe=ne===void 0?Math.max(0,...ie.map(ve=>ve.x))+280:ne.x+280;let Ce=(ne==null?void 0:ne.y)??40;for(;ie.some(ve=>Math.abs(ve.x-pe)<200&&Math.abs(ve.y-Ce)<100);)Ce+=130;const fe=[...t.nodes.map(ve=>{var ue,xe;return ve.kind==="end"?{...ve,position:{x:Math.max(((ue=P.get(ve.id))==null?void 0:ue.x)??0,pe+300),y:((xe=P.get(ve.id))==null?void 0:xe.y)??Ce}}:ve}),{...Y,position:{x:pe,y:Ce}}];M({...t,nodes:fe}),y(Y.id),N(null)},H=t.nodes.find(Y=>Y.id===x),Z=S===null?void 0:t.edges[S],G=Y=>M({...t,nodes:t.nodes.map(re=>re.id===Y.id?Y:re)},`node:${Y.id}`);return s.jsxs("div",{className:"pipeline-editor",ref:k,children:[s.jsxs("div",{className:"pipeline-palette","aria-label":"节点",children:[s.jsx("div",{className:"sidebar-label",children:"脚本任务"}),m.length===0&&s.jsx("div",{className:"muted small pad",children:"脚本库里还没有带脚本包的脚本"}),m.map(Y=>s.jsxs("details",{className:"palette-group",open:m.length<=3,children:[s.jsx("summary",{children:Y.scriptName}),Y.tasks.map(re=>s.jsxs("button",{className:"palette-item",title:re.description??re.title,onClick:()=>F({id:go(Y.scriptId.replace(/[^A-Za-z0-9_-]/g,"").slice(0,20)||"task",t),kind:"script-task",scriptId:Y.scriptId,taskId:re.id,params:{}}),children:[s.jsx("span",{children:re.title}),Am[re.input]!==""&&s.jsx("span",{className:"badge",children:Am[re.input]})]},re.id))]},Y.scriptId)),s.jsx("div",{className:"sidebar-label pack-label",children:"其他步骤"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:go("agent",t),kind:"agent",prompt:"检查活动还剩几天,快结束的提醒我"}),children:"agent 步骤"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:go("wait",t),kind:"wait",minutes:10}),children:"控制节点"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:go("notify",t),kind:"notify",text:`${t.name}跑完了`}),children:"发消息"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:go("gate",t),kind:"gate",text:"确认后继续"}),children:"人工确认"}),s.jsx("p",{className:"muted small pad",children:"从节点右边的圆点拖到另一个节点左边,表示「这个完成后再运行那个」。没有连线的节点会同时开始;需要同一资源的会自动排队。"})]}),s.jsxs("div",{className:"pipeline-canvas",children:[s.jsxs(e5,{nodes:L,edges:B,nodeTypes:$5,onNodesChange:D,onConnect:U,onNodeClick:()=>N(null),onEdgeClick:(Y,re)=>{N(Number(re.id.slice(1))),y(null)},onPaneClick:()=>{y(null),N(null)},deleteKeyCode:["Delete","Backspace"],colorMode:u,fitView:!0,fitViewOptions:{maxZoom:1,padding:.2},proOptions:{hideAttribution:!0},children:[s.jsx(r5,{gap:20}),s.jsx(h5,{showInteractive:!1})]}),!t.nodes.some(Y=>!Hi(Y))&&s.jsx("div",{className:"canvas-hint",children:"从左边点一个任务加到画布上,再从节点右边的圆点拖到下一个节点,连成先后顺序"})]}),s.jsxs("aside",{className:"pipeline-inspector",children:[H!==void 0&&s.jsx(D5,{client:e,node:H,pipeline:t,run:i,scripts:m,onChange:G,onTasksChanged:()=>h(Y=>Y+1),runFrom:o,onRemove:O}),Z!==void 0&&s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:"连线"}),s.jsxs("p",{className:"muted small",children:["「",((q=t.nodes.find(Y=>Y.id===Z.from))==null?void 0:q.title)??Z.from,"」→「",((X=t.nodes.find(Y=>Y.id===Z.to))==null?void 0:X.title)??Z.to,"」"]}),s.jsx("label",{className:"field-label",htmlFor:"edge-when",children:"什么时候运行下一步"}),s.jsx(Vt,{id:"edge-when",value:Z.when,onChange:Y=>M({...t,edges:t.edges.map((re,ee)=>ee===S?{...re,when:Y}:re)}),options:[{value:"success",label:"上一步成功后"},{value:"failure",label:"上一步失败后"},{value:"always",label:"上一步结束后",hint:"不管成败"}]}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>{M({...t,edges:t.edges.filter((Y,re)=>re!==S)}),N(null)},children:"删除连线"})]}),g.length>1&&Z===void 0&&s.jsxs("section",{className:"inspector-section",children:[s.jsxs("h4",{children:["已选 ",g.length," 个节点"]}),s.jsx("p",{className:"muted small",children:"Ctrl+C 复制、Ctrl+V 粘贴(连同它们之间的连线),Delete 删除,Ctrl+Z 撤销。开始和结束不会被复制或删除。"}),s.jsx("button",{className:"danger-outline small-button",onClick:O,children:"删除这些节点"})]}),H===void 0&&Z===void 0&&g.length<=1&&(c??s.jsx("p",{className:"muted small pad",children:"点一个节点或连线来修改。选中后按 Delete 也能删除,Ctrl+C / Ctrl+V 复制粘贴,Ctrl+Z 撤销。"})),(H!==void 0||Z!==void 0||g.length>1)&&c!==void 0&&s.jsx("button",{className:"link-button small back-to-pipeline",onClick:()=>{y(null),N(null)},children:"← 流水线设置"})]})]})}function L5({client:e,value:t,onChange:n}){const i=b.useRef(null),r=rw({client:e,text:t,setText:n,area:i,placement:"below"});return s.jsxs("div",{className:"slash-anchor",children:[s.jsx("textarea",{id:"node-prompt",ref:i,className:"text-input plain",rows:4,value:t,placeholder:"例如:/game-arknights 看看活动商店还剩什么没换",onChange:o=>n(o.target.value),onKeyDown:o=>{r.onKeyDown(o)}}),r.menu,s.jsx("p",{className:"muted small",children:"输入 / 可以选命令或技能,运行时展开成完整的指令。"})]})}function D5({client:e,node:t,pipeline:n,run:i,scripts:r,onChange:o,onRemove:c,onTasksChanged:u,runFrom:d}){var y,S;const[h,m]=b.useState(null),g=i==null?void 0:i.nodes[t.id],p=t.kind==="script-task"?(y=r.find(N=>N.scriptId===t.scriptId))==null?void 0:y.tasks.find(N=>N.id===t.taskId):void 0,x=t.onFailure;return Hi(t)?s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:qo[t.kind]}),s.jsx("p",{className:"muted small",children:t.kind==="start"?"流水线从这里开始。从它连出去的步骤最先运行(没有连线的步骤也会一开始就运行)。":"所有步骤都结束后到这里,不管成败;连到它的线只是为了看得清楚。"}),(g==null?void 0:g.detail)!==void 0&&s.jsx("div",{className:"muted small",children:g.detail})]}):s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:qo[t.kind]}),s.jsx("label",{className:"field-label",htmlFor:"node-title",children:"名称(可选)"}),s.jsx("input",{id:"node-title",className:"text-input plain",value:t.title??"",maxLength:60,onChange:N=>{const{title:k,...E}=t;o(N.target.value===""?E:{...E,title:N.target.value})}}),t.kind==="script-task"&&s.jsx(Xw,{id:"node-profile",label:"用哪份配置",list:((S=r.find(N=>N.scriptId===t.scriptId))==null?void 0:S.profiles)??null,value:t.profile,onChange:N=>{const{profile:k,...E}=t;o(N===void 0?E:{...E,profile:N})}}),t.kind==="script-task"&&p!==void 0&&Object.entries(p.params).map(([N,k])=>s.jsx(Kw,{client:e,scriptId:t.scriptId,taskId:t.taskId,name:N,spec:k,profile:t.profile,value:String(t.params[N]??(k.type==="boolean"?k.default??!1:"")),onCreated:u,onChange:E=>{const{[N]:j,...A}=t.params,P=k.type==="boolean"?E==="true":k.type==="integer"||k.type==="number"?Number(E):E;o({...t,params:E===""?A:{...A,[N]:P}})}},N)),t.kind==="agent"&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-prompt",children:"让 agent 做什么"}),s.jsx(L5,{client:e,value:t.prompt,onChange:N=>o({...t,prompt:N})})]}),(t.kind==="notify"||t.kind==="gate")&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-text",children:t.kind==="notify"?"消息内容":"确认时显示的话"}),s.jsx("textarea",{id:"node-text",className:"text-input plain",rows:3,value:t.text,onChange:N=>o({...t,text:N.target.value})})]}),t.kind==="wait"&&s.jsxs("div",{className:"key-input",children:[s.jsx(Vt,{"aria-label":"等待方式",value:t.minutes!==void 0?"minutes":"until",options:[{value:"minutes",label:"等几分钟"},{value:"until",label:"等到某个时间"}],onChange:N=>o(N==="minutes"?{id:t.id,kind:"wait",minutes:10,...t.title===void 0?{}:{title:t.title},...t.position===void 0?{}:{position:t.position}}:{id:t.id,kind:"wait",until:"05:00",...t.title===void 0?{}:{title:t.title},...t.position===void 0?{}:{position:t.position}})}),t.minutes!==void 0?s.jsx("input",{className:"text-input plain",type:"number",min:1,max:1440,value:t.minutes,onChange:N=>o({...t,minutes:Math.max(1,Math.min(1440,Math.round(Number(N.target.value)||1)))})}):s.jsx("input",{className:"text-input plain",type:"time",value:t.until,onChange:N=>o({...t,until:N.target.value})})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.waitForAll===!0,onChange:N=>{const{waitForAll:k,...E}=t;o(N.target.checked?{...E,waitForAll:!0}:E)}}),"等前面的节点全部结束再开始"]}),s.jsx("p",{className:"muted small",children:"不只等连进来的线:画布上不在它后面的节点(其他分支也算)都结束了(成功、失败、跳过都算)才开始。用来让并行的几条分支汇合。"}),t.kind!=="gate"&&t.kind!=="notify"&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-retries",children:"失败时"}),s.jsxs("div",{className:"select-stack",children:[s.jsx(Vt,{id:"node-retries","aria-label":"重试次数",value:x===void 0?"inherit":String(x.retries),options:[{value:"inherit",label:"按流水线的设置"},...B_],onChange:N=>{const{onFailure:k,...E}=t;if(N==="inherit")return o(E);o({...E,onFailure:{retries:Number(N),then:(x==null?void 0:x.then)??n.onFailure.then}})}}),s.jsx(Vt,{"aria-label":"仍失败时",disabled:x===void 0,value:(x??n.onFailure).then,options:H_,onChange:N=>o({...t,onFailure:{retries:(x==null?void 0:x.retries)??n.onFailure.retries,then:N}})})]}),x===void 0&&s.jsxs("p",{className:"muted small",children:["流水线的设置:",n.onFailure.retries>0?`重试 ${n.onFailure.retries} 次,`:"不重试,","然后",n.onFailure.then==="stop"?"停止流水线":"继续其他分支"]})]}),g!==void 0&&s.jsxs("div",{className:"inspector-run",children:[s.jsx("div",{className:"sidebar-label",children:"这次运行"}),s.jsxs("div",{children:[Dp[g.state],g.attempts>1?` · 第 ${g.attempts} 次`:""]}),g.detail!==void 0&&s.jsx("div",{className:"muted small",children:g.detail}),g.runIds.length>0&&s.jsxs("div",{className:"muted small",children:["脚本运行:",g.runIds.join("、"),"(在「运行」页看日志)"]}),t.kind==="gate"&&g.state==="running"&&i!==void 0&&s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"primary small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:i.id,nodeId:t.id,decision:"continue"}).catch(N=>m(Ie(N))),children:"继续"}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:i.id,nodeId:t.id,decision:"stop"}).catch(N=>m(Ie(N))),children:"停止"})]})]}),h!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:h})]}),d!==void 0&&s.jsxs("div",{className:"run-from",children:[s.jsxs("button",{className:"small-button",onClick:()=>d(t.id),children:[s.jsx(J,{name:"arrow"}),"从这里开始运行"]}),s.jsx("span",{className:"muted small",children:"这一步和它后面的会运行,前面的不运行(例如前面已经跑过了)"})]}),s.jsx("button",{className:"danger-outline small-button",onClick:c,children:"删除这个节点"})]})}const Cd={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]},F5=()=>({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"}),U5=(e,t)=>{var n,i;return(((n=t.lastRun)==null?void 0:n.startedAt)??-1)-(((i=e.lastRun)==null?void 0:i.startedAt)??-1)||(t.updatedAt??0)-(e.updatedAt??0)||e.name.localeCompare(t.name,"zh-CN")},Z_="adg.pipelines.last",B5=()=>{try{return localStorage.getItem(Z_)}catch{return null}},H5=e=>{try{localStorage.setItem(Z_,e)}catch{}};function Z5({client:e,openSettings:t,arg:n}){const i=we(e.connection.status),r=An(3e4),[o,c]=b.useState(null),[u,d]=b.useState(null),[h,m]=b.useState(null),[g,p]=b.useState(""),[x,y]=b.useState([]),[S,N]=b.useState(null),[k,E]=b.useState(null),[j,A]=b.useState(null),[P,L]=b.useState(null),[B,V]=b.useState(0);b.useEffect(()=>e.connection.on("pipelines/changed",()=>V(se=>se+1)),[e]);const M=we(e.capabilities),[z,D]=b.useState(null),[U,I]=b.useState(0);b.useEffect(()=>e.connection.on("schedule/changed",()=>I(se=>se+1)),[e]),b.useEffect(()=>{if(i.state!=="open"||!M.has("schedule"))return;let se=!0;return e.connection.call("schedule/status",{}).then(ne=>{se&&D(ne.settings)}).catch(()=>{}),()=>{se=!1}},[e,i.state,M,U]);const T=async se=>{try{D((await e.connection.call("schedule/settings/set",se)).settings)}catch(ne){L(Ie(ne))}};b.useEffect(()=>{n!==void 0&&d(n)},[n]),b.useEffect(()=>{if(i.state!=="open")return;let se=!0;return e.connection.call("pipelines/list",{}).then(ne=>{if(!se)return;const ie=[...ne.items].sort(U5);c(ie);const pe=B5();d(Ce=>{var fe,ve;return Ce??((fe=ie.find(ue=>ue.id===pe))==null?void 0:fe.id)??((ve=ie[0])==null?void 0:ve.id)??null})}).catch(ne=>{se&&L(Ie(ne))}),()=>{se=!1}},[e,i.state,B]),b.useEffect(()=>{if(u===null||i.state!=="open"||(h==null?void 0:h.id)===u&&(o!=null&&o.every(ne=>ne.id!==u)))return;let se=!0;return e.connection.call("pipelines/get",{id:u}).then(ne=>{if(!se)return;const ie=kM(ne);H5(ie.id),m(ie),p(JSON.stringify(ie)),E(null)}).catch(()=>{}),e.connection.call("pipelines/runs",{pipelineId:u,limit:10}).then(ne=>{se&&y(ne.items)}).catch(()=>{}),N(null),()=>{se=!1}},[e,u,i.state,B]),b.useEffect(()=>e.connection.on("pipelines/run",se=>{se.pipelineId===u&&y(ne=>[se,...ne.filter(ie=>ie.id!==se.id)].sort((ie,pe)=>pe.startedAt-ie.startedAt).slice(0,10))}),[e,u]);const O=h!==null&&JSON.stringify(h)!==g,$=h!==null&&o!==null&&o.every(se=>se.id!==h.id),F=x.find(se=>{var ne;return se.id===(S??((ne=x[0])==null?void 0:ne.id))}),H=x.find(se=>se.state==="running"),Z=H!==void 0&&(H.stopping!==void 0||j==="cancel");b.useEffect(()=>{if(h===null||!h.nodes.some(ne=>!Hi(ne))){E(null);return}const se=setTimeout(()=>{e.connection.call("pipelines/check",{pipeline:h}).then(E).catch(()=>{})},400);return()=>clearTimeout(se)},[e,h]);const G=async(se,ne)=>{A(se),L(null);try{await ne()}catch(ie){L(Ie(ie))}finally{A(null)}},q=()=>G("save",async()=>{if(h===null)return;const se=await e.connection.call("pipelines/save",{pipeline:h});m(se.pipeline),p(JSON.stringify(se.pipeline)),E(se.check),d(se.pipeline.id)}),X=se=>G("run",async()=>{if(h===null)return;(O||$)&&await q();const ne=await e.connection.call("pipelines/run",{id:h.id,...se===void 0?{}:{from:se}});N(ne.id)}),Y=()=>G("remove",async()=>{h!==null&&($||await e.connection.call("pipelines/remove",{id:h.id}),m(null),d(null))}),re=b.useCallback(se=>m(se),[]),ee=()=>{const se=F5();m(se),p(""),d(se.id),y([]),E(null)};return s.jsxs("section",{className:"main scripts-page pipelines-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"编排"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"流水线"})]}),s.jsx(q5,{list:o??[],current:h,isNew:$,now:r,onPick:d}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>t("schedule"),children:[s.jsx(J,{name:"settings"}),"定时与自启"]}),s.jsxs("button",{className:"primary small-button",onClick:ee,children:[s.jsx(J,{name:"plus"}),"新建流水线"]})]})]}),s.jsx("div",{className:"pipeline-main",children:h===null?s.jsxs("div",{className:"empty",children:[s.jsx(J,{name:"flow"}),o!==null&&o.length===0?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"还没有流水线。"}),s.jsx("p",{className:"muted small",children:"新建一条,或对 agent 说「先跑方舟日常,同时跑三月七,都完了发飞书」"})]}):s.jsx("p",{children:"在上面选一条流水线,或新建一条。"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"pipeline-toolbar",children:[s.jsx("input",{className:"text-input plain pipeline-name",value:h.name,maxLength:60,"aria-label":"流水线名称",onChange:se=>m({...h,name:se.target.value})}),h.draft===!0&&s.jsx("span",{className:"badge warn",title:"agent 生成的草稿:保存后才会按定时运行",children:"agent 草稿"}),O&&s.jsx("span",{className:"muted small",children:"未保存"}),s.jsx("span",{className:"spacer"}),Z?s.jsxs("button",{className:"danger-outline small-button stopping",disabled:!0,"aria-busy":"true",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),"正在停止…"]}):H!==void 0?s.jsx("button",{className:"danger-outline small-button",disabled:j!==null,onClick:()=>void G("cancel",()=>e.connection.call("pipelines/cancel",{runId:H.id})),children:"取消运行"}):s.jsxs("button",{className:"small-button",disabled:j!==null||!h.nodes.some(se=>!Hi(se))||(k==null?void 0:k.ok)===!1,onClick:()=>void X(),children:[s.jsx(J,{name:"arrow"}),"运行"]}),s.jsx("button",{className:"primary small-button",disabled:j!==null||!O&&!$&&h.draft!==!0,onClick:()=>void q(),children:j==="save"?"保存中…":h.draft===!0&&!O?"确认并保存":"保存"}),s.jsx("button",{className:"small-button",disabled:j!==null||H!==void 0,onClick:()=>void Os({title:`删除流水线「${h.name}」?`,message:"它的步骤和定时都会删掉,不能撤销。",confirmLabel:"删除",danger:!0}).then(se=>{se&&Y()}),children:"删除"})]}),Z&&s.jsxs("div",{className:"notice info left small pipeline-stopping",role:"status",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),s.jsxs("span",{children:["已收到停止指令。",H.stopping??"正在通知正在运行的步骤…"]})]}),P!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:P})]}),s.jsx(z5,{client:e,pipeline:h,onChange:re,run:F,check:k,runFrom:H!==void 0||j!==null||(k==null?void 0:k.ok)===!1?void 0:se=>void X(se),idle:s.jsx(G5,{pipeline:h,check:k,runs:x,shownRun:F==null?void 0:F.id,onShowRun:N,others:o??[],onChange:re,now:r,startup:z,onStartup:se=>void T(se)})},h.id)]})})]})}function W5({check:e,pipeline:t}){if(e===null)return null;const n=i=>{const r=t.nodes.find(o=>o.id===i);return r===void 0?"":`${r.title??r.id}:`};return s.jsxs("section",{className:"side-pane",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"运行前检查"}),s.jsx("p",{className:"muted small",children:e.estimateMinutes===void 0?"部分任务没有预计时长":`预计约 ${e.estimateMinutes} 分钟`})]}),s.jsx("span",{className:`badge ${e.ok?"ok":"warn"}`,children:e.ok?"可以运行":"有问题"})]}),e.issues.length===0&&s.jsx("div",{className:"muted small",children:"没有发现问题。"}),s.jsx("ul",{className:"incident-steps",children:e.issues.map((i,r)=>s.jsxs("li",{className:i.level==="error"||i.level==="warning"?"failed":"",children:[i.level==="error"?"✗":i.level==="warning"?"!":"ℹ"," ",n(i.nodeId),i.message]},r))})]})}function V5({runs:e,shown:t,onShow:n,now:i}){if(e.length===0)return s.jsx("section",{className:"side-pane",children:s.jsx("p",{className:"muted small",children:"还没有运行过。"})});const r={manual:"手动",schedule:"定时",autostart:"启动时",agent:"agent",after:"接续"};return s.jsxs("section",{className:"side-pane",children:[s.jsx("div",{className:"run-history",children:e.map(o=>s.jsxs("button",{className:`run-row ${o.id===t?"active":""}`,onClick:()=>n(o.id),children:[s.jsx("span",{className:`badge ${Cd[o.state][0]}`,children:Cd[o.state][1]}),s.jsx("span",{className:"run-title",children:r[o.trigger.kind]??o.trigger.kind}),s.jsx("span",{className:"muted small run-outcome",children:o.outcome??"…"}),s.jsx("span",{className:"session-time",children:Et(o.startedAt,i)})]},o.id))}),s.jsx("p",{className:"muted small",children:"选中一次运行,画布上的节点会显示它的状态;点节点看详情和对应的脚本运行。"})]})}function q5({list:e,current:t,isNew:n,now:i,onPick:r}){const[o,c]=b.useState(!1),u=b.useRef(null);return b.useEffect(()=>{if(!o)return;const d=h=>{u.current!==null&&!u.current.contains(h.target)&&c(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[o]),e.length===0&&t===null?s.jsx("span",{className:"spacer"}):s.jsxs("div",{className:"pipeline-switcher",ref:u,children:[s.jsxs("button",{className:"small-button switcher-button","aria-haspopup":"listbox","aria-expanded":o,onClick:()=>c(d=>!d),children:[s.jsx(J,{name:"flow"}),s.jsxs("span",{className:"switcher-name",children:[(t==null?void 0:t.name)??"选择流水线",n?"(未保存)":""]}),s.jsxs("span",{className:"muted small",children:[e.length," 条"]}),s.jsx(J,{name:"chevron-down"})]}),o&&s.jsxs("div",{className:"switcher-menu",role:"listbox","aria-label":"流水线",children:[e.map(d=>s.jsxs("button",{role:"option","aria-selected":d.id===(t==null?void 0:t.id),className:`switcher-item ${d.id===(t==null?void 0:t.id)&&!n?"active":""}`,onClick:()=>{r(d.id),c(!1)},children:[s.jsxs("span",{className:"switcher-item-main",children:[s.jsx("span",{children:d.name}),s.jsxs("span",{className:"muted small",children:[d.nodes," 个步骤",d.schedule.enabled&&d.schedule.times.length>0?` · 每天 ${d.schedule.times.join("、")}`:"",d.lastRun===void 0?"":` · ${Et(d.lastRun.startedAt,i)}`]})]}),d.draft?s.jsx("span",{className:"badge warn",children:"草稿"}):d.lastRun!==void 0?s.jsx("span",{className:`badge ${Cd[d.lastRun.state][0]}`,children:Cd[d.lastRun.state][1]}):null]},d.id)),e.length===0&&s.jsx("div",{className:"muted small pad",children:"还没有保存的流水线"})]})]})}function G5({pipeline:e,check:t,runs:n,shownRun:i,onShowRun:r,others:o,onChange:c,now:u,startup:d,onStartup:h}){const[m,g]=b.useState(n.some(x=>x.state==="running")?"runs":"check"),p=(t==null?void 0:t.issues.filter(x=>x.level==="error").length)??0;return s.jsxs("div",{className:"pipeline-side",children:[s.jsxs("nav",{className:"tabs side-tabs",role:"tablist","aria-label":"流水线",children:[s.jsxs("button",{role:"tab","aria-selected":m==="check",className:m==="check"?"active":"",onClick:()=>g("check"),children:["检查",p>0?` · ${p}`:""]}),s.jsx("button",{role:"tab","aria-selected":m==="runs",className:m==="runs"?"active":"",onClick:()=>g("runs"),children:"运行记录"}),s.jsx("button",{role:"tab","aria-selected":m==="schedule",className:m==="schedule"?"active":"",onClick:()=>g("schedule"),children:"定时与失败"})]}),m==="check"&&(t===null?s.jsx("p",{className:"muted small pad",children:"加上步骤后会自动检查。"}):s.jsx(W5,{check:t,pipeline:e})),m==="runs"&&s.jsx(V5,{runs:n,shown:i,onShow:r,now:u}),m==="schedule"&&s.jsx(Y5,{pipeline:e,others:o,onChange:c,startup:d,onStartup:h}),s.jsx("p",{className:"muted small pad",children:"点画布上的节点或连线来修改它;选中后按 Delete 删除。Ctrl+点击或按住 Shift 拖动可以选多个节点,Ctrl+C / Ctrl+V 复制粘贴,Ctrl+Z 撤销、Ctrl+Y 重做。"})]})}const K5=["日","一","二","三","四","五","六"],Ek={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function Y5({pipeline:e,others:t,onChange:n,startup:i,onStartup:r}){const o=(i==null?void 0:i.autostartPipelines.includes(e.id))===!0,c=e.schedule,[u,d]=b.useState(c.times.join(","));b.useEffect(()=>d(c.times.join(",")),[e.id]);const h=p=>n({...e,schedule:{...c,...p}}),m=b.useMemo(()=>u.split(/[,,\s]+/).map(p=>p.trim()).filter(Boolean).map(p=>/^\d:\d\d$/.test(p)?`0${p}`:p),[u]),g=m.filter(p=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(p));return s.jsxs("section",{className:"side-pane",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.enabled,onChange:p=>h({enabled:p.target.checked})}),"按定时自动运行",e.draft===!0?"(草稿要先保存)":""]}),s.jsx("label",{className:"field-label",htmlFor:"pl-times",children:"时间(24 小时制,多个用逗号分开)"}),s.jsx("input",{id:"pl-times",className:"text-input",value:u,placeholder:"04:30,16:30",onChange:p=>d(p.target.value),onBlur:()=>{g.length===0&&h({times:[...new Set(m)].sort()})}}),g.length>0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsxs("span",{children:["时间写成 HH:MM:",g.join("、")]})]}),s.jsxs("div",{className:"chip-row",role:"group","aria-label":"星期",children:[K5.map((p,x)=>s.jsxs("button",{className:`chip ${c.days.includes(x)?"active":""}`,onClick:()=>h({days:c.days.includes(x)?c.days.filter(y=>y!==x):[...c.days,x].sort()}),children:["周",p]},p)),s.jsx("span",{className:"muted small",children:c.days.length===0?"不选=每天":""})]}),i!==null&&s.jsxs("div",{className:"startup-box",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:o,disabled:e.draft===!0,onChange:p=>r({autostartPipelines:p.target.checked?[...i.autostartPipelines,e.id]:i.autostartPipelines.filter(x=>x!==e.id)})}),"软件启动时运行",e.draft===!0?"(草稿要先保存)":""]}),o&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"check-label sub",children:[s.jsx("input",{type:"checkbox",checked:i.firstStartOnly,onChange:p=>r({firstStartOnly:p.target.checked})}),"只在每天第一次启动时运行(每天从 4:00 算起)"]}),s.jsxs("label",{className:"check-label sub",children:[s.jsx("input",{type:"checkbox",checked:i.skipIfRanToday,onChange:p=>r({skipIfRanToday:p.target.checked})}),"今天(4:00 起)已经成功运行过就跳过"]}),s.jsxs("p",{className:"muted small",children:["打开桌面版(自己打开或开机自启)后",i.autostart?`开机自启时等 ${i.autostartDelaySeconds} 秒、自己打开时等 10 秒`:"等 10 秒","再运行;dsh 崩溃后自动重启不算。和游戏一样,每天从 4:00 算起:凌晨 2 点启动还算前一天。这两项对所有「软件启动时运行」的流水线生效。"]})]})]}),s.jsx("label",{className:"field-label",htmlFor:"pl-catchup",children:"错过多少分钟以内还补跑(睡眠、刚开机)"}),s.jsx("input",{id:"pl-catchup",className:"text-input plain",type:"number",min:0,max:720,value:c.catchUpMinutes,onChange:p=>h({catchUpMinutes:Math.max(0,Math.min(720,Math.round(Number(p.target.value)||0)))})}),s.jsx("label",{className:"field-label",htmlFor:"pl-after",children:"另一条流水线成功后接着运行"}),s.jsx(Vt,{id:"pl-after",value:c.after??"",onChange:p=>{const{after:x,...y}=c;n({...e,schedule:p===""?y:{...y,after:p}})},options:[{value:"",label:"不接续"},...t.filter(p=>p.id!==e.id).map(p=>({value:p.id,label:p.name}))]}),s.jsx("label",{className:"field-label",htmlFor:"pl-fail",children:"节点失败时(节点自己没设置时)"}),s.jsxs("div",{className:"select-stack",children:[s.jsx(Vt,{id:"pl-fail","aria-label":"重试次数",value:String(e.onFailure.retries),options:B_,onChange:p=>n({...e,onFailure:{...e.onFailure,retries:Number(p)}})}),s.jsx(Vt,{"aria-label":"仍失败时",value:e.onFailure.then,options:H_,onChange:p=>n({...e,onFailure:{...e.onFailure,then:p}})})]}),s.jsx("div",{className:"field-label",children:"结束后"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:e.closeGameAfter,onChange:p=>n({...e,closeGameAfter:p.target.checked})}),"关闭游戏(任务玩过的电脑游戏和模拟器里的游戏)"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:e.stopEmulatorAfter,onChange:p=>n({...e,stopEmulatorAfter:p.target.checked})}),"关闭模拟器"]}),s.jsx("label",{className:"field-label",htmlFor:"pl-power",children:"然后电脑"}),s.jsx(Vt,{id:"pl-power",value:e.powerAfter,onChange:p=>n({...e,powerAfter:p}),options:[{value:"none",label:"保持开着"},{value:"sleep",label:"睡眠"},{value:"hibernate",label:"休眠",hint:"断电也不丢失进度,唤醒比睡眠慢"},{value:"shutdown",label:"关机"}]}),e.powerAfter!=="none"&&s.jsxs("p",{className:"muted small",children:["等其他任务都结束后先倒计时",i===null?"":` ${i.powerCountdownSeconds} 秒`,",界面和飞书里都可以取消;15 分钟内还有定时任务就不",Ek[e.powerAfter],"。在这里手动点运行、或运行被取消时不会",Ek[e.powerAfter],"。",e.powerAfter==="shutdown"?"关机会强制关闭所有程序。":"想让电脑按时醒来跑定时任务,在「设置 → 定时与自启」打开定时唤醒。"]})]})}const Ck=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"}),Ak={fired:["ok","已运行"],missed:["warn","错过"],skipped:["","跳过"],failed:["warn","没能运行"]};function X5({client:e}){const t=we(e.connection.status),n=An(3e4),[i,r]=b.useState(null),[o,c]=b.useState(0),[u,d]=b.useState(!1),[h,m]=b.useState(null);b.useEffect(()=>e.connection.on("schedule/changed",()=>c(x=>x+1)),[e]),b.useEffect(()=>e.connection.on("pipelines/changed",()=>c(x=>x+1)),[e]),b.useEffect(()=>e.connection.on("schedule/power",x=>r(y=>y===null?y:{...y,power:x})),[e]),b.useEffect(()=>{if(t.state!=="open")return;let x=!0;return e.connection.call("schedule/status",{}).then(y=>{x&&r(y)}).catch(y=>{x&&m(Ie(y))}),()=>{x=!1}},[e,t.state,o]);const g=async x=>{d(!0),m(null);try{r(await e.connection.call("schedule/settings/set",x))}catch(y){m(Ie(y))}finally{d(!1)}},p=i==null?void 0:i.settings;return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"定时与自启"}),s.jsx("p",{children:"每条流水线的运行时间和结束后做什么(关游戏、关模拟器、睡眠或关机)在「编排」页里设置。这里设置电脑开机登录后是否自动启动 MultiGameAssistant,以及电脑睡着时要不要按时醒来。关掉窗口后程序在托盘里继续运行,定时照常执行。"}),i!==null&&p!==void 0&&s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"开机自启"}),s.jsx("p",{className:"muted small",children:i.autostart.detail??(i.autostart.registered?"已在 Windows 任务计划程序中注册(登录后启动,最小化到托盘)":"登录 Windows 后自动启动并最小化到托盘")})]}),s.jsx("span",{className:`badge ${i.autostart.registered?"ok":""}`,children:i.autostart.registered?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:p.autostart,disabled:u||!i.autostart.available,onChange:x=>void g({autostart:x.target.checked})}),"登录 Windows 后自动启动"]}),s.jsxs("div",{className:"notice info left small",children:[s.jsx(J,{name:"info"}),s.jsxs("span",{children:["软件启动时运行哪些流水线、是否只在每天第一次启动时运行,在「编排」页每条流水线的「定时与失败」里设置。",p.autostartPipelines.length>0?`现在有 ${p.autostartPipelines.length} 条。`:""]})]}),s.jsx("label",{className:"field-label",htmlFor:"autostart-delay",children:"开机自启后等待多少秒再运行流水线(等网络、桌面和显卡驱动就绪)"}),s.jsx("input",{id:"autostart-delay",className:"text-input plain",type:"number",min:0,max:1800,defaultValue:p.autostartDelaySeconds,onBlur:x=>void g({autostartDelaySeconds:Math.max(0,Math.min(1800,Math.round(Number(x.target.value)||0)))})}),i.autostarted&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(J,{name:"info"}),s.jsx("span",{children:"这次是开机自动启动的。"})]})]}),i!==null&&p!==void 0&&s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"定时唤醒"}),s.jsx("p",{className:"muted small",children:i.wake.detail??(i.wake.registered&&i.wake.next!==void 0?`已在 Windows 任务计划程序中注册,下次在 ${Ck(i.wake.next)} 唤醒`:"电脑睡眠(或休眠)时,在定时任务开始前 2 分钟把它唤醒")})]}),s.jsx("span",{className:`badge ${i.wake.registered?"ok":""}`,children:i.wake.registered?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:p.wakeToRun,disabled:u||!i.wake.available,onChange:x=>void g({wakeToRun:x.target.checked})}),"睡眠时按定时唤醒电脑"]}),s.jsx("p",{className:"muted small",children:"关机后不能唤醒。程序没开着时,唤醒会顺便把它在托盘里打开(不运行「软件启动时运行」的流水线)。要在 Windows 电源选项里允许唤醒定时器:控制面板 → 电源选项 → 更改计划设置 → 更改高级电源设置 → 睡眠 → 允许使用唤醒定时器 → 启用(笔记本的「使用电池」也要改)。"}),s.jsx("h3",{children:"运行时防睡眠"}),s.jsxs("p",{className:"muted small",children:["流水线或脚本运行时,电脑不会自己睡眠;前台脚本(用鼠标键盘的)运行时屏幕也保持亮着。全部结束后恢复 Windows 自己的设置。",i.power.awake?"现在正在防睡眠。":""]}),s.jsx("label",{className:"field-label",htmlFor:"power-countdown",children:"流水线结束后睡眠、休眠或关机前倒计时多少秒(这段时间里可以取消)"}),s.jsx("input",{id:"power-countdown",className:"text-input plain",type:"number",min:10,max:600,defaultValue:p.powerCountdownSeconds,onBlur:x=>void g({powerCountdownSeconds:Math.max(10,Math.min(600,Math.round(Number(x.target.value)||60)))})})]}),i!==null&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"接下来"}),i.upcoming.length===0&&s.jsx("div",{className:"muted small",children:"没有开启定时的流水线。"}),s.jsx("ul",{className:"version-list",children:i.upcoming.map((x,y)=>s.jsxs("li",{children:[s.jsx("span",{className:"version-name",children:Ck(x.at)}),s.jsx("span",{children:x.pipelineName})]},y))})]}),i!==null&&i.history.length>0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"最近的定时记录"}),s.jsx("ul",{className:"version-list",children:i.history.map((x,y)=>{var S,N;return s.jsxs("li",{children:[s.jsx("span",{className:`badge ${((S=Ak[x.outcome])==null?void 0:S[0])??""}`,children:((N=Ak[x.outcome])==null?void 0:N[1])??x.outcome}),s.jsx("span",{children:x.pipelineName}),s.jsxs("span",{className:"muted small",children:[x.slot,x.detail===void 0?"":` · ${x.detail}`]}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"session-time",children:Et(x.at,n)})]},y)})})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"无人值守检查清单"}),s.jsxs("ul",{className:"guide-steps",children:[s.jsxs("li",{children:["前台脚本(如三月七)需要已登录、没有锁屏的桌面:在 Windows 里设置自动登录(运行 ",s.jsx("code",{children:"netplwiz"}),"),关闭屏幕保护程序;睡眠唤醒后不要求登录(设置 → 帐户 → 登录选项 →「需要登录」选「从不」)。"]}),s.jsx("li",{children:"模拟器脚本(如 MAA)不受锁屏影响。"}),s.jsx("li",{children:"运行期间程序会阻止电脑睡眠;想让睡着的电脑按时醒来跑定时任务,打开上面的「定时唤醒」。关机后的电脑不能被唤醒,可以在主板 BIOS 里设置定时开机,再配合开机自启。"}),s.jsx("li",{children:"没接显示器时,游戏可能以很小的分辨率启动;可以接一个 HDMI 假负载(显卡欺骗器)。"}),s.jsx("li",{children:"想在手机上收到结果,先在「设置 → 飞书」接好飞书。"})]})]}),h!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:h})]})]})}const Q5={id:"pipelines",title:"编排",milestone:"M4",requires:["pipelines","scripts","runs"],pages:[{id:"pipelines",title:"编排",icon:"flow",order:20,agent:"pipelines",component:Z5}]},J5={id:"schedule",title:"定时与自启",milestone:"M4",requires:["schedule","pipelines"],settingsPages:[{id:"schedule",title:"定时与自启",order:9,component:X5}]},Im=new Map;function W_(e,t){let n=Im.get(t);return n===void 0&&(n=e.connection.call("games/image",{url:t}).then(i=>`data:${i.mediaType};base64,${i.data}`),n.catch(()=>Im.delete(t)),Im.set(t,n)),n}function V_(e,t){const[n,i]=b.useState(void 0),r=t.filter(o=>o!==void 0).filter((o,c,u)=>u.indexOf(o)===c);return b.useEffect(()=>{i(void 0);let o=!0;return(async()=>{for(const c of r){const u=await W_(e,c).catch(()=>{});if(u!==void 0){o&&i(u);return}}})(),()=>{o=!1}},[e,r.join(`
230
+ `)]),n}function Yo(e,t){const[n,i]=b.useState(void 0);return b.useEffect(()=>{if(i(void 0),t===void 0)return;let r=!0;return W_(e,t).then(o=>{r&&i(o)},()=>{}),()=>{r=!1}},[e,t]),n}const q_=["image/png","image/jpeg","image/gif","image/webp","image/avif"],eH=8*1024*1024;function Fp(e,t){const n=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(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-Math.floor(e/1e3)*1e3}function tH(e){var n;return(((n=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(new Date).find(i=>i.type==="timeZoneName"))==null?void 0:n.value)??"").replace("GMT","UTC")||e}function Ik(e,t){return e===void 0?"":new Date(e+Fp(e,t)).toISOString().slice(0,16)}function Tk(e,t){const n=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(e);if(n===null)return;const i=Date.UTC(Number(n[1]),Number(n[2])-1,Number(n[3]),Number(n[4]),Number(n[5]));return i-Fp(i-Fp(i,t),t)}function nH(e){return new Promise((t,n)=>{if(!q_.includes(e.type)){n(new Error("只支持 png、jpg、gif、webp、avif 图片"));return}if(e.size>eH){n(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=()=>n(new Error("图片读不出来")),i.readAsDataURL(e)})}function Jg({client:e,game:t,activity:n,onDone:i,onCancel:r}){var z;const o=t.timezone,c={name:(n==null?void 0:n.name)??"",kind:(n==null?void 0:n.kind)??"",startsAt:Ik(n==null?void 0:n.startsAt,o),endsAt:Ik(n==null?void 0:n.endsAt,o),url:(n==null?void 0:n.url)??"",description:(n==null?void 0:n.description)??""},[u,d]=b.useState(c),[h,m]=b.useState(null),[g,p]=b.useState(!1),[x,y]=b.useState(!1),[S,N]=b.useState(null),k=b.useRef(null),E=((z=n==null?void 0:n.own)==null?void 0:z.fields.includes("cover"))===!0,j=Yo(e,g||n==null?void 0:n.cover),A=(h==null?void 0:h.src)??j,P=n!==void 0&&(n.sources!==void 0||n.screen!==void 0);b.useEffect(()=>{N(null)},[u]);const L=D=>U=>d(I=>({...I,[D]:U.target.value})),B=D=>{D!==void 0&&nH(D).then(U=>{m(U),p(!1)},U=>N(Ie(U)))},V=D=>{const U=[...D.clipboardData.files].find(I=>I.type.startsWith("image/"));U!==void 0&&(D.preventDefault(),B(U))},M=async()=>{if(u.name.trim()===""){N("活动要有名字");return}const D=u.startsAt===""?null:Tk(u.startsAt,o)??null,U=u.endsAt===""?null:Tk(u.endsAt,o)??null;if(D!==null&&U!==null&&U<=D){N("结束时间要晚于开始时间");return}const I=$=>n===void 0||u[$]!==c[$],T=$=>I($)?{[$]:u[$].trim()===""?null:u[$].trim()}:{},O={game:t.id,...n===void 0?{}:{activityId:n.id},...T("name"),...T("kind"),...T("url"),...T("description"),...I("startsAt")?{startsAt:D}:{},...I("endsAt")?{endsAt:U}:{},...h!==null?{image:h.image}:g?{cover:null}:{}};y(!0),N(null);try{i(await e.connection.call("games/activity/save",O))}catch($){N(Ie($))}finally{y(!1)}};return s.jsxs("form",{className:"activity-editor",onSubmit:D=>{D.preventDefault(),M()},onPaste:V,onKeyDown:D=>{D.key==="Escape"&&r()},children:[s.jsxs("div",{className:"activity-editor-head",children:[s.jsx("strong",{children:n===void 0?`添加${t.name}的活动`:"编辑活动"}),P&&s.jsx("span",{className:"muted small",children:"你改的内容比数据站优先,刷新不会改掉;没改的照来源走。"})]}),s.jsxs("div",{className:"activity-editor-body",children:[s.jsxs("div",{className:"activity-editor-image",children:[s.jsx("button",{type:"button",className:`activity-image-pick ${A===void 0?"empty":""}`,onClick:()=>{var D;return(D=k.current)==null?void 0:D.click()},title:"选一张图片(也可以直接粘贴)",children:A!==void 0?s.jsx("img",{src:A,alt:""}):s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"image"}),s.jsx("span",{children:"选图片"}),s.jsx("small",{children:"或粘贴"})]})}),s.jsx("input",{ref:k,type:"file",accept:q_.join(","),hidden:!0,onChange:D=>{var U;B((U=D.target.files)==null?void 0:U[0]),D.target.value=""}}),s.jsxs("div",{className:"activity-image-tools",children:[s.jsx("span",{className:"muted small",children:A===void 0?"点上面选图,或直接粘贴":"点图片换一张,或直接粘贴"}),(h!==null||E&&!g)&&s.jsx("button",{type:"button",className:"link-button small muted",onClick:()=>{m(null),E&&p(!0)},children:h!==null?"不用这张":P?"用回来源的图":"去掉图片"})]})]}),s.jsxs("div",{className:"activity-editor-fields top",children:[s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field wide",children:[s.jsx("span",{className:"field-title",children:"活动名"}),s.jsx("input",{className:"text-input plain",autoFocus:n===void 0,maxLength:60,value:u.name,onChange:L("name"),placeholder:"例如:周年庆签到"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"类型"}),s.jsx("input",{className:"text-input plain",maxLength:20,value:u.kind,onChange:L("kind"),placeholder:"签到、SideStory…"})]})]}),s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field date",children:[s.jsx("span",{className:"field-title",children:"开始"}),s.jsx("input",{className:"text-input plain",type:"datetime-local",value:u.startsAt,onChange:L("startsAt")})]}),s.jsxs("label",{className:"field date",children:[s.jsx("span",{className:"field-title",children:"结束"}),s.jsx("input",{className:"text-input plain",type:"datetime-local",value:u.endsAt,onChange:L("endsAt")})]})]}),s.jsxs("span",{className:"muted small",children:["时间按游戏服务器时间(",tH(o),")",u.endsAt===""?";不填结束时间的会一直留着,直到你去掉它":""]})]}),s.jsxs("div",{className:"activity-editor-fields full",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"活动页面(可选)"}),s.jsx("input",{className:"text-input plain",type:"url",value:u.url,onChange:L("url"),placeholder:"https://…"})]}),s.jsxs("label",{className:"field description",children:[s.jsxs("span",{className:"field-title",children:["说明(可选)",s.jsxs("small",{className:"muted",children:[u.description.length,"/500"]})]}),s.jsx("textarea",{className:"text-input plain",rows:8,maxLength:500,value:u.description,onChange:L("description"),placeholder:"要做什么、奖励是什么"})]})]})]}),s.jsxs("div",{className:"activity-editor-actions",children:[s.jsx("button",{className:"small-button primary",type:"submit",disabled:x,children:x?"保存中…":n===void 0?"添加":"保存"}),s.jsx("button",{className:"small-button",type:"button",disabled:x,onClick:r,children:"取消"}),S!==null&&s.jsx("span",{className:"tone-error small",children:S})]})]})}const Qs=864e5,$k={name:"名字",startsAt:"开始时间",endsAt:"结束时间",kind:"类型",description:"说明",url:"页面",cover:"图片"},Tm=2,sH=28,Kr=["#3b82c4","#c0567d","#2f9e7a","#c98a1b","#7a62d6","#d2643c","#4d9a3c","#2a93a8","#a86bb8","#8a7a3a"],Mk="adg:games:overview:shown",Rk="adg:games:overview:mode";function Ok(e,t){try{const n=localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}}function Pk(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function rs(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 iH(e,t){return new Date(e).toLocaleDateString("zh-CN",{timeZone:t,month:"numeric",day:"numeric"})}function id(e,t){const n=e-t;return n<=0?"已结束":n<Qs?`${Math.max(1,Math.floor(n/36e5))} 小时`:`${Math.floor(n/Qs)} 天`}function rH({client:e,games:t,activities:n,now:i,soonDays:r,onOpenGame:o,onChanged:c}){const[u,d]=b.useState(()=>Ok(Mk,null)),[h,m]=b.useState(()=>Ok(Rk,"time")),[g,p]=b.useState(null);b.useEffect(()=>Pk(Mk,u),[u]),b.useEffect(()=>Pk(Rk,h),[h]);const x=b.useMemo(()=>new Map(t.map((U,I)=>[U.id,Kr[I%Kr.length]])),[t]),y=U=>u===null||u.includes(U),S=U=>d(I=>{const T=I??t.map($=>$.id),O=T.includes(U)?T.filter($=>$!==U):[...T,U];return O.length===t.length?null:O}),N=new Date(i-Tm*Qs).setHours(0,0,0,0),k=N+(Tm+sH)*Qs,E=U=>Math.min(100,Math.max(0,(U-N)/(k-N)*100)),j=n.filter(U=>y(U.game)&&(U.endsAt===void 0||Math.max(U.endsAt,U.shopEndsAt??0)>i)),A=(U,I)=>(U.endsAt??1/0)-(I.endsAt??1/0)||U.name.localeCompare(I.name),P=j.filter(U=>(U.startsAt??0)<=i),L=j.filter(U=>U.startsAt!==void 0&&U.startsAt>i).sort((U,I)=>U.startsAt-I.startsAt),B=[];if(h==="time"){const U=N+(Tm+7)*Qs,I=P.filter($=>$.endsAt!==void 0&&$.endsAt-i<r*Qs).sort(A),T=P.filter($=>!I.includes($)&&$.endsAt!==void 0&&$.endsAt<U).sort(A),O=P.filter($=>!I.includes($)&&!T.includes($)).sort(A);B.push({key:"soon",title:"快结束",hint:`${r} 天内`,rows:I},{key:"week",title:"本周内结束",rows:T},{key:"later",title:"之后结束",rows:O},{key:"upcoming",title:"即将开始",rows:L})}else for(const U of t){if(!y(U.id))continue;const I=[...P.filter(T=>T.game===U.id).sort(A),...L.filter(T=>T.game===U.id)];B.push({key:U.id,title:U.name,rows:I,game:U})}const V=P.reduce((U,I)=>{const T=rs(I);return{...U,[T.state]:U[T.state]+1}},{finished:0,partial:0,unknown:0}),M=P.filter(U=>U.endsAt!==void 0&&U.endsAt-i<r*Qs&&rs(U).state!=="finished").length,z=[];for(let U=N;U<=k;U+=Qs){const I=Math.round((U-new Date(i).setHours(0,0,0,0))/Qs);z.push({at:U,...I>0&&I%7===0?{label:iH(U,Intl.DateTimeFormat().resolvedOptions().timeZone)}:{}})}const D=U=>n.filter(I=>I.game===U&&(I.startsAt??0)<=i&&(I.endsAt===void 0||Math.max(I.endsAt,I.shopEndsAt??0)>i));return s.jsxs("div",{className:"games-overview",children:[s.jsx("div",{className:"game-tiles",role:"group","aria-label":"各游戏",children:t.map(U=>{const I=D(U.id);return s.jsx(aH,{client:e,game:U,color:x.get(U.id)??Kr[0],now:i,shown:y(U.id),running:I.length,soon:I.filter(T=>T.endsAt!==void 0&&T.endsAt-i<r*Qs&&rs(T).state!=="finished").length,covers:I.map(T=>T.cover).filter(T=>(T==null?void 0:T.startsWith("shot:"))!==!0).slice(0,6),onOpen:()=>o(U.id),onToggle:()=>S(U.id)},U.id)})}),s.jsxs("section",{className:"card games-overview-board",children:[s.jsxs("div",{className:"ov-toolbar",children:[s.jsxs("div",{className:"ov-stats",children:[s.jsx(Pl,{value:P.length,label:"进行中"}),s.jsx(Pl,{value:M,label:"快结束未做完",tone:M>0?"warn":void 0}),s.jsx(Pl,{value:V.finished,label:"做完"}),s.jsx(Pl,{value:V.partial,label:"做了一部分"}),s.jsx(Pl,{value:V.unknown,label:"没记录"})]}),s.jsxs("div",{className:"segmented-control ov-mode",role:"group","aria-label":"排序",children:[s.jsx("button",{className:h==="time"?"active":"","aria-pressed":h==="time",onClick:()=>m("time"),children:"按时间"}),s.jsx("button",{className:h==="game"?"active":"","aria-pressed":h==="game",onClick:()=>m("game"),children:"按游戏"})]})]}),s.jsxs("div",{className:"ov-grid",children:[s.jsx("div",{className:"ov-lines","aria-hidden":"true",children:z.filter(U=>U.label!==void 0).map(U=>s.jsx("i",{style:{left:`${E(U.at)}%`}},U.at))}),s.jsxs("div",{className:"ov-row ov-axis","aria-hidden":"true",children:[s.jsx("div",{className:"ov-label"}),s.jsxs("div",{className:"ov-track",children:[z.map(U=>s.jsx("span",{className:`ov-tick ${U.label!==void 0?"major":""}`,style:{left:`${E(U.at)}%`},children:U.label!==void 0&&s.jsx("em",{children:U.label})},U.at)),s.jsx("span",{className:"ov-today-label",style:{left:`${E(i)}%`},children:"今天"})]}),s.jsx("div",{className:"ov-side"})]}),B.every(U=>U.rows.length===0)&&s.jsxs("div",{className:"empty",children:[s.jsx(J,{name:"calendar"}),s.jsx("p",{children:t.length===0?"没有游戏。":"显示的游戏现在没有活动。点「刷新全部」读取,或点上面游戏卡片的眼睛多显示几个。"})]}),B.filter(U=>U.rows.length>0).map(U=>{var I;return s.jsxs("div",{className:`ov-section ${U.key==="soon"?"warn":""} ${U.game!==void 0?"by-game":""}`,style:U.game===void 0?void 0:{"--game":x.get(U.game.id)},children:[s.jsxs("div",{className:"ov-section-title",children:[U.game!==void 0&&s.jsx("span",{className:"game-dot"}),s.jsx("span",{className:"ov-section-name",children:U.title}),s.jsx("span",{className:"ov-section-count",children:U.rows.length}),U.hint!==void 0&&s.jsx("span",{className:"muted small",children:U.hint}),((I=U.game)==null?void 0:I.version)!==void 0&&s.jsxs("span",{className:"muted small ov-section-version",children:[U.game.version.name,U.game.version.title===void 0?"":`「${U.game.version.title}」`]}),U.game!==void 0&&s.jsxs("button",{className:"link-button small ov-section-open",onClick:()=>o(U.game.id),children:["打开",s.jsx(J,{name:"chevron"})]})]}),U.rows.map(T=>{const O=t.find($=>$.id===T.game);return s.jsx(oH,{client:e,activity:T,game:O,color:x.get(T.game)??Kr[0],showGame:h==="time",now:i,soonDays:r,x:E,open:g===T.id,onToggle:()=>p($=>$===T.id?null:T.id),onOpenGame:()=>o(T.game),onChanged:c},T.id)})]},U.key)}),s.jsx("div",{className:"ov-today",style:{left:`calc(var(--ov-label) + (100% - var(--ov-label) - var(--ov-side)) * ${E(i)/100})`},"aria-hidden":"true"})]})]})]})}function Pl({value:e,label:t,tone:n}){return s.jsxs("span",{className:`ov-stat ${n??""} ${e===0?"zero":""}`,children:[s.jsx("strong",{children:e}),t]})}function aH({client:e,game:t,color:n,covers:i,now:r,running:o,soon:c,shown:u,onOpen:d,onToggle:h}){const m=t.version,g=V_(e,[m==null?void 0:m.cover,t.art,...i]),p=(m==null?void 0:m.endsAt)!==void 0&&m.endsAt>r?` · 还剩 ${id(m.endsAt,r)}`:"";return s.jsxs("article",{className:`game-tile ${g===void 0?"no-art":""} ${u?"":"off"}`,style:{"--game":n},children:[g!==void 0&&s.jsx("img",{className:"game-tile-art",src:g,alt:""}),s.jsx("span",{className:"game-tile-shade"}),s.jsxs("button",{className:"game-tile-open",title:`打开${t.name}`,onClick:d,children:[s.jsxs("span",{className:"game-tile-name",children:[s.jsx("span",{className:"game-dot"}),t.name]}),s.jsx("span",{className:"game-tile-version",children:m===void 0?"没有版本信息":`${m.name}${m.title===void 0?"":`「${m.title}」`}${p}`}),s.jsxs("span",{className:"game-tile-counts",children:[s.jsxs("span",{children:[s.jsx("b",{children:o})," 进行中"]}),c>0&&s.jsxs("span",{className:"soon",children:[s.jsx("b",{children:c})," 快结束"]})]})]}),s.jsx("button",{className:"game-tile-eye","aria-pressed":u,"aria-label":`在时间线上显示${t.name}`,title:u?"在时间线上隐藏":"在时间线上显示",onClick:h,children:s.jsx(J,{name:u?"eye":"eye-off"})})]})}function oH({client:e,activity:t,game:n,color:i,showGame:r,now:o,soonDays:c,x:u,open:d,onToggle:h,onOpenGame:m,onChanged:g}){const p=rs(t),x=(t.startsAt??0)<=o,y=t.endsAt,S=x&&y!==void 0&&y-o<c*Qs&&p.state!=="finished",N=u(t.startsAt??o-30*Qs),k=y===void 0?100:u(y),E=t.shopEndsAt===void 0||y===void 0||t.shopEndsAt<=y?void 0:u(t.shopEndsAt),j=Yo(e,t.cover);return s.jsxs("div",{className:`ov-item ${d?"open":""}`,style:{"--game":i},children:[s.jsxs("button",{className:`ov-row ${S?"soon":""} ${p.state==="finished"?"finished":""}`,onClick:h,"aria-expanded":d,children:[s.jsxs("div",{className:"ov-label",children:[s.jsx("span",{className:"ov-thumb",children:j!==void 0&&s.jsx("img",{src:j,alt:"",decoding:"async"})}),s.jsxs("span",{className:"ov-text",children:[s.jsx("span",{className:"ov-name",title:t.name,children:t.name}),(r||t.kind!==void 0)&&s.jsxs("span",{className:"ov-meta",children:[r&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"game-dot"}),(n==null?void 0:n.name)??t.game]}),t.kind!==void 0&&s.jsx("span",{className:"ov-kind",children:t.kind})]})]})]}),s.jsxs("div",{className:"ov-track",children:[s.jsx("span",{className:`ov-bar ${x?"":"future"} ${N<=0?"cut-left":""} ${y===void 0||k>=100?"cut-right":""}`,style:{left:`${N}%`,width:`${Math.max(1.2,k-N)}%`},children:p.total>0&&s.jsx("span",{className:"ov-bar-done",style:{width:`${p.done/p.total*100}%`}})}),E!==void 0&&s.jsx("span",{className:"ov-shop",style:{left:`${k}%`,width:`${Math.max(.6,E-k)}%`},title:"之后只开商店"})]}),s.jsxs("div",{className:"ov-side",children:[s.jsx("span",{className:`ov-left ${S?"tone-warn":""}`,children:x?y===void 0?"时间未知":y<=o&&t.shopEndsAt!==void 0?`商店 ${id(t.shopEndsAt,o)}`:id(y,o):`${id(t.startsAt,o)}后开始`}),s.jsx(ex,{progress:p})]})]}),d&&s.jsx(cH,{client:e,activity:t,game:n,onOpenGame:m,onChanged:g})]})}function ex({progress:e}){return e.state==="finished"?s.jsxs("span",{className:"ov-progress done",children:[s.jsx(J,{name:"check"}),"做完了"]}):e.state==="unknown"?s.jsx("span",{className:"ov-progress unknown",children:"未记录"}):s.jsxs("span",{className:"ov-progress partial",title:`做了 ${e.done} 项,还剩 ${e.total-e.done} 项`,children:[s.jsx("span",{className:"ov-ring",style:{"--pct":`${e.done/e.total*100}%`}}),e.done,"/",e.total]})}function lH({activity:e,game:t,chosen:n,onChoose:i}){const r=An(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 c=(t==null?void 0:t.timezone)??"Asia/Shanghai",u=x=>new Date(x).toLocaleString("zh-CN",{timeZone:c,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(n===x?null:x),m=o.length===0&&e.screen===void 0,g=e.own!==void 0&&(e.own.startsAt!==void 0||e.own.endsAt!==void 0||e.own.cover!==void 0),p=e.screen!==void 0&&(e.screen.endsAt!==void 0||e.screen.image!==void 0);return s.jsxs("div",{className:"activity-sources",children:[s.jsx("span",{className:"muted small",children:"来源"}),o.map(x=>{var y;return s.jsxs("button",{className:`fact-chip ${x.web?"web":"site"} ${n===x.id?"on":""}`,"aria-pressed":n===x.id,title:`${d(x)}。点一下用它的图片和时间`,onClick:()=>h(x.id),children:[x.name,s.jsxs("small",{children:[x.web?"网页":"数据站"," · ",Et(x.at,r)]}),o.length>1&&((y=e.shown)==null?void 0:y.endsAt)===x.id&&s.jsx("small",{className:"fact-main",children:"时间以它为准"})]},x.id)}),e.screen!==void 0&&s.jsxs("button",{className:`fact-chip screen ${n===ql?"on":""}`,"aria-pressed":n===ql,disabled:!p,title:`agent 进游戏看到的。${d({endsAt:e.screen.endsAt,cover:e.screen.image})}`,onClick:()=>h(ql),children:["游戏画面",s.jsxs("small",{children:["agent 看过 · ",Et(e.screen.at,r)]})]}),e.own!==void 0&&s.jsxs("button",{className:`fact-chip own ${n===So?"on":""}`,"aria-pressed":n===So,disabled:!g||m,title:m?"你自己添加的活动":`你改过:${e.own.fields.map(x=>$k[x]).join("、")};比来源优先,刷新不会改掉`,onClick:()=>h(So),children:[m?"我添加的":"我改过",s.jsxs("small",{children:[m?"":`${e.own.fields.map(x=>$k[x]).join("、")} · `,Et(e.own.at,r)]})]}),n!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>i(null),children:"恢复默认"})]})}function cH({client:e,activity:t,game:n,onOpenGame:i,onChanged:r,openSession:o}){var T,O;const[c,u]=b.useState(null),[d,h]=b.useState(!1),[m,g]=b.useState(""),[p,x]=b.useState(!1),[y,S]=b.useState(null),[N,k]=b.useState(void 0);b.useEffect(()=>k(void 0),[t]);const E=N??t,[j,A]=b.useState(void 0);b.useEffect(()=>A(void 0),[E.chosen]);const P=$=>{A($),S(null),e.connection.call("games/activity/source",{activityId:E.id,source:$}).then(F=>{k(F),r()},F=>{A(void 0),S(Ie(F))})},L=(n==null?void 0:n.timezone)??"Asia/Shanghai",B=$=>new Date($).toLocaleString("zh-CN",{timeZone:L,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),V=async $=>{x(!0),S(null);try{await e.connection.call("games/activity/progress",{activityId:E.id,...$}),r()}catch(F){S(Ie(F))}finally{x(!1)}},M=$=>void V({todo:E.todo.filter(F=>F!==$),done:[...E.done,$]}),z=$=>void V({todo:[...E.todo,$],done:E.done.filter(F=>F!==$)}),D=()=>{const $=m.trim();$===""||E.todo.includes($)||E.done.includes($)||(g(""),V({todo:[...E.todo,$]}))},U=E.sources!==void 0||E.screen!==void 0,I=()=>{x(!0),S(null),e.connection.call("games/activity/reset",{activityId:E.id}).then(r,$=>S(Ie($))).finally(()=>x(!1))};return d&&n!==void 0?s.jsx("div",{className:"ov-detail",children:s.jsx(Jg,{client:e,game:n,activity:E,onDone:()=>{h(!1),r()},onCancel:()=>h(!1)})}):s.jsxs("div",{className:"ov-detail",children:[E.description!==void 0&&s.jsx("p",{className:"ov-description",children:E.description}),s.jsxs("div",{className:"activity-dates muted small",children:[E.startsAt!==void 0&&s.jsxs("span",{children:[B(E.startsAt)," 开始"]}),E.endsAt!==void 0&&s.jsxs("span",{children:[B(E.endsAt)," 结束"]}),E.shopEndsAt!==void 0&&s.jsxs("span",{children:["商店开到 ",B(E.shopEndsAt)]})]}),s.jsx(lH,{activity:E,game:n,chosen:j!==void 0?j??void 0:E.chosen,onChoose:P}),s.jsxs("div",{className:"ov-checklist",role:"list","aria-label":"要做的事",children:[E.todo.map($=>s.jsxs("label",{className:"ov-check",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!1,disabled:p,onChange:()=>M($)}),$]},`t${$}`)),E.done.map($=>s.jsxs("label",{className:"ov-check done",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!0,disabled:p,onChange:()=>z($)}),$]},`d${$}`)),E.todo.length+E.done.length===0&&s.jsx("p",{className:"muted small",children:"还没有要做的事。自己加几项(例如「活动商店换完」「剧情通关」),或者在游戏页让 agent 进游戏读一次。"})]}),s.jsxs("div",{className:"ov-add",children:[s.jsx("input",{className:"text-input plain",value:m,maxLength:80,placeholder:"加一项要做的事,回车添加",disabled:p,onChange:$=>g($.target.value),onKeyDown:$=>{$.key==="Enter"&&D()}}),s.jsxs("button",{className:"small-button",disabled:p||m.trim()==="",onClick:D,children:[s.jsx(J,{name:"plus"}),"添加"]})]}),s.jsxs("div",{className:"ov-detail-actions",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:E.finished!==void 0,disabled:p,onChange:$=>void V({finished:$.target.checked})}),"这个活动我做完了"]}),s.jsx("span",{className:"spacer"}),((T=E.screen)==null?void 0:T.evidence)===!0&&s.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:E.id}).then($=>{const F=`data:${$.mediaType};base64,${$.data}`,H=new Image;H.onload=()=>u({src:F,width:H.naturalWidth,height:H.naturalHeight}),H.src=F},$=>S(Ie($))),children:"看游戏截图"}),((O=E.screen)==null?void 0:O.sessionId)!==void 0&&o!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>o(E.screen.sessionId),children:"agent 的对话"}),E.url!==void 0&&s.jsx("a",{className:"link-button small",href:E.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),i!==void 0&&s.jsxs("button",{className:"link-button small",onClick:i,children:["去",(n==null?void 0:n.name)??"游戏"]}),n!==void 0&&s.jsxs("button",{className:"link-button small",disabled:p,onClick:()=>h(!0),children:[s.jsx(J,{name:"pencil"}),"编辑"]}),E.own!==void 0&&U&&s.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:p,onClick:I,children:"恢复来源的内容"}),s.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:p,onClick:()=>void e.connection.call("games/activity/remove",{activityId:E.id}).then(r,$=>S(Ie($))),children:"从日历去掉"})]}),y!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:y})]}),c!==null&&s.jsx(Cg,{src:c.src,width:c.width,height:c.height,name:`${E.name}.png`,onClose:()=>u(null)})]})}function uH({client:e,onChanged:t,onDiscover:n}){const[i,r]=b.useState(null),[o,c]=b.useState(""),[u,d]=b.useState(null),[h,m]=b.useState(null),[g,p]=b.useState(0);b.useEffect(()=>{let y=!0;return e.connection.call("games/catalog",{}).then(S=>{y&&r(S.games)}).catch(S=>{y&&m(Ie(S))}),()=>{y=!1}},[e,g]);const x=async(y,S)=>{d(y),m(null);try{await e.connection.call("games/follow",{sra:y,follow:S}),p(N=>N+1),t()}catch(N){m(Ie(N))}finally{d(null)}};return s.jsxs("div",{className:"catalog-picker",children:[s.jsxs("p",{className:"muted small",children:["这些游戏的活动来自 ",s.jsx("a",{href:"https://starrailassistant.top/reference/public-api/",target:"_blank",rel:"noreferrer",children:"SRA 公共 API"}),"(社区按官方公告整理,免费,不用模型)。勾上的游戏每天自动读一次。"]}),i===null&&h===null&&s.jsx("p",{className:"muted small",children:"正在读取…"}),s.jsx("div",{className:"catalog-grid",children:i==null?void 0:i.map(y=>s.jsxs("label",{className:`check-label ${y.pack!==void 0?"muted":""}`,title:y.pack!==void 0?"已经有游戏包在读它":void 0,children:[s.jsx("input",{type:"checkbox",checked:y.pack!==void 0||y.followed,disabled:y.pack!==void 0||u!==null,onChange:S=>void x(y.sra,S.target.checked)}),y.name,y.pack!==void 0?"(已有)":u===y.sra?"…":""]},y.sra))}),n!==void 0&&s.jsxs("form",{className:"discover-row",onSubmit:y=>{y.preventDefault();const S=o.trim();S!==""&&(n(S),c(""))},children:[s.jsx("span",{className:"field-title",children:"列表里没有?"}),s.jsx("input",{className:"text-input plain",value:o,maxLength:60,placeholder:"输入游戏名,例如:重返未来:1999",onChange:y=>c(y.target.value)}),s.jsxs("button",{className:"small-button primary",type:"submit",disabled:o.trim()==="",children:[s.jsx(J,{name:"search"}),"让 agent 去找"]}),s.jsx("span",{className:"muted small",children:"agent 会找它的 Wiki、官网公告等来源,建一个游戏包加到游戏页。"})]}),h!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:h})]})]})}const Qr=864e5,Ea=36e5,Up=6e4;function tx(e,t){const n=e-t;return n<=0?"已结束":n>=Qr?`${Math.floor(n/Qr)} 天 ${Math.floor(n%Qr/Ea)} 时`:`${Math.floor(n/Ea)} 时 ${Math.floor(n%Ea/Up)} 分`}function dH(e){return e<=0?{value:"0",unit:"时",rest:""}:e>=Qr?{value:String(Math.floor(e/Qr)),unit:"天",rest:`${Math.floor(e%Qr/Ea)} 时`}:e>=Ea?{value:String(Math.floor(e/Ea)),unit:"时",rest:`${Math.floor(e%Ea/Up)} 分`}:{value:String(Math.max(1,Math.floor(e/Up))),unit:"分",rest:""}}function Bp(e,t){const n=Object.fromEntries(new Intl.DateTimeFormat("en-CA",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).formatToParts(new Date(e)).map(i=>[i.type,i.value]));return`${n.year}/${n.month}/${n.day} ${n.hour}:${n.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 hH({client:e,game:t,activities:n,color:i,now:r,soonDays:o,busy:c,open:u,adding:d,onOpen:h,onAdd:m,onRefresh:g,onRead:p,onReadWeb:x,onUnfollow:y,onChanged:S,openSession:N,openScripts:k}){var O,$;const[E,j]=b.useState(!1),A=n.filter(F=>Math.max(F.endsAt??1/0,F.shopEndsAt??0)>r),P=(F,H)=>(F.endsAt??1/0)-(H.endsAt??1/0),L=A.filter(F=>(F.startsAt??0)<=r).sort(P),B=A.filter(F=>F.startsAt!==void 0&&F.startsAt>r).sort((F,H)=>F.startsAt-H.startsAt),V=L.filter(F=>rs(F).state!=="finished"&&(F.endsAt??1/0)-r<o*Qr),M=t.sources.some(F=>F.auto),z={partial:0,unknown:1,finished:2},D=L.filter(F=>!V.includes(F)&&rs(F).state!=="finished").sort((F,H)=>z[rs(F).state]-z[rs(H).state]||P(F,H)),U=L.filter(F=>rs(F).state==="finished"),I=[{key:"soon",title:"需要关注",hint:`${o} 天内结束,还没做完`,rows:V,tone:"warn"},{key:"ongoing",title:"进行中",hint:"做了一部分的在前",rows:D},{key:"upcoming",title:"即将开始",hint:"按开始时间",rows:B}],T=F=>s.jsx("div",{className:"schedule-item",children:s.jsx(vH,{client:e,activity:F,game:t,now:r,soonDays:o,onClick:()=>h(F.id),expanded:u===F.id})},F.id);return s.jsxs("div",{className:"game-view",style:{"--game":i},children:[s.jsx(fH,{client:e,game:t,now:r,covers:L.map(F=>F.cover).filter(F=>(F==null?void 0:F.startsWith("shot:"))!==!0)}),s.jsxs("div",{className:"game-columns",children:[s.jsxs("div",{className:"game-main",children:[(((O=t.pools)==null?void 0:O.length)??0)>0&&s.jsxs("section",{className:"game-section pools-card",children:[s.jsxs("div",{className:"game-section-head",children:[s.jsx("h3",{children:"卡池"}),s.jsx("span",{className:"count",children:t.pools.length})]}),s.jsx("div",{className:"pool-list",children:t.pools.map(F=>s.jsx(yH,{client:e,pool:F,game:t,now:r},`${F.name}-${F.endsAt}`))})]}),s.jsxs("section",{className:"game-section game-events","aria-label":"活动日程",children:[s.jsxs("div",{className:"game-section-head",children:[s.jsx("h3",{children:"活动日程"}),s.jsx("span",{className:"count",children:A.length}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"muted small",children:(($=t.sources.find(F=>F.auto))==null?void 0:$.name)??"数据站"}),s.jsx("button",{className:"icon-button",title:"自己添加一个活动","aria-label":"添加活动","aria-pressed":d,onClick:m,children:s.jsx(J,{name:"plus"})}),s.jsx("button",{className:"icon-button",title:M?"刷新数据站(不用模型)":"这个游戏没有能自动读的数据站",disabled:c!==null||!M,onClick:g,children:s.jsx(J,{name:"refresh"})})]}),A.length===0&&s.jsx("p",{className:"muted small schedule-empty",children:M?"还没有活动。点右上角刷新,或点「+」自己添加。":"这个游戏没有能自动读的数据站:让 agent 进游戏读一次,或点「+」自己添加。"}),I.filter(F=>F.rows.length>0).map(F=>s.jsxs("section",{className:`schedule-group ${F.tone??""}`,children:[s.jsxs("div",{className:"schedule-group-title",children:[s.jsx("span",{children:F.title}),s.jsx("span",{className:"count",children:F.rows.length}),s.jsx("span",{className:"muted small",children:F.hint})]}),s.jsx("div",{className:"schedule-grid",children:F.rows.map(T)})]},F.key)),U.length>0&&s.jsxs("section",{className:"schedule-group done",children:[s.jsxs("button",{className:"schedule-group-title toggle","aria-expanded":E,onClick:()=>j(F=>!F),children:[s.jsx("span",{children:"已做完"}),s.jsx("span",{className:"count",children:U.length}),s.jsx("span",{className:"muted small",children:E?"收起":"展开"}),s.jsx(J,{name:"chevron-down",className:`chevron-icon ${E?"open":""}`})]}),E&&s.jsx("div",{className:"schedule-grid",children:U.map(T)})]})]})]}),s.jsxs("aside",{className:"game-side",children:[s.jsx(pH,{game:t,running:L,soon:V,now:r,busy:c,onRead:p,onReadWeb:x,onUnfollow:y,openSession:N}),s.jsx("section",{className:"card game-runs-card",children:s.jsx(xH,{client:e,game:t,now:r,openScripts:k})}),s.jsxs("section",{className:"card game-sources-card",children:[s.jsx("h3",{children:"数据来源"}),s.jsxs("div",{className:"game-sources",children:[t.sources.map(F=>{var H;return s.jsxs("span",{className:`source-chip ${F.auto?"auto":"agent"}`,children:[F.auto?s.jsxs("span",{className:"source-name",title:"每天自动读取(不用模型)",children:[s.jsx("span",{className:"source-dot auto"}),F.name]}):s.jsxs("button",{className:"source-name",disabled:c!==null||((H=t.webReading)==null?void 0:H.state)==="running",title:"让 agent 读这个来源,把活动记进日历",onClick:()=>x(F.id),children:[s.jsx("span",{className:"source-dot"}),F.name,s.jsx("span",{className:"source-action",children:"agent 读"})]}),F.homepage!==void 0&&s.jsx("a",{className:"source-open",href:F.homepage,target:"_blank",rel:"noreferrer",title:"在浏览器里打开","aria-label":`打开${F.name}`,children:s.jsx(J,{name:"popout"})}),F.added===!0&&s.jsx("button",{className:"source-open",title:"不再读这个网址","aria-label":`删除${F.name}`,onClick:()=>void e.connection.call("games/source/remove",{game:t.id,source:F.id}).then(S,()=>{}),children:s.jsx(J,{name:"close"})})]},F.id)}),s.jsx(mH,{client:e,game:t,onAdded:S})]}),t.refreshed!==void 0&&s.jsxs("span",{className:"muted small",children:[Et(t.refreshed.at,r),"刷新"]}),t.refreshed!==void 0&&!t.refreshed.ok&&s.jsxs("span",{className:"tone-error small",children:["上次没读到:",t.refreshed.detail]})]})]})]})]})}function fH({client:e,game:t,now:n,covers:i}){const r=t.version,o=V_(e,[r==null?void 0:r.cover,t.art,...i]),c=(r==null?void 0:r.startsAt)!==void 0&&r.endsAt!==void 0?r.endsAt-r.startsAt:void 0,u=c===void 0||c<=0?void 0:Math.min(1,Math.max(0,(n-r.startsAt)/c)),d=h=>new Date(h).toLocaleDateString("zh-CN",{timeZone:t.timezone,month:"numeric",day:"numeric"});return s.jsxs("section",{className:`version-hero ${o===void 0?"no-art":""}`,children:[o!==void 0&&s.jsx("img",{className:"version-art",src:o,alt:""}),s.jsx("div",{className:"version-shade"}),s.jsxs("div",{className:"version-caption",children:[s.jsxs("span",{className:"version-kicker",children:[t.name,r===void 0?"":s.jsxs(s.Fragment,{children:[" · ",s.jsx("b",{children:r.name})," 版本"]})]}),s.jsx("h2",{children:(r==null?void 0:r.title)??t.name})]}),s.jsxs("div",{className:"version-strip",children:[r===void 0&&s.jsx("span",{className:"small version-none",children:t.sources.some(h=>h.auto)?"还没有版本信息:点「活动日程」右上角刷新":"这个游戏的数据站不提供版本信息"}),r!==void 0&&u!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"version-end",children:d(r.startsAt)}),s.jsxs("div",{className:"version-track",role:"meter","aria-label":"版本进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u*100),children:[s.jsx("span",{className:"version-fill",style:{width:`${u*100}%`}}),s.jsx("span",{className:"version-now",style:{left:`${u*100}%`}})]}),s.jsx("span",{className:"version-end",children:d(r.endsAt)})]}),(r==null?void 0:r.endsAt)!==void 0&&s.jsx("span",{className:"version-remaining",children:r.endsAt>n?s.jsxs(s.Fragment,{children:["还剩 ",s.jsx("strong",{children:tx(r.endsAt,n)})]}):"本版本已结束"})]})]})}function mH({client:e,game:t,onAdded:n}){const[i,r]=b.useState(!1),[o,c]=b.useState(""),[u,d]=b.useState(!1),[h,m]=b.useState(null);if(!i)return s.jsxs("button",{className:"source-add",onClick:()=>r(!0),title:"添加一个关于这个游戏的网页,agent 会去读它",children:[s.jsx(J,{name:"plus"}),"添加网址"]});const g=async()=>{const p=o.trim();if(p!==""){d(!0),m(null);try{await e.connection.call("games/source/add",{game:t.id,url:/^https?:\/\//.test(p)?p:`https://${p}`}),c(""),r(!1),n()}catch(x){m(Ie(x))}finally{d(!1)}}};return s.jsxs("form",{className:"source-form",onSubmit:p=>{p.preventDefault(),g()},children:[s.jsx("input",{className:"text-input plain",autoFocus:!0,type:"text",inputMode:"url",placeholder:"https://… 官网公告、Wiki 页面、帖子",value:o,disabled:u,onChange:p=>c(p.target.value),onKeyDown:p=>{p.key==="Escape"&&r(!1)}}),s.jsx("button",{className:"small-button primary",type:"submit",disabled:u||o.trim()==="",children:u?"添加中…":"添加并读取"}),s.jsx("button",{className:"small-button",type:"button",onClick:()=>{r(!1),m(null)},children:"取消"}),h!==null&&s.jsx("span",{className:"tone-error small",children:h})]})}function pH({game:e,running:t,soon:n,now:i,busy:r,onRead:o,onReadWeb:c,onUnfollow:u,openSession:d}){var y,S;const h=t.map(rs),m=h.filter(N=>N.state==="finished").length,g=h.filter(N=>N.state==="partial").length,p=h.filter(N=>N.state==="unknown").length,x=e.reading;return s.jsxs("section",{className:"card status-card",children:[s.jsx("h3",{children:"我的状态"}),s.jsxs("div",{className:"status-figures",children:[s.jsxs("div",{className:"status-figure",children:[s.jsx("strong",{children:t.length}),s.jsx("span",{children:"进行中"})]}),s.jsxs("div",{className:`status-figure ${n.length>0?"warn":""}`,children:[s.jsx("strong",{children:n.length}),s.jsx("span",{children:"快结束未做完"})]})]}),t.length>0&&s.jsxs("div",{className:"status-bar",role:"img","aria-label":`已做完 ${m} 个,做了一部分 ${g} 个,没记录 ${p} 个`,children:[m>0&&s.jsx("span",{className:"done",style:{flexGrow:m}}),g>0&&s.jsx("span",{className:"partial",style:{flexGrow:g}}),p>0&&s.jsx("span",{className:"unknown",style:{flexGrow:p}})]}),s.jsxs("ul",{className:"status-legend",children:[s.jsxs("li",{children:[s.jsx("i",{className:"done"}),"已做完",s.jsx("b",{children:m})]}),s.jsxs("li",{children:[s.jsx("i",{className:"partial"}),"做了一部分",s.jsx("b",{children:g})]}),s.jsxs("li",{children:[s.jsx("i",{className:"unknown"}),"没记录",s.jsx("b",{children:p})]})]}),s.jsx("p",{className:"muted small",children:"进度来自你在活动卡片里勾的,和 agent 进游戏读到的。"}),s.jsxs("div",{className:"game-actions",children:[e.followed!==!0&&s.jsxs("button",{className:"small-button primary",disabled:r!==null||(x==null?void 0:x.state)==="running",title:"agent 会看游戏画面,进活动页读取剩余时间和没做完的事;只看不花东西",onClick:o,children:[s.jsx(J,{name:"gamepad"}),(x==null?void 0:x.state)==="running"?"agent 正在读…":"让 agent 进游戏读取"]}),s.jsxs("button",{className:"small-button",disabled:r!==null||((y=e.webReading)==null?void 0:y.state)==="running",title:"agent 读官网公告、Wiki 等插件不能自己读的来源,把活动记进日历",onClick:()=>c(),children:[s.jsx(J,{name:"search"}),((S=e.webReading)==null?void 0:S.state)==="running"?"agent 正在查…":"让 agent 上网查活动"]}),e.followed===!0&&s.jsx("button",{className:"small-button",disabled:r!==null,title:"不再显示这个游戏",onClick:u,children:"取消关注"})]}),x!==void 0&&s.jsx(zk,{what:"进游戏",reading:x,now:i,openSession:d}),e.webReading!==void 0&&s.jsx(zk,{what:"上网查",reading:e.webReading,now:i,openSession:d})]})}function zk({what:e,reading:t,now:n,openSession:i}){var o;const r=(o=t.summary)==null?void 0:o.replace(/[*_`#>]+/g,"").replace(/\s+/g," ").trim();return s.jsxs("div",{className:`reading ${t.state}`,children:[s.jsxs("div",{className:"reading-head",children:[s.jsx("span",{className:`badge ${t.state==="done"?"ok":t.state==="failed"?"warn":""}`,children:t.state==="running"?`正在${e}`:t.state==="done"?`上次${e}`:`${e}没完成`}),s.jsx("span",{className:"muted small",children:Et(t.at,n)}),s.jsx("span",{className:"spacer"}),t.sessionId!==void 0&&s.jsxs("button",{className:"link-button small reading-open",onClick:()=>i(t.sessionId),children:["查看对话",s.jsx(J,{name:"chevron"})]})]}),r!==void 0&&r!==""&&s.jsx("p",{className:"reading-summary",title:r,children:r})]})}function gH({client:e,game:t}){const n=we(e.capabilities),[i,r]=b.useState(null);return b.useEffect(()=>{if(!n.has("scripts"))return;let o=!0;return e.connection.call("games/mirrorchyan",{game:t.id}).then(c=>{o&&r(c.items)},()=>{o&&r([])}),()=>{o=!1}},[e,t.id,n.has("scripts")]),i===null||i.length===0?null:s.jsxs("div",{className:"mirror-tools",children:[s.jsx("div",{className:"muted small",children:"Mirror酱 上有这些玩它的工具:"}),s.jsx("ul",{children:i.slice(0,5).map(o=>s.jsxs("li",{children:[s.jsx("a",{href:`#/p/scripts/${encodeURIComponent(`mirror:${o.rid}`)}`,children:o.name}),s.jsx("span",{className:"chip subtle",children:o.rid}),o.description!==""&&s.jsx("span",{className:"muted small",children:o.description})]},o.rid))})]})}function xH({client:e,game:t,now:n,openScripts:i}){const r=we(e.capabilities),o=we(e.connection.status),[c,u]=b.useState(null),[d,h]=b.useState([]),[m,g]=b.useState(0),[p,x]=b.useState(null),[y,S]=b.useState(null),N=r.has("pipelines");b.useEffect(()=>e.connection.on("pipelines/changed",()=>g(j=>j+1)),[e]),b.useEffect(()=>e.connection.on("pipelines/run",j=>{j.state!=="running"&&g(A=>A+1)}),[e]),b.useEffect(()=>{if(o.state!=="open"||!N||t.scripts.length===0){u([]);return}let j=!0;return(async()=>{const{items:A}=await e.connection.call("pipelines/list",{}),L=(await Promise.all(A.filter(V=>!V.draft).map(async V=>({summary:V,pipeline:await e.connection.call("pipelines/get",{id:V.id})})))).filter(({pipeline:V})=>V.nodes.some(M=>M.kind==="script-task"&&t.scripts.includes(M.scriptId))),B=r.has("schedule")?await e.connection.call("schedule/status",{}).catch(()=>{}):void 0;j&&(u(L),h((B==null?void 0:B.upcoming)??[]))})().catch(A=>{j&&S(Ie(A))}),()=>{j=!1}},[e,o.state,N,t.id,t.scripts.join(","),m]);const k=async j=>{x(j),S(null);try{await e.connection.call("pipelines/run",{id:j}),g(A=>A+1)}catch(A){S(Ie(A))}finally{x(null)}},E={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]};return s.jsxs("div",{className:"game-schedule-runs",children:[s.jsx("h3",{children:"自动日程"}),t.scripts.length===0&&s.jsxs("p",{className:"muted small",children:["还没有玩它的脚本。在",s.jsx("button",{className:"link-button",onClick:i,children:"脚本页"}),"安装或导入后,名字或仓库里提到这个游戏的脚本会自动对上。"]}),t.scripts.length===0&&s.jsx(gH,{client:e,game:t}),t.scripts.length>0&&s.jsxs("p",{className:"muted small",children:["玩它的脚本:",t.scripts.map((j,A)=>s.jsxs("span",{children:[A>0?"、":"",s.jsx("button",{className:"link-button",onClick:i,children:j})]},j))]}),c!==null&&t.scripts.length>0&&c.length===0&&s.jsxs("p",{className:"muted small",children:["还没有自动跑这个游戏的流水线。在 ",s.jsx("a",{href:"#/p/pipelines",children:"编排"})," 里建一条并设上定时,日常就会每天自己跑。"]}),c!==null&&c.length>0&&s.jsx("ul",{className:"run-list",children:c.map(({summary:j})=>{var L,B;const A=d.filter(V=>V.pipelineId===j.id).map(V=>V.at).sort((V,M)=>V-M)[0],P=j.lastRun;return s.jsxs("li",{children:[s.jsx("a",{className:"run-name",href:`#/p/pipelines/${encodeURIComponent(j.id)}`,children:j.name}),s.jsx("span",{className:"muted small",children:A!==void 0?`下次 ${new Date(A).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"})}`:j.schedule.enabled?"定时已开":"没有定时"}),P!==void 0&&s.jsxs("span",{className:`badge ${((L=E[P.state])==null?void 0:L[0])??""}`,title:new Date(P.startedAt).toLocaleString("zh-CN",{hour12:!1}),children:[((B=E[P.state])==null?void 0:B[1])??P.state," · ",Et(P.endedAt??P.startedAt,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:p!==null||(P==null?void 0:P.state)==="running",onClick:()=>void k(j.id),children:(P==null?void 0:P.state)==="running"?"运行中…":p===j.id?"启动中…":"运行"})]},j.id)})}),y!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:y})]})]})}function G_(e,t,n){const i=(e.startsAt??0)<=t,r=i&&e.endsAt!==void 0&&e.endsAt<=t,o=r?e.shopEndsAt:e.endsAt,c=i&&o!==void 0&&o-t<n*Qr&&rs(e).state!=="finished";return{started:i,shopOnly:r,end:o,soon:c,target:i?o:e.startsAt}}function K_({activity:e,art:t,now:n,soonDays:i}){var y;const{started:r,shopOnly:o,end:c,soon:u,target:d}=G_(e,n,i),h=e.startsAt!==void 0&&c!==void 0?c-e.startsAt:void 0,m=h===void 0||h<=0||!r?void 0:Math.min(1,Math.max(0,(n-e.startsAt)/h)),g=rs(e).state==="finished"?["done","已做完"]:r?o?["shop","商店开放"]:["live","进行中"]:["upcoming","即将开始"],p=d===void 0?{value:"",unit:"",rest:""}:dH(d-n),x=((y=e.cover)==null?void 0:y.startsWith("shot:"))===!0;return s.jsxs("span",{className:`sched-media ${u?"soon":""}`,children:[t!==void 0&&s.jsx("img",{className:`sched-art ${x?"shot":""}`,src:t,alt:"",title:x?"没有别的活动图,用的是 agent 读这个活动时的游戏截图":void 0},e.cover),s.jsx("span",{className:"sched-shade"}),s.jsx("span",{className:`sched-tag ${g[0]}`,children:g[1]}),s.jsxs("span",{className:"sched-count","aria-label":d===void 0?"时间未知":`${r?"剩余":"距开始"}${tx(d,n)}`,children:[d===void 0?s.jsx("b",{children:"?"}):s.jsxs(s.Fragment,{children:[s.jsx("b",{children:p.value}),s.jsx("small",{children:p.unit}),p.rest!==""&&s.jsx("em",{children:p.rest})]}),s.jsx("i",{children:r?o?"商店":"剩余":"后开始"})]}),m!==void 0&&s.jsx("span",{className:"sched-elapsed",style:{width:`${m*100}%`}})]})}function vH({client:e,activity:t,game:n,now:i,soonDays:r,onClick:o,expanded:c}){var S,N,k,E;const u=Yo(e,t.cover),d=rs(t),{started:h,shopOnly:m,end:g,soon:p}=G_(t,i,r),x=nx(n.timezone,i),y=t.chosen===void 0?void 0:t.chosen===So?"我设的":t.chosen===ql?"游戏画面":(N=(S=t.sources)==null?void 0:S.find(j=>j.id===t.chosen))==null?void 0:N.name;return s.jsxs("button",{className:`sched-card ${u===void 0?"no-art":""} ${p?"soon":""}`,onClick:o,"aria-expanded":c,children:[s.jsx(K_,{activity:t,art:u,now:i,soonDays:r}),s.jsxs("span",{className:"sched-body",children:[s.jsx("span",{className:"sched-name",title:t.name,children:t.name}),s.jsx("span",{className:"sched-when",children:!h&&t.startsAt!==void 0?`${Bp(t.startsAt,n.timezone)} 开始 · ${x}`:g!==void 0?`${Bp(g,n.timezone)} ${m?"商店关闭":"结束"} · ${x}`:`结束时间未知${((k=t.screen)==null?void 0:k.remaining)===void 0?"":`,游戏里显示「${t.screen.remaining}」`}`}),t.todo.length>0&&d.state!=="finished"&&s.jsxs("span",{className:"sched-todo",title:t.todo.join("、"),children:["还没做:",t.todo.slice(0,3).join("、")]}),s.jsxs("span",{className:"sched-foot",children:[s.jsxs("span",{className:"sched-kinds",children:[t.kind!==void 0&&s.jsx("span",{className:"sched-kind",children:t.kind}),y!==void 0&&s.jsxs("span",{className:"sched-kind",title:`你选了用「${y}」的图片和时间`,children:["用 ",y]}),t.own!==void 0&&s.jsx("span",{className:"sched-kind",title:t.sources===void 0&&t.screen===void 0?"你自己添加的活动":"你改过这个活动",children:t.sources===void 0&&t.screen===void 0?"我添加的":"我改过"}),((E=t.sources)==null?void 0:E.some(j=>j.web))===!0&&s.jsx("span",{className:"sched-kind",title:`来源:${t.sources.map(j=>j.name).join("、")}`,children:t.sources.every(j=>j.web)?"网页读到":"数据站 + 网页"})]}),s.jsx(ex,{progress:d})]})]})]})}function yH({client:e,pool:t,game:n,now:i}){const r=Yo(e,t.cover),o=(t.startsAt??0)<=i;return s.jsxs("article",{className:"pool-card",children:[s.jsx("div",{className:"pool-art",children:r===void 0?s.jsx(J,{name:"sparkles"}):s.jsx("img",{src:r,alt:""})}),s.jsxs("div",{className:"pool-main",children:[t.type!==void 0&&s.jsx("span",{className:"muted small",children:t.type}),s.jsx("strong",{children:t.name}),t.up.length>0&&s.jsxs("span",{className:"small",children:["UP:",t.up.join("、")]}),s.jsxs("span",{className:"small",children:[o?"剩余":"距开始"," ",s.jsx("strong",{className:"pool-left",children:tx(o?t.endsAt:t.startsAt,i)})]}),s.jsxs("span",{className:"muted small",children:[Bp(t.endsAt,n.timezone)," 结束 (",nx(n.timezone,i),")"]})]})]})}function bH(e,t){return b.useMemo(()=>new Map(e.map((n,i)=>[n.id,t[i%t.length]])),[e,t])}function Lk({color:e,label:t,onClose:n,children:i}){const r=b.useRef(null),o=()=>{var c;return((c=r.current)==null?void 0:c.querySelector("form.activity-editor"))!==null};return b.useEffect(()=>{var u;const c=document.activeElement;return(u=r.current)==null||u.focus({preventScroll:!0}),()=>{c instanceof HTMLElement&&c.isConnected&&c.focus({preventScroll:!0})}},[]),b.useEffect(()=>{const c=u=>{if(document.querySelector(".image-viewer")!==null||(u.key==="Escape"&&!o()&&n(),u.key!=="Tab"||r.current===null))return;const d=[...r.current.querySelectorAll("a[href], button:not(:disabled), input:not(:disabled):not([hidden]), textarea:not(:disabled)")],h=d[0],m=d[d.length-1],g=document.activeElement;h===void 0||m===void 0||(u.shiftKey&&(g===h||g===r.current)?(u.preventDefault(),m.focus()):!u.shiftKey&&g===m&&(u.preventDefault(),h.focus()))};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[n]),s.jsx("div",{className:"activity-scrim",onPointerDown:c=>{c.target===c.currentTarget&&!o()&&n()},children:s.jsx("div",{ref:r,className:"activity-dialog",role:"dialog","aria-modal":"true","aria-label":t,tabIndex:-1,style:{"--game":e},children:i})})}function kH(e,t){const n=u=>Et(u,t),i=e.sources??[],r=e.own,o=u=>u.startsAt!==void 0||u.endsAt!==void 0||u.cover!==void 0,c=u=>({id:u.id,name:u.name,note:`${u.web?"网页":"数据站"} · ${n(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:So,name:"我设的",note:r===void 0?"":n(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(c),...i.filter(u=>u.web).map(c),...e.screen===void 0?[]:[{id:ql,name:"游戏画面",note:`agent 看过 · ${n(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 NH(e,t){var r,o,c;const n=((r=e.shown)==null?void 0:r.startsAt)===t,i=((o=e.shown)==null?void 0:o.endsAt)===t;return[...((c=e.shown)==null?void 0:c.cover)===t?["图片"]:[],...n&&i?["时间"]:n?["开始时间"]:i?["结束时间"]:[]]}function jH({client:e,url:t}){const n=Yo(e,t);return s.jsx("span",{className:`source-thumb ${t===void 0?"none":""}`,children:n!==void 0?s.jsx("img",{src:n,alt:"",decoding:"async"}):t===void 0?"无图":null})}function wH({client:e,activity:t,game:n,now:i,soonDays:r,onClose:o,onChanged:c,openSession:u}){var re,ee,se;const[d,h]=b.useState(null),[m,g]=b.useState(!1),[p,x]=b.useState(""),[y,S]=b.useState(!1),[N,k]=b.useState(null),[E,j]=b.useState(void 0);b.useEffect(()=>j(void 0),[t]);const A=E??t,[P,L]=b.useState(void 0);b.useEffect(()=>L(void 0),[A.chosen]);const B=P!==void 0?P??void 0:A.chosen,V=Yo(e,A.cover),M=b.useRef(void 0);V!==void 0&&(M.current=V);const z=A.cover===void 0?void 0:V??M.current,D=(n==null?void 0:n.timezone)??"Asia/Shanghai",U=ne=>new Date(ne).toLocaleString("zh-CN",{timeZone:D,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),I=kH(A,i),T=A.shopEndsAt!==void 0||I.some(ne=>ne.shopEndsAt!==void 0),O=A.sources!==void 0||A.screen!==void 0,$=(ne,ie)=>{S(!0),k(null),ne.then(()=>{c(),ie==null||ie()},pe=>k(Ie(pe))).finally(()=>S(!1))},F=ne=>$(e.connection.call("games/activity/progress",{activityId:A.id,...ne})),H=ne=>F({todo:A.todo.filter(ie=>ie!==ne),done:[...A.done,ne]}),Z=ne=>F({todo:[...A.todo,ne],done:A.done.filter(ie=>ie!==ne)}),G=()=>{const ne=p.trim();ne===""||A.todo.includes(ne)||A.done.includes(ne)||(x(""),F({todo:[...A.todo,ne]}))},q=ne=>{L(ne),k(null),e.connection.call("games/activity/source",{activityId:A.id,source:ne}).then(ie=>{j(ie),c()},ie=>{L(void 0),k(Ie(ie))})},X=(ne,ie)=>{const pe=new Image;pe.onload=()=>h({src:ne,width:pe.naturalWidth,height:pe.naturalHeight,name:ie}),pe.src=ne},Y=()=>{S(!0),k(null),e.connection.call("games/activity/reset",{activityId:A.id}).then(ne=>{c(),ne.activity===void 0&&o()},ne=>k(Ie(ne))).finally(()=>S(!1))};return m&&n!==void 0?s.jsx("div",{className:"dialog-form",children:s.jsx(Jg,{client:e,game:n,activity:A,onDone:()=>{g(!1),c()},onCancel:()=>g(!1)})}):s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"dialog-head",children:[s.jsxs("div",{className:"dialog-title",children:[s.jsx("h3",{title:A.name,children:A.name}),s.jsxs("div",{className:"dialog-meta",children:[s.jsxs("span",{className:"dialog-game",children:[s.jsx("span",{className:"game-dot"}),(n==null?void 0:n.name)??A.game]}),A.kind!==void 0&&s.jsx("span",{className:"sched-kind",children:A.kind})]})]}),s.jsx(ex,{progress:rs(A)}),s.jsx("button",{className:"dialog-close","aria-label":"关闭详情",title:"关闭(Esc)",onClick:o,children:s.jsx(J,{name:"close"})})]}),s.jsxs("div",{className:"dialog-cols",children:[s.jsxs("div",{className:"dialog-col side",children:[s.jsx("button",{className:"dialog-media",disabled:z===void 0,title:z===void 0?void 0:"看大图","aria-label":"看大图",onClick:()=>{z!==void 0&&X(z,`${A.name}.png`)},children:s.jsx(K_,{activity:A,art:z,now:i,soonDays:r})}),s.jsxs("div",{className:"dialog-facts",children:[s.jsxs("dl",{className:"dialog-dates",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"开始"}),s.jsx("dd",{children:A.startsAt===void 0?"未知":U(A.startsAt)})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"结束"}),s.jsx("dd",{children:A.endsAt===void 0?"未知":U(A.endsAt)})]}),T&&s.jsxs("div",{className:"wide",children:[s.jsx("dt",{children:"商店开到"}),s.jsx("dd",{children:A.shopEndsAt===void 0?"—":U(A.shopEndsAt)})]})]}),s.jsxs("span",{className:"muted small",children:[nx(D,i),",游戏服务器时间",((re=A.screen)==null?void 0:re.remaining)===void 0?"":`;游戏里显示「${A.screen.remaining}」`]}),A.description!==void 0&&s.jsx("p",{className:"ov-description",children:A.description})]})]}),s.jsxs("div",{className:"dialog-col main",children:[s.jsxs("section",{className:"dialog-section","aria-label":"信息来源",children:[s.jsxs("div",{className:"dialog-section-head",children:[s.jsx("h4",{children:"信息来源"}),s.jsx("span",{className:"spacer"}),B!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>q(null),children:"恢复默认"})]}),s.jsx("div",{className:"source-rows",children:I.map(ne=>{const ie=ne.id===So,pe=B===ne.id;return s.jsxs("button",{className:`source-row ${pe?"on":""}`,"aria-pressed":pe,disabled:ne.blank&&!ie,title:ne.title,onClick:()=>{ne.blank&&ie?g(!0):q(pe?null:ne.id)},children:[s.jsx(jH,{client:e,url:ne.cover}),s.jsxs("span",{className:"source-row-main",children:[s.jsxs("span",{className:"source-row-name",children:[s.jsx("b",{children:ne.name}),pe&&s.jsx(J,{name:"check"}),ne.note!==""&&s.jsx("small",{children:ne.note})]}),ne.blank?s.jsx("span",{className:"source-row-dates muted",children:ie?"还没填,点这里设置图片和时间":"没有时间和图片"}):s.jsxs("span",{className:"source-row-dates",children:[s.jsx("span",{children:ne.startsAt===void 0&&ne.endsAt===void 0?"没有时间":`${ne.startsAt===void 0?"?":U(ne.startsAt)} – ${ne.endsAt===void 0?"?":U(ne.endsAt)}`}),ne.shopEndsAt!==void 0&&s.jsxs("em",{children:["商店到 ",U(ne.shopEndsAt)]})]})]}),s.jsx("span",{className:"source-row-uses",children:NH(A,ne.id).map(Ce=>s.jsx("i",{children:Ce},Ce))})]},ne.id)})}),s.jsx("p",{className:"muted small dialog-hint",children:"默认图片按 我设的 › 数据站和网页 › 游戏截图 显示。点一个来源,图片和时间就用它的;它没有的还按默认。"})]}),s.jsxs("section",{className:"dialog-section","aria-label":"要做的事",children:[s.jsxs("div",{className:"dialog-section-head",children:[s.jsx("h4",{children:"要做的事"}),A.todo.length+A.done.length>0&&s.jsxs("span",{className:"count",children:[A.done.length,"/",A.todo.length+A.done.length]})]}),s.jsxs("div",{className:"ov-checklist",role:"list",children:[A.todo.map(ne=>s.jsxs("label",{className:"ov-check",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!1,disabled:y,onChange:()=>H(ne)}),ne]},`t${ne}`)),A.done.map(ne=>s.jsxs("label",{className:"ov-check done",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!0,disabled:y,onChange:()=>Z(ne)}),ne]},`d${ne}`)),A.todo.length+A.done.length===0&&s.jsx("p",{className:"muted small",children:"还没有要做的事。自己加几项(例如「活动商店换完」),或者让 agent 进游戏读一次。"})]}),s.jsxs("div",{className:"ov-add",children:[s.jsx("input",{className:"text-input plain",value:p,maxLength:80,placeholder:"加一项,回车添加",disabled:y,onChange:ne=>x(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&G()}}),s.jsxs("button",{className:"small-button",disabled:y||p.trim()==="",onClick:G,children:[s.jsx(J,{name:"plus"}),"添加"]})]})]}),s.jsxs("div",{className:"dialog-section dialog-links",children:[A.url!==void 0&&s.jsx("a",{className:"link-button small",href:A.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),((ee=A.screen)==null?void 0:ee.evidence)===!0&&s.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:A.id}).then(ne=>X(`data:${ne.mediaType};base64,${ne.data}`,`${A.name}-截图.png`),ne=>k(Ie(ne))),children:"看游戏截图"}),((se=A.screen)==null?void 0:se.sessionId)!==void 0&&u!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>u(A.screen.sessionId),children:"agent 的对话"}),s.jsx("span",{className:"spacer"}),A.own!==void 0&&O&&s.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:y,onClick:Y,children:"清除我设的"}),s.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:y,onClick:()=>$(e.connection.call("games/activity/remove",{activityId:A.id}),o),children:"从日历去掉"})]}),N!==null&&s.jsx("div",{className:"dialog-section",children:s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:N})]})})]})]}),s.jsxs("footer",{className:"dialog-foot",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:A.finished!==void 0,disabled:y,onChange:ne=>F({finished:ne.target.checked})}),"这个活动我做完了"]}),s.jsx("span",{className:"spacer"}),n!==void 0&&s.jsxs("button",{className:"small-button",disabled:y,onClick:()=>g(!0),children:[s.jsx(J,{name:"pencil"}),"编辑"]})]}),d!==null&&s.jsx(Cg,{src:d.src,width:d.width,height:d.height,name:d.name,onClose:()=>h(null)})]})}const SH=864e5;function _H({client:e,openSession:t,openSettings:n,openPage:i,arg:r}){const o=we(e.connection.status),c=An(3e4),[u,d]=b.useState(null),[h,m]=b.useState(0),[g,p]=b.useState(r??""),[x,y]=b.useState(null),[S,N]=b.useState(null),[k,E]=b.useState(null),[j,A]=b.useState(!1),[P,L]=b.useState(null),B=b.useCallback(()=>L(null),[]);b.useEffect(()=>{r!==void 0&&p(r)},[r]),b.useEffect(()=>e.connection.on("games/changed",()=>m(F=>F+1)),[e]),b.useEffect(()=>{if(o.state!=="open")return;let F=!0;return e.connection.call("games/list",{}).then(H=>{F&&d(H)}).catch(H=>{F&&N(Ie(H))}),()=>{F=!1}},[e,o.state,h]);const V=(u==null?void 0:u.games)??[],M=bH(V,Kr),z=g==="report",D=z?void 0:V.find(F=>F.id===g),U=!z&&D===void 0,I=F=>{p(F),L(null),E(null),N(null)},T=async(F,H)=>{y(F),N(null),E(null);try{const Z=await H();typeof Z=="string"&&E(Z)}catch(Z){N(Ie(Z))}finally{y(null),m(Z=>Z+1)}},O=F=>T(`refresh:${F??""}`,async()=>{const{results:H}=await e.connection.call("games/refresh",F===void 0?{}:{game:F}),Z=X=>{var Y;return((Y=V.find(re=>re.id===X))==null?void 0:Y.name)??X},G=X=>{var Y;return((Y=V.find(re=>re.id===X))==null?void 0:Y.sources.some(re=>re.auto))===!0},q=H.filter(X=>G(X.game)&&!X.ok);if(q.length>0)throw new Error(q.map(X=>`${Z(X.game)}没读到:${X.detail??"未知原因"}`).join(";"));return F===void 0?`刷新完成:${H.filter(X=>G(X.game)).map(X=>`${Z(X.game)} ${X.count} 个活动`).join(";")}`:void 0}),$=F=>{const H=((u==null?void 0:u.activities)??[]).filter(G=>G.game===F.id&&(G.startsAt??0)<=c&&Math.max(G.endsAt??1/0,G.shopEndsAt??0)>c),Z=H.filter(G=>rs(G).state!=="finished"&&G.endsAt!==void 0&&G.endsAt>c&&G.endsAt-c<((u==null?void 0:u.settings.report.soonDays)??3)*SH).length;return s.jsxs("button",{role:"tab","aria-selected":(D==null?void 0:D.id)===F.id,className:`game-tab ${(D==null?void 0:D.id)===F.id?"active":""}`,style:{"--game":M.get(F.id)},title:`${H.length} 个进行中${F.refreshed===void 0?"":` · ${Et(F.refreshed.at,c)}刷新`}${F.followed===!0?" · 关注的游戏":""}`,onClick:()=>I(F.id),children:[s.jsx("span",{className:"game-dot"}),F.name,Z>0&&s.jsx("span",{className:"game-tab-badge",title:`${Z} 个快结束还没做完`,children:Z})]},F.id)};return s.jsxs("section",{className:"main games-page",children:[s.jsxs("header",{className:"page-header games-header",children:[s.jsx("div",{className:"breadcrumb",children:s.jsx("h1",{children:"游戏"})}),s.jsxs("nav",{className:"game-tabs",role:"tablist","aria-label":"游戏",children:[s.jsxs("button",{role:"tab","aria-selected":U,className:`game-tab ${U?"active":""}`,onClick:()=>I(""),children:[s.jsx(J,{name:"calendar"}),"全部活动"]}),s.jsx("span",{className:"game-tabs-divider"}),V.map($),s.jsxs("button",{className:`game-tab add ${j?"active":""}`,"aria-expanded":j,title:"关注更多游戏(SRA 公共 API)",onClick:()=>A(F=>!F),children:[s.jsx(J,{name:"plus"}),"更多游戏"]}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{role:"tab","aria-selected":z,className:`game-tab ${z?"active":""}`,onClick:()=>I("report"),children:[s.jsx(J,{name:"send"}),"日报"]})]}),s.jsx("div",{className:"page-actions",children:s.jsxs("button",{className:"small-button",disabled:x!==null||V.length===0,onClick:()=>void O(),children:[s.jsx(J,{name:"refresh"}),x==="refresh:"?"刷新中…":"刷新全部"]})})]}),s.jsxs("div",{className:"games-body",children:[j&&s.jsx("section",{className:"card",children:s.jsx(uH,{client:e,onChanged:()=>m(F=>F+1),onDiscover:F=>void T("discover",async()=>{const{sessionId:H}=await e.connection.call("games/discover",{name:F});t(H)})})}),S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:S})]}),k!==null&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(J,{name:"info"}),s.jsx("span",{children:k})]}),u!==null&&V.length===0&&s.jsxs("div",{className:"empty",children:[s.jsx(J,{name:"gamepad"}),s.jsx("p",{children:"没有游戏。点「更多游戏」关注几个。"})]}),u!==null&&U&&V.length>0&&s.jsx(rH,{client:e,games:V,activities:u.activities,now:c,soonDays:u.settings.report.soonDays,onOpenGame:I,onChanged:()=>m(F=>F+1)}),u!==null&&z&&s.jsx(EH,{client:e,data:u,games:V,now:c,openSettings:n,onChanged:()=>m(F=>F+1)}),u!==null&&D!==void 0&&s.jsx(hH,{client:e,game:D,activities:u.activities.filter(F=>F.game===D.id),color:M.get(D.id)??Kr[0],now:c,soonDays:u.settings.report.soonDays,busy:x,open:(P==null?void 0:P.kind)==="activity"?P.id:null,adding:(P==null?void 0:P.kind)==="add",onOpen:F=>L({kind:"activity",id:F}),onAdd:()=>L({kind:"add",game:D.id}),onRefresh:()=>void O(D.id),onRead:()=>void T(`read:${D.id}`,async()=>{const{sessionId:F}=await e.connection.call("games/read",{game:D.id});t(F)}),onReadWeb:F=>void T(`read-web:${D.id}`,async()=>{const{sessionId:H}=await e.connection.call("games/read",{game:D.id,how:"web",...F===void 0?{}:{source:F}});t(H)}),onUnfollow:()=>void T(`unfollow:${D.id}`,async()=>(await e.connection.call("games/follow",{sra:D.id.replace(/^sra-/,""),follow:!1}),p(""),`不再关注${D.name}`)),onChanged:()=>m(F=>F+1),openSession:t,openScripts:()=>i("scripts")},D.id)]}),u!==null&&P!==null&&(()=>{const F=()=>m(Z=>Z+1);if(P.kind==="add"){const Z=V.find(G=>G.id===P.game);return Z===void 0?null:s.jsx(Lk,{color:M.get(Z.id)??Kr[0],label:"添加活动",onClose:B,children:s.jsx("div",{className:"dialog-form",children:s.jsx(Jg,{client:e,game:Z,onCancel:B,onDone:G=>{L({kind:"activity",id:G.id,saved:G}),F()}})})})}const H=u.activities.find(Z=>Z.id===P.id)??P.saved;return H===void 0?null:s.jsx(Lk,{color:M.get(H.game)??Kr[0],label:`${H.name}的详情`,onClose:B,children:s.jsx(wH,{client:e,activity:H,game:V.find(Z=>Z.id===H.game),now:c,soonDays:u.settings.report.soonDays,onClose:B,onChanged:F,openSession:t},H.id)})})()]})}function EH({client:e,data:t,games:n,now:i,openSettings:r,onChanged:o}){const c=t.settings.report,[u,d]=b.useState(null),[h,m]=b.useState(!1),[g,p]=b.useState(null),[x,y]=b.useState(null);b.useEffect(()=>{let k=!0;return e.connection.call("games/report/preview",{}).then(E=>{k&&d(E)}).catch(()=>{}),()=>{k=!1}},[e,t]);const S=async k=>{m(!0),p(null);try{await e.connection.call("games/settings/set",{report:k}),o()}catch(E){p(Ie(E))}finally{m(!1)}},N=async()=>{m(!0),p(null),y(null);try{const{channels:k}=await e.connection.call("games/report/send",{});y(k.length===0?"没有发出去:还没有设置好的聊天渠道。":`已发到${k.join("、")}。`),o()}catch(k){p(Ie(k))}finally{m(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"每日日报"}),s.jsx("p",{className:"muted small",children:"每天先读一遍数据站,再把各游戏的活动、剩余天数和没做完的事发到飞书。进度来自 agent 最近一次进游戏读取(可以在编排里加一个 agent 节点,日常跑完后读一次)。"})]}),s.jsx("span",{className:`badge ${c.enabled?"ok":""}`,children:c.enabled?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.enabled,disabled:h,onChange:k=>void S({enabled:k.target.checked})}),"每天定时发送"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.ai,disabled:h,onChange:k=>void S({ai:k.target.checked})}),"用 AI 总结,只说近期的事(刚开始、快结束、即将开始),语气按「设置 → 回复风格」;agent 不可用时发下面的完整列表"]}),s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"发送时间"}),s.jsx("input",{className:"text-input plain",type:"time",defaultValue:c.at,disabled:h,onBlur:k=>{/^\d{2}:\d{2}$/.test(k.target.value)&&k.target.value!==c.at&&S({at:k.target.value})}},c.at)]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"剩余几天以内标成「快结束」"}),s.jsx("input",{className:"text-input plain",type:"number",min:1,max:30,defaultValue:c.soonDays,disabled:h,onBlur:k=>{const E=Math.max(1,Math.min(30,Math.round(Number(k.target.value)||3)));E!==c.soonDays&&S({soonDays:E})}},c.soonDays)]})]}),s.jsx("div",{className:"field-title",children:"包括的游戏(都不选就是全部)"}),s.jsx("div",{className:"chip-row",children:n.map(k=>{const E=c.games.includes(k.id);return s.jsx("button",{className:`chip chip-button ${E?"active":""}`,disabled:h,onClick:()=>void S({games:E?c.games.filter(j=>j!==k.id):[...c.games,k.id]}),children:k.name},k.id)})}),s.jsxs("p",{className:"muted small",children:[t.report.lastSentAt===void 0?"还没发过。":`上次:${Et(t.report.lastSentAt,i)}。`,t.report.lastResult===void 0?"":` ${t.report.lastResult}。`,c.enabled&&t.report.next!==void 0&&` 下一次:${new Date(t.report.next).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}。`," ",s.jsx("button",{className:"link-button",onClick:()=>r("feishu"),children:"远程连接"})]}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:g})]})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"今天的日报"}),s.jsx("p",{className:"muted small",children:c.ai?"完整列表。发送时 agent 从里面挑出近期的事写成总结,写不出来就发这份。":"发到飞书的就是这份。"})]}),s.jsxs("button",{className:"small-button primary",disabled:h,onClick:()=>void N(),children:[s.jsx(J,{name:"send"}),h?"发送中…":"现在发送"]})]}),x!==null&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(J,{name:"info"}),s.jsx("span",{children:x})]}),u!==null&&s.jsxs("div",{className:"report-preview",children:[s.jsx("strong",{children:u.title}),`
231
+
232
+ `,u.text]})]}),t.report.lastText!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"上次发出的"}),t.report.lastSentAt!==void 0&&s.jsx("p",{className:"muted small",children:Et(t.report.lastSentAt,i)})]})}),s.jsx("div",{className:"report-preview",children:t.report.lastText})]})]})}const CH={id:"games",title:"游戏看板",milestone:"M6",requires:["games"],pages:[{id:"games",title:"游戏",icon:"gamepad",order:-10,component:_H}]},AH={game:"游戏",script:"脚本",general:"通用"};function IH({client:e,focus:t,openSession:n,openSkill:i}){const r=An(6e4),o=we(e.capabilities),[c,u]=b.useState(null),[d,h]=b.useState({games:new Set,scripts:new Set}),[m,g]=b.useState(null),[p,x]=b.useState(null),[y,S]=b.useState(null),[N,k]=b.useState(null),[E,j]=b.useState(!1),A=async(M=!1)=>{g(M?"refresh":m);try{u(await e.connection.call("skillhub/list",M?{refresh:!0}:{})),x(null)}catch(z){x(Ie(z))}finally{M&&g(null)}};b.useEffect(()=>{A()},[e]),b.useEffect(()=>e.connection.on("skillhub/changed",()=>void A()),[e]),b.useEffect(()=>{let M=!0;return(async()=>{var U,I;const z=o.has("games")?((U=await e.connection.call("games/list",{}).catch(()=>{}))==null?void 0:U.games.map(T=>T.id))??[]:[],D=o.has("scripts")?((I=await e.connection.call("scripts/list",{}).catch(()=>{}))==null?void 0:I.scripts.flatMap(T=>[T.id,T.packId,T.known].filter(O=>O!==void 0)))??[]:[];M&&h({games:new Set(z),scripts:new Set(D)})})(),()=>{M=!1}},[e,o.has("games"),o.has("scripts")]);const P=async(M,z)=>{g(M),x(null),S(null);try{const D=await z();typeof D=="string"&&S(D),await A()}catch(D){x(Ie(D))}finally{g(null)}},L=M=>M.games.some(z=>d.games.has(z))||M.scripts.some(z=>d.scripts.has(z)),B=b.useMemo(()=>{const M=[...(c==null?void 0:c.items)??[]].sort((z,D)=>+(D.name===t)-+(z.name===t)||z.name.localeCompare(D.name));return[{label:"已下载",items:M.filter(z=>z.installed!==void 0)},{label:"推荐给你",hint:"你关注的游戏、装了的脚本",items:M.filter(z=>z.installed===void 0&&L(z))},{label:"其他",items:M.filter(z=>z.installed===void 0&&!L(z))}].filter(z=>z.items.length>0)},[c,d,t]),V=(M,z)=>P(`update:${M.name}`,async()=>{const D=await e.connection.call("skillhub/update",{name:M.name,...z===void 0?{}:{resolve:z}});return k(null),D.state==="merging"&&D.sessionId!==void 0?(n(D.sessionId),"agent 正在合并,合并完会写回你的这份技能"):D.state==="conflict"?"你改过这个技能:选「保留我的」「用新版」或「让 agent 合并」":D.state==="kept"?"已保留你的版本,这个新版本不再提示":D.state==="updated"?D.backup===void 0?`${M.name} 已更新`:`${M.name} 已更新,你原来的那份备份在 ${D.backup}`:"已是最新"});return s.jsxs("div",{className:"skill-hub",children:[s.jsxs("section",{className:"card skill-hub-head",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"技能库"}),s.jsxs("p",{className:"muted small",children:["游戏和脚本的技能放在 ",(c==null?void 0:c.repos.map(M=>M.repo).join("、"))??"MultiGameAssistant/skills",",按需下载;下载的可以改,更新时不会覆盖你的改动。软件自带的核心技能受保护,随软件更新。"]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:(c==null?void 0:c.fetchedAt)===void 0?"":`${Et(c.fetchedAt,r)}读取`}),s.jsxs("button",{className:"small-button",disabled:m!==null,onClick:()=>void A(!0),children:[s.jsx(J,{name:"refresh"}),m==="refresh"?"读取中…":"检查更新"]}),s.jsx("button",{className:"ghost small-button",onClick:()=>j(M=>!M),children:"仓库"})]})]}),E&&c!==null&&s.jsx(TH,{repos:c.repos,disabled:m!==null,onSave:M=>P("repos",async()=>(await e.connection.call("skillhub/repos/set",{repos:M}),j(!1),await e.connection.call("skillhub/list",{refresh:!0}),"已保存,按新的仓库读取"))}),c==null?void 0:c.errors.map(M=>s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsxs("span",{children:["读不到:",M,c.items.length>0?"(下面是之前读到的)":""]})]},M))]}),y!==null&&s.jsx("div",{className:"notice info",children:y}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:p})]}),c===null&&p===null&&s.jsx("p",{className:"muted",children:"正在读取技能库…"}),c!==null&&c.items.length===0&&c.errors.length===0&&s.jsx("p",{className:"muted",children:"技能库里还没有技能。"}),B.map(M=>s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"sidebar-label",children:[M.label,s.jsx("span",{className:"skills-count",children:M.items.length}),"hint"in M&&s.jsxs("span",{children:["· ",M.hint]})]}),s.jsx("ul",{className:"hub-list",children:M.items.map(z=>{var D,U,I,T;return s.jsxs("li",{className:z.name===t?"focused":"",children:[s.jsxs("div",{className:"hub-main",children:[s.jsxs("div",{className:"hub-title",children:[s.jsx("strong",{children:z.title??z.name}),z.title!==void 0&&s.jsx("code",{className:"muted small",children:z.name}),s.jsx("span",{className:"badge",children:AH[z.kind]}),((D=z.installed)==null?void 0:D.modified)===!0&&s.jsx("span",{className:"badge",title:"你改过这个技能;更新时不会覆盖",children:"你改过"}),((U=z.installed)==null?void 0:U.update)===!0&&s.jsx("span",{className:"badge ok",children:"有新版"})]}),s.jsx("span",{className:"muted small",children:z.description}),z.blocked!==void 0&&s.jsxs("span",{className:"muted small",children:[z.blocked,",没有下载(以你已有的为准)"]})]}),s.jsxs("div",{className:"hub-actions",children:[z.installed===void 0&&z.blocked===void 0&&s.jsx("button",{className:"primary small-button",disabled:m!==null,onClick:()=>void P(`install:${z.name}`,async()=>(await e.connection.call("skillhub/install",{name:z.name,repo:z.repo}),`已下载 ${z.name},agent 现在就能用`)),children:m===`install:${z.name}`?"下载中…":"下载"}),((I=z.installed)==null?void 0:I.update)===!0&&z.installed.modified!==!0&&s.jsx("button",{className:"primary small-button",disabled:m!==null,onClick:()=>void V(z),children:"更新"}),((T=z.installed)==null?void 0:T.update)===!0&&z.installed.modified===!0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"small-button",disabled:m!==null,onClick:()=>void P(`diff:${z.name}`,async()=>k({name:z.name,...await e.connection.call("skillhub/diff",{name:z.name})})),children:"看看哪里不同"}),s.jsx("button",{className:"small-button",disabled:m!==null,onClick:()=>void V(z,"keep"),children:"保留我的"}),s.jsx("button",{className:"small-button",disabled:m!==null,onClick:()=>void V(z,"replace"),children:"用新版"}),s.jsx("button",{className:"primary small-button",disabled:m!==null,onClick:()=>void V(z,"merge"),children:"让 agent 合并"})]}),z.installed!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ghost small-button",onClick:()=>i(z.name),children:"查看"}),s.jsx("button",{className:"ghost small-button",disabled:m!==null,onClick:()=>void P(`remove:${z.name}`,async()=>(await e.connection.call("skillhub/remove",{name:z.name}),`已删除下载的 ${z.name}`)),children:"删除"})]})]}),(N==null?void 0:N.name)===z.name&&s.jsx($H,{mine:N.mine,theirs:N.theirs,onClose:()=>k(null)})]},`${z.repo}/${z.name}`)})})]},M.label))]})}function TH({repos:e,disabled:t,onSave:n}){const[i,r]=b.useState(e.map(u=>u.branch==="main"?u.repo:`${u.repo}@${u.branch}`).join(`
233
+ `)),o=i.split(/\r?\n/).map(u=>u.trim()).filter(Boolean).map(u=>{const[d,h]=u.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("@");return{repo:d??"",branch:h??"main"}}),c=o.length>0&&o.every(u=>/^[\w.-]+\/[\w.-]+$/.test(u.repo)&&/^[\w./-]+$/.test(u.branch));return s.jsxs("div",{className:"hub-repos",children:[s.jsx("label",{className:"field-label",htmlFor:"hub-repos",children:"技能仓库(一行一个 owner/repo,可以写 @分支;前面的同名技能优先)"}),s.jsx("textarea",{id:"hub-repos",className:"text-input plain",rows:3,value:i,onChange:u=>r(u.target.value),spellCheck:!1}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:"别的仓库里的技能会让 agent 照着做,只加你信得过的。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:t,onClick:()=>r("MultiGameAssistant/skills"),children:"恢复默认"}),s.jsx("button",{className:"primary small-button",disabled:t||!c,onClick:()=>n(o),children:"保存"})]})]})}function $H({mine:e,theirs:t,onClose:n}){const i=b.useMemo(()=>MH(e.split(/\r?\n/),t.split(/\r?\n/)),[e,t]);return s.jsxs("div",{className:"hub-diff",children:[s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[s.jsx("span",{className:"diff-del",children:"− 只在你的版本里"})," ",s.jsx("span",{className:"diff-add",children:"+ 只在新版本里"})]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"ghost small-button",onClick:n,children:"收起"})]}),s.jsx("pre",{children:i.map((r,o)=>s.jsxs("div",{className:r.kind==="-"?"diff-del":r.kind==="+"?"diff-add":"muted",children:[r.kind," ",r.text]},o))})]})}function MH(e,t){var m;const n=e.length,i=t.length,r=Array.from({length:n+1},()=>new Array(i+1).fill(0));for(let g=n-1;g>=0;g--)for(let p=i-1;p>=0;p--)r[g][p]=e[g]===t[p]?r[g+1][p+1]+1:Math.max(r[g+1][p],r[g][p+1]);const o=[];let c=0,u=0;for(;c<n||u<i;)c<n&&u<i&&e[c]===t[u]?(o.push({kind:" ",text:e[c]}),c++,u++):u<i&&(c===n||r[c][u+1]>=r[c+1][u])?(o.push({kind:"+",text:t[u]}),u++):(o.push({kind:"-",text:e[c]}),c++);const d=g=>o.slice(Math.max(0,g-2),g+3).some(p=>p.kind!==" "),h=[];for(let g=0;g<o.length;g++)o[g].kind!==" "||d(g)?h.push(o[g]):((m=h.at(-1))==null?void 0:m.text)!=="…"&&h.push({kind:" ",text:"…"});return h}const RH=[{label:"本应用自带 · 受保护",match:e=>e==="bundled"},{label:"从技能库下载的",match:e=>e==="hub"},{label:"脚本包和游戏包",match:e=>e==="custom"},{label:"你的技能文件夹",match:e=>e.startsWith("user-")},{label:"工作文件夹里的",match:e=>e.startsWith("project-")}];function OH(e){var t;return e.removable===!0?"在这里存的":((t=RH.find(n=>n.match(e.source)))==null?void 0:t.label)??"其他"}const PH="通用",Y_="adg:skills:folded";function zH(){try{return new Set(JSON.parse(localStorage.getItem(Y_)??"[]"))}catch{return new Set}}function LH(e){try{localStorage.setItem(Y_,JSON.stringify([...e]))}catch{}}const DH=e=>e.startsWith("game:")?"gamepad":e.startsWith("script:")?"package":"layers";function FH({client:e,arg:t,openSession:n}){var ne,ie,pe,Ce;const i=we(e.connection.status),r=we(e.capabilities),[o,c]=b.useState((t==null?void 0:t.startsWith("hub"))===!0?"hub":"mine"),u=(t==null?void 0:t.startsWith("hub:"))===!0?t.slice(4):void 0,[d,h]=b.useState(null),[m,g]=b.useState(""),[p,x]=b.useState(t??""),[y,S]=b.useState(null),[N,k]=b.useState(null),[E,j]=b.useState(0),[A,P]=b.useState(!1),[L,B]=b.useState(null),[V,M]=b.useState(zH),[z,D]=b.useState(!1),U=fe=>M(ve=>{const ue=new Set(ve);return ue.delete(fe)||ue.add(fe),LH(ue),ue}),I=((ne=Ld(e).data)==null?void 0:ne.scripts)??[],[T,O]=b.useState([]);b.useEffect(()=>{t!==void 0&&(t.startsWith("hub")?c("hub"):(c("mine"),x(t)))},[t]),b.useEffect(()=>e.connection.on("skills/changed",()=>j(fe=>fe+1)),[e]),b.useEffect(()=>{if(i.state!=="open"||!r.has("games"))return;let fe=!0;return e.connection.call("games/list",{}).then(ve=>{fe&&O(ve.games)},()=>{}),()=>{fe=!1}},[e,i.state,r]),b.useEffect(()=>{if(i.state!=="open")return;let fe=!0;return e.connection.call("skills/list",{}).then(ve=>{fe&&(h(ve.skills),k(null))},ve=>{fe&&k(Ie(ve))}),()=>{fe=!1}},[e,i.state,E,o]);const $=m.trim().toLowerCase(),F=b.useMemo(()=>(d??[]).filter(fe=>$===""||`${fe.name} ${fe.description} ${fe.whenToUse??""}`.toLowerCase().includes($)),[d,$]),H=b.useMemo(()=>{const fe=new Map,ve=(Te,tt,et)=>{const St=fe.get(Te)??{key:Te,label:tt,items:[],subs:[],...et};return fe.set(Te,St),St},ue=Te=>ve(`game:${Te.id}`,Te.name,{game:Te.id}),xe=(Te,tt)=>{const et=Te.subs.find(St=>St.script===tt.id)??{key:`${Te.key}/${tt.id}`,label:tt.name,script:tt.id,items:[]};return Te.subs.includes(et)||Te.subs.push(et),et},De=(Te,tt)=>{Te.includes(tt)||Te.push(tt)};if($===""){for(const Te of T)ue(Te);for(const Te of I){const tt=sw(Te,T);tt===void 0?ve(`script:${Te.id}`,Te.name,{script:Te.id}):xe(ue(tt),Te)}}for(const Te of F){const tt=yp(Te.owner,I,T);tt.length===0&&De(ve("general",PH,{}).items,Te);for(const et of tt)et.game!==void 0&&et.script!==void 0?De(xe(ue(et.game),et.script).items,Te):et.game!==void 0?De(ue(et.game).items,Te):et.script!==void 0&&De(ve(`script:${et.script.id}`,et.script.name,{script:et.script.id}).items,Te)}const Me=(Te,tt)=>Te.name.localeCompare(tt.name),Ge=Te=>Te.key.startsWith("game:")?0:Te.key.startsWith("script:")?1:2;return[...fe.values()].map(Te=>({...Te,items:Te.items.sort(Me),subs:Te.subs.map(tt=>({...tt,items:tt.items.sort(Me)})).sort((tt,et)=>tt.label.localeCompare(et.label))})).sort((Te,tt)=>Ge(Te)-Ge(tt)||Te.label.localeCompare(tt.label))},[F,I,T,$]),Z=H.flatMap(fe=>[...fe.items,...fe.subs.flatMap(ve=>ve.items)])[0],G=F.find(fe=>fe.name===p)??Z;b.useEffect(()=>{if(D(!1),G===void 0){S(null);return}let fe=!0;return P(!1),e.connection.call("skills/get",{name:G.name}).then(ve=>{fe&&S(ve)},ve=>{fe&&k(Ie(ve))}),()=>{fe=!1}},[e,G==null?void 0:G.name,E]);const q=fe=>{var ve;(ve=navigator.clipboard)==null||ve.writeText(`/${fe} `).then(()=>P(!0),()=>{})},X=async fe=>{if(await Os({title:`删除技能「${fe.name}」?`,message:"它的文件夹会一起删掉,agent 以后就用不到它了。",confirmLabel:"删除",danger:!0}))try{await e.connection.call("skills/remove",{name:fe.name}),x(""),j(ve=>ve+1)}catch(ve){k(Ie(ve))}},Y=fe=>[...new Set(yp(fe.owner,I,T).map(iw))],re=fe=>({name:"",description:"",content:"",scripts:fe.script===void 0?[]:[fe.script],games:fe.script===void 0&&fe.game!==void 0?[fe.game]:[]}),ee=fe=>s.jsxs("button",{className:`script-row skill-row ${L===null&&(G==null?void 0:G.name)===fe.name?"active":""}`,onClick:()=>{B(null),x(fe.name)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:fe.name}),s.jsx("span",{className:"muted small skills-row-desc",children:fe.description})]}),fe.removable===!0&&s.jsx("span",{className:"skill-row-mark",title:"在这里存的:可以编辑和删除",children:s.jsx(J,{name:"pencil"})})]},fe.name),se=(fe,ve,ue)=>s.jsx("button",{className:"icon-button skills-add",title:ue,"aria-label":`在${fe}下新建技能`,disabled:i.state!=="open",onClick:()=>B(re(ve)),children:s.jsx(J,{name:"plus"})});return s.jsxs("section",{className:"main scripts-page skills-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"技能"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:o==="hub"?"技能库":"agent 的技能"})]}),s.jsxs("div",{className:"page-actions",children:[r.has("skillhub")&&s.jsxs("div",{className:"tabs",role:"tablist",children:[s.jsx("button",{role:"tab","aria-selected":o==="mine",className:o==="mine"?"active":"",onClick:()=>c("mine"),children:"已有的技能"}),s.jsx("button",{role:"tab","aria-selected":o==="hub",className:o==="hub"?"active":"",onClick:()=>c("hub"),children:"技能库"})]}),o==="mine"&&s.jsxs("button",{className:"small-button",disabled:i.state!=="open",onClick:()=>B(re({})),children:[s.jsx(J,{name:"plus"}),"新建技能"]}),o==="mine"&&s.jsxs("button",{className:"small-button",onClick:()=>j(fe=>fe+1),children:[s.jsx(J,{name:"refresh"}),"刷新"]})]})]}),o==="hub"&&r.has("skillhub")?s.jsx("div",{className:"skill-hub-body",children:s.jsx(IH,{client:e,focus:u,openSession:n,openSkill:fe=>{x(fe),c("mine")}})}):s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"技能列表",children:[s.jsxs("div",{className:"skills-search",children:[s.jsx(J,{name:"search"}),s.jsx("input",{className:"text-input",value:m,onChange:fe=>g(fe.target.value),placeholder:"搜索技能","aria-label":"搜索技能"})]}),d!==null&&$!==""&&s.jsx("p",{className:"muted small skills-found",children:F.length===0?"没有匹配的技能。":`找到 ${F.length} 个技能`}),d!==null&&$===""&&F.length===0&&s.jsx("p",{className:"muted small pad",children:"还没有技能。"}),H.map(fe=>{const ve=$!==""||!V.has(fe.key);return s.jsxs("div",{className:`skills-group ${ve?"":"folded"}`,children:[s.jsxs("div",{className:"skills-section-head",children:[s.jsxs("button",{className:"skills-fold","aria-expanded":ve,onClick:()=>U(fe.key),children:[s.jsx(J,{name:"chevron-down",className:"skills-chevron"}),s.jsx(J,{name:DH(fe.key),className:"skills-section-icon"}),s.jsx("span",{className:"skills-group-name",children:fe.label}),s.jsx("span",{className:"skills-count",children:new Set([...fe.items,...fe.subs.flatMap(ue=>ue.items)]).size})]}),se(fe.label,fe,fe.game!==void 0?`给游戏「${fe.label}」新建一个技能(处理这个游戏的对话都能用)`:fe.script!==void 0?`给「${fe.label}」新建一个技能(只给它用)`:"新建一个通用技能")]}),ve&&s.jsxs(s.Fragment,{children:[fe.items.map(ee),fe.script!==void 0&&fe.items.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有只给它用的技能"}),fe.game!==void 0&&fe.items.length===0&&fe.subs.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有这个游戏的技能"}),fe.subs.map(ue=>s.jsxs("div",{className:"skills-sub",children:[s.jsxs("div",{className:"skills-sub-label",children:[s.jsx(J,{name:"package",className:"skills-section-icon"}),s.jsx("span",{className:"skills-group-name",children:ue.label}),s.jsx("span",{className:"skills-count",children:ue.items.length}),s.jsx("span",{className:"spacer"}),se(ue.label,{script:ue.script},`给「${ue.label}」新建一个技能(只给它用)`)]}),ue.items.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有只给它用的技能"}),ue.items.map(ee)]},ue.key))]})]},fe.key)})]}),s.jsx("div",{className:"scripts-detail",children:s.jsxs("div",{className:"script-detail",children:[N!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:N})]}),L!==null?s.jsx(UH,{client:e,draft:L,scripts:I,games:T,onCancel:()=>B(null),onSaved:fe=>{B(null),x(fe),k(null),j(ve=>ve+1)}}):s.jsxs(s.Fragment,{children:[d===null&&N===null&&s.jsx("p",{className:"muted",children:"正在读取…"}),d!==null&&G===void 0&&s.jsxs("div",{className:"skills-blank",children:[s.jsx(J,{name:"sparkles"}),s.jsx("strong",{children:"还没有技能"}),s.jsx("span",{className:"muted small",children:"agent 做成一件事后会提议存成技能;也可以自己写一个。"}),s.jsxs("button",{className:"small-button primary",disabled:i.state!=="open",onClick:()=>B(re({})),children:[s.jsx(J,{name:"plus"}),"新建技能"]})]}),G!==void 0&&s.jsxs("article",{className:"card skill-card",children:[s.jsxs("header",{className:"skill-top",children:[s.jsxs("div",{className:"skill-title",children:[s.jsx("h2",{children:G.name}),s.jsxs("div",{className:"skill-meta",children:[Y(G).length===0?s.jsxs("span",{className:"badge",title:"所有对话都看得到、用得了",children:[s.jsx(J,{name:"layers"}),"通用"]}):s.jsxs("span",{className:"badge warn",title:"技能隔离:只有在处理这些游戏或脚本的对话里,agent 才看得到、用得了这个技能",children:[s.jsx(J,{name:(pe=(ie=G.owner)==null?void 0:ie.scripts)!=null&&pe.length?"package":"gamepad"}),"只给 ",Y(G).join("、")," 用"]}),G.modelInvocable&&s.jsx("span",{className:"badge ok",title:"agent 遇到相关的事会自己读这个技能",children:"agent 自动使用"}),s.jsxs("span",{className:"badge",title:G.removable===!0?"存在这个软件的技能文件夹里,可以编辑和删除":`在这里不能改和删${G.source==="hub"?",到「技能库」里卸载":""}`,children:[OH(G),G.removable===!0?"":" · 只读"]})]})]}),s.jsxs("div",{className:"skill-buttons",children:[G.userInvocable&&s.jsxs("button",{className:"small-button",onClick:()=>q(G.name),title:"复制后粘贴到对话框,后面写要它做的事",children:[s.jsx(J,{name:A?"check":"copy"}),A?"已复制":`/${G.name}`]}),(G.removable===!0||G.source==="hub")&&s.jsxs("button",{className:"small-button","aria-expanded":z,onClick:()=>D(fe=>!fe),title:"放错了游戏或脚本时,换到对的那个",children:[s.jsx(J,{name:"gamepad"}),"更换游戏和脚本"]}),G.removable===!0&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"small-button",disabled:(y==null?void 0:y.name)!==G.name,onClick:()=>{var fe,ve;return B({original:G.name,name:G.name,description:G.description,content:(y==null?void 0:y.content)??"",scripts:[...((fe=G.owner)==null?void 0:fe.scripts)??[]],games:[...((ve=G.owner)==null?void 0:ve.games)??[]]})},children:[s.jsx(J,{name:"pencil"}),"编辑"]}),s.jsx("button",{className:"small-button danger-outline",onClick:()=>void X(G),children:"删除"})]}),G.path!==void 0&&((Ce=wi())==null?void 0:Ce.openPath)!==void 0&&s.jsx("button",{className:"icon-button skill-folder",title:`打开所在文件夹:${G.path}`,"aria-label":"打开所在文件夹",onClick:()=>{var fe,ve;return void((ve=(fe=wi())==null?void 0:fe.openPath)==null?void 0:ve.call(fe,G.path.replace(/[\\/][^\\/]+$/,"")))},children:s.jsx(J,{name:"layers"})})]})]}),z&&s.jsx(BH,{client:e,skill:G,content:(y==null?void 0:y.name)===G.name?y.content:void 0,scripts:I,games:T,onCancel:()=>D(!1),onMoved:()=>{D(!1),k(null),j(fe=>fe+1)}},G.name),s.jsx("p",{className:"skill-desc",children:G.description}),G.whenToUse!==void 0&&s.jsxs("p",{className:"muted small",children:["什么时候用:",G.whenToUse]}),s.jsxs("section",{className:"skill-body","aria-label":"技能内容",children:[s.jsx("div",{className:"skill-body-label",children:"技能内容"}),(y==null?void 0:y.name)===G.name?s.jsx(Js,{text:y.content}):s.jsx("p",{className:"muted",children:"正在读取…"})]}),G.path!==void 0&&s.jsx("code",{className:"muted small skill-path",title:G.path,children:G.path})]})]})]})})]})]})}function UH({client:e,draft:t,scripts:n,games:i,onCancel:r,onSaved:o}){const[c,u]=b.useState(t),[d,h]=b.useState(!1),[m,g]=b.useState(null);b.useEffect(()=>{u(t),g(null)},[t]);const p=t.original!==void 0,x=HN.test(c.name)&&c.name.length<=Gm,y=x&&c.description.trim().length>=10&&c.content.trim().length>=20,S=async()=>{h(!0),g(null);try{await e.connection.call("skills/save",{name:c.name,description:c.description.trim(),content:c.content.trim(),...c.scripts.length===0?{}:{scripts:c.scripts},...c.games.length===0?{}:{games:c.games},...p?{replace:!0}:{}}),o(c.name)}catch(N){g(Ie(N))}finally{h(!1)}};return s.jsxs("article",{className:"card skill-card skill-form",children:[s.jsx("div",{className:"skill-head",children:s.jsx("h2",{children:p?`编辑 ${t.original}`:"新建技能"})}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:"名字(在对话里用 /名字 调用它)"}),s.jsx("input",{className:"text-input",value:c.name,disabled:p,maxLength:Gm,autoFocus:!p,onChange:N=>u(k=>({...k,name:N.target.value.trim().toLowerCase()})),placeholder:"例:maa-daily-check"}),c.name!==""&&!x&&s.jsx("span",{className:"error small",children:"只能用小写英文字母、数字和短横线,例如 maa-daily-check"})]}),s.jsx(X_,{scripts:n,games:i,value:c,onChange:N=>u(k=>({...k,...N}))}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:"说明:做什么、什么时候用(agent 靠它决定什么时候用,10–400 字)"}),s.jsx("textarea",{className:"text-input",rows:2,maxLength:400,value:c.description,onChange:N=>u(k=>({...k,description:N.target.value})),placeholder:"例:MAA 日常跑完后检查理智和基建是否都处理了;用户问「MAA 跑完了吗」时用。"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:"内容(Markdown):适用场景、一步一步的做法、怎样算成功、注意事项"}),s.jsx("textarea",{className:"text-input skill-content-input",rows:16,maxLength:2e4,value:c.content,onChange:N=>u(k=>({...k,content:N.target.value}))})]}),m!==null&&s.jsx("p",{className:"error small",children:m}),s.jsxs("div",{className:"skill-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:d,onClick:r,children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:d||!y,onClick:()=>void S(),children:d?"保存中…":"保存"})]})]})}function X_({scripts:e,games:t,value:n,onChange:i}){const[r]=b.useState(n),o=[...new Set([...r.scripts,...n.scripts])].filter(m=>!e.some(g=>g.id===m)),c=[...new Set([...r.games,...n.games])].filter(m=>vp(m,t)===void 0),u=(m,g)=>{var p;return m===g||((p=vp(m,t))==null?void 0:p.id)===g},d=m=>i({...n,scripts:n.scripts.includes(m)?n.scripts.filter(g=>g!==m):[...n.scripts,m]}),h=m=>i({...n,games:n.games.some(g=>u(g,m))?n.games.filter(g=>!u(g,m)):[...n.games,m]});return s.jsxs(s.Fragment,{children:[(t.length>0||c.length>0)&&s.jsxs("fieldset",{className:"field skill-owners",children:[s.jsx("legend",{className:"field-label",children:"给哪个游戏用(和游戏本身有关、换个脚本也用得上的:游戏里的操作、界面、活动、机制)"}),s.jsxs("div",{className:"skill-owner-list",children:[t.map(m=>s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.games.some(g=>u(g,m.id)),onChange:()=>h(m.id)}),m.name]},m.id)),c.map(m=>s.jsxs("label",{className:"check-label",title:"游戏页上没有这个游戏",children:[s.jsx("input",{type:"checkbox",checked:n.games.includes(m),onChange:()=>h(m)}),m]},m))]})]}),s.jsxs("fieldset",{className:"field skill-owners",children:[s.jsx("legend",{className:"field-label",children:"给哪个脚本用(只在用这个脚本时才用得上的做法:它的配置、报错、日志)"}),e.length===0&&o.length===0&&s.jsx("span",{className:"muted small",children:"还没有装脚本。"}),s.jsxs("div",{className:"skill-owner-list",children:[e.map(m=>s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.scripts.includes(m.id),onChange:()=>d(m.id)}),m.name]},m.id)),o.map(m=>s.jsxs("label",{className:"check-label",title:"这个脚本不在脚本库里(删掉了,或是脚本包 id)",children:[s.jsx("input",{type:"checkbox",checked:n.scripts.includes(m),onChange:()=>d(m)}),m]},m))]})]}),s.jsx("p",{className:"muted small",children:"游戏和脚本都不选就是通用技能,所有对话都能用。"})]})}function BH({client:e,skill:t,content:n,scripts:i,games:r,onCancel:o,onMoved:c}){var S,N;const[u,d]=b.useState({scripts:[...((S=t.owner)==null?void 0:S.scripts)??[]],games:[...((N=t.owner)==null?void 0:N.games)??[]]}),[h,m]=b.useState(!1),[g,p]=b.useState(null),x=t.source==="hub",y=async k=>{m(!0),p(null);try{if(x)await e.connection.call("skillhub/owner",{name:t.name,owner:k});else{if(n===void 0||k===null)return;await e.connection.call("skills/save",{name:t.name,description:t.description,content:n,replace:!0,...k.scripts.length===0?{}:{scripts:k.scripts},...k.games.length===0?{}:{games:k.games}})}c()}catch(E){p(Ie(E))}finally{m(!1)}};return s.jsxs("div",{className:"skill-move",role:"group","aria-label":"更换游戏和脚本",children:[s.jsx(X_,{scripts:i,games:r,value:u,onChange:d}),x&&s.jsx("p",{className:"muted small",children:"这是从技能库下载的技能:你选的会一直保留,技能库更新它也不变。"}),g!==null&&s.jsx("p",{className:"error small",children:g}),s.jsxs("div",{className:"skill-actions",children:[x&&s.jsx("button",{className:"link-button small",disabled:h,onClick:()=>void y(null),children:"恢复成技能库里的"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:h,onClick:o,children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:h||!x&&n===void 0,onClick:()=>void y(u),children:h?"保存中…":"保存"})]})]})}const HH={id:"skills",title:"技能",requires:["skills"],pages:[{id:"skills",title:"技能",icon:"sparkles",order:50,agent:"scripts",component:FH}]};function ZH({client:e}){const t=we(e.connection.status),[n,i]=b.useState(null),[r,o]=b.useState(0),[c,u]=b.useState(null),[d,h]=b.useState(null),[m,g]=b.useState(""),[p,x]=b.useState("");b.useEffect(()=>e.connection.on("emulators/changed",()=>o(N=>N+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let N=!0;return e.connection.call("emulators/status",{refresh:r===0}).then(k=>{N&&(i(k),g(k.settings.manualAddress??""),x(k.settings.adbPath??""))}).catch(k=>{N&&h(Ie(k))}),()=>{N=!1}},[e,t.state,r]);const y=async(N,k)=>{u(N),h(null);try{await k(),o(E=>E+1)}catch(E){h(Ie(E))}finally{u(null)}},S=N=>y("settings",()=>e.connection.call("emulators/settings/set",N));return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"模拟器"}),s.jsx("p",{children:"需要安卓模拟器的任务(如 MAA)运行前,会自动启动这里选定的实例并取得 ADB 地址。分辨率请设为 16:9(如 1280×720)。"}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"当前使用"}),s.jsx("p",{className:"muted small",children:(n==null?void 0:n.selection.label)??"…"})]}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y("refresh",()=>e.connection.call("emulators/status",{refresh:!0})),children:"重新检测"})]}),(n==null?void 0:n.selection.problem)!==void 0&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(J,{name:"info"}),s.jsxs("span",{children:[n.selection.problem,"。可以对 agent 说「安装 MuMu 模拟器」,或在下面填写手动 ADB 地址。"]})]})]}),n==null?void 0:n.providers.map(N=>s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsxs("h3",{children:[N.name,N.version===void 0?"":` ${N.version}`]}),s.jsx("p",{className:"muted small",children:N.manager})]}),n.settings.mumuManager===N.manager&&s.jsx("span",{className:"badge ok",children:"已指定"})]}),N.error!==void 0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:N.error})]}),s.jsx("ul",{className:"version-list",children:N.instances.map(k=>s.jsxs("li",{className:k.index===n.settings.instance?"current":"",children:[s.jsx("span",{className:"version-name",children:k.index}),s.jsx("span",{children:k.name}),s.jsx("span",{className:`badge ${k.ready?"ok":""}`,children:k.ready?"已启动":k.running?"启动中":"未运行"}),k.adb!==void 0&&s.jsx("span",{className:"muted small",children:k.adb}),s.jsx("span",{className:"spacer"}),k.index!==n.settings.instance&&s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void S({instance:k.index}),children:"任务用这个"}),k.ready?s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y(`stop-${k.index}`,()=>e.connection.call("emulators/stop",{index:k.index})),children:"关闭"}):s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y(`start-${k.index}`,()=>e.connection.call("emulators/start",{index:k.index})),children:c===`start-${k.index}`?"启动中…":"启动"})]},k.index))})]},N.manager)),n!==null&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"设置"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.settings.autoStart,onChange:N=>void S({autoStart:N.target.checked})}),"任务需要时自动启动模拟器"]}),s.jsx("label",{className:"field-label",htmlFor:"manual-adb",children:"手动 ADB 地址(其他模拟器或真机,可选)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"manual-adb",className:"text-input plain",value:m,onChange:N=>g(N.target.value),placeholder:"例如 127.0.0.1:5555;填写后不再管理 MuMu",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void S({manualAddress:m.trim()===""?null:m.trim()}),children:"保存"})]}),s.jsx("label",{className:"field-label",htmlFor:"adb-path",children:"adb.exe 位置(可选,出错时重连模拟器、截图用;默认用 MuMu 自带的)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"adb-path",className:"text-input plain",value:p,onChange:N=>x(N.target.value),placeholder:"例如 D:\\platform-tools\\adb.exe",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void S({adbPath:p.trim()===""?null:p.trim()}),children:"保存"})]}),s.jsx("label",{className:"field-label",htmlFor:"boot-timeout",children:"等待安卓启动的最长时间(秒)"}),s.jsx("input",{id:"boot-timeout",className:"text-input plain",type:"number",min:30,max:900,defaultValue:n.settings.bootTimeoutSeconds,onBlur:N=>void S({bootTimeoutSeconds:Math.max(30,Math.min(900,Number(N.target.value)||180))})})]}),d!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:d})]})]})}function WH({client:e}){const t=we(e.connection.status),[n,i]=b.useState(null),[r,o]=b.useState(null),[c,u]=b.useState(""),[d,h]=b.useState(""),[m,g]=b.useState(null),[p,x]=b.useState(!1),[y,S]=b.useState(null),[N,k]=b.useState(null),E=()=>e.connection.call("scripts/settings",{}).then(L=>{i(L),o(L)}).catch(L=>k(Ie(L)));if(b.useEffect(()=>{t.state==="open"&&E()},[e,t.state]),r===null||n===null)return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"脚本安装"}),N===null?s.jsx("p",{children:"加载中…"}):s.jsx("div",{className:"notice error left",children:N})]});const j=(L,B)=>o({...r,[L]:B}),A=async()=>{x(!0),k(null),S(null);try{const{tokenConfigured:L,cdkConfigured:B,...V}=n,M=Object.fromEntries(Object.entries(r).filter(([z,D])=>V[z]!==D));Object.keys(M).length>0&&await e.connection.call("scripts/settings/set",M),c.trim()!==""&&await e.connection.call("credentials/set",{ref:r.tokenRef,value:c.trim()}),u(""),d.trim()!==""&&(await e.connection.call("credentials/set",{ref:r.cdkRef,value:d.trim()}),h(""),P()),await E(),S("已保存,下一次安装起生效")}catch(L){k(Ie(L))}finally{x(!1)}},P=async()=>{g("checking");try{g(await e.connection.call("scripts/mirrorchyan/check",{}))}catch(L){g({ok:!1,message:Ie(L)})}};return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"脚本安装"}),s.jsx("p",{children:"从 GitHub 发布页下载脚本时使用的设置。国内网络下载慢或失败时,可以填写下载镜像前缀。"}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"下载镜像"}),s.jsx("input",{className:"text-input plain",value:r.downloadMirror,onChange:L=>j("downloadMirror",L.target.value),placeholder:"留空直接下载;例如 https://ghfast.top/",spellCheck:!1}),s.jsx("p",{className:"muted small",children:"镜像只用于 GitHub 上的文件:下载地址前面加上这个前缀。微软、Google 等官方组件始终直接下载。"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:r.mirrorFallback,onChange:L=>j("mirrorFallback",L.target.checked)}),"镜像失败时改为直接下载"]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"Mirror酱"}),s.jsxs("p",{className:"muted small",children:["在 ",s.jsx("a",{href:"https://mirrorchyan.com?source=multigameassistant_settings",target:"_blank",rel:"noreferrer",children:"Mirror酱"})," 发布的脚本(MAA、MaaEnd、三月七小助手、M9A、BetterGI 等)填了 CDK 后从 Mirror酱 更新:国内下载快,而且只下载改动的文件(增量更新)。不填照常从 GitHub 下载;CDK 过期、次数用完时也会自动改回 GitHub。"]}),s.jsx("label",{className:"field-label",htmlFor:"mc-cdk",children:"CDK"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"mc-cdk",className:"text-input",type:"password",value:d,onChange:L=>h(L.target.value),placeholder:n.cdkConfigured?"已配置;输入新值可替换":"在 Mirror酱 购买后得到的 CDK",autoComplete:"off"}),n.cdkConfigured?s.jsx("span",{className:"badge ok",children:"已配置"}):s.jsx("span",{className:"badge",children:"未配置"}),n.cdkConfigured&&s.jsx("button",{className:"small-button",disabled:m==="checking",onClick:()=>void P(),children:m==="checking"?"检查中…":"检查"})]}),m!==null&&m!=="checking"&&s.jsx("p",{className:"small",style:{color:m.ok?"var(--ok)":"var(--error)"},children:m.message}),s.jsxs("p",{className:"muted small",children:["保存在 dsh 的凭据文件里(",r.cdkRef,"),界面和日志里都不会显示它。"]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"GitHub 访问"}),s.jsx("label",{className:"field-label",htmlFor:"gh-token",children:"GitHub Token(可选)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"gh-token",className:"text-input",type:"password",value:c,onChange:L=>u(L.target.value),placeholder:n.tokenConfigured?"已配置;输入新值可替换":"不填也能用;填写后请求上限从每小时 60 次提高到 5000 次",autoComplete:"off"}),n.tokenConfigured?s.jsx("span",{className:"badge ok",children:"已配置"}):s.jsx("span",{className:"badge",children:"未配置"})]}),s.jsxs("p",{className:"muted small",children:["只需要读取公开仓库的权限。保存在 dsh 的凭据文件里(",r.tokenRef,"),界面不会显示它的内容。"]}),s.jsx("label",{className:"field-label",htmlFor:"gh-api",children:"API 地址"}),s.jsx("input",{id:"gh-api",className:"text-input plain",value:r.apiBase,onChange:L=>j("apiBase",L.target.value),spellCheck:!1})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"版本"}),s.jsx("label",{className:"field-label",htmlFor:"keep-versions",children:"每个脚本保留的版本数(含当前版本)"}),s.jsx("input",{id:"keep-versions",className:"text-input plain",type:"number",min:1,max:10,value:r.keepVersions,onChange:L=>j("keepVersions",Math.max(1,Math.min(10,Number(L.target.value)||1)))}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:r.includePrereleases,onChange:L=>j("includePrereleases",L.target.checked)}),"没有正式版时使用预发布版本"]})]}),s.jsxs("div",{className:"key-actions",children:[y!==null&&s.jsx("span",{className:"muted small",children:y}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary",disabled:p,onClick:()=>void A(),children:p?"保存中…":"保存"})]}),N!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:N})]})]})}function VH({client:e,initialRepo:t,jobs:n,onDone:i,openSession:r,onClose:o}){const[c,u]=b.useState(t??""),[d,h]=b.useState(null),[m,g]=b.useState(""),[p,x]=b.useState(""),[y,S]=b.useState(!1),[N,k]=b.useState(null),[E,j]=b.useState(null),A=async(M=c)=>{var D;const z=RR(M);if(z===void 0){k("请输入 owner/repo,或粘贴 GitHub 上的仓库、发布或文件链接");return}S(!0),k(null);try{const U=await e.connection.call("scripts/releases",{repo:z.repo,limit:10});u(z.repo),h({...U,branch:z.branch});const I=U.releases.find(O=>O.tag===z.tag),T=I??U.releases.find(O=>!O.prerelease)??U.releases[0];g((T==null?void 0:T.tag)??""),x(((D=T==null?void 0:T.assets.find(O=>O.name===z.asset))==null?void 0:D.name)??(T==null?void 0:T.suggestedAsset)??""),z.tag!==void 0&&I===void 0&&U.releases.length>0&&k(`最近的发布里没有 ${z.tag},已改选最新版本`)}catch(U){h(null),k(Ie(U))}finally{S(!1)}};b.useEffect(()=>{t!==void 0&&A(t)},[t]);const P=d==null?void 0:d.releases.find(M=>M.tag===m),L=d!==null&&(d.branch!==void 0||d.releases.length===0),B=async()=>{if(d!==null){S(!0),k(null);try{const{jobId:M,scriptId:z}=await e.connection.call("scripts/install",{repo:d.repo,...d.branch===void 0?{}:{branch:d.branch}});j({jobId:M,scriptId:z,tag:d.branch===void 0?"默认分支":`${d.branch} 分支`,asset:"源码压缩包"})}catch(M){k(Ie(M))}finally{S(!1)}}},V=async()=>{var M;if(!(d===null||P===void 0||p==="")){S(!0),k(null);try{const{jobId:z,scriptId:D}=await e.connection.call("scripts/install",{repo:d.repo,tag:P.tag,asset:p});j({jobId:z,scriptId:D,tag:P.tag,asset:p,size:(M=P.assets.find(U=>U.name===p))==null?void 0:M.size})}catch(z){k(Ie(z))}finally{S(!1)}}};if(E!==null&&d!==null){const M=n.get(E.scriptId);return s.jsx(Q_,{client:e,repo:d.repo,...E,job:(M==null?void 0:M.id)===E.jobId?M:void 0,onDone:()=>i(E.scriptId),openSession:r,onRetry:()=>j(null),onClose:o})}return s.jsxs("section",{className:"card panel-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"从 GitHub 安装"}),s.jsx("p",{className:"muted small",children:"优先使用发布版本;文件会放进统一的工具目录,旧版本保留用于回滚。"})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:o,children:s.jsx(J,{name:"close"})})]}),s.jsxs("form",{className:"field-row",onSubmit:M=>{M.preventDefault(),A()},children:[s.jsx("input",{className:"text-input plain","aria-label":"GitHub 仓库",value:c,onChange:M=>u(M.target.value),placeholder:"owner/repo 或 GitHub 链接,例如 MaaAssistantArknights/MaaAssistantArknights",spellCheck:!1,disabled:y}),s.jsx("button",{type:"submit",disabled:y||c.trim()==="",children:y&&d===null?"读取中…":"读取发布"})]}),L&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:d.branch!==void 0?`链接指向 ${d.branch} 分支:会下载这个分支当前的源码,之后跟着它更新。`:"这个仓库还没有发布版本:可以下载默认分支当前的源码,之后跟着这个分支更新。"}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:d.releases.length===0?"primary":"",onClick:()=>void B(),disabled:y,children:["安装",d.branch===void 0?"源码":` ${d.branch} 分支`]})]}),d!==null&&d.releases.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"field-label",htmlFor:"release-select",children:["版本",d.packId!==void 0&&s.jsxs("span",{className:"chip subtle",children:["内置脚本包 ",d.packId]})]}),s.jsx(Vt,{id:"release-select",value:m,disabled:y,onChange:M=>{var z;g(M),x(((z=d.releases.find(D=>D.tag===M))==null?void 0:z.suggestedAsset)??"")},options:d.releases.map(M=>({value:M.tag,label:`${M.tag}${M.prerelease?"(预发布)":""}`,...M.publishedAt===void 0?{}:{hint:`${M.publishedAt.slice(0,10)} 发布`}}))}),P!==void 0&&s.jsxs("fieldset",{className:"asset-list",disabled:y,children:[s.jsx("legend",{className:"field-label",children:"下载文件"}),P.assets.length===0&&s.jsx("div",{className:"muted small",children:"这个版本没有可下载的文件"}),[...P.assets].sort((M,z)=>+(z.name===P.suggestedAsset)-+(M.name===P.suggestedAsset)).map(M=>s.jsxs("label",{className:`asset-option ${M.name===p?"active":""}`,children:[s.jsx("input",{type:"radio",name:"asset",value:M.name,checked:M.name===p,onChange:()=>x(M.name)}),s.jsx("span",{className:"asset-name",children:M.name}),M.name===P.suggestedAsset&&s.jsx("span",{className:"badge ok",children:"推荐"}),s.jsx("span",{className:"muted small",children:Sa(M.size)})]},M.name))]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:(P==null?void 0:P.suggestedAsset)===void 0?"没有自动匹配到适合本机的文件,请手动选择。":"已按本机(Windows x64)选好文件。"}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:"primary",onClick:()=>void V(),disabled:y||p==="",children:["安装 ",P==null?void 0:P.tag]})]})]}),N!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:N})]})]})}function qH({client:e,initialRid:t,jobs:n,onDone:i,openSession:r,onGitHub:o,onClose:c}){const[u,d]=b.useState(""),h=GH(e,u),[m,g]=b.useState(null),[p,x]=b.useState(null),[y,S]=b.useState(!1),[N,k]=b.useState(null),[E,j]=b.useState(null);b.useEffect(()=>{e.connection.call("scripts/settings",{}).then(V=>x(V.cdkConfigured),()=>x(null))},[e]);const A=async V=>{S(!0),k(null);try{g(await e.connection.call("scripts/mirrorchyan/lookup",{rid:V}))}catch(M){g(null),k(Ie(M))}finally{S(!1)}};b.useEffect(()=>{t!==void 0&&A(t)},[t]);const P=async()=>{if(m!==null){S(!0),k(null);try{j(await e.connection.call("scripts/install",{mirrorchyan:m.rid}))}catch(V){k(Ie(V))}finally{S(!1)}}};if(E!==null&&m!==null){const V=n.get(E.scriptId);return s.jsx(Q_,{client:e,repo:`Mirror酱 · ${m.rid}`,tag:m.version,asset:`${m.name??m.rid}(Mirror酱 完整包)`,job:(V==null?void 0:V.id)===E.jobId?V:void 0,onDone:()=>i(E.scriptId),openSession:r,onRetry:()=>j(null),onClose:c})}const L=u.trim(),B=/^[\w.-]{1,100}$/.test(L)&&!(h.items??[]).some(V=>V.rid.toLowerCase()===L.toLowerCase());return s.jsxs("section",{className:"card panel-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"从 Mirror酱 安装"}),s.jsx("p",{className:"muted small",children:"按游戏名、工具名或资源 id 查找(查找和查询版本都不需要 CDK);下载需要在「设置 → 脚本安装」填写 CDK,以后的更新有增量包。"})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:c,children:s.jsx(J,{name:"close"})})]}),s.jsx("input",{className:"text-input plain","aria-label":"搜索 Mirror酱",value:u,onChange:V=>d(V.target.value),placeholder:"例如 原神、鸣潮、BetterGI、MAA",spellCheck:!1,autoFocus:!0}),s.jsx(KH,{results:h,selected:m==null?void 0:m.rid,disabled:y,onPick:V=>void A(V)}),B&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:"small-button",disabled:y,onClick:()=>void A(L),children:["按资源 id 查询 ",L]})]}),m!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"install-file",children:[s.jsx(J,{name:"package"}),s.jsx("span",{className:"asset-name",children:m.name??m.rid}),s.jsxs("span",{className:"badge",children:["Mirror酱 ",m.rid]}),s.jsxs("span",{className:"muted small",children:["最新 ",m.version]})]}),m.description!==void 0&&s.jsx("p",{className:"muted small mirror-desc",children:m.description}),p===!1&&s.jsx("div",{className:"notice info left small",children:s.jsxs("span",{children:["还没有填写 Mirror酱 CDK,没法从 Mirror酱 下载。",m.repo!==void 0?"也可以从 GitHub 安装,填了 CDK 后它的更新会走 Mirror酱。":""]})}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:m.repo===void 0?"":`GitHub:${m.repo}`}),s.jsx("span",{className:"spacer"}),m.repo!==void 0&&s.jsx("button",{className:"small-button",disabled:y,onClick:()=>o(m.repo),children:"从 GitHub 安装"}),s.jsxs("button",{className:"primary",onClick:()=>void P(),disabled:y||p===!1,children:["安装 ",m.version]})]})]}),N!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:N})]})]})}function GH(e,t){const[n,i]=b.useState({loading:!0});return b.useEffect(()=>{let r=!0;i(c=>({...c,loading:!0}));const o=setTimeout(()=>{e.connection.call("scripts/mirrorchyan/search",{query:t.trim()}).then(c=>{r&&i({items:c.items,from:c.from,loading:!1})}).catch(c=>{r&&i({error:Ie(c),loading:!1})})},t.trim()===""?0:250);return()=>{r=!1,clearTimeout(o)}},[e,t]),n}function KH({results:e,selected:t,disabled:n,limit:i=8,onPick:r,pickLabel:o="选择"}){const[c,u]=b.useState(!1);if(e.error!==void 0)return s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:e.error})]});const d=e.items??[];if(d.length===0)return s.jsx("div",{className:"muted small mirror-empty",children:e.loading?"查找中…":"没有找到。可以换个说法(游戏简称、英文名),或直接输入资源 id。"});const h=c?d:d.slice(0,i);return s.jsxs(s.Fragment,{children:[e.from==="builtin"&&s.jsx("div",{className:"muted small mirror-empty",children:"读不到 Mirror酱 的项目列表,下面是已知的几个;也可以直接输入资源 id 查询。"}),s.jsx("ul",{className:"mirror-results",children:h.map(m=>s.jsxs("li",{className:m.rid===t?"active":"",children:[s.jsxs("div",{className:"mirror-result-main",children:[s.jsxs("span",{className:"mirror-result-name",children:[m.name,s.jsx("span",{className:"chip subtle",children:m.rid}),m.installed&&s.jsx("span",{className:"badge ok",children:"已在脚本库"})]}),m.description!==""&&s.jsx("span",{className:"muted small",children:m.description})]}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>r(m.rid),children:o})]},m.rid))}),!c&&d.length>i&&s.jsxs("button",{className:"link-button small",onClick:()=>u(!0),children:["还有 ",d.length-i," 个"]})]})}const Dk=["resolving","downloading","verifying","extracting","checking","done"];function Q_({client:e,repo:t,tag:n,asset:i,size:r,job:o,onDone:c,openSession:u,onRetry:d,onClose:h}){const m=(o==null?void 0:o.phase)??"queued",g=m==="done"?o==null?void 0:o.setup:void 0,p=o===void 0||o.endedAt===void 0,x=YH(o==null?void 0:o.received),y=(o==null?void 0:o.total)??r,S=y!==void 0&&y>0&&(o==null?void 0:o.received)!==void 0?Math.min(1,o.received/y):void 0,N=b.useRef(-1),k=Dk.indexOf(m);k>N.current&&(N.current=k);const E=g!==void 0?"交给 agent 安装":m==="done"?"安装完成":m==="failed"?"安装失败":m==="cancelled"?"已取消安装":"正在安装",j=A=>m==="done"||A<N.current?"done":A===N.current?p?"active":"stopped":"todo";return s.jsxs("section",{className:"card panel-card install-progress","aria-live":"polite",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:E}),s.jsxs("p",{className:"muted small",children:[t," · ",n]})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",title:p?"关掉面板,安装在后台继续(左边列表里能看到进度)":"关闭",onClick:h,children:s.jsx(J,{name:"close"})})]}),s.jsxs("div",{className:"install-file",children:[s.jsx(J,{name:"package"}),s.jsx("span",{className:"asset-name",children:i}),r!==void 0&&s.jsx("span",{className:"muted small",children:Sa(r)})]}),s.jsx("ol",{className:"install-steps",children:Dk.slice(0,-1).map((A,P)=>{const L=j(P);return s.jsxs("li",{className:`install-step ${L}`,children:[s.jsx("span",{className:"install-step-mark",children:L==="done"?s.jsx(J,{name:"check"}):L==="stopped"?s.jsx(J,{name:"close"}):P+1}),s.jsx("span",{children:ic[A]})]},A)})}),p&&s.jsxs("div",{className:"install-bar",children:[s.jsx("div",{className:`progress ${m==="downloading"&&S!==void 0?"":"indeterminate"}`,"aria-hidden":"true",children:s.jsx("span",{style:m==="downloading"&&S!==void 0?{width:`${(S*100).toFixed(1)}%`}:void 0})}),s.jsxs("div",{className:"install-numbers muted small",children:[s.jsx("span",{children:o===void 0?"等待开始…":o.message??ic[m]}),m==="downloading"&&(o==null?void 0:o.received)!==void 0&&s.jsxs("span",{className:"install-bytes",children:[Sa(o.received),y!==void 0?` / ${Sa(y)}`:"",S!==void 0?` · ${Math.floor(S*100)}%`:"",x!==void 0?` · ${Sa(Math.round(x))}/s`:"",x!==void 0&&x>0&&y!==void 0?` · 还要 ${XH((y-o.received)/x)}`:""]})]})]}),(o==null?void 0:o.error)!==void 0&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:o.error})]}),g!==void 0&&s.jsxs("div",{className:"notice left",children:[s.jsx(J,{name:"info"}),s.jsxs("span",{children:[o==null?void 0:o.message,"。它也在左边「等待安装」里:没配好模型时可以在那里自己安装。装好后脚本会出现在列表里。"]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:p?"可以关掉这个面板,安装会在后台继续。":g!==void 0?`下载好了 ${(o==null?void 0:o.version)??n} 的安装程序。`:m==="done"?`已安装 ${(o==null?void 0:o.version)??n}。`:""}),s.jsx("span",{className:"spacer"}),p&&o!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:o.id}).catch(()=>{}),children:"取消安装"}),(m==="failed"||m==="cancelled")&&s.jsx("button",{className:"small-button",onClick:d,children:"重新选择"}),(g==null?void 0:g.sessionId)!==void 0&&s.jsx("button",{className:"primary small-button",onClick:()=>u(g.sessionId),children:"查看对话"}),m==="done"&&g===void 0&&s.jsx("button",{className:"primary small-button",onClick:c,children:"查看脚本"})]})]})}function YH(e){const t=b.useRef([]),[n,i]=b.useState(void 0);return b.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 c=o[0];r-c.at>=500&&i((e-c.bytes)/((r-c.at)/1e3))},[e]),n}function XH(e){return!Number.isFinite(e)||e<0?"—":e<60?`${Math.max(1,Math.round(e))} 秒`:`${Math.floor(e/60)} 分 ${Math.round(e%60)} 秒`}function QH({client:e,onImported:t,onClose:n}){const[i,r]=b.useState(""),[o,c]=b.useState(""),[u,d]=b.useState(!1),[h,m]=b.useState(null),g=async()=>{d(!0),m(null);try{const p=await e.connection.call("scripts/import",{path:i.trim().replace(/^"|"$/g,""),...o.trim()===""?{}:{name:o.trim()}});t(p.id)}catch(p){m(Ie(p)),d(!1)}};return s.jsxs("section",{className:"card panel-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"导入本地项目"}),s.jsx("p",{className:"muted small",children:"登记电脑上已有的脚本目录,原地使用:不移动、不复制、不修改,移除时也不会删除。"})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:n,children:s.jsx(J,{name:"close"})})]}),s.jsxs("form",{className:"import-form",onSubmit:p=>{p.preventDefault(),g()},children:[s.jsx("label",{className:"field-label",htmlFor:"import-path",children:"目录路径"}),s.jsx("input",{id:"import-path",className:"text-input plain",value:i,onChange:p=>r(p.target.value),placeholder:"例如 D:\\Games\\MAA",spellCheck:!1,disabled:u}),s.jsx("label",{className:"field-label",htmlFor:"import-name",children:"显示名称(可选)"}),s.jsx("input",{id:"import-name",className:"text-input plain",value:o,onChange:p=>c(p.target.value),placeholder:"留空则按脚本包或目录名",disabled:u}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:"会按内置脚本包自动识别是哪个脚本。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary",type:"submit",disabled:u||i.trim()==="",children:u?"导入中…":"导入"})]})]}),h!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:h})]})]})}function Hp({client:e,job:t,compact:n=!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 s.jsxs("div",{className:`job ${t.phase}${n?" compact":""}`,role:"status",children:[s.jsxs("div",{className:"job-line",children:[s.jsxs("span",{className:"job-phase",children:[o," · ",t.setup!==void 0&&t.phase==="done"?"已交给 agent 安装":ic[t.phase],t.version!==void 0&&t.phase==="done"?` ${t.version}`:""]}),r!==void 0&&i&&s.jsxs("span",{className:"job-bytes",children:[Sa(t.received??0)," / ",Sa(t.total??0)]}),i&&s.jsx("button",{className:"link-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:t.id}).catch(()=>{}),children:"取消"})]}),i&&s.jsx("div",{className:`progress ${r===void 0?"indeterminate":""}`,"aria-hidden":"true",children:s.jsx("span",{style:r===void 0?void 0:{width:`${(r*100).toFixed(1)}%`}})}),!n&&t.message!==void 0&&(i||t.setup!==void 0)&&s.jsx("div",{className:"job-message muted small",children:t.message}),t.error!==void 0&&s.jsx("div",{className:"job-error small",children:t.error})]})}const JH={install:"安装来源",pack:"脚本包",known:"已知项目",user:"你设置的"};function J_({client:e,script:t,disabled:n,act:i}){const[r,o]=b.useState(null),[c,u]=b.useState(""),[d,h]=b.useState(null),m=t.channels.github,g=t.channels.mirrorchyan,p=(N,k)=>i("channel",async()=>{await e.connection.call("scripts/source/set",k==="reset"?{id:t.id,reset:[N]}:N==="repo"?{id:t.id,repo:k}:{id:t.id,mirrorchyan:k}),o(null);const E=N==="repo"?"GitHub":"Mirror酱";return k===null?`已不再从 ${E} 更新`:k==="reset"?`${E} 更新渠道已恢复自动`:`${E} 更新渠道已设为 ${k}`}),x=()=>i("mirror-match",async()=>{const N=await e.connection.call("scripts/mirrorchyan/match",{id:t.id});return h({items:N.items,checked:!0}),N.items.length===0?`Mirror酱 上没有找到它${N.from==="builtin"?"(读不到 Mirror酱 的项目列表,只查了已知的)":""};知道资源 id 的话可以直接「设置」`:void 0}),y=(N,k)=>N==="repo"?/^[\w.-]+\/[\w.-]+$/.test(k):/^[\w.-]{1,100}$/.test(k),S=(N,k,E,j,A)=>s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:k}),s.jsx("dd",{children:r!==N?s.jsxs(s.Fragment,{children:[E!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:E.text}),s.jsxs("span",{className:"muted small",children:["(",JH[E.from],")"]})]}):s.jsx("span",{className:"muted small",children:j}),(E==null?void 0:E.from)!=="install"&&s.jsx("button",{className:"ghost small-button",disabled:n,onClick:()=>{u((E==null?void 0:E.text)??""),o(N)},children:E===void 0?"设置":"修改"}),N==="mirrorchyan"&&E===void 0&&s.jsx("button",{className:"ghost small-button",disabled:n,onClick:()=>void x(),children:"查询是否接入"})]}):s.jsxs("span",{className:"local-source-edit",children:[s.jsx("input",{className:"text-input plain","aria-label":`${k}更新渠道`,value:c,onChange:P=>u(P.target.value),placeholder:A,spellCheck:!1,autoFocus:!0}),s.jsx("button",{className:"primary small-button",disabled:n||!y(N,c.trim()),onClick:()=>void p(N,c.trim()),children:N==="mirrorchyan"?"查询并保存":"保存"}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void p(N,"reset"),children:"恢复自动"}),E!==void 0&&s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void p(N,null),children:"不用"}),s.jsx("button",{className:"ghost small-button",onClick:()=>o(null),children:"取消"})]})})]});return s.jsxs(s.Fragment,{children:[S("repo","GitHub",m===void 0?void 0:{text:m.repo,from:m.from},"未设置:填写它的 GitHub 仓库","owner/repo,例如 babalae/better-genshin-impact"),S("mirrorchyan","Mirror酱",g===void 0?void 0:{text:g.rid,from:g.from},"未设置:在 Mirror酱 发布的脚本填它的资源 id","资源 id,例如 BGI、MAA"),g===void 0&&d!==null&&d.items.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{}),s.jsxs("dd",{className:"mirror-matches",children:[s.jsx("span",{className:"muted small",children:"Mirror酱 上可能是它:"}),d.items.slice(0,5).map(N=>s.jsxs("span",{className:"mirror-match",children:[s.jsx("span",{children:N.name}),s.jsx("span",{className:"chip subtle",children:N.rid}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void p("mirrorchyan",N.rid).then(()=>h(null)),children:"用这个"})]},N.rid))]})]})]})}function e9({client:e,script:t,disabled:n,busy:i,now:r,act:o}){const[c,u]=b.useState(!1),d=t.localVersion,h=t.update,m=t.channels.github!==void 0||t.channels.mirrorchyan!==void 0;return s.jsxs("div",{className:"local-update",children:[s.jsxs("dl",{className:"local-facts",children:[s.jsx("dt",{children:"当前版本"}),s.jsx("dd",{children:d!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"version-name",children:d.version}),s.jsx("span",{className:"muted small",children:d.from==="更新"?"(由 MultiGameAssistant 更新)":`(读自 ${d.from})`})]}):s.jsx("span",{className:"muted small",children:"认不出这个目录的版本:检查更新时会当作可以更新"})}),s.jsx(J_,{client:e,script:t,disabled:n,act:o})]}),c?s.jsxs("div",{className:"local-confirm",children:[s.jsxs("p",{className:"small",children:["将在 ",s.jsx("code",{children:t.dir})," 里更新到 ",h==null?void 0:h.latest,":被替换的程序文件先备份到工具目录(可以撤销),已有的配置文件不动。请先关闭这个脚本。"]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>u(!1),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:n,onClick:()=>void o("update",async()=>(u(!1),(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0)),children:"确认更新"})]})]}):s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[h===void 0?"还没有检查过更新":h.available?`有新版本 ${h.latest}`:`已是最新(${h.latest})`,h!==void 0&&` · ${Et(h.checkedAt,r)}检查`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:n||!m,onClick:()=>void o("check",async()=>{const g=await e.connection.call("scripts/checkUpdate",{id:t.id});return g.available?`发现新版本 ${g.latest}${g.current===void 0?"(认不出当前版本)":`,当前 ${g.current}`}`:"已是最新版本"}),children:i==="check"?"检查中…":"检查更新"}),s.jsx("button",{className:"primary small-button",disabled:n||(h==null?void 0:h.available)!==!0,onClick:()=>u(!0),children:"更新"})]}),t.undo!==void 0&&s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:["上次更新:",t.undo.from??"(未知版本)"," → ",t.undo.to," · ",Et(t.undo.at,r)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void o("restore",async()=>{const g=await e.connection.call("scripts/restore",{id:t.id});return`已撤销,换回了更新前的文件${g.localVersion===void 0?"":`(${g.localVersion.version})`}`}),children:i==="restore"?"撤销中…":"撤销上次更新"})]})]})}function t9({client:e,script:t,openSession:n}){var I,T,O;const i=we(e.connection.status),r=we(e.capabilities),o=An(6e4),[c,u]=b.useState([]),[d,h]=b.useState(0),[m,g]=b.useState(!1),[p,x]=b.useState(null),[y,S]=b.useState(null),[N,k]=b.useState([]),[E,j]=b.useState(!1);b.useEffect(()=>e.connection.on("packs/changed",()=>h($=>$+1)),[e]),b.useEffect(()=>{if(i.state!=="open"||!r.has("packs"))return;let $=!0;return e.connection.call("packs/drafts",{scriptId:t.id}).then(F=>{$&&u(F.items)}).catch(()=>{}),()=>{$=!1}},[e,t.id,i.state,r,d]),b.useEffect(()=>{if(i.state!=="open"||!r.has("packs")||t.packId===void 0){k([]);return}let $=!0;return e.connection.call("packs/history",{packId:t.packId}).then(F=>{$&&k(F.items)}).catch(()=>{$&&k([])}),()=>{$=!1}},[e,t.packId,i.state,r,d]);const A=async $=>{g(!0),x(null);try{await $()}catch(F){x(Ie(F))}finally{g(!1)}},P=()=>A(async()=>{const{sessionId:$}=await e.connection.call("sessions/create",{focus:{scripts:[t.id]},role:"scripts"});await e.connection.call("session/prompt",{sessionId:$,requestId:`analyze-${Date.now()}`,mode:"queue",text:`请按 script-analysis 技能分析脚本库里的「${t.name}」(id: ${t.id}),${t.packId===void 0?"为它生成":"检查并改进它的"}脚本包:先找到并读完这个项目自己的文档(目录里的说明、仓库 README、Wiki、文档站),再结合代码核对补全,实在没有文档才直接看代码。写好给我看的使用说明(每个任务和参数是什么、每个功能怎么开启、配置文件怎么设置、运行前检查什么、常见问题),给 agent 的备注写进 SKILL.md。用 pack_propose 保存(直接生效),docs 里写明依据的文档。`}),n($)}),L=$=>A(async()=>{const{sessionId:F}=await e.connection.call("scripts/packReview",{id:t.id,decision:$});F!==void 0&&n(F)}),B=$=>A(async()=>{const{sessionId:F}=await e.connection.call("scripts/optimize",{id:t.id,decision:$});F!==void 0&&n(F)}),V=$=>A(async()=>{j(!1),await e.connection.call("packs/restore",{packId:t.packId,version:$.id}),j(!0)}),M=$=>`${$.builtin===!0?"内置脚本包":`${Et($.at??o,o)}被替换`} · 任务:${$.tasks.map(F=>F.title).join("、")||"无"}`,z=c[0],D=N[0],U=(I=t.optimize)==null?void 0:I.due;return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"脚本包"}),s.jsx("p",{className:"muted small",children:t.packId===void 0?"还没有脚本包:agent 还不知道怎么运行它。":`使用脚本包 ${t.packId}。`})]}),s.jsxs("span",{className:"key-actions",children:[t.packId!==void 0&&s.jsxs("button",{className:"small-button",disabled:m||i.state!=="open",onClick:()=>void B("run"),title:"用运行攒下的信息:重新总结脚本包、调「多久没动静算卡住」、把走通的步骤存成只给它用的技能",children:[s.jsx(J,{name:"sparkles"}),"优化脚本"]}),s.jsxs("button",{className:"small-button",disabled:m||i.state!=="open",onClick:()=>void P(),children:[s.jsx(J,{name:"sparkles"}),t.packId===void 0?"让 agent 分析":"让 agent 改进"]})]})]}),t.packReview!==void 0&&z===void 0&&s.jsxs("div",{className:"notice left pack-review",children:[s.jsx(J,{name:"refresh"}),s.jsxs("span",{children:[t.name," 从 ",t.packReview.from??"旧版本"," 更新到了 ",t.packReview.to,",脚本包是按旧版本写的。要让 agent 先读这次的更新日志,再检查脚本包要不要改吗?"]}),s.jsxs("span",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:m,onClick:()=>void L("keep"),children:"不用改"}),s.jsx("button",{className:"primary small-button",disabled:m||i.state!=="open",onClick:()=>void L("check"),children:"让 agent 检查"})]})]}),U!==void 0&&t.packReview===void 0&&z===void 0&&s.jsxs("div",{className:"notice left pack-review",children:[s.jsx(J,{name:"sparkles"}),s.jsxs("span",{children:[U==="updated"?`${t.name} 更新后已经跑通了。`:`${t.name} ${((T=t.optimize)==null?void 0:T.at)===void 0?"装好以来":"上次优化以来"}已经跑成功 ${((O=t.optimize)==null?void 0:O.runs)??0} 次。`,"要让 agent 用这些运行记录优化它吗:重新总结脚本包、调卡住时间、把走通的步骤存成技能。"]}),s.jsxs("span",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:m,onClick:()=>void B("keep"),children:"这次不用"}),s.jsx("button",{className:"primary small-button",disabled:m||i.state!=="open",onClick:()=>void B("run"),children:"优化脚本"})]})]}),D!==void 0&&s.jsxs("div",{className:"pack-history",children:[s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[D.builtin===!0?"现在用的是自己写的脚本包,可以换回":"上一版脚本包:",M(D)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:m||i.state!=="open",title:"现在用的这一版会留在历史里,可以再恢复回来",onClick:()=>void V(D),children:D.builtin===!0?"恢复内置的":"恢复上一版"})]}),N.length>1&&s.jsxs("details",{className:"draft-docs",children:[s.jsxs("summary",{className:"muted small",children:["更早的版本(",N.length-1,")"]}),s.jsx("ul",{children:N.slice(1).map($=>s.jsxs("li",{children:[M($)," ",s.jsx("button",{className:"link-button",disabled:m||i.state!=="open",onClick:()=>void V($),children:"恢复"})]},$.id))})]}),E&&s.jsx("p",{className:"muted small",children:"已恢复。刚才用的那一版留在历史里,可以再恢复回来。"})]}),z!==void 0&&s.jsxs("div",{className:"draft",children:[s.jsxs("div",{className:"draft-head",children:[s.jsx("span",{className:"badge warn",children:"待确认的草稿"}),s.jsxs("span",{className:"muted small",children:[Et(z.proposedAt,o),"提交 · 任务:",z.tasks.map($=>$.title).join("、")||"无"]})]}),s.jsx("p",{className:"draft-summary",children:z.summary}),z.docs!==void 0&&z.docs.length>0&&s.jsxs("details",{className:"draft-docs",children:[s.jsxs("summary",{className:"muted small",children:["依据的文档(",z.docs.length,")"]}),s.jsx("ul",{children:z.docs.map($=>s.jsxs("li",{children:[s.jsx("code",{children:$.source}),":",$.used]},$.source))})]}),z.noDocs!==void 0&&s.jsxs("p",{className:"muted small",children:["没有找到项目文档,按代码分析:",z.noDocs]}),z.current!==void 0&&s.jsxs("p",{className:"muted small",children:["接受后会替换当前的",z.current.builtin?"内置":"","脚本包(之前的版本会保留在历史里)。"]}),s.jsxs("div",{className:"segmented draft-tabs",children:[s.jsxs("label",{className:y==="manifest"?"active":"",children:[s.jsx("input",{type:"checkbox",checked:y==="manifest",onChange:()=>S($=>$==="manifest"?null:"manifest")}),"adg.script.yaml"]}),s.jsxs("label",{className:y==="skill"?"active":"",children:[s.jsx("input",{type:"checkbox",checked:y==="skill",onChange:()=>S($=>$==="skill"?null:"skill")}),"SKILL.md"]})]}),y!==null&&s.jsx("pre",{className:"draft-text",children:y==="manifest"?z.manifest:z.skill}),s.jsxs("div",{className:"key-actions",children:[z.sessionId!==void 0&&s.jsx("button",{className:"link-button",onClick:()=>n(z.sessionId),children:"查看分析过程"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:m,onClick:()=>void A(()=>e.connection.call("packs/reject",{packId:z.packId})),children:"拒绝"}),s.jsx("button",{className:"primary small-button",disabled:m,onClick:()=>void A(()=>e.connection.call("packs/accept",{packId:z.packId})),children:"接受并使用"})]})]}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:p})]})]})}function n9({client:e,script:t}){const n=we(e.connection.status),i=An(15e3),[r,o]=b.useState(void 0),[c,u]=b.useState(0),[d,h]=b.useState(30),[m,g]=b.useState(null);b.useEffect(()=>e.connection.on("guard/changed",()=>u(y=>y+1)),[e]),b.useEffect(()=>{if(n.state!=="open")return;let y=!0;return e.connection.call("guard/grants",{}).then(S=>{y&&o(S.items.find(N=>N.scriptId===t.id))}).catch(()=>{}),()=>{y=!1}},[e,t.id,n.state,c]);const p=r!==void 0&&r.expiresAt>i?r:void 0,x=y=>{g(null),y().catch(S=>g(Ie(S)))};return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"修改脚本文件"}),s.jsx("p",{className:"muted small",children:"默认禁止:agent 只能改脚本包声明的配置文件、只能用官方更新。确实需要改代码时,在这里临时允许。"})]}),p===void 0?s.jsx("span",{className:"badge ok",children:"受保护"}):s.jsx("span",{className:"badge warn",children:"已允许"})]}),p===void 0?s.jsxs("div",{className:"key-actions",children:[s.jsxs("label",{className:"check-label",children:["允许 agent 修改",s.jsx(Vt,{inline:!0,"aria-label":"允许多久",value:String(d),onChange:y=>h(Number(y)),options:[15,30,60,120].map(y=>({value:String(y),label:`${y} 分钟`}))})]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>x(()=>e.connection.call("guard/grant",{scriptId:t.id,minutes:d})),children:"临时允许"})]}):s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:["还剩约 ",Math.max(1,Math.round((p.expiresAt-i)/6e4))," 分钟"]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>x(()=>e.connection.call("guard/revoke",{scriptId:t.id})),children:"立即收回"})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:m})]})]})}function s9({client:e,script:t}){const n=we(e.connection.status),i=An(6e4),r=Yw(e,t.id),[o,c]=b.useState(void 0),[u,d]=b.useState(null),[h,m]=b.useState(0),[g,p]=b.useState(null),[x,y]=b.useState(null),[S,N]=b.useState(null),[k,E]=b.useState(!1),[j,A]=b.useState(null),[P,L]=b.useState(null),[B,V]=b.useState(null),M=(r==null?void 0:r.items.find($=>$.id===o))??(r==null?void 0:r.items.find($=>$.id===r.current));b.useEffect(()=>{p(null),N(null)},[M==null?void 0:M.id]),b.useEffect(()=>e.connection.on("runs/state",$=>{$.scriptId!==t.id||$.endedAt===void 0||(m(F=>F+1),V(F=>F===null||F.runId!==$.id?F:(A($.state==="succeeded"?`修改已同步到「${F.profile}」`:$.state==="cancelled"?"已放弃这次修改,本地配置没变":`没能保存修改:${$.outcome??"脚本窗口异常退出"}`),null)))}),[e,t.id]);const z=async $=>{if(B!==null){V({...B,finishing:$});try{$==="done"?await e.connection.call("configs/done",{runId:B.runId}):await e.connection.call("runs/stop",{runId:B.runId})}catch(F){L(Ie(F)),V(null)}}};b.useEffect(()=>{if(n.state!=="open"||M===void 0)return;let $=!0;return e.connection.call("configs/status",{scriptId:t.id,profile:M.id}).then(F=>{$&&(d(F),L(null))}).catch(F=>{$&&L(Ie(F))}),()=>{$=!1}},[e,t.id,t.packId,n.state,h,M==null?void 0:M.id]);const D=async $=>{E(!0),L(null),A(null);try{const F=await $();typeof F=="string"&&A(F),m(H=>H+1)}catch(F){L(Ie(F))}finally{E(!1)}},U=((r==null?void 0:r.items.length)??0)>1,I=M!==void 0&&M.id===(r==null?void 0:r.current),T=(u==null?void 0:u.files.filter($=>$.local))??[],O=u!==null&&u.profile.id===(M==null?void 0:M.id)?u:null;return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"配置"}),s.jsx("p",{className:"muted small",children:"通过本应用运行时,用的是本地保存的配置;原项目里的配置不会被改动,你自己打开脚本时仍是它原来的设置。可以存几份(比如两个账号),运行和编排时选用哪一份。"})]}),s.jsxs("button",{className:"small-button",disabled:k||B!==null||n.state!=="open"||M===void 0,onClick:()=>void D(async()=>{const $=await e.connection.call("configs/open",{scriptId:t.id,profile:M.id});if($.endedAt===void 0)V({runId:$.id,profile:M.name,finishing:null});else if($.state!=="succeeded")throw new Error($.outcome??"没能打开脚本的设置界面")}),children:[s.jsx(J,{name:"settings"}),"打开脚本修改设置"]})]}),r!==null&&(U||((u==null?void 0:u.files.length)??0)>0)&&s.jsxs("div",{className:"profile-bar",children:[s.jsxs("div",{className:"profile-chips",role:"tablist","aria-label":"配置",children:[r.items.map($=>s.jsxs("button",{role:"tab","aria-selected":$.id===(M==null?void 0:M.id),className:`profile-chip ${$.id===(M==null?void 0:M.id)?"active":""}`,onClick:()=>c($.id),children:[$.name,$.id===r.current&&U&&s.jsx("span",{className:"profile-current",title:"不指定配置的运行都用它",children:"当前使用"})]},$.id)),s.jsx("button",{className:"ghost small-button",disabled:k,onClick:()=>y($=>$===null?{name:"",source:"copy",dir:""}:null),children:"+ 另存一份"})]}),M!==void 0&&U&&S===null&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:I?"运行时没有指定配置就用这一份":"在编排或运行时选它才会用到"}),s.jsx("span",{className:"spacer"}),!I&&s.jsx("button",{className:"small-button",disabled:k,onClick:()=>void D(async()=>(await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:M.id,current:!0}),`现在默认使用「${M.name}」`)),children:"设为当前使用"}),s.jsx("button",{className:"ghost small-button",disabled:k,onClick:()=>N(M.name),children:"改名"}),M.id!=="default"&&(g==="remove"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"muted small",children:"用了这份配置的编排步骤会运行失败"}),s.jsx("button",{className:"small-button",onClick:()=>p(null),children:"取消"}),s.jsx("button",{className:"danger-outline small-button",disabled:k,onClick:()=>void D(async()=>(await e.connection.call("configs/profiles/remove",{scriptId:t.id,profile:M.id}),p(null),c(void 0),`已删除「${M.name}」`)),children:"确认删除"})]}):s.jsx("button",{className:"ghost small-button",disabled:k,onClick:()=>p("remove"),children:"删除"}))]}),M!==void 0&&S!==null&&s.jsxs("div",{className:"key-input",children:[s.jsx("input",{className:"text-input plain","aria-label":"新名字",value:S,maxLength:30,autoFocus:!0,onChange:$=>N($.target.value)}),s.jsx("button",{className:"small-button",onClick:()=>N(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:k||S.trim()==="",onClick:()=>void D(async()=>{await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:M.id,name:S.trim()}),N(null)}),children:"保存"})]}),x!==null&&M!==void 0&&s.jsxs("div",{className:"profile-save",children:[s.jsx("label",{className:"field-label",htmlFor:"profile-name",children:"新配置的名字"}),s.jsx("input",{id:"profile-name",className:"text-input plain",placeholder:"例如:小号、只清体力",value:x.name,maxLength:30,autoFocus:!0,onChange:$=>y({...x,name:$.target.value})}),s.jsxs("fieldset",{className:"asset-list",disabled:k,children:[s.jsx("legend",{className:"field-label",children:"内容从哪里来"}),[["copy",`复制「${M.name}」`,"复制后可以「打开脚本修改设置」单独改它"],["original","读取原项目现在的配置","在脚本自己的界面里设好了另一套设置时用"],["folder","从别的文件夹读取",`另一份同样的脚本,或存下来的配置;只读 ${(u==null?void 0:u.files.map($=>$.file).join("、"))||"脚本包声明的配置文件"}`]].map(([$,F,H])=>s.jsxs("label",{className:`asset-option choice-option ${x.source===$?"active":""}`,children:[s.jsx("input",{type:"radio",name:"profile-source",value:$,checked:x.source===$,onChange:()=>y({...x,source:$})}),s.jsxs("span",{className:"choice-text",children:[s.jsx("span",{children:F}),s.jsx("span",{className:"muted small",children:H})]})]},$))]}),x.source==="folder"&&s.jsx("input",{className:"text-input plain","aria-label":"文件夹",placeholder:"文件夹的完整路径,例如 D:\\MAA2",value:x.dir,onChange:$=>y({...x,dir:$.target.value})}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>y(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:k||x.name.trim()===""||x.source==="folder"&&x.dir.trim()==="",onClick:()=>void D(async()=>{const $=x.source==="copy"?{kind:"copy",profile:M.id}:x.source==="original"?{kind:"original"}:{kind:"folder",dir:x.dir.trim()},F=await e.connection.call("configs/profiles/create",{scriptId:t.id,name:x.name.trim(),from:$});return y(null),c(F.profile.id),`已保存「${F.profile.name}」:${F.files.length>0?F.files.join("、"):"还没有配置文件"}`}),children:"保存"})]})]})]}),O!==null&&s.jsxs(s.Fragment,{children:[O.drift.length>0&&s.jsxs("div",{className:"notice warn-box left",children:[s.jsx(J,{name:"info"}),s.jsxs("span",{children:["原项目的配置在导入后改过(",O.drift.join("、"),"),可能是在脚本自己的界面里改的。本应用仍按「",O.profile.name,"」运行;需要的话可以导入。"]})]}),s.jsx(Ia,{id:`config.files.${t.id}`,title:"配置文件",count:O.files.length,children:s.jsxs("ul",{className:"version-list",children:[O.files.map($=>s.jsx(i9,{client:e,scriptId:t.id,profile:O.profile.id,file:$},`${O.profile.id}:${$.file}`)),O.files.length===0&&s.jsx("li",{className:"muted small",children:"脚本包没有声明配置文件"})]})}),s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[O.importedAt===void 0?"还没有导入":`${Et(O.importedAt,i)}${U?`存的「${O.profile.name}」`:"从原项目导入"}`,T.length>0&&" · ",T.length>0&&s.jsx("button",{className:"link-button",onClick:()=>{var $;return void(($=navigator.clipboard)==null?void 0:$.writeText(O.dir))},children:"复制本地配置目录"})]}),s.jsx("span",{className:"spacer"}),g!=="import"?s.jsx("button",{className:"small-button",disabled:k,onClick:()=>p("import"),children:"导入原项目设置"}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted small",children:["会用原项目当前的配置覆盖「",O.profile.name,"」"]}),s.jsx("button",{className:"small-button",onClick:()=>p(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:k,onClick:()=>void D(async()=>{const $=await e.connection.call("configs/import",{scriptId:t.id,profile:O.profile.id});return p(null),$.imported.length>0?`已导入到「${O.profile.name}」:${$.imported.join("、")}`:"原项目里还没有这些配置文件"}),children:"确认导入"})]})]})]}),j!==null&&s.jsx("div",{className:"notice info left small",children:j}),B!==null&&s.jsx("div",{className:"dialog-backdrop",children:s.jsxs("div",{className:"dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"config-edit-title",children:[s.jsxs("h3",{id:"config-edit-title",children:[s.jsx(J,{name:"settings"}),"正在用脚本自己的界面修改设置"]}),s.jsxs("p",{children:[t.name," 的设置窗口已经打开,用的是本地配置「",B.profile,"」。在那个窗口里改好、保存后,回到这里点「我已手动改好」:脚本窗口会关闭,修改同步到「",B.profile,"」,之后的运行和编排都用它。"]}),s.jsx("p",{className:"muted small",children:"直接关掉脚本窗口也会保存。原项目里的配置不会被改动。"}),B.finishing!==null&&s.jsxs("p",{className:"dialog-progress",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),B.finishing==="done"?"正在关闭脚本窗口并保存修改…":"正在关闭脚本窗口,不保存…"]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:B.finishing!==null,onClick:()=>void z("discard"),children:"放弃修改"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:B.finishing!==null,onClick:()=>void z("done"),children:B.finishing==="done"?"保存中…":"我已手动改好"})]})]})}),P!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:P})]})]})}function i9({client:e,scriptId:t,profile:n,file:i}){const[r,o]=b.useState(!1),[c,u]=b.useState(null),[d,h]=b.useState(null),m=()=>{o(g=>!g),!(c!==null||!i.local)&&e.connection.call("configs/read",{scriptId:t,file:i.file,profile:n}).then(u,g=>h(Ie(g)))};return s.jsxs("li",{className:`config-file ${r?"open":""}`,children:[s.jsxs("button",{type:"button",className:"config-file-head","aria-expanded":r,onClick:m,disabled:!i.local,title:i.local?"展开看本地配置的内容":"本地还没有这个文件",children:[s.jsx(J,{name:"chevron",className:`fold-chevron ${r?"open":""}`}),s.jsx("span",{className:"version-name",children:i.file}),i.local?s.jsx("span",{className:"badge ok",children:"本地已保存"}):s.jsx("span",{className:"badge",children:"本地没有"}),i.changed&&s.jsx("span",{className:"badge warn",children:"原项目已改动"}),!i.original&&s.jsx("span",{className:"muted small",children:"原项目里没有"})]}),r&&(d!==null?s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:d})]}):c===null?s.jsx("div",{className:"muted small",children:"读取中…"}):s.jsxs("pre",{className:"config-preview",children:[c.content,c.truncated?`
234
+ …(太长,只显示前一部分)`:""]}))]})}function r9({client:e,scriptId:t,scriptName:n,openSession:i}){const r=we(e.connection.status),[o,c]=b.useState(null),[u,d]=b.useState(""),[h,m]=b.useState(""),[g,p]=b.useState(""),[x,y]=b.useState(!1),[S,N]=b.useState(null),[k,E]=b.useState(!1),[j,A]=b.useState(null),[P,L]=b.useState(!1);b.useEffect(()=>{if(r.state!=="open")return;let O=!0;return e.connection.call("configs/launch",{scriptId:t}).then($=>{O&&(c($),d($.settings.pcExe??""),m($.settings.pcProcess??""),p($.settings.androidPackage??""))}).catch($=>{O&&N(Ie($))}),()=>{O=!1}},[e,t,r.state]);const B=async O=>{y(!0),N(null),E(!1);try{c(await e.connection.call("configs/launch/set",{scriptId:t,...O})),E(!0)}catch($){N(Ie($))}finally{y(!1)}},V=async O=>{d(O),await B({pcExe:O})},M=async()=>{L(!0),N(null),E(!1),A(null);try{const O=await e.connection.call("configs/launch/locate",{scriptId:t});A(O),O.candidates.length===1&&await V(O.candidates[0].path)}catch(O){N(Ie(O))}finally{L(!1)}},z=async()=>{N(null);try{const{sessionId:O}=await e.connection.call("sessions/create",{focus:{scripts:[t]}});await e.connection.call("session/prompt",{sessionId:O,requestId:`locate-${Date.now()}`,mode:"queue",text:`帮我找到「${n}」(脚本 id: ${t})要玩的 PC 游戏${(o==null?void 0:o.game.name)===void 0?"":`「${o.game.name}」`}装在哪里:先用 game_locate;没找到就在各个磁盘上搜索名为 ${(j==null?void 0:j.exe)??(o==null?void 0:o.game.pcProcess)??"游戏进程名"} 的程序(可以问我装在哪个盘)。找到后告诉我路径和你怎么确认的,再用 game_path_set 保存。`}),i(O)}catch(O){N(Ie(O))}},D=async()=>{const O=wi();if(O===void 0)return;const $=await O.pickFile({title:"选择游戏程序",defaultPath:u.trim()===""?void 0:u.trim(),filterName:"程序",extensions:["exe"]});$!==null&&await V($)};if(o===null)return S===null?null:s.jsx("section",{className:"card",children:s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:S})]})});const{settings:U,game:I,uses:T}=o;return!T.adb&&!T.desktop?null:s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsxs("h3",{children:["启动游戏",I.name===void 0?"":`:${I.name}`]}),s.jsxs("p",{className:"muted small",children:["有的脚本不会自己打开游戏或模拟器。运行前,本应用会先启动模拟器(模拟器任务),再按这里的设置启动游戏;游戏已经开着、或脚本自己会启动时不会重复启动。",I.selfLaunch,"。"]})]})}),s.jsx("label",{className:"field-label",htmlFor:`launch-mode-${t}`,children:"运行前由谁启动游戏"}),s.jsx(Vt,{id:`launch-mode-${t}`,value:U.mode,disabled:x,onChange:O=>void B({mode:O}),options:[{value:"auto",label:"自动(推荐)",hint:"脚本自己不会启动游戏时,由本应用启动"},{value:"platform",label:"总是由本应用启动",hint:"游戏没开时先打开它"},{value:"off",label:"不启动",hint:"交给脚本或我自己"}]}),U.mode!=="off"&&T.adb&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:`launch-pkg-${t}`,children:"模拟器里的游戏包名(模拟器任务)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-pkg-${t}`,className:"text-input plain",value:g,onChange:O=>p(O.target.value),placeholder:I.androidPackage??"例如 com.example.game(不填就不在模拟器里启动游戏)",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:x,onClick:()=>void B({androidPackage:g.trim()===""?null:g.trim()}),children:"保存"})]}),I.androidPackage!==void 0&&s.jsxs("p",{className:"muted small",children:["默认 ",I.androidPackage,";B 服、国际服等版本的包名不同时在这里改。"]})]}),U.mode!=="off"&&T.desktop&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:`launch-exe-${t}`,children:"PC 游戏程序位置(占用鼠标键盘的任务)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-exe-${t}`,className:"text-input",value:u,onChange:O=>d(O.target.value),placeholder:"例如 D:\\Games\\Endfield\\Endfield.exe(也可以是游戏启动器)",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:x,onClick:()=>void B({pcExe:u.trim()===""?null:u.trim().replace(/^"|"$/g,"")}),children:"保存"})]}),s.jsxs("div",{className:"button-row",children:[s.jsx("button",{className:"small-button",disabled:x||P,onClick:()=>void M(),children:P?"正在查找…":"自动查找"}),wi()!==void 0&&s.jsx("button",{className:"small-button",disabled:x||P,onClick:()=>void D(),children:"选择文件…"}),s.jsx("button",{className:"link-button small",disabled:P,onClick:()=>void z(),children:"让 agent 找"})]}),j!==null&&j.exe===void 0&&s.jsx("p",{className:"muted small",children:"脚本包没有写游戏的进程名:先在下面填进程名,或用「选择文件…」/ 让 agent 找。"}),j!==null&&j.exe!==void 0&&j.candidates.length===0&&s.jsxs("p",{className:"muted small",children:["没找到 ",j.exe,"(查了正在运行的程序、已安装程序、开始菜单和桌面快捷方式、各盘的常见游戏目录)。可以「选择文件…」,或「让 agent 找」在整个磁盘上搜。"]}),j!==null&&j.candidates.length===1&&s.jsxs("p",{className:"muted small",children:["找到并保存了:",j.candidates[0].path,"(",j.candidates[0].source,")"]}),j!==null&&j.candidates.length>1&&s.jsxs("div",{className:"candidate-list",children:[s.jsxs("span",{className:"muted small",children:["找到 ",j.candidates.length," 个,选一个:"]}),j.candidates.map(O=>s.jsxs("button",{className:`candidate ${U.pcExe===O.path?"chosen":""}`,disabled:x,onClick:()=>void V(O.path),children:[s.jsx("span",{className:"mono",children:O.path}),s.jsx("span",{className:"muted small",children:O.source})]},O.path))]}),s.jsx("label",{className:"field-label",htmlFor:`launch-proc-${t}`,children:"游戏进程名(判断游戏是否已经开着)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-proc-${t}`,className:"text-input",value:h,onChange:O=>m(O.target.value),placeholder:I.pcProcess??"默认是上面程序的文件名",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:x,onClick:()=>void B({pcProcess:h.trim()===""?null:h.trim()}),children:"保存"})]}),s.jsx("p",{className:"muted small",children:"填的是启动器时,进程名要填游戏本身的(在任务管理器「详细信息」里看)。"})]}),k&&s.jsx("div",{className:"muted small",children:"已保存,下次运行生效。"}),S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:S})]})]})}const a9=15*6e4;function o9({client:e,script:t,openSession:n}){const i=An(3e4),[r,o]=b.useState(!1),[c,u]=b.useState(null),d=t.summary,h=(d==null?void 0:d.state)==="running"&&i-d.at<a9,m=(d==null?void 0:d.state)==="failed"||d==null?void 0:d.text,g=async()=>{o(!0),u(null);try{await e.connection.call("scripts/summarize",{id:t.id})}catch(p){u(Ie(p))}finally{o(!1)}};return s.jsxs("section",{className:"card script-summary",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"简介"}),s.jsx("p",{className:"muted small",children:h?"agent 正在看它的说明和文件…":d===void 0?"让 AI 看看它的说明(README)、文件和脚本包,用几句话说清楚它是什么、能做什么。":d.state==="failed"||d.state==="running"?"上次总结没有完成":`AI 总结 · ${Et(d.at,i)}`})]}),s.jsxs("div",{className:"key-actions",children:[(d==null?void 0:d.sessionId)!==void 0&&s.jsx("button",{className:"ghost small-button",onClick:()=>n(d.sessionId),children:h?"看看进度":"查看对话"}),s.jsxs("button",{className:`${d===void 0?"primary ":""}small-button`,disabled:r||h,onClick:()=>void g(),children:[s.jsx(J,{name:"sparkles"}),h?"总结中…":d===void 0?"让 AI 总结":"重新总结"]})]})]}),m!==void 0&&s.jsx("p",{className:`summary-text ${h?"muted":""}`,children:m}),(d==null?void 0:d.state)==="failed"&&d.text!==void 0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:d.text})]}),c!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:c})]})]})}const l9={desktop:"占用鼠标键盘",adb:"用模拟器,不占鼠标",window:"后台操作游戏窗口",none:"不占用"};function c9(e){const t=/^(\d+)(s|m|h)$/.exec(e);return t===null?e:`约 ${t[1]} ${t[2]==="s"?"秒":t[2]==="m"?"分钟":"小时"}`}function Zp({items:e}){const t=e.filter(n=>n[1]!==void 0&&n[1]!=="");return t.length===0?null:s.jsx("div",{className:"guide-facts muted small",children:t.map(([n,i])=>s.jsxs("span",{children:[n,":",i]},n))})}function u9({client:e,script:t}){const n=we(e.connection.status),[i,r]=b.useState(void 0),[o,c]=b.useState(null),[u,d]=b.useState(0),[h,m]=b.useState("tasks");if(b.useEffect(()=>e.connection.on("packs/changed",()=>d(y=>y+1)),[e]),b.useEffect(()=>{if(n.state!=="open"||t.packId===void 0)return;let y=!0;return e.connection.call("scripts/guide",{id:t.id}).then(S=>{y&&(r(S.guide),c(null))}).catch(S=>{y&&c(Ie(S))}),()=>{y=!1}},[e,t.id,t.packId,n.state,u]),t.packId===void 0||i===null)return null;const p=(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(([,,y])=>y),x=p.some(([y])=>y===h)?h:"tasks";return s.jsxs("section",{className:"card script-guide",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"使用说明"}),s.jsx("p",{className:"muted small",children:i===void 0?"读取中…":i.written?`脚本包 ${i.packId} 的说明${i.builtin?"(内置)":""}`:"这个脚本包还没有写使用说明,下面只有任务和运行时的临时修改;可以在「脚本包」里点「让 agent 改进」补上。"})]})}),o!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:o})]}),i!==void 0&&s.jsxs(s.Fragment,{children:[i.overview!==void 0&&s.jsx("p",{className:"guide-overview",children:i.overview}),p.length>1&&s.jsx("div",{className:"segmented guide-tabs",role:"tablist",children:p.map(([y,S])=>s.jsxs("label",{className:x===y?"active":"",children:[s.jsx("input",{type:"radio",name:`guide-${t.id}`,checked:x===y,onChange:()=>m(y)}),S]},y))}),x==="tasks"&&s.jsx(d9,{guide:i}),x==="features"&&s.jsx(h9,{guide:i}),x==="config"&&s.jsx(f9,{guide:i}),x==="before"&&s.jsx(m9,{guide:i}),x==="problems"&&s.jsx(p9,{guide:i})]})]})}function d9({guide:e}){return e.tasks.length===0?s.jsx("p",{className:"muted small",children:"脚本包没有声明任务。"}):s.jsx("ul",{className:"guide-list",children:e.tasks.map(t=>s.jsxs("li",{children:[s.jsxs("div",{className:"guide-item-head",children:[s.jsx("strong",{children:t.title}),s.jsx("span",{className:"chip",children:t.id}),s.jsx("span",{className:"badge",children:l9[t.input]}),t.expectedDuration!==void 0&&s.jsx("span",{className:"muted small",children:c9(t.expectedDuration)})]}),t.description!==void 0&&s.jsx("p",{children:t.description}),t.utterances.length>0&&s.jsxs("p",{className:"muted small",children:["可以这样说:",t.utterances.map(n=>`「${n}」`).join("")]}),t.params.length===0?s.jsx("p",{className:"muted small",children:"没有参数。"}):s.jsx("dl",{className:"guide-keys",children:t.params.map(n=>s.jsxs("div",{children:[s.jsx("dt",{children:s.jsx("code",{children:n.name})}),s.jsxs("dd",{children:[s.jsx("span",{children:n.description??"(没有说明)"}),s.jsx(Zp,{items:[["可选值",n.values],["默认",n.default??(n.values===void 0?"无,运行时必须填":void 0)]]})]})]},n.name))})]},t.id))})}function h9({guide:e}){return s.jsx("ul",{className:"guide-list",children:e.features.map(t=>s.jsxs("li",{children:[s.jsxs("div",{className:"guide-item-head",children:[s.jsx("strong",{children:t.title}),t.tasks.length>0&&s.jsxs("span",{className:"muted small",children:["任务:",t.tasks.join("、")]})]}),t.description!==void 0&&s.jsx("p",{children:t.description}),s.jsxs("p",{children:[s.jsx("span",{className:"guide-label",children:"怎么开启"}),t.enable]}),t.config.length>0&&s.jsx("div",{className:"guide-facts muted small",children:t.config.map(n=>s.jsxs("span",{children:["配置:",s.jsx("code",{children:n.file})," 里 ",s.jsx("code",{children:n.key})," 设为 ",s.jsx("code",{children:n.value})]},`${n.file}:${n.key}`))})]},t.title))})}function f9({guide:e}){return s.jsx("div",{className:"guide-files",children:e.config.map(t=>s.jsxs("div",{className:"guide-file",children:[s.jsx("div",{className:"guide-item-head",children:s.jsx("code",{className:"guide-file-name",children:t.file})}),t.about!==void 0&&s.jsx("p",{children:t.about}),t.keys.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"field-label",children:"重要的键"}),s.jsx("dl",{className:"guide-keys",children:t.keys.map(n=>s.jsxs("div",{children:[s.jsx("dt",{children:s.jsx("code",{children:n.key})}),s.jsxs("dd",{children:[s.jsx("span",{children:n.meaning}),s.jsx(Zp,{items:[["取值",n.values],["默认",n.default]]}),n.advice!==void 0&&s.jsxs("span",{className:"guide-advice",children:["建议:",n.advice]})]})]},n.key))})]}),t.changes.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"field-label",children:"运行时本应用临时修改的键(只改本应用用的那份配置,运行结束后还原)"}),s.jsx("dl",{className:"guide-keys",children:t.changes.map(n=>s.jsxs("div",{children:[s.jsx("dt",{children:s.jsx("code",{children:n.key})}),s.jsxs("dd",{children:[s.jsxs("span",{children:["设为 ",s.jsx("code",{children:n.value}),n.note===void 0?"":`:${n.note}`]}),s.jsx(Zp,{items:[["条件",n.when],["任务",n.tasks.join("、")]]})]})]},`${n.key}=${n.value}:${n.when??""}`))})]})]},t.file))})}function m9({guide:e}){return s.jsxs("div",{className:"guide-before",children:[e.setup.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"field-label",children:"第一次使用前"}),s.jsx("ol",{className:"guide-steps",children:e.setup.map((t,n)=>s.jsx("li",{children:t},n))})]}),e.checks.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"field-label",children:"每次运行前检查"}),s.jsx("ul",{className:"guide-steps checks",children:e.checks.map((t,n)=>s.jsx("li",{children:t},n))})]})]})}function p9({guide:e}){return s.jsx("ul",{className:"guide-list",children:e.troubleshooting.map((t,n)=>s.jsxs("li",{children:[s.jsx("strong",{children:t.problem}),t.cause!==void 0&&s.jsxs("p",{children:[s.jsx("span",{className:"guide-label",children:"原因"}),t.cause]}),s.jsxs("p",{children:[s.jsx("span",{className:"guide-label",children:"怎么办"}),t.fix]})]},n))})}const g9={nsis:"NSIS",inno:"Inno Setup",kachina:"Kachina"};function eE({client:e,setup:t,openSession:n,onImported:i}){const[r,o]=b.useState(t.dir),[c,u]=b.useState(!1),[d,h]=b.useState(null),[m,g]=b.useState(null),[p,x]=b.useState(!1),y=t.agent,S=async(N,k)=>{h(N),g(null);try{await k()}catch(E){g(Ie(E))}finally{h(null)}};return s.jsxs("section",{className:"card setup-card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsxs("h3",{children:[t.update?"更新":"安装"," ",t.name," ",t.version]}),s.jsxs("p",{className:"muted small",children:["下载到的是 ",g9[t.kind]," 安装程序,不是压缩包:要运行它把文件装好,再导入装好的文件夹。"]})]})}),(y==null?void 0:y.state)==="running"&&s.jsxs("div",{className:"notice left",children:[s.jsx(J,{name:"info"}),s.jsx("span",{children:"agent 正在安装。也可以不等它,按下面的步骤自己装。"}),s.jsx("button",{className:"link-button",onClick:()=>n(y.sessionId),children:"查看对话"})]}),(y==null?void 0:y.state)==="failed"&&s.jsxs("div",{className:"notice warn-box left",children:[s.jsx(J,{name:"alert"}),s.jsxs("span",{children:["agent 没能装好:",y.reason??"原因不明","。可以按下面的步骤自己装,也可以之后再交给 agent。"]}),s.jsx("button",{className:"link-button",onClick:()=>n(y.sessionId),children:"查看对话"})]}),s.jsxs("ol",{className:"setup-steps",children:[s.jsx("li",{children:s.jsxs("div",{className:"setup-step",children:[s.jsx("span",{children:"打开安装程序,按它的提示装完。安装位置已经填好,保持不变;最后不用勾选「立即运行」。"}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void S("open",async()=>{await e.connection.call("scripts/setup/open",{id:t.scriptId}),u(!0)}),children:d==="open"?"正在打开…":c?"再打开一次":"打开安装程序"})]})}),s.jsx("li",{children:s.jsxs("div",{className:"setup-step",children:[s.jsxs("span",{children:["装好后导入装好的文件夹。",t.update?"":"改了安装位置的话,填你选的文件夹。"]}),s.jsxs("form",{className:"setup-import",onSubmit:N=>{N.preventDefault(),S("import",async()=>{const k=await e.connection.call("scripts/import",{path:r.trim().replace(/^"|"$/g,""),id:t.scriptId});i(k.id)})},children:[s.jsx("input",{className:"text-input plain","aria-label":"装好的文件夹",value:r,onChange:N=>o(N.target.value),spellCheck:!1,disabled:d!==null}),s.jsx("button",{className:"primary small-button",type:"submit",disabled:d!==null||r.trim()==="",children:d==="import"?"导入中…":"装好了,导入"})]})]})})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:m})]}),s.jsx("div",{className:"key-actions",children:p?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"muted small",children:"删除下载好的安装程序,什么都不装。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>x(!1),children:"取消"}),s.jsx("button",{className:"danger small-button",disabled:d!==null,onClick:()=>void S("discard",async()=>{await e.connection.call("scripts/setup/discard",{id:t.scriptId})}),children:"确认删除"})]}):s.jsxs(s.Fragment,{children:[(y==null?void 0:y.state)!=="running"&&s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void S("agent",async()=>{const{sessionId:N}=await e.connection.call("scripts/setup/agent",{id:t.scriptId});n(N)}),children:d==="agent"?"正在交给 agent…":"让 agent 安装"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",disabled:d!==null,onClick:()=>x(!0),children:"不装了"})]})})]})}const x9={ok:["ok","满足"],missing:["warn","缺少"],outdated:["warn","版本过旧"],unknown:["warn","无法判断"],unsupported:["","暂不检测"]};function v9({client:e,script:t,job:n,setup:i,onRemoved:r,openSession:o}){var L;const c=An(6e4),[u,d]=b.useState(null),[h,m]=b.useState(null),[g,p]=b.useState(null),[x,y]=b.useState(!1),[S,N]=b.useState(!1),k=n!==void 0&&(n.endedAt===void 0||n.startedAt>=t.addedAt-1e3)?n:void 0,E=Na(k),j=we(e.capabilities),A=t.source.kind!=="local",P=async(B,V)=>{d(B),m(null),p(null);try{const M=await V();typeof M=="string"&&p(M)}catch(M){m(Ie(M))}finally{d(null)}};return s.jsxs("div",{className:"script-detail",children:[s.jsx("header",{className:"script-detail-head",children:s.jsxs("div",{children:[s.jsx("h2",{children:t.name}),s.jsxs("div",{className:"script-meta",children:[s.jsx("span",{className:"chip",children:t.id}),t.family!==void 0&&s.jsx("span",{className:"badge",children:fj[t.family]??t.family}),t.packId!==void 0?s.jsxs("span",{className:"badge ok",children:["脚本包 ",t.packId]}):s.jsx("span",{className:"badge warn",children:"无脚本包"}),t.channels.mirrorchyan!==void 0&&s.jsxs("span",{className:"badge",title:"填了 Mirror酱 CDK 后从 Mirror酱 更新(增量)",children:["Mirror酱 ",t.channels.mirrorchyan.rid]}),s.jsx("span",{className:"muted small",children:t.source.kind==="github"?`GitHub · ${t.source.repo}`:t.source.kind==="mirrorchyan"?`Mirror酱 · ${t.source.rid}`:"本地导入"})]})]})}),k!==void 0&&s.jsx(Hp,{client:e,job:k}),i!==void 0&&s.jsx(eE,{client:e,setup:i,openSession:o,onImported:()=>{}}),t.dir!==void 0&&s.jsx(o9,{client:e,script:t,openSession:o}),t.packId!==void 0&&s.jsx(u9,{client:e,script:t},`guide:${t.id}`),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"位置与版本"}),s.jsx("p",{className:"muted small",children:t.dir??"(无)"})]}),t.dir!==void 0&&s.jsxs("button",{className:"ghost small-button",onClick:()=>{var B;return void((B=navigator.clipboard)==null?void 0:B.writeText(t.dir))},children:[s.jsx(J,{name:"copy"}),"复制路径"]})]}),A?s.jsxs(s.Fragment,{children:[s.jsx("ul",{className:"version-list",children:t.versions.map(B=>{var V;return s.jsxs("li",{className:B.current?"current":"",children:[s.jsx("span",{className:"version-name",children:B.version}),B.current&&s.jsx("span",{className:"badge ok",children:"当前"}),s.jsxs("span",{className:"muted small",children:[((V=B.asset)==null?void 0:V.name)??""," · ",Et(B.installedAt,c)]}),s.jsx("span",{className:"spacer"}),!B.current&&s.jsx("button",{className:"small-button",disabled:E||u!==null,onClick:()=>void P("rollback",async()=>(await e.connection.call("scripts/rollback",{id:t.id,version:B.version}),`已切换到 ${B.version}`)),children:"切换到此版本"})]},B.version)})}),s.jsx("dl",{className:"local-facts channel-facts",children:s.jsx(J_,{client:e,script:t,disabled:E||u!==null,act:P})}),s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[t.update===void 0?"还没有检查过更新":t.update.available?`有新版本 ${t.update.latest}`:`已是最新(${t.update.latest})`,t.update!==void 0&&` · ${Et(t.update.checkedAt,c)}检查`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:E||u!==null,onClick:()=>void P("check",async()=>{const B=await e.connection.call("scripts/checkUpdate",{id:t.id});return B.available?`发现新版本 ${B.latest}`:"已是最新版本"}),children:u==="check"?"检查中…":"检查更新"}),s.jsx("button",{className:"primary small-button",disabled:E||u!==null||((L=t.update)==null?void 0:L.available)!==!0,onClick:()=>void P("update",async()=>(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0),children:"更新"})]})]}):s.jsx(e9,{client:e,script:t,disabled:E||u!==null,busy:u,now:c,act:P})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"运行环境"}),s.jsx("p",{className:"muted small",children:t.env===void 0?t.packId===void 0?"没有脚本包,暂时不知道它需要什么":"还没有检查":`${Et(t.env.checkedAt,c)}检查`})]}),s.jsx("button",{className:"small-button",disabled:E||u!==null,onClick:()=>void P("env",async()=>(await e.connection.call("scripts/envCheck",{id:t.id})).ok?"运行环境满足":"有依赖需要处理"),children:u==="env"?"检查中…":"重新检查"})]}),t.env!==void 0&&t.env.items.length===0&&s.jsx("div",{className:"muted small",children:"脚本包没有声明额外依赖。"}),t.env!==void 0&&t.env.items.length>0&&s.jsx("ul",{className:"env-list",children:t.env.items.map(B=>{const[V,M]=x9[B.status];return s.jsxs("li",{children:[s.jsxs("div",{className:"env-main",children:[s.jsx("span",{className:"env-label",children:B.label}),s.jsx("span",{className:`badge ${V}`,children:M}),B.found!==void 0&&s.jsx("span",{className:"muted small",children:B.found})]}),B.detail!==void 0&&s.jsx("div",{className:"muted small",children:B.detail}),B.fix!==void 0&&s.jsxs("div",{className:"env-fix",children:[s.jsx("span",{className:"muted small",children:B.fix.description}),B.fix.kind!=="manual"&&s.jsx("button",{className:"small-button",disabled:E||u!==null,onClick:()=>void P(`fix-${B.kind}`,async()=>{await e.connection.call("scripts/envFix",{id:t.id,kind:B.kind})}),children:B.fix.kind==="installer"?"安装(需要管理员)":"自动修复"})]})]},B.kind)})})]}),j.has("runs")&&t.dir!==void 0&&s.jsx(dD,{client:e,scriptId:t.id,packId:t.packId}),j.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&s.jsx(s9,{client:e,script:t}),j.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&s.jsx(r9,{client:e,scriptId:t.id,scriptName:t.name,openSession:o},t.id),j.has("packs")&&s.jsx(t9,{client:e,script:t,openSession:o}),t.probe!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"目录概况"}),s.jsx("p",{className:"muted small",children:t.packId===void 0?"只是快速看一眼;启动方式、任务和配置的完整分析请用上面的「让 agent 分析」。":"导入时快速看到的文件;脚本怎么运行以脚本包为准。"})]})}),s.jsxs("div",{className:"probe-grid",children:[s.jsx("span",{className:"field-label",children:"可执行文件"}),s.jsx("div",{className:"chip-row",children:t.probe.executables.length===0?s.jsx("span",{className:"muted small",children:"未发现"}):t.probe.executables.map(B=>s.jsx("span",{className:"chip",children:B},B))}),s.jsx("span",{className:"field-label",children:"标志文件"}),s.jsx("div",{className:"chip-row",children:t.probe.markers.length===0?s.jsx("span",{className:"muted small",children:"未发现"}):t.probe.markers.map(B=>s.jsx("span",{className:"chip",children:B},B))})]})]}),j.has("guard")&&s.jsx(n9,{client:e,script:t}),s.jsx("section",{className:"card danger-zone",children:x?s.jsxs("div",{className:"key-actions",children:[A&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:S,onChange:B=>N(B.target.checked)}),"同时删除所有已安装版本"]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>y(!1),children:"取消"}),s.jsx("button",{className:"danger small-button",disabled:u!==null,onClick:()=>void P("remove",async()=>{await e.connection.call("scripts/remove",{id:t.id,deleteFiles:A&&S}),r()}),children:"确认移除"})]}):s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:A?"从脚本库移除;可选择同时删除已安装的文件。":"从脚本库移除;你的目录不会被删除。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",disabled:E,onClick:()=>y(!0),children:"移除"})]})}),g!==null&&s.jsx("div",{className:"notice info",children:g}),h!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:h})]})]})}function y9({client:e,openSession:t,arg:n}){const{data:i,error:r}=Ld(e),o=hj(e),[c,u]=b.useState(null),[d,h]=b.useState(null);b.useEffect(()=>{(n==null?void 0:n.startsWith("mirror:"))===!0&&h({kind:"mirror",rid:n.slice(7)})},[n]);const m=(i==null?void 0:i.scripts)??[],g=((i==null?void 0:i.packs)??[]).filter(j=>!j.installed&&j.repo!==void 0&&j.error===void 0),p=((i==null?void 0:i.packs)??[]).filter(j=>j.error!==void 0),x=((i==null?void 0:i.known)??[]).filter(j=>!j.installed),y=(i==null?void 0:i.setups)??[],S=y.filter(j=>!m.some(A=>A.id===j.scriptId)),N=d===null?S.find(j=>j.scriptId===c):void 0,k=c===null||m.some(j=>j.id===c)||N!==void 0?void 0:o.get(c),E=m.find(j=>j.id===c)??(d===null&&k===void 0&&N===void 0?m[0]:void 0);return s.jsxs("section",{className:"main scripts-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"脚本"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"脚本库"})]}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>h({kind:"import"}),children:[s.jsx(J,{name:"paperclip"}),"导入本地项目"]}),s.jsxs("button",{className:"small-button",onClick:()=>h({kind:"mirror"}),children:[s.jsx(J,{name:"plus"}),"从 Mirror酱 安装"]}),s.jsxs("button",{className:"primary small-button",onClick:()=>h({kind:"install"}),children:[s.jsx(J,{name:"plus"}),"从 GitHub 安装"]})]})]}),s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"脚本列表",children:[r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:r})]}),i===null&&r===null&&s.jsx("div",{className:"muted small pad",children:"加载中…"}),i!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sidebar-label",children:["我的脚本(",m.length,")"]}),m.length===0&&![...o.values()].some(Na)&&s.jsxs("div",{className:"sidebar-empty",children:[s.jsx(J,{name:"package"}),s.jsx("span",{children:"还没有脚本"}),s.jsx("span",{children:"从下面的脚本包安装,或导入已有目录"})]}),m.map(j=>{var L,B;const A=o.get(j.id),P=((L=j.env)==null?void 0:L.items.filter(V=>V.status!=="ok"&&V.status!=="unsupported").length)??0;return s.jsxs("button",{className:`script-row ${j.id===(E==null?void 0:E.id)&&d===null?"active":""}`,onClick:()=>{u(j.id),h(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:j.name}),s.jsxs("span",{className:"muted small",children:[j.source.kind==="local"?"本地":j.current??"未安装",j.family===void 0?"":` · ${fj[j.family]??j.family}`]})]}),Na(A)?s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):y.some(V=>V.scriptId===j.id)?s.jsx("span",{className:"badge warn",children:"待安装"}):((B=j.update)==null?void 0:B.available)===!0?s.jsx("span",{className:"badge ok",children:"可更新"}):P>0?s.jsxs("span",{className:"badge warn",children:["环境 ",P]}):null]},j.id)}),S.length>0&&s.jsxs("div",{className:"sidebar-label",children:["等待安装(",S.length,")"]}),S.map(j=>{var A,P,L;return s.jsxs("button",{className:`script-row ${j===N?"active":""}`,onClick:()=>{u(j.scriptId),h(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:j.name}),s.jsxs("span",{className:"muted small",children:[j.version," · ",((A=j.agent)==null?void 0:A.state)==="running"?"agent 正在安装":((P=j.agent)==null?void 0:P.state)==="failed"?"agent 没能装好":"安装程序已下载"]})]}),((L=j.agent)==null?void 0:L.state)==="running"?s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):s.jsx("span",{className:"badge warn",children:"待安装"})]},j.scriptId)}),[...o.values()].filter(j=>Na(j)&&!m.some(A=>A.id===j.scriptId)).map(j=>s.jsxs("button",{className:`script-row ${c===j.scriptId&&d===null?"active":""}`,onClick:()=>{u(j.scriptId),h(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:j.scriptId}),s.jsxs("span",{className:"muted small",children:["正在安装 · ",ic[j.phase],j.total!==void 0&&j.received!==void 0&&j.total>0?` ${Math.floor(j.received/j.total*100)}%`:""]})]}),s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"})]},j.id)),(g.length>0||x.length>0)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label pack-label",children:"可安装的脚本包"}),g.map(j=>s.jsxs("div",{className:"pack-row",children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:j.name}),s.jsx("span",{className:"muted small",children:j.description??j.repo})]}),s.jsx("button",{className:"small-button",onClick:()=>h({kind:"install",repo:j.repo}),children:"安装"})]},j.id)),x.map(j=>s.jsxs("div",{className:"pack-row",children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:j.name}),s.jsx("span",{className:"muted small",children:[j.mirrorchyan===void 0?void 0:`Mirror酱 ${j.mirrorchyan}`,j.repo].filter(Boolean).join(" · ")})]}),s.jsx("button",{className:"small-button",onClick:()=>h(j.mirrorchyan!==void 0?{kind:"mirror",rid:j.mirrorchyan}:{kind:"install",repo:j.repo}),children:"安装"})]},j.id))]}),p.length>0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(J,{name:"alert"}),s.jsxs("span",{children:[p.length," 个脚本包无法读取:",p.map(j=>j.id).join("、")]})]})]})]}),s.jsxs("div",{className:"scripts-detail",children:[(d==null?void 0:d.kind)==="install"&&s.jsx(VH,{client:e,jobs:o,...d.repo===void 0?{}:{initialRepo:d.repo},onClose:()=>h(null),onDone:j=>{u(j),h(null)},openSession:t},d.repo??"blank"),(d==null?void 0:d.kind)==="mirror"&&s.jsx(qH,{client:e,jobs:o,...d.rid===void 0?{}:{initialRid:d.rid},onClose:()=>h(null),onDone:j=>{u(j),h(null)},openSession:t,onGitHub:j=>h({kind:"install",repo:j})},d.rid??"blank"),(d==null?void 0:d.kind)==="import"&&s.jsx(QH,{client:e,onClose:()=>h(null),onImported:j=>{u(j),h(null)}}),d===null&&E!==void 0&&s.jsx(v9,{client:e,script:E,job:o.get(E.id),setup:y.find(j=>j.scriptId===E.id),onRemoved:()=>u(null),openSession:t},E.id),N!==void 0&&s.jsx(eE,{client:e,setup:N,openSession:t,onImported:j=>u(j)},N.scriptId),d===null&&E===void 0&&k!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:k.scriptId}),s.jsx("p",{className:"muted small",children:Na(k)?"正在安装,装好后这里显示脚本的详情":"安装没有完成"})]})}),s.jsx(Hp,{client:e,job:k})]}),d===null&&E===void 0&&k===void 0&&N===void 0&&i!==null&&s.jsxs("div",{className:"empty",children:[[...o.values()].filter(j=>Na(j)&&!m.some(A=>A.id===j.scriptId)).map(j=>s.jsxs("div",{className:"pending-install",children:[s.jsx("strong",{children:j.scriptId}),s.jsx(Hp,{client:e,job:j})]},j.id)),s.jsx("p",{children:"选择左侧的脚本查看详情,或安装一个新脚本。"})]}),i!==null&&s.jsxs("p",{className:"tools-dir muted small",children:["工具目录:",i.toolsDir]})]})]})]})}const b9={id:"scripts",title:"脚本库",milestone:"M1",requires:["scripts"],pages:[{id:"scripts",title:"脚本",icon:"package",order:10,agent:"scripts",component:y9}],settingsPages:[{id:"script-install",title:"脚本安装",order:10,component:WH}]},k9={id:"emulators",title:"模拟器",milestone:"M2",requires:["emulators"],settingsPages:[{id:"emulators",title:"模拟器",order:11,component:ZH}]},$m="https://github.com/haaahhhis/MultiGameAssistant";function N9({client:e}){const[t,n]=b.useState(void 0),i=Wj(e),r=t===null?i===void 0?void 0:i===!1?null:i.version:null;b.useEffect(()=>{var d;const c=(d=wi())==null?void 0:d.appInfo;if(c===void 0){n(null);return}let u=!0;return c().then(h=>{u&&n(h)},()=>{u&&n(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 s.jsxs("div",{className:"settings-page about-page",children:[s.jsx("h2",{children:"关于"}),s.jsx("p",{children:"MultiGameAssistant(多游戏助手):让 agent 替你管好各个游戏的日常脚本。"}),s.jsx("section",{className:"card about-card",children:s.jsxs("dl",{className:"about-facts",children:[s.jsx("dt",{children:"版本"}),s.jsx("dd",{children:o}),s.jsx("dt",{children:"源代码"}),s.jsx("dd",{children:s.jsx("a",{href:$m,target:"_blank",rel:"noreferrer",children:$m.replace("https://","")})}),s.jsx("dt",{children:"许可证"}),s.jsx("dd",{children:s.jsx("a",{href:`${$m}/blob/main/LICENSE`,target:"_blank",rel:"noreferrer",children:"GNU AGPL-3.0-only"})})]})}),(t==null?void 0:t.fromSource)===!0?s.jsxs("section",{className:"card about-card",children:[s.jsx("h3",{children:"更新"}),s.jsx("p",{className:"muted",children:"从源码运行:在项目目录 git pull 后重新构建(pnpm install、pnpm build)。"})]}):t!=null?s.jsx(j9,{}):typeof r=="string"&&s.jsx(w9,{client:e}),s.jsxs("section",{className:"card about-card",children:[s.jsx("h3",{children:"许可证"}),s.jsx("p",{children:"Copyright (C) 2026 MultiGameAssistant contributors"}),s.jsx("p",{children:"本程序是自由软件:你可以按自由软件基金会发布的 GNU Affero 通用公共许可证第 3 版(AGPL-3.0-only)再分发和修改它。分发修改后的版本,或让别人通过网络使用修改后的版本时,要以同样的许可证提供它的完整源代码。"}),s.jsx("p",{children:"发布本程序是希望它有用,但不提供任何担保,也没有适销性或特定用途适用性的默示担保。详见许可证全文。"}),s.jsx("p",{className:"muted small",children:"附带的第三方组件(Electron、DeepSeek Harness 等)遵循各自的许可证,许可证文件在程序的安装目录里。本程序安装和调度的游戏脚本是各自独立的项目,不属于本程序。"})]})]})}function j9(){const{bridge:e,state:t}=kg();if(e===void 0||t===null)return null;const n=t==null?void 0:t.latest,i=t===void 0?"…":t.checking?"正在检查…":t.error!==void 0?t.error:n!==void 0?`有新版本 ${n.version}${n.prerelease?"(预发布版)":""}${n.version===t.skipped?",已跳过":""}`:t.checkedAt!==void 0?`已经是最新版本(${new Date(t.checkedAt).toLocaleString()} 检查)`:"还没有检查过";return s.jsxs("section",{className:"card about-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"更新"}),s.jsx("p",{className:(t==null?void 0:t.error)!==void 0&&!t.checking?"error small":"muted small",children:i})]}),s.jsxs("button",{className:"small-button",disabled:t===void 0||t.checking,onClick:()=>void e.check(),children:[s.jsx(J,{name:"refresh"}),"检查更新"]})]}),n!==void 0&&s.jsx("div",{className:"about-release-notes",children:s.jsx(Ng,{notes:n.notes??[],notesUrl:n.notesUrl})}),t!==void 0&&s.jsx(jg,{bridge:e,state:t}),t!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.auto,onChange:r=>void e.setAuto(r.target.checked)}),"自动检查更新(启动后和每隔几小时,从 GitHub Releases;",/-/.test(t.current)?"预发布版也会收到更新的预发布版":"只提示正式版",")"]})]})}function w9({client:e}){var r;const t=Vj(e,!0),n=(r=t.result)==null?void 0:r.latest,i=t.checking?"正在检查…":t.error!==void 0?t.error:n!==void 0?`有新版本 ${n.version}${n.prerelease?"(预发布版)":""}`:t.result!==void 0?`已经是最新版本(${new Date(t.result.checkedAt).toLocaleString()} 检查)`:"还没有检查过";return s.jsxs("section",{className:"card about-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"更新"}),s.jsx("p",{className:t.error!==void 0&&!t.checking?"error small":"muted small",children:i})]}),s.jsxs("button",{className:"small-button",disabled:t.checking,onClick:t.check,children:[s.jsx(J,{name:"refresh"}),"检查更新"]})]}),n!==void 0&&!t.checking&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"about-release-notes",children:s.jsx(Ng,{notes:n.notes??[],notesUrl:n.notesUrl})}),s.jsx(Yj,{version:n.version,onNpm:n.onNpm})]})]})}const Wl=e=>e.replace(/\/+$/,""),Fk=e=>{const t=Wl(e);return t.endsWith("/v1")?t.slice(0,-3):t},tE=[{id:"openai-completions",title:"OpenAI 兼容",subtitle:"Chat Completions",hint:"绝大多数第三方网关和本地服务都用这种:OneAPI / NewAPI、OpenRouter、硅基流动、vLLM、Ollama、LM Studio 等。",placeholder:"https://api.example.com/v1",requestPath:e=>`${Wl(e)}/chat/completions`,listPath:e=>`${Wl(e)}/models`},{id:"openai-responses",title:"OpenAI Responses",subtitle:"Responses API",hint:"OpenAI 的新一代接口,支持推理摘要等能力;仅在服务方明确支持 /responses 时使用。",placeholder:"https://api.openai.com/v1",requestPath:e=>`${Wl(e)}/responses`,listPath:e=>`${Wl(e)}/models`},{id:"anthropic-messages",title:"Anthropic 兼容",subtitle:"Messages API",hint:"Claude 官方接口以及兼容 Anthropic 格式的网关。地址写到域名即可,末尾的 /v1 可有可无。",placeholder:"https://api.anthropic.com",requestPath:e=>`${Fk(e)}/v1/messages`,listPath:e=>`${Fk(e)}/v1/models`}];function Wp(e){return tE.find(t=>t.id===e)}function S9(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,40)}function _9(e){return`${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}_API_KEY`}const E9=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function C9(e){try{const{protocol:t}=new URL(e);return t==="http:"||t==="https:"}catch{return!1}}function jo(e){return e===void 0?null:e%1048576===0?`${e/1048576}M`:e>=1e6?`${+(e/1e6).toFixed(1)}M`:e%1024===0?`${e/1024}K`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function A9({client:e,profile:t,preset:n,taken:i,revision:r,readOnly:o,onDone:c}){var re;const u=t===void 0,d=n===void 0||n.id===""?"":i.includes(n.id)?`${n.id}-2`:n.id,[h,m]=b.useState(()=>{var ee;return((ee=Wp((t==null?void 0:t.api)??(n==null?void 0:n.api)))==null?void 0:ee.id)??"openai-completions"}),[g,p]=b.useState((t==null?void 0:t.displayName)??((n==null?void 0:n.baseURL)===""?"":(n==null?void 0:n.name)??"")),[x,y]=b.useState((t==null?void 0:t.id)??d),[S,N]=b.useState(!u||d!==""),[k,E]=b.useState((t==null?void 0:t.baseURL)??(n==null?void 0:n.baseURL)??""),[j,A]=b.useState(""),[P,L]=b.useState((t==null?void 0:t.models)??[]),[B,V]=b.useState(!1),[M,z]=b.useState(null),D=Wp(h),U=k.trim(),I=U!==""&&!C9(U),T=x!==""&&!E9.test(x),O=u&&i.includes(x),$=sE(j),F=(t==null?void 0:t.apiKeyRef)??(x===""?null:_9(x)),H=((re=t==null?void 0:t.credential)==null?void 0:re.configured)===!0,Z=(t==null?void 0:t.credential)!==void 0&&!t.credential.writable,G=x===""?"请填写标识":T?"标识格式不正确":O?"这个标识已被占用":U===""?"请填写 Base URL":I?"Base URL 需要以 http:// 或 https:// 开头":$!==null?$:P.length===0?"至少需要一个模型:点击「拉取模型列表」或手动添加":null,q=ee=>{p(ee),S||y(S9(ee))},X=async()=>{if(G===null){V(!0),z(null);try{await e.saveProvider({id:x,create:u,...g.trim()===""?{}:{displayName:g.trim()},api:h,baseURL:U,models:[...P],...j.trim()===""?{}:{apiKey:j.trim()},expectedRevision:r}),c()}catch(ee){const se=ee instanceof Error?ee.message:String(ee);z(/SETTINGS_CONFLICT|conflict/i.test(se)?"配置在别处被修改过了,请返回列表后重试。":se)}finally{V(!1)}}},Y=B||o;return s.jsxs("form",{className:"provider-editor",onSubmit:ee=>{ee.preventDefault(),X()},children:[s.jsxs("div",{className:"page-head",children:[s.jsx("h3",{children:u?n!==void 0&&n.baseURL!==""?`添加 ${n.name}`:"添加模型服务":`编辑「${t.displayName}」`}),s.jsx("button",{type:"button",className:"ghost",onClick:c,disabled:B,children:"返回"})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{className:"field-title",children:"接口模式"}),s.jsx("div",{className:"mode-grid",role:"radiogroup","aria-label":"接口模式",children:tE.map(ee=>s.jsxs("button",{type:"button",role:"radio","aria-checked":h===ee.id,"aria-label":`${ee.title}(${ee.subtitle})`,className:`mode-option${h===ee.id?" selected":""}`,onClick:()=>m(ee.id),disabled:Y,children:[s.jsx("span",{className:"mode-title",children:ee.title}),s.jsx("span",{className:"mode-subtitle",children:ee.subtitle})]},ee.id))}),s.jsx("div",{className:"muted small",children:D.hint})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"名称"}),s.jsx("input",{className:"text-input plain",value:g,onChange:ee=>q(ee.target.value),placeholder:"例如:我的中转站",disabled:Y})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"标识"}),s.jsx("input",{className:"text-input",value:x,onChange:ee=>{y(ee.target.value.trim()),N(!0)},placeholder:"my-gateway",disabled:Y||!u,spellCheck:!1})]})]}),s.jsx("div",{className:T||O?"error small":"muted small",children:T?"标识只能用小写字母、数字和单个连字符,并以字母开头。":O?"这个标识已被占用(可能是已有的提供方或 dsh 内置提供方)。":u?"用于区分提供方,保存后不能修改。":"标识创建后不能修改。"}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"Base URL"}),s.jsx("input",{className:"text-input",value:k,onChange:ee=>E(ee.target.value),placeholder:D.placeholder,disabled:Y,spellCheck:!1})]}),I?s.jsx("div",{className:"error small",children:"Base URL 需要以 http:// 或 https:// 开头。"}):U!==""&&s.jsxs("div",{className:"muted small endpoint-preview",children:["对话请求 ",s.jsxs("code",{children:["POST ",D.requestPath(U)]}),s.jsx("br",{}),"模型列表 ",s.jsxs("code",{children:["GET ",D.listPath(U)]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"API Key"}),s.jsx("input",{className:"text-input",type:"password",value:j,onChange:ee=>A(ee.target.value),placeholder:Z?"由启动环境变量提供,无法在此修改":H?"已配置,留空则保持不变":"粘贴 Key;本地服务不需要时可留空",autoComplete:"new-password",disabled:Y||Z,spellCheck:!1})]}),$!==null?s.jsx("div",{className:"error small",children:$}):F!==null&&s.jsxs("div",{className:"muted small",children:["保存在 dsh 凭据 ",s.jsx("code",{children:F})," 中,界面不会再显示 Key 的内容。",(n==null?void 0:n.keyUrl)!==void 0&&s.jsxs(s.Fragment,{children:[" ",s.jsx("a",{href:n.keyUrl,target:"_blank",rel:"noopener noreferrer",children:"获取 Key ↗"})]})]}),(n==null?void 0:n.vision)!==void 0&&s.jsxs("div",{className:"muted small",children:["截图诊断、读游戏信息需要能看图的模型:",n.vision,"。"]})]}),s.jsx(I9,{client:e,models:P,onChange:L,probe:{...t===void 0?{}:{provider:t.id},api:h,baseURL:U,apiKey:j.trim()},probeBlocked:U===""?"先填写 Base URL":I?"Base URL 无效":$,disabled:Y}),M!==null&&s.jsx("div",{className:"banner error",children:M}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:G}),s.jsx("span",{className:"spacer"}),s.jsx("button",{type:"button",onClick:c,disabled:B,children:"取消"}),s.jsx("button",{type:"submit",className:"primary",disabled:Y||G!==null,children:B?"保存中…":u?"创建":"保存"})]})]})}function I9({client:e,models:t,onChange:n,probe:i,probeBlocked:r,disabled:o}){const[c,u]=b.useState(null),[d,h]=b.useState(""),[m,g]=b.useState(""),[p,x]=b.useState(!1),[y,S]=b.useState(null),N=b.useRef(null),k=b.useMemo(()=>new Set(t.map(M=>M.id)),[t]),E=async()=>{var z;(z=N.current)==null||z.abort();const M=new AbortController;N.current=M,x(!0),S(null);try{const D=await e.discoverModels({...i.provider===void 0?{}:{provider:i.provider},api:i.api,baseURL:i.baseURL,...i.apiKey===""?{}:{apiKey:i.apiKey}},M.signal);if(M.signal.aborted)return;u([...D].sort((U,I)=>U.id.localeCompare(I.id))),D.length===0&&S("接口返回了空的模型列表,可以手动添加模型 ID。")}catch(D){M.signal.aborted||S(D instanceof Error?D.message:String(D))}finally{N.current===M&&(N.current=null,x(!1))}},j=M=>{n(k.has(M.id)?t.filter(z=>z.id!==M.id):[...t,M])},A=M=>{n(t.map(z=>{if(z.id!==M)return z;if(z.efforts!==void 0&&z.efforts.length>0){const{efforts:D,...U}=z;return U}return{...z,efforts:["off","low","medium","high"]}}))},P=M=>{n(t.map(z=>{var D;return z.id!==M?z:{...z,input:((D=z.input)==null?void 0:D.includes("image"))===!0?["text"]:["text","image"]}}))},L=b.useMemo(()=>{const M=d.trim().toLowerCase();return(c??[]).filter(z=>M===""||z.id.toLowerCase().includes(M)||(z.name??"").toLowerCase().includes(M))},[c,d]),B=M=>{if(M){const z=L.filter(D=>!k.has(D.id));n([...t,...z])}else{const z=new Set(L.map(D=>D.id));n(t.filter(D=>!z.has(D.id)))}},V=()=>{const M=m.split(/[\s,,]+/).map(z=>z.trim()).filter(z=>z!==""&&!k.has(z));M.length!==0&&(n([...t,...M.map(z=>(c==null?void 0:c.find(D=>D.id===z))??{id:z})]),g(""))};return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"模型"}),s.jsxs("div",{className:"muted small",children:["已选 ",t.length," 个。只有选中的模型会出现在模型选择器里。能看图的模型点亮「图片」,否则 dsh 会拒绝发送图片;支持调思考强度的模型(如 GPT-5、o 系列、Claude、DeepSeek R 系列)点亮「思考」,对话里就能选强度。"]})]}),s.jsx("button",{type:"button",onClick:()=>void E(),disabled:o||p||r!==null,title:r??void 0,children:p?"拉取中…":c===null?"拉取模型列表":"重新拉取"})]}),y!==null&&s.jsx("div",{className:"error small",children:y}),t.length>0&&s.jsx("div",{className:"model-chips",children:t.map(M=>{var z,D,U,I,T,O;return s.jsxs("span",{className:"chip removable",children:[M.id,jo(M.contextWindow)!==null&&s.jsxs("span",{className:"muted",children:[" · ",jo(M.contextWindow)]}),s.jsx("button",{type:"button",className:`chip-flag${((z=M.input)==null?void 0:z.includes("image"))===!0?" on":""}`,onClick:()=>P(M.id),disabled:o,"aria-pressed":((D=M.input)==null?void 0:D.includes("image"))===!0,title:((U=M.input)==null?void 0:U.includes("image"))===!0?"支持图片输入(点击关闭)":"不支持图片输入(点击开启)",children:"图片"}),s.jsx("button",{type:"button",className:`chip-flag${(((I=M.efforts)==null?void 0:I.length)??0)>0?" on":""}`,onClick:()=>A(M.id),disabled:o,"aria-pressed":(((T=M.efforts)==null?void 0:T.length)??0)>0,title:(((O=M.efforts)==null?void 0:O.length)??0)>0?`可选思考强度:${M.efforts.join(" / ")}(点击关闭)`:"没有声明思考强度(点击开启:不思考 / 低 / 中 / 高)",children:"思考"}),s.jsx("button",{type:"button",className:"chip-x",onClick:()=>n(t.filter($=>$.id!==M.id)),disabled:o,"aria-label":`移除 ${M.id}`,children:"×"})]},M.id)})}),c!==null&&c.length>0&&s.jsxs("div",{className:"candidates",children:[s.jsxs("div",{className:"candidates-bar",children:[s.jsx("input",{className:"text-input plain",value:d,onChange:M=>h(M.target.value),placeholder:`搜索 ${c.length} 个模型`}),s.jsxs("button",{type:"button",className:"small-button",onClick:()=>B(!0),disabled:o,children:["全选",d!==""?"筛选结果":""]}),s.jsx("button",{type:"button",className:"small-button",onClick:()=>B(!1),disabled:o,children:"全不选"})]}),s.jsxs("ul",{className:"candidate-list",children:[L.map(M=>{var z;return s.jsx("li",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:k.has(M.id),onChange:()=>j(M),disabled:o}),s.jsx("span",{className:"mono",children:M.id}),M.name!==void 0&&s.jsxs("span",{className:"muted",children:[" ",M.name]}),s.jsx("span",{className:"spacer"}),((z=M.input)==null?void 0:z.includes("image"))===!0&&s.jsx("span",{className:"badge",children:"图像"}),jo(M.contextWindow)!==null&&s.jsxs("span",{className:"muted small",children:[jo(M.contextWindow)," 上下文"]})]})},M.id)}),L.length===0&&s.jsx("li",{className:"muted small",children:"没有匹配的模型。"})]})]}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{className:"text-input plain-mono",value:m,onChange:M=>g(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),V())},placeholder:"手动添加模型 ID,多个用空格或逗号分隔",disabled:o,spellCheck:!1}),s.jsx("button",{type:"button",onClick:V,disabled:o||m.trim()==="",children:"添加"})]})]})}const T9=[{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:""}],Mm=[{id:"deepseek-official",name:"DeepSeek",note:"内置,只需要填 Key",keyRef:Qm,keyUrl:"https://platform.deepseek.com/api_keys"}];function $9({client:e}){const{catalog:t}=Ba(e),[n,i]=b.useState(!1),[r,o]=b.useState(void 0),c=we(e.providersRevision),u=we(e.credentialRevision),d=we(e.connection.status),[h,m]=b.useState(null),[g,p]=b.useState(null),[x,y]=b.useState(null),[S,N]=b.useState(null),k=b.useCallback(()=>{e.listProviders().then(j=>{m(j),p(null)}).catch(j=>p(j instanceof Error?j.message:String(j)))},[e]);if(b.useEffect(()=>{d.state==="open"&&k()},[k,c,u,d.state]),x!==null&&h!==null){const j=x==="new"?void 0:h.providers.find(A=>A.id===x);return s.jsx("section",{className:"providers-section",children:s.jsx(A9,{client:e,profile:j,preset:x==="new"?r:void 0,taken:h.taken,revision:h.revision,readOnly:!h.writable,onDone:()=>{y(null),o(void 0),k()}},x)})}if(n)return s.jsxs("section",{className:"providers-section",children:[s.jsxs("div",{className:"page-head",children:[s.jsx("h3",{children:"添加模型服务"}),s.jsx("button",{className:"ghost",onClick:()=>i(!1),children:"返回"})]}),s.jsxs("div",{className:"preset-grid",children:[Mm.map(j=>s.jsxs("button",{className:"preset-option",onClick:()=>{var A;i(!1),(A=document.getElementById(`builtin-${j.id}`))==null||A.scrollIntoView({behavior:"smooth"})},children:[s.jsx("span",{className:"mode-title",children:j.name}),s.jsx("span",{className:"mode-subtitle",children:j.note})]},j.id)),T9.map(j=>s.jsxs("button",{className:"preset-option",disabled:h===null||!h.writable,onClick:()=>{o(j),i(!1),y("new")},children:[s.jsx("span",{className:"mode-title",children:j.name}),s.jsx("span",{className:"mode-subtitle",children:j.note})]},j.key))]})]});const E=new Set((h==null?void 0:h.providers.map(j=>j.id))??[]);return s.jsxs("section",{className:"providers-section",children:[s.jsxs("div",{className:"page-head",children:[s.jsx("h3",{children:"模型服务"}),s.jsx("button",{className:"primary",onClick:()=>i(!0),disabled:h===null,children:"+ 添加模型服务"})]}),s.jsx("p",{className:"muted",children:"每个服务填一次 Key,它的模型就会出现在输入框旁的模型选择器里。Claude、ChatGPT、Gemini、国内各家和本机的 Ollama 都可以接;需要看截图的功能请选能看图的模型。Key 保存在本机 dsh 的凭据文件里,界面不会再显示。"}),Mm.map(j=>s.jsx(O9,{client:e,provider:j,catalog:t},j.id)),t==null?void 0:t.groups.filter(j=>!E.has(j.id)&&!Mm.some(A=>A.id===j.id)).map(j=>s.jsxs("section",{className:"card provider-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:j.name}),s.jsx("div",{className:"muted small",children:s.jsx("code",{children:j.id})})]}),s.jsx("span",{className:"badge",children:"内置"})]}),s.jsx("div",{className:"model-chips",children:j.models.map(A=>s.jsx("span",{className:"chip",children:A.name},A.id))})]},j.id)),g!==null&&s.jsx("div",{className:"banner error",children:g}),S!==null&&s.jsx("div",{className:"success small",children:S}),h!==null&&!h.writable&&s.jsx("div",{className:"notice info left",children:"当前 profile 是只读的,无法在界面中修改提供方。"}),h===null&&g===null&&s.jsx("div",{className:"muted small",children:"读取中…"}),h==null?void 0:h.providers.map(j=>s.jsx(M9,{client:e,profile:j,revision:h.revision,readOnly:!h.writable,onEdit:()=>y(j.id),onRemoved:A=>{N(A?"已删除。它原本是新会话的默认模型,默认模型已恢复为 profile 自带的设置。":null),k()}},j.id))]})}function M9({client:e,profile:t,revision:n,readOnly:i,onEdit:r,onRemoved:o}){const[c,u]=b.useState(!1),[d,h]=b.useState(null),m=Wp(t.api),g=async()=>{var x,y;const p=t.apiKeyRef!==void 0&&((x=t.credential)==null?void 0:x.source)==="file"?`
235
+
236
+ 同时删除已保存的 Key(${t.apiKeyRef})。`:"";if(await Os({title:`删除「${t.displayName}」?`,message:`使用它的会话需要换一个模型。${p}`,confirmLabel:"删除",danger:!0})){u(!0),h(null);try{const{defaultReset:S}=await e.removeProvider({id:t.id,removeKey:((y=t.credential)==null?void 0:y.source)==="file",expectedRevision:n});o(S)}catch(S){h(S instanceof Error?S.message:String(S))}finally{u(!1)}}};return s.jsxs("section",{className:"card provider-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:t.displayName}),s.jsxs("div",{className:"muted small",children:[s.jsx("code",{children:t.id}),t.baseURL!==void 0&&s.jsxs(s.Fragment,{children:[" · ",s.jsx("span",{className:"mono",children:t.baseURL})]})]})]}),s.jsxs("div",{className:"badges",children:[s.jsx("span",{className:"badge",children:m===void 0?t.api??"内置目录":`${m.title} · ${m.subtitle}`}),s.jsx(R9,{profile:t}),t.active?s.jsx("span",{className:"badge ok",children:"已生效"}):s.jsx("span",{className:"badge warn",title:t.error,children:"未生效"})]})]}),t.error!==void 0&&s.jsx("div",{className:"error small",children:t.error}),t.models.length>0?s.jsx("div",{className:"model-chips",children:t.models.map(p=>s.jsxs("span",{className:"chip",title:p.name??p.id,children:[p.id,jo(p.contextWindow)!==null&&s.jsxs("span",{className:"muted",children:[" · ",jo(p.contextWindow)]})]},p.id))}):s.jsx("div",{className:"muted small",children:"使用 dsh 内置的模型目录。"}),d!==null&&s.jsx("div",{className:"error small",children:d}),s.jsxs("div",{className:"key-actions",children:[!t.declared&&s.jsx("span",{className:"muted small",children:"这是 dsh 内置提供方的配置,请在 dsh 官方模型页面编辑。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline",onClick:()=>void g(),disabled:c||i,children:"删除"}),t.declared&&s.jsx("button",{onClick:r,disabled:c||i,children:"编辑"})]})]})}function R9({profile:e}){return e.apiKeyRef===void 0?s.jsx("span",{className:"badge",children:"无 Key"}):e.credential===void 0?s.jsxs("span",{className:"badge",children:["Key:",e.apiKeyRef]}):e.credential.configured?s.jsx("span",{className:"badge ok",title:e.apiKeyRef,children:"Key 已配置"}):s.jsx("span",{className:"badge warn",title:e.apiKeyRef,children:"Key 未配置"})}function O9({client:e,provider:t,catalog:n}){const{items:i}=dj(e,[t.keyRef]),r=(i==null?void 0:i[t.keyRef])??null,o=n==null?void 0:n.groups.find(u=>u.id===t.id),c=n==null?void 0:n.failures.find(u=>u.id===t.id);return s.jsxs("section",{className:"card provider-card",id:`builtin-${t.id}`,children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:t.name}),s.jsxs("div",{className:"muted small",children:[s.jsx("code",{children:t.id})," · ",t.note]})]}),s.jsxs("div",{className:"badges",children:[s.jsx("span",{className:"badge",children:"内置"}),r===null?null:r.configured?s.jsx("span",{className:"badge ok",children:"Key 已配置"}):s.jsx("span",{className:"badge warn",children:"Key 未配置"})]})]}),o!==void 0&&o.models.length>0&&s.jsx("div",{className:"model-chips",children:o.models.map(u=>s.jsx("span",{className:"chip",title:u.description,children:u.name},u.id))}),c!==void 0&&s.jsx("div",{className:"error small",children:c.message}),s.jsx(z9,{client:e,refName:t.keyRef,title:`${t.name} API Key`,description:"",helpUrl:t.keyUrl,info:r,bare:!0})]})}const nE={file:"dsh 凭据文件",env:"启动环境变量","project-env":"项目 .env 文件","user-env":"dsh 主目录 .env 文件"};function sE(e){const t=e.trim();return e.length>0&&t.length===0?"API Key 不能只包含空白字符。":t===""?null:/^[A-Z][A-Z0-9_]*=[^=]/.test(t)?'看起来粘贴了 "名称=值" 的整行,请只粘贴 Key 本身。':/^(["'`]).+\1$/.test(t)?"请去掉 Key 两侧的引号。":/^[\x21-\x7E]+$/.test(t)?null:"API Key 只能包含可见的 ASCII 字符,不能有空格或中文。"}function P9({client:e}){const t=we(e.capabilities);return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"模型"}),s.jsx("p",{className:"muted",children:"agent 用哪个模型、接哪些模型服务都在这里。保存后立即生效;新对话和飞书对话默认用下面选的模型,软件自己开的会话(干预、游戏等)可以另选一个;每个对话也可以在输入框旁边单独换。"}),s.jsx(D9,{client:e}),t.has("role-model")&&s.jsx(F9,{client:e}),t.has("providers")&&s.jsx($9,{client:e})]})}function z9({client:e,refName:t,title:n,description:i,helpUrl:r,info:o,placeholder:c,bare:u=!1}){const[d,h]=b.useState(""),[m,g]=b.useState(!1),[p,x]=b.useState(!1),[y,S]=b.useState(null),N=sE(d),k=o!==null&&!o.writable,E=async()=>{if(!(d.trim()===""||N!==null)){x(!0),S(null);try{await e.setCredential(t,d.trim()),h(""),g(!1),S({tone:"ok",text:"已保存,立即生效。"})}catch(P){S({tone:"error",text:P instanceof Error?P.message:String(P)})}finally{x(!1)}}},j=async()=>{if(await Os({title:`删除已保存的 ${n}?`,message:"删除后需要重新填写才能使用对应模型。",confirmLabel:"删除",danger:!0})){x(!0),S(null);try{await e.unsetCredential(t),S({tone:"ok",text:"已删除。"})}catch(P){S({tone:"error",text:P instanceof Error?P.message:String(P)})}finally{x(!1)}}},A=u?"div":"section";return s.jsxs(A,{className:u?"credential-inline":"card",children:[!u&&s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:n}),s.jsxs("div",{className:"muted small",children:[i," ",s.jsx("code",{children:t})]})]}),s.jsx(L9,{info:o})]}),k?s.jsxs("div",{className:"notice info left",children:["当前 Key 来自",nE[o.source??""]??o.source,",优先级高于界面保存的值,因此这里无法修改。 如需在界面中管理,请先从启动 dsh 的环境中移除 ",s.jsx("code",{children:t})," 再重新启动。"]}):s.jsxs("form",{className:"key-form",onSubmit:P=>{P.preventDefault(),E()},children:[s.jsxs("div",{className:"key-input",children:[s.jsx("input",{type:m?"text":"password",value:d,onChange:P=>{h(P.target.value),S(null)},placeholder:(o==null?void 0:o.configured)===!0?"已配置。输入新的 Key 可替换":c??"粘贴你的 API Key(sk-…)",autoComplete:"off",spellCheck:!1,"aria-label":n,disabled:p}),s.jsx("button",{type:"button",className:"ghost",onClick:()=>g(P=>!P),disabled:d==="",children:m?"隐藏":"显示"})]}),N!==null&&s.jsx("div",{className:"error small",children:N}),s.jsxs("div",{className:"key-actions",children:[r!==void 0&&s.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"small",children:"获取 API Key ↗"}),s.jsx("span",{className:"spacer"}),(o==null?void 0:o.configured)===!0&&o.source==="file"&&s.jsx("button",{type:"button",className:"danger-outline",onClick:()=>void j(),disabled:p,children:"删除"}),s.jsx("button",{type:"submit",className:"primary",disabled:p||d.trim()===""||N!==null,children:p?"保存中…":(o==null?void 0:o.configured)===!0?"替换":"保存"})]})]}),y!==null&&s.jsx("div",{className:y.tone==="ok"?"success small":"error small",children:y.text})]})}function L9({info:e}){return e===null?s.jsx("span",{className:"badge",children:"读取中…"}):e.configured?s.jsxs("span",{className:"badge ok",children:["已配置 · ",nE[e.source??""]??e.source??"未知来源"]}):s.jsx("span",{className:"badge warn",children:"未配置"})}function D9({client:e}){const{catalog:t,error:n}=Ba(e),i=we(e.capabilities),[r,o]=b.useState(!1),[c,u]=b.useState(null),d=t===null?"":`${t.default.provider}/${t.default.model}`,h=async g=>{const[p,...x]=g.split("/");o(!0),u(null);try{await e.connection.call("models/setDefault",{provider:p,model:x.join("/")}),u("已设为默认,新对话会用它。")}catch(y){u(y instanceof Error?y.message:String(y))}finally{o(!1)}},m=(t==null?void 0:t.groups.some(g=>g.models.some(p=>`${g.id}/${p.id}`===d)))??!1;return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"默认模型"}),s.jsx("p",{className:"muted small",children:"先在下面的模型服务里填好 Key,这里就能选它的模型。"})]})}),n!==null&&s.jsx("div",{className:"error small",children:n}),t===null&&n===null&&s.jsx("div",{className:"muted small",children:"读取中…"}),t!==null&&s.jsx(Vt,{"aria-label":"默认模型",value:d,disabled:r||!i.has("model-default"),onChange:g=>void h(g),options:[...m?[]:[{value:d,label:`${t.default.provider} / ${t.default.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...t.groups.flatMap(g=>g.models.map(p=>({value:`${g.id}/${p.id}`,label:p.name,group:g.name})))]}),t==null?void 0:t.failures.map(g=>s.jsxs("div",{className:"error small",children:[g.name,":",g.message]},g.id)),c!==null&&s.jsx("div",{className:"muted small",children:c})]})}function F9({client:e}){const{catalog:t}=Ba(e),n=we(e.connection.status),[i,r]=b.useState(void 0),[o,c]=b.useState(!1),[u,d]=b.useState(null);b.useEffect(()=>{if(n.state!=="open")return;let p=!0;return e.connection.call("models/roleModel",{}).then(x=>{p&&r(x.model)}).catch(()=>{}),()=>{p=!1}},[e,n.state]);const h=i==null?"":`${i.provider}/${i.model}`,m=async p=>{const[x,...y]=p.split("/"),S=p===""?null:{provider:x,model:y.join("/")};c(!0),d(null);try{const{warning:N}=await e.connection.call("models/setRoleModel",{model:S});r(S),d(N!==void 0?{tone:"warn",text:N}:{tone:"ok",text:S===null?"角色 agent 和以前一样,用默认模型。":"之后新开的干预、游戏、脚本、编排会话用它;已经开着的会话不变。"})}catch(N){d({tone:"warn",text:N instanceof Error?N.message:String(N)})}finally{c(!1)}},g=h===""||((t==null?void 0:t.groups.some(p=>p.models.some(x=>`${p.id}/${x.id}`===h)))??!1);return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"角色 agent 的模型"}),s.jsx("p",{className:"muted small",children:"干预、游戏、脚本、编排这些软件自己开的会话用它。它们主要是截图、看日志、点击,选一个便宜、能看图的模型可以省用量;你自己的对话仍用上面的默认模型。"})]})}),t===null||i===void 0?s.jsx("div",{className:"muted small",children:"读取中…"}):s.jsx(Vt,{"aria-label":"角色 agent 的模型",value:h,disabled:o,onChange:p=>void m(p),options:[{value:"",label:"和默认模型一样"},...g?[]:[{value:h,label:`${i.provider} / ${i.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...t.groups.flatMap(p=>p.models.map(x=>({value:`${p.id}/${x.id}`,label:x.name,group:p.name})))]}),u!==null&&s.jsx("div",{className:u.tone==="ok"?"muted small":"error small",children:u.text})]})}const U9=(e,t)=>e.auto===t.auto&&e.threshold===t.threshold;function B9({client:e}){var x;const t=we(e.connection.status),[n,i]=b.useState(null),[r,o]=b.useState(null),[c,u]=b.useState(!1),[d,h]=b.useState(null),m=(x=wi())==null?void 0:x.restartService;b.useEffect(()=>{if(d===null||n===null)return;if(d===n.settings.threshold){h(null);return}const y=setTimeout(()=>void g({...n.settings,threshold:d}).then(()=>h(null)),400);return()=>clearTimeout(y)},[d,n]),b.useEffect(()=>{if(t.state!=="open")return;let y=!0;return e.connection.call("compaction/get",{}).then(S=>{y&&i(S)}).catch(S=>{y&&o(Ie(S))}),()=>{y=!1}},[e,t.state]);const g=async y=>{if(!(!y.auto&&(n==null?void 0:n.settings.auto)===!0&&!await Os({title:"关掉自动压缩?",message:"关掉后,对话超过模型的上下文长度时会直接出错,要手动压缩或开新对话才能继续。",confirmLabel:"关掉",danger:!0}))){u(!0),o(null);try{i(await e.connection.call("compaction/set",{settings:y}))}catch(S){o(Ie(S))}finally{u(!1)}}},p=async()=>{m===void 0||!await Os({title:"现在重启 agent 服务?",message:"正在进行的对话和正在跑的脚本、流水线会被中断,大约需要半分钟。",confirmLabel:"重启",danger:!0,icon:"refresh"})||await m()};return s.jsxs("div",{className:"settings-page compaction-page",children:[s.jsx("h2",{children:"对话压缩"}),s.jsx("p",{children:"对话很长时,模型一次看不下全部内容。压缩会把较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:"}),s.jsxs("ul",{className:"compaction-costs",children:[s.jsxs("li",{children:[s.jsx("strong",{children:"会丢失记忆"}),":早先的细节(具体的命令和输出、日志、截图、你说过的原话)agent 不再记得;"]}),s.jsx("li",{children:"摘要可能漏掉或写错内容,而且不能撤销;"}),s.jsx("li",{children:"界面上的聊天记录还在,只是 agent 看不到了。"})]}),n!==null&&s.jsxs("section",{className:"card",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.settings.auto,disabled:c,onChange:y=>void g({...n.settings,auto:y.target.checked})}),"对话太长时自动压缩"]}),s.jsx("p",{className:"muted small",children:n.settings.auto?"关掉后不会自动压缩:对话超过模型的上下文长度时会出错,需要手动压缩或开新对话。":"已关闭:对话超过模型的上下文长度时会出错,需要手动压缩或开新对话。"}),s.jsxs("label",{className:"field compaction-threshold",children:[s.jsxs("span",{className:"field-title",children:["占满上下文的多少时压缩:",s.jsxs("strong",{children:[d??n.settings.threshold,"%"]}),(d??n.settings.threshold)===sR?"(默认)":""]}),s.jsx("input",{type:"range",min:KN,max:YN,step:5,value:d??n.settings.threshold,disabled:!n.settings.auto,"aria-label":"压缩阈值(百分比)",onChange:y=>h(Number(y.target.value))}),s.jsx("span",{className:"muted small",children:"调低:压缩得早,回复快、花费少,但记得的细节少;调高:记得的多,但更可能临时压缩一大段。100% 是到上下文快满时才压缩(会留出回复的空间)。"}),(d??n.settings.threshold)<iR&&n.settings.auto&&s.jsxs("span",{className:"notice warn-box left small compaction-warn",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:"这么低时,光是系统提示和工具说明就可能接近这个用量,几乎每一步都会压缩一次,每次都要调用模型写摘要。想让上下文保持很短,用下面的「低上下文模式」更合适。"})]})]}),!U9(n.settings,n.applied)&&s.jsxs("div",{className:"notice left",children:[s.jsx(J,{name:"info"}),s.jsxs("span",{children:["改动要重启 agent 服务才生效(现在还是:",n.applied.auto?`自动压缩,${n.applied.threshold}%`:"不自动压缩",")。",m===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),m!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void p(),children:"重启 agent 服务"})]}),r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:r})]})]}),n!==null&&s.jsxs("section",{className:"card",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.settings.lowContext,disabled:c,onChange:y=>void g({...n.settings,lowContext:y.target.checked})}),"低上下文模式"]}),s.jsx("p",{className:"muted small",children:"只保留最近 12 小时的对话,更早的在任务做完后压缩成摘要。"}),s.jsxs("label",{className:"check-label compaction-archive",children:[s.jsx("input",{type:"checkbox",checked:n.settings.archiveDays!==null,disabled:c||!n.settings.lowContext,onChange:y=>void g({...n.settings,archiveDays:y.target.checked?7:null})}),"摘要也归档"]}),n.settings.archiveDays!==null&&s.jsxs("label",{className:"field compaction-archive-days",children:[s.jsx("span",{className:"field-title",children:"对话过了多久,它的摘要就移出上下文"}),s.jsx(Vt,{"aria-label":"多久以后归档",value:String(n.settings.archiveDays),disabled:c||!n.settings.lowContext,onChange:y=>void g({...n.settings,archiveDays:Number(y)}),options:[...new Set([...oR,n.settings.archiveDays])].sort((y,S)=>y-S).map(y=>({value:String(y),label:`${y} 天`}))})]}),s.jsx("p",{className:"muted small",children:n.settings.lowContext?"打开后,每一段较早的对话单独写一份摘要(攒到大约一天写一次,不会把摘要再压成摘要);对话过了上面的天数,它的摘要也移出上下文,只留一行说明。做过的事在「记忆」的日记里,agent 需要细节时会去查归档的摘要和原话。上下文最短,但 agent 要靠查才想得起来以前的事。":"要先打开低上下文模式。"})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"手动压缩"}),s.jsxs("p",{className:"muted small",children:["在对话框里输入 ",s.jsx("kbd",{children:"/压缩"}),",会先说明代价再确认。对话框旁边的小圆圈显示上下文用了多少,点开能看到各部分占多少。对话变慢、或报上下文超长时用;agent 正在工作时不能压缩。"]})]}),n===null&&r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:r})]})]})}const Vp=[{kind:"core",title:"核心",hint:`你最在意的要求和偏好:每个 agent 每次都会带上,不会被挤掉;所有核心一共最多 ${ag} 字,总是共享`},{kind:"profile",title:"资料",hint:"长期有效的事实和偏好"},{kind:"journal",title:"日记",hint:"某一天做过或决定的事"}],H9={core:"核心",profile:"资料",journal:"日记"},Fr="",Z9=["周日","周一","周二","周三","周四","周五","周六"];function W9(e){const t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function V9(e){const[t,n,i]=e.split("-").map(Number),r=new Date(t,n-1,i),o=new Date,c=Math.round((new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime()-r.getTime())/864e5),u=`${t===o.getFullYear()?"":`${t}年`}${n}月${i}日 ${Z9[r.getDay()]}`;return c===0?`今天 · ${u}`:c===1?`昨天 · ${u}`:u}const Jl=e=>e.kind==="journal"?e.createdAt:e.updatedAt,iE=(e,t)=>n=>{n.key==="Enter"&&(n.ctrlKey||n.metaKey)?(n.preventDefault(),e()):n.key==="Escape"&&(n.preventDefault(),t())};function q9({client:e}){var $,F;const t=we(e.connection.status),n=ti(e),[i,r]=b.useState(null),[o,c]=b.useState(0),[u,d]=b.useState(ya),[h,m]=b.useState(Fr),[g,p]=b.useState(""),[x,y]=b.useState(!1),[S,N]=b.useState(null);b.useEffect(()=>e.connection.on("memory/changed",()=>c(H=>H+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let H=!0;return e.connection.call("memory/list",{}).then(Z=>{H&&(r(Z.items),N(null))}).catch(Z=>{H&&N(Ie(Z))}),()=>{H=!1}},[e,t.state,o]);const k=b.useMemo(()=>[{id:bn.id,name:bn.name},...n.map(H=>({id:H.id,name:H.name}))],[n]),E=H=>{var Z;return H===ya?"共享":H==="user"?"你":H==="auto"?"自动整理":((Z=k.find(G=>G.id===H))==null?void 0:Z.name)??H},j=g.trim().toLowerCase().split(/\s+/).filter(H=>H!==""),A=H=>(i??[]).filter(Z=>Z.scope===H).length,P=(i??[]).filter(H=>H.scope===u),L=(i??[]).filter(H=>H.kind==="core").reduce((H,Z)=>H+Z.text.length,0),B=P.filter(H=>(h===Fr||H.kind===h)&&j.every(Z=>H.text.toLowerCase().includes(Z))).sort((H,Z)=>Jl(Z).localeCompare(Jl(H))),V=B.filter(H=>H.kind==="core"),M=[];for(const H of B.filter(Z=>Z.kind!=="core")){const Z=W9(Jl(H));(($=M.at(-1))==null?void 0:$.day)===Z?M.at(-1).entries.push(H):M.push({day:Z,entries:[H]})}const z=[{id:ya,name:"共享"},...k],D=((F=z.find(H=>H.id===u))==null?void 0:F.name)??u,U=u===ya,I=j.length>0||h!==Fr,T=async H=>{N(null);try{return await H(),c(Z=>Z+1),!0}catch(Z){return N(Ie(Z)),!1}},O=async(H,Z)=>{const G=H==="core"?ya:u;return await T(()=>e.connection.call("memory/add",{kind:H,scope:G,text:Z}))?(G!==u&&d(G),h!==Fr&&h!==H&&m(Fr),p(""),y(!1),!0):!1};return s.jsxs("div",{className:"settings-page memory-page",children:[s.jsx("h2",{children:"记忆"}),s.jsx("p",{children:"agent 在对话里记下的关于你的事,新开的对话也记得。「共享」的每个 agent 都看得到,其余的只有那个 agent 自己看得到。「核心」是你最在意的要求和偏好,每个 agent 每次都会带上,不会因为记得多了或时间久了被挤掉;只有你自己(或你明确让 agent 记)才会写进去。你也可以在这里记一条、改掉或删掉。密码、验证码、密钥不会被记下。怎么一步步做一件事是另一回事,存在「技能」里。"}),i!==null&&s.jsxs(s.Fragment,{children:[s.jsx(G9,{client:e}),s.jsxs("section",{className:"card memory-browse",children:[s.jsxs("div",{className:"card-head memory-head",children:[s.jsxs("div",{className:"memory-whose",children:[s.jsx(Vt,{className:"scope-select","aria-label":"谁的记忆",value:u,onChange:d,options:z.map(H=>({value:H.id,label:H.id===ya?"共享的记忆":`「${H.name}」的记忆`,hint:A(H.id)===0?"还没有":`${A(H.id)} 条`,...H.id===ya?{}:{group:"一个 agent 自己的"}}))}),s.jsx("span",{className:"muted small",children:U?"每个 agent 都看得到":`只有「${D}」自己看得到`})]}),!x&&s.jsxs("button",{className:"small-button",onClick:()=>y(!0),children:[s.jsx(J,{name:"plus"}),"记一条"]})]}),x&&s.jsx(K9,{to:U?"共享":`「${D}」`,coreUsed:L,onAdd:O,onClose:()=>y(!1)}),S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:S})]}),P.length>0&&s.jsxs("div",{className:"memory-filters",children:[s.jsx("div",{className:"memory-kinds",role:"radiogroup","aria-label":"种类",children:[{kind:Fr,title:"全部"},...Vp].map(H=>s.jsxs("button",{role:"radio","aria-checked":h===H.kind,className:`filter-chip ${h===H.kind?"active":""}`,onClick:()=>m(H.kind),children:[H.title,s.jsx("span",{className:"memory-kind-count",children:H.kind===Fr?P.length:P.filter(Z=>Z.kind===H.kind).length})]},H.kind))}),s.jsxs("label",{className:"memory-search",children:[s.jsx(J,{name:"search"}),s.jsx("input",{className:"text-input plain",type:"search",placeholder:"搜索(空格分开几个词)",value:g,onChange:H=>p(H.target.value),"aria-label":"搜索记忆"})]})]}),V.length>0&&s.jsxs("div",{className:"memory-day memory-core",children:[s.jsx("h4",{className:"memory-day-title",children:s.jsxs("span",{children:["核心 · 每次都带上(",L," / ",ag," 字)"]})}),s.jsx("ul",{className:"memory-list",children:V.map(H=>s.jsx(Uk,{entry:H,nameOf:E,onSave:Z=>T(()=>e.connection.call("memory/update",{id:H.id,text:Z})),onForget:()=>void Os({title:"删掉这条核心记忆?",message:"之后 agent 就不会每次都带上它了,不能撤销。",quote:H.text,confirmLabel:"删掉",danger:!0}).then(Z=>{Z&&T(()=>e.connection.call("memory/remove",{id:H.id}))})},H.id))})]}),M.length===0&&V.length===0?s.jsxs("div",{className:"memory-empty",children:[s.jsx("p",{className:"muted",children:I?"没有找到。":`「${D}」还没有记忆。`}),I?s.jsx("button",{className:"link-button small",onClick:()=>{m(Fr),p("")},children:"清除筛选"}):s.jsx("p",{className:"muted small",children:"agent 干活时会自己记下,你也可以点「记一条」写给它。"})]}):M.map(H=>s.jsxs("div",{className:"memory-day",children:[s.jsx("h4",{className:"memory-day-title",children:s.jsx("span",{children:V9(H.day)})}),s.jsx("ul",{className:"memory-list",children:H.entries.map(Z=>s.jsx(Uk,{entry:Z,nameOf:E,onSave:G=>T(()=>e.connection.call("memory/update",{id:Z.id,text:G})),onForget:()=>void Os({title:"忘掉这条记忆?",message:"之后 agent 就不记得了,不能撤销。",quote:Z.text,confirmLabel:"忘掉",danger:!0}).then(G=>{G&&T(()=>e.connection.call("memory/remove",{id:Z.id}))})},Z.id))})]},H.day))]})]}),i===null&&S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:S})]})]})}function G9({client:e}){const t=we(e.connection.status),{catalog:n}=Ba(e),[i,r]=b.useState(null),[o,c]=b.useState(!1),[u,d]=b.useState(null);b.useEffect(()=>{if(t.state!=="open")return;let y=!0;return e.connection.call("memory/auto/get",{}).then(S=>{y&&(r(S),d(null))}).catch(S=>{y&&d(Ie(S))}),()=>{y=!1}},[e,t.state]);const h=async y=>{c(!0),d(null);try{const S=await e.connection.call("memory/auto/set",{auto:y.auto,model:y.model});r({...S,...(i==null?void 0:i.forced)===!0?{forced:!0}:{}})}catch(S){d(Ie(S))}finally{c(!1)}};if(i===null)return u===null?null:s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:u})]});const m=i.auto||i.forced===!0,g=i.model===null?"":`${i.model.provider}/${i.model.model}`,p=g===""||((n==null?void 0:n.groups.some(y=>y.models.some(S=>`${y.id}/${S.id}`===g)))??!1),x=y=>{const[S,...N]=y.split("/");h({...i,model:y===""?null:{provider:S,model:N.join("/")}})};return s.jsxs("section",{className:"card memory-auto",children:[s.jsxs("div",{className:"memory-auto-row",children:[s.jsxs("label",{className:"check-label memory-auto-check",children:[s.jsx("input",{type:"checkbox",checked:m,disabled:o||i.forced===!0,onChange:y=>void h({...i,auto:y.target.checked})}),s.jsxs("span",{className:"memory-auto-text",children:[s.jsx("strong",{children:"自动整理"}),s.jsxs("span",{className:"muted small",children:["对话停下几分钟后,自动把没记下的偏好和做过的事整理进记忆",i.forced===!0?"。低上下文模式开着,自动整理会一直开着。":""]})]})]}),m&&s.jsxs("label",{className:"field memory-auto-model",children:[s.jsx("span",{className:"field-title",children:"整理用的模型"}),n===null?s.jsx("span",{className:"muted small",children:"读取中…"}):s.jsx(Vt,{"aria-label":"整理用的模型",value:g,disabled:o,onChange:x,options:[{value:"",label:"和默认模型一样"},...p?[]:[{value:g,label:`${i.model.provider} / ${i.model.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...n.groups.flatMap(y=>y.models.map(S=>({value:`${y.id}/${S.id}`,label:S.name,group:y.name})))]})]})]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:u})]})]})}function K9({to:e,coreUsed:t,onAdd:n,onClose:i}){var y;const[r,o]=b.useState(""),[c,u]=b.useState("profile"),[d,h]=b.useState(!1),m=ag-t,g=c==="core"&&r.trim().length>m,p=!d&&r.trim()!==""&&!g,x=async()=>{p&&(h(!0),await n(c,r.trim()),h(!1))};return s.jsxs("div",{className:"memory-compose",children:[s.jsx("textarea",{className:"text-input plain",rows:3,maxLength:og,autoFocus:!0,"aria-label":"要记下的事",placeholder:"一句话写一件事,例如:日报只要告诉我有没有失败的;明日方舟只玩 B 服。",value:r,onChange:S=>o(S.target.value),onKeyDown:iE(()=>void x(),i)}),s.jsxs("div",{className:"memory-compose-foot",children:[s.jsx("div",{className:"segmented-control memory-kind",role:"radiogroup","aria-label":"种类",children:Vp.map(S=>s.jsx("button",{role:"radio","aria-checked":c===S.kind,className:c===S.kind?"active":"",onClick:()=>u(S.kind),children:S.title},S.kind))}),s.jsxs("span",{className:`small memory-compose-hint ${g?"warn-text":"muted"}`,children:[(y=Vp.find(S=>S.kind===c))==null?void 0:y.hint,c==="core"&&(g?`。核心只剩 ${Math.max(0,m)} 字了:先合并或删掉几条,或记成资料。`:`(还能写 ${m} 字)`)]}),s.jsxs("span",{className:"memory-compose-actions",children:[s.jsx("button",{disabled:d,onClick:i,children:"取消"}),s.jsx("button",{className:"primary",disabled:!p,onClick:()=>void x(),children:d?"记下中…":c==="core"?"记成核心":`记到${e}`})]})]})]})}function Uk({entry:e,nameOf:t,onSave:n,onForget:i}){const[r,o]=b.useState(null),[c,u]=b.useState(!1),d=!c&&r!==null&&r.trim()!=="",h=async()=>{d&&(u(!0),await n(r.trim())&&o(null),u(!1))};return s.jsxs("li",{className:`memory-row ${r===null?"":"editing"}`,children:[s.jsx("time",{className:"memory-time",dateTime:Jl(e),title:e.kind==="journal"?"记下的时间":"最后更新的时间",children:new Date(Jl(e)).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}),s.jsxs("div",{className:"memory-body",children:[r===null?s.jsx("div",{className:"memory-text",children:e.text}):s.jsx("textarea",{className:"text-input plain",rows:3,maxLength:og,value:r,onChange:m=>o(m.target.value),onKeyDown:iE(()=>void h(),()=>o(null)),"aria-label":"修改记忆",autoFocus:!0}),s.jsxs("div",{className:"memory-meta",children:[s.jsx("span",{className:`memory-kind-tag ${e.kind}`,children:H9[e.kind]}),s.jsx("span",{className:"muted small",children:e.by==="user"?"你记的":e.by==="auto"?"自动整理出来的":`${t(e.by)}记的`}),r!==null&&s.jsxs("span",{className:"memory-edit-actions",children:[s.jsx("button",{className:"small-button",disabled:c,onClick:()=>o(null),children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:!d,onClick:()=>void h(),children:c?"保存中…":"保存"})]})]})]}),r===null&&s.jsxs("span",{className:"memory-actions",children:[s.jsx("button",{className:"link-button small",onClick:()=>o(e.text),children:"修改"}),s.jsx("button",{className:"link-button small memory-forget",onClick:i,children:"忘掉"})]})]})}const Bk=[{policy:"default",label:"默认",hint:"跟着上面的模式走"},{policy:"allow",label:"允许",hint:"不问你,直接做"},{policy:"ask",label:"先问我",hint:"每次都先问你,「完全访问」时也问"},{policy:"deny",label:"不允许",hint:"agent 不能做,会告诉你被关掉了"}],Y9=[{value:"auto",label:"自动更新"},{value:"ask",label:"先问我"},{value:"off",label:"不自动更新"}],X9=[{value:"act",label:"诊断并处理"},{value:"diagnose",label:"只诊断"},{value:"off",label:"不干预"}];function Q9({client:e,state:t,onState:n}){const i=we(e.capabilities),[r,o]=b.useState(null),[c,u]=b.useState(null),[d,h]=b.useState(null),m=i.has("monitor"),g=i.has("scripts"),[p,x]=b.useState(null);b.useEffect(()=>{if(!g)return;let k=!0;return e.connection.call("scripts/settings",{}).then(E=>{k&&x(E.autoUpdate)}).catch(()=>{}),()=>{k=!1}},[e,g]),b.useEffect(()=>{if(!m)return;let k=!0;return e.connection.call("monitor/settings",{}).then(E=>{k&&h(E)}).catch(()=>{}),()=>{k=!1}},[e,m]);const y=async(k,E)=>{o(k),u(null);try{n(await e.connection.call("permissions/area/set",{area:k,policy:E}))}catch(j){u(Ie(j))}finally{o(null)}},S=async k=>{o("autoUpdate"),u(null);try{x((await e.connection.call("scripts/settings/set",{autoUpdate:k})).autoUpdate)}catch(E){u(Ie(E))}finally{o(null)}},N=async k=>{o("intervene"),u(null);try{h(await e.connection.call("monitor/settings/set",{intervene:k}))}catch(E){u(Ie(E))}finally{o(null)}};return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"按范围设置"}),s.jsxs("p",{className:"muted small",children:["agent 能自己做的事,一项一项决定:",Bk.map(k=>`「${k.label}」${k.hint}`).join(";"),"。"]})]})}),s.jsxs("div",{className:"area-list",children:[m&&d!==null&&s.jsxs("div",{className:"area-row",children:[s.jsxs("div",{className:"area-text",children:[s.jsx("strong",{children:"主动干预出问题的脚本"}),s.jsx("span",{className:"muted small",children:"脚本卡住、报错,自动处理解决不了时交给 agent:「诊断并处理」会暂停脚本、看屏幕、点击输入来解决;「只诊断」只说明原因由你决定。"})]}),s.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":"主动干预",children:X9.map(k=>s.jsx("button",{role:"radio","aria-checked":d.intervene===k.value,className:d.intervene===k.value?"active":"",disabled:r!==null,onClick:()=>void N(k.value),children:k.label},k.value))})]}),g&&p!==null&&s.jsxs("div",{className:"area-row",children:[s.jsxs("div",{className:"area-text",children:[s.jsx("strong",{children:"脚本有新版本时"}),s.jsx("span",{className:"muted small",children:"运行前和每隔几小时检查一次:「自动更新」下次运行前先更新;「先问我」在聊天输入框上方提示,你点了才更新;「不自动更新」只在脚本页标出新版本。agent 也照这里来:只有「自动更新」时会自己决定更新。"})]}),s.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":"脚本有新版本时",children:Y9.map(k=>s.jsx("button",{role:"radio","aria-checked":p===k.value,className:p===k.value?"active":"",disabled:r!==null,onClick:()=>void S(k.value),children:k.label},k.value))})]}),DM.map(k=>{const E=t.areas[k.id]??"default";return s.jsxs("div",{className:"area-row",children:[s.jsxs("div",{className:"area-text",children:[s.jsx("strong",{children:k.title}),s.jsx("span",{className:"muted small",children:k.description})]}),s.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":k.title,children:Bk.map(j=>s.jsx("button",{role:"radio","aria-checked":E===j.policy,title:j.hint,className:`${E===j.policy?"active":""} ${j.policy}`,disabled:r!==null,onClick:()=>void y(k.id,j.policy),children:j.label},j.policy))})]},k.id)})]}),c!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:c})]})]})}const J9=[{mode:"ask",title:"每次确认(推荐)",text:"agent 的命令在沙箱里运行;安装陌生仓库、操作屏幕、沙箱外的命令、修改脚本文件等,都先问你。"},{mode:"full",title:"完全访问",text:"不用沙箱,所有需要确认的操作都自动允许,也可以修改脚本文件:agent 想改什么就改什么,不再问你。"}];function e8({client:e}){const t=we(e.connection.status),n=An(3e4),[i,r]=b.useState(null),[o,c]=b.useState(!1),[u,d]=b.useState(null);b.useEffect(()=>e.connection.on("permissions/changed",m=>r(m)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let m=!0;return e.connection.call("permissions/get",{}).then(g=>{m&&r(g)}).catch(g=>{m&&d(Ie(g))}),()=>{m=!1}},[e,t.state]);const h=async m=>{if((i==null?void 0:i.mode)!==m&&!(m==="full"&&!await Os({title:"打开「完全访问」?",icon:"shield",confirmLabel:"打开",danger:!0,message:`打开后,agent 可以不经确认运行任何命令、修改或删除任何文件(包括脚本文件)、操作屏幕、安装软件。
237
+
238
+ 只在你信任当前模型、并且需要它自己完成整件事时打开。`}))){c(!0),d(null);try{r(await e.connection.call("permissions/set",{mode:m}))}catch(g){d(Ie(g))}finally{c(!1)}}};return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"权限"}),s.jsx("p",{children:"决定 agent 做事之前要不要先问你。对所有会话都有效,包括飞书里的对话、异常处理和流水线里的 agent 步骤。"}),s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"permission-options",role:"radiogroup","aria-label":"权限",children:J9.map(m=>s.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:[s.jsx("span",{className:"permission-dot","aria-hidden":"true"}),s.jsxs("span",{className:"permission-text",children:[s.jsx("strong",{children:m.title}),s.jsx("span",{children:m.text})]})]},m.mode))}),(i==null?void 0:i.mode)==="full"&&s.jsxs("div",{className:"notice warn-note left small",children:[s.jsx(J,{name:"alert"}),s.jsxs("span",{children:["完全访问一直开着,没有时间限制,直到你改回「每次确认」",i.since===void 0?"":`(${t8(i.since,n)})`,"。agent 不会再请求确认;它仍然不会替你输入密码、验证码或付款。agent 之间可以互相交事情,这时也不会有人拦:比如读网页时读到的内容,可能经别的 agent 变成运行或安装。"]})]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:u})]})]}),i!==null&&s.jsx(Q9,{client:e,state:i,onState:r}),i!==null&&i.recent.length>0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"没问你就允许了的操作"}),s.jsxs("p",{className:"muted small",children:["因为「完全访问」或某个范围设成了「允许」。程序这次启动以来,最近 ",i.recent.length," 条。"]}),s.jsx("ul",{className:"version-list",children:i.recent.map((m,g)=>s.jsxs("li",{children:[s.jsx("span",{className:"badge",children:m.toolName}),s.jsx("span",{className:"permission-reason",children:m.reason??"(没有说明)"}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"session-time",children:Et(m.at,n)})]},g))})]})]})}function t8(e,t){const n=Et(e,t);return n==="刚刚"?"刚刚打开":/^\d+ (分钟|小时|天)$/.test(n)?`${n}前打开`:`${n} 打开`}const qp=[{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:"今日日常已完成。另有一项需要您决定:活动商店剩余两件,是否明日继续兑换?"}],Rm=[{style:"plain",title:"平实",text:"直接说事,不带人设和称呼:它们要读的是内容。推荐。"},{style:"same",title:"和对你一样",text:"人设也带到 agent 之间的往来里,你在「协作」里看到的就是这个语气。"}],Om="",Hk=e=>{var t;return((t=qp.find(n=>n.style===e))==null?void 0:t.title)??e};function Zk(e){return e===void 0||e.style===void 0&&e.callUser===void 0&&e.custom===void 0&&e.peerStyle===void 0}const Wk=e=>{var t,n,i;return[e.style??"",((t=e.name)==null?void 0:t.trim())??"",((n=e.callUser)==null?void 0:n.trim())??"",((i=e.custom)==null?void 0:i.trim())??"",e.peerStyle??""]};function Vu(e){const t=Object.entries(e.agents).map(([n,i])=>[n,Wk(i)]).filter(([,n])=>n.some(i=>i!=="")).sort(([n],[i])=>n.localeCompare(i));return JSON.stringify([Wk({...e.persona,peerStyle:e.persona.peerStyle??"plain"}),t])}function n8({client:e}){var G,q,X,Y,re;const t=we(e.connection.status),n=ti(e),[i,r]=b.useState(null),[o,c]=b.useState(null),[u,d]=b.useState(Om),[h,m]=b.useState(!1),[g,p]=b.useState(null),[x,y]=b.useState(!1),S=ee=>{const se={persona:ee.persona,agents:ee.agents};r(se),c(se)};if(b.useEffect(()=>{if(t.state!=="open")return;let ee=!0;return e.connection.call("persona/get",{}).then(se=>{ee&&S(se)}).catch(se=>{ee&&p(Ie(se))}),()=>{ee=!1}},[e,t.state]),o===null||i===null)return s.jsxs("div",{className:"settings-page persona-page",children:[s.jsx("h2",{children:"回复风格"}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:g})]})]});const N=Vu(o)!==Vu(i),k=ee=>{c(ee),y(!1)},E=async()=>{m(!0),p(null);try{S(await e.connection.call("persona/set",o)),y(!0)}catch(ee){p(Ie(ee))}finally{m(!1)}},j=[{id:bn.id,name:bn.name},...n.map(ee=>({id:ee.id,name:ee.name}))],A=u===Om,P=o.persona,L=A?void 0:o.agents[u],B=((G=j.find(ee=>ee.id===u))==null?void 0:G.name)??u,V=ee=>k({...o,persona:{...P,...ee}}),M=ee=>{const se=Object.fromEntries(Object.entries({...L,...ee}).filter(([,ne])=>ne!==void 0&&(typeof ne!="string"||ne.trim()!=="")));k({...o,agents:{...o.agents,[u]:se}})},z=A?V:M,D=A?P:hy(o,u),U=fy(D),I=new Set(fy(A?i.persona:hy(i,u)).split(`
239
+ `)),T=((q=qp.find(ee=>ee.style===D.style))==null?void 0:q.sample)??"",O=A?P.style:L==null?void 0:L.style,$=A?P.peerStyle??"plain":L==null?void 0:L.peerStyle,F=(ee,se)=>A?se:ee===void 0||ee===""?"留空:跟随统一(现在没有设置)":`留空:跟随统一(${ee})`,H=A?Vu({persona:P,agents:{}})!==Vu({persona:{style:"default"},agents:{}}):!Zk(L),Z=()=>k(A?{...o,persona:{style:"default"}}:{...o,agents:{...o.agents,[u]:(L==null?void 0:L.name)===void 0?{}:{name:L.name}}});return s.jsxs("div",{className:"settings-page persona-page",children:[s.jsx("h2",{children:"回复风格"}),s.jsx("p",{children:"agent 说话的方式和人设:可以统一设置,也可以给某个 agent 单独设置。软件里的对话、飞书里的回复、流水线里的 agent 步骤都算。只改说话方式:它们能做什么、该做什么、什么要问你,都不变。子 agent 不用设置,它们只把结果交回给开它们的 agent。"}),s.jsxs("section",{className:"card persona-board",children:[s.jsxs("header",{className:"persona-bar",children:[s.jsxs("label",{className:"persona-who",children:[s.jsx("span",{className:"field-title",children:"设置给"}),s.jsx(Vt,{className:"scope-select","aria-label":"设置给谁",value:u,onChange:d,options:[{value:Om,label:"所有 agent",hint:"统一设置"},...j.map(ee=>{var ie;const se=o.agents[ee.id],ne=(ie=se==null?void 0:se.name)==null?void 0:ie.trim();return{value:ee.id,label:ne?`${ee.name}(${ne})`:ee.name,hint:Zk(se)?"跟随统一":"有单独设置",group:"只给一个 agent"}})]})]}),s.jsx("span",{className:`persona-state ${N?"dirty":""}`,role:"status",children:N?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"persona-dot"}),"有没保存的改动"]}):x?s.jsxs(s.Fragment,{children:[s.jsx(J,{name:"check"}),"已保存,下一句回复开始生效"]}):null}),N&&s.jsx("button",{disabled:h,onClick:()=>k(i),children:"撤销"}),s.jsx("button",{className:"primary",disabled:h||!N,onClick:()=>void E(),children:h?"保存中…":"保存"})]}),g!==null&&s.jsxs("div",{className:"notice error left persona-error",children:[s.jsx(J,{name:"alert"}),s.jsx("span",{children:g})]}),s.jsxs("div",{className:"persona-panes",children:[s.jsxs("div",{className:"persona-form",children:[s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field-title",children:"风格"}),s.jsxs("div",{className:"persona-tiles",role:"radiogroup","aria-label":"风格",children:[!A&&s.jsx(Vk,{wide:!0,title:"跟随统一",note:`现在是「${Hk(P.style)}」`,selected:O===void 0,onClick:()=>M({style:void 0})}),qp.map(ee=>s.jsx(Vk,{title:ee.title,note:ee.note,selected:O===ee.style,onClick:()=>z({style:ee.style})},ee.style))]})]}),s.jsxs("div",{className:"persona-pair",children:[!A&&s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"它的名字(可选)"}),s.jsx("input",{className:"text-input plain",maxLength:20,placeholder:"例如:小助",value:(L==null?void 0:L.name)??"",onChange:ee=>M({name:ee.target.value}),title:"它自称时用这个名字;别的 agent 也会知道你这么叫它。"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"怎么称呼你(可选)"}),s.jsx("input",{className:"text-input plain",maxLength:20,placeholder:F(P.callUser,"例如:博士、开拓者、指挥官"),value:(A?P.callUser:L==null?void 0:L.callUser)??"",onChange:ee=>z({callUser:ee.target.value})})]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"其他要求(可选)"}),s.jsx("textarea",{className:"text-input plain persona-custom",rows:4,placeholder:F(P.custom,"例如:说话带一点罗德岛干员的口吻;汇报时先说有没有失败;不要用表情。"),value:(A?P.custom:L==null?void 0:L.custom)??"",onChange:ee=>z({custom:ee.target.value})})]}),s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field-title",children:"对其他 agent 说话"}),s.jsxs("div",{className:"segmented-control persona-peer",role:"radiogroup","aria-label":"对其他 agent 说话",children:[!A&&s.jsx("button",{role:"radio","aria-checked":$===void 0,className:$===void 0?"active":"",onClick:()=>M({peerStyle:void 0}),children:"跟随统一"}),Rm.map(ee=>s.jsx("button",{role:"radio","aria-checked":$===ee.style,className:$===ee.style?"active":"",onClick:()=>z({peerStyle:ee.style}),children:ee.title},ee.style))]}),s.jsx("span",{className:"muted small",children:$===void 0?`和统一设置一样:${(X=Rm.find(ee=>ee.style===(P.peerStyle??"plain")))==null?void 0:X.title}。`:(Y=Rm.find(ee=>ee.style===$))==null?void 0:Y.text})]}),s.jsxs("div",{className:"persona-foot muted small",children:[s.jsx("span",{children:A?"没有单独设置的 agent 都按这里的来。":"没改的地方跟随「所有 agent」的设置。"}),H&&s.jsx("button",{className:"link-button small",onClick:Z,children:A?"恢复默认":"全部改回跟随统一"})]})]}),s.jsx("aside",{className:"persona-preview","aria-label":"预览",children:s.jsxs("div",{className:"persona-preview-in",children:[s.jsxs("div",{className:"persona-preview-head",children:[s.jsx("strong",{children:"预览"}),s.jsx("span",{className:"muted small",children:N?"跟着左边的选择变,保存后生效":"现在生效的设置"})]}),s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field-title",children:"说出来大概这样"}),T===""?s.jsx("p",{className:"persona-sample none",children:"不加风格,按模型自己的说话方式。"}):s.jsxs("div",{className:"persona-sample",children:[s.jsx("span",{className:"persona-sample-who",children:((re=D.name)==null?void 0:re.trim())||(A?"agent":B)}),s.jsx("p",{children:T})]}),s.jsxs("span",{className:"muted small",children:["只是「",Hk(D.style),"」的示例;实际怎么说,模型照下面这段来。"]})]}),s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field-title",children:A?"加到 agent 提示词里的内容":`加到「${B}」提示词里的内容`}),U===""?s.jsx("p",{className:"persona-prompt empty-prompt",children:"什么都不加。"}):s.jsx("div",{className:"persona-prompt",children:U.split(`
240
+ `).map((ee,se)=>s.jsx("div",{className:I.has(ee)?"":"changed",children:ee},se))})]})]})})]})]})]})}function Vk({title:e,note:t,selected:n,wide:i,onClick:r}){return s.jsxs("button",{role:"radio","aria-checked":n,className:`persona-tile ${n?"selected":""} ${i===!0?"wide":""}`,onClick:r,children:[s.jsxs("strong",{children:[e,n&&s.jsx(J,{name:"check"})]}),s.jsx("span",{className:"muted small",children:t})]})}const s8={id:"settings-credentials",title:"模型",requires:["credentials","models"],settingsPages:[{id:"api-keys",title:"模型",order:0,component:P9}]},i8={id:"permissions",title:"权限",requires:["permissions"],settingsPages:[{id:"permissions",title:"权限",order:1,component:e8}]},r8={id:"persona",title:"回复风格",requires:["persona"],settingsPages:[{id:"persona",title:"回复风格",order:2,component:n8}]},a8={id:"compaction",title:"对话压缩",requires:["compaction"],settingsPages:[{id:"compaction",title:"对话压缩",order:3,component:B9}]},o8={id:"memory",title:"记忆",requires:["memory"],settingsPages:[{id:"memory",title:"记忆",order:2.5,component:q9}]},l8={id:"about",title:"关于",requires:[],settingsPages:[{id:"about",title:"关于",order:100,component:N9}]};function c8({client:e}){const t=we(e.capabilities),n=we(e.connection.server),[i,r]=b.useState(0);b.useEffect(()=>cj(()=>r(d=>d+1)),[]);const o=b.useMemo(()=>VR(t),[t,i]),c=o.filter(d=>d.missing.length===0),u=o.filter(d=>d.missing.length>0);return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"插件状态"}),s.jsx("p",{children:"界面插件只在后端提供了它需要的能力时启用。后端少装一个插件,对应的界面就自动隐藏。"}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"后端能力"}),s.jsx("p",{className:"muted small",children:n===null?"尚未连接":`${n.server.name} ${n.server.version}${n.server.dsh===void 0?"":` · dsh ${n.server.dsh}`}`}),s.jsxs("div",{className:"chip-row",children:[[...t].sort().map(d=>s.jsx("span",{className:"chip",children:d},d)),t.size===0&&s.jsx("span",{className:"muted small",children:"无"})]})]}),s.jsxs("section",{className:"card",children:[s.jsxs("h3",{children:["已启用(",c.length,")"]}),s.jsx("ul",{className:"plugin-list",children:c.map(({plugin:d})=>s.jsxs("li",{children:[s.jsx("span",{className:"plugin-name",children:d.title}),s.jsx("span",{className:"muted small",children:d.requires.length===0?"无需后端能力":d.requires.join(" · ")})]},d.id))})]}),u.length>0&&s.jsxs("section",{className:"card",children:[s.jsxs("h3",{children:["等待后端能力(",u.length,")"]}),s.jsx("ul",{className:"plugin-list",children:u.map(({plugin:d,missing:h})=>s.jsxs("li",{children:[s.jsxs("span",{className:"plugin-name",children:[d.title,d.milestone!==void 0&&s.jsx("span",{className:"chip subtle",children:d.milestone})]}),s.jsxs("span",{className:"muted small",children:["缺少:",h.join(" · ")]})]},d.id))})]})]})}const u8={id:"plugin-status",title:"插件状态",requires:[],settingsPages:[{id:"plugins",title:"插件状态",order:90,component:c8}]};function d8(e,t,n){const i=new Array(e);return new Proxy(i,{get(r,o,c){if(typeof o=="string"){const u=o.charCodeAt(0);if(u>=48&&u<=57){const d=+o;if(Number.isInteger(d)&&d>=0&&d<e){let h=r[d];if(!h){const m=t[d*2];h=r[d]={index:d,key:n(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,c)}})}function xo(e,t,n){let i=n.initialDeps??[],r,o=!0;function c(){const u=e();return(u.length!==i.length||u.some((h,m)=>i[m]!==h))&&(i=u,r=t(...u),n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(r),o=!1),r}return c.updateDeps=u=>{i=u},c}function qk(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const h8=(e,t)=>Math.abs(e-t)<1.01,f8=(e,t,n)=>{let i;return Object.assign(function(...r){e.clearTimeout(i),i=e.setTimeout(()=>t.apply(this,r),n)},{cancel:()=>{e.clearTimeout(i)}})};let zl;const Pm=()=>{if(zl!==void 0)return zl;if(typeof navigator>"u")return zl=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return zl=!0;const e=navigator.maxTouchPoints;return zl=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Gk=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},m8=e=>e,p8=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},g8=(e,t)=>{const n=e.scrollElement;if(!n)return;const i=e.targetWindow;if(!i)return;const r=c=>{const{width:u,height:d}=c;t({width:Math.round(u),height:Math.round(d)})};if(r(Gk(n)),!i.ResizeObserver)return()=>{};const o=new i.ResizeObserver(c=>{const u=()=>{const d=c[0];if(d!=null&&d.borderBoxSize){const h=d.borderBoxSize[0];if(h){r({width:h.inlineSize,height:h.blockSize});return}}r(Gk(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},Ad={passive:!0},x8=typeof window>"u"?!0:"onscrollend"in window,v8=(e,t,n)=>{const i=e.scrollElement;if(!i)return;const r=e.targetWindow;if(!r)return;const o=e.options.useScrollendEvent&&x8;let c=0;const u=o?null:f8(r,()=>t(c,!1),e.options.isScrollingResetDelay),d=g=>()=>{c=n(i),u==null||u(),t(c,g)},h=d(!0),m=d(!1);return i.addEventListener("scroll",h,Ad),o&&i.addEventListener("scrollend",m,Ad),()=>{i.removeEventListener("scroll",h),o&&i.removeEventListener("scrollend",m),u==null||u.cancel()}},y8=(e,t)=>v8(e,t,n=>{const{horizontal:i,isRtl:r}=e.options;return i?n.scrollLeft*(r&&-1||1):n.scrollTop}),b8=(e,t,n)=>{if(n.options.useCachedMeasurements){const i=n.indexFromElement(e),r=n.options.getItemKey(i);return n.itemSizeCache.get(r)??n.options.estimateSize(i)}if(t!=null&&t.borderBoxSize){const i=t.borderBoxSize[0];if(i)return Math.round(i[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const i=n.indexFromElement(e),r=n.options.getItemKey(i),o=n.itemSizeCache.get(r);if(o!==void 0)return o}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},k8=(e,{adjustments:t=0,behavior:n},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:n})},N8=k8;class j8{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,i,r;return((r=(i=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let n=null;const i=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(r=>{r.forEach(o=>{const c=()=>{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(c):c()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),n=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=n=>{var i,r;const o={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:m8,rangeExtractor:p8,onChange:()=>{},measureElement:b8,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 p in n){const x=n[p];x!==void 0&&(o[p]=x)}const c=this.options;let u=null,d=null,h=!1;if(c!==void 0&&c.enabled&&o.enabled&&o.anchorTo==="end"&&this.scrollElement!==null){const p=c.count,x=o.count,y=this.getMeasurements(),S=p>0?((i=y[0])==null?void 0:i.key)??c.getItemKey(0):null,N=p>0?((r=y[p-1])==null?void 0:r.key)??c.getItemKey(p-1):null;if(x!==p||p>0&&x>0&&(o.getItemKey(0)!==S||o.getItemKey(x-1)!==N)){h=!0;const j=p>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;j&&(u=[j.key,this.getScrollOffset()-j.start]);const A=o.followOnAppend===!0?"auto":o.followOnAppend||null;A&&x>p&&this.isAtEnd(c.scrollEndThreshold)&&(p===0||o.getItemKey(x-1)!==N)&&(d=A)}}this.options=o,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let m=!1,g=0;if(u&&this.scrollOffset!==null){const[p,x]=u,y=this.getMeasurements(),{count:S,getItemKey:N}=this.options;let k=0;for(;k<S&&N(k)!==p;)k++;if(k<S){const E=y[k];if(E){const j=Math.max(0,E.start+x);j!==this.scrollOffset&&(g=j-this.scrollOffset,this.scrollOffset=j,m=!0)}}}(m||d)&&(this.pendingScrollAnchor=[m?u[0]:null,m?u[1]:0,d,g])},this.notify=n=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,n)},this.maybeNotify=xo(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const 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=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,c)=>{if(c&&this._intendedScrollOffset===null&&o===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5&&(o=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const u=this.getScrollOffset();this.scrollDirection=c?u===o?this.scrollDirection:u<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=c,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,c=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},u=()=>{this._iosTouching=!1,!(!Pm()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",c,Ad),o.addEventListener("touchend",u,Ad),this.unsubs.push(()=>{o.removeEventListener("touchstart",c),o.removeEventListener("touchend",u),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const r=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled){const[o,c,u,d]=r;o!==null&&!u&&(Pm()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),u&&this.scrollToEnd({behavior:u})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),i=this.getMaxScrollOffset();if(n<0||n>i)return;if(this._iosDeferredAdjustment<0&&n>=i-1){this._iosDeferredAdjustment=0;return}const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{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=xo(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,i,r,o,c,u,d,h)=>(this.prevLanes!==void 0&&this.prevLanes!==u&&(this.lanesChangedFlag=!0),this.prevLanes=u,this.pendingMin=null,{count:n,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:c,lanes:u,laneAssignmentMode:d,gap:h}),{key:!1}),this.isIndexInRange=n=>n>=0&&n<this.options.count,this.getMeasurements=xo(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:c,lanes:u,laneAssignmentMode:d,gap:h},m)=>{const g=this.itemSizeCache;if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const k of this.laneAssignments.keys())k>=n&&this.laneAssignments.delete(k);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(k=>{this.itemSizeCache.set(k.key,k.size)}));const p=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),u===1){const k=n*2;let E=this._flatMeasurements;if(!E||E.length<k){const P=new Float64Array(k);E&&p>0&&P.set(E.subarray(0,p*2)),E=P,this._flatMeasurements=E}let j;if(p===0)j=i+r;else{const P=p-1;j=E[P*2]+E[P*2+1]+h}for(let P=p;P<n;P++){const L=o(P),B=g.get(L),V=typeof B=="number"?B:this.options.estimateSize(P);E[P*2]=j,E[P*2+1]=V,j+=V+h}const A=d8(n,E,o);return this.measurementsCache=A,A}const x=this.measurementsCache.slice(0,p),y=new Array(u).fill(void 0),S=new Float64Array(u);let N=0;for(let k=0;k<p;k++){const E=x[k];E&&(y[E.lane]===void 0&&N++,y[E.lane]=k,S[E.lane]=E.end)}for(let k=p;k<n;k++){const E=o(k),j=this.laneAssignments.get(k);let A,P;const L=d==="estimate"||g.has(E);if(j!==void 0&&this.options.lanes>1){A=j;const z=y[A],D=z!==void 0?x[z]:void 0;P=D?D.end+h:i+r}else if(N===u){let z=0,D=S[0],U=y[0];for(let I=1;I<u;I++){const T=S[I];(T<D||T===D&&y[I]<U)&&(z=I,D=T,U=y[I])}A=z,P=D+h,L&&this.laneAssignments.set(k,A)}else A=k%this.options.lanes,P=i+r,L&&this.laneAssignments.set(k,A);const B=g.get(E),V=typeof B=="number"?B:this.options.estimateSize(k),M=P+V;x[k]={index:k,start:P,size:V,end:M,key:E,lane:A},y[A]===void 0&&N++,y[A]=k,S[A]=M}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=xo(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,i,r,o)=>n.length===0||i===0?(this.range=null,null):(this.range=S8(n,i,r,o,o===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=xo(()=>{let n=null,i=null;const r=this.calculateRange();return r&&(n=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,i]},(n,i,r,o,c)=>o===null||c===null?[]:n({startIndex:o,endIndex:c,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const i=this.options.indexAttribute,r=n.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{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)),c=Math.max(0,r-o),u=Math.min(this.options.count-1,r+o);return n>=c&&n<=u}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((c,u)=>{c.isConnected||(this.observer.unobserve(c),this.elementsCache.delete(u))});return}const i=this.indexFromElement(n);if(!this.isIndexInRange(i))return;const r=this.options.getItemKey(i),o=this.elementsCache.get(r);o!==n&&(o&&this.observer.unobserve(o),this.observer.observe(n),this.elementsCache.set(r,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,i)=>{var r,o;if(!this.isIndexInRange(n))return;let c,u,d;const h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)d=this.options.getItemKey(n),u=h[n*2],c=h[n*2+1];else{const p=this.measurementsCache[n];if(!p)return;d=p.key,u=p.start,c=p.size}const m=this.itemSizeCache.get(d)??c,g=i-m;if(g!==0){const p=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,x=p?this.getTotalSize():0,y=this.getScrollOffset()+this.scrollAdjustments,N=!this.itemSizeCache.has(d)?u<y:u+m<=y&&this.scrollDirection!=="backward",k=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:d,start:u,size:c,end:u+c,lane:0},g,this):N);(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(d,i),this.itemSizeCacheVersion++;let E=!1;p?E=this.applyScrollAdjustment(this.getTotalSize()-x):k&&(E=this.applyScrollAdjustment(g)),this.notify(E)}},this.getVirtualItems=xo(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,i)=>{const r=[];for(let o=0,c=n.length;o<c;o++){const u=n[o],d=i[u];r.push(d)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const i=this.getMeasurements();if(i.length===0)return;const r=this._flatMeasurements,o=this.options.lanes===1&&r!=null,c=rE(0,i.length-1,o?u=>r[u*2]:u=>qk(i[u]).start,n);return qk(i[c])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,i,r=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),c=this.getScrollOffset();i==="auto"&&(i=n>=c+o?"end":"start"),i==="center"?n+=(r-o)/2:i==="end"&&(n-=o);const u=this.getMaxScrollOffset();return Math.max(Math.min(u,n),0)},this.getOffsetForIndex=(n,i="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getSize(),o=this.getScrollOffset(),c=this.measurementsCache[n];if(!c)return;if(i==="auto")if(c.end>=o+r-this.options.scrollPaddingEnd)i="end";else if(c.start<=o+this.options.scrollPaddingStart)i="start";else return[o,i];if(i==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),i];const u=i==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(u,i,c.size),i]},this.scrollToOffset=(n,{align:i="start",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0;const o=this.getOffsetForAlignment(n,i),c=this.now();this.scrollState={index:null,align:i,behavior:r,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:i="auto",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0,n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getOffsetForIndex(n,i);if(!o)return;const[c,u]=o,d=this.now();this.scrollState={index:n,align:u,behavior:r,startedAt:d,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:i="auto"}={})=>{const r=this.getScrollOffset()+n,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:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const i=this.getMeasurements();let r;if(i.length===0)r=this.options.paddingStart;else if(this.options.lanes===1){const o=i.length-1,c=this._flatMeasurements;c!=null?r=c[o*2]+c[o*2+1]:r=((n=i[o])==null?void 0:n.end)??0}else{const o=Array(this.options.lanes).fill(null);let c=i.length-1;for(;c>=0&&o.some(u=>u===null);){const u=i[c];o[u.lane]===null&&(o[u.lane]=u.end),c--}r=Math.max(...o.filter(u=>u!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const i=this.getMeasurements();for(const r of i)r&&this.itemSizeCache.has(r.key)&&n.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return n},this._scrollToOffset=(n,{adjustments:i,behavior:r})=>{this._intendedScrollOffset=n+(i??0),this.options.scrollToFn(n,{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,n){return t===0?!1:Pm()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=t,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=i?i[0]:this.scrollState.lastTargetOffset,o=1,c=r!==this.scrollState.lastTargetOffset;if(!c&&h8(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,c){const u=this.getSize()||600,d=Math.abs(r-this.getScrollOffset()),h=this.scrollState.behavior==="smooth"&&d>u;this.scrollState.lastTargetOffset=r,h||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}}const rE=(e,t,n,i)=>{for(;e<=t;){const r=(e+t)/2|0,o=n(r);if(o<i)e=r+1;else if(o>i)t=r-1;else return r}return e>0?e-1:0};function w8(e,t,n){let i=0;for(;i<=t;){const r=(i+t)/2|0,o=e[r*2];if(o<n)i=r+1;else if(o>n)t=r-1;else return r}return i>0?i-1:0}function S8(e,t,n,i,r){const o=e.length-1;if(e.length<=i)return{startIndex:0,endIndex:o};if(i===1&&r!==null){const h=w8(r,o,n);let m=h;const g=n+t;for(;m<o&&r[m*2]+r[m*2+1]<g;)m++;return{startIndex:h,endIndex:m}}let u=rE(0,o,h=>e[h].start,n),d=u;if(i===1)for(;d<o&&e[d].end<n+t;)d++;else if(i>1){const h=Array(i).fill(0);for(;d<o&&h.some(g=>g<n+t);){const g=e[d];h[g.lane]=g.end,d++}const m=Array(i).fill(n+t);for(;u>=0&&m.some(g=>g>=n);){const g=e[u];m[g.lane]=g.start,u--}u=Math.max(0,u-u%i),d=Math.min(o,d+(i-1-d%i))}return{startIndex:u,endIndex:d}}const zm=typeof document<"u"?b.useLayoutEffect:b.useEffect;function _8({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...i}){const r=b.useReducer(m=>m+1,0)[1],o=b.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=n;const c=m=>{const g=o.current;if(!g.enabled||!g.container)return;const p=m.getTotalSize();if(p!==g.lastSize){g.lastSize=p;const x=m.options.horizontal?"width":"height";g.container.style[x]=`${p}px`}},u=m=>{const g=o.current;if(!g.enabled||!g.container)return;c(m);const p=!!m.options.horizontal,x=g.mode==="transform",y=p?"left":"top",S=m.options.scrollMargin,N=m.getVirtualItems();for(const k of N){const E=k.start-S,j=m.elementsCache.get(k.key);j&&g.lastPositions.get(j)!==E&&(g.lastPositions.set(j,E),x?j.style.transform=p?`translate3d(${E}px, 0, 0)`:`translate3d(0, ${E}px, 0)`:j.style[y]=`${E}px`)}},d={...i,onChange:(m,g)=>{var p;const x=o.current;let y=!0;if(x.enabled){u(m);const S=m.range,N=x.prevRange;y=!N||N.isScrolling!==m.isScrolling||N.startIndex!==(S==null?void 0:S.startIndex)||N.endIndex!==(S==null?void 0:S.endIndex),y&&(x.prevRange=S?{startIndex:S.startIndex,endIndex:S.endIndex,isScrolling:m.isScrolling}:null)}y&&(e&&g?Ud.flushSync(r):r()),(p=i.onChange)==null||p.call(i,m,g)}},[h]=b.useState(()=>{const m=new j8(d);return Object.assign(m,{containerRef:g=>{const p=o.current;if(p.container=g,p.lastSize=null,g&&p.enabled){const x=m.getTotalSize();p.lastSize=x;const y=m.options.horizontal?"width":"height";g.style[y]=`${x}px`}}})});return h.setOptions(d),zm(()=>h._didMount(),[]),zm(()=>(c(h),h._willUpdate())),zm(()=>{u(h)}),h}function E8(e){return _8({observeElementRect:g8,observeElementOffset:y8,scrollToFn:N8,...e})}const eh={user:"用户",context:"上下文",system:"系统",assistant:"助手",attempt:"失败尝试",tool:"工具",compaction:"压缩"},aE={ok:"已完成",error:"失败",running:"运行中",interrupted:"已中断"},C8={completed:"已完成",aborted:"已停止",error:"失败",blocked:"已阻止","max-tokens":"达到输出上限",interrupted:"已中断",forked:"已分叉"};function A8(e){return e.turn===null?"轮次之间":`第 ${e.turn} 轮`}function I8(e){return e.end===null?"进行中":e.reason===void 0?"":C8[e.reason.kind]??e.reason.kind}function oE(e){if(e.kind!=="assistant"||e.request.usage===void 0)return;const t=e.request.usage;return t.inputTokens+(t.cacheReadTokens??0)+(t.cacheWriteTokens??0)}function ec(e){return e.end===null||e.end<e.start?void 0:e.end-e.start}function Id(e){return e.kind==="assistant"?e.content.filter(t=>t.type==="tool-call").length:0}function T8({record:e,totals:t,onClose:n}){const i=M8(e,t),[r,o]=b.useState(i[0].id),c=i.find(u=>u.id===r)??i[0];return s.jsxs("aside",{className:"inspector","aria-label":"事件详情",children:[s.jsxs("header",{className:"inspector-head",children:[s.jsx("span",{className:`kind-badge kind-${e.kind}`,children:eh[e.kind]}),s.jsx("span",{className:"inspector-title",title:e.title,children:$8(e)}),s.jsx("button",{className:"ghost icon",onClick:n,"aria-label":"关闭详情",children:s.jsx(J,{name:"close"})})]}),s.jsx("nav",{className:"inspector-tabs",role:"tablist",children:i.map(u=>s.jsx("button",{role:"tab","aria-selected":u.id===c.id,className:u.id===c.id?"active":"",onClick:()=>o(u.id),children:u.label},u.id))}),s.jsx("div",{className:"inspector-body",children:c.render()})]})}function $8(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 M8(e,t){switch(e.kind){case"assistant":return[{id:"summary",label:"概述",render:()=>s.jsx(R8,{record:e})},{id:"raw",label:"原始输出",render:()=>s.jsx(Lm,{content:e.content})},{id:"usage",label:"用量",render:()=>s.jsx(O8,{record:e,totals:t})},{id:"timing",label:"计时",render:()=>s.jsx(P8,{record:e})}];case"tool":return[{id:"summary",label:"概述",render:()=>s.jsx(Yr,{rows:[["状态",s.jsx(rd,{record:e})],["工具",s.jsx("code",{children:e.name})],["调用 ID",s.jsx("code",{children:e.callId})],["开始时间",qr(e.start)],["时长",e.end===null?"运行中":Rs(ec(e))],["审批",e.approval===void 0?"无需审批":e.approval.outcome??"等待中"],["错误",e.error===void 0?void 0:`${e.error.message}${e.error.code===void 0?"":` (${e.error.code})`}`]]})},{id:"payload",label:"参数",render:()=>s.jsx("pre",{className:"payload",children:e.arguments===""?"未捕获参数":Eg(e.arguments)})},{id:"result",label:"结果",render:()=>e.result===void 0?s.jsx("p",{className:"muted",children:"未捕获结果"}):s.jsx(Lm,{content:e.result})}];case"user":case"context":return[{id:"summary",label:"概述",render:()=>s.jsxs(s.Fragment,{children:[s.jsx(Yr,{rows:[["来源",e.origin.human?"用户":e.origin.kind],["时间",qr(e.start)],["附件",e.imageCount+e.fileCount===0?void 0:`图片 ×${e.imageCount} · 文件 ×${e.fileCount}`]]}),s.jsx("div",{className:"label",children:"预览"}),s.jsx(Lm,{content:e.content})]})},{id:"raw",label:"原始内容",render:()=>s.jsx("pre",{className:"payload",children:JSON.stringify(e.content,null,2)})}];case"system":return[{id:"prompt",label:"系统提示词",render:()=>s.jsx("pre",{className:"payload",children:e.text})}];case"attempt":return[{id:"summary",label:"概述",render:()=>s.jsx(Yr,{rows:[["状态",s.jsx(rd,{record:e})],["开始时间",qr(e.start)],["时长",Rs(ec(e))],["错误",e.error===void 0?"尝试在没有输出的情况下结束":`${e.error.message}${e.error.code===void 0?"":` (${e.error.code})`}`]]})}];case"compaction":return[{id:"summary",label:"概述",render:()=>s.jsx(Yr,{rows:[["状态",s.jsx(rd,{record:e})],["开始时间",qr(e.start)],["时长",e.end===null?"运行中":Rs(ec(e))],["已压缩",e.shadowedTokenCount===void 0?void 0:`${yn(e.shadowedTokenCount)} tok`],["输入 / 输出",e.usage===void 0?void 0:`${yn(e.usage.inputTokens)} / ${yn(e.usage.outputTokens)} tok`],["错误",e.error]]})}]}}function rd({record:e}){return s.jsx("span",{className:`status-text status-${e.status}`,children:aE[e.status]})}function Yr({rows:e}){return s.jsx("dl",{className:"facts",children:e.filter(([,t])=>t!==void 0&&t!=="").map(([t,n])=>s.jsxs("div",{className:"fact",children:[s.jsx("dt",{children:t}),s.jsx("dd",{children:n})]},t))})}function R8({record:e}){const t=e.request,n=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 s.jsxs(s.Fragment,{children:[s.jsx(Yr,{rows:[["状态",s.jsx(rd,{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})`}`]]}),n.trim()!==""&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"label",children:"助手消息"}),s.jsx(Js,{text:n,className:"inspector-markdown"})]}),n.trim()===""&&i.length>0&&s.jsx("p",{className:"muted small",children:"(仅工具调用)"}),i.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"label",children:"工具调用"}),s.jsx("ul",{className:"call-list",children:i.map(r=>s.jsxs("li",{children:[s.jsx("code",{children:r.name})," ",s.jsx("span",{className:"muted",children:r.arguments.slice(0,120)})]},r.callId))})]})]})}function Lm({content:e}){return e.length===0?s.jsx("p",{className:"muted",children:"无内容"}):s.jsx("div",{className:"raw-blocks",children:e.map((t,n)=>{switch(t.type){case"reasoning":return s.jsxs("details",{className:"raw-block reasoning-block",children:[s.jsx("summary",{children:"思考"}),s.jsx(Js,{text:t.text,className:"inspector-markdown"})]},n);case"text":return s.jsx("pre",{className:"payload",children:t.text},n);case"tool-call":return s.jsxs("div",{className:"raw-block",children:[s.jsxs("div",{className:"label",children:["工具调用 · ",s.jsx("code",{children:t.name})]}),s.jsx("pre",{className:"payload",children:Eg(t.arguments)})]},n);case"image":return s.jsxs("div",{className:"raw-block muted small",children:["🖼 ",t.name??`图片 ${n+1}`," ",t.width!==void 0?`${t.width}×${t.height}`:""]},n);case"file":return s.jsxs("div",{className:"raw-block muted small",children:["📎 ",t.name??"文件"," ",t.size===void 0?"":`${yn(t.size)}B`]},n);default:return s.jsxs("div",{className:"raw-block muted small",children:["[",t.kind,"]"]},n)}})})}function O8({record:e,totals:t}){const n=e.request.usage;return s.jsxs(s.Fragment,{children:[s.jsx("h4",{className:"usage-heading",children:"本次请求"}),n===void 0?s.jsx("p",{className:"muted",children:"未报告用量"}):s.jsx(Yr,{rows:[["输入(未缓存)",`${yn(n.inputTokens)} tok`],["缓存读取",n.cacheReadTokens===void 0?void 0:`${yn(n.cacheReadTokens)} tok`],["缓存写入",n.cacheWriteTokens===void 0?void 0:`${yn(n.cacheWriteTokens)} tok`],["输入合计",`${yn(oE(e))} tok`],["输出",`${yn(n.outputTokens)} tok`],["其中推理",n.reasoningTokens===void 0?void 0:`${yn(n.reasoningTokens)} tok`],["总计",n.totalTokens===void 0?void 0:`${yn(n.totalTokens)} tok`]]}),s.jsx("h4",{className:"usage-heading",children:"已加载窗口累计"}),s.jsx(Yr,{rows:[["请求数",String(t.requests)],["输入(未缓存)",`${yn(t.inputTokens)} tok`],["缓存读取",`${yn(t.cacheReadTokens)} tok`],["输出",`${yn(t.outputTokens)} tok`],["其中推理",`${yn(t.reasoningTokens)} tok`]]})]})}function P8({record:e}){const[t,n]=b.useState(!1),i=e.request;return s.jsx(Yr,{rows:[["开始时间",s.jsx("button",{className:"link-button",onClick:()=>n(r=>!r),title:t?"显示本地时间":"显示 Unix 时间戳",children:t?String(e.start):qr(e.start)})],["总时长",e.end===null?"运行中":Rs(ec(e))],["首 token 延迟",i.ttftMs===void 0?"不可用(步骤开始时间或首 token 不在已加载范围内)":Rs(i.ttftMs)],["生成",i.decodeMs===void 0?e.live?"运行中":"不可用":Rs(i.decodeMs)],["吞吐量",i.tokensPerSecond===void 0?i.usage===void 0?"用量不可用":"时长过短":`${i.tokensPerSecond.toFixed(1)} tok/s`],["工具调用",Id(e)===0?void 0:String(Id(e))],["计时来源",e.live?"会话时间戳(运行中)":"会话时间戳"]]})}const qu=14,z8=b.memo(function({model:t,mode:n,brush:i,selectedId:r,onBrush:o,onSelect:c}){const u=b.useMemo(()=>Az(t),[t]),d=b.useMemo(()=>Aw.map((z,D)=>({...z,index:D})).filter(z=>z.id!=="compaction"||u.some(D=>D.lane===z.index)),[u]),h=new Map(d.map((z,D)=>[z.index,D])),m=t.span,[g,p]=b.useState(null),x=n==="actual"&&m!==null?L8(g,m):null,y=b.useRef(null),[S,N]=b.useState(null),k=b.useRef(null),E=t.records.length,j=(z,D)=>n==="equal"?E===0?0:z/E:x===null||x.end===x.start?0:(D-x.start)/(x.end-x.start),A=z=>{var U;const D=(U=y.current)==null?void 0:U.getBoundingClientRect();return D===void 0||D.width===0?0:Math.min(1,Math.max(0,(z-D.left)/D.width))},P=z=>{if(z.button===2&&x!==null&&m!==null&&(x.start>m.start||x.end<m.end)){k.current={x:z.clientX,view:x};return}if(z.button!==0)return;const D=A(z.clientX);N({x0:D,x1:D})},L=z=>{if(k.current!==null&&m!==null&&y.current!==null){const D=(z.clientX-k.current.x)/y.current.clientWidth,U=k.current.view.end-k.current.view.start;p($z(k.current.view,-D*U,m));return}S!==null&&N({...S,x1:A(z.clientX)})},B=()=>{if(k.current=null,S===null)return;const[z,D]=S.x0<S.x1?[S.x0,S.x1]:[S.x1,S.x0];if(N(null),!(D-z<.005)){if(n==="equal")o({mode:"equal",from:Math.floor(z*E),to:Math.max(Math.floor(z*E),Math.ceil(D*E)-1)});else if(x!==null){const U=x.end-x.start;o({mode:"actual",range:{start:x.start+z*U,end:x.start+D*U}})}}},V=z=>{if(n!=="actual"||x===null||m===null)return;const D=x.end-x.start;p(Tz(x,x.start+A(z.clientX)*D,z.deltaY>0?1.25:.8,m))};if(E===0||m===null)return s.jsx("div",{className:"overview empty-overview muted small",children:"无计时数据"});const M=i===null?null:i.mode==="equal"?n==="equal"?{left:i.from/E,right:(i.to+1)/E}:null:n==="actual"?{left:j(0,i.range.start),right:j(0,i.range.end)}:null;return s.jsxs("div",{className:"overview",onContextMenu:z=>{z.preventDefault(),k.current===null&&o(null)},children:[s.jsx("div",{className:"overview-lanes",children:d.map(z=>s.jsx("div",{className:"lane-label",style:{height:qu},children:D8(z.id)},z.id))}),s.jsxs("div",{className:"overview-track",ref:y,style:{height:d.length*(qu+2)},onMouseDown:P,onMouseMove:L,onMouseUp:B,onMouseLeave:B,onWheel:V,children:[u.map((z,D)=>{const U=h.get(z.lane)??0,I=j(D,z.start),T=n==="equal"?(D+1)/E:j(D,z.end);if(T<0||I>1)return null;const O=z.record,$=Math.max(0,Math.min(1,T)-Math.max(0,I)),F=n==="actual"&&z.firstTokenAt!==void 0&&z.end>z.start?(z.firstTokenAt-z.start)/(z.end-z.start):null;return s.jsx("div",{className:`bar kind-${O.kind} status-${O.status} ${z.instant&&n==="actual"?"instant":""} ${O.id===r?"selected":""}`,style:{left:`${Math.max(0,I)*100}%`,width:n==="equal"?`calc(${$*100}% - 1px)`:`max(2px, ${$*100}%)`,top:U*(qu+2),height:qu,...F===null?{}:{"--ttft":`${Math.min(100,Math.max(0,F*100))}%`}},title:F8(O,z.firstTokenAt),onMouseUp:H=>{S!==null&&Math.abs(S.x1-S.x0)<.005&&H.button===0&&c(O)}},O.id)}),M!==null&&s.jsx("div",{className:"brush",style:{left:`${Math.max(0,M.left)*100}%`,width:`${(Math.min(1,M.right)-Math.max(0,M.left))*100}%`}}),S!==null&&s.jsx("div",{className:"brush dragging",style:{left:`${Math.min(S.x0,S.x1)*100}%`,width:`${Math.abs(S.x1-S.x0)*100}%`}})]}),s.jsx("div",{className:"overview-scale muted",children:n==="actual"&&x!==null?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:qr(x.start)}),s.jsxs("span",{children:["总计 ",Rs(m.end-m.start),g!==null?" · 已缩放":""]}),s.jsx("span",{children:qr(x.end)})]}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:[E," 条记录(等宽)"]}),s.jsxs("span",{children:["总计 ",Rs(m.end-m.start)]}),s.jsx("span",{children:"拖动选择区间 · 右键清除"})]})})]})});function L8(e,t){if(e===null)return t;const n=Math.max(t.start,e.start),i=Math.min(t.end,e.end);return i>n?{start:n,end:i}:t}function D8(e){return e==="input"?"输入":e==="model"?"模型":e==="tool"?"工具":"压缩"}function F8(e,t){const n=[`${eh[e.kind]} · ${e.title}`,`开始于 ${qr(e.start)}`];return e.end===null?n.push("进行中(只显示开始标记)"):n.push(`总计 ${Rs(e.end-e.start)}`),e.kind==="assistant"&&t!==void 0&&e.end!==null&&n.push(`首 token ${Rs(t-e.start)} · 解码 ${Rs(e.end-t)}`),n.join(`
241
+ `)}const U8=32,B8=34,H8=60;function Z8({session:e,state:t}){const n=b.useMemo(()=>Nz(t.events,t.live,{now:Date.now()}),[t.events,t.live,t.version]),[i,r]=b.useState("equal"),[o,c]=b.useState(null),[u,d]=b.useState(""),[h,m]=b.useState(new Set),[g,p]=b.useState(!0),[x,y]=b.useState(null),S=n.records.find(z=>z.id===x)??null,N=b.useMemo(()=>W8(n,{brush:o,query:u,collapsed:h,showCalls:g}),[n,o,u,h,g]),k=b.useMemo(()=>N.flatMap(z=>z.type==="record"?[z.record]:[]),[N]),E=b.useRef(null),j=Cw(H8),A=j.following,P=E8({count:N.length,getScrollElement:()=>E.current,estimateSize:z=>{var D;return((D=N[z])==null?void 0:D.type)==="group"?B8:U8},getItemKey:z=>{var D;return((D=N[z])==null?void 0:D.key)??z},overscan:12});b.useLayoutEffect(()=>{A.current&&N.length>0&&P.scrollToIndex(N.length-1,{align:"end"})},[N.length,t.version,P]),b.useEffect(()=>{if(x===null)return;const z=N.findIndex(D=>D.type==="record"&&D.record.id===x);z!==-1&&P.scrollToIndex(z,{align:"auto"})},[x]);const L=z=>m(D=>{const U=new Set(D);return U.has(z)?U.delete(z):U.add(z),U}),B=n.groups.length>0&&n.groups.every(z=>h.has(z.key)),V=z=>{if(z.key!=="ArrowDown"&&z.key!=="ArrowUp"&&z.key!=="Escape")return;if(z.preventDefault(),z.key==="Escape"){y(null);return}const D=k.findIndex(I=>I.id===x),U=k[z.key==="ArrowDown"?Math.min(k.length-1,D+1):Math.max(0,D-1)];U!==void 0&&y(U.id)},M=n.totals;return s.jsxs("div",{className:"trajectory",children:[s.jsxs("div",{className:"traj-toolbar",role:"toolbar","aria-label":"轨迹工具栏",children:[s.jsxs("button",{className:`toggle ${i==="actual"?"on":""}`,onClick:()=>{r(z=>z==="equal"?"actual":"equal"),c(null)},title:i==="equal"?"使用实际时长":"使用等宽操作",children:["⏱ ",i==="equal"?"等宽":"实际时间"]}),s.jsxs("button",{className:"toggle",onClick:()=>m(B?new Set:new Set(n.groups.map(z=>z.key))),children:["⊟ ",B?"展开所有轮次":"收起所有轮次"]}),s.jsxs("button",{className:`toggle ${g?"":"on"}`,onClick:()=>p(z=>!z),children:["⊟ ",g?"收起所有调用":"展开所有调用"]}),s.jsx("input",{className:"traj-search",value:u,onChange:z=>d(z.target.value),placeholder:"搜索轨迹","aria-label":"搜索轨迹"}),s.jsxs("span",{className:"traj-totals muted small",title:"已加载窗口内的累计",children:[M.requests," 次请求 · 输入 ",yn(M.inputTokens+M.cacheReadTokens+M.cacheWriteTokens)," · 输出 ",yn(M.outputTokens)," · ",M.toolCalls," 次工具调用",M.errors>0?` · ${M.errors} 个错误`:""]})]}),s.jsx(z8,{model:n,mode:i,brush:o,selectedId:x,onBrush:c,onSelect:z=>y(z.id)}),o!==null&&s.jsxs("div",{className:"brush-note small",children:["已按时间区间筛选,显示 ",k.length," 条记录 ",s.jsx("button",{className:"link-button",onClick:()=>c(null),children:"清除"})]}),s.jsxs("div",{className:"traj-main",children:[s.jsxs("div",{className:"ledger",ref:E,onScroll:j.onScroll,onWheel:j.onWheel,tabIndex:0,onKeyDown:V,role:"grid","aria-label":"轨迹事件表",children:[s.jsxs("div",{className:"ledger-head",role:"row",children:[s.jsx("span",{}),s.jsx("span",{children:"类型"}),s.jsx("span",{children:"内容"}),s.jsx("span",{className:"num",children:"输入"}),s.jsx("span",{className:"num",children:"输出"}),s.jsx("span",{className:"num",children:"思考"}),s.jsx("span",{className:"num",children:"时间"}),s.jsx("span",{children:"模型"}),s.jsx("span",{className:"num",children:"工具"})]}),t.hasMore&&s.jsx("button",{className:"link-button load-older",disabled:t.loadingOlder,onClick:()=>void e.loadOlder(),children:t.loadingOlder?"正在加载更早的历史…":"加载更早的历史"}),N.length===0&&s.jsx("div",{className:"empty",children:t.status==="opening"?"正在加载轨迹…":u!==""?"没有匹配的记录":"还没有记录"}),s.jsx("div",{style:{height:P.getTotalSize(),position:"relative"},children:P.getVirtualItems().map(z=>{const D=N[z.index];return s.jsx("div",{className:"vrow",style:{transform:`translateY(${z.start}px)`,height:z.size},children:D.type==="group"?s.jsx(V8,{row:D,onToggle:()=>L(D.group.key)}):s.jsx(q8,{row:D,selected:D.record.id===x,onSelect:()=>y(U=>U===D.record.id?null:D.record.id)})},z.key)})})]}),S!==null&&s.jsx(T8,{record:S,totals:n.totals,onClose:()=>y(null)},S.id)]})]})}function W8(e,t){const n=new Set;let i=e.records;if(t.brush!==null){const c=t.brush;i=c.mode==="equal"?i.slice(c.from,c.to+1):i.filter(u=>Iz(u,c.range))}for(const c of Mz(i,t.query))n.add(c.id);const r=t.brush!==null||t.query.trim()!=="",o=[];for(const c of e.groups){const u=c.records.filter(m=>n.has(m.id)&&(t.showCalls||m.kind!=="tool"));if(r&&u.length===0)continue;const d=t.collapsed.has(c.key);if(o.push({type:"group",key:`g:${c.key}`,group:c,collapsed:d,matches:u.length}),d)continue;let h=null;for(const m of u){const g=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:g})}}return o}const V8=b.memo(function({row:t,onToggle:n}){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,c=I8(i);return s.jsxs("button",{className:`group-row ${i.end===null?"open":""} reason-${((u=i.reason)==null?void 0:u.kind)??"none"}`,onClick:n,"aria-expanded":!t.collapsed,children:[s.jsx("span",{className:"chevron",children:t.collapsed?"▸":"▾"}),s.jsx("span",{className:"group-title",children:A8(i)}),s.jsxs("span",{className:"muted small",children:[i.steps.length>0&&`${i.steps.length} 个步骤`,r>0&&` · ${r} 个工具调用`,o!==null&&` · ${Rs(o)}`,i.partialStart&&" · 开头在已加载范围之外"]}),c!==""&&s.jsx("span",{className:`group-reason reason-${i.end===null?"running":((d=i.reason)==null?void 0:d.kind)??"none"}`,children:c})]})}),q8=b.memo(function({row:t,selected:n,onSelect:i}){var u;const r=t.record,o=r.kind==="assistant",c=ec(r);return s.jsxs("div",{className:`record-row kind-${r.kind} status-${r.status} ${n?"selected":""} ${t.stepStart!==null?"step-start":""}`,onClick:i,role:"row","aria-selected":n,children:[s.jsx("span",{className:"gutter muted",children:t.stepStart!==null?`第 ${t.stepStart} 步`:""}),s.jsx("span",{children:s.jsx("span",{className:`kind-badge kind-${r.kind}`,children:o?`#${r.request.index}`:eh[r.kind]})}),s.jsxs("span",{className:"record-content",title:r.preview,children:[r.status==="running"&&s.jsx("span",{className:"running-dot"}),r.status==="error"&&s.jsxs("span",{className:"status-text status-error",children:[aE.error," · "]}),r.kind==="tool"?s.jsxs(s.Fragment,{children:[s.jsx("code",{className:"tool-name-inline",children:r.name})," ",s.jsx("span",{className:"muted",children:r.preview})]}):r.preview||s.jsx("span",{className:"muted",children:"(无内容)"})]}),s.jsx("span",{className:"num",children:o?yn(oE(r)):""}),s.jsx("span",{className:"num",children:o&&r.request.usage!==void 0?yn(r.request.usage.outputTokens):""}),s.jsx("span",{className:"num",children:o&&((u=r.request.usage)==null?void 0:u.reasoningTokens)!==void 0?yn(r.request.usage.reasoningTokens):""}),s.jsx("span",{className:"num",children:r.status==="running"?"…":c!==void 0&&(o||r.kind==="tool"||r.kind==="compaction"||r.kind==="attempt")?Rs(c):""}),s.jsx("span",{className:"model-cell",children:o?r.request.model??"":""}),s.jsx("span",{className:"num",children:o&&Id(r)>0?Id(r):""})]})}),G8={id:"trajectory",title:"轨迹",requires:["sessions"],sessionViews:[{id:"trajectory",title:"轨迹",order:10,component:Z8}]};hw();Pn(JL);Pn(G8);Pn(s8);Pn(i8);Pn(r8);Pn(o8);Pn(a8);Pn(l8);Pn(u8);Pn(b9);Pn(k9);Pn(vD);Pn(yD);Pn(Q5);Pn(J5);Pn(CH);Pn(HH);for(const e of eD)Pn(e);const lE=W1.createRoot(document.getElementById("root"));function Dm(e){const t=new LR({url:SP(e),clientInfo:{name:"adg-web",version:"0.1.0"}});t.start(),lE.render(s.jsxs(YL,{children:[s.jsx(UL,{client:t}),s.jsx(KL,{client:t}),s.jsx(FP,{}),s.jsx(QL,{})]}))}const Kk=wg?null:tw();wg?Dm(null):Kk===null?lE.render(s.jsx(WL,{onSubmit:e=>{wP(e),Dm(e)}})):Dm(Kk);
242
+ //# sourceMappingURL=index-BuStplKb.js.map