From 02dfdcd8b0bd5450940cb9686b6d2eb890775f04 Mon Sep 17 00:00:00 2001 From: cft0808 Date: Mon, 16 Mar 2026 22:08:33 +0800 Subject: [PATCH] fix: resolve open GitHub issues (#142 #139 #136 #131 #127 #124 #132 #125) - install.sh: clean invalid binding 'pattern' field (Closes #142) - server.py: make dispatch channel configurable via agent_config.json (Closes #139) - server.py: add POST /api/set-dispatch-channel endpoint - sync_agent_config.py: preserve dispatchChannel across syncs - ModelConfig.tsx/api.ts: add dispatch channel selector UI - install.ps1: add Windows PowerShell install script (Closes #136) - Verify gongbu/bingbu SOUL.md are correct and consistent (Closes #131) - Already fixed in prior commit: Closes #127, Closes #124, Closes #132, Closes #125 --- .../{index-J5u1Q_A5.js => index-DQ-p_wPk.js} | 54 +-- dashboard/dist/index.html | 2 +- dashboard/server.py | 18 +- edict/frontend/src/api.ts | 3 + edict/frontend/src/components/ModelConfig.tsx | 39 +++ install.ps1 | 308 ++++++++++++++++++ install.sh | 13 + scripts/sync_agent_config.py | 10 + 8 files changed, 418 insertions(+), 29 deletions(-) rename dashboard/dist/assets/{index-J5u1Q_A5.js => index-DQ-p_wPk.js} (56%) create mode 100644 install.ps1 diff --git a/dashboard/dist/assets/index-J5u1Q_A5.js b/dashboard/dist/assets/index-DQ-p_wPk.js similarity index 56% rename from dashboard/dist/assets/index-J5u1Q_A5.js rename to dashboard/dist/assets/index-DQ-p_wPk.js index 981e4c8..43a3e18 100644 --- a/dashboard/dist/assets/index-J5u1Q_A5.js +++ b/dashboard/dist/assets/index-DQ-p_wPk.js @@ -1,4 +1,4 @@ -(function(){const f=document.createElement("link").relList;if(f&&f.supports&&f.supports("modulepreload"))return;for(const x of document.querySelectorAll('link[rel="modulepreload"]'))y(x);new MutationObserver(x=>{for(const L of x)if(L.type==="childList")for(const T of L.addedNodes)T.tagName==="LINK"&&T.rel==="modulepreload"&&y(T)}).observe(document,{childList:!0,subtree:!0});function c(x){const L={};return x.integrity&&(L.integrity=x.integrity),x.referrerPolicy&&(L.referrerPolicy=x.referrerPolicy),x.crossOrigin==="use-credentials"?L.credentials="include":x.crossOrigin==="anonymous"?L.credentials="omit":L.credentials="same-origin",L}function y(x){if(x.ep)return;x.ep=!0;const L=c(x);fetch(x.href,L)}})();function Zi(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var $i={exports:{}},Tr={},Fi={exports:{}},ge={};/** +(function(){const f=document.createElement("link").relList;if(f&&f.supports&&f.supports("modulepreload"))return;for(const g of document.querySelectorAll('link[rel="modulepreload"]'))v(g);new MutationObserver(g=>{for(const P of g)if(P.type==="childList")for(const L of P.addedNodes)L.tagName==="LINK"&&L.rel==="modulepreload"&&v(L)}).observe(document,{childList:!0,subtree:!0});function c(g){const P={};return g.integrity&&(P.integrity=g.integrity),g.referrerPolicy&&(P.referrerPolicy=g.referrerPolicy),g.crossOrigin==="use-credentials"?P.credentials="include":g.crossOrigin==="anonymous"?P.credentials="omit":P.credentials="same-origin",P}function v(g){if(g.ep)return;g.ep=!0;const P=c(g);fetch(g.href,P)}})();function Zi(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var $i={exports:{}},Tr={},Fi={exports:{}},ge={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Qc;function mf(){if(Qc)return ge;Qc=1;var o=Symbol.for("react.element"),f=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),L=Symbol.for("react.provider"),T=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),C=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),d=Symbol.iterator;function w(v){return v===null||typeof v!="object"?null:(v=d&&v[d]||v["@@iterator"],typeof v=="function"?v:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},R=Object.assign,g={};function A(v,D,de){this.props=v,this.context=D,this.refs=g,this.updater=de||m}A.prototype.isReactComponent={},A.prototype.setState=function(v,D){if(typeof v!="object"&&typeof v!="function"&&v!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,v,D,"setState")},A.prototype.forceUpdate=function(v){this.updater.enqueueForceUpdate(this,v,"forceUpdate")};function P(){}P.prototype=A.prototype;function W(v,D,de){this.props=v,this.context=D,this.refs=g,this.updater=de||m}var J=W.prototype=new P;J.constructor=W,R(J,A.prototype),J.isPureReactComponent=!0;var I=Array.isArray,oe=Object.prototype.hasOwnProperty,ue={current:null},me={key:!0,ref:!0,__self:!0,__source:!0};function pe(v,D,de){var he,k={},H=null,ne=null;if(D!=null)for(he in D.ref!==void 0&&(ne=D.ref),D.key!==void 0&&(H=""+D.key),D)oe.call(D,he)&&!me.hasOwnProperty(he)&&(k[he]=D[he]);var ve=arguments.length-2;if(ve===1)k.children=de;else if(1>>1,D=E[v];if(0>>1;vx(k,U))Hx(ne,k)?(E[v]=ne,E[H]=U,v=H):(E[v]=k,E[he]=U,v=he);else if(Hx(ne,U))E[v]=ne,E[H]=U,v=H;else break e}}return K}function x(E,K){var U=E.sortIndex-K.sortIndex;return U!==0?U:E.id-K.id}if(typeof performance=="object"&&typeof performance.now=="function"){var L=performance;o.unstable_now=function(){return L.now()}}else{var T=Date,_=T.now();o.unstable_now=function(){return T.now()-_}}var b=[],C=[],z=1,d=null,w=3,m=!1,R=!1,g=!1,A=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,W=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(E){for(var K=c(C);K!==null;){if(K.callback===null)y(C);else if(K.startTime<=E)y(C),K.sortIndex=K.expirationTime,f(b,K);else break;K=c(C)}}function I(E){if(g=!1,J(E),!R)if(c(b)!==null)R=!0,Ee(oe);else{var K=c(C);K!==null&&je(I,K.startTime-E)}}function oe(E,K){R=!1,g&&(g=!1,P(pe),pe=-1),m=!0;var U=w;try{for(J(K),d=c(b);d!==null&&(!(d.expirationTime>K)||E&&!ie());){var v=d.callback;if(typeof v=="function"){d.callback=null,w=d.priorityLevel;var D=v(d.expirationTime<=K);K=o.unstable_now(),typeof D=="function"?d.callback=D:d===c(b)&&y(b),J(K)}else y(b);d=c(b)}if(d!==null)var de=!0;else{var he=c(C);he!==null&&je(I,he.startTime-K),de=!1}return de}finally{d=null,w=U,m=!1}}var ue=!1,me=null,pe=-1,Ae=5,X=-1;function ie(){return!(o.unstable_now()-XE||125v?(E.sortIndex=U,f(C,E),c(b)===null&&E===c(C)&&(g?(P(pe),pe=-1):g=!0,je(I,U-v))):(E.sortIndex=D,f(b,E),R||m||(R=!0,Ee(oe))),E},o.unstable_shouldYield=ie,o.unstable_wrapCallback=function(E){var K=w;return function(){var U=w;w=K;try{return E.apply(this,arguments)}finally{w=U}}}})(Ui)),Ui}var Zc;function yf(){return Zc||(Zc=1,Wi.exports=gf()),Wi.exports}/** + */var Xc;function gf(){return Xc||(Xc=1,(function(o){function f(_,G){var U=_.length;_.push(G);e:for(;0>>1,I=_[h];if(0>>1;hg(y,U))Hg(ne,y)?(_[h]=ne,_[H]=U,h=H):(_[h]=y,_[he]=U,h=he);else if(Hg(ne,U))_[h]=ne,_[H]=U,h=H;else break e}}return G}function g(_,G){var U=_.sortIndex-G.sortIndex;return U!==0?U:_.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var P=performance;o.unstable_now=function(){return P.now()}}else{var L=Date,z=L.now();o.unstable_now=function(){return L.now()-z}}var T=[],E=[],b=1,d=null,N=3,j=!1,O=!1,S=!1,M=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function V(_){for(var G=c(E);G!==null;){if(G.callback===null)v(E);else if(G.startTime<=_)v(E),G.sortIndex=G.expirationTime,f(T,G);else break;G=c(E)}}function R(_){if(S=!1,V(_),!O)if(c(T)!==null)O=!0,Ee(re);else{var G=c(E);G!==null&&je(R,G.startTime-_)}}function re(_,G){O=!1,S&&(S=!1,x(pe),pe=-1),j=!0;var U=N;try{for(V(G),d=c(T);d!==null&&(!(d.expirationTime>G)||_&&!oe());){var h=d.callback;if(typeof h=="function"){d.callback=null,N=d.priorityLevel;var I=h(d.expirationTime<=G);G=o.unstable_now(),typeof I=="function"?d.callback=I:d===c(T)&&v(T),V(G)}else v(T);d=c(T)}if(d!==null)var fe=!0;else{var he=c(E);he!==null&&je(R,he.startTime-G),fe=!1}return fe}finally{d=null,N=U,j=!1}}var ue=!1,me=null,pe=-1,Ae=5,Z=-1;function oe(){return!(o.unstable_now()-Z_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Ae=0<_?Math.floor(1e3/_):5},o.unstable_getCurrentPriorityLevel=function(){return N},o.unstable_getFirstCallbackNode=function(){return c(T)},o.unstable_next=function(_){switch(N){case 1:case 2:case 3:var G=3;break;default:G=N}var U=N;N=G;try{return _()}finally{N=U}},o.unstable_pauseExecution=function(){},o.unstable_requestPaint=function(){},o.unstable_runWithPriority=function(_,G){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var U=N;N=_;try{return G()}finally{N=U}},o.unstable_scheduleCallback=function(_,G,U){var h=o.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0h?(_.sortIndex=U,f(E,_),c(T)===null&&_===c(E)&&(S?(x(pe),pe=-1):S=!0,je(R,U-h))):(_.sortIndex=I,f(T,_),O||j||(O=!0,Ee(re))),_},o.unstable_shouldYield=oe,o.unstable_wrapCallback=function(_){var G=N;return function(){var U=N;N=G;try{return _.apply(this,arguments)}finally{N=U}}}})(Ui)),Ui}var Zc;function yf(){return Zc||(Zc=1,Wi.exports=gf()),Wi.exports}/** * @license React * react-dom.production.min.js * @@ -30,14 +30,14 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Jc;function xf(){if(Jc)return it;Jc=1;var o=Rr(),f=yf();function c(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),b=Object.prototype.hasOwnProperty,C=/^[: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]*$/,z={},d={};function w(e){return b.call(d,e)?!0:b.call(z,e)?!1:C.test(e)?d[e]=!0:(z[e]=!0,!1)}function m(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function R(e,t,n,r){if(t===null||typeof t>"u"||m(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function g(e,t,n,r,s,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var A={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){A[e]=new g(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];A[t]=new g(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){A[e]=new g(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){A[e]=new g(e,2,!1,e,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(e){A[e]=new g(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){A[e]=new g(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){A[e]=new g(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){A[e]=new g(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){A[e]=new g(e,5,!1,e.toLowerCase(),null,!1,!1)});var P=/[\-:]([a-z])/g;function W(e){return e[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(e){var t=e.replace(P,W);A[t]=new g(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(P,W);A[t]=new g(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(P,W);A[t]=new g(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){A[e]=new g(e,1,!1,e.toLowerCase(),null,!1,!1)}),A.xlinkHref=new g("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){A[e]=new g(e,1,!1,e.toLowerCase(),null,!0,!0)});function J(e,t,n,r){var s=A.hasOwnProperty(t)?A[t]:null;(s!==null?s.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),T=Object.prototype.hasOwnProperty,E=/^[: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]*$/,b={},d={};function N(e){return T.call(d,e)?!0:T.call(b,e)?!1:E.test(e)?d[e]=!0:(b[e]=!0,!1)}function j(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function O(e,t,n,r){if(t===null||typeof t>"u"||j(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function S(e,t,n,r,s,i,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=a}var M={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){M[e]=new S(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];M[t]=new S(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){M[e]=new S(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){M[e]=new S(e,2,!1,e,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(e){M[e]=new S(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){M[e]=new S(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){M[e]=new S(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){M[e]=new S(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){M[e]=new S(e,5,!1,e.toLowerCase(),null,!1,!1)});var x=/[\-:]([a-z])/g;function A(e){return e[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(e){var t=e.replace(x,A);M[t]=new S(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(x,A);M[t]=new S(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(x,A);M[t]=new S(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){M[e]=new S(e,1,!1,e.toLowerCase(),null,!1,!1)}),M.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){M[e]=new S(e,1,!1,e.toLowerCase(),null,!0,!0)});function V(e,t,n,r){var s=M.hasOwnProperty(t)?M[t]:null;(s!==null?s.type!==0:r||!(2u||s[a]!==i[u]){var p=` -`+s[a].replace(" at new "," at ");return e.displayName&&p.includes("")&&(p=p.replace("",e.displayName)),p}while(1<=a&&0<=u);break}}}finally{de=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?D(e):""}function k(e){switch(e.tag){case 5:return D(e.type);case 16:return D("Lazy");case 13:return D("Suspense");case 19:return D("SuspenseList");case 0:case 2:case 15:return e=he(e.type,!1),e;case 11:return e=he(e.type.render,!1),e;case 1:return e=he(e.type,!0),e;default:return""}}function H(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case me:return"Fragment";case ue:return"Portal";case Ae:return"Profiler";case pe:return"StrictMode";case re:return"Suspense";case te:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ie:return(e.displayName||"Context")+".Consumer";case X:return(e._context.displayName||"Context")+".Provider";case ke:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ne:return t=e.displayName||null,t!==null?t:H(e.type)||"Memo";case Ee:t=e._payload,e=e._init;try{return H(e(t))}catch{}}return null}function ne(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return H(t);case 8:return t===pe?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function ve(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function M(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ce(e){var t=M(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ye(e){e._valueTracker||(e._valueTracker=ce(e))}function Be(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=M(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ke(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function et(e,t){var n=t.checked;return U({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function sn(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ve(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ct(e,t){t=t.checked,t!=null&&J(e,"checked",t,!1)}function Kl(e,t){Ct(e,t);var n=ve(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Gl(e,t.type,n):t.hasOwnProperty("defaultValue")&&Gl(e,t.type,ve(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function eo(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Gl(e,t,n){(t!=="number"||Ke(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Vn=Array.isArray;function kn(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=Ir.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Qn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Kn={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},gu=["Webkit","ms","Moz","O"];Object.keys(Kn).forEach(function(e){gu.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Kn[t]=Kn[e]})});function io(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Kn.hasOwnProperty(e)&&Kn[e]?(""+t).trim():t+"px"}function oo(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=io(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var yu=U({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 Zl(e,t){if(t){if(yu[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(c(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(c(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(c(61))}if(t.style!=null&&typeof t.style!="object")throw Error(c(62))}}function Jl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 ql=null;function es(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ts=null,jn=null,Sn=null;function ao(e){if(e=hr(e)){if(typeof ts!="function")throw Error(c(280));var t=e.stateNode;t&&(t=rl(t),ts(e.stateNode,e.type,t))}}function co(e){jn?Sn?Sn.push(e):Sn=[e]:jn=e}function uo(){if(jn){var e=jn,t=Sn;if(Sn=jn=null,ao(e),t)for(e=0;e>>=0,e===0?32:31-(bu(e)/Tu|0)|0}var $r=64,Fr=4194304;function Zn(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Br(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var u=a&~s;u!==0?r=Zn(u):(i&=a,i!==0&&(r=Zn(i)))}else a=n&~s,a!==0?r=Zn(a):i!==0&&(r=Zn(i));if(r===0)return 0;if(t!==0&&t!==r&&(t&s)===0&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Jn(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-yt(t),e[t]=n}function Iu(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=ir),$o=" ",Fo=!1;function Bo(e,t){switch(e){case"keyup":return ad.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wo(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Cn=!1;function ud(e,t){switch(e){case"compositionend":return Wo(t);case"keypress":return t.which!==32?null:(Fo=!0,$o);case"textInput":return e=t.data,e===$o&&Fo?null:e;default:return null}}function dd(e,t){if(Cn)return e==="compositionend"||!xs&&Bo(e,t)?(e=Po(),Qr=ps=Ut=null,Cn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Yo(n)}}function Zo(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Zo(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Jo(){for(var e=window,t=Ke();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ke(e.document)}return t}function Ss(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function kd(e){var t=Jo(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Zo(n.ownerDocument.documentElement,n)){if(r!==null&&Ss(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Xo(n,i);var a=Xo(n,r);s&&a&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,En=null,ws=null,ur=null,Ns=!1;function qo(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ns||En==null||En!==Ke(r)||(r=En,"selectionStart"in r&&Ss(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ur&&cr(ur,r)||(ur=r,r=el(ws,"onSelect"),0Ln||(e.current=Ms[Ln],Ms[Ln]=null,Ln--)}function _e(e,t){Ln++,Ms[Ln]=e.current,e.current=t}var Kt={},Ge=Qt(Kt),tt=Qt(!1),cn=Kt;function Rn(e,t){var n=e.type.contextTypes;if(!n)return Kt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function nt(e){return e=e.childContextTypes,e!=null}function ll(){be(tt),be(Ge)}function ma(e,t,n){if(Ge.current!==Kt)throw Error(c(168));_e(Ge,t),_e(tt,n)}function ha(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(c(108,ne(e)||"Unknown",s));return U({},n,r)}function sl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Kt,cn=Ge.current,_e(Ge,e),_e(tt,tt.current),!0}function va(e,t,n){var r=e.stateNode;if(!r)throw Error(c(169));n?(e=ha(e,t,cn),r.__reactInternalMemoizedMergedChildContext=e,be(tt),be(Ge),_e(Ge,e)):be(tt),_e(tt,n)}var Rt=null,il=!1,As=!1;function ga(e){Rt===null?Rt=[e]:Rt.push(e)}function Rd(e){il=!0,ga(e)}function Gt(){if(!As&&Rt!==null){As=!0;var e=0,t=Ce;try{var n=Rt;for(Ce=1;e>=a,s-=a,Pt=1<<32-yt(t)+s|n<ae?(He=se,se=null):He=se.sibling;var we=O(j,se,S[ae],B);if(we===null){se===null&&(se=He);break}e&&se&&we.alternate===null&&t(j,se),h=i(we,h,ae),le===null?q=we:le.sibling=we,le=we,se=He}if(ae===S.length)return n(j,se),Te&&dn(j,ae),q;if(se===null){for(;aeae?(He=se,se=null):He=se.sibling;var rn=O(j,se,we.value,B);if(rn===null){se===null&&(se=He);break}e&&se&&rn.alternate===null&&t(j,se),h=i(rn,h,ae),le===null?q=rn:le.sibling=rn,le=rn,se=He}if(we.done)return n(j,se),Te&&dn(j,ae),q;if(se===null){for(;!we.done;ae++,we=S.next())we=F(j,we.value,B),we!==null&&(h=i(we,h,ae),le===null?q=we:le.sibling=we,le=we);return Te&&dn(j,ae),q}for(se=r(j,se);!we.done;ae++,we=S.next())we=Q(se,j,ae,we.value,B),we!==null&&(e&&we.alternate!==null&&se.delete(we.key===null?ae:we.key),h=i(we,h,ae),le===null?q=we:le.sibling=we,le=we);return e&&se.forEach(function(pf){return t(j,pf)}),Te&&dn(j,ae),q}function Me(j,h,S,B){if(typeof S=="object"&&S!==null&&S.type===me&&S.key===null&&(S=S.props.children),typeof S=="object"&&S!==null){switch(S.$$typeof){case oe:e:{for(var q=S.key,le=h;le!==null;){if(le.key===q){if(q=S.type,q===me){if(le.tag===7){n(j,le.sibling),h=s(le,S.props.children),h.return=j,j=h;break e}}else if(le.elementType===q||typeof q=="object"&&q!==null&&q.$$typeof===Ee&&wa(q)===le.type){n(j,le.sibling),h=s(le,S.props),h.ref=vr(j,le,S),h.return=j,j=h;break e}n(j,le);break}else t(j,le);le=le.sibling}S.type===me?(h=xn(S.props.children,j.mode,B,S.key),h.return=j,j=h):(B=Il(S.type,S.key,S.props,null,j.mode,B),B.ref=vr(j,h,S),B.return=j,j=B)}return a(j);case ue:e:{for(le=S.key;h!==null;){if(h.key===le)if(h.tag===4&&h.stateNode.containerInfo===S.containerInfo&&h.stateNode.implementation===S.implementation){n(j,h.sibling),h=s(h,S.children||[]),h.return=j,j=h;break e}else{n(j,h);break}else t(j,h);h=h.sibling}h=Ii(S,j.mode,B),h.return=j,j=h}return a(j);case Ee:return le=S._init,Me(j,h,le(S._payload),B)}if(Vn(S))return Y(j,h,S,B);if(K(S))return Z(j,h,S,B);ul(j,S)}return typeof S=="string"&&S!==""||typeof S=="number"?(S=""+S,h!==null&&h.tag===6?(n(j,h.sibling),h=s(h,S),h.return=j,j=h):(n(j,h),h=Pi(S,j.mode,B),h.return=j,j=h),a(j)):n(j,h)}return Me}var Mn=Na(!0),Ca=Na(!1),dl=Qt(null),fl=null,An=null,Us=null;function Hs(){Us=An=fl=null}function Vs(e){var t=dl.current;be(dl),e._currentValue=t}function Qs(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function On(e,t){fl=e,Us=An=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(rt=!0),e.firstContext=null)}function pt(e){var t=e._currentValue;if(Us!==e)if(e={context:e,memoizedValue:t,next:null},An===null){if(fl===null)throw Error(c(308));An=e,fl.dependencies={lanes:0,firstContext:e}}else An=An.next=e;return t}var fn=null;function Ks(e){fn===null?fn=[e]:fn.push(e)}function Ea(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Ks(t)):(n.next=s.next,s.next=n),t.interleaved=n,Dt(e,r)}function Dt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Yt=!1;function Gs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _a(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Mt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Xt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(Se&2)!==0){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Dt(e,n)}return s=r.interleaved,s===null?(t.next=t,Ks(r)):(t.next=s.next,s.next=t),r.interleaved=t,Dt(e,n)}function pl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,as(e,n)}}function za(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ml(e,t,n,r){var s=e.updateQueue;Yt=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,u=s.shared.pending;if(u!==null){s.shared.pending=null;var p=u,N=p.next;p.next=null,a===null?i=N:a.next=N,a=p;var $=e.alternate;$!==null&&($=$.updateQueue,u=$.lastBaseUpdate,u!==a&&(u===null?$.firstBaseUpdate=N:u.next=N,$.lastBaseUpdate=p))}if(i!==null){var F=s.baseState;a=0,$=N=p=null,u=i;do{var O=u.lane,Q=u.eventTime;if((r&O)===O){$!==null&&($=$.next={eventTime:Q,lane:0,tag:u.tag,payload:u.payload,callback:u.callback,next:null});e:{var Y=e,Z=u;switch(O=t,Q=n,Z.tag){case 1:if(Y=Z.payload,typeof Y=="function"){F=Y.call(Q,F,O);break e}F=Y;break e;case 3:Y.flags=Y.flags&-65537|128;case 0:if(Y=Z.payload,O=typeof Y=="function"?Y.call(Q,F,O):Y,O==null)break e;F=U({},F,O);break e;case 2:Yt=!0}}u.callback!==null&&u.lane!==0&&(e.flags|=64,O=s.effects,O===null?s.effects=[u]:O.push(u))}else Q={eventTime:Q,lane:O,tag:u.tag,payload:u.payload,callback:u.callback,next:null},$===null?(N=$=Q,p=F):$=$.next=Q,a|=O;if(u=u.next,u===null){if(u=s.shared.pending,u===null)break;O=u,u=O.next,O.next=null,s.lastBaseUpdate=O,s.shared.pending=null}}while(!0);if($===null&&(p=F),s.baseState=p,s.firstBaseUpdate=N,s.lastBaseUpdate=$,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);hn|=a,e.lanes=a,e.memoizedState=F}}function ba(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=qs.transition;qs.transition={};try{e(!1),t()}finally{Ce=n,qs.transition=r}}function Ga(){return mt().memoizedState}function Md(e,t,n){var r=en(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ya(e))Xa(t,n);else if(n=Ea(e,t,n,r),n!==null){var s=qe();Nt(n,e,r,s),Za(n,t,r)}}function Ad(e,t,n){var r=en(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ya(e))Xa(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,u=i(a,n);if(s.hasEagerState=!0,s.eagerState=u,xt(u,a)){var p=t.interleaved;p===null?(s.next=s,Ks(t)):(s.next=p.next,p.next=s),t.interleaved=s;return}}catch{}finally{}n=Ea(e,t,s,r),n!==null&&(s=qe(),Nt(n,e,r,s),Za(n,t,r))}}function Ya(e){var t=e.alternate;return e===Re||t!==null&&t===Re}function Xa(e,t){kr=gl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Za(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,as(e,n)}}var kl={readContext:pt,useCallback:Ye,useContext:Ye,useEffect:Ye,useImperativeHandle:Ye,useInsertionEffect:Ye,useLayoutEffect:Ye,useMemo:Ye,useReducer:Ye,useRef:Ye,useState:Ye,useDebugValue:Ye,useDeferredValue:Ye,useTransition:Ye,useMutableSource:Ye,useSyncExternalStore:Ye,useId:Ye,unstable_isNewReconciler:!1},Od={readContext:pt,useCallback:function(e,t){return bt().memoizedState=[e,t===void 0?null:t],e},useContext:pt,useEffect:Fa,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,yl(4194308,4,Ua.bind(null,t,e),n)},useLayoutEffect:function(e,t){return yl(4194308,4,e,t)},useInsertionEffect:function(e,t){return yl(4,2,e,t)},useMemo:function(e,t){var n=bt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=bt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Md.bind(null,Re,e),[r.memoizedState,e]},useRef:function(e){var t=bt();return e={current:e},t.memoizedState=e},useState:Oa,useDebugValue:ii,useDeferredValue:function(e){return bt().memoizedState=e},useTransition:function(){var e=Oa(!1),t=e[0];return e=Dd.bind(null,e[1]),bt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Re,s=bt();if(Te){if(n===void 0)throw Error(c(407));n=n()}else{if(n=t(),Ue===null)throw Error(c(349));(mn&30)!==0||Pa(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Fa(Da.bind(null,r,i,e),[e]),r.flags|=2048,wr(9,Ia.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=bt(),t=Ue.identifierPrefix;if(Te){var n=It,r=Pt;n=(r&~(1<<32-yt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=jr++,0")&&(p=p.replace("",e.displayName)),p}while(1<=a&&0<=u);break}}}finally{fe=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?I(e):""}function y(e){switch(e.tag){case 5:return I(e.type);case 16:return I("Lazy");case 13:return I("Suspense");case 19:return I("SuspenseList");case 0:case 2:case 15:return e=he(e.type,!1),e;case 11:return e=he(e.type.render,!1),e;case 1:return e=he(e.type,!0),e;default:return""}}function H(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case me:return"Fragment";case ue:return"Portal";case Ae:return"Profiler";case pe:return"StrictMode";case le:return"Suspense";case te:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case oe:return(e.displayName||"Context")+".Consumer";case Z:return(e._context.displayName||"Context")+".Provider";case ke:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ne:return t=e.displayName||null,t!==null?t:H(e.type)||"Memo";case Ee:t=e._payload,e=e._init;try{return H(e(t))}catch{}}return null}function ne(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return H(t);case 8:return t===pe?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function ve(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function D(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ce(e){var t=D(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,i.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ye(e){e._valueTracker||(e._valueTracker=ce(e))}function Be(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=D(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ke(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function et(e,t){var n=t.checked;return U({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function sn(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ve(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ct(e,t){t=t.checked,t!=null&&V(e,"checked",t,!1)}function Kl(e,t){Ct(e,t);var n=ve(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Gl(e,t.type,n):t.hasOwnProperty("defaultValue")&&Gl(e,t.type,ve(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function eo(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Gl(e,t,n){(t!=="number"||Ke(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Vn=Array.isArray;function kn(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=Ir.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Qn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Kn={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},gu=["Webkit","ms","Moz","O"];Object.keys(Kn).forEach(function(e){gu.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Kn[t]=Kn[e]})});function io(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Kn.hasOwnProperty(e)&&Kn[e]?(""+t).trim():t+"px"}function oo(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=io(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var yu=U({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 Zl(e,t){if(t){if(yu[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(c(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(c(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(c(61))}if(t.style!=null&&typeof t.style!="object")throw Error(c(62))}}function Jl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 ql=null;function es(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ts=null,jn=null,Sn=null;function ao(e){if(e=hr(e)){if(typeof ts!="function")throw Error(c(280));var t=e.stateNode;t&&(t=rl(t),ts(e.stateNode,e.type,t))}}function co(e){jn?Sn?Sn.push(e):Sn=[e]:jn=e}function uo(){if(jn){var e=jn,t=Sn;if(Sn=jn=null,ao(e),t)for(e=0;e>>=0,e===0?32:31-(bu(e)/Tu|0)|0}var $r=64,Fr=4194304;function Zn(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Br(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var u=a&~s;u!==0?r=Zn(u):(i&=a,i!==0&&(r=Zn(i)))}else a=n&~s,a!==0?r=Zn(a):i!==0&&(r=Zn(i));if(r===0)return 0;if(t!==0&&t!==r&&(t&s)===0&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Jn(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-yt(t),e[t]=n}function Iu(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=ir),$o=" ",Fo=!1;function Bo(e,t){switch(e){case"keyup":return ad.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wo(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Cn=!1;function ud(e,t){switch(e){case"compositionend":return Wo(t);case"keypress":return t.which!==32?null:(Fo=!0,$o);case"textInput":return e=t.data,e===$o&&Fo?null:e;default:return null}}function dd(e,t){if(Cn)return e==="compositionend"||!xs&&Bo(e,t)?(e=Po(),Qr=ps=Ut=null,Cn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Yo(n)}}function Zo(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Zo(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Jo(){for(var e=window,t=Ke();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ke(e.document)}return t}function Ss(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function kd(e){var t=Jo(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Zo(n.ownerDocument.documentElement,n)){if(r!==null&&Ss(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Xo(n,i);var a=Xo(n,r);s&&a&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,En=null,ws=null,ur=null,Ns=!1;function qo(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ns||En==null||En!==Ke(r)||(r=En,"selectionStart"in r&&Ss(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ur&&cr(ur,r)||(ur=r,r=el(ws,"onSelect"),0Ln||(e.current=Ms[Ln],Ms[Ln]=null,Ln--)}function _e(e,t){Ln++,Ms[Ln]=e.current,e.current=t}var Kt={},Ge=Qt(Kt),tt=Qt(!1),cn=Kt;function Rn(e,t){var n=e.type.contextTypes;if(!n)return Kt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function nt(e){return e=e.childContextTypes,e!=null}function ll(){be(tt),be(Ge)}function ma(e,t,n){if(Ge.current!==Kt)throw Error(c(168));_e(Ge,t),_e(tt,n)}function ha(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(c(108,ne(e)||"Unknown",s));return U({},n,r)}function sl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Kt,cn=Ge.current,_e(Ge,e),_e(tt,tt.current),!0}function va(e,t,n){var r=e.stateNode;if(!r)throw Error(c(169));n?(e=ha(e,t,cn),r.__reactInternalMemoizedMergedChildContext=e,be(tt),be(Ge),_e(Ge,e)):be(tt),_e(tt,n)}var Rt=null,il=!1,As=!1;function ga(e){Rt===null?Rt=[e]:Rt.push(e)}function Rd(e){il=!0,ga(e)}function Gt(){if(!As&&Rt!==null){As=!0;var e=0,t=Ce;try{var n=Rt;for(Ce=1;e>=a,s-=a,Pt=1<<32-yt(t)+s|n<ae?(He=ie,ie=null):He=ie.sibling;var we=$(k,ie,w[ae],W);if(we===null){ie===null&&(ie=He);break}e&&ie&&we.alternate===null&&t(k,ie),m=i(we,m,ae),se===null?q=we:se.sibling=we,se=we,ie=He}if(ae===w.length)return n(k,ie),Te&&dn(k,ae),q;if(ie===null){for(;aeae?(He=ie,ie=null):He=ie.sibling;var rn=$(k,ie,we.value,W);if(rn===null){ie===null&&(ie=He);break}e&&ie&&rn.alternate===null&&t(k,ie),m=i(rn,m,ae),se===null?q=rn:se.sibling=rn,se=rn,ie=He}if(we.done)return n(k,ie),Te&&dn(k,ae),q;if(ie===null){for(;!we.done;ae++,we=w.next())we=B(k,we.value,W),we!==null&&(m=i(we,m,ae),se===null?q=we:se.sibling=we,se=we);return Te&&dn(k,ae),q}for(ie=r(k,ie);!we.done;ae++,we=w.next())we=K(ie,k,ae,we.value,W),we!==null&&(e&&we.alternate!==null&&ie.delete(we.key===null?ae:we.key),m=i(we,m,ae),se===null?q=we:se.sibling=we,se=we);return e&&ie.forEach(function(pf){return t(k,pf)}),Te&&dn(k,ae),q}function Me(k,m,w,W){if(typeof w=="object"&&w!==null&&w.type===me&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case re:e:{for(var q=w.key,se=m;se!==null;){if(se.key===q){if(q=w.type,q===me){if(se.tag===7){n(k,se.sibling),m=s(se,w.props.children),m.return=k,k=m;break e}}else if(se.elementType===q||typeof q=="object"&&q!==null&&q.$$typeof===Ee&&wa(q)===se.type){n(k,se.sibling),m=s(se,w.props),m.ref=vr(k,se,w),m.return=k,k=m;break e}n(k,se);break}else t(k,se);se=se.sibling}w.type===me?(m=xn(w.props.children,k.mode,W,w.key),m.return=k,k=m):(W=Il(w.type,w.key,w.props,null,k.mode,W),W.ref=vr(k,m,w),W.return=k,k=W)}return a(k);case ue:e:{for(se=w.key;m!==null;){if(m.key===se)if(m.tag===4&&m.stateNode.containerInfo===w.containerInfo&&m.stateNode.implementation===w.implementation){n(k,m.sibling),m=s(m,w.children||[]),m.return=k,k=m;break e}else{n(k,m);break}else t(k,m);m=m.sibling}m=Ii(w,k.mode,W),m.return=k,k=m}return a(k);case Ee:return se=w._init,Me(k,m,se(w._payload),W)}if(Vn(w))return X(k,m,w,W);if(G(w))return J(k,m,w,W);ul(k,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,m!==null&&m.tag===6?(n(k,m.sibling),m=s(m,w),m.return=k,k=m):(n(k,m),m=Pi(w,k.mode,W),m.return=k,k=m),a(k)):n(k,m)}return Me}var Mn=Na(!0),Ca=Na(!1),dl=Qt(null),fl=null,An=null,Us=null;function Hs(){Us=An=fl=null}function Vs(e){var t=dl.current;be(dl),e._currentValue=t}function Qs(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function On(e,t){fl=e,Us=An=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(rt=!0),e.firstContext=null)}function pt(e){var t=e._currentValue;if(Us!==e)if(e={context:e,memoizedValue:t,next:null},An===null){if(fl===null)throw Error(c(308));An=e,fl.dependencies={lanes:0,firstContext:e}}else An=An.next=e;return t}var fn=null;function Ks(e){fn===null?fn=[e]:fn.push(e)}function Ea(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,Ks(t)):(n.next=s.next,s.next=n),t.interleaved=n,Dt(e,r)}function Dt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Yt=!1;function Gs(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _a(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Mt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Xt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(Se&2)!==0){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Dt(e,n)}return s=r.interleaved,s===null?(t.next=t,Ks(r)):(t.next=s.next,s.next=t),r.interleaved=t,Dt(e,n)}function pl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,as(e,n)}}function za(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ml(e,t,n,r){var s=e.updateQueue;Yt=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,u=s.shared.pending;if(u!==null){s.shared.pending=null;var p=u,C=p.next;p.next=null,a===null?i=C:a.next=C,a=p;var F=e.alternate;F!==null&&(F=F.updateQueue,u=F.lastBaseUpdate,u!==a&&(u===null?F.firstBaseUpdate=C:u.next=C,F.lastBaseUpdate=p))}if(i!==null){var B=s.baseState;a=0,F=C=p=null,u=i;do{var $=u.lane,K=u.eventTime;if((r&$)===$){F!==null&&(F=F.next={eventTime:K,lane:0,tag:u.tag,payload:u.payload,callback:u.callback,next:null});e:{var X=e,J=u;switch($=t,K=n,J.tag){case 1:if(X=J.payload,typeof X=="function"){B=X.call(K,B,$);break e}B=X;break e;case 3:X.flags=X.flags&-65537|128;case 0:if(X=J.payload,$=typeof X=="function"?X.call(K,B,$):X,$==null)break e;B=U({},B,$);break e;case 2:Yt=!0}}u.callback!==null&&u.lane!==0&&(e.flags|=64,$=s.effects,$===null?s.effects=[u]:$.push(u))}else K={eventTime:K,lane:$,tag:u.tag,payload:u.payload,callback:u.callback,next:null},F===null?(C=F=K,p=B):F=F.next=K,a|=$;if(u=u.next,u===null){if(u=s.shared.pending,u===null)break;$=u,u=$.next,$.next=null,s.lastBaseUpdate=$,s.shared.pending=null}}while(!0);if(F===null&&(p=B),s.baseState=p,s.firstBaseUpdate=C,s.lastBaseUpdate=F,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);hn|=a,e.lanes=a,e.memoizedState=B}}function ba(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=qs.transition;qs.transition={};try{e(!1),t()}finally{Ce=n,qs.transition=r}}function Ga(){return mt().memoizedState}function Md(e,t,n){var r=en(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ya(e))Xa(t,n);else if(n=Ea(e,t,n,r),n!==null){var s=qe();Nt(n,e,r,s),Za(n,t,r)}}function Ad(e,t,n){var r=en(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ya(e))Xa(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,u=i(a,n);if(s.hasEagerState=!0,s.eagerState=u,xt(u,a)){var p=t.interleaved;p===null?(s.next=s,Ks(t)):(s.next=p.next,p.next=s),t.interleaved=s;return}}catch{}finally{}n=Ea(e,t,s,r),n!==null&&(s=qe(),Nt(n,e,r,s),Za(n,t,r))}}function Ya(e){var t=e.alternate;return e===Re||t!==null&&t===Re}function Xa(e,t){kr=gl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Za(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,as(e,n)}}var kl={readContext:pt,useCallback:Ye,useContext:Ye,useEffect:Ye,useImperativeHandle:Ye,useInsertionEffect:Ye,useLayoutEffect:Ye,useMemo:Ye,useReducer:Ye,useRef:Ye,useState:Ye,useDebugValue:Ye,useDeferredValue:Ye,useTransition:Ye,useMutableSource:Ye,useSyncExternalStore:Ye,useId:Ye,unstable_isNewReconciler:!1},Od={readContext:pt,useCallback:function(e,t){return bt().memoizedState=[e,t===void 0?null:t],e},useContext:pt,useEffect:Fa,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,yl(4194308,4,Ua.bind(null,t,e),n)},useLayoutEffect:function(e,t){return yl(4194308,4,e,t)},useInsertionEffect:function(e,t){return yl(4,2,e,t)},useMemo:function(e,t){var n=bt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=bt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Md.bind(null,Re,e),[r.memoizedState,e]},useRef:function(e){var t=bt();return e={current:e},t.memoizedState=e},useState:Oa,useDebugValue:ii,useDeferredValue:function(e){return bt().memoizedState=e},useTransition:function(){var e=Oa(!1),t=e[0];return e=Dd.bind(null,e[1]),bt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Re,s=bt();if(Te){if(n===void 0)throw Error(c(407));n=n()}else{if(n=t(),Ue===null)throw Error(c(349));(mn&30)!==0||Pa(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Fa(Da.bind(null,r,i,e),[e]),r.flags|=2048,wr(9,Ia.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=bt(),t=Ue.identifierPrefix;if(Te){var n=It,r=Pt;n=(r&~(1<<32-yt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=jr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[_t]=t,e[mr]=r,gc(e,t,!1,!1),t.stateNode=e;e:{switch(a=Jl(n,r),n){case"dialog":ze("cancel",e),ze("close",e),s=r;break;case"iframe":case"object":case"embed":ze("load",e),s=r;break;case"video":case"audio":for(s=0;sUn&&(t.flags|=128,r=!0,Nr(i,!1),t.lanes=4194304)}else{if(!r)if(e=hl(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Nr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!Te)return Xe(t),null}else 2*De()-i.renderingStartTime>Un&&n!==1073741824&&(t.flags|=128,r=!0,Nr(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=De(),t.sibling=null,n=Le.current,_e(Le,r?n&1|2:n&1),t):(Xe(t),null);case 22:case 23:return Ti(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(ut&1073741824)!==0&&(Xe(t),t.subtreeFlags&6&&(t.flags|=8192)):Xe(t),null;case 24:return null;case 25:return null}throw Error(c(156,t.tag))}function Qd(e,t){switch($s(t),t.tag){case 1:return nt(t.type)&&ll(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $n(),be(tt),be(Ge),Js(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Xs(t),null;case 13:if(be(Le),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(c(340));Dn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return be(Le),null;case 4:return $n(),null;case 10:return Vs(t.type._context),null;case 22:case 23:return Ti(),null;case 24:return null;default:return null}}var Nl=!1,Ze=!1,Kd=typeof WeakSet=="function"?WeakSet:Set,G=null;function Bn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Pe(e,t,r)}else n.current=null}function yi(e,t,n){try{n()}catch(r){Pe(e,t,r)}}var kc=!1;function Gd(e,t){if(Ts=Hr,e=Jo(),Ss(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var a=0,u=-1,p=-1,N=0,$=0,F=e,O=null;t:for(;;){for(var Q;F!==n||s!==0&&F.nodeType!==3||(u=a+s),F!==i||r!==0&&F.nodeType!==3||(p=a+r),F.nodeType===3&&(a+=F.nodeValue.length),(Q=F.firstChild)!==null;)O=F,F=Q;for(;;){if(F===e)break t;if(O===n&&++N===s&&(u=a),O===i&&++$===r&&(p=a),(Q=F.nextSibling)!==null)break;F=O,O=F.parentNode}F=Q}n=u===-1||p===-1?null:{start:u,end:p}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ls={focusedElem:e,selectionRange:n},Hr=!1,G=t;G!==null;)if(t=G,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,G=e;else for(;G!==null;){t=G;try{var Y=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(Y!==null){var Z=Y.memoizedProps,Me=Y.memoizedState,j=t.stateNode,h=j.getSnapshotBeforeUpdate(t.elementType===t.type?Z:jt(t.type,Z),Me);j.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var S=t.stateNode.containerInfo;S.nodeType===1?S.textContent="":S.nodeType===9&&S.documentElement&&S.removeChild(S.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(c(163))}}catch(B){Pe(t,t.return,B)}if(e=t.sibling,e!==null){e.return=t.return,G=e;break}G=t.return}return Y=kc,kc=!1,Y}function Cr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&yi(t,n,i)}s=s.next}while(s!==r)}}function Cl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function xi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function jc(e){var t=e.alternate;t!==null&&(e.alternate=null,jc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_t],delete t[mr],delete t[Ds],delete t[Td],delete t[Ld])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Sc(e){return e.tag===5||e.tag===3||e.tag===4}function wc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Sc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ki(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=nl));else if(r!==4&&(e=e.child,e!==null))for(ki(e,t,n),e=e.sibling;e!==null;)ki(e,t,n),e=e.sibling}function ji(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ji(e,t,n),e=e.sibling;e!==null;)ji(e,t,n),e=e.sibling}var Ve=null,St=!1;function Zt(e,t,n){for(n=n.child;n!==null;)Nc(e,t,n),n=n.sibling}function Nc(e,t,n){if(Et&&typeof Et.onCommitFiberUnmount=="function")try{Et.onCommitFiberUnmount(Or,n)}catch{}switch(n.tag){case 5:Ze||Bn(n,t);case 6:var r=Ve,s=St;Ve=null,Zt(e,t,n),Ve=r,St=s,Ve!==null&&(St?(e=Ve,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ve.removeChild(n.stateNode));break;case 18:Ve!==null&&(St?(e=Ve,n=n.stateNode,e.nodeType===8?Is(e.parentNode,n):e.nodeType===1&&Is(e,n),rr(e)):Is(Ve,n.stateNode));break;case 4:r=Ve,s=St,Ve=n.stateNode.containerInfo,St=!0,Zt(e,t,n),Ve=r,St=s;break;case 0:case 11:case 14:case 15:if(!Ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&((i&2)!==0||(i&4)!==0)&&yi(n,t,a),s=s.next}while(s!==r)}Zt(e,t,n);break;case 1:if(!Ze&&(Bn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(u){Pe(n,t,u)}Zt(e,t,n);break;case 21:Zt(e,t,n);break;case 22:n.mode&1?(Ze=(r=Ze)||n.memoizedState!==null,Zt(e,t,n),Ze=r):Zt(e,t,n);break;default:Zt(e,t,n)}}function Cc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Kd),t.forEach(function(r){var s=rf.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function wt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=a),r&=~i}if(r=s,r=De()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Xd(r/1960))-r,10e?16:e,qt===null)var r=!1;else{if(e=qt,qt=null,Tl=0,(Se&6)!==0)throw Error(c(331));var s=Se;for(Se|=4,G=e.current;G!==null;){var i=G,a=i.child;if((G.flags&16)!==0){var u=i.deletions;if(u!==null){for(var p=0;pDe()-Ni?gn(e,0):wi|=n),st(e,t)}function Oc(e,t){t===0&&((e.mode&1)===0?t=1:(t=Fr,Fr<<=1,(Fr&130023424)===0&&(Fr=4194304)));var n=qe();e=Dt(e,t),e!==null&&(Jn(e,t,n),st(e,n))}function nf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Oc(e,n)}function rf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(c(314))}r!==null&&r.delete(t),Oc(e,n)}var $c;$c=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||tt.current)rt=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return rt=!1,Hd(e,t,n);rt=(e.flags&131072)!==0}else rt=!1,Te&&(t.flags&1048576)!==0&&ya(t,al,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;wl(e,t),e=t.pendingProps;var s=Rn(t,Ge.current);On(t,n),s=ti(null,t,r,e,s,n);var i=ni();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,nt(r)?(i=!0,sl(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Gs(t),s.updater=jl,t.stateNode=s,s._reactInternals=t,ai(t,r,e,n),t=fi(null,t,r,!0,i,n)):(t.tag=0,Te&&i&&Os(t),Je(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(wl(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=sf(r),e=jt(r,e),s){case 0:t=di(null,t,r,e,n);break e;case 1:t=dc(null,t,r,e,n);break e;case 11:t=ic(null,t,r,e,n);break e;case 14:t=oc(null,t,r,jt(r.type,e),n);break e}throw Error(c(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),di(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),dc(e,t,r,s,n);case 3:e:{if(fc(t),e===null)throw Error(c(387));r=t.pendingProps,i=t.memoizedState,s=i.element,_a(e,t),ml(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Fn(Error(c(423)),t),t=pc(e,t,r,n,s);break e}else if(r!==s){s=Fn(Error(c(424)),t),t=pc(e,t,r,n,s);break e}else for(ct=Vt(t.stateNode.containerInfo.firstChild),at=t,Te=!0,kt=null,n=Ca(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Dn(),r===s){t=At(e,t,n);break e}Je(e,t,r,n)}t=t.child}return t;case 5:return Ta(t),e===null&&Bs(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,Rs(r,s)?a=null:i!==null&&Rs(r,i)&&(t.flags|=32),uc(e,t),Je(e,t,a,n),t.child;case 6:return e===null&&Bs(t),null;case 13:return mc(e,t,n);case 4:return Ys(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Mn(t,null,r,n):Je(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),ic(e,t,r,s,n);case 7:return Je(e,t,t.pendingProps,n),t.child;case 8:return Je(e,t,t.pendingProps.children,n),t.child;case 12:return Je(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,a=s.value,_e(dl,r._currentValue),r._currentValue=a,i!==null)if(xt(i.value,a)){if(i.children===s.children&&!tt.current){t=At(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var u=i.dependencies;if(u!==null){a=i.child;for(var p=u.firstContext;p!==null;){if(p.context===r){if(i.tag===1){p=Mt(-1,n&-n),p.tag=2;var N=i.updateQueue;if(N!==null){N=N.shared;var $=N.pending;$===null?p.next=p:(p.next=$.next,$.next=p),N.pending=p}}i.lanes|=n,p=i.alternate,p!==null&&(p.lanes|=n),Qs(i.return,n,t),u.lanes|=n;break}p=p.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(c(341));a.lanes|=n,u=a.alternate,u!==null&&(u.lanes|=n),Qs(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}Je(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,On(t,n),s=pt(s),r=r(s),t.flags|=1,Je(e,t,r,n),t.child;case 14:return r=t.type,s=jt(r,t.pendingProps),s=jt(r.type,s),oc(e,t,r,s,n);case 15:return ac(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),wl(e,t),t.tag=1,nt(r)?(e=!0,sl(t)):e=!1,On(t,n),qa(t,r,s),ai(t,r,s,n),fi(null,t,r,!0,e,n);case 19:return vc(e,t,n);case 22:return cc(e,t,n)}throw Error(c(156,t.tag))};function Fc(e,t){return xo(e,t)}function lf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vt(e,t,n,r){return new lf(e,t,n,r)}function Ri(e){return e=e.prototype,!(!e||!e.isReactComponent)}function sf(e){if(typeof e=="function")return Ri(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ke)return 11;if(e===Ne)return 14}return 2}function nn(e,t){var n=e.alternate;return n===null?(n=vt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Il(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")Ri(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case me:return xn(n.children,s,i,t);case pe:a=8,s|=8;break;case Ae:return e=vt(12,n,t,s|2),e.elementType=Ae,e.lanes=i,e;case re:return e=vt(13,n,t,s),e.elementType=re,e.lanes=i,e;case te:return e=vt(19,n,t,s),e.elementType=te,e.lanes=i,e;case je:return Dl(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case X:a=10;break e;case ie:a=9;break e;case ke:a=11;break e;case Ne:a=14;break e;case Ee:a=16,r=null;break e}throw Error(c(130,e==null?e:typeof e,""))}return t=vt(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function xn(e,t,n,r){return e=vt(7,e,r,t),e.lanes=n,e}function Dl(e,t,n,r){return e=vt(22,e,r,t),e.elementType=je,e.lanes=n,e.stateNode={isHidden:!1},e}function Pi(e,t,n){return e=vt(6,e,null,t),e.lanes=n,e}function Ii(e,t,n){return t=vt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function of(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=os(0),this.expirationTimes=os(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=os(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Di(e,t,n,r,s,i,a,u,p){return e=new of(e,t,n,u,p),t===1?(t=1,i===!0&&(t|=8)):t=0,i=vt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Gs(i),e}function af(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(o)}catch(f){console.error(f)}}return o(),Bi.exports=xf(),Bi.exports}var eu;function jf(){if(eu)return Wl;eu=1;var o=kf();return Wl.createRoot=o.createRoot,Wl.hydrateRoot=o.hydrateRoot,Wl}var Sf=jf();const wf=Zi(Sf),Nf={},tu=o=>{let f;const c=new Set,y=(z,d)=>{const w=typeof z=="function"?z(f):z;if(!Object.is(w,f)){const m=f;f=d??(typeof w!="object"||w===null)?w:Object.assign({},f,w),c.forEach(R=>R(f,m))}},x=()=>f,b={setState:y,getState:x,getInitialState:()=>C,subscribe:z=>(c.add(z),()=>c.delete(z)),destroy:()=>{(Nf?"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."),c.clear()}},C=f=o(y,x,b);return b},Cf=o=>o?tu(o):tu;var Hi={exports:{}},Vi={},Qi={exports:{}},Ki={};/** +`+i.stack}return{value:e,source:t,stack:s,digest:null}}function ci(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ui(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Bd=typeof WeakMap=="function"?WeakMap:Map;function tc(e,t,n){n=Mt(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){zl||(zl=!0,Ci=r),ui(e,t)},n}function nc(e,t,n){n=Mt(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var s=t.value;n.payload=function(){return r(s)},n.callback=function(){ui(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){ui(e,t),typeof r!="function"&&(Jt===null?Jt=new Set([this]):Jt.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function rc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Bd;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(n)||(s.add(n),e=tf.bind(null,e,t,n),t.then(e,e))}function lc(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function sc(e,t,n,r,s){return(e.mode&1)===0?(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Mt(-1,1),t.tag=2,Xt(n,t,1))),n.lanes|=1),e):(e.flags|=65536,e.lanes=s,e)}var Wd=R.ReactCurrentOwner,rt=!1;function Je(e,t,n,r){t.child=e===null?Ca(t,null,n,r):Mn(t,e.child,n,r)}function ic(e,t,n,r,s){n=n.render;var i=t.ref;return On(t,s),r=ti(e,t,n,r,i,s),n=ni(),e!==null&&!rt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,At(e,t,s)):(Te&&n&&Os(t),t.flags|=1,Je(e,t,r,s),t.child)}function oc(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!Ri(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,ac(e,t,i,r,s)):(e=Il(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,(e.lanes&s)===0){var a=i.memoizedProps;if(n=n.compare,n=n!==null?n:cr,n(a,r)&&e.ref===t.ref)return At(e,t,s)}return t.flags|=1,e=nn(i,r),e.ref=t.ref,e.return=t,t.child=e}function ac(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(cr(i,r)&&e.ref===t.ref)if(rt=!1,t.pendingProps=r=i,(e.lanes&s)!==0)(e.flags&131072)!==0&&(rt=!0);else return t.lanes=e.lanes,At(e,t,s)}return di(e,t,n,r,s)}function cc(e,t,n){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if((t.mode&1)===0)t.memoizedState={baseLanes:0,cachePool:null,transitions:null},_e(Wn,ut),ut|=n;else{if((n&1073741824)===0)return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,_e(Wn,ut),ut|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,_e(Wn,ut),ut|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,_e(Wn,ut),ut|=r;return Je(e,t,s,n),t.child}function uc(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function di(e,t,n,r,s){var i=nt(n)?cn:Ge.current;return i=Rn(t,i),On(t,s),n=ti(e,t,n,r,i,s),r=ni(),e!==null&&!rt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,At(e,t,s)):(Te&&r&&Os(t),t.flags|=1,Je(e,t,n,s),t.child)}function dc(e,t,n,r,s){if(nt(n)){var i=!0;sl(t)}else i=!1;if(On(t,s),t.stateNode===null)wl(e,t),qa(t,n,r),ai(t,n,r,s),r=!0;else if(e===null){var a=t.stateNode,u=t.memoizedProps;a.props=u;var p=a.context,C=n.contextType;typeof C=="object"&&C!==null?C=pt(C):(C=nt(n)?cn:Ge.current,C=Rn(t,C));var F=n.getDerivedStateFromProps,B=typeof F=="function"||typeof a.getSnapshotBeforeUpdate=="function";B||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(u!==r||p!==C)&&ec(t,a,r,C),Yt=!1;var $=t.memoizedState;a.state=$,ml(t,r,a,s),p=t.memoizedState,u!==r||$!==p||tt.current||Yt?(typeof F=="function"&&(oi(t,n,F,r),p=t.memoizedState),(u=Yt||Ja(t,n,u,r,$,p,C))?(B||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=C,r=u):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,_a(e,t),u=t.memoizedProps,C=t.type===t.elementType?u:jt(t.type,u),a.props=C,B=t.pendingProps,$=a.context,p=n.contextType,typeof p=="object"&&p!==null?p=pt(p):(p=nt(n)?cn:Ge.current,p=Rn(t,p));var K=n.getDerivedStateFromProps;(F=typeof K=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(u!==B||$!==p)&&ec(t,a,r,p),Yt=!1,$=t.memoizedState,a.state=$,ml(t,r,a,s);var X=t.memoizedState;u!==B||$!==X||tt.current||Yt?(typeof K=="function"&&(oi(t,n,K,r),X=t.memoizedState),(C=Yt||Ja(t,n,C,r,$,X,p)||!1)?(F||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,X,p),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,X,p)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||u===e.memoizedProps&&$===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||u===e.memoizedProps&&$===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=X),a.props=r,a.state=X,a.context=p,r=C):(typeof a.componentDidUpdate!="function"||u===e.memoizedProps&&$===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||u===e.memoizedProps&&$===e.memoizedState||(t.flags|=1024),r=!1)}return fi(e,t,n,r,i,s)}function fi(e,t,n,r,s,i){uc(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&va(t,n,!1),At(e,t,i);r=t.stateNode,Wd.current=t;var u=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Mn(t,e.child,null,i),t.child=Mn(t,null,u,i)):Je(e,t,u,i),t.memoizedState=r.state,s&&va(t,n,!0),t.child}function fc(e){var t=e.stateNode;t.pendingContext?ma(e,t.pendingContext,t.pendingContext!==t.context):t.context&&ma(e,t.context,!1),Ys(e,t.containerInfo)}function pc(e,t,n,r,s){return Dn(),Ws(s),t.flags|=256,Je(e,t,n,r),t.child}var pi={dehydrated:null,treeContext:null,retryLane:0};function mi(e){return{baseLanes:e,cachePool:null,transitions:null}}function mc(e,t,n){var r=t.pendingProps,s=Le.current,i=!1,a=(t.flags&128)!==0,u;if((u=a)||(u=e!==null&&e.memoizedState===null?!1:(s&2)!==0),u?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),_e(Le,s&1),e===null)return Bs(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((t.mode&1)===0?t.lanes=1:e.data==="$!"?t.lanes=8:t.lanes=1073741824,null):(a=r.children,e=r.fallback,i?(r=t.mode,i=t.child,a={mode:"hidden",children:a},(r&1)===0&&i!==null?(i.childLanes=0,i.pendingProps=a):i=Dl(a,r,0,null),e=xn(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=mi(n),t.memoizedState=pi,e):hi(t,a));if(s=e.memoizedState,s!==null&&(u=s.dehydrated,u!==null))return Ud(e,t,a,r,u,s,n);if(i){i=r.fallback,a=t.mode,s=e.child,u=s.sibling;var p={mode:"hidden",children:r.children};return(a&1)===0&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=p,t.deletions=null):(r=nn(s,p),r.subtreeFlags=s.subtreeFlags&14680064),u!==null?i=nn(u,i):(i=xn(i,a,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a=a===null?mi(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=pi,r}return i=e.child,e=i.sibling,r=nn(i,{mode:"visible",children:r.children}),(t.mode&1)===0&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function hi(e,t){return t=Dl({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Sl(e,t,n,r){return r!==null&&Ws(r),Mn(t,e.child,null,n),e=hi(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Ud(e,t,n,r,s,i,a){if(n)return t.flags&256?(t.flags&=-257,r=ci(Error(c(422))),Sl(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Dl({mode:"visible",children:r.children},s,0,null),i=xn(i,s,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,(t.mode&1)!==0&&Mn(t,e.child,null,a),t.child.memoizedState=mi(a),t.memoizedState=pi,i);if((t.mode&1)===0)return Sl(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var u=r.dgst;return r=u,i=Error(c(419)),r=ci(i,r,void 0),Sl(e,t,a,r)}if(u=(a&e.childLanes)!==0,rt||u){if(r=Ue,r!==null){switch(a&-a){case 4:s=2;break;case 16:s=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:s=32;break;case 536870912:s=268435456;break;default:s=0}s=(s&(r.suspendedLanes|a))!==0?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,Dt(e,s),Nt(r,e,s,-1))}return Li(),r=ci(Error(c(421))),Sl(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=nf.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,ct=Vt(s.nextSibling),at=t,Te=!0,kt=null,e!==null&&(dt[ft++]=Pt,dt[ft++]=It,dt[ft++]=un,Pt=e.id,It=e.overflow,un=t),t=hi(t,r.children),t.flags|=4096,t)}function hc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Qs(e.return,t,n)}function vi(e,t,n,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function vc(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(Je(e,t,r.children,n),r=Le.current,(r&2)!==0)r=r&1|2,t.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&hc(e,n,t);else if(e.tag===19)hc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(_e(Le,r),(t.mode&1)===0)t.memoizedState=null;else switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&hl(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),vi(t,!1,s,n,i);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&hl(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}vi(t,!0,n,null,i);break;case"together":vi(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function wl(e,t){(t.mode&1)===0&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function At(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),hn|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(c(153));if(t.child!==null){for(e=t.child,n=nn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=nn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Hd(e,t,n){switch(t.tag){case 3:fc(t),Dn();break;case 5:Ta(t);break;case 1:nt(t.type)&&sl(t);break;case 4:Ys(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;_e(dl,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(_e(Le,Le.current&1),t.flags|=128,null):(n&t.child.childLanes)!==0?mc(e,t,n):(_e(Le,Le.current&1),e=At(e,t,n),e!==null?e.sibling:null);_e(Le,Le.current&1);break;case 19:if(r=(n&t.childLanes)!==0,(e.flags&128)!==0){if(r)return vc(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),_e(Le,Le.current),r)break;return null;case 22:case 23:return t.lanes=0,cc(e,t,n)}return At(e,t,n)}var gc,gi,yc,xc;gc=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},gi=function(){},yc=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,pn(zt.current);var i=null;switch(n){case"input":s=et(e,s),r=et(e,r),i=[];break;case"select":s=U({},s,{value:void 0}),r=U({},r,{value:void 0}),i=[];break;case"textarea":s=Yl(e,s),r=Yl(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=nl)}Zl(n,r);var a;n=null;for(C in s)if(!r.hasOwnProperty(C)&&s.hasOwnProperty(C)&&s[C]!=null)if(C==="style"){var u=s[C];for(a in u)u.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else C!=="dangerouslySetInnerHTML"&&C!=="children"&&C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(g.hasOwnProperty(C)?i||(i=[]):(i=i||[]).push(C,null));for(C in r){var p=r[C];if(u=s!=null?s[C]:void 0,r.hasOwnProperty(C)&&p!==u&&(p!=null||u!=null))if(C==="style")if(u){for(a in u)!u.hasOwnProperty(a)||p&&p.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in p)p.hasOwnProperty(a)&&u[a]!==p[a]&&(n||(n={}),n[a]=p[a])}else n||(i||(i=[]),i.push(C,n)),n=p;else C==="dangerouslySetInnerHTML"?(p=p?p.__html:void 0,u=u?u.__html:void 0,p!=null&&u!==p&&(i=i||[]).push(C,p)):C==="children"?typeof p!="string"&&typeof p!="number"||(i=i||[]).push(C,""+p):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&(g.hasOwnProperty(C)?(p!=null&&C==="onScroll"&&ze("scroll",e),i||u===p||(i=[])):(i=i||[]).push(C,p))}n&&(i=i||[]).push("style",n);var C=i;(t.updateQueue=C)&&(t.flags|=4)}},xc=function(e,t,n,r){n!==r&&(t.flags|=4)};function Nr(e,t){if(!Te)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Xe(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Vd(e,t,n){var r=t.pendingProps;switch($s(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Xe(t),null;case 1:return nt(t.type)&&ll(),Xe(t),null;case 3:return r=t.stateNode,$n(),be(tt),be(Ge),Js(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(cl(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,kt!==null&&(zi(kt),kt=null))),gi(e,t),Xe(t),null;case 5:Xs(t);var s=pn(xr.current);if(n=t.type,e!==null&&t.stateNode!=null)yc(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(c(166));return Xe(t),null}if(e=pn(zt.current),cl(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[_t]=t,r[mr]=i,e=(t.mode&1)!==0,n){case"dialog":ze("cancel",r),ze("close",r);break;case"iframe":case"object":case"embed":ze("load",r);break;case"video":case"audio":for(s=0;s<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[_t]=t,e[mr]=r,gc(e,t,!1,!1),t.stateNode=e;e:{switch(a=Jl(n,r),n){case"dialog":ze("cancel",e),ze("close",e),s=r;break;case"iframe":case"object":case"embed":ze("load",e),s=r;break;case"video":case"audio":for(s=0;sUn&&(t.flags|=128,r=!0,Nr(i,!1),t.lanes=4194304)}else{if(!r)if(e=hl(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Nr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!Te)return Xe(t),null}else 2*De()-i.renderingStartTime>Un&&n!==1073741824&&(t.flags|=128,r=!0,Nr(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=De(),t.sibling=null,n=Le.current,_e(Le,r?n&1|2:n&1),t):(Xe(t),null);case 22:case 23:return Ti(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(ut&1073741824)!==0&&(Xe(t),t.subtreeFlags&6&&(t.flags|=8192)):Xe(t),null;case 24:return null;case 25:return null}throw Error(c(156,t.tag))}function Qd(e,t){switch($s(t),t.tag){case 1:return nt(t.type)&&ll(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $n(),be(tt),be(Ge),Js(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Xs(t),null;case 13:if(be(Le),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(c(340));Dn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return be(Le),null;case 4:return $n(),null;case 10:return Vs(t.type._context),null;case 22:case 23:return Ti(),null;case 24:return null;default:return null}}var Nl=!1,Ze=!1,Kd=typeof WeakSet=="function"?WeakSet:Set,Y=null;function Bn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ie(e,t,r)}else n.current=null}function yi(e,t,n){try{n()}catch(r){Ie(e,t,r)}}var kc=!1;function Gd(e,t){if(Ts=Hr,e=Jo(),Ss(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var a=0,u=-1,p=-1,C=0,F=0,B=e,$=null;t:for(;;){for(var K;B!==n||s!==0&&B.nodeType!==3||(u=a+s),B!==i||r!==0&&B.nodeType!==3||(p=a+r),B.nodeType===3&&(a+=B.nodeValue.length),(K=B.firstChild)!==null;)$=B,B=K;for(;;){if(B===e)break t;if($===n&&++C===s&&(u=a),$===i&&++F===r&&(p=a),(K=B.nextSibling)!==null)break;B=$,$=B.parentNode}B=K}n=u===-1||p===-1?null:{start:u,end:p}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ls={focusedElem:e,selectionRange:n},Hr=!1,Y=t;Y!==null;)if(t=Y,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Y=e;else for(;Y!==null;){t=Y;try{var X=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(X!==null){var J=X.memoizedProps,Me=X.memoizedState,k=t.stateNode,m=k.getSnapshotBeforeUpdate(t.elementType===t.type?J:jt(t.type,J),Me);k.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(c(163))}}catch(W){Ie(t,t.return,W)}if(e=t.sibling,e!==null){e.return=t.return,Y=e;break}Y=t.return}return X=kc,kc=!1,X}function Cr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&yi(t,n,i)}s=s.next}while(s!==r)}}function Cl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function xi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function jc(e){var t=e.alternate;t!==null&&(e.alternate=null,jc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_t],delete t[mr],delete t[Ds],delete t[Td],delete t[Ld])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Sc(e){return e.tag===5||e.tag===3||e.tag===4}function wc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Sc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ki(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=nl));else if(r!==4&&(e=e.child,e!==null))for(ki(e,t,n),e=e.sibling;e!==null;)ki(e,t,n),e=e.sibling}function ji(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ji(e,t,n),e=e.sibling;e!==null;)ji(e,t,n),e=e.sibling}var Ve=null,St=!1;function Zt(e,t,n){for(n=n.child;n!==null;)Nc(e,t,n),n=n.sibling}function Nc(e,t,n){if(Et&&typeof Et.onCommitFiberUnmount=="function")try{Et.onCommitFiberUnmount(Or,n)}catch{}switch(n.tag){case 5:Ze||Bn(n,t);case 6:var r=Ve,s=St;Ve=null,Zt(e,t,n),Ve=r,St=s,Ve!==null&&(St?(e=Ve,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ve.removeChild(n.stateNode));break;case 18:Ve!==null&&(St?(e=Ve,n=n.stateNode,e.nodeType===8?Is(e.parentNode,n):e.nodeType===1&&Is(e,n),rr(e)):Is(Ve,n.stateNode));break;case 4:r=Ve,s=St,Ve=n.stateNode.containerInfo,St=!0,Zt(e,t,n),Ve=r,St=s;break;case 0:case 11:case 14:case 15:if(!Ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&((i&2)!==0||(i&4)!==0)&&yi(n,t,a),s=s.next}while(s!==r)}Zt(e,t,n);break;case 1:if(!Ze&&(Bn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(u){Ie(n,t,u)}Zt(e,t,n);break;case 21:Zt(e,t,n);break;case 22:n.mode&1?(Ze=(r=Ze)||n.memoizedState!==null,Zt(e,t,n),Ze=r):Zt(e,t,n);break;default:Zt(e,t,n)}}function Cc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Kd),t.forEach(function(r){var s=rf.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function wt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=a),r&=~i}if(r=s,r=De()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Xd(r/1960))-r,10e?16:e,qt===null)var r=!1;else{if(e=qt,qt=null,Tl=0,(Se&6)!==0)throw Error(c(331));var s=Se;for(Se|=4,Y=e.current;Y!==null;){var i=Y,a=i.child;if((Y.flags&16)!==0){var u=i.deletions;if(u!==null){for(var p=0;pDe()-Ni?gn(e,0):wi|=n),st(e,t)}function Oc(e,t){t===0&&((e.mode&1)===0?t=1:(t=Fr,Fr<<=1,(Fr&130023424)===0&&(Fr=4194304)));var n=qe();e=Dt(e,t),e!==null&&(Jn(e,t,n),st(e,n))}function nf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Oc(e,n)}function rf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(c(314))}r!==null&&r.delete(t),Oc(e,n)}var $c;$c=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||tt.current)rt=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return rt=!1,Hd(e,t,n);rt=(e.flags&131072)!==0}else rt=!1,Te&&(t.flags&1048576)!==0&&ya(t,al,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;wl(e,t),e=t.pendingProps;var s=Rn(t,Ge.current);On(t,n),s=ti(null,t,r,e,s,n);var i=ni();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,nt(r)?(i=!0,sl(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Gs(t),s.updater=jl,t.stateNode=s,s._reactInternals=t,ai(t,r,e,n),t=fi(null,t,r,!0,i,n)):(t.tag=0,Te&&i&&Os(t),Je(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(wl(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=sf(r),e=jt(r,e),s){case 0:t=di(null,t,r,e,n);break e;case 1:t=dc(null,t,r,e,n);break e;case 11:t=ic(null,t,r,e,n);break e;case 14:t=oc(null,t,r,jt(r.type,e),n);break e}throw Error(c(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),di(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),dc(e,t,r,s,n);case 3:e:{if(fc(t),e===null)throw Error(c(387));r=t.pendingProps,i=t.memoizedState,s=i.element,_a(e,t),ml(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Fn(Error(c(423)),t),t=pc(e,t,r,n,s);break e}else if(r!==s){s=Fn(Error(c(424)),t),t=pc(e,t,r,n,s);break e}else for(ct=Vt(t.stateNode.containerInfo.firstChild),at=t,Te=!0,kt=null,n=Ca(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Dn(),r===s){t=At(e,t,n);break e}Je(e,t,r,n)}t=t.child}return t;case 5:return Ta(t),e===null&&Bs(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,Rs(r,s)?a=null:i!==null&&Rs(r,i)&&(t.flags|=32),uc(e,t),Je(e,t,a,n),t.child;case 6:return e===null&&Bs(t),null;case 13:return mc(e,t,n);case 4:return Ys(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Mn(t,null,r,n):Je(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),ic(e,t,r,s,n);case 7:return Je(e,t,t.pendingProps,n),t.child;case 8:return Je(e,t,t.pendingProps.children,n),t.child;case 12:return Je(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,a=s.value,_e(dl,r._currentValue),r._currentValue=a,i!==null)if(xt(i.value,a)){if(i.children===s.children&&!tt.current){t=At(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var u=i.dependencies;if(u!==null){a=i.child;for(var p=u.firstContext;p!==null;){if(p.context===r){if(i.tag===1){p=Mt(-1,n&-n),p.tag=2;var C=i.updateQueue;if(C!==null){C=C.shared;var F=C.pending;F===null?p.next=p:(p.next=F.next,F.next=p),C.pending=p}}i.lanes|=n,p=i.alternate,p!==null&&(p.lanes|=n),Qs(i.return,n,t),u.lanes|=n;break}p=p.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(c(341));a.lanes|=n,u=a.alternate,u!==null&&(u.lanes|=n),Qs(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}Je(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,On(t,n),s=pt(s),r=r(s),t.flags|=1,Je(e,t,r,n),t.child;case 14:return r=t.type,s=jt(r,t.pendingProps),s=jt(r.type,s),oc(e,t,r,s,n);case 15:return ac(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:jt(r,s),wl(e,t),t.tag=1,nt(r)?(e=!0,sl(t)):e=!1,On(t,n),qa(t,r,s),ai(t,r,s,n),fi(null,t,r,!0,e,n);case 19:return vc(e,t,n);case 22:return cc(e,t,n)}throw Error(c(156,t.tag))};function Fc(e,t){return xo(e,t)}function lf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vt(e,t,n,r){return new lf(e,t,n,r)}function Ri(e){return e=e.prototype,!(!e||!e.isReactComponent)}function sf(e){if(typeof e=="function")return Ri(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ke)return 11;if(e===Ne)return 14}return 2}function nn(e,t){var n=e.alternate;return n===null?(n=vt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Il(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")Ri(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case me:return xn(n.children,s,i,t);case pe:a=8,s|=8;break;case Ae:return e=vt(12,n,t,s|2),e.elementType=Ae,e.lanes=i,e;case le:return e=vt(13,n,t,s),e.elementType=le,e.lanes=i,e;case te:return e=vt(19,n,t,s),e.elementType=te,e.lanes=i,e;case je:return Dl(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Z:a=10;break e;case oe:a=9;break e;case ke:a=11;break e;case Ne:a=14;break e;case Ee:a=16,r=null;break e}throw Error(c(130,e==null?e:typeof e,""))}return t=vt(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function xn(e,t,n,r){return e=vt(7,e,r,t),e.lanes=n,e}function Dl(e,t,n,r){return e=vt(22,e,r,t),e.elementType=je,e.lanes=n,e.stateNode={isHidden:!1},e}function Pi(e,t,n){return e=vt(6,e,null,t),e.lanes=n,e}function Ii(e,t,n){return t=vt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function of(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=os(0),this.expirationTimes=os(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=os(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Di(e,t,n,r,s,i,a,u,p){return e=new of(e,t,n,u,p),t===1?(t=1,i===!0&&(t|=8)):t=0,i=vt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Gs(i),e}function af(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(o)}catch(f){console.error(f)}}return o(),Bi.exports=xf(),Bi.exports}var eu;function jf(){if(eu)return Wl;eu=1;var o=kf();return Wl.createRoot=o.createRoot,Wl.hydrateRoot=o.hydrateRoot,Wl}var Sf=jf();const wf=Zi(Sf),Nf={},tu=o=>{let f;const c=new Set,v=(b,d)=>{const N=typeof b=="function"?b(f):b;if(!Object.is(N,f)){const j=f;f=d??(typeof N!="object"||N===null)?N:Object.assign({},f,N),c.forEach(O=>O(f,j))}},g=()=>f,T={setState:v,getState:g,getInitialState:()=>E,subscribe:b=>(c.add(b),()=>c.delete(b)),destroy:()=>{(Nf?"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."),c.clear()}},E=f=o(v,g,T);return T},Cf=o=>o?tu(o):tu;var Hi={exports:{}},Vi={},Qi={exports:{}},Ki={};/** * @license React * use-sync-external-store-shim.production.js * @@ -45,7 +45,7 @@ Error generating stack: `+i.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var nu;function Ef(){if(nu)return Ki;nu=1;var o=Rr();function f(d,w){return d===w&&(d!==0||1/d===1/w)||d!==d&&w!==w}var c=typeof Object.is=="function"?Object.is:f,y=o.useState,x=o.useEffect,L=o.useLayoutEffect,T=o.useDebugValue;function _(d,w){var m=w(),R=y({inst:{value:m,getSnapshot:w}}),g=R[0].inst,A=R[1];return L(function(){g.value=m,g.getSnapshot=w,b(g)&&A({inst:g})},[d,m,w]),x(function(){return b(g)&&A({inst:g}),d(function(){b(g)&&A({inst:g})})},[d]),T(m),m}function b(d){var w=d.getSnapshot;d=d.value;try{var m=w();return!c(d,m)}catch{return!0}}function C(d,w){return w()}var z=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?C:_;return Ki.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:z,Ki}var ru;function _f(){return ru||(ru=1,Qi.exports=Ef()),Qi.exports}/** + */var nu;function Ef(){if(nu)return Ki;nu=1;var o=Rr();function f(d,N){return d===N&&(d!==0||1/d===1/N)||d!==d&&N!==N}var c=typeof Object.is=="function"?Object.is:f,v=o.useState,g=o.useEffect,P=o.useLayoutEffect,L=o.useDebugValue;function z(d,N){var j=N(),O=v({inst:{value:j,getSnapshot:N}}),S=O[0].inst,M=O[1];return P(function(){S.value=j,S.getSnapshot=N,T(S)&&M({inst:S})},[d,j,N]),g(function(){return T(S)&&M({inst:S}),d(function(){T(S)&&M({inst:S})})},[d]),L(j),j}function T(d){var N=d.getSnapshot;d=d.value;try{var j=N();return!c(d,j)}catch{return!0}}function E(d,N){return N()}var b=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?E:z;return Ki.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:b,Ki}var ru;function _f(){return ru||(ru=1,Qi.exports=Ef()),Qi.exports}/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -53,32 +53,32 @@ Error generating stack: `+i.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var lu;function zf(){if(lu)return Vi;lu=1;var o=Rr(),f=_f();function c(C,z){return C===z&&(C!==0||1/C===1/z)||C!==C&&z!==z}var y=typeof Object.is=="function"?Object.is:c,x=f.useSyncExternalStore,L=o.useRef,T=o.useEffect,_=o.useMemo,b=o.useDebugValue;return Vi.useSyncExternalStoreWithSelector=function(C,z,d,w,m){var R=L(null);if(R.current===null){var g={hasValue:!1,value:null};R.current=g}else g=R.current;R=_(function(){function P(ue){if(!W){if(W=!0,J=ue,ue=w(ue),m!==void 0&&g.hasValue){var me=g.value;if(m(me,ue))return I=me}return I=ue}if(me=I,y(J,ue))return me;var pe=w(ue);return m!==void 0&&m(me,pe)?(J=ue,me):(J=ue,I=pe)}var W=!1,J,I,oe=d===void 0?null:d;return[function(){return P(z())},oe===null?void 0:function(){return P(oe())}]},[z,d,w,m]);var A=x(C,R[0],R[1]);return T(function(){g.hasValue=!0,g.value=A},[A]),b(A),A},Vi}var su;function bf(){return su||(su=1,Hi.exports=zf()),Hi.exports}var Tf=bf();const Lf=Zi(Tf),uu={},{useDebugValue:Rf}=cu,{useSyncExternalStoreWithSelector:Pf}=Lf;let iu=!1;const If=o=>o;function Df(o,f=If,c){(uu?"production":void 0)!=="production"&&c&&!iu&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),iu=!0);const y=Pf(o.subscribe,o.getState,o.getServerState||o.getInitialState,f,c);return Rf(y),y}const ou=o=>{(uu?"production":void 0)!=="production"&&typeof o!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const f=typeof o=="function"?Cf(o):o,c=(y,x)=>Df(f,y,x);return Object.assign(c,f),c},Mf=o=>o?ou(o):ou,xe="";async function gt(o){const f=await fetch(o,{cache:"no-store"});if(!f.ok)throw new Error(String(f.status));return f.json()}async function Ie(o,f){return(await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)})).json()}const fe={liveStatus:()=>gt(`${xe}/api/live-status`),agentConfig:()=>gt(`${xe}/api/agent-config`),modelChangeLog:()=>gt(`${xe}/api/model-change-log`).catch(()=>[]),officialsStats:()=>gt(`${xe}/api/officials-stats`),morningBrief:()=>gt(`${xe}/api/morning-brief`),morningConfig:()=>gt(`${xe}/api/morning-config`),agentsStatus:()=>gt(`${xe}/api/agents-status`),taskActivity:o=>gt(`${xe}/api/task-activity/${encodeURIComponent(o)}`),schedulerState:o=>gt(`${xe}/api/scheduler-state/${encodeURIComponent(o)}`),skillContent:(o,f)=>gt(`${xe}/api/skill-content/${encodeURIComponent(o)}/${encodeURIComponent(f)}`),setModel:(o,f)=>Ie(`${xe}/api/set-model`,{agentId:o,model:f}),agentWake:o=>Ie(`${xe}/api/agent-wake`,{agentId:o}),taskAction:(o,f,c)=>Ie(`${xe}/api/task-action`,{taskId:o,action:f,reason:c}),reviewAction:(o,f,c)=>Ie(`${xe}/api/review-action`,{taskId:o,action:f,comment:c}),advanceState:(o,f)=>Ie(`${xe}/api/advance-state`,{taskId:o,comment:f}),archiveTask:(o,f)=>Ie(`${xe}/api/archive-task`,{taskId:o,archived:f}),archiveAllDone:()=>Ie(`${xe}/api/archive-task`,{archiveAllDone:!0}),schedulerScan:(o=180)=>Ie(`${xe}/api/scheduler-scan`,{thresholdSec:o}),schedulerRetry:(o,f)=>Ie(`${xe}/api/scheduler-retry`,{taskId:o,reason:f}),schedulerEscalate:(o,f)=>Ie(`${xe}/api/scheduler-escalate`,{taskId:o,reason:f}),schedulerRollback:(o,f)=>Ie(`${xe}/api/scheduler-rollback`,{taskId:o,reason:f}),refreshMorning:()=>Ie(`${xe}/api/morning-brief/refresh`,{}),saveMorningConfig:o=>Ie(`${xe}/api/morning-config`,o),addSkill:(o,f,c,y)=>Ie(`${xe}/api/add-skill`,{agentId:o,skillName:f,description:c,trigger:y}),addRemoteSkill:(o,f,c,y)=>Ie(`${xe}/api/add-remote-skill`,{agentId:o,skillName:f,sourceUrl:c,description:y||""}),remoteSkillsList:()=>gt(`${xe}/api/remote-skills-list`),updateRemoteSkill:(o,f)=>Ie(`${xe}/api/update-remote-skill`,{agentId:o,skillName:f}),removeRemoteSkill:(o,f)=>Ie(`${xe}/api/remove-remote-skill`,{agentId:o,skillName:f}),createTask:o=>Ie(`${xe}/api/create-task`,o),courtDiscussStart:(o,f,c)=>Ie(`${xe}/api/court-discuss/start`,{topic:o,officials:f,taskId:c}),courtDiscussAdvance:(o,f,c)=>Ie(`${xe}/api/court-discuss/advance`,{sessionId:o,userMessage:f,decree:c}),courtDiscussConclude:o=>Ie(`${xe}/api/court-discuss/conclude`,{sessionId:o}),courtDiscussDestroy:o=>Ie(`${xe}/api/court-discuss/destroy`,{sessionId:o}),courtDiscussFate:()=>gt(`${xe}/api/court-discuss/fate`)},du=[{key:"Inbox",dept:"皇上",icon:"👑",action:"下旨"},{key:"Taizi",dept:"太子",icon:"🤴",action:"分拣"},{key:"Zhongshu",dept:"中书省",icon:"📜",action:"起草"},{key:"Menxia",dept:"门下省",icon:"🔍",action:"审议"},{key:"Assigned",dept:"尚书省",icon:"📮",action:"派发"},{key:"Doing",dept:"六部",icon:"⚙️",action:"执行"},{key:"Review",dept:"尚书省",icon:"🔎",action:"汇总"},{key:"Done",dept:"回奏",icon:"✅",action:"完成"}],Af={Inbox:0,Pending:0,Taizi:1,Zhongshu:2,Menxia:3,Assigned:4,Doing:5,Review:6,Done:7,Blocked:5,Cancelled:5,Next:4},Of={太子:"#e8a040",中书省:"#a07aff",门下省:"#6a9eff",尚书省:"#6aef9a",礼部:"#f5c842",户部:"#ff9a6a",兵部:"#ff5270",刑部:"#cc4444",工部:"#44aaff",吏部:"#9b59b6",皇上:"#ffd700",回奏:"#2ecc8a"},Pr={Inbox:"收件",Pending:"待处理",Taizi:"太子分拣",Zhongshu:"中书起草",Menxia:"门下审议",Assigned:"已派发",Doing:"执行中",Review:"待审查",Done:"已完成",Blocked:"阻塞",Cancelled:"已取消",Next:"待执行"};function Ul(o){return Of[o]||"#6a9eff"}function Ji(o){const f=o.review_round||0;return o.state==="Menxia"&&f>1?`门下审议(第${f}轮)`:o.state==="Zhongshu"&&f>0?`中书修订(第${f}轮)`:Pr[o.state]||o.state}function ln(o){return/^JJC-/i.test(o.id||"")}function Vl(o){return o.archived||["Done","Cancelled"].includes(o.state)}function qi(o){const f=Af[o.state]??4;return du.map((c,y)=>({...c,status:yo;function Df(o,f=If,c){(uu?"production":void 0)!=="production"&&c&&!iu&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),iu=!0);const v=Pf(o.subscribe,o.getState,o.getServerState||o.getInitialState,f,c);return Rf(v),v}const ou=o=>{(uu?"production":void 0)!=="production"&&typeof o!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const f=typeof o=="function"?Cf(o):o,c=(v,g)=>Df(f,v,g);return Object.assign(c,f),c},Mf=o=>o?ou(o):ou,xe="";async function gt(o){const f=await fetch(o,{cache:"no-store"});if(!f.ok)throw new Error(String(f.status));return f.json()}async function Pe(o,f){return(await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)})).json()}const de={liveStatus:()=>gt(`${xe}/api/live-status`),agentConfig:()=>gt(`${xe}/api/agent-config`),modelChangeLog:()=>gt(`${xe}/api/model-change-log`).catch(()=>[]),officialsStats:()=>gt(`${xe}/api/officials-stats`),morningBrief:()=>gt(`${xe}/api/morning-brief`),morningConfig:()=>gt(`${xe}/api/morning-config`),agentsStatus:()=>gt(`${xe}/api/agents-status`),taskActivity:o=>gt(`${xe}/api/task-activity/${encodeURIComponent(o)}`),schedulerState:o=>gt(`${xe}/api/scheduler-state/${encodeURIComponent(o)}`),skillContent:(o,f)=>gt(`${xe}/api/skill-content/${encodeURIComponent(o)}/${encodeURIComponent(f)}`),setModel:(o,f)=>Pe(`${xe}/api/set-model`,{agentId:o,model:f}),setDispatchChannel:o=>Pe(`${xe}/api/set-dispatch-channel`,{channel:o}),agentWake:o=>Pe(`${xe}/api/agent-wake`,{agentId:o}),taskAction:(o,f,c)=>Pe(`${xe}/api/task-action`,{taskId:o,action:f,reason:c}),reviewAction:(o,f,c)=>Pe(`${xe}/api/review-action`,{taskId:o,action:f,comment:c}),advanceState:(o,f)=>Pe(`${xe}/api/advance-state`,{taskId:o,comment:f}),archiveTask:(o,f)=>Pe(`${xe}/api/archive-task`,{taskId:o,archived:f}),archiveAllDone:()=>Pe(`${xe}/api/archive-task`,{archiveAllDone:!0}),schedulerScan:(o=180)=>Pe(`${xe}/api/scheduler-scan`,{thresholdSec:o}),schedulerRetry:(o,f)=>Pe(`${xe}/api/scheduler-retry`,{taskId:o,reason:f}),schedulerEscalate:(o,f)=>Pe(`${xe}/api/scheduler-escalate`,{taskId:o,reason:f}),schedulerRollback:(o,f)=>Pe(`${xe}/api/scheduler-rollback`,{taskId:o,reason:f}),refreshMorning:()=>Pe(`${xe}/api/morning-brief/refresh`,{}),saveMorningConfig:o=>Pe(`${xe}/api/morning-config`,o),addSkill:(o,f,c,v)=>Pe(`${xe}/api/add-skill`,{agentId:o,skillName:f,description:c,trigger:v}),addRemoteSkill:(o,f,c,v)=>Pe(`${xe}/api/add-remote-skill`,{agentId:o,skillName:f,sourceUrl:c,description:v||""}),remoteSkillsList:()=>gt(`${xe}/api/remote-skills-list`),updateRemoteSkill:(o,f)=>Pe(`${xe}/api/update-remote-skill`,{agentId:o,skillName:f}),removeRemoteSkill:(o,f)=>Pe(`${xe}/api/remove-remote-skill`,{agentId:o,skillName:f}),createTask:o=>Pe(`${xe}/api/create-task`,o),courtDiscussStart:(o,f,c)=>Pe(`${xe}/api/court-discuss/start`,{topic:o,officials:f,taskId:c}),courtDiscussAdvance:(o,f,c)=>Pe(`${xe}/api/court-discuss/advance`,{sessionId:o,userMessage:f,decree:c}),courtDiscussConclude:o=>Pe(`${xe}/api/court-discuss/conclude`,{sessionId:o}),courtDiscussDestroy:o=>Pe(`${xe}/api/court-discuss/destroy`,{sessionId:o}),courtDiscussFate:()=>gt(`${xe}/api/court-discuss/fate`)},du=[{key:"Inbox",dept:"皇上",icon:"👑",action:"下旨"},{key:"Taizi",dept:"太子",icon:"🤴",action:"分拣"},{key:"Zhongshu",dept:"中书省",icon:"📜",action:"起草"},{key:"Menxia",dept:"门下省",icon:"🔍",action:"审议"},{key:"Assigned",dept:"尚书省",icon:"📮",action:"派发"},{key:"Doing",dept:"六部",icon:"⚙️",action:"执行"},{key:"Review",dept:"尚书省",icon:"🔎",action:"汇总"},{key:"Done",dept:"回奏",icon:"✅",action:"完成"}],Af={Inbox:0,Pending:0,Taizi:1,Zhongshu:2,Menxia:3,Assigned:4,Doing:5,Review:6,Done:7,Blocked:5,Cancelled:5,Next:4},Of={太子:"#e8a040",中书省:"#a07aff",门下省:"#6a9eff",尚书省:"#6aef9a",礼部:"#f5c842",户部:"#ff9a6a",兵部:"#ff5270",刑部:"#cc4444",工部:"#44aaff",吏部:"#9b59b6",皇上:"#ffd700",回奏:"#2ecc8a"},Pr={Inbox:"收件",Pending:"待处理",Taizi:"太子分拣",Zhongshu:"中书起草",Menxia:"门下审议",Assigned:"已派发",Doing:"执行中",Review:"待审查",Done:"已完成",Blocked:"阻塞",Cancelled:"已取消",Next:"待执行"};function Ul(o){return Of[o]||"#6a9eff"}function Ji(o){const f=o.review_round||0;return o.state==="Menxia"&&f>1?`门下审议(第${f}轮)`:o.state==="Zhongshu"&&f>0?`中书修订(第${f}轮)`:Pr[o.state]||o.state}function ln(o){return/^JJC-/i.test(o.id||"")}function Vl(o){return o.archived||["Done","Cancelled"].includes(o.state)}function qi(o){const f=Af[o.state]??4;return du.map((c,v)=>({...c,status:v({liveStatus:null,agentConfig:null,changeLog:[],officialsData:null,agentsStatusData:null,morningBrief:null,subConfig:null,activeTab:"edicts",edictFilter:"active",sessFilter:"all",tplCatFilter:"全部",selectedOfficial:null,modalTaskId:null,countdown:5,toasts:[],setActiveTab:c=>{o({activeTab:c});const y=f();["models","skills","sessions"].includes(c)&&!y.agentConfig&&y.loadAgentConfig(),c==="officials"&&!y.officialsData&&y.loadOfficials(),c==="monitor"&&y.loadAgentsStatus(),c==="morning"&&!y.morningBrief&&y.loadMorning()},setEdictFilter:c=>o({edictFilter:c}),setSessFilter:c=>o({sessFilter:c}),setTplCatFilter:c=>o({tplCatFilter:c}),setSelectedOfficial:c=>o({selectedOfficial:c}),setModalTaskId:c=>o({modalTaskId:c}),setCountdown:c=>o({countdown:c}),toast:(c,y="ok")=>{const x=++Wf;o(L=>({toasts:[...L.toasts,{id:x,msg:c,type:y}]})),setTimeout(()=>{o(L=>({toasts:L.toasts.filter(T=>T.id!==x)}))},3e3)},loadLive:async()=>{try{const c=await fe.liveStatus();o({liveStatus:c}),f().officialsData||fe.officialsStats().then(x=>o({officialsData:x})).catch(()=>{})}catch{}},loadAgentConfig:async()=>{try{const c=await fe.agentConfig(),y=await fe.modelChangeLog();o({agentConfig:c,changeLog:y})}catch{}},loadOfficials:async()=>{try{const c=await fe.officialsStats();o({officialsData:c})}catch{}},loadAgentsStatus:async()=>{try{const c=await fe.agentsStatus();o({agentsStatusData:c})}catch{o({agentsStatusData:null})}},loadMorning:async()=>{try{const[c,y]=await Promise.all([fe.morningBrief(),fe.morningConfig()]);o({morningBrief:c,subConfig:y})}catch{}},loadSubConfig:async()=>{try{const c=await fe.morningConfig();o({subConfig:c})}catch{}},loadAll:async()=>{const c=f();await c.loadLive();const y=c.activeTab;["models","skills"].includes(y)&&await c.loadAgentConfig()}}));let Lr=null;function Uf(){Lr||(ee.getState().loadAll(),Lr=setInterval(()=>{const o=ee.getState(),f=o.countdown-1;f<=0?(o.setCountdown(5),o.loadAll()):o.setCountdown(f)},1e3))}function Hf(){Lr&&(clearInterval(Lr),Lr=null)}function Vf(o){if(!o)return"";try{const f=new Date(o.includes("T")?o:o.replace(" ","T")+"Z");if(isNaN(f.getTime()))return"";const c=Date.now()-f.getTime(),y=Math.floor(c/6e4);if(y<1)return"刚刚";if(y<60)return y+"分钟前";const x=Math.floor(y/60);return x<24?x+"小时前":Math.floor(x/24)+"天前"}catch{return""}}const au={Doing:0,Review:1,Assigned:2,Menxia:3,Zhongshu:4,Taizi:5,Inbox:6,Blocked:7,Next:8,Done:9,Cancelled:10};function Qf({task:o}){const f=qi(o);return l.jsx("div",{className:"ec-pipe",children:f.map((c,y)=>l.jsxs("span",{style:{display:"contents"},children:[l.jsxs("div",{className:`ep-node ${c.status}`,children:[l.jsx("div",{className:"ep-icon",children:c.icon}),l.jsx("div",{className:"ep-name",children:c.dept})]}),yP.setModalTaskId),c=ee(P=>P.toast),y=ee(P=>P.loadAll),x=o.heartbeat||{status:"unknown",label:"⚪"},L="st-"+(o.state||""),T="dt-"+(o.org||"").replace(/\s/g,""),_=du.find((P,W)=>qi(o)[W].status==="active"),b=o.todos||[],C=b.filter(P=>P.status==="completed").length,z=b.length,d=!["Done","Blocked","Cancelled"].includes(o.state),w=["Blocked","Cancelled"].includes(o.state),m=Vl(o),R=o.block&&o.block!=="无"&&o.block!=="-",g=async(P,W)=>{if(W.stopPropagation(),P==="stop"||P==="cancel"){const J=prompt(P==="stop"?"请输入叫停原因:":"请输入取消原因:");if(J===null)return;try{const I=await fe.taskAction(o.id,P,J);I.ok?(c(I.message||"操作成功"),y()):c(I.error||"操作失败","err")}catch{c("服务器连接失败","err")}}else if(P==="resume")try{const J=await fe.taskAction(o.id,"resume","恢复执行");J.ok?(c(J.message||"已恢复"),y()):c(J.error||"操作失败","err")}catch{c("服务器连接失败","err")}},A=async P=>{P.stopPropagation();try{const W=await fe.archiveTask(o.id,!o.archived);W.ok?(c(W.message||"操作成功"),y()):c(W.error||"操作失败","err")}catch{c("服务器连接失败","err")}};return l.jsxs("div",{className:`edict-card${m?" archived":""}`,onClick:()=>f(o.id),children:[l.jsx(Qf,{task:o}),l.jsx("div",{className:"ec-id",children:o.id}),l.jsx("div",{className:"ec-title",children:o.title||"(无标题)"}),l.jsxs("div",{className:"ec-meta",children:[l.jsx("span",{className:`tag ${L}`,children:Ji(o)}),o.org&&l.jsx("span",{className:`tag ${T}`,children:o.org}),_&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["当前: ",l.jsxs("b",{style:{color:Ul(_.dept)},children:[_.dept," · ",_.action]})]})]}),o.now&&o.now!=="-"&&l.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5,marginBottom:6},children:o.now.substring(0,80)}),(o.review_round||0)>0&&l.jsxs("div",{style:{fontSize:11,marginBottom:6},children:[Array.from({length:o.review_round||0},(P,W)=>l.jsx("span",{style:{display:"inline-block",width:14,height:14,borderRadius:"50%",background:W<(o.review_round||0)-1?"#1a3a6a22":"var(--acc)22",border:`1px solid ${W<(o.review_round||0)-1?"#2a4a8a":"var(--acc)"}`,fontSize:9,textAlign:"center",lineHeight:"13px",marginRight:2,color:W<(o.review_round||0)-1?"#4a6aaa":"var(--acc)"},children:W+1},W)),l.jsxs("span",{style:{color:"var(--muted)",fontSize:10},children:["第 ",o.review_round," 轮磋商"]})]}),z>0&&l.jsxs("div",{className:"ec-todo-bar",children:[l.jsxs("span",{children:["📋 ",C,"/",z]}),l.jsx("div",{className:"ec-todo-track",children:l.jsx("div",{className:"ec-todo-fill",style:{width:`${Math.round(C/z*100)}%`}})}),l.jsx("span",{children:C===z?"✅ 全部完成":"🔄 进行中"})]}),l.jsxs("div",{className:"ec-footer",children:[l.jsx("span",{className:`hb ${x.status}`,children:x.label}),R&&l.jsxs("span",{className:"tag",style:{borderColor:"#ff527044",color:"var(--danger)",background:"#200a10"},children:["🚫 ",o.block]}),o.eta&&o.eta!=="-"&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["📅 ",o.eta]})]}),l.jsxs("div",{className:"ec-actions",onClick:P=>P.stopPropagation(),children:[d&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"mini-act",onClick:P=>g("stop",P),children:"⏸ 叫停"}),l.jsx("button",{className:"mini-act danger",onClick:P=>g("cancel",P),children:"🚫 取消"})]}),w&&l.jsx("button",{className:"mini-act",onClick:P=>g("resume",P),children:"▶ 恢复"}),m&&!o.archived&&l.jsx("button",{className:"mini-act",onClick:A,children:"📦 归档"}),o.archived&&l.jsx("button",{className:"mini-act",onClick:A,children:"📤 取消归档"})]})]})}function Gf(){const o=ee(m=>m.liveStatus),f=ee(m=>m.edictFilter),c=ee(m=>m.setEdictFilter),y=ee(m=>m.toast),x=ee(m=>m.loadAll),T=((o==null?void 0:o.tasks)||[]).filter(ln),_=T.filter(m=>!Vl(m)),b=T.filter(m=>Vl(m));let C;f==="active"?C=_:f==="archived"?C=b:C=T,C.sort((m,R)=>(au[m.state]??9)-(au[R.state]??9));const z=T.filter(m=>!m.archived&&["Done","Cancelled"].includes(m.state)),d=async()=>{if(confirm("将所有已完成/已取消的旨意移入归档?"))try{const m=await fe.archiveAllDone();m.ok?(y(`📦 ${m.count||0} 道旨意已归档`),x()):y(m.error||"批量归档失败","err")}catch{y("服务器连接失败","err")}},w=async()=>{try{const m=await fe.schedulerScan();m.ok?y(`🧭 太子巡检完成:${m.count||0} 个动作`):y(m.error||"巡检失败","err"),x()}catch{y("服务器连接失败","err")}};return l.jsxs("div",{children:[l.jsxs("div",{className:"archive-bar",children:[l.jsx("span",{className:"ab-label",children:"筛选:"}),["active","archived","all"].map(m=>l.jsx("button",{className:`ab-btn ${f===m?"active":""}`,onClick:()=>c(m),children:m==="active"?"活跃":m==="archived"?"归档":"全部"},m)),z.length>0&&l.jsx("button",{className:"ab-btn",onClick:d,children:"📦 一键归档"}),l.jsxs("span",{className:"ab-count",children:["活跃 ",_.length," · 归档 ",b.length," · 共 ",T.length]}),l.jsx("button",{className:"ab-scan",onClick:w,children:"🧭 太子巡检"})]}),l.jsx("div",{className:"edict-grid",children:C.length===0?l.jsxs("div",{className:"empty",style:{gridColumn:"1/-1"},children:["暂无旨意",l.jsx("br",{}),l.jsx("small",{style:{fontSize:11,marginTop:6,display:"block",color:"var(--muted)"},children:"通过飞书向太子发送任务,太子分拣后转中书省处理"})]}):C.map(m=>l.jsx(Kf,{task:m},m.id))})]})}function Yf(){var J;const o=ee(I=>I.liveStatus),f=ee(I=>I.agentsStatusData),c=ee(I=>I.officialsData),y=ee(I=>I.loadAgentsStatus),x=ee(I=>I.setModalTaskId),L=ee(I=>I.toast);V.useEffect(()=>{y()},[y]);const _=((o==null?void 0:o.tasks)||[]).filter(I=>ln(I)&&I.state!=="Done"&&I.state!=="Next"),b={};c!=null&&c.officials&&c.officials.forEach(I=>{b[I.id]=I});const C=async I=>{try{const oe=await fe.agentWake(I);L(oe.message||"唤醒指令已发出"),setTimeout(()=>y(),3e4)}catch{L("唤醒失败","err")}},z=async()=>{if(!f)return;const I=f.agents.filter(oe=>oe.id!=="main"&&oe.status!=="running"&&oe.status!=="unconfigured");if(!I.length){L("所有 Agent 均已在线");return}L(`正在唤醒 ${I.length} 个 Agent...`);for(const oe of I)try{await fe.agentWake(oe.id)}catch{}L(`${I.length} 个唤醒指令已发出,30秒后刷新状态`),setTimeout(()=>y(),3e4)},d=f,w=((J=d==null?void 0:d.agents)==null?void 0:J.filter(I=>I.id!=="main"))||[],m=w.filter(I=>I.status==="running").length,R=w.filter(I=>I.status==="idle").length,g=w.filter(I=>I.status==="offline").length,A=w.filter(I=>I.status==="unconfigured").length,P=d==null?void 0:d.gateway,W=P!=null&&P.probe?"ok":P!=null&&P.alive?"warn":"err";return l.jsxs("div",{children:[d&&d.ok&&l.jsxs("div",{className:"as-panel",children:[l.jsxs("div",{className:"as-header",children:[l.jsx("span",{className:"as-title",children:"🔌 Agent 在线状态"}),l.jsxs("span",{className:`as-gw ${W}`,children:["Gateway: ",(P==null?void 0:P.status)||"未知"]}),l.jsx("button",{className:"btn-refresh",onClick:()=>y(),style:{marginLeft:8},children:"🔄 刷新"}),g+A>0&&l.jsx("button",{className:"btn-refresh",onClick:z,style:{marginLeft:4,borderColor:"var(--warn)",color:"var(--warn)"},children:"⚡ 全部唤醒"})]}),l.jsx("div",{className:"as-grid",children:w.map(I=>{const oe=I.status!=="running"&&I.status!=="unconfigured"&&(P==null?void 0:P.alive);return l.jsxs("div",{className:"as-card",title:`${I.role} · ${I.statusLabel}`,children:[l.jsx("div",{className:`as-dot ${I.status}`}),l.jsx("div",{style:{fontSize:22},children:I.emoji}),l.jsx("div",{style:{fontSize:12,fontWeight:700},children:I.label}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:I.role}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:I.statusLabel}),I.lastActive?l.jsxs("div",{style:{fontSize:10,color:"var(--muted)"},children:["⏰ ",I.lastActive]}):l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"无活动记录"}),oe&&l.jsx("button",{className:"as-wake-btn",onClick:ue=>{ue.stopPropagation(),C(I.id)},children:"⚡ 唤醒"})]},I.id)})}),l.jsxs("div",{className:"as-summary",children:[l.jsxs("span",{children:[l.jsx("span",{className:"as-dot running",style:{position:"static",width:8,height:8}})," ",m," 运行中"]}),l.jsxs("span",{children:[l.jsx("span",{className:"as-dot idle",style:{position:"static",width:8,height:8}})," ",R," 待命"]}),g>0&&l.jsxs("span",{children:[l.jsx("span",{className:"as-dot offline",style:{position:"static",width:8,height:8}})," ",g," 离线"]}),A>0&&l.jsxs("span",{children:[l.jsx("span",{className:"as-dot unconfigured",style:{position:"static",width:8,height:8}})," ",A," 未配置"]}),l.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--muted)"},children:["检测于 ",(d.checkedAt||"").substring(11,19)]})]})]}),l.jsx("div",{className:"duty-grid",children:fu.map(I=>{const oe=_.filter(re=>re.org===I.label),ue=oe.some(re=>re.state==="Doing"),me=oe.some(re=>re.state==="Blocked"),pe=b[I.id],Ae=(pe==null?void 0:pe.heartbeat)||{status:"idle"},X=me?"blocked":ue?"busy":Ae.status==="active"?"active":"idle",ie=me?"⚠️ 阻塞":ue?"⚙️ 执行中":Ae.status==="active"?"🟢 活跃":"⚪ 候命",ke=me?"blocked-card":ue?"active-card":"";return l.jsxs("div",{className:`duty-card ${ke}`,children:[l.jsxs("div",{className:"dc-hdr",children:[l.jsx("span",{className:"dc-emoji",children:I.emoji}),l.jsxs("div",{className:"dc-info",children:[l.jsx("div",{className:"dc-name",children:I.label}),l.jsxs("div",{className:"dc-role",children:[I.role," · ",I.rank]})]}),l.jsxs("div",{className:"dc-status",children:[l.jsx("span",{className:`dc-dot ${X}`}),l.jsx("span",{children:ie})]})]}),l.jsx("div",{className:"dc-body",children:oe.length>0?oe.map(re=>l.jsxs("div",{className:"dc-task",onClick:()=>x(re.id),children:[l.jsx("div",{className:"dc-task-id",children:re.id}),l.jsx("div",{className:"dc-task-title",children:re.title||"(无标题)"}),re.now&&re.now!=="-"&&l.jsx("div",{className:"dc-task-now",children:re.now.substring(0,70)}),l.jsxs("div",{className:"dc-task-meta",children:[l.jsx("span",{className:`tag st-${re.state}`,children:Ji(re)}),re.block&&re.block!=="无"&&l.jsxs("span",{className:"tag",style:{borderColor:"#ff527044",color:"var(--danger)"},children:["🚫",re.block]})]})]},re.id)):l.jsxs("div",{className:"dc-idle",children:[l.jsx("span",{style:{fontSize:20},children:"🪭"}),l.jsx("span",{children:"候命中"})]})}),l.jsxs("div",{className:"dc-footer",children:[l.jsxs("span",{className:"dc-model",children:["🤖 ",(pe==null?void 0:pe.model_short)||"待配置"]}),(pe==null?void 0:pe.last_active)&&l.jsxs("span",{className:"dc-la",children:["⏰ ",pe.last_active]})]})]},I.id)})})]})}const Xf=["🥇","🥈","🥉"];function Zf(){var d;const o=ee(w=>w.officialsData),f=ee(w=>w.selectedOfficial),c=ee(w=>w.setSelectedOfficial),y=ee(w=>w.loadOfficials),x=ee(w=>w.setModalTaskId);if(V.useEffect(()=>{y()},[y]),!(o!=null&&o.officials))return l.jsx("div",{className:"empty",children:"⚠️ 请确保本地服务器已启动"});const L=o.officials,T=o.totals||{tasks_done:0,cost_cny:0},_=Math.max(...L.map(w=>w.tokens_in+w.tokens_out+w.cache_read+w.cache_write),1),b=L.filter(w=>{var m;return((m=w.heartbeat)==null?void 0:m.status)==="active"}),C=L.find(w=>{var m;return w.id===(f||((m=L[0])==null?void 0:m.id))}),z=(C==null?void 0:C.id)||((d=L[0])==null?void 0:d.id);return l.jsxs("div",{children:[b.length>0&&l.jsxs("div",{className:"off-activity",children:[l.jsx("span",{children:"🟢 当前活跃:"}),b.map(w=>l.jsxs("span",{style:{fontSize:12},children:[w.emoji," ",w.role]},w.id)),l.jsx("span",{style:{color:"var(--muted)",fontSize:11,marginLeft:"auto"},children:"其余官员待命"})]}),l.jsxs("div",{className:"off-kpi",children:[l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{color:"var(--acc)"},children:L.length}),l.jsx("div",{className:"kpi-l",children:"在职官员"})]}),l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{color:"#f5c842"},children:T.tasks_done||0}),l.jsx("div",{className:"kpi-l",children:"累计完成旨意"})]}),l.jsxs("div",{className:"kpi",children:[l.jsxs("div",{className:"kpi-v",style:{color:(T.cost_cny||0)>20?"var(--warn)":"var(--ok)"},children:["¥",T.cost_cny||0]}),l.jsx("div",{className:"kpi-l",children:"累计费用(含缓存)"})]}),l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{fontSize:16,paddingTop:4},children:o.top_official||"—"}),l.jsx("div",{className:"kpi-l",children:"功绩最高"})]})]}),l.jsxs("div",{className:"off-layout",children:[l.jsxs("div",{className:"off-ranklist",children:[l.jsx("div",{className:"orl-hdr",children:"功绩排行"}),L.map(w=>{const m=w.heartbeat||{status:"idle"};return l.jsxs("div",{className:`orl-item${z===w.id?" selected":""}`,onClick:()=>c(w.id),children:[l.jsx("span",{style:{minWidth:24,textAlign:"center"},children:w.merit_rank<=3?Xf[w.merit_rank-1]:"#"+w.merit_rank}),l.jsx("span",{children:w.emoji}),l.jsxs("span",{style:{flex:1},children:[l.jsx("div",{style:{fontSize:12,fontWeight:700},children:w.role}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:w.label})]}),l.jsxs("span",{style:{fontSize:11},children:[w.merit_score,"分"]}),l.jsx("span",{className:`dc-dot ${m.status}`,style:{width:8,height:8}})]},w.id)})]}),l.jsx("div",{className:"off-detail",children:C?l.jsx(Jf,{official:C,maxTk:_,onOpenTask:x}):l.jsx("div",{className:"empty",children:"选择左侧官员查看详情"})})]})]})}function Jf({official:o,maxTk:f,onOpenTask:c}){const y=o.heartbeat||{status:"idle",label:"⚪ 待命"},x=o.tokens_in+o.tokens_out+o.cache_read+o.cache_write,L=o.participated_edicts||[],T=[{l:"输入",v:o.tokens_in,color:"#6a9eff"},{l:"输出",v:o.tokens_out,color:"#a07aff"},{l:"缓存读",v:o.cache_read,color:"#2ecc8a"},{l:"缓存写",v:o.cache_write,color:"#f5c842"}];return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:16,alignItems:"center",marginBottom:20},children:[l.jsx("div",{style:{fontSize:40},children:o.emoji}),l.jsxs("div",{style:{flex:1},children:[l.jsx("div",{style:{fontSize:18,fontWeight:800},children:o.role}),l.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:[o.label," · ",l.jsx("span",{style:{color:"var(--acc)"},children:o.model_short||o.model})]}),l.jsxs("div",{style:{fontSize:11,color:"var(--muted)",marginTop:2},children:["🏅 ",o.rank," · 功绩分 ",o.merit_score]})]}),l.jsxs("div",{style:{textAlign:"right"},children:[l.jsx("div",{className:`hb ${y.status}`,style:{marginBottom:4},children:y.label}),o.last_active&&l.jsxs("div",{style:{fontSize:10,color:"var(--muted)"},children:["活跃 ",o.last_active]}),l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:2},children:[o.sessions," 个会话 · ",o.messages," 条消息"]})]})]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"功绩统计"}),l.jsxs("div",{style:{display:"flex",gap:16},children:[l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--ok)"},children:o.tasks_done}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"完成旨意"})]}),l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--warn)"},children:o.tasks_active}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"执行中"})]}),l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--acc)"},children:o.flow_participations}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"流转参与"})]})]})]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"Token 消耗"}),T.map(_=>l.jsxs("div",{style:{marginBottom:6},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,marginBottom:2},children:[l.jsx("span",{style:{color:"var(--muted)"},children:_.l}),l.jsx("span",{children:_.v.toLocaleString()})]}),l.jsx("div",{style:{height:6,background:"#0e1320",borderRadius:3},children:l.jsx("div",{style:{height:"100%",width:`${f>0?Math.round(_.v/f*100):0}%`,background:_.color,borderRadius:3}})})]},_.l))]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"累计费用"}),l.jsxs("div",{style:{display:"flex",gap:10},children:[l.jsxs("span",{style:{fontSize:12,color:o.cost_cny>10?"var(--danger)":o.cost_cny>3?"var(--warn)":"var(--ok)"},children:[l.jsxs("b",{children:["¥",o.cost_cny]})," 人民币"]}),l.jsxs("span",{style:{fontSize:12},children:[l.jsxs("b",{children:["$",o.cost_usd]})," 美元"]}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["总计 ",x.toLocaleString()," tokens"]})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"sec-title",children:["参与旨意(",L.length," 道)"]}),L.length===0?l.jsx("div",{style:{fontSize:12,color:"var(--muted)",padding:"8px 0"},children:"暂无旨意记录"}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:L.map(_=>l.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",padding:"6px 8px",borderRadius:6,cursor:"pointer",border:"1px solid var(--line)"},onClick:()=>c(_.id),children:[l.jsx("span",{style:{fontSize:10,color:"var(--acc)",fontWeight:700},children:_.id}),l.jsx("span",{style:{flex:1,fontSize:12},children:_.title.substring(0,35)}),l.jsx("span",{className:`tag st-${_.state}`,style:{fontSize:10},children:Pr[_.state]||_.state})]},_.id))})]})]})}const qf=[{id:"anthropic/claude-sonnet-4-6",l:"Claude Sonnet 4.6",p:"Anthropic"},{id:"anthropic/claude-opus-4-5",l:"Claude Opus 4.5",p:"Anthropic"},{id:"anthropic/claude-haiku-3-5",l:"Claude Haiku 3.5",p:"Anthropic"},{id:"openai/gpt-4o",l:"GPT-4o",p:"OpenAI"},{id:"openai/gpt-4o-mini",l:"GPT-4o Mini",p:"OpenAI"},{id:"google/gemini-2.5-pro",l:"Gemini 2.5 Pro",p:"Google"},{id:"copilot/claude-sonnet-4",l:"Claude Sonnet 4",p:"Copilot"},{id:"copilot/claude-opus-4.5",l:"Claude Opus 4.5",p:"Copilot"},{id:"copilot/gpt-4o",l:"GPT-4o",p:"Copilot"},{id:"copilot/gemini-2.5-pro",l:"Gemini 2.5 Pro",p:"Copilot"}];function ep(){var w;const o=ee(m=>m.agentConfig),f=ee(m=>m.changeLog),c=ee(m=>m.loadAgentConfig),y=ee(m=>m.toast),[x,L]=V.useState({}),[T,_]=V.useState({});if(V.useEffect(()=>{c()},[c]),V.useEffect(()=>{if(o!=null&&o.agents){const m={};o.agents.forEach(R=>{m[R.id]=R.model}),L(m)}},[o]),!(o!=null&&o.agents))return l.jsx("div",{className:"empty",style:{gridColumn:"1/-1"},children:"⚠️ 请先启动本地服务器"});const b=(w=o.knownModels)!=null&&w.length?o.knownModels.map(m=>({id:m.id,l:m.label,p:m.provider})):qf,C=(m,R)=>{L(g=>({...g,[m]:R}))},z=m=>{const R=o.agents.find(g=>g.id===m);R&&L(g=>({...g,[m]:R.model}))},d=async m=>{const R=x[m];if(R){_(g=>({...g,[m]:{cls:"pending",text:"⟳ 提交中…"}}));try{const g=await fe.setModel(m,R);g.ok?(_(A=>({...A,[m]:{cls:"ok",text:"✅ 已提交,Gateway 重启中(约5秒)"}})),y(m+" 模型已更改","ok"),setTimeout(()=>c(),5500)):_(A=>({...A,[m]:{cls:"err",text:"❌ "+(g.error||"错误")}}))}catch{_(g=>({...g,[m]:{cls:"err",text:"❌ 无法连接服务器"}}))}}};return l.jsxs("div",{children:[l.jsx("div",{className:"model-grid",children:o.agents.map(m=>{const R=x[m.id]||m.model,g=R!==m.model,A=T[m.id];return l.jsxs("div",{className:"mc-card",children:[l.jsxs("div",{className:"mc-top",children:[l.jsx("span",{className:"mc-emoji",children:m.emoji||"🏛️"}),l.jsxs("div",{children:[l.jsxs("div",{className:"mc-name",children:[m.label," ",l.jsx("span",{style:{fontSize:11,color:"var(--muted)"},children:m.id})]}),l.jsx("div",{className:"mc-role",children:m.role})]})]}),l.jsxs("div",{className:"mc-cur",children:["当前: ",l.jsx("b",{children:m.model})]}),l.jsx("select",{className:"msel",value:R,onChange:P=>C(m.id,P.target.value),children:b.map(P=>l.jsxs("option",{value:P.id,children:[P.l," (",P.p,")"]},P.id))}),l.jsxs("div",{className:"mc-btns",children:[l.jsx("button",{className:"btn btn-p",disabled:!g,onClick:()=>d(m.id),children:"应用"}),l.jsx("button",{className:"btn btn-g",onClick:()=>z(m.id),children:"重置"})]}),A&&l.jsx("div",{className:`mc-st ${A.cls}`,children:A.text})]},m.id)})}),l.jsxs("div",{style:{marginTop:24},children:[l.jsx("div",{className:"sec-title",children:"变更日志"}),l.jsx("div",{className:"cl-list",children:f!=null&&f.length?[...f].reverse().slice(0,15).map((m,R)=>l.jsxs("div",{className:"cl-row",children:[l.jsx("span",{className:"cl-t",children:(m.at||"").substring(0,16).replace("T"," ")}),l.jsx("span",{className:"cl-a",children:m.agentId}),l.jsxs("span",{className:"cl-c",children:[l.jsx("b",{children:m.oldModel})," → ",l.jsx("b",{children:m.newModel}),m.rolledBack&&l.jsx("span",{style:{color:"var(--danger)",fontSize:10,border:"1px solid #ff527044",padding:"1px 5px",borderRadius:3,marginLeft:4},children:"⚠ 已回滚"})]})]},R)):l.jsx("div",{style:{fontSize:12,color:"var(--muted)",padding:"8px 0"},children:"暂无变更"})})]})]})}const tp=[{label:"obra/superpowers",emoji:"⚡",stars:"66.9k",desc:"完整开发工作流技能集",skills:[{name:"brainstorming",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/brainstorming/SKILL.md"},{name:"test-driven-development",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/test-driven-development/SKILL.md"},{name:"systematic-debugging",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/systematic-debugging/SKILL.md"},{name:"subagent-driven-development",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/subagent-driven-development/SKILL.md"},{name:"writing-plans",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/writing-plans/SKILL.md"},{name:"executing-plans",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/executing-plans/SKILL.md"},{name:"requesting-code-review",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/requesting-code-review/SKILL.md"},{name:"root-cause-tracing",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/root-cause-tracing/SKILL.md"},{name:"verification-before-completion",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/verification-before-completion/SKILL.md"},{name:"dispatching-parallel-agents",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/dispatching-parallel-agents/SKILL.md"}]},{label:"anthropics/skills",emoji:"🏛️",stars:"官方",desc:"Anthropic 官方技能库",skills:[{name:"docx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/docx/SKILL.md"},{name:"pdf",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/pdf/SKILL.md"},{name:"xlsx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/xlsx/SKILL.md"},{name:"pptx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/pptx/SKILL.md"},{name:"mcp-builder",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/mcp-builder/SKILL.md"},{name:"frontend-design",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/frontend-design/SKILL.md"},{name:"web-artifacts-builder",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/web-artifacts-builder/SKILL.md"},{name:"webapp-testing",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/webapp-testing/SKILL.md"},{name:"algorithmic-art",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/algorithmic-art/SKILL.md"},{name:"canvas-design",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/canvas-design/SKILL.md"}]},{label:"ComposioHQ/awesome-claude-skills",emoji:"🌐",stars:"39.2k",desc:"100+ 社区精选技能",skills:[{name:"github-integration",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/github-integration/SKILL.md"},{name:"data-analysis",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/data-analysis/SKILL.md"},{name:"code-review",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/code-review/SKILL.md"}]}];function np(){const o=ee(k=>k.agentConfig),f=ee(k=>k.loadAgentConfig),c=ee(k=>k.toast),[y,x]=V.useState(null),[L,T]=V.useState(null),[_,b]=V.useState({name:"",desc:"",trigger:""}),[C,z]=V.useState(!1),[d,w]=V.useState("local"),[m,R]=V.useState([]),[g,A]=V.useState(!1),[P,W]=V.useState(!1),[J,I]=V.useState({agentId:"",skillName:"",sourceUrl:"",description:""}),[oe,ue]=V.useState(!1),[me,pe]=V.useState(null),[Ae,X]=V.useState(null),[ie,ke]=V.useState(null),[re,te]=V.useState("");V.useEffect(()=>{f()},[f]),V.useEffect(()=>{d==="remote"&&Ne()},[d]);const Ne=async()=>{A(!0);try{const k=await fe.remoteSkillsList();k.ok&&R(k.remoteSkills||[])}catch{c("远程技能列表加载失败","err")}A(!1)},Ee=async(k,H)=>{x({agentId:k,name:H,content:"⟳ 加载中…",path:""});try{const ne=await fe.skillContent(k,H);ne.ok?x({agentId:k,name:H,content:ne.content||"",path:ne.path||""}):x({agentId:k,name:H,content:"❌ "+(ne.error||"无法读取"),path:""})}catch{x({agentId:k,name:H,content:"❌ 服务器连接失败",path:""})}},je=(k,H)=>{T({agentId:k,agentLabel:H}),b({name:"",desc:"",trigger:""})},E=async k=>{if(k.preventDefault(),!(!L||!_.name)){z(!0);try{const H=await fe.addSkill(L.agentId,_.name,_.desc,_.trigger);H.ok?(c(`✅ 技能 ${_.name} 已添加到 ${L.agentLabel}`,"ok"),T(null),f()):c(H.error||"添加失败","err")}catch{c("服务器连接失败","err")}z(!1)}},K=async k=>{k.preventDefault();const{agentId:H,skillName:ne,sourceUrl:ve,description:M}=J;if(!(!H||!ne||!ve)){ue(!0);try{const ce=await fe.addRemoteSkill(H,ne,ve,M);ce.ok?(c(`✅ 远程技能 ${ne} 已添加到 ${H}`,"ok"),W(!1),I({agentId:"",skillName:"",sourceUrl:"",description:""}),Ne(),f()):c(ce.error||"添加失败","err")}catch{c("服务器连接失败","err")}ue(!1)}},U=async k=>{const H=`${k.agentId}/${k.skillName}`;pe(H);try{const ne=await fe.updateRemoteSkill(k.agentId,k.skillName);ne.ok?(c(`✅ 技能 ${k.skillName} 已更新`,"ok"),Ne()):c(ne.error||"更新失败","err")}catch{c("服务器连接失败","err")}pe(null)},v=async k=>{const H=`${k.agentId}/${k.skillName}`;X(H);try{const ne=await fe.removeRemoteSkill(k.agentId,k.skillName);ne.ok?(c(`🗑️ 技能 ${k.skillName} 已移除`,"ok"),Ne(),f()):c(ne.error||"移除失败","err")}catch{c("服务器连接失败","err")}X(null)},D=async(k,H)=>{if(!re){c("请先选择目标 Agent","err");return}try{const ne=await fe.addRemoteSkill(re,H,k,"");ne.ok?(c(`✅ ${H} → ${re}`,"ok"),Ne(),f()):c(ne.error||"导入失败","err")}catch{c("服务器连接失败","err")}};if(!(o!=null&&o.agents))return l.jsx("div",{className:"empty",children:"无法加载"});const de=l.jsx("div",{children:l.jsx("div",{className:"skills-grid",children:o.agents.map(k=>l.jsxs("div",{className:"sk-card",children:[l.jsxs("div",{className:"sk-hdr",children:[l.jsx("span",{className:"sk-emoji",children:k.emoji||"🏛️"}),l.jsx("span",{className:"sk-name",children:k.label}),l.jsxs("span",{className:"sk-cnt",children:[(k.skills||[]).length," 技能"]})]}),l.jsx("div",{className:"sk-list",children:(k.skills||[]).length?(k.skills||[]).map(H=>l.jsxs("div",{className:"sk-item",onClick:()=>Ee(k.id,H.name),children:[l.jsxs("span",{className:"si-name",children:["📦 ",H.name]}),l.jsx("span",{className:"si-desc",children:H.description||"无描述"}),l.jsx("span",{className:"si-arrow",children:"›"})]},H.name)):l.jsx("div",{className:"sk-empty",children:"暂无 Skills"})}),l.jsx("div",{className:"sk-add",onClick:()=>je(k.id,k.label),children:"+ 添加技能"})]},k.id))})}),he=l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:10,marginBottom:20,flexWrap:"wrap",alignItems:"center"},children:[l.jsx("button",{style:{padding:"8px 18px",background:"var(--acc)",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600,fontSize:13},onClick:()=>{W(!0),ke(null)},children:"+ 添加远程 Skill"}),l.jsx("button",{style:{padding:"8px 14px",background:"transparent",color:"var(--acc)",border:"1px solid var(--acc)",borderRadius:8,cursor:"pointer",fontSize:12},onClick:Ne,children:"⟳ 刷新列表"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:4},children:["共 ",m.length," 个远程技能"]})]}),l.jsxs("div",{style:{marginBottom:24},children:[l.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--muted)",letterSpacing:".06em",marginBottom:10},children:"🌐 社区技能源 — 一键导入"}),l.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:tp.map(k=>l.jsxs("div",{onClick:()=>ke((ie==null?void 0:ie.label)===k.label?null:k),style:{padding:"8px 14px",background:(ie==null?void 0:ie.label)===k.label?"#0d1f45":"var(--panel)",border:`1px solid ${(ie==null?void 0:ie.label)===k.label?"var(--acc)":"var(--line)"}`,borderRadius:10,cursor:"pointer",fontSize:12,transition:"all .15s"},children:[l.jsx("span",{style:{marginRight:6},children:k.emoji}),l.jsx("b",{style:{color:"var(--text)"},children:k.label}),l.jsxs("span",{style:{marginLeft:6,color:"#f0b429",fontSize:11},children:["★ ",k.stars]}),l.jsx("span",{style:{marginLeft:8,color:"var(--muted)"},children:k.desc})]},k.label))}),ie&&l.jsxs("div",{style:{marginTop:14,background:"var(--panel)",border:"1px solid var(--line)",borderRadius:12,padding:16},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[l.jsx("span",{style:{fontSize:12,fontWeight:600},children:"目标 Agent:"}),l.jsxs("select",{value:re,onChange:k=>te(k.target.value),style:{padding:"6px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12},children:[l.jsx("option",{value:"",children:"— 选择 Agent —"}),o.agents.map(k=>l.jsxs("option",{value:k.id,children:[k.emoji," ",k.label," (",k.id,")"]},k.id))]})]}),l.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:8},children:ie.skills.map(k=>{const H=m.some(ne=>ne.skillName===k.name&&ne.agentId===re);return l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"var(--panel2)",borderRadius:8,border:"1px solid var(--line)"},children:[l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:12,fontWeight:600},children:["📦 ",k.name]}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)",wordBreak:"break-all",maxWidth:180},children:k.url.split("/").slice(-2).join("/")})]}),H?l.jsx("span",{style:{fontSize:10,color:"#4caf88",fontWeight:600},children:"✓ 已导入"}):l.jsx("button",{onClick:()=>D(k.url,k.name),style:{padding:"4px 10px",background:"var(--acc)",color:"#fff",border:"none",borderRadius:6,cursor:"pointer",fontSize:11,whiteSpace:"nowrap"},children:"导入"})]},k.name)})})]})]}),g?l.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:"var(--muted)",fontSize:13},children:"⟳ 加载中…"}):m.length===0?l.jsxs("div",{style:{textAlign:"center",padding:"40px",background:"var(--panel)",borderRadius:12,border:"1px dashed var(--line)"},children:[l.jsx("div",{style:{fontSize:32,marginBottom:10},children:"🌐"}),l.jsx("div",{style:{fontSize:14,color:"var(--muted)"},children:"尚无远程技能"}),l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginTop:6},children:"从社区技能源快速导入,或手动添加 URL"})]}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:m.map(k=>{var ce;const H=`${k.agentId}/${k.skillName}`,ne=me===H,ve=Ae===H,M=o.agents.find(ye=>ye.id===k.agentId);return l.jsxs("div",{style:{background:"var(--panel)",border:"1px solid var(--line)",borderRadius:12,padding:"14px 18px",display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:6},children:[l.jsxs("span",{style:{fontSize:14,fontWeight:700},children:["📦 ",k.skillName]}),l.jsx("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:k.status==="valid"?"#0d3322":"#3d1111",color:k.status==="valid"?"#4caf88":"#ff5270",fontWeight:600},children:k.status==="valid"?"✓ 有效":"✗ 文件丢失"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",background:"var(--panel2)",padding:"2px 8px",borderRadius:6},children:[M==null?void 0:M.emoji," ",(M==null?void 0:M.label)||k.agentId]})]}),k.description&&l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:4},children:k.description}),l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",display:"flex",gap:16,flexWrap:"wrap"},children:[l.jsxs("span",{children:["🔗 ",l.jsx("a",{href:k.sourceUrl,target:"_blank",rel:"noreferrer",style:{color:"var(--acc)",textDecoration:"none"},children:k.sourceUrl.length>60?k.sourceUrl.slice(0,60)+"…":k.sourceUrl})]}),l.jsxs("span",{children:["📅 ",k.lastUpdated?k.lastUpdated.slice(0,10):(ce=k.addedAt)==null?void 0:ce.slice(0,10)]})]})]}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:()=>Ee(k.agentId,k.skillName),style:{padding:"6px 12px",background:"transparent",color:"var(--muted)",border:"1px solid var(--line)",borderRadius:6,cursor:"pointer",fontSize:11},children:"查看"}),l.jsx("button",{onClick:()=>U(k),disabled:ne,style:{padding:"6px 12px",background:"transparent",color:"var(--acc)",border:"1px solid var(--acc)",borderRadius:6,cursor:"pointer",fontSize:11},children:ne?"⟳":"更新"}),l.jsx("button",{onClick:()=>v(k),disabled:ve,style:{padding:"6px 12px",background:"transparent",color:"#ff5270",border:"1px solid #ff5270",borderRadius:6,cursor:"pointer",fontSize:11},children:ve?"⟳":"删除"})]})]},H)})})]});return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:4,marginBottom:20,borderBottom:"1px solid var(--line)",paddingBottom:0},children:[{key:"local",label:"🏛️ 本地技能",count:o.agents.reduce((k,H)=>{var ne;return k+(((ne=H.skills)==null?void 0:ne.length)||0)},0)},{key:"remote",label:"🌐 远程技能",count:m.length}].map(k=>l.jsxs("div",{onClick:()=>w(k.key),style:{padding:"8px 18px",cursor:"pointer",fontSize:13,borderRadius:"8px 8px 0 0",fontWeight:d===k.key?700:400,background:d===k.key?"var(--panel)":"transparent",color:d===k.key?"var(--text)":"var(--muted)",border:d===k.key?"1px solid var(--line)":"1px solid transparent",borderBottom:d===k.key?"1px solid var(--panel)":"1px solid transparent",position:"relative",bottom:-1,transition:"all .15s"},children:[k.label,k.count>0&&l.jsx("span",{style:{marginLeft:6,fontSize:10,padding:"1px 6px",borderRadius:999,background:"#1a2040",color:"var(--acc)"},children:k.count})]},k.key))}),d==="local"?de:he,y&&l.jsx("div",{className:"modal-bg open",onClick:()=>x(null),children:l.jsxs("div",{className:"modal",onClick:k=>k.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>x(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:y.agentId.toUpperCase()}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:16},children:["📦 ",y.name]}),l.jsxs("div",{className:"sk-modal-body",children:[l.jsx("div",{className:"sk-md",style:{whiteSpace:"pre-wrap",fontSize:12,lineHeight:1.7},children:y.content}),y.path&&l.jsxs("div",{className:"sk-path",style:{fontSize:10,color:"var(--muted)",marginTop:12},children:["📂 ",y.path]})]})]})]})}),L&&l.jsx("div",{className:"modal-bg open",onClick:()=>T(null),children:l.jsxs("div",{className:"modal",onClick:k=>k.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>T(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsxs("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:["为 ",L.agentLabel," 添加技能"]}),l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:18},children:"+ 新增 Skill"}),l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:10,padding:14,marginBottom:18,fontSize:12,lineHeight:1.7,color:"var(--muted)"},children:[l.jsx("b",{style:{color:"var(--text)"},children:"📋 Skill 规范说明"}),l.jsx("br",{}),"• 技能名称使用",l.jsx("b",{style:{color:"var(--text)"},children:"小写英文 + 连字符"}),l.jsx("br",{}),"• 创建后会生成模板文件 SKILL.md",l.jsx("br",{}),"• 技能会在 agent 收到相关任务时",l.jsx("b",{style:{color:"var(--text)"},children:"自动激活"})]}),l.jsxs("form",{onSubmit:E,style:{display:"flex",flexDirection:"column",gap:14},children:[l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["技能名称 ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"text",required:!0,placeholder:"如 data-analysis, code-review",value:_.name,onChange:k=>b(H=>({...H,name:k.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"技能描述"}),l.jsx("input",{type:"text",placeholder:"一句话说明用途",value:_.desc,onChange:k=>b(H=>({...H,desc:k.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"触发条件(可选)"}),l.jsx("input",{type:"text",placeholder:"何时激活此技能",value:_.trigger,onChange:k=>b(H=>({...H,trigger:k.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",marginTop:4},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:()=>T(null),style:{padding:"8px 20px"},children:"取消"}),l.jsx("button",{type:"submit",disabled:C,style:{padding:"8px 20px",fontSize:13,background:"var(--acc)",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600},children:C?"⟳ 创建中…":"📦 创建技能"})]})]})]})]})}),P&&l.jsx("div",{className:"modal-bg open",onClick:()=>W(!1),children:l.jsxs("div",{className:"modal",style:{maxWidth:520},onClick:k=>k.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>W(!1),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"#a07aff",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:"远程技能管理"}),l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:18},children:"🌐 添加远程 Skill"}),l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:10,padding:12,marginBottom:18,fontSize:11,color:"var(--muted)",lineHeight:1.7},children:["支持 GitHub Raw URL,如:",l.jsx("br",{}),l.jsx("code",{style:{color:"var(--acc)",fontSize:10},children:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/brainstorming/SKILL.md"})]}),l.jsxs("form",{onSubmit:K,style:{display:"flex",flexDirection:"column",gap:14},children:[l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["目标 Agent ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsxs("select",{required:!0,value:J.agentId,onChange:k=>I(H=>({...H,agentId:k.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13},children:[l.jsx("option",{value:"",children:"— 选择 Agent —"}),o.agents.map(k=>l.jsxs("option",{value:k.id,children:[k.emoji," ",k.label," (",k.id,")"]},k.id))]})]}),l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["技能名称 ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"text",required:!0,placeholder:"如 brainstorming, code-review",value:J.skillName,onChange:k=>I(H=>({...H,skillName:k.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["源 URL ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"url",required:!0,placeholder:"https://raw.githubusercontent.com/...",value:J.sourceUrl,onChange:k=>I(H=>({...H,sourceUrl:k.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:12,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"描述(可选)"}),l.jsx("input",{type:"text",placeholder:"一句话说明用途",value:J.description,onChange:k=>I(H=>({...H,description:k.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",marginTop:4},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:()=>W(!1),style:{padding:"8px 20px"},children:"取消"}),l.jsx("button",{type:"submit",disabled:oe,style:{padding:"8px 20px",fontSize:13,background:"#a07aff",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600},children:oe?"⟳ 下载中…":"🌐 添加远程技能"})]})]})]})]})})]})}function rp(){const o=ee(y=>y.agentConfig),f={},c={};return o!=null&&o.agents&&o.agents.forEach(y=>{f[y.id]=y.emoji||"🏛️",c[y.id]=y.label||y.id}),{emojiMap:f,labelMap:c}}function Hl(o){const f=(o.id||"").match(/^OC-(\w+)-/);return f?f[1]:(o.org||"").replace(/省|部/g,"").toLowerCase()}function pu(o,f){let c=o.title||"";if(c==="heartbeat 会话")return"💓 心跳检测";const y=c.match(/^agent:(\w+):(\w+)/);if(y){const x=f[y[1]]||y[1];return y[2]==="main"?x+" · 主会话":y[2]==="subagent"?x+" · 子任务执行":y[2]==="cron"?x+" · 定时任务":x+" · "+y[2]}return c.replace(/ 会话$/,"")||o.id}function mu(o){const f=o.now||"";return f.includes("feishu/direct")?{icon:"💬",text:"飞书对话"}:f.includes("feishu")?{icon:"💬",text:"飞书"}:f.includes("webchat")?{icon:"🌐",text:"WebChat"}:f.includes("cron")?{icon:"⏰",text:"定时"}:f.includes("direct")?{icon:"📨",text:"直连"}:{icon:"🔗",text:"会话"}}function lp(o){const f=o.activity||[];for(let c=f.length-1;c>=0;c--){const y=f[c];if(y.kind==="assistant"){let x=y.text||"";if(x.startsWith("NO_REPLY")||x.startsWith("Reasoning:"))continue;return x=x.replace(/\[\[.*?\]\]/g,"").replace(/\*\*/g,"").replace(/^#+\s/gm,"").trim(),x.substring(0,120)+(x.length>120?"…":"")}}return""}function sp(){const o=ee(d=>d.liveStatus),f=ee(d=>d.sessFilter),c=ee(d=>d.setSessFilter),{emojiMap:y,labelMap:x}=rp(),[L,T]=V.useState(null),b=((o==null?void 0:o.tasks)||[]).filter(d=>!ln(d));let C=b;f==="active"?C=b.filter(d=>!["Done","Cancelled"].includes(d.state)):f!=="all"&&(C=b.filter(d=>Hl(d)===f));const z=[...new Set(b.map(Hl))];return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:6,marginBottom:16,flexWrap:"wrap"},children:[{key:"all",label:`全部 (${b.length})`},{key:"active",label:"活跃"},...z.slice(0,8).map(d=>({key:d,label:x[d]||d}))].map(d=>l.jsx("span",{className:`sess-filter${f===d.key?" active":""}`,onClick:()=>c(d.key),children:d.label},d.key))}),l.jsx("div",{className:"sess-grid",children:C.length?C.map(d=>{const w=Hl(d),m=y[w]||"🏛️",R=x[w]||d.org||w,g=d.heartbeat||{status:"unknown",label:""},A=mu(d),P=pu(d,x),W=lp(d),I=(d.sourceMeta||{}).totalTokens,oe=d.eta||"",ue=g.status==="active"?"🟢":g.status==="warn"?"🟡":g.status==="stalled"?"🔴":"⚪",me=d.state||"Unknown";return l.jsxs("div",{className:"sess-card",onClick:()=>T(d),children:[l.jsxs("div",{className:"sc-top",children:[l.jsx("span",{className:"sc-emoji",children:m}),l.jsx("div",{style:{flex:1,minWidth:0},children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{className:"sc-agent",children:R}),l.jsxs("span",{style:{fontSize:10,color:"var(--muted)",background:"var(--panel2)",padding:"2px 6px",borderRadius:4},children:[A.icon," ",A.text]})]})}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{title:g.label||"",children:ue}),l.jsx("span",{className:`tag st-${me}`,style:{fontSize:10},children:Pr[me]||me})]})]}),l.jsx("div",{className:"sc-title",children:P}),W&&l.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5,marginBottom:8,borderLeft:"2px solid var(--line)",paddingLeft:8,maxHeight:40,overflow:"hidden"},children:W}),l.jsxs("div",{className:"sc-meta",children:[I?l.jsxs("span",{style:{fontSize:10,color:"var(--muted)"},children:["🪙 ",I.toLocaleString()," tokens"]}):null,oe?l.jsx("span",{className:"sc-time",children:Vf(oe)}):null]})]},d.id)}):l.jsx("div",{style:{fontSize:13,color:"var(--muted)",padding:24,textAlign:"center",gridColumn:"1/-1"},children:"暂无小任务/会话数据"})}),L&&l.jsx(ip,{task:L,labelMap:x,emojiMap:y,onClose:()=>T(null)})]})}function ip({task:o,labelMap:f,emojiMap:c,onClose:y}){const x=Hl(o),L=c[x]||"🏛️",T=pu(o,f),_=mu(o),b=o.heartbeat||{label:""},C=o.sourceMeta||{},z=o.activity||[],d=o.state||"Unknown",w=C.totalTokens,m=C.inputTokens,R=C.outputTokens;return l.jsx("div",{className:"modal-bg open",onClick:y,children:l.jsxs("div",{className:"modal",onClick:g=>g.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:y,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:o.id}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[L," ",T]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,flexWrap:"wrap"},children:[l.jsx("span",{className:`tag st-${d}`,children:Pr[d]||d}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:[_.icon," ",_.text]}),b.label&&l.jsx("span",{style:{fontSize:11},children:b.label})]}),l.jsxs("div",{style:{display:"flex",gap:14,marginBottom:18,flexWrap:"wrap"},children:[w!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--acc)"},children:w.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"总 Tokens"})]}),m!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700},children:m.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"输入"})]}),R!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700},children:R.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"输出"})]})]}),l.jsxs("div",{style:{fontSize:12,fontWeight:700,marginBottom:8},children:["📋 最近活动 ",l.jsxs("span",{style:{fontWeight:400,color:"var(--muted)"},children:["(",z.length," 条)"]})]}),l.jsx("div",{style:{maxHeight:350,overflowY:"auto",border:"1px solid var(--line)",borderRadius:10,background:"var(--panel2)"},children:z.length?z.slice(-15).reverse().map((g,A)=>{const P=g.kind||"",W=P==="assistant"?"🤖":P==="tool"?"🔧":P==="user"?"👤":"📝",J=P==="assistant"?"回复":P==="tool"?"工具":P==="user"?"用户":"事件";let I=(g.text||"").replace(/\[\[.*?\]\]/g,"").replace(/\*\*/g,"").trim();I.length>200&&(I=I.substring(0,200)+"…");const oe=(g.at||"").substring(11,19);return l.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--line)",fontSize:12,lineHeight:1.5},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[l.jsx("span",{children:W}),l.jsx("span",{style:{fontWeight:600,fontSize:11},children:J}),l.jsx("span",{style:{color:"var(--muted)",fontSize:10,marginLeft:"auto"},children:oe})]}),l.jsx("div",{style:{color:"var(--muted)"},children:I})]},A)}):l.jsx("div",{style:{padding:16,color:"var(--muted)",fontSize:12,textAlign:"center"},children:"暂无活动记录"})}),o.output&&o.output!=="-"&&l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:12,wordBreak:"break-all",borderTop:"1px solid var(--line)",paddingTop:8},children:["📂 ",o.output]})]})]})})}function op(){const o=ee(C=>C.liveStatus),[f,c]=V.useState("all"),[y,x]=V.useState(null),L=ee(C=>C.toast);let _=((o==null?void 0:o.tasks)||[]).filter(C=>ln(C)&&["Done","Cancelled"].includes(C.state));f!=="all"&&(_=_.filter(C=>C.state===f));const b=C=>{const z=C.flow_log||[];let d=`# 📜 奏折 · ${C.title} +需要可视化:{viz}`},{id:"tpl-blog",cat:"内容创作",icon:"✍️",name:"博客文章",desc:"给定主题和要求,生成高质量博客文章",depts:["礼部"],est:"~15分钟",cost:"¥1",params:[{key:"topic",label:"文章主题",type:"text",required:!0},{key:"audience",label:"目标读者",type:"text",default:"技术人员"},{key:"length",label:"期望字数",type:"select",options:["~1000字","~2000字","~3000字"],default:"~2000字"},{key:"style",label:"风格",type:"select",options:["技术教程","观点评论","案例分析"],default:"技术教程"}],command:"写一篇关于「{topic}」的博客文章,面向{audience},{length},风格:{style}"},{id:"tpl-deploy",cat:"工程开发",icon:"🚀",name:"部署方案",desc:"生成完整的部署检查单、Docker配置、CI/CD流程",depts:["兵部","工部"],est:"~25分钟",cost:"¥2",params:[{key:"project",label:"项目名称/描述",type:"text",required:!0},{key:"env",label:"部署环境",type:"select",options:["Docker","K8s","VPS","Serverless"],default:"Docker"},{key:"ci",label:"CI/CD 工具",type:"select",options:["GitHub Actions","GitLab CI","无"],default:"GitHub Actions"}],command:"为项目「{project}」生成{env}部署方案,CI/CD使用{ci}"},{id:"tpl-email",cat:"内容创作",icon:"📧",name:"邮件/通知文案",desc:"根据场景和目的,生成专业邮件或通知文案",depts:["礼部"],est:"~5分钟",cost:"¥0.3",params:[{key:"scenario",label:"使用场景",type:"select",options:["商务邮件","产品发布","客户通知","内部公告"],default:"商务邮件"},{key:"purpose",label:"目的/内容",type:"textarea",required:!0},{key:"tone",label:"语调",type:"select",options:["正式","友好","简洁"],default:"正式"}],command:"撰写一封{scenario},{tone}语调。内容:{purpose}"},{id:"tpl-standup",cat:"日常办公",icon:"🗓️",name:"每日站会摘要",desc:"汇总各部今日进展和明日计划,生成站会摘要",depts:["尚书省"],est:"~5分钟",cost:"¥0.3",params:[{key:"range",label:"汇总范围",type:"select",options:["今天","最近24小时","昨天+今天"],default:"今天"}],command:"汇总{range}各部工作进展和待办,生成站会摘要"}],Bf=[{name:"全部",icon:"📋"},{name:"日常办公",icon:"💼"},{name:"数据分析",icon:"📊"},{name:"工程开发",icon:"⚙️"},{name:"内容创作",icon:"✍️"}];let Wf=0;const ee=Mf((o,f)=>({liveStatus:null,agentConfig:null,changeLog:[],officialsData:null,agentsStatusData:null,morningBrief:null,subConfig:null,activeTab:"edicts",edictFilter:"active",sessFilter:"all",tplCatFilter:"全部",selectedOfficial:null,modalTaskId:null,countdown:5,toasts:[],setActiveTab:c=>{o({activeTab:c});const v=f();["models","skills","sessions"].includes(c)&&!v.agentConfig&&v.loadAgentConfig(),c==="officials"&&!v.officialsData&&v.loadOfficials(),c==="monitor"&&v.loadAgentsStatus(),c==="morning"&&!v.morningBrief&&v.loadMorning()},setEdictFilter:c=>o({edictFilter:c}),setSessFilter:c=>o({sessFilter:c}),setTplCatFilter:c=>o({tplCatFilter:c}),setSelectedOfficial:c=>o({selectedOfficial:c}),setModalTaskId:c=>o({modalTaskId:c}),setCountdown:c=>o({countdown:c}),toast:(c,v="ok")=>{const g=++Wf;o(P=>({toasts:[...P.toasts,{id:g,msg:c,type:v}]})),setTimeout(()=>{o(P=>({toasts:P.toasts.filter(L=>L.id!==g)}))},3e3)},loadLive:async()=>{try{const c=await de.liveStatus();o({liveStatus:c}),f().officialsData||de.officialsStats().then(g=>o({officialsData:g})).catch(()=>{})}catch{}},loadAgentConfig:async()=>{try{const c=await de.agentConfig(),v=await de.modelChangeLog();o({agentConfig:c,changeLog:v})}catch{}},loadOfficials:async()=>{try{const c=await de.officialsStats();o({officialsData:c})}catch{}},loadAgentsStatus:async()=>{try{const c=await de.agentsStatus();o({agentsStatusData:c})}catch{o({agentsStatusData:null})}},loadMorning:async()=>{try{const[c,v]=await Promise.all([de.morningBrief(),de.morningConfig()]);o({morningBrief:c,subConfig:v})}catch{}},loadSubConfig:async()=>{try{const c=await de.morningConfig();o({subConfig:c})}catch{}},loadAll:async()=>{const c=f();await c.loadLive();const v=c.activeTab;["models","skills"].includes(v)&&await c.loadAgentConfig()}}));let Lr=null;function Uf(){Lr||(ee.getState().loadAll(),Lr=setInterval(()=>{const o=ee.getState(),f=o.countdown-1;f<=0?(o.setCountdown(5),o.loadAll()):o.setCountdown(f)},1e3))}function Hf(){Lr&&(clearInterval(Lr),Lr=null)}function Vf(o){if(!o)return"";try{const f=new Date(o.includes("T")?o:o.replace(" ","T")+"Z");if(isNaN(f.getTime()))return"";const c=Date.now()-f.getTime(),v=Math.floor(c/6e4);if(v<1)return"刚刚";if(v<60)return v+"分钟前";const g=Math.floor(v/60);return g<24?g+"小时前":Math.floor(g/24)+"天前"}catch{return""}}const au={Doing:0,Review:1,Assigned:2,Menxia:3,Zhongshu:4,Taizi:5,Inbox:6,Blocked:7,Next:8,Done:9,Cancelled:10};function Qf({task:o}){const f=qi(o);return l.jsx("div",{className:"ec-pipe",children:f.map((c,v)=>l.jsxs("span",{style:{display:"contents"},children:[l.jsxs("div",{className:`ep-node ${c.status}`,children:[l.jsx("div",{className:"ep-icon",children:c.icon}),l.jsx("div",{className:"ep-name",children:c.dept})]}),vx.setModalTaskId),c=ee(x=>x.toast),v=ee(x=>x.loadAll),g=o.heartbeat||{status:"unknown",label:"⚪"},P="st-"+(o.state||""),L="dt-"+(o.org||"").replace(/\s/g,""),z=du.find((x,A)=>qi(o)[A].status==="active"),T=o.todos||[],E=T.filter(x=>x.status==="completed").length,b=T.length,d=!["Done","Blocked","Cancelled"].includes(o.state),N=["Blocked","Cancelled"].includes(o.state),j=Vl(o),O=o.block&&o.block!=="无"&&o.block!=="-",S=async(x,A)=>{if(A.stopPropagation(),x==="stop"||x==="cancel"){const V=prompt(x==="stop"?"请输入叫停原因:":"请输入取消原因:");if(V===null)return;try{const R=await de.taskAction(o.id,x,V);R.ok?(c(R.message||"操作成功"),v()):c(R.error||"操作失败","err")}catch{c("服务器连接失败","err")}}else if(x==="resume")try{const V=await de.taskAction(o.id,"resume","恢复执行");V.ok?(c(V.message||"已恢复"),v()):c(V.error||"操作失败","err")}catch{c("服务器连接失败","err")}},M=async x=>{x.stopPropagation();try{const A=await de.archiveTask(o.id,!o.archived);A.ok?(c(A.message||"操作成功"),v()):c(A.error||"操作失败","err")}catch{c("服务器连接失败","err")}};return l.jsxs("div",{className:`edict-card${j?" archived":""}`,onClick:()=>f(o.id),children:[l.jsx(Qf,{task:o}),l.jsx("div",{className:"ec-id",children:o.id}),l.jsx("div",{className:"ec-title",children:o.title||"(无标题)"}),l.jsxs("div",{className:"ec-meta",children:[l.jsx("span",{className:`tag ${P}`,children:Ji(o)}),o.org&&l.jsx("span",{className:`tag ${L}`,children:o.org}),z&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["当前: ",l.jsxs("b",{style:{color:Ul(z.dept)},children:[z.dept," · ",z.action]})]})]}),o.now&&o.now!=="-"&&l.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5,marginBottom:6},children:o.now.substring(0,80)}),(o.review_round||0)>0&&l.jsxs("div",{style:{fontSize:11,marginBottom:6},children:[Array.from({length:o.review_round||0},(x,A)=>l.jsx("span",{style:{display:"inline-block",width:14,height:14,borderRadius:"50%",background:A<(o.review_round||0)-1?"#1a3a6a22":"var(--acc)22",border:`1px solid ${A<(o.review_round||0)-1?"#2a4a8a":"var(--acc)"}`,fontSize:9,textAlign:"center",lineHeight:"13px",marginRight:2,color:A<(o.review_round||0)-1?"#4a6aaa":"var(--acc)"},children:A+1},A)),l.jsxs("span",{style:{color:"var(--muted)",fontSize:10},children:["第 ",o.review_round," 轮磋商"]})]}),b>0&&l.jsxs("div",{className:"ec-todo-bar",children:[l.jsxs("span",{children:["📋 ",E,"/",b]}),l.jsx("div",{className:"ec-todo-track",children:l.jsx("div",{className:"ec-todo-fill",style:{width:`${Math.round(E/b*100)}%`}})}),l.jsx("span",{children:E===b?"✅ 全部完成":"🔄 进行中"})]}),l.jsxs("div",{className:"ec-footer",children:[l.jsx("span",{className:`hb ${g.status}`,children:g.label}),O&&l.jsxs("span",{className:"tag",style:{borderColor:"#ff527044",color:"var(--danger)",background:"#200a10"},children:["🚫 ",o.block]}),o.eta&&o.eta!=="-"&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["📅 ",o.eta]})]}),l.jsxs("div",{className:"ec-actions",onClick:x=>x.stopPropagation(),children:[d&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"mini-act",onClick:x=>S("stop",x),children:"⏸ 叫停"}),l.jsx("button",{className:"mini-act danger",onClick:x=>S("cancel",x),children:"🚫 取消"})]}),N&&l.jsx("button",{className:"mini-act",onClick:x=>S("resume",x),children:"▶ 恢复"}),j&&!o.archived&&l.jsx("button",{className:"mini-act",onClick:M,children:"📦 归档"}),o.archived&&l.jsx("button",{className:"mini-act",onClick:M,children:"📤 取消归档"})]})]})}function Gf(){const o=ee(j=>j.liveStatus),f=ee(j=>j.edictFilter),c=ee(j=>j.setEdictFilter),v=ee(j=>j.toast),g=ee(j=>j.loadAll),L=((o==null?void 0:o.tasks)||[]).filter(ln),z=L.filter(j=>!Vl(j)),T=L.filter(j=>Vl(j));let E;f==="active"?E=z:f==="archived"?E=T:E=L,E.sort((j,O)=>(au[j.state]??9)-(au[O.state]??9));const b=L.filter(j=>!j.archived&&["Done","Cancelled"].includes(j.state)),d=async()=>{if(confirm("将所有已完成/已取消的旨意移入归档?"))try{const j=await de.archiveAllDone();j.ok?(v(`📦 ${j.count||0} 道旨意已归档`),g()):v(j.error||"批量归档失败","err")}catch{v("服务器连接失败","err")}},N=async()=>{try{const j=await de.schedulerScan();j.ok?v(`🧭 太子巡检完成:${j.count||0} 个动作`):v(j.error||"巡检失败","err"),g()}catch{v("服务器连接失败","err")}};return l.jsxs("div",{children:[l.jsxs("div",{className:"archive-bar",children:[l.jsx("span",{className:"ab-label",children:"筛选:"}),["active","archived","all"].map(j=>l.jsx("button",{className:`ab-btn ${f===j?"active":""}`,onClick:()=>c(j),children:j==="active"?"活跃":j==="archived"?"归档":"全部"},j)),b.length>0&&l.jsx("button",{className:"ab-btn",onClick:d,children:"📦 一键归档"}),l.jsxs("span",{className:"ab-count",children:["活跃 ",z.length," · 归档 ",T.length," · 共 ",L.length]}),l.jsx("button",{className:"ab-scan",onClick:N,children:"🧭 太子巡检"})]}),l.jsx("div",{className:"edict-grid",children:E.length===0?l.jsxs("div",{className:"empty",style:{gridColumn:"1/-1"},children:["暂无旨意",l.jsx("br",{}),l.jsx("small",{style:{fontSize:11,marginTop:6,display:"block",color:"var(--muted)"},children:"通过飞书向太子发送任务,太子分拣后转中书省处理"})]}):E.map(j=>l.jsx(Kf,{task:j},j.id))})]})}function Yf(){var V;const o=ee(R=>R.liveStatus),f=ee(R=>R.agentsStatusData),c=ee(R=>R.officialsData),v=ee(R=>R.loadAgentsStatus),g=ee(R=>R.setModalTaskId),P=ee(R=>R.toast);Q.useEffect(()=>{v()},[v]);const z=((o==null?void 0:o.tasks)||[]).filter(R=>ln(R)&&R.state!=="Done"&&R.state!=="Next"),T={};c!=null&&c.officials&&c.officials.forEach(R=>{T[R.id]=R});const E=async R=>{try{const re=await de.agentWake(R);P(re.message||"唤醒指令已发出"),setTimeout(()=>v(),3e4)}catch{P("唤醒失败","err")}},b=async()=>{if(!f)return;const R=f.agents.filter(re=>re.id!=="main"&&re.status!=="running"&&re.status!=="unconfigured");if(!R.length){P("所有 Agent 均已在线");return}P(`正在唤醒 ${R.length} 个 Agent...`);for(const re of R)try{await de.agentWake(re.id)}catch{}P(`${R.length} 个唤醒指令已发出,30秒后刷新状态`),setTimeout(()=>v(),3e4)},d=f,N=((V=d==null?void 0:d.agents)==null?void 0:V.filter(R=>R.id!=="main"))||[],j=N.filter(R=>R.status==="running").length,O=N.filter(R=>R.status==="idle").length,S=N.filter(R=>R.status==="offline").length,M=N.filter(R=>R.status==="unconfigured").length,x=d==null?void 0:d.gateway,A=x!=null&&x.probe?"ok":x!=null&&x.alive?"warn":"err";return l.jsxs("div",{children:[d&&d.ok&&l.jsxs("div",{className:"as-panel",children:[l.jsxs("div",{className:"as-header",children:[l.jsx("span",{className:"as-title",children:"🔌 Agent 在线状态"}),l.jsxs("span",{className:`as-gw ${A}`,children:["Gateway: ",(x==null?void 0:x.status)||"未知"]}),l.jsx("button",{className:"btn-refresh",onClick:()=>v(),style:{marginLeft:8},children:"🔄 刷新"}),S+M>0&&l.jsx("button",{className:"btn-refresh",onClick:b,style:{marginLeft:4,borderColor:"var(--warn)",color:"var(--warn)"},children:"⚡ 全部唤醒"})]}),l.jsx("div",{className:"as-grid",children:N.map(R=>{const re=R.status!=="running"&&R.status!=="unconfigured"&&(x==null?void 0:x.alive);return l.jsxs("div",{className:"as-card",title:`${R.role} · ${R.statusLabel}`,children:[l.jsx("div",{className:`as-dot ${R.status}`}),l.jsx("div",{style:{fontSize:22},children:R.emoji}),l.jsx("div",{style:{fontSize:12,fontWeight:700},children:R.label}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:R.role}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:R.statusLabel}),R.lastActive?l.jsxs("div",{style:{fontSize:10,color:"var(--muted)"},children:["⏰ ",R.lastActive]}):l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"无活动记录"}),re&&l.jsx("button",{className:"as-wake-btn",onClick:ue=>{ue.stopPropagation(),E(R.id)},children:"⚡ 唤醒"})]},R.id)})}),l.jsxs("div",{className:"as-summary",children:[l.jsxs("span",{children:[l.jsx("span",{className:"as-dot running",style:{position:"static",width:8,height:8}})," ",j," 运行中"]}),l.jsxs("span",{children:[l.jsx("span",{className:"as-dot idle",style:{position:"static",width:8,height:8}})," ",O," 待命"]}),S>0&&l.jsxs("span",{children:[l.jsx("span",{className:"as-dot offline",style:{position:"static",width:8,height:8}})," ",S," 离线"]}),M>0&&l.jsxs("span",{children:[l.jsx("span",{className:"as-dot unconfigured",style:{position:"static",width:8,height:8}})," ",M," 未配置"]}),l.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--muted)"},children:["检测于 ",(d.checkedAt||"").substring(11,19)]})]})]}),l.jsx("div",{className:"duty-grid",children:fu.map(R=>{const re=z.filter(le=>le.org===R.label),ue=re.some(le=>le.state==="Doing"),me=re.some(le=>le.state==="Blocked"),pe=T[R.id],Ae=(pe==null?void 0:pe.heartbeat)||{status:"idle"},Z=me?"blocked":ue?"busy":Ae.status==="active"?"active":"idle",oe=me?"⚠️ 阻塞":ue?"⚙️ 执行中":Ae.status==="active"?"🟢 活跃":"⚪ 候命",ke=me?"blocked-card":ue?"active-card":"";return l.jsxs("div",{className:`duty-card ${ke}`,children:[l.jsxs("div",{className:"dc-hdr",children:[l.jsx("span",{className:"dc-emoji",children:R.emoji}),l.jsxs("div",{className:"dc-info",children:[l.jsx("div",{className:"dc-name",children:R.label}),l.jsxs("div",{className:"dc-role",children:[R.role," · ",R.rank]})]}),l.jsxs("div",{className:"dc-status",children:[l.jsx("span",{className:`dc-dot ${Z}`}),l.jsx("span",{children:oe})]})]}),l.jsx("div",{className:"dc-body",children:re.length>0?re.map(le=>l.jsxs("div",{className:"dc-task",onClick:()=>g(le.id),children:[l.jsx("div",{className:"dc-task-id",children:le.id}),l.jsx("div",{className:"dc-task-title",children:le.title||"(无标题)"}),le.now&&le.now!=="-"&&l.jsx("div",{className:"dc-task-now",children:le.now.substring(0,70)}),l.jsxs("div",{className:"dc-task-meta",children:[l.jsx("span",{className:`tag st-${le.state}`,children:Ji(le)}),le.block&&le.block!=="无"&&l.jsxs("span",{className:"tag",style:{borderColor:"#ff527044",color:"var(--danger)"},children:["🚫",le.block]})]})]},le.id)):l.jsxs("div",{className:"dc-idle",children:[l.jsx("span",{style:{fontSize:20},children:"🪭"}),l.jsx("span",{children:"候命中"})]})}),l.jsxs("div",{className:"dc-footer",children:[l.jsxs("span",{className:"dc-model",children:["🤖 ",(pe==null?void 0:pe.model_short)||"待配置"]}),(pe==null?void 0:pe.last_active)&&l.jsxs("span",{className:"dc-la",children:["⏰ ",pe.last_active]})]})]},R.id)})})]})}const Xf=["🥇","🥈","🥉"];function Zf(){var d;const o=ee(N=>N.officialsData),f=ee(N=>N.selectedOfficial),c=ee(N=>N.setSelectedOfficial),v=ee(N=>N.loadOfficials),g=ee(N=>N.setModalTaskId);if(Q.useEffect(()=>{v()},[v]),!(o!=null&&o.officials))return l.jsx("div",{className:"empty",children:"⚠️ 请确保本地服务器已启动"});const P=o.officials,L=o.totals||{tasks_done:0,cost_cny:0},z=Math.max(...P.map(N=>N.tokens_in+N.tokens_out+N.cache_read+N.cache_write),1),T=P.filter(N=>{var j;return((j=N.heartbeat)==null?void 0:j.status)==="active"}),E=P.find(N=>{var j;return N.id===(f||((j=P[0])==null?void 0:j.id))}),b=(E==null?void 0:E.id)||((d=P[0])==null?void 0:d.id);return l.jsxs("div",{children:[T.length>0&&l.jsxs("div",{className:"off-activity",children:[l.jsx("span",{children:"🟢 当前活跃:"}),T.map(N=>l.jsxs("span",{style:{fontSize:12},children:[N.emoji," ",N.role]},N.id)),l.jsx("span",{style:{color:"var(--muted)",fontSize:11,marginLeft:"auto"},children:"其余官员待命"})]}),l.jsxs("div",{className:"off-kpi",children:[l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{color:"var(--acc)"},children:P.length}),l.jsx("div",{className:"kpi-l",children:"在职官员"})]}),l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{color:"#f5c842"},children:L.tasks_done||0}),l.jsx("div",{className:"kpi-l",children:"累计完成旨意"})]}),l.jsxs("div",{className:"kpi",children:[l.jsxs("div",{className:"kpi-v",style:{color:(L.cost_cny||0)>20?"var(--warn)":"var(--ok)"},children:["¥",L.cost_cny||0]}),l.jsx("div",{className:"kpi-l",children:"累计费用(含缓存)"})]}),l.jsxs("div",{className:"kpi",children:[l.jsx("div",{className:"kpi-v",style:{fontSize:16,paddingTop:4},children:o.top_official||"—"}),l.jsx("div",{className:"kpi-l",children:"功绩最高"})]})]}),l.jsxs("div",{className:"off-layout",children:[l.jsxs("div",{className:"off-ranklist",children:[l.jsx("div",{className:"orl-hdr",children:"功绩排行"}),P.map(N=>{const j=N.heartbeat||{status:"idle"};return l.jsxs("div",{className:`orl-item${b===N.id?" selected":""}`,onClick:()=>c(N.id),children:[l.jsx("span",{style:{minWidth:24,textAlign:"center"},children:N.merit_rank<=3?Xf[N.merit_rank-1]:"#"+N.merit_rank}),l.jsx("span",{children:N.emoji}),l.jsxs("span",{style:{flex:1},children:[l.jsx("div",{style:{fontSize:12,fontWeight:700},children:N.role}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:N.label})]}),l.jsxs("span",{style:{fontSize:11},children:[N.merit_score,"分"]}),l.jsx("span",{className:`dc-dot ${j.status}`,style:{width:8,height:8}})]},N.id)})]}),l.jsx("div",{className:"off-detail",children:E?l.jsx(Jf,{official:E,maxTk:z,onOpenTask:g}):l.jsx("div",{className:"empty",children:"选择左侧官员查看详情"})})]})]})}function Jf({official:o,maxTk:f,onOpenTask:c}){const v=o.heartbeat||{status:"idle",label:"⚪ 待命"},g=o.tokens_in+o.tokens_out+o.cache_read+o.cache_write,P=o.participated_edicts||[],L=[{l:"输入",v:o.tokens_in,color:"#6a9eff"},{l:"输出",v:o.tokens_out,color:"#a07aff"},{l:"缓存读",v:o.cache_read,color:"#2ecc8a"},{l:"缓存写",v:o.cache_write,color:"#f5c842"}];return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:16,alignItems:"center",marginBottom:20},children:[l.jsx("div",{style:{fontSize:40},children:o.emoji}),l.jsxs("div",{style:{flex:1},children:[l.jsx("div",{style:{fontSize:18,fontWeight:800},children:o.role}),l.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:[o.label," · ",l.jsx("span",{style:{color:"var(--acc)"},children:o.model_short||o.model})]}),l.jsxs("div",{style:{fontSize:11,color:"var(--muted)",marginTop:2},children:["🏅 ",o.rank," · 功绩分 ",o.merit_score]})]}),l.jsxs("div",{style:{textAlign:"right"},children:[l.jsx("div",{className:`hb ${v.status}`,style:{marginBottom:4},children:v.label}),o.last_active&&l.jsxs("div",{style:{fontSize:10,color:"var(--muted)"},children:["活跃 ",o.last_active]}),l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:2},children:[o.sessions," 个会话 · ",o.messages," 条消息"]})]})]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"功绩统计"}),l.jsxs("div",{style:{display:"flex",gap:16},children:[l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--ok)"},children:o.tasks_done}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"完成旨意"})]}),l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--warn)"},children:o.tasks_active}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"执行中"})]}),l.jsxs("div",{style:{textAlign:"center"},children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--acc)"},children:o.flow_participations}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)"},children:"流转参与"})]})]})]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"Token 消耗"}),L.map(z=>l.jsxs("div",{style:{marginBottom:6},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,marginBottom:2},children:[l.jsx("span",{style:{color:"var(--muted)"},children:z.l}),l.jsx("span",{children:z.v.toLocaleString()})]}),l.jsx("div",{style:{height:6,background:"#0e1320",borderRadius:3},children:l.jsx("div",{style:{height:"100%",width:`${f>0?Math.round(z.v/f*100):0}%`,background:z.color,borderRadius:3}})})]},z.l))]}),l.jsxs("div",{style:{marginBottom:18},children:[l.jsx("div",{className:"sec-title",children:"累计费用"}),l.jsxs("div",{style:{display:"flex",gap:10},children:[l.jsxs("span",{style:{fontSize:12,color:o.cost_cny>10?"var(--danger)":o.cost_cny>3?"var(--warn)":"var(--ok)"},children:[l.jsxs("b",{children:["¥",o.cost_cny]})," 人民币"]}),l.jsxs("span",{style:{fontSize:12},children:[l.jsxs("b",{children:["$",o.cost_usd]})," 美元"]}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["总计 ",g.toLocaleString()," tokens"]})]})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"sec-title",children:["参与旨意(",P.length," 道)"]}),P.length===0?l.jsx("div",{style:{fontSize:12,color:"var(--muted)",padding:"8px 0"},children:"暂无旨意记录"}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:P.map(z=>l.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",padding:"6px 8px",borderRadius:6,cursor:"pointer",border:"1px solid var(--line)"},onClick:()=>c(z.id),children:[l.jsx("span",{style:{fontSize:10,color:"var(--acc)",fontWeight:700},children:z.id}),l.jsx("span",{style:{flex:1,fontSize:12},children:z.title.substring(0,35)}),l.jsx("span",{className:`tag st-${z.state}`,style:{fontSize:10},children:Pr[z.state]||z.state})]},z.id))})]})]})}const qf=[{id:"anthropic/claude-sonnet-4-6",l:"Claude Sonnet 4.6",p:"Anthropic"},{id:"anthropic/claude-opus-4-5",l:"Claude Opus 4.5",p:"Anthropic"},{id:"anthropic/claude-haiku-3-5",l:"Claude Haiku 3.5",p:"Anthropic"},{id:"openai/gpt-4o",l:"GPT-4o",p:"OpenAI"},{id:"openai/gpt-4o-mini",l:"GPT-4o Mini",p:"OpenAI"},{id:"google/gemini-2.5-pro",l:"Gemini 2.5 Pro",p:"Google"},{id:"copilot/claude-sonnet-4",l:"Claude Sonnet 4",p:"Copilot"},{id:"copilot/claude-opus-4.5",l:"Claude Opus 4.5",p:"Copilot"},{id:"copilot/gpt-4o",l:"GPT-4o",p:"Copilot"},{id:"copilot/gemini-2.5-pro",l:"Gemini 2.5 Pro",p:"Copilot"}],ep=[{id:"feishu",label:"飞书 Feishu"},{id:"telegram",label:"Telegram"},{id:"wecom",label:"企业微信 WeCom"},{id:"discord",label:"Discord"},{id:"slack",label:"Slack"},{id:"signal",label:"Signal"},{id:"tui",label:"TUI (终端)"}];function tp(){var M;const o=ee(x=>x.agentConfig),f=ee(x=>x.changeLog),c=ee(x=>x.loadAgentConfig),v=ee(x=>x.toast),[g,P]=Q.useState({}),[L,z]=Q.useState({}),[T,E]=Q.useState("feishu"),[b,d]=Q.useState("");if(Q.useEffect(()=>{c()},[c]),Q.useEffect(()=>{if(o!=null&&o.agents){const x={};o.agents.forEach(A=>{x[A.id]=A.model}),P(x)}o!=null&&o.dispatchChannel&&E(o.dispatchChannel)},[o]),!(o!=null&&o.agents))return l.jsx("div",{className:"empty",style:{gridColumn:"1/-1"},children:"⚠️ 请先启动本地服务器"});const N=(M=o.knownModels)!=null&&M.length?o.knownModels.map(x=>({id:x.id,l:x.label,p:x.provider})):qf,j=(x,A)=>{P(V=>({...V,[x]:A}))},O=x=>{const A=o.agents.find(V=>V.id===x);A&&P(V=>({...V,[x]:A.model}))},S=async x=>{const A=g[x];if(A){z(V=>({...V,[x]:{cls:"pending",text:"⟳ 提交中…"}}));try{const V=await de.setModel(x,A);V.ok?(z(R=>({...R,[x]:{cls:"ok",text:"✅ 已提交,Gateway 重启中(约5秒)"}})),v(x+" 模型已更改","ok"),setTimeout(()=>c(),5500)):z(R=>({...R,[x]:{cls:"err",text:"❌ "+(V.error||"错误")}}))}catch{z(V=>({...V,[x]:{cls:"err",text:"❌ 无法连接服务器"}}))}}};return l.jsxs("div",{children:[l.jsx("div",{className:"model-grid",children:o.agents.map(x=>{const A=g[x.id]||x.model,V=A!==x.model,R=L[x.id];return l.jsxs("div",{className:"mc-card",children:[l.jsxs("div",{className:"mc-top",children:[l.jsx("span",{className:"mc-emoji",children:x.emoji||"🏛️"}),l.jsxs("div",{children:[l.jsxs("div",{className:"mc-name",children:[x.label," ",l.jsx("span",{style:{fontSize:11,color:"var(--muted)"},children:x.id})]}),l.jsx("div",{className:"mc-role",children:x.role})]})]}),l.jsxs("div",{className:"mc-cur",children:["当前: ",l.jsx("b",{children:x.model})]}),l.jsx("select",{className:"msel",value:A,onChange:re=>j(x.id,re.target.value),children:N.map(re=>l.jsxs("option",{value:re.id,children:[re.l," (",re.p,")"]},re.id))}),l.jsxs("div",{className:"mc-btns",children:[l.jsx("button",{className:"btn btn-p",disabled:!V,onClick:()=>S(x.id),children:"应用"}),l.jsx("button",{className:"btn btn-g",onClick:()=>O(x.id),children:"重置"})]}),R&&l.jsx("div",{className:`mc-st ${R.cls}`,children:R.text})]},x.id)})}),l.jsxs("div",{style:{marginTop:24,marginBottom:8},children:[l.jsx("div",{className:"sec-title",children:"派发渠道"}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 0"},children:[l.jsx("select",{className:"msel",value:T,onChange:x=>E(x.target.value),style:{maxWidth:220},children:ep.map(x=>l.jsx("option",{value:x.id,children:x.label},x.id))}),l.jsx("button",{className:"btn btn-p",disabled:T===((o==null?void 0:o.dispatchChannel)||"feishu"),onClick:async()=>{try{const x=await de.setDispatchChannel(T);x.ok?(d("✅ 已保存"),v("派发渠道已切换","ok"),c()):d("❌ "+(x.error||"失败"))}catch{d("❌ 无法连接")}setTimeout(()=>d(""),3e3)},children:"应用"}),b&&l.jsx("span",{style:{fontSize:12,color:b.startsWith("✅")?"var(--success)":"var(--danger)"},children:b})]}),l.jsx("div",{style:{fontSize:11,color:"var(--muted)"},children:"自动派发时使用的 OpenClaw 通知渠道(需已在 openclaw.json 中配置对应 channel)"})]}),l.jsxs("div",{style:{marginTop:24},children:[l.jsx("div",{className:"sec-title",children:"变更日志"}),l.jsx("div",{className:"cl-list",children:f!=null&&f.length?[...f].reverse().slice(0,15).map((x,A)=>l.jsxs("div",{className:"cl-row",children:[l.jsx("span",{className:"cl-t",children:(x.at||"").substring(0,16).replace("T"," ")}),l.jsx("span",{className:"cl-a",children:x.agentId}),l.jsxs("span",{className:"cl-c",children:[l.jsx("b",{children:x.oldModel})," → ",l.jsx("b",{children:x.newModel}),x.rolledBack&&l.jsx("span",{style:{color:"var(--danger)",fontSize:10,border:"1px solid #ff527044",padding:"1px 5px",borderRadius:3,marginLeft:4},children:"⚠ 已回滚"})]})]},A)):l.jsx("div",{style:{fontSize:12,color:"var(--muted)",padding:"8px 0"},children:"暂无变更"})})]})]})}const np=[{label:"obra/superpowers",emoji:"⚡",stars:"66.9k",desc:"完整开发工作流技能集",skills:[{name:"brainstorming",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/brainstorming/SKILL.md"},{name:"test-driven-development",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/test-driven-development/SKILL.md"},{name:"systematic-debugging",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/systematic-debugging/SKILL.md"},{name:"subagent-driven-development",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/subagent-driven-development/SKILL.md"},{name:"writing-plans",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/writing-plans/SKILL.md"},{name:"executing-plans",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/executing-plans/SKILL.md"},{name:"requesting-code-review",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/requesting-code-review/SKILL.md"},{name:"root-cause-tracing",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/root-cause-tracing/SKILL.md"},{name:"verification-before-completion",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/verification-before-completion/SKILL.md"},{name:"dispatching-parallel-agents",url:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/dispatching-parallel-agents/SKILL.md"}]},{label:"anthropics/skills",emoji:"🏛️",stars:"官方",desc:"Anthropic 官方技能库",skills:[{name:"docx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/docx/SKILL.md"},{name:"pdf",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/pdf/SKILL.md"},{name:"xlsx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/xlsx/SKILL.md"},{name:"pptx",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/pptx/SKILL.md"},{name:"mcp-builder",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/mcp-builder/SKILL.md"},{name:"frontend-design",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/frontend-design/SKILL.md"},{name:"web-artifacts-builder",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/web-artifacts-builder/SKILL.md"},{name:"webapp-testing",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/webapp-testing/SKILL.md"},{name:"algorithmic-art",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/algorithmic-art/SKILL.md"},{name:"canvas-design",url:"https://raw.githubusercontent.com/anthropics/skills/main/skills/canvas-design/SKILL.md"}]},{label:"ComposioHQ/awesome-claude-skills",emoji:"🌐",stars:"39.2k",desc:"100+ 社区精选技能",skills:[{name:"github-integration",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/github-integration/SKILL.md"},{name:"data-analysis",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/data-analysis/SKILL.md"},{name:"code-review",url:"https://raw.githubusercontent.com/ComposioHQ/awesome-claude-skills/master/code-review/SKILL.md"}]}];function rp(){const o=ee(y=>y.agentConfig),f=ee(y=>y.loadAgentConfig),c=ee(y=>y.toast),[v,g]=Q.useState(null),[P,L]=Q.useState(null),[z,T]=Q.useState({name:"",desc:"",trigger:""}),[E,b]=Q.useState(!1),[d,N]=Q.useState("local"),[j,O]=Q.useState([]),[S,M]=Q.useState(!1),[x,A]=Q.useState(!1),[V,R]=Q.useState({agentId:"",skillName:"",sourceUrl:"",description:""}),[re,ue]=Q.useState(!1),[me,pe]=Q.useState(null),[Ae,Z]=Q.useState(null),[oe,ke]=Q.useState(null),[le,te]=Q.useState("");Q.useEffect(()=>{f()},[f]),Q.useEffect(()=>{d==="remote"&&Ne()},[d]);const Ne=async()=>{M(!0);try{const y=await de.remoteSkillsList();y.ok&&O(y.remoteSkills||[])}catch{c("远程技能列表加载失败","err")}M(!1)},Ee=async(y,H)=>{g({agentId:y,name:H,content:"⟳ 加载中…",path:""});try{const ne=await de.skillContent(y,H);ne.ok?g({agentId:y,name:H,content:ne.content||"",path:ne.path||""}):g({agentId:y,name:H,content:"❌ "+(ne.error||"无法读取"),path:""})}catch{g({agentId:y,name:H,content:"❌ 服务器连接失败",path:""})}},je=(y,H)=>{L({agentId:y,agentLabel:H}),T({name:"",desc:"",trigger:""})},_=async y=>{if(y.preventDefault(),!(!P||!z.name)){b(!0);try{const H=await de.addSkill(P.agentId,z.name,z.desc,z.trigger);H.ok?(c(`✅ 技能 ${z.name} 已添加到 ${P.agentLabel}`,"ok"),L(null),f()):c(H.error||"添加失败","err")}catch{c("服务器连接失败","err")}b(!1)}},G=async y=>{y.preventDefault();const{agentId:H,skillName:ne,sourceUrl:ve,description:D}=V;if(!(!H||!ne||!ve)){ue(!0);try{const ce=await de.addRemoteSkill(H,ne,ve,D);ce.ok?(c(`✅ 远程技能 ${ne} 已添加到 ${H}`,"ok"),A(!1),R({agentId:"",skillName:"",sourceUrl:"",description:""}),Ne(),f()):c(ce.error||"添加失败","err")}catch{c("服务器连接失败","err")}ue(!1)}},U=async y=>{const H=`${y.agentId}/${y.skillName}`;pe(H);try{const ne=await de.updateRemoteSkill(y.agentId,y.skillName);ne.ok?(c(`✅ 技能 ${y.skillName} 已更新`,"ok"),Ne()):c(ne.error||"更新失败","err")}catch{c("服务器连接失败","err")}pe(null)},h=async y=>{const H=`${y.agentId}/${y.skillName}`;Z(H);try{const ne=await de.removeRemoteSkill(y.agentId,y.skillName);ne.ok?(c(`🗑️ 技能 ${y.skillName} 已移除`,"ok"),Ne(),f()):c(ne.error||"移除失败","err")}catch{c("服务器连接失败","err")}Z(null)},I=async(y,H)=>{if(!le){c("请先选择目标 Agent","err");return}try{const ne=await de.addRemoteSkill(le,H,y,"");ne.ok?(c(`✅ ${H} → ${le}`,"ok"),Ne(),f()):c(ne.error||"导入失败","err")}catch{c("服务器连接失败","err")}};if(!(o!=null&&o.agents))return l.jsx("div",{className:"empty",children:"无法加载"});const fe=l.jsx("div",{children:l.jsx("div",{className:"skills-grid",children:o.agents.map(y=>l.jsxs("div",{className:"sk-card",children:[l.jsxs("div",{className:"sk-hdr",children:[l.jsx("span",{className:"sk-emoji",children:y.emoji||"🏛️"}),l.jsx("span",{className:"sk-name",children:y.label}),l.jsxs("span",{className:"sk-cnt",children:[(y.skills||[]).length," 技能"]})]}),l.jsx("div",{className:"sk-list",children:(y.skills||[]).length?(y.skills||[]).map(H=>l.jsxs("div",{className:"sk-item",onClick:()=>Ee(y.id,H.name),children:[l.jsxs("span",{className:"si-name",children:["📦 ",H.name]}),l.jsx("span",{className:"si-desc",children:H.description||"无描述"}),l.jsx("span",{className:"si-arrow",children:"›"})]},H.name)):l.jsx("div",{className:"sk-empty",children:"暂无 Skills"})}),l.jsx("div",{className:"sk-add",onClick:()=>je(y.id,y.label),children:"+ 添加技能"})]},y.id))})}),he=l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:10,marginBottom:20,flexWrap:"wrap",alignItems:"center"},children:[l.jsx("button",{style:{padding:"8px 18px",background:"var(--acc)",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600,fontSize:13},onClick:()=>{A(!0),ke(null)},children:"+ 添加远程 Skill"}),l.jsx("button",{style:{padding:"8px 14px",background:"transparent",color:"var(--acc)",border:"1px solid var(--acc)",borderRadius:8,cursor:"pointer",fontSize:12},onClick:Ne,children:"⟳ 刷新列表"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:4},children:["共 ",j.length," 个远程技能"]})]}),l.jsxs("div",{style:{marginBottom:24},children:[l.jsx("div",{style:{fontSize:12,fontWeight:700,color:"var(--muted)",letterSpacing:".06em",marginBottom:10},children:"🌐 社区技能源 — 一键导入"}),l.jsx("div",{style:{display:"flex",gap:10,flexWrap:"wrap"},children:np.map(y=>l.jsxs("div",{onClick:()=>ke((oe==null?void 0:oe.label)===y.label?null:y),style:{padding:"8px 14px",background:(oe==null?void 0:oe.label)===y.label?"#0d1f45":"var(--panel)",border:`1px solid ${(oe==null?void 0:oe.label)===y.label?"var(--acc)":"var(--line)"}`,borderRadius:10,cursor:"pointer",fontSize:12,transition:"all .15s"},children:[l.jsx("span",{style:{marginRight:6},children:y.emoji}),l.jsx("b",{style:{color:"var(--text)"},children:y.label}),l.jsxs("span",{style:{marginLeft:6,color:"#f0b429",fontSize:11},children:["★ ",y.stars]}),l.jsx("span",{style:{marginLeft:8,color:"var(--muted)"},children:y.desc})]},y.label))}),oe&&l.jsxs("div",{style:{marginTop:14,background:"var(--panel)",border:"1px solid var(--line)",borderRadius:12,padding:16},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:14},children:[l.jsx("span",{style:{fontSize:12,fontWeight:600},children:"目标 Agent:"}),l.jsxs("select",{value:le,onChange:y=>te(y.target.value),style:{padding:"6px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12},children:[l.jsx("option",{value:"",children:"— 选择 Agent —"}),o.agents.map(y=>l.jsxs("option",{value:y.id,children:[y.emoji," ",y.label," (",y.id,")"]},y.id))]})]}),l.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:8},children:oe.skills.map(y=>{const H=j.some(ne=>ne.skillName===y.name&&ne.agentId===le);return l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"var(--panel2)",borderRadius:8,border:"1px solid var(--line)"},children:[l.jsxs("div",{children:[l.jsxs("div",{style:{fontSize:12,fontWeight:600},children:["📦 ",y.name]}),l.jsx("div",{style:{fontSize:10,color:"var(--muted)",wordBreak:"break-all",maxWidth:180},children:y.url.split("/").slice(-2).join("/")})]}),H?l.jsx("span",{style:{fontSize:10,color:"#4caf88",fontWeight:600},children:"✓ 已导入"}):l.jsx("button",{onClick:()=>I(y.url,y.name),style:{padding:"4px 10px",background:"var(--acc)",color:"#fff",border:"none",borderRadius:6,cursor:"pointer",fontSize:11,whiteSpace:"nowrap"},children:"导入"})]},y.name)})})]})]}),S?l.jsx("div",{style:{textAlign:"center",padding:"40px 0",color:"var(--muted)",fontSize:13},children:"⟳ 加载中…"}):j.length===0?l.jsxs("div",{style:{textAlign:"center",padding:"40px",background:"var(--panel)",borderRadius:12,border:"1px dashed var(--line)"},children:[l.jsx("div",{style:{fontSize:32,marginBottom:10},children:"🌐"}),l.jsx("div",{style:{fontSize:14,color:"var(--muted)"},children:"尚无远程技能"}),l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginTop:6},children:"从社区技能源快速导入,或手动添加 URL"})]}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:j.map(y=>{var ce;const H=`${y.agentId}/${y.skillName}`,ne=me===H,ve=Ae===H,D=o.agents.find(ye=>ye.id===y.agentId);return l.jsxs("div",{style:{background:"var(--panel)",border:"1px solid var(--line)",borderRadius:12,padding:"14px 18px",display:"grid",gridTemplateColumns:"1fr auto",gap:12,alignItems:"center"},children:[l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:6},children:[l.jsxs("span",{style:{fontSize:14,fontWeight:700},children:["📦 ",y.skillName]}),l.jsx("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:999,background:y.status==="valid"?"#0d3322":"#3d1111",color:y.status==="valid"?"#4caf88":"#ff5270",fontWeight:600},children:y.status==="valid"?"✓ 有效":"✗ 文件丢失"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",background:"var(--panel2)",padding:"2px 8px",borderRadius:6},children:[D==null?void 0:D.emoji," ",(D==null?void 0:D.label)||y.agentId]})]}),y.description&&l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:4},children:y.description}),l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",display:"flex",gap:16,flexWrap:"wrap"},children:[l.jsxs("span",{children:["🔗 ",l.jsx("a",{href:y.sourceUrl,target:"_blank",rel:"noreferrer",style:{color:"var(--acc)",textDecoration:"none"},children:y.sourceUrl.length>60?y.sourceUrl.slice(0,60)+"…":y.sourceUrl})]}),l.jsxs("span",{children:["📅 ",y.lastUpdated?y.lastUpdated.slice(0,10):(ce=y.addedAt)==null?void 0:ce.slice(0,10)]})]})]}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{onClick:()=>Ee(y.agentId,y.skillName),style:{padding:"6px 12px",background:"transparent",color:"var(--muted)",border:"1px solid var(--line)",borderRadius:6,cursor:"pointer",fontSize:11},children:"查看"}),l.jsx("button",{onClick:()=>U(y),disabled:ne,style:{padding:"6px 12px",background:"transparent",color:"var(--acc)",border:"1px solid var(--acc)",borderRadius:6,cursor:"pointer",fontSize:11},children:ne?"⟳":"更新"}),l.jsx("button",{onClick:()=>h(y),disabled:ve,style:{padding:"6px 12px",background:"transparent",color:"#ff5270",border:"1px solid #ff5270",borderRadius:6,cursor:"pointer",fontSize:11},children:ve?"⟳":"删除"})]})]},H)})})]});return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:4,marginBottom:20,borderBottom:"1px solid var(--line)",paddingBottom:0},children:[{key:"local",label:"🏛️ 本地技能",count:o.agents.reduce((y,H)=>{var ne;return y+(((ne=H.skills)==null?void 0:ne.length)||0)},0)},{key:"remote",label:"🌐 远程技能",count:j.length}].map(y=>l.jsxs("div",{onClick:()=>N(y.key),style:{padding:"8px 18px",cursor:"pointer",fontSize:13,borderRadius:"8px 8px 0 0",fontWeight:d===y.key?700:400,background:d===y.key?"var(--panel)":"transparent",color:d===y.key?"var(--text)":"var(--muted)",border:d===y.key?"1px solid var(--line)":"1px solid transparent",borderBottom:d===y.key?"1px solid var(--panel)":"1px solid transparent",position:"relative",bottom:-1,transition:"all .15s"},children:[y.label,y.count>0&&l.jsx("span",{style:{marginLeft:6,fontSize:10,padding:"1px 6px",borderRadius:999,background:"#1a2040",color:"var(--acc)"},children:y.count})]},y.key))}),d==="local"?fe:he,v&&l.jsx("div",{className:"modal-bg open",onClick:()=>g(null),children:l.jsxs("div",{className:"modal",onClick:y=>y.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>g(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:v.agentId.toUpperCase()}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:16},children:["📦 ",v.name]}),l.jsxs("div",{className:"sk-modal-body",children:[l.jsx("div",{className:"sk-md",style:{whiteSpace:"pre-wrap",fontSize:12,lineHeight:1.7},children:v.content}),v.path&&l.jsxs("div",{className:"sk-path",style:{fontSize:10,color:"var(--muted)",marginTop:12},children:["📂 ",v.path]})]})]})]})}),P&&l.jsx("div",{className:"modal-bg open",onClick:()=>L(null),children:l.jsxs("div",{className:"modal",onClick:y=>y.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>L(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsxs("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:["为 ",P.agentLabel," 添加技能"]}),l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:18},children:"+ 新增 Skill"}),l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:10,padding:14,marginBottom:18,fontSize:12,lineHeight:1.7,color:"var(--muted)"},children:[l.jsx("b",{style:{color:"var(--text)"},children:"📋 Skill 规范说明"}),l.jsx("br",{}),"• 技能名称使用",l.jsx("b",{style:{color:"var(--text)"},children:"小写英文 + 连字符"}),l.jsx("br",{}),"• 创建后会生成模板文件 SKILL.md",l.jsx("br",{}),"• 技能会在 agent 收到相关任务时",l.jsx("b",{style:{color:"var(--text)"},children:"自动激活"})]}),l.jsxs("form",{onSubmit:_,style:{display:"flex",flexDirection:"column",gap:14},children:[l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["技能名称 ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"text",required:!0,placeholder:"如 data-analysis, code-review",value:z.name,onChange:y=>T(H=>({...H,name:y.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"技能描述"}),l.jsx("input",{type:"text",placeholder:"一句话说明用途",value:z.desc,onChange:y=>T(H=>({...H,desc:y.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"触发条件(可选)"}),l.jsx("input",{type:"text",placeholder:"何时激活此技能",value:z.trigger,onChange:y=>T(H=>({...H,trigger:y.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",marginTop:4},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:()=>L(null),style:{padding:"8px 20px"},children:"取消"}),l.jsx("button",{type:"submit",disabled:E,style:{padding:"8px 20px",fontSize:13,background:"var(--acc)",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600},children:E?"⟳ 创建中…":"📦 创建技能"})]})]})]})]})}),x&&l.jsx("div",{className:"modal-bg open",onClick:()=>A(!1),children:l.jsxs("div",{className:"modal",style:{maxWidth:520},onClick:y=>y.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>A(!1),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"#a07aff",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:"远程技能管理"}),l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:18},children:"🌐 添加远程 Skill"}),l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:10,padding:12,marginBottom:18,fontSize:11,color:"var(--muted)",lineHeight:1.7},children:["支持 GitHub Raw URL,如:",l.jsx("br",{}),l.jsx("code",{style:{color:"var(--acc)",fontSize:10},children:"https://raw.githubusercontent.com/obra/superpowers/refs/heads/main/skills/brainstorming/SKILL.md"})]}),l.jsxs("form",{onSubmit:G,style:{display:"flex",flexDirection:"column",gap:14},children:[l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["目标 Agent ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsxs("select",{required:!0,value:V.agentId,onChange:y=>R(H=>({...H,agentId:y.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13},children:[l.jsx("option",{value:"",children:"— 选择 Agent —"}),o.agents.map(y=>l.jsxs("option",{value:y.id,children:[y.emoji," ",y.label," (",y.id,")"]},y.id))]})]}),l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["技能名称 ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"text",required:!0,placeholder:"如 brainstorming, code-review",value:V.skillName,onChange:y=>R(H=>({...H,skillName:y.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{children:[l.jsxs("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:["源 URL ",l.jsx("span",{style:{color:"#ff5270"},children:"*"})]}),l.jsx("input",{type:"url",required:!0,placeholder:"https://raw.githubusercontent.com/...",value:V.sourceUrl,onChange:y=>R(H=>({...H,sourceUrl:y.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:12,outline:"none"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{fontSize:12,fontWeight:600,display:"block",marginBottom:6},children:"描述(可选)"}),l.jsx("input",{type:"text",placeholder:"一句话说明用途",value:V.description,onChange:y=>R(H=>({...H,description:y.target.value})),style:{width:"100%",padding:"10px 12px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:8,color:"var(--text)",fontSize:13,outline:"none"}})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end",marginTop:4},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:()=>A(!1),style:{padding:"8px 20px"},children:"取消"}),l.jsx("button",{type:"submit",disabled:re,style:{padding:"8px 20px",fontSize:13,background:"#a07aff",color:"#fff",border:"none",borderRadius:8,cursor:"pointer",fontWeight:600},children:re?"⟳ 下载中…":"🌐 添加远程技能"})]})]})]})]})})]})}function lp(){const o=ee(v=>v.agentConfig),f={},c={};return o!=null&&o.agents&&o.agents.forEach(v=>{f[v.id]=v.emoji||"🏛️",c[v.id]=v.label||v.id}),{emojiMap:f,labelMap:c}}function Hl(o){const f=(o.id||"").match(/^OC-(\w+)-/);return f?f[1]:(o.org||"").replace(/省|部/g,"").toLowerCase()}function pu(o,f){let c=o.title||"";if(c==="heartbeat 会话")return"💓 心跳检测";const v=c.match(/^agent:(\w+):(\w+)/);if(v){const g=f[v[1]]||v[1];return v[2]==="main"?g+" · 主会话":v[2]==="subagent"?g+" · 子任务执行":v[2]==="cron"?g+" · 定时任务":g+" · "+v[2]}return c.replace(/ 会话$/,"")||o.id}function mu(o){const f=o.now||"";return f.includes("feishu/direct")?{icon:"💬",text:"飞书对话"}:f.includes("feishu")?{icon:"💬",text:"飞书"}:f.includes("webchat")?{icon:"🌐",text:"WebChat"}:f.includes("cron")?{icon:"⏰",text:"定时"}:f.includes("direct")?{icon:"📨",text:"直连"}:{icon:"🔗",text:"会话"}}function sp(o){const f=o.activity||[];for(let c=f.length-1;c>=0;c--){const v=f[c];if(v.kind==="assistant"){let g=v.text||"";if(g.startsWith("NO_REPLY")||g.startsWith("Reasoning:"))continue;return g=g.replace(/\[\[.*?\]\]/g,"").replace(/\*\*/g,"").replace(/^#+\s/gm,"").trim(),g.substring(0,120)+(g.length>120?"…":"")}}return""}function ip(){const o=ee(d=>d.liveStatus),f=ee(d=>d.sessFilter),c=ee(d=>d.setSessFilter),{emojiMap:v,labelMap:g}=lp(),[P,L]=Q.useState(null),T=((o==null?void 0:o.tasks)||[]).filter(d=>!ln(d));let E=T;f==="active"?E=T.filter(d=>!["Done","Cancelled"].includes(d.state)):f!=="all"&&(E=T.filter(d=>Hl(d)===f));const b=[...new Set(T.map(Hl))];return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:6,marginBottom:16,flexWrap:"wrap"},children:[{key:"all",label:`全部 (${T.length})`},{key:"active",label:"活跃"},...b.slice(0,8).map(d=>({key:d,label:g[d]||d}))].map(d=>l.jsx("span",{className:`sess-filter${f===d.key?" active":""}`,onClick:()=>c(d.key),children:d.label},d.key))}),l.jsx("div",{className:"sess-grid",children:E.length?E.map(d=>{const N=Hl(d),j=v[N]||"🏛️",O=g[N]||d.org||N,S=d.heartbeat||{status:"unknown",label:""},M=mu(d),x=pu(d,g),A=sp(d),R=(d.sourceMeta||{}).totalTokens,re=d.eta||"",ue=S.status==="active"?"🟢":S.status==="warn"?"🟡":S.status==="stalled"?"🔴":"⚪",me=d.state||"Unknown";return l.jsxs("div",{className:"sess-card",onClick:()=>L(d),children:[l.jsxs("div",{className:"sc-top",children:[l.jsx("span",{className:"sc-emoji",children:j}),l.jsx("div",{style:{flex:1,minWidth:0},children:l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{className:"sc-agent",children:O}),l.jsxs("span",{style:{fontSize:10,color:"var(--muted)",background:"var(--panel2)",padding:"2px 6px",borderRadius:4},children:[M.icon," ",M.text]})]})}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{title:S.label||"",children:ue}),l.jsx("span",{className:`tag st-${me}`,style:{fontSize:10},children:Pr[me]||me})]})]}),l.jsx("div",{className:"sc-title",children:x}),A&&l.jsx("div",{style:{fontSize:11,color:"var(--muted)",lineHeight:1.5,marginBottom:8,borderLeft:"2px solid var(--line)",paddingLeft:8,maxHeight:40,overflow:"hidden"},children:A}),l.jsxs("div",{className:"sc-meta",children:[R?l.jsxs("span",{style:{fontSize:10,color:"var(--muted)"},children:["🪙 ",R.toLocaleString()," tokens"]}):null,re?l.jsx("span",{className:"sc-time",children:Vf(re)}):null]})]},d.id)}):l.jsx("div",{style:{fontSize:13,color:"var(--muted)",padding:24,textAlign:"center",gridColumn:"1/-1"},children:"暂无小任务/会话数据"})}),P&&l.jsx(op,{task:P,labelMap:g,emojiMap:v,onClose:()=>L(null)})]})}function op({task:o,labelMap:f,emojiMap:c,onClose:v}){const g=Hl(o),P=c[g]||"🏛️",L=pu(o,f),z=mu(o),T=o.heartbeat||{label:""},E=o.sourceMeta||{},b=o.activity||[],d=o.state||"Unknown",N=E.totalTokens,j=E.inputTokens,O=E.outputTokens;return l.jsx("div",{className:"modal-bg open",onClick:v,children:l.jsxs("div",{className:"modal",onClick:S=>S.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:v,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:o.id}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[P," ",L]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,flexWrap:"wrap"},children:[l.jsx("span",{className:`tag st-${d}`,children:Pr[d]||d}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:[z.icon," ",z.text]}),T.label&&l.jsx("span",{style:{fontSize:11},children:T.label})]}),l.jsxs("div",{style:{display:"flex",gap:14,marginBottom:18,flexWrap:"wrap"},children:[N!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--acc)"},children:N.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"总 Tokens"})]}),j!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700},children:j.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"输入"})]}),O!=null&&l.jsxs("div",{style:{background:"var(--panel2)",padding:"10px 16px",borderRadius:8,fontSize:12},children:[l.jsx("div",{style:{fontSize:16,fontWeight:700},children:O.toLocaleString()}),l.jsx("div",{style:{color:"var(--muted)",fontSize:10},children:"输出"})]})]}),l.jsxs("div",{style:{fontSize:12,fontWeight:700,marginBottom:8},children:["📋 最近活动 ",l.jsxs("span",{style:{fontWeight:400,color:"var(--muted)"},children:["(",b.length," 条)"]})]}),l.jsx("div",{style:{maxHeight:350,overflowY:"auto",border:"1px solid var(--line)",borderRadius:10,background:"var(--panel2)"},children:b.length?b.slice(-15).reverse().map((S,M)=>{const x=S.kind||"",A=x==="assistant"?"🤖":x==="tool"?"🔧":x==="user"?"👤":"📝",V=x==="assistant"?"回复":x==="tool"?"工具":x==="user"?"用户":"事件";let R=(S.text||"").replace(/\[\[.*?\]\]/g,"").replace(/\*\*/g,"").trim();R.length>200&&(R=R.substring(0,200)+"…");const re=(S.at||"").substring(11,19);return l.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--line)",fontSize:12,lineHeight:1.5},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[l.jsx("span",{children:A}),l.jsx("span",{style:{fontWeight:600,fontSize:11},children:V}),l.jsx("span",{style:{color:"var(--muted)",fontSize:10,marginLeft:"auto"},children:re})]}),l.jsx("div",{style:{color:"var(--muted)"},children:R})]},M)}):l.jsx("div",{style:{padding:16,color:"var(--muted)",fontSize:12,textAlign:"center"},children:"暂无活动记录"})}),o.output&&o.output!=="-"&&l.jsxs("div",{style:{fontSize:10,color:"var(--muted)",marginTop:12,wordBreak:"break-all",borderTop:"1px solid var(--line)",paddingTop:8},children:["📂 ",o.output]})]})]})})}function ap(){const o=ee(E=>E.liveStatus),[f,c]=Q.useState("all"),[v,g]=Q.useState(null),P=ee(E=>E.toast);let z=((o==null?void 0:o.tasks)||[]).filter(E=>ln(E)&&["Done","Cancelled"].includes(E.state));f!=="all"&&(z=z.filter(E=>E.state===f));const T=E=>{const b=E.flow_log||[];let d=`# 📜 奏折 · ${E.title} -`;if(d+=`- **任务编号**: ${C.id} -`,d+=`- **状态**: ${C.state} -`,d+=`- **负责部门**: ${C.org} -`,z.length){const w=z[0].at?z[0].at.substring(0,19).replace("T"," "):"未知",m=z[z.length-1].at?z[z.length-1].at.substring(0,19).replace("T"," "):"未知";d+=`- **开始时间**: ${w} -`,d+=`- **完成时间**: ${m} +`;if(d+=`- **任务编号**: ${E.id} +`,d+=`- **状态**: ${E.state} +`,d+=`- **负责部门**: ${E.org} +`,b.length){const N=b[0].at?b[0].at.substring(0,19).replace("T"," "):"未知",j=b[b.length-1].at?b[b.length-1].at.substring(0,19).replace("T"," "):"未知";d+=`- **开始时间**: ${N} +`,d+=`- **完成时间**: ${j} `}d+=` ## 流转记录 -`;for(const w of z)d+=`- **${w.from}** → **${w.to}** - ${w.remark} - _${(w.at||"").substring(0,19)}_ +`;for(const N of b)d+=`- **${N.from}** → **${N.to}** + ${N.remark} + _${(N.at||"").substring(0,19)}_ -`;C.output&&C.output!=="-"&&(d+=`## 产出物 +`;E.output&&E.output!=="-"&&(d+=`## 产出物 -\`${C.output}\` -`),navigator.clipboard.writeText(d).then(()=>L("✅ 奏折已复制为 Markdown","ok"),()=>L("复制失败","err"))};return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16,alignItems:"center"},children:[l.jsx("span",{style:{fontSize:12,color:"var(--muted)"},children:"筛选:"}),[{key:"all",label:"全部"},{key:"Done",label:"✅ 已完成"},{key:"Cancelled",label:"🚫 已取消"}].map(C=>l.jsx("span",{className:`sess-filter${f===C.key?" active":""}`,onClick:()=>c(C.key),children:C.label},C.key))]}),l.jsx("div",{className:"mem-list",children:_.length?_.map(C=>{const z=C.flow_log||[],d=[...new Set(z.map(g=>g.from).concat(z.map(g=>g.to)).filter(g=>g&&g!=="皇上"))],w=z.length?(z[0].at||"").substring(0,16).replace("T"," "):"",m=z.length?(z[z.length-1].at||"").substring(0,16).replace("T"," "):"",R=C.state==="Done"?"✅":"🚫";return l.jsxs("div",{className:"mem-card",onClick:()=>x(C),children:[l.jsx("div",{className:"mem-icon",children:"📜"}),l.jsxs("div",{className:"mem-info",children:[l.jsxs("div",{className:"mem-title",children:[R," ",C.title||C.id]}),l.jsxs("div",{className:"mem-sub",children:[C.id," · ",C.org||""," · 流转 ",z.length," 步"]}),l.jsx("div",{className:"mem-tags",children:d.slice(0,5).map(g=>l.jsx("span",{className:"mem-tag",children:g},g))})]}),l.jsxs("div",{className:"mem-right",children:[l.jsx("span",{className:"mem-date",children:w}),m!==w&&l.jsx("span",{className:"mem-date",children:m})]})]},C.id)}):l.jsx("div",{className:"mem-empty",children:"暂无奏折 — 任务完成后自动生成"})}),y&&l.jsx(ap,{task:y,onClose:()=>x(null),onExport:b})]})}function ap({task:o,onClose:f,onExport:c}){const y=o.flow_log||[],x=o.state||"Unknown",L=x==="Done"?"✅":x==="Cancelled"?"🚫":"🔄",T=[...new Set(y.map(m=>m.from).concat(y.map(m=>m.to)).filter(m=>m&&m!=="皇上"))],_=[],b=[],C=[],z=[],d=[];for(const m of y)m.from==="皇上"?_.push(m):m.to==="中书省"||m.from==="中书省"?b.push(m):m.to==="门下省"||m.from==="门下省"?C.push(m):m.remark&&(m.remark.includes("完成")||m.remark.includes("回奏"))?d.push(m):z.push(m);const w=(m,R,g)=>g.length?l.jsxs("div",{style:{marginBottom:18},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:700,marginBottom:10},children:[R," ",m]}),l.jsx("div",{className:"md-timeline",children:g.map((A,P)=>{var J,I;const W=(J=A.remark)!=null&&J.includes("✅")?"green":(I=A.remark)!=null&&I.includes("驳")?"red":"";return l.jsxs("div",{className:"md-tl-item",children:[l.jsx("div",{className:`md-tl-dot ${W}`}),l.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[l.jsx("span",{className:"md-tl-from",children:A.from}),l.jsxs("span",{className:"md-tl-to",children:["→ ",A.to]})]}),l.jsx("div",{className:"md-tl-remark",children:A.remark}),l.jsx("div",{className:"md-tl-time",children:(A.at||"").substring(0,19).replace("T"," ")})]},P)})})]}):null;return l.jsx("div",{className:"modal-bg open",onClick:f,children:l.jsxs("div",{className:"modal",onClick:m=>m.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:f,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:o.id}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[L," ",o.title||o.id]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,flexWrap:"wrap"},children:[l.jsx("span",{className:`tag st-${x}`,children:Pr[x]||x}),l.jsx("span",{style:{fontSize:11,color:"var(--muted)"},children:o.org}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["流转 ",y.length," 步"]}),T.map(m=>l.jsx("span",{className:"mem-tag",children:m},m))]}),o.now&&l.jsx("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:8,padding:"10px 14px",marginBottom:18,fontSize:12,color:"var(--muted)"},children:o.now}),w("圣旨原文","👑",_),w("中书规划","📋",b),w("门下审议","🔍",C),w("六部执行","⚔️",z),w("汇总回奏","📨",d),o.output&&o.output!=="-"&&l.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:"1px solid var(--line)"},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:4},children:"📦 产出物"}),l.jsx("code",{style:{fontSize:11,wordBreak:"break-all"},children:o.output})]}),l.jsx("div",{style:{display:"flex",gap:8,marginTop:16,justifyContent:"flex-end"},children:l.jsx("button",{className:"btn btn-g",onClick:()=>c(o),style:{fontSize:12,padding:"6px 16px"},children:"📋 复制奏折"})})]})]})})}function cp(){const o=ee(g=>g.tplCatFilter),f=ee(g=>g.setTplCatFilter),c=ee(g=>g.toast),y=ee(g=>g.loadAll),[x,L]=V.useState(null),[T,_]=V.useState({}),[b,C]=V.useState("");let z=Ff;o!=="全部"&&(z=z.filter(g=>g.cat===o));const d=g=>{const A={};g.params.forEach(P=>{A[P.key]=P.default||""}),_(A),L(g),C("")},w=g=>{let A=g.command;for(const P of g.params)A=A.replace(new RegExp("\\{"+P.key+"\\}","g"),T[P.key]||P.default||"");return A},m=()=>{x&&C(w(x))},R=async g=>{if(g.preventDefault(),!x)return;const A=w(x);if(!A.trim()){c("请填写必填参数","err");return}try{const P=await fe.agentsStatus();if(P.ok&&P.gateway&&!P.gateway.alive&&(c("⚠️ Gateway 未启动,任务将无法派发!","err"),!confirm("Gateway 未启动,继续?")))return}catch{}if(confirm(`确认下旨? +\`${E.output}\` +`),navigator.clipboard.writeText(d).then(()=>P("✅ 奏折已复制为 Markdown","ok"),()=>P("复制失败","err"))};return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",gap:8,marginBottom:16,alignItems:"center"},children:[l.jsx("span",{style:{fontSize:12,color:"var(--muted)"},children:"筛选:"}),[{key:"all",label:"全部"},{key:"Done",label:"✅ 已完成"},{key:"Cancelled",label:"🚫 已取消"}].map(E=>l.jsx("span",{className:`sess-filter${f===E.key?" active":""}`,onClick:()=>c(E.key),children:E.label},E.key))]}),l.jsx("div",{className:"mem-list",children:z.length?z.map(E=>{const b=E.flow_log||[],d=[...new Set(b.map(S=>S.from).concat(b.map(S=>S.to)).filter(S=>S&&S!=="皇上"))],N=b.length?(b[0].at||"").substring(0,16).replace("T"," "):"",j=b.length?(b[b.length-1].at||"").substring(0,16).replace("T"," "):"",O=E.state==="Done"?"✅":"🚫";return l.jsxs("div",{className:"mem-card",onClick:()=>g(E),children:[l.jsx("div",{className:"mem-icon",children:"📜"}),l.jsxs("div",{className:"mem-info",children:[l.jsxs("div",{className:"mem-title",children:[O," ",E.title||E.id]}),l.jsxs("div",{className:"mem-sub",children:[E.id," · ",E.org||""," · 流转 ",b.length," 步"]}),l.jsx("div",{className:"mem-tags",children:d.slice(0,5).map(S=>l.jsx("span",{className:"mem-tag",children:S},S))})]}),l.jsxs("div",{className:"mem-right",children:[l.jsx("span",{className:"mem-date",children:N}),j!==N&&l.jsx("span",{className:"mem-date",children:j})]})]},E.id)}):l.jsx("div",{className:"mem-empty",children:"暂无奏折 — 任务完成后自动生成"})}),v&&l.jsx(cp,{task:v,onClose:()=>g(null),onExport:T})]})}function cp({task:o,onClose:f,onExport:c}){const v=o.flow_log||[],g=o.state||"Unknown",P=g==="Done"?"✅":g==="Cancelled"?"🚫":"🔄",L=[...new Set(v.map(j=>j.from).concat(v.map(j=>j.to)).filter(j=>j&&j!=="皇上"))],z=[],T=[],E=[],b=[],d=[];for(const j of v)j.from==="皇上"?z.push(j):j.to==="中书省"||j.from==="中书省"?T.push(j):j.to==="门下省"||j.from==="门下省"?E.push(j):j.remark&&(j.remark.includes("完成")||j.remark.includes("回奏"))?d.push(j):b.push(j);const N=(j,O,S)=>S.length?l.jsxs("div",{style:{marginBottom:18},children:[l.jsxs("div",{style:{fontSize:13,fontWeight:700,marginBottom:10},children:[O," ",j]}),l.jsx("div",{className:"md-timeline",children:S.map((M,x)=>{var V,R;const A=(V=M.remark)!=null&&V.includes("✅")?"green":(R=M.remark)!=null&&R.includes("驳")?"red":"";return l.jsxs("div",{className:"md-tl-item",children:[l.jsx("div",{className:`md-tl-dot ${A}`}),l.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline"},children:[l.jsx("span",{className:"md-tl-from",children:M.from}),l.jsxs("span",{className:"md-tl-to",children:["→ ",M.to]})]}),l.jsx("div",{className:"md-tl-remark",children:M.remark}),l.jsx("div",{className:"md-tl-time",children:(M.at||"").substring(0,19).replace("T"," ")})]},x)})})]}):null;return l.jsx("div",{className:"modal-bg open",onClick:f,children:l.jsxs("div",{className:"modal",onClick:j=>j.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:f,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:o.id}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[P," ",o.title||o.id]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:18,flexWrap:"wrap"},children:[l.jsx("span",{className:`tag st-${g}`,children:Pr[g]||g}),l.jsx("span",{style:{fontSize:11,color:"var(--muted)"},children:o.org}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["流转 ",v.length," 步"]}),L.map(j=>l.jsx("span",{className:"mem-tag",children:j},j))]}),o.now&&l.jsx("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:8,padding:"10px 14px",marginBottom:18,fontSize:12,color:"var(--muted)"},children:o.now}),N("圣旨原文","👑",z),N("中书规划","📋",T),N("门下审议","🔍",E),N("六部执行","⚔️",b),N("汇总回奏","📨",d),o.output&&o.output!=="-"&&l.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:"1px solid var(--line)"},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,marginBottom:4},children:"📦 产出物"}),l.jsx("code",{style:{fontSize:11,wordBreak:"break-all"},children:o.output})]}),l.jsx("div",{style:{display:"flex",gap:8,marginTop:16,justifyContent:"flex-end"},children:l.jsx("button",{className:"btn btn-g",onClick:()=>c(o),style:{fontSize:12,padding:"6px 16px"},children:"📋 复制奏折"})})]})]})})}function up(){const o=ee(S=>S.tplCatFilter),f=ee(S=>S.setTplCatFilter),c=ee(S=>S.toast),v=ee(S=>S.loadAll),[g,P]=Q.useState(null),[L,z]=Q.useState({}),[T,E]=Q.useState("");let b=Ff;o!=="全部"&&(b=b.filter(S=>S.cat===o));const d=S=>{const M={};S.params.forEach(x=>{M[x.key]=x.default||""}),z(M),P(S),E("")},N=S=>{let M=S.command;for(const x of S.params)M=M.replace(new RegExp("\\{"+x.key+"\\}","g"),L[x.key]||x.default||"");return M},j=()=>{g&&E(N(g))},O=async S=>{if(S.preventDefault(),!g)return;const M=N(g);if(!M.trim()){c("请填写必填参数","err");return}try{const x=await de.agentsStatus();if(x.ok&&x.gateway&&!x.gateway.alive&&(c("⚠️ Gateway 未启动,任务将无法派发!","err"),!confirm("Gateway 未启动,继续?")))return}catch{}if(confirm(`确认下旨? -${A.substring(0,200)}${A.length>200?"…":""}`))try{const P={};for(const J of x.params)P[J.key]=T[J.key]||J.default||"";const W=await fe.createTask({title:A.substring(0,120),org:"中书省",targetDept:x.depts[0]||"",priority:"normal",templateId:x.id,params:P});W.ok?(c(`📜 ${W.taskId} 旨意已下达`,"ok"),L(null),y()):c(W.error||"下旨失败","err")}catch{c("⚠️ 服务器连接失败","err")}};return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:6,marginBottom:16,flexWrap:"wrap"},children:Bf.map(g=>l.jsxs("span",{className:`tpl-cat${o===g.name?" active":""}`,onClick:()=>f(g.name),children:[g.icon," ",g.name]},g.name))}),l.jsx("div",{className:"tpl-grid",children:z.map(g=>l.jsxs("div",{className:"tpl-card",children:[l.jsxs("div",{className:"tpl-top",children:[l.jsx("span",{className:"tpl-icon",children:g.icon}),l.jsx("span",{className:"tpl-name",children:g.name})]}),l.jsx("div",{className:"tpl-desc",children:g.desc}),l.jsxs("div",{className:"tpl-footer",children:[g.depts.map(A=>l.jsx("span",{className:"tpl-dept",children:A},A)),l.jsxs("span",{className:"tpl-est",children:[g.est," · ",g.cost]}),l.jsx("button",{className:"tpl-go",onClick:()=>d(g),children:"下旨"})]})]},g.id))}),x&&l.jsx("div",{className:"modal-bg open",onClick:()=>L(null),children:l.jsxs("div",{className:"modal",onClick:g=>g.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>L(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:"圣旨模板"}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[x.icon," ",x.name]}),l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:18},children:x.desc}),l.jsxs("div",{style:{display:"flex",gap:6,marginBottom:18,flexWrap:"wrap"},children:[x.depts.map(g=>l.jsx("span",{className:"tpl-dept",children:g},g)),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:"auto"},children:[x.est," · ",x.cost]})]}),l.jsxs("form",{className:"tpl-form",onSubmit:R,children:[x.params.map(g=>l.jsxs("div",{className:"tpl-field",children:[l.jsxs("label",{className:"tpl-label",children:[g.label,g.required&&l.jsx("span",{style:{color:"#ff5270"},children:" *"})]}),g.type==="textarea"?l.jsx("textarea",{className:"tpl-input",style:{minHeight:80,resize:"vertical"},required:g.required,value:T[g.key]||"",onChange:A=>_(P=>({...P,[g.key]:A.target.value}))}):g.type==="select"?l.jsx("select",{className:"tpl-input",value:T[g.key]||g.default||"",onChange:A=>_(P=>({...P,[g.key]:A.target.value})),children:(g.options||[]).map(A=>l.jsx("option",{children:A},A))}):l.jsx("input",{className:"tpl-input",type:"text",required:g.required,value:T[g.key]||"",onChange:A=>_(P=>({...P,[g.key]:A.target.value}))})]},g.key)),b&&l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:8,padding:12,marginBottom:14,fontSize:12,color:"var(--muted)"},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text)",marginBottom:6},children:"📜 将发送给中书省的旨意:"}),l.jsx("div",{style:{whiteSpace:"pre-wrap",lineHeight:1.6},children:b})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end"},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:m,style:{padding:"8px 16px",fontSize:12},children:"👁 预览旨意"}),l.jsx("button",{type:"submit",className:"tpl-go",style:{padding:"8px 20px",fontSize:13},children:"📜 下旨"})]})]})]})]})})]})}const hu={政治:{icon:"🏛️",color:"#6a9eff",desc:"全球政治动态"},军事:{icon:"⚔️",color:"#ff5270",desc:"军事与冲突"},经济:{icon:"💹",color:"#2ecc8a",desc:"经济与市场"},AI大模型:{icon:"🤖",color:"#a07aff",desc:"AI与大模型进展"}},Gi=["政治","军事","经济","AI大模型"];function up(){const o=ee(X=>X.morningBrief),f=ee(X=>X.subConfig),c=ee(X=>X.loadMorning),y=ee(X=>X.loadSubConfig),x=ee(X=>X.toast),[L,T]=V.useState(!1),[_,b]=V.useState(null),[C,z]=V.useState(!1),[d,w]=V.useState("⟳ 立即采集"),m=V.useRef(null);V.useEffect(()=>{c()},[c]),V.useEffect(()=>{f&&b(JSON.parse(JSON.stringify(f)))},[f]),V.useEffect(()=>()=>{m.current&&clearInterval(m.current)},[]);const R=async()=>{z(!0),w("⟳ 采集中…");let X=null;try{X=(o==null?void 0:o.generated_at)||null}catch{}try{await fe.refreshMorning(),x("采集已触发,自动检测更新中…","ok");let ie=0;m.current&&clearInterval(m.current),m.current=setInterval(async()=>{if(ie++,ie>24){clearInterval(m.current),m.current=null,z(!1),w("⟳ 立即采集"),x("采集超时,请重试","err");return}try{const ke=await fe.morningBrief();ke.generated_at&&ke.generated_at!==X?(clearInterval(m.current),m.current=null,z(!1),w("⟳ 立即采集"),c(),x("✅ 天下要闻已更新","ok")):w(`⟳ 采集中… (${ie*5}s)`)}catch{}},5e3)}catch{x("触发失败","err"),z(!1),w("⟳ 立即采集")}},g=X=>{if(!_)return;const ie=[..._.categories||[]],ke=ie.find(re=>re.name===X);ke?ke.enabled=!ke.enabled:ie.push({name:X,enabled:!0}),b({..._,categories:ie})},A=X=>{if(!_||!X)return;const ie=[..._.keywords||[]];ie.includes(X)||ie.push(X),b({..._,keywords:ie})},P=X=>{if(!_)return;const ie=[..._.keywords||[]];ie.splice(X,1),b({..._,keywords:ie})},W=(X,ie,ke)=>{if(!_||!X||!ie){x("请填写源名称和URL","err");return}const re=[..._.custom_feeds||[]];re.push({name:X,url:ie,category:ke}),b({..._,custom_feeds:re})},J=X=>{if(!_)return;const ie=[..._.custom_feeds||[]];ie.splice(X,1),b({..._,custom_feeds:ie})},I=async()=>{if(_)try{const X=await fe.saveMorningConfig(_);X.ok?(x("订阅配置已保存","ok"),y()):x(X.error||"保存失败","err")}catch{x("服务器连接失败","err")}},oe=_?new Set((_.categories||[]).filter(X=>X.enabled).map(X=>X.name)):new Set(Gi),ue=((_==null?void 0:_.keywords)||[]).map(X=>X.toLowerCase()),me=(o==null?void 0:o.categories)||{},pe=o!=null&&o.date?o.date.replace(/(\d{4})(\d{2})(\d{2})/,"$1年$2月$3日"):"",Ae=Object.values(me).flat().length;return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:4},children:"🌅 天下要闻"}),l.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:[pe&&`${pe} | `,(o==null?void 0:o.generated_at)&&`采集于 ${o.generated_at} | `,"共 ",Ae," 条要闻"]})]}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{className:"btn btn-g",onClick:()=>T(!L),style:{fontSize:12,padding:"6px 14px"},children:"⚙ 订阅配置"}),l.jsx("button",{className:"tpl-go",disabled:C,onClick:R,style:{fontSize:12,padding:"6px 14px"},children:d})]})]}),L&&_&&l.jsx(dp,{config:_,enabledSet:oe,onToggleCat:g,onAddKeyword:A,onRemoveKeyword:P,onAddFeed:W,onRemoveFeed:J,onSave:I,onSetWebhook:X=>b({..._,feishu_webhook:X})}),Object.keys(me).length?l.jsx("div",{className:"mb-cats",children:Object.entries(me).map(([X,ie])=>{if(!oe.has(X))return null;const ke=hu[X]||{icon:"📰",color:"var(--acc)"},re=ie.map(te=>{const Ne=((te.title||"")+(te.summary||"")).toLowerCase(),Ee=ue.filter(je=>Ne.includes(je)).length;return{...te,_kwHits:Ee}}).sort((te,Ne)=>Ne._kwHits-te._kwHits);return l.jsxs("div",{className:"mb-cat",children:[l.jsxs("div",{className:"mb-cat-hdr",children:[l.jsx("span",{className:"mb-cat-icon",children:ke.icon}),l.jsx("span",{className:"mb-cat-name",style:{color:ke.color},children:X}),l.jsxs("span",{className:"mb-cat-cnt",children:[re.length," 条"]})]}),l.jsx("div",{className:"mb-news-list",children:re.length?re.map((te,Ne)=>{const Ee=!!(te.image&&te.image.startsWith("http"));return l.jsxs("div",{className:"mb-card",onClick:()=>window.open(te.link,"_blank"),children:[l.jsx("div",{className:"mb-img",children:Ee?l.jsx("img",{src:te.image,onError:je=>{je.target.style.display="none"},loading:"lazy",alt:""}):l.jsx("span",{children:ke.icon})}),l.jsxs("div",{className:"mb-info",children:[l.jsxs("div",{className:"mb-headline",children:[te.title,te._kwHits>0&&l.jsx("span",{style:{fontSize:9,padding:"1px 5px",borderRadius:999,background:"#a07aff22",color:"#a07aff",border:"1px solid #a07aff44",marginLeft:4},children:"⭐ 关注"})]}),l.jsx("div",{className:"mb-summary",children:te.summary||te.desc||""}),l.jsxs("div",{className:"mb-meta",children:[l.jsxs("span",{className:"mb-source",children:["📡 ",te.source||""]}),te.pub_date&&l.jsx("span",{className:"mb-time",children:te.pub_date.substring(0,16)})]})]})]},Ne)}):l.jsx("div",{className:"mb-empty",style:{padding:16},children:"暂无新闻"})})]},X)})}):l.jsx("div",{className:"mb-empty",children:"暂无数据,点击右上角「立即采集」获取今日简报"})]})}function dp({config:o,enabledSet:f,onToggleCat:c,onAddKeyword:y,onRemoveKeyword:x,onAddFeed:L,onRemoveFeed:T,onSave:_,onSetWebhook:b}){const[C,z]=V.useState(""),[d,w]=V.useState(""),[m,R]=V.useState(""),[g,A]=V.useState(Gi[0]),P=[...Gi];return(o.categories||[]).forEach(W=>{P.includes(W.name)||P.push(W.name)}),l.jsxs("div",{className:"sub-config",style:{marginBottom:20,padding:16,background:"var(--panel2)",borderRadius:12,border:"1px solid var(--line)"},children:[l.jsx("div",{style:{fontSize:14,fontWeight:700,marginBottom:12},children:"⚙ 订阅配置"}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"订阅分类"}),l.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:P.map(W=>{const J=hu[W]||{icon:"📰"},I=f.has(W);return l.jsxs("div",{className:`sub-cat ${I?"active":""}`,onClick:()=>c(W),style:{cursor:"pointer",padding:"6px 12px",borderRadius:8,border:`1px solid ${I?"var(--acc)":"var(--line)"}`,display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{children:J.icon}),l.jsx("span",{style:{fontSize:12},children:W}),I&&l.jsx("span",{style:{fontSize:10,color:"var(--ok)"},children:"✓"})]},W)})})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"关注关键词"}),l.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:6},children:(o.keywords||[]).map((W,J)=>l.jsxs("span",{className:"sub-kw",style:{fontSize:11,padding:"2px 8px",borderRadius:4,background:"var(--bg)",border:"1px solid var(--line)"},children:[W,l.jsx("span",{style:{cursor:"pointer",marginLeft:4,color:"var(--danger)"},onClick:()=>x(J),children:"✕"})]},J))}),l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("input",{type:"text",value:C,onChange:W=>z(W.target.value),placeholder:"输入关键词",onKeyDown:W=>{W.key==="Enter"&&(y(C.trim()),z(""))},style:{flex:1,padding:"6px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}}),l.jsx("button",{className:"btn btn-g",onClick:()=>{y(C.trim()),z("")},style:{fontSize:11,padding:"4px 12px"},children:"添加"})]})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"自定义信息源"}),(o.custom_feeds||[]).map((W,J)=>l.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:4,fontSize:11},children:[l.jsx("span",{style:{fontWeight:600},children:W.name}),l.jsx("span",{style:{color:"var(--muted)",flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:W.url}),l.jsx("span",{style:{color:"var(--acc)"},children:W.category}),l.jsx("span",{style:{cursor:"pointer",color:"var(--danger)"},onClick:()=>T(J),children:"✕"})]},J)),l.jsxs("div",{style:{display:"flex",gap:6,marginTop:6},children:[l.jsx("input",{placeholder:"源名称",value:d,onChange:W=>w(W.target.value),style:{width:100,padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"}}),l.jsx("input",{placeholder:"RSS / URL",value:m,onChange:W=>R(W.target.value),style:{flex:1,padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"}}),l.jsx("select",{value:g,onChange:W=>A(W.target.value),style:{padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"},children:P.map(W=>l.jsx("option",{value:W,children:W},W))}),l.jsx("button",{className:"btn btn-g",onClick:()=>{L(d,m,g),w(""),R("")},style:{fontSize:11,padding:"4px 12px"},children:"添加"})]})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"飞书 Webhook"}),l.jsx("input",{type:"text",value:o.feishu_webhook||"",onChange:W=>b(W.target.value),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",style:{width:"100%",padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}})]}),l.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:l.jsx("button",{className:"tpl-go",onClick:_,style:{fontSize:12,padding:"6px 16px"},children:"💾 保存配置"})})]})}const vu={main:"太子",zhongshu:"中书省",menxia:"门下省",shangshu:"尚书省",libu:"礼部",hubu:"户部",bingbu:"兵部",xingbu:"刑部",gongbu:"工部",libu_hr:"吏部",zaochao:"钦天监"},fp={Taizi:"中书省起草",Zhongshu:"门下省审议",Menxia:"尚书省派发",Assigned:"开始执行",Doing:"进入审查",Review:"完成"};function pp(o){const f=Math.max(0,o);if(f<60)return`${f}秒`;if(f<3600)return`${Math.floor(f/60)}分${f%60}秒`;const c=Math.floor(f/3600),y=Math.floor(f%3600/60);return`${c}小时${y}分`}function Yi(o){if(!o)return"";if(typeof o=="number"){const f=new Date(o);return`${String(f.getHours()).padStart(2,"0")}:${String(f.getMinutes()).padStart(2,"0")}:${String(f.getSeconds()).padStart(2,"0")}`}return typeof o=="string"&&o.length>=19?o.substring(11,19):String(o).substring(0,8)}function mp(){var Ee,je;const o=ee(E=>E.modalTaskId),f=ee(E=>E.setModalTaskId),c=ee(E=>E.liveStatus),y=ee(E=>E.loadAll),x=ee(E=>E.toast),[L,T]=V.useState(null),[_,b]=V.useState(null),C=V.useRef(null),z=V.useRef(null),d=((Ee=c==null?void 0:c.tasks)==null?void 0:Ee.find(E=>E.id===o))||null,w=V.useCallback(async()=>{if(o)try{const E=await fe.taskActivity(o);T(E)}catch{T(null)}},[o]),m=V.useCallback(async()=>{if(o)try{const E=await fe.schedulerState(o);b(E)}catch{b(null)}},[o]);if(V.useEffect(()=>!o||!d?void 0:(w(),m(),["Done","Cancelled"].includes(d.state)||(C.current=setInterval(()=>{w(),m()},4e3)),()=>{C.current&&(clearInterval(C.current),C.current=null)}),[o,d==null?void 0:d.state,w,m]),V.useEffect(()=>{z.current&&(z.current.scrollTop=z.current.scrollHeight)},[(je=L==null?void 0:L.activity)==null?void 0:je.length]),!o||!d)return null;const R=()=>f(null),g=qi(d),A=g.find(E=>E.status==="active"),P=d.heartbeat||{status:"unknown",label:"⚪ 无数据"},W=d.flow_log||[],J=d.todos||[],I=J.filter(E=>E.status==="completed").length,oe=J.length,ue=!["Done","Blocked","Cancelled"].includes(d.state),me=["Blocked","Cancelled"].includes(d.state),pe=async(E,K)=>{try{const U=await fe.taskAction(d.id,E,K);U.ok?(x(U.message||"操作成功","ok"),y(),R()):x(U.error||"操作失败","err")}catch{x("服务器连接失败","err")}},Ae=async E=>{const K={approve:"准奏",reject:"封驳"},U=prompt(`${K[E]} ${d.id} +${M.substring(0,200)}${M.length>200?"…":""}`))try{const x={};for(const V of g.params)x[V.key]=L[V.key]||V.default||"";const A=await de.createTask({title:M.substring(0,120),org:"中书省",targetDept:g.depts[0]||"",priority:"normal",templateId:g.id,params:x});A.ok?(c(`📜 ${A.taskId} 旨意已下达`,"ok"),P(null),v()):c(A.error||"下旨失败","err")}catch{c("⚠️ 服务器连接失败","err")}};return l.jsxs("div",{children:[l.jsx("div",{style:{display:"flex",gap:6,marginBottom:16,flexWrap:"wrap"},children:Bf.map(S=>l.jsxs("span",{className:`tpl-cat${o===S.name?" active":""}`,onClick:()=>f(S.name),children:[S.icon," ",S.name]},S.name))}),l.jsx("div",{className:"tpl-grid",children:b.map(S=>l.jsxs("div",{className:"tpl-card",children:[l.jsxs("div",{className:"tpl-top",children:[l.jsx("span",{className:"tpl-icon",children:S.icon}),l.jsx("span",{className:"tpl-name",children:S.name})]}),l.jsx("div",{className:"tpl-desc",children:S.desc}),l.jsxs("div",{className:"tpl-footer",children:[S.depts.map(M=>l.jsx("span",{className:"tpl-dept",children:M},M)),l.jsxs("span",{className:"tpl-est",children:[S.est," · ",S.cost]}),l.jsx("button",{className:"tpl-go",onClick:()=>d(S),children:"下旨"})]})]},S.id))}),g&&l.jsx("div",{className:"modal-bg open",onClick:()=>P(null),children:l.jsxs("div",{className:"modal",onClick:S=>S.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:()=>P(null),children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{style:{fontSize:11,color:"var(--acc)",fontWeight:700,letterSpacing:".04em",marginBottom:4},children:"圣旨模板"}),l.jsxs("div",{style:{fontSize:20,fontWeight:800,marginBottom:6},children:[g.icon," ",g.name]}),l.jsx("div",{style:{fontSize:12,color:"var(--muted)",marginBottom:18},children:g.desc}),l.jsxs("div",{style:{display:"flex",gap:6,marginBottom:18,flexWrap:"wrap"},children:[g.depts.map(S=>l.jsx("span",{className:"tpl-dept",children:S},S)),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:"auto"},children:[g.est," · ",g.cost]})]}),l.jsxs("form",{className:"tpl-form",onSubmit:O,children:[g.params.map(S=>l.jsxs("div",{className:"tpl-field",children:[l.jsxs("label",{className:"tpl-label",children:[S.label,S.required&&l.jsx("span",{style:{color:"#ff5270"},children:" *"})]}),S.type==="textarea"?l.jsx("textarea",{className:"tpl-input",style:{minHeight:80,resize:"vertical"},required:S.required,value:L[S.key]||"",onChange:M=>z(x=>({...x,[S.key]:M.target.value}))}):S.type==="select"?l.jsx("select",{className:"tpl-input",value:L[S.key]||S.default||"",onChange:M=>z(x=>({...x,[S.key]:M.target.value})),children:(S.options||[]).map(M=>l.jsx("option",{children:M},M))}):l.jsx("input",{className:"tpl-input",type:"text",required:S.required,value:L[S.key]||"",onChange:M=>z(x=>({...x,[S.key]:M.target.value}))})]},S.key)),T&&l.jsxs("div",{style:{background:"var(--panel2)",border:"1px solid var(--line)",borderRadius:8,padding:12,marginBottom:14,fontSize:12,color:"var(--muted)"},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text)",marginBottom:6},children:"📜 将发送给中书省的旨意:"}),l.jsx("div",{style:{whiteSpace:"pre-wrap",lineHeight:1.6},children:T})]}),l.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"flex-end"},children:[l.jsx("button",{type:"button",className:"btn btn-g",onClick:j,style:{padding:"8px 16px",fontSize:12},children:"👁 预览旨意"}),l.jsx("button",{type:"submit",className:"tpl-go",style:{padding:"8px 20px",fontSize:13},children:"📜 下旨"})]})]})]})]})})]})}const hu={政治:{icon:"🏛️",color:"#6a9eff",desc:"全球政治动态"},军事:{icon:"⚔️",color:"#ff5270",desc:"军事与冲突"},经济:{icon:"💹",color:"#2ecc8a",desc:"经济与市场"},AI大模型:{icon:"🤖",color:"#a07aff",desc:"AI与大模型进展"}},Gi=["政治","军事","经济","AI大模型"];function dp(){const o=ee(Z=>Z.morningBrief),f=ee(Z=>Z.subConfig),c=ee(Z=>Z.loadMorning),v=ee(Z=>Z.loadSubConfig),g=ee(Z=>Z.toast),[P,L]=Q.useState(!1),[z,T]=Q.useState(null),[E,b]=Q.useState(!1),[d,N]=Q.useState("⟳ 立即采集"),j=Q.useRef(null);Q.useEffect(()=>{c()},[c]),Q.useEffect(()=>{f&&T(JSON.parse(JSON.stringify(f)))},[f]),Q.useEffect(()=>()=>{j.current&&clearInterval(j.current)},[]);const O=async()=>{b(!0),N("⟳ 采集中…");let Z=null;try{Z=(o==null?void 0:o.generated_at)||null}catch{}try{await de.refreshMorning(),g("采集已触发,自动检测更新中…","ok");let oe=0;j.current&&clearInterval(j.current),j.current=setInterval(async()=>{if(oe++,oe>24){clearInterval(j.current),j.current=null,b(!1),N("⟳ 立即采集"),g("采集超时,请重试","err");return}try{const ke=await de.morningBrief();ke.generated_at&&ke.generated_at!==Z?(clearInterval(j.current),j.current=null,b(!1),N("⟳ 立即采集"),c(),g("✅ 天下要闻已更新","ok")):N(`⟳ 采集中… (${oe*5}s)`)}catch{}},5e3)}catch{g("触发失败","err"),b(!1),N("⟳ 立即采集")}},S=Z=>{if(!z)return;const oe=[...z.categories||[]],ke=oe.find(le=>le.name===Z);ke?ke.enabled=!ke.enabled:oe.push({name:Z,enabled:!0}),T({...z,categories:oe})},M=Z=>{if(!z||!Z)return;const oe=[...z.keywords||[]];oe.includes(Z)||oe.push(Z),T({...z,keywords:oe})},x=Z=>{if(!z)return;const oe=[...z.keywords||[]];oe.splice(Z,1),T({...z,keywords:oe})},A=(Z,oe,ke)=>{if(!z||!Z||!oe){g("请填写源名称和URL","err");return}const le=[...z.custom_feeds||[]];le.push({name:Z,url:oe,category:ke}),T({...z,custom_feeds:le})},V=Z=>{if(!z)return;const oe=[...z.custom_feeds||[]];oe.splice(Z,1),T({...z,custom_feeds:oe})},R=async()=>{if(z)try{const Z=await de.saveMorningConfig(z);Z.ok?(g("订阅配置已保存","ok"),v()):g(Z.error||"保存失败","err")}catch{g("服务器连接失败","err")}},re=z?new Set((z.categories||[]).filter(Z=>Z.enabled).map(Z=>Z.name)):new Set(Gi),ue=((z==null?void 0:z.keywords)||[]).map(Z=>Z.toLowerCase()),me=(o==null?void 0:o.categories)||{},pe=o!=null&&o.date?o.date.replace(/(\d{4})(\d{2})(\d{2})/,"$1年$2月$3日"):"",Ae=Object.values(me).flat().length;return l.jsxs("div",{children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:20,fontWeight:800,marginBottom:4},children:"🌅 天下要闻"}),l.jsxs("div",{style:{fontSize:12,color:"var(--muted)"},children:[pe&&`${pe} | `,(o==null?void 0:o.generated_at)&&`采集于 ${o.generated_at} | `,"共 ",Ae," 条要闻"]})]}),l.jsxs("div",{style:{display:"flex",gap:8},children:[l.jsx("button",{className:"btn btn-g",onClick:()=>L(!P),style:{fontSize:12,padding:"6px 14px"},children:"⚙ 订阅配置"}),l.jsx("button",{className:"tpl-go",disabled:E,onClick:O,style:{fontSize:12,padding:"6px 14px"},children:d})]})]}),P&&z&&l.jsx(fp,{config:z,enabledSet:re,onToggleCat:S,onAddKeyword:M,onRemoveKeyword:x,onAddFeed:A,onRemoveFeed:V,onSave:R,onSetWebhook:Z=>T({...z,feishu_webhook:Z})}),Object.keys(me).length?l.jsx("div",{className:"mb-cats",children:Object.entries(me).map(([Z,oe])=>{if(!re.has(Z))return null;const ke=hu[Z]||{icon:"📰",color:"var(--acc)"},le=oe.map(te=>{const Ne=((te.title||"")+(te.summary||"")).toLowerCase(),Ee=ue.filter(je=>Ne.includes(je)).length;return{...te,_kwHits:Ee}}).sort((te,Ne)=>Ne._kwHits-te._kwHits);return l.jsxs("div",{className:"mb-cat",children:[l.jsxs("div",{className:"mb-cat-hdr",children:[l.jsx("span",{className:"mb-cat-icon",children:ke.icon}),l.jsx("span",{className:"mb-cat-name",style:{color:ke.color},children:Z}),l.jsxs("span",{className:"mb-cat-cnt",children:[le.length," 条"]})]}),l.jsx("div",{className:"mb-news-list",children:le.length?le.map((te,Ne)=>{const Ee=!!(te.image&&te.image.startsWith("http"));return l.jsxs("div",{className:"mb-card",onClick:()=>window.open(te.link,"_blank"),children:[l.jsx("div",{className:"mb-img",children:Ee?l.jsx("img",{src:te.image,onError:je=>{je.target.style.display="none"},loading:"lazy",alt:""}):l.jsx("span",{children:ke.icon})}),l.jsxs("div",{className:"mb-info",children:[l.jsxs("div",{className:"mb-headline",children:[te.title,te._kwHits>0&&l.jsx("span",{style:{fontSize:9,padding:"1px 5px",borderRadius:999,background:"#a07aff22",color:"#a07aff",border:"1px solid #a07aff44",marginLeft:4},children:"⭐ 关注"})]}),l.jsx("div",{className:"mb-summary",children:te.summary||te.desc||""}),l.jsxs("div",{className:"mb-meta",children:[l.jsxs("span",{className:"mb-source",children:["📡 ",te.source||""]}),te.pub_date&&l.jsx("span",{className:"mb-time",children:te.pub_date.substring(0,16)})]})]})]},Ne)}):l.jsx("div",{className:"mb-empty",style:{padding:16},children:"暂无新闻"})})]},Z)})}):l.jsx("div",{className:"mb-empty",children:"暂无数据,点击右上角「立即采集」获取今日简报"})]})}function fp({config:o,enabledSet:f,onToggleCat:c,onAddKeyword:v,onRemoveKeyword:g,onAddFeed:P,onRemoveFeed:L,onSave:z,onSetWebhook:T}){const[E,b]=Q.useState(""),[d,N]=Q.useState(""),[j,O]=Q.useState(""),[S,M]=Q.useState(Gi[0]),x=[...Gi];return(o.categories||[]).forEach(A=>{x.includes(A.name)||x.push(A.name)}),l.jsxs("div",{className:"sub-config",style:{marginBottom:20,padding:16,background:"var(--panel2)",borderRadius:12,border:"1px solid var(--line)"},children:[l.jsx("div",{style:{fontSize:14,fontWeight:700,marginBottom:12},children:"⚙ 订阅配置"}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"订阅分类"}),l.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:x.map(A=>{const V=hu[A]||{icon:"📰"},R=f.has(A);return l.jsxs("div",{className:`sub-cat ${R?"active":""}`,onClick:()=>c(A),style:{cursor:"pointer",padding:"6px 12px",borderRadius:8,border:`1px solid ${R?"var(--acc)":"var(--line)"}`,display:"flex",alignItems:"center",gap:6},children:[l.jsx("span",{children:V.icon}),l.jsx("span",{style:{fontSize:12},children:A}),R&&l.jsx("span",{style:{fontSize:10,color:"var(--ok)"},children:"✓"})]},A)})})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"关注关键词"}),l.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:6},children:(o.keywords||[]).map((A,V)=>l.jsxs("span",{className:"sub-kw",style:{fontSize:11,padding:"2px 8px",borderRadius:4,background:"var(--bg)",border:"1px solid var(--line)"},children:[A,l.jsx("span",{style:{cursor:"pointer",marginLeft:4,color:"var(--danger)"},onClick:()=>g(V),children:"✕"})]},V))}),l.jsxs("div",{style:{display:"flex",gap:6},children:[l.jsx("input",{type:"text",value:E,onChange:A=>b(A.target.value),placeholder:"输入关键词",onKeyDown:A=>{A.key==="Enter"&&(v(E.trim()),b(""))},style:{flex:1,padding:"6px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}}),l.jsx("button",{className:"btn btn-g",onClick:()=>{v(E.trim()),b("")},style:{fontSize:11,padding:"4px 12px"},children:"添加"})]})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:8},children:"自定义信息源"}),(o.custom_feeds||[]).map((A,V)=>l.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:4,fontSize:11},children:[l.jsx("span",{style:{fontWeight:600},children:A.name}),l.jsx("span",{style:{color:"var(--muted)",flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:A.url}),l.jsx("span",{style:{color:"var(--acc)"},children:A.category}),l.jsx("span",{style:{cursor:"pointer",color:"var(--danger)"},onClick:()=>L(V),children:"✕"})]},V)),l.jsxs("div",{style:{display:"flex",gap:6,marginTop:6},children:[l.jsx("input",{placeholder:"源名称",value:d,onChange:A=>N(A.target.value),style:{width:100,padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"}}),l.jsx("input",{placeholder:"RSS / URL",value:j,onChange:A=>O(A.target.value),style:{flex:1,padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"}}),l.jsx("select",{value:S,onChange:A=>M(A.target.value),style:{padding:"6px 8px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:11,outline:"none"},children:x.map(A=>l.jsx("option",{value:A,children:A},A))}),l.jsx("button",{className:"btn btn-g",onClick:()=>{P(d,j,S),N(""),O("")},style:{fontSize:11,padding:"4px 12px"},children:"添加"})]})]}),l.jsxs("div",{style:{marginBottom:14},children:[l.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"飞书 Webhook"}),l.jsx("input",{type:"text",value:o.feishu_webhook||"",onChange:A=>T(A.target.value),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",style:{width:"100%",padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--line)",borderRadius:6,color:"var(--text)",fontSize:12,outline:"none"}})]}),l.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:l.jsx("button",{className:"tpl-go",onClick:z,style:{fontSize:12,padding:"6px 16px"},children:"💾 保存配置"})})]})}const vu={main:"太子",zhongshu:"中书省",menxia:"门下省",shangshu:"尚书省",libu:"礼部",hubu:"户部",bingbu:"兵部",xingbu:"刑部",gongbu:"工部",libu_hr:"吏部",zaochao:"钦天监"},pp={Taizi:"中书省起草",Zhongshu:"门下省审议",Menxia:"尚书省派发",Assigned:"开始执行",Doing:"进入审查",Review:"完成"};function mp(o){const f=Math.max(0,o);if(f<60)return`${f}秒`;if(f<3600)return`${Math.floor(f/60)}分${f%60}秒`;const c=Math.floor(f/3600),v=Math.floor(f%3600/60);return`${c}小时${v}分`}function Yi(o){if(!o)return"";if(typeof o=="number"){const f=new Date(o);return`${String(f.getHours()).padStart(2,"0")}:${String(f.getMinutes()).padStart(2,"0")}:${String(f.getSeconds()).padStart(2,"0")}`}return typeof o=="string"&&o.length>=19?o.substring(11,19):String(o).substring(0,8)}function hp(){var Ee,je;const o=ee(_=>_.modalTaskId),f=ee(_=>_.setModalTaskId),c=ee(_=>_.liveStatus),v=ee(_=>_.loadAll),g=ee(_=>_.toast),[P,L]=Q.useState(null),[z,T]=Q.useState(null),E=Q.useRef(null),b=Q.useRef(null),d=((Ee=c==null?void 0:c.tasks)==null?void 0:Ee.find(_=>_.id===o))||null,N=Q.useCallback(async()=>{if(o)try{const _=await de.taskActivity(o);L(_)}catch{L(null)}},[o]),j=Q.useCallback(async()=>{if(o)try{const _=await de.schedulerState(o);T(_)}catch{T(null)}},[o]);if(Q.useEffect(()=>!o||!d?void 0:(N(),j(),["Done","Cancelled"].includes(d.state)||(E.current=setInterval(()=>{N(),j()},4e3)),()=>{E.current&&(clearInterval(E.current),E.current=null)}),[o,d==null?void 0:d.state,N,j]),Q.useEffect(()=>{b.current&&(b.current.scrollTop=b.current.scrollHeight)},[(je=P==null?void 0:P.activity)==null?void 0:je.length]),!o||!d)return null;const O=()=>f(null),S=qi(d),M=S.find(_=>_.status==="active"),x=d.heartbeat||{status:"unknown",label:"⚪ 无数据"},A=d.flow_log||[],V=d.todos||[],R=V.filter(_=>_.status==="completed").length,re=V.length,ue=!["Done","Blocked","Cancelled"].includes(d.state),me=["Blocked","Cancelled"].includes(d.state),pe=async(_,G)=>{try{const U=await de.taskAction(d.id,_,G);U.ok?(g(U.message||"操作成功","ok"),v(),O()):g(U.error||"操作失败","err")}catch{g("服务器连接失败","err")}},Ae=async _=>{const G={approve:"准奏",reject:"封驳"},U=prompt(`${G[_]} ${d.id} -请输入批注(可留空):`);if(U!==null)try{const v=await fe.reviewAction(d.id,E,U||"");v.ok?(x(`✅ ${d.id} 已${K[E]}`,"ok"),y(),R()):x(v.error||"操作失败","err")}catch{x("服务器连接失败","err")}},X=async()=>{const E=fp[d.state]||"下一步",K=prompt(`⏩ 手动推进 ${d.id} -当前: ${d.state} → 下一步: ${E} +请输入批注(可留空):`);if(U!==null)try{const h=await de.reviewAction(d.id,_,U||"");h.ok?(g(`✅ ${d.id} 已${G[_]}`,"ok"),v(),O()):g(h.error||"操作失败","err")}catch{g("服务器连接失败","err")}},Z=async()=>{const _=pp[d.state]||"下一步",G=prompt(`⏩ 手动推进 ${d.id} +当前: ${d.state} → 下一步: ${_} -请输入说明(可留空):`);if(K!==null)try{const U=await fe.advanceState(d.id,K||"");U.ok?(x(`⏩ ${U.message}`,"ok"),y(),R()):x(U.error||"推进失败","err")}catch{x("服务器连接失败","err")}},ie=async E=>{if(E==="scan"){try{const D=await fe.schedulerScan(180);D.ok?x(`🔍 扫描完成:${D.count||0} 个动作`,"ok"):x(D.error||"扫描失败","err"),m()}catch{x("服务器连接失败","err")}return}const U=prompt(`请输入${{retry:"重试",escalate:"升级",rollback:"回滚"}[E]}原因(可留空):`);if(U===null)return;const v={retry:fe.schedulerRetry,escalate:fe.schedulerEscalate,rollback:fe.schedulerRollback};try{const D=await v[E](d.id,U);D.ok?x(D.message||"操作成功","ok"):x(D.error||"操作失败","err"),m(),y()}catch{x("服务器连接失败","err")}},ke=()=>{const E=prompt("请输入叫停原因(可留空):");E!==null&&pe("stop",E)},re=()=>{if(!confirm(`确定要取消 ${d.id} 吗?`))return;const E=prompt("请输入取消原因(可留空):");E!==null&&pe("cancel",E)},te=_==null?void 0:_.scheduler,Ne=(_==null?void 0:_.stalledSec)||0;return l.jsx("div",{className:"modal-bg open",onClick:R,children:l.jsxs("div",{className:"modal",onClick:E=>E.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:R,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{className:"modal-id",children:d.id}),l.jsx("div",{className:"modal-title",children:d.title||"(无标题)"}),A&&l.jsxs("div",{className:"cur-stage",children:[l.jsx("div",{className:"cs-icon",children:A.icon}),l.jsxs("div",{className:"cs-info",children:[l.jsx("div",{className:"cs-dept",style:{color:Ul(A.dept)},children:A.dept}),l.jsxs("div",{className:"cs-action",children:["当前阶段:",A.action]})]}),l.jsx("span",{className:`hb ${P.status} cs-hb`,children:P.label})]}),l.jsx("div",{className:"m-pipe",children:g.map((E,K)=>l.jsxs("div",{className:"mp-stage",children:[l.jsxs("div",{className:`mp-node ${E.status}`,children:[E.status==="done"&&l.jsx("div",{className:"mp-done-tick",children:"✓"}),l.jsx("div",{className:"mp-icon",children:E.icon}),l.jsx("div",{className:"mp-dept",style:E.status==="active"?{color:"var(--acc)"}:E.status==="done"?{color:"var(--ok)"}:{},children:E.dept}),l.jsx("div",{className:"mp-action",children:E.action})]}),Kpe("resume","恢复执行"),children:"▶️ 恢复执行"}),["Review","Menxia"].includes(d.state)&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"btn-action",style:{background:"#2ecc8a22",color:"#2ecc8a",border:"1px solid #2ecc8a44"},onClick:()=>Ae("approve"),children:"✅ 准奏"}),l.jsx("button",{className:"btn-action",style:{background:"#ff527022",color:"#ff5270",border:"1px solid #ff527044"},onClick:()=>Ae("reject"),children:"🚫 封驳"})]}),["Pending","Taizi","Zhongshu","Menxia","Assigned","Doing","Review","Next"].includes(d.state)&&l.jsx("button",{className:"btn-action",style:{background:"#7c5cfc18",color:"#7c5cfc",border:"1px solid #7c5cfc44"},onClick:X,children:"⏩ 推进到下一步"})]}),l.jsxs("div",{className:"sched-section",children:[l.jsxs("div",{className:"sched-head",children:[l.jsx("span",{className:"sched-title",children:"🧭 太子调度"}),l.jsx("span",{className:"sched-status",children:te?`${te.enabled===!1?"已禁用":"运行中"} · 阈值 ${te.stallThresholdSec||180}s`:"加载中..."})]}),l.jsxs("div",{className:"sched-grid",children:[l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"停滞时长"}),l.jsx("div",{className:"v",children:pp(Ne)})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"重试次数"}),l.jsx("div",{className:"v",children:(te==null?void 0:te.retryCount)||0})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"升级级别"}),l.jsx("div",{className:"v",children:te!=null&&te.escalationLevel?te.escalationLevel===1?"门下省":"尚书省":"无"})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"派发状态"}),l.jsx("div",{className:"v",children:(te==null?void 0:te.lastDispatchStatus)||"idle"})]})]}),te&&l.jsxs("div",{className:"sched-line",children:[te.lastProgressAt&&l.jsxs("span",{children:["最近进展 ",(te.lastProgressAt||"").replace("T"," ").substring(0,19)]}),te.lastDispatchAt&&l.jsxs("span",{children:["最近派发 ",(te.lastDispatchAt||"").replace("T"," ").substring(0,19)]}),l.jsxs("span",{children:["自动回滚 ",te.autoRollback===!1?"关闭":"开启"]}),te.lastDispatchAgent&&l.jsxs("span",{children:["目标 ",te.lastDispatchAgent]})]}),l.jsxs("div",{className:"sched-actions",children:[l.jsx("button",{className:"sched-btn",onClick:()=>ie("retry"),children:"🔁 重试派发"}),l.jsx("button",{className:"sched-btn warn",onClick:()=>ie("escalate"),children:"📣 升级协调"}),l.jsx("button",{className:"sched-btn danger",onClick:()=>ie("rollback"),children:"↩️ 回滚稳定点"}),l.jsx("button",{className:"sched-btn",onClick:()=>ie("scan"),children:"🔍 立即扫描"})]})]}),oe>0&&l.jsx(hp,{todos:J,todoDone:I,todoTotal:oe}),l.jsx("div",{className:"m-section",children:l.jsxs("div",{className:"m-rows",children:[l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"状态"}),l.jsxs("div",{className:"mr-val",children:[l.jsx("span",{className:`tag st-${d.state}`,children:Ji(d)}),(d.review_round||0)>0&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:8},children:["共磋商 ",d.review_round," 轮"]})]})]}),l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"执行部门"}),l.jsx("div",{className:"mr-val",children:l.jsx("span",{className:`tag dt-${(d.org||"").replace(/\s/g,"")}`,children:d.org||"—"})})]}),d.eta&&d.eta!=="-"&&l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"预计完成"}),l.jsx("div",{className:"mr-val",children:d.eta})]}),d.block&&d.block!=="无"&&d.block!=="-"&&l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",style:{color:"var(--danger)"},children:"阻塞项"}),l.jsx("div",{className:"mr-val",style:{color:"var(--danger)"},children:d.block})]}),d.now&&d.now!=="-"&&l.jsxs("div",{className:"m-row",style:{gridColumn:"1/-1"},children:[l.jsx("div",{className:"mr-label",children:"当前进展"}),l.jsx("div",{className:"mr-val",style:{fontWeight:400,fontSize:12},children:d.now})]}),d.ac&&l.jsxs("div",{className:"m-row",style:{gridColumn:"1/-1"},children:[l.jsx("div",{className:"mr-label",children:"验收标准"}),l.jsx("div",{className:"mr-val",style:{fontWeight:400,fontSize:12},children:d.ac})]})]})}),W.length>0&&l.jsxs("div",{className:"m-section",children:[l.jsxs("div",{className:"m-sec-label",children:["流转日志(",W.length," 条)"]}),l.jsx("div",{className:"fl-timeline",children:W.map((E,K)=>{const U=Ul(E.from||"");return l.jsxs("div",{className:"fl-item",children:[l.jsx("div",{className:"fl-time",children:E.at?E.at.substring(11,16):""}),l.jsx("div",{className:"fl-dot",style:{background:U}}),l.jsxs("div",{className:"fl-content",children:[l.jsxs("div",{className:"fl-who",children:[l.jsx("span",{className:"from",style:{color:U},children:E.from}),l.jsx("span",{style:{color:"var(--muted)"},children:" → "}),l.jsx("span",{className:"to",style:{color:Ul(E.to||"")},children:E.to})]}),l.jsx("div",{className:"fl-rem",children:E.remark})]})]},K)})})]}),d.output&&d.output!=="-"&&d.output!==""&&l.jsxs("div",{className:"m-section",children:[l.jsx("div",{className:"m-sec-label",children:"产出物"}),l.jsx("code",{children:d.output})]}),l.jsx(vp,{data:L,isDone:["Done","Cancelled"].includes(d.state),logRef:z})]})]})})}function hp({todos:o,todoDone:f,todoTotal:c}){return l.jsxs("div",{className:"todo-section",children:[l.jsxs("div",{className:"todo-header",children:[l.jsxs("div",{className:"m-sec-label",style:{marginBottom:0,border:"none",padding:0},children:["子任务清单(",f,"/",c,")"]}),l.jsxs("div",{className:"todo-progress",children:[l.jsx("div",{className:"todo-bar",children:l.jsx("div",{className:"todo-bar-fill",style:{width:`${Math.round(f/c*100)}%`}})}),l.jsxs("span",{children:[Math.round(f/c*100),"%"]})]})]}),l.jsx("div",{className:"todo-list",children:o.map(y=>{const x=y.status==="completed"?"✅":y.status==="in-progress"?"🔄":"⬜",L=y.status==="completed"?"已完成":y.status==="in-progress"?"进行中":"待开始",T=y.status==="completed"?"s-done":y.status==="in-progress"?"s-progress":"s-notstarted",_=y.status==="completed"?"done":"";return l.jsxs("div",{className:`todo-item ${_}`,children:[l.jsxs("div",{className:"t-row",children:[l.jsx("span",{className:"t-icon",children:x}),l.jsxs("span",{className:"t-id",children:["#",y.id]}),l.jsx("span",{className:"t-title",children:y.title}),l.jsx("span",{className:`t-status ${T}`,children:L})]}),y.detail&&l.jsx("div",{className:"todo-detail",children:y.detail})]},y.id)})})]})}function vp({data:o,isDone:f,logRef:c}){if(!o)return null;const y=o.activity||[],x=(()=>{if(!y.length)return!1;const R=y[y.length-1];if(!R.at)return!1;const g=typeof R.at=="number"?R.at:new Date(R.at).getTime();return Date.now()-g<3e5})(),L=[];o.agentLabel&&L.push(o.agentLabel),o.relatedAgents&&o.relatedAgents.length>1&&L.push(`${o.relatedAgents.length}个 Agent`),o.lastActive&&L.push(`最后活跃: ${o.lastActive}`);const T=o.phaseDurations||[],_=Math.max(...T.map(R=>R.durationSec||1),1),b={皇上:"#eab308",太子:"#f97316",中书省:"#3b82f6",门下省:"#8b5cf6",尚书省:"#10b981",六部:"#06b6d4",礼部:"#ec4899",户部:"#f59e0b",兵部:"#ef4444",刑部:"#6366f1",工部:"#14b8a6",吏部:"#d946ef"},C=o.todosSummary,z=o.resourceSummary,d=y.filter(R=>R.kind==="flow"),w=y.filter(R=>R.kind!=="flow"),m=new Map;return w.forEach(R=>{const g=R.agent||"unknown";m.has(g)||m.set(g,[]),m.get(g).push(R)}),l.jsxs("div",{className:"la-section",children:[l.jsxs("div",{className:"la-header",children:[l.jsxs("span",{className:"la-title",children:[l.jsx("span",{className:`la-dot${x?"":" idle"}`}),f?"执行回顾":"实时动态"]}),l.jsx("span",{className:"la-agent",children:L.join(" · ")||"加载中..."})]}),T.length>0&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"⏱ 阶段耗时"}),o.totalDuration&&l.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--muted)"},children:["总耗时 ",o.totalDuration]})]}),T.map((R,g)=>{const A=Math.max(5,Math.round((R.durationSec||1)/_*100)),P=b[R.phase]||"#6b7280";return l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,margin:"2px 0",fontSize:11},children:[l.jsx("span",{style:{minWidth:48,color:"var(--muted)",textAlign:"right"},children:R.phase}),l.jsx("div",{style:{flex:1,height:14,background:"var(--panel)",borderRadius:3,overflow:"hidden"},children:l.jsx("div",{style:{width:`${A}%`,height:"100%",background:P,borderRadius:3,opacity:R.ongoing?.6:.85}})}),l.jsxs("span",{style:{minWidth:60,fontSize:10,color:"var(--muted)"},children:[R.durationText,R.ongoing&&l.jsx("span",{style:{fontSize:9,color:"#60a5fa"},children:" ●进行中"})]})]},g)})]}),C&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"📊 执行进度"}),l.jsxs("span",{style:{fontSize:20,fontWeight:700,color:C.percent>=100?"#22c55e":C.percent>=50?"#60a5fa":"var(--text)"},children:[C.percent,"%"]}),l.jsxs("span",{style:{fontSize:10,color:"var(--muted)"},children:["✅",C.completed," 🔄",C.inProgress," ⬜",C.notStarted," / 共",C.total,"项"]})]}),l.jsxs("div",{style:{height:8,background:"var(--panel)",borderRadius:4,overflow:"hidden",display:"flex"},children:[l.jsx("div",{style:{width:`${C.total?C.completed/C.total*100:0}%`,background:"#22c55e",transition:"width .3s"}}),l.jsx("div",{style:{width:`${C.total?C.inProgress/C.total*100:0}%`,background:"#3b82f6",transition:"width .3s"}})]})]}),z&&(z.totalTokens||z.totalCost)&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)",display:"flex",gap:12,alignItems:"center"},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"📈 资源消耗"}),z.totalTokens!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["🔢 ",z.totalTokens.toLocaleString()," tokens"]}),z.totalCost!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["💰 $",z.totalCost.toFixed(4)]}),z.totalElapsedSec!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["⏳ ",z.totalElapsedSec>=60?`${Math.floor(z.totalElapsedSec/60)}分`:"",z.totalElapsedSec%60,"秒"]})]}),l.jsxs("div",{className:"la-log",ref:c,children:[d.length>0&&l.jsx("div",{className:"la-flow-wrap",children:d.map((R,g)=>l.jsxs("div",{className:"la-entry la-tool",children:[l.jsx("span",{className:"la-icon",children:"📋"}),l.jsxs("span",{className:"la-body",children:[l.jsx("b",{children:R.from})," → ",l.jsx("b",{children:R.to})," ",R.remark||""]}),l.jsx("span",{className:"la-time",children:Yi(R.at)})]},`flow-${g}`))}),m.size>0?l.jsx("div",{className:"la-groups",children:Array.from(m.entries()).map(([R,g])=>{const A=vu[R]||R||"未标识",P=g[g.length-1],W=P!=null&&P.at?Yi(P.at):"--:--:--";return l.jsxs("div",{className:"la-group",children:[l.jsxs("div",{className:"la-group-hd",children:[l.jsx("span",{className:"name",children:A}),l.jsxs("span",{children:["最近更新 ",W]})]}),l.jsx("div",{className:"la-group-bd",children:g.map((J,I)=>l.jsx(gp,{entry:J},I))})]},R)})}):!d.length&&l.jsx("div",{className:"la-empty",children:o.message||o.error||"Agent 尚未上报进展(等待 Agent 调用 progress 命令)"})]})]})}function gp({entry:o}){var y,x,L;const f=Yi(o.at),c=o.agent?l.jsx("span",{style:{fontSize:9,color:"var(--muted)",background:"var(--panel)",padding:"1px 4px",borderRadius:3,marginRight:4},children:vu[o.agent]||o.agent}):null;if(o.kind==="progress")return l.jsxs("div",{className:"la-entry la-assistant",children:[l.jsx("span",{className:"la-icon",children:"🔄"}),l.jsxs("span",{className:"la-body",children:[c,l.jsx("b",{children:"当前进展:"}),o.text]}),l.jsx("span",{className:"la-time",children:f})]});if(o.kind==="todos"){const T=o.items||[],_=new Map;return o.diff&&((o.diff.changed||[]).forEach(b=>_.set(b.id,{type:"changed",from:b.from,to:b.to})),(o.diff.added||[]).forEach(b=>_.set(b.id,{type:"added"}))),l.jsxs("div",{className:"la-entry",style:{flexDirection:"column",alignItems:"flex-start",gap:2},children:[l.jsxs("div",{style:{fontSize:11,color:"var(--muted)",marginBottom:2},children:[c,"📝 执行计划"]}),T.map(b=>{const C=b.status==="completed"?"✅":b.status==="in-progress"?"🔄":"⬜",z=_.get(String(b.id)),d=b.status==="completed"?{opacity:.5,textDecoration:"line-through"}:b.status==="in-progress"?{color:"#60a5fa",fontWeight:"bold"}:{};return l.jsxs("div",{style:d,children:[C," ",b.title,z&&z.type==="changed"&&z.to==="completed"&&l.jsx("span",{style:{color:"#22c55e",fontSize:9,marginLeft:4},children:"✨刚完成"}),z&&z.type==="changed"&&z.to!=="completed"&&l.jsxs("span",{style:{color:"#f59e0b",fontSize:9,marginLeft:4},children:["↻",z.from,"→",z.to]}),z&&z.type==="added"&&l.jsx("span",{style:{color:"#3b82f6",fontSize:9,marginLeft:4},children:"🆕新增"})]},b.id)}),(x=(y=o.diff)==null?void 0:y.removed)==null?void 0:x.map(b=>l.jsxs("div",{style:{opacity:.4,textDecoration:"line-through"},children:["🗑 ",b.title]},b.id))]})}if(o.kind==="assistant")return l.jsxs(l.Fragment,{children:[o.thinking&&l.jsxs("div",{className:"la-entry la-thinking",children:[l.jsx("span",{className:"la-icon",children:"💭"}),l.jsxs("span",{className:"la-body",children:[c,o.thinking]}),l.jsx("span",{className:"la-time",children:f})]}),(L=o.tools)==null?void 0:L.map((T,_)=>l.jsxs("div",{className:"la-entry la-tool",children:[l.jsx("span",{className:"la-icon",children:"🔧"}),l.jsxs("span",{className:"la-body",children:[c,l.jsx("span",{className:"la-tool-name",children:T.name}),l.jsx("span",{className:"la-trunc",children:T.input_preview||""})]}),l.jsx("span",{className:"la-time",children:f})]},_)),o.text&&l.jsxs("div",{className:"la-entry la-assistant",children:[l.jsx("span",{className:"la-icon",children:"🤖"}),l.jsxs("span",{className:"la-body",children:[c,o.text]}),l.jsx("span",{className:"la-time",children:f})]})]});if(o.kind==="tool_result"){const T=o.exitCode===0||o.exitCode===null||o.exitCode===void 0;return l.jsxs("div",{className:`la-entry la-tool-result ${T?"ok":"err"}`,children:[l.jsx("span",{className:"la-icon",children:T?"✅":"❌"}),l.jsxs("span",{className:"la-body",children:[c,l.jsx("span",{className:"la-tool-name",children:o.tool||""}),o.output?o.output.substring(0,150):""]}),l.jsx("span",{className:"la-time",children:f})]})}return o.kind==="user"?l.jsxs("div",{className:"la-entry la-user",children:[l.jsx("span",{className:"la-icon",children:"📥"}),l.jsxs("span",{className:"la-body",children:[c,o.text||""]}),l.jsx("span",{className:"la-time",children:f})]}):null}function yp(){const o=ee(f=>f.toasts);return o.length?l.jsx("div",{className:"toaster",children:o.map(f=>l.jsx("div",{className:`toast ${f.type}`,children:f.msg},f.id))}):null}function xp(){const o=ee(R=>R.liveStatus),[f,c]=V.useState(!1),[y,x]=V.useState(!1);V.useEffect(()=>{const R=localStorage.getItem("openclaw_court_date"),g=new Date().toISOString().substring(0,10);if(!JSON.parse(localStorage.getItem("openclaw_court_pref")||'{"enabled":true}').enabled||R===g)return;localStorage.setItem("openclaw_court_date",g),c(!0);const P=setTimeout(()=>L(),3500);return()=>clearTimeout(P)},[]);const L=()=>{x(!0),setTimeout(()=>c(!1),500)};if(!f)return null;const _=((o==null?void 0:o.tasks)||[]).filter(ln),b=_.filter(R=>!["Done","Cancelled"].includes(R.state)).length,C=_.filter(R=>R.state==="Done").length,z=_.filter(R=>R.state!=="Done"&&R.state!=="Cancelled"&&R.eta&&new Date(R.eta.replace(" ","T"))0&&` · ⚠ 超期 ${z} 件`]}),l.jsx("div",{className:"crm-date in",children:m}),l.jsx("div",{className:"crm-skip",children:"点击任意处跳过"})]})}const Xi={taizi:"#e8a040",zhongshu:"#a07aff",menxia:"#6a9eff",shangshu:"#2ecc8a",libu:"#f5c842",hubu:"#ff9a6a",bingbu:"#ff5270",xingbu:"#cc4444",gongbu:"#44aaff",libu_hr:"#9b59b6"},Ql={neutral:"",confident:"😏",worried:"😟",angry:"😤",thinking:"🤔",amused:"😄",happy:"😊"},kp={zhongshu:{x:15,y:25},menxia:{x:15,y:45},shangshu:{x:15,y:65},libu:{x:85,y:20},hubu:{x:85,y:35},bingbu:{x:85,y:50},xingbu:{x:85,y:65},gongbu:{x:85,y:80},taizi:{x:50,y:20},libu_hr:{x:50,y:80}};function jp(){var ve;const[o,f]=V.useState("setup"),[c,y]=V.useState(new Set),[x,L]=V.useState(""),[T,_]=V.useState(null),[b,C]=V.useState(!1),[z,d]=V.useState(!1),w=V.useRef(!1),[m,R]=V.useState(""),[g,A]=V.useState(!1),[P,W]=V.useState(""),[J,I]=V.useState(!1),[oe,ue]=V.useState(!1),[me,pe]=V.useState(null),[Ae,X]=V.useState(null),[ie,ke]=V.useState({}),re=V.useRef(null),te=ee(M=>M.toast),Ne=ee(M=>M.liveStatus);V.useEffect(()=>{var M;(M=re.current)==null||M.scrollIntoView({behavior:"smooth"})},[(ve=T==null?void 0:T.messages)==null?void 0:ve.length]),V.useEffect(()=>{w.current=z},[z]),V.useEffect(()=>{if(!z||!T||b)return;const M=setInterval(()=>{w.current&&!b&&E()},5e3);return()=>clearInterval(M)},[z,T,b]);const Ee=M=>{y(ce=>{const ye=new Set(ce);return ye.has(M)?ye.delete(M):ye.size<8&&ye.add(M),ye})},je=async()=>{if(!(!x.trim()||c.size<2||b)){C(!0);try{const M=await fe.courtDiscussStart(x,Array.from(c));if(!M.ok)throw new Error(M.error||"启动失败");_(M),f("session")}catch(M){te(M.message||"启动失败","err")}finally{C(!1)}}},E=V.useCallback(async(M,ce)=>{if(!(!T||b)){C(!0);try{const ye=await fe.courtDiscussAdvance(T.session_id,M,ce);if(!ye.ok)throw new Error(ye.error||"推进失败");_(Ke=>{if(!Ke)return Ke;const et=[];M&&et.push({type:"emperor",content:M,timestamp:Date.now()/1e3}),ce&&et.push({type:"decree",content:ce,timestamp:Date.now()/1e3});const sn=(ye.new_messages||[]).map(Ct=>({type:"official",official_id:Ct.official_id,official_name:Ct.name,content:Ct.content,emotion:Ct.emotion,action:Ct.action,timestamp:Date.now()/1e3}));return ye.scene_note&&et.push({type:"scene_note",content:ye.scene_note,timestamp:Date.now()/1e3}),{...Ke,round:ye.round??Ke.round+1,messages:[...Ke.messages,...et,...sn]}});const Be=ye.new_messages||[];if(Be.length>0){const Ke={};let et=0;const sn=()=>{et({...Ct,...Ke}))}}catch{}finally{C(!1)}}},[T,b]),K=()=>{const M=m.trim();M&&(R(""),E(M))},U=()=>{const M=P.trim();M&&(W(""),A(!1),I(!0),setTimeout(()=>I(!1),800),E(void 0,M))},v=async()=>{if(b||oe)return;ue(!0),pe(null);let M=0;const ce=setInterval(async()=>{if(M++,pe("🎲 命运轮转中..."),M>=6){clearInterval(ce);try{const Be=(await fe.courtDiscussFate()).event||"边疆急报传来";pe(Be),ue(!1),E(void 0,`【命运骰子】${Be}`)}catch{pe("命运之力暂时无法触及"),ue(!1)}}},200)},D=async()=>{if(T){C(!0);try{const M=await fe.courtDiscussConclude(T.session_id);M.summary&&_(ce=>ce&&{...ce,phase:"concluded",messages:[...ce.messages,{type:"system",content:`📋 朝堂议政结束 — ${M.summary}`,timestamp:Date.now()/1e3}]}),d(!1)}catch{te("结束失败","err")}finally{C(!1)}}},de=()=>{T&&fe.courtDiscussDestroy(T.session_id).catch(()=>{}),f("setup"),_(null),d(!1),ke({}),X(null),pe(null)},k=[...((Ne==null?void 0:Ne.tasks)||[]).filter(M=>/^JJC-/i.test(M.id)&&!["Done","Cancelled"].includes(M.state)).slice(0,3).map(M=>({text:`讨论旨意 ${M.id}:${M.title}`,taskId:M.id,icon:"📜"})),{text:"讨论系统架构优化方案",taskId:"",icon:"🏗️"},{text:"评估当前项目进展和风险",taskId:"",icon:"📊"},{text:"制定下周工作计划",taskId:"",icon:"📋"},{text:"紧急问题:线上Bug排查方案",taskId:"",icon:"🚨"}];if(o==="setup")return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"text-center py-4",children:[l.jsx("h2",{className:"text-xl font-bold bg-gradient-to-r from-amber-400 to-purple-400 bg-clip-text text-transparent",children:"🏛 朝堂议政"}),l.jsx("p",{className:"text-xs text-[var(--muted)] mt-1",children:"择臣上殿,围绕议题展开讨论 · 陛下可随时发言或降下天意改变走向"})]}),l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl p-4 border border-[var(--line)]",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("span",{className:"text-sm font-semibold",children:"👔 选择参朝官员"}),l.jsxs("span",{className:"text-xs text-[var(--muted)]",children:["(",c.size,"/8,至少2位)"]})]}),l.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-2",children:fu.map(M=>{const ce=c.has(M.id),ye=Xi[M.id]||"#6a9eff";return l.jsx("button",{onClick:()=>Ee(M.id),className:"p-2.5 rounded-lg border transition-all text-left",style:{borderColor:ce?ye+"80":"var(--line)",background:ce?ye+"15":"var(--panel2)",boxShadow:ce?`0 0 12px ${ye}20`:"none"},children:l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"text-lg",children:M.emoji}),l.jsxs("div",{children:[l.jsx("div",{className:"text-xs font-semibold",style:{color:ce?ye:"var(--text)"},children:M.label}),l.jsx("div",{className:"text-[10px] text-[var(--muted)]",children:M.role})]}),ce&&l.jsx("span",{className:"ml-auto w-4 h-4 rounded-full flex items-center justify-center text-[10px] text-white",style:{background:ye},children:"✓"})]})},M.id)})})]}),l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl p-4 border border-[var(--line)]",children:[l.jsx("div",{className:"text-sm font-semibold mb-2",children:"📜 设定议题"}),k.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5 mb-3",children:k.map((M,ce)=>l.jsxs("button",{onClick:()=>L(M.text),className:"text-xs px-2.5 py-1.5 rounded-lg border border-[var(--line)] hover:border-[var(--acc)] hover:text-[var(--acc)] transition-colors",style:{background:x===M.text?"var(--acc)18":"transparent",borderColor:x===M.text?"var(--acc)":void 0,color:x===M.text?"var(--acc)":void 0},children:[M.icon," ",M.text]},ce))}),l.jsx("textarea",{className:"w-full bg-[var(--panel2)] rounded-lg p-3 text-sm border border-[var(--line)] focus:border-[var(--acc)] outline-none resize-none",rows:2,placeholder:"或自定义议题...",value:x,onChange:M=>L(M.target.value)})]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:["👑 皇帝发言","⚡ 天命降临","🎲 命运骰子","🔄 自动推进","📜 讨论记录"].map(M=>l.jsx("span",{className:"text-[10px] px-2 py-1 rounded-full border border-[var(--line)] text-[var(--muted)]",children:M},M))}),l.jsx("button",{onClick:je,disabled:c.size<2||!x.trim()||b,className:"w-full py-3 rounded-xl font-semibold text-sm transition-all border-0",style:{background:c.size>=2&&x.trim()?"linear-gradient(135deg, #6a9eff, #a07aff)":"var(--panel2)",color:c.size>=2&&x.trim()?"#fff":"var(--muted)",opacity:b?.6:1,cursor:c.size>=2&&x.trim()&&!b?"pointer":"not-allowed"},children:b?"召集中...":`🏛 开始朝议(${c.size}位上殿)`})]});const H=(T==null?void 0:T.officials)||[],ne=(T==null?void 0:T.messages)||[];return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2 bg-[var(--panel)] rounded-xl px-4 py-2 border border-[var(--line)]",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-bold",children:"🏛 朝堂议政"}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-[var(--acc)]20 text-[var(--acc)] border border-[var(--acc)]30",children:["第",(T==null?void 0:T.round)||0,"轮"]}),(T==null?void 0:T.phase)==="concluded"&&l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-green-900/40 text-green-400 border border-green-800",children:"已结束"})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{onClick:()=>A(!g),className:"text-xs px-2.5 py-1 rounded-lg border border-amber-600/40 text-amber-400 hover:bg-amber-900/20 transition",title:"天命降临 — 上帝视角干预",children:"⚡ 天命"}),l.jsxs("button",{onClick:v,disabled:oe||b,className:"text-xs px-2.5 py-1 rounded-lg border border-purple-600/40 text-purple-400 hover:bg-purple-900/20 transition",title:"命运骰子 — 随机事件",children:["🎲 ",oe?"...":"骰子"]}),l.jsx("button",{onClick:()=>d(!z),className:`text-xs px-2.5 py-1 rounded-lg border transition ${z?"border-green-600/40 text-green-400 bg-green-900/20":"border-[var(--line)] text-[var(--muted)] hover:text-[var(--text)]"}`,children:z?"⏸ 暂停":"▶ 自动"}),(T==null?void 0:T.phase)!=="concluded"&&l.jsx("button",{onClick:D,className:"text-xs px-2.5 py-1 rounded-lg border border-[var(--line)] text-[var(--muted)] hover:text-[var(--warn)] hover:border-[var(--warn)]40 transition",children:"📋 散朝"}),l.jsx("button",{onClick:de,className:"text-xs px-2 py-1 rounded-lg border border-red-900/40 text-red-400/70 hover:text-red-400 transition",children:"✕"})]})]}),g&&l.jsxs("div",{className:"bg-gradient-to-br from-amber-950/40 to-purple-950/30 rounded-xl p-4 border border-amber-700/30",style:{animation:"fadeIn .3s"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm font-bold text-amber-400",children:"⚡ 天命降临 — 上帝视角"}),l.jsx("button",{onClick:()=>A(!1),className:"text-xs text-[var(--muted)]",children:"✕"})]}),l.jsx("p",{className:"text-[10px] text-amber-300/60 mb-2",children:"降下天意改变讨论走向,所有官员将对此做出反应"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:P,onChange:M=>W(M.target.value),onKeyDown:M=>M.key==="Enter"&&U(),placeholder:"例如:突然发现预算多出一倍...",className:"flex-1 bg-black/30 rounded-lg px-3 py-1.5 text-sm border border-amber-800/40 outline-none focus:border-amber-600"}),l.jsx("button",{onClick:U,disabled:!P.trim(),className:"px-4 py-1.5 rounded-lg bg-gradient-to-r from-amber-600 to-purple-600 text-white text-xs font-semibold disabled:opacity-40",children:"降旨"})]})]}),me&&l.jsxs("div",{className:"bg-purple-950/40 rounded-lg px-3 py-2 border border-purple-700/30 text-xs text-purple-300 flex items-center gap-2",style:{animation:"fadeIn .3s"},children:[l.jsx("span",{className:"text-lg",children:"🎲"}),me]}),J&&l.jsx("div",{className:"fixed inset-0 pointer-events-none z-50",style:{background:"radial-gradient(circle, rgba(255,200,50,0.3), transparent 70%)",animation:"fadeOut .8s forwards"}}),l.jsxs("div",{className:"text-xs text-center text-[var(--muted)] py-1",children:["📜 ",(T==null?void 0:T.topic)||""]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[280px_1fr] gap-3",children:[l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl p-3 border border-[var(--line)] relative overflow-hidden min-h-[320px]",children:[l.jsx("div",{className:"text-center mb-2",children:l.jsxs("div",{className:"inline-block px-3 py-1 rounded-lg bg-gradient-to-b from-amber-800/40 to-amber-950/40 border border-amber-700/30",children:[l.jsx("span",{className:"text-lg",children:"👑"}),l.jsx("div",{className:"text-[10px] text-amber-400/80",children:"龙 椅"})]})}),l.jsxs("div",{className:"relative",style:{minHeight:250},children:[l.jsx("div",{className:"absolute left-0 top-0 text-[9px] text-[var(--muted)] opacity-50",children:"三省"}),l.jsx("div",{className:"absolute right-0 top-0 text-[9px] text-[var(--muted)] opacity-50",children:"六部"}),H.map(M=>{const ce=kp[M.id]||{x:50,y:50},ye=Xi[M.id]||"#6a9eff",Be=Ae===M.id,Ke=ie[M.id]||"neutral";return l.jsxs("div",{className:"absolute transition-all duration-500",style:{left:`${ce.x}%`,top:`${ce.y}%`,transform:"translate(-50%, -50%)"},children:[Be&&l.jsx("div",{className:"absolute -inset-2 rounded-full",style:{background:`radial-gradient(circle, ${ye}40, transparent)`,animation:"pulse 1s infinite"}}),l.jsxs("div",{className:"relative w-10 h-10 rounded-full flex items-center justify-center text-lg border-2 transition-all",style:{borderColor:Be?ye:ye+"40",background:Be?ye+"30":ye+"10",transform:Be?"scale(1.2)":"scale(1)",boxShadow:Be?`0 0 16px ${ye}50`:"none"},children:[M.emoji,Ql[Ke]&&l.jsx("span",{className:"absolute -top-1 -right-1 text-xs",style:{animation:"bounceIn .3s"},children:Ql[Ke]})]}),l.jsx("div",{className:"text-[9px] text-center mt-0.5 whitespace-nowrap",style:{color:Be?ye:"var(--muted)"},children:M.name})]},M.id)})]})]}),l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl border border-[var(--line)] flex flex-col",style:{maxHeight:500},children:[l.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",style:{minHeight:200},children:[ne.map((M,ce)=>l.jsx(Sp,{msg:M,officials:H},ce)),b&&l.jsx("div",{className:"text-xs text-[var(--muted)] text-center py-2",style:{animation:"pulse 1.5s infinite"},children:"🏛 群臣正在思考..."}),l.jsx("div",{ref:re})]}),(T==null?void 0:T.phase)!=="concluded"&&l.jsxs("div",{className:"border-t border-[var(--line)] p-2 flex gap-2",children:[l.jsx("input",{value:m,onChange:M=>R(M.target.value),onKeyDown:M=>M.key==="Enter"&&K(),placeholder:"朕有话说...",className:"flex-1 bg-[var(--panel2)] rounded-lg px-3 py-1.5 text-sm border border-[var(--line)] outline-none focus:border-amber-600"}),l.jsx("button",{onClick:K,disabled:!m.trim()||b,className:"px-4 py-1.5 rounded-lg text-xs font-semibold border-0 disabled:opacity-40",style:{background:m.trim()?"linear-gradient(135deg, #e8a040, #f5c842)":"var(--panel2)",color:m.trim()?"#000":"var(--muted)"},children:"👑 发言"}),l.jsx("button",{onClick:()=>E(),disabled:b,className:"px-3 py-1.5 rounded-lg text-xs border border-[var(--acc)]40 text-[var(--acc)] hover:bg-[var(--acc)]10 disabled:opacity-40 transition",children:"▶ 下一轮"})]})]})]})]})}function Sp({msg:o,officials:f}){var x;const c=Xi[o.official_id||""]||"#6a9eff",y=f.find(L=>L.id===o.official_id);return o.type==="system"?l.jsx("div",{className:"text-center text-[10px] text-[var(--muted)] py-1 border-b border-[var(--line)] border-dashed",children:o.content}):o.type==="scene_note"?l.jsxs("div",{className:"text-center text-[10px] text-purple-400/80 py-1 italic",children:["✦ ",o.content," ✦"]}):o.type==="emperor"?l.jsx("div",{className:"flex justify-end",children:l.jsxs("div",{className:"max-w-[80%] bg-gradient-to-br from-amber-900/40 to-amber-800/20 rounded-xl px-3 py-2 border border-amber-700/30",children:[l.jsx("div",{className:"text-[10px] text-amber-400 mb-0.5",children:"👑 皇帝"}),l.jsx("div",{className:"text-sm",children:o.content})]})}):o.type==="decree"?l.jsx("div",{className:"text-center py-2",children:l.jsxs("div",{className:"inline-block bg-gradient-to-r from-amber-900/30 via-purple-900/30 to-amber-900/30 rounded-lg px-4 py-2 border border-amber-600/30",children:[l.jsx("div",{className:"text-xs text-amber-400 font-bold",children:"⚡ 天命降临"}),l.jsx("div",{className:"text-sm mt-0.5",children:o.content})]})}):l.jsxs("div",{className:"flex gap-2 items-start",style:{animation:"fadeIn .4s"},children:[l.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-sm flex-shrink-0 border",style:{borderColor:c+"60",background:c+"15"},children:(y==null?void 0:y.emoji)||"💬"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[l.jsx("span",{className:"text-[11px] font-semibold",style:{color:c},children:o.official_name||"官员"}),o.emotion&&Ql[o.emotion]&&l.jsx("span",{className:"text-xs",children:Ql[o.emotion]})]}),l.jsx("div",{className:"text-sm leading-relaxed",children:(x=o.content)==null?void 0:x.split(/(\*[^*]+\*)/).map((L,T)=>L.startsWith("*")&&L.endsWith("*")?l.jsx("span",{className:"text-[var(--muted)] italic text-xs",children:L.slice(1,-1)},T):l.jsx("span",{children:L},T))})]})]})}function wp(){const o=ee(d=>d.activeTab),f=ee(d=>d.setActiveTab),c=ee(d=>d.liveStatus),y=ee(d=>d.countdown),x=ee(d=>d.loadAll);V.useEffect(()=>(Uf(),()=>Hf()),[]);const L=(c==null?void 0:c.tasks)||[],T=L.filter(ln),_=T.filter(d=>!Vl(d)),b=c==null?void 0:c.syncStatus,C=b==null?void 0:b.ok,z=d=>d==="edicts"?String(_.length):d==="sessions"?String(L.filter(w=>!ln(w)).length):d==="memorials"?String(T.filter(w=>["Done","Cancelled"].includes(w.state)).length):d==="monitor"?L.filter(m=>ln(m)&&m.state==="Doing").length+"活跃":"";return l.jsxs("div",{className:"wrap",children:[l.jsxs("div",{className:"hdr",children:[l.jsxs("div",{children:[l.jsx("div",{className:"logo",children:"三省六部 · 总控台"}),l.jsx("div",{className:"sub-text",children:"OpenClaw Sansheng-Liubu Dashboard"})]}),l.jsxs("div",{className:"hdr-r",children:[l.jsx("span",{className:`chip ${C?"ok":C===!1?"err":""}`,children:C?"✅ 同步正常":C===!1?"❌ 服务器未启动":"⏳ 连接中…"}),l.jsxs("span",{className:"chip",children:[_.length," 道旨意"]}),l.jsx("button",{className:"btn-refresh",onClick:()=>x(),children:"⟳ 刷新"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["⟳ ",y,"s"]})]})]}),l.jsx("div",{className:"tabs",children:$f.map(d=>l.jsxs("div",{className:`tab ${o===d.key?"active":""}`,onClick:()=>f(d.key),children:[d.icon," ",d.label,z(d.key)&&l.jsx("span",{className:"tbadge",children:z(d.key)})]},d.key))}),o==="edicts"&&l.jsx(Gf,{}),o==="court"&&l.jsx(jp,{}),o==="monitor"&&l.jsx(Yf,{}),o==="officials"&&l.jsx(Zf,{}),o==="models"&&l.jsx(ep,{}),o==="skills"&&l.jsx(np,{}),o==="sessions"&&l.jsx(sp,{}),o==="memorials"&&l.jsx(op,{}),o==="templates"&&l.jsx(cp,{}),o==="morning"&&l.jsx(up,{}),l.jsx(mp,{}),l.jsx(yp,{}),l.jsx(xp,{})]})}wf.createRoot(document.getElementById("root")).render(l.jsx(cu.StrictMode,{children:l.jsx(wp,{})})); +请输入说明(可留空):`);if(G!==null)try{const U=await de.advanceState(d.id,G||"");U.ok?(g(`⏩ ${U.message}`,"ok"),v(),O()):g(U.error||"推进失败","err")}catch{g("服务器连接失败","err")}},oe=async _=>{if(_==="scan"){try{const I=await de.schedulerScan(180);I.ok?g(`🔍 扫描完成:${I.count||0} 个动作`,"ok"):g(I.error||"扫描失败","err"),j()}catch{g("服务器连接失败","err")}return}const U=prompt(`请输入${{retry:"重试",escalate:"升级",rollback:"回滚"}[_]}原因(可留空):`);if(U===null)return;const h={retry:de.schedulerRetry,escalate:de.schedulerEscalate,rollback:de.schedulerRollback};try{const I=await h[_](d.id,U);I.ok?g(I.message||"操作成功","ok"):g(I.error||"操作失败","err"),j(),v()}catch{g("服务器连接失败","err")}},ke=()=>{const _=prompt("请输入叫停原因(可留空):");_!==null&&pe("stop",_)},le=()=>{if(!confirm(`确定要取消 ${d.id} 吗?`))return;const _=prompt("请输入取消原因(可留空):");_!==null&&pe("cancel",_)},te=z==null?void 0:z.scheduler,Ne=(z==null?void 0:z.stalledSec)||0;return l.jsx("div",{className:"modal-bg open",onClick:O,children:l.jsxs("div",{className:"modal",onClick:_=>_.stopPropagation(),children:[l.jsx("button",{className:"modal-close",onClick:O,children:"✕"}),l.jsxs("div",{className:"modal-body",children:[l.jsx("div",{className:"modal-id",children:d.id}),l.jsx("div",{className:"modal-title",children:d.title||"(无标题)"}),M&&l.jsxs("div",{className:"cur-stage",children:[l.jsx("div",{className:"cs-icon",children:M.icon}),l.jsxs("div",{className:"cs-info",children:[l.jsx("div",{className:"cs-dept",style:{color:Ul(M.dept)},children:M.dept}),l.jsxs("div",{className:"cs-action",children:["当前阶段:",M.action]})]}),l.jsx("span",{className:`hb ${x.status} cs-hb`,children:x.label})]}),l.jsx("div",{className:"m-pipe",children:S.map((_,G)=>l.jsxs("div",{className:"mp-stage",children:[l.jsxs("div",{className:`mp-node ${_.status}`,children:[_.status==="done"&&l.jsx("div",{className:"mp-done-tick",children:"✓"}),l.jsx("div",{className:"mp-icon",children:_.icon}),l.jsx("div",{className:"mp-dept",style:_.status==="active"?{color:"var(--acc)"}:_.status==="done"?{color:"var(--ok)"}:{},children:_.dept}),l.jsx("div",{className:"mp-action",children:_.action})]}),Gpe("resume","恢复执行"),children:"▶️ 恢复执行"}),["Review","Menxia"].includes(d.state)&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:"btn-action",style:{background:"#2ecc8a22",color:"#2ecc8a",border:"1px solid #2ecc8a44"},onClick:()=>Ae("approve"),children:"✅ 准奏"}),l.jsx("button",{className:"btn-action",style:{background:"#ff527022",color:"#ff5270",border:"1px solid #ff527044"},onClick:()=>Ae("reject"),children:"🚫 封驳"})]}),["Pending","Taizi","Zhongshu","Menxia","Assigned","Doing","Review","Next"].includes(d.state)&&l.jsx("button",{className:"btn-action",style:{background:"#7c5cfc18",color:"#7c5cfc",border:"1px solid #7c5cfc44"},onClick:Z,children:"⏩ 推进到下一步"})]}),l.jsxs("div",{className:"sched-section",children:[l.jsxs("div",{className:"sched-head",children:[l.jsx("span",{className:"sched-title",children:"🧭 太子调度"}),l.jsx("span",{className:"sched-status",children:te?`${te.enabled===!1?"已禁用":"运行中"} · 阈值 ${te.stallThresholdSec||180}s`:"加载中..."})]}),l.jsxs("div",{className:"sched-grid",children:[l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"停滞时长"}),l.jsx("div",{className:"v",children:mp(Ne)})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"重试次数"}),l.jsx("div",{className:"v",children:(te==null?void 0:te.retryCount)||0})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"升级级别"}),l.jsx("div",{className:"v",children:te!=null&&te.escalationLevel?te.escalationLevel===1?"门下省":"尚书省":"无"})]}),l.jsxs("div",{className:"sched-kpi",children:[l.jsx("div",{className:"k",children:"派发状态"}),l.jsx("div",{className:"v",children:(te==null?void 0:te.lastDispatchStatus)||"idle"})]})]}),te&&l.jsxs("div",{className:"sched-line",children:[te.lastProgressAt&&l.jsxs("span",{children:["最近进展 ",(te.lastProgressAt||"").replace("T"," ").substring(0,19)]}),te.lastDispatchAt&&l.jsxs("span",{children:["最近派发 ",(te.lastDispatchAt||"").replace("T"," ").substring(0,19)]}),l.jsxs("span",{children:["自动回滚 ",te.autoRollback===!1?"关闭":"开启"]}),te.lastDispatchAgent&&l.jsxs("span",{children:["目标 ",te.lastDispatchAgent]})]}),l.jsxs("div",{className:"sched-actions",children:[l.jsx("button",{className:"sched-btn",onClick:()=>oe("retry"),children:"🔁 重试派发"}),l.jsx("button",{className:"sched-btn warn",onClick:()=>oe("escalate"),children:"📣 升级协调"}),l.jsx("button",{className:"sched-btn danger",onClick:()=>oe("rollback"),children:"↩️ 回滚稳定点"}),l.jsx("button",{className:"sched-btn",onClick:()=>oe("scan"),children:"🔍 立即扫描"})]})]}),re>0&&l.jsx(vp,{todos:V,todoDone:R,todoTotal:re}),l.jsx("div",{className:"m-section",children:l.jsxs("div",{className:"m-rows",children:[l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"状态"}),l.jsxs("div",{className:"mr-val",children:[l.jsx("span",{className:`tag st-${d.state}`,children:Ji(d)}),(d.review_round||0)>0&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)",marginLeft:8},children:["共磋商 ",d.review_round," 轮"]})]})]}),l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"执行部门"}),l.jsx("div",{className:"mr-val",children:l.jsx("span",{className:`tag dt-${(d.org||"").replace(/\s/g,"")}`,children:d.org||"—"})})]}),d.eta&&d.eta!=="-"&&l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",children:"预计完成"}),l.jsx("div",{className:"mr-val",children:d.eta})]}),d.block&&d.block!=="无"&&d.block!=="-"&&l.jsxs("div",{className:"m-row",children:[l.jsx("div",{className:"mr-label",style:{color:"var(--danger)"},children:"阻塞项"}),l.jsx("div",{className:"mr-val",style:{color:"var(--danger)"},children:d.block})]}),d.now&&d.now!=="-"&&l.jsxs("div",{className:"m-row",style:{gridColumn:"1/-1"},children:[l.jsx("div",{className:"mr-label",children:"当前进展"}),l.jsx("div",{className:"mr-val",style:{fontWeight:400,fontSize:12},children:d.now})]}),d.ac&&l.jsxs("div",{className:"m-row",style:{gridColumn:"1/-1"},children:[l.jsx("div",{className:"mr-label",children:"验收标准"}),l.jsx("div",{className:"mr-val",style:{fontWeight:400,fontSize:12},children:d.ac})]})]})}),A.length>0&&l.jsxs("div",{className:"m-section",children:[l.jsxs("div",{className:"m-sec-label",children:["流转日志(",A.length," 条)"]}),l.jsx("div",{className:"fl-timeline",children:A.map((_,G)=>{const U=Ul(_.from||"");return l.jsxs("div",{className:"fl-item",children:[l.jsx("div",{className:"fl-time",children:_.at?_.at.substring(11,16):""}),l.jsx("div",{className:"fl-dot",style:{background:U}}),l.jsxs("div",{className:"fl-content",children:[l.jsxs("div",{className:"fl-who",children:[l.jsx("span",{className:"from",style:{color:U},children:_.from}),l.jsx("span",{style:{color:"var(--muted)"},children:" → "}),l.jsx("span",{className:"to",style:{color:Ul(_.to||"")},children:_.to})]}),l.jsx("div",{className:"fl-rem",children:_.remark})]})]},G)})})]}),d.output&&d.output!=="-"&&d.output!==""&&l.jsxs("div",{className:"m-section",children:[l.jsx("div",{className:"m-sec-label",children:"产出物"}),l.jsx("code",{children:d.output})]}),l.jsx(gp,{data:P,isDone:["Done","Cancelled"].includes(d.state),logRef:b})]})]})})}function vp({todos:o,todoDone:f,todoTotal:c}){return l.jsxs("div",{className:"todo-section",children:[l.jsxs("div",{className:"todo-header",children:[l.jsxs("div",{className:"m-sec-label",style:{marginBottom:0,border:"none",padding:0},children:["子任务清单(",f,"/",c,")"]}),l.jsxs("div",{className:"todo-progress",children:[l.jsx("div",{className:"todo-bar",children:l.jsx("div",{className:"todo-bar-fill",style:{width:`${Math.round(f/c*100)}%`}})}),l.jsxs("span",{children:[Math.round(f/c*100),"%"]})]})]}),l.jsx("div",{className:"todo-list",children:o.map(v=>{const g=v.status==="completed"?"✅":v.status==="in-progress"?"🔄":"⬜",P=v.status==="completed"?"已完成":v.status==="in-progress"?"进行中":"待开始",L=v.status==="completed"?"s-done":v.status==="in-progress"?"s-progress":"s-notstarted",z=v.status==="completed"?"done":"";return l.jsxs("div",{className:`todo-item ${z}`,children:[l.jsxs("div",{className:"t-row",children:[l.jsx("span",{className:"t-icon",children:g}),l.jsxs("span",{className:"t-id",children:["#",v.id]}),l.jsx("span",{className:"t-title",children:v.title}),l.jsx("span",{className:`t-status ${L}`,children:P})]}),v.detail&&l.jsx("div",{className:"todo-detail",children:v.detail})]},v.id)})})]})}function gp({data:o,isDone:f,logRef:c}){if(!o)return null;const v=o.activity||[],g=(()=>{if(!v.length)return!1;const O=v[v.length-1];if(!O.at)return!1;const S=typeof O.at=="number"?O.at:new Date(O.at).getTime();return Date.now()-S<3e5})(),P=[];o.agentLabel&&P.push(o.agentLabel),o.relatedAgents&&o.relatedAgents.length>1&&P.push(`${o.relatedAgents.length}个 Agent`),o.lastActive&&P.push(`最后活跃: ${o.lastActive}`);const L=o.phaseDurations||[],z=Math.max(...L.map(O=>O.durationSec||1),1),T={皇上:"#eab308",太子:"#f97316",中书省:"#3b82f6",门下省:"#8b5cf6",尚书省:"#10b981",六部:"#06b6d4",礼部:"#ec4899",户部:"#f59e0b",兵部:"#ef4444",刑部:"#6366f1",工部:"#14b8a6",吏部:"#d946ef"},E=o.todosSummary,b=o.resourceSummary,d=v.filter(O=>O.kind==="flow"),N=v.filter(O=>O.kind!=="flow"),j=new Map;return N.forEach(O=>{const S=O.agent||"unknown";j.has(S)||j.set(S,[]),j.get(S).push(O)}),l.jsxs("div",{className:"la-section",children:[l.jsxs("div",{className:"la-header",children:[l.jsxs("span",{className:"la-title",children:[l.jsx("span",{className:`la-dot${g?"":" idle"}`}),f?"执行回顾":"实时动态"]}),l.jsx("span",{className:"la-agent",children:P.join(" · ")||"加载中..."})]}),L.length>0&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"⏱ 阶段耗时"}),o.totalDuration&&l.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--muted)"},children:["总耗时 ",o.totalDuration]})]}),L.map((O,S)=>{const M=Math.max(5,Math.round((O.durationSec||1)/z*100)),x=T[O.phase]||"#6b7280";return l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,margin:"2px 0",fontSize:11},children:[l.jsx("span",{style:{minWidth:48,color:"var(--muted)",textAlign:"right"},children:O.phase}),l.jsx("div",{style:{flex:1,height:14,background:"var(--panel)",borderRadius:3,overflow:"hidden"},children:l.jsx("div",{style:{width:`${M}%`,height:"100%",background:x,borderRadius:3,opacity:O.ongoing?.6:.85}})}),l.jsxs("span",{style:{minWidth:60,fontSize:10,color:"var(--muted)"},children:[O.durationText,O.ongoing&&l.jsx("span",{style:{fontSize:9,color:"#60a5fa"},children:" ●进行中"})]})]},S)})]}),E&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"📊 执行进度"}),l.jsxs("span",{style:{fontSize:20,fontWeight:700,color:E.percent>=100?"#22c55e":E.percent>=50?"#60a5fa":"var(--text)"},children:[E.percent,"%"]}),l.jsxs("span",{style:{fontSize:10,color:"var(--muted)"},children:["✅",E.completed," 🔄",E.inProgress," ⬜",E.notStarted," / 共",E.total,"项"]})]}),l.jsxs("div",{style:{height:8,background:"var(--panel)",borderRadius:4,overflow:"hidden",display:"flex"},children:[l.jsx("div",{style:{width:`${E.total?E.completed/E.total*100:0}%`,background:"#22c55e",transition:"width .3s"}}),l.jsx("div",{style:{width:`${E.total?E.inProgress/E.total*100:0}%`,background:"#3b82f6",transition:"width .3s"}})]})]}),b&&(b.totalTokens||b.totalCost)&&l.jsxs("div",{style:{padding:"4px 0 8px",borderBottom:"1px solid var(--line)",display:"flex",gap:12,alignItems:"center"},children:[l.jsx("span",{style:{fontSize:11,fontWeight:600},children:"📈 资源消耗"}),b.totalTokens!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["🔢 ",b.totalTokens.toLocaleString()," tokens"]}),b.totalCost!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["💰 $",b.totalCost.toFixed(4)]}),b.totalElapsedSec!=null&&l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["⏳ ",b.totalElapsedSec>=60?`${Math.floor(b.totalElapsedSec/60)}分`:"",b.totalElapsedSec%60,"秒"]})]}),l.jsxs("div",{className:"la-log",ref:c,children:[d.length>0&&l.jsx("div",{className:"la-flow-wrap",children:d.map((O,S)=>l.jsxs("div",{className:"la-entry la-tool",children:[l.jsx("span",{className:"la-icon",children:"📋"}),l.jsxs("span",{className:"la-body",children:[l.jsx("b",{children:O.from})," → ",l.jsx("b",{children:O.to})," ",O.remark||""]}),l.jsx("span",{className:"la-time",children:Yi(O.at)})]},`flow-${S}`))}),j.size>0?l.jsx("div",{className:"la-groups",children:Array.from(j.entries()).map(([O,S])=>{const M=vu[O]||O||"未标识",x=S[S.length-1],A=x!=null&&x.at?Yi(x.at):"--:--:--";return l.jsxs("div",{className:"la-group",children:[l.jsxs("div",{className:"la-group-hd",children:[l.jsx("span",{className:"name",children:M}),l.jsxs("span",{children:["最近更新 ",A]})]}),l.jsx("div",{className:"la-group-bd",children:S.map((V,R)=>l.jsx(yp,{entry:V},R))})]},O)})}):!d.length&&l.jsx("div",{className:"la-empty",children:o.message||o.error||"Agent 尚未上报进展(等待 Agent 调用 progress 命令)"})]})]})}function yp({entry:o}){var v,g,P;const f=Yi(o.at),c=o.agent?l.jsx("span",{style:{fontSize:9,color:"var(--muted)",background:"var(--panel)",padding:"1px 4px",borderRadius:3,marginRight:4},children:vu[o.agent]||o.agent}):null;if(o.kind==="progress")return l.jsxs("div",{className:"la-entry la-assistant",children:[l.jsx("span",{className:"la-icon",children:"🔄"}),l.jsxs("span",{className:"la-body",children:[c,l.jsx("b",{children:"当前进展:"}),o.text]}),l.jsx("span",{className:"la-time",children:f})]});if(o.kind==="todos"){const L=o.items||[],z=new Map;return o.diff&&((o.diff.changed||[]).forEach(T=>z.set(T.id,{type:"changed",from:T.from,to:T.to})),(o.diff.added||[]).forEach(T=>z.set(T.id,{type:"added"}))),l.jsxs("div",{className:"la-entry",style:{flexDirection:"column",alignItems:"flex-start",gap:2},children:[l.jsxs("div",{style:{fontSize:11,color:"var(--muted)",marginBottom:2},children:[c,"📝 执行计划"]}),L.map(T=>{const E=T.status==="completed"?"✅":T.status==="in-progress"?"🔄":"⬜",b=z.get(String(T.id)),d=T.status==="completed"?{opacity:.5,textDecoration:"line-through"}:T.status==="in-progress"?{color:"#60a5fa",fontWeight:"bold"}:{};return l.jsxs("div",{style:d,children:[E," ",T.title,b&&b.type==="changed"&&b.to==="completed"&&l.jsx("span",{style:{color:"#22c55e",fontSize:9,marginLeft:4},children:"✨刚完成"}),b&&b.type==="changed"&&b.to!=="completed"&&l.jsxs("span",{style:{color:"#f59e0b",fontSize:9,marginLeft:4},children:["↻",b.from,"→",b.to]}),b&&b.type==="added"&&l.jsx("span",{style:{color:"#3b82f6",fontSize:9,marginLeft:4},children:"🆕新增"})]},T.id)}),(g=(v=o.diff)==null?void 0:v.removed)==null?void 0:g.map(T=>l.jsxs("div",{style:{opacity:.4,textDecoration:"line-through"},children:["🗑 ",T.title]},T.id))]})}if(o.kind==="assistant")return l.jsxs(l.Fragment,{children:[o.thinking&&l.jsxs("div",{className:"la-entry la-thinking",children:[l.jsx("span",{className:"la-icon",children:"💭"}),l.jsxs("span",{className:"la-body",children:[c,o.thinking]}),l.jsx("span",{className:"la-time",children:f})]}),(P=o.tools)==null?void 0:P.map((L,z)=>l.jsxs("div",{className:"la-entry la-tool",children:[l.jsx("span",{className:"la-icon",children:"🔧"}),l.jsxs("span",{className:"la-body",children:[c,l.jsx("span",{className:"la-tool-name",children:L.name}),l.jsx("span",{className:"la-trunc",children:L.input_preview||""})]}),l.jsx("span",{className:"la-time",children:f})]},z)),o.text&&l.jsxs("div",{className:"la-entry la-assistant",children:[l.jsx("span",{className:"la-icon",children:"🤖"}),l.jsxs("span",{className:"la-body",children:[c,o.text]}),l.jsx("span",{className:"la-time",children:f})]})]});if(o.kind==="tool_result"){const L=o.exitCode===0||o.exitCode===null||o.exitCode===void 0;return l.jsxs("div",{className:`la-entry la-tool-result ${L?"ok":"err"}`,children:[l.jsx("span",{className:"la-icon",children:L?"✅":"❌"}),l.jsxs("span",{className:"la-body",children:[c,l.jsx("span",{className:"la-tool-name",children:o.tool||""}),o.output?o.output.substring(0,150):""]}),l.jsx("span",{className:"la-time",children:f})]})}return o.kind==="user"?l.jsxs("div",{className:"la-entry la-user",children:[l.jsx("span",{className:"la-icon",children:"📥"}),l.jsxs("span",{className:"la-body",children:[c,o.text||""]}),l.jsx("span",{className:"la-time",children:f})]}):null}function xp(){const o=ee(f=>f.toasts);return o.length?l.jsx("div",{className:"toaster",children:o.map(f=>l.jsx("div",{className:`toast ${f.type}`,children:f.msg},f.id))}):null}function kp(){const o=ee(O=>O.liveStatus),[f,c]=Q.useState(!1),[v,g]=Q.useState(!1);Q.useEffect(()=>{const O=localStorage.getItem("openclaw_court_date"),S=new Date().toISOString().substring(0,10);if(!JSON.parse(localStorage.getItem("openclaw_court_pref")||'{"enabled":true}').enabled||O===S)return;localStorage.setItem("openclaw_court_date",S),c(!0);const x=setTimeout(()=>P(),3500);return()=>clearTimeout(x)},[]);const P=()=>{g(!0),setTimeout(()=>c(!1),500)};if(!f)return null;const z=((o==null?void 0:o.tasks)||[]).filter(ln),T=z.filter(O=>!["Done","Cancelled"].includes(O.state)).length,E=z.filter(O=>O.state==="Done").length,b=z.filter(O=>O.state!=="Done"&&O.state!=="Cancelled"&&O.eta&&new Date(O.eta.replace(" ","T"))0&&` · ⚠ 超期 ${b} 件`]}),l.jsx("div",{className:"crm-date in",children:j}),l.jsx("div",{className:"crm-skip",children:"点击任意处跳过"})]})}const Xi={taizi:"#e8a040",zhongshu:"#a07aff",menxia:"#6a9eff",shangshu:"#2ecc8a",libu:"#f5c842",hubu:"#ff9a6a",bingbu:"#ff5270",xingbu:"#cc4444",gongbu:"#44aaff",libu_hr:"#9b59b6"},Ql={neutral:"",confident:"😏",worried:"😟",angry:"😤",thinking:"🤔",amused:"😄",happy:"😊"},jp={zhongshu:{x:15,y:25},menxia:{x:15,y:45},shangshu:{x:15,y:65},libu:{x:85,y:20},hubu:{x:85,y:35},bingbu:{x:85,y:50},xingbu:{x:85,y:65},gongbu:{x:85,y:80},taizi:{x:50,y:20},libu_hr:{x:50,y:80}};function Sp(){var ve;const[o,f]=Q.useState("setup"),[c,v]=Q.useState(new Set),[g,P]=Q.useState(""),[L,z]=Q.useState(null),[T,E]=Q.useState(!1),[b,d]=Q.useState(!1),N=Q.useRef(!1),[j,O]=Q.useState(""),[S,M]=Q.useState(!1),[x,A]=Q.useState(""),[V,R]=Q.useState(!1),[re,ue]=Q.useState(!1),[me,pe]=Q.useState(null),[Ae,Z]=Q.useState(null),[oe,ke]=Q.useState({}),le=Q.useRef(null),te=ee(D=>D.toast),Ne=ee(D=>D.liveStatus);Q.useEffect(()=>{var D;(D=le.current)==null||D.scrollIntoView({behavior:"smooth"})},[(ve=L==null?void 0:L.messages)==null?void 0:ve.length]),Q.useEffect(()=>{N.current=b},[b]),Q.useEffect(()=>{if(!b||!L||T)return;const D=setInterval(()=>{N.current&&!T&&_()},5e3);return()=>clearInterval(D)},[b,L,T]);const Ee=D=>{v(ce=>{const ye=new Set(ce);return ye.has(D)?ye.delete(D):ye.size<8&&ye.add(D),ye})},je=async()=>{if(!(!g.trim()||c.size<2||T)){E(!0);try{const D=await de.courtDiscussStart(g,Array.from(c));if(!D.ok)throw new Error(D.error||"启动失败");z(D),f("session")}catch(D){te(D.message||"启动失败","err")}finally{E(!1)}}},_=Q.useCallback(async(D,ce)=>{if(!(!L||T)){E(!0);try{const ye=await de.courtDiscussAdvance(L.session_id,D,ce);if(!ye.ok)throw new Error(ye.error||"推进失败");z(Ke=>{if(!Ke)return Ke;const et=[];D&&et.push({type:"emperor",content:D,timestamp:Date.now()/1e3}),ce&&et.push({type:"decree",content:ce,timestamp:Date.now()/1e3});const sn=(ye.new_messages||[]).map(Ct=>({type:"official",official_id:Ct.official_id,official_name:Ct.name,content:Ct.content,emotion:Ct.emotion,action:Ct.action,timestamp:Date.now()/1e3}));return ye.scene_note&&et.push({type:"scene_note",content:ye.scene_note,timestamp:Date.now()/1e3}),{...Ke,round:ye.round??Ke.round+1,messages:[...Ke.messages,...et,...sn]}});const Be=ye.new_messages||[];if(Be.length>0){const Ke={};let et=0;const sn=()=>{et({...Ct,...Ke}))}}catch{}finally{E(!1)}}},[L,T]),G=()=>{const D=j.trim();D&&(O(""),_(D))},U=()=>{const D=x.trim();D&&(A(""),M(!1),R(!0),setTimeout(()=>R(!1),800),_(void 0,D))},h=async()=>{if(T||re)return;ue(!0),pe(null);let D=0;const ce=setInterval(async()=>{if(D++,pe("🎲 命运轮转中..."),D>=6){clearInterval(ce);try{const Be=(await de.courtDiscussFate()).event||"边疆急报传来";pe(Be),ue(!1),_(void 0,`【命运骰子】${Be}`)}catch{pe("命运之力暂时无法触及"),ue(!1)}}},200)},I=async()=>{if(L){E(!0);try{const D=await de.courtDiscussConclude(L.session_id);D.summary&&z(ce=>ce&&{...ce,phase:"concluded",messages:[...ce.messages,{type:"system",content:`📋 朝堂议政结束 — ${D.summary}`,timestamp:Date.now()/1e3}]}),d(!1)}catch{te("结束失败","err")}finally{E(!1)}}},fe=()=>{L&&de.courtDiscussDestroy(L.session_id).catch(()=>{}),f("setup"),z(null),d(!1),ke({}),Z(null),pe(null)},y=[...((Ne==null?void 0:Ne.tasks)||[]).filter(D=>/^JJC-/i.test(D.id)&&!["Done","Cancelled"].includes(D.state)).slice(0,3).map(D=>({text:`讨论旨意 ${D.id}:${D.title}`,taskId:D.id,icon:"📜"})),{text:"讨论系统架构优化方案",taskId:"",icon:"🏗️"},{text:"评估当前项目进展和风险",taskId:"",icon:"📊"},{text:"制定下周工作计划",taskId:"",icon:"📋"},{text:"紧急问题:线上Bug排查方案",taskId:"",icon:"🚨"}];if(o==="setup")return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"text-center py-4",children:[l.jsx("h2",{className:"text-xl font-bold bg-gradient-to-r from-amber-400 to-purple-400 bg-clip-text text-transparent",children:"🏛 朝堂议政"}),l.jsx("p",{className:"text-xs text-[var(--muted)] mt-1",children:"择臣上殿,围绕议题展开讨论 · 陛下可随时发言或降下天意改变走向"})]}),l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl p-4 border border-[var(--line)]",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[l.jsx("span",{className:"text-sm font-semibold",children:"👔 选择参朝官员"}),l.jsxs("span",{className:"text-xs text-[var(--muted)]",children:["(",c.size,"/8,至少2位)"]})]}),l.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-2",children:fu.map(D=>{const ce=c.has(D.id),ye=Xi[D.id]||"#6a9eff";return l.jsx("button",{onClick:()=>Ee(D.id),className:"p-2.5 rounded-lg border transition-all text-left",style:{borderColor:ce?ye+"80":"var(--line)",background:ce?ye+"15":"var(--panel2)",boxShadow:ce?`0 0 12px ${ye}20`:"none"},children:l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("span",{className:"text-lg",children:D.emoji}),l.jsxs("div",{children:[l.jsx("div",{className:"text-xs font-semibold",style:{color:ce?ye:"var(--text)"},children:D.label}),l.jsx("div",{className:"text-[10px] text-[var(--muted)]",children:D.role})]}),ce&&l.jsx("span",{className:"ml-auto w-4 h-4 rounded-full flex items-center justify-center text-[10px] text-white",style:{background:ye},children:"✓"})]})},D.id)})})]}),l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl p-4 border border-[var(--line)]",children:[l.jsx("div",{className:"text-sm font-semibold mb-2",children:"📜 设定议题"}),y.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1.5 mb-3",children:y.map((D,ce)=>l.jsxs("button",{onClick:()=>P(D.text),className:"text-xs px-2.5 py-1.5 rounded-lg border border-[var(--line)] hover:border-[var(--acc)] hover:text-[var(--acc)] transition-colors",style:{background:g===D.text?"var(--acc)18":"transparent",borderColor:g===D.text?"var(--acc)":void 0,color:g===D.text?"var(--acc)":void 0},children:[D.icon," ",D.text]},ce))}),l.jsx("textarea",{className:"w-full bg-[var(--panel2)] rounded-lg p-3 text-sm border border-[var(--line)] focus:border-[var(--acc)] outline-none resize-none",rows:2,placeholder:"或自定义议题...",value:g,onChange:D=>P(D.target.value)})]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:["👑 皇帝发言","⚡ 天命降临","🎲 命运骰子","🔄 自动推进","📜 讨论记录"].map(D=>l.jsx("span",{className:"text-[10px] px-2 py-1 rounded-full border border-[var(--line)] text-[var(--muted)]",children:D},D))}),l.jsx("button",{onClick:je,disabled:c.size<2||!g.trim()||T,className:"w-full py-3 rounded-xl font-semibold text-sm transition-all border-0",style:{background:c.size>=2&&g.trim()?"linear-gradient(135deg, #6a9eff, #a07aff)":"var(--panel2)",color:c.size>=2&&g.trim()?"#fff":"var(--muted)",opacity:T?.6:1,cursor:c.size>=2&&g.trim()&&!T?"pointer":"not-allowed"},children:T?"召集中...":`🏛 开始朝议(${c.size}位上殿)`})]});const H=(L==null?void 0:L.officials)||[],ne=(L==null?void 0:L.messages)||[];return l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2 bg-[var(--panel)] rounded-xl px-4 py-2 border border-[var(--line)]",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm font-bold",children:"🏛 朝堂议政"}),l.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-[var(--acc)]20 text-[var(--acc)] border border-[var(--acc)]30",children:["第",(L==null?void 0:L.round)||0,"轮"]}),(L==null?void 0:L.phase)==="concluded"&&l.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-green-900/40 text-green-400 border border-green-800",children:"已结束"})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{onClick:()=>M(!S),className:"text-xs px-2.5 py-1 rounded-lg border border-amber-600/40 text-amber-400 hover:bg-amber-900/20 transition",title:"天命降临 — 上帝视角干预",children:"⚡ 天命"}),l.jsxs("button",{onClick:h,disabled:re||T,className:"text-xs px-2.5 py-1 rounded-lg border border-purple-600/40 text-purple-400 hover:bg-purple-900/20 transition",title:"命运骰子 — 随机事件",children:["🎲 ",re?"...":"骰子"]}),l.jsx("button",{onClick:()=>d(!b),className:`text-xs px-2.5 py-1 rounded-lg border transition ${b?"border-green-600/40 text-green-400 bg-green-900/20":"border-[var(--line)] text-[var(--muted)] hover:text-[var(--text)]"}`,children:b?"⏸ 暂停":"▶ 自动"}),(L==null?void 0:L.phase)!=="concluded"&&l.jsx("button",{onClick:I,className:"text-xs px-2.5 py-1 rounded-lg border border-[var(--line)] text-[var(--muted)] hover:text-[var(--warn)] hover:border-[var(--warn)]40 transition",children:"📋 散朝"}),l.jsx("button",{onClick:fe,className:"text-xs px-2 py-1 rounded-lg border border-red-900/40 text-red-400/70 hover:text-red-400 transition",children:"✕"})]})]}),S&&l.jsxs("div",{className:"bg-gradient-to-br from-amber-950/40 to-purple-950/30 rounded-xl p-4 border border-amber-700/30",style:{animation:"fadeIn .3s"},children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-sm font-bold text-amber-400",children:"⚡ 天命降临 — 上帝视角"}),l.jsx("button",{onClick:()=>M(!1),className:"text-xs text-[var(--muted)]",children:"✕"})]}),l.jsx("p",{className:"text-[10px] text-amber-300/60 mb-2",children:"降下天意改变讨论走向,所有官员将对此做出反应"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{value:x,onChange:D=>A(D.target.value),onKeyDown:D=>D.key==="Enter"&&U(),placeholder:"例如:突然发现预算多出一倍...",className:"flex-1 bg-black/30 rounded-lg px-3 py-1.5 text-sm border border-amber-800/40 outline-none focus:border-amber-600"}),l.jsx("button",{onClick:U,disabled:!x.trim(),className:"px-4 py-1.5 rounded-lg bg-gradient-to-r from-amber-600 to-purple-600 text-white text-xs font-semibold disabled:opacity-40",children:"降旨"})]})]}),me&&l.jsxs("div",{className:"bg-purple-950/40 rounded-lg px-3 py-2 border border-purple-700/30 text-xs text-purple-300 flex items-center gap-2",style:{animation:"fadeIn .3s"},children:[l.jsx("span",{className:"text-lg",children:"🎲"}),me]}),V&&l.jsx("div",{className:"fixed inset-0 pointer-events-none z-50",style:{background:"radial-gradient(circle, rgba(255,200,50,0.3), transparent 70%)",animation:"fadeOut .8s forwards"}}),l.jsxs("div",{className:"text-xs text-center text-[var(--muted)] py-1",children:["📜 ",(L==null?void 0:L.topic)||""]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[280px_1fr] gap-3",children:[l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl p-3 border border-[var(--line)] relative overflow-hidden min-h-[320px]",children:[l.jsx("div",{className:"text-center mb-2",children:l.jsxs("div",{className:"inline-block px-3 py-1 rounded-lg bg-gradient-to-b from-amber-800/40 to-amber-950/40 border border-amber-700/30",children:[l.jsx("span",{className:"text-lg",children:"👑"}),l.jsx("div",{className:"text-[10px] text-amber-400/80",children:"龙 椅"})]})}),l.jsxs("div",{className:"relative",style:{minHeight:250},children:[l.jsx("div",{className:"absolute left-0 top-0 text-[9px] text-[var(--muted)] opacity-50",children:"三省"}),l.jsx("div",{className:"absolute right-0 top-0 text-[9px] text-[var(--muted)] opacity-50",children:"六部"}),H.map(D=>{const ce=jp[D.id]||{x:50,y:50},ye=Xi[D.id]||"#6a9eff",Be=Ae===D.id,Ke=oe[D.id]||"neutral";return l.jsxs("div",{className:"absolute transition-all duration-500",style:{left:`${ce.x}%`,top:`${ce.y}%`,transform:"translate(-50%, -50%)"},children:[Be&&l.jsx("div",{className:"absolute -inset-2 rounded-full",style:{background:`radial-gradient(circle, ${ye}40, transparent)`,animation:"pulse 1s infinite"}}),l.jsxs("div",{className:"relative w-10 h-10 rounded-full flex items-center justify-center text-lg border-2 transition-all",style:{borderColor:Be?ye:ye+"40",background:Be?ye+"30":ye+"10",transform:Be?"scale(1.2)":"scale(1)",boxShadow:Be?`0 0 16px ${ye}50`:"none"},children:[D.emoji,Ql[Ke]&&l.jsx("span",{className:"absolute -top-1 -right-1 text-xs",style:{animation:"bounceIn .3s"},children:Ql[Ke]})]}),l.jsx("div",{className:"text-[9px] text-center mt-0.5 whitespace-nowrap",style:{color:Be?ye:"var(--muted)"},children:D.name})]},D.id)})]})]}),l.jsxs("div",{className:"bg-[var(--panel)] rounded-xl border border-[var(--line)] flex flex-col",style:{maxHeight:500},children:[l.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",style:{minHeight:200},children:[ne.map((D,ce)=>l.jsx(wp,{msg:D,officials:H},ce)),T&&l.jsx("div",{className:"text-xs text-[var(--muted)] text-center py-2",style:{animation:"pulse 1.5s infinite"},children:"🏛 群臣正在思考..."}),l.jsx("div",{ref:le})]}),(L==null?void 0:L.phase)!=="concluded"&&l.jsxs("div",{className:"border-t border-[var(--line)] p-2 flex gap-2",children:[l.jsx("input",{value:j,onChange:D=>O(D.target.value),onKeyDown:D=>D.key==="Enter"&&G(),placeholder:"朕有话说...",className:"flex-1 bg-[var(--panel2)] rounded-lg px-3 py-1.5 text-sm border border-[var(--line)] outline-none focus:border-amber-600"}),l.jsx("button",{onClick:G,disabled:!j.trim()||T,className:"px-4 py-1.5 rounded-lg text-xs font-semibold border-0 disabled:opacity-40",style:{background:j.trim()?"linear-gradient(135deg, #e8a040, #f5c842)":"var(--panel2)",color:j.trim()?"#000":"var(--muted)"},children:"👑 发言"}),l.jsx("button",{onClick:()=>_(),disabled:T,className:"px-3 py-1.5 rounded-lg text-xs border border-[var(--acc)]40 text-[var(--acc)] hover:bg-[var(--acc)]10 disabled:opacity-40 transition",children:"▶ 下一轮"})]})]})]})]})}function wp({msg:o,officials:f}){var g;const c=Xi[o.official_id||""]||"#6a9eff",v=f.find(P=>P.id===o.official_id);return o.type==="system"?l.jsx("div",{className:"text-center text-[10px] text-[var(--muted)] py-1 border-b border-[var(--line)] border-dashed",children:o.content}):o.type==="scene_note"?l.jsxs("div",{className:"text-center text-[10px] text-purple-400/80 py-1 italic",children:["✦ ",o.content," ✦"]}):o.type==="emperor"?l.jsx("div",{className:"flex justify-end",children:l.jsxs("div",{className:"max-w-[80%] bg-gradient-to-br from-amber-900/40 to-amber-800/20 rounded-xl px-3 py-2 border border-amber-700/30",children:[l.jsx("div",{className:"text-[10px] text-amber-400 mb-0.5",children:"👑 皇帝"}),l.jsx("div",{className:"text-sm",children:o.content})]})}):o.type==="decree"?l.jsx("div",{className:"text-center py-2",children:l.jsxs("div",{className:"inline-block bg-gradient-to-r from-amber-900/30 via-purple-900/30 to-amber-900/30 rounded-lg px-4 py-2 border border-amber-600/30",children:[l.jsx("div",{className:"text-xs text-amber-400 font-bold",children:"⚡ 天命降临"}),l.jsx("div",{className:"text-sm mt-0.5",children:o.content})]})}):l.jsxs("div",{className:"flex gap-2 items-start",style:{animation:"fadeIn .4s"},children:[l.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-sm flex-shrink-0 border",style:{borderColor:c+"60",background:c+"15"},children:(v==null?void 0:v.emoji)||"💬"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[l.jsx("span",{className:"text-[11px] font-semibold",style:{color:c},children:o.official_name||"官员"}),o.emotion&&Ql[o.emotion]&&l.jsx("span",{className:"text-xs",children:Ql[o.emotion]})]}),l.jsx("div",{className:"text-sm leading-relaxed",children:(g=o.content)==null?void 0:g.split(/(\*[^*]+\*)/).map((P,L)=>P.startsWith("*")&&P.endsWith("*")?l.jsx("span",{className:"text-[var(--muted)] italic text-xs",children:P.slice(1,-1)},L):l.jsx("span",{children:P},L))})]})]})}function Np(){const o=ee(d=>d.activeTab),f=ee(d=>d.setActiveTab),c=ee(d=>d.liveStatus),v=ee(d=>d.countdown),g=ee(d=>d.loadAll);Q.useEffect(()=>(Uf(),()=>Hf()),[]);const P=(c==null?void 0:c.tasks)||[],L=P.filter(ln),z=L.filter(d=>!Vl(d)),T=c==null?void 0:c.syncStatus,E=T==null?void 0:T.ok,b=d=>d==="edicts"?String(z.length):d==="sessions"?String(P.filter(N=>!ln(N)).length):d==="memorials"?String(L.filter(N=>["Done","Cancelled"].includes(N.state)).length):d==="monitor"?P.filter(j=>ln(j)&&j.state==="Doing").length+"活跃":"";return l.jsxs("div",{className:"wrap",children:[l.jsxs("div",{className:"hdr",children:[l.jsxs("div",{children:[l.jsx("div",{className:"logo",children:"三省六部 · 总控台"}),l.jsx("div",{className:"sub-text",children:"OpenClaw Sansheng-Liubu Dashboard"})]}),l.jsxs("div",{className:"hdr-r",children:[l.jsx("span",{className:`chip ${E?"ok":E===!1?"err":""}`,children:E?"✅ 同步正常":E===!1?"❌ 服务器未启动":"⏳ 连接中…"}),l.jsxs("span",{className:"chip",children:[z.length," 道旨意"]}),l.jsx("button",{className:"btn-refresh",onClick:()=>g(),children:"⟳ 刷新"}),l.jsxs("span",{style:{fontSize:11,color:"var(--muted)"},children:["⟳ ",v,"s"]})]})]}),l.jsx("div",{className:"tabs",children:$f.map(d=>l.jsxs("div",{className:`tab ${o===d.key?"active":""}`,onClick:()=>f(d.key),children:[d.icon," ",d.label,b(d.key)&&l.jsx("span",{className:"tbadge",children:b(d.key)})]},d.key))}),o==="edicts"&&l.jsx(Gf,{}),o==="court"&&l.jsx(Sp,{}),o==="monitor"&&l.jsx(Yf,{}),o==="officials"&&l.jsx(Zf,{}),o==="models"&&l.jsx(tp,{}),o==="skills"&&l.jsx(rp,{}),o==="sessions"&&l.jsx(ip,{}),o==="memorials"&&l.jsx(ap,{}),o==="templates"&&l.jsx(up,{}),o==="morning"&&l.jsx(dp,{}),l.jsx(hp,{}),l.jsx(xp,{}),l.jsx(kp,{})]})}wf.createRoot(document.getElementById("root")).render(l.jsx(cu.StrictMode,{children:l.jsx(Np,{})})); diff --git a/dashboard/dist/index.html b/dashboard/dist/index.html index 773fe72..571880c 100644 --- a/dashboard/dist/index.html +++ b/dashboard/dist/index.html @@ -5,7 +5,7 @@ 三省六部 · Edict Dashboard - + diff --git a/dashboard/server.py b/dashboard/server.py index c13e6af..c2df395 100644 --- a/dashboard/server.py +++ b/dashboard/server.py @@ -1952,8 +1952,11 @@ def dispatch_for_state(task_id, task, new_state, trigger='state-transition'): 'lastDispatchTrigger': trigger, })) return + # Fix #139: dispatch channel 可配置(默认 feishu,支持 telegram/wecom/signal 等) + _agent_cfg = read_json(DATA / 'agent_config.json', {}) + _channel = (_agent_cfg.get('dispatchChannel') or 'feishu').strip() cmd = ['openclaw', 'agent', '--agent', agent_id, '-m', msg, - '--deliver', '--channel', 'feishu', '--timeout', '300'] + '--deliver', '--channel', _channel, '--timeout', '300'] max_retries = 2 err = '' for attempt in range(1, max_retries + 1): @@ -2466,6 +2469,19 @@ class Handler(BaseHTTPRequestHandler): threading.Thread(target=apply_async, daemon=True).start() self.send_json({'ok': True, 'message': f'Queued: {agent_id} → {model}'}) + # Fix #139: 设置派发渠道(feishu/telegram/wecom/signal/tui) + elif p == '/api/set-dispatch-channel': + channel = body.get('channel', '').strip() + allowed = {'feishu', 'telegram', 'wecom', 'signal', 'tui', 'discord', 'slack'} + if not channel or channel not in allowed: + self.send_json({'ok': False, 'error': f'channel must be one of: {", ".join(sorted(allowed))}'}, 400) + return + def _set_channel(cfg): + cfg['dispatchChannel'] = channel + return cfg + atomic_json_update(DATA / 'agent_config.json', _set_channel, {}) + self.send_json({'ok': True, 'message': f'派发渠道已切换为 {channel}'}) + # ── 朝堂议政 POST ── elif p == '/api/court-discuss/start': topic = body.get('topic', '').strip() diff --git a/edict/frontend/src/api.ts b/edict/frontend/src/api.ts index 69559dc..2657bd2 100644 --- a/edict/frontend/src/api.ts +++ b/edict/frontend/src/api.ts @@ -49,6 +49,8 @@ export const api = { // 操作类 setModel: (agentId: string, model: string) => postJ(`${API_BASE}/api/set-model`, { agentId, model }), + setDispatchChannel: (channel: string) => + postJ(`${API_BASE}/api/set-dispatch-channel`, { channel }), agentWake: (agentId: string) => postJ(`${API_BASE}/api/agent-wake`, { agentId }), taskAction: (taskId: string, action: string, reason: string) => @@ -190,6 +192,7 @@ export interface KnownModel { export interface AgentConfig { agents: AgentInfo[]; knownModels?: KnownModel[]; + dispatchChannel?: string; } export interface ChangeLogEntry { diff --git a/edict/frontend/src/components/ModelConfig.tsx b/edict/frontend/src/components/ModelConfig.tsx index f7d3cd1..bb07156 100644 --- a/edict/frontend/src/components/ModelConfig.tsx +++ b/edict/frontend/src/components/ModelConfig.tsx @@ -15,6 +15,16 @@ const FALLBACK_MODELS = [ { id: 'copilot/gemini-2.5-pro', l: 'Gemini 2.5 Pro', p: 'Copilot' }, ]; +const CHANNELS = [ + { id: 'feishu', label: '飞书 Feishu' }, + { id: 'telegram', label: 'Telegram' }, + { id: 'wecom', label: '企业微信 WeCom' }, + { id: 'discord', label: 'Discord' }, + { id: 'slack', label: 'Slack' }, + { id: 'signal', label: 'Signal' }, + { id: 'tui', label: 'TUI (终端)' }, +]; + export default function ModelConfig() { const agentConfig = useStore((s) => s.agentConfig); const changeLog = useStore((s) => s.changeLog); @@ -23,6 +33,8 @@ export default function ModelConfig() { const [selMap, setSelMap] = useState>({}); const [statusMap, setStatusMap] = useState>({}); + const [channelSel, setChannelSel] = useState('feishu'); + const [channelStatus, setChannelStatus] = useState(''); useEffect(() => { loadAgentConfig(); @@ -36,6 +48,9 @@ export default function ModelConfig() { }); setSelMap(m); } + if (agentConfig?.dispatchChannel) { + setChannelSel(agentConfig.dispatchChannel); + } }, [agentConfig]); if (!agentConfig?.agents) { @@ -116,6 +131,30 @@ export default function ModelConfig() { })} + {/* Dispatch Channel 配置 */} +
+
派发渠道
+
+ + + {channelStatus && {channelStatus}} +
+
自动派发时使用的 OpenClaw 通知渠道(需已在 openclaw.json 中配置对应 channel)
+
+ {/* Change Log */}
变更日志
diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..d6d70c1 --- /dev/null +++ b/install.ps1 @@ -0,0 +1,308 @@ +# ══════════════════════════════════════════════════════════════ +# 三省六部 · OpenClaw Multi-Agent System 一键安装脚本 (Windows) +# PowerShell 版本 — 对应 install.sh +# ══════════════════════════════════════════════════════════════ +#Requires -Version 5.1 +$ErrorActionPreference = "Stop" + +$REPO_DIR = Split-Path -Parent $MyInvocation.MyCommand.Path +$OC_HOME = Join-Path $env:USERPROFILE ".openclaw" +$OC_CFG = Join-Path $OC_HOME "openclaw.json" + +function Write-Banner { + Write-Host "" + Write-Host "╔══════════════════════════════════════════╗" -ForegroundColor Blue + Write-Host "║ 🏛️ 三省六部 · OpenClaw Multi-Agent ║" -ForegroundColor Blue + Write-Host "║ 安装向导 (Windows) ║" -ForegroundColor Blue + Write-Host "╚══════════════════════════════════════════╝" -ForegroundColor Blue + Write-Host "" +} + +function Log { param($msg) Write-Host "✅ $msg" -ForegroundColor Green } +function Warn { param($msg) Write-Host "⚠️ $msg" -ForegroundColor Yellow } +function Error { param($msg) Write-Host "❌ $msg" -ForegroundColor Red } +function Info { param($msg) Write-Host "ℹ️ $msg" -ForegroundColor Blue } + +# ── Step 0: 依赖检查 ── +function Check-Deps { + Info "检查依赖..." + + $oc = Get-Command openclaw -ErrorAction SilentlyContinue + if (-not $oc) { + Error "未找到 openclaw CLI。请先安装 OpenClaw: https://openclaw.ai" + exit 1 + } + Log "OpenClaw CLI: OK" + + $py = Get-Command python3 -ErrorAction SilentlyContinue + if (-not $py) { + $py = Get-Command python -ErrorAction SilentlyContinue + } + if (-not $py) { + Error "未找到 python3 或 python" + exit 1 + } + $global:PYTHON = $py.Source + Log "Python: $($global:PYTHON)" + + if (-not (Test-Path $OC_CFG)) { + Error "未找到 openclaw.json。请先运行 openclaw 完成初始化。" + exit 1 + } + Log "openclaw.json: $OC_CFG" +} + +# ── Step 0.5: 备份已有 Agent 数据 ── +function Backup-Existing { + $hasExisting = Get-ChildItem -Path $OC_HOME -Directory -Filter "workspace-*" -ErrorAction SilentlyContinue + if ($hasExisting) { + Info "检测到已有 Agent Workspace,自动备份中..." + $ts = Get-Date -Format "yyyyMMdd-HHmmss" + $backupDir = Join-Path $OC_HOME "backups\pre-install-$ts" + New-Item -ItemType Directory -Path $backupDir -Force | Out-Null + + Get-ChildItem -Path $OC_HOME -Directory -Filter "workspace-*" | ForEach-Object { + Copy-Item -Path $_.FullName -Destination (Join-Path $backupDir $_.Name) -Recurse + } + + if (Test-Path $OC_CFG) { + Copy-Item $OC_CFG (Join-Path $backupDir "openclaw.json") + } + Log "已备份到: $backupDir" + } +} + +# ── Step 1: 创建 Workspace ── +function Create-Workspaces { + Info "创建 Agent Workspace..." + + $agents = @("taizi","zhongshu","menxia","shangshu","hubu","libu","bingbu","xingbu","gongbu","libu_hr","zaochao") + foreach ($agent in $agents) { + $ws = Join-Path $OC_HOME "workspace-$agent" + New-Item -ItemType Directory -Path (Join-Path $ws "skills") -Force | Out-Null + + $soulSrc = Join-Path $REPO_DIR "agents\$agent\SOUL.md" + $soulDst = Join-Path $ws "SOUL.md" + if (Test-Path $soulSrc) { + if (Test-Path $soulDst) { + $ts = Get-Date -Format "yyyyMMdd-HHmmss" + Copy-Item $soulDst "$soulDst.bak.$ts" + Warn "已备份旧 SOUL.md → $soulDst.bak.$ts" + } + $content = (Get-Content $soulSrc -Raw) -replace "__REPO_DIR__", $REPO_DIR + Set-Content -Path $soulDst -Value $content -Encoding UTF8 + } + Log "Workspace 已创建: $ws" + + # AGENTS.md + $agentsMd = @" +# AGENTS.md · 工作协议 + +1. 接到任务先回复"已接旨"。 +2. 输出必须包含:任务ID、结果、证据/文件路径、阻塞项。 +3. 需要协作时,回复尚书省请求转派,不跨部直连。 +4. 涉及删除/外发动作必须明确标注并等待批准。 +"@ + Set-Content -Path (Join-Path $ws "AGENTS.md") -Value $agentsMd -Encoding UTF8 + } +} + +# ── Step 2: 注册 Agents ── +function Register-Agents { + Info "注册三省六部 Agents..." + + $ts = Get-Date -Format "yyyyMMdd-HHmmss" + Copy-Item $OC_CFG "$OC_CFG.bak.sansheng-$ts" + Log "已备份配置: $OC_CFG.bak.*" + + $pyScript = @" +import json, pathlib, sys, os + +cfg_path = pathlib.Path(os.environ['USERPROFILE']) / '.openclaw' / 'openclaw.json' +cfg = json.loads(cfg_path.read_text(encoding='utf-8')) + +AGENTS = [ + {"id": "taizi", "subagents": {"allowAgents": ["zhongshu"]}}, + {"id": "zhongshu", "subagents": {"allowAgents": ["menxia", "shangshu"]}}, + {"id": "menxia", "subagents": {"allowAgents": ["shangshu", "zhongshu"]}}, + {"id": "shangshu", "subagents": {"allowAgents": ["zhongshu", "menxia", "hubu", "libu", "bingbu", "xingbu", "gongbu", "libu_hr"]}}, + {"id": "hubu", "subagents": {"allowAgents": ["shangshu"]}}, + {"id": "libu", "subagents": {"allowAgents": ["shangshu"]}}, + {"id": "bingbu", "subagents": {"allowAgents": ["shangshu"]}}, + {"id": "xingbu", "subagents": {"allowAgents": ["shangshu"]}}, + {"id": "gongbu", "subagents": {"allowAgents": ["shangshu"]}}, + {"id": "libu_hr", "subagents": {"allowAgents": ["shangshu"]}}, + {"id": "zaochao", "subagents": {"allowAgents": []}}, +] + +agents_cfg = cfg.setdefault('agents', {}) +agents_list = agents_cfg.get('list', []) +existing_ids = {a['id'] for a in agents_list} + +added = 0 +for ag in AGENTS: + ag_id = ag['id'] + ws = str(pathlib.Path(os.environ['USERPROFILE']) / f'.openclaw/workspace-{ag_id}') + if ag_id not in existing_ids: + entry = {'id': ag_id, 'workspace': ws, **{k:v for k,v in ag.items() if k!='id'}} + agents_list.append(entry) + added += 1 + print(f' + added: {ag_id}') + else: + print(f' ~ exists: {ag_id} (skipped)') + +agents_cfg['list'] = agents_list + +# Fix #142: clean invalid binding pattern +bindings = cfg.get('bindings', []) +for b in bindings: + match = b.get('match', {}) + if isinstance(match, dict) and 'pattern' in match: + del match['pattern'] + print(f' cleaned invalid pattern from binding: {b.get("agentId", "?")}') + +cfg_path.write_text(json.dumps(cfg, ensure_ascii=False, indent=2), encoding='utf-8') +print(f'Done: {added} agents added') +"@ + & $global:PYTHON -c $pyScript + Log "Agents 注册完成" +} + +# ── Step 3: 初始化 Data ── +function Init-Data { + Info "初始化数据目录..." + $dataDir = Join-Path $REPO_DIR "data" + New-Item -ItemType Directory -Path $dataDir -Force | Out-Null + + foreach ($f in @("live_status.json","agent_config.json","model_change_log.json")) { + $fp = Join-Path $dataDir $f + if (-not (Test-Path $fp)) { Set-Content $fp "{}" -Encoding UTF8 } + } + Set-Content (Join-Path $dataDir "pending_model_changes.json") "[]" -Encoding UTF8 + Log "数据目录初始化完成" +} + +# ── Step 3.3: 创建 data/scripts 目录连接 (Junction) ── +function Link-Resources { + Info "创建 data/scripts 目录连接..." + $linked = 0 + $agents = @("taizi","zhongshu","menxia","shangshu","hubu","libu","bingbu","xingbu","gongbu","libu_hr","zaochao") + foreach ($agent in $agents) { + $ws = Join-Path $OC_HOME "workspace-$agent" + New-Item -ItemType Directory -Path $ws -Force | Out-Null + + # data 目录 + $wsData = Join-Path $ws "data" + $srcData = Join-Path $REPO_DIR "data" + if (-not (Test-Path $wsData)) { + cmd /c mklink /J "$wsData" "$srcData" | Out-Null + $linked++ + } elseif (-not ((Get-Item $wsData).Attributes -band [IO.FileAttributes]::ReparsePoint)) { + $ts = Get-Date -Format "yyyyMMdd-HHmmss" + Rename-Item $wsData "$wsData.bak.$ts" + cmd /c mklink /J "$wsData" "$srcData" | Out-Null + $linked++ + } + + # scripts 目录 + $wsScripts = Join-Path $ws "scripts" + $srcScripts = Join-Path $REPO_DIR "scripts" + if (-not (Test-Path $wsScripts)) { + cmd /c mklink /J "$wsScripts" "$srcScripts" | Out-Null + $linked++ + } elseif (-not ((Get-Item $wsScripts).Attributes -band [IO.FileAttributes]::ReparsePoint)) { + $ts = Get-Date -Format "yyyyMMdd-HHmmss" + Rename-Item $wsScripts "$wsScripts.bak.$ts" + cmd /c mklink /J "$wsScripts" "$srcScripts" | Out-Null + $linked++ + } + } + Log "已创建 $linked 个目录连接 (data/scripts → 项目目录)" +} + +# ── Step 3.5: 设置 Agent 间通信可见性 ── +function Setup-Visibility { + Info "配置 Agent 间消息可见性..." + try { + openclaw config set tools.sessions.visibility all 2>$null + Log "已设置 tools.sessions.visibility=all" + } catch { + Warn "设置 visibility 失败,请手动执行: openclaw config set tools.sessions.visibility all" + } +} + +# ── Step 4: 构建前端 ── +function Build-Frontend { + Info "构建 React 前端..." + $node = Get-Command node -ErrorAction SilentlyContinue + if (-not $node) { + Warn "未找到 node,跳过前端构建。" + Warn "请安装 Node.js 18+ 后运行: cd edict\frontend && npm install && npm run build" + return + } + $pkgJson = Join-Path $REPO_DIR "edict\frontend\package.json" + if (Test-Path $pkgJson) { + Push-Location (Join-Path $REPO_DIR "edict\frontend") + npm install --silent 2>$null + npm run build 2>$null + Pop-Location + $indexHtml = Join-Path $REPO_DIR "dashboard\dist\index.html" + if (Test-Path $indexHtml) { + Log "前端构建完成: dashboard\dist\" + } else { + Warn "前端构建可能失败,请手动检查" + } + } +} + +# ── Step 5: 首次数据同步 ── +function First-Sync { + Info "执行首次数据同步..." + Push-Location $REPO_DIR + $env:REPO_DIR = $REPO_DIR + try { & $global:PYTHON scripts/sync_agent_config.py } catch { Warn "sync_agent_config 有警告" } + try { & $global:PYTHON scripts/sync_officials_stats.py } catch { Warn "sync_officials_stats 有警告" } + try { & $global:PYTHON scripts/refresh_live_data.py } catch { Warn "refresh_live_data 有警告" } + Pop-Location + Log "首次同步完成" +} + +# ── Step 6: 重启 Gateway ── +function Restart-Gateway { + Info "重启 OpenClaw Gateway..." + try { + openclaw gateway restart 2>$null + Log "Gateway 重启成功" + } catch { + Warn "Gateway 重启失败,请手动重启: openclaw gateway restart" + } +} + +# ── Main ── +Write-Banner +Check-Deps +Backup-Existing +Create-Workspaces +Register-Agents +Init-Data +Link-Resources +Setup-Visibility +Build-Frontend +First-Sync +Restart-Gateway + +Write-Host "" +Write-Host "╔══════════════════════════════════════════════════╗" -ForegroundColor Green +Write-Host "║ 🎉 三省六部安装完成! ║" -ForegroundColor Green +Write-Host "╚══════════════════════════════════════════════════╝" -ForegroundColor Green +Write-Host "" +Write-Host "下一步:" +Write-Host " 1. 配置 API Key(如尚未配置):" +Write-Host " openclaw agents add taizi # 按提示输入 Anthropic API Key" +Write-Host " .\install.ps1 # 重新运行以同步到所有 Agent" +Write-Host " 2. 启动数据刷新循环: Start-Process python3 -ArgumentList 'scripts/run_loop.sh'" +Write-Host " 3. 启动看板服务器: python3 dashboard/server.py" +Write-Host " 4. 打开看板: http://127.0.0.1:7891" +Write-Host "" +Warn "首次安装必须配置 API Key,否则 Agent 会报错" +Info "文档: docs/getting-started.md" diff --git a/install.sh b/install.sh index c99002d..992c0b8 100755 --- a/install.sh +++ b/install.sh @@ -165,6 +165,19 @@ for ag in AGENTS: print(f' ~ exists: {ag_id} (skipped)') agents_cfg['list'] = agents_list + +# Fix #142: 清理 bindings 中的非法字段(pattern 不被 gateway 支持) +bindings = cfg.get('bindings', []) +cleaned = 0 +for b in bindings: + match = b.get('match', {}) + if isinstance(match, dict) and 'pattern' in match: + del match['pattern'] + cleaned += 1 + print(f' 🧹 cleaned invalid "pattern" from binding: {b.get("agentId", "?")}') +if cleaned: + print(f'Cleaned {cleaned} invalid binding field(s)') + cfg_path.write_text(json.dumps(cfg, ensure_ascii=False, indent=2)) print(f'Done: {added} agents added') PYEOF diff --git a/scripts/sync_agent_config.py b/scripts/sync_agent_config.py index 7d6f03d..0e280b1 100644 --- a/scripts/sync_agent_config.py +++ b/scripts/sync_agent_config.py @@ -165,10 +165,20 @@ def main(): 'isDefaultModel': True, }) + # 保留已有的 dispatchChannel 配置 (Fix #139) + existing_cfg = {} + cfg_path = DATA / 'agent_config.json' + if cfg_path.exists(): + try: + existing_cfg = json.loads(cfg_path.read_text()) + except Exception: + pass + payload = { 'generatedAt': datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), 'defaultModel': default_model, 'knownModels': merged_models, + 'dispatchChannel': existing_cfg.get('dispatchChannel', 'feishu'), 'agents': result, } DATA.mkdir(exist_ok=True)